import { EventEmitter } from 'events';
import type { AgentsIndex, CursorState, HistoryMessage } from './types.js';
export declare class JsonlIndex extends EventEmitter {
    private projectsDir;
    private debounceTimer;
    private subscribed;
    /** After phone `agents:unsubscribe` — keep JSONL watch until DOM overlay drains into archive. */
    private draining;
    private mtimeByAgent;
    private pollTimer;
    private readonly fileCache;
    private readonly emitFileTimers;
    private liveWatcher;
    private liveWatchKey;
    /** Skip poll `agent:history` while serving explicit `agents:history` (avoids relay race). */
    readonly historyReplyInFlight: Set<string>;
    private bridgeState;
    constructor(projectsDir: string);
    setBridgeStateProvider(fn: () => Pick<CursorState, 'composerIdByTitle' | 'activeComposerId' | 'tabs'>): void;
    private resolveOpts;
    start(): void;
    stop(): void;
    subscribe(agentId: string, title?: string, opts?: {
        emitHistory?: boolean;
    }): void;
    unsubscribe(agentId: string): void;
    /** Background JSONL sync after unsubscribe while DOM overlay is still pending. */
    drain(agentId: string, title?: string): void;
    stopDrain(agentId: string): void;
    getDrainingAgents(): ReadonlyMap<string, {
        title?: string;
    }>;
    private agentsWatchedForJsonl;
    /** Immediate `change` on subscribed/draining `.jsonl` (no awaitWriteFinish delay). */
    private refreshLiveWatcher;
    getSubscribedAgents(): ReadonlyMap<string, {
        title?: string;
    }>;
    private pollSubscribed;
    private emitHistoryForAgent;
    private scheduleEmitHistoryForFile;
    private isLiveWatchedFile;
    private loadMessagesForFile;
    private emitHistoryForFileNow;
    private scheduleRebuild;
    rebuild(opts?: {
        broadcast?: boolean;
    }): Promise<AgentsIndex>;
    findProjectDirForAgent(agentId: string): string | null;
    loadHistory(agentId: string, opts?: {
        title?: string;
        composerIdByTitle?: Record<string, string>;
        activeComposerId?: string;
        activeTabTitle?: string;
        limit?: number;
        /** Skip newest `offset` rows before taking `limit` tail (0 = newest). */
        offset?: number;
    }): Promise<{
        agentId: string;
        messages: HistoryMessage[];
        totalMessages: number;
    }>;
}
