import type { CompactionConfig } from '../config/runtime.js'; import { type TokenUsage } from '../types/common/index.js'; import type { Message } from '../types/message/index.js'; import type { LLMProvider } from '../types/provider/index.js'; import { type CompactionVerificationOptions } from './verifier.js'; /** * Compaction a host can ask for, rather than one that only happens to it. * * `runCompactionCheck` was the only entry point in the kernel and it was * exported from nowhere. So a host could not offer "compact this * conversation", could not shrink an idle session sitting between turns, * and could not collapse a span it had chosen — every compaction had to * wait for the in-loop threshold or a provider overflow retry. * * These are that entry point, built on the planner rather than on a second * copy of the boundary arithmetic. Nothing here touches an * `IterationContext`: there is no turn, which is the whole point. */ export interface CompactionResult { /** The new history. A fresh array — the input is never edited. */ readonly messages: readonly Message[]; /** How many messages the pass removed. Always at least one. */ readonly shed: number; /** The summary that replaced them, as it appears in `messages`. */ readonly summary: Message; /** * Tokens spent by this host-triggered pass's optional verifier call. * * A zero record means no verifier model call ran. The manual path has no * `TurnRecorder` to account for side-channel usage, so returning it is the * only way a host can include that real provider work in its own ledger. */ readonly usage: TokenUsage; } export interface CompactNowInput extends CompactionVerificationOptions { readonly messages: readonly Message[]; readonly config: CompactionConfig; readonly provider: LLMProvider; readonly model?: string; readonly contextWindowTokens?: number; /** * Archive removed originals before the caller can install the replacement. * Awaited on both manual paths; rejection prevents publication. No call for * a no-op. The callback owns persistence and must not mutate the messages. */ readonly onShed?: (messages: readonly Message[]) => void | Promise; } /** * Compact a history now, whatever its size. * * Returns `null` when there is nothing to shed — not a zero-shed result. * A caller has to be able to tell "I compacted and it did nothing" from "I * compacted", and an outcome object reporting zero is the shape that gets * logged as a successful pass and shown to a user as work done. */ export declare function compactNow(input: CompactNowInput): Promise; export interface CompactRegionInput extends CompactNowInput { /** First index to summarise, inclusive. */ readonly start: number; /** One past the last index to summarise. */ readonly end: number; } /** * Compact exactly the span a host chose, or refuse. * * REFUSES rather than repairing. Snapping a bad edge to the nearest safe * one would return a different span than the one asked for, and the caller * — who picked those indices from something they were looking at — has no * way to notice: the result is a valid history that summarised the wrong * messages. `refuse-do-not-degrade`, and the offending index is named so * the caller can move it themselves. */ export declare function compactRegion(input: CompactRegionInput): Promise; //# sourceMappingURL=manual.d.ts.map