import type { ConversationEventV1, PromptReceipt } from './conversation-types.js'; export interface ConversationStoreOptions { roleId: string; segmentBytes?: number; log?(line: string): void; } export interface OpenPrompt { promptId: string; state: 'admitted' | 'started'; /** The prompt body, when it was persisted (browser/local sources). */ text?: string; commandId?: string; sessionGeneration: string; } export interface ConversationPageRequest { after?: string; limit?: number; } export interface ConversationStorePage { events: ConversationEventV1[]; firstAvailableCursor?: string; nextCursor?: string; hasMore: boolean; } export declare class IdempotencyConflictError extends Error { constructor(); } type EventDraft = Omit; export declare class ConversationEventStore { private readonly dir; private nextSeq; private segments; private tail; private readonly listeners; private readonly commands; private readonly promptStates; private activeFd?; private activeBytes; private _degraded; private degradedReason?; private readonly segmentBytes; private readonly roleId; private readonly log; constructor(dir: string, options: ConversationStoreOptions); /** First 24 hex chars of sha-256; the idempotency body-digest convention. */ static bodyDigest(body: string): string; get degraded(): boolean; get degradedDetail(): string | undefined; /** * Durably append one event. Throws when the record cannot be persisted — * the caller must fail its command rather than acknowledge a lost prompt. */ append(draft: EventDraft): ConversationEventV1; /** * Append an agent-stream event; on failure record degradation and keep the * role alive. Conversation durability may degrade, active work must not die. */ appendSafe(draft: EventDraft): ConversationEventV1 | undefined; page(request?: ConversationPageRequest): ConversationStorePage; subscribe(listener: (event: ConversationEventV1) => void): () => void; /** Store the receipt a repeated command must get back. */ recordReceipt(commandId: string, receipt: PromptReceipt, bodyDigest: string): void; /** * The receipt for a previously accepted command, or undefined for a new one. * A reused ID with a different body digest is a conflict, never a replay. */ receiptFor(commandId: string, bodyDigest: string): PromptReceipt | undefined; /** * Prompts with no terminal event, classified for restart recovery: * `admitted` never started and is safe to restore into the FIFO; * `started` may already have had side effects and must not be replayed. */ openPrompts(): OpenPrompt[]; lastCursor(): string | undefined; close(): void; private recover; private readManifest; private discoverSegments; private readSegment; private rebuildCommandIndex; private trackPromptState; private segmentFd; private writeManifest; private firstStoredSeq; private eventsAfter; private markDegraded; } export {};