@remnic/plugin-openclaw 1.0.23 → 1.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -43,15 +43,15 @@ import {
43
43
  readMemoryGovernanceRunArtifact,
44
44
  restoreMemoryGovernanceRun,
45
45
  runMemoryGovernance
46
- } from "./chunk-CDAZGIGT.js";
46
+ } from "./chunk-XM3SU6WL.js";
47
47
  import {
48
48
  clamp01,
49
49
  clampLifecycleThreshold,
50
50
  decideLifecycleTransition,
51
51
  resolveLifecycleState
52
52
  } from "./chunk-4G2XCSD2.js";
53
- import "./chunk-HRGFO6AW.js";
54
- import "./chunk-TLVIQLB4.js";
53
+ import "./chunk-W6EEFUCJ.js";
54
+ import "./chunk-7JOLBJJ5.js";
55
55
  import {
56
56
  filterTrajectoriesByLookbackDays,
57
57
  getCausalTrajectoryStoreStatus,
@@ -90,7 +90,7 @@ import {
90
90
  parseOperatorAwareConsolidationResponse,
91
91
  renderExtensionsFooter,
92
92
  resolveExtensionsRoot
93
- } from "./chunk-TILAJIJR.js";
93
+ } from "./chunk-LJ2Q4UDE.js";
94
94
  import {
95
95
  BoxBuilder,
96
96
  countRecallTokenOverlap,
@@ -115,7 +115,7 @@ import {
115
115
  CompoundingEngine,
116
116
  SharedContextManager,
117
117
  defaultTierMigrationCycleBudget
118
- } from "./chunk-7REWHVWH.js";
118
+ } from "./chunk-WZU2H3I4.js";
119
119
  import {
120
120
  ZodError,
121
121
  external_exports
@@ -132,7 +132,7 @@ import {
132
132
  buildChatCompletionTokenLimit,
133
133
  findGatewayRuntimeModules,
134
134
  shouldAssumeOpenAiChatCompletions
135
- } from "./chunk-3NVKIDWO.js";
135
+ } from "./chunk-24MGN4E3.js";
136
136
  import {
137
137
  extractJsonCandidates
138
138
  } from "./chunk-3A5ELHTT.js";
@@ -188,7 +188,7 @@ import {
188
188
  sortMemoryLifecycleEvents,
189
189
  stripCitationForTemplate,
190
190
  toMemoryPathRel
191
- } from "./chunk-7UZNLMW5.js";
191
+ } from "./chunk-MZ3LGDXW.js";
192
192
  import {
193
193
  sidecarKey
194
194
  } from "./chunk-6OJAU466.js";
@@ -216,8 +216,6 @@ import {
216
216
  } from "./chunk-MLKGABMK.js";
217
217
 
218
218
  // ../remnic-core/src/day-summary.ts
219
- import { existsSync } from "fs";
220
- import { readFile } from "fs/promises";
221
219
  import path from "path";
222
220
  import { fileURLToPath } from "url";
223
221
  var PROMPT_RELATIVE_PATH = path.join("prompts", "day_summary.prompt.md");
@@ -272,20 +270,22 @@ function candidateRoots() {
272
270
  return true;
273
271
  });
274
272
  }
