@integrity-labs/agt-cli 0.27.160 → 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-O24XVAYZ.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;
@@ -4367,6 +4484,7 @@ var AUTO_RESUME_SELF_WINDOW_MS = 12e4;
4367
4484
  var autoResumeLoggedSkips = /* @__PURE__ */ new Map();
4368
4485
  var autoResumeStandDowns = /* @__PURE__ */ new Set();
4369
4486
  var killPausedCodeNames = /* @__PURE__ */ new Set();
4487
+ var BACK_ONLINE_GREETING_GUIDANCE = " When you reconnect, if you tell anyone you are back, start that message with a \u{1F44B} wave emoji and do not use a \u{1F7E2} green-light emoji.";
4370
4488
  function maybeAutoResume(agent) {
4371
4489
  const codeName = agent.code_name;
4372
4490
  if (autoResumeInFlight.has(codeName)) return;
@@ -4539,7 +4657,7 @@ function inboundAgeSecondsFor(codeName) {
4539
4657
  }
4540
4658
  function paneLogAgeSecondsFor(codeName) {
4541
4659
  try {
4542
- const mtimeMs = statSync3(paneLogPath(codeName)).mtimeMs;
4660
+ const mtimeMs = statSync4(paneLogPath(codeName)).mtimeMs;
4543
4661
  return Math.max(0, Math.floor((Date.now() - mtimeMs) / 1e3));
4544
4662
  } catch (err) {
4545
4663
  if (err?.code === "ENOENT") return null;
@@ -4565,7 +4683,7 @@ var runningMcpServerKeys = /* @__PURE__ */ new Map();
4565
4683
  var runningChannelSecretHashes = /* @__PURE__ */ new Map();
4566
4684
  function projectMcpHash(_codeName, projectDir) {
4567
4685
  try {
4568
- const raw = readFileSync9(join9(projectDir, ".mcp.json"), "utf-8");
4686
+ const raw = readFileSync10(join10(projectDir, ".mcp.json"), "utf-8");
4569
4687
  return createHash3("sha256").update(canonicalJson(JSON.parse(raw))).digest("hex");
4570
4688
  } catch {
4571
4689
  return null;
@@ -4573,7 +4691,7 @@ function projectMcpHash(_codeName, projectDir) {
4573
4691
  }
4574
4692
  function projectMcpKeys(_codeName, projectDir) {
4575
4693
  try {
4576
- const raw = readFileSync9(join9(projectDir, ".mcp.json"), "utf-8");
4694
+ const raw = readFileSync10(join10(projectDir, ".mcp.json"), "utf-8");
4577
4695
  const parsed = JSON.parse(raw);
4578
4696
  const servers = parsed.mcpServers;
4579
4697
  if (!servers || typeof servers !== "object") return /* @__PURE__ */ new Set();
@@ -4584,7 +4702,7 @@ function projectMcpKeys(_codeName, projectDir) {
4584
4702
  }
4585
4703
  function readMcpHttpServerConfig(projectDir, serverKey, env) {
4586
4704
  try {
4587
- const raw = readFileSync9(join9(projectDir, ".mcp.json"), "utf-8");
4705
+ const raw = readFileSync10(join10(projectDir, ".mcp.json"), "utf-8");
4588
4706
  const servers = JSON.parse(raw).mcpServers ?? {};
4589
4707
  const entry = servers[serverKey];
4590
4708
  if (entry && typeof entry.url === "string" && (entry.type === "http" || entry.type === void 0)) {
@@ -4612,9 +4730,9 @@ async function runAgentConnectivityProbes(agent, integrations, projectDir) {
4612
4730
  if (integrations.length === 0) return;
4613
4731
  const probeEnv = { ...process.env };
4614
4732
  try {
4615
- const envIntPath = join9(projectDir, ".env.integrations");
4733
+ const envIntPath = join10(projectDir, ".env.integrations");
4616
4734
  if (existsSync5(envIntPath)) {
4617
- Object.assign(probeEnv, parseEnvIntegrations(readFileSync9(envIntPath, "utf-8")));
4735
+ Object.assign(probeEnv, parseEnvIntegrations(readFileSync10(envIntPath, "utf-8")));
4618
4736
  }
4619
4737
  } catch {
4620
4738
  }
@@ -4802,7 +4920,7 @@ function checkMcpConfigDriftAndScheduleRestart(codeName, projectDir) {
4802
4920
  function projectChannelSecretHash(projectDir) {
4803
4921
  try {
4804
4922
  const entries = parseEnvIntegrations(
4805
- readFileSync9(join9(projectDir, ".env.integrations"), "utf-8")
4923
+ readFileSync10(join10(projectDir, ".env.integrations"), "utf-8")
4806
4924
  );
4807
4925
  return channelSecretValueHash(entries, CHANNEL_SECRET_ENV_KEYS);
4808
4926
  } catch {
@@ -4894,7 +5012,7 @@ var cachedMaintenanceWindow = null;
4894
5012
  var lastVersionCheckAt = 0;
4895
5013
  var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
4896
5014
  var lastResponsivenessProbeAt = 0;
4897
- var agtCliVersion = true ? "0.27.160" : "dev";
5015
+ var agtCliVersion = true ? "0.27.162" : "dev";
4898
5016
  function resolveBrewPath(execFileSync4) {
4899
5017
  try {
4900
5018
  const out = execFileSync4("which", ["brew"], { timeout: 5e3 }).toString().trim();
@@ -5071,7 +5189,7 @@ function ensureClaudeManagedSettings(path = claudeManagedSettingsPath()) {
5071
5189
  try {
5072
5190
  let settings = {};
5073
5191
  if (existsSync5(path)) {
5074
- const raw = readFileSync9(path, "utf-8").trim();
5192
+ const raw = readFileSync10(path, "utf-8").trim();
5075
5193
  if (raw) {
5076
5194
  let parsed;
5077
5195
  try {
@@ -5145,7 +5263,7 @@ async function ensureFrameworkBinary(frameworkId) {
5145
5263
  var CLAUDE_CODE_UPGRADE_CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
5146
5264
  var claudeCodeUpgradeInFlight = false;
5147
5265
  function claudeCodeUpgradeMarkerPath() {
5148
- return join9(homedir5(), ".augmented", ".last-claude-code-upgrade-check");
5266
+ return join10(homedir5(), ".augmented", ".last-claude-code-upgrade-check");
5149
5267
  }
5150
5268
  function stampClaudeCodeUpgradeMarker() {
5151
5269
  try {
@@ -5155,7 +5273,7 @@ function stampClaudeCodeUpgradeMarker() {
5155
5273
  }
5156
5274
  function claudeCodeUpgradeThrottled() {
5157
5275
  try {
5158
- const lastCheck = parseInt(readFileSync9(claudeCodeUpgradeMarkerPath(), "utf-8").trim(), 10);
5276
+ const lastCheck = parseInt(readFileSync10(claudeCodeUpgradeMarkerPath(), "utf-8").trim(), 10);
5159
5277
  if (!Number.isFinite(lastCheck)) return false;
5160
5278
  return Date.now() - lastCheck < CLAUDE_CODE_UPGRADE_CHECK_INTERVAL_MS;
5161
5279
  } catch {
@@ -5208,7 +5326,7 @@ ${r.stderr}`;
5208
5326
  }
5209
5327
  var UPDATE_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
5210
5328
  function selfUpdateAppliedMarkerPath() {
5211
- return join9(homedir5(), ".augmented", ".last-self-update-applied");
5329
+ return join10(homedir5(), ".augmented", ".last-self-update-applied");
5212
5330
  }
5213
5331
  var selfUpdateUpToDateLogged = false;
5214
5332
  var restartAfterUpgrade = false;
@@ -5231,7 +5349,7 @@ async function checkAndUpdateCli() {
5231
5349
  const isNpmGlobal = !isBrewFormula && resolvedPath.includes("node_modules");
5232
5350
  if (!isBrewFormula && !isNpmGlobal) return;
5233
5351
  const { readFileSync: readF, writeFileSync: writeF } = await import("fs");
5234
- const markerPath = join9(homedir5(), ".augmented", ".last-update-check");
5352
+ const markerPath = join10(homedir5(), ".augmented", ".last-update-check");
5235
5353
  try {
5236
5354
  const lastCheck = parseInt(readF(markerPath, "utf-8").trim(), 10);
5237
5355
  if (Date.now() - lastCheck < UPDATE_CHECK_INTERVAL_MS) return;
@@ -5488,9 +5606,9 @@ async function applyClaudeAuthToEnv(childEnv, label) {
5488
5606
  throw new Error("claude_auth_mode=api_key but /host/exchange returned no decrypted key");
5489
5607
  }
5490
5608
  childEnv.ANTHROPIC_API_KEY = exchange.anthropicApiKey;
5491
- const claudeDir = join9(homedir5(), ".claude");
5609
+ const claudeDir = join10(homedir5(), ".claude");
5492
5610
  for (const filename of [".credentials.json", "credentials.json"]) {
5493
- const p = join9(claudeDir, filename);
5611
+ const p = join10(claudeDir, filename);
5494
5612
  if (existsSync5(p)) {
5495
5613
  try {
5496
5614
  rmSync2(p, { force: true });
@@ -5506,12 +5624,12 @@ async function applyClaudeAuthToEnv(childEnv, label) {
5506
5624
  var evalEmptyMcpConfigPath = null;
5507
5625
  function ensureEvalEmptyMcpConfig() {
5508
5626
  if (evalEmptyMcpConfigPath && existsSync5(evalEmptyMcpConfigPath)) return evalEmptyMcpConfigPath;
5509
- const dir = join9(homedir5(), ".augmented");
5627
+ const dir = join10(homedir5(), ".augmented");
5510
5628
  try {
5511
5629
  mkdirSync3(dir, { recursive: true });
5512
5630
  } catch {
5513
5631
  }
5514
- const p = join9(dir, ".eval-empty-mcp.json");
5632
+ const p = join10(dir, ".eval-empty-mcp.json");
5515
5633
  writeFileSync4(p, JSON.stringify({ mcpServers: {} }));
5516
5634
  evalEmptyMcpConfigPath = p;
5517
5635
  return p;
@@ -5586,7 +5704,7 @@ function resolveConversationEvalBackend() {
5586
5704
  }
5587
5705
  function loadGatewayPorts() {
5588
5706
  try {
5589
- return JSON.parse(readFileSync9(GATEWAY_PORTS_FILE, "utf-8"));
5707
+ return JSON.parse(readFileSync10(GATEWAY_PORTS_FILE, "utf-8"));
5590
5708
  } catch {
5591
5709
  return {};
5592
5710
  }
@@ -5616,10 +5734,10 @@ function freePort(codeName) {
5616
5734
  }
5617
5735
  }
5618
5736
  function getStateFile() {
5619
- 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");
5620
5738
  }
5621
5739
  function channelHashCacheDir() {
5622
- return config?.configDir ?? join9(process.env["HOME"] ?? "/tmp", ".augmented");
5740
+ return config?.configDir ?? join10(process.env["HOME"] ?? "/tmp", ".augmented");
5623
5741
  }
5624
5742
  function loadChannelHashCache2() {
5625
5743
  loadChannelHashCache(agentState.knownChannelConfigHashes, channelHashCacheDir());
@@ -5630,7 +5748,7 @@ function saveChannelHashCache2() {
5630
5748
  var _channelQuarantineStore = null;
5631
5749
  function channelQuarantineStore() {
5632
5750
  if (!_channelQuarantineStore) {
5633
- const dir = config?.configDir ?? join9(process.env["HOME"] ?? "/tmp", ".augmented");
5751
+ const dir = config?.configDir ?? join10(process.env["HOME"] ?? "/tmp", ".augmented");
5634
5752
  _channelQuarantineStore = new ChannelQuarantineStore(defaultQuarantinePath(dir));
5635
5753
  }
5636
5754
  return _channelQuarantineStore;
@@ -5638,7 +5756,7 @@ function channelQuarantineStore() {
5638
5756
  var _hostFlagStore = null;
5639
5757
  function hostFlagStore() {
5640
5758
  if (!_hostFlagStore) {
5641
- const dir = config?.configDir ?? join9(process.env["HOME"] ?? "/tmp", ".augmented");
5759
+ const dir = config?.configDir ?? join10(process.env["HOME"] ?? "/tmp", ".augmented");
5642
5760
  _hostFlagStore = new HostFlagStore({ cachePath: defaultFlagsCachePath(dir), log });
5643
5761
  }
5644
5762
  return _hostFlagStore;
@@ -5693,7 +5811,7 @@ function log(msg) {
5693
5811
  `;
5694
5812
  if (!managerLogPath) {
5695
5813
  try {
5696
- managerLogPath = join9(homedir5(), ".augmented", "manager.log");
5814
+ managerLogPath = join10(homedir5(), ".augmented", "manager.log");
5697
5815
  mkdirSync3(dirname2(managerLogPath), { recursive: true });
5698
5816
  if (existsSync5(managerLogPath)) {
5699
5817
  chmodSync(managerLogPath, 384);
@@ -5723,7 +5841,7 @@ function sha256(content) {
5723
5841
  }
5724
5842
  function hashFile(filePath) {
5725
5843
  try {
5726
- const content = readFileSync9(filePath, "utf-8");
5844
+ const content = readFileSync10(filePath, "utf-8");
5727
5845
  return sha256(content);
5728
5846
  } catch {
5729
5847
  return null;
@@ -5747,13 +5865,13 @@ function parseSkillFrontmatter(content) {
5747
5865
  return out;
5748
5866
  }
5749
5867
  async function refreshSkillsIndexInClaudeMd(configDir, codeName, log2) {
5750
- const { readdirSync: readdirSync5, readFileSync: rfs, existsSync: ex, writeFileSync: writeFileSync5 } = await import("fs");
5751
- const skillsDir = join9(configDir, codeName, "project", ".claude", "skills");
5752
- 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");
5753
5871
  if (!ex(skillsDir) || !ex(claudeMdPath)) return;
5754
5872
  const entries = [];
5755
- for (const dir of readdirSync5(skillsDir).sort()) {
5756
- const skillFile = join9(skillsDir, dir, "SKILL.md");
5873
+ for (const dir of readdirSync6(skillsDir).sort()) {
5874
+ const skillFile = join10(skillsDir, dir, "SKILL.md");
5757
5875
  if (!ex(skillFile)) continue;
5758
5876
  try {
5759
5877
  const { name, description } = parseSkillFrontmatter(rfs(skillFile, "utf-8"));
@@ -5801,10 +5919,10 @@ ${SKILLS_INDEX_END}`;
5801
5919
  }
5802
5920
  async function migrateToProfiles() {
5803
5921
  const homeDir = process.env["HOME"] ?? "/tmp";
5804
- const sharedConfigPath = join9(homeDir, ".openclaw", "openclaw.json");
5922
+ const sharedConfigPath = join10(homeDir, ".openclaw", "openclaw.json");
5805
5923
  let sharedConfig;
5806
5924
  try {
5807
- sharedConfig = JSON.parse(readFileSync9(sharedConfigPath, "utf-8"));
5925
+ sharedConfig = JSON.parse(readFileSync10(sharedConfigPath, "utf-8"));
5808
5926
  } catch {
5809
5927
  return;
5810
5928
  }
@@ -5817,19 +5935,19 @@ async function migrateToProfiles() {
5817
5935
  const codeName = agentEntry["id"];
5818
5936
  if (!codeName) continue;
5819
5937
  if (codeName === "main") continue;
5820
- const profileDir = join9(homeDir, `.openclaw-${codeName}`);
5821
- if (existsSync5(join9(profileDir, "openclaw.json"))) continue;
5938
+ const profileDir = join10(homeDir, `.openclaw-${codeName}`);
5939
+ if (existsSync5(join10(profileDir, "openclaw.json"))) continue;
5822
5940
  log(`Migrating agent '${codeName}' to per-agent profile`);
5823
5941
  if (adapter.seedProfileConfig) {
5824
5942
  adapter.seedProfileConfig(codeName);
5825
5943
  }
5826
- const sharedAuthDir = join9(homeDir, ".openclaw", "agents", codeName, "agent");
5827
- const profileAuthDir = join9(profileDir, "agents", codeName, "agent");
5828
- 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");
5829
5947
  if (existsSync5(authFile)) {
5830
5948
  mkdirSync3(profileAuthDir, { recursive: true });
5831
- const authContent = readFileSync9(authFile, "utf-8");
5832
- writeFileSync4(join9(profileAuthDir, "auth-profiles.json"), authContent);
5949
+ const authContent = readFileSync10(authFile, "utf-8");
5950
+ writeFileSync4(join10(profileAuthDir, "auth-profiles.json"), authContent);
5833
5951
  }
5834
5952
  allocatePort(codeName);
5835
5953
  migrated++;
@@ -5867,7 +5985,7 @@ function readGatewayToken(codeName) {
5867
5985
  }
5868
5986
  const homeDir = process.env["HOME"] ?? "/tmp";
5869
5987
  try {
5870
- 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"));
5871
5989
  return cfg?.gateway?.auth?.token;
5872
5990
  } catch {
5873
5991
  return void 0;
@@ -5876,10 +5994,10 @@ function readGatewayToken(codeName) {
5876
5994
  var GATEWAY_HUNG_TIMEOUT_MS = 5 * 6e4;
5877
5995
  function isGatewayHung(codeName) {
5878
5996
  const homeDir = process.env["HOME"] ?? "/tmp";
5879
- const jobsPath = join9(homeDir, `.openclaw-${codeName}`, "cron", "jobs.json");
5997
+ const jobsPath = join10(homeDir, `.openclaw-${codeName}`, "cron", "jobs.json");
5880
5998
  if (!existsSync5(jobsPath)) return false;
5881
5999
  try {
5882
- const data = JSON.parse(readFileSync9(jobsPath, "utf-8"));
6000
+ const data = JSON.parse(readFileSync10(jobsPath, "utf-8"));
5883
6001
  const jobs = data.jobs ?? data;
5884
6002
  if (!Array.isArray(jobs)) return false;
5885
6003
  const now = Date.now();
@@ -5912,15 +6030,15 @@ async function ensureGatewayRunning(codeName, adapter) {
5912
6030
  }
5913
6031
  await new Promise((r) => setTimeout(r, 2e3));
5914
6032
  const homeDir = process.env["HOME"] ?? "/tmp";
5915
- const cronJobsPath = join9(homeDir, `.openclaw-${codeName}`, "cron", "jobs.json");
6033
+ const cronJobsPath = join10(homeDir, `.openclaw-${codeName}`, "cron", "jobs.json");
5916
6034
  clearStaleCronRunState(cronJobsPath);
5917
6035
  } else {
5918
6036
  if (status.port) {
5919
6037
  try {
5920
6038
  const homeDir = process.env["HOME"] ?? "/tmp";
5921
- const configPath = join9(homeDir, `.openclaw-${codeName}`, "openclaw.json");
6039
+ const configPath = join10(homeDir, `.openclaw-${codeName}`, "openclaw.json");
5922
6040
  if (existsSync5(configPath)) {
5923
- const cfg = JSON.parse(readFileSync9(configPath, "utf-8"));
6041
+ const cfg = JSON.parse(readFileSync10(configPath, "utf-8"));
5924
6042
  if (cfg.gateway?.port !== status.port) {
5925
6043
  if (!cfg.gateway) cfg.gateway = {};
5926
6044
  cfg.gateway.port = status.port;
@@ -5944,9 +6062,9 @@ async function ensureGatewayRunning(codeName, adapter) {
5944
6062
  gatewaysStartedThisCycle.add(codeName);
5945
6063
  try {
5946
6064
  const homeDir = process.env["HOME"] ?? "/tmp";
5947
- const configPath = join9(homeDir, `.openclaw-${codeName}`, "openclaw.json");
6065
+ const configPath = join10(homeDir, `.openclaw-${codeName}`, "openclaw.json");
5948
6066
  if (existsSync5(configPath)) {
5949
- const cfg = JSON.parse(readFileSync9(configPath, "utf-8"));
6067
+ const cfg = JSON.parse(readFileSync10(configPath, "utf-8"));
5950
6068
  if (!cfg.gateway) cfg.gateway = {};
5951
6069
  cfg.gateway.port = port;
5952
6070
  writeFileSync4(configPath, JSON.stringify(cfg, null, 2));
@@ -6100,7 +6218,7 @@ async function pollCycle() {
6100
6218
  }
6101
6219
  try {
6102
6220
  const { detectHostSecurity } = await import("../host-security-6PDFG7F5.js");
6103
- const { collectDiagnostics } = await import("../persistent-session-W6V2DO3R.js");
6221
+ const { collectDiagnostics } = await import("../persistent-session-WL22MKBS.js");
6104
6222
  const diagCodeNames = [...agentState.persistentSessionAgents];
6105
6223
  const agentDiagnostics = diagCodeNames.length > 0 ? collectDiagnostics(diagCodeNames) : void 0;
6106
6224
  let tailscaleHostname;
@@ -6194,12 +6312,12 @@ async function pollCycle() {
6194
6312
  const {
6195
6313
  collectResponsivenessProbes,
6196
6314
  getResponsivenessIntervalMs
6197
- } = await import("../responsiveness-probe-LY2H2XR5.js");
6315
+ } = await import("../responsiveness-probe-N3Q3O6X7.js");
6198
6316
  const probeIntervalMs = getResponsivenessIntervalMs();
6199
6317
  if (now - lastResponsivenessProbeAt > probeIntervalMs) {
6200
6318
  const probeCodeNames = [...agentState.persistentSessionAgents];
6201
6319
  if (probeCodeNames.length > 0) {
6202
- const { takeAcpxExecFailureCount, creditAcpxExecFailureCount } = await import("../persistent-session-W6V2DO3R.js");
6320
+ const { takeAcpxExecFailureCount, creditAcpxExecFailureCount } = await import("../persistent-session-WL22MKBS.js");
6203
6321
  const drainedGiveUps = /* @__PURE__ */ new Map();
6204
6322
  const drainedAcpxFailures = /* @__PURE__ */ new Map();
6205
6323
  const probes = collectResponsivenessProbes(probeCodeNames).map((p) => {
@@ -6233,7 +6351,7 @@ async function pollCycle() {
6233
6351
  collectResponsivenessProbes,
6234
6352
  livePendingInboundOldestAgeSeconds,
6235
6353
  parkPendingInbound
6236
- } = await import("../responsiveness-probe-LY2H2XR5.js");
6354
+ } = await import("../responsiveness-probe-N3Q3O6X7.js");
6237
6355
  const { getProjectDir: wedgeProjectDir } = await import("../claude-scheduler-FATCLHDM.js");
6238
6356
  const wedgeNow = /* @__PURE__ */ new Date();
6239
6357
  const liveAgents = agentState.persistentSessionAgents;
@@ -6490,7 +6608,7 @@ async function pollCycle() {
6490
6608
  }
6491
6609
  killAgentChannelProcesses(prev.codeName, { log });
6492
6610
  freePort(prev.codeName);
6493
- const agentDir = join9(adapter.getAgentDir(prev.codeName), "provision");
6611
+ const agentDir = join10(adapter.getAgentDir(prev.codeName), "provision");
6494
6612
  await cleanupAgentFiles(prev.codeName, agentDir);
6495
6613
  clearAgentCaches(prev.agentId, prev.codeName);
6496
6614
  }
@@ -6576,10 +6694,10 @@ async function pollCycle() {
6576
6694
  // pending-inbound marker. Best-effort: a write failure is logged by
6577
6695
  // the watchdog, never fails the poll cycle.
6578
6696
  signalGiveUp: (codeName) => {
6579
- const dir = join9(homedir5(), ".augmented", codeName);
6697
+ const dir = join10(homedir5(), ".augmented", codeName);
6580
6698
  if (!existsSync5(dir)) return;
6581
6699
  atomicWriteFileSync(
6582
- join9(dir, "watchdog-give-up.json"),
6700
+ join10(dir, "watchdog-give-up.json"),
6583
6701
  JSON.stringify({ gave_up_at: (/* @__PURE__ */ new Date()).toISOString() })
6584
6702
  );
6585
6703
  }
@@ -6681,6 +6799,12 @@ async function processAgent(agent, agentStates) {
6681
6799
  agentId: agent.agent_id,
6682
6800
  log
6683
6801
  });
6802
+ void maybeReconcileWorkflowRunTokens({
6803
+ api,
6804
+ codeName: agent.code_name,
6805
+ agentId: agent.agent_id,
6806
+ log
6807
+ });
6684
6808
  void maybeEvaluateConversations({
6685
6809
  api,
6686
6810
  backend: resolveConversationEvalBackend(),
@@ -6700,7 +6824,7 @@ async function processAgent(agent, agentStates) {
6700
6824
  }
6701
6825
  const now = (/* @__PURE__ */ new Date()).toISOString();
6702
6826
  const adapter = resolveAgentFramework(agent.code_name);
6703
- let agentDir = join9(adapter.getAgentDir(agent.code_name), "provision");
6827
+ let agentDir = join10(adapter.getAgentDir(agent.code_name), "provision");
6704
6828
  if (agent.status === "draft" || agent.status === "paused") {
6705
6829
  if (previousKnownStatus !== agent.status) {
6706
6830
  log(`Agent '${agent.code_name}' is ${agent.status}, skipping provisioning`);
@@ -6904,7 +7028,7 @@ async function processAgent(agent, agentStates) {
6904
7028
  const frameworkId = refreshData.agent.framework ?? "openclaw";
6905
7029
  agentFrameworkCache.set(agent.code_name, frameworkId);
6906
7030
  const frameworkAdapter = getFramework(frameworkId);
6907
- agentDir = join9(frameworkAdapter.getAgentDir(agent.code_name), "provision");
7031
+ agentDir = join10(frameworkAdapter.getAgentDir(agent.code_name), "provision");
6908
7032
  cacheAgentDeliveryMetadata(agent.code_name, refreshData);
6909
7033
  if (frameworkAdapter.migrateSecretStorage && !migratedSecretStorage.has(agent.code_name)) {
6910
7034
  try {
@@ -6947,7 +7071,7 @@ async function processAgent(agent, agentStates) {
6947
7071
  const changedFiles = [];
6948
7072
  mkdirSync3(agentDir, { recursive: true });
6949
7073
  for (const artifact of artifacts) {
6950
- const filePath = join9(agentDir, artifact.relativePath);
7074
+ const filePath = join10(agentDir, artifact.relativePath);
6951
7075
  let existingHash;
6952
7076
  let newHash;
6953
7077
  let writeContent = artifact.content;
@@ -6966,8 +7090,8 @@ async function processAgent(agent, agentStates) {
6966
7090
  };
6967
7091
  newHash = sha256(stripDynamicSections(artifact.content));
6968
7092
  try {
6969
- const projectClaudeMd = join9(config.configDir, agent.code_name, "project", "CLAUDE.md");
6970
- 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");
6971
7095
  existingHash = sha256(stripDynamicSections(existing));
6972
7096
  } catch {
6973
7097
  existingHash = null;
@@ -6985,7 +7109,7 @@ async function processAgent(agent, agentStates) {
6985
7109
  const generatorKeys = Object.keys(generatorServers);
6986
7110
  let existingRaw = "";
6987
7111
  try {
6988
- existingRaw = readFileSync9(filePath, "utf-8");
7112
+ existingRaw = readFileSync10(filePath, "utf-8");
6989
7113
  } catch {
6990
7114
  }
6991
7115
  const existingServers = parseMcp(existingRaw);
@@ -7007,12 +7131,12 @@ async function processAgent(agent, agentStates) {
7007
7131
  }
7008
7132
  }
7009
7133
  if (changedFiles.length > 0) {
7010
- const isFirst = !existsSync5(join9(agentDir, "CHARTER.md"));
7134
+ const isFirst = !existsSync5(join10(agentDir, "CHARTER.md"));
7011
7135
  const verb = isFirst ? "Provisioning" : "Updating";
7012
7136
  const fileNames = changedFiles.map((f) => f.relativePath).join(", ");
7013
7137
  log(`${verb} '${agent.code_name}': ${fileNames}`);
7014
7138
  for (const file of changedFiles) {
7015
- const filePath = join9(agentDir, file.relativePath);
7139
+ const filePath = join10(agentDir, file.relativePath);
7016
7140
  mkdirSync3(dirname2(filePath), { recursive: true });
7017
7141
  if (file.relativePath === ".mcp.json") {
7018
7142
  safeWriteJsonAtomic(filePath, file.content, { mode: 384 });
@@ -7021,12 +7145,12 @@ async function processAgent(agent, agentStates) {
7021
7145
  }
7022
7146
  }
7023
7147
  try {
7024
- const provSkillsDir = join9(agentDir, ".claude", "skills");
7148
+ const provSkillsDir = join10(agentDir, ".claude", "skills");
7025
7149
  if (existsSync5(provSkillsDir)) {
7026
- for (const folder of readdirSync4(provSkillsDir)) {
7150
+ for (const folder of readdirSync5(provSkillsDir)) {
7027
7151
  if (folder.startsWith("knowledge-")) {
7028
7152
  try {
7029
- rmSync2(join9(provSkillsDir, folder), { recursive: true });
7153
+ rmSync2(join10(provSkillsDir, folder), { recursive: true });
7030
7154
  } catch {
7031
7155
  }
7032
7156
  }
@@ -7039,7 +7163,7 @@ async function processAgent(agent, agentStates) {
7039
7163
  const trackedFiles2 = frameworkAdapter.driftTrackedFiles();
7040
7164
  const hashes = /* @__PURE__ */ new Map();
7041
7165
  for (const file of trackedFiles2) {
7042
- const h = hashFile(join9(agentDir, file));
7166
+ const h = hashFile(join10(agentDir, file));
7043
7167
  if (h) hashes.set(file, h);
7044
7168
  }
7045
7169
  agentState.writtenHashes.set(agent.agent_id, hashes);
@@ -7088,7 +7212,7 @@ async function processAgent(agent, agentStates) {
7088
7212
  const delivered = await injectMessage(
7089
7213
  agent.code_name,
7090
7214
  "system",
7091
- restartNotice,
7215
+ restartNotice + BACK_ONLINE_GREETING_GUIDANCE,
7092
7216
  { task_name: "model-update" },
7093
7217
  log
7094
7218
  ).catch(() => false);
@@ -7107,7 +7231,7 @@ async function processAgent(agent, agentStates) {
7107
7231
  if (written && existsSync5(agentDir)) {
7108
7232
  const driftedFiles = [];
7109
7233
  for (const [file, expectedHash] of written) {
7110
- const localHash = hashFile(join9(agentDir, file));
7234
+ const localHash = hashFile(join10(agentDir, file));
7111
7235
  if (localHash && localHash !== expectedHash) {
7112
7236
  driftedFiles.push(file);
7113
7237
  }
@@ -7118,7 +7242,7 @@ async function processAgent(agent, agentStates) {
7118
7242
  try {
7119
7243
  const localHashes = {};
7120
7244
  for (const file of driftedFiles) {
7121
- localHashes[file] = hashFile(join9(agentDir, file));
7245
+ localHashes[file] = hashFile(join10(agentDir, file));
7122
7246
  }
7123
7247
  await api.post("/host/drift", {
7124
7248
  agent_id: agent.agent_id,
@@ -7296,7 +7420,7 @@ async function processAgent(agent, agentStates) {
7296
7420
  const reason = reasonParts.join(" ");
7297
7421
  log(`[hot-reload] Channel set changed for '${agent.code_name}' (${reason}) \u2014 restarting session`);
7298
7422
  const restartNotice = restartDecision.added.length > 0 ? `New channels have been wired up (${restartDecision.added.join(", ")}). Note: channels require a session restart to attach their MCP servers as channel listeners. Your manager will restart your session shortly.` : `Channels were removed (${restartDecision.removed.join(", ")}). Your manager will restart your session shortly so the launch flags drop those channels.`;
7299
- const delivered = await injectMessage(agent.code_name, "system", restartNotice, { task_name: "channel-update" }, log).catch(() => false);
7423
+ const delivered = await injectMessage(agent.code_name, "system", restartNotice + BACK_ONLINE_GREETING_GUIDANCE, { task_name: "channel-update" }, log).catch(() => false);
7300
7424
  const delay = delivered ? 8e3 : 3e3;
7301
7425
  if (!delivered) {
7302
7426
  log(`[hot-reload] Inject notification unconfirmed for '${agent.code_name}' \u2014 proceeding with shorter delay`);
@@ -7324,7 +7448,7 @@ async function processAgent(agent, agentStates) {
7324
7448
  const delivered = await injectMessage(
7325
7449
  agent.code_name,
7326
7450
  "system",
7327
- notice,
7451
+ notice + BACK_ONLINE_GREETING_GUIDANCE,
7328
7452
  { task_name: "sender-policy-update" },
7329
7453
  log
7330
7454
  ).catch(() => false);
@@ -7368,7 +7492,7 @@ async function processAgent(agent, agentStates) {
7368
7492
  const behaviourDelivered = await injectMessage(
7369
7493
  agent.code_name,
7370
7494
  "system",
7371
- behaviourNotice,
7495
+ behaviourNotice + BACK_ONLINE_GREETING_GUIDANCE,
7372
7496
  { task_name: "channel-update" },
7373
7497
  log
7374
7498
  ).catch(() => false);
@@ -7416,7 +7540,7 @@ async function processAgent(agent, agentStates) {
7416
7540
  const slackBehaviourDelivered = await injectMessage(
7417
7541
  agent.code_name,
7418
7542
  "system",
7419
- slackBehaviourNotice,
7543
+ slackBehaviourNotice + BACK_ONLINE_GREETING_GUIDANCE,
7420
7544
  { task_name: "channel-update" },
7421
7545
  log
7422
7546
  ).catch(() => false);
@@ -7442,18 +7566,18 @@ async function processAgent(agent, agentStates) {
7442
7566
  if (agentSessionMode === "persistent" && (agentFrameworkCache.get(agent.code_name) ?? "openclaw") === "claude-code") {
7443
7567
  try {
7444
7568
  const agentProvisionDir = agentDir;
7445
- const projectDir = join9(homedir5(), ".augmented", agent.code_name, "project");
7569
+ const projectDir = join10(homedir5(), ".augmented", agent.code_name, "project");
7446
7570
  mkdirSync3(agentProvisionDir, { recursive: true });
7447
7571
  mkdirSync3(projectDir, { recursive: true });
7448
- const provisionMcpPath = join9(agentProvisionDir, ".mcp.json");
7449
- const projectMcpPath = join9(projectDir, ".mcp.json");
7572
+ const provisionMcpPath = join10(agentProvisionDir, ".mcp.json");
7573
+ const projectMcpPath = join10(projectDir, ".mcp.json");
7450
7574
  let mcpConfig = { mcpServers: {} };
7451
7575
  try {
7452
- mcpConfig = JSON.parse(readFileSync9(provisionMcpPath, "utf-8"));
7576
+ mcpConfig = JSON.parse(readFileSync10(provisionMcpPath, "utf-8"));
7453
7577
  if (!mcpConfig.mcpServers) mcpConfig.mcpServers = {};
7454
7578
  } catch {
7455
7579
  }
7456
- const localDirectChatChannel = join9(homedir5(), ".augmented", "_mcp", "direct-chat-channel.js");
7580
+ const localDirectChatChannel = join10(homedir5(), ".augmented", "_mcp", "direct-chat-channel.js");
7457
7581
  const directChatTeamSettings = refreshData.team?.settings;
7458
7582
  const directChatTz = (() => {
7459
7583
  const tz = directChatTeamSettings?.["timezone"];
@@ -7483,7 +7607,7 @@ async function processAgent(agent, agentStates) {
7483
7607
  log(`Channel credentials written for '${agent.code_name}/direct-chat'`);
7484
7608
  }
7485
7609
  }
7486
- const staleChannelsPath = join9(projectDir, ".mcp-channels.json");
7610
+ const staleChannelsPath = join10(projectDir, ".mcp-channels.json");
7487
7611
  if (existsSync5(staleChannelsPath)) {
7488
7612
  try {
7489
7613
  rmSync2(staleChannelsPath, { force: true });
@@ -7548,7 +7672,7 @@ async function processAgent(agent, agentStates) {
7548
7672
  }
7549
7673
  if (process.env.AGT_CONNECTIVITY_PROBE_ENABLED === "true") {
7550
7674
  try {
7551
- const probeProjectDir = join9(homedir5(), ".augmented", agent.code_name, "project");
7675
+ const probeProjectDir = join10(homedir5(), ".augmented", agent.code_name, "project");
7552
7676
  await runAgentConnectivityProbes(agent, integrations, probeProjectDir);
7553
7677
  } catch (err) {
7554
7678
  log(`Connectivity probe failed for '${agent.code_name}': ${err.message}`);
@@ -7566,11 +7690,11 @@ async function processAgent(agent, agentStates) {
7566
7690
  recordConfigChurnEvent(agent.agent_id, agent.code_name, FLAP_CHANNEL_INTEGRATIONS, intMembership);
7567
7691
  }
7568
7692
  if (intHash !== prevIntHash) {
7569
- const projectDir = join9(homedir5(), ".augmented", agent.code_name, "project");
7570
- const envIntPath = join9(projectDir, ".env.integrations");
7693
+ const projectDir = join10(homedir5(), ".augmented", agent.code_name, "project");
7694
+ const envIntPath = join10(projectDir, ".env.integrations");
7571
7695
  let preWriteEnv;
7572
7696
  try {
7573
- preWriteEnv = readFileSync9(envIntPath, "utf-8");
7697
+ preWriteEnv = readFileSync10(envIntPath, "utf-8");
7574
7698
  } catch {
7575
7699
  preWriteEnv = void 0;
7576
7700
  }
@@ -7582,9 +7706,9 @@ async function processAgent(agent, agentStates) {
7582
7706
  let rotationHandled = true;
7583
7707
  if (fw === "claude-code" && isSessionHealthy(agent.code_name)) {
7584
7708
  try {
7585
- const projectMcpPath = join9(projectDir, ".mcp.json");
7586
- const postWriteEnv = readFileSync9(envIntPath, "utf-8");
7587
- 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");
7588
7712
  const changedVars = diffEnvIntegrations(preWriteEnv, postWriteEnv);
7589
7713
  const mcpJsonForReap = JSON.parse(mcpContent);
7590
7714
  const affectedServerKeys = findMcpServersUsingVars(mcpJsonForReap, changedVars);
@@ -7664,8 +7788,8 @@ async function processAgent(agent, agentStates) {
7664
7788
  const mcpPath = frameworkAdapter.getMcpPath(agent.code_name);
7665
7789
  if (mcpPath) {
7666
7790
  try {
7667
- const { readFileSync: readFileSync10 } = await import("fs");
7668
- const mcpConfig = JSON.parse(readFileSync10(mcpPath, "utf-8"));
7791
+ const { readFileSync: readFileSync11 } = await import("fs");
7792
+ const mcpConfig = JSON.parse(readFileSync11(mcpPath, "utf-8"));
7669
7793
  if (mcpConfig.mcpServers) {
7670
7794
  const managedPrefixes = [
7671
7795
  "composio_",
@@ -7704,7 +7828,7 @@ async function processAgent(agent, agentStates) {
7704
7828
  const delivered = await injectMessage(
7705
7829
  agent.code_name,
7706
7830
  "system",
7707
- restartNotice,
7831
+ restartNotice + BACK_ONLINE_GREETING_GUIDANCE,
7708
7832
  { task_name: "mcp-update" },
7709
7833
  log
7710
7834
  ).catch(() => false);
@@ -7766,7 +7890,7 @@ async function processAgent(agent, agentStates) {
7766
7890
  if (agent.status === "active") {
7767
7891
  if (frameworkAdapter.installPlugin) {
7768
7892
  try {
7769
- 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");
7770
7894
  if (existsSync5(pluginPath)) {
7771
7895
  frameworkAdapter.installPlugin(agent.code_name, "augmented", pluginPath, {
7772
7896
  agtHost: requireHost(),
@@ -7832,25 +7956,25 @@ async function processAgent(agent, agentStates) {
7832
7956
  }
7833
7957
  }
7834
7958
  try {
7835
- const { readdirSync: readdirSync5, rmSync: rmSync3 } = await import("fs");
7959
+ const { readdirSync: readdirSync6, rmSync: rmSync3 } = await import("fs");
7836
7960
  const { homedir: homedir6 } = await import("os");
7837
7961
  const frameworkId2 = frameworkAdapter.id;
7838
7962
  const candidateSkillDirs = [
7839
7963
  // Claude Code — framework runtime tree
7840
- join9(homedir6(), ".augmented", agent.code_name, "skills"),
7964
+ join10(homedir6(), ".augmented", agent.code_name, "skills"),
7841
7965
  // Claude Code — project tree
7842
- join9(homedir6(), ".augmented", agent.code_name, "project", ".claude", "skills"),
7966
+ join10(homedir6(), ".augmented", agent.code_name, "project", ".claude", "skills"),
7843
7967
  // OpenClaw — framework runtime tree
7844
- join9(homedir6(), `.openclaw-${agent.code_name}`, "skills"),
7968
+ join10(homedir6(), `.openclaw-${agent.code_name}`, "skills"),
7845
7969
  // Defensive: legacy provision-side path, not currently an
7846
7970
  // install target but cheap to sweep.
7847
- join9(agentDir, ".claude", "skills")
7971
+ join10(agentDir, ".claude", "skills")
7848
7972
  ];
7849
7973
  const existingDirs = candidateSkillDirs.filter((d) => existsSync5(d));
7850
7974
  const discoveredEntries = /* @__PURE__ */ new Set();
7851
7975
  for (const dir of existingDirs) {
7852
7976
  try {
7853
- for (const entry of readdirSync5(dir)) {
7977
+ for (const entry of readdirSync6(dir)) {
7854
7978
  if (entry.startsWith("plugin-") || entry.startsWith("integration-")) {
7855
7979
  discoveredEntries.add(entry);
7856
7980
  }
@@ -7860,7 +7984,7 @@ async function processAgent(agent, agentStates) {
7860
7984
  }
7861
7985
  const removeSkillFolder = (entry, reason) => {
7862
7986
  for (const dir of existingDirs) {
7863
- const p = join9(dir, entry);
7987
+ const p = join10(dir, entry);
7864
7988
  if (existsSync5(p)) {
7865
7989
  rmSync3(p, { recursive: true, force: true });
7866
7990
  }
@@ -8040,8 +8164,8 @@ async function processAgent(agent, agentStates) {
8040
8164
  const sess = getSessionState(agent.code_name);
8041
8165
  let mcpJsonParsed = null;
8042
8166
  try {
8043
- const mcpPath = join9(getProjectDir(agent.code_name), ".mcp.json");
8044
- 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"));
8045
8169
  } catch {
8046
8170
  }
8047
8171
  reapMissingMcpSessions({
@@ -8250,10 +8374,10 @@ async function processAgent(agent, agentStates) {
8250
8374
  lastWorkTriggerAt.set(agent.code_name, triggerTs);
8251
8375
  if (agentFw === "openclaw" && gatewayRunning && gatewayPort) {
8252
8376
  const homeDir = process.env["HOME"] ?? "/tmp";
8253
- const jobsPath = join9(homeDir, `.openclaw-${agent.code_name}`, "cron", "jobs.json");
8377
+ const jobsPath = join10(homeDir, `.openclaw-${agent.code_name}`, "cron", "jobs.json");
8254
8378
  if (existsSync5(jobsPath)) {
8255
8379
  try {
8256
- const jobsData = JSON.parse(readFileSync9(jobsPath, "utf-8"));
8380
+ const jobsData = JSON.parse(readFileSync10(jobsPath, "utf-8"));
8257
8381
  const kanbanJob = (jobsData.jobs ?? []).find(
8258
8382
  (j) => typeof j.name === "string" && j.name.includes("kanban-work")
8259
8383
  );
@@ -8390,7 +8514,7 @@ In progress for ${age} minutes \u2014 auto-failed`).catch(() => {
8390
8514
  if (trackedFiles.length > 0 && existsSync5(agentDir)) {
8391
8515
  const hashes = /* @__PURE__ */ new Map();
8392
8516
  for (const file of trackedFiles) {
8393
- const h = hashFile(join9(agentDir, file));
8517
+ const h = hashFile(join10(agentDir, file));
8394
8518
  if (h) hashes.set(file, h);
8395
8519
  }
8396
8520
  agentState.writtenHashes.set(agent.agent_id, hashes);
@@ -8424,19 +8548,19 @@ function cleanupStaleSessions(codeName) {
8424
8548
  lastCleanupAt.set(codeName, Date.now());
8425
8549
  const homeDir = process.env["HOME"] ?? "/tmp";
8426
8550
  for (const agentDir of ["main", codeName]) {
8427
- const sessionsDir = join9(homeDir, `.openclaw-${codeName}`, "agents", agentDir, "sessions");
8551
+ const sessionsDir = join10(homeDir, `.openclaw-${codeName}`, "agents", agentDir, "sessions");
8428
8552
  cleanupCronSessions(sessionsDir, CRON_SESSION_KEEP_COUNT);
8429
8553
  }
8430
- const cronRunsDir = join9(homeDir, `.openclaw-${codeName}`, "cron", "runs");
8554
+ const cronRunsDir = join10(homeDir, `.openclaw-${codeName}`, "cron", "runs");
8431
8555
  cleanupOldFiles(cronRunsDir, CRON_RUN_RETENTION_DAYS, ".jsonl");
8432
- const cronJobsPath = join9(homeDir, `.openclaw-${codeName}`, "cron", "jobs.json");
8556
+ const cronJobsPath = join10(homeDir, `.openclaw-${codeName}`, "cron", "jobs.json");
8433
8557
  clearStaleCronRunState(cronJobsPath);
8434
8558
  }
8435
8559
  function cleanupCronSessions(sessionsDir, keepCount) {
8436
- const indexPath = join9(sessionsDir, "sessions.json");
8560
+ const indexPath = join10(sessionsDir, "sessions.json");
8437
8561
  if (!existsSync5(indexPath)) return;
8438
8562
  try {
8439
- const raw = readFileSync9(indexPath, "utf-8");
8563
+ const raw = readFileSync10(indexPath, "utf-8");
8440
8564
  const index = JSON.parse(raw);
8441
8565
  const cronRunKeys = Object.keys(index).filter((k) => k.includes(":cron:") && k.includes(":run:")).map((k) => ({
8442
8566
  key: k,
@@ -8449,7 +8573,7 @@ function cleanupCronSessions(sessionsDir, keepCount) {
8449
8573
  for (const entry of toDelete) {
8450
8574
  delete index[entry.key];
8451
8575
  if (entry.sessionId) {
8452
- const sessionFile = join9(sessionsDir, `${entry.sessionId}.jsonl`);
8576
+ const sessionFile = join10(sessionsDir, `${entry.sessionId}.jsonl`);
8453
8577
  try {
8454
8578
  if (existsSync5(sessionFile)) {
8455
8579
  unlinkSync(sessionFile);
@@ -8471,7 +8595,7 @@ function cleanupCronSessions(sessionsDir, keepCount) {
8471
8595
  delete index[parentKey];
8472
8596
  if (parentSessionId) {
8473
8597
  try {
8474
- const f = join9(sessionsDir, `${parentSessionId}.jsonl`);
8598
+ const f = join10(sessionsDir, `${parentSessionId}.jsonl`);
8475
8599
  if (existsSync5(f)) {
8476
8600
  unlinkSync(f);
8477
8601
  deletedFiles++;
@@ -8492,7 +8616,7 @@ var STALE_RUN_TIMEOUT_MS = 5 * 6e4;
8492
8616
  function clearStaleCronRunState(jobsPath) {
8493
8617
  if (!existsSync5(jobsPath)) return;
8494
8618
  try {
8495
- const raw = readFileSync9(jobsPath, "utf-8");
8619
+ const raw = readFileSync10(jobsPath, "utf-8");
8496
8620
  const data = JSON.parse(raw);
8497
8621
  const jobs = data.jobs ?? data;
8498
8622
  if (!Array.isArray(jobs)) return;
@@ -8527,11 +8651,11 @@ function cleanupOldFiles(dir, maxAgeDays, ext) {
8527
8651
  const cutoff = Date.now() - maxAgeDays * 24 * 60 * 60 * 1e3;
8528
8652
  let removed = 0;
8529
8653
  try {
8530
- for (const f of readdirSync4(dir)) {
8654
+ for (const f of readdirSync5(dir)) {
8531
8655
  if (!f.endsWith(ext)) continue;
8532
- const fullPath = join9(dir, f);
8656
+ const fullPath = join10(dir, f);
8533
8657
  try {
8534
- const st = statSync3(fullPath);
8658
+ const st = statSync4(fullPath);
8535
8659
  if (st.mtimeMs < cutoff) {
8536
8660
  unlinkSync(fullPath);
8537
8661
  removed++;
@@ -8569,7 +8693,7 @@ var inFlightClaudeTasks = /* @__PURE__ */ new Set();
8569
8693
  var claudeTaskConcurrency = /* @__PURE__ */ new Map();
8570
8694
  var MAX_CLAUDE_CONCURRENCY = 2;
8571
8695
  function claudePidFilePath() {
8572
- return join9(homedir5(), ".augmented", "manager-claude-pids.json");
8696
+ return join10(homedir5(), ".augmented", "manager-claude-pids.json");
8573
8697
  }
8574
8698
  var inFlightClaudePids = /* @__PURE__ */ new Map();
8575
8699
  function registerClaudeSpawn(record) {
@@ -8909,7 +9033,7 @@ async function fireScheduledTaskViaKanban(codeName, agentId, task, prompt) {
8909
9033
  }
8910
9034
  async function executeAndProcessClaudeTask(codeName, agentId, task, prompt) {
8911
9035
  const projectDir = getProjectDir2(codeName);
8912
- const mcpConfigPath = join9(projectDir, ".mcp.json");
9036
+ const mcpConfigPath = join10(projectDir, ".mcp.json");
8913
9037
  let runId = null;
8914
9038
  let kanbanItemId = null;
8915
9039
  let taskResult;
@@ -8917,11 +9041,11 @@ async function executeAndProcessClaudeTask(codeName, agentId, task, prompt) {
8917
9041
  const priorRuns = await fetchPriorScheduledRuns(agentId, task.taskId);
8918
9042
  prompt = wrapScheduledTaskPrompt(prompt, { priorRuns });
8919
9043
  try {
8920
- const claudeMdPath = join9(projectDir, "CLAUDE.md");
9044
+ const claudeMdPath = join10(projectDir, "CLAUDE.md");
8921
9045
  const serverNames = [];
8922
9046
  if (existsSync5(mcpConfigPath)) {
8923
9047
  try {
8924
- const d = JSON.parse(readFileSync9(mcpConfigPath, "utf-8"));
9048
+ const d = JSON.parse(readFileSync10(mcpConfigPath, "utf-8"));
8925
9049
  if (d.mcpServers) serverNames.push(...Object.keys(d.mcpServers));
8926
9050
  } catch {
8927
9051
  }
@@ -8944,10 +9068,10 @@ async function executeAndProcessClaudeTask(codeName, agentId, task, prompt) {
8944
9068
  claudeArgs.push("--system-prompt-file", claudeMdPath);
8945
9069
  }
8946
9070
  const childEnv = { ...process.env };
8947
- const envIntPath = join9(projectDir, ".env.integrations");
9071
+ const envIntPath = join10(projectDir, ".env.integrations");
8948
9072
  if (existsSync5(envIntPath)) {
8949
9073
  try {
8950
- Object.assign(childEnv, parseEnvIntegrations(readFileSync9(envIntPath, "utf-8")));
9074
+ Object.assign(childEnv, parseEnvIntegrations(readFileSync10(envIntPath, "utf-8")));
8951
9075
  } catch {
8952
9076
  }
8953
9077
  }
@@ -9119,8 +9243,8 @@ var claudeAuthTupleBySession = /* @__PURE__ */ new Map();
9119
9243
  async function ensurePersistentSession(agent, tasks, boardItems, refreshData) {
9120
9244
  const codeName = agent.code_name;
9121
9245
  const projectDir = getProjectDir(codeName);
9122
- const mcpConfigPath = join9(projectDir, ".mcp.json");
9123
- const claudeMdPath = join9(projectDir, "CLAUDE.md");
9246
+ const mcpConfigPath = join10(projectDir, ".mcp.json");
9247
+ const claudeMdPath = join10(projectDir, "CLAUDE.md");
9124
9248
  if (restartBreaker.isTripped(codeName)) {
9125
9249
  const trip = restartBreaker.getTrip(codeName);
9126
9250
  return {
@@ -9754,11 +9878,11 @@ ${escapeXml(msg.content)}
9754
9878
  log(`[direct-chat] One-shot spawn for '${agent.codeName}' (msg=${msg.id}; host in-flight=${directChatSpawnGate.hostInFlight}, queued=${directChatSpawnGate.queuedCount})`);
9755
9879
  const { getProjectDir: ccProjectDir } = await import("../claude-scheduler-FATCLHDM.js");
9756
9880
  const projDir = ccProjectDir(agent.codeName);
9757
- const mcpConfigPath = join9(projDir, ".mcp.json");
9881
+ const mcpConfigPath = join10(projDir, ".mcp.json");
9758
9882
  const serverNames = [];
9759
9883
  if (existsSync5(mcpConfigPath)) {
9760
9884
  try {
9761
- const d = JSON.parse(readFileSync9(mcpConfigPath, "utf-8"));
9885
+ const d = JSON.parse(readFileSync10(mcpConfigPath, "utf-8"));
9762
9886
  if (d.mcpServers) serverNames.push(...Object.keys(d.mcpServers));
9763
9887
  } catch {
9764
9888
  }
@@ -9777,15 +9901,15 @@ ${escapeXml(msg.content)}
9777
9901
  "--allowedTools",
9778
9902
  allowedTools
9779
9903
  ];
9780
- const chatClaudeMd = join9(projDir, "CLAUDE.md");
9904
+ const chatClaudeMd = join10(projDir, "CLAUDE.md");
9781
9905
  if (existsSync5(chatClaudeMd)) {
9782
9906
  chatArgs.push("--system-prompt-file", chatClaudeMd);
9783
9907
  }
9784
- const envIntPath = join9(projDir, ".env.integrations");
9908
+ const envIntPath = join10(projDir, ".env.integrations");
9785
9909
  const childEnv = { ...process.env };
9786
9910
  if (existsSync5(envIntPath)) {
9787
9911
  try {
9788
- Object.assign(childEnv, parseEnvIntegrations(readFileSync9(envIntPath, "utf-8")));
9912
+ Object.assign(childEnv, parseEnvIntegrations(readFileSync10(envIntPath, "utf-8")));
9789
9913
  } catch {
9790
9914
  }
9791
9915
  }
@@ -10163,12 +10287,12 @@ function getBuiltInSkillContent(skillId) {
10163
10287
  if (builtInSkillCache.has(skillId)) return builtInSkillCache.get(skillId);
10164
10288
  try {
10165
10289
  const candidates = [
10166
- join9(process.cwd(), "skills", skillId, "SKILL.md"),
10167
- 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")
10168
10292
  ];
10169
10293
  for (const candidate of candidates) {
10170
10294
  if (existsSync5(candidate)) {
10171
- const content = readFileSync9(candidate, "utf-8");
10295
+ const content = readFileSync10(candidate, "utf-8");
10172
10296
  const files = [{ relativePath: "SKILL.md", content }];
10173
10297
  builtInSkillCache.set(skillId, files);
10174
10298
  return files;
@@ -10823,7 +10947,7 @@ async function processClaudePairSessions(agents) {
10823
10947
  killPairSession,
10824
10948
  pairTmuxSession,
10825
10949
  finalizeClaudePairOnboarding
10826
- } = await import("../claude-pair-runtime-G4MYOINJ.js");
10950
+ } = await import("../claude-pair-runtime-TZOAZFBQ.js");
10827
10951
  for (const pairId of pendingResp.cancelled_pair_ids ?? []) {
10828
10952
  log(`[claude-pair] sweeping orphan tmux session for pair ${pairId.slice(0, 8)}`);
10829
10953
  const killed = await killPairSession(pairTmuxSession(pairId));
@@ -11133,8 +11257,8 @@ function parseMemoryFile(raw, fallbackName) {
11133
11257
  };
11134
11258
  }
11135
11259
  async function syncMemories(agent, configDir, log2) {
11136
- const projectDir = join9(configDir, agent.code_name, "project");
11137
- const memoryDir = join9(projectDir, "memory");
11260
+ const projectDir = join10(configDir, agent.code_name, "project");
11261
+ const memoryDir = join10(projectDir, "memory");
11138
11262
  const isFreshSync = pendingFreshMemorySync.has(agent.agent_id);
11139
11263
  if (isFreshSync) {
11140
11264
  log2(`[memory-sync] Fresh-sync requested for '${agent.code_name}' \u2014 pulling DB first`);
@@ -11149,10 +11273,10 @@ async function syncMemories(agent, configDir, log2) {
11149
11273
  const prevHashes = memoryFileHashes.get(agent.agent_id) ?? /* @__PURE__ */ new Map();
11150
11274
  const currentHashes = /* @__PURE__ */ new Map();
11151
11275
  const changedMemories = [];
11152
- for (const file of readdirSync4(memoryDir)) {
11276
+ for (const file of readdirSync5(memoryDir)) {
11153
11277
  if (!file.endsWith(".md")) continue;
11154
11278
  try {
11155
- const raw = readFileSync9(join9(memoryDir, file), "utf-8");
11279
+ const raw = readFileSync10(join10(memoryDir, file), "utf-8");
11156
11280
  const fileHash = createHash3("sha256").update(raw).digest("hex").slice(0, 16);
11157
11281
  currentHashes.set(file, fileHash);
11158
11282
  if (prevHashes.get(file) === fileHash) continue;
@@ -11177,7 +11301,7 @@ async function syncMemories(agent, configDir, log2) {
11177
11301
  } catch (err) {
11178
11302
  for (const mem of changedMemories) {
11179
11303
  for (const [file] of currentHashes) {
11180
- 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$/, ""));
11181
11305
  if (parsed?.name === mem.name) currentHashes.delete(file);
11182
11306
  }
11183
11307
  }
@@ -11190,7 +11314,7 @@ async function syncMemories(agent, configDir, log2) {
11190
11314
  }
11191
11315
  }
11192
11316
  async function downloadMemories(agent, memoryDir, log2, { force }) {
11193
- 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() : [];
11194
11318
  const localListHash = createHash3("sha256").update(localFiles.join(",")).digest("hex").slice(0, 16);
11195
11319
  const prevLocalHash = lastLocalFileHash.get(agent.agent_id);
11196
11320
  const prevDownload = lastDownloadHash.get(agent.agent_id);
@@ -11212,7 +11336,7 @@ async function downloadMemories(agent, memoryDir, log2, { force }) {
11212
11336
  const mem = dbMemories.memories[i];
11213
11337
  const rawSlug = mem.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "").slice(0, 60);
11214
11338
  const slug = rawSlug || `memory-${i}`;
11215
- const filePath = join9(memoryDir, `${slug}.md`);
11339
+ const filePath = join10(memoryDir, `${slug}.md`);
11216
11340
  const desired = `---
11217
11341
  name: ${JSON.stringify(mem.name)}
11218
11342
  type: ${mem.type}
@@ -11224,7 +11348,7 @@ ${mem.content}
11224
11348
  if (existsSync5(filePath)) {
11225
11349
  let existing = "";
11226
11350
  try {
11227
- existing = readFileSync9(filePath, "utf-8");
11351
+ existing = readFileSync10(filePath, "utf-8");
11228
11352
  } catch {
11229
11353
  }
11230
11354
  if (existing === desired) continue;
@@ -11236,7 +11360,7 @@ ${mem.content}
11236
11360
  }
11237
11361
  }
11238
11362
  if (written > 0 || overwritten > 0) {
11239
- const updatedFiles = readdirSync4(memoryDir).filter((f) => f.endsWith(".md")).sort();
11363
+ const updatedFiles = readdirSync5(memoryDir).filter((f) => f.endsWith(".md")).sort();
11240
11364
  lastLocalFileHash.set(agent.agent_id, createHash3("sha256").update(updatedFiles.join(",")).digest("hex").slice(0, 16));
11241
11365
  log2(`Memory download for '${agent.code_name}': wrote ${written} new, overwrote ${overwritten} stale`);
11242
11366
  }
@@ -11479,7 +11603,7 @@ function startManager(opts) {
11479
11603
  try {
11480
11604
  const stateFile = getStateFile();
11481
11605
  if (existsSync5(stateFile)) {
11482
- const raw = readFileSync9(stateFile, "utf-8");
11606
+ const raw = readFileSync10(stateFile, "utf-8");
11483
11607
  const parsed = JSON.parse(raw);
11484
11608
  if (Array.isArray(parsed.agents)) {
11485
11609
  state6.agents = parsed.agents;
@@ -11500,7 +11624,7 @@ function startManager(opts) {
11500
11624
  log(`[startup] state rehydration failed (continuing with empty state): ${err.message}`);
11501
11625
  }
11502
11626
  log(
11503
- `[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")}`
11504
11628
  );
11505
11629
  deployMcpAssets();
11506
11630
  reapOrphanChannelMcps({ log });
@@ -11521,7 +11645,7 @@ async function reapOrphanedClaudePids() {
11521
11645
  const looksLikeClaude = (pid) => {
11522
11646
  if (process.platform !== "linux") return true;
11523
11647
  try {
11524
- const comm = readFileSync9(`/proc/${pid}/comm`, "utf-8").trim().toLowerCase();
11648
+ const comm = readFileSync10(`/proc/${pid}/comm`, "utf-8").trim().toLowerCase();
11525
11649
  return comm.includes("claude");
11526
11650
  } catch {
11527
11651
  return false;
@@ -11631,14 +11755,14 @@ function restartRunningChannelMcps(basenames) {
11631
11755
  }
11632
11756
  }
11633
11757
  function deployMcpAssets() {
11634
- const targetDir = join9(homedir5(), ".augmented", "_mcp");
11758
+ const targetDir = join10(homedir5(), ".augmented", "_mcp");
11635
11759
  mkdirSync3(targetDir, { recursive: true });
11636
11760
  const moduleDir = dirname2(fileURLToPath(import.meta.url));
11637
11761
  let mcpSourceDir = "";
11638
11762
  let dir = moduleDir;
11639
11763
  for (let i = 0; i < 6; i++) {
11640
- const candidate = join9(dir, "dist", "mcp");
11641
- if (existsSync5(join9(candidate, "index.js"))) {
11764
+ const candidate = join10(dir, "dist", "mcp");
11765
+ if (existsSync5(join10(candidate, "index.js"))) {
11642
11766
  mcpSourceDir = candidate;
11643
11767
  break;
11644
11768
  }
@@ -11654,7 +11778,7 @@ function deployMcpAssets() {
11654
11778
  const fileHash = (p) => {
11655
11779
  try {
11656
11780
  if (!existsSync5(p)) return null;
11657
- return createHash3("sha256").update(readFileSync9(p)).digest("hex");
11781
+ return createHash3("sha256").update(readFileSync10(p)).digest("hex");
11658
11782
  } catch {
11659
11783
  return null;
11660
11784
  }
@@ -11681,8 +11805,8 @@ function deployMcpAssets() {
11681
11805
  // natural session restart.
11682
11806
  "augmented-admin.js"
11683
11807
  ]) {
11684
- const src = join9(mcpSourceDir, file);
11685
- const dst = join9(targetDir, file);
11808
+ const src = join10(mcpSourceDir, file);
11809
+ const dst = join10(targetDir, file);
11686
11810
  if (!existsSync5(src)) continue;
11687
11811
  const before = fileHash(dst);
11688
11812
  try {
@@ -11700,16 +11824,16 @@ function deployMcpAssets() {
11700
11824
  log(`[manager] Bundle(s) updated: ${changedBasenames.join(", ")} \u2014 signalling running instances to restart`);
11701
11825
  restartRunningChannelMcps(changedBasenames);
11702
11826
  }
11703
- const localMcpPath = join9(targetDir, "index.js");
11827
+ const localMcpPath = join10(targetDir, "index.js");
11704
11828
  try {
11705
- const agentsDir = join9(homedir5(), ".augmented", "agents");
11829
+ const agentsDir = join10(homedir5(), ".augmented", "agents");
11706
11830
  if (existsSync5(agentsDir)) {
11707
- for (const entry of readdirSync4(agentsDir, { withFileTypes: true })) {
11831
+ for (const entry of readdirSync5(agentsDir, { withFileTypes: true })) {
11708
11832
  if (!entry.isDirectory()) continue;
11709
11833
  for (const subdir of ["provision", "project"]) {
11710
- const mcpJsonPath = join9(agentsDir, entry.name, subdir, ".mcp.json");
11834
+ const mcpJsonPath = join10(agentsDir, entry.name, subdir, ".mcp.json");
11711
11835
  try {
11712
- const raw = readFileSync9(mcpJsonPath, "utf-8");
11836
+ const raw = readFileSync10(mcpJsonPath, "utf-8");
11713
11837
  if (!raw.includes("@integrity-labs/augmented-mcp")) continue;
11714
11838
  const mcpConfig = JSON.parse(raw);
11715
11839
  const augServer = mcpConfig.mcpServers?.["augmented"];
@@ -11751,6 +11875,7 @@ process.on("disconnect", () => {
11751
11875
  });
11752
11876
  });
11753
11877
  export {
11878
+ BACK_ONLINE_GREETING_GUIDANCE,
11754
11879
  ChildProcessError,
11755
11880
  SCHEDULED_CARD_DELIVERY_CONTRACT,
11756
11881
  __resetScheduledDeliveryDedupeForTest,