import type { AgentState, ChannelPage, ChannelRecord, ChannelScanCursor, ChannelScanPage, CommitChannel, CommitResult, CreateChannel, CreateWebSession, Lease, PutUser, ReplaceChannel, SaveCheckpoint, StoredChannel, UpdateAgentContext, UserRecord, WebSession, } from "./model"; export interface UserStore { put(user: PutUser): Promise; get(id: string): Promise; } export interface SessionStore { create(session: CreateWebSession): Promise; get(id: string, now: Date): Promise; delete(id: string): Promise; deleteExpired(now: Date): Promise; deleteAll( now: Date, lease: Lease, leaseTtlMs: number, ): Promise<{ deleted: number; lease: Lease }>; } export interface ChannelStore { create(channel: CreateChannel): Promise; get(id: string): Promise; list(repositoryId: string, limit: number, after?: { updatedAt: Date; id: string; }): Promise; scan(repositoryId: string, limit: number, after?: ChannelScanCursor): Promise; claimAgentOwner(channelId: string, sessionId: string, now: Date): Promise; clearAgentOwner( channelId: string, expectedSessionId: string, expectedGeneration: number, now: Date, ): Promise; updateAgentContext(context: UpdateAgentContext): Promise; } export interface CollaborationStore { load(channelId: string, now: Date): Promise; commit(input: CommitChannel): Promise; replace(input: ReplaceChannel): Promise; checkpoint(input: SaveCheckpoint): Promise; } export interface LeaseStore { acquire(name: string, owner: string, ttlMs: number): Promise; renew(lease: Lease, ttlMs: number): Promise; release(lease: Lease): Promise; } /** The complete durable boundary. No provider-specific primitive crosses it. */ export interface StorageAdapter { readonly driver: string; readonly users: UserStore; readonly sessions: SessionStore; readonly channels: ChannelStore; readonly collaboration: CollaborationStore; readonly leases: LeaseStore; migrate(): Promise; health(): Promise; close(): Promise; }