import type { AddUserProject, AddUserProjectResult, AgentState, ChannelPage, ChannelRecord, ChannelScanCursor, ChannelScanPage, CommitChannel, CommitResult, CreateChannel, CreateWebSession, Lease, PutUser, RecordNavigationVisit, RenameChannel, RenameResult, ReplaceChannel, SaveCheckpoint, StoredChannel, UpdateAgentContext, UserNavigation, UserProject, 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 NavigationStore { projects(userId: string): Promise; addProject(input: AddUserProject): Promise; get(userId: string): Promise; setLastDocument( userId: string, documentId: string | undefined, now: Date, ): Promise; recordVisit(input: RecordNavigationVisit): Promise; } export interface ChannelStore { create(channel: CreateChannel): Promise; get(id: string): Promise; resolve(repositoryId: string, slug: string): Promise; rename(channel: RenameChannel): Promise; list(repositoryId: string, limit: number, after?: { updatedAt: Date; id: string; }, query?: 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 navigation: NavigationStore; readonly channels: ChannelStore; readonly collaboration: CollaborationStore; readonly leases: LeaseStore; migrate(): Promise; health(): Promise; close(): Promise; }