@claude-flow/cli 3.42.4 → 3.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -801,6 +801,52 @@ async function rescueAgentdbEmbedder(agentdb) {
801
801
  emb.__ruvectorRescued = true;
802
802
  _embedderPatched = true;
803
803
  }
804
+ /**
805
+ * #3325: embed text for a bridge row or query.
806
+ *
807
+ * AgentDB's embedder is tried first. If it is absent or throws, fall back to
808
+ * the LOCAL chain — `generateLocalEmbedding`, never the bridge-first
809
+ * `generateEmbedding`, which would re-enter this bridge (#2312). Only a real
810
+ * ONNX vector is accepted from the local chain; a hash vector would make the
811
+ * row look embedded while carrying no meaning. Previously both failure modes
812
+ * were a bare `catch {}` that stored embedding=NULL and reported nothing.
813
+ */
814
+ async function embedForBridge(agentdb, text) {
815
+ let agentdbProblem;
816
+ const embedder = agentdb?.embedder;
817
+ // Same mock signal bridgeGenerateEmbedding honours (AUDIT #3): the rescue
818
+ // tags a degraded embedder backend='mock' when it cannot replace it.
819
+ const agentdbIsMock = embedder?.isMock === true || embedder?.backend === 'mock';
820
+ if (agentdbIsMock) {
821
+ agentdbProblem = 'agentdb embedder is serving mock vectors';
822
+ }
823
+ else if (embedder && typeof embedder.embed === 'function') {
824
+ try {
825
+ const emb = await embedder.embed(text);
826
+ if (emb && emb.length > 0) {
827
+ return { vector: Array.from(emb), model: 'Xenova/all-MiniLM-L6-v2' };
828
+ }
829
+ agentdbProblem = 'agentdb embedder returned no vector';
830
+ }
831
+ catch (err) {
832
+ agentdbProblem = `agentdb embedder threw: ${err instanceof Error ? err.message : String(err)}`;
833
+ }
834
+ }
835
+ else {
836
+ agentdbProblem = 'agentdb embedder unavailable';
837
+ }
838
+ try {
839
+ const { generateLocalEmbedding } = await import('./memory-initializer.js');
840
+ const local = await generateLocalEmbedding(text);
841
+ if (local.backend === 'onnx' && local.embedding.length > 0) {
842
+ return { vector: Array.from(local.embedding), model: local.model };
843
+ }
844
+ return { vector: null, reason: `${agentdbProblem}; local embedding chain has no real model (backend=${local.backend})` };
845
+ }
846
+ catch (err) {
847
+ return { vector: null, reason: `${agentdbProblem}; local embedding chain failed: ${err instanceof Error ? err.message : String(err)}` };
848
+ }
849
+ }
804
850
  // ===== Bridge functions — match memory-initializer.ts signatures =====
