@integrity-labs/agt-cli 0.27.161 → 0.27.162

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-H5B4ESA5.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-AEECYKHW.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-LK7R6HLJ.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.162" : "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,7 +5756,7 @@ 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;
@@ -5694,7 +5811,7 @@ function log(msg) {
5694
5811
  `;
5695
5812
  if (!managerLogPath) {
5696
5813
  try {
5697
- managerLogPath = join9(homedir5(), ".augmented", "manager.log");
5814
+ managerLogPath = join10(homedir5(), ".augmented", "manager.log");
5698
5815
  mkdirSync3(dirname2(managerLogPath), { recursive: true });
5699
5816
  if (existsSync5(managerLogPath)) {
5700
5817
  chmodSync(managerLogPath, 384);
@@ -5724,7 +5841,7 @@ function sha256(content) {
5724
5841
  }
5725
5842
  function hashFile(filePath) {
5726
5843
  try {
5727
- const content = readFileSync9(filePath, "utf-8");
5844
+ const content = readFileSync10(filePath, "utf-8");
5728
5845
  return sha256(content);
5729
5846
  } catch {
5730
5847
  return null;
@@ -5748,13 +5865,13 @@ function parseSkillFrontmatter(content) {
5748
5865
  return out;
5749
5866
  }
5750
5867
  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");
5868
+ const { readdirSync: readdirSync6, readFileSync: rfs, existsSync: ex, writeFileSync: writeFileSync5 } = await import("fs");
5869
+ const skillsDir = join10(configDir, codeName, "project", ".claude", "skills");
5870
+ const claudeMdPath = join10(configDir, codeName, "project", "CLAUDE.md");
5754
5871
  if (!ex(skillsDir) || !ex(claudeMdPath)) return;
5755
5872
  const entries = [];
5756
- for (const dir of readdirSync5(skillsDir).sort()) {
5757
- const skillFile = join9(skillsDir, dir, "SKILL.md");
5873
+ for (const dir of readdirSync6(skillsDir).sort()) {
5874
+ const skillFile = join10(skillsDir, dir, "SKILL.md");
5758
5875
  if (!ex(skillFile)) continue;
5759
5876
  try {
5760
5877
  const { name, description } = parseSkillFrontmatter(rfs(skillFile, "utf-8"));
@@ -5802,10 +5919,10 @@ ${SKILLS_INDEX_END}`;
5802
5919
  }
