@memtensor/memos-local-openclaw-plugin 0.3.10 → 0.3.11

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 CHANGED
@@ -77,16 +77,11 @@ Persistent local conversation memory for [OpenClaw](https://github.com/nicepkg/o
77
77
  openclaw plugins install @memtensor/memos-local-openclaw-plugin
78
78
  ```
79
79
 
80
- The plugin is installed under `~/.openclaw/extensions/memos-local-openclaw-plugin` and registered as `memos-local-openclaw-plugin`.
80
+ The plugin is installed under `~/.openclaw/extensions/memos-local-openclaw-plugin` and registered as `memos-local-openclaw-plugin`. Dependencies and native modules are built automatically during installation.
81
81
 
82
- > **If the gateway reports `Could not locate the bindings file` for better-sqlite3**, run:
83
- > ```bash
84
- > cd ~/.openclaw/extensions/memos-local-openclaw-plugin
85
- > npm rebuild better-sqlite3
86
- > ```
87
- > This compiles the native SQLite module for your system. Requires C++ build tools — macOS: `xcode-select --install`, Linux: `sudo apt install build-essential`.
88
-
89
- > **Important:** The Memory Viewer starts only when the **OpenClaw gateway** is running. After install, **configure** `openclaw.json` (step 2) and **start the gateway** (step 3); the viewer will then be available at `http://127.0.0.1:18799`.
82
+ > **Note:** The Memory Viewer starts only when the **OpenClaw gateway** is running. After install, **configure** `openclaw.json` (step 2) and **start the gateway** (step 3); the viewer will then be available at `http://127.0.0.1:18799`.
83
+ >
84
+ > If better-sqlite3 fails to build automatically, ensure you have C++ build tools installed: macOS: `xcode-select --install`, Linux: `sudo apt install build-essential`.
90
85
 
91
86
  **From source (development):**
92
87
 
@@ -467,36 +462,27 @@ TELEMETRY_ENABLED=false
467
462
  - Events are batched and sent in the background; failures are silently ignored
468
463
  - The anonymous ID is never linked to any personal information
469
464
 
470
- ## Reinstall / Upgrade
471
-
472
- If you see **"plugin already exists"** or **"plugin not found"**:
465
+ ## Upgrade
473
466
 
474
- **Option A — Clean reinstall via OpenClaw CLI:**
475
467
  ```bash
476
- rm -rf ~/.openclaw/extensions/memos-local-openclaw-plugin
477
- openclaw plugins install @memtensor/memos-local-openclaw-plugin
478
- cd ~/.openclaw/extensions/memos-local-openclaw-plugin && npm install --omit=dev
479
- openclaw gateway stop && openclaw gateway start
468
+ openclaw plugins update memos-local-openclaw-plugin
480
469
  ```
481
470
 
482
- **Option B Manual install (when config already references memos-local-openclaw-plugin):**
471
+ The plugin will automatically install dependencies, clean up legacy versions, and rebuild the native SQLite module. After update, restart the gateway:
472
+
483
473
  ```bash
484
- rm -rf ~/.openclaw/extensions/memos-local
485
- cd /tmp
486
- npm pack @memtensor/memos-local-openclaw-plugin
487
- tar -xzf memtensor-memos-local-openclaw-plugin-*.tgz
488
- mv package ~/.openclaw/extensions/memos-local-openclaw-plugin
489
- cd ~/.openclaw/extensions/memos-local-openclaw-plugin && npm install --omit=dev
490
474
  openclaw gateway stop && openclaw gateway start
491
475
  ```
492
476
 
493
- **Plugin shows as "error" in `openclaw plugins list`?** (e.g. `Cannot find module '@sinclair/typebox'`)
477
+ > **Tip:** To update all plugins at once: `openclaw plugins update --all`
478
+
479
+ **If `openclaw plugins update` doesn't work** (plugin not in install registry):
494
480
 
495
481
  ```bash
496
- cd ~/.openclaw/extensions/memos-local-openclaw-plugin && npm install --omit=dev
482
+ openclaw plugins install @memtensor/memos-local-openclaw-plugin
497
483
  ```
498
484
 
499
- Then restart the gateway.
485
+ This will reinstall the latest version. The postinstall script handles everything automatically — no need to manually delete directories or run `npm install`.
500
486
 
501
487
  ## Troubleshooting
502
488
 
@@ -21,7 +21,7 @@
21
21
  "openclaw": ">=2026.2.0"
22
22
  },