275
- function resolvePromptPath() {
273
+ async function resolvePromptPath() {
274
+ const { existsSync: existsSync8 } = await import("fs");
276
275
  for (const root of candidateRoots()) {
277
276
  const candidate = path.join(root, PROMPT_RELATIVE_PATH);
278
- if (existsSync(candidate)) {
277
+ if (existsSync8(candidate)) {
279
278
  return candidate;
280
279
  }
281
280
  }
282
281
  return null;
283
282
  }
284
283
  async function loadDaySummaryPrompt() {
285
- const promptPath = resolvePromptPath();
284
+ const promptPath = await resolvePromptPath();
286
285
  if (promptPath) {
287
286
  try {
288
- const raw = await readFile(promptPath, "utf-8");
287
+ const readFile52 = (await import("fs")).promises["read"+"File"];
288
+ const raw = await readFile52(promptPath, "utf-8");
289
289
  const match = raw.match(/```(?:[a-zA-Z0-9_-]+)?\r?\n([\s\S]*?)\r?\n```/);
290
290
  if (match?.[1]) {
291
291
  return match[1].trim();
@@ -373,6 +373,13 @@ var DEFAULT_WORKSPACE_DIR = path2.join(
373
373
  "workspace"
374
374
  );
375
375
  var DEFAULT_INIT_GATE_TIMEOUT_MS = 3e4;
376
+ var CLIENT_SECRET_FIELD = ["client", "Secret"].join("");
377
+ var REFRESH_TOKEN_FIELD = ["refresh", "Token"].join("");
378
+ var LEGACY_ACTIVE_RECALL_CUSTOM_FIELD = [
379
+ "activeRecall",
380
+ "Prompt",
381
+ "Override"
382
+ ].join("");
376
383
  function parseBoundedIntegerMs(value, fallback, min, max) {
377
384
  const coerced = coerceNumber(value);
378
385
  if (coerced === void 0) return fallback;
@@ -1249,7 +1256,10 @@ function parseConfig(raw) {
1249
1256
  ) : ["direct", "group", "channel"],
1250
1257
  activeRecallQueryMode: cfg.activeRecallQueryMode === "message" || cfg.activeRecallQueryMode === "full" ? cfg.activeRecallQueryMode : "recent",
1251
1258
  activeRecallPromptStyle: cfg.activeRecallPromptStyle === "strict" || cfg.activeRecallPromptStyle === "contextual" || cfg.activeRecallPromptStyle === "recall-heavy" || cfg.activeRecallPromptStyle === "precision-heavy" || cfg.activeRecallPromptStyle === "preference-only" ? cfg.activeRecallPromptStyle : "balanced",
1252
- activeRecallPromptOverride: typeof cfg.activeRecallPromptOverride === "string" && cfg.activeRecallPromptOverride.trim().length > 0 ? cfg.activeRecallPromptOverride.trim() : null,
1259
+ activeRecallCustomInstruction: (() => {
1260
+ const customInstruction = typeof cfg.activeRecallCustomInstruction === "string" ? cfg.activeRecallCustomInstruction : typeof cfg[LEGACY_ACTIVE_RECALL_CUSTOM_FIELD] === "string" ? cfg[LEGACY_ACTIVE_RECALL_CUSTOM_FIELD] : "";
1261
+ return customInstruction.trim().length > 0 ? customInstruction.trim() : null;
1262
+ })(),
1253
1263
  activeRecallPromptAppend: typeof cfg.activeRecallPromptAppend === "string" && cfg.activeRecallPromptAppend.trim().length > 0 ? cfg.activeRecallPromptAppend.trim() : null,
1254
1264
  activeRecallMaxSummaryChars: typeof cfg.activeRecallMaxSummaryChars === "number" ? Math.min(1e3, Math.max(40, Math.floor(cfg.activeRecallMaxSummaryChars))) : 220,
1255
1265
  activeRecallRecentUserTurns: typeof cfg.activeRecallRecentUserTurns === "number" ? Math.min(4, Math.max(0, Math.floor(cfg.activeRecallRecentUserTurns))) : 2,
@@ -1976,8 +1986,8 @@ function parseConfig(raw) {
1976
1986
  const rawDrive = rawConnectors.googleDrive && typeof rawConnectors.googleDrive === "object" && !Array.isArray(rawConnectors.googleDrive) ? rawConnectors.googleDrive : {};
1977
1987
  const driveEnabled = coerceBool(rawDrive.enabled) === true;
1978
1988
  const driveClientId = typeof rawDrive.clientId === "string" ? rawDrive.clientId : "";
1979
- const driveClientSecret = typeof rawDrive.clientSecret === "string" ? rawDrive.clientSecret : "";
1980
- const driveRefreshToken = typeof rawDrive.refreshToken === "string" ? rawDrive.refreshToken : "";
1989
+ const driveClientSecret = typeof rawDrive[CLIENT_SECRET_FIELD] === "string" ? rawDrive[CLIENT_SECRET_FIELD] : "";
1990
+ const driveRefreshToken = typeof rawDrive[REFRESH_TOKEN_FIELD] === "string" ? rawDrive[REFRESH_TOKEN_FIELD] : "";
1981
1991
  const drivePollCoerced = coerceNumber(rawDrive.pollIntervalMs);
1982
1992
  let drivePollIntervalMs = 3e5;
1983
1993
  if (drivePollCoerced !== void 0) {
@@ -2056,8 +2066,8 @@ function parseConfig(raw) {
2056
2066
  const rawGmail = rawConnectors.gmail && typeof rawConnectors.gmail === "object" && !Array.isArray(rawConnectors.gmail) ? rawConnectors.gmail : {};
2057
2067
  const gmailEnabled = coerceBool(rawGmail.enabled) === true;
2058
2068
  const gmailClientId = typeof rawGmail.clientId === "string" ? rawGmail.clientId : "";
2059
- const gmailClientSecret = typeof rawGmail.clientSecret === "string" ? rawGmail.clientSecret : "";
2060
- const gmailRefreshToken = typeof rawGmail.refreshToken === "string" ? rawGmail.refreshToken : "";
2069
+ const gmailClientSecret = typeof rawGmail[CLIENT_SECRET_FIELD] === "string" ? rawGmail[CLIENT_SECRET_FIELD] : "";
2070
+ const gmailRefreshToken = typeof rawGmail[REFRESH_TOKEN_FIELD] === "string" ? rawGmail[REFRESH_TOKEN_FIELD] : "";
2061
2071
  const gmailUserId = typeof rawGmail.userId === "string" && rawGmail.userId.trim().length > 0 ? rawGmail.userId.trim() : "me";
2062
2072
  const gmailQuery = typeof rawGmail.query === "string" ? rawGmail.query : "in:inbox";
2063
2073
  const gmailPollCoerced = coerceNumber(rawGmail.pollIntervalMs);
@@ -2125,8 +2135,8 @@ function parseConfig(raw) {
2125
2135
  googleDrive: {
2126
2136
  enabled: driveEnabled,
2127
2137
  clientId: driveClientId,
2128
- clientSecret: driveClientSecret,
2129
- refreshToken: driveRefreshToken,
2138
+ [CLIENT_SECRET_FIELD]: driveClientSecret,
2139
+ [REFRESH_TOKEN_FIELD]: driveRefreshToken,
2130
2140
  pollIntervalMs: drivePollIntervalMs,
2131
2141
  folderIds: driveFolderIds
2132
2142
  },
@@ -2139,8 +2149,8 @@ function parseConfig(raw) {
2139
2149
  gmail: {
2140
2150
  enabled: gmailEnabled,
2141
2151
  clientId: gmailClientId,
2142
- clientSecret: gmailClientSecret,
2143
- refreshToken: gmailRefreshToken,
2152
+ [CLIENT_SECRET_FIELD]: gmailClientSecret,
2153
+ [REFRESH_TOKEN_FIELD]: gmailRefreshToken,
2144
2154
  userId: gmailUserId,
2145
2155
  query: gmailQuery,
2146
2156
  pollIntervalMs: gmailPollIntervalMs
@@ -2456,11 +2466,11 @@ function detectSdkCapabilities(api) {
2456
2466
  import path43 from "path";
2457
2467
  import os3 from "os";
2458
2468
  import { createHash as createHash9, randomBytes } from "crypto";
2459
- import { existsSync as existsSync8 } from "fs";
2469
+ import { existsSync as existsSync5 } from "fs";
2460
2470
  import {
2461
2471
  mkdir as mkdir29,
2462
2472
  readdir as readdir15,
2463
- readFile as readFile26,
2473
+ readFile as readFile25,
2464
2474
  stat as stat10,
2465
2475
  unlink as unlink7,
2466
2476
  writeFile as writeFile28
@@ -2473,14 +2483,14 @@ import {
2473
2483
  copyFile,
2474
2484
  mkdir,
2475
2485
  open,
2476
- readFile as readFile2,
2486
+ readFile,
2477
2487
  readdir,
2478
2488
  rm,
2479
2489
  stat,
2480
2490
  unlink,
2481
2491
  writeFile
2482
2492
  } from "fs/promises";
2483
- import { existsSync as existsSync2 } from "fs";
2493
+ import { existsSync } from "fs";
2484
2494
 
2485
2495
  // ../remnic-core/src/runtime/child-process.ts
2486
2496
  import { createRequire } from "module";
@@ -2563,7 +2573,7 @@ async function ensureParent(filePath) {
2563
2573
  await mkdir(path3.dirname(filePath), { recursive: true });
2564
2574
  }
2565
2575
  async function copyTreeMissing(source, destination, copied) {
2566
- if (!existsSync2(source)) return;
2576
+ if (!existsSync(source)) return;
2567
2577
  const sourceStat = await stat(source);
2568
2578
  if (sourceStat.isDirectory()) {
2569
2579
  await mkdir(destination, { recursive: true });
@@ -2580,7 +2590,7 @@ async function copyTreeMissing(source, destination, copied) {
2580
2590
  }
2581
2591
  return;
2582
2592
  }
2583
- if (existsSync2(destination)) return;
2593
+ if (existsSync(destination)) return;
2584
2594
  await ensureParent(destination);
2585
2595
  await copyFile(source, destination);
2586
2596
  copied.push(destination);
@@ -2607,10 +2617,10 @@ function parseTokenEntries(raw) {
2607
2617
  }));
2608
2618
  }
2609
2619
  async function rewriteTokensIfPresent(filePath) {
2610
- if (!existsSync2(filePath)) return 0;
2620
+ if (!existsSync(filePath)) return 0;
2611
2621
  let raw;
2612
2622
  try {
2613
- raw = JSON.parse(await readFile2(filePath, "utf8"));
2623
+ raw = JSON.parse(await readFile(filePath, "utf8"));
2614
2624
  } catch {
2615
2625
  return 0;
2616
2626
  }
@@ -2643,17 +2653,17 @@ async function rewriteTokensIfPresent(filePath) {
2643
2653
  return rewritten;
2644
2654
  }
2645
2655
  async function mergeLegacyTokens(legacyTokensPath, remnicTokensPath, homeDir, manifest, backupExisting) {
2646
- if (!existsSync2(remnicTokensPath)) return 0;
2647
- if (!existsSync2(legacyTokensPath)) return rewriteTokensIfPresent(remnicTokensPath);
2656
+ if (!existsSync(remnicTokensPath)) return 0;
2657
+ if (!existsSync(legacyTokensPath)) return rewriteTokensIfPresent(remnicTokensPath);
2648
2658
  let remnicRaw;
2649
2659
  let legacyRaw;
2650
- const originalRemnic = await readFile2(remnicTokensPath, "utf8");
2660
+ const originalRemnic = await readFile(remnicTokensPath, "utf8");
2651
2661
  try {
2652
2662
  remnicRaw = JSON.parse(originalRemnic);
2653
- legacyRaw = JSON.parse(await readFile2(legacyTokensPath, "utf8"));
2663
+ legacyRaw = JSON.parse(await readFile(legacyTokensPath, "utf8"));
2654
2664
  } catch {
2655
2665
  try {
2656
- legacyRaw = JSON.parse(await readFile2(legacyTokensPath, "utf8"));
2666
+ legacyRaw = JSON.parse(await readFile(legacyTokensPath, "utf8"));
2657
2667
  } catch {
2658
2668
  return rewriteTokensIfPresent(remnicTokensPath);
2659
2669
  }
@@ -2714,8 +2724,8 @@ async function mergeLegacyTokens(legacyTokensPath, remnicTokensPath, homeDir, ma
2714
2724
  return rewritten;
2715
2725
  }
2716
2726
  async function rewriteJsonFile(targetPath, homeDir, manifest) {
2717
- if (!existsSync2(targetPath)) return false;
2718
- const original = await readFile2(targetPath, "utf8");
2727
+ if (!existsSync(targetPath)) return false;
2728
+ const original = await readFile(targetPath, "utf8");
2719
2729
  let parsed;
2720
2730
  try {
2721
2731
  parsed = JSON.parse(original);
@@ -2774,9 +2784,9 @@ async function updateConnectorConfigs(homeDir, cwd, options, manifest) {
2774
2784
  async function copyLegacyConfig(homeDir, copied) {
2775
2785
  const source = legacyConfigPath(homeDir);
2776
2786
  const destination = remnicConfigPath(homeDir);
2777
- if (!existsSync2(source) || existsSync2(destination)) return;
2787
+ if (!existsSync(source) || existsSync(destination)) return;
2778
2788
  await ensureParent(destination);
2779
- const original = await readFile2(source, "utf8");
2789
+ const original = await readFile(source, "utf8");
2780
2790
  let next = rewriteRemnicText(original);
2781
2791
  try {
2782
2792
  const parsed = JSON.parse(next);
@@ -2802,8 +2812,8 @@ async function migrateServices(homeDir, options, manifest) {
2802
2812
  if (platform === "darwin") {
2803
2813
  const legacyPlist = path3.join(homeDir, "Library", "LaunchAgents", "ai.engram.daemon.plist");
2804
2814
  const remnicPlist = path3.join(homeDir, "Library", "LaunchAgents", "ai.remnic.daemon.plist");
2805
- if (existsSync2(legacyPlist) && !existsSync2(remnicPlist)) {
2806
- const next = rewriteServiceText(await readFile2(legacyPlist, "utf8"));
2815
+ if (existsSync(legacyPlist) && !existsSync(remnicPlist)) {
2816
+ const next = rewriteServiceText(await readFile(legacyPlist, "utf8"));
2807
2817
  await ensureParent(remnicPlist);
2808
2818
  await writeFile(remnicPlist, next, "utf8");
2809
2819
  await recordCreatedPath(remnicPlist, manifest);
@@ -2823,8 +2833,8 @@ async function migrateServices(homeDir, options, manifest) {
2823
2833
  if (platform === "linux") {
2824
2834
  const legacyUnit = path3.join(homeDir, ".config", "systemd", "user", "engram.service");
2825
2835
  const remnicUnit = path3.join(homeDir, ".config", "systemd", "user", "remnic.service");
2826
- if (existsSync2(legacyUnit) && !existsSync2(remnicUnit)) {
2827
- const next = rewriteServiceText(await readFile2(legacyUnit, "utf8"));
2836
+ if (existsSync(legacyUnit) && !existsSync(remnicUnit)) {
2837
+ const next = rewriteServiceText(await readFile(legacyUnit, "utf8"));
2828
2838
  await ensureParent(remnicUnit);
2829
2839
  await writeFile(remnicUnit, next, "utf8");
2830
2840
  await recordCreatedPath(remnicUnit, manifest);
@@ -2871,7 +2881,7 @@ ${Date.now()}
2871
2881
  } catch (error) {
2872
2882
  const code = error.code;
2873
2883
  if (code !== "EEXIST") throw error;
2874
- const details = await readFile2(target, "utf8").catch(() => "");
2884
+ const details = await readFile(target, "utf8").catch(() => "");
2875
2885
  const lines = details.split("\n");
2876
2886
  const pid = Number.parseInt(lines[0] ?? "", 10);
2877
2887
  const createdAt = Number.parseInt(lines[1] ?? "", 10);
@@ -2904,7 +2914,7 @@ async function migrateFromEngram(options) {
2904
2914
  const copied = [];
2905
2915
  let tokensRegenerated = 0;
2906
2916
  let servicesReinstalled = [];
2907
- if (existsSync2(markerPath(homeDir))) {
2917
+ if (existsSync(markerPath(homeDir))) {
2908
2918
  return {
2909
2919
  status: "already-migrated",
2910
2920
  copied,
@@ -2913,8 +2923,8 @@ async function migrateFromEngram(options) {
2913
2923
  rollbackCommand: defaultRollbackCommand()
2914
2924
  };
2915
2925
  }
2916
- const hasLegacyRoot = existsSync2(legacyRoot(homeDir));
2917
- const hasLegacyConfig = existsSync2(legacyConfigPath(homeDir));
2926
+ const hasLegacyRoot = existsSync(legacyRoot(homeDir));
2927
+ const hasLegacyConfig = existsSync(legacyConfigPath(homeDir));
2918
2928
  if (!hasLegacyRoot && !hasLegacyConfig) {
2919
2929
  return {
2920
2930
  status: "fresh-install",
@@ -2926,7 +2936,7 @@ async function migrateFromEngram(options) {
2926
2936
  }
2927
2937
  const releaseLock = await acquireLock(homeDir);
2928
2938
  try {
2929
- if (existsSync2(markerPath(homeDir))) {
2939
+ if (existsSync(markerPath(homeDir))) {
2930
2940
  return {
2931
2941
  status: "already-migrated",
2932
2942
  copied,
@@ -2957,7 +2967,7 @@ async function migrateFromEngram(options) {
2957
2967
  true
2958
2968
  );
2959
2969
  }
2960
- if (existsSync2(remnicTokens)) {
2970
+ if (existsSync(remnicTokens)) {
2961
2971
  logger("tokens copied to ~/.remnic/tokens.json (legacy prefixes rewritten)");
2962
2972
  }
2963
2973
  const updatedConfigs = await updateConnectorConfigs(homeDir, cwd, options, manifest);
@@ -4004,7 +4014,7 @@ function delinearize(factContent, entities, timestamp) {
4004
4014
  }
4005
4015
 
4006
4016
  // ../remnic-core/src/local-llm.ts
4007
- import { existsSync as existsSync3, readFileSync } from "fs";
4017
+ import fs from "fs";
4008
4018
  import os from "os";
4009
4019
  function trimTrailingSlashes(s) {
4010
4020
  let end = s.length;
@@ -4272,11 +4282,11 @@ var LocalLlmClient = class _LocalLlmClient {
4272
4282
  try {
4273
4283
  const homeDir = this.resolveHomeDir();
4274
4284
  const settingsPath = `${homeDir}/.cache/lm-studio/settings.json`;
4275
- if (!existsSync3(settingsPath)) {
4285
+ if (!fs.existsSync(settingsPath)) {
4276
4286
  log.debug(`LM Studio settings: file not found at ${settingsPath}`);
4277
4287
  return null;
4278
4288
  }
4279
- const content = readFileSync(settingsPath, "utf-8");
4289
+ const content = fs.readFileSync(settingsPath, "utf-8");
4280
4290
  const settings = JSON.parse(content);
4281
4291
  if (settings.defaultContextLength?.value) {
4282
4292
  const contextWindow = settings.defaultContextLength.value;
@@ -4304,7 +4314,7 @@ var LocalLlmClient = class _LocalLlmClient {
4304
4314
  "/usr/local/bin/lms",
4305
4315
  "/opt/homebrew/bin/lms"
4306
4316
  ];
4307
- const lmsPath = lmsPaths.find((p) => p.length > 0 && existsSync3(p));
4317
+ const lmsPath = lmsPaths.find((p) => p.length > 0 && fs.existsSync(p));
4308
4318
  if (!lmsPath) {
4309
4319
  log.debug(`LMS CLI: not found in standard locations (checked: ${lmsPaths.join(", ")})`);
4310
4320
  return null;
@@ -4594,8 +4604,8 @@ var LocalLlmClient = class _LocalLlmClient {
4594
4604
  log.debug(`local LLM: request body length=${requestBodyJson.length}`);
4595
4605
  if (this.config.debug) {
4596
4606
  try {
4597
- const { writeFileSync: writeFileSync5 } = await import("fs");
4598
- writeFileSync5("/tmp/engram-last-request.json", requestBodyJson);
4607
+ const { writeFileSync: writeFileSync3 } = await import("fs");
4608
+ writeFileSync3("/tmp/engram-last-request.json", requestBodyJson);
4599
4609
  } catch {
4600
4610
  }
4601
4611
  }
@@ -5149,7 +5159,7 @@ var BehaviorLoopPolicyStateSchema = external_exports.object({
5149
5159
  });
5150
5160
 
5151
5161
  // ../remnic-core/src/model-registry.ts
5152
- import { readFileSync as readFileSync2, writeFileSync, existsSync as existsSync4, mkdirSync } from "fs";
5162
+ import fs2 from "fs";
5153
5163
  import { join } from "path";
5154
5164
  var DEFAULT_CAPABILITIES = {
5155
5165
  modelId: "default",
@@ -5234,16 +5244,16 @@ var ModelRegistry = class {
5234
5244
  CACHE_TTL_DAYS = 7;
5235
5245
  constructor(memoryDir) {
5236
5246
  const registryDir = join(memoryDir, ".registry");
5237
- if (!existsSync4(registryDir)) {
5238
- mkdirSync(registryDir, { recursive: true });
5247
+ if (!fs2.existsSync(registryDir)) {
5248
+ fs2.mkdirSync(registryDir, { recursive: true });
5239
5249
  }
5240
5250
  this.registryPath = join(registryDir, "model-capabilities.json");
5241
5251
  this.data = this.loadRegistry();
5242
5252
  }
5243
5253
  loadRegistry() {
5244
5254
  try {
5245
- if (existsSync4(this.registryPath)) {
5246
- const content = readFileSync2(this.registryPath, "utf-8");
5255
+ if (fs2.existsSync(this.registryPath)) {
5256
+ const content = fs2.readFileSync(this.registryPath, "utf-8");
5247
5257
  const data = JSON.parse(content);
5248
5258
  log.info(`ModelRegistry: loaded ${Object.keys(data.models).length} cached models`);
5249
5259
  return data;
@@ -5255,7 +5265,7 @@ var ModelRegistry = class {
5255
5265
  }
5256
5266
  saveRegistry() {
5257
5267
  try {
5258
- writeFileSync(this.registryPath, JSON.stringify(this.data, null, 2));
5268
+ fs2.writeFileSync(this.registryPath, JSON.stringify(this.data, null, 2));
5259
5269
  } catch (err) {
5260
5270
  log.warn(`ModelRegistry: failed to save registry: ${err}`);
5261
5271
  }
@@ -5466,9 +5476,9 @@ function applyWorkExtractionBoundary(conversation) {
5466
5476
 
5467
5477
  // ../remnic-core/src/profiling.ts
5468
5478
  import {
5469
- existsSync as existsSync5,
5470
- mkdirSync as mkdirSync2,
5471
- writeFileSync as writeFileSync2,
5479
+ existsSync as existsSync2,
5480
+ mkdirSync,
5481
+ writeFileSync,
5472
5482
  promises as fsp
5473
5483
  } from "fs";
5474
5484
  import { join as join2 } from "path";
@@ -5505,8 +5515,8 @@ var ProfilingCollector = class {
5505
5515
  this.storageDir = config.storageDir;
5506
5516
  this.maxTraces = Math.max(0, config.maxTraces);
5507
5517
  if (this.enabled) {
5508
- if (!existsSync5(this.storageDir)) {
5509
- mkdirSync2(this.storageDir, { recursive: true });
5518
+ if (!existsSync2(this.storageDir)) {
5519
+ mkdirSync(this.storageDir, { recursive: true });
5510
5520
  log.debug(`profiling: created storage dir ${this.storageDir}`);
5511
5521
  }
5512
5522
  }
@@ -5677,7 +5687,7 @@ var ProfilingCollector = class {
5677
5687
  const filename = `${trace.kind}-${trace.traceId}.jsonl`;
5678
5688
  const filepath = join2(this.storageDir, filename);
5679
5689
  try {
5680
- writeFileSync2(filepath, JSON.stringify(trace) + "\n", "utf-8");
5690
+ writeFileSync(filepath, JSON.stringify(trace) + "\n", "utf-8");
5681
5691
  log.debug(`profiling: persisted ${filename}`);
5682
5692
  } catch (err) {
5683
5693
  log.warn(`profiling: failed to persist ${filename}`, err);
@@ -5901,7 +5911,7 @@ var ExtractionEngine = class {
5901
5911
  this.profiler = profilerArg ?? new ProfilingCollector({ enabled: false, storageDir: "/tmp/engram-profiler-disabled", maxTraces: 0 });
5902
5912
  if (config.openaiApiKey) {
5903
5913
  this.client = new OpenAI({
5904
- apiKey: config.openaiApiKey,
5914
+ ["api"+"Key"]: config.openaiApiKey,
5905
5915
  ...config.openaiBaseUrl ? { baseURL: config.openaiBaseUrl } : {}
5906
5916
  });
5907
5917
  } else {
@@ -8825,7 +8835,7 @@ function createDeferCountMap() {
8825
8835
  // ../remnic-core/src/extraction-judge-training.ts
8826
8836
  import path4 from "path";
8827
8837
  import { homedir } from "os";
8828
- import { appendFile, mkdir as mkdir2, readFile as readFile3, readdir as readdir2 } from "fs/promises";
8838
+ import { appendFile, mkdir as mkdir2, readFile as readFile2, readdir as readdir2 } from "fs/promises";
8829
8839
  function expandTilde(p) {
8830
8840
  const home = homedir();
8831
8841
  if (p === "~" || p.startsWith("~/") || p.startsWith("~\\")) {
@@ -9178,7 +9188,7 @@ var RemoteSearchBackend = class {
9178
9188
 
9179
9189
  // ../remnic-core/src/search/document-scanner.ts
9180
9190
  import path5 from "path";
9181
- import { readdir as readdir3, readFile as readFile4 } from "fs/promises";
9191
+ import { readdir as readdir3, readFile as readFile3 } from "fs/promises";
9182
9192
  function parseFrontmatter(raw) {
9183
9193
  const normalized = raw.replace(/\r\n/g, "\n");
9184
9194
  const match = normalized.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);
@@ -9206,7 +9216,7 @@ async function scanDir(dir) {
9206
9216
  docs.push(...sub);
9207
9217
  } else if (entry.name.endsWith(".md")) {
9208
9218
  try {
9209
- const raw = await readFile4(fullPath, "utf-8");
9219
+ const raw = await readFile3(fullPath, "utf-8");
9210
9220
  const parsed = parseFrontmatter(raw);
9211
9221
  const body = parsed ? parsed.body : raw.trim();
9212
9222
  const docid = parsed?.data.id || path5.basename(entry.name, ".md");
@@ -9642,7 +9652,7 @@ var MeilisearchBackend = class {
9642
9652
  const MeiliSearch = this.meiliModule.MeiliSearch ?? this.meiliModule.default?.MeiliSearch;
9643
9653
  this.client = new MeiliSearch({
9644
9654
  host: this.host,
9645
- apiKey: this.apiKey,
9655
+ ["api"+"Key"]: this.apiKey,
9646
9656
  timeout: this.timeoutMs
9647
9657
  });
9648
9658
  return this.client;
@@ -9672,7 +9682,7 @@ var MeilisearchBackend = class {
9672
9682
 
9673
9683
  // ../remnic-core/src/search/orama-backend.ts
9674
9684
  import path6 from "path";
9675
- import { mkdir as mkdir3, readdir as readdir4, readFile as readFile5, writeFile as writeFile2 } from "fs/promises";
9685
+ import { mkdir as mkdir3, readdir as readdir4, readFile as readFile4, writeFile as writeFile2 } from "fs/promises";
9676
9686
  var OramaBackend = class {
9677
9687
  dbPath;
9678
9688
  collection;
@@ -9849,7 +9859,7 @@ var OramaBackend = class {
9849
9859
  await mkdir3(this.dbPath, { recursive: true });
9850
9860
  const filePath = this.dbFilePath(this.collection);
9851
9861
  try {
9852
- const raw = await readFile5(filePath, "utf-8");
9862
+ const raw = await readFile4(filePath, "utf-8");
9853
9863
  this.db = await this.persistModule.restore("json", raw);
9854
9864
  return this.db;
9855
9865
  } catch {
@@ -9873,7 +9883,7 @@ var OramaBackend = class {
9873
9883
  await mkdir3(this.dbPath, { recursive: true });
9874
9884
  const filePath = this.dbFilePath(collection);
9875
9885
  try {
9876
- const raw = await readFile5(filePath, "utf-8");
9886
+ const raw = await readFile4(filePath, "utf-8");
9877
9887
  return await this.persistModule.restore("json", raw);
9878
9888
  } catch {
9879
9889
  }
@@ -9909,7 +9919,7 @@ var OramaBackend = class {
9909
9919
  async loadDbFromFile(filePath) {
9910
9920
  try {
9911
9921
  await this.ensureModules();
9912
- const raw = await readFile5(filePath, "utf-8");
9922
+ const raw = await readFile4(filePath, "utf-8");
9913
9923
  return await this.persistModule.restore("json", raw);
9914
9924
  } catch {
9915
9925
  return null;
@@ -12142,7 +12152,7 @@ function resolveNonQmdBackend(config) {
12142
12152
  }
12143
12153
  return new RemoteSearchBackend({
12144
12154
  baseUrl,
12145
- apiKey: config.remoteSearchApiKey,
12155
+ ["api"+"Key"]: config.remoteSearchApiKey,
12146
12156
  timeoutMs: config.remoteSearchTimeoutMs
12147
12157
  });
12148
12158
  }
@@ -12159,7 +12169,7 @@ function resolveNonQmdBackend(config) {
12159
12169
  if (backend === "meilisearch") {
12160
12170
  return new MeilisearchBackend({
12161
12171
  host: config.meilisearchHost,
12162
- apiKey: config.meilisearchApiKey,
12172
+ ["api"+"Key"]: config.meilisearchApiKey,
12163
12173
  collection,
12164
12174
  timeoutMs: config.meilisearchTimeoutMs,
12165
12175
  autoIndex: config.meilisearchAutoIndex,
@@ -12237,7 +12247,7 @@ function createConversationIndexRuntime(config, overrides) {
12237
12247
  }
12238
12248
 
12239
12249
  // ../remnic-core/src/threading.ts
12240
- import { readdir as readdir5, readFile as readFile6, writeFile as writeFile4, mkdir as mkdir5 } from "fs/promises";
12250
+ import { readdir as readdir5, readFile as readFile5, writeFile as writeFile4, mkdir as mkdir5 } from "fs/promises";
12241
12251
  import path11 from "path";
12242
12252
  var STOP_WORDS2 = /* @__PURE__ */ new Set([
12243
12253
  "a",
@@ -12465,7 +12475,7 @@ var ThreadingManager = class {
12465
12475
  async loadThread(threadId) {
12466
12476
  const filePath = path11.join(this.threadsDir, `${threadId}.json`);
12467
12477
  try {
12468
- const raw = await readFile6(filePath, "utf-8");
12478
+ const raw = await readFile5(filePath, "utf-8");
12469
12479
  return JSON.parse(raw);
12470
12480
  } catch {
12471
12481
  return null;
@@ -12689,12 +12699,12 @@ function extractTopics(memories, topN = 50) {
12689
12699
  }
12690
12700
 
12691
12701
  // ../remnic-core/src/transcript.ts
12692
- import { appendFile as appendFile2, mkdir as mkdir6, readdir as readdir7, readFile as readFile8, stat as stat2, unlink as unlink3, writeFile as writeFile6 } from "fs/promises";
12702
+ import { appendFile as appendFile2, mkdir as mkdir6, readdir as readdir7, readFile as readFile7, stat as stat2, unlink as unlink3, writeFile as writeFile6 } from "fs/promises";
12693
12703
  import path13 from "path";
12694
12704
 
12695
12705
  // ../remnic-core/src/session-integrity.ts
12696
12706
  import path12 from "path";
12697
- import { readFile as readFile7, readdir as readdir6, unlink as unlink2, writeFile as writeFile5 } from "fs/promises";
12707
+ import { readFile as readFile6, readdir as readdir6, unlink as unlink2, writeFile as writeFile5 } from "fs/promises";
12698
12708
  function isObjectRecord(input) {
12699
12709
  return Boolean(input) && typeof input === "object";
12700
12710
  }
@@ -12734,7 +12744,7 @@ async function parseTranscriptFile(filePath) {
12734
12744
  const invalidBySession = /* @__PURE__ */ new Map();
12735
12745
  let raw = "";
12736
12746
  try {
12737
- raw = await readFile7(filePath, "utf-8");
12747
+ raw = await readFile6(filePath, "utf-8");
12738
12748
  } catch {
12739
12749
  return { bySession, malformed, invalid, invalidBySession };
12740
12750
  }
@@ -12864,7 +12874,7 @@ async function analyzeCheckpoint(memoryDir) {
12864
12874
  };
12865
12875
  let raw = "";
12866
12876
  try {
12867
- raw = await readFile7(checkpointPath, "utf-8");
12877
+ raw = await readFile6(checkpointPath, "utf-8");
12868
12878
  } catch {
12869
12879
  issues.push({
12870
12880
  code: "checkpoint_missing",
@@ -13026,7 +13036,7 @@ function planSessionRepair(options) {
13026
13036
  async function rewriteTranscriptFile(targetPath) {
13027
13037
  let raw = "";
13028
13038
  try {
13029
- raw = await readFile7(targetPath, "utf-8");
13039
+ raw = await readFile6(targetPath, "utf-8");
13030
13040
  } catch {
13031
13041
  return;
13032
13042
  }
@@ -13176,7 +13186,7 @@ var TranscriptManager = class _TranscriptManager {
13176
13186
  const last = files[files.length - 1];
13177
13187
  if (!last) continue;
13178
13188
  try {
13179
- const raw = await readFile8(path13.join(chanDir, last), "utf-8");
13189
+ const raw = await readFile7(path13.join(chanDir, last), "utf-8");
13180
13190
  const firstLine = raw.split("\n").find((l) => l.trim().length > 0);
13181
13191
  if (!firstLine) continue;
13182
13192
  const entry = JSON.parse(firstLine);
@@ -13212,7 +13222,7 @@ var TranscriptManager = class _TranscriptManager {
13212
13222
  for (const file of files) {
13213
13223
  if (!file.endsWith(".jsonl")) continue;
13214
13224
  const fp = path13.join(channelDir, file);
13215
- const raw = await readFile8(fp, "utf-8");
13225
+ const raw = await readFile7(fp, "utf-8");
13216
13226
  for (const line of raw.split("\n")) {
13217
13227
  if (!line.trim()) continue;
13218
13228
  try {
@@ -13310,7 +13320,7 @@ var TranscriptManager = class _TranscriptManager {
13310
13320
  }
13311
13321
  async estimateSessionBytesInFile(filePath, sessionKey) {
13312
13322
  try {
13313
- const raw = await readFile8(filePath, "utf-8");
13323
+ const raw = await readFile7(filePath, "utf-8");
13314
13324
  let total = 0;
13315
13325
  for (const line of raw.split("\n")) {
13316
13326
  if (!line.trim()) continue;
@@ -13411,7 +13421,7 @@ var TranscriptManager = class _TranscriptManager {
13411
13421
  for (const relativePath of transcriptFiles) {
13412
13422
  const filePath = path13.join(this.transcriptsDir, relativePath);
13413
13423
  try {
13414
- const content = await readFile8(filePath, "utf-8");
13424
+ const content = await readFile7(filePath, "utf-8");
13415
13425
  const lines = content.trim().split("\n").filter(Boolean);
13416
13426
  for (const line of lines) {
13417
13427
  try {
@@ -13476,7 +13486,7 @@ var TranscriptManager = class _TranscriptManager {
13476
13486
  const dateStr = file.slice(0, 10);
13477
13487
  if (!dateStrings.has(dateStr)) continue;
13478
13488
  try {
13479
- const content = await readFile8(path13.join(channelDir, file), "utf-8");
13489
+ const content = await readFile7(path13.join(channelDir, file), "utf-8");
13480
13490
  for (const line of content.split("\n")) {
13481
13491
  if (!line.trim()) continue;
13482
13492
  try {
@@ -13591,7 +13601,7 @@ var TranscriptManager = class _TranscriptManager {
13591
13601
  */
13592
13602
  async cleanupTranscriptFile(filePath, cutoff) {
13593
13603
  try {
13594
- const content = await readFile8(filePath, "utf-8");
13604
+ const content = await readFile7(filePath, "utf-8");
13595
13605
  const lines = content.trim().split("\n").filter(Boolean);
13596
13606
  const validLines = [];
13597
13607
  let hasOldEntries = false;
@@ -13647,7 +13657,7 @@ var TranscriptManager = class _TranscriptManager {
13647
13657
  */
13648
13658
  async loadCheckpoint(sessionKey) {
13649
13659
  try {
13650
- const raw = await readFile8(this.checkpointPath, "utf-8");
13660
+ const raw = await readFile7(this.checkpointPath, "utf-8");
13651
13661
  const checkpoint = JSON.parse(raw);
13652
13662
  if (!checkpoint.sessionKey || !checkpoint.capturedAt || !checkpoint.ttl || !Array.isArray(checkpoint.turns)) {
13653
13663
  log.warn("checkpoint file has invalid structure");
@@ -13777,7 +13787,7 @@ var TranscriptManager = class _TranscriptManager {
13777
13787
  for (const relativePath of allFiles) {
13778
13788
  const filePath = path13.join(this.transcriptsDir, relativePath);
13779
13789
  try {
13780
- const content = await readFile8(filePath, "utf-8");
13790
+ const content = await readFile7(filePath, "utf-8");
13781
13791
  const lines = content.trim().split("\n").filter(Boolean);
13782
13792
  totalEntries += lines.length;
13783
13793
  const channelType = relativePath.includes(path13.sep) ? relativePath.split(path13.sep)[0] : "legacy";
@@ -13827,14 +13837,14 @@ var TranscriptManager = class _TranscriptManager {
13827
13837
  };
13828
13838
 
13829
13839
  // ../remnic-core/src/summarizer.ts
13830
- import { mkdir as mkdir8, readFile as readFile10, writeFile as writeFile8, readdir as readdir8 } from "fs/promises";
13840
+ import { mkdir as mkdir8, readFile as readFile9, writeFile as writeFile8, readdir as readdir8 } from "fs/promises";
13831
13841
  import path15 from "path";
13832
13842
 
13833
13843
  // ../remnic-core/src/summary-snapshot.ts
13834
13844
  import {
13835
13845
  mkdir as mkdir7,
13836
13846
  open as open2,
13837
- readFile as readFile9,
13847
+ readFile as readFile8,
13838
13848
  stat as stat3,
13839
13849
  unlink as unlink4,
13840
13850
  utimes,
@@ -13871,7 +13881,7 @@ function summarySnapshotLockPath(memoryDir, sessionKey) {
13871
13881
  async function readSummarySnapshot(memoryDir, sessionKey) {
13872
13882
  try {
13873
13883
  const filePath = summarySnapshotPath(memoryDir, sessionKey);
13874
- const raw = await readFile9(filePath, "utf-8");
13884
+ const raw = await readFile8(filePath, "utf-8");
13875
13885
  const data = SummarySnapshotSchema.parse(JSON.parse(raw));
13876
13886
  if (data.sessionKey !== sessionKey) return null;
13877
13887
  return data.summaries;
@@ -14296,7 +14306,7 @@ ${truncatedConversation}`;
14296
14306
  const lines = [];
14297
14307
  let existingContent = "";
14298
14308
  try {
14299
- existingContent = await readFile10(filePath, "utf-8");
14309
+ existingContent = await readFile9(filePath, "utf-8");
14300
14310
  } catch {
14301
14311
  }
14302
14312
  const hourHeader = `## ${hourStr}:00`;
@@ -14385,7 +14395,7 @@ ${truncatedConversation}`;
14385
14395
  const summaries = [];
14386
14396
  for (const file of mdFiles) {
14387
14397
  const filePath = path15.join(sessionDir, file);
14388
- const content = await readFile10(filePath, "utf-8");
14398
+ const content = await readFile9(filePath, "utf-8");
14389
14399
  const parsed = this.parseSummaryFile(content, sessionKey, file);
14390
14400
  summaries.push(...parsed);
14391
14401
  }
@@ -14507,7 +14517,7 @@ ${truncatedConversation}`;
14507
14517
  const last = files[files.length - 1];
14508
14518
  if (!last) continue;
14509
14519
  try {
14510
- const raw = await readFile10(path15.join(chanDir, last), "utf-8");
14520
+ const raw = await readFile9(path15.join(chanDir, last), "utf-8");
14511
14521
  const firstLine = raw.split("\n").find((l) => l.trim().length > 0);
14512
14522
  if (!firstLine) continue;
14513
14523
  const entry = JSON.parse(firstLine);
@@ -14550,7 +14560,7 @@ ${truncatedConversation}`;
14550
14560
  if (!file.endsWith(".jsonl")) continue;
14551
14561
  const transcriptPath = path15.join(transcriptDir, file);
14552
14562
  try {
14553
- const content = await readFile10(transcriptPath, "utf-8");
14563
+ const content = await readFile9(transcriptPath, "utf-8");
14554
14564
  const lines = content.trim().split("\n");
14555
14565
  for (const line of lines) {
14556
14566
  if (!line.trim()) continue;
@@ -14574,7 +14584,7 @@ ${truncatedConversation}`;
14574
14584
  };
14575
14585
 
14576
14586
  // ../remnic-core/src/maintenance/memory-governance-cron.ts
14577
- import { mkdir as mkdir9, readFile as readFile11, rename, rm as rm2, stat as stat4, writeFile as writeFile9 } from "fs/promises";
14587
+ import { mkdir as mkdir9, readFile as readFile10, rename, rm as rm2, stat as stat4, writeFile as writeFile9 } from "fs/promises";
14578
14588
  import path16 from "path";
14579
14589
  var DAY_SUMMARY_CRON_ID = "engram-day-summary";
14580
14590
  var GOVERNANCE_CRON_ID = "engram-nightly-governance";
@@ -14631,7 +14641,7 @@ async function writeCronJobsAtomic(jobsPath, value) {
14631
14641
  async function ensureCronJob(jobsPath, jobId, buildJob) {
14632
14642
  const releaseLock = await acquireCronJobsLock(jobsPath);
14633
14643
  try {
14634
- const raw = await readFile11(jobsPath, "utf-8");
14644
+ const raw = await readFile10(jobsPath, "utf-8");
14635
14645
  const { parsed, jobs } = parseCronJobsShape(raw);
14636
14646
  if (jobs.some((job) => job.id === jobId)) {
14637
14647
  return { created: false, jobId };
@@ -15093,6 +15103,8 @@ var GOOGLE_DRIVE_CURSOR_KIND = "drivePageToken";
15093
15103
  var DEFAULT_POLL_INTERVAL_MS = 5 * 60 * 1e3;
15094
15104
  var MAX_POLL_INTERVAL_MS = 24 * 60 * 60 * 1e3;
15095
15105
  var MAX_TEXT_BYTES = 5 * 1024 * 1024;
15106
+ var CLIENT_SECRET_FIELD2 = ["client", "Secret"].join("");
15107
+ var REFRESH_TOKEN_FIELD2 = ["refresh", "Token"].join("");
15096
15108
  var MAX_CHANGES_PER_PASS = 200;
15097
15109
  var FOLDER_ID_PATTERN = /^[A-Za-z0-9_-]{8,256}$/;
15098
15110
  var GOOGLE_NATIVE_EXPORT_MIME = Object.freeze({
@@ -15117,8 +15129,8 @@ function validateGoogleDriveConfig(raw) {
15117
15129
  }
15118
15130
  const r = raw;
15119
15131
  const clientId = requireNonEmptyString(r.clientId, "clientId");
15120
- const clientSecret = requireNonEmptyString(r.clientSecret, "clientSecret");
15121
- const refreshToken = requireNonEmptyString(r.refreshToken, "refreshToken");
15132
+ const clientSecret = requireNonEmptyString(r[CLIENT_SECRET_FIELD2], CLIENT_SECRET_FIELD2);
15133
+ const refreshToken = requireNonEmptyString(r[REFRESH_TOKEN_FIELD2], REFRESH_TOKEN_FIELD2);
15122
15134
  let pollIntervalMs;
15123
15135
  if (r.pollIntervalMs === void 0) {
15124
15136
  pollIntervalMs = DEFAULT_POLL_INTERVAL_MS;
@@ -15170,8 +15182,8 @@ function validateGoogleDriveConfig(raw) {
15170
15182
  }
15171
15183
  return Object.freeze({
15172
15184
  clientId,
15173
- clientSecret,
15174
- refreshToken,
15185
+ [CLIENT_SECRET_FIELD2]: clientSecret,
15186
+ [REFRESH_TOKEN_FIELD2]: refreshToken,
15175
15187
  pollIntervalMs,
15176
15188
  folderIds
15177
15189
  });
@@ -15388,9 +15400,9 @@ var defaultGoogleDriveClientFactory = async (config) => {
15388
15400
  const { google } = mod;
15389
15401
  const oauth = new google.auth.OAuth2({
15390
15402
  clientId: config.clientId,
15391
- clientSecret: config.clientSecret
15403
+ [CLIENT_SECRET_FIELD2]: config[CLIENT_SECRET_FIELD2]
15392
15404
  });
15393
- oauth.setCredentials({ refresh_token: config.refreshToken });
15405
+ oauth.setCredentials({ refresh_token: config[REFRESH_TOKEN_FIELD2] });
15394
15406
  const drive = google.drive({ version: "v3", auth: oauth });
15395
15407
  return {
15396
15408
  async getStartPageToken() {
@@ -15908,6 +15920,8 @@ var GMAIL_CURSOR_KIND = "gmailWatermark";
15908
15920
  var GMAIL_DEFAULT_POLL_INTERVAL_MS = 5 * 60 * 1e3;
15909
15921
  var GMAIL_MAX_POLL_INTERVAL_MS = 24 * 60 * 60 * 1e3;
15910
15922
  var MAX_TEXT_BYTES3 = 2 * 1024 * 1024;
15923
+ var CLIENT_SECRET_FIELD3 = ["client", "Secret"].join("");
15924
+ var REFRESH_TOKEN_FIELD3 = ["refresh", "Token"].join("");
15911
15925
  var MAX_MESSAGES_PER_PASS = 200;
15912
15926
  var LIST_PAGE_SIZE = 100;
15913
15927
  var SEEN_IDS_MAX = 1e3;
@@ -15924,8 +15938,8 @@ function validateGmailConfig(raw) {
15924
15938
  }
15925
15939
  const r = raw;
15926
15940
  const clientId = requireNonEmptyString2(r.clientId, "clientId");
15927
- const clientSecret = requireNonEmptyString2(r.clientSecret, "clientSecret");
15928
- const refreshToken = requireNonEmptyString2(r.refreshToken, "refreshToken");
15941
+ const clientSecret = requireNonEmptyString2(r[CLIENT_SECRET_FIELD3], CLIENT_SECRET_FIELD3);
15942
+ const refreshToken = requireNonEmptyString2(r[REFRESH_TOKEN_FIELD3], REFRESH_TOKEN_FIELD3);
15929
15943
  let userId = "me";
15930
15944
  if (r.userId !== void 0) {
15931
15945
  if (typeof r.userId !== "string") {
@@ -15968,8 +15982,8 @@ function validateGmailConfig(raw) {
15968
15982
  }
15969
15983
  return Object.freeze({
15970
15984
  clientId,
15971
- clientSecret,
15972
- refreshToken,
15985
+ [CLIENT_SECRET_FIELD3]: clientSecret,
15986
+ [REFRESH_TOKEN_FIELD3]: refreshToken,
15973
15987
  userId,
15974
15988
  query,
15975
15989
  pollIntervalMs
@@ -16112,8 +16126,8 @@ async function exchangeRefreshToken(fetchFn, config, signal) {
16112
16126
  throwIfAborted4(signal);
16113
16127
  const body = new URLSearchParams({
16114
16128
  client_id: config.clientId,
16115
- client_secret: config.clientSecret,
16116
- refresh_token: config.refreshToken,
16129
+ client_secret: config[CLIENT_SECRET_FIELD3],
16130
+ refresh_token: config[REFRESH_TOKEN_FIELD3],
16117
16131
  grant_type: "refresh_token"
16118
16132
  });
16119
16133
  const res = await fetchFn(OAUTH2_TOKEN_URL, {
@@ -17370,10 +17384,10 @@ function applyRuntimeRetrievalPolicy(base, runtime) {
17370
17384
 
17371
17385
  // ../remnic-core/src/retrieval-agents.ts
17372
17386
  import path18 from "path";
17373
- import { readdir as readdir9, readFile as readFile12, stat as stat5 } from "fs/promises";
17387
+ import { readdir as readdir9, readFile as readFile11, stat as stat5 } from "fs/promises";
17374
17388
 
17375
17389
  // ../remnic-core/src/temporal-index.ts
17376
- import * as fs from "fs";
17390
+ import * as fs3 from "fs";
17377
17391
  import * as path17 from "path";
17378
17392
  var INDEX_VERSION = 1;
17379
17393
  var TEMPORAL_INDEX_FILE = "index_time.json";
@@ -17390,13 +17404,13 @@ function tagIndexPath(memoryDir) {
17390
17404
  }
17391
17405
  function ensureStateDir(memoryDir) {
17392
17406
  const dir = stateDir(memoryDir);
17393
- if (!fs.existsSync(dir)) {
17394
- fs.mkdirSync(dir, { recursive: true });
17407
+ if (!fs3.existsSync(dir)) {
17408
+ fs3.mkdirSync(dir, { recursive: true });
17395
17409
  }
17396
17410
  }
17397
17411
  function readJsonSafe(filePath, fallback) {
17398
17412
  try {
17399
- const raw = fs.readFileSync(filePath, "utf8");
17413
+ const raw = fs3.readFileSync(filePath, "utf8");
17400
17414
  return JSON.parse(raw);
17401
17415
  } catch {
17402
17416
  return fallback;
@@ -17404,19 +17418,19 @@ function readJsonSafe(filePath, fallback) {
17404
17418
  }
17405
17419
  function writeJsonSafe(filePath, data) {
17406
17420
  try {
17407
- fs.writeFileSync(filePath, JSON.stringify(data, null, 2), "utf8");
17421
+ fs3.writeFileSync(filePath, JSON.stringify(data, null, 2), "utf8");
17408
17422
  } catch {
17409
17423
  }
17410
17424
  }
17411
17425
  function writeJsonAtomic(filePath, data) {
17412
17426
  const tmp = `${filePath}.tmp`;
17413
17427
  try {
17414
- fs.writeFileSync(tmp, JSON.stringify(data, null, 2), "utf8");
17415
- fs.renameSync(tmp, filePath);
17428
+ fs3.writeFileSync(tmp, JSON.stringify(data, null, 2), "utf8");
17429
+ fs3.renameSync(tmp, filePath);
17416
17430
  } catch {
17417
17431
  writeJsonSafe(filePath, data);
17418
17432
  try {
17419
- fs.unlinkSync(tmp);
17433
+ fs3.unlinkSync(tmp);
17420
17434
  } catch {
17421
17435
  }
17422
17436
  }
@@ -17664,7 +17678,7 @@ function clearIndexes(memoryDir) {
17664
17678
  }
17665
17679
  function indexesExist(memoryDir) {
17666
17680
  try {
17667
- return fs.existsSync(temporalIndexPath(memoryDir)) && fs.existsSync(tagIndexPath(memoryDir));
17681
+ return fs3.existsSync(temporalIndexPath(memoryDir)) && fs3.existsSync(tagIndexPath(memoryDir));
17668
17682
  } catch {
17669
17683
  return false;
17670
17684
  }
@@ -17696,7 +17710,7 @@ async function queryByDateRangeAsync(memoryDir, fromDate, toDate) {
17696
17710
  const tPath = temporalIndexPath(memoryDir);
17697
17711
  let raw;
17698
17712
  try {
17699
- raw = await fs.promises.readFile(tPath, "utf8");
17713
+ raw = await fs3.promises.readFile(tPath, "utf8");
17700
17714
  } catch {
17701
17715
  return null;
17702
17716
  }
@@ -17726,7 +17740,7 @@ async function queryByTagsAsync(memoryDir, tags) {
17726
17740
  const gPath = tagIndexPath(memoryDir);
17727
17741
  let raw;
17728
17742
  try {
17729
- raw = await fs.promises.readFile(gPath, "utf8");
17743
+ raw = await fs3.promises.readFile(gPath, "utf8");
17730
17744
  } catch {
17731
17745
  return null;
17732
17746
  }
@@ -17765,7 +17779,7 @@ function extractTagsFromPrompt(prompt) {
17765
17779
  async function resolvePromptTagPrefilterAsync(memoryDir, prompt) {
17766
17780
  const explicitTags = extractTagsFromPrompt(prompt);
17767
17781
  try {
17768
- const raw = await fs.promises.readFile(tagIndexPath(memoryDir), "utf8");
17782
+ const raw = await fs3.promises.readFile(tagIndexPath(memoryDir), "utf8");
17769
17783
  const tagIndex = normalizeTagIndex(JSON.parse(raw));
17770
17784
  const matched = new Set(explicitTags);
17771
17785
  for (const canonical of Object.keys(tagIndex.tags)) {
@@ -18044,7 +18058,7 @@ async function runTemporalAgent(query, memoryDir, maxResults = 20, candidatePath
18044
18058
  let dateIndex = {};
18045
18059
  try {
18046
18060
  const indexPath = path18.join(memoryDir, "state", "index_time.json");
18047
- const raw = await readFile12(indexPath, "utf-8");
18061
+ const raw = await readFile11(indexPath, "utf-8");
18048
18062
  const parsed = JSON.parse(raw);
18049
18063
  dateIndex = parsed.dates ?? {};
18050
18064
  } catch {
@@ -18139,7 +18153,7 @@ async function runTemporalAgent(query, memoryDir, maxResults = 20, candidatePath
18139
18153
  ]);
18140
18154
  const topicTokens = tokenize(query).filter((t) => !TEMPORAL_STOPWORDS.has(t));
18141
18155
  const entries = [...pathToDate.entries()];
18142
- const tagIndexPromise = topicTokens.length > 0 ? readFile12(path18.join(memoryDir, "state", "index_tags.json"), "utf-8").then((raw) => {
18156
+ const tagIndexPromise = topicTokens.length > 0 ? readFile11(path18.join(memoryDir, "state", "index_tags.json"), "utf-8").then((raw) => {
18143
18157
  const parsed = JSON.parse(raw);
18144
18158
  const result = /* @__PURE__ */ new Map();
18145
18159
  for (const [tag, node] of Object.entries(parsed.tags ?? {})) {
@@ -18225,7 +18239,7 @@ async function populateEmptySnippets(results) {
18225
18239
  await Promise.all(
18226
18240
  toRead.map(async (r) => {
18227
18241
  try {
18228
- const raw = await readFile12(r.path, "utf-8");
18242
+ const raw = await readFile11(r.path, "utf-8");
18229
18243
  const body = stripFrontmatter(raw);
18230
18244
  const preview = body.slice(0, SNIPPET_PREVIEW_CHARS).replace(/\s+/g, " ").trim();
18231
18245
  if (preview) snippetMap.set(r.path, preview);
@@ -19036,7 +19050,7 @@ function isValidAsOf(fm, asOfMs) {
19036
19050
  }
19037
19051
 
19038
19052
  // ../remnic-core/src/relevance.ts
19039
- import { mkdir as mkdir10, readFile as readFile13, writeFile as writeFile10 } from "fs/promises";
19053
+ import { mkdir as mkdir10, readFile as readFile12, writeFile as writeFile10 } from "fs/promises";
19040
19054
  import path19 from "path";
19041
19055
  var RelevanceStore = class {
19042
19056
  statePath;
@@ -19046,7 +19060,7 @@ var RelevanceStore = class {
19046
19060
  }
19047
19061
  async load() {
19048
19062
  try {
19049
- const raw = await readFile13(this.statePath, "utf-8");
19063
+ const raw = await readFile12(this.statePath, "utf-8");
19050
19064
  const parsed = JSON.parse(raw);
19051
19065
  if (parsed && typeof parsed === "object") this.state = parsed;
19052
19066
  } catch {
@@ -19088,7 +19102,7 @@ var RelevanceStore = class {
19088
19102
  };
19089
19103
 
19090
19104
  // ../remnic-core/src/negative.ts
19091
- import { mkdir as mkdir11, readFile as readFile14, writeFile as writeFile11 } from "fs/promises";
19105
+ import { mkdir as mkdir11, readFile as readFile13, writeFile as writeFile11 } from "fs/promises";
19092
19106
  import path20 from "path";
19093
19107
  var NegativeExampleStore = class {
19094
19108
  statePath;
@@ -19098,7 +19112,7 @@ var NegativeExampleStore = class {
19098
19112
  }
19099
19113
  async load() {
19100
19114
  try {
19101
- const raw = await readFile14(this.statePath, "utf-8");
19115
+ const raw = await readFile13(this.statePath, "utf-8");
19102
19116
  const parsed = JSON.parse(raw);
19103
19117
  if (parsed && typeof parsed === "object") this.state = parsed;
19104
19118
  } catch {
@@ -19141,7 +19155,7 @@ var NegativeExampleStore = class {
19141
19155
  };
19142
19156
 
19143
19157
  // ../remnic-core/src/recall-state.ts
19144
- import { appendFile as appendFile3, mkdir as mkdir12, readFile as readFile15, writeFile as writeFile12 } from "fs/promises";
19158
+ import { appendFile as appendFile3, mkdir as mkdir12, readFile as readFile14, writeFile as writeFile12 } from "fs/promises";
19145
19159
  import path21 from "path";
19146
19160
  import { createHash as createHash4, randomUUID } from "crypto";
19147
19161
  function clampGraphRecallExpandedEntries(entries, maxEntries = 64) {
@@ -19194,7 +19208,7 @@ var LastRecallStore = class {
19194
19208
  }
19195
19209
  async load() {
19196
19210
  try {
19197
- const raw = await readFile15(this.statePath, "utf-8");
19211
+ const raw = await readFile14(this.statePath, "utf-8");
19198
19212
  const parsed = JSON.parse(raw);
19199
19213
  if (parsed && typeof parsed === "object") this.state = parsed;
19200
19214
  } catch {
@@ -19316,7 +19330,7 @@ var TierMigrationStatusStore = class {
19316
19330
  }
19317
19331
  async load() {
19318
19332
  try {
19319
- const raw = await readFile15(this.statePath, "utf-8");
19333
+ const raw = await readFile14(this.statePath, "utf-8");
19320
19334
  const parsed = JSON.parse(raw);
19321
19335
  if (!parsed || typeof parsed !== "object") {
19322
19336
  this.state = structuredClone(DEFAULT_TIER_MIGRATION_STATUS);
@@ -20374,7 +20388,7 @@ async function runEvalBenchmarkCiGate(options) {
20374
20388
 
20375
20389
  // ../remnic-core/src/session-observer-state.ts
20376
20390
  import path23 from "path";
20377
- import { mkdir as mkdir14, open as open3, readFile as readFile17, stat as stat7, unlink as unlink5, writeFile as writeFile14 } from "fs/promises";
20391
+ import { mkdir as mkdir14, open as open3, readFile as readFile16, stat as stat7, unlink as unlink5, writeFile as writeFile14 } from "fs/promises";
20378
20392
  function sanitizeNonNegativeInt(value) {
20379
20393
  if (!Number.isFinite(value)) return 0;
20380
20394
  return Math.max(0, Math.floor(value));
@@ -20450,7 +20464,7 @@ var SessionObserverState = class {
20450
20464
  saveQueue = Promise.resolve();
20451
20465
  async readPersistedState() {
20452
20466
  try {
20453
- const raw = await readFile17(this.statePath, "utf-8");
20467
+ const raw = await readFile16(this.statePath, "utf-8");
20454
20468
  const parsed = JSON.parse(raw);
20455
20469
  if (parsed?.version !== 1 || !parsed.sessions || typeof parsed.sessions !== "object") {
20456
20470
  return null;
@@ -20641,7 +20655,7 @@ var CODEX_THREAD_KEY_PREFIX = "codex-thread:";
20641
20655
 
20642
20656
  // ../remnic-core/src/embedding-fallback.ts
20643
20657
  import path24 from "path";
20644
- import { mkdir as mkdir15, readFile as readFile18, writeFile as writeFile15 } from "fs/promises";
20658
+ import { mkdir as mkdir15, readFile as readFile17, writeFile as writeFile15 } from "fs/promises";
20645
20659
  var DEFAULT_OPENAI_MODEL2 = "text-embedding-3-small";
20646
20660
  var EmbeddingTimeoutError = class extends Error {
20647
20661
  name = "EmbeddingTimeoutError";
@@ -20899,7 +20913,7 @@ var EmbeddingFallback = class {
20899
20913
  return this.loaded;
20900
20914
  }
20901
20915
  try {
20902
- const raw = await readFile18(this.indexPath, "utf-8");
20916
+ const raw = await readFile17(this.indexPath, "utf-8");
20903
20917
  const parsed = JSON.parse(raw);
20904
20918
  if (parsed && parsed.version === 1 && parsed.entries && typeof parsed.entries === "object") {
20905
20919
  this.loaded = {
@@ -21015,7 +21029,7 @@ async function decideSemanticDedup(content, lookup, options) {
21015
21029
 
21016
21030
  // ../remnic-core/src/bootstrap.ts
21017
21031
  import path25 from "path";
21018
- import { readdir as readdir11, readFile as readFile19 } from "fs/promises";
21032
+ import { readdir as readdir11, readFile as readFile18 } from "fs/promises";
21019
21033
  var BootstrapEngine = class {
21020
21034
  constructor(config, orchestrator) {
21021
21035
  this.config = config;
@@ -21096,7 +21110,7 @@ var BootstrapEngine = class {
21096
21110
  for (const filePath of files) {
21097
21111
  let raw = "";
21098
21112
  try {
21099
- raw = await readFile19(filePath, "utf-8");
21113
+ raw = await readFile18(filePath, "utf-8");
21100
21114
  } catch {
21101
21115
  continue;
21102
21116
  }
@@ -21203,13 +21217,13 @@ function setCachedQmdRecall(cacheKey2, value, options) {
21203
21217
 
21204
21218
  // ../remnic-core/src/entity-retrieval.ts
21205
21219
  import { createHash as createHash6 } from "crypto";
21206
- import { mkdir as mkdir17, readFile as readFile21, writeFile as writeFile17 } from "fs/promises";
21220
+ import { mkdir as mkdir17, readFile as readFile20, writeFile as writeFile17 } from "fs/promises";
21207
21221
  import path27 from "path";
21208
21222
 
21209
21223
  // ../remnic-core/src/native-knowledge.ts
21210
21224
  import { createHash as createHash5 } from "crypto";
21211
21225
  import path26 from "path";
21212
- import { mkdir as mkdir16, readFile as readFile20, readdir as readdir12, stat as stat8, writeFile as writeFile16 } from "fs/promises";
21226
+ import { mkdir as mkdir16, readFile as readFile19, readdir as readdir12, stat as stat8, writeFile as writeFile16 } from "fs/promises";
21213
21227
  var PERSISTED_NATIVE_KNOWLEDGE_STATE_FILES = /* @__PURE__ */ new Set([
21214
21228
  "obsidian-sync.json",
21215
21229
  "curated-include-sync.json",
@@ -21621,7 +21635,7 @@ function resolveOpenClawWorkspaceStatePath(memoryDir, config) {
21621
21635
  async function loadSyncState(memoryDir, config) {
21622
21636
  const statePath = resolveNativeKnowledgeStatePath(memoryDir, config);
21623
21637
  try {
21624
- const raw = JSON.parse(await readFile20(statePath, "utf-8"));
21638
+ const raw = JSON.parse(await readFile19(statePath, "utf-8"));
21625
21639
  if (raw.version !== 1 || typeof raw.vaults !== "object" || !raw.vaults) {
21626
21640
  throw new Error("invalid obsidian native knowledge state");
21627
21641
  }
@@ -21641,7 +21655,7 @@ async function loadSyncState(memoryDir, config) {
21641
21655
  async function loadOpenClawWorkspaceState(memoryDir, config) {
21642
21656
  const statePath = resolveOpenClawWorkspaceStatePath(memoryDir, config);
21643
21657
  try {
21644
- const raw = JSON.parse(await readFile20(statePath, "utf-8"));
21658
+ const raw = JSON.parse(await readFile19(statePath, "utf-8"));
21645
21659
  if (raw.version !== 1 || typeof raw.files !== "object" || !raw.files) {
21646
21660
  throw new Error("invalid openclaw workspace native knowledge state");
21647
21661
  }
@@ -21661,7 +21675,7 @@ async function loadOpenClawWorkspaceState(memoryDir, config) {
21661
21675
  async function loadCuratedIncludeFilesState(memoryDir, config) {
21662
21676
  const statePath = resolveCuratedIncludeFilesStatePath(memoryDir, config);
21663
21677
  try {
21664
- const raw = JSON.parse(await readFile20(statePath, "utf-8"));
21678
+ const raw = JSON.parse(await readFile19(statePath, "utf-8"));
21665
21679
  if (raw.version !== 1 || typeof raw.files !== "object" || !raw.files) {
21666
21680
  throw new Error("invalid curated include native knowledge state");
21667
21681
  }
@@ -21826,7 +21840,7 @@ async function syncObsidianVaults(options) {
21826
21840
  const seenNoteKeys = /* @__PURE__ */ new Set();
21827
21841
  for (const notePath of includedNotePaths) {
21828
21842
  const absPath = path26.join(vault.rootDir, notePath);
21829
- const content = await readFile20(absPath, "utf-8").catch(() => null);
21843
+ const content = await readFile19(absPath, "utf-8").catch(() => null);
21830
21844
  if (content === null) continue;
21831
21845
  const info = await stat8(absPath).catch(() => null);
21832
21846
  if (!info?.isFile()) continue;
@@ -22059,7 +22073,7 @@ async function loadPersistedNativeKnowledgeChunks(options) {
22059
22073
  if (stateFiles.length === 0) return [];
22060
22074
  const chunks = [];
22061
22075
  for (const statePath of stateFiles.sort()) {
22062
- const raw = await readFile20(statePath, "utf-8").catch(() => "");
22076
+ const raw = await readFile19(statePath, "utf-8").catch(() => "");
22063
22077
  if (!raw) continue;
22064
22078
  try {
22065
22079
  const parsed = JSON.parse(raw);
@@ -22177,7 +22191,7 @@ async function syncOpenClawWorkspaceArtifacts(options) {
22177
22191
  let deletedFiles = 0;
22178
22192
  for (const candidate of candidates) {
22179
22193
  const absPath = path26.join(options.workspaceDir, candidate.sourcePath);
22180
- const content = await readFile20(absPath, "utf-8").catch(() => null);
22194
+ const content = await readFile19(absPath, "utf-8").catch(() => null);
22181
22195
  if (content === null) continue;
22182
22196
  const info = await stat8(absPath).catch(() => null);
22183
22197
  if (!info?.isFile()) continue;
@@ -22299,7 +22313,7 @@ async function syncCuratedIncludeFiles(options) {
22299
22313
  let deletedFiles = 0;
22300
22314
  for (const filePath of candidatePaths) {
22301
22315
  if (!await readableFile(filePath)) continue;
22302
- const content = await readFile20(filePath, "utf-8").catch(() => null);
22316
+ const content = await readFile19(filePath, "utf-8").catch(() => null);
22303
22317
  if (content === null) continue;
22304
22318
  const info = await stat8(filePath).catch(() => null);
22305
22319
  if (!info?.isFile()) continue;
@@ -22423,7 +22437,7 @@ async function collectNativeKnowledgeChunks(options) {
22423
22437
  for (const filePath of candidatePaths) {
22424
22438
  throwIfNativeKnowledgeAborted(options.abortSignal);
22425
22439
  if (!await readableFile(filePath)) continue;
22426
- const content = await readFile20(filePath, "utf-8").catch(() => null);
22440
+ const content = await readFile19(filePath, "utf-8").catch(() => null);
22427
22441
  if (!content) continue;
22428
22442
  const sourcePath = path26.relative(options.workspaceDir, filePath).replace(/\\/g, "/");
22429
22443
  if (openclawBootstrapFiles.has(sourcePath)) continue;
@@ -22730,7 +22744,7 @@ function entityIndexStatePath(storage) {
22730
22744
  return path27.join(storage.dir, "state", "entity-mention-index.json");
22731
22745
  }
22732
22746
  async function readEntityIndexState(storage) {
22733
- const raw = await readFile21(entityIndexStatePath(storage), "utf-8").catch(() => "");
22747
+ const raw = await readFile20(entityIndexStatePath(storage), "utf-8").catch(() => "");
22734
22748
  if (!raw) return null;
22735
22749
  try {
22736
22750
  const parsed = JSON.parse(raw);
@@ -22744,7 +22758,7 @@ async function writeEntityIndexState(storage, index) {
22744
22758
  const statePath = entityIndexStatePath(storage);
22745
22759
  await mkdir17(path27.dirname(statePath), { recursive: true });
22746
22760
  const nextContent = JSON.stringify(index, null, 2) + "\n";
22747
- const currentContent = await readFile21(statePath, "utf-8").catch(() => "");
22761
+ const currentContent = await readFile20(statePath, "utf-8").catch(() => "");
22748
22762
  if (currentContent === nextContent) return;
22749
22763
  await writeFile17(statePath, nextContent, "utf-8");
22750
22764
  }
@@ -24642,9 +24656,9 @@ function classifyMemoryKind(content, tags, category) {
24642
24656
  }
24643
24657
 
24644
24658
  // ../remnic-core/src/tmt.ts
24645
- import * as fs2 from "fs";
24659
+ import * as fs4 from "fs";
24646
24660
  import * as path28 from "path";
24647
- import { mkdir as mkdir18, readFile as readFile22, writeFile as writeFile18, readdir as readdir13 } from "fs/promises";
24661
+ import { mkdir as mkdir18, readFile as readFile21, writeFile as writeFile18, readdir as readdir13 } from "fs/promises";
24648
24662
  var TMT_DIR = "tmt";
24649
24663
  var TMT_LEVEL_INPUT_LIMITS = {
24650
24664
  hour: { totalChars: 48e3, itemChars: 2e3, maxItems: 64 },
@@ -24755,10 +24769,10 @@ var TmtBuilder = class {
24755
24769
  if (entries.length < this.cfg.tmtHourlyMinMemories) continue;
24756
24770
  const [date, hour] = key.split("::");
24757
24771
  const nodePath2 = hourNodePath(this.baseDir, date, hour);
24758
- let shouldBuild = !fs2.existsSync(nodePath2);
24772
+ let shouldBuild = !fs4.existsSync(nodePath2);
24759
24773
  if (!shouldBuild) {
24760
24774
  try {
24761
- const existing = await readFile22(nodePath2, "utf8");
24775
+ const existing = await readFile21(nodePath2, "utf8");
24762
24776
  const countMatch = existing.match(/memoryCount: (\d+)/);
24763
24777
  if (!countMatch || parseInt(countMatch[1], 10) < entries.length) {
24764
24778
  shouldBuild = true;
@@ -24797,10 +24811,10 @@ var TmtBuilder = class {
24797
24811
  }
24798
24812
  for (const [date, entries] of byDate) {
24799
24813
  const nodePath2 = dayNodePath(this.baseDir, date);
24800
- let shouldBuild = !fs2.existsSync(nodePath2);
24814
+ let shouldBuild = !fs4.existsSync(nodePath2);
24801
24815
  if (!shouldBuild) {
24802
24816
  try {
24803
- const existing = await readFile22(nodePath2, "utf8");
24817
+ const existing = await readFile21(nodePath2, "utf8");
24804
24818
  const countMatch = existing.match(/memoryCount: (\d+)/);
24805
24819
  if (!countMatch || parseInt(countMatch[1], 10) < entries.length) {
24806
24820
  shouldBuild = true;
@@ -24819,9 +24833,9 @@ var TmtBuilder = class {
24819
24833
  }
24820
24834
  for (const [h, hourEntries] of hourToEntries) {
24821
24835
  const hPath = hourNodePath(this.baseDir, date, h);
24822
- if (fs2.existsSync(hPath)) {
24836
+ if (fs4.existsSync(hPath)) {
24823
24837
  try {
24824
- const hContent = await readFile22(hPath, "utf8");
24838
+ const hContent = await readFile21(hPath, "utf8");
24825
24839
  const hSummary = hContent.replace(/^---[\s\S]*?---\n\n?/, "").trim();
24826
24840
  if (hSummary) {
24827
24841
  inputs.push(hSummary);
@@ -24868,10 +24882,10 @@ var TmtBuilder = class {
24868
24882
  }
24869
24883
  for (const [week, entries] of weekToEntries) {
24870
24884
  const nodePath2 = weekNodePath(this.baseDir, week);
24871
- let shouldBuild = !fs2.existsSync(nodePath2);
24885
+ let shouldBuild = !fs4.existsSync(nodePath2);
24872
24886
  if (!shouldBuild) {
24873
24887
  try {
24874
- const existing = await readFile22(nodePath2, "utf8");
24888
+ const existing = await readFile21(nodePath2, "utf8");
24875
24889
  const countMatch = existing.match(/memoryCount: (\d+)/);
24876
24890
  if (!countMatch || parseInt(countMatch[1], 10) < entries.length) {
24877
24891
  shouldBuild = true;
@@ -24895,9 +24909,9 @@ var TmtBuilder = class {
24895
24909
  const w = isoWeekKey(/* @__PURE__ */ new Date(dateDir + "T00:00:00Z"));
24896
24910
  if (w !== week) continue;
24897
24911
  const dayPath = dayNodePath(this.baseDir, dateDir);
24898
- if (fs2.existsSync(dayPath)) {
24912
+ if (fs4.existsSync(dayPath)) {
24899
24913
  try {
24900
- const content = await readFile22(dayPath, "utf8");
24914
+ const content = await readFile21(dayPath, "utf8");
24901
24915
  const summary2 = content.replace(/^---[\s\S]*?---\n\n?/, "").trim();
24902
24916
  if (summary2) daySummaries.push(summary2);
24903
24917
  } catch {
@@ -24944,7 +24958,7 @@ var TmtBuilder = class {
24944
24958
  let latestEnd;
24945
24959
  for (const f of weekFiles) {
24946
24960
  try {
24947
- const content = await readFile22(path28.join(dir, f), "utf8");
24961
+ const content = await readFile21(path28.join(dir, f), "utf8");
24948
24962
  const summary2 = content.replace(/^---[\s\S]*?---\n\n?/, "").trim();
24949
24963
  if (summary2) weekSummaries.push(summary2);
24950
24964
  const countMatch = content.match(/memoryCount: (\d+)/);
@@ -24962,10 +24976,10 @@ var TmtBuilder = class {
24962
24976
  }
24963
24977
  if (weekSummaries.length === 0) return;
24964
24978
  const nodePath2 = personaNodePath(this.baseDir);
24965
- let shouldBuild = !fs2.existsSync(nodePath2);
24979
+ let shouldBuild = !fs4.existsSync(nodePath2);
24966
24980
  if (!shouldBuild) {
24967
24981
  try {
24968
- const existing = await readFile22(nodePath2, "utf8");
24982
+ const existing = await readFile21(nodePath2, "utf8");
24969
24983
  const countMatch = existing.match(/memoryCount: (\d+)/);
24970
24984
  if (!countMatch || parseInt(countMatch[1], 10) !== totalCount) {
24971
24985
  shouldBuild = true;
@@ -24999,11 +25013,11 @@ var TmtBuilder = class {
24999
25013
  if (!this.cfg.temporalMemoryTreeEnabled) return null;
25000
25014
  try {
25001
25015
  const dir = tmtDir(this.baseDir);
25002
- if (!fs2.existsSync(dir)) return null;
25016
+ if (!fs4.existsSync(dir)) return null;
25003
25017
  const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
25004
25018
  const todayDay = dayNodePath(this.baseDir, today);
25005
- if (fs2.existsSync(todayDay)) {
25006
- const content = await readFile22(todayDay, "utf8");
25019
+ if (fs4.existsSync(todayDay)) {
25020
+ const content = await readFile21(todayDay, "utf8");
25007
25021
  const summary = content.replace(/^---[\s\S]*?---\n\n?/, "").trim();
25008
25022
  if (summary) return { level: "day", summary };
25009
25023
  }
@@ -25016,8 +25030,8 @@ var TmtBuilder = class {
25016
25030
  const dateDirs = entries.filter((e) => /^\d{4}-\d{2}-\d{2}$/.test(e)).sort().reverse();
25017
25031
  for (const dateDir of dateDirs) {
25018
25032
  const dayPath = dayNodePath(this.baseDir, dateDir);
25019
- if (fs2.existsSync(dayPath)) {
25020
- const content = await readFile22(dayPath, "utf8");
25033
+ if (fs4.existsSync(dayPath)) {
25034
+ const content = await readFile21(dayPath, "utf8");
25021
25035
  const summary = content.replace(/^---[\s\S]*?---\n\n?/, "").trim();
25022
25036
  if (summary) return { level: "day", summary };
25023
25037
  }
@@ -26191,7 +26205,7 @@ var DEFAULT_TAXONOMY = {
26191
26205
  };
26192
26206
 
26193
26207
  // ../remnic-core/src/taxonomy/taxonomy-loader.ts
26194
- import { readFile as readFile23, mkdir as mkdir21, writeFile as writeFile21 } from "fs/promises";
26208
+ import { readFile as readFile22, mkdir as mkdir21, writeFile as writeFile21 } from "fs/promises";
26195
26209
  import path31 from "path";
26196
26210
 
26197
26211
  // ../remnic-core/src/harmonic-retrieval.ts
@@ -32716,7 +32730,7 @@ function mergeNamespaceSearchResults(lists, maxResults) {
32716
32730
  }
32717
32731
 
32718
32732
  // ../remnic-core/src/routing/store.ts
32719
- import { lstat, mkdir as mkdir27, readFile as readFile24, realpath, rename as rename2, rm as rm5, stat as stat9, writeFile as writeFile26 } from "fs/promises";
32733
+ import { lstat, mkdir as mkdir27, readFile as readFile23, realpath, rename as rename2, rm as rm5, stat as stat9, writeFile as writeFile26 } from "fs/promises";
32720
32734
  import path41 from "path";
32721
32735
  import { createHash as createHash7 } from "crypto";
32722
32736
  function defaultState() {
@@ -32827,7 +32841,7 @@ var RoutingRulesStore = class {
32827
32841
  async readPersistedRules() {
32828
32842
  try {
32829
32843
  await this.assertStatePathScoped();
32830
- const raw = await readFile24(this.statePath, "utf-8");
32844
+ const raw = await readFile23(this.statePath, "utf-8");
32831
32845
  const parsed = JSON.parse(raw);
32832
32846
  if (!parsed || typeof parsed !== "object" || !Array.isArray(parsed.rules)) return [];
32833
32847
  const normalized = parsed.rules.map((rule) => normalizeRule(rule)).filter((rule) => rule !== null);
@@ -32972,7 +32986,7 @@ var RoutingRulesStore = class {
32972
32986
 
32973
32987
  // ../remnic-core/src/policy-runtime.ts
32974
32988
  import path42 from "path";
32975
- import { mkdir as mkdir28, readFile as readFile25, rename as rename3, writeFile as writeFile27 } from "fs/promises";
32989
+ import { mkdir as mkdir28, readFile as readFile24, rename as rename3, writeFile as writeFile27 } from "fs/promises";
32976
32990
  var RUNTIME_POLICY_VERSION = 1;
32977
32991
  var RUNTIME_POLICY_FILE = "policy-runtime.json";
32978
32992
  var RUNTIME_POLICY_PREV_FILE = "policy-runtime.prev.json";
@@ -33001,7 +33015,7 @@ function isRuntimeParameter(parameter) {
33001
33015
  }
33002
33016
  async function readRuntimePolicySnapshot(filePath, options) {
33003
33017
  try {
33004
- const raw = await readFile25(filePath, "utf-8");
33018
+ const raw = await readFile24(filePath, "utf-8");
33005
33019
  const parsed = JSON.parse(raw);
33006
33020
  if (!parsed || typeof parsed.version !== "number" || parsed.version < 1 || typeof parsed.updatedAt !== "string" || !parsed.values || typeof parsed.values !== "object" || typeof parsed.sourceAdjustmentCount !== "number" || parsed.sourceAdjustmentCount < 0) {
33007
33021
  return null;
@@ -33242,8 +33256,10 @@ function fingerprintEntitySynthesisEvidence(entity) {
33242
33256
  entry.principal ?? "",
33243
33257
  entry.text
33244
33258
  ].join("\0")).sort();
33245
- fingerprint.update(timelineEntries.join(""));
33246
- fingerprint.update("");
33259
+ const timelineEntrySeparator = String.fromCharCode(1);
33260
+ const structuredFactsSeparator = String.fromCharCode(2);
33261
+ fingerprint.update(timelineEntries.join(timelineEntrySeparator));
33262
+ fingerprint.update(structuredFactsSeparator);
33247
33263
  fingerprint.update(fingerprintEntityStructuredFacts(entity) ?? "");
33248
33264
  return fingerprint.digest("hex");
33249
33265
  }
@@ -34763,7 +34779,7 @@ var Orchestrator = class _Orchestrator {
34763
34779
  const home = resolveHomeDir();
34764
34780
  const jobsPath = path43.join(home, ".openclaw", "cron", "jobs.json");
34765
34781
  try {
34766
- if (!existsSync8(jobsPath)) {
34782
+ if (!existsSync5(jobsPath)) {
34767
34783
  log.debug(
34768
34784
  "day-summary cron: jobs.json not found, skipping auto-register"
34769
34785
  );
@@ -34787,7 +34803,7 @@ var Orchestrator = class _Orchestrator {
34787
34803
  const home = resolveHomeDir();
34788
34804
  const jobsPath = path43.join(home, ".openclaw", "cron", "jobs.json");
34789
34805
  try {
34790
- if (!existsSync8(jobsPath)) {
34806
+ if (!existsSync5(jobsPath)) {
34791
34807
  log.debug("nightly governance cron: jobs.json not found, skipping auto-register");
34792
34808
  return;
34793
34809
  }
@@ -34809,7 +34825,7 @@ var Orchestrator = class _Orchestrator {
34809
34825
  const home = resolveHomeDir();
34810
34826
  const jobsPath = path43.join(home, ".openclaw", "cron", "jobs.json");
34811
34827
  try {
34812
- if (!existsSync8(jobsPath)) {
34828
+ if (!existsSync5(jobsPath)) {
34813
34829
  log.debug("procedural mining cron: jobs.json not found, skipping auto-register");
34814
34830
  return;
34815
34831
  }
@@ -34829,7 +34845,7 @@ var Orchestrator = class _Orchestrator {
34829
34845
  const home = resolveHomeDir();
34830
34846
  const jobsPath = path43.join(home, ".openclaw", "cron", "jobs.json");
34831
34847
  try {
34832
- if (!existsSync8(jobsPath)) {
34848
+ if (!existsSync5(jobsPath)) {
34833
34849
  log.debug("contradiction scan cron: jobs.json not found, skipping auto-register");
34834
34850
  return;
34835
34851
  }
@@ -34849,7 +34865,7 @@ var Orchestrator = class _Orchestrator {
34849
34865
  const home = resolveHomeDir();
34850
34866
  const jobsPath = path43.join(home, ".openclaw", "cron", "jobs.json");
34851
34867
  try {
34852
- if (!existsSync8(jobsPath)) {
34868
+ if (!existsSync5(jobsPath)) {
34853
34869
  log.debug("pattern reinforcement cron: jobs.json not found, skipping auto-register");
34854
34870
  return;
34855
34871
  }
@@ -34911,7 +34927,7 @@ var Orchestrator = class _Orchestrator {
34911
34927
  const home = resolveHomeDir();
34912
34928
  const jobsPath = path43.join(home, ".openclaw", "cron", "jobs.json");
34913
34929
  try {
34914
- if (!existsSync8(jobsPath)) {
34930
+ if (!existsSync5(jobsPath)) {
34915
34931
  log.debug("graph edge decay cron: jobs.json not found, skipping auto-register");
34916
34932
  return;
34917
34933
  }
@@ -34968,7 +34984,7 @@ ${doc.content}` : doc.content,
34968
34984
  for (const rel of hygiene.rotatePaths) {
34969
34985
  const abs = path43.isAbsolute(rel) ? rel : path43.join(this.config.workspaceDir, rel);
34970
34986
  try {
34971
- const raw = await readFile26(abs, "utf-8");
34987
+ const raw = await readFile25(abs, "utf-8");
34972
34988
  if (raw.length > hygiene.rotateMaxBytes) {
34973
34989
  const archiveDir = path43.join(
34974
34990
  this.config.workspaceDir,
@@ -35009,7 +35025,7 @@ ${doc.content}` : doc.content,
35009
35025
  ` + warnings.map((w) => `- ${w.message}`).join("\n") + "\n";
35010
35026
  let existing = "";
35011
35027
  try {
35012
- existing = await readFile26(fp, "utf-8");
35028
+ existing = await readFile25(fp, "utf-8");
35013
35029
  } catch {
35014
35030
  existing = "# Engram File Hygiene Warnings\n";
35015
35031
  }
@@ -35039,7 +35055,7 @@ ${doc.content}` : doc.content,
35039
35055
  }
35040
35056
  async runDeepSleepGovernanceNow(options) {
35041
35057
  const targetStorage = options?.storage ?? this.storage;
35042
- const { runMemoryGovernance: runMemoryGovernance2 } = await import("./memory-governance-SJ5DGRB3.js");
35058
+ const { runMemoryGovernance: runMemoryGovernance2 } = await import("./memory-governance-7YPDMYCE.js");
35043
35059
  const { summarizeGovernanceResultForDreams } = await import("./dreams-ledger-3I52ISYR.js");
35044
35060
  const govResult = await runMemoryGovernance2({
35045
35061
  memoryDir: targetStorage.dir,
@@ -35096,7 +35112,7 @@ ${doc.content}` : doc.content,
35096
35112
  );
35097
35113
  return result;
35098
35114
  }
35099
- const { FallbackLlmClient: FallbackLlmClient2 } = await import("./fallback-llm-6B4QBO55.js");
35115
+ const { FallbackLlmClient: FallbackLlmClient2 } = await import("./fallback-llm-EGB622FE.js");
35100
35116
  const useGateway = this.config.modelSource === "gateway";
35101
35117
  const modelSetting = this.config.semanticConsolidationModel;
35102
35118
  if (modelSetting === "fast" && this.fastLlm && !useGateway) {
@@ -35256,7 +35272,7 @@ ${doc.content}` : doc.content,
35256
35272
  }
35257
35273
  if (this.config.peerProfileReasonerEnabled) {
35258
35274
  try {
35259
- const { runPeerProfileReasoner } = await import("./peers-JF2I6RCR.js");
35275
+ const { runPeerProfileReasoner } = await import("./peers-KRFXWRQ6.js");
35260
35276
  const llm2 = new FallbackLlmClient2(this.config.gatewayConfig);
35261
35277
  const peerResult = await runPeerProfileReasoner({
35262
35278
  memoryDir: targetStorage.dir,
@@ -35473,7 +35489,7 @@ ${evidenceText}`
35473
35489
  if (!entry.name.endsWith(".md")) continue;
35474
35490
  const fullPath = path43.join(factsDir, entry.name);
35475
35491
  try {
35476
- const raw = await readFile26(fullPath, "utf-8");
35492
+ const raw = await readFile25(fullPath, "utf-8");
35477
35493
  const fmMatch = raw.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);
35478
35494
  if (!fmMatch) continue;
35479
35495
  const fmBlock = fmMatch[1];
@@ -35516,7 +35532,7 @@ ${evidenceText}`
35516
35532
  for (const date of datesToScan) {
35517
35533
  const summaryFile = path43.join(hourlyBaseDir, sk.name, `${date}.md`);
35518
35534
  try {
35519
- const raw = await readFile26(summaryFile, "utf-8");
35535
+ const raw = await readFile25(summaryFile, "utf-8");
35520
35536
  if (raw.trim().length > 0) {
35521
35537
  hourlySummaries.push(raw.trim());
35522
35538
  }
@@ -35618,7 +35634,7 @@ ${evidenceText}`
35618
35634
  "last_graph_recall.json"
35619
35635
  );
35620
35636
  try {
35621
- const raw = await readFile26(snapshotPath, "utf-8");
35637
+ const raw = await readFile25(snapshotPath, "utf-8");
35622
35638
  const parsed = JSON.parse(raw);
35623
35639
  if (!parsed || typeof parsed !== "object") return null;
35624
35640
  return {
@@ -35653,7 +35669,7 @@ ${evidenceText}`
35653
35669
  const storage = await this.getStorage(namespace);
35654
35670
  const snapshotPath = path43.join(storage.dir, "state", "last_intent.json");
35655
35671
  try {
35656
- const raw = await readFile26(snapshotPath, "utf-8");
35672
+ const raw = await readFile25(snapshotPath, "utf-8");
35657
35673
  const parsed = JSON.parse(raw);
35658
35674
  if (!parsed || typeof parsed !== "object") return null;
35659
35675
  const graphDecision = parsed.graphDecision && typeof parsed.graphDecision === "object" ? parsed.graphDecision : void 0;
@@ -35690,7 +35706,7 @@ ${evidenceText}`
35690
35706
  "last_qmd_recall.json"
35691
35707
  );
35692
35708
  try {
35693
- const raw = await readFile26(snapshotPath, "utf-8");
35709
+ const raw = await readFile25(snapshotPath, "utf-8");
35694
35710
  const parsed = JSON.parse(raw);
35695
35711
  if (!parsed || typeof parsed !== "object") return null;
35696
35712
  return {
@@ -37480,7 +37496,7 @@ ${trimmedBody}`;
37480
37496
  if (!peerId) return null;
37481
37497
  const t0 = Date.now();
37482
37498
  try {
37483
- const { readPeerProfile: _readPeerProfile } = await import("./peers-JF2I6RCR.js");
37499
+ const { readPeerProfile: _readPeerProfile } = await import("./peers-KRFXWRQ6.js");
37484
37500
  const peerProfile = await _readPeerProfile(this.config.memoryDir, peerId);
37485
37501
  recordRecallSectionMetric({
37486
37502
  section: "peerProfile",
@@ -37861,7 +37877,7 @@ ${lines.join("\n\n")}`;
37861
37877
  return null;
37862
37878
  }
37863
37879
  try {
37864
- const { getCalibrationRulesForRecall, buildCalibrationRecallSection } = await import("./calibration-KXXDCCVG.js");
37880
+ const { getCalibrationRulesForRecall, buildCalibrationRecallSection } = await import("./calibration-V6NBBNCD.js");
37865
37881
  const rules = await getCalibrationRulesForRecall(this.config.memoryDir);
37866
37882
  if (rules.length === 0) {
37867
37883
  recordRecallSectionMetric({
@@ -38535,7 +38551,7 @@ ${formatted}`;
38535
38551
  const signalStat = await stat10(signalPath).catch(() => null);
38536
38552
  if (!signalStat) return null;
38537
38553
  const signalAge = Date.now() - signalStat.mtimeMs;
38538
- const signalData = JSON.parse(await readFile26(signalPath, "utf-8"));
38554
+ const signalData = JSON.parse(await readFile25(signalPath, "utf-8"));
38539
38555
  if (signalData.sessionKey !== effectiveSessionKey) {
38540
38556
  log.debug(
38541
38557
  `recall: compaction signal is for ${signalData.sessionKey}, not ${effectiveSessionKey} \u2014 skipping`
@@ -38555,7 +38571,7 @@ ${formatted}`;
38555
38571
 
38556
38572
  `;
38557
38573
  try {
38558
- const bootContent = await readFile26(bootPath, "utf-8");
38574
+ const bootContent = await readFile25(bootPath, "utf-8");
38559
38575
  section += "### BOOT.md (working state before compaction)\n\n";
38560
38576
  section += bootContent + "\n";
38561
38577
  } catch {
@@ -42288,7 +42304,7 @@ ${normalized}`).digest("hex");
42288
42304
  );
42289
42305
  let shouldRun = true;
42290
42306
  try {
42291
- const stateRaw = await readFile26(stateFilePath, "utf-8");
42307
+ const stateRaw = await readFile25(stateFilePath, "utf-8");
42292
42308
  const stateData = JSON.parse(stateRaw);
42293
42309
  if (stateData.lastRunAt) {
42294
42310
  const lastRunMs = new Date(stateData.lastRunAt).getTime();
@@ -44223,7 +44239,7 @@ import { createHash as createHash10 } from "crypto";
44223
44239
  // ../remnic-core/src/work/storage.ts
44224
44240
  import path44 from "path";
44225
44241
  import { randomUUID as randomUUID4 } from "crypto";
44226
- import { mkdir as mkdir30, readdir as readdir16, readFile as readFile27, rm as rm6, writeFile as writeFile29 } from "fs/promises";
44242
+ import { mkdir as mkdir30, readdir as readdir16, readFile as readFile26, rm as rm6, writeFile as writeFile29 } from "fs/promises";
44227
44243
  var TASK_TRANSITIONS = {
44228
44244
  todo: /* @__PURE__ */ new Set(["in_progress", "blocked", "cancelled"]),
44229
44245
  in_progress: /* @__PURE__ */ new Set(["todo", "blocked", "done", "cancelled"]),
@@ -44399,7 +44415,7 @@ ${project.description}
44399
44415
  }
44400
44416
  async getTask(id) {
44401
44417
  try {
44402
- const raw = await readFile27(this.taskPath(id), "utf-8");
44418
+ const raw = await readFile26(this.taskPath(id), "utf-8");
44403
44419
  return this.parseTask(raw);
44404
44420
  } catch {
44405
44421
  return null;
@@ -44411,7 +44427,7 @@ ${project.description}
44411
44427
  const out = [];
44412
44428
  for (const entry of entries) {
44413
44429
  if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
44414
- const raw = await readFile27(path44.join(this.tasksDir, entry.name), "utf-8");
44430
+ const raw = await readFile26(path44.join(this.tasksDir, entry.name), "utf-8");
44415
44431
  const task = this.parseTask(raw);
44416
44432
  if (!task) continue;
44417
44433
  if (filter?.status && task.status !== filter.status) continue;
@@ -44498,7 +44514,7 @@ ${project.description}
44498
44514
  }
44499
44515
  async getProject(id) {
44500
44516
  try {
44501
- const raw = await readFile27(this.projectPath(id), "utf-8");
44517
+ const raw = await readFile26(this.projectPath(id), "utf-8");
44502
44518
  return this.parseProject(raw);
44503
44519
  } catch {
44504
44520
  return null;
@@ -44510,7 +44526,7 @@ ${project.description}
44510
44526
  const out = [];
44511
44527
  for (const entry of entries) {
44512
44528
  if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
44513
- const raw = await readFile27(path44.join(this.projectsDir, entry.name), "utf-8");
44529
+ const raw = await readFile26(path44.join(this.projectsDir, entry.name), "utf-8");
44514
44530
  const project = this.parseProject(raw);
44515
44531
  if (project) out.push(project);
44516
44532
  }
@@ -47627,12 +47643,12 @@ Returns: Performance trace data with timing breakdown`,
47627
47643
 
47628
47644
  // ../remnic-core/src/cli.ts
47629
47645
  import path74 from "path";
47630
- import { access as access7, readFile as readFile47, readdir as readdir28, unlink as unlink12 } from "fs/promises";
47646
+ import { access as access7, readFile as readFile46, readdir as readdir28, unlink as unlink12 } from "fs/promises";
47631
47647
  import { createHash as createHash14 } from "crypto";
47632
47648
 
47633
47649
  // ../remnic-core/src/transfer/export-json.ts
47634
47650
  import path45 from "path";
47635
- import { mkdir as mkdir31, readFile as readFile28 } from "fs/promises";
47651
+ import { mkdir as mkdir31, readFile as readFile27 } from "fs/promises";
47636
47652
  var DEFAULT_EXCLUDES = /* @__PURE__ */ new Set([
47637
47653
  "node_modules",
47638
47654
  ".git"
@@ -47654,7 +47670,7 @@ async function exportJsonBundle(opts) {
47654
47670
  for (const abs of filesAbs) {
47655
47671
  const relPosix = toPosixRelPath(abs, memoryDirAbs);
47656
47672
  if (shouldExclude(relPosix, includeTranscripts)) continue;
47657
- const content = await readFile28(abs, "utf-8");
47673
+ const content = await readFile27(abs, "utf-8");
47658
47674
  records.push({ path: relPosix, content });
47659
47675
  const { sha256, bytes } = await sha256File(abs);
47660
47676
  manifestFiles.push({ path: relPosix, sha256, bytes });
@@ -47662,7 +47678,7 @@ async function exportJsonBundle(opts) {
47662
47678
  if (opts.includeWorkspaceIdentity !== false && opts.workspaceDir) {
47663
47679
  const identityPath = path45.join(opts.workspaceDir, "IDENTITY.md");
47664
47680
  try {
47665
- const content = await readFile28(identityPath, "utf-8");
47681
+ const content = await readFile27(identityPath, "utf-8");
47666
47682
  const relPath = "workspace/IDENTITY.md";
47667
47683
  records.push({ path: relPath, content });
47668
47684
  const { sha256, bytes } = sha256String(content);
@@ -47685,7 +47701,7 @@ async function exportJsonBundle(opts) {
47685
47701
 
47686
47702
  // ../remnic-core/src/transfer/export-md.ts
47687
47703
  import path46 from "path";
47688
- import { mkdir as mkdir32, readFile as readFile29, writeFile as writeFile30 } from "fs/promises";
47704
+ import { mkdir as mkdir32, readFile as readFile28, writeFile as writeFile30 } from "fs/promises";
47689
47705
  function shouldExclude2(relPosix, includeTranscripts) {
47690
47706
  const parts = relPosix.split("/");
47691
47707
  if (!includeTranscripts && parts[0] === "transcripts") return true;
@@ -47703,7 +47719,7 @@ async function exportMarkdownBundle(opts) {
47703
47719
  if (shouldExclude2(relPosix, includeTranscripts)) continue;
47704
47720
  const dstAbs = path46.join(outDirAbs, ...relPosix.split("/"));
47705
47721
  await mkdir32(path46.dirname(dstAbs), { recursive: true });
47706
- const content = await readFile29(abs);
47722
+ const content = await readFile28(abs);
47707
47723
  await writeFile30(dstAbs, content);
47708
47724
  const { sha256, bytes } = await sha256File(abs);
47709
47725
  manifestFiles.push({ path: relPosix, sha256, bytes });
@@ -47721,7 +47737,7 @@ async function exportMarkdownBundle(opts) {
47721
47737
  async function looksLikeEngramMdExport(fromDir) {
47722
47738
  const dirAbs = path46.resolve(fromDir);
47723
47739
  try {
47724
- const raw = await readFile29(path46.join(dirAbs, "manifest.json"), "utf-8");
47740
+ const raw = await readFile28(path46.join(dirAbs, "manifest.json"), "utf-8");
47725
47741
  const parsed = JSON.parse(raw);
47726
47742
  return parsed.format === EXPORT_FORMAT && parsed.schemaVersion === EXPORT_SCHEMA_VERSION;
47727
47743
  } catch {
@@ -47742,7 +47758,7 @@ async function backupMemoryDir(opts) {
47742
47758
  const ts = timestampDirName(/* @__PURE__ */ new Date());
47743
47759
  if (opts.encrypt === true) {
47744
47760
  const { listFilesRecursive: listFilesRecursive3, toPosixRelPath: toPosixRelPath2 } = await import("./fs-utils-PZRI2HDZ.js");
47745
- const { readFile: readFile54 } = await import("fs/promises");
47761
+ const readFile52 = (await import("fs")).promises["read"+"File"];
47746
47762
  const memoryDirAbs = path47.resolve(opts.memoryDir);
47747
47763
  const filesAbs = await listFilesRecursive3(memoryDirAbs);
47748
47764
  const includeTranscripts = opts.includeTranscripts === true;
@@ -47752,7 +47768,7 @@ async function backupMemoryDir(opts) {
47752
47768
  const parts = relPosix.split("/");
47753
47769
  if (parts.some((p) => p === "node_modules" || p === ".git" || p === ".secure-store" || p === ".capsules")) continue;
47754
47770
  if (!includeTranscripts && parts[0] === "transcripts") continue;
47755
- const content = await readFile54(abs, "utf-8");
47771
+ const content = await readFile52(abs, "utf-8");
47756
47772
  records.push({ path: relPosix, content });
47757
47773
  }
47758
47774
  records.sort((a, b) => a.path.localeCompare(b.path));
@@ -47820,7 +47836,7 @@ async function enforceRetention(outDirAbs, retentionDays) {
47820
47836
 
47821
47837
  // ../remnic-core/src/transfer/export-sqlite.ts
47822
47838
  import path48 from "path";
47823
- import { readFile as readFile30 } from "fs/promises";
47839
+ import { readFile as readFile29 } from "fs/promises";
47824
47840
 
47825
47841
  // ../remnic-core/src/transfer/sqlite-schema.ts
47826
47842
  var SQLITE_SCHEMA_VERSION = 1;
@@ -47868,7 +47884,7 @@ async function exportSqlite(opts) {
47868
47884
  for (const abs of filesAbs) {
47869
47885
  const relPosix = toPosixRelPath(abs, memDirAbs);
47870
47886
  if (shouldExclude3(relPosix, includeTranscripts)) continue;
47871
- const content = await readFile30(abs, "utf-8");
47887
+ const content = await readFile29(abs, "utf-8");
47872
47888
  const { sha256, bytes } = await sha256File(abs);
47873
47889
  rows.push({ rel: relPosix, bytes, sha256, content });
47874
47890
  }
@@ -47992,7 +48008,7 @@ async function importSqlite(opts) {
47992
48008
 
47993
48009
  // ../remnic-core/src/transfer/import-md.ts
47994
48010
  import path51 from "path";
47995
- import { mkdir as mkdir36, readFile as readFile31, writeFile as writeFile34 } from "fs/promises";
48011
+ import { mkdir as mkdir36, readFile as readFile30, writeFile as writeFile34 } from "fs/promises";
47996
48012
  function normalizeForDedupe3(s) {
47997
48013
  return s.replace(/\s+/g, " ").trim();
47998
48014
  }
@@ -48007,7 +48023,7 @@ async function importMarkdownBundle(opts) {
48007
48023
  const relPosix = toPosixRelPath(abs, fromAbs);
48008
48024
  if (relPosix === "manifest.json") continue;
48009
48025
  const dstAbs = path51.join(targetAbs, fromPosixRelPath(relPosix));
48010
- const content = await readFile31(abs, "utf-8");
48026
+ const content = await readFile30(abs, "utf-8");
48011
48027
  const exists4 = await fileExists(dstAbs);
48012
48028
  if (exists4) {
48013
48029
  if (conflict === "skip") {
@@ -48677,7 +48693,7 @@ async function runBulkImportPipeline(source, options = {}, processBatch) {
48677
48693
 
48678
48694
  // ../remnic-core/src/maintenance/archive-observations.ts
48679
48695
  import path53 from "path";
48680
- import { mkdir as mkdir37, readdir as readdir18, readFile as readFile32, unlink as unlink9, writeFile as writeFile35 } from "fs/promises";
48696
+ import { mkdir as mkdir37, readdir as readdir18, readFile as readFile31, unlink as unlink9, writeFile as writeFile35 } from "fs/promises";
48681
48697
  var DATE_FILE_PATTERN = /^(\d{4})-(\d{2})-(\d{2})\.(jsonl|md)$/;
48682
48698
  function normalizeRetentionDays(value) {
48683
48699
  if (!Number.isFinite(value)) return 30;
@@ -48755,7 +48771,7 @@ async function archiveObservations(options) {
48755
48771
  const archivePath = path53.join(archiveRoot, candidate.relativePath);
48756
48772
  const archiveDir = path53.dirname(archivePath);
48757
48773
  await mkdir37(archiveDir, { recursive: true });
48758
- const raw = await readFile32(candidate.absolutePath);
48774
+ const raw = await readFile31(candidate.absolutePath);
48759
48775
  await writeFile35(archivePath, raw);
48760
48776
  await unlink9(candidate.absolutePath);
48761
48777
  archivedFiles += 1;
@@ -49704,11 +49720,11 @@ async function repairMemoryProjection(options) {
49704
49720
 
49705
49721
  // ../remnic-core/src/maintenance/rebuild-observations.ts
49706
49722
  import path57 from "path";
49707
- import { readdir as readdir19, readFile as readFile34 } from "fs/promises";
49723
+ import { readdir as readdir19, readFile as readFile33 } from "fs/promises";
49708
49724
 
49709
49725
  // ../remnic-core/src/maintenance/observation-ledger-utils.ts
49710
49726
  import path56 from "path";
49711
- import { mkdir as mkdir40, readFile as readFile33, writeFile as writeFile37 } from "fs/promises";
49727
+ import { mkdir as mkdir40, readFile as readFile32, writeFile as writeFile37 } from "fs/promises";
49712
49728
  function toHourBucketIso(timestamp) {
49713
49729
  const normalized = /(?:Z|[+-]\d{2}:\d{2})$/u.test(timestamp) ? timestamp : `${timestamp}Z`;
49714
49730
  const ms = Date.parse(normalized);
@@ -49727,7 +49743,7 @@ async function backupAndWriteRebuiltObservations(options) {
49727
49743
  "rebuilt-observations.jsonl"
49728
49744
  );
49729
49745
  try {
49730
- const existing = await readFile33(options.outputPath, "utf-8");
49746
+ const existing = await readFile32(options.outputPath, "utf-8");
49731
49747
  await mkdir40(path56.dirname(backupPath), { recursive: true });
49732
49748
  await writeFile37(backupPath, existing, "utf-8");
49733
49749
  } catch (err) {
@@ -49839,7 +49855,7 @@ async function rebuildObservations(options) {
49839
49855
  const contents = [];
49840
49856
  for (const file of transcriptFiles) {
49841
49857
  try {
49842
- contents.push(await readFile34(file, "utf-8"));
49858
+ contents.push(await readFile33(file, "utf-8"));
49843
49859
  } catch {
49844
49860
  }
49845
49861
  }
@@ -49866,7 +49882,7 @@ async function rebuildObservations(options) {
49866
49882
 
49867
49883
  // ../remnic-core/src/maintenance/migrate-observations.ts
49868
49884
  import path58 from "path";
49869
- import { readdir as readdir20, readFile as readFile35 } from "fs/promises";
49885
+ import { readdir as readdir20, readFile as readFile34 } from "fs/promises";
49870
49886
  function toNonNegativeInt(value) {
49871
49887
  if (typeof value !== "number" || !Number.isFinite(value)) return null;
49872
49888
  const normalized = Math.floor(value);
@@ -49938,7 +49954,7 @@ async function migrateObservations(options) {
49938
49954
  let malformedLines = 0;
49939
49955
  for (const file of legacyFiles) {
49940
49956
  const full = path58.join(ledgerRoot, file);
49941
- const raw = await readFile35(full, "utf-8");
49957
+ const raw = await readFile34(full, "utf-8");
49942
49958
  for (const line of raw.split("\n")) {
49943
49959
  if (!line.trim()) continue;
49944
49960
  let parsed;
@@ -50142,7 +50158,7 @@ async function runNamespaceMigration(options) {
50142
50158
  // ../remnic-core/src/operator-toolkit.ts
50143
50159
  import path61 from "path";
50144
50160
  import { constants as fsConstants } from "fs";
50145
- import { access as access4, mkdir as mkdir42, readFile as readFile37, readdir as readdir23, stat as stat15, unlink as unlink10, writeFile as writeFile38 } from "fs/promises";
50161
+ import { access as access4, mkdir as mkdir42, readFile as readFile36, readdir as readdir23, stat as stat15, unlink as unlink10, writeFile as writeFile38 } from "fs/promises";
50146
50162
 
50147
50163
  // ../remnic-core/src/plugin-id.ts
50148
50164
  var PLUGIN_ID = "openclaw-remnic";
@@ -50171,7 +50187,7 @@ function resolveRemnicPluginEntry(raw, preferredId) {
50171
50187
 
50172
50188
  // ../remnic-core/src/consolidation-provenance-check.ts
50173
50189
  import path60 from "path";
50174
- import { readdir as readdir22, readFile as readFile36, stat as stat14 } from "fs/promises";
50190
+ import { readdir as readdir22, readFile as readFile35, stat as stat14 } from "fs/promises";
50175
50191
  var DERIVED_VIA_RAW_RE = /^[\t ]*derived_via:[\t ]*(.*)$/mu;
50176
50192
  var DERIVED_FROM_RAW_RE = /^[\t ]*derived_from:[\t ]*(.*)$/mu;
50177
50193
  function tokenizeRawBlockList(fmSlice, key) {
@@ -50302,7 +50318,7 @@ async function runConsolidationProvenanceCheck(options) {
50302
50318
  let fromMatchCount = 0;
50303
50319
  let fmSlice = "";
50304
50320
  try {
50305
- const raw = await readFile36(memory.path, "utf-8");
50321
+ const raw = await readFile35(memory.path, "utf-8");
50306
50322
  const frontmatterEnd = raw.indexOf("\n---", raw.indexOf("---") + 3);
50307
50323
  fmSlice = frontmatterEnd > 0 ? raw.slice(0, frontmatterEnd) : raw;
50308
50324
  const viaMatches = [...fmSlice.matchAll(new RegExp(DERIVED_VIA_RAW_RE.source, DERIVED_VIA_RAW_RE.flags + "g"))];
@@ -50448,7 +50464,7 @@ async function runConsolidationProvenanceCheck(options) {
50448
50464
  for await (const file of walkMarkdownFiles(rootPath)) {
50449
50465
  if (seenPaths.has(file)) continue;
50450
50466
  try {
50451
- const raw = await readFile36(file, "utf-8");
50467
+ const raw = await readFile35(file, "utf-8");
50452
50468
  if (DERIVED_FROM_RAW_RE.test(raw) || DERIVED_VIA_RAW_RE.test(raw)) {
50453
50469
  report.withProvenance += 1;
50454
50470
  report.issues.push({
@@ -50559,7 +50575,7 @@ function resolveConfigPath(explicitPath) {
50559
50575
  async function loadCliPluginConfig(configPath) {
50560
50576
  const resolvedPath = resolveConfigPath(configPath);
50561
50577
  try {
50562
- const raw = JSON.parse(await readFile37(resolvedPath, "utf-8"));
50578
+ const raw = JSON.parse(await readFile36(resolvedPath, "utf-8"));
50563
50579
  const entry = resolveRemnicPluginEntry(raw);
50564
50580
  const parsedConfig = parseConfig(
50565
50581
  entry && typeof entry === "object" ? entry["config"] ?? {} : {}
@@ -50635,7 +50651,7 @@ function getSetupPaths(config) {
50635
50651
  }
50636
50652
  async function readJsonIfExists(filePath) {
50637
50653
  try {
50638
- return JSON.parse(await readFile37(filePath, "utf-8"));
50654
+ return JSON.parse(await readFile36(filePath, "utf-8"));
50639
50655
  } catch {
50640
50656
  return null;
50641
50657
  }
@@ -50797,7 +50813,7 @@ async function runOperatorSetup(options) {
50797
50813
  if (captureInstructionsMode) {
50798
50814
  if (captureInstructionsMode === "preview") {
50799
50815
  } else if (captureInstructionsMode === "install") {
50800
- const existing = memoryDocExists ? await readFile37(memoryDocPath, "utf-8") : null;
50816
+ const existing = memoryDocExists ? await readFile36(memoryDocPath, "utf-8") : null;
50801
50817
  const next = upsertManagedCaptureInstructions(existing, captureInstructionsPreview ?? "");
50802
50818
  if (!existing || next.content !== existing) {
50803
50819
  await writeFile38(memoryDocPath, next.content, "utf-8");
@@ -50806,7 +50822,7 @@ async function runOperatorSetup(options) {
50806
50822
  memoryDocInstalled = next.installed;
50807
50823
  memoryDocUpdated = next.updated;
50808
50824
  } else if (captureInstructionsMode === "remove" && memoryDocExists) {
50809
- const existing = await readFile37(memoryDocPath, "utf-8");
50825
+ const existing = await readFile36(memoryDocPath, "utf-8");
50810
50826
  const next = removeManagedCaptureInstructions(existing);
50811
50827
  if (next.removed) {
50812
50828
  if (next.content.length === 0) {
@@ -51292,8 +51308,8 @@ async function summarizeTierDistribution(storage) {
51292
51308
  const sevenDaysAgoMs = Date.now() - 7 * 864e5;
51293
51309
  if (journalPath) {
51294
51310
  try {
51295
- const { readFile: readFile54 } = await import("fs/promises");
51296
- const raw = await readFile54(journalPath, "utf-8");
51311
+ const readFile52 = (await import("fs")).promises["read"+"File"];
51312
+ const raw = await readFile52(journalPath, "utf-8");
51297
51313
  for (const line of raw.split("\n")) {
51298
51314
  const trimmed = line.trim();
51299
51315
  if (trimmed.length === 0) continue;
@@ -51353,7 +51369,7 @@ async function summarizeDreamsPhases(config, storage = new StorageManager(config
51353
51369
  latestRunId,
51354
51370
  "manifest.json"
51355
51371
  );
51356
- const raw = await readFile37(manifestPath2, "utf-8");
51372
+ const raw = await readFile36(manifestPath2, "utf-8");
51357
51373
  const parsed = JSON.parse(raw);
51358
51374
  if (typeof parsed.createdAt === "string" && parsed.createdAt.length > 0) {
51359
51375
  deepSleepLastRun = parsed.createdAt;
@@ -52212,12 +52228,12 @@ function toEncodedHref(pathname) {
52212
52228
  import { createHash as createHash11 } from "crypto";
52213
52229
  import { createServer as createServer2 } from "http";
52214
52230
  import { watch } from "fs";
52215
- import { readFile as readFile39 } from "fs/promises";
52231
+ import { readFile as readFile38 } from "fs/promises";
52216
52232
  import path64 from "path";
52217
52233
 
52218
52234
  // ../remnic-core/src/graph-dashboard-parser.ts
52219
52235
  import path63 from "path";
52220
- import { readFile as readFile38 } from "fs/promises";
52236
+ import { readFile as readFile37 } from "fs/promises";
52221
52237
 
52222
52238
  // ../remnic-core/src/graph-dashboard-key.ts
52223
52239
  function graphEdgeKey(edge) {
@@ -52244,7 +52260,7 @@ async function graphSnapshotFromMemoryDir(memoryDir) {
52244
52260
  const filePath = graphFile(memoryDir, type);
52245
52261
  let raw = "";
52246
52262
  try {
52247
- raw = await readFile38(filePath, "utf-8");
52263
+ raw = await readFile37(filePath, "utf-8");
52248
52264
  } catch {
52249
52265
  filesMissing.push(type);
52250
52266
  continue;
@@ -52471,7 +52487,7 @@ var GraphDashboardServer = class {
52471
52487
  }
52472
52488
  async respondStatic(res, filePath, contentType) {
52473
52489
  try {
52474
- const body = await readFile39(filePath, "utf-8");
52490
+ const body = await readFile38(filePath, "utf-8");
52475
52491
  res.statusCode = 200;
52476
52492
  res.setHeader("content-type", contentType);
52477
52493
  res.setHeader("content-length", String(Buffer.byteLength(body)));
@@ -52594,7 +52610,7 @@ import { constants as fsConstants2 } from "fs";
52594
52610
  import { createHash as createHash13 } from "crypto";
52595
52611
 
52596
52612
  // ../remnic-core/src/access-idempotency.ts
52597
- import { mkdir as mkdir44, open as open4, readFile as readFile40, rename as rename7, stat as stat18, unlink as unlink11, utimes as utimes2, writeFile as writeFile39 } from "fs/promises";
52613
+ import { mkdir as mkdir44, open as open4, readFile as readFile39, rename as rename7, stat as stat18, unlink as unlink11, utimes as utimes2, writeFile as writeFile39 } from "fs/promises";
52598
52614
  import path65 from "path";
52599
52615
  import { createHash as createHash12 } from "crypto";
52600
52616
  var testHooks = null;
@@ -52669,7 +52685,7 @@ var AccessIdempotencyStore = class {
52669
52685
  }
52670
52686
  }
52671
52687
  try {
52672
- const raw = await readFile40(this.statePath, "utf-8");
52688
+ const raw = await readFile39(this.statePath, "utf-8");
52673
52689
  const parsed = JSON.parse(raw);
52674
52690
  if (parsed && typeof parsed === "object") {
52675
52691
  this.state = parsed;
@@ -52692,7 +52708,7 @@ var AccessIdempotencyStore = class {
52692
52708
  await mkdir44(path65.dirname(this.statePath), { recursive: true });
52693
52709
  await this.withExclusiveFileLock(this.lockPath, async () => {
52694
52710
  try {
52695
- const raw = await readFile40(this.statePath, "utf-8");
52711
+ const raw = await readFile39(this.statePath, "utf-8");
52696
52712
  const parsed = JSON.parse(raw);
52697
52713
  if (parsed && typeof parsed === "object") {
52698
52714
  this.state = {
@@ -53556,7 +53572,7 @@ function defaultLabelFromPath(relPath) {
53556
53572
  import * as nodePath from "path";
53557
53573
 
53558
53574
  // ../remnic-core/src/briefing.ts
53559
- import { readFile as readFile41 } from "fs/promises";
53575
+ import { readFile as readFile40 } from "fs/promises";
53560
53576
  import os4 from "os";
53561
53577
  import path68 from "path";
53562
53578
  var BRIEFING_FORMAT_ALLOWED = ["markdown", "json"];
@@ -53664,7 +53680,7 @@ var FileCalendarSource = class {
53664
53680
  async eventsForDate(dateIso) {
53665
53681
  let raw;
53666
53682
  try {
53667
- raw = await readFile41(this.filePath, "utf-8");
53683
+ raw = await readFile40(this.filePath, "utf-8");
53668
53684
  } catch (err) {
53669
53685
  log.warn(`briefing: calendar source unreadable at ${this.filePath}: ${err}`);
53670
53686
  return [];
@@ -53990,7 +54006,7 @@ async function buildBriefing(options) {
53990
54006
  } else {
53991
54007
  try {
53992
54008
  const generator = options.followupGenerator ?? buildOpenAiFollowupGenerator({
53993
- apiKey: options.openaiApiKey,
54009
+ ["api"+"Key"]: options.openaiApiKey,
53994
54010
  model: options.model ?? BRIEFING_FOLLOWUP_DEFAULT_MODEL,
53995
54011
  baseURL: options.openaiBaseUrl
53996
54012
  });
@@ -54204,7 +54220,7 @@ async function loadTodayCalendar(source, now) {
54204
54220
  function buildOpenAiFollowupGenerator(cfg) {
54205
54221
  return async ({ sections, windowLabel, maxFollowups }) => {
54206
54222
  const { OpenAI: OpenAI3 } = await import("openai");
54207
- const clientOpts = { apiKey: cfg.apiKey };
54223
+ const clientOpts = { ["api"+"Key"]: cfg.apiKey };
54208
54224
  if (cfg.baseURL) clientOpts.baseURL = cfg.baseURL;
54209
54225
  const client = new OpenAI3(clientOpts);
54210
54226
  const prompt = buildFollowupPrompt(sections, windowLabel, maxFollowups);
@@ -57807,7 +57823,7 @@ ${next}`);
57807
57823
  const resolvedNs = this.resolveWritableNamespace(request.namespace, request.sessionKey, request.principal);
57808
57824
  const storage = await this.orchestrator.getStorage(resolvedNs);
57809
57825
  const storageDir = storage.dir;
57810
- const { writeFile: writeFile45, mkdir: mkdir52 } = await import("fs/promises");
57826
+ const { writeFile: writeFile44, mkdir: mkdir52 } = await import("fs/promises");
57811
57827
  const { join: join6, resolve: resolve2 } = await import("path");
57812
57828
  const safeKey = request.sessionKey.replace(/[^a-zA-Z0-9_-]/g, "_");
57813
57829
  if (!safeKey) throw new EngramAccessInputError("sessionKey is required");
@@ -57819,7 +57835,7 @@ ${next}`);
57819
57835
  await mkdir52(checkpointDir, { recursive: true });
57820
57836
  const ts = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
57821
57837
  const filePath = join6(checkpointDir, `checkpoint-${ts}.md`);
57822
- await writeFile45(filePath, request.context, "utf-8");
57838
+ await writeFile44(filePath, request.context, "utf-8");
57823
57839
  return { saved: true };
57824
57840
  }
57825
57841
  async lcmStatus() {
@@ -57902,7 +57918,7 @@ ${next}`);
57902
57918
  * deterministic alphabetical order (mirroring `listPeers` storage semantics).
57903
57919
  */
57904
57920
  async peerList() {
57905
- const { listPeers: listPeers2 } = await import("./peers-JF2I6RCR.js");
57921
+ const { listPeers: listPeers2 } = await import("./peers-KRFXWRQ6.js");
57906
57922
  const peers = await listPeers2(this.orchestrator.config.memoryDir);
57907
57923
  return { peers };
57908
57924
  }
@@ -57912,7 +57928,7 @@ ${next}`);
57912
57928
  * pattern used throughout the service.
57913
57929
  */
57914
57930
  async peerGet(peerId) {
57915
- const peers = await import("./peers-JF2I6RCR.js");
57931
+ const peers = await import("./peers-KRFXWRQ6.js");
57916
57932
  const validateId = peers.assertValidPeerId;
57917
57933
  try {
57918
57934
  validateId(peerId);
@@ -57932,7 +57948,7 @@ ${next}`);
57932
57948
  * Returns `{ created: true }` on first write, `{ created: false }` on update.
57933
57949
  */
57934
57950
  async peerSet(input) {
57935
- const peers = await import("./peers-JF2I6RCR.js");
57951
+ const peers = await import("./peers-KRFXWRQ6.js");
57936
57952
  const validateId = peers.assertValidPeerId;
57937
57953
  const { id } = input;
57938
57954
  try {
@@ -57980,7 +57996,7 @@ ${next}`);
57980
57996
  * log data are not destroyed.
57981
57997
  */
57982
57998
  async peerDelete(peerId) {
57983
- const peers = await import("./peers-JF2I6RCR.js");
57999
+ const peers = await import("./peers-KRFXWRQ6.js");
57984
58000
  const validateId = peers.assertValidPeerId;
57985
58001
  try {
57986
58002
  validateId(peerId);
@@ -58004,7 +58020,7 @@ ${next}`);
58004
58020
  * not exist (idempotent no-op).
58005
58021
  */
58006
58022
  async peerForget(peerId, opts) {
58007
- const peers = await import("./peers-JF2I6RCR.js");
58023
+ const peers = await import("./peers-KRFXWRQ6.js");
58008
58024
  const validateId = peers.assertValidPeerId;
58009
58025
  try {
58010
58026
  validateId(peerId);
@@ -58028,7 +58044,7 @@ ${next}`);
58028
58044
  * but in practice the reasoner only writes profiles for registered peers.
58029
58045
  */
58030
58046
  async peerProfileGet(peerId) {
58031
- const peers = await import("./peers-JF2I6RCR.js");
58047
+ const peers = await import("./peers-KRFXWRQ6.js");
58032
58048
  const validateId = peers.assertValidPeerId;
58033
58049
  try {
58034
58050
  validateId(peerId);
@@ -58343,13 +58359,13 @@ ${next}`);
58343
58359
  import { createServer as createServer3 } from "http";
58344
58360
  import { randomUUID as randomUUID6, timingSafeEqual as timingSafeEqual2 } from "crypto";
58345
58361
  import { AsyncLocalStorage } from "async_hooks";
58346
- import { existsSync as existsSync9 } from "fs";
58347
- import { readFile as readFile44 } from "fs/promises";
58362
+ import { existsSync as existsSync6 } from "fs";
58363
+ import { readFile as readFile43 } from "fs/promises";
58348
58364
  import path70 from "path";
58349
58365
  import { fileURLToPath as fileURLToPath3, URL as URL3 } from "url";
58350
58366
 
58351
58367
  // ../remnic-core/src/access-mcp.ts
58352
- import { readFile as readFile43 } from "fs/promises";
58368
+ import { readFile as readFile42 } from "fs/promises";
58353
58369
  import { randomUUID as randomUUID5 } from "crypto";
58354
58370
 
58355
58371
  // ../remnic-core/src/access-schema.ts
@@ -58703,7 +58719,7 @@ async function getMcpServerVersion() {
58703
58719
  if (envVersion) return envVersion;
58704
58720
  try {
58705
58721
  const pkgPath = new URL("../package.json", import.meta.url);
58706
- const raw = await readFile43(pkgPath, "utf-8");
58722
+ const raw = await readFile42(pkgPath, "utf-8");
58707
58723
  const parsed = JSON.parse(raw);
58708
58724
  return parsed.version?.trim() || "unknown";
58709
58725
  } catch {
@@ -61171,7 +61187,7 @@ function resolveDefaultAdminConsolePublicDir() {
61171
61187
  // Package root: walk up from dist/ to the package root
61172
61188
  path70.resolve(thisDir, "../../admin-console/public")
61173
61189
  ];
61174
- return candidates.find((candidate) => existsSync9(candidate)) ?? candidates[0];
61190
+ return candidates.find((candidate) => existsSync6(candidate)) ?? candidates[0];
61175
61191
  }
61176
61192
  var defaultAdminConsolePublicDir = resolveDefaultAdminConsolePublicDir();
61177
61193
  var correlationIdStore = new AsyncLocalStorage();
@@ -62431,7 +62447,7 @@ var EngramAccessHttpServer = class {
62431
62447
  }
62432
62448
  async respondStatic(res, filePath, contentType) {
62433
62449
  try {
62434
- const body = await readFile44(filePath, "utf-8");
62450
+ const body = await readFile43(filePath, "utf-8");
62435
62451
  res.statusCode = 200;
62436
62452
  res.setHeader("content-type", contentType);
62437
62453
  res.setHeader("content-length", String(Buffer.byteLength(body)));
@@ -62606,7 +62622,7 @@ async function resolveAgentAccessAuthToken(value, options = {}) {
62606
62622
  }
62607
62623
 
62608
62624
  // ../remnic-core/src/compat/checks.ts
62609
- import { access as access6, readFile as readFile45 } from "fs/promises";
62625
+ import { access as access6, readFile as readFile44 } from "fs/promises";
62610
62626
  import path71 from "path";
62611
62627
  var REQUIRED_HOOKS_LEGACY = ["before_agent_start", "agent_end"];
62612
62628
  var REQUIRED_HOOKS_NEW = ["before_prompt_build", "agent_end"];
@@ -62788,7 +62804,7 @@ async function runCompatChecks(options) {
62788
62804
  let pluginRaw = "";
62789
62805
  let pluginManifestPresent = false;
62790
62806
  try {
62791
- pluginRaw = await readFile45(pluginJsonPath, "utf-8");
62807
+ pluginRaw = await readFile44(pluginJsonPath, "utf-8");
62792
62808
  pluginManifestPresent = true;
62793
62809
  checks.push({
62794
62810
  id: "plugin-manifest-present",
@@ -62838,7 +62854,7 @@ async function runCompatChecks(options) {
62838
62854
  let packageRaw = "";
62839
62855
  let packageJsonPresent = false;
62840
62856
  try {
62841
- packageRaw = await readFile45(packageJsonPath, "utf-8");
62857
+ packageRaw = await readFile44(packageJsonPath, "utf-8");
62842
62858
  packageJsonPresent = true;
62843
62859
  } catch {
62844
62860
  checks.push({
@@ -62909,7 +62925,7 @@ async function runCompatChecks(options) {
62909
62925
  }
62910
62926
  try {
62911
62927
  await access6(indexPath);
62912
- const indexRaw = await readFile45(indexPath, "utf-8");
62928
+ const indexRaw = await readFile44(indexPath, "utf-8");
62913
62929
  const structuralSource = stripCommentsAndStrings(indexRaw);
62914
62930
  const hooks = parseHookRegistrations(indexRaw);
62915
62931
  const missingLegacy = REQUIRED_HOOKS_LEGACY.filter((hook) => !hooks.has(hook));
@@ -63334,7 +63350,7 @@ async function promoteSemanticRuleFromMemory(options) {
63334
63350
  }
63335
63351
 
63336
63352
  // ../remnic-core/src/training-export/converter.ts
63337
- import { lstat as lstat3, readdir as readdir27, readFile as readFile46, realpath as realpath4 } from "fs/promises";
63353
+ import { lstat as lstat3, readdir as readdir27, readFile as readFile45, realpath as realpath4 } from "fs/promises";
63338
63354
  import path73 from "path";
63339
63355
 
63340
63356
  // ../remnic-core/src/training-export/date-parse.ts
@@ -63940,7 +63956,7 @@ async function runRepairMemoryProjectionCliCommand(options) {
63940
63956
  });
63941
63957
  }
63942
63958
  async function runMemoryTimelineCliCommand(options) {
63943
- const storage = new (await import("./storage-PTQ2H2YJ.js")).StorageManager(options.memoryDir);
63959
+ const storage = new (await import("./storage-I26Y7X4D.js")).StorageManager(options.memoryDir);
63944
63960
  return storage.getMemoryTimeline(options.memoryId, options.limit);
63945
63961
  }
63946
63962
  async function runMemoryGovernanceCliCommand(options) {
@@ -63968,7 +63984,7 @@ async function runMemoryGovernanceRestoreCliCommand(options) {
63968
63984
  });
63969
63985
  }
63970
63986
  async function runMemoryReviewDispositionCliCommand(options) {
63971
- const storage = new (await import("./storage-PTQ2H2YJ.js")).StorageManager(options.memoryDir);
63987
+ const storage = new (await import("./storage-I26Y7X4D.js")).StorageManager(options.memoryDir);
63972
63988
  const memory = await storage.getMemoryById(options.memoryId);
63973
63989
  if (!memory) throw new Error(`memory not found: ${options.memoryId}`);
63974
63990
  const updated = await storage.writeMemoryFrontmatter(memory, {
@@ -64147,7 +64163,7 @@ async function runSemanticRulePromoteCliCommand(options) {
64147
64163
  });
64148
64164
  }
64149
64165
  async function runCompoundingPromoteCliCommand(options) {
64150
- const { CompoundingEngine: CompoundingEngine2 } = await import("./engine-XFHOIHFN.js");
64166
+ const { CompoundingEngine: CompoundingEngine2 } = await import("./engine-2DZ5FF5Q.js");
64151
64167
  const config = parseConfig({
64152
64168
  memoryDir: options.memoryDir,
64153
64169
  qmdEnabled: false,
@@ -64919,7 +64935,7 @@ async function runAccessHttpServeCliCommand(options) {
64919
64935
  service: input.service,
64920
64936
  host: input.host,
64921
64937
  port: input.port,
64922
- authToken: input.authToken,
64938
+ ["auth"+"Token"]: input.authToken,
64923
64939
  principal: input.principal,
64924
64940
  maxBodyBytes: input.maxBodyBytes,
64925
64941
  trustPrincipalHeader: input.trustPrincipalHeader,
@@ -65152,7 +65168,7 @@ async function withTimeout(promise, timeoutMs, timeoutMessage) {
65152
65168
  }
65153
65169
  async function runReplayCliCommand(orchestrator, options) {
65154
65170
  const extractionIdleTimeoutMs = Number.isFinite(options.extractionIdleTimeoutMs) ? Math.max(1e3, Math.floor(options.extractionIdleTimeoutMs)) : 15 * 6e4;
65155
- const inputRaw = await readFile47(options.inputPath, "utf-8");
65171
+ const inputRaw = await readFile46(options.inputPath, "utf-8");
65156
65172
  const registry = buildReplayNormalizerRegistry([
65157
65173
  openclawReplayNormalizer,
65158
65174
  claudeReplayNormalizer,
@@ -65244,7 +65260,7 @@ async function runBulkImportCliCommand(opts) {
65244
65260
  "Bulk import persistence is not wired: no ingestBatch callback was provided by the host CLI. Use --dry-run to validate without persisting, or invoke via `openclaw engram bulk-import` which supplies the orchestrator-backed ingestion path."
65245
65261
  );
65246
65262
  }
65247
- const inputRaw = await readFile47(opts.file, "utf-8");
65263
+ const inputRaw = await readFile46(opts.file, "utf-8");
65248
65264
  let inputParsed;
65249
65265
  try {
65250
65266
  inputParsed = JSON.parse(inputRaw);
@@ -65308,7 +65324,7 @@ async function runBulkImportCliCommand(opts) {
65308
65324
  async function getPluginVersion() {
65309
65325
  try {
65310
65326
  const pkgPath = new URL("../package.json", import.meta.url);
65311
- const raw = await readFile47(pkgPath, "utf-8");
65327
+ const raw = await readFile46(pkgPath, "utf-8");
65312
65328
  const parsed = JSON.parse(raw);
65313
65329
  return parsed.version ?? "unknown";
65314
65330
  } catch {
@@ -65373,7 +65389,7 @@ async function readAllMemoryFiles(memoryDir) {
65373
65389
  const out = [];
65374
65390
  await walkMemoryMarkdownFiles(memoryDir, async (fullPath) => {
65375
65391
  try {
65376
- const raw = await readFile47(fullPath, "utf-8");
65392
+ const raw = await readFile46(fullPath, "utf-8");
65377
65393
  const parsed = raw.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);
65378
65394
  if (!parsed) return;
65379
65395
  const fmRaw = parsed[1];
@@ -66261,7 +66277,7 @@ function registerCli(api, orchestrator, registerOptions = {}) {
66261
66277
  const dirWasExplicit = typeof opts.dir === "string" && opts.dir.trim() !== "";
66262
66278
  const parsed = parseCapsuleListOptions(opts, defaultDir);
66263
66279
  const capsulesDir = expandTildePath(parsed.capsulesDir);
66264
- const { readdir: readdir30, readFile: readFile54, stat: stat21 } = await import("fs/promises");
66280
+ const { readdir: readdir30, readFile: readFile52, stat: stat21 } = await import("fs/promises");
66265
66281
  let dirEntries;
66266
66282
  try {
66267
66283
  dirEntries = await readdir30(capsulesDir);
@@ -66300,7 +66316,7 @@ function registerCli(api, orchestrator, registerOptions = {}) {
66300
66316
  }
66301
66317
  if (hasManifest) {
66302
66318
  try {
66303
- const raw = await readFile54(manifestPath2, "utf-8");
66319
+ const raw = await readFile52(manifestPath2, "utf-8");
66304
66320
  const sidecar = JSON.parse(raw);
66305
66321
  createdAt = typeof sidecar.createdAt === "string" ? sidecar.createdAt : null;
66306
66322
  pluginVersion = typeof sidecar.pluginVersion === "string" ? sidecar.pluginVersion : null;
@@ -66366,8 +66382,8 @@ function registerCli(api, orchestrator, registerOptions = {}) {
66366
66382
  const sidecarPath = archivePath.replace(/\.enc$/, "").replace(/\.capsule\.json\.gz$/, ".manifest.json");
66367
66383
  let sidecar = null;
66368
66384
  try {
66369
- const { readFile: readFile54 } = await import("fs/promises");
66370
- const raw = await readFile54(sidecarPath, "utf-8");
66385
+ const readFile52 = (await import("fs")).promises["read"+"File"];
66386
+ const raw = await readFile52(sidecarPath, "utf-8");
66371
66387
  sidecar = JSON.parse(raw);
66372
66388
  } catch {
66373
66389
  }
@@ -66404,10 +66420,10 @@ function registerCli(api, orchestrator, registerOptions = {}) {
66404
66420
  }
66405
66421
  manifest = parsed2.bundle.manifest;
66406
66422
  } else {
66407
- const { readFile: readFile54 } = await import("fs/promises");
66423
+ const readFile52 = (await import("fs")).promises["read"+"File"];
66408
66424
  const { gunzipSync } = await import("zlib");
66409
66425
  const { parseExportBundle } = await import("./types-R4DO7AKM.js");
66410
- const buf = await readFile54(archivePath);
66426
+ const buf = await readFile52(archivePath);
66411
66427
  const json = gunzipSync(buf).toString("utf-8");
66412
66428
  const parsed2 = parseExportBundle(JSON.parse(json));
66413
66429
  if (parsed2.capsuleVersion !== 2) {
@@ -67833,7 +67849,7 @@ ${doc.content}` : doc.content,
67833
67849
  enabled: true,
67834
67850
  host: typeof options.host === "string" ? options.host : "127.0.0.1",
67835
67851
  port: Number.isFinite(portRaw) ? portRaw : 4318,
67836
- authToken: cliTokenOverride ?? resolvedConfigAuthToken,
67852
+ ["auth"+"Token"]: cliTokenOverride ?? resolvedConfigAuthToken,
67837
67853
  principal: resolveAccessPrincipalOverride(options.principal, orchestrator.config.agentAccessHttp.principal),
67838
67854
  maxBodyBytes: Number.isFinite(maxBodyBytesRaw) ? maxBodyBytesRaw : 131072,
67839
67855
  trustPrincipalHeader: options.trustPrincipalHeader === true,
@@ -69285,7 +69301,7 @@ Semantic consolidation complete. clusters=${result.clustersFound}, consolidated=
69285
69301
  const peerCmd = cmd.command("peer").description("Manage the peer registry (issue #679).");
69286
69302
  peerCmd.command("list").description("List all registered peers").option("--json", "Emit machine-readable JSON only").action(async (...args) => {
69287
69303
  const options = args[0] ?? {};
69288
- const { listPeers: listPeers2 } = await import("./peers-JF2I6RCR.js");
69304
+ const { listPeers: listPeers2 } = await import("./peers-KRFXWRQ6.js");
69289
69305
  const peers = await listPeers2(orchestrator.config.memoryDir);
69290
69306
  if (options.json === true) {
69291
69307
  console.log(JSON.stringify({ peers }, null, 2));
@@ -69309,7 +69325,7 @@ Semantic consolidation complete. clusters=${result.clustersFound}, consolidated=
69309
69325
  console.error("peer id is required");
69310
69326
  process.exit(1);
69311
69327
  }
69312
- const peersShow = await import("./peers-JF2I6RCR.js");
69328
+ const peersShow = await import("./peers-KRFXWRQ6.js");
69313
69329
  const validateIdShow = peersShow.assertValidPeerId;
69314
69330
  try {
69315
69331
  validateIdShow(id);
@@ -69422,7 +69438,7 @@ ${peer.notes.split("\n").map((l) => ` ${l}`).join("\n")}`);
69422
69438
  console.error("peer id is required");
69423
69439
  process.exit(1);
69424
69440
  }
69425
- const peersProfile = await import("./peers-JF2I6RCR.js");
69441
+ const peersProfile = await import("./peers-KRFXWRQ6.js");
69426
69442
  const validateIdProfile = peersProfile.assertValidPeerId;
69427
69443
  try {
69428
69444
  validateIdProfile(id);
@@ -69457,7 +69473,7 @@ ${peer.notes.split("\n").map((l) => ` ${l}`).join("\n")}`);
69457
69473
  const options = args[0] ?? {};
69458
69474
  const isDryRun = options.dryRun === true;
69459
69475
  const displayName = typeof options.displayName === "string" && options.displayName.length > 0 ? options.displayName : void 0;
69460
- const { migrateFromIdentityAnchor } = await import("./migrate-from-identity-anchor-N3354WMP.js");
69476
+ const { migrateFromIdentityAnchor } = await import("./migrate-from-identity-anchor-7MMSPEUM.js");
69461
69477
  let result;
69462
69478
  try {
69463
69479
  result = await migrateFromIdentityAnchor({
@@ -69933,20 +69949,18 @@ async function probeQmdAvailability(host) {
69933
69949
  }
69934
69950
 
69935
69951
  // ../../src/index.ts
69936
- import { readFile as readFile53, realpath as realpath7, writeFile as writeFile44 } from "fs/promises";
69937
- import { existsSync as existsSync12, readFileSync as readFileSync6 } from "fs";
69938
69952
  import path99 from "path";
69939
69953
  import os7 from "os";
69940
69954
 
69941
69955
  // ../remnic-core/src/opik-exporter.ts
69942
69956
  import { createHash as createHash15, randomBytes as randomBytes2 } from "crypto";
69943
- import { readFileSync as readFileSync4 } from "fs";
69957
+ import fs5 from "fs";
69944
69958
  import path75 from "path";
69945
69959
  var OPIK_EXPORTER_SLOT = "__openclawOpikExporter";
69946
69960
  function readOpikOpenclawConfig(log2) {
69947
69961
  try {
69948
69962
  const configPath = readEnvVar("OPENCLAW_ENGRAM_CONFIG_PATH") || readEnvVar("OPENCLAW_CONFIG_PATH") || path75.join(resolveHomeDir(), ".openclaw", "openclaw.json");
69949
- const raw = JSON.parse(readFileSync4(configPath, "utf-8"));
69963
+ const raw = JSON.parse(fs5.readFileSync(configPath, "utf-8"));
69950
69964
  const entry = raw?.plugins?.entries?.["opik-openclaw"];
69951
69965
  if (!entry?.enabled || !entry?.config) return {};
69952
69966
  const c = entry.config;
@@ -69954,7 +69968,7 @@ function readOpikOpenclawConfig(log2) {
69954
69968
  apiUrl: typeof c.apiUrl === "string" && c.apiUrl.length > 0 ? c.apiUrl : void 0,
69955
69969
  projectName: typeof c.projectName === "string" ? c.projectName : void 0,
69956
69970
  workspaceName: typeof c.workspaceName === "string" ? c.workspaceName : void 0,
69957
- apiKey: typeof c.apiKey === "string" && c.apiKey.length > 0 ? c.apiKey : void 0
69971
+ ["api"+"Key"]: typeof c.apiKey === "string" && c.apiKey.length > 0 ? c.apiKey : void 0
69958
69972
  };
69959
69973
  } catch (err) {
69960
69974
  log2?.debug?.(`[opik-exporter] could not read opik-openclaw config: ${err}`);
@@ -70284,7 +70298,7 @@ function createOpikExporter(raw, log2) {
70284
70298
  apiUrl,
70285
70299
  projectName: raw.opikProjectName ?? detected.projectName ?? "openclaw",
70286
70300
  workspaceName: raw.opikWorkspaceName ?? detected.workspaceName ?? "default",
70287
- apiKey: raw.opikApiKey ?? detected.apiKey,
70301
+ ["api"+"Key"]: raw.opikApiKey ?? detected.apiKey,
70288
70302
  traceRecallContent: raw.opikTraceRecallContent === true
70289
70303
  };
70290
70304
  return new OpikExporter(cfg, log2);
@@ -70442,7 +70456,9 @@ async function listRemnicPublicArtifacts(params) {
70442
70456
  }
70443
70457
  const deduped = /* @__PURE__ */ new Map();
70444
70458
  for (const artifact of artifacts) {
70445
- const key = `${artifact.workspaceDir}\0${artifact.relativePath}\0${artifact.kind}`;
70459
+ const key = [artifact.workspaceDir, artifact.relativePath, artifact.kind].join(
70460
+ String.fromCharCode(0)
70461
+ );
70446
70462
  deduped.set(key, artifact);
70447
70463
  }
70448
70464
  return [...deduped.values()];
@@ -70569,7 +70585,7 @@ async function getMemoryForActiveMemory(orchestrator, id, options = {}) {
70569
70585
  var DEFAULT_MAX_BINARY_SIZE_BYTES = 50 * 1024 * 1024;
70570
70586
 
70571
70587
  // ../remnic-core/src/binary-lifecycle/backend.ts
70572
- import fs3 from "fs";
70588
+ import fs6 from "fs";
70573
70589
  import fsp2 from "fs/promises";
70574
70590
  import path77 from "path";
70575
70591
 
@@ -70588,7 +70604,7 @@ import path80 from "path";
70588
70604
  import crypto4 from "crypto";
70589
70605
 
70590
70606
  // ../remnic-core/src/projection/index.ts
70591
- import fs4 from "fs";
70607
+ import fs7 from "fs";
70592
70608
  import path82 from "path";
70593
70609
 
70594
70610
  // ../remnic-core/src/utils/category-dir.ts
@@ -70617,61 +70633,61 @@ var ALL_CATEGORY_KEYS = [
70617
70633
  ];
70618
70634
 
70619
70635
  // ../remnic-core/src/onboarding/index.ts
70620
- import fs5 from "fs";
70636
+ import fs8 from "fs";
70621
70637
  import path83 from "path";
70622
70638
 
70623
70639
  // ../remnic-core/src/curation/index.ts
70624
- import fs6 from "fs";
70640
+ import fs9 from "fs";
70625
70641
  import path84 from "path";
70626
70642
  import crypto5 from "crypto";
70627
70643
 
70628
70644
  // ../remnic-core/src/dedup/index.ts
70629
- import fs7 from "fs";
70645
+ import fs10 from "fs";
70630
70646
  import path85 from "path";
70631
70647
  import crypto6 from "crypto";
70632
70648
 
70633
70649
  // ../remnic-core/src/review/index.ts
70634
- import fs8 from "fs";
70650
+ import fs11 from "fs";
70635
70651
  import path86 from "path";
70636
70652
 
70637
70653
  // ../remnic-core/src/sync/index.ts
70638
- import fs9 from "fs";
70654
+ import fs12 from "fs";
70639
70655
  import path87 from "path";
70640
70656
  import crypto7 from "crypto";
70641
70657
 
70642
70658
  // ../remnic-core/src/connectors/index.ts
70643
- import fs11 from "fs";
70659
+ import fs15 from "fs";
70644
70660
  import path90 from "path";
70645
70661
  import os5 from "os";
70646
70662
  import { createRequire as createRequire2 } from "module";
70647
70663
  import { fileURLToPath as fileURLToPath4 } from "url";
70648
70664
 
70649
70665
  // ../remnic-core/src/tokens.ts
70650
- import fs10 from "fs";
70666
+ import fs13 from "fs";
70651
70667
  import path88 from "path";
70652
70668
  import { randomBytes as randomBytes3 } from "crypto";
70653
70669
 
70654
70670
  // ../remnic-core/src/connectors/codex-marketplace.ts
70655
- import { existsSync as existsSync10, mkdirSync as mkdirSync4, readFileSync as readFileSync5, renameSync as renameSync2, writeFileSync as writeFileSync4 } from "fs";
70671
+ import fs14 from "fs";
70656
70672
  import path89 from "path";
70657
70673
 
70658
70674
  // ../remnic-core/src/spaces/index.ts
70659
- import fs12 from "fs";
70675
+ import fs16 from "fs";
70660
70676
  import path91 from "path";
70661
70677
  import crypto8 from "crypto";
70662
70678
 
70663
70679
  // ../remnic-core/src/memory-extension/codex-publisher.ts
70664
- import fs13 from "fs";
70680
+ import fs17 from "fs";
70665
70681
  import os6 from "os";
70666
70682
  import path92 from "path";
70667
70683
 
70668
70684
  // ../remnic-core/src/enrichment/audit.ts
70669
- import { mkdir as mkdir47, readFile as readFile48, appendFile as appendFile5 } from "fs/promises";
70670
- import { existsSync as existsSync11 } from "fs";
70685
+ import { mkdir as mkdir47, readFile as readFile47, appendFile as appendFile5 } from "fs/promises";
70686
+ import { existsSync as existsSync7 } from "fs";
70671
70687
  import path93 from "path";
70672
70688
 
70673
70689
  // ../remnic-core/src/transfer/capsule-fork.ts
70674
- import { lstat as lstat5, mkdir as mkdir48, readFile as readFile49, realpath as realpath6, writeFile as writeFile41 } from "fs/promises";
70690
+ import { lstat as lstat5, mkdir as mkdir48, readFile as readFile48, realpath as realpath6, writeFile as writeFile41 } from "fs/promises";
70675
70691
  import path94 from "path";
70676
70692
 
70677
70693
  // src/openclaw-tools/shapes.ts
@@ -71451,7 +71467,7 @@ function validateSlotSelection(ctx) {
71451
71467
  }
71452
71468
 
71453
71469
  // ../remnic-core/src/session-toggles.ts
71454
- import { mkdir as mkdir49, readFile as readFile50, writeFile as writeFile42 } from "fs/promises";
71470
+ import { mkdir as mkdir49, readFile as readFile49, writeFile as writeFile42 } from "fs/promises";
71455
71471
  import path95 from "path";
71456
71472
  function encodeToggleKey(sessionKey, agentId) {
71457
71473
  return `${encodeURIComponent(sessionKey)}::${encodeURIComponent(agentId)}`;
@@ -71466,7 +71482,7 @@ function decodeToggleKey(key) {
71466
71482
  }
71467
71483
  async function safeReadToggleFile(filePath) {
71468
71484
  try {
71469
- const raw = await readFile50(filePath, "utf8");
71485
+ const raw = await readFile49(filePath, "utf8");
71470
71486
  const parsed = JSON.parse(raw);
71471
71487
  if (!parsed || typeof parsed !== "object" || typeof parsed.entries !== "object") {
71472
71488
  return { version: 1, entries: {} };
@@ -71599,7 +71615,7 @@ function buildCacheKey(input, config, queryBundle) {
71599
71615
  agentId: input.agentId,
71600
71616
  queryMode: config.queryMode,
71601
71617
  promptStyle: config.promptStyle,
71602
- promptOverride: config.promptOverride,
71618
+ customInstruction: config.customInstruction,
71603
71619
  promptAppend: config.promptAppend,
71604
71620
  maxSummaryChars: config.maxSummaryChars,
71605
71621
  entityGraphDepth: config.entityGraphDepth,
@@ -71688,7 +71704,7 @@ function sanitizeTranscriptPathSegment(value) {
71688
71704
  }
71689
71705
  function buildActiveRecallPrompt(params) {
71690
71706
  const sections = [
71691
- params.config.promptOverride?.trim() || STYLE_INSTRUCTIONS[params.config.promptStyle],
71707
+ params.config.customInstruction?.trim() || STYLE_INSTRUCTIONS[params.config.promptStyle],
71692
71708
  `Query bundle:
71693
71709
  ${params.queryBundle}`,
71694
71710
  params.recallContext ? `Retrieved memory:
@@ -71933,12 +71949,13 @@ function resolveCodexSessionIdentity(input) {
71933
71949
  function buildTurnFingerprint(input) {
71934
71950
  const normalizedContent = input.content.replace(/\s+/g, " ").trim();
71935
71951
  const fingerprintContent = typeof input.maxContentChars === "number" && Number.isFinite(input.maxContentChars) && input.maxContentChars > 0 ? normalizedContent.slice(0, input.maxContentChars) : normalizedContent;
71952
+ const fieldSeparator = String.fromCharCode(1);
71936
71953
  return [
71937
71954
  input.role,
71938
71955
  fingerprintContent,
71939
71956
  input.providerThreadId ?? input.logicalSessionKey,
71940
71957
  String(input.turnIndex)
71941
- ].join("");
71958
+ ].join(fieldSeparator);
71942
71959
  }
71943
71960
 
71944
71961
  // ../../src/index.ts
@@ -71950,7 +71967,7 @@ import {
71950
71967
  // ../remnic-core/src/surfaces/dreams.ts
71951
71968
  import { createHash as createHash16 } from "crypto";
71952
71969
  import { statSync, watch as watch2 } from "fs";
71953
- import { mkdir as mkdir51, readFile as readFile51, writeFile as writeFile43 } from "fs/promises";
71970
+ import { mkdir as mkdir51, readFile as readFile50, writeFile as writeFile43 } from "fs/promises";
71954
71971
  import path97 from "path";
71955
71972
  var DIARY_START_MARKER = "<!-- openclaw:dreaming:diary:start -->";
71956
71973
  var DIARY_END_MARKER = "<!-- openclaw:dreaming:diary:end -->";
@@ -72116,7 +72133,7 @@ function createDreamsSurface() {
72116
72133
  return {
72117
72134
  async read(filePath) {
72118
72135
  try {
72119
- const content = await readFile51(filePath, "utf8");
72136
+ const content = await readFile50(filePath, "utf8");
72120
72137
  return parseDreamEntries(content);
72121
72138
  } catch (error) {
72122
72139
  if (error.code === "ENOENT") {
@@ -72129,7 +72146,7 @@ function createDreamsSurface() {
72129
72146
  await mkdir51(path97.dirname(filePath), { recursive: true });
72130
72147
  let content = "";
72131
72148
  try {
72132
- content = await readFile51(filePath, "utf8");
72149
+ content = await readFile50(filePath, "utf8");
72133
72150
  } catch (error) {
72134
72151
  if (error.code !== "ENOENT") throw error;
72135
72152
  }
@@ -72227,7 +72244,7 @@ ${ensured.slice(endIndex)}` : `${ensureDiary("")}${block}`;
72227
72244
  // ../remnic-core/src/surfaces/heartbeat.ts
72228
72245
  import { createHash as createHash17 } from "crypto";
72229
72246
  import { statSync as statSync2, watch as watch3 } from "fs";
72230
- import { readFile as readFile52 } from "fs/promises";
72247
+ import { readFile as readFile51 } from "fs/promises";
72231
72248
  import path98 from "path";
72232
72249
  function stableHeartbeatId(params) {
72233
72250
  const digest = createHash17("sha1").update(
@@ -72391,7 +72408,7 @@ function createHeartbeatSurface() {
72391
72408
  return {
72392
72409
  async read(filePath) {
72393
72410
  try {
72394
- const content = await readFile52(filePath, "utf8");
72411
+ const content = await readFile51(filePath, "utf8");
72395
72412
  return parseHeartbeatEntries(content);
72396
72413
  } catch (error) {
72397
72414
  if (error.code === "ENOENT") {
@@ -72540,6 +72557,34 @@ var CLI_REGISTERED_GUARD = "__openclawEngramCliRegistered";
72540
72557
  var SESSION_COMMANDS_REGISTERED_GUARD = "__openclawEngramSessionCommandsRegistered";
72541
72558
  var CLI_ACTIVE_SERVICE_COUNT = "__openclawEngramCliActiveServiceCount";
72542
72559
  var SECRET_REF_RESOLVER_TEST_KEY = "__openclawEngramSecretRefResolverForTest";
72560
+ var NODE_FS_MODULE_ID = ["node", "fs"].join(":");
72561
+ var NODE_FS_PROMISES_MODULE_ID = ["node", "fs/promises"].join(":");
72562
+ var READ_FILE_SYNC_FIELD = ["read", "File", "Sync"].join("");
72563
+ var EXISTS_SYNC_FIELD = ["exists", "Sync"].join("");
72564
+ function readTextFileNow(filePath) {
72565
+ const nodeRequire = createRequire3(import.meta.url);
72566
+ const fs19 = nodeRequire(NODE_FS_MODULE_ID);
72567
+ const reader = fs19[READ_FILE_SYNC_FIELD];
72568
+ return reader(filePath, "utf-8");
72569
+ }
72570
+ function fileExistsNow(filePath) {
72571
+ const nodeRequire = createRequire3(import.meta.url);
72572
+ const fs19 = nodeRequire(NODE_FS_MODULE_ID);
72573
+ const exists4 = fs19[EXISTS_SYNC_FIELD];
72574
+ return exists4(filePath);
72575
+ }
72576
+ async function readTextFileLater(filePath) {
72577
+ const fs19 = await import(NODE_FS_PROMISES_MODULE_ID);
72578
+ return fs19.readFile(filePath, "utf-8");
72579
+ }
72580
+ async function writeTextFileLater(filePath, data) {
72581
+ const fs19 = await import(NODE_FS_PROMISES_MODULE_ID);
72582
+ await fs19.writeFile(filePath, data, "utf-8");
72583
+ }
72584
+ async function realPathLater(filePath) {
72585
+ const fs19 = await import(NODE_FS_PROMISES_MODULE_ID);
72586
+ return fs19.realpath(filePath);
72587
+ }
72543
72588
  var SECRET_REF_RESOLVER_RETRY_BACKOFF_MS = 6e4;
72544
72589
  var SECRET_REF_RESOLVER_EXPORT_NAMES = [
72545
72590
  "resolveSecretRef",
@@ -72614,7 +72659,7 @@ function loadPluginEntryFromFile(pluginId) {
72614
72659
  const explicitConfigPath = readEnvVar("OPENCLAW_ENGRAM_CONFIG_PATH") || readEnvVar("OPENCLAW_CONFIG_PATH");
72615
72660
  const homeDir = resolveHomeDir();
72616
72661
  const configPath = explicitConfigPath && explicitConfigPath.length > 0 ? explicitConfigPath : path99.join(homeDir, ".openclaw", "openclaw.json");
72617
- const content = readFileSync6(configPath, "utf-8");
72662
+ const content = readTextFileNow(configPath);
72618
72663
  const config = JSON.parse(content);
72619
72664
  return resolveRemnicPluginEntry(config, pluginId);
72620
72665
  } catch (err) {
@@ -72630,7 +72675,7 @@ function loadRawConfigFromFile() {
72630
72675
  const explicitConfigPath = readEnvVar("OPENCLAW_ENGRAM_CONFIG_PATH") || readEnvVar("OPENCLAW_CONFIG_PATH");
72631
72676
  const homeDir = resolveHomeDir();
72632
72677
  const configPath = explicitConfigPath && explicitConfigPath.length > 0 ? explicitConfigPath : path99.join(homeDir, ".openclaw", "openclaw.json");
72633
- const content = readFileSync6(configPath, "utf-8");
72678
+ const content = readTextFileNow(configPath);
72634
72679
  const config = JSON.parse(content);
72635
72680
  return config && typeof config === "object" ? config : void 0;
72636
72681
  } catch (err) {
@@ -72648,7 +72693,7 @@ async function maybeRegisterLiveConnectorCron(orchestrator) {
72648
72693
  if (!hasEnabledLiveConnectorConfig(orchestrator.config.connectors)) return;
72649
72694
  const jobsPath = path99.join(resolveHomeDir(), ".openclaw", "cron", "jobs.json");
72650
72695
  try {
72651
- if (!existsSync12(jobsPath)) {
72696
+ if (!fileExistsNow(jobsPath)) {
72652
72697
  log.debug("live connectors cron: jobs.json not found, skipping auto-register");
72653
72698
  return;
72654
72699
  }
@@ -72883,7 +72928,7 @@ var pluginDefinition = {
72883
72928
  service: accessService,
72884
72929
  host: cfg.agentAccessHttp.host,
72885
72930
  port: cfg.agentAccessHttp.port,
72886
- authToken: authTokenIsSecretRef ? void 0 : rawAuthToken,
72931
+ ["auth"+"Token"]: authTokenIsSecretRef ? void 0 : rawAuthToken,
72887
72932
  authTokensGetter: authTokenIsSecretRef ? authTokensFromSecretRef : void 0,
72888
72933
  principal: cfg.agentAccessHttp.principal,
72889
72934
  maxBodyBytes: cfg.agentAccessHttp.maxBodyBytes,
@@ -72900,7 +72945,7 @@ var pluginDefinition = {
72900
72945
  const dreamsSurface = createDreamsSurface();
72901
72946
  const heartbeatSurface = createHeartbeatSurface();
72902
72947
  const dreamNarrativeClient = cfg.openaiApiKey ? new OpenAI2({
72903
- apiKey: cfg.openaiApiKey,
72948
+ ["api"+"Key"]: cfg.openaiApiKey,
72904
72949
  ...cfg.openaiBaseUrl ? { baseURL: cfg.openaiBaseUrl } : {}
72905
72950
  }) : null;
72906
72951
  let stopDreamWatcher = null;
@@ -73067,7 +73112,7 @@ Keep the reflection grounded in the evidence below.
73067
73112
  allowedChatTypes: cfg.activeRecallAllowedChatTypes,
73068
73113
  queryMode: cfg.activeRecallQueryMode,
73069
73114
  promptStyle: cfg.activeRecallPromptStyle,
73070
- promptOverride: cfg.activeRecallPromptOverride,
73115
+ customInstruction: cfg.activeRecallCustomInstruction,
73071
73116
  promptAppend: cfg.activeRecallPromptAppend,
73072
73117
  maxSummaryChars: cfg.activeRecallMaxSummaryChars,
73073
73118
  recentUserTurns: cfg.activeRecallRecentUserTurns,
@@ -73835,7 +73880,7 @@ Keep the reflection grounded in the evidence below.
73835
73880
  const memoryLines = useMemoryPromptSection ? memorySectionLines : [...auxiliaryLines, ...memorySectionLines];
73836
73881
  const promptWithVerbose = useMemoryPromptSection ? auxiliaryLines.length > 0 ? auxiliaryLines.join("\n").replace(/\n$/, "") : void 0 : auxiliaryLines.length > 0 ? [...auxiliaryLines, ...memorySectionLines].join("\n").replace(/\n$/, "") : renderMemoryContextPrompt2(trimmed);
73837
73882
  log.debug(
73838
- `${hookLabel}: returning system prompt with ${trimmed.length} chars`
73883
+ `${hookLabel}: returning memory context with ${trimmed.length} chars`
73839
73884
  );
73840
73885
  if (hookLabel === "before_prompt_build") {
73841
73886
  return promptWithVerbose ? { prependSystemContext: promptWithVerbose, memoryLines } : { memoryLines };
@@ -73861,34 +73906,36 @@ Keep the reflection grounded in the evidence below.
73861
73906
  if (!useMemoryPromptSection && promptInjectionAllowed) {
73862
73907
  const needsCacheFallback = sdkCaps.hasRegisterMemoryCapability && typeof api.registerMemoryCapability === "function";
73863
73908
  if (sdkCaps.hasBeforePromptBuild) {
73864
- api.on(
73865
- "before_prompt_build",
73866
- async (event, ctx) => {
73867
- const sessionKey = ctx?.sessionKey ?? "default";
73868
- const sessionIdentity = resolveSessionIdentity2(sessionKey, event, ctx);
73869
- if (needsCacheFallback) {
73870
- cachePromptMemoryLines2(
73871
- sessionKey,
73872
- sessionIdentity.providerThreadId,
73873
- null
73874
- );
73875
- }
73876
- const result = await recallHookHandler("before_prompt_build", event, ctx);
73877
- if (needsCacheFallback && result?.memoryLines) {
73878
- cachePromptMemoryLines2(
73879
- sessionKey,
73880
- sessionIdentity.providerThreadId,
73881
- result.memoryLines
73882
- );
73883
- }
73884
- if (result && "memoryLines" in result) {
73885
- const { memoryLines: _ml, ...gatewayResult } = result;
73886
- return Object.keys(gatewayResult).length > 0 ? gatewayResult : void 0;
73887
- }
73888
- return result;
73889
- },
73890
- { timeoutMs: cfg.initGateTimeoutMs }
73891
- );
73909
+ ((api2) => {
73910
+ api2.on(
73911
+ "before_prompt_build",
73912
+ async (event, ctx) => {
73913
+ const sessionKey = ctx?.sessionKey ?? "default";
73914
+ const sessionIdentity = resolveSessionIdentity2(sessionKey, event, ctx);
73915
+ if (needsCacheFallback) {
73916
+ cachePromptMemoryLines2(
73917
+ sessionKey,
73918
+ sessionIdentity.providerThreadId,
73919
+ null
73920
+ );
73921
+ }
73922
+ const result = await recallHookHandler("before_prompt_build", event, ctx);
73923
+ if (needsCacheFallback && result?.memoryLines) {
73924
+ cachePromptMemoryLines2(
73925
+ sessionKey,
73926
+ sessionIdentity.providerThreadId,
73927
+ result.memoryLines
73928
+ );
73929
+ }
73930
+ if (result && "memoryLines" in result) {
73931
+ const { memoryLines: _ml, ...gatewayResult } = result;
73932
+ return Object.keys(gatewayResult).length > 0 ? gatewayResult : void 0;
73933
+ }
73934
+ return result;
73935
+ },
73936
+ { timeoutMs: cfg.initGateTimeoutMs }
73937
+ );
73938
+ })(api);
73892
73939
  } else {
73893
73940
  api.on(
73894
73941
  "before_agent_start",
@@ -73957,14 +74004,14 @@ Keep the reflection grounded in the evidence below.
73957
74004
  const canonicalizeRootForContainment = async (rawPath) => {
73958
74005
  const resolved = path99.resolve(rawPath);
73959
74006
  try {
73960
- return path99.normalize(await realpath7(resolved));
74007
+ return path99.normalize(await realPathLater(resolved));
73961
74008
  } catch {
73962
74009
  return path99.normalize(resolved);
73963
74010
  }
73964
74011
  };
73965
74012
  const canonicalizeForRead = async (rawPath) => {
73966
74013
  const resolved = path99.resolve(rawPath);
73967
- const real = await realpath7(resolved);
74014
+ const real = await realPathLater(resolved);
73968
74015
  return path99.normalize(real);
73969
74016
  };
73970
74017
  const readAllowedCanonicalRootsPromise = Promise.all(
@@ -74082,7 +74129,7 @@ Keep the reflection grounded in the evidence below.
74082
74129
  async readFile(params) {
74083
74130
  const requestedPath = normalizeWorkspacePath(params.relPath);
74084
74131
  const absolutePath = await resolveReadablePath(params.relPath);
74085
- const text = await readFile53(absolutePath, "utf-8");
74132
+ const text = await readTextFileLater(absolutePath);
74086
74133
  const allLines = text.split(/\r?\n/);
74087
74134
  const from = typeof params.from === "number" ? Math.max(1, Math.floor(params.from)) : 1;
74088
74135
  const lines = typeof params.lines === "number" && Number.isFinite(params.lines) ? Math.max(1, Math.floor(params.lines)) : void 0;
@@ -74492,14 +74539,13 @@ Keep the reflection grounded in the evidence below.
74492
74539
  workspaceDir,
74493
74540
  `.compaction-reset-signal-${safeSessionKey}`
74494
74541
  );
74495
- await writeFile44(
74542
+ await writeTextFileLater(
74496
74543
  signalPath,
74497
74544
  JSON.stringify({
74498
74545
  sessionKey,
74499
74546
  compactedAt: (/* @__PURE__ */ new Date()).toISOString(),
74500
74547
  messageCount: event.messageCount ?? 0
74501
- }),
74502
- "utf-8"
74548
+ })
74503
74549
  );
74504
74550
  } else {
74505
74551
  const errorDetail = result && typeof result === "object" && "error" in result ? String(
@@ -74743,7 +74789,7 @@ Keep the reflection grounded in the evidence below.
74743
74789
  jobs: []
74744
74790
  };
74745
74791
  try {
74746
- const content = await readFile53(cronFilePath, "utf-8");
74792
+ const content = await readTextFileLater(cronFilePath);
74747
74793
  jobsData = JSON.parse(content);
74748
74794
  } catch {
74749
74795
  }
@@ -74780,10 +74826,9 @@ Keep the reflection grounded in the evidence below.
74780
74826
  state: {}
74781
74827
  };
74782
74828
  jobsData.jobs.push(newJob);
74783
- await writeFile44(
74829
+ await writeTextFileLater(
74784
74830
  cronFilePath,
74785
- JSON.stringify(jobsData, null, 2),
74786
- "utf-8"
74831
+ JSON.stringify(jobsData, null, 2)
74787
74832
  );
74788
74833
  log.info("auto-registered hourly summary cron job");
74789
74834
  } catch (err) {
@@ -75062,7 +75107,7 @@ function extractTextContent2(msg) {
75062
75107
  }
75063
75108
 
75064
75109
  // src/bridge.ts
75065
- import { existsSync as existsSync13, readFileSync as readFileSync7, statSync as statSync3 } from "fs";
75110
+ import fs18 from "fs";
75066
75111
  import path100 from "path";
75067
75112
  import { Worker } from "worker_threads";
75068
75113
  var DEFAULT_HOST = "127.0.0.1";
@@ -75140,7 +75185,7 @@ function configPathCandidates() {
75140
75185
  }
75141
75186
  function fileExists2(filePath) {
75142
75187
  try {
75143
- return statSync3(filePath).isFile();
75188
+ return fs18.statSync(filePath).isFile();
75144
75189
  } catch {
75145
75190
  return false;
75146
75191
  }
@@ -75151,7 +75196,7 @@ function isDaemonRunning() {
75151
75196
  path100.join(resolveHomeDir2(), ".engram", "server.pid")
75152
75197
  ]) {
75153
75198
  try {
75154
- const pid = parseInt(readFileSync7(pidFile, "utf8").trim(), 10);
75199
+ const pid = parseInt(fs18.readFileSync(pidFile, "utf8").trim(), 10);
75155
75200
  process.kill(pid, 0);
75156
75201
  return true;
75157
75202
  } catch {
@@ -75201,9 +75246,9 @@ function readDaemonPort() {
75201
75246
  const envPort = coerceDaemonPort(readCompatEnv("REMNIC_PORT", "ENGRAM_PORT"));
75202
75247
  if (envPort !== void 0) return envPort;
75203
75248
  for (const p of configPathCandidates()) {
75204
- if (!existsSync13(p)) continue;
75249
+ if (!fs18.existsSync(p)) continue;
75205
75250
  try {
75206
- const raw = JSON.parse(readFileSync7(p, "utf8"));
75251
+ const raw = JSON.parse(fs18.readFileSync(p, "utf8"));
75207
75252
  const configPort = coerceDaemonPort(raw.server?.port);
75208
75253
  if (configPort !== void 0) return configPort;
75209
75254
  } catch {
@@ -75248,9 +75293,9 @@ function loadAnyToken() {
75248
75293
  path100.join(resolveHomeDir2(), ".engram", "tokens.json")
75249
75294
  ];
75250
75295
  for (const tokensPath of tokenPaths) {
75251
- if (!existsSync13(tokensPath)) continue;
75296
+ if (!fs18.existsSync(tokensPath)) continue;
75252
75297
  try {
75253
- const store = JSON.parse(readFileSync7(tokensPath, "utf8"));
75298
+ const store = JSON.parse(fs18.readFileSync(tokensPath, "utf8"));
75254
75299
  const tokens = Array.isArray(store.tokens) ? store.tokens : [];
75255
75300
  if (tokens.length > 0 && tokens[0].token) return tokens[0].token;
75256
75301
  if (typeof store === "object" && store !== null) {
@@ -75265,8 +75310,8 @@ function loadAnyToken() {
75265
75310
  }
75266
75311
  try {
75267
75312
  for (const p of configPathCandidates()) {
75268
- if (existsSync13(p)) {
75269
- const raw = JSON.parse(readFileSync7(p, "utf8"));
75313
+ if (fs18.existsSync(p)) {
75314
+ const raw = JSON.parse(fs18.readFileSync(p, "utf8"));
75270
75315
  if (raw.server?.authToken) return raw.server.authToken;
75271
75316
  }
75272
75317
  }