@t0ken.ai/memoryx-openclaw-plugin 2.2.17 → 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 +24 -21
- package/openclaw.plugin.json +1 -1
- package/package.json +3 -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;
|
|
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,CA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Y,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
|
@@ -25,18 +25,8 @@
|
|
|
25
25
|
import * as fs from "fs";
|
|
26
26
|
import * as path from "path";
|
|
27
27
|
import * as os from "os";
|
|
28
|
-
//
|
|
29
|
-
|
|
30
|
-
const PACKAGE_JSON_PATH = path.join(__dirname, "..", "package.json");
|
|
31
|
-
function getVersion() {
|
|
32
|
-
try {
|
|
33
|
-
const packageJson = JSON.parse(fs.readFileSync(PACKAGE_JSON_PATH, "utf-8"));
|
|
34
|
-
return packageJson.version || "unknown";
|
|
35
|
-
}
|
|
36
|
-
catch {
|
|
37
|
-
return "unknown";
|
|
38
|
-
}
|
|
39
|
-
}
|
|
28
|
+
// 插件版本号 - 由 prebuild 脚本自动从 package.json 同步
|
|
29
|
+
const PLUGIN_VERSION = "2.2.19";
|
|
40
30
|
const DEFAULT_API_BASE = "https://t0ken.ai/api";
|
|
41
31
|
const PLUGIN_DIR = path.join(os.homedir(), ".openclaw", "extensions", "memoryx-openclaw-plugin");
|
|
42
32
|
let logStream = null;
|
|
@@ -93,6 +83,8 @@ async function getSDK(pluginConfig) {
|
|
|
93
83
|
// Set debug mode
|
|
94
84
|
const { setDebug } = await import("@t0ken.ai/memoryx-sdk");
|
|
95
85
|
setDebug(true);
|
|
86
|
+
// 注意:不在这里启动定时器!
|
|
87
|
+
// 定时器在 onMessage 第一次收到消息时启动,避免阻塞 openclaw status 命令
|
|
96
88
|
log("SDK initialized with conversation preset (30k tokens / 5min idle)");
|
|
97
89
|
return sdkInstance;
|
|
98
90
|
})();
|
|
@@ -118,15 +110,17 @@ class MemoryXPlugin {
|
|
|
118
110
|
log(`Init failed: ${e}`);
|
|
119
111
|
}
|
|
120
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
|
+
}
|
|
121
122
|
async onMessage(role, content) {
|
|
122
123
|
await this.init();
|
|
123
|
-
// 第一次收到消息时启动定时器
|
|
124
|
-
if (!this.timersStarted) {
|
|
125
|
-
const sdk = await getSDK(this.pluginConfig);
|
|
126
|
-
sdk.startTimers();
|
|
127
|
-
this.timersStarted = true;
|
|
128
|
-
log("Timers started on first message");
|
|
129
|
-
}
|
|
130
124
|
if (!content || content.length < 2) {
|
|
131
125
|
return false;
|
|
132
126
|
}
|
|
@@ -283,7 +277,7 @@ let plugin;
|
|
|
283
277
|
export default {
|
|
284
278
|
id: "memoryx-openclaw-plugin",
|
|
285
279
|
name: "MemoryX Realtime Plugin",
|
|
286
|
-
get version() { return
|
|
280
|
+
get version() { return PLUGIN_VERSION; },
|
|
287
281
|
description: "Real-time memory capture and recall for OpenClaw (powered by @t0ken.ai/memoryx-sdk)",
|
|
288
282
|
register(api, pluginConfig) {
|
|
289
283
|
api.logger.info("[MemoryX] Plugin registering...");
|
|
@@ -649,11 +643,20 @@ export default {
|
|
|
649
643
|
// Auto-inject memories via prependContext
|
|
650
644
|
// Note: OpenClaw's systemPrompt field is extracted but NEVER USED (bug in attempt.ts:918-928)
|
|
651
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 功能中触发
|
|
652
649
|
api.on("before_agent_start", async (event, ctx) => {
|
|
653
650
|
const { prompt } = event;
|
|
654
651
|
if (!prompt || prompt.length < 2 || !plugin)
|
|
655
652
|
return;
|
|
656
653
|
try {
|
|
654
|
+
// 1. 启动定时器(第一次对话时)
|
|
655
|
+
// 对话流不走 message_received,必须在这里启动定时器
|
|
656
|
+
await plugin.startTimersIfNeeded();
|
|
657
|
+
// 2. 保存用户消息到队列
|
|
658
|
+
await plugin.onMessage("user", prompt);
|
|
659
|
+
// 3. 搜索相关记忆
|
|
657
660
|
const result = await plugin.recall(prompt, 5);
|
|
658
661
|
if (result.isLimited) {
|
|
659
662
|
// Don't inject upgrade hints into prompt - just log
|
|
@@ -691,7 +694,7 @@ export default {
|
|
|
691
694
|
await plugin.endConversation();
|
|
692
695
|
}
|
|
693
696
|
});
|
|
694
|
-
api.logger.info(`[MemoryX] ✅ Plugin v${
|
|
697
|
+
api.logger.info(`[MemoryX] ✅ Plugin v${PLUGIN_VERSION} ready! Your conversations will be remembered automatically.`);
|
|
695
698
|
// Async check and show portal link after SDK initializes
|
|
696
699
|
setImmediate(async () => {
|
|
697
700
|
try {
|
package/openclaw.plugin.json
CHANGED
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",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"README.md"
|
|
13
13
|
],
|
|
14
14
|
"scripts": {
|
|
15
|
+
"prebuild": "node scripts/update-version.cjs",
|
|
15
16
|
"build": "tsc"
|
|
16
17
|
},
|
|
17
18
|
"keywords": [
|
|
@@ -35,6 +36,6 @@
|
|
|
35
36
|
"typescript": "^5.0.0"
|
|
36
37
|
},
|
|
37
38
|
"dependencies": {
|
|
38
|
-
"@t0ken.ai/memoryx-sdk": "^1.4.
|
|
39
|
+
"@t0ken.ai/memoryx-sdk": "^1.4.9"
|
|
39
40
|
}
|
|
40
41
|
}
|