claude-flow 3.7.0-alpha.52 → 3.7.0-alpha.54
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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-flow",
|
|
3
|
-
"version": "3.7.0-alpha.
|
|
3
|
+
"version": "3.7.0-alpha.54",
|
|
4
4
|
"description": "Ruflo - Enterprise AI agent orchestration for Claude Code. Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -1280,6 +1280,139 @@ export const embeddingsTools = [
|
|
|
1280
1280
|
},
|
|
1281
1281
|
},
|
|
1282
1282
|
// ============================================================
|
|
1283
|
+
// ADR-121 Phase 12 — HyDE embedding-level fusion (alpha.53 CLI)
|
|
1284
|
+
// ============================================================
|
|
1285
|
+
//
|
|
1286
|
+
// HyDE (Gao, Ma, Lin, Callan 2022 — "Precise Zero-Shot Dense
|
|
1287
|
+
// Retrieval without Relevance Labels"): question embeddings live in
|
|
1288
|
+
// "question space" while documents embed into "answer space", so
|
|
1289
|
+
// cosine search systematically underweights relevant docs. The
|
|
1290
|
+
// standard fix: have an LLM generate N hypothetical answers, embed
|
|
1291
|
+
// each, AVERAGE the embeddings into a single query vector, search
|
|
1292
|
+
// once with that.
|
|
1293
|
+
//
|
|
1294
|
+
// Distinct from `embeddings_search_text_ensemble` (Phase 11):
|
|
1295
|
+
// - HyDE fuses at the EMBEDDING level (1 search after average).
|
|
1296
|
+
// Cheaper, finds the centroid hit, interpolates between
|
|
1297
|
+
// hypothetical answers.
|
|
1298
|
+
// - RRF fuses at the RANK level (N searches then merge ranks).
|
|
1299
|
+
// More expensive, preserves intent boundaries between variants.
|
|
1300
|
+
//
|
|
1301
|
+
// Both are useful. Production systems often combine them — HyDE
|
|
1302
|
+
// inside one ranked list, RRF across multiple lists.
|
|
1303
|
+
{
|
|
1304
|
+
name: 'embeddings_search_text_hyde',
|
|
1305
|
+
description: "Embed N hypothetical-answer texts, AVERAGE their embeddings into a single query vector, and search a named AnnRouter handle once. Implements the HyDE recipe (Gao et al. 2022) for zero-shot dense retrieval — the LLM-generated hypothetical answers live in the same answer-space as the corpus, so the averaged vector lands near the true relevant docs. Distinct from embeddings_search_text_ensemble (which fuses at the rank level via RRF — more expensive, preserves intent boundaries); HyDE fuses at the embedding level (cheaper, one search, finds the centroid hit). Optional `weights` per text (e.g. weight the user's original question 0.5× and LLM answers 1.0× each — the paper's recommended recipe). Returns hits + averaged-vector metadata (unitNorm assertion + contributing-text count) for transparency.",
|
|
1306
|
+
category: 'embeddings',
|
|
1307
|
+
inputSchema: {
|
|
1308
|
+
type: 'object',
|
|
1309
|
+
properties: {
|
|
1310
|
+
texts: {
|
|
1311
|
+
type: 'array',
|
|
1312
|
+
items: { type: 'string' },
|
|
1313
|
+
description: 'Array of hypothetical-answer texts (LLM-generated) to fuse. The caller is responsible for generating these — typically via a few-shot prompt to an LLM asking it to answer the user question.',
|
|
1314
|
+
},
|
|
1315
|
+
name: { type: 'string', description: 'AnnRouter handle name (set by embeddings_ann_router_build).' },
|
|
1316
|
+
k: { type: 'number', description: 'Number of nearest neighbors to return.' },
|
|
1317
|
+
weights: {
|
|
1318
|
+
type: 'array',
|
|
1319
|
+
items: { type: 'number' },
|
|
1320
|
+
description: 'Per-text weights for the embedding average. Length must equal texts.length. Default uniform.',
|
|
1321
|
+
},
|
|
1322
|
+
},
|
|
1323
|
+
required: ['texts', 'name', 'k'],
|
|
1324
|
+
},
|
|
1325
|
+
handler: async (input) => {
|
|
1326
|
+
const config = loadConfig();
|
|
1327
|
+
if (!config) {
|
|
1328
|
+
return { success: false, error: 'Embeddings not initialized. Run embeddings_init first.' };
|
|
1329
|
+
}
|
|
1330
|
+
const texts = input.texts;
|
|
1331
|
+
const name = input.name;
|
|
1332
|
+
const k = input.k;
|
|
1333
|
+
const weights = Array.isArray(input.weights) ? input.weights : undefined;
|
|
1334
|
+
if (!Array.isArray(texts) || texts.length === 0) {
|
|
1335
|
+
return { success: false, error: 'texts must be a non-empty array' };
|
|
1336
|
+
}
|
|
1337
|
+
if (!Number.isInteger(k) || k < 1) {
|
|
1338
|
+
return { success: false, error: 'k must be a positive integer' };
|
|
1339
|
+
}
|
|
1340
|
+
for (let i = 0; i < texts.length; i++) {
|
|
1341
|
+
if (typeof texts[i] !== 'string') {
|
|
1342
|
+
return { success: false, error: `texts[${i}] is not a string` };
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
if (weights && weights.length !== texts.length) {
|
|
1346
|
+
return {
|
|
1347
|
+
success: false,
|
|
1348
|
+
error: `weights.length (${weights.length}) must match texts.length (${texts.length})`,
|
|
1349
|
+
};
|
|
1350
|
+
}
|
|
1351
|
+
if (weights) {
|
|
1352
|
+
for (let i = 0; i < weights.length; i++) {
|
|
1353
|
+
if (weights[i] < 0) {
|
|
1354
|
+
return { success: false, error: `weights[${i}] is negative` };
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1358
|
+
const { getAnnRouterRegistry } = await import('../memory/ann-router-registry.js');
|
|
1359
|
+
const registry = getAnnRouterRegistry();
|
|
1360
|
+
// Stage 1 — embed each hypothetical text in parallel.
|
|
1361
|
+
const embedT0 = Date.now();
|
|
1362
|
+
let embeddings;
|
|
1363
|
+
try {
|
|
1364
|
+
embeddings = await Promise.all(texts.map(t => generateRealEmbedding(t, config.dimension)));
|
|
1365
|
+
}
|
|
1366
|
+
catch (err) {
|
|
1367
|
+
return { success: false, name, error: `batch embed failed: ${err instanceof Error ? err.message : String(err)}` };
|
|
1368
|
+
}
|
|
1369
|
+
const embeddingMs = Date.now() - embedT0;
|
|
1370
|
+
// Stage 2 — average the embeddings (HyDE fusion).
|
|
1371
|
+
const { averageEmbeddings, isUnitNorm } = await import('@claude-flow/embeddings/embedding-fusion');
|
|
1372
|
+
const fuseT0 = Date.now();
|
|
1373
|
+
const avgVec = averageEmbeddings(embeddings, {
|
|
1374
|
+
weights,
|
|
1375
|
+
normalizeInputs: true,
|
|
1376
|
+
normalizeOutput: true,
|
|
1377
|
+
});
|
|
1378
|
+
const fuseMs = Date.now() - fuseT0;
|
|
1379
|
+
const fusedUnit = isUnitNorm(avgVec);
|
|
1380
|
+
// Stage 3 — single search with the averaged vector.
|
|
1381
|
+
const searchT0 = Date.now();
|
|
1382
|
+
let hits;
|
|
1383
|
+
try {
|
|
1384
|
+
hits = await registry.search(name, avgVec, k);
|
|
1385
|
+
}
|
|
1386
|
+
catch (err) {
|
|
1387
|
+
return {
|
|
1388
|
+
success: false,
|
|
1389
|
+
name,
|
|
1390
|
+
error: err instanceof Error ? err.message : String(err),
|
|
1391
|
+
latency: { embeddingMs, fuseMs, searchMs: 0 },
|
|
1392
|
+
};
|
|
1393
|
+
}
|
|
1394
|
+
const searchMs = Date.now() - searchT0;
|
|
1395
|
+
return {
|
|
1396
|
+
success: true,
|
|
1397
|
+
name,
|
|
1398
|
+
k,
|
|
1399
|
+
hits,
|
|
1400
|
+
hyde: {
|
|
1401
|
+
textsFused: texts.length,
|
|
1402
|
+
weights: weights ?? null,
|
|
1403
|
+
averagedVectorUnitNorm: fusedUnit,
|
|
1404
|
+
dimension: avgVec.length,
|
|
1405
|
+
},
|
|
1406
|
+
latency: {
|
|
1407
|
+
embeddingMs,
|
|
1408
|
+
fuseMs,
|
|
1409
|
+
searchMs,
|
|
1410
|
+
totalMs: embeddingMs + fuseMs + searchMs,
|
|
1411
|
+
},
|
|
1412
|
+
};
|
|
1413
|
+
},
|
|
1414
|
+
},
|
|
1415
|
+
// ============================================================
|
|
1283
1416
|
// ADR-121 Phase 11 — RRF ensemble retrieval (alpha.52 CLI)
|
|
1284
1417
|
// ============================================================
|
|
1285
1418
|
//
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@claude-flow/cli",
|
|
3
|
-
"version": "3.7.0-alpha.
|
|
3
|
+
"version": "3.7.0-alpha.54",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Ruflo CLI - Enterprise AI agent orchestration with 60+ specialized agents, swarm coordination, MCP server, self-learning hooks, and vector memory for Claude Code",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -104,14 +104,14 @@
|
|
|
104
104
|
"semver": "^7.6.0",
|
|
105
105
|
"yaml": "^2.8.0",
|
|
106
106
|
"@claude-flow/memory": "^3.0.0-alpha.17",
|
|
107
|
-
"@claude-flow/embeddings": "^3.0.0-alpha.
|
|
107
|
+
"@claude-flow/embeddings": "^3.0.0-alpha.34",
|
|
108
108
|
"@claude-flow/security": "^3.0.0-alpha.8",
|
|
109
109
|
"@claude-flow/swarm": "^3.0.0-alpha.8"
|
|
110
110
|
},
|
|
111
111
|
"optionalDependencies": {
|
|
112
112
|
"@claude-flow/aidefence": "^3.0.2",
|
|
113
113
|
"@claude-flow/codex": "^3.0.0-alpha.8",
|
|
114
|
-
"@claude-flow/embeddings": "^3.0.0-alpha.
|
|
114
|
+
"@claude-flow/embeddings": "^3.0.0-alpha.34",
|
|
115
115
|
"@claude-flow/guidance": "^3.0.0-alpha.1",
|
|
116
116
|
"@claude-flow/memory": "^3.0.0-alpha.17",
|
|
117
117
|
"@claude-flow/plugin-gastown-bridge": "^0.1.3",
|