@xdarkicex/openclaw-memory-libravdb 1.4.74 → 1.4.76
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/dist/cli.js +44 -12
- package/dist/index.js +43 -12
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -35,7 +35,8 @@ export function registerMemoryCli(api, runtime, cfg, logger = console) {
|
|
|
35
35
|
.option("--agent <id>", "Agent id")
|
|
36
36
|
.option("--json", "Print JSON")
|
|
37
37
|
.option("--deep", "Probe authored collection search health")
|
|
38
|
-
.option("--index", "
|
|
38
|
+
.option("--index", "Rebuild the index before printing status")
|
|
39
|
+
.option("--force", "Required with --index: confirm index rebuild")
|
|
39
40
|
.option("--fix", "Accepted for OpenClaw memory CLI compatibility")
|
|
40
41
|
.option("--verbose", "Verbose logging")
|
|
41
42
|
.action(async (opts) => {
|
|
@@ -143,6 +144,17 @@ async function runCliCommand(runtime, logger, action) {
|
|
|
143
144
|
}
|
|
144
145
|
}
|
|
145
146
|
async function runStatus(runtime, cfg, logger, opts = {}) {
|
|
147
|
+
if (opts.index) {
|
|
148
|
+
if (!opts.force) {
|
|
149
|
+
logger.error("LibraVDB status --index performs an index rebuild. Re-run with --force to continue.");
|
|
150
|
+
process.exitCode = 1;
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const ok = await runIndex(runtime, cfg, { ...opts, verbose: false }, logger, { quiet: true });
|
|
154
|
+
if (!ok) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
146
158
|
try {
|
|
147
159
|
const rpc = await runtime.getRpc();
|
|
148
160
|
const status = await rpc.call("status", {});
|
|
@@ -260,7 +272,7 @@ async function runIndex(runtime, cfg, opts, logger, params = {}) {
|
|
|
260
272
|
if (!opts?.force) {
|
|
261
273
|
logger.error("LibraVDB index rebuild requires --force. This re-embeds all stored documents with the current model and may be slow.");
|
|
262
274
|
process.exitCode = 1;
|
|
263
|
-
return;
|
|
275
|
+
return false;
|
|
264
276
|
}
|
|
265
277
|
const namespace = resolveCliNamespace(opts);
|
|
266
278
|
const collections = opts?.collections
|
|
@@ -288,11 +300,14 @@ async function runIndex(runtime, cfg, opts, logger, params = {}) {
|
|
|
288
300
|
if ((result.errors?.length ?? 0) > 0 && (result.recordsReindexed ?? 0) === 0) {
|
|
289
301
|
logger.error("LibraVDB index rebuild completed with errors and no records reindexed.");
|
|
290
302
|
process.exitCode = 1;
|
|
303
|
+
return false;
|
|
291
304
|
}
|
|
305
|
+
return true;
|
|
292
306
|
}
|
|
293
307
|
catch (error) {
|
|
294
308
|
logger.error(`LibraVDB index rebuild failed: ${formatError(error)}`);
|
|
295
309
|
process.exitCode = 1;
|
|
310
|
+
return false;
|
|
296
311
|
}
|
|
297
312
|
}
|
|
298
313
|
function resolveIndexRebuildTimeoutMs(cfg) {
|
|
@@ -350,14 +365,14 @@ function resolveDefaultSearchMinScore(status, cfg) {
|
|
|
350
365
|
return normalizeNumber(status?.gatingThreshold) ?? normalizeNumber(cfg.ingestionGateThreshold) ?? 0.35;
|
|
351
366
|
}
|
|
352
367
|
async function runFlush(runtime, opts, logger) {
|
|
353
|
-
const
|
|
354
|
-
if (!
|
|
368
|
+
const scope = resolveCliMemoryOperationScope(opts);
|
|
369
|
+
if (!scope) {
|
|
355
370
|
logger.error("LibraVDB flush requires --user-id <userId> or --session-key <sessionKey>.");
|
|
356
371
|
process.exitCode = 1;
|
|
357
372
|
return;
|
|
358
373
|
}
|
|
359
374
|
if (!opts?.yes) {
|
|
360
|
-
const confirmed = await confirm(`Delete durable memory namespace ${
|
|
375
|
+
const confirmed = await confirm(`Delete durable memory namespace ${scope.displayName}? [y/N] `);
|
|
361
376
|
if (!confirmed) {
|
|
362
377
|
console.log("Aborted.");
|
|
363
378
|
return;
|
|
@@ -365,8 +380,8 @@ async function runFlush(runtime, opts, logger) {
|
|
|
365
380
|
}
|
|
366
381
|
try {
|
|
367
382
|
const rpc = await runtime.getRpc();
|
|
368
|
-
await rpc.call("flush_namespace",
|
|
369
|
-
console.log(`Deleted durable memory namespace ${
|
|
383
|
+
await rpc.call("flush_namespace", scope.params);
|
|
384
|
+
console.log(`Deleted durable memory namespace ${scope.displayName}.`);
|
|
370
385
|
}
|
|
371
386
|
catch (error) {
|
|
372
387
|
logger.error(`LibraVDB flush failed: ${formatError(error)}`);
|
|
@@ -374,17 +389,15 @@ async function runFlush(runtime, opts, logger) {
|
|
|
374
389
|
}
|
|
375
390
|
}
|
|
376
391
|
async function runExport(runtime, opts, logger) {
|
|
377
|
-
const
|
|
378
|
-
if (!
|
|
392
|
+
const scope = resolveCliMemoryOperationScope(opts);
|
|
393
|
+
if (!scope) {
|
|
379
394
|
logger.error("LibraVDB export requires a namespace. Provide --user-id or --session-key.");
|
|
380
395
|
process.exitCode = 1;
|
|
381
396
|
return;
|
|
382
397
|
}
|
|
383
398
|
try {
|
|
384
399
|
const rpc = await runtime.getRpc();
|
|
385
|
-
const result = await rpc.call("export_memory",
|
|
386
|
-
namespace,
|
|
387
|
-
});
|
|
400
|
+
const result = await rpc.call("export_memory", scope.params);
|
|
388
401
|
for (const record of result.records ?? []) {
|
|
389
402
|
stdout.write(`${JSON.stringify(record)}\n`);
|
|
390
403
|
}
|
|
@@ -505,3 +518,22 @@ function resolveCliNamespace(opts) {
|
|
|
505
518
|
}
|
|
506
519
|
return resolveDurableNamespace({ userId, sessionKey, agentId });
|
|
507
520
|
}
|
|
521
|
+
function resolveCliMemoryOperationScope(opts) {
|
|
522
|
+
const userId = opts?.userId?.trim();
|
|
523
|
+
if (userId) {
|
|
524
|
+
return {
|
|
525
|
+
displayName: `user:${userId}`,
|
|
526
|
+
params: { userId },
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
const sessionKey = opts?.sessionKey?.trim();
|
|
530
|
+
const agentId = opts?.agent?.trim();
|
|
531
|
+
if (!sessionKey && !agentId) {
|
|
532
|
+
return undefined;
|
|
533
|
+
}
|
|
534
|
+
const namespace = resolveDurableNamespace({ sessionKey, agentId });
|
|
535
|
+
return {
|
|
536
|
+
displayName: namespace,
|
|
537
|
+
params: { namespace },
|
|
538
|
+
};
|
|
539
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -33225,7 +33225,7 @@ function registerMemoryCli(api, runtime, cfg, logger = console) {
|
|
|
33225
33225
|
ensureCommand(root, "dream-promote").description("Promote vetted dream diary entries into the dedicated dream collection");
|
|
33226
33226
|
return;
|
|
33227
33227
|
}
|
|
33228
|
-
ensureCommand(root, "status").description("Show sidecar health, record counts, and active thresholds").option("--agent <id>", "Agent id").option("--json", "Print JSON").option("--deep", "Probe authored collection search health").option("--index", "
|
|
33228
|
+
ensureCommand(root, "status").description("Show sidecar health, record counts, and active thresholds").option("--agent <id>", "Agent id").option("--json", "Print JSON").option("--deep", "Probe authored collection search health").option("--index", "Rebuild the index before printing status").option("--force", "Required with --index: confirm index rebuild").option("--fix", "Accepted for OpenClaw memory CLI compatibility").option("--verbose", "Verbose logging").action(async (opts) => {
|
|
33229
33229
|
await runCliCommand(runtime, logger, async () => {
|
|
33230
33230
|
await runStatus(runtime, cfg, logger, normalizeOptionBag(opts));
|
|
33231
33231
|
});
|
|
@@ -33315,6 +33315,17 @@ async function runCliCommand(runtime, logger, action) {
|
|
|
33315
33315
|
}
|
|
33316
33316
|
}
|
|
33317
33317
|
async function runStatus(runtime, cfg, logger, opts = {}) {
|
|
33318
|
+
if (opts.index) {
|
|
33319
|
+
if (!opts.force) {
|
|
33320
|
+
logger.error("LibraVDB status --index performs an index rebuild. Re-run with --force to continue.");
|
|
33321
|
+
process.exitCode = 1;
|
|
33322
|
+
return;
|
|
33323
|
+
}
|
|
33324
|
+
const ok = await runIndex(runtime, cfg, { ...opts, verbose: false }, logger, { quiet: true });
|
|
33325
|
+
if (!ok) {
|
|
33326
|
+
return;
|
|
33327
|
+
}
|
|
33328
|
+
}
|
|
33318
33329
|
try {
|
|
33319
33330
|
const rpc = await runtime.getRpc();
|
|
33320
33331
|
const status = await rpc.call("status", {});
|
|
@@ -33430,7 +33441,7 @@ async function runIndex(runtime, cfg, opts, logger, params = {}) {
|
|
|
33430
33441
|
if (!opts?.force) {
|
|
33431
33442
|
logger.error("LibraVDB index rebuild requires --force. This re-embeds all stored documents with the current model and may be slow.");
|
|
33432
33443
|
process.exitCode = 1;
|
|
33433
|
-
return;
|
|
33444
|
+
return false;
|
|
33434
33445
|
}
|
|
33435
33446
|
const namespace = resolveCliNamespace(opts);
|
|
33436
33447
|
const collections = opts?.collections?.split(",").map((c) => c.trim()).filter((c) => c.length > 0);
|
|
@@ -33455,10 +33466,13 @@ async function runIndex(runtime, cfg, opts, logger, params = {}) {
|
|
|
33455
33466
|
if ((result.errors?.length ?? 0) > 0 && (result.recordsReindexed ?? 0) === 0) {
|
|
33456
33467
|
logger.error("LibraVDB index rebuild completed with errors and no records reindexed.");
|
|
33457
33468
|
process.exitCode = 1;
|
|
33469
|
+
return false;
|
|
33458
33470
|
}
|
|
33471
|
+
return true;
|
|
33459
33472
|
} catch (error) {
|
|
33460
33473
|
logger.error(`LibraVDB index rebuild failed: ${formatError(error)}`);
|
|
33461
33474
|
process.exitCode = 1;
|
|
33475
|
+
return false;
|
|
33462
33476
|
}
|
|
33463
33477
|
}
|
|
33464
33478
|
function resolveIndexRebuildTimeoutMs(cfg) {
|
|
@@ -33516,14 +33530,14 @@ function resolveDefaultSearchMinScore(status, cfg) {
|
|
|
33516
33530
|
return normalizeNumber2(status?.gatingThreshold) ?? normalizeNumber2(cfg.ingestionGateThreshold) ?? 0.35;
|
|
33517
33531
|
}
|
|
33518
33532
|
async function runFlush(runtime, opts, logger) {
|
|
33519
|
-
const
|
|
33520
|
-
if (!
|
|
33533
|
+
const scope = resolveCliMemoryOperationScope(opts);
|
|
33534
|
+
if (!scope) {
|
|
33521
33535
|
logger.error("LibraVDB flush requires --user-id <userId> or --session-key <sessionKey>.");
|
|
33522
33536
|
process.exitCode = 1;
|
|
33523
33537
|
return;
|
|
33524
33538
|
}
|
|
33525
33539
|
if (!opts?.yes) {
|
|
33526
|
-
const confirmed = await confirm(`Delete durable memory namespace ${
|
|
33540
|
+
const confirmed = await confirm(`Delete durable memory namespace ${scope.displayName}? [y/N] `);
|
|
33527
33541
|
if (!confirmed) {
|
|
33528
33542
|
console.log("Aborted.");
|
|
33529
33543
|
return;
|
|
@@ -33531,25 +33545,23 @@ async function runFlush(runtime, opts, logger) {
|
|
|
33531
33545
|
}
|
|
33532
33546
|
try {
|
|
33533
33547
|
const rpc = await runtime.getRpc();
|
|
33534
|
-
await rpc.call("flush_namespace",
|
|
33535
|
-
console.log(`Deleted durable memory namespace ${
|
|
33548
|
+
await rpc.call("flush_namespace", scope.params);
|
|
33549
|
+
console.log(`Deleted durable memory namespace ${scope.displayName}.`);
|
|
33536
33550
|
} catch (error) {
|
|
33537
33551
|
logger.error(`LibraVDB flush failed: ${formatError(error)}`);
|
|
33538
33552
|
process.exitCode = 1;
|
|
33539
33553
|
}
|
|
33540
33554
|
}
|
|
33541
33555
|
async function runExport(runtime, opts, logger) {
|
|
33542
|
-
const
|
|
33543
|
-
if (!
|
|
33556
|
+
const scope = resolveCliMemoryOperationScope(opts);
|
|
33557
|
+
if (!scope) {
|
|
33544
33558
|
logger.error("LibraVDB export requires a namespace. Provide --user-id or --session-key.");
|
|
33545
33559
|
process.exitCode = 1;
|
|
33546
33560
|
return;
|
|
33547
33561
|
}
|
|
33548
33562
|
try {
|
|
33549
33563
|
const rpc = await runtime.getRpc();
|
|
33550
|
-
const result = await rpc.call("export_memory",
|
|
33551
|
-
namespace
|
|
33552
|
-
});
|
|
33564
|
+
const result = await rpc.call("export_memory", scope.params);
|
|
33553
33565
|
for (const record of result.records ?? []) {
|
|
33554
33566
|
stdout.write(`${JSON.stringify(record)}
|
|
33555
33567
|
`);
|
|
@@ -33667,6 +33679,25 @@ function resolveCliNamespace(opts) {
|
|
|
33667
33679
|
}
|
|
33668
33680
|
return resolveDurableNamespace({ userId, sessionKey, agentId });
|
|
33669
33681
|
}
|
|
33682
|
+
function resolveCliMemoryOperationScope(opts) {
|
|
33683
|
+
const userId = opts?.userId?.trim();
|
|
33684
|
+
if (userId) {
|
|
33685
|
+
return {
|
|
33686
|
+
displayName: `user:${userId}`,
|
|
33687
|
+
params: { userId }
|
|
33688
|
+
};
|
|
33689
|
+
}
|
|
33690
|
+
const sessionKey = opts?.sessionKey?.trim();
|
|
33691
|
+
const agentId = opts?.agent?.trim();
|
|
33692
|
+
if (!sessionKey && !agentId) {
|
|
33693
|
+
return void 0;
|
|
33694
|
+
}
|
|
33695
|
+
const namespace = resolveDurableNamespace({ sessionKey, agentId });
|
|
33696
|
+
return {
|
|
33697
|
+
displayName: namespace,
|
|
33698
|
+
params: { namespace }
|
|
33699
|
+
};
|
|
33700
|
+
}
|
|
33670
33701
|
|
|
33671
33702
|
// src/context-engine.ts
|
|
33672
33703
|
var APPROX_CHARS_PER_TOKEN = 4;
|
package/openclaw.plugin.json
CHANGED