/** * Pure decision helper for kv-cache history slicing used by * `completion-stream.ts` (via the slice computed from * `TurnHandle.savedCount`). * * This module intentionally has **no** `bare-*` imports so it can be * exercised directly from unit tests running under `bun` without * pulling in the Bare runtime (which is not available in that * environment). * * Cancel detection flows through the per-request `AbortSignal` from * `RequestRegistry`; the `cachedMessageCounts` map lives in * `kv-cache-session.ts`, which owns all three KV-cache bookkeeping * layers (saved counts, init flags, on-disk files). Only the pure * slice-decision helper remains here. */ export interface HistoryMessage { role: string; content: string; attachments?: { path: string; }[] | undefined; } export interface HistorySliceDecision { /** Messages to send to the model on the next turn. */ messages: HistoryMessage[]; /** * True when the decision path proves the current `savedCount` is stale * and the caller should drop the cached entry (via * `KvCacheSession.dropStaleSavedCount(turn)`) to avoid propagating the * bad count to the next turn. */ clearStaleCount: boolean; } /** * Pure slice decision for `prepareMessagesForCache`. * * Mirrors the shape of the logic in `completion-stream.ts` but without * calling `transformMessages` (which depends on `bare-fs` for * attachment probing). Kept here so the decision can be unit-tested in * isolation. * * The key regression guard: when a non-zero `savedCount` would slice * the history down to an empty array, it is treated as stale — the * caller falls back to sending the system-stripped full history rather * than handing the model an empty payload. */ export declare function decideCachedHistorySlice(savedCount: number, cacheExists: boolean, history: HistoryMessage[]): HistorySliceDecision; //# sourceMappingURL=kv-cache-state.d.ts.map