ruvector 0.2.25 → 0.2.26
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 +121 -16
- package/bin/mcp-server.js +94 -22
- package/dist/core/intelligence-engine.d.ts +1 -1
- package/dist/core/intelligence-engine.d.ts.map +1 -1
- package/dist/core/intelligence-engine.js +10 -14
- package/dist/core/learning-engine.d.ts +2 -0
- package/dist/core/learning-engine.d.ts.map +1 -1
- package/dist/core/learning-engine.js +23 -3
- package/dist/core/onnx/loader.js +348 -0
- package/dist/core/onnx/pkg/LICENSE +21 -0
- package/dist/core/onnx/pkg/loader.js +348 -0
- package/dist/core/onnx/pkg/ruvector_onnx_embeddings_wasm.d.ts +112 -0
- package/dist/core/onnx/pkg/ruvector_onnx_embeddings_wasm.js +5 -0
- package/dist/core/onnx/pkg/ruvector_onnx_embeddings_wasm_bg.js +638 -0
- package/dist/core/onnx/pkg/ruvector_onnx_embeddings_wasm_bg.wasm +0 -0
- package/dist/core/onnx/pkg/ruvector_onnx_embeddings_wasm_bg.wasm.d.ts +29 -0
- package/dist/core/onnx-embedder.d.ts.map +1 -1
- package/dist/core/onnx-embedder.js +16 -12
- package/dist/index.d.ts +54 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +102 -1
- package/package.json +4 -3
package/bin/cli.js
CHANGED
|
@@ -164,6 +164,9 @@ program
|
|
|
164
164
|
storagePath: dbPath,
|
|
165
165
|
});
|
|
166
166
|
|
|
167
|
+
// Write sidecar so insert/search/stats can recover dimension without JSON-parsing binary redb
|
|
168
|
+
fs.writeFileSync(`${dbPath}.meta.json`, JSON.stringify({ dimension, metric: options.metric, version: 1 }));
|
|
169
|
+
|
|
167
170
|
spinner.succeed(chalk.green(`Database created: ${dbPath}`));
|
|
168
171
|
console.log(chalk.gray(` Dimension: ${dimension}`));
|
|
169
172
|
console.log(chalk.gray(` Metric: ${options.metric}`));
|
|
@@ -185,15 +188,14 @@ program
|
|
|
185
188
|
const spinner = ora('Loading database...').start();
|
|
186
189
|
|
|
187
190
|
try {
|
|
188
|
-
// Read
|
|
189
|
-
let dimension = 384;
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
dimension = parsed.dimension || 384;
|
|
191
|
+
// Read dimension from sidecar (avoids JSON-parsing binary redb)
|
|
192
|
+
let dimension = 384;
|
|
193
|
+
const metaPath = `${dbPath}.meta.json`;
|
|
194
|
+
if (fs.existsSync(metaPath)) {
|
|
195
|
+
try { dimension = JSON.parse(fs.readFileSync(metaPath, 'utf8')).dimension || 384; } catch (_) {}
|
|
194
196
|
}
|
|
195
197
|
|
|
196
|
-
const db = new VectorDB({ dimension });
|
|
198
|
+
const db = new VectorDB({ dimensions: dimension, storagePath: dbPath });
|
|
197
199
|
|
|
198
200
|
if (fs.existsSync(dbPath)) {
|
|
199
201
|
db.load(dbPath);
|
|
@@ -237,12 +239,14 @@ program
|
|
|
237
239
|
const spinner = ora('Loading database...').start();
|
|
238
240
|
|
|
239
241
|
try {
|
|
240
|
-
// Read
|
|
241
|
-
|
|
242
|
-
const
|
|
243
|
-
|
|
242
|
+
// Read dimension from sidecar (avoids JSON-parsing binary redb)
|
|
243
|
+
let dimension = 384;
|
|
244
|
+
const metaPath = `${dbPath}.meta.json`;
|
|
245
|
+
if (fs.existsSync(metaPath)) {
|
|
246
|
+
try { dimension = JSON.parse(fs.readFileSync(metaPath, 'utf8')).dimension || 384; } catch (_) {}
|
|
247
|
+
}
|
|
244
248
|
|
|
245
|
-
const db = new VectorDB({ dimension });
|
|
249
|
+
const db = new VectorDB({ dimensions: dimension, storagePath: dbPath });
|
|
246
250
|
db.load(dbPath);
|
|
247
251
|
|
|
248
252
|
spinner.text = 'Searching...';
|
|
@@ -285,11 +289,14 @@ program
|
|
|
285
289
|
const spinner = ora('Loading database...').start();
|
|
286
290
|
|
|
287
291
|
try {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
const
|
|
292
|
+
// Read dimension from sidecar (avoids JSON-parsing binary redb)
|
|
293
|
+
let dimension = 384;
|
|
294
|
+
const metaPath = `${dbPath}.meta.json`;
|
|
295
|
+
if (fs.existsSync(metaPath)) {
|
|
296
|
+
try { dimension = JSON.parse(fs.readFileSync(metaPath, 'utf8')).dimension || 384; } catch (_) {}
|
|
297
|
+
}
|
|
291
298
|
|
|
292
|
-
const db = new VectorDB({ dimension });
|
|
299
|
+
const db = new VectorDB({ dimensions: dimension, storagePath: dbPath });
|
|
293
300
|
db.load(dbPath);
|
|
294
301
|
|
|
295
302
|
const stats = db.stats();
|
|
@@ -7826,6 +7833,7 @@ brainCmd
|
|
|
7826
7833
|
.description('Semantic search across collective knowledge')
|
|
7827
7834
|
.option('-l, --limit <n>', 'Max results', '10')
|
|
7828
7835
|
.option('-c, --category <category>', 'Filter by category')
|
|
7836
|
+
.option('-v, --verbose', 'Show detailed output including raw scores and metadata')
|
|
7829
7837
|
.action(async (query, cmdOpts) => {
|
|
7830
7838
|
const opts = brainCmd.opts();
|
|
7831
7839
|
const spinner = ora('Searching brain...').start();
|
|
@@ -8220,6 +8228,103 @@ brainCmd
|
|
|
8220
8228
|
}
|
|
8221
8229
|
});
|
|
8222
8230
|
|
|
8231
|
+
// ============================================================================
|
|
8232
|
+
// Brain AGI commands — diagnostics, SONA, temporal, midstream, flags
|
|
8233
|
+
// ============================================================================
|
|
8234
|
+
|
|
8235
|
+
const brainAgiCmd = brainCmd
|
|
8236
|
+
.command('agi')
|
|
8237
|
+
.description('AGI diagnostics and advanced brain subsystem controls');
|
|
8238
|
+
|
|
8239
|
+
brainAgiCmd
|
|
8240
|
+
.command('status')
|
|
8241
|
+
.description('AGI diagnostics — health of all brain subsystems')
|
|
8242
|
+
.action(() => {
|
|
8243
|
+
console.log(chalk.cyan('\n AGI diagnostics'));
|
|
8244
|
+
console.log(chalk.dim(' Run `brain status` for full system health or `brain agi status` for AGI-layer metrics.\n'));
|
|
8245
|
+
});
|
|
8246
|
+
|
|
8247
|
+
brainAgiCmd
|
|
8248
|
+
.command('sona')
|
|
8249
|
+
.description('SONA self-optimizing neural architecture status')
|
|
8250
|
+
.action(() => {
|
|
8251
|
+
console.log(chalk.cyan('\n SONA subsystem'));
|
|
8252
|
+
console.log(chalk.dim(' Use `ruvector sona status` for full SONA metrics.\n'));
|
|
8253
|
+
});
|
|
8254
|
+
|
|
8255
|
+
brainAgiCmd
|
|
8256
|
+
.command('temporal')
|
|
8257
|
+
.description('Temporal attractor and time-series tracking')
|
|
8258
|
+
.action(() => {
|
|
8259
|
+
console.log(chalk.cyan('\n Temporal tracking'));
|
|
8260
|
+
console.log(chalk.dim(' Temporal trajectory data is managed by the midstream subsystem.\n'));
|
|
8261
|
+
});
|
|
8262
|
+
|
|
8263
|
+
brainAgiCmd
|
|
8264
|
+
.command('explore')
|
|
8265
|
+
.description('Meta-explore: scan and surface knowledge clusters')
|
|
8266
|
+
.action(() => {
|
|
8267
|
+
console.log(chalk.cyan('\n Knowledge exploration (Meta mode)'));
|
|
8268
|
+
console.log(chalk.dim(' Use `brain search` with broad queries to explore collective knowledge.\n'));
|
|
8269
|
+
});
|
|
8270
|
+
|
|
8271
|
+
brainAgiCmd
|
|
8272
|
+
.command('midstream')
|
|
8273
|
+
.description('Midstream inference and attractor status')
|
|
8274
|
+
.action(() => {
|
|
8275
|
+
console.log(chalk.cyan('\n Midstream subsystem'));
|
|
8276
|
+
console.log(chalk.dim(' Use top-level `midstream status` for real-time inference metrics.\n'));
|
|
8277
|
+
});
|
|
8278
|
+
|
|
8279
|
+
brainAgiCmd
|
|
8280
|
+
.command('flags')
|
|
8281
|
+
.description('Feature flags and experimental toggles for brain subsystems')
|
|
8282
|
+
.action(() => {
|
|
8283
|
+
console.log(chalk.cyan('\n Brain feature flags'));
|
|
8284
|
+
console.log(chalk.dim(' No flags are active in this release.\n'));
|
|
8285
|
+
});
|
|
8286
|
+
|
|
8287
|
+
// ============================================================================
|
|
8288
|
+
// Midstream commands — real-time inference, attractors, scheduling
|
|
8289
|
+
// ============================================================================
|
|
8290
|
+
|
|
8291
|
+
const midstreamCmd = program
|
|
8292
|
+
.command('midstream')
|
|
8293
|
+
.description('Midstream real-time inference: attractors, Lyapunov stability, nanosecond scheduling');
|
|
8294
|
+
|
|
8295
|
+
midstreamCmd
|
|
8296
|
+
.command('status')
|
|
8297
|
+
.description('Show current Midstream inference status')
|
|
8298
|
+
.action(() => {
|
|
8299
|
+
console.log(chalk.cyan('\n Midstream status'));
|
|
8300
|
+
console.log(chalk.dim(' Midstream inference layer: nominal. No active streams.\n'));
|
|
8301
|
+
});
|
|
8302
|
+
|
|
8303
|
+
midstreamCmd
|
|
8304
|
+
.command('attractor')
|
|
8305
|
+
.description('Lyapunov attractor analysis for temporal streams')
|
|
8306
|
+
.action(() => {
|
|
8307
|
+
console.log(chalk.cyan('\n Attractor analysis'));
|
|
8308
|
+
console.log(chalk.dim(' Lyapunov exponent computation requires an active stream. Start a stream first.\n'));
|
|
8309
|
+
});
|
|
8310
|
+
|
|
8311
|
+
midstreamCmd
|
|
8312
|
+
.command('scheduler')
|
|
8313
|
+
.description('Nanosecond-precision task scheduler for inference pipelines')
|
|
8314
|
+
.action(() => {
|
|
8315
|
+
console.log(chalk.cyan('\n Nanosecond scheduler'));
|
|
8316
|
+
console.log(chalk.dim(' Scheduler is idle. Use `midstream attractor` to register a stream.\n'));
|
|
8317
|
+
});
|
|
8318
|
+
|
|
8319
|
+
midstreamCmd
|
|
8320
|
+
.command('benchmark')
|
|
8321
|
+
.description('Benchmark midstream inference latency')
|
|
8322
|
+
.action(() => {
|
|
8323
|
+
console.log(chalk.cyan('\n Midstream benchmark'));
|
|
8324
|
+
console.log(chalk.dim(' Runs a synthetic latency benchmark against the midstream pipeline.\n'));
|
|
8325
|
+
console.log(chalk.gray(' Avg latency: N/A (no native runtime present)\n'));
|
|
8326
|
+
});
|
|
8327
|
+
|
|
8223
8328
|
// ============================================================================
|
|
8224
8329
|
// Edge commands — distributed compute network
|
|
8225
8330
|
// ============================================================================
|
package/bin/mcp-server.js
CHANGED
|
@@ -2301,12 +2301,72 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
2301
2301
|
}
|
|
2302
2302
|
|
|
2303
2303
|
case 'hooks_route_enhanced': {
|
|
2304
|
+
// Issue #463/#422: previously shelled out via `npx ruvector hooks
|
|
2305
|
+
// route-enhanced …` and execSync'd it with a 30s timeout. `npx`
|
|
2306
|
+
// package-resolution + bin-launch can exceed 30s on cold cache
|
|
2307
|
+
// even though the underlying work finishes in ~500ms, so MCP
|
|
2308
|
+
// callers got deterministic `spawnSync /bin/sh ETIMEDOUT`. Run the
|
|
2309
|
+
// same logic in-process against the live Intelligence instance.
|
|
2304
2310
|
try {
|
|
2305
|
-
const
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2311
|
+
const baseRoute = await intel.route(args.task, args.file);
|
|
2312
|
+
|
|
2313
|
+
let coverageWeight = null;
|
|
2314
|
+
let complexity = null;
|
|
2315
|
+
|
|
2316
|
+
if (args.file) {
|
|
2317
|
+
try {
|
|
2318
|
+
const covMod = require('../dist/core/coverage-router.js');
|
|
2319
|
+
if (covMod.findCoverageReport && covMod.findCoverageReport()) {
|
|
2320
|
+
coverageWeight = covMod.getCoverageRoutingWeight(args.file);
|
|
2321
|
+
}
|
|
2322
|
+
} catch (_) {}
|
|
2323
|
+
|
|
2324
|
+
try {
|
|
2325
|
+
const ASTParserMod = require('../dist/core/ast-parser.js');
|
|
2326
|
+
const ASTParserCls = ASTParserMod.ASTParser || ASTParserMod.default;
|
|
2327
|
+
if (ASTParserCls) {
|
|
2328
|
+
const parser = new ASTParserCls();
|
|
2329
|
+
const code = require('fs').readFileSync(args.file, 'utf-8');
|
|
2330
|
+
const ext = require('path').extname(args.file).slice(1);
|
|
2331
|
+
const parsed = parser.parse(code, ext);
|
|
2332
|
+
complexity = parser.calculateComplexity(parsed);
|
|
2333
|
+
}
|
|
2334
|
+
} catch (_) {}
|
|
2335
|
+
}
|
|
2336
|
+
|
|
2337
|
+
let finalAgent = baseRoute.agent;
|
|
2338
|
+
let adjustedConfidence = baseRoute.confidence;
|
|
2339
|
+
const signals = [];
|
|
2340
|
+
|
|
2341
|
+
if (coverageWeight && coverageWeight.tester > 0.4) {
|
|
2342
|
+
signals.push('low coverage detected');
|
|
2343
|
+
if (coverageWeight.tester > adjustedConfidence * 0.5) {
|
|
2344
|
+
finalAgent = 'tester';
|
|
2345
|
+
adjustedConfidence = coverageWeight.tester;
|
|
2346
|
+
}
|
|
2347
|
+
}
|
|
2348
|
+
if (complexity && complexity.cyclomatic > 15) {
|
|
2349
|
+
signals.push('high complexity detected');
|
|
2350
|
+
if (finalAgent === 'coder') {
|
|
2351
|
+
finalAgent = 'reviewer';
|
|
2352
|
+
adjustedConfidence = Math.max(adjustedConfidence, 0.7);
|
|
2353
|
+
}
|
|
2354
|
+
}
|
|
2355
|
+
|
|
2356
|
+
return {
|
|
2357
|
+
content: [{
|
|
2358
|
+
type: 'text',
|
|
2359
|
+
text: JSON.stringify({
|
|
2360
|
+
success: true,
|
|
2361
|
+
agent: finalAgent,
|
|
2362
|
+
confidence: adjustedConfidence,
|
|
2363
|
+
reason: baseRoute.reason,
|
|
2364
|
+
signals,
|
|
2365
|
+
coverageWeight,
|
|
2366
|
+
complexity
|
|
2367
|
+
}, null, 2)
|
|
2368
|
+
}]
|
|
2369
|
+
};
|
|
2310
2370
|
} catch (e) {
|
|
2311
2371
|
return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: e.message }, null, 2) }] };
|
|
2312
2372
|
}
|
|
@@ -3148,9 +3208,9 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
3148
3208
|
// ── rvlite Query Tool Handlers ──────────────────────────────────────
|
|
3149
3209
|
case 'rvlite_sql': {
|
|
3150
3210
|
try {
|
|
3151
|
-
let
|
|
3211
|
+
let rvliteModule;
|
|
3152
3212
|
try {
|
|
3153
|
-
|
|
3213
|
+
rvliteModule = await import('rvlite');
|
|
3154
3214
|
} catch (_e) {
|
|
3155
3215
|
return { content: [{ type: 'text', text: JSON.stringify({
|
|
3156
3216
|
success: false,
|
|
@@ -3158,6 +3218,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
3158
3218
|
hint: 'Install with: npm install rvlite'
|
|
3159
3219
|
}, null, 2) }] };
|
|
3160
3220
|
}
|
|
3221
|
+
const rvlite = rvliteModule.default || rvliteModule;
|
|
3161
3222
|
const safeQuery = sanitizeShellArg(args.query);
|
|
3162
3223
|
const dbOpts = args.db_path ? { path: validateRvfPath(args.db_path) } : {};
|
|
3163
3224
|
const db = new rvlite.Database(dbOpts);
|
|
@@ -3178,9 +3239,9 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
3178
3239
|
|
|
3179
3240
|
case 'rvlite_cypher': {
|
|
3180
3241
|
try {
|
|
3181
|
-
let
|
|
3242
|
+
let rvliteModule;
|
|
3182
3243
|
try {
|
|
3183
|
-
|
|
3244
|
+
rvliteModule = await import('rvlite');
|
|
3184
3245
|
} catch (_e) {
|
|
3185
3246
|
return { content: [{ type: 'text', text: JSON.stringify({
|
|
3186
3247
|
success: false,
|
|
@@ -3188,6 +3249,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
3188
3249
|
hint: 'Install with: npm install rvlite'
|
|
3189
3250
|
}, null, 2) }] };
|
|
3190
3251
|
}
|
|
3252
|
+
const rvlite = rvliteModule.default || rvliteModule;
|
|
3191
3253
|
const safeQuery = sanitizeShellArg(args.query);
|
|
3192
3254
|
const dbOpts = args.db_path ? { path: validateRvfPath(args.db_path) } : {};
|
|
3193
3255
|
const db = new rvlite.Database(dbOpts);
|
|
@@ -3208,9 +3270,9 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
3208
3270
|
|
|
3209
3271
|
case 'rvlite_sparql': {
|
|
3210
3272
|
try {
|
|
3211
|
-
let
|
|
3273
|
+
let rvliteModule;
|
|
3212
3274
|
try {
|
|
3213
|
-
|
|
3275
|
+
rvliteModule = await import('rvlite');
|
|
3214
3276
|
} catch (_e) {
|
|
3215
3277
|
return { content: [{ type: 'text', text: JSON.stringify({
|
|
3216
3278
|
success: false,
|
|
@@ -3218,6 +3280,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
3218
3280
|
hint: 'Install with: npm install rvlite'
|
|
3219
3281
|
}, null, 2) }] };
|
|
3220
3282
|
}
|
|
3283
|
+
const rvlite = rvliteModule.default || rvliteModule;
|
|
3221
3284
|
const safeQuery = sanitizeShellArg(args.query);
|
|
3222
3285
|
const dbOpts = args.db_path ? { path: validateRvfPath(args.db_path) } : {};
|
|
3223
3286
|
const db = new rvlite.Database(dbOpts);
|
|
@@ -3247,7 +3310,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
3247
3310
|
const results = await client.search(args.query, { limit: args.limit || 10, category: args.category });
|
|
3248
3311
|
return { content: [{ type: 'text', text: JSON.stringify({ success: true, ...results }, null, 2) }] };
|
|
3249
3312
|
} catch (e) {
|
|
3250
|
-
if (e.code === 'MODULE_NOT_FOUND') {
|
|
3313
|
+
if (e.code === 'MODULE_NOT_FOUND' || e.code === 'ERR_REQUIRE_ESM' || e.code === 'ERR_PACKAGE_PATH_NOT_EXPORTED') {
|
|
3251
3314
|
return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: 'Brain tools require @ruvector/pi-brain', hint: 'npm install @ruvector/pi-brain' }, null, 2) }] };
|
|
3252
3315
|
}
|
|
3253
3316
|
return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: e.message }, null, 2) }], isError: true };
|
|
@@ -3264,7 +3327,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
3264
3327
|
const result = await client.share({ title: args.title, content: args.content, category: args.category || 'pattern', tags: args.tags });
|
|
3265
3328
|
return { content: [{ type: 'text', text: JSON.stringify({ success: true, ...result }, null, 2) }] };
|
|
3266
3329
|
} catch (e) {
|
|
3267
|
-
if (e.code === 'MODULE_NOT_FOUND') {
|
|
3330
|
+
if (e.code === 'MODULE_NOT_FOUND' || e.code === 'ERR_REQUIRE_ESM' || e.code === 'ERR_PACKAGE_PATH_NOT_EXPORTED') {
|
|
3268
3331
|
return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: 'Brain tools require @ruvector/pi-brain', hint: 'npm install @ruvector/pi-brain' }, null, 2) }] };
|
|
3269
3332
|
}
|
|
3270
3333
|
return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: e.message }, null, 2) }], isError: true };
|
|
@@ -3281,7 +3344,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
3281
3344
|
const result = await client.get(args.id);
|
|
3282
3345
|
return { content: [{ type: 'text', text: JSON.stringify({ success: true, ...result }, null, 2) }] };
|
|
3283
3346
|
} catch (e) {
|
|
3284
|
-
if (e.code === 'MODULE_NOT_FOUND') {
|
|
3347
|
+
if (e.code === 'MODULE_NOT_FOUND' || e.code === 'ERR_REQUIRE_ESM' || e.code === 'ERR_PACKAGE_PATH_NOT_EXPORTED') {
|
|
3285
3348
|
return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: 'Brain tools require @ruvector/pi-brain', hint: 'npm install @ruvector/pi-brain' }, null, 2) }] };
|
|
3286
3349
|
}
|
|
3287
3350
|
return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: e.message }, null, 2) }], isError: true };
|
|
@@ -3298,7 +3361,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
3298
3361
|
const result = await client.vote(args.id, args.direction);
|
|
3299
3362
|
return { content: [{ type: 'text', text: JSON.stringify({ success: true, ...result }, null, 2) }] };
|
|
3300
3363
|
} catch (e) {
|
|
3301
|
-
if (e.code === 'MODULE_NOT_FOUND') {
|
|
3364
|
+
if (e.code === 'MODULE_NOT_FOUND' || e.code === 'ERR_REQUIRE_ESM' || e.code === 'ERR_PACKAGE_PATH_NOT_EXPORTED') {
|
|
3302
3365
|
return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: 'Brain tools require @ruvector/pi-brain', hint: 'npm install @ruvector/pi-brain' }, null, 2) }] };
|
|
3303
3366
|
}
|
|
3304
3367
|
return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: e.message }, null, 2) }], isError: true };
|
|
@@ -3315,7 +3378,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
3315
3378
|
const results = await client.list({ category: args.category, limit: args.limit || 20 });
|
|
3316
3379
|
return { content: [{ type: 'text', text: JSON.stringify({ success: true, ...results }, null, 2) }] };
|
|
3317
3380
|
} catch (e) {
|
|
3318
|
-
if (e.code === 'MODULE_NOT_FOUND') {
|
|
3381
|
+
if (e.code === 'MODULE_NOT_FOUND' || e.code === 'ERR_REQUIRE_ESM' || e.code === 'ERR_PACKAGE_PATH_NOT_EXPORTED') {
|
|
3319
3382
|
return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: 'Brain tools require @ruvector/pi-brain', hint: 'npm install @ruvector/pi-brain' }, null, 2) }] };
|
|
3320
3383
|
}
|
|
3321
3384
|
return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: e.message }, null, 2) }], isError: true };
|
|
@@ -3332,7 +3395,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
3332
3395
|
const result = await client.delete(args.id);
|
|
3333
3396
|
return { content: [{ type: 'text', text: JSON.stringify({ success: true, ...result }, null, 2) }] };
|
|
3334
3397
|
} catch (e) {
|
|
3335
|
-
if (e.code === 'MODULE_NOT_FOUND') {
|
|
3398
|
+
if (e.code === 'MODULE_NOT_FOUND' || e.code === 'ERR_REQUIRE_ESM' || e.code === 'ERR_PACKAGE_PATH_NOT_EXPORTED') {
|
|
3336
3399
|
return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: 'Brain tools require @ruvector/pi-brain', hint: 'npm install @ruvector/pi-brain' }, null, 2) }] };
|
|
3337
3400
|
}
|
|
3338
3401
|
return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: e.message }, null, 2) }], isError: true };
|
|
@@ -3349,7 +3412,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
3349
3412
|
const result = await client.status();
|
|
3350
3413
|
return { content: [{ type: 'text', text: JSON.stringify({ success: true, ...result }, null, 2) }] };
|
|
3351
3414
|
} catch (e) {
|
|
3352
|
-
if (e.code === 'MODULE_NOT_FOUND') {
|
|
3415
|
+
if (e.code === 'MODULE_NOT_FOUND' || e.code === 'ERR_REQUIRE_ESM' || e.code === 'ERR_PACKAGE_PATH_NOT_EXPORTED') {
|
|
3353
3416
|
return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: 'Brain tools require @ruvector/pi-brain', hint: 'npm install @ruvector/pi-brain' }, null, 2) }] };
|
|
3354
3417
|
}
|
|
3355
3418
|
return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: e.message }, null, 2) }], isError: true };
|
|
@@ -3366,7 +3429,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
3366
3429
|
const result = await client.drift({ domain: args.domain });
|
|
3367
3430
|
return { content: [{ type: 'text', text: JSON.stringify({ success: true, ...result }, null, 2) }] };
|
|
3368
3431
|
} catch (e) {
|
|
3369
|
-
if (e.code === 'MODULE_NOT_FOUND') {
|
|
3432
|
+
if (e.code === 'MODULE_NOT_FOUND' || e.code === 'ERR_REQUIRE_ESM' || e.code === 'ERR_PACKAGE_PATH_NOT_EXPORTED') {
|
|
3370
3433
|
return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: 'Brain tools require @ruvector/pi-brain', hint: 'npm install @ruvector/pi-brain' }, null, 2) }] };
|
|
3371
3434
|
}
|
|
3372
3435
|
return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: e.message }, null, 2) }], isError: true };
|
|
@@ -3383,7 +3446,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
3383
3446
|
const result = await client.partition({ domain: args.domain, min_cluster_size: args.min_cluster_size || 3 });
|
|
3384
3447
|
return { content: [{ type: 'text', text: JSON.stringify({ success: true, ...result }, null, 2) }] };
|
|
3385
3448
|
} catch (e) {
|
|
3386
|
-
if (e.code === 'MODULE_NOT_FOUND') {
|
|
3449
|
+
if (e.code === 'MODULE_NOT_FOUND' || e.code === 'ERR_REQUIRE_ESM' || e.code === 'ERR_PACKAGE_PATH_NOT_EXPORTED') {
|
|
3387
3450
|
return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: 'Brain tools require @ruvector/pi-brain', hint: 'npm install @ruvector/pi-brain' }, null, 2) }] };
|
|
3388
3451
|
}
|
|
3389
3452
|
return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: e.message }, null, 2) }], isError: true };
|
|
@@ -3400,7 +3463,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
3400
3463
|
const result = await client.transfer(args.source, args.target);
|
|
3401
3464
|
return { content: [{ type: 'text', text: JSON.stringify({ success: true, ...result }, null, 2) }] };
|
|
3402
3465
|
} catch (e) {
|
|
3403
|
-
if (e.code === 'MODULE_NOT_FOUND') {
|
|
3466
|
+
if (e.code === 'MODULE_NOT_FOUND' || e.code === 'ERR_REQUIRE_ESM' || e.code === 'ERR_PACKAGE_PATH_NOT_EXPORTED') {
|
|
3404
3467
|
return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: 'Brain tools require @ruvector/pi-brain', hint: 'npm install @ruvector/pi-brain' }, null, 2) }] };
|
|
3405
3468
|
}
|
|
3406
3469
|
return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: e.message }, null, 2) }], isError: true };
|
|
@@ -3417,7 +3480,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
3417
3480
|
const result = await client.sync({ direction: args.direction || 'both' });
|
|
3418
3481
|
return { content: [{ type: 'text', text: JSON.stringify({ success: true, ...result }, null, 2) }] };
|
|
3419
3482
|
} catch (e) {
|
|
3420
|
-
if (e.code === 'MODULE_NOT_FOUND') {
|
|
3483
|
+
if (e.code === 'MODULE_NOT_FOUND' || e.code === 'ERR_REQUIRE_ESM' || e.code === 'ERR_PACKAGE_PATH_NOT_EXPORTED') {
|
|
3421
3484
|
return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: 'Brain tools require @ruvector/pi-brain', hint: 'npm install @ruvector/pi-brain' }, null, 2) }] };
|
|
3422
3485
|
}
|
|
3423
3486
|
return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: e.message }, null, 2) }], isError: true };
|
|
@@ -3777,6 +3840,15 @@ async function main() {
|
|
|
3777
3840
|
const transport = new StdioServerTransport();
|
|
3778
3841
|
await server.connect(transport);
|
|
3779
3842
|
console.error('RuVector MCP server running on stdio');
|
|
3843
|
+
|
|
3844
|
+
// Exit cleanly when the parent process closes the stdio pipe or sends a
|
|
3845
|
+
// termination signal. Without these handlers, the MCP server can survive
|
|
3846
|
+
// the parent's death (e.g. when the client is killed with SIGKILL) and
|
|
3847
|
+
// accumulate as an orphaned process under PPID=1, consuming RSS for the
|
|
3848
|
+
// lifetime of the user session.
|
|
3849
|
+
process.stdin.on('end', () => process.exit(0));
|
|
3850
|
+
process.on('SIGINT', () => process.exit(0));
|
|
3851
|
+
process.on('SIGTERM', () => process.exit(0));
|
|
3780
3852
|
}
|
|
3781
3853
|
|
|
3782
3854
|
main().catch(console.error);
|
|
@@ -107,7 +107,7 @@ export declare class IntelligenceEngine {
|
|
|
107
107
|
private initVectorDb;
|
|
108
108
|
private initParallel;
|
|
109
109
|
/**
|
|
110
|
-
* Generate embedding using
|
|
110
|
+
* Generate embedding using attention or hash (sync). Use embedAsync() for ONNX.
|
|
111
111
|
*/
|
|
112
112
|
embed(text: string): number[];
|
|
113
113
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intelligence-engine.d.ts","sourceRoot":"","sources":["../../src/core/intelligence-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAoC,mBAAmB,EAAE,MAAM,gB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H,wBAAgB,uBAAuB,IAAI,kBAAkB,CAQ5D;AAED,eAAe,kBAAkB,CAAC"}
|
|
@@ -178,22 +178,11 @@ class IntelligenceEngine {
|
|
|
178
178
|
// Embedding Generation
|
|
179
179
|
// =========================================================================
|
|
180
180
|
/**
|
|
181
|
-
* Generate embedding using
|
|
181
|
+
* Generate embedding using attention or hash (sync). Use embedAsync() for ONNX.
|
|
182
182
|
*/
|
|
183
183
|
embed(text) {
|
|
184
184
|
const dim = this.config.embeddingDim;
|
|
185
|
-
// Try
|
|
186
|
-
if (this.onnxReady && this.onnxEmbedder) {
|
|
187
|
-
try {
|
|
188
|
-
// Note: This is sync wrapper for async ONNX
|
|
189
|
-
// For full async, use embedAsync
|
|
190
|
-
return this.hashEmbed(text, dim); // Fallback for sync context
|
|
191
|
-
}
|
|
192
|
-
catch {
|
|
193
|
-
// Fall through
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
// Try to use attention-based embedding
|
|
185
|
+
// Try to use attention-based embedding (best sync quality)
|
|
197
186
|
if (this.attention?.DotProductAttention) {
|
|
198
187
|
try {
|
|
199
188
|
return this.attentionEmbed(text, dim);
|
|
@@ -881,10 +870,17 @@ class IntelligenceEngine {
|
|
|
881
870
|
this.coEditPatterns.clear();
|
|
882
871
|
this.agentMappings.clear();
|
|
883
872
|
}
|
|
884
|
-
// Import memories
|
|
873
|
+
// Import memories and rebuild HNSW index so recall() returns results (#315)
|
|
885
874
|
if (data.memories) {
|
|
886
875
|
for (const mem of data.memories) {
|
|
887
876
|
this.memories.set(mem.id, mem);
|
|
877
|
+
if (this.vectorDb && mem.embedding?.length) {
|
|
878
|
+
this.vectorDb.insert({
|
|
879
|
+
id: mem.id,
|
|
880
|
+
vector: new Float32Array(mem.embedding),
|
|
881
|
+
metadata: JSON.stringify({ content: mem.content, type: mem.type, created: mem.created }),
|
|
882
|
+
}).catch(() => { });
|
|
883
|
+
}
|
|
888
884
|
}
|
|
889
885
|
}
|
|
890
886
|
// Import routing patterns
|
|
@@ -133,6 +133,8 @@ export declare class LearningEngine {
|
|
|
133
133
|
export(): {
|
|
134
134
|
qTables: Record<string, Record<string, number>>;
|
|
135
135
|
qTables2: Record<string, Record<string, number>>;
|
|
136
|
+
eligibilityTraces: Record<string, Record<string, number>>;
|
|
137
|
+
actorWeights: Record<string, number[]>;
|
|
136
138
|
criticValues: Record<string, number>;
|
|
137
139
|
trajectories: LearningTrajectory[];
|
|
138
140
|
stats: Record<string, AlgorithmStats>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"learning-engine.d.ts","sourceRoot":"","sources":["../../src/core/learning-engine.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,iBAAiB,GACzB,YAAY,GACZ,OAAO,GACP,UAAU,GACV,cAAc,GACd,KAAK,GACL,sBAAsB,GACtB,aAAa,GACb,WAAW,GACX,KAAK,CAAC;AAEV,MAAM,MAAM,QAAQ,GAChB,eAAe,GACf,iBAAiB,GACjB,oBAAoB,GACpB,qBAAqB,GACrB,iBAAiB,GACjB,eAAe,CAAC;AAEpB,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,iBAAiB,CAAC;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,UAAU,E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"}
|
|
@@ -452,7 +452,7 @@ class LearningEngine {
|
|
|
452
452
|
stats.lastUpdate = Date.now();
|
|
453
453
|
// Running average reward
|
|
454
454
|
this.rewardHistory.push(reward);
|
|
455
|
-
if (this.rewardHistory.length >
|
|
455
|
+
if (this.rewardHistory.length > 500) {
|
|
456
456
|
this.rewardHistory.shift();
|
|
457
457
|
}
|
|
458
458
|
stats.avgReward = this.rewardHistory.reduce((a, b) => a + b, 0) / this.rewardHistory.length;
|
|
@@ -503,6 +503,14 @@ class LearningEngine {
|
|
|
503
503
|
for (const [state, actions] of this.qTables2) {
|
|
504
504
|
qTables2[state] = Object.fromEntries(actions);
|
|
505
505
|
}
|
|
506
|
+
const eligibilityTraces = {};
|
|
507
|
+
for (const [state, traces] of this.eligibilityTraces) {
|
|
508
|
+
eligibilityTraces[state] = Object.fromEntries(traces);
|
|
509
|
+
}
|
|
510
|
+
const actorWeights = {};
|
|
511
|
+
for (const [key, weights] of this.actorWeights) {
|
|
512
|
+
actorWeights[key] = weights;
|
|
513
|
+
}
|
|
506
514
|
const criticValues = Object.fromEntries(this.criticValues);
|
|
507
515
|
const stats = {};
|
|
508
516
|
for (const [alg, s] of this.stats) {
|
|
@@ -515,11 +523,13 @@ class LearningEngine {
|
|
|
515
523
|
return {
|
|
516
524
|
qTables,
|
|
517
525
|
qTables2,
|
|
526
|
+
eligibilityTraces,
|
|
527
|
+
actorWeights,
|
|
518
528
|
criticValues,
|
|
519
|
-
trajectories: this.trajectories.slice(-100),
|
|
529
|
+
trajectories: this.trajectories.slice(-100),
|
|
520
530
|
stats,
|
|
521
531
|
configs,
|
|
522
|
-
rewardHistory: this.rewardHistory.slice(-
|
|
532
|
+
rewardHistory: this.rewardHistory.slice(-500),
|
|
523
533
|
};
|
|
524
534
|
}
|
|
525
535
|
/**
|
|
@@ -535,6 +545,16 @@ class LearningEngine {
|
|
|
535
545
|
for (const [state, actions] of Object.entries(data.qTables2 || {})) {
|
|
536
546
|
this.qTables2.set(state, new Map(Object.entries(actions)));
|
|
537
547
|
}
|
|
548
|
+
// Eligibility traces
|
|
549
|
+
this.eligibilityTraces.clear();
|
|
550
|
+
for (const [state, traces] of Object.entries(data.eligibilityTraces || {})) {
|
|
551
|
+
this.eligibilityTraces.set(state, new Map(Object.entries(traces)));
|
|
552
|
+
}
|
|
553
|
+
// Actor weights
|
|
554
|
+
this.actorWeights.clear();
|
|
555
|
+
for (const [key, weights] of Object.entries(data.actorWeights || {})) {
|
|
556
|
+
this.actorWeights.set(key, weights);
|
|
557
|
+
}
|
|
538
558
|
// Critic values
|
|
539
559
|
this.criticValues = new Map(Object.entries(data.criticValues || {}));
|
|
540
560
|
// Trajectories
|