import type { ModelClient, SessionMessage } from "../agent/types.js";
export interface SessionSnapshot {
    id: string;
    createdAt: string;
    messages: SessionMessage[];
}
export interface CompactionResult {
    removedMessages: number;
    summaryTokens: number;
    previousTokens: number;
    newTokens: number;
    /**
     * Which strategy actually produced the summary. `compactWithLlm` falls
     * back to mechanical compaction on error, so the method that *attempted*
     * the work isn't always the one that finished it. UI surfaces this so
     * users know whether the LLM call ran (slow, billable) or the
     * deterministic fallback fired (instant, free).
     */
    method: "llm" | "mechanical";
}
export declare class Session {
    readonly id: string;
    readonly createdAt: Date;
    private readonly messages;
    constructor(id?: string, createdAt?: Date);
    toJSON(): SessionSnapshot;
    static fromJSON(snapshot: SessionSnapshot): Session;
    addMessage(message: SessionMessage): void;
    getMessages(): SessionMessage[];
    getTokenEstimate(): number;
    /**
     * Progressive context eviction with three phases:
     *
     * Phase 1 — Shrink: Replace old tool result contents with compact summaries.
     *   Tool outputs are ephemeral (file contents, search results) — the model
     *   already extracted what it needed. Shrinking preserves the *fact* that a
     *   tool was called and a rough sense of the result, without the full payload.
     *
     * Phase 2 — Drop: Remove the oldest complete message chunks (assistant +
     *   tool results, or standalone messages) as before.
     *
     * Phase 3 — Emergency: If still over budget after dropping all removable
     *   messages, shrink tool results in the protected (recent) window too.
     */
    trim(maxTokens: number, keepRecentMessages: number): void;
    /**
     * Compact the conversation by summarizing old messages into a single
     * context summary message. This preserves the *meaning* of prior exchanges
     * while dramatically reducing token count.
     *
     * @param keepRecentMessages Number of recent messages to preserve verbatim.
     * @returns CompactionResult with stats, or null if nothing to compact.
     */
    compact(keepRecentMessages: number): CompactionResult | null;
    /**
     * Compact the conversation using an LLM to produce a high-quality summary.
     * The LLM can identify what matters (decisions, modified files, user intent)
     * rather than blindly truncating. Falls back to mechanical compaction on error.
     *
     * @param keepRecentMessages Number of recent messages to preserve verbatim.
     * @param modelClient The model client to use for the summarization call.
     * @param compactionModel The model ID to use (e.g. "zai-org/glm-4.7-flash").
     * @returns CompactionResult with stats, or null if nothing to compact.
     */
    compactWithLlm(keepRecentMessages: number, modelClient: ModelClient, compactionModel: string): Promise<CompactionResult | null>;
    /**
     * Check whether compaction should be auto-triggered.
     * Returns true when token usage exceeds the given threshold ratio.
     */
    shouldCompact(maxTokens: number, thresholdRatio?: number): boolean;
    /**
     * Shrink tool result messages in the given range by replacing their
     * content with a compact summary. Already-summarized messages are skipped.
     */
    private shrinkToolResults;
    private getProtectedStart;
    private removeOldestChunk;
}
//# sourceMappingURL=session.d.ts.map