ruvector 0.2.0 → 0.2.1
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/cli.js +688 -598
- package/bin/mcp-server.js +272 -1
- package/package.json +7 -7
package/bin/mcp-server.js
CHANGED
|
@@ -363,7 +363,7 @@ class Intelligence {
|
|
|
363
363
|
const server = new Server(
|
|
364
364
|
{
|
|
365
365
|
name: 'ruvector',
|
|
366
|
-
version: '0.1
|
|
366
|
+
version: '0.2.1',
|
|
367
367
|
},
|
|
368
368
|
{
|
|
369
369
|
capabilities: {
|
|
@@ -1269,6 +1269,185 @@ const TOOLS = [
|
|
|
1269
1269
|
},
|
|
1270
1270
|
required: ['query']
|
|
1271
1271
|
}
|
|
1272
|
+
},
|
|
1273
|
+
// ── Brain Tools (11) ── Shared intelligence via @ruvector/pi-brain ──
|
|
1274
|
+
{
|
|
1275
|
+
name: 'brain_search',
|
|
1276
|
+
description: 'Semantic search across shared brain knowledge',
|
|
1277
|
+
inputSchema: {
|
|
1278
|
+
type: 'object',
|
|
1279
|
+
properties: {
|
|
1280
|
+
query: { type: 'string', description: 'Search query' },
|
|
1281
|
+
category: { type: 'string', description: 'Filter by category (pattern, solution, architecture, convention, security, performance, tooling)' },
|
|
1282
|
+
limit: { type: 'number', description: 'Max results (default 10)' }
|
|
1283
|
+
},
|
|
1284
|
+
required: ['query']
|
|
1285
|
+
}
|
|
1286
|
+
},
|
|
1287
|
+
{
|
|
1288
|
+
name: 'brain_share',
|
|
1289
|
+
description: 'Share a learning or pattern with the collective brain',
|
|
1290
|
+
inputSchema: {
|
|
1291
|
+
type: 'object',
|
|
1292
|
+
properties: {
|
|
1293
|
+
title: { type: 'string', description: 'Title of the knowledge entry' },
|
|
1294
|
+
content: { type: 'string', description: 'Content/description of the knowledge' },
|
|
1295
|
+
category: { type: 'string', description: 'Category (pattern, solution, architecture, convention, security, performance, tooling)' },
|
|
1296
|
+
tags: { type: 'string', description: 'Comma-separated tags' },
|
|
1297
|
+
code_snippet: { type: 'string', description: 'Optional code snippet' }
|
|
1298
|
+
},
|
|
1299
|
+
required: ['title', 'content', 'category']
|
|
1300
|
+
}
|
|
1301
|
+
},
|
|
1302
|
+
{
|
|
1303
|
+
name: 'brain_get',
|
|
1304
|
+
description: 'Retrieve a specific memory by ID with full provenance',
|
|
1305
|
+
inputSchema: {
|
|
1306
|
+
type: 'object',
|
|
1307
|
+
properties: {
|
|
1308
|
+
id: { type: 'string', description: 'Memory ID' }
|
|
1309
|
+
},
|
|
1310
|
+
required: ['id']
|
|
1311
|
+
}
|
|
1312
|
+
},
|
|
1313
|
+
{
|
|
1314
|
+
name: 'brain_vote',
|
|
1315
|
+
description: 'Quality-gate a memory with an up or down vote',
|
|
1316
|
+
inputSchema: {
|
|
1317
|
+
type: 'object',
|
|
1318
|
+
properties: {
|
|
1319
|
+
id: { type: 'string', description: 'Memory ID' },
|
|
1320
|
+
direction: { type: 'string', description: 'Vote direction: up or down' }
|
|
1321
|
+
},
|
|
1322
|
+
required: ['id', 'direction']
|
|
1323
|
+
}
|
|
1324
|
+
},
|
|
1325
|
+
{
|
|
1326
|
+
name: 'brain_list',
|
|
1327
|
+
description: 'List recent shared memories filtered by category or quality',
|
|
1328
|
+
inputSchema: {
|
|
1329
|
+
type: 'object',
|
|
1330
|
+
properties: {
|
|
1331
|
+
category: { type: 'string', description: 'Filter by category' },
|
|
1332
|
+
limit: { type: 'number', description: 'Max results (default 20)' }
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
},
|
|
1336
|
+
{
|
|
1337
|
+
name: 'brain_delete',
|
|
1338
|
+
description: 'Delete your own contribution from the shared brain',
|
|
1339
|
+
inputSchema: {
|
|
1340
|
+
type: 'object',
|
|
1341
|
+
properties: {
|
|
1342
|
+
id: { type: 'string', description: 'Memory ID to delete' }
|
|
1343
|
+
},
|
|
1344
|
+
required: ['id']
|
|
1345
|
+
}
|
|
1346
|
+
},
|
|
1347
|
+
{
|
|
1348
|
+
name: 'brain_status',
|
|
1349
|
+
description: 'Get shared brain system health: counts, drift, quality, graph topology',
|
|
1350
|
+
inputSchema: {
|
|
1351
|
+
type: 'object',
|
|
1352
|
+
properties: {}
|
|
1353
|
+
}
|
|
1354
|
+
},
|
|
1355
|
+
{
|
|
1356
|
+
name: 'brain_drift',
|
|
1357
|
+
description: 'Check if shared knowledge has drifted from local state',
|
|
1358
|
+
inputSchema: {
|
|
1359
|
+
type: 'object',
|
|
1360
|
+
properties: {
|
|
1361
|
+
domain: { type: 'string', description: 'Domain to check drift for' }
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
},
|
|
1365
|
+
{
|
|
1366
|
+
name: 'brain_partition',
|
|
1367
|
+
description: 'Get knowledge partitioned by mincut topology into clusters',
|
|
1368
|
+
inputSchema: {
|
|
1369
|
+
type: 'object',
|
|
1370
|
+
properties: {
|
|
1371
|
+
domain: { type: 'string', description: 'Domain to partition' },
|
|
1372
|
+
min_cluster_size: { type: 'number', description: 'Minimum cluster size (default 3)' }
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
},
|
|
1376
|
+
{
|
|
1377
|
+
name: 'brain_transfer',
|
|
1378
|
+
description: 'Apply learned priors from one knowledge domain to another',
|
|
1379
|
+
inputSchema: {
|
|
1380
|
+
type: 'object',
|
|
1381
|
+
properties: {
|
|
1382
|
+
source_domain: { type: 'string', description: 'Source domain to transfer from' },
|
|
1383
|
+
target_domain: { type: 'string', description: 'Target domain to transfer to' }
|
|
1384
|
+
},
|
|
1385
|
+
required: ['source_domain', 'target_domain']
|
|
1386
|
+
}
|
|
1387
|
+
},
|
|
1388
|
+
{
|
|
1389
|
+
name: 'brain_sync',
|
|
1390
|
+
description: 'Synchronize LoRA weights between local and shared brain',
|
|
1391
|
+
inputSchema: {
|
|
1392
|
+
type: 'object',
|
|
1393
|
+
properties: {
|
|
1394
|
+
direction: { type: 'string', description: 'Sync direction: pull, push, or both (default both)' }
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
},
|
|
1398
|
+
// ── Edge Tools (4) ── Distributed compute via @ruvector/edge-net ──
|
|
1399
|
+
{
|
|
1400
|
+
name: 'edge_status',
|
|
1401
|
+
description: 'Get edge compute network status (genesis, relay, nodes, rUv supply)',
|
|
1402
|
+
inputSchema: {
|
|
1403
|
+
type: 'object',
|
|
1404
|
+
properties: {}
|
|
1405
|
+
}
|
|
1406
|
+
},
|
|
1407
|
+
{
|
|
1408
|
+
name: 'edge_join',
|
|
1409
|
+
description: 'Join the edge compute network as a compute node',
|
|
1410
|
+
inputSchema: {
|
|
1411
|
+
type: 'object',
|
|
1412
|
+
properties: {
|
|
1413
|
+
contribution: { type: 'number', description: 'Contribution level 0.0-1.0 (default 0.3)' }
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
},
|
|
1417
|
+
{
|
|
1418
|
+
name: 'edge_balance',
|
|
1419
|
+
description: 'Check rUv credit balance for current identity',
|
|
1420
|
+
inputSchema: {
|
|
1421
|
+
type: 'object',
|
|
1422
|
+
properties: {}
|
|
1423
|
+
}
|
|
1424
|
+
},
|
|
1425
|
+
{
|
|
1426
|
+
name: 'edge_tasks',
|
|
1427
|
+
description: 'List available distributed compute tasks on the edge network',
|
|
1428
|
+
inputSchema: {
|
|
1429
|
+
type: 'object',
|
|
1430
|
+
properties: {
|
|
1431
|
+
limit: { type: 'number', description: 'Max tasks to return (default 20)' }
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
},
|
|
1435
|
+
// ── Identity Tools (2) ── Pi key management ──
|
|
1436
|
+
{
|
|
1437
|
+
name: 'identity_generate',
|
|
1438
|
+
description: 'Generate a new pi key and derive pseudonym',
|
|
1439
|
+
inputSchema: {
|
|
1440
|
+
type: 'object',
|
|
1441
|
+
properties: {}
|
|
1442
|
+
}
|
|
1443
|
+
},
|
|
1444
|
+
{
|
|
1445
|
+
name: 'identity_show',
|
|
1446
|
+
description: 'Show current pi key pseudonym and derived identities',
|
|
1447
|
+
inputSchema: {
|
|
1448
|
+
type: 'object',
|
|
1449
|
+
properties: {}
|
|
1450
|
+
}
|
|
1272
1451
|
}
|
|
1273
1452
|
];
|
|
1274
1453
|
|
|
@@ -2963,6 +3142,98 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
2963
3142
|
}
|
|
2964
3143
|
}
|
|
2965
3144
|
|
|
3145
|
+
// ── Brain Tool Handlers ──────────────────────────────────────────────
|
|
3146
|
+
case 'brain_search':
|
|
3147
|
+
case 'brain_share':
|
|
3148
|
+
case 'brain_get':
|
|
3149
|
+
case 'brain_vote':
|
|
3150
|
+
case 'brain_list':
|
|
3151
|
+
case 'brain_delete':
|
|
3152
|
+
case 'brain_status':
|
|
3153
|
+
case 'brain_drift':
|
|
3154
|
+
case 'brain_partition':
|
|
3155
|
+
case 'brain_transfer':
|
|
3156
|
+
case 'brain_sync': {
|
|
3157
|
+
try {
|
|
3158
|
+
const { PiBrainClient } = require('@ruvector/pi-brain');
|
|
3159
|
+
const client = new PiBrainClient({
|
|
3160
|
+
url: process.env.BRAIN_URL || 'https://pi.ruv.io',
|
|
3161
|
+
key: process.env.PI
|
|
3162
|
+
});
|
|
3163
|
+
const subCmd = name.replace('brain_', '');
|
|
3164
|
+
let result;
|
|
3165
|
+
switch (subCmd) {
|
|
3166
|
+
case 'search': result = await client.search(args.query, { category: args.category, limit: args.limit || 10 }); break;
|
|
3167
|
+
case 'share': result = await client.share({ title: args.title, content: args.content, category: args.category, tags: args.tags ? args.tags.split(',').map(t => t.trim()) : [], code_snippet: args.code_snippet }); break;
|
|
3168
|
+
case 'get': result = await client.get(args.id); break;
|
|
3169
|
+
case 'vote': result = await client.vote(args.id, args.direction); break;
|
|
3170
|
+
case 'list': result = await client.list({ category: args.category, limit: args.limit || 20 }); break;
|
|
3171
|
+
case 'delete': result = await client.delete(args.id); break;
|
|
3172
|
+
case 'status': result = await client.status(); break;
|
|
3173
|
+
case 'drift': result = await client.drift({ domain: args.domain }); break;
|
|
3174
|
+
case 'partition': result = await client.partition({ domain: args.domain, min_cluster_size: args.min_cluster_size }); break;
|
|
3175
|
+
case 'transfer': result = await client.transfer(args.source_domain, args.target_domain); break;
|
|
3176
|
+
case 'sync': result = await client.sync(args.direction || 'both'); break;
|
|
3177
|
+
}
|
|
3178
|
+
return { content: [{ type: 'text', text: JSON.stringify({ success: true, ...result }, null, 2) }] };
|
|
3179
|
+
} catch (e) {
|
|
3180
|
+
if (e.code === 'MODULE_NOT_FOUND') {
|
|
3181
|
+
return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: 'Brain tools require @ruvector/pi-brain. Install with: npm install @ruvector/pi-brain' }, null, 2) }], isError: true };
|
|
3182
|
+
}
|
|
3183
|
+
return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: e.message }, null, 2) }], isError: true };
|
|
3184
|
+
}
|
|
3185
|
+
}
|
|
3186
|
+
|
|
3187
|
+
// ── Edge Tool Handlers ───────────────────────────────────────────────
|
|
3188
|
+
case 'edge_status':
|
|
3189
|
+
case 'edge_join':
|
|
3190
|
+
case 'edge_balance':
|
|
3191
|
+
case 'edge_tasks': {
|
|
3192
|
+
try {
|
|
3193
|
+
const genesisUrl = process.env.EDGE_GENESIS_URL || 'https://edge-net-genesis-875130704813.us-central1.run.app';
|
|
3194
|
+
const subCmd = name.replace('edge_', '');
|
|
3195
|
+
let endpoint, method = 'GET', body;
|
|
3196
|
+
switch (subCmd) {
|
|
3197
|
+
case 'status': endpoint = '/status'; break;
|
|
3198
|
+
case 'join': endpoint = '/join'; method = 'POST'; body = JSON.stringify({ contribution: args.contribution || 0.3, pi_key: process.env.PI }); break;
|
|
3199
|
+
case 'balance': endpoint = `/balance/${process.env.PI || 'anonymous'}`; break;
|
|
3200
|
+
case 'tasks': endpoint = `/tasks?limit=${args.limit || 20}`; break;
|
|
3201
|
+
}
|
|
3202
|
+
const resp = await fetch(`${genesisUrl}${endpoint}`, {
|
|
3203
|
+
method,
|
|
3204
|
+
headers: { 'Content-Type': 'application/json', ...(process.env.PI ? { 'Authorization': `Bearer ${process.env.PI}` } : {}) },
|
|
3205
|
+
...(body ? { body } : {})
|
|
3206
|
+
});
|
|
3207
|
+
const data = await resp.json();
|
|
3208
|
+
return { content: [{ type: 'text', text: JSON.stringify({ success: true, ...data }, null, 2) }] };
|
|
3209
|
+
} catch (e) {
|
|
3210
|
+
return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: e.message }, null, 2) }], isError: true };
|
|
3211
|
+
}
|
|
3212
|
+
}
|
|
3213
|
+
|
|
3214
|
+
// ── Identity Tool Handlers ───────────────────────────────────────────
|
|
3215
|
+
case 'identity_generate': {
|
|
3216
|
+
const crypto = require('crypto');
|
|
3217
|
+
const key = crypto.randomBytes(32).toString('hex');
|
|
3218
|
+
const hash = crypto.createHash('shake256', { outputLength: 16 });
|
|
3219
|
+
hash.update(key);
|
|
3220
|
+
const pseudonym = hash.digest('hex');
|
|
3221
|
+
return { content: [{ type: 'text', text: JSON.stringify({ success: true, pi_key: key, pseudonym, warning: 'Store this key securely. Set PI env var to use it.' }, null, 2) }] };
|
|
3222
|
+
}
|
|
3223
|
+
|
|
3224
|
+
case 'identity_show': {
|
|
3225
|
+
const piKey = process.env.PI;
|
|
3226
|
+
if (!piKey) {
|
|
3227
|
+
return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: 'No PI environment variable set. Run identity_generate first.' }, null, 2) }], isError: true };
|
|
3228
|
+
}
|
|
3229
|
+
const crypto = require('crypto');
|
|
3230
|
+
const hash = crypto.createHash('shake256', { outputLength: 16 });
|
|
3231
|
+
hash.update(piKey);
|
|
3232
|
+
const pseudonym = hash.digest('hex');
|
|
3233
|
+
const mcpToken = crypto.createHmac('sha256', piKey).update('mcp').digest('hex').slice(0, 32);
|
|
3234
|
+
return { content: [{ type: 'text', text: JSON.stringify({ success: true, pseudonym, mcp_token: mcpToken, key_prefix: piKey.slice(0, 8) + '...' }, null, 2) }] };
|
|
3235
|
+
}
|
|
3236
|
+
|
|
2966
3237
|
default:
|
|
2967
3238
|
return {
|
|
2968
3239
|
content: [{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ruvector",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
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",
|
|
@@ -79,12 +79,6 @@
|
|
|
79
79
|
"@types/node": "^20.10.5",
|
|
80
80
|
"typescript": "^5.3.3"
|
|
81
81
|
},
|
|
82
|
-
"files": [
|
|
83
|
-
"bin/",
|
|
84
|
-
"dist/",
|
|
85
|
-
"README.md",
|
|
86
|
-
"LICENSE"
|
|
87
|
-
],
|
|
88
82
|
"peerDependencies": {
|
|
89
83
|
"@ruvector/pi-brain": ">=0.1.0",
|
|
90
84
|
"@ruvector/ruvllm": ">=2.0.0",
|
|
@@ -95,6 +89,12 @@
|
|
|
95
89
|
"@ruvector/ruvllm": { "optional": true },
|
|
96
90
|
"@ruvector/router": { "optional": true }
|
|
97
91
|
},
|
|
92
|
+
"files": [
|
|
93
|
+
"bin/",
|
|
94
|
+
"dist/",
|
|
95
|
+
"README.md",
|
|
96
|
+
"LICENSE"
|
|
97
|
+
],
|
|
98
98
|
"engines": {
|
|
99
99
|
"node": ">=18.0.0"
|
|
100
100
|
}
|