ruvector 0.1.96 → 0.1.98

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/bin/mcp-server.js CHANGED
@@ -24,7 +24,46 @@ const {
24
24
  } = require('@modelcontextprotocol/sdk/types.js');
25
25
  const path = require('path');
26
26
  const fs = require('fs');
27
- const { execSync } = require('child_process');
27
+ const { execSync, execFileSync } = require('child_process');
28
+
29
+ // ── Security Helpers ────────────────────────────────────────────────────────
30
+
31
+ /**
32
+ * Validate a file path argument for RVF operations.
33
+ * Prevents path traversal and restricts to safe locations.
34
+ */
35
+ function validateRvfPath(filePath) {
36
+ if (typeof filePath !== 'string' || filePath.length === 0) {
37
+ throw new Error('Path must be a non-empty string');
38
+ }
39
+ const resolved = path.resolve(filePath);
40
+ // Block obvious path traversal
41
+ if (filePath.includes('..') || filePath.includes('\0')) {
42
+ throw new Error('Path traversal detected');
43
+ }
44
+ // Block sensitive system paths
45
+ const blocked = ['/etc', '/proc', '/sys', '/dev', '/boot', '/root', '/var/run'];
46
+ for (const prefix of blocked) {
47
+ if (resolved.startsWith(prefix)) {
48
+ throw new Error(`Access to ${prefix} is not allowed`);
49
+ }
50
+ }
51
+ return resolved;
52
+ }
53
+
54
+ /**
55
+ * Sanitize a shell argument to prevent command injection.
56
+ * Strips shell metacharacters and limits length.
57
+ */
58
+ function sanitizeShellArg(arg) {
59
+ if (typeof arg !== 'string') return '';
60
+ // Remove null bytes, backticks, $(), and other shell metacharacters
61
+ return arg
62
+ .replace(/\0/g, '')
63
+ .replace(/[`$(){}|;&<>!]/g, '')
64
+ .replace(/\.\./g, '')
65
+ .slice(0, 4096);
66
+ }
28
67
 
29
68
  // Try to load the full IntelligenceEngine
30
69
  let IntelligenceEngine = null;
@@ -1045,6 +1084,161 @@ const TOOLS = [
1045
1084
  },
1046
1085
  required: []
1047
1086
  }
1087
+ },
1088
+ // ── RVF Vector Store Tools ────────────────────────────────────────────────
1089
+ {
1090
+ name: 'rvf_create',
1091
+ description: 'Create a new RVF vector store (.rvf file) with specified dimensions and distance metric',
1092
+ inputSchema: {
1093
+ type: 'object',
1094
+ properties: {
1095
+ path: { type: 'string', description: 'File path for the new .rvf store' },
1096
+ dimension: { type: 'number', description: 'Vector dimensionality (e.g. 128, 384, 768, 1536)' },
1097
+ metric: { type: 'string', description: 'Distance metric: cosine, l2, or dotproduct', default: 'cosine' }
1098
+ },
1099
+ required: ['path', 'dimension']
1100
+ }
1101
+ },
1102
+ {
1103
+ name: 'rvf_open',
1104
+ description: 'Open an existing RVF store for read-write operations',
1105
+ inputSchema: {
1106
+ type: 'object',
1107
+ properties: {
1108
+ path: { type: 'string', description: 'Path to existing .rvf file' }
1109
+ },
1110
+ required: ['path']
1111
+ }
1112
+ },
1113
+ {
1114
+ name: 'rvf_ingest',
1115
+ description: 'Insert vectors into an RVF store',
1116
+ inputSchema: {
1117
+ type: 'object',
1118
+ properties: {
1119
+ path: { type: 'string', description: 'Path to .rvf store' },
1120
+ entries: { type: 'array', description: 'Array of {id, vector, metadata?} objects', items: { type: 'object' } }
1121
+ },
1122
+ required: ['path', 'entries']
1123
+ }
1124
+ },
1125
+ {
1126
+ name: 'rvf_query',
1127
+ description: 'Query nearest neighbors in an RVF store',
1128
+ inputSchema: {
1129
+ type: 'object',
1130
+ properties: {
1131
+ path: { type: 'string', description: 'Path to .rvf store' },
1132
+ vector: { type: 'array', description: 'Query vector as array of numbers', items: { type: 'number' } },
1133
+ k: { type: 'number', description: 'Number of results to return', default: 10 }
1134
+ },
1135
+ required: ['path', 'vector']
1136
+ }
1137
+ },
1138
+ {
1139
+ name: 'rvf_delete',
1140
+ description: 'Delete vectors by ID from an RVF store',
1141
+ inputSchema: {
1142
+ type: 'object',
1143
+ properties: {
1144
+ path: { type: 'string', description: 'Path to .rvf store' },
1145
+ ids: { type: 'array', description: 'Vector IDs to delete', items: { type: 'number' } }
1146
+ },
1147
+ required: ['path', 'ids']
1148
+ }
1149
+ },
1150
+ {
1151
+ name: 'rvf_status',
1152
+ description: 'Get status of an RVF store (vector count, dimension, metric, file size)',
1153
+ inputSchema: {
1154
+ type: 'object',
1155
+ properties: {
1156
+ path: { type: 'string', description: 'Path to .rvf store' }
1157
+ },
1158
+ required: ['path']
1159
+ }
1160
+ },
1161
+ {
1162
+ name: 'rvf_compact',
1163
+ description: 'Compact an RVF store to reclaim space from deleted vectors',
1164
+ inputSchema: {
1165
+ type: 'object',
1166
+ properties: {
1167
+ path: { type: 'string', description: 'Path to .rvf store' }
1168
+ },
1169
+ required: ['path']
1170
+ }
1171
+ },
1172
+ {
1173
+ name: 'rvf_derive',
1174
+ description: 'Derive a child RVF store from a parent using copy-on-write branching',
1175
+ inputSchema: {
1176
+ type: 'object',
1177
+ properties: {
1178
+ parent_path: { type: 'string', description: 'Path to parent .rvf store' },
1179
+ child_path: { type: 'string', description: 'Path for the new child .rvf store' }
1180
+ },
1181
+ required: ['parent_path', 'child_path']
1182
+ }
1183
+ },
1184
+ {
1185
+ name: 'rvf_segments',
1186
+ description: 'List all segments in an RVF file (VEC, INDEX, KERNEL, EBPF, WITNESS, etc.)',
1187
+ inputSchema: {
1188
+ type: 'object',
1189
+ properties: {
1190
+ path: { type: 'string', description: 'Path to .rvf store' }
1191
+ },
1192
+ required: ['path']
1193
+ }
1194
+ },
1195
+ {
1196
+ name: 'rvf_examples',
1197
+ description: 'List available example .rvf files with download URLs from the ruvector repository',
1198
+ inputSchema: {
1199
+ type: 'object',
1200
+ properties: {
1201
+ filter: { type: 'string', description: 'Filter examples by name or description substring' }
1202
+ },
1203
+ required: []
1204
+ }
1205
+ },
1206
+ // ── rvlite Query Tools ──────────────────────────────────────────────────
1207
+ {
1208
+ name: 'rvlite_sql',
1209
+ description: 'Execute SQL query over rvlite vector database with optional RVF backend',
1210
+ inputSchema: {
1211
+ type: 'object',
1212
+ properties: {
1213
+ query: { type: 'string', description: 'SQL query string (supports distance() and vec_search() functions)' },
1214
+ db_path: { type: 'string', description: 'Path to database file (optional)' }
1215
+ },
1216
+ required: ['query']
1217
+ }
1218
+ },
1219
+ {
1220
+ name: 'rvlite_cypher',
1221
+ description: 'Execute Cypher graph query over rvlite property graph',
1222
+ inputSchema: {
1223
+ type: 'object',
1224
+ properties: {
1225
+ query: { type: 'string', description: 'Cypher query string' },
1226
+ db_path: { type: 'string', description: 'Path to database file (optional)' }
1227
+ },
1228
+ required: ['query']
1229
+ }
1230
+ },
1231
+ {
1232
+ name: 'rvlite_sparql',
1233
+ description: 'Execute SPARQL query over rvlite RDF triple store',
1234
+ inputSchema: {
1235
+ type: 'object',
1236
+ properties: {
1237
+ query: { type: 'string', description: 'SPARQL query string' },
1238
+ db_path: { type: 'string', description: 'Path to database file (optional)' }
1239
+ },
1240
+ required: ['query']
1241
+ }
1048
1242
  }
1049
1243
  ];
1050
1244
 
@@ -1654,7 +1848,8 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1654
1848
 
1655
1849
  case 'hooks_ast_analyze': {
1656
1850
  try {
1657
- const output = execSync(`npx ruvector hooks ast-analyze "${args.file}" --json`, { encoding: 'utf-8', timeout: 30000 });
1851
+ const safeFile = sanitizeShellArg(args.file);
1852
+ const output = execSync(`npx ruvector hooks ast-analyze "${safeFile}" --json`, { encoding: 'utf-8', timeout: 30000 });
1658
1853
  return { content: [{ type: 'text', text: output }] };
1659
1854
  } catch (e) {
1660
1855
  return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: e.message }, null, 2) }] };
@@ -1663,8 +1858,9 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1663
1858
 
1664
1859
  case 'hooks_ast_complexity': {
1665
1860
  try {
1666
- const filesArg = args.files.map(f => `"${f}"`).join(' ');
1667
- const output = execSync(`npx ruvector hooks ast-complexity ${filesArg} --threshold ${args.threshold || 10}`, { encoding: 'utf-8', timeout: 60000 });
1861
+ const filesArg = args.files.map(f => `"${sanitizeShellArg(f)}"`).join(' ');
1862
+ const threshold = parseInt(args.threshold, 10) || 10;
1863
+ const output = execSync(`npx ruvector hooks ast-complexity ${filesArg} --threshold ${threshold}`, { encoding: 'utf-8', timeout: 60000 });
1668
1864
  return { content: [{ type: 'text', text: output }] };
1669
1865
  } catch (e) {
1670
1866
  return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: e.message }, null, 2) }] };
@@ -1673,7 +1869,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1673
1869
 
1674
1870
  case 'hooks_diff_analyze': {
1675
1871
  try {
1676
- const cmd = args.commit ? `npx ruvector hooks diff-analyze "${args.commit}" --json` : 'npx ruvector hooks diff-analyze --json';
1872
+ const cmd = args.commit ? `npx ruvector hooks diff-analyze "${sanitizeShellArg(args.commit)}" --json` : 'npx ruvector hooks diff-analyze --json';
1677
1873
  const output = execSync(cmd, { encoding: 'utf-8', timeout: 60000 });
1678
1874
  return { content: [{ type: 'text', text: output }] };
1679
1875
  } catch (e) {
@@ -1683,7 +1879,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1683
1879
 
1684
1880
  case 'hooks_diff_classify': {
1685
1881
  try {
1686
- const cmd = args.commit ? `npx ruvector hooks diff-classify "${args.commit}"` : 'npx ruvector hooks diff-classify';
1882
+ const cmd = args.commit ? `npx ruvector hooks diff-classify "${sanitizeShellArg(args.commit)}"` : 'npx ruvector hooks diff-classify';
1687
1883
  const output = execSync(cmd, { encoding: 'utf-8', timeout: 30000 });
1688
1884
  return { content: [{ type: 'text', text: output }] };
1689
1885
  } catch (e) {
@@ -1693,7 +1889,9 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1693
1889
 
1694
1890
  case 'hooks_diff_similar': {
1695
1891
  try {
1696
- const output = execSync(`npx ruvector hooks diff-similar -k ${args.top_k || 5} --commits ${args.commits || 50}`, { encoding: 'utf-8', timeout: 120000 });
1892
+ const topK = parseInt(args.top_k, 10) || 5;
1893
+ const commits = parseInt(args.commits, 10) || 50;
1894
+ const output = execSync(`npx ruvector hooks diff-similar -k ${topK} --commits ${commits}`, { encoding: 'utf-8', timeout: 120000 });
1697
1895
  return { content: [{ type: 'text', text: output }] };
1698
1896
  } catch (e) {
1699
1897
  return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: e.message }, null, 2) }] };
@@ -1702,7 +1900,8 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1702
1900
 
1703
1901
  case 'hooks_coverage_route': {
1704
1902
  try {
1705
- const output = execSync(`npx ruvector hooks coverage-route "${args.file}"`, { encoding: 'utf-8', timeout: 15000 });
1903
+ const safeFile = sanitizeShellArg(args.file);
1904
+ const output = execSync(`npx ruvector hooks coverage-route "${safeFile}"`, { encoding: 'utf-8', timeout: 15000 });
1706
1905
  return { content: [{ type: 'text', text: output }] };
1707
1906
  } catch (e) {
1708
1907
  return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: e.message }, null, 2) }] };
@@ -1711,7 +1910,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1711
1910
 
1712
1911
  case 'hooks_coverage_suggest': {
1713
1912
  try {
1714
- const filesArg = args.files.map(f => `"${f}"`).join(' ');
1913
+ const filesArg = args.files.map(f => `"${sanitizeShellArg(f)}"`).join(' ');
1715
1914
  const output = execSync(`npx ruvector hooks coverage-suggest ${filesArg}`, { encoding: 'utf-8', timeout: 30000 });
1716
1915
  return { content: [{ type: 'text', text: output }] };
1717
1916
  } catch (e) {
@@ -1721,7 +1920,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1721
1920
 
1722
1921
  case 'hooks_graph_mincut': {
1723
1922
  try {
1724
- const filesArg = args.files.map(f => `"${f}"`).join(' ');
1923
+ const filesArg = args.files.map(f => `"${sanitizeShellArg(f)}"`).join(' ');
1725
1924
  const output = execSync(`npx ruvector hooks graph-mincut ${filesArg}`, { encoding: 'utf-8', timeout: 60000 });
1726
1925
  return { content: [{ type: 'text', text: output }] };
1727
1926
  } catch (e) {
@@ -1731,9 +1930,9 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1731
1930
 
1732
1931
  case 'hooks_graph_cluster': {
1733
1932
  try {
1734
- const filesArg = args.files.map(f => `"${f}"`).join(' ');
1735
- const method = args.method || 'louvain';
1736
- const clusters = args.clusters || 3;
1933
+ const filesArg = args.files.map(f => `"${sanitizeShellArg(f)}"`).join(' ');
1934
+ const method = sanitizeShellArg(args.method || 'louvain');
1935
+ const clusters = parseInt(args.clusters, 10) || 3;
1737
1936
  const output = execSync(`npx ruvector hooks graph-cluster ${filesArg} --method ${method} --clusters ${clusters}`, { encoding: 'utf-8', timeout: 60000 });
1738
1937
  return { content: [{ type: 'text', text: output }] };
1739
1938
  } catch (e) {
@@ -1743,7 +1942,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1743
1942
 
1744
1943
  case 'hooks_security_scan': {
1745
1944
  try {
1746
- const filesArg = args.files.map(f => `"${f}"`).join(' ');
1945
+ const filesArg = args.files.map(f => `"${sanitizeShellArg(f)}"`).join(' ');
1747
1946
  const output = execSync(`npx ruvector hooks security-scan ${filesArg}`, { encoding: 'utf-8', timeout: 120000 });
1748
1947
  return { content: [{ type: 'text', text: output }] };
1749
1948
  } catch (e) {
@@ -1753,7 +1952,9 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1753
1952
 
1754
1953
  case 'hooks_rag_context': {
1755
1954
  try {
1756
- let cmd = `npx ruvector hooks rag-context "${args.query}" -k ${args.top_k || 5}`;
1955
+ const safeQuery = sanitizeShellArg(args.query);
1956
+ const topK = parseInt(args.top_k, 10) || 5;
1957
+ let cmd = `npx ruvector hooks rag-context "${safeQuery}" -k ${topK}`;
1757
1958
  if (args.rerank) cmd += ' --rerank';
1758
1959
  const output = execSync(cmd, { encoding: 'utf-8', timeout: 30000 });
1759
1960
  return { content: [{ type: 'text', text: output }] };
@@ -1764,7 +1965,9 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1764
1965
 
1765
1966
  case 'hooks_git_churn': {
1766
1967
  try {
1767
- const output = execSync(`npx ruvector hooks git-churn --days ${args.days || 30} --top ${args.top || 10}`, { encoding: 'utf-8', timeout: 30000 });
1968
+ const days = parseInt(args.days, 10) || 30;
1969
+ const top = parseInt(args.top, 10) || 10;
1970
+ const output = execSync(`npx ruvector hooks git-churn --days ${days} --top ${top}`, { encoding: 'utf-8', timeout: 30000 });
1768
1971
  return { content: [{ type: 'text', text: output }] };
1769
1972
  } catch (e) {
1770
1973
  return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: e.message }, null, 2) }] };
@@ -1773,8 +1976,9 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1773
1976
 
1774
1977
  case 'hooks_route_enhanced': {
1775
1978
  try {
1776
- let cmd = `npx ruvector hooks route-enhanced "${args.task}"`;
1777
- if (args.file) cmd += ` --file "${args.file}"`;
1979
+ const safeTask = sanitizeShellArg(args.task);
1980
+ let cmd = `npx ruvector hooks route-enhanced "${safeTask}"`;
1981
+ if (args.file) cmd += ` --file "${sanitizeShellArg(args.file)}"`;
1778
1982
  const output = execSync(cmd, { encoding: 'utf-8', timeout: 30000 });
1779
1983
  return { content: [{ type: 'text', text: output }] };
1780
1984
  } catch (e) {
@@ -2199,7 +2403,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
2199
2403
  // BACKGROUND WORKERS HANDLERS (via agentic-flow)
2200
2404
  // ============================================
2201
2405
  case 'workers_dispatch': {
2202
- const prompt = args.prompt;
2406
+ const prompt = sanitizeShellArg(args.prompt);
2203
2407
  try {
2204
2408
  const result = execSync(`npx agentic-flow@alpha workers dispatch "${prompt.replace(/"/g, '\\"')}"`, {
2205
2409
  encoding: 'utf-8',
@@ -2380,8 +2584,8 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
2380
2584
  }
