@integrity-labs/agt-cli 0.28.1265 → 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.
Files changed (26) hide show
  1. package/dist/{api-client-LPV5RUCO.js → api-client-NGXHG4YA.js} +2 -2
  2. package/dist/bin/agt.js +6 -6
  3. package/dist/{chunk-ZIAXGM6I.js → chunk-DCI6M6TF.js} +2 -2
  4. package/dist/{chunk-DRP3J4CV.js → chunk-SR72T5SB.js} +4 -4
  5. package/dist/{chunk-6ENTMJ5T.js → chunk-UA2UPXYC.js} +47 -30
  6. package/dist/chunk-UA2UPXYC.js.map +1 -0
  7. package/dist/{chunk-HYQ7VOC3.js → chunk-XL2HPM67.js} +19 -3
  8. package/dist/chunk-XL2HPM67.js.map +1 -0
  9. package/dist/{claude-pair-runtime-2EOLNZEY.js → claude-pair-runtime-ASGVKZ5N.js} +15 -13
  10. package/dist/claude-pair-runtime-ASGVKZ5N.js.map +1 -0
  11. package/dist/lib/manager-worker.js +809 -460
  12. package/dist/lib/manager-worker.js.map +1 -1
  13. package/dist/mcp/direct-chat-channel.js +7 -1
  14. package/dist/mcp/slack-channel.js +7 -1
  15. package/dist/mcp/telegram-channel.js +7 -1
  16. package/dist/{persistent-session-C7UKT4EE.js → persistent-session-FMY2FZEL.js} +5 -3
  17. package/dist/{responsiveness-probe-NV3LXAWL.js → responsiveness-probe-26TFNDWB.js} +3 -3
  18. package/package.json +1 -1
  19. package/dist/chunk-6ENTMJ5T.js.map +0 -1
  20. package/dist/chunk-HYQ7VOC3.js.map +0 -1
  21. package/dist/claude-pair-runtime-2EOLNZEY.js.map +0 -1
  22. /package/dist/{api-client-LPV5RUCO.js.map → api-client-NGXHG4YA.js.map} +0 -0
  23. /package/dist/{chunk-ZIAXGM6I.js.map → chunk-DCI6M6TF.js.map} +0 -0
  24. /package/dist/{chunk-DRP3J4CV.js.map → chunk-SR72T5SB.js.map} +0 -0
  25. /package/dist/{persistent-session-C7UKT4EE.js.map → persistent-session-FMY2FZEL.js.map} +0 -0
  26. /package/dist/{responsiveness-probe-NV3LXAWL.js.map → responsiveness-probe-26TFNDWB.js.map} +0 -0
@@ -70,7 +70,7 @@ import {
70
70
  tripClass,
71
71
  writeEtcEnvironment,
72
72
  writeProfileDScript
73
- } from "../chunk-DRP3J4CV.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-ZIAXGM6I.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-6ENTMJ5T.js";
178
+ } from "../chunk-UA2UPXYC.js";
178
179
  import {
179
180
  isAgentIdle,
180
181
  isStaleForToday,
@@ -193,8 +194,10 @@ import {
193
194
  paneRemedy,
194
195
  parkedModalKind,
195
196
  sendDialogKeys,
196
- simpleTextHash
197
- } from "../chunk-HYQ7VOC3.js";
197
+ simpleTextHash,
198
+ tmuxPaneTarget,
199
+ tmuxSessionTarget
200
+ } from "../chunk-XL2HPM67.js";
198
201
  import "../chunk-6HBXEJHO.js";
