import type { TurnRecorder } from '../../manager/session/turn-recorder.js'; import type { SessionCheckpointStore } from '../../store/checkpoint/index.js'; import type { SessionLog } from '../../store/session-log/index.js'; import type { CheckpointId, MessageId, ProjectId, SessionId, TenantId, TopicId, TurnId } from '../../types/ids/index.js'; import type { Message } from '../../types/message/index.js'; import type { Checkpoint } from '../../types/session/checkpoint.js'; import { type TurnState } from '../../types/session/turn-state.js'; /** * Where a turn's durable state lives: the full attribution, so a shared * backend can enforce isolation. */ export interface TurnStateScope { readonly tenantId: TenantId; readonly projectId: ProjectId; readonly topicId: TopicId; readonly sessionId: SessionId; readonly turnId: TurnId; /** Present on a child session's turn. */ readonly parentSessionId?: SessionId; /** Present on a child session's turn. */ readonly parentTurnId?: TurnId; } /** * Snapshot a live turn into a {@link TurnState} a different process can * resume. Every field is copied, not referenced: the caller is about to * serialize it. */ export declare function captureTurnState(recorder: TurnRecorder, scope: TurnStateScope, extra?: { elapsedMs?: number; checkpoint?: Checkpoint | null; }): TurnState; /** * Read a turn's state back from its checkpoint and the session log. The * parked checkpoint if there is one, else the newest; `null` when the turn * has none — a turn that never checkpointed left nothing to resume from. * * `status` is `running`: a checkpoint is written mid-flight. Read `pending` * to tell a parked turn from a live one. */ export declare function loadTurnState(log: SessionLog, store: SessionCheckpointStore, scope: TurnStateScope, checkpointId?: CheckpointId): Promise; /** {@link loadTurnState}, also returning the checkpoint document it was read from. */ export declare function loadSelectedTurnState(log: SessionLog, store: SessionCheckpointStore, scope: TurnStateScope, checkpointId?: CheckpointId): Promise<{ readonly state: TurnState; readonly checkpoint: Checkpoint; } | null>; /** * @internal {@link loadSelectedTurnState} plus the record ids of the restored * messages, which a resume in this process adopts so the log keeps one * record per message. */ export declare function loadSelectedTurnContext(log: SessionLog, store: SessionCheckpointStore, scope: TurnStateScope, checkpointId?: CheckpointId): Promise<{ readonly state: TurnState; readonly checkpoint: Checkpoint; readonly messageIds: ReadonlyMap; } | null>; //# sourceMappingURL=turn-state.d.ts.map