import type { WireSessionInfo } from './broker-protocol.js'; export declare function compactSessionSearchText(text: string): string; /** In-memory + file-backed cache keyed by absolute `.jsonl` path. One instance * per broker; the file is shared across brokers (last-writer-wins via atomic * rename — a lost update just costs one file's rebuild next open, never * corruption). */ export declare class SessionListCache { private readonly cacheFile; private cache; /** In-flight cwd scans keyed by normalized session dir, so an immediate * /resume that races the background prewarm (or a second identical open) * shares the one running jsonlFiles/stat/build pass instead of queueing a * redundant one behind it. */ private inflightDir; private loadPromise; private buildChain; private persisting; private persistAgain; private persistTimer; constructor(cacheFile: string); /** Fire-and-forget warm of the cwd scope at broker start, so the first * `/resume` open after this broker launches is already warm. The cold scan * streams each file via readline (yields per chunk), so it never blocks the * broker loop — pre-warming beats worker threads here. Errors are swallowed * by the same paths that guard a normal open. */ prewarm(sessionDir: string): void; /** Sessions for one cwd's session dir (the picker's default `cwd` scope). * Single-flight: an identical concurrent cwd open (prewarm ⇄ immediate * /resume) shares the in-flight promise rather than repeating the scan. * Incompatible cwd/all builds still serialize through the build chain. */ listDir(sessionDir: string): Promise; private buildDir; /** Sessions across every cwd's dir under the sessions root (`all` scope). */ listAll(sessionsRoot: string): Promise; /** Serialize builds through a single chain: they mutate the shared cache map * and, cold, scan the same large corpus. Identical cwd opens are already * collapsed upstream by `listDir`'s in-flight sharing; chaining serializes * the remaining incompatible builds (a cwd scan vs an `all` scan) so they * never race map mutation or launch overlapping cold scans. */ private build; private buildLocked; /** Load the persisted cache exactly once, single-flight. Returns a shared * promise so a build that starts while the read is still in flight awaits the * same load rather than proceeding against a not-yet-populated map. */ private ensureLoaded; private loadFromDisk; /** Coalesce persists onto a single trailing timer so the tens-of-MB * `JSON.stringify` never runs on the reply path and rapid opens write once. */ private schedulePersist; /** Atomic write (temp + rename) so a concurrent reader never sees a partial * file. Coalesces overlapping writes into one trailing flush. */ private persist; }