@nanocollective/nanocoder
Version:
A local-first CLI coding agent that brings the power of agentic coding tools like Claude Code and Gemini CLI to local models or controlled APIs like OpenRouter
55 lines • 2.39 kB
TypeScript
import type { CompressionMode } from '../types/config.js';
import type { Message } from '../types/core.js';
import type { Tokenizer } from '../types/tokenization.js';
/**
* Compression configuration constants
*/
export declare const COMPRESSION_CONSTANTS: {
/** Default number of recent messages to keep at full detail */
readonly DEFAULT_KEEP_RECENT_MESSAGES: 2;
/** Character threshold for compressing user messages */
readonly USER_MESSAGE_COMPRESSION_THRESHOLD: 500;
/** Character threshold for compressing assistant messages with tool_calls */
readonly ASSISTANT_WITH_TOOLS_THRESHOLD: 300;
/** Target length for aggressive text truncation */
readonly AGGRESSIVE_TRUNCATION_LIMIT: 100;
/** Target length for default text truncation */
readonly DEFAULT_TRUNCATION_LIMIT: 200;
/** Target length for aggressive assistant message truncation */
readonly AGGRESSIVE_ASSISTANT_LIMIT: 150;
/** Target length for default assistant message truncation */
readonly DEFAULT_ASSISTANT_LIMIT: 300;
/** Minimum valid auto-compact threshold percentage */
readonly MIN_THRESHOLD_PERCENT: 50;
/** Maximum valid auto-compact threshold percentage */
readonly MAX_THRESHOLD_PERCENT: 95;
/** Character threshold for compressing user messages in conservative mode */
readonly CONSERVATIVE_USER_MESSAGE_THRESHOLD: 1000;
/** Target length for conservative mode text truncation */
readonly CONSERVATIVE_TRUNCATION_LIMIT: 500;
};
export interface CompressionResult {
compressedMessages: Message[];
originalTokenCount: number;
compressedTokenCount: number;
reductionPercentage: number;
preservedInfo: {
keyDecisions: number;
fileModifications: number;
toolResults: number;
recentMessages: number;
};
}
export interface CompressionOptions {
mode: CompressionMode;
keepRecentMessages?: number;
}
/**
* Compress message history while preserving essential information
* @param messages - Original messages to compress
* @param tokenizer - Tokenizer for counting tokens
* @param options - Compression options
* @returns Compression result with compressed messages and statistics
*/
export declare function compressMessages(messages: Message[], tokenizer: Tokenizer, options: CompressionOptions): CompressionResult;
//# sourceMappingURL=message-compression.d.ts.map