import type { HistoryEntry } from './history-entry.js'; /** How many recent entries to keep in memory at all times. */ export declare const MAX_MEMORY_ENTRIES = 150; /** Number of entries loaded from disk per scroll-back page. */ export declare const ARCHIVE_PAGE_SIZE = 100; /** * Disk-backed archive of TUI history entries. * * Usage: * ```ts * const archive = new HistoryArchive(sessionDir); * await archive.append(entry); // write to JSONL * const entries = await archive.loadRange(0, 100); // load by index * await archive.close(); * ``` * * The archive file lives at `/history-archive.jsonl`. * It is append-only; entries are never removed (they are the durable * record). The in-memory window management is handled by the reducer. */ export declare class HistoryArchive { private readonly filePath; private handle; private closed; /** Byte-offset index: index → { offset, length }. Built on first load. */ private index; /** Total entries written so far (monotonic counter). */ private writeChain; private drainToken; constructor(sessionDir: string); /** * Append an entry to the archive. Fire-and-forget: the write is queued * on an internal promise chain so callers never block. Returns immediately. */ append(entry: HistoryEntry): void; /** * Load a range of entries by index. Indices are 0-based and sequential * across the entire file (index 0 = oldest archived entry). * * Returns the loaded entries in chronological order (oldest first). * When the range exceeds the available data, returns whatever fits. */ loadRange(startIndex: number, count: number): Promise; /** How many entries are archived on disk. */ get archivedCount(): number; /** * Close the file handle and release resources. Idempotent. * The write chain is drained before closing so no in-flight write * is lost. */ close(): Promise; private ensureOpen; /** * Build the byte-offset index by scanning the archive file. * Rebuilds when `this.index` is null (first use or after rotation). * The index is cached for the lifetime of the archive object. */ private buildIndex; /** Serialise writes through a FIFO promise chain with fresh-token coalescing. */ private enqueueWrite; } /** * Build the archive file path from a session directory. * Exported so the TUI can create the archive path from the session dir * without importing the class. */ export declare function historyArchivePath(sessionDir: string): string; //# sourceMappingURL=history-archive.d.ts.map