@integrity-labs/agt-cli 0.28.1266 → 0.28.1267

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.
@@ -70,7 +70,7 @@ import {
70
70
  tripClass,
71
71
  writeEtcEnvironment,
72
72
  writeProfileDScript
73
- } from "../chunk-7Z3N4G2Y.js";
73
+ } from "../chunk-SR72T5SB.js";
74
74
  import {
75
75
  ApiError,
76
76
  adoptHostKeyInProcess,
@@ -88,7 +88,7 @@ import {
88
88
  probeHostKey,
89
89
  requireHost,
90
90
  setConfigHash
91
- } from "../chunk-SGYCPC5K.js";
91
+ } from "../chunk-DCI6M6TF.js";
92
92
  import {
93
93
  BLOCKED_ON_PROMPT_DECISION,
94
94
  CHANNEL_SECRET_ENV_KEYS,
@@ -154,6 +154,7 @@ import {
154
154
  restartEgressSidecar,
155
155
  rotatePaneLogForDayRollover,
156
156
  rotateSessionForWedge,
157
+ sanitizeMcpJson,
157
158
  seedContainerMemory,
158
159
  sessionBlockedOnPrompt,
159
160
  sessionHealthyAndUnblocked,
@@ -174,7 +175,7 @@ import {
174
175
  webFetchBaselineValue,
175
176
  webFetchRestartNeeded,
176
177
  writeEgressAllowlist
177
- } from "../chunk-WJUGK4R5.js";
178
+ } from "../chunk-UA2UPXYC.js";
178
179
  import {
179
180
  isAgentIdle,
180
181
  isStaleForToday,
@@ -563,8 +564,8 @@ function confirmConfigReload(input, deps) {
563
564
  }
564
565
 
565
566
  // src/lib/manager-worker.ts
566
- import { createHash as createHash20 } from "crypto";
567
- import { readFileSync as readFileSync36, writeFileSync as writeFileSync19, mkdirSync as mkdirSync17, existsSync as existsSync20, rmSync as rmSync9, readdirSync as readdirSync14, statSync as statSync15, unlinkSync as unlinkSync6, renameSync as renameSync11, utimesSync as utimesSync4, readlinkSync as readlinkSync2 } from "fs";
567
+ import { createHash as createHash21 } from "crypto";
568
+ import { readFileSync as readFileSync37, writeFileSync as writeFileSync19, mkdirSync as mkdirSync18, existsSync as existsSync20, rmSync as rmSync9, readdirSync as readdirSync14, statSync as statSync15, unlinkSync as unlinkSync6, renameSync as renameSync11, utimesSync as utimesSync4, readlinkSync as readlinkSync2 } from "fs";
568
569
 
569
570
  // src/lib/atomic-file-replace.ts
570
571
  import { copyFileSync, renameSync, unlinkSync } from "fs";
@@ -981,7 +982,7 @@ function clearEpisode(codeName) {
981
982
  }
982
983
 
983
984
  // src/lib/manager-worker.ts
984
- import { join as join45, dirname as dirname11, delimiter as pathDelimiter } from "path";
985
+ import { join as join46, dirname as dirname11, delimiter as pathDelimiter } from "path";
985
986
  import { homedir as homedir17, hostname, platform as platform3 } from "os";
986
987
  import { fileURLToPath as fileURLToPath2 } from "url";
987
988
 
@@ -2857,17 +2858,272 @@ function isRemoteMcpEntry(value) {
2857
2858
  function expectedRemoteMcpKeys(integrations) {
2858
2859
  return new Set(integrations.map((i) => remoteMcpServerKey(i.definition_id, i.connection_key ?? null)));
2859
2860
  }
2861
+ function isSanitizedRemoteBridge(entry) {
2862
+ if (!entry || typeof entry !== "object") return false;
2863
+ const e = entry;
2864
+ if (e.command !== "npx" || !Array.isArray(e.args)) return false;
2865
+ const a = e.args;
2866
+ return a.length === 4 && a[0] === "-y" && a[1] === "mcp-remote" && typeof a[2] === "string" && /^https?:\/\//.test(a[2]) && a[3] === "--allow-http";
2867
+ }
2860
2868
  function orphanedRemoteMcpKeys(mcpServers, expectedIntegrationKeys) {
2861
2869
  const orphans = [];
2862
2870
  for (const [key, entry] of Object.entries(mcpServers)) {
2863
2871
  if (expectedIntegrationKeys.has(key)) continue;
2864
2872
  if (isManagedMcpServerKey(key)) continue;
2865
- if (!isRemoteMcpEntry(entry) && classifyMcpServer(entry) !== "oauth-proxy") continue;
2873
+ if (!isRemoteMcpEntry(entry) && classifyMcpServer(entry) !== "oauth-proxy" && !isSanitizedRemoteBridge(entry)) continue;
2866
2874
  orphans.push(key);
2867
2875
  }
2868
2876
  return orphans;
2869
2877
  }
2870
2878
 
2879
+ // src/lib/spawn-mcp-filter.ts
2880
+ import {
2881
+ closeSync,
2882
+ constants as fsConstants,
2883
+ fchmodSync,
2884
+ fstatSync,
2885
+ ftruncateSync,
2886
+ lstatSync as lstatSync2,
2887
+ mkdirSync as mkdirSync3,
2888
+ openSync,
2889
+ readFileSync as readFileSync7,
2890
+ writeSync
2891
+ } from "fs";
2892
+ import { join as join7 } from "path";
2893
+ import { createHash as createHash4 } from "crypto";
2894
+ var SPAWN_MCP_CONFIG_RELATIVE = join7(".claude", "spawn-mcp.json");
2895
+ var SPAWN_MCP_FILE_MODE = 384;
2896
+ function writeSpawnConfigNoFollow(projectDir, relativePath, content) {
2897
+ const claudeDir = join7(projectDir, ".claude");
2898
+ mkdirSync3(projectDir, { recursive: true });
2899
+ try {
2900
+ mkdirSync3(claudeDir);
2901
+ } catch (err) {
2902
+ if (err.code !== "EEXIST") throw err;
2903
+ }
2904
+ const dirStat = lstatSync2(claudeDir);
2905
+ if (dirStat.isSymbolicLink() || !dirStat.isDirectory()) {
2906
+ throw new Error(`${claudeDir} is not a real directory (refusing to follow it)`);
2907
+ }
2908
+ const path = join7(projectDir, relativePath);
2909
+ const fd = openSync(
2910
+ path,
2911
+ fsConstants.O_WRONLY | fsConstants.O_CREAT | fsConstants.O_NOFOLLOW | fsConstants.O_NONBLOCK,
2912
+ SPAWN_MCP_FILE_MODE
2913
+ );
2914
+ try {
2915
+ const st = fstatSync(fd);
2916
+ if (!st.isFile()) throw new Error(`${path} is not a regular file (refusing to write it)`);
2917
+ if (st.nlink !== 1) throw new Error(`${path} has ${st.nlink} links (refusing to write through a hard link)`);
2918
+ fchmodSync(fd, SPAWN_MCP_FILE_MODE);
2919
+ ftruncateSync(fd, 0);
2920
+ const bytes = Buffer.from(content, "utf-8");
2921
+ let off = 0;
2922
+ while (off < bytes.length) {
2923
+ const n = writeSync(fd, bytes, off, bytes.length - off);
2924
+ if (n <= 0) throw new Error(`${path}: short write (${off}/${bytes.length} bytes)`);
2925
+ off += n;
2926
+ }
2927
+ } finally {
2928
+ closeSync(fd);
2929
+ }
2930
+ return path;
2931
+ }
2932
+ function filterOrphanRemoteMcpForSpawn(servers, expectedKeys) {
2933
+ const dropped = orphanedRemoteMcpKeys(servers, expectedKeys);
2934
+ if (dropped.length === 0) return { kept: servers, dropped };
2935
+ const kept = {};
2936
+ for (const [key, entry] of Object.entries(servers)) {
2937
+ if (!dropped.includes(key)) kept[key] = entry;
2938
+ }
2939
+ return { kept, dropped };
2940
+ }
2941
+ function spawnViewOfMcpConfig(parsed, integrations) {
2942
+ if (integrations === void 0) return parsed;
2943
+ const servers = parsed["mcpServers"];
2944
+ if (!servers || typeof servers !== "object" || Array.isArray(servers)) return parsed;
2945
+ const { kept, dropped } = filterOrphanRemoteMcpForSpawn(servers, expectedRemoteMcpKeys(integrations));
2946
+ return dropped.length === 0 ? parsed : { ...parsed, mcpServers: kept };
2947
+ }
2948
+ function spawnDroppedServerKeys(mcpConfigPath, integrations) {
2949
+ if (integrations === void 0) return /* @__PURE__ */ new Set();
2950
+ try {
2951
+ const parsed = JSON.parse(readFileSync7(mcpConfigPath, "utf-8"));
2952
+ const servers = parsed?.mcpServers;
2953
+ if (!servers || typeof servers !== "object" || Array.isArray(servers)) return /* @__PURE__ */ new Set();
2954
+ return new Set(filterOrphanRemoteMcpForSpawn(servers, expectedRemoteMcpKeys(integrations)).dropped);
2955
+ } catch {
2956
+ return /* @__PURE__ */ new Set();
2957
+ }
2958
+ }
2959
+ function prepareSpawnMcpConfig(input) {
2960
+ const { codeName, projectDir, mcpConfigPath, integrations, apiHost, log: log2, onCopyFailed, onNothingToDrop } = input;
2961
+ if (integrations === void 0) {
2962
+ log2(
2963
+ `[spawn-mcp-filter] ORPHAN_FILTER_SET_UNKNOWN agent='${codeName}': no integration set known in this manager process yet, so the spawn uses .mcp.json unfiltered (filtering against nothing would drop every remote server) (ENG-12048)`
2964
+ );
2965
+ return mcpConfigPath;
2966
+ }
2967
+ let config2;
2968
+ try {
2969
+ config2 = JSON.parse(readFileSync7(mcpConfigPath, "utf-8"));
2970
+ } catch {
2971
+ return mcpConfigPath;
2972
+ }
2973
+ if (!config2 || typeof config2 !== "object" || Array.isArray(config2)) return mcpConfigPath;
2974
+ const rawServers = config2["mcpServers"];
2975
+ if (rawServers !== void 0 && (!rawServers || typeof rawServers !== "object" || Array.isArray(rawServers))) {
2976
+ return mcpConfigPath;
2977
+ }
2978
+ const servers = rawServers ?? {};
2979
+ const { dropped } = filterOrphanRemoteMcpForSpawn(servers, expectedRemoteMcpKeys(integrations));
2980
+ if (dropped.length === 0) {
2981
+ onNothingToDrop?.();
2982
+ return mcpConfigPath;
2983
+ }
2984
+ try {
2985
+ sanitizeMcpJson(mcpConfigPath, apiHost);
2986
+ const reread = JSON.parse(readFileSync7(mcpConfigPath, "utf-8"));
2987
+ if (reread && typeof reread === "object" && !Array.isArray(reread)) config2 = reread;
2988
+ } catch {
2989
+ }
2990
+ const afterSanitise = config2["mcpServers"] ?? {};
2991
+ const droppedAfterSanitise = filterOrphanRemoteMcpForSpawn(afterSanitise, expectedRemoteMcpKeys(integrations)).dropped;
2992
+ const neverLoad = /* @__PURE__ */ new Set([...dropped, ...droppedAfterSanitise]);
2993
+ const keptAfterSanitise = Object.fromEntries(Object.entries(afterSanitise).filter(([key]) => !neverLoad.has(key)));
2994
+ let spawnPath;
2995
+ try {
2996
+ spawnPath = writeSpawnConfigNoFollow(
2997
+ projectDir,
2998
+ SPAWN_MCP_CONFIG_RELATIVE,
2999
+ `${JSON.stringify({ ...config2, mcpServers: keptAfterSanitise }, null, 2)}
3000
+ `
3001
+ );
3002
+ } catch (err) {
3003
+ log2(
3004
+ `[spawn-mcp-filter] ORPHAN_SPAWN_UNFILTERED agent='${codeName}' servers=${dropped.map((k) => `'${k}'`).join(", ")} reason=could not write the filtered spawn config (${err.message}). The session starts WITH these removed integrations' servers (ENG-12048)`
3005
+ );
3006
+ onCopyFailed?.({ dropped: [...neverLoad], error: err.message });
3007
+ return mcpConfigPath;
3008
+ }
3009
+ log2(
3010
+ `[spawn-mcp-filter] '${codeName}': session starts WITHOUT orphaned remote MCP server(s) ${dropped.map((k) => `'${k}'`).join(", ")} (integration removed; .mcp.json still declares them) (ENG-12048)`
3011
+ );
3012
+ return spawnPath;
3013
+ }
3014
+ function hashMcpConfig(config2) {
3015
+ return createHash4("sha256").update(canonicalJson(config2)).digest("hex");
3016
+ }
3017
+ var SPAWN_COPY_RETRY_INTERVAL_MS = 5 * 6e4;
3018
+ var SpawnCopyFailureTracker = class {
3019
+ constructor(retryIntervalMs = SPAWN_COPY_RETRY_INTERVAL_MS) {
3020
+ this.retryIntervalMs = retryIntervalMs;
3021
+ }
3022
+ failures = /* @__PURE__ */ new Map();
3023
+ /** When the copy write was last attempted for a held agent (spawn or retry). */
3024
+ lastAttemptMs = /* @__PURE__ */ new Map();
3025
+ /** Record a fail-open spawn. Returns true when this ENTERS (or changes) the state. */
3026
+ noteFailure(codeName, failure, nowMs = Date.now()) {
3027
+ const prev = this.failures.get(codeName);
3028
+ this.failures.set(codeName, failure);
3029
+ this.lastAttemptMs.set(codeName, nowMs);
3030
+ return !prev || prev.rawHash !== failure.rawHash;
3031
+ }
3032
+ /** A spawn wrote its copy (or had nothing to drop). Returns true when this cleared a failure. */
3033
+ noteSuccess(codeName) {
3034
+ this.lastAttemptMs.delete(codeName);
3035
+ return this.failures.delete(codeName);
3036
+ }
3037
+ /**
3038
+ * Obi Wan c7b7dea6ccc0: the hold is keyed on the raw file, but the spawn view
3039
+ * also changes when the integration set does (a SECOND removal whose prune is
3040
+ * also refused). Record the servers the view drops NOW, so the per-poll log
3041
+ * and alert name the new one. Returns true when the set changed. Never starts
3042
+ * or ends a hold.
3043
+ */
3044
+ noteDropped(codeName, dropped) {
3045
+ const f = this.failures.get(codeName);
3046
+ if (!f || dropped.length === 0) return false;
3047
+ const next = [...new Set(dropped)].sort();
3048
+ if (next.join("\0") === [...f.dropped].sort().join("\0")) return false;
3049
+ this.failures.set(codeName, { ...f, dropped: next });
3050
+ return true;
3051
+ }
3052
+ /** The failure currently held for an agent, or null. */
3053
+ held(codeName) {
3054
+ return this.failures.get(codeName) ?? null;
3055
+ }
3056
+ /**
3057
+ * CodeRabbit on c464bd3a: while held, is a retry of the copy write due? True
3058
+ * at most once per interval per agent (the call stamps the attempt), and
3059
+ * never when nothing is held. A failed retry goes back through noteFailure.
3060
+ */
3061
+ retryDue(codeName, nowMs = Date.now()) {
3062
+ if (!this.failures.has(codeName)) return false;
3063
+ const last = this.lastAttemptMs.get(codeName);
3064
+ if (last !== void 0 && nowMs - last < this.retryIntervalMs) return false;
3065
+ this.lastAttemptMs.set(codeName, nowMs);
3066
+ return true;
3067
+ }
3068
+ /**
3069
+ * Should a drift restart be held? While the recorded raw hash is unchanged,
3070
+ * or unknown (an unreadable read is not a change). A changed raw file clears
3071
+ * the state and returns null.
3072
+ */
3073
+ holdsDriftRestart(codeName, currentRawHash) {
3074
+ const f = this.failures.get(codeName);
3075
+ if (!f) return null;
3076
+ if (currentRawHash !== null && currentRawHash !== f.rawHash) {
3077
+ this.failures.delete(codeName);
3078
+ this.lastAttemptMs.delete(codeName);
3079
+ return null;
3080
+ }
3081
+ return f;
3082
+ }
3083
+ };
3084
+ function retryHeldSpawnCopy(input) {
3085
+ const { tracker, codeName, projectDir, held, integrations, resolveApiHost, log: log2, nowMs = Date.now() } = input;
3086
+ if (integrations === void 0) return held;
3087
+ const mcpConfigPath = join7(projectDir, ".mcp.json");
3088
+ const outcome = {
3089
+ failed: null,
3090
+ nothingToDrop: false
3091
+ };
3092
+ let written;
3093
+ try {
3094
+ written = prepareSpawnMcpConfig({
3095
+ codeName,
3096
+ projectDir,
3097
+ mcpConfigPath,
3098
+ integrations,
3099
+ apiHost: resolveApiHost?.(),
3100
+ log: log2,
3101
+ onCopyFailed: (info) => {
3102
+ outcome.failed = info;
3103
+ },
3104
+ onNothingToDrop: () => {
3105
+ outcome.nothingToDrop = true;
3106
+ }
3107
+ });
3108
+ } catch (err) {
3109
+ outcome.failed = { dropped: held.dropped, error: err instanceof Error ? err.message : String(err) };
3110
+ written = mcpConfigPath;
3111
+ }
3112
+ if (!outcome.failed && outcome.nothingToDrop) {
3113
+ tracker.noteSuccess(codeName);
3114
+ log2(`[spawn-mcp-filter] ORPHAN_SPAWN_COPY_NOT_NEEDED agent='${codeName}': the config no longer drops any server, so the copy-failure hold ends; drift is judged normally again (ENG-12048)`);
3115
+ return null;
3116
+ }
3117
+ if (outcome.failed || written === mcpConfigPath) {
3118
+ const still = { ...held, ...outcome.failed ?? {} };
3119
+ tracker.noteFailure(codeName, still, nowMs);
3120
+ return still;
3121
+ }
3122
+ tracker.noteSuccess(codeName);
3123
+ log2(`[spawn-mcp-filter] ORPHAN_SPAWN_COPY_RECOVERED agent='${codeName}': the filtered spawn config was written on retry; drift is judged normally again (ENG-12048)`);
3124
+ return null;
3125
+ }
3126
+
2871
3127
  // src/lib/auto-resume.ts
2872
3128
  var DEFAULT_QUIET_MS = 18e5;
2873
3129
  var DEFAULT_BACKOFF_RESET_MS = 864e5;
@@ -3089,12 +3345,12 @@ function stopAgentRuntime(codeName, reason, log2, deps) {
3089
3345
  }
3090
3346
 
3091
3347
  // src/lib/opencode-credential-fingerprint.ts
3092
- import { createHash as createHash4 } from "crypto";
3348
+ import { createHash as createHash5 } from "crypto";
3093
3349
  var FINGERPRINT_LENGTH = 16;
3094
3350
  var ABSENT = "none";
3095
3351
  function fingerprintOf(secret) {
3096
3352
  if (!secret) return ABSENT;
3097
- return createHash4("sha256").update(secret, "utf8").digest("hex").slice(0, FINGERPRINT_LENGTH);
3353
+ return createHash5("sha256").update(secret, "utf8").digest("hex").slice(0, FINGERPRINT_LENGTH);
3098
3354
  }
3099
3355
  function opencodeCredentialFingerprint(inputs) {
3100
3356
  const openRouter = inputs.openRouterToken ? inputs.openRouterFingerprint || fingerprintOf(inputs.openRouterToken) : ABSENT;
@@ -3286,9 +3542,9 @@ var DependencyRecoveryLedger = class {
3286
3542
  // src/lib/mcp-assets-ready.ts
3287
3543
  import { existsSync as nodeExistsSync, readFileSync as nodeReadFileSync } from "fs";
3288
3544
  import { homedir as homedir2 } from "os";
3289
- import { join as join7, resolve, sep } from "path";
3545
+ import { join as join8, resolve, sep } from "path";
3290
3546
  function getSharedMcpDir(homeDir = homedir2()) {
3291
- return join7(homeDir, ".augmented", "_mcp");
3547
+ return join8(homeDir, ".augmented", "_mcp");
3292
3548
  }
3293
3549
  function isPathInsideDir(candidate, dir) {
3294
3550
  const resolvedDir = resolve(dir);
@@ -3298,11 +3554,11 @@ function isPathInsideDir(candidate, dir) {
3298
3554
  }
3299
3555
  function findMissingMcpBundles(mcpConfigPath, deps = {}) {
3300
3556
  const existsSync21 = deps.existsSync ?? nodeExistsSync;
3301
- const readFileSync37 = deps.readFileSync ?? nodeReadFileSync;
3557
+ const readFileSync38 = deps.readFileSync ?? nodeReadFileSync;
3302
3558
  const mcpDir = deps.mcpDir ?? getSharedMcpDir();
3303
3559
  let parsed;
3304
3560
  try {
3305
- parsed = JSON.parse(readFileSync37(mcpConfigPath, "utf-8"));
3561
+ parsed = JSON.parse(readFileSync38(mcpConfigPath, "utf-8"));
3306
3562
  } catch {
3307
3563
  return [];
3308
3564
  }
@@ -3311,6 +3567,7 @@ function findMissingMcpBundles(mcpConfigPath, deps = {}) {
3311
3567
  const missing = [];
3312
3568
  const seenPaths = /* @__PURE__ */ new Set();
3313
3569
  for (const [key, rawEntry] of Object.entries(servers)) {
3570
+ if (deps.skipKeys?.has(key)) continue;
3314
3571
  if (!rawEntry || typeof rawEntry !== "object" || Array.isArray(rawEntry)) continue;
3315
3572
  const entry = rawEntry;
3316
3573
  if (entry.command !== "node") continue;
@@ -3340,7 +3597,7 @@ function formatMissingMcpBundles(missing) {
3340
3597
  }
3341
3598
 
3342
3599
  // src/lib/self-update-coalesce.ts
3343
- import { readFileSync as readFileSync7, writeFileSync as writeFileSync4, mkdirSync as mkdirSync3 } from "fs";
3600
+ import { readFileSync as readFileSync8, writeFileSync as writeFileSync4, mkdirSync as mkdirSync4 } from "fs";
3344
3601
  import { dirname as dirname4 } from "path";
3345
3602
  var DEFAULT_SELF_UPDATE_COALESCE_MS = 30 * 60 * 1e3;
3346
3603
  function resolveCoalesceWindowMs(env = process.env) {
@@ -3350,7 +3607,7 @@ function resolveCoalesceWindowMs(env = process.env) {
3350
3607
  if (!Number.isFinite(parsed) || parsed < 0) return DEFAULT_SELF_UPDATE_COALESCE_MS;
3351
3608
  return Math.trunc(parsed);
3352
3609
  }
3353
- function readLastSelfUpdateAppliedMs(markerPath, now = Date.now(), read = (p) => readFileSync7(p, "utf-8")) {
3610
+ function readLastSelfUpdateAppliedMs(markerPath, now = Date.now(), read = (p) => readFileSync8(p, "utf-8")) {
3354
3611
  let raw;
3355
3612
  try {
3356
3613
  raw = read(markerPath);
@@ -3363,7 +3620,7 @@ function readLastSelfUpdateAppliedMs(markerPath, now = Date.now(), read = (p) =>
3363
3620
  return v;
3364
3621
  }
3365
3622
  function stampLastSelfUpdateApplied(markerPath, now = Date.now(), write = (p, v) => {
3366
- mkdirSync3(dirname4(p), { recursive: true });
3623
+ mkdirSync4(dirname4(p), { recursive: true });
3367
3624
  writeFileSync4(p, v);
3368
3625
  }) {
3369
3626
  try {
@@ -3655,11 +3912,11 @@ async function reportModelApiError(opts) {
3655
3912
  }
3656
3913
 
3657
3914
  // src/lib/claude-pid-tracker.ts
3658
- import { existsSync, readFileSync as readFileSync8 } from "fs";
3915
+ import { existsSync, readFileSync as readFileSync9 } from "fs";
3659
3916
  function readPidFile(path) {
3660
3917
  if (!existsSync(path)) return { version: 1, spawns: [] };
3661
3918
  try {
3662
- const raw = JSON.parse(readFileSync8(path, "utf-8"));
3919
+ const raw = JSON.parse(readFileSync9(path, "utf-8"));
3663
3920
  if (raw.version !== 1 || !Array.isArray(raw.spawns)) return { version: 1, spawns: [] };
3664
3921
  const spawns = raw.spawns.filter(
3665
3922
  (s) => !!s && typeof s.pid === "number" && Number.isFinite(s.pid) && s.pid > 0
@@ -3759,14 +4016,14 @@ async function killSessionsConcurrently(sessions, killOne) {
3759
4016
  }
3760
4017
 
3761
4018
  // src/lib/direct-chat-delivery.ts
3762
- import { join as join8 } from "path";
4019
+ import { join as join9 } from "path";
3763
4020
  var DEFAULT_DIRECT_CHAT_MAX_AGE_MS = 30 * 6e4;
3764
4021
  function directChatMaxAgeMs() {
3765
4022
  const raw = parseInt(process.env["AGT_DIRECT_CHAT_MAX_AGE_MS"] ?? "", 10);
3766
4023
  return Number.isFinite(raw) && raw >= 0 ? raw : DEFAULT_DIRECT_CHAT_MAX_AGE_MS;
3767
4024
  }
3768
4025
  function directChatDoorbellPath(agentId, home) {
3769
- return join8(home, ".augmented", agentId, "direct-chat-doorbell");
4026
+ return join9(home, ".augmented", agentId, "direct-chat-doorbell");
3770
4027
  }
3771
4028
  function isDirectChatMessageExpired(createdAt, nowMs, maxAgeMs) {
3772
4029
  if (!maxAgeMs || maxAgeMs <= 0) return false;
@@ -3777,8 +4034,8 @@ function isDirectChatMessageExpired(createdAt, nowMs, maxAgeMs) {
3777
4034
  }
3778
4035
 
3779
4036
  // src/lib/review-poster-asset.ts
3780
- import { copyFileSync as copyFileSync2, chmodSync, existsSync as existsSync2, mkdirSync as mkdirSync4, readFileSync as readFileSync9 } from "fs";
3781
- import { dirname as dirname5, join as join9 } from "path";
4037
+ import { copyFileSync as copyFileSync2, chmodSync, existsSync as existsSync2, mkdirSync as mkdirSync5, readFileSync as readFileSync10 } from "fs";
4038
+ import { dirname as dirname5, join as join10 } from "path";
3782
4039
  import { fileURLToPath } from "url";
3783
4040
  var POSTER_FILENAME = "post-review-findings.mjs";
3784
4041
  var AUTH_FILENAME = "obiwan-auth.mjs";
@@ -3791,14 +4048,14 @@ function resolveBundledReviewAssetDir() {
3791
4048
  const moduleDir = dirname5(fileURLToPath(import.meta.url));
3792
4049
  const candidates = [
3793
4050
  // Built output: dist/<chunk>.js → dist/assets/review
3794
- join9(moduleDir, "assets", REVIEW_ASSET_DIRNAME),
4051
+ join10(moduleDir, "assets", REVIEW_ASSET_DIRNAME),
3795
4052
  // Built output sibling case: dist/<sub>/<chunk>.js → dist/assets/review
3796
- join9(moduleDir, "..", "assets", REVIEW_ASSET_DIRNAME),
4053
+ join10(moduleDir, "..", "assets", REVIEW_ASSET_DIRNAME),
3797
4054
  // Dev source: src/lib/review-poster-asset.ts → ../../assets/review
3798
- join9(moduleDir, "..", "..", "assets", REVIEW_ASSET_DIRNAME)
4055
+ join10(moduleDir, "..", "..", "assets", REVIEW_ASSET_DIRNAME)
3799
4056
  ];
3800
4057
  for (const candidate of candidates) {
3801
- if (existsSync2(join9(candidate, POSTER_FILENAME))) return candidate;
4058
+ if (existsSync2(join10(candidate, POSTER_FILENAME))) return candidate;
3802
4059
  }
3803
4060
  throw new Error(
3804
4061
  `[review-poster] could not locate bundled assets; tried:
@@ -3806,18 +4063,18 @@ function resolveBundledReviewAssetDir() {
3806
4063
  );
3807
4064
  }
3808
4065
  function reviewPosterDir(codeName) {
3809
- return join9(getFramework("claude-code").getAgentDir(codeName), REVIEW_ASSET_DIRNAME);
4066
+ return join10(getFramework("claude-code").getAgentDir(codeName), REVIEW_ASSET_DIRNAME);
3810
4067
  }
3811
4068
  function provisionReviewPoster(codeName, sourceDir = resolveBundledReviewAssetDir()) {
3812
4069
  const destDir = reviewPosterDir(codeName);
3813
- mkdirSync4(destDir, { recursive: true });
4070
+ mkdirSync5(destDir, { recursive: true });
3814
4071
  for (const [name, mode] of ASSET_FILES) {
3815
- const src = join9(sourceDir, name);
3816
- const dest = join9(destDir, name);
4072
+ const src = join10(sourceDir, name);
4073
+ const dest = join10(destDir, name);
3817
4074
  if (!existsSync2(src)) {
3818
4075
  throw new Error(`[review-poster] bundled asset missing: ${src}`);
3819
4076
  }
3820
- if (!existsSync2(dest) || !readFileSync9(src).equals(readFileSync9(dest))) {
4077
+ if (!existsSync2(dest) || !readFileSync10(src).equals(readFileSync10(dest))) {
3821
4078
  copyFileSync2(src, dest);
3822
4079
  }
3823
4080
  chmodSync(dest, mode);
@@ -3825,8 +4082,8 @@ function provisionReviewPoster(codeName, sourceDir = resolveBundledReviewAssetDi
3825
4082
  }
3826
4083
 
3827
4084
  // src/lib/scratch-sweep-policy.ts
3828
- import { existsSync as existsSync3, mkdirSync as mkdirSync5, readFileSync as readFileSync10, rmSync as rmSync2, writeFileSync as writeFileSync5 } from "fs";
3829
- import { join as join10 } from "path";
4085
+ import { existsSync as existsSync3, mkdirSync as mkdirSync6, readFileSync as readFileSync11, rmSync as rmSync2, writeFileSync as writeFileSync5 } from "fs";
4086
+ import { join as join11 } from "path";
3830
4087
  var SCRATCH_POLICY_LOG_INTERVAL_MS = 60 * 60 * 1e3;
3831
4088
  var SCRATCH_HOLD_LIFT_DELAY_MS = 10 * 60 * 1e3;
3832
4089
  var SCRATCH_HOLD_MAX_OBSERVATION_GAP_MS = 5 * 60 * 1e3;
@@ -3857,9 +4114,9 @@ function resolveScratchSweepPolicy(input) {
3857
4114
  note(input, "kept=all reason=invalid-agent-id");
3858
4115
  return HELD;
3859
4116
  }
3860
- const marker = join10(input.holdsDir, input.agentId);
4117
+ const marker = join11(input.holdsDir, input.agentId);
3861
4118
  if (unrecordedHolds.has(input.agentId) || input.flag("scratch-sweep-held", input.agentId)) {
3862
- mkdirSync5(input.holdsDir, { recursive: true });
4119
+ mkdirSync6(input.holdsDir, { recursive: true });
3863
4120
  writeFileSync5(marker, HELD_MARKER);
3864
4121
  unrecordedHolds.delete(input.agentId);
3865
4122
  return HELD;
@@ -3872,7 +4129,7 @@ function resolveScratchSweepPolicy(input) {
3872
4129
  return HELD;
3873
4130
  }
3874
4131
  const now = (input.now ?? Date.now)();
3875
- const off = OFF_SINCE.exec(readFileSync10(marker, "utf8"));
4132
+ const off = OFF_SINCE.exec(readFileSync11(marker, "utf8"));
3876
4133
  if (!off) {
3877
4134
  writeFileSync5(marker, offSince(now, now));
3878
4135
  return HELD;
@@ -3895,7 +4152,7 @@ function resolveScratchSweepPolicy(input) {
3895
4152
  rmSync2(marker, { force: true });
3896
4153
  }
3897
4154
  if (state10 === "not-evaluated") {
3898
- mkdirSync5(input.holdsDir, { recursive: true });
4155
+ mkdirSync6(input.holdsDir, { recursive: true });
3899
4156
  writeFileSync5(marker, HELD_MARKER);
3900
4157
  note(input, "kept=all reason=agent-not-evaluated");
3901
4158
  return HELD;
@@ -3925,15 +4182,15 @@ function recordScratchHoldsFromHeartbeat(input) {
3925
4182
  let held = false;
3926
4183
  try {
3927
4184
  held = input.flag("scratch-sweep-held", id);
3928
- const marker = join10(input.holdsDir, id);
4185
+ const marker = join11(input.holdsDir, id);
3929
4186
  if (held) {
3930
- mkdirSync5(input.holdsDir, { recursive: true });
4187
+ mkdirSync6(input.holdsDir, { recursive: true });
3931
4188
  writeFileSync5(marker, HELD_MARKER);
3932
4189
  unrecordedHolds.delete(id);
3933
4190
  continue;
3934
4191
  }
3935
4192
  if (!existsSync3(marker)) continue;
3936
- const off = OFF_SINCE.exec(readFileSync10(marker, "utf8"));
4193
+ const off = OFF_SINCE.exec(readFileSync11(marker, "utf8"));
3937
4194
  if (!off) continue;
3938
4195
  const since = Number(off[1]);
3939
4196
  const seen = Number(off[2] ?? off[1]);
@@ -3949,8 +4206,8 @@ function recordScratchHoldsFromHeartbeat(input) {
3949
4206
  for (const id of input.hostAgentIds ?? []) {
3950
4207
  if (!safe(id) || evaluated.has(id)) continue;
3951
4208
  try {
3952
- mkdirSync5(input.holdsDir, { recursive: true });
3953
- writeFileSync5(join10(input.holdsDir, id), HELD_MARKER);
4209
+ mkdirSync6(input.holdsDir, { recursive: true });
4210
+ writeFileSync5(join11(input.holdsDir, id), HELD_MARKER);
3954
4211
  } catch (err) {
3955
4212
  unrecordedHolds.add(id);
3956
4213
  const code = err?.code ?? "unknown";
@@ -3961,8 +4218,8 @@ function recordScratchHoldsFromHeartbeat(input) {
3961
4218
  }
3962
4219
 
3963
4220
  // src/lib/id-keyed-migration.ts
3964
- import { existsSync as existsSync4, lstatSync as lstatSync2, readlinkSync, renameSync as renameSync2 } from "fs";
3965
- import { join as join11 } from "path";
4221
+ import { existsSync as existsSync4, lstatSync as lstatSync3, readlinkSync, renameSync as renameSync2 } from "fs";
4222
+ import { join as join12 } from "path";
3966
4223
  import { homedir as homedir3 } from "os";
3967
4224
  var ID_KEYED_MIGRATION_FLAG = "id-keyed-layout-migration";
3968
4225
  function agentHasActiveWhatsapp(channelConfigs, codeNameDir) {
@@ -3970,7 +4227,7 @@ function agentHasActiveWhatsapp(channelConfigs, codeNameDir) {
3970
4227
  return true;
3971
4228
  }
3972
4229
  try {
3973
- if (existsSync4(join11(codeNameDir, "whatsapp-pending-inbound"))) return true;
4230
+ if (existsSync4(join12(codeNameDir, "whatsapp-pending-inbound"))) return true;
3974
4231
  } catch {
3975
4232
  }
3976
4233
  return false;
@@ -4002,13 +4259,13 @@ function finishTranscriptMove(oldCwd, newCwd, codeName, log2) {
4002
4259
  function maybeMigrateAgentToIdKeyedLayout(agent, deps) {
4003
4260
  const home = deps.home ?? homedir3();
4004
4261
  const { code_name: codeName, agent_id: agentId } = agent;
4005
- const codeNamePath = join11(home, ".augmented", codeName);
4006
- const idPath = join11(home, ".augmented", agentId);
4007
- const oldCwd = join11(home, ".augmented", codeName, "project");
4008
- const newCwd = join11(idPath, "project");
4262
+ const codeNamePath = join12(home, ".augmented", codeName);
4263
+ const idPath = join12(home, ".augmented", agentId);
4264
+ const oldCwd = join12(home, ".augmented", codeName, "project");
4265
+ const newCwd = join12(idPath, "project");
4009
4266
  let codeNameKind;
4010
4267
  try {
4011
- codeNameKind = lstatSync2(codeNamePath).isSymbolicLink() ? "symlink" : "realdir";
4268
+ codeNameKind = lstatSync3(codeNamePath).isSymbolicLink() ? "symlink" : "realdir";
4012
4269
  } catch {
4013
4270
  codeNameKind = "absent";
4014
4271
  }
@@ -4266,7 +4523,7 @@ function decideAuthResolveFailureAction(args) {
4266
4523
  }
4267
4524
 
4268
4525
  // ../../packages/core/dist/host-config/capture.js
4269
- import { createHash as createHash5 } from "crypto";
4526
+ import { createHash as createHash6 } from "crypto";
4270
4527
  var NON_SECRET_ENV_GATES = [
4271
4528
  "AGT_MEMORY_EXTRACTION_ENABLED",
4272
4529
  "AGT_CHANNEL_REPLAY_ENABLED",
@@ -4304,8 +4561,8 @@ function collectEnvGates(env) {
4304
4561
  }
4305
4562
 
4306
4563
  // ../../packages/core/dist/direct-chat/cursor-advance-telemetry.js
4307
- import { readFileSync as readFileSync11, writeFileSync as writeFileSync6 } from "fs";
4308
- import { join as join12 } from "path";
4564
+ import { readFileSync as readFileSync12, writeFileSync as writeFileSync6 } from "fs";
4565
+ import { join as join13 } from "path";
4309
4566
  var CURSOR_SHORTFALL_COUNTER_SUFFIX = "-cursor-advance-classifications.json";
4310
4567
  function recordCursorAdvanceOutcome(agentDir, source, route, verdict) {
4311
4568
  if (!agentDir)
@@ -4313,10 +4570,10 @@ function recordCursorAdvanceOutcome(agentDir, source, route, verdict) {
4313
4570
  const key = cursorAdvanceCounterKey(route, verdict);
4314
4571
  if (key === null)
4315
4572
  return;
4316
- const path = join12(agentDir, `${source}${CURSOR_SHORTFALL_COUNTER_SUFFIX}`);
4573
+ const path = join13(agentDir, `${source}${CURSOR_SHORTFALL_COUNTER_SUFFIX}`);
4317
4574
  const counts = {};
4318
4575
  try {
4319
- const parsed = JSON.parse(readFileSync11(path, "utf-8"));
4576
+ const parsed = JSON.parse(readFileSync12(path, "utf-8"));
4320
4577
  if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
4321
4578
  for (const [k, v] of Object.entries(parsed)) {
4322
4579
  if (typeof v === "number" && Number.isInteger(v) && v >= 0)
@@ -4333,7 +4590,7 @@ function recordCursorAdvanceOutcome(agentDir, source, route, verdict) {
4333
4590
  }
4334
4591
 
4335
4592
  // src/lib/artifact-stream.ts
4336
- import { join as join13 } from "path";
4593
+ import { join as join14 } from "path";
4337
4594
  import { homedir as homedir4 } from "os";
4338
4595
  import { readdir, stat, readFile } from "fs/promises";
4339
4596
  var ARTEFACT_ENTRY_FILE = "index.html";
@@ -4419,7 +4676,7 @@ var ArtifactStreamScanner = class {
4419
4676
  return;
4420
4677
  }
4421
4678
  for (const name of names) {
4422
- const file = join13(this.artifactsDir, name, ARTEFACT_ENTRY_FILE);
4679
+ const file = join14(this.artifactsDir, name, ARTEFACT_ENTRY_FILE);
4423
4680
  const mtime = await this.fsDeps.mtimeMs(file).catch(() => null);
4424
4681
  if (mtime === null) continue;
4425
4682
  if (this.seenMtime.get(name) === mtime) continue;
@@ -4450,7 +4707,7 @@ var ArtifactStreamScanner = class {
4450
4707
  }
4451
4708
  };
4452
4709
  function artifactsDirFor(codeName) {
4453
- return join13(homedir4(), ".augmented", codeName, "artifacts");
4710
+ return join14(homedir4(), ".augmented", codeName, "artifacts");
4454
4711
  }
4455
4712
  var nodeArtifactFs = {
4456
4713
  async listArtefactNames(artifactsDir) {
@@ -4723,15 +4980,15 @@ async function maybePollHostUsage(deps) {
4723
4980
  }
4724
4981
 
4725
4982
  // src/lib/claude-account-fingerprint.ts
4726
- import { createHash as createHash6 } from "crypto";
4983
+ import { createHash as createHash7 } from "crypto";
4727
4984
  import { readFile as readFile3, readdir as readdir3 } from "fs/promises";
4728
4985
  import { homedir as homedir6, platform as platform2 } from "os";
4729
- import { dirname as dirname6, join as join15 } from "path";
4986
+ import { dirname as dirname6, join as join16 } from "path";
4730
4987
 
4731
4988
  // src/lib/claude-auth-detect.ts
4732
4989
  import { readFile as readFile2, readdir as readdir2 } from "fs/promises";
4733
4990
  import { homedir as homedir5, platform } from "os";
4734
- import { join as join14 } from "path";
4991
+ import { join as join15 } from "path";
4735
4992
  import { execFile } from "child_process";
4736
4993
  import { promisify } from "util";
4737
4994
  var execFileAsync = promisify(execFile);
@@ -4746,16 +5003,16 @@ async function detectClaudeAuth() {
4746
5003
  }
4747
5004
  async function findClaudeCredentialsPaths() {
4748
5005
  const candidates = [
4749
- join14(homedir5(), ".claude", ".credentials.json"),
4750
- join14(homedir5(), ".claude", "credentials.json")
5006
+ join15(homedir5(), ".claude", ".credentials.json"),
5007
+ join15(homedir5(), ".claude", "credentials.json")
4751
5008
  ];
4752
5009
  const isLinuxRoot = platform() === "linux" && typeof process.getuid === "function" && process.getuid() === 0;
4753
5010
  if (isLinuxRoot) {
4754
5011
  try {
4755
5012
  const entries = await readdir2("/home", { withFileTypes: true });
4756
5013
  for (const entry of entries.filter((entry2) => entry2.isDirectory()).sort((a, b) => a.name.localeCompare(b.name))) {
4757
- candidates.push(join14("/home", entry.name, ".claude", ".credentials.json"));
4758
- candidates.push(join14("/home", entry.name, ".claude", "credentials.json"));
5014
+ candidates.push(join15("/home", entry.name, ".claude", ".credentials.json"));
5015
+ candidates.push(join15("/home", entry.name, ".claude", "credentials.json"));
4759
5016
  }
4760
5017
  } catch {
4761
5018
  }
@@ -4839,7 +5096,7 @@ async function candidateHomes() {
4839
5096
  try {
4840
5097
  const entries = await readdir3("/home", { withFileTypes: true });
4841
5098
  for (const entry of entries.filter((e) => e.isDirectory()).sort((a, b) => a.name.localeCompare(b.name))) {
4842
- homes.push(join15("/home", entry.name));
5099
+ homes.push(join16("/home", entry.name));
4843
5100
  }
4844
5101
  } catch {
4845
5102
  }
@@ -4859,17 +5116,17 @@ async function homeOfActiveCredentials() {
4859
5116
  async function claudeConfigCandidatePaths() {
4860
5117
  const paths = [];
4861
5118
  const configDir = process.env["CLAUDE_CONFIG_DIR"]?.trim();
4862
- if (configDir) paths.push(join15(configDir, ".claude.json"));
5119
+ if (configDir) paths.push(join16(configDir, ".claude.json"));
4863
5120
  const activeHome = await homeOfActiveCredentials();
4864
- if (activeHome) paths.push(join15(activeHome, ".claude.json"));
5121
+ if (activeHome) paths.push(join16(activeHome, ".claude.json"));
4865
5122
  for (const home of await candidateHomes()) {
4866
- const path = join15(home, ".claude.json");
5123
+ const path = join16(home, ".claude.json");
4867
5124
  if (!paths.includes(path)) paths.push(path);
4868
5125
  }
4869
5126
  return paths;
4870
5127
  }
4871
5128
  function hashAccount(accountUuid, organizationUuid) {
4872
- return createHash6("sha256").update(`claude-account:${accountUuid}:${organizationUuid ?? ""}`).digest("hex").slice(0, 12);
5129
+ return createHash7("sha256").update(`claude-account:${accountUuid}:${organizationUuid ?? ""}`).digest("hex").slice(0, 12);
4873
5130
  }
4874
5131
  var ABSENT_CODES = /* @__PURE__ */ new Set(["ENOENT", "ENOTDIR"]);
4875
5132
  function errnoCode(err) {
@@ -5027,11 +5284,11 @@ function diffAuthTuples(recorded, current) {
5027
5284
  }
5028
5285
 
5029
5286
  // src/lib/account-enforcement-marker.ts
5030
- import { mkdirSync as mkdirSync6, renameSync as renameSync3, rmSync as rmSync3, writeFileSync as writeFileSync7 } from "fs";
5287
+ import { mkdirSync as mkdirSync7, renameSync as renameSync3, rmSync as rmSync3, writeFileSync as writeFileSync7 } from "fs";
5031
5288
  import { homedir as homedir7 } from "os";
5032
- import { join as join16 } from "path";
5289
+ import { join as join17 } from "path";
5033
5290
  function accountEnforcementMarkerPath(codeName) {
5034
- return join16(homedir7(), ".augmented", codeName, ACCOUNT_ENFORCEMENT_MARKER_FILENAME);
5291
+ return join17(homedir7(), ".augmented", codeName, ACCOUNT_ENFORCEMENT_MARKER_FILENAME);
5035
5292
  }
5036
5293
  function syncAccountEnforcementMarker(codeName, level, log2 = (m) => process.stderr.write(`${m}
5037
5294
  `), text) {
@@ -5039,11 +5296,11 @@ function syncAccountEnforcementMarker(codeName, level, log2 = (m) => process.std
5039
5296
  clearAccountEnforcementMarker(codeName, log2);
5040
5297
  return;
5041
5298
  }
5042
- const dir = join16(homedir7(), ".augmented", codeName);
5043
- const path = join16(dir, ACCOUNT_ENFORCEMENT_MARKER_FILENAME);
5299
+ const dir = join17(homedir7(), ".augmented", codeName);
5300
+ const path = join17(dir, ACCOUNT_ENFORCEMENT_MARKER_FILENAME);
5044
5301
  const tempPath = `${path}.${process.pid}.tmp`;
5045
5302
  try {
5046
- mkdirSync6(dir, { recursive: true });
5303
+ mkdirSync7(dir, { recursive: true });
5047
5304
  writeFileSync7(tempPath, serializeAccountEnforcementMarker(level, text), "utf-8");
5048
5305
  renameSync3(tempPath, path);
5049
5306
  } catch (err) {
@@ -5065,8 +5322,8 @@ function clearAccountEnforcementMarker(codeName, log2 = (m) => process.stderr.wr
5065
5322
  }
5066
5323
 
5067
5324
  // src/lib/token-usage-monitor.ts
5068
- import { readdirSync, readFileSync as readFileSync12, statSync } from "fs";
5069
- import { join as join17 } from "path";
5325
+ import { readdirSync, readFileSync as readFileSync13, statSync } from "fs";
5326
+ import { join as join18 } from "path";
5070
5327
  var MIN_CHECK_INTERVAL_MS2 = 6e4;
5071
5328
  var TRANSCRIPT_MTIME_WINDOW_MS = 2 * 24 * 60 * 60 * 1e3;
5072
5329
  var MAX_ENTRIES_PER_POST = 200;
@@ -5095,7 +5352,7 @@ async function maybeReportTokenUsage(args) {
5095
5352
  if (!name.endsWith(".jsonl")) continue;
5096
5353
  const sessionId = name.slice(0, -".jsonl".length);
5097
5354
  if (!sessionId) continue;
5098
- const path = join17(dir, name);
5355
+ const path = join18(dir, name);
5099
5356
  let st;
5100
5357
  try {
5101
5358
  st = statSync(path);
@@ -5111,7 +5368,7 @@ async function maybeReportTokenUsage(args) {
5111
5368
  }
5112
5369
  let content;
5113
5370
  try {
5114
- content = readFileSync12(path, "utf-8");
5371
+ content = readFileSync13(path, "utf-8");
5115
5372
  } catch (err) {
5116
5373
  log2(`[token-usage] read failed for '${codeName}/${name}': ${err.message}`);
5117
5374
  continue;
@@ -5192,8 +5449,8 @@ async function maybeReportTokenUsage(args) {
5192
5449
  }
5193
5450
 
5194
5451
  // src/lib/failing-turn-monitor.ts
5195
- import { closeSync, openSync, readdirSync as readdirSync2, readSync, statSync as statSync2 } from "fs";
5196
- import { join as join18 } from "path";
5452
+ import { closeSync as closeSync2, openSync as openSync2, readdirSync as readdirSync2, readSync, statSync as statSync2 } from "fs";
5453
+ import { join as join19 } from "path";
5197
5454
  var MIN_CHECK_INTERVAL_MS3 = 3e4;
5198
5455
  var FAILING_TURN_TAIL_BYTES = 512 * 1024;
5199
5456
  var ACTIVE_TRANSCRIPT_WINDOW_MS = 60 * 60 * 1e3;
@@ -5225,7 +5482,7 @@ function newestActiveTranscript(dir, nowMs) {
5225
5482
  let best = null;
5226
5483
  for (const name of names) {
5227
5484
  if (!name.endsWith(".jsonl")) continue;
5228
- const path = join18(dir, name);
5485
+ const path = join19(dir, name);
5229
5486
  try {
5230
5487
  const st = statSync2(path);
5231
5488
  if (!st.isFile() || nowMs - st.mtimeMs > ACTIVE_TRANSCRIPT_WINDOW_MS) continue;
@@ -5239,11 +5496,11 @@ function newestActiveTranscript(dir, nowMs) {
5239
5496
  function readTail(path, size, bytes = FAILING_TURN_TAIL_BYTES) {
5240
5497
  const length = Math.min(size, bytes);
5241
5498
  const buf = Buffer.alloc(length);
5242
- const fd = openSync(path, "r");
5499
+ const fd = openSync2(path, "r");
5243
5500
  try {
5244
5501
  readSync(fd, buf, 0, length, size - length);
5245
5502
  } finally {
5246
- closeSync(fd);
5503
+ closeSync2(fd);
5247
5504
  }
5248
5505
  return buf.toString("utf-8");
5249
5506
  }
@@ -5297,8 +5554,8 @@ function failingTurnLoops(now = Date.now(), threshold = failingTurnThreshold(),
5297
5554
  }
5298
5555
 
5299
5556
  // src/lib/session-activity.ts
5300
- import { closeSync as closeSync2, openSync as openSync2, readFileSync as readFileSync13, readSync as readSync2, readdirSync as readdirSync3, statSync as statSync3 } from "fs";
5301
- import { join as join19 } from "path";
5557
+ import { closeSync as closeSync3, openSync as openSync3, readFileSync as readFileSync14, readSync as readSync2, readdirSync as readdirSync3, statSync as statSync3 } from "fs";
5558
+ import { join as join20 } from "path";
5302
5559
  var RULE = /^[─━]{10,}/;
5303
5560
  var CARET_LINE = /^\s*❯(\s|$)/;
5304
5561
  var NON_BLOCKING_PICKER = { title: "We recommend compacting earlier", footer: "esc not now", kind: "compaction-suggestion" };
@@ -5358,7 +5615,7 @@ function newestTranscript(dir) {
5358
5615
  let best = null;
5359
5616
  for (const name of names) {
5360
5617
  if (!name.endsWith(".jsonl")) continue;
5361
- const path = join19(dir, name);
5618
+ const path = join20(dir, name);
5362
5619
  try {
5363
5620
  const st = statSync3(path);
5364
5621
  if (st.isFile() && (best === null || st.mtimeMs > best.mtimeMs)) {
@@ -5372,7 +5629,7 @@ function newestTranscript(dir) {
5372
5629
  }
5373
5630
  function sessionTranscript(dir, sessionId) {
5374
5631
  if (!sessionId) return newestTranscript(dir);
5375
- const path = join19(dir, `${sessionId}.jsonl`);
5632
+ const path = join20(dir, `${sessionId}.jsonl`);
5376
5633
  try {
5377
5634
  const st = statSync3(path);
5378
5635
  return st.isFile() ? { path, mtimeMs: st.mtimeMs, size: st.size } : null;
@@ -5413,12 +5670,12 @@ function scanNewLines(path, size, scan, budget, log2) {
5413
5670
  const length = Math.min(size - offset, budget);
5414
5671
  if (length <= 0) return 0;
5415
5672
  const buffer = Buffer.alloc(length);
5416
- const fd = openSync2(path, "r");
5673
+ const fd = openSync3(path, "r");
5417
5674
  let read;
5418
5675
  try {
5419
5676
  read = readSync2(fd, buffer, 0, length, offset);
5420
5677
  } finally {
5421
- closeSync2(fd);
5678
+ closeSync3(fd);
5422
5679
  }
5423
5680
  let window = buffer.subarray(0, read);
5424
5681
  let base = offset;
@@ -5460,7 +5717,7 @@ function subagentFiles(dir) {
5460
5717
  }
5461
5718
  return names.flatMap((name) => {
5462
5719
  if (!name.endsWith(".jsonl")) return [];
5463
- const path = join19(dir, name);
5720
+ const path = join20(dir, name);
5464
5721
  try {
5465
5722
  const st = statSync3(path);
5466
5723
  return st.isFile() ? [{ path, mtimeMs: st.mtimeMs, size: st.size }] : [];
@@ -5474,7 +5731,7 @@ function knownProcessStartMs(session) {
5474
5731
  return session.startedAt === session.estimatedStartedAt ? null : session.startedAt;
5475
5732
  }
5476
5733
  function drainScan(scan, dir, log2) {
5477
- const main = join19(dir, `${scan.sessionId}.jsonl`);
5734
+ const main = join20(dir, `${scan.sessionId}.jsonl`);
5478
5735
  let budget = BACKGROUND_SCAN_BYTES_PER_POLL;
5479
5736
  try {
5480
5737
  budget -= scanNewLines(main, statSync3(main).size, scan, budget, log2);
@@ -5491,7 +5748,7 @@ function readBackgroundActivity(codeName, dir, sessionId, spawnedAtMs, isSpawnSe
5491
5748
  const sameRun = prev?.sessionId === sessionId && prev.spawnedAtMs === spawnedAtMs;
5492
5749
  if (prev && sameRun && minCheckMs > 0 && nowMs - prev.checkedAt < minCheckMs) return prev;
5493
5750
  try {
5494
- const main = join19(dir, `${sessionId}.jsonl`);
5751
+ const main = join20(dir, `${sessionId}.jsonl`);
5495
5752
  let size;
5496
5753
  try {
5497
5754
  size = statSync3(main).size;
@@ -5539,7 +5796,7 @@ function readBackgroundActivity(codeName, dir, sessionId, spawnedAtMs, isSpawnSe
5539
5796
  }
5540
5797
  function readRecordedSession(agentDir) {
5541
5798
  try {
5542
- const parsed = JSON.parse(readFileSync13(join19(agentDir, "session-state.json"), "utf-8"));
5799
+ const parsed = JSON.parse(readFileSync14(join20(agentDir, "session-state.json"), "utf-8"));
5543
5800
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
5544
5801
  const { session_id: sessionId, recorded_at: recordedAtMs } = parsed;
5545
5802
  if (typeof sessionId !== "string" || typeof recordedAtMs !== "number" || !Number.isFinite(recordedAtMs)) return null;
@@ -5631,8 +5888,8 @@ function buildSessionActivityReport(args) {
5631
5888
  }
5632
5889
 
5633
5890
  // src/lib/workflow-run-reconciler.ts
5634
- import { readdirSync as readdirSync4, readFileSync as readFileSync14, statSync as statSync4 } from "fs";
5635
- import { join as join20 } from "path";
5891
+ import { readdirSync as readdirSync4, readFileSync as readFileSync15, statSync as statSync4 } from "fs";
5892
+ import { join as join21 } from "path";
5636
5893
  var MIN_CHECK_INTERVAL_MS4 = 5 * 6e4;
5637
5894
  var SETTLE_MS = 3e4;
5638
5895
  var TRANSCRIPT_MTIME_WINDOW_MS2 = 2 * 24 * 60 * 60 * 1e3;
@@ -5671,7 +5928,7 @@ function collectJsonlRecursive(dir, minMtimeMs, out, depth) {
5671
5928
  return;
5672
5929
  }
5673
5930
  for (const name of entries) {
5674
- const p = join20(dir, name);
5931
+ const p = join21(dir, name);
5675
5932
  let st;
5676
5933
  try {
5677
5934
  st = statSync4(p);
@@ -5694,7 +5951,7 @@ function enumerateTranscriptFiles(transcriptDir, nowMs, minMtimeMs = nowMs - TRA
5694
5951
  return out;
5695
5952
  }
5696
5953
  for (const name of entries) {
5697
- const path = join20(transcriptDir, name);
5954
+ const path = join21(transcriptDir, name);
5698
5955
  let st;
5699
5956
  try {
5700
5957
  st = statSync4(path);
@@ -5706,7 +5963,7 @@ function enumerateTranscriptFiles(transcriptDir, nowMs, minMtimeMs = nowMs - TRA
5706
5963
  continue;
5707
5964
  }
5708
5965
  if (st.isDirectory()) {
5709
- collectJsonlRecursive(join20(path, "subagents"), minMtimeMs, out, 0);
5966
+ collectJsonlRecursive(join21(path, "subagents"), minMtimeMs, out, 0);
5710
5967
  }
5711
5968
  }
5712
5969
  return out;
@@ -5750,7 +6007,7 @@ async function maybeReconcileWorkflowRunTokens(args) {
5750
6007
  const contents = [];
5751
6008
  for (const path of files) {
5752
6009
  try {
5753
- contents.push(readFileSync14(path, "utf-8"));
6010
+ contents.push(readFileSync15(path, "utf-8"));
5754
6011
  } catch {
5755
6012
  }
5756
6013
  }
@@ -5795,8 +6052,8 @@ async function maybeReconcileWorkflowRunTokens(args) {
5795
6052
  }
5796
6053
 
5797
6054
  // src/lib/conversation-evaluator.ts
5798
- import { readdirSync as readdirSync5, readFileSync as readFileSync15, statSync as statSync5 } from "fs";
5799
- import { join as join21 } from "path";
6055
+ import { readdirSync as readdirSync5, readFileSync as readFileSync16, statSync as statSync5 } from "fs";
6056
+ import { join as join22 } from "path";
5800
6057
 
5801
6058
  // src/lib/detect-meta-egress.ts
5802
6059
  var REPOST_PREAMBLE_WINDOW = 200;
@@ -6281,7 +6538,7 @@ function readRecentTurns(dir, nowMs) {
6281
6538
  return;
6282
6539
  }
6283
6540
  for (const ent of entries) {
6284
- const full = join21(d, ent.name);
6541
+ const full = join22(d, ent.name);
6285
6542
  if (ent.isDirectory()) {
6286
6543
  visit(full);
6287
6544
  continue;
@@ -6296,7 +6553,7 @@ function readRecentTurns(dir, nowMs) {
6296
6553
  if (nowMs - mtimeMs > TRANSCRIPT_MTIME_WINDOW_MS3) continue;
6297
6554
  let content;
6298
6555
  try {
6299
- content = readFileSync15(full, "utf8");
6556
+ content = readFileSync16(full, "utf8");
6300
6557
  } catch {
6301
6558
  continue;
6302
6559
  }
@@ -6669,22 +6926,22 @@ async function reportSkip2(api2, agentId, conversationId, log2, codeName) {
6669
6926
 
6670
6927
  // src/lib/tool-call-audit.ts
6671
6928
  import { homedir as homedir11 } from "os";
6672
- import { join as join26 } from "path";
6929
+ import { join as join27 } from "path";
6673
6930
 
6674
6931
  // src/lib/agent-logging-mode.ts
6675
- import { readFileSync as readFileSync16 } from "fs";
6932
+ import { readFileSync as readFileSync17 } from "fs";
6676
6933
  import { homedir as homedir8 } from "os";
6677
- import { join as join22 } from "path";
6934
+ import { join as join23 } from "path";
6678
6935
  var LOGGING_MODES = ["hash-only", "redacted", "full-local"];
6679
6936
  function charterPath(codeName, homeDir) {
6680
6937
  const home = homeDir ?? (process.env["HOME"]?.trim() || homedir8());
6681
6938
  const key = agentRuntimeKey(codeName, homeDir);
6682
- return join22(home, ".augmented", key, "provision", "CHARTER.md");
6939
+ return join23(home, ".augmented", key, "provision", "CHARTER.md");
6683
6940
  }
6684
6941
  function readAgentLoggingMode(codeName, homeDir) {
6685
6942
  let raw;
6686
6943
  try {
6687
- raw = readFileSync16(charterPath(codeName, homeDir), "utf-8");
6944
+ raw = readFileSync17(charterPath(codeName, homeDir), "utf-8");
6688
6945
  } catch {
6689
6946
  return { mode: null, reason: "no-charter" };
6690
6947
  }
@@ -6708,15 +6965,15 @@ function loggingModeWithholdsTargets(reading) {
6708
6965
 
6709
6966
  // src/lib/tool-call-path-salt.ts
6710
6967
  import { randomBytes } from "crypto";
6711
- import { existsSync as existsSync5, mkdirSync as mkdirSync7, readFileSync as readFileSync17, renameSync as renameSync4, unlinkSync as unlinkSync2, writeFileSync as writeFileSync8 } from "fs";
6968
+ import { existsSync as existsSync5, mkdirSync as mkdirSync8, readFileSync as readFileSync18, renameSync as renameSync4, unlinkSync as unlinkSync2, writeFileSync as writeFileSync8 } from "fs";
6712
6969
  import { homedir as homedir9 } from "os";
6713
- import { dirname as dirname7, join as join23 } from "path";
6970
+ import { dirname as dirname7, join as join24 } from "path";
6714
6971
  var SALT_BYTES = 32;
6715
6972
  var SALT_RE = /^[0-9a-f]{64}$/;
6716
6973
  function pathSaltPath(codeName, homeDir) {
6717
6974
  const home = homeDir ?? (process.env["HOME"]?.trim() || homedir9());
6718
6975
  const key = agentRuntimeKey(codeName, homeDir);
6719
- return join23(home, ".augmented", key, "tool-call-path-salt");
6976
+ return join24(home, ".augmented", key, "tool-call-path-salt");
6720
6977
  }
6721
6978
  function readToolCallPathSalt(codeName, homeDir) {
6722
6979
  let file;
@@ -6727,7 +6984,7 @@ function readToolCallPathSalt(codeName, homeDir) {
6727
6984
  }
6728
6985
  try {
6729
6986
  if (existsSync5(file)) {
6730
- const existing = readFileSync17(file, "utf-8").trim();
6987
+ const existing = readFileSync18(file, "utf-8").trim();
6731
6988
  if (SALT_RE.test(existing)) return existing;
6732
6989
  }
6733
6990
  } catch {
@@ -6735,7 +6992,7 @@ function readToolCallPathSalt(codeName, homeDir) {
6735
6992
  const salt = randomBytes(SALT_BYTES).toString("hex");
6736
6993
  const tmp = `${file}.tmp.${process.pid}`;
6737
6994
  try {
6738
- mkdirSync7(dirname7(file), { recursive: true, mode: 448 });
6995
+ mkdirSync8(dirname7(file), { recursive: true, mode: 448 });
6739
6996
  writeFileSync8(tmp, `${salt}
6740
6997
  `, { encoding: "utf-8", mode: 384 });
6741
6998
  renameSync4(tmp, file);
@@ -6753,20 +7010,20 @@ function readToolCallPathSalt(codeName, homeDir) {
6753
7010
  import { statSync as statSync6 } from "fs";
6754
7011
 
6755
7012
  // src/lib/tool-call-extractor.ts
6756
- import { closeSync as closeSync3, fstatSync, openSync as openSync3, readFileSync as readFileSync18, readSync as readSync3, readdirSync as readdirSync6 } from "fs";
6757
- import { basename as basename2, join as join24, relative } from "path";
7013
+ import { closeSync as closeSync4, fstatSync as fstatSync2, openSync as openSync4, readFileSync as readFileSync19, readSync as readSync3, readdirSync as readdirSync6 } from "fs";
7014
+ import { basename as basename2, join as join25, relative } from "path";
6758
7015
  import { StringDecoder } from "string_decoder";
6759
7016
 
6760
7017
  // src/lib/tool-call-redaction.ts
6761
7018
  import { createHmac } from "crypto";
6762
7019
 
6763
7020
  // ../../packages/core/dist/tool-calls/input-hash.js
6764
- import { createHash as createHash7 } from "crypto";
7021
+ import { createHash as createHash8 } from "crypto";
6765
7022
  function hashToolInput(input) {
6766
7023
  if (input === void 0)
6767
7024
  return null;
6768
7025
  try {
6769
- return createHash7("sha256").update(canonicalJson2(input)).digest("hex");
7026
+ return createHash8("sha256").update(canonicalJson2(input)).digest("hex");
6770
7027
  } catch {
6771
7028
  return null;
6772
7029
  }
@@ -6883,7 +7140,7 @@ function redactToolTargetInner(toolName, input, ctx) {
6883
7140
  var EXTRACTOR_VERSION = "e1";
6884
7141
  function enumerateSessionTranscripts(transcriptDir, sessionId, projectsRoot) {
6885
7142
  const files = [];
6886
- const mainAbs = join24(transcriptDir, `${sessionId}.jsonl`);
7143
+ const mainAbs = join25(transcriptDir, `${sessionId}.jsonl`);
6887
7144
  files.push({
6888
7145
  absPath: mainAbs,
6889
7146
  relPath: relative(projectsRoot, mainAbs),
@@ -6891,7 +7148,7 @@ function enumerateSessionTranscripts(transcriptDir, sessionId, projectsRoot) {
6891
7148
  isSubagent: false,
6892
7149
  subagentId: null
6893
7150
  });
6894
- const subDir = join24(transcriptDir, sessionId, "subagents");
7151
+ const subDir = join25(transcriptDir, sessionId, "subagents");
6895
7152
  let entries;
6896
7153
  try {
6897
7154
  entries = readdirSync6(subDir);
@@ -6900,7 +7157,7 @@ function enumerateSessionTranscripts(transcriptDir, sessionId, projectsRoot) {
6900
7157
  }
6901
7158
  for (const name of entries) {
6902
7159
  if (!name.endsWith(".jsonl")) continue;
6903
- const abs = join24(subDir, name);
7160
+ const abs = join25(subDir, name);
6904
7161
  const stem = basename2(name, ".jsonl");
6905
7162
  files.push({
6906
7163
  absPath: abs,
@@ -7003,7 +7260,7 @@ var WINDOW_BUDGET_BYTES = 4 * 1024 * 1024;
7003
7260
  function extractTranscriptWindow(file, opts, from) {
7004
7261
  let fd;
7005
7262
  try {
7006
- fd = openSync3(file.absPath, "r");
7263
+ fd = openSync4(file.absPath, "r");
7007
7264
  } catch {
7008
7265
  return {
7009
7266
  records: [],
@@ -7024,7 +7281,7 @@ function extractTranscriptWindow(file, opts, from) {
7024
7281
  let rewound = false;
7025
7282
  let fileSize = null;
7026
7283
  try {
7027
- const { size } = fstatSync(fd);
7284
+ const { size } = fstatSync2(fd);
7028
7285
  fileSize = size;
7029
7286
  if (startByte > size) {
7030
7287
  startByte = 0;
@@ -7072,7 +7329,7 @@ function extractTranscriptWindow(file, opts, from) {
7072
7329
  } catch {
7073
7330
  } finally {
7074
7331
  try {
7075
- closeSync3(fd);
7332
+ closeSync4(fd);
7076
7333
  } catch {
7077
7334
  }
7078
7335
  }
@@ -7098,9 +7355,9 @@ function extractTranscriptWindow(file, opts, from) {
7098
7355
  }
7099
7356
 
7100
7357
  // src/lib/tool-call-cursor.ts
7101
- import { existsSync as existsSync6, readFileSync as readFileSync19 } from "fs";
7358
+ import { existsSync as existsSync6, readFileSync as readFileSync20 } from "fs";
7102
7359
  import { homedir as homedir10 } from "os";
7103
- import { join as join25 } from "path";
7360
+ import { join as join26 } from "path";
7104
7361
  var COVERAGE_DISPOSITIONS = [
7105
7362
  "ok",
7106
7363
  "not_entitled",
@@ -7155,13 +7412,13 @@ function parseCursorKey(key) {
7155
7412
  function cursorStatePath(codeName, homeDir) {
7156
7413
  const home = homeDir ?? (process.env["HOME"]?.trim() || homedir10());
7157
7414
  const key = agentRuntimeKey(codeName, homeDir);
7158
- return join25(home, ".augmented", key, "tool-call-cursors.json");
7415
+ return join26(home, ".augmented", key, "tool-call-cursors.json");
7159
7416
  }
7160
7417
  function loadCursors(path) {
7161
7418
  const out = /* @__PURE__ */ new Map();
7162
7419
  if (!existsSync6(path)) return out;
7163
7420
  try {
7164
- const parsed = JSON.parse(readFileSync19(path, "utf-8"));
7421
+ const parsed = JSON.parse(readFileSync20(path, "utf-8"));
7165
7422
  if (!parsed || parsed.version !== 1 || typeof parsed.files !== "object") return out;
7166
7423
  for (const [k, v] of Object.entries(parsed.files)) {
7167
7424
  if (!v || typeof v !== "object") continue;
@@ -7568,7 +7825,7 @@ async function maybeScanToolCalls(args) {
7568
7825
  log2(`[tool-call-audit] ${codeName}: no path-hash salt available \u2014 file targets withheld`);
7569
7826
  }
7570
7827
  const home = args.homeDir ?? (process.env["HOME"]?.trim() || homedir11());
7571
- const projectsRoot = args.projectsRoot ?? join26(home, ".claude", "projects");
7828
+ const projectsRoot = args.projectsRoot ?? join27(home, ".claude", "projects");
7572
7829
  const transcriptDir = args.transcriptDir ?? sessionTranscriptDir(getProjectDir(codeName));
7573
7830
  const current = peekCurrentSession(codeName);
7574
7831
  const sessionIds = current ? [current.sessionId] : [];
@@ -7597,11 +7854,11 @@ async function maybeScanToolCalls(args) {
7597
7854
  }
7598
7855
 
7599
7856
  // src/lib/activity-cache-monitor.ts
7600
- import { existsSync as existsSync7, readFileSync as readFileSync20 } from "fs";
7857
+ import { existsSync as existsSync7, readFileSync as readFileSync21 } from "fs";
7601
7858
  import { homedir as homedir12 } from "os";
7602
- import { join as join27 } from "path";
7859
+ import { join as join28 } from "path";
7603
7860
  var MIN_CHECK_INTERVAL_MS8 = 6e4;
7604
- var STATS_CACHE_PATH = join27(homedir12(), ".claude", "stats-cache.json");
7861
+ var STATS_CACHE_PATH = join28(homedir12(), ".claude", "stats-cache.json");
7605
7862
  var ISO_DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
7606
7863
  var state8 = { lastObservedDate: null, lastCheckedAt: 0 };
7607
7864
  function selectNewDailyRows(raw, lastObservedDate) {
@@ -7649,7 +7906,7 @@ async function maybeReportActivityCache(args) {
7649
7906
  }
7650
7907
  let raw;
7651
7908
  try {
7652
- raw = readFileSync20(STATS_CACHE_PATH, "utf-8");
7909
+ raw = readFileSync21(STATS_CACHE_PATH, "utf-8");
7653
7910
  } catch (err) {
7654
7911
  log2(`[activity-cache] readFileSync failed: ${err.message}`);
7655
7912
  return;
@@ -7922,7 +8179,7 @@ function deviceStateHoldApplies(inputs) {
7922
8179
  }
7923
8180
 
7924
8181
  // src/lib/channel-config-hash.ts
7925
- import { createHash as createHash8 } from "crypto";
8182
+ import { createHash as createHash9 } from "crypto";
7926
8183
  var DERIVED_PRINCIPAL_ID_LIST_KEYS = [
7927
8184
  "allowed_users",
7928
8185
  "diagnostic_chat_ids",
@@ -7943,7 +8200,7 @@ function normalizeChannelConfigForHash(config2) {
7943
8200
  }
7944
8201
  var CHANNEL_WRITE_VERSION = 9;
7945
8202
  function computeChannelConfigHash(input) {
7946
- return createHash8("sha256").update(
8203
+ return createHash9("sha256").update(
7947
8204
  canonicalJson({
7948
8205
  writeVersion: CHANNEL_WRITE_VERSION,
7949
8206
  cliVersion: input.cliVersion,
@@ -7967,11 +8224,11 @@ function computeChannelConfigHash(input) {
7967
8224
  }
7968
8225
 
7969
8226
  // src/lib/knowledge-cache.ts
7970
- import { createHash as createHash9 } from "crypto";
8227
+ import { createHash as createHash10 } from "crypto";
7971
8228
  import {
7972
8229
  existsSync as existsSync8,
7973
- mkdirSync as mkdirSync8,
7974
- readFileSync as readFileSync21,
8230
+ mkdirSync as mkdirSync9,
8231
+ readFileSync as readFileSync22,
7975
8232
  readdirSync as readdirSync7,
7976
8233
  renameSync as renameSync5,
7977
8234
  rmSync as rmSync4,
@@ -7979,21 +8236,21 @@ import {
7979
8236
  utimesSync,
7980
8237
  writeFileSync as writeFileSync9
7981
8238
  } from "fs";
7982
- import { join as join28 } from "path";
8239
+ import { join as join29 } from "path";
7983
8240
  var KNOWLEDGE_FETCH_CHUNK = 100;
7984
8241
  var CACHE_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
7985
8242
  var SWEEP_INTERVAL_MS = 24 * 60 * 60 * 1e3;
7986
8243
  var lastSweepAt = 0;
7987
8244
  function knowledgeHash(content) {
7988
- return createHash9("sha256").update(content, "utf8").digest("hex");
8245
+ return createHash10("sha256").update(content, "utf8").digest("hex");
7989
8246
  }
7990
8247
  function cachePath(cacheDir, hash) {
7991
- return join28(cacheDir, hash);
8248
+ return join29(cacheDir, hash);
7992
8249
  }
7993
8250
  function readCachedKnowledge(cacheDir, hash) {
7994
8251
  const path = cachePath(cacheDir, hash);
7995
8252
  try {
7996
- const content = readFileSync21(path, "utf-8");
8253
+ const content = readFileSync22(path, "utf-8");
7997
8254
  try {
7998
8255
  const now = /* @__PURE__ */ new Date();
7999
8256
  utimesSync(path, now, now);
@@ -8007,7 +8264,7 @@ function readCachedKnowledge(cacheDir, hash) {
8007
8264
  function writeCachedKnowledge(cacheDir, hash, content) {
8008
8265
  if (knowledgeHash(content) !== hash) return false;
8009
8266
  try {
8010
- mkdirSync8(cacheDir, { recursive: true });
8267
+ mkdirSync9(cacheDir, { recursive: true });
8011
8268
  const tmp = `${cachePath(cacheDir, hash)}.tmp-${process.pid}`;
8012
8269
  writeFileSync9(tmp, content, "utf-8");
8013
8270
  renameSync5(tmp, cachePath(cacheDir, hash));
@@ -8022,7 +8279,7 @@ function sweepKnowledgeCache(cacheDir, now = Date.now()) {
8022
8279
  try {
8023
8280
  if (!existsSync8(cacheDir)) return;
8024
8281
  for (const name of readdirSync7(cacheDir)) {
8025
- const path = join28(cacheDir, name);
8282
+ const path = join29(cacheDir, name);
8026
8283
  try {
8027
8284
  if (now - statSync8(path).mtimeMs > CACHE_TTL_MS) rmSync4(path, { force: true });
8028
8285
  } catch {
@@ -8070,11 +8327,11 @@ async function resolveKnowledgeFromManifest(args) {
8070
8327
  }
8071
8328
 
8072
8329
  // src/lib/memory-cache.ts
8073
- import { createHash as createHash10 } from "crypto";
8330
+ import { createHash as createHash11 } from "crypto";
8074
8331
  import {
8075
8332
  existsSync as existsSync9,
8076
- mkdirSync as mkdirSync9,
8077
- readFileSync as readFileSync22,
8333
+ mkdirSync as mkdirSync10,
8334
+ readFileSync as readFileSync23,
8078
8335
  readdirSync as readdirSync8,
8079
8336
  renameSync as renameSync6,
8080
8337
  rmSync as rmSync5,
@@ -8082,21 +8339,21 @@ import {
8082
8339
  utimesSync as utimesSync2,
8083
8340
  writeFileSync as writeFileSync10
8084
8341
  } from "fs";
8085
- import { join as join29 } from "path";
8342
+ import { join as join30 } from "path";
8086
8343
  var MEMORY_FETCH_CHUNK = 100;
8087
8344
  var CACHE_TTL_MS2 = 30 * 24 * 60 * 60 * 1e3;
8088
8345
  var SWEEP_INTERVAL_MS2 = 24 * 60 * 60 * 1e3;
8089
8346
  var lastSweepAt2 = /* @__PURE__ */ new Map();
8090
8347
  function memoryHash(content) {
8091
- return createHash10("sha256").update(content, "utf8").digest("hex");
8348
+ return createHash11("sha256").update(content, "utf8").digest("hex");
8092
8349
  }
8093
8350
  function cachePath2(cacheDir, hash) {
8094
- return join29(cacheDir, hash);
8351
+ return join30(cacheDir, hash);
8095
8352
  }
8096
8353
  function readCachedMemory(cacheDir, hash) {
8097
8354
  const path = cachePath2(cacheDir, hash);
8098
8355
  try {
8099
- const content = readFileSync22(path, "utf-8");
8356
+ const content = readFileSync23(path, "utf-8");
8100
8357
  try {
8101
8358
  const now = /* @__PURE__ */ new Date();
8102
8359
  utimesSync2(path, now, now);
@@ -8110,7 +8367,7 @@ function readCachedMemory(cacheDir, hash) {
8110
8367
  function writeCachedMemory(cacheDir, hash, content) {
8111
8368
  if (memoryHash(content) !== hash) return false;
8112
8369
  try {
8113
- mkdirSync9(cacheDir, { recursive: true });
8370
+ mkdirSync10(cacheDir, { recursive: true });
8114
8371
  const tmp = `${cachePath2(cacheDir, hash)}.tmp-${process.pid}`;
8115
8372
  writeFileSync10(tmp, content, "utf-8");
8116
8373
  renameSync6(tmp, cachePath2(cacheDir, hash));
@@ -8125,7 +8382,7 @@ function sweepMemoryCache(cacheDir, now = Date.now()) {
8125
8382
  try {
8126
8383
  if (!existsSync9(cacheDir)) return;
8127
8384
  for (const name of readdirSync8(cacheDir)) {
8128
- const path = join29(cacheDir, name);
8385
+ const path = join30(cacheDir, name);
8129
8386
  try {
8130
8387
  if (now - statSync9(path).mtimeMs > CACHE_TTL_MS2) rmSync5(path, { force: true });
8131
8388
  } catch {
@@ -8179,11 +8436,11 @@ async function resolveMemoriesFromManifest(args) {
8179
8436
  }
8180
8437
 
8181
8438
  // src/lib/skill-cache.ts
8182
- import { createHash as createHash11 } from "crypto";
8439
+ import { createHash as createHash12 } from "crypto";
8183
8440
  import {
8184
8441
  existsSync as existsSync10,
8185
- mkdirSync as mkdirSync10,
8186
- readFileSync as readFileSync23,
8442
+ mkdirSync as mkdirSync11,
8443
+ readFileSync as readFileSync24,
8187
8444
  readdirSync as readdirSync9,
8188
8445
  renameSync as renameSync7,
8189
8446
  rmSync as rmSync6,
@@ -8191,21 +8448,21 @@ import {
8191
8448
  utimesSync as utimesSync3,
8192
8449
  writeFileSync as writeFileSync11
8193
8450
  } from "fs";
8194
- import { join as join30 } from "path";
8451
+ import { join as join31 } from "path";
8195
8452
  var SKILL_FETCH_CHUNK = 100;
8196
8453
  var CACHE_TTL_MS3 = 30 * 24 * 60 * 60 * 1e3;
8197
8454
  var SWEEP_INTERVAL_MS3 = 24 * 60 * 60 * 1e3;
8198
8455
  var lastSweepAt3 = 0;
8199
8456
  function skillHash(content) {
8200
- return createHash11("sha256").update(content, "utf8").digest("hex");
8457
+ return createHash12("sha256").update(content, "utf8").digest("hex");
8201
8458
  }
8202
8459
  function cachePath3(cacheDir, hash) {
8203
- return join30(cacheDir, hash);
8460
+ return join31(cacheDir, hash);
8204
8461
  }
8205
8462
  function readCachedSkill(cacheDir, hash) {
8206
8463
  const path = cachePath3(cacheDir, hash);
8207
8464
  try {
8208
- const content = readFileSync23(path, "utf-8");
8465
+ const content = readFileSync24(path, "utf-8");
8209
8466
  try {
8210
8467
  const now = /* @__PURE__ */ new Date();
8211
8468
  utimesSync3(path, now, now);
@@ -8219,7 +8476,7 @@ function readCachedSkill(cacheDir, hash) {
8219
8476
  function writeCachedSkill(cacheDir, hash, content) {
8220
8477
  if (skillHash(content) !== hash) return "mismatch";
8221
8478
  try {
8222
- mkdirSync10(cacheDir, { recursive: true });
8479
+ mkdirSync11(cacheDir, { recursive: true });
8223
8480
  const tmp = `${cachePath3(cacheDir, hash)}.tmp-${process.pid}`;
8224
8481
  writeFileSync11(tmp, content, "utf-8");
8225
8482
  renameSync7(tmp, cachePath3(cacheDir, hash));
@@ -8234,7 +8491,7 @@ function sweepSkillCache(cacheDir, now = Date.now()) {
8234
8491
  try {
8235
8492
  if (!existsSync10(cacheDir)) return;
8236
8493
  for (const name of readdirSync9(cacheDir)) {
8237
- const path = join30(cacheDir, name);
8494
+ const path = join31(cacheDir, name);
8238
8495
  try {
8239
8496
  if (now - statSync10(path).mtimeMs > CACHE_TTL_MS3) rmSync6(path, { force: true });
8240
8497
  } catch {
@@ -8563,18 +8820,18 @@ function resolveConditionalResponse(wire, hasCachedBody) {
8563
8820
  }
8564
8821
 
8565
8822
  // src/lib/channel-hash-cache.ts
8566
- import { existsSync as existsSync11, readFileSync as readFileSync24, writeFileSync as writeFileSync12 } from "fs";
8567
- import { join as join31 } from "path";
8823
+ import { existsSync as existsSync11, readFileSync as readFileSync25, writeFileSync as writeFileSync12 } from "fs";
8824
+ import { join as join32 } from "path";
8568
8825
  var CACHE_FILENAME = "channel-hash-cache.json";
8569
8826
  function getChannelHashCacheFile(configDir) {
8570
- return join31(configDir, CACHE_FILENAME);
8827
+ return join32(configDir, CACHE_FILENAME);
8571
8828
  }
8572
8829
  function loadChannelHashCache(target, configDir) {
8573
8830
  const path = getChannelHashCacheFile(configDir);
8574
8831
  if (!existsSync11(path)) return;
8575
8832
  let parsed;
8576
8833
  try {
8577
- parsed = JSON.parse(readFileSync24(path, "utf-8"));
8834
+ parsed = JSON.parse(readFileSync25(path, "utf-8"));
8578
8835
  } catch {
8579
8836
  return;
8580
8837
  }
@@ -8594,8 +8851,8 @@ function saveChannelHashCache(source, configDir) {
8594
8851
  }
8595
8852
 
8596
8853
  // src/lib/sender-policy-baseline.ts
8597
- import { existsSync as existsSync12, readFileSync as readFileSync25 } from "fs";
8598
- import { join as join32 } from "path";
8854
+ import { existsSync as existsSync12, readFileSync as readFileSync26 } from "fs";
8855
+ import { join as join33 } from "path";
8599
8856
  var BASELINE_FILENAME = "sender-policy-baseline.json";
8600
8857
  var SENDER_POLICY_BASELINE_VERSION = 1;
8601
8858
  var BASELINE_CONCERNS = [
@@ -8651,14 +8908,14 @@ function createDeliveryBaselineMaps() {
8651
8908
  };
8652
8909
  }
8653
8910
  function getSenderPolicyBaselineFile(configDir) {
8654
- return join32(configDir, BASELINE_FILENAME);
8911
+ return join33(configDir, BASELINE_FILENAME);
8655
8912
  }
8656
8913
  function loadSenderPolicyBaseline(target, configDir, log2) {
8657
8914
  const path = getSenderPolicyBaselineFile(configDir);
8658
8915
  if (!existsSync12(path)) return;
8659
8916
  let parsed;
8660
8917
  try {
8661
- parsed = JSON.parse(readFileSync25(path, "utf-8"));
8918
+ parsed = JSON.parse(readFileSync26(path, "utf-8"));
8662
8919
  } catch (err) {
8663
8920
  log2?.(
8664
8921
  `[sender-policy] discarding corrupt ${BASELINE_FILENAME} (${err.message}) - restrictive-policy agents will take one fail-closed restart`
@@ -8737,8 +8994,8 @@ function resolveIntegrationEgressDomains(fetched, persisted) {
8737
8994
  }
8738
8995
 
8739
8996
  // src/lib/stuck-streak-store.ts
8740
- import { existsSync as existsSync13, readFileSync as readFileSync26 } from "fs";
8741
- import { join as join33 } from "path";
8997
+ import { existsSync as existsSync13, readFileSync as readFileSync27 } from "fs";
8998
+ import { join as join34 } from "path";
8742
8999
  var STORE_FILENAME = "stuck-streaks.json";
8743
9000
  var STUCK_STREAK_STORE_VERSION = 1;
8744
9001
  var STUCK_STREAK_CONCERNS = ["channelSync", "realtimeRebind"];
@@ -8746,7 +9003,7 @@ function createStuckStreakMaps() {
8746
9003
  return { channelSync: /* @__PURE__ */ new Map(), realtimeRebind: /* @__PURE__ */ new Map() };
8747
9004
  }
8748
9005
  function getStuckStreakStoreFile(configDir) {
8749
- return join33(configDir, STORE_FILENAME);
9006
+ return join34(configDir, STORE_FILENAME);
8750
9007
  }
8751
9008
  function isValidPersistedStreak(value) {
8752
9009
  if (!value || typeof value !== "object" || Array.isArray(value)) return false;
@@ -8788,7 +9045,7 @@ function loadStuckStreaks(target, configDir, log2) {
8788
9045
  if (!existsSync13(path)) return;
8789
9046
  let parsed;
8790
9047
  try {
8791
- parsed = JSON.parse(readFileSync26(path, "utf-8"));
9048
+ parsed = JSON.parse(readFileSync27(path, "utf-8"));
8792
9049
  } catch (err) {
8793
9050
  log2?.(
8794
9051
  `[stuck-streaks] discarding corrupt ${STORE_FILENAME} (${err.message}) \u2014 stuck-streak ages restart from zero and one spurious "recovered" close may follow`
@@ -8831,7 +9088,7 @@ function pruneStuckStreaksToAgents(maps, activeAgentIds) {
8831
9088
  }
8832
9089
 
8833
9090
  // src/lib/claude-device-state.ts
8834
- import { readFileSync as readFileSync27, statSync as statSync11 } from "fs";
9091
+ import { readFileSync as readFileSync28, statSync as statSync11 } from "fs";
8835
9092
  function claudeDeviceStatePath(env = process.env) {
8836
9093
  return effectiveClaudeJsonPath(void 0, env);
8837
9094
  }
@@ -8856,7 +9113,7 @@ function checkClaudeDeviceState(path = claudeDeviceStatePath()) {
8856
9113
  }
8857
9114
  let raw;
8858
9115
  try {
8859
- raw = readFileSync27(path, "utf-8");
9116
+ raw = readFileSync28(path, "utf-8");
8860
9117
  } catch {
8861
9118
  return { usable: false, reason: "unreadable" };
8862
9119
  }
@@ -9548,7 +9805,7 @@ function planGlobalSkillSync(globalSkills, prevIds, hashOf, knownHash, options)
9548
9805
  }
9549
9806
 
9550
9807
  // src/lib/manager/integration-skill-cache.ts
9551
- import { join as join34 } from "path";
9808
+ import { join as join35 } from "path";
9552
9809
  function integrationSkillHashKey(agentId, skillId) {
9553
9810
  return `plugin-skill:${agentId}:${skillId}`;
9554
9811
  }
@@ -9564,21 +9821,21 @@ function forgetIntegrationSkill(cache3, agentId, skillId) {
9564
9821
  function removeIntegrationSkillFolder(opts) {
9565
9822
  forgetIntegrationSkill(opts.cache, opts.agentId, opts.entry);
9566
9823
  for (const dir of opts.dirs) {
9567
- opts.removeDir(join34(dir, opts.entry));
9824
+ opts.removeDir(join35(dir, opts.entry));
9568
9825
  }
9569
9826
  }
9570
9827
 
9571
9828
  // src/lib/manager/managed-skill-manifest.ts
9572
- import { existsSync as existsSync14, mkdirSync as mkdirSync11, readFileSync as readFileSync28, writeFileSync as writeFileSync13 } from "fs";
9573
- import { dirname as dirname8, join as join35 } from "path";
9829
+ import { existsSync as existsSync14, mkdirSync as mkdirSync12, readFileSync as readFileSync29, writeFileSync as writeFileSync13 } from "fs";
9830
+ import { dirname as dirname8, join as join36 } from "path";
9574
9831
  var MANIFEST_VERSION = 1;
9575
9832
  function managedSkillManifestPath(agentRootDir) {
9576
- return join35(agentRootDir, "managed-skills.json");
9833
+ return join36(agentRootDir, "managed-skills.json");
9577
9834
  }
9578
9835
  function readManagedSkillManifest(path) {
9579
9836
  try {
9580
9837
  if (!existsSync14(path)) return /* @__PURE__ */ new Set();
9581
- const parsed = JSON.parse(readFileSync28(path, "utf-8"));
9838
+ const parsed = JSON.parse(readFileSync29(path, "utf-8"));
9582
9839
  const ids = Array.isArray(parsed?.globalSkillIds) ? parsed.globalSkillIds : [];
9583
9840
  return new Set(ids.filter((id) => typeof id === "string" && id.length > 0));
9584
9841
  } catch {
@@ -9587,7 +9844,7 @@ function readManagedSkillManifest(path) {
9587
9844
  }
9588
9845
  function writeManagedSkillManifest(path, ids) {
9589
9846
  try {
9590
- mkdirSync11(dirname8(path), { recursive: true });
9847
+ mkdirSync12(dirname8(path), { recursive: true });
9591
9848
  const body = {
9592
9849
  version: MANIFEST_VERSION,
9593
9850
  globalSkillIds: [...ids].sort()
@@ -9727,8 +9984,8 @@ function resolveModelChain(refreshData) {
9727
9984
  }
9728
9985
 
9729
9986
  // src/lib/manager/claude-auth.ts
9730
- import { chmodSync as chmodSync2, existsSync as existsSync15, lstatSync as lstatSync3, mkdirSync as mkdirSync12, rmSync as rmSync7 } from "fs";
9731
- import { join as join36 } from "path";
9987
+ import { chmodSync as chmodSync2, existsSync as existsSync15, lstatSync as lstatSync4, mkdirSync as mkdirSync13, rmSync as rmSync7 } from "fs";
9988
+ import { join as join37 } from "path";
9732
9989
  import { homedir as homedir13 } from "os";
9733
9990
  async function applyClaudeAuthToEnv(childEnv, label, options = {}) {
9734
9991
  const apiKey = getApiKey();
@@ -9747,7 +10004,7 @@ async function applyClaudeAuthToEnv(childEnv, label, options = {}) {
9747
10004
  }
9748
10005
  const claudeDir = claudeConfigDirForChild(childEnv);
9749
10006
  for (const filename of [".credentials.json", "credentials.json"]) {
9750
- const p = join36(claudeDir, filename);
10007
+ const p = join37(claudeDir, filename);
9751
10008
  if (existsSync15(p)) {
9752
10009
  try {
9753
10010
  rmSync7(p, { force: true });
@@ -9762,23 +10019,23 @@ async function applyClaudeAuthToEnv(childEnv, label, options = {}) {
9762
10019
  return { isolated: false };
9763
10020
  }
9764
10021
  function claudeConfigDirForChild(childEnv) {
9765
- return childEnv.CLAUDE_CONFIG_DIR?.trim() || join36(homedir13(), ".claude");
10022
+ return childEnv.CLAUDE_CONFIG_DIR?.trim() || join37(homedir13(), ".claude");
9766
10023
  }
9767
10024
  function ensurePrivateConfigDir(dir, platform4 = process.platform, chmod = chmodSync2) {
9768
- mkdirSync12(dir, { recursive: true, mode: 448 });
9769
- const st = lstatSync3(dir);
10025
+ mkdirSync13(dir, { recursive: true, mode: 448 });
10026
+ const st = lstatSync4(dir);
9770
10027
  if (!st.isDirectory()) {
9771
10028
  throw new Error(`isolated Claude config dir ${dir} is not a real directory (symlink or file); refusing`);
9772
10029
  }
9773
10030
  if (platform4 === "win32") return;
9774
10031
  if ((st.mode & 511) !== 448) chmod(dir, 448);
9775
- const mode = lstatSync3(dir).mode & 511;
10032
+ const mode = lstatSync4(dir).mode & 511;
9776
10033
  if (mode !== 448) {
9777
10034
  throw new Error(`isolated Claude config dir ${dir} could not be made private (mode ${mode.toString(8)}); refusing`);
9778
10035
  }
9779
10036
  }
9780
10037
  function oneShotIsolatedConfigDir() {
9781
- return join36(homedir13(), ".augmented", "claude-oneshot");
10038
+ return join37(homedir13(), ".augmented", "claude-oneshot");
9782
10039
  }
9783
10040
 
9784
10041
  // src/lib/claude-runtime-auth-probe.ts
@@ -10123,19 +10380,19 @@ function formatBoardForPrompt(items, template) {
10123
10380
  }
10124
10381
 
10125
10382
  // src/lib/manager/kanban/nudge-state-cache.ts
10126
- import { existsSync as existsSync16, readFileSync as readFileSync29, writeFileSync as writeFileSync14 } from "fs";
10127
- import { join as join37 } from "path";
10383
+ import { existsSync as existsSync16, readFileSync as readFileSync30, writeFileSync as writeFileSync14 } from "fs";
10384
+ import { join as join38 } from "path";
10128
10385
  var CACHE_FILENAME2 = "kanban-nudge-state.json";
10129
10386
  var KANBAN_NUDGE_STATE_VERSION = 1;
10130
10387
  function getKanbanNudgeStateFile(configDir) {
10131
- return join37(configDir, CACHE_FILENAME2);
10388
+ return join38(configDir, CACHE_FILENAME2);
10132
10389
  }
10133
10390
  function loadKanbanNudgeState(target, configDir) {
10134
10391
  const path = getKanbanNudgeStateFile(configDir);
10135
10392
  if (!existsSync16(path)) return;
10136
10393
  let parsed;
10137
10394
  try {
10138
- parsed = JSON.parse(readFileSync29(path, "utf-8"));
10395
+ parsed = JSON.parse(readFileSync30(path, "utf-8"));
10139
10396
  } catch {
10140
10397
  return;
10141
10398
  }
@@ -10173,7 +10430,7 @@ function saveKanbanNudgeState(source, configDir) {
10173
10430
  }
10174
10431
 
10175
10432
  // src/lib/manager/kanban/notify.ts
10176
- import { createHash as createHash12 } from "crypto";
10433
+ import { createHash as createHash13 } from "crypto";
10177
10434
  async function enqueueKanbanNotice(opts) {
10178
10435
  try {
10179
10436
  const res = await api.post(
@@ -10188,7 +10445,7 @@ async function enqueueKanbanNotice(opts) {
10188
10445
  return res.ok === true;
10189
10446
  } catch (err) {
10190
10447
  const errText = err instanceof Error ? err.message : String(err);
10191
- const errId = createHash12("sha256").update(errText).digest("hex").slice(0, 12);
10448
+ const errId = createHash13("sha256").update(errText).digest("hex").slice(0, 12);
10192
10449
  log(`[kanban] notice enqueue failed for agent_id=${opts.agentId} error_id=${errId}`);
10193
10450
  return false;
10194
10451
  }
@@ -10203,7 +10460,7 @@ async function cancelKanbanNotice(agentId) {
10203
10460
  return typeof res.cancelled === "number" ? res.cancelled : 0;
10204
10461
  } catch (err) {
10205
10462
  const errText = err instanceof Error ? err.message : String(err);
10206
- const errId = createHash12("sha256").update(errText).digest("hex").slice(0, 12);
10463
+ const errId = createHash13("sha256").update(errText).digest("hex").slice(0, 12);
10207
10464
  log(`[kanban] notice cancel failed for agent_id=${agentId} error_id=${errId}`);
10208
10465
  return null;
10209
10466
  }
@@ -10700,7 +10957,7 @@ function deriveScheduledTaskNotify(task) {
10700
10957
  }
10701
10958
 
10702
10959
  // src/lib/manager/scheduler/runs.ts
10703
- import { createHash as createHash13 } from "crypto";
10960
+ import { createHash as createHash14 } from "crypto";
10704
10961
  async function startRun(opts) {
10705
10962
  try {
10706
10963
  const res = await api.post(
@@ -10715,7 +10972,7 @@ async function startRun(opts) {
10715
10972
  };
10716
10973
  } catch (err) {
10717
10974
  const errText = err instanceof Error ? err.message : String(err);
10718
- const errId = createHash13("sha256").update(errText).digest("hex").slice(0, 12);
10975
+ const errId = createHash14("sha256").update(errText).digest("hex").slice(0, 12);
10719
10976
  log(`[runs] start failed for agent_id=${opts.agent_id} source_type=${opts.source_type} error_id=${errId}`);
10720
10977
  return { run_id: null, kanban_item_id: null };
10721
10978
  }
@@ -10754,7 +11011,7 @@ async function finishRun(runId, outcome, options = {}) {
10754
11011
  return;
10755
11012
  } catch (err) {
10756
11013
  const errText = err instanceof Error ? err.message : String(err);
10757
- const errId = createHash13("sha256").update(errText).digest("hex").slice(0, 12);
11014
+ const errId = createHash14("sha256").update(errText).digest("hex").slice(0, 12);
10758
11015
  const status = err instanceof ApiError ? err.status : 0;
10759
11016
  if (isRetryableFinishError(err) && attempt < maxRetries) {
10760
11017
  log(
@@ -10783,7 +11040,7 @@ async function fetchPriorScheduledRuns(agentId, taskId) {
10783
11040
  return rows.filter((r) => typeof r.output_text === "string" && r.output_text.length > 0).map((r) => ({ startedAt: r.started_at, output: r.output_text }));
10784
11041
  } catch (err) {
10785
11042
  const errText = err instanceof Error ? err.message : String(err);
10786
- const errId = createHash13("sha256").update(errText).digest("hex").slice(0, 12);
11043
+ const errId = createHash14("sha256").update(errText).digest("hex").slice(0, 12);
10787
11044
  log(`[runs] prior-runs lookup failed for task_id=${taskId} error_id=${errId}`);
10788
11045
  return [];
10789
11046
  }
@@ -10844,13 +11101,13 @@ function closeSessionRunForCode(codeName, outcome, reason) {
10844
11101
  }
10845
11102
 
10846
11103
  // src/lib/manager/scheduler/kanban-route.ts
10847
- import { createHash as createHash15 } from "crypto";
10848
- import { writeFileSync as writeFileSync15, renameSync as renameSync8, mkdirSync as mkdirSync13, readFileSync as readFileSync30, unlinkSync as unlinkSync3 } from "fs";
11104
+ import { createHash as createHash16 } from "crypto";
11105
+ import { writeFileSync as writeFileSync15, renameSync as renameSync8, mkdirSync as mkdirSync14, readFileSync as readFileSync31, unlinkSync as unlinkSync3 } from "fs";
10849
11106
  import { homedir as homedir14 } from "os";
10850
- import { join as join38, dirname as dirname9 } from "path";
11107
+ import { join as join39, dirname as dirname9 } from "path";
10851
11108
 
10852
11109
  // src/lib/manager/scheduler/notify.ts
10853
- import { createHash as createHash14 } from "crypto";
11110
+ import { createHash as createHash15 } from "crypto";
10854
11111
  async function enqueueScheduledTaskNotice(opts) {
10855
11112
  try {
10856
11113
  const res = await api.post(
@@ -10867,7 +11124,7 @@ async function enqueueScheduledTaskNotice(opts) {
10867
11124
  return res.ok === true;
10868
11125
  } catch (err) {
10869
11126
  const errText = err instanceof Error ? err.message : String(err);
10870
- const errId = createHash14("sha256").update(errText).digest("hex").slice(0, 12);
11127
+ const errId = createHash15("sha256").update(errText).digest("hex").slice(0, 12);
10871
11128
  log(
10872
11129
  `[scheduled-kanban] notice enqueue failed for agent_id=${opts.agentId} task_id=${opts.taskId} error_id=${errId}`
10873
11130
  );
@@ -11210,7 +11467,7 @@ function resolveScheduledSlackTarget(task) {
11210
11467
  }
11211
11468
  function stampScheduledTurnMarker(codeName, taskId, target) {
11212
11469
  try {
11213
- const file = join38(homedir14(), ".augmented", codeName, SCHEDULED_TURN_MARKER_FILENAME);
11470
+ const file = join39(homedir14(), ".augmented", codeName, SCHEDULED_TURN_MARKER_FILENAME);
11214
11471
  const marker = { ts: Date.now(), task_id: taskId, ...target ? { target } : {} };
11215
11472
  const tmp = `${file}.tmp`;
11216
11473
  writeFileSync15(tmp, JSON.stringify(marker), "utf8");
@@ -11220,9 +11477,9 @@ function stampScheduledTurnMarker(codeName, taskId, target) {
11220
11477
  }
11221
11478
  }
11222
11479
  function clearScheduledTurnMarkerForTask(codeName, taskId) {
11223
- const file = join38(homedir14(), ".augmented", codeName, SCHEDULED_TURN_MARKER_FILENAME);
11480
+ const file = join39(homedir14(), ".augmented", codeName, SCHEDULED_TURN_MARKER_FILENAME);
11224
11481
  try {
11225
- const raw = JSON.parse(readFileSync30(file, "utf8"));
11482
+ const raw = JSON.parse(readFileSync31(file, "utf8"));
11226
11483
  if (typeof raw?.task_id !== "string" || raw.task_id !== taskId) return;
11227
11484
  unlinkSync3(file);
11228
11485
  log(`[scheduled-kanban] scheduled-turn marker cleared for '${codeName}' (task ${taskId} complete)`);
@@ -11289,7 +11546,7 @@ async function routeScheduledTaskViaKanban(codeName, agentId, task, prompt, dura
11289
11546
  if (!enqueued) return false;
11290
11547
  try {
11291
11548
  const doorbell = directChatDoorbellPath(agentId, homedir14());
11292
- mkdirSync13(dirname9(doorbell), { recursive: true });
11549
+ mkdirSync14(dirname9(doorbell), { recursive: true });
11293
11550
  writeFileSync15(doorbell, String(Date.now()));
11294
11551
  } catch (err) {
11295
11552
  log(`[scheduled-kanban] doorbell ring failed for '${codeName}': ${err.message} (notice still queued)`);
@@ -11380,24 +11637,24 @@ async function processClaudeTaskResult(codeName, agentId, templateId, rawOutput,
11380
11637
  const assertion = parseDeliverAssertion(rawOutput);
11381
11638
  if (!assertion.deliver) {
11382
11639
  const trimmed = (rawOutput ?? "").trim();
11383
- const outputHash = trimmed.length === 0 ? "empty" : createHash15("sha256").update(trimmed).digest("hex").slice(0, 12);
11640
+ const outputHash = trimmed.length === 0 ? "empty" : createHash16("sha256").update(trimmed).digest("hex").slice(0, 12);
11384
11641
  log(`[claude-scheduler] Suppressed by delivery_policy=conditional for '${codeName}' (template=${templateId}, task=${delivery?.taskId ?? "n/a"}) \u2014 ${assertion.vacuous ? "deliver marker had a vacuous reason" : "no deliver marker"}; output_len=${trimmed.length} output_hash=${outputHash}`);
11385
11642
  if (delivery?.mode === "announce" && delivery.to) {
11386
11643
  await reportDeliveryStatus(agentId, delivery.taskId, { status: "skipped", error_code: "SUPPRESSED_BY_POLICY" });
11387
11644
  }
11388
11645
  return { ok: true };
11389
11646
  }
11390
- const reasonHash = createHash15("sha256").update(assertion.reason ?? "").digest("hex").slice(0, 12);
11647
+ const reasonHash = createHash16("sha256").update(assertion.reason ?? "").digest("hex").slice(0, 12);
11391
11648
  log(`[claude-scheduler] Delivering conditional run for '${codeName}' (template=${templateId}, task=${delivery?.taskId ?? "n/a"}) \u2014 agent asserted a concrete trigger (reason_len=${(assertion.reason ?? "").length} reason_hash=${reasonHash})`);
11392
11649
  rawOutput = assertion.deliverable;
11393
11650
  }
11394
11651
  const classification = classifyOutput(rawOutput);
11395
11652
  if (classification.action === "suppress") {
11396
11653
  const trimmed = (rawOutput ?? "").trim();
11397
- const outputHash = trimmed.length === 0 ? "empty" : createHash15("sha256").update(trimmed).digest("hex").slice(0, 12);
11654
+ const outputHash = trimmed.length === 0 ? "empty" : createHash16("sha256").update(trimmed).digest("hex").slice(0, 12);
11398
11655
  log(`[claude-scheduler] Suppressing delivery for '${codeName}' (template=${templateId}, task=${delivery?.taskId ?? "n/a"}) \u2014 output_len=${trimmed.length} output_hash=${outputHash}`);
11399
11656
  if (classification.suppressedNotes) {
11400
- const notesHash = createHash15("sha256").update(classification.suppressedNotes).digest("hex").slice(0, 12);
11657
+ const notesHash = createHash16("sha256").update(classification.suppressedNotes).digest("hex").slice(0, 12);
11401
11658
  log(`[claude-scheduler] Suppressed notes for '${codeName}' (task=${delivery?.taskId ?? "n/a"}) \u2014 notes_len=${classification.suppressedNotes.length} notes_hash=${notesHash}`);
11402
11659
  }
11403
11660
  if (delivery?.mode === "announce" && delivery.to) {
@@ -11469,13 +11726,13 @@ async function processClaudeTaskResult(codeName, agentId, templateId, rawOutput,
11469
11726
  }
11470
11727
 
11471
11728
  // src/lib/manager/scheduler/execution.ts
11472
- import { createHash as createHash16 } from "crypto";
11729
+ import { createHash as createHash17 } from "crypto";
11473
11730
  import { homedir as homedir15 } from "os";
11474
- import { join as join40 } from "path";
11731
+ import { join as join41 } from "path";
11475
11732
 
11476
11733
  // src/lib/agent-serving-probe.ts
11477
- import { readFileSync as readFileSync31, readdirSync as readdirSync10, statSync as statSync12 } from "fs";
11478
- import { join as join39 } from "path";
11734
+ import { readFileSync as readFileSync32, readdirSync as readdirSync10, statSync as statSync12 } from "fs";
11735
+ import { join as join40 } from "path";
11479
11736
  var RATE_LIMIT_WINDOW_MS = 6 * 60 * 60 * 1e3;
11480
11737
  function probeRateLimit(args) {
11481
11738
  const now = args.now ?? /* @__PURE__ */ new Date();
@@ -11491,7 +11748,7 @@ function probeRateLimit(args) {
11491
11748
  let newest = UNKNOWN_RATE_LIMIT;
11492
11749
  for (const name of entries) {
11493
11750
  if (!name.endsWith(".jsonl")) continue;
11494
- const path = join39(dir, name);
11751
+ const path = join40(dir, name);
11495
11752
  try {
11496
11753
  const st = statSync12(path);
11497
11754
  if (!st.isFile() || st.mtimeMs < startMs) continue;
@@ -11500,7 +11757,7 @@ function probeRateLimit(args) {
11500
11757
  }
11501
11758
  let content;
11502
11759
  try {
11503
- content = readFileSync31(path, "utf-8");
11760
+ content = readFileSync32(path, "utf-8");
11504
11761
  } catch {
11505
11762
  continue;
11506
11763
  }
@@ -11562,7 +11819,7 @@ function shouldLogUsageCapDeferral(site, codeName, limitedUntil) {
11562
11819
 
11563
11820
  // src/lib/manager/scheduler/execution.ts
11564
11821
  function claudePidFilePath() {
11565
- return join40(homedir15(), ".augmented", "manager-claude-pids.json");
11822
+ return join41(homedir15(), ".augmented", "manager-claude-pids.json");
11566
11823
  }
11567
11824
  var inFlightClaudePids = /* @__PURE__ */ new Map();
11568
11825
  function registerClaudeSpawn(record) {
@@ -11582,10 +11839,10 @@ function unregisterClaudeSpawn(pid) {
11582
11839
  }
11583
11840
  async function syncAndCheckClaudeScheduler(agent, tasks, boardItems, refreshData, durableScheduledNudge = false) {
11584
11841
  const codeName = agent.code_name;
11585
- const stableTasksHash = createHash16("sha256").update(JSON.stringify(tasks)).digest("hex").slice(0, 16);
11586
- const boardHash = boardItems.length > 0 ? createHash16("sha256").update(JSON.stringify(boardItems.map((b) => ({ id: b.id, title: b.title, status: b.status, priority: b.priority, deliverable: b.deliverable })))).digest("hex").slice(0, 16) : "empty";
11842
+ const stableTasksHash = createHash17("sha256").update(JSON.stringify(tasks)).digest("hex").slice(0, 16);
11843
+ const boardHash = boardItems.length > 0 ? createHash17("sha256").update(JSON.stringify(boardItems.map((b) => ({ id: b.id, title: b.title, status: b.status, priority: b.priority, deliverable: b.deliverable })))).digest("hex").slice(0, 16) : "empty";
11587
11844
  const resolvedModels = resolveModelChain(refreshData);
11588
- const modelsHash = createHash16("sha256").update(JSON.stringify(resolvedModels)).digest("hex").slice(0, 16);
11845
+ const modelsHash = createHash17("sha256").update(JSON.stringify(resolvedModels)).digest("hex").slice(0, 16);
11589
11846
  const combinedHash = `${stableTasksHash}:${boardHash}:${modelsHash}`;
11590
11847
  const prevHash = agentState.knownTasksHashes.get(agent.agent_id);
11591
11848
  if (combinedHash !== prevHash) {
@@ -11854,8 +12111,8 @@ function respawnedByAnotherCaller(decision, healthyAfter, sessionStartedAt, lane
11854
12111
  }
11855
12112
 
11856
12113
  // src/lib/occupancy-gate.ts
11857
- import { closeSync as closeSync4, openSync as openSync4, readdirSync as readdirSync11, readSync as readSync4, statSync as statSync13 } from "fs";
11858
- import { join as join41 } from "path";
12114
+ import { closeSync as closeSync5, openSync as openSync5, readdirSync as readdirSync11, readSync as readSync4, statSync as statSync13 } from "fs";
12115
+ import { join as join42 } from "path";
11859
12116
  function rostersMeasuredZero(mode, attested, runtimeRunning) {
11860
12117
  return mode === "enforce" && attested && runtimeRunning;
11861
12118
  }
@@ -11871,7 +12128,7 @@ function readAlignedTail(path, tailBytes, maxAlignBytes) {
11871
12128
  try {
11872
12129
  const size = statSync13(path).size;
11873
12130
  if (size <= 0) return { content: "", complete: true, truncated: false };
11874
- fd = openSync4(path, "r");
12131
+ fd = openSync5(path, "r");
11875
12132
  let readStart = Math.max(0, size - tailBytes);
11876
12133
  if (readStart > 0) {
11877
12134
  const scanFloor = Math.max(0, readStart - maxAlignBytes);
@@ -11907,7 +12164,7 @@ function readAlignedTail(path, tailBytes, maxAlignBytes) {
11907
12164
  } finally {
11908
12165
  if (fd != null) {
11909
12166
  try {
11910
- closeSync4(fd);
12167
+ closeSync5(fd);
11911
12168
  } catch {
11912
12169
  }
11913
12170
  }
@@ -11946,10 +12203,10 @@ function candidateTranscriptPaths(dir) {
11946
12203
  let complete = true;
11947
12204
  for (const name of top) {
11948
12205
  if (name.endsWith(".jsonl")) {
11949
- paths.push(join41(dir, name));
12206
+ paths.push(join42(dir, name));
11950
12207
  continue;
11951
12208
  }
11952
- const subDir = join41(dir, name, "subagents");
12209
+ const subDir = join42(dir, name, "subagents");
11953
12210
  let subs;
11954
12211
  try {
11955
12212
  subs = readdirSync11(subDir);
@@ -11958,7 +12215,7 @@ function candidateTranscriptPaths(dir) {
11958
12215
  continue;
11959
12216
  }
11960
12217
  for (const sub of subs) {
11961
- if (sub.endsWith(".jsonl")) paths.push(join41(subDir, sub));
12218
+ if (sub.endsWith(".jsonl")) paths.push(join42(subDir, sub));
11962
12219
  }
11963
12220
  }
11964
12221
  return { paths, complete };
@@ -12184,7 +12441,7 @@ function stopPaneOccupancySampler() {
12184
12441
  }
12185
12442
 
12186
12443
  // src/lib/pid-pressure-sampler.ts
12187
- import { existsSync as existsSync17, readFileSync as readFileSync32 } from "fs";
12444
+ import { existsSync as existsSync17, readFileSync as readFileSync33 } from "fs";
12188
12445
  var SAMPLE_INTERVAL_MS2 = 3e4;
12189
12446
  function warnFraction() {
12190
12447
  const raw = Number(process.env.AGT_PID_PRESSURE_WARN_FRACTION);
@@ -12212,7 +12469,7 @@ function parseMemoryEvents(text) {
12212
12469
  }
12213
12470
  function readTextReal(path) {
12214
12471
  try {
12215
- return readFileSync32(path, "utf-8");
12472
+ return readFileSync33(path, "utf-8");
12216
12473
  } catch {
12217
12474
  return null;
12218
12475
  }
@@ -12452,7 +12709,7 @@ function stopRuntimeVersionSampler() {
12452
12709
  }
12453
12710
 
12454
12711
  // src/lib/opencode-slack-ingest.ts
12455
- import { createHash as createHash17 } from "crypto";
12712
+ import { createHash as createHash18 } from "crypto";
12456
12713
 
12457
12714
  // ../../packages/core/dist/channels/slack-rich-text.js
12458
12715
  var MAX_DEPTH = 12;
@@ -13420,7 +13677,7 @@ function startSlackIngest(config2) {
13420
13677
  // src/lib/opencode-slack-ingest.ts
13421
13678
  var ingests = /* @__PURE__ */ new Map();
13422
13679
  function fingerprint(params) {
13423
- return createHash17("sha256").update(
13680
+ return createHash18("sha256").update(
13424
13681
  JSON.stringify({
13425
13682
  appToken: params.appToken,
13426
13683
  botToken: params.botToken,
@@ -13501,7 +13758,7 @@ function stopAllOpencodeSlackIngests(log2) {
13501
13758
  }
13502
13759
 
13503
13760
  // src/lib/manager/opencode-scheduler.ts
13504
- import { createHash as createHash18 } from "crypto";
13761
+ import { createHash as createHash19 } from "crypto";
13505
13762
  var MAX_OPENCODE_SCHED_CONCURRENCY = 2;
13506
13763
  var opencodeSchedulerStates = /* @__PURE__ */ new Map();
13507
13764
  var inFlightOpencodeTasks = /* @__PURE__ */ new Set();
@@ -13515,7 +13772,7 @@ function shouldDeliver(task, reply) {
13515
13772
  }
13516
13773
  async function syncAndCheckOpencodeScheduler(agent, tasks, refreshData) {
13517
13774
  const codeName = agent.code_name;
13518
- const tasksHash = createHash18("sha256").update(JSON.stringify(tasks)).digest("hex").slice(0, 16);
13775
+ const tasksHash = createHash19("sha256").update(JSON.stringify(tasks)).digest("hex").slice(0, 16);
13519
13776
  if (knownOpencodeTaskHashes.get(agent.agent_id) !== tasksHash) {
13520
13777
  const taskInputs = tasks.map((t) => buildSchedulerTaskInput(t));
13521
13778
  const state11 = syncTasksToScheduler(codeName, agent.agent_id, taskInputs);
@@ -13593,10 +13850,10 @@ async function fireOpencodeScheduledTask(agent, task) {
13593
13850
  }
13594
13851
 
13595
13852
  // src/lib/opencode-telegram-ingest.ts
13596
- import { createHash as createHash19 } from "crypto";
13597
- import { existsSync as existsSync18, mkdirSync as mkdirSync14, readFileSync as readFileSync33, renameSync as renameSync9, unlinkSync as unlinkSync4, writeFileSync as writeFileSync16 } from "fs";
13853
+ import { createHash as createHash20 } from "crypto";
13854
+ import { existsSync as existsSync18, mkdirSync as mkdirSync15, readFileSync as readFileSync34, renameSync as renameSync9, unlinkSync as unlinkSync4, writeFileSync as writeFileSync16 } from "fs";
13598
13855
  import { randomUUID } from "crypto";
13599
- import { join as join42 } from "path";
13856
+ import { join as join43 } from "path";
13600
13857
 
13601
13858
  // src/lib/telegram-ingest.ts
13602
13859
  import https2 from "https";
@@ -14277,7 +14534,7 @@ function anySignal(signals) {
14277
14534
  var ingests2 = /* @__PURE__ */ new Map();
14278
14535
  var migrationQueues = /* @__PURE__ */ new Map();
14279
14536
  function fingerprint2(params) {
14280
- return createHash19("sha256").update(
14537
+ return createHash20("sha256").update(
14281
14538
  JSON.stringify({
14282
14539
  botToken: params.botToken,
14283
14540
  allowedChats: [...params.allowedChats].sort(),
@@ -14299,7 +14556,7 @@ function createFileOffsetStore(codeName, log2, currentBotId) {
14299
14556
  let filePath;
14300
14557
  try {
14301
14558
  dir = getFramework("opencode").getAgentDir(codeName);
14302
- filePath = join42(dir, "telegram-getupdates-offset-opencode.json");
14559
+ filePath = join43(dir, "telegram-getupdates-offset-opencode.json");
14303
14560
  } catch {
14304
14561
  dir = null;
14305
14562
  filePath = null;
@@ -14308,7 +14565,7 @@ function createFileOffsetStore(codeName, log2, currentBotId) {
14308
14565
  load() {
14309
14566
  if (!filePath) return 0;
14310
14567
  try {
14311
- const parsed = JSON.parse(readFileSync33(filePath, "utf-8"));
14568
+ const parsed = JSON.parse(readFileSync34(filePath, "utf-8"));
14312
14569
  if (currentBotId != null && typeof parsed?.bot_id === "number" && parsed.bot_id !== currentBotId) {
14313
14570
  log2(`[telegram-ingest:${codeName}] offset cursor belongs to a different bot; ignoring (bot swap)`);
14314
14571
  return 0;
@@ -14326,7 +14583,7 @@ function createFileOffsetStore(codeName, log2, currentBotId) {
14326
14583
  if (!filePath || !dir) return;
14327
14584
  const tmpPath = `${filePath}.${process.pid}.${randomUUID()}.tmp`;
14328
14585
  try {
14329
- mkdirSync14(dir, { recursive: true, mode: 448 });
14586
+ mkdirSync15(dir, { recursive: true, mode: 448 });
14330
14587
  writeFileSync16(
14331
14588
  tmpPath,
14332
14589
  JSON.stringify({
@@ -14353,7 +14610,7 @@ function createFileMigrationReportIO(codeName, log2) {
14353
14610
  let filePath;
14354
14611
  try {
14355
14612
  dir = getFramework("opencode").getAgentDir(codeName);
14356
- filePath = join42(dir, "telegram-migration-reports-opencode.json");
14613
+ filePath = join43(dir, "telegram-migration-reports-opencode.json");
14357
14614
  } catch {
14358
14615
  dir = null;
14359
14616
  filePath = null;
@@ -14362,7 +14619,7 @@ function createFileMigrationReportIO(codeName, log2) {
14362
14619
  load() {
14363
14620
  if (!filePath) return null;
14364
14621
  try {
14365
- return readFileSync33(filePath, "utf-8");
14622
+ return readFileSync34(filePath, "utf-8");
14366
14623
  } catch {
14367
14624
  return null;
14368
14625
  }
@@ -14370,7 +14627,7 @@ function createFileMigrationReportIO(codeName, log2) {
14370
14627
  save(data) {
14371
14628
  if (!filePath || !dir) return;
14372
14629
  try {
14373
- mkdirSync14(dir, { recursive: true, mode: 448 });
14630
+ mkdirSync15(dir, { recursive: true, mode: 448 });
14374
14631
  atomicWriteFileSync(filePath, data, { mode: 384 });
14375
14632
  } catch (err) {
14376
14633
  log2(`[telegram-ingest:${codeName}] migration-report persist failed: ${err instanceof Error ? err.message : String(err)}`);
@@ -14379,7 +14636,7 @@ function createFileMigrationReportIO(codeName, log2) {
14379
14636
  };
14380
14637
  }
14381
14638
  var managerHostPost = async (path, body) => {
14382
- const { api: api2, ApiError: ApiError3 } = await import("../api-client-5CNPCJKS.js");
14639
+ const { api: api2, ApiError: ApiError3 } = await import("../api-client-NGXHG4YA.js");
14383
14640
  try {
14384
14641
  const json = await api2.post(path, body);
14385
14642
  return { status: 200, json };
@@ -14645,15 +14902,15 @@ function partitionActionableByPoison(actionable, states, config2) {
14645
14902
  }
14646
14903
 
14647
14904
  // src/lib/restart-flags.ts
14648
- import { existsSync as existsSync19, mkdirSync as mkdirSync15, readdirSync as readdirSync12, readFileSync as readFileSync34, renameSync as renameSync10, rmSync as rmSync8, writeFileSync as writeFileSync17 } from "fs";
14905
+ import { existsSync as existsSync19, mkdirSync as mkdirSync16, readdirSync as readdirSync12, readFileSync as readFileSync35, renameSync as renameSync10, rmSync as rmSync8, writeFileSync as writeFileSync17 } from "fs";
14649
14906
  import { homedir as homedir16 } from "os";
14650
- import { join as join43 } from "path";
14907
+ import { join as join44 } from "path";
14651
14908
  import { randomUUID as randomUUID2 } from "crypto";
14652
14909
  function restartFlagsDir() {
14653
- return join43(homedir16(), ".augmented", "restart-flags");
14910
+ return join44(homedir16(), ".augmented", "restart-flags");
14654
14911
  }
14655
14912
  function flagPath(codeName) {
14656
- return join43(restartFlagsDir(), `${codeName}.flag`);
14913
+ return join44(restartFlagsDir(), `${codeName}.flag`);
14657
14914
  }
14658
14915
  function readRestartFlags() {
14659
14916
  const dir = restartFlagsDir();
@@ -14662,7 +14919,7 @@ function readRestartFlags() {
14662
14919
  for (const entry of readdirSync12(dir)) {
14663
14920
  if (!entry.endsWith(".flag")) continue;
14664
14921
  try {
14665
- const raw = readFileSync34(join43(dir, entry), "utf8");
14922
+ const raw = readFileSync35(join44(dir, entry), "utf8");
14666
14923
  const parsed = JSON.parse(raw);
14667
14924
  if (typeof parsed.codeName !== "string" || parsed.codeName.length === 0) {
14668
14925
  parsed.codeName = entry.replace(/\.flag$/, "");
@@ -14780,8 +15037,8 @@ async function sendError(flag, opts, text) {
14780
15037
  }
14781
15038
 
14782
15039
  // src/lib/restart-context.ts
14783
- import { readdirSync as readdirSync13, readFileSync as readFileSync35, writeFileSync as writeFileSync18, mkdirSync as mkdirSync16, unlinkSync as unlinkSync5 } from "fs";
14784
- import { dirname as dirname10, join as join44 } from "path";
15040
+ import { readdirSync as readdirSync13, readFileSync as readFileSync36, writeFileSync as writeFileSync18, mkdirSync as mkdirSync17, unlinkSync as unlinkSync5 } from "fs";
15041
+ import { dirname as dirname10, join as join45 } from "path";
14785
15042
  var SLACK_PENDING_INBOUND_DIRNAME = "slack-pending-inbound";
14786
15043
  var SLACK_RESTART_CONTEXT_DIRNAME = "slack-restart-context";
14787
15044
  var MAX_TOPIC_CHARS = 140;
@@ -14793,10 +15050,10 @@ function augmentedAgentDir(codeName) {
14793
15050
  return dirname10(getProjectDir(codeName));
14794
15051
  }
14795
15052
  function slackPendingInboundDir(codeName) {
14796
- return join44(augmentedAgentDir(codeName), SLACK_PENDING_INBOUND_DIRNAME);
15053
+ return join45(augmentedAgentDir(codeName), SLACK_PENDING_INBOUND_DIRNAME);
14797
15054
  }
14798
15055
  function slackRestartContextDir(codeName) {
14799
- return join44(augmentedAgentDir(codeName), SLACK_RESTART_CONTEXT_DIRNAME);
15056
+ return join45(augmentedAgentDir(codeName), SLACK_RESTART_CONTEXT_DIRNAME);
14800
15057
  }
14801
15058
  function sanitizeTopic(raw) {
14802
15059
  const cleaned = raw.replace(/\s+/g, " ").trim().replace(/[<>]/g, " ").replace(/\s+/g, " ").trim();
@@ -14838,7 +15095,7 @@ function safeReaddir(dir) {
14838
15095
  }
14839
15096
  function readStrandedMarker(path) {
14840
15097
  try {
14841
- const parsed = JSON.parse(readFileSync35(path, "utf-8"));
15098
+ const parsed = JSON.parse(readFileSync36(path, "utf-8"));
14842
15099
  if (typeof parsed.channel === "string" && typeof parsed.thread_ts === "string") {
14843
15100
  return { channel: parsed.channel, thread_ts: parsed.thread_ts };
14844
15101
  }
@@ -14847,7 +15104,7 @@ function readStrandedMarker(path) {
14847
15104
  return null;
14848
15105
  }
14849
15106
  function writeHintFile(path, dir, hint) {
14850
- mkdirSync16(dir, { recursive: true, mode: 448 });
15107
+ mkdirSync17(dir, { recursive: true, mode: 448 });
14851
15108
  writeFileSync18(path, JSON.stringify(hint), { mode: 384 });
14852
15109
  }
14853
15110
  function pruneHintsExcept(codeName, freshFilenames) {
@@ -14856,7 +15113,7 @@ function pruneHintsExcept(codeName, freshFilenames) {
14856
15113
  if (!filename.endsWith(".json")) continue;
14857
15114
  if (freshFilenames.has(filename)) continue;
14858
15115
  try {
14859
- unlinkSync5(join44(ctxDir, filename));
15116
+ unlinkSync5(join45(ctxDir, filename));
14860
15117
  } catch {
14861
15118
  }
14862
15119
  }
@@ -14877,7 +15134,7 @@ function refreshSlackRestartContextHints(codeNames, opts = {}) {
14877
15134
  }
14878
15135
  const markers = [];
14879
15136
  for (const filename of markerFilenames.slice(0, cap)) {
14880
- const parsed = readStrandedMarker(join44(markerDir, filename));
15137
+ const parsed = readStrandedMarker(join45(markerDir, filename));
14881
15138
  if (parsed) markers.push({ filename, channel: parsed.channel, thread_ts: parsed.thread_ts });
14882
15139
  }
14883
15140
  if (markers.length === 0) {
@@ -14891,7 +15148,7 @@ function refreshSlackRestartContextHints(codeNames, opts = {}) {
14891
15148
  const freshFilenames = /* @__PURE__ */ new Set();
14892
15149
  for (const { filename, hint } of hints) {
14893
15150
  try {
14894
- writeHintFile(join44(ctxDir, filename), ctxDir, hint);
15151
+ writeHintFile(join45(ctxDir, filename), ctxDir, hint);
14895
15152
  freshFilenames.add(filename);
14896
15153
  } catch (err) {
14897
15154
  log2(`[restart-context] ${codeName}: hint write failed for ${filename}: ${err.message}`);
@@ -15697,7 +15954,7 @@ async function runDangerousRmBackstop(agentId, codeName, pane) {
15697
15954
  return;
15698
15955
  }
15699
15956
  const policy = readRmPolicyText(
15700
- () => readFileSync36(join45(getFramework("claude-code").getAgentDir(codeName), RM_POLICY_RELATIVE_PATH), "utf-8")
15957
+ () => readFileSync37(join46(getFramework("claude-code").getAgentDir(codeName), RM_POLICY_RELATIVE_PATH), "utf-8")
15701
15958
  );
15702
15959
  const decision = decideDangerousRm(action.prompt, policy, {
15703
15960
  isolated: isolationMode(codeName) === "docker"
@@ -16418,7 +16675,7 @@ var pendingDayRolloverReset = /* @__PURE__ */ new Set();
16418
16675
  var dayRolloverInboundHold = /* @__PURE__ */ new Map();
16419
16676
  var INBOUND_HOLD_EPISODE_GAP_MS = 12e4;
16420
16677
  async function channelInboundActivityAgeSecondsFor(codeName) {
16421
- const { newestPendingInboundActivityMtimeMs } = await import("../responsiveness-probe-ZOCD6UYO.js");
16678
+ const { newestPendingInboundActivityMtimeMs } = await import("../responsiveness-probe-26TFNDWB.js");
16422
16679
  const newest = newestPendingInboundActivityMtimeMs(dirname11(paneLogPath(codeName)));
16423
16680
  if (newest === null) return null;
16424
16681
  return Math.max(0, Math.floor((Date.now() - newest) / 1e3));
@@ -16785,18 +17042,66 @@ var anchorSessionLifecycle = new AnchorSessionLifecycle();
16785
17042
  var runningMcpServerKeys = /* @__PURE__ */ new Map();
16786
17043
  var runningChannelSecretHashes = /* @__PURE__ */ new Map();
16787
17044
  var sessionLaunchManagedStructure = /* @__PURE__ */ new Map();
16788
- function projectMcpHash(_codeName, projectDir) {
17045
+ function readSpawnViewMcpConfig(codeName, projectDir) {
17046
+ const parsed = JSON.parse(readFileSync37(join46(projectDir, ".mcp.json"), "utf-8"));
17047
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return parsed;
17048
+ const agentId = agentState.codeNameToAgentId.get(codeName);
17049
+ const integrations = agentId ? lastIntegrationsPayload.get(agentId) : void 0;
17050
+ return spawnViewOfMcpConfig(parsed, integrations);
17051
+ }
17052
+ var sessionsSpawnedByThisProcess = /* @__PURE__ */ new Set();
17053
+ var spawnCopyFailures = new SpawnCopyFailureTracker();
17054
+ function reportSpawnCopyFailure(codeName, f) {
17055
+ const agentId = agentState.codeNameToAgentId.get(codeName);
17056
+ if (!agentId) return;
17057
+ void reportReaperEvent(
17058
+ agentId,
17059
+ "spawn-mcp-filter",
17060
+ "alert",
17061
+ `Agent '${codeName}' is running with removed integration server(s) ${f.dropped.map((k) => `'${k}'`).join(", ")} still declared: the filtered spawn config could not be written (${f.error}). Their tools are reachable until the copy is written or the integration's entry is pruned from .mcp.json. Drift restarts are held so this does not loop (ENG-12048).`
17062
+ );
17063
+ }
17064
+ function refreshHeldDropped(codeName, projectDir, held) {
17065
+ const agentId = agentState.codeNameToAgentId.get(codeName);
17066
+ const integrations = agentId ? lastIntegrationsPayload.get(agentId) : void 0;
17067
+ const now = [...spawnDroppedServerKeys(join46(projectDir, ".mcp.json"), integrations)];
17068
+ if (spawnCopyFailures.noteDropped(codeName, now)) {
17069
+ log(
17070
+ `[spawn-mcp-filter] ORPHAN_SPAWN_UNFILTERED_CHANGED agent='${codeName}' servers=${now.map((k) => `'${k}'`).join(", ")}: the set of removed servers still loaded changed while the copy failure is held (ENG-12048)`
17071
+ );
17072
+ }
17073
+ return spawnCopyFailures.held(codeName) ?? held;
17074
+ }
17075
+ function retryHeldSpawnCopy2(codeName, projectDir, held) {
17076
+ const agentId = agentState.codeNameToAgentId.get(codeName);
17077
+ const integrations = agentId ? lastIntegrationsPayload.get(agentId) : void 0;
17078
+ if (integrations === void 0) return held;
17079
+ return retryHeldSpawnCopy({ tracker: spawnCopyFailures, codeName, projectDir, held, integrations, resolveApiHost: requireHost, log });
17080
+ }
17081
+ function readSpawnedMcpConfig(path) {
16789
17082
  try {
16790
- const raw = readFileSync36(join45(projectDir, ".mcp.json"), "utf-8");
16791
- return createHash20("sha256").update(canonicalJson(JSON.parse(raw))).digest("hex");
17083
+ const parsed = JSON.parse(readFileSync37(path, "utf-8"));
17084
+ return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
16792
17085
  } catch {
16793
17086
  return null;
16794
17087
  }
16795
17088
  }
16796
- function projectMcpKeys(_codeName, projectDir) {
17089
+ function readRawMcpConfig(projectDir) {
17090
+ return JSON.parse(readFileSync37(join46(projectDir, ".mcp.json"), "utf-8"));
17091
+ }
17092
+ function readMcpConfigFor(codeName, projectDir, source) {
17093
+ return source === "raw" ? readRawMcpConfig(projectDir) : readSpawnViewMcpConfig(codeName, projectDir);
17094
+ }
17095
+ function projectMcpHash(codeName, projectDir, source = "spawn-view") {
16797
17096
  try {
16798
- const raw = readFileSync36(join45(projectDir, ".mcp.json"), "utf-8");
16799
- const parsed = JSON.parse(raw);
17097
+ return hashMcpConfig(readMcpConfigFor(codeName, projectDir, source));
17098
+ } catch {
17099
+ return null;
17100
+ }
17101
+ }
17102
+ function projectMcpKeys(codeName, projectDir, source = "spawn-view") {
17103
+ try {
17104
+ const parsed = readMcpConfigFor(codeName, projectDir, source);
16800
17105
  const servers = parsed.mcpServers;
16801
17106
  if (!servers || typeof servers !== "object") return /* @__PURE__ */ new Set();
16802
17107
  return new Set(Object.keys(servers));
@@ -16804,16 +17109,18 @@ function projectMcpKeys(_codeName, projectDir) {
16804
17109
  return null;
16805
17110
  }
16806
17111
  }
16807
- function seedSessionLaunchBaselines(codeName, projectDir) {
16808
- const hash = projectMcpHash(codeName, projectDir);
16809
- const keys = projectMcpKeys(codeName, projectDir);
17112
+ function seedSessionLaunchBaselines(codeName, projectDir, spawnMcpConfigPath) {
17113
+ sessionsSpawnedByThisProcess.add(codeName);
17114
+ const given = spawnMcpConfigPath ? readSpawnedMcpConfig(spawnMcpConfigPath) : void 0;
17115
+ const hash = given === void 0 ? projectMcpHash(codeName, projectDir) : given === null ? null : hashMcpConfig(given);
17116
+ const keys = given === void 0 ? projectMcpKeys(codeName, projectDir) : given === null ? null : new Set(Object.keys(given.mcpServers ?? {}));
16810
17117
  if (hash) runningMcpHashes.set(codeName, hash);
16811
17118
  else runningMcpHashes.delete(codeName);
16812
17119
  if (keys) runningMcpServerKeys.set(codeName, keys);
16813
17120
  else runningMcpServerKeys.delete(codeName);
16814
17121
  let launchStructure = null;
16815
17122
  try {
16816
- const raw = readFileSync36(join45(projectDir, ".mcp.json"), "utf-8");
17123
+ const raw = readFileSync37(join46(projectDir, ".mcp.json"), "utf-8");
16817
17124
  launchStructure = managedMcpStructureHashFromFile(
16818
17125
  JSON.parse(raw),
16819
17126
  isManagedMcpServerKey
@@ -16965,7 +17272,7 @@ async function runAgentSessionToolBindProbes(agent, integrations, projectDir, op
16965
17272
  if (result && result.rebindCandidates.length > 0 && hostFlagStore().getBoolean("session-tool-rebind")) {
16966
17273
  let mcpJsonForRebind = null;
16967
17274
  try {
16968
- mcpJsonForRebind = JSON.parse(readFileSync36(join45(projectDir, ".mcp.json"), "utf-8"));
17275
+ mcpJsonForRebind = JSON.parse(readFileSync37(join46(projectDir, ".mcp.json"), "utf-8"));
16969
17276
  } catch {
16970
17277
  mcpJsonForRebind = null;
16971
17278
  }
@@ -17047,8 +17354,11 @@ function checkMcpConfigDriftAndScheduleRestart(codeName, projectDir) {
17047
17354
  case "no-drift":
17048
17355
  return;
17049
17356
  case "baseline": {
17050
- runningMcpHashes.set(codeName, action.hash);
17051
- const baselineKeys = projectMcpKeys(codeName, projectDir);
17357
+ const baselineSource = sessionsSpawnedByThisProcess.has(codeName) ? "spawn-view" : "raw";
17358
+ const rawHash = projectMcpHash(codeName, projectDir, baselineSource);
17359
+ if (rawHash === null) return;
17360
+ runningMcpHashes.set(codeName, rawHash);
17361
+ const baselineKeys = projectMcpKeys(codeName, projectDir, baselineSource);
17052
17362
  if (baselineKeys) {
17053
17363
  runningMcpServerKeys.set(codeName, baselineKeys);
17054
17364
  } else {
@@ -17057,6 +17367,18 @@ function checkMcpConfigDriftAndScheduleRestart(codeName, projectDir) {
17057
17367
  return;
17058
17368
  }
17059
17369
  case "drift": {
17370
+ let heldFailure = spawnCopyFailures.holdsDriftRestart(codeName, projectMcpHash(codeName, projectDir, "raw"));
17371
+ if (heldFailure && spawnCopyFailures.retryDue(codeName)) {
17372
+ heldFailure = retryHeldSpawnCopy2(codeName, projectDir, heldFailure);
17373
+ }
17374
+ if (heldFailure) heldFailure = refreshHeldDropped(codeName, projectDir, heldFailure);
17375
+ if (heldFailure) {
17376
+ log(
17377
+ `[spawn-mcp-filter] ORPHAN_SPAWN_UNFILTERED agent='${codeName}' servers=${heldFailure.dropped.map((k) => `'${k}'`).join(", ")} reason=${heldFailure.error}; drift restart held (the respawn would fail the same way) (ENG-12048)`
17378
+ );
17379
+ reportSpawnCopyFailure(codeName, heldFailure);
17380
+ return;
17381
+ }
17060
17382
  log(
17061
17383
  `[hot-reload] .mcp.json content changed for '${codeName}' (${action.previous.slice(0, 12)} \u2192 ${action.current.slice(0, 12)}) (ENG-4897)`
17062
17384
  );
@@ -17114,7 +17436,7 @@ function shouldInjectChannelSecrets(agentId) {
17114
17436
  function projectChannelSecretHash(projectDir) {
17115
17437
  try {
17116
17438
  const entries = parseEnvIntegrations(
17117
- readFileSync36(join45(projectDir, ".env.integrations"), "utf-8")
17439
+ readFileSync37(join46(projectDir, ".env.integrations"), "utf-8")
17118
17440
  );
17119
17441
  return channelSecretValueHash(entries, CHANNEL_SECRET_ENV_KEYS);
17120
17442
  } catch {
@@ -17234,7 +17556,7 @@ var agentRestartTimezoneInputs = /* @__PURE__ */ new Map();
17234
17556
  var lastVersionCheckAt = 0;
17235
17557
  var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
17236
17558
  var lastResponsivenessProbeAt = 0;
17237
- var agtCliVersion = true ? "0.28.1266" : "dev";
17559
+ var agtCliVersion = true ? "0.28.1267" : "dev";
17238
17560
  function resolveBrewPath(execFileSync4) {
17239
17561
  try {
17240
17562
  const out = execFileSync4("which", ["brew"], { timeout: 5e3 }).toString().trim();
@@ -17794,7 +18116,7 @@ function runAsync(cmd, args, opts) {
17794
18116
  });
17795
18117
  }
17796
18118
  function claudeManagedSettingsPath() {
17797
- return join45(CLAUDE_MANAGED_SETTINGS_DIR, "managed-settings.json");
18119
+ return join46(CLAUDE_MANAGED_SETTINGS_DIR, "managed-settings.json");
17798
18120
  }
17799
18121
  var MANAGED_SETTINGS_KEYS = ["channelsEnabled", "enableAllProjectMcpServers"];
17800
18122
  var MANAGED_SETTINGS_ENV = { DISABLE_AUTOUPDATER: "1" };
@@ -17817,7 +18139,7 @@ function deniedTools(settings) {
17817
18139
  }
17818
18140
  function readCrossSessionBlockStatus(path = claudeManagedSettingsPath()) {
17819
18141
  try {
17820
- const parsed = JSON.parse(readFileSync36(path, "utf-8"));
18142
+ const parsed = JSON.parse(readFileSync37(path, "utf-8"));
17821
18143
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return "missing";
17822
18144
  const settings = parsed;
17823
18145
  const deny = deniedTools(settings);
@@ -17857,7 +18179,7 @@ function ensureClaudeManagedSettings(path = claudeManagedSettingsPath(), write =
17857
18179
  try {
17858
18180
  let settings = {};
17859
18181
  if (existsSync20(path)) {
17860
- const raw = readFileSync36(path, "utf-8").trim();
18182
+ const raw = readFileSync37(path, "utf-8").trim();
17861
18183
  if (raw) {
17862
18184
  let parsed;
17863
18185
  try {
@@ -17898,7 +18220,7 @@ function ensureClaudeManagedSettings(path = claudeManagedSettingsPath(), write =
17898
18220
  const body = `${JSON.stringify(settings, null, 2)}
17899
18221
  `;
17900
18222
  try {
17901
- mkdirSync17(dirname11(path), { recursive: true });
18223
+ mkdirSync18(dirname11(path), { recursive: true });
17902
18224
  write(path, body);
17903
18225
  } catch (err) {
17904
18226
  if (channelKeysNeeded) throw err;
@@ -17950,7 +18272,7 @@ async function ensureOpencodeBinary() {
17950
18272
  try {
17951
18273
  const prefix = execFileSync4("npm", ["prefix", "-g"], { encoding: "utf-8", timeout: 1e4 }).trim();
17952
18274
  if (prefix) {
17953
- const npmBin = join45(prefix, "bin");
18275
+ const npmBin = join46(prefix, "bin");
17954
18276
  const current = (process.env.PATH ?? "").split(pathDelimiter);
17955
18277
  if (!current.includes(npmBin)) {
17956
18278
  process.env.PATH = [npmBin, ...current.filter(Boolean)].join(pathDelimiter);
@@ -18021,7 +18343,7 @@ async function ensureFrameworkBinary(frameworkId) {
18021
18343
  agentRuntimeAuthenticated = await checkClaudeAuth();
18022
18344
  }
18023
18345
  var claudeCodeUpgradeInFlight = false;
18024
- var SCRATCH_HOLDS_DIR = () => join45(homedir17(), ".augmented", ".manager-scratch-holds");
18346
+ var SCRATCH_HOLDS_DIR = () => join46(homedir17(), ".augmented", ".manager-scratch-holds");
18025
18347
  setScratchSweepPolicyResolver(
18026
18348
  (codeName) => resolveScratchSweepPolicy({
18027
18349
  agentId: agentState.codeNameToAgentId.get(codeName),
@@ -18100,7 +18422,7 @@ async function maybeUpgradeClaudeCode() {
18100
18422
  }
18101
18423
  var UPDATE_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
18102
18424
  function selfUpdateAppliedMarkerPath() {
18103
- return join45(homedir17(), ".augmented", ".last-self-update-applied");
18425
+ return join46(homedir17(), ".augmented", ".last-self-update-applied");
18104
18426
  }
18105
18427
  var selfUpdateUpToDateLogged = false;
18106
18428
  var selfUpdatePinnedLogged = false;
@@ -18151,7 +18473,7 @@ async function checkAndUpdateCli(opts) {
18151
18473
  const isNpmGlobal = !isBrewFormula && resolvedPath.includes("node_modules");
18152
18474
  if (!isBrewFormula && !isNpmGlobal) return "noop";
18153
18475
  const { readFileSync: readF, writeFileSync: writeF } = await import("fs");
18154
- const markerPath = join45(homedir17(), ".augmented", ".last-update-check");
18476
+ const markerPath = join46(homedir17(), ".augmented", ".last-update-check");
18155
18477
  if (!force) {
18156
18478
  try {
18157
18479
  const lastCheck = parseInt(readF(markerPath, "utf-8").trim(), 10);
@@ -18655,12 +18977,12 @@ async function checkClaudeAuth() {
18655
18977
  var evalEmptyMcpConfigPath = null;
18656
18978
  function ensureEvalEmptyMcpConfig() {
18657
18979
  if (evalEmptyMcpConfigPath && existsSync20(evalEmptyMcpConfigPath)) return evalEmptyMcpConfigPath;
18658
- const dir = join45(homedir17(), ".augmented");
18980
+ const dir = join46(homedir17(), ".augmented");
18659
18981
  try {
18660
- mkdirSync17(dir, { recursive: true });
18982
+ mkdirSync18(dir, { recursive: true });
18661
18983
  } catch {
18662
18984
  }
18663
- const p = join45(dir, ".eval-empty-mcp.json");
18985
+ const p = join46(dir, ".eval-empty-mcp.json");
18664
18986
  writeFileSync19(p, JSON.stringify({ mcpServers: {} }));
18665
18987
  evalEmptyMcpConfigPath = p;
18666
18988
  return p;
@@ -18751,10 +19073,10 @@ function resolveConversationEvalBackend() {
18751
19073
  return conversationEvalBackend;
18752
19074
  }
18753
19075
  function getStateFile() {
18754
- return join45(config?.configDir ?? join45(process.env["HOME"] ?? "/tmp", ".augmented"), "manager-state.json");
19076
+ return join46(config?.configDir ?? join46(process.env["HOME"] ?? "/tmp", ".augmented"), "manager-state.json");
18755
19077
  }
18756
19078
  function channelHashCacheDir() {
18757
- return config?.configDir ?? join45(process.env["HOME"] ?? "/tmp", ".augmented");
19079
+ return config?.configDir ?? join46(process.env["HOME"] ?? "/tmp", ".augmented");
18758
19080
  }
18759
19081
  function loadChannelHashCache2() {
18760
19082
  loadChannelHashCache(agentState.knownChannelConfigHashes, channelHashCacheDir());
@@ -18967,7 +19289,7 @@ function removeDeliveryBaselineEntries(agentId) {
18967
19289
  var _channelQuarantineStore = null;
18968
19290
  function channelQuarantineStore() {
18969
19291
  if (!_channelQuarantineStore) {
18970
- const dir = config?.configDir ?? join45(process.env["HOME"] ?? "/tmp", ".augmented");
19292
+ const dir = config?.configDir ?? join46(process.env["HOME"] ?? "/tmp", ".augmented");
18971
19293
  _channelQuarantineStore = new ChannelQuarantineStore(defaultQuarantinePath(dir));
18972
19294
  }
18973
19295
  return _channelQuarantineStore;
@@ -18975,7 +19297,7 @@ function channelQuarantineStore() {
18975
19297
  var _channelResumeHistoryStore = null;
18976
19298
  function channelResumeHistoryStore() {
18977
19299
  if (!_channelResumeHistoryStore) {
18978
- const dir = config?.configDir ?? join45(process.env["HOME"] ?? "/tmp", ".augmented");
19300
+ const dir = config?.configDir ?? join46(process.env["HOME"] ?? "/tmp", ".augmented");
18979
19301
  _channelResumeHistoryStore = new ChannelResumeHistoryStore(defaultResumeHistoryPath(dir));
18980
19302
  }
18981
19303
  return _channelResumeHistoryStore;
@@ -19020,12 +19342,12 @@ function sessionActivityFor(codeName, pane, opts = {}) {
19020
19342
  }
19021
19343
  function forwardedToolsFor(codeName) {
19022
19344
  if (!config?.configDir) return null;
19023
- return readForwardedToolsReport(join45(config.configDir, codeName));
19345
+ return readForwardedToolsReport(join46(config.configDir, codeName));
19024
19346
  }
19025
19347
  var _hostFlagStore = null;
19026
19348
  function hostFlagStore() {
19027
19349
  if (!_hostFlagStore) {
19028
- const dir = config?.configDir ?? join45(process.env["HOME"] ?? "/tmp", ".augmented");
19350
+ const dir = config?.configDir ?? join46(process.env["HOME"] ?? "/tmp", ".augmented");
19029
19351
  _hostFlagStore = new HostFlagStore({ cachePath: defaultFlagsCachePath(dir), log });
19030
19352
  }
19031
19353
  return _hostFlagStore;
@@ -19099,12 +19421,12 @@ function parseSkillFrontmatter(content) {
19099
19421
  }
19100
19422
  async function refreshSkillsIndexInClaudeMd(configDir, codeName, log2) {
19101
19423
  const { readdirSync: readdirSync15, readFileSync: rfs, existsSync: ex, writeFileSync: writeFileSync20 } = await import("fs");
19102
- const skillsDir = join45(configDir, codeName, "project", ".claude", "skills");
19103
- const claudeMdPath = join45(configDir, codeName, "project", "CLAUDE.md");
19424
+ const skillsDir = join46(configDir, codeName, "project", ".claude", "skills");
19425
+ const claudeMdPath = join46(configDir, codeName, "project", "CLAUDE.md");
19104
19426
  if (!ex(skillsDir) || !ex(claudeMdPath)) return;
19105
19427
  const entries = [];
19106
19428
  for (const dir of readdirSync15(skillsDir).sort()) {
19107
- const skillFile = join45(skillsDir, dir, "SKILL.md");
19429
+ const skillFile = join46(skillsDir, dir, "SKILL.md");
19108
19430
  if (!ex(skillFile)) continue;
19109
19431
  try {
19110
19432
  const { name, description } = parseSkillFrontmatter(rfs(skillFile, "utf-8"));
@@ -19243,7 +19565,7 @@ function flushRestartedAgentDiagnostics(hostId, codeNames) {
19243
19565
  if (codeNames.length === 0) return;
19244
19566
  void (async () => {
19245
19567
  try {
19246
- const { collectDiagnostics } = await import("../persistent-session-YBCMFF7T.js");
19568
+ const { collectDiagnostics } = await import("../persistent-session-FMY2FZEL.js");
19247
19569
  await api.post("/host/heartbeat", {
19248
19570
  host_id: hostId,
19249
19571
  agent_diagnostics: collectDiagnostics(codeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
@@ -19386,7 +19708,7 @@ async function pollCycleInner() {
19386
19708
  }
19387
19709
  try {
19388
19710
  const { detectHostSecurity } = await import("../host-security-KQYYZZVW.js");
19389
- const { collectDiagnostics } = await import("../persistent-session-YBCMFF7T.js");
19711
+ const { collectDiagnostics } = await import("../persistent-session-FMY2FZEL.js");
19390
19712
  const diagCodeNames = [...agentState.persistentSessionAgents];
19391
19713
  const agentDiagnostics = diagCodeNames.length > 0 ? collectDiagnostics(diagCodeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor) : void 0;
19392
19714
  let tailscaleHostname;
@@ -19416,7 +19738,7 @@ async function pollCycleInner() {
19416
19738
  claudeAuth = await detectClaudeAuth();
19417
19739
  } catch (err) {
19418
19740
  const errText = err instanceof Error ? err.message : String(err);
19419
- const errId = createHash20("sha256").update(errText).digest("hex").slice(0, 12);
19741
+ const errId = createHash21("sha256").update(errText).digest("hex").slice(0, 12);
19420
19742
  log(`Claude auth detection failed (error_id=${errId})`);
19421
19743
  }
19422
19744
  let claudeAccountEmail = null;
@@ -19692,7 +20014,7 @@ async function pollCycleInner() {
19692
20014
  collectPanelessActivityProbes,
19693
20015
  getResponsivenessIntervalMs,
19694
20016
  occupancyQualificationClassifications
19695
- } = await import("../responsiveness-probe-ZOCD6UYO.js");
20017
+ } = await import("../responsiveness-probe-26TFNDWB.js");
19696
20018
  const probeIntervalMs = getResponsivenessIntervalMs();
19697
20019
  if (now - lastResponsivenessProbeAt > probeIntervalMs) {
19698
20020
  const probeCodeNames = [...agentState.persistentSessionAgents];
@@ -19809,7 +20131,7 @@ async function pollCycleInner() {
19809
20131
  collectResponsivenessProbes,
19810
20132
  livePendingInboundOldestAgeSeconds,
19811
20133
  parkPendingInbound
19812
- } = await import("../responsiveness-probe-ZOCD6UYO.js");
20134
+ } = await import("../responsiveness-probe-26TFNDWB.js");
19813
20135
  const { getProjectDir: wedgeProjectDir } = await import("../scheduler-engine-5PCBGRNY.js");
19814
20136
  const wedgeNow = /* @__PURE__ */ new Date();
19815
20137
  const liveAgents = agentState.persistentSessionAgents;
@@ -19898,13 +20220,13 @@ async function pollCycleInner() {
19898
20220
  );
19899
20221
  if (hostFlagStore().getBoolean("wedge-transient-notice")) {
19900
20222
  try {
19901
- const paneTail = readFileSync36(paneLogPath(codeName), "utf8").slice(-65536);
20223
+ const paneTail = readFileSync37(paneLogPath(codeName), "utf8").slice(-65536);
19902
20224
  const transient = detectTransientApiErrorInLog(paneTail);
19903
20225
  if (transient) {
19904
- const wedgeHome = join45(homedir17(), ".augmented", codeName);
20226
+ const wedgeHome = join46(homedir17(), ".augmented", codeName);
19905
20227
  if (existsSync20(wedgeHome)) {
19906
20228
  atomicWriteFileSync(
19907
- join45(wedgeHome, "watchdog-give-up.json"),
20229
+ join46(wedgeHome, "watchdog-give-up.json"),
19908
20230
  JSON.stringify({
19909
20231
  gave_up_at: wedgeNow.toISOString(),
19910
20232
  reason: "transient_overload"
@@ -20095,7 +20417,7 @@ async function pollCycleInner() {
20095
20417
  }
20096
20418
  }
20097
20419
  );
20098
- const { parkPendingInbound } = await import("../responsiveness-probe-ZOCD6UYO.js");
20420
+ const { parkPendingInbound } = await import("../responsiveness-probe-26TFNDWB.js");
20099
20421
  const { parked, deadLettered } = parkPendingInbound(codeName, new Date(fatalNowMs));
20100
20422
  paneFatalStreak.delete(codeName);
20101
20423
  paneFatalRestarts.set(codeName, [...history, fatalNowMs]);
@@ -20126,7 +20448,7 @@ async function pollCycleInner() {
20126
20448
  TRANSCRIPT_MOUNT_ESCALATION_REFRESH_MS,
20127
20449
  bindSourceEscalations
20128
20450
  } = await import("../transcript-mount-health-OHE6IVJV.js");
20129
- const { transcriptBindSourcesFor, ensureTranscriptBindSources } = await import("../persistent-session-YBCMFF7T.js");
20451
+ const { transcriptBindSourcesFor, ensureTranscriptBindSources } = await import("../persistent-session-FMY2FZEL.js");
20130
20452
  const mountConfig = resolveTranscriptMountConfig();
20131
20453
  const liveAgents = agentState.persistentSessionAgents;
20132
20454
  for (const tracked of [
@@ -20845,7 +21167,7 @@ async function pollCycleInner() {
20845
21167
  `[drain-flush] FAILED for '${prev.codeName}': ${err.message} \u2014 proceeding to teardown; this session was NOT shipped (ENG-9491)`
20846
21168
  );
20847
21169
  }
20848
- const agentDir = join45(adapter.getAgentDir(prev.codeName), "provision");
21170
+ const agentDir = join46(adapter.getAgentDir(prev.codeName), "provision");
20849
21171
  await cleanupAgentFiles(prev.codeName, agentDir);
20850
21172
  clearAgentCaches(prev.agentId, prev.codeName);
20851
21173
  }
@@ -20924,10 +21246,10 @@ async function pollCycleInner() {
20924
21246
  // pending-inbound marker. Best-effort: a write failure is logged by
20925
21247
  // the watchdog, never fails the poll cycle.
20926
21248
  signalGiveUp: (codeName) => {
20927
- const dir = join45(homedir17(), ".augmented", codeName);
21249
+ const dir = join46(homedir17(), ".augmented", codeName);
20928
21250
  if (!existsSync20(dir)) return;
20929
21251
  atomicWriteFileSync(
20930
- join45(dir, "watchdog-give-up.json"),
21252
+ join46(dir, "watchdog-give-up.json"),
20931
21253
  JSON.stringify({ gave_up_at: (/* @__PURE__ */ new Date()).toISOString() })
20932
21254
  );
20933
21255
  },
@@ -20955,20 +21277,20 @@ async function pollCycleInner() {
20955
21277
  const dir = getFramework("claude-code").getAgentDir(codeName);
20956
21278
  if (!existsSync20(dir)) return;
20957
21279
  atomicWriteFileSync(
20958
- join45(dir, "blocked-prompt.json"),
21280
+ join46(dir, "blocked-prompt.json"),
20959
21281
  JSON.stringify({ kind, last_seen_at: (/* @__PURE__ */ new Date()).toISOString() })
20960
21282
  );
20961
21283
  },
20962
21284
  clearBlockedPromptLiveness: (codeName) => {
20963
- const file = join45(getFramework("claude-code").getAgentDir(codeName), "blocked-prompt.json");
21285
+ const file = join46(getFramework("claude-code").getAgentDir(codeName), "blocked-prompt.json");
20964
21286
  if (existsSync20(file)) rmSync9(file, { force: true });
20965
21287
  },
20966
21288
  refreshUsageLimitLiveness: (codeName) => {
20967
21289
  const dir = getFramework("claude-code").getAgentDir(codeName);
20968
- const file = join45(dir, "watchdog-give-up.json");
21290
+ const file = join46(dir, "watchdog-give-up.json");
20969
21291
  if (!existsSync20(file)) return;
20970
21292
  try {
20971
- const raw = JSON.parse(readFileSync36(file, "utf8"));
21293
+ const raw = JSON.parse(readFileSync37(file, "utf8"));
20972
21294
  if (raw["reason"] !== "usage_limit") return;
20973
21295
  raw["usage_limit_last_seen_at"] = (/* @__PURE__ */ new Date()).toISOString();
20974
21296
  atomicWriteFileSync(file, JSON.stringify(raw));
@@ -20979,7 +21301,7 @@ async function pollCycleInner() {
20979
21301
  const dir = getFramework("claude-code").getAgentDir(codeName);
20980
21302
  if (!existsSync20(dir)) return;
20981
21303
  atomicWriteFileSync(
20982
- join45(dir, "watchdog-give-up.json"),
21304
+ join46(dir, "watchdog-give-up.json"),
20983
21305
  JSON.stringify({
20984
21306
  gave_up_at: (/* @__PURE__ */ new Date()).toISOString(),
20985
21307
  reason: "usage_limit",
@@ -21256,7 +21578,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
21256
21578
  }
21257
21579
  const now = (/* @__PURE__ */ new Date()).toISOString();
21258
21580
  const adapter = resolveAgentFramework(agent.code_name);
21259
- let agentDir = join45(adapter.getAgentDir(agent.code_name), "provision");
21581
+ let agentDir = join46(adapter.getAgentDir(agent.code_name), "provision");
21260
21582
  if (agent.status === "draft" || agent.status === "paused") {
21261
21583
  forgetChannelSyncState(agent.agent_id);
21262
21584
  reapLegacyTokenFileEdgeWarned(agent.code_name, log);
@@ -21404,7 +21726,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
21404
21726
  if (refreshData.knowledge_manifest) {
21405
21727
  const resolved = await resolveKnowledgeFromManifest({
21406
21728
  manifest: refreshData.knowledge_manifest,
21407
- cacheDir: join45(config.configDir, "_knowledge"),
21729
+ cacheDir: join46(config.configDir, "_knowledge"),
21408
21730
  delivery: refreshData.agent?.knowledge_delivery ?? "both",
21409
21731
  fetchContents: async (hashes) => {
21410
21732
  const res = await api.post(
@@ -21421,7 +21743,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
21421
21743
  const resolvedSkills = await resolveSkillsFromManifest({
21422
21744
  globals: refreshData.global_skills_manifest ?? [],
21423
21745
  shared: refreshData.shared_skills_manifest ?? [],
21424
- cacheDir: join45(config.configDir, "_skills"),
21746
+ cacheDir: join46(config.configDir, "_skills"),
21425
21747
  fetchContents: async (hashes) => {
21426
21748
  const res = await api.post(
21427
21749
  "/host/skills/contents",
@@ -21439,7 +21761,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
21439
21761
  if (refreshData.integration_skills_manifest) {
21440
21762
  const resolvedIntegrationSkills = await resolveIntegrationSkillsFromManifest({
21441
21763
  manifest: refreshData.integration_skills_manifest,
21442
- cacheDir: join45(config.configDir, "_skills"),
21764
+ cacheDir: join46(config.configDir, "_skills"),
21443
21765
  fetchContents: async (hashes) => {
21444
21766
  const res = await api.post(
21445
21767
  "/host/skills/contents",
@@ -21501,7 +21823,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
21501
21823
  const frameworkId = refreshData.agent.framework ?? DEFAULT_FRAMEWORK;
21502
21824
  agentFrameworkCache.set(agent.code_name, frameworkId);
21503
21825
  const frameworkAdapter = getFramework(frameworkId);
21504
- agentDir = join45(frameworkAdapter.getAgentDir(agent.code_name), "provision");
21826
+ agentDir = join46(frameworkAdapter.getAgentDir(agent.code_name), "provision");
21505
21827
  cacheAgentDeliveryMetadata(agent.code_name, refreshData);
21506
21828
  agentRestartTimezoneInputs.set(agent.code_name, {
21507
21829
  agentTimezone: typeof refreshData.agent.timezone === "string" ? refreshData.agent.timezone : null,
@@ -21577,9 +21899,9 @@ async function processAgent(agent, agentStates, managedToolkits) {
21577
21899
  }
21578
21900
  const artifacts = generateArtifacts(agent, provisionRefreshData, frameworkAdapter, renderIntegrationsSection);
21579
21901
  const changedFiles = [];
21580
- mkdirSync17(agentDir, { recursive: true });
21902
+ mkdirSync18(agentDir, { recursive: true });
21581
21903
  for (const artifact of artifacts) {
21582
- const filePath = join45(agentDir, artifact.relativePath);
21904
+ const filePath = join46(agentDir, artifact.relativePath);
21583
21905
  let existingHash;
21584
21906
  let newHash;
21585
21907
  let writeContent = artifact.content;
@@ -21598,8 +21920,8 @@ async function processAgent(agent, agentStates, managedToolkits) {
21598
21920
  };
21599
21921
  newHash = sha256(stripDynamicSections(artifact.content));
21600
21922
  try {
21601
- const projectClaudeMd = join45(config.configDir, agent.code_name, "project", "CLAUDE.md");
21602
- const existing = readFileSync36(projectClaudeMd, "utf-8");
21923
+ const projectClaudeMd = join46(config.configDir, agent.code_name, "project", "CLAUDE.md");
21924
+ const existing = readFileSync37(projectClaudeMd, "utf-8");
21603
21925
  existingHash = sha256(stripDynamicSections(existing));
21604
21926
  } catch {
21605
21927
  existingHash = null;
@@ -21617,7 +21939,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
21617
21939
  const generatorKeys = Object.keys(generatorServers);
21618
21940
  let existingRaw = "";
21619
21941
  try {
21620
- existingRaw = readFileSync36(filePath, "utf-8");
21942
+ existingRaw = readFileSync37(filePath, "utf-8");
21621
21943
  } catch {
21622
21944
  }
21623
21945
  const existingServers = parseMcp(existingRaw);
@@ -21633,7 +21955,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
21633
21955
  } else if (artifact.relativePath === "opencode.json") {
21634
21956
  let existingRaw = null;
21635
21957
  try {
21636
- existingRaw = readFileSync36(filePath, "utf-8");
21958
+ existingRaw = readFileSync37(filePath, "utf-8");
21637
21959
  } catch {
21638
21960
  }
21639
21961
  const mergeResult = mergeOpencodeConfigArtifact(artifact.content, existingRaw);
@@ -21649,13 +21971,13 @@ async function processAgent(agent, agentStates, managedToolkits) {
21649
21971
  }
21650
21972
  }
21651
21973
  if (changedFiles.length > 0) {
21652
- const isFirst = !existsSync20(join45(agentDir, "CHARTER.md"));
21974
+ const isFirst = !existsSync20(join46(agentDir, "CHARTER.md"));
21653
21975
  const verb = isFirst ? "Provisioning" : "Updating";
21654
21976
  const fileNames = changedFiles.map((f) => f.relativePath).join(", ");
21655
21977
  log(`${verb} '${agent.code_name}': ${fileNames}`);
21656
21978
  for (const file of changedFiles) {
21657
- const filePath = join45(agentDir, file.relativePath);
21658
- mkdirSync17(dirname11(filePath), { recursive: true });
21979
+ const filePath = join46(agentDir, file.relativePath);
21980
+ mkdirSync18(dirname11(filePath), { recursive: true });
21659
21981
  if (file.relativePath === ".mcp.json") {
21660
21982
  safeWriteJsonAtomic(filePath, file.content, { mode: 384 });
21661
21983
  } else {
@@ -21663,12 +21985,12 @@ async function processAgent(agent, agentStates, managedToolkits) {
21663
21985
  }
21664
21986
  }
21665
21987
  try {
21666
- const provSkillsDir = join45(agentDir, ".claude", "skills");
21988
+ const provSkillsDir = join46(agentDir, ".claude", "skills");
21667
21989
  if (existsSync20(provSkillsDir)) {
21668
21990
  for (const folder of readdirSync14(provSkillsDir)) {
21669
21991
  if (folder.startsWith("knowledge-")) {
21670
21992
  try {
21671
- rmSync9(join45(provSkillsDir, folder), { recursive: true });
21993
+ rmSync9(join46(provSkillsDir, folder), { recursive: true });
21672
21994
  } catch {
21673
21995
  }
21674
21996
  }
@@ -21681,7 +22003,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
21681
22003
  const trackedFiles2 = frameworkAdapter.driftTrackedFiles();
21682
22004
  const hashes = /* @__PURE__ */ new Map();
21683
22005
  for (const file of trackedFiles2) {
21684
- const h = hashFile(join45(agentDir, file));
22006
+ const h = hashFile(join46(agentDir, file));
21685
22007
  if (h) hashes.set(file, h);
21686
22008
  }
21687
22009
  agentState.writtenHashes.set(agent.agent_id, hashes);
@@ -21699,14 +22021,14 @@ async function processAgent(agent, agentStates, managedToolkits) {
21699
22021
  }
21700
22022
  if (Array.isArray(refreshData.workflows)) {
21701
22023
  try {
21702
- const provWorkflowsDir = join45(agentDir, ".claude", "workflows");
22024
+ const provWorkflowsDir = join46(agentDir, ".claude", "workflows");
21703
22025
  if (existsSync20(provWorkflowsDir)) {
21704
22026
  const expected = new Set(refreshData.workflows.map((w) => `${w.name}.js`));
21705
22027
  for (const file of readdirSync14(provWorkflowsDir)) {
21706
22028
  if (!file.endsWith(".js")) continue;
21707
22029
  if (expected.has(file)) continue;
21708
22030
  try {
21709
- rmSync9(join45(provWorkflowsDir, file));
22031
+ rmSync9(join46(provWorkflowsDir, file));
21710
22032
  } catch {
21711
22033
  }
21712
22034
  }
@@ -21801,7 +22123,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
21801
22123
  if (written && existsSync20(agentDir)) {
21802
22124
  const driftedFiles = [];
21803
22125
  for (const [file, expectedHash] of written) {
21804
- const localHash = hashFile(join45(agentDir, file));
22126
+ const localHash = hashFile(join46(agentDir, file));
21805
22127
  if (localHash && localHash !== expectedHash) {
21806
22128
  driftedFiles.push(file);
21807
22129
  }
@@ -21812,7 +22134,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
21812
22134
  try {
21813
22135
  const localHashes = {};
21814
22136
  for (const file of driftedFiles) {
21815
- localHashes[file] = hashFile(join45(agentDir, file));
22137
+ localHashes[file] = hashFile(join46(agentDir, file));
21816
22138
  }
21817
22139
  await api.post("/host/drift", {
21818
22140
  agent_id: agent.agent_id,
@@ -22097,15 +22419,15 @@ async function processAgent(agent, agentStates, managedToolkits) {
22097
22419
  const addedChannels = [...restartDecision.added];
22098
22420
  const writeDmNoticeMarkers = isChannelAddRestart ? () => {
22099
22421
  try {
22100
- const agentAugmentedDir = join45(homedir17(), ".augmented", agent.code_name);
22101
- mkdirSync17(agentAugmentedDir, { recursive: true });
22422
+ const agentAugmentedDir = join46(homedir17(), ".augmented", agent.code_name);
22423
+ mkdirSync18(agentAugmentedDir, { recursive: true });
22102
22424
  const markerJson = JSON.stringify({
22103
22425
  version: 1,
22104
22426
  at: (/* @__PURE__ */ new Date()).toISOString(),
22105
22427
  added: addedChannels
22106
22428
  });
22107
22429
  for (const file of ["slack-channel-add-restart.json", "telegram-channel-add-restart.json"]) {
22108
- atomicWriteFileSync(join45(agentAugmentedDir, file), markerJson);
22430
+ atomicWriteFileSync(join46(agentAugmentedDir, file), markerJson);
22109
22431
  }
22110
22432
  } catch (err) {
22111
22433
  log(`[hot-reload] channel-add DM-notice marker write failed for '${agent.code_name}' (non-fatal): ${err.message}`);
@@ -22185,7 +22507,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
22185
22507
  const behaviourSubset = extractMsTeamsBehaviourSubset(
22186
22508
  msteamsEntry?.config
22187
22509
  );
22188
- const behaviourHash = createHash20("sha256").update(canonicalJson(behaviourSubset)).digest("hex");
22510
+ const behaviourHash = createHash21("sha256").update(canonicalJson(behaviourSubset)).digest("hex");
22189
22511
  const prevBehaviourHash = agentState.knownMsTeamsBehaviourHashes.get(agent.agent_id);
22190
22512
  const msteamsBehaviourRestrictive = isMsTeamsBehaviourRestrictive(behaviourSubset);
22191
22513
  const behaviourDecision = decideSenderPolicyRestart({
@@ -22241,7 +22563,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
22241
22563
  const slackBehaviourSubset = extractSlackBehaviourSubset(
22242
22564
  slackEntry?.config
22243
22565
  );
22244
- const slackBehaviourHash = createHash20("sha256").update(canonicalJson(slackBehaviourSubset)).digest("hex");
22566
+ const slackBehaviourHash = createHash21("sha256").update(canonicalJson(slackBehaviourSubset)).digest("hex");
22245
22567
  const prevSlackBehaviourHash = agentState.knownSlackBehaviourHashes.get(agent.agent_id);
22246
22568
  const slackBehaviourRestrictive = isSlackBehaviourRestrictive(slackBehaviourSubset);
22247
22569
  const slackBehaviourDecision = decideSenderPolicyRestart({
@@ -22296,7 +22618,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
22296
22618
  }
22297
22619
  if (currentChannelIds.has("telegram")) {
22298
22620
  const telegramPolicyEnv = telegramPolicyEnvForRestart ?? {};
22299
- const telegramPolicyHash = createHash20("sha256").update(telegramPolicyEnvBasis(telegramPolicyEnv)).digest("hex");
22621
+ const telegramPolicyHash = createHash21("sha256").update(telegramPolicyEnvBasis(telegramPolicyEnv)).digest("hex");
22300
22622
  const prevTelegramPolicyHash = agentState.knownTelegramPolicyHashes.get(agent.agent_id);
22301
22623
  const telegramPolicyRestrictive = isTelegramPolicyRestrictive(telegramPolicyEnv);
22302
22624
  const telegramPolicyDecision = decideSenderPolicyRestart({
@@ -22355,7 +22677,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
22355
22677
  } else {
22356
22678
  const agentRules = refreshData.agent_rules ?? [];
22357
22679
  const inheritedRules = inheritedResolution.rules;
22358
- const agentRulesHash = createHash20("sha256").update(agentRulesRestartBasis(agentRules, inheritedRules)).digest("hex");
22680
+ const agentRulesHash = createHash21("sha256").update(agentRulesRestartBasis(agentRules, inheritedRules)).digest("hex");
22359
22681
  const prevAgentRulesHash = agentState.knownAgentRulesHashes.get(agent.agent_id);
22360
22682
  const rulesPresent = agentHasRules(agentRules, inheritedRules);
22361
22683
  const agentRulesDecision = decideSenderPolicyRestart({
@@ -22409,18 +22731,18 @@ async function processAgent(agent, agentStates, managedToolkits) {
22409
22731
  if (agentSessionMode === "persistent" && (agentFrameworkCache.get(agent.code_name) ?? DEFAULT_FRAMEWORK) === "claude-code") {
22410
22732
  try {
22411
22733
  const agentProvisionDir = agentDir;
22412
- const projectDir = join45(homedir17(), ".augmented", agent.code_name, "project");
22413
- mkdirSync17(agentProvisionDir, { recursive: true });
22414
- mkdirSync17(projectDir, { recursive: true });
22415
- const provisionMcpPath = join45(agentProvisionDir, ".mcp.json");
22416
- const projectMcpPath = join45(projectDir, ".mcp.json");
22734
+ const projectDir = join46(homedir17(), ".augmented", agent.code_name, "project");
22735
+ mkdirSync18(agentProvisionDir, { recursive: true });
22736
+ mkdirSync18(projectDir, { recursive: true });
22737
+ const provisionMcpPath = join46(agentProvisionDir, ".mcp.json");
22738
+ const projectMcpPath = join46(projectDir, ".mcp.json");
22417
22739
  let mcpConfig = { mcpServers: {} };
22418
22740
  try {
22419
- mcpConfig = JSON.parse(readFileSync36(provisionMcpPath, "utf-8"));
22741
+ mcpConfig = JSON.parse(readFileSync37(provisionMcpPath, "utf-8"));
22420
22742
  if (!mcpConfig.mcpServers) mcpConfig.mcpServers = {};
22421
22743
  } catch {
22422
22744
  }
22423
- const localDirectChatChannel = join45(homedir17(), ".augmented", "_mcp", "direct-chat-channel.js");
22745
+ const localDirectChatChannel = join46(homedir17(), ".augmented", "_mcp", "direct-chat-channel.js");
22424
22746
  const directChatTeamSettings = refreshData.team?.settings;
22425
22747
  const directChatTz = (() => {
22426
22748
  const tz = directChatTeamSettings?.["timezone"];
@@ -22446,7 +22768,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
22446
22768
  // ~/.augmented/<codeName>/.current-turn-initiator.json. Note getAgentDir
22447
22769
  // returns the agent root (NOT the /provision subdir `agentDir` points at),
22448
22770
  // so it byte-matches the broker readers' path.
22449
- AGT_TURN_INITIATOR_FILE: join45(
22771
+ AGT_TURN_INITIATOR_FILE: join46(
22450
22772
  frameworkAdapter.getAgentDir(agent.code_name),
22451
22773
  ".current-turn-initiator.json"
22452
22774
  )
@@ -22466,7 +22788,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
22466
22788
  log(`Channel credentials written for '${agent.code_name}/direct-chat'`);
22467
22789
  }
22468
22790
  }
22469
- const staleChannelsPath = join45(projectDir, ".mcp-channels.json");
22791
+ const staleChannelsPath = join46(projectDir, ".mcp-channels.json");
22470
22792
  if (existsSync20(staleChannelsPath)) {
22471
22793
  try {
22472
22794
  rmSync9(staleChannelsPath, { force: true });
@@ -22594,7 +22916,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
22594
22916
  }
22595
22917
  if (hostFlagStore().getBoolean("connectivity-probe")) {
22596
22918
  try {
22597
- const probeProjectDir = join45(homedir17(), ".augmented", agent.code_name, "project");
22919
+ const probeProjectDir = join46(homedir17(), ".augmented", agent.code_name, "project");
22598
22920
  let probeSet = integrations;
22599
22921
  const fetchQuarantined = async () => {
22600
22922
  const quarantined = await api.post("/host/agent-integrations/quarantined", { agent_id: agent.agent_id });
@@ -22654,7 +22976,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
22654
22976
  const forceDue = attemptsLeft > 0;
22655
22977
  let probeRan = false;
22656
22978
  try {
22657
- const probeProjectDir = join45(homedir17(), ".augmented", agent.code_name, "project");
22979
+ const probeProjectDir = join46(homedir17(), ".augmented", agent.code_name, "project");
22658
22980
  const renderPending = integrationRenderPending(
22659
22981
  integrations,
22660
22982
  agentState.knownIntegrationHashes.get(agent.agent_id)
@@ -22783,11 +23105,11 @@ async function processAgent(agent, agentStates, managedToolkits) {
22783
23105
  const intHash = computeIntegrationsHash(integrations);
22784
23106
  const prevIntHash = agentState.knownIntegrationHashes.get(agent.agent_id);
22785
23107
  if (intHash !== prevIntHash) {
22786
- const projectDir = join45(homedir17(), ".augmented", agent.code_name, "project");
22787
- const envIntPath = join45(projectDir, ".env.integrations");
23108
+ const projectDir = join46(homedir17(), ".augmented", agent.code_name, "project");
23109
+ const envIntPath = join46(projectDir, ".env.integrations");
22788
23110
  let preWriteEnv;
22789
23111
  try {
22790
- preWriteEnv = readFileSync36(envIntPath, "utf-8");
23112
+ preWriteEnv = readFileSync37(envIntPath, "utf-8");
22791
23113
  } catch {
22792
23114
  preWriteEnv = void 0;
22793
23115
  }
@@ -22815,9 +23137,9 @@ async function processAgent(agent, agentStates, managedToolkits) {
22815
23137
  }
22816
23138
  if (fw === "claude-code" && isSessionHealthy(agent.code_name)) {
22817
23139
  try {
22818
- const projectMcpPath = join45(projectDir, ".mcp.json");
22819
- const postWriteEnv = readFileSync36(envIntPath, "utf-8");
22820
- const mcpContent = readFileSync36(projectMcpPath, "utf-8");
23140
+ const projectMcpPath = join46(projectDir, ".mcp.json");
23141
+ const postWriteEnv = readFileSync37(envIntPath, "utf-8");
23142
+ const mcpContent = readFileSync37(projectMcpPath, "utf-8");
22821
23143
  const changedVars = diffEnvIntegrations(preWriteEnv, postWriteEnv);
22822
23144
  const mcpJsonForReap = JSON.parse(mcpContent);
22823
23145
  const affectedServerKeys = findMcpServersUsingVars(mcpJsonForReap, changedVars);
@@ -22944,10 +23266,10 @@ async function processAgent(agent, agentStates, managedToolkits) {
22944
23266
  desiredEntries.push({ serverId, url, headers: mcpHeaders, name: tk.toolkit_name });
22945
23267
  }
22946
23268
  const hashBasis = desiredEntries.slice().sort((a, b) => a.serverId.localeCompare(b.serverId)).map((e) => {
22947
- const headersHash = createHash20("sha256").update(canonicalJson(e.headers ?? {})).digest("hex").slice(0, 16);
23269
+ const headersHash = createHash21("sha256").update(canonicalJson(e.headers ?? {})).digest("hex").slice(0, 16);
22948
23270
  return `${e.serverId}|${e.url}|${headersHash}`;
22949
23271
  }).join("\n");
22950
- const mcpHash = createHash20("sha256").update(hashBasis).digest("hex").slice(0, 16);
23272
+ const mcpHash = createHash21("sha256").update(hashBasis).digest("hex").slice(0, 16);
22951
23273
  const prevMcpHash = agentState.knownManagedMcpHashes.get(agent.agent_id);
22952
23274
  const structureHash = managedMcpStructureHash(desiredEntries);
22953
23275
  const prevStructureHash = agentState.knownManagedMcpStructure.get(agent.agent_id);
@@ -22990,7 +23312,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
22990
23312
  if (mcpHash !== prevMcpHash) {
22991
23313
  for (const e of desiredEntries) {
22992
23314
  frameworkAdapter.writeMcpServer(agent.code_name, e.serverId, { url: e.url, headers: e.headers });
22993
- const urlHash = createHash20("sha256").update(e.url).digest("hex").slice(0, 12);
23315
+ const urlHash = createHash21("sha256").update(e.url).digest("hex").slice(0, 12);
22994
23316
  log(`[managed-toolkit] ${agent.code_name}: wrote '${e.name}' (serverId=${e.serverId}, url_hash=${urlHash})`);
22995
23317
  }
22996
23318
  if (deferredPruneKeys.length === 0) {
@@ -23092,7 +23414,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
23092
23414
  if (frameworkAdapter.installSkillFiles) {
23093
23415
  const currentIntegrationSkillIds = /* @__PURE__ */ new Set();
23094
23416
  const installedIntegrationSkills = [];
23095
- const { createHash: createHash21 } = await import("crypto");
23417
+ const { createHash: createHash22 } = await import("crypto");
23096
23418
  const refreshAny = refreshData;
23097
23419
  const contexts = refreshAny.integration_contexts ?? refreshAny.plugin_contexts ?? [];
23098
23420
  const contextBySlug = /* @__PURE__ */ new Map();
@@ -23129,7 +23451,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
23129
23451
  )
23130
23452
  }));
23131
23453
  const bundle = buildIntegrationBundle(renderedScopes);
23132
- const contentHash = createHash21("sha256").update(bundleFingerprint(bundle.files)).digest("hex").slice(0, 12);
23454
+ const contentHash = createHash22("sha256").update(bundleFingerprint(bundle.files)).digest("hex").slice(0, 12);
23133
23455
  if (!shouldWriteIntegrationSkill(
23134
23456
  agentState.knownSkillHashes,
23135
23457
  agent.agent_id,
@@ -23157,12 +23479,12 @@ async function processAgent(agent, agentStates, managedToolkits) {
23157
23479
  const frameworkId2 = frameworkAdapter.id;
23158
23480
  const candidateSkillDirs = [
23159
23481
  // Claude Code — framework runtime tree
23160
- join45(homedir18(), ".augmented", agent.code_name, "skills"),
23482
+ join46(homedir18(), ".augmented", agent.code_name, "skills"),
23161
23483
  // Claude Code — project tree
23162
- join45(homedir18(), ".augmented", agent.code_name, "project", ".claude", "skills"),
23484
+ join46(homedir18(), ".augmented", agent.code_name, "project", ".claude", "skills"),
23163
23485
  // Defensive: legacy provision-side path, not currently an
23164
23486
  // install target but cheap to sweep.
23165
- join45(agentDir, ".claude", "skills")
23487
+ join46(agentDir, ".claude", "skills")
23166
23488
  ];
23167
23489
  const existingDirs = candidateSkillDirs.filter((d) => existsSync20(d));
23168
23490
  const discoveredEntries = /* @__PURE__ */ new Set();
@@ -23205,7 +23527,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
23205
23527
  const sharedSkillsPayload = refreshAny.shared_skills;
23206
23528
  const desiredResolved = globalSkillsPayload !== void 0 || sharedSkillsPayload !== void 0;
23207
23529
  const manifestPath = managedSkillManifestPath(
23208
- join45(homedir17(), ".augmented", agent.code_name)
23530
+ join46(homedir17(), ".augmented", agent.code_name)
23209
23531
  );
23210
23532
  const prevIds = /* @__PURE__ */ new Set([
23211
23533
  ...agentState.knownGlobalSkillIds.get(agent.agent_id) ?? /* @__PURE__ */ new Set(),
@@ -23214,7 +23536,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
23214
23536
  const plan = planGlobalSkillSync(
23215
23537
  [...globalSkillsPayload ?? [], ...sharedSkillsPayload ?? []],
23216
23538
  prevIds,
23217
- (content) => createHash21("sha256").update(content).digest("hex").slice(0, 12),
23539
+ (content) => createHash22("sha256").update(content).digest("hex").slice(0, 12),
23218
23540
  (skillId) => agentState.knownSkillHashes.get(`global-skill:${agent.agent_id}:${skillId}`),
23219
23541
  { desiredResolved }
23220
23542
  );
@@ -23225,15 +23547,15 @@ async function processAgent(agent, agentStates, managedToolkits) {
23225
23547
  }
23226
23548
  if (plan.removes.length) {
23227
23549
  const globalSkillDirs = [
23228
- join45(homedir17(), ".augmented", agent.code_name, "skills"),
23229
- join45(homedir17(), ".augmented", agent.code_name, "project", ".claude", "skills"),
23230
- join45(agentDir, ".claude", "skills")
23550
+ join46(homedir17(), ".augmented", agent.code_name, "skills"),
23551
+ join46(homedir17(), ".augmented", agent.code_name, "project", ".claude", "skills"),
23552
+ join46(agentDir, ".claude", "skills")
23231
23553
  ];
23232
23554
  for (const id of plan.removes) {
23233
23555
  let prunedAny = false;
23234
23556
  for (const dir of globalSkillDirs) {
23235
- const p = join45(dir, id);
23236
- if (existsSync20(p) && existsSync20(join45(p, "SKILL.md"))) {
23557
+ const p = join46(dir, id);
23558
+ if (existsSync20(p) && existsSync20(join46(p, "SKILL.md"))) {
23237
23559
  rmSync9(p, { recursive: true, force: true });
23238
23560
  prunedAny = true;
23239
23561
  }
@@ -23265,7 +23587,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
23265
23587
  const slug = hook.integration_slug ?? hook.plugin_slug;
23266
23588
  if (!slug) continue;
23267
23589
  try {
23268
- const scriptHash = createHash21("sha256").update(hook.script).digest("hex").slice(0, 12);
23590
+ const scriptHash = createHash22("sha256").update(hook.script).digest("hex").slice(0, 12);
23269
23591
  const hookKey = `${agent.agent_id}:${frameworkAdapter.id}:plugin-hook:${slug}:on_install`;
23270
23592
  if (agentState.knownSkillHashes.get(hookKey) === scriptHash) continue;
23271
23593
  const result = await frameworkAdapter.executePluginHook({
@@ -23280,9 +23602,9 @@ async function processAgent(agent, agentStates, managedToolkits) {
23280
23602
  } else if (result.timedOut) {
23281
23603
  log(`Integration hook on_install '${slug}' TIMED OUT for '${agent.code_name}' after ${result.durationMs}ms`);
23282
23604
  } else {
23283
- const stderrHash = createHash21("sha256").update(result.stderr).digest("hex").slice(0, 12);
23605
+ const stderrHash = createHash22("sha256").update(result.stderr).digest("hex").slice(0, 12);
23284
23606
  const missingCmd = result.exitCode === 127 ? extractCommandNotFound(result.stderr) : null;
23285
- const missingCmdHash = missingCmd ? createHash21("sha256").update(missingCmd).digest("hex").slice(0, 8) : null;
23607
+ const missingCmdHash = missingCmd ? createHash22("sha256").update(missingCmd).digest("hex").slice(0, 8) : null;
23286
23608
  log(
23287
23609
  `Integration hook on_install '${slug}' exited ${result.exitCode} for '${agent.code_name}' ` + (missingCmdHash ? `[missing_command_hash=${missingCmdHash}] ` : "") + `[stderr_hash=${stderrHash} stderr_len=${result.stderr.length}]`
23288
23610
  );
@@ -23503,8 +23825,10 @@ async function processAgent(agent, agentStates, managedToolkits) {
23503
23825
  const sess = getSessionState(agent.code_name);
23504
23826
  let mcpJsonParsed = null;
23505
23827
  try {
23506
- const mcpPath = join45(getProjectDir(agent.code_name), ".mcp.json");
23507
- mcpJsonParsed = JSON.parse(readFileSync36(mcpPath, "utf-8"));
23828
+ mcpJsonParsed = readSpawnViewMcpConfig(
23829
+ agent.code_name,
23830
+ getProjectDir(agent.code_name)
23831
+ );
23508
23832
  } catch {
23509
23833
  }
23510
23834
  const computerUseIsolated = isolationMode(agent.code_name) === "docker";
@@ -23966,7 +24290,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
23966
24290
  freshDoneIds.add(item.id);
23967
24291
  }
23968
24292
  } catch (err) {
23969
- const errId = createHash20("sha256").update(err instanceof Error ? err.message : String(err)).digest("hex").slice(0, 12);
24293
+ const errId = createHash21("sha256").update(err instanceof Error ? err.message : String(err)).digest("hex").slice(0, 12);
23970
24294
  log(`Reap API error for item_id=${item.id} error_id=${errId}`);
23971
24295
  }
23972
24296
  if (reapAction === "dead_letter") {
@@ -24017,7 +24341,7 @@ Retried to the limit after repeated stalls \u2014 needs a look.`).catch(() => {
24017
24341
  if (trackedFiles.length > 0 && existsSync20(agentDir)) {
24018
24342
  const hashes = /* @__PURE__ */ new Map();
24019
24343
  for (const file of trackedFiles) {
24020
- const h = hashFile(join45(agentDir, file));
24344
+ const h = hashFile(join46(agentDir, file));
24021
24345
  if (h) hashes.set(file, h);
24022
24346
  }
24023
24347
  agentState.writtenHashes.set(agent.agent_id, hashes);
@@ -24032,7 +24356,7 @@ Retried to the limit after repeated stalls \u2014 needs a look.`).catch(() => {
24032
24356
  refreshData.agent.onboarding_state
24033
24357
  );
24034
24358
  const obStep = obState.step;
24035
- const markerPath = join45(homedir17(), ".augmented", agent.code_name, "onboarding-drive.json");
24359
+ const markerPath = join46(homedir17(), ".augmented", agent.code_name, "onboarding-drive.json");
24036
24360
  const marker = readOnboardingDriveMarker(markerPath);
24037
24361
  const obContactRaw = refreshData.agent.manager_last_contacted_at;
24038
24362
  const obContact = typeof obContactRaw === "string" && obContactRaw ? obContactRaw : null;
@@ -24165,7 +24489,7 @@ async function ensureOpencodeRuntime(agent, refreshData, agentTimezone) {
24165
24489
  }
24166
24490
  stopOpencodeSlackIngest(codeName, log);
24167
24491
  stopOpencodeTelegramIngest(codeName, log);
24168
- const opencodeProjectDir = join45(getFramework("opencode").getAgentDir(codeName), "provision");
24492
+ const opencodeProjectDir = join46(getFramework("opencode").getAgentDir(codeName), "provision");
24169
24493
  const serveEnv = {
24170
24494
  AGT_HOST: requireHost(),
24171
24495
  AGT_API_KEY: getApiKey() ?? void 0,
@@ -24236,8 +24560,8 @@ async function ensurePersistentSessionUnchecked(agent, tasks, boardItems, refres
24236
24560
  });
24237
24561
  }
24238
24562
  const projectDir = getProjectDir(codeName);
24239
- const mcpConfigPath = join45(projectDir, ".mcp.json");
24240
- const claudeMdPath = join45(projectDir, "CLAUDE.md");
24563
+ const mcpConfigPath = join46(projectDir, ".mcp.json");
24564
+ const claudeMdPath = join46(projectDir, "CLAUDE.md");
24241
24565
  if (restartBreaker.isTripped(codeName)) {
24242
24566
  const trip = restartBreaker.getTrip(codeName);
24243
24567
  return {
@@ -24248,7 +24572,11 @@ async function ensurePersistentSessionUnchecked(agent, tasks, boardItems, refres
24248
24572
  };
24249
24573
  }
24250
24574
  if ((agentFrameworkCache.get(codeName) ?? DEFAULT_FRAMEWORK) === "claude-code" && !isSessionHealthy(codeName)) {
24251
- const missingMcpBundles = findMissingMcpBundles(mcpConfigPath);
24575
+ const spawnDropped = spawnDroppedServerKeys(
24576
+ mcpConfigPath,
24577
+ lastIntegrationsPayload.get(agent.agent_id)
24578
+ );
24579
+ const missingMcpBundles = findMissingMcpBundles(mcpConfigPath, { skipKeys: spawnDropped });
24252
24580
  if (missingMcpBundles.length > 0) {
24253
24581
  const detail = formatMissingMcpBundles(missingMcpBundles);
24254
24582
  log(
@@ -24621,7 +24949,7 @@ async function ensurePersistentSessionUnchecked(agent, tasks, boardItems, refres
24621
24949
  const ctx = getLastFailureContext(codeName);
24622
24950
  const recovery = prepareForRespawn(codeName);
24623
24951
  const tailSummary = !ctx.tail ? "" : KNOWN_SAFE_TAIL_SIGNATURES.has(ctx.signature) ? `; last pane output (${PANE_TAIL_PREVIEW_LINES} of ~20 lines):
24624
- ${truncateForLog(ctx.tail)}` : `; pane_tail_hash=sha256:${createHash20("sha256").update(ctx.tail).digest("hex").slice(0, 12)} (raw at ~/.augmented/${codeName}/pane.log)`;
24952
+ ${truncateForLog(ctx.tail)}` : `; pane_tail_hash=sha256:${createHash21("sha256").update(ctx.tail).digest("hex").slice(0, 12)} (raw at ~/.augmented/${codeName}/pane.log)`;
24625
24953
  const sigSummary = ctx.signature !== "unknown" ? `; signature=${ctx.signature}` : "";
24626
24954
  const recoverySummary = recovery ? `; recovery=${recovery}` : "";
24627
24955
  log(
@@ -24635,7 +24963,7 @@ ${truncateForLog(ctx.tail)}` : `; pane_tail_hash=sha256:${createHash20("sha256")
24635
24963
  );
24636
24964
  getHostId().then((hostId) => {
24637
24965
  if (!hostId) return;
24638
- const paneTailHash = zombie.paneTail ? `sha256:${createHash20("sha256").update(zombie.paneTail).digest("hex").slice(0, 12)}` : null;
24966
+ const paneTailHash = zombie.paneTail ? `sha256:${createHash21("sha256").update(zombie.paneTail).digest("hex").slice(0, 12)}` : null;
24639
24967
  return api.post("/host/events", {
24640
24968
  host_id: hostId,
24641
24969
  agent_code_name: codeName,
@@ -24746,11 +25074,30 @@ ${truncateForLog(ctx.tail)}` : `; pane_tail_hash=sha256:${createHash20("sha256")
24746
25074
  `[persistent-session] '${codeName}' (host_kind=${hostKind ?? "dedicated"}): injecting per-agent org-scoped key (ADR-0042 pt3b)`
24747
25075
  );
24748
25076
  }
25077
+ let spawnCopyFailedNow = false;
25078
+ const spawnMcpConfigPath = prepareSpawnMcpConfig({
25079
+ codeName,
25080
+ projectDir,
25081
+ mcpConfigPath,
25082
+ integrations: lastIntegrationsPayload.get(agent.agent_id),
25083
+ apiHost: requireHost(),
25084
+ log,
25085
+ // Sherlock's ruling on #7569: hold the drift restart while the copy keeps
25086
+ // failing on the same raw file, and keep a human-facing alert open.
25087
+ onCopyFailed: (info) => {
25088
+ spawnCopyFailedNow = true;
25089
+ const rawHash = projectMcpHash(codeName, projectDir, "raw");
25090
+ if (rawHash !== null && spawnCopyFailures.noteFailure(codeName, { rawHash, ...info })) {
25091
+ reportSpawnCopyFailure(codeName, info);
25092
+ }
25093
+ }
25094
+ });
25095
+ if (!spawnCopyFailedNow) spawnCopyFailures.noteSuccess(codeName);
24749
25096
  startPersistentSession({
24750
25097
  codeName,
24751
25098
  agentId: agent.agent_id,
24752
25099
  projectDir,
24753
- mcpConfigPath,
25100
+ mcpConfigPath: spawnMcpConfigPath,
24754
25101
  claudeMdPath,
24755
25102
  channels,
24756
25103
  devChannels,
@@ -24834,7 +25181,7 @@ ${truncateForLog(ctx.tail)}` : `; pane_tail_hash=sha256:${createHash20("sha256")
24834
25181
  recordSessionPolicyBaseline(codeName, currentPolicyModel, currentPolicyId);
24835
25182
  denyWebFetchBySession.set(codeName, spawnDenyWebFetch);
24836
25183
  persistDeliveryBaselineEntry("webFetch", agent.agent_id, webFetchBaselineValue(spawnDenyWebFetch));
24837
- seedSessionLaunchBaselines(codeName, projectDir);
25184
+ seedSessionLaunchBaselines(codeName, projectDir, spawnMcpConfigPath);
24838
25185
  if (effectiveIsolationMode(codeName) === "docker") {
24839
25186
  seedContainerMemory(codeName, resolveContainerMemory(spawnAgentClass));
24840
25187
  }
@@ -24900,7 +25247,7 @@ ${truncateForLog(ctx.tail)}` : `; pane_tail_hash=sha256:${createHash20("sha256")
24900
25247
  claudeAuthTupleBySession.set(codeName, currentAuthTuple);
24901
25248
  recordSessionPolicyBaseline(codeName, currentPolicyModel, currentPolicyId);
24902
25249
  }
24903
- const stableTasksHash = createHash20("sha256").update(JSON.stringify(tasks)).digest("hex").slice(0, 16);
25250
+ const stableTasksHash = createHash21("sha256").update(JSON.stringify(tasks)).digest("hex").slice(0, 16);
24904
25251
  const prevHash = agentState.knownTasksHashes.get(agent.agent_id);
24905
25252
  if (stableTasksHash !== prevHash) {
24906
25253
  const taskInputs = tasks.map((t) => buildSchedulerTaskInput(t));
@@ -25255,7 +25602,7 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
25255
25602
  if (!refreshData) return;
25256
25603
  const framework = refreshData.agent?.framework ?? agentFrameworkCache.get(codeName) ?? DEFAULT_FRAMEWORK;
25257
25604
  const hostId = await getHostId();
25258
- const parkForRestart = await import("../responsiveness-probe-ZOCD6UYO.js").then(
25605
+ const parkForRestart = await import("../responsiveness-probe-26TFNDWB.js").then(
25259
25606
  (m) => m.parkPendingInbound,
25260
25607
  (err) => err
25261
25608
  );
@@ -25332,7 +25679,7 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
25332
25679
  void api.post("/host/restart-ack", { host_id: hostId, agent_id: agentId, restart_requested_at: requestedAt }).catch((err) => log(`[restart-lane] ack failed for '${codeName}': ${err.message}`));
25333
25680
  void (async () => {
25334
25681
  try {
25335
- const { collectDiagnostics } = await import("../persistent-session-YBCMFF7T.js");
25682
+ const { collectDiagnostics } = await import("../persistent-session-FMY2FZEL.js");
25336
25683
  await api.post("/host/heartbeat", {
25337
25684
  host_id: hostId,
25338
25685
  agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
@@ -25385,7 +25732,7 @@ async function respawnAgentAfterMcpStop(codeName, reason) {
25385
25732
  }
25386
25733
  try {
25387
25734
  const hostId = await getHostId();
25388
- const { collectDiagnostics } = await import("../persistent-session-YBCMFF7T.js");
25735
+ const { collectDiagnostics } = await import("../persistent-session-FMY2FZEL.js");
25389
25736
  await api.post("/host/heartbeat", {
25390
25737
  host_id: hostId,
25391
25738
  agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
@@ -25480,7 +25827,7 @@ function ensureRealtimeKanbanStarted(agentStates) {
25480
25827
  );
25481
25828
  }
25482
25829
  }).catch((err) => {
25483
- const errId = createHash20("sha256").update(err instanceof Error ? err.message : String(err)).digest("hex").slice(0, 12);
25830
+ const errId = createHash21("sha256").update(err instanceof Error ? err.message : String(err)).digest("hex").slice(0, 12);
25484
25831
  log(
25485
25832
  `[realtime] Work trigger enqueue threw for '${agent.codeName}' item_id=${item.id} error_id=${errId} \u2014 hybrid nudge will retry`
25486
25833
  );
@@ -25797,7 +26144,7 @@ async function processDirectChatMessage(agent, msg) {
25797
26144
  if (useDoorbell) {
25798
26145
  try {
25799
26146
  const doorbell = directChatDoorbellPath(agent.agentId, homedir17());
25800
- mkdirSync17(dirname11(doorbell), { recursive: true });
26147
+ mkdirSync18(dirname11(doorbell), { recursive: true });
25801
26148
  writeFileSync19(doorbell, String(Date.now()));
25802
26149
  log(`[direct-chat] Doorbell rung for '${agent.codeName}' (msg=${msg.id}) \u2014 in-session MCP will pull via the cursor`);
25803
26150
  return;
@@ -25926,7 +26273,7 @@ ${formatRunMarker(run_id)}` : KANBAN_CHECK_COMMAND;
25926
26273
  if (run_id) openInjectedRunByCode.set(codeName, run_id);
25927
26274
  try {
25928
26275
  const doorbell = directChatDoorbellPath(agentId, homedir17());
25929
- mkdirSync17(dirname11(doorbell), { recursive: true });
26276
+ mkdirSync18(dirname11(doorbell), { recursive: true });
25930
26277
  writeFileSync19(doorbell, String(Date.now()));
25931
26278
  } catch (err) {
25932
26279
  log(`[kanban] doorbell ring failed for '${codeName}': ${err.message} (notice still queued)`);
@@ -26087,7 +26434,7 @@ async function processClaudePairSessions(agents) {
26087
26434
  snapshotPairConfig,
26088
26435
  // ENG-11659: result -> report body + the manager.log line that records it.
26089
26436
  planPairStartReport
26090
- } = await import("../claude-pair-runtime-2XKML4U6.js");
26437
+ } = await import("../claude-pair-runtime-ASGVKZ5N.js");
26091
26438
  const { resetClaudeSignin, describeSigninResetForLog, describeSigninResetFailure } = await import("../claude-signin-reset-6IJMMVYG.js");
26092
26439
  for (const pairId of pendingResp.cancelled_pair_ids ?? []) {
26093
26440
  log(`[claude-pair] sweeping orphan tmux session for pair ${pairId.slice(0, 8)}`);
@@ -26386,17 +26733,17 @@ var lastLocalFileHash = /* @__PURE__ */ new Map();
26386
26733
  var lastMemoriesBody = /* @__PURE__ */ new Map();
26387
26734
  var memoryManifests = /* @__PURE__ */ new Map();
26388
26735
  function memoryRetirementDir(configDir, codeName) {
26389
- return join45(configDir, "_memory-retirement", codeName);
26736
+ return join46(configDir, "_memory-retirement", codeName);
26390
26737
  }
26391
26738
  function memoryManifestPath(configDir, codeName) {
26392
- return join45(memoryRetirementDir(configDir, codeName), "manifest.json");
26739
+ return join46(memoryRetirementDir(configDir, codeName), "manifest.json");
26393
26740
  }
26394
26741
  function loadMemoryManifest(agentId, configDir, codeName) {
26395
26742
  const cached = memoryManifests.get(agentId);
26396
26743
  if (cached) return cached;
26397
26744
  let manifest = {};
26398
26745
  try {
26399
- const raw = readFileSync36(memoryManifestPath(configDir, codeName), "utf-8");
26746
+ const raw = readFileSync37(memoryManifestPath(configDir, codeName), "utf-8");
26400
26747
  const parsed = JSON.parse(raw);
26401
26748
  if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
26402
26749
  for (const [name, entry] of Object.entries(parsed)) {
@@ -26416,7 +26763,7 @@ function saveMemoryManifest(agentId, configDir, codeName) {
26416
26763
  if (!manifest) return;
26417
26764
  try {
26418
26765
  const path = memoryManifestPath(configDir, codeName);
26419
- mkdirSync17(memoryRetirementDir(configDir, codeName), { recursive: true });
26766
+ mkdirSync18(memoryRetirementDir(configDir, codeName), { recursive: true });
26420
26767
  const tmp = `${path}.tmp`;
26421
26768
  writeFileSync19(tmp, JSON.stringify(manifest, null, 2));
26422
26769
  renameSync11(tmp, path);
@@ -26424,7 +26771,7 @@ function saveMemoryManifest(agentId, configDir, codeName) {
26424
26771
  }
26425
26772
  }
26426
26773
  function retiredMemoryDir(configDir, codeName) {
26427
- return join45(memoryRetirementDir(configDir, codeName), "retired");
26774
+ return join46(memoryRetirementDir(configDir, codeName), "retired");
26428
26775
  }
26429
26776
  var RETIRED_MEMORY_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
26430
26777
  var lastRetirementReport = /* @__PURE__ */ new Map();
@@ -26503,7 +26850,7 @@ function applyMemoryTombstones(opts) {
26503
26850
  log2(`[memory-retire] ${agent.code_name}: KEPT '${tomb.name}' \u2014 no write record, not ours to remove`);
26504
26851
  continue;
26505
26852
  }
26506
- const filePath = join45(memoryDir, entry.file);
26853
+ const filePath = join46(memoryDir, entry.file);
26507
26854
  if (!existsSync20(filePath)) {
26508
26855
  outcomes.already_gone++;
26509
26856
  delete manifest[tomb.name];
@@ -26511,7 +26858,7 @@ function applyMemoryTombstones(opts) {
26511
26858
  continue;
26512
26859
  }
26513
26860
  try {
26514
- const actual = createHash20("sha256").update(readFileSync36(filePath)).digest("hex");
26861
+ const actual = createHash21("sha256").update(readFileSync37(filePath)).digest("hex");
26515
26862
  if (actual !== entry.sha) {
26516
26863
  outcomes.kept_modified++;
26517
26864
  outcomes.unapplied.push({ name: tomb.name, reason: "kept_modified" });
@@ -26521,11 +26868,11 @@ function applyMemoryTombstones(opts) {
26521
26868
  continue;
26522
26869
  }
26523
26870
  const destDir = retiredMemoryDir(configDir, agent.code_name);
26524
- mkdirSync17(destDir, { recursive: true });
26871
+ mkdirSync18(destDir, { recursive: true });
26525
26872
  const stamp = Date.now();
26526
- let dest = join45(destDir, `${entry.file}.${stamp}.retired`);
26873
+ let dest = join46(destDir, `${entry.file}.${stamp}.retired`);
26527
26874
  for (let n = 1; existsSync20(dest); n++) {
26528
- dest = join45(destDir, `${entry.file}.${stamp}-${n}.retired`);
26875
+ dest = join46(destDir, `${entry.file}.${stamp}-${n}.retired`);
26529
26876
  }
26530
26877
  renameSync11(filePath, dest);
26531
26878
  try {
@@ -26564,7 +26911,7 @@ function reapRetiredMemories(configDir, codeName, log2) {
26564
26911
  try {
26565
26912
  for (const file of readdirSync14(dir)) {
26566
26913
  if (!file.endsWith(".retired")) continue;
26567
- const path = join45(dir, file);
26914
+ const path = join46(dir, file);
26568
26915
  try {
26569
26916
  if (statSync15(path).mtimeMs < cutoff) {
26570
26917
  unlinkSync6(path);
@@ -26579,8 +26926,8 @@ function reapRetiredMemories(configDir, codeName, log2) {
26579
26926
  if (reaped > 0) log2(`[memory-retire] ${codeName}: reaped ${reaped} retired memory file(s) past TTL`);
26580
26927
  }
26581
26928
  async function syncMemories(agent, configDir, log2) {
26582
- const projectDir = join45(configDir, agent.code_name, "project");
26583
- const memoryDir = join45(projectDir, "memory");
26929
+ const projectDir = join46(configDir, agent.code_name, "project");
26930
+ const memoryDir = join46(projectDir, "memory");
26584
26931
  const isFreshSync = pendingFreshMemorySync.has(agent.agent_id);
26585
26932
  if (isFreshSync) {
26586
26933
  log2(`[memory-sync] Fresh-sync requested for '${agent.code_name}' \u2014 pulling DB first`);
@@ -26611,8 +26958,8 @@ async function syncMemories(agent, configDir, log2) {
26611
26958
  for (const file of readdirSync14(memoryDir)) {
26612
26959
  if (!file.endsWith(".md")) continue;
26613
26960
  try {
26614
- const raw = readFileSync36(join45(memoryDir, file), "utf-8");
26615
- const fileHash = createHash20("sha256").update(raw).digest("hex").slice(0, 16);
26961
+ const raw = readFileSync37(join46(memoryDir, file), "utf-8");
26962
+ const fileHash = createHash21("sha256").update(raw).digest("hex").slice(0, 16);
26616
26963
  currentHashes.set(file, fileHash);
26617
26964
  if (prevHashes.get(file) === fileHash) continue;
26618
26965
  const parsed = parseMemoryFile(raw, file.replace(/\.md$/, ""));
@@ -26636,7 +26983,7 @@ async function syncMemories(agent, configDir, log2) {
26636
26983
  } catch (err) {
26637
26984
  for (const mem of changedMemories) {
26638
26985
  for (const [file] of currentHashes) {
26639
- const parsed = parseMemoryFile(readFileSync36(join45(memoryDir, file), "utf-8"), file.replace(/\.md$/, ""));
26986
+ const parsed = parseMemoryFile(readFileSync37(join46(memoryDir, file), "utf-8"), file.replace(/\.md$/, ""));
26640
26987
  if (parsed?.name === mem.name) currentHashes.delete(file);
26641
26988
  }
26642
26989
  }
@@ -26663,7 +27010,7 @@ async function syncMemories(agent, configDir, log2) {
26663
27010
  }
26664
27011
  async function downloadMemories(agent, memoryDir, log2, { force, configDir }) {
26665
27012
  const localFiles = existsSync20(memoryDir) ? readdirSync14(memoryDir).filter((f) => f.endsWith(".md")).sort() : [];
26666
- const localListHash = createHash20("sha256").update(localFiles.join(",")).digest("hex").slice(0, 16);
27013
+ const localListHash = createHash21("sha256").update(localFiles.join(",")).digest("hex").slice(0, 16);
26667
27014
  const prevLocalHash = lastLocalFileHash.get(agent.agent_id);
26668
27015
  const prevDownload = lastDownloadHash.get(agent.agent_id);
26669
27016
  const memoriesToken = memoriesFetchGate.beginFetch(agent.agent_id);
@@ -26717,7 +27064,7 @@ async function downloadMemories(agent, memoryDir, log2, { force, configDir }) {
26717
27064
  // Per-agent, not host-wide: memories are agent-private, so a shared
26718
27065
  // store would buy almost no dedupe while exposing one agent's content
26719
27066
  // to every other agent on the host. See memory-cache.ts's header.
26720
- cacheDir: join45(configDir, agent.code_name, "_memory_bodies"),
27067
+ cacheDir: join46(configDir, agent.code_name, "_memory_bodies"),
26721
27068
  fetchContents: async (hashes) => {
26722
27069
  const res = await api.post(
26723
27070
  "/host/memories/contents",
@@ -26739,14 +27086,14 @@ async function downloadMemories(agent, memoryDir, log2, { force, configDir }) {
26739
27086
  );
26740
27087
  }
26741
27088
  }
26742
- const responseHash = createHash20("sha256").update(JSON.stringify({ m: memories ?? [], t: tombstones })).digest("hex").slice(0, 16);
27089
+ const responseHash = createHash21("sha256").update(JSON.stringify({ m: memories ?? [], t: tombstones })).digest("hex").slice(0, 16);
26743
27090
  if (!force && prevDownload && prevLocalHash === localListHash && lastDownloadHash.get(agent.agent_id) === responseHash) {
26744
27091
  return { status: "skipped", tombstones, truncated: dbMemories.tombstones_truncated === true };
26745
27092
  }
26746
27093
  lastDownloadHash.set(agent.agent_id, responseHash);
26747
27094
  lastLocalFileHash.set(agent.agent_id, localListHash);
26748
27095
  if (memories?.length) {
26749
- mkdirSync17(memoryDir, { recursive: true });
27096
+ mkdirSync18(memoryDir, { recursive: true });
26750
27097
  const manifest = loadMemoryManifest(agent.agent_id, configDir, agent.code_name);
26751
27098
  let written = 0;
26752
27099
  let overwritten = 0;
@@ -26755,7 +27102,7 @@ async function downloadMemories(agent, memoryDir, log2, { force, configDir }) {
26755
27102
  const rawSlug = mem.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "").slice(0, 60);
26756
27103
  const slug = rawSlug || `memory-${i}`;
26757
27104
  const fileName = `${slug}.md`;
26758
- const filePath = join45(memoryDir, fileName);
27105
+ const filePath = join46(memoryDir, fileName);
26759
27106
  const desired = `---
26760
27107
  name: ${JSON.stringify(mem.name)}
26761
27108
  type: ${mem.type}
@@ -26765,7 +27112,7 @@ description: ${JSON.stringify(mem.content.slice(0, 200))}
26765
27112
  ${mem.content}
26766
27113
  `;
26767
27114
  const record = () => {
26768
- const sha = createHash20("sha256").update(desired).digest("hex");
27115
+ const sha = createHash21("sha256").update(desired).digest("hex");
26769
27116
  const prev = manifest[mem.name];
26770
27117
  if (prev?.file === fileName && prev.sha === sha) return false;
26771
27118
  manifest[mem.name] = { file: fileName, sha };
@@ -26775,7 +27122,7 @@ ${mem.content}
26775
27122
  if (existsSync20(filePath)) {
26776
27123
  let existing = "";
26777
27124
  try {
26778
- existing = readFileSync36(filePath, "utf-8");
27125
+ existing = readFileSync37(filePath, "utf-8");
26779
27126
  } catch {
26780
27127
  }
26781
27128
  if (existing === desired) {
@@ -26794,7 +27141,7 @@ ${mem.content}
26794
27141
  }
26795
27142
  if (written > 0 || overwritten > 0) {
26796
27143
  const updatedFiles = readdirSync14(memoryDir).filter((f) => f.endsWith(".md")).sort();
26797
- lastLocalFileHash.set(agent.agent_id, createHash20("sha256").update(updatedFiles.join(",")).digest("hex").slice(0, 16));
27144
+ lastLocalFileHash.set(agent.agent_id, createHash21("sha256").update(updatedFiles.join(",")).digest("hex").slice(0, 16));
26798
27145
  log2(`Memory download for '${agent.code_name}': wrote ${written} new, overwrote ${overwritten} stale`);
26799
27146
  }
26800
27147
  }
@@ -27176,7 +27523,7 @@ function startManager(opts) {
27176
27523
  try {
27177
27524
  const stateFile = getStateFile();
27178
27525
  if (existsSync20(stateFile)) {
27179
- const raw = readFileSync36(stateFile, "utf-8");
27526
+ const raw = readFileSync37(stateFile, "utf-8");
27180
27527
  const parsed = JSON.parse(raw);
27181
27528
  if (Array.isArray(parsed.agents)) {
27182
27529
  state9.agents = parsed.agents;
@@ -27210,7 +27557,7 @@ function startManager(opts) {
27210
27557
  log(`[startup] state rehydration failed (continuing with empty state): ${err.message}`);
27211
27558
  }
27212
27559
  log(
27213
- `[startup] worker pid=${process.pid} ppid=${process.ppid} node=${process.version} log=${join45(homedir17(), ".augmented", "manager.log")}`
27560
+ `[startup] worker pid=${process.pid} ppid=${process.ppid} node=${process.version} log=${join46(homedir17(), ".augmented", "manager.log")}`
27214
27561
  );
27215
27562
  deployMcpAssets();
27216
27563
  reapOrphanChannelMcps({ log });
@@ -27239,7 +27586,7 @@ async function reapOrphanedClaudePids() {
27239
27586
  const looksLikeClaude = (pid) => {
27240
27587
  if (process.platform !== "linux") return true;
27241
27588
  try {
27242
- const comm = readFileSync36(`/proc/${pid}/comm`, "utf-8").trim().toLowerCase();
27589
+ const comm = readFileSync37(`/proc/${pid}/comm`, "utf-8").trim().toLowerCase();
27243
27590
  return comm.includes("claude");
27244
27591
  } catch {
27245
27592
  return false;
@@ -27336,14 +27683,14 @@ function restartRunningChannelMcps(basenames) {
27336
27683
  }
27337
27684
  }
27338
27685
  function deployMcpAssets() {
27339
- const targetDir = join45(homedir17(), ".augmented", "_mcp");
27340
- mkdirSync17(targetDir, { recursive: true });
27686
+ const targetDir = join46(homedir17(), ".augmented", "_mcp");
27687
+ mkdirSync18(targetDir, { recursive: true });
27341
27688
  const moduleDir = dirname11(fileURLToPath2(import.meta.url));
27342
27689
  let mcpSourceDir = "";
27343
27690
  let dir = moduleDir;
27344
27691
  for (let i = 0; i < 6; i++) {
27345
- const candidate = join45(dir, "dist", "mcp");
27346
- if (existsSync20(join45(candidate, "index.js"))) {
27692
+ const candidate = join46(dir, "dist", "mcp");
27693
+ if (existsSync20(join46(candidate, "index.js"))) {
27347
27694
  mcpSourceDir = candidate;
27348
27695
  break;
27349
27696
  }
@@ -27361,7 +27708,7 @@ function deployMcpAssets() {
27361
27708
  const fileHash = (p) => {
27362
27709
  try {
27363
27710
  if (!existsSync20(p)) return null;
27364
- return createHash20("sha256").update(readFileSync36(p)).digest("hex");
27711
+ return createHash21("sha256").update(readFileSync37(p)).digest("hex");
27365
27712
  } catch {
27366
27713
  return null;
27367
27714
  }
@@ -27443,8 +27790,8 @@ function deployMcpAssets() {
27443
27790
  // natural session restart.
27444
27791
  "computer-use-proxy.js"
27445
27792
  ]) {
27446
- const src = join45(mcpSourceDir, file);
27447
- const dst = join45(targetDir, file);
27793
+ const src = join46(mcpSourceDir, file);
27794
+ const dst = join46(targetDir, file);
27448
27795
  if (!existsSync20(src)) continue;
27449
27796
  attemptedFiles.push(file);
27450
27797
  const before = fileHash(dst);
@@ -27470,16 +27817,16 @@ function deployMcpAssets() {
27470
27817
  log(`[manager] Bundle(s) updated: ${changedBasenames.join(", ")} \u2014 signalling running instances to restart`);
27471
27818
  restartRunningChannelMcps(changedBasenames);
27472
27819
  }
27473
- const localMcpPath = join45(targetDir, "index.js");
27820
+ const localMcpPath = join46(targetDir, "index.js");
27474
27821
  try {
27475
- const agentsDir = join45(homedir17(), ".augmented", "agents");
27822
+ const agentsDir = join46(homedir17(), ".augmented", "agents");
27476
27823
  if (existsSync20(agentsDir)) {
27477
27824
  for (const entry of readdirSync14(agentsDir, { withFileTypes: true })) {
27478
27825
  if (!entry.isDirectory()) continue;
27479
27826
  for (const subdir of ["provision", "project"]) {
27480
- const mcpJsonPath = join45(agentsDir, entry.name, subdir, ".mcp.json");
27827
+ const mcpJsonPath = join46(agentsDir, entry.name, subdir, ".mcp.json");
27481
27828
  try {
27482
- const raw = readFileSync36(mcpJsonPath, "utf-8");
27829
+ const raw = readFileSync37(mcpJsonPath, "utf-8");
27483
27830
  if (!raw.includes("@integrity-labs/augmented-mcp")) continue;
27484
27831
  const mcpConfig = JSON.parse(raw);
27485
27832
  const augServer = mcpConfig.mcpServers?.["augmented"];