805
851
  /**
806
852
  * Store an entry via AgentDB v3.
@@ -851,26 +897,24 @@ export async function bridgeStoreEntry(options) {
851
897
  if (!guardResult.allowed) {
852
898
  return { success: false, id, error: `MutationGuard rejected: ${guardResult.reason}` };
853
899
  }
854
- // Generate embedding via AgentDB's embedder
900
+ // Generate embedding via AgentDB's embedder, falling back to the local
901
+ // chain (#3325). If neither can produce one, the row is still written but
902
+ // the result says why instead of silently storing embedding=NULL.
855
903
  let embeddingJson = null;
856
904
  let embeddingArr = null;
857
905
  let dimensions = 0;
858
906
  let model = 'local';
907
+ let embeddingError;
859
908
  if (options.generateEmbeddingFlag !== false && value.length > 0) {
860
- try {
861
- const embedder = ctx.agentdb.embedder;
862
- if (embedder) {
863
- const emb = await embedder.embed(value);
864
- if (emb) {
865
- embeddingArr = Array.from(emb);
866
- embeddingJson = JSON.stringify(embeddingArr);
867
- dimensions = emb.length;
868
- model = 'Xenova/all-MiniLM-L6-v2';
869
- }
870
- }
909
+ const emb = await embedForBridge(ctx.agentdb, value);
910
+ if (emb.vector) {
911
+ embeddingArr = emb.vector;
912
+ embeddingJson = JSON.stringify(embeddingArr);
913
+ dimensions = embeddingArr.length;
914
+ model = emb.model;
871
915
  }
872
- catch {
873
- // Embedding failed — store without
916
+ else {
917
+ embeddingError = emb.reason;
874
918
  }
875
919
  }
876
920
  // #2775: strict-insert path now auto-resurrects soft-deleted tombstones
@@ -1011,6 +1055,7 @@ export async function bridgeStoreEntry(options) {
1011
1055
  cached: true,
1012
1056
  attested: true,
1013
1057
  ...(persistWarning ? { persistWarning } : {}),
1058
+ ...(embeddingError ? { embeddingError } : {}),
1014
1059
  };
1015
1060
  }
1016
1061
  catch (err) {
@@ -1061,18 +1106,10 @@ export async function bridgeSearchEntries(options) {
1061
1106
  const { query: queryStr, namespace, limit = 10, threshold = 0.3, provenanceFilter } = options;
1062
1107
  const effectiveNamespace = namespace || 'all';
1063
1108
  const startTime = Date.now();
1064
- // Generate query embedding
1065
- let queryEmbedding = null;
1066
- try {
1067
- const embedder = ctx.agentdb.embedder;
1068
- if (embedder) {
1069
- const emb = await embedder.embed(queryStr);
1070
- queryEmbedding = Array.from(emb);
1071
- }
1072
- }
1073
- catch {
1074
- // Fall back to keyword search
1075
- }
1109
+ // Generate query embedding — same agentdb-then-local chain as the write
1110
+ // path (#3325), so rows embedded by the local fallback are searchable.
1111
+ // No vector → keyword (BM25) search only.
1112
+ const queryEmbedding = (await embedForBridge(ctx.agentdb, queryStr)).vector;
1076
1113
  // better-sqlite3: .prepare().all() returns array of objects
1077
1114
  // ADR-323: compose namespace + provenance filters into one WHERE clause.
1078
1115
  const filters = [];
@@ -1300,7 +1337,10 @@ export async function bridgeGetEntry(options) {
1300
1337
  accessCount: cached.accessCount ?? 0,
1301
1338
  createdAt: cached.createdAt || new Date().toISOString(),
1302
1339
  updatedAt: cached.updatedAt || new Date().toISOString(),
1303
- hasEmbedding: !!cached.embedding,
1340
+ // #3325: the cache holds the `entry` object built below, which has
1341
+ // `hasEmbedding` but no `embedding` field — so `!!cached.embedding`
1342
+ // reported false on every cache hit, even for embedded rows.
1343
+ hasEmbedding: typeof cached.hasEmbedding === 'boolean' ? cached.hasEmbedding : !!cached.embedding,
1304
1344
  tags: cached.tags || [],
1305
1345
  },
1306
1346
  };
@@ -1830,16 +1870,33 @@ export async function bridgeStorePattern(options) {
1830
1870
  try {
1831
1871
  const reasoningBank = registry.get('reasoningBank');
1832
1872
  const patternId = generateId('pattern');
1833
- if (reasoningBank && typeof reasoningBank.store === 'function') {
1834
- await reasoningBank.store({
1835
- id: patternId,
1836
- content: options.pattern,
1837
- type: options.type,
1838
- confidence: options.confidence,
1873
+ // #3327 Finding A — the real method is `storePattern`, and it takes a
1874
+ // ReasoningPattern, NOT the {id, content, type, confidence} shape used
1875
+ // here before. `reasoningBank.store` has never existed on agentdb's
1876
+ // ReasoningBank, so `typeof ... === 'function'` was always false and this
1877
+ // branch was dead code — every write fell through to bridge-fallback while
1878
+ // `agentdb_controllers` cheerfully reported `reasoningBank: enabled=true`.
1879
+ //
1880
+ // Contract (agentdb ReasoningBank.d.ts):
1881
+ // storePattern({ taskType, approach, successRate, uses?, avgReward?,
1882
+ // tags?, metadata? }) => Promise<number> // sqlite rowid
1883
+ // The embedded text is `${taskType}: ${approach}`, so the caller's pattern
1884
+ // text must land in `approach` for search to match on it.
1885
+ if (reasoningBank && typeof reasoningBank.storePattern === 'function') {
1886
+ const rowId = await reasoningBank.storePattern({
1887
+ taskType: options.type,
1888
+ approach: options.pattern,
1889
+ successRate: options.confidence,
1890
+ tags: [options.type, 'reasoning-pattern'],
1839
1891
  metadata: options.metadata,
1840
- timestamp: Date.now(),
1841
1892
  });
1842
- return { success: true, patternId, controller: 'reasoningBank' };
1893
+ // storePattern returns a numeric rowid; surface it as the caller-facing
1894
+ // id so a later getPattern/deletePattern by this id resolves.
1895
+ return {
1896
+ success: true,
1897
+ patternId: rowId != null ? String(rowId) : patternId,
1898
+ controller: 'reasoningBank',
1899
+ };
1843
1900
  }
1844
1901
  // Fallback: store via bridge SQL
1845
1902
  const patternValue = JSON.stringify({ pattern: options.pattern, type: options.type, confidence: options.confidence, metadata: options.metadata });
@@ -1871,9 +1928,23 @@ export async function bridgeStorePattern(options) {
1871
1928
  // was actually stored under. getEntry/memory_retrieve look up by `key`,
1872
1929
  // so returning result.id here handed the caller a handle that can never
1873
1930
  // be read back — return `patternId` (the real key) instead.
1874
- return { success: true, patternId, controller: 'bridge-fallback' };
1931
+ // #3325: say whether the row got a vector. Without one, Tier-1 (semantic)
1932
+ // pattern search cannot find it — report that here, at write time.
1933
+ return {
1934
+ success: true,
1935
+ patternId,
1936
+ controller: 'bridge-fallback',
1937
+ hasEmbedding: !!result.embedding,
1938
+ ...(result.embeddingError ? { embeddingError: result.embeddingError } : {}),
1939
+ };
1875
1940
  }
1876
- catch {
1941
+ catch (err) {
1942
+ // #3327 Finding A — this catch is what hid the defect for months. When
1943
+ // ReasoningBank threw `embedPassage is not a function`, the error was
1944
+ // discarded and the caller saw an ordinary fallback, indistinguishable
1945
+ // from "no controller registered". Record it so `agentdb_health` and the
1946
+ // degraded `reason` can name the real cause instead of guessing.
1947
+ bridgeFailureReason = err instanceof Error ? err.message : String(err);
1877
1948
  return null;
1878
1949
  }
1879
1950
  }
@@ -1895,11 +1966,17 @@ export async function bridgeSearchPatterns(options) {
1895
1966
  else {
1896
1967
  results = await reasoningBank.search(options.query, { topK: options.topK || 5, minScore: options.minConfidence || 0.3 });
1897
1968
  }
1969
+ // #3327 Finding A — agentdb returns ReasoningPattern[]: the text lives in
1970
+ // `approach` and the cosine score in `similarity`. Neither `content`/
1971
+ // `pattern` nor `score`/`confidence` exists on that shape, so the old
1972
+ // mapping produced `content: ''` and `score: 0` for every hit even when
1973
+ // the search itself succeeded. Read the real fields first, keeping the
1974
+ // legacy names as fallbacks for the pre-agentdb shape.
1898
1975
  return {
1899
1976
  results: Array.isArray(results) ? results.map((r) => ({
1900
- id: r.id || r.patternId || '',
1901
- content: r.content || r.pattern || '',
1902
- score: r.score ?? r.confidence ?? 0,
1977
+ id: String(r.id ?? r.patternId ?? ''),
1978
+ content: r.approach ?? r.content ?? r.pattern ?? '',
1979
+ score: r.similarity ?? r.score ?? r.successRate ?? r.confidence ?? 0,
1903
1980
  })) : [],
1904
1981
  controller: 'reasoningBank',
1905
1982
  };
@@ -1954,7 +2031,12 @@ export async function bridgeSearchPatterns(options) {
1954
2031
  controller: 'bridge-fallback',
1955
2032
  } : null;
1956
2033
  }
1957
- catch {
2034
+ catch (err) {
2035
+ // #3327 Finding A — see bridgeStorePattern's catch. `embedQuery is not a
2036
+ // function` died here silently, which is why search reported
2037
+ // `reasoningBank-unavailable:registry-null` (a null return) even though
2038
+ // the registry was present and the controller was reported enabled.
2039
+ bridgeFailureReason = err instanceof Error ? err.message : String(err);
1958
2040
  return null;
1959
2041
  }
1960
2042
  }
@@ -452,6 +452,9 @@ export declare function storeEntry(options: {
452
452
  /** #2968: set when the bridge's checkpoint failed in a way indicating
453
453
  * this write may not be durably persisted (sql.js fallback driver). */
