/** * Router embedder (ADR-390). * * `hooks_route` compares a task with each agent pattern's keywords in a 384-d * vector index. Historically both sides came from a character hash * (`generateSimpleEmbedding`), which measures spelling, not meaning. This * module lets the router use the local sentence model (all-MiniLM-L6-v2, 384-d) * instead, with the hash as the fallback. * * Rules (ADR-390 §Decision): * - The MiniLM path uses `generateLocalEmbedding` ONLY. Never the bridge-first * `generateEmbedding` — that recursed without bound in #2312. * - One embedder per index: if ANY text cannot be embedded by the real model * (throw, backend !== 'onnx', or a non-384 vector), EVERY text in the call * is embedded with the hash, and the result says so. * - The default stays `hash` until ADR-391's benchmark says otherwise. * * Selection: `CLAUDE_FLOW_ROUTER_EMBEDDER=minilm|hash`. The router index is * process-lifetime state, so the env var is read when the index is (re)built, * not per CLI invocation. */ export type RouterEmbedderKind = 'minilm' | 'hash'; /** Default embedder. ADR-391 decides whether this flips to 'minilm'. */ export declare const DEFAULT_ROUTER_EMBEDDER: RouterEmbedderKind; /** Dimension of the router index (VectorDb + SemanticRouter are built at 384). */ export declare const ROUTER_EMBEDDING_DIM = 384; export declare const ROUTER_EMBEDDER_ENV = "CLAUDE_FLOW_ROUTER_EMBEDDER"; export interface RouterEmbedderSelection { kind: RouterEmbedderKind; /** Set when the requested value was invalid and the default was used. */ reason?: string; } export interface RouterEmbeddingResult { vectors: Float32Array[]; /** The embedder that actually produced `vectors` (after any degradation). */ embedder: RouterEmbedderKind; /** Why the result is `hash` when `minilm` was requested. */ reason?: string; } /** * Resolve which embedder the router should use. * Precedence: explicit override > CLAUDE_FLOW_ROUTER_EMBEDDER > DEFAULT_ROUTER_EMBEDDER. */ export declare function resolveRouterEmbedder(override?: RouterEmbedderKind, env?: NodeJS.ProcessEnv): RouterEmbedderSelection; /** * Deterministic character-hash embedding (the router's historical embedder). * Moved verbatim from hooks-tools.ts; do not change the math — existing routes * and thresholds were calibrated against it. */ export declare function generateSimpleEmbedding(text: string, dimension?: number): Float32Array; /** * Embed texts for the router. All vectors in one result come from ONE embedder. * `hash` never touches the model (no load cost for default users). */ export declare function embedForRouter(texts: readonly string[], kind?: RouterEmbedderKind): Promise; /** Test hook: clear the MiniLM vector memo. */ export declare function clearRouterEmbedderCache(): void; //# sourceMappingURL=router-embedder.d.ts.map