agentic-flow 2.0.12-fix.8 → 2.0.12

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.
File without changes
package/dist/cli-proxy.js CHANGED
File without changes
@@ -1,6 +1,12 @@
1
1
  /**
2
2
  * Embedding generation for semantic similarity
3
3
  * Uses local transformers.js - no API key required!
4
+ *
5
+ * `@xenova/transformers` is an OPTIONAL dependency. The module is loaded
6
+ * dynamically inside `initializeEmbeddings()` so the rest of this file is
7
+ * importable even when transformers.js is absent (e.g. when consumers
8
+ * pass `npm install --omit=optional`). Code paths that don't call
9
+ * `computeEmbedding()` continue to work without ever loading the module.
4
10
  */
5
11
  /**
6
12
  * Compute embedding for text using local model
@@ -1 +1 @@
1
- {"version":3,"file":"embeddings.d.ts","sourceRoot":"","sources":["../../../src/reasoningbank/utils/embeddings.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAgEH;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAmE1E;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAEpF;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,CAE/C;AA+CD;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAO1C"}
1
+ {"version":3,"file":"embeddings.d.ts","sourceRoot":"","sources":["../../../src/reasoningbank/utils/embeddings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAyFH;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAuE1E;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAEpF;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,CAE/C;AA+CD;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAO1C"}
@@ -1,13 +1,20 @@
1
1
  /**
2
2
  * Embedding generation for semantic similarity
3
3
  * Uses local transformers.js - no API key required!
4
+ *
5
+ * `@xenova/transformers` is an OPTIONAL dependency. The module is loaded
6
+ * dynamically inside `initializeEmbeddings()` so the rest of this file is
7
+ * importable even when transformers.js is absent (e.g. when consumers
8
+ * pass `npm install --omit=optional`). Code paths that don't call
9
+ * `computeEmbedding()` continue to work without ever loading the module.
4
10
  */
5
- import { pipeline, env } from '@xenova/transformers';
6
11
  import { loadConfig } from './config.js';
7
- // Configure transformers.js to use WASM backend only (avoid ONNX runtime issues)
8
- // The native ONNX runtime causes "DefaultLogger not registered" errors in Node.js
9
- env.backends.onnx.wasm.proxy = false; // Disable ONNX runtime proxy
10
- env.backends.onnx.wasm.numThreads = 1; // Single thread for stability
12
+ // Cached references resolved at first call to initializeEmbeddings(). Types
13
+ // are imported as `type-only` so TypeScript can typecheck the file without
14
+ // requiring @xenova/transformers to be installed at build time — the actual
15
+ // runtime import is dynamic below.
16
+ let pipeline = null;
17
+ let env = null;
11
18
  let embeddingPipeline = null;
12
19
  let initializationPromise = null;
13
20
  const embeddingCache = new Map();
@@ -37,15 +44,38 @@ async function initializeEmbeddings() {
37
44
  }
38
45
  // RACE CONDITION FIX: Create promise for concurrent callers to await
39
46
  initializationPromise = (async () => {
47
+ // Optional-dep load: try to import @xenova/transformers. If absent,
48
+ // emit a clear warning and let callers fall back to hash-based embeddings.
49
+ if (!pipeline || !env) {
50
+ try {
51
+ const transformers = await import('@xenova/transformers');
52
+ pipeline = transformers.pipeline;
53
+ env = transformers.env;
54
+ // Configure transformers.js to use WASM backend only (avoid ONNX runtime issues)
55
+ // The native ONNX runtime causes "DefaultLogger not registered" errors in Node.js
56
+ env.backends.onnx.wasm.proxy = false; // Disable ONNX runtime proxy
57
+ env.backends.onnx.wasm.numThreads = 1; // Single thread for stability
58
+ }
59
+ catch (err) {
60
+ console.warn('[Embeddings] @xenova/transformers not installed (optional dependency).');
61
+ console.warn('[Embeddings] Install with: npm install @xenova/transformers');
62
+ console.warn('[Embeddings] Falling back to hash-based embeddings');
63
+ initializationPromise = null;
64
+ return;
65
+ }
66
+ }
40
67
  console.log('[Embeddings] Initializing local embedding model (Xenova/all-MiniLM-L6-v2)...');
41
68
  console.log('[Embeddings] First run will download ~23MB model...');
42
69
  try {
43
- embeddingPipeline = await pipeline('feature-extraction', 'Xenova/all-MiniLM-L6-v2', { quantized: true } // Smaller, faster
44
- );
70
+ // `pipeline('feature-extraction', ...)` returns a union; narrow to
71
+ // FeatureExtractionPipeline so call-sites can use .pooling / .normalize.
72
+ embeddingPipeline = (await pipeline('feature-extraction', 'Xenova/all-MiniLM-L6-v2', { quantized: true } // Smaller, faster
73
+ ));
45
74
  console.log('[Embeddings] Local model ready! (384 dimensions)');
46
75
  }
47
76
  catch (error) {
48
- console.error('[Embeddings] Failed to initialize:', error?.message || error);
77
+ const msg = error instanceof Error ? error.message : String(error);
78
+ console.error('[Embeddings] Failed to initialize:', msg);
49
79
  console.warn('[Embeddings] Falling back to hash-based embeddings');
50
80
  // Reset promise so retry is possible
51
81
  initializationPromise = null;
@@ -73,10 +103,14 @@ export async function computeEmbedding(text) {
73
103
  pooling: 'mean',
74
104
  normalize: true
75
105
  });
106
+ // output.data is a Tensor.data typed-array union; cast to a Float32-
107
+ // compatible source. The model is feature-extraction with normalize:true
108
+ // so the underlying buffer is always Float32 at runtime.
76
109
  embedding = new Float32Array(output.data);
77
110
  }
78
111
  catch (error) {
79
- console.error('[Embeddings] Generation failed:', error?.message || error);
112
+ const msg = error instanceof Error ? error.message : String(error);
113
+ console.error('[Embeddings] Generation failed:', msg);
80
114
  embedding = hashEmbed(text, 384); // Fallback
81
115
  }
82
116
  }
