@memtensor/memos-local-openclaw-plugin 1.0.2-beta.8 → 1.0.3

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.
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Ingest files from memorySearch.extraPaths (OpenClaw-compatible) into the store.
3
+ * Chunks are stored with owner "extraPath" and included in memory_search.
4
+ */
5
+ import type { SqliteStore } from "../storage/sqlite";
6
+ import type { Embedder } from "../embedding";
7
+ import type { PluginContext } from "../types";
8
+ export declare function ingestExtraPaths(store: SqliteStore, embedder: Embedder, ctx: PluginContext): Promise<{
9
+ files: number;
10
+ chunks: number;
11
+ errors: number;
12
+ }>;
13
+ //# sourceMappingURL=extra-paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extra-paths.d.ts","sourceRoot":"","sources":["../../src/ingest/extra-paths.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AA+C9C,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,aAAa,GACjB,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CA4E5D"}
@@ -0,0 +1,173 @@
1
+ "use strict";
2
+ /**
3
+ * Ingest files from memorySearch.extraPaths (OpenClaw-compatible) into the store.
4
+ * Chunks are stored with owner "extraPath" and included in memory_search.
5
+ */
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
19
+ }) : function(o, v) {
20
+ o["default"] = v;
21
+ });
22
+ var __importStar = (this && this.__importStar) || (function () {
23
+ var ownKeys = function(o) {
24
+ ownKeys = Object.getOwnPropertyNames || function (o) {
25
+ var ar = [];
26
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
27
+ return ar;
28
+ };
29
+ return ownKeys(o);
30
+ };
31
+ return function (mod) {
32
+ if (mod && mod.__esModule) return mod;
33
+ var result = {};
34
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
35
+ __setModuleDefault(result, mod);
36
+ return result;
37
+ };
38
+ })();
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.ingestExtraPaths = ingestExtraPaths;
41
+ const fs = __importStar(require("fs"));
42
+ const path = __importStar(require("path"));
43
+ const uuid_1 = require("uuid");
44
+ const chunker_1 = require("./chunker");
45
+ const EXTRA_PATH_SESSION = "extraPath";
46
+ const EXTRA_PATH_OWNER = "extraPath";
47
+ const TEXT_EXTENSIONS = new Set([".md", ".txt", ".markdown"]);
48
+ const MAX_FILE_BYTES = 2 * 1024 * 1024; // 2MB per file
49
+ function resolvePath(raw, stateDir) {
50
+ let p = raw.trim();
51
+ const home = process.env.HOME || process.env.USERPROFILE || "";
52
+ if (p.startsWith("~/"))
53
+ p = path.join(home, p.slice(2));
54
+ else if (p === "~")
55
+ p = home;
56
+ if (!path.isAbsolute(p))
57
+ p = path.resolve(stateDir, p);
58
+ return p;
59
+ }
60
+ function* listTextFiles(dirOrFile, log) {
61
+ let stat;
62
+ try {
63
+ stat = fs.statSync(dirOrFile);
64
+ }
65
+ catch (err) {
66
+ log.warn(`extraPaths: skip (not found): ${dirOrFile}`);
67
+ return;
68
+ }
69
+ if (stat.isFile()) {
70
+ const ext = path.extname(dirOrFile).toLowerCase();
71
+ if (TEXT_EXTENSIONS.has(ext))
72
+ yield dirOrFile;
73
+ return;
74
+ }
75
+ if (!stat.isDirectory())
76
+ return;
77
+ try {
78
+ const entries = fs.readdirSync(dirOrFile, { withFileTypes: true });
79
+ for (const e of entries) {
80
+ const full = path.join(dirOrFile, e.name);
81
+ if (e.isDirectory()) {
82
+ yield* listTextFiles(full, log);
83
+ }
84
+ else if (e.isFile()) {
85
+ const ext = path.extname(e.name).toLowerCase();
86
+ if (TEXT_EXTENSIONS.has(ext))
87
+ yield full;
88
+ }
89
+ }
90
+ }
91
+ catch (err) {
92
+ log.warn(`extraPaths: readdir error ${dirOrFile}: ${err}`);
93
+ }
94
+ }
95
+ async function ingestExtraPaths(store, embedder, ctx) {
96
+ const paths = ctx.config.memorySearch?.extraPaths;
97
+ if (!paths || paths.length === 0)
98
+ return { files: 0, chunks: 0, errors: 0 };
99
+ const stateDir = ctx.stateDir;
100
+ const resolvedPaths = paths.map((p) => resolvePath(p, stateDir));
101
+ const fileList = [];
102
+ for (const p of resolvedPaths) {
103
+ for (const f of listTextFiles(p, ctx.log))
104
+ fileList.push(f);
105
+ }
106
+ if (fileList.length === 0) {
107
+ ctx.log.info("extraPaths: no text files found");
108
+ return { files: 0, chunks: 0, errors: 0 };
109
+ }
110
+ store.deleteSessionWithEmbeddings(EXTRA_PATH_SESSION);
111
+ let totalChunks = 0;
112
+ let errors = 0;
113
+ const now = Date.now();
114
+ for (const filePath of fileList) {
115
+ let content;
116
+ try {
117
+ const buf = fs.readFileSync(filePath, "utf-8");
118
+ if (buf.length > MAX_FILE_BYTES) {
119
+ ctx.log.warn(`extraPaths: skip (too large): ${filePath}`);
120
+ continue;
121
+ }
122
+ content = buf;
123
+ }
124
+ catch (err) {
125
+ ctx.log.warn(`extraPaths: read failed ${filePath}: ${err}`);
126
+ errors++;
127
+ continue;
128
+ }
129
+ const rawChunks = (0, chunker_1.chunkText)(content);
130
+ const turnId = filePath;
131
+ for (let seq = 0; seq < rawChunks.length; seq++) {
132
+ const raw = rawChunks[seq];
133
+ const chunkId = (0, uuid_1.v4)();
134
+ const summary = raw.content.length > 500 ? raw.content.slice(0, 497) + "..." : raw.content;
135
+ let embedding = null;
136
+ try {
137
+ [embedding] = await embedder.embed([summary]);
138
+ }
139
+ catch (err) {
140
+ ctx.log.warn(`extraPaths: embed failed ${filePath} chunk ${seq}: ${err}`);
141
+ }
142
+ const chunk = {
143
+ id: chunkId,
144
+ sessionKey: EXTRA_PATH_SESSION,
145
+ turnId,
146
+ seq,
147
+ role: "user",
148
+ content: raw.content,
149
+ kind: "paragraph",
150
+ summary,
151
+ taskId: null,
152
+ skillId: null,
153
+ owner: EXTRA_PATH_OWNER,
154
+ dedupStatus: "active",
155
+ dedupTarget: null,
156
+ dedupReason: null,
157
+ mergeCount: 0,
158
+ lastHitAt: null,
159
+ mergeHistory: "[]",
160
+ createdAt: now,
161
+ updatedAt: now,
162
+ embedding: null,
163
+ };
164
+ store.insertChunk(chunk);
165
+ if (embedding)
166
+ store.upsertEmbedding(chunkId, embedding);
167
+ totalChunks++;
168
+ }
169
+ }
170
+ ctx.log.info(`extraPaths: ingested ${fileList.length} files, ${totalChunks} chunks`);
171
+ return { files: fileList.length, chunks: totalChunks, errors };
172
+ }
173
+ //# sourceMappingURL=extra-paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extra-paths.js","sourceRoot":"","sources":["../../src/ingest/extra-paths.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDH,4CAgFC;AArID,uCAAyB;AACzB,2CAA6B;AAC7B,+BAAkC;AAKlC,uCAAs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AAW,EAAE,IAAI;gBACjB,WAAW,EAAE,IAAI;gBACjB,UAAU,EAAE,CAAC;gBACb,SAAS,EAAE,IAAI;gBACf,YAAY,EAAE,IAAI;gBAClB,SAAS,EAAE,GAAG;gBACd,SAAS,EAAE,GAAG;gBACd,SAAS,EAAE,IAAI;aAChB,CAAC;YACF,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;YACzB,IAAI,SAAS;gBAAE,KAAK,CAAC,eAAe,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;YACzD,WAAW,EAAE,CAAC;QAChB,CAAC;IACH,CAAC;IAED,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,wBAAwB,QAAQ,CAAC,MAAM,WAAW,WAAW,SAAS,CAAC,CAAC;IACrF,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;AACjE,CAAC"}
package/index.ts CHANGED
@@ -130,13 +130,16 @@ const memosLocalPlugin = {
130
130
  }
