import type { ModelMessage } from "./model.js"; import type { Role, SessionData, SessionEntry, SignalEntryData } from "./types.js"; export declare const DEFAULT_HEADLESS_PREAMBLE = "You are running in headless autonomous mode (background-agent mode) with no human operator assumed. Work autonomously: Do not ask clarifying questions or wait for in-band user input. Make safe, reasonable assumptions when possible; if blocked by missing credentials, unavailable capabilities, denied policy, or required approvals, fail closed with a concise actionable explanation. Irreversible or high-risk actions must go through policy/approval gates, not natural-language confirmation. Summarize what you did and any remaining risks or follow-ups."; export declare class SessionHistory { private readonly entries; private readonly byId; private leafId; private constructor(); static fromData(data: SessionData | undefined): SessionHistory; /** * Returns a SessionData snapshot containing only the entries up to and * including `stepId` along the active path. The new `leafId` is `stepId`. * Throws if `stepId` is not found on the active path. * * Used by `fh replay --rerun` to fork a session at a specific step. */ truncateAt(sourceId: string, stepId: string): { entries: SessionEntry[]; leafId: string; }; /** * Returns the next user_prompt entry _after_ the given step on the active * path, if any. Used by replay re-execution to resubmit the prompt that * originally followed the cut. */ nextPromptAfter(stepId: string): SessionEntry | undefined; getActivePath(): SessionEntry[]; /** * Rewind the active path to a specific entry. Used during interrupted-tool * repair to branch from a prior entry when partial out-of-order results need * to be replaced with a correctly ordered complete batch. */ setLeaf(entryId: string): void; /** * Active-path entries appended after `afterLeafId` (exclusive), in order. * * - `afterLeafId` is null/undefined means "from the start of the path" → * returns the entire active path. * - When the id is found, returns entries strictly after it. * - When the id is *not* on the current active path (e.g. a branch switch * happened mid-window), returns `[]`. Callers use this for bounded windowing * — falling back to the full path would silently include unrelated history. * An empty result is the safer answer for usage aggregation: zero is loud * (sums won't match expectations) while full-history is silent overcounting. */ getActivePathSince(afterLeafId: string | null | undefined): SessionEntry[]; getLatestCompaction(): SessionEntry | undefined; /** Trailing dangling tool calls on THIS history's active path. See {@link findTrailingDanglingToolCalls}. */ findTrailingDanglingToolCalls(): SessionEntry[]; buildContextEntries(): SessionEntry[]; buildModelMessages(role?: Role): ModelMessage[]; } export declare function buildModelMessagesFromHistory(data: SessionData | undefined, role?: Role): ModelMessage[]; /** * Find trailing `tool_call` entries on the active path that were never * settled — no matching `tool_result` (paired by `toolCallId`, falling back * to tool name) and no subsequent `error` entry for the same tool. * * A dangling call means a model turn died (crash/abort) between recording * the call and recording its outcome. Left in place it produces an * assistant `tool_use` with no `tool_result` on resume, which providers * reject — the repair path appends synthetic interrupted outcomes for * exactly the entries returned here. * * Conservative by construction: only the window after the last turn * boundary (user prompt / assistant message / result / compaction / signal) * is examined, so historical, already-settled turns are never re-judged. * Both the resume-repair and the submission terminalization derive the * dangling set through this single function so they can never disagree. */ export declare function findTrailingDanglingToolCalls(path: SessionEntry[]): SessionEntry[]; /** * Trailing `task_start` entries in the same window with no matching * `task_end` — a subtask that was in flight when the turn died. These do not * corrupt model context (task entries are bookkeeping), but settling them * keeps UI/audit state coherent. */ export declare function findTrailingUnfinishedTasks(path: SessionEntry[]): SessionEntry[]; export declare function renderSignalMessage(data: SignalEntryData): string; //# sourceMappingURL=history.d.ts.map