@modelstudio/modelstudio-memory-for-openclaw 1.0.2 → 1.0.4
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/index.ts +20 -9
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -78,6 +78,7 @@ const ALLOWED_KEYS = [
|
|
|
78
78
|
"captureMaxMessages",
|
|
79
79
|
"recallMinPromptLength",
|
|
80
80
|
"recallCacheTtlMs",
|
|
81
|
+
"enabled",
|
|
81
82
|
];
|
|
82
83
|
|
|
83
84
|
function assertAllowedKeys(
|
|
@@ -92,10 +93,14 @@ function assertAllowedKeys(
|
|
|
92
93
|
|
|
93
94
|
const modelstudioMemoryConfigSchema = {
|
|
94
95
|
parse(value: unknown): BailianMemoryConfig {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
let raw =
|
|
97
|
+
value && typeof value === "object" && !Array.isArray(value)
|
|
98
|
+
? (value as Record<string, unknown>)
|
|
99
|
+
: {};
|
|
100
|
+
const cfg =
|
|
101
|
+
"config" in raw && raw.config && typeof raw.config === "object" && !Array.isArray(raw.config)
|
|
102
|
+
? (raw.config as Record<string, unknown>)
|
|
103
|
+
: raw;
|
|
99
104
|
assertAllowedKeys(cfg, ALLOWED_KEYS, "modelstudio-memory-for-openclaw config");
|
|
100
105
|
|
|
101
106
|
// apiKey: allow empty at parse time; tools return config prompt when missing
|
|
@@ -358,7 +363,7 @@ function stripInjectedContext(text: string): string {
|
|
|
358
363
|
}
|
|
359
364
|
|
|
360
365
|
const CONFIG_REQUIRED_MESSAGE =
|
|
361
|
-
"Memory plugin is not configured. Please add apiKey and userId to ~/.openclaw/openclaw.json under plugins.entries.modelstudio-memory-for-openclaw.config
|
|
366
|
+
"Memory plugin is not configured. Please add apiKey and userId to ~/.openclaw/openclaw.json under plugins.entries.modelstudio-memory-for-openclaw.config";
|
|
362
367
|
|
|
363
368
|
// ============================================================================
|
|
364
369
|
// Plugin Definition
|
|
@@ -381,9 +386,10 @@ const modelstudioMemoryPlugin = {
|
|
|
381
386
|
);
|
|
382
387
|
|
|
383
388
|
if (!cfg.apiKey) {
|
|
384
|
-
|
|
385
|
-
"modelstudio-memory
|
|
386
|
-
);
|
|
389
|
+
const msg =
|
|
390
|
+
"[modelstudio-memory] apiKey not configured. Memory features disabled. Add apiKey to ~/.openclaw/openclaw.json under plugins.entries.modelstudio-memory-for-openclaw.config";
|
|
391
|
+
api.logger.warn(msg);
|
|
392
|
+
console.warn(msg);
|
|
387
393
|
}
|
|
388
394
|
api.logger.info(
|
|
389
395
|
`modelstudio-memory: registered (user: ${cfg.userId}, autoCapture: ${cfg.autoCapture}, autoRecall: ${cfg.autoRecall})`
|
|
@@ -722,7 +728,12 @@ const modelstudioMemoryPlugin = {
|
|
|
722
728
|
// ========== autoRecall ==========
|
|
723
729
|
if (cfg.autoRecall) {
|
|
724
730
|
api.on("before_agent_start", async (event) => {
|
|
725
|
-
if (!cfg.apiKey)
|
|
731
|
+
if (!cfg.apiKey) {
|
|
732
|
+
return {
|
|
733
|
+
prependSystemContext:
|
|
734
|
+
"Note: Memory plugin is not configured (apiKey missing). Long-term memory is disabled. Ask the user to add apiKey to ~/.openclaw/openclaw.json under plugins.entries.modelstudio-memory-for-openclaw.config and restart the gateway.",
|
|
735
|
+
};
|
|
736
|
+
}
|
|
726
737
|
const prompt = extractTextContent(event.prompt);
|
|
727
738
|
if (!prompt || prompt.length < cfg.recallMinPromptLength) {
|
|
728
739
|
return;
|
package/openclaw.plugin.json
CHANGED