/**
 * Message History Manager
 *
 * Encapsulates message and chat history management.
 * This class handles:
 * - Chat history storage and retrieval
 * - LLM message management
 * - History trimming and cleanup
 * - Memory optimization for long sessions
 */
import type { ChatEntry } from '../types.js';
import type { CodeBuddyMessage } from '../../codebuddy/client.js';
/**
 * Configuration for history size limits
 */
export interface HistoryConfig {
    /** Maximum number of chat history entries to keep */
    maxHistorySize: number;
    /** Maximum number of LLM messages to keep */
    maxMessagesSize: number;
    /** Number of recent entries to keep at full detail */
    recentEntriesToKeepFull: number;
    /** Maximum content length for older entries */
    maxContentLength: number;
    /** Maximum output length for older tool results */
    maxOutputLength: number;
}
/**
 * Statistics about history usage
 */
export interface HistoryStats {
    chatHistorySize: number;
    messagesSize: number;
    maxHistory: number;
    maxMessages: number;
}
/**
 * Manager for message and chat history in agents.
 *
 * Responsibilities:
 * - Storing and retrieving chat history
 * - Managing LLM message arrays
 * - Trimming history to prevent memory leaks
 * - Cleaning up obsolete references for garbage collection
 */
export declare class MessageHistoryManager {
    private chatHistory;
    private messages;
    private readonly config;
    constructor(config?: Partial<HistoryConfig>);
    /**
     * Get a copy of the chat history
     */
    getChatHistory(): ChatEntry[];
    /**
     * Get the raw chat history array (for internal use)
     */
    getChatHistoryRef(): ChatEntry[];
    /**
     * Add an entry to chat history
     */
    addChatEntry(entry: ChatEntry): void;
    /**
     * Add multiple entries to chat history
     */
    addChatEntries(entries: ChatEntry[]): void;
    /**
     * Set the entire chat history (e.g., when loading a session)
     */
    setChatHistory(history: ChatEntry[]): void;
    /**
     * Clear chat history
     */
    clearChatHistory(): void;
    /**
     * Get a copy of the messages array
     */
    getMessages(): CodeBuddyMessage[];
    /**
     * Get the raw messages array (for internal use)
     */
    getMessagesRef(): CodeBuddyMessage[];
    /**
     * Add a message to the messages array
     */
    addMessage(message: CodeBuddyMessage): void;
    /**
     * Add multiple messages
     */
    addMessages(messages: CodeBuddyMessage[]): void;
    /**
     * Set the entire messages array
     */
    setMessages(messages: CodeBuddyMessage[]): void;
    /**
     * Clear messages while optionally preserving system message
     */
    clearMessages(preserveSystemMessage?: boolean): void;
    /**
     * Get the system message if present
     */
    getSystemMessage(): CodeBuddyMessage | null;
    /**
     * Set or update the system message
     */
    setSystemMessage(content: string): void;
    /**
     * Clear both chat history and messages
     */
    clearAll(preserveSystemMessage?: boolean): void;
    /**
     * Get current history statistics
     */
    getStats(): HistoryStats;
    /**
     * Trim history arrays to prevent memory leaks.
     *
     * Implements a sliding window approach:
     * - For chatHistory: keeps the most recent entries up to maxHistorySize
     * - For messages: preserves system message and keeps recent conversation messages
     */
    private trimHistory;
    /**
     * Trim chat history using sliding window
     */
    private trimChatHistory;
    /**
     * Trim LLM messages, preserving system message
     */
    private trimMessages;
    /**
     * Clean up large objects in old chat history entries.
     * This helps garbage collection by removing references to
     * potentially large tool results from older entries.
     */
    private cleanupObsoleteReferences;
    /**
     * Clear all data for disposal
     */
    dispose(): void;
}
