@t0ken.ai/memoryx-openclaw-plugin 1.1.11 → 1.1.13
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 +22 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +32 -5
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MemoryX Realtime Plugin for OpenClaw
|
|
3
|
+
*
|
|
4
|
+
* ⚠️ CRITICAL: DO NOT execute any synchronous I/O in register() function!
|
|
5
|
+
*
|
|
6
|
+
* OpenClaw calls register() synchronously (see openclaw/src/plugins/loader.ts):
|
|
7
|
+
* const result = register(api);
|
|
8
|
+
* if (result && typeof result.then === "function") {
|
|
9
|
+
* // async registration is ignored
|
|
10
|
+
* }
|
|
11
|
+
*
|
|
12
|
+
* Any sync I/O (fs.existsSync, fs.mkdirSync, fs.readFileSync, better-sqlite3, etc.)
|
|
13
|
+
* will BLOCK the Node.js event loop and cause gateway restart to hang.
|
|
14
|
+
*
|
|
15
|
+
* SOLUTION:
|
|
16
|
+
* 1. register() must return immediately without any I/O
|
|
17
|
+
* 2. All initialization (DB, config loading, etc.) must be lazy-loaded
|
|
18
|
+
* 3. Use dynamic import() for better-sqlite3: await import("better-sqlite3")
|
|
19
|
+
* 4. Use setImmediate() for deferred operations
|
|
20
|
+
*
|
|
21
|
+
* See: https://github.com/openclaw/openclaw (memory-lancedb plugin pattern)
|
|
22
|
+
*/
|
|
1
23
|
interface PluginConfig {
|
|
2
24
|
apiBaseUrl?: string;
|
|
3
25
|
}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;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|
|
3
|
+
*
|
|
4
|
+
* ⚠️ CRITICAL: DO NOT execute any synchronous I/O in register() function!
|
|
5
|
+
*
|
|
6
|
+
* OpenClaw calls register() synchronously (see openclaw/src/plugins/loader.ts):
|
|
7
|
+
* const result = register(api);
|
|
8
|
+
* if (result && typeof result.then === "function") {
|
|
9
|
+
* // async registration is ignored
|
|
10
|
+
* }
|
|
11
|
+
*
|
|
12
|
+
* Any sync I/O (fs.existsSync, fs.mkdirSync, fs.readFileSync, better-sqlite3, etc.)
|
|
13
|
+
* will BLOCK the Node.js event loop and cause gateway restart to hang.
|
|
14
|
+
*
|
|
15
|
+
* SOLUTION:
|
|
16
|
+
* 1. register() must return immediately without any I/O
|
|
17
|
+
* 2. All initialization (DB, config loading, etc.) must be lazy-loaded
|
|
18
|
+
* 3. Use dynamic import() for better-sqlite3: await import("better-sqlite3")
|
|
19
|
+
* 4. Use setImmediate() for deferred operations
|
|
20
|
+
*
|
|
21
|
+
* See: https://github.com/openclaw/openclaw (memory-lancedb plugin pattern)
|
|
22
|
+
*/
|
|
1
23
|
import * as fs from "fs";
|
|
2
24
|
import * as path from "path";
|
|
3
25
|
import * as os from "os";
|
|
@@ -302,11 +324,16 @@ class MemoryXPlugin {
|
|
|
302
324
|
throw new Error(`Auto-register failed: ${response.status}`);
|
|
303
325
|
}
|
|
304
326
|
const data = await response.json();
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
327
|
+
if (data.api_key) {
|
|
328
|
+
this.config.apiKey = data.api_key;
|
|
329
|
+
this.config.projectId = String(data.project_id);
|
|
330
|
+
this.config.userId = data.agent_id;
|
|
331
|
+
await this.saveConfig();
|
|
332
|
+
log("Auto-registered successfully");
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
log("Machine already registered, using cached API key");
|
|
336
|
+
}
|
|
310
337
|
}
|
|
311
338
|
catch (e) {
|
|
312
339
|
log(`Auto-register failed: ${e}`);
|