import type { ChatMessage } from "./types.js";
import { type LiveToolResultGuardStats } from "./live-tool-result-guard.js";
export interface OptimizeOptions {
    /** Sliding window: keep last N assistant rounds. Undefined = no window. */
    windowRounds?: number;
    /**
     * Soft trim threshold (chars). Processed tool results larger than this are
     * trimmed to keep head + tail with "[...trimmed...]" in between.
     * Default: 1000. Applied uniformly to every processed result regardless of
     * age so the trimmed output is byte-identical across consecutive turns
     * (prompt-cache stability).
     */
    softTrimThreshold?: number;
    /**
     * Hard omit threshold (chars). Processed tool results larger than this are
     * fully replaced with a short placeholder.
     * Default: 8000
     */
    hardOmitThreshold?: number;
    /** Chars to keep at the start of a soft-trimmed result. Default: 500 */
    softTrimHead?: number;
    /** Chars to keep at the end of a soft-trimmed result. Default: 500 */
    softTrimTail?: number;
    /** Always preserve the first message (e.g. task prompt). Default: false */
    preserveFirst?: boolean;
    /** Slim large arguments on already-processed tool calls. Default: 2000 */
    processedToolArgThreshold?: number;
    /** Preview chars for slimmed processed tool-call arguments. Default: 160 */
    processedToolArgPreview?: number;
    /** Max chars for each latest/unprocessed tool result. Default: 16000 */
    liveToolResultMaxChars?: number;
    /** Aggregate max chars for latest/unprocessed tool results. Default: 64000 */
    liveToolResultAggregateMaxChars?: number;
}
export interface OptimizeMessagesWithStatsResult {
    messages: ChatMessage[];
    liveToolResultGuard: LiveToolResultGuardStats;
}
/**
 * Build an optimized copy of messages for LLM consumption.
 *
 * Pipeline (order matters):
 * 1. Optionally preserve the first message (task prompt)
 * 2. Optional sliding window to keep only the last N rounds
 * 3. Stable pruning of processed tool results (already consumed by LLM):
 *    - Snapshot results → always replaced by a one-line "[snapshot omitted …]"
 *      summary (ephemeral page state is useless once consumed).
 *    - Screenshot results → hard-omitted (large, opaque blobs that the LLM
 *      no longer references once it has acted on them).
 *    - Generic results larger than hardOmitThreshold → hard_omit.
 *    - Generic results larger than softTrimThreshold → soft_trim (head + tail).
 *    Unprocessed results (no assistant message after them) are NEVER touched.
 *    The pruning decision depends only on content type + size — NOT on how
 *    old the message is — so once a result is processed its serialized form
 *    is fixed forever, which is what lets the provider prompt cache hit.
 * 4. Slim assistant tool-call args once their results were consumed, using
 *    the same content-only criterion.
 */
export declare function optimizeMessages(messages: ChatMessage[], options?: OptimizeOptions): ChatMessage[];
export declare function optimizeMessagesWithStats(messages: ChatMessage[], options?: OptimizeOptions): OptimizeMessagesWithStatsResult;
