claude-flow 3.7.0-alpha.46 → 3.7.0-alpha.47

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.46",
3
+ "version": "3.7.0-alpha.47",
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",
@@ -940,5 +940,94 @@ export const embeddingsTools = [
940
940
  };
941
941
  },
942
942
  },
943
+ // ============================================================
944
+ // ADR-121 Phase 5b — DiskannSnapshot MCP tools (alpha.47 CLI)
945
+ // ============================================================
946
+ //
947
+ // Process-level registry of named DiskannSnapshot handles. Build
948
+ // an index once, search it many times. Persistence to disk via
949
+ // the snapshot's storagePath; the handle is keyed by `name`.
950
+ // For in-memory snapshots, set persist: false and the index is
951
+ // re-built only while this process lives.
952
+ {
953
+ name: 'embeddings_diskann_build',
954
+ description: 'Build a DiskANN/Vamana ANN index from a batch of (id, vector) pairs. Use when you have a fixed corpus (≥10k vectors typical) that needs sub-millisecond ANN search and you want persistence across process restarts — for streaming inserts at smaller scale use SearchableEmbeddingCache instead, for batch in-memory 32×-compressed use RabitqSnapshot. Pair with embeddings_diskann_search to query, embeddings_diskann_status to inspect. Requires @ruvector/diskann (optional peer dep — throws a clear named error if missing).',
955
+ category: 'embeddings',
956
+ inputSchema: {
957
+ type: 'object',
958
+ properties: {
959
+ name: { type: 'string', description: 'Snapshot handle name (used by search + status). Must be unique per process.' },
960
+ dimension: { type: 'number', description: 'Embedding dimension.' },
961
+ entries: {
962
+ type: 'array',
963
+ description: 'Vectors to index. Each entry: { id: string, vector: number[] }.',
964
+ items: {
965
+ type: 'object',
966
+ properties: {
967
+ id: { type: 'string' },
968
+ vector: { type: 'array', items: { type: 'number' } },
969
+ },
970
+ required: ['id', 'vector'],
971
+ },
972
+ },
973
+ storagePath: { type: 'string', description: 'Optional directory for on-disk persistence (snapshot survives restarts via embeddings_diskann_load).' },
974
+ },
975
+ required: ['name', 'dimension', 'entries'],
976
+ },
977
+ handler: async (input) => {
978
+ const { getDiskannRegistry } = await import('../memory/diskann-registry.js');
979
+ const registry = getDiskannRegistry();
980
+ const name = input.name;
981
+ const dimension = input.dimension;
982
+ const entries = input.entries;
983
+ const storagePath = input.storagePath;
984
+ try {
985
+ const stats = await registry.build({ name, dimension, entries, storagePath });
986
+ return { success: true, name, ...stats };
987
+ }
988
+ catch (err) {
989
+ return { success: false, name, error: err instanceof Error ? err.message : String(err) };
990
+ }
991
+ },
992
+ },
993
+ {
994
+ name: 'embeddings_diskann_search',
995
+ description: 'Search a previously-built DiskANN index for the k nearest neighbors of a query vector. Use when you built an index via embeddings_diskann_build and now need ANN retrieval — returns ids + L2² distances sorted ascending. For text→vector→search in one call, pair with embeddings_generate first. For exact-match key lookup over a streaming cache, use SearchableEmbeddingCache.get instead.',
996
+ category: 'embeddings',
997
+ inputSchema: {
998
+ type: 'object',
999
+ properties: {
1000
+ name: { type: 'string', description: 'Snapshot handle name (set by embeddings_diskann_build).' },
1001
+ vector: { type: 'array', items: { type: 'number' }, description: 'Query vector. Must match the index dimension.' },
1002
+ k: { type: 'number', description: 'Number of nearest neighbors to return.' },
1003
+ },
1004
+ required: ['name', 'vector', 'k'],
1005
+ },
1006
+ handler: async (input) => {
1007
+ const { getDiskannRegistry } = await import('../memory/diskann-registry.js');
1008
+ const registry = getDiskannRegistry();
1009
+ const name = input.name;
1010
+ const vector = new Float32Array(input.vector);
1011
+ const k = input.k;
1012
+ try {
1013
+ const hits = await registry.search(name, vector, k);
1014
+ return { success: true, name, k, hits };
1015
+ }
1016
+ catch (err) {
1017
+ return { success: false, name, error: err instanceof Error ? err.message : String(err) };
1018
+ }
1019
+ },
1020
+ },
1021
+ {
1022
+ name: 'embeddings_diskann_status',
1023
+ description: 'List all DiskANN snapshots currently held by this MCP server, with their dimension, vector count, and storage path. Use when you want to inventory in-process indexes before opening a new one, or when debugging "which snapshot did I build?". For checking whether the @ruvector/diskann peer dep itself is installed, use embeddings_check_ruvector_sidecar (the family probe) instead.',
1024
+ category: 'embeddings',
1025
+ inputSchema: { type: 'object', properties: {} },
1026
+ handler: async () => {
1027
+ const { getDiskannRegistry } = await import('../memory/diskann-registry.js');
1028
+ const registry = getDiskannRegistry();
1029
+ return { success: true, snapshots: registry.list() };
1030
+ },
1031
+ },
943
1032
  ];
