/**
 * Context condensation.
 *
 * When a conversation's estimated footprint approaches the model's window, the
 * oldest stretch of history is replaced by a single dense summary turn while a
 * verbatim tail of recent turns is preserved. This module decides *whether* to
 * condense ({@link shouldCompact}), *where* the boundary falls without severing
 * a tool call from its result ({@link findCutPoint}), *how* the prefix is
 * distilled into one turn ({@link summarize}), and finally stitches the two
 * together ({@link compact}).
 */
import type { ModelCard, Turn } from "../../llmgateway/contract";
import type { CompactionPolicy } from "../contract";
import type { ModelInvoker } from "../contract";
/**
 * Decide whether the history has grown enough to warrant condensation.
 *
 * Compares the estimated token footprint against `triggerRatio` of the model's
 * context window. Returns `false` for a non-positive window (nothing meaningful
 * to compare against) so callers never condense on a misconfigured card.
 */
export declare function shouldCompact(messages: readonly Turn[], model: ModelCard, cfg?: CompactionPolicy): boolean;
/**
 * Locate the boundary index separating the prefix to condense from the tail to
 * preserve.
 *
 * The tail starts at `length - keepRecent`, clamped into range. The boundary is
 * then nudged *forward* (shrinking the tail, enlarging the condensed prefix)
 * while the candidate first-preserved turn carries tool results, so a
 * `tool_call`/`tool_result` pair is never split across the boundary. Returns the
 * index of the first turn that survives verbatim: `0` means nothing is
 * condensed; `length` means everything is.
 */
export declare function findCutPoint(messages: readonly Turn[], keepRecent: number): number;
/**
 * Distill a stretch of history into one synthetic turn.
 *
 * Builds a conversation whose system preamble is the {@link DISTILL_INSTRUCTION}
 * and whose single user turn is the rendered transcript of `messages`, invokes
 * the injected model, and folds the streamed response into a `user`-role turn.
 * Filing the summary under the `user` role keeps it valid input for the next
 * invocation regardless of which provider follows, and marks it visibly with
 * {@link SUMMARY_HEADING}.
 */
export declare function summarize(messages: readonly Turn[], invoke: ModelInvoker): Promise<Turn>;
/**
 * Condense a history: replace its older prefix with a single distilled turn and
 * keep the recent tail verbatim.
 *
 * Resolves the policy (falling back to {@link DEFAULT_POLICY}), finds the
 * tool-safe cut point, and — when there is a prefix worth condensing — invokes
 * {@link summarize} on it. The result is `[summary, ...tail]`. When the cut
 * point is `0` (nothing old enough to drop) the original history is returned
 * unchanged, so `compact` is safe to call unconditionally.
 */
export declare function compact(messages: readonly Turn[], model: ModelCard, cfg: CompactionPolicy | undefined, invoke: ModelInvoker): Promise<readonly Turn[]>;
