@modelstudio/modelstudio-memory-for-openclaw 1.0.5 → 1.0.7
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 +36 -13
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -78,7 +78,6 @@ const ALLOWED_KEYS = [
|
|
|
78
78
|
"captureMaxMessages",
|
|
79
79
|
"recallMinPromptLength",
|
|
80
80
|
"recallCacheTtlMs",
|
|
81
|
-
"enabled",
|
|
82
81
|
];
|
|
83
82
|
|
|
84
83
|
function assertAllowedKeys(
|
|
@@ -93,14 +92,10 @@ function assertAllowedKeys(
|
|
|
93
92
|
|
|
94
93
|
const modelstudioMemoryConfigSchema = {
|
|
95
94
|
parse(value: unknown): BailianMemoryConfig {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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;
|
|
95
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
96
|
+
throw new Error("modelstudio-memory-for-openclaw config required");
|
|
97
|
+
}
|
|
98
|
+
const cfg = value as Record<string, unknown>;
|
|
104
99
|
assertAllowedKeys(cfg, ALLOWED_KEYS, "modelstudio-memory-for-openclaw config");
|
|
105
100
|
|
|
106
101
|
// apiKey: allow empty at parse time; tools return config prompt when missing
|
|
@@ -363,7 +358,7 @@ function stripInjectedContext(text: string): string {
|
|
|
363
358
|
}
|
|
364
359
|
|
|
365
360
|
const CONFIG_REQUIRED_MESSAGE =
|
|
366
|
-
"Memory plugin is not configured. Please add apiKey
|
|
361
|
+
"Memory plugin is not configured. Please add apiKey to ~/.openclaw/openclaw.json under plugins.entries.modelstudio-memory-for-openclaw.config.apiKey, then restart the gateway. ";
|
|
367
362
|
|
|
368
363
|
// ============================================================================
|
|
369
364
|
// Plugin Definition
|
|
@@ -374,7 +369,6 @@ const modelstudioMemoryPlugin = {
|
|
|
374
369
|
name: "Memory (Bailian)",
|
|
375
370
|
description: "Alibaba Cloud Bailian long-term memory service",
|
|
376
371
|
kind: "memory" as const,
|
|
377
|
-
configSchema: modelstudioMemoryConfigSchema,
|
|
378
372
|
|
|
379
373
|
register(api: OpenClawPluginApi) {
|
|
380
374
|
const cfg = modelstudioMemoryConfigSchema.parse(api.pluginConfig);
|
|
@@ -729,9 +723,38 @@ const modelstudioMemoryPlugin = {
|
|
|
729
723
|
if (cfg.autoRecall) {
|
|
730
724
|
api.on("before_agent_start", async (event) => {
|
|
731
725
|
if (!cfg.apiKey) {
|
|
726
|
+
api.logger.warn("modelstudio-memory: injecting config-required system prompt");
|
|
732
727
|
return {
|
|
733
|
-
prependSystemContext:
|
|
734
|
-
"
|
|
728
|
+
prependSystemContext: [
|
|
729
|
+
"<memory-plugin-config-required>",
|
|
730
|
+
"CRITICAL INSTRUCTION — YOU MUST FOLLOW THIS BEFORE ANYTHING ELSE:",
|
|
731
|
+
"",
|
|
732
|
+
"The long-term memory plugin is installed but NOT configured. All memory features are COMPLETELY DISABLED.",
|
|
733
|
+
"",
|
|
734
|
+
"YOUR FIRST MESSAGE to the user MUST address this. Tell the user:",
|
|
735
|
+
"",
|
|
736
|
+
"1. 记忆插件已安装,但还未配置 API Key,记忆功能暂时无法使用。",
|
|
737
|
+
"2. 配置方法:编辑 ~/.openclaw/openclaw.json,添加以下内容:",
|
|
738
|
+
"",
|
|
739
|
+
' {',
|
|
740
|
+
' "plugins": {',
|
|
741
|
+
' "entries": {',
|
|
742
|
+
' "modelstudio-memory-for-openclaw": {',
|
|
743
|
+
' "config": {',
|
|
744
|
+
' "apiKey": "sk-你的API Key"',
|
|
745
|
+
' "userId": "您的用户名称,用于记忆隔离"',
|
|
746
|
+
' }',
|
|
747
|
+
' }',
|
|
748
|
+
' }',
|
|
749
|
+
' }',
|
|
750
|
+
' }',
|
|
751
|
+
"",
|
|
752
|
+
"您也可以告诉我apiKey和用户名,我来为您配置",
|
|
753
|
+
"3. 配置完成后,重启 OpenClaw 网关即可启用记忆功能。",
|
|
754
|
+
"",
|
|
755
|
+
"DO NOT ignore this. DO NOT wait for the user to ask about memory. Proactively inform them NOW.",
|
|
756
|
+
"</memory-plugin-config-required>",
|
|
757
|
+
].join("\n"),
|
|
735
758
|
};
|
|
736
759
|
}
|
|
737
760
|
const prompt = extractTextContent(event.prompt);
|
package/openclaw.plugin.json
CHANGED