@t0ken.ai/memoryx-openclaw-plugin 2.2.58 → 2.2.60
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.map +1 -1
- package/dist/index.js +66 -11
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
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;AAuDH,UAAU,YAAY;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mCAAmC;IACnC,aAAa,CAAC,EAAE,OAAO,CAAC;CAC3B;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;AAqDD,cAAM,aAAa;IACf,OAAO,CAAC,YAAY,CAA2B;IAC/C,OAAO,CAAC,WAAW,CAAkB;IACrC,OAAO,CAAC,aAAa,CAAkB;gBAE3B,YAAY,CAAC,EAAE,YAAY;IAIjC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;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iBAAiB,YAAY,GAAG,IAAI;;AANzD,wBAq8BE;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -27,7 +27,7 @@ import * as path from "path";
|
|
|
27
27
|
import * as os from "os";
|
|
28
28
|
import * as http from "http";
|
|
29
29
|
// 插件版本号 - 由 prebuild 脚本自动从 package.json 同步
|
|
30
|
-
const PLUGIN_VERSION = "2.2.
|
|
30
|
+
const PLUGIN_VERSION = "2.2.60";
|
|
31
31
|
const DEFAULT_API_BASE = "https://t0ken.ai/api";
|
|
32
32
|
const PLUGIN_DIR = path.join(os.homedir(), ".openclaw", "extensions", "memoryx-openclaw-plugin");
|
|
33
33
|
let logStream = null;
|
|
@@ -37,32 +37,41 @@ function ensureDir() {
|
|
|
37
37
|
fs.mkdirSync(PLUGIN_DIR, { recursive: true });
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
+
const LOG_FILE = path.join(PLUGIN_DIR, "plugin.log");
|
|
40
41
|
/**
|
|
41
42
|
* 分层日志系统
|
|
42
|
-
* -
|
|
43
|
+
* - 所有日志都写入文件(先尝试 stream,未就绪时同步 append 确保不丢)
|
|
43
44
|
* - console=true 时同时写入控制台(用于重要/引导性信息)
|
|
44
|
-
* - console=false 时只写文件(用于调试信息)
|
|
45
45
|
*/
|
|
46
46
|
function log(message, options = {}) {
|
|
47
47
|
const { console: toConsole = false } = options;
|
|
48
|
-
|
|
48
|
+
const line = `[${new Date().toISOString()}] ${message}\n`;
|
|
49
49
|
if (toConsole) {
|
|
50
50
|
console.log(`[MemoryX] ${message}`);
|
|
51
51
|
}
|
|
52
|
-
|
|
53
|
-
setImmediate(() => {
|
|
52
|
+
const writeToFile = () => {
|
|
54
53
|
try {
|
|
55
54
|
if (!logStreamReady) {
|
|
56
55
|
ensureDir();
|
|
57
|
-
logStream = fs.createWriteStream(
|
|
56
|
+
logStream = fs.createWriteStream(LOG_FILE, { flags: "a" });
|
|
58
57
|
logStreamReady = true;
|
|
59
58
|
}
|
|
60
|
-
logStream?.write(
|
|
59
|
+
logStream?.write(line, (err) => { if (err) {
|
|
60
|
+
try {
|
|
61
|
+
fs.appendFileSync(LOG_FILE, line);
|
|
62
|
+
}
|
|
63
|
+
catch (_) { }
|
|
64
|
+
} });
|
|
61
65
|
}
|
|
62
66
|
catch (e) {
|
|
63
|
-
|
|
67
|
+
try {
|
|
68
|
+
ensureDir();
|
|
69
|
+
fs.appendFileSync(LOG_FILE, line);
|
|
70
|
+
}
|
|
71
|
+
catch (_) { }
|
|
64
72
|
}
|
|
65
|
-
}
|
|
73
|
+
};
|
|
74
|
+
setImmediate(writeToFile);
|
|
66
75
|
}
|
|
67
76
|
// Lazy-loaded SDK instance
|
|
68
77
|
let sdkInstance = null;
|
|
@@ -296,6 +305,7 @@ export default {
|
|
|
296
305
|
description: "Real-time memory capture and recall for OpenClaw (powered by @t0ken.ai/memoryx-sdk)",
|
|
297
306
|
register(api, pluginConfig) {
|
|
298
307
|
api.logger.info("[MemoryX] Plugin registering...");
|
|
308
|
+
api.logger.info(`[MemoryX] Plugin log file: ${LOG_FILE}`);
|
|
299
309
|
if (pluginConfig?.apiBaseUrl) {
|
|
300
310
|
api.logger.info(`[MemoryX] API Base: \`${pluginConfig.apiBaseUrl}\``);
|
|
301
311
|
}
|
|
@@ -661,7 +671,8 @@ export default {
|
|
|
661
671
|
// IMPORTANT: 对话流走的是 before_agent_start 事件,不是 message_received!
|
|
662
672
|
// message_received 只在 auto-reply 功能中触发
|
|
663
673
|
api.on("before_agent_start", async (event, ctx) => {
|
|
664
|
-
//
|
|
674
|
+
// 每次对话前:重新包装 Proxy(防止 config 被合并覆盖)+ 重写 baseUrl
|
|
675
|
+
wrapProvidersWithProxy();
|
|
665
676
|
applySidecarRedirect({ quiet: true });
|
|
666
677
|
const { prompt } = event;
|
|
667
678
|
if (!prompt || prompt.length < 2 || !plugin)
|
|
@@ -848,6 +859,7 @@ export default {
|
|
|
848
859
|
});
|
|
849
860
|
this.server.listen(SIDECAR_PORT, () => {
|
|
850
861
|
log(`[Sidecar] Started on port ${SIDECAR_PORT}`);
|
|
862
|
+
api.logger.info(`[MemoryX] Plugin log file: ${LOG_FILE}`);
|
|
851
863
|
resolve();
|
|
852
864
|
});
|
|
853
865
|
});
|
|
@@ -1070,7 +1082,50 @@ export default {
|
|
|
1070
1082
|
api.logger.info(`[MemoryX] ✅ Sidecar redirect applied for ${n} provider(s). Use your configured model (e.g. zai/glm-5).`);
|
|
1071
1083
|
log(`[Proxy] Sidecar redirect applied for ${n} provider(s)`, { console: true });
|
|
1072
1084
|
}
|
|
1085
|
+
// 诊断:读回 baseUrl,确认网关用的 config 是否和我们改的是同一份
|
|
1086
|
+
if (n > 0) {
|
|
1087
|
+
for (const providerId of creds.keys()) {
|
|
1088
|
+
if (providerId === 'memoryx-proxy')
|
|
1089
|
+
continue;
|
|
1090
|
+
const p = providers[providerId];
|
|
1091
|
+
const readBack = (p && typeof p === 'object' && p.baseUrl) ? p.baseUrl : '<missing>';
|
|
1092
|
+
const isSidecar = readBack === sidecarBase;
|
|
1093
|
+
log(`[Proxy] Readback ${providerId}.baseUrl = ${readBack} ${isSidecar ? '(Sidecar ✓)' : '(NOT Sidecar!)'}`);
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
};
|
|
1097
|
+
// 用 Proxy 包装 providers,使对 baseUrl 的读取始终返回 Sidecar(防止网关从副本/缓存读)
|
|
1098
|
+
const wrapProvidersWithProxy = () => {
|
|
1099
|
+
if (!api.config?.models?.providers || typeof api.config.models.providers !== 'object')
|
|
1100
|
+
return;
|
|
1101
|
+
const creds = extractProviderCredentials(api.config);
|
|
1102
|
+
if (creds.size === 0)
|
|
1103
|
+
return;
|
|
1104
|
+
const raw = api.config.models.providers;
|
|
1105
|
+
const handler = {
|
|
1106
|
+
get(target, prop) {
|
|
1107
|
+
const val = target[prop];
|
|
1108
|
+
if (val && typeof val === 'object' && creds.has(prop) && prop !== 'memoryx-proxy') {
|
|
1109
|
+
return new Proxy(val, {
|
|
1110
|
+
get(t, k) {
|
|
1111
|
+
if (k === 'baseUrl')
|
|
1112
|
+
return sidecarBase;
|
|
1113
|
+
if (k === 'headers') {
|
|
1114
|
+
const h = t.headers && typeof t.headers === 'object' ? { ...t.headers } : {};
|
|
1115
|
+
h[realProviderHeader] = prop;
|
|
1116
|
+
return h;
|
|
1117
|
+
}
|
|
1118
|
+
return t[k];
|
|
1119
|
+
}
|
|
1120
|
+
});
|
|
1121
|
+
}
|
|
1122
|
+
return val;
|
|
1123
|
+
}
|
|
1124
|
+
};
|
|
1125
|
+
api.config.models.providers = new Proxy(raw, handler);
|
|
1126
|
+
log(`[Proxy] Wrapped models.providers in Proxy so baseUrl/headers always resolve to Sidecar`);
|
|
1073
1127
|
};
|
|
1128
|
+
wrapProvidersWithProxy();
|
|
1074
1129
|
applySidecarRedirect();
|
|
1075
1130
|
api.logger.info(`[MemoryX] ✅ Plugin v${PLUGIN_VERSION} ready! Requests go through MemoryX proxy with your configured model.`);
|
|
1076
1131
|
// Async check and show portal link after SDK initializes
|
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED