@t0ken.ai/memoryx-openclaw-plugin 2.2.18 → 2.2.19
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.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -8
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -48,6 +48,7 @@ declare class MemoryXPlugin {
|
|
|
48
48
|
private timersStarted;
|
|
49
49
|
constructor(pluginConfig?: PluginConfig);
|
|
50
50
|
init(): Promise<void>;
|
|
51
|
+
startTimersIfNeeded(): Promise<void>;
|
|
51
52
|
onMessage(role: string, content: string): Promise<boolean>;
|
|
52
53
|
recall(query: string, limit?: number): Promise<RecallResult>;
|
|
53
54
|
endConversation(): Promise<void>;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAqCH,UAAU,YAAY;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,YAAY;IAClB,QAAQ,EAAE,KAAK,CAAC;QACZ,EAAE,EAAE,MAAM,CAAC;QACX,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;IACH,eAAe,EAAE,KAAK,CAAC;QACnB,EAAE,EAAE,MAAM,CAAC;QACX,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;IACH,SAAS,EAAE,OAAO,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],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IAcvE,IAAI,CAAC,KAAK,GAAE,MAAW,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAiBxC,cAAc,IAAI,OAAO,CAAC;QACnC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;QACtB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;QACvB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;QACzB,WAAW,EAAE,OAAO,CAAC;QACrB,KAAK,CAAC,EAAE,GAAG,CAAC;KACf,CAAC;IAwBW,cAAc,IAAI,OAAO,CAAC;QACnC,OAAO,EAAE,OAAO,CAAC;QACjB,IAAI,CAAC,EAAE;YACH,QAAQ,EAAE,MAAM,CAAC;YACjB,IAAI,EAAE,MAAM,CAAC;YACb,UAAU,EAAE,MAAM,CAAC;YACnB,YAAY,EAAE,MAAM,CAAC;YACrB,iBAAiB,EAAE,MAAM,CAAC;YAC1B,gBAAgB,EAAE,MAAM,CAAC;YACzB,mBAAmB,EAAE,MAAM,CAAC;YAC5B,MAAM,EAAE,MAAM,CAAC;YACf,OAAO,EAAE,MAAM,CAAC;SACnB,CAAC;QACF,KAAK,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CAcL;;;;;;kBAUiB,GAAG,iBAAiB,YAAY,GAAG,IAAI;;AANzD,wBAgfE;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -26,7 +26,7 @@ import * as fs from "fs";
|
|
|
26
26
|
import * as path from "path";
|
|
27
27
|
import * as os from "os";
|
|
28
28
|
// 插件版本号 - 由 prebuild 脚本自动从 package.json 同步
|
|
29
|
-
const PLUGIN_VERSION = "2.2.
|
|
29
|
+
const PLUGIN_VERSION = "2.2.19";
|
|
30
30
|
const DEFAULT_API_BASE = "https://t0ken.ai/api";
|
|
31
31
|
const PLUGIN_DIR = path.join(os.homedir(), ".openclaw", "extensions", "memoryx-openclaw-plugin");
|
|
32
32
|
let logStream = null;
|
|
@@ -83,6 +83,8 @@ async function getSDK(pluginConfig) {
|
|
|
83
83
|
// Set debug mode
|
|
84
84
|
const { setDebug } = await import("@t0ken.ai/memoryx-sdk");
|
|
85
85
|
setDebug(true);
|
|
86
|
+
// 注意:不在这里启动定时器!
|
|
87
|
+
// 定时器在 onMessage 第一次收到消息时启动,避免阻塞 openclaw status 命令
|
|
86
88
|
log("SDK initialized with conversation preset (30k tokens / 5min idle)");
|
|
87
89
|
return sdkInstance;
|
|
88
90
|
})();
|
|
@@ -108,15 +110,17 @@ class MemoryXPlugin {
|
|
|
108
110
|
log(`Init failed: ${e}`);
|
|
109
111
|
}
|
|
110
112
|
}
|
|
113
|
+
async startTimersIfNeeded() {
|
|
114
|
+
if (this.timersStarted)
|
|
115
|
+
return;
|
|
116
|
+
await this.init();
|
|
117
|
+
const sdk = await getSDK(this.pluginConfig);
|
|
118
|
+
sdk.startTimers();
|
|
119
|
+
this.timersStarted = true;
|
|
120
|
+
log("Timers started");
|
|
121
|
+
}
|
|
111
122
|
async onMessage(role, content) {
|
|
112
123
|
await this.init();
|
|
113
|
-
// 第一次收到消息时启动定时器
|
|
114
|
-
if (!this.timersStarted) {
|
|
115
|
-
const sdk = await getSDK(this.pluginConfig);
|
|
116
|
-
sdk.startTimers();
|
|
117
|
-
this.timersStarted = true;
|
|
118
|
-
log("Timers started on first message");
|
|
119
|
-
}
|
|
120
124
|
if (!content || content.length < 2) {
|
|
121
125
|
return false;
|
|
122
126
|
}
|
|
@@ -639,11 +643,20 @@ export default {
|
|
|
639
643
|
// Auto-inject memories via prependContext
|
|
640
644
|
// Note: OpenClaw's systemPrompt field is extracted but NEVER USED (bug in attempt.ts:918-928)
|
|
641
645
|
// We use prependContext which works, but the context will be visible in the user's prompt
|
|
646
|
+
//
|
|
647
|
+
// IMPORTANT: 对话流走的是 before_agent_start 事件,不是 message_received!
|
|
648
|
+
// message_received 只在 auto-reply 功能中触发
|
|
642
649
|
api.on("before_agent_start", async (event, ctx) => {
|
|
643
650
|
const { prompt } = event;
|
|
644
651
|
if (!prompt || prompt.length < 2 || !plugin)
|
|
645
652
|
return;
|
|
646
653
|
try {
|
|
654
|
+
// 1. 启动定时器(第一次对话时)
|
|
655
|
+
// 对话流不走 message_received,必须在这里启动定时器
|
|
656
|
+
await plugin.startTimersIfNeeded();
|
|
657
|
+
// 2. 保存用户消息到队列
|
|
658
|
+
await plugin.onMessage("user", prompt);
|
|
659
|
+
// 3. 搜索相关记忆
|
|
647
660
|
const result = await plugin.recall(prompt, 5);
|
|
648
661
|
if (result.isLimited) {
|
|
649
662
|
// Don't inject upgrade hints into prompt - just log
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t0ken.ai/memoryx-openclaw-plugin",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.19",
|
|
4
4
|
"description": "MemoryX real-time memory capture and recall plugin for OpenClaw (powered by @t0ken.ai/memoryx-sdk)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "MemoryX Team",
|
|
@@ -36,6 +36,6 @@
|
|
|
36
36
|
"typescript": "^5.0.0"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@t0ken.ai/memoryx-sdk": "^1.4.
|
|
39
|
+
"@t0ken.ai/memoryx-sdk": "^1.4.9"
|
|
40
40
|
}
|
|
41
41
|
}
|