@@ -1 +1 @@
1
- {"version":3,"file":"embeddings.js","sourceRoot":"","sources":["../../../src/reasoningbank/utils/embeddings.ts"],"names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transformers.js - no API key required!\n */\n\nimport { pipeline, env } from '@xenova/transformers';\nimport { loadConfig } from './config.js';\n\n// Configure transformers.js to use WASM backend only (avoid ONNX runtime issues)\n// The native ONNX runtime causes \"DefaultLogger not registered\" errors in Node.js\nenv.backends.onnx.wasm.proxy = false; // Disable ONNX runtime proxy\nenv.backends.onnx.wasm.numThreads = 1; // Single thread for stability\n\nlet embeddingPipeline: any = null;\nlet initializationPromise: Promise<void> | null = null;\nconst embeddingCache = new Map<string, Float32Array>();\n// MEMORY LEAK FIX: Track TTL timers so they can be cleaned up\nconst embeddingTimers = new Map<string, NodeJS.Timeout>();\n\n/**\n * Initialize the embedding pipeline (lazy load)\n * RACE CONDITION FIX: Use promise-based initialization instead of busy-wait\n */\nasync function initializeEmbeddings(): Promise<void> {\n // Already initialized\n if (embeddingPipeline) return;\n\n // Initialization in progress - await existing promise\n if (initializationPromise) {\n return initializationPromise;\n }\n\n // Detect npx environment (known transformer initialization issues)\n const isNpxEnv = process.env.npm_lifecycle_event === 'npx' ||\n process.env.npm_execpath?.includes('npx') ||\n process.cwd().includes('/_npx/') ||\n process.cwd().includes('\\\\_npx\\\\');\n\n if (isNpxEnv && !process.env.FORCE_TRANSFORMERS) {\n console.log('[Embeddings] NPX environment detected - using hash-based embeddings');\n console.log('[Embeddings] For semantic search, install globally: npm install -g claude-flow');\n return;\n }\n\n // RACE CONDITION FIX: Create promise for concurrent callers to await\n initializationPromise = (async () => {\n console.log('[Embeddings] Initializing local embedding model (Xenova/all-MiniLM-L6-v2)...');\n console.log('[Embeddings] First run will download ~23MB model...');\n\n try {\n embeddingPipeline = await pipeline(\n 'feature-extraction',\n 'Xenova/all-MiniLM-L6-v2',\n { quantized: true } // Smaller, faster\n );\n console.log('[Embeddings] Local model ready! (384 dimensions)');\n } catch (error: any) {\n console.error('[Embeddings] Failed to initialize:', error?.message || error);\n console.warn('[Embeddings] Falling back to hash-based embeddings');\n // Reset promise so retry is possible\n initializationPromise = null;\n }\n })();\n\n return initializationPromise;\n}\n\n/**\n * Compute embedding for text using local model\n */\nexport async function computeEmbedding(text: string): Promise<Float32Array> {\n const config = loadConfig();\n\n // Check cache\n const cacheKey = `local:${text}`;\n if (embeddingCache.has(cacheKey)) {\n return embeddingCache.get(cacheKey)!;\n }\n\n let embedding: Float32Array;\n\n // Initialize if needed\n await initializeEmbeddings();\n\n if (embeddingPipeline) {\n try {\n // Use transformers.js for real embeddings\n const output = await embeddingPipeline(text, {\n pooling: 'mean',\n normalize: true\n });\n embedding = new Float32Array(output.data);\n } catch (error: any) {\n console.error('[Embeddings] Generation failed:', error?.message || error);\n embedding = hashEmbed(text, 384); // Fallback\n }\n } else {\n // Fallback to hash-based embeddings\n const dims = config?.embeddings?.dimensions || 384;\n embedding = hashEmbed(text, dims);\n }\n\n // MEMORY LEAK FIX: Clear existing timer if key exists\n const existingTimer = embeddingTimers.get(cacheKey);\n if (existingTimer) {\n clearTimeout(existingTimer);\n embeddingTimers.delete(cacheKey);\n }\n\n // Cache with LRU (limit 1000 entries)\n // PERFORMANCE FIX: Use proper LRU by tracking access order\n if (embeddingCache.size >= 1000) {\n // Find and remove oldest entry (first key in iteration order)\n const firstKey = embeddingCache.keys().next().value;\n if (firstKey) {\n embeddingCache.delete(firstKey);\n // Also clear its timer\n const timer = embeddingTimers.get(firstKey);\n if (timer) {\n clearTimeout(timer);\n embeddingTimers.delete(firstKey);\n }\n }\n }\n embeddingCache.set(cacheKey, embedding);\n\n // Set TTL for cache entry with tracked timer\n const ttl = config?.embeddings?.cache_ttl_seconds || 3600;\n const timerId = setTimeout(() => {\n embeddingCache.delete(cacheKey);\n embeddingTimers.delete(cacheKey);\n }, ttl * 1000);\n\n // MEMORY LEAK FIX: Track timer for cleanup\n embeddingTimers.set(cacheKey, timerId);\n\n return embedding;\n}\n\n/**\n * Batch compute embeddings (more efficient)\n */\nexport async function computeEmbeddingBatch(texts: string[]): Promise<Float32Array[]> {\n return Promise.all(texts.map(text => computeEmbedding(text)));\n}\n\n/**\n * Get embedding dimensions\n */\nexport function getEmbeddingDimensions(): number {\n return 384; // all-MiniLM-L6-v2 uses 384 dimensions\n}\n\n/**\n * Deterministic hash-based embedding (fallback)\n */\nfunction hashEmbed(text: string, dims: number): Float32Array {\n const hash = simpleHash(text);\n const vec = new Float32Array(dims);\n\n // Generate deterministic pseudo-random vector from hash\n for (let i = 0; i < dims; i++) {\n vec[i] = Math.sin(hash * (i + 1) * 0.01) + Math.cos(hash * i * 0.02);\n }\n\n return normalize(vec);\n}\n\n/**\n * Simple string hash function\n */\nfunction simpleHash(str: string): number {\n let hash = 0;\n for (let i = 0; i < str.length; i++) {\n hash = ((hash << 5) - hash) + str.charCodeAt(i);\n hash |= 0;\n }\n return Math.abs(hash);\n}\n\n/**\n * Normalize vector to unit length\n */\nfunction normalize(vec: Float32Array): Float32Array {\n let mag = 0;\n for (let i = 0; i < vec.length; i++) {\n mag += vec[i] * vec[i];\n }\n mag = Math.sqrt(mag);\n\n if (mag === 0) return vec;\n\n for (let i = 0; i < vec.length; i++) {\n vec[i] /= mag;\n }\n return vec;\n}\n\n/**\n * Clear embedding cache\n * MEMORY LEAK FIX: Also clear all TTL timers\n */\nexport function clearEmbeddingCache(): void {\n // Clear all timers first to prevent memory leaks\n for (const timer of embeddingTimers.values()) {\n clearTimeout(timer);\n }\n embeddingTimers.clear();\n embeddingCache.clear();\n}\n"]}
1
+ {"version":3,"file":"embeddings.js","sourceRoot":"","sources":["../../../src/reasoningbank/utils/embeddings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,4EAA4E;AAC5E,2EAA2E;AAC3E,4EAA4E;AAC5E,mCAAmC;AACnC,IAAI,QAAQ,GAA2B,IAAI,CAAC;AAC5C,IAAI,GAAG,GAAsB,IAAI,CAAC;AAElC,IAAI,iBAAiB,GAAqC,IAAI,CAAC;AAC/D,IAAI,qBAAqB,GAAyB,IAAI,CAAC;AACvD,MAAM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GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAErB,IAAI,GAAG,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC;IAE1B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACpC,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC;IAChB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB;IACjC,iDAAiD;IACjD,KAAK,MAAM,KAAK,IAAI,eAAe,CAAC,MAAM,EAAE,EAAE,CAAC;QAC7C,YAAY,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;IACD,eAAe,CAAC,KAAK,EAAE,CAAC;IACxB,cAAc,CAAC,KAAK,EAAE,CAAC;AACzB,CAAC","sourcesContent":["/**\n * Embedding generation for semantic similarity\n * Uses local transformers.js - no API key required!\n *\n * `@xenova/transformers` is an OPTIONAL dependency. The module is loaded\n * dynamically inside `initializeEmbeddings()` so the rest of this file is\n * importable even when transformers.js is absent (e.g. when consumers\n * pass `npm install --omit=optional`). Code paths that don't call\n * `computeEmbedding()` continue to work without ever loading the module.\n */\n\nimport type { pipeline as Pipeline, env as Env, FeatureExtractionPipeline } from '@xenova/transformers';\nimport { loadConfig } from './config.js';\n\n// Cached references resolved at first call to initializeEmbeddings(). Types\n// are imported as `type-only` so TypeScript can typecheck the file without\n// requiring @xenova/transformers to be installed at build time — the actual\n// runtime import is dynamic below.\nlet pipeline: typeof Pipeline | null = null;\nlet env: typeof Env | null = null;\n\nlet embeddingPipeline: FeatureExtractionPipeline | null = null;\nlet initializationPromise: Promise<void> | null = null;\nconst embeddingCache = new Map<string, Float32Array>();\n// MEMORY LEAK FIX: Track TTL timers so they can be cleaned up\nconst embeddingTimers = new Map<string, NodeJS.Timeout>();\n\n/**\n * Initialize the embedding pipeline (lazy load)\n * RACE CONDITION FIX: Use promise-based initialization instead of busy-wait\n */\nasync function initializeEmbeddings(): Promise<void> {\n // Already initialized\n if (embeddingPipeline) return;\n\n // Initialization in progress - await existing promise\n if (initializationPromise) {\n return initializationPromise;\n }\n\n // Detect npx environment (known transformer initialization issues)\n const isNpxEnv = process.env.npm_lifecycle_event === 'npx' ||\n process.env.npm_execpath?.includes('npx') ||\n process.cwd().includes('/_npx/') ||\n process.cwd().includes('\\\\_npx\\\\');\n\n if (isNpxEnv && !process.env.FORCE_TRANSFORMERS) {\n console.log('[Embeddings] NPX environment detected - using hash-based embeddings');\n console.log('[Embeddings] For semantic search, install globally: npm install -g claude-flow');\n return;\n }\n\n // RACE CONDITION FIX: Create promise for concurrent callers to await\n initializationPromise = (async () => {\n // Optional-dep load: try to import @xenova/transformers. If absent,\n // emit a clear warning and let callers fall back to hash-based embeddings.\n if (!pipeline || !env) {\n try {\n const transformers = await import('@xenova/transformers');\n pipeline = transformers.pipeline;\n env = transformers.env;\n // Configure transformers.js to use WASM backend only (avoid ONNX runtime issues)\n // The native ONNX runtime causes \"DefaultLogger not registered\" errors in Node.js\n env.backends.onnx.wasm.proxy = false; // Disable ONNX runtime proxy\n env.backends.onnx.wasm.numThreads = 1; // Single thread for stability\n } catch (err: unknown) {\n console.warn('[Embeddings] @xenova/transformers not installed (optional dependency).');\n console.warn('[Embeddings] Install with: npm install @xenova/transformers');\n console.warn('[Embeddings] Falling back to hash-based embeddings');\n initializationPromise = null;\n return;\n }\n }\n\n console.log('[Embeddings] Initializing local embedding model (Xenova/all-MiniLM-L6-v2)...');\n console.log('[Embeddings] First run will download ~23MB model...');\n\n try {\n // `pipeline('feature-extraction', ...)` returns a union; narrow to\n // FeatureExtractionPipeline so call-sites can use .pooling / .normalize.\n embeddingPipeline = (await pipeline(\n 'feature-extraction',\n 'Xenova/all-MiniLM-L6-v2',\n { quantized: true } // Smaller, faster\n )) as FeatureExtractionPipeline;\n console.log('[Embeddings] Local model ready! (384 dimensions)');\n } catch (error: unknown) {\n const msg = error instanceof Error ? error.message : String(error);\n console.error('[Embeddings] Failed to initialize:', msg);\n console.warn('[Embeddings] Falling back to hash-based embeddings');\n // Reset promise so retry is possible\n initializationPromise = null;\n }\n })();\n\n return initializationPromise;\n}\n\n/**\n * Compute embedding for text using local model\n */\nexport async function computeEmbedding(text: string): Promise<Float32Array> {\n const config = loadConfig();\n\n // Check cache\n const cacheKey = `local:${text}`;\n if (embeddingCache.has(cacheKey)) {\n return embeddingCache.get(cacheKey)!;\n }\n\n let embedding: Float32Array;\n\n // Initialize if needed\n await initializeEmbeddings();\n\n if (embeddingPipeline) {\n try {\n // Use transformers.js for real embeddings\n const output = await embeddingPipeline(text, {\n pooling: 'mean',\n normalize: true\n });\n // output.data is a Tensor.data typed-array union; cast to a Float32-\n // compatible source. The model is feature-extraction with normalize:true\n // so the underlying buffer is always Float32 at runtime.\n embedding = new Float32Array(output.data as unknown as ArrayLike<number>);\n } catch (error: unknown) {\n const msg = error instanceof Error ? error.message : String(error);\n console.error('[Embeddings] Generation failed:', msg);\n embedding = hashEmbed(text, 384); // Fallback\n }\n } else {\n // Fallback to hash-based embeddings\n const dims = config?.embeddings?.dimensions || 384;\n embedding = hashEmbed(text, dims);\n }\n\n // MEMORY LEAK FIX: Clear existing timer if key exists\n const existingTimer = embeddingTimers.get(cacheKey);\n if (existingTimer) {\n clearTimeout(existingTimer);\n embeddingTimers.delete(cacheKey);\n }\n\n // Cache with LRU (limit 1000 entries)\n // PERFORMANCE FIX: Use proper LRU by tracking access order\n if (embeddingCache.size >= 1000) {\n // Find and remove oldest entry (first key in iteration order)\n const firstKey = embeddingCache.keys().next().value;\n if (firstKey) {\n embeddingCache.delete(firstKey);\n // Also clear its timer\n const timer = embeddingTimers.get(firstKey);\n if (timer) {\n clearTimeout(timer);\n embeddingTimers.delete(firstKey);\n }\n }\n }\n embeddingCache.set(cacheKey, embedding);\n\n // Set TTL for cache entry with tracked timer\n const ttl = config?.embeddings?.cache_ttl_seconds || 3600;\n const timerId = setTimeout(() => {\n embeddingCache.delete(cacheKey);\n embeddingTimers.delete(cacheKey);\n }, ttl * 1000);\n\n // MEMORY LEAK FIX: Track timer for cleanup\n embeddingTimers.set(cacheKey, timerId);\n\n return embedding;\n}\n\n/**\n * Batch compute embeddings (more efficient)\n */\nexport async function computeEmbeddingBatch(texts: string[]): Promise<Float32Array[]> {\n return Promise.all(texts.map(text => computeEmbedding(text)));\n}\n\n/**\n * Get embedding dimensions\n */\nexport function getEmbeddingDimensions(): number {\n return 384; // all-MiniLM-L6-v2 uses 384 dimensions\n}\n\n/**\n * Deterministic hash-based embedding (fallback)\n */\nfunction hashEmbed(text: string, dims: number): Float32Array {\n const hash = simpleHash(text);\n const vec = new Float32Array(dims);\n\n // Generate deterministic pseudo-random vector from hash\n for (let i = 0; i < dims; i++) {\n vec[i] = Math.sin(hash * (i + 1) * 0.01) + Math.cos(hash * i * 0.02);\n }\n\n return normalize(vec);\n}\n\n/**\n * Simple string hash function\n */\nfunction simpleHash(str: string): number {\n let hash = 0;\n for (let i = 0; i < str.length; i++) {\n hash = ((hash << 5) - hash) + str.charCodeAt(i);\n hash |= 0;\n }\n return Math.abs(hash);\n}\n\n/**\n * Normalize vector to unit length\n */\nfunction normalize(vec: Float32Array): Float32Array {\n let mag = 0;\n for (let i = 0; i < vec.length; i++) {\n mag += vec[i] * vec[i];\n }\n mag = Math.sqrt(mag);\n\n if (mag === 0) return vec;\n\n for (let i = 0; i < vec.length; i++) {\n vec[i] /= mag;\n }\n return vec;\n}\n\n/**\n * Clear embedding cache\n * MEMORY LEAK FIX: Also clear all TTL timers\n */\nexport function clearEmbeddingCache(): void {\n // Clear all timers first to prevent memory leaks\n for (const timer of embeddingTimers.values()) {\n clearTimeout(timer);\n }\n embeddingTimers.clear();\n embeddingCache.clear();\n}\n"]}
@@ -1,3 +1,2 @@
1
1
  export * from './quic.js';
2
- export { loadQuicTransport, isQuicAvailable, getTransportCapabilities, WebSocketFallbackTransport, DEFAULT_STREAM_ID, type AgentTransport, type AgentMessage, type InboundMessageHandler, type OnMessageOptions, type PoolStatistics, type TransportCapabilities, type QuicTransportConfig as LoaderQuicTransportConfig, type TlsConfig, } from './quic-loader.js';
3
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transport/index.ts"],"names":[],"mappings":"AACA,cAAc,WAAW,CAAC;AAC1B,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,wBAAwB,EACxB,0BAA0B,EAC1B,iBAAiB,EACjB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,IAAI,yBAAyB,EACrD,KAAK,SAAS,GACf,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transport/index.ts"],"names":[],"mappings":"AACA,cAAc,WAAW,CAAC"}
@@ -1,4 +1,3 @@
1
1
  // Transport Layer Exports
2
2
  export * from './quic.js';
3
- export { loadQuicTransport, isQuicAvailable, getTransportCapabilities, WebSocketFallbackTransport, DEFAULT_STREAM_ID, } from './quic-loader.js';
4
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/transport/index.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAC1B,cAAc,WAAW,CAAC;AAC1B,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,wBAAwB,EACxB,0BAA0B,EAC1B,iBAAiB,GASlB,MAAM,kBAAkB,CAAC","sourcesContent":["// Transport Layer Exports\nexport * from './quic.js';\nexport {\n loadQuicTransport,\n isQuicAvailable,\n getTransportCapabilities,\n WebSocketFallbackTransport,\n DEFAULT_STREAM_ID,\n type AgentTransport,\n type AgentMessage,\n type InboundMessageHandler,\n type OnMessageOptions,\n type PoolStatistics,\n type TransportCapabilities,\n type QuicTransportConfig as LoaderQuicTransportConfig,\n type TlsConfig,\n} from './quic-loader.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/transport/index.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAC1B,cAAc,WAAW,CAAC","sourcesContent":["// Transport Layer Exports\nexport * from './quic.js';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentic-flow",
3
- "version": "2.0.12-fix.8",
3
+ "version": "2.0.12",
4
4
  "description": "Production-ready AI agent orchestration platform with 66 specialized agents, 213 MCP tools, ReasoningBank learning memory, and autonomous multi-agent swarms. Built by @ruvnet with Claude Agent SDK, neural networks, memory persistence, GitHub integration, and distributed consensus protocols.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -23,8 +23,7 @@
23
23
  "./router": "./dist/router/index.js",
24
24
  "./agent-booster": "./dist/agent-booster/index.js",
25
25
  "./transport/quic": "./dist/transport/quic.js",
26
- "./embeddings": "./dist/embeddings/index.js",
27
- "./transport/loader": "./dist/transport/quic-loader.js"
26
+ "./embeddings": "./dist/embeddings/index.js"
28
27
  },
