@remnic/cli 9.64.1 → 9.64.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.
Files changed (2) hide show
  1. package/dist/index.js +367 -292
  2. package/package.json +31 -31
package/dist/index.js CHANGED
@@ -18,7 +18,7 @@ async function persistEnrichmentCandidate(storage, entityName, candidate) {
18
18
  }
19
19
 
20
20
  // src/index.ts
21
- import fs16 from "fs";
21
+ import fs17 from "fs";
22
22
  import os3 from "os";
23
23
  import path18 from "path";
24
24
  import { createHash as createHash4 } from "crypto";
@@ -27,11 +27,11 @@ import * as childProcess2 from "child_process";
27
27
  import { fileURLToPath as fileURLToPath5 } from "url";
28
28
  import { gzipSync } from "zlib";
29
29
  import {
30
- parseConfig as parseConfig7,
30
+ parseConfig as parseConfig8,
31
31
  isOpenaiApiKeyDisabled,
32
32
  resolveEnvVars,
33
- resolveRemnicConfigRecord as resolveRemnicConfigRecord6,
34
- Orchestrator as Orchestrator4,
33
+ resolveRemnicConfigRecord as resolveRemnicConfigRecord7,
34
+ Orchestrator as Orchestrator5,
35
35
  EngramAccessService as EngramAccessService2,
36
36
  initLogger as initLogger3,
37
37
  onboard,
@@ -110,6 +110,9 @@ import {
110
110
  formatProcedureStatsText,
111
111
  parseXrayCliOptions,
112
112
  renderXray,
113
+ extractWhoKnowsRawArgs,
114
+ parseWhoKnowsCliOptions,
115
+ renderWhoKnows,
113
116
  OFFLINE_SYNC_APPLY_MAX_BODY_BYTES,
114
117
  OFFLINE_SYNC_FILE_CONTENT_MAX_CHUNK_BYTES as OFFLINE_SYNC_FILE_CONTENT_MAX_CHUNK_BYTES2,
115
118
  OFFLINE_SYNC_FILE_CONTENT_TRANSFER_CHUNK_BYTES as OFFLINE_SYNC_FILE_CONTENT_TRANSFER_CHUNK_BYTES4,
@@ -191,15 +194,52 @@ async function runMeetingsBinaryCommand(rest) {
191
194
  }
192
195
  }
193
196
 
194
- // src/commands/external-wiki.ts
197
+ // src/commands/okf.ts
195
198
  import fs2 from "fs";
196
- import { parseConfig as parseConfig2, resolveRemnicConfigRecord as resolveRemnicConfigRecord2, runExternalWikiCliCommand } from "@remnic/core";
199
+ import { Orchestrator as Orchestrator2, parseConfig as parseConfig2, resolveRemnicConfigRecord as resolveRemnicConfigRecord2, runOkfCliCommand } from "@remnic/core";
200
+ async function runOkfBinaryCommand(rest) {
201
+ const argv = rest.length === 0 || rest[0] === "--help" || rest[0] === "-h" ? ["help"] : rest;
202
+ let orchestrator;
203
+ try {
204
+ try {
205
+ const configPath = resolveConfigPath();
206
+ const raw = fs2.existsSync(configPath) ? JSON.parse(fs2.readFileSync(configPath, "utf8")) : {};
207
+ const config2 = parseConfig2(resolveRemnicConfigRecord2(raw));
208
+ orchestrator = new Orchestrator2(config2);
209
+ await orchestrator.initialize();
210
+ await orchestrator.deferredReady;
211
+ } catch {
212
+ console.error(
213
+ "okf: failed to load the Remnic config or start the memory engine \u2014 run `remnic doctor` and check the config file for errors"
214
+ );
215
+ process.exitCode = 1;
216
+ return;
217
+ }
218
+ const config = orchestrator.config;
219
+ const code = await runOkfCliCommand(argv, { stdout: process.stdout, stderr: process.stderr }, {
220
+ memoryDir: config.memoryDir,
221
+ conformanceEnabled: config.okf.conformanceEnabled,
222
+ sweepEnabled: config.okf.sweepEnabled
223
+ });
224
+ if (code !== 0) process.exitCode = code;
225
+ } catch (err) {
226
+ console.error(err instanceof Error ? err.message : String(err));
227
+ process.exitCode = 1;
228
+ } finally {
229
+ orchestrator?.abortDeferredInit();
230
+ await orchestrator?.destroy();
231
+ }
232
+ }
233
+
234
+ // src/commands/external-wiki.ts
235
+ import fs3 from "fs";
236
+ import { parseConfig as parseConfig3, resolveRemnicConfigRecord as resolveRemnicConfigRecord3, runExternalWikiCliCommand } from "@remnic/core";
197
237
  async function runExternalWikiBinaryCommand(rest) {
198
238
  let roots;
199
239
  try {
200
240
  const configPath = resolveConfigPath();
201
- const raw = fs2.existsSync(configPath) ? JSON.parse(fs2.readFileSync(configPath, "utf8")) : {};
202
- roots = parseConfig2(resolveRemnicConfigRecord2(raw)).externalWikis;
241
+ const raw = fs3.existsSync(configPath) ? JSON.parse(fs3.readFileSync(configPath, "utf8")) : {};
242
+ roots = parseConfig3(resolveRemnicConfigRecord3(raw)).externalWikis;
203
243
  } catch {
204
244
  console.error(
205
245
  "external-wiki: failed to load the Remnic config - run `remnic doctor` and check the config file for errors"
@@ -269,13 +309,13 @@ async function loadWecloneExportModule() {
269
309
  }
270
310
 
271
311
  // src/converge.ts
272
- import * as fs4 from "fs";
312
+ import * as fs5 from "fs";
273
313
  import { createHash as createHash3 } from "crypto";
274
314
  import * as path2 from "path";
275
315
  import {
276
316
  CONVERGE_CONFLICT_POLICIES,
277
317
  DEFAULT_CONVERGE_CONFLICT_POLICY,
278
- parseConfig as parseConfig3,
318
+ parseConfig as parseConfig4,
279
319
  buildOfflineSyncSnapshotFromBase,
280
320
  applyOfflineSyncFileContentChunk,
281
321
  isInternalRemnicStatePath as isInternalRemnicStatePath3,
@@ -301,7 +341,7 @@ import {
301
341
 
302
342
  // src/offline-storage-io.ts
303
343
  import { createDecipheriv, createHash } from "crypto";
304
- import fs3 from "fs";
344
+ import fs4 from "fs";
305
345
  import { lstat, mkdtemp, readdir, rm } from "fs/promises";
306
346
  import path from "path";
307
347
  import {
@@ -463,7 +503,7 @@ async function* readOfflineSyncFileChunks(options) {
463
503
  });
464
504
  }
465
505
  async function readFilePrefix(filePath, length) {
466
- const handle = await fs3.promises.open(filePath, "r");
506
+ const handle = await fs4.promises.open(filePath, "r");
467
507
  try {
468
508
  const out = Buffer.alloc(length);
469
509
  const { bytesRead } = await handle.read(out, 0, length, 0);
@@ -473,7 +513,7 @@ async function readFilePrefix(filePath, length) {
473
513
  }
474
514
  }
475
515
  async function* readPlainOfflineFileChunks(filePath, chunkSize) {
476
- const stream = fs3.createReadStream(filePath, { highWaterMark: chunkSize });
516
+ const stream = fs4.createReadStream(filePath, { highWaterMark: chunkSize });
477
517
  for await (const chunk of stream) {
478
518
  yield Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
479
519
  }
@@ -510,9 +550,9 @@ async function* readEncryptedOfflineFileChunks(options) {
510
550
  });
511
551
  decipher.setAuthTag(authTag);
512
552
  decipher.setAAD(Buffer.concat([secureStoreEnvelopeHeaderAad(salt), aad]));
513
- const output = fs3.createWriteStream(tempPath, { mode: 384 });
553
+ const output = fs4.createWriteStream(tempPath, { mode: 384 });
514
554
  try {
515
- const stream = fs3.createReadStream(options.filePath, {
555
+ const stream = fs4.createReadStream(options.filePath, {
516
556
  start: MAGIC_HEADER_SIZE + ENVELOPE_HEADER_SIZE,
517
557
  highWaterMark: options.chunkSize
518
558
  });
@@ -1122,7 +1162,7 @@ async function readLocalTombstoneEvidence(rootDir) {
1122
1162
  for (const relativePath of TOMBSTONE_PATHS) {
1123
1163
  let content;
1124
1164
  try {
1125
- content = await fs4.promises.readFile(path2.join(rootDir, relativePath), "utf-8");
1165
+ content = await fs5.promises.readFile(path2.join(rootDir, relativePath), "utf-8");
1126
1166
  } catch (error) {
1127
1167
  if (error.code === "ENOENT") continue;
1128
1168
  throw error;
@@ -1137,7 +1177,7 @@ async function discoverCursorNamespaces(memoryDir, peerUrl) {
1137
1177
  const cursorDir = path2.join(path2.resolve(memoryDir), ".remnic", "state", "converge-cursors");
1138
1178
  let entries;
1139
1179
  try {
1140
- entries = await fs4.promises.readdir(cursorDir, { withFileTypes: true });
1180
+ entries = await fs5.promises.readdir(cursorDir, { withFileTypes: true });
1141
1181
  } catch (error) {
1142
1182
  if (error.code === "ENOENT") return [];
1143
1183
  throw error;
@@ -1213,7 +1253,7 @@ async function computeConvergePlan(options = {}) {
1213
1253
  let config = options.config;
1214
1254
  if (!config) {
1215
1255
  try {
1216
- config = parseConfig3({});
1256
+ config = parseConfig4({});
1217
1257
  } catch {
1218
1258
  }
1219
1259
  }
@@ -1464,7 +1504,7 @@ async function executeConvergeApply(options = {}) {
1464
1504
  let config = options.config;
1465
1505
  if (!config) {
1466
1506
  try {
1467
- config = parseConfig3({});
1507
+ config = parseConfig4({});
1468
1508
  } catch {
1469
1509
  }
1470
1510
  }
@@ -1627,7 +1667,7 @@ async function executeConvergeApply(options = {}) {
1627
1667
  if (current.sha256 !== entry.localSha256) {
1628
1668
  throw new Error(`local file changed during push: ${localPath}`);
1629
1669
  }
1630
- const stat2 = await fs4.promises.stat(filePath);
1670
+ const stat2 = await fs5.promises.stat(filePath);
1631
1671
  let chunks;
1632
1672
  let chunkOffset = 0;
1633
1673
  const resetChunks = async () => {
@@ -1904,7 +1944,7 @@ function formatConvergeApplyReport(result) {
1904
1944
  lines.push(formatConvergeReport(result.plan));
1905
1945
  return lines.join("\n");
1906
1946
  }
1907
- async function cmdConverge(action, rest, json, config = parseConfig3({})) {
1947
+ async function cmdConverge(action, rest, json, config = parseConfig4({})) {
1908
1948
  if (action === "help" || action === "--help" || action === "-h" || rest.includes("--help") || rest.includes("-h")) {
1909
1949
  console.log(`Usage: remnic converge <plan|apply> [options]
1910
1950
 
@@ -2110,8 +2150,8 @@ function renderReplayResult(result, targetNamespace, format) {
2110
2150
  }
2111
2151
 
2112
2152
  // src/quarantine-replay.ts
2113
- import * as fs5 from "fs";
2114
- import { EngramAccessService, Orchestrator as Orchestrator2, initLogger, parseConfig as parseConfig4, resolveRemnicConfigRecord as resolveRemnicConfigRecord3 } from "@remnic/core";
2153
+ import * as fs6 from "fs";
2154
+ import { EngramAccessService, Orchestrator as Orchestrator3, initLogger, parseConfig as parseConfig5, resolveRemnicConfigRecord as resolveRemnicConfigRecord4 } from "@remnic/core";
2115
2155
  import { WriteQuarantineStore } from "@remnic/core/write-quarantine.js";
2116
2156
  function valueFlag(args, flag) {
2117
2157
  const occurrences = args.filter((a) => a === flag).length;
@@ -2159,9 +2199,9 @@ async function runQuarantineReplay(rest, format, resolveConfigPath2) {
2159
2199
  let orchestrator;
2160
2200
  try {
2161
2201
  const configPath = resolveConfigPath2();
2162
- const raw = fs5.existsSync(configPath) ? JSON.parse(fs5.readFileSync(configPath, "utf8")) : {};
2163
- const config = parseConfig4(resolveRemnicConfigRecord3(raw));
2164
- orchestrator = new Orchestrator2(config);
2202
+ const raw = fs6.existsSync(configPath) ? JSON.parse(fs6.readFileSync(configPath, "utf8")) : {};
2203
+ const config = parseConfig5(resolveRemnicConfigRecord4(raw));
2204
+ orchestrator = new Orchestrator3(config);
2165
2205
  await orchestrator.initialize();
2166
2206
  await orchestrator.deferredReady;
2167
2207
  const service = new EngramAccessService(orchestrator);
@@ -2191,15 +2231,15 @@ async function runQuarantineReplay(rest, format, resolveConfigPath2) {
2191
2231
  }
2192
2232
 
2193
2233
  // src/offline-impression-rotation.ts
2194
- import fs6 from "fs";
2195
- import { parseConfig as parseConfig5, resolveRemnicConfigRecord as resolveRemnicConfigRecord4, drainPendingImpressionsForOfflineSync } from "@remnic/core";
2234
+ import fs7 from "fs";
2235
+ import { parseConfig as parseConfig6, resolveRemnicConfigRecord as resolveRemnicConfigRecord5, drainPendingImpressionsForOfflineSync } from "@remnic/core";
2196
2236
  import { LastRecallStore } from "@remnic/core/recall-state";
2197
2237
  function parseConfigQuietly(raw) {
2198
2238
  const originalWarn = console.warn;
2199
2239
  console.warn = () => {
2200
2240
  };
2201
2241
  try {
2202
- return parseConfig5(resolveRemnicConfigRecord4(raw));
2242
+ return parseConfig6(resolveRemnicConfigRecord5(raw));
2203
2243
  } finally {
2204
2244
  console.warn = originalWarn;
2205
2245
  }
@@ -2213,7 +2253,7 @@ var OFFLINE_CONFIG_KEYS = [
2213
2253
  function pickOfflineConfigRecord(raw) {
2214
2254
  let resolved;
2215
2255
  try {
2216
- resolved = resolveRemnicConfigRecord4(raw);
2256
+ resolved = resolveRemnicConfigRecord5(raw);
2217
2257
  } catch {
2218
2258
  resolved = raw && typeof raw === "object" && !Array.isArray(raw) ? raw : {};
2219
2259
  }
@@ -2226,7 +2266,7 @@ function pickOfflineConfigRecord(raw) {
2226
2266
  function resolveOfflineImpressionRotation(configPath) {
2227
2267
  let raw;
2228
2268
  try {
2229
- raw = fs6.existsSync(configPath) ? JSON.parse(fs6.readFileSync(configPath, "utf8")) : {};
2269
+ raw = fs7.existsSync(configPath) ? JSON.parse(fs7.readFileSync(configPath, "utf8")) : {};
2230
2270
  } catch {
2231
2271
  throw new Error(
2232
2272
  `cannot read recall-impression rotation from ${configPath}: config file could not be read as JSON`
@@ -2484,12 +2524,12 @@ function assertBenchModuleFreshForDevelopment() {
2484
2524
  }
2485
2525
 
2486
2526
  // src/cmd-security.ts
2487
- import fs7 from "fs";
2527
+ import fs8 from "fs";
2488
2528
  import {
2489
- Orchestrator as Orchestrator3,
2490
- parseConfig as parseConfig6,
2529
+ Orchestrator as Orchestrator4,
2530
+ parseConfig as parseConfig7,
2491
2531
  initLogger as initLogger2,
2492
- resolveRemnicConfigRecord as resolveRemnicConfigRecord5,
2532
+ resolveRemnicConfigRecord as resolveRemnicConfigRecord6,
2493
2533
  runAuditMemoryCliCommand,
2494
2534
  formatAuditMemoryReport
2495
2535
  } from "@remnic/core";
@@ -2504,9 +2544,9 @@ async function cmdSecurity(rest) {
2504
2544
  }
2505
2545
  initLogger2();
2506
2546
  const configPath = resolveConfigPath();
2507
- const raw = fs7.existsSync(configPath) ? JSON.parse(fs7.readFileSync(configPath, "utf8")) : {};
2508
- const config = parseConfig6(resolveRemnicConfigRecord5(raw));
2509
- const orchestrator = new Orchestrator3(config);
2547
+ const raw = fs8.existsSync(configPath) ? JSON.parse(fs8.readFileSync(configPath, "utf8")) : {};
2548
+ const config = parseConfig7(resolveRemnicConfigRecord6(raw));
2549
+ const orchestrator = new Orchestrator4(config);
2510
2550
  await orchestrator.initialize();
2511
2551
  try {
2512
2552
  const sinceFlag = rest.indexOf("--since");
@@ -2529,7 +2569,7 @@ async function cmdSecurity(rest) {
2529
2569
  }
2530
2570
 
2531
2571
  // src/daemon-service-candidates.ts
2532
- import fs8 from "fs";
2572
+ import fs9 from "fs";
2533
2573
  import path5 from "path";
2534
2574
  var LAUNCHD_LABEL = "ai.remnic.daemon";
2535
2575
  var LEGACY_REMNIC_SERVER_LAUNCHD_LABEL = "ai.remnic.server";
@@ -2551,7 +2591,7 @@ function systemdUnitPaths(homeDir) {
2551
2591
  function anyFileExists(paths) {
2552
2592
  return paths.some((candidate) => {
2553
2593
  try {
2554
- return fs8.statSync(candidate).isFile();
2594
+ return fs9.statSync(candidate).isFile();
2555
2595
  } catch {
2556
2596
  return false;
2557
2597
  }
@@ -2563,7 +2603,7 @@ function commandNames(command) {
2563
2603
  }
2564
2604
  function isRunnableNodeScript(filePath) {
2565
2605
  try {
2566
- const text = fs8.readFileSync(filePath, "utf8").slice(0, 4096);
2606
+ const text = fs9.readFileSync(filePath, "utf8").slice(0, 4096);
2567
2607
  const firstLine = text.split(/\r?\n/, 1)[0] ?? "";
2568
2608
  if (/^#!.*\bnode\b/.test(firstLine)) return true;
2569
2609
  if (firstLine.startsWith("#!")) return false;
@@ -2576,7 +2616,7 @@ function isRunnableNodeScript(filePath) {
2576
2616
  function resolveShimNodeScript(filePath) {
2577
2617
  let text;
2578
2618
  try {
2579
- text = fs8.readFileSync(filePath, "utf8").slice(0, 16384);
2619
+ text = fs9.readFileSync(filePath, "utf8").slice(0, 16384);
2580
2620
  } catch {
2581
2621
  return void 0;
2582
2622
  }
@@ -2588,8 +2628,8 @@ function resolveShimNodeScript(filePath) {
2588
2628
  const candidate = raw.replaceAll("${basedir}", basedir).replaceAll("$basedir", basedir).replaceAll("\\ ", " ");
2589
2629
  const resolved = path5.isAbsolute(candidate) ? candidate : path5.resolve(basedir, candidate);
2590
2630
  try {
2591
- if (fs8.statSync(resolved).isFile() && isRunnableNodeScript(resolved)) {
2592
- return fs8.realpathSync(resolved);
2631
+ if (fs9.statSync(resolved).isFile() && isRunnableNodeScript(resolved)) {
2632
+ return fs9.realpathSync(resolved);
2593
2633
  }
2594
2634
  } catch {
2595
2635
  }
@@ -2597,7 +2637,7 @@ function resolveShimNodeScript(filePath) {
2597
2637
  return void 0;
2598
2638
  }
2599
2639
  function resolveRunnableNodeScript(filePath) {
2600
- const realPath = fs8.realpathSync(filePath);
2640
+ const realPath = fs9.realpathSync(filePath);
2601
2641
  if (isRunnableNodeScript(realPath)) return realPath;
2602
2642
  return resolveShimNodeScript(realPath);
2603
2643
  }
@@ -2607,9 +2647,9 @@ function findCommandOnPath(command, pathEnv = process.env.PATH ?? "") {
2607
2647
  for (const name of commandNames(command)) {
2608
2648
  const candidate = path5.join(dir, name);
2609
2649
  try {
2610
- const stat2 = fs8.statSync(candidate);
2650
+ const stat2 = fs9.statSync(candidate);
2611
2651
  if (!stat2.isFile()) continue;
2612
- if (process.platform !== "win32") fs8.accessSync(candidate, fs8.constants.X_OK);
2652
+ if (process.platform !== "win32") fs9.accessSync(candidate, fs9.constants.X_OK);
2613
2653
  const runnable = resolveRunnableNodeScript(candidate);
2614
2654
  if (runnable) return runnable;
2615
2655
  } catch {
@@ -4100,7 +4140,7 @@ function finalizeBenchStatus(filePath) {
4100
4140
  }
4101
4141
 
4102
4142
  // src/bench-fallback.ts
4103
- import fs9 from "fs";
4143
+ import fs10 from "fs";
4104
4144
  import path9 from "path";
4105
4145
  var FALLBACK_RESULTS_DIRNAME = "fallback-runs";
4106
4146
  function buildBenchRunnerArgs(parsed, benchmarkId, outputDir) {
@@ -4172,7 +4212,7 @@ function createFallbackBenchOutputDir(resultsDir, benchmarkId, pid, startedAtMs
4172
4212
  );
4173
4213
  }
4174
4214
  function resolveFallbackBenchResultPath(outputDir) {
4175
- const entries = fs9.readdirSync(outputDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name).sort();
4215
+ const entries = fs10.readdirSync(outputDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name).sort();
4176
4216
  if (entries.length === 0) {
4177
4217
  throw new Error(`Fallback benchmark runner did not write a JSON result artifact in ${outputDir}`);
4178
4218
  }
@@ -4180,7 +4220,7 @@ function resolveFallbackBenchResultPath(outputDir) {
4180
4220
  }
4181
4221
 
4182
4222
  // src/openclaw-upgrade-swap.ts
4183
- import fs10 from "fs";
4223
+ import fs11 from "fs";
4184
4224
  import path10 from "path";
4185
4225
  function describeError(error) {
4186
4226
  return error instanceof Error ? error.message : String(error);
@@ -4192,7 +4232,7 @@ function createSiblingTempFilePath(targetPath, label) {
4192
4232
  function resolveAtomicWriteMode(targetPath, explicitMode) {
4193
4233
  if (explicitMode !== void 0) return explicitMode;
4194
4234
  try {
4195
- return fs10.statSync(targetPath).mode & 4095;
4235
+ return fs11.statSync(targetPath).mode & 4095;
4196
4236
  } catch (error) {
4197
4237
  if (error instanceof Error && "code" in error && error.code === "ENOENT") {
4198
4238
  return 384;
@@ -4202,8 +4242,8 @@ function resolveAtomicWriteMode(targetPath, explicitMode) {
4202
4242
  }
4203
4243
  function resolveAtomicReplacementPath(targetPath) {
4204
4244
  try {
4205
- if (fs10.lstatSync(targetPath).isSymbolicLink()) {
4206
- return fs10.realpathSync(targetPath);
4245
+ if (fs11.lstatSync(targetPath).isSymbolicLink()) {
4246
+ return fs11.realpathSync(targetPath);
4207
4247
  }
4208
4248
  } catch (error) {
4209
4249
  if (error instanceof Error && "code" in error && error.code === "ENOENT") {
@@ -4220,7 +4260,7 @@ function createSiblingSwapPath(targetDir, label) {
4220
4260
  function cleanupDisplacedDirectoryBestEffort(displacedDir, context) {
4221
4261
  if (!displacedDir) return void 0;
4222
4262
  try {
4223
- fs10.rmSync(displacedDir, { recursive: true, force: true });
4263
+ fs11.rmSync(displacedDir, { recursive: true, force: true });
4224
4264
  return void 0;
4225
4265
  } catch (error) {
4226
4266
  return `Warning: ${context}, but failed to remove the displaced plugin copy at ${displacedDir}: ${describeError(error)}`;
@@ -4228,43 +4268,43 @@ function cleanupDisplacedDirectoryBestEffort(displacedDir, context) {
4228
4268
  }
4229
4269
  function atomicWriteFileSync(targetPath, data, options = {}) {
4230
4270
  const resolvedTargetPath = resolveAtomicReplacementPath(targetPath);
4231
- fs10.mkdirSync(path10.dirname(resolvedTargetPath), { recursive: true });
4271
+ fs11.mkdirSync(path10.dirname(resolvedTargetPath), { recursive: true });
4232
4272
  const tempPath = createSiblingTempFilePath(resolvedTargetPath, "write");
4233
4273
  const mode = resolveAtomicWriteMode(resolvedTargetPath, options.mode);
4234
4274
  try {
4235
4275
  if (options.hooks?.writeTempFileSync) {
4236
4276
  options.hooks.writeTempFileSync(tempPath);
4237
4277
  } else {
4238
- fs10.writeFileSync(tempPath, data, { mode });
4278
+ fs11.writeFileSync(tempPath, data, { mode });
4239
4279
  }
4240
- fs10.chmodSync(tempPath, mode);
4241
- const renameTempFileSync = options.hooks?.renameTempFileSync ?? fs10.renameSync;
4280
+ fs11.chmodSync(tempPath, mode);
4281
+ const renameTempFileSync = options.hooks?.renameTempFileSync ?? fs11.renameSync;
4242
4282
  renameTempFileSync(tempPath, resolvedTargetPath);
4243
4283
  } catch (error) {
4244
- fs10.rmSync(tempPath, { force: true });
4284
+ fs11.rmSync(tempPath, { force: true });
4245
4285
  throw error;
4246
4286
  }
4247
4287
  }
4248
4288
  function atomicCopyFileSync(sourcePath, targetPath, options = {}) {
4249
- if (!fs10.existsSync(sourcePath)) return;
4289
+ if (!fs11.existsSync(sourcePath)) return;
4250
4290
  const resolvedTargetPath = resolveAtomicReplacementPath(targetPath);
4251
- fs10.mkdirSync(path10.dirname(resolvedTargetPath), { recursive: true });
4291
+ fs11.mkdirSync(path10.dirname(resolvedTargetPath), { recursive: true });
4252
4292
  const tempPath = createSiblingTempFilePath(resolvedTargetPath, "copy");
4253
- const mode = fs10.statSync(sourcePath).mode & 4095;
4293
+ const mode = fs11.statSync(sourcePath).mode & 4095;
4254
4294
  try {
4255
- const copyTempFileSync = options.hooks?.copyTempFileSync ?? fs10.copyFileSync;
4295
+ const copyTempFileSync = options.hooks?.copyTempFileSync ?? fs11.copyFileSync;
4256
4296
  copyTempFileSync(sourcePath, tempPath);
4257
- fs10.chmodSync(tempPath, mode);
4258
- const renameTempFileSync = options.hooks?.renameTempFileSync ?? fs10.renameSync;
4297
+ fs11.chmodSync(tempPath, mode);
4298
+ const renameTempFileSync = options.hooks?.renameTempFileSync ?? fs11.renameSync;
4259
4299
  renameTempFileSync(tempPath, resolvedTargetPath);
4260
4300
  } catch (error) {
4261
- fs10.rmSync(tempPath, { force: true });
4301
+ fs11.rmSync(tempPath, { force: true });
4262
4302
  throw error;
4263
4303
  }
4264
4304
  }
4265
4305
  function cleanupRollbackDirectory(rollbackDir) {
4266
4306
  if (!rollbackDir) return;
4267
- fs10.rmSync(rollbackDir, { recursive: true, force: true });
4307
+ fs11.rmSync(rollbackDir, { recursive: true, force: true });
4268
4308
  }
4269
4309
  function cleanupRollbackDirectoryBestEffort(rollbackDir) {
4270
4310
  if (!rollbackDir) return void 0;
@@ -4276,20 +4316,20 @@ function cleanupRollbackDirectoryBestEffort(rollbackDir) {
4276
4316
  }
4277
4317
  }
4278
4318
  function restoreDirectoryFromRollback(targetDir, rollbackDir) {
4279
- if (!fs10.existsSync(rollbackDir)) {
4319
+ if (!fs11.existsSync(rollbackDir)) {
4280
4320
  throw new Error(`Rollback directory is missing: ${rollbackDir}`);
4281
4321
  }
4282
- fs10.mkdirSync(path10.dirname(targetDir), { recursive: true });
4283
- const displacedDir = fs10.existsSync(targetDir) ? createSiblingSwapPath(targetDir, "rollback-restore") : void 0;
4322
+ fs11.mkdirSync(path10.dirname(targetDir), { recursive: true });
4323
+ const displacedDir = fs11.existsSync(targetDir) ? createSiblingSwapPath(targetDir, "rollback-restore") : void 0;
4284
4324
  if (displacedDir) {
4285
- fs10.renameSync(targetDir, displacedDir);
4325
+ fs11.renameSync(targetDir, displacedDir);
4286
4326
  }
4287
4327
  try {
4288
- fs10.renameSync(rollbackDir, targetDir);
4328
+ fs11.renameSync(rollbackDir, targetDir);
4289
4329
  } catch (restoreError) {
4290
- if (displacedDir && fs10.existsSync(displacedDir)) {
4330
+ if (displacedDir && fs11.existsSync(displacedDir)) {
4291
4331
  try {
4292
- fs10.renameSync(displacedDir, targetDir);
4332
+ fs11.renameSync(displacedDir, targetDir);
4293
4333
  } catch (revertError) {
4294
4334
  throw new AggregateError(
4295
4335
  [restoreError, revertError],
@@ -4305,23 +4345,23 @@ function restoreDirectoryFromRollback(targetDir, rollbackDir) {
4305
4345
  return cleanupDisplacedDirectoryBestEffort(displacedDir, `restored the previous plugin copy into ${targetDir}`);
4306
4346
  }
4307
4347
  function restoreDirectoryFromBackup(targetDir, backupDir) {
4308
- if (!fs10.existsSync(backupDir)) {
4348
+ if (!fs11.existsSync(backupDir)) {
4309
4349
  throw new Error(`Plugin backup directory is missing: ${backupDir}`);
4310
4350
  }
4311
- fs10.mkdirSync(path10.dirname(targetDir), { recursive: true });
4351
+ fs11.mkdirSync(path10.dirname(targetDir), { recursive: true });
4312
4352
  const stagedDir = createSiblingSwapPath(targetDir, "backup-restore");
4313
- const displacedDir = fs10.existsSync(targetDir) ? createSiblingSwapPath(targetDir, "pre-backup-restore") : void 0;
4314
- fs10.cpSync(backupDir, stagedDir, { recursive: true });
4353
+ const displacedDir = fs11.existsSync(targetDir) ? createSiblingSwapPath(targetDir, "pre-backup-restore") : void 0;
4354
+ fs11.cpSync(backupDir, stagedDir, { recursive: true });
4315
4355
  if (displacedDir) {
4316
- fs10.renameSync(targetDir, displacedDir);
4356
+ fs11.renameSync(targetDir, displacedDir);
4317
4357
  }
4318
4358
  try {
4319
- fs10.renameSync(stagedDir, targetDir);
4359
+ fs11.renameSync(stagedDir, targetDir);
4320
4360
  } catch (restoreError) {
4321
- fs10.rmSync(targetDir, { recursive: true, force: true });
4322
- if (displacedDir && fs10.existsSync(displacedDir)) {
4361
+ fs11.rmSync(targetDir, { recursive: true, force: true });
4362
+ if (displacedDir && fs11.existsSync(displacedDir)) {
4323
4363
  try {
4324
- fs10.renameSync(displacedDir, targetDir);
4364
+ fs11.renameSync(displacedDir, targetDir);
4325
4365
  } catch (revertError) {
4326
4366
  throw new AggregateError(
4327
4367
  [restoreError, revertError],
@@ -4329,7 +4369,7 @@ function restoreDirectoryFromBackup(targetDir, backupDir) {
4329
4369
  );
4330
4370
  }
4331
4371
  }
4332
- fs10.rmSync(stagedDir, { recursive: true, force: true });
4372
+ fs11.rmSync(stagedDir, { recursive: true, force: true });
4333
4373
  throw new Error(
4334
4374
  `Failed to restore the plugin backup into ${targetDir}. The durable backup remains preserved at ${backupDir}.`,
4335
4375
  { cause: restoreError }
@@ -4354,7 +4394,7 @@ function rollbackOpenclawUpgrade({
4354
4394
  let configRemovalAttempted = false;
4355
4395
  let pluginRestored = false;
4356
4396
  try {
4357
- if (rollbackDir && fs10.existsSync(rollbackDir)) {
4397
+ if (rollbackDir && fs11.existsSync(rollbackDir)) {
4358
4398
  const cleanupWarning = restoreDirectoryFromRollback(pluginDir, rollbackDir);
4359
4399
  notes.push(`Restored previous plugin from rollback copy at ${rollbackDir}`);
4360
4400
  if (cleanupWarning) notes.push(cleanupWarning);
@@ -4364,7 +4404,7 @@ function rollbackOpenclawUpgrade({
4364
4404
  rollbackRestoreError = error instanceof Error ? error.message : String(error);
4365
4405
  }
4366
4406
  try {
4367
- if (!pluginRestored && pluginBackupDir && fs10.existsSync(pluginBackupDir)) {
4407
+ if (!pluginRestored && pluginBackupDir && fs11.existsSync(pluginBackupDir)) {
4368
4408
  const cleanupWarning = restoreDirectoryFromBackup(pluginDir, pluginBackupDir);
4369
4409
  if (rollbackRestoreError) {
4370
4410
  notes.push(`Rollback copy restore failed; restored previous plugin from durable backup at ${pluginBackupDir}`);
@@ -4389,12 +4429,12 @@ function rollbackOpenclawUpgrade({
4389
4429
  notes.push("No previous plugin copy was available for automatic restore");
4390
4430
  }
4391
4431
  try {
4392
- if (configBackupPath && fs10.existsSync(configBackupPath)) {
4432
+ if (configBackupPath && fs11.existsSync(configBackupPath)) {
4393
4433
  restoreFileFromBackup(configPath, configBackupPath);
4394
4434
  notes.push(`Restored OpenClaw config from backup at ${configBackupPath}`);
4395
- } else if (removeConfigIfUnbacked && fs10.existsSync(configPath)) {
4435
+ } else if (removeConfigIfUnbacked && fs11.existsSync(configPath)) {
4396
4436
  configRemovalAttempted = true;
4397
- fs10.rmSync(configPath, { force: true });
4437
+ fs11.rmSync(configPath, { force: true });
4398
4438
  notes.push("Removed OpenClaw config created during the failed upgrade");
4399
4439
  }
4400
4440
  } catch (error) {
@@ -4447,7 +4487,7 @@ Run this manually when you're ready:
4447
4487
 
4448
4488
  // src/openclaw-managed-upgrade-loader.ts
4449
4489
  import { execFileSync } from "child_process";
4450
- import fs11 from "fs";
4490
+ import fs12 from "fs";
4451
4491
  import os from "os";
4452
4492
  import path11 from "path";
4453
4493
  import { fileURLToPath as fileURLToPath3, pathToFileURL as pathToFileURL2 } from "url";
@@ -4523,7 +4563,7 @@ function buildOpenclawManagedUpgradePackageSpec(version = "latest") {
4523
4563
  function readCliAdapterRange() {
4524
4564
  const moduleDir = path11.dirname(fileURLToPath3(import.meta.url));
4525
4565
  const manifestPath = path11.resolve(moduleDir, "../package.json");
4526
- const manifest = JSON.parse(fs11.readFileSync(manifestPath, "utf8"));
4566
+ const manifest = JSON.parse(fs12.readFileSync(manifestPath, "utf8"));
4527
4567
  if (manifest.name !== "@remnic/cli") {
4528
4568
  throw new Error(`Invalid @remnic/cli package manifest at ${manifestPath}.`);
4529
4569
  }
@@ -4567,7 +4607,7 @@ async function loadOpenclawManagedUpgradeModule(packageSpec, hooks = {}) {
4567
4607
  const adapterMissing = isSpecifierNotFoundError(error, OPENCLAW_PLUGIN_PACKAGE) || isSpecifierNotFoundError(error, MANAGED_UPGRADE_SPECIFIER) || isManagedUpgradeSubpathMissing(error);
4568
4608
  if (!adapterMissing) throw error;
4569
4609
  }
4570
- const temporaryRoot = fs11.mkdtempSync(path11.join(os.tmpdir(), "remnic-openclaw-upgrade-"));
4610
+ const temporaryRoot = fs12.mkdtempSync(path11.join(os.tmpdir(), "remnic-openclaw-upgrade-"));
4571
4611
  try {
4572
4612
  const toolingPackageSpec = `${OPENCLAW_PLUGIN_PACKAGE}@${readCliAdapterRange()}`;
4573
4613
  const installArgs = [
@@ -4582,12 +4622,12 @@ async function loadOpenclawManagedUpgradeModule(packageSpec, hooks = {}) {
4582
4622
  ];
4583
4623
  (hooks.runNpmInstall ?? runNpmInstall)(installArgs);
4584
4624
  const resolverPath = path11.join(temporaryRoot, "load-managed-upgrade.mjs");
4585
- fs11.writeFileSync(resolverPath, `export * from ${JSON.stringify(MANAGED_UPGRADE_SPECIFIER)};
4625
+ fs12.writeFileSync(resolverPath, `export * from ${JSON.stringify(MANAGED_UPGRADE_SPECIFIER)};
4586
4626
  `, "utf8");
4587
4627
  return await importModule(pathToFileURL2(resolverPath).href);
4588
4628
  } finally {
4589
4629
  try {
4590
- fs11.rmSync(temporaryRoot, { recursive: true, force: true });
4630
+ fs12.rmSync(temporaryRoot, { recursive: true, force: true });
4591
4631
  } catch (error) {
4592
4632
  const detail = error instanceof Error ? error.message : String(error);
4593
4633
  console.warn(`Could not remove temporary managed upgrade project at ${temporaryRoot}: ${detail}`);
@@ -4596,13 +4636,13 @@ async function loadOpenclawManagedUpgradeModule(packageSpec, hooks = {}) {
4596
4636
  }
4597
4637
 
4598
4638
  // src/remote-daemon.ts
4599
- import fs12 from "fs";
4639
+ import fs13 from "fs";
4600
4640
  function readCompatEnv(primary, legacy) {
4601
4641
  return process.env[primary] ?? process.env[legacy];
4602
4642
  }
4603
4643
  function readRemnicConfigRecord(configPath) {
4604
4644
  try {
4605
- const parsed = JSON.parse(fs12.readFileSync(configPath, "utf8"));
4645
+ const parsed = JSON.parse(fs13.readFileSync(configPath, "utf8"));
4606
4646
  if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
4607
4647
  return parsed;
4608
4648
  }
@@ -4831,7 +4871,7 @@ async function remoteRecallXray(daemon, request) {
4831
4871
  }
4832
4872
 
4833
4873
  // src/daemon-service.ts
4834
- import fs13 from "fs";
4874
+ import fs14 from "fs";
4835
4875
  import path12 from "path";
4836
4876
  import * as childProcess from "child_process";
4837
4877
  import { fileURLToPath as fileURLToPath4 } from "url";
@@ -4843,7 +4883,7 @@ function launchdUnloadPlist(plistPath, processApi = childProcess) {
4843
4883
  processApi.execFileSync("launchctl", ["unload", plistPath], { stdio: "pipe" });
4844
4884
  }
4845
4885
  function resolveServerBinDetails(options = {}) {
4846
- const existsSync4 = options.existsSync ?? fs13.existsSync;
4886
+ const existsSync4 = options.existsSync ?? fs14.existsSync;
4847
4887
  const findCommandOnPath2 = options.findCommandOnPath ?? findCommandOnPath;
4848
4888
  const moduleDir = options.moduleDir ?? thisModuleDir;
4849
4889
  const packageResolve = options.packageResolve ?? resolveImportSpecifier;
@@ -4902,8 +4942,8 @@ function resolveServerBin(options = {}) {
4902
4942
  return resolveServerBinDetails(options).path;
4903
4943
  }
4904
4944
  function readVerifiedDaemonPid(options) {
4905
- const readFileSync4 = options.readFileSync ?? fs13.readFileSync;
4906
- const unlinkSync = options.unlinkSync ?? fs13.unlinkSync;
4945
+ const readFileSync4 = options.readFileSync ?? fs14.readFileSync;
4946
+ const unlinkSync = options.unlinkSync ?? fs14.unlinkSync;
4907
4947
  const processKill = options.processKill ?? process.kill;
4908
4948
  const platform = options.platform ?? process.platform;
4909
4949
  const execFileSync4 = options.execFileSync ?? ((command, args, execOptions) => childProcess.execFileSync(command, args, execOptions));
@@ -5003,8 +5043,8 @@ function removePidFileBestEffort(file, unlinkSync) {
5003
5043
  }
5004
5044
  }
5005
5045
  function inspectLaunchdPlist(plistPath, options = {}) {
5006
- const existsSync4 = options.existsSync ?? fs13.existsSync;
5007
- const readFileSync4 = options.readFileSync ?? fs13.readFileSync;
5046
+ const existsSync4 = options.existsSync ?? fs14.existsSync;
5047
+ const readFileSync4 = options.readFileSync ?? fs14.readFileSync;
5008
5048
  if (!existsSync4(plistPath)) {
5009
5049
  return {
5010
5050
  installed: false,
@@ -5238,7 +5278,7 @@ function stripConfigArgv(args) {
5238
5278
  }
5239
5279
 
5240
5280
  // src/import-dispatch.ts
5241
- import fs14 from "fs";
5281
+ import fs15 from "fs";
5242
5282
  import {
5243
5283
  runImporter,
5244
5284
  validateImportBatchSize,
@@ -5752,7 +5792,7 @@ async function cmdImport(rest, targetFactory, disposeTarget, ioOverrides = {}) {
5752
5792
  let materializedTarget;
5753
5793
  let materializePromise;
5754
5794
  const io = {
5755
- readFile: ioOverrides.readFile ?? (async (p) => fs14.promises.readFile(p, "utf-8")),
5795
+ readFile: ioOverrides.readFile ?? (async (p) => fs15.promises.readFile(p, "utf-8")),
5756
5796
  loadAdapter: ioOverrides.loadAdapter ?? (async (name) => (await loadImporterModule(name)).adapter),
5757
5797
  runImporter: ioOverrides.runImporter ?? runImporter,
5758
5798
  getWriteTarget: async () => {
@@ -5865,7 +5905,7 @@ async function cmdCapture(rest, io) {
5865
5905
  }
5866
5906
 
5867
5907
  // src/import-lossless-claw-cmd.ts
5868
- import fs15 from "fs";
5908
+ import fs16 from "fs";
5869
5909
  import path14 from "path";
5870
5910
  import {
5871
5911
  applyLcmSchema,
@@ -5977,15 +6017,15 @@ async function loadImportLosslessClawModule() {
5977
6017
 
5978
6018
  // src/import-lossless-claw-cmd.ts
5979
6019
  function assertDirectoryOrAbsent(p, label) {
5980
- if (fs15.existsSync(p) && !fs15.statSync(p).isDirectory()) {
6020
+ if (fs16.existsSync(p) && !fs16.statSync(p).isDirectory()) {
5981
6021
  throw new Error(`${label} is not a directory: ${p}`);
5982
6022
  }
5983
6023
  }
5984
6024
  function assertFile(p, label) {
5985
- if (!fs15.existsSync(p)) {
6025
+ if (!fs16.existsSync(p)) {
5986
6026
  throw new Error(`${label} does not exist: ${p}`);
5987
6027
  }
5988
- if (!fs15.statSync(p).isFile()) {
6028
+ if (!fs16.statSync(p).isFile()) {
5989
6029
  throw new Error(`${label} is not a file: ${p}`);
5990
6030
  }
5991
6031
  }
@@ -6017,7 +6057,7 @@ async function cmdImportLosslessClaw(argv, io, deps = {}) {
6017
6057
  try {
6018
6058
  if (parsed.dryRun) {
6019
6059
  const lcmPath = path14.join(memoryDir, "state", "lcm.sqlite");
6020
- if (fs15.existsSync(lcmPath)) {
6060
+ if (fs16.existsSync(lcmPath)) {
6021
6061
  destDb = mod.openExistingLcmDatabaseReadOnly(lcmPath);
6022
6062
  } else {
6023
6063
  destDb = mod.openInMemoryDestinationDatabase();
@@ -7369,7 +7409,7 @@ async function resolveAllBenchmarks() {
7369
7409
  if (packageBenchmarks) {
7370
7410
  return packageBenchmarks.filter((entry) => entry.runnerAvailable).map((entry) => entry.id);
7371
7411
  }
7372
- if (!fs16.existsSync(EVAL_RUNNER_PATH)) {
7412
+ if (!fs17.existsSync(EVAL_RUNNER_PATH)) {
7373
7413
  return [];
7374
7414
  }
7375
7415
  return BENCHMARK_CATALOG.filter((entry) => entry.category !== "ingestion").map((entry) => entry.id);
@@ -7417,7 +7457,7 @@ async function runBenchViaFallback(parsed, benchmarkId, runtimeProfile) {
7417
7457
  `Fallback benchmark runner does not support provider-backed, gateway, or thinking/timeout flags (${unsupportedOptions.join(", ")}). Build/install @remnic/bench to use those options.`
7418
7458
  );
7419
7459
  }
7420
- if (!fs16.existsSync(EVAL_RUNNER_PATH)) {
7460
+ if (!fs17.existsSync(EVAL_RUNNER_PATH)) {
7421
7461
  console.error(
7422
7462
  "Benchmark runner not found. Expected eval runner at evals/run.ts or a phase-1 @remnic/bench runtime export."
7423
7463
  );
@@ -7427,7 +7467,7 @@ async function runBenchViaFallback(parsed, benchmarkId, runtimeProfile) {
7427
7467
  path18.join(CLI_REPO_ROOT, "node_modules", ".bin", "tsx"),
7428
7468
  path18.join(CLI_REPO_ROOT, "packages", "remnic-cli", "node_modules", ".bin", "tsx")
7429
7469
  ];
7430
- const tsxCmd = tsxCandidates.find((candidate) => fs16.existsSync(candidate)) ?? "tsx";
7470
+ const tsxCmd = tsxCandidates.find((candidate) => fs17.existsSync(candidate)) ?? "tsx";
7431
7471
  const fallbackOutputDir = createFallbackBenchOutputDir(
7432
7472
  parsed.resultsDir ?? resolveBenchOutputDir(),
7433
7473
  benchmarkId,
@@ -7572,9 +7612,9 @@ var PERSONAMEM_COMPLETION_MARKER = path18.join(
7572
7612
  );
7573
7613
  function resolveRealpathWithinDataset(datasetPath, relativePath) {
7574
7614
  try {
7575
- const datasetRoot = fs16.realpathSync(datasetPath);
7615
+ const datasetRoot = fs17.realpathSync(datasetPath);
7576
7616
  const candidatePath = path18.resolve(datasetRoot, relativePath);
7577
- const candidateRealPath = fs16.realpathSync(candidatePath);
7617
+ const candidateRealPath = fs17.realpathSync(candidatePath);
7578
7618
  const relativeToRoot = path18.relative(datasetRoot, candidateRealPath);
7579
7619
  if (relativeToRoot.startsWith("..") || path18.isAbsolute(relativeToRoot)) {
7580
7620
  return null;
@@ -7633,14 +7673,14 @@ function parseCsvRows(raw) {
7633
7673
  function isPersonaMemDatasetComplete(datasetPath) {
7634
7674
  try {
7635
7675
  const completionMarkerPath = path18.join(datasetPath, PERSONAMEM_COMPLETION_MARKER);
7636
- if (fs16.statSync(completionMarkerPath).isFile()) {
7676
+ if (fs17.statSync(completionMarkerPath).isFile()) {
7637
7677
  return true;
7638
7678
  }
7639
7679
  } catch {
7640
7680
  }
7641
7681
  const datasetFile = PERSONAMEM_DATASET_FILE_CANDIDATES.find((candidate) => {
7642
7682
  try {
7643
- return fs16.statSync(path18.join(datasetPath, candidate)).isFile();
7683
+ return fs17.statSync(path18.join(datasetPath, candidate)).isFile();
7644
7684
  } catch {
7645
7685
  return false;
7646
7686
  }
@@ -7649,7 +7689,7 @@ function isPersonaMemDatasetComplete(datasetPath) {
7649
7689
  return false;
7650
7690
  }
7651
7691
  try {
7652
- const rows = parseCsvRows(fs16.readFileSync(path18.join(datasetPath, datasetFile), "utf8"));
7692
+ const rows = parseCsvRows(fs17.readFileSync(path18.join(datasetPath, datasetFile), "utf8"));
7653
7693
  if (rows.length < 2) {
7654
7694
  return false;
7655
7695
  }
@@ -7664,7 +7704,7 @@ function isPersonaMemDatasetComplete(datasetPath) {
7664
7704
  }
7665
7705
  return historyPaths.every((relativePath) => {
7666
7706
  const resolvedPath = resolveRealpathWithinDataset(datasetPath, relativePath);
7667
- return resolvedPath !== null && fs16.statSync(resolvedPath).isFile();
7707
+ return resolvedPath !== null && fs17.statSync(resolvedPath).isFile();
7668
7708
  });
7669
7709
  } catch {
7670
7710
  return false;
@@ -7672,7 +7712,7 @@ function isPersonaMemDatasetComplete(datasetPath) {
7672
7712
  }
7673
7713
  function hasDatasetFile(datasetPath, relativePath) {
7674
7714
  try {
7675
- return fs16.statSync(path18.join(datasetPath, relativePath)).isFile();
7715
+ return fs17.statSync(path18.join(datasetPath, relativePath)).isFile();
7676
7716
  } catch {
7677
7717
  return false;
7678
7718
  }
@@ -7692,10 +7732,10 @@ function memoryAgentBenchDatasetHasRecSysSamples(datasetPath) {
7692
7732
  return candidateFilenames.some((filename) => {
7693
7733
  const filePath = path18.join(datasetPath, filename);
7694
7734
  try {
7695
- if (!fs16.statSync(filePath).isFile()) {
7735
+ if (!fs17.statSync(filePath).isFile()) {
7696
7736
  return false;
7697
7737
  }
7698
- const raw = fs16.readFileSync(filePath, "utf8");
7738
+ const raw = fs17.readFileSync(filePath, "utf8");
7699
7739
  return /"source"\s*:\s*"recsys[_-]/i.test(raw);
7700
7740
  } catch {
7701
7741
  return false;
@@ -7711,7 +7751,7 @@ function isMemoryAgentBenchDatasetComplete(datasetPath) {
7711
7751
  function isDatasetDownloaded(datasetPath, benchmarkId) {
7712
7752
  let stats;
7713
7753
  try {
7714
- stats = fs16.statSync(datasetPath);
7754
+ stats = fs17.statSync(datasetPath);
7715
7755
  } catch {
7716
7756
  return false;
7717
7757
  }
@@ -7721,7 +7761,7 @@ function isDatasetDownloaded(datasetPath, benchmarkId) {
7721
7761
  const marker = DOWNLOADED_DATASET_MARKERS[benchmarkId];
7722
7762
  if (!marker) {
7723
7763
  try {
7724
- return fs16.readdirSync(datasetPath).length > 0;
7764
+ return fs17.readdirSync(datasetPath).length > 0;
7725
7765
  } catch {
7726
7766
  return false;
7727
7767
  }
@@ -7729,7 +7769,7 @@ function isDatasetDownloaded(datasetPath, benchmarkId) {
7729
7769
  if (marker.allOf) {
7730
7770
  const hasAllRequiredFiles = marker.allOf.every((name) => {
7731
7771
  try {
7732
- return fs16.statSync(path18.join(datasetPath, name)).isFile();
7772
+ return fs17.statSync(path18.join(datasetPath, name)).isFile();
7733
7773
  } catch {
7734
7774
  return false;
7735
7775
  }
@@ -7741,7 +7781,7 @@ function isDatasetDownloaded(datasetPath, benchmarkId) {
7741
7781
  if (marker.anyOf) {
7742
7782
  const hasMarkerFile = marker.anyOf.some((name) => {
7743
7783
  try {
7744
- return fs16.statSync(path18.join(datasetPath, name)).isFile();
7784
+ return fs17.statSync(path18.join(datasetPath, name)).isFile();
7745
7785
  } catch {
7746
7786
  return false;
7747
7787
  }
@@ -7759,7 +7799,7 @@ function isDatasetDownloaded(datasetPath, benchmarkId) {
7759
7799
  }
7760
7800
  if (marker.ext) {
7761
7801
  try {
7762
- return fs16.readdirSync(datasetPath).some(
7802
+ return fs17.readdirSync(datasetPath).some(
7763
7803
  (name) => name.endsWith(marker.ext) && !marker.exclude?.includes(name)
7764
7804
  );
7765
7805
  } catch {
@@ -7771,7 +7811,7 @@ function isDatasetDownloaded(datasetPath, benchmarkId) {
7771
7811
  async function launchBenchUi(resultsDir) {
7772
7812
  const benchUiDir = path18.join(CLI_REPO_ROOT, "packages", "bench-ui");
7773
7813
  const pnpmCmd = process.platform === "win32" ? "pnpm.cmd" : "pnpm";
7774
- if (!fs16.existsSync(path18.join(benchUiDir, "package.json"))) {
7814
+ if (!fs17.existsSync(path18.join(benchUiDir, "package.json"))) {
7775
7815
  console.error("ERROR: @remnic/bench-ui is not available in this checkout.");
7776
7816
  process.exit(1);
7777
7817
  }
@@ -7809,13 +7849,13 @@ function listDownloadableBenchmarks() {
7809
7849
  }
7810
7850
  function resolveDatasetDownloadScriptPath() {
7811
7851
  const bundled = path18.join(CLI_MODULE_DIR, "assets", "download-datasets.sh");
7812
- if (fs16.existsSync(bundled)) {
7852
+ if (fs17.existsSync(bundled)) {
7813
7853
  return bundled;
7814
7854
  }
7815
7855
  return path18.join(CLI_REPO_ROOT, "evals", "scripts", "download-datasets.sh");
7816
7856
  }
7817
7857
  function isRepoCheckout() {
7818
- return fs16.existsSync(path18.join(CLI_REPO_ROOT, "pnpm-workspace.yaml")) && fs16.existsSync(path18.join(CLI_REPO_ROOT, "evals", "scripts", "download-datasets.sh"));
7858
+ return fs17.existsSync(path18.join(CLI_REPO_ROOT, "pnpm-workspace.yaml")) && fs17.existsSync(path18.join(CLI_REPO_ROOT, "evals", "scripts", "download-datasets.sh"));
7819
7859
  }
7820
7860
  function runDatasetDownloadScript(scriptPath, benchmarkId, datasetRoot, jsonMode) {
7821
7861
  const stdio = jsonMode ? ["inherit", process.stderr, "inherit"] : "inherit";
@@ -8128,8 +8168,8 @@ async function exportBenchPackageResult(parsed) {
8128
8168
  ...reportCardProvenance ? { reportCardProvenance } : {}
8129
8169
  });
8130
8170
  if (parsed.output) {
8131
- fs16.mkdirSync(path18.dirname(parsed.output), { recursive: true });
8132
- fs16.writeFileSync(parsed.output, rendered);
8171
+ fs17.mkdirSync(path18.dirname(parsed.output), { recursive: true });
8172
+ fs17.writeFileSync(parsed.output, rendered);
8133
8173
  console.log(`Exported ${summary.id} as ${parsed.format} to ${parsed.output}`);
8134
8174
  return;
8135
8175
  }
@@ -8174,7 +8214,7 @@ async function manageBenchDatasets(parsed) {
8174
8214
  process.exit(1);
8175
8215
  }
8176
8216
  const scriptPath = resolveDatasetDownloadScriptPath();
8177
- if (!fs16.existsSync(scriptPath)) {
8217
+ if (!fs17.existsSync(scriptPath)) {
8178
8218
  console.error(`ERROR: dataset download script not found: ${scriptPath}`);
8179
8219
  process.exit(1);
8180
8220
  }
@@ -8374,7 +8414,7 @@ async function calibrateBenchJudges(parsed, rawArgs) {
8374
8414
  );
8375
8415
  process.exit(1);
8376
8416
  }
8377
- const sourceResultSha256 = createHash4("sha256").update(fs16.readFileSync(latest.path)).digest("hex");
8417
+ const sourceResultSha256 = createHash4("sha256").update(fs17.readFileSync(latest.path)).digest("hex");
8378
8418
  const expandedManifestPath = expandTilde(manifestPath);
8379
8419
  if (!bench.resolveLocalLabJudgeProviderConfig) {
8380
8420
  console.error(
@@ -8789,7 +8829,7 @@ function loadPinnedLoCoMoTaskSelector(parsed) {
8789
8829
  }
8790
8830
  let decoded;
8791
8831
  try {
8792
- decoded = JSON.parse(fs16.readFileSync(parsed.taskIdsFile, "utf8"));
8832
+ decoded = JSON.parse(fs17.readFileSync(parsed.taskIdsFile, "utf8"));
8793
8833
  } catch (error) {
8794
8834
  throw new Error(
8795
8835
  `Unable to read --task-ids-file ${parsed.taskIdsFile}: ${error instanceof Error ? error.message : String(error)}`
@@ -9464,7 +9504,7 @@ function resolveBenchReproDatasetDir(datasetDir) {
9464
9504
  return void 0;
9465
9505
  }
9466
9506
  try {
9467
- return fs16.realpathSync(datasetDir);
9507
+ return fs17.realpathSync(datasetDir);
9468
9508
  } catch {
9469
9509
  return datasetDir;
9470
9510
  }
@@ -9518,13 +9558,13 @@ async function writeBenchReproManifestForPackageRun(args) {
9518
9558
  }
9519
9559
  function loadStandaloneConvergeCommandConfig() {
9520
9560
  const configPath = resolveConfigPath();
9521
- const raw = fs16.existsSync(configPath) ? JSON.parse(fs16.readFileSync(configPath, "utf8")) : {};
9522
- return parseConfig7(resolveRemnicConfigRecord6(raw));
9561
+ const raw = fs17.existsSync(configPath) ? JSON.parse(fs17.readFileSync(configPath, "utf8")) : {};
9562
+ return parseConfig8(resolveRemnicConfigRecord7(raw));
9523
9563
  }
9524
9564
  function parseConvergePluginConfig(value) {
9525
9565
  if (value === null || typeof value !== "object" || Array.isArray(value)) return void 0;
9526
9566
  if (Object.keys(value).length === 0) return void 0;
9527
- return parseConfig7(resolveRemnicConfigRecord6(value));
9567
+ return parseConfig8(resolveRemnicConfigRecord7(value));
9528
9568
  }
9529
9569
  function loadConvergeCommandConfig() {
9530
9570
  if (readCompatEnv("REMNIC_CONFIG_PATH", "ENGRAM_CONFIG_PATH")) {
@@ -9547,13 +9587,13 @@ function resolveConfigPath(cliPath) {
9547
9587
  path18.join(resolveHomeDir(), ".config", "engram", "config.json")
9548
9588
  ];
9549
9589
  for (const candidate of candidates) {
9550
- if (fs16.existsSync(candidate)) return candidate;
9590
+ if (fs17.existsSync(candidate)) return candidate;
9551
9591
  }
9552
9592
  return path18.join(resolveHomeDir(), ".config", "remnic", "config.json");
9553
9593
  }
9554
9594
  function resolveExistingBenchRemnicConfigPath(cliPath) {
9555
9595
  const configPath = resolveConfigPath(cliPath);
9556
- if (fs16.existsSync(configPath)) {
9596
+ if (fs17.existsSync(configPath)) {
9557
9597
  return configPath;
9558
9598
  }
9559
9599
  if (cliPath) {
@@ -9563,7 +9603,7 @@ function resolveExistingBenchRemnicConfigPath(cliPath) {
9563
9603
  }
9564
9604
  function resolveExistingBenchOpenclawConfigPath(cliPath) {
9565
9605
  const configPath = resolveOpenclawConfigPath(cliPath);
9566
- if (fs16.existsSync(configPath)) {
9606
+ if (fs17.existsSync(configPath)) {
9567
9607
  return configPath;
9568
9608
  }
9569
9609
  if (cliPath) {
@@ -9670,8 +9710,8 @@ function resolveMemoryDir() {
9670
9710
  const envMemoryDir = readCompatEnv("REMNIC_MEMORY_DIR", "ENGRAM_MEMORY_DIR");
9671
9711
  if (envMemoryDir) return normalizeMemoryDirPath(envMemoryDir);
9672
9712
  const configPath = resolveConfigPath();
9673
- const raw = fs16.existsSync(configPath) ? JSON.parse(fs16.readFileSync(configPath, "utf8")) : {};
9674
- const remnicCfg = resolveRemnicConfigRecord6(raw);
9713
+ const raw = fs17.existsSync(configPath) ? JSON.parse(fs17.readFileSync(configPath, "utf8")) : {};
9714
+ const remnicCfg = resolveRemnicConfigRecord7(raw);
9675
9715
  if (typeof remnicCfg.memoryDir === "string" && remnicCfg.memoryDir.length > 0) {
9676
9716
  return normalizeMemoryDirPath(remnicCfg.memoryDir);
9677
9717
  }
@@ -9679,18 +9719,18 @@ function resolveMemoryDir() {
9679
9719
  const standalonePath = path18.join(home, ".remnic", "memory");
9680
9720
  const legacyStandalonePath = path18.join(home, ".engram", "memory");
9681
9721
  const openclawPath = path18.join(resolveOpenclawStateDir(), "workspace", "memory", "local");
9682
- if (fs16.existsSync(standalonePath)) return standalonePath;
9683
- if (fs16.existsSync(legacyStandalonePath)) return legacyStandalonePath;
9722
+ if (fs17.existsSync(standalonePath)) return standalonePath;
9723
+ if (fs17.existsSync(legacyStandalonePath)) return legacyStandalonePath;
9684
9724
  return openclawPath;
9685
9725
  })();
9686
9726
  const manifestPath = getManifestPath();
9687
- if (fs16.existsSync(manifestPath)) {
9727
+ if (fs17.existsSync(manifestPath)) {
9688
9728
  try {
9689
9729
  const active = getActiveSpace();
9690
9730
  if (active?.memoryDir) {
9691
9731
  const activeMemoryDir = normalizeMemoryDirPath(active.memoryDir);
9692
- if (!fs16.existsSync(activeMemoryDir)) {
9693
- fs16.mkdirSync(activeMemoryDir, { recursive: true });
9732
+ if (!fs17.existsSync(activeMemoryDir)) {
9733
+ fs17.mkdirSync(activeMemoryDir, { recursive: true });
9694
9734
  }
9695
9735
  return activeMemoryDir;
9696
9736
  }
@@ -9739,13 +9779,13 @@ function resolveOpenclawConfigPath(cliPath) {
9739
9779
  const envPath = process.env.OPENCLAW_CONFIG_PATH || process.env.OPENCLAW_ENGRAM_CONFIG_PATH;
9740
9780
  if (envPath) return path18.resolve(expandTilde(envPath));
9741
9781
  for (const candidate of DEFAULT_OPENCLAW_CONFIG_PATHS_FOR_DOCTOR) {
9742
- if (fs16.existsSync(candidate)) return candidate;
9782
+ if (fs17.existsSync(candidate)) return candidate;
9743
9783
  }
9744
9784
  return path18.join(resolveOpenclawStateDir(), "openclaw.json");
9745
9785
  }
9746
9786
  function readOpenclawConfig(configPath) {
9747
- if (!fs16.existsSync(configPath)) return {};
9748
- const raw = fs16.readFileSync(configPath, "utf-8");
9787
+ if (!fs17.existsSync(configPath)) return {};
9788
+ const raw = fs17.readFileSync(configPath, "utf-8");
9749
9789
  let parsed;
9750
9790
  try {
9751
9791
  parsed = JSON.parse(raw);
@@ -9847,9 +9887,9 @@ function formatOpenclawUpgradeStamp(now = /* @__PURE__ */ new Date()) {
9847
9887
  return `${yyyy}${mm}${dd}-${hh}${min}${ss}`;
9848
9888
  }
9849
9889
  function backupPathIfPresent(sourcePath, backupPath) {
9850
- if (!fs16.existsSync(sourcePath)) return false;
9851
- fs16.mkdirSync(path18.dirname(backupPath), { recursive: true });
9852
- fs16.cpSync(sourcePath, backupPath, { recursive: true });
9890
+ if (!fs17.existsSync(sourcePath)) return false;
9891
+ fs17.mkdirSync(path18.dirname(backupPath), { recursive: true });
9892
+ fs17.cpSync(sourcePath, backupPath, { recursive: true });
9853
9893
  return true;
9854
9894
  }
9855
9895
  function restartOpenclawGateway() {
@@ -9868,7 +9908,7 @@ function restartOpenclawGateway() {
9868
9908
  }
9869
9909
  function cmdInit() {
9870
9910
  const configPath = path18.join(process.cwd(), "remnic.config.json");
9871
- if (fs16.existsSync(configPath)) {
9911
+ if (fs17.existsSync(configPath)) {
9872
9912
  console.log(`Config already exists: ${configPath}`);
9873
9913
  return;
9874
9914
  }
@@ -9884,7 +9924,7 @@ function cmdInit() {
9884
9924
  authToken: "${REMNIC_AUTH_TOKEN}"
9885
9925
  }
9886
9926
  };
9887
- fs16.writeFileSync(configPath, JSON.stringify(template, null, 2) + "\n");
9927
+ fs17.writeFileSync(configPath, JSON.stringify(template, null, 2) + "\n");
9888
9928
  console.log(`Created ${configPath}`);
9889
9929
  console.log("\nSet these environment variables:");
9890
9930
  console.log(" export OPENAI_API_KEY=sk-...");
@@ -10306,10 +10346,10 @@ async function cmdQuery(queryText, json, explain) {
10306
10346
  }
10307
10347
  initLogger3();
10308
10348
  const configPath = resolveConfigPath();
10309
- const raw = fs16.existsSync(configPath) ? JSON.parse(fs16.readFileSync(configPath, "utf8")) : {};
10310
- const remnicCfg = resolveRemnicConfigRecord6(raw);
10311
- const config = parseConfig7(remnicCfg);
10312
- const orchestrator = new Orchestrator4(config);
10349
+ const raw = fs17.existsSync(configPath) ? JSON.parse(fs17.readFileSync(configPath, "utf8")) : {};
10350
+ const remnicCfg = resolveRemnicConfigRecord7(raw);
10351
+ const config = parseConfig8(remnicCfg);
10352
+ const orchestrator = new Orchestrator5(config);
10313
10353
  await orchestrator.initialize();
10314
10354
  const service = new EngramAccessService2(orchestrator);
10315
10355
  const recallRequest = buildQueryRecallRequest(queryText);
@@ -10486,10 +10526,10 @@ async function cmdXray(rest) {
10486
10526
  }
10487
10527
  initLogger3();
10488
10528
  const configPath = resolveConfigPath();
10489
- const raw = fs16.existsSync(configPath) ? JSON.parse(fs16.readFileSync(configPath, "utf8")) : {};
10490
- const remnicCfg = resolveRemnicConfigRecord6(raw);
10491
- const config = parseConfig7(remnicCfg);
10492
- const orchestrator = new Orchestrator4(config);
10529
+ const raw = fs17.existsSync(configPath) ? JSON.parse(fs17.readFileSync(configPath, "utf8")) : {};
10530
+ const remnicCfg = resolveRemnicConfigRecord7(raw);
10531
+ const config = parseConfig8(remnicCfg);
10532
+ const orchestrator = new Orchestrator5(config);
10493
10533
  await orchestrator.initialize();
10494
10534
  await orchestrator.deferredReady;
10495
10535
  const service = new EngramAccessService2(orchestrator);
@@ -10506,12 +10546,46 @@ function xrayCliIo(recallXray) {
10506
10546
  stdout: (line) => console.log(line)
10507
10547
  };
10508
10548
  }
10549
+ async function runWhoKnowsCommand(rest, io) {
10550
+ const { topic, options } = extractWhoKnowsRawArgs(rest);
10551
+ const parsed = parseWhoKnowsCliOptions(topic, options);
10552
+ const result = await io.whoKnows({
10553
+ topic: parsed.topic,
10554
+ limit: parsed.limit,
10555
+ ...parsed.namespace ? { namespace: parsed.namespace } : {}
10556
+ });
10557
+ io.stdout(renderWhoKnows(result, parsed.json));
10558
+ }
10559
+ async function cmdWhoKnows(rest) {
10560
+ const { topic, options } = extractWhoKnowsRawArgs(rest);
10561
+ parseWhoKnowsCliOptions(topic, options);
10562
+ if (resolveRemoteDaemon(resolveConfigPath())) {
10563
+ throw new Error("who-knows: remote daemon mode is not supported yet; run with a local config");
10564
+ }
10565
+ initLogger3();
10566
+ const configPath = resolveConfigPath();
10567
+ const raw = fs17.existsSync(configPath) ? JSON.parse(fs17.readFileSync(configPath, "utf8")) : {};
10568
+ const config = parseConfig8(resolveRemnicConfigRecord7(raw));
10569
+ const orchestrator = new Orchestrator5(config);
10570
+ await orchestrator.initialize();
10571
+ await orchestrator.deferredReady;
10572
+ const service = new EngramAccessService2(orchestrator);
10573
+ try {
10574
+ await runWhoKnowsCommand(rest, {
10575
+ whoKnows: (request) => service.whoKnows(request),
10576
+ stdout: (line) => console.log(line)
10577
+ });
10578
+ } finally {
10579
+ orchestrator.abortDeferredInit();
10580
+ await orchestrator.destroy();
10581
+ }
10582
+ }
10509
10583
  async function cmdVersions(rest) {
10510
10584
  initLogger3();
10511
10585
  const configPath = resolveConfigPath();
10512
- const raw = fs16.existsSync(configPath) ? JSON.parse(fs16.readFileSync(configPath, "utf8")) : {};
10513
- const remnicCfg = resolveRemnicConfigRecord6(raw);
10514
- const config = parseConfig7(remnicCfg);
10586
+ const raw = fs17.existsSync(configPath) ? JSON.parse(fs17.readFileSync(configPath, "utf8")) : {};
10587
+ const remnicCfg = resolveRemnicConfigRecord7(raw);
10588
+ const config = parseConfig8(remnicCfg);
10515
10589
  if (!config.versioningEnabled) {
10516
10590
  console.error("Page versioning is disabled (versioningEnabled = false).");
10517
10591
  process.exit(1);
@@ -10625,9 +10699,9 @@ Options:
10625
10699
  async function cmdEnrich(rest) {
10626
10700
  initLogger3();
10627
10701
  const configPath = resolveConfigPath();
10628
- const raw = fs16.existsSync(configPath) ? JSON.parse(fs16.readFileSync(configPath, "utf8")) : {};
10629
- const remnicCfg = resolveRemnicConfigRecord6(raw);
10630
- const config = parseConfig7(remnicCfg);
10702
+ const raw = fs17.existsSync(configPath) ? JSON.parse(fs17.readFileSync(configPath, "utf8")) : {};
10703
+ const remnicCfg = resolveRemnicConfigRecord7(raw);
10704
+ const config = parseConfig8(remnicCfg);
10631
10705
  const subcommand = rest[0];
10632
10706
  if (subcommand === "audit") {
10633
10707
  const memoryDir2 = expandTilde(config.memoryDir);
@@ -10655,7 +10729,7 @@ async function cmdEnrich(rest) {
10655
10729
  pipelineConfig2.providers = [
10656
10730
  { id: "web-search", enabled: true, costTier: "cheap" }
10657
10731
  ];
10658
- const orchestrator2 = new Orchestrator4(config);
10732
+ const orchestrator2 = new Orchestrator5(config);
10659
10733
  await orchestrator2.initialize();
10660
10734
  await orchestrator2.deferredReady;
10661
10735
  const searchBackend2 = orchestrator2.qmd;
@@ -10691,7 +10765,7 @@ Registered providers:`);
10691
10765
  console.error("Usage: remnic enrich <entity-name> | --all | --dry-run | audit | providers");
10692
10766
  process.exit(1);
10693
10767
  }
10694
- const orchestrator = new Orchestrator4(config);
10768
+ const orchestrator = new Orchestrator5(config);
10695
10769
  await orchestrator.initialize();
10696
10770
  await orchestrator.deferredReady;
10697
10771
  const storage = await orchestrator.getStorage(config.defaultNamespace);
@@ -10870,9 +10944,9 @@ Shared with:
10870
10944
  process.exit(1);
10871
10945
  }
10872
10946
  const configPath = resolveConfigPath();
10873
- const raw = fs16.existsSync(configPath) ? JSON.parse(fs16.readFileSync(configPath, "utf8")) : {};
10874
- const remnicCfg = resolveRemnicConfigRecord6(raw);
10875
- const config = parseConfig7(remnicCfg);
10947
+ const raw = fs17.existsSync(configPath) ? JSON.parse(fs17.readFileSync(configPath, "utf8")) : {};
10948
+ const remnicCfg = resolveRemnicConfigRecord7(raw);
10949
+ const config = parseConfig8(remnicCfg);
10876
10950
  const memoryDir = expandTilde(
10877
10951
  typeof memoryDirOverride === "string" && memoryDirOverride.length > 0 ? memoryDirOverride : config.memoryDir ?? resolveMemoryDir()
10878
10952
  );
@@ -10887,9 +10961,9 @@ Shared with:
10887
10961
  async function cmdExtensions(action, rest) {
10888
10962
  initLogger3();
10889
10963
  const configPath = resolveConfigPath();
10890
- const raw = fs16.existsSync(configPath) ? JSON.parse(fs16.readFileSync(configPath, "utf8")) : {};
10891
- const remnicCfg = resolveRemnicConfigRecord6(raw);
10892
- const config = parseConfig7(remnicCfg);
10964
+ const raw = fs17.existsSync(configPath) ? JSON.parse(fs17.readFileSync(configPath, "utf8")) : {};
10965
+ const remnicCfg = resolveRemnicConfigRecord7(raw);
10966
+ const config = parseConfig8(remnicCfg);
10893
10967
  const root = resolveExtensionsRoot(config);
10894
10968
  const noopLog = { warn: () => {
10895
10969
  }, debug: () => {
@@ -10938,7 +11012,7 @@ Root: ${root}`);
10938
11012
  const extensions = await discoverMemoryExtensions(root, warnLog);
10939
11013
  let entries = [];
10940
11014
  try {
10941
- entries = fs16.readdirSync(root);
11015
+ entries = fs17.readdirSync(root);
10942
11016
  } catch {
10943
11017
  console.log(`Extensions root does not exist: ${root}`);
10944
11018
  process.exitCode = 0;
@@ -10949,7 +11023,7 @@ Root: ${root}`);
10949
11023
  for (const entry of entries) {
10950
11024
  const entryPath = path18.join(root, entry);
10951
11025
  try {
10952
- if (!fs16.statSync(entryPath).isDirectory()) continue;
11026
+ if (!fs17.statSync(entryPath).isDirectory()) continue;
10953
11027
  } catch {
10954
11028
  continue;
10955
11029
  }
@@ -10981,9 +11055,9 @@ Root: ${root}`);
10981
11055
  async function cmdBriefing(rest) {
10982
11056
  initLogger3();
10983
11057
  const configPath = resolveConfigPath();
10984
- const raw = fs16.existsSync(configPath) ? JSON.parse(fs16.readFileSync(configPath, "utf8")) : {};
10985
- const remnicCfg = resolveRemnicConfigRecord6(raw);
10986
- const config = parseConfig7(remnicCfg);
11058
+ const raw = fs17.existsSync(configPath) ? JSON.parse(fs17.readFileSync(configPath, "utf8")) : {};
11059
+ const remnicCfg = resolveRemnicConfigRecord7(raw);
11060
+ const config = parseConfig8(remnicCfg);
10987
11061
  if (!config.briefing.enabled) {
10988
11062
  console.error("Briefing is disabled in config (briefing.enabled = false).");
10989
11063
  process.exit(1);
@@ -11036,7 +11110,7 @@ async function cmdBriefing(rest) {
11036
11110
  process.exit(1);
11037
11111
  }
11038
11112
  const format = effectiveFormatFlag === "json" ? "json" : effectiveFormatFlag === "markdown" ? "markdown" : config.briefing.defaultFormat;
11039
- const orchestrator = new Orchestrator4(config);
11113
+ const orchestrator = new Orchestrator5(config);
11040
11114
  await orchestrator.initialize();
11041
11115
  const storage = await orchestrator.getStorage(config.defaultNamespace);
11042
11116
  const calendarSource = config.briefing.calendarSource ? new FileCalendarSource(config.briefing.calendarSource) : void 0;
@@ -11061,10 +11135,10 @@ async function cmdBriefing(rest) {
11061
11135
  if (save) {
11062
11136
  try {
11063
11137
  const saveDir = resolveBriefingSaveDir(config.briefing.saveDir);
11064
- fs16.mkdirSync(saveDir, { recursive: true });
11138
+ fs17.mkdirSync(saveDir, { recursive: true });
11065
11139
  const filename = briefingFilename(new Date(result.window.to), format);
11066
11140
  const filePath = path18.join(saveDir, filename);
11067
- fs16.writeFileSync(filePath, payload + (payload.endsWith("\n") ? "" : "\n"));
11141
+ fs17.writeFileSync(filePath, payload + (payload.endsWith("\n") ? "" : "\n"));
11068
11142
  console.error(`Saved briefing: ${filePath}`);
11069
11143
  } catch (err) {
11070
11144
  console.error(`Failed to save briefing: ${err instanceof Error ? err.message : String(err)}`);
@@ -11082,7 +11156,7 @@ async function cmdDoctor() {
11082
11156
  detail: `${nodeVersion} (requires >= 22.12.0)`
11083
11157
  });
11084
11158
  const configPath = resolveConfigPath();
11085
- const configExists = fs16.existsSync(configPath);
11159
+ const configExists = fs17.existsSync(configPath);
11086
11160
  checks.push({ name: "Config file", ok: configExists, detail: configPath });
11087
11161
  let standaloneConfig;
11088
11162
  let standaloneConfigError;
@@ -11090,11 +11164,11 @@ async function cmdDoctor() {
11090
11164
  let configuredNs = { invalid: false };
11091
11165
  if (configExists) {
11092
11166
  try {
11093
- const raw = JSON.parse(fs16.readFileSync(configPath, "utf8"));
11094
- const remnicCfg = resolveRemnicConfigRecord6(raw);
11167
+ const raw = JSON.parse(fs17.readFileSync(configPath, "utf8"));
11168
+ const remnicCfg = resolveRemnicConfigRecord7(raw);
11095
11169
  standaloneOpenaiApiKeyExplicitlyFalse = isOpenaiApiKeyDisabled(remnicCfg.openaiApiKey);
11096
11170
  configuredNs = readConfiguredNamespace(remnicCfg);
11097
- standaloneConfig = parseConfig7(remnicCfg);
11171
+ standaloneConfig = parseConfig8(remnicCfg);
11098
11172
  } catch (err) {
11099
11173
  standaloneConfigError = err instanceof Error ? err.message : String(err);
11100
11174
  }
@@ -11103,10 +11177,10 @@ async function cmdDoctor() {
11103
11177
  try {
11104
11178
  memoryDir = resolveMemoryDir();
11105
11179
  } catch {
11106
- memoryDir = parseConfig7({}).memoryDir;
11180
+ memoryDir = parseConfig8({}).memoryDir;
11107
11181
  }
11108
11182
  try {
11109
- fs16.mkdirSync(memoryDir, { recursive: true });
11183
+ fs17.mkdirSync(memoryDir, { recursive: true });
11110
11184
  checks.push({ name: "Memory directory", ok: true, detail: memoryDir });
11111
11185
  } catch {
11112
11186
  checks.push({ name: "Memory directory", ok: false, detail: `cannot create ${memoryDir}` });
@@ -11135,7 +11209,7 @@ async function cmdDoctor() {
11135
11209
  });
11136
11210
  if (nsPolicyCheck) checks.push(nsPolicyCheck);
11137
11211
  const openclawConfigPath = resolveOpenclawConfigPath();
11138
- const openclawConfigExists = fs16.existsSync(openclawConfigPath);
11212
+ const openclawConfigExists = fs17.existsSync(openclawConfigPath);
11139
11213
  let openclawConfig = {};
11140
11214
  let openclawConfigValid = false;
11141
11215
  let openclawPluginModeConfigured = false;
@@ -11143,7 +11217,7 @@ async function cmdDoctor() {
11143
11217
  let activeOpenclawEntryConfig = null;
11144
11218
  if (openclawConfigExists) {
11145
11219
  try {
11146
- const parsed = JSON.parse(fs16.readFileSync(openclawConfigPath, "utf-8"));
11220
+ const parsed = JSON.parse(fs17.readFileSync(openclawConfigPath, "utf-8"));
11147
11221
  if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
11148
11222
  openclawConfig = parsed;
11149
11223
  openclawConfigValid = true;
@@ -11223,9 +11297,9 @@ async function cmdDoctor() {
11223
11297
  let memDirOk = false;
11224
11298
  let memDirDetail = `${resolvedMemDir} (not found)`;
11225
11299
  let memDirRemediation = `Run \`remnic openclaw install --memory-dir "${resolvedMemDir}"\` to create the directory.`;
11226
- if (fs16.existsSync(resolvedMemDir)) {
11300
+ if (fs17.existsSync(resolvedMemDir)) {
11227
11301
  try {
11228
- const stat2 = fs16.statSync(resolvedMemDir);
11302
+ const stat2 = fs17.statSync(resolvedMemDir);
11229
11303
  if (stat2.isDirectory()) {
11230
11304
  memDirOk = true;
11231
11305
  memDirDetail = resolvedMemDir;
@@ -11380,12 +11454,12 @@ async function cmdDoctor() {
11380
11454
  }
11381
11455
  function cmdConfig() {
11382
11456
  const configPath = resolveConfigPath();
11383
- if (!fs16.existsSync(configPath)) {
11457
+ if (!fs17.existsSync(configPath)) {
11384
11458
  console.log("No config file found. Run `remnic init` to create one.");
11385
11459
  return;
11386
11460
  }
11387
11461
  console.log(`Config: ${configPath}`);
11388
- const rawConfig = fs16.readFileSync(configPath, "utf8");
11462
+ const rawConfig = fs17.readFileSync(configPath, "utf8");
11389
11463
  const redacted = rawConfig.replace(
11390
11464
  /("(?:openaiApiKey|localLlmApiKey|authToken|apiKey|remoteSearchApiKey|meilisearchApiKey|opikApiKey)"\s*:\s*")([^"]*)(")/g,
11391
11465
  "$1[REDACTED]$3"
@@ -11493,9 +11567,9 @@ async function cmdReview(action, rest) {
11493
11567
  const configPath = resolveConfigPath();
11494
11568
  let tombstonesConfig = null;
11495
11569
  try {
11496
- const rawCfg = fs16.existsSync(configPath) ? JSON.parse(fs16.readFileSync(configPath, "utf8")) : {};
11497
- const remnicCfg = resolveRemnicConfigRecord6(rawCfg);
11498
- const config = parseConfig7(remnicCfg);
11570
+ const rawCfg = fs17.existsSync(configPath) ? JSON.parse(fs17.readFileSync(configPath, "utf8")) : {};
11571
+ const remnicCfg = resolveRemnicConfigRecord7(rawCfg);
11572
+ const config = parseConfig8(remnicCfg);
11499
11573
  tombstonesConfig = {
11500
11574
  enabled: config.tombstonesEnabled,
11501
11575
  semanticMatch: config.tombstonesSemanticMatch,
@@ -12237,7 +12311,7 @@ async function pushOfflineFileContent(args) {
12237
12311
  }
12238
12312
  async function pushOfflineFileContentFromChunkReader(args) {
12239
12313
  const filePath = resolveOfflineDirectHydrationPath(args.memoryDir, args.file.path);
12240
- const stat2 = fs16.statSync(filePath);
12314
+ const stat2 = fs17.statSync(filePath);
12241
12315
  if (stat2.mtimeMs !== args.file.mtimeMs) {
12242
12316
  throw new Error(`local file changed while pushing offline content: ${args.file.path}`);
12243
12317
  }
@@ -12728,7 +12802,7 @@ function advanceOfflineBaseFilesForSuccessfulPush(options) {
12728
12802
  return [...next.values()].sort((left, right) => left.path.localeCompare(right.path));
12729
12803
  }
12730
12804
  async function runOfflineSyncOnce(options) {
12731
- fs16.mkdirSync(options.memoryDir, { recursive: true });
12805
+ fs17.mkdirSync(options.memoryDir, { recursive: true });
12732
12806
  let activeStatePath = options.statePath;
12733
12807
  let priorState = await readOfflineSyncState(activeStatePath);
12734
12808
  let syncNamespace = options.namespace ?? priorState?.namespace;
@@ -13361,7 +13435,7 @@ Environment fallbacks:
13361
13435
  const configPath = resolveConfigPath();
13362
13436
  let config;
13363
13437
  try {
13364
- const rawConfig = fs16.existsSync(configPath) ? JSON.parse(fs16.readFileSync(configPath, "utf8")) : {};
13438
+ const rawConfig = fs17.existsSync(configPath) ? JSON.parse(fs17.readFileSync(configPath, "utf8")) : {};
13365
13439
  config = parseConfigQuietly(pickOfflineConfigRecord(rawConfig));
13366
13440
  } catch {
13367
13441
  throw new Error(
@@ -13376,7 +13450,7 @@ Environment fallbacks:
13376
13450
  const statePath = statePathExplicit ? path18.resolve(expandTilde(stateOverride)) : remoteUrl !== void 0 ? defaultOfflineSyncStatePath(memoryDir, remoteUrl, namespace) : void 0;
13377
13451
  if (action === "prepare") {
13378
13452
  if (!remoteUrl || !token || !statePath) throw new Error("offline prepare requires remote URL and token");
13379
- fs16.mkdirSync(memoryDir, { recursive: true });
13453
+ fs17.mkdirSync(memoryDir, { recursive: true });
13380
13454
  const remoteSnapshot = await fetchOfflineSnapshot({
13381
13455
  remoteUrl,
13382
13456
  token,
@@ -13475,7 +13549,7 @@ Environment fallbacks:
13475
13549
  return;
13476
13550
  }
13477
13551
  if (action === "status") {
13478
- fs16.mkdirSync(memoryDir, { recursive: true });
13552
+ fs17.mkdirSync(memoryDir, { recursive: true });
13479
13553
  const state = statePath ? await readOfflineSyncState(statePath) : null;
13480
13554
  if (state && remoteUrl && statePath) {
13481
13555
  assertOfflineStateMatches({
@@ -13613,7 +13687,7 @@ function cmdDedup(json) {
13613
13687
  function readInstalledConnectorConfig(configPath, fallback) {
13614
13688
  if (!configPath) return fallback;
13615
13689
  try {
13616
- const parsed = JSON.parse(fs16.readFileSync(configPath, "utf8"));
13690
+ const parsed = JSON.parse(fs17.readFileSync(configPath, "utf8"));
13617
13691
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return fallback;
13618
13692
  const { token: _token, ...config } = parsed;
13619
13693
  return config;
@@ -13791,7 +13865,7 @@ async function cmdConnectors(action, rest, json) {
13791
13865
  const pub = factory();
13792
13866
  const available = await pub.isHostAvailable();
13793
13867
  const extRoot = available ? await pub.resolveExtensionRoot() : "(host not installed)";
13794
- const extensionExists = available && extRoot ? fs16.existsSync(extRoot) : false;
13868
+ const extensionExists = available && extRoot ? fs17.existsSync(extRoot) : false;
13795
13869
  publisherChecks.push({
13796
13870
  name: `Publisher: ${targetHostId}`,
13797
13871
  ok: !available || extensionExists,
@@ -13865,7 +13939,7 @@ async function cmdConnectors(action, rest, json) {
13865
13939
  let connectorsCfg;
13866
13940
  const configPath = resolveConfigPath();
13867
13941
  try {
13868
- const raw = fs16.existsSync(configPath) ? JSON.parse(fs16.readFileSync(configPath, "utf8")) : {};
13942
+ const raw = fs17.existsSync(configPath) ? JSON.parse(fs17.readFileSync(configPath, "utf8")) : {};
13869
13943
  connectorsCfg = parseConfigQuietly(raw).connectors;
13870
13944
  } catch {
13871
13945
  process.stderr.write(
@@ -13941,10 +14015,10 @@ async function cmdConnectors(action, rest, json) {
13941
14015
  }
13942
14016
  initLogger3();
13943
14017
  const configPath = resolveConfigPath();
13944
- const raw = fs16.existsSync(configPath) ? JSON.parse(fs16.readFileSync(configPath, "utf8")) : {};
13945
- const remnicCfg = resolveRemnicConfigRecord6(raw);
13946
- const config = parseConfig7(remnicCfg);
13947
- const orchestrator = new Orchestrator4(config);
14018
+ const raw = fs17.existsSync(configPath) ? JSON.parse(fs17.readFileSync(configPath, "utf8")) : {};
14019
+ const remnicCfg = resolveRemnicConfigRecord7(raw);
14020
+ const config = parseConfig8(remnicCfg);
14021
+ const orchestrator = new Orchestrator5(config);
13948
14022
  try {
13949
14023
  await orchestrator.initialize();
13950
14024
  await orchestrator.deferredReady;
@@ -14066,9 +14140,9 @@ async function cmdConnectorsMarketplace(subAction, rest, json) {
14066
14140
  console.error(`connectors marketplace: ${err instanceof Error ? err.message : String(err)}`);
14067
14141
  process.exit(1);
14068
14142
  }
14069
- const rawConfig = fs16.existsSync(configPath) ? JSON.parse(fs16.readFileSync(configPath, "utf8")) : {};
14070
- const pluginConfig = resolveRemnicConfigRecord6(rawConfig);
14071
- const config = parseConfig7(pluginConfig);
14143
+ const rawConfig = fs17.existsSync(configPath) ? JSON.parse(fs17.readFileSync(configPath, "utf8")) : {};
14144
+ const pluginConfig = resolveRemnicConfigRecord7(rawConfig);
14145
+ const config = parseConfig8(pluginConfig);
14072
14146
  if (subAction === "generate") {
14073
14147
  let outputDir;
14074
14148
  try {
@@ -14088,13 +14162,13 @@ async function cmdConnectorsMarketplace(subAction, rest, json) {
14088
14162
  } else if (subAction === "validate") {
14089
14163
  const targetPath = rest.filter((a) => !a.startsWith("--"))[0] ?? path18.join(process.cwd(), "marketplace.json");
14090
14164
  const resolved = path18.resolve(targetPath);
14091
- if (!fs16.existsSync(resolved)) {
14165
+ if (!fs17.existsSync(resolved)) {
14092
14166
  console.error(`File not found: ${resolved}`);
14093
14167
  process.exit(1);
14094
14168
  }
14095
14169
  let parsed;
14096
14170
  try {
14097
- parsed = JSON.parse(fs16.readFileSync(resolved, "utf8"));
14171
+ parsed = JSON.parse(fs17.readFileSync(resolved, "utf8"));
14098
14172
  } catch {
14099
14173
  console.error(`Invalid JSON in ${resolved}`);
14100
14174
  process.exit(1);
@@ -14295,10 +14369,10 @@ async function cmdSpace(action, rest, json) {
14295
14369
  async function cmdLegacyBenchmark(action, rest, json) {
14296
14370
  initLogger3();
14297
14371
  const configPath = resolveConfigPath();
14298
- const raw = fs16.existsSync(configPath) ? JSON.parse(fs16.readFileSync(configPath, "utf8")) : {};
14299
- const remnicCfg = resolveRemnicConfigRecord6(raw);
14300
- const config = parseConfig7(remnicCfg);
14301
- const orchestrator = new Orchestrator4(config);
14372
+ const raw = fs17.existsSync(configPath) ? JSON.parse(fs17.readFileSync(configPath, "utf8")) : {};
14373
+ const remnicCfg = resolveRemnicConfigRecord7(raw);
14374
+ const config = parseConfig8(remnicCfg);
14375
+ const orchestrator = new Orchestrator5(config);
14302
14376
  const service = new EngramAccessService2(orchestrator);
14303
14377
  const { runBenchSuite, loadBaseline, checkRegression } = await loadBenchModule();
14304
14378
  const benchConfig = {
@@ -14700,7 +14774,7 @@ function readPid() {
14700
14774
  function inferPort() {
14701
14775
  try {
14702
14776
  const configPath = resolveConfigPath();
14703
- const raw = JSON.parse(fs16.readFileSync(configPath, "utf8"));
14777
+ const raw = JSON.parse(fs17.readFileSync(configPath, "utf8"));
14704
14778
  return raw.server?.port ?? 4318;
14705
14779
  } catch {
14706
14780
  return 4318;
@@ -14795,13 +14869,13 @@ function daemonInstall() {
14795
14869
  process.exit(1);
14796
14870
  }
14797
14871
  const vars = { HOME: home, NODE_PATH: nodePath, REMNIC_SERVER_BIN: serverBin };
14798
- fs16.mkdirSync(LOGS_DIR, { recursive: true });
14872
+ fs17.mkdirSync(LOGS_DIR, { recursive: true });
14799
14873
  if (isMacOS()) {
14800
14874
  const templatePath = path18.resolve(import.meta.dirname, "../templates/launchd/ai.remnic.daemon.plist");
14801
- const template = fs16.readFileSync(templatePath, "utf8");
14875
+ const template = fs17.readFileSync(templatePath, "utf8");
14802
14876
  const plist = renderTemplate(template, vars);
14803
- fs16.mkdirSync(path18.dirname(LAUNCHD_PLIST_PATH), { recursive: true });
14804
- fs16.writeFileSync(LAUNCHD_PLIST_PATH, plist);
14877
+ fs17.mkdirSync(path18.dirname(LAUNCHD_PLIST_PATH), { recursive: true });
14878
+ fs17.writeFileSync(LAUNCHD_PLIST_PATH, plist);
14805
14879
  try {
14806
14880
  launchdLoadPlist(LAUNCHD_PLIST_PATH);
14807
14881
  } catch (err) {
@@ -14818,10 +14892,10 @@ function daemonInstall() {
14818
14892
  console.log(` Logs: ${LOGS_DIR}/daemon.log`);
14819
14893
  } else if (isLinux()) {
14820
14894
  const templatePath = path18.resolve(import.meta.dirname, "../templates/systemd/remnic.service");
14821
- const template = fs16.readFileSync(templatePath, "utf8");
14895
+ const template = fs17.readFileSync(templatePath, "utf8");
14822
14896
  const unit = renderTemplate(template, vars);
14823
- fs16.mkdirSync(path18.dirname(SYSTEMD_UNIT_PATH), { recursive: true });
14824
- fs16.writeFileSync(SYSTEMD_UNIT_PATH, unit);
14897
+ fs17.mkdirSync(path18.dirname(SYSTEMD_UNIT_PATH), { recursive: true });
14898
+ fs17.writeFileSync(SYSTEMD_UNIT_PATH, unit);
14825
14899
  try {
14826
14900
  childProcess2.execSync("systemctl --user daemon-reload", { stdio: "pipe" });
14827
14901
  } catch (err) {
@@ -14857,7 +14931,7 @@ function daemonUninstall() {
14857
14931
  } catch {
14858
14932
  }
14859
14933
  try {
14860
- fs16.unlinkSync(plistPath);
14934
+ fs17.unlinkSync(plistPath);
14861
14935
  removed = true;
14862
14936
  console.log(`Removed launchd service: ${plistPath}`);
14863
14937
  } catch {
@@ -14877,7 +14951,7 @@ function daemonUninstall() {
14877
14951
  let removed = false;
14878
14952
  for (const unitPath of SYSTEMD_UNIT_PATHS) {
14879
14953
  try {
14880
- fs16.unlinkSync(unitPath);
14954
+ fs17.unlinkSync(unitPath);
14881
14955
  removed = true;
14882
14956
  console.log(`Removed systemd service: ${unitPath}`);
14883
14957
  } catch {
@@ -14944,13 +15018,13 @@ async function daemonStatus() {
14944
15018
  console.log(` Port: ${port}`);
14945
15019
  console.log(` Service: ${serviceInstalled ? "installed" : "not installed"}`);
14946
15020
  console.log(` Platform: ${process.platform}`);
14947
- console.log(` PID file: ${fs16.existsSync(PID_FILE) ? PID_FILE : LEGACY_PID_FILE}`);
14948
- console.log(` Log file: ${fs16.existsSync(LOG_FILE) ? LOG_FILE : LEGACY_LOG_FILE}`);
15021
+ console.log(` PID file: ${fs17.existsSync(PID_FILE) ? PID_FILE : LEGACY_PID_FILE}`);
15022
+ console.log(` Log file: ${fs17.existsSync(LOG_FILE) ? LOG_FILE : LEGACY_LOG_FILE}`);
14949
15023
  try {
14950
15024
  const configPath = resolveConfigPath();
14951
- const raw = fs16.existsSync(configPath) ? JSON.parse(fs16.readFileSync(configPath, "utf8")) : {};
14952
- const remnicCfg = resolveRemnicConfigRecord6(raw);
14953
- const config = parseConfig7(remnicCfg);
15025
+ const raw = fs17.existsSync(configPath) ? JSON.parse(fs17.readFileSync(configPath, "utf8")) : {};
15026
+ const remnicCfg = resolveRemnicConfigRecord7(raw);
15027
+ const config = parseConfig8(remnicCfg);
14954
15028
  const extRoot = resolveExtensionsRoot(config);
14955
15029
  const noopLog = { warn: () => {
14956
15030
  }, debug: () => {
@@ -14989,9 +15063,9 @@ function daemonStart() {
14989
15063
  return;
14990
15064
  }
14991
15065
  }
14992
- fs16.mkdirSync(PID_DIR, { recursive: true });
14993
- fs16.mkdirSync(LOGS_DIR, { recursive: true });
14994
- const logStream = fs16.openSync(LOG_FILE, "a");
15066
+ fs17.mkdirSync(PID_DIR, { recursive: true });
15067
+ fs17.mkdirSync(LOGS_DIR, { recursive: true });
15068
+ const logStream = fs17.openSync(LOG_FILE, "a");
14995
15069
  const serverBin = resolveServerBin();
14996
15070
  const isSource = serverBin.endsWith(".ts");
14997
15071
  let cmd;
@@ -15013,7 +15087,7 @@ function daemonStart() {
15013
15087
  }
15014
15088
  });
15015
15089
  child.unref();
15016
- fs16.writeFileSync(PID_FILE, String(child.pid));
15090
+ fs17.writeFileSync(PID_FILE, String(child.pid));
15017
15091
  console.log(`Started remnic server (pid ${child.pid})`);
15018
15092
  console.log(` Log: ${LOG_FILE}`);
15019
15093
  }
@@ -15047,11 +15121,11 @@ function daemonStop() {
15047
15121
  console.log("Process not found (cleaning up PID file)");
15048
15122
  }
15049
15123
  try {
15050
- fs16.unlinkSync(PID_FILE);
15124
+ fs17.unlinkSync(PID_FILE);
15051
15125
  } catch {
15052
15126
  }
15053
15127
  try {
15054
- fs16.unlinkSync(LEGACY_PID_FILE);
15128
+ fs17.unlinkSync(LEGACY_PID_FILE);
15055
15129
  } catch {
15056
15130
  }
15057
15131
  }
@@ -15179,9 +15253,9 @@ async function promptYesNo(question, defaultYes = true) {
15179
15253
  async function cmdBinary(rest) {
15180
15254
  initLogger3();
15181
15255
  const configPath = resolveConfigPath();
15182
- const raw = fs16.existsSync(configPath) ? JSON.parse(fs16.readFileSync(configPath, "utf8")) : {};
15183
- const remnicCfg = resolveRemnicConfigRecord6(raw);
15184
- const config = parseConfig7(remnicCfg);
15256
+ const raw = fs17.existsSync(configPath) ? JSON.parse(fs17.readFileSync(configPath, "utf8")) : {};
15257
+ const remnicCfg = resolveRemnicConfigRecord7(raw);
15258
+ const config = parseConfig8(remnicCfg);
15185
15259
  const memoryDir = resolveMemoryDir();
15186
15260
  const blConfig = {
15187
15261
  enabled: config.binaryLifecycleEnabled,
@@ -15370,7 +15444,7 @@ async function cmdOpenclawInstall(opts) {
15370
15444
  } else if (slotIsActiveLegacy) {
15371
15445
  changes.push(` Slot left as "${REMNIC_OPENCLAW_LEGACY_PLUGIN_ID}" \u2014 re-run with --yes to activate the new entry`);
15372
15446
  }
15373
- if (!fs16.existsSync(memoryDir)) changes.push(`+ Will create memory directory: ${memoryDir}`);
15447
+ if (!fs17.existsSync(memoryDir)) changes.push(`+ Will create memory directory: ${memoryDir}`);
15374
15448
  if (hasLegacy && migrateLegacy) {
15375
15449
  changes.push(`~ Legacy '${REMNIC_OPENCLAW_LEGACY_PLUGIN_ID}' entry retained (safe to remove after verifying hooks fire)`);
15376
15450
  }
@@ -15390,8 +15464,8 @@ async function cmdOpenclawInstall(opts) {
15390
15464
  Resulting plugins.slots.memory: ${dryRunPlugins.slots?.memory ?? "(unset)"}`);
15391
15465
  return;
15392
15466
  }
15393
- if (fs16.existsSync(memoryDir)) {
15394
- const st = fs16.statSync(memoryDir);
15467
+ if (fs17.existsSync(memoryDir)) {
15468
+ const st = fs17.statSync(memoryDir);
15395
15469
  if (!st.isDirectory()) {
15396
15470
  throw new Error(
15397
15471
  `Cannot use ${memoryDir} as the memory directory \u2014 a file already exists at that path.
@@ -15399,12 +15473,12 @@ Remove it first and re-run, or choose a different path with --memory-dir.`
15399
15473
  );
15400
15474
  }
15401
15475
  } else {
15402
- fs16.mkdirSync(memoryDir, { recursive: true });
15476
+ fs17.mkdirSync(memoryDir, { recursive: true });
15403
15477
  console.log(`Created memory directory: ${memoryDir}`);
15404
15478
  }
15405
15479
  const configDir = path18.dirname(configPath);
15406
- if (!fs16.existsSync(configDir)) {
15407
- fs16.mkdirSync(configDir, { recursive: true });
15480
+ if (!fs17.existsSync(configDir)) {
15481
+ fs17.mkdirSync(configDir, { recursive: true });
15408
15482
  }
15409
15483
  atomicWriteFileSync(configPath, JSON.stringify(updatedConfig, null, 2) + "\n");
15410
15484
  console.log("\nDone! Summary of changes:");
@@ -15433,7 +15507,7 @@ async function cmdOpenclawUpgrade(opts) {
15433
15507
  const legacyPluginDirForBackup = opts.legacyPluginDirForBackup ? resolveOpenclawLegacyPluginDir(opts.legacyPluginDirForBackup) : void 0;
15434
15508
  const fallbackMemoryDir = path18.join(resolveOpenclawStateDir(), "workspace", "memory", "local");
15435
15509
  const packageSpec = buildOpenclawManagedUpgradePackageSpec(opts.version);
15436
- const configExistedBefore = fs16.existsSync(configPath);
15510
+ const configExistedBefore = fs17.existsSync(configPath);
15437
15511
  const existingConfig = readOpenclawConfig(configPath);
15438
15512
  const { entries, slots } = parseOpenclawPluginState(existingConfig, configPath);
15439
15513
  const preservedMemoryDir = opts.memoryDir ? path18.resolve(expandTilde(opts.memoryDir)) : resolveCurrentOpenclawMemoryDir(entries, slots, fallbackMemoryDir);
@@ -15658,15 +15732,15 @@ async function cmdOpenclawMigrateEngram(opts) {
15658
15732
  }
15659
15733
  function createOpenclawUpgradeBackupDir() {
15660
15734
  const backupsRoot = path18.join(resolveOpenclawStateDir(), "backups");
15661
- fs16.mkdirSync(backupsRoot, { recursive: true });
15662
- return fs16.mkdtempSync(path18.join(backupsRoot, `remnic-openclaw-upgrade-${formatOpenclawUpgradeStamp()}-`));
15735
+ fs17.mkdirSync(backupsRoot, { recursive: true });
15736
+ return fs17.mkdtempSync(path18.join(backupsRoot, `remnic-openclaw-upgrade-${formatOpenclawUpgradeStamp()}-`));
15663
15737
  }
15664
15738
  async function cmdTaxonomy(rest) {
15665
15739
  initLogger3();
15666
15740
  const configPath = resolveConfigPath();
15667
- const raw = fs16.existsSync(configPath) ? JSON.parse(fs16.readFileSync(configPath, "utf8")) : {};
15668
- const remnicCfg = resolveRemnicConfigRecord6(raw);
15669
- const config = parseConfig7(remnicCfg);
15741
+ const raw = fs17.existsSync(configPath) ? JSON.parse(fs17.readFileSync(configPath, "utf8")) : {};
15742
+ const remnicCfg = resolveRemnicConfigRecord7(raw);
15743
+ const config = parseConfig8(remnicCfg);
15670
15744
  if (!config.taxonomyEnabled) {
15671
15745
  console.error(
15672
15746
  "Taxonomy is disabled in config (taxonomyEnabled = false). Enable it to use taxonomy commands."
@@ -15702,8 +15776,8 @@ async function cmdTaxonomy(rest) {
15702
15776
  console.log(doc);
15703
15777
  if (config.taxonomyAutoGenResolver) {
15704
15778
  const resolverPath = path18.join(config.memoryDir, ".taxonomy", "RESOLVER.md");
15705
- fs16.mkdirSync(path18.dirname(resolverPath), { recursive: true });
15706
- fs16.writeFileSync(resolverPath, doc);
15779
+ fs17.mkdirSync(path18.dirname(resolverPath), { recursive: true });
15780
+ fs17.writeFileSync(resolverPath, doc);
15707
15781
  console.error(`Written: ${resolverPath}`);
15708
15782
  }
15709
15783
  break;
@@ -15749,7 +15823,7 @@ async function cmdTaxonomy(rest) {
15749
15823
  if (config.taxonomyAutoGenResolver) {
15750
15824
  const doc = generateResolverDocument(taxonomy);
15751
15825
  const resolverPath = path18.join(config.memoryDir, ".taxonomy", "RESOLVER.md");
15752
- fs16.writeFileSync(resolverPath, doc);
15826
+ fs17.writeFileSync(resolverPath, doc);
15753
15827
  console.error(`Regenerated: ${resolverPath}`);
15754
15828
  }
15755
15829
  break;
@@ -15780,7 +15854,7 @@ async function cmdTaxonomy(rest) {
15780
15854
  if (config.taxonomyAutoGenResolver) {
15781
15855
  const doc = generateResolverDocument(taxonomy);
15782
15856
  const resolverPath = path18.join(config.memoryDir, ".taxonomy", "RESOLVER.md");
15783
- fs16.writeFileSync(resolverPath, doc);
15857
+ fs17.writeFileSync(resolverPath, doc);
15784
15858
  console.error(`Regenerated: ${resolverPath}`);
15785
15859
  }
15786
15860
  break;
@@ -15971,12 +16045,12 @@ async function runTrainingExport(args, stdout = process.stdout) {
15971
16045
  `Unknown training-export format "${args.format}". ${validList}`
15972
16046
  );
15973
16047
  }
15974
- if (!fs16.existsSync(args.memoryDir)) {
16048
+ if (!fs17.existsSync(args.memoryDir)) {
15975
16049
  throw new Error(
15976
16050
  `--memory-dir "${args.memoryDir}" does not exist. Provide the path to an existing memory directory.`
15977
16051
  );
15978
16052
  }
15979
- if (!fs16.statSync(args.memoryDir).isDirectory()) {
16053
+ if (!fs17.statSync(args.memoryDir).isDirectory()) {
15980
16054
  throw new Error(
15981
16055
  `--memory-dir "${args.memoryDir}" is not a directory. Provide the path to a memory directory, not a file.`
15982
16056
  );
@@ -16062,10 +16136,10 @@ async function runTrainingExport(args, stdout = process.stdout) {
16062
16136
  }
16063
16137
  const formatted = adapter.formatRecords(records);
16064
16138
  const outDir = path18.dirname(args.output);
16065
- fs16.mkdirSync(outDir, { recursive: true });
16139
+ fs17.mkdirSync(outDir, { recursive: true });
16066
16140
  const tmpPath = `${args.output}.tmp-${process.pid}-${Date.now()}`;
16067
- fs16.writeFileSync(tmpPath, formatted, "utf-8");
16068
- fs16.renameSync(tmpPath, args.output);
16141
+ fs17.writeFileSync(tmpPath, formatted, "utf-8");
16142
+ fs17.renameSync(tmpPath, args.output);
16069
16143
  stdout.write(
16070
16144
  `Exported ${records.length} records to ${args.output} (${adapter.name} format)
16071
16145
  `
@@ -16114,6 +16188,9 @@ async function main(argv = process.argv.slice(2)) {
16114
16188
  case "xray":
16115
16189
  await cmdXray(rest);
16116
16190
  break;
16191
+ case "who-knows":
16192
+ await cmdWhoKnows(rest);
16193
+ break;
16117
16194
  case "security":
16118
16195
  await cmdSecurity(rest);
16119
16196
  break;
@@ -16237,7 +16314,7 @@ async function main(argv = process.argv.slice(2)) {
16237
16314
  }
16238
16315
  }, 500);
16239
16316
  };
16240
- fs16.watch(memoryDir, { recursive: true }, (_event, filename) => {
16317
+ fs17.watch(memoryDir, { recursive: true }, (_event, filename) => {
16241
16318
  if (filename && filename.startsWith(".")) return;
16242
16319
  rebuild();
16243
16320
  });
@@ -16245,12 +16322,12 @@ async function main(argv = process.argv.slice(2)) {
16245
16322
  });
16246
16323
  } else if (subAction === "validate") {
16247
16324
  const treeDir = outputDir;
16248
- if (!fs16.existsSync(treeDir)) {
16325
+ if (!fs17.existsSync(treeDir)) {
16249
16326
  console.error(`Context tree not found at ${treeDir}. Run 'remnic tree generate' first.`);
16250
16327
  process.exit(1);
16251
16328
  }
16252
16329
  const indexPath = path18.join(treeDir, "INDEX.md");
16253
- if (!fs16.existsSync(indexPath)) {
16330
+ if (!fs17.existsSync(indexPath)) {
16254
16331
  console.error(`INDEX.md missing in ${treeDir}. Tree may be corrupt \u2014 regenerate.`);
16255
16332
  process.exit(1);
16256
16333
  }
@@ -16432,10 +16509,10 @@ Other:
16432
16509
  let wearablesService;
16433
16510
  try {
16434
16511
  const configPath = resolveConfigPath();
16435
- const raw = fs16.existsSync(configPath) ? JSON.parse(fs16.readFileSync(configPath, "utf8")) : {};
16436
- const remnicCfg = resolveRemnicConfigRecord6(raw);
16437
- const config = parseConfig7(remnicCfg);
16438
- wearablesOrchestrator = new Orchestrator4(config);
16512
+ const raw = fs17.existsSync(configPath) ? JSON.parse(fs17.readFileSync(configPath, "utf8")) : {};
16513
+ const remnicCfg = resolveRemnicConfigRecord7(raw);
16514
+ const config = parseConfig8(remnicCfg);
16515
+ wearablesOrchestrator = new Orchestrator5(config);
16439
16516
  await wearablesOrchestrator.initialize();
16440
16517
  await wearablesOrchestrator.deferredReady;
16441
16518
  wearablesService = wearablesOrchestrator.getWearablesService();
@@ -16474,6 +16551,9 @@ Other:
16474
16551
  await runMeetingsBinaryCommand(rest);
16475
16552
  break;
16476
16553
  }
16554
+ case "okf":
16555
+ await runOkfBinaryCommand(rest);
16556
+ break;
16477
16557
  case "external-wiki": {
16478
16558
  await runExternalWikiBinaryCommand(rest);
16479
16559
  break;
@@ -16487,10 +16567,10 @@ Other:
16487
16567
  const targetFactory = async () => {
16488
16568
  if (!orchestratorSingleton) {
16489
16569
  const configPath = resolveConfigPath();
16490
- const raw = fs16.existsSync(configPath) ? JSON.parse(fs16.readFileSync(configPath, "utf8")) : {};
16491
- const remnicCfg = resolveRemnicConfigRecord6(raw);
16492
- const config = parseConfig7(remnicCfg);
16493
- orchestratorSingleton = new Orchestrator4(config);
16570
+ const raw = fs17.existsSync(configPath) ? JSON.parse(fs17.readFileSync(configPath, "utf8")) : {};
16571
+ const remnicCfg = resolveRemnicConfigRecord7(raw);
16572
+ const config = parseConfig8(remnicCfg);
16573
+ orchestratorSingleton = new Orchestrator5(config);
16494
16574
  await orchestratorSingleton.initialize();
16495
16575
  await orchestratorSingleton.deferredReady;
16496
16576
  }
@@ -16675,33 +16755,27 @@ Usage:
16675
16755
  remnic query <text> [--json] [--explain] Query memories (use --explain for tier breakdown)
16676
16756
  remnic xray <query> [--format text|markdown|json] [--budget <chars>] [--namespace <ns>] [--out <path>]
16677
16757
  Run a recall with X-ray capture and print the unified snapshot
16678
- (tier + audit + MMR + filters). Part of #570. Defaults to text
16679
- output on stdout.
16758
+ (tier + audit + MMR + filters). Part of #570. Text output by default.
16759
+ remnic who-knows <topic> [--limit N] [--json] [--namespace <ns>] Rank entities by topic expertise
16680
16760
  remnic wearables <status|check|sync|transcript|search|memories|speakers|corrections>
16681
16761
  Wearable transcript sources (Limitless / Bee / Omi): pull + clean +
16682
16762
  store day transcripts, trust-gated memory creation, speaker labels,
16683
16763
  and per-user corrections. Run "remnic wearables help" for details.
16684
16764
  Connectors install \xE0 la carte: npm install @remnic/connector-limitless
16685
16765
  remnic meetings <list|show|build>
16686
- Retrospective meetings: list stored records, show one by id, or build
16687
- (detect + fuse + store) a day's meetings from ingested audio + screen
16688
- activity. Run "remnic meetings help" for details.
16766
+ Retrospective meetings: list, show, or build a day's meetings.
16767
+ Run "remnic meetings help" for details.
16768
+ remnic okf <lint|sweep> [--json]
16769
+ OKF v0.1 conformance: lint reports missing frontmatter/type findings,
16770
+ sweep backfills missing type values (okf.sweepEnabled).
16689
16771
  remnic external-wiki search <query...> [--wiki-id <id>] [--limit <1-20>] [--max-chars-per-hit <100-8000>] [--json]
16690
-
16691
16772
  remnic doctor Run diagnostics
16692
16773
  remnic config Show current config
16693
16774
  remnic openclaw install Configure OpenClaw to use Remnic memory (sets slot + entry)
16694
16775
  remnic openclaw upgrade Safe OpenClaw npm upgrade with backups and gateway restart
16695
16776
  remnic openclaw migrate-engram
16696
16777
  Migrate legacy @joshuaswarren/openclaw-engram installs with legacy extension backup
16697
- --yes / -y / --force Skip prompts
16698
- --dry-run Preview changes without writing
16699
- --memory-dir <path> Custom memory directory
16700
- --config <path> Custom OpenClaw config path
16701
- --version <tag> Upgrade @remnic/plugin-openclaw from a specific npm tag/version
16702
- --plugin-dir <path> Custom OpenClaw extension directory
16703
- --legacy-plugin-dir <path> Custom legacy extension directory for migration backup
16704
- --no-restart Skip the final launchctl kickstart after upgrade
16778
+ Run "remnic openclaw migrate-engram" for the full option list.
16705
16779
  remnic daemon <start|stop|restart|install|uninstall|status> Manage background server
16706
16780
  remnic token <generate|list|revoke> [connector-id] Manage auth tokens
16707
16781
  remnic tree <generate|watch|validate> Generate context tree
@@ -16879,6 +16953,7 @@ export {
16879
16953
  resolveSyncSourceDir,
16880
16954
  runOfflineSyncOnce,
16881
16955
  runTrainingExport,
16956
+ runWhoKnowsCommand,
16882
16957
  runXrayCommand,
16883
16958
  shouldDirectHydrateOfflineFile,
16884
16959
  stripConfigArgv,