ruvector 0.1.63 → 0.1.64

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.
@@ -0,0 +1,148 @@
1
+ /**
2
+ * Cluster Wrapper - Distributed coordination for multi-agent systems
3
+ *
4
+ * Wraps @ruvector/cluster for Raft consensus, auto-sharding,
5
+ * and distributed memory across agents.
6
+ */
7
+ export declare function isClusterAvailable(): boolean;
8
+ export interface ClusterNode {
9
+ id: string;
10
+ address: string;
11
+ role: 'leader' | 'follower' | 'candidate';
12
+ status: 'healthy' | 'unhealthy' | 'unknown';
13
+ lastHeartbeat: number;
14
+ }
15
+ export interface ShardInfo {
16
+ id: number;
17
+ range: [number, number];
18
+ node: string;
19
+ size: number;
20
+ status: 'active' | 'migrating' | 'offline';
21
+ }
22
+ export interface ClusterConfig {
23
+ nodeId: string;
24
+ address: string;
25
+ peers?: string[];
26
+ shards?: number;
27
+ replicationFactor?: number;
28
+ }
29
+ /**
30
+ * Distributed cluster for multi-agent coordination
31
+ */
32
+ export declare class RuvectorCluster {
33
+ private inner;
34
+ private nodeId;
35
+ private isLeader;
36
+ constructor(config: ClusterConfig);
37
+ /**
38
+ * Start the cluster node
39
+ */
40
+ start(): Promise<void>;
41
+ /**
42
+ * Stop the cluster node gracefully
43
+ */
44
+ stop(): Promise<void>;
45
+ /**
46
+ * Join an existing cluster
47
+ */
48
+ join(peerAddress: string): Promise<boolean>;
49
+ /**
50
+ * Leave the cluster
51
+ */
52
+ leave(): Promise<void>;
53
+ /**
54
+ * Get current node info
55
+ */
56
+ getNodeInfo(): ClusterNode;
57
+ /**
58
+ * Get all cluster nodes
59
+ */
60
+ getNodes(): ClusterNode[];
61
+ /**
62
+ * Check if this node is the leader
63
+ */
64
+ isClusterLeader(): boolean;
65
+ /**
66
+ * Get the current leader
67
+ */
68
+ getLeader(): ClusterNode | null;
69
+ /**
70
+ * Put a value in distributed storage
71
+ */
72
+ put(key: string, value: any): Promise<boolean>;
73
+ /**
74
+ * Get a value from distributed storage
75
+ */
76
+ get(key: string): Promise<any | null>;
77
+ /**
78
+ * Delete a value from distributed storage
79
+ */
80
+ delete(key: string): Promise<boolean>;
81
+ /**
82
+ * Atomic compare-and-swap
83
+ */
84
+ compareAndSwap(key: string, expected: any, newValue: any): Promise<boolean>;
85
+ /**
86
+ * Get shard information
87
+ */
88
+ getShards(): ShardInfo[];
89
+ /**
90
+ * Get the shard for a key
91
+ */
92
+ getShardForKey(key: string): ShardInfo;
93
+ /**
94
+ * Trigger shard rebalancing
95
+ */
96
+ rebalance(): Promise<void>;
97
+ /**
98
+ * Acquire a distributed lock
99
+ */
100
+ lock(name: string, timeout?: number): Promise<string | null>;
101
+ /**
102
+ * Release a distributed lock
103
+ */
104
+ unlock(name: string, token: string): Promise<boolean>;
105
+ /**
106
+ * Extend a lock's TTL
107
+ */
108
+ extendLock(name: string, token: string, extension?: number): Promise<boolean>;
109
+ /**
110
+ * Subscribe to a channel
111
+ */
112
+ subscribe(channel: string, callback: (message: any) => void): () => void;
113
+ /**
114
+ * Publish to a channel
115
+ */
116
+ publish(channel: string, message: any): Promise<number>;
117
+ /**
118
+ * Register an agent with the cluster
119
+ */
120
+ registerAgent(agentId: string, capabilities: string[]): Promise<boolean>;
121
+ /**
122
+ * Find agents with a capability
123
+ */
124
+ findAgents(capability: string): Promise<string[]>;
125
+ /**
126
+ * Assign a task to an agent
127
+ */
128
+ assignTask(taskId: string, agentId: string, task: any): Promise<boolean>;
129
+ /**
130
+ * Complete a task
131
+ */
132
+ completeTask(taskId: string, result: any): Promise<boolean>;
133
+ /**
134
+ * Get cluster statistics
135
+ */
136
+ stats(): {
137
+ nodes: number;
138
+ shards: number;
139
+ leader: string | null;
140
+ healthy: boolean;
141
+ };
142
+ }
143
+ /**
144
+ * Create a cluster node for agent coordination
145
+ */
146
+ export declare function createCluster(config: ClusterConfig): RuvectorCluster;
147
+ export default RuvectorCluster;
148
+ //# sourceMappingURL=cluster-wrapper.d.ts.map
@@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AAE,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;IAQ7D;;OAEG;IACG,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAS9E;;OAEG;IACG,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAcvD;;OAEG;IACG,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC;IAgB9E;;OAEG;IACG,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC;IAgBjE;;OAEG;IACH,KAAK,IAAI;QACP,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;QACtB,OAAO,EAAE,OAAO,CAAC;KAClB;CAGF;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,eAAe,CAEpE;AAED,eAAe,eAAe,CAAC"}
@@ -0,0 +1,271 @@
1
+ "use strict";
2
+ /**
3
+ * Cluster Wrapper - Distributed coordination for multi-agent systems
4
+ *
5
+ * Wraps @ruvector/cluster for Raft consensus, auto-sharding,
6
+ * and distributed memory across agents.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.RuvectorCluster = void 0;
10
+ exports.isClusterAvailable = isClusterAvailable;
11
+ exports.createCluster = createCluster;
12
+ let clusterModule = null;
13
+ let loadError = null;
14
+ function getClusterModule() {
15
+ if (clusterModule)
16
+ return clusterModule;
17
+ if (loadError)
18
+ throw loadError;
19
+ try {
20
+ clusterModule = require('@ruvector/cluster');
21
+ return clusterModule;
22
+ }
23
+ catch (e) {
24
+ loadError = new Error(`@ruvector/cluster not installed: ${e.message}\n` +
25
+ `Install with: npm install @ruvector/cluster`);
26
+ throw loadError;
27
+ }
28
+ }
29
+ function isClusterAvailable() {
30
+ try {
31
+ getClusterModule();
32
+ return true;
33
+ }
34
+ catch {
35
+ return false;
36
+ }
37
+ }
38
+ /**
39
+ * Distributed cluster for multi-agent coordination
40
+ */
41
+ class RuvectorCluster {
42
+ constructor(config) {
43
+ this.isLeader = false;
44
+ const cluster = getClusterModule();
45
+ this.nodeId = config.nodeId;
46
+ this.inner = new cluster.Cluster({
47
+ nodeId: config.nodeId,
48
+ address: config.address,
49
+ peers: config.peers ?? [],
50
+ shards: config.shards ?? 16,
51
+ replicationFactor: config.replicationFactor ?? 2,
52
+ });
53
+ }
54
+ // ===========================================================================
55
+ // Cluster Lifecycle
56
+ // ===========================================================================
57
+ /**
58
+ * Start the cluster node
59
+ */
60
+ async start() {
61
+ await this.inner.start();
62
+ }
63
+ /**
64
+ * Stop the cluster node gracefully
65
+ */
66
+ async stop() {
67
+ await this.inner.stop();
68
+ }
69
+ /**
70
+ * Join an existing cluster
71
+ */
72
+ async join(peerAddress) {
73
+ return this.inner.join(peerAddress);
74
+ }
75
+ /**
76
+ * Leave the cluster
77
+ */
78
+ async leave() {
79
+ await this.inner.leave();
80
+ }
81
+ // ===========================================================================
82
+ // Node Management
83
+ // ===========================================================================
84
+ /**
85
+ * Get current node info
86
+ */
87
+ getNodeInfo() {
88
+ return this.inner.getNodeInfo();
89
+ }
90
+ /**
91
+ * Get all cluster nodes
92
+ */
93
+ getNodes() {
94
+ return this.inner.getNodes();
95
+ }
96
+ /**
97
+ * Check if this node is the leader
98
+ */
99
+ isClusterLeader() {
100
+ this.isLeader = this.inner.isLeader();
101
+ return this.isLeader;
102
+ }
103
+ /**
104
+ * Get the current leader
105
+ */
106
+ getLeader() {
107
+ return this.inner.getLeader();
108
+ }
109
+ // ===========================================================================
110
+ // Distributed Operations
111
+ // ===========================================================================
112
+ /**
113
+ * Put a value in distributed storage
114
+ */
115
+ async put(key, value) {
116
+ return this.inner.put(key, JSON.stringify(value));
117
+ }
118
+ /**
119
+ * Get a value from distributed storage
120
+ */
121
+ async get(key) {
122
+ const result = await this.inner.get(key);
123
+ return result ? JSON.parse(result) : null;
124
+ }
125
+ /**
126
+ * Delete a value from distributed storage
127
+ */
128
+ async delete(key) {
129
+ return this.inner.delete(key);
130
+ }
131
+ /**
132
+ * Atomic compare-and-swap
133
+ */
134
+ async compareAndSwap(key, expected, newValue) {
135
+ return this.inner.compareAndSwap(key, JSON.stringify(expected), JSON.stringify(newValue));
136
+ }
137
+ // ===========================================================================
138
+ // Sharding
139
+ // ===========================================================================
140
+ /**
141
+ * Get shard information
142
+ */
143
+ getShards() {
144
+ return this.inner.getShards();
145
+ }
146
+ /**
147
+ * Get the shard for a key
148
+ */
149
+ getShardForKey(key) {
150
+ return this.inner.getShardForKey(key);
151
+ }
152
+ /**
153
+ * Trigger shard rebalancing
154
+ */
155
+ async rebalance() {
156
+ await this.inner.rebalance();
157
+ }
158
+ // ===========================================================================
159
+ // Distributed Locks
160
+ // ===========================================================================
161
+ /**
162
+ * Acquire a distributed lock
163
+ */
164
+ async lock(name, timeout = 30000) {
165
+ return this.inner.lock(name, timeout);
166
+ }
167
+ /**
168
+ * Release a distributed lock
169
+ */
170
+ async unlock(name, token) {
171
+ return this.inner.unlock(name, token);
172
+ }
173
+ /**
174
+ * Extend a lock's TTL
175
+ */
176
+ async extendLock(name, token, extension = 30000) {
177
+ return this.inner.extendLock(name, token, extension);
178
+ }
179
+ // ===========================================================================
180
+ // Pub/Sub
181
+ // ===========================================================================
182
+ /**
183
+ * Subscribe to a channel
184
+ */
185
+ subscribe(channel, callback) {
186
+ return this.inner.subscribe(channel, (msg) => {
187
+ callback(JSON.parse(msg));
188
+ });
189
+ }
190
+ /**
191
+ * Publish to a channel
192
+ */
193
+ async publish(channel, message) {
194
+ return this.inner.publish(channel, JSON.stringify(message));
195
+ }
196
+ // ===========================================================================
197
+ // Agent Coordination
198
+ // ===========================================================================
199
+ /**
200
+ * Register an agent with the cluster
201
+ */
202
+ async registerAgent(agentId, capabilities) {
203
+ return this.put(`agent:${agentId}`, {
204
+ id: agentId,
205
+ capabilities,
206
+ node: this.nodeId,
207
+ registeredAt: Date.now(),
208
+ });
209
+ }
210
+ /**
211
+ * Find agents with a capability
212
+ */
213
+ async findAgents(capability) {
214
+ const agents = await this.inner.scan('agent:*');
215
+ const matching = [];
216
+ for (const key of agents) {
217
+ const agent = await this.get(key);
218
+ if (agent?.capabilities?.includes(capability)) {
219
+ matching.push(agent.id);
220
+ }
221
+ }
222
+ return matching;
223
+ }
224
+ /**
225
+ * Assign a task to an agent
226
+ */
227
+ async assignTask(taskId, agentId, task) {
228
+ const assigned = await this.put(`task:${taskId}`, {
229
+ id: taskId,
230
+ agent: agentId,
231
+ task,
232
+ status: 'assigned',
233
+ assignedAt: Date.now(),
234
+ });
235
+ if (assigned) {
236
+ await this.publish(`agent:${agentId}:tasks`, { type: 'new_task', taskId });
237
+ }
238
+ return assigned;
239
+ }
240
+ /**
241
+ * Complete a task
242
+ */
243
+ async completeTask(taskId, result) {
244
+ const task = await this.get(`task:${taskId}`);
245
+ if (!task)
246
+ return false;
247
+ return this.put(`task:${taskId}`, {
248
+ ...task,
249
+ status: 'completed',
250
+ result,
251
+ completedAt: Date.now(),
252
+ });
253
+ }
254
+ // ===========================================================================
255
+ // Stats
256
+ // ===========================================================================
257
+ /**
258
+ * Get cluster statistics
259
+ */
260
+ stats() {
261
+ return this.inner.stats();
262
+ }
263
+ }
264
+ exports.RuvectorCluster = RuvectorCluster;
265
+ /**
266
+ * Create a cluster node for agent coordination
267
+ */
268
+ function createCluster(config) {
269
+ return new RuvectorCluster(config);
270
+ }
271
+ exports.default = RuvectorCluster;
@@ -0,0 +1,147 @@
1
+ /**
2
+ * Graph Wrapper - Hypergraph database for code relationships
3
+ *
4
+ * Wraps @ruvector/graph-node for dependency analysis, co-edit patterns,
5
+ * and code structure understanding.
6
+ */
7
+ export declare function isGraphAvailable(): boolean;
8
+ export interface Node {
9
+ id: string;
10
+ labels: string[];
11
+ properties: Record<string, any>;
12
+ }
13
+ export interface Edge {
14
+ id?: string;
15
+ from: string;
16
+ to: string;
17
+ type: string;
18
+ properties?: Record<string, any>;
19
+ }
20
+ export interface Hyperedge {
21
+ id?: string;
22
+ nodes: string[];
23
+ type: string;
24
+ properties?: Record<string, any>;
25
+ }
26
+ export interface CypherResult {
27
+ columns: string[];
28
+ rows: any[][];
29
+ }
30
+ export interface PathResult {
31
+ nodes: Node[];
32
+ edges: Edge[];
33
+ length: number;
34
+ }
35
+ /**
36
+ * Graph Database for code relationships
37
+ */
38
+ export declare class CodeGraph {
39
+ private inner;
40
+ private storagePath?;
41
+ constructor(options?: {
42
+ storagePath?: string;
43
+ inMemory?: boolean;
44
+ });
45
+ /**
46
+ * Create a node (file, function, class, etc.)
47
+ */
48
+ createNode(id: string, labels: string[], properties?: Record<string, any>): Node;
49
+ /**
50
+ * Get a node by ID
51
+ */
52
+ getNode(id: string): Node | null;
53
+ /**
54
+ * Update node properties
55
+ */
56
+ updateNode(id: string, properties: Record<string, any>): boolean;
57
+ /**
58
+ * Delete a node
59
+ */
60
+ deleteNode(id: string): boolean;
61
+ /**
62
+ * Find nodes by label
63
+ */
64
+ findNodesByLabel(label: string): Node[];
65
+ /**
66
+ * Create an edge (import, call, reference, etc.)
67
+ */
68
+ createEdge(from: string, to: string, type: string, properties?: Record<string, any>): Edge;
69
+ /**
70
+ * Get edges from a node
71
+ */
72
+ getOutgoingEdges(nodeId: string, type?: string): Edge[];
73
+ /**
74
+ * Get edges to a node
75
+ */
76
+ getIncomingEdges(nodeId: string, type?: string): Edge[];
77
+ /**
78
+ * Delete an edge
79
+ */
80
+ deleteEdge(edgeId: string): boolean;
81
+ /**
82
+ * Create a hyperedge connecting multiple nodes
83
+ */
84
+ createHyperedge(nodes: string[], type: string, properties?: Record<string, any>): Hyperedge;
85
+ /**
86
+ * Get hyperedges containing a node
87
+ */
88
+ getHyperedges(nodeId: string, type?: string): Hyperedge[];
89
+ /**
90
+ * Execute a Cypher query
91
+ */
92
+ cypher(query: string, params?: Record<string, any>): CypherResult;
93
+ /**
94
+ * Find shortest path between nodes
95
+ */
96
+ shortestPath(from: string, to: string, maxDepth?: number): PathResult | null;
97
+ /**
98
+ * Get all paths between nodes (up to maxPaths)
99
+ */
100
+ allPaths(from: string, to: string, maxDepth?: number, maxPaths?: number): PathResult[];
101
+ /**
102
+ * Get neighbors of a node
103
+ */
104
+ neighbors(nodeId: string, depth?: number): Node[];
105
+ /**
106
+ * Calculate PageRank for nodes
107
+ */
108
+ pageRank(iterations?: number, dampingFactor?: number): Map<string, number>;
109
+ /**
110
+ * Find connected components
111
+ */
112
+ connectedComponents(): string[][];
113
+ /**
114
+ * Detect communities (Louvain algorithm)
115
+ */
116
+ communities(): Map<string, number>;
117
+ /**
118
+ * Calculate betweenness centrality
119
+ */
120
+ betweennessCentrality(): Map<string, number>;
121
+ /**
122
+ * Save graph to storage
123
+ */
124
+ save(): void;
125
+ /**
126
+ * Load graph from storage
127
+ */
128
+ load(): void;
129
+ /**
130
+ * Clear all data
131
+ */
132
+ clear(): void;
133
+ /**
134
+ * Get graph statistics
135
+ */
136
+ stats(): {
137
+ nodes: number;
138
+ edges: number;
139
+ hyperedges: number;
140
+ };
141
+ }
142
+ /**
143
+ * Create a code dependency graph from file analysis
144
+ */
145
+ export declare function createCodeDependencyGraph(storagePath?: string): CodeGraph;
146
+ export default CodeGraph;
147
+ //# sourceMappingURL=graph-wrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph-wrapper.d.ts","sourceRoot":"","sources":["../../src/core/graph-wrapper.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAqBH,wBAAgB,gBAAgB,IAAI,OAAO,CAO1C;AAED,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,UAAU,EAAE,MAAM,C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AE,MAAU,GAAG,IAAI,EAAE;IAapD;;OAEG;IACH,QAAQ,CAAC,UAAU,GAAE,MAAW,EAAE,aAAa,GAAE,MAAa,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAKpF;;OAEG;IACH,mBAAmB,IAAI,MAAM,EAAE,EAAE;IAIjC;;OAEG;IACH,WAAW,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAKlC;;OAEG;IACH,qBAAqB,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAS5C;;OAEG;IACH,IAAI,IAAI,IAAI;IAOZ;;OAEG;IACH,IAAI,IAAI,IAAI;IAOZ;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;OAEG;IACH,KAAK,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE;CAG9D;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAEzE;AAED,eAAe,SAAS,CAAC"}
@@ -0,0 +1,299 @@
1
+ "use strict";
2
+ /**
3
+ * Graph Wrapper - Hypergraph database for code relationships
4
+ *
5
+ * Wraps @ruvector/graph-node for dependency analysis, co-edit patterns,
6
+ * and code structure understanding.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.CodeGraph = void 0;
10
+ exports.isGraphAvailable = isGraphAvailable;
11
+ exports.createCodeDependencyGraph = createCodeDependencyGraph;
12
+ let graphModule = null;
13
+ let loadError = null;
14
+ function getGraphModule() {
15
+ if (graphModule)
16
+ return graphModule;
17
+ if (loadError)
18
+ throw loadError;
19
+ try {
20
+ graphModule = require('@ruvector/graph-node');
21
+ return graphModule;
22
+ }
23
+ catch (e) {
24
+ loadError = new Error(`@ruvector/graph-node not installed: ${e.message}\n` +
25
+ `Install with: npm install @ruvector/graph-node`);
26
+ throw loadError;
27
+ }
28
+ }
29
+ function isGraphAvailable() {
30
+ try {
31
+ getGraphModule();
32
+ return true;
33
+ }
34
+ catch {
35
+ return false;
36
+ }
37
+ }
38
+ /**
39
+ * Graph Database for code relationships
40
+ */
41
+ class CodeGraph {
42
+ constructor(options = {}) {
43
+ const graph = getGraphModule();
44
+ this.storagePath = options.storagePath;
45
+ this.inner = new graph.GraphDatabase({
46
+ storagePath: options.storagePath,
47
+ inMemory: options.inMemory ?? true,
48
+ });
49
+ }
50
+ // ===========================================================================
51
+ // Node Operations
52
+ // ===========================================================================
53
+ /**
54
+ * Create a node (file, function, class, etc.)
55
+ */
56
+ createNode(id, labels, properties = {}) {
57
+ this.inner.createNode(id, labels, JSON.stringify(properties));
58
+ return { id, labels, properties };
59
+ }
60
+ /**
61
+ * Get a node by ID
62
+ */
63
+ getNode(id) {
64
+ const result = this.inner.getNode(id);
65
+ if (!result)
66
+ return null;
67
+ return {
68
+ id: result.id,
69
+ labels: result.labels,
70
+ properties: result.properties ? JSON.parse(result.properties) : {},
71
+ };
72
+ }
73
+ /**
74
+ * Update node properties
75
+ */
76
+ updateNode(id, properties) {
77
+ return this.inner.updateNode(id, JSON.stringify(properties));
78
+ }
79
+ /**
80
+ * Delete a node
81
+ */
82
+ deleteNode(id) {
83
+ return this.inner.deleteNode(id);
84
+ }
85
+ /**
86
+ * Find nodes by label
87
+ */
88
+ findNodesByLabel(label) {
89
+ const results = this.inner.findNodesByLabel(label);
90
+ return results.map((r) => ({
91
+ id: r.id,
92
+ labels: r.labels,
93
+ properties: r.properties ? JSON.parse(r.properties) : {},
94
+ }));
95
+ }
96
+ // ===========================================================================
97
+ // Edge Operations
98
+ // ===========================================================================
99
+ /**
100
+ * Create an edge (import, call, reference, etc.)
101
+ */
102
+ createEdge(from, to, type, properties = {}) {
103
+ const id = this.inner.createEdge(from, to, type, JSON.stringify(properties));
104
+ return { id, from, to, type, properties };
105
+ }
106
+ /**
107
+ * Get edges from a node
108
+ */
109
+ getOutgoingEdges(nodeId, type) {
110
+ const results = this.inner.getOutgoingEdges(nodeId, type);
111
+ return results.map((r) => ({
112
+ id: r.id,
113
+ from: r.from,
114
+ to: r.to,
115
+ type: r.type,
116
+ properties: r.properties ? JSON.parse(r.properties) : {},
117
+ }));
118
+ }
119
+ /**
120
+ * Get edges to a node
121
+ */
122
+ getIncomingEdges(nodeId, type) {
123
+ const results = this.inner.getIncomingEdges(nodeId, type);
124
+ return results.map((r) => ({
125
+ id: r.id,
126
+ from: r.from,
127
+ to: r.to,
128
+ type: r.type,
129
+ properties: r.properties ? JSON.parse(r.properties) : {},
130
+ }));
131
+ }
132
+ /**
133
+ * Delete an edge
134
+ */
135
+ deleteEdge(edgeId) {
136
+ return this.inner.deleteEdge(edgeId);
137
+ }
138
+ // ===========================================================================
139
+ // Hyperedge Operations (for co-edit patterns)
140
+ // ===========================================================================
141
+ /**
142
+ * Create a hyperedge connecting multiple nodes
143
+ */
144
+ createHyperedge(nodes, type, properties = {}) {
145
+ const id = this.inner.createHyperedge(nodes, type, JSON.stringify(properties));
146
+ return { id, nodes, type, properties };
147
+ }
148
+ /**
149
+ * Get hyperedges containing a node
150
+ */
151
+ getHyperedges(nodeId, type) {
152
+ const results = this.inner.getHyperedges(nodeId, type);
153
+ return results.map((r) => ({
154
+ id: r.id,
155
+ nodes: r.nodes,
156
+ type: r.type,
157
+ properties: r.properties ? JSON.parse(r.properties) : {},
158
+ }));
159
+ }
160
+ // ===========================================================================
161
+ // Query Operations
162
+ // ===========================================================================
163
+ /**
164
+ * Execute a Cypher query
165
+ */
166
+ cypher(query, params = {}) {
167
+ const result = this.inner.cypher(query, JSON.stringify(params));
168
+ return {
169
+ columns: result.columns,
170
+ rows: result.rows,
171
+ };
172
+ }
173
+ /**
174
+ * Find shortest path between nodes
175
+ */
176
+ shortestPath(from, to, maxDepth = 10) {
177
+ const result = this.inner.shortestPath(from, to, maxDepth);
178
+ if (!result)
179
+ return null;
180
+ return {
181
+ nodes: result.nodes.map((n) => ({
182
+ id: n.id,
183
+ labels: n.labels,
184
+ properties: n.properties ? JSON.parse(n.properties) : {},
185
+ })),
186
+ edges: result.edges.map((e) => ({
187
+ id: e.id,
188
+ from: e.from,
189
+ to: e.to,
190
+ type: e.type,
191
+ properties: e.properties ? JSON.parse(e.properties) : {},
192
+ })),
193
+ length: result.length,
194
+ };
195
+ }
196
+ /**
197
+ * Get all paths between nodes (up to maxPaths)
198
+ */
199
+ allPaths(from, to, maxDepth = 5, maxPaths = 10) {
200
+ const results = this.inner.allPaths(from, to, maxDepth, maxPaths);
201
+ return results.map((r) => ({
202
+ nodes: r.nodes.map((n) => ({
203
+ id: n.id,
204
+ labels: n.labels,
205
+ properties: n.properties ? JSON.parse(n.properties) : {},
206
+ })),
207
+ edges: r.edges.map((e) => ({
208
+ id: e.id,
209
+ from: e.from,
210
+ to: e.to,
211
+ type: e.type,
212
+ properties: e.properties ? JSON.parse(e.properties) : {},
213
+ })),
214
+ length: r.length,
215
+ }));
216
+ }
217
+ /**
218
+ * Get neighbors of a node
219
+ */
220
+ neighbors(nodeId, depth = 1) {
221
+ const results = this.inner.neighbors(nodeId, depth);
222
+ return results.map((n) => ({
223
+ id: n.id,
224
+ labels: n.labels,
225
+ properties: n.properties ? JSON.parse(n.properties) : {},
226
+ }));
227
+ }
228
+ // ===========================================================================
229
+ // Graph Algorithms
230
+ // ===========================================================================
231
+ /**
232
+ * Calculate PageRank for nodes
233
+ */
234
+ pageRank(iterations = 20, dampingFactor = 0.85) {
235
+ const result = this.inner.pageRank(iterations, dampingFactor);
236
+ return new Map(Object.entries(result));
237
+ }
238
+ /**
239
+ * Find connected components
240
+ */
241
+ connectedComponents() {
242
+ return this.inner.connectedComponents();
243
+ }
244
+ /**
245
+ * Detect communities (Louvain algorithm)
246
+ */
247
+ communities() {
248
+ const result = this.inner.communities();
249
+ return new Map(Object.entries(result));
250
+ }
251
+ /**
252
+ * Calculate betweenness centrality
253
+ */
254
+ betweennessCentrality() {
255
+ const result = this.inner.betweennessCentrality();
256
+ return new Map(Object.entries(result));
257
+ }
258
+ // ===========================================================================
259
+ // Persistence
260
+ // ===========================================================================
261
+ /**
262
+ * Save graph to storage
263
+ */
264
+ save() {
265
+ if (!this.storagePath) {
266
+ throw new Error('No storage path configured');
267
+ }
268
+ this.inner.save();
269
+ }
270
+ /**
271
+ * Load graph from storage
272
+ */
273
+ load() {
274
+ if (!this.storagePath) {
275
+ throw new Error('No storage path configured');
276
+ }
277
+ this.inner.load();
278
+ }
279
+ /**
280
+ * Clear all data
281
+ */
282
+ clear() {
283
+ this.inner.clear();
284
+ }
285
+ /**
286
+ * Get graph statistics
287
+ */
288
+ stats() {
289
+ return this.inner.stats();
290
+ }
291
+ }
292
+ exports.CodeGraph = CodeGraph;
293
+ /**
294
+ * Create a code dependency graph from file analysis
295
+ */
296
+ function createCodeDependencyGraph(storagePath) {
297
+ return new CodeGraph({ storagePath, inMemory: !storagePath });
298
+ }
299
+ exports.default = CodeGraph;
@@ -12,6 +12,9 @@ export * from './intelligence-engine';
12
12
  export * from './onnx-embedder';
