@integrity-labs/agt-cli 0.28.593 → 0.28.594

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-U7DHWGAZ.js";
57
57
  import {
58
58
  getProjectDir as getProjectDir2,
59
59
  getReadyTasks,
@@ -184,14 +184,14 @@ import {
184
184
  toOpencodeModel,
185
185
  transcriptActivityAgeSeconds,
186
186
  writeEgressAllowlist
187
- } from "../chunk-TKWDYMM3.js";
187
+ } from "../chunk-74UJCPIS.js";
188
188
  import {
189
189
  reapOrphanChannelMcps
190
190
  } from "../chunk-XWVM4KPK.js";
191
191
 
192
192
  // src/lib/manager-worker.ts
193
193
  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";
194
+ 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
195
  import { execFileSync as syncExecFile } from "child_process";
196
196
  import { join as join34, dirname as dirname9, delimiter as pathDelimiter } from "path";
197
197
  import { homedir as homedir16 } from "os";
@@ -7576,6 +7576,147 @@ function stopPaneOccupancySampler() {
7576
7576
  timer = null;
7577
7577
  }
7578
7578
 
7579
+ // src/lib/pid-pressure-sampler.ts
7580
+ import { execFileSync as execFileSync2 } from "child_process";
7581
+ import { existsSync as existsSync12, readFileSync as readFileSync24 } from "fs";
7582
+ var SAMPLE_INTERVAL_MS2 = 3e4;
7583
+ function warnFraction() {
7584
+ const raw = Number(process.env.AGT_PID_PRESSURE_WARN_FRACTION);
7585
+ if (!Number.isFinite(raw) || raw <= 0 || raw > 1) return 0.8;
7586
+ return raw;
7587
+ }
7588
+ function configuredCeiling() {
7589
+ const raw = Number(process.env.AGT_ISOLATION_PIDS);
7590
+ return Number.isFinite(raw) && raw > 0 ? raw : 512;
7591
+ }
7592
+ function readTextReal(path) {
7593
+ try {
7594
+ return readFileSync24(path, "utf-8");
7595
+ } catch {
7596
+ return null;
7597
+ }
7598
+ }
7599
+ var cgroupDirCache = /* @__PURE__ */ new Map();
7600
+ var resolveRetryAfter = /* @__PURE__ */ new Map();
7601
+ var RESOLVE_RETRY_BACKOFF_MS = 5 * 6e4;
7602
+ function resolveCgroupDirReal(codeName, deps = {}) {
7603
+ const exists = deps.exists ?? existsSync12;
7604
+ const inspectId = deps.inspectId ?? inspectContainerId;
7605
+ const now = deps.now ?? Date.now;
7606
+ const cached = cgroupDirCache.get(codeName);
7607
+ if (cached && exists(cached)) {
7608
+ resolveRetryAfter.delete(codeName);
7609
+ return cached;
7610
+ }
7611
+ const retryAt = resolveRetryAfter.get(codeName);
7612
+ if (retryAt != null && now() < retryAt) return null;
7613
+ if (cached) cgroupDirCache.delete(codeName);
7614
+ const id = inspectId(codeName);
7615
+ if (id == null || !/^[0-9a-f]{12,64}$/.test(id)) {
7616
+ resolveRetryAfter.set(codeName, now() + RESOLVE_RETRY_BACKOFF_MS);
7617
+ return null;
7618
+ }
7619
+ for (const dir of [
7620
+ `/sys/fs/cgroup/system.slice/docker-${id}.scope`,
7621
+ `/sys/fs/cgroup/docker/${id}`
7622
+ ]) {
7623
+ if (exists(dir)) {
7624
+ cgroupDirCache.set(codeName, dir);
7625
+ resolveRetryAfter.delete(codeName);
7626
+ return dir;
7627
+ }
7628
+ }
7629
+ resolveRetryAfter.set(codeName, now() + RESOLVE_RETRY_BACKOFF_MS);
7630
+ return null;
7631
+ }
7632
+ function inspectContainerId(codeName) {
7633
+ try {
7634
+ return execFileSync2("docker", ["inspect", "-f", "{{.Id}}", `agt-${codeName}`], {
7635
+ encoding: "utf-8",
7636
+ timeout: 5e3,
7637
+ stdio: ["ignore", "pipe", "ignore"]
7638
+ }).trim();
7639
+ } catch {
7640
+ return null;
7641
+ }
7642
+ }
7643
+ function countDefunct(cgroupDir, readText) {
7644
+ const procs = readText(`${cgroupDir}/cgroup.procs`);
7645
+ if (procs == null) return 0;
7646
+ let defunct = 0;
7647
+ for (const line of procs.split("\n")) {
7648
+ const pid = line.trim();
7649
+ if (!pid) continue;
7650
+ const stat2 = readText(`/proc/${pid}/stat`);
7651
+ if (stat2 == null) continue;
7652
+ const close = stat2.lastIndexOf(")");
7653
+ if (close < 0) continue;
7654
+ const state8 = stat2.slice(close + 1).trim().charAt(0);
7655
+ if (state8 === "Z") defunct += 1;
7656
+ }
7657
+ return defunct;
7658
+ }
7659
+ function samplePidPressureFor(codeName, io = {}) {
7660
+ const isolated = io.isolatedFor?.(codeName) ?? isolationMode(codeName) === "docker";
7661
+ if (!isolated) return null;
7662
+ const readText = io.readText ?? readTextReal;
7663
+ const resolveDir = io.resolveCgroupDir ?? resolveCgroupDirReal;
7664
+ const dir = resolveDir(codeName);
7665
+ if (dir == null) return null;
7666
+ const currentRaw = readText(`${dir}/pids.current`)?.trim();
7667
+ if (currentRaw == null || currentRaw === "") return null;
7668
+ const current = Number(currentRaw);
7669
+ if (!Number.isFinite(current) || current < 0) return null;
7670
+ const maxParsed = Number(readText(`${dir}/pids.max`)?.trim());
7671
+ const max = Number.isFinite(maxParsed) && maxParsed > 0 ? maxParsed : null;
7672
+ const ceiling = configuredCeiling();
7673
+ const warnAt = Math.floor(ceiling * warnFraction());
7674
+ return {
7675
+ current,
7676
+ max,
7677
+ ceiling,
7678
+ defunct: countDefunct(dir, readText),
7679
+ warnAt,
7680
+ overThreshold: current >= warnAt
7681
+ };
7682
+ }
7683
+ var lastSample = /* @__PURE__ */ new Map();
7684
+ function samplePidPressureOnce(codeNames, io = {}) {
7685
+ const seen = /* @__PURE__ */ new Set();
7686
+ for (const codeName of codeNames) {
7687
+ seen.add(codeName);
7688
+ const sample = samplePidPressureFor(codeName, io);
7689
+ if (sample) lastSample.set(codeName, sample);
7690
+ else lastSample.delete(codeName);
7691
+ }
7692
+ for (const codeName of [...lastSample.keys()]) {
7693
+ if (!seen.has(codeName)) {
7694
+ lastSample.delete(codeName);
7695
+ cgroupDirCache.delete(codeName);
7696
+ resolveRetryAfter.delete(codeName);
7697
+ }
7698
+ }
7699
+ }
7700
+ function pidPressureFor(codeName) {
7701
+ return lastSample.get(codeName) ?? null;
7702
+ }
7703
+ var timer2 = null;
7704
+ function startPidPressureSampler(liveAgents) {
7705
+ if (timer2) return;
7706
+ timer2 = setInterval(() => {
7707
+ try {
7708
+ samplePidPressureOnce(liveAgents());
7709
+ } catch {
7710
+ }
7711
+ }, SAMPLE_INTERVAL_MS2);
7712
+ timer2.unref?.();
7713
+ }
7714
+ function stopPidPressureSampler() {
7715
+ if (!timer2) return;
7716
+ clearInterval(timer2);
7717
+ timer2 = null;
7718
+ }
7719
+
7579
7720
  // src/lib/opencode-slack-ingest.ts