2381
2585
 
2382
2586
  case 'workers_run': {
2383
- const name = args.name;
2384
- const targetPath = args.path || '.';
2587
+ const name = sanitizeShellArg(args.name);
2588
+ const targetPath = sanitizeShellArg(args.path || '.');
2385
2589
  try {
2386
2590
  const result = execSync(`npx agentic-flow@alpha workers run "${name}" --path "${targetPath}"`, {
2387
2591
  encoding: 'utf-8',
@@ -2447,7 +2651,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
2447
2651
  }
2448
2652
 
2449
2653
  case 'workers_load_config': {
2450
- const configFile = args.file || 'workers.yaml';
2654
+ const configFile = sanitizeShellArg(args.file || 'workers.yaml');
2451
2655
  try {
2452
2656
  const result = execSync(`npx agentic-flow@alpha workers load-config --file "${configFile}"`, {
2453
2657
  encoding: 'utf-8',
@@ -2468,6 +2672,244 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
2468
2672
  }
2469
2673
  }
2470
2674
 
2675
+ // ── RVF Tool Handlers ─────────────────────────────────────────────────
2676
+ case 'rvf_create': {
2677
+ try {
2678
+ const safePath = validateRvfPath(args.path);
2679
+ const { createRvfStore } = require('../dist/core/rvf-wrapper.js');
2680
+ const store = await createRvfStore(safePath, { dimension: args.dimension, metric: args.metric || 'cosine' });
2681
+ const status = store.status ? await store.status() : { dimension: args.dimension };
2682
+ return { content: [{ type: 'text', text: JSON.stringify({ success: true, path: safePath, ...status }, null, 2) }] };
2683
+ } catch (e) {
2684
+ return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: e.message, hint: 'Install @ruvector/rvf: npm install @ruvector/rvf' }, null, 2) }], isError: true };
2685
+ }
2686
+ }
2687
+
2688
+ case 'rvf_open': {
2689
+ try {
2690
+ const safePath = validateRvfPath(args.path);
2691
+ const { openRvfStore, rvfStatus } = require('../dist/core/rvf-wrapper.js');
2692
+ const store = await openRvfStore(safePath);
2693
+ const status = await rvfStatus(store);
2694
+ return { content: [{ type: 'text', text: JSON.stringify({ success: true, path: safePath, ...status }, null, 2) }] };
2695
+ } catch (e) {
2696
+ return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: e.message }, null, 2) }], isError: true };
2697
+ }
2698
+ }
2699
+
2700
+ case 'rvf_ingest': {
2701
+ try {
2702
+ const safePath = validateRvfPath(args.path);
2703
+ const { openRvfStore, rvfIngest, rvfClose } = require('../dist/core/rvf-wrapper.js');
2704
+ const store = await openRvfStore(safePath);
2705
+ const result = await rvfIngest(store, args.entries);
2706
+ await rvfClose(store);
2707
+ return { content: [{ type: 'text', text: JSON.stringify({ success: true, ...result }, null, 2) }] };
2708
+ } catch (e) {
2709
+ return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: e.message }, null, 2) }], isError: true };
2710
+ }
2711
+ }
2712
+
2713
+ case 'rvf_query': {
2714
+ try {
2715
+ const safePath = validateRvfPath(args.path);
2716
+ const { openRvfStore, rvfQuery, rvfClose } = require('../dist/core/rvf-wrapper.js');
2717
+ const store = await openRvfStore(safePath);
2718
+ const results = await rvfQuery(store, args.vector, args.k || 10);
2719
+ await rvfClose(store);
2720
+ return { content: [{ type: 'text', text: JSON.stringify({ success: true, results }, null, 2) }] };
2721
+ } catch (e) {
2722
+ return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: e.message }, null, 2) }], isError: true };
2723
+ }
2724
+ }
2725
+
2726
+ case 'rvf_delete': {
2727
+ try {
2728
+ const safePath = validateRvfPath(args.path);
2729
+ const { openRvfStore, rvfDelete, rvfClose } = require('../dist/core/rvf-wrapper.js');
2730
+ const store = await openRvfStore(safePath);
2731
+ const result = await rvfDelete(store, args.ids);
2732
+ await rvfClose(store);
2733
+ return { content: [{ type: 'text', text: JSON.stringify({ success: true, ...result }, null, 2) }] };
2734
+ } catch (e) {
2735
+ return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: e.message }, null, 2) }], isError: true };
2736
+ }
2737
+ }
2738
+
2739
+ case 'rvf_status': {
2740
+ try {
2741
+ const safePath = validateRvfPath(args.path);
2742
+ const { openRvfStore, rvfStatus, rvfClose } = require('../dist/core/rvf-wrapper.js');
2743
+ const store = await openRvfStore(safePath);
2744
+ const status = await rvfStatus(store);
2745
+ await rvfClose(store);
2746
+ return { content: [{ type: 'text', text: JSON.stringify({ success: true, ...status }, null, 2) }] };
2747
+ } catch (e) {
2748
+ return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: e.message }, null, 2) }], isError: true };
2749
+ }
2750
+ }
2751
+
2752
+ case 'rvf_compact': {
2753
+ try {
2754
+ const safePath = validateRvfPath(args.path);
2755
+ const { openRvfStore, rvfCompact, rvfClose } = require('../dist/core/rvf-wrapper.js');
2756
+ const store = await openRvfStore(safePath);
2757
+ const result = await rvfCompact(store);
2758
+ await rvfClose(store);
2759
+ return { content: [{ type: 'text', text: JSON.stringify({ success: true, ...result }, null, 2) }] };
2760
+ } catch (e) {
2761
+ return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: e.message }, null, 2) }], isError: true };
2762
+ }
2763
+ }
2764
+
2765
+ case 'rvf_derive': {
2766
+ try {
2767
+ const safeParent = validateRvfPath(args.parent_path);
2768
+ const safeChild = validateRvfPath(args.child_path);
2769
+ const { openRvfStore, rvfDerive, rvfClose } = require('../dist/core/rvf-wrapper.js');
2770
+ const store = await openRvfStore(safeParent);
2771
+ await rvfDerive(store, safeChild);
2772
+ await rvfClose(store);
2773
+ return { content: [{ type: 'text', text: JSON.stringify({ success: true, parent: safeParent, child: safeChild }, null, 2) }] };
2774
+ } catch (e) {
2775
+ return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: e.message }, null, 2) }], isError: true };
2776
+ }
2777
+ }
2778
+
2779
+ case 'rvf_segments': {
2780
+ try {
2781
+ const safePath = validateRvfPath(args.path);
2782
+ const { openRvfStore, rvfClose } = require('../dist/core/rvf-wrapper.js');
2783
+ const store = await openRvfStore(safePath);
2784
+ const segs = await store.segments();
2785
+ await rvfClose(store);
2786
+ return { content: [{ type: 'text', text: JSON.stringify({ success: true, segments: segs }, null, 2) }] };
2787
+ } catch (e) {
2788
+ return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: e.message }, null, 2) }], isError: true };
2789
+ }
2790
+ }
2791
+
2792
+ case 'rvf_examples': {
2793
+ const BASE_URL = 'https://raw.githubusercontent.com/ruvnet/ruvector/main/examples/rvf/output';
2794
+ const examples = [
2795
+ { name: 'basic_store', size: '152 KB', desc: '1,000 vectors, dim 128' },
2796
+ { name: 'semantic_search', size: '755 KB', desc: 'Semantic search with HNSW' },
2797
+ { name: 'rag_pipeline', size: '303 KB', desc: 'RAG pipeline embeddings' },
2798
+ { name: 'agent_memory', size: '32 KB', desc: 'AI agent episodic memory' },
2799
+ { name: 'swarm_knowledge', size: '86 KB', desc: 'Multi-agent knowledge base' },
2800
+ { name: 'self_booting', size: '31 KB', desc: 'Self-booting with kernel' },
2801
+ { name: 'ebpf_accelerator', size: '153 KB', desc: 'eBPF distance accelerator' },
2802
+ { name: 'tee_attestation', size: '102 KB', desc: 'TEE attestation + witnesses' },
2803
+ { name: 'lineage_parent', size: '52 KB', desc: 'COW parent file' },
2804
+ { name: 'lineage_child', size: '26 KB', desc: 'COW child (derived)' },
2805
+ { name: 'claude_code_appliance', size: '17 KB', desc: 'Claude Code appliance' },
2806
+ { name: 'progressive_index', size: '2.5 MB', desc: 'Large-scale HNSW index' },
2807
+ ];
2808
+ let filtered = examples;
2809
+ if (args.filter) {
2810
+ const f = args.filter.toLowerCase();
2811
+ filtered = examples.filter(e => e.name.includes(f) || e.desc.toLowerCase().includes(f));
2812
+ }
2813
+ return { content: [{ type: 'text', text: JSON.stringify({
2814
+ success: true,
2815
+ total: 45,
2816
+ shown: filtered.length,
2817
+ examples: filtered.map(e => ({ ...e, url: `${BASE_URL}/${e.name}.rvf` })),
2818
+ catalog: 'https://github.com/ruvnet/ruvector/tree/main/examples/rvf/output'
2819
+ }, null, 2) }] };
2820
+ }
2821
+
2822
+ // ── rvlite Query Tool Handlers ──────────────────────────────────────
2823
+ case 'rvlite_sql': {
2824
+ try {
2825
+ let rvlite;
2826
+ try {
2827
+ rvlite = require('rvlite');
2828
+ } catch (_e) {
2829
+ return { content: [{ type: 'text', text: JSON.stringify({
2830
+ success: false,
2831
+ error: 'rvlite package not installed',
2832
+ hint: 'Install with: npm install rvlite'
2833
+ }, null, 2) }] };
2834
+ }
2835
+ const safeQuery = sanitizeShellArg(args.query);
2836
+ const dbOpts = args.db_path ? { path: validateRvfPath(args.db_path) } : {};
2837
+ const db = new rvlite.Database(dbOpts);
2838
+ const results = db.sql(safeQuery);
2839
+ return { content: [{ type: 'text', text: JSON.stringify({
2840
+ success: true,
2841
+ query_type: 'sql',
2842
+ results,
2843
+ row_count: Array.isArray(results) ? results.length : 0
2844
+ }, null, 2) }] };
2845
+ } catch (e) {
2846
+ return { content: [{ type: 'text', text: JSON.stringify({
2847
+ success: false,
2848
+ error: e.message
2849
+ }, null, 2) }], isError: true };
2850
+ }
2851
+ }
2852
+
2853
+ case 'rvlite_cypher': {
2854
+ try {
2855
+ let rvlite;
2856
+ try {
2857
+ rvlite = require('rvlite');
2858
+ } catch (_e) {
2859
+ return { content: [{ type: 'text', text: JSON.stringify({
2860
+ success: false,
2861
+ error: 'rvlite package not installed',
2862
+ hint: 'Install with: npm install rvlite'
2863
+ }, null, 2) }] };
2864
+ }
2865
+ const safeQuery = sanitizeShellArg(args.query);
2866
+ const dbOpts = args.db_path ? { path: validateRvfPath(args.db_path) } : {};
2867
+ const db = new rvlite.Database(dbOpts);
2868
+ const results = db.cypher(safeQuery);
2869
+ return { content: [{ type: 'text', text: JSON.stringify({
2870
+ success: true,
2871
+ query_type: 'cypher',
2872
+ results,
2873
+ row_count: Array.isArray(results) ? results.length : 0
2874
+ }, null, 2) }] };
2875
+ } catch (e) {
2876
+ return { content: [{ type: 'text', text: JSON.stringify({
2877
+ success: false,
2878
+ error: e.message
2879
+ }, null, 2) }], isError: true };
2880
+ }
2881
+ }
2882
+
2883
+ case 'rvlite_sparql': {
2884
+ try {
2885
+ let rvlite;
2886
+ try {
2887
+ rvlite = require('rvlite');
2888
+ } catch (_e) {
2889
+ return { content: [{ type: 'text', text: JSON.stringify({
2890
+ success: false,
2891
+ error: 'rvlite package not installed',
2892
+ hint: 'Install with: npm install rvlite'
2893
+ }, null, 2) }] };
2894
+ }
2895
+ const safeQuery = sanitizeShellArg(args.query);
2896
+ const dbOpts = args.db_path ? { path: validateRvfPath(args.db_path) } : {};
2897
+ const db = new rvlite.Database(dbOpts);
2898
+ const results = db.sparql(safeQuery);
2899
+ return { content: [{ type: 'text', text: JSON.stringify({
2900
+ success: true,
2901
+ query_type: 'sparql',
2902
+ results,
2903
+ row_count: Array.isArray(results) ? results.length : 0
2904
+ }, null, 2) }] };
2905
+ } catch (e) {
2906
+ return { content: [{ type: 'text', text: JSON.stringify({
2907
+ success: false,
2908
+ error: e.message
2909
+ }, null, 2) }], isError: true };
2910
+ }
2911
+ }
2912
+
2471
2913
  default:
2472
2914
  return {
2473
2915
  content: [{
@@ -25,6 +25,7 @@ export * from './learning-engine';
25
25
  export * from './adaptive-embedder';
26
26
  export * from './neural-embeddings';
27
27
  export * from './neural-perf';
28
+ export * from './rvf-wrapper';
28
29
  export * from '../analysis';
29
30
  export { default as gnnWrapper } from './gnn-wrapper';
30
31
  export { default as attentionFallbacks } from './attention-fallbacks';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,c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O,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;AAC/D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AAGrD,OAAO,EAAE,UAAU,IAAI,SAAS,EAAE,MAAM,cAAc,CAAC;AAGvD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,qBAAqB,CAAC"}
@@ -45,6 +45,7 @@ __exportStar(require("./learning-engine"), exports);
45
45
  __exportStar(require("./adaptive-embedder"), exports);
46
46
  __exportStar(require("./neural-embeddings"), exports);
47
47
  __exportStar(require("./neural-perf"), exports);
48
+ __exportStar(require("./rvf-wrapper"), exports);
48
49
  // Analysis module (consolidated security, complexity, patterns)
49
50
  __exportStar(require("../analysis"), exports);
50
51
  // Re-export default objects for convenience