@engramx/client 0.16.0-rc.2 → 0.16.0-rc.21

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.
Files changed (95) hide show
  1. package/README.md +69 -8
  2. package/dist/EngramClient.d.ts +60 -16
  3. package/dist/EngramClient.js +139 -70
  4. package/dist/EngramClient.js.map +1 -1
  5. package/dist/MarketClient.js.map +1 -1
  6. package/dist/ProfileManager.d.ts +3 -19
  7. package/dist/ProfileManager.js +1 -58
  8. package/dist/ProfileManager.js.map +1 -1
  9. package/dist/SessionManager.d.ts +1 -1
  10. package/dist/SessionManager.js.map +1 -1
  11. package/dist/actionReceipt.d.ts +8 -0
  12. package/dist/actionReceipt.js +8 -0
  13. package/dist/actionReceipt.js.map +1 -1
  14. package/dist/birthChain.d.ts +87 -0
  15. package/dist/birthChain.js +233 -0
  16. package/dist/birthChain.js.map +1 -0
  17. package/dist/cache.js.map +1 -1
  18. package/dist/certifiedAudit.d.ts +31 -0
  19. package/dist/certifiedAudit.js +124 -0
  20. package/dist/certifiedAudit.js.map +1 -1
  21. package/dist/claude-setup.d.ts +15 -6
  22. package/dist/claude-setup.js +30 -17
  23. package/dist/claude-setup.js.map +1 -1
  24. package/dist/cli.d.ts +7 -1
  25. package/dist/cli.js +212 -187
  26. package/dist/cli.js.map +1 -1
  27. package/dist/connect-config.d.ts +109 -0
  28. package/dist/connect-config.js +251 -0
  29. package/dist/connect-config.js.map +1 -0
  30. package/dist/encryption.d.ts +4 -0
  31. package/dist/encryption.js +7 -1
  32. package/dist/encryption.js.map +1 -1
  33. package/dist/evidence.d.ts +94 -0
  34. package/dist/evidence.js +352 -0
  35. package/dist/evidence.js.map +1 -0
  36. package/dist/idl.d.ts +21 -3
  37. package/dist/idl.js +34 -4
  38. package/dist/idl.js.map +1 -1
  39. package/dist/index.d.ts +13 -6
  40. package/dist/index.js +22 -5
  41. package/dist/index.js.map +1 -1
  42. package/dist/ledgerfsHash.d.ts +0 -2
  43. package/dist/ledgerfsHash.js +0 -2
  44. package/dist/ledgerfsHash.js.map +1 -1
  45. package/dist/lineage.d.ts +7 -1
  46. package/dist/lineage.js +7 -1
  47. package/dist/lineage.js.map +1 -1
  48. package/dist/memoryArchive.d.ts +77 -98
  49. package/dist/memoryArchive.js +58 -31
  50. package/dist/memoryArchive.js.map +1 -1
  51. package/dist/migrate.d.ts +18 -30
  52. package/dist/migrate.js +42 -136
  53. package/dist/migrate.js.map +1 -1
  54. package/dist/openEngram.d.ts +7 -0
  55. package/dist/openEngram.js +27 -3
  56. package/dist/openEngram.js.map +1 -1
  57. package/dist/openclaw-local.d.ts +86 -0
  58. package/dist/openclaw-local.js +332 -0
  59. package/dist/openclaw-local.js.map +1 -0
  60. package/dist/openclaw-setup.d.ts +82 -3
  61. package/dist/openclaw-setup.js +162 -50
  62. package/dist/openclaw-setup.js.map +1 -1
  63. package/dist/pair.js.map +1 -1
  64. package/dist/path-utils.d.ts +0 -16
  65. package/dist/path-utils.js +4 -27
  66. package/dist/path-utils.js.map +1 -1
  67. package/dist/publicRecord.d.ts +5 -0
  68. package/dist/publicRecord.js +52 -0
  69. package/dist/publicRecord.js.map +1 -0
  70. package/dist/recordChain.d.ts +69 -0
  71. package/dist/recordChain.js +145 -0
  72. package/dist/recordChain.js.map +1 -0
  73. package/dist/schema.d.ts +11 -22
  74. package/dist/schema.js +6 -28
  75. package/dist/schema.js.map +1 -1
  76. package/dist/types.d.ts +67 -451
  77. package/dist/verify.d.ts +8 -0
  78. package/dist/verify.js +19 -0
  79. package/dist/verify.js.map +1 -0
  80. package/dist/version.d.ts +22 -0
  81. package/dist/version.js +22 -0
  82. package/dist/version.js.map +1 -1
  83. package/package.json +27 -12
  84. package/dist/generated/engram.idl.d.ts +0 -6
  85. package/dist/generated/engram.idl.js +0 -1366
  86. package/dist/generated/engram.idl.js.map +0 -1
  87. package/dist/generated/market.idl.d.ts +0 -6
  88. package/dist/generated/market.idl.js +0 -557
  89. package/dist/generated/market.idl.js.map +0 -1
  90. package/dist/generated/registry.idl.d.ts +0 -6
  91. package/dist/generated/registry.idl.js +0 -510
  92. package/dist/generated/registry.idl.js.map +0 -1
  93. package/dist/offline.d.ts +0 -21
  94. package/dist/offline.js +0 -104
  95. package/dist/offline.js.map +0 -1
