/** * Picking a session back up. * * The browser could read a finished session and nothing else, which was a deliberate limit and the * wrong one: the commonest thing to want from a transcript is to carry on with it. The engine has * always supported it — createAgentSession takes initialMessages, initialStats and initialPlan — * so nothing here is new capability. What was missing is the answer to "and what was it doing?". * * That question deserves better than replaying the last message. A session that ended mid-plan * with three steps outstanding is unfinished in a way a session that ended on "done, all tests * pass" is not, and the difference is recoverable from what was written down: the plan's own step * states, whether the last turn was a tool call or a conclusion, and whether it stopped or was * stopped. So resuming offers what remains, and asking is left to the interface — a session that * looks finished should not be told to carry on with nothing. */ import type { Message } from '../types.js'; import { type Plan } from '../plan.js'; import { type PastSession } from './history.js'; export interface Unfinished { /** Plan steps not marked done, in the order they were planned. */ steps: Array<{ text: string; state: string; }>; /** The last thing it actually did, as a sentence. */ lastAction: string; /** The last thing it said, trimmed to something readable. */ lastSaid: string; /** True when the evidence says the work was not finished. */ looksUnfinished: boolean; /** Why, in words, so the interface can show it rather than assert it. */ because: string; /** What to send to carry on, when there is something. Empty when it looks finished. */ suggestion: string; } /** * Reads the trajectory and the transcript for signs the work stopped rather than ended. * * Ordered by how much each signal is worth. An outstanding plan step is the strongest: the session * wrote down what it intended and did not tick it off. A transcript whose last entry is a tool * result is next — the model had asked for something and never said what it made of the answer, * which is what an interrupted turn looks like from the outside. */ export declare function assess(past: PastSession): Unfinished; export interface Resumable { /** The messages to hand the new agent, exactly as they were written. */ messages: Message[]; /** Totals the restored history already accounts for, so counting continues rather than restarts. */ stats: { promptTokens: number; completionTokens: number; totalTokens: number; turns: number; }; /** The plan as it stood, so resuming continues the work instead of re-planning it. */ plan: Plan | null; title: string; assessment: Unfinished; } /** * Everything needed to carry on, read off disk. * * Two readers, because they answer different questions from the same file: loadSession returns the * messages the engine needs verbatim, and readPast returns the rendered view plus the trajectory, * which is where the plan and the stop events live. Reading it twice is a few kilobytes and avoids * a second parser that would drift from the first. */ export declare function readResumable(cwd: string, file: string): Promise; //# sourceMappingURL=resume.d.ts.map