import { BaseCheckpointSaver } from '@langchain/langgraph'; import { type HistoryConfigView } from '#src/history/historyEnabled.js'; /** The checkpointer a session drives, plus what the session needs to know about it. */ export interface SessionCheckpointer { /** The saver to hand to `GthAgentRunner.init` / `GthAgentInterface.init`. Never null. */ saver: BaseCheckpointSaver; /** * True when checkpoints are reaching disk — i.e. when this session can be resumed later. False * for a `MemorySaver`, whether that is the deliberate opt-out or the fallback. */ durable: boolean; /** * The LangGraph thread this session's state is stored under, minted here so the conversation row * can record it BEFORE the runner is initialised — `init` can throw partway, and a conversation * whose thread id was never written is a listing entry that can never be resumed. */ threadId: string; /** * Name the conversation row this session's turns group under, so a later checkpoint-write failure * can mark it unresumable ON DISK. Call once per conversation the session records under: * immediately after `openConversationSafe`, and again when a mid-session `/resume` moves the * session onto another conversation — the saver is the same, so the row it would mark has to * follow the session. Passing `undefined` (history off, or the row could not be opened) is fine * and simply leaves nothing to mark. Safe to call before or after a failure has already happened * — a failure that arrives first is applied here instead, and a rebind after one marks the new * row too, which is correct: a saver that has stopped writing is truncating whichever * conversation it is now on. Never throws. * * **Optional on the interface, and called with `?.`**, because a dozen-odd specs stub * `openSessionCheckpointerSafe` with a plain object literal to keep a session off the real * database. Requiring it would break every one of them at runtime for no gain: a stub that omits * it simply has no conversation to mark, which is the correct behaviour for a test that is not * about this. */ bindConversation?(conversationId: number | undefined): void; /** * GS2-106 — whether a checkpoint write has failed in this session, so its conversation's link * has been (or, once bound, will be) cut. A single-shot run reads it before printing its continue * hint: a hint naming a conversation whose link was just cut would name an id that refuses. * Optional for the same reason as {@link bindConversation}. */ isDegraded?(): boolean; /** Release the underlying connection (a no-op when the saver is in memory). Never throws. */ close(): void; } export interface OpenSessionCheckpointerOptions { /** Drive a specific thread instead of a fresh one — how a resume re-enters a stored thread. */ threadId?: string; /** * Where the fallback notice goes. Defaults to {@link displayWarning}; injectable so a caller on a * managed surface can route it, and so a test can read it without mocking the console. */ notify?: (message: string) => void; } export declare function openSessionCheckpointerSafe(config: HistoryConfigView, options?: OpenSessionCheckpointerOptions): SessionCheckpointer;