29
28
  "scripts": {
30
29
  "postinstall": "node scripts/postinstall.js || true",
@@ -158,7 +157,6 @@
158
157
  "@ruvector/ruvllm": "^0.2.3",
159
158
  "@ruvector/tiny-dancer": "^0.1.17",
160
159
  "@supabase/supabase-js": "^2.78.0",
161
- "@xenova/transformers": "^2.17.2",
162
160
  "axios": "^1.12.2",
163
161
  "dotenv": "^16.4.5",
164
162
  "express": "^5.1.0",
@@ -170,7 +168,7 @@
170
168
  "ruvector-onnx-embeddings-wasm": "^0.1.2",
171
169
  "tiktoken": "^1.0.22",
172
170
  "ulid": "^3.0.1",
173
- "ws": "^8.20.0",
171
+ "ws": "^8.18.3",
174
172
  "yaml": "^2.8.1",
175
173
  "zod": "^3.25.76"
176
174
  },
@@ -178,6 +176,7 @@
178
176
  "@rollup/rollup-darwin-arm64": "^4.59.0",
179
177
  "@ruvector/attention": "^0.1.4",
180
178
  "@ruvector/sona": "^0.1.4",
179
+ "@xenova/transformers": "^2.17.2",
181
180
  "agentdb": "^3.0.0-alpha.14",