23
23
  "setup": {
24
- "postInstall": "npm install --omit=dev && npm rebuild better-sqlite3",
24
+ "postInstall": "node scripts/postinstall.cjs",
25
25
  "notes": [
26
26
  "After install, add to ~/.openclaw/openclaw.json: plugins.slots.memory = \"memos-local-openclaw-plugin\"",
27
27
  "Set agents.defaults.memorySearch.enabled = false to disable OpenClaw's built-in memory",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memtensor/memos-local-openclaw-plugin",
3
- "version": "0.3.10",
3
+ "version": "0.3.11",
4
4
  "description": "MemOS Local memory plugin for OpenClaw — full-write, hybrid-recall, progressive retrieval",
5
5
  "type": "module",
6
6
  "main": "index.ts",
@@ -18,6 +18,64 @@ function warn(msg) { console.log(`${YELLOW}[memos-local]${RESET} ${msg}`); }
18
18
  function ok(msg) { console.log(`${GREEN}[memos-local]${RESET} ${msg}`); }
19
19
  function fail(msg) { console.log(`${RED}[memos-local]${RESET} ${msg}`); }
20
20
 
21
+ const pluginDir = path.resolve(__dirname, "..");
22
+
23
+ console.log(`
24
+ ${CYAN}${BOLD}┌──────────────────────────────────────────────────┐
25
+ │ MemOS Local Memory — postinstall │
26
+ └──────────────────────────────────────────────────┘${RESET}
27
+ `);
28
+
29
+ log(`Plugin dir: ${DIM}${pluginDir}${RESET}`);
30
+ log(`Node: ${process.version} Platform: ${process.platform}-${process.arch}`);
31
+
32
+ /* ═══════════════════════════════════════════════════════════
33
+ * Phase 0: Ensure all dependencies are installed
34
+ * ═══════════════════════════════════════════════════════════ */
35
+
36
+ function ensureDependencies() {
37
+ const coreDeps = ["@sinclair/typebox", "uuid", "posthog-node", "@huggingface/transformers"];
38
+ const missing = [];
39
+ for (const dep of coreDeps) {
40
+ try {
41
+ require.resolve(dep, { paths: [pluginDir] });
42
+ } catch {
43
+ missing.push(dep);
44
+ }
45
+ }
46
+
47
+ if (missing.length === 0) {
48
+ ok("All dependencies present.");
49
+ return;
50
+ }
51
+
52
+ warn(`Missing dependencies: ${missing.join(", ")}`);
53
+ log("Running: npm install --omit=dev (this may take a moment)...");
54
+
55
+ const startMs = Date.now();
56
+ const result = spawnSync("npm", ["install", "--omit=dev"], {
57
+ cwd: pluginDir,
58
+ stdio: "inherit",
59
+ shell: true,
60
+ timeout: 120_000,
61
+ });
62
+ const elapsed = ((Date.now() - startMs) / 1000).toFixed(1);
63
+
64
+ if (result.status === 0) {
65
+ ok(`Dependencies installed (${elapsed}s).`);
66
+ } else {
67
+ fail(`npm install exited with code ${result.status} (${elapsed}s).`);
68
+ warn("Some features may not work. Try running manually:");
69
+ warn(` cd ${pluginDir} && npm install --omit=dev`);
70
+ }
71
+ }
72
+
73
+ try {
74
+ ensureDependencies();
75
+ } catch (e) {
76
+ warn(`Dependency check skipped: ${e.message}`);
77
+ }
78
+
21
79
  /* ═══════════════════════════════════════════════════════════
22
80
  * Phase 1: Clean up legacy plugin versions
23
81
  * ═══════════════════════════════════════════════════════════ */
@@ -52,7 +110,6 @@ function cleanupLegacy() {
52
110
  }
53
111
  }
54
112
 
55
- // Clean up openclaw.json config — migrate old plugin entries
56
113
  const cfgPath = path.join(ocHome, "openclaw.json");
57
114
  if (fs.existsSync(cfgPath)) {
58
115
  try {
@@ -67,9 +124,8 @@ function cleanupLegacy() {
67
124
  if (entries[oldKey]) {
68
125
  const oldEntry = entries[oldKey];
69
126
  if (!entries["memos-local-openclaw-plugin"]) {
70
- // Migrate: copy old config to new key
71
127
  entries["memos-local-openclaw-plugin"] = oldEntry;
72
- log(`Migrated config: ${DIM}${oldKey}${RESET} ${GREEN}memos-local-openclaw-plugin${RESET}`);
128
+ log(`Migrated config: ${DIM}${oldKey}${RESET} -> ${GREEN}memos-local-openclaw-plugin${RESET}`);
73
129
  }
74
130
  delete entries[oldKey];
75
131
  cfgChanged = true;
@@ -77,7 +133,6 @@ function cleanupLegacy() {
77
133
  }
78
134
  }
79
135
 
80
- // Fix source path if it points to old directory names
81
136
  const newEntry = entries["memos-local-openclaw-plugin"];
82
137
  if (newEntry && typeof newEntry.source === "string") {
83
138
  const oldSource = newEntry.source;
@@ -86,14 +141,13 @@ function cleanupLegacy() {
86
141
  .replace(/memos-lite-openclaw-plugin/g, "memos-local-openclaw-plugin")
87
142
  .replace(/memos-lite/g, "memos-local");
88
143
  if (newEntry.source !== oldSource) {
89
- log(`Updated source path: ${DIM}${oldSource}${RESET} ${GREEN}${newEntry.source}${RESET}`);
144
+ log(`Updated source path: ${DIM}${oldSource}${RESET} -> ${GREEN}${newEntry.source}${RESET}`);
90
145
  cfgChanged = true;
91
146
  }
92
147
  }
93
148
  }
94
149
 
95
150
  if (cfgChanged) {
96
- // Write back with backup
97
151
  const backup = cfgPath + ".bak-" + Date.now();
98
152
  fs.copyFileSync(cfgPath, backup);
99
153
  fs.writeFileSync(cfgPath, JSON.stringify(cfg, null, 2) + "\n", "utf-8");
@@ -127,18 +181,18 @@ log("Checking better-sqlite3 native module...");
127
181
  try {
128
182
  require("better-sqlite3");
129
183
  ok("better-sqlite3 is ready.");
184
+ console.log(`\n${GREEN}${BOLD}[memos-local] Setup complete!${RESET} Restart the gateway: ${CYAN}openclaw gateway stop && openclaw gateway start${RESET}\n`);
130
185
  process.exit(0);
131
186
  } catch (_) {
132
187
  warn("better-sqlite3 native bindings not found, attempting rebuild...");
133
188
  }
134
189
 
135
- log(`Node: ${process.version} Platform: ${process.platform}-${process.arch}`);
136
190
  log("Running: npm rebuild better-sqlite3 (this may take 30-60 seconds)...");
137
191
 
138
192
  const startMs = Date.now();
139
193
 
140
194
  const result = spawnSync("npm", ["rebuild", "better-sqlite3"], {
141
- cwd: path.resolve(__dirname, ".."),
195
+ cwd: pluginDir,
142
196
  stdio: "inherit",
143
197
  shell: true,
144
198
  timeout: 180_000,
@@ -151,6 +205,7 @@ if (result.status === 0) {
151
205
  delete require.cache[require.resolve("better-sqlite3")];
152
206
  require("better-sqlite3");
153
207
  ok(`better-sqlite3 rebuilt successfully (${elapsed}s).`);
208
+ console.log(`\n${GREEN}${BOLD}[memos-local] Setup complete!${RESET} Restart the gateway: ${CYAN}openclaw gateway stop && openclaw gateway start${RESET}\n`);
154
209
  process.exit(0);
155
210
  } catch (_) {
156
211
  fail(`Rebuild completed but module still cannot load (${elapsed}s).`);
@@ -159,7 +214,6 @@ if (result.status === 0) {
159
214
  fail(`Rebuild failed with exit code ${result.status} (${elapsed}s).`);
160
215
  }
161
216
 
162
- const pluginDir = path.resolve(__dirname, "..");
163
217
  console.log(`
164
218
  ${YELLOW}${BOLD}╔══════════════════════════════════════════════════════════════╗
165
219
  ║ better-sqlite3 native module build failed ║
@@ -176,6 +230,7 @@ ${YELLOW}║${RESET}
176
230
  ${YELLOW}║${RESET} Then retry: ${YELLOW}║${RESET}
177
231
  ${YELLOW}║${RESET} ${GREEN}cd ${pluginDir}${RESET}
178
232
  ${YELLOW}║${RESET} ${GREEN}npm rebuild better-sqlite3${RESET} ${YELLOW}║${RESET}
233
+ ${YELLOW}║${RESET} ${GREEN}openclaw gateway stop && openclaw gateway start${RESET} ${YELLOW}║${RESET}
179
234
  ${YELLOW}${BOLD}╚══════════════════════════════════════════════════════════════╝${RESET}
180
235
  `);
181
236