@xdarkicex/openclaw-memory-libravdb 1.4.62 → 1.4.64

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.
@@ -312,8 +312,9 @@ function isQuestionShapedRecallCandidate(text) {
312
312
  /^\s*(?:who|what|when|where|why|how)\b/i.test(normalized));
313
313
  }
314
314
  function rankExactRecallCandidate(result, token) {
315
- if (!result.text.includes(token))
315
+ if (typeof result.text !== "string" || !result.text.includes(token)) {
316
316
  return Number.NEGATIVE_INFINITY;
317
+ }
317
318
  let rank = result.score;
318
319
  if (/\bmeans\b/i.test(result.text))
319
320
  rank += 100;
@@ -476,7 +477,7 @@ export function buildContextEngineFactory(runtime, cfg, logger = console) {
476
477
  excludeByCollection: {},
477
478
  });
478
479
  const hit = (result.results ?? [])
479
- .filter((candidate) => isExactRecallFact(candidate.text, token))
480
+ .filter((candidate) => typeof candidate?.text === "string" && isExactRecallFact(candidate.text, token))
480
481
  .sort((a, b) => rankExactRecallCandidate(b, token) - rankExactRecallCandidate(a, token))[0];
481
482
  if (hit) {
482
483
  injectedFacts.push(buildExactRecallFact(hit, token));
@@ -321,22 +321,26 @@ function parseTrailingMetadata(body) {
321
321
  uniqueQueries,
322
322
  };
323
323
  }