182
181
  "better-sqlite3": "^11.10.0",
183
182
  "onnxruntime-node": "^1.23.2",
@@ -104,28 +104,28 @@ export function log(message) {
104
104
  const len0 = WASM_VECTOR_LEN;
105
105
  wasm.log(ptr0, len0);
106
106
  }
107
- export function __wbg___wbindgen_debug_string_edece8177ad01481(arg0, arg1) {
107
+ export function __wbg___wbindgen_debug_string_07cb72cfcc952e2b(arg0, arg1) {
108
108
  const ret = debugString(getObject(arg1));
109
109
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
110
110
  const len1 = WASM_VECTOR_LEN;
111
111
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
112
112
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
113
113
  }
114
- export function __wbg___wbindgen_is_function_5cd60d5cf78b4eef(arg0) {
114
+ export function __wbg___wbindgen_is_function_2f0fd7ceb86e64c5(arg0) {
115
115
  const ret = typeof(getObject(arg0)) === 'function';
116
116
  return ret;
117
117
  }
118
- export function __wbg___wbindgen_is_undefined_35bb9f4c7fd651d5(arg0) {
118
+ export function __wbg___wbindgen_is_undefined_244a92c34d3b6ec0(arg0) {
119
119
  const ret = getObject(arg0) === undefined;
120
120
  return ret;
121
121
  }
122
- export function __wbg___wbindgen_throw_9c31b086c2b26051(arg0, arg1) {
122
+ export function __wbg___wbindgen_throw_9c75d47bf9e7731e(arg0, arg1) {
123
123
  throw new Error(getStringFromWasm0(arg0, arg1));
124
124
  }
125
- export function __wbg__wbg_cb_unref_3fa391f3fcdb55f8(arg0) {
125
+ export function __wbg__wbg_cb_unref_158e43e869788cdc(arg0) {
126
126
  getObject(arg0)._wbg_cb_unref();
127
127
  }
128
- export function __wbg_call_dfde26266607c996() { return handleError(function (arg0, arg1, arg2) {
128
+ export function __wbg_call_a41d6421b30a32c5() { return handleError(function (arg0, arg1, arg2) {
129
129
  const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
130
130
  return addHeapObject(ret);
131
131
  }, arguments); }
@@ -143,15 +143,15 @@ export function __wbg_error_a6fa202b58aa1cd3(arg0, arg1) {
143
143
  export function __wbg_getRandomValues_ef12552bf5acd2fe() { return handleError(function (arg0, arg1) {
144
144
  globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
145
145
  }, arguments); }
146
- export function __wbg_get_dcf82ab8aad1a593() { return handleError(function (arg0, arg1) {
146
+ export function __wbg_get_41476db20fef99a8() { return handleError(function (arg0, arg1) {
147
147
  const ret = Reflect.get(getObject(arg0), getObject(arg1));
148
148
  return addHeapObject(ret);
149
149
  }, arguments); }
150
- export function __wbg_indexedDB_cbfeacc981615a77() { return handleError(function (arg0) {
150
+ export function __wbg_indexedDB_06cbacc078ae71b2() { return handleError(function (arg0) {
151
151
  const ret = getObject(arg0).indexedDB;
152
152
  return isLikeNone(ret) ? 0 : addHeapObject(ret);
153
153
  }, arguments); }
154
- export function __wbg_instanceof_Window_faa5cf994f49cca7(arg0) {
154
+ export function __wbg_instanceof_Window_4153c1818a1c0c0b(arg0) {
155
155
  let result;
156
156
  try {
157
157
  result = getObject(arg0) instanceof Window;
@@ -161,21 +161,21 @@ export function __wbg_instanceof_Window_faa5cf994f49cca7(arg0) {
161
161
  const ret = result;
162
162
  return ret;
163
163
  }
164
- export function __wbg_log_eb752234eec406d1(arg0) {
164
+ export function __wbg_log_72d22df918dcc232(arg0) {
165
165
  console.log(getObject(arg0));
166
166
  }
167
167
  export function __wbg_new_227d7c05414eb861() {
168
168
  const ret = new Error();
169
169
  return addHeapObject(ret);
170
170
  }
171
- export function __wbg_new_typed_c072c4ce9a2a0cdf(arg0, arg1) {
171
+ export function __wbg_new_typed_1137602701dc87d4(arg0, arg1) {
172
172
  try {
173
173
  var state0 = {a: arg0, b: arg1};
174
174
  var cb0 = (arg0, arg1) => {
175
175
  const a = state0.a;
176
176
  state0.a = 0;
177
177
  try {
178
- return __wasm_bindgen_func_elem_357(a, state0.b, arg0, arg1);
178
+ return __wasm_bindgen_func_elem_352(a, state0.b, arg0, arg1);
179
179
  } finally {
180
180
  state0.a = a;
181
181
  }
@@ -186,22 +186,22 @@ export function __wbg_new_typed_c072c4ce9a2a0cdf(arg0, arg1) {
186
186
  state0.a = 0;
187
187
  }
188
188
  }
189
- export function __wbg_open_40ab11cdd8f5ac5a() { return handleError(function (arg0, arg1, arg2, arg3) {
189
+ export function __wbg_open_5a9e43bc5e42b3c5() { return handleError(function (arg0, arg1, arg2, arg3) {
190
190
  const ret = getObject(arg0).open(getStringFromWasm0(arg1, arg2), arg3 >>> 0);
191
191
  return addHeapObject(ret);
192
192
  }, arguments); }
193
- export function __wbg_queueMicrotask_78d584b53af520f5(arg0) {
193
+ export function __wbg_queueMicrotask_40ac6ffc2848ba77(arg0) {
194
+ queueMicrotask(getObject(arg0));
195
+ }
196
+ export function __wbg_queueMicrotask_74d092439f6494c1(arg0) {
194
197
  const ret = getObject(arg0).queueMicrotask;
195
198
  return addHeapObject(ret);
196
199
  }
197
- export function __wbg_queueMicrotask_b39ea83c7f01971a(arg0) {
198
- queueMicrotask(getObject(arg0));
199
- }
200
200
  export function __wbg_reasoningbankwasm_new(arg0) {
201
201
  const ret = ReasoningBankWasm.__wrap(arg0);
202
202
  return addHeapObject(ret);
203
203
  }
204
- export function __wbg_resolve_d17db9352f5a220e(arg0) {
204
+ export function __wbg_resolve_9feb5d906ca62419(arg0) {
205
205
  const ret = Promise.resolve(getObject(arg0));
206
206
  return addHeapObject(ret);
207
207
  }
@@ -212,29 +212,29 @@ export function __wbg_stack_3b0d974bbf31e44f(arg0, arg1) {
212
212
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
213
213
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
214
214
  }
215
- export function __wbg_static_accessor_GLOBAL_THIS_02344c9b09eb08a9() {
215
+ export function __wbg_static_accessor_GLOBAL_THIS_1c7f1bd6c6941fdb() {
216
216
  const ret = typeof globalThis === 'undefined' ? null : globalThis;
217
217
  return isLikeNone(ret) ? 0 : addHeapObject(ret);
218
218
  }
219
- export function __wbg_static_accessor_GLOBAL_ac6d4ac874d5cd54() {
219
+ export function __wbg_static_accessor_GLOBAL_e039bc914f83e74e() {
220
220
  const ret = typeof global === 'undefined' ? null : global;
221
221
  return isLikeNone(ret) ? 0 : addHeapObject(ret);
222
222
  }
223
- export function __wbg_static_accessor_SELF_9b2406c23aeb2023() {
223
+ export function __wbg_static_accessor_SELF_8bf8c48c28420ad5() {
224
224
  const ret = typeof self === 'undefined' ? null : self;
225
225
  return isLikeNone(ret) ? 0 : addHeapObject(ret);
226
226
  }
227
- export function __wbg_static_accessor_WINDOW_b34d2126934e16ba() {
227
+ export function __wbg_static_accessor_WINDOW_6aeee9b51652ee0f() {
228
228
  const ret = typeof window === 'undefined' ? null : window;
229
229
  return isLikeNone(ret) ? 0 : addHeapObject(ret);
230
230
  }
231
- export function __wbg_then_837494e384b37459(arg0, arg1) {
231
+ export function __wbg_then_20a157d939b514f5(arg0, arg1) {
232
232
  const ret = getObject(arg0).then(getObject(arg1));
233
233
  return addHeapObject(ret);
234
234
  }
235
235
  export function __wbindgen_cast_0000000000000001(arg0, arg1) {
236
236
  // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 95, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
237
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_348);
237
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_346);
238
238
  return addHeapObject(ret);
239
239
  }
240
240
  export function __wbindgen_cast_0000000000000002(arg0, arg1) {
@@ -249,10 +249,10 @@ export function __wbindgen_object_clone_ref(arg0) {
249
249
  export function __wbindgen_object_drop_ref(arg0) {
250
250
  takeObject(arg0);
251
251
  }
252
- function __wasm_bindgen_func_elem_348(arg0, arg1, arg2) {
252
+ function __wasm_bindgen_func_elem_346(arg0, arg1, arg2) {
253
253
  try {
254
254
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
255
- wasm.__wasm_bindgen_func_elem_348(retptr, arg0, arg1, addHeapObject(arg2));
255
+ wasm.__wasm_bindgen_func_elem_346(retptr, arg0, arg1, addHeapObject(arg2));
256
256
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
257
257
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
258
258
  if (r1) {
@@ -263,8 +263,8 @@ function __wasm_bindgen_func_elem_348(arg0, arg1, arg2) {
263
263
  }
264
264
  }
265
265
 
266
- function __wasm_bindgen_func_elem_357(arg0, arg1, arg2, arg3) {
267
- wasm.__wasm_bindgen_func_elem_357(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
266
+ function __wasm_bindgen_func_elem_352(arg0, arg1, arg2, arg3) {
267
+ wasm.__wasm_bindgen_func_elem_352(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
268
268
  }
269
269
 
270
270
  const ReasoningBankWasmFinalization = (typeof FinalizationRegistry === 'undefined')
@@ -10,8 +10,8 @@ export const reasoningbankwasm_new: (a: number, b: number) => number;
10
10
  export const reasoningbankwasm_searchByCategory: (a: number, b: number, c: number, d: number) => number;
11
11
  export const reasoningbankwasm_storePattern: (a: number, b: number, c: number) => number;
12
12
  export const init: () => void;
13
- export const __wasm_bindgen_func_elem_348: (a: number, b: number, c: number, d: number) => void;
14
- export const __wasm_bindgen_func_elem_357: (a: number, b: number, c: number, d: number) => void;
13
+ export const __wasm_bindgen_func_elem_346: (a: number, b: number, c: number, d: number) => void;
14
+ export const __wasm_bindgen_func_elem_352: (a: number, b: number, c: number, d: number) => void;
15
15
  export const __wbindgen_export: (a: number, b: number) => number;
16
16
  export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
17
17
  export const __wbindgen_export3: (a: number) => void;
@@ -1,217 +0,0 @@
1
- /** TLS configuration for wss:// peers (ADR-107). */
2
- export interface TlsConfig {
3
- /** Path to PEM cert file (server side — bind certs for the listener). */
4
- certPath?: string;
5
- /** Path to PEM key file (server side). */
6
- keyPath?: string;
7
- /**
8
- * Pinned `sha256/<base64>` fingerprints of acceptable peer certs
9
- * (client side — outbound connections).
10
- *
11
- * When set, ONLY these exact certs are accepted. CA validation is
12
- * skipped — the fingerprint IS the trust anchor. Fail-closed: if the
13
- * peer's cert rotates and the fingerprint doesn't match, the
14
- * connection is refused (operator must update config + restart).
15
- *
16
- * This prevents:
17
- * - Compromised public CAs issuing rogue certs for our domain
18
- * - TLS-MITM attacks where the attacker holds a valid cert chain
19
- */
20
- pinnedFingerprints?: string[];
21
- /**
22
- * Optional CA bundle path for non-pinned mode (e.g. private CA).
23
- * Used only when `pinnedFingerprints` is empty/unset.
24
- */
25
- caPath?: string;
26
- }
27
- /** Caller-facing config — minimal common surface across both backends. */
28
- export interface QuicTransportConfig {
29
- serverName?: string;
30
- maxIdleTimeoutMs?: number;
31
- maxConcurrentStreams?: number;
32
- enable0Rtt?: boolean;
33
- /** TLS materials for wss:// listeners + clients (ADR-107). */
34
- tls?: TlsConfig;
35
- }
36
- export interface AgentMessage {
37
- id: string;
38
- type: 'task' | 'result' | 'status' | 'coordination' | 'heartbeat' | string;
39
- payload: unknown;
40
- metadata?: Record<string, unknown>;
41
- /**
42
- * Stream multiplexing identifier. Messages with different streamIds
43
- * to the same peer are independent — receive queues and onMessage
44
- * handlers can scope per-stream, eliminating head-of-line blocking
45
- * for sequential `await` patterns on a single peer connection.
46
- *
47
- * Defaults to `'default'` if omitted (backward compat). Common
48
- * patterns:
49
- * - One stream per logical request type (`'rpc'`, `'event'`,
50
- * `'control'`)
51
- * - One stream per task (`taskId` doubled as streamId)
52
- * - One stream per priority class (`'high'`, `'normal'`, `'low'`)
53
- *
54
- * Maps cleanly to native QUIC streams when AGENTIC_FLOW_QUIC_NATIVE=1
55
- * (each app-layer streamId becomes a QUIC stream id at that point).
56
- */
57
- streamId?: string | number;
58
- }
59
- /** Default streamId when caller omits it. Backward-compat sentinel. */
60
- export declare const DEFAULT_STREAM_ID = "default";
61
- export interface PoolStatistics {
62
- active: number;
63
- idle: number;
64
- created: number;
65
- closed: number;
66
- }
67
- /** Inbound message handler — called for every received message. */
68
- export type InboundMessageHandler = (address: string, message: AgentMessage) => void | Promise<void>;
69
- /**
70
- * Per-stream subscription options. Pass to `onMessage` to scope a
71
- * handler to a specific streamId (only fires for messages with that
72
- * exact streamId). Omit to receive all streams.
73
- */
74
- export interface OnMessageOptions {
75
- readonly streamId?: string | number;
76
- }
77
- /** Common interface both real-QUIC and fallback transports satisfy. */
78
- export interface AgentTransport {
79
- send(address: string, message: AgentMessage): Promise<void>;
80
- /**
81
- * Receive the next message from a peer. Optional `streamId` scopes
82
- * to that stream's queue (independent of other streams to the same
83
- * peer). Omit to use the default stream — backward-compat behavior.
84
- */
85
- receive(address: string, streamId?: string | number): Promise<AgentMessage>;
86
- request(address: string, message: AgentMessage): Promise<AgentMessage>;
87
- sendBatch(address: string, messages: AgentMessage[]): Promise<void>;
88
- getStats(): Promise<PoolStatistics>;
89
- close(): Promise<void>;
90
- /**
91
- * Subscribe to inbound messages. The handler fires for every received
92
- * message that matches `options.streamId` (if provided) or for every
93
- * message regardless of streamId (if options omitted).
94
- *
95
- * Multiple handlers may be registered (per-stream OR all-streams or
96
- * a mix). Errors thrown by a handler are logged but do not stop
97
- * delivery to other handlers.
98
- *
99
- * Optional method — implementations that don't support push-style
100
- * delivery may omit it. Callers should use `transport.onMessage?.(h)`
101
- * to gracefully degrade.
102
- */
103
- onMessage?(handler: InboundMessageHandler, options?: OnMessageOptions): void;
104
- }
105
- /**
106
- * WebSocket fallback transport.
107
- *
108
- * Spec compliance: implements the AgentTransport interface using
109
- * `ws://` (or `wss://` if address starts with `wss://`). Each call to
110
- * `send` lazily opens (or reuses) a connection to `address`. The
111
- * `receive(address)` call drains the next queued message for that
112
- * address; if none is queued it polls every 100ms until one arrives.
113
- *
114
- * Limits vs real QUIC: no 0-RTT resumption, no multiplexed streams
115
- * (one TCP connection per peer), TLS handled by the WS layer (use
116
- * `wss://` for encryption). Performance is "good enough" for federation
117
- * messages at human/agent rates (≤ 100 RPS per peer).
118
- */
119
- declare class WebSocketFallbackTransport implements AgentTransport {
120
- private readonly config;
121
- private connections;
122
- /**
123
- * Per-(address, streamId) message queue. Composite key shape
124
- * `${address}#${streamId}` — see {@link queueKey}. Each stream gets
125
- * its own FIFO so receive(addr, streamA) is independent of
126
- * receive(addr, streamB) — eliminates head-of-line blocking on a
127
- * single peer connection.
128
- */
129
- private messageQueue;
130
- private connectionsCreated;
131
- private connectionsClosed;
132
- private servers;
133
- /**
134
- * Inbound handlers. Each entry is { handler, streamId? }. When
135
- * streamId is undefined the handler receives ALL messages
136
- * regardless of stream; otherwise only messages with the matching
137
- * streamId. Lets callers register both per-stream + catch-all.
138
- */
139
- private inboundHandlers;
140
- /** Compose the per-(address, streamId) queue key. */
141
- private queueKey;
142
- /** Resolve the streamId for a message — defaults to DEFAULT_STREAM_ID. */
143
- private streamOf;
144
- constructor(config: Required<QuicTransportConfig>);
145
- static create(config?: QuicTransportConfig): Promise<WebSocketFallbackTransport>;
146
- /**
147
- * Bind a server-side listener so this transport instance can RECEIVE
148
- * messages from a remote peer (in addition to sending). Federation
149
- * peers run BOTH a listener and a client — calling listen(9100) plus
150
- * send('peer:9100', ...) gives bidirectional connectivity.
151
- *
152
- * Enables `permessage-deflate` compression with thresholds chosen
153
- * for federation envelopes (typically JSON, 100B-10KB):
154
- * - threshold: 256B — don't waste CPU compressing tiny pings
155
- * - level: 3 — balanced compression vs CPU (zlib's BEST_SPEED→6 range)
156
- * - serverNoContextTakeover: true — bound per-conn memory growth
157
- */
158
- listen(port: number, host?: string): Promise<void>;
159
- /**
160
- * Wire the server's `connection` and per-socket `message` handlers.
161
- * Extracted so the wss:// path (where the WebSocketServer is attached
162
- * to a pre-created https.Server) can share the same logic.
163
- */
164
- private attachServerHandlers;
165
- private getOrCreateConnection;
166
- send(address: string, message: AgentMessage): Promise<void>;
167
- /**
168
- * Register an inbound handler. Optional `options.streamId` scopes
169
- * the handler to a specific stream (only fires for messages with
170
- * matching streamId). Omit to subscribe to ALL streams.
171
- *
172
- * Patterns:
173
- * onMessage(h) — receives all
174
- * onMessage(h, { streamId: 'rpc' }) — receives only rpc
175
- * onMessage(h, { streamId: 'event' }) — receives only event
176
- * (both registered) — both fire on
177
- * their respective streams
178
- */
179
- onMessage(handler: InboundMessageHandler, options?: OnMessageOptions): void;
180
- /**
181
- * Fire all matching handlers for a received message. Stream-scoped
182
- * handlers only fire when the message's streamId matches; all-stream
183
- * handlers always fire. Errors thrown sync OR async-rejected by one
184
- * handler don't stop delivery to others.
185
- */
186
- private dispatchInbound;
187
- receive(address: string, streamId?: string | number): Promise<AgentMessage>;
188
- request(address: string, message: AgentMessage): Promise<AgentMessage>;
189
- sendBatch(address: string, messages: AgentMessage[]): Promise<void>;
190
- getStats(): Promise<PoolStatistics>;
191
- close(): Promise<void>;
192
- }
193
- /**
194
- * Public API — load a working transport, preferring real QUIC when
195
- * available, falling back to WebSocket otherwise. The returned object
196
- * satisfies the AgentTransport interface in both cases.
197
- *
198
- * Example:
199
- * const t = await loadQuicTransport({ serverName: 'ruvultra:9100' });
200
- * await t.send('ruvultra:9100', { id: '1', type: 'task', payload: {...} });
201
- *
202
- * Federation v1 ships on the WebSocket fallback (this is the actual
203
- * working transport today). When the native QUIC binding lands, set
204
- * the AGENTIC_FLOW_QUIC_NATIVE=1 environment variable and the same
205
- * code path picks up the upgrade with no API changes.
206
- */
207
- export declare function loadQuicTransport(config?: QuicTransportConfig): Promise<AgentTransport>;
208
- /** Quick capability probe for the doctor / health surface. */
209
- export declare function isQuicAvailable(): Promise<boolean>;
210
- export interface TransportCapabilities {
211
- quicAvailable: boolean;
212
- webSocketFallbackAvailable: true;
213
- selectedBackend: 'quic' | 'websocket';
214
- }
215
- export declare function getTransportCapabilities(): Promise<TransportCapabilities>;
216
- export { WebSocketFallbackTransport };
217
- //# sourceMappingURL=quic-loader.d.ts.map