claude-flow 3.7.0-alpha.47 → 3.7.0-alpha.49
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.49",
|
|
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",
|
|
@@ -1029,5 +1029,162 @@ export const embeddingsTools = [
|
|
|
1029
1029
|
return { success: true, snapshots: registry.list() };
|
|
1030
1030
|
},
|
|
1031
1031
|
},
|
|
1032
|
+
// ============================================================
|
|
1033
|
+
// ADR-121 Phase 8 (CLI) — AnnRouter MCP tools (alpha.48)
|
|
1034
|
+
// ============================================================
|
|
1035
|
+
//
|
|
1036
|
+
// Composition layer: agents declare the workload shape
|
|
1037
|
+
// (corpusSize/persistent/mutable) and the router picks between
|
|
1038
|
+
// HNSW / RaBitQ / DiskANN. The decision is returned to the agent
|
|
1039
|
+
// so they can see what was picked + why (useful for routing
|
|
1040
|
+
// explanations + cost attribution).
|
|
1041
|
+
{
|
|
1042
|
+
name: 'embeddings_ann_router_build',
|
|
1043
|
+
description: "Build an ANN index using AnnRouter — auto-selects between HNSW / RaBitQ / DiskANN based on workload. Use when you have a corpus to index and don't want to choose between the three backings yourself — declare the workload ({corpusSize, persistent, mutable}) and the router picks. Pair with embeddings_ann_router_search to query, embeddings_ann_router_status to see what was picked. For direct DiskANN control (e.g. for known billion-scale persistent indexes), use embeddings_diskann_build instead.",
|
|
1044
|
+
category: 'embeddings',
|
|
1045
|
+
inputSchema: {
|
|
1046
|
+
type: 'object',
|
|
1047
|
+
properties: {
|
|
1048
|
+
name: { type: 'string', description: 'Handle name. Must be unique per process.' },
|
|
1049
|
+
workload: {
|
|
1050
|
+
type: 'object',
|
|
1051
|
+
properties: {
|
|
1052
|
+
corpusSize: { type: 'number', description: 'Approximate corpus size.' },
|
|
1053
|
+
dimension: { type: 'number' },
|
|
1054
|
+
persistent: { type: 'boolean', description: 'Survive process restarts? Forces DiskANN.' },
|
|
1055
|
+
mutable: { type: 'boolean', description: 'Streaming inserts/deletes after build? Prefers HNSW.' },
|
|
1056
|
+
storagePath: { type: 'string', description: 'On-disk path; required when persistent=true.' },
|
|
1057
|
+
},
|
|
1058
|
+
required: ['corpusSize', 'dimension'],
|
|
1059
|
+
},
|
|
1060
|
+
entries: {
|
|
1061
|
+
type: 'array',
|
|
1062
|
+
items: {
|
|
1063
|
+
type: 'object',
|
|
1064
|
+
properties: { id: { type: 'string' }, vector: { type: 'array', items: { type: 'number' } } },
|
|
1065
|
+
required: ['id', 'vector'],
|
|
1066
|
+
},
|
|
1067
|
+
},
|
|
1068
|
+
},
|
|
1069
|
+
required: ['name', 'workload', 'entries'],
|
|
1070
|
+
},
|
|
1071
|
+
handler: async (input) => {
|
|
1072
|
+
const { getAnnRouterRegistry } = await import('../memory/ann-router-registry.js');
|
|
1073
|
+
const registry = getAnnRouterRegistry();
|
|
1074
|
+
try {
|
|
1075
|
+
const result = await registry.build({
|
|
1076
|
+
name: input.name,
|
|
1077
|
+
workload: input.workload,
|
|
1078
|
+
entries: input.entries,
|
|
1079
|
+
});
|
|
1080
|
+
return { success: true, name: input.name, ...result };
|
|
1081
|
+
}
|
|
1082
|
+
catch (err) {
|
|
1083
|
+
return { success: false, name: input.name, error: err instanceof Error ? err.message : String(err) };
|
|
1084
|
+
}
|
|
1085
|
+
},
|
|
1086
|
+
},
|
|
1087
|
+
{
|
|
1088
|
+
name: 'embeddings_ann_router_search',
|
|
1089
|
+
description: 'Search a named AnnRouter handle for the k nearest neighbors. Returns hits with the routing-decision-aware score (cosine sim for HNSW; L2 distance for RaBitQ/DiskANN — interpret relative to embeddings_ann_router_status). For raw DiskANN search use embeddings_diskann_search; for raw HNSW use SearchableEmbeddingCache.search directly.',
|
|
1090
|
+
category: 'embeddings',
|
|
1091
|
+
inputSchema: {
|
|
1092
|
+
type: 'object',
|
|
1093
|
+
properties: {
|
|
1094
|
+
name: { type: 'string' },
|
|
1095
|
+
vector: { type: 'array', items: { type: 'number' } },
|
|
1096
|
+
k: { type: 'number' },
|
|
1097
|
+
},
|
|
1098
|
+
required: ['name', 'vector', 'k'],
|
|
1099
|
+
},
|
|
1100
|
+
handler: async (input) => {
|
|
1101
|
+
const { getAnnRouterRegistry } = await import('../memory/ann-router-registry.js');
|
|
1102
|
+
const registry = getAnnRouterRegistry();
|
|
1103
|
+
try {
|
|
1104
|
+
const hits = await registry.search(input.name, new Float32Array(input.vector), input.k);
|
|
1105
|
+
return { success: true, name: input.name, k: input.k, hits };
|
|
1106
|
+
}
|
|
1107
|
+
catch (err) {
|
|
1108
|
+
return { success: false, name: input.name, error: err instanceof Error ? err.message : String(err) };
|
|
1109
|
+
}
|
|
1110
|
+
},
|
|
1111
|
+
},
|
|
1112
|
+
{
|
|
1113
|
+
name: 'embeddings_ann_router_status',
|
|
1114
|
+
description: 'List all AnnRouter handles, each with its decided backing, routing reason, and current count. Use to inventory routed indexes + confirm the router picked what you expected. For peer-dep family availability use embeddings_check_ruvector_sidecar.',
|
|
1115
|
+
category: 'embeddings',
|
|
1116
|
+
inputSchema: { type: 'object', properties: {} },
|
|
1117
|
+
handler: async () => {
|
|
1118
|
+
const { getAnnRouterRegistry } = await import('../memory/ann-router-registry.js');
|
|
1119
|
+
const registry = getAnnRouterRegistry();
|
|
1120
|
+
return { success: true, handles: registry.list() };
|
|
1121
|
+
},
|
|
1122
|
+
},
|
|
1123
|
+
// ============================================================
|
|
1124
|
+
// ADR-121 Phase 9 — one-call RAG retrieval (alpha.49 CLI)
|
|
1125
|
+
// ============================================================
|
|
1126
|
+
{
|
|
1127
|
+
name: 'embeddings_search_text',
|
|
1128
|
+
description: "Embed a text query and search a named AnnRouter handle in a single call — the standard RAG retrieval shape. Eliminates the two-call dance of `embeddings_generate` then `embeddings_ann_router_search`. Returns hits plus per-stage latency (embeddingMs + searchMs) so callers can attribute cost. Pair with embeddings_ann_router_build to build the index first. For raw vector input (no embedding step) use embeddings_ann_router_search.",
|
|
1129
|
+
category: 'embeddings',
|
|
1130
|
+
inputSchema: {
|
|
1131
|
+
type: 'object',
|
|
1132
|
+
properties: {
|
|
1133
|
+
text: { type: 'string', description: 'Query text. Will be embedded inline.' },
|
|
1134
|
+
name: { type: 'string', description: 'AnnRouter handle name (set by embeddings_ann_router_build).' },
|
|
1135
|
+
k: { type: 'number', description: 'Number of nearest neighbors.' },
|
|
1136
|
+
},
|
|
1137
|
+
required: ['text', 'name', 'k'],
|
|
1138
|
+
},
|
|
1139
|
+
handler: async (input) => {
|
|
1140
|
+
const config = loadConfig();
|
|
1141
|
+
if (!config) {
|
|
1142
|
+
return {
|
|
1143
|
+
success: false,
|
|
1144
|
+
error: 'Embeddings not initialized. Run embeddings_init first.',
|
|
1145
|
+
};
|
|
1146
|
+
}
|
|
1147
|
+
const text = input.text;
|
|
1148
|
+
const name = input.name;
|
|
1149
|
+
const k = input.k;
|
|
1150
|
+
const tv = validateText(text, 'text');
|
|
1151
|
+
if (!tv.valid)
|
|
1152
|
+
return { success: false, error: tv.error };
|
|
1153
|
+
// Stage 1 — embed the query.
|
|
1154
|
+
const embedT0 = Date.now();
|
|
1155
|
+
let embedding;
|
|
1156
|
+
try {
|
|
1157
|
+
embedding = await generateRealEmbedding(text, config.dimension);
|
|
1158
|
+
}
|
|
1159
|
+
catch (err) {
|
|
1160
|
+
return { success: false, error: `embed failed: ${err instanceof Error ? err.message : String(err)}` };
|
|
1161
|
+
}
|
|
1162
|
+
const embeddingMs = Date.now() - embedT0;
|
|
1163
|
+
// Stage 2 — search the named router handle.
|
|
1164
|
+
const { getAnnRouterRegistry } = await import('../memory/ann-router-registry.js');
|
|
1165
|
+
const registry = getAnnRouterRegistry();
|
|
1166
|
+
const searchT0 = Date.now();
|
|
1167
|
+
try {
|
|
1168
|
+
const hits = await registry.search(name, new Float32Array(embedding), k);
|
|
1169
|
+
const searchMs = Date.now() - searchT0;
|
|
1170
|
+
return {
|
|
1171
|
+
success: true,
|
|
1172
|
+
name,
|
|
1173
|
+
k,
|
|
1174
|
+
hits,
|
|
1175
|
+
latency: { embeddingMs, searchMs, totalMs: embeddingMs + searchMs },
|
|
1176
|
+
embeddingDimension: embedding.length,
|
|
1177
|
+
};
|
|
1178
|
+
}
|
|
1179
|
+
catch (err) {
|
|
1180
|
+
return {
|
|
1181
|
+
success: false,
|
|
1182
|
+
name,
|
|
1183
|
+
error: err instanceof Error ? err.message : String(err),
|
|
1184
|
+
latency: { embeddingMs, searchMs: 0 },
|
|
1185
|
+
};
|
|
1186
|
+
}
|
|
1187
|
+
},
|
|
1188
|
+
},
|
|
1032
1189
|
];
|
|
1033
1190
|
//# sourceMappingURL=embeddings-tools.js.map
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process-level registry of named AnnRouter handles backing the
|
|
3
|
+
* `embeddings_ann_router_*` MCP tools.
|
|
4
|
+
*
|
|
5
|
+
* Mirrors the shape of `diskann-registry.ts` but for the unified
|
|
6
|
+
* routing layer. Lifecycle:
|
|
7
|
+
* - `build({ name, workload, entries })` creates an AnnRouter with
|
|
8
|
+
* the given workload, adds the entries, calls build, stashes the
|
|
9
|
+
* handle under `name`. Returns the routing decision so agents
|
|
10
|
+
* can see which backing was picked + why.
|
|
11
|
+
* - `search(name, vector, k)` runs top-k against the named handle.
|
|
12
|
+
* - `list()` returns all handles with their decision + count.
|
|
13
|
+
*
|
|
14
|
+
* ADR-121 Phase 8 (CLI) — cli alpha.48.
|
|
15
|
+
*/
|
|
16
|
+
export interface AnnRouterBuildInput {
|
|
17
|
+
readonly name: string;
|
|
18
|
+
readonly workload: {
|
|
19
|
+
readonly corpusSize: number;
|
|
20
|
+
readonly dimension: number;
|
|
21
|
+
readonly persistent?: boolean;
|
|
22
|
+
readonly mutable?: boolean;
|
|
23
|
+
readonly storagePath?: string;
|
|
24
|
+
};
|
|
25
|
+
readonly entries: ReadonlyArray<{
|
|
26
|
+
id: string;
|
|
27
|
+
vector: number[];
|
|
28
|
+
}>;
|
|
29
|
+
}
|
|
30
|
+
export interface AnnRouterDecisionView {
|
|
31
|
+
readonly backing: string;
|
|
32
|
+
readonly reason: string;
|
|
33
|
+
readonly degraded: boolean;
|
|
34
|
+
readonly degradationReason?: string;
|
|
35
|
+
}
|
|
36
|
+
export interface AnnRouterBuildResult {
|
|
37
|
+
readonly decision: AnnRouterDecisionView;
|
|
38
|
+
readonly count: number;
|
|
39
|
+
readonly buildMs: number;
|
|
40
|
+
}
|
|
41
|
+
export interface AnnRouterSearchHit {
|
|
42
|
+
readonly id: string;
|
|
43
|
+
readonly score: number;
|
|
44
|
+
}
|
|
45
|
+
export interface AnnRouterHandleInfo {
|
|
46
|
+
readonly name: string;
|
|
47
|
+
readonly decision: AnnRouterDecisionView;
|
|
48
|
+
readonly count: number;
|
|
49
|
+
}
|
|
50
|
+
declare class AnnRouterRegistry {
|
|
51
|
+
private readonly entries;
|
|
52
|
+
private ctor;
|
|
53
|
+
private loadCtor;
|
|
54
|
+
build(input: AnnRouterBuildInput): Promise<AnnRouterBuildResult>;
|
|
55
|
+
search(name: string, vector: Float32Array, k: number): Promise<AnnRouterSearchHit[]>;
|
|
56
|
+
list(): AnnRouterHandleInfo[];
|
|
57
|
+
clear(): void;
|
|
58
|
+
}
|
|
59
|
+
export declare function getAnnRouterRegistry(): AnnRouterRegistry;
|
|
60
|
+
export {};
|
|
61
|
+
//# sourceMappingURL=ann-router-registry.d.ts.map
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process-level registry of named AnnRouter handles backing the
|
|
3
|
+
* `embeddings_ann_router_*` MCP tools.
|
|
4
|
+
*
|
|
5
|
+
* Mirrors the shape of `diskann-registry.ts` but for the unified
|
|
6
|
+
* routing layer. Lifecycle:
|
|
7
|
+
* - `build({ name, workload, entries })` creates an AnnRouter with
|
|
8
|
+
* the given workload, adds the entries, calls build, stashes the
|
|
9
|
+
* handle under `name`. Returns the routing decision so agents
|
|
10
|
+
* can see which backing was picked + why.
|
|
11
|
+
* - `search(name, vector, k)` runs top-k against the named handle.
|
|
12
|
+
* - `list()` returns all handles with their decision + count.
|
|
13
|
+
*
|
|
14
|
+
* ADR-121 Phase 8 (CLI) — cli alpha.48.
|
|
15
|
+
*/
|
|
16
|
+
class AnnRouterRegistry {
|
|
17
|
+
entries = new Map();
|
|
18
|
+
ctor = null;
|
|
19
|
+
async loadCtor() {
|
|
20
|
+
if (this.ctor)
|
|
21
|
+
return this.ctor;
|
|
22
|
+
const mod = await import('@claude-flow/embeddings/ann-router');
|
|
23
|
+
this.ctor = mod.AnnRouter;
|
|
24
|
+
return this.ctor;
|
|
25
|
+
}
|
|
26
|
+
async build(input) {
|
|
27
|
+
const Ctor = await this.loadCtor();
|
|
28
|
+
const t0 = Date.now();
|
|
29
|
+
const router = await Ctor.create(input.workload);
|
|
30
|
+
const float32 = input.entries.map(e => ({
|
|
31
|
+
id: e.id,
|
|
32
|
+
vector: new Float32Array(e.vector),
|
|
33
|
+
}));
|
|
34
|
+
await router.add(float32);
|
|
35
|
+
await router.build();
|
|
36
|
+
const buildMs = Date.now() - t0;
|
|
37
|
+
this.entries.set(input.name, { router, decision: router.decision });
|
|
38
|
+
return {
|
|
39
|
+
decision: router.decision,
|
|
40
|
+
count: router.count(),
|
|
41
|
+
buildMs,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
async search(name, vector, k) {
|
|
45
|
+
const entry = this.entries.get(name);
|
|
46
|
+
if (!entry) {
|
|
47
|
+
throw new Error(`embeddings_ann_router_search: no router named "${name}" — call embeddings_ann_router_build first`);
|
|
48
|
+
}
|
|
49
|
+
return entry.router.search(vector, k);
|
|
50
|
+
}
|
|
51
|
+
list() {
|
|
52
|
+
const out = [];
|
|
53
|
+
for (const [name, entry] of this.entries) {
|
|
54
|
+
out.push({
|
|
55
|
+
name,
|
|
56
|
+
decision: entry.decision,
|
|
57
|
+
count: entry.router.count(),
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return out;
|
|
61
|
+
}
|
|
62
|
+
clear() {
|
|
63
|
+
this.entries.clear();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
let singleton = null;
|
|
67
|
+
export function getAnnRouterRegistry() {
|
|
68
|
+
if (!singleton)
|
|
69
|
+
singleton = new AnnRouterRegistry();
|
|
70
|
+
return singleton;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=ann-router-registry.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@claude-flow/cli",
|
|
3
|
-
"version": "3.7.0-alpha.
|
|
3
|
+
"version": "3.7.0-alpha.49",
|
|
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",
|