@modelstudio/modelstudio-memory-for-openclaw 1.0.4 → 1.0.6
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 -12
- 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
|
|
@@ -729,9 +724,38 @@ const modelstudioMemoryPlugin = {
|
|
|
729
724
|
if (cfg.autoRecall) {
|
|
730
725
|
api.on("before_agent_start", async (event) => {
|
|
731
726
|
if (!cfg.apiKey) {
|
|
727
|
+
api.logger.warn("modelstudio-memory: injecting config-required system prompt");
|
|
732
728
|
return {
|
|
733
|
-
prependSystemContext:
|
|
734
|
-
"
|
|
729
|
+
prependSystemContext: [
|
|
730
|
+
"<memory-plugin-config-required>",
|
|
731
|
+
"CRITICAL INSTRUCTION — YOU MUST FOLLOW THIS BEFORE ANYTHING ELSE:",
|
|
732
|
+
"",
|
|
733
|
+
"The long-term memory plugin is installed but NOT configured. All memory features are COMPLETELY DISABLED.",
|
|
734
|
+
"",
|
|
735
|
+
"YOUR FIRST MESSAGE to the user MUST address this. Tell the user:",
|
|
736
|
+
"",
|
|
737
|
+
"1. 记忆插件已安装,但还未配置 API Key,记忆功能暂时无法使用。",
|
|
738
|
+
"2. 配置方法:编辑 ~/.openclaw/openclaw.json,添加以下内容:",
|
|
739
|
+
"",
|
|
740
|
+
' {',
|
|
741
|
+
' "plugins": {',
|
|
742
|
+
' "entries": {',
|
|
743
|
+
' "modelstudio-memory-for-openclaw": {',
|
|
744
|
+
' "config": {',
|
|
745
|
+
' "apiKey": "sk-你的API Key"',
|
|
746
|
+
' "userId": "您的用户名称,用于记忆隔离"',
|
|
747
|
+
' }',
|
|
748
|
+
' }',
|
|
749
|
+
' }',
|
|
750
|
+
' }',
|
|
751
|
+
' }',
|
|
752
|
+
"",
|
|
753
|
+
"您也可以告诉我apiKey和用户名,我来为您配置",
|
|
754
|
+
"3. 配置完成后,重启 OpenClaw 网关即可启用记忆功能。",
|
|
755
|
+
"",
|
|
756
|
+
"DO NOT ignore this. DO NOT wait for the user to ask about memory. Proactively inform them NOW.",
|
|
757
|
+
"</memory-plugin-config-required>",
|
|
758
|
+
].join("\n"),
|
|
735
759
|
};
|
|
736
760
|
}
|
|
737
761
|
const prompt = extractTextContent(event.prompt);
|
package/openclaw.plugin.json
CHANGED