/** * Provider replay data stripping for idle session transcripts (`omp gc --strip`). * * Assistant turns persist state only their provider can read back, so a * resumed turn replays natively: signed or encrypted reasoning, the verbatim * wire response kept for prompt caching, request controls, uploaded-file * references. Once a transcript has sat idle past every provider's cache and * response retention, that state is dead weight. {@link stripRecord} removes * it, leaving each turn as one recorded by another model, which every provider * already replays (reasoning as plain text, or not at all), so the session * stays resumable on any model. * * Kept on purpose: * - The latest replay turn, verbatim: the run of assistant responses that ends * the latest surviving assistant turn, joined by tool results or adjacency as * a provider's message list joins them. Providers validate that run as one * assistant message, so a resumed turn that continues its tool loop must * replay each response's reasoning unmodified. * - Replay state that carries context found nowhere else: reasoning source * markers ({@link isReasoningSourceSignature}), text signatures (OpenAI * message phase), Anthropic message controls and native compaction blocks, * OpenAI snapshot histories, and compaction entries (an OpenAI remote * compaction's stored summary is a placeholder for its encrypted history). * * A rewrite keeps every line without replay data byte for byte (the title slot * included) and the transcript's timestamps. */ import type { BigIntStats } from "node:fs"; import { type FileSessionStorage } from "../session/session-storage.js"; /** What stripping one transcript removes, planned against the file as it was at `stat`. */ export interface StripPlan { file: string; stat: BigIntStats; /** Line indices whose replay data is removed. */ strip: ReadonlySet; /** Records that lose replay data. */ records: number; /** JSONL bytes removed; uncompressed for an archived `.jsonl.gz`. */ bytes: number; } /** * Plan stripping `file`. Undefined when it was modified after `idleBeforeMs`, * is not a regular file with a single link (a rename would split the links), * or carries no replay data outside its latest replay turn. */ export declare function planStrip(file: string, idleBeforeMs: number): Promise; /** * Replace the planned transcript with its stripped copy, staged beside it with * the original's timestamps. A `.jsonl` transcript is swapped under the session * publish lock that serializes appends. Returns false, replacing nothing, when * the file changed since it was planned. * * @throws When the copy cannot be written or a writer holds the publish lock. */ export declare function applyStrip(plan: StripPlan, storage: FileSessionStorage): Promise;