@remnic/cli 9.69.87 → 9.69.88

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 +575 -332
  2. package/package.json +32 -32
package/dist/index.js CHANGED
@@ -488,7 +488,7 @@ function resetLegacyDatasetWarningState() {
488
488
  // src/index.ts
489
489
  import fs32 from "fs";
490
490
  import os4 from "os";
491
- import path23 from "path";
491
+ import path24 from "path";
492
492
  import { createHash as createHash6 } from "crypto";
493
493
  import { writeFile as fsWriteFile } from "fs/promises";
494
494
  import * as childProcess2 from "child_process";
@@ -573,7 +573,7 @@ import {
573
573
  discoverMemoryExtensions,
574
574
  resolveExtensionsRoot,
575
575
  coerceInstallExtension,
576
- StorageManager as StorageManager4,
576
+ StorageManager as StorageManager5,
577
577
  parseXrayCliOptions,
578
578
  renderXray,
579
579
  parseWhyCliOptions,
@@ -597,6 +597,8 @@ import {
597
597
  offlineSyncStateFromSnapshot,
598
598
  readOfflineSyncFileContentChunk,
599
599
  readOfflineSyncState,
600
+ embeddingGenerationMembership as embeddingGenerationMembership2,
601
+ divergedEmbeddingGenerationDeferrals,
600
602
  shouldPreferIncomingOfflineRuntimeFile,
601
603
  summarizeOfflineSyncPendingChanges,
602
604
  summarizeOfflineSyncPendingFiles,
@@ -2965,7 +2967,8 @@ async function createOfflineStorageIo(memoryDir, configuredStorage, persistedExc
2965
2967
  chunkSize
2966
2968
  }),
2967
2969
  writeFile: async ({ filePath, content }) => storage.writeOfflineSyncFile(filePath, content),
2968
- writeStagingFile: async ({ filePath, content }) => storage.writeOfflineSyncStagingFile(filePath, content),
2970
+ writeStagingFile: async ({ filePath, content, finalAadFilePath }) => storage.writeOfflineSyncStagingFile(filePath, content, finalAadFilePath === void 0 ? void 0 : { aadFilePath: finalAadFilePath }),
2971
+ readStagingFile: async ({ filePath, finalAadFilePath }) => storage.readOfflineSyncFile(filePath, finalAadFilePath === void 0 ? void 0 : { aadFilePath: finalAadFilePath }),
2969
2972
  writeFileChunks: async ({ filePath, chunks }) => storage.writeOfflineSyncFileChunks(filePath, chunks),
2970
2973
  deleteFile: async ({ filePath, mtimeMs }) => storage.deleteOfflineSyncFile(filePath, mtimeMs ?? null),
2971
2974
  recordDeletionRevision: async ({ filePath, mtimeMs }) => storage.recordReplicatedDeletionRevision(filePath, mtimeMs)
@@ -3305,13 +3308,13 @@ async function planLocalNamespaceCensus(args) {
3305
3308
  citationTemplate: args.citationTemplate,
3306
3309
  cachedFiles: identityCache.size > 0 ? [...identityCache.values()] : priorFiles,
3307
3310
  readFile: async (file) => {
3308
- const readFile5 = io.readFile;
3309
- if (!readFile5) {
3311
+ const readFile6 = io.readFile;
3312
+ if (!readFile6) {
3310
3313
  manifestReadFailed = true;
3311
3314
  throw new Error("offline storage cannot read reconciliation manifest files");
3312
3315
  }
3313
3316
  try {
3314
- return await readFile5({
3317
+ return await readFile6({
3315
3318
  root: rootDir,
3316
3319
  path: file.path,
3317
3320
  filePath: path6.join(rootDir, file.path)
@@ -5447,6 +5450,157 @@ async function drainOfflineSyncImpressions(memoryDir, rotation) {
5447
5450
  );
5448
5451
  }
5449
5452
 
5453
+ // src/offline-generation-staging.ts
5454
+ import { lstat as lstat3, mkdir as mkdir2, mkdtemp as mkdtemp2, readFile as readFile2, readdir as readdir3, rm as rm3, writeFile as writeFile2 } from "fs/promises";
5455
+ import path8 from "path";
5456
+ import { hostname } from "os";
5457
+ import { StorageManager as StorageManager4, embeddingGenerationMembership } from "@remnic/core";
5458
+ var GENERATION_STAGING_PREFIX = "generation-incoming-";
5459
+ function generationMembersForStagedTransport(options) {
5460
+ const currentByPath = new Map((options.currentFiles ?? []).map((file) => [file.path, file]));
5461
+ const deferred = new Set(options.deferredPaths ?? []);
5462
+ return options.incomingFiles.filter(
5463
+ (file) => file.bytes >= options.minBytes && !deferred.has(file.path) && currentByPath.get(file.path)?.sha256 !== file.sha256 && embeddingGenerationMembership(file.path) !== null
5464
+ ).sort((left, right) => right.bytes - left.bytes || left.path.localeCompare(right.path));
5465
+ }
5466
+ async function assertPrivateOfflineDir(offlineDir) {
5467
+ const info = await lstat3(offlineDir).catch((error) => {
5468
+ if (error.code === "ENOENT") return null;
5469
+ throw error;
5470
+ });
5471
+ if (info && (info.isSymbolicLink() || !info.isDirectory())) {
5472
+ throw new Error("offline-sync staging directory must be a real directory, not a symlink");
5473
+ }
5474
+ }
5475
+ async function removeStage(offlineDir, stage) {
5476
+ await assertPrivateOfflineDir(offlineDir);
5477
+ const info = await lstat3(stage).catch((error) => {
5478
+ if (error.code === "ENOENT") return null;
5479
+ throw error;
5480
+ });
5481
+ if (info?.isDirectory() && !info.isSymbolicLink()) {
5482
+ await rm3(stage, { recursive: true, force: true });
5483
+ }
5484
+ }
5485
+ async function reclaimAbandonedGenerationStages(offlineDir) {
5486
+ await assertPrivateOfflineDir(offlineDir);
5487
+ const names = await readdir3(offlineDir).catch((error) => {
5488
+ if (error.code === "ENOENT") return [];
5489
+ throw error;
5490
+ });
5491
+ for (const name of names) {
5492
+ if (!name.startsWith(GENERATION_STAGING_PREFIX)) continue;
5493
+ const dir = path8.join(offlineDir, name);
5494
+ try {
5495
+ const info = await lstat3(dir);
5496
+ if (!info.isDirectory() || info.isSymbolicLink()) continue;
5497
+ const owner = JSON.parse(await readFile2(path8.join(dir, "owner.json"), "utf-8"));
5498
+ if (owner?.hostname !== hostname() || !Number.isSafeInteger(owner.pid) || owner.pid <= 0) continue;
5499
+ try {
5500
+ process.kill(owner.pid, 0);
5501
+ } catch (error) {
5502
+ if (error.code === "ESRCH") {
5503
+ await removeStage(offlineDir, dir);
5504
+ }
5505
+ }
5506
+ } catch {
5507
+ }
5508
+ }
5509
+ }
5510
+ async function stageGenerationMembersForApply(options) {
5511
+ const noop = {
5512
+ stagedPaths: /* @__PURE__ */ new Set(),
5513
+ readIncomingFile: async () => null,
5514
+ cleanup: async () => {
5515
+ }
5516
+ };
5517
+ const candidates = generationMembersForStagedTransport({
5518
+ incomingFiles: options.incomingFiles,
5519
+ currentFiles: options.currentFiles,
5520
+ deferredPaths: options.deferredPaths,
5521
+ minBytes: options.minBytes
5522
+ });
5523
+ const offlineDir = path8.join(options.memoryDir, ".offline-sync");
5524
+ await reclaimAbandonedGenerationStages(offlineDir);
5525
+ if (candidates.length === 0) return noop;
5526
+ await mkdir2(offlineDir, { recursive: true });
5527
+ await assertPrivateOfflineDir(offlineDir);
5528
+ const stagingRoot = await mkdtemp2(path8.join(offlineDir, GENERATION_STAGING_PREFIX));
5529
+ try {
5530
+ await writeFile2(path8.join(stagingRoot, "owner.json"), JSON.stringify({
5531
+ pid: process.pid,
5532
+ hostname: hostname()
5533
+ }), { mode: 384, flag: "wx" });
5534
+ const configured = await createConfiguredOfflineStorage(options.memoryDir, options.secureStoreEncryptOnWrite);
5535
+ const stagingStorage = new StorageManager4(stagingRoot);
5536
+ if (configured.secureStoreRequired) stagingStorage.setSecureStoreRequired(true);
5537
+ if (configured.secureStoreKey) {
5538
+ await stagingStorage.setSecureStoreKeyAndWait(
5539
+ configured.secureStoreKey,
5540
+ options.secureStoreEncryptOnWrite ?? true
5541
+ );
5542
+ }
5543
+ const stagingIo = await createOfflineStorageIo(stagingRoot, {
5544
+ storage: stagingStorage,
5545
+ secureStoreKey: configured.secureStoreKey,
5546
+ secureStoreRequired: configured.secureStoreRequired
5547
+ });
5548
+ const stagingReadFile = stagingIo.readFile;
5549
+ const {
5550
+ readFileDigest: stagingReadFileDigest,
5551
+ writeFile: stagingWriteFile,
5552
+ writeStagingFile: stagingWriteStagingFile,
5553
+ writeFileChunks: stagingWriteFileChunks
5554
+ } = stagingIo;
5555
+ if (!stagingReadFile || !stagingReadFileDigest || !stagingWriteFile || !stagingWriteStagingFile || !stagingWriteFileChunks) {
5556
+ throw new Error("offline generation staging requires full storage IO hooks");
5557
+ }
5558
+ const stagedPaths = /* @__PURE__ */ new Set();
5559
+ for (const member of candidates) {
5560
+ const result = await options.hydrateFileContent({
5561
+ remoteUrl: options.remoteUrl,
5562
+ token: options.token,
5563
+ namespace: options.namespace,
5564
+ includeTranscripts: options.includeTranscripts,
5565
+ memoryDir: stagingRoot,
5566
+ sourceId: "remote",
5567
+ expected: member,
5568
+ readFile: stagingReadFile,
5569
+ readFileDigest: stagingReadFileDigest,
5570
+ writeFile: stagingWriteFile,
5571
+ writeStagingFile: stagingWriteStagingFile,
5572
+ writeFileChunks: stagingWriteFileChunks
5573
+ });
5574
+ if (result.conflict) {
5575
+ throw new Error(`offline generation staging conflict for ${member.path}`);
5576
+ }
5577
+ if (!result.done || !(result.applied || result.skipped)) {
5578
+ throw new Error(`offline generation staging did not finish for ${member.path}`);
5579
+ }
5580
+ stagedPaths.add(member.path);
5581
+ }
5582
+ return {
5583
+ stagedPaths,
5584
+ readIncomingFile: async (target) => {
5585
+ if (!stagedPaths.has(target.path)) return null;
5586
+ return await stagingReadFile({
5587
+ root: stagingRoot,
5588
+ path: target.path,
5589
+ filePath: resolveOfflineDirectHydrationPath(stagingRoot, target.path)
5590
+ });
5591
+ },
5592
+ cleanup: async () => {
5593
+ await removeStage(offlineDir, stagingRoot).catch(() => {
5594
+ });
5595
+ }
5596
+ };
5597
+ } catch (error) {
5598
+ await removeStage(offlineDir, stagingRoot).catch(() => {
5599
+ });
5600
+ throw error;
5601
+ }
5602
+ }
5603
+
5450
5604
  // src/index.ts
5451
5605
  import { briefingLocationSection, locationTaggingEnabled } from "@remnic/core/location";
5452
5606
 
@@ -5458,15 +5612,15 @@ import {
5458
5612
  readFileSync as readFileSync3,
5459
5613
  statSync
5460
5614
  } from "fs";
5461
- import path8 from "path";
5615
+ import path9 from "path";
5462
5616
  import { fileURLToPath as fileURLToPath2 } from "url";
5463
5617
  var STALE_BUILD_TOLERANCE_MS = 1e3;
5464
5618
  function assertLocalBenchBuildFreshForDevelopment(currentModuleUrl) {
5465
5619
  if (isTruthyEnv(process.env.REMNIC_BENCH_ALLOW_STALE_DIST)) {
5466
5620
  return;
5467
5621
  }
5468
- const currentDir = path8.dirname(fileURLToPath2(currentModuleUrl));
5469
- const benchPackageDir = path8.resolve(currentDir, "../../bench");
5622
+ const currentDir = path9.dirname(fileURLToPath2(currentModuleUrl));
5623
+ const benchPackageDir = path9.resolve(currentDir, "../../bench");
5470
5624
  const freshness = checkBenchBuildFreshness(benchPackageDir);
5471
5625
  if (!freshness.stale) {
5472
5626
  return;
@@ -5483,7 +5637,7 @@ function assertLocalBenchBuildFreshForDevelopment(currentModuleUrl) {
5483
5637
  );
5484
5638
  }
5485
5639
  function checkBenchBuildFreshness(benchPackageDir) {
5486
- const packageJsonPath = path8.join(benchPackageDir, "package.json");
5640
+ const packageJsonPath = path9.join(benchPackageDir, "package.json");
5487
5641
  if (!existsSync2(packageJsonPath)) {
5488
5642
  return { stale: false };
5489
5643
  }
@@ -5496,17 +5650,17 @@ function checkBenchBuildFreshness(benchPackageDir) {
5496
5650
  if (packageName !== "@remnic/bench") {
5497
5651
  return { stale: false };
5498
5652
  }
5499
- const srcDir = path8.join(benchPackageDir, "src");
5653
+ const srcDir = path9.join(benchPackageDir, "src");
5500
5654
  if (!isDirectory(srcDir)) {
5501
5655
  return { stale: false };
5502
5656
  }
5503
5657
  const sourceRoots = [
5504
5658
  srcDir,
5505
5659
  packageJsonPath,
5506
- path8.join(benchPackageDir, "tsup.config.ts"),
5507
- path8.join(benchPackageDir, "tsconfig.json")
5660
+ path9.join(benchPackageDir, "tsup.config.ts"),
5661
+ path9.join(benchPackageDir, "tsconfig.json")
5508
5662
  ];
5509
- const distPath = path8.join(benchPackageDir, "dist", "index.js");
5663
+ const distPath = path9.join(benchPackageDir, "dist", "index.js");
5510
5664
  if (!existsSync2(distPath)) {
5511
5665
  return {
5512
5666
  stale: true,
@@ -5549,7 +5703,7 @@ function newestMtime(roots) {
5549
5703
  }
5550
5704
  if (stat3.isDirectory()) {
5551
5705
  for (const child of readdirSync(entryPath)) {
5552
- visit(path8.join(entryPath, child));
5706
+ visit(path9.join(entryPath, child));
5553
5707
  }
5554
5708
  return;
5555
5709
  }
@@ -5582,18 +5736,18 @@ function isTruthyEnv(value) {
5582
5736
 
5583
5737
  // src/optional-bench.ts
5584
5738
  import { existsSync as existsSync3 } from "fs";
5585
- import path9 from "path";
5739
+ import path10 from "path";
5586
5740
  import { fileURLToPath as fileURLToPath3, pathToFileURL } from "url";
5587
5741
  var SPECIFIER2 = "@remnic/bench";
5588
5742
  var TSX_ESM_API_SPECIFIER = "tsx/esm/api";
5589
5743
  var cached2;
5590
5744
  var cachedFromLocalWorkspaceBenchSource = false;
5591
5745
  function resolveLocalWorkspaceBenchPaths() {
5592
- const currentDir = path9.dirname(fileURLToPath3(import.meta.url));
5593
- const benchPackageDir = path9.resolve(currentDir, "../../bench");
5746
+ const currentDir = path10.dirname(fileURLToPath3(import.meta.url));
5747
+ const benchPackageDir = path10.resolve(currentDir, "../../bench");
5594
5748
  return {
5595
- distEntry: path9.join(benchPackageDir, "dist", "index.js"),
5596
- sourceEntry: path9.join(benchPackageDir, "src", "index.ts")
5749
+ distEntry: path10.join(benchPackageDir, "dist", "index.js"),
5750
+ sourceEntry: path10.join(benchPackageDir, "src", "index.ts")
5597
5751
  };
5598
5752
  }
5599
5753
  async function tryImportLocalWorkspaceBenchSource(err) {
@@ -5730,7 +5884,7 @@ async function cmdSecurity(rest) {
5730
5884
 
5731
5885
  // src/daemon-service-candidates.ts
5732
5886
  import fs25 from "fs";
5733
- import path10 from "path";
5887
+ import path11 from "path";
5734
5888
  var LAUNCHD_LABEL = "ai.remnic.daemon";
5735
5889
  var LEGACY_REMNIC_SERVER_LAUNCHD_LABEL = "ai.remnic.server";
5736
5890
  var LEGACY_LAUNCHD_LABEL = "ai.engram.daemon";
@@ -5743,10 +5897,10 @@ var SYSTEMD_SERVICE = "remnic.service";
5743
5897
  var LEGACY_SYSTEMD_SERVICE = "engram.service";
5744
5898
  var SYSTEMD_SERVICE_CANDIDATES = [SYSTEMD_SERVICE, LEGACY_SYSTEMD_SERVICE];
5745
5899
  function launchdPlistPaths(homeDir) {
5746
- return LAUNCHD_LABEL_CANDIDATES.map((label) => path10.join(homeDir, "Library", "LaunchAgents", `${label}.plist`));
5900
+ return LAUNCHD_LABEL_CANDIDATES.map((label) => path11.join(homeDir, "Library", "LaunchAgents", `${label}.plist`));
5747
5901
  }
5748
5902
  function systemdUnitPaths(homeDir) {
5749
- return SYSTEMD_SERVICE_CANDIDATES.map((service) => path10.join(homeDir, ".config", "systemd", "user", service));
5903
+ return SYSTEMD_SERVICE_CANDIDATES.map((service) => path11.join(homeDir, ".config", "systemd", "user", service));
5750
5904
  }
5751
5905
  function anyFileExists(paths) {
5752
5906
  return paths.some((candidate) => {
@@ -5780,13 +5934,13 @@ function resolveShimNodeScript(filePath) {
5780
5934
  } catch {
5781
5935
  return void 0;
5782
5936
  }
5783
- const basedir = path10.dirname(filePath);
5937
+ const basedir = path11.dirname(filePath);
5784
5938
  const jsReferencePattern = /"([^"]+\.js)"|'([^']+\.js)'|([^\s"'`]+\.js)/g;
5785
5939
  for (const match of text.matchAll(jsReferencePattern)) {
5786
5940
  const raw = match[1] ?? match[2] ?? match[3];
5787
5941
  if (!raw) continue;
5788
5942
  const candidate = raw.replaceAll("${basedir}", basedir).replaceAll("$basedir", basedir).replaceAll("\\ ", " ");
5789
- const resolved = path10.isAbsolute(candidate) ? candidate : path10.resolve(basedir, candidate);
5943
+ const resolved = path11.isAbsolute(candidate) ? candidate : path11.resolve(basedir, candidate);
5790
5944
  try {
5791
5945
  if (fs25.statSync(resolved).isFile() && isRunnableNodeScript(resolved)) {
5792
5946
  return fs25.realpathSync(resolved);
@@ -5802,10 +5956,10 @@ function resolveRunnableNodeScript(filePath) {
5802
5956
  return resolveShimNodeScript(realPath);
5803
5957
  }
5804
5958
  function findCommandOnPath(command, pathEnv = process.env.PATH ?? "") {
5805
- for (const dir of pathEnv.split(path10.delimiter)) {
5959
+ for (const dir of pathEnv.split(path11.delimiter)) {
5806
5960
  if (!dir) continue;
5807
5961
  for (const name of commandNames(command)) {
5808
- const candidate = path10.join(dir, name);
5962
+ const candidate = path11.join(dir, name);
5809
5963
  try {
5810
5964
  const stat3 = fs25.statSync(candidate);
5811
5965
  if (!stat3.isFile()) continue;
@@ -5819,11 +5973,11 @@ function findCommandOnPath(command, pathEnv = process.env.PATH ?? "") {
5819
5973
  return void 0;
5820
5974
  }
5821
5975
  function serverBinWrapperRequiredPath(candidate) {
5822
- const filename = path10.basename(candidate);
5976
+ const filename = path11.basename(candidate);
5823
5977
  if (filename !== "remnic-server.js" && filename !== "engram-server.js") return void 0;
5824
- const binDir = path10.dirname(candidate);
5825
- if (path10.basename(binDir) !== "bin") return void 0;
5826
- return path10.join(path10.dirname(binDir), "dist", "index.js");
5978
+ const binDir = path11.dirname(candidate);
5979
+ if (path11.basename(binDir) !== "bin") return void 0;
5980
+ return path11.join(path11.dirname(binDir), "dist", "index.js");
5827
5981
  }
5828
5982
 
5829
5983
  // src/service-candidates.ts
@@ -5845,7 +5999,7 @@ function firstSuccessfulCandidate(candidates, attempt) {
5845
5999
  }
5846
6000
 
5847
6001
  // src/bench-args.ts
5848
- import path12 from "path";
6002
+ import path13 from "path";
5849
6003
 
5850
6004
  // src/bench-flags.ts
5851
6005
  function readBenchOptionValue(argv, flag) {
@@ -6210,7 +6364,7 @@ function collectBenchmarks(argv) {
6210
6364
  }
6211
6365
 
6212
6366
  // src/bench-args-research.ts
6213
- import path11 from "path";
6367
+ import path12 from "path";
6214
6368
  function readPositiveInteger(args, flag) {
6215
6369
  const raw = readBenchOptionValue(args, flag);
6216
6370
  if (raw === void 0) return void 0;
@@ -6256,7 +6410,7 @@ function parseBenchResearchArgs(action, args) {
6256
6410
  }
6257
6411
  const outRaw = readBenchOptionValue(args, "--out");
6258
6412
  if (outRaw !== void 0) {
6259
- out = path11.resolve(expandTilde(outRaw));
6413
+ out = path12.resolve(expandTilde(outRaw));
6260
6414
  }
6261
6415
  }
6262
6416
  const epochs = readPositiveInteger(args, "--epochs");
@@ -6270,8 +6424,8 @@ function parseBenchResearchArgs(action, args) {
6270
6424
  }
6271
6425
  return {
6272
6426
  runRef,
6273
- memoryDir: memoryDirRaw ? path11.resolve(expandTilde(memoryDirRaw)) : void 0,
6274
- qmdPath: qmdPathRaw ? path11.resolve(expandTilde(qmdPathRaw)) : void 0,
6427
+ memoryDir: memoryDirRaw ? path12.resolve(expandTilde(memoryDirRaw)) : void 0,
6428
+ qmdPath: qmdPathRaw ? path12.resolve(expandTilde(qmdPathRaw)) : void 0,
6275
6429
  collection,
6276
6430
  users: readPositiveInteger(args, "--users"),
6277
6431
  epochs,
@@ -6491,7 +6645,7 @@ function parseBenchArgs(argv) {
6491
6645
  }
6492
6646
  validateBenchFlags(action, args);
6493
6647
  const driftGenPositionals = action === "drift-gen" && driftGenAction === "validate" ? collectBenchmarks(args.slice(1)) : [];
6494
- const driftGenDir = driftGenPositionals[0] ? path12.resolve(expandTilde(driftGenPositionals[0])) : void 0;
6648
+ const driftGenDir = driftGenPositionals[0] ? path13.resolve(expandTilde(driftGenPositionals[0])) : void 0;
6495
6649
  const benchmarkArgs = action === "baseline" || action === "datasets" || action === "providers" || action === "runs" || action === "drift-gen" && (args[0] === "validate" || args[0] === "generate") ? args.slice(1) : args;
6496
6650
  const benchmarks = collectBenchmarks(benchmarkArgs);
6497
6651
  const datasetDir = readBenchOptionValue(args, "--dataset-dir") ?? readBenchOptionValue(args, "--dataset");
@@ -7041,13 +7195,13 @@ function parseBenchArgs(argv) {
7041
7195
  mcpUrl,
7042
7196
  mcpToolMap,
7043
7197
  mcpDemo,
7044
- datasetDir: datasetDir ? path12.resolve(expandTilde(datasetDir)) : void 0,
7045
- resultsDir: resultsDir ? path12.resolve(expandTilde(resultsDir)) : void 0,
7046
- baselinesDir: baselinesDir ? path12.resolve(expandTilde(baselinesDir)) : void 0,
7198
+ datasetDir: datasetDir ? path13.resolve(expandTilde(datasetDir)) : void 0,
7199
+ resultsDir: resultsDir ? path13.resolve(expandTilde(resultsDir)) : void 0,
7200
+ baselinesDir: baselinesDir ? path13.resolve(expandTilde(baselinesDir)) : void 0,
7047
7201
  runtimeProfile,
7048
7202
  matrixProfiles,
7049
- remnicConfigPath: remnicConfigRaw ? path12.resolve(expandTilde(remnicConfigRaw)) : void 0,
7050
- openclawConfigPath: openclawConfigRaw ? path12.resolve(expandTilde(openclawConfigRaw)) : void 0,
7203
+ remnicConfigPath: remnicConfigRaw ? path13.resolve(expandTilde(remnicConfigRaw)) : void 0,
7204
+ openclawConfigPath: openclawConfigRaw ? path13.resolve(expandTilde(openclawConfigRaw)) : void 0,
7051
7205
  modelSource,
7052
7206
  gatewayAgentId,
7053
7207
  fastGatewayAgentId,
@@ -7070,13 +7224,13 @@ function parseBenchArgs(argv) {
7070
7224
  internalDisableThinking: args.includes("--internal-disable-thinking"),
7071
7225
  internalCodexReasoningEffort,
7072
7226
  threshold,
7073
- custom: customRaw ? path12.resolve(expandTilde(customRaw)) : void 0,
7227
+ custom: customRaw ? path13.resolve(expandTilde(customRaw)) : void 0,
7074
7228
  baselineAction,
7075
7229
  datasetAction,
7076
7230
  providerAction,
7077
7231
  runAction,
7078
7232
  format,
7079
- output: output ? path12.resolve(expandTilde(output)) : void 0,
7233
+ output: output ? path13.resolve(expandTilde(output)) : void 0,
7080
7234
  target,
7081
7235
  publishedName,
7082
7236
  publishedSeed,
@@ -7086,24 +7240,24 @@ function parseBenchArgs(argv) {
7086
7240
  publishedIngestConcurrency,
7087
7241
  publishedTaskFilter,
7088
7242
  memcorrectAdapter,
7089
- publishedOut: publishedOutRaw ? path12.resolve(expandTilde(publishedOutRaw)) : void 0,
7243
+ publishedOut: publishedOutRaw ? path13.resolve(expandTilde(publishedOutRaw)) : void 0,
7090
7244
  publishedDryRun: args.includes("--dry-run"),
7091
7245
  requestTimeout,
7092
7246
  localJudgeRequestTimeout,
7093
7247
  frontierJudgeRequestTimeout,
7094
- calibrationDir: calibrationDirRaw ? path12.resolve(expandTilde(calibrationDirRaw)) : void 0,
7248
+ calibrationDir: calibrationDirRaw ? path13.resolve(expandTilde(calibrationDirRaw)) : void 0,
7095
7249
  calibrationLocalConfigSha256,
7096
7250
  calibrationFrontierConfigSha256,
7097
7251
  sourceResultId,
7098
7252
  expectedAnswerSetSha256,
7099
7253
  expectedQuestionIdListSha256,
7100
- taskIdsFile: taskIdsFileRaw ? path12.resolve(expandTilde(taskIdsFileRaw)) : void 0,
7254
+ taskIdsFile: taskIdsFileRaw ? path13.resolve(expandTilde(taskIdsFileRaw)) : void 0,
7101
7255
  expectedTaskIdListSha256,
7102
7256
  drainTimeout,
7103
7257
  // Issue #1573 PR1: surface judge-cache flags into the runner options.
7104
7258
  noJudgeCache: args.includes("--no-judge-cache"),
7105
- judgeCacheDir: judgeCacheDirRaw ? path12.resolve(expandTilde(judgeCacheDirRaw)) : void 0,
7106
- localLabManifestPath: localLabManifestRaw ? path12.resolve(expandTilde(localLabManifestRaw)) : void 0,
7259
+ judgeCacheDir: judgeCacheDirRaw ? path13.resolve(expandTilde(judgeCacheDirRaw)) : void 0,
7260
+ localLabManifestPath: localLabManifestRaw ? path13.resolve(expandTilde(localLabManifestRaw)) : void 0,
7107
7261
  max429WaitMs,
7108
7262
  disableThinking: args.includes("--disable-thinking"),
7109
7263
  amaBenchJudgeProtocol,
@@ -7140,23 +7294,23 @@ function assertCalibrationProvenanceMatches(binding, state, benchmarkId) {
7140
7294
  }
7141
7295
 
7142
7296
  // src/bench-status.ts
7143
- import { mkdir as mkdir2, readFile as readFile2, readdir as readdir3, rename as rename2, writeFile as writeFile2 } from "fs/promises";
7144
- import path13 from "path";
7297
+ import { mkdir as mkdir3, readFile as readFile3, readdir as readdir4, rename as rename2, writeFile as writeFile3 } from "fs/promises";
7298
+ import path14 from "path";
7145
7299
  function createBenchStatusPath(resultsDir, pid, startedAtMs = Date.now()) {
7146
- return path13.join(resultsDir, `bench-status-${startedAtMs}-${pid}.json`);
7300
+ return path14.join(resultsDir, `bench-status-${startedAtMs}-${pid}.json`);
7147
7301
  }
7148
7302
  var BENCH_STATUS_FILENAME = /^bench-status-\d+-\d+\.json$/;
7149
7303
  var VALID_BENCH_ENTRY_STATUSES = /* @__PURE__ */ new Set(["pending", "running", "complete", "failed"]);
7150
7304
  async function findLatestBenchStatusFile(resultsDir) {
7151
7305
  let entries;
7152
7306
  try {
7153
- entries = await readdir3(resultsDir);
7307
+ entries = await readdir4(resultsDir);
7154
7308
  } catch {
7155
7309
  return null;
7156
7310
  }
7157
7311
  const candidates = entries.filter((name) => BENCH_STATUS_FILENAME.test(name)).sort().reverse();
7158
7312
  for (const name of candidates) {
7159
- const filePath = path13.join(resultsDir, name);
7313
+ const filePath = path14.join(resultsDir, name);
7160
7314
  const status = await readBenchStatus(filePath);
7161
7315
  if (status) {
7162
7316
  return filePath;
@@ -7165,14 +7319,14 @@ async function findLatestBenchStatusFile(resultsDir) {
7165
7319
  return null;
7166
7320
  }
7167
7321
  async function atomicWriteJSON(filePath, data) {
7168
- await mkdir2(path13.dirname(filePath), { recursive: true });
7322
+ await mkdir3(path14.dirname(filePath), { recursive: true });
7169
7323
  const tmp = `${filePath}.${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`;
7170
- await writeFile2(tmp, JSON.stringify(data, null, 2) + "\n");
7324
+ await writeFile3(tmp, JSON.stringify(data, null, 2) + "\n");
7171
7325
  await rename2(tmp, filePath);
7172
7326
  }
7173
7327
  async function readBenchStatus(filePath) {
7174
7328
  try {
7175
- const raw = await readFile2(filePath, "utf-8");
7329
+ const raw = await readFile3(filePath, "utf-8");
7176
7330
  const parsed = JSON.parse(raw);
7177
7331
  if (typeof parsed !== "object" || parsed === null) return null;
7178
7332
  const obj = parsed;
@@ -7283,13 +7437,13 @@ function finalizeBenchStatus(filePath) {
7283
7437
 
7284
7438
  // src/openclaw-upgrade-swap.ts
7285
7439
  import fs26 from "fs";
7286
- import path14 from "path";
7440
+ import path15 from "path";
7287
7441
  function describeError(error) {
7288
7442
  return error instanceof Error ? error.message : String(error);
7289
7443
  }
7290
7444
  function createSiblingTempFilePath(targetPath, label) {
7291
7445
  const nonce = `${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2, 10)}`;
7292
- return path14.join(path14.dirname(targetPath), `.${path14.basename(targetPath)}.${label}.${nonce}.tmp`);
7446
+ return path15.join(path15.dirname(targetPath), `.${path15.basename(targetPath)}.${label}.${nonce}.tmp`);
7293
7447
  }
7294
7448
  function resolveAtomicWriteMode(targetPath, explicitMode) {
7295
7449
  if (explicitMode !== void 0) return explicitMode;
@@ -7317,7 +7471,7 @@ function resolveAtomicReplacementPath(targetPath) {
7317
7471
  }
7318
7472
  function createSiblingSwapPath(targetDir, label) {
7319
7473
  const nonce = `${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2, 10)}`;
7320
- return path14.join(path14.dirname(targetDir), `.${path14.basename(targetDir)}.${label}.${nonce}`);
7474
+ return path15.join(path15.dirname(targetDir), `.${path15.basename(targetDir)}.${label}.${nonce}`);
7321
7475
  }
7322
7476
  function cleanupDisplacedDirectoryBestEffort(displacedDir, context) {
7323
7477
  if (!displacedDir) return void 0;
@@ -7330,7 +7484,7 @@ function cleanupDisplacedDirectoryBestEffort(displacedDir, context) {
7330
7484
  }
7331
7485
  function atomicWriteFileSync(targetPath, data, options = {}) {
7332
7486
  const resolvedTargetPath = resolveAtomicReplacementPath(targetPath);
7333
- fs26.mkdirSync(path14.dirname(resolvedTargetPath), { recursive: true });
7487
+ fs26.mkdirSync(path15.dirname(resolvedTargetPath), { recursive: true });
7334
7488
  const tempPath = createSiblingTempFilePath(resolvedTargetPath, "write");
7335
7489
  const mode = resolveAtomicWriteMode(resolvedTargetPath, options.mode);
7336
7490
  try {
@@ -7350,7 +7504,7 @@ function atomicWriteFileSync(targetPath, data, options = {}) {
7350
7504
  function atomicCopyFileSync(sourcePath, targetPath, options = {}) {
7351
7505
  if (!fs26.existsSync(sourcePath)) return;
7352
7506
  const resolvedTargetPath = resolveAtomicReplacementPath(targetPath);
7353
- fs26.mkdirSync(path14.dirname(resolvedTargetPath), { recursive: true });
7507
+ fs26.mkdirSync(path15.dirname(resolvedTargetPath), { recursive: true });
7354
7508
  const tempPath = createSiblingTempFilePath(resolvedTargetPath, "copy");
7355
7509
  const mode = fs26.statSync(sourcePath).mode & 4095;
7356
7510
  try {
@@ -7381,7 +7535,7 @@ function restoreDirectoryFromRollback(targetDir, rollbackDir) {
7381
7535
  if (!fs26.existsSync(rollbackDir)) {
7382
7536
  throw new Error(`Rollback directory is missing: ${rollbackDir}`);
7383
7537
  }
7384
- fs26.mkdirSync(path14.dirname(targetDir), { recursive: true });
7538
+ fs26.mkdirSync(path15.dirname(targetDir), { recursive: true });
7385
7539
  const displacedDir = fs26.existsSync(targetDir) ? createSiblingSwapPath(targetDir, "rollback-restore") : void 0;
7386
7540
  if (displacedDir) {
7387
7541
  fs26.renameSync(targetDir, displacedDir);
@@ -7410,7 +7564,7 @@ function restoreDirectoryFromBackup(targetDir, backupDir) {
7410
7564
  if (!fs26.existsSync(backupDir)) {
7411
7565
  throw new Error(`Plugin backup directory is missing: ${backupDir}`);
7412
7566
  }
7413
- fs26.mkdirSync(path14.dirname(targetDir), { recursive: true });
7567
+ fs26.mkdirSync(path15.dirname(targetDir), { recursive: true });
7414
7568
  const stagedDir = createSiblingSwapPath(targetDir, "backup-restore");
7415
7569
  const displacedDir = fs26.existsSync(targetDir) ? createSiblingSwapPath(targetDir, "pre-backup-restore") : void 0;
7416
7570
  fs26.cpSync(backupDir, stagedDir, { recursive: true });
@@ -7551,7 +7705,7 @@ Run this manually when you're ready:
7551
7705
  import { execFileSync } from "child_process";
7552
7706
  import fs27 from "fs";
7553
7707
  import os from "os";
7554
- import path15 from "path";
7708
+ import path16 from "path";
7555
7709
  import { fileURLToPath as fileURLToPath4, pathToFileURL as pathToFileURL2 } from "url";
7556
7710
  var MANAGED_UPGRADE_SPECIFIER = "@remnic/plugin-openclaw/managed-upgrade";
7557
7711
  var OPENCLAW_PLUGIN_PACKAGE = "@remnic/plugin-openclaw";
@@ -7623,8 +7777,8 @@ function buildOpenclawManagedUpgradePackageSpec(version = "latest") {
7623
7777
  return `${OPENCLAW_PLUGIN_PACKAGE}@${version}`;
7624
7778
  }
7625
7779
  function readCliAdapterRange() {
7626
- const moduleDir = path15.dirname(fileURLToPath4(import.meta.url));
7627
- const manifestPath = path15.resolve(moduleDir, "../package.json");
7780
+ const moduleDir = path16.dirname(fileURLToPath4(import.meta.url));
7781
+ const manifestPath = path16.resolve(moduleDir, "../package.json");
7628
7782
  const manifest = JSON.parse(fs27.readFileSync(manifestPath, "utf8"));
7629
7783
  if (manifest.name !== "@remnic/cli") {
7630
7784
  throw new Error(`Invalid @remnic/cli package manifest at ${manifestPath}.`);
@@ -7669,7 +7823,7 @@ async function loadOpenclawManagedUpgradeModule(packageSpec, hooks = {}) {
7669
7823
  const adapterMissing = isSpecifierNotFoundError(error, OPENCLAW_PLUGIN_PACKAGE) || isSpecifierNotFoundError(error, MANAGED_UPGRADE_SPECIFIER) || isManagedUpgradeSubpathMissing(error);
7670
7824
  if (!adapterMissing) throw error;
7671
7825
  }
7672
- const temporaryRoot = fs27.mkdtempSync(path15.join(os.tmpdir(), "remnic-openclaw-upgrade-"));
7826
+ const temporaryRoot = fs27.mkdtempSync(path16.join(os.tmpdir(), "remnic-openclaw-upgrade-"));
7673
7827
  try {
7674
7828
  const toolingPackageSpec = `${OPENCLAW_PLUGIN_PACKAGE}@${readCliAdapterRange()}`;
7675
7829
  const installArgs = [
@@ -7683,7 +7837,7 @@ async function loadOpenclawManagedUpgradeModule(packageSpec, hooks = {}) {
7683
7837
  toolingPackageSpec
7684
7838
  ];
7685
7839
  (hooks.runNpmInstall ?? runNpmInstall)(installArgs);
7686
- const resolverPath = path15.join(temporaryRoot, "load-managed-upgrade.mjs");
7840
+ const resolverPath = path16.join(temporaryRoot, "load-managed-upgrade.mjs");
7687
7841
  fs27.writeFileSync(resolverPath, `export * from ${JSON.stringify(MANAGED_UPGRADE_SPECIFIER)};
7688
7842
  `, "utf8");
7689
7843
  return await importModule(pathToFileURL2(resolverPath).href);
@@ -7699,9 +7853,9 @@ async function loadOpenclawManagedUpgradeModule(packageSpec, hooks = {}) {
7699
7853
 
7700
7854
  // src/report.ts
7701
7855
  import { existsSync as existsSync4, mkdirSync, readFileSync as readFileSync4, readdirSync as readdirSync2, statSync as statSync2, writeFileSync } from "fs";
7702
- import { readFile as readFile3 } from "fs/promises";
7856
+ import { readFile as readFile4 } from "fs/promises";
7703
7857
  import os2 from "os";
7704
- import path16 from "path";
7858
+ import path17 from "path";
7705
7859
  var REPORT_ALLOWED_CONFIG_FIELDS = Object.freeze([
7706
7860
  "qmdEnabled",
7707
7861
  "qmdAutoEmbedEnabled",
@@ -7752,7 +7906,7 @@ function countMemories(dir) {
7752
7906
  let count = 0;
7753
7907
  const walk = (d) => {
7754
7908
  for (const entry of readdirSync2(d)) {
7755
- const full = path16.join(d, entry);
7909
+ const full = path17.join(d, entry);
7756
7910
  const st = statSync2(full);
7757
7911
  if (st.isDirectory()) walk(full);
7758
7912
  else if (entry.endsWith(".md")) count++;
@@ -7766,9 +7920,9 @@ function countMemories(dir) {
7766
7920
  }
7767
7921
  function findConfigPath() {
7768
7922
  const candidates = [
7769
- path16.join(os2.homedir(), ".config", "remnic", "config.json"),
7770
- path16.join(os2.homedir(), ".config", "openclaw", "openclaw.json"),
7771
- path16.join(os2.homedir(), ".openclaw", "config.json")
7923
+ path17.join(os2.homedir(), ".config", "remnic", "config.json"),
7924
+ path17.join(os2.homedir(), ".config", "openclaw", "openclaw.json"),
7925
+ path17.join(os2.homedir(), ".openclaw", "config.json")
7772
7926
  ];
7773
7927
  for (const p of candidates) {
7774
7928
  if (existsSync4(p)) return p;
@@ -7784,7 +7938,7 @@ function findMemoryDir(configPath) {
7784
7938
  } catch {
7785
7939
  }
7786
7940
  }
7787
- return path16.join(os2.homedir(), ".remnic", "memory");
7941
+ return path17.join(os2.homedir(), ".remnic", "memory");
7788
7942
  }
7789
7943
  function extractConfigShape(rawConfig) {
7790
7944
  const result = {};
@@ -7813,7 +7967,7 @@ function runDoctorChecks() {
7813
7967
  } catch {
7814
7968
  checks.push({ name: "Memory directory", ok: false });
7815
7969
  }
7816
- const openclawPath = path16.join(os2.homedir(), ".config", "openclaw", "openclaw.json");
7970
+ const openclawPath = path17.join(os2.homedir(), ".config", "openclaw", "openclaw.json");
7817
7971
  checks.push({ name: "OpenClaw config file", ok: existsSync4(openclawPath) });
7818
7972
  return checks;
7819
7973
  }
@@ -7895,9 +8049,9 @@ function summarizeBenchScorecard(raw) {
7895
8049
  function readOwn(source, key) {
7896
8050
  return Object.hasOwn(source, key) ? source[key] : void 0;
7897
8051
  }
7898
- function readNested(source, ...path24) {
8052
+ function readNested(source, ...path25) {
7899
8053
  let current = source;
7900
- for (const key of path24) {
8054
+ for (const key of path25) {
7901
8055
  if (typeof current !== "object" || current === null) return void 0;
7902
8056
  if (!Object.hasOwn(current, key)) return void 0;
7903
8057
  current = current[key];
@@ -7960,9 +8114,9 @@ async function buildReport(options = {}) {
7960
8114
  const sizeBucketLabel = sizeBucket(storeBytes);
7961
8115
  let benchScorecard;
7962
8116
  if (options.includeBench) {
7963
- const scorecardPath = path16.join(os2.homedir(), ".remnic", "reports", "bench-scorecard.json");
8117
+ const scorecardPath = path17.join(os2.homedir(), ".remnic", "reports", "bench-scorecard.json");
7964
8118
  try {
7965
- const raw = JSON.parse(await readFile3(scorecardPath, "utf-8"));
8119
+ const raw = JSON.parse(await readFile4(scorecardPath, "utf-8"));
7966
8120
  benchScorecard = summarizeBenchScorecard(raw);
7967
8121
  } catch {
7968
8122
  }
@@ -8022,12 +8176,12 @@ function renderReportJson(report) {
8022
8176
  return JSON.stringify(report, null, 2);
8023
8177
  }
8024
8178
  async function cmdReport(options = {}) {
8025
- const reportDir = path16.join(os2.homedir(), ".remnic", "reports");
8179
+ const reportDir = path17.join(os2.homedir(), ".remnic", "reports");
8026
8180
  mkdirSync(reportDir, { recursive: true });
8027
8181
  const report = await buildReport({ includeBench: options.includeBench });
8028
8182
  const dateStr = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10).replace(/-/g, "");
8029
- const mdPath = path16.join(reportDir, `report-${dateStr}.md`);
8030
- const jsonPath = path16.join(reportDir, `report-${dateStr}.json`);
8183
+ const mdPath = path17.join(reportDir, `report-${dateStr}.md`);
8184
+ const jsonPath = path17.join(reportDir, `report-${dateStr}.json`);
8031
8185
  const md = renderReportMarkdown(report);
8032
8186
  const json = renderReportJson(report);
8033
8187
  writeFileSync(mdPath, md, "utf-8");
@@ -8149,13 +8303,13 @@ function resolveRemoteDaemon(configPath) {
8149
8303
  function resolveHostedOnlyDaemonRefusal(configPath) {
8150
8304
  const remoteUrl = resolveRemoteDaemonUrl(configPath);
8151
8305
  if (!remoteUrl) return void 0;
8152
- let hostname;
8306
+ let hostname2;
8153
8307
  try {
8154
- hostname = new URL(remoteUrl).hostname;
8308
+ hostname2 = new URL(remoteUrl).hostname;
8155
8309
  } catch {
8156
8310
  return void 0;
8157
8311
  }
8158
- if (isLoopbackHost(hostname)) return void 0;
8312
+ if (isLoopbackHost(hostname2)) return void 0;
8159
8313
  return { remoteUrl };
8160
8314
  }
8161
8315
  function hostedOnlyDaemonRefusalMessage(remoteUrl, action) {
@@ -8346,10 +8500,10 @@ async function remoteRecallWhy(daemon, request) {
8346
8500
 
8347
8501
  // src/daemon-service.ts
8348
8502
  import fs29 from "fs";
8349
- import path17 from "path";
8503
+ import path18 from "path";
8350
8504
  import * as childProcess from "child_process";
8351
8505
  import { fileURLToPath as fileURLToPath5 } from "url";
8352
- var thisModuleDir = path17.dirname(fileURLToPath5(import.meta.url));
8506
+ var thisModuleDir = path18.dirname(fileURLToPath5(import.meta.url));
8353
8507
  function launchdLoadPlist(plistPath, processApi = childProcess) {
8354
8508
  processApi.execFileSync("launchctl", ["load", "-w", plistPath], { stdio: "pipe" });
8355
8509
  }
@@ -8371,8 +8525,8 @@ function resolveServerBinDetails(options = {}) {
8371
8525
  });
8372
8526
  } catch {
8373
8527
  }
8374
- const workspaceServerBin = path17.resolve(moduleDir, "../../remnic-server/bin/remnic-server.js");
8375
- const workspaceDistIndex = path17.resolve(moduleDir, "../../remnic-server/dist/index.js");
8528
+ const workspaceServerBin = path18.resolve(moduleDir, "../../remnic-server/bin/remnic-server.js");
8529
+ const workspaceDistIndex = path18.resolve(moduleDir, "../../remnic-server/dist/index.js");
8376
8530
  candidates.push(
8377
8531
  {
8378
8532
  path: workspaceServerBin,
@@ -8393,11 +8547,11 @@ function resolveServerBinDetails(options = {}) {
8393
8547
  });
8394
8548
  }
8395
8549
  candidates.push({
8396
- path: path17.resolve(moduleDir, "../../remnic-server/src/index.ts"),
8550
+ path: path18.resolve(moduleDir, "../../remnic-server/src/index.ts"),
8397
8551
  source: "workspace-source"
8398
8552
  });
8399
8553
  const selected = candidates.find((candidate) => isCandidateReady(candidate, existsSync5)) ?? candidates.find((candidate) => existsSync5(candidate.path)) ?? candidates[0] ?? {
8400
- path: path17.resolve(moduleDir, "../../remnic-server/dist/index.js"),
8554
+ path: path18.resolve(moduleDir, "../../remnic-server/dist/index.js"),
8401
8555
  source: "workspace-dist"
8402
8556
  };
8403
8557
  const exists = existsSync5(selected.path);
@@ -8452,7 +8606,7 @@ function readVerifiedDaemonPid(options) {
8452
8606
  }
8453
8607
  function doesProcessCommandLookLikeRemnicDaemon(command, expectedServerBin) {
8454
8608
  const normalizedCommand = command.trim();
8455
- const normalizedExpected = path17.resolve(expandTilde(expectedServerBin));
8609
+ const normalizedExpected = path18.resolve(expandTilde(expectedServerBin));
8456
8610
  return normalizedCommand.includes(normalizedExpected) || /(?:^|\s|[/\\])(?:remnic-server|engram-server)(?:\.js)?(?:\s|$)/.test(normalizedCommand) || /@remnic[/\\]server[/\\]/.test(normalizedCommand) || /packages[/\\]remnic-server[/\\](?:bin[/\\]remnic-server\.js|dist[/\\]index\.js|src[/\\]index\.ts)/.test(normalizedCommand);
8457
8611
  }
8458
8612
  function parseDaemonPid(raw) {
@@ -8557,7 +8711,7 @@ function inspectLaunchdPlist(plistPath, options = {}) {
8557
8711
  };
8558
8712
  }
8559
8713
  const expandedServerArg = expandTilde(serverArg);
8560
- if (!path17.isAbsolute(expandedServerArg)) {
8714
+ if (!path18.isAbsolute(expandedServerArg)) {
8561
8715
  return {
8562
8716
  installed: true,
8563
8717
  ok: false,
@@ -8629,8 +8783,8 @@ function normalizeResolvedPath(resolved) {
8629
8783
  return resolved;
8630
8784
  }
8631
8785
  function packageServerBinFromEntry(packageEntry) {
8632
- if (path17.basename(packageEntry) === "index.js" && path17.basename(path17.dirname(packageEntry)) === "dist") {
8633
- return path17.join(path17.dirname(path17.dirname(packageEntry)), "bin", "remnic-server.js");
8786
+ if (path18.basename(packageEntry) === "index.js" && path18.basename(path18.dirname(packageEntry)) === "dist") {
8787
+ return path18.join(path18.dirname(path18.dirname(packageEntry)), "bin", "remnic-server.js");
8634
8788
  }
8635
8789
  return packageEntry;
8636
8790
  }
@@ -8705,9 +8859,9 @@ import {
8705
8859
 
8706
8860
  // src/import-bundle-detect.ts
8707
8861
  import { lstatSync as lstatSync3, readdirSync as readdirSync3, readFileSync as readFileSync5 } from "fs";
8708
- import path18 from "path";
8862
+ import path19 from "path";
8709
8863
  function detectBundleEntries(bundleDir, options = {}) {
8710
- const readdir4 = options.readdirImpl ?? defaultReaddir;
8864
+ const readdir5 = options.readdirImpl ?? defaultReaddir;
8711
8865
  const readFileImpl = options.readFileImpl ?? defaultReadFile;
8712
8866
  const isDirectory2 = options.isDirectoryImpl ?? defaultIsDirectory;
8713
8867
  const isRegularFile = options.isRegularFileImpl ?? (options.readdirImpl !== void 0 || options.isDirectoryImpl !== void 0 ? (p) => !isDirectory2(p) : defaultIsRegularFile);
@@ -8727,7 +8881,7 @@ function detectBundleEntries(bundleDir, options = {}) {
8727
8881
  }
8728
8882
  const roots = collectCandidatePaths(
8729
8883
  bundleDir,
8730
- readdir4,
8884
+ readdir5,
8731
8885
  isDirectory2,
8732
8886
  isRegularFile
8733
8887
  );
@@ -8736,7 +8890,7 @@ function detectBundleEntries(bundleDir, options = {}) {
8736
8890
  for (const filePath of roots) {
8737
8891
  if (seenFiles.has(filePath)) continue;
8738
8892
  seenFiles.add(filePath);
8739
- const name = path18.basename(filePath);
8893
+ const name = path19.basename(filePath);
8740
8894
  const match = classifyFile(name, filePath, readFileImpl);
8741
8895
  if (match) entries.push(match);
8742
8896
  }
@@ -8756,9 +8910,9 @@ function detectBundleEntries(bundleDir, options = {}) {
8756
8910
  return entries;
8757
8911
  }
8758
8912
  var MAX_WALK_DEPTH = 4;
8759
- function collectCandidatePaths(root, readdir4, isDirectory2, isRegularFile) {
8913
+ function collectCandidatePaths(root, readdir5, isDirectory2, isRegularFile) {
8760
8914
  try {
8761
- readdir4(root);
8915
+ readdir5(root);
8762
8916
  } catch {
8763
8917
  throw new Error(
8764
8918
  `Bundle directory '${root}' could not be read. Pass an existing directory.`
@@ -8769,12 +8923,12 @@ function collectCandidatePaths(root, readdir4, isDirectory2, isRegularFile) {
8769
8923
  if (depth > MAX_WALK_DEPTH) return;
8770
8924
  let entries;
8771
8925
  try {
8772
- entries = readdir4(dir);
8926
+ entries = readdir5(dir);
8773
8927
  } catch {
8774
8928
  return;
8775
8929
  }
8776
8930
  for (const entry of entries) {
8777
- const full = path18.join(dir, entry);
8931
+ const full = path19.join(dir, entry);
8778
8932
  if (isDirectory2(full)) {
8779
8933
  walk(full, depth + 1);
8780
8934
  } else if (isRegularFile(full)) {
@@ -9330,7 +9484,7 @@ async function cmdCapture(rest, io) {
9330
9484
 
9331
9485
  // src/import-lossless-claw-cmd.ts
9332
9486
  import fs31 from "fs";
9333
- import path19 from "path";
9487
+ import path20 from "path";
9334
9488
  import {
9335
9489
  applyLcmSchema,
9336
9490
  ensureLcmStateDir,
@@ -9480,7 +9634,7 @@ async function cmdImportLosslessClaw(argv, io, deps = {}) {
9480
9634
  let destDb;
9481
9635
  try {
9482
9636
  if (parsed.dryRun) {
9483
- const lcmPath = path19.join(memoryDir, "state", "lcm.sqlite");
9637
+ const lcmPath = path20.join(memoryDir, "state", "lcm.sqlite");
9484
9638
  if (fs31.existsSync(lcmPath)) {
9485
9639
  destDb = mod.openExistingLcmDatabaseReadOnly(lcmPath);
9486
9640
  } else {
@@ -9600,9 +9754,9 @@ function printBenchComparisonSummary(comparison, baseline, candidate) {
9600
9754
  }
9601
9755
 
9602
9756
  // src/bench-coding-commands.ts
9603
- import { lstat as lstat3, readFile as readFile4, realpath as realpath2, stat as stat2 } from "fs/promises";
9757
+ import { lstat as lstat4, readFile as readFile5, realpath as realpath2, stat as stat2 } from "fs/promises";
9604
9758
  import os3 from "os";
9605
- import path20 from "path";
9759
+ import path21 from "path";
9606
9760
  var UINT32_MAX = 4294967295;
9607
9761
  var FROZEN_GENERATOR_SEED = 81;
9608
9762
  var FROZEN_TASK_COUNT = 30;
@@ -9612,7 +9766,7 @@ var FROZEN_MAX_STEPS = 12;
9612
9766
  var FROZEN_MAX_TOOL_CALLS = 8;
9613
9767
  var FROZEN_MAX_OUTPUT_CHARS = 16384;
9614
9768
  var MAX_OUTPUT_BYTES = 16384;
9615
- var DEFAULT_REPEATED_FAILURE_OUTPUT_DIR = path20.join(
9769
+ var DEFAULT_REPEATED_FAILURE_OUTPUT_DIR = path21.join(
9616
9770
  resolveHomeDir(),
9617
9771
  ".remnic",
9618
9772
  "bench",
@@ -9946,7 +10100,7 @@ function parseBenchCodingArgs(args) {
9946
10100
  throw new Error(`unknown bench coding subcommand ${args[0]}`);
9947
10101
  }
9948
10102
  function normalizeCommandPaths(command) {
9949
- const resolve3 = (value) => path20.resolve(expandTilde(value));
10103
+ const resolve3 = (value) => path21.resolve(expandTilde(value));
9950
10104
  if (command.kind === "repo-generate") {
9951
10105
  return { ...command, outputDir: resolve3(command.outputDir) };
9952
10106
  }
@@ -9977,27 +10131,27 @@ function normalizeCommandPaths(command) {
9977
10131
  return command;
9978
10132
  }
9979
10133
  async function canonicalProspectivePath(value) {
9980
- let candidate = path20.resolve(value);
10134
+ let candidate = path21.resolve(value);
9981
10135
  const missingSegments = [];
9982
10136
  while (true) {
9983
10137
  try {
9984
- return path20.join(await realpath2(candidate), ...missingSegments.reverse());
10138
+ return path21.join(await realpath2(candidate), ...missingSegments.reverse());
9985
10139
  } catch (error) {
9986
10140
  if (error.code !== "ENOENT") throw error;
9987
- const parent = path20.dirname(candidate);
10141
+ const parent = path21.dirname(candidate);
9988
10142
  if (parent === candidate) throw error;
9989
- missingSegments.push(path20.basename(candidate));
10143
+ missingSegments.push(path21.basename(candidate));
9990
10144
  candidate = parent;
9991
10145
  }
9992
10146
  }
9993
10147
  }
9994
10148
  function isSameOrDescendant(candidate, root) {
9995
- const relative2 = path20.relative(root, candidate);
9996
- return relative2 === "" || relative2 !== ".." && !relative2.startsWith(`..${path20.sep}`) && !path20.isAbsolute(relative2);
10149
+ const relative2 = path21.relative(root, candidate);
10150
+ return relative2 === "" || relative2 !== ".." && !relative2.startsWith(`..${path21.sep}`) && !path21.isAbsolute(relative2);
9997
10151
  }
9998
10152
  async function pathExists(value) {
9999
10153
  try {
10000
- await lstat3(value);
10154
+ await lstat4(value);
10001
10155
  return true;
10002
10156
  } catch (error) {
10003
10157
  if (error.code === "ENOENT") return false;
@@ -10012,7 +10166,7 @@ async function assertSafeBenchmarkOutput(outputDir) {
10012
10166
  const configured = process.env[variable]?.trim();
10013
10167
  if (!configured) continue;
10014
10168
  const memoryRoot = await canonicalProspectivePath(
10015
- path20.resolve(expandTilde(configured))
10169
+ path21.resolve(expandTilde(configured))
10016
10170
  );
10017
10171
  if (isSameOrDescendant(canonicalOutput, memoryRoot)) {
10018
10172
  throw new Error(refusal);
@@ -10020,10 +10174,10 @@ async function assertSafeBenchmarkOutput(outputDir) {
10020
10174
  }
10021
10175
  let candidate = canonicalOutput;
10022
10176
  while (true) {
10023
- const hasProfile = await pathExists(path20.join(candidate, "profile.md"));
10024
- const hasMemoryData = await pathExists(path20.join(candidate, "facts")) || await pathExists(path20.join(candidate, "entities")) || await pathExists(path20.join(candidate, "state"));
10177
+ const hasProfile = await pathExists(path21.join(candidate, "profile.md"));
10178
+ const hasMemoryData = await pathExists(path21.join(candidate, "facts")) || await pathExists(path21.join(candidate, "entities")) || await pathExists(path21.join(candidate, "state"));
10025
10179
  if (hasProfile && hasMemoryData) throw new Error(refusal);
10026
- const parent = path20.dirname(candidate);
10180
+ const parent = path21.dirname(candidate);
10027
10181
  if (parent === candidate) break;
10028
10182
  candidate = parent;
10029
10183
  }
@@ -10035,7 +10189,7 @@ async function assertSafeBenchmarkOutput(outputDir) {
10035
10189
  async function assertH6StatsRunDirectory(runDir, commandName = "stats") {
10036
10190
  try {
10037
10191
  const parsed = JSON.parse(
10038
- await readFile4(path20.join(runDir, "run.json"), "utf8")
10192
+ await readFile5(path21.join(runDir, "run.json"), "utf8")
10039
10193
  );
10040
10194
  if (parsed.schemaVersion !== 1 || typeof parsed.runId !== "string" || parsed.runId.length === 0 || typeof parsed.suiteVersion !== "string" || !parsed.suiteVersion.startsWith("h6-failure-gate-v1-")) {
10041
10195
  throw new Error("invalid H6 metadata");
@@ -10094,7 +10248,7 @@ async function runRepoVerification(command, bench) {
10094
10248
  if (command.directory === void 0) {
10095
10249
  dataset = await requireFunction(bench, "loadCommittedH6BenchmarkDataset")();
10096
10250
  } else {
10097
- const serialized = await readFile4(path20.join(command.directory, "dataset.json"), "utf8").catch(
10251
+ const serialized = await readFile5(path21.join(command.directory, "dataset.json"), "utf8").catch(
10098
10252
  () => void 0
10099
10253
  );
10100
10254
  if (serialized === void 0) {
@@ -10222,8 +10376,8 @@ async function cmdBenchCoding(args) {
10222
10376
  }
10223
10377
 
10224
10378
  // src/bench-security-commands.ts
10225
- import path21 from "path";
10226
- var DEFAULT_OUTPUT_DIR = path21.join(
10379
+ import path22 from "path";
10380
+ var DEFAULT_OUTPUT_DIR = path22.join(
10227
10381
  resolveHomeDir(),
10228
10382
  ".remnic",
10229
10383
  "bench",
@@ -10706,7 +10860,7 @@ ${BENCH_SECURITY_USAGE}`);
10706
10860
  }
10707
10861
 
10708
10862
  // src/bench-research-commands.ts
10709
- import path22 from "path";
10863
+ import path23 from "path";
10710
10864
  function emit(result) {
10711
10865
  if (result.output) {
10712
10866
  console.log(result.output);
@@ -10724,7 +10878,7 @@ async function runBenchResearchCommand(parsed) {
10724
10878
  emit(
10725
10879
  await runAttributeCliCommand({
10726
10880
  runRef: parsed.runRef,
10727
- resultsDir: parsed.resultsDir ?? path22.join(resolveHomeDir(), ".remnic", "bench", "results"),
10881
+ resultsDir: parsed.resultsDir ?? path23.join(resolveHomeDir(), ".remnic", "bench", "results"),
10728
10882
  memoryDir: parsed.memoryDir,
10729
10883
  qmdPath: parsed.qmdPath,
10730
10884
  collection: parsed.collection,
@@ -10954,6 +11108,7 @@ Examples:
10954
11108
  }
10955
11109
 
10956
11110
  // src/index.ts
11111
+ import { divergedEmbeddingGenerationDeferrals as divergedEmbeddingGenerationDeferrals2 } from "@remnic/core";
10957
11112
  var LazyPluginPiPublisher = class {
10958
11113
  constructor(hostId, select) {
10959
11114
  this.hostId = hostId;
@@ -10994,14 +11149,14 @@ registerPublisher("hermes", () => new HermesMemoryExtensionPublisher());
10994
11149
  registerPublisher("pi", () => new LazyPluginPiPublisher("pi", (mod) => mod.PiMemoryExtensionPublisher));
10995
11150
  registerPublisher("omp", () => new LazyPluginPiPublisher("omp", (mod) => mod.OmpMemoryExtensionPublisher));
10996
11151
  registerPublisher("prime-agent", () => new LazyPluginPiPublisher("prime-agent", (mod) => mod.PrimeAgentMemoryExtensionPublisher));
10997
- var PID_DIR = path23.join(resolveHomeDir(), ".remnic");
10998
- var LEGACY_PID_DIR = path23.join(resolveHomeDir(), ".engram");
10999
- var PID_FILE = path23.join(PID_DIR, "server.pid");
11000
- var LEGACY_PID_FILE = path23.join(LEGACY_PID_DIR, "server.pid");
11001
- var LOG_FILE = path23.join(PID_DIR, "server.log");
11002
- var LEGACY_LOG_FILE = path23.join(LEGACY_PID_DIR, "server.log");
11003
- var CLI_MODULE_DIR = path23.dirname(fileURLToPath6(import.meta.url));
11004
- var CLI_REPO_ROOT2 = path23.resolve(CLI_MODULE_DIR, "../../..");
11152
+ var PID_DIR = path24.join(resolveHomeDir(), ".remnic");
11153
+ var LEGACY_PID_DIR = path24.join(resolveHomeDir(), ".engram");
11154
+ var PID_FILE = path24.join(PID_DIR, "server.pid");
11155
+ var LEGACY_PID_FILE = path24.join(LEGACY_PID_DIR, "server.pid");
11156
+ var LOG_FILE = path24.join(PID_DIR, "server.log");
11157
+ var LEGACY_LOG_FILE = path24.join(LEGACY_PID_DIR, "server.log");
11158
+ var CLI_MODULE_DIR = path24.dirname(fileURLToPath6(import.meta.url));
11159
+ var CLI_REPO_ROOT2 = path24.resolve(CLI_MODULE_DIR, "../../..");
11005
11160
  var OPENCLAW_GATEWAY_LABEL = "ai.openclaw.gateway";
11006
11161
  var CLI_SUCCESS_EXIT_GRACE_MS = 5e3;
11007
11162
  var CLI_OUTPUT_FLUSH_GRACE_MS = 250;
@@ -11180,12 +11335,12 @@ async function resolveKnownBenchmarkIds() {
11180
11335
  return knownIds;
11181
11336
  }
11182
11337
  function resolveBenchOutputDir() {
11183
- return path23.join(resolveHomeDir(), ".remnic", "bench", "results");
11338
+ return path24.join(resolveHomeDir(), ".remnic", "bench", "results");
11184
11339
  }
11185
11340
  async function launchBenchUi(resultsDir) {
11186
- const benchUiDir = path23.join(CLI_REPO_ROOT2, "packages", "bench-ui");
11341
+ const benchUiDir = path24.join(CLI_REPO_ROOT2, "packages", "bench-ui");
11187
11342
  const pnpmCmd = process.platform === "win32" ? "pnpm.cmd" : "pnpm";
11188
- if (!fs32.existsSync(path23.join(benchUiDir, "package.json"))) {
11343
+ if (!fs32.existsSync(path24.join(benchUiDir, "package.json"))) {
11189
11344
  console.error("ERROR: @remnic/bench-ui is not available in this checkout.");
11190
11345
  process.exit(1);
11191
11346
  }
@@ -11212,11 +11367,11 @@ async function launchBenchUi(resultsDir) {
11212
11367
  });
11213
11368
  }
11214
11369
  function resolveDatasetDownloadScriptPath() {
11215
- const bundled = path23.join(CLI_MODULE_DIR, "assets", "download-datasets.sh");
11370
+ const bundled = path24.join(CLI_MODULE_DIR, "assets", "download-datasets.sh");
11216
11371
  if (fs32.existsSync(bundled)) {
11217
11372
  return bundled;
11218
11373
  }
11219
- return path23.join(CLI_REPO_ROOT2, "packages", "remnic-cli", "assets", "download-datasets.sh");
11374
+ return path24.join(CLI_REPO_ROOT2, "packages", "remnic-cli", "assets", "download-datasets.sh");
11220
11375
  }
11221
11376
  function runDatasetDownloadScript(scriptPath, benchmarkId, datasetRoot, jsonMode) {
11222
11377
  const stdio = jsonMode ? ["inherit", process.stderr, "inherit"] : "inherit";
@@ -11522,12 +11677,12 @@ async function exportBenchPackageResult(parsed) {
11522
11677
  process.exit(1);
11523
11678
  }
11524
11679
  const result = await loadBenchmarkResult(summary.path);
11525
- const reportCardProvenance = parsed.format === "html" ? await loadBenchmarkReportCardProvenance(path23.dirname(summary.path), result.meta.id) : void 0;
11680
+ const reportCardProvenance = parsed.format === "html" ? await loadBenchmarkReportCardProvenance(path24.dirname(summary.path), result.meta.id) : void 0;
11526
11681
  const rendered = renderBenchmarkResultExport(result, parsed.format, {
11527
11682
  ...reportCardProvenance ? { reportCardProvenance } : {}
11528
11683
  });
11529
11684
  if (parsed.output) {
11530
- fs32.mkdirSync(path23.dirname(parsed.output), { recursive: true });
11685
+ fs32.mkdirSync(path24.dirname(parsed.output), { recursive: true });
11531
11686
  fs32.writeFileSync(parsed.output, rendered);
11532
11687
  console.log(`Exported ${summary.id} as ${parsed.format} to ${parsed.output}`);
11533
11688
  return;
@@ -11549,7 +11704,7 @@ async function manageBenchDatasets(parsed) {
11549
11704
  return {
11550
11705
  benchmark: benchmarkId,
11551
11706
  downloaded: discovered !== void 0,
11552
- path: discovered ? discovered.dir : path23.join(datasetRoot, benchmarkId),
11707
+ path: discovered ? discovered.dir : path24.join(datasetRoot, benchmarkId),
11553
11708
  source: discovered?.source ?? "canonical"
11554
11709
  };
11555
11710
  });
@@ -11584,7 +11739,7 @@ async function manageBenchDatasets(parsed) {
11584
11739
  runDatasetDownloadScript(scriptPath, benchmarkId, datasetRoot, parsed.json === true);
11585
11740
  downloaded.push({
11586
11741
  benchmark: benchmarkId,
11587
- path: path23.join(datasetRoot, benchmarkId)
11742
+ path: path24.join(datasetRoot, benchmarkId)
11588
11743
  });
11589
11744
  }
11590
11745
  if (parsed.json) {
@@ -11723,10 +11878,10 @@ async function calibrateBenchJudges(parsed, rawArgs) {
11723
11878
  }
11724
11879
  const bench = await loadBenchModule();
11725
11880
  const resultsDir = expandTilde(
11726
- parsed.resultsDir ?? path23.join(resolveHomeDir(), ".remnic", "bench", "results")
11881
+ parsed.resultsDir ?? path24.join(resolveHomeDir(), ".remnic", "bench", "results")
11727
11882
  );
11728
11883
  const calibrationDir = expandTilde(
11729
- parsed.calibrationDir ?? path23.join(resolveHomeDir(), ".remnic", "bench", "calibration")
11884
+ parsed.calibrationDir ?? path24.join(resolveHomeDir(), ".remnic", "bench", "calibration")
11730
11885
  );
11731
11886
  const stored = await bench.listBenchmarkResults(resultsDir);
11732
11887
  const allForBenchmark = stored.filter((entry) => entry.benchmark === benchmarkId);
@@ -12286,7 +12441,7 @@ async function loadPublishedPromotionHelpers() {
12286
12441
  return {
12287
12442
  async promoteArtifactsToPublished(args) {
12288
12443
  const { mkdirSync: mkdirSync2, readFileSync: readFileSync6, writeFileSync: writeFileSync2 } = await import("fs");
12289
- const path24 = await import("path");
12444
+ const path25 = await import("path");
12290
12445
  mkdirSync2(args.publishedOutDir, { recursive: true });
12291
12446
  if (args.artifactPaths.length === 0) {
12292
12447
  console.warn(
@@ -12303,13 +12458,13 @@ async function loadPublishedPromotionHelpers() {
12303
12458
  const modelSlug = args.model.replace(/[^a-zA-Z0-9_.-]/g, "-");
12304
12459
  const rawProfile = parsedObj.config?.runtimeProfile;
12305
12460
  const profileSlug = typeof rawProfile === "string" && rawProfile.length > 0 ? `-${rawProfile.replace(/[^a-zA-Z0-9_.-]/g, "-")}` : "";
12306
- const target = path24.join(
12461
+ const target = path25.join(
12307
12462
  args.publishedOutDir,
12308
12463
  `${today}-${args.benchmarkId}-${modelSlug}${profileSlug}-${gitShaShort}.json`
12309
12464
  );
12310
12465
  writeFileSync2(target, raw, "utf8");
12311
12466
  console.log(
12312
- `[bench published] Promoted ${path24.basename(artifactPath)} \u2192 ${target}`
12467
+ `[bench published] Promoted ${path25.basename(artifactPath)} \u2192 ${target}`
12313
12468
  );
12314
12469
  }
12315
12470
  void benchModule;
@@ -12416,7 +12571,7 @@ async function runBenchViaPackage(parsed, benchmarkId, runtimeProfile, benchStat
12416
12571
  const previousCodexDiagnosticsDir = process.env[CODEX_CLI_BENCH_DIAGNOSTICS_DIR_ENV];
12417
12572
  const previousCodexDiagnosticsMode = process.env[CODEX_CLI_BENCH_DIAGNOSTICS_MODE_ENV];
12418
12573
  if (!previousCodexDiagnosticsDir) {
12419
- process.env[CODEX_CLI_BENCH_DIAGNOSTICS_DIR_ENV] = path23.join(
12574
+ process.env[CODEX_CLI_BENCH_DIAGNOSTICS_DIR_ENV] = path24.join(
12420
12575
  outputDir,
12421
12576
  "codex-cli-diagnostics"
12422
12577
  );
@@ -12566,7 +12721,7 @@ async function preparePersistedJudgeCalibrationAttachment(benchModule, benchmark
12566
12721
  );
12567
12722
  }
12568
12723
  const calibrationDir = expandTilde(
12569
- calibrationBinding.calibrationDir ?? path23.join(resolveHomeDir(), ".remnic", "bench", "calibration")
12724
+ calibrationBinding.calibrationDir ?? path24.join(resolveHomeDir(), ".remnic", "bench", "calibration")
12570
12725
  );
12571
12726
  const state = await benchModule.loadJudgeCalibrationState?.(benchmarkId, calibrationDir);
12572
12727
  if (!state) {
@@ -13048,7 +13203,7 @@ async function resolvePackageBenchRuntime(benchModule, parsed, runtimeProfile) {
13048
13203
  );
13049
13204
  }
13050
13205
  function normalizeMemoryDirPath(memoryDir) {
13051
- return path23.resolve(expandTilde(memoryDir));
13206
+ return path24.resolve(expandTilde(memoryDir));
13052
13207
  }
13053
13208
  function resolveMemoryDir() {
13054
13209
  const configMemoryDir = (() => {
@@ -13061,9 +13216,9 @@ function resolveMemoryDir() {
13061
13216
  return normalizeMemoryDirPath(remnicCfg.memoryDir);
13062
13217
  }
13063
13218
  const home = resolveHomeDir();
13064
- const standalonePath = path23.join(home, ".remnic", "memory");
13065
- const legacyStandalonePath = path23.join(home, ".engram", "memory");
13066
- const openclawPath = path23.join(resolveOpenclawStateDir(), "workspace", "memory", "local");
13219
+ const standalonePath = path24.join(home, ".remnic", "memory");
13220
+ const legacyStandalonePath = path24.join(home, ".engram", "memory");
13221
+ const openclawPath = path24.join(resolveOpenclawStateDir(), "workspace", "memory", "local");
13067
13222
  if (fs32.existsSync(standalonePath)) return standalonePath;
13068
13223
  if (fs32.existsSync(legacyStandalonePath)) return legacyStandalonePath;
13069
13224
  return openclawPath;
@@ -13112,21 +13267,21 @@ function resolveFlagStrict(args, flag) {
13112
13267
  var REMNIC_OPENCLAW_LEGACY_PLUGIN_ID = "openclaw-engram";
13113
13268
  function resolveOpenclawStateDir() {
13114
13269
  const configuredStateDir = process.env.OPENCLAW_STATE_DIR?.trim();
13115
- return configuredStateDir ? path23.resolve(expandTilde(configuredStateDir)) : path23.join(resolveHomeDir(), ".openclaw");
13270
+ return configuredStateDir ? path24.resolve(expandTilde(configuredStateDir)) : path24.join(resolveHomeDir(), ".openclaw");
13116
13271
  }
13117
13272
  var DEFAULT_OPENCLAW_CONFIG_PATHS_FOR_DOCTOR = [
13118
13273
  process.env.OPENCLAW_CONFIG_PATH,
13119
13274
  process.env.OPENCLAW_ENGRAM_CONFIG_PATH,
13120
- path23.join(resolveOpenclawStateDir(), "openclaw.json")
13275
+ path24.join(resolveOpenclawStateDir(), "openclaw.json")
13121
13276
  ].filter(Boolean);
13122
13277
  function resolveOpenclawConfigPath(cliPath) {
13123
- if (cliPath) return path23.resolve(expandTilde(cliPath));
13278
+ if (cliPath) return path24.resolve(expandTilde(cliPath));
13124
13279
  const envPath = process.env.OPENCLAW_CONFIG_PATH || process.env.OPENCLAW_ENGRAM_CONFIG_PATH;
13125
- if (envPath) return path23.resolve(expandTilde(envPath));
13280
+ if (envPath) return path24.resolve(expandTilde(envPath));
13126
13281
  for (const candidate of DEFAULT_OPENCLAW_CONFIG_PATHS_FOR_DOCTOR) {
13127
13282
  if (fs32.existsSync(candidate)) return candidate;
13128
13283
  }
13129
- return path23.join(resolveOpenclawStateDir(), "openclaw.json");
13284
+ return path24.join(resolveOpenclawStateDir(), "openclaw.json");
13130
13285
  }
13131
13286
  function readOpenclawConfig(configPath) {
13132
13287
  if (!fs32.existsSync(configPath)) return {};
@@ -13185,10 +13340,10 @@ function buildRemnicOpenclawHooksPolicy(legacyHooks, existingHooks) {
13185
13340
  function resolveOpenclawInstallMemoryDir(args) {
13186
13341
  const existingMemoryDir = (typeof args.existingNewEntryConfig.memoryDir === "string" ? args.existingNewEntryConfig.memoryDir : void 0) || (args.migrateLegacy && typeof args.legacyConfigToMerge.memoryDir === "string" ? args.legacyConfigToMerge.memoryDir : void 0);
13187
13342
  if (args.requestedMemoryDir) {
13188
- return path23.resolve(expandTilde(args.requestedMemoryDir));
13343
+ return path24.resolve(expandTilde(args.requestedMemoryDir));
13189
13344
  }
13190
13345
  if (existingMemoryDir) {
13191
- return path23.resolve(expandTilde(existingMemoryDir));
13346
+ return path24.resolve(expandTilde(existingMemoryDir));
13192
13347
  }
13193
13348
  return args.fallbackMemoryDir;
13194
13349
  }
@@ -13206,21 +13361,21 @@ function resolveCurrentOpenclawMemoryDir(entries, slots, fallbackMemoryDir) {
13206
13361
  if (!config || typeof config !== "object" || Array.isArray(config)) continue;
13207
13362
  const memoryDir = config.memoryDir;
13208
13363
  if (typeof memoryDir === "string" && memoryDir.trim().length > 0) {
13209
- return path23.resolve(expandTilde(memoryDir));
13364
+ return path24.resolve(expandTilde(memoryDir));
13210
13365
  }
13211
13366
  }
13212
13367
  return fallbackMemoryDir;
13213
13368
  }
13214
13369
  function resolveOpenclawPluginDir(cliPath) {
13215
- if (cliPath) return path23.resolve(expandTilde(cliPath));
13370
+ if (cliPath) return path24.resolve(expandTilde(cliPath));
13216
13371
  return resolveOpenclawManagedPluginDir();
13217
13372
  }
13218
13373
  function resolveOpenclawManagedPluginDir() {
13219
- return path23.join(resolveOpenclawStateDir(), "extensions", REMNIC_OPENCLAW_PLUGIN_ID);
13374
+ return path24.join(resolveOpenclawStateDir(), "extensions", REMNIC_OPENCLAW_PLUGIN_ID);
13220
13375
  }
13221
13376
  function resolveOpenclawLegacyPluginDir(cliPath) {
13222
- if (cliPath) return path23.resolve(expandTilde(cliPath));
13223
- return path23.join(resolveOpenclawStateDir(), "extensions", REMNIC_OPENCLAW_LEGACY_PLUGIN_ID);
13377
+ if (cliPath) return path24.resolve(expandTilde(cliPath));
13378
+ return path24.join(resolveOpenclawStateDir(), "extensions", REMNIC_OPENCLAW_LEGACY_PLUGIN_ID);
13224
13379
  }
13225
13380
  function formatOpenclawUpgradeStamp(now = /* @__PURE__ */ new Date()) {
13226
13381
  const yyyy = now.getFullYear().toString();
@@ -13233,7 +13388,7 @@ function formatOpenclawUpgradeStamp(now = /* @__PURE__ */ new Date()) {
13233
13388
  }
13234
13389
  function backupPathIfPresent(sourcePath, backupPath) {
13235
13390
  if (!fs32.existsSync(sourcePath)) return false;
13236
- fs32.mkdirSync(path23.dirname(backupPath), { recursive: true });
13391
+ fs32.mkdirSync(path24.dirname(backupPath), { recursive: true });
13237
13392
  fs32.cpSync(sourcePath, backupPath, { recursive: true });
13238
13393
  return true;
13239
13394
  }
@@ -13252,7 +13407,7 @@ function restartOpenclawGateway() {
13252
13407
  });
13253
13408
  }
13254
13409
  function cmdInit() {
13255
- const configPath = path23.join(process.cwd(), "remnic.config.json");
13410
+ const configPath = path24.join(process.cwd(), "remnic.config.json");
13256
13411
  if (fs32.existsSync(configPath)) {
13257
13412
  console.log(`Config already exists: ${configPath}`);
13258
13413
  return;
@@ -13260,7 +13415,7 @@ function cmdInit() {
13260
13415
  const template = {
13261
13416
  remnic: {
13262
13417
  openaiApiKey: "${OPENAI_API_KEY}",
13263
- memoryDir: path23.join(process.cwd(), ".remnic", "memory"),
13418
+ memoryDir: path24.join(process.cwd(), ".remnic", "memory"),
13264
13419
  memoryOsPreset: "balanced"
13265
13420
  },
13266
13421
  server: {
@@ -13322,7 +13477,7 @@ async function cmdStatus(json) {
13322
13477
  console.log(`Remnic server: running${pid ? ` (pid ${pid})` : ""}`);
13323
13478
  await printHealthCheck(resolveDaemonBaseUrl(resolveConfigPath()), resolveStatusProbeToken());
13324
13479
  }
13325
- async function oauthFetch(method, path24, token, body) {
13480
+ async function oauthFetch(method, path25, token, body) {
13326
13481
  const controller = new AbortController();
13327
13482
  const timeoutId = setTimeout(() => controller.abort(), 5e3);
13328
13483
  try {
@@ -13341,7 +13496,7 @@ async function oauthFetch(method, path24, token, body) {
13341
13496
  if (body !== void 0) {
13342
13497
  init.body = JSON.stringify(body);
13343
13498
  }
13344
- const response = await fetch(`${resolveDaemonBaseUrl(resolveConfigPath())}${path24}`, init);
13499
+ const response = await fetch(`${resolveDaemonBaseUrl(resolveConfigPath())}${path25}`, init);
13345
13500
  if (response.status === 401) {
13346
13501
  throw new Error(
13347
13502
  "operator token rejected by remnic-server (HTTP 401). Update `server.authToken` or `REMNIC_AUTH_TOKEN` to match the running daemon."
@@ -14035,7 +14190,7 @@ async function cmdVersions(rest) {
14035
14190
  console.error("Usage: remnic versions list <page-path>");
14036
14191
  process.exit(1);
14037
14192
  }
14038
- const absPath = path23.resolve(pagePath);
14193
+ const absPath = path24.resolve(pagePath);
14039
14194
  const history = await listVersions(absPath, versioningConfig, memDir);
14040
14195
  if (json) {
14041
14196
  console.log(JSON.stringify(history, null, 2));
@@ -14060,7 +14215,7 @@ async function cmdVersions(rest) {
14060
14215
  console.error("Usage: remnic versions show <page-path> <version-id>");
14061
14216
  process.exit(1);
14062
14217
  }
14063
- const absPath = path23.resolve(pagePath);
14218
+ const absPath = path24.resolve(pagePath);
14064
14219
  try {
14065
14220
  const content = await getVersion(absPath, versionId, versioningConfig, memDir);
14066
14221
  console.log(content);
@@ -14078,7 +14233,7 @@ async function cmdVersions(rest) {
14078
14233
  console.error("Usage: remnic versions diff <page-path> <v1> <v2>");
14079
14234
  process.exit(1);
14080
14235
  }
14081
- const absPath = path23.resolve(pagePath);
14236
+ const absPath = path24.resolve(pagePath);
14082
14237
  try {
14083
14238
  const diffOutput = await diffVersions(absPath, v1, v2, versioningConfig, memDir);
14084
14239
  console.log(diffOutput);
@@ -14095,7 +14250,7 @@ async function cmdVersions(rest) {
14095
14250
  console.error("Usage: remnic versions revert <page-path> <version-id>");
14096
14251
  process.exit(1);
14097
14252
  }
14098
- const absPath = path23.resolve(pagePath);
14253
+ const absPath = path24.resolve(pagePath);
14099
14254
  try {
14100
14255
  const version = await revertToVersion(absPath, versionId, versioningConfig, void 0, memDir);
14101
14256
  if (json) {
@@ -14135,7 +14290,7 @@ async function cmdEnrich(rest) {
14135
14290
  const subcommand = rest[0];
14136
14291
  if (subcommand === "audit") {
14137
14292
  const memoryDir2 = expandTilde(config.memoryDir);
14138
- const auditDir2 = path23.join(memoryDir2, "enrichment");
14293
+ const auditDir2 = path24.join(memoryDir2, "enrichment");
14139
14294
  const sinceFlag = resolveFlag(rest.slice(1), "--since");
14140
14295
  const entries = await readAuditLog(auditDir2, sinceFlag ?? void 0);
14141
14296
  if (entries.length === 0) {
@@ -14260,7 +14415,7 @@ Registered providers:`);
14260
14415
  return;
14261
14416
  }
14262
14417
  const memoryDir = expandTilde(config.memoryDir);
14263
- const auditDir = path23.join(memoryDir, "enrichment");
14418
+ const auditDir = path24.join(memoryDir, "enrichment");
14264
14419
  let totalPersisted = 0;
14265
14420
  for (const result of results) {
14266
14421
  for (const candidate of result.acceptedCandidates) {
@@ -14383,7 +14538,7 @@ Root: ${root}`);
14383
14538
  const validNames = new Set(extensions.map((e) => e.name));
14384
14539
  let errors = 0;
14385
14540
  for (const entry of entries) {
14386
- const entryPath = path23.join(root, entry);
14541
+ const entryPath = path24.join(root, entry);
14387
14542
  try {
14388
14543
  if (!fs32.statSync(entryPath).isDirectory()) continue;
14389
14544
  } catch {
@@ -14514,7 +14669,7 @@ ${section}
14514
14669
  const saveDir = resolveBriefingSaveDir(config.briefing.saveDir);
14515
14670
  fs32.mkdirSync(saveDir, { recursive: true });
14516
14671
  const filename = briefingFilename(new Date(result.window.to), format);
14517
- const filePath = path23.join(saveDir, filename);
14672
+ const filePath = path24.join(saveDir, filename);
14518
14673
  fs32.writeFileSync(filePath, payload + (payload.endsWith("\n") ? "" : "\n"));
14519
14674
  console.error(`Saved briefing: ${filePath}`);
14520
14675
  } catch (err) {
@@ -14670,7 +14825,7 @@ async function cmdDoctor() {
14670
14825
  const rawMemoryDir = entryConfig?.memoryDir;
14671
14826
  const configuredMemoryDir = typeof rawMemoryDir === "string" ? rawMemoryDir : void 0;
14672
14827
  if (configuredMemoryDir) {
14673
- const resolvedMemDir = path23.resolve(expandTilde(configuredMemoryDir));
14828
+ const resolvedMemDir = path24.resolve(expandTilde(configuredMemoryDir));
14674
14829
  let memDirOk = false;
14675
14830
  let memDirDetail = `${resolvedMemDir} (not found)`;
14676
14831
  let memDirRemediation = `Run \`remnic openclaw install --memory-dir "${resolvedMemDir}"\` to create the directory.`;
@@ -14883,7 +15038,7 @@ async function cmdMigrate(json, rollback) {
14883
15038
  console.log(` Rollback: ${result.rollbackCommand}`);
14884
15039
  }
14885
15040
  function cmdOnboard(dirPath, json) {
14886
- const directory = path23.resolve(dirPath || process.cwd());
15041
+ const directory = path24.resolve(dirPath || process.cwd());
14887
15042
  const result = onboard({ directory });
14888
15043
  if (json) {
14889
15044
  console.log(JSON.stringify(result, null, 2));
@@ -14902,7 +15057,7 @@ Suggested namespace: ${result.plan.suggestedNamespace}`);
14902
15057
  async function cmdCurate(targetPath, json) {
14903
15058
  const memoryDir = resolveMemoryDir();
14904
15059
  const result = await curate({
14905
- targetPath: path23.resolve(targetPath),
15060
+ targetPath: path24.resolve(targetPath),
14906
15061
  memoryDir,
14907
15062
  source: "curation",
14908
15063
  checkDuplicates: true,
@@ -14940,7 +15095,7 @@ async function cmdReview(action, rest) {
14940
15095
  console.error("Usage: remnic review <approve|dismiss|flag> <id>");
14941
15096
  process.exit(1);
14942
15097
  }
14943
- const storage = new StorageManager4(memoryDir);
15098
+ const storage = new StorageManager5(memoryDir);
14944
15099
  const configPath = resolveConfigPath();
14945
15100
  let tombstonesConfig = null;
14946
15101
  try {
@@ -15032,7 +15187,7 @@ async function cmdSync(action, rest, json) {
15032
15187
  }
15033
15188
  function localOfflineSourceId(memoryDir) {
15034
15189
  const host = os4.hostname() || "unknown-host";
15035
- const dirHash = createHash6("sha256").update(path23.resolve(memoryDir)).digest("hex").slice(0, 16);
15190
+ const dirHash = createHash6("sha256").update(path24.resolve(memoryDir)).digest("hex").slice(0, 16);
15036
15191
  return `remnic-local:${host}:${dirHash}`;
15037
15192
  }
15038
15193
  function normalizeOfflineRemoteUrl(raw) {
@@ -15224,7 +15379,8 @@ async function parseOfflineSnapshotStreamResponse(response) {
15224
15379
  schemaVersion: parsed.schemaVersion,
15225
15380
  createdAt: parsed.createdAt,
15226
15381
  sourceId: parsed.sourceId,
15227
- includeTranscripts: parsed.includeTranscripts
15382
+ includeTranscripts: parsed.includeTranscripts,
15383
+ ...Array.isArray(parsed.omittedEmbeddingGenerationDirs) ? { omittedEmbeddingGenerationDirs: parsed.omittedEmbeddingGenerationDirs } : {}
15228
15384
  };
15229
15385
  return;
15230
15386
  }
@@ -15257,7 +15413,8 @@ async function parseOfflineSnapshotStreamResponse(response) {
15257
15413
  createdAt: finalHeader.createdAt,
15258
15414
  sourceId: finalHeader.sourceId,
15259
15415
  includeTranscripts: finalHeader.includeTranscripts,
15260
- files
15416
+ files,
15417
+ ...finalHeader.omittedEmbeddingGenerationDirs ? { omittedEmbeddingGenerationDirs: finalHeader.omittedEmbeddingGenerationDirs } : {}
15261
15418
  });
15262
15419
  return {
15263
15420
  ...finalHeader.namespace ? { namespace: finalHeader.namespace } : {},
@@ -15441,10 +15598,10 @@ var OFFLINE_SYNC_CONTENT_MISSING_RETRY_MAX = 3;
15441
15598
  var OFFLINE_SYNC_CONTENT_MISSING_RETRY_DELAY_MS = 250;
15442
15599
  var OfflineRemoteFileChangedError = class extends Error {
15443
15600
  path;
15444
- constructor(path24) {
15445
- super(`remote file changed while fetching offline content: ${path24}`);
15601
+ constructor(path25) {
15602
+ super(`remote file changed while fetching offline content: ${path25}`);
15446
15603
  this.name = "OfflineRemoteFileChangedError";
15447
- this.path = path24;
15604
+ this.path = path25;
15448
15605
  }
15449
15606
  };
15450
15607
  function isOfflineRemoteFileChangedError(error) {
@@ -15585,9 +15742,11 @@ function offlineSnapshotContentFilesForApply(options) {
15585
15742
  const current = options.currentFiles ? offlineFileStateMap(options.currentFiles) : null;
15586
15743
  const conflictContentMaxBytes = options.conflictContentMaxBytes ?? Number.POSITIVE_INFINITY;
15587
15744
  const deferredPaths = new Set(options.deferredPaths ?? []);
15745
+ const skipPaths = options.skipPaths ?? /* @__PURE__ */ new Set();
15588
15746
  const files = [];
15589
15747
  for (const incoming of options.snapshot.files) {
15590
15748
  if (deferredPaths.has(incoming.path)) continue;
15749
+ if (skipPaths.has(incoming.path)) continue;
15591
15750
  const baseEntry = base.get(incoming.path);
15592
15751
  const currentEntry = current?.get(incoming.path);
15593
15752
  if (currentEntry?.sha256 === incoming.sha256) continue;
@@ -15613,6 +15772,7 @@ function offlineSnapshotContentFilesForApply(options) {
15613
15772
  function shouldDirectHydrateOfflineFile(options) {
15614
15773
  if (options.incoming.bytes < OFFLINE_SYNC_DIRECT_HYDRATE_MIN_BYTES) return false;
15615
15774
  if (options.current?.sha256 === options.incoming.sha256) return false;
15775
+ if (embeddingGenerationMembership2(options.incoming.path)) return false;
15616
15776
  if (shouldPreferIncomingOfflineRuntimeFile(options.incoming.path)) return true;
15617
15777
  if (options.current && options.base && options.current.sha256 === options.base.sha256) {
15618
15778
  return true;
@@ -15705,7 +15865,7 @@ async function pushOfflineFileContentFromChunkReader(args) {
15705
15865
  }
15706
15866
  const hash = createHash6("sha256");
15707
15867
  const chunks = args.readFileChunks({
15708
- root: path23.resolve(args.memoryDir),
15868
+ root: path24.resolve(args.memoryDir),
15709
15869
  path: args.file.path,
15710
15870
  filePath,
15711
15871
  chunkSize: OFFLINE_SYNC_FILE_CONTENT_UPLOAD_CHUNK_BYTES
@@ -15975,7 +16135,8 @@ async function hydrateOfflineSnapshotContent(args) {
15975
16135
  baseFiles: args.baseFiles,
15976
16136
  currentFiles: args.currentFiles,
15977
16137
  conflictContentMaxBytes: OFFLINE_SYNC_FILES_CONTENT_MAX_BATCH_BYTES,
15978
- deferredPaths: args.deferredPaths
16138
+ deferredPaths: args.deferredPaths,
16139
+ skipPaths: args.skipContentPaths
15979
16140
  });
15980
16141
  if (neededFiles.length === 0) return { ...args.snapshot, files: snapshot.files };
15981
16142
  const expectedByPath = new Map(snapshot.files.map((file) => [file.path, file]));
@@ -16340,16 +16501,16 @@ async function runOfflineSyncOnce(options) {
16340
16501
  conflicts: [...prior?.conflicts ?? [], ...result.conflicts]
16341
16502
  });
16342
16503
  pushed = buildPushedSummary(null);
16343
- const stateWritePathsFor = (resolvedNamespace2) => offlineStatePathsForNamespace({
16504
+ const stateWritePathsFor = (resolvedNamespace) => offlineStatePathsForNamespace({
16344
16505
  memoryDir: options.memoryDir,
16345
16506
  remoteUrl: options.remoteUrl,
16346
16507
  requestedNamespace: options.namespace,
16347
- resolvedNamespace: resolvedNamespace2,
16508
+ resolvedNamespace,
16348
16509
  explicitStatePath: options.statePathExplicit ? activeStatePath : void 0
16349
16510
  });
16350
16511
  const writePartialPushState = async (error, partial, checkpointChangeset = changeset) => {
16351
- const resolvedNamespace2 = partial?.resolvedNamespace ?? resolvedOfflineSnapshotNamespace({ namespace: pushed?.namespace ?? "" }, syncNamespace);
16352
- const stateWritePaths2 = stateWritePathsFor(resolvedNamespace2);
16512
+ const resolvedNamespace = partial?.resolvedNamespace ?? resolvedOfflineSnapshotNamespace({ namespace: pushed?.namespace ?? "" }, syncNamespace);
16513
+ const stateWritePaths = stateWritePathsFor(resolvedNamespace);
16353
16514
  const nextBaseFiles = advanceOfflineBaseFilesForSuccessfulPush({
16354
16515
  baseFiles: syncBaseFiles,
16355
16516
  currentFiles: currentSnapshotForPush.files,
@@ -16358,23 +16519,23 @@ async function runOfflineSyncOnce(options) {
16358
16519
  changeset: checkpointChangeset,
16359
16520
  conflicts: pushed?.conflicts ?? directPushConflicts
16360
16521
  });
16361
- const state2 = {
16522
+ const state = {
16362
16523
  version: 1,
16363
16524
  remoteId: options.remoteUrl,
16364
- ...resolvedNamespace2 ? { namespace: resolvedNamespace2 } : {},
16525
+ ...resolvedNamespace ? { namespace: resolvedNamespace } : {},
16365
16526
  includeTranscripts: options.includeTranscripts,
16366
16527
  // Partial checkpoints do not recapture conflicted/deferred paths, so keep
16367
16528
  // the original capture time for safe fast-base reuse on the next run.
16368
16529
  lastSyncedAt: priorState?.lastSyncedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
16369
16530
  baseFiles: nextBaseFiles
16370
16531
  };
16371
- for (const statePath of stateWritePaths2) {
16372
- await writeOfflineSyncState(statePath, state2);
16532
+ for (const statePath of stateWritePaths) {
16533
+ await writeOfflineSyncState(statePath, state);
16373
16534
  }
16374
16535
  const message = error instanceof Error ? error.message : String(error);
16375
16536
  return {
16376
- statePath: stateWritePaths2[0] ?? activeStatePath,
16377
- namespace: resolvedNamespace2,
16537
+ statePath: stateWritePaths[0] ?? activeStatePath,
16538
+ namespace: resolvedNamespace,
16378
16539
  prepared: priorState === null,
16379
16540
  pushed,
16380
16541
  pull: null,
@@ -16581,18 +16742,26 @@ async function runOfflineSyncOnce(options) {
16581
16742
  excludeNodeLocalState: false
16582
16743
  });
16583
16744
  const applyCurrentSnapshot = await buildCurrentSnapshotForApply();
16584
- let remoteSnapshot;
16745
+ const generationDeferrals = divergedEmbeddingGenerationDeferrals({
16746
+ incomingFiles: remoteSnapshotMetadata.files,
16747
+ baseFiles: syncBaseFiles,
16748
+ currentFiles: applyCurrentSnapshot.files
16749
+ });
16750
+ const pullDeferredPaths = [...remoteDeferredPaths, ...generationDeferrals];
16751
+ let stagedTransport;
16585
16752
  try {
16586
- remoteSnapshot = await hydrateOfflineSnapshotContent({
16753
+ stagedTransport = await stageGenerationMembersForApply({
16754
+ memoryDir: options.memoryDir,
16587
16755
  remoteUrl: options.remoteUrl,
16588
16756
  token: options.token,
16589
16757
  namespace: syncNamespace,
16590
16758
  includeTranscripts: options.includeTranscripts,
16591
- snapshot: remoteSnapshotMetadata,
16592
- baseFiles: syncBaseFiles,
16759
+ incomingFiles: remoteSnapshotMetadata.files,
16593
16760
  currentFiles: applyCurrentSnapshot.files,
16594
- deferredPaths: [...remoteDeferredPaths],
16595
- missingContentDeferredPaths: remoteDeferredPaths
16761
+ deferredPaths: pullDeferredPaths,
16762
+ minBytes: options.generationStagedHydrateMinBytes ?? OFFLINE_SYNC_DIRECT_HYDRATE_MIN_BYTES,
16763
+ secureStoreEncryptOnWrite: options.secureStoreEncryptOnWrite,
16764
+ hydrateFileContent: hydrateOfflineFileContent
16596
16765
  });
16597
16766
  } catch (error) {
16598
16767
  if (pushed || partialHydration.hydratedFiles.length > 0) {
@@ -16600,36 +16769,10 @@ async function runOfflineSyncOnce(options) {
16600
16769
  }
16601
16770
  throw error;
16602
16771
  }
16603
- const resolvedNamespace = resolvedOfflineSnapshotNamespace(remoteSnapshot, syncNamespace);
16604
- let pull;
16605
16772
  try {
16606
- const latestApplySnapshot = await buildCurrentSnapshotForApply();
16607
- pull = await applyOfflineSyncSnapshot({
16608
- root: options.memoryDir,
16609
- snapshot: remoteSnapshot,
16610
- baseFiles: syncBaseFiles,
16611
- currentFiles: latestApplySnapshot.files,
16612
- deferredPaths: [...remoteDeferredPaths],
16613
- allowMissingConflictContent: true,
16614
- readFile: storageIo.readFile,
16615
- readFileDigest: storageIo.readFileDigest,
16616
- writeFile: storageIo.writeFile,
16617
- deleteFile: storageIo.deleteFile,
16618
- recordDeletionRevision: storageIo.recordDeletionRevision
16619
- });
16620
- } catch (error) {
16621
- if (!isMissingOfflineContentError(error)) {
16622
- if (pushed || partialHydration.hydratedFiles.length > 0) {
16623
- return writePartialPushState(error, {
16624
- ...partialHydrationWithContext,
16625
- resolvedNamespace
16626
- });
16627
- }
16628
- throw error;
16629
- }
16630
- let retrySnapshot;
16773
+ let remoteSnapshot;
16631
16774
  try {
16632
- retrySnapshot = await hydrateOfflineSnapshotContent({
16775
+ remoteSnapshot = await hydrateOfflineSnapshotContent({
16633
16776
  remoteUrl: options.remoteUrl,
16634
16777
  token: options.token,
16635
16778
  namespace: syncNamespace,
@@ -16637,69 +16780,126 @@ async function runOfflineSyncOnce(options) {
16637
16780
  snapshot: remoteSnapshotMetadata,
16638
16781
  baseFiles: syncBaseFiles,
16639
16782
  currentFiles: applyCurrentSnapshot.files,
16640
- deferredPaths: [...remoteDeferredPaths],
16641
- missingContentDeferredPaths: remoteDeferredPaths
16783
+ deferredPaths: pullDeferredPaths,
16784
+ missingContentDeferredPaths: remoteDeferredPaths,
16785
+ skipContentPaths: stagedTransport.stagedPaths
16642
16786
  });
16643
- } catch (retryError) {
16787
+ } catch (error) {
16644
16788
  if (pushed || partialHydration.hydratedFiles.length > 0) {
16645
- return writePartialPushState(retryError, {
16646
- ...partialHydrationWithContext,
16647
- resolvedNamespace
16648
- });
16789
+ return writePartialPushState(error, partialHydrationWithContext);
16649
16790
  }
16650
- throw retryError;
16791
+ throw error;
16651
16792
  }
16793
+ const resolvedNamespace = resolvedOfflineSnapshotNamespace(remoteSnapshot, syncNamespace);
16794
+ let pull;
16652
16795
  try {
16653
- const latestRetryApplySnapshot = await buildCurrentSnapshotForApply();
16796
+ const latestApplySnapshot = await buildCurrentSnapshotForApply();
16654
16797
  pull = await applyOfflineSyncSnapshot({
16655
16798
  root: options.memoryDir,
16656
- snapshot: retrySnapshot,
16799
+ snapshot: remoteSnapshot,
16657
16800
  baseFiles: syncBaseFiles,
16658
- currentFiles: latestRetryApplySnapshot.files,
16659
- deferredPaths: [...remoteDeferredPaths],
16801
+ currentFiles: latestApplySnapshot.files,
16802
+ deferredPaths: pullDeferredPaths,
16660
16803
  allowMissingConflictContent: true,
16804
+ readIncomingFile: stagedTransport.readIncomingFile,
16661
16805
  readFile: storageIo.readFile,
16662
16806
  readFileDigest: storageIo.readFileDigest,
16663
16807
  writeFile: storageIo.writeFile,
16808
+ writeStagingFile: storageIo.writeStagingFile,
16809
+ readStagingFile: storageIo.readStagingFile,
16664
16810
  deleteFile: storageIo.deleteFile,
16665
16811
  recordDeletionRevision: storageIo.recordDeletionRevision
16666
16812
  });
16667
- } catch (retryApplyError) {
16668
- if (pushed || partialHydration.hydratedFiles.length > 0) {
16669
- return writePartialPushState(retryApplyError, {
16670
- ...partialHydrationWithContext,
16671
- resolvedNamespace
16813
+ } catch (error) {
16814
+ if (!isMissingOfflineContentError(error)) {
16815
+ if (pushed || partialHydration.hydratedFiles.length > 0) {
16816
+ return writePartialPushState(error, {
16817
+ ...partialHydrationWithContext,
16818
+ resolvedNamespace
16819
+ });
16820
+ }
16821
+ throw error;
16822
+ }
16823
+ let retrySnapshot;
16824
+ try {
16825
+ retrySnapshot = await hydrateOfflineSnapshotContent({
16826
+ remoteUrl: options.remoteUrl,
16827
+ token: options.token,
16828
+ namespace: syncNamespace,
16829
+ includeTranscripts: options.includeTranscripts,
16830
+ snapshot: remoteSnapshotMetadata,
16831
+ baseFiles: syncBaseFiles,
16832
+ currentFiles: applyCurrentSnapshot.files,
16833
+ deferredPaths: pullDeferredPaths,
16834
+ missingContentDeferredPaths: remoteDeferredPaths,
16835
+ skipContentPaths: stagedTransport.stagedPaths
16836
+ });
16837
+ } catch (retryError) {
16838
+ if (pushed || partialHydration.hydratedFiles.length > 0) {
16839
+ return writePartialPushState(retryError, {
16840
+ ...partialHydrationWithContext,
16841
+ resolvedNamespace
16842
+ });
16843
+ }
16844
+ throw retryError;
16845
+ }
16846
+ try {
16847
+ const latestRetryApplySnapshot = await buildCurrentSnapshotForApply();
16848
+ pull = await applyOfflineSyncSnapshot({
16849
+ root: options.memoryDir,
16850
+ snapshot: retrySnapshot,
16851
+ baseFiles: syncBaseFiles,
16852
+ currentFiles: latestRetryApplySnapshot.files,
16853
+ deferredPaths: pullDeferredPaths,
16854
+ allowMissingConflictContent: true,
16855
+ readIncomingFile: stagedTransport.readIncomingFile,
16856
+ readFile: storageIo.readFile,
16857
+ readFileDigest: storageIo.readFileDigest,
16858
+ writeFile: storageIo.writeFile,
16859
+ writeStagingFile: storageIo.writeStagingFile,
16860
+ readStagingFile: storageIo.readStagingFile,
16861
+ deleteFile: storageIo.deleteFile,
16862
+ recordDeletionRevision: storageIo.recordDeletionRevision
16672
16863
  });
16864
+ } catch (retryApplyError) {
16865
+ if (pushed || partialHydration.hydratedFiles.length > 0) {
16866
+ return writePartialPushState(retryApplyError, {
16867
+ ...partialHydrationWithContext,
16868
+ resolvedNamespace
16869
+ });
16870
+ }
16871
+ throw retryApplyError;
16673
16872
  }
16674
- throw retryApplyError;
16675
16873
  }
16676
- }
16677
- const state = offlineSyncStateFromSnapshot({
16678
- remoteId: options.remoteUrl,
16679
- namespace: resolvedNamespace,
16680
- snapshot: remoteSnapshot,
16681
- baseFiles: pull.nextBaseFiles
16682
- });
16683
- const stateWritePaths = stateWritePathsFor(resolvedNamespace);
16684
- for (const statePath of stateWritePaths) {
16685
- await writeOfflineSyncState(statePath, state);
16686
- }
16687
- return {
16688
- statePath: stateWritePaths[0] ?? activeStatePath,
16689
- namespace: resolvedNamespace,
16690
- prepared: priorState === null,
16691
- pushed,
16692
- pull,
16693
- partial: false,
16694
- pendingSummary,
16695
- remoteFileCount: remoteSnapshot.files.length,
16696
- largeFilePushFailures: [...directPushFailures],
16697
- deferred: {
16698
- localChangedDuringPush: [...directPushDeferredPaths].sort(),
16699
- remoteChangedDuringHydrate: [...remoteDeferredPaths].sort(),
16700
- total: directPushDeferredPaths.size + remoteDeferredPaths.size
16874
+ const state = offlineSyncStateFromSnapshot({
16875
+ remoteId: options.remoteUrl,
16876
+ namespace: resolvedNamespace,
16877
+ snapshot: remoteSnapshot,
16878
+ baseFiles: pull.nextBaseFiles
16879
+ });
16880
+ const stateWritePaths = stateWritePathsFor(resolvedNamespace);
16881
+ for (const statePath of stateWritePaths) {
16882
+ await writeOfflineSyncState(statePath, state);
16701
16883
  }
16702
- };
16884
+ return {
16885
+ statePath: stateWritePaths[0] ?? activeStatePath,
16886
+ namespace: resolvedNamespace,
16887
+ prepared: priorState === null,
16888
+ pushed,
16889
+ pull,
16890
+ partial: false,
16891
+ pendingSummary,
16892
+ remoteFileCount: remoteSnapshot.files.length,
16893
+ largeFilePushFailures: [...directPushFailures],
16894
+ deferred: {
16895
+ localChangedDuringPush: [...directPushDeferredPaths].sort(),
16896
+ remoteChangedDuringHydrate: [...remoteDeferredPaths].sort(),
16897
+ total: directPushDeferredPaths.size + remoteDeferredPaths.size
16898
+ }
16899
+ };
16900
+ } finally {
16901
+ await stagedTransport.cleanup();
16902
+ }
16703
16903
  }
16704
16904
  function sumOfflineFileBytes(files) {
16705
16905
  return files.reduce((total, file) => total + file.bytes, 0);
@@ -16819,7 +17019,7 @@ Environment fallbacks:
16819
17019
  REMNIC_OFFLINE_TOKEN > REMNIC_AUTH_TOKEN > ENGRAM_AUTH_TOKEN.`);
16820
17020
  return;
16821
17021
  }
16822
- const memoryDir = path23.resolve(expandTilde(resolveRequiredValueFlag(rest, "--memory-dir") ?? resolveMemoryDir()));
17022
+ const memoryDir = path24.resolve(expandTilde(resolveRequiredValueFlag(rest, "--memory-dir") ?? resolveMemoryDir()));
16823
17023
  const namespace = resolveRequiredValueFlag(rest, "--namespace");
16824
17024
  const includeTranscripts = !hasFlag(rest, "--no-transcripts");
16825
17025
  const stateOverride = resolveRequiredValueFlag(rest, "--state");
@@ -16840,17 +17040,18 @@ Environment fallbacks:
16840
17040
  const remoteUrl = needsRemote ? resolveOfflineRemoteUrl(rest) : resolveOptionalOfflineRemoteUrl(rest);
16841
17041
  const knownAction = needsRemote || action === "status";
16842
17042
  const token = knownAction ? resolveOfflineToken(rest) : void 0;
16843
- const statePath = statePathExplicit ? path23.resolve(expandTilde(stateOverride)) : remoteUrl !== void 0 ? defaultOfflineSyncStatePath(memoryDir, remoteUrl, namespace) : void 0;
17043
+ const statePath = statePathExplicit ? path24.resolve(expandTilde(stateOverride)) : remoteUrl !== void 0 ? defaultOfflineSyncStatePath(memoryDir, remoteUrl, namespace) : void 0;
16844
17044
  if (action === "prepare") {
16845
17045
  if (!remoteUrl || !token || !statePath) throw new Error("offline prepare requires remote URL and token");
16846
17046
  fs32.mkdirSync(memoryDir, { recursive: true });
16847
- const remoteSnapshot = await fetchOfflineSnapshot({
17047
+ const remoteSnapshotMetadata = await fetchOfflineSnapshot({
16848
17048
  remoteUrl,
16849
17049
  token,
16850
17050
  namespace,
16851
- includeTranscripts
17051
+ includeTranscripts,
17052
+ includeContent: false
16852
17053
  });
16853
- const resolvedNamespace = resolvedOfflineSnapshotNamespace(remoteSnapshot, namespace);
17054
+ const resolvedNamespace = resolvedOfflineSnapshotNamespace(remoteSnapshotMetadata, namespace);
16854
17055
  const stateWritePaths = offlineStatePathsForNamespace({
16855
17056
  memoryDir,
16856
17057
  remoteUrl,
@@ -16873,16 +17074,56 @@ Environment fallbacks:
16873
17074
  memoryDir,
16874
17075
  await createConfiguredOfflineStorage(memoryDir, config.secureStoreEncryptOnWrite)
16875
17076
  );
16876
- const pull = await applyOfflineSyncSnapshot({
17077
+ const currentSnapshot = await buildOfflineSyncSnapshotFromBase2({
16877
17078
  root: memoryDir,
16878
- snapshot: remoteSnapshot,
16879
- baseFiles: existingState?.state.baseFiles ?? [],
17079
+ sourceId: "local",
17080
+ includeContent: false,
17081
+ includeTranscripts,
16880
17082
  readFile: storageIo.readFile,
16881
17083
  readFileDigest: storageIo.readFileDigest,
16882
- writeFile: storageIo.writeFile,
16883
- deleteFile: storageIo.deleteFile,
16884
- recordDeletionRevision: storageIo.recordDeletionRevision
17084
+ excludeNodeLocalState: false
16885
17085
  });
17086
+ const stagedTransport = await stageGenerationMembersForApply({
17087
+ memoryDir,
17088
+ remoteUrl,
17089
+ token,
17090
+ namespace: resolvedNamespace,
17091
+ includeTranscripts,
17092
+ incomingFiles: remoteSnapshotMetadata.files,
17093
+ currentFiles: currentSnapshot.files,
17094
+ minBytes: OFFLINE_SYNC_DIRECT_HYDRATE_MIN_BYTES,
17095
+ secureStoreEncryptOnWrite: config.secureStoreEncryptOnWrite,
17096
+ hydrateFileContent: hydrateOfflineFileContent
17097
+ });
17098
+ let remoteSnapshot;
17099
+ let pull;
17100
+ try {
17101
+ remoteSnapshot = await hydrateOfflineSnapshotContent({
17102
+ remoteUrl,
17103
+ token,
17104
+ namespace: resolvedNamespace,
17105
+ includeTranscripts,
17106
+ snapshot: remoteSnapshotMetadata,
17107
+ baseFiles: existingState?.state.baseFiles ?? [],
17108
+ currentFiles: currentSnapshot.files,
17109
+ skipContentPaths: stagedTransport.stagedPaths
17110
+ });
17111
+ pull = await applyOfflineSyncSnapshot({
17112
+ root: memoryDir,
17113
+ snapshot: remoteSnapshot,
17114
+ baseFiles: existingState?.state.baseFiles ?? [],
17115
+ readFile: storageIo.readFile,
17116
+ readFileDigest: storageIo.readFileDigest,
17117
+ writeFile: storageIo.writeFile,
17118
+ writeStagingFile: storageIo.writeStagingFile,
17119
+ readStagingFile: storageIo.readStagingFile,
17120
+ deleteFile: storageIo.deleteFile,
17121
+ recordDeletionRevision: storageIo.recordDeletionRevision,
17122
+ readIncomingFile: stagedTransport.readIncomingFile
17123
+ });
17124
+ } finally {
17125
+ await stagedTransport.cleanup();
17126
+ }
16886
17127
  const state = offlineSyncStateFromSnapshot({
16887
17128
  remoteId: remoteUrl,
16888
17129
  namespace: resolvedNamespace,
@@ -17022,11 +17263,11 @@ Environment fallbacks:
17022
17263
  failures: result.largeFilePushFailures
17023
17264
  });
17024
17265
  largeFileFailureCounts = advanced.counts;
17025
- for (const path24 of advanced.newlySkipped) {
17026
- if (skippedLargeFiles.has(path24)) continue;
17027
- skippedLargeFiles.add(path24);
17266
+ for (const path25 of advanced.newlySkipped) {
17267
+ if (skippedLargeFiles.has(path25)) continue;
17268
+ skippedLargeFiles.add(path25);
17028
17269
  console.warn(
17029
- `offline sync: permanently skipping ${path24} after ${OFFLINE_LARGE_FILE_SKIP_AFTER_FAILURES} failed large-file pushes for this watcher process (see issue #1786; use --exclude or offlineSyncExcludes to silence permanently)`
17270
+ `offline sync: permanently skipping ${path25} after ${OFFLINE_LARGE_FILE_SKIP_AFTER_FAILURES} failed large-file pushes for this watcher process (see issue #1786; use --exclude or offlineSyncExcludes to silence permanently)`
17030
17271
  );
17031
17272
  }
17032
17273
  const pulled = result.pull ? result.pull.upserted + result.pull.deleted : 0;
@@ -17041,11 +17282,11 @@ Environment fallbacks:
17041
17282
  failures: error.failures
17042
17283
  });
17043
17284
  largeFileFailureCounts = advanced.counts;
17044
- for (const path24 of advanced.newlySkipped) {
17045
- if (skippedLargeFiles.has(path24)) continue;
17046
- skippedLargeFiles.add(path24);
17285
+ for (const path25 of advanced.newlySkipped) {
17286
+ if (skippedLargeFiles.has(path25)) continue;
17287
+ skippedLargeFiles.add(path25);
17047
17288
  console.warn(
17048
- `offline sync: permanently skipping ${path24} after ${OFFLINE_LARGE_FILE_SKIP_AFTER_FAILURES} failed large-file pushes for this watcher process (see issue #1786; use --exclude or offlineSyncExcludes to silence permanently)`
17289
+ `offline sync: permanently skipping ${path25} after ${OFFLINE_LARGE_FILE_SKIP_AFTER_FAILURES} failed large-file pushes for this watcher process (see issue #1786; use --exclude or offlineSyncExcludes to silence permanently)`
17049
17290
  );
17050
17291
  }
17051
17292
  }
@@ -17186,7 +17427,7 @@ async function cmdConnectors(action, rest, json) {
17186
17427
  const connectorDaemonUrl = typeof effectiveConnectorConfig.remnicDaemonUrl === "string" && effectiveConnectorConfig.remnicDaemonUrl.trim().length > 0 ? effectiveConnectorConfig.remnicDaemonUrl.trim() : void 0;
17187
17428
  const pubResult = await pub.publish({
17188
17429
  config: { memoryDir, namespace: connectorNamespace, daemonUrl: connectorDaemonUrl },
17189
- skillsRoot: path23.join(memoryDir, "skills"),
17430
+ skillsRoot: path24.join(memoryDir, "skills"),
17190
17431
  rollbackTokenEntry: preInstallTokenEntry,
17191
17432
  log: { info: console.log, warn: console.warn, error: console.error }
17192
17433
  });
@@ -17546,15 +17787,15 @@ async function cmdConnectorsMarketplace(subAction, rest, json) {
17546
17787
  }
17547
17788
  const manifest = generateMarketplaceManifest();
17548
17789
  await writeMarketplaceManifest(outputDir, manifest);
17549
- const outPath = path23.join(outputDir, "marketplace.json");
17790
+ const outPath = path24.join(outputDir, "marketplace.json");
17550
17791
  if (json) {
17551
17792
  console.log(JSON.stringify({ status: "generated", path: outPath }, null, 2));
17552
17793
  } else {
17553
17794
  console.log(`Generated marketplace.json at ${outPath}`);
17554
17795
  }
17555
17796
  } else if (subAction === "validate") {
17556
- const targetPath = rest.filter((a) => !a.startsWith("--"))[0] ?? path23.join(process.cwd(), "marketplace.json");
17557
- const resolved = path23.resolve(targetPath);
17797
+ const targetPath = rest.filter((a) => !a.startsWith("--"))[0] ?? path24.join(process.cwd(), "marketplace.json");
17798
+ const resolved = path24.resolve(targetPath);
17558
17799
  if (!fs32.existsSync(resolved)) {
17559
17800
  console.error(`File not found: ${resolved}`);
17560
17801
  process.exit(1);
@@ -17970,7 +18211,7 @@ async function cmdBench(rest) {
17970
18211
  }
17971
18212
  const completeCount = prevStatus.benchmarks.filter((b) => b.status === "complete").length;
17972
18213
  const failedCount = prevStatus.benchmarks.filter((b) => b.status === "failed").length;
17973
- printBenchStatusLine(parsed.json, `Resuming from: ${path23.basename(latestStatusPath)}`);
18214
+ printBenchStatusLine(parsed.json, `Resuming from: ${path24.basename(latestStatusPath)}`);
17974
18215
  printBenchStatusLine(parsed.json, ` Previous run: ${prevStatus.startedAt}`);
17975
18216
  printBenchStatusLine(parsed.json, ` Benchmarks: ${prevStatus.benchmarks.length} total, ${completeCount} complete, ${failedCount} failed`);
17976
18217
  const before = selectedBenchmarks.length;
@@ -18135,9 +18376,9 @@ Options:
18135
18376
  );
18136
18377
  process.exit(1);
18137
18378
  } else {
18138
- fixturePath = path23.resolve(expandTilde(fixturePathRaw));
18379
+ fixturePath = path24.resolve(expandTilde(fixturePathRaw));
18139
18380
  }
18140
- const outPath = path23.resolve(expandTilde(outPathRaw));
18381
+ const outPath = path24.resolve(expandTilde(outPathRaw));
18141
18382
  const benchModule = await loadBenchModule();
18142
18383
  const runner = benchModule.runProceduralAblationCli;
18143
18384
  if (typeof runner !== "function") {
@@ -18156,7 +18397,7 @@ Options:
18156
18397
  );
18157
18398
  console.log(`wrote ${outPath}`);
18158
18399
  }
18159
- var LOGS_DIR = path23.join(PID_DIR, "logs");
18400
+ var LOGS_DIR = path24.join(PID_DIR, "logs");
18160
18401
  var LAUNCHD_PLIST_PATHS = launchdPlistPaths(resolveHomeDir());
18161
18402
  var [LAUNCHD_PLIST_PATH] = LAUNCHD_PLIST_PATHS;
18162
18403
  var SYSTEMD_UNIT_PATHS = systemdUnitPaths(resolveHomeDir());
@@ -18233,7 +18474,7 @@ function selectLaunchdInspection(openclawPluginModeConfigured) {
18233
18474
  for (const plistPath of LAUNCHD_PLIST_PATHS.slice(1)) {
18234
18475
  const legacy = inspectLaunchdPlist(plistPath);
18235
18476
  if (!legacy.installed) continue;
18236
- const label = path23.basename(plistPath, ".plist");
18477
+ const label = path24.basename(plistPath, ".plist");
18237
18478
  return legacy.ok ? {
18238
18479
  ...legacy,
18239
18480
  warn: true,
@@ -18267,10 +18508,10 @@ function daemonInstall() {
18267
18508
  const vars = { HOME: home, NODE_PATH: nodePath, REMNIC_SERVER_BIN: serverBin };
18268
18509
  fs32.mkdirSync(LOGS_DIR, { recursive: true });
18269
18510
  if (isMacOS()) {
18270
- const templatePath = path23.resolve(import.meta.dirname, "../templates/launchd/ai.remnic.daemon.plist");
18511
+ const templatePath = path24.resolve(import.meta.dirname, "../templates/launchd/ai.remnic.daemon.plist");
18271
18512
  const template = fs32.readFileSync(templatePath, "utf8");
18272
18513
  const plist = renderTemplate(template, vars);
18273
- fs32.mkdirSync(path23.dirname(LAUNCHD_PLIST_PATH), { recursive: true });
18514
+ fs32.mkdirSync(path24.dirname(LAUNCHD_PLIST_PATH), { recursive: true });
18274
18515
  fs32.writeFileSync(LAUNCHD_PLIST_PATH, plist);
18275
18516
  try {
18276
18517
  launchdLoadPlist(LAUNCHD_PLIST_PATH);
@@ -18287,10 +18528,10 @@ function daemonInstall() {
18287
18528
  console.log(` RunAtLoad: true, KeepAlive: true`);
18288
18529
  console.log(` Logs: ${LOGS_DIR}/daemon.log`);
18289
18530
  } else if (isLinux()) {
18290
- const templatePath = path23.resolve(import.meta.dirname, "../templates/systemd/remnic.service");
18531
+ const templatePath = path24.resolve(import.meta.dirname, "../templates/systemd/remnic.service");
18291
18532
  const template = fs32.readFileSync(templatePath, "utf8");
18292
18533
  const unit = renderTemplate(template, vars);
18293
- fs32.mkdirSync(path23.dirname(SYSTEMD_UNIT_PATH), { recursive: true });
18534
+ fs32.mkdirSync(path24.dirname(SYSTEMD_UNIT_PATH), { recursive: true });
18294
18535
  fs32.writeFileSync(SYSTEMD_UNIT_PATH, unit);
18295
18536
  try {
18296
18537
  childProcess2.execSync("systemctl --user daemon-reload", { stdio: "pipe" });
@@ -18789,7 +19030,7 @@ Clean complete: cleaned=${result.cleaned}`
18789
19030
  }
18790
19031
  async function cmdOpenclawInstall(opts) {
18791
19032
  const configPath = resolveOpenclawConfigPath(opts.configPath);
18792
- const fallbackMemoryDir = path23.join(resolveOpenclawStateDir(), "workspace", "memory", "local");
19033
+ const fallbackMemoryDir = path24.join(resolveOpenclawStateDir(), "workspace", "memory", "local");
18793
19034
  console.log(`OpenClaw config: ${configPath}`);
18794
19035
  const existingConfig = readOpenclawConfig(configPath);
18795
19036
  const { plugins, entries, slots } = parseOpenclawPluginState(existingConfig, configPath);
@@ -18892,7 +19133,7 @@ Remove it first and re-run, or choose a different path with --memory-dir.`
18892
19133
  fs32.mkdirSync(memoryDir, { recursive: true });
18893
19134
  console.log(`Created memory directory: ${memoryDir}`);
18894
19135
  }
18895
- const configDir = path23.dirname(configPath);
19136
+ const configDir = path24.dirname(configPath);
18896
19137
  if (!fs32.existsSync(configDir)) {
18897
19138
  fs32.mkdirSync(configDir, { recursive: true });
18898
19139
  }
@@ -18921,12 +19162,12 @@ async function cmdOpenclawUpgrade(opts) {
18921
19162
  const pluginDir = resolveOpenclawPluginDir(opts.pluginDir);
18922
19163
  const managedTargetDir = resolveOpenclawManagedPluginDir();
18923
19164
  const legacyPluginDirForBackup = opts.legacyPluginDirForBackup ? resolveOpenclawLegacyPluginDir(opts.legacyPluginDirForBackup) : void 0;
18924
- const fallbackMemoryDir = path23.join(resolveOpenclawStateDir(), "workspace", "memory", "local");
19165
+ const fallbackMemoryDir = path24.join(resolveOpenclawStateDir(), "workspace", "memory", "local");
18925
19166
  const packageSpec = buildOpenclawManagedUpgradePackageSpec(opts.version);
18926
19167
  const configExistedBefore = fs32.existsSync(configPath);
18927
19168
  const existingConfig = readOpenclawConfig(configPath);
18928
19169
  const { entries, slots } = parseOpenclawPluginState(existingConfig, configPath);
18929
- const preservedMemoryDir = opts.memoryDir ? path23.resolve(expandTilde(opts.memoryDir)) : resolveCurrentOpenclawMemoryDir(entries, slots, fallbackMemoryDir);
19170
+ const preservedMemoryDir = opts.memoryDir ? path24.resolve(expandTilde(opts.memoryDir)) : resolveCurrentOpenclawMemoryDir(entries, slots, fallbackMemoryDir);
18930
19171
  console.log(`OpenClaw config: ${configPath}`);
18931
19172
  console.log(`Plugin dir: ${pluginDir}`);
18932
19173
  if (legacyPluginDirForBackup) {
@@ -18934,7 +19175,7 @@ async function cmdOpenclawUpgrade(opts) {
18934
19175
  }
18935
19176
  console.log(`Memory dir: ${preservedMemoryDir}`);
18936
19177
  console.log(`Package spec: ${packageSpec}`);
18937
- console.log(`Backup root: ${path23.join(resolveOpenclawStateDir(), "backups")}`);
19178
+ console.log(`Backup root: ${path24.join(resolveOpenclawStateDir(), "backups")}`);
18938
19179
  const plannedActions = [
18939
19180
  `backup openclaw.json and the existing ${REMNIC_OPENCLAW_PLUGIN_ID} extension`,
18940
19181
  ...legacyPluginDirForBackup ? [`backup the existing ${REMNIC_OPENCLAW_LEGACY_PLUGIN_ID} extension without modifying it`] : [],
@@ -18972,9 +19213,9 @@ async function cmdOpenclawUpgrade(opts) {
18972
19213
  assertDirectoryPathOrMissing(legacyPluginDirForBackup, "Legacy OpenClaw plugin dir");
18973
19214
  }
18974
19215
  const backupDir = createOpenclawUpgradeBackupDir();
18975
- const configBackupPath = path23.join(backupDir, "openclaw.json");
18976
- const pluginBackupDir = path23.join(backupDir, "extensions", REMNIC_OPENCLAW_PLUGIN_ID);
18977
- const legacyPluginBackupDir = legacyPluginDirForBackup ? path23.join(backupDir, "extensions", REMNIC_OPENCLAW_LEGACY_PLUGIN_ID) : void 0;
19216
+ const configBackupPath = path24.join(backupDir, "openclaw.json");
19217
+ const pluginBackupDir = path24.join(backupDir, "extensions", REMNIC_OPENCLAW_PLUGIN_ID);
19218
+ const legacyPluginBackupDir = legacyPluginDirForBackup ? path24.join(backupDir, "extensions", REMNIC_OPENCLAW_LEGACY_PLUGIN_ID) : void 0;
18978
19219
  const backupNotes = [];
18979
19220
  if (backupPathIfPresent(configPath, configBackupPath)) {
18980
19221
  backupNotes.push(`+ Backed up config to ${configBackupPath}`);
@@ -19024,7 +19265,7 @@ async function cmdOpenclawUpgrade(opts) {
19024
19265
  const managedRollbackDir = publishedInstallError ? publishedInstallError.managedRollbackDir : installResult?.managedRollbackDir;
19025
19266
  const managedRollbackTargetDir = publishedInstallError?.managedRollbackTargetDir ?? installResult?.managedRollbackTargetDir ?? managedTargetDir;
19026
19267
  const requiresHostManagedRestore = publishedInstallError?.requiresHostManagedRestore ?? installResult?.requiresHostManagedRestore ?? false;
19027
- const managedRollbackSharesPluginDir = managedRollbackDir && path23.resolve(managedRollbackTargetDir) === path23.resolve(pluginDir);
19268
+ const managedRollbackSharesPluginDir = managedRollbackDir && path24.resolve(managedRollbackTargetDir) === path24.resolve(pluginDir);
19028
19269
  const pluginRollbackDir = managedRollbackSharesPluginDir ? requiresHostManagedRestore ? rollbackDir : rollbackDir ?? managedRollbackDir : rollbackDir;
19029
19270
  const shouldRestorePlugin = Boolean(
19030
19271
  installResult && !requiresHostManagedRestore || pluginRollbackDir || publishedInstallError?.shouldRestoreBackup
@@ -19081,7 +19322,7 @@ async function cmdOpenclawUpgrade(opts) {
19081
19322
  rollbackErrors.push(error);
19082
19323
  }
19083
19324
  if (pendingConfigRestoreError) rollbackErrors.push(pendingConfigRestoreError);
19084
- if (managedRollbackDir && path23.resolve(managedRollbackTargetDir) !== path23.resolve(pluginDir) && !requiresHostManagedRestore) {
19325
+ if (managedRollbackDir && path24.resolve(managedRollbackTargetDir) !== path24.resolve(pluginDir) && !requiresHostManagedRestore) {
19085
19326
  try {
19086
19327
  rollbackNotes.push(
19087
19328
  ...rollbackOpenclawUpgrade({
@@ -19147,9 +19388,9 @@ async function cmdOpenclawMigrateEngram(opts) {
19147
19388
  console.log(" - Re-apply any local source patches to the new package only after verifying the published build.");
19148
19389
  }
19149
19390
  function createOpenclawUpgradeBackupDir() {
19150
- const backupsRoot = path23.join(resolveOpenclawStateDir(), "backups");
19391
+ const backupsRoot = path24.join(resolveOpenclawStateDir(), "backups");
19151
19392
  fs32.mkdirSync(backupsRoot, { recursive: true });
19152
- return fs32.mkdtempSync(path23.join(backupsRoot, `remnic-openclaw-upgrade-${formatOpenclawUpgradeStamp()}-`));
19393
+ return fs32.mkdtempSync(path24.join(backupsRoot, `remnic-openclaw-upgrade-${formatOpenclawUpgradeStamp()}-`));
19153
19394
  }
19154
19395
  async function cmdTaxonomy(rest) {
19155
19396
  initLogger5();
@@ -19191,8 +19432,8 @@ async function cmdTaxonomy(rest) {
19191
19432
  const doc = generateResolverDocument(taxonomy);
19192
19433
  console.log(doc);
19193
19434
  if (config.taxonomyAutoGenResolver) {
19194
- const resolverPath = path23.join(config.memoryDir, ".taxonomy", "RESOLVER.md");
19195
- fs32.mkdirSync(path23.dirname(resolverPath), { recursive: true });
19435
+ const resolverPath = path24.join(config.memoryDir, ".taxonomy", "RESOLVER.md");
19436
+ fs32.mkdirSync(path24.dirname(resolverPath), { recursive: true });
19196
19437
  fs32.writeFileSync(resolverPath, doc);
19197
19438
  console.error(`Written: ${resolverPath}`);
19198
19439
  }
@@ -19238,7 +19479,7 @@ async function cmdTaxonomy(rest) {
19238
19479
  console.log(`Added category "${id}" (${name}).`);
19239
19480
  if (config.taxonomyAutoGenResolver) {
19240
19481
  const doc = generateResolverDocument(taxonomy);
19241
- const resolverPath = path23.join(config.memoryDir, ".taxonomy", "RESOLVER.md");
19482
+ const resolverPath = path24.join(config.memoryDir, ".taxonomy", "RESOLVER.md");
19242
19483
  fs32.writeFileSync(resolverPath, doc);
19243
19484
  console.error(`Regenerated: ${resolverPath}`);
19244
19485
  }
@@ -19269,7 +19510,7 @@ async function cmdTaxonomy(rest) {
19269
19510
  console.log(`Removed category "${id}".`);
19270
19511
  if (config.taxonomyAutoGenResolver) {
19271
19512
  const doc = generateResolverDocument(taxonomy);
19272
- const resolverPath = path23.join(config.memoryDir, ".taxonomy", "RESOLVER.md");
19513
+ const resolverPath = path24.join(config.memoryDir, ".taxonomy", "RESOLVER.md");
19273
19514
  fs32.writeFileSync(resolverPath, doc);
19274
19515
  console.error(`Regenerated: ${resolverPath}`);
19275
19516
  }
@@ -19551,7 +19792,7 @@ async function runTrainingExport(args, stdout = process.stdout) {
19551
19792
  );
19552
19793
  }
19553
19794
  const formatted = adapter.formatRecords(records);
19554
- const outDir = path23.dirname(args.output);
19795
+ const outDir = path24.dirname(args.output);
19555
19796
  fs32.mkdirSync(outDir, { recursive: true });
19556
19797
  const tmpPath = `${args.output}.tmp-${process.pid}-${Date.now()}`;
19557
19798
  fs32.writeFileSync(tmpPath, formatted, "utf-8");
@@ -19680,7 +19921,7 @@ async function main(argv = process.argv.slice(2)) {
19680
19921
  case "tree": {
19681
19922
  const subAction = rest[0];
19682
19923
  const json = rest.includes("--json");
19683
- const outputDir = resolveFlag(rest, "--output") ?? path23.join(process.cwd(), ".remnic", "context-tree");
19924
+ const outputDir = resolveFlag(rest, "--output") ?? path24.join(process.cwd(), ".remnic", "context-tree");
19684
19925
  const categoriesFlag = resolveFlag(rest, "--categories");
19685
19926
  const categories = categoriesFlag ? categoriesFlag.split(",") : void 0;
19686
19927
  const maxPerCategoryRaw = resolveFlag(rest, "--max-per-category");
@@ -19757,7 +19998,7 @@ async function main(argv = process.argv.slice(2)) {
19757
19998
  console.error(`Context tree not found at ${treeDir}. Run 'remnic tree generate' first.`);
19758
19999
  process.exit(1);
19759
20000
  }
19760
- const indexPath = path23.join(treeDir, "INDEX.md");
20001
+ const indexPath = path24.join(treeDir, "INDEX.md");
19761
20002
  if (!fs32.existsSync(indexPath)) {
19762
20003
  console.error(`INDEX.md missing in ${treeDir}. Tree may be corrupt \u2014 regenerate.`);
19763
20004
  process.exit(1);
@@ -20370,6 +20611,7 @@ export {
20370
20611
  chunkOfflineChangesetApplyBatches,
20371
20612
  chunkOfflineFileContentBatches,
20372
20613
  directHydrateLargeOfflineFiles,
20614
+ divergedEmbeddingGenerationDeferrals2 as divergedEmbeddingGenerationDeferrals,
20373
20615
  extractWhyRawArgs,
20374
20616
  extractXrayRawArgs,
20375
20617
  fetchOfflineSnapshot,
@@ -20377,6 +20619,7 @@ export {
20377
20619
  formatOfflineRequestForError,
20378
20620
  hasFlag,
20379
20621
  hashCalibrationProviderConfig,
20622
+ hydrateOfflineFileContent,
20380
20623
  hydrateOfflineSnapshotContent,
20381
20624
  isOfflineMissingContentDeferrablePath,
20382
20625
  isOfflineSnapshotPostFallbackError,