7580
7721
  import { createHash as createHash14 } from "crypto";
7581
7722
 
@@ -8702,7 +8843,7 @@ async function fireOpencodeScheduledTask(agent, task) {
8702
8843
 
8703
8844
  // src/lib/opencode-telegram-ingest.ts
8704
8845
  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";
8846
+ import { existsSync as existsSync13, mkdirSync as mkdirSync8, readFileSync as readFileSync25, renameSync as renameSync5, unlinkSync as unlinkSync3, writeFileSync as writeFileSync11 } from "fs";
8706
8847
  import { randomUUID } from "crypto";
8707
8848
  import { join as join31 } from "path";
8708
8849
 
@@ -9261,7 +9402,7 @@ function createFileOffsetStore(codeName, log2, currentBotId) {
9261
9402
  load() {
9262
9403
  if (!filePath) return 0;
9263
9404
  try {
9264
- const parsed = JSON.parse(readFileSync24(filePath, "utf-8"));
9405
+ const parsed = JSON.parse(readFileSync25(filePath, "utf-8"));
9265
9406
  if (currentBotId != null && typeof parsed?.bot_id === "number" && parsed.bot_id !== currentBotId) {
9266
9407
  log2(`[telegram-ingest:${codeName}] offset cursor belongs to a different bot; ignoring (bot swap)`);
9267
9408
  return 0;
@@ -9294,7 +9435,7 @@ function createFileOffsetStore(codeName, log2, currentBotId) {
9294
9435
  } catch (err) {
9295
9436
  log2(`[telegram-ingest:${codeName}] offset persist failed: ${err instanceof Error ? err.message : String(err)}`);
9296
9437
  try {
9297
- if (existsSync12(tmpPath)) unlinkSync3(tmpPath);
9438
+ if (existsSync13(tmpPath)) unlinkSync3(tmpPath);
9298
9439
  } catch {
9299
9440
  }
9300
9441
  }
@@ -9531,7 +9672,7 @@ function partitionActionableByPoison(actionable, states, config2) {
9531
9672
  }
9532
9673
 
9533
9674
  // 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";
9675
+ 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
9676
  import { homedir as homedir15 } from "os";
9536
9677
  import { join as join32 } from "path";
9537
9678
  import { randomUUID as randomUUID2 } from "crypto";
@@ -9543,12 +9684,12 @@ function flagPath(codeName) {
9543
9684
  }
9544
9685
  function readRestartFlags() {
9545
9686
  const dir = restartFlagsDir();
9546
- if (!existsSync13(dir)) return [];
9687
+ if (!existsSync14(dir)) return [];
9547
9688
  const out = [];
9548
9689
  for (const entry of readdirSync7(dir)) {
9549
9690
  if (!entry.endsWith(".flag")) continue;
9550
9691
  try {
9551
- const raw = readFileSync25(join32(dir, entry), "utf8");
9692
+ const raw = readFileSync26(join32(dir, entry), "utf8");
9552
9693
  const parsed = JSON.parse(raw);
9553
9694
  if (typeof parsed.codeName !== "string" || parsed.codeName.length === 0) {
9554
9695
  parsed.codeName = entry.replace(/\.flag$/, "");
@@ -9566,7 +9707,7 @@ function readRestartFlags() {
9566
9707
  }
9567
9708
  function deleteRestartFlag(codeName) {
9568
9709
  const path = flagPath(codeName);
9569
- if (existsSync13(path)) {
9710
+ if (existsSync14(path)) {
9570
9711
  rmSync4(path, { force: true });
9571
9712
  }
9572
9713
  }
@@ -9666,7 +9807,7 @@ async function sendError(flag, opts, text) {
9666
9807
  }
9667
9808
 
9668
9809
  // src/lib/restart-context.ts
9669
- import { readdirSync as readdirSync8, readFileSync as readFileSync26, writeFileSync as writeFileSync13, mkdirSync as mkdirSync10, unlinkSync as unlinkSync4 } from "fs";
9810
+ import { readdirSync as readdirSync8, readFileSync as readFileSync27, writeFileSync as writeFileSync13, mkdirSync as mkdirSync10, unlinkSync as unlinkSync4 } from "fs";
9670
9811
  import { dirname as dirname8, join as join33 } from "path";
9671
9812
  var SLACK_PENDING_INBOUND_DIRNAME = "slack-pending-inbound";
9672
9813
  var SLACK_RESTART_CONTEXT_DIRNAME = "slack-restart-context";
@@ -9724,7 +9865,7 @@ function safeReaddir(dir) {
9724
9865
  }
9725
9866
  function readStrandedMarker(path) {
9726
9867
  try {
9727
- const parsed = JSON.parse(readFileSync26(path, "utf-8"));
9868
+ const parsed = JSON.parse(readFileSync27(path, "utf-8"));
9728
9869
  if (typeof parsed.channel === "string" && typeof parsed.thread_ts === "string") {
9729
9870
  return { channel: parsed.channel, thread_ts: parsed.thread_ts };
9730
9871
  }
@@ -10867,7 +11008,7 @@ function scheduleSessionRestart(codeName, delayMs, reason, breakerReason = "hot-
10867
11008
  clearTimeout(existing.timer);
10868
11009
  log(`[hot-reload] Coalesced restart for '${codeName}': replacing pending timer with ${reason}`);
10869
11010
  }
10870
- const timer2 = setTimeout(() => {
11011
+ const timer3 = setTimeout(() => {
10871
11012
  pendingSessionRestarts.delete(codeName);
10872
11013
  const gate = restartGateFor(codeName, breakerReason);
10873
11014
  if (gate !== "bypass" && gate !== "proceed") {
@@ -10945,8 +11086,8 @@ function scheduleSessionRestart(codeName, delayMs, reason, breakerReason = "hot-
10945
11086
  void respawnAgentAfterMcpStop(codeName, reason);
10946
11087
  }
10947
11088
  }, delayMs);
10948
- timer2.unref?.();
10949
- pendingSessionRestarts.set(codeName, { timer: timer2, reason, breakerReason, beforeStop, auditDetail });
11089
+ timer3.unref?.();
11090
+ pendingSessionRestarts.set(codeName, { timer: timer3, reason, breakerReason, beforeStop, auditDetail });
10950
11091
  }
10951
11092
  function cancelPendingSessionRestart(codeName) {
10952
11093
  pendingRestartVerifications.delete(codeName);
@@ -11295,7 +11436,7 @@ var runningChannelSecretHashes = /* @__PURE__ */ new Map();
11295
11436
  var sessionLaunchManagedStructure = /* @__PURE__ */ new Map();
11296
11437
  function projectMcpHash(_codeName, projectDir) {
11297
11438
  try {
11298
- const raw = readFileSync27(join34(projectDir, ".mcp.json"), "utf-8");
11439
+ const raw = readFileSync28(join34(projectDir, ".mcp.json"), "utf-8");
11299
11440
  return createHash17("sha256").update(canonicalJson(JSON.parse(raw))).digest("hex");
11300
11441
  } catch {
11301
11442
  return null;
@@ -11303,7 +11444,7 @@ function projectMcpHash(_codeName, projectDir) {
11303
11444
  }
11304
11445
  function projectMcpKeys(_codeName, projectDir) {
11305
11446
  try {
11306
- const raw = readFileSync27(join34(projectDir, ".mcp.json"), "utf-8");
11447
+ const raw = readFileSync28(join34(projectDir, ".mcp.json"), "utf-8");
11307
11448
  const parsed = JSON.parse(raw);
11308
11449
  const servers = parsed.mcpServers;
11309
11450
  if (!servers || typeof servers !== "object") return /* @__PURE__ */ new Set();
@@ -11321,7 +11462,7 @@ function seedSessionLaunchBaselines(codeName, projectDir) {
11321
11462
  else runningMcpServerKeys.delete(codeName);
11322
11463
  let launchStructure = null;
11323
11464
  try {
11324
- const raw = readFileSync27(join34(projectDir, ".mcp.json"), "utf-8");
11465
+ const raw = readFileSync28(join34(projectDir, ".mcp.json"), "utf-8");
11325
11466
  launchStructure = managedMcpStructureHashFromFile(
11326
11467
  JSON.parse(raw),
11327
11468
  isManagedMcpServerKey
@@ -11443,7 +11584,7 @@ async function runAgentSessionToolBindProbes(agent, integrations, projectDir, op
11443
11584
  if (result && result.rebindCandidates.length > 0 && hostFlagStore().getBoolean("session-tool-rebind")) {
11444
11585
  let mcpJsonForRebind = null;
11445
11586
  try {
11446
- mcpJsonForRebind = JSON.parse(readFileSync27(join34(projectDir, ".mcp.json"), "utf-8"));
11587
+ mcpJsonForRebind = JSON.parse(readFileSync28(join34(projectDir, ".mcp.json"), "utf-8"));
11447
11588
  } catch {
11448
11589
  mcpJsonForRebind = null;
11449
11590
  }
@@ -11588,7 +11729,7 @@ function checkMcpConfigDriftAndScheduleRestart(codeName, projectDir) {
11588
11729
  function projectChannelSecretHash(projectDir) {
11589
11730
  try {
11590
11731
  const entries = parseEnvIntegrations(
11591
- readFileSync27(join34(projectDir, ".env.integrations"), "utf-8")
11732
+ readFileSync28(join34(projectDir, ".env.integrations"), "utf-8")
11592
11733
  );
11593
11734
  return channelSecretValueHash(entries, CHANNEL_SECRET_ENV_KEYS);
11594
11735
  } catch {
@@ -11684,10 +11825,10 @@ var agentRestartTimezoneInputs = /* @__PURE__ */ new Map();
11684
11825
  var lastVersionCheckAt = 0;
11685
11826
  var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
11686
11827
  var lastResponsivenessProbeAt = 0;
11687
- var agtCliVersion = true ? "0.28.593" : "dev";
11688
- function resolveBrewPath(execFileSync2) {
11828
+ var agtCliVersion = true ? "0.28.594" : "dev";
11829
+ function resolveBrewPath(execFileSync3) {
11689
11830
  try {
11690
- const out = execFileSync2("which", ["brew"], { timeout: 5e3 }).toString().trim();
11831
+ const out = execFileSync3("which", ["brew"], { timeout: 5e3 }).toString().trim();
11691
11832
  if (out) return out;
11692
11833
  } catch {
11693
11834
  }
@@ -11697,19 +11838,19 @@ function resolveBrewPath(execFileSync2) {
11697
11838
  "/usr/local/bin/brew"
11698
11839
  ];
11699
11840
  for (const path of fallbacks) {
11700
- if (existsSync14(path)) return path;
11841
+ if (existsSync15(path)) return path;
11701
11842
  }
11702
11843
  return null;
11703
11844
  }
11704
- function claudeBinaryInstalled(execFileSync2) {
11845
+ function claudeBinaryInstalled(execFileSync3) {
11705
11846
  const canonical = [
11706
11847
  "/home/linuxbrew/.linuxbrew/bin/claude",
11707
11848
  "/opt/homebrew/bin/claude",
11708
11849
  "/usr/local/bin/claude"
11709
11850
  ];
11710
- if (canonical.some((path) => existsSync14(path))) return true;
11851
+ if (canonical.some((path) => existsSync15(path))) return true;
11711
11852
  try {
11712
- execFileSync2("which", ["claude"], { timeout: 5e3 });
11853
+ execFileSync3("which", ["claude"], { timeout: 5e3 });
11713
11854
  return true;
11714
11855
  } catch {
11715
11856
  return false;
@@ -11743,9 +11884,9 @@ async function ensureToolkitCli(toolkitSlug) {
11743
11884
  }
11744
11885
  const { binary, installer, package: pkg, script } = integration.cli_tool;
11745
11886
  const resolvedInstaller = installer ?? "manual";
11746
- const { execFileSync: execFileSync2, execSync } = await import("child_process");
11887
+ const { execFileSync: execFileSync3, execSync } = await import("child_process");
11747
11888
  try {
11748
- execFileSync2("which", [binary], { timeout: 5e3, stdio: "pipe" });
11889
+ execFileSync3("which", [binary], { timeout: 5e3, stdio: "pipe" });
11749
11890
  toolkitCliEnsured.add(toolkitSlug);
11750
11891
  toolkitCliRetryAfter.delete(toolkitSlug);
11751
11892
  toolkitCliFailureCount.delete(toolkitSlug);
@@ -11766,14 +11907,14 @@ async function ensureToolkitCli(toolkitSlug) {
11766
11907
  return;
11767
11908
  }
11768
11909
  log(`[toolkit-install] ${toolkitSlug}: installing via npm (${pkg})\u2026`);
11769
- execFileSync2("npm", ["install", "-g", pkg], { timeout: 18e4, stdio: "pipe" });
11910
+ execFileSync3("npm", ["install", "-g", pkg], { timeout: 18e4, stdio: "pipe" });
11770
11911
  } else if (resolvedInstaller === "brew") {
11771
11912
  if (!pkg) {
11772
11913
  log(`[toolkit-install] ${toolkitSlug}: installer=brew but no package declared`);
11773
11914
  toolkitCliEnsured.add(toolkitSlug);
11774
11915
  return;
11775
11916
  }
11776
- const brewPath = resolveBrewPath(execFileSync2);
11917
+ const brewPath = resolveBrewPath(execFileSync3);
11777
11918
  if (!brewPath) {
11778
11919
  log(`[toolkit-install] ${toolkitSlug}: installer=brew but Homebrew not available \u2014 install manually: brew install ${pkg}`);
11779
11920
  toolkitCliEnsured.add(toolkitSlug);
@@ -11783,9 +11924,9 @@ async function ensureToolkitCli(toolkitSlug) {
11783
11924
  const isRoot = typeof process.getuid === "function" && process.getuid() === 0;
11784
11925
  log(`[toolkit-install] ${toolkitSlug}: installing via brew (${pkg})\u2026`);
11785
11926
  if (isRoot) {
11786
- execFileSync2("sudo", ["-u", "ec2-user", "-H", brewPath, "install", pkg], { timeout: 18e4, stdio: "pipe", cwd: "/tmp" });
11927
+ execFileSync3("sudo", ["-u", "ec2-user", "-H", brewPath, "install", pkg], { timeout: 18e4, stdio: "pipe", cwd: "/tmp" });
11787
11928
  } else {
11788
- execFileSync2(brewPath, ["install", pkg], { timeout: 18e4, stdio: "pipe" });
11929
+ execFileSync3(brewPath, ["install", pkg], { timeout: 18e4, stdio: "pipe" });
11789
11930
  }
11790
11931
  } else if (resolvedInstaller === "script") {
11791
11932
  if (!script) {
@@ -11807,7 +11948,7 @@ async function ensureToolkitCli(toolkitSlug) {
11807
11948
  process.env.PATH = `${brewBinDir}:${process.env.PATH ?? ""}`;
11808
11949
  }
11809
11950
  try {
11810
- execFileSync2("which", [binary], { timeout: 5e3, stdio: "pipe" });
11951
+ execFileSync3("which", [binary], { timeout: 5e3, stdio: "pipe" });
11811
11952
  log(`[toolkit-install] ${toolkitSlug}: installed \u2014 ${binary} now on PATH`);
11812
11953
  toolkitCliEnsured.add(toolkitSlug);
11813
11954
  toolkitCliRetryAfter.delete(toolkitSlug);
@@ -11855,16 +11996,16 @@ async function ensureIsolationImage(imageUri) {
11855
11996
  }
11856
11997
  isolationImageInFlight.add(imageUri);
11857
11998
  try {
11858
- const { execFileSync: execFileSync2 } = await import("child_process");
11999
+ const { execFileSync: execFileSync3 } = await import("child_process");
11859
12000
  try {
11860
- execFileSync2("which", ["docker"], { timeout: 5e3, stdio: "pipe" });
12001
+ execFileSync3("which", ["docker"], { timeout: 5e3, stdio: "pipe" });
11861
12002
  } catch {
11862
12003
  recordIsolationImageFailure(imageUri, `'docker' not found on host - required to pull the isolation image (install it, then the manager retries)`);
11863
12004
  return;
11864
12005
  }
11865
12006
  const hasAws = (() => {
11866
12007
  try {
11867
- execFileSync2("which", ["aws"], { timeout: 5e3, stdio: "pipe" });
12008
+ execFileSync3("which", ["aws"], { timeout: 5e3, stdio: "pipe" });
11868
12009
  return true;
11869
12010
  } catch {
11870
12011
  return false;
@@ -11873,11 +12014,11 @@ async function ensureIsolationImage(imageUri) {
11873
12014
  if (isPublic) {
11874
12015
  if (hasAws) {
11875
12016
  try {
11876
- const password = execFileSync2("aws", ["ecr-public", "get-login-password", "--region", "us-east-1"], {
12017
+ const password = execFileSync3("aws", ["ecr-public", "get-login-password", "--region", "us-east-1"], {
11877
12018
  timeout: 3e4,
11878
12019
  stdio: ["ignore", "pipe", "pipe"]
11879
12020
  }).toString().trim();
11880
- execFileSync2("docker", ["login", "--username", "AWS", "--password-stdin", "public.ecr.aws"], {
12021
+ execFileSync3("docker", ["login", "--username", "AWS", "--password-stdin", "public.ecr.aws"], {
11881
12022
  input: password,
11882
12023
  timeout: 3e4,
11883
12024
  stdio: ["pipe", "pipe", "pipe"]
@@ -11892,11 +12033,11 @@ async function ensureIsolationImage(imageUri) {
11892
12033
  return;
11893
12034
  }
11894
12035
  try {
11895
- const password = execFileSync2("aws", ["ecr", "get-login-password", "--region", privRegion], {
12036
+ const password = execFileSync3("aws", ["ecr", "get-login-password", "--region", privRegion], {
11896
12037
  timeout: 3e4,
11897
12038
  stdio: ["ignore", "pipe", "pipe"]
11898
12039
  }).toString().trim();
11899
- execFileSync2("docker", ["login", "--username", "AWS", "--password-stdin", registry], {
12040
+ execFileSync3("docker", ["login", "--username", "AWS", "--password-stdin", registry], {
11900
12041
  input: password,
11901
12042
  timeout: 3e4,
11902
12043
  stdio: ["pipe", "pipe", "pipe"]
@@ -11977,7 +12118,7 @@ function runAsync(cmd, args, opts) {
11977
12118
  let stdout = "";
11978
12119
  let stderr = "";
11979
12120
  let settled = false;
11980
- const timer2 = setTimeout(() => {
12121
+ const timer3 = setTimeout(() => {
11981
12122
  child.kill("SIGTERM");
11982
12123
  if (settled) return;
11983
12124
  settled = true;
@@ -11998,13 +12139,13 @@ function runAsync(cmd, args, opts) {
11998
12139
  child.on("error", (err) => {
11999
12140
  if (settled) return;
12000
12141
  settled = true;
12001
- clearTimeout(timer2);
12142
+ clearTimeout(timer3);
12002
12143
  reject(err);
12003
12144
  });
12004
12145
  child.on("close", (code) => {
12005
12146
  if (settled) return;
12006
12147
  settled = true;
12007
- clearTimeout(timer2);
12148
+ clearTimeout(timer3);
12008
12149
  resolve({ code: code ?? -1, stdout, stderr });
12009
12150
  });
12010
12151
  }).catch(reject);
@@ -12016,8 +12157,8 @@ function claudeManagedSettingsPath() {
12016
12157
  function ensureClaudeManagedSettings(path = claudeManagedSettingsPath()) {
12017
12158
  try {
12018
12159
  let settings = {};
12019
- if (existsSync14(path)) {
12020
- const raw = readFileSync27(path, "utf-8").trim();
12160
+ if (existsSync15(path)) {
12161
+ const raw = readFileSync28(path, "utf-8").trim();
12021
12162
  if (raw) {
12022
12163
  let parsed;
12023
12164
  try {
@@ -12045,11 +12186,11 @@ function ensureClaudeManagedSettings(path = claudeManagedSettingsPath()) {
12045
12186
  }
12046
12187
  var OPENCODE_NPM_VERSION = "1.18.3";
12047
12188
  async function ensureOpencodeBinary() {
12048
- const { execFileSync: execFileSync2 } = await import("child_process");
12189
+ const { execFileSync: execFileSync3 } = await import("child_process");
12049
12190
  const bin = process.env["AGT_OPENCODE_BIN"]?.trim() || "opencode";
12050
12191
  const probe = () => {
12051
12192
  try {
12052
- execFileSync2(bin, ["--version"], { stdio: "ignore", timeout: 1e4 });
12193
+ execFileSync3(bin, ["--version"], { stdio: "ignore", timeout: 1e4 });
12053
12194
  return true;
12054
12195
  } catch {
12055
12196
  return false;
@@ -12070,7 +12211,7 @@ async function ensureOpencodeBinary() {
12070
12211
  return false;
12071
12212
  }
12072
12213
  try {
12073
- const prefix = execFileSync2("npm", ["prefix", "-g"], { encoding: "utf-8", timeout: 1e4 }).trim();
12214
+ const prefix = execFileSync3("npm", ["prefix", "-g"], { encoding: "utf-8", timeout: 1e4 }).trim();
12074
12215
  if (prefix) {
12075
12216
  const npmBin = join34(prefix, "bin");
12076
12217
  const current = (process.env.PATH ?? "").split(pathDelimiter);
@@ -12102,8 +12243,8 @@ async function ensureFrameworkBinary(frameworkId) {
12102
12243
  }
12103
12244
  frameworkBinaryChecked.add(frameworkId);
12104
12245
  lastManagedSettingsStatus = ensureClaudeManagedSettings();
12105
- const { execFileSync: execFileSync2 } = await import("child_process");
12106
- const brewPath = resolveBrewPath(execFileSync2);
12246
+ const { execFileSync: execFileSync3 } = await import("child_process");
12247
+ const brewPath = resolveBrewPath(execFileSync3);
12107
12248
  if (!brewPath) {
12108
12249
  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
12250
  return;
@@ -12116,7 +12257,7 @@ async function ensureFrameworkBinary(frameworkId) {
12116
12257
  }
12117
12258
  return runAsync(brewPath, args, opts);
12118
12259
  };
12119
- const claudeExists = claudeBinaryInstalled(execFileSync2);
12260
+ const claudeExists = claudeBinaryInstalled(execFileSync3);
12120
12261
  if (!claudeExists) {
12121
12262
  log(`Claude Code binary not found \u2014 installing via Homebrew${isRoot ? " (as ec2-user via sudo)" : ""}...`);
12122
12263
  try {
@@ -12133,7 +12274,7 @@ async function ensureFrameworkBinary(frameworkId) {
12133
12274
  if (!process.env.PATH?.split(":").includes(brewBinDir)) {
12134
12275
  process.env.PATH = `${brewBinDir}:${process.env.PATH ?? ""}`;
12135
12276
  }
12136
- if (existsSync14("/home/linuxbrew/.linuxbrew/bin/claude")) {
12277
+ if (existsSync15("/home/linuxbrew/.linuxbrew/bin/claude")) {
12137
12278
  log("Claude Code installed successfully");
12138
12279
  } else {
12139
12280
  log("Claude Code install completed but binary not found at expected path \u2014 check brew logs");
@@ -12151,13 +12292,13 @@ async function maybeUpgradeClaudeCode() {
12151
12292
  }
12152
12293
  claudeCodeUpgradeInFlight = true;
12153
12294
  stampClaudeCodeUpgradeMarker();
12154
- const { execFileSync: execFileSync2 } = await import("child_process");
12155
- const brewPath = resolveBrewPath(execFileSync2);
12295
+ const { execFileSync: execFileSync3 } = await import("child_process");
12296
+ const brewPath = resolveBrewPath(execFileSync3);
12156
12297
  if (!brewPath) {
12157
12298
  claudeCodeUpgradeInFlight = false;
12158
12299
  return;
12159
12300
  }
12160
- if (!claudeBinaryInstalled(execFileSync2)) {
12301
+ if (!claudeBinaryInstalled(execFileSync3)) {
12161
12302
  claudeCodeUpgradeInFlight = false;
12162
12303
  return;
12163
12304
  }
@@ -12241,8 +12382,8 @@ async function checkAndUpdateCli(opts) {
12241
12382
  }
12242
12383
  }
12243
12384
  async function checkAndUpdateCliViaBrew(force = false) {
12244
- const { execFileSync: execFileSync2 } = await import("child_process");
12245
- const brewPath = resolveBrewPath(execFileSync2);
12385
+ const { execFileSync: execFileSync3 } = await import("child_process");
12386
+ const brewPath = resolveBrewPath(execFileSync3);
12246
12387
  if (!brewPath) return "noop";
12247
12388
  {
12248
12389
  const brewPinRaw = resolveAgtCliPinRaw();
@@ -12269,13 +12410,13 @@ async function checkAndUpdateCliViaBrew(force = false) {
12269
12410
  }
12270
12411
  let metadataFresh = true;
12271
12412
  try {
12272
- execFileSync2(brewPath, ["update", "--quiet"], { timeout: 6e4, stdio: "pipe" });
12413
+ execFileSync3(brewPath, ["update", "--quiet"], { timeout: 6e4, stdio: "pipe" });
12273
12414
  } catch (err) {
12274
12415
  metadataFresh = false;
12275
12416
  log(`[self-update] brew update failed (continuing with stale cache): ${err.message}`);
12276
12417
  }
12277
12418
  try {
12278
- const outdated = execFileSync2(brewPath, ["outdated", "--json=v2"], {
12419
+ const outdated = execFileSync3(brewPath, ["outdated", "--json=v2"], {
12279
12420
  timeout: 3e4,
12280
12421
  encoding: "utf-8"
12281
12422
  });
@@ -12308,7 +12449,7 @@ async function checkAndUpdateCliViaBrew(force = false) {
12308
12449
  }
12309
12450
  log(`[self-update] agt CLI update available: ${installed} \u2192 ${latest}. Upgrading via brew${force ? " (forced \u2014 Update CLI now)" : ""}...`);
12310
12451
  try {
12311
- execFileSync2(brewPath, ["upgrade", "integrity-labs/tap/agt"], {
12452
+ execFileSync3(brewPath, ["upgrade", "integrity-labs/tap/agt"], {
12312
12453
  timeout: 12e4,
12313
12454
  stdio: "pipe"
12314
12455
  });
@@ -12485,7 +12626,7 @@ async function fetchUrgentDistTagVersion() {
12485
12626
  }
12486
12627
  }
12487
12628
  async function installAgtCliViaNpm(version, reasonLabel) {
12488
- const { execFileSync: execFileSync2 } = await import("child_process");
12629
+ const { execFileSync: execFileSync3 } = await import("child_process");
12489
12630
  const isRoot = typeof process.getuid === "function" && process.getuid() === 0;
12490
12631
  const cmd = isRoot ? "npm" : "sudo";
12491
12632
  const installArgs = [
@@ -12496,14 +12637,14 @@ async function installAgtCliViaNpm(version, reasonLabel) {
12496
12637
  ];
12497
12638
  const args = isRoot ? installArgs : ["-n", "npm", ...installArgs];
12498
12639
  try {
12499
- execFileSync2(cmd, args, { timeout: 18e4, stdio: "pipe" });
12640
+ execFileSync3(cmd, args, { timeout: 18e4, stdio: "pipe" });
12500
12641
  } catch (err) {
12501
12642
  log(`[self-update] npm upgrade failed: ${err.message}`);
12502
12643
  return "failed";
12503
12644
  }
12504
12645
  let smokeOk = false;
12505
12646
  try {
12506
- const out = execFileSync2("agt", ["--version"], { timeout: 15e3, stdio: "pipe" }).toString();
12647
+ const out = execFileSync3("agt", ["--version"], { timeout: 15e3, stdio: "pipe" }).toString();
12507
12648
  smokeOk = isAgtVersionSmokeOk(out, version);
12508
12649
  if (!smokeOk) {
12509
12650
  log(
@@ -12568,8 +12709,8 @@ function effectiveRuntimeAuthenticated() {
12568
12709
  async function maybeProbeClaudeRuntimeAuth() {
12569
12710
  if (runtimeAuthProbeInFlight) return;
12570
12711
  if (Date.now() - lastRuntimeAuthProbeAt < RUNTIME_AUTH_PROBE_INTERVAL_MS) return;
12571
- const { execFileSync: execFileSync2 } = await import("child_process");
12572
- if (!claudeBinaryInstalled(execFileSync2)) return;
12712
+ const { execFileSync: execFileSync3 } = await import("child_process");
12713
+ if (!claudeBinaryInstalled(execFileSync3)) return;
12573
12714
  runtimeAuthProbeInFlight = true;
12574
12715
  lastRuntimeAuthProbeAt = Date.now();
12575
12716
  try {
@@ -12670,7 +12811,7 @@ async function checkClaudeAuth() {
12670
12811
  }
12671
12812
  var evalEmptyMcpConfigPath = null;
12672
12813
  function ensureEvalEmptyMcpConfig() {
12673
- if (evalEmptyMcpConfigPath && existsSync14(evalEmptyMcpConfigPath)) return evalEmptyMcpConfigPath;
12814
+ if (evalEmptyMcpConfigPath && existsSync15(evalEmptyMcpConfigPath)) return evalEmptyMcpConfigPath;
12674
12815
  const dir = join34(homedir16(), ".augmented");
12675
12816
  try {
12676
12817
  mkdirSync11(dir, { recursive: true });
@@ -12991,10 +13132,10 @@ function flushRestartedAgentDiagnostics(hostId, codeNames) {
12991
13132
  if (codeNames.length === 0) return;
12992
13133
  void (async () => {
12993
13134
  try {
12994
- const { collectDiagnostics } = await import("../persistent-session-JLTLTQHQ.js");
13135
+ const { collectDiagnostics } = await import("../persistent-session-YRCF7AAC.js");
12995
13136
  await api.post("/host/heartbeat", {
12996
13137
  host_id: hostId,
12997
- agent_diagnostics: collectDiagnostics(codeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics)
13138
+ agent_diagnostics: collectDiagnostics(codeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor)
12998
13139
  });
12999
13140
  } catch (err) {
13000
13141
  log(`[restart] post-respawn diagnostics flush failed: ${err.message}`);
@@ -13024,7 +13165,7 @@ async function pollCycle() {
13024
13165
  getSlackToken: (codeName) => agentChannelTokens.get(codeName)?.slack ?? null,
13025
13166
  sendSlack: async (botToken, body) => {
13026
13167
  const controller = new AbortController();
13027
- const timer2 = setTimeout(() => controller.abort(), 5e3);
13168
+ const timer3 = setTimeout(() => controller.abort(), 5e3);
13028
13169
  try {
13029
13170
  const res = await fetch("https://slack.com/api/chat.postMessage", {
13030
13171
  method: "POST",
@@ -13041,7 +13182,7 @@ async function pollCycle() {
13041
13182
  const isAbort = err.name === "AbortError";
13042
13183
  return { ok: false, error: isAbort ? "timeout" : err.message };
13043
13184
  } finally {
13044
- clearTimeout(timer2);
13185
+ clearTimeout(timer3);
13045
13186
  }
13046
13187
  },
13047
13188
  // ENG-6399: report the restart to audit_log via POST /host/restart-event.
@@ -13099,9 +13240,9 @@ async function pollCycle() {
13099
13240
  }
13100
13241
  try {
13101
13242
  const { detectHostSecurity } = await import("../host-security-6PDFG7F5.js");
13102
- const { collectDiagnostics } = await import("../persistent-session-JLTLTQHQ.js");
13243
+ const { collectDiagnostics } = await import("../persistent-session-YRCF7AAC.js");
13103
13244
  const diagCodeNames = [...agentState.persistentSessionAgents];
13104
- const agentDiagnostics = diagCodeNames.length > 0 ? collectDiagnostics(diagCodeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics) : void 0;
13245
+ const agentDiagnostics = diagCodeNames.length > 0 ? collectDiagnostics(diagCodeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor) : void 0;
13105
13246
  let tailscaleHostname;
13106
13247
  try {
13107
13248
  const { execSync: es } = await import("child_process");
@@ -13222,7 +13363,7 @@ async function pollCycle() {
13222
13363
  collectPanelessActivityProbes,
13223
13364
  getResponsivenessIntervalMs,
13224
13365
  occupancyQualificationClassifications
13225
- } = await import("../responsiveness-probe-4GJUK5GG.js");
13366
+ } = await import("../responsiveness-probe-MFWXIRTJ.js");
13226
13367
  const probeIntervalMs = getResponsivenessIntervalMs();
13227
13368
  if (now - lastResponsivenessProbeAt > probeIntervalMs) {
13228
13369
  const probeCodeNames = [...agentState.persistentSessionAgents];
@@ -13313,7 +13454,7 @@ async function pollCycle() {
13313
13454
  collectResponsivenessProbes,
13314
13455
  livePendingInboundOldestAgeSeconds,
13315
13456
  parkPendingInbound
13316
- } = await import("../responsiveness-probe-4GJUK5GG.js");
13457
+ } = await import("../responsiveness-probe-MFWXIRTJ.js");
13317
13458
  const { getProjectDir: wedgeProjectDir } = await import("../scheduler-engine-NDP36U7O.js");
13318
13459
  const wedgeNow = /* @__PURE__ */ new Date();
13319
13460
  const liveAgents = agentState.persistentSessionAgents;
@@ -13402,11 +13543,11 @@ async function pollCycle() {
13402
13543
  );
13403
13544
  if (hostFlagStore().getBoolean("wedge-transient-notice")) {
13404
13545
  try {
13405
- const paneTail = readFileSync27(paneLogPath(codeName), "utf8").slice(-65536);
13546
+ const paneTail = readFileSync28(paneLogPath(codeName), "utf8").slice(-65536);
13406
13547
  const transient = detectTransientApiErrorInLog(paneTail);
13407
13548
  if (transient) {
13408
13549
  const wedgeHome = join34(homedir16(), ".augmented", codeName);
13409
- if (existsSync14(wedgeHome)) {
13550
+ if (existsSync15(wedgeHome)) {
13410
13551
  atomicWriteFileSync(
13411
13552
  join34(wedgeHome, "watchdog-give-up.json"),
13412
13553
  JSON.stringify({
@@ -13777,7 +13918,7 @@ async function pollCycle() {
13777
13918
  // the watchdog, never fails the poll cycle.
13778
13919
  signalGiveUp: (codeName) => {
13779
13920
  const dir = join34(homedir16(), ".augmented", codeName);
13780
- if (!existsSync14(dir)) return;
13921
+ if (!existsSync15(dir)) return;
13781
13922
  atomicWriteFileSync(
13782
13923
  join34(dir, "watchdog-give-up.json"),
13783
13924
  JSON.stringify({ gave_up_at: (/* @__PURE__ */ new Date()).toISOString() })
@@ -13975,7 +14116,7 @@ async function processAgent(agent, agentStates) {
13975
14116
  const residuals = {
13976
14117
  gatewayRunning: false,
13977
14118
  portAllocated: false,
13978
- provisionDirExists: existsSync14(agentDir)
14119
+ provisionDirExists: existsSync15(agentDir)
13979
14120
  };
13980
14121
  if (!hasRevokedResiduals(residuals)) {
13981
14122
  agentStates.push({
@@ -14178,7 +14319,7 @@ async function processAgent(agent, agentStates) {
14178
14319
  newHash = sha256(stripDynamicSections(artifact.content));
14179
14320
  try {
14180
14321
  const projectClaudeMd = join34(config.configDir, agent.code_name, "project", "CLAUDE.md");
14181
- const existing = readFileSync27(projectClaudeMd, "utf-8");
14322
+ const existing = readFileSync28(projectClaudeMd, "utf-8");
14182
14323
  existingHash = sha256(stripDynamicSections(existing));
14183
14324
  } catch {
14184
14325
  existingHash = null;
@@ -14196,7 +14337,7 @@ async function processAgent(agent, agentStates) {
14196
14337
  const generatorKeys = Object.keys(generatorServers);
14197
14338
  let existingRaw = "";
14198
14339
  try {
14199
- existingRaw = readFileSync27(filePath, "utf-8");
14340
+ existingRaw = readFileSync28(filePath, "utf-8");
14200
14341
  } catch {
14201
14342
  }
14202
14343
  const existingServers = parseMcp(existingRaw);
@@ -14212,7 +14353,7 @@ async function processAgent(agent, agentStates) {
14212
14353
  } else if (artifact.relativePath === "opencode.json") {
14213
14354
  let existingRaw = null;
14214
14355
  try {
14215
- existingRaw = readFileSync27(filePath, "utf-8");
14356
+ existingRaw = readFileSync28(filePath, "utf-8");
14216
14357
  } catch {
14217
14358
  }
14218
14359
  const mergeResult = mergeOpencodeConfigArtifact(artifact.content, existingRaw);
@@ -14228,7 +14369,7 @@ async function processAgent(agent, agentStates) {
14228
14369
  }
14229
14370
  }
14230
14371
  if (changedFiles.length > 0) {
14231
- const isFirst = !existsSync14(join34(agentDir, "CHARTER.md"));
14372
+ const isFirst = !existsSync15(join34(agentDir, "CHARTER.md"));
14232
14373
  const verb = isFirst ? "Provisioning" : "Updating";
14233
14374
  const fileNames = changedFiles.map((f) => f.relativePath).join(", ");
14234
14375
  log(`${verb} '${agent.code_name}': ${fileNames}`);
@@ -14243,7 +14384,7 @@ async function processAgent(agent, agentStates) {
14243
14384
  }
14244
14385
  try {
14245
14386
  const provSkillsDir = join34(agentDir, ".claude", "skills");
14246
- if (existsSync14(provSkillsDir)) {
14387
+ if (existsSync15(provSkillsDir)) {
14247
14388
  for (const folder of readdirSync9(provSkillsDir)) {
14248
14389
  if (folder.startsWith("knowledge-")) {
14249
14390
  try {
@@ -14279,7 +14420,7 @@ async function processAgent(agent, agentStates) {
14279
14420
  if (Array.isArray(refreshData.workflows)) {
14280
14421
  try {
14281
14422
  const provWorkflowsDir = join34(agentDir, ".claude", "workflows");
14282
- if (existsSync14(provWorkflowsDir)) {
14423
+ if (existsSync15(provWorkflowsDir)) {
14283
14424
  const expected = new Set(refreshData.workflows.map((w) => `${w.name}.js`));
14284
14425
  for (const file of readdirSync9(provWorkflowsDir)) {
14285
14426
  if (!file.endsWith(".js")) continue;
@@ -14364,7 +14505,7 @@ async function processAgent(agent, agentStates) {
14364
14505
  }
14365
14506
  let lastDriftCheckAt = now;
14366
14507
  const written = agentState.writtenHashes.get(agent.agent_id);
14367
- if (written && existsSync14(agentDir)) {
14508
+ if (written && existsSync15(agentDir)) {
14368
14509
  const driftedFiles = [];
14369
14510
  for (const [file, expectedHash] of written) {
14370
14511
  const localHash = hashFile(join34(agentDir, file));
@@ -14784,7 +14925,7 @@ async function processAgent(agent, agentStates) {
14784
14925
  const projectMcpPath = join34(projectDir, ".mcp.json");
14785
14926
  let mcpConfig = { mcpServers: {} };
14786
14927
  try {
14787
- mcpConfig = JSON.parse(readFileSync27(provisionMcpPath, "utf-8"));
14928
+ mcpConfig = JSON.parse(readFileSync28(provisionMcpPath, "utf-8"));
14788
14929
  if (!mcpConfig.mcpServers) mcpConfig.mcpServers = {};
14789
14930
  } catch {
14790
14931
  }
@@ -14794,7 +14935,7 @@ async function processAgent(agent, agentStates) {
14794
14935
  const tz = directChatTeamSettings?.["timezone"];
14795
14936
  return typeof tz === "string" && tz.trim() !== "" ? tz.trim() : void 0;
14796
14937
  })();
14797
- if (existsSync14(localDirectChatChannel)) {
14938
+ if (existsSync15(localDirectChatChannel)) {
14798
14939
  const directChatEnv = {
14799
14940
  AGT_HOST: requireHost(),
14800
14941
  // ENG-5901 Track D: templated — the manager exports the real
@@ -14835,7 +14976,7 @@ async function processAgent(agent, agentStates) {
14835
14976
  }
14836
14977
  }
14837
14978
  const staleChannelsPath = join34(projectDir, ".mcp-channels.json");
14838
- if (existsSync14(staleChannelsPath)) {
14979
+ if (existsSync15(staleChannelsPath)) {
14839
14980
  try {
14840
14981
  rmSync5(staleChannelsPath, { force: true });
14841
14982
  } catch {
@@ -15051,7 +15192,7 @@ async function processAgent(agent, agentStates) {
15051
15192
  const envIntPath = join34(projectDir, ".env.integrations");
15052
15193
  let preWriteEnv;
15053
15194
  try {
15054
- preWriteEnv = readFileSync27(envIntPath, "utf-8");
15195
+ preWriteEnv = readFileSync28(envIntPath, "utf-8");
15055
15196
  } catch {
15056
15197
  preWriteEnv = void 0;
15057
15198
  }
@@ -15071,8 +15212,8 @@ async function processAgent(agent, agentStates) {
15071
15212
  if (fw === "claude-code" && isSessionHealthy(agent.code_name)) {
15072
15213
  try {
15073
15214
  const projectMcpPath = join34(projectDir, ".mcp.json");
15074
- const postWriteEnv = readFileSync27(envIntPath, "utf-8");
15075
- const mcpContent = readFileSync27(projectMcpPath, "utf-8");
15215
+ const postWriteEnv = readFileSync28(envIntPath, "utf-8");
15216
+ const mcpContent = readFileSync28(projectMcpPath, "utf-8");
15076
15217
  const changedVars = diffEnvIntegrations(preWriteEnv, postWriteEnv);
15077
15218
  const mcpJsonForReap = JSON.parse(mcpContent);
15078
15219
  const affectedServerKeys = findMcpServersUsingVars(mcpJsonForReap, changedVars);
@@ -15347,7 +15488,7 @@ async function processAgent(agent, agentStates) {
15347
15488
  // install target but cheap to sweep.
15348
15489
  join34(agentDir, ".claude", "skills")
15349
15490
  ];
15350
- const existingDirs = candidateSkillDirs.filter((d) => existsSync14(d));
15491
+ const existingDirs = candidateSkillDirs.filter((d) => existsSync15(d));
15351
15492
  const discoveredEntries = /* @__PURE__ */ new Set();
15352
15493
  for (const dir of existingDirs) {
15353
15494
  try {
@@ -15366,7 +15507,7 @@ async function processAgent(agent, agentStates) {
15366
15507
  entry,
15367
15508
  dirs: existingDirs,
15368
15509
  removeDir: (p) => {
15369
- if (existsSync14(p)) {
15510
+ if (existsSync15(p)) {
15370
15511
  rmSync6(p, { recursive: true, force: true });
15371
15512
  }
15372
15513
  }
@@ -15414,7 +15555,7 @@ async function processAgent(agent, agentStates) {
15414
15555
  let prunedAny = false;
15415
15556
  for (const dir of globalSkillDirs) {
15416
15557
  const p = join34(dir, id);
15417
- if (existsSync14(p) && existsSync14(join34(p, "SKILL.md"))) {
15558
+ if (existsSync15(p) && existsSync15(join34(p, "SKILL.md"))) {
15418
15559
  rmSync5(p, { recursive: true, force: true });
15419
15560
  prunedAny = true;
15420
15561
  }
@@ -15647,7 +15788,7 @@ async function processAgent(agent, agentStates) {
15647
15788
  let mcpJsonParsed = null;
15648
15789
  try {
15649
15790
  const mcpPath = join34(getProjectDir(agent.code_name), ".mcp.json");
15650
- mcpJsonParsed = JSON.parse(readFileSync27(mcpPath, "utf-8"));
15791
+ mcpJsonParsed = JSON.parse(readFileSync28(mcpPath, "utf-8"));
15651
15792
  } catch {
15652
15793
  }
15653
15794
  reapMissingMcpSessions({
@@ -16078,7 +16219,7 @@ Retried to the limit after repeated stalls \u2014 needs a look.`).catch(() => {
16078
16219
  }
16079
16220
  }
16080
16221
  const trackedFiles = frameworkAdapter.driftTrackedFiles();
16081
- if (trackedFiles.length > 0 && existsSync14(agentDir)) {
16222
+ if (trackedFiles.length > 0 && existsSync15(agentDir)) {
16082
16223
  const hashes = /* @__PURE__ */ new Map();
16083
16224
  for (const file of trackedFiles) {
16084
16225
  const h = hashFile(join34(agentDir, file));
@@ -16884,10 +17025,10 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
16884
17025
  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
17026
  void (async () => {
16886
17027
  try {
16887
- const { collectDiagnostics } = await import("../persistent-session-JLTLTQHQ.js");
17028
+ const { collectDiagnostics } = await import("../persistent-session-YRCF7AAC.js");
16888
17029
  await api.post("/host/heartbeat", {
16889
17030
  host_id: hostId,
16890
- agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics)
17031
+ agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor)
16891
17032
  });
16892
17033
  } catch (err) {
16893
17034
  log(`[restart-lane] post-respawn diagnostics flush failed for '${codeName}': ${err.message}`);
@@ -16935,10 +17076,10 @@ async function respawnAgentAfterMcpStop(codeName, reason) {
16935
17076
  }
16936
17077
  try {
16937
17078
  const hostId = await getHostId();
16938
- const { collectDiagnostics } = await import("../persistent-session-JLTLTQHQ.js");
17079
+ const { collectDiagnostics } = await import("../persistent-session-YRCF7AAC.js");
16939
17080
  await api.post("/host/heartbeat", {
16940
17081
  host_id: hostId,
16941
- agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics)
17082
+ agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor)
16942
17083
  });
16943
17084
  } catch (err) {
16944
17085
  log(`[fast-mcp-respawn] post-respawn diagnostics flush failed for '${codeName}': ${err.message}`);
@@ -17513,7 +17654,7 @@ async function processClaudePairSessions(agents) {
17513
17654
  killPairSession,
17514
17655
  pairTmuxSession,
17515
17656
  finalizeClaudePairOnboarding
17516
- } = await import("../claude-pair-runtime-PBFR6UGJ.js");
17657
+ } = await import("../claude-pair-runtime-CGVDKWFC.js");
17517
17658
  for (const pairId of pendingResp.cancelled_pair_ids ?? []) {
17518
17659
  log(`[claude-pair] sweeping orphan tmux session for pair ${pairId.slice(0, 8)}`);
17519
17660
  const killed = await killPairSession(pairTmuxSession(pairId));
@@ -17779,14 +17920,14 @@ async function syncMemories(agent, configDir, log2) {
17779
17920
  }
17780
17921
  pendingFreshMemorySync.delete(agent.agent_id);
17781
17922
  }
17782
- if (existsSync14(memoryDir)) {
17923
+ if (existsSync15(memoryDir)) {
17783
17924
  const prevHashes = memoryFileHashes.get(agent.agent_id) ?? /* @__PURE__ */ new Map();
17784
17925
  const currentHashes = /* @__PURE__ */ new Map();
17785
17926
  const changedMemories = [];
17786
17927
  for (const file of readdirSync9(memoryDir)) {
17787
17928
  if (!file.endsWith(".md")) continue;
17788
17929
  try {
17789
- const raw = readFileSync27(join34(memoryDir, file), "utf-8");
17930
+ const raw = readFileSync28(join34(memoryDir, file), "utf-8");
17790
17931
  const fileHash = createHash17("sha256").update(raw).digest("hex").slice(0, 16);
17791
17932
  currentHashes.set(file, fileHash);
17792
17933
  if (prevHashes.get(file) === fileHash) continue;
@@ -17811,7 +17952,7 @@ async function syncMemories(agent, configDir, log2) {
17811
17952
  } catch (err) {
17812
17953
  for (const mem of changedMemories) {
17813
17954
  for (const [file] of currentHashes) {
17814
- const parsed = parseMemoryFile(readFileSync27(join34(memoryDir, file), "utf-8"), file.replace(/\.md$/, ""));
17955
+ const parsed = parseMemoryFile(readFileSync28(join34(memoryDir, file), "utf-8"), file.replace(/\.md$/, ""));
17815
17956
  if (parsed?.name === mem.name) currentHashes.delete(file);
17816
17957
  }
17817
17958
  }
@@ -17824,7 +17965,7 @@ async function syncMemories(agent, configDir, log2) {
17824
17965
  }
17825
17966
  }
17826
17967
  async function downloadMemories(agent, memoryDir, log2, { force }) {
17827
- const localFiles = existsSync14(memoryDir) ? readdirSync9(memoryDir).filter((f) => f.endsWith(".md")).sort() : [];
17968
+ const localFiles = existsSync15(memoryDir) ? readdirSync9(memoryDir).filter((f) => f.endsWith(".md")).sort() : [];
17828
17969
  const localListHash = createHash17("sha256").update(localFiles.join(",")).digest("hex").slice(0, 16);
17829
17970
  const prevLocalHash = lastLocalFileHash.get(agent.agent_id);
17830
17971
  const prevDownload = lastDownloadHash.get(agent.agent_id);
@@ -17855,10 +17996,10 @@ description: ${JSON.stringify(mem.content.slice(0, 200))}
17855
17996
 
17856
17997
  ${mem.content}
17857
17998
  `;
17858
- if (existsSync14(filePath)) {
17999
+ if (existsSync15(filePath)) {
17859
18000
  let existing = "";
17860
18001
  try {
17861
- existing = readFileSync27(filePath, "utf-8");
18002
+ existing = readFileSync28(filePath, "utf-8");
17862
18003
  } catch {
17863
18004
  }
17864
18005
  if (existing === desired) continue;
@@ -17882,7 +18023,7 @@ ${mem.content}
17882
18023
  }
17883
18024
  }
17884
18025
  async function cleanupAgentFiles(codeName, agentDir) {
17885
- if (existsSync14(agentDir)) {
18026
+ if (existsSync15(agentDir)) {
17886
18027
  try {
17887
18028
  rmSync5(agentDir, { recursive: true, force: true });
17888
18029
  log(`Removed provision directory for '${codeName}'`);
@@ -17990,6 +18131,7 @@ function startPolling() {
17990
18131
  }, LIVENESS_HEARTBEAT_INTERVAL_MS);
17991
18132
  livenessTimer.unref();
17992
18133
  startPaneOccupancySampler(() => agentState.persistentSessionAgents);
18134
+ startPidPressureSampler(() => agentState.persistentSessionAgents);
17993
18135
  void startCaffeinate();
17994
18136
  loadChannelHashCache2();
17995
18137
  loadSenderPolicyBaseline2();
@@ -18084,6 +18226,7 @@ async function stopPolling(opts = {}) {
18084
18226
  livenessTimer = null;
18085
18227
  }
18086
18228
  stopPaneOccupancySampler();
18229
+ stopPidPressureSampler();
18087
18230
  const shutdownTimer = setTimeout(() => {
18088
18231
  log("Shutdown timeout exceeded (15s), forcing exit");
18089
18232
  process.exit(opts.forcedExitCode ?? 1);
@@ -18124,8 +18267,8 @@ function startManager(opts) {
18124
18267
  config = opts;
18125
18268
  try {
18126
18269
  const stateFile = getStateFile();
18127
- if (existsSync14(stateFile)) {
18128
- const raw = readFileSync27(stateFile, "utf-8");
18270
+ if (existsSync15(stateFile)) {
18271
+ const raw = readFileSync28(stateFile, "utf-8");
18129
18272
  const parsed = JSON.parse(raw);
18130
18273
  if (Array.isArray(parsed.agents)) {
18131
18274
  state7.agents = parsed.agents;
@@ -18181,7 +18324,7 @@ async function reapOrphanedClaudePids() {
18181
18324
  const looksLikeClaude = (pid) => {
18182
18325
  if (process.platform !== "linux") return true;
18183
18326
  try {
18184
- const comm = readFileSync27(`/proc/${pid}/comm`, "utf-8").trim().toLowerCase();
18327
+ const comm = readFileSync28(`/proc/${pid}/comm`, "utf-8").trim().toLowerCase();
18185
18328
  return comm.includes("claude");
18186
18329
  } catch {
18187
18330
  return false;
@@ -18285,7 +18428,7 @@ function deployMcpAssets() {
18285
18428
  let dir = moduleDir;
18286
18429
  for (let i = 0; i < 6; i++) {
18287
18430
  const candidate = join34(dir, "dist", "mcp");
18288
- if (existsSync14(join34(candidate, "index.js"))) {
18431
+ if (existsSync15(join34(candidate, "index.js"))) {
18289
18432
  mcpSourceDir = candidate;
18290
18433
  break;
18291
18434
  }
@@ -18300,8 +18443,8 @@ function deployMcpAssets() {
18300
18443
  const changedBasenames = [];
18301
18444
  const fileHash = (p) => {
18302
18445
  try {
18303
- if (!existsSync14(p)) return null;
18304
- return createHash17("sha256").update(readFileSync27(p)).digest("hex");
18446
+ if (!existsSync15(p)) return null;
18447
+ return createHash17("sha256").update(readFileSync28(p)).digest("hex");
18305
18448
  } catch {
18306
18449
  return null;
18307
18450
  }
@@ -18374,7 +18517,7 @@ function deployMcpAssets() {
18374
18517
  ]) {
18375
18518
  const src = join34(mcpSourceDir, file);
18376
18519
  const dst = join34(targetDir, file);
18377
- if (!existsSync14(src)) continue;
18520
+ if (!existsSync15(src)) continue;
18378
18521
  const before = fileHash(dst);
18379
18522
  try {
18380
18523
  copyFileSync(src, dst);
@@ -18394,13 +18537,13 @@ function deployMcpAssets() {
18394
18537
  const localMcpPath = join34(targetDir, "index.js");
18395
18538
  try {
18396
18539
  const agentsDir = join34(homedir16(), ".augmented", "agents");
18397
- if (existsSync14(agentsDir)) {
18540
+ if (existsSync15(agentsDir)) {
18398
18541
  for (const entry of readdirSync9(agentsDir, { withFileTypes: true })) {
18399
18542
  if (!entry.isDirectory()) continue;
18400
18543
  for (const subdir of ["provision", "project"]) {
18401
18544
  const mcpJsonPath = join34(agentsDir, entry.name, subdir, ".mcp.json");
18402
18545
  try {
18403
- const raw = readFileSync27(mcpJsonPath, "utf-8");
18546
+ const raw = readFileSync28(mcpJsonPath, "utf-8");
18404
18547
  if (!raw.includes("@integrity-labs/augmented-mcp")) continue;
18405
18548
  const mcpConfig = JSON.parse(raw);
18406
18549
  const augServer = mcpConfig.mcpServers?.["augmented"];