@xdarkicex/openclaw-memory-libravdb 1.4.72 → 1.4.74

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
@@ -32966,6 +32976,7 @@ function buildMemoryRuntimeBridge(getRpc, cfg) {
32966
32976
  function createMemorySearchManager(getRpc, cfg, defaults, initialStatus) {
32967
32977
  let cachedStatus = initialStatus;
32968
32978
  let cachedIdentityUserId = null;
32979
+ const returnedSearchPaths = /* @__PURE__ */ new Set();
32969
32980
  function getResolvedUserId(sessionKey) {
32970
32981
  if (cachedIdentityUserId !== null) return cachedIdentityUserId;
32971
32982
  cachedIdentityUserId = resolveIdentity({
@@ -33018,9 +33029,16 @@ function createMemorySearchManager(getRpc, cfg, defaults, initialStatus) {
33018
33029
  if (legacyCall) {
33019
33030
  return { results: legacyResults };
33020
33031
  }
33021
- return filteredResults.map(toMemorySearchResult);
33032
+ const memoryResults = filteredResults.map(toMemorySearchResult);
33033
+ for (const item of memoryResults) {
33034
+ returnedSearchPaths.add(item.path);
33035
+ }
33036
+ return memoryResults;
33022
33037
  },
33023
33038
  async readFile(params) {
33039
+ if (!returnedSearchPaths.has(params.relPath)) {
33040
+ throw new Error("LibraVDB memory path was not returned by this search manager");
33041
+ }
33024
33042
  const located = await loadSearchResultText(getRpc, params.relPath);
33025
33043
  const fromLine = Math.max(1, params.from ?? 1);
33026
33044
  const lineCount = Math.max(1, params.lines ?? 200);
@@ -33074,7 +33092,7 @@ function resolveSearchCollections(cfg, userId, sessionId) {
33074
33092
  if (cfg.crossSessionRecall === false) {
33075
33093
  return sessionId ? [resolveSessionSearchCollection(cfg, sessionId)] : [];
33076
33094
  }
33077
- const collections = [`user:${userId}`, "global"];
33095
+ const collections = [resolveUserCollection(userId), "global"];
33078
33096
  if (!sessionId) {
33079
33097
  return collections;
33080
33098
  }
@@ -33361,9 +33379,19 @@ async function runDeepStatusProbe(rpc, cfg) {
33361
33379
  identityPath: cfg.identityPath,
33362
33380
  noAutoPersist: true
33363
33381
  });
33364
- const durableCollections = [`user:${userId}`, "global"];
33365
- const allCollections = [...AUTHORED_STATUS_COLLECTIONS, ...durableCollections];
33366
33382
  const probes = [];
33383
+ let userCollection = null;
33384
+ try {
33385
+ userCollection = resolveUserCollection(userId);
33386
+ } catch (error) {
33387
+ probes.push({
33388
+ ok: false,
33389
+ collection: "user:<invalid>",
33390
+ error: formatError(error)
33391
+ });
33392
+ }
33393
+ const durableCollections = userCollection ? [userCollection, "global"] : ["global"];
33394
+ const allCollections = [...AUTHORED_STATUS_COLLECTIONS, ...durableCollections];
33367
33395
  for (const collection of allCollections) {
33368
33396
  try {
33369
33397
  const result = await rpc.call("search_text", {
@@ -34123,7 +34151,7 @@ function buildContextEngineFactory(runtime, cfg, logger = console) {
34123
34151
  for (const token of missingTokens) {
34124
34152
  try {
34125
34153
  const result = await rpc.call("search_text_collections", {
34126
- collections: [`user:${args.userId}`, "global"],
34154
+ collections: [resolveUserCollection(args.userId), "global"],
34127
34155
  text: token,
34128
34156
  k: Math.max(EXACT_RECALL_SEARCH_K, cfg.topK ?? 0),
34129
34157
  excludeByCollection: {}
@@ -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) {
@@ -22,6 +22,7 @@ export function buildMemoryRuntimeBridge(getRpc, cfg) {
22
22
  function createMemorySearchManager(getRpc, cfg, defaults, initialStatus) {
23
23
  let cachedStatus = initialStatus;
24
24
  let cachedIdentityUserId = null;
25
+ const returnedSearchPaths = new Set();
25
26
  function getResolvedUserId(sessionKey) {
26
27
  if (cachedIdentityUserId !== null)
27
28
  return cachedIdentityUserId;
@@ -82,9 +83,16 @@ function createMemorySearchManager(getRpc, cfg, defaults, initialStatus) {
82
83
  if (legacyCall) {
83
84
  return { results: legacyResults };
84
85
  }
85
- return filteredResults.map(toMemorySearchResult);
86
+ const memoryResults = filteredResults.map(toMemorySearchResult);
87
+ for (const item of memoryResults) {
88
+ returnedSearchPaths.add(item.path);
89
+ }
90
+ return memoryResults;
86
91
  },
87
92
  async readFile(params) {
93
+ if (!returnedSearchPaths.has(params.relPath)) {
94
+ throw new Error("LibraVDB memory path was not returned by this search manager");
95
+ }
88
96
  const located = await loadSearchResultText(getRpc, params.relPath);
89
97
  const fromLine = Math.max(1, params.from ?? 1);
90
98
  const lineCount = Math.max(1, params.lines ?? 200);
@@ -144,7 +152,7 @@ function resolveSearchCollections(cfg, userId, sessionId) {
144
152
  if (cfg.crossSessionRecall === false) {
145
153
  return sessionId ? [resolveSessionSearchCollection(cfg, sessionId)] : [];
146
154
  }
147
- const collections = [`user:${userId}`, "global"];
155
+ const collections = [resolveUserCollection(userId), "global"];
148
156
  if (!sessionId) {
149
157
  return collections;
150
158
  }
@@ -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
  }
@@ -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.72",
5
+ "version": "1.4.74",
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.72",
3
+ "version": "1.4.74",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",