@xdarkicex/openclaw-memory-libravdb 1.4.37 → 1.4.39

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 CHANGED
@@ -276,17 +276,27 @@ async function runSearch(runtime, cfg, queryArg, opts, logger) {
276
276
  process.exitCode = 1;
277
277
  return;
278
278
  }
279
+ let maxResults;
280
+ let explicitMinScore;
281
+ try {
282
+ maxResults = normalizeCliLimit(opts?.maxResults ?? opts?.limit, "--max-results");
283
+ explicitMinScore = normalizeCliScore(opts?.minScore, "--min-score");
284
+ }
285
+ catch (validationError) {
286
+ logger.error(formatError(validationError));
287
+ process.exitCode = 1;
288
+ return;
289
+ }
279
290
  try {
280
291
  const bridge = buildMemoryRuntimeBridge(runtime.getRpc, cfg);
281
292
  const { manager } = await bridge.getMemorySearchManager({
282
293
  agentId: opts?.agent,
283
294
  });
284
- const maxResults = normalizeLimit(opts?.maxResults ?? opts?.limit);
285
- const minScore = normalizeNumber(opts?.minScore);
295
+ const minScore = explicitMinScore ?? resolveDefaultSearchMinScore(manager.status(), cfg);
286
296
  const results = (await manager.search({
287
297
  query,
288
298
  ...(maxResults ? { maxResults } : {}),
289
- ...(minScore !== undefined ? { minScore } : {}),
299
+ minScore,
290
300
  }));
291
301
  if (opts?.json) {
292
302
  console.log(JSON.stringify({ results }, null, 2));
@@ -307,6 +317,9 @@ async function runSearch(runtime, cfg, queryArg, opts, logger) {
307
317
  process.exitCode = 1;
308
318
  }
309
319
  }
320
+ function resolveDefaultSearchMinScore(status, cfg) {
321
+ return normalizeNumber(status?.gatingThreshold) ?? normalizeNumber(cfg.ingestionGateThreshold) ?? 0.35;
322
+ }
310
323
  async function runFlush(runtime, opts, logger) {
311
324
  const namespace = resolveCliNamespace(opts);
312
325
  if (!namespace) {
@@ -332,10 +345,16 @@ async function runFlush(runtime, opts, logger) {
332
345
  }
333
346
  }
334
347
  async function runExport(runtime, opts, logger) {
348
+ const namespace = resolveCliNamespace(opts);
349
+ if (!namespace) {
350
+ logger.error("LibraVDB export requires a namespace. Provide --user-id or --session-key.");
351
+ process.exitCode = 1;
352
+ return;
353
+ }
335
354
  try {
336
355
  const rpc = await runtime.getRpc();
337
356
  const result = await rpc.call("export_memory", {
338
- namespace: resolveCliNamespace(opts),
357
+ namespace,
339
358
  });
340
359
  for (const record of result.records ?? []) {
341
360
  stdout.write(`${JSON.stringify(record)}\n`);
@@ -347,11 +366,20 @@ async function runExport(runtime, opts, logger) {
347
366
  }
348
367
  }
349
368
  async function runJournal(runtime, opts, logger) {
369
+ let limit;
370
+ try {
371
+ limit = normalizeCliLimit(opts?.limit, "--limit");
372
+ }
373
+ catch (validationError) {
374
+ logger.error(formatError(validationError));
375
+ process.exitCode = 1;
376
+ return;
377
+ }
350
378
  try {
351
379
  const rpc = await runtime.getRpc();
352
380
  const result = await rpc.call("list_lifecycle_journal", {
353
381
  sessionId: opts?.sessionId?.trim() || undefined,
354
- limit: normalizeLimit(opts?.limit),
382
+ limit,
355
383
  });
356
384
  for (const record of result.results ?? []) {
357
385
  stdout.write(`${JSON.stringify(record)}\n`);
@@ -396,17 +424,30 @@ function formatError(error) {
396
424
  }
397
425
  return String(error);
398
426
  }
399
- function normalizeLimit(limit) {
400
- if (typeof limit === "number" && Number.isFinite(limit) && limit > 0) {
401
- return Math.floor(limit);
427
+ function normalizeCliLimit(limit, optionName) {
428
+ if (limit === undefined)
429
+ return undefined;
430
+ const parsed = parseStrictNumber(limit);
431
+ if (Number.isFinite(parsed) && Number.isInteger(parsed) && parsed > 0) {
432
+ return parsed;
402
433
  }
403
- if (typeof limit === "string") {
404
- const parsed = Number.parseInt(limit, 10);
405
- if (Number.isFinite(parsed) && parsed > 0) {
406
- return parsed;
407
- }
434
+ throw new Error(`Invalid value for ${optionName}: must be a positive integer`);
435
+ }
436
+ function normalizeCliScore(value, optionName) {
437
+ if (value === undefined)
438
+ return undefined;
439
+ const parsed = parseStrictNumber(value);
440
+ if (Number.isFinite(parsed) && parsed >= 0 && parsed <= 1) {
441
+ return parsed;
408
442
  }
409
- return undefined;
443
+ throw new Error(`Invalid value for ${optionName}: must be a number between 0 and 1`);
444
+ }
445
+ function parseStrictNumber(value) {
446
+ if (typeof value === "number") {
447
+ return value;
448
+ }
449
+ const trimmed = value.trim();
450
+ return trimmed === "" ? NaN : Number(trimmed);
410
451
  }
411
452
  function normalizeNumber(value) {
412
453
  if (typeof value === "number" && Number.isFinite(value)) {
package/dist/index.js CHANGED
@@ -33354,18 +33354,27 @@ async function runSearch(runtime, cfg, queryArg, opts, logger) {
33354
33354
  process.exitCode = 1;
33355
33355
  return;
33356
33356
  }
33357
+ let maxResults;
33358
+ let explicitMinScore;
33359
+ try {
33360
+ maxResults = normalizeCliLimit(opts?.maxResults ?? opts?.limit, "--max-results");
33361
+ explicitMinScore = normalizeCliScore(opts?.minScore, "--min-score");
33362
+ } catch (validationError) {
33363
+ logger.error(formatError2(validationError));
33364
+ process.exitCode = 1;
33365
+ return;
33366
+ }
33357
33367
  try {
33358
33368
  const bridge = buildMemoryRuntimeBridge(runtime.getRpc, cfg);
33359
33369
  const { manager } = await bridge.getMemorySearchManager({
33360
33370
  agentId: opts?.agent
33361
33371
  });
33362
- const maxResults = normalizeLimit(opts?.maxResults ?? opts?.limit);
33363
- const minScore = normalizeNumber2(opts?.minScore);
33372
+ const minScore = explicitMinScore ?? resolveDefaultSearchMinScore(manager.status(), cfg);
33364
33373
  const results = await manager.search(
33365
33374
  {
33366
33375
  query,
33367
33376
  ...maxResults ? { maxResults } : {},
33368
- ...minScore !== void 0 ? { minScore } : {}
33377
+ minScore
33369
33378
  }
33370
33379
  );
33371
33380
  if (opts?.json) {
@@ -33386,6 +33395,9 @@ async function runSearch(runtime, cfg, queryArg, opts, logger) {
33386
33395
  process.exitCode = 1;
33387
33396
  }
33388
33397
  }
33398
+ function resolveDefaultSearchMinScore(status, cfg) {
33399
+ return normalizeNumber2(status?.gatingThreshold) ?? normalizeNumber2(cfg.ingestionGateThreshold) ?? 0.35;
33400
+ }
33389
33401
  async function runFlush(runtime, opts, logger) {
33390
33402
  const namespace = resolveCliNamespace(opts);
33391
33403
  if (!namespace) {
@@ -33410,10 +33422,16 @@ async function runFlush(runtime, opts, logger) {
33410
33422
  }
33411
33423
  }
33412
33424
  async function runExport(runtime, opts, logger) {
33425
+ const namespace = resolveCliNamespace(opts);
33426
+ if (!namespace) {
33427
+ logger.error("LibraVDB export requires a namespace. Provide --user-id or --session-key.");
33428
+ process.exitCode = 1;
33429
+ return;
33430
+ }
33413
33431
  try {
33414
33432
  const rpc = await runtime.getRpc();
33415
33433
  const result = await rpc.call("export_memory", {
33416
- namespace: resolveCliNamespace(opts)
33434
+ namespace
33417
33435
  });
33418
33436
  for (const record of result.records ?? []) {
33419
33437
  stdout.write(`${JSON.stringify(record)}
@@ -33425,11 +33443,19 @@ async function runExport(runtime, opts, logger) {
33425
33443
  }
33426
33444
  }
33427
33445
  async function runJournal(runtime, opts, logger) {
33446
+ let limit;
33447
+ try {
33448
+ limit = normalizeCliLimit(opts?.limit, "--limit");
33449
+ } catch (validationError) {
33450
+ logger.error(formatError2(validationError));
33451
+ process.exitCode = 1;
33452
+ return;
33453
+ }
33428
33454
  try {
33429
33455
  const rpc = await runtime.getRpc();
33430
33456
  const result = await rpc.call("list_lifecycle_journal", {
33431
33457
  sessionId: opts?.sessionId?.trim() || void 0,
33432
- limit: normalizeLimit(opts?.limit)
33458
+ limit
33433
33459
  });
33434
33460
  for (const record of result.results ?? []) {
33435
33461
  stdout.write(`${JSON.stringify(record)}
@@ -33474,17 +33500,28 @@ function formatError2(error) {
33474
33500
  }
33475
33501
  return String(error);
33476
33502
  }
33477
- function normalizeLimit(limit) {
33478
- if (typeof limit === "number" && Number.isFinite(limit) && limit > 0) {
33479
- return Math.floor(limit);
33503
+ function normalizeCliLimit(limit, optionName) {
33504
+ if (limit === void 0) return void 0;
33505
+ const parsed = parseStrictNumber(limit);
33506
+ if (Number.isFinite(parsed) && Number.isInteger(parsed) && parsed > 0) {
33507
+ return parsed;
33480
33508
  }
33481
- if (typeof limit === "string") {
33482
- const parsed = Number.parseInt(limit, 10);
33483
- if (Number.isFinite(parsed) && parsed > 0) {
33484
- return parsed;
33485
- }
33509
+ throw new Error(`Invalid value for ${optionName}: must be a positive integer`);
33510
+ }
33511
+ function normalizeCliScore(value, optionName) {
33512
+ if (value === void 0) return void 0;
33513
+ const parsed = parseStrictNumber(value);
33514
+ if (Number.isFinite(parsed) && parsed >= 0 && parsed <= 1) {
33515
+ return parsed;
33486
33516
  }
33487
- return void 0;
33517
+ throw new Error(`Invalid value for ${optionName}: must be a number between 0 and 1`);
33518
+ }
33519
+ function parseStrictNumber(value) {
33520
+ if (typeof value === "number") {
33521
+ return value;
33522
+ }
33523
+ const trimmed = value.trim();
33524
+ return trimmed === "" ? NaN : Number(trimmed);
33488
33525
  }
33489
33526
  function normalizeNumber2(value) {
33490
33527
  if (typeof value === "number" && Number.isFinite(value)) {
@@ -39548,7 +39585,7 @@ function formatError5(error) {
39548
39585
  function enrichStartupError(error, healthMessage) {
39549
39586
  const rawMessage = error instanceof Error ? error.message : String(error);
39550
39587
  const message = rawMessage.trim() || "LibraVDB daemon startup failed";
39551
- if (message.includes("install and start libravdbd separately") || message.includes("package does not provision the daemon binary")) {
39588
+ if (message.includes("package does not provision the daemon binary")) {
39552
39589
  return error instanceof Error ? error : new Error(message);
39553
39590
  }
39554
39591
  const shouldHint = /health check|daemon unavailable|connection refused|ECONNREFUSED|ENOENT|fallback mode|ONNX Runtime|embedder/i.test(
@@ -39653,6 +39690,16 @@ function register(api) {
39653
39690
  await dreamPromotion.stop();
39654
39691
  }
39655
39692
  });
39693
+ api.registerRuntimeLifecycle?.({
39694
+ id: "libravdb-shutdown",
39695
+ description: "Shut down the vector service runtime on plugin disable",
39696
+ async cleanup(ctx) {
39697
+ if (ctx.reason === "disable") {
39698
+ logger.info?.("LibraVDB disable \u2014 shutting down runtime");
39699
+ await runtime.shutdown();
39700
+ }
39701
+ }
39702
+ });
39656
39703
  api.on("before_reset", createBeforeResetHook(runtime, api.logger ?? console));
39657
39704
  api.on("session_end", createSessionEndHook(runtime, api.logger ?? console));
39658
39705
  api.on("agent_end", async (event) => {
@@ -133,7 +133,7 @@ function formatError(error) {
133
133
  export function enrichStartupError(error, healthMessage) {
134
134
  const rawMessage = error instanceof Error ? error.message : String(error);
135
135
  const message = rawMessage.trim() || "LibraVDB daemon startup failed";
136
- if (message.includes("install and start libravdbd separately") || message.includes("package does not provision the daemon binary")) {
136
+ if (message.includes("package does not provision the daemon binary")) {
137
137
  return error instanceof Error ? error : new Error(message);
138
138
  }
139
139
  const shouldHint = /health check|daemon unavailable|connection refused|ECONNREFUSED|ENOENT|fallback mode|ONNX Runtime|embedder/i.test(`${message} ${healthMessage ?? ""}`);
@@ -2,7 +2,7 @@
2
2
  "id": "libravdb-memory",
3
3
  "name": "LibraVDB Memory",
4
4
  "description": "Persistent vector memory with three-tier hybrid scoring",
5
- "version": "1.4.37",
5
+ "version": "1.4.39",
6
6
  "kind": [
7
7
  "memory",
8
8
  "context-engine"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xdarkicex/openclaw-memory-libravdb",
3
- "version": "1.4.37",
3
+ "version": "1.4.39",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",