454
454
  persistWarning?: string;
455
+ /** #3325: set by the bridge when an embedding was requested but none could
456
+ * be produced — the row is stored without a vector. */
457
+ embeddingError?: string;
455
458
  }>;
456
459
  /**
457
460
  * Search entries using sql.js with vector similarity
@@ -81,6 +81,23 @@ function hasNativeWalSidecars(dbPath) {
81
81
  return true;
82
82
  }
83
83
  }
84
+ /**
85
+ * #3397 — this process's own graph-edge-writer handle keeps -wal/-shm on disk
86
+ * between its idle-release ticks. Release (checkpoint + close) it before the
87
+ * #2735 guard runs, so the guard only sees sidecars some OTHER native
88
+ * connection is holding. The guard itself is unchanged: even a same-process
89
+ * open WAL connection makes a whole-image sql.js write unsafe until its WAL
90
+ * has been checkpointed, which is exactly what releasing does.
91
+ */
92
+ async function releaseOwnNativeHandle(dbPath) {
93
+ try {
94
+ const { releaseBridgeDb } = await import('./graph-edge-writer.js');
95
+ releaseBridgeDb(dbPath);
96
+ }
97
+ catch {
98
+ // Writer module unavailable — nothing of ours to release; the guard decides.
99
+ }
100
+ }
84
101
  /**
85
102
  * #1854: previously every site that needed the memory directory hardcoded
86
103
  * `getMemoryRoot()`, so the documented config entry
@@ -1957,7 +1974,17 @@ export async function applyTemporalDecay(dbPath) {
1957
1974
  };
1958
1975
  }
1959
1976
  }
1977
+ /**
1978
+ * State of the LOCAL embedding chain only (transformers.js / agentic-flow /
1979
+ * ruvector ONNX / hash). #3375: the AgentDB bridge's result is cached
1980
+ * separately in `bridgeEmbeddingInfo` and must never be written here — it used
1981
+ * to be recorded as `{ loaded: true, model: null }`, which made
1982
+ * generateLocalEmbedding() skip loading any local model and always return the
1983
+ * hash fallback, so rescueAgentdbEmbedder()'s `backend === 'onnx'` probe could
1984
+ * never pass.
1985
+ */
1960
1986
  let embeddingModelState = null;
