@integrity-labs/agt-cli 0.27.161 → 0.27.163

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.
@@ -22,7 +22,7 @@ import {
22
22
  provisionStopHook,
23
23
  requireHost,
24
24
  safeWriteJsonAtomic
25
- } from "../chunk-V5RAWFRT.js";
25
+ } from "../chunk-DTZKJYJP.js";
26
26
  import {
27
27
  getProjectDir as getProjectDir2,
28
28
  getReadyTasks,
@@ -64,7 +64,7 @@ import {
64
64
  takeWatchdogGiveUpCount,
65
65
  takeZombieDetection,
66
66
  transcriptActivityAgeSeconds
67
- } from "../chunk-7RCGHACC.js";
67
+ } from "../chunk-5TBIEU36.js";
68
68
  import {
69
69
  FLAGS_SCHEMA_VERSION,
70
70
  KANBAN_CHECK_COMMAND,
@@ -93,9 +93,10 @@ import {
93
93
  resolveChannels,
94
94
  resolveConnectivityProbe,
95
95
  resolveDmTarget,
96
+ sumTranscriptUsageInWindow,
96
97
  worseConnectivityOutcome,
97
98
  wrapScheduledTaskPrompt
98
- } from "../chunk-BC26YO7P.js";
99
+ } from "../chunk-3A2H4ZLD.js";
99
100
  import {
100
101
  parsePsRows,
101
102
  reapOrphanChannelMcps
@@ -103,10 +104,10 @@ import {
103
104
 
104
105
  // src/lib/manager-worker.ts
105
106
  import { createHash as createHash3 } from "crypto";
106
- import { readFileSync as readFileSync9, writeFileSync as writeFileSync4, appendFileSync, mkdirSync as mkdirSync3, chmodSync, existsSync as existsSync5, rmSync as rmSync2, readdirSync as readdirSync4, statSync as statSync3, unlinkSync, copyFileSync } from "fs";
107
+ import { readFileSync as readFileSync10, writeFileSync as writeFileSync4, appendFileSync, mkdirSync as mkdirSync3, chmodSync, existsSync as existsSync5, rmSync as rmSync2, readdirSync as readdirSync5, statSync as statSync4, unlinkSync, copyFileSync } from "fs";
107
108
  import https from "https";
108
109
  import { execFileSync as syncExecFile } from "child_process";
109
- import { join as join9, dirname as dirname2 } from "path";
110
+ import { join as join10, dirname as dirname2 } from "path";
110
111
  import { homedir as homedir5 } from "os";
111
112
  import { fileURLToPath } from "url";
112
113
 
@@ -1976,11 +1977,127 @@ async function maybeReportTokenUsage(args) {
1976
1977
  state2.set(codeName, next);
1977
1978
  }
1978
1979
 
1979
- // src/lib/conversation-evaluator.ts
1980
+ // src/lib/workflow-run-reconciler.ts
1980
1981
  import { readdirSync as readdirSync2, readFileSync as readFileSync5, statSync as statSync2 } from "fs";
1981
1982
  import { join as join4 } from "path";
1982
1983
  var MIN_CHECK_INTERVAL_MS3 = 5 * 6e4;
1983
- var TRANSCRIPT_MTIME_WINDOW_MS2 = 3 * 24 * 60 * 60 * 1e3;
1984
+ var SETTLE_MS = 3e4;
1985
+ var TRANSCRIPT_MTIME_WINDOW_MS2 = 2 * 24 * 60 * 60 * 1e3;
1986
+ var MAX_RUNS_PER_TICK = 20;
1987
+ var lastCheckedAt = /* @__PURE__ */ new Map();
1988
+ function emptyTotals() {
1989
+ return { inputTokens: 0, outputTokens: 0, cacheCreationTokens: 0, cacheReadTokens: 0 };
1990
+ }
1991
+ function enumerateTranscriptFiles(transcriptDir, nowMs, minMtimeMs = nowMs - TRANSCRIPT_MTIME_WINDOW_MS2) {
1992
+ const out = [];
1993
+ let entries;
1994
+ try {
1995
+ entries = readdirSync2(transcriptDir);
1996
+ } catch {
1997
+ return out;
1998
+ }
1999
+ for (const name of entries) {
2000
+ const path = join4(transcriptDir, name);
2001
+ let st;
2002
+ try {
2003
+ st = statSync2(path);
2004
+ } catch {
2005
+ continue;
2006
+ }
2007
+ if (st.isFile() && name.endsWith(".jsonl")) {
2008
+ if (st.mtimeMs >= minMtimeMs) out.push(path);
2009
+ continue;
2010
+ }
2011
+ if (st.isDirectory()) {
2012
+ const subDir = join4(path, "subagents");
2013
+ let subEntries;
2014
+ try {
2015
+ subEntries = readdirSync2(subDir);
2016
+ } catch {
2017
+ continue;
2018
+ }
2019
+ for (const sub of subEntries) {
2020
+ if (!sub.endsWith(".jsonl")) continue;
2021
+ const subPath = join4(subDir, sub);
2022
+ try {
2023
+ const sst = statSync2(subPath);
2024
+ if (sst.isFile() && sst.mtimeMs >= minMtimeMs) out.push(subPath);
2025
+ } catch {
2026
+ }
2027
+ }
2028
+ }
2029
+ }
2030
+ return out;
2031
+ }
2032
+ function sumWindowedUsageAcrossContents(contents, startMs, endMs) {
2033
+ const totals = emptyTotals();
2034
+ for (const content of contents) {
2035
+ const r = sumTranscriptUsageInWindow(content, startMs, endMs);
2036
+ totals.inputTokens += r.totals.inputTokens;
2037
+ totals.outputTokens += r.totals.outputTokens;
2038
+ totals.cacheCreationTokens += r.totals.cacheCreationTokens;
2039
+ totals.cacheReadTokens += r.totals.cacheReadTokens;
2040
+ }
2041
+ return totals;
2042
+ }
2043
+ async function maybeReconcileWorkflowRunTokens(args) {
2044
+ const { api: api2, codeName, agentId, log: log2 } = args;
2045
+ const now = args.now ?? /* @__PURE__ */ new Date();
2046
+ const nowMs = now.getTime();
2047
+ const prev = lastCheckedAt.get(codeName);
2048
+ if (prev !== void 0 && nowMs - prev < MIN_CHECK_INTERVAL_MS3) return;
2049
+ lastCheckedAt.set(codeName, nowMs);
2050
+ let runs;
2051
+ try {
2052
+ const res = await api2.get("/host/workflow-runs/unreconciled");
2053
+ runs = (res?.runs ?? []).filter(
2054
+ (r) => r.agent_id === agentId && !!r.finished_at && nowMs - new Date(r.finished_at).getTime() >= SETTLE_MS
2055
+ );
2056
+ } catch (err) {
2057
+ log2(`[workflow-reconcile] list failed for '${codeName}': ${err.message}`);
2058
+ return;
2059
+ }
2060
+ if (runs.length === 0) return;
2061
+ const dir = args.transcriptDir ?? sessionTranscriptDir(getProjectDir(codeName));
2062
+ const runStartMs = runs.map((r) => new Date(r.started_at).getTime()).filter((t) => Number.isFinite(t));
2063
+ const minMtimeMs = runStartMs.length > 0 ? Math.min(...runStartMs) : nowMs - TRANSCRIPT_MTIME_WINDOW_MS2;
2064
+ const files = enumerateTranscriptFiles(dir, nowMs, minMtimeMs);
2065
+ const contents = [];
2066
+ for (const path of files) {
2067
+ try {
2068
+ contents.push(readFileSync5(path, "utf-8"));
2069
+ } catch {
2070
+ }
2071
+ }
2072
+ if (contents.length === 0) return;
2073
+ let reconciled = 0;
2074
+ for (const run of runs.slice(0, MAX_RUNS_PER_TICK)) {
2075
+ const startMs = new Date(run.started_at).getTime();
2076
+ const endMs = new Date(run.finished_at).getTime();
2077
+ if (!Number.isFinite(startMs) || !Number.isFinite(endMs) || endMs < startMs) continue;
2078
+ const totals = sumWindowedUsageAcrossContents(contents, startMs, endMs);
2079
+ try {
2080
+ await api2.post(`/host/workflow-runs/${run.id}/reconcile-tokens`, {
2081
+ total_input_tokens: totals.inputTokens,
2082
+ total_output_tokens: totals.outputTokens,
2083
+ total_cache_creation_tokens: totals.cacheCreationTokens,
2084
+ total_cache_read_tokens: totals.cacheReadTokens
2085
+ });
2086
+ reconciled++;
2087
+ } catch (err) {
2088
+ log2(`[workflow-reconcile] post failed for run ${run.id}: ${err.message}`);
2089
+ }
2090
+ }
2091
+ if (reconciled > 0) {
2092
+ log2(`[workflow-reconcile] reconciled ${reconciled} run(s) for '${codeName}'`);
2093
+ }
2094
+ }
2095
+
2096
+ // src/lib/conversation-evaluator.ts
2097
+ import { readdirSync as readdirSync3, readFileSync as readFileSync6, statSync as statSync3 } from "fs";
2098
+ import { join as join5 } from "path";
2099
+ var MIN_CHECK_INTERVAL_MS4 = 5 * 6e4;
2100
+ var TRANSCRIPT_MTIME_WINDOW_MS3 = 3 * 24 * 60 * 60 * 1e3;
1984
2101
  var WINDOW_PAD_MS = 5 * 6e4;
1985
2102
  var MAX_TURN_CHARS = 1500;
1986
2103
  var MAX_TRANSCRIPT_CHARS = 6e3;
@@ -2128,7 +2245,7 @@ async function maybeEvaluateConversations(args) {
2128
2245
  const now = args.now ?? /* @__PURE__ */ new Date();
2129
2246
  const nowMs = now.getTime();
2130
2247
  const existing = state3.get(codeName);
2131
- if (existing && nowMs - existing.lastCheckedAt < MIN_CHECK_INTERVAL_MS3) {
2248
+ if (existing && nowMs - existing.lastCheckedAt < MIN_CHECK_INTERVAL_MS4) {
2132
2249
  return;
2133
2250
  }
2134
2251
  state3.set(codeName, { lastCheckedAt: nowMs });
@@ -2208,24 +2325,24 @@ async function reportSkip(api2, agentId, conversationId, log2, codeName) {
2208
2325
  function readRecentTurns(dir, nowMs) {
2209
2326
  let entries;
2210
2327
  try {
2211
- entries = readdirSync2(dir);
2328
+ entries = readdirSync3(dir);
2212
2329
  } catch {
2213
2330
  return [];
2214
2331
  }
2215
2332
  const turns = [];
2216
2333
  for (const name of entries) {
2217
2334
  if (!name.endsWith(".jsonl")) continue;
2218
- const full = join4(dir, name);
2335
+ const full = join5(dir, name);
2219
2336
  let mtimeMs;
2220
2337
  try {
2221
- mtimeMs = statSync2(full).mtimeMs;
2338
+ mtimeMs = statSync3(full).mtimeMs;
2222
2339
  } catch {
2223
2340
  continue;
2224
2341
  }
2225
- if (nowMs - mtimeMs > TRANSCRIPT_MTIME_WINDOW_MS2) continue;
2342
+ if (nowMs - mtimeMs > TRANSCRIPT_MTIME_WINDOW_MS3) continue;
2226
2343
  let content;
2227
2344
  try {
2228
- content = readFileSync5(full, "utf8");
2345
+ content = readFileSync6(full, "utf8");
2229
2346
  } catch {
2230
2347
  continue;
2231
2348
  }
@@ -2235,7 +2352,7 @@ function readRecentTurns(dir, nowMs) {
2235
2352
  }
2236
2353
 
2237
2354
  // src/lib/memory-extractor.ts
2238
- var MIN_CHECK_INTERVAL_MS4 = 10 * 6e4;
2355
+ var MIN_CHECK_INTERVAL_MS5 = 10 * 6e4;
2239
2356
  var WINDOW_PAD_MS2 = 5 * 6e4;
2240
2357
  var VALID_MEMORY_TYPES = /* @__PURE__ */ new Set(["user", "feedback", "project", "reference"]);
2241
2358
  var SECRET_PATTERNS = [
@@ -2310,7 +2427,7 @@ async function maybeExtractMemories(args) {
2310
2427
  const now = args.now ?? /* @__PURE__ */ new Date();
2311
2428
  const nowMs = now.getTime();
2312
2429
  const existing = state4.get(codeName);
2313
- if (existing && nowMs - existing.lastCheckedAt < MIN_CHECK_INTERVAL_MS4) {
2430
+ if (existing && nowMs - existing.lastCheckedAt < MIN_CHECK_INTERVAL_MS5) {
2314
2431
  return;
2315
2432
  }
2316
2433
  state4.set(codeName, { lastCheckedAt: nowMs });
@@ -2394,11 +2511,11 @@ async function reportSkip2(api2, agentId, conversationId, log2, codeName) {
2394
2511
  }
2395
2512
 
2396
2513
  // src/lib/activity-cache-monitor.ts
2397
- import { existsSync as existsSync2, readFileSync as readFileSync6 } from "fs";
2514
+ import { existsSync as existsSync2, readFileSync as readFileSync7 } from "fs";
2398
2515
  import { homedir as homedir2 } from "os";
2399
- import { join as join5 } from "path";
2400
- var MIN_CHECK_INTERVAL_MS5 = 6e4;
2401
- var STATS_CACHE_PATH = join5(homedir2(), ".claude", "stats-cache.json");
2516
+ import { join as join6 } from "path";
2517
+ var MIN_CHECK_INTERVAL_MS6 = 6e4;
2518
+ var STATS_CACHE_PATH = join6(homedir2(), ".claude", "stats-cache.json");
2402
2519
  var ISO_DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
2403
2520
  var state5 = { lastObservedDate: null, lastCheckedAt: 0 };
2404
2521
  function selectNewDailyRows(raw, lastObservedDate) {
@@ -2439,14 +2556,14 @@ async function maybeReportActivityCache(args) {
2439
2556
  const { api: api2, log: log2 } = args;
2440
2557
  const now = args.now ?? /* @__PURE__ */ new Date();
2441
2558
  const nowMs = now.getTime();
2442
- if (nowMs - state5.lastCheckedAt < MIN_CHECK_INTERVAL_MS5) return;
2559
+ if (nowMs - state5.lastCheckedAt < MIN_CHECK_INTERVAL_MS6) return;
2443
2560
  state5.lastCheckedAt = nowMs;
2444
2561
  if (!existsSync2(STATS_CACHE_PATH)) {
2445
2562
  return;
2446
2563
  }
2447
2564
  let raw;
2448
2565
  try {
2449
- raw = readFileSync6(STATS_CACHE_PATH, "utf-8");
2566
+ raw = readFileSync7(STATS_CACHE_PATH, "utf-8");
2450
2567
  } catch (err) {
2451
2568
  log2(`[activity-cache] readFileSync failed: ${err.message}`);
2452
2569
  return;
@@ -2896,7 +3013,7 @@ var GatewayClientPool = class extends EventEmitter {
2896
3013
  // src/lib/claude-auth-detect.ts
2897
3014
  import { readFile as readFile2, readdir as readdir2 } from "fs/promises";
2898
3015
  import { homedir as homedir3, platform } from "os";
2899
- import { join as join6 } from "path";
3016
+ import { join as join7 } from "path";
2900
3017
  import { execFile as execFile2 } from "child_process";
2901
3018
  import { promisify } from "util";
2902
3019
  var execFileAsync = promisify(execFile2);
@@ -2911,8 +3028,8 @@ async function detectClaudeAuth() {
2911
3028
  }
2912
3029
  async function findClaudeCredentialsPaths() {
2913
3030
  const candidates = [
2914
- join6(homedir3(), ".claude", ".credentials.json"),
2915
- join6(homedir3(), ".claude", "credentials.json")
3031
+ join7(homedir3(), ".claude", ".credentials.json"),
3032
+ join7(homedir3(), ".claude", "credentials.json")
2916
3033
  ];
2917
3034
  const isLinuxRoot = platform() === "linux" && typeof process.getuid === "function" && process.getuid() === 0;
2918
3035
  if (isLinuxRoot) {
@@ -2920,8 +3037,8 @@ async function findClaudeCredentialsPaths() {
2920
3037
  const entries = await readdir2("/home", { withFileTypes: true });
2921
3038
  for (const entry of entries) {
2922
3039
  if (!entry.isDirectory()) continue;
2923
- candidates.push(join6("/home", entry.name, ".claude", ".credentials.json"));
2924
- candidates.push(join6("/home", entry.name, ".claude", "credentials.json"));
3040
+ candidates.push(join7("/home", entry.name, ".claude", ".credentials.json"));
3041
+ candidates.push(join7("/home", entry.name, ".claude", "credentials.json"));
2925
3042
  }
2926
3043
  } catch {
2927
3044
  }
@@ -3013,18 +3130,18 @@ function normalize(value) {
3013
3130
  }
3014
3131
 
3015
3132
  // src/lib/channel-hash-cache.ts
3016
- import { existsSync as existsSync3, readFileSync as readFileSync7, writeFileSync as writeFileSync2 } from "fs";
3017
- import { join as join7 } from "path";
3133
+ import { existsSync as existsSync3, readFileSync as readFileSync8, writeFileSync as writeFileSync2 } from "fs";
3134
+ import { join as join8 } from "path";
3018
3135
  var CACHE_FILENAME = "channel-hash-cache.json";
3019
3136
  function getChannelHashCacheFile(configDir) {
3020
- return join7(configDir, CACHE_FILENAME);
3137
+ return join8(configDir, CACHE_FILENAME);
3021
3138
  }
3022
3139
  function loadChannelHashCache(target, configDir) {
3023
3140
  const path = getChannelHashCacheFile(configDir);
3024
3141
  if (!existsSync3(path)) return;
3025
3142
  let parsed;
3026
3143
  try {
3027
- parsed = JSON.parse(readFileSync7(path, "utf-8"));
3144
+ parsed = JSON.parse(readFileSync8(path, "utf-8"));
3028
3145
  } catch {
3029
3146
  return;
3030
3147
  }
@@ -3625,24 +3742,24 @@ function partitionActionableByPoison(actionable, states, config2) {
3625
3742
  }
3626
3743
 
3627
3744
  // src/lib/restart-flags.ts
3628
- import { existsSync as existsSync4, mkdirSync as mkdirSync2, readdirSync as readdirSync3, readFileSync as readFileSync8, renameSync, rmSync, writeFileSync as writeFileSync3 } from "fs";
3745
+ import { existsSync as existsSync4, mkdirSync as mkdirSync2, readdirSync as readdirSync4, readFileSync as readFileSync9, renameSync, rmSync, writeFileSync as writeFileSync3 } from "fs";
3629
3746
  import { homedir as homedir4 } from "os";
3630
- import { join as join8 } from "path";
3747
+ import { join as join9 } from "path";
3631
3748
  import { randomUUID } from "crypto";
3632
3749
  function restartFlagsDir() {
3633
- return join8(homedir4(), ".augmented", "restart-flags");
3750
+ return join9(homedir4(), ".augmented", "restart-flags");
3634
3751
  }
3635
3752
  function flagPath(codeName) {
3636
- return join8(restartFlagsDir(), `${codeName}.flag`);
3753
+ return join9(restartFlagsDir(), `${codeName}.flag`);
3637
3754
  }
3638
3755
  function readRestartFlags() {
3639
3756
  const dir = restartFlagsDir();
3640
3757
  if (!existsSync4(dir)) return [];
3641
3758
  const out = [];
3642
- for (const entry of readdirSync3(dir)) {
3759
+ for (const entry of readdirSync4(dir)) {
3643
3760
  if (!entry.endsWith(".flag")) continue;
3644
3761
  try {
3645
- const raw = readFileSync8(join8(dir, entry), "utf8");
3762
+ const raw = readFileSync9(join9(dir, entry), "utf8");
3646
3763
  const parsed = JSON.parse(raw);
3647
3764
  if (typeof parsed.codeName !== "string" || parsed.codeName.length === 0) {
3648
3765
  parsed.codeName = entry.replace(/\.flag$/, "");
@@ -4190,8 +4307,8 @@ function applyRestartAcks(args) {
4190
4307
  var GATEWAY_PORT_BASE = 18800;
4191
4308
  var GATEWAY_PORT_STEP = 10;
4192
4309
  var GATEWAY_PORT_MAX = 18899;
4193
- var AUGMENTED_DIR = join9(process.env["HOME"] ?? "/tmp", ".augmented");
4194
- var GATEWAY_PORTS_FILE = join9(AUGMENTED_DIR, "gateway-ports.json");
4310
+ var AUGMENTED_DIR = join10(process.env["HOME"] ?? "/tmp", ".augmented");
4311
+ var GATEWAY_PORTS_FILE = join10(AUGMENTED_DIR, "gateway-ports.json");
4195
4312
  var CHANNEL_SWEEP_INTERVAL_MS = (() => {
4196
4313
  const raw = parseInt(process.env["AGT_CHANNEL_SWEEP_INTERVAL_MS"] ?? "", 10);
4197
4314
  if (!Number.isFinite(raw)) return 5 * 60 * 1e3;
@@ -4540,7 +4657,7 @@ function inboundAgeSecondsFor(codeName) {
4540
4657
  }
4541
4658
  function paneLogAgeSecondsFor(codeName) {
4542
4659
  try {
4543
- const mtimeMs = statSync3(paneLogPath(codeName)).mtimeMs;
4660
+ const mtimeMs = statSync4(paneLogPath(codeName)).mtimeMs;
4544
4661
  return Math.max(0, Math.floor((Date.now() - mtimeMs) / 1e3));
4545
4662
  } catch (err) {
4546
4663
  if (err?.code === "ENOENT") return null;
@@ -4566,7 +4683,7 @@ var runningMcpServerKeys = /* @__PURE__ */ new Map();
4566
4683
  var runningChannelSecretHashes = /* @__PURE__ */ new Map();
4567
4684
  function projectMcpHash(_codeName, projectDir) {
4568
4685
  try {
4569
- const raw = readFileSync9(join9(projectDir, ".mcp.json"), "utf-8");
4686
+ const raw = readFileSync10(join10(projectDir, ".mcp.json"), "utf-8");
4570
4687
  return createHash3("sha256").update(canonicalJson(JSON.parse(raw))).digest("hex");
4571
4688
  } catch {
4572
4689
  return null;
@@ -4574,7 +4691,7 @@ function projectMcpHash(_codeName, projectDir) {
4574
4691
  }
4575
4692
  function projectMcpKeys(_codeName, projectDir) {
4576
4693
  try {
4577
- const raw = readFileSync9(join9(projectDir, ".mcp.json"), "utf-8");
4694
+ const raw = readFileSync10(join10(projectDir, ".mcp.json"), "utf-8");
4578
4695
  const parsed = JSON.parse(raw);
4579
4696
  const servers = parsed.mcpServers;
4580
4697
  if (!servers || typeof servers !== "object") return /* @__PURE__ */ new Set();
@@ -4585,7 +4702,7 @@ function projectMcpKeys(_codeName, projectDir) {
4585
4702
  }
4586
4703
  function readMcpHttpServerConfig(projectDir, serverKey, env) {
4587
4704
  try {
4588
- const raw = readFileSync9(join9(projectDir, ".mcp.json"), "utf-8");
4705
+ const raw = readFileSync10(join10(projectDir, ".mcp.json"), "utf-8");
4589
4706
  const servers = JSON.parse(raw).mcpServers ?? {};
4590
4707
  const entry = servers[serverKey];
4591
4708
  if (entry && typeof entry.url === "string" && (entry.type === "http" || entry.type === void 0)) {
@@ -4613,9 +4730,9 @@ async function runAgentConnectivityProbes(agent, integrations, projectDir) {
4613
4730
  if (integrations.length === 0) return;
4614
4731
  const probeEnv = { ...process.env };
4615
4732
  try {
4616
- const envIntPath = join9(projectDir, ".env.integrations");
4733
+ const envIntPath = join10(projectDir, ".env.integrations");
4617
4734
  if (existsSync5(envIntPath)) {
4618
- Object.assign(probeEnv, parseEnvIntegrations(readFileSync9(envIntPath, "utf-8")));
4735
+ Object.assign(probeEnv, parseEnvIntegrations(readFileSync10(envIntPath, "utf-8")));
4619
4736
  }
4620
4737
  } catch {
4621
4738
  }
@@ -4803,7 +4920,7 @@ function checkMcpConfigDriftAndScheduleRestart(codeName, projectDir) {
4803
4920
  function projectChannelSecretHash(projectDir) {
4804
4921
  try {
4805
4922
  const entries = parseEnvIntegrations(
4806
- readFileSync9(join9(projectDir, ".env.integrations"), "utf-8")
4923
+ readFileSync10(join10(projectDir, ".env.integrations"), "utf-8")
4807
4924
  );
4808
4925
  return channelSecretValueHash(entries, CHANNEL_SECRET_ENV_KEYS);
4809
4926
  } catch {
@@ -4895,7 +5012,7 @@ var cachedMaintenanceWindow = null;
4895
5012
  var lastVersionCheckAt = 0;
4896
5013
  var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
4897
5014
  var lastResponsivenessProbeAt = 0;
4898
- var agtCliVersion = true ? "0.27.161" : "dev";
5015
+ var agtCliVersion = true ? "0.27.163" : "dev";
4899
5016
  function resolveBrewPath(execFileSync4) {
4900
5017
  try {
4901
5018
  const out = execFileSync4("which", ["brew"], { timeout: 5e3 }).toString().trim();
@@ -5072,7 +5189,7 @@ function ensureClaudeManagedSettings(path = claudeManagedSettingsPath()) {
5072
5189
  try {
5073
5190
  let settings = {};
5074
5191
  if (existsSync5(path)) {
5075
- const raw = readFileSync9(path, "utf-8").trim();
5192
+ const raw = readFileSync10(path, "utf-8").trim();
5076
5193
  if (raw) {
5077
5194
  let parsed;
5078
5195
  try {
@@ -5146,7 +5263,7 @@ async function ensureFrameworkBinary(frameworkId) {
5146
5263
  var CLAUDE_CODE_UPGRADE_CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
5147
5264
  var claudeCodeUpgradeInFlight = false;
5148
5265
  function claudeCodeUpgradeMarkerPath() {
5149
- return join9(homedir5(), ".augmented", ".last-claude-code-upgrade-check");
5266
+ return join10(homedir5(), ".augmented", ".last-claude-code-upgrade-check");
5150
5267
  }
5151
5268
  function stampClaudeCodeUpgradeMarker() {
5152
5269
  try {
@@ -5156,7 +5273,7 @@ function stampClaudeCodeUpgradeMarker() {
5156
5273
  }
5157
5274
  function claudeCodeUpgradeThrottled() {
5158
5275
  try {
5159
- const lastCheck = parseInt(readFileSync9(claudeCodeUpgradeMarkerPath(), "utf-8").trim(), 10);
5276
+ const lastCheck = parseInt(readFileSync10(claudeCodeUpgradeMarkerPath(), "utf-8").trim(), 10);
5160
5277
  if (!Number.isFinite(lastCheck)) return false;
5161
5278
  return Date.now() - lastCheck < CLAUDE_CODE_UPGRADE_CHECK_INTERVAL_MS;
5162
5279
  } catch {
@@ -5209,7 +5326,7 @@ ${r.stderr}`;
5209
5326
  }
5210
5327
  var UPDATE_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
5211
5328
  function selfUpdateAppliedMarkerPath() {
5212
- return join9(homedir5(), ".augmented", ".last-self-update-applied");
5329
+ return join10(homedir5(), ".augmented", ".last-self-update-applied");
5213
5330
  }
5214
5331
  var selfUpdateUpToDateLogged = false;
5215
5332
  var restartAfterUpgrade = false;
@@ -5232,7 +5349,7 @@ async function checkAndUpdateCli() {
5232
5349
  const isNpmGlobal = !isBrewFormula && resolvedPath.includes("node_modules");
5233
5350
  if (!isBrewFormula && !isNpmGlobal) return;
5234
5351
  const { readFileSync: readF, writeFileSync: writeF } = await import("fs");
5235
- const markerPath = join9(homedir5(), ".augmented", ".last-update-check");
5352
+ const markerPath = join10(homedir5(), ".augmented", ".last-update-check");
5236
5353
  try {
5237
5354
  const lastCheck = parseInt(readF(markerPath, "utf-8").trim(), 10);
5238
5355
  if (Date.now() - lastCheck < UPDATE_CHECK_INTERVAL_MS) return;
@@ -5489,9 +5606,9 @@ async function applyClaudeAuthToEnv(childEnv, label) {
5489
5606
  throw new Error("claude_auth_mode=api_key but /host/exchange returned no decrypted key");
5490
5607
  }
5491
5608
  childEnv.ANTHROPIC_API_KEY = exchange.anthropicApiKey;
5492
- const claudeDir = join9(homedir5(), ".claude");
5609
+ const claudeDir = join10(homedir5(), ".claude");
5493
5610
  for (const filename of [".credentials.json", "credentials.json"]) {
5494
- const p = join9(claudeDir, filename);
5611
+ const p = join10(claudeDir, filename);
5495
5612
  if (existsSync5(p)) {
5496
5613
  try {
5497
5614
  rmSync2(p, { force: true });
@@ -5507,12 +5624,12 @@ async function applyClaudeAuthToEnv(childEnv, label) {
5507
5624
  var evalEmptyMcpConfigPath = null;
5508
5625
  function ensureEvalEmptyMcpConfig() {
5509
5626
  if (evalEmptyMcpConfigPath && existsSync5(evalEmptyMcpConfigPath)) return evalEmptyMcpConfigPath;
5510
- const dir = join9(homedir5(), ".augmented");
5627
+ const dir = join10(homedir5(), ".augmented");
5511
5628
  try {
5512
5629
  mkdirSync3(dir, { recursive: true });
5513
5630
  } catch {
5514
5631
  }
5515
- const p = join9(dir, ".eval-empty-mcp.json");
5632
+ const p = join10(dir, ".eval-empty-mcp.json");
5516
5633
  writeFileSync4(p, JSON.stringify({ mcpServers: {} }));
5517
5634
  evalEmptyMcpConfigPath = p;
5518
5635
  return p;
@@ -5587,7 +5704,7 @@ function resolveConversationEvalBackend() {
5587
5704
  }
5588
5705
  function loadGatewayPorts() {
5589
5706
  try {
5590
- return JSON.parse(readFileSync9(GATEWAY_PORTS_FILE, "utf-8"));
5707
+ return JSON.parse(readFileSync10(GATEWAY_PORTS_FILE, "utf-8"));
5591
5708
  } catch {
5592
5709
  return {};
5593
5710
  }
@@ -5617,10 +5734,10 @@ function freePort(codeName) {
5617
5734
  }
5618
5735
  }
5619
5736
  function getStateFile() {
5620
- return join9(config?.configDir ?? join9(process.env["HOME"] ?? "/tmp", ".augmented"), "manager-state.json");
5737
+ return join10(config?.configDir ?? join10(process.env["HOME"] ?? "/tmp", ".augmented"), "manager-state.json");
5621
5738
  }
5622
5739
  function channelHashCacheDir() {
5623
- return config?.configDir ?? join9(process.env["HOME"] ?? "/tmp", ".augmented");
5740
+ return config?.configDir ?? join10(process.env["HOME"] ?? "/tmp", ".augmented");
5624
5741
  }
5625
5742
  function loadChannelHashCache2() {
5626
5743
  loadChannelHashCache(agentState.knownChannelConfigHashes, channelHashCacheDir());
@@ -5631,7 +5748,7 @@ function saveChannelHashCache2() {
5631
5748
  var _channelQuarantineStore = null;
5632
5749
  function channelQuarantineStore() {
5633
5750
  if (!_channelQuarantineStore) {
5634
- const dir = config?.configDir ?? join9(process.env["HOME"] ?? "/tmp", ".augmented");
5751
+ const dir = config?.configDir ?? join10(process.env["HOME"] ?? "/tmp", ".augmented");
5635
5752
  _channelQuarantineStore = new ChannelQuarantineStore(defaultQuarantinePath(dir));
5636
5753
  }
5637
5754
  return _channelQuarantineStore;
@@ -5639,16 +5756,13 @@ function channelQuarantineStore() {
5639
5756
  var _hostFlagStore = null;
5640
5757
  function hostFlagStore() {
5641
5758
  if (!_hostFlagStore) {
5642
- const dir = config?.configDir ?? join9(process.env["HOME"] ?? "/tmp", ".augmented");
5759
+ const dir = config?.configDir ?? join10(process.env["HOME"] ?? "/tmp", ".augmented");
5643
5760
  _hostFlagStore = new HostFlagStore({ cachePath: defaultFlagsCachePath(dir), log });
5644
5761
  }
5645
5762
  return _hostFlagStore;
5646
5763
  }
5647
5764
  function channelQuarantineMode() {
5648
- const v = process.env["AGT_CHANNEL_QUARANTINE_MODE"]?.toLowerCase();
5649
- if (v === "off") return "off";
5650
- if (v === "enforce") return "enforce";
5651
- return "shadow";
5765
+ return hostFlagStore().getString("channel-quarantine-mode");
5652
5766
  }
5653
5767
  function channelQuarantineDwellMs() {
5654
5768
  const raw = parseInt(process.env["AGT_CHANNEL_QUARANTINE_DWELL_MS"] ?? "", 10);
@@ -5694,7 +5808,7 @@ function log(msg) {
5694
5808
  `;
5695
5809
  if (!managerLogPath) {
5696
5810
  try {
5697
- managerLogPath = join9(homedir5(), ".augmented", "manager.log");
5811
+ managerLogPath = join10(homedir5(), ".augmented", "manager.log");
5698
5812
  mkdirSync3(dirname2(managerLogPath), { recursive: true });
5699
5813
  if (existsSync5(managerLogPath)) {
5700
5814
  chmodSync(managerLogPath, 384);
@@ -5724,7 +5838,7 @@ function sha256(content) {
5724
5838
  }
5725
5839
  function hashFile(filePath) {
5726
5840
  try {
5727
- const content = readFileSync9(filePath, "utf-8");
5841
+ const content = readFileSync10(filePath, "utf-8");
5728
5842
  return sha256(content);
5729
5843
  } catch {
5730
5844
  return null;
@@ -5748,13 +5862,13 @@ function parseSkillFrontmatter(content) {
5748
5862
  return out;
5749
5863
  }
5750
5864
  async function refreshSkillsIndexInClaudeMd(configDir, codeName, log2) {
5751
- const { readdirSync: readdirSync5, readFileSync: rfs, existsSync: ex, writeFileSync: writeFileSync5 } = await import("fs");
5752
- const skillsDir = join9(configDir, codeName, "project", ".claude", "skills");
5753
- const claudeMdPath = join9(configDir, codeName, "project", "CLAUDE.md");
5865
+ const { readdirSync: readdirSync6, readFileSync: rfs, existsSync: ex, writeFileSync: writeFileSync5 } = await import("fs");
5866
+ const skillsDir = join10(configDir, codeName, "project", ".claude", "skills");
5867
+ const claudeMdPath = join10(configDir, codeName, "project", "CLAUDE.md");
5754
5868
  if (!ex(skillsDir) || !ex(claudeMdPath)) return;
5755
5869
  const entries = [];
5756
- for (const dir of readdirSync5(skillsDir).sort()) {
5757
- const skillFile = join9(skillsDir, dir, "SKILL.md");
5870
+ for (const dir of readdirSync6(skillsDir).sort()) {
5871
+ const skillFile = join10(skillsDir, dir, "SKILL.md");
5758
5872
  if (!ex(skillFile)) continue;
5759
5873
  try {
5760
5874
  const { name, description } = parseSkillFrontmatter(rfs(skillFile, "utf-8"));
@@ -5802,10 +5916,10 @@ ${SKILLS_INDEX_END}`;
5802
5916
  }
5803
5917
  async function migrateToProfiles() {
5804
5918
  const homeDir = process.env["HOME"] ?? "/tmp";
5805
- const sharedConfigPath = join9(homeDir, ".openclaw", "openclaw.json");
5919
+ const sharedConfigPath = join10(homeDir, ".openclaw", "openclaw.json");
5806
5920
  let sharedConfig;
5807
5921
  try {
5808
- sharedConfig = JSON.parse(readFileSync9(sharedConfigPath, "utf-8"));
5922
+ sharedConfig = JSON.parse(readFileSync10(sharedConfigPath, "utf-8"));
5809
5923
  } catch {
5810
5924
  return;
5811
5925
  }
@@ -5818,19 +5932,19 @@ async function migrateToProfiles() {
5818
5932
  const codeName = agentEntry["id"];
5819
5933
  if (!codeName) continue;
5820
5934
  if (codeName === "main") continue;
5821
- const profileDir = join9(homeDir, `.openclaw-${codeName}`);
5822
- if (existsSync5(join9(profileDir, "openclaw.json"))) continue;
5935
+ const profileDir = join10(homeDir, `.openclaw-${codeName}`);
5936
+ if (existsSync5(join10(profileDir, "openclaw.json"))) continue;
5823
5937
  log(`Migrating agent '${codeName}' to per-agent profile`);
5824
5938
  if (adapter.seedProfileConfig) {
5825
5939
  adapter.seedProfileConfig(codeName);
5826
5940
  }
5827
- const sharedAuthDir = join9(homeDir, ".openclaw", "agents", codeName, "agent");
5828
- const profileAuthDir = join9(profileDir, "agents", codeName, "agent");
5829
- const authFile = join9(sharedAuthDir, "auth-profiles.json");
5941
+ const sharedAuthDir = join10(homeDir, ".openclaw", "agents", codeName, "agent");
5942
+ const profileAuthDir = join10(profileDir, "agents", codeName, "agent");
5943
+ const authFile = join10(sharedAuthDir, "auth-profiles.json");
5830
5944
  if (existsSync5(authFile)) {
5831
5945
  mkdirSync3(profileAuthDir, { recursive: true });
5832
- const authContent = readFileSync9(authFile, "utf-8");
5833
- writeFileSync4(join9(profileAuthDir, "auth-profiles.json"), authContent);
5946
+ const authContent = readFileSync10(authFile, "utf-8");
5947
+ writeFileSync4(join10(profileAuthDir, "auth-profiles.json"), authContent);
5834
5948
  }
5835
5949
  allocatePort(codeName);
5836
5950
  migrated++;
@@ -5868,7 +5982,7 @@ function readGatewayToken(codeName) {
5868
5982
  }
5869
5983
  const homeDir = process.env["HOME"] ?? "/tmp";
5870
5984
  try {
5871
- const cfg = JSON.parse(readFileSync9(join9(homeDir, `.openclaw-${codeName}`, "openclaw.json"), "utf-8"));
5985
+ const cfg = JSON.parse(readFileSync10(join10(homeDir, `.openclaw-${codeName}`, "openclaw.json"), "utf-8"));
5872
5986
  return cfg?.gateway?.auth?.token;
5873
5987
  } catch {
5874
5988
  return void 0;
@@ -5877,10 +5991,10 @@ function readGatewayToken(codeName) {
5877
5991
  var GATEWAY_HUNG_TIMEOUT_MS = 5 * 6e4;
5878
5992
  function isGatewayHung(codeName) {
5879
5993
  const homeDir = process.env["HOME"] ?? "/tmp";
5880
- const jobsPath = join9(homeDir, `.openclaw-${codeName}`, "cron", "jobs.json");
5994
+ const jobsPath = join10(homeDir, `.openclaw-${codeName}`, "cron", "jobs.json");
5881
5995
  if (!existsSync5(jobsPath)) return false;
5882
5996
  try {
5883
- const data = JSON.parse(readFileSync9(jobsPath, "utf-8"));
5997
+ const data = JSON.parse(readFileSync10(jobsPath, "utf-8"));
5884
5998
  const jobs = data.jobs ?? data;
5885
5999
  if (!Array.isArray(jobs)) return false;
5886
6000
  const now = Date.now();
@@ -5913,15 +6027,15 @@ async function ensureGatewayRunning(codeName, adapter) {
5913
6027
  }
5914
6028
  await new Promise((r) => setTimeout(r, 2e3));
5915
6029
  const homeDir = process.env["HOME"] ?? "/tmp";
5916
- const cronJobsPath = join9(homeDir, `.openclaw-${codeName}`, "cron", "jobs.json");
6030
+ const cronJobsPath = join10(homeDir, `.openclaw-${codeName}`, "cron", "jobs.json");
5917
6031
  clearStaleCronRunState(cronJobsPath);
5918
6032
  } else {
5919
6033
  if (status.port) {
5920
6034
  try {
5921
6035
  const homeDir = process.env["HOME"] ?? "/tmp";
5922
- const configPath = join9(homeDir, `.openclaw-${codeName}`, "openclaw.json");
6036
+ const configPath = join10(homeDir, `.openclaw-${codeName}`, "openclaw.json");
5923
6037
  if (existsSync5(configPath)) {
5924
- const cfg = JSON.parse(readFileSync9(configPath, "utf-8"));
6038
+ const cfg = JSON.parse(readFileSync10(configPath, "utf-8"));
5925
6039
  if (cfg.gateway?.port !== status.port) {
5926
6040
  if (!cfg.gateway) cfg.gateway = {};
5927
6041
  cfg.gateway.port = status.port;
@@ -5945,9 +6059,9 @@ async function ensureGatewayRunning(codeName, adapter) {
5945
6059
  gatewaysStartedThisCycle.add(codeName);
5946
6060
  try {
5947
6061
  const homeDir = process.env["HOME"] ?? "/tmp";
5948
- const configPath = join9(homeDir, `.openclaw-${codeName}`, "openclaw.json");
6062
+ const configPath = join10(homeDir, `.openclaw-${codeName}`, "openclaw.json");
5949
6063
  if (existsSync5(configPath)) {
5950
- const cfg = JSON.parse(readFileSync9(configPath, "utf-8"));
6064
+ const cfg = JSON.parse(readFileSync10(configPath, "utf-8"));
5951
6065
  if (!cfg.gateway) cfg.gateway = {};
5952
6066
  cfg.gateway.port = port;
5953
6067
  writeFileSync4(configPath, JSON.stringify(cfg, null, 2));
@@ -6101,7 +6215,7 @@ async function pollCycle() {
6101
6215
  }
6102
6216
  try {
6103
6217
  const { detectHostSecurity } = await import("../host-security-6PDFG7F5.js");
6104
- const { collectDiagnostics } = await import("../persistent-session-W6V2DO3R.js");
6218
+ const { collectDiagnostics } = await import("../persistent-session-7BLPRGWR.js");
6105
6219
  const diagCodeNames = [...agentState.persistentSessionAgents];
6106
6220
  const agentDiagnostics = diagCodeNames.length > 0 ? collectDiagnostics(diagCodeNames) : void 0;
6107
6221
  let tailscaleHostname;
@@ -6195,12 +6309,12 @@ async function pollCycle() {
6195
6309
  const {
6196
6310
  collectResponsivenessProbes,
6197
6311
  getResponsivenessIntervalMs
6198
- } = await import("../responsiveness-probe-LY2H2XR5.js");
6312
+ } = await import("../responsiveness-probe-AL3O7SYZ.js");
6199
6313
  const probeIntervalMs = getResponsivenessIntervalMs();
6200
6314
  if (now - lastResponsivenessProbeAt > probeIntervalMs) {
6201
6315
  const probeCodeNames = [...agentState.persistentSessionAgents];
6202
6316
  if (probeCodeNames.length > 0) {
6203
- const { takeAcpxExecFailureCount, creditAcpxExecFailureCount } = await import("../persistent-session-W6V2DO3R.js");
6317
+ const { takeAcpxExecFailureCount, creditAcpxExecFailureCount } = await import("../persistent-session-7BLPRGWR.js");
6204
6318
  const drainedGiveUps = /* @__PURE__ */ new Map();
6205
6319
  const drainedAcpxFailures = /* @__PURE__ */ new Map();
6206
6320
  const probes = collectResponsivenessProbes(probeCodeNames).map((p) => {
@@ -6234,7 +6348,7 @@ async function pollCycle() {
6234
6348
  collectResponsivenessProbes,
6235
6349
  livePendingInboundOldestAgeSeconds,
6236
6350
  parkPendingInbound
6237
- } = await import("../responsiveness-probe-LY2H2XR5.js");
6351
+ } = await import("../responsiveness-probe-AL3O7SYZ.js");
6238
6352
  const { getProjectDir: wedgeProjectDir } = await import("../claude-scheduler-FATCLHDM.js");
6239
6353
  const wedgeNow = /* @__PURE__ */ new Date();
6240
6354
  const liveAgents = agentState.persistentSessionAgents;
@@ -6491,7 +6605,7 @@ async function pollCycle() {
6491
6605
  }
6492
6606
  killAgentChannelProcesses(prev.codeName, { log });
6493
6607
  freePort(prev.codeName);
6494
- const agentDir = join9(adapter.getAgentDir(prev.codeName), "provision");
6608
+ const agentDir = join10(adapter.getAgentDir(prev.codeName), "provision");
6495
6609
  await cleanupAgentFiles(prev.codeName, agentDir);
6496
6610
  clearAgentCaches(prev.agentId, prev.codeName);
6497
6611
  }
@@ -6577,10 +6691,10 @@ async function pollCycle() {
6577
6691
  // pending-inbound marker. Best-effort: a write failure is logged by
6578
6692
  // the watchdog, never fails the poll cycle.
6579
6693
  signalGiveUp: (codeName) => {
6580
- const dir = join9(homedir5(), ".augmented", codeName);
6694
+ const dir = join10(homedir5(), ".augmented", codeName);
6581
6695
  if (!existsSync5(dir)) return;
6582
6696
  atomicWriteFileSync(
6583
- join9(dir, "watchdog-give-up.json"),
6697
+ join10(dir, "watchdog-give-up.json"),
6584
6698
  JSON.stringify({ gave_up_at: (/* @__PURE__ */ new Date()).toISOString() })
6585
6699
  );
6586
6700
  }
@@ -6682,6 +6796,12 @@ async function processAgent(agent, agentStates) {
6682
6796
  agentId: agent.agent_id,
6683
6797
  log
6684
6798
  });
6799
+ void maybeReconcileWorkflowRunTokens({
6800
+ api,
6801
+ codeName: agent.code_name,
6802
+ agentId: agent.agent_id,
6803
+ log
6804
+ });
6685
6805
  void maybeEvaluateConversations({
6686
6806
  api,
6687
6807
  backend: resolveConversationEvalBackend(),
@@ -6701,7 +6821,7 @@ async function processAgent(agent, agentStates) {
6701
6821
  }
6702
6822
  const now = (/* @__PURE__ */ new Date()).toISOString();
6703
6823
  const adapter = resolveAgentFramework(agent.code_name);
6704
- let agentDir = join9(adapter.getAgentDir(agent.code_name), "provision");
6824
+ let agentDir = join10(adapter.getAgentDir(agent.code_name), "provision");
6705
6825
  if (agent.status === "draft" || agent.status === "paused") {
6706
6826
  if (previousKnownStatus !== agent.status) {
6707
6827
  log(`Agent '${agent.code_name}' is ${agent.status}, skipping provisioning`);
@@ -6905,7 +7025,7 @@ async function processAgent(agent, agentStates) {
6905
7025
  const frameworkId = refreshData.agent.framework ?? "openclaw";
6906
7026
  agentFrameworkCache.set(agent.code_name, frameworkId);
6907
7027
  const frameworkAdapter = getFramework(frameworkId);
6908
- agentDir = join9(frameworkAdapter.getAgentDir(agent.code_name), "provision");
7028
+ agentDir = join10(frameworkAdapter.getAgentDir(agent.code_name), "provision");
6909
7029
  cacheAgentDeliveryMetadata(agent.code_name, refreshData);
6910
7030
  if (frameworkAdapter.migrateSecretStorage && !migratedSecretStorage.has(agent.code_name)) {
6911
7031
  try {
@@ -6948,7 +7068,7 @@ async function processAgent(agent, agentStates) {
6948
7068
  const changedFiles = [];
6949
7069
  mkdirSync3(agentDir, { recursive: true });
6950
7070
  for (const artifact of artifacts) {
6951
- const filePath = join9(agentDir, artifact.relativePath);
7071
+ const filePath = join10(agentDir, artifact.relativePath);
6952
7072
  let existingHash;
6953
7073
  let newHash;
6954
7074
  let writeContent = artifact.content;
@@ -6967,8 +7087,8 @@ async function processAgent(agent, agentStates) {
6967
7087
  };
6968
7088
  newHash = sha256(stripDynamicSections(artifact.content));
6969
7089
  try {
6970
- const projectClaudeMd = join9(config.configDir, agent.code_name, "project", "CLAUDE.md");
6971
- const existing = readFileSync9(projectClaudeMd, "utf-8");
7090
+ const projectClaudeMd = join10(config.configDir, agent.code_name, "project", "CLAUDE.md");
7091
+ const existing = readFileSync10(projectClaudeMd, "utf-8");
6972
7092
  existingHash = sha256(stripDynamicSections(existing));
6973
7093
  } catch {
6974
7094
  existingHash = null;
@@ -6986,7 +7106,7 @@ async function processAgent(agent, agentStates) {
6986
7106
  const generatorKeys = Object.keys(generatorServers);
6987
7107
  let existingRaw = "";
6988
7108
  try {
6989
- existingRaw = readFileSync9(filePath, "utf-8");
7109
+ existingRaw = readFileSync10(filePath, "utf-8");
6990
7110
  } catch {
6991
7111
  }
6992
7112
  const existingServers = parseMcp(existingRaw);
@@ -7008,12 +7128,12 @@ async function processAgent(agent, agentStates) {
7008
7128
  }
7009
7129
  }
7010
7130
  if (changedFiles.length > 0) {
7011
- const isFirst = !existsSync5(join9(agentDir, "CHARTER.md"));
7131
+ const isFirst = !existsSync5(join10(agentDir, "CHARTER.md"));
7012
7132
  const verb = isFirst ? "Provisioning" : "Updating";
7013
7133
  const fileNames = changedFiles.map((f) => f.relativePath).join(", ");
7014
7134
  log(`${verb} '${agent.code_name}': ${fileNames}`);
7015
7135
  for (const file of changedFiles) {
7016
- const filePath = join9(agentDir, file.relativePath);
7136
+ const filePath = join10(agentDir, file.relativePath);
7017
7137
  mkdirSync3(dirname2(filePath), { recursive: true });
7018
7138
  if (file.relativePath === ".mcp.json") {
7019
7139
  safeWriteJsonAtomic(filePath, file.content, { mode: 384 });
@@ -7022,12 +7142,12 @@ async function processAgent(agent, agentStates) {
7022
7142
  }
7023
7143
  }
7024
7144
  try {
7025
- const provSkillsDir = join9(agentDir, ".claude", "skills");
7145
+ const provSkillsDir = join10(agentDir, ".claude", "skills");
7026
7146
  if (existsSync5(provSkillsDir)) {
7027
- for (const folder of readdirSync4(provSkillsDir)) {
7147
+ for (const folder of readdirSync5(provSkillsDir)) {
7028
7148
  if (folder.startsWith("knowledge-")) {
7029
7149
  try {
7030
- rmSync2(join9(provSkillsDir, folder), { recursive: true });
7150
+ rmSync2(join10(provSkillsDir, folder), { recursive: true });
7031
7151
  } catch {
7032
7152
  }
7033
7153
  }
@@ -7040,7 +7160,7 @@ async function processAgent(agent, agentStates) {
7040
7160
  const trackedFiles2 = frameworkAdapter.driftTrackedFiles();
7041
7161
  const hashes = /* @__PURE__ */ new Map();
7042
7162
  for (const file of trackedFiles2) {
7043
- const h = hashFile(join9(agentDir, file));
7163
+ const h = hashFile(join10(agentDir, file));
7044
7164
  if (h) hashes.set(file, h);
7045
7165
  }
7046
7166
  agentState.writtenHashes.set(agent.agent_id, hashes);
@@ -7108,7 +7228,7 @@ async function processAgent(agent, agentStates) {
7108
7228
  if (written && existsSync5(agentDir)) {
7109
7229
  const driftedFiles = [];
7110
7230
  for (const [file, expectedHash] of written) {
7111
- const localHash = hashFile(join9(agentDir, file));
7231
+ const localHash = hashFile(join10(agentDir, file));
7112
7232
  if (localHash && localHash !== expectedHash) {
7113
7233
  driftedFiles.push(file);
7114
7234
  }
@@ -7119,7 +7239,7 @@ async function processAgent(agent, agentStates) {
7119
7239
  try {
7120
7240
  const localHashes = {};
7121
7241
  for (const file of driftedFiles) {
7122
- localHashes[file] = hashFile(join9(agentDir, file));
7242
+ localHashes[file] = hashFile(join10(agentDir, file));
7123
7243
  }
7124
7244
  await api.post("/host/drift", {
7125
7245
  agent_id: agent.agent_id,
@@ -7443,18 +7563,18 @@ async function processAgent(agent, agentStates) {
7443
7563
  if (agentSessionMode === "persistent" && (agentFrameworkCache.get(agent.code_name) ?? "openclaw") === "claude-code") {
7444
7564
  try {
7445
7565
  const agentProvisionDir = agentDir;
7446
- const projectDir = join9(homedir5(), ".augmented", agent.code_name, "project");
7566
+ const projectDir = join10(homedir5(), ".augmented", agent.code_name, "project");
7447
7567
  mkdirSync3(agentProvisionDir, { recursive: true });
7448
7568
  mkdirSync3(projectDir, { recursive: true });
7449
- const provisionMcpPath = join9(agentProvisionDir, ".mcp.json");
7450
- const projectMcpPath = join9(projectDir, ".mcp.json");
7569
+ const provisionMcpPath = join10(agentProvisionDir, ".mcp.json");
7570
+ const projectMcpPath = join10(projectDir, ".mcp.json");
7451
7571
  let mcpConfig = { mcpServers: {} };
7452
7572
  try {
7453
- mcpConfig = JSON.parse(readFileSync9(provisionMcpPath, "utf-8"));
7573
+ mcpConfig = JSON.parse(readFileSync10(provisionMcpPath, "utf-8"));
7454
7574
  if (!mcpConfig.mcpServers) mcpConfig.mcpServers = {};
7455
7575
  } catch {
7456
7576
  }
7457
- const localDirectChatChannel = join9(homedir5(), ".augmented", "_mcp", "direct-chat-channel.js");
7577
+ const localDirectChatChannel = join10(homedir5(), ".augmented", "_mcp", "direct-chat-channel.js");
7458
7578
  const directChatTeamSettings = refreshData.team?.settings;
7459
7579
  const directChatTz = (() => {
7460
7580
  const tz = directChatTeamSettings?.["timezone"];
@@ -7484,7 +7604,7 @@ async function processAgent(agent, agentStates) {
7484
7604
  log(`Channel credentials written for '${agent.code_name}/direct-chat'`);
7485
7605
  }
7486
7606
  }
7487
- const staleChannelsPath = join9(projectDir, ".mcp-channels.json");
7607
+ const staleChannelsPath = join10(projectDir, ".mcp-channels.json");
7488
7608
  if (existsSync5(staleChannelsPath)) {
7489
7609
  try {
7490
7610
  rmSync2(staleChannelsPath, { force: true });
@@ -7549,7 +7669,7 @@ async function processAgent(agent, agentStates) {
7549
7669
  }
7550
7670
  if (process.env.AGT_CONNECTIVITY_PROBE_ENABLED === "true") {
7551
7671
  try {
7552
- const probeProjectDir = join9(homedir5(), ".augmented", agent.code_name, "project");
7672
+ const probeProjectDir = join10(homedir5(), ".augmented", agent.code_name, "project");
7553
7673
  await runAgentConnectivityProbes(agent, integrations, probeProjectDir);
7554
7674
  } catch (err) {
7555
7675
  log(`Connectivity probe failed for '${agent.code_name}': ${err.message}`);
@@ -7567,11 +7687,11 @@ async function processAgent(agent, agentStates) {
7567
7687
  recordConfigChurnEvent(agent.agent_id, agent.code_name, FLAP_CHANNEL_INTEGRATIONS, intMembership);
7568
7688
  }
7569
7689
  if (intHash !== prevIntHash) {
7570
- const projectDir = join9(homedir5(), ".augmented", agent.code_name, "project");
7571
- const envIntPath = join9(projectDir, ".env.integrations");
7690
+ const projectDir = join10(homedir5(), ".augmented", agent.code_name, "project");
7691
+ const envIntPath = join10(projectDir, ".env.integrations");
7572
7692
  let preWriteEnv;
7573
7693
  try {
7574
- preWriteEnv = readFileSync9(envIntPath, "utf-8");
7694
+ preWriteEnv = readFileSync10(envIntPath, "utf-8");
7575
7695
  } catch {
7576
7696
  preWriteEnv = void 0;
7577
7697
  }
@@ -7583,9 +7703,9 @@ async function processAgent(agent, agentStates) {
7583
7703
  let rotationHandled = true;
7584
7704
  if (fw === "claude-code" && isSessionHealthy(agent.code_name)) {
7585
7705
  try {
7586
- const projectMcpPath = join9(projectDir, ".mcp.json");
7587
- const postWriteEnv = readFileSync9(envIntPath, "utf-8");
7588
- const mcpContent = readFileSync9(projectMcpPath, "utf-8");
7706
+ const projectMcpPath = join10(projectDir, ".mcp.json");
7707
+ const postWriteEnv = readFileSync10(envIntPath, "utf-8");
7708
+ const mcpContent = readFileSync10(projectMcpPath, "utf-8");
7589
7709
  const changedVars = diffEnvIntegrations(preWriteEnv, postWriteEnv);
7590
7710
  const mcpJsonForReap = JSON.parse(mcpContent);
7591
7711
  const affectedServerKeys = findMcpServersUsingVars(mcpJsonForReap, changedVars);
@@ -7665,8 +7785,8 @@ async function processAgent(agent, agentStates) {
7665
7785
  const mcpPath = frameworkAdapter.getMcpPath(agent.code_name);
7666
7786
  if (mcpPath) {
7667
7787
  try {
7668
- const { readFileSync: readFileSync10 } = await import("fs");
7669
- const mcpConfig = JSON.parse(readFileSync10(mcpPath, "utf-8"));
7788
+ const { readFileSync: readFileSync11 } = await import("fs");
7789
+ const mcpConfig = JSON.parse(readFileSync11(mcpPath, "utf-8"));
7670
7790
  if (mcpConfig.mcpServers) {
7671
7791
  const managedPrefixes = [
7672
7792
  "composio_",
@@ -7767,7 +7887,7 @@ async function processAgent(agent, agentStates) {
7767
7887
  if (agent.status === "active") {
7768
7888
  if (frameworkAdapter.installPlugin) {
7769
7889
  try {
7770
- const pluginPath = join9(process.cwd(), "packages", "openclaw-plugin-augmented", "src", "index.ts");
7890
+ const pluginPath = join10(process.cwd(), "packages", "openclaw-plugin-augmented", "src", "index.ts");
7771
7891
  if (existsSync5(pluginPath)) {
7772
7892
  frameworkAdapter.installPlugin(agent.code_name, "augmented", pluginPath, {
7773
7893
  agtHost: requireHost(),
@@ -7833,25 +7953,25 @@ async function processAgent(agent, agentStates) {
7833
7953
  }
7834
7954
  }
7835
7955
  try {
7836
- const { readdirSync: readdirSync5, rmSync: rmSync3 } = await import("fs");
7956
+ const { readdirSync: readdirSync6, rmSync: rmSync3 } = await import("fs");
7837
7957
  const { homedir: homedir6 } = await import("os");
7838
7958
  const frameworkId2 = frameworkAdapter.id;
7839
7959
  const candidateSkillDirs = [
7840
7960
  // Claude Code — framework runtime tree
7841
- join9(homedir6(), ".augmented", agent.code_name, "skills"),
7961
+ join10(homedir6(), ".augmented", agent.code_name, "skills"),
7842
7962
  // Claude Code — project tree
7843
- join9(homedir6(), ".augmented", agent.code_name, "project", ".claude", "skills"),
7963
+ join10(homedir6(), ".augmented", agent.code_name, "project", ".claude", "skills"),
7844
7964
  // OpenClaw — framework runtime tree
7845
- join9(homedir6(), `.openclaw-${agent.code_name}`, "skills"),
7965
+ join10(homedir6(), `.openclaw-${agent.code_name}`, "skills"),
7846
7966
  // Defensive: legacy provision-side path, not currently an
7847
7967
  // install target but cheap to sweep.
7848
- join9(agentDir, ".claude", "skills")
7968
+ join10(agentDir, ".claude", "skills")
7849
7969
  ];
7850
7970
  const existingDirs = candidateSkillDirs.filter((d) => existsSync5(d));
7851
7971
  const discoveredEntries = /* @__PURE__ */ new Set();
7852
7972
  for (const dir of existingDirs) {
7853
7973
  try {
7854
- for (const entry of readdirSync5(dir)) {
7974
+ for (const entry of readdirSync6(dir)) {
7855
7975
  if (entry.startsWith("plugin-") || entry.startsWith("integration-")) {
7856
7976
  discoveredEntries.add(entry);
7857
7977
  }
@@ -7861,7 +7981,7 @@ async function processAgent(agent, agentStates) {
7861
7981
  }
7862
7982
  const removeSkillFolder = (entry, reason) => {
7863
7983
  for (const dir of existingDirs) {
7864
- const p = join9(dir, entry);
7984
+ const p = join10(dir, entry);
7865
7985
  if (existsSync5(p)) {
7866
7986
  rmSync3(p, { recursive: true, force: true });
7867
7987
  }
@@ -8041,8 +8161,8 @@ async function processAgent(agent, agentStates) {
8041
8161
  const sess = getSessionState(agent.code_name);
8042
8162
  let mcpJsonParsed = null;
8043
8163
  try {
8044
- const mcpPath = join9(getProjectDir(agent.code_name), ".mcp.json");
8045
- mcpJsonParsed = JSON.parse(readFileSync9(mcpPath, "utf-8"));
8164
+ const mcpPath = join10(getProjectDir(agent.code_name), ".mcp.json");
8165
+ mcpJsonParsed = JSON.parse(readFileSync10(mcpPath, "utf-8"));
8046
8166
  } catch {
8047
8167
  }
8048
8168
  reapMissingMcpSessions({
@@ -8251,10 +8371,10 @@ async function processAgent(agent, agentStates) {
8251
8371
  lastWorkTriggerAt.set(agent.code_name, triggerTs);
8252
8372
  if (agentFw === "openclaw" && gatewayRunning && gatewayPort) {
8253
8373
  const homeDir = process.env["HOME"] ?? "/tmp";
8254
- const jobsPath = join9(homeDir, `.openclaw-${agent.code_name}`, "cron", "jobs.json");
8374
+ const jobsPath = join10(homeDir, `.openclaw-${agent.code_name}`, "cron", "jobs.json");
8255
8375
  if (existsSync5(jobsPath)) {
8256
8376
  try {
8257
- const jobsData = JSON.parse(readFileSync9(jobsPath, "utf-8"));
8377
+ const jobsData = JSON.parse(readFileSync10(jobsPath, "utf-8"));
8258
8378
  const kanbanJob = (jobsData.jobs ?? []).find(
8259
8379
  (j) => typeof j.name === "string" && j.name.includes("kanban-work")
8260
8380
  );
@@ -8391,7 +8511,7 @@ In progress for ${age} minutes \u2014 auto-failed`).catch(() => {
8391
8511
  if (trackedFiles.length > 0 && existsSync5(agentDir)) {
8392
8512
  const hashes = /* @__PURE__ */ new Map();
8393
8513
  for (const file of trackedFiles) {
8394
- const h = hashFile(join9(agentDir, file));
8514
+ const h = hashFile(join10(agentDir, file));
8395
8515
  if (h) hashes.set(file, h);
8396
8516
  }
8397
8517
  agentState.writtenHashes.set(agent.agent_id, hashes);
@@ -8425,19 +8545,19 @@ function cleanupStaleSessions(codeName) {
8425
8545
  lastCleanupAt.set(codeName, Date.now());
8426
8546
  const homeDir = process.env["HOME"] ?? "/tmp";
8427
8547
  for (const agentDir of ["main", codeName]) {
8428
- const sessionsDir = join9(homeDir, `.openclaw-${codeName}`, "agents", agentDir, "sessions");
8548
+ const sessionsDir = join10(homeDir, `.openclaw-${codeName}`, "agents", agentDir, "sessions");
8429
8549
  cleanupCronSessions(sessionsDir, CRON_SESSION_KEEP_COUNT);
8430
8550
  }
8431
- const cronRunsDir = join9(homeDir, `.openclaw-${codeName}`, "cron", "runs");
8551
+ const cronRunsDir = join10(homeDir, `.openclaw-${codeName}`, "cron", "runs");
8432
8552
  cleanupOldFiles(cronRunsDir, CRON_RUN_RETENTION_DAYS, ".jsonl");
8433
- const cronJobsPath = join9(homeDir, `.openclaw-${codeName}`, "cron", "jobs.json");
8553
+ const cronJobsPath = join10(homeDir, `.openclaw-${codeName}`, "cron", "jobs.json");
8434
8554
  clearStaleCronRunState(cronJobsPath);
8435
8555
  }
8436
8556
  function cleanupCronSessions(sessionsDir, keepCount) {
8437
- const indexPath = join9(sessionsDir, "sessions.json");
8557
+ const indexPath = join10(sessionsDir, "sessions.json");
8438
8558
  if (!existsSync5(indexPath)) return;
8439
8559
  try {
8440
- const raw = readFileSync9(indexPath, "utf-8");
8560
+ const raw = readFileSync10(indexPath, "utf-8");
8441
8561
  const index = JSON.parse(raw);
8442
8562
  const cronRunKeys = Object.keys(index).filter((k) => k.includes(":cron:") && k.includes(":run:")).map((k) => ({
8443
8563
  key: k,
@@ -8450,7 +8570,7 @@ function cleanupCronSessions(sessionsDir, keepCount) {
8450
8570
  for (const entry of toDelete) {
8451
8571
  delete index[entry.key];
8452
8572
  if (entry.sessionId) {
8453
- const sessionFile = join9(sessionsDir, `${entry.sessionId}.jsonl`);
8573
+ const sessionFile = join10(sessionsDir, `${entry.sessionId}.jsonl`);
8454
8574
  try {
8455
8575
  if (existsSync5(sessionFile)) {
8456
8576
  unlinkSync(sessionFile);
@@ -8472,7 +8592,7 @@ function cleanupCronSessions(sessionsDir, keepCount) {
8472
8592
  delete index[parentKey];
8473
8593
  if (parentSessionId) {
8474
8594
  try {
8475
- const f = join9(sessionsDir, `${parentSessionId}.jsonl`);
8595
+ const f = join10(sessionsDir, `${parentSessionId}.jsonl`);
8476
8596
  if (existsSync5(f)) {
8477
8597
  unlinkSync(f);
8478
8598
  deletedFiles++;
@@ -8493,7 +8613,7 @@ var STALE_RUN_TIMEOUT_MS = 5 * 6e4;
8493
8613
  function clearStaleCronRunState(jobsPath) {
8494
8614
  if (!existsSync5(jobsPath)) return;
8495
8615
  try {
8496
- const raw = readFileSync9(jobsPath, "utf-8");
8616
+ const raw = readFileSync10(jobsPath, "utf-8");
8497
8617
  const data = JSON.parse(raw);
8498
8618
  const jobs = data.jobs ?? data;
8499
8619
  if (!Array.isArray(jobs)) return;
@@ -8528,11 +8648,11 @@ function cleanupOldFiles(dir, maxAgeDays, ext) {
8528
8648
  const cutoff = Date.now() - maxAgeDays * 24 * 60 * 60 * 1e3;
8529
8649
  let removed = 0;
8530
8650
  try {
8531
- for (const f of readdirSync4(dir)) {
8651
+ for (const f of readdirSync5(dir)) {
8532
8652
  if (!f.endsWith(ext)) continue;
8533
- const fullPath = join9(dir, f);
8653
+ const fullPath = join10(dir, f);
8534
8654
  try {
8535
- const st = statSync3(fullPath);
8655
+ const st = statSync4(fullPath);
8536
8656
  if (st.mtimeMs < cutoff) {
8537
8657
  unlinkSync(fullPath);
8538
8658
  removed++;
@@ -8570,7 +8690,7 @@ var inFlightClaudeTasks = /* @__PURE__ */ new Set();
8570
8690
  var claudeTaskConcurrency = /* @__PURE__ */ new Map();
8571
8691
  var MAX_CLAUDE_CONCURRENCY = 2;
8572
8692
  function claudePidFilePath() {
8573
- return join9(homedir5(), ".augmented", "manager-claude-pids.json");
8693
+ return join10(homedir5(), ".augmented", "manager-claude-pids.json");
8574
8694
  }
8575
8695
  var inFlightClaudePids = /* @__PURE__ */ new Map();
8576
8696
  function registerClaudeSpawn(record) {
@@ -8910,7 +9030,7 @@ async function fireScheduledTaskViaKanban(codeName, agentId, task, prompt) {
8910
9030
  }
8911
9031
  async function executeAndProcessClaudeTask(codeName, agentId, task, prompt) {
8912
9032
  const projectDir = getProjectDir2(codeName);
8913
- const mcpConfigPath = join9(projectDir, ".mcp.json");
9033
+ const mcpConfigPath = join10(projectDir, ".mcp.json");
8914
9034
  let runId = null;
8915
9035
  let kanbanItemId = null;
8916
9036
  let taskResult;
@@ -8918,11 +9038,11 @@ async function executeAndProcessClaudeTask(codeName, agentId, task, prompt) {
8918
9038
  const priorRuns = await fetchPriorScheduledRuns(agentId, task.taskId);
8919
9039
  prompt = wrapScheduledTaskPrompt(prompt, { priorRuns });
8920
9040
  try {
8921
- const claudeMdPath = join9(projectDir, "CLAUDE.md");
9041
+ const claudeMdPath = join10(projectDir, "CLAUDE.md");
8922
9042
  const serverNames = [];
8923
9043
  if (existsSync5(mcpConfigPath)) {
8924
9044
  try {
8925
- const d = JSON.parse(readFileSync9(mcpConfigPath, "utf-8"));
9045
+ const d = JSON.parse(readFileSync10(mcpConfigPath, "utf-8"));
8926
9046
  if (d.mcpServers) serverNames.push(...Object.keys(d.mcpServers));
8927
9047
  } catch {
8928
9048
  }
@@ -8945,10 +9065,10 @@ async function executeAndProcessClaudeTask(codeName, agentId, task, prompt) {
8945
9065
  claudeArgs.push("--system-prompt-file", claudeMdPath);
8946
9066
  }
8947
9067
  const childEnv = { ...process.env };
8948
- const envIntPath = join9(projectDir, ".env.integrations");
9068
+ const envIntPath = join10(projectDir, ".env.integrations");
8949
9069
  if (existsSync5(envIntPath)) {
8950
9070
  try {
8951
- Object.assign(childEnv, parseEnvIntegrations(readFileSync9(envIntPath, "utf-8")));
9071
+ Object.assign(childEnv, parseEnvIntegrations(readFileSync10(envIntPath, "utf-8")));
8952
9072
  } catch {
8953
9073
  }
8954
9074
  }
@@ -9120,8 +9240,8 @@ var claudeAuthTupleBySession = /* @__PURE__ */ new Map();
9120
9240
  async function ensurePersistentSession(agent, tasks, boardItems, refreshData) {
9121
9241
  const codeName = agent.code_name;
9122
9242
  const projectDir = getProjectDir(codeName);
9123
- const mcpConfigPath = join9(projectDir, ".mcp.json");
9124
- const claudeMdPath = join9(projectDir, "CLAUDE.md");
9243
+ const mcpConfigPath = join10(projectDir, ".mcp.json");
9244
+ const claudeMdPath = join10(projectDir, "CLAUDE.md");
9125
9245
  if (restartBreaker.isTripped(codeName)) {
9126
9246
  const trip = restartBreaker.getTrip(codeName);
9127
9247
  return {
@@ -9755,11 +9875,11 @@ ${escapeXml(msg.content)}
9755
9875
  log(`[direct-chat] One-shot spawn for '${agent.codeName}' (msg=${msg.id}; host in-flight=${directChatSpawnGate.hostInFlight}, queued=${directChatSpawnGate.queuedCount})`);
9756
9876
  const { getProjectDir: ccProjectDir } = await import("../claude-scheduler-FATCLHDM.js");
9757
9877
  const projDir = ccProjectDir(agent.codeName);
9758
- const mcpConfigPath = join9(projDir, ".mcp.json");
9878
+ const mcpConfigPath = join10(projDir, ".mcp.json");
9759
9879
  const serverNames = [];
9760
9880
  if (existsSync5(mcpConfigPath)) {
9761
9881
  try {
9762
- const d = JSON.parse(readFileSync9(mcpConfigPath, "utf-8"));
9882
+ const d = JSON.parse(readFileSync10(mcpConfigPath, "utf-8"));
9763
9883
  if (d.mcpServers) serverNames.push(...Object.keys(d.mcpServers));
9764
9884
  } catch {
9765
9885
  }
@@ -9778,15 +9898,15 @@ ${escapeXml(msg.content)}
9778
9898
  "--allowedTools",
9779
9899
  allowedTools
9780
9900
  ];
9781
- const chatClaudeMd = join9(projDir, "CLAUDE.md");
9901
+ const chatClaudeMd = join10(projDir, "CLAUDE.md");
9782
9902
  if (existsSync5(chatClaudeMd)) {
9783
9903
  chatArgs.push("--system-prompt-file", chatClaudeMd);
9784
9904
  }
9785
- const envIntPath = join9(projDir, ".env.integrations");
9905
+ const envIntPath = join10(projDir, ".env.integrations");
9786
9906
  const childEnv = { ...process.env };
9787
9907
  if (existsSync5(envIntPath)) {
9788
9908
  try {
9789
- Object.assign(childEnv, parseEnvIntegrations(readFileSync9(envIntPath, "utf-8")));
9909
+ Object.assign(childEnv, parseEnvIntegrations(readFileSync10(envIntPath, "utf-8")));
9790
9910
  } catch {
9791
9911
  }
9792
9912
  }
@@ -10164,12 +10284,12 @@ function getBuiltInSkillContent(skillId) {
10164
10284
  if (builtInSkillCache.has(skillId)) return builtInSkillCache.get(skillId);
10165
10285
  try {
10166
10286
  const candidates = [
10167
- join9(process.cwd(), "skills", skillId, "SKILL.md"),
10168
- join9(new URL(".", import.meta.url).pathname, "..", "..", "..", "..", "skills", skillId, "SKILL.md")
10287
+ join10(process.cwd(), "skills", skillId, "SKILL.md"),
10288
+ join10(new URL(".", import.meta.url).pathname, "..", "..", "..", "..", "skills", skillId, "SKILL.md")
10169
10289
  ];
10170
10290
  for (const candidate of candidates) {
10171
10291
  if (existsSync5(candidate)) {
10172
- const content = readFileSync9(candidate, "utf-8");
10292
+ const content = readFileSync10(candidate, "utf-8");
10173
10293
  const files = [{ relativePath: "SKILL.md", content }];
10174
10294
  builtInSkillCache.set(skillId, files);
10175
10295
  return files;
@@ -10824,7 +10944,7 @@ async function processClaudePairSessions(agents) {
10824
10944
  killPairSession,
10825
10945
  pairTmuxSession,
10826
10946
  finalizeClaudePairOnboarding
10827
- } = await import("../claude-pair-runtime-G4MYOINJ.js");
10947
+ } = await import("../claude-pair-runtime-ZEFIYDUH.js");
10828
10948
  for (const pairId of pendingResp.cancelled_pair_ids ?? []) {
10829
10949
  log(`[claude-pair] sweeping orphan tmux session for pair ${pairId.slice(0, 8)}`);
10830
10950
  const killed = await killPairSession(pairTmuxSession(pairId));
@@ -11134,8 +11254,8 @@ function parseMemoryFile(raw, fallbackName) {
11134
11254
  };
11135
11255
  }
11136
11256
  async function syncMemories(agent, configDir, log2) {
11137
- const projectDir = join9(configDir, agent.code_name, "project");
11138
- const memoryDir = join9(projectDir, "memory");
11257
+ const projectDir = join10(configDir, agent.code_name, "project");
11258
+ const memoryDir = join10(projectDir, "memory");
11139
11259
  const isFreshSync = pendingFreshMemorySync.has(agent.agent_id);
11140
11260
  if (isFreshSync) {
11141
11261
  log2(`[memory-sync] Fresh-sync requested for '${agent.code_name}' \u2014 pulling DB first`);
@@ -11150,10 +11270,10 @@ async function syncMemories(agent, configDir, log2) {
11150
11270
  const prevHashes = memoryFileHashes.get(agent.agent_id) ?? /* @__PURE__ */ new Map();
11151
11271
  const currentHashes = /* @__PURE__ */ new Map();
11152
11272
  const changedMemories = [];
11153
- for (const file of readdirSync4(memoryDir)) {
11273
+ for (const file of readdirSync5(memoryDir)) {
11154
11274
  if (!file.endsWith(".md")) continue;
11155
11275
  try {
11156
- const raw = readFileSync9(join9(memoryDir, file), "utf-8");
11276
+ const raw = readFileSync10(join10(memoryDir, file), "utf-8");
11157
11277
  const fileHash = createHash3("sha256").update(raw).digest("hex").slice(0, 16);
11158
11278
  currentHashes.set(file, fileHash);
11159
11279
  if (prevHashes.get(file) === fileHash) continue;
@@ -11178,7 +11298,7 @@ async function syncMemories(agent, configDir, log2) {
11178
11298
  } catch (err) {
11179
11299
  for (const mem of changedMemories) {
11180
11300
  for (const [file] of currentHashes) {
11181
- const parsed = parseMemoryFile(readFileSync9(join9(memoryDir, file), "utf-8"), file.replace(/\.md$/, ""));
11301
+ const parsed = parseMemoryFile(readFileSync10(join10(memoryDir, file), "utf-8"), file.replace(/\.md$/, ""));
11182
11302
  if (parsed?.name === mem.name) currentHashes.delete(file);
11183
11303
  }
11184
11304
  }
@@ -11191,7 +11311,7 @@ async function syncMemories(agent, configDir, log2) {
11191
11311
  }
11192
11312
  }
11193
11313
  async function downloadMemories(agent, memoryDir, log2, { force }) {
11194
- const localFiles = existsSync5(memoryDir) ? readdirSync4(memoryDir).filter((f) => f.endsWith(".md")).sort() : [];
11314
+ const localFiles = existsSync5(memoryDir) ? readdirSync5(memoryDir).filter((f) => f.endsWith(".md")).sort() : [];
11195
11315
  const localListHash = createHash3("sha256").update(localFiles.join(",")).digest("hex").slice(0, 16);
11196
11316
  const prevLocalHash = lastLocalFileHash.get(agent.agent_id);
11197
11317
  const prevDownload = lastDownloadHash.get(agent.agent_id);
@@ -11213,7 +11333,7 @@ async function downloadMemories(agent, memoryDir, log2, { force }) {
11213
11333
  const mem = dbMemories.memories[i];
11214
11334
  const rawSlug = mem.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "").slice(0, 60);
11215
11335
  const slug = rawSlug || `memory-${i}`;
11216
- const filePath = join9(memoryDir, `${slug}.md`);
11336
+ const filePath = join10(memoryDir, `${slug}.md`);
11217
11337
  const desired = `---
11218
11338
  name: ${JSON.stringify(mem.name)}
11219
11339
  type: ${mem.type}
@@ -11225,7 +11345,7 @@ ${mem.content}
11225
11345
  if (existsSync5(filePath)) {
11226
11346
  let existing = "";
11227
11347
  try {
11228
- existing = readFileSync9(filePath, "utf-8");
11348
+ existing = readFileSync10(filePath, "utf-8");
11229
11349
  } catch {
11230
11350
  }
11231
11351
  if (existing === desired) continue;
@@ -11237,7 +11357,7 @@ ${mem.content}
11237
11357
  }
11238
11358
  }
11239
11359
  if (written > 0 || overwritten > 0) {
11240
- const updatedFiles = readdirSync4(memoryDir).filter((f) => f.endsWith(".md")).sort();
11360
+ const updatedFiles = readdirSync5(memoryDir).filter((f) => f.endsWith(".md")).sort();
11241
11361
  lastLocalFileHash.set(agent.agent_id, createHash3("sha256").update(updatedFiles.join(",")).digest("hex").slice(0, 16));
11242
11362
  log2(`Memory download for '${agent.code_name}': wrote ${written} new, overwrote ${overwritten} stale`);
11243
11363
  }
@@ -11480,7 +11600,7 @@ function startManager(opts) {
11480
11600
  try {
11481
11601
  const stateFile = getStateFile();
11482
11602
  if (existsSync5(stateFile)) {
11483
- const raw = readFileSync9(stateFile, "utf-8");
11603
+ const raw = readFileSync10(stateFile, "utf-8");
11484
11604
  const parsed = JSON.parse(raw);
11485
11605
  if (Array.isArray(parsed.agents)) {
11486
11606
  state6.agents = parsed.agents;
@@ -11501,7 +11621,7 @@ function startManager(opts) {
11501
11621
  log(`[startup] state rehydration failed (continuing with empty state): ${err.message}`);
11502
11622
  }
11503
11623
  log(
11504
- `[startup] worker pid=${process.pid} ppid=${process.ppid} node=${process.version} log=${join9(homedir5(), ".augmented", "manager.log")}`
11624
+ `[startup] worker pid=${process.pid} ppid=${process.ppid} node=${process.version} log=${join10(homedir5(), ".augmented", "manager.log")}`
11505
11625
  );
11506
11626
  deployMcpAssets();
11507
11627
  reapOrphanChannelMcps({ log });
@@ -11522,7 +11642,7 @@ async function reapOrphanedClaudePids() {
11522
11642
  const looksLikeClaude = (pid) => {
11523
11643
  if (process.platform !== "linux") return true;
11524
11644
  try {
11525
- const comm = readFileSync9(`/proc/${pid}/comm`, "utf-8").trim().toLowerCase();
11645
+ const comm = readFileSync10(`/proc/${pid}/comm`, "utf-8").trim().toLowerCase();
11526
11646
  return comm.includes("claude");
11527
11647
  } catch {
11528
11648
  return false;
@@ -11632,14 +11752,14 @@ function restartRunningChannelMcps(basenames) {
11632
11752
  }
11633
11753
  }
11634
11754
  function deployMcpAssets() {
11635
- const targetDir = join9(homedir5(), ".augmented", "_mcp");
11755
+ const targetDir = join10(homedir5(), ".augmented", "_mcp");
11636
11756
  mkdirSync3(targetDir, { recursive: true });
11637
11757
  const moduleDir = dirname2(fileURLToPath(import.meta.url));
11638
11758
  let mcpSourceDir = "";
11639
11759
  let dir = moduleDir;
11640
11760
  for (let i = 0; i < 6; i++) {
11641
- const candidate = join9(dir, "dist", "mcp");
11642
- if (existsSync5(join9(candidate, "index.js"))) {
11761
+ const candidate = join10(dir, "dist", "mcp");
11762
+ if (existsSync5(join10(candidate, "index.js"))) {
11643
11763
  mcpSourceDir = candidate;
11644
11764
  break;
11645
11765
  }
@@ -11655,7 +11775,7 @@ function deployMcpAssets() {
11655
11775
  const fileHash = (p) => {
11656
11776
  try {
11657
11777
  if (!existsSync5(p)) return null;
11658
- return createHash3("sha256").update(readFileSync9(p)).digest("hex");
11778
+ return createHash3("sha256").update(readFileSync10(p)).digest("hex");
11659
11779
  } catch {
11660
11780
  return null;
11661
11781
  }
@@ -11682,8 +11802,8 @@ function deployMcpAssets() {
11682
11802
  // natural session restart.
11683
11803
  "augmented-admin.js"
11684
11804
  ]) {
11685
- const src = join9(mcpSourceDir, file);
11686
- const dst = join9(targetDir, file);
11805
+ const src = join10(mcpSourceDir, file);
11806
+ const dst = join10(targetDir, file);
11687
11807
  if (!existsSync5(src)) continue;
11688
11808
  const before = fileHash(dst);
11689
11809
  try {
@@ -11701,16 +11821,16 @@ function deployMcpAssets() {
11701
11821
  log(`[manager] Bundle(s) updated: ${changedBasenames.join(", ")} \u2014 signalling running instances to restart`);
11702
11822
  restartRunningChannelMcps(changedBasenames);
11703
11823
  }
11704
- const localMcpPath = join9(targetDir, "index.js");
11824
+ const localMcpPath = join10(targetDir, "index.js");
11705
11825
  try {
11706
- const agentsDir = join9(homedir5(), ".augmented", "agents");
11826
+ const agentsDir = join10(homedir5(), ".augmented", "agents");
11707
11827
  if (existsSync5(agentsDir)) {
11708
- for (const entry of readdirSync4(agentsDir, { withFileTypes: true })) {
11828
+ for (const entry of readdirSync5(agentsDir, { withFileTypes: true })) {
11709
11829
  if (!entry.isDirectory()) continue;
11710
11830
  for (const subdir of ["provision", "project"]) {
11711
- const mcpJsonPath = join9(agentsDir, entry.name, subdir, ".mcp.json");
11831
+ const mcpJsonPath = join10(agentsDir, entry.name, subdir, ".mcp.json");
11712
11832
  try {
11713
- const raw = readFileSync9(mcpJsonPath, "utf-8");
11833
+ const raw = readFileSync10(mcpJsonPath, "utf-8");
11714
11834
  if (!raw.includes("@integrity-labs/augmented-mcp")) continue;
11715
11835
  const mcpConfig = JSON.parse(raw);
11716
11836
  const augServer = mcpConfig.mcpServers?.["augmented"];