/** * task-embedder.ts — Shared lazy task embedder + LRU cache (ADR-149 iter 9). * * The cost-optimal neural router (ADR-149) fires only when `route(task, embedding)` * is called with a real embedding. Two call sites in the dispatcher chain need * embeddings: `agent-tools.ts` (initial routing) and `agent-execute-core.ts` * (the fallback chain on 429/5xx). Before this module they each loaded their * own @xenova/transformers MiniLM pipeline and recomputed embeddings on every * call — including for repeated prompts. * * This module: * 1. Loads the pipeline once per process (`loadTaskEmbedder`). * 2. Caches embeddings per task text via an LRU of configurable size * (default 500 entries ≈ 1.5 MB at 384-dim). * 3. Hashes by FNV-1a-32 + length to keep the key compact and collision-safe * for typical prompt sizes. * 4. Returns `undefined` on any failure so callers gracefully fall back to * the heuristic+bandit path. * * @module task-embedder */ /** * Compute (or fetch from cache) the 384-dim MiniLM embedding for `task`. * Returns `undefined` on any failure (missing @xenova/transformers, ONNX * runtime error, etc.) so callers can gracefully fall back to the * heuristic+bandit path. Best-effort and never throws. * * Cache hit-rate accumulates across the process lifetime and is observable * via `embedderStats()` for diagnostics. */ export declare function embedTaskWithCache(task: string): Promise; /** * Batch counterpart to `embedTaskWithCache`. For each task, returns the * cached embedding when present, else schedules a fresh inference. The * fresh-inference set is computed in a SINGLE ONNX pass via * @xenova/transformers' array-input mode, amortizing tensor setup + * model-load overhead across the batch. Order of the output array * matches the input order. * * Returns `undefined` for any task that failed to embed (missing dep, * runtime error). Cache state updates as if each task had been called * separately through embedTaskWithCache (hits/misses counters update * accordingly). */ export declare function embedTaskWithCacheBatch(tasks: string[]): Promise>; /** Diagnostic surface — hit/miss counters + cache state. */ export declare function embedderStats(): { size: number; maxSize: number; hits: number; misses: number; hitRate: number; }; /** Test seam — clear LRU + counters so tests get a fresh baseline. */ export declare function __resetTaskEmbedderForTests(): void; //# sourceMappingURL=task-embedder.d.ts.map