1987
+ let bridgeEmbeddingInfo = null;
1961
1988
  /**
1962
1989
  * Lazy load ONNX embedding model
1963
1990
  * Only loads when first embedding is requested
@@ -1966,10 +1993,11 @@ export async function loadEmbeddingModel(options) {
1966
1993
  const { verbose = false } = options || {};
1967
1994
  const startTime = Date.now();
1968
1995
  // Already loaded
1969
- if (embeddingModelState?.loaded) {
1996
+ const cached = bridgeEmbeddingInfo ?? (embeddingModelState?.loaded ? embeddingModelState : null);
1997
+ if (cached) {
1970
1998
  return {
1971
1999
  success: true,
1972
- dimensions: embeddingModelState.dimensions,
2000
+ dimensions: cached.dimensions,
1973
2001
  modelName: 'cached',
1974
2002
  loadTime: 0
1975
2003
  };
@@ -1979,16 +2007,24 @@ export async function loadEmbeddingModel(options) {
1979
2007
  if (bridge) {
1980
2008
  const bridgeResult = await bridge.bridgeLoadEmbeddingModel();
1981
2009
  if (bridgeResult && bridgeResult.success) {
1982
- // Mark local state as loaded too so subsequent calls use cache
1983
- embeddingModelState = {
1984
- loaded: true,
1985
- model: null, // Bridge handles embedding
1986
- tokenizer: null,
1987
- dimensions: bridgeResult.dimensions
1988
- };
2010
+ // #3375: cache the bridge result on its own. Do NOT mark the local
2011
+ // chain as loaded — the bridge's model is not callable from here.
2012
+ bridgeEmbeddingInfo = { dimensions: bridgeResult.dimensions };
1989
2013
  return bridgeResult;
1990
2014
  }
1991
2015
  }
2016
+ return loadLocalEmbeddingChain(verbose, startTime);
2017
+ }
2018
+ /**
2019
+ * Load the LOCAL embedding chain into `embeddingModelState`, never consulting
2020
+ * the AgentDB bridge. Used by loadEmbeddingModel() after the bridge declines,
2021
+ * and directly by generateLocalEmbedding() so the "bridge-free" contract the
2022
+ * #2312 comment on that function describes actually holds (#3375).
2023
+ */
2024
+ async function loadLocalEmbeddingChain(verbose = false, startTime = Date.now()) {
2025
+ if (embeddingModelState?.loaded) {
2026
+ return { success: true, dimensions: embeddingModelState.dimensions, modelName: 'cached', loadTime: 0 };
2027
+ }
1992
2028
  try {
1993
2029
  // ADR-094: prefer @huggingface/transformers (clears protobufjs <7.5.5
1994
2030
  // critical RCE chain), fall back to legacy @xenova/transformers.
@@ -2195,9 +2231,12 @@ export async function generateEmbedding(text) {
2195
2231
  * Keeping the local chain as its own export breaks that cycle structurally.
2196
2232
  */
2197
2233
  export async function generateLocalEmbedding(text) {
2198
- // Ensure model is loaded
2234
+ // Ensure the LOCAL model is loaded. #3375: this must not go through
2235
+ // loadEmbeddingModel(), which is bridge-first — when the bridge answered
2236
+ // there, no local model was ever loaded and this function always returned
2237
+ // the hash fallback.
2199
2238
  if (!embeddingModelState?.loaded) {
2200
- await loadEmbeddingModel();
2239
+ await loadLocalEmbeddingChain();
2201
2240
  }
2202
2241
  // #2461: loadEmbeddingModel() can leave embeddingModelState null when an
2203
2242
  // earlier loader (transformers fetch, ruvector init) throws and we never
@@ -2535,6 +2574,7 @@ export async function storeEntry(options) {
2535
2574
  // this closes and its known residual (the narrow assess-then-write
2536
2575
  // race). This check gates ensureSchemaColumns()'s own whole-image
2537
2576
  // write below too, not just this function's.
2577
+ await releaseOwnNativeHandle(dbPath);
2538
2578
  if (hasNativeWalSidecars(dbPath)) {
2539
2579
  return {
2540
2580
  success: false,
@@ -3043,6 +3083,7 @@ export async function getEntry(options) {
3043
3083
  // this closes. Applies here too because the fallback's access_count
3044
3084
  // bump is itself a whole-image write, not a lightweight read, even
3045
3085
  // though this function's contract reads as a "get".
3086
+ await releaseOwnNativeHandle(dbPath);
3046
3087
  if (hasNativeWalSidecars(dbPath)) {
3047
3088
  return {
3048
3089
  success: false,
@@ -3162,6 +3203,7 @@ export async function deleteEntry(options) {
3162
3203
  }
3163
3204
  // #2735 — see storeEntry's identical gate for the corruption mechanism
3164
3205
  // this closes.
3206
+ await releaseOwnNativeHandle(dbPath);
3165
3207
  if (hasNativeWalSidecars(dbPath)) {
3166
3208
  return {
3167
3209
  success: false,
@@ -0,0 +1,119 @@
1
+ /**
2
+ * typesafe-router.ts — opt-in `@ruvector/typesafe` augmentation for `hooks_route`.
3
+ *
4
+ * Mirrors ADR-150's MetaHarness rules for optional integrations:
5
+ * 1. Removable — the package is loaded with a dynamic import only; any load,
6
+ * construction or decide error falls back to the existing router.
7
+ * 2. Opt-in — does nothing unless `CLAUDE_FLOW_ROUTER_TYPESAFE=1`. With the
8
+ * flag unset the package is never imported and the legacy result is
9
+ * returned unchanged (same object, no added fields).
10
+ * 3. Optional — declared as an optional peer of `@claude-flow/cli`.
11
+ * 4. Honest — the result carries `routedBy`, typesafe's confidence, abstain
12
+ * mass and `calibrated` flag verbatim. The default `hash` embedder is
13
+ * uncalibrated, so its confidence is reported as `confidenceCalibrated:
14
+ * false` and is never copied into `estimatedMetrics.successProbability`.
15
+ *
16
+ * Gate: typesafe's answer is used only when all hold —
17
+ * - `abstain <= maxAbstain` (default 0.30)
18
+ * - lift = top-1 probability × option count >= `minLift` (default 1.2, i.e.
19
+ * 20% above chance). Lift, not raw confidence, because confidence scales
20
+ * with the option count (~0.1 for ten agents) and differs per embedder.
21
+ * - top-1 beats the runner-up by >= `minMargin` (default 0.005); a uniform
22
+ * distribution — text that matches nothing — has margin 0.
23
+ * Otherwise the legacy route is kept and `typesafe.reason` says which gate failed.
24
+ *
25
+ * @module typesafe-router
26
+ */
27
+ /** Keyword/agent table shape shared with hooks-tools' TASK_PATTERNS. */
28
+ export interface RoutingPatternLike {
29
+ keywords: string[];
30
+ agents: string[];
31
+ }
32
+ /** One `choice` option in typesafe's `{ what, not_for, examples }` form. */
33
+ export interface TypesafeCriterion {
34
+ what: string;
35
+ not_for?: string;
36
+ examples?: string[];
37
+ }
38
+ /** The subset of a typesafe choice answer this adapter reads. */
39
+ export interface TypesafeChoiceAnswer {
40
+ choice: string;
41
+ probabilities: Record<string, number>;
42
+ confidence: number;
43
+ abstain: number;
44
+ calibrated: boolean;
45
+ head?: string;
46
+ model?: string;
47
+ }
48
+ /** The subset of `@ruvector/typesafe`'s module surface this adapter uses. */
49
+ export interface TypesafeModuleLike {
50
+ createTypesafe(opts?: Record<string, unknown>): {
51
+ readonly backend?: string;
52
+ decide(state: string, questions: Record<string, unknown>): Promise<Record<string, unknown>>;
53
+ };
54
+ choice?(criteria: Record<string, TypesafeCriterion>): unknown;
55
+ }
56
+ export interface TypesafeRouterConfig {
57
+ enabled: boolean;
58
+ minLift: number;
59
+ maxAbstain: number;
60
+ minMargin: number;
61
+ /** `'hash'` (default, uncalibrated) or an ONNX model dir + manifest. */
62
+ embedder: 'hash' | {
63
+ kind: 'onnx';
64
+ modelDir: string;
65
+ manifest: string;
66
+ };
67
+ }
68
+ export interface TypesafeRouteOutcome {
69
+ used: boolean;
70
+ reason: string;
71
+ answer?: TypesafeChoiceAnswer;
72
+ backend?: string;
73
+ embedder?: string;
74
+ /** top-1 probability × option count (1.0 = chance). */
75
+ lift?: number;
76
+ thresholds: Pick<TypesafeRouterConfig, 'minLift' | 'maxAbstain' | 'minMargin'>;
77
+ }
78
+ /** Injectable deps (tests). `loadModule` defaults to a dynamic import of the package. */
79
+ export interface TypesafeRouterDeps {
80
+ env?: NodeJS.ProcessEnv;
81
+ loadModule?: () => Promise<unknown>;
82
+ debug?: (msg: string) => void;
83
+ }
84
+ /**
85
+ * Build choice options from the router's pattern table: every primary agent of
86
+ * a pattern, plus the profiled roles (researcher/reviewer) the table only lists
87
+ * as alternates. Each pattern's keywords are appended to its primary agent's
88
+ * `what`, so the options track TASK_PATTERNS rather than a parallel list.
89
+ */
90
+ export declare function buildAgentCriteria(patterns: Record<string, RoutingPatternLike>): Record<string, TypesafeCriterion>;
91
+ /** Read config from env. Invalid numeric values fall back to the defaults. */
92
+ export declare function readTypesafeConfig(env?: NodeJS.ProcessEnv): TypesafeRouterConfig;
93
+ /**
94
+ * Stateful router: loads the module and builds one engine on first use, caches
95
+ * a load failure so a missing package costs one import attempt per process.
96
+ */
97
+ export declare class TypesafeRouter {
98
+ private engine;
99
+ private mod;
100
+ private loadError;
101
+ private readonly env;
102
+ private readonly loadModule;
103
+ private readonly debug;
104
+ constructor(deps?: TypesafeRouterDeps);
105
+ isEnabled(): boolean;
106
+ private ensureEngine;
107
+ /** Ask typesafe for an agent. Never throws; `used: false` means keep the legacy route. */
108
+ route(task: string, patterns: Record<string, RoutingPatternLike>): Promise<TypesafeRouteOutcome>;
109
+ }
110
+ type RouteResult = Record<string, unknown>;
111
+ /**
112
+ * Merge a typesafe outcome into a legacy `hooks_route` result. Disabled or
113
+ * error results (`success: false`) pass through untouched.
114
+ */
115
+ export declare function applyTypesafeRouting(params: Record<string, unknown>, legacy: RouteResult, patterns: Record<string, RoutingPatternLike>, router: TypesafeRouter): Promise<RouteResult>;
116
+ /** Process-wide router used by hooks_route. */
117
+ export declare function getTypesafeRouter(): TypesafeRouter;
118
+ export {};
119
+ //# sourceMappingURL=typesafe-router.d.ts.map