import type { HistoryMessage } from "./context/index.js"; import type { ConversationHistoryProviderSessionTurn, ConversationHistoryContextImport, ConversationHistoryStore, PreparedHistoryAppend, ProviderSessionTurnBinding } from "./types.js"; export interface DurableHistoryStoreOptions { /** Owner-only directory containing one content-addressed file per conversation. */ readonly root: string; /** Retained messages per conversation. Defaults to, and may not exceed, 64. */ readonly maxMessages?: number; /** Aggregate committed-history quota. Defaults to 256 MiB. */ readonly maxStoreBytes?: number; /** Aggregate unpublished-stage quota. Defaults to `maxStoreBytes`. */ readonly maxStagedBytes?: number; /** Maximum committed conversations. Defaults to 10,000. */ readonly maxConversations?: number; /** Maximum inactive conversation-file age. Defaults to 365 days. */ readonly maxAgeMs?: number; /** Injectable clock for deterministic retention and tests. */ readonly now?: () => number; /** * Fail-closed removal of an exact provider-session id. When present, this * store may coordinate durable provider sessions across processes; every * epoch made unreachable is retired before the owning history mutation. */ readonly retireProviderSession?: (providerSessionId: string, modelKey?: string) => Promise; } export interface DurableHistoryStoreStats { readonly conversations: number; readonly bytes: number; readonly activePreparedAppends: number; readonly postCommitMaintenanceFailures: number; readonly lastPostCommitMaintenanceError?: string; readonly limits: { readonly maxMessages: number; readonly maxStoreBytes: number; readonly maxStagedBytes: number; readonly maxConversations: number; readonly maxAgeMs: number; }; } /** * Restart-durable conversation history with bounded, owner-only, atomic files. * * Conversation ids never become path components: their normalized exact value * is stored in the file while a SHA-256 digest selects the filename. Prepared * appends are fully validated and fsynced but remain invisible until commit's * atomic rename. SQLite-backed OS locks serialize same-conversation turns and * root retention across both store instances and independent processes. */ export declare class DurableConversationHistoryStore implements ConversationHistoryStore { readonly providerSessionModelBinding: "v1"; readonly providerSessionRecovery: "v1"; readonly providerSessionRetirement: "fail-closed" | undefined; readonly contextImport: ConversationHistoryContextImport | undefined; private readonly root; private readonly maxMessages; private readonly maxStoreBytes; private readonly maxStagedBytes; private readonly maxConversations; private readonly maxAgeMs; private readonly now; private readonly retireProviderSession; private rootReady; private locksRootReady; constructor(options: DurableHistoryStoreOptions); load(conversationId: string): Promise; append(conversationId: string, messages: readonly HistoryMessage[]): Promise; reset(conversationId: string): Promise; resetLogicalConversation(logicalConversationId: string): Promise; private resetDirtyFencesForLogicalConversation; private resetPhysicalConversation; private resetHeldPhysicalConversation; prepareAppend(conversationId: string, messages: readonly HistoryMessage[]): Promise; private beginExclusiveTurn; private prepareContextImport; beginProviderSessionTurn(conversationId: string, runId: string, binding?: ProviderSessionTurnBinding): Promise; stats(): Promise; private prepareRecord; private projectRecord; private findDirtyFence; private reserveDirtyFenceCapacity; private publishDirtyFence; private writeStage; private createPreparedAppend; private removeDirtyFenceAfterCommit; private validateRetentionReservation; private validateStagingReservation; private applyRetention; private retentionPlan; private scanStagedBytes; private scanCommittedEntries; private ensureRoot; private ensureLocksRoot; private acquireRootTransaction; private acquireConversation; private acquireLogicalConversation; private acquireExactConversationClaim; private releaseConversation; private createActiveMarker; private removeActiveMarker; private scanActiveMarkers; private scanDirtyFences; private retireInactiveDirtyFences; private readRecord; private readRecordOnce; private prepareProviderRetirement; private ensureRetirementFence; private providerSessionsForRetirement; private readCommittedEntryRecord; private rotateCommittedProviderEpoch; private retireProviderSessions; private recordPath; private queueKey; } export declare function createDurableHistoryStore(options: DurableHistoryStoreOptions): DurableConversationHistoryStore; //# sourceMappingURL=durable-history.d.ts.map