import { type Conversation } from "./protocol.js"; import type { EventRecord } from "./store-event-presentation.js"; export { messageEvent, rawExchangeEvent, type EventRecord } from "./store-event-presentation.js"; declare const STORE_SCHEMA = "agent-knock-knock/store"; export declare const STORE_DEFERRED_FOREGROUND_TRANSFERS_DIRECTORY = "deferred-foreground-transfers"; export declare const STORE_TERMINAL_WATCHES_DIRECTORY = "terminal-watches"; export declare const STORE_FORMAT_VERSION = 1; export declare const STORE_WRITER_PROTOCOL = 7; export declare const STORE_SESSION_AUTHORITY_PROTOCOL = 3; export interface StoreManifest { schema: typeof STORE_SCHEMA; format_version: number; writer_protocol: number; created_at: string; } export interface StoreCompatibility { status: "uninitialized" | "legacy" | "upgradeable" | "compatible" | "incompatible"; store_dir: string; manifest_path: string; readable: boolean; writable: boolean; upgradeable?: boolean; format_version?: number; writer_protocol?: number; reason?: string; } declare const STORE_WRITER_LEASE_BRAND: unique symbol; export interface StoreWriterLease { readonly storeDir: string; readonly manifest: Readonly; readonly [STORE_WRITER_LEASE_BRAND]: true; } export declare class StoreCompatibilityError extends Error { readonly code = "AKK_STORE_INCOMPATIBLE"; readonly compatibility: StoreCompatibility; constructor(message: string, compatibility: StoreCompatibility); } export declare class StoreLockTimeoutError extends Error { readonly code = "AKK_STORE_LOCK_TIMEOUT"; readonly lockPath: string; readonly lockKind: "writer" | "conversation"; constructor(lockPath: string); } export declare function defaultStoreDir(_workspace?: string): string; export declare function defaultLogDir(workspace?: string): string; export declare function ensureDir(dir: string): void; export interface ConversationPaths { storeDir: string; logDir: string; conversationDir: string; logPath: string; statePath: string; } export declare function storeManifestPath(storeDir?: string): string; export declare function storeConversationsDir(storeDir?: string): string; export declare function storeSessionsDir(storeDir?: string): string; export declare function inspectStoreCompatibility(storeDir?: string): StoreCompatibility; export declare function assertStoreReadable(storeDir?: string): StoreCompatibility; /** * Validate whether this binary may write the selected store without creating or * repairing anything. An absent or empty store is writable because its first * real mutation may initialize the manifest. */ export declare function assertStoreWriterCompatible(storeDir?: string): StoreCompatibility; export declare function ensureStoreWritable(storeDir?: string): StoreManifest; /** * Hold the store's writer lock for one synchronous mutation boundary. Nested * calls for the same store reuse the active lease, so saveState/appendEvent can * safely enforce the guard without deadlocking a command-level lease. */ export declare function withStoreWriterLease(storeDir: string, action: (lease: StoreWriterLease) => T): T; /** Hold the store writer lease until an asynchronous side effect and commit finish. */ export declare function withStoreWriterLeaseAsync(storeDir: string, action: (lease: StoreWriterLease) => Promise, options?: { timeoutMs?: number; }): Promise; export declare function pathsForConversation(conversationId: string, storeDir?: string): ConversationPaths; export declare function pathsForConversationDir(conversationDir: string): ConversationPaths; export declare function logPathForStatePath(statePath: string): string; export declare function saveState(statePath: string, conversation: Conversation): void; /** * Persist the user-facing half of an explicit management-only Close even when * this Turn is frozen in deferred source history. All ordinary state/path * checks remain in force; only this exact closed disposition bypasses the * source-history mutation fence. */ export declare function saveExplicitUserCloseState(statePath: string, conversation: Conversation): void; export declare function loadState(statePath: string): Conversation; export declare function statePathForConversationId(conversationId: string, storeDir?: string): string; export declare function loadConversationById(conversationId: string, storeDir?: string): Conversation; export declare function listConversations(storeDir?: string): Conversation[]; export declare function appendEvent(logPath: string, event: EventRecord): void; /** Append only the exact audit event paired with saveExplicitUserCloseState. */ export declare function appendExplicitUserCloseEvent(logPath: string, event: EventRecord): void; export declare function assertAppendableEventLog(logPath: string): true;