@integrity-labs/agt-cli 0.28.643 → 0.28.644

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.
@@ -55,7 +55,7 @@ import {
55
55
  safeWriteJsonAtomic,
56
56
  setConfigHash,
57
57
  tripClass
58
- } from "../chunk-M24MLZPT.js";
58
+ } from "../chunk-V2NZ2PAA.js";
59
59
  import {
60
60
  getProjectDir as getProjectDir2,
61
61
  getReadyTasks,
@@ -195,9 +195,33 @@ import {
195
195
 
196
196
  // src/lib/manager-worker.ts
197
197
  import { createHash as createHash17 } from "crypto";
198
- import { readFileSync as readFileSync28, writeFileSync as writeFileSync14, mkdirSync as mkdirSync11, existsSync as existsSync15, rmSync as rmSync5, readdirSync as readdirSync9, statSync as statSync8, copyFileSync } from "fs";
198
+ import { readFileSync as readFileSync28, writeFileSync as writeFileSync14, mkdirSync as mkdirSync11, existsSync as existsSync15, rmSync as rmSync5, readdirSync as readdirSync9, statSync as statSync8 } from "fs";
199
+
200
+ // src/lib/atomic-file-replace.ts
201
+ import { copyFileSync, renameSync, unlinkSync } from "fs";
202
+ import { join, dirname, basename } from "path";
203
+ function atomicCopyFileSync(src, dst, unique = defaultUnique) {
204
+ const tmp = join(dirname(dst), `.${basename(dst)}.tmp-${unique()}`);
205
+ try {
206
+ copyFileSync(src, tmp);
207
+ renameSync(tmp, dst);
208
+ } catch (err) {
209
+ try {
210
+ unlinkSync(tmp);
211
+ } catch {
212
+ }
213
+ throw err;
214
+ }
215
+ }
216
+ var seq = 0;
217
+ function defaultUnique() {
218
+ seq += 1;
219
+ return `${process.pid}-${seq}-${Date.now().toString(36)}`;
220
+ }
221
+
222
+ // src/lib/manager-worker.ts
199
223
  import { execFileSync as syncExecFile } from "child_process";
200
- import { join as join35, dirname as dirname9, delimiter as pathDelimiter } from "path";
224
+ import { join as join36, dirname as dirname10, delimiter as pathDelimiter } from "path";
201
225
  import { homedir as homedir17 } from "os";
202
226
  import { fileURLToPath } from "url";
203
227
 
@@ -241,16 +265,16 @@ function createSingleFlight(task, opts = {}) {
241
265
 
242
266
  // src/lib/claude-code-upgrade-throttle.ts
243
267
  import { mkdirSync, readFileSync, writeFileSync } from "fs";
244
- import { dirname, join } from "path";
268
+ import { dirname as dirname2, join as join2 } from "path";
245
269
  import { homedir } from "os";
246
270
  var CLAUDE_CODE_UPGRADE_CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
247
271
  function claudeCodeUpgradeMarkerPath() {
248
- return join(homedir(), ".augmented", ".last-claude-code-upgrade-check");
272
+ return join2(homedir(), ".augmented", ".last-claude-code-upgrade-check");
249
273
  }
250
274
  function stampClaudeCodeUpgradeMarker() {
251
275
  try {
252
276
  const markerPath = claudeCodeUpgradeMarkerPath();
253
- mkdirSync(dirname(markerPath), { recursive: true });
277
+ mkdirSync(dirname2(markerPath), { recursive: true });
254
278
  writeFileSync(markerPath, String(Date.now()));
255
279
  } catch {
256
280
  }
@@ -690,7 +714,7 @@ function isSlackBehaviourRestrictive(subset) {
690
714
 
691
715
  // src/lib/onboarding-drive.ts
692
716
  import { mkdirSync as mkdirSync2, readFileSync as readFileSync2, rmSync, writeFileSync as writeFileSync2 } from "fs";
693
- import { dirname as dirname2 } from "path";
717
+ import { dirname as dirname3 } from "path";
694
718
  var ONBOARDING_REINJECT_INTERVAL_MS = 45 * 6e4;
695
719
  var ONBOARDING_MAX_NUDGES = 3;
696
720
  var ONBOARDING_MIN_STANDDOWN_AGE_MS = 60 * 6e4;
@@ -841,7 +865,7 @@ function readOnboardingDriveMarker(path) {
841
865
  return null;
842
866
  }
843
867
  function writeOnboardingDriveMarker(path, marker) {
844
- mkdirSync2(dirname2(path), { recursive: true });
868
+ mkdirSync2(dirname3(path), { recursive: true });
845
869
  writeFileSync2(path, JSON.stringify(marker) + "\n", "utf8");
846
870
  }
847
871
  function clearOnboardingDriveMarker(path) {
@@ -853,7 +877,7 @@ function clearOnboardingDriveMarker(path) {
853
877
 
854
878
  // src/lib/channel-quarantine.ts
855
879
  import { readFileSync as readFileSync3 } from "fs";
856
- import { join as join2 } from "path";
880
+ import { join as join3 } from "path";
857
881
  var ESSENTIAL_CHANNEL_KEYS = /* @__PURE__ */ new Set(["direct-chat", "augmented"]);
858
882
  var OPTIONAL_CHANNEL_KEYS = /* @__PURE__ */ new Set([
859
883
  "telegram",
@@ -885,7 +909,7 @@ function classifyChannelCriticality(serverKey, entry) {
885
909
  return "essential";
886
910
  }
887
911
  function defaultQuarantinePath(configDir) {
888
- return join2(configDir, "channel-quarantine.json");
912
+ return join3(configDir, "channel-quarantine.json");
889
913
  }
890
914
  var ChannelQuarantineStore = class {
891
915
  path;
@@ -985,10 +1009,10 @@ function isQuarantineFile(value) {
985
1009
 
986
1010
  // src/lib/claude-md-size.ts
987
1011
  import { readFileSync as readFileSync4 } from "fs";
988
- import { join as join3 } from "path";
1012
+ import { join as join4 } from "path";
989
1013
  function measureClaudeMd(configDir, codeName, ceiling = CLAUDE_MD_MAX_CHARS) {
990
1014
  try {
991
- const buf = readFileSync4(join3(configDir, codeName, "project", "CLAUDE.md"));
1015
+ const buf = readFileSync4(join4(configDir, codeName, "project", "CLAUDE.md"));
992
1016
  const chars = buf.toString("utf8").length;
993
1017
  return { chars, bytes: buf.length, ceiling, overCeiling: chars > ceiling };
994
1018
  } catch {
@@ -1566,9 +1590,9 @@ var DependencyRecoveryLedger = class {
1566
1590
  // src/lib/mcp-assets-ready.ts
1567
1591
  import { existsSync as nodeExistsSync, readFileSync as nodeReadFileSync } from "fs";
1568
1592
  import { homedir as homedir2 } from "os";
1569
- import { join as join4, resolve, sep } from "path";
1593
+ import { join as join5, resolve, sep } from "path";
1570
1594
  function getSharedMcpDir(homeDir = homedir2()) {
1571
- return join4(homeDir, ".augmented", "_mcp");
1595
+ return join5(homeDir, ".augmented", "_mcp");
1572
1596
  }
1573
1597
  function isPathInsideDir(candidate, dir) {
1574
1598
  const resolvedDir = resolve(dir);
@@ -1621,7 +1645,7 @@ function formatMissingMcpBundles(missing) {
1621
1645
 
1622
1646
  // src/lib/self-update-coalesce.ts
1623
1647
  import { readFileSync as readFileSync5, writeFileSync as writeFileSync3, mkdirSync as mkdirSync3 } from "fs";
1624
- import { dirname as dirname3 } from "path";
1648
+ import { dirname as dirname4 } from "path";
1625
1649
  var DEFAULT_SELF_UPDATE_COALESCE_MS = 30 * 60 * 1e3;
1626
1650
  function resolveCoalesceWindowMs(env = process.env) {
1627
1651
  const raw = env.AGT_SELF_UPDATE_COALESCE_MS;
@@ -1643,7 +1667,7 @@ function readLastSelfUpdateAppliedMs(markerPath, now = Date.now(), read = (p) =>
1643
1667
  return v;
1644
1668
  }
1645
1669
  function stampLastSelfUpdateApplied(markerPath, now = Date.now(), write = (p, v) => {
1646
- mkdirSync3(dirname3(p), { recursive: true });
1670
+ mkdirSync3(dirname4(p), { recursive: true });
1647
1671
  writeFileSync3(p, v);
1648
1672
  }) {
1649
1673
  try {
@@ -1988,14 +2012,14 @@ function formatReaperBootLine(opts) {
1988
2012
  }
1989
2013
 
1990
2014
  // src/lib/direct-chat-delivery.ts
1991
- import { join as join5 } from "path";
2015
+ import { join as join6 } from "path";
1992
2016
  var DEFAULT_DIRECT_CHAT_MAX_AGE_MS = 30 * 6e4;
1993
2017
  function directChatMaxAgeMs() {
1994
2018
  const raw = parseInt(process.env["AGT_DIRECT_CHAT_MAX_AGE_MS"] ?? "", 10);
1995
2019
  return Number.isFinite(raw) && raw >= 0 ? raw : DEFAULT_DIRECT_CHAT_MAX_AGE_MS;
1996
2020
  }
1997
2021
  function directChatDoorbellPath(agentId, home) {
1998
- return join5(home, ".augmented", agentId, "direct-chat-doorbell");
2022
+ return join6(home, ".augmented", agentId, "direct-chat-doorbell");
1999
2023
  }
2000
2024
  function isDirectChatMessageExpired(createdAt, nowMs, maxAgeMs) {
2001
2025
  if (!maxAgeMs || maxAgeMs <= 0) return false;
@@ -2006,8 +2030,8 @@ function isDirectChatMessageExpired(createdAt, nowMs, maxAgeMs) {
2006
2030
  }
2007
2031
 
2008
2032
  // src/lib/id-keyed-migration.ts
2009
- import { existsSync as existsSync2, lstatSync, readlinkSync, renameSync } from "fs";
2010
- import { join as join6 } from "path";
2033
+ import { existsSync as existsSync2, lstatSync, readlinkSync, renameSync as renameSync2 } from "fs";
2034
+ import { join as join7 } from "path";
2011
2035
  import { homedir as homedir3 } from "os";
2012
2036
  var ID_KEYED_MIGRATION_FLAG = "id-keyed-layout-migration";
2013
2037
  function agentHasActiveWhatsapp(channelConfigs, codeNameDir) {
@@ -2015,7 +2039,7 @@ function agentHasActiveWhatsapp(channelConfigs, codeNameDir) {
2015
2039
  return true;
2016
2040
  }
2017
2041
  try {
2018
- if (existsSync2(join6(codeNameDir, "whatsapp-pending-inbound"))) return true;
2042
+ if (existsSync2(join7(codeNameDir, "whatsapp-pending-inbound"))) return true;
2019
2043
  } catch {
2020
2044
  }
2021
2045
  return false;
@@ -2041,16 +2065,16 @@ function finishTranscriptMove(oldCwd, newCwd, codeName, log2) {
2041
2065
  );
2042
2066
  return;
2043
2067
  }
2044
- renameSync(from, to);
2068
+ renameSync2(from, to);
2045
2069
  log2(`[id-keyed-migration] moved transcript store for '${codeName}' to the id-keyed key`);
2046
2070
  }
2047
2071
  function maybeMigrateAgentToIdKeyedLayout(agent, deps) {
2048
2072
  const home = deps.home ?? homedir3();
2049
2073
  const { code_name: codeName, agent_id: agentId } = agent;
2050
- const codeNamePath = join6(home, ".augmented", codeName);
2051
- const idPath = join6(home, ".augmented", agentId);
2052
- const oldCwd = join6(home, ".augmented", codeName, "project");
2053
- const newCwd = join6(idPath, "project");
2074
+ const codeNamePath = join7(home, ".augmented", codeName);
2075
+ const idPath = join7(home, ".augmented", agentId);
2076
+ const oldCwd = join7(home, ".augmented", codeName, "project");
2077
+ const newCwd = join7(idPath, "project");
2054
2078
  let codeNameKind;
2055
2079
  try {
2056
2080
  codeNameKind = lstatSync(codeNamePath).isSymbolicLink() ? "symlink" : "realdir";
@@ -2178,7 +2202,7 @@ function collectEnvGates(env) {
2178
2202
 
2179
2203
  // ../../packages/core/dist/direct-chat/cursor-advance-telemetry.js
2180
2204
  import { readFileSync as readFileSync7, writeFileSync as writeFileSync4 } from "fs";
2181
- import { join as join7 } from "path";
2205
+ import { join as join8 } from "path";
2182
2206
  var CURSOR_SHORTFALL_COUNTER_SUFFIX = "-cursor-advance-classifications.json";
2183
2207
  function recordCursorAdvanceOutcome(agentDir, source, route, verdict) {
2184
2208
  if (!agentDir)
@@ -2186,7 +2210,7 @@ function recordCursorAdvanceOutcome(agentDir, source, route, verdict) {
2186
2210
  const key = cursorAdvanceCounterKey(route, verdict);
2187
2211
  if (key === null)
2188
2212
  return;
2189
- const path = join7(agentDir, `${source}${CURSOR_SHORTFALL_COUNTER_SUFFIX}`);
2213
+ const path = join8(agentDir, `${source}${CURSOR_SHORTFALL_COUNTER_SUFFIX}`);
2190
2214
  const counts = {};
2191
2215
  try {
2192
2216
  const parsed = JSON.parse(readFileSync7(path, "utf-8"));
@@ -2206,7 +2230,7 @@ function recordCursorAdvanceOutcome(agentDir, source, route, verdict) {
2206
2230
  }
2207
2231
 
2208
2232
  // src/lib/artifact-stream.ts
2209
- import { join as join8 } from "path";
2233
+ import { join as join9 } from "path";
2210
2234
  import { homedir as homedir4 } from "os";
2211
2235
  import { readdir, stat, readFile } from "fs/promises";
2212
2236
  var ARTEFACT_ENTRY_FILE = "index.html";
@@ -2292,7 +2316,7 @@ var ArtifactStreamScanner = class {
2292
2316
  return;
2293
2317
  }
2294
2318
  for (const name of names) {
2295
- const file = join8(this.artifactsDir, name, ARTEFACT_ENTRY_FILE);
2319
+ const file = join9(this.artifactsDir, name, ARTEFACT_ENTRY_FILE);
2296
2320
  const mtime = await this.fsDeps.mtimeMs(file).catch(() => null);
2297
2321
  if (mtime === null) continue;
2298
2322
  if (this.seenMtime.get(name) === mtime) continue;
@@ -2323,7 +2347,7 @@ var ArtifactStreamScanner = class {
2323
2347
  }
2324
2348
  };
2325
2349
  function artifactsDirFor(codeName) {
2326
- return join8(homedir4(), ".augmented", codeName, "artifacts");
2350
+ return join9(homedir4(), ".augmented", codeName, "artifacts");
2327
2351
  }
2328
2352
  var nodeArtifactFs = {
2329
2353
  async listArtefactNames(artifactsDir) {
@@ -2434,12 +2458,12 @@ async function maybeReportUsageBanner(args) {
2434
2458
  import { createHash as createHash6 } from "crypto";
2435
2459
  import { readFile as readFile3, readdir as readdir3 } from "fs/promises";
2436
2460
  import { homedir as homedir6, platform as platform2 } from "os";
2437
- import { dirname as dirname4, join as join10 } from "path";
2461
+ import { dirname as dirname5, join as join11 } from "path";
2438
2462
 
2439
2463
  // src/lib/claude-auth-detect.ts
2440
2464
  import { readFile as readFile2, readdir as readdir2 } from "fs/promises";
2441
2465
  import { homedir as homedir5, platform } from "os";
2442
- import { join as join9 } from "path";
2466
+ import { join as join10 } from "path";
2443
2467
  import { execFile } from "child_process";
2444
2468
  import { promisify } from "util";
2445
2469
  var execFileAsync = promisify(execFile);
@@ -2454,16 +2478,16 @@ async function detectClaudeAuth() {
2454
2478
  }
2455
2479
  async function findClaudeCredentialsPaths() {
2456
2480
  const candidates = [
2457
- join9(homedir5(), ".claude", ".credentials.json"),
2458
- join9(homedir5(), ".claude", "credentials.json")
2481
+ join10(homedir5(), ".claude", ".credentials.json"),
2482
+ join10(homedir5(), ".claude", "credentials.json")
2459
2483
  ];
2460
2484
  const isLinuxRoot = platform() === "linux" && typeof process.getuid === "function" && process.getuid() === 0;
2461
2485
  if (isLinuxRoot) {
2462
2486
  try {
2463
2487
  const entries = await readdir2("/home", { withFileTypes: true });
2464
2488
  for (const entry of entries.filter((entry2) => entry2.isDirectory()).sort((a, b) => a.name.localeCompare(b.name))) {
2465
- candidates.push(join9("/home", entry.name, ".claude", ".credentials.json"));
2466
- candidates.push(join9("/home", entry.name, ".claude", "credentials.json"));
2489
+ candidates.push(join10("/home", entry.name, ".claude", ".credentials.json"));
2490
+ candidates.push(join10("/home", entry.name, ".claude", "credentials.json"));
2467
2491
  }
2468
2492
  } catch {
2469
2493
  }
@@ -2547,7 +2571,7 @@ async function candidateHomes() {
2547
2571
  try {
2548
2572
  const entries = await readdir3("/home", { withFileTypes: true });
2549
2573
  for (const entry of entries.filter((e) => e.isDirectory()).sort((a, b) => a.name.localeCompare(b.name))) {
2550
- homes.push(join10("/home", entry.name));
2574
+ homes.push(join11("/home", entry.name));
2551
2575
  }
2552
2576
  } catch {
2553
2577
  }
@@ -2558,7 +2582,7 @@ async function homeOfActiveCredentials() {
2558
2582
  for (const path of await findClaudeCredentialsPaths()) {
2559
2583
  try {
2560
2584
  await readFile3(path, "utf-8");
2561
- return dirname4(dirname4(path));
2585
+ return dirname5(dirname5(path));
2562
2586
  } catch {
2563
2587
  }
2564
2588
  }
@@ -2567,11 +2591,11 @@ async function homeOfActiveCredentials() {
2567
2591
  async function claudeConfigCandidatePaths() {
2568
2592
  const paths = [];
2569
2593
  const configDir = process.env["CLAUDE_CONFIG_DIR"]?.trim();
2570
- if (configDir) paths.push(join10(configDir, ".claude.json"));
2594
+ if (configDir) paths.push(join11(configDir, ".claude.json"));
2571
2595
  const activeHome = await homeOfActiveCredentials();
2572
- if (activeHome) paths.push(join10(activeHome, ".claude.json"));
2596
+ if (activeHome) paths.push(join11(activeHome, ".claude.json"));
2573
2597
  for (const home of await candidateHomes()) {
2574
- const path = join10(home, ".claude.json");
2598
+ const path = join11(home, ".claude.json");
2575
2599
  if (!paths.includes(path)) paths.push(path);
2576
2600
  }
2577
2601
  return paths;
@@ -2668,11 +2692,11 @@ function diffAuthTuples(recorded, current) {
2668
2692
  }
2669
2693
 
2670
2694
  // src/lib/account-enforcement-marker.ts
2671
- import { mkdirSync as mkdirSync4, renameSync as renameSync2, rmSync as rmSync2, writeFileSync as writeFileSync5 } from "fs";
2695
+ import { mkdirSync as mkdirSync4, renameSync as renameSync3, rmSync as rmSync2, writeFileSync as writeFileSync5 } from "fs";
2672
2696
  import { homedir as homedir7 } from "os";
2673
- import { join as join11 } from "path";
2697
+ import { join as join12 } from "path";
2674
2698
  function accountEnforcementMarkerPath(codeName) {
2675
- return join11(homedir7(), ".augmented", codeName, ACCOUNT_ENFORCEMENT_MARKER_FILENAME);
2699
+ return join12(homedir7(), ".augmented", codeName, ACCOUNT_ENFORCEMENT_MARKER_FILENAME);
2676
2700
  }
2677
2701
  function syncAccountEnforcementMarker(codeName, level, log2 = (m) => process.stderr.write(`${m}
2678
2702
  `), text) {
@@ -2680,13 +2704,13 @@ function syncAccountEnforcementMarker(codeName, level, log2 = (m) => process.std
2680
2704
  clearAccountEnforcementMarker(codeName, log2);
2681
2705
  return;
2682
2706
  }
2683
- const dir = join11(homedir7(), ".augmented", codeName);
2684
- const path = join11(dir, ACCOUNT_ENFORCEMENT_MARKER_FILENAME);
2707
+ const dir = join12(homedir7(), ".augmented", codeName);
2708
+ const path = join12(dir, ACCOUNT_ENFORCEMENT_MARKER_FILENAME);
2685
2709
  const tempPath = `${path}.${process.pid}.tmp`;
2686
2710
  try {
2687
2711
  mkdirSync4(dir, { recursive: true });
2688
2712
  writeFileSync5(tempPath, serializeAccountEnforcementMarker(level, text), "utf-8");
2689
- renameSync2(tempPath, path);
2713
+ renameSync3(tempPath, path);
2690
2714
  } catch (err) {
2691
2715
  try {
2692
2716
  rmSync2(tempPath, { force: true });
@@ -2707,7 +2731,7 @@ function clearAccountEnforcementMarker(codeName, log2 = (m) => process.stderr.wr
2707
2731
 
2708
2732
  // src/lib/token-usage-monitor.ts
2709
2733
  import { readdirSync, readFileSync as readFileSync8, statSync } from "fs";
2710
- import { join as join12 } from "path";
2734
+ import { join as join13 } from "path";
2711
2735
  var MIN_CHECK_INTERVAL_MS2 = 6e4;
2712
2736
  var TRANSCRIPT_MTIME_WINDOW_MS = 2 * 24 * 60 * 60 * 1e3;
2713
2737
  var MAX_ENTRIES_PER_POST = 200;
@@ -2736,7 +2760,7 @@ async function maybeReportTokenUsage(args) {
2736
2760
  if (!name.endsWith(".jsonl")) continue;
2737
2761
  const sessionId = name.slice(0, -".jsonl".length);
2738
2762
  if (!sessionId) continue;
2739
- const path = join12(dir, name);
2763
+ const path = join13(dir, name);
2740
2764
  let st;
2741
2765
  try {
2742
2766
  st = statSync(path);
@@ -2834,7 +2858,7 @@ async function maybeReportTokenUsage(args) {
2834
2858
 
2835
2859
  // src/lib/workflow-run-reconciler.ts
2836
2860
  import { readdirSync as readdirSync2, readFileSync as readFileSync9, statSync as statSync2 } from "fs";
2837
- import { join as join13 } from "path";
2861
+ import { join as join14 } from "path";
2838
2862
  var MIN_CHECK_INTERVAL_MS3 = 5 * 6e4;
2839
2863
  var SETTLE_MS = 3e4;
2840
2864
  var TRANSCRIPT_MTIME_WINDOW_MS2 = 2 * 24 * 60 * 60 * 1e3;
@@ -2853,7 +2877,7 @@ function collectJsonlRecursive(dir, minMtimeMs, out, depth) {
2853
2877
  return;
2854
2878
  }
2855
2879
  for (const name of entries) {
2856
- const p = join13(dir, name);
2880
+ const p = join14(dir, name);
2857
2881
  let st;
2858
2882
  try {
2859
2883
  st = statSync2(p);
@@ -2876,7 +2900,7 @@ function enumerateTranscriptFiles(transcriptDir, nowMs, minMtimeMs = nowMs - TRA
2876
2900
  return out;
2877
2901
  }
2878
2902
  for (const name of entries) {
2879
- const path = join13(transcriptDir, name);
2903
+ const path = join14(transcriptDir, name);
2880
2904
  let st;
2881
2905
  try {
2882
2906
  st = statSync2(path);
@@ -2888,7 +2912,7 @@ function enumerateTranscriptFiles(transcriptDir, nowMs, minMtimeMs = nowMs - TRA
2888
2912
  continue;
2889
2913
  }
2890
2914
  if (st.isDirectory()) {
2891
- collectJsonlRecursive(join13(path, "subagents"), minMtimeMs, out, 0);
2915
+ collectJsonlRecursive(join14(path, "subagents"), minMtimeMs, out, 0);
2892
2916
  }
2893
2917
  }
2894
2918
  return out;
@@ -2979,7 +3003,7 @@ async function maybeReconcileWorkflowRunTokens(args) {
2979
3003
 
2980
3004
  // src/lib/conversation-evaluator.ts
2981
3005
  import { readdirSync as readdirSync3, readFileSync as readFileSync10, statSync as statSync3 } from "fs";
2982
- import { join as join14 } from "path";
3006
+ import { join as join15 } from "path";
2983
3007
  var MIN_CHECK_INTERVAL_MS4 = 5 * 6e4;
2984
3008
  var TRANSCRIPT_MTIME_WINDOW_MS3 = 7 * 24 * 60 * 60 * 1e3;
2985
3009
  var WINDOW_PAD_MS = 5 * 6e4;
@@ -3415,7 +3439,7 @@ function readRecentTurns(dir, nowMs) {
3415
3439
  return;
3416
3440
  }
3417
3441
  for (const ent of entries) {
3418
- const full = join14(d, ent.name);
3442
+ const full = join15(d, ent.name);
3419
3443
  if (ent.isDirectory()) {
3420
3444
  visit(full);
3421
3445
  continue;
@@ -3721,17 +3745,17 @@ async function reportSkip2(api2, agentId, conversationId, log2, codeName) {
3721
3745
 
3722
3746
  // src/lib/tool-call-audit.ts
3723
3747
  import { homedir as homedir11 } from "os";
3724
- import { join as join19 } from "path";
3748
+ import { join as join20 } from "path";
3725
3749
 
3726
3750
  // src/lib/agent-logging-mode.ts
3727
3751
  import { readFileSync as readFileSync11 } from "fs";
3728
3752
  import { homedir as homedir8 } from "os";
3729
- import { join as join15 } from "path";
3753
+ import { join as join16 } from "path";
3730
3754
  var LOGGING_MODES = ["hash-only", "redacted", "full-local"];
3731
3755
  function charterPath(codeName, homeDir) {
3732
3756
  const home = homeDir ?? (process.env["HOME"]?.trim() || homedir8());
3733
3757
  const key = agentRuntimeKey(codeName, homeDir);
3734
- return join15(home, ".augmented", key, "provision", "CHARTER.md");
3758
+ return join16(home, ".augmented", key, "provision", "CHARTER.md");
3735
3759
  }
3736
3760
  function readAgentLoggingMode(codeName, homeDir) {
3737
3761
  let raw;
@@ -3760,15 +3784,15 @@ function loggingModeWithholdsTargets(reading) {
3760
3784
 
3761
3785
  // src/lib/tool-call-path-salt.ts
3762
3786
  import { randomBytes } from "crypto";
3763
- import { existsSync as existsSync3, mkdirSync as mkdirSync5, readFileSync as readFileSync12, renameSync as renameSync3, unlinkSync, writeFileSync as writeFileSync6 } from "fs";
3787
+ import { existsSync as existsSync3, mkdirSync as mkdirSync5, readFileSync as readFileSync12, renameSync as renameSync4, unlinkSync as unlinkSync2, writeFileSync as writeFileSync6 } from "fs";
3764
3788
  import { homedir as homedir9 } from "os";
3765
- import { dirname as dirname5, join as join16 } from "path";
3789
+ import { dirname as dirname6, join as join17 } from "path";
3766
3790
  var SALT_BYTES = 32;
3767
3791
  var SALT_RE = /^[0-9a-f]{64}$/;
3768
3792
  function pathSaltPath(codeName, homeDir) {
3769
3793
  const home = homeDir ?? (process.env["HOME"]?.trim() || homedir9());
3770
3794
  const key = agentRuntimeKey(codeName, homeDir);
3771
- return join16(home, ".augmented", key, "tool-call-path-salt");
3795
+ return join17(home, ".augmented", key, "tool-call-path-salt");
3772
3796
  }
3773
3797
  function readToolCallPathSalt(codeName, homeDir) {
3774
3798
  let file;
@@ -3787,13 +3811,13 @@ function readToolCallPathSalt(codeName, homeDir) {
3787
3811
  const salt = randomBytes(SALT_BYTES).toString("hex");
3788
3812
  const tmp = `${file}.tmp.${process.pid}`;
3789
3813
  try {
3790
- mkdirSync5(dirname5(file), { recursive: true, mode: 448 });
3814
+ mkdirSync5(dirname6(file), { recursive: true, mode: 448 });
3791
3815
  writeFileSync6(tmp, `${salt}
3792
3816
  `, { encoding: "utf-8", mode: 384 });
3793
- renameSync3(tmp, file);
3817
+ renameSync4(tmp, file);
3794
3818
  } catch {
3795
3819
  try {
3796
- unlinkSync(tmp);
3820
+ unlinkSync2(tmp);
3797
3821
  } catch {
3798
3822
  }
3799
3823
  return null;
@@ -3845,7 +3869,7 @@ function readHostArchiveAddress(path) {
3845
3869
 
3846
3870
  // src/lib/tool-call-extractor.ts
3847
3871
  import { closeSync, fstatSync, openSync, readFileSync as readFileSync14, readSync, readdirSync as readdirSync4 } from "fs";
3848
- import { basename, join as join17, relative } from "path";
3872
+ import { basename as basename2, join as join18, relative } from "path";
3849
3873
  import { StringDecoder } from "string_decoder";
3850
3874
 
3851
3875
  // src/lib/tool-call-redaction.ts
@@ -3974,7 +3998,7 @@ function redactToolTargetInner(toolName, input, ctx) {
3974
3998
  var EXTRACTOR_VERSION = "e1";
3975
3999
  function enumerateSessionTranscripts(transcriptDir, sessionId, projectsRoot) {
3976
4000
  const files = [];
3977
- const mainAbs = join17(transcriptDir, `${sessionId}.jsonl`);
4001
+ const mainAbs = join18(transcriptDir, `${sessionId}.jsonl`);
3978
4002
  files.push({
3979
4003
  absPath: mainAbs,
3980
4004
  relPath: relative(projectsRoot, mainAbs),
@@ -3982,7 +4006,7 @@ function enumerateSessionTranscripts(transcriptDir, sessionId, projectsRoot) {
3982
4006
  isSubagent: false,
3983
4007
  subagentId: null
3984
4008
  });
3985
- const subDir = join17(transcriptDir, sessionId, "subagents");
4009
+ const subDir = join18(transcriptDir, sessionId, "subagents");
3986
4010
  let entries;
3987
4011
  try {
3988
4012
  entries = readdirSync4(subDir);
@@ -3991,8 +4015,8 @@ function enumerateSessionTranscripts(transcriptDir, sessionId, projectsRoot) {
3991
4015
  }
3992
4016
  for (const name of entries) {
3993
4017
  if (!name.endsWith(".jsonl")) continue;
3994
- const abs = join17(subDir, name);
3995
- const stem = basename(name, ".jsonl");
4018
+ const abs = join18(subDir, name);
4019
+ const stem = basename2(name, ".jsonl");
3996
4020
  files.push({
3997
4021
  absPath: abs,
3998
4022
  relPath: relative(projectsRoot, abs),
@@ -4191,7 +4215,7 @@ function extractTranscriptWindow(file, opts, from) {
4191
4215
  // src/lib/tool-call-cursor.ts
4192
4216
  import { existsSync as existsSync4, readFileSync as readFileSync15 } from "fs";
4193
4217
  import { homedir as homedir10 } from "os";
4194
- import { join as join18 } from "path";
4218
+ import { join as join19 } from "path";
4195
4219
  var COVERAGE_DISPOSITIONS = [
4196
4220
  "ok",
4197
4221
  "not_entitled",
@@ -4246,7 +4270,7 @@ function parseCursorKey(key) {
4246
4270
  function cursorStatePath(codeName, homeDir) {
4247
4271
  const home = homeDir ?? (process.env["HOME"]?.trim() || homedir10());
4248
4272
  const key = agentRuntimeKey(codeName, homeDir);
4249
- return join18(home, ".augmented", key, "tool-call-cursors.json");
4273
+ return join19(home, ".augmented", key, "tool-call-cursors.json");
4250
4274
  }
4251
4275
  function loadCursors(path) {
4252
4276
  const out = /* @__PURE__ */ new Map();
@@ -4659,7 +4683,7 @@ async function maybeScanToolCalls(args) {
4659
4683
  log2(`[tool-call-audit] ${codeName}: no path-hash salt available \u2014 file targets withheld`);
4660
4684
  }
4661
4685
  const home = args.homeDir ?? (process.env["HOME"]?.trim() || homedir11());
4662
- const projectsRoot = args.projectsRoot ?? join19(home, ".claude", "projects");
4686
+ const projectsRoot = args.projectsRoot ?? join20(home, ".claude", "projects");
4663
4687
  const transcriptDir = args.transcriptDir ?? sessionTranscriptDir(getProjectDir(codeName));
4664
4688
  const current = peekCurrentSession(codeName);
4665
4689
  const sessionIds = current ? [current.sessionId] : [];
@@ -4690,9 +4714,9 @@ async function maybeScanToolCalls(args) {
4690
4714
  // src/lib/activity-cache-monitor.ts
4691
4715
  import { existsSync as existsSync5, readFileSync as readFileSync16 } from "fs";
4692
4716
  import { homedir as homedir12 } from "os";
4693
- import { join as join20 } from "path";
4717
+ import { join as join21 } from "path";
4694
4718
  var MIN_CHECK_INTERVAL_MS7 = 6e4;
4695
- var STATS_CACHE_PATH = join20(homedir12(), ".claude", "stats-cache.json");
4719
+ var STATS_CACHE_PATH = join21(homedir12(), ".claude", "stats-cache.json");
4696
4720
  var ISO_DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
4697
4721
  var state6 = { lastObservedDate: null, lastCheckedAt: 0 };
4698
4722
  function selectNewDailyRows(raw, lastObservedDate) {
@@ -4973,10 +4997,10 @@ function computeChannelConfigHash(input) {
4973
4997
 
4974
4998
  // src/lib/channel-hash-cache.ts
4975
4999
  import { existsSync as existsSync6, readFileSync as readFileSync17, writeFileSync as writeFileSync7 } from "fs";
4976
- import { join as join21 } from "path";
5000
+ import { join as join22 } from "path";
4977
5001
  var CACHE_FILENAME = "channel-hash-cache.json";
4978
5002
  function getChannelHashCacheFile(configDir) {
4979
- return join21(configDir, CACHE_FILENAME);
5003
+ return join22(configDir, CACHE_FILENAME);
4980
5004
  }
4981
5005
  function loadChannelHashCache(target, configDir) {
4982
5006
  const path = getChannelHashCacheFile(configDir);
@@ -5004,7 +5028,7 @@ function saveChannelHashCache(source, configDir) {
5004
5028
 
5005
5029
  // src/lib/sender-policy-baseline.ts
5006
5030
  import { existsSync as existsSync7, readFileSync as readFileSync18 } from "fs";
5007
- import { join as join22 } from "path";
5031
+ import { join as join23 } from "path";
5008
5032
  var BASELINE_FILENAME = "sender-policy-baseline.json";
5009
5033
  var SENDER_POLICY_BASELINE_VERSION = 1;
5010
5034
  var BASELINE_CONCERNS = ["senderPolicy", "slackBehaviour", "msteamsBehaviour"];
@@ -5016,7 +5040,7 @@ function createDeliveryBaselineMaps() {
5016
5040
  };
5017
5041
  }
5018
5042
  function getSenderPolicyBaselineFile(configDir) {
5019
- return join22(configDir, BASELINE_FILENAME);
5043
+ return join23(configDir, BASELINE_FILENAME);
5020
5044
  }
5021
5045
  function loadSenderPolicyBaseline(target, configDir, log2) {
5022
5046
  const path = getSenderPolicyBaselineFile(configDir);
@@ -5546,7 +5570,7 @@ function planGlobalSkillSync(globalSkills, prevIds, hashOf, knownHash, options)
5546
5570
  }
5547
5571
 
5548
5572
  // src/lib/manager/integration-skill-cache.ts
5549
- import { join as join23 } from "path";
5573
+ import { join as join24 } from "path";
5550
5574
  function integrationSkillHashKey(agentId, skillId) {
5551
5575
  return `plugin-skill:${agentId}:${skillId}`;
5552
5576
  }
@@ -5562,16 +5586,16 @@ function forgetIntegrationSkill(cache3, agentId, skillId) {
5562
5586
  function removeIntegrationSkillFolder(opts) {
5563
5587
  forgetIntegrationSkill(opts.cache, opts.agentId, opts.entry);
5564
5588
  for (const dir of opts.dirs) {
5565
- opts.removeDir(join23(dir, opts.entry));
5589
+ opts.removeDir(join24(dir, opts.entry));
5566
5590
  }
5567
5591
  }
5568
5592
 
5569
5593
  // src/lib/manager/managed-skill-manifest.ts
5570
5594
  import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync19, writeFileSync as writeFileSync8 } from "fs";
5571
- import { dirname as dirname6, join as join24 } from "path";
5595
+ import { dirname as dirname7, join as join25 } from "path";
5572
5596
  var MANIFEST_VERSION = 1;
5573
5597
  function managedSkillManifestPath(agentRootDir) {
5574
- return join24(agentRootDir, "managed-skills.json");
5598
+ return join25(agentRootDir, "managed-skills.json");
5575
5599
  }
5576
5600
  function readManagedSkillManifest(path) {
5577
5601
  try {
@@ -5585,7 +5609,7 @@ function readManagedSkillManifest(path) {
5585
5609
  }
5586
5610
  function writeManagedSkillManifest(path, ids) {
5587
5611
  try {
5588
- mkdirSync6(dirname6(path), { recursive: true });
5612
+ mkdirSync6(dirname7(path), { recursive: true });
5589
5613
  const body = {
5590
5614
  version: MANIFEST_VERSION,
5591
5615
  globalSkillIds: [...ids].sort()
@@ -5703,7 +5727,7 @@ function resolveModelChain(refreshData) {
5703
5727
 
5704
5728
  // src/lib/manager/claude-auth.ts
5705
5729
  import { existsSync as existsSync9, rmSync as rmSync3 } from "fs";
5706
- import { join as join25 } from "path";
5730
+ import { join as join26 } from "path";
5707
5731
  import { homedir as homedir13 } from "os";
5708
5732
  async function applyClaudeAuthToEnv(childEnv, label) {
5709
5733
  const apiKey = getApiKey();
@@ -5716,9 +5740,9 @@ async function applyClaudeAuthToEnv(childEnv, label) {
5716
5740
  throw new Error("claude_auth_mode=api_key but /host/exchange returned no decrypted key");
5717
5741
  }
5718
5742
  childEnv.ANTHROPIC_API_KEY = exchange.anthropicApiKey;
5719
- const claudeDir = join25(homedir13(), ".claude");
5743
+ const claudeDir = join26(homedir13(), ".claude");
5720
5744
  for (const filename of [".credentials.json", "credentials.json"]) {
5721
- const p = join25(claudeDir, filename);
5745
+ const p = join26(claudeDir, filename);
5722
5746
  if (existsSync9(p)) {
5723
5747
  try {
5724
5748
  rmSync3(p, { force: true });
@@ -5801,7 +5825,7 @@ function heartbeatRuntimeAuthFields(probeVerdict) {
5801
5825
 
5802
5826
  // src/lib/manager/kanban/parsers.ts
5803
5827
  import { existsSync as existsSync10, readFileSync as readFileSync20 } from "fs";
5804
- import { join as join26 } from "path";
5828
+ import { join as join27 } from "path";
5805
5829
  var STANDUP_TEMPLATES = /* @__PURE__ */ new Set(["daily-standup", "end-of-day-summary"]);
5806
5830
  var TASK_UPDATE_TEMPLATES = /* @__PURE__ */ new Set(["hourly-status", "task-update"]);
5807
5831
  var PLAN_TEMPLATES = /* @__PURE__ */ new Set(["morning-plan"]);
@@ -5953,8 +5977,8 @@ function getBuiltInSkillContent(skillId) {
5953
5977
  if (builtInSkillCache.has(skillId)) return builtInSkillCache.get(skillId);
5954
5978
  try {
5955
5979
  const candidates = [
5956
- join26(process.cwd(), "skills", skillId, "SKILL.md"),
5957
- join26(new URL(".", import.meta.url).pathname, "..", "..", "..", "..", "..", "..", "skills", skillId, "SKILL.md")
5980
+ join27(process.cwd(), "skills", skillId, "SKILL.md"),
5981
+ join27(new URL(".", import.meta.url).pathname, "..", "..", "..", "..", "..", "..", "skills", skillId, "SKILL.md")
5958
5982
  ];
5959
5983
  for (const candidate of candidates) {
5960
5984
  if (existsSync10(candidate)) {
@@ -6100,11 +6124,11 @@ function formatBoardForPrompt(items, template) {
6100
6124
 
6101
6125
  // src/lib/manager/kanban/nudge-state-cache.ts
6102
6126
  import { existsSync as existsSync11, readFileSync as readFileSync21, writeFileSync as writeFileSync9 } from "fs";
6103
- import { join as join27 } from "path";
6127
+ import { join as join28 } from "path";
6104
6128
  var CACHE_FILENAME2 = "kanban-nudge-state.json";
6105
6129
  var KANBAN_NUDGE_STATE_VERSION = 1;
6106
6130
  function getKanbanNudgeStateFile(configDir) {
6107
- return join27(configDir, CACHE_FILENAME2);
6131
+ return join28(configDir, CACHE_FILENAME2);
6108
6132
  }
6109
6133
  function loadKanbanNudgeState(target, configDir) {
6110
6134
  const path = getKanbanNudgeStateFile(configDir);
@@ -6729,9 +6753,9 @@ function closeSessionRunForCode(codeName, outcome, reason) {
6729
6753
 
6730
6754
  // src/lib/manager/scheduler/kanban-route.ts
6731
6755
  import { createHash as createHash12 } from "crypto";
6732
- import { writeFileSync as writeFileSync10, renameSync as renameSync4, mkdirSync as mkdirSync7, readFileSync as readFileSync22, unlinkSync as unlinkSync2 } from "fs";
6756
+ import { writeFileSync as writeFileSync10, renameSync as renameSync5, mkdirSync as mkdirSync7, readFileSync as readFileSync22, unlinkSync as unlinkSync3 } from "fs";
6733
6757
  import { homedir as homedir14 } from "os";
6734
- import { join as join28, dirname as dirname7 } from "path";
6758
+ import { join as join29, dirname as dirname8 } from "path";
6735
6759
 
6736
6760
  // src/lib/manager/scheduler/notify.ts
6737
6761
  import { createHash as createHash11 } from "crypto";
@@ -7090,21 +7114,21 @@ function resolveScheduledSlackTarget(task) {
7090
7114
  }
7091
7115
  function stampScheduledTurnMarker(codeName, taskId, target) {
7092
7116
  try {
7093
- const file = join28(homedir14(), ".augmented", codeName, SCHEDULED_TURN_MARKER_FILENAME);
7117
+ const file = join29(homedir14(), ".augmented", codeName, SCHEDULED_TURN_MARKER_FILENAME);
7094
7118
  const marker = { ts: Date.now(), task_id: taskId, ...target ? { target } : {} };
7095
7119
  const tmp = `${file}.tmp`;
7096
7120
  writeFileSync10(tmp, JSON.stringify(marker), "utf8");
7097
- renameSync4(tmp, file);
7121
+ renameSync5(tmp, file);
7098
7122
  } catch (err) {
7099
7123
  log(`[scheduled-kanban] scheduled-turn marker write failed for '${codeName}': ${err.message}`);
7100
7124
  }
7101
7125
  }
7102
7126
  function clearScheduledTurnMarkerForTask(codeName, taskId) {
7103
- const file = join28(homedir14(), ".augmented", codeName, SCHEDULED_TURN_MARKER_FILENAME);
7127
+ const file = join29(homedir14(), ".augmented", codeName, SCHEDULED_TURN_MARKER_FILENAME);
7104
7128
  try {
7105
7129
  const raw = JSON.parse(readFileSync22(file, "utf8"));
7106
7130
  if (typeof raw?.task_id !== "string" || raw.task_id !== taskId) return;
7107
- unlinkSync2(file);
7131
+ unlinkSync3(file);
7108
7132
  log(`[scheduled-kanban] scheduled-turn marker cleared for '${codeName}' (task ${taskId} complete)`);
7109
7133
  } catch {
7110
7134
  }
@@ -7163,7 +7187,7 @@ async function routeScheduledTaskViaKanban(codeName, agentId, task, prompt, dura
7163
7187
  }
7164
7188
  try {
7165
7189
  const doorbell = directChatDoorbellPath(agentId, homedir14());
7166
- mkdirSync7(dirname7(doorbell), { recursive: true });
7190
+ mkdirSync7(dirname8(doorbell), { recursive: true });
7167
7191
  writeFileSync10(doorbell, String(Date.now()));
7168
7192
  } catch (err) {
7169
7193
  log(`[scheduled-kanban] doorbell ring failed for '${codeName}': ${err.message} (notice still queued)`);
@@ -7315,11 +7339,11 @@ async function processClaudeTaskResult(codeName, agentId, templateId, rawOutput,
7315
7339
  // src/lib/manager/scheduler/execution.ts
7316
7340
  import { createHash as createHash13 } from "crypto";
7317
7341
  import { homedir as homedir15 } from "os";
7318
- import { join as join30 } from "path";
7342
+ import { join as join31 } from "path";
7319
7343
 
7320
7344
  // src/lib/agent-serving-probe.ts
7321
7345
  import { readFileSync as readFileSync23, readdirSync as readdirSync5, statSync as statSync5 } from "fs";
7322
- import { join as join29 } from "path";
7346
+ import { join as join30 } from "path";
7323
7347
  var RATE_LIMIT_WINDOW_MS = 6 * 60 * 60 * 1e3;
7324
7348
  function probeRateLimit(args) {
7325
7349
  const now = args.now ?? /* @__PURE__ */ new Date();
@@ -7335,7 +7359,7 @@ function probeRateLimit(args) {
7335
7359
  let newest = UNKNOWN_RATE_LIMIT;
7336
7360
  for (const name of entries) {
7337
7361
  if (!name.endsWith(".jsonl")) continue;
7338
- const path = join29(dir, name);
7362
+ const path = join30(dir, name);
7339
7363
  try {
7340
7364
  const st = statSync5(path);
7341
7365
  if (!st.isFile() || st.mtimeMs < startMs) continue;
@@ -7406,7 +7430,7 @@ function shouldLogUsageCapDeferral(site, codeName, limitedUntil) {
7406
7430
 
7407
7431
  // src/lib/manager/scheduler/execution.ts
7408
7432
  function claudePidFilePath() {
7409
- return join30(homedir15(), ".augmented", "manager-claude-pids.json");
7433
+ return join31(homedir15(), ".augmented", "manager-claude-pids.json");
7410
7434
  }
7411
7435
  var inFlightClaudePids = /* @__PURE__ */ new Map();
7412
7436
  function registerClaudeSpawn(record) {
@@ -7477,7 +7501,7 @@ async function syncAndCheckClaudeScheduler(agent, tasks, boardItems, refreshData
7477
7501
 
7478
7502
  // src/lib/occupancy-gate.ts
7479
7503
  import { closeSync as closeSync2, openSync as openSync2, readdirSync as readdirSync6, readSync as readSync2, statSync as statSync6 } from "fs";
7480
- import { join as join31 } from "path";
7504
+ import { join as join32 } from "path";
7481
7505
  function rostersMeasuredZero(mode, attested, runtimeRunning) {
7482
7506
  return mode === "enforce" && attested && runtimeRunning;
7483
7507
  }
@@ -7566,10 +7590,10 @@ function candidateTranscriptPaths(dir) {
7566
7590
  let complete = true;
7567
7591
  for (const name of top) {
7568
7592
  if (name.endsWith(".jsonl")) {
7569
- paths.push(join31(dir, name));
7593
+ paths.push(join32(dir, name));
7570
7594
  continue;
7571
7595
  }
7572
- const subDir = join31(dir, name, "subagents");
7596
+ const subDir = join32(dir, name, "subagents");
7573
7597
  let subs;
7574
7598
  try {
7575
7599
  subs = readdirSync6(subDir);
@@ -7578,7 +7602,7 @@ function candidateTranscriptPaths(dir) {
7578
7602
  continue;
7579
7603
  }
7580
7604
  for (const sub of subs) {
7581
- if (sub.endsWith(".jsonl")) paths.push(join31(subDir, sub));
7605
+ if (sub.endsWith(".jsonl")) paths.push(join32(subDir, sub));
7582
7606
  }
7583
7607
  }
7584
7608
  return { paths, complete };
@@ -9060,9 +9084,9 @@ async function fireOpencodeScheduledTask(agent, task) {
9060
9084
 
9061
9085
  // src/lib/opencode-telegram-ingest.ts
9062
9086
  import { createHash as createHash16 } from "crypto";
9063
- import { existsSync as existsSync13, mkdirSync as mkdirSync8, readFileSync as readFileSync25, renameSync as renameSync5, unlinkSync as unlinkSync3, writeFileSync as writeFileSync11 } from "fs";
9087
+ import { existsSync as existsSync13, mkdirSync as mkdirSync8, readFileSync as readFileSync25, renameSync as renameSync6, unlinkSync as unlinkSync4, writeFileSync as writeFileSync11 } from "fs";
9064
9088
  import { randomUUID } from "crypto";
9065
- import { join as join32 } from "path";
9089
+ import { join as join33 } from "path";
9066
9090
 
9067
9091
  // src/lib/telegram-ingest.ts
9068
9092
  import https2 from "https";
@@ -9610,7 +9634,7 @@ function createFileOffsetStore(codeName, log2, currentBotId) {
9610
9634
  let filePath;
9611
9635
  try {
9612
9636
  dir = getFramework("opencode").getAgentDir(codeName);
9613
- filePath = join32(dir, "telegram-getupdates-offset-opencode.json");
9637
+ filePath = join33(dir, "telegram-getupdates-offset-opencode.json");
9614
9638
  } catch {
9615
9639
  dir = null;
9616
9640
  filePath = null;
@@ -9648,11 +9672,11 @@ function createFileOffsetStore(codeName, log2, currentBotId) {
9648
9672
  }),
9649
9673
  { mode: 384 }
9650
9674
  );
9651
- renameSync5(tmpPath, filePath);
9675
+ renameSync6(tmpPath, filePath);
9652
9676
  } catch (err) {
9653
9677
  log2(`[telegram-ingest:${codeName}] offset persist failed: ${err instanceof Error ? err.message : String(err)}`);
9654
9678
  try {
9655
- if (existsSync13(tmpPath)) unlinkSync3(tmpPath);
9679
+ if (existsSync13(tmpPath)) unlinkSync4(tmpPath);
9656
9680
  } catch {
9657
9681
  }
9658
9682
  }
@@ -9889,15 +9913,15 @@ function partitionActionableByPoison(actionable, states, config2) {
9889
9913
  }
9890
9914
 
9891
9915
  // src/lib/restart-flags.ts
9892
- import { existsSync as existsSync14, mkdirSync as mkdirSync9, readdirSync as readdirSync7, readFileSync as readFileSync26, renameSync as renameSync6, rmSync as rmSync4, writeFileSync as writeFileSync12 } from "fs";
9916
+ import { existsSync as existsSync14, mkdirSync as mkdirSync9, readdirSync as readdirSync7, readFileSync as readFileSync26, renameSync as renameSync7, rmSync as rmSync4, writeFileSync as writeFileSync12 } from "fs";
9893
9917
  import { homedir as homedir16 } from "os";
9894
- import { join as join33 } from "path";
9918
+ import { join as join34 } from "path";
9895
9919
  import { randomUUID as randomUUID2 } from "crypto";
9896
9920
  function restartFlagsDir() {
9897
- return join33(homedir16(), ".augmented", "restart-flags");
9921
+ return join34(homedir16(), ".augmented", "restart-flags");
9898
9922
  }
9899
9923
  function flagPath(codeName) {
9900
- return join33(restartFlagsDir(), `${codeName}.flag`);
9924
+ return join34(restartFlagsDir(), `${codeName}.flag`);
9901
9925
  }
9902
9926
  function readRestartFlags() {
9903
9927
  const dir = restartFlagsDir();
@@ -9906,7 +9930,7 @@ function readRestartFlags() {
9906
9930
  for (const entry of readdirSync7(dir)) {
9907
9931
  if (!entry.endsWith(".flag")) continue;
9908
9932
  try {
9909
- const raw = readFileSync26(join33(dir, entry), "utf8");
9933
+ const raw = readFileSync26(join34(dir, entry), "utf8");
9910
9934
  const parsed = JSON.parse(raw);
9911
9935
  if (typeof parsed.codeName !== "string" || parsed.codeName.length === 0) {
9912
9936
  parsed.codeName = entry.replace(/\.flag$/, "");
@@ -10024,8 +10048,8 @@ async function sendError(flag, opts, text) {
10024
10048
  }
10025
10049
 
10026
10050
  // src/lib/restart-context.ts
10027
- import { readdirSync as readdirSync8, readFileSync as readFileSync27, writeFileSync as writeFileSync13, mkdirSync as mkdirSync10, unlinkSync as unlinkSync4 } from "fs";
10028
- import { dirname as dirname8, join as join34 } from "path";
10051
+ import { readdirSync as readdirSync8, readFileSync as readFileSync27, writeFileSync as writeFileSync13, mkdirSync as mkdirSync10, unlinkSync as unlinkSync5 } from "fs";
10052
+ import { dirname as dirname9, join as join35 } from "path";
10029
10053
  var SLACK_PENDING_INBOUND_DIRNAME = "slack-pending-inbound";
10030
10054
  var SLACK_RESTART_CONTEXT_DIRNAME = "slack-restart-context";
10031
10055
  var MAX_TOPIC_CHARS = 140;
@@ -10034,13 +10058,13 @@ var RECONSTRUCT_WINDOW_MS = 7 * 24 * 60 * 60 * 1e3;
10034
10058
  var WINDOW_PAD_MS3 = 5 * 6e4;
10035
10059
  var DEFAULT_MAX_MARKERS_PER_AGENT = 25;
10036
10060
  function augmentedAgentDir(codeName) {
10037
- return dirname8(getProjectDir(codeName));
10061
+ return dirname9(getProjectDir(codeName));
10038
10062
  }
10039
10063
  function slackPendingInboundDir(codeName) {
10040
- return join34(augmentedAgentDir(codeName), SLACK_PENDING_INBOUND_DIRNAME);
10064
+ return join35(augmentedAgentDir(codeName), SLACK_PENDING_INBOUND_DIRNAME);
10041
10065
  }
10042
10066
  function slackRestartContextDir(codeName) {
10043
- return join34(augmentedAgentDir(codeName), SLACK_RESTART_CONTEXT_DIRNAME);
10067
+ return join35(augmentedAgentDir(codeName), SLACK_RESTART_CONTEXT_DIRNAME);
10044
10068
  }
10045
10069
  function sanitizeTopic(raw) {
10046
10070
  const cleaned = raw.replace(/\s+/g, " ").trim().replace(/[<>]/g, " ").replace(/\s+/g, " ").trim();
@@ -10100,7 +10124,7 @@ function pruneHintsExcept(codeName, freshFilenames) {
10100
10124
  if (!filename.endsWith(".json")) continue;
10101
10125
  if (freshFilenames.has(filename)) continue;
10102
10126
  try {
10103
- unlinkSync4(join34(ctxDir, filename));
10127
+ unlinkSync5(join35(ctxDir, filename));
10104
10128
  } catch {
10105
10129
  }
10106
10130
  }
@@ -10121,7 +10145,7 @@ function refreshSlackRestartContextHints(codeNames, opts = {}) {
10121
10145
  }
10122
10146
  const markers = [];
10123
10147
  for (const filename of markerFilenames.slice(0, cap)) {
10124
- const parsed = readStrandedMarker(join34(markerDir, filename));
10148
+ const parsed = readStrandedMarker(join35(markerDir, filename));
10125
10149
  if (parsed) markers.push({ filename, channel: parsed.channel, thread_ts: parsed.thread_ts });
10126
10150
  }
10127
10151
  if (markers.length === 0) {
@@ -10135,7 +10159,7 @@ function refreshSlackRestartContextHints(codeNames, opts = {}) {
10135
10159
  const freshFilenames = /* @__PURE__ */ new Set();
10136
10160
  for (const { filename, hint } of hints) {
10137
10161
  try {
10138
- writeHintFile(join34(ctxDir, filename), ctxDir, hint);
10162
+ writeHintFile(join35(ctxDir, filename), ctxDir, hint);
10139
10163
  freshFilenames.add(filename);
10140
10164
  } catch (err) {
10141
10165
  log2(`[restart-context] ${codeName}: hint write failed for ${filename}: ${err.message}`);
@@ -11512,7 +11536,7 @@ var dayRolloverInboundHold = /* @__PURE__ */ new Map();
11512
11536
  var INBOUND_HOLD_EPISODE_GAP_MS = 12e4;
11513
11537
  async function channelInboundActivityAgeSecondsFor(codeName) {
11514
11538
  const { newestPendingInboundActivityMtimeMs } = await import("../responsiveness-probe-JAME5YLS.js");
11515
- const newest = newestPendingInboundActivityMtimeMs(dirname9(paneLogPath(codeName)));
11539
+ const newest = newestPendingInboundActivityMtimeMs(dirname10(paneLogPath(codeName)));
11516
11540
  if (newest === null) return null;
11517
11541
  return Math.max(0, Math.floor((Date.now() - newest) / 1e3));
11518
11542
  }
@@ -11761,7 +11785,7 @@ var runningChannelSecretHashes = /* @__PURE__ */ new Map();
11761
11785
  var sessionLaunchManagedStructure = /* @__PURE__ */ new Map();
11762
11786
  function projectMcpHash(_codeName, projectDir) {
11763
11787
  try {
11764
- const raw = readFileSync28(join35(projectDir, ".mcp.json"), "utf-8");
11788
+ const raw = readFileSync28(join36(projectDir, ".mcp.json"), "utf-8");
11765
11789
  return createHash17("sha256").update(canonicalJson(JSON.parse(raw))).digest("hex");
11766
11790
  } catch {
11767
11791
  return null;
@@ -11769,7 +11793,7 @@ function projectMcpHash(_codeName, projectDir) {
11769
11793
  }
11770
11794
  function projectMcpKeys(_codeName, projectDir) {
11771
11795
  try {
11772
- const raw = readFileSync28(join35(projectDir, ".mcp.json"), "utf-8");
11796
+ const raw = readFileSync28(join36(projectDir, ".mcp.json"), "utf-8");
11773
11797
  const parsed = JSON.parse(raw);
11774
11798
  const servers = parsed.mcpServers;
11775
11799
  if (!servers || typeof servers !== "object") return /* @__PURE__ */ new Set();
@@ -11787,7 +11811,7 @@ function seedSessionLaunchBaselines(codeName, projectDir) {
11787
11811
  else runningMcpServerKeys.delete(codeName);
11788
11812
  let launchStructure = null;
11789
11813
  try {
11790
- const raw = readFileSync28(join35(projectDir, ".mcp.json"), "utf-8");
11814
+ const raw = readFileSync28(join36(projectDir, ".mcp.json"), "utf-8");
11791
11815
  launchStructure = managedMcpStructureHashFromFile(
11792
11816
  JSON.parse(raw),
11793
11817
  isManagedMcpServerKey
@@ -11913,7 +11937,7 @@ async function runAgentSessionToolBindProbes(agent, integrations, projectDir, op
11913
11937
  if (result && result.rebindCandidates.length > 0 && hostFlagStore().getBoolean("session-tool-rebind")) {
11914
11938
  let mcpJsonForRebind = null;
11915
11939
  try {
11916
- mcpJsonForRebind = JSON.parse(readFileSync28(join35(projectDir, ".mcp.json"), "utf-8"));
11940
+ mcpJsonForRebind = JSON.parse(readFileSync28(join36(projectDir, ".mcp.json"), "utf-8"));
11917
11941
  } catch {
11918
11942
  mcpJsonForRebind = null;
11919
11943
  }
@@ -12058,7 +12082,7 @@ function checkMcpConfigDriftAndScheduleRestart(codeName, projectDir) {
12058
12082
  function projectChannelSecretHash(projectDir) {
12059
12083
  try {
12060
12084
  const entries = parseEnvIntegrations(
12061
- readFileSync28(join35(projectDir, ".env.integrations"), "utf-8")
12085
+ readFileSync28(join36(projectDir, ".env.integrations"), "utf-8")
12062
12086
  );
12063
12087
  return channelSecretValueHash(entries, CHANNEL_SECRET_ENV_KEYS);
12064
12088
  } catch {
@@ -12154,7 +12178,7 @@ var agentRestartTimezoneInputs = /* @__PURE__ */ new Map();
12154
12178
  var lastVersionCheckAt = 0;
12155
12179
  var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
12156
12180
  var lastResponsivenessProbeAt = 0;
12157
- var agtCliVersion = true ? "0.28.643" : "dev";
12181
+ var agtCliVersion = true ? "0.28.644" : "dev";
12158
12182
  function resolveBrewPath(execFileSync3) {
12159
12183
  try {
12160
12184
  const out = execFileSync3("which", ["brew"], { timeout: 5e3 }).toString().trim();
@@ -12249,7 +12273,7 @@ async function ensureToolkitCli(toolkitSlug) {
12249
12273
  toolkitCliEnsured.add(toolkitSlug);
12250
12274
  return;
12251
12275
  }
12252
- brewBinDir = dirname9(brewPath);
12276
+ brewBinDir = dirname10(brewPath);
12253
12277
  const isRoot = typeof process.getuid === "function" && process.getuid() === 0;
12254
12278
  log(`[toolkit-install] ${toolkitSlug}: installing via brew (${pkg})\u2026`);
12255
12279
  if (isRoot) {
@@ -12503,7 +12527,7 @@ function ensureClaudeManagedSettings(path = claudeManagedSettingsPath()) {
12503
12527
  }
12504
12528
  if (settings.channelsEnabled === true) return "ok";
12505
12529
  settings.channelsEnabled = true;
12506
- mkdirSync11(dirname9(path), { recursive: true });
12530
+ mkdirSync11(dirname10(path), { recursive: true });
12507
12531
  writeFileSync14(path, `${JSON.stringify(settings, null, 2)}
12508
12532
  `);
12509
12533
  log(`[managed-settings] set channelsEnabled:true in ${path} (ENG-5786 \u2014 unblocks Claude Code channels)`);
@@ -12542,7 +12566,7 @@ async function ensureOpencodeBinary() {
12542
12566
  try {
12543
12567
  const prefix = execFileSync3("npm", ["prefix", "-g"], { encoding: "utf-8", timeout: 1e4 }).trim();
12544
12568
  if (prefix) {
12545
- const npmBin = join35(prefix, "bin");
12569
+ const npmBin = join36(prefix, "bin");
12546
12570
  const current = (process.env.PATH ?? "").split(pathDelimiter);
12547
12571
  if (!current.includes(npmBin)) {
12548
12572
  process.env.PATH = [npmBin, ...current.filter(Boolean)].join(pathDelimiter);
@@ -12599,7 +12623,7 @@ async function ensureFrameworkBinary(frameworkId) {
12599
12623
  log(`Claude Code install failed: ${err.message}`);
12600
12624
  return;
12601
12625
  }
12602
- const brewBinDir = dirname9(brewPath);
12626
+ const brewBinDir = dirname10(brewPath);
12603
12627
  if (!process.env.PATH?.split(":").includes(brewBinDir)) {
12604
12628
  process.env.PATH = `${brewBinDir}:${process.env.PATH ?? ""}`;
12605
12629
  }
@@ -12659,7 +12683,7 @@ ${r.stderr}`;
12659
12683
  }
12660
12684
  var UPDATE_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
12661
12685
  function selfUpdateAppliedMarkerPath() {
12662
- return join35(homedir17(), ".augmented", ".last-self-update-applied");
12686
+ return join36(homedir17(), ".augmented", ".last-self-update-applied");
12663
12687
  }
12664
12688
  var selfUpdateUpToDateLogged = false;
12665
12689
  var selfUpdatePinnedLogged = false;
@@ -12688,7 +12712,7 @@ async function checkAndUpdateCli(opts) {
12688
12712
  const isNpmGlobal = !isBrewFormula && resolvedPath.includes("node_modules");
12689
12713
  if (!isBrewFormula && !isNpmGlobal) return "noop";
12690
12714
  const { readFileSync: readF, writeFileSync: writeF } = await import("fs");
12691
- const markerPath = join35(homedir17(), ".augmented", ".last-update-check");
12715
+ const markerPath = join36(homedir17(), ".augmented", ".last-update-check");
12692
12716
  if (!force) {
12693
12717
  try {
12694
12718
  const lastCheck = parseInt(readF(markerPath, "utf-8").trim(), 10);
@@ -13141,12 +13165,12 @@ async function checkClaudeAuth() {
13141
13165
  var evalEmptyMcpConfigPath = null;
13142
13166
  function ensureEvalEmptyMcpConfig() {
13143
13167
  if (evalEmptyMcpConfigPath && existsSync15(evalEmptyMcpConfigPath)) return evalEmptyMcpConfigPath;
13144
- const dir = join35(homedir17(), ".augmented");
13168
+ const dir = join36(homedir17(), ".augmented");
13145
13169
  try {
13146
13170
  mkdirSync11(dir, { recursive: true });
13147
13171
  } catch {
13148
13172
  }
13149
- const p = join35(dir, ".eval-empty-mcp.json");
13173
+ const p = join36(dir, ".eval-empty-mcp.json");
13150
13174
  writeFileSync14(p, JSON.stringify({ mcpServers: {} }));
13151
13175
  evalEmptyMcpConfigPath = p;
13152
13176
  return p;
@@ -13241,10 +13265,10 @@ function resolveConversationEvalBackend() {
13241
13265
  return conversationEvalBackend;
13242
13266
  }
13243
13267
  function getStateFile() {
13244
- return join35(config?.configDir ?? join35(process.env["HOME"] ?? "/tmp", ".augmented"), "manager-state.json");
13268
+ return join36(config?.configDir ?? join36(process.env["HOME"] ?? "/tmp", ".augmented"), "manager-state.json");
13245
13269
  }
13246
13270
  function channelHashCacheDir() {
13247
- return config?.configDir ?? join35(process.env["HOME"] ?? "/tmp", ".augmented");
13271
+ return config?.configDir ?? join36(process.env["HOME"] ?? "/tmp", ".augmented");
13248
13272
  }
13249
13273
  function loadChannelHashCache2() {
13250
13274
  loadChannelHashCache(agentState.knownChannelConfigHashes, channelHashCacheDir());
@@ -13298,7 +13322,7 @@ function removeDeliveryBaselineEntries(agentId) {
13298
13322
  var _channelQuarantineStore = null;
13299
13323
  function channelQuarantineStore() {
13300
13324
  if (!_channelQuarantineStore) {
13301
- const dir = config?.configDir ?? join35(process.env["HOME"] ?? "/tmp", ".augmented");
13325
+ const dir = config?.configDir ?? join36(process.env["HOME"] ?? "/tmp", ".augmented");
13302
13326
  _channelQuarantineStore = new ChannelQuarantineStore(defaultQuarantinePath(dir));
13303
13327
  }
13304
13328
  return _channelQuarantineStore;
@@ -13315,7 +13339,7 @@ function claudeMdSizeFor(codeName) {
13315
13339
  var _hostFlagStore = null;
13316
13340
  function hostFlagStore() {
13317
13341
  if (!_hostFlagStore) {
13318
- const dir = config?.configDir ?? join35(process.env["HOME"] ?? "/tmp", ".augmented");
13342
+ const dir = config?.configDir ?? join36(process.env["HOME"] ?? "/tmp", ".augmented");
13319
13343
  _hostFlagStore = new HostFlagStore({ cachePath: defaultFlagsCachePath(dir), log });
13320
13344
  }
13321
13345
  return _hostFlagStore;
@@ -13389,12 +13413,12 @@ function parseSkillFrontmatter(content) {
13389
13413
  }
13390
13414
  async function refreshSkillsIndexInClaudeMd(configDir, codeName, log2) {
13391
13415
  const { readdirSync: readdirSync10, readFileSync: rfs, existsSync: ex, writeFileSync: writeFileSync15 } = await import("fs");
13392
- const skillsDir = join35(configDir, codeName, "project", ".claude", "skills");
13393
- const claudeMdPath = join35(configDir, codeName, "project", "CLAUDE.md");
13416
+ const skillsDir = join36(configDir, codeName, "project", ".claude", "skills");
13417
+ const claudeMdPath = join36(configDir, codeName, "project", "CLAUDE.md");
13394
13418
  if (!ex(skillsDir) || !ex(claudeMdPath)) return;
13395
13419
  const entries = [];
13396
13420
  for (const dir of readdirSync10(skillsDir).sort()) {
13397
- const skillFile = join35(skillsDir, dir, "SKILL.md");
13421
+ const skillFile = join36(skillsDir, dir, "SKILL.md");
13398
13422
  if (!ex(skillFile)) continue;
13399
13423
  try {
13400
13424
  const { name, description } = parseSkillFrontmatter(rfs(skillFile, "utf-8"));
@@ -13898,10 +13922,10 @@ async function pollCycleInner() {
13898
13922
  const paneTail = readFileSync28(paneLogPath(codeName), "utf8").slice(-65536);
13899
13923
  const transient = detectTransientApiErrorInLog(paneTail);
13900
13924
  if (transient) {
13901
- const wedgeHome = join35(homedir17(), ".augmented", codeName);
13925
+ const wedgeHome = join36(homedir17(), ".augmented", codeName);
13902
13926
  if (existsSync15(wedgeHome)) {
13903
13927
  atomicWriteFileSync(
13904
- join35(wedgeHome, "watchdog-give-up.json"),
13928
+ join36(wedgeHome, "watchdog-give-up.json"),
13905
13929
  JSON.stringify({
13906
13930
  gave_up_at: wedgeNow.toISOString(),
13907
13931
  reason: "transient_overload"
@@ -14198,7 +14222,7 @@ async function pollCycleInner() {
14198
14222
  const adapter = resolveAgentFramework(prev.codeName);
14199
14223
  stopAgentRuntime2(prev.codeName, "removed-from-host");
14200
14224
  killAgentChannelProcesses(prev.codeName, { log });
14201
- const agentDir = join35(adapter.getAgentDir(prev.codeName), "provision");
14225
+ const agentDir = join36(adapter.getAgentDir(prev.codeName), "provision");
14202
14226
  await cleanupAgentFiles(prev.codeName, agentDir);
14203
14227
  clearAgentCaches(prev.agentId, prev.codeName);
14204
14228
  }
@@ -14285,10 +14309,10 @@ async function pollCycleInner() {
14285
14309
  // pending-inbound marker. Best-effort: a write failure is logged by
14286
14310
  // the watchdog, never fails the poll cycle.
14287
14311
  signalGiveUp: (codeName) => {
14288
- const dir = join35(homedir17(), ".augmented", codeName);
14312
+ const dir = join36(homedir17(), ".augmented", codeName);
14289
14313
  if (!existsSync15(dir)) return;
14290
14314
  atomicWriteFileSync(
14291
- join35(dir, "watchdog-give-up.json"),
14315
+ join36(dir, "watchdog-give-up.json"),
14292
14316
  JSON.stringify({ gave_up_at: (/* @__PURE__ */ new Date()).toISOString() })
14293
14317
  );
14294
14318
  },
@@ -14309,7 +14333,7 @@ async function pollCycleInner() {
14309
14333
  const dir = getFramework("claude-code").getAgentDir(codeName);
14310
14334
  if (!existsSync15(dir)) return;
14311
14335
  atomicWriteFileSync(
14312
- join35(dir, "watchdog-give-up.json"),
14336
+ join36(dir, "watchdog-give-up.json"),
14313
14337
  JSON.stringify({
14314
14338
  gave_up_at: (/* @__PURE__ */ new Date()).toISOString(),
14315
14339
  reason: "usage_limit",
@@ -14571,7 +14595,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
14571
14595
  }
14572
14596
  const now = (/* @__PURE__ */ new Date()).toISOString();
14573
14597
  const adapter = resolveAgentFramework(agent.code_name);
14574
- let agentDir = join35(adapter.getAgentDir(agent.code_name), "provision");
14598
+ let agentDir = join36(adapter.getAgentDir(agent.code_name), "provision");
14575
14599
  if (agent.status === "draft" || agent.status === "paused") {
14576
14600
  if (previousKnownStatus !== agent.status) {
14577
14601
  log(`Agent '${agent.code_name}' is ${agent.status}, skipping provisioning`);
@@ -14745,7 +14769,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
14745
14769
  const frameworkId = refreshData.agent.framework ?? DEFAULT_FRAMEWORK;
14746
14770
  agentFrameworkCache.set(agent.code_name, frameworkId);
14747
14771
  const frameworkAdapter = getFramework(frameworkId);
14748
- agentDir = join35(frameworkAdapter.getAgentDir(agent.code_name), "provision");
14772
+ agentDir = join36(frameworkAdapter.getAgentDir(agent.code_name), "provision");
14749
14773
  cacheAgentDeliveryMetadata(agent.code_name, refreshData);
14750
14774
  agentRestartTimezoneInputs.set(agent.code_name, {
14751
14775
  agentTimezone: typeof refreshData.agent.timezone === "string" ? refreshData.agent.timezone : null,
@@ -14794,7 +14818,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
14794
14818
  const changedFiles = [];
14795
14819
  mkdirSync11(agentDir, { recursive: true });
14796
14820
  for (const artifact of artifacts) {
14797
- const filePath = join35(agentDir, artifact.relativePath);
14821
+ const filePath = join36(agentDir, artifact.relativePath);
14798
14822
  let existingHash;
14799
14823
  let newHash;
14800
14824
  let writeContent = artifact.content;
@@ -14813,7 +14837,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
14813
14837
  };
14814
14838
  newHash = sha256(stripDynamicSections(artifact.content));
14815
14839
  try {
14816
- const projectClaudeMd = join35(config.configDir, agent.code_name, "project", "CLAUDE.md");
14840
+ const projectClaudeMd = join36(config.configDir, agent.code_name, "project", "CLAUDE.md");
14817
14841
  const existing = readFileSync28(projectClaudeMd, "utf-8");
14818
14842
  existingHash = sha256(stripDynamicSections(existing));
14819
14843
  } catch {
@@ -14864,13 +14888,13 @@ async function processAgent(agent, agentStates, managedToolkits) {
14864
14888
  }
14865
14889
  }
14866
14890
  if (changedFiles.length > 0) {
14867
- const isFirst = !existsSync15(join35(agentDir, "CHARTER.md"));
14891
+ const isFirst = !existsSync15(join36(agentDir, "CHARTER.md"));
14868
14892
  const verb = isFirst ? "Provisioning" : "Updating";
14869
14893
  const fileNames = changedFiles.map((f) => f.relativePath).join(", ");
14870
14894
  log(`${verb} '${agent.code_name}': ${fileNames}`);
14871
14895
  for (const file of changedFiles) {
14872
- const filePath = join35(agentDir, file.relativePath);
14873
- mkdirSync11(dirname9(filePath), { recursive: true });
14896
+ const filePath = join36(agentDir, file.relativePath);
14897
+ mkdirSync11(dirname10(filePath), { recursive: true });
14874
14898
  if (file.relativePath === ".mcp.json") {
14875
14899
  safeWriteJsonAtomic(filePath, file.content, { mode: 384 });
14876
14900
  } else {
@@ -14878,12 +14902,12 @@ async function processAgent(agent, agentStates, managedToolkits) {
14878
14902
  }
14879
14903
  }
14880
14904
  try {
14881
- const provSkillsDir = join35(agentDir, ".claude", "skills");
14905
+ const provSkillsDir = join36(agentDir, ".claude", "skills");
14882
14906
  if (existsSync15(provSkillsDir)) {
14883
14907
  for (const folder of readdirSync9(provSkillsDir)) {
14884
14908
  if (folder.startsWith("knowledge-")) {
14885
14909
  try {
14886
- rmSync5(join35(provSkillsDir, folder), { recursive: true });
14910
+ rmSync5(join36(provSkillsDir, folder), { recursive: true });
14887
14911
  } catch {
14888
14912
  }
14889
14913
  }
@@ -14896,7 +14920,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
14896
14920
  const trackedFiles2 = frameworkAdapter.driftTrackedFiles();
14897
14921
  const hashes = /* @__PURE__ */ new Map();
14898
14922
  for (const file of trackedFiles2) {
14899
- const h = hashFile(join35(agentDir, file));
14923
+ const h = hashFile(join36(agentDir, file));
14900
14924
  if (h) hashes.set(file, h);
14901
14925
  }
14902
14926
  agentState.writtenHashes.set(agent.agent_id, hashes);
@@ -14914,14 +14938,14 @@ async function processAgent(agent, agentStates, managedToolkits) {
14914
14938
  }
14915
14939
  if (Array.isArray(refreshData.workflows)) {
14916
14940
  try {
14917
- const provWorkflowsDir = join35(agentDir, ".claude", "workflows");
14941
+ const provWorkflowsDir = join36(agentDir, ".claude", "workflows");
14918
14942
  if (existsSync15(provWorkflowsDir)) {
14919
14943
  const expected = new Set(refreshData.workflows.map((w) => `${w.name}.js`));
14920
14944
  for (const file of readdirSync9(provWorkflowsDir)) {
14921
14945
  if (!file.endsWith(".js")) continue;
14922
14946
  if (expected.has(file)) continue;
14923
14947
  try {
14924
- rmSync5(join35(provWorkflowsDir, file));
14948
+ rmSync5(join36(provWorkflowsDir, file));
14925
14949
  } catch {
14926
14950
  }
14927
14951
  }
@@ -15003,7 +15027,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
15003
15027
  if (written && existsSync15(agentDir)) {
15004
15028
  const driftedFiles = [];
15005
15029
  for (const [file, expectedHash] of written) {
15006
- const localHash = hashFile(join35(agentDir, file));
15030
+ const localHash = hashFile(join36(agentDir, file));
15007
15031
  if (localHash && localHash !== expectedHash) {
15008
15032
  driftedFiles.push(file);
15009
15033
  }
@@ -15014,7 +15038,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
15014
15038
  try {
15015
15039
  const localHashes = {};
15016
15040
  for (const file of driftedFiles) {
15017
- localHashes[file] = hashFile(join35(agentDir, file));
15041
+ localHashes[file] = hashFile(join36(agentDir, file));
15018
15042
  }
15019
15043
  await api.post("/host/drift", {
15020
15044
  agent_id: agent.agent_id,
@@ -15216,7 +15240,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
15216
15240
  const addedChannels = [...restartDecision.added];
15217
15241
  const writeDmNoticeMarkers = isChannelAddRestart ? () => {
15218
15242
  try {
15219
- const agentAugmentedDir = join35(homedir17(), ".augmented", agent.code_name);
15243
+ const agentAugmentedDir = join36(homedir17(), ".augmented", agent.code_name);
15220
15244
  mkdirSync11(agentAugmentedDir, { recursive: true });
15221
15245
  const markerJson = JSON.stringify({
15222
15246
  version: 1,
@@ -15224,7 +15248,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
15224
15248
  added: addedChannels
15225
15249
  });
15226
15250
  for (const file of ["slack-channel-add-restart.json", "telegram-channel-add-restart.json"]) {
15227
- atomicWriteFileSync(join35(agentAugmentedDir, file), markerJson);
15251
+ atomicWriteFileSync(join36(agentAugmentedDir, file), markerJson);
15228
15252
  }
15229
15253
  } catch (err) {
15230
15254
  log(`[hot-reload] channel-add DM-notice marker write failed for '${agent.code_name}' (non-fatal): ${err.message}`);
@@ -15413,18 +15437,18 @@ async function processAgent(agent, agentStates, managedToolkits) {
15413
15437
  if (agentSessionMode === "persistent" && (agentFrameworkCache.get(agent.code_name) ?? DEFAULT_FRAMEWORK) === "claude-code") {
15414
15438
  try {
15415
15439
  const agentProvisionDir = agentDir;
15416
- const projectDir = join35(homedir17(), ".augmented", agent.code_name, "project");
15440
+ const projectDir = join36(homedir17(), ".augmented", agent.code_name, "project");
15417
15441
  mkdirSync11(agentProvisionDir, { recursive: true });
15418
15442
  mkdirSync11(projectDir, { recursive: true });
15419
- const provisionMcpPath = join35(agentProvisionDir, ".mcp.json");
15420
- const projectMcpPath = join35(projectDir, ".mcp.json");
15443
+ const provisionMcpPath = join36(agentProvisionDir, ".mcp.json");
15444
+ const projectMcpPath = join36(projectDir, ".mcp.json");
15421
15445
  let mcpConfig = { mcpServers: {} };
15422
15446
  try {
15423
15447
  mcpConfig = JSON.parse(readFileSync28(provisionMcpPath, "utf-8"));
15424
15448
  if (!mcpConfig.mcpServers) mcpConfig.mcpServers = {};
15425
15449
  } catch {
15426
15450
  }
15427
- const localDirectChatChannel = join35(homedir17(), ".augmented", "_mcp", "direct-chat-channel.js");
15451
+ const localDirectChatChannel = join36(homedir17(), ".augmented", "_mcp", "direct-chat-channel.js");
15428
15452
  const directChatTeamSettings = refreshData.team?.settings;
15429
15453
  const directChatTz = (() => {
15430
15454
  const tz = directChatTeamSettings?.["timezone"];
@@ -15450,7 +15474,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
15450
15474
  // ~/.augmented/<codeName>/.current-turn-initiator.json. Note getAgentDir
15451
15475
  // returns the agent root (NOT the /provision subdir `agentDir` points at),
15452
15476
  // so it byte-matches the broker readers' path.
15453
- AGT_TURN_INITIATOR_FILE: join35(
15477
+ AGT_TURN_INITIATOR_FILE: join36(
15454
15478
  frameworkAdapter.getAgentDir(agent.code_name),
15455
15479
  ".current-turn-initiator.json"
15456
15480
  )
@@ -15470,7 +15494,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
15470
15494
  log(`Channel credentials written for '${agent.code_name}/direct-chat'`);
15471
15495
  }
15472
15496
  }
15473
- const staleChannelsPath = join35(projectDir, ".mcp-channels.json");
15497
+ const staleChannelsPath = join36(projectDir, ".mcp-channels.json");
15474
15498
  if (existsSync15(staleChannelsPath)) {
15475
15499
  try {
15476
15500
  rmSync5(staleChannelsPath, { force: true });
@@ -15560,7 +15584,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
15560
15584
  }
15561
15585
  if (hostFlagStore().getBoolean("connectivity-probe")) {
15562
15586
  try {
15563
- const probeProjectDir = join35(homedir17(), ".augmented", agent.code_name, "project");
15587
+ const probeProjectDir = join36(homedir17(), ".augmented", agent.code_name, "project");
15564
15588
  let probeSet = integrations;
15565
15589
  try {
15566
15590
  const quarantined = await api.post("/host/agent-integrations/quarantined", { agent_id: agent.agent_id });
@@ -15606,7 +15630,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
15606
15630
  const forceDue = attemptsLeft > 0;
15607
15631
  let probeRan = false;
15608
15632
  try {
15609
- const probeProjectDir = join35(homedir17(), ".augmented", agent.code_name, "project");
15633
+ const probeProjectDir = join36(homedir17(), ".augmented", agent.code_name, "project");
15610
15634
  probeRan = await runAgentSessionToolBindProbes(agent, integrations, probeProjectDir, { forceDue });
15611
15635
  } catch (err) {
15612
15636
  log(`Session-tool-bind probe failed for '${agent.code_name}': ${err.message}`);
@@ -15683,8 +15707,8 @@ async function processAgent(agent, agentStates, managedToolkits) {
15683
15707
  const intHash = computeIntegrationsHash(integrations);
15684
15708
  const prevIntHash = agentState.knownIntegrationHashes.get(agent.agent_id);
15685
15709
  if (intHash !== prevIntHash) {
15686
- const projectDir = join35(homedir17(), ".augmented", agent.code_name, "project");
15687
- const envIntPath = join35(projectDir, ".env.integrations");
15710
+ const projectDir = join36(homedir17(), ".augmented", agent.code_name, "project");
15711
+ const envIntPath = join36(projectDir, ".env.integrations");
15688
15712
  let preWriteEnv;
15689
15713
  try {
15690
15714
  preWriteEnv = readFileSync28(envIntPath, "utf-8");
@@ -15706,7 +15730,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
15706
15730
  }
15707
15731
  if (fw === "claude-code" && isSessionHealthy(agent.code_name)) {
15708
15732
  try {
15709
- const projectMcpPath = join35(projectDir, ".mcp.json");
15733
+ const projectMcpPath = join36(projectDir, ".mcp.json");
15710
15734
  const postWriteEnv = readFileSync28(envIntPath, "utf-8");
15711
15735
  const mcpContent = readFileSync28(projectMcpPath, "utf-8");
15712
15736
  const changedVars = diffEnvIntegrations(preWriteEnv, postWriteEnv);
@@ -15976,12 +16000,12 @@ async function processAgent(agent, agentStates, managedToolkits) {
15976
16000
  const frameworkId2 = frameworkAdapter.id;
15977
16001
  const candidateSkillDirs = [
15978
16002
  // Claude Code — framework runtime tree
15979
- join35(homedir18(), ".augmented", agent.code_name, "skills"),
16003
+ join36(homedir18(), ".augmented", agent.code_name, "skills"),
15980
16004
  // Claude Code — project tree
15981
- join35(homedir18(), ".augmented", agent.code_name, "project", ".claude", "skills"),
16005
+ join36(homedir18(), ".augmented", agent.code_name, "project", ".claude", "skills"),
15982
16006
  // Defensive: legacy provision-side path, not currently an
15983
16007
  // install target but cheap to sweep.
15984
- join35(agentDir, ".claude", "skills")
16008
+ join36(agentDir, ".claude", "skills")
15985
16009
  ];
15986
16010
  const existingDirs = candidateSkillDirs.filter((d) => existsSync15(d));
15987
16011
  const discoveredEntries = /* @__PURE__ */ new Set();
@@ -16022,7 +16046,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
16022
16046
  const sharedSkillsPayload = refreshAny.shared_skills;
16023
16047
  const desiredResolved = globalSkillsPayload !== void 0 || sharedSkillsPayload !== void 0;
16024
16048
  const manifestPath = managedSkillManifestPath(
16025
- join35(homedir17(), ".augmented", agent.code_name)
16049
+ join36(homedir17(), ".augmented", agent.code_name)
16026
16050
  );
16027
16051
  const prevIds = /* @__PURE__ */ new Set([
16028
16052
  ...agentState.knownGlobalSkillIds.get(agent.agent_id) ?? /* @__PURE__ */ new Set(),
@@ -16042,15 +16066,15 @@ async function processAgent(agent, agentStates, managedToolkits) {
16042
16066
  }
16043
16067
  if (plan.removes.length) {
16044
16068
  const globalSkillDirs = [
16045
- join35(homedir17(), ".augmented", agent.code_name, "skills"),
16046
- join35(homedir17(), ".augmented", agent.code_name, "project", ".claude", "skills"),
16047
- join35(agentDir, ".claude", "skills")
16069
+ join36(homedir17(), ".augmented", agent.code_name, "skills"),
16070
+ join36(homedir17(), ".augmented", agent.code_name, "project", ".claude", "skills"),
16071
+ join36(agentDir, ".claude", "skills")
16048
16072
  ];
16049
16073
  for (const id of plan.removes) {
16050
16074
  let prunedAny = false;
16051
16075
  for (const dir of globalSkillDirs) {
16052
- const p = join35(dir, id);
16053
- if (existsSync15(p) && existsSync15(join35(p, "SKILL.md"))) {
16076
+ const p = join36(dir, id);
16077
+ if (existsSync15(p) && existsSync15(join36(p, "SKILL.md"))) {
16054
16078
  rmSync5(p, { recursive: true, force: true });
16055
16079
  prunedAny = true;
16056
16080
  }
@@ -16282,7 +16306,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
16282
16306
  const sess = getSessionState(agent.code_name);
16283
16307
  let mcpJsonParsed = null;
16284
16308
  try {
16285
- const mcpPath = join35(getProjectDir(agent.code_name), ".mcp.json");
16309
+ const mcpPath = join36(getProjectDir(agent.code_name), ".mcp.json");
16286
16310
  mcpJsonParsed = JSON.parse(readFileSync28(mcpPath, "utf-8"));
16287
16311
  } catch {
16288
16312
  }
@@ -16717,7 +16741,7 @@ Retried to the limit after repeated stalls \u2014 needs a look.`).catch(() => {
16717
16741
  if (trackedFiles.length > 0 && existsSync15(agentDir)) {
16718
16742
  const hashes = /* @__PURE__ */ new Map();
16719
16743
  for (const file of trackedFiles) {
16720
- const h = hashFile(join35(agentDir, file));
16744
+ const h = hashFile(join36(agentDir, file));
16721
16745
  if (h) hashes.set(file, h);
16722
16746
  }
16723
16747
  agentState.writtenHashes.set(agent.agent_id, hashes);
@@ -16732,7 +16756,7 @@ Retried to the limit after repeated stalls \u2014 needs a look.`).catch(() => {
16732
16756
  refreshData.agent.onboarding_state
16733
16757
  );
16734
16758
  const obStep = obState.step;
16735
- const markerPath = join35(homedir17(), ".augmented", agent.code_name, "onboarding-drive.json");
16759
+ const markerPath = join36(homedir17(), ".augmented", agent.code_name, "onboarding-drive.json");
16736
16760
  const marker = readOnboardingDriveMarker(markerPath);
16737
16761
  const obContactRaw = refreshData.agent.manager_last_contacted_at;
16738
16762
  const obContact = typeof obContactRaw === "string" && obContactRaw ? obContactRaw : null;
@@ -16834,7 +16858,7 @@ async function ensureOpencodeRuntime(agent, refreshData, agentTimezone) {
16834
16858
  }
16835
16859
  stopOpencodeSlackIngest(codeName, log);
16836
16860
  stopOpencodeTelegramIngest(codeName, log);
16837
- const opencodeProjectDir = join35(getFramework("opencode").getAgentDir(codeName), "provision");
16861
+ const opencodeProjectDir = join36(getFramework("opencode").getAgentDir(codeName), "provision");
16838
16862
  const serveEnv = {
16839
16863
  AGT_HOST: requireHost(),
16840
16864
  AGT_API_KEY: getApiKey() ?? void 0,
@@ -16889,8 +16913,8 @@ async function ensurePersistentSession(agent, tasks, boardItems, refreshData) {
16889
16913
  });
16890
16914
  }
16891
16915
  const projectDir = getProjectDir(codeName);
16892
- const mcpConfigPath = join35(projectDir, ".mcp.json");
16893
- const claudeMdPath = join35(projectDir, "CLAUDE.md");
16916
+ const mcpConfigPath = join36(projectDir, ".mcp.json");
16917
+ const claudeMdPath = join36(projectDir, "CLAUDE.md");
16894
16918
  if (restartBreaker.isTripped(codeName)) {
16895
16919
  const trip = restartBreaker.getTrip(codeName);
16896
16920
  return {
@@ -17927,7 +17951,7 @@ async function processDirectChatMessageOpencode(agent, msg) {
17927
17951
  body
17928
17952
  });
17929
17953
  recordCursorAdvanceOutcome(
17930
- dirname9(paneLogPath(agent.codeName)),
17954
+ dirname10(paneLogPath(agent.codeName)),
17931
17955
  "direct-chat-manager",
17932
17956
  "reply",
17933
17957
  verdict
@@ -17957,7 +17981,7 @@ async function processDirectChatMessageOpencode(agent, msg) {
17957
17981
  } catch (err) {
17958
17982
  if (!recorded) {
17959
17983
  recordCursorAdvanceOutcome(
17960
- dirname9(paneLogPath(agent.codeName)),
17984
+ dirname10(paneLogPath(agent.codeName)),
17961
17985
  "direct-chat-manager",
17962
17986
  "reply",
17963
17987
  { outcome: "failed", error: err.message, expected: 1 }
@@ -18009,7 +18033,7 @@ async function processDirectChatMessage(agent, msg) {
18009
18033
  if (useDoorbell) {
18010
18034
  try {
18011
18035
  const doorbell = directChatDoorbellPath(agent.agentId, homedir17());
18012
- mkdirSync11(dirname9(doorbell), { recursive: true });
18036
+ mkdirSync11(dirname10(doorbell), { recursive: true });
18013
18037
  writeFileSync14(doorbell, String(Date.now()));
18014
18038
  log(`[direct-chat] Doorbell rung for '${agent.codeName}' (msg=${msg.id}) \u2014 in-session MCP will pull via the cursor`);
18015
18039
  return;
@@ -18138,7 +18162,7 @@ ${formatRunMarker(run_id)}` : KANBAN_CHECK_COMMAND;
18138
18162
  if (run_id) openInjectedRunByCode.set(codeName, run_id);
18139
18163
  try {
18140
18164
  const doorbell = directChatDoorbellPath(agentId, homedir17());
18141
- mkdirSync11(dirname9(doorbell), { recursive: true });
18165
+ mkdirSync11(dirname10(doorbell), { recursive: true });
18142
18166
  writeFileSync14(doorbell, String(Date.now()));
18143
18167
  } catch (err) {
18144
18168
  log(`[kanban] doorbell ring failed for '${codeName}': ${err.message} (notice still queued)`);
@@ -18497,8 +18521,8 @@ function parseMemoryFile(raw, fallbackName) {
18497
18521
  };
18498
18522
  }
18499
18523
  async function syncMemories(agent, configDir, log2) {
18500
- const projectDir = join35(configDir, agent.code_name, "project");
18501
- const memoryDir = join35(projectDir, "memory");
18524
+ const projectDir = join36(configDir, agent.code_name, "project");
18525
+ const memoryDir = join36(projectDir, "memory");
18502
18526
  const isFreshSync = pendingFreshMemorySync.has(agent.agent_id);
18503
18527
  if (isFreshSync) {
18504
18528
  log2(`[memory-sync] Fresh-sync requested for '${agent.code_name}' \u2014 pulling DB first`);
@@ -18516,7 +18540,7 @@ async function syncMemories(agent, configDir, log2) {
18516
18540
  for (const file of readdirSync9(memoryDir)) {
18517
18541
  if (!file.endsWith(".md")) continue;
18518
18542
  try {
18519
- const raw = readFileSync28(join35(memoryDir, file), "utf-8");
18543
+ const raw = readFileSync28(join36(memoryDir, file), "utf-8");
18520
18544
  const fileHash = createHash17("sha256").update(raw).digest("hex").slice(0, 16);
18521
18545
  currentHashes.set(file, fileHash);
18522
18546
  if (prevHashes.get(file) === fileHash) continue;
@@ -18541,7 +18565,7 @@ async function syncMemories(agent, configDir, log2) {
18541
18565
  } catch (err) {
18542
18566
  for (const mem of changedMemories) {
18543
18567
  for (const [file] of currentHashes) {
18544
- const parsed = parseMemoryFile(readFileSync28(join35(memoryDir, file), "utf-8"), file.replace(/\.md$/, ""));
18568
+ const parsed = parseMemoryFile(readFileSync28(join36(memoryDir, file), "utf-8"), file.replace(/\.md$/, ""));
18545
18569
  if (parsed?.name === mem.name) currentHashes.delete(file);
18546
18570
  }
18547
18571
  }
@@ -18576,7 +18600,7 @@ async function downloadMemories(agent, memoryDir, log2, { force }) {
18576
18600
  const mem = dbMemories.memories[i];
18577
18601
  const rawSlug = mem.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "").slice(0, 60);
18578
18602
  const slug = rawSlug || `memory-${i}`;
18579
- const filePath = join35(memoryDir, `${slug}.md`);
18603
+ const filePath = join36(memoryDir, `${slug}.md`);
18580
18604
  const desired = `---
18581
18605
  name: ${JSON.stringify(mem.name)}
18582
18606
  type: ${mem.type}
@@ -18906,7 +18930,7 @@ function startManager(opts) {
18906
18930
  log(`[startup] state rehydration failed (continuing with empty state): ${err.message}`);
18907
18931
  }
18908
18932
  log(
18909
- `[startup] worker pid=${process.pid} ppid=${process.ppid} node=${process.version} log=${join35(homedir17(), ".augmented", "manager.log")}`
18933
+ `[startup] worker pid=${process.pid} ppid=${process.ppid} node=${process.version} log=${join36(homedir17(), ".augmented", "manager.log")}`
18910
18934
  );
18911
18935
  deployMcpAssets();
18912
18936
  reapOrphanChannelMcps({ log });
@@ -19032,18 +19056,18 @@ function restartRunningChannelMcps(basenames) {
19032
19056
  }
19033
19057
  }
19034
19058
  function deployMcpAssets() {
19035
- const targetDir = join35(homedir17(), ".augmented", "_mcp");
19059
+ const targetDir = join36(homedir17(), ".augmented", "_mcp");
19036
19060
  mkdirSync11(targetDir, { recursive: true });
19037
- const moduleDir = dirname9(fileURLToPath(import.meta.url));
19061
+ const moduleDir = dirname10(fileURLToPath(import.meta.url));
19038
19062
  let mcpSourceDir = "";
19039
19063
  let dir = moduleDir;
19040
19064
  for (let i = 0; i < 6; i++) {
19041
- const candidate = join35(dir, "dist", "mcp");
19042
- if (existsSync15(join35(candidate, "index.js"))) {
19065
+ const candidate = join36(dir, "dist", "mcp");
19066
+ if (existsSync15(join36(candidate, "index.js"))) {
19043
19067
  mcpSourceDir = candidate;
19044
19068
  break;
19045
19069
  }
19046
- const parent = dirname9(dir);
19070
+ const parent = dirname10(dir);
19047
19071
  if (parent === dir) break;
19048
19072
  dir = parent;
19049
19073
  }
@@ -19128,13 +19152,13 @@ function deployMcpAssets() {
19128
19152
  // needs restarting to pick up a token rotation.
19129
19153
  "xero.js"
19130
19154
  ]) {
19131
- const src = join35(mcpSourceDir, file);
19132
- const dst = join35(targetDir, file);
19155
+ const src = join36(mcpSourceDir, file);
19156
+ const dst = join36(targetDir, file);
19133
19157
  if (!existsSync15(src)) continue;
19134
19158
  attemptedFiles.push(file);
19135
19159
  const before = fileHash(dst);
19136
19160
  try {
19137
- copyFileSync(src, dst);
19161
+ atomicCopyFileSync(src, dst);
19138
19162
  const after = fileHash(dst);
19139
19163
  if (before !== after && RESTARTABLE_CHANNEL_FILES.has(file)) {
19140
19164
  changedBasenames.push(file.replace(/\.js$/, ""));
@@ -19155,14 +19179,14 @@ function deployMcpAssets() {
19155
19179
  log(`[manager] Bundle(s) updated: ${changedBasenames.join(", ")} \u2014 signalling running instances to restart`);
19156
19180
  restartRunningChannelMcps(changedBasenames);
19157
19181
  }
19158
- const localMcpPath = join35(targetDir, "index.js");
19182
+ const localMcpPath = join36(targetDir, "index.js");
19159
19183
  try {
19160
- const agentsDir = join35(homedir17(), ".augmented", "agents");
19184
+ const agentsDir = join36(homedir17(), ".augmented", "agents");
19161
19185
  if (existsSync15(agentsDir)) {
19162
19186
  for (const entry of readdirSync9(agentsDir, { withFileTypes: true })) {
19163
19187
  if (!entry.isDirectory()) continue;
19164
19188
  for (const subdir of ["provision", "project"]) {
19165
- const mcpJsonPath = join35(agentsDir, entry.name, subdir, ".mcp.json");
19189
+ const mcpJsonPath = join36(agentsDir, entry.name, subdir, ".mcp.json");
19166
19190
  try {
19167
19191
  const raw = readFileSync28(mcpJsonPath, "utf-8");
19168
19192
  if (!raw.includes("@integrity-labs/augmented-mcp")) continue;