13
13
  export * from './parallel-intelligence';
14
14
  export * from './parallel-workers';
15
+ export * from './router-wrapper';
16
+ export * from './graph-wrapper';
17
+ export * from './cluster-wrapper';
15
18
  export { default as gnnWrapper } from './gnn-wrapper';
16
19
  export { default as attentionFallbacks } from './attention-fallbacks';
17
20
  export { default as agentdbFast } from './agentdb-fast';
@@ -20,4 +23,7 @@ export { default as IntelligenceEngine } from './intelligence-engine';
20
23
  export { default as OnnxEmbedder } from './onnx-embedder';
21
24
  export { default as ParallelIntelligence } from './parallel-intelligence';
22
25
  export { default as ExtendedWorkerPool } from './parallel-workers';
26
+ export { default as SemanticRouter } from './router-wrapper';
27
+ export { default as CodeGraph } from './graph-wrapper';
28
+ export { default as RuvectorCluster } from './cluster-wrapper';
23
29
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;A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tE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
@@ -23,7 +23,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
23
23
  return (mod && mod.__esModule) ? mod : { "default": mod };
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.ExtendedWorkerPool = exports.ParallelIntelligence = exports.OnnxEmbedder = exports.IntelligenceEngine = exports.Sona = exports.agentdbFast = exports.attentionFallbacks = exports.gnnWrapper = void 0;
26
+ exports.RuvectorCluster = exports.CodeGraph = exports.SemanticRouter = exports.ExtendedWorkerPool = exports.ParallelIntelligence = exports.OnnxEmbedder = exports.IntelligenceEngine = exports.Sona = exports.agentdbFast = exports.attentionFallbacks = exports.gnnWrapper = void 0;
27
27
  __exportStar(require("./gnn-wrapper"), exports);
