import type { AgentMessage } from '@earendil-works/pi-agent-core';
import { type Model, type Api } from '@earendil-works/pi-ai';
import { type ConversationSummary } from './summary-generator.js';
export interface CompactionResult {
    summary: string;
    firstKeptIndex: number;
    tokensBefore: number;
    tokensAfter: number;
    compacted: boolean;
    structuredSummary?: ConversationSummary;
    compactedUsage?: {
        input: number;
        output: number;
        total: number;
        cost?: number;
    };
}
export interface CompactionConfig {
    enabled: boolean;
    mode: 'extractive' | 'abstractive' | 'structured';
    reserveTokens: number;
    triggerThreshold: number;
    minMessagesBeforeCompact: number;
    keepRecentMessages: number;
    summaryMaxTokens: number;
    evictionWindow: number;
    retentionWindow: number;
    preserveReasoning: boolean;
    accumulateUsage: boolean;
}
interface MessageUsage {
    input: number;
    output: number;
    total: number;
    cost?: number;
}
export declare function accumulateUsage(messages: AgentMessage[]): MessageUsage | undefined;
export declare class SessionCompactor {
    private model?;
    private config;
    constructor(config?: Partial<CompactionConfig>, model?: Model<Api>);
    needsCompaction(messages: AgentMessage[], contextWindow: number): {
        needed: boolean;
        reason: string;
        usagePercent?: number;
    };
    compact(messages: AgentMessage[], instructions?: string, force?: boolean): Promise<CompactionResult>;
    private generateSummary;
    private llmAbstractiveSummary;
    private formatMessages;
    private extractiveSummary;
    estimateTotalTokens(messages: AgentMessage[]): number;
    applyCompaction(messages: AgentMessage[], result: CompactionResult): AgentMessage[];
}
export {};