@@ -0,0 +1,332 @@
1
+ // Where OpenClaw keeps things on this machine, and the format of the database backups the OpenClaw
2
+ // plugin uploads and `migrate --recover` restores. ONE module for both halves.
3
+ //
4
+ // ⟨2026-10-13, the bloat audit⟩ WHY THIS FILE EXISTS. "Find OpenClaw's directory, read its config,
5
+ // find its memory directory and its databases" was written three times — in migrate.ts, in
6
+ // openclaw-setup.ts and in the plugin (integrations/openclaw/index.ts) — and the copies had drifted:
7
+ // different environment variables for the directory (OPENCLAW_STATE_DIR in the plugin,
8
+ // OPENCLAW_CONFIG_DIR here), different places for the builtin SQLite store (`<dir>/*.sqlite` in
9
+ // migrate, the configured store path or `<dir>/memory` in the plugin), and different database type
10
+ // names. The last one was a real defect: the plugin tagged its backups `openclaw-sqlite`,
11
+ // `openclaw-qmd` and `openclaw-lancedb`, and `migrate --recover` branched on `sqlite`, `qmd` and
12
+ // `lancedb`, which nothing writes — so every backup the plugin ever made fell into the restore's
13
+ // tar-extract branch: a single SQLite file (uploaded raw) failed to extract, and a QMD archive
14
+ // landed in the wrong folder under its encoded names. The writer and the reader of one format now
15
+ // live here, beside each other, and test/openclaw-local.test.ts round-trips them.
16
+ //
17
+ // THE BACKUP FORMAT (since 2026-10-13). SQLite and QMD: a gzipped tar of one entry per database
18
+ // file, each named `<base64url(path relative to the OpenClaw directory)>.sqlite` (an absolute path
19
+ // for a store configured outside it), so a restore knows where every file goes — on another
20
+ // machine too. (Until then a lone builtin SQLite file was
21
+ // uploaded raw, with no path at all, and QMD entries carried ABSOLUTE paths.) LanceDB: a gzipped tar
22
+ // of the store directory. A restore never writes outside the OpenClaw directory, and a backup in
23
+ // the old raw form is refused in words rather than guessed at.
24
+ // WHAT WOULD MAKE THIS WRONG: OpenClaw moving its builtin store away from the configured
25
+ // `agents.defaults.memorySearch.store.path` (default `<dir>/memory`), or the plugin writing a
26
+ // backup through anything but `encodeDatabaseBackup`.
27
+ import * as fs from 'node:fs';
28
+ import * as path from 'node:path';
29
+ import { randomBytes } from 'node:crypto';
30
+ import { execFileSync } from 'node:child_process';
31
+ import { tmpdir } from 'node:os';
32
+ /**
33
+ * OpenClaw's directory: `OPENCLAW_STATE_DIR` (OpenClaw's own variable, which the plugin read), else
34
+ * `OPENCLAW_CONFIG_DIR` (which this package's CLI read), else `~/.openclaw`.
35
+ */
36
+ export function getOpenClawDir() {
37
+ return (process.env['OPENCLAW_STATE_DIR'] ||
38
+ process.env['OPENCLAW_CONFIG_DIR'] ||
39
+ path.join(process.env['HOME'] || '', '.openclaw'));
40
+ }
41
+ /** openclaw.json (or `OPENCLAW_CONFIG_PATH`), or `{}` when it is absent or not JSON. Read-only:
42
+ * the paths that WRITE the config parse it strictly instead (openclaw-setup.ts readJsonConfig). */
43
+ export function loadOpenClawConfig(openclawDir) {
44
+ const configPath = process.env['OPENCLAW_CONFIG_PATH'] ?? path.join(openclawDir, 'openclaw.json');
45
+ if (!fs.existsSync(configPath))
46
+ return {};
47
+ try {
48
+ return JSON.parse(fs.readFileSync(configPath, 'utf-8'));
49
+ }
50
+ catch {
51
+ return {};
52
+ }
53
+ }
54
+ /**
55
+ * The memory directory: the plugin's own `memoryDir` (relative to the OpenClaw directory), else the
56
+ * base directory of the configured store path when it exists, else `<dir>/memory`.
57
+ */
58
+ export function resolveMemoryDir(openclawDir, ocConfig) {
59
+ const dir = ocConfig.plugins?.entries?.['memory-engramx']?.config?.memoryDir;
60
+ if (dir)
61
+ return path.isAbsolute(dir) ? dir : path.join(openclawDir, dir);
62
+ const storePath = ocConfig.agents?.defaults?.memorySearch?.store?.path;
63
+ if (storePath) {
64
+ // The store path may carry an {agentId} token: its base directory is what holds the files.
65
+ const withoutToken = storePath.replace(/\{agentId\}.*$/, '');
66
+ const resolved = path.isAbsolute(withoutToken)
67
+ ? path.dirname(withoutToken)
68
+ : path.join(openclawDir, path.dirname(withoutToken));
69
+ if (fs.existsSync(resolved))
70
+ return resolved;
71
+ }
72
+ return path.join(openclawDir, 'memory');
73
+ }
74
+ /** What a memory repo made by `git-setup`, `pair --git-remote` or the plugin leaves out. */
75
+ export const GITIGNORE_CONTENT = [
76
+ '# Auto-generated by memory-engramx',
77
+ '*.sqlite',
78
+ '*.sqlite-wal',
79
+ '*.sqlite-shm',
80
+ '*.db',
81
+ '*.db-wal',
82
+ '*.db-shm',
83
+ 'lancedb/',
84
+ '.DS_Store',
85
+ // ⟨2026-10-13, the second review⟩ The OpenClaw plugin's record of the paths it has synced with the
86
+ // engram, and its write-in-progress copy (integrations/openclaw/index.ts · knownPathsFile): this
87
+ // machine's state, not memory. Held by test/openclaw-setup.test.ts.
88
+ '.engramx-sync.json*',
89
+ '',
90
+ ].join('\n');
91
+ /** The backup type names on the engram, one per kind of database. The ONLY spelling. */
92
+ export const DB_TYPES = {
93
+ sqlite: 'openclaw-sqlite',
94
+ qmd: 'openclaw-qmd',
95
+ lancedb: 'openclaw-lancedb',
96
+ };
97
+ function findFilesByExt(dir, ext) {
98
+ if (!fs.existsSync(dir))
99
+ return [];
100
+ try {
101
+ return fs
102
+ .readdirSync(dir, { withFileTypes: true })
103
+ .filter((e) => e.isFile() && e.name.endsWith(ext))
104
+ .map((e) => path.join(dir, e.name));
105
+ }
106
+ catch {
107
+ return [];
108
+ }
109
+ }
110
+ /** The builtin SQLite store's directory: the configured store path's base, or `<dir>/memory`. */
111
+ function sqliteStoreDir(openclawDir, ocConfig) {
112
+ const storePath = ocConfig.agents?.defaults?.memorySearch?.store?.path;
113
+ if (!storePath)
114
+ return path.join(openclawDir, 'memory');
115
+ let baseDir = path.dirname(storePath.replace(/\{agentId\}/g, '*'));
116
+ if (baseDir.includes('*'))
117
+ baseDir = path.dirname(storePath.replace(/\{agentId\}.*$/, ''));
118
+ return path.isAbsolute(baseDir) ? baseDir : path.join(openclawDir, baseDir);
119
+ }
120
+ /** The configured LanceDB store directory. */
121
+ function lancedbDir(openclawDir, ocConfig) {
122
+ return (ocConfig.plugins?.entries?.['memory-lancedb']?.config?.dbPath ??
123
+ path.join(openclawDir, 'memory', 'lancedb'));
124
+ }
125
+ /** The databases openclaw.json says are active, and the files they are made of. */
126
+ export function detectDatabases(openclawDir, ocConfig = loadOpenClawConfig(openclawDir)) {
127
+ const detected = [];
128
+ const backend = ocConfig.memory?.backend ?? 'builtin';
129
+ // SQLite (builtin) — active when memory.backend is "builtin" or absent.
130
+ if (backend === 'builtin') {
131
+ const files = findFilesByExt(sqliteStoreDir(openclawDir, ocConfig), '.sqlite');
132
+ if (files.length > 0) {
133
+ detected.push({
134
+ dbType: DB_TYPES.sqlite,
135
+ suffix: 'sqlite',
136
+ label: 'SQLite (builtin)',
137
+ filePaths: files,
138
+ isDirectory: false,
139
+ });
140
+ }
141
+ }
142
+ // QMD — active when memory.backend === "qmd": agents/*/qmd/*.sqlite and *.db.
143
+ if (backend === 'qmd') {
144
+ const agentsDir = path.join(openclawDir, 'agents');
145
+ const files = [];
146
+ if (fs.existsSync(agentsDir)) {
147
+ for (const entry of fs.readdirSync(agentsDir, { withFileTypes: true })) {
148
+ if (!entry.isDirectory())
149
+ continue;
150
+ const qmdDir = path.join(agentsDir, entry.name, 'qmd');
151
+ files.push(...findFilesByExt(qmdDir, '.sqlite'), ...findFilesByExt(qmdDir, '.db'));
152
+ }
153
+ }
154
+ if (files.length > 0) {
155
+ detected.push({
156
+ dbType: DB_TYPES.qmd,
157
+ suffix: 'qmd',
158
+ label: 'QMD (experimental)',
159
+ filePaths: files,
160
+ isDirectory: false,
161
+ });
162
+ }
163
+ }
164
+ // LanceDB — active when plugins.slots.memory === "memory-lancedb" and not disabled.
165
+ if (ocConfig.plugins?.slots?.memory === 'memory-lancedb') {
166
+ if (ocConfig.plugins?.entries?.['memory-lancedb']?.enabled !== false) {
167
+ const dbPath = lancedbDir(openclawDir, ocConfig);
168
+ if (fs.existsSync(dbPath) && fs.statSync(dbPath).isDirectory()) {
169
+ detected.push({
170
+ dbType: DB_TYPES.lancedb,
171
+ suffix: 'lancedb',
172
+ label: 'LanceDB (plugin)',
173
+ filePaths: [dbPath],
174
+ isDirectory: true,
175
+ });
176
+ }
177
+ }
178
+ }
179
+ return detected;
180
+ }
181
+ // ── The backup format ─────────────────────────────────────────────────────────────────────────
182
+ const SQLITE3_TIMEOUT_MS = 30000;
183
+ const TAR_TIMEOUT_MS = 120000;
184
+ const ENTRY_SUFFIX = '.sqlite';
185
+ /** A consistent copy of a SQLite file through the sqlite3 CLI (`.backup`), or the file as it is
186
+ * when the CLI is not installed (WAL contents may then be missing, and the logger says so). */
187
+ export function snapshotSqliteFile(dbPath, logger) {
188
+ const tmpPath = path.join(fs.mkdtempSync(path.join(tmpdir(), 'engramx-sqlite-')), `backup-${randomBytes(8).toString('hex')}.sqlite`);
189
+ try {
190
+ execFileSync('sqlite3', [dbPath, `.backup '${tmpPath.replace(/'/g, "''")}'`], {
191
+ timeout: SQLITE3_TIMEOUT_MS,
192
+ stdio: 'pipe',
193
+ });
194
+ return fs.readFileSync(tmpPath);
195
+ }
196
+ catch (err) {
197
+ const msg = err instanceof Error ? err.message : String(err);
198
+ if (msg.includes('ENOENT') || msg.includes('not found')) {
199
+ logger?.warn('memory-engramx: sqlite3 CLI not available, falling back to direct file read. ' +
200
+ 'WAL data may not be included.');
201
+ return fs.readFileSync(dbPath);
202
+ }
203
+ throw err;
204
+ }
205
+ finally {
206
+ fs.rmSync(path.dirname(tmpPath), { recursive: true, force: true });
207
+ }
208
+ }
209
+ function inside(base, p) {
210
+ const rel = path.relative(base, p);
211
+ return rel !== '' && !rel.startsWith('..') && !path.isAbsolute(rel);
212
+ }
213
+ function tarGz(cwd, entries) {
214
+ const tmp = fs.mkdtempSync(path.join(tmpdir(), 'engramx-tar-'));
215
+ const tarPath = path.join(tmp, 'backup.tar.gz');
216
+ try {
217
+ execFileSync('tar', ['-czf', tarPath, '-C', cwd, ...entries], {
218
+ timeout: TAR_TIMEOUT_MS,
219
+ stdio: 'pipe',
220
+ });
221
+ return fs.readFileSync(tarPath);
222
+ }
223
+ finally {
224
+ fs.rmSync(tmp, { recursive: true, force: true });
225
+ }
226
+ }
227
+ function untarGz(data) {
228
+ const tmp = fs.mkdtempSync(path.join(tmpdir(), 'engramx-restore-'));
229
+ const tarPath = path.join(tmp, 'backup.tar.gz');
230
+ const out = path.join(tmp, 'out');
231
+ fs.mkdirSync(out);
232
+ fs.writeFileSync(tarPath, data);
233
+ try {
234
+ execFileSync('tar', ['--no-same-owner', '-xzf', tarPath, '-C', out], {
235
+ timeout: TAR_TIMEOUT_MS,
236
+ stdio: 'pipe',
237
+ });
238
+ }
239
+ catch (err) {
240
+ fs.rmSync(tmp, { recursive: true, force: true });
241
+ throw new Error(`the backup is not a gzipped tar archive (${err instanceof Error ? err.message.split('\n')[0] : String(err)})`, { cause: err });
242
+ }
243
+ return out;
244
+ }
245
+ /**
246
+ * The bytes the plugin uploads for one detected database (see THE BACKUP FORMAT above).
247
+ * `snapshot` reads one SQLite file; it is a parameter so a test can pack files that are not
248
+ * SQLite databases.
249
+ */
250
+ export function encodeDatabaseBackup(openclawDir, db, opts = {}) {
251
+ const snapshot = opts.snapshot ?? snapshotSqliteFile;
252
+ if (db.suffix === 'lancedb') {
253
+ const dir = db.filePaths[0];
254
+ return tarGz(path.dirname(dir), [path.basename(dir)]);
255
+ }
256
+ const staging = fs.mkdtempSync(path.join(tmpdir(), 'engramx-dbpack-'));
257
+ try {
258
+ const names = [];
259
+ for (const fp of db.filePaths) {
260
+ // Relative to the OpenClaw directory when inside it (a restore on another machine lands in
261
+ // that machine's directory); absolute for a store configured elsewhere.
262
+ const named = inside(openclawDir, fp) ? path.relative(openclawDir, fp) : path.resolve(fp);
263
+ const name = Buffer.from(named).toString('base64url') + ENTRY_SUFFIX;
264
+ fs.writeFileSync(path.join(staging, name), snapshot(fp, opts.logger));
265
+ names.push(name);
266
+ }
267
+ return tarGz(staging, names);
268
+ }
269
+ finally {
270
+ fs.rmSync(staging, { recursive: true, force: true });
271
+ }
272
+ }
273
+ /** SQLite's file header — the start of a lone database uploaded raw before 2026-10-13. */
274
+ const SQLITE_HEADER = Buffer.from('SQLite format 3\0', 'latin1');
275
+ /**
276
+ * Write a downloaded backup back where it came from. Returns the paths written.
277
+ * Throws, writing nothing, for a type it does not know, a backup in the pre-2026-10-13 raw form, an
278
+ * archive that is not one, or an entry that would land outside the OpenClaw directory.
279
+ */
280
+ export function restoreDatabaseBackup(openclawDir, ocConfig, dbType, data) {
281
+ const known = Object.values(DB_TYPES);
282
+ if (!known.includes(dbType)) {
283
+ throw new Error(`unknown backup type "${dbType}" — this version restores ${known.join(', ')}; nothing was written.`);
284
+ }
285
+ if (Buffer.from(data.subarray(0, SQLITE_HEADER.length)).equals(SQLITE_HEADER)) {
286
+ throw new Error('this backup is a lone SQLite file in the form used before 2026-10-13, which records no path, ' +
287
+ 'so this version cannot tell where it belongs. Nothing was written. Download it with the ' +
288
+ "client's pullBackupChunk and copy it into the builtin store directory by hand.");
289
+ }
290
+ const out = untarGz(data);
291
+ const tmpRoot = path.dirname(out);
292
+ try {
293
+ if (dbType === DB_TYPES.lancedb) {
294
+ const tops = fs.readdirSync(out);
295
+ if (tops.length !== 1 || !fs.statSync(path.join(out, tops[0])).isDirectory()) {
296
+ throw new Error('a LanceDB backup holds one directory; this one does not. Nothing was written.');
297
+ }
298
+ const dest = lancedbDir(openclawDir, ocConfig);
299
+ fs.rmSync(dest, { recursive: true, force: true });
300
+ fs.mkdirSync(path.dirname(dest), { recursive: true });
301
+ fs.cpSync(path.join(out, tops[0]), dest, { recursive: true });
302
+ return [dest];
303
+ }
304
+ // SQLite and QMD: every entry first, so a bad one writes nothing.
305
+ const plan = [];
306
+ for (const name of fs.readdirSync(out)) {
307
+ if (!name.endsWith(ENTRY_SUFFIX)) {
308
+ throw new Error(`unexpected entry "${name}" in a ${dbType} backup. Nothing was written.`);
309
+ }
310
+ const rel = Buffer.from(name.slice(0, -ENTRY_SUFFIX.length), 'base64url').toString('utf-8');
311
+ // A relative name lands in this OpenClaw directory. An absolute one (a store configured
312
+ // outside it, or a QMD backup written before 2026-10-13) is kept only when it lies inside
313
+ // this directory or, for SQLite, inside the store directory this machine's config names.
314
+ const to = path.resolve(openclawDir, rel);
315
+ const allowed = inside(openclawDir, to) ||
316
+ (dbType === DB_TYPES.sqlite && inside(sqliteStoreDir(openclawDir, ocConfig), to));
317
+ if (!allowed) {
318
+ throw new Error(`the backup names ${rel}, which is outside the OpenClaw directory ${openclawDir}. Nothing was written.`);
319
+ }
320
+ plan.push({ from: path.join(out, name), to });
321
+ }
322
+ for (const { from, to } of plan) {
323
+ fs.mkdirSync(path.dirname(to), { recursive: true });
324
+ fs.copyFileSync(from, to);
325
+ }
326
+ return plan.map((p) => p.to);
327
+ }
328
+ finally {
329
+ fs.rmSync(tmpRoot, { recursive: true, force: true });
330
+ }
331
+ }
332
+ //# sourceMappingURL=openclaw-local.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openclaw-local.js","sourceRoot":"","sources":["../src/openclaw-local.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,+EAA+E;AAC/E,EAAE;AACF,mGAAmG;AACnG,2FAA2F;AAC3F,qGAAqG;AACrG,uFAAuF;AACvF,gGAAgG;AAChG,mGAAmG;AACnG,0FAA0F;AAC1F,iGAAiG;AACjG,iGAAiG;AACjG,+FAA+F;AAC/F,kGAAkG;AAClG,kFAAkF;AAClF,EAAE;AACF,gGAAgG;AAChG,mGAAmG;AACnG,4FAA4F;AAC5F,0DAA0D;AAC1D,qGAAqG;AACrG,iGAAiG;AACjG,+DAA+D;AAC/D,yFAAyF;AACzF,8FAA8F;AAC9F,sDAAsD;AAEtD,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,WAAW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AC,EAAE,CAAC,CAAC;IAC/B,CAAC;YAAS,CAAC;QACT,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACvD,CAAC;AACH,CAAC"}
@@ -1,3 +1,5 @@
1
+ import { getOpenClawDir } from './openclaw-local.js';
2
+ export { getOpenClawDir };
1
3
  export interface OpenClawSetupOptions {
2
4
  canisterId: string;
3
5
  sessionKeyPath: string;
@@ -5,11 +7,89 @@ export interface OpenClawSetupOptions {
5
7
  }
6
8
  export interface OpenClawSetupResult {
7
9
  configPath: string;
10
+ /** True only when this run installed the plugin. */
8
11
  pluginInstalled: boolean;
9
- pluginMethod: 'cli' | 'manual-npm' | 'skipped';
12
+ /**
13
+ * What happened to the plugin: installed through OpenClaw's installer (`cli`) or with npm
14
+ * (`manual-npm`), already at this kit's version so nothing ran (`current`), or not installed
15
+ * (`skipped`). ⟨2026-10-13, the second review⟩ `current` is new; before it, a plugin already in
16
+ * pair's npm folder — at any version — was `skipped`, and pair printed "Installed" over it.
17
+ */
18
+ pluginMethod: 'cli' | 'manual-npm' | 'current' | 'skipped';
19
+ /** Where the plugin is (`manual-npm`, `current`), or why nothing was installed (`skipped`). */
20
+ pluginNote?: string;
10
21
  }
11
- export declare function getOpenClawDir(): string;
12
22
  export declare function setupOpenClaw(options: OpenClawSetupOptions): Promise<OpenClawSetupResult>;
23
+ /**
24
+ * The plugin `pair --target openclaw` installs: `@engramx/openclaw@<this kit's version>`.
25
+ *
26
+ * ⟨ADDED 2026-10-13, on the review of the owner's "fix … the MCP version in rc.12"⟩ WHY. Both installs
27
+ * below named the bare `@engramx/openclaw`, which installs npm's `latest` — the last FINAL release,
28
+ * 0.15.0 while 0.16.0's candidates soak under `next` (npm dist-tags, read 2026-10-13) — a plugin that
29
+ * cannot talk to this release's engram. The packages are released in lockstep (version.ts), so this
30
+ * kit's version is the plugin's. OpenClaw's installer takes the versioned name: its registry-spec
31
+ * parser (openclaw 2026.10.3, the npm `latest` read that day, `parseRegistryNpmSpecResult`) accepts
32
+ * `<name>@<exact version>`, and for a pre-release such as `0.16.0-rc.12` only when it is named
33
+ * exactly — a bare name that resolved to one is refused — while `@engramx/openclaw@<version>` (this
34
+ * kit's unread-version blank) is refused — neither an exact version nor a tag — as npm refuses it.
35
+ * Measured by running that parser on these four spellings (the fix notes keep the log).
36
+ * WHAT WOULD MAKE THIS WRONG: the packages no longer sharing one version number, or an OpenClaw
37
+ * release whose installer refuses an exact version. Held by test/openclaw-plugin-pinned.test.ts.
38
+ */
39
+ export declare const OPENCLAW_PLUGIN: string;
40
+ /** A copy of @engramx/openclaw found on this machine. */
41
+ export interface InstalledOpenClawPlugin {
42
+ /** The package's folder, `…/node_modules/@engramx/openclaw`. */
43
+ dir: string;
44
+ /** The npm project holding it: the folder `npm install` ran in. */
45
+ project: string;
46
+ /** The version its package.json names, or null when that cannot be read. */
47
+ version: string | null;
48
+ /** Who put it there, which decides the command that upgrades it. */
49
+ installer: 'npm' | 'openclaw';
50
+ }
51
+ /**
52
+ * Every copy of @engramx/openclaw in the places a plugin install puts it, under `openclawDir`:
53
+ * pair's own npm fallback (`extensions/memory-engramx`), and OpenClaw's installer — one npm project
54
+ * per package under `npm/projects/` (a package keeps more than one after an upgrade: OpenClaw's
55
+ * docs say upgrades "retain generation paths that running plugins may still need"), and the single
56
+ * `npm/` project it used before 2026.5.28. Read from openclaw 2026.10.3's own code
57
+ * (`resolvePluginNpmProjectDir`, `resolvePluginInstallRoots`) and docs
58
+ * (plugins/dependency-resolution.md, "Install roots"); no real OpenClaw was run.
59
+ * WHAT WOULD MAKE THIS WRONG: an OpenClaw that keeps its plugins elsewhere — `OPENCLAW_STATE_DIR`
60
+ * set apart from the folder pair reads (OPENCLAW_CONFIG_DIR or ~/.openclaw), a plugin loaded from a
61
+ * `plugins.load.paths` entry or a workspace's `.openclaw/extensions` — is not seen here.
62
+ */
63
+ export declare function findInstalledOpenClawPlugins(openclawDir?: string): InstalledOpenClawPlugin[];
64
+ /**
65
+ * The copies `pair` will not point at an engram: any in its own npm folder that is not this kit's
66
+ * version, and OpenClaw's copies when none of them is (an older folder beside a current one is what
67
+ * an upgrade leaves, so it is not counted against a current copy).
68
+ *
69
+ * ⟨ADDED 2026-10-13, the second review of the owner's "fix the pairing migration"⟩ WHY. pair skipped
70
+ * the install whenever any @engramx/openclaw sat in its npm folder, whatever its version, then wrote
71
+ * openclaw.json and printed "Installed EngramX plugin for OpenClaw" — and on a gateway that was not
72
+ * running, the same line over no install at all. The plugin that ran at OpenClaw's next start was
73
+ * the one already there, and one from 0.16.0-rc.11 or earlier deletes every local memory file the
74
+ * engram does not list before it pushes (unless more than five and more than half would go) — the
75
+ * files `pair` now leaves where they are without --migrate. So a different version is never
76
+ * configured: `pair` stops before pairing and prints the command that upgrades it
77
+ * (cli.ts · Step 1's check), and setupOpenClaw refuses the same before writing openclaw.json.
78
+ * Refusing, not upgrading in place: the refusal comes before the invite is used, so running the
79
+ * same pair command again afterwards works, and pair runs nothing on someone's OpenClaw that it
80
+ * cannot check (how OpenClaw's `plugins update` behaves without a terminal was not run). Held by
81
+ * test/openclaw-plugin-pinned.test.ts and test/pair-migrate.test.ts.
82
+ * WHAT WOULD MAKE THIS WRONG: a copy outside the places findInstalledOpenClawPlugins reads (it
83
+ * says which), or OpenClaw loading an older retained folder over a current one.
84
+ */
85
+ export declare function outdatedOpenClawPlugins(copies?: InstalledOpenClawPlugin[]): InstalledOpenClawPlugin[];
86
+ /** The command that puts `copy` at this kit's version, exact, to run as printed. */
87
+ export declare function pluginUpgradeCommand(copy: InstalledOpenClawPlugin): string;
88
+ /** pair's refusal: each copy and its version, and the commands that upgrade them. */
89
+ export declare class OpenClawPluginOutdatedError extends Error {
90
+ readonly outdated: InstalledOpenClawPlugin[];
91
+ constructor(outdated: InstalledOpenClawPlugin[]);
92
+ }
13
93
  export declare class OpenClawNotFoundError extends Error {
14
94
  constructor(message: string);
15
95
  }
@@ -20,5 +100,4 @@ export interface GitSetupResult {
20
100
  export declare function isGitRepo(dir: string): boolean;
21
101
  /** Resolve the memory directory from openclaw.json config. */
22
102
  export declare function getMemoryDir(): string;
23
- export declare function resolveMemoryDirFromConfig(openclawDir: string, config: Record<string, unknown>): string;
24
103
  export declare function setupGitVersioning(remoteUrl: string): GitSetupResult;