324
+ const DECIMAL_NUMBER_PATTERN = /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i;
325
+ const INTEGER_PATTERN = /^[+-]?\d+$/;
324
326
  function parseNumber(value) {
325
- if (!value) {
327
+ const trimmed = value?.trim();
328
+ if (!trimmed || !DECIMAL_NUMBER_PATTERN.test(trimmed)) {
326
329
  return null;
327
330
  }
328
- const parsed = Number.parseFloat(value);
331
+ const parsed = Number(trimmed);
329
332
  if (!Number.isFinite(parsed)) {
330
333
  return null;
331
334
  }
332
335
  return parsed;
333
336
  }
334
337
  function parseInteger(value) {
335
- if (!value) {
338
+ const trimmed = value?.trim();
339
+ if (!trimmed || !INTEGER_PATTERN.test(trimmed)) {
336
340
  return null;
337
341
  }
338
- const parsed = Number.parseInt(value, 10);
339
- if (!Number.isFinite(parsed)) {
342
+ const parsed = Number(trimmed);
343
+ if (!Number.isSafeInteger(parsed)) {
340
344
  return null;
341
345
  }
342
346
  return parsed;
package/dist/index.js CHANGED
@@ -32830,22 +32830,26 @@ function parseTrailingMetadata(body) {
32830
32830
  uniqueQueries
32831
32831
  };
32832
32832
  }
32833
+ var DECIMAL_NUMBER_PATTERN = /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i;
32834
+ var INTEGER_PATTERN = /^[+-]?\d+$/;
32833
32835
  function parseNumber(value) {
32834
- if (!value) {
32836
+ const trimmed = value?.trim();
32837
+ if (!trimmed || !DECIMAL_NUMBER_PATTERN.test(trimmed)) {
32835
32838
  return null;
32836
32839
  }
32837
- const parsed = Number.parseFloat(value);
32840
+ const parsed = Number(trimmed);
32838
32841
  if (!Number.isFinite(parsed)) {
32839
32842
  return null;
32840
32843
  }
32841
32844
  return parsed;
32842
32845
  }
32843
32846
  function parseInteger(value) {
32844
- if (!value) {
32847
+ const trimmed = value?.trim();
32848
+ if (!trimmed || !INTEGER_PATTERN.test(trimmed)) {
32845
32849
  return null;
32846
32850
  }
32847
- const parsed = Number.parseInt(value, 10);
32848
- if (!Number.isFinite(parsed)) {
32851
+ const parsed = Number(trimmed);
32852
+ if (!Number.isSafeInteger(parsed)) {
32849
32853
  return null;
32850
32854
  }
32851
32855
  return parsed;
@@ -33087,7 +33091,16 @@ function resolveSessionSearchCollection(cfg, sessionId) {
33087
33091
  return `session:${sessionId}`;
33088
33092
  }
33089
33093
  function firstString(...values) {
33090
- return values.find((value) => typeof value === "string" && value.length > 0);
33094
+ for (const value of values) {
33095
+ if (typeof value !== "string") {
33096
+ continue;
33097
+ }
33098
+ const trimmed = value.trim();
33099
+ if (trimmed.length > 0) {
33100
+ return trimmed;
33101
+ }
33102
+ }
33103
+ return void 0;
33091
33104
  }
33092
33105
  function toMemorySearchResult(item) {
33093
33106
  const collection = typeof item.metadata.collection === "string" ? item.metadata.collection : "memory";
@@ -33940,7 +33953,9 @@ function isQuestionShapedRecallCandidate(text) {
33940
33953
  return normalized.includes("?") || /\bwhat\s+does\b/i.test(normalized) || /^\s*(?:who|what|when|where|why|how)\b/i.test(normalized);
33941
33954
  }
33942
33955
  function rankExactRecallCandidate(result, token) {
33943
- if (!result.text.includes(token)) return Number.NEGATIVE_INFINITY;
33956
+ if (typeof result.text !== "string" || !result.text.includes(token)) {
33957
+ return Number.NEGATIVE_INFINITY;
33958
+ }
33944
33959
  let rank = result.score;
33945
33960
  if (/\bmeans\b/i.test(result.text)) rank += 100;
33946
33961
  if (/\b(remember|durable|fact)\b/i.test(result.text)) rank += 10;
@@ -34087,7 +34102,7 @@ function buildContextEngineFactory(runtime, cfg, logger = console) {
34087
34102
  k: Math.max(EXACT_RECALL_SEARCH_K, cfg.topK ?? 0),
34088
34103
  excludeByCollection: {}
34089
34104
  });
34090
- const hit = (result.results ?? []).filter((candidate) => isExactRecallFact(candidate.text, token)).sort((a, b) => rankExactRecallCandidate(b, token) - rankExactRecallCandidate(a, token))[0];
34105
+ const hit = (result.results ?? []).filter((candidate) => typeof candidate?.text === "string" && isExactRecallFact(candidate.text, token)).sort((a, b) => rankExactRecallCandidate(b, token) - rankExactRecallCandidate(a, token))[0];
34091
34106
  if (hit) {
34092
34107
  injectedFacts.push(buildExactRecallFact(hit, token));
34093
34108
  }
@@ -34449,13 +34464,18 @@ function createSessionEndHook(runtime, logger = console) {
34449
34464
  return async (event, ctx) => {
34450
34465
  const typedEvent = asSessionEndEvent(event);
34451
34466
  const typedCtx = asAgentContext(ctx);
34467
+ const sessionId = typedEvent.sessionId ?? typedCtx.sessionId;
34468
+ const sessionKey = typedEvent.sessionKey ?? typedCtx.sessionKey;
34452
34469
  try {
34470
+ logger.info?.(
34471
+ `LibraVDB session_end sessionId=${sessionId ?? "(unknown)"} messageCount=${typedEvent.messageCount ?? "?"} durationMs=${typedEvent.durationMs ?? "?"} reason=${typedEvent.reason ?? "unknown"}`
34472
+ );
34453
34473
  await runtime.emitLifecycleHint({
34454
34474
  hook: "session_end",
34455
34475
  reason: typedEvent.reason,
34456
34476
  sessionFile: typedEvent.sessionFile,
34457
- sessionId: typedEvent.sessionId ?? typedCtx.sessionId,
34458
- sessionKey: typedEvent.sessionKey ?? typedCtx.sessionKey,
34477
+ sessionId,
34478
+ sessionKey,
34459
34479
  agentId: typedCtx.agentId,
34460
34480
  workspaceDir: typedCtx.workspaceDir,
34461
34481
  messageCount: typedEvent.messageCount,
@@ -39661,19 +39681,20 @@ function resolveConfiguredEndpoint(cfg) {
39661
39681
  if (!value || value === "auto") {
39662
39682
  return defaultEndpoint();
39663
39683
  }
39664
- if (!isConfiguredEndpoint(value)) {
39684
+ const endpoint = normalizeConfiguredEndpoint(value);
39685
+ if (!endpoint) {
39665
39686
  throw new Error(
39666
39687
  `LibraVDB sidecarPath must be a daemon endpoint like unix:/path/to/libravdb.sock or tcp:127.0.0.1:37421. Executable paths are no longer supported.`
39667
39688
  );
39668
39689
  }
39669
- return value;
39690
+ return endpoint;
39670
39691
  }
39671
39692
  function daemonProvisioningHint() {
39672
39693
  return "If you installed the npm package, install and start libravdbd separately; the package does not provision the daemon binary, ONNX Runtime, or model assets.";
39673
39694
  }
39674
39695
  function defaultEndpoint(platform = process.platform, homeDir = os2.homedir(), pathExists = fs3.existsSync) {
39675
- const envEndpoint = process.env.LIBRAVDB_RPC_ENDPOINT?.trim();
39676
- if (envEndpoint && isConfiguredEndpoint(envEndpoint)) {
39696
+ const envEndpoint = normalizeConfiguredEndpoint(process.env.LIBRAVDB_RPC_ENDPOINT);
39697
+ if (envEndpoint) {
39677
39698
  return envEndpoint;
39678
39699
  }
39679
39700
  if (platform === "win32") {
@@ -39766,6 +39787,17 @@ function isConfiguredEndpoint(value) {
39766
39787
  const port = Number(address.slice(separator + 1));
39767
39788
  return host.length > 0 && Number.isInteger(port) && port > 0 && port <= 65535;
39768
39789
  }
39790
+ function normalizeConfiguredEndpoint(value) {
39791
+ const trimmed = value?.trim();
39792
+ if (!trimmed || trimmed === "auto") {
39793
+ return null;
39794
+ }
39795
+ if (trimmed.startsWith("unix:")) {
39796
+ const socketPath = trimmed.slice("unix:".length).trim();
39797
+ return socketPath ? `unix:${socketPath}` : null;
39798
+ }
39799
+ return isConfiguredEndpoint(trimmed) ? trimmed : null;
39800
+ }
39769
39801
  function sleep2(delayMs) {
39770
39802
  return new Promise((resolve) => setTimeout(resolve, delayMs));
39771
39803
  }
@@ -40025,19 +40057,10 @@ function register(api) {
40025
40057
  });
40026
40058
  api.on("before_reset", createBeforeResetHook(runtime, api.logger ?? console));
40027
40059
  api.on("session_end", createSessionEndHook(runtime, api.logger ?? console));
40028
- api.on("agent_end", async (event) => {
40029
- const e = asRecord(event) ?? {};
40030
- logger.info?.(
40031
- `LibraVDB agent_end success=${e.success ?? "unknown"} durationMs=${e.durationMs ?? "?"} error=${typeof e.error === "string" ? e.error : "none"}`
40032
- );
40033
- });
40034
40060
  api.on("gateway_stop", async () => {
40035
40061
  await runtime.shutdown();
40036
40062
  });
40037
40063
  }
40038
- function asRecord(value) {
40039
- return typeof value === "object" && value !== null ? value : null;
40040
- }
40041
40064
  var index_default = definePluginEntry({
40042
40065
  id: MEMORY_ID,
40043
40066
  name: "LibraVDB Memory",
@@ -24,13 +24,19 @@ export function createSessionEndHook(runtime, logger = console) {
24
24
  return async (event, ctx) => {
25
25
  const typedEvent = asSessionEndEvent(event);
26
26
  const typedCtx = asAgentContext(ctx);
27
+ const sessionId = typedEvent.sessionId ?? typedCtx.sessionId;
28
+ const sessionKey = typedEvent.sessionKey ?? typedCtx.sessionKey;
27
29
  try {
30
+ logger.info?.(`LibraVDB session_end sessionId=${sessionId ?? "(unknown)"} ` +
31
+ `messageCount=${typedEvent.messageCount ?? "?"} ` +
32
+ `durationMs=${typedEvent.durationMs ?? "?"} ` +
33
+ `reason=${typedEvent.reason ?? "unknown"}`);
28
34
  await runtime.emitLifecycleHint({
29
35
  hook: "session_end",
30
36
  reason: typedEvent.reason,
31
37
  sessionFile: typedEvent.sessionFile,
32
- sessionId: typedEvent.sessionId ?? typedCtx.sessionId,
33
- sessionKey: typedEvent.sessionKey ?? typedCtx.sessionKey,
38
+ sessionId,
39
+ sessionKey,
34
40
  agentId: typedCtx.agentId,
35
41
  workspaceDir: typedCtx.workspaceDir,
36
42
  messageCount: typedEvent.messageCount,
@@ -161,7 +161,16 @@ function resolveSessionSearchCollection(cfg, sessionId) {
161
161
  return `session:${sessionId}`;
162
162
  }
163
163
  function firstString(...values) {
164
- return values.find((value) => typeof value === "string" && value.length > 0);
164
+ for (const value of values) {
165
+ if (typeof value !== "string") {
166
+ continue;
167
+ }
168
+ const trimmed = value.trim();
169
+ if (trimmed.length > 0) {
170
+ return trimmed;
171
+ }
172
+ }
173
+ return undefined;
165
174
  }
166
175
  function toMemorySearchResult(item) {
167
176
  const collection = typeof item.metadata.collection === "string" ? item.metadata.collection : "memory";
package/dist/sidecar.js CHANGED
@@ -351,18 +351,19 @@ export function resolveConfiguredEndpoint(cfg) {
351
351
  if (!value || value === "auto") {
352
352
  return defaultEndpoint();
353
353
  }
354
- if (!isConfiguredEndpoint(value)) {
354
+ const endpoint = normalizeConfiguredEndpoint(value);
355
+ if (!endpoint) {
355
356
  throw new Error(`LibraVDB sidecarPath must be a daemon endpoint like unix:/path/to/libravdb.sock or tcp:127.0.0.1:37421. Executable paths are no longer supported.`);
356
357
  }
357
- return value;
358
+ return endpoint;
358
359
  }
359
360
  export function daemonProvisioningHint() {
360
361
  return "If you installed the npm package, install and start libravdbd separately; the package does not provision the daemon binary, ONNX Runtime, or model assets.";
361
362
  }
362
363
  export function defaultEndpoint(platform = process.platform, homeDir = os.homedir(), pathExists = fs.existsSync) {
363
364
  // Honour the daemon's own env var first (set by Homebrew LaunchAgent / systemd unit).
364
- const envEndpoint = process.env.LIBRAVDB_RPC_ENDPOINT?.trim();
365
- if (envEndpoint && isConfiguredEndpoint(envEndpoint)) {
365
+ const envEndpoint = normalizeConfiguredEndpoint(process.env.LIBRAVDB_RPC_ENDPOINT);
366
+ if (envEndpoint) {
366
367
  return envEndpoint;
367
368
  }
368
369
  if (platform === "win32") {
@@ -525,6 +526,17 @@ function isConfiguredEndpoint(value) {
525
526
  const port = Number(address.slice(separator + 1));
526
527
  return host.length > 0 && Number.isInteger(port) && port > 0 && port <= 65535;
527
528
  }
529
+ function normalizeConfiguredEndpoint(value) {
530
+ const trimmed = value?.trim();
531
+ if (!trimmed || trimmed === "auto") {
532
+ return null;
533
+ }
534
+ if (trimmed.startsWith("unix:")) {
535
+ const socketPath = trimmed.slice("unix:".length).trim();
536
+ return socketPath ? `unix:${socketPath}` : null;
537
+ }
538
+ return isConfiguredEndpoint(trimmed) ? trimmed : null;
539
+ }
528
540
  export { PlaceholderSocket };
529
541
  function sleep(delayMs) {
530
542
  return new Promise((resolve) => setTimeout(resolve, delayMs));
@@ -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.62",
5
+ "version": "1.4.64",
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.62",
3
+ "version": "1.4.64",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",