@integrity-labs/agt-cli 0.28.593 → 0.28.595

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.
@@ -53,7 +53,7 @@ import {
53
53
  safeWriteJsonAtomic,
54
54
  setConfigHash,
55
55
  tripClass
56
- } from "../chunk-BYCE4V7Q.js";
56
+ } from "../chunk-RC6V6QN2.js";
57
57
  import {
58
58
  getProjectDir as getProjectDir2,
59
59
  getReadyTasks,
@@ -61,12 +61,60 @@ import {
61
61
  markTaskFired,
62
62
  syncTasksToScheduler
63
63
  } from "../chunk-3HLECXMI.js";
64
+ import {
65
+ ChildProcessError,
66
+ agentRuntimeKey,
67
+ buildEgressAllowlist,
68
+ checkChannelInputs,
69
+ creditWatchdogGiveUpCount,
70
+ egressMode,
71
+ execFilePromiseLong,
72
+ getLastFailureContext,
73
+ getOpencodeActivityAgeSeconds,
74
+ getOpencodeSessionState,
75
+ getOpencodeTurnHealth,
76
+ getProjectDir,
77
+ getSessionState,
78
+ hashFile,
79
+ injectMessage,
80
+ injectMessageWithStatus,
81
+ injectOpencodeMessage,
82
+ isOpencodeSessionHealthy,
83
+ isSessionHealthy,
84
+ isolationMode,
85
+ log,
86
+ mergeOpencodeConfigArtifact,
87
+ paneLogPath,
88
+ parseEnvIntegrations,
89
+ prepareForRespawn,
90
+ readChannelServerEnv,
91
+ readDirectChatSessionState,
92
+ readOpencodePaneLogTail,
93
+ readPaneLogTail,
94
+ readProvisionedOpencodeModel,
95
+ reloadEgressSidecar,
96
+ resetRestartCount,
97
+ resolveClaudeBinary,
98
+ restartEgressSidecar,
99
+ rotatePaneLogForDayRollover,
100
+ rotateSessionForWedge,
101
+ sha256,
102
+ sharedBusyBuckets,
103
+ startOpencodeSession,
104
+ startPersistentSession,
105
+ stopAllSessionsAndWait,
106
+ stopOpencodeSession,
107
+ stopPersistentSession,
108
+ takeWatchdogGiveUpCount,
109
+ takeZombieDetection,
110
+ toOpencodeModel,
111
+ writeEgressAllowlist
112
+ } from "../chunk-6NVRWZ5W.js";
64
113
  import {
65
114
  ACCOUNT_ENFORCEMENT_MARKER_FILENAME,
66
115
  AnchorSessionClient,
67
116
  CLAUDE_MD_MAX_CHARS,
68
117
  CONVERSATION_FAILURE_CATEGORIES,
69
- ChildProcessError,
70
118
  DEFAULT_FRAMEWORK,
71
119
  DEFAULT_NEIGHBOURHOOD_MS,
72
120
  FLAGS_SCHEMA_VERSION,
@@ -82,24 +130,18 @@ import {
82
130
  SUPPRESS_SENTINEL,
83
131
  StreamEncoder,
84
132
  UNKNOWN_RATE_LIMIT,
85
- agentRuntimeKey,
86
133
  appendDmFooter,
87
134
  attributeTranscriptUsageByRun,
88
- buildEgressAllowlist,
89
135
  buildFailureCategoryPromptLines,
90
136
  buildScheduledTaskContextBlocks,
91
- checkChannelInputs,
92
137
  classifyActor,
93
138
  classifyCursorAdvance,
94
139
  classifyOutput,
95
140
  classifyTranscriptRateLimit,
96
141
  coerceOnboardingState,
97
- creditWatchdogGiveUpCount,
98
142
  cursorAdvanceCounterKey,
99
143
  describeOnboardingChannel,
100
- egressMode,
101
144
  estimateActiveTasksTokens,
102
- execFilePromiseLong,
103
145
  extractFrontmatter,
104
146
  extractQualifyingTurns,
105
147
  findRunMarker,
@@ -109,16 +151,6 @@ import {
109
151
  formatRunMarker,
110
152
  getFramework,
111
153
  getIntegration,
112
- getLastFailureContext,
113
- getOpencodeActivityAgeSeconds,
114
- getOpencodeSessionState,
115
- getOpencodeTurnHealth,
116
- getProjectDir,
117
- getSessionState,
118
- hashFile,
119
- injectMessage,
120
- injectMessageWithStatus,
121
- injectOpencodeMessage,
122
154
  isAgentIdle,
123
155
  isAgentTimezoneOverrideExpired,
124
156
  isBareAck,
@@ -129,69 +161,39 @@ import {
129
161
  isEmptyTotals,
130
162
  isForcedUpdatePastDeadline,
131
163
  isOnboardingArea,
132
- isOpencodeSessionHealthy,
133
164
  isParseError,
134
165
  isResolveError,
135
166
  isSelfCompletion,
136
- isSessionHealthy,
137
167
  isStaleForToday,
138
168
  isSystemInjectedContent,
139
169
  isUnsetTimezone,
140
170
  isVacuousDeliverReason,
141
- isolationMode,
142
171
  laneTagFragment,
143
- log,
144
- mergeOpencodeConfigArtifact,
145
172
  minutesSinceLocalMidnight,
146
- paneLogPath,
147
173
  parseDeliverAssertion,
148
174
  parseDeliveryTarget,
149
- parseEnvIntegrations,
150
175
  parseTranscriptUsage,
151
176
  parseUsageBanner,
152
177
  peekCurrentSession,
153
178
  pickNewerClassification,
154
- prepareForRespawn,
155
- readChannelServerEnv,
156
- readDirectChatSessionState,
157
- readOpencodePaneLogTail,
158
- readPaneLogTail,
159
- readProvisionedOpencodeModel,
160
- reloadEgressSidecar,
161
179
  remoteMcpServerKey,
162
- resetRestartCount,
163
180
  resolveAgentTimezone,
164
181
  resolveAvatarEnvUrl,
165
182
  resolveChannels,
166
- resolveClaudeBinary,
167
183
  resolveDmTarget,
168
- restartEgressSidecar,
169
- rotatePaneLogForDayRollover,
170
- rotateSessionForWedge,
171
184
  serializeAccountEnforcementMarker,
172
185
  sessionTranscriptDir,
173
- sha256,
174
- sharedBusyBuckets,
175
- startOpencodeSession,
176
- startPersistentSession,
177
- stopAllSessionsAndWait,
178
- stopOpencodeSession,
179
- stopPersistentSession,
180
186
  subagentActivityAgeSeconds,
181
187
  sumTranscriptUsageInWindow,
182
- takeWatchdogGiveUpCount,
183
- takeZombieDetection,
184
- toOpencodeModel,
185
- transcriptActivityAgeSeconds,
186
- writeEgressAllowlist
187
- } from "../chunk-TKWDYMM3.js";
188
+ transcriptActivityAgeSeconds
189
+ } from "../chunk-3PNRUCHD.js";
188
190
  import {
189
191
  reapOrphanChannelMcps
190
192
  } from "../chunk-XWVM4KPK.js";
191
193
 
192
194
  // src/lib/manager-worker.ts
193
195
  import { createHash as createHash17 } from "crypto";
194
- import { readFileSync as readFileSync27, writeFileSync as writeFileSync14, mkdirSync as mkdirSync11, existsSync as existsSync14, rmSync as rmSync5, readdirSync as readdirSync9, statSync as statSync8, copyFileSync } from "fs";
196
+ import { readFileSync as readFileSync28, writeFileSync as writeFileSync14, mkdirSync as mkdirSync11, existsSync as existsSync15, rmSync as rmSync5, readdirSync as readdirSync9, statSync as statSync8, copyFileSync } from "fs";
195
197
  import { execFileSync as syncExecFile } from "child_process";
196
198
  import { join as join34, dirname as dirname9, delimiter as pathDelimiter } from "path";
197
199
  import { homedir as homedir16 } from "os";
@@ -7576,6 +7578,147 @@ function stopPaneOccupancySampler() {
7576
7578
  timer = null;
7577
7579
  }
7578
7580
 
7581
+ // src/lib/pid-pressure-sampler.ts
7582
+ import { execFileSync as execFileSync2 } from "child_process";
7583
+ import { existsSync as existsSync12, readFileSync as readFileSync24 } from "fs";
7584
+ var SAMPLE_INTERVAL_MS2 = 3e4;
7585
+ function warnFraction() {
7586
+ const raw = Number(process.env.AGT_PID_PRESSURE_WARN_FRACTION);
7587
+ if (!Number.isFinite(raw) || raw <= 0 || raw > 1) return 0.8;
7588
+ return raw;
7589
+ }
7590
+ function configuredCeiling() {
7591
+ const raw = Number(process.env.AGT_ISOLATION_PIDS);
7592
+ return Number.isFinite(raw) && raw > 0 ? raw : 512;
7593
+ }
7594
+ function readTextReal(path) {
7595
+ try {
7596
+ return readFileSync24(path, "utf-8");
7597
+ } catch {
7598
+ return null;
7599
+ }
7600
+ }
7601
+ var cgroupDirCache = /* @__PURE__ */ new Map();
7602
+ var resolveRetryAfter = /* @__PURE__ */ new Map();
7603
+ var RESOLVE_RETRY_BACKOFF_MS = 5 * 6e4;
7604
+ function resolveCgroupDirReal(codeName, deps = {}) {
7605
+ const exists = deps.exists ?? existsSync12;
7606
+ const inspectId = deps.inspectId ?? inspectContainerId;
7607
+ const now = deps.now ?? Date.now;
7608
+ const cached = cgroupDirCache.get(codeName);
7609
+ if (cached && exists(cached)) {
7610
+ resolveRetryAfter.delete(codeName);
7611
+ return cached;
7612
+ }
7613
+ const retryAt = resolveRetryAfter.get(codeName);
7614
+ if (retryAt != null && now() < retryAt) return null;
7615
+ if (cached) cgroupDirCache.delete(codeName);
7616
+ const id = inspectId(codeName);
7617
+ if (id == null || !/^[0-9a-f]{12,64}$/.test(id)) {
7618
+ resolveRetryAfter.set(codeName, now() + RESOLVE_RETRY_BACKOFF_MS);
7619
+ return null;
7620
+ }
7621
+ for (const dir of [
7622
+ `/sys/fs/cgroup/system.slice/docker-${id}.scope`,
7623
+ `/sys/fs/cgroup/docker/${id}`
7624
+ ]) {
7625
+ if (exists(dir)) {
7626
+ cgroupDirCache.set(codeName, dir);
7627
+ resolveRetryAfter.delete(codeName);
7628
+ return dir;
7629
+ }
7630
+ }
7631
+ resolveRetryAfter.set(codeName, now() + RESOLVE_RETRY_BACKOFF_MS);
7632
+ return null;
7633
+ }
7634
+ function inspectContainerId(codeName) {
7635
+ try {
7636
+ return execFileSync2("docker", ["inspect", "-f", "{{.Id}}", `agt-${codeName}`], {
7637
+ encoding: "utf-8",
7638
+ timeout: 5e3,
7639
+ stdio: ["ignore", "pipe", "ignore"]
7640
+ }).trim();
7641
+ } catch {
7642
+ return null;
7643
+ }
7644
+ }
7645
+ function countDefunct(cgroupDir, readText) {
7646
+ const procs = readText(`${cgroupDir}/cgroup.procs`);
7647
+ if (procs == null) return 0;
7648
+ let defunct = 0;
7649
+ for (const line of procs.split("\n")) {
7650
+ const pid = line.trim();
7651
+ if (!pid) continue;
7652
+ const stat2 = readText(`/proc/${pid}/stat`);
7653
+ if (stat2 == null) continue;
7654
+ const close = stat2.lastIndexOf(")");
7655
+ if (close < 0) continue;
7656
+ const state8 = stat2.slice(close + 1).trim().charAt(0);
7657
+ if (state8 === "Z") defunct += 1;
7658
+ }
7659
+ return defunct;
7660
+ }
7661
+ function samplePidPressureFor(codeName, io = {}) {
7662
+ const isolated = io.isolatedFor?.(codeName) ?? isolationMode(codeName) === "docker";
7663
+ if (!isolated) return null;
7664
+ const readText = io.readText ?? readTextReal;
7665
+ const resolveDir = io.resolveCgroupDir ?? resolveCgroupDirReal;
7666
+ const dir = resolveDir(codeName);
7667
+ if (dir == null) return null;
7668
+ const currentRaw = readText(`${dir}/pids.current`)?.trim();
7669
+ if (currentRaw == null || currentRaw === "") return null;
7670
+ const current = Number(currentRaw);
7671
+ if (!Number.isFinite(current) || current < 0) return null;
7672
+ const maxParsed = Number(readText(`${dir}/pids.max`)?.trim());
7673
+ const max = Number.isFinite(maxParsed) && maxParsed > 0 ? maxParsed : null;
7674
+ const ceiling = configuredCeiling();
7675
+ const warnAt = Math.floor(ceiling * warnFraction());
7676
+ return {
7677
+ current,
7678
+ max,
7679
+ ceiling,
7680
+ defunct: countDefunct(dir, readText),
7681
+ warnAt,
7682
+ overThreshold: current >= warnAt
7683
+ };
7684
+ }
7685
+ var lastSample = /* @__PURE__ */ new Map();
7686
+ function samplePidPressureOnce(codeNames, io = {}) {
7687
+ const seen = /* @__PURE__ */ new Set();
7688
+ for (const codeName of codeNames) {
7689
+ seen.add(codeName);
7690
+ const sample = samplePidPressureFor(codeName, io);
7691
+ if (sample) lastSample.set(codeName, sample);
7692
+ else lastSample.delete(codeName);
7693
+ }
7694
+ for (const codeName of [...lastSample.keys()]) {
7695
+ if (!seen.has(codeName)) {
7696
+ lastSample.delete(codeName);
7697
+ cgroupDirCache.delete(codeName);
7698
+ resolveRetryAfter.delete(codeName);
7699
+ }
7700
+ }
7701
+ }
7702
+ function pidPressureFor(codeName) {
7703
+ return lastSample.get(codeName) ?? null;
7704
+ }
7705
+ var timer2 = null;
7706
+ function startPidPressureSampler(liveAgents) {
7707
+ if (timer2) return;
7708
+ timer2 = setInterval(() => {
7709
+ try {
7710
+ samplePidPressureOnce(liveAgents());
7711
+ } catch {
7712
+ }
7713
+ }, SAMPLE_INTERVAL_MS2);
7714
+ timer2.unref?.();
7715
+ }
7716
+ function stopPidPressureSampler() {
7717
+ if (!timer2) return;
7718
+ clearInterval(timer2);
7719
+ timer2 = null;
7720
+ }
7721
+
7579
7722
  // src/lib/opencode-slack-ingest.ts
7580
7723
  import { createHash as createHash14 } from "crypto";
7581
7724
 
@@ -8702,7 +8845,7 @@ async function fireOpencodeScheduledTask(agent, task) {
8702
8845
 
8703
8846
  // src/lib/opencode-telegram-ingest.ts
8704
8847
  import { createHash as createHash16 } from "crypto";
8705
- import { existsSync as existsSync12, mkdirSync as mkdirSync8, readFileSync as readFileSync24, renameSync as renameSync5, unlinkSync as unlinkSync3, writeFileSync as writeFileSync11 } from "fs";
8848
+ import { existsSync as existsSync13, mkdirSync as mkdirSync8, readFileSync as readFileSync25, renameSync as renameSync5, unlinkSync as unlinkSync3, writeFileSync as writeFileSync11 } from "fs";
8706
8849
  import { randomUUID } from "crypto";
8707
8850
  import { join as join31 } from "path";
8708
8851
 
@@ -9261,7 +9404,7 @@ function createFileOffsetStore(codeName, log2, currentBotId) {
9261
9404
  load() {
9262
9405
  if (!filePath) return 0;
9263
9406
  try {
9264
- const parsed = JSON.parse(readFileSync24(filePath, "utf-8"));
9407
+ const parsed = JSON.parse(readFileSync25(filePath, "utf-8"));
9265
9408
  if (currentBotId != null && typeof parsed?.bot_id === "number" && parsed.bot_id !== currentBotId) {
9266
9409
  log2(`[telegram-ingest:${codeName}] offset cursor belongs to a different bot; ignoring (bot swap)`);
9267
9410
  return 0;
@@ -9294,7 +9437,7 @@ function createFileOffsetStore(codeName, log2, currentBotId) {
9294
9437
  } catch (err) {
9295
9438
  log2(`[telegram-ingest:${codeName}] offset persist failed: ${err instanceof Error ? err.message : String(err)}`);
9296
9439
  try {
9297
- if (existsSync12(tmpPath)) unlinkSync3(tmpPath);
9440
+ if (existsSync13(tmpPath)) unlinkSync3(tmpPath);
9298
9441
  } catch {
9299
9442
  }
9300
9443
  }
@@ -9531,7 +9674,7 @@ function partitionActionableByPoison(actionable, states, config2) {
9531
9674
  }
9532
9675
 
9533
9676
  // src/lib/restart-flags.ts
9534
- import { existsSync as existsSync13, mkdirSync as mkdirSync9, readdirSync as readdirSync7, readFileSync as readFileSync25, renameSync as renameSync6, rmSync as rmSync4, writeFileSync as writeFileSync12 } from "fs";
9677
+ import { existsSync as existsSync14, mkdirSync as mkdirSync9, readdirSync as readdirSync7, readFileSync as readFileSync26, renameSync as renameSync6, rmSync as rmSync4, writeFileSync as writeFileSync12 } from "fs";
9535
9678
  import { homedir as homedir15 } from "os";
9536
9679
  import { join as join32 } from "path";
9537
9680
  import { randomUUID as randomUUID2 } from "crypto";
@@ -9543,12 +9686,12 @@ function flagPath(codeName) {
9543
9686
  }
9544
9687
  function readRestartFlags() {
9545
9688
  const dir = restartFlagsDir();
9546
- if (!existsSync13(dir)) return [];
9689
+ if (!existsSync14(dir)) return [];
9547
9690
  const out = [];
9548
9691
  for (const entry of readdirSync7(dir)) {
9549
9692
  if (!entry.endsWith(".flag")) continue;
9550
9693
  try {
9551
- const raw = readFileSync25(join32(dir, entry), "utf8");
9694
+ const raw = readFileSync26(join32(dir, entry), "utf8");
9552
9695
  const parsed = JSON.parse(raw);
9553
9696
  if (typeof parsed.codeName !== "string" || parsed.codeName.length === 0) {
9554
9697
  parsed.codeName = entry.replace(/\.flag$/, "");
@@ -9566,7 +9709,7 @@ function readRestartFlags() {
9566
9709
  }
9567
9710
  function deleteRestartFlag(codeName) {
9568
9711
  const path = flagPath(codeName);
9569
- if (existsSync13(path)) {
9712
+ if (existsSync14(path)) {
9570
9713
  rmSync4(path, { force: true });
9571
9714
  }
9572
9715
  }
@@ -9666,7 +9809,7 @@ async function sendError(flag, opts, text) {
9666
9809
  }
9667
9810
 
9668
9811
  // src/lib/restart-context.ts
9669
- import { readdirSync as readdirSync8, readFileSync as readFileSync26, writeFileSync as writeFileSync13, mkdirSync as mkdirSync10, unlinkSync as unlinkSync4 } from "fs";
9812
+ import { readdirSync as readdirSync8, readFileSync as readFileSync27, writeFileSync as writeFileSync13, mkdirSync as mkdirSync10, unlinkSync as unlinkSync4 } from "fs";
9670
9813
  import { dirname as dirname8, join as join33 } from "path";
9671
9814
  var SLACK_PENDING_INBOUND_DIRNAME = "slack-pending-inbound";
9672
9815
  var SLACK_RESTART_CONTEXT_DIRNAME = "slack-restart-context";
@@ -9724,7 +9867,7 @@ function safeReaddir(dir) {
9724
9867
  }
9725
9868
  function readStrandedMarker(path) {
9726
9869
  try {
9727
- const parsed = JSON.parse(readFileSync26(path, "utf-8"));
9870
+ const parsed = JSON.parse(readFileSync27(path, "utf-8"));
9728
9871
  if (typeof parsed.channel === "string" && typeof parsed.thread_ts === "string") {
9729
9872
  return { channel: parsed.channel, thread_ts: parsed.thread_ts };
9730
9873
  }
@@ -10867,7 +11010,7 @@ function scheduleSessionRestart(codeName, delayMs, reason, breakerReason = "hot-
10867
11010
  clearTimeout(existing.timer);
10868
11011
  log(`[hot-reload] Coalesced restart for '${codeName}': replacing pending timer with ${reason}`);
10869
11012
  }
10870
- const timer2 = setTimeout(() => {
11013
+ const timer3 = setTimeout(() => {
10871
11014
  pendingSessionRestarts.delete(codeName);
10872
11015
  const gate = restartGateFor(codeName, breakerReason);
10873
11016
  if (gate !== "bypass" && gate !== "proceed") {
@@ -10945,8 +11088,8 @@ function scheduleSessionRestart(codeName, delayMs, reason, breakerReason = "hot-
10945
11088
  void respawnAgentAfterMcpStop(codeName, reason);
10946
11089
  }
10947
11090
  }, delayMs);
10948
- timer2.unref?.();
10949
- pendingSessionRestarts.set(codeName, { timer: timer2, reason, breakerReason, beforeStop, auditDetail });
11091
+ timer3.unref?.();
11092
+ pendingSessionRestarts.set(codeName, { timer: timer3, reason, breakerReason, beforeStop, auditDetail });
10950
11093
  }
10951
11094
  function cancelPendingSessionRestart(codeName) {
10952
11095
  pendingRestartVerifications.delete(codeName);
@@ -11295,7 +11438,7 @@ var runningChannelSecretHashes = /* @__PURE__ */ new Map();
11295
11438
  var sessionLaunchManagedStructure = /* @__PURE__ */ new Map();
11296
11439
  function projectMcpHash(_codeName, projectDir) {
11297
11440
  try {
11298
- const raw = readFileSync27(join34(projectDir, ".mcp.json"), "utf-8");
11441
+ const raw = readFileSync28(join34(projectDir, ".mcp.json"), "utf-8");
11299
11442
  return createHash17("sha256").update(canonicalJson(JSON.parse(raw))).digest("hex");
11300
11443
  } catch {
11301
11444
  return null;
@@ -11303,7 +11446,7 @@ function projectMcpHash(_codeName, projectDir) {
11303
11446
  }
11304
11447
  function projectMcpKeys(_codeName, projectDir) {
11305
11448
  try {
11306
- const raw = readFileSync27(join34(projectDir, ".mcp.json"), "utf-8");
11449
+ const raw = readFileSync28(join34(projectDir, ".mcp.json"), "utf-8");
11307
11450
  const parsed = JSON.parse(raw);
11308
11451
  const servers = parsed.mcpServers;
11309
11452
  if (!servers || typeof servers !== "object") return /* @__PURE__ */ new Set();
@@ -11321,7 +11464,7 @@ function seedSessionLaunchBaselines(codeName, projectDir) {
11321
11464
  else runningMcpServerKeys.delete(codeName);
11322
11465
  let launchStructure = null;
11323
11466
  try {
11324
- const raw = readFileSync27(join34(projectDir, ".mcp.json"), "utf-8");
11467
+ const raw = readFileSync28(join34(projectDir, ".mcp.json"), "utf-8");
11325
11468
  launchStructure = managedMcpStructureHashFromFile(
11326
11469
  JSON.parse(raw),
11327
11470
  isManagedMcpServerKey
@@ -11443,7 +11586,7 @@ async function runAgentSessionToolBindProbes(agent, integrations, projectDir, op
11443
11586
  if (result && result.rebindCandidates.length > 0 && hostFlagStore().getBoolean("session-tool-rebind")) {
11444
11587
  let mcpJsonForRebind = null;
11445
11588
  try {
11446
- mcpJsonForRebind = JSON.parse(readFileSync27(join34(projectDir, ".mcp.json"), "utf-8"));
11589
+ mcpJsonForRebind = JSON.parse(readFileSync28(join34(projectDir, ".mcp.json"), "utf-8"));
11447
11590
  } catch {
11448
11591
  mcpJsonForRebind = null;
11449
11592
  }
@@ -11588,7 +11731,7 @@ function checkMcpConfigDriftAndScheduleRestart(codeName, projectDir) {
11588
11731
  function projectChannelSecretHash(projectDir) {
11589
11732
  try {
11590
11733
  const entries = parseEnvIntegrations(
11591
- readFileSync27(join34(projectDir, ".env.integrations"), "utf-8")
11734
+ readFileSync28(join34(projectDir, ".env.integrations"), "utf-8")
11592
11735
  );
11593
11736
  return channelSecretValueHash(entries, CHANNEL_SECRET_ENV_KEYS);
11594
11737
  } catch {
@@ -11684,10 +11827,10 @@ var agentRestartTimezoneInputs = /* @__PURE__ */ new Map();
11684
11827
  var lastVersionCheckAt = 0;
11685
11828
  var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
11686
11829
  var lastResponsivenessProbeAt = 0;
11687
- var agtCliVersion = true ? "0.28.593" : "dev";
11688
- function resolveBrewPath(execFileSync2) {
11830
+ var agtCliVersion = true ? "0.28.595" : "dev";
11831
+ function resolveBrewPath(execFileSync3) {
11689
11832
  try {
11690
- const out = execFileSync2("which", ["brew"], { timeout: 5e3 }).toString().trim();
11833
+ const out = execFileSync3("which", ["brew"], { timeout: 5e3 }).toString().trim();
11691
11834
  if (out) return out;
11692
11835
  } catch {
11693
11836
  }
@@ -11697,19 +11840,19 @@ function resolveBrewPath(execFileSync2) {
11697
11840
  "/usr/local/bin/brew"
11698
11841
  ];
11699
11842
  for (const path of fallbacks) {
11700
- if (existsSync14(path)) return path;
11843
+ if (existsSync15(path)) return path;
11701
11844
  }
11702
11845
  return null;
11703
11846
  }
11704
- function claudeBinaryInstalled(execFileSync2) {
11847
+ function claudeBinaryInstalled(execFileSync3) {
11705
11848
  const canonical = [
11706
11849
  "/home/linuxbrew/.linuxbrew/bin/claude",
11707
11850
  "/opt/homebrew/bin/claude",
11708
11851
  "/usr/local/bin/claude"
11709
11852
  ];
11710
- if (canonical.some((path) => existsSync14(path))) return true;
11853
+ if (canonical.some((path) => existsSync15(path))) return true;
11711
11854
  try {
11712
- execFileSync2("which", ["claude"], { timeout: 5e3 });
11855
+ execFileSync3("which", ["claude"], { timeout: 5e3 });
11713
11856
  return true;
11714
11857
  } catch {
11715
11858
  return false;
@@ -11743,9 +11886,9 @@ async function ensureToolkitCli(toolkitSlug) {
11743
11886
  }
11744
11887
  const { binary, installer, package: pkg, script } = integration.cli_tool;
11745
11888
  const resolvedInstaller = installer ?? "manual";
11746
- const { execFileSync: execFileSync2, execSync } = await import("child_process");
11889
+ const { execFileSync: execFileSync3, execSync } = await import("child_process");
11747
11890
  try {
11748
- execFileSync2("which", [binary], { timeout: 5e3, stdio: "pipe" });
11891
+ execFileSync3("which", [binary], { timeout: 5e3, stdio: "pipe" });
11749
11892
  toolkitCliEnsured.add(toolkitSlug);
11750
11893
  toolkitCliRetryAfter.delete(toolkitSlug);
11751
11894
  toolkitCliFailureCount.delete(toolkitSlug);
@@ -11766,14 +11909,14 @@ async function ensureToolkitCli(toolkitSlug) {
11766
11909
  return;
11767
11910
  }
11768
11911
  log(`[toolkit-install] ${toolkitSlug}: installing via npm (${pkg})\u2026`);
11769
- execFileSync2("npm", ["install", "-g", pkg], { timeout: 18e4, stdio: "pipe" });
11912
+ execFileSync3("npm", ["install", "-g", pkg], { timeout: 18e4, stdio: "pipe" });
11770
11913
  } else if (resolvedInstaller === "brew") {
11771
11914
  if (!pkg) {
11772
11915
  log(`[toolkit-install] ${toolkitSlug}: installer=brew but no package declared`);
11773
11916
  toolkitCliEnsured.add(toolkitSlug);
11774
11917
  return;
11775
11918
  }
11776
- const brewPath = resolveBrewPath(execFileSync2);
11919
+ const brewPath = resolveBrewPath(execFileSync3);
11777
11920
  if (!brewPath) {
11778
11921
  log(`[toolkit-install] ${toolkitSlug}: installer=brew but Homebrew not available \u2014 install manually: brew install ${pkg}`);
11779
11922
  toolkitCliEnsured.add(toolkitSlug);
@@ -11783,9 +11926,9 @@ async function ensureToolkitCli(toolkitSlug) {
11783
11926
  const isRoot = typeof process.getuid === "function" && process.getuid() === 0;
11784
11927
  log(`[toolkit-install] ${toolkitSlug}: installing via brew (${pkg})\u2026`);
11785
11928
  if (isRoot) {
11786
- execFileSync2("sudo", ["-u", "ec2-user", "-H", brewPath, "install", pkg], { timeout: 18e4, stdio: "pipe", cwd: "/tmp" });
11929
+ execFileSync3("sudo", ["-u", "ec2-user", "-H", brewPath, "install", pkg], { timeout: 18e4, stdio: "pipe", cwd: "/tmp" });
11787
11930
  } else {
11788
- execFileSync2(brewPath, ["install", pkg], { timeout: 18e4, stdio: "pipe" });
11931
+ execFileSync3(brewPath, ["install", pkg], { timeout: 18e4, stdio: "pipe" });
11789
11932
  }
11790
11933
  } else if (resolvedInstaller === "script") {
11791
11934
  if (!script) {
@@ -11807,7 +11950,7 @@ async function ensureToolkitCli(toolkitSlug) {
11807
11950
  process.env.PATH = `${brewBinDir}:${process.env.PATH ?? ""}`;
11808
11951
  }
11809
11952
  try {
11810
- execFileSync2("which", [binary], { timeout: 5e3, stdio: "pipe" });
11953
+ execFileSync3("which", [binary], { timeout: 5e3, stdio: "pipe" });
11811
11954
  log(`[toolkit-install] ${toolkitSlug}: installed \u2014 ${binary} now on PATH`);
11812
11955
  toolkitCliEnsured.add(toolkitSlug);
11813
11956
  toolkitCliRetryAfter.delete(toolkitSlug);
@@ -11855,16 +11998,16 @@ async function ensureIsolationImage(imageUri) {
11855
11998
  }
11856
11999
  isolationImageInFlight.add(imageUri);
11857
12000
  try {
11858
- const { execFileSync: execFileSync2 } = await import("child_process");
12001
+ const { execFileSync: execFileSync3 } = await import("child_process");
11859
12002
  try {
11860
- execFileSync2("which", ["docker"], { timeout: 5e3, stdio: "pipe" });
12003
+ execFileSync3("which", ["docker"], { timeout: 5e3, stdio: "pipe" });
11861
12004
  } catch {
11862
12005
  recordIsolationImageFailure(imageUri, `'docker' not found on host - required to pull the isolation image (install it, then the manager retries)`);
11863
12006
  return;
11864
12007
  }
11865
12008
  const hasAws = (() => {
11866
12009
  try {
11867
- execFileSync2("which", ["aws"], { timeout: 5e3, stdio: "pipe" });
12010
+ execFileSync3("which", ["aws"], { timeout: 5e3, stdio: "pipe" });
11868
12011
  return true;
11869
12012
  } catch {
11870
12013
  return false;
@@ -11873,11 +12016,11 @@ async function ensureIsolationImage(imageUri) {
11873
12016
  if (isPublic) {
11874
12017
  if (hasAws) {
11875
12018
  try {
11876
- const password = execFileSync2("aws", ["ecr-public", "get-login-password", "--region", "us-east-1"], {
12019
+ const password = execFileSync3("aws", ["ecr-public", "get-login-password", "--region", "us-east-1"], {
11877
12020
  timeout: 3e4,
11878
12021
  stdio: ["ignore", "pipe", "pipe"]
11879
12022
  }).toString().trim();
11880
- execFileSync2("docker", ["login", "--username", "AWS", "--password-stdin", "public.ecr.aws"], {
12023
+ execFileSync3("docker", ["login", "--username", "AWS", "--password-stdin", "public.ecr.aws"], {
11881
12024
  input: password,
11882
12025
  timeout: 3e4,
11883
12026
  stdio: ["pipe", "pipe", "pipe"]
@@ -11892,11 +12035,11 @@ async function ensureIsolationImage(imageUri) {
11892
12035
  return;
11893
12036
  }
11894
12037
  try {
11895
- const password = execFileSync2("aws", ["ecr", "get-login-password", "--region", privRegion], {
12038
+ const password = execFileSync3("aws", ["ecr", "get-login-password", "--region", privRegion], {
11896
12039
  timeout: 3e4,
11897
12040
  stdio: ["ignore", "pipe", "pipe"]
11898
12041
  }).toString().trim();
11899
- execFileSync2("docker", ["login", "--username", "AWS", "--password-stdin", registry], {
12042
+ execFileSync3("docker", ["login", "--username", "AWS", "--password-stdin", registry], {
11900
12043
  input: password,
11901
12044
  timeout: 3e4,
11902
12045
  stdio: ["pipe", "pipe", "pipe"]
@@ -11977,7 +12120,7 @@ function runAsync(cmd, args, opts) {
11977
12120
  let stdout = "";
11978
12121
  let stderr = "";
11979
12122
  let settled = false;
11980
- const timer2 = setTimeout(() => {
12123
+ const timer3 = setTimeout(() => {
11981
12124
  child.kill("SIGTERM");
11982
12125
  if (settled) return;
11983
12126
  settled = true;
@@ -11998,13 +12141,13 @@ function runAsync(cmd, args, opts) {
11998
12141
  child.on("error", (err) => {
11999
12142
  if (settled) return;
12000
12143
  settled = true;
12001
- clearTimeout(timer2);
12144
+ clearTimeout(timer3);
12002
12145
  reject(err);
12003
12146
  });
12004
12147
  child.on("close", (code) => {
12005
12148
  if (settled) return;
12006
12149
  settled = true;
12007
- clearTimeout(timer2);
12150
+ clearTimeout(timer3);
12008
12151
  resolve({ code: code ?? -1, stdout, stderr });
12009
12152
  });
12010
12153
  }).catch(reject);
@@ -12016,8 +12159,8 @@ function claudeManagedSettingsPath() {
12016
12159
  function ensureClaudeManagedSettings(path = claudeManagedSettingsPath()) {
12017
12160
  try {
12018
12161
  let settings = {};
12019
- if (existsSync14(path)) {
12020
- const raw = readFileSync27(path, "utf-8").trim();
12162
+ if (existsSync15(path)) {
12163
+ const raw = readFileSync28(path, "utf-8").trim();
12021
12164
  if (raw) {
12022
12165
  let parsed;
12023
12166
  try {
@@ -12045,11 +12188,11 @@ function ensureClaudeManagedSettings(path = claudeManagedSettingsPath()) {
12045
12188
  }
12046
12189
  var OPENCODE_NPM_VERSION = "1.18.3";
12047
12190
  async function ensureOpencodeBinary() {
12048
- const { execFileSync: execFileSync2 } = await import("child_process");
12191
+ const { execFileSync: execFileSync3 } = await import("child_process");
12049
12192
  const bin = process.env["AGT_OPENCODE_BIN"]?.trim() || "opencode";
12050
12193
  const probe = () => {
12051
12194
  try {
12052
- execFileSync2(bin, ["--version"], { stdio: "ignore", timeout: 1e4 });
12195
+ execFileSync3(bin, ["--version"], { stdio: "ignore", timeout: 1e4 });
12053
12196
  return true;
12054
12197
  } catch {
12055
12198
  return false;
@@ -12070,7 +12213,7 @@ async function ensureOpencodeBinary() {
12070
12213
  return false;
12071
12214
  }
12072
12215
  try {
12073
- const prefix = execFileSync2("npm", ["prefix", "-g"], { encoding: "utf-8", timeout: 1e4 }).trim();
12216
+ const prefix = execFileSync3("npm", ["prefix", "-g"], { encoding: "utf-8", timeout: 1e4 }).trim();
12074
12217
  if (prefix) {
12075
12218
  const npmBin = join34(prefix, "bin");
12076
12219
  const current = (process.env.PATH ?? "").split(pathDelimiter);
@@ -12102,8 +12245,8 @@ async function ensureFrameworkBinary(frameworkId) {
12102
12245
  }
12103
12246
  frameworkBinaryChecked.add(frameworkId);
12104
12247
  lastManagedSettingsStatus = ensureClaudeManagedSettings();
12105
- const { execFileSync: execFileSync2 } = await import("child_process");
12106
- const brewPath = resolveBrewPath(execFileSync2);
12248
+ const { execFileSync: execFileSync3 } = await import("child_process");
12249
+ const brewPath = resolveBrewPath(execFileSync3);
12107
12250
  if (!brewPath) {
12108
12251
  log("Homebrew not found (no `brew` on PATH, no /home/linuxbrew/.linuxbrew/bin/brew). Cannot auto-install Claude Code. Install manually: https://claude.ai/download");
12109
12252
  return;
@@ -12116,7 +12259,7 @@ async function ensureFrameworkBinary(frameworkId) {
12116
12259
  }
12117
12260
  return runAsync(brewPath, args, opts);
12118
12261
  };
12119
- const claudeExists = claudeBinaryInstalled(execFileSync2);
12262
+ const claudeExists = claudeBinaryInstalled(execFileSync3);
12120
12263
  if (!claudeExists) {
12121
12264
  log(`Claude Code binary not found \u2014 installing via Homebrew${isRoot ? " (as ec2-user via sudo)" : ""}...`);
12122
12265
  try {
@@ -12133,7 +12276,7 @@ async function ensureFrameworkBinary(frameworkId) {
12133
12276
  if (!process.env.PATH?.split(":").includes(brewBinDir)) {
12134
12277
  process.env.PATH = `${brewBinDir}:${process.env.PATH ?? ""}`;
12135
12278
  }
12136
- if (existsSync14("/home/linuxbrew/.linuxbrew/bin/claude")) {
12279
+ if (existsSync15("/home/linuxbrew/.linuxbrew/bin/claude")) {
12137
12280
  log("Claude Code installed successfully");
12138
12281
  } else {
12139
12282
  log("Claude Code install completed but binary not found at expected path \u2014 check brew logs");
@@ -12151,13 +12294,13 @@ async function maybeUpgradeClaudeCode() {
12151
12294
  }
12152
12295
  claudeCodeUpgradeInFlight = true;
12153
12296
  stampClaudeCodeUpgradeMarker();
12154
- const { execFileSync: execFileSync2 } = await import("child_process");
12155
- const brewPath = resolveBrewPath(execFileSync2);
12297
+ const { execFileSync: execFileSync3 } = await import("child_process");
12298
+ const brewPath = resolveBrewPath(execFileSync3);
12156
12299
  if (!brewPath) {
12157
12300
  claudeCodeUpgradeInFlight = false;
12158
12301
  return;
12159
12302
  }
12160
- if (!claudeBinaryInstalled(execFileSync2)) {
12303
+ if (!claudeBinaryInstalled(execFileSync3)) {
12161
12304
  claudeCodeUpgradeInFlight = false;
12162
12305
  return;
12163
12306
  }
@@ -12241,8 +12384,8 @@ async function checkAndUpdateCli(opts) {
12241
12384
  }
12242
12385
  }
12243
12386
  async function checkAndUpdateCliViaBrew(force = false) {
12244
- const { execFileSync: execFileSync2 } = await import("child_process");
12245
- const brewPath = resolveBrewPath(execFileSync2);
12387
+ const { execFileSync: execFileSync3 } = await import("child_process");
12388
+ const brewPath = resolveBrewPath(execFileSync3);
12246
12389
  if (!brewPath) return "noop";
12247
12390
  {
12248
12391
  const brewPinRaw = resolveAgtCliPinRaw();
@@ -12269,13 +12412,13 @@ async function checkAndUpdateCliViaBrew(force = false) {
12269
12412
  }
12270
12413
  let metadataFresh = true;
12271
12414
  try {
12272
- execFileSync2(brewPath, ["update", "--quiet"], { timeout: 6e4, stdio: "pipe" });
12415
+ execFileSync3(brewPath, ["update", "--quiet"], { timeout: 6e4, stdio: "pipe" });
12273
12416
  } catch (err) {
12274
12417
  metadataFresh = false;
12275
12418
  log(`[self-update] brew update failed (continuing with stale cache): ${err.message}`);
12276
12419
  }
12277
12420
  try {
12278
- const outdated = execFileSync2(brewPath, ["outdated", "--json=v2"], {
12421
+ const outdated = execFileSync3(brewPath, ["outdated", "--json=v2"], {
12279
12422
  timeout: 3e4,
12280
12423
  encoding: "utf-8"
12281
12424
  });
@@ -12308,7 +12451,7 @@ async function checkAndUpdateCliViaBrew(force = false) {
12308
12451
  }
12309
12452
  log(`[self-update] agt CLI update available: ${installed} \u2192 ${latest}. Upgrading via brew${force ? " (forced \u2014 Update CLI now)" : ""}...`);
12310
12453
  try {
12311
- execFileSync2(brewPath, ["upgrade", "integrity-labs/tap/agt"], {
12454
+ execFileSync3(brewPath, ["upgrade", "integrity-labs/tap/agt"], {
12312
12455
  timeout: 12e4,
12313
12456
  stdio: "pipe"
12314
12457
  });
@@ -12485,7 +12628,7 @@ async function fetchUrgentDistTagVersion() {
12485
12628
  }
12486
12629
  }
12487
12630
  async function installAgtCliViaNpm(version, reasonLabel) {
12488
- const { execFileSync: execFileSync2 } = await import("child_process");
12631
+ const { execFileSync: execFileSync3 } = await import("child_process");
12489
12632
  const isRoot = typeof process.getuid === "function" && process.getuid() === 0;
12490
12633
  const cmd = isRoot ? "npm" : "sudo";
12491
12634
  const installArgs = [
@@ -12496,14 +12639,14 @@ async function installAgtCliViaNpm(version, reasonLabel) {
12496
12639
  ];
12497
12640
  const args = isRoot ? installArgs : ["-n", "npm", ...installArgs];
12498
12641
  try {
12499
- execFileSync2(cmd, args, { timeout: 18e4, stdio: "pipe" });
12642
+ execFileSync3(cmd, args, { timeout: 18e4, stdio: "pipe" });
12500
12643
  } catch (err) {
12501
12644
  log(`[self-update] npm upgrade failed: ${err.message}`);
12502
12645
  return "failed";
12503
12646
  }
12504
12647
  let smokeOk = false;
12505
12648
  try {
12506
- const out = execFileSync2("agt", ["--version"], { timeout: 15e3, stdio: "pipe" }).toString();
12649
+ const out = execFileSync3("agt", ["--version"], { timeout: 15e3, stdio: "pipe" }).toString();
12507
12650
  smokeOk = isAgtVersionSmokeOk(out, version);
12508
12651
  if (!smokeOk) {
12509
12652
  log(
@@ -12568,8 +12711,8 @@ function effectiveRuntimeAuthenticated() {
12568
12711
  async function maybeProbeClaudeRuntimeAuth() {
12569
12712
  if (runtimeAuthProbeInFlight) return;
12570
12713
  if (Date.now() - lastRuntimeAuthProbeAt < RUNTIME_AUTH_PROBE_INTERVAL_MS) return;
12571
- const { execFileSync: execFileSync2 } = await import("child_process");
12572
- if (!claudeBinaryInstalled(execFileSync2)) return;
12714
+ const { execFileSync: execFileSync3 } = await import("child_process");
12715
+ if (!claudeBinaryInstalled(execFileSync3)) return;
12573
12716
  runtimeAuthProbeInFlight = true;
12574
12717
  lastRuntimeAuthProbeAt = Date.now();
12575
12718
  try {
@@ -12670,7 +12813,7 @@ async function checkClaudeAuth() {
12670
12813
  }
12671
12814
  var evalEmptyMcpConfigPath = null;
12672
12815
  function ensureEvalEmptyMcpConfig() {
12673
- if (evalEmptyMcpConfigPath && existsSync14(evalEmptyMcpConfigPath)) return evalEmptyMcpConfigPath;
12816
+ if (evalEmptyMcpConfigPath && existsSync15(evalEmptyMcpConfigPath)) return evalEmptyMcpConfigPath;
12674
12817
  const dir = join34(homedir16(), ".augmented");
12675
12818
  try {
12676
12819
  mkdirSync11(dir, { recursive: true });
@@ -12991,10 +13134,10 @@ function flushRestartedAgentDiagnostics(hostId, codeNames) {
12991
13134
  if (codeNames.length === 0) return;
12992
13135
  void (async () => {
12993
13136
  try {
12994
- const { collectDiagnostics } = await import("../persistent-session-JLTLTQHQ.js");
13137
+ const { collectDiagnostics } = await import("../persistent-session-BGMQQYW2.js");
12995
13138
  await api.post("/host/heartbeat", {
12996
13139
  host_id: hostId,
12997
- agent_diagnostics: collectDiagnostics(codeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics)
13140
+ agent_diagnostics: collectDiagnostics(codeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor)
12998
13141
  });
12999
13142
  } catch (err) {
13000
13143
  log(`[restart] post-respawn diagnostics flush failed: ${err.message}`);
@@ -13024,7 +13167,7 @@ async function pollCycle() {
13024
13167
  getSlackToken: (codeName) => agentChannelTokens.get(codeName)?.slack ?? null,
13025
13168
  sendSlack: async (botToken, body) => {
13026
13169
  const controller = new AbortController();
13027
- const timer2 = setTimeout(() => controller.abort(), 5e3);
13170
+ const timer3 = setTimeout(() => controller.abort(), 5e3);
13028
13171
  try {
13029
13172
  const res = await fetch("https://slack.com/api/chat.postMessage", {
13030
13173
  method: "POST",
@@ -13041,7 +13184,7 @@ async function pollCycle() {
13041
13184
  const isAbort = err.name === "AbortError";
13042
13185
  return { ok: false, error: isAbort ? "timeout" : err.message };
13043
13186
  } finally {
13044
- clearTimeout(timer2);
13187
+ clearTimeout(timer3);
13045
13188
  }
13046
13189
  },
13047
13190
  // ENG-6399: report the restart to audit_log via POST /host/restart-event.
@@ -13099,9 +13242,9 @@ async function pollCycle() {
13099
13242
  }
13100
13243
  try {
13101
13244
  const { detectHostSecurity } = await import("../host-security-6PDFG7F5.js");
13102
- const { collectDiagnostics } = await import("../persistent-session-JLTLTQHQ.js");
13245
+ const { collectDiagnostics } = await import("../persistent-session-BGMQQYW2.js");
13103
13246
  const diagCodeNames = [...agentState.persistentSessionAgents];
13104
- const agentDiagnostics = diagCodeNames.length > 0 ? collectDiagnostics(diagCodeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics) : void 0;
13247
+ const agentDiagnostics = diagCodeNames.length > 0 ? collectDiagnostics(diagCodeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor) : void 0;
13105
13248
  let tailscaleHostname;
13106
13249
  try {
13107
13250
  const { execSync: es } = await import("child_process");
@@ -13222,7 +13365,7 @@ async function pollCycle() {
13222
13365
  collectPanelessActivityProbes,
13223
13366
  getResponsivenessIntervalMs,
13224
13367
  occupancyQualificationClassifications
13225
- } = await import("../responsiveness-probe-4GJUK5GG.js");
13368
+ } = await import("../responsiveness-probe-VAGPO5FZ.js");
13226
13369
  const probeIntervalMs = getResponsivenessIntervalMs();
13227
13370
  if (now - lastResponsivenessProbeAt > probeIntervalMs) {
13228
13371
  const probeCodeNames = [...agentState.persistentSessionAgents];
@@ -13313,7 +13456,7 @@ async function pollCycle() {
13313
13456
  collectResponsivenessProbes,
13314
13457
  livePendingInboundOldestAgeSeconds,
13315
13458
  parkPendingInbound
13316
- } = await import("../responsiveness-probe-4GJUK5GG.js");
13459
+ } = await import("../responsiveness-probe-VAGPO5FZ.js");
13317
13460
  const { getProjectDir: wedgeProjectDir } = await import("../scheduler-engine-NDP36U7O.js");
13318
13461
  const wedgeNow = /* @__PURE__ */ new Date();
13319
13462
  const liveAgents = agentState.persistentSessionAgents;
@@ -13402,11 +13545,11 @@ async function pollCycle() {
13402
13545
  );
13403
13546
  if (hostFlagStore().getBoolean("wedge-transient-notice")) {
13404
13547
  try {
13405
- const paneTail = readFileSync27(paneLogPath(codeName), "utf8").slice(-65536);
13548
+ const paneTail = readFileSync28(paneLogPath(codeName), "utf8").slice(-65536);
13406
13549
  const transient = detectTransientApiErrorInLog(paneTail);
13407
13550
  if (transient) {
13408
13551
  const wedgeHome = join34(homedir16(), ".augmented", codeName);
13409
- if (existsSync14(wedgeHome)) {
13552
+ if (existsSync15(wedgeHome)) {
13410
13553
  atomicWriteFileSync(
13411
13554
  join34(wedgeHome, "watchdog-give-up.json"),
13412
13555
  JSON.stringify({
@@ -13469,12 +13612,24 @@ async function pollCycle() {
13469
13612
  }
13470
13613
  try {
13471
13614
  const { scrapeMcpFailedBannerCount } = await import("../pane-mcp-banner-scraper-JA437JIB.js");
13615
+ const { probeSessionAuth } = await import("../session-auth-dead-CWFGB472.js");
13472
13616
  const observations = [];
13473
13617
  const pendingCacheCommits = [];
13474
13618
  const modelApiErrorReportingOn = hostFlagStore().getBoolean("model-api-error-reporting");
13475
13619
  for (const codeName of agentState.persistentSessionAgents) {
13476
13620
  const agentId = agentState.codeNameToAgentId.get(codeName);
13477
13621
  if (!agentId) continue;
13622
+ try {
13623
+ const authVerdict = probeSessionAuth({ projectDir: getProjectDir(codeName) });
13624
+ if (authVerdict.state !== "ok" && lastSessionAuthDetail.get(codeName) !== authVerdict.detail) {
13625
+ log(
13626
+ `[session-auth] agent=${codeName} ${authVerdict.detail}${authVerdict.worst?.toolName ? ` tool=${authVerdict.worst.toolName}` : ""} \u2014 ${authVerdict.worst?.remedy ?? ""}`
13627
+ );
13628
+ }
13629
+ lastSessionAuthDetail.set(codeName, authVerdict.detail);
13630
+ } catch (err) {
13631
+ log(`[session-auth] probe failed for ${codeName}: ${err.message}`);
13632
+ }
13478
13633
  const tail = readPaneLogTail(codeName, 40);
13479
13634
  if (!tail) continue;
13480
13635
  if (modelApiErrorReportingOn) {
@@ -13777,7 +13932,7 @@ async function pollCycle() {
13777
13932
  // the watchdog, never fails the poll cycle.
13778
13933
  signalGiveUp: (codeName) => {
13779
13934
  const dir = join34(homedir16(), ".augmented", codeName);
13780
- if (!existsSync14(dir)) return;
13935
+ if (!existsSync15(dir)) return;
13781
13936
  atomicWriteFileSync(
13782
13937
  join34(dir, "watchdog-give-up.json"),
13783
13938
  JSON.stringify({ gave_up_at: (/* @__PURE__ */ new Date()).toISOString() })
@@ -13975,7 +14130,7 @@ async function processAgent(agent, agentStates) {
13975
14130
  const residuals = {
13976
14131
  gatewayRunning: false,
13977
14132
  portAllocated: false,
13978
- provisionDirExists: existsSync14(agentDir)
14133
+ provisionDirExists: existsSync15(agentDir)
13979
14134
  };
13980
14135
  if (!hasRevokedResiduals(residuals)) {
13981
14136
  agentStates.push({
@@ -14178,7 +14333,7 @@ async function processAgent(agent, agentStates) {
14178
14333
  newHash = sha256(stripDynamicSections(artifact.content));
14179
14334
  try {
14180
14335
  const projectClaudeMd = join34(config.configDir, agent.code_name, "project", "CLAUDE.md");
14181
- const existing = readFileSync27(projectClaudeMd, "utf-8");
14336
+ const existing = readFileSync28(projectClaudeMd, "utf-8");
14182
14337
  existingHash = sha256(stripDynamicSections(existing));
14183
14338
  } catch {
14184
14339
  existingHash = null;
@@ -14196,7 +14351,7 @@ async function processAgent(agent, agentStates) {
14196
14351
  const generatorKeys = Object.keys(generatorServers);
14197
14352
  let existingRaw = "";
14198
14353
  try {
14199
- existingRaw = readFileSync27(filePath, "utf-8");
14354
+ existingRaw = readFileSync28(filePath, "utf-8");
14200
14355
  } catch {
14201
14356
  }
14202
14357
  const existingServers = parseMcp(existingRaw);
@@ -14212,7 +14367,7 @@ async function processAgent(agent, agentStates) {
14212
14367
  } else if (artifact.relativePath === "opencode.json") {
14213
14368
  let existingRaw = null;
14214
14369
  try {
14215
- existingRaw = readFileSync27(filePath, "utf-8");
14370
+ existingRaw = readFileSync28(filePath, "utf-8");
14216
14371
  } catch {
14217
14372
  }
14218
14373
  const mergeResult = mergeOpencodeConfigArtifact(artifact.content, existingRaw);
@@ -14228,7 +14383,7 @@ async function processAgent(agent, agentStates) {
14228
14383
  }
14229
14384
  }
14230
14385
  if (changedFiles.length > 0) {
14231
- const isFirst = !existsSync14(join34(agentDir, "CHARTER.md"));
14386
+ const isFirst = !existsSync15(join34(agentDir, "CHARTER.md"));
14232
14387
  const verb = isFirst ? "Provisioning" : "Updating";
14233
14388
  const fileNames = changedFiles.map((f) => f.relativePath).join(", ");
14234
14389
  log(`${verb} '${agent.code_name}': ${fileNames}`);
@@ -14243,7 +14398,7 @@ async function processAgent(agent, agentStates) {
14243
14398
  }
14244
14399
  try {
14245
14400
  const provSkillsDir = join34(agentDir, ".claude", "skills");
14246
- if (existsSync14(provSkillsDir)) {
14401
+ if (existsSync15(provSkillsDir)) {
14247
14402
  for (const folder of readdirSync9(provSkillsDir)) {
14248
14403
  if (folder.startsWith("knowledge-")) {
14249
14404
  try {
@@ -14279,7 +14434,7 @@ async function processAgent(agent, agentStates) {
14279
14434
  if (Array.isArray(refreshData.workflows)) {
14280
14435
  try {
14281
14436
  const provWorkflowsDir = join34(agentDir, ".claude", "workflows");
14282
- if (existsSync14(provWorkflowsDir)) {
14437
+ if (existsSync15(provWorkflowsDir)) {
14283
14438
  const expected = new Set(refreshData.workflows.map((w) => `${w.name}.js`));
14284
14439
  for (const file of readdirSync9(provWorkflowsDir)) {
14285
14440
  if (!file.endsWith(".js")) continue;
@@ -14364,7 +14519,7 @@ async function processAgent(agent, agentStates) {
14364
14519
  }
14365
14520
  let lastDriftCheckAt = now;
14366
14521
  const written = agentState.writtenHashes.get(agent.agent_id);
14367
- if (written && existsSync14(agentDir)) {
14522
+ if (written && existsSync15(agentDir)) {
14368
14523
  const driftedFiles = [];
14369
14524
  for (const [file, expectedHash] of written) {
14370
14525
  const localHash = hashFile(join34(agentDir, file));
@@ -14784,7 +14939,7 @@ async function processAgent(agent, agentStates) {
14784
14939
  const projectMcpPath = join34(projectDir, ".mcp.json");
14785
14940
  let mcpConfig = { mcpServers: {} };
14786
14941
  try {
14787
- mcpConfig = JSON.parse(readFileSync27(provisionMcpPath, "utf-8"));
14942
+ mcpConfig = JSON.parse(readFileSync28(provisionMcpPath, "utf-8"));
14788
14943
  if (!mcpConfig.mcpServers) mcpConfig.mcpServers = {};
14789
14944
  } catch {
14790
14945
  }
@@ -14794,7 +14949,7 @@ async function processAgent(agent, agentStates) {
14794
14949
  const tz = directChatTeamSettings?.["timezone"];
14795
14950
  return typeof tz === "string" && tz.trim() !== "" ? tz.trim() : void 0;
14796
14951
  })();
14797
- if (existsSync14(localDirectChatChannel)) {
14952
+ if (existsSync15(localDirectChatChannel)) {
14798
14953
  const directChatEnv = {
14799
14954
  AGT_HOST: requireHost(),
14800
14955
  // ENG-5901 Track D: templated — the manager exports the real
@@ -14835,7 +14990,7 @@ async function processAgent(agent, agentStates) {
14835
14990
  }
14836
14991
  }
14837
14992
  const staleChannelsPath = join34(projectDir, ".mcp-channels.json");
14838
- if (existsSync14(staleChannelsPath)) {
14993
+ if (existsSync15(staleChannelsPath)) {
14839
14994
  try {
14840
14995
  rmSync5(staleChannelsPath, { force: true });
14841
14996
  } catch {
@@ -15051,7 +15206,7 @@ async function processAgent(agent, agentStates) {
15051
15206
  const envIntPath = join34(projectDir, ".env.integrations");
15052
15207
  let preWriteEnv;
15053
15208
  try {
15054
- preWriteEnv = readFileSync27(envIntPath, "utf-8");
15209
+ preWriteEnv = readFileSync28(envIntPath, "utf-8");
15055
15210
  } catch {
15056
15211
  preWriteEnv = void 0;
15057
15212
  }
@@ -15071,8 +15226,8 @@ async function processAgent(agent, agentStates) {
15071
15226
  if (fw === "claude-code" && isSessionHealthy(agent.code_name)) {
15072
15227
  try {
15073
15228
  const projectMcpPath = join34(projectDir, ".mcp.json");
15074
- const postWriteEnv = readFileSync27(envIntPath, "utf-8");
15075
- const mcpContent = readFileSync27(projectMcpPath, "utf-8");
15229
+ const postWriteEnv = readFileSync28(envIntPath, "utf-8");
15230
+ const mcpContent = readFileSync28(projectMcpPath, "utf-8");
15076
15231
  const changedVars = diffEnvIntegrations(preWriteEnv, postWriteEnv);
15077
15232
  const mcpJsonForReap = JSON.parse(mcpContent);
15078
15233
  const affectedServerKeys = findMcpServersUsingVars(mcpJsonForReap, changedVars);
@@ -15347,7 +15502,7 @@ async function processAgent(agent, agentStates) {
15347
15502
  // install target but cheap to sweep.
15348
15503
  join34(agentDir, ".claude", "skills")
15349
15504
  ];
15350
- const existingDirs = candidateSkillDirs.filter((d) => existsSync14(d));
15505
+ const existingDirs = candidateSkillDirs.filter((d) => existsSync15(d));
15351
15506
  const discoveredEntries = /* @__PURE__ */ new Set();
15352
15507
  for (const dir of existingDirs) {
15353
15508
  try {
@@ -15366,7 +15521,7 @@ async function processAgent(agent, agentStates) {
15366
15521
  entry,
15367
15522
  dirs: existingDirs,
15368
15523
  removeDir: (p) => {
15369
- if (existsSync14(p)) {
15524
+ if (existsSync15(p)) {
15370
15525
  rmSync6(p, { recursive: true, force: true });
15371
15526
  }
15372
15527
  }
@@ -15414,7 +15569,7 @@ async function processAgent(agent, agentStates) {
15414
15569
  let prunedAny = false;
15415
15570
  for (const dir of globalSkillDirs) {
15416
15571
  const p = join34(dir, id);
15417
- if (existsSync14(p) && existsSync14(join34(p, "SKILL.md"))) {
15572
+ if (existsSync15(p) && existsSync15(join34(p, "SKILL.md"))) {
15418
15573
  rmSync5(p, { recursive: true, force: true });
15419
15574
  prunedAny = true;
15420
15575
  }
@@ -15647,7 +15802,7 @@ async function processAgent(agent, agentStates) {
15647
15802
  let mcpJsonParsed = null;
15648
15803
  try {
15649
15804
  const mcpPath = join34(getProjectDir(agent.code_name), ".mcp.json");
15650
- mcpJsonParsed = JSON.parse(readFileSync27(mcpPath, "utf-8"));
15805
+ mcpJsonParsed = JSON.parse(readFileSync28(mcpPath, "utf-8"));
15651
15806
  } catch {
15652
15807
  }
15653
15808
  reapMissingMcpSessions({
@@ -16078,7 +16233,7 @@ Retried to the limit after repeated stalls \u2014 needs a look.`).catch(() => {
16078
16233
  }
16079
16234
  }
16080
16235
  const trackedFiles = frameworkAdapter.driftTrackedFiles();
16081
- if (trackedFiles.length > 0 && existsSync14(agentDir)) {
16236
+ if (trackedFiles.length > 0 && existsSync15(agentDir)) {
16082
16237
  const hashes = /* @__PURE__ */ new Map();
16083
16238
  for (const file of trackedFiles) {
16084
16239
  const h = hashFile(join34(agentDir, file));
@@ -16158,6 +16313,7 @@ Retried to the limit after repeated stalls \u2014 needs a look.`).catch(() => {
16158
16313
  }
16159
16314
  var lastMcpFailedBannerCount = /* @__PURE__ */ new Map();
16160
16315
  var lastModelApiErrorSig = /* @__PURE__ */ new Map();
16316
+ var lastSessionAuthDetail = /* @__PURE__ */ new Map();
16161
16317
  var DAY_ROLLOVER_FORCE_GRACE_MIN = 30;
16162
16318
  var persistentSessionStuckTracker = new PersistentSessionStuckTracker();
16163
16319
  var claudeAuthTupleBySession = /* @__PURE__ */ new Map();
@@ -16884,10 +17040,10 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
16884
17040
  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}`));
16885
17041
  void (async () => {
16886
17042
  try {
16887
- const { collectDiagnostics } = await import("../persistent-session-JLTLTQHQ.js");
17043
+ const { collectDiagnostics } = await import("../persistent-session-BGMQQYW2.js");
16888
17044
  await api.post("/host/heartbeat", {
16889
17045
  host_id: hostId,
16890
- agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics)
17046
+ agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor)
16891
17047
  });
16892
17048
  } catch (err) {
16893
17049
  log(`[restart-lane] post-respawn diagnostics flush failed for '${codeName}': ${err.message}`);
@@ -16935,10 +17091,10 @@ async function respawnAgentAfterMcpStop(codeName, reason) {
16935
17091
  }
16936
17092
  try {
16937
17093
  const hostId = await getHostId();
16938
- const { collectDiagnostics } = await import("../persistent-session-JLTLTQHQ.js");
17094
+ const { collectDiagnostics } = await import("../persistent-session-BGMQQYW2.js");
16939
17095
  await api.post("/host/heartbeat", {
16940
17096
  host_id: hostId,
16941
- agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics)
17097
+ agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor)
16942
17098
  });
16943
17099
  } catch (err) {
16944
17100
  log(`[fast-mcp-respawn] post-respawn diagnostics flush failed for '${codeName}': ${err.message}`);
@@ -17513,7 +17669,7 @@ async function processClaudePairSessions(agents) {
17513
17669
  killPairSession,
17514
17670
  pairTmuxSession,
17515
17671
  finalizeClaudePairOnboarding
17516
- } = await import("../claude-pair-runtime-PBFR6UGJ.js");
17672
+ } = await import("../claude-pair-runtime-5WB2FMIX.js");
17517
17673
  for (const pairId of pendingResp.cancelled_pair_ids ?? []) {
17518
17674
  log(`[claude-pair] sweeping orphan tmux session for pair ${pairId.slice(0, 8)}`);
17519
17675
  const killed = await killPairSession(pairTmuxSession(pairId));
@@ -17779,14 +17935,14 @@ async function syncMemories(agent, configDir, log2) {
17779
17935
  }
17780
17936
  pendingFreshMemorySync.delete(agent.agent_id);
17781
17937
  }
17782
- if (existsSync14(memoryDir)) {
17938
+ if (existsSync15(memoryDir)) {
17783
17939
  const prevHashes = memoryFileHashes.get(agent.agent_id) ?? /* @__PURE__ */ new Map();
17784
17940
  const currentHashes = /* @__PURE__ */ new Map();
17785
17941
  const changedMemories = [];
17786
17942
  for (const file of readdirSync9(memoryDir)) {
17787
17943
  if (!file.endsWith(".md")) continue;
17788
17944
  try {
17789
- const raw = readFileSync27(join34(memoryDir, file), "utf-8");
17945
+ const raw = readFileSync28(join34(memoryDir, file), "utf-8");
17790
17946
  const fileHash = createHash17("sha256").update(raw).digest("hex").slice(0, 16);
17791
17947
  currentHashes.set(file, fileHash);
17792
17948
  if (prevHashes.get(file) === fileHash) continue;
@@ -17811,7 +17967,7 @@ async function syncMemories(agent, configDir, log2) {
17811
17967
  } catch (err) {
17812
17968
  for (const mem of changedMemories) {
17813
17969
  for (const [file] of currentHashes) {
17814
- const parsed = parseMemoryFile(readFileSync27(join34(memoryDir, file), "utf-8"), file.replace(/\.md$/, ""));
17970
+ const parsed = parseMemoryFile(readFileSync28(join34(memoryDir, file), "utf-8"), file.replace(/\.md$/, ""));
17815
17971
  if (parsed?.name === mem.name) currentHashes.delete(file);
17816
17972
  }
17817
17973
  }
@@ -17824,7 +17980,7 @@ async function syncMemories(agent, configDir, log2) {
17824
17980
  }
17825
17981
  }
17826
17982
  async function downloadMemories(agent, memoryDir, log2, { force }) {
17827
- const localFiles = existsSync14(memoryDir) ? readdirSync9(memoryDir).filter((f) => f.endsWith(".md")).sort() : [];
17983
+ const localFiles = existsSync15(memoryDir) ? readdirSync9(memoryDir).filter((f) => f.endsWith(".md")).sort() : [];
17828
17984
  const localListHash = createHash17("sha256").update(localFiles.join(",")).digest("hex").slice(0, 16);
17829
17985
  const prevLocalHash = lastLocalFileHash.get(agent.agent_id);
17830
17986
  const prevDownload = lastDownloadHash.get(agent.agent_id);
@@ -17855,10 +18011,10 @@ description: ${JSON.stringify(mem.content.slice(0, 200))}
17855
18011
 
17856
18012
  ${mem.content}
17857
18013
  `;
17858
- if (existsSync14(filePath)) {
18014
+ if (existsSync15(filePath)) {
17859
18015
  let existing = "";
17860
18016
  try {
17861
- existing = readFileSync27(filePath, "utf-8");
18017
+ existing = readFileSync28(filePath, "utf-8");
17862
18018
  } catch {
17863
18019
  }
17864
18020
  if (existing === desired) continue;
@@ -17882,7 +18038,7 @@ ${mem.content}
17882
18038
  }
17883
18039
  }
17884
18040
  async function cleanupAgentFiles(codeName, agentDir) {
17885
- if (existsSync14(agentDir)) {
18041
+ if (existsSync15(agentDir)) {
17886
18042
  try {
17887
18043
  rmSync5(agentDir, { recursive: true, force: true });
17888
18044
  log(`Removed provision directory for '${codeName}'`);
@@ -17990,6 +18146,7 @@ function startPolling() {
17990
18146
  }, LIVENESS_HEARTBEAT_INTERVAL_MS);
17991
18147
  livenessTimer.unref();
17992
18148
  startPaneOccupancySampler(() => agentState.persistentSessionAgents);
18149
+ startPidPressureSampler(() => agentState.persistentSessionAgents);
17993
18150
  void startCaffeinate();
17994
18151
  loadChannelHashCache2();
17995
18152
  loadSenderPolicyBaseline2();
@@ -18084,6 +18241,7 @@ async function stopPolling(opts = {}) {
18084
18241
  livenessTimer = null;
18085
18242
  }
18086
18243
  stopPaneOccupancySampler();
18244
+ stopPidPressureSampler();
18087
18245
  const shutdownTimer = setTimeout(() => {
18088
18246
  log("Shutdown timeout exceeded (15s), forcing exit");
18089
18247
  process.exit(opts.forcedExitCode ?? 1);
@@ -18124,8 +18282,8 @@ function startManager(opts) {
18124
18282
  config = opts;
18125
18283
  try {
18126
18284
  const stateFile = getStateFile();
18127
- if (existsSync14(stateFile)) {
18128
- const raw = readFileSync27(stateFile, "utf-8");
18285
+ if (existsSync15(stateFile)) {
18286
+ const raw = readFileSync28(stateFile, "utf-8");
18129
18287
  const parsed = JSON.parse(raw);
18130
18288
  if (Array.isArray(parsed.agents)) {
18131
18289
  state7.agents = parsed.agents;
@@ -18181,7 +18339,7 @@ async function reapOrphanedClaudePids() {
18181
18339
  const looksLikeClaude = (pid) => {
18182
18340
  if (process.platform !== "linux") return true;
18183
18341
  try {
18184
- const comm = readFileSync27(`/proc/${pid}/comm`, "utf-8").trim().toLowerCase();
18342
+ const comm = readFileSync28(`/proc/${pid}/comm`, "utf-8").trim().toLowerCase();
18185
18343
  return comm.includes("claude");
18186
18344
  } catch {
18187
18345
  return false;
@@ -18285,7 +18443,7 @@ function deployMcpAssets() {
18285
18443
  let dir = moduleDir;
18286
18444
  for (let i = 0; i < 6; i++) {
18287
18445
  const candidate = join34(dir, "dist", "mcp");
18288
- if (existsSync14(join34(candidate, "index.js"))) {
18446
+ if (existsSync15(join34(candidate, "index.js"))) {
18289
18447
  mcpSourceDir = candidate;
18290
18448
  break;
18291
18449
  }
@@ -18300,8 +18458,8 @@ function deployMcpAssets() {
18300
18458
  const changedBasenames = [];
18301
18459
  const fileHash = (p) => {
18302
18460
  try {
18303
- if (!existsSync14(p)) return null;
18304
- return createHash17("sha256").update(readFileSync27(p)).digest("hex");
18461
+ if (!existsSync15(p)) return null;
18462
+ return createHash17("sha256").update(readFileSync28(p)).digest("hex");
18305
18463
  } catch {
18306
18464
  return null;
18307
18465
  }
@@ -18374,7 +18532,7 @@ function deployMcpAssets() {
18374
18532
  ]) {
18375
18533
  const src = join34(mcpSourceDir, file);
18376
18534
  const dst = join34(targetDir, file);
18377
- if (!existsSync14(src)) continue;
18535
+ if (!existsSync15(src)) continue;
18378
18536
  const before = fileHash(dst);
18379
18537
  try {
18380
18538
  copyFileSync(src, dst);
@@ -18394,13 +18552,13 @@ function deployMcpAssets() {
18394
18552
  const localMcpPath = join34(targetDir, "index.js");
18395
18553
  try {
18396
18554
  const agentsDir = join34(homedir16(), ".augmented", "agents");
18397
- if (existsSync14(agentsDir)) {
18555
+ if (existsSync15(agentsDir)) {
18398
18556
  for (const entry of readdirSync9(agentsDir, { withFileTypes: true })) {
18399
18557
  if (!entry.isDirectory()) continue;
18400
18558
  for (const subdir of ["provision", "project"]) {
18401
18559
  const mcpJsonPath = join34(agentsDir, entry.name, subdir, ".mcp.json");
18402
18560
  try {
18403
- const raw = readFileSync27(mcpJsonPath, "utf-8");
18561
+ const raw = readFileSync28(mcpJsonPath, "utf-8");
18404
18562
  if (!raw.includes("@integrity-labs/augmented-mcp")) continue;
18405
18563
  const mcpConfig = JSON.parse(raw);
18406
18564
  const augServer = mcpConfig.mcpServers?.["augmented"];