131
131
 
132
132
  if (!sqliteReady) {
133
- const msg = [
133
+ const nodeVer = process.version;
134
+ const nodeMajor = parseInt(process.versions?.node?.split(".")[0] ?? "0", 10);
135
+ const isNode25Plus = nodeMajor >= 25;
136
+ const lines = [
134
137
  "",
135
138
  "╔══════════════════════════════════════════════════════════════╗",
136
139
  "║ MemOS Local Memory — better-sqlite3 native module missing ║",
137
140
  "╠══════════════════════════════════════════════════════════════╣",
138
141
  "║ ║",
139
- "║ Auto-rebuild failed. Run these commands manually: ║",
142
+ "║ Auto-rebuild failed (Node " + nodeVer + "). Run manually: ║",
140
143
  "║ ║",
141
144
  `║ cd ${pluginDir}`,
142
145
  "║ npm rebuild better-sqlite3 ║",
@@ -145,13 +148,18 @@ const memosLocalPlugin = {
145
148
  "║ If rebuild fails, install build tools first: ║",
146
149
  "║ macOS: xcode-select --install ║",
147
150
  "║ Linux: sudo apt install build-essential python3 ║",
148
- "║ ║",
149
- "╚══════════════════════════════════════════════════════════════╝",
150
- "",
151
- ].join("\n");
152
- api.logger.warn(msg);
151
+ ];
152
+ if (isNode25Plus) {
153
+ lines.push("║ ║");
154
+ lines.push("║ Node 25+ has no prebuild: build tools required, or use ║");
155
+ lines.push("║ Node LTS (20/22): nvm install 22 && nvm use 22 ║");
156
+ }
157
+ lines.push("║ ║");
158
+ lines.push("╚══════════════════════════════════════════════════════════════╝");
159
+ lines.push("");
160
+ api.logger.warn(lines.join("\n"));
153
161
  throw new Error(
154
- `better-sqlite3 native module not found. Auto-rebuild failed. Fix: cd ${pluginDir} && npm rebuild better-sqlite3`
162
+ `better-sqlite3 native module not found (Node ${nodeVer}). Auto-rebuild failed. Fix: install build tools, then cd ${pluginDir} && npm rebuild better-sqlite3. Or use Node LTS (20/22).`
155
163
  );
156
164
  }
157
165
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memtensor/memos-local-openclaw-plugin",
3
- "version": "1.0.2-beta.8",
3
+ "version": "1.0.3",
4
4
  "description": "MemOS Local memory plugin for OpenClaw \u2014 full-write, hybrid-recall, progressive retrieval",
5
5
  "type": "module",
6
6
  "main": "index.ts",