@xdarkicex/openclaw-memory-libravdb 1.4.60 → 1.4.62
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/index.js +32 -9
- package/dist/memory-scopes.d.ts +3 -0
- package/dist/memory-scopes.js +18 -4
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -32164,14 +32164,25 @@ 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 COLLECTION_NAME_RE = /^[a-zA-Z][a-zA-Z0-9_.:@#-]{0,127}$/;
|
|
32168
|
+
function validateNamespace(name) {
|
|
32169
|
+
if (!COLLECTION_NAME_RE.test(name)) {
|
|
32170
|
+
throw new Error(
|
|
32171
|
+
`Invalid collection namespace: "${name}". Must match ${COLLECTION_NAME_RE.source}`
|
|
32172
|
+
);
|
|
32173
|
+
}
|
|
32174
|
+
return name;
|
|
32175
|
+
}
|
|
32167
32176
|
function resolveDurableNamespace(params) {
|
|
32168
32177
|
const explicitUserId = firstNonEmpty(params.userId);
|
|
32169
|
-
if (explicitUserId) return explicitUserId;
|
|
32178
|
+
if (explicitUserId) return validateNamespace(explicitUserId);
|
|
32170
32179
|
const sessionKey = firstNonEmpty(params.sessionKey);
|
|
32171
|
-
if (sessionKey) return `${SESSION_KEY_NAMESPACE_PREFIX}${sessionKey}
|
|
32180
|
+
if (sessionKey) return validateNamespace(`${SESSION_KEY_NAMESPACE_PREFIX}${sessionKey}`);
|
|
32172
32181
|
const agentId = firstNonEmpty(params.agentId);
|
|
32173
|
-
if (agentId) return `${AGENT_ID_NAMESPACE_PREFIX}${agentId}
|
|
32174
|
-
|
|
32182
|
+
if (agentId) return validateNamespace(`${AGENT_ID_NAMESPACE_PREFIX}${agentId}`);
|
|
32183
|
+
const fallback = firstNonEmpty(params.fallback);
|
|
32184
|
+
if (fallback) return validateNamespace(fallback);
|
|
32185
|
+
return "default";
|
|
32175
32186
|
}
|
|
32176
32187
|
function firstNonEmpty(value) {
|
|
32177
32188
|
if (typeof value !== "string") return void 0;
|
|
@@ -39911,6 +39922,21 @@ function register(api) {
|
|
|
39911
39922
|
logger.info?.(
|
|
39912
39923
|
`LibraVDB registering mode=${registrationMode} lightweight=${isLightweight} discovery=${isDiscovery} userId=${cfg.userId ?? "(auto)"} crossSessionRecall=${cfg.crossSessionRecall !== false}`
|
|
39913
39924
|
);
|
|
39925
|
+
const memSlot = api.config?.plugins?.slots?.memory;
|
|
39926
|
+
if (!isLightweight && !isDiscovery) {
|
|
39927
|
+
if (memSlot && memSlot !== MEMORY_ID && memSlot !== "none") {
|
|
39928
|
+
throw new Error(
|
|
39929
|
+
`[libravdb-memory] plugins.slots.memory is "${memSlot}". Set it to "libravdb-memory" before enabling this plugin.`
|
|
39930
|
+
);
|
|
39931
|
+
}
|
|
39932
|
+
if (memSlot === "none") {
|
|
39933
|
+
logger.info?.(
|
|
39934
|
+
'[libravdb-memory] plugins.slots.memory is "none"; skipping memory capability, context engine, embedding providers, services, and hooks.'
|
|
39935
|
+
);
|
|
39936
|
+
registerMemoryCli(api, null, cfg, logger);
|
|
39937
|
+
return;
|
|
39938
|
+
}
|
|
39939
|
+
}
|
|
39914
39940
|
const runtimeOrNull = isLightweight ? null : createPluginRuntime(cfg, logger);
|
|
39915
39941
|
registerMemoryCli(api, runtimeOrNull, cfg, logger);
|
|
39916
39942
|
if (isLightweight || isDiscovery) {
|
|
@@ -39927,11 +39953,8 @@ function register(api) {
|
|
|
39927
39953
|
}
|
|
39928
39954
|
const runtime = runtimeOrNull;
|
|
39929
39955
|
if (!runtime) return;
|
|
39930
|
-
|
|
39931
|
-
|
|
39932
|
-
throw new Error(
|
|
39933
|
-
`[libravdb-memory] plugins.slots.memory is "${memSlot}". Set it to "libravdb-memory" before enabling this plugin.`
|
|
39934
|
-
);
|
|
39956
|
+
if (!memSlot) {
|
|
39957
|
+
logger.warn?.('[libravdb-memory] plugins.slots.memory is unset; set it to "libravdb-memory" for memory to work.');
|
|
39935
39958
|
}
|
|
39936
39959
|
api.registerMemoryCapability(MEMORY_ID, {
|
|
39937
39960
|
promptBuilder: buildMemoryPromptSection(runtime.getRpc, cfg),
|
package/dist/memory-scopes.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/** Validate and return a collection-safe namespace.
|
|
2
|
+
* Throws on invalid characters or length. */
|
|
3
|
+
export declare function validateNamespace(name: string): string;
|
|
1
4
|
export type RetrievalScopes = {
|
|
2
5
|
/** Always queried — fresh context bound to this session. */
|
|
3
6
|
session: string;
|
package/dist/memory-scopes.js
CHANGED
|
@@ -1,16 +1,30 @@
|
|
|
1
1
|
const SESSION_KEY_NAMESPACE_PREFIX = "session-key:";
|
|
2
2
|
const AGENT_ID_NAMESPACE_PREFIX = "agent-id:";
|
|
3
|
+
/** Valid collection names: alphanumeric, underscores, hyphens, dots, colons, at-signs, hashes.
|
|
4
|
+
* Must start with a letter. Max 128 characters. */
|
|
5
|
+
const COLLECTION_NAME_RE = /^[a-zA-Z][a-zA-Z0-9_.:@#-]{0,127}$/;
|
|
6
|
+
/** Validate and return a collection-safe namespace.
|
|
7
|
+
* Throws on invalid characters or length. */
|
|
8
|
+
export function validateNamespace(name) {
|
|
9
|
+
if (!COLLECTION_NAME_RE.test(name)) {
|
|
10
|
+
throw new Error(`Invalid collection namespace: "${name}". Must match ${COLLECTION_NAME_RE.source}`);
|
|
11
|
+
}
|
|
12
|
+
return name;
|
|
13
|
+
}
|
|
3
14
|
export function resolveDurableNamespace(params) {
|
|
4
15
|
const explicitUserId = firstNonEmpty(params.userId);
|
|
5
16
|
if (explicitUserId)
|
|
6
|
-
return explicitUserId;
|
|
17
|
+
return validateNamespace(explicitUserId);
|
|
7
18
|
const sessionKey = firstNonEmpty(params.sessionKey);
|
|
8
19
|
if (sessionKey)
|
|
9
|
-
return `${SESSION_KEY_NAMESPACE_PREFIX}${sessionKey}
|
|
20
|
+
return validateNamespace(`${SESSION_KEY_NAMESPACE_PREFIX}${sessionKey}`);
|
|
10
21
|
const agentId = firstNonEmpty(params.agentId);
|
|
11
22
|
if (agentId)
|
|
12
|
-
return `${AGENT_ID_NAMESPACE_PREFIX}${agentId}
|
|
13
|
-
|
|
23
|
+
return validateNamespace(`${AGENT_ID_NAMESPACE_PREFIX}${agentId}`);
|
|
24
|
+
const fallback = firstNonEmpty(params.fallback);
|
|
25
|
+
if (fallback)
|
|
26
|
+
return validateNamespace(fallback);
|
|
27
|
+
return "default";
|
|
14
28
|
}
|
|
15
29
|
export function resolveScopes(params) {
|
|
16
30
|
return {
|
package/openclaw.plugin.json
CHANGED