claude-flow 3.7.0-alpha.49 → 3.7.0-alpha.50

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.49",
3
+ "version": "3.7.0-alpha.50",
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",
@@ -1186,5 +1186,98 @@ export const embeddingsTools = [
1186
1186
  }
1187
1187
  },
1188
1188
  },
1189
+ // ============================================================
1190
+ // ADR-121 Phase 9b — batch one-call RAG (alpha.50 CLI)
1191
+ // ============================================================
1192
+ {
1193
+ name: 'embeddings_search_text_batch',
1194
+ description: "Embed N text queries and search a named AnnRouter handle for each, in a single MCP call. Standard shape for question-reformulation RAG (expand one user question into N variants, retrieve top-k for each, merge). Embeddings + searches run in parallel where the backing supports it. Returns one results entry per query in input order, plus aggregate latency. For single-query use embeddings_search_text; for raw vector input use embeddings_ann_router_search.",
1195
+ category: 'embeddings',
1196
+ inputSchema: {
1197
+ type: 'object',
1198
+ properties: {
1199
+ texts: {
1200
+ type: 'array',
1201
+ items: { type: 'string' },
1202
+ description: 'Array of query texts. Order preserved in results.',
1203
+ },
1204
+ name: { type: 'string', description: 'AnnRouter handle name.' },
1205
+ k: { type: 'number', description: 'Nearest neighbors per query.' },
1206
+ },
1207
+ required: ['texts', 'name', 'k'],
1208
+ },
1209
+ handler: async (input) => {
1210
+ const config = loadConfig();
1211
+ if (!config) {
1212
+ return { success: false, error: 'Embeddings not initialized. Run embeddings_init first.' };
1213
+ }
1214
+ const texts = input.texts;
1215
+ const name = input.name;
1216
+ const k = input.k;
1217
+ if (!Array.isArray(texts) || texts.length === 0) {
1218
+ return { success: false, error: 'texts must be a non-empty array' };
1219
+ }
1220
+ // Validate every text upfront so we don't half-embed before failing.
1221
+ for (let i = 0; i < texts.length; i++) {
1222
+ const t = texts[i];
1223
+ if (typeof t !== 'string') {
1224
+ return { success: false, error: `texts[${i}] is not a string` };
1225
+ }
1226
+ }
1227
+ const { getAnnRouterRegistry } = await import('../memory/ann-router-registry.js');
1228
+ const registry = getAnnRouterRegistry();
1229
+ // Stage 1 — embed all queries in parallel.
1230
+ const embedT0 = Date.now();
1231
+ let embeddings;
1232
+ try {
1233
+ embeddings = await Promise.all(texts.map(t => generateRealEmbedding(t, config.dimension)));
1234
+ }
1235
+ catch (err) {
1236
+ return {
1237
+ success: false,
1238
+ name,
1239
+ error: `batch embed failed: ${err instanceof Error ? err.message : String(err)}`,
1240
+ };
1241
+ }
1242
+ const embeddingMs = Date.now() - embedT0;
1243
+ // Stage 2 — search each in parallel against the named handle.
1244
+ // Per-query errors are captured into the results entry rather
1245
+ // than aborting the whole batch — callers see which queries
1246
+ // succeeded and which didn't.
1247
+ const searchT0 = Date.now();
1248
+ const results = await Promise.all(embeddings.map(async (emb, i) => {
1249
+ try {
1250
+ const hits = await registry.search(name, new Float32Array(emb), k);
1251
+ return { index: i, text: texts[i], success: true, hits };
1252
+ }
1253
+ catch (err) {
1254
+ return {
1255
+ index: i,
1256
+ text: texts[i],
1257
+ success: false,
1258
+ error: err instanceof Error ? err.message : String(err),
1259
+ };
1260
+ }
1261
+ }));
1262
+ const searchMs = Date.now() - searchT0;
1263
+ const successCount = results.filter(r => r.success).length;
1264
+ return {
1265
+ success: successCount === results.length,
1266
+ name,
1267
+ k,
1268
+ queryCount: texts.length,
1269
+ successCount,
1270
+ failureCount: results.length - successCount,
1271
+ results,
1272
+ latency: {
1273
+ embeddingMs,
1274
+ searchMs,
1275
+ totalMs: embeddingMs + searchMs,
1276
+ avgPerQueryMs: Math.round(((embeddingMs + searchMs) / texts.length) * 100) / 100,
1277
+ },
1278
+ embeddingDimension: embeddings[0]?.length,
1279
+ };
1280
+ },
1281
+ },
1189
1282
  ];
1190
1283
  //# sourceMappingURL=embeddings-tools.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claude-flow/cli",
3
- "version": "3.7.0-alpha.49",
3
+ "version": "3.7.0-alpha.50",
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",