944
1033
  //# sourceMappingURL=embeddings-tools.js.map
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Process-level registry of named `DiskannSnapshot` handles backing
3
+ * the `embeddings_diskann_*` MCP tools.
4
+ *
5
+ * Lifecycle:
6
+ * - `build({ name, dimension, entries, storagePath? })` →
7
+ * creates a snapshot, adds the entries, builds the Vamana graph,
8
+ * persists if storagePath is set, stashes the handle under `name`.
9
+ * - `search(name, vector, k)` → top-k against the named snapshot.
10
+ * - `list()` → inventory of all current snapshots (name, dimension,
11
+ * count, storagePath?).
12
+ *
13
+ * The registry is process-level; agents that want cross-restart
14
+ * persistence should pass `storagePath` on build and reload from
15
+ * disk via a separate `embeddings_diskann_load` follow-up tool.
16
+ *
17
+ * ADR-121 Phase 5b — cli alpha.47.
18
+ */
19
+ export interface DiskannBuildInput {
20
+ readonly name: string;
21
+ readonly dimension: number;
22
+ readonly entries: ReadonlyArray<{
23
+ id: string;
24
+ vector: number[];
25
+ }>;
26
+ readonly storagePath?: string;
27
+ }
28
+ export interface DiskannBuildResult {
29
+ readonly dimension: number;
30
+ readonly count: number;
31
+ readonly buildMs: number;
32
+ readonly storagePath?: string;
33
+ }
34
+ export interface DiskannSearchHit {
35
+ readonly id: string;
36
+ readonly distance: number;
37
+ }
38
+ export interface DiskannSnapshotInfo {
39
+ readonly name: string;
40
+ readonly dimension: number;
41
+ readonly count: number;
42
+ readonly storagePath?: string;
43
+ }
44
+ declare class DiskannRegistry {
45
+ private readonly entries;
46
+ private snapshotCtor;
47
+ private loadCtor;
48
+ build(input: DiskannBuildInput): Promise<DiskannBuildResult>;
49
+ search(name: string, vector: Float32Array, k: number): Promise<DiskannSearchHit[]>;
50
+ list(): DiskannSnapshotInfo[];
51
+ /** Test seam — clear the registry between tests. */
52
+ clear(): void;
53
+ }
54
+ export declare function getDiskannRegistry(): DiskannRegistry;
55
+ export {};
56
+ //# sourceMappingURL=diskann-registry.d.ts.map
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Process-level registry of named `DiskannSnapshot` handles backing
3
+ * the `embeddings_diskann_*` MCP tools.
4
+ *
5
+ * Lifecycle:
6
+ * - `build({ name, dimension, entries, storagePath? })` →
7
+ * creates a snapshot, adds the entries, builds the Vamana graph,
8
+ * persists if storagePath is set, stashes the handle under `name`.
9
+ * - `search(name, vector, k)` → top-k against the named snapshot.
10
+ * - `list()` → inventory of all current snapshots (name, dimension,
11
+ * count, storagePath?).
12
+ *
13
+ * The registry is process-level; agents that want cross-restart
14
+ * persistence should pass `storagePath` on build and reload from
15
+ * disk via a separate `embeddings_diskann_load` follow-up tool.
16
+ *
17
+ * ADR-121 Phase 5b — cli alpha.47.
18
+ */
19
+ class DiskannRegistry {
20
+ entries = new Map();
21
+ snapshotCtor = null;
22
+ async loadCtor() {
23
+ if (this.snapshotCtor)
24
+ return this.snapshotCtor;
25
+ // Same wildcard sub-path import the sidecar tool uses (Phase 5 full).
26
+ const mod = await import('@claude-flow/embeddings/diskann-snapshot');
27
+ this.snapshotCtor = mod.DiskannSnapshot;
28
+ return this.snapshotCtor;
29
+ }
30
+ async build(input) {
31
+ const ctor = await this.loadCtor();
32
+ const t0 = Date.now();
33
+ const snap = await ctor.create({
34
+ dimension: input.dimension,
35
+ storagePath: input.storagePath,
36
+ });
37
+ // Convert plain-number arrays from the MCP input into Float32Array.
38
+ const float32Entries = input.entries.map(e => ({
39
+ id: e.id,
40
+ vector: new Float32Array(e.vector),
41
+ }));
42
+ snap.add(float32Entries);
43
+ await snap.build();
44
+ const buildMs = Date.now() - t0;
45
+ // Replace any existing snapshot under this name.
46
+ this.entries.set(input.name, {
47
+ snapshot: snap,
48
+ dimension: input.dimension,
49
+ storagePath: input.storagePath,
50
+ });
51
+ return {
52
+ dimension: input.dimension,
53
+ count: snap.count(),
54
+ buildMs,
55
+ storagePath: input.storagePath,
56
+ };
57
+ }
58
+ async search(name, vector, k) {
59
+ const entry = this.entries.get(name);
60
+ if (!entry) {
61
+ throw new Error(`embeddings_diskann_search: no snapshot named "${name}" — call embeddings_diskann_build first`);
62
+ }
63
+ return entry.snapshot.search(vector, k);
64
+ }
65
+ list() {
66
+ const out = [];
67
+ for (const [name, entry] of this.entries) {
68
+ out.push({
69
+ name,
70
+ dimension: entry.dimension,
71
+ count: entry.snapshot.count(),
72
+ storagePath: entry.storagePath,
73
+ });
74
+ }
75
+ return out;
76
+ }
77
+ /** Test seam — clear the registry between tests. */
78
+ clear() {
79
+ this.entries.clear();
80
+ }
81
+ }
82
+ let singleton = null;
83
+ export function getDiskannRegistry() {
84
+ if (!singleton)
85
+ singleton = new DiskannRegistry();
86
+ return singleton;
87
+ }
88
+ //# sourceMappingURL=diskann-registry.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claude-flow/cli",
3
- "version": "3.7.0-alpha.46",
3
+ "version": "3.7.0-alpha.47",
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",