28
28
  __exportStar(require("./attention-fallbacks"), exports);
29
29
  __exportStar(require("./agentdb-fast"), exports);
@@ -32,6 +32,9 @@ __exportStar(require("./intelligence-engine"), exports);
32
32
  __exportStar(require("./onnx-embedder"), exports);
33
33
  __exportStar(require("./parallel-intelligence"), exports);
34
34
  __exportStar(require("./parallel-workers"), exports);
35
+ __exportStar(require("./router-wrapper"), exports);
36
+ __exportStar(require("./graph-wrapper"), exports);
37
+ __exportStar(require("./cluster-wrapper"), exports);
35
38
  // Re-export default objects for convenience
36
39
  var gnn_wrapper_1 = require("./gnn-wrapper");
37
40
  Object.defineProperty(exports, "gnnWrapper", { enumerable: true, get: function () { return __importDefault(gnn_wrapper_1).default; } });
@@ -49,3 +52,9 @@ var parallel_intelligence_1 = require("./parallel-intelligence");
49
52
  Object.defineProperty(exports, "ParallelIntelligence", { enumerable: true, get: function () { return __importDefault(parallel_intelligence_1).default; } });
50
53
  var parallel_workers_1 = require("./parallel-workers");
51
54
  Object.defineProperty(exports, "ExtendedWorkerPool", { enumerable: true, get: function () { return __importDefault(parallel_workers_1).default; } });