199
202
  import {
200
203
  CLAUDE_CODE_SECURITY_FLOOR,
@@ -389,11 +392,11 @@ function killAbortsRestart(killed, restartReason) {
389
392
  }
390
393
  var TMUX_PROBE_TIMEOUT_MS = 3e3;
391
394
  function captureAgentPane(codeName) {
392
- const tmuxSession = `=agt-${codeName}`;
395
+ const tmuxSession = `agt-${codeName}`;
393
396
  let tmuxAlive;
394
397
  let screenCapture = null;
395
398
  try {
396
- execFileSync("tmux", ["has-session", "-t", tmuxSession], {
399
+ execFileSync("tmux", ["has-session", "-t", tmuxSessionTarget(tmuxSession)], {
397
400
  stdio: ["ignore", "ignore", "pipe"],
398
401
  encoding: "utf-8",
399
402
  timeout: TMUX_PROBE_TIMEOUT_MS
@@ -404,7 +407,7 @@ function captureAgentPane(codeName) {
404
407
  }
405
408
  if (tmuxAlive) {
406
409
  try {
407
- screenCapture = execFileSync("tmux", ["capture-pane", "-t", `${tmuxSession}:`, "-p", "-S", "-30"], {
410
+ screenCapture = execFileSync("tmux", ["capture-pane", "-t", tmuxPaneTarget(tmuxSession), "-p", "-S", "-30"], {
408
411
  encoding: "utf-8",
409
412
  timeout: TMUX_PROBE_TIMEOUT_MS
410
413
  }).trim();
@@ -416,7 +419,7 @@ function captureAgentPane(codeName) {
416
419
  var TMUX_KILL_TIMEOUT_MS = 1e4;
417
420
  function killAgentPane(codeName, exec = execFileSync) {
418
421
  try {
419
- exec("tmux", ["kill-session", "-t", `=agt-${codeName}`], {
422
+ exec("tmux", ["kill-session", "-t", tmuxSessionTarget(`agt-${codeName}`)], {
420
423
  stdio: ["ignore", "ignore", "pipe"],
421
424
  encoding: "utf-8",
422
425
  timeout: TMUX_KILL_TIMEOUT_MS,
@@ -561,8 +564,8 @@ function confirmConfigReload(input, deps) {
561
564
  }
562
565
 
563
566
  // src/lib/manager-worker.ts
564
- import { createHash as createHash20 } from "crypto";
565
- 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";
566
569
 
567
570
  // src/lib/atomic-file-replace.ts
568
571
  import { copyFileSync, renameSync, unlinkSync } from "fs";
@@ -979,7 +982,7 @@ function clearEpisode(codeName) {
979
982
  }
980
983
 
981
984
  // src/lib/manager-worker.ts
982
- 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";
983
986
  import { homedir as homedir17, hostname, platform as platform3 } from "os";
984
987
  import { fileURLToPath as fileURLToPath2 } from "url";
985
988
 
@@ -2855,17 +2858,272 @@ function isRemoteMcpEntry(value) {
2855
2858
  function expectedRemoteMcpKeys(integrations) {
2856
2859
  return new Set(integrations.map((i) => remoteMcpServerKey(i.definition_id, i.connection_key ?? null)));
2857
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
+ }
2858
2868
  function orphanedRemoteMcpKeys(mcpServers, expectedIntegrationKeys) {
2859
2869
  const orphans = [];
2860
2870
  for (const [key, entry] of Object.entries(mcpServers)) {
2861
2871
  if (expectedIntegrationKeys.has(key)) continue;
2862
2872
  if (isManagedMcpServerKey(key)) continue;
2863
- if (!isRemoteMcpEntry(entry) && classifyMcpServer(entry) !== "oauth-proxy") continue;
2873
+ if (!isRemoteMcpEntry(entry) && classifyMcpServer(entry) !== "oauth-proxy" && !isSanitizedRemoteBridge(entry)) continue;
2864
2874
  orphans.push(key);
2865
2875
  }
2866
2876
  return orphans;
2867
2877
  }
2868
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
+
2869
3127
  // src/lib/auto-resume.ts
2870
3128
  var DEFAULT_QUIET_MS = 18e5;
2871
3129
  var DEFAULT_BACKOFF_RESET_MS = 864e5;
@@ -3087,12 +3345,12 @@ function stopAgentRuntime(codeName, reason, log2, deps) {
3087
3345
  }
3088
3346
 
3089
3347
  // src/lib/opencode-credential-fingerprint.ts
3090
- import { createHash as createHash4 } from "crypto";
3348
+ import { createHash as createHash5 } from "crypto";
3091
3349
  var FINGERPRINT_LENGTH = 16;
3092
3350
  var ABSENT = "none";
3093
3351
  function fingerprintOf(secret) {
3094
3352
  if (!secret) return ABSENT;
3095
- 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);
3096
3354
  }
3097
3355
  function opencodeCredentialFingerprint(inputs) {
3098
3356
  const openRouter = inputs.openRouterToken ? inputs.openRouterFingerprint || fingerprintOf(inputs.openRouterToken) : ABSENT;
@@ -3284,9 +3542,9 @@ var DependencyRecoveryLedger = class {
3284
3542
  // src/lib/mcp-assets-ready.ts
3285
3543
  import { existsSync as nodeExistsSync, readFileSync as nodeReadFileSync } from "fs";
3286
3544
  import { homedir as homedir2 } from "os";
3287
- import { join as join7, resolve, sep } from "path";
3545
+ import { join as join8, resolve, sep } from "path";
3288
3546
  function getSharedMcpDir(homeDir = homedir2()) {
3289
- return join7(homeDir, ".augmented", "_mcp");
3547
+ return join8(homeDir, ".augmented", "_mcp");
3290
3548
  }
3291
3549
  function isPathInsideDir(candidate, dir) {
3292
3550
  const resolvedDir = resolve(dir);
@@ -3296,11 +3554,11 @@ function isPathInsideDir(candidate, dir) {
3296
3554
  }
3297
3555
  function findMissingMcpBundles(mcpConfigPath, deps = {}) {
3298
3556
  const existsSync21 = deps.existsSync ?? nodeExistsSync;
3299
- const readFileSync37 = deps.readFileSync ?? nodeReadFileSync;
3557
+ const readFileSync38 = deps.readFileSync ?? nodeReadFileSync;
3300
3558
  const mcpDir = deps.mcpDir ?? getSharedMcpDir();
3301
3559
  let parsed;
3302
3560
  try {
3303
- parsed = JSON.parse(readFileSync37(mcpConfigPath, "utf-8"));
3561
+ parsed = JSON.parse(readFileSync38(mcpConfigPath, "utf-8"));
3304
3562
  } catch {
3305
3563
  return [];
3306
3564
  }
@@ -3309,6 +3567,7 @@ function findMissingMcpBundles(mcpConfigPath, deps = {}) {
3309
3567
  const missing = [];
3310
3568
  const seenPaths = /* @__PURE__ */ new Set();
3311
3569
  for (const [key, rawEntry] of Object.entries(servers)) {
3570
+ if (deps.skipKeys?.has(key)) continue;
3312
3571
  if (!rawEntry || typeof rawEntry !== "object" || Array.isArray(rawEntry)) continue;
3313
3572
  const entry = rawEntry;
3314
3573
  if (entry.command !== "node") continue;
@@ -3338,7 +3597,7 @@ function formatMissingMcpBundles(missing) {
3338
3597
  }
3339
3598
 
3340
3599
  // src/lib/self-update-coalesce.ts
3341
- 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";
3342
3601
  import { dirname as dirname4 } from "path";
3343
3602
  var DEFAULT_SELF_UPDATE_COALESCE_MS = 30 * 60 * 1e3;
3344
3603
  function resolveCoalesceWindowMs(env = process.env) {
@@ -3348,7 +3607,7 @@ function resolveCoalesceWindowMs(env = process.env) {
3348
3607
  if (!Number.isFinite(parsed) || parsed < 0) return DEFAULT_SELF_UPDATE_COALESCE_MS;
3349
3608
  return Math.trunc(parsed);
3350
3609
  }
3351
- 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")) {
3352
3611
  let raw;
3353
3612
  try {
3354
3613
  raw = read(markerPath);
@@ -3361,7 +3620,7 @@ function readLastSelfUpdateAppliedMs(markerPath, now = Date.now(), read = (p) =>
3361
3620
  return v;
3362
3621
  }
3363
3622
  function stampLastSelfUpdateApplied(markerPath, now = Date.now(), write = (p, v) => {
3364
- mkdirSync3(dirname4(p), { recursive: true });
3623
+ mkdirSync4(dirname4(p), { recursive: true });
3365
3624
  writeFileSync4(p, v);
3366
3625
  }) {
3367
3626
  try {
@@ -3653,11 +3912,11 @@ async function reportModelApiError(opts) {
3653
3912
  }
3654
3913
 
3655
3914
  // src/lib/claude-pid-tracker.ts
3656
- import { existsSync, readFileSync as readFileSync8 } from "fs";
3915
+ import { existsSync, readFileSync as readFileSync9 } from "fs";
3657
3916
  function readPidFile(path) {
3658
3917
  if (!existsSync(path)) return { version: 1, spawns: [] };
3659
3918
  try {
3660
- const raw = JSON.parse(readFileSync8(path, "utf-8"));
3919
+ const raw = JSON.parse(readFileSync9(path, "utf-8"));
3661
3920
  if (raw.version !== 1 || !Array.isArray(raw.spawns)) return { version: 1, spawns: [] };
3662
3921
  const spawns = raw.spawns.filter(
3663
3922
  (s) => !!s && typeof s.pid === "number" && Number.isFinite(s.pid) && s.pid > 0
@@ -3757,14 +4016,14 @@ async function killSessionsConcurrently(sessions, killOne) {
3757
4016
  }
3758
4017
 
3759
4018
  // src/lib/direct-chat-delivery.ts
3760
- import { join as join8 } from "path";
4019
+ import { join as join9 } from "path";
3761
4020
  var DEFAULT_DIRECT_CHAT_MAX_AGE_MS = 30 * 6e4;
3762
4021
  function directChatMaxAgeMs() {
3763
4022
  const raw = parseInt(process.env["AGT_DIRECT_CHAT_MAX_AGE_MS"] ?? "", 10);
3764
4023
  return Number.isFinite(raw) && raw >= 0 ? raw : DEFAULT_DIRECT_CHAT_MAX_AGE_MS;
3765
4024
  }
3766
4025
  function directChatDoorbellPath(agentId, home) {
3767
- return join8(home, ".augmented", agentId, "direct-chat-doorbell");
4026
+ return join9(home, ".augmented", agentId, "direct-chat-doorbell");
3768
4027
  }
3769
4028
  function isDirectChatMessageExpired(createdAt, nowMs, maxAgeMs) {
3770
4029
  if (!maxAgeMs || maxAgeMs <= 0) return false;
@@ -3775,8 +4034,8 @@ function isDirectChatMessageExpired(createdAt, nowMs, maxAgeMs) {
3775
4034
  }
3776
4035
 
3777
4036
  // src/lib/review-poster-asset.ts
3778
- import { copyFileSync as copyFileSync2, chmodSync, existsSync as existsSync2, mkdirSync as mkdirSync4, readFileSync as readFileSync9 } from "fs";
3779
- 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";
3780
4039
  import { fileURLToPath } from "url";
3781
4040
  var POSTER_FILENAME = "post-review-findings.mjs";
3782
4041
  var AUTH_FILENAME = "obiwan-auth.mjs";
@@ -3789,14 +4048,14 @@ function resolveBundledReviewAssetDir() {
3789
4048
  const moduleDir = dirname5(fileURLToPath(import.meta.url));
3790
4049
  const candidates = [
3791
4050
  // Built output: dist/<chunk>.js → dist/assets/review
3792
- join9(moduleDir, "assets", REVIEW_ASSET_DIRNAME),
4051
+ join10(moduleDir, "assets", REVIEW_ASSET_DIRNAME),
3793
4052
  // Built output sibling case: dist/<sub>/<chunk>.js → dist/assets/review
3794
- join9(moduleDir, "..", "assets", REVIEW_ASSET_DIRNAME),
4053
+ join10(moduleDir, "..", "assets", REVIEW_ASSET_DIRNAME),
3795
4054
  // Dev source: src/lib/review-poster-asset.ts → ../../assets/review
3796
- join9(moduleDir, "..", "..", "assets", REVIEW_ASSET_DIRNAME)
4055
+ join10(moduleDir, "..", "..", "assets", REVIEW_ASSET_DIRNAME)
3797
4056
  ];
3798
4057
  for (const candidate of candidates) {
3799
- if (existsSync2(join9(candidate, POSTER_FILENAME))) return candidate;
4058
+ if (existsSync2(join10(candidate, POSTER_FILENAME))) return candidate;
3800
4059
  }
3801
4060
  throw new Error(
3802
4061
  `[review-poster] could not locate bundled assets; tried:
@@ -3804,18 +4063,18 @@ function resolveBundledReviewAssetDir() {
3804
4063
  );
3805
4064
  }
3806
4065
  function reviewPosterDir(codeName) {
3807
- return join9(getFramework("claude-code").getAgentDir(codeName), REVIEW_ASSET_DIRNAME);
4066
+ return join10(getFramework("claude-code").getAgentDir(codeName), REVIEW_ASSET_DIRNAME);
3808
4067
  }
3809
4068
  function provisionReviewPoster(codeName, sourceDir = resolveBundledReviewAssetDir()) {
3810
4069
  const destDir = reviewPosterDir(codeName);
3811
- mkdirSync4(destDir, { recursive: true });
4070
+ mkdirSync5(destDir, { recursive: true });
3812
4071
  for (const [name, mode] of ASSET_FILES) {
3813
- const src = join9(sourceDir, name);
3814
- const dest = join9(destDir, name);
4072
+ const src = join10(sourceDir, name);
4073
+ const dest = join10(destDir, name);
3815
4074
  if (!existsSync2(src)) {
3816
4075
  throw new Error(`[review-poster] bundled asset missing: ${src}`);
3817
4076
  }
3818
- if (!existsSync2(dest) || !readFileSync9(src).equals(readFileSync9(dest))) {
4077
+ if (!existsSync2(dest) || !readFileSync10(src).equals(readFileSync10(dest))) {
3819
4078
  copyFileSync2(src, dest);
3820
4079
  }
3821
4080
  chmodSync(dest, mode);
@@ -3823,8 +4082,8 @@ function provisionReviewPoster(codeName, sourceDir = resolveBundledReviewAssetDi
3823
4082
  }
3824
4083
 
3825
4084
  // src/lib/scratch-sweep-policy.ts
3826
- import { existsSync as existsSync3, mkdirSync as mkdirSync5, readFileSync as readFileSync10, rmSync as rmSync2, writeFileSync as writeFileSync5 } from "fs";
3827
- 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";
3828
4087
  var SCRATCH_POLICY_LOG_INTERVAL_MS = 60 * 60 * 1e3;
3829
4088
  var SCRATCH_HOLD_LIFT_DELAY_MS = 10 * 60 * 1e3;
3830
4089
  var SCRATCH_HOLD_MAX_OBSERVATION_GAP_MS = 5 * 60 * 1e3;
@@ -3855,9 +4114,9 @@ function resolveScratchSweepPolicy(input) {
3855
4114
  note(input, "kept=all reason=invalid-agent-id");
3856
4115
  return HELD;
3857
4116
  }
3858
- const marker = join10(input.holdsDir, input.agentId);
4117
+ const marker = join11(input.holdsDir, input.agentId);
3859
4118
  if (unrecordedHolds.has(input.agentId) || input.flag("scratch-sweep-held", input.agentId)) {
3860
- mkdirSync5(input.holdsDir, { recursive: true });
4119
+ mkdirSync6(input.holdsDir, { recursive: true });
3861
4120
  writeFileSync5(marker, HELD_MARKER);
3862
4121
  unrecordedHolds.delete(input.agentId);
3863
4122
  return HELD;
@@ -3870,7 +4129,7 @@ function resolveScratchSweepPolicy(input) {
3870
4129
  return HELD;
3871
4130
  }
3872
4131
  const now = (input.now ?? Date.now)();
3873
- const off = OFF_SINCE.exec(readFileSync10(marker, "utf8"));
4132
+ const off = OFF_SINCE.exec(readFileSync11(marker, "utf8"));
3874
4133
  if (!off) {
3875
4134
  writeFileSync5(marker, offSince(now, now));
3876
4135
  return HELD;
@@ -3893,7 +4152,7 @@ function resolveScratchSweepPolicy(input) {
3893
4152
  rmSync2(marker, { force: true });
3894
4153
  }
3895
4154
  if (state10 === "not-evaluated") {
3896
- mkdirSync5(input.holdsDir, { recursive: true });
4155
+ mkdirSync6(input.holdsDir, { recursive: true });
3897
4156
  writeFileSync5(marker, HELD_MARKER);
3898
4157
  note(input, "kept=all reason=agent-not-evaluated");
3899
4158
  return HELD;
@@ -3923,15 +4182,15 @@ function recordScratchHoldsFromHeartbeat(input) {
3923
4182
  let held = false;
3924
4183
  try {
3925
4184
  held = input.flag("scratch-sweep-held", id);
3926
- const marker = join10(input.holdsDir, id);
4185
+ const marker = join11(input.holdsDir, id);
3927
4186
  if (held) {
3928
- mkdirSync5(input.holdsDir, { recursive: true });
4187
+ mkdirSync6(input.holdsDir, { recursive: true });
3929
4188
  writeFileSync5(marker, HELD_MARKER);
3930
4189
  unrecordedHolds.delete(id);
3931
4190
  continue;
3932
4191
  }
3933
4192
  if (!existsSync3(marker)) continue;
3934
- const off = OFF_SINCE.exec(readFileSync10(marker, "utf8"));
4193
+ const off = OFF_SINCE.exec(readFileSync11(marker, "utf8"));
3935
4194
  if (!off) continue;
3936
4195
  const since = Number(off[1]);
3937
4196
  const seen = Number(off[2] ?? off[1]);
@@ -3947,8 +4206,8 @@ function recordScratchHoldsFromHeartbeat(input) {
3947
4206
  for (const id of input.hostAgentIds ?? []) {
3948
4207
  if (!safe(id) || evaluated.has(id)) continue;
3949
4208
  try {
3950
- mkdirSync5(input.holdsDir, { recursive: true });
3951
- writeFileSync5(join10(input.holdsDir, id), HELD_MARKER);
4209
+ mkdirSync6(input.holdsDir, { recursive: true });
4210
+ writeFileSync5(join11(input.holdsDir, id), HELD_MARKER);
3952
4211
  } catch (err) {
3953
4212
  unrecordedHolds.add(id);
3954
4213
  const code = err?.code ?? "unknown";
@@ -3959,8 +4218,8 @@ function recordScratchHoldsFromHeartbeat(input) {
3959
4218
  }
3960
4219
 
3961
4220
  // src/lib/id-keyed-migration.ts
3962
- import { existsSync as existsSync4, lstatSync as lstatSync2, readlinkSync, renameSync as renameSync2 } from "fs";
3963
- 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";
3964
4223
  import { homedir as homedir3 } from "os";
3965
4224
  var ID_KEYED_MIGRATION_FLAG = "id-keyed-layout-migration";
3966
4225
  function agentHasActiveWhatsapp(channelConfigs, codeNameDir) {
@@ -3968,7 +4227,7 @@ function agentHasActiveWhatsapp(channelConfigs, codeNameDir) {
3968
4227
  return true;
3969
4228
  }
3970
4229
  try {
3971
- if (existsSync4(join11(codeNameDir, "whatsapp-pending-inbound"))) return true;
4230
+ if (existsSync4(join12(codeNameDir, "whatsapp-pending-inbound"))) return true;
3972
4231
  } catch {
3973
4232
  }
3974
4233
  return false;
@@ -4000,13 +4259,13 @@ function finishTranscriptMove(oldCwd, newCwd, codeName, log2) {
4000
4259
  function maybeMigrateAgentToIdKeyedLayout(agent, deps) {
4001
4260
  const home = deps.home ?? homedir3();
4002
4261
  const { code_name: codeName, agent_id: agentId } = agent;
4003
- const codeNamePath = join11(home, ".augmented", codeName);
4004
- const idPath = join11(home, ".augmented", agentId);
4005
- const oldCwd = join11(home, ".augmented", codeName, "project");
4006
- 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");
4007
4266
  let codeNameKind;
4008
4267
  try {
4009
- codeNameKind = lstatSync2(codeNamePath).isSymbolicLink() ? "symlink" : "realdir";
4268
+ codeNameKind = lstatSync3(codeNamePath).isSymbolicLink() ? "symlink" : "realdir";
4010
4269
  } catch {
4011
4270
  codeNameKind = "absent";
4012
4271
  }
@@ -4264,7 +4523,7 @@ function decideAuthResolveFailureAction(args) {
4264
4523
  }
4265
4524
 
4266
4525
  // ../../packages/core/dist/host-config/capture.js
4267
- import { createHash as createHash5 } from "crypto";
4526
+ import { createHash as createHash6 } from "crypto";
4268
4527
  var NON_SECRET_ENV_GATES = [
4269
4528
  "AGT_MEMORY_EXTRACTION_ENABLED",
4270
4529
  "AGT_CHANNEL_REPLAY_ENABLED",
@@ -4302,8 +4561,8 @@ function collectEnvGates(env) {
4302
4561
  }
4303
4562
 
4304
4563
  // ../../packages/core/dist/direct-chat/cursor-advance-telemetry.js
4305
- import { readFileSync as readFileSync11, writeFileSync as writeFileSync6 } from "fs";
4306
- import { join as join12 } from "path";
4564
+ import { readFileSync as readFileSync12, writeFileSync as writeFileSync6 } from "fs";
4565
+ import { join as join13 } from "path";
4307
4566
  var CURSOR_SHORTFALL_COUNTER_SUFFIX = "-cursor-advance-classifications.json";
4308
4567
  function recordCursorAdvanceOutcome(agentDir, source, route, verdict) {
4309
4568
  if (!agentDir)
@@ -4311,10 +4570,10 @@ function recordCursorAdvanceOutcome(agentDir, source, route, verdict) {
4311
4570
  const key = cursorAdvanceCounterKey(route, verdict);
4312
4571
  if (key === null)
4313
4572
  return;
4314
- const path = join12(agentDir, `${source}${CURSOR_SHORTFALL_COUNTER_SUFFIX}`);
4573
+ const path = join13(agentDir, `${source}${CURSOR_SHORTFALL_COUNTER_SUFFIX}`);
4315
4574
  const counts = {};
4316
4575
  try {
4317
- const parsed = JSON.parse(readFileSync11(path, "utf-8"));
4576
+ const parsed = JSON.parse(readFileSync12(path, "utf-8"));
4318
4577
  if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
4319
4578
  for (const [k, v] of Object.entries(parsed)) {
4320
4579
  if (typeof v === "number" && Number.isInteger(v) && v >= 0)
@@ -4331,7 +4590,7 @@ function recordCursorAdvanceOutcome(agentDir, source, route, verdict) {
4331
4590
  }
4332
4591
 
4333
4592
  // src/lib/artifact-stream.ts
4334
- import { join as join13 } from "path";
4593
+ import { join as join14 } from "path";
4335
4594
  import { homedir as homedir4 } from "os";
4336
4595
  import { readdir, stat, readFile } from "fs/promises";
4337
4596
  var ARTEFACT_ENTRY_FILE = "index.html";
@@ -4417,7 +4676,7 @@ var ArtifactStreamScanner = class {
4417
4676
  return;
4418
4677
  }
4419
4678
  for (const name of names) {
4420
- const file = join13(this.artifactsDir, name, ARTEFACT_ENTRY_FILE);
4679
+ const file = join14(this.artifactsDir, name, ARTEFACT_ENTRY_FILE);
4421
4680
  const mtime = await this.fsDeps.mtimeMs(file).catch(() => null);
4422
4681
  if (mtime === null) continue;
4423
4682
  if (this.seenMtime.get(name) === mtime) continue;
@@ -4448,7 +4707,7 @@ var ArtifactStreamScanner = class {
4448
4707
  }
4449
4708
  };
4450
4709
  function artifactsDirFor(codeName) {
4451
- return join13(homedir4(), ".augmented", codeName, "artifacts");
4710
+ return join14(homedir4(), ".augmented", codeName, "artifacts");
4452
4711
  }
4453
4712
  var nodeArtifactFs = {
4454
4713
  async listArtefactNames(artifactsDir) {
@@ -4721,15 +4980,15 @@ async function maybePollHostUsage(deps) {
4721
4980
  }
4722
4981
 
4723
4982
  // src/lib/claude-account-fingerprint.ts
4724
- import { createHash as createHash6 } from "crypto";
4983
+ import { createHash as createHash7 } from "crypto";
4725
4984
  import { readFile as readFile3, readdir as readdir3 } from "fs/promises";
4726
4985
  import { homedir as homedir6, platform as platform2 } from "os";
4727
- import { dirname as dirname6, join as join15 } from "path";
4986
+ import { dirname as dirname6, join as join16 } from "path";
4728
4987
 
4729
4988
  // src/lib/claude-auth-detect.ts
4730
4989
  import { readFile as readFile2, readdir as readdir2 } from "fs/promises";
4731
4990
  import { homedir as homedir5, platform } from "os";
4732
- import { join as join14 } from "path";
4991
+ import { join as join15 } from "path";
4733
4992
  import { execFile } from "child_process";
4734
4993
  import { promisify } from "util";
4735
4994
  var execFileAsync = promisify(execFile);
@@ -4744,16 +5003,16 @@ async function detectClaudeAuth() {
4744
5003
  }
4745
5004
  async function findClaudeCredentialsPaths() {
4746
5005
  const candidates = [
4747
- join14(homedir5(), ".claude", ".credentials.json"),
4748
- join14(homedir5(), ".claude", "credentials.json")
5006
+ join15(homedir5(), ".claude", ".credentials.json"),
5007
+ join15(homedir5(), ".claude", "credentials.json")
4749
5008
  ];
4750
5009
  const isLinuxRoot = platform() === "linux" && typeof process.getuid === "function" && process.getuid() === 0;
4751
5010
  if (isLinuxRoot) {
4752
5011
  try {
4753
5012
  const entries = await readdir2("/home", { withFileTypes: true });
4754
5013
  for (const entry of entries.filter((entry2) => entry2.isDirectory()).sort((a, b) => a.name.localeCompare(b.name))) {
4755
- candidates.push(join14("/home", entry.name, ".claude", ".credentials.json"));
4756
- 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"));
4757
5016
  }
4758
5017
  } catch {
4759
5018
  }
@@ -4837,7 +5096,7 @@ async function candidateHomes() {
4837
5096
  try {
4838
5097
  const entries = await readdir3("/home", { withFileTypes: true });
4839
5098
  for (const entry of entries.filter((e) => e.isDirectory()).sort((a, b) => a.name.localeCompare(b.name))) {
4840
- homes.push(join15("/home", entry.name));
5099
+ homes.push(join16("/home", entry.name));
4841
5100
  }
4842
5101
  } catch {
4843
5102
  }
@@ -4857,17 +5116,17 @@ async function homeOfActiveCredentials() {
4857
5116
  async function claudeConfigCandidatePaths() {
4858
5117
  const paths = [];
4859
5118
  const configDir = process.env["CLAUDE_CONFIG_DIR"]?.trim();
4860
- if (configDir) paths.push(join15(configDir, ".claude.json"));
5119
+ if (configDir) paths.push(join16(configDir, ".claude.json"));
4861
5120
  const activeHome = await homeOfActiveCredentials();
4862
- if (activeHome) paths.push(join15(activeHome, ".claude.json"));
5121
+ if (activeHome) paths.push(join16(activeHome, ".claude.json"));
4863
5122
  for (const home of await candidateHomes()) {
4864
- const path = join15(home, ".claude.json");
5123
+ const path = join16(home, ".claude.json");
4865
5124
  if (!paths.includes(path)) paths.push(path);
4866
5125
  }
4867
5126
  return paths;
4868
5127
  }
4869
5128
  function hashAccount(accountUuid, organizationUuid) {
4870
- 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);
4871
5130
  }
4872
5131
  var ABSENT_CODES = /* @__PURE__ */ new Set(["ENOENT", "ENOTDIR"]);
4873
5132
  function errnoCode(err) {
@@ -5025,11 +5284,11 @@ function diffAuthTuples(recorded, current) {
5025
5284
  }
5026
5285
 
5027
5286
  // src/lib/account-enforcement-marker.ts
5028
- 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";
5029
5288
  import { homedir as homedir7 } from "os";
5030
- import { join as join16 } from "path";
5289
+ import { join as join17 } from "path";
5031
5290
  function accountEnforcementMarkerPath(codeName) {
5032
- return join16(homedir7(), ".augmented", codeName, ACCOUNT_ENFORCEMENT_MARKER_FILENAME);
5291
+ return join17(homedir7(), ".augmented", codeName, ACCOUNT_ENFORCEMENT_MARKER_FILENAME);
5033
5292
  }
5034
5293
  function syncAccountEnforcementMarker(codeName, level, log2 = (m) => process.stderr.write(`${m}
5035
5294
  `), text) {
@@ -5037,11 +5296,11 @@ function syncAccountEnforcementMarker(codeName, level, log2 = (m) => process.std
5037
5296
  clearAccountEnforcementMarker(codeName, log2);
5038
5297
  return;
5039
5298
  }
5040
- const dir = join16(homedir7(), ".augmented", codeName);
5041
- const path = join16(dir, ACCOUNT_ENFORCEMENT_MARKER_FILENAME);
5299
+ const dir = join17(homedir7(), ".augmented", codeName);
5300
+ const path = join17(dir, ACCOUNT_ENFORCEMENT_MARKER_FILENAME);
5042
5301
  const tempPath = `${path}.${process.pid}.tmp`;
5043
5302
  try {
5044
- mkdirSync6(dir, { recursive: true });
5303
+ mkdirSync7(dir, { recursive: true });
5045
5304
  writeFileSync7(tempPath, serializeAccountEnforcementMarker(level, text), "utf-8");
5046
5305
  renameSync3(tempPath, path);
5047
5306
  } catch (err) {
@@ -5063,8 +5322,8 @@ function clearAccountEnforcementMarker(codeName, log2 = (m) => process.stderr.wr
5063
5322
  }
5064
5323
 
5065
5324
  // src/lib/token-usage-monitor.ts
5066
- import { readdirSync, readFileSync as readFileSync12, statSync } from "fs";
5067
- import { join as join17 } from "path";
5325
+ import { readdirSync, readFileSync as readFileSync13, statSync } from "fs";
5326
+ import { join as join18 } from "path";
5068
5327
  var MIN_CHECK_INTERVAL_MS2 = 6e4;
5069
5328
  var TRANSCRIPT_MTIME_WINDOW_MS = 2 * 24 * 60 * 60 * 1e3;
5070
5329
  var MAX_ENTRIES_PER_POST = 200;
@@ -5093,7 +5352,7 @@ async function maybeReportTokenUsage(args) {
5093
5352
  if (!name.endsWith(".jsonl")) continue;
5094
5353
  const sessionId = name.slice(0, -".jsonl".length);
5095
5354
  if (!sessionId) continue;
5096
- const path = join17(dir, name);
5355
+ const path = join18(dir, name);
5097
5356
  let st;
5098
5357
  try {
5099
5358
  st = statSync(path);
@@ -5109,7 +5368,7 @@ async function maybeReportTokenUsage(args) {
5109
5368
  }
5110
5369
  let content;
5111
5370
  try {
5112
- content = readFileSync12(path, "utf-8");
5371
+ content = readFileSync13(path, "utf-8");
5113
5372
  } catch (err) {
5114
5373
  log2(`[token-usage] read failed for '${codeName}/${name}': ${err.message}`);
5115
5374
  continue;
@@ -5190,8 +5449,8 @@ async function maybeReportTokenUsage(args) {
5190
5449
  }
5191
5450
 
5192
5451
  // src/lib/failing-turn-monitor.ts
5193
- import { closeSync, openSync, readdirSync as readdirSync2, readSync, statSync as statSync2 } from "fs";
5194
- 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";
5195
5454
  var MIN_CHECK_INTERVAL_MS3 = 3e4;
5196
5455
  var FAILING_TURN_TAIL_BYTES = 512 * 1024;
5197
5456
  var ACTIVE_TRANSCRIPT_WINDOW_MS = 60 * 60 * 1e3;
@@ -5223,7 +5482,7 @@ function newestActiveTranscript(dir, nowMs) {
5223
5482
  let best = null;
5224
5483
  for (const name of names) {
5225
5484
  if (!name.endsWith(".jsonl")) continue;
5226
- const path = join18(dir, name);
5485
+ const path = join19(dir, name);
5227
5486
  try {
5228
5487
  const st = statSync2(path);
5229
5488
  if (!st.isFile() || nowMs - st.mtimeMs > ACTIVE_TRANSCRIPT_WINDOW_MS) continue;
@@ -5237,11 +5496,11 @@ function newestActiveTranscript(dir, nowMs) {
5237
5496
  function readTail(path, size, bytes = FAILING_TURN_TAIL_BYTES) {
5238
5497
  const length = Math.min(size, bytes);
5239
5498
  const buf = Buffer.alloc(length);
5240
- const fd = openSync(path, "r");
5499
+ const fd = openSync2(path, "r");
5241
5500
  try {
5242
5501
  readSync(fd, buf, 0, length, size - length);
5243
5502
  } finally {
5244
- closeSync(fd);
5503
+ closeSync2(fd);
5245
5504
  }
5246
5505
  return buf.toString("utf-8");
5247
5506
  }
@@ -5295,8 +5554,8 @@ function failingTurnLoops(now = Date.now(), threshold = failingTurnThreshold(),
5295
5554
  }
5296
5555
 
5297
5556
  // src/lib/session-activity.ts
5298
- import { closeSync as closeSync2, openSync as openSync2, readFileSync as readFileSync13, readSync as readSync2, readdirSync as readdirSync3, statSync as statSync3 } from "fs";
5299
- 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";
5300
5559
  var RULE = /^[─━]{10,}/;
5301
5560
  var CARET_LINE = /^\s*❯(\s|$)/;
5302
5561
  var NON_BLOCKING_PICKER = { title: "We recommend compacting earlier", footer: "esc not now", kind: "compaction-suggestion" };
@@ -5356,7 +5615,7 @@ function newestTranscript(dir) {
5356
5615
  let best = null;
5357
5616
  for (const name of names) {
5358
5617
  if (!name.endsWith(".jsonl")) continue;
5359
- const path = join19(dir, name);
5618
+ const path = join20(dir, name);
5360
5619
  try {
5361
5620
  const st = statSync3(path);
5362
5621
  if (st.isFile() && (best === null || st.mtimeMs > best.mtimeMs)) {
@@ -5370,7 +5629,7 @@ function newestTranscript(dir) {
5370
5629
  }
5371
5630
  function sessionTranscript(dir, sessionId) {
5372
5631
  if (!sessionId) return newestTranscript(dir);
5373
- const path = join19(dir, `${sessionId}.jsonl`);
5632
+ const path = join20(dir, `${sessionId}.jsonl`);
5374
5633
  try {
5375
5634
  const st = statSync3(path);
5376
5635
  return st.isFile() ? { path, mtimeMs: st.mtimeMs, size: st.size } : null;
@@ -5411,12 +5670,12 @@ function scanNewLines(path, size, scan, budget, log2) {
5411
5670
  const length = Math.min(size - offset, budget);
5412
5671
  if (length <= 0) return 0;
5413
5672
  const buffer = Buffer.alloc(length);
5414
- const fd = openSync2(path, "r");
5673
+ const fd = openSync3(path, "r");
5415
5674
  let read;
5416
5675
  try {
5417
5676
  read = readSync2(fd, buffer, 0, length, offset);
5418
5677
  } finally {
5419
- closeSync2(fd);
5678
+ closeSync3(fd);
5420
5679
  }
5421
5680
  let window = buffer.subarray(0, read);
5422
5681
  let base = offset;
@@ -5458,7 +5717,7 @@ function subagentFiles(dir) {
5458
5717
  }
5459
5718
  return names.flatMap((name) => {
5460
5719
  if (!name.endsWith(".jsonl")) return [];
5461
- const path = join19(dir, name);
5720
+ const path = join20(dir, name);
5462
5721
  try {
5463
5722
  const st = statSync3(path);
5464
5723
  return st.isFile() ? [{ path, mtimeMs: st.mtimeMs, size: st.size }] : [];
@@ -5472,7 +5731,7 @@ function knownProcessStartMs(session) {
5472
5731
  return session.startedAt === session.estimatedStartedAt ? null : session.startedAt;
5473
5732
  }
5474
5733
  function drainScan(scan, dir, log2) {
5475
- const main = join19(dir, `${scan.sessionId}.jsonl`);
5734
+ const main = join20(dir, `${scan.sessionId}.jsonl`);
5476
5735
  let budget = BACKGROUND_SCAN_BYTES_PER_POLL;
5477
5736
  try {
5478
5737
  budget -= scanNewLines(main, statSync3(main).size, scan, budget, log2);
@@ -5489,7 +5748,7 @@ function readBackgroundActivity(codeName, dir, sessionId, spawnedAtMs, isSpawnSe
5489
5748
  const sameRun = prev?.sessionId === sessionId && prev.spawnedAtMs === spawnedAtMs;
5490
5749
  if (prev && sameRun && minCheckMs > 0 && nowMs - prev.checkedAt < minCheckMs) return prev;
5491
5750
  try {
5492
- const main = join19(dir, `${sessionId}.jsonl`);
5751
+ const main = join20(dir, `${sessionId}.jsonl`);
5493
5752
  let size;
5494
5753
  try {
5495
5754
  size = statSync3(main).size;
@@ -5537,7 +5796,7 @@ function readBackgroundActivity(codeName, dir, sessionId, spawnedAtMs, isSpawnSe
5537
5796
  }
5538
5797
  function readRecordedSession(agentDir) {
5539
5798
  try {
5540
- 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"));
5541
5800
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
5542
5801
  const { session_id: sessionId, recorded_at: recordedAtMs } = parsed;
5543
5802
  if (typeof sessionId !== "string" || typeof recordedAtMs !== "number" || !Number.isFinite(recordedAtMs)) return null;
@@ -5629,8 +5888,8 @@ function buildSessionActivityReport(args) {
5629
5888
  }
5630
5889
 
5631
5890
  // src/lib/workflow-run-reconciler.ts
5632
- import { readdirSync as readdirSync4, readFileSync as readFileSync14, statSync as statSync4 } from "fs";
5633
- 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";
5634
5893
  var MIN_CHECK_INTERVAL_MS4 = 5 * 6e4;
5635
5894
  var SETTLE_MS = 3e4;
5636
5895
  var TRANSCRIPT_MTIME_WINDOW_MS2 = 2 * 24 * 60 * 60 * 1e3;
@@ -5669,7 +5928,7 @@ function collectJsonlRecursive(dir, minMtimeMs, out, depth) {
5669
5928
  return;
5670
5929
  }
5671
5930
  for (const name of entries) {
5672
- const p = join20(dir, name);
5931
+ const p = join21(dir, name);
5673
5932
  let st;
5674
5933
  try {
5675
5934
  st = statSync4(p);
@@ -5692,7 +5951,7 @@ function enumerateTranscriptFiles(transcriptDir, nowMs, minMtimeMs = nowMs - TRA
5692
5951
  return out;
5693
5952
  }
5694
5953
  for (const name of entries) {
5695
- const path = join20(transcriptDir, name);
5954
+ const path = join21(transcriptDir, name);
5696
5955
  let st;
5697
5956
  try {
5698
5957
  st = statSync4(path);
@@ -5704,7 +5963,7 @@ function enumerateTranscriptFiles(transcriptDir, nowMs, minMtimeMs = nowMs - TRA
5704
5963
  continue;
5705
5964
  }
5706
5965
  if (st.isDirectory()) {
5707
- collectJsonlRecursive(join20(path, "subagents"), minMtimeMs, out, 0);
5966
+ collectJsonlRecursive(join21(path, "subagents"), minMtimeMs, out, 0);
5708
5967
  }
5709
5968
  }
5710
5969
  return out;
@@ -5748,7 +6007,7 @@ async function maybeReconcileWorkflowRunTokens(args) {
5748
6007
  const contents = [];
5749
6008
  for (const path of files) {
5750
6009
  try {
5751
- contents.push(readFileSync14(path, "utf-8"));
6010
+ contents.push(readFileSync15(path, "utf-8"));
5752
6011
  } catch {
5753
6012
  }
5754
6013
  }
@@ -5793,8 +6052,8 @@ async function maybeReconcileWorkflowRunTokens(args) {
5793
6052
  }
5794
6053
 
5795
6054
  // src/lib/conversation-evaluator.ts
5796
- import { readdirSync as readdirSync5, readFileSync as readFileSync15, statSync as statSync5 } from "fs";
5797
- 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";
5798
6057
 
5799
6058
  // src/lib/detect-meta-egress.ts
5800
6059
  var REPOST_PREAMBLE_WINDOW = 200;
@@ -6279,7 +6538,7 @@ function readRecentTurns(dir, nowMs) {
6279
6538
  return;
6280
6539
  }
6281
6540
  for (const ent of entries) {
6282
- const full = join21(d, ent.name);
6541
+ const full = join22(d, ent.name);
6283
6542
  if (ent.isDirectory()) {
6284
6543
  visit(full);
6285
6544
  continue;
@@ -6294,7 +6553,7 @@ function readRecentTurns(dir, nowMs) {
6294
6553
  if (nowMs - mtimeMs > TRANSCRIPT_MTIME_WINDOW_MS3) continue;
6295
6554
  let content;
6296
6555
  try {
6297
- content = readFileSync15(full, "utf8");
6556
+ content = readFileSync16(full, "utf8");
6298
6557
  } catch {
6299
6558
  continue;
6300
6559
  }
@@ -6667,22 +6926,22 @@ async function reportSkip2(api2, agentId, conversationId, log2, codeName) {
6667
6926
 
6668
6927
  // src/lib/tool-call-audit.ts
6669
6928
  import { homedir as homedir11 } from "os";
6670
- import { join as join26 } from "path";
6929
+ import { join as join27 } from "path";
6671
6930
 
6672
6931
  // src/lib/agent-logging-mode.ts
6673
- import { readFileSync as readFileSync16 } from "fs";
6932
+ import { readFileSync as readFileSync17 } from "fs";
6674
6933
  import { homedir as homedir8 } from "os";
6675
- import { join as join22 } from "path";
6934
+ import { join as join23 } from "path";
6676
6935
  var LOGGING_MODES = ["hash-only", "redacted", "full-local"];
6677
6936
  function charterPath(codeName, homeDir) {
6678
6937
  const home = homeDir ?? (process.env["HOME"]?.trim() || homedir8());
6679
6938
  const key = agentRuntimeKey(codeName, homeDir);
6680
- return join22(home, ".augmented", key, "provision", "CHARTER.md");
6939
+ return join23(home, ".augmented", key, "provision", "CHARTER.md");
6681
6940
  }
6682
6941
  function readAgentLoggingMode(codeName, homeDir) {
6683
6942
  let raw;
6684
6943
  try {
6685
- raw = readFileSync16(charterPath(codeName, homeDir), "utf-8");
6944
+ raw = readFileSync17(charterPath(codeName, homeDir), "utf-8");
6686
6945
  } catch {
6687
6946
  return { mode: null, reason: "no-charter" };
6688
6947
  }
@@ -6706,15 +6965,15 @@ function loggingModeWithholdsTargets(reading) {
6706
6965
 
6707
6966
  // src/lib/tool-call-path-salt.ts
6708
6967
  import { randomBytes } from "crypto";
6709
- 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";
6710
6969
  import { homedir as homedir9 } from "os";
6711
- import { dirname as dirname7, join as join23 } from "path";
6970
+ import { dirname as dirname7, join as join24 } from "path";
6712
6971
  var SALT_BYTES = 32;
6713
6972
  var SALT_RE = /^[0-9a-f]{64}$/;
6714
6973
  function pathSaltPath(codeName, homeDir) {
6715
6974
  const home = homeDir ?? (process.env["HOME"]?.trim() || homedir9());
6716
6975
  const key = agentRuntimeKey(codeName, homeDir);
6717
- return join23(home, ".augmented", key, "tool-call-path-salt");
6976
+ return join24(home, ".augmented", key, "tool-call-path-salt");
6718
6977
  }
6719
6978
  function readToolCallPathSalt(codeName, homeDir) {
6720
6979
  let file;
@@ -6725,7 +6984,7 @@ function readToolCallPathSalt(codeName, homeDir) {
6725
6984
  }
6726
6985
  try {
6727
6986
  if (existsSync5(file)) {
6728
- const existing = readFileSync17(file, "utf-8").trim();
6987
+ const existing = readFileSync18(file, "utf-8").trim();
6729
6988
  if (SALT_RE.test(existing)) return existing;
6730
6989
  }
6731
6990
  } catch {
@@ -6733,7 +6992,7 @@ function readToolCallPathSalt(codeName, homeDir) {
6733
6992
  const salt = randomBytes(SALT_BYTES).toString("hex");
6734
6993
  const tmp = `${file}.tmp.${process.pid}`;
6735
6994
  try {
6736
- mkdirSync7(dirname7(file), { recursive: true, mode: 448 });
6995
+ mkdirSync8(dirname7(file), { recursive: true, mode: 448 });
6737
6996
  writeFileSync8(tmp, `${salt}
6738
6997
  `, { encoding: "utf-8", mode: 384 });
6739
6998
  renameSync4(tmp, file);
@@ -6751,20 +7010,20 @@ function readToolCallPathSalt(codeName, homeDir) {
6751
7010
  import { statSync as statSync6 } from "fs";
6752
7011
 
6753
7012
  // src/lib/tool-call-extractor.ts
6754
- import { closeSync as closeSync3, fstatSync, openSync as openSync3, readFileSync as readFileSync18, readSync as readSync3, readdirSync as readdirSync6 } from "fs";
6755
- 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";
6756
7015
  import { StringDecoder } from "string_decoder";
6757
7016
 
6758
7017
  // src/lib/tool-call-redaction.ts
6759
7018
  import { createHmac } from "crypto";
6760
7019
 
6761
7020
  // ../../packages/core/dist/tool-calls/input-hash.js
6762
- import { createHash as createHash7 } from "crypto";
7021
+ import { createHash as createHash8 } from "crypto";
6763
7022
  function hashToolInput(input) {
6764
7023
  if (input === void 0)
6765
7024
  return null;
6766
7025
  try {
6767
- return createHash7("sha256").update(canonicalJson2(input)).digest("hex");
7026
+ return createHash8("sha256").update(canonicalJson2(input)).digest("hex");
6768
7027
  } catch {
6769
7028
  return null;
6770
7029
  }
@@ -6881,7 +7140,7 @@ function redactToolTargetInner(toolName, input, ctx) {
6881
7140
  var EXTRACTOR_VERSION = "e1";
6882
7141
  function enumerateSessionTranscripts(transcriptDir, sessionId, projectsRoot) {
6883
7142
  const files = [];
6884
- const mainAbs = join24(transcriptDir, `${sessionId}.jsonl`);
7143
+ const mainAbs = join25(transcriptDir, `${sessionId}.jsonl`);
6885
7144
  files.push({
6886
7145
  absPath: mainAbs,
6887
7146
  relPath: relative(projectsRoot, mainAbs),
@@ -6889,7 +7148,7 @@ function enumerateSessionTranscripts(transcriptDir, sessionId, projectsRoot) {
6889
7148
  isSubagent: false,
6890
7149
  subagentId: null
6891
7150
  });
6892
- const subDir = join24(transcriptDir, sessionId, "subagents");
7151
+ const subDir = join25(transcriptDir, sessionId, "subagents");
6893
7152
  let entries;
6894
7153
  try {
6895
7154
  entries = readdirSync6(subDir);
@@ -6898,7 +7157,7 @@ function enumerateSessionTranscripts(transcriptDir, sessionId, projectsRoot) {
6898
7157
  }
6899
7158
  for (const name of entries) {
6900
7159
  if (!name.endsWith(".jsonl")) continue;
6901
- const abs = join24(subDir, name);
7160
+ const abs = join25(subDir, name);
6902
7161
  const stem = basename2(name, ".jsonl");
6903
7162
  files.push({
6904
7163
  absPath: abs,
@@ -7001,7 +7260,7 @@ var WINDOW_BUDGET_BYTES = 4 * 1024 * 1024;
7001
7260
  function extractTranscriptWindow(file, opts, from) {
7002
7261
  let fd;
7003
7262
  try {
7004
- fd = openSync3(file.absPath, "r");
7263
+ fd = openSync4(file.absPath, "r");
7005
7264
  } catch {
7006
7265
  return {
7007
7266
  records: [],
@@ -7022,7 +7281,7 @@ function extractTranscriptWindow(file, opts, from) {
7022
7281
  let rewound = false;
7023
7282
  let fileSize = null;
7024
7283
  try {
7025
- const { size } = fstatSync(fd);
7284
+ const { size } = fstatSync2(fd);
7026
7285
  fileSize = size;
7027
7286
  if (startByte > size) {
7028
7287
  startByte = 0;
@@ -7070,7 +7329,7 @@ function extractTranscriptWindow(file, opts, from) {
7070
7329
  } catch {
7071
7330
  } finally {
7072
7331
  try {
7073
- closeSync3(fd);
7332
+ closeSync4(fd);
7074
7333
  } catch {
7075
7334
  }
7076
7335
  }
@@ -7096,9 +7355,9 @@ function extractTranscriptWindow(file, opts, from) {
7096
7355
  }
7097
7356
 
7098
7357
  // src/lib/tool-call-cursor.ts
7099
- import { existsSync as existsSync6, readFileSync as readFileSync19 } from "fs";
7358
+ import { existsSync as existsSync6, readFileSync as readFileSync20 } from "fs";
7100
7359
  import { homedir as homedir10 } from "os";
7101
- import { join as join25 } from "path";
7360
+ import { join as join26 } from "path";
7102
7361
  var COVERAGE_DISPOSITIONS = [
7103
7362
  "ok",
7104
7363
  "not_entitled",
@@ -7153,13 +7412,13 @@ function parseCursorKey(key) {
7153
7412
  function cursorStatePath(codeName, homeDir) {
7154
7413
  const home = homeDir ?? (process.env["HOME"]?.trim() || homedir10());
7155
7414
  const key = agentRuntimeKey(codeName, homeDir);
7156
- return join25(home, ".augmented", key, "tool-call-cursors.json");
7415
+ return join26(home, ".augmented", key, "tool-call-cursors.json");
7157
7416
  }
7158
7417
  function loadCursors(path) {
7159
7418
  const out = /* @__PURE__ */ new Map();
7160
7419
  if (!existsSync6(path)) return out;
7161
7420
  try {
7162
- const parsed = JSON.parse(readFileSync19(path, "utf-8"));
7421
+ const parsed = JSON.parse(readFileSync20(path, "utf-8"));
7163
7422
  if (!parsed || parsed.version !== 1 || typeof parsed.files !== "object") return out;
7164
7423
  for (const [k, v] of Object.entries(parsed.files)) {
7165
7424
  if (!v || typeof v !== "object") continue;
@@ -7566,7 +7825,7 @@ async function maybeScanToolCalls(args) {
7566
7825
  log2(`[tool-call-audit] ${codeName}: no path-hash salt available \u2014 file targets withheld`);
7567
7826
  }
7568
7827
  const home = args.homeDir ?? (process.env["HOME"]?.trim() || homedir11());
7569
- const projectsRoot = args.projectsRoot ?? join26(home, ".claude", "projects");
7828
+ const projectsRoot = args.projectsRoot ?? join27(home, ".claude", "projects");
7570
7829
  const transcriptDir = args.transcriptDir ?? sessionTranscriptDir(getProjectDir(codeName));
7571
7830
  const current = peekCurrentSession(codeName);
7572
7831
  const sessionIds = current ? [current.sessionId] : [];
@@ -7595,11 +7854,11 @@ async function maybeScanToolCalls(args) {
7595
7854
  }
7596
7855
 
7597
7856
  // src/lib/activity-cache-monitor.ts
7598
- import { existsSync as existsSync7, readFileSync as readFileSync20 } from "fs";
7857
+ import { existsSync as existsSync7, readFileSync as readFileSync21 } from "fs";
7599
7858
  import { homedir as homedir12 } from "os";
7600
- import { join as join27 } from "path";
7859
+ import { join as join28 } from "path";
7601
7860
  var MIN_CHECK_INTERVAL_MS8 = 6e4;
7602
- var STATS_CACHE_PATH = join27(homedir12(), ".claude", "stats-cache.json");
7861
+ var STATS_CACHE_PATH = join28(homedir12(), ".claude", "stats-cache.json");
7603
7862
  var ISO_DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
7604
7863
  var state8 = { lastObservedDate: null, lastCheckedAt: 0 };
7605
7864
  function selectNewDailyRows(raw, lastObservedDate) {
@@ -7647,7 +7906,7 @@ async function maybeReportActivityCache(args) {
7647
7906
  }
7648
7907
  let raw;
7649
7908
  try {
7650
- raw = readFileSync20(STATS_CACHE_PATH, "utf-8");
7909
+ raw = readFileSync21(STATS_CACHE_PATH, "utf-8");
7651
7910
  } catch (err) {
7652
7911
  log2(`[activity-cache] readFileSync failed: ${err.message}`);
7653
7912
  return;
@@ -7920,7 +8179,7 @@ function deviceStateHoldApplies(inputs) {
7920
8179
  }
7921
8180
 
7922
8181
  // src/lib/channel-config-hash.ts
7923
- import { createHash as createHash8 } from "crypto";
8182
+ import { createHash as createHash9 } from "crypto";
7924
8183
  var DERIVED_PRINCIPAL_ID_LIST_KEYS = [
7925
8184
  "allowed_users",
7926
8185
  "diagnostic_chat_ids",
@@ -7941,7 +8200,7 @@ function normalizeChannelConfigForHash(config2) {
7941
8200
  }
7942
8201
  var CHANNEL_WRITE_VERSION = 9;
7943
8202
  function computeChannelConfigHash(input) {
7944
- return createHash8("sha256").update(
8203
+ return createHash9("sha256").update(
7945
8204
  canonicalJson({
7946
8205
  writeVersion: CHANNEL_WRITE_VERSION,
7947
8206
  cliVersion: input.cliVersion,
@@ -7965,11 +8224,11 @@ function computeChannelConfigHash(input) {
7965
8224
  }
7966
8225
 
7967
8226
  // src/lib/knowledge-cache.ts
7968
- import { createHash as createHash9 } from "crypto";
8227
+ import { createHash as createHash10 } from "crypto";
7969
8228
  import {
7970
8229
  existsSync as existsSync8,
7971
- mkdirSync as mkdirSync8,
7972
- readFileSync as readFileSync21,
8230
+ mkdirSync as mkdirSync9,
8231
+ readFileSync as readFileSync22,
7973
8232
  readdirSync as readdirSync7,
7974
8233
  renameSync as renameSync5,
7975
8234
  rmSync as rmSync4,
@@ -7977,21 +8236,21 @@ import {
7977
8236
  utimesSync,
7978
8237
  writeFileSync as writeFileSync9
7979
8238
  } from "fs";
7980
- import { join as join28 } from "path";
8239
+ import { join as join29 } from "path";
7981
8240
  var KNOWLEDGE_FETCH_CHUNK = 100;
7982
8241
  var CACHE_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
7983
8242
  var SWEEP_INTERVAL_MS = 24 * 60 * 60 * 1e3;
7984
8243
  var lastSweepAt = 0;
7985
8244
  function knowledgeHash(content) {
7986
- return createHash9("sha256").update(content, "utf8").digest("hex");
8245
+ return createHash10("sha256").update(content, "utf8").digest("hex");
7987
8246
  }
7988
8247
  function cachePath(cacheDir, hash) {
7989
- return join28(cacheDir, hash);
8248
+ return join29(cacheDir, hash);
7990
8249
  }
7991
8250
  function readCachedKnowledge(cacheDir, hash) {
7992
8251
  const path = cachePath(cacheDir, hash);
7993
8252
  try {
7994
- const content = readFileSync21(path, "utf-8");
8253
+ const content = readFileSync22(path, "utf-8");
7995
8254
  try {
7996
8255
  const now = /* @__PURE__ */ new Date();
7997
8256
  utimesSync(path, now, now);
@@ -8005,7 +8264,7 @@ function readCachedKnowledge(cacheDir, hash) {
8005
8264
  function writeCachedKnowledge(cacheDir, hash, content) {
8006
8265
  if (knowledgeHash(content) !== hash) return false;
8007
8266
  try {
8008
- mkdirSync8(cacheDir, { recursive: true });
8267
+ mkdirSync9(cacheDir, { recursive: true });
8009
8268
  const tmp = `${cachePath(cacheDir, hash)}.tmp-${process.pid}`;
8010
8269
  writeFileSync9(tmp, content, "utf-8");
8011
8270
  renameSync5(tmp, cachePath(cacheDir, hash));
@@ -8020,7 +8279,7 @@ function sweepKnowledgeCache(cacheDir, now = Date.now()) {
8020
8279
  try {
8021
8280
  if (!existsSync8(cacheDir)) return;
8022
8281
  for (const name of readdirSync7(cacheDir)) {
8023
- const path = join28(cacheDir, name);
8282
+ const path = join29(cacheDir, name);
8024
8283
  try {
8025
8284
  if (now - statSync8(path).mtimeMs > CACHE_TTL_MS) rmSync4(path, { force: true });
8026
8285
  } catch {
@@ -8068,11 +8327,11 @@ async function resolveKnowledgeFromManifest(args) {
8068
8327
  }
8069
8328
 
8070
8329
  // src/lib/memory-cache.ts
8071
- import { createHash as createHash10 } from "crypto";
8330
+ import { createHash as createHash11 } from "crypto";
8072
8331
  import {
8073
8332
  existsSync as existsSync9,
8074
- mkdirSync as mkdirSync9,
8075
- readFileSync as readFileSync22,
8333
+ mkdirSync as mkdirSync10,
8334
+ readFileSync as readFileSync23,
8076
8335
  readdirSync as readdirSync8,
8077
8336
  renameSync as renameSync6,
8078
8337
  rmSync as rmSync5,
@@ -8080,21 +8339,21 @@ import {
8080
8339
  utimesSync as utimesSync2,
8081
8340
  writeFileSync as writeFileSync10
8082
8341
  } from "fs";
8083
- import { join as join29 } from "path";
8342
+ import { join as join30 } from "path";
8084
8343
  var MEMORY_FETCH_CHUNK = 100;
8085
8344
  var CACHE_TTL_MS2 = 30 * 24 * 60 * 60 * 1e3;
8086
8345
  var SWEEP_INTERVAL_MS2 = 24 * 60 * 60 * 1e3;
8087
8346
  var lastSweepAt2 = /* @__PURE__ */ new Map();
8088
8347
  function memoryHash(content) {
8089
- return createHash10("sha256").update(content, "utf8").digest("hex");
8348
+ return createHash11("sha256").update(content, "utf8").digest("hex");
8090
8349
  }
8091
8350
  function cachePath2(cacheDir, hash) {
8092
- return join29(cacheDir, hash);
8351
+ return join30(cacheDir, hash);
8093
8352
  }
8094
8353
  function readCachedMemory(cacheDir, hash) {
8095
8354
  const path = cachePath2(cacheDir, hash);
8096
8355
  try {
8097
- const content = readFileSync22(path, "utf-8");
8356
+ const content = readFileSync23(path, "utf-8");
8098
8357
  try {
8099
8358
  const now = /* @__PURE__ */ new Date();
8100
8359
  utimesSync2(path, now, now);
@@ -8108,7 +8367,7 @@ function readCachedMemory(cacheDir, hash) {
8108
8367
  function writeCachedMemory(cacheDir, hash, content) {
8109
8368
  if (memoryHash(content) !== hash) return false;
8110
8369
  try {
8111
- mkdirSync9(cacheDir, { recursive: true });
8370
+ mkdirSync10(cacheDir, { recursive: true });
8112
8371
  const tmp = `${cachePath2(cacheDir, hash)}.tmp-${process.pid}`;
8113
8372
  writeFileSync10(tmp, content, "utf-8");
8114
8373
  renameSync6(tmp, cachePath2(cacheDir, hash));
@@ -8123,7 +8382,7 @@ function sweepMemoryCache(cacheDir, now = Date.now()) {
8123
8382
  try {
8124
8383
  if (!existsSync9(cacheDir)) return;
8125
8384
  for (const name of readdirSync8(cacheDir)) {
8126
- const path = join29(cacheDir, name);
8385
+ const path = join30(cacheDir, name);
8127
8386
  try {
8128
8387
  if (now - statSync9(path).mtimeMs > CACHE_TTL_MS2) rmSync5(path, { force: true });
8129
8388
  } catch {
@@ -8177,11 +8436,11 @@ async function resolveMemoriesFromManifest(args) {
8177
8436
  }
8178
8437
 
8179
8438
  // src/lib/skill-cache.ts
8180
- import { createHash as createHash11 } from "crypto";
8439
+ import { createHash as createHash12 } from "crypto";
8181
8440
  import {
8182
8441
  existsSync as existsSync10,
8183
- mkdirSync as mkdirSync10,
8184
- readFileSync as readFileSync23,
8442
+ mkdirSync as mkdirSync11,
8443
+ readFileSync as readFileSync24,
8185
8444
  readdirSync as readdirSync9,
8186
8445
  renameSync as renameSync7,
8187
8446
  rmSync as rmSync6,
@@ -8189,21 +8448,21 @@ import {
8189
8448
  utimesSync as utimesSync3,
8190
8449
  writeFileSync as writeFileSync11
8191
8450
  } from "fs";
8192
- import { join as join30 } from "path";
8451
+ import { join as join31 } from "path";
8193
8452
  var SKILL_FETCH_CHUNK = 100;
8194
8453
  var CACHE_TTL_MS3 = 30 * 24 * 60 * 60 * 1e3;
8195
8454
  var SWEEP_INTERVAL_MS3 = 24 * 60 * 60 * 1e3;
8196
8455
  var lastSweepAt3 = 0;
8197
8456
  function skillHash(content) {
8198
- return createHash11("sha256").update(content, "utf8").digest("hex");
8457
+ return createHash12("sha256").update(content, "utf8").digest("hex");
8199
8458
  }
8200
8459
  function cachePath3(cacheDir, hash) {
8201
- return join30(cacheDir, hash);
8460
+ return join31(cacheDir, hash);
8202
8461
  }
8203
8462
  function readCachedSkill(cacheDir, hash) {
8204
8463
  const path = cachePath3(cacheDir, hash);
8205
8464
  try {
8206
- const content = readFileSync23(path, "utf-8");
8465
+ const content = readFileSync24(path, "utf-8");
8207
8466
  try {
8208
8467
  const now = /* @__PURE__ */ new Date();
8209
8468
  utimesSync3(path, now, now);
@@ -8217,7 +8476,7 @@ function readCachedSkill(cacheDir, hash) {
8217
8476
  function writeCachedSkill(cacheDir, hash, content) {
8218
8477
  if (skillHash(content) !== hash) return "mismatch";
8219
8478
  try {
8220
- mkdirSync10(cacheDir, { recursive: true });
8479
+ mkdirSync11(cacheDir, { recursive: true });
8221
8480
  const tmp = `${cachePath3(cacheDir, hash)}.tmp-${process.pid}`;
8222
8481
  writeFileSync11(tmp, content, "utf-8");
8223
8482
  renameSync7(tmp, cachePath3(cacheDir, hash));
@@ -8232,7 +8491,7 @@ function sweepSkillCache(cacheDir, now = Date.now()) {
8232
8491
  try {
8233
8492
  if (!existsSync10(cacheDir)) return;
8234
8493
  for (const name of readdirSync9(cacheDir)) {
8235
- const path = join30(cacheDir, name);
8494
+ const path = join31(cacheDir, name);
8236
8495
  try {
8237
8496
  if (now - statSync10(path).mtimeMs > CACHE_TTL_MS3) rmSync6(path, { force: true });
8238
8497
  } catch {
@@ -8561,18 +8820,18 @@ function resolveConditionalResponse(wire, hasCachedBody) {
8561
8820
  }
8562
8821
 
8563
8822
  // src/lib/channel-hash-cache.ts
8564
- import { existsSync as existsSync11, readFileSync as readFileSync24, writeFileSync as writeFileSync12 } from "fs";
8565
- 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";
8566
8825
  var CACHE_FILENAME = "channel-hash-cache.json";
8567
8826
  function getChannelHashCacheFile(configDir) {
8568
- return join31(configDir, CACHE_FILENAME);
8827
+ return join32(configDir, CACHE_FILENAME);
8569
8828
  }
8570
8829
  function loadChannelHashCache(target, configDir) {
8571
8830
  const path = getChannelHashCacheFile(configDir);
8572
8831
  if (!existsSync11(path)) return;
8573
8832
  let parsed;
8574
8833
  try {
8575
- parsed = JSON.parse(readFileSync24(path, "utf-8"));
8834
+ parsed = JSON.parse(readFileSync25(path, "utf-8"));
8576
8835
  } catch {
8577
8836
  return;
8578
8837
  }
@@ -8592,8 +8851,8 @@ function saveChannelHashCache(source, configDir) {
8592
8851
  }
8593
8852
 
8594
8853
  // src/lib/sender-policy-baseline.ts
8595
- import { existsSync as existsSync12, readFileSync as readFileSync25 } from "fs";
8596
- import { join as join32 } from "path";
8854
+ import { existsSync as existsSync12, readFileSync as readFileSync26 } from "fs";
8855
+ import { join as join33 } from "path";
8597
8856
  var BASELINE_FILENAME = "sender-policy-baseline.json";
8598
8857
  var SENDER_POLICY_BASELINE_VERSION = 1;
8599
8858
  var BASELINE_CONCERNS = [
@@ -8649,14 +8908,14 @@ function createDeliveryBaselineMaps() {
8649
8908
  };
8650
8909
  }
8651
8910
  function getSenderPolicyBaselineFile(configDir) {
8652
- return join32(configDir, BASELINE_FILENAME);
8911
+ return join33(configDir, BASELINE_FILENAME);
8653
8912
  }
8654
8913
  function loadSenderPolicyBaseline(target, configDir, log2) {
8655
8914
  const path = getSenderPolicyBaselineFile(configDir);
8656
8915
  if (!existsSync12(path)) return;
8657
8916
  let parsed;
8658
8917
  try {
8659
- parsed = JSON.parse(readFileSync25(path, "utf-8"));
8918
+ parsed = JSON.parse(readFileSync26(path, "utf-8"));
8660
8919
  } catch (err) {
8661
8920
  log2?.(
8662
8921
  `[sender-policy] discarding corrupt ${BASELINE_FILENAME} (${err.message}) - restrictive-policy agents will take one fail-closed restart`
@@ -8735,8 +8994,8 @@ function resolveIntegrationEgressDomains(fetched, persisted) {
8735
8994
  }
8736
8995
 
8737
8996
  // src/lib/stuck-streak-store.ts
8738
- import { existsSync as existsSync13, readFileSync as readFileSync26 } from "fs";
8739
- import { join as join33 } from "path";
8997
+ import { existsSync as existsSync13, readFileSync as readFileSync27 } from "fs";
8998
+ import { join as join34 } from "path";
8740
8999
  var STORE_FILENAME = "stuck-streaks.json";
8741
9000
  var STUCK_STREAK_STORE_VERSION = 1;
8742
9001
  var STUCK_STREAK_CONCERNS = ["channelSync", "realtimeRebind"];
@@ -8744,7 +9003,7 @@ function createStuckStreakMaps() {
8744
9003
  return { channelSync: /* @__PURE__ */ new Map(), realtimeRebind: /* @__PURE__ */ new Map() };
8745
9004
  }
8746
9005
  function getStuckStreakStoreFile(configDir) {
8747
- return join33(configDir, STORE_FILENAME);
9006
+ return join34(configDir, STORE_FILENAME);
8748
9007
  }
8749
9008
  function isValidPersistedStreak(value) {
8750
9009
  if (!value || typeof value !== "object" || Array.isArray(value)) return false;
@@ -8786,7 +9045,7 @@ function loadStuckStreaks(target, configDir, log2) {
8786
9045
  if (!existsSync13(path)) return;
8787
9046
  let parsed;
8788
9047
  try {
8789
- parsed = JSON.parse(readFileSync26(path, "utf-8"));
9048
+ parsed = JSON.parse(readFileSync27(path, "utf-8"));
8790
9049
  } catch (err) {
8791
9050
  log2?.(
8792
9051
  `[stuck-streaks] discarding corrupt ${STORE_FILENAME} (${err.message}) \u2014 stuck-streak ages restart from zero and one spurious "recovered" close may follow`
@@ -8829,7 +9088,7 @@ function pruneStuckStreaksToAgents(maps, activeAgentIds) {
8829
9088
  }
8830
9089
 
8831
9090
  // src/lib/claude-device-state.ts
8832
- import { readFileSync as readFileSync27, statSync as statSync11 } from "fs";
9091
+ import { readFileSync as readFileSync28, statSync as statSync11 } from "fs";
8833
9092
  function claudeDeviceStatePath(env = process.env) {
8834
9093
  return effectiveClaudeJsonPath(void 0, env);
8835
9094
  }
@@ -8854,7 +9113,7 @@ function checkClaudeDeviceState(path = claudeDeviceStatePath()) {
8854
9113
  }
8855
9114
  let raw;
8856
9115
  try {
8857
- raw = readFileSync27(path, "utf-8");
9116
+ raw = readFileSync28(path, "utf-8");
8858
9117
  } catch {
8859
9118
  return { usable: false, reason: "unreadable" };
8860
9119
  }
@@ -9128,7 +9387,7 @@ function resolveLiveAnchorPids(agentCodeNames) {
9128
9387
  for (const codeName of agentCodeNames) {
9129
9388
  const pids = /* @__PURE__ */ new Set();
9130
9389
  try {
9131
- const out = execFileSync2("tmux", ["list-panes", "-t", `agt-${codeName}`, "-F", "#{pane_pid}"], {
9390
+ const out = execFileSync2("tmux", ["list-panes", "-t", tmuxPaneTarget(`agt-${codeName}`), "-F", "#{pane_pid}"], {
9132
9391
  encoding: "utf-8",
9133
9392
  timeout: 2e3,
9134
9393
  stdio: ["ignore", "pipe", "ignore"]
@@ -9546,7 +9805,7 @@ function planGlobalSkillSync(globalSkills, prevIds, hashOf, knownHash, options)
9546
9805
  }
9547
9806
 
9548
9807
  // src/lib/manager/integration-skill-cache.ts
9549
- import { join as join34 } from "path";
9808
+ import { join as join35 } from "path";
9550
9809
  function integrationSkillHashKey(agentId, skillId) {
9551
9810
  return `plugin-skill:${agentId}:${skillId}`;
9552
9811
  }
@@ -9562,21 +9821,21 @@ function forgetIntegrationSkill(cache3, agentId, skillId) {
9562
9821
  function removeIntegrationSkillFolder(opts) {
9563
9822
  forgetIntegrationSkill(opts.cache, opts.agentId, opts.entry);
9564
9823
  for (const dir of opts.dirs) {
9565
- opts.removeDir(join34(dir, opts.entry));
9824
+ opts.removeDir(join35(dir, opts.entry));
9566
9825
  }
9567
9826
  }
9568
9827
 
9569
9828
  // src/lib/manager/managed-skill-manifest.ts
9570
- import { existsSync as existsSync14, mkdirSync as mkdirSync11, readFileSync as readFileSync28, writeFileSync as writeFileSync13 } from "fs";
9571
- 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";
9572
9831
  var MANIFEST_VERSION = 1;
9573
9832
  function managedSkillManifestPath(agentRootDir) {
9574
- return join35(agentRootDir, "managed-skills.json");
9833
+ return join36(agentRootDir, "managed-skills.json");
9575
9834
  }
9576
9835
  function readManagedSkillManifest(path) {
9577
9836
  try {
9578
9837
  if (!existsSync14(path)) return /* @__PURE__ */ new Set();
9579
- const parsed = JSON.parse(readFileSync28(path, "utf-8"));
9838
+ const parsed = JSON.parse(readFileSync29(path, "utf-8"));
9580
9839
  const ids = Array.isArray(parsed?.globalSkillIds) ? parsed.globalSkillIds : [];
9581
9840
  return new Set(ids.filter((id) => typeof id === "string" && id.length > 0));
9582
9841
  } catch {
@@ -9585,7 +9844,7 @@ function readManagedSkillManifest(path) {
9585
9844
  }
9586
9845
  function writeManagedSkillManifest(path, ids) {
9587
9846
  try {
9588
- mkdirSync11(dirname8(path), { recursive: true });
9847
+ mkdirSync12(dirname8(path), { recursive: true });
9589
9848
  const body = {
9590
9849
  version: MANIFEST_VERSION,
9591
9850
  globalSkillIds: [...ids].sort()
@@ -9725,8 +9984,8 @@ function resolveModelChain(refreshData) {
9725
9984
  }
9726
9985
 
9727
9986
  // src/lib/manager/claude-auth.ts
9728
- import { chmodSync as chmodSync2, existsSync as existsSync15, lstatSync as lstatSync3, mkdirSync as mkdirSync12, rmSync as rmSync7 } from "fs";
9729
- 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";
9730
9989
  import { homedir as homedir13 } from "os";
9731
9990
  async function applyClaudeAuthToEnv(childEnv, label, options = {}) {
9732
9991
  const apiKey = getApiKey();
@@ -9745,7 +10004,7 @@ async function applyClaudeAuthToEnv(childEnv, label, options = {}) {
9745
10004
  }
9746
10005
  const claudeDir = claudeConfigDirForChild(childEnv);
9747
10006
  for (const filename of [".credentials.json", "credentials.json"]) {
9748
- const p = join36(claudeDir, filename);
10007
+ const p = join37(claudeDir, filename);
9749
10008
  if (existsSync15(p)) {
9750
10009
  try {
9751
10010
  rmSync7(p, { force: true });
@@ -9760,23 +10019,23 @@ async function applyClaudeAuthToEnv(childEnv, label, options = {}) {
9760
10019
  return { isolated: false };
9761
10020
  }
9762
10021
  function claudeConfigDirForChild(childEnv) {
9763
- return childEnv.CLAUDE_CONFIG_DIR?.trim() || join36(homedir13(), ".claude");
10022
+ return childEnv.CLAUDE_CONFIG_DIR?.trim() || join37(homedir13(), ".claude");
9764
10023
  }
9765
10024
  function ensurePrivateConfigDir(dir, platform4 = process.platform, chmod = chmodSync2) {
9766
- mkdirSync12(dir, { recursive: true, mode: 448 });
9767
- const st = lstatSync3(dir);
10025
+ mkdirSync13(dir, { recursive: true, mode: 448 });
10026
+ const st = lstatSync4(dir);
9768
10027
  if (!st.isDirectory()) {
9769
10028
  throw new Error(`isolated Claude config dir ${dir} is not a real directory (symlink or file); refusing`);
9770
10029
  }
9771
10030
  if (platform4 === "win32") return;
9772
10031
  if ((st.mode & 511) !== 448) chmod(dir, 448);
9773
- const mode = lstatSync3(dir).mode & 511;
10032
+ const mode = lstatSync4(dir).mode & 511;
9774
10033
  if (mode !== 448) {
9775
10034
  throw new Error(`isolated Claude config dir ${dir} could not be made private (mode ${mode.toString(8)}); refusing`);
9776
10035
  }
9777
10036
  }
9778
10037
  function oneShotIsolatedConfigDir() {
9779
- return join36(homedir13(), ".augmented", "claude-oneshot");
10038
+ return join37(homedir13(), ".augmented", "claude-oneshot");
9780
10039
  }
9781
10040
 
9782
10041
  // src/lib/claude-runtime-auth-probe.ts
@@ -10121,19 +10380,19 @@ function formatBoardForPrompt(items, template) {
10121
10380
  }
10122
10381
 
10123
10382
  // src/lib/manager/kanban/nudge-state-cache.ts
10124
- import { existsSync as existsSync16, readFileSync as readFileSync29, writeFileSync as writeFileSync14 } from "fs";
10125
- 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";
10126
10385
  var CACHE_FILENAME2 = "kanban-nudge-state.json";
10127
10386
  var KANBAN_NUDGE_STATE_VERSION = 1;
10128
10387
  function getKanbanNudgeStateFile(configDir) {
10129
- return join37(configDir, CACHE_FILENAME2);
10388
+ return join38(configDir, CACHE_FILENAME2);
10130
10389
  }
10131
10390
  function loadKanbanNudgeState(target, configDir) {
10132
10391
  const path = getKanbanNudgeStateFile(configDir);
10133
10392
  if (!existsSync16(path)) return;
10134
10393
  let parsed;
10135
10394
  try {
10136
- parsed = JSON.parse(readFileSync29(path, "utf-8"));
10395
+ parsed = JSON.parse(readFileSync30(path, "utf-8"));
10137
10396
  } catch {
10138
10397
  return;
10139
10398
  }
@@ -10171,7 +10430,7 @@ function saveKanbanNudgeState(source, configDir) {
10171
10430
  }
10172
10431
 
10173
10432
  // src/lib/manager/kanban/notify.ts
10174
- import { createHash as createHash12 } from "crypto";
10433
+ import { createHash as createHash13 } from "crypto";
10175
10434
  async function enqueueKanbanNotice(opts) {
10176
10435
  try {
10177
10436
  const res = await api.post(
@@ -10186,7 +10445,7 @@ async function enqueueKanbanNotice(opts) {
10186
10445
  return res.ok === true;
10187
10446
  } catch (err) {
10188
10447
  const errText = err instanceof Error ? err.message : String(err);
10189
- const errId = createHash12("sha256").update(errText).digest("hex").slice(0, 12);
10448
+ const errId = createHash13("sha256").update(errText).digest("hex").slice(0, 12);
10190
10449
  log(`[kanban] notice enqueue failed for agent_id=${opts.agentId} error_id=${errId}`);
10191
10450
  return false;
10192
10451
  }
@@ -10201,7 +10460,7 @@ async function cancelKanbanNotice(agentId) {
10201
10460
  return typeof res.cancelled === "number" ? res.cancelled : 0;
10202
10461
  } catch (err) {
10203
10462
  const errText = err instanceof Error ? err.message : String(err);
10204
- const errId = createHash12("sha256").update(errText).digest("hex").slice(0, 12);
10463
+ const errId = createHash13("sha256").update(errText).digest("hex").slice(0, 12);
10205
10464
  log(`[kanban] notice cancel failed for agent_id=${agentId} error_id=${errId}`);
10206
10465
  return null;
10207
10466
  }
@@ -10698,7 +10957,7 @@ function deriveScheduledTaskNotify(task) {
10698
10957
  }
10699
10958
 
10700
10959
  // src/lib/manager/scheduler/runs.ts
10701
- import { createHash as createHash13 } from "crypto";
10960
+ import { createHash as createHash14 } from "crypto";
10702
10961
  async function startRun(opts) {
10703
10962
  try {
10704
10963
  const res = await api.post(
@@ -10713,7 +10972,7 @@ async function startRun(opts) {
10713
10972
  };
10714
10973
  } catch (err) {
10715
10974
  const errText = err instanceof Error ? err.message : String(err);
10716
- const errId = createHash13("sha256").update(errText).digest("hex").slice(0, 12);
10975
+ const errId = createHash14("sha256").update(errText).digest("hex").slice(0, 12);
10717
10976
  log(`[runs] start failed for agent_id=${opts.agent_id} source_type=${opts.source_type} error_id=${errId}`);
10718
10977
  return { run_id: null, kanban_item_id: null };
10719
10978
  }
@@ -10752,7 +11011,7 @@ async function finishRun(runId, outcome, options = {}) {
10752
11011
  return;
10753
11012
  } catch (err) {
10754
11013
  const errText = err instanceof Error ? err.message : String(err);
10755
- const errId = createHash13("sha256").update(errText).digest("hex").slice(0, 12);
11014
+ const errId = createHash14("sha256").update(errText).digest("hex").slice(0, 12);
10756
11015
  const status = err instanceof ApiError ? err.status : 0;
10757
11016
  if (isRetryableFinishError(err) && attempt < maxRetries) {
10758
11017
  log(
@@ -10781,7 +11040,7 @@ async function fetchPriorScheduledRuns(agentId, taskId) {
10781
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 }));
10782
11041
  } catch (err) {
10783
11042
  const errText = err instanceof Error ? err.message : String(err);
10784
- const errId = createHash13("sha256").update(errText).digest("hex").slice(0, 12);
11043
+ const errId = createHash14("sha256").update(errText).digest("hex").slice(0, 12);
10785
11044
  log(`[runs] prior-runs lookup failed for task_id=${taskId} error_id=${errId}`);
10786
11045
  return [];
10787
11046
  }
@@ -10842,13 +11101,13 @@ function closeSessionRunForCode(codeName, outcome, reason) {
10842
11101
  }
10843
11102
 
10844
11103
  // src/lib/manager/scheduler/kanban-route.ts
10845
- import { createHash as createHash15 } from "crypto";
10846
- 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";
10847
11106
  import { homedir as homedir14 } from "os";
10848
- import { join as join38, dirname as dirname9 } from "path";
11107
+ import { join as join39, dirname as dirname9 } from "path";
10849
11108
 
10850
11109
  // src/lib/manager/scheduler/notify.ts
10851
- import { createHash as createHash14 } from "crypto";
11110
+ import { createHash as createHash15 } from "crypto";
10852
11111
  async function enqueueScheduledTaskNotice(opts) {
10853
11112
  try {
10854
11113
  const res = await api.post(
@@ -10865,7 +11124,7 @@ async function enqueueScheduledTaskNotice(opts) {
10865
11124
  return res.ok === true;
10866
11125
  } catch (err) {
10867
11126
  const errText = err instanceof Error ? err.message : String(err);
10868
- const errId = createHash14("sha256").update(errText).digest("hex").slice(0, 12);
11127
+ const errId = createHash15("sha256").update(errText).digest("hex").slice(0, 12);
10869
11128
  log(
10870
11129
  `[scheduled-kanban] notice enqueue failed for agent_id=${opts.agentId} task_id=${opts.taskId} error_id=${errId}`
10871
11130
  );
@@ -11208,7 +11467,7 @@ function resolveScheduledSlackTarget(task) {
11208
11467
  }
11209
11468
  function stampScheduledTurnMarker(codeName, taskId, target) {
11210
11469
  try {
11211
- const file = join38(homedir14(), ".augmented", codeName, SCHEDULED_TURN_MARKER_FILENAME);
11470
+ const file = join39(homedir14(), ".augmented", codeName, SCHEDULED_TURN_MARKER_FILENAME);
11212
11471
  const marker = { ts: Date.now(), task_id: taskId, ...target ? { target } : {} };
11213
11472
  const tmp = `${file}.tmp`;
11214
11473
  writeFileSync15(tmp, JSON.stringify(marker), "utf8");
@@ -11218,9 +11477,9 @@ function stampScheduledTurnMarker(codeName, taskId, target) {
11218
11477
  }
11219
11478
  }
11220
11479
  function clearScheduledTurnMarkerForTask(codeName, taskId) {
11221
- const file = join38(homedir14(), ".augmented", codeName, SCHEDULED_TURN_MARKER_FILENAME);
11480
+ const file = join39(homedir14(), ".augmented", codeName, SCHEDULED_TURN_MARKER_FILENAME);
11222
11481
  try {
11223
- const raw = JSON.parse(readFileSync30(file, "utf8"));
11482
+ const raw = JSON.parse(readFileSync31(file, "utf8"));
11224
11483
  if (typeof raw?.task_id !== "string" || raw.task_id !== taskId) return;
11225
11484
  unlinkSync3(file);
11226
11485
  log(`[scheduled-kanban] scheduled-turn marker cleared for '${codeName}' (task ${taskId} complete)`);
@@ -11287,7 +11546,7 @@ async function routeScheduledTaskViaKanban(codeName, agentId, task, prompt, dura
11287
11546
  if (!enqueued) return false;
11288
11547
  try {
11289
11548
  const doorbell = directChatDoorbellPath(agentId, homedir14());
11290
- mkdirSync13(dirname9(doorbell), { recursive: true });
11549
+ mkdirSync14(dirname9(doorbell), { recursive: true });
11291
11550
  writeFileSync15(doorbell, String(Date.now()));
11292
11551
  } catch (err) {
11293
11552
  log(`[scheduled-kanban] doorbell ring failed for '${codeName}': ${err.message} (notice still queued)`);
@@ -11378,24 +11637,24 @@ async function processClaudeTaskResult(codeName, agentId, templateId, rawOutput,
11378
11637
  const assertion = parseDeliverAssertion(rawOutput);
11379
11638
  if (!assertion.deliver) {
11380
11639
  const trimmed = (rawOutput ?? "").trim();
11381
- 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);
11382
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}`);
11383
11642
  if (delivery?.mode === "announce" && delivery.to) {
11384
11643
  await reportDeliveryStatus(agentId, delivery.taskId, { status: "skipped", error_code: "SUPPRESSED_BY_POLICY" });
11385
11644
  }
11386
11645
  return { ok: true };
11387
11646
  }
11388
- 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);
11389
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})`);
11390
11649
  rawOutput = assertion.deliverable;
11391
11650
  }
11392
11651
  const classification = classifyOutput(rawOutput);
11393
11652
  if (classification.action === "suppress") {
11394
11653
  const trimmed = (rawOutput ?? "").trim();
11395
- 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);
11396
11655
  log(`[claude-scheduler] Suppressing delivery for '${codeName}' (template=${templateId}, task=${delivery?.taskId ?? "n/a"}) \u2014 output_len=${trimmed.length} output_hash=${outputHash}`);
11397
11656
  if (classification.suppressedNotes) {
11398
- 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);
11399
11658
  log(`[claude-scheduler] Suppressed notes for '${codeName}' (task=${delivery?.taskId ?? "n/a"}) \u2014 notes_len=${classification.suppressedNotes.length} notes_hash=${notesHash}`);
11400
11659
  }
11401
11660
  if (delivery?.mode === "announce" && delivery.to) {
@@ -11467,13 +11726,13 @@ async function processClaudeTaskResult(codeName, agentId, templateId, rawOutput,
11467
11726
  }
11468
11727
 
11469
11728
  // src/lib/manager/scheduler/execution.ts
11470
- import { createHash as createHash16 } from "crypto";
11729
+ import { createHash as createHash17 } from "crypto";
11471
11730
  import { homedir as homedir15 } from "os";
11472
- import { join as join40 } from "path";
11731
+ import { join as join41 } from "path";
11473
11732
 
11474
11733
  // src/lib/agent-serving-probe.ts
11475
- import { readFileSync as readFileSync31, readdirSync as readdirSync10, statSync as statSync12 } from "fs";
11476
- 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";
11477
11736
  var RATE_LIMIT_WINDOW_MS = 6 * 60 * 60 * 1e3;
11478
11737
  function probeRateLimit(args) {
11479
11738
  const now = args.now ?? /* @__PURE__ */ new Date();
@@ -11489,7 +11748,7 @@ function probeRateLimit(args) {
11489
11748
  let newest = UNKNOWN_RATE_LIMIT;
11490
11749
  for (const name of entries) {
11491
11750
  if (!name.endsWith(".jsonl")) continue;
11492
- const path = join39(dir, name);
11751
+ const path = join40(dir, name);
11493
11752
  try {
11494
11753
  const st = statSync12(path);
11495
11754
  if (!st.isFile() || st.mtimeMs < startMs) continue;
@@ -11498,7 +11757,7 @@ function probeRateLimit(args) {
11498
11757
  }
11499
11758
  let content;
11500
11759
  try {
11501
- content = readFileSync31(path, "utf-8");
11760
+ content = readFileSync32(path, "utf-8");
11502
11761
  } catch {
11503
11762
  continue;
11504
11763
  }
@@ -11560,7 +11819,7 @@ function shouldLogUsageCapDeferral(site, codeName, limitedUntil) {
11560
11819
 
11561
11820
  // src/lib/manager/scheduler/execution.ts
11562
11821
  function claudePidFilePath() {
11563
- return join40(homedir15(), ".augmented", "manager-claude-pids.json");
11822
+ return join41(homedir15(), ".augmented", "manager-claude-pids.json");
11564
11823
  }
11565
11824
  var inFlightClaudePids = /* @__PURE__ */ new Map();
11566
11825
  function registerClaudeSpawn(record) {
@@ -11580,10 +11839,10 @@ function unregisterClaudeSpawn(pid) {
11580
11839
  }
11581
11840
  async function syncAndCheckClaudeScheduler(agent, tasks, boardItems, refreshData, durableScheduledNudge = false) {
11582
11841
  const codeName = agent.code_name;
11583
- const stableTasksHash = createHash16("sha256").update(JSON.stringify(tasks)).digest("hex").slice(0, 16);
11584
- 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";
11585
11844
  const resolvedModels = resolveModelChain(refreshData);
11586
- 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);
11587
11846
  const combinedHash = `${stableTasksHash}:${boardHash}:${modelsHash}`;
11588
11847
  const prevHash = agentState.knownTasksHashes.get(agent.agent_id);
11589
11848
  if (combinedHash !== prevHash) {
@@ -11852,8 +12111,8 @@ function respawnedByAnotherCaller(decision, healthyAfter, sessionStartedAt, lane
11852
12111
  }
11853
12112
 
11854
12113
  // src/lib/occupancy-gate.ts
11855
- import { closeSync as closeSync4, openSync as openSync4, readdirSync as readdirSync11, readSync as readSync4, statSync as statSync13 } from "fs";
11856
- 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";
11857
12116
  function rostersMeasuredZero(mode, attested, runtimeRunning) {
11858
12117
  return mode === "enforce" && attested && runtimeRunning;
11859
12118
  }
@@ -11869,7 +12128,7 @@ function readAlignedTail(path, tailBytes, maxAlignBytes) {
11869
12128
  try {
11870
12129
  const size = statSync13(path).size;
11871
12130
  if (size <= 0) return { content: "", complete: true, truncated: false };
11872
- fd = openSync4(path, "r");
12131
+ fd = openSync5(path, "r");
11873
12132
  let readStart = Math.max(0, size - tailBytes);
11874
12133
  if (readStart > 0) {
11875
12134
  const scanFloor = Math.max(0, readStart - maxAlignBytes);
@@ -11905,7 +12164,7 @@ function readAlignedTail(path, tailBytes, maxAlignBytes) {
11905
12164
  } finally {
11906
12165
  if (fd != null) {
11907
12166
  try {
11908
- closeSync4(fd);
12167
+ closeSync5(fd);
11909
12168
  } catch {
11910
12169
  }
11911
12170
  }
@@ -11944,10 +12203,10 @@ function candidateTranscriptPaths(dir) {
11944
12203
  let complete = true;
11945
12204
  for (const name of top) {
11946
12205
  if (name.endsWith(".jsonl")) {
11947
- paths.push(join41(dir, name));
12206
+ paths.push(join42(dir, name));
11948
12207
  continue;
11949
12208
  }
11950
- const subDir = join41(dir, name, "subagents");
12209
+ const subDir = join42(dir, name, "subagents");
11951
12210
  let subs;
11952
12211
  try {
11953
12212
  subs = readdirSync11(subDir);
@@ -11956,7 +12215,7 @@ function candidateTranscriptPaths(dir) {
11956
12215
  continue;
11957
12216
  }
11958
12217
  for (const sub of subs) {
11959
- if (sub.endsWith(".jsonl")) paths.push(join41(subDir, sub));
12218
+ if (sub.endsWith(".jsonl")) paths.push(join42(subDir, sub));
11960
12219
  }
11961
12220
  }
11962
12221
  return { paths, complete };
@@ -12182,7 +12441,7 @@ function stopPaneOccupancySampler() {
12182
12441
  }
12183
12442
 
12184
12443
  // src/lib/pid-pressure-sampler.ts
12185
- import { existsSync as existsSync17, readFileSync as readFileSync32 } from "fs";
12444
+ import { existsSync as existsSync17, readFileSync as readFileSync33 } from "fs";
12186
12445
  var SAMPLE_INTERVAL_MS2 = 3e4;
12187
12446
  function warnFraction() {
12188
12447
  const raw = Number(process.env.AGT_PID_PRESSURE_WARN_FRACTION);
@@ -12210,7 +12469,7 @@ function parseMemoryEvents(text) {
12210
12469
  }
12211
12470
  function readTextReal(path) {
12212
12471
  try {
12213
- return readFileSync32(path, "utf-8");
12472
+ return readFileSync33(path, "utf-8");
12214
12473
  } catch {
12215
12474
  return null;
12216
12475
  }
@@ -12450,7 +12709,7 @@ function stopRuntimeVersionSampler() {
12450
12709
  }
12451
12710
 
12452
12711
  // src/lib/opencode-slack-ingest.ts
12453
- import { createHash as createHash17 } from "crypto";
12712
+ import { createHash as createHash18 } from "crypto";
12454
12713
 
12455
12714
  // ../../packages/core/dist/channels/slack-rich-text.js
12456
12715
  var MAX_DEPTH = 12;
@@ -13418,7 +13677,7 @@ function startSlackIngest(config2) {
13418
13677
  // src/lib/opencode-slack-ingest.ts
13419
13678
  var ingests = /* @__PURE__ */ new Map();
13420
13679
  function fingerprint(params) {
13421
- return createHash17("sha256").update(
13680
+ return createHash18("sha256").update(
13422
13681
  JSON.stringify({
13423
13682
  appToken: params.appToken,
13424
13683
  botToken: params.botToken,
@@ -13499,7 +13758,7 @@ function stopAllOpencodeSlackIngests(log2) {
13499
13758
  }
13500
13759
 
13501
13760
  // src/lib/manager/opencode-scheduler.ts
13502
- import { createHash as createHash18 } from "crypto";
13761
+ import { createHash as createHash19 } from "crypto";
13503
13762
  var MAX_OPENCODE_SCHED_CONCURRENCY = 2;
13504
13763
  var opencodeSchedulerStates = /* @__PURE__ */ new Map();
13505
13764
  var inFlightOpencodeTasks = /* @__PURE__ */ new Set();
@@ -13513,7 +13772,7 @@ function shouldDeliver(task, reply) {
13513
13772
  }
13514
13773
  async function syncAndCheckOpencodeScheduler(agent, tasks, refreshData) {
13515
13774
  const codeName = agent.code_name;
13516
- 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);
13517
13776
  if (knownOpencodeTaskHashes.get(agent.agent_id) !== tasksHash) {
13518
13777
  const taskInputs = tasks.map((t) => buildSchedulerTaskInput(t));
13519
13778
  const state11 = syncTasksToScheduler(codeName, agent.agent_id, taskInputs);
@@ -13591,10 +13850,10 @@ async function fireOpencodeScheduledTask(agent, task) {
13591
13850
  }
13592
13851
 
13593
13852
  // src/lib/opencode-telegram-ingest.ts
13594
- import { createHash as createHash19 } from "crypto";
13595
- 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";
13596
13855
  import { randomUUID } from "crypto";
13597
- import { join as join42 } from "path";
13856
+ import { join as join43 } from "path";
13598
13857
 
13599
13858
  // src/lib/telegram-ingest.ts
13600
13859
  import https2 from "https";
@@ -14275,7 +14534,7 @@ function anySignal(signals) {
14275
14534
  var ingests2 = /* @__PURE__ */ new Map();
14276
14535
  var migrationQueues = /* @__PURE__ */ new Map();
14277
14536
  function fingerprint2(params) {
14278
- return createHash19("sha256").update(
14537
+ return createHash20("sha256").update(
14279
14538
  JSON.stringify({
14280
14539
  botToken: params.botToken,
14281
14540
  allowedChats: [...params.allowedChats].sort(),
@@ -14297,7 +14556,7 @@ function createFileOffsetStore(codeName, log2, currentBotId) {
14297
14556
  let filePath;
14298
14557
  try {
14299
14558
  dir = getFramework("opencode").getAgentDir(codeName);
14300
- filePath = join42(dir, "telegram-getupdates-offset-opencode.json");
14559
+ filePath = join43(dir, "telegram-getupdates-offset-opencode.json");
14301
14560
  } catch {
14302
14561
  dir = null;
14303
14562
  filePath = null;
@@ -14306,7 +14565,7 @@ function createFileOffsetStore(codeName, log2, currentBotId) {
14306
14565
  load() {
14307
14566
  if (!filePath) return 0;
14308
14567
  try {
14309
- const parsed = JSON.parse(readFileSync33(filePath, "utf-8"));
14568
+ const parsed = JSON.parse(readFileSync34(filePath, "utf-8"));
14310
14569
  if (currentBotId != null && typeof parsed?.bot_id === "number" && parsed.bot_id !== currentBotId) {
14311
14570
  log2(`[telegram-ingest:${codeName}] offset cursor belongs to a different bot; ignoring (bot swap)`);
14312
14571
  return 0;
@@ -14324,7 +14583,7 @@ function createFileOffsetStore(codeName, log2, currentBotId) {
14324
14583
  if (!filePath || !dir) return;
14325
14584
  const tmpPath = `${filePath}.${process.pid}.${randomUUID()}.tmp`;
14326
14585
  try {
14327
- mkdirSync14(dir, { recursive: true, mode: 448 });
14586
+ mkdirSync15(dir, { recursive: true, mode: 448 });
14328
14587
  writeFileSync16(
14329
14588
  tmpPath,
14330
14589
  JSON.stringify({
@@ -14351,7 +14610,7 @@ function createFileMigrationReportIO(codeName, log2) {
14351
14610
  let filePath;
14352
14611
  try {
14353
14612
  dir = getFramework("opencode").getAgentDir(codeName);
14354
- filePath = join42(dir, "telegram-migration-reports-opencode.json");
14613
+ filePath = join43(dir, "telegram-migration-reports-opencode.json");
14355
14614
  } catch {
14356
14615
  dir = null;
14357
14616
  filePath = null;
@@ -14360,7 +14619,7 @@ function createFileMigrationReportIO(codeName, log2) {
14360
14619
  load() {
14361
14620
  if (!filePath) return null;
14362
14621
  try {
14363
- return readFileSync33(filePath, "utf-8");
14622
+ return readFileSync34(filePath, "utf-8");
14364
14623
  } catch {
14365
14624
  return null;
14366
14625
  }
@@ -14368,7 +14627,7 @@ function createFileMigrationReportIO(codeName, log2) {
14368
14627
  save(data) {
14369
14628
  if (!filePath || !dir) return;
14370
14629
  try {
14371
- mkdirSync14(dir, { recursive: true, mode: 448 });
14630
+ mkdirSync15(dir, { recursive: true, mode: 448 });
14372
14631
  atomicWriteFileSync(filePath, data, { mode: 384 });
14373
14632
  } catch (err) {
14374
14633
  log2(`[telegram-ingest:${codeName}] migration-report persist failed: ${err instanceof Error ? err.message : String(err)}`);
@@ -14377,7 +14636,7 @@ function createFileMigrationReportIO(codeName, log2) {
14377
14636
  };
14378
14637
  }
14379
14638
  var managerHostPost = async (path, body) => {
14380
- const { api: api2, ApiError: ApiError3 } = await import("../api-client-LPV5RUCO.js");
14639
+ const { api: api2, ApiError: ApiError3 } = await import("../api-client-NGXHG4YA.js");
14381
14640
  try {
14382
14641
  const json = await api2.post(path, body);
14383
14642
  return { status: 200, json };
@@ -14643,15 +14902,15 @@ function partitionActionableByPoison(actionable, states, config2) {
14643
14902
  }
14644
14903
 
14645
14904
  // src/lib/restart-flags.ts
14646
- 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";
14647
14906
  import { homedir as homedir16 } from "os";
14648
- import { join as join43 } from "path";
14907
+ import { join as join44 } from "path";
14649
14908
  import { randomUUID as randomUUID2 } from "crypto";
14650
14909
  function restartFlagsDir() {
14651
- return join43(homedir16(), ".augmented", "restart-flags");
14910
+ return join44(homedir16(), ".augmented", "restart-flags");
14652
14911
  }
14653
14912
  function flagPath(codeName) {
14654
- return join43(restartFlagsDir(), `${codeName}.flag`);
14913
+ return join44(restartFlagsDir(), `${codeName}.flag`);
14655
14914
  }
14656
14915
  function readRestartFlags() {
14657
14916
  const dir = restartFlagsDir();
@@ -14660,7 +14919,7 @@ function readRestartFlags() {
14660
14919
  for (const entry of readdirSync12(dir)) {
14661
14920
  if (!entry.endsWith(".flag")) continue;
14662
14921
  try {
14663
- const raw = readFileSync34(join43(dir, entry), "utf8");
14922
+ const raw = readFileSync35(join44(dir, entry), "utf8");
14664
14923
  const parsed = JSON.parse(raw);
14665
14924
  if (typeof parsed.codeName !== "string" || parsed.codeName.length === 0) {
14666
14925
  parsed.codeName = entry.replace(/\.flag$/, "");
@@ -14778,8 +15037,8 @@ async function sendError(flag, opts, text) {
14778
15037
  }
14779
15038
 
14780
15039
  // src/lib/restart-context.ts
14781
- import { readdirSync as readdirSync13, readFileSync as readFileSync35, writeFileSync as writeFileSync18, mkdirSync as mkdirSync16, unlinkSync as unlinkSync5 } from "fs";
14782
- 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";
14783
15042
  var SLACK_PENDING_INBOUND_DIRNAME = "slack-pending-inbound";
14784
15043
  var SLACK_RESTART_CONTEXT_DIRNAME = "slack-restart-context";
14785
15044
  var MAX_TOPIC_CHARS = 140;
@@ -14791,10 +15050,10 @@ function augmentedAgentDir(codeName) {
14791
15050
  return dirname10(getProjectDir(codeName));
14792
15051
  }
14793
15052
  function slackPendingInboundDir(codeName) {
14794
- return join44(augmentedAgentDir(codeName), SLACK_PENDING_INBOUND_DIRNAME);
15053
+ return join45(augmentedAgentDir(codeName), SLACK_PENDING_INBOUND_DIRNAME);
14795
15054
  }
14796
15055
  function slackRestartContextDir(codeName) {
14797
- return join44(augmentedAgentDir(codeName), SLACK_RESTART_CONTEXT_DIRNAME);
15056
+ return join45(augmentedAgentDir(codeName), SLACK_RESTART_CONTEXT_DIRNAME);
14798
15057
  }
14799
15058
  function sanitizeTopic(raw) {
14800
15059
  const cleaned = raw.replace(/\s+/g, " ").trim().replace(/[<>]/g, " ").replace(/\s+/g, " ").trim();
@@ -14836,7 +15095,7 @@ function safeReaddir(dir) {
14836
15095
  }
14837
15096
  function readStrandedMarker(path) {
14838
15097
  try {
14839
- const parsed = JSON.parse(readFileSync35(path, "utf-8"));
15098
+ const parsed = JSON.parse(readFileSync36(path, "utf-8"));
14840
15099
  if (typeof parsed.channel === "string" && typeof parsed.thread_ts === "string") {
14841
15100
  return { channel: parsed.channel, thread_ts: parsed.thread_ts };
14842
15101
  }
@@ -14845,7 +15104,7 @@ function readStrandedMarker(path) {
14845
15104
  return null;
14846
15105
  }
14847
15106
  function writeHintFile(path, dir, hint) {
14848
- mkdirSync16(dir, { recursive: true, mode: 448 });
15107
+ mkdirSync17(dir, { recursive: true, mode: 448 });
14849
15108
  writeFileSync18(path, JSON.stringify(hint), { mode: 384 });
14850
15109
  }
14851
15110
  function pruneHintsExcept(codeName, freshFilenames) {
@@ -14854,7 +15113,7 @@ function pruneHintsExcept(codeName, freshFilenames) {
14854
15113
  if (!filename.endsWith(".json")) continue;
14855
15114
  if (freshFilenames.has(filename)) continue;
14856
15115
  try {
14857
- unlinkSync5(join44(ctxDir, filename));
15116
+ unlinkSync5(join45(ctxDir, filename));
14858
15117
  } catch {
14859
15118
  }
14860
15119
  }
@@ -14875,7 +15134,7 @@ function refreshSlackRestartContextHints(codeNames, opts = {}) {
14875
15134
  }
14876
15135
  const markers = [];
14877
15136
  for (const filename of markerFilenames.slice(0, cap)) {
14878
- const parsed = readStrandedMarker(join44(markerDir, filename));
15137
+ const parsed = readStrandedMarker(join45(markerDir, filename));
14879
15138
  if (parsed) markers.push({ filename, channel: parsed.channel, thread_ts: parsed.thread_ts });
14880
15139
  }
14881
15140
  if (markers.length === 0) {
@@ -14889,7 +15148,7 @@ function refreshSlackRestartContextHints(codeNames, opts = {}) {
14889
15148
  const freshFilenames = /* @__PURE__ */ new Set();
14890
15149
  for (const { filename, hint } of hints) {
14891
15150
  try {
14892
- writeHintFile(join44(ctxDir, filename), ctxDir, hint);
15151
+ writeHintFile(join45(ctxDir, filename), ctxDir, hint);
14893
15152
  freshFilenames.add(filename);
14894
15153
  } catch (err) {
14895
15154
  log2(`[restart-context] ${codeName}: hint write failed for ${filename}: ${err.message}`);
@@ -15695,7 +15954,7 @@ async function runDangerousRmBackstop(agentId, codeName, pane) {
15695
15954
  return;
15696
15955
  }
15697
15956
  const policy = readRmPolicyText(
15698
- () => 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")
15699
15958
  );
15700
15959
  const decision = decideDangerousRm(action.prompt, policy, {
15701
15960
  isolated: isolationMode(codeName) === "docker"
@@ -16416,7 +16675,7 @@ var pendingDayRolloverReset = /* @__PURE__ */ new Set();
16416
16675
  var dayRolloverInboundHold = /* @__PURE__ */ new Map();
16417
16676
  var INBOUND_HOLD_EPISODE_GAP_MS = 12e4;
16418
16677
  async function channelInboundActivityAgeSecondsFor(codeName) {
16419
- const { newestPendingInboundActivityMtimeMs } = await import("../responsiveness-probe-NV3LXAWL.js");
16678
+ const { newestPendingInboundActivityMtimeMs } = await import("../responsiveness-probe-26TFNDWB.js");
16420
16679
  const newest = newestPendingInboundActivityMtimeMs(dirname11(paneLogPath(codeName)));
16421
16680
  if (newest === null) return null;
16422
16681
  return Math.max(0, Math.floor((Date.now() - newest) / 1e3));
@@ -16783,18 +17042,66 @@ var anchorSessionLifecycle = new AnchorSessionLifecycle();
16783
17042
  var runningMcpServerKeys = /* @__PURE__ */ new Map();
16784
17043
  var runningChannelSecretHashes = /* @__PURE__ */ new Map();
16785
17044
  var sessionLaunchManagedStructure = /* @__PURE__ */ new Map();
16786
- 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) {
16787
17082
  try {
16788
- const raw = readFileSync36(join45(projectDir, ".mcp.json"), "utf-8");
16789
- 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;
16790
17085
  } catch {
16791
17086
  return null;
16792
17087
  }
16793
17088
  }
16794
- 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") {
16795
17096
  try {
16796
- const raw = readFileSync36(join45(projectDir, ".mcp.json"), "utf-8");
16797
- 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);
16798
17105
  const servers = parsed.mcpServers;
16799
17106
  if (!servers || typeof servers !== "object") return /* @__PURE__ */ new Set();
16800
17107
  return new Set(Object.keys(servers));
@@ -16802,16 +17109,18 @@ function projectMcpKeys(_codeName, projectDir) {
16802
17109
  return null;
16803
17110
  }
16804
17111
  }
16805
- function seedSessionLaunchBaselines(codeName, projectDir) {
16806
- const hash = projectMcpHash(codeName, projectDir);
16807
- 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 ?? {}));
16808
17117
  if (hash) runningMcpHashes.set(codeName, hash);
16809
17118
  else runningMcpHashes.delete(codeName);
16810
17119
  if (keys) runningMcpServerKeys.set(codeName, keys);
16811
17120
  else runningMcpServerKeys.delete(codeName);
16812
17121
  let launchStructure = null;
16813
17122
  try {
16814
- const raw = readFileSync36(join45(projectDir, ".mcp.json"), "utf-8");
17123
+ const raw = readFileSync37(join46(projectDir, ".mcp.json"), "utf-8");
16815
17124
  launchStructure = managedMcpStructureHashFromFile(
16816
17125
  JSON.parse(raw),
16817
17126
  isManagedMcpServerKey
@@ -16963,7 +17272,7 @@ async function runAgentSessionToolBindProbes(agent, integrations, projectDir, op
16963
17272
  if (result && result.rebindCandidates.length > 0 && hostFlagStore().getBoolean("session-tool-rebind")) {
16964
17273
  let mcpJsonForRebind = null;
16965
17274
  try {
16966
- mcpJsonForRebind = JSON.parse(readFileSync36(join45(projectDir, ".mcp.json"), "utf-8"));
17275
+ mcpJsonForRebind = JSON.parse(readFileSync37(join46(projectDir, ".mcp.json"), "utf-8"));
16967
17276
  } catch {
16968
17277
  mcpJsonForRebind = null;
16969
17278
  }
@@ -17027,7 +17336,7 @@ var agentRuntimeTeardownDeps = {
17027
17336
  stopClaudePersistentSession: (codeName) => stopPersistentSessionAndForgetMcpBaseline(codeName),
17028
17337
  killTmuxSession: (sessionName) => {
17029
17338
  try {
17030
- syncExecFile("tmux", ["kill-session", "-t", sessionName], { stdio: "ignore" });
17339
+ syncExecFile("tmux", ["kill-session", "-t", tmuxSessionTarget(sessionName)], { stdio: "ignore" });
17031
17340
  return true;
17032
17341
  } catch {
17033
17342
  return false;
@@ -17045,8 +17354,11 @@ function checkMcpConfigDriftAndScheduleRestart(codeName, projectDir) {
17045
17354
  case "no-drift":
17046
17355
  return;
17047
17356
  case "baseline": {
17048
- runningMcpHashes.set(codeName, action.hash);
17049
- 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);
17050
17362
  if (baselineKeys) {
17051
17363
  runningMcpServerKeys.set(codeName, baselineKeys);
17052
17364
  } else {
@@ -17055,6 +17367,18 @@ function checkMcpConfigDriftAndScheduleRestart(codeName, projectDir) {
17055
17367
  return;
17056
17368
  }
17057
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
+ }
17058
17382
  log(
17059
17383
  `[hot-reload] .mcp.json content changed for '${codeName}' (${action.previous.slice(0, 12)} \u2192 ${action.current.slice(0, 12)}) (ENG-4897)`
17060
17384
  );
@@ -17112,7 +17436,7 @@ function shouldInjectChannelSecrets(agentId) {
17112
17436
  function projectChannelSecretHash(projectDir) {
17113
17437
  try {
17114
17438
  const entries = parseEnvIntegrations(
17115
- readFileSync36(join45(projectDir, ".env.integrations"), "utf-8")
17439
+ readFileSync37(join46(projectDir, ".env.integrations"), "utf-8")
17116
17440
  );
17117
17441
  return channelSecretValueHash(entries, CHANNEL_SECRET_ENV_KEYS);
17118
17442
  } catch {
@@ -17232,7 +17556,7 @@ var agentRestartTimezoneInputs = /* @__PURE__ */ new Map();
17232
17556
  var lastVersionCheckAt = 0;
17233
17557
  var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
17234
17558
  var lastResponsivenessProbeAt = 0;
17235
- var agtCliVersion = true ? "0.28.1265" : "dev";
17559
+ var agtCliVersion = true ? "0.28.1267" : "dev";
17236
17560
  function resolveBrewPath(execFileSync4) {
17237
17561
  try {
17238
17562
  const out = execFileSync4("which", ["brew"], { timeout: 5e3 }).toString().trim();
@@ -17792,7 +18116,7 @@ function runAsync(cmd, args, opts) {
17792
18116
  });
17793
18117
  }
17794
18118
  function claudeManagedSettingsPath() {
17795
- return join45(CLAUDE_MANAGED_SETTINGS_DIR, "managed-settings.json");
18119
+ return join46(CLAUDE_MANAGED_SETTINGS_DIR, "managed-settings.json");
17796
18120
  }
17797
18121
  var MANAGED_SETTINGS_KEYS = ["channelsEnabled", "enableAllProjectMcpServers"];
17798
18122
  var MANAGED_SETTINGS_ENV = { DISABLE_AUTOUPDATER: "1" };
@@ -17815,7 +18139,7 @@ function deniedTools(settings) {
17815
18139
  }
17816
18140
  function readCrossSessionBlockStatus(path = claudeManagedSettingsPath()) {
17817
18141
  try {
17818
- const parsed = JSON.parse(readFileSync36(path, "utf-8"));
18142
+ const parsed = JSON.parse(readFileSync37(path, "utf-8"));
17819
18143
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return "missing";
17820
18144
  const settings = parsed;
17821
18145
  const deny = deniedTools(settings);
@@ -17855,7 +18179,7 @@ function ensureClaudeManagedSettings(path = claudeManagedSettingsPath(), write =
17855
18179
  try {
17856
18180
  let settings = {};
17857
18181
  if (existsSync20(path)) {
17858
- const raw = readFileSync36(path, "utf-8").trim();
18182
+ const raw = readFileSync37(path, "utf-8").trim();
17859
18183
  if (raw) {
17860
18184
  let parsed;
17861
18185
  try {
@@ -17896,7 +18220,7 @@ function ensureClaudeManagedSettings(path = claudeManagedSettingsPath(), write =
17896
18220
  const body = `${JSON.stringify(settings, null, 2)}
17897
18221
  `;
17898
18222
  try {
17899
- mkdirSync17(dirname11(path), { recursive: true });
18223
+ mkdirSync18(dirname11(path), { recursive: true });
17900
18224
  write(path, body);
17901
18225
  } catch (err) {
17902
18226
  if (channelKeysNeeded) throw err;
@@ -17948,7 +18272,7 @@ async function ensureOpencodeBinary() {
17948
18272
  try {
17949
18273
  const prefix = execFileSync4("npm", ["prefix", "-g"], { encoding: "utf-8", timeout: 1e4 }).trim();
17950
18274
  if (prefix) {
17951
- const npmBin = join45(prefix, "bin");
18275
+ const npmBin = join46(prefix, "bin");
17952
18276
  const current = (process.env.PATH ?? "").split(pathDelimiter);
17953
18277
  if (!current.includes(npmBin)) {
17954
18278
  process.env.PATH = [npmBin, ...current.filter(Boolean)].join(pathDelimiter);
@@ -18019,7 +18343,7 @@ async function ensureFrameworkBinary(frameworkId) {
18019
18343
  agentRuntimeAuthenticated = await checkClaudeAuth();
18020
18344
  }
18021
18345
  var claudeCodeUpgradeInFlight = false;
18022
- var SCRATCH_HOLDS_DIR = () => join45(homedir17(), ".augmented", ".manager-scratch-holds");
18346
+ var SCRATCH_HOLDS_DIR = () => join46(homedir17(), ".augmented", ".manager-scratch-holds");
18023
18347
  setScratchSweepPolicyResolver(
18024
18348
  (codeName) => resolveScratchSweepPolicy({
18025
18349
  agentId: agentState.codeNameToAgentId.get(codeName),
@@ -18098,7 +18422,7 @@ async function maybeUpgradeClaudeCode() {
18098
18422
  }
18099
18423
  var UPDATE_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
18100
18424
  function selfUpdateAppliedMarkerPath() {
18101
- return join45(homedir17(), ".augmented", ".last-self-update-applied");
18425
+ return join46(homedir17(), ".augmented", ".last-self-update-applied");
18102
18426
  }
18103
18427
  var selfUpdateUpToDateLogged = false;
18104
18428
  var selfUpdatePinnedLogged = false;
@@ -18149,7 +18473,7 @@ async function checkAndUpdateCli(opts) {
18149
18473
  const isNpmGlobal = !isBrewFormula && resolvedPath.includes("node_modules");
18150
18474
  if (!isBrewFormula && !isNpmGlobal) return "noop";
18151
18475
  const { readFileSync: readF, writeFileSync: writeF } = await import("fs");
18152
- const markerPath = join45(homedir17(), ".augmented", ".last-update-check");
18476
+ const markerPath = join46(homedir17(), ".augmented", ".last-update-check");
18153
18477
  if (!force) {
18154
18478
  try {
18155
18479
  const lastCheck = parseInt(readF(markerPath, "utf-8").trim(), 10);
@@ -18653,12 +18977,12 @@ async function checkClaudeAuth() {
18653
18977
  var evalEmptyMcpConfigPath = null;
18654
18978
  function ensureEvalEmptyMcpConfig() {
18655
18979
  if (evalEmptyMcpConfigPath && existsSync20(evalEmptyMcpConfigPath)) return evalEmptyMcpConfigPath;
18656
- const dir = join45(homedir17(), ".augmented");
18980
+ const dir = join46(homedir17(), ".augmented");
18657
18981
  try {
18658
- mkdirSync17(dir, { recursive: true });
18982
+ mkdirSync18(dir, { recursive: true });
18659
18983
  } catch {
18660
18984
  }
18661
- const p = join45(dir, ".eval-empty-mcp.json");
18985
+ const p = join46(dir, ".eval-empty-mcp.json");
18662
18986
  writeFileSync19(p, JSON.stringify({ mcpServers: {} }));
18663
18987
  evalEmptyMcpConfigPath = p;
18664
18988
  return p;
@@ -18749,10 +19073,10 @@ function resolveConversationEvalBackend() {
18749
19073
  return conversationEvalBackend;
18750
19074
  }
18751
19075
  function getStateFile() {
18752
- 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");
18753
19077
  }
18754
19078
  function channelHashCacheDir() {
18755
- return config?.configDir ?? join45(process.env["HOME"] ?? "/tmp", ".augmented");
19079
+ return config?.configDir ?? join46(process.env["HOME"] ?? "/tmp", ".augmented");
18756
19080
  }
18757
19081
  function loadChannelHashCache2() {
18758
19082
  loadChannelHashCache(agentState.knownChannelConfigHashes, channelHashCacheDir());
@@ -18965,7 +19289,7 @@ function removeDeliveryBaselineEntries(agentId) {
18965
19289
  var _channelQuarantineStore = null;
18966
19290
  function channelQuarantineStore() {
18967
19291
  if (!_channelQuarantineStore) {
18968
- const dir = config?.configDir ?? join45(process.env["HOME"] ?? "/tmp", ".augmented");
19292
+ const dir = config?.configDir ?? join46(process.env["HOME"] ?? "/tmp", ".augmented");
18969
19293
  _channelQuarantineStore = new ChannelQuarantineStore(defaultQuarantinePath(dir));
18970
19294
  }
18971
19295
  return _channelQuarantineStore;
@@ -18973,7 +19297,7 @@ function channelQuarantineStore() {
18973
19297
  var _channelResumeHistoryStore = null;
18974
19298
  function channelResumeHistoryStore() {
18975
19299
  if (!_channelResumeHistoryStore) {
18976
- const dir = config?.configDir ?? join45(process.env["HOME"] ?? "/tmp", ".augmented");
19300
+ const dir = config?.configDir ?? join46(process.env["HOME"] ?? "/tmp", ".augmented");
18977
19301
  _channelResumeHistoryStore = new ChannelResumeHistoryStore(defaultResumeHistoryPath(dir));
18978
19302
  }
18979
19303
  return _channelResumeHistoryStore;
@@ -19018,12 +19342,12 @@ function sessionActivityFor(codeName, pane, opts = {}) {
19018
19342
  }
19019
19343
  function forwardedToolsFor(codeName) {
19020
19344
  if (!config?.configDir) return null;
19021
- return readForwardedToolsReport(join45(config.configDir, codeName));
19345
+ return readForwardedToolsReport(join46(config.configDir, codeName));
19022
19346
  }
19023
19347
  var _hostFlagStore = null;
19024
19348
  function hostFlagStore() {
19025
19349
  if (!_hostFlagStore) {
19026
- const dir = config?.configDir ?? join45(process.env["HOME"] ?? "/tmp", ".augmented");
19350
+ const dir = config?.configDir ?? join46(process.env["HOME"] ?? "/tmp", ".augmented");
19027
19351
  _hostFlagStore = new HostFlagStore({ cachePath: defaultFlagsCachePath(dir), log });
19028
19352
  }
19029
19353
  return _hostFlagStore;
@@ -19097,12 +19421,12 @@ function parseSkillFrontmatter(content) {
19097
19421
  }
19098
19422
  async function refreshSkillsIndexInClaudeMd(configDir, codeName, log2) {
19099
19423
  const { readdirSync: readdirSync15, readFileSync: rfs, existsSync: ex, writeFileSync: writeFileSync20 } = await import("fs");
19100
- const skillsDir = join45(configDir, codeName, "project", ".claude", "skills");
19101
- 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");
19102
19426
  if (!ex(skillsDir) || !ex(claudeMdPath)) return;
19103
19427
  const entries = [];
19104
19428
  for (const dir of readdirSync15(skillsDir).sort()) {
19105
- const skillFile = join45(skillsDir, dir, "SKILL.md");
19429
+ const skillFile = join46(skillsDir, dir, "SKILL.md");
19106
19430
  if (!ex(skillFile)) continue;
19107
19431
  try {
19108
19432
  const { name, description } = parseSkillFrontmatter(rfs(skillFile, "utf-8"));
@@ -19241,7 +19565,7 @@ function flushRestartedAgentDiagnostics(hostId, codeNames) {
19241
19565
  if (codeNames.length === 0) return;
19242
19566
  void (async () => {
19243
19567
  try {
19244
- const { collectDiagnostics } = await import("../persistent-session-C7UKT4EE.js");
19568
+ const { collectDiagnostics } = await import("../persistent-session-FMY2FZEL.js");
19245
19569
  await api.post("/host/heartbeat", {
19246
19570
  host_id: hostId,
19247
19571
  agent_diagnostics: collectDiagnostics(codeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
@@ -19384,7 +19708,7 @@ async function pollCycleInner() {
19384
19708
  }
19385
19709
  try {
19386
19710
  const { detectHostSecurity } = await import("../host-security-KQYYZZVW.js");
19387
- const { collectDiagnostics } = await import("../persistent-session-C7UKT4EE.js");
19711
+ const { collectDiagnostics } = await import("../persistent-session-FMY2FZEL.js");
19388
19712
  const diagCodeNames = [...agentState.persistentSessionAgents];
19389
19713
  const agentDiagnostics = diagCodeNames.length > 0 ? collectDiagnostics(diagCodeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor) : void 0;
19390
19714
  let tailscaleHostname;
@@ -19414,7 +19738,7 @@ async function pollCycleInner() {
19414
19738
  claudeAuth = await detectClaudeAuth();
19415
19739
  } catch (err) {
19416
19740
  const errText = err instanceof Error ? err.message : String(err);
19417
- const errId = createHash20("sha256").update(errText).digest("hex").slice(0, 12);
19741
+ const errId = createHash21("sha256").update(errText).digest("hex").slice(0, 12);
19418
19742
  log(`Claude auth detection failed (error_id=${errId})`);
19419
19743
  }
19420
19744
  let claudeAccountEmail = null;
@@ -19690,7 +20014,7 @@ async function pollCycleInner() {
19690
20014
  collectPanelessActivityProbes,
19691
20015
  getResponsivenessIntervalMs,
19692
20016
  occupancyQualificationClassifications
19693
- } = await import("../responsiveness-probe-NV3LXAWL.js");
20017
+ } = await import("../responsiveness-probe-26TFNDWB.js");
19694
20018
  const probeIntervalMs = getResponsivenessIntervalMs();
19695
20019
  if (now - lastResponsivenessProbeAt > probeIntervalMs) {
19696
20020
  const probeCodeNames = [...agentState.persistentSessionAgents];
@@ -19807,7 +20131,7 @@ async function pollCycleInner() {
19807
20131
  collectResponsivenessProbes,
19808
20132
  livePendingInboundOldestAgeSeconds,
19809
20133
  parkPendingInbound
19810
- } = await import("../responsiveness-probe-NV3LXAWL.js");
20134
+ } = await import("../responsiveness-probe-26TFNDWB.js");
19811
20135
  const { getProjectDir: wedgeProjectDir } = await import("../scheduler-engine-5PCBGRNY.js");
19812
20136
  const wedgeNow = /* @__PURE__ */ new Date();
19813
20137
  const liveAgents = agentState.persistentSessionAgents;
@@ -19883,7 +20207,7 @@ async function pollCycleInner() {
19883
20207
  const newId = rotateSessionForWedge(codeName);
19884
20208
  try {
19885
20209
  const { execSync: es } = await import("child_process");
19886
- es(`tmux kill-session -t agt-${codeName} 2>/dev/null`, { stdio: "ignore" });
20210
+ es(`tmux kill-session -t ${tmuxSessionTarget(`agt-${codeName}`)} 2>/dev/null`, { stdio: "ignore" });
19887
20211
  } catch {
19888
20212
  }
19889
20213
  stopPersistentSessionAndForgetMcpBaseline(codeName);
@@ -19896,13 +20220,13 @@ async function pollCycleInner() {
19896
20220
  );
19897
20221
  if (hostFlagStore().getBoolean("wedge-transient-notice")) {
19898
20222
  try {
19899
- const paneTail = readFileSync36(paneLogPath(codeName), "utf8").slice(-65536);
20223
+ const paneTail = readFileSync37(paneLogPath(codeName), "utf8").slice(-65536);
19900
20224
  const transient = detectTransientApiErrorInLog(paneTail);
19901
20225
  if (transient) {
19902
- const wedgeHome = join45(homedir17(), ".augmented", codeName);
20226
+ const wedgeHome = join46(homedir17(), ".augmented", codeName);
19903
20227
  if (existsSync20(wedgeHome)) {
19904
20228
  atomicWriteFileSync(
19905
- join45(wedgeHome, "watchdog-give-up.json"),
20229
+ join46(wedgeHome, "watchdog-give-up.json"),
19906
20230
  JSON.stringify({
19907
20231
  gave_up_at: wedgeNow.toISOString(),
19908
20232
  reason: "transient_overload"
@@ -20000,7 +20324,7 @@ async function pollCycleInner() {
20000
20324
  }
20001
20325
  let pane = null;
20002
20326
  try {
20003
- pane = syncExecFile("tmux", ["capture-pane", "-t", `agt-${codeName}`, "-p", "-J"], {
20327
+ pane = syncExecFile("tmux", ["capture-pane", "-t", tmuxPaneTarget(`agt-${codeName}`), "-p", "-J"], {
20004
20328
  stdio: ["ignore", "pipe", "ignore"],
20005
20329
  timeout: 2e3
20006
20330
  }).toString();
@@ -20074,7 +20398,7 @@ async function pollCycleInner() {
20074
20398
  try {
20075
20399
  const newId = rotateSessionForWedge(codeName);
20076
20400
  try {
20077
- syncExecFile("tmux", ["kill-session", "-t", `agt-${codeName}`], { stdio: "ignore" });
20401
+ syncExecFile("tmux", ["kill-session", "-t", tmuxSessionTarget(`agt-${codeName}`)], { stdio: "ignore" });
20078
20402
  } catch {
20079
20403
  }
20080
20404
  stopPersistentSessionAndForgetMcpBaseline(
@@ -20093,7 +20417,7 @@ async function pollCycleInner() {
20093
20417
  }
20094
20418
  }
20095
20419
  );
20096
- const { parkPendingInbound } = await import("../responsiveness-probe-NV3LXAWL.js");
20420
+ const { parkPendingInbound } = await import("../responsiveness-probe-26TFNDWB.js");
20097
20421
  const { parked, deadLettered } = parkPendingInbound(codeName, new Date(fatalNowMs));
20098
20422
  paneFatalStreak.delete(codeName);
20099
20423
  paneFatalRestarts.set(codeName, [...history, fatalNowMs]);
@@ -20124,7 +20448,7 @@ async function pollCycleInner() {
20124
20448
  TRANSCRIPT_MOUNT_ESCALATION_REFRESH_MS,
20125
20449
  bindSourceEscalations
20126
20450
  } = await import("../transcript-mount-health-OHE6IVJV.js");
20127
- const { transcriptBindSourcesFor, ensureTranscriptBindSources } = await import("../persistent-session-C7UKT4EE.js");
20451
+ const { transcriptBindSourcesFor, ensureTranscriptBindSources } = await import("../persistent-session-FMY2FZEL.js");
20128
20452
  const mountConfig = resolveTranscriptMountConfig();
20129
20453
  const liveAgents = agentState.persistentSessionAgents;
20130
20454
  for (const tracked of [
@@ -20622,7 +20946,7 @@ async function pollCycleInner() {
20622
20946
  let sweptPane = null;
20623
20947
  const observation = observeBlockedPrompt(agent.code_name, true, (codeName) => {
20624
20948
  try {
20625
- sweptPane = syncExecFile("tmux", ["capture-pane", "-t", `agt-${codeName}`, "-p"], {
20949
+ sweptPane = syncExecFile("tmux", ["capture-pane", "-t", tmuxPaneTarget(`agt-${codeName}`), "-p"], {
20626
20950
  stdio: ["ignore", "pipe", "ignore"],
20627
20951
  timeout: 2e3
20628
20952
  }).toString();
@@ -20843,7 +21167,7 @@ async function pollCycleInner() {
20843
21167
  `[drain-flush] FAILED for '${prev.codeName}': ${err.message} \u2014 proceeding to teardown; this session was NOT shipped (ENG-9491)`
20844
21168
  );
20845
21169
  }
20846
- const agentDir = join45(adapter.getAgentDir(prev.codeName), "provision");
21170
+ const agentDir = join46(adapter.getAgentDir(prev.codeName), "provision");
20847
21171
  await cleanupAgentFiles(prev.codeName, agentDir);
20848
21172
  clearAgentCaches(prev.agentId, prev.codeName);
20849
21173
  }
@@ -20866,7 +21190,7 @@ async function pollCycleInner() {
20866
21190
  checkChannelInputs(claudeCodeAgents, {
20867
21191
  capturePane: (codeName) => {
20868
21192
  try {
20869
- return syncExecFile("tmux", ["capture-pane", "-t", `agt-${codeName}`, "-p"], {
21193
+ return syncExecFile("tmux", ["capture-pane", "-t", tmuxPaneTarget(`agt-${codeName}`), "-p"], {
20870
21194
  stdio: ["ignore", "pipe", "ignore"],
20871
21195
  timeout: 2e3
20872
21196
  }).toString();
@@ -20876,7 +21200,7 @@ async function pollCycleInner() {
20876
21200
  },
20877
21201
  isClientAttached: (codeName) => {
20878
21202
  try {
20879
- const out = syncExecFile("tmux", ["list-clients", "-t", `agt-${codeName}`], {
21203
+ const out = syncExecFile("tmux", ["list-clients", "-t", tmuxSessionTarget(`agt-${codeName}`)], {
20880
21204
  stdio: ["ignore", "pipe", "ignore"],
20881
21205
  timeout: 2e3
20882
21206
  }).toString();
@@ -20887,7 +21211,7 @@ async function pollCycleInner() {
20887
21211
  },
20888
21212
  sendEnter: (codeName) => {
20889
21213
  try {
20890
- syncExecFile("tmux", ["send-keys", "-t", `agt-${codeName}`, "Enter"], {
21214
+ syncExecFile("tmux", ["send-keys", "-t", tmuxPaneTarget(`agt-${codeName}`), "Enter"], {
20891
21215
  stdio: "ignore",
20892
21216
  timeout: 2e3
20893
21217
  });
@@ -20906,7 +21230,7 @@ async function pollCycleInner() {
20906
21230
  const view = new Int32Array(new SharedArrayBuffer(4));
20907
21231
  Atomics.wait(view, 0, 0, interKeyDelayMs);
20908
21232
  }
20909
- syncExecFile("tmux", ["send-keys", "-t", `agt-${codeName}`, keys[i]], {
21233
+ syncExecFile("tmux", ["send-keys", "-t", tmuxPaneTarget(`agt-${codeName}`), keys[i]], {
20910
21234
  stdio: "ignore",
20911
21235
  timeout: 2e3
20912
21236
  });
@@ -20922,10 +21246,10 @@ async function pollCycleInner() {
20922
21246
  // pending-inbound marker. Best-effort: a write failure is logged by
20923
21247
  // the watchdog, never fails the poll cycle.
20924
21248
  signalGiveUp: (codeName) => {
20925
- const dir = join45(homedir17(), ".augmented", codeName);
21249
+ const dir = join46(homedir17(), ".augmented", codeName);
20926
21250
  if (!existsSync20(dir)) return;
20927
21251
  atomicWriteFileSync(
20928
- join45(dir, "watchdog-give-up.json"),
21252
+ join46(dir, "watchdog-give-up.json"),
20929
21253
  JSON.stringify({ gave_up_at: (/* @__PURE__ */ new Date()).toISOString() })
20930
21254
  );
20931
21255
  },
@@ -20953,20 +21277,20 @@ async function pollCycleInner() {
20953
21277
  const dir = getFramework("claude-code").getAgentDir(codeName);
20954
21278
  if (!existsSync20(dir)) return;
20955
21279
  atomicWriteFileSync(
20956
- join45(dir, "blocked-prompt.json"),
21280
+ join46(dir, "blocked-prompt.json"),
20957
21281
  JSON.stringify({ kind, last_seen_at: (/* @__PURE__ */ new Date()).toISOString() })
20958
21282
  );
20959
21283
  },
20960
21284
  clearBlockedPromptLiveness: (codeName) => {
20961
- const file = join45(getFramework("claude-code").getAgentDir(codeName), "blocked-prompt.json");
21285
+ const file = join46(getFramework("claude-code").getAgentDir(codeName), "blocked-prompt.json");
20962
21286
  if (existsSync20(file)) rmSync9(file, { force: true });
20963
21287
  },
20964
21288
  refreshUsageLimitLiveness: (codeName) => {
20965
21289
  const dir = getFramework("claude-code").getAgentDir(codeName);
20966
- const file = join45(dir, "watchdog-give-up.json");
21290
+ const file = join46(dir, "watchdog-give-up.json");
20967
21291
  if (!existsSync20(file)) return;
20968
21292
  try {
20969
- const raw = JSON.parse(readFileSync36(file, "utf8"));
21293
+ const raw = JSON.parse(readFileSync37(file, "utf8"));
20970
21294
  if (raw["reason"] !== "usage_limit") return;
20971
21295
  raw["usage_limit_last_seen_at"] = (/* @__PURE__ */ new Date()).toISOString();
20972
21296
  atomicWriteFileSync(file, JSON.stringify(raw));
@@ -20977,7 +21301,7 @@ async function pollCycleInner() {
20977
21301
  const dir = getFramework("claude-code").getAgentDir(codeName);
20978
21302
  if (!existsSync20(dir)) return;
20979
21303
  atomicWriteFileSync(
20980
- join45(dir, "watchdog-give-up.json"),
21304
+ join46(dir, "watchdog-give-up.json"),
20981
21305
  JSON.stringify({
20982
21306
  gave_up_at: (/* @__PURE__ */ new Date()).toISOString(),
20983
21307
  reason: "usage_limit",
@@ -21254,7 +21578,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
21254
21578
  }
21255
21579
  const now = (/* @__PURE__ */ new Date()).toISOString();
21256
21580
  const adapter = resolveAgentFramework(agent.code_name);
21257
- let agentDir = join45(adapter.getAgentDir(agent.code_name), "provision");
21581
+ let agentDir = join46(adapter.getAgentDir(agent.code_name), "provision");
21258
21582
  if (agent.status === "draft" || agent.status === "paused") {
21259
21583
  forgetChannelSyncState(agent.agent_id);
21260
21584
  reapLegacyTokenFileEdgeWarned(agent.code_name, log);
@@ -21402,7 +21726,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
21402
21726
  if (refreshData.knowledge_manifest) {
21403
21727
  const resolved = await resolveKnowledgeFromManifest({
21404
21728
  manifest: refreshData.knowledge_manifest,
21405
- cacheDir: join45(config.configDir, "_knowledge"),
21729
+ cacheDir: join46(config.configDir, "_knowledge"),
21406
21730
  delivery: refreshData.agent?.knowledge_delivery ?? "both",
21407
21731
  fetchContents: async (hashes) => {
21408
21732
  const res = await api.post(
@@ -21419,7 +21743,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
21419
21743
  const resolvedSkills = await resolveSkillsFromManifest({
21420
21744
  globals: refreshData.global_skills_manifest ?? [],
21421
21745
  shared: refreshData.shared_skills_manifest ?? [],
21422
- cacheDir: join45(config.configDir, "_skills"),
21746
+ cacheDir: join46(config.configDir, "_skills"),
21423
21747
  fetchContents: async (hashes) => {
21424
21748
  const res = await api.post(
21425
21749
  "/host/skills/contents",
@@ -21437,7 +21761,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
21437
21761
  if (refreshData.integration_skills_manifest) {
21438
21762
  const resolvedIntegrationSkills = await resolveIntegrationSkillsFromManifest({
21439
21763
  manifest: refreshData.integration_skills_manifest,
21440
- cacheDir: join45(config.configDir, "_skills"),
21764
+ cacheDir: join46(config.configDir, "_skills"),
21441
21765
  fetchContents: async (hashes) => {
21442
21766
  const res = await api.post(
21443
21767
  "/host/skills/contents",
@@ -21499,7 +21823,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
21499
21823
  const frameworkId = refreshData.agent.framework ?? DEFAULT_FRAMEWORK;
21500
21824
  agentFrameworkCache.set(agent.code_name, frameworkId);
21501
21825
  const frameworkAdapter = getFramework(frameworkId);
21502
- agentDir = join45(frameworkAdapter.getAgentDir(agent.code_name), "provision");
21826
+ agentDir = join46(frameworkAdapter.getAgentDir(agent.code_name), "provision");
21503
21827
  cacheAgentDeliveryMetadata(agent.code_name, refreshData);
21504
21828
  agentRestartTimezoneInputs.set(agent.code_name, {
21505
21829
  agentTimezone: typeof refreshData.agent.timezone === "string" ? refreshData.agent.timezone : null,
@@ -21575,9 +21899,9 @@ async function processAgent(agent, agentStates, managedToolkits) {
21575
21899
  }
21576
21900
  const artifacts = generateArtifacts(agent, provisionRefreshData, frameworkAdapter, renderIntegrationsSection);
21577
21901
  const changedFiles = [];
21578
- mkdirSync17(agentDir, { recursive: true });
21902
+ mkdirSync18(agentDir, { recursive: true });
21579
21903
  for (const artifact of artifacts) {
21580
- const filePath = join45(agentDir, artifact.relativePath);
21904
+ const filePath = join46(agentDir, artifact.relativePath);
21581
21905
  let existingHash;
21582
21906
  let newHash;
21583
21907
  let writeContent = artifact.content;
@@ -21596,8 +21920,8 @@ async function processAgent(agent, agentStates, managedToolkits) {
21596
21920
  };
21597
21921
  newHash = sha256(stripDynamicSections(artifact.content));
21598
21922
  try {
21599
- const projectClaudeMd = join45(config.configDir, agent.code_name, "project", "CLAUDE.md");
21600
- 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");
21601
21925
  existingHash = sha256(stripDynamicSections(existing));
21602
21926
  } catch {
21603
21927
  existingHash = null;
@@ -21615,7 +21939,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
21615
21939
  const generatorKeys = Object.keys(generatorServers);
21616
21940
  let existingRaw = "";
21617
21941
  try {
21618
- existingRaw = readFileSync36(filePath, "utf-8");
21942
+ existingRaw = readFileSync37(filePath, "utf-8");
21619
21943
  } catch {
21620
21944
  }
21621
21945
  const existingServers = parseMcp(existingRaw);
@@ -21631,7 +21955,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
21631
21955
  } else if (artifact.relativePath === "opencode.json") {
21632
21956
  let existingRaw = null;
21633
21957
  try {
21634
- existingRaw = readFileSync36(filePath, "utf-8");
21958
+ existingRaw = readFileSync37(filePath, "utf-8");
21635
21959
  } catch {
21636
21960
  }
21637
21961
  const mergeResult = mergeOpencodeConfigArtifact(artifact.content, existingRaw);
@@ -21647,13 +21971,13 @@ async function processAgent(agent, agentStates, managedToolkits) {
21647
21971
  }
21648
21972
  }
21649
21973
  if (changedFiles.length > 0) {
21650
- const isFirst = !existsSync20(join45(agentDir, "CHARTER.md"));
21974
+ const isFirst = !existsSync20(join46(agentDir, "CHARTER.md"));
21651
21975
  const verb = isFirst ? "Provisioning" : "Updating";
21652
21976
  const fileNames = changedFiles.map((f) => f.relativePath).join(", ");
21653
21977
  log(`${verb} '${agent.code_name}': ${fileNames}`);
21654
21978
  for (const file of changedFiles) {
21655
- const filePath = join45(agentDir, file.relativePath);
21656
- mkdirSync17(dirname11(filePath), { recursive: true });
21979
+ const filePath = join46(agentDir, file.relativePath);
21980
+ mkdirSync18(dirname11(filePath), { recursive: true });
21657
21981
  if (file.relativePath === ".mcp.json") {
21658
21982
  safeWriteJsonAtomic(filePath, file.content, { mode: 384 });
21659
21983
  } else {
@@ -21661,12 +21985,12 @@ async function processAgent(agent, agentStates, managedToolkits) {
21661
21985
  }
21662
21986
  }
21663
21987
  try {
21664
- const provSkillsDir = join45(agentDir, ".claude", "skills");
21988
+ const provSkillsDir = join46(agentDir, ".claude", "skills");
21665
21989
  if (existsSync20(provSkillsDir)) {
21666
21990
  for (const folder of readdirSync14(provSkillsDir)) {
21667
21991
  if (folder.startsWith("knowledge-")) {
21668
21992
  try {
21669
- rmSync9(join45(provSkillsDir, folder), { recursive: true });
21993
+ rmSync9(join46(provSkillsDir, folder), { recursive: true });
21670
21994
  } catch {
21671
21995
  }
21672
21996
  }
@@ -21679,7 +22003,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
21679
22003
  const trackedFiles2 = frameworkAdapter.driftTrackedFiles();
21680
22004
  const hashes = /* @__PURE__ */ new Map();
21681
22005
  for (const file of trackedFiles2) {
21682
- const h = hashFile(join45(agentDir, file));
22006
+ const h = hashFile(join46(agentDir, file));
21683
22007
  if (h) hashes.set(file, h);
21684
22008
  }
21685
22009
  agentState.writtenHashes.set(agent.agent_id, hashes);
@@ -21697,14 +22021,14 @@ async function processAgent(agent, agentStates, managedToolkits) {
21697
22021
  }
21698
22022
  if (Array.isArray(refreshData.workflows)) {
21699
22023
  try {
21700
- const provWorkflowsDir = join45(agentDir, ".claude", "workflows");
22024
+ const provWorkflowsDir = join46(agentDir, ".claude", "workflows");
21701
22025
  if (existsSync20(provWorkflowsDir)) {
21702
22026
  const expected = new Set(refreshData.workflows.map((w) => `${w.name}.js`));
21703
22027
  for (const file of readdirSync14(provWorkflowsDir)) {
21704
22028
  if (!file.endsWith(".js")) continue;
21705
22029
  if (expected.has(file)) continue;
21706
22030
  try {
21707
- rmSync9(join45(provWorkflowsDir, file));
22031
+ rmSync9(join46(provWorkflowsDir, file));
21708
22032
  } catch {
21709
22033
  }
21710
22034
  }
@@ -21799,7 +22123,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
21799
22123
  if (written && existsSync20(agentDir)) {
21800
22124
  const driftedFiles = [];
21801
22125
  for (const [file, expectedHash] of written) {
21802
- const localHash = hashFile(join45(agentDir, file));
22126
+ const localHash = hashFile(join46(agentDir, file));
21803
22127
  if (localHash && localHash !== expectedHash) {
21804
22128
  driftedFiles.push(file);
21805
22129
  }
@@ -21810,7 +22134,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
21810
22134
  try {
21811
22135
  const localHashes = {};
21812
22136
  for (const file of driftedFiles) {
21813
- localHashes[file] = hashFile(join45(agentDir, file));
22137
+ localHashes[file] = hashFile(join46(agentDir, file));
21814
22138
  }
21815
22139
  await api.post("/host/drift", {
21816
22140
  agent_id: agent.agent_id,
@@ -22095,15 +22419,15 @@ async function processAgent(agent, agentStates, managedToolkits) {
22095
22419
  const addedChannels = [...restartDecision.added];
22096
22420
  const writeDmNoticeMarkers = isChannelAddRestart ? () => {
22097
22421
  try {
22098
- const agentAugmentedDir = join45(homedir17(), ".augmented", agent.code_name);
22099
- mkdirSync17(agentAugmentedDir, { recursive: true });
22422
+ const agentAugmentedDir = join46(homedir17(), ".augmented", agent.code_name);
22423
+ mkdirSync18(agentAugmentedDir, { recursive: true });
22100
22424
  const markerJson = JSON.stringify({
22101
22425
  version: 1,
22102
22426
  at: (/* @__PURE__ */ new Date()).toISOString(),
22103
22427
  added: addedChannels
22104
22428
  });
22105
22429
  for (const file of ["slack-channel-add-restart.json", "telegram-channel-add-restart.json"]) {
22106
- atomicWriteFileSync(join45(agentAugmentedDir, file), markerJson);
22430
+ atomicWriteFileSync(join46(agentAugmentedDir, file), markerJson);
22107
22431
  }
22108
22432
  } catch (err) {
22109
22433
  log(`[hot-reload] channel-add DM-notice marker write failed for '${agent.code_name}' (non-fatal): ${err.message}`);
@@ -22183,7 +22507,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
22183
22507
  const behaviourSubset = extractMsTeamsBehaviourSubset(
22184
22508
  msteamsEntry?.config
22185
22509
  );
22186
- const behaviourHash = createHash20("sha256").update(canonicalJson(behaviourSubset)).digest("hex");
22510
+ const behaviourHash = createHash21("sha256").update(canonicalJson(behaviourSubset)).digest("hex");
22187
22511
  const prevBehaviourHash = agentState.knownMsTeamsBehaviourHashes.get(agent.agent_id);
22188
22512
  const msteamsBehaviourRestrictive = isMsTeamsBehaviourRestrictive(behaviourSubset);
22189
22513
  const behaviourDecision = decideSenderPolicyRestart({
@@ -22239,7 +22563,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
22239
22563
  const slackBehaviourSubset = extractSlackBehaviourSubset(
22240
22564
  slackEntry?.config
22241
22565
  );
22242
- const slackBehaviourHash = createHash20("sha256").update(canonicalJson(slackBehaviourSubset)).digest("hex");
22566
+ const slackBehaviourHash = createHash21("sha256").update(canonicalJson(slackBehaviourSubset)).digest("hex");
22243
22567
  const prevSlackBehaviourHash = agentState.knownSlackBehaviourHashes.get(agent.agent_id);
22244
22568
  const slackBehaviourRestrictive = isSlackBehaviourRestrictive(slackBehaviourSubset);
22245
22569
  const slackBehaviourDecision = decideSenderPolicyRestart({
@@ -22294,7 +22618,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
22294
22618
  }
22295
22619
  if (currentChannelIds.has("telegram")) {
22296
22620
  const telegramPolicyEnv = telegramPolicyEnvForRestart ?? {};
22297
- const telegramPolicyHash = createHash20("sha256").update(telegramPolicyEnvBasis(telegramPolicyEnv)).digest("hex");
22621
+ const telegramPolicyHash = createHash21("sha256").update(telegramPolicyEnvBasis(telegramPolicyEnv)).digest("hex");
22298
22622
  const prevTelegramPolicyHash = agentState.knownTelegramPolicyHashes.get(agent.agent_id);
22299
22623
  const telegramPolicyRestrictive = isTelegramPolicyRestrictive(telegramPolicyEnv);
22300
22624
  const telegramPolicyDecision = decideSenderPolicyRestart({
@@ -22353,7 +22677,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
22353
22677
  } else {
22354
22678
  const agentRules = refreshData.agent_rules ?? [];
22355
22679
  const inheritedRules = inheritedResolution.rules;
22356
- const agentRulesHash = createHash20("sha256").update(agentRulesRestartBasis(agentRules, inheritedRules)).digest("hex");
22680
+ const agentRulesHash = createHash21("sha256").update(agentRulesRestartBasis(agentRules, inheritedRules)).digest("hex");
22357
22681
  const prevAgentRulesHash = agentState.knownAgentRulesHashes.get(agent.agent_id);
22358
22682
  const rulesPresent = agentHasRules(agentRules, inheritedRules);
22359
22683
  const agentRulesDecision = decideSenderPolicyRestart({
@@ -22407,18 +22731,18 @@ async function processAgent(agent, agentStates, managedToolkits) {
22407
22731
  if (agentSessionMode === "persistent" && (agentFrameworkCache.get(agent.code_name) ?? DEFAULT_FRAMEWORK) === "claude-code") {
22408
22732
  try {
22409
22733
  const agentProvisionDir = agentDir;
22410
- const projectDir = join45(homedir17(), ".augmented", agent.code_name, "project");
22411
- mkdirSync17(agentProvisionDir, { recursive: true });
22412
- mkdirSync17(projectDir, { recursive: true });
22413
- const provisionMcpPath = join45(agentProvisionDir, ".mcp.json");
22414
- 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");
22415
22739
  let mcpConfig = { mcpServers: {} };
22416
22740
  try {
22417
- mcpConfig = JSON.parse(readFileSync36(provisionMcpPath, "utf-8"));
22741
+ mcpConfig = JSON.parse(readFileSync37(provisionMcpPath, "utf-8"));
22418
22742
  if (!mcpConfig.mcpServers) mcpConfig.mcpServers = {};
22419
22743
  } catch {
22420
22744
  }
22421
- const localDirectChatChannel = join45(homedir17(), ".augmented", "_mcp", "direct-chat-channel.js");
22745
+ const localDirectChatChannel = join46(homedir17(), ".augmented", "_mcp", "direct-chat-channel.js");
22422
22746
  const directChatTeamSettings = refreshData.team?.settings;
22423
22747
  const directChatTz = (() => {
22424
22748
  const tz = directChatTeamSettings?.["timezone"];
@@ -22444,7 +22768,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
22444
22768
  // ~/.augmented/<codeName>/.current-turn-initiator.json. Note getAgentDir
22445
22769
  // returns the agent root (NOT the /provision subdir `agentDir` points at),
22446
22770
  // so it byte-matches the broker readers' path.
22447
- AGT_TURN_INITIATOR_FILE: join45(
22771
+ AGT_TURN_INITIATOR_FILE: join46(
22448
22772
  frameworkAdapter.getAgentDir(agent.code_name),
22449
22773
  ".current-turn-initiator.json"
22450
22774
  )
@@ -22464,7 +22788,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
22464
22788
  log(`Channel credentials written for '${agent.code_name}/direct-chat'`);
22465
22789
  }
22466
22790
  }
22467
- const staleChannelsPath = join45(projectDir, ".mcp-channels.json");
22791
+ const staleChannelsPath = join46(projectDir, ".mcp-channels.json");
22468
22792
  if (existsSync20(staleChannelsPath)) {
22469
22793
  try {
22470
22794
  rmSync9(staleChannelsPath, { force: true });
@@ -22592,7 +22916,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
22592
22916
  }
22593
22917
  if (hostFlagStore().getBoolean("connectivity-probe")) {
22594
22918
  try {
22595
- const probeProjectDir = join45(homedir17(), ".augmented", agent.code_name, "project");
22919
+ const probeProjectDir = join46(homedir17(), ".augmented", agent.code_name, "project");
22596
22920
  let probeSet = integrations;
22597
22921
  const fetchQuarantined = async () => {
22598
22922
  const quarantined = await api.post("/host/agent-integrations/quarantined", { agent_id: agent.agent_id });
@@ -22652,7 +22976,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
22652
22976
  const forceDue = attemptsLeft > 0;
22653
22977
  let probeRan = false;
22654
22978
  try {
22655
- const probeProjectDir = join45(homedir17(), ".augmented", agent.code_name, "project");
22979
+ const probeProjectDir = join46(homedir17(), ".augmented", agent.code_name, "project");
22656
22980
  const renderPending = integrationRenderPending(
22657
22981
  integrations,
22658
22982
  agentState.knownIntegrationHashes.get(agent.agent_id)
@@ -22781,11 +23105,11 @@ async function processAgent(agent, agentStates, managedToolkits) {
22781
23105
  const intHash = computeIntegrationsHash(integrations);
22782
23106
  const prevIntHash = agentState.knownIntegrationHashes.get(agent.agent_id);
22783
23107
  if (intHash !== prevIntHash) {
22784
- const projectDir = join45(homedir17(), ".augmented", agent.code_name, "project");
22785
- const envIntPath = join45(projectDir, ".env.integrations");
23108
+ const projectDir = join46(homedir17(), ".augmented", agent.code_name, "project");
23109
+ const envIntPath = join46(projectDir, ".env.integrations");
22786
23110
  let preWriteEnv;
22787
23111
  try {
22788
- preWriteEnv = readFileSync36(envIntPath, "utf-8");
23112
+ preWriteEnv = readFileSync37(envIntPath, "utf-8");
22789
23113
  } catch {
22790
23114
  preWriteEnv = void 0;
22791
23115
  }
@@ -22813,9 +23137,9 @@ async function processAgent(agent, agentStates, managedToolkits) {
22813
23137
  }
22814
23138
  if (fw === "claude-code" && isSessionHealthy(agent.code_name)) {
22815
23139
  try {
22816
- const projectMcpPath = join45(projectDir, ".mcp.json");
22817
- const postWriteEnv = readFileSync36(envIntPath, "utf-8");
22818
- 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");
22819
23143
  const changedVars = diffEnvIntegrations(preWriteEnv, postWriteEnv);
22820
23144
  const mcpJsonForReap = JSON.parse(mcpContent);
22821
23145
  const affectedServerKeys = findMcpServersUsingVars(mcpJsonForReap, changedVars);
@@ -22901,7 +23225,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
22901
23225
  stopOpencode: (code) => stopOpencodeSession(code, log),
22902
23226
  stopClaudeCode: (code) => {
22903
23227
  try {
22904
- syncExecFile("tmux", ["kill-session", "-t", `agt-${code}`], { stdio: "ignore" });
23228
+ syncExecFile("tmux", ["kill-session", "-t", tmuxSessionTarget(`agt-${code}`)], { stdio: "ignore" });
22905
23229
  } catch {
22906
23230
  }
22907
23231
  stopPersistentSessionAndForgetMcpBaseline(code, "integration-change");
@@ -22942,10 +23266,10 @@ async function processAgent(agent, agentStates, managedToolkits) {
22942
23266
  desiredEntries.push({ serverId, url, headers: mcpHeaders, name: tk.toolkit_name });
22943
23267
  }
22944
23268
  const hashBasis = desiredEntries.slice().sort((a, b) => a.serverId.localeCompare(b.serverId)).map((e) => {
22945
- 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);
22946
23270
  return `${e.serverId}|${e.url}|${headersHash}`;
22947
23271
  }).join("\n");
22948
- const mcpHash = createHash20("sha256").update(hashBasis).digest("hex").slice(0, 16);
23272
+ const mcpHash = createHash21("sha256").update(hashBasis).digest("hex").slice(0, 16);
22949
23273
  const prevMcpHash = agentState.knownManagedMcpHashes.get(agent.agent_id);
22950
23274
  const structureHash = managedMcpStructureHash(desiredEntries);
22951
23275
  const prevStructureHash = agentState.knownManagedMcpStructure.get(agent.agent_id);
@@ -22988,7 +23312,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
22988
23312
  if (mcpHash !== prevMcpHash) {
22989
23313
  for (const e of desiredEntries) {
22990
23314
  frameworkAdapter.writeMcpServer(agent.code_name, e.serverId, { url: e.url, headers: e.headers });
22991
- 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);
22992
23316
  log(`[managed-toolkit] ${agent.code_name}: wrote '${e.name}' (serverId=${e.serverId}, url_hash=${urlHash})`);
22993
23317
  }
22994
23318
  if (deferredPruneKeys.length === 0) {
@@ -23090,7 +23414,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
23090
23414
  if (frameworkAdapter.installSkillFiles) {
23091
23415
  const currentIntegrationSkillIds = /* @__PURE__ */ new Set();
23092
23416
  const installedIntegrationSkills = [];
23093
- const { createHash: createHash21 } = await import("crypto");
23417
+ const { createHash: createHash22 } = await import("crypto");
23094
23418
  const refreshAny = refreshData;
23095
23419
  const contexts = refreshAny.integration_contexts ?? refreshAny.plugin_contexts ?? [];
23096
23420
  const contextBySlug = /* @__PURE__ */ new Map();
@@ -23127,7 +23451,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
23127
23451
  )
23128
23452
  }));
23129
23453
  const bundle = buildIntegrationBundle(renderedScopes);
23130
- 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);
23131
23455
  if (!shouldWriteIntegrationSkill(
23132
23456
  agentState.knownSkillHashes,
23133
23457
  agent.agent_id,
@@ -23155,12 +23479,12 @@ async function processAgent(agent, agentStates, managedToolkits) {
23155
23479
  const frameworkId2 = frameworkAdapter.id;
23156
23480
  const candidateSkillDirs = [
23157
23481
  // Claude Code — framework runtime tree
23158
- join45(homedir18(), ".augmented", agent.code_name, "skills"),
23482
+ join46(homedir18(), ".augmented", agent.code_name, "skills"),
23159
23483
  // Claude Code — project tree
23160
- join45(homedir18(), ".augmented", agent.code_name, "project", ".claude", "skills"),
23484
+ join46(homedir18(), ".augmented", agent.code_name, "project", ".claude", "skills"),
23161
23485
  // Defensive: legacy provision-side path, not currently an
23162
23486
  // install target but cheap to sweep.
23163
- join45(agentDir, ".claude", "skills")
23487
+ join46(agentDir, ".claude", "skills")
23164
23488
  ];
23165
23489
  const existingDirs = candidateSkillDirs.filter((d) => existsSync20(d));
23166
23490
  const discoveredEntries = /* @__PURE__ */ new Set();
@@ -23203,7 +23527,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
23203
23527
  const sharedSkillsPayload = refreshAny.shared_skills;
23204
23528
  const desiredResolved = globalSkillsPayload !== void 0 || sharedSkillsPayload !== void 0;
23205
23529
  const manifestPath = managedSkillManifestPath(
23206
- join45(homedir17(), ".augmented", agent.code_name)
23530
+ join46(homedir17(), ".augmented", agent.code_name)
23207
23531
  );
23208
23532
  const prevIds = /* @__PURE__ */ new Set([
23209
23533
  ...agentState.knownGlobalSkillIds.get(agent.agent_id) ?? /* @__PURE__ */ new Set(),
@@ -23212,7 +23536,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
23212
23536
  const plan = planGlobalSkillSync(
23213
23537
  [...globalSkillsPayload ?? [], ...sharedSkillsPayload ?? []],
23214
23538
  prevIds,
23215
- (content) => createHash21("sha256").update(content).digest("hex").slice(0, 12),
23539
+ (content) => createHash22("sha256").update(content).digest("hex").slice(0, 12),
23216
23540
  (skillId) => agentState.knownSkillHashes.get(`global-skill:${agent.agent_id}:${skillId}`),
23217
23541
  { desiredResolved }
23218
23542
  );
@@ -23223,15 +23547,15 @@ async function processAgent(agent, agentStates, managedToolkits) {
23223
23547
  }
23224
23548
  if (plan.removes.length) {
23225
23549
  const globalSkillDirs = [
23226
- join45(homedir17(), ".augmented", agent.code_name, "skills"),
23227
- join45(homedir17(), ".augmented", agent.code_name, "project", ".claude", "skills"),
23228
- 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")
23229
23553
  ];
23230
23554
  for (const id of plan.removes) {
23231
23555
  let prunedAny = false;
23232
23556
  for (const dir of globalSkillDirs) {
23233
- const p = join45(dir, id);
23234
- if (existsSync20(p) && existsSync20(join45(p, "SKILL.md"))) {
23557
+ const p = join46(dir, id);
23558
+ if (existsSync20(p) && existsSync20(join46(p, "SKILL.md"))) {
23235
23559
  rmSync9(p, { recursive: true, force: true });
23236
23560
  prunedAny = true;
23237
23561
  }
@@ -23263,7 +23587,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
23263
23587
  const slug = hook.integration_slug ?? hook.plugin_slug;
23264
23588
  if (!slug) continue;
23265
23589
  try {
23266
- 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);
23267
23591
  const hookKey = `${agent.agent_id}:${frameworkAdapter.id}:plugin-hook:${slug}:on_install`;
23268
23592
  if (agentState.knownSkillHashes.get(hookKey) === scriptHash) continue;
23269
23593
  const result = await frameworkAdapter.executePluginHook({
@@ -23278,9 +23602,9 @@ async function processAgent(agent, agentStates, managedToolkits) {
23278
23602
  } else if (result.timedOut) {
23279
23603
  log(`Integration hook on_install '${slug}' TIMED OUT for '${agent.code_name}' after ${result.durationMs}ms`);
23280
23604
  } else {
23281
- 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);
23282
23606
  const missingCmd = result.exitCode === 127 ? extractCommandNotFound(result.stderr) : null;
23283
- 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;
23284
23608
  log(
23285
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}]`
23286
23610
  );
@@ -23501,8 +23825,10 @@ async function processAgent(agent, agentStates, managedToolkits) {
23501
23825
  const sess = getSessionState(agent.code_name);
23502
23826
  let mcpJsonParsed = null;
23503
23827
  try {
23504
- const mcpPath = join45(getProjectDir(agent.code_name), ".mcp.json");
23505
- mcpJsonParsed = JSON.parse(readFileSync36(mcpPath, "utf-8"));
23828
+ mcpJsonParsed = readSpawnViewMcpConfig(
23829
+ agent.code_name,
23830
+ getProjectDir(agent.code_name)
23831
+ );
23506
23832
  } catch {
23507
23833
  }
23508
23834
  const computerUseIsolated = isolationMode(agent.code_name) === "docker";
@@ -23604,7 +23930,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
23604
23930
  // recovery for every agent on the host.
23605
23931
  readPane: (codeName) => {
23606
23932
  try {
23607
- return syncExecFile("tmux", ["capture-pane", "-t", `agt-${codeName}`, "-p"], {
23933
+ return syncExecFile("tmux", ["capture-pane", "-t", tmuxPaneTarget(`agt-${codeName}`), "-p"], {
23608
23934
  stdio: ["ignore", "pipe", "ignore"],
23609
23935
  timeout: 2e3
23610
23936
  }).toString();
@@ -23964,7 +24290,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
23964
24290
  freshDoneIds.add(item.id);
23965
24291
  }
23966
24292
  } catch (err) {
23967
- 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);
23968
24294
  log(`Reap API error for item_id=${item.id} error_id=${errId}`);
23969
24295
  }
23970
24296
  if (reapAction === "dead_letter") {
@@ -24015,7 +24341,7 @@ Retried to the limit after repeated stalls \u2014 needs a look.`).catch(() => {
24015
24341
  if (trackedFiles.length > 0 && existsSync20(agentDir)) {
24016
24342
  const hashes = /* @__PURE__ */ new Map();
24017
24343
  for (const file of trackedFiles) {
24018
- const h = hashFile(join45(agentDir, file));
24344
+ const h = hashFile(join46(agentDir, file));
24019
24345
  if (h) hashes.set(file, h);
24020
24346
  }
24021
24347
  agentState.writtenHashes.set(agent.agent_id, hashes);
@@ -24030,7 +24356,7 @@ Retried to the limit after repeated stalls \u2014 needs a look.`).catch(() => {
24030
24356
  refreshData.agent.onboarding_state
24031
24357
  );
24032
24358
  const obStep = obState.step;
24033
- const markerPath = join45(homedir17(), ".augmented", agent.code_name, "onboarding-drive.json");
24359
+ const markerPath = join46(homedir17(), ".augmented", agent.code_name, "onboarding-drive.json");
24034
24360
  const marker = readOnboardingDriveMarker(markerPath);
24035
24361
  const obContactRaw = refreshData.agent.manager_last_contacted_at;
24036
24362
  const obContact = typeof obContactRaw === "string" && obContactRaw ? obContactRaw : null;
@@ -24163,7 +24489,7 @@ async function ensureOpencodeRuntime(agent, refreshData, agentTimezone) {
24163
24489
  }
24164
24490
  stopOpencodeSlackIngest(codeName, log);
24165
24491
  stopOpencodeTelegramIngest(codeName, log);
24166
- const opencodeProjectDir = join45(getFramework("opencode").getAgentDir(codeName), "provision");
24492
+ const opencodeProjectDir = join46(getFramework("opencode").getAgentDir(codeName), "provision");
24167
24493
  const serveEnv = {
24168
24494
  AGT_HOST: requireHost(),
24169
24495
  AGT_API_KEY: getApiKey() ?? void 0,
@@ -24234,8 +24560,8 @@ async function ensurePersistentSessionUnchecked(agent, tasks, boardItems, refres
24234
24560
  });
24235
24561
  }
24236
24562
  const projectDir = getProjectDir(codeName);
24237
- const mcpConfigPath = join45(projectDir, ".mcp.json");
24238
- const claudeMdPath = join45(projectDir, "CLAUDE.md");
24563
+ const mcpConfigPath = join46(projectDir, ".mcp.json");
24564
+ const claudeMdPath = join46(projectDir, "CLAUDE.md");
24239
24565
  if (restartBreaker.isTripped(codeName)) {
24240
24566
  const trip = restartBreaker.getTrip(codeName);
24241
24567
  return {
@@ -24246,7 +24572,11 @@ async function ensurePersistentSessionUnchecked(agent, tasks, boardItems, refres
24246
24572
  };
24247
24573
  }
24248
24574
  if ((agentFrameworkCache.get(codeName) ?? DEFAULT_FRAMEWORK) === "claude-code" && !isSessionHealthy(codeName)) {
24249
- const missingMcpBundles = findMissingMcpBundles(mcpConfigPath);
24575
+ const spawnDropped = spawnDroppedServerKeys(
24576
+ mcpConfigPath,
24577
+ lastIntegrationsPayload.get(agent.agent_id)
24578
+ );
24579
+ const missingMcpBundles = findMissingMcpBundles(mcpConfigPath, { skipKeys: spawnDropped });
24250
24580
  if (missingMcpBundles.length > 0) {
24251
24581
  const detail = formatMissingMcpBundles(missingMcpBundles);
24252
24582
  log(
@@ -24619,7 +24949,7 @@ async function ensurePersistentSessionUnchecked(agent, tasks, boardItems, refres
24619
24949
  const ctx = getLastFailureContext(codeName);
24620
24950
  const recovery = prepareForRespawn(codeName);
24621
24951
  const tailSummary = !ctx.tail ? "" : KNOWN_SAFE_TAIL_SIGNATURES.has(ctx.signature) ? `; last pane output (${PANE_TAIL_PREVIEW_LINES} of ~20 lines):
24622
- ${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)`;
24623
24953
  const sigSummary = ctx.signature !== "unknown" ? `; signature=${ctx.signature}` : "";
24624
24954
  const recoverySummary = recovery ? `; recovery=${recovery}` : "";
24625
24955
  log(
@@ -24633,7 +24963,7 @@ ${truncateForLog(ctx.tail)}` : `; pane_tail_hash=sha256:${createHash20("sha256")
24633
24963
  );
24634
24964
  getHostId().then((hostId) => {
24635
24965
  if (!hostId) return;
24636
- 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;
24637
24967
  return api.post("/host/events", {
24638
24968
  host_id: hostId,
24639
24969
  agent_code_name: codeName,
@@ -24744,11 +25074,30 @@ ${truncateForLog(ctx.tail)}` : `; pane_tail_hash=sha256:${createHash20("sha256")
24744
25074
  `[persistent-session] '${codeName}' (host_kind=${hostKind ?? "dedicated"}): injecting per-agent org-scoped key (ADR-0042 pt3b)`
24745
25075
  );
24746
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);
24747
25096
  startPersistentSession({
24748
25097
  codeName,
24749
25098
  agentId: agent.agent_id,
24750
25099
  projectDir,
24751
- mcpConfigPath,
25100
+ mcpConfigPath: spawnMcpConfigPath,
24752
25101
  claudeMdPath,
24753
25102
  channels,
24754
25103
  devChannels,
@@ -24832,7 +25181,7 @@ ${truncateForLog(ctx.tail)}` : `; pane_tail_hash=sha256:${createHash20("sha256")
24832
25181
  recordSessionPolicyBaseline(codeName, currentPolicyModel, currentPolicyId);
24833
25182
  denyWebFetchBySession.set(codeName, spawnDenyWebFetch);
24834
25183
  persistDeliveryBaselineEntry("webFetch", agent.agent_id, webFetchBaselineValue(spawnDenyWebFetch));
24835
- seedSessionLaunchBaselines(codeName, projectDir);
25184
+ seedSessionLaunchBaselines(codeName, projectDir, spawnMcpConfigPath);
24836
25185
  if (effectiveIsolationMode(codeName) === "docker") {
24837
25186
  seedContainerMemory(codeName, resolveContainerMemory(spawnAgentClass));
24838
25187
  }
@@ -24898,7 +25247,7 @@ ${truncateForLog(ctx.tail)}` : `; pane_tail_hash=sha256:${createHash20("sha256")
24898
25247
  claudeAuthTupleBySession.set(codeName, currentAuthTuple);
24899
25248
  recordSessionPolicyBaseline(codeName, currentPolicyModel, currentPolicyId);
24900
25249
  }
24901
- 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);
24902
25251
  const prevHash = agentState.knownTasksHashes.get(agent.agent_id);
24903
25252
  if (stableTasksHash !== prevHash) {
24904
25253
  const taskInputs = tasks.map((t) => buildSchedulerTaskInput(t));
@@ -25253,7 +25602,7 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
25253
25602
  if (!refreshData) return;
25254
25603
  const framework = refreshData.agent?.framework ?? agentFrameworkCache.get(codeName) ?? DEFAULT_FRAMEWORK;
25255
25604
  const hostId = await getHostId();
25256
- const parkForRestart = await import("../responsiveness-probe-NV3LXAWL.js").then(
25605
+ const parkForRestart = await import("../responsiveness-probe-26TFNDWB.js").then(
25257
25606
  (m) => m.parkPendingInbound,
25258
25607
  (err) => err
25259
25608
  );
@@ -25330,7 +25679,7 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
25330
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}`));
25331
25680
  void (async () => {
25332
25681
  try {
25333
- const { collectDiagnostics } = await import("../persistent-session-C7UKT4EE.js");
25682
+ const { collectDiagnostics } = await import("../persistent-session-FMY2FZEL.js");
25334
25683
  await api.post("/host/heartbeat", {
25335
25684
  host_id: hostId,
25336
25685
  agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
@@ -25383,7 +25732,7 @@ async function respawnAgentAfterMcpStop(codeName, reason) {
25383
25732
  }
25384
25733
  try {
25385
25734
  const hostId = await getHostId();
25386
- const { collectDiagnostics } = await import("../persistent-session-C7UKT4EE.js");
25735
+ const { collectDiagnostics } = await import("../persistent-session-FMY2FZEL.js");
25387
25736
  await api.post("/host/heartbeat", {
25388
25737
  host_id: hostId,
25389
25738
  agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
@@ -25478,7 +25827,7 @@ function ensureRealtimeKanbanStarted(agentStates) {
25478
25827
  );
25479
25828
  }
25480
25829
  }).catch((err) => {
25481
- 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);
25482
25831
  log(
25483
25832
  `[realtime] Work trigger enqueue threw for '${agent.codeName}' item_id=${item.id} error_id=${errId} \u2014 hybrid nudge will retry`
25484
25833
  );
@@ -25795,7 +26144,7 @@ async function processDirectChatMessage(agent, msg) {
25795
26144
  if (useDoorbell) {
25796
26145
  try {
25797
26146
  const doorbell = directChatDoorbellPath(agent.agentId, homedir17());
25798
- mkdirSync17(dirname11(doorbell), { recursive: true });
26147
+ mkdirSync18(dirname11(doorbell), { recursive: true });
25799
26148
  writeFileSync19(doorbell, String(Date.now()));
25800
26149
  log(`[direct-chat] Doorbell rung for '${agent.codeName}' (msg=${msg.id}) \u2014 in-session MCP will pull via the cursor`);
25801
26150
  return;
@@ -25924,7 +26273,7 @@ ${formatRunMarker(run_id)}` : KANBAN_CHECK_COMMAND;
25924
26273
  if (run_id) openInjectedRunByCode.set(codeName, run_id);
25925
26274
  try {
25926
26275
  const doorbell = directChatDoorbellPath(agentId, homedir17());
25927
- mkdirSync17(dirname11(doorbell), { recursive: true });
26276
+ mkdirSync18(dirname11(doorbell), { recursive: true });
25928
26277
  writeFileSync19(doorbell, String(Date.now()));
25929
26278
  } catch (err) {
25930
26279
  log(`[kanban] doorbell ring failed for '${codeName}': ${err.message} (notice still queued)`);
@@ -26085,7 +26434,7 @@ async function processClaudePairSessions(agents) {
26085
26434
  snapshotPairConfig,
26086
26435
  // ENG-11659: result -> report body + the manager.log line that records it.
26087
26436
  planPairStartReport
26088
- } = await import("../claude-pair-runtime-2EOLNZEY.js");
26437
+ } = await import("../claude-pair-runtime-ASGVKZ5N.js");
26089
26438
  const { resetClaudeSignin, describeSigninResetForLog, describeSigninResetFailure } = await import("../claude-signin-reset-6IJMMVYG.js");
26090
26439
  for (const pairId of pendingResp.cancelled_pair_ids ?? []) {
26091
26440
  log(`[claude-pair] sweeping orphan tmux session for pair ${pairId.slice(0, 8)}`);
@@ -26384,17 +26733,17 @@ var lastLocalFileHash = /* @__PURE__ */ new Map();
26384
26733
  var lastMemoriesBody = /* @__PURE__ */ new Map();
26385
26734
  var memoryManifests = /* @__PURE__ */ new Map();
26386
26735
  function memoryRetirementDir(configDir, codeName) {
26387
- return join45(configDir, "_memory-retirement", codeName);
26736
+ return join46(configDir, "_memory-retirement", codeName);
26388
26737
  }
26389
26738
  function memoryManifestPath(configDir, codeName) {
26390
- return join45(memoryRetirementDir(configDir, codeName), "manifest.json");
26739
+ return join46(memoryRetirementDir(configDir, codeName), "manifest.json");
26391
26740
  }
26392
26741
  function loadMemoryManifest(agentId, configDir, codeName) {
26393
26742
  const cached = memoryManifests.get(agentId);
26394
26743
  if (cached) return cached;
26395
26744
  let manifest = {};
26396
26745
  try {
26397
- const raw = readFileSync36(memoryManifestPath(configDir, codeName), "utf-8");
26746
+ const raw = readFileSync37(memoryManifestPath(configDir, codeName), "utf-8");
26398
26747
  const parsed = JSON.parse(raw);
26399
26748
  if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
26400
26749
  for (const [name, entry] of Object.entries(parsed)) {
@@ -26414,7 +26763,7 @@ function saveMemoryManifest(agentId, configDir, codeName) {
26414
26763
  if (!manifest) return;
26415
26764
  try {
26416
26765
  const path = memoryManifestPath(configDir, codeName);
26417
- mkdirSync17(memoryRetirementDir(configDir, codeName), { recursive: true });
26766
+ mkdirSync18(memoryRetirementDir(configDir, codeName), { recursive: true });
26418
26767
  const tmp = `${path}.tmp`;
26419
26768
  writeFileSync19(tmp, JSON.stringify(manifest, null, 2));
26420
26769
  renameSync11(tmp, path);
@@ -26422,7 +26771,7 @@ function saveMemoryManifest(agentId, configDir, codeName) {
26422
26771
  }
26423
26772
  }
26424
26773
  function retiredMemoryDir(configDir, codeName) {
26425
- return join45(memoryRetirementDir(configDir, codeName), "retired");
26774
+ return join46(memoryRetirementDir(configDir, codeName), "retired");
26426
26775
  }
26427
26776
  var RETIRED_MEMORY_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
26428
26777
  var lastRetirementReport = /* @__PURE__ */ new Map();
@@ -26501,7 +26850,7 @@ function applyMemoryTombstones(opts) {
26501
26850
  log2(`[memory-retire] ${agent.code_name}: KEPT '${tomb.name}' \u2014 no write record, not ours to remove`);
26502
26851
  continue;
26503
26852
  }
26504
- const filePath = join45(memoryDir, entry.file);
26853
+ const filePath = join46(memoryDir, entry.file);
26505
26854
  if (!existsSync20(filePath)) {
26506
26855
  outcomes.already_gone++;
26507
26856
  delete manifest[tomb.name];
@@ -26509,7 +26858,7 @@ function applyMemoryTombstones(opts) {
26509
26858
  continue;
26510
26859
  }
26511
26860
  try {
26512
- const actual = createHash20("sha256").update(readFileSync36(filePath)).digest("hex");
26861
+ const actual = createHash21("sha256").update(readFileSync37(filePath)).digest("hex");
26513
26862
  if (actual !== entry.sha) {
26514
26863
  outcomes.kept_modified++;
26515
26864
  outcomes.unapplied.push({ name: tomb.name, reason: "kept_modified" });
@@ -26519,11 +26868,11 @@ function applyMemoryTombstones(opts) {
26519
26868
  continue;
26520
26869
  }
26521
26870
  const destDir = retiredMemoryDir(configDir, agent.code_name);
26522
- mkdirSync17(destDir, { recursive: true });
26871
+ mkdirSync18(destDir, { recursive: true });
26523
26872
  const stamp = Date.now();
26524
- let dest = join45(destDir, `${entry.file}.${stamp}.retired`);
26873
+ let dest = join46(destDir, `${entry.file}.${stamp}.retired`);
26525
26874
  for (let n = 1; existsSync20(dest); n++) {
26526
- dest = join45(destDir, `${entry.file}.${stamp}-${n}.retired`);
26875
+ dest = join46(destDir, `${entry.file}.${stamp}-${n}.retired`);
26527
26876
  }
26528
26877
  renameSync11(filePath, dest);
26529
26878
  try {
@@ -26562,7 +26911,7 @@ function reapRetiredMemories(configDir, codeName, log2) {
26562
26911
  try {
26563
26912
  for (const file of readdirSync14(dir)) {
26564
26913
  if (!file.endsWith(".retired")) continue;
26565
- const path = join45(dir, file);
26914
+ const path = join46(dir, file);
26566
26915
  try {
26567
26916
  if (statSync15(path).mtimeMs < cutoff) {
26568
26917
  unlinkSync6(path);
@@ -26577,8 +26926,8 @@ function reapRetiredMemories(configDir, codeName, log2) {
26577
26926
  if (reaped > 0) log2(`[memory-retire] ${codeName}: reaped ${reaped} retired memory file(s) past TTL`);
26578
26927
  }
26579
26928
  async function syncMemories(agent, configDir, log2) {
26580
- const projectDir = join45(configDir, agent.code_name, "project");
26581
- const memoryDir = join45(projectDir, "memory");
26929
+ const projectDir = join46(configDir, agent.code_name, "project");
26930
+ const memoryDir = join46(projectDir, "memory");
26582
26931
  const isFreshSync = pendingFreshMemorySync.has(agent.agent_id);
26583
26932
  if (isFreshSync) {
26584
26933
  log2(`[memory-sync] Fresh-sync requested for '${agent.code_name}' \u2014 pulling DB first`);
@@ -26609,8 +26958,8 @@ async function syncMemories(agent, configDir, log2) {
26609
26958
  for (const file of readdirSync14(memoryDir)) {
26610
26959
  if (!file.endsWith(".md")) continue;
26611
26960
  try {
26612
- const raw = readFileSync36(join45(memoryDir, file), "utf-8");
26613
- 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);
26614
26963
  currentHashes.set(file, fileHash);
26615
26964
  if (prevHashes.get(file) === fileHash) continue;
26616
26965
  const parsed = parseMemoryFile(raw, file.replace(/\.md$/, ""));
@@ -26634,7 +26983,7 @@ async function syncMemories(agent, configDir, log2) {
26634
26983
  } catch (err) {
26635
26984
  for (const mem of changedMemories) {
26636
26985
  for (const [file] of currentHashes) {
26637
- 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$/, ""));
26638
26987
  if (parsed?.name === mem.name) currentHashes.delete(file);
26639
26988
  }
26640
26989
  }
@@ -26661,7 +27010,7 @@ async function syncMemories(agent, configDir, log2) {
26661
27010
  }
26662
27011
  async function downloadMemories(agent, memoryDir, log2, { force, configDir }) {
26663
27012
  const localFiles = existsSync20(memoryDir) ? readdirSync14(memoryDir).filter((f) => f.endsWith(".md")).sort() : [];
26664
- 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);
26665
27014
  const prevLocalHash = lastLocalFileHash.get(agent.agent_id);
26666
27015
  const prevDownload = lastDownloadHash.get(agent.agent_id);
26667
27016
  const memoriesToken = memoriesFetchGate.beginFetch(agent.agent_id);
@@ -26715,7 +27064,7 @@ async function downloadMemories(agent, memoryDir, log2, { force, configDir }) {
26715
27064
  // Per-agent, not host-wide: memories are agent-private, so a shared
26716
27065
  // store would buy almost no dedupe while exposing one agent's content
26717
27066
  // to every other agent on the host. See memory-cache.ts's header.
26718
- cacheDir: join45(configDir, agent.code_name, "_memory_bodies"),
27067
+ cacheDir: join46(configDir, agent.code_name, "_memory_bodies"),
26719
27068
  fetchContents: async (hashes) => {
26720
27069
  const res = await api.post(
26721
27070
  "/host/memories/contents",
@@ -26737,14 +27086,14 @@ async function downloadMemories(agent, memoryDir, log2, { force, configDir }) {
26737
27086
  );
26738
27087
  }
26739
27088
  }
26740
- 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);
26741
27090
  if (!force && prevDownload && prevLocalHash === localListHash && lastDownloadHash.get(agent.agent_id) === responseHash) {
26742
27091
  return { status: "skipped", tombstones, truncated: dbMemories.tombstones_truncated === true };
26743
27092
  }
26744
27093
  lastDownloadHash.set(agent.agent_id, responseHash);
26745
27094
  lastLocalFileHash.set(agent.agent_id, localListHash);
26746
27095
  if (memories?.length) {
26747
- mkdirSync17(memoryDir, { recursive: true });
27096
+ mkdirSync18(memoryDir, { recursive: true });
26748
27097
  const manifest = loadMemoryManifest(agent.agent_id, configDir, agent.code_name);
26749
27098
  let written = 0;
26750
27099
  let overwritten = 0;
@@ -26753,7 +27102,7 @@ async function downloadMemories(agent, memoryDir, log2, { force, configDir }) {
26753
27102
  const rawSlug = mem.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "").slice(0, 60);
26754
27103
  const slug = rawSlug || `memory-${i}`;
26755
27104
  const fileName = `${slug}.md`;
26756
- const filePath = join45(memoryDir, fileName);
27105
+ const filePath = join46(memoryDir, fileName);
26757
27106
  const desired = `---
26758
27107
  name: ${JSON.stringify(mem.name)}
26759
27108
  type: ${mem.type}
@@ -26763,7 +27112,7 @@ description: ${JSON.stringify(mem.content.slice(0, 200))}
26763
27112
  ${mem.content}
26764
27113
  `;
26765
27114
  const record = () => {
26766
- const sha = createHash20("sha256").update(desired).digest("hex");
27115
+ const sha = createHash21("sha256").update(desired).digest("hex");
26767
27116
  const prev = manifest[mem.name];
26768
27117
  if (prev?.file === fileName && prev.sha === sha) return false;
26769
27118
  manifest[mem.name] = { file: fileName, sha };
@@ -26773,7 +27122,7 @@ ${mem.content}
26773
27122
  if (existsSync20(filePath)) {
26774
27123
  let existing = "";
26775
27124
  try {
26776
- existing = readFileSync36(filePath, "utf-8");
27125
+ existing = readFileSync37(filePath, "utf-8");
26777
27126
  } catch {
26778
27127
  }
26779
27128
  if (existing === desired) {
@@ -26792,7 +27141,7 @@ ${mem.content}
26792
27141
  }
26793
27142
  if (written > 0 || overwritten > 0) {
26794
27143
  const updatedFiles = readdirSync14(memoryDir).filter((f) => f.endsWith(".md")).sort();
26795
- 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));
26796
27145
  log2(`Memory download for '${agent.code_name}': wrote ${written} new, overwrote ${overwritten} stale`);
26797
27146
  }
26798
27147
  }
@@ -27031,7 +27380,7 @@ async function killAllAgtTmuxSessions() {
27031
27380
  );
27032
27381
  const sessions = output.trim().split("\n").filter((s) => s.startsWith("agt-"));
27033
27382
  const { killed, failed } = await killSessionsConcurrently(sessions, async (session) => {
27034
- await execFilePromiseLong("tmux", ["kill-session", "-t", session], {
27383
+ await execFilePromiseLong("tmux", ["kill-session", "-t", tmuxSessionTarget(session)], {
27035
27384
  timeout: 2e3,
27036
27385
  stdin: "ignore"
27037
27386
  });
@@ -27174,7 +27523,7 @@ function startManager(opts) {
27174
27523
  try {
27175
27524
  const stateFile = getStateFile();
27176
27525
  if (existsSync20(stateFile)) {
27177
- const raw = readFileSync36(stateFile, "utf-8");
27526
+ const raw = readFileSync37(stateFile, "utf-8");
27178
27527
  const parsed = JSON.parse(raw);
27179
27528
  if (Array.isArray(parsed.agents)) {
27180
27529
  state9.agents = parsed.agents;
@@ -27208,7 +27557,7 @@ function startManager(opts) {
27208
27557
  log(`[startup] state rehydration failed (continuing with empty state): ${err.message}`);
27209
27558
  }
27210
27559
  log(
27211
- `[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")}`
27212
27561
  );
27213
27562
  deployMcpAssets();
27214
27563
  reapOrphanChannelMcps({ log });
@@ -27237,7 +27586,7 @@ async function reapOrphanedClaudePids() {
27237
27586
  const looksLikeClaude = (pid) => {
27238
27587
  if (process.platform !== "linux") return true;
27239
27588
  try {
27240
- const comm = readFileSync36(`/proc/${pid}/comm`, "utf-8").trim().toLowerCase();
27589
+ const comm = readFileSync37(`/proc/${pid}/comm`, "utf-8").trim().toLowerCase();
27241
27590
  return comm.includes("claude");
27242
27591
  } catch {
27243
27592
  return false;
@@ -27334,14 +27683,14 @@ function restartRunningChannelMcps(basenames) {
27334
27683
  }
27335
27684
  }
27336
27685
  function deployMcpAssets() {
27337
- const targetDir = join45(homedir17(), ".augmented", "_mcp");
27338
- mkdirSync17(targetDir, { recursive: true });
27686
+ const targetDir = join46(homedir17(), ".augmented", "_mcp");
27687
+ mkdirSync18(targetDir, { recursive: true });
27339
27688
  const moduleDir = dirname11(fileURLToPath2(import.meta.url));
27340
27689
  let mcpSourceDir = "";
27341
27690
  let dir = moduleDir;
27342
27691
  for (let i = 0; i < 6; i++) {
27343
- const candidate = join45(dir, "dist", "mcp");
27344
- if (existsSync20(join45(candidate, "index.js"))) {
27692
+ const candidate = join46(dir, "dist", "mcp");
27693
+ if (existsSync20(join46(candidate, "index.js"))) {
27345
27694
  mcpSourceDir = candidate;
27346
27695
  break;
27347
27696
  }
@@ -27359,7 +27708,7 @@ function deployMcpAssets() {
27359
27708
  const fileHash = (p) => {
27360
27709
  try {
27361
27710
  if (!existsSync20(p)) return null;
27362
- return createHash20("sha256").update(readFileSync36(p)).digest("hex");
27711
+ return createHash21("sha256").update(readFileSync37(p)).digest("hex");
27363
27712
  } catch {
27364
27713
  return null;
27365
27714
  }
@@ -27441,8 +27790,8 @@ function deployMcpAssets() {
27441
27790
  // natural session restart.
27442
27791
  "computer-use-proxy.js"
27443
27792
  ]) {
27444
- const src = join45(mcpSourceDir, file);
27445
- const dst = join45(targetDir, file);
27793
+ const src = join46(mcpSourceDir, file);
27794
+ const dst = join46(targetDir, file);
27446
27795
  if (!existsSync20(src)) continue;
27447
27796
  attemptedFiles.push(file);
27448
27797
  const before = fileHash(dst);
@@ -27468,16 +27817,16 @@ function deployMcpAssets() {
27468
27817
  log(`[manager] Bundle(s) updated: ${changedBasenames.join(", ")} \u2014 signalling running instances to restart`);
27469
27818
  restartRunningChannelMcps(changedBasenames);
27470
27819
  }
27471
- const localMcpPath = join45(targetDir, "index.js");
27820
+ const localMcpPath = join46(targetDir, "index.js");
27472
27821
  try {
27473
- const agentsDir = join45(homedir17(), ".augmented", "agents");
27822
+ const agentsDir = join46(homedir17(), ".augmented", "agents");
27474
27823
  if (existsSync20(agentsDir)) {
27475
27824
  for (const entry of readdirSync14(agentsDir, { withFileTypes: true })) {
27476
27825
  if (!entry.isDirectory()) continue;
27477
27826
  for (const subdir of ["provision", "project"]) {
27478
- const mcpJsonPath = join45(agentsDir, entry.name, subdir, ".mcp.json");
27827
+ const mcpJsonPath = join46(agentsDir, entry.name, subdir, ".mcp.json");
27479
27828
  try {
27480
- const raw = readFileSync36(mcpJsonPath, "utf-8");
27829
+ const raw = readFileSync37(mcpJsonPath, "utf-8");
27481
27830
  if (!raw.includes("@integrity-labs/augmented-mcp")) continue;
27482
27831
  const mcpConfig = JSON.parse(raw);
27483
27832
  const augServer = mcpConfig.mcpServers?.["augmented"];