5803
5920
  async function migrateToProfiles() {
5804
5921
  const homeDir = process.env["HOME"] ?? "/tmp";
5805
- const sharedConfigPath = join9(homeDir, ".openclaw", "openclaw.json");
5922
+ const sharedConfigPath = join10(homeDir, ".openclaw", "openclaw.json");
5806
5923
  let sharedConfig;
5807
5924
  try {
5808
- sharedConfig = JSON.parse(readFileSync9(sharedConfigPath, "utf-8"));
5925
+ sharedConfig = JSON.parse(readFileSync10(sharedConfigPath, "utf-8"));
5809
5926
  } catch {
5810
5927
  return;
5811
5928
  }
@@ -5818,19 +5935,19 @@ async function migrateToProfiles() {
5818
5935
  const codeName = agentEntry["id"];
5819
5936
  if (!codeName) continue;
5820
5937
  if (codeName === "main") continue;
5821
- const profileDir = join9(homeDir, `.openclaw-${codeName}`);
5822
- if (existsSync5(join9(profileDir, "openclaw.json"))) continue;
5938
+ const profileDir = join10(homeDir, `.openclaw-${codeName}`);
5939
+ if (existsSync5(join10(profileDir, "openclaw.json"))) continue;
5823
5940
  log(`Migrating agent '${codeName}' to per-agent profile`);
5824
5941
  if (adapter.seedProfileConfig) {
5825
5942
  adapter.seedProfileConfig(codeName);
5826
5943
  }
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");
5944
+ const sharedAuthDir = join10(homeDir, ".openclaw", "agents", codeName, "agent");
5945
+ const profileAuthDir = join10(profileDir, "agents", codeName, "agent");
5946
+ const authFile = join10(sharedAuthDir, "auth-profiles.json");
5830
5947
  if (existsSync5(authFile)) {
5831
5948
  mkdirSync3(profileAuthDir, { recursive: true });
5832
- const authContent = readFileSync9(authFile, "utf-8");
5833
- writeFileSync4(join9(profileAuthDir, "auth-profiles.json"), authContent);
5949
+ const authContent = readFileSync10(authFile, "utf-8");
5950
+ writeFileSync4(join10(profileAuthDir, "auth-profiles.json"), authContent);
5834
5951
  }
5835
5952
  allocatePort(codeName);
5836
5953
  migrated++;
@@ -5868,7 +5985,7 @@ function readGatewayToken(codeName) {
5868
5985
  }
5869
5986
  const homeDir = process.env["HOME"] ?? "/tmp";
5870
5987
  try {
5871
- const cfg = JSON.parse(readFileSync9(join9(homeDir, `.openclaw-${codeName}`, "openclaw.json"), "utf-8"));
5988
+ const cfg = JSON.parse(readFileSync10(join10(homeDir, `.openclaw-${codeName}`, "openclaw.json"), "utf-8"));
5872
5989
  return cfg?.gateway?.auth?.token;
5873
5990
  } catch {
5874
5991
  return void 0;
@@ -5877,10 +5994,10 @@ function readGatewayToken(codeName) {
5877
5994
  var GATEWAY_HUNG_TIMEOUT_MS = 5 * 6e4;
5878
5995
  function isGatewayHung(codeName) {
5879
5996
  const homeDir = process.env["HOME"] ?? "/tmp";
5880
- const jobsPath = join9(homeDir, `.openclaw-${codeName}`, "cron", "jobs.json");
5997
+ const jobsPath = join10(homeDir, `.openclaw-${codeName}`, "cron", "jobs.json");
5881
5998
  if (!existsSync5(jobsPath)) return false;
5882
5999
  try {
5883
- const data = JSON.parse(readFileSync9(jobsPath, "utf-8"));
6000
+ const data = JSON.parse(readFileSync10(jobsPath, "utf-8"));
5884
6001
  const jobs = data.jobs ?? data;
5885
6002
  if (!Array.isArray(jobs)) return false;
5886
6003
  const now = Date.now();
@@ -5913,15 +6030,15 @@ async function ensureGatewayRunning(codeName, adapter) {
5913
6030
  }
5914
6031
  await new Promise((r) => setTimeout(r, 2e3));
5915
6032
  const homeDir = process.env["HOME"] ?? "/tmp";
5916
- const cronJobsPath = join9(homeDir, `.openclaw-${codeName}`, "cron", "jobs.json");
6033
+ const cronJobsPath = join10(homeDir, `.openclaw-${codeName}`, "cron", "jobs.json");
5917
6034
  clearStaleCronRunState(cronJobsPath);
5918
6035
  } else {
5919
6036
  if (status.port) {
5920
6037
  try {
5921
6038
  const homeDir = process.env["HOME"] ?? "/tmp";
5922
- const configPath = join9(homeDir, `.openclaw-${codeName}`, "openclaw.json");
6039
+ const configPath = join10(homeDir, `.openclaw-${codeName}`, "openclaw.json");
5923
6040
  if (existsSync5(configPath)) {
5924
- const cfg = JSON.parse(readFileSync9(configPath, "utf-8"));
6041
+ const cfg = JSON.parse(readFileSync10(configPath, "utf-8"));
5925
6042
  if (cfg.gateway?.port !== status.port) {
5926
6043
  if (!cfg.gateway) cfg.gateway = {};
5927
6044
  cfg.gateway.port = status.port;
@@ -5945,9 +6062,9 @@ async function ensureGatewayRunning(codeName, adapter) {
5945
6062
  gatewaysStartedThisCycle.add(codeName);
5946
6063
  try {
5947
6064
  const homeDir = process.env["HOME"] ?? "/tmp";
5948
- const configPath = join9(homeDir, `.openclaw-${codeName}`, "openclaw.json");
6065
+ const configPath = join10(homeDir, `.openclaw-${codeName}`, "openclaw.json");
5949
6066
  if (existsSync5(configPath)) {
5950
- const cfg = JSON.parse(readFileSync9(configPath, "utf-8"));
6067
+ const cfg = JSON.parse(readFileSync10(configPath, "utf-8"));
5951
6068
  if (!cfg.gateway) cfg.gateway = {};
5952
6069
  cfg.gateway.port = port;
5953
6070
  writeFileSync4(configPath, JSON.stringify(cfg, null, 2));
@@ -6101,7 +6218,7 @@ async function pollCycle() {
6101
6218
  }
6102
6219
  try {
6103
6220
  const { detectHostSecurity } = await import("../host-security-6PDFG7F5.js");
6104
- const { collectDiagnostics } = await import("../persistent-session-W6V2DO3R.js");
6221
+ const { collectDiagnostics } = await import("../persistent-session-WL22MKBS.js");
6105
6222
  const diagCodeNames = [...agentState.persistentSessionAgents];
6106
6223
  const agentDiagnostics = diagCodeNames.length > 0 ? collectDiagnostics(diagCodeNames) : void 0;
6107
6224
  let tailscaleHostname;
@@ -6195,12 +6312,12 @@ async function pollCycle() {
6195
6312
  const {
6196
6313
  collectResponsivenessProbes,
6197
6314
  getResponsivenessIntervalMs
6198
- } = await import("../responsiveness-probe-LY2H2XR5.js");
6315
+ } = await import("../responsiveness-probe-N3Q3O6X7.js");
6199
6316
  const probeIntervalMs = getResponsivenessIntervalMs();
6200
6317
  if (now - lastResponsivenessProbeAt > probeIntervalMs) {
6201
6318
  const probeCodeNames = [...agentState.persistentSessionAgents];
6202
6319
  if (probeCodeNames.length > 0) {
6203
- const { takeAcpxExecFailureCount, creditAcpxExecFailureCount } = await import("../persistent-session-W6V2DO3R.js");
6320
+ const { takeAcpxExecFailureCount, creditAcpxExecFailureCount } = await import("../persistent-session-WL22MKBS.js");
6204
6321
  const drainedGiveUps = /* @__PURE__ */ new Map();
6205
6322
  const drainedAcpxFailures = /* @__PURE__ */ new Map();
6206
6323
  const probes = collectResponsivenessProbes(probeCodeNames).map((p) => {
@@ -6234,7 +6351,7 @@ async function pollCycle() {
6234
6351
  collectResponsivenessProbes,
6235
6352
  livePendingInboundOldestAgeSeconds,
6236
6353
  parkPendingInbound
6237
- } = await import("../responsiveness-probe-LY2H2XR5.js");
6354
+ } = await import("../responsiveness-probe-N3Q3O6X7.js");
6238
6355
  const { getProjectDir: wedgeProjectDir } = await import("../claude-scheduler-FATCLHDM.js");
6239
6356
  const wedgeNow = /* @__PURE__ */ new Date();
6240
6357
  const liveAgents = agentState.persistentSessionAgents;
@@ -6491,7 +6608,7 @@ async function pollCycle() {
6491
6608
  }
6492
6609
  killAgentChannelProcesses(prev.codeName, { log });
6493
6610
  freePort(prev.codeName);
6494
- const agentDir = join9(adapter.getAgentDir(prev.codeName), "provision");
6611
+ const agentDir = join10(adapter.getAgentDir(prev.codeName), "provision");
6495
6612
  await cleanupAgentFiles(prev.codeName, agentDir);
6496
6613
  clearAgentCaches(prev.agentId, prev.codeName);
6497
6614
  }
@@ -6577,10 +6694,10 @@ async function pollCycle() {
6577
6694
  // pending-inbound marker. Best-effort: a write failure is logged by
6578
6695
  // the watchdog, never fails the poll cycle.
6579
6696
  signalGiveUp: (codeName) => {
6580
- const dir = join9(homedir5(), ".augmented", codeName);
6697
+ const dir = join10(homedir5(), ".augmented", codeName);
6581
6698
  if (!existsSync5(dir)) return;
6582
6699
  atomicWriteFileSync(
6583
- join9(dir, "watchdog-give-up.json"),
6700
+ join10(dir, "watchdog-give-up.json"),
6584
6701
  JSON.stringify({ gave_up_at: (/* @__PURE__ */ new Date()).toISOString() })
6585
6702
  );
6586
6703
  }
@@ -6682,6 +6799,12 @@ async function processAgent(agent, agentStates) {
6682
6799
  agentId: agent.agent_id,
6683
6800
  log
6684
6801
  });
6802
+ void maybeReconcileWorkflowRunTokens({
6803
+ api,
6804
+ codeName: agent.code_name,
6805
+ agentId: agent.agent_id,
6806
+ log
6807
+ });
6685
6808
  void maybeEvaluateConversations({
6686
6809
  api,
6687
6810
  backend: resolveConversationEvalBackend(),
@@ -6701,7 +6824,7 @@ async function processAgent(agent, agentStates) {
6701
6824
  }
6702
6825
  const now = (/* @__PURE__ */ new Date()).toISOString();
6703
6826
  const adapter = resolveAgentFramework(agent.code_name);
6704
- let agentDir = join9(adapter.getAgentDir(agent.code_name), "provision");
6827
+ let agentDir = join10(adapter.getAgentDir(agent.code_name), "provision");
6705
6828
  if (agent.status === "draft" || agent.status === "paused") {
6706
6829
  if (previousKnownStatus !== agent.status) {
6707
6830
  log(`Agent '${agent.code_name}' is ${agent.status}, skipping provisioning`);
@@ -6905,7 +7028,7 @@ async function processAgent(agent, agentStates) {
6905
7028
  const frameworkId = refreshData.agent.framework ?? "openclaw";
6906
7029
  agentFrameworkCache.set(agent.code_name, frameworkId);
6907
7030
  const frameworkAdapter = getFramework(frameworkId);
6908
- agentDir = join9(frameworkAdapter.getAgentDir(agent.code_name), "provision");
7031
+ agentDir = join10(frameworkAdapter.getAgentDir(agent.code_name), "provision");
6909
7032
  cacheAgentDeliveryMetadata(agent.code_name, refreshData);
6910
7033
  if (frameworkAdapter.migrateSecretStorage && !migratedSecretStorage.has(agent.code_name)) {
6911
7034
  try {
@@ -6948,7 +7071,7 @@ async function processAgent(agent, agentStates) {
6948
7071
  const changedFiles = [];
6949
7072
  mkdirSync3(agentDir, { recursive: true });
6950
7073
  for (const artifact of artifacts) {
6951
- const filePath = join9(agentDir, artifact.relativePath);
7074
+ const filePath = join10(agentDir, artifact.relativePath);
6952
7075
  let existingHash;
6953
7076
  let newHash;
6954
7077
  let writeContent = artifact.content;
@@ -6967,8 +7090,8 @@ async function processAgent(agent, agentStates) {
6967
7090
  };
6968
7091
  newHash = sha256(stripDynamicSections(artifact.content));
6969
7092
  try {
6970
- const projectClaudeMd = join9(config.configDir, agent.code_name, "project", "CLAUDE.md");
6971
- const existing = readFileSync9(projectClaudeMd, "utf-8");
7093
+ const projectClaudeMd = join10(config.configDir, agent.code_name, "project", "CLAUDE.md");
7094
+ const existing = readFileSync10(projectClaudeMd, "utf-8");
6972
7095
  existingHash = sha256(stripDynamicSections(existing));
6973
7096
  } catch {
6974
7097
  existingHash = null;
@@ -6986,7 +7109,7 @@ async function processAgent(agent, agentStates) {
6986
7109
  const generatorKeys = Object.keys(generatorServers);
6987
7110
  let existingRaw = "";
6988
7111
  try {
6989
- existingRaw = readFileSync9(filePath, "utf-8");
7112
+ existingRaw = readFileSync10(filePath, "utf-8");
6990
7113
  } catch {
6991
7114
  }
6992
7115
  const existingServers = parseMcp(existingRaw);
@@ -7008,12 +7131,12 @@ async function processAgent(agent, agentStates) {
7008
7131
  }
7009
7132
  }
7010
7133
  if (changedFiles.length > 0) {
7011
- const isFirst = !existsSync5(join9(agentDir, "CHARTER.md"));
7134
+ const isFirst = !existsSync5(join10(agentDir, "CHARTER.md"));
7012
7135
  const verb = isFirst ? "Provisioning" : "Updating";
7013
7136
  const fileNames = changedFiles.map((f) => f.relativePath).join(", ");
7014
7137
  log(`${verb} '${agent.code_name}': ${fileNames}`);
7015
7138
  for (const file of changedFiles) {
7016
- const filePath = join9(agentDir, file.relativePath);
7139
+ const filePath = join10(agentDir, file.relativePath);
7017
7140
  mkdirSync3(dirname2(filePath), { recursive: true });
7018
7141
  if (file.relativePath === ".mcp.json") {
7019
7142
  safeWriteJsonAtomic(filePath, file.content, { mode: 384 });
@@ -7022,12 +7145,12 @@ async function processAgent(agent, agentStates) {
7022
7145
  }
7023
7146
  }
7024
7147
  try {
7025
- const provSkillsDir = join9(agentDir, ".claude", "skills");
7148
+ const provSkillsDir = join10(agentDir, ".claude", "skills");
7026
7149
  if (existsSync5(provSkillsDir)) {
7027
- for (const folder of readdirSync4(provSkillsDir)) {
7150
+ for (const folder of readdirSync5(provSkillsDir)) {
7028
7151
  if (folder.startsWith("knowledge-")) {
7029
7152
  try {
7030
- rmSync2(join9(provSkillsDir, folder), { recursive: true });
7153
+ rmSync2(join10(provSkillsDir, folder), { recursive: true });
7031
7154
  } catch {
7032
7155
  }
7033
7156
  }
@@ -7040,7 +7163,7 @@ async function processAgent(agent, agentStates) {
7040
7163
  const trackedFiles2 = frameworkAdapter.driftTrackedFiles();
7041
7164
  const hashes = /* @__PURE__ */ new Map();
7042
7165
  for (const file of trackedFiles2) {
7043
- const h = hashFile(join9(agentDir, file));
7166
+ const h = hashFile(join10(agentDir, file));
7044
7167
  if (h) hashes.set(file, h);
7045
7168
  }
7046
7169
  agentState.writtenHashes.set(agent.agent_id, hashes);
@@ -7108,7 +7231,7 @@ async function processAgent(agent, agentStates) {
7108
7231
  if (written && existsSync5(agentDir)) {
7109
7232
  const driftedFiles = [];
7110
7233
  for (const [file, expectedHash] of written) {
7111
- const localHash = hashFile(join9(agentDir, file));
7234
+ const localHash = hashFile(join10(agentDir, file));
7112
7235
  if (localHash && localHash !== expectedHash) {
7113
7236
  driftedFiles.push(file);
7114
7237
  }
@@ -7119,7 +7242,7 @@ async function processAgent(agent, agentStates) {
7119
7242
  try {
7120
7243
  const localHashes = {};
7121
7244
  for (const file of driftedFiles) {
7122
- localHashes[file] = hashFile(join9(agentDir, file));
7245
+ localHashes[file] = hashFile(join10(agentDir, file));
7123
7246
  }
7124
7247
  await api.post("/host/drift", {
7125
7248
  agent_id: agent.agent_id,
@@ -7443,18 +7566,18 @@ async function processAgent(agent, agentStates) {
7443
7566
  if (agentSessionMode === "persistent" && (agentFrameworkCache.get(agent.code_name) ?? "openclaw") === "claude-code") {
7444
7567
  try {
7445
7568
  const agentProvisionDir = agentDir;
7446
- const projectDir = join9(homedir5(), ".augmented", agent.code_name, "project");
7569
+ const projectDir = join10(homedir5(), ".augmented", agent.code_name, "project");
7447
7570
  mkdirSync3(agentProvisionDir, { recursive: true });
7448
7571
  mkdirSync3(projectDir, { recursive: true });
7449
- const provisionMcpPath = join9(agentProvisionDir, ".mcp.json");
7450
- const projectMcpPath = join9(projectDir, ".mcp.json");
7572
+ const provisionMcpPath = join10(agentProvisionDir, ".mcp.json");
7573
+ const projectMcpPath = join10(projectDir, ".mcp.json");
7451
7574
  let mcpConfig = { mcpServers: {} };
7452
7575
  try {
7453
- mcpConfig = JSON.parse(readFileSync9(provisionMcpPath, "utf-8"));
7576
+ mcpConfig = JSON.parse(readFileSync10(provisionMcpPath, "utf-8"));
7454
7577
  if (!mcpConfig.mcpServers) mcpConfig.mcpServers = {};
7455
7578
  } catch {
7456
7579
  }
7457
- const localDirectChatChannel = join9(homedir5(), ".augmented", "_mcp", "direct-chat-channel.js");
7580
+ const localDirectChatChannel = join10(homedir5(), ".augmented", "_mcp", "direct-chat-channel.js");
7458
7581
  const directChatTeamSettings = refreshData.team?.settings;
7459
7582
  const directChatTz = (() => {
7460
7583
  const tz = directChatTeamSettings?.["timezone"];
@@ -7484,7 +7607,7 @@ async function processAgent(agent, agentStates) {
7484
7607
  log(`Channel credentials written for '${agent.code_name}/direct-chat'`);
7485
7608
  }
7486
7609
  }
7487
- const staleChannelsPath = join9(projectDir, ".mcp-channels.json");
7610
+ const staleChannelsPath = join10(projectDir, ".mcp-channels.json");
7488
7611
  if (existsSync5(staleChannelsPath)) {
7489
7612
  try {
7490
7613
  rmSync2(staleChannelsPath, { force: true });
@@ -7549,7 +7672,7 @@ async function processAgent(agent, agentStates) {
7549
7672
  }
7550
7673
  if (process.env.AGT_CONNECTIVITY_PROBE_ENABLED === "true") {
7551
7674
  try {
7552
- const probeProjectDir = join9(homedir5(), ".augmented", agent.code_name, "project");
7675
+ const probeProjectDir = join10(homedir5(), ".augmented", agent.code_name, "project");
7553
7676
  await runAgentConnectivityProbes(agent, integrations, probeProjectDir);
7554
7677
  } catch (err) {
7555
7678
  log(`Connectivity probe failed for '${agent.code_name}': ${err.message}`);
@@ -7567,11 +7690,11 @@ async function processAgent(agent, agentStates) {
7567
7690
  recordConfigChurnEvent(agent.agent_id, agent.code_name, FLAP_CHANNEL_INTEGRATIONS, intMembership);
7568
7691
  }
7569
7692
  if (intHash !== prevIntHash) {
7570
- const projectDir = join9(homedir5(), ".augmented", agent.code_name, "project");
7571
- const envIntPath = join9(projectDir, ".env.integrations");
7693
+ const projectDir = join10(homedir5(), ".augmented", agent.code_name, "project");
7694
+ const envIntPath = join10(projectDir, ".env.integrations");
7572
7695
  let preWriteEnv;
7573
7696
  try {
7574
- preWriteEnv = readFileSync9(envIntPath, "utf-8");
7697
+ preWriteEnv = readFileSync10(envIntPath, "utf-8");
7575
7698
  } catch {
7576
7699
  preWriteEnv = void 0;
7577
7700
  }
@@ -7583,9 +7706,9 @@ async function processAgent(agent, agentStates) {
7583
7706
  let rotationHandled = true;
7584
7707
  if (fw === "claude-code" && isSessionHealthy(agent.code_name)) {
7585
7708
  try {
7586
- const projectMcpPath = join9(projectDir, ".mcp.json");
7587
- const postWriteEnv = readFileSync9(envIntPath, "utf-8");
7588
- const mcpContent = readFileSync9(projectMcpPath, "utf-8");
7709
+ const projectMcpPath = join10(projectDir, ".mcp.json");
7710
+ const postWriteEnv = readFileSync10(envIntPath, "utf-8");
7711
+ const mcpContent = readFileSync10(projectMcpPath, "utf-8");
7589
7712
  const changedVars = diffEnvIntegrations(preWriteEnv, postWriteEnv);
7590
7713
  const mcpJsonForReap = JSON.parse(mcpContent);
7591
7714
  const affectedServerKeys = findMcpServersUsingVars(mcpJsonForReap, changedVars);
@@ -7665,8 +7788,8 @@ async function processAgent(agent, agentStates) {
7665
7788
  const mcpPath = frameworkAdapter.getMcpPath(agent.code_name);
7666
7789
  if (mcpPath) {
7667
7790
  try {
7668
- const { readFileSync: readFileSync10 } = await import("fs");
7669
- const mcpConfig = JSON.parse(readFileSync10(mcpPath, "utf-8"));
7791
+ const { readFileSync: readFileSync11 } = await import("fs");
7792
+ const mcpConfig = JSON.parse(readFileSync11(mcpPath, "utf-8"));
7670
7793
  if (mcpConfig.mcpServers) {
7671
7794
  const managedPrefixes = [
7672
7795
  "composio_",
@@ -7767,7 +7890,7 @@ async function processAgent(agent, agentStates) {
7767
7890
  if (agent.status === "active") {
7768
7891
  if (frameworkAdapter.installPlugin) {
7769
7892
  try {
7770
- const pluginPath = join9(process.cwd(), "packages", "openclaw-plugin-augmented", "src", "index.ts");
7893
+ const pluginPath = join10(process.cwd(), "packages", "openclaw-plugin-augmented", "src", "index.ts");
7771
7894
  if (existsSync5(pluginPath)) {
7772
7895
  frameworkAdapter.installPlugin(agent.code_name, "augmented", pluginPath, {
7773
7896
  agtHost: requireHost(),
@@ -7833,25 +7956,25 @@ async function processAgent(agent, agentStates) {
7833
7956
  }
7834
7957
  }
7835
7958
  try {
7836
- const { readdirSync: readdirSync5, rmSync: rmSync3 } = await import("fs");
7959
+ const { readdirSync: readdirSync6, rmSync: rmSync3 } = await import("fs");
7837
7960
  const { homedir: homedir6 } = await import("os");
7838
7961
  const frameworkId2 = frameworkAdapter.id;
7839
7962
  const candidateSkillDirs = [
7840
7963
  // Claude Code — framework runtime tree
7841
- join9(homedir6(), ".augmented", agent.code_name, "skills"),
7964
+ join10(homedir6(), ".augmented", agent.code_name, "skills"),
7842
7965
  // Claude Code — project tree
7843
- join9(homedir6(), ".augmented", agent.code_name, "project", ".claude", "skills"),
7966
+ join10(homedir6(), ".augmented", agent.code_name, "project", ".claude", "skills"),
7844
7967
  // OpenClaw — framework runtime tree
7845
- join9(homedir6(), `.openclaw-${agent.code_name}`, "skills"),
7968
+ join10(homedir6(), `.openclaw-${agent.code_name}`, "skills"),
7846
7969
  // Defensive: legacy provision-side path, not currently an
7847
7970
  // install target but cheap to sweep.
7848
- join9(agentDir, ".claude", "skills")
7971
+ join10(agentDir, ".claude", "skills")
7849
7972
  ];
7850
7973
  const existingDirs = candidateSkillDirs.filter((d) => existsSync5(d));
7851
7974
  const discoveredEntries = /* @__PURE__ */ new Set();
7852
7975
  for (const dir of existingDirs) {
7853
7976
  try {
7854
- for (const entry of readdirSync5(dir)) {
7977
+ for (const entry of readdirSync6(dir)) {
7855
7978
  if (entry.startsWith("plugin-") || entry.startsWith("integration-")) {
7856
7979
  discoveredEntries.add(entry);
7857
7980
  }
@@ -7861,7 +7984,7 @@ async function processAgent(agent, agentStates) {
7861
7984
  }
7862
7985
  const removeSkillFolder = (entry, reason) => {
7863
7986
  for (const dir of existingDirs) {
7864
- const p = join9(dir, entry);
7987
+ const p = join10(dir, entry);
7865
7988
  if (existsSync5(p)) {
7866
7989
  rmSync3(p, { recursive: true, force: true });
7867
7990
  }
@@ -8041,8 +8164,8 @@ async function processAgent(agent, agentStates) {
8041
8164
  const sess = getSessionState(agent.code_name);
8042
8165
  let mcpJsonParsed = null;
8043
8166
  try {
8044
- const mcpPath = join9(getProjectDir(agent.code_name), ".mcp.json");
8045
- mcpJsonParsed = JSON.parse(readFileSync9(mcpPath, "utf-8"));
8167
+ const mcpPath = join10(getProjectDir(agent.code_name), ".mcp.json");
8168
+ mcpJsonParsed = JSON.parse(readFileSync10(mcpPath, "utf-8"));
8046
8169
  } catch {
8047
8170
  }
8048
8171
  reapMissingMcpSessions({
@@ -8251,10 +8374,10 @@ async function processAgent(agent, agentStates) {
8251
8374
  lastWorkTriggerAt.set(agent.code_name, triggerTs);
8252
8375
  if (agentFw === "openclaw" && gatewayRunning && gatewayPort) {
8253
8376
  const homeDir = process.env["HOME"] ?? "/tmp";
8254
- const jobsPath = join9(homeDir, `.openclaw-${agent.code_name}`, "cron", "jobs.json");
8377
+ const jobsPath = join10(homeDir, `.openclaw-${agent.code_name}`, "cron", "jobs.json");
8255
8378
  if (existsSync5(jobsPath)) {
8256
8379
  try {
8257
- const jobsData = JSON.parse(readFileSync9(jobsPath, "utf-8"));
8380
+ const jobsData = JSON.parse(readFileSync10(jobsPath, "utf-8"));
8258
8381
  const kanbanJob = (jobsData.jobs ?? []).find(
8259
8382
  (j) => typeof j.name === "string" && j.name.includes("kanban-work")
8260
8383
  );
@@ -8391,7 +8514,7 @@ In progress for ${age} minutes \u2014 auto-failed`).catch(() => {
8391
8514
  if (trackedFiles.length > 0 && existsSync5(agentDir)) {
8392
8515
  const hashes = /* @__PURE__ */ new Map();
8393
8516
  for (const file of trackedFiles) {
8394
- const h = hashFile(join9(agentDir, file));
8517
+ const h = hashFile(join10(agentDir, file));
8395
8518
  if (h) hashes.set(file, h);
8396
8519
  }
8397
8520
  agentState.writtenHashes.set(agent.agent_id, hashes);
@@ -8425,19 +8548,19 @@ function cleanupStaleSessions(codeName) {
8425
8548
  lastCleanupAt.set(codeName, Date.now());
8426
8549
  const homeDir = process.env["HOME"] ?? "/tmp";
8427
8550
  for (const agentDir of ["main", codeName]) {
8428
- const sessionsDir = join9(homeDir, `.openclaw-${codeName}`, "agents", agentDir, "sessions");
8551
+ const sessionsDir = join10(homeDir, `.openclaw-${codeName}`, "agents", agentDir, "sessions");
8429
8552
  cleanupCronSessions(sessionsDir, CRON_SESSION_KEEP_COUNT);
8430
8553
  }
8431
- const cronRunsDir = join9(homeDir, `.openclaw-${codeName}`, "cron", "runs");
8554
+ const cronRunsDir = join10(homeDir, `.openclaw-${codeName}`, "cron", "runs");
8432
8555
  cleanupOldFiles(cronRunsDir, CRON_RUN_RETENTION_DAYS, ".jsonl");
8433
- const cronJobsPath = join9(homeDir, `.openclaw-${codeName}`, "cron", "jobs.json");
8556
+ const cronJobsPath = join10(homeDir, `.openclaw-${codeName}`, "cron", "jobs.json");
8434
8557
  clearStaleCronRunState(cronJobsPath);
8435
8558
  }
8436
8559
  function cleanupCronSessions(sessionsDir, keepCount) {
8437
- const indexPath = join9(sessionsDir, "sessions.json");
8560
+ const indexPath = join10(sessionsDir, "sessions.json");
8438
8561
  if (!existsSync5(indexPath)) return;
8439
8562
  try {
8440
- const raw = readFileSync9(indexPath, "utf-8");
8563
+ const raw = readFileSync10(indexPath, "utf-8");
8441
8564
  const index = JSON.parse(raw);
8442
8565
  const cronRunKeys = Object.keys(index).filter((k) => k.includes(":cron:") && k.includes(":run:")).map((k) => ({
8443
8566
  key: k,
@@ -8450,7 +8573,7 @@ function cleanupCronSessions(sessionsDir, keepCount) {
8450
8573
  for (const entry of toDelete) {
8451
8574
  delete index[entry.key];
8452
8575
  if (entry.sessionId) {
8453
- const sessionFile = join9(sessionsDir, `${entry.sessionId}.jsonl`);
8576
+ const sessionFile = join10(sessionsDir, `${entry.sessionId}.jsonl`);
8454
8577
  try {
8455
8578
  if (existsSync5(sessionFile)) {
8456
8579
  unlinkSync(sessionFile);
@@ -8472,7 +8595,7 @@ function cleanupCronSessions(sessionsDir, keepCount) {
8472
8595
  delete index[parentKey];
8473
8596
  if (parentSessionId) {
8474
8597
  try {
8475
- const f = join9(sessionsDir, `${parentSessionId}.jsonl`);
8598
+ const f = join10(sessionsDir, `${parentSessionId}.jsonl`);
8476
8599
  if (existsSync5(f)) {
8477
8600
  unlinkSync(f);
8478
8601
  deletedFiles++;
@@ -8493,7 +8616,7 @@ var STALE_RUN_TIMEOUT_MS = 5 * 6e4;
8493
8616
  function clearStaleCronRunState(jobsPath) {
8494
8617
  if (!existsSync5(jobsPath)) return;
8495
8618
  try {
8496
- const raw = readFileSync9(jobsPath, "utf-8");
8619
+ const raw = readFileSync10(jobsPath, "utf-8");
8497
8620
  const data = JSON.parse(raw);
8498
8621
  const jobs = data.jobs ?? data;
8499
8622
  if (!Array.isArray(jobs)) return;
@@ -8528,11 +8651,11 @@ function cleanupOldFiles(dir, maxAgeDays, ext) {
8528
8651
  const cutoff = Date.now() - maxAgeDays * 24 * 60 * 60 * 1e3;
8529
8652
  let removed = 0;
8530
8653
  try {
8531
- for (const f of readdirSync4(dir)) {
8654
+ for (const f of readdirSync5(dir)) {
8532
8655
  if (!f.endsWith(ext)) continue;
8533
- const fullPath = join9(dir, f);
8656
+ const fullPath = join10(dir, f);
8534
8657
  try {
8535
- const st = statSync3(fullPath);
8658
+ const st = statSync4(fullPath);
8536
8659
  if (st.mtimeMs < cutoff) {
8537
8660
  unlinkSync(fullPath);
8538
8661
  removed++;
@@ -8570,7 +8693,7 @@ var inFlightClaudeTasks = /* @__PURE__ */ new Set();
8570
8693
  var claudeTaskConcurrency = /* @__PURE__ */ new Map();
8571
8694
  var MAX_CLAUDE_CONCURRENCY = 2;
8572
8695
  function claudePidFilePath() {
8573
- return join9(homedir5(), ".augmented", "manager-claude-pids.json");
8696
+ return join10(homedir5(), ".augmented", "manager-claude-pids.json");
8574
8697
  }
8575
8698
  var inFlightClaudePids = /* @__PURE__ */ new Map();
8576
8699
  function registerClaudeSpawn(record) {
@@ -8910,7 +9033,7 @@ async function fireScheduledTaskViaKanban(codeName, agentId, task, prompt) {
8910
9033
  }
8911
9034
  async function executeAndProcessClaudeTask(codeName, agentId, task, prompt) {
8912
9035
  const projectDir = getProjectDir2(codeName);
8913
- const mcpConfigPath = join9(projectDir, ".mcp.json");
9036
+ const mcpConfigPath = join10(projectDir, ".mcp.json");
8914
9037
  let runId = null;
8915
9038
  let kanbanItemId = null;
8916
9039
  let taskResult;
@@ -8918,11 +9041,11 @@ async function executeAndProcessClaudeTask(codeName, agentId, task, prompt) {
8918
9041
  const priorRuns = await fetchPriorScheduledRuns(agentId, task.taskId);
8919
9042
  prompt = wrapScheduledTaskPrompt(prompt, { priorRuns });
8920
9043
  try {
8921
- const claudeMdPath = join9(projectDir, "CLAUDE.md");
9044
+ const claudeMdPath = join10(projectDir, "CLAUDE.md");
8922
9045
  const serverNames = [];
8923
9046
  if (existsSync5(mcpConfigPath)) {
8924
9047
  try {
8925
- const d = JSON.parse(readFileSync9(mcpConfigPath, "utf-8"));
9048
+ const d = JSON.parse(readFileSync10(mcpConfigPath, "utf-8"));
8926
9049
  if (d.mcpServers) serverNames.push(...Object.keys(d.mcpServers));
8927
9050
  } catch {
8928
9051
  }
@@ -8945,10 +9068,10 @@ async function executeAndProcessClaudeTask(codeName, agentId, task, prompt) {
8945
9068
  claudeArgs.push("--system-prompt-file", claudeMdPath);
8946
9069
  }
8947
9070
  const childEnv = { ...process.env };
8948
- const envIntPath = join9(projectDir, ".env.integrations");
9071
+ const envIntPath = join10(projectDir, ".env.integrations");
8949
9072
  if (existsSync5(envIntPath)) {
8950
9073
  try {
8951
- Object.assign(childEnv, parseEnvIntegrations(readFileSync9(envIntPath, "utf-8")));
9074
+ Object.assign(childEnv, parseEnvIntegrations(readFileSync10(envIntPath, "utf-8")));
8952
9075
  } catch {
8953
9076
  }
8954
9077
  }
@@ -9120,8 +9243,8 @@ var claudeAuthTupleBySession = /* @__PURE__ */ new Map();
9120
9243
  async function ensurePersistentSession(agent, tasks, boardItems, refreshData) {
9121
9244
  const codeName = agent.code_name;
9122
9245
  const projectDir = getProjectDir(codeName);
9123
- const mcpConfigPath = join9(projectDir, ".mcp.json");
9124
- const claudeMdPath = join9(projectDir, "CLAUDE.md");
9246
+ const mcpConfigPath = join10(projectDir, ".mcp.json");
9247
+ const claudeMdPath = join10(projectDir, "CLAUDE.md");
9125
9248
  if (restartBreaker.isTripped(codeName)) {
9126
9249
  const trip = restartBreaker.getTrip(codeName);
9127
9250
  return {
@@ -9755,11 +9878,11 @@ ${escapeXml(msg.content)}
9755
9878
  log(`[direct-chat] One-shot spawn for '${agent.codeName}' (msg=${msg.id}; host in-flight=${directChatSpawnGate.hostInFlight}, queued=${directChatSpawnGate.queuedCount})`);
9756
9879
  const { getProjectDir: ccProjectDir } = await import("../claude-scheduler-FATCLHDM.js");
9757
9880
  const projDir = ccProjectDir(agent.codeName);
9758
- const mcpConfigPath = join9(projDir, ".mcp.json");
9881
+ const mcpConfigPath = join10(projDir, ".mcp.json");
9759
9882
  const serverNames = [];
9760
9883
  if (existsSync5(mcpConfigPath)) {
9761
9884
  try {
9762
- const d = JSON.parse(readFileSync9(mcpConfigPath, "utf-8"));
9885
+ const d = JSON.parse(readFileSync10(mcpConfigPath, "utf-8"));
9763
9886
  if (d.mcpServers) serverNames.push(...Object.keys(d.mcpServers));
9764
9887
  } catch {
9765
9888
  }
@@ -9778,15 +9901,15 @@ ${escapeXml(msg.content)}
9778
9901
  "--allowedTools",
9779
9902
  allowedTools
9780
9903
  ];
9781
- const chatClaudeMd = join9(projDir, "CLAUDE.md");
9904
+ const chatClaudeMd = join10(projDir, "CLAUDE.md");
9782
9905
  if (existsSync5(chatClaudeMd)) {
9783
9906
  chatArgs.push("--system-prompt-file", chatClaudeMd);
9784
9907
  }
9785
- const envIntPath = join9(projDir, ".env.integrations");
9908
+ const envIntPath = join10(projDir, ".env.integrations");
9786
9909
  const childEnv = { ...process.env };
9787
9910
  if (existsSync5(envIntPath)) {
9788
9911
  try {
9789
- Object.assign(childEnv, parseEnvIntegrations(readFileSync9(envIntPath, "utf-8")));
9912
+ Object.assign(childEnv, parseEnvIntegrations(readFileSync10(envIntPath, "utf-8")));
9790
9913
  } catch {
9791
9914
  }
9792
9915
  }
@@ -10164,12 +10287,12 @@ function getBuiltInSkillContent(skillId) {
10164
10287
  if (builtInSkillCache.has(skillId)) return builtInSkillCache.get(skillId);
10165
10288
  try {
10166
10289
  const candidates = [
10167
- join9(process.cwd(), "skills", skillId, "SKILL.md"),
10168
- join9(new URL(".", import.meta.url).pathname, "..", "..", "..", "..", "skills", skillId, "SKILL.md")
10290
+ join10(process.cwd(), "skills", skillId, "SKILL.md"),
10291
+ join10(new URL(".", import.meta.url).pathname, "..", "..", "..", "..", "skills", skillId, "SKILL.md")
10169
10292
  ];
10170
10293
  for (const candidate of candidates) {
10171
10294
  if (existsSync5(candidate)) {
10172
- const content = readFileSync9(candidate, "utf-8");
10295
+ const content = readFileSync10(candidate, "utf-8");
10173
10296
  const files = [{ relativePath: "SKILL.md", content }];
10174
10297
  builtInSkillCache.set(skillId, files);
10175
10298
  return files;
@@ -10824,7 +10947,7 @@ async function processClaudePairSessions(agents) {
10824
10947
  killPairSession,
10825
10948
  pairTmuxSession,
10826
10949
  finalizeClaudePairOnboarding
10827
- } = await import("../claude-pair-runtime-G4MYOINJ.js");
10950
+ } = await import("../claude-pair-runtime-TZOAZFBQ.js");
10828
10951
  for (const pairId of pendingResp.cancelled_pair_ids ?? []) {
10829
10952
  log(`[claude-pair] sweeping orphan tmux session for pair ${pairId.slice(0, 8)}`);
10830
10953
  const killed = await killPairSession(pairTmuxSession(pairId));
@@ -11134,8 +11257,8 @@ function parseMemoryFile(raw, fallbackName) {
11134
11257
  };
11135
11258
  }
11136
11259
  async function syncMemories(agent, configDir, log2) {
11137
- const projectDir = join9(configDir, agent.code_name, "project");
11138
- const memoryDir = join9(projectDir, "memory");
11260
+ const projectDir = join10(configDir, agent.code_name, "project");
11261
+ const memoryDir = join10(projectDir, "memory");
11139
11262
  const isFreshSync = pendingFreshMemorySync.has(agent.agent_id);
11140
11263
  if (isFreshSync) {
11141
11264
  log2(`[memory-sync] Fresh-sync requested for '${agent.code_name}' \u2014 pulling DB first`);
@@ -11150,10 +11273,10 @@ async function syncMemories(agent, configDir, log2) {
11150
11273
  const prevHashes = memoryFileHashes.get(agent.agent_id) ?? /* @__PURE__ */ new Map();
11151
11274
  const currentHashes = /* @__PURE__ */ new Map();
11152
11275
  const changedMemories = [];
11153
- for (const file of readdirSync4(memoryDir)) {
11276
+ for (const file of readdirSync5(memoryDir)) {
11154
11277
  if (!file.endsWith(".md")) continue;
11155
11278
  try {
11156
- const raw = readFileSync9(join9(memoryDir, file), "utf-8");
11279
+ const raw = readFileSync10(join10(memoryDir, file), "utf-8");
11157
11280
  const fileHash = createHash3("sha256").update(raw).digest("hex").slice(0, 16);
11158
11281
  currentHashes.set(file, fileHash);
11159
11282
  if (prevHashes.get(file) === fileHash) continue;
@@ -11178,7 +11301,7 @@ async function syncMemories(agent, configDir, log2) {
11178
11301
  } catch (err) {
11179
11302
  for (const mem of changedMemories) {
11180
11303
  for (const [file] of currentHashes) {
11181
- const parsed = parseMemoryFile(readFileSync9(join9(memoryDir, file), "utf-8"), file.replace(/\.md$/, ""));
11304
+ const parsed = parseMemoryFile(readFileSync10(join10(memoryDir, file), "utf-8"), file.replace(/\.md$/, ""));
11182
11305
  if (parsed?.name === mem.name) currentHashes.delete(file);
11183
11306
  }
11184
11307
  }
@@ -11191,7 +11314,7 @@ async function syncMemories(agent, configDir, log2) {
11191
11314
  }
11192
11315
  }
11193
11316
  async function downloadMemories(agent, memoryDir, log2, { force }) {
11194
- const localFiles = existsSync5(memoryDir) ? readdirSync4(memoryDir).filter((f) => f.endsWith(".md")).sort() : [];
11317
+ const localFiles = existsSync5(memoryDir) ? readdirSync5(memoryDir).filter((f) => f.endsWith(".md")).sort() : [];
11195
11318
  const localListHash = createHash3("sha256").update(localFiles.join(",")).digest("hex").slice(0, 16);
11196
11319
  const prevLocalHash = lastLocalFileHash.get(agent.agent_id);
11197
11320
  const prevDownload = lastDownloadHash.get(agent.agent_id);
@@ -11213,7 +11336,7 @@ async function downloadMemories(agent, memoryDir, log2, { force }) {
11213
11336
  const mem = dbMemories.memories[i];
11214
11337
  const rawSlug = mem.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "").slice(0, 60);
11215
11338
  const slug = rawSlug || `memory-${i}`;
11216
- const filePath = join9(memoryDir, `${slug}.md`);
11339
+ const filePath = join10(memoryDir, `${slug}.md`);
11217
11340
  const desired = `---
11218
11341
  name: ${JSON.stringify(mem.name)}
11219
11342
  type: ${mem.type}
@@ -11225,7 +11348,7 @@ ${mem.content}
11225
11348
  if (existsSync5(filePath)) {
11226
11349
  let existing = "";
11227
11350
  try {
11228
- existing = readFileSync9(filePath, "utf-8");
11351
+ existing = readFileSync10(filePath, "utf-8");
11229
11352
  } catch {
11230
11353
  }
11231
11354
  if (existing === desired) continue;
@@ -11237,7 +11360,7 @@ ${mem.content}
11237
11360
  }
11238
11361
  }
11239
11362
  if (written > 0 || overwritten > 0) {
11240
- const updatedFiles = readdirSync4(memoryDir).filter((f) => f.endsWith(".md")).sort();
11363
+ const updatedFiles = readdirSync5(memoryDir).filter((f) => f.endsWith(".md")).sort();
11241
11364
  lastLocalFileHash.set(agent.agent_id, createHash3("sha256").update(updatedFiles.join(",")).digest("hex").slice(0, 16));
11242
11365
  log2(`Memory download for '${agent.code_name}': wrote ${written} new, overwrote ${overwritten} stale`);
11243
11366
  }
@@ -11480,7 +11603,7 @@ function startManager(opts) {
11480
11603
  try {
11481
11604
  const stateFile = getStateFile();
11482
11605
  if (existsSync5(stateFile)) {
11483
- const raw = readFileSync9(stateFile, "utf-8");
11606
+ const raw = readFileSync10(stateFile, "utf-8");
11484
11607
  const parsed = JSON.parse(raw);
11485
11608
  if (Array.isArray(parsed.agents)) {
11486
11609
  state6.agents = parsed.agents;
@@ -11501,7 +11624,7 @@ function startManager(opts) {
11501
11624
  log(`[startup] state rehydration failed (continuing with empty state): ${err.message}`);
11502
11625
  }
11503
11626
  log(
11504
- `[startup] worker pid=${process.pid} ppid=${process.ppid} node=${process.version} log=${join9(homedir5(), ".augmented", "manager.log")}`
11627
+ `[startup] worker pid=${process.pid} ppid=${process.ppid} node=${process.version} log=${join10(homedir5(), ".augmented", "manager.log")}`
11505
11628
  );
11506
11629
  deployMcpAssets();
11507
11630
  reapOrphanChannelMcps({ log });
@@ -11522,7 +11645,7 @@ async function reapOrphanedClaudePids() {
11522
11645
  const looksLikeClaude = (pid) => {
11523
11646
  if (process.platform !== "linux") return true;
11524
11647
  try {
11525
- const comm = readFileSync9(`/proc/${pid}/comm`, "utf-8").trim().toLowerCase();
11648
+ const comm = readFileSync10(`/proc/${pid}/comm`, "utf-8").trim().toLowerCase();
11526
11649
  return comm.includes("claude");
11527
11650
  } catch {
11528
11651
  return false;
@@ -11632,14 +11755,14 @@ function restartRunningChannelMcps(basenames) {
11632
11755
  }
11633
11756
  }
11634
11757
  function deployMcpAssets() {
11635
- const targetDir = join9(homedir5(), ".augmented", "_mcp");
11758
+ const targetDir = join10(homedir5(), ".augmented", "_mcp");
11636
11759
  mkdirSync3(targetDir, { recursive: true });
11637
11760
  const moduleDir = dirname2(fileURLToPath(import.meta.url));
11638
11761
  let mcpSourceDir = "";
11639
11762
  let dir = moduleDir;
11640
11763
  for (let i = 0; i < 6; i++) {
11641
- const candidate = join9(dir, "dist", "mcp");
11642
- if (existsSync5(join9(candidate, "index.js"))) {
11764
+ const candidate = join10(dir, "dist", "mcp");
11765
+ if (existsSync5(join10(candidate, "index.js"))) {
11643
11766
  mcpSourceDir = candidate;
11644
11767
  break;
11645
11768
  }
@@ -11655,7 +11778,7 @@ function deployMcpAssets() {
11655
11778
  const fileHash = (p) => {
11656
11779
  try {
11657
11780
  if (!existsSync5(p)) return null;
11658
- return createHash3("sha256").update(readFileSync9(p)).digest("hex");
11781
+ return createHash3("sha256").update(readFileSync10(p)).digest("hex");
11659
11782
  } catch {
11660
11783
  return null;
11661
11784
  }
@@ -11682,8 +11805,8 @@ function deployMcpAssets() {
11682
11805
  // natural session restart.
11683
11806
  "augmented-admin.js"
11684
11807
  ]) {
11685
- const src = join9(mcpSourceDir, file);
11686
- const dst = join9(targetDir, file);
11808
+ const src = join10(mcpSourceDir, file);
11809
+ const dst = join10(targetDir, file);
11687
11810
  if (!existsSync5(src)) continue;
11688
11811
  const before = fileHash(dst);
11689
11812
  try {
@@ -11701,16 +11824,16 @@ function deployMcpAssets() {
11701
11824
  log(`[manager] Bundle(s) updated: ${changedBasenames.join(", ")} \u2014 signalling running instances to restart`);
11702
11825
  restartRunningChannelMcps(changedBasenames);
11703
11826
  }
11704
- const localMcpPath = join9(targetDir, "index.js");
11827
+ const localMcpPath = join10(targetDir, "index.js");
11705
11828
  try {
11706
- const agentsDir = join9(homedir5(), ".augmented", "agents");
11829
+ const agentsDir = join10(homedir5(), ".augmented", "agents");
11707
11830
  if (existsSync5(agentsDir)) {
11708
- for (const entry of readdirSync4(agentsDir, { withFileTypes: true })) {
11831
+ for (const entry of readdirSync5(agentsDir, { withFileTypes: true })) {
11709
11832
  if (!entry.isDirectory()) continue;
11710
11833
  for (const subdir of ["provision", "project"]) {
11711
- const mcpJsonPath = join9(agentsDir, entry.name, subdir, ".mcp.json");
11834
+ const mcpJsonPath = join10(agentsDir, entry.name, subdir, ".mcp.json");
11712
11835
  try {
11713
- const raw = readFileSync9(mcpJsonPath, "utf-8");
11836
+ const raw = readFileSync10(mcpJsonPath, "utf-8");
11714
11837
  if (!raw.includes("@integrity-labs/augmented-mcp")) continue;
11715
11838
  const mcpConfig = JSON.parse(raw);
11716
11839
  const augServer = mcpConfig.mcpServers?.["augmented"];