55
+ var router_wrapper_1 = require("./router-wrapper");
56
+ Object.defineProperty(exports, "SemanticRouter", { enumerable: true, get: function () { return __importDefault(router_wrapper_1).default; } });
57
+ var graph_wrapper_1 = require("./graph-wrapper");
58
+ Object.defineProperty(exports, "CodeGraph", { enumerable: true, get: function () { return __importDefault(graph_wrapper_1).default; } });
59
+ var cluster_wrapper_1 = require("./cluster-wrapper");
60
+ Object.defineProperty(exports, "RuvectorCluster", { enumerable: true, get: function () { return __importDefault(cluster_wrapper_1).default; } });
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Router Wrapper - Semantic router for AI agent intent matching
3
+ *
4
+ * Wraps @ruvector/router for vector-based intent classification.
5
+ * Perfect for hooks to route tasks to the right agent.
6
+ */
7
+ export declare function isRouterAvailable(): boolean;
8
+ export interface Route {
9
+ name: string;
10
+ utterances: string[];
11
+ metadata?: Record<string, any>;
12
+ }
13
+ export interface RouteMatch {
14
+ route: string;
15
+ score: number;
16
+ metadata?: Record<string, any>;
17
+ }
18
+ /**
19
+ * Semantic Router for agent task routing
20
+ */
21
+ export declare class SemanticRouter {
22
+ private inner;
23
+ private routes;
24
+ constructor(options?: {
25
+ dimensions?: number;
26
+ threshold?: number;
27
+ });
28
+ /**
29
+ * Add a route with example utterances
30
+ */
31
+ addRoute(name: string, utterances: string[], metadata?: Record<string, any>): void;
32
+ /**
33
+ * Add multiple routes at once
34
+ */
35
+ addRoutes(routes: Route[]): void;
36
+ /**
37
+ * Match input to best route
38
+ */
39
+ match(input: string): RouteMatch | null;
40
+ /**
41
+ * Get top-k route matches
42
+ */
43
+ matchTopK(input: string, k?: number): RouteMatch[];
44
+ /**
45
+ * Get all registered routes
46
+ */
47
+ getRoutes(): Route[];
48
+ /**
49
+ * Remove a route
50
+ */
51
+ removeRoute(name: string): boolean;
52
+ /**
53
+ * Clear all routes
54
+ */
55
+ clear(): void;
56
+ }
57
+ /**
58
+ * Create a pre-configured agent router for hooks
59
+ */
60
+ export declare function createAgentRouter(): SemanticRouter;
61
+ export default SemanticRouter;
62
+ //# sourceMappingURL=router-wrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router-wrapper.d.ts","sourceRoot":"","sources":["../../src/core/router-wrapper.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAqBH,wBAAgB,iBAAiB,IAAI,OAAO,CAO3C;AAED,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC;AAED;;GAEG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,KAAK,CAAM;IACnB,OAAO,CAAC,MAAM,CAAiC;gBAEnC,OAAO,GAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAO;IAQrE;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;IAKlF;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI;IAMhC;;OAEG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI;IAWvC;;OAEG;IACH,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,GAAE,MAAU,GAAG,UAAU,EAAE;IASrD;;OAEG;IACH,SAAS,IAAI,KAAK,EAAE;IAIpB;;OAEG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAMlC;;OAEG;IACH,KAAK,IAAI,IAAI;CAId;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,cAAc,CA8FlD;AAED,eAAe,cAAc,CAAC"}
@@ -0,0 +1,209 @@
1
+ "use strict";
2
+ /**
3
+ * Router Wrapper - Semantic router for AI agent intent matching
4
+ *
5
+ * Wraps @ruvector/router for vector-based intent classification.
6
+ * Perfect for hooks to route tasks to the right agent.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.SemanticRouter = void 0;
10
+ exports.isRouterAvailable = isRouterAvailable;
11
+ exports.createAgentRouter = createAgentRouter;
12
+ let routerModule = null;
13
+ let loadError = null;
14
+ function getRouterModule() {
15
+ if (routerModule)
16
+ return routerModule;
17
+ if (loadError)
18
+ throw loadError;
19
+ try {
20
+ routerModule = require('@ruvector/router');
21
+ return routerModule;
22
+ }
23
+ catch (e) {
24
+ loadError = new Error(`@ruvector/router not installed: ${e.message}\n` +
25
+ `Install with: npm install @ruvector/router`);
26
+ throw loadError;
27
+ }
28
+ }
29
+ function isRouterAvailable() {
30
+ try {
31
+ getRouterModule();
32
+ return true;
33
+ }
34
+ catch {
35
+ return false;
36
+ }
37
+ }
38
+ /**
39
+ * Semantic Router for agent task routing
40
+ */
41
+ class SemanticRouter {
42
+ constructor(options = {}) {
43
+ this.routes = new Map();
44
+ const router = getRouterModule();
45
+ this.inner = new router.SemanticRouter({
46
+ dimensions: options.dimensions ?? 384,
47
+ threshold: options.threshold ?? 0.7,
48
+ });
49
+ }
50
+ /**
51
+ * Add a route with example utterances
52
+ */
53
+ addRoute(name, utterances, metadata) {
54
+ this.routes.set(name, { name, utterances, metadata });
55
+ this.inner.addRoute(name, utterances, metadata ? JSON.stringify(metadata) : undefined);
56
+ }
57
+ /**
58
+ * Add multiple routes at once
59
+ */
60
+ addRoutes(routes) {
61
+ for (const route of routes) {
62
+ this.addRoute(route.name, route.utterances, route.metadata);
63
+ }
64
+ }
65
+ /**
66
+ * Match input to best route
67
+ */
68
+ match(input) {
69
+ const result = this.inner.match(input);
70
+ if (!result)
71
+ return null;
72
+ return {
73
+ route: result.route,
74
+ score: result.score,
75
+ metadata: result.metadata ? JSON.parse(result.metadata) : undefined,
76
+ };
77
+ }
78
+ /**
79
+ * Get top-k route matches
80
+ */
81
+ matchTopK(input, k = 3) {
82
+ const results = this.inner.matchTopK(input, k);
83
+ return results.map((r) => ({
84
+ route: r.route,
85
+ score: r.score,
86
+ metadata: r.metadata ? JSON.parse(r.metadata) : undefined,
87
+ }));
88
+ }
89
+ /**
90
+ * Get all registered routes
91
+ */
92
+ getRoutes() {
93
+ return Array.from(this.routes.values());
94
+ }
95
+ /**
96
+ * Remove a route
97
+ */
98
+ removeRoute(name) {
99
+ if (!this.routes.has(name))
100
+ return false;
101
+ this.routes.delete(name);
102
+ return this.inner.removeRoute(name);
103
+ }
104
+ /**
105
+ * Clear all routes
106
+ */
107
+ clear() {
108
+ this.routes.clear();
109
+ this.inner.clear();
110
+ }
111
+ }
112
+ exports.SemanticRouter = SemanticRouter;
113
+ /**
114
+ * Create a pre-configured agent router for hooks
115
+ */
116
+ function createAgentRouter() {
117
+ const router = new SemanticRouter({ threshold: 0.6 });
118
+ // Add common agent routes
119
+ router.addRoutes([
120
+ {
121
+ name: 'coder',
122
+ utterances: [
123
+ 'implement feature',
124
+ 'write code',
125
+ 'create function',
126
+ 'add method',
127
+ 'build component',
128
+ 'fix bug',
129
+ 'update implementation',
130
+ ],
131
+ metadata: { type: 'development' },
132
+ },
133
+ {
134
+ name: 'reviewer',
135
+ utterances: [
136
+ 'review code',
137
+ 'check quality',
138
+ 'find issues',
139
+ 'suggest improvements',
140
+ 'analyze code',
141
+ 'code review',
142
+ ],
143
+ metadata: { type: 'review' },
144
+ },
145
+ {
146
+ name: 'tester',
147
+ utterances: [
148
+ 'write tests',
149
+ 'add test cases',
150
+ 'create unit tests',
151
+ 'test coverage',
152
+ 'integration tests',
153
+ 'verify functionality',
154
+ ],
155
+ metadata: { type: 'testing' },
156
+ },
157
+ {
158
+ name: 'researcher',
159
+ utterances: [
160
+ 'research topic',
161
+ 'find information',
162
+ 'explore options',
163
+ 'investigate',
164
+ 'analyze requirements',
165
+ 'understand codebase',
166
+ ],
167
+ metadata: { type: 'research' },
168
+ },
169
+ {
170
+ name: 'architect',
171
+ utterances: [
172
+ 'design system',
173
+ 'architecture',
174
+ 'structure project',
175
+ 'plan implementation',
176
+ 'design patterns',
177
+ 'system design',
178
+ ],
179
+ metadata: { type: 'architecture' },
180
+ },
181
+ {
182
+ name: 'devops',
183
+ utterances: [
184
+ 'deploy',
185
+ 'ci/cd',
186
+ 'docker',
187
+ 'kubernetes',
188
+ 'infrastructure',
189
+ 'build pipeline',
190
+ 'github actions',
191
+ ],
192
+ metadata: { type: 'devops' },
193
+ },
194
+ {
195
+ name: 'security',
196
+ utterances: [
197
+ 'security audit',
198
+ 'vulnerability',
199
+ 'authentication',
200
+ 'authorization',
201
+ 'secure code',
202
+ 'penetration test',
203
+ ],
204
+ metadata: { type: 'security' },
205
+ },
206
+ ]);
207
+ return router;
208
+ }
209
+ exports.default = SemanticRouter;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ruvector",
3
- "version": "0.1.63",
3
+ "version": "0.1.64",
4
4
  "description": "High-performance vector database for Node.js with automatic native/WASM fallback",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/ruvector.db CHANGED
Binary file