@t0ken.ai/memoryx-openclaw-plugin 1.0.8 → 1.1.0
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/README.md +6 -0
- package/dist/index.d.ts +1 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +54 -46
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -35,6 +35,9 @@ Edit `~/.openclaw/openclaw.json`:
|
|
|
35
35
|
},
|
|
36
36
|
"memory-core": {
|
|
37
37
|
"enabled": false
|
|
38
|
+
},
|
|
39
|
+
"memory-lancedb": {
|
|
40
|
+
"enabled": false
|
|
38
41
|
}
|
|
39
42
|
}
|
|
40
43
|
}
|
|
@@ -58,6 +61,9 @@ For self-hosted MemoryX:
|
|
|
58
61
|
},
|
|
59
62
|
"memory-core": {
|
|
60
63
|
"enabled": false
|
|
64
|
+
},
|
|
65
|
+
"memory-lancedb": {
|
|
66
|
+
"enabled": false
|
|
61
67
|
}
|
|
62
68
|
}
|
|
63
69
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* MemoryX Realtime Plugin for OpenClaw
|
|
2
|
+
* MemoryX Realtime Plugin for OpenClaw
|
|
3
3
|
*
|
|
4
4
|
* Features:
|
|
5
5
|
* - ConversationBuffer with token counting
|
|
@@ -8,10 +8,6 @@
|
|
|
8
8
|
* - Sensitive data filtered on server
|
|
9
9
|
* - Configurable API base URL
|
|
10
10
|
* - Precise token counting with tiktoken
|
|
11
|
-
*
|
|
12
|
-
* Model Downloads (CDN):
|
|
13
|
-
* - INT8 Model (122MB, recommended): https://static.t0ken.ai/models/model_int8.onnx
|
|
14
|
-
* - FP32 Model (489MB): https://static.t0ken.ai/models/model.onnx
|
|
15
11
|
*/
|
|
16
12
|
interface PluginConfig {
|
|
17
13
|
apiBaseUrl?: string;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAYH,UAAU,YAAY;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAUD,UAAU,OAAO;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACrB;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,SAAS,EAAE,OAAO,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AA2BD,cAAM,kBAAkB;IACpB,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,QAAQ,CAAc;IAC9B,OAAO,CAAC,cAAc,CAAc;IACpC,OAAO,CAAC,SAAS,CAAsB;IACvC,OAAO,CAAC,cAAc,CAAsB;IAC5C,OAAO,CAAC,OAAO,CAAW;IAE1B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAK;IACrC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAkB;IAC7C,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAQ;;IAO/C,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,WAAW;IAInB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO;IA6BlD,WAAW,IAA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Y,GAAG,IAAI;;AANzD,wBAqEE;AAEF,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* MemoryX Realtime Plugin for OpenClaw
|
|
2
|
+
* MemoryX Realtime Plugin for OpenClaw
|
|
3
3
|
*
|
|
4
4
|
* Features:
|
|
5
5
|
* - ConversationBuffer with token counting
|
|
@@ -8,13 +8,40 @@
|
|
|
8
8
|
* - Sensitive data filtered on server
|
|
9
9
|
* - Configurable API base URL
|
|
10
10
|
* - Precise token counting with tiktoken
|
|
11
|
-
*
|
|
12
|
-
* Model Downloads (CDN):
|
|
13
|
-
* - INT8 Model (122MB, recommended): https://static.t0ken.ai/models/model_int8.onnx
|
|
14
|
-
* - FP32 Model (489MB): https://static.t0ken.ai/models/model.onnx
|
|
15
11
|
*/
|
|
16
12
|
import { getEncoding } from "js-tiktoken";
|
|
13
|
+
import * as fs from "fs";
|
|
14
|
+
import * as path from "path";
|
|
15
|
+
import * as os from "os";
|
|
16
|
+
import * as crypto from "crypto";
|
|
17
17
|
const DEFAULT_API_BASE = "https://t0ken.ai/api";
|
|
18
|
+
const CONFIG_DIR = path.join(os.homedir(), ".t0ken");
|
|
19
|
+
const CONFIG_FILE = path.join(CONFIG_DIR, "memoryx.json");
|
|
20
|
+
class FileStorage {
|
|
21
|
+
static load() {
|
|
22
|
+
try {
|
|
23
|
+
if (fs.existsSync(CONFIG_FILE)) {
|
|
24
|
+
const data = fs.readFileSync(CONFIG_FILE, "utf-8");
|
|
25
|
+
return JSON.parse(data);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
console.warn("[MemoryX] Failed to load config:", e);
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
static save(config) {
|
|
34
|
+
try {
|
|
35
|
+
if (!fs.existsSync(CONFIG_DIR)) {
|
|
36
|
+
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
37
|
+
}
|
|
38
|
+
fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
console.warn("[MemoryX] Failed to save config:", e);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
18
45
|
class ConversationBuffer {
|
|
19
46
|
messages = [];
|
|
20
47
|
tokenCount = 0;
|
|
@@ -125,40 +152,29 @@ class MemoryXPlugin {
|
|
|
125
152
|
return this.config.apiBaseUrl || DEFAULT_API_BASE;
|
|
126
153
|
}
|
|
127
154
|
async init() {
|
|
128
|
-
|
|
155
|
+
this.loadConfig();
|
|
129
156
|
if (!this.config.apiKey) {
|
|
130
157
|
await this.autoRegister();
|
|
131
158
|
}
|
|
132
159
|
this.startFlushTimer();
|
|
133
160
|
this.config.initialized = true;
|
|
134
161
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
apiBaseUrl: storedConfig.apiBaseUrl || this.config.apiBaseUrl
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
catch (e) {
|
|
148
|
-
console.warn("[MemoryX] Failed to load config:", e);
|
|
162
|
+
loadConfig() {
|
|
163
|
+
const stored = FileStorage.load();
|
|
164
|
+
if (stored) {
|
|
165
|
+
this.config = {
|
|
166
|
+
...this.config,
|
|
167
|
+
...stored,
|
|
168
|
+
apiBaseUrl: this.pluginConfig?.apiBaseUrl || stored.apiBaseUrl || this.config.apiBaseUrl
|
|
169
|
+
};
|
|
149
170
|
}
|
|
150
171
|
}
|
|
151
172
|
saveConfig() {
|
|
152
|
-
|
|
153
|
-
localStorage.setItem("memoryx_config", JSON.stringify(this.config));
|
|
154
|
-
}
|
|
155
|
-
catch (e) {
|
|
156
|
-
console.warn("[MemoryX] Failed to save config:", e);
|
|
157
|
-
}
|
|
173
|
+
FileStorage.save(this.config);
|
|
158
174
|
}
|
|
159
175
|
async autoRegister() {
|
|
160
176
|
try {
|
|
161
|
-
const fingerprint =
|
|
177
|
+
const fingerprint = this.getMachineFingerprint();
|
|
162
178
|
const response = await fetch(`${this.apiBase}/agents/auto-register`, {
|
|
163
179
|
method: "POST",
|
|
164
180
|
headers: { "Content-Type": "application/json" },
|
|
@@ -166,8 +182,8 @@ class MemoryXPlugin {
|
|
|
166
182
|
machine_fingerprint: fingerprint,
|
|
167
183
|
agent_type: "openclaw",
|
|
168
184
|
agent_name: "openclaw-agent",
|
|
169
|
-
platform:
|
|
170
|
-
platform_version:
|
|
185
|
+
platform: os.platform(),
|
|
186
|
+
platform_version: os.release()
|
|
171
187
|
})
|
|
172
188
|
});
|
|
173
189
|
if (!response.ok) {
|
|
@@ -184,21 +200,16 @@ class MemoryXPlugin {
|
|
|
184
200
|
console.error("[MemoryX] Auto-register failed:", e);
|
|
185
201
|
}
|
|
186
202
|
}
|
|
187
|
-
|
|
203
|
+
getMachineFingerprint() {
|
|
188
204
|
const components = [
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
new Date().getTimezoneOffset()
|
|
205
|
+
os.hostname(),
|
|
206
|
+
os.platform(),
|
|
207
|
+
os.arch(),
|
|
208
|
+
os.cpus()[0]?.model || "unknown",
|
|
209
|
+
os.totalmem()
|
|
195
210
|
];
|
|
196
211
|
const raw = components.join("|");
|
|
197
|
-
|
|
198
|
-
const data = encoder.encode(raw);
|
|
199
|
-
const hashBuffer = await crypto.subtle.digest("SHA-256", data);
|
|
200
|
-
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
201
|
-
return hashArray.slice(0, 32).map(b => b.toString(16).padStart(2, "0")).join("");
|
|
212
|
+
return crypto.createHash("sha256").update(raw).digest("hex").slice(0, 32);
|
|
202
213
|
}
|
|
203
214
|
startFlushTimer() {
|
|
204
215
|
this.flushTimer = setInterval(() => {
|
|
@@ -323,17 +334,14 @@ let plugin;
|
|
|
323
334
|
export default {
|
|
324
335
|
id: "memoryx-openclaw-plugin",
|
|
325
336
|
name: "MemoryX Real-time Plugin",
|
|
326
|
-
version: "1.0
|
|
337
|
+
version: "1.1.0",
|
|
327
338
|
description: "Real-time memory capture and recall for OpenClaw",
|
|
328
339
|
register(api, pluginConfig) {
|
|
329
340
|
api.logger.info("[MemoryX] Plugin registering...");
|
|
330
341
|
if (pluginConfig?.apiBaseUrl) {
|
|
331
342
|
api.logger.info(`[MemoryX] API Base: \`${pluginConfig.apiBaseUrl}\``);
|
|
332
343
|
}
|
|
333
|
-
|
|
334
|
-
if (storedConfig) {
|
|
335
|
-
api.logger.info(`[MemoryX] Database: ${storedConfig.split('"apiBaseUrl"')[0].match(/"([^"]+)"/)?.[1] || 'unknown'}`);
|
|
336
|
-
}
|
|
344
|
+
api.logger.info(`[MemoryX] Config: ${CONFIG_FILE}`);
|
|
337
345
|
plugin = new MemoryXPlugin(pluginConfig);
|
|
338
346
|
api.on("message_received", async (event, ctx) => {
|
|
339
347
|
const { content, from, timestamp } = event;
|
package/openclaw.plugin.json
CHANGED