/** * Resume helpers: classic/history TranscriptItem + ChatMessage → v2 store shape. * * History records may carry a full TUI transcript (classic clai) or only the * model messages array (older / partial saves). We hydrate both so /history * restores prompts, tools, and assistant text — not just a notice. */ import { type ChatMessage } from "../../types.js"; import type { TranscriptItem as ClassicTranscriptItem } from "../../app/ports/transcript-item.js"; import { type ToolCallId } from "../../app/events/app-event.js"; import { type FileChange } from "../../tools/file-diff.js"; import { type TranscriptState } from "./transcript-types.js"; export interface HydrateResult { readonly state: TranscriptState; /** Tool outputs to seed into OutputSpool (classic embeds output on the item). */ readonly toolOutputs: ReadonlyMap; } /** Convert a classic (or mixed) saved transcript into the v2 normalized state. */ export declare function hydrateFromClassicTranscript(items: readonly ClassicTranscriptItem[]): HydrateResult; /** * Rebuild structured file diffs from tool-call args so /history shows the same * green/red hunks as the live session. Live turns attach `fileChanges` on * tool-result; message-only history (or a re-save after a thin hydrate) often * drops that payload while still keeping path/content in `toolCalls[].args`. * * Not a cwd issue — absolute paths in the snapshot still render; missing * `fileChanges` is what forces the ugly receipt + JSON args UI. */ export declare function fileChangesFromToolArgs(name: string, args: Record | undefined): FileChange[] | undefined; /** * Fallback when a history row only has model messages (no visual transcript), * or when the visual transcript is thinner than the model history (e.g. abort * stub saved after tools ran in-memory but never as transcript items). * * Reconstructs user / assistant bubbles and tool cards from native * `toolCalls` + `role: "tool"` pairs so /history still shows commands and * outputs when possible. */ export declare function hydrateFromMessages(messages: readonly ChatMessage[]): HydrateResult; /** * True when the visual transcript is missing the bulk of tool work that still * exists in model messages (common after abort-before-save of the UI snapshot). */ export declare function transcriptLooksIncomplete(transcriptLen: number, messages: readonly ChatMessage[]): boolean; /** * Prefer the richer of classic visual transcript vs message-derived hydrate * so /history does not drop tools when only one representation survived. * * Classic is enriched with `fileChanges` rebuilt from message tool args when * a prior message-only re-save wiped the structured diffs (common after * resume). */ export interface BoundedSessionVisualInput { readonly transcript: ClassicTranscriptItem[] | undefined; readonly messages: ChatMessage[]; readonly omittedItems: number; readonly omittedMessages: number; } export declare function boundSessionVisualInput(transcript: readonly ClassicTranscriptItem[] | undefined, messages: readonly ChatMessage[]): BoundedSessionVisualInput; export declare function hydrateSessionVisual(transcript: readonly ClassicTranscriptItem[] | undefined, messages: readonly ChatMessage[]): HydrateResult; /** * Snapshot the live v2 transcript into the classic shape for history.db so * /history can restore tools + prompts next time (parity with classic clai). */ export declare function serializeForHistory(state: TranscriptState, toolOutput: (toolCallId: ToolCallId) => string): ClassicTranscriptItem[]; /** Strip the model framing prefix for display in the compacted card. */ export declare function displayCompactSummary(summary: string): string;