/** SDK-owned platform module. This implementation is maintained in goodvibes-sdk. */ import { type ReplayIntoConversationResult } from './transcript-journal-replay.js'; import type { ConversationManager, ConversationMessageSnapshot } from '../core/conversation.js'; import type { SessionSurface } from './session-surface.js'; declare const recoveryRestoreConfirmationBrand: unique symbol; /** * Proof that a user was asked whether to restore a recovery snapshot and said * yes. Cannot be constructed by a literal, {@link confirmRecoveryRestore} is * the only source. */ export interface RecoveryRestoreConfirmation { readonly [recoveryRestoreConfirmationBrand]: true; } /** * Turn a user's answer into the token {@link applyRecoverySnapshot} requires. * * Call this with the result of an actual question put to the user. `false` * yields null, so a surface that passes an unanswered or declined prompt * straight through gets nothing to apply with. * * @param userSaidYes - What the user answered. Not a setting, not a default. */ export declare function confirmRecoveryRestore(userSaidYes: boolean): RecoveryRestoreConfirmation | null; /** * What restoring needs a conversation to be able to do. * * `rebuildHistory` is optional for the same reason it is in journal replay: it * is a rendering concern, and a headless surface has nothing to re-lay-out. */ export type RestorableConversation = Pick & { rebuildHistory?: () => void; }; export interface ApplyRecoverySnapshotOptions { /** The surface that owns the session's storage, where the snapshot and journal live. */ readonly surface: SessionSurface; /** The session whose recovery snapshot is being restored. */ readonly sessionId: string; /** The live conversation to restore into. */ readonly conversation: RestorableConversation; /** * Persist the restored conversation so the gap is durably closed. Best-effort *, a failure here does not fail the restore, the same contract journal * replay keeps. */ readonly persistSnapshot: (messages: ConversationMessageSnapshot[]) => void; /** The user's answer, from {@link confirmRecoveryRestore}. */ readonly confirmation: RecoveryRestoreConfirmation; } /** Why a restore did not happen. Each value is a fact a surface can report as-is. */ export type RecoveryApplyRefusal = /** Nothing was on disk to consume, or the file could not be read. The snapshot, if any, was left alone. */ 'no-snapshot' /** A snapshot loaded but did not contain a conversation. It was already retired by the load. */ | 'unusable-snapshot' /** The conversation rejected the restored state. The snapshot was already retired by the load. */ | 'apply-failed'; export interface ApplyRecoverySnapshotResult { /** True when the conversation now holds the recovered messages. */ readonly applied: boolean; /** Set when `applied` is false. */ readonly refusal?: RecoveryApplyRefusal | undefined; /** * True once the snapshot file is gone. Always true after a successful apply, * and true for the refusals that follow a successful load, the read is what * retires the file, so a snapshot that loaded is retired whether or not its * contents turned out to be usable. */ readonly retired: boolean; /** Messages the conversation holds once the snapshot (plus any journal tail) is in place. 0 when nothing was applied. */ readonly messageCount: number; /** Journal records that post-dated the snapshot and were folded in on top of it. */ readonly journalReplay: ReplayIntoConversationResult; } /** * Restore the recovery snapshot the user asked for, retiring it in the process. * * The sequence is the one a normal resume runs, reset, fromJSON, * rebuildHistory, then fold in journal records newer than the snapshot, with * the messages coming from the retired recovery file instead of the session * store. * * Never throws: a failed restore reports a refusal so the surface can say what * happened, because a crash-recovery path that itself crashes takes the boot * down with it. */ export declare function applyRecoverySnapshot(options: ApplyRecoverySnapshotOptions): ApplyRecoverySnapshotResult; export {}; //# sourceMappingURL=recovery-snapshot-apply.d.ts.map