/** * The working set: which messages stay whole for the next call. * * Given every message's salience, choose the cheapest actions that bring * the estimated context under a target, lowest salience first, then the * larger result among equally salient candidates: * * clear replace a tool result with the same excerpt the stale pass * uses, retaining a saved-artifact pointer when one exists; * stub cut an assistant narration to its first sentence — the * decision survives, the paragraph around it does not. * * Nothing protected is touched, and a message is never removed: the * shape of the conversation — every `tool_use` beside its `tool_result`, * every turn boundary — is exactly what it was, which is what makes this * safe to run on every iteration. Folding a span into the structured * state and summarising stay with the existing plan, which runs after * this when the target could not be reached. Pure, like the rest of the * compaction arithmetic. */ import type { Message } from '../../types/message/index.js'; import type { ScoredMessage } from './score.js'; export interface WorkingSetAction { readonly kind: 'clear' | 'stub'; readonly index: number; readonly charsReclaimed: number; } export interface WorkingSetPlan { readonly messages: Message[]; readonly actions: readonly WorkingSetAction[]; readonly clearedCount: number; readonly stubbedCount: number; readonly charsReclaimed: number; readonly reclaimedTokens: number; /** Whether the actions brought the estimate under the target. */ readonly reachedTarget: boolean; } export interface WorkingSetOptions { readonly estimatedTokens: number; readonly targetTokens: number; /** Tool results smaller than this are not worth a placeholder. */ readonly minToolResultChars?: number; /** Assistant narrations shorter than this keep their whole text. */ readonly minNarrationChars?: number; /** Tools whose results are never cleared. */ readonly preserveTools?: readonly string[]; /** * A message the goal names or a later turn cited is not evicted to * reach the target while it scores above this fraction of the most * salient evictable message. A strict target evicted the one result * the goal named to shave the last few tokens — an eval watched it * happen — and a pass that stops short and says so is the better * answer: the trigger threshold still guards the hard limit. */ readonly keepAboveFraction?: number; } export declare function isStubbedNarration(content: unknown): boolean; export declare function planWorkingSet(messages: readonly Message[], scored: readonly ScoredMessage[], options: WorkingSetOptions): WorkingSetPlan; //# sourceMappingURL=working-set.d.ts.map