import type { Message, GrawkusConfig } from './types.js';
/**
 * Estimate tokens accounting for content type and message overhead.
 * - English prose: ~3.5 chars per token
 * - Code: ~3 chars per token (more special chars)
 * - Message overhead: ~4 tokens per message for role/structure
 */
export declare function estimateTokens(messages: Message[]): number;
export interface CompactionConfig {
    enabled: boolean;
    triggerTokens: number;
    keepRecentMessages: number;
    targetTokens: number;
}
export declare const DEFAULT_COMPACTION: CompactionConfig;
export declare const DEFAULT_CONTEXT_WINDOW_TOKENS = 128000;
export declare const OPENROUTER_FREE_ROUTER_SAFE_CONTEXT_WINDOW_TOKENS = 128000;
export declare const OPENROUTER_UNKNOWN_FREE_MODEL_CONTEXT_WINDOW_TOKENS = 32768;
export declare const ROLLING_COMPACTION_MAX_TRIGGER_TOKENS = 60000;
export declare const ROLLING_COMPACTION_CONTEXT_FRACTION = 0.5;
export declare const LOCAL_COMPACTION_SUMMARY_MAX_LINES = 80;
export declare const DEFAULT_COMPACTION_SUMMARY_MAX_TOKENS = 2048;
export interface ContextCapResult {
    messages: Message[];
    changed: boolean;
    droppedMessages: number;
    beforeTokens: number;
    afterTokens: number;
    maxAllowedTokens: number;
}
export declare function contextCapTokens(contextWindowTokens: number): number;
export declare function inferContextWindowTokens(config: Pick<GrawkusConfig, 'model' | 'contextWindowTokens'>): number;
export declare function compactionTriggerTokens(config: Pick<GrawkusConfig, 'model' | 'contextWindowTokens'>, base?: CompactionConfig): number;
export declare function buildCompactionConfig(config: Pick<GrawkusConfig, 'model' | 'contextWindowTokens'>, base?: CompactionConfig): CompactionConfig;
export declare function enforceContextCap(messages: Message[], maxAllowedTokens: number): ContextCapResult;
export declare function shouldCompact(messages: Message[], config: CompactionConfig): boolean;
export declare function getCompactionStats(messages: Message[], config?: Pick<GrawkusConfig, 'model' | 'contextWindowTokens'>): {
    messageCount: number;
    estimatedTokens: number;
    needsCompaction: boolean;
    triggerTokens: number;
};
export interface CompactionPartition {
    pinnedPrefix: Message[];
    oldMessages: Message[];
    recentMessages: Message[];
    pinnedFirstUser: boolean;
}
export declare function partitionMessagesForCompaction(messages: Message[], keepRecentMessages: number): CompactionPartition;
export declare function buildCompactedMessages(summary: string, partition: CompactionPartition): Message[];
export declare function buildLocalCompactionSummary(oldMessages: Message[]): string;
export declare function buildCompactionSummaryConfig(config: GrawkusConfig): GrawkusConfig;
/**
 * Compact messages by summarizing older ones with the AI model.
 * Returns a new messages array with a summary + recent messages.
 */
export declare function compactMessages(messages: Message[], config: GrawkusConfig, compactionConfig?: CompactionConfig): Promise<Message[]>;
/**
 * Quick local compaction without API call — just truncates tool results.
 */
export declare const QUICK_TOOL_OUTPUT_TRIGGER_CHARS = 5000;
export declare const QUICK_TOOL_OUTPUT_HEAD_CHARS = 2000;
export declare const QUICK_TOOL_OUTPUT_TAIL_CHARS = 2000;
export declare function compactLargeToolOutput(content: string, triggerChars?: number, headChars?: number, tailChars?: number): string;
export declare function quickCompact(messages: Message[]): Message[];
