@memtensor/memos-local-openclaw-plugin 0.3.15 โ 0.3.17
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 +5 -2
- package/index.ts +26 -18
- package/package.json +1 -1
- package/scripts/postinstall.cjs +28 -9
package/README.md
CHANGED
|
@@ -476,16 +476,19 @@ openclaw gateway stop && openclaw gateway start
|
|
|
476
476
|
|
|
477
477
|
> **Tip:** To update all plugins at once: `openclaw plugins update --all`
|
|
478
478
|
|
|
479
|
-
**If `openclaw plugins update` doesn't work** (plugin not in install registry):
|
|
479
|
+
**If `openclaw plugins update` doesn't work** (plugin not in install registry), reinstall:
|
|
480
480
|
|
|
481
481
|
```bash
|
|
482
|
+
rm -rf ~/.openclaw/extensions/memos-local-openclaw-plugin
|
|
482
483
|
openclaw plugins install @memtensor/memos-local-openclaw-plugin
|
|
483
484
|
```
|
|
484
485
|
|
|
485
|
-
|
|
486
|
+
> **Note:** `openclaw plugins install` requires the target directory to not exist. If you see `plugin already exists`, delete the directory first. Your memory data is stored separately at `~/.openclaw/memos-local/memos.db` and will not be affected.
|
|
486
487
|
|
|
487
488
|
## Troubleshooting
|
|
488
489
|
|
|
490
|
+
> ๐ **่ฏฆ็ปๆๆฅๆๅ / Detailed troubleshooting guide:** [docs/troubleshooting.html](https://memtensor.github.io/MemOS/apps/memos-local-openclaw/docs/troubleshooting.html) โ ๅ
ๅซ้ๆญฅๆๆฅๆต็จใๆฅๅฟๆฅ็ๆนๆณใๅฎๅ
จ้่ฃ
ๆญฅ้ชค็ญใ
|
|
491
|
+
|
|
489
492
|
### Common Issues
|
|
490
493
|
|
|
491
494
|
1. **Note the exact error** โ e.g. `plugin not found`, `Cannot find module 'xxx'`, `Invalid config`.
|
package/index.ts
CHANGED
|
@@ -14,7 +14,7 @@ import { SqliteStore } from "./src/storage/sqlite";
|
|
|
14
14
|
import { Embedder } from "./src/embedding";
|
|
15
15
|
import { IngestWorker } from "./src/ingest/worker";
|
|
16
16
|
import { RecallEngine } from "./src/recall/engine";
|
|
17
|
-
import { captureMessages } from "./src/capture";
|
|
17
|
+
import { captureMessages, stripInboundMetadata } from "./src/capture";
|
|
18
18
|
import { DEFAULTS } from "./src/types";
|
|
19
19
|
import { ViewerServer } from "./src/viewer/server";
|
|
20
20
|
import { SkillEvolver } from "./src/skill/evolver";
|
|
@@ -76,17 +76,27 @@ const memosLocalPlugin = {
|
|
|
76
76
|
|
|
77
77
|
register(api: OpenClawPluginApi) {
|
|
78
78
|
// โโโ Ensure better-sqlite3 native module is available โโโ
|
|
79
|
+
const pluginDir = path.dirname(new URL(import.meta.url).pathname);
|
|
79
80
|
let sqliteReady = false;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
|
|
82
|
+
function trySqliteLoad(): boolean {
|
|
83
|
+
try {
|
|
84
|
+
const resolved = require.resolve("better-sqlite3", { paths: [pluginDir] });
|
|
85
|
+
if (!resolved.startsWith(pluginDir)) {
|
|
86
|
+
api.logger.warn(`memos-local: better-sqlite3 resolved outside plugin dir: ${resolved}`);
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
require(resolved);
|
|
90
|
+
return true;
|
|
91
|
+
} catch {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
85
94
|
}
|
|
86
95
|
|
|
96
|
+
sqliteReady = trySqliteLoad();
|
|
97
|
+
|
|
87
98
|
if (!sqliteReady) {
|
|
88
|
-
|
|
89
|
-
api.logger.warn(`memos-local: better-sqlite3 not found, attempting auto-rebuild in ${pluginDir} ...`);
|
|
99
|
+
api.logger.warn(`memos-local: better-sqlite3 not found in ${pluginDir}, attempting auto-rebuild ...`);
|
|
90
100
|
|
|
91
101
|
try {
|
|
92
102
|
const { spawnSync } = require("child_process");
|
|
@@ -103,16 +113,14 @@ const memosLocalPlugin = {
|
|
|
103
113
|
if (stderr) api.logger.warn(`memos-local: rebuild stderr: ${stderr.slice(0, 500)}`);
|
|
104
114
|
|
|
105
115
|
if (rebuildResult.status === 0) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
delete require.cache[
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
require("better-sqlite3");
|
|
112
|
-
sqliteReady = true;
|
|
116
|
+
Object.keys(require.cache)
|
|
117
|
+
.filter(k => k.includes("better-sqlite3") || k.includes("better_sqlite3"))
|
|
118
|
+
.forEach(k => delete require.cache[k]);
|
|
119
|
+
sqliteReady = trySqliteLoad();
|
|
120
|
+
if (sqliteReady) {
|
|
113
121
|
api.logger.info("memos-local: better-sqlite3 auto-rebuild succeeded!");
|
|
114
|
-
}
|
|
115
|
-
api.logger.warn(
|
|
122
|
+
} else {
|
|
123
|
+
api.logger.warn("memos-local: rebuild exited 0 but module still not loadable from plugin dir");
|
|
116
124
|
}
|
|
117
125
|
} else {
|
|
118
126
|
api.logger.warn(`memos-local: rebuild exited with code ${rebuildResult.status}`);
|
|
@@ -710,7 +718,7 @@ const memosLocalPlugin = {
|
|
|
710
718
|
const tail = rawPrompt.slice(lastDoubleNewline + 2).trim();
|
|
711
719
|
if (tail.length >= 2) query = tail;
|
|
712
720
|
}
|
|
713
|
-
query = query
|
|
721
|
+
query = stripInboundMetadata(query);
|
|
714
722
|
query = query.replace(/<[^>]+>/g, "").trim();
|
|
715
723
|
recallQuery = query;
|
|
716
724
|
|
package/package.json
CHANGED
package/scripts/postinstall.cjs
CHANGED
|
@@ -190,8 +190,27 @@ try {
|
|
|
190
190
|
|
|
191
191
|
phase(2, "ๆฃๆฅ better-sqlite3 ๅ็ๆจกๅ / Check native module");
|
|
192
192
|
|
|
193
|
-
|
|
194
|
-
|
|
193
|
+
const sqliteModulePath = path.join(pluginDir, "node_modules", "better-sqlite3");
|
|
194
|
+
const sqliteBuildDir = path.join(sqliteModulePath, "build", "Release");
|
|
195
|
+
const sqliteBindingFile = path.join(sqliteBuildDir, "better_sqlite3.node");
|
|
196
|
+
|
|
197
|
+
function sqliteBindingsExist() {
|
|
198
|
+
if (fs.existsSync(sqliteBindingFile)) return true;
|
|
199
|
+
try {
|
|
200
|
+
const resolved = require.resolve("better-sqlite3", { paths: [pluginDir] });
|
|
201
|
+
log(`Resolved better-sqlite3 at: ${DIM}${resolved}${RESET}`);
|
|
202
|
+
if (!resolved.startsWith(pluginDir)) {
|
|
203
|
+
warn("Resolved outside plugin dir โ treating as missing.");
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
require(resolved);
|
|
207
|
+
return true;
|
|
208
|
+
} catch {
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (sqliteBindingsExist()) {
|
|
195
214
|
ok("better-sqlite3 is ready.");
|
|
196
215
|
console.log(`
|
|
197
216
|
${GREEN}${BOLD} โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
@@ -202,8 +221,9 @@ ${GREEN}${BOLD} โโโโโโโโโโโโโโโโโโโโโ
|
|
|
202
221
|
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ${RESET}
|
|
203
222
|
`);
|
|
204
223
|
process.exit(0);
|
|
205
|
-
}
|
|
206
|
-
warn("better-sqlite3 native bindings not found.");
|
|
224
|
+
} else {
|
|
225
|
+
warn("better-sqlite3 native bindings not found in plugin dir.");
|
|
226
|
+
log(`Expected: ${DIM}${sqliteBindingFile}${RESET}`);
|
|
207
227
|
log("Running: npm rebuild better-sqlite3 (may take 30-60s)...");
|
|
208
228
|
}
|
|
209
229
|
|
|
@@ -224,9 +244,7 @@ if (stdout) log(`rebuild output: ${DIM}${stdout.slice(0, 500)}${RESET}`);
|
|
|
224
244
|
if (stderr) warn(`rebuild stderr: ${DIM}${stderr.slice(0, 500)}${RESET}`);
|
|
225
245
|
|
|
226
246
|
if (result.status === 0) {
|
|
227
|
-
|
|
228
|
-
delete require.cache[require.resolve("better-sqlite3")];
|
|
229
|
-
require("better-sqlite3");
|
|
247
|
+
if (sqliteBindingsExist()) {
|
|
230
248
|
ok(`better-sqlite3 rebuilt successfully (${elapsed}s).`);
|
|
231
249
|
console.log(`
|
|
232
250
|
${GREEN}${BOLD} โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
@@ -237,8 +255,9 @@ ${GREEN}${BOLD} โโโโโโโโโโโโโโโโโโโโโ
|
|
|
237
255
|
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ${RESET}
|
|
238
256
|
`);
|
|
239
257
|
process.exit(0);
|
|
240
|
-
}
|
|
241
|
-
fail(`Rebuild completed but
|
|
258
|
+
} else {
|
|
259
|
+
fail(`Rebuild completed but bindings still missing (${elapsed}s).`);
|
|
260
|
+
fail(`Looked in: ${sqliteBuildDir}`);
|
|
242
261
|
}
|
|
243
262
|
} else {
|
|
244
263
|
fail(`Rebuild failed with exit code ${result.status} (${elapsed}s).`);
|