@xdarkicex/openclaw-memory-libravdb 1.4.71 → 1.4.73

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
@@ -1,7 +1,7 @@
1
1
  import { createInterface } from "node:readline/promises";
2
2
  import { stdin, stdout } from "node:process";
3
3
  import { MEMORY_CLI_DESCRIPTOR, isMemorySlotSelected } from "./cli-descriptors.js";
4
- import { resolveDurableNamespace } from "./memory-scopes.js";
4
+ import { resolveDurableNamespace, resolveUserCollection } from "./memory-scopes.js";
5
5
  import { resolveIdentity } from "./identity.js";
6
6
  import { formatError } from "./format-error.js";
7
7
  import { promoteDreamDiaryFile } from "./dream-promotion.js";
@@ -205,9 +205,20 @@ async function runDeepStatusProbe(rpc, cfg) {
205
205
  identityPath: cfg.identityPath,
206
206
  noAutoPersist: true,
207
207
  });
208
- const durableCollections = [`user:${userId}`, "global"];
209
- const allCollections = [...AUTHORED_STATUS_COLLECTIONS, ...durableCollections];
210
208
  const probes = [];
209
+ let userCollection = null;
210
+ try {
211
+ userCollection = resolveUserCollection(userId);
212
+ }
213
+ catch (error) {
214
+ probes.push({
215
+ ok: false,
216
+ collection: "user:<invalid>",
217
+ error: formatError(error),
218
+ });
219
+ }
220
+ const durableCollections = userCollection ? [userCollection, "global"] : ["global"];
221
+ const allCollections = [...AUTHORED_STATUS_COLLECTIONS, ...durableCollections];
211
222
  for (const collection of allCollections) {
212
223
  try {
213
224
  const result = await rpc.call("search_text", {
@@ -1,4 +1,5 @@
1
1
  import { resolveIdentity } from "./identity.js";
2
+ import { resolveUserCollection } from "./memory-scopes.js";
2
3
  const APPROX_CHARS_PER_TOKEN = 4;
3
4
  const ASSEMBLE_BUDGET_HEADROOM_TOKENS = 256;
4
5
  const DEFAULT_COMPACTION_THRESHOLD_FRACTION = 0.8;
@@ -489,7 +490,7 @@ export function buildContextEngineFactory(runtime, cfg, logger = console) {
489
490
  for (const token of missingTokens) {
490
491
  try {
491
492
  const result = await rpc.call("search_text_collections", {
492
- collections: [`user:${args.userId}`, "global"],
493
+ collections: [resolveUserCollection(args.userId), "global"],
493
494
  text: token,
494
495
  k: Math.max(EXACT_RECALL_SEARCH_K, cfg.topK ?? 0),
495
496
  excludeByCollection: {},
@@ -1,3 +1,4 @@
1
+ import { validateNamespace } from "./memory-scopes.js";
1
2
  const DREAM_COLLECTION_PREFIX = "dream:";
2
3
  const DREAM_PATTERN_RULES = [
3
4
  {
@@ -48,5 +49,6 @@ export function detectDreamQuerySignal(queryText) {
48
49
  };
49
50
  }
50
51
  export function resolveDreamCollection(userId) {
51
- return `${DREAM_COLLECTION_PREFIX}${userId.trim()}`;
52
+ const namespace = validateNamespace(userId.trim());
53
+ return validateNamespace(`${DREAM_COLLECTION_PREFIX}${namespace}`);
52
54
  }
package/dist/index.js CHANGED
@@ -32164,6 +32164,7 @@ function registerMemoryCliMetadata(api) {
32164
32164
  // src/memory-scopes.ts
32165
32165
  var SESSION_KEY_NAMESPACE_PREFIX = "session-key:";
32166
32166
  var AGENT_ID_NAMESPACE_PREFIX = "agent-id:";
32167
+ var USER_COLLECTION_PREFIX = "user:";
32167
32168
  var COLLECTION_NAME_RE = /^[a-zA-Z][a-zA-Z0-9_.:@#-]{0,127}$/;
32168
32169
  function validateNamespace(name) {
32169
32170
  if (!COLLECTION_NAME_RE.test(name)) {
@@ -32184,6 +32185,14 @@ function resolveDurableNamespace(params) {
32184
32185
  if (fallback) return validateNamespace(fallback);
32185
32186
  return "default";
32186
32187
  }
32188
+ function resolveUserCollection(userId) {
32189
+ const namespace = firstNonEmpty(userId);
32190
+ if (!namespace) {
32191
+ throw new Error("Invalid user collection namespace: userId must be non-empty");
32192
+ }
32193
+ validateNamespace(namespace);
32194
+ return validateNamespace(`${USER_COLLECTION_PREFIX}${namespace}`);
32195
+ }
32187
32196
  function firstNonEmpty(value) {
32188
32197
  if (typeof value !== "string") return void 0;
32189
32198
  const trimmed = value.trim();
@@ -32944,7 +32953,8 @@ function detectDreamQuerySignal(queryText) {
32944
32953
  };
32945
32954
  }
32946
32955
  function resolveDreamCollection(userId) {
32947
- return `${DREAM_COLLECTION_PREFIX}${userId.trim()}`;
32956
+ const namespace = validateNamespace(userId.trim());
32957
+ return validateNamespace(`${DREAM_COLLECTION_PREFIX}${namespace}`);
32948
32958
  }
32949
32959
 
32950
32960
  // src/memory-runtime.ts
@@ -33074,7 +33084,7 @@ function resolveSearchCollections(cfg, userId, sessionId) {
33074
33084
  if (cfg.crossSessionRecall === false) {
33075
33085
  return sessionId ? [resolveSessionSearchCollection(cfg, sessionId)] : [];
33076
33086
  }
33077
- const collections = [`user:${userId}`, "global"];
33087
+ const collections = [resolveUserCollection(userId), "global"];
33078
33088
  if (!sessionId) {
33079
33089
  return collections;
33080
33090
  }
@@ -33361,9 +33371,19 @@ async function runDeepStatusProbe(rpc, cfg) {
33361
33371
  identityPath: cfg.identityPath,
33362
33372
  noAutoPersist: true
33363
33373
  });
33364
- const durableCollections = [`user:${userId}`, "global"];
33365
- const allCollections = [...AUTHORED_STATUS_COLLECTIONS, ...durableCollections];
33366
33374
  const probes = [];
33375
+ let userCollection = null;
33376
+ try {
33377
+ userCollection = resolveUserCollection(userId);
33378
+ } catch (error) {
33379
+ probes.push({
33380
+ ok: false,
33381
+ collection: "user:<invalid>",
33382
+ error: formatError(error)
33383
+ });
33384
+ }
33385
+ const durableCollections = userCollection ? [userCollection, "global"] : ["global"];
33386
+ const allCollections = [...AUTHORED_STATUS_COLLECTIONS, ...durableCollections];
33367
33387
  for (const collection of allCollections) {
33368
33388
  try {
33369
33389
  const result = await rpc.call("search_text", {
@@ -34123,7 +34143,7 @@ function buildContextEngineFactory(runtime, cfg, logger = console) {
34123
34143
  for (const token of missingTokens) {
34124
34144
  try {
34125
34145
  const result = await rpc.call("search_text_collections", {
34126
- collections: [`user:${args.userId}`, "global"],
34146
+ collections: [resolveUserCollection(args.userId), "global"],
34127
34147
  text: token,
34128
34148
  k: Math.max(EXACT_RECALL_SEARCH_K, cfg.topK ?? 0),
34129
34149
  excludeByCollection: {}
@@ -39904,17 +39924,18 @@ function defaultEndpoint(platform = process.platform, homeDir = os3.homedir(), p
39904
39924
  if (platform === "win32") {
39905
39925
  return "tcp:127.0.0.1:37421";
39906
39926
  }
39927
+ const joinSocketPath = path4.posix.join;
39907
39928
  const sockName = "libravdb.sock";
39908
39929
  const candidateDirs = [
39909
39930
  // User-local (npm plugin convention)
39910
- homeDir?.trim() ? path4.join(homeDir, ".libravdbd", "run") : null,
39931
+ homeDir?.trim() ? joinSocketPath(homeDir, ".libravdbd", "run") : null,
39911
39932
  // Homebrew (Apple Silicon) — matches the Homebrew formula LaunchAgent
39912
39933
  "/opt/homebrew/var/libravdbd/run",
39913
39934
  // Homebrew (Intel Mac) / manual Linux installs
39914
39935
  "/usr/local/var/libravdbd/run"
39915
39936
  ].filter((d) => d !== null);
39916
39937
  for (const dir of candidateDirs) {
39917
- const sockPath = path4.join(dir, sockName);
39938
+ const sockPath = joinSocketPath(dir, sockName);
39918
39939
  try {
39919
39940
  if (pathExists(sockPath)) {
39920
39941
  return `unix:${sockPath}`;
@@ -39922,8 +39943,8 @@ function defaultEndpoint(platform = process.platform, homeDir = os3.homedir(), p
39922
39943
  } catch {
39923
39944
  }
39924
39945
  }
39925
- const baseDir = homeDir?.trim() ? path4.join(homeDir, ".libravdbd", "run") : path4.join(".", ".libravdbd", "run");
39926
- return `unix:${path4.join(baseDir, sockName)}`;
39946
+ const baseDir = homeDir?.trim() ? joinSocketPath(homeDir, ".libravdbd", "run") : joinSocketPath(".", ".libravdbd", "run");
39947
+ return `unix:${joinSocketPath(baseDir, sockName)}`;
39927
39948
  }
39928
39949
  function createDefaultRuntime() {
39929
39950
  return {
@@ -1,4 +1,4 @@
1
- import { resolveDurableNamespace } from "./memory-scopes.js";
1
+ import { resolveDurableNamespace, resolveUserCollection } from "./memory-scopes.js";
2
2
  import { resolveIdentity } from "./identity.js";
3
3
  import { detectDreamQuerySignal, resolveDreamCollection } from "./dream-routing.js";
4
4
  export function buildMemoryRuntimeBridge(getRpc, cfg) {
@@ -144,7 +144,7 @@ function resolveSearchCollections(cfg, userId, sessionId) {
144
144
  if (cfg.crossSessionRecall === false) {
145
145
  return sessionId ? [resolveSessionSearchCollection(cfg, sessionId)] : [];
146
146
  }
147
- const collections = [`user:${userId}`, "global"];
147
+ const collections = [resolveUserCollection(userId), "global"];
148
148
  if (!sessionId) {
149
149
  return collections;
150
150
  }
@@ -16,6 +16,7 @@ export declare function resolveDurableNamespace(params: {
16
16
  agentId?: string;
17
17
  fallback?: string;
18
18
  }): string;
19
+ export declare function resolveUserCollection(userId: string): string;
19
20
  export declare function resolveScopes(params: {
20
21
  userId: string;
21
22
  sessionId?: string;
@@ -1,5 +1,6 @@
1
1
  const SESSION_KEY_NAMESPACE_PREFIX = "session-key:";
2
2
  const AGENT_ID_NAMESPACE_PREFIX = "agent-id:";
3
+ const USER_COLLECTION_PREFIX = "user:";
3
4
  /** Valid collection names: alphanumeric, underscores, hyphens, dots, colons, at-signs, hashes.
4
5
  * Must start with a letter. Max 128 characters. */
5
6
  const COLLECTION_NAME_RE = /^[a-zA-Z][a-zA-Z0-9_.:@#-]{0,127}$/;
@@ -26,10 +27,18 @@ export function resolveDurableNamespace(params) {
26
27
  return validateNamespace(fallback);
27
28
  return "default";
28
29
  }
30
+ export function resolveUserCollection(userId) {
31
+ const namespace = firstNonEmpty(userId);
32
+ if (!namespace) {
33
+ throw new Error("Invalid user collection namespace: userId must be non-empty");
34
+ }
35
+ validateNamespace(namespace);
36
+ return validateNamespace(`${USER_COLLECTION_PREFIX}${namespace}`);
37
+ }
29
38
  export function resolveScopes(params) {
30
39
  return {
31
40
  session: params.sessionId ? `session:${params.sessionId}` : "session:default",
32
- user: params.crossSessionRecall !== false ? `user:${params.userId}` : null,
41
+ user: params.crossSessionRecall !== false ? resolveUserCollection(params.userId) : null,
33
42
  global: "global",
34
43
  };
35
44
  }
package/dist/sidecar.js CHANGED
@@ -369,17 +369,18 @@ export function defaultEndpoint(platform = process.platform, homeDir = os.homedi
369
369
  if (platform === "win32") {
370
370
  return "tcp:127.0.0.1:37421";
371
371
  }
372
+ const joinSocketPath = path.posix.join;
372
373
  const sockName = "libravdb.sock";
373
374
  const candidateDirs = [
374
375
  // User-local (npm plugin convention)
375
- homeDir?.trim() ? path.join(homeDir, ".libravdbd", "run") : null,
376
+ homeDir?.trim() ? joinSocketPath(homeDir, ".libravdbd", "run") : null,
376
377
  // Homebrew (Apple Silicon) — matches the Homebrew formula LaunchAgent
377
378
  "/opt/homebrew/var/libravdbd/run",
378
379
  // Homebrew (Intel Mac) / manual Linux installs
379
380
  "/usr/local/var/libravdbd/run",
380
381
  ].filter((d) => d !== null);
381
382
  for (const dir of candidateDirs) {
382
- const sockPath = path.join(dir, sockName);
383
+ const sockPath = joinSocketPath(dir, sockName);
383
384
  try {
384
385
  if (pathExists(sockPath)) {
385
386
  return `unix:${sockPath}`;
@@ -391,9 +392,9 @@ export function defaultEndpoint(platform = process.platform, homeDir = os.homedi
391
392
  }
392
393
  // Fallback to the original user-local path so error messages stay familiar.
393
394
  const baseDir = homeDir?.trim()
394
- ? path.join(homeDir, ".libravdbd", "run")
395
- : path.join(".", ".libravdbd", "run");
396
- return `unix:${path.join(baseDir, sockName)}`;
395
+ ? joinSocketPath(homeDir, ".libravdbd", "run")
396
+ : joinSocketPath(".", ".libravdbd", "run");
397
+ return `unix:${joinSocketPath(baseDir, sockName)}`;
397
398
  }
398
399
  export function buildSidecarEnv(cfg) {
399
400
  const env = {};
@@ -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.71",
5
+ "version": "1.4.73",
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.71",
3
+ "version": "1.4.73",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",