import type { AddUserProject, AddUserProjectResult, AgentState, BackgroundJob, BackgroundJobCursor, BackgroundJobDetail, BackgroundJobPage, ChannelPage, ChannelRecord, ChannelScanCursor, ChannelScanPage, ClaimBackgroundJobs, CommitChannel, CommitResult, ControlBackgroundJob, CreateChannel, CreateWebSession, EnqueueBackgroundJob, FailBackgroundJob, Lease, PauseBackgroundJob, PutUser, RecordNavigationVisit, RenameChannel, RenameResult, RenewBackgroundJob, ReplaceChannel, RequeueBackgroundJob, ResumeBackgroundJob, SaveCheckpoint, SettleBackgroundJob, StoredChannel, SupersedeBackgroundJob, 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; } export interface BackgroundJobStore { enqueue(input: EnqueueBackgroundJob): Promise<{ job: BackgroundJob; repeated: boolean }>; claim(input: ClaimBackgroundJobs): Promise; renew(input: RenewBackgroundJob): Promise; requeue(input: RequeueBackgroundJob): Promise; settle(input: SettleBackgroundJob): Promise; pause(input: PauseBackgroundJob): Promise; resume(input: ResumeBackgroundJob): Promise; fail(input: FailBackgroundJob): Promise; cancel(input: ControlBackgroundJob): Promise; supersede(input: SupersedeBackgroundJob): Promise; list( channelId: string, limit: number, after?: BackgroundJobCursor, ): Promise; get(channelId: string, jobId: string): 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; readonly jobs: BackgroundJobStore; migrate(): Promise; health(): Promise; close(): Promise; }