@t0ken.ai/memoryx-openclaw-plugin 1.1.0 → 1.1.2
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 +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +60 -23
- package/openclaw.plugin.json +1 -1
- package/package.json +6 -2
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAWH,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;AA6ED,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,CAA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AAC,YAAY,CAAC;IAoD/D,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAKtC,SAAS,IAAI;QAChB,WAAW,EAAE,OAAO,CAAC;QACrB,SAAS,EAAE,OAAO,CAAC;QACnB,YAAY,EAAE;YAAE,YAAY,EAAE,MAAM,CAAC;YAAC,UAAU,EAAE,MAAM,CAAA;SAAE,CAAA;KAC7D;CAOJ;;;;;;kBAUiB,GAAG,iBAAiB,YAAY,GAAG,IAAI;;AANzD,wBAqEE;AAEF,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -14,15 +14,55 @@ import * as fs from "fs";
|
|
|
14
14
|
import * as path from "path";
|
|
15
15
|
import * as os from "os";
|
|
16
16
|
import * as crypto from "crypto";
|
|
17
|
+
import Database from "better-sqlite3";
|
|
17
18
|
const DEFAULT_API_BASE = "https://t0ken.ai/api";
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
let db = null;
|
|
20
|
+
let dbPath = "";
|
|
21
|
+
function getDbPath() {
|
|
22
|
+
if (dbPath)
|
|
23
|
+
return dbPath;
|
|
24
|
+
const possiblePaths = [
|
|
25
|
+
path.join(process.cwd(), "memoryx.sqlite"),
|
|
26
|
+
path.join(os.homedir(), ".openclaw", "extensions", "memoryx-openclaw-plugin", "memoryx.sqlite"),
|
|
27
|
+
path.join(os.homedir(), ".t0ken", "memoryx.sqlite")
|
|
28
|
+
];
|
|
29
|
+
for (const p of possiblePaths) {
|
|
30
|
+
if (fs.existsSync(p)) {
|
|
31
|
+
dbPath = p;
|
|
32
|
+
return dbPath;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
dbPath = path.join(os.homedir(), ".openclaw", "extensions", "memoryx-openclaw-plugin", "memoryx.sqlite");
|
|
36
|
+
const dir = path.dirname(dbPath);
|
|
37
|
+
if (!fs.existsSync(dir)) {
|
|
38
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
39
|
+
}
|
|
40
|
+
return dbPath;
|
|
41
|
+
}
|
|
42
|
+
function initDb() {
|
|
43
|
+
const dbFile = getDbPath();
|
|
44
|
+
const database = new Database(dbFile);
|
|
45
|
+
database.exec(`
|
|
46
|
+
CREATE TABLE IF NOT EXISTS config (
|
|
47
|
+
key TEXT PRIMARY KEY,
|
|
48
|
+
value TEXT
|
|
49
|
+
)
|
|
50
|
+
`);
|
|
51
|
+
return database;
|
|
52
|
+
}
|
|
53
|
+
function getDb() {
|
|
54
|
+
if (!db) {
|
|
55
|
+
db = initDb();
|
|
56
|
+
}
|
|
57
|
+
return db;
|
|
58
|
+
}
|
|
59
|
+
class SQLiteStorage {
|
|
21
60
|
static load() {
|
|
22
61
|
try {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
62
|
+
const database = getDb();
|
|
63
|
+
const row = database.prepare("SELECT value FROM config WHERE key = 'config'").get();
|
|
64
|
+
if (row) {
|
|
65
|
+
return JSON.parse(row.value);
|
|
26
66
|
}
|
|
27
67
|
}
|
|
28
68
|
catch (e) {
|
|
@@ -32,10 +72,10 @@ class FileStorage {
|
|
|
32
72
|
}
|
|
33
73
|
static save(config) {
|
|
34
74
|
try {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
75
|
+
const database = getDb();
|
|
76
|
+
database.prepare(`
|
|
77
|
+
INSERT OR REPLACE INTO config (key, value) VALUES ('config', ?)
|
|
78
|
+
`).run(JSON.stringify(config));
|
|
39
79
|
}
|
|
40
80
|
catch (e) {
|
|
41
81
|
console.warn("[MemoryX] Failed to save config:", e);
|
|
@@ -146,21 +186,18 @@ class MemoryXPlugin {
|
|
|
146
186
|
if (pluginConfig?.apiBaseUrl) {
|
|
147
187
|
this.config.apiBaseUrl = pluginConfig.apiBaseUrl;
|
|
148
188
|
}
|
|
149
|
-
this.init();
|
|
150
|
-
}
|
|
151
|
-
get apiBase() {
|
|
152
|
-
return this.config.apiBaseUrl || DEFAULT_API_BASE;
|
|
153
|
-
}
|
|
154
|
-
async init() {
|
|
155
189
|
this.loadConfig();
|
|
156
|
-
if (!this.config.apiKey) {
|
|
157
|
-
await this.autoRegister();
|
|
158
|
-
}
|
|
159
190
|
this.startFlushTimer();
|
|
160
191
|
this.config.initialized = true;
|
|
192
|
+
if (!this.config.apiKey) {
|
|
193
|
+
this.autoRegister().catch(e => console.error("[MemoryX] Auto-register failed:", e));
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
get apiBase() {
|
|
197
|
+
return this.config.apiBaseUrl || DEFAULT_API_BASE;
|
|
161
198
|
}
|
|
162
199
|
loadConfig() {
|
|
163
|
-
const stored =
|
|
200
|
+
const stored = SQLiteStorage.load();
|
|
164
201
|
if (stored) {
|
|
165
202
|
this.config = {
|
|
166
203
|
...this.config,
|
|
@@ -170,7 +207,7 @@ class MemoryXPlugin {
|
|
|
170
207
|
}
|
|
171
208
|
}
|
|
172
209
|
saveConfig() {
|
|
173
|
-
|
|
210
|
+
SQLiteStorage.save(this.config);
|
|
174
211
|
}
|
|
175
212
|
async autoRegister() {
|
|
176
213
|
try {
|
|
@@ -334,14 +371,14 @@ let plugin;
|
|
|
334
371
|
export default {
|
|
335
372
|
id: "memoryx-openclaw-plugin",
|
|
336
373
|
name: "MemoryX Real-time Plugin",
|
|
337
|
-
version: "1.1.
|
|
374
|
+
version: "1.1.1",
|
|
338
375
|
description: "Real-time memory capture and recall for OpenClaw",
|
|
339
376
|
register(api, pluginConfig) {
|
|
340
377
|
api.logger.info("[MemoryX] Plugin registering...");
|
|
341
378
|
if (pluginConfig?.apiBaseUrl) {
|
|
342
379
|
api.logger.info(`[MemoryX] API Base: \`${pluginConfig.apiBaseUrl}\``);
|
|
343
380
|
}
|
|
344
|
-
api.logger.info(`[MemoryX]
|
|
381
|
+
api.logger.info(`[MemoryX] Database: ${getDbPath()}`);
|
|
345
382
|
plugin = new MemoryXPlugin(pluginConfig);
|
|
346
383
|
api.on("message_received", async (event, ctx) => {
|
|
347
384
|
const { content, from, timestamp } = event;
|
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": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "MemoryX real-time memory capture and recall plugin for OpenClaw",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "MemoryX Team",
|
|
@@ -26,14 +26,18 @@
|
|
|
26
26
|
"directory": "plugins/memoryx-realtime-plugin"
|
|
27
27
|
},
|
|
28
28
|
"openclaw": {
|
|
29
|
-
"extensions": [
|
|
29
|
+
"extensions": [
|
|
30
|
+
"./dist/index.js"
|
|
31
|
+
]
|
|
30
32
|
},
|
|
31
33
|
"devDependencies": {
|
|
34
|
+
"@types/better-sqlite3": "^7.6.0",
|
|
32
35
|
"@types/node": "^20.0.0",
|
|
33
36
|
"typescript": "^5.0.0"
|
|
34
37
|
},
|
|
35
38
|
"dependencies": {
|
|
36
39
|
"@huggingface/transformers": "^3.8.1",
|
|
40
|
+
"better-sqlite3": "^11.0.0",
|
|
37
41
|
"js-tiktoken": "^1.0.21",
|
|
38
42
|
"onnxruntime-node": "^1.24.1",
|
|
39
43
|
"onnxruntime-web": "^1.24.1"
|