/**
 * Chat History Persistence — Persist completed chat messages to local disk
 *
 * Design:
 * - ~/.adhdev/history/{agentType}/YYYY-MM-DD.jsonl
 * - JSONL format (one line = one message, append-friendly)
 * - Track only new messages (hash comparison with previous)
 * - Auto-rotation (delete files older than 30 days)
 * - Async/non-blocking (no impact on chat collection)
 */
interface HistoryMessage {
    ts: string;
    receivedAt: number;
    role: 'user' | 'assistant' | 'system';
    content: string;
    agent: string;
    instanceId?: string;
    sessionTitle?: string;
}
export declare class ChatHistoryWriter {
    /** Last seen message count per agent (deduplication) */
    private lastSeenCounts;
    /** Last seen message hash per agent (deduplication) */
    private lastSeenHashes;
    /** Last seen append-only terminal transcript per agent */
    private lastSeenTerminal;
    private rotated;
    /**
    * Append new messages to history
    *
    * @param agentType agent type (e.g. 'antigravity', 'cursor')
    * @param messages Message array received from readChat
    * @param sessionTitle Current session title
    * @param instanceId IDE instance UUID (distinguishes windows of the same agent)
    */
    appendNewMessages(agentType: string, messages: Array<{
        role: string;
        content: string;
        receivedAt?: number;
    }>, sessionTitle?: string, instanceId?: string): void;
    appendTerminalHistory(agentType: string, terminalHistory: string, sessionTitle?: string, instanceId?: string): void;
    /** Called when agent session is explicitly changed */
    onSessionChange(agentType: string): void;
    /** Delete history files older than 30 days */
    private rotateOldFiles;
    /** Allow only filename-safe characters */
    private sanitize;
}
/**
 * Read history (static — called from P2P commands)
 *
 * Read JSONL files in reverse order, returning most recent messages first.
 * When instanceId is specified, reads only that instance file.
 * Offset/limit-based paging.
 */
export declare function readChatHistory(agentType: string, offset?: number, limit?: number, instanceId?: string): {
    messages: HistoryMessage[];
    hasMore: boolean;
};
export {};
