0
     ˆÄÃÇ466ÂÆÅ Ò    ‹      Í”Oo›0‡ïýï|Ø^ÈiKS‘)M¢4Ó4M;8Ø€À‘í,Í>ýLÈÔ´jÖu§�°áñO¿Ç`è›tž¬¾.Æðiu;…Åç�ÓIÄCüÒOÓUÚ=øAˆ8ž ¥µÛâ~¿÷÷}_éWK,m]ÐX-3ësËI|EÛ{ñÐR0î®@­´•ˆ'÷ r@µ³Fr1À�ÑhJ¦ÚRÔÂ`*r¶«,Ån‰ÁS
]+~hÃÃ×9þX�­�yíPÇÔ–ðƒU²h"bÕ–ÄTÖ�Ee¦ƒëŠ5¿�9VÙˆ|›$óïŽsùíê˜2(µÈ#ò!‰f×ó(%ñŒÕ‚"{ž¹uÌ‰§ÌX¨—¹ü"|×ÁwòçåÀ´cRa2-·VªæE§x®š©Êl™s:ƒRŸSÂ_Ú–=ÚŒÅÍr<[¥“e·%¼�xh÷‡×Bâ…›5R©Ef•>œZwo›µÙ^ÿžÂ©“–EiIàÁ³ä+DrUq¡ÏU.IvãõüÀÛˆƒk}>;oü¤b/è¼à½ô Ž‚!ÀãÒ÷ƒ“G;zÉ!½Ð9¼õÃtøËÏO“âñ|Sì~¿ �Ì‘ÝŸ    K   ˆl–Ãa¾”ªi?u8 ¸Ûw
˜´o�þBä�¬ã�f8Ûf9Yl_ÏÉƒmæ›È_“I|¥ŽõHºl=$¤�zTÖ™	ÈÇ Õ    /**
 * Query pool â€” runs CPU-heavy read-tool calls on a pool of worker threads so
 * the shared daemon's main event loop stays free for the MCP transport.
 *
 * Why this exists: see {@link ./query-worker}. One daemon, one event loop, one
 * synchronous SQLite connection serializes every concurrent `codegraph_explore`
 * AND starves the transport (a 10-way wave delivered 0 transport heartbeats in
 * 25s â€” responses can't flush until the whole batch drains, so clients time
 * out). Spreading the dispatch across worker threads (each its own WAL read
 * connection) restores true multi-core parallelism and an idle main loop.
 *
 * Properties:
 *   - lazy growth: one warm worker on construct, grows to `size` on demand, so a
 *     single-agent session pays for one connection and a 10-subagent burst grows
 *     to the core budget.
 *   - crash recovery: a dead worker is respawned and its in-flight call retried
 *     once; a poison call that keeps crashing fails gracefully (never wedges the
 *     pool). A crash budget trips a circuit breaker (`healthy` â†’ false) so the
 *     caller falls back to in-process dispatch instead of thrashing respawns.
 *   - graceful backstop: a call that can't be served within `softTimeoutMs`
 *     resolves with SUCCESS-shaped "busy, retry" guidance â€” never `isError`, so
 *     a momentary overload can't teach the agent to abandon codegraph â€” instead
 *     of hanging past the client's hard timeout.
 */
import type { ToolResult } from './tools';
/**
 * Minimal worker surface the pool drives â€” satisfied by a real `worker_threads`
 * Worker. Abstracted so tests can inject a fake worker and exercise the pool's
 * queue / growth / crash-recovery / backstop logic without spawning threads or
 * needing a built `dist/`.
 */
export interface PoolWorker {
    postMessage(msg: unknown): void;
    terminate(): Promise<number> | void;
    on(event: 'message', cb: (m: unknown) => void): void;
    on(event: 'error', cb: (e: Error) => void): void;
    on(event: 'exit', cb: (code: number) => void): void;
}
export interface QueryPoolOptions {
    /** Default project root each worker opens at spawn, or null for per-call projects. */
    root: string | null;
    /** Max worker threads. Defaults to `clamp(cores-1, 1, 16)`. */
    size?: number;
    /** Linger before a queued call gets busy-guidance. Default 45s. */
    softTimeoutMs?: number;
    /** Retries for an in-flight call whose worker crashed. Default 1. */
    maxRetries?: number;
    /** Worker factory (tests inject a fake). Defaults to a real `worker_threads` Worker. */
    createWorker?: () => PoolWorker;
    /** How long destroy() waits on a worker still starting up (tests shorten it). Default 15s. */
    startSettleMs?: number;
}
/**
 * Resolve the pool size from the `CODEGRAPH_QUERY_POOL_SIZE` override and the
 * machine's core count. `0` (or a negative) explicitly disables the pool (the
 * caller serves in-process â€” today's behavior). Unset â†’ `clamp(cores-1, 1, 16)`:
 * leave a core for the main loop + OS, but never zero, since even one worker
 * frees the transport and lets responses flush incrementally.
 */
export declare function resolvePoolSize(envVal: string | undefined, cpuCount: number): number;
export declare class QueryPool {
    private idle;
    private queue;
    private inflight;
    private workers;
    private pendingWorkers;
    private starts;
    private nextId;
    private totalCrashes;
    private destroyed;
    private readonly root;