@integrity-labs/agt-cli 0.28.1316 → 0.28.1318

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/{api-client-CXLMRGYB.js → api-client-2MEHL5RP.js} +3 -3
  2. package/dist/bin/agt.js +7 -7
  3. package/dist/{chunk-2PCQX3FQ.js → chunk-2FY3WW6O.js} +3 -3
  4. package/dist/{chunk-JX4S7KFB.js → chunk-4ATDVGN4.js} +2 -2
  5. package/dist/{chunk-BSZRE4X6.js → chunk-AABYEBCU.js} +23 -3
  6. package/dist/chunk-AABYEBCU.js.map +1 -0
  7. package/dist/{chunk-4VFHXY7W.js → chunk-K4HGH6N2.js} +2 -2
  8. package/dist/{chunk-SXTB4L3V.js → chunk-KJNJNMRY.js} +5 -5
  9. package/dist/{chunk-JYBRZAAK.js → chunk-U6WANH5Z.js} +1 -1
  10. package/dist/chunk-U6WANH5Z.js.map +1 -0
  11. package/dist/{claude-code-updater-OLV2OEVG.js → claude-code-updater-BIBCDTQX.js} +3 -3
  12. package/dist/{claude-pair-runtime-QA3AUNBF.js → claude-pair-runtime-OR72T4SI.js} +3 -3
  13. package/dist/lib/manager-worker.js +135 -49
  14. package/dist/lib/manager-worker.js.map +1 -1
  15. package/dist/mcp/direct-chat-channel.js +15 -1
  16. package/dist/mcp/index.js +8 -0
  17. package/dist/{persistent-session-K5WFQVXD.js → persistent-session-PZI32TLO.js} +8 -4
  18. package/dist/{responsiveness-probe-Q5PDMK2L.js → responsiveness-probe-MJOASK7A.js} +4 -4
  19. package/dist/{session-auth-dead-T57ORTYP.js → session-auth-dead-KYFRPM4G.js} +3 -3
  20. package/package.json +1 -1
  21. package/dist/chunk-BSZRE4X6.js.map +0 -1
  22. package/dist/chunk-JYBRZAAK.js.map +0 -1
  23. /package/dist/{api-client-CXLMRGYB.js.map → api-client-2MEHL5RP.js.map} +0 -0
  24. /package/dist/{chunk-2PCQX3FQ.js.map → chunk-2FY3WW6O.js.map} +0 -0
  25. /package/dist/{chunk-JX4S7KFB.js.map → chunk-4ATDVGN4.js.map} +0 -0
  26. /package/dist/{chunk-4VFHXY7W.js.map → chunk-K4HGH6N2.js.map} +0 -0
  27. /package/dist/{chunk-SXTB4L3V.js.map → chunk-KJNJNMRY.js.map} +0 -0
  28. /package/dist/{claude-code-updater-OLV2OEVG.js.map → claude-code-updater-BIBCDTQX.js.map} +0 -0
  29. /package/dist/{claude-pair-runtime-QA3AUNBF.js.map → claude-pair-runtime-OR72T4SI.js.map} +0 -0
  30. /package/dist/{persistent-session-K5WFQVXD.js.map → persistent-session-PZI32TLO.js.map} +0 -0
  31. /package/dist/{responsiveness-probe-Q5PDMK2L.js.map → responsiveness-probe-MJOASK7A.js.map} +0 -0
  32. /package/dist/{session-auth-dead-T57ORTYP.js.map → session-auth-dead-KYFRPM4G.js.map} +0 -0
@@ -13,9 +13,9 @@ import {
13
13
  probeClaudeInstalls,
14
14
  readsAsNativeInstall,
15
15
  shouldRunClaudeCodeUpdater
16
- } from "./chunk-4VFHXY7W.js";
16
+ } from "./chunk-K4HGH6N2.js";
17
17
  import "./chunk-XWVM4KPK.js";
18
- import "./chunk-JYBRZAAK.js";
18
+ import "./chunk-U6WANH5Z.js";
19
19
  import "./chunk-AIUIMEUS.js";
20
20
  import "./chunk-DGUM43GV.js";
21
21
  export {
@@ -34,4 +34,4 @@ export {
34
34
  readsAsNativeInstall,
35
35
  shouldRunClaudeCodeUpdater
36
36
  };
37
- //# sourceMappingURL=claude-code-updater-OLV2OEVG.js.map
37
+ //# sourceMappingURL=claude-code-updater-BIBCDTQX.js.map
@@ -10,7 +10,7 @@ import {
10
10
  import {
11
11
  redactPaneFrame,
12
12
  sanitizeTerminalFrame
13
- } from "./chunk-JYBRZAAK.js";
13
+ } from "./chunk-U6WANH5Z.js";
14
14
  import {
15
15
  CLAUDE_CONFIG_DIR_ENV,
16
16
  claudeConfigDirFor,
@@ -323,7 +323,7 @@ async function spawnPairSession(session) {
323
323
  return { ok: true };
324
324
  } catch {
325
325
  }
326
- const { resolveClaudeBinary } = await import("./persistent-session-K5WFQVXD.js");
326
+ const { resolveClaudeBinary } = await import("./persistent-session-PZI32TLO.js");
327
327
  const claudeBin = resolveClaudeBinary();
328
328
  const pairEnv = {
329
329
  ...process.env,
@@ -838,4 +838,4 @@ export {
838
838
  startClaudePair,
839
839
  submitClaudePairCode
840
840
  };
841
- //# sourceMappingURL=claude-pair-runtime-QA3AUNBF.js.map
841
+ //# sourceMappingURL=claude-pair-runtime-OR72T4SI.js.map
@@ -70,7 +70,7 @@ import {
70
70
  tripClass,
71
71
  writeEtcEnvironment,
72
72
  writeProfileDScript
73
- } from "../chunk-SXTB4L3V.js";
73
+ } from "../chunk-KJNJNMRY.js";
74
74
  import {
75
75
  ApiError,
76
76
  adoptHostKeyInProcess,
@@ -88,7 +88,7 @@ import {
88
88
  probeHostKey,
89
89
  requireHost,
90
90
  setConfigHash
91
- } from "../chunk-2PCQX3FQ.js";
91
+ } from "../chunk-2FY3WW6O.js";
92
92
  import {
93
93
  BLOCKED_ON_PROMPT_DECISION,
94
94
  CHANNEL_SECRET_ENV_KEYS,
@@ -185,7 +185,7 @@ import {
185
185
  webFetchBaselineValue,
186
186
  webFetchRestartNeeded,
187
187
  writeEgressAllowlist
188
- } from "../chunk-BSZRE4X6.js";
188
+ } from "../chunk-AABYEBCU.js";
189
189
  import {
190
190
  isAgentIdle,
191
191
  isStaleForToday,
@@ -197,7 +197,7 @@ import {
197
197
  subagentActivityAgeSeconds,
198
198
  subagentTranscriptDir,
199
199
  transcriptActivityAgeSeconds
200
- } from "../chunk-JX4S7KFB.js";
200
+ } from "../chunk-4ATDVGN4.js";
201
201
  import {
202
202
  classifyUnanswerablePane,
203
203
  focusedConfirmDialogBlock,
@@ -223,7 +223,7 @@ import {
223
223
  runSafeCleanup,
224
224
  tightestDiskStat,
225
225
  withPackageCacheLock
226
- } from "../chunk-4VFHXY7W.js";
226
+ } from "../chunk-K4HGH6N2.js";
227
227
  import {
228
228
  parsePsRows,
229
229
  reapOrphanChannelMcps
@@ -352,7 +352,7 @@ import {
352
352
  stabiliseResetInstant,
353
353
  sumTranscriptUsageInWindow,
354
354
  summarizeTranscriptActivity
355
- } from "../chunk-JYBRZAAK.js";
355
+ } from "../chunk-U6WANH5Z.js";
356
356
  import {
357
357
  CLAUDE_CONFIG_DIR_ENV,
358
358
  claudeConfigDirFor,
@@ -1008,7 +1008,7 @@ function hostStragglerGate(codeName, scan, deps) {
1008
1008
  const unverified = lingering.filter((l) => l.state === "unverified" && !found.pids.includes(l.pid));
1009
1009
  for (const u of unverified) {
1010
1010
  deps.log(
1011
- `[persistent-session] HOST_STRAGGLER_UNVERIFIED code_name=${codeName} pid=${u.pid} argv0=${u.argv0} - a host process signalled earlier is not confirmed gone and its identity cannot be confirmed; not signalled, spawn held (ENG-11871)`
1011
+ `[persistent-session] HOST_STRAGGLER_UNVERIFIED code_name=${codeName} pid=${u.pid} argv0=${u.argv0} - a host process signalled (or, during the login refresh hold, seen) earlier is not confirmed gone and its identity cannot be confirmed; not signalled, spawn held (ENG-11871)`
1012
1012
  );
1013
1013
  }
1014
1014
  const roots = [...found.roots, ...verified.map((l) => ({ pid: l.pid, argv0: l.argv0 }))];
@@ -1259,7 +1259,18 @@ var SignalledHostPids = class {
1259
1259
  }
1260
1260
  if (list.length > 0) this.byAgent.set(codeName, list);
1261
1261
  }
1262
- /** Signalled processes not confirmed gone; the confirmed-gone ones are forgotten. */
1262
+ /**
1263
+ * ENG-12290: record targets the gate SAW but did not signal (the Claude login
1264
+ * refresh hold is active, so nothing is signalled). Kept exactly like a
1265
+ * signalled process, so `survivors` still holds a Docker start beside a
1266
+ * descendant whose root exits between two polls. Once the hold releases the
1267
+ * gate treats it like any lingering identity: re-verified, and signalled only
1268
+ * if it is confirmed to be the same process.
1269
+ */
1270
+ observe(codeName, targets) {
1271
+ this.remember(codeName, targets);
1272
+ }
1273
+ /** Signalled (or, during the hold, observed) processes not confirmed gone; the confirmed-gone ones are forgotten. */
1263
1274
  survivors(codeName) {
1264
1275
  const list = this.byAgent.get(codeName);
1265
1276
  if (!list) return [];
@@ -5591,6 +5602,8 @@ var AuthRefreshHoldTracker = class {
5591
5602
  state = { phase: "idle" };
5592
5603
  /** The expiry whose single-start phase already ran, so a stale expiry cannot re-open it. */
5593
5604
  singleDoneFor = null;
5605
+ /** ENG-12290: a fresh id per grant, so a holder can tell its grant from a later one. */
5606
+ grantSeq = 0;
5594
5607
  /**
5595
5608
  * The last expiry actually read (null when the read said there is none). An
5596
5609
  * expiry is known hours ahead, so the clock alone can say when its window
@@ -5629,7 +5642,7 @@ var AuthRefreshHoldTracker = class {
5629
5642
  if (verdict.reason === "past-cap" && this.singleDoneFor !== expiresAtMs) {
5630
5643
  const e = expiresAtMs;
5631
5644
  if (this.state.phase !== "single" || this.state.for !== e) {
5632
- this.state = { phase: "single", for: e, since: nowMs, grantedAt: null, grants: 0 };
5645
+ this.state = { phase: "single", for: e, since: nowMs, grantedAt: null, grants: 0, grantId: null };
5633
5646
  this.log(
5634
5647
  `[auth-hold] host=${this.host} past-cap expires_at=${new Date(e).toISOString()}: the token was not refreshed in the window; allowing ONE session start to refresh it, every other start held (at most ${SINGLE_START_MAX_MS / 6e4}m) [ENG-12287]`
5635
5648
  );
@@ -5638,6 +5651,7 @@ var AuthRefreshHoldTracker = class {
5638
5651
  if (nowMs > (single.grantedAt ?? single.since) + SINGLE_START_MAX_MS) {
5639
5652
  if (single.grantedAt !== null && single.grants < MAX_SINGLE_START_GRANTS) {
5640
5653
  single.grantedAt = null;
5654
+ single.grantId = null;
5641
5655
  single.since = nowMs;
5642
5656
  this.log(
5643
5657
  `[auth-hold] host=${this.host} single start ${single.grants} did not refresh; offering another (${single.grants}/${MAX_SINGLE_START_GRANTS}) [ENG-12287]`
@@ -5651,6 +5665,7 @@ var AuthRefreshHoldTracker = class {
5651
5665
  if (opts.claimStart && single.grantedAt === null) {
5652
5666
  single.grantedAt = nowMs;
5653
5667
  single.grants += 1;
5668
+ single.grantId = ++this.grantSeq;
5654
5669
  this.log(`[auth-hold] host=${this.host} single start granted (${single.grants}/${MAX_SINGLE_START_GRANTS}) [ENG-12287]`);
5655
5670
  return false;
5656
5671
  }
@@ -5694,11 +5709,26 @@ var AuthRefreshHoldTracker = class {
5694
5709
  returnStart(nowMs) {
5695
5710
  if (this.state.phase !== "single" || this.state.grantedAt === null) return;
5696
5711
  this.state.grantedAt = null;
5712
+ this.state.grantId = null;
5697
5713
  this.state.grants -= 1;
5698
5714
  this.log(
5699
5715
  `[auth-hold] host=${this.host} single start returned unspent at ${new Date(nowMs).toISOString()} (the granted session's previous process is not confirmed dead); the next claimer may take it [ENG-12287]`
5700
5716
  );
5701
5717
  }
5718
+ /** ENG-12290: the id of the single-start grant outstanding right now, or null. */
5719
+ get currentGrantId() {
5720
+ return this.state.phase === "single" ? this.state.grantId : null;
5721
+ }
5722
+ /**
5723
+ * ENG-12290 (CodeRabbit on #7796): is `grantId` still the outstanding grant,
5724
+ * judged against the clock now? A holder that took long enough over its awaits
5725
+ * for the grant to time out and pass to another claimer must not start too:
5726
+ * that would be two starts in the one-refresher phase.
5727
+ */
5728
+ grantIsCurrent(grantId, nowMs) {
5729
+ this.rejudge(nowMs);
5730
+ return grantId !== null && this.currentGrantId === grantId;
5731
+ }
5702
5732
  /** Any phase but idle holds restarts, self-updates, one-shots and /restart flags. */
5703
5733
  get engaged() {
5704
5734
  return this.state.phase !== "idle";
@@ -5727,18 +5757,22 @@ function createAuthRefreshHold(deps) {
5727
5757
  let cached = null;
5728
5758
  let inflight = null;
5729
5759
  const openRouterBacked = /* @__PURE__ */ new Set();
5760
+ const readExpiry = async () => {
5761
+ const t = now();
5762
+ if (!cached || t - cached.at >= READ_CACHE_MS) {
5763
+ if (!inflight) {
5764
+ inflight = deps.readExpiresAtMs().catch(() => "unreadable").finally(() => {
5765
+ inflight = null;
5766
+ });
5767
+ }
5768
+ cached = { at: t, expiresAtMs: await inflight };
5769
+ }
5770
+ return cached.expiresAtMs;
5771
+ };
5730
5772
  return {
5731
5773
  async isHeld(opts = {}) {
5732
- const t = now();
5733
- if (!cached || t - cached.at >= READ_CACHE_MS) {
5734
- if (!inflight) {
5735
- inflight = deps.readExpiresAtMs().catch(() => "unreadable").finally(() => {
5736
- inflight = null;
5737
- });
5738
- }
5739
- cached = { at: t, expiresAtMs: await inflight };
5740
- }
5741
- return tracker.observe(cached.expiresAtMs, now(), opts);
5774
+ const expiresAtMs = await readExpiry();
5775
+ return tracker.observe(expiresAtMs, now(), opts);
5742
5776
  },
5743
5777
  wasHeld: () => tracker.rejudge(now()),
5744
5778
  wasInWindow: () => {
@@ -5750,6 +5784,15 @@ function createAuthRefreshHold(deps) {
5750
5784
  return tracker.windowOpensWithin(now(), leadMs);
5751
5785
  },
5752
5786
  returnStart: () => tracker.returnStart(now()),
5787
+ async claimSessionStart(healthyBeforeHold) {
5788
+ const expiresAtMs = await readExpiry();
5789
+ const t = now();
5790
+ if (tracker.observe(expiresAtMs, t, { claimStart: !healthyBeforeHold })) return { claim: "held", grantId: null };
5791
+ if (!healthyBeforeHold && tracker.rejudge(t)) return { claim: "granted", grantId: tracker.currentGrantId };
5792
+ return { claim: "free", grantId: null };
5793
+ },
5794
+ currentGrantId: () => tracker.currentGrantId,
5795
+ grantIsCurrent: (grantId) => tracker.grantIsCurrent(grantId, now()),
5753
5796
  heldFor: (codeName) => !openRouterBacked.has(codeName) && tracker.rejudge(now()),
5754
5797
  noteSubscriptionBacked: (codeName, backed) => {
5755
5798
  if (backed) openRouterBacked.delete(codeName);
@@ -5765,8 +5808,14 @@ function stragglerSignalDeps(holdActive, real) {
5765
5808
  killHostStragglers: () => [],
5766
5809
  // CodeRabbit on PR #7796: survivors signalled BEFORE the hold still block a
5767
5810
  // spawn (a fresh scan can miss a descendant whose root exited), so reads go
5768
- // through; only NEW records are suppressed, because nothing is signalled now.
5769
- signalledHostPids: tracker === void 0 ? void 0 : { survivors: (c) => tracker.survivors(c), verify: (t) => tracker.verify(t), remember: () => void 0 },
5811
+ // through. ENG-12290: what the gate SEES while held is kept as observed (not
5812
+ // signalled), so a new root plus descendant keeps blocking after the root
5813
+ // exits. A tracker without `observe` records nothing, as before.
5814
+ signalledHostPids: tracker === void 0 ? void 0 : {
5815
+ survivors: (c) => tracker.survivors(c),
5816
+ verify: (t) => tracker.verify(t),
5817
+ remember: (c, targets) => tracker.observe?.(c, targets)
5818
+ },
5770
5819
  // CodeRabbit on PR #7796: a held check advances no SIGTERM-to-SIGKILL count.
5771
5820
  // The count is frozen, not reset: a streak built BEFORE the hold is kept, so
5772
5821
  // the first check after release continues it (SIGKILL if it had already
@@ -5774,6 +5823,12 @@ function stragglerSignalDeps(holdActive, real) {
5774
5823
  deferStreak: void 0
5775
5824
  };
5776
5825
  }
5826
+ function staleGrantReason(currentGrantId) {
5827
+ return currentGrantId === null ? "held: this start's single-start grant expired before it spawned (ENG-12290)" : "held: this start's single-start grant expired and passed to another start (ENG-12290)";
5828
+ }
5829
+ function singleStartLaunchAllowed(hold, grantId) {
5830
+ return !(hold.wasHeld() && !hold.grantIsCurrent(grantId));
5831
+ }
5777
5832
 
5778
5833
  // src/lib/manager/host-auth-refresh-hold.ts
5779
5834
  async function readHostExpiresAtMs() {
@@ -16045,7 +16100,7 @@ function createFileMigrationReportIO(codeName, log2) {
16045
16100
  };
16046
16101
  }
16047
16102
  var managerHostPost = async (path, body) => {
16048
- const { api: api2, ApiError: ApiError3 } = await import("../api-client-CXLMRGYB.js");
16103
+ const { api: api2, ApiError: ApiError3 } = await import("../api-client-2MEHL5RP.js");
16049
16104
  try {
16050
16105
  const json = await api2.post(path, body);
16051
16106
  return { status: 200, json };
@@ -18215,7 +18270,7 @@ var pendingDayRolloverReset = /* @__PURE__ */ new Set();
18215
18270
  var dayRolloverInboundHold = /* @__PURE__ */ new Map();
18216
18271
  var INBOUND_HOLD_EPISODE_GAP_MS = 12e4;
18217
18272
  async function channelInboundActivityAgeSecondsFor(codeName) {
18218
- const { newestPendingInboundActivityMtimeMs } = await import("../responsiveness-probe-Q5PDMK2L.js");
18273
+ const { newestPendingInboundActivityMtimeMs } = await import("../responsiveness-probe-MJOASK7A.js");
18219
18274
  const newest = newestPendingInboundActivityMtimeMs(dirname11(paneLogPath(codeName)));
18220
18275
  if (newest === null) return null;
18221
18276
  return Math.max(0, Math.floor((Date.now() - newest) / 1e3));
@@ -18591,6 +18646,7 @@ function runPendingForcedUpdate() {
18591
18646
  `[self-update] failed to persist update-request ack; retrying next poll: ${err.message}`
18592
18647
  );
18593
18648
  }
18649
+ if (outcome === "updated") restartPromptlyAfterUpgrade();
18594
18650
  }).catch((err) => {
18595
18651
  log(
18596
18652
  `[self-update] forced check failed: ${err.message} \u2014 leaving the request pending for retry.`
@@ -19126,7 +19182,7 @@ var agentRestartTimezoneInputs = /* @__PURE__ */ new Map();
19126
19182
  var lastVersionCheckAt = 0;
19127
19183
  var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
19128
19184
  var lastResponsivenessProbeAt = 0;
19129
- var agtCliVersion = true ? "0.28.1316" : "dev";
19185
+ var agtCliVersion = true ? "0.28.1318" : "dev";
19130
19186
  function resolveBrewPath(execFileSync5) {
19131
19187
  try {
19132
19188
  const out = execFileSync5("which", ["brew"], { timeout: 5e3 }).toString().trim();
@@ -21262,7 +21318,7 @@ function flushRestartedAgentDiagnostics(hostId, codeNames) {
21262
21318
  if (codeNames.length === 0) return;
21263
21319
  void (async () => {
21264
21320
  try {
21265
- const { collectDiagnostics } = await import("../persistent-session-K5WFQVXD.js");
21321
+ const { collectDiagnostics } = await import("../persistent-session-PZI32TLO.js");
21266
21322
  await api.post("/host/heartbeat", {
21267
21323
  host_id: hostId,
21268
21324
  agent_diagnostics: collectDiagnostics(codeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
@@ -21380,7 +21436,9 @@ async function pollCycleInner() {
21380
21436
  log(`[self-update] runPendingForcedUpdate threw: ${err.message}`);
21381
21437
  }
21382
21438
  if (!forcedUpdateKicked) {
21383
- checkAndUpdateCli().catch((err) => log(`[self-update] Check failed: ${err.message}`));
21439
+ checkAndUpdateCli().then((outcome) => {
21440
+ if (outcome === "updated") restartPromptlyAfterUpgrade();
21441
+ }).catch((err) => log(`[self-update] Check failed: ${err.message}`));
21384
21442
  }
21385
21443
  maybeUpgradeClaudeCode().catch((err) => log(`[claude-code-upgrade] Check failed: ${err.message}`));
21386
21444
  diskGuardDeps().then((deps) => maybeRunDiskGuard({ ...deps, nowMs: Date.now() })).catch((err) => log(`[disk-guard] check failed: ${err.message}`));
@@ -21407,7 +21465,7 @@ async function pollCycleInner() {
21407
21465
  }
21408
21466
  try {
21409
21467
  const { detectHostSecurity } = await import("../host-security-KQYYZZVW.js");
21410
- const { collectDiagnostics } = await import("../persistent-session-K5WFQVXD.js");
21468
+ const { collectDiagnostics } = await import("../persistent-session-PZI32TLO.js");
21411
21469
  const recordedSinceHeartbeat = new Set(spawnOutcomesSinceHeartbeat.drain());
21412
21470
  const diagCodeNames = heartbeatDiagnosticsCodeNames(agentState.persistentSessionAgents, recordedSinceHeartbeat);
21413
21471
  const heartbeatSpawnOutcomeFor = spawnOutcomeIfRecorded(spawnOutcomeForDiagnostics, recordedSinceHeartbeat);
@@ -21708,7 +21766,7 @@ async function pollCycleInner() {
21708
21766
  }
21709
21767
  try {
21710
21768
  const desiredClaudeCodeVersion = hbResp?.desired_claude_code_version?.trim();
21711
- const { maybeUpdateClaudeCode, shouldRunClaudeCodeUpdater } = await import("../claude-code-updater-OLV2OEVG.js");
21769
+ const { maybeUpdateClaudeCode, shouldRunClaudeCodeUpdater } = await import("../claude-code-updater-BIBCDTQX.js");
21712
21770
  const securityFloor = currentSecurityFloor();
21713
21771
  claudeUpdaterInFlight = true;
21714
21772
  if (desiredClaudeCodeVersion && (claudePairLoop.busy || claudePairingInProgress())) {
@@ -21743,7 +21801,7 @@ async function pollCycleInner() {
21743
21801
  collectPanelessActivityProbes,
21744
21802
  getResponsivenessIntervalMs,
21745
21803
  occupancyQualificationClassifications
21746
- } = await import("../responsiveness-probe-Q5PDMK2L.js");
21804
+ } = await import("../responsiveness-probe-MJOASK7A.js");
21747
21805
  const probeIntervalMs = getResponsivenessIntervalMs();
21748
21806
  if (now - lastResponsivenessProbeAt > probeIntervalMs) {
21749
21807
  const probeCodeNames = [...agentState.persistentSessionAgents];
@@ -21860,7 +21918,7 @@ async function pollCycleInner() {
21860
21918
  collectResponsivenessProbes,
21861
21919
  livePendingInboundOldestAgeSeconds,
21862
21920
  parkPendingInbound
21863
- } = await import("../responsiveness-probe-Q5PDMK2L.js");
21921
+ } = await import("../responsiveness-probe-MJOASK7A.js");
21864
21922
  const { getProjectDir: wedgeProjectDir } = await import("../scheduler-engine-5PCBGRNY.js");
21865
21923
  const wedgeNow = /* @__PURE__ */ new Date();
21866
21924
  const liveAgents = agentState.persistentSessionAgents;
@@ -22149,7 +22207,7 @@ async function pollCycleInner() {
22149
22207
  }
22150
22208
  );
22151
22209
  if (!paneFatalTornDown) continue;
22152
- const { parkPendingInbound } = await import("../responsiveness-probe-Q5PDMK2L.js");
22210
+ const { parkPendingInbound } = await import("../responsiveness-probe-MJOASK7A.js");
22153
22211
  const { parked, deadLettered } = parkPendingInbound(codeName, new Date(fatalNowMs));
22154
22212
  paneFatalStreak.delete(codeName);
22155
22213
  paneFatalRestarts.set(codeName, [...history, fatalNowMs]);
@@ -22180,7 +22238,7 @@ async function pollCycleInner() {
22180
22238
  TRANSCRIPT_MOUNT_ESCALATION_REFRESH_MS,
22181
22239
  bindSourceEscalations
22182
22240
  } = await import("../transcript-mount-health-OHE6IVJV.js");
22183
- const { transcriptBindSourcesFor, ensureTranscriptBindSources } = await import("../persistent-session-K5WFQVXD.js");
22241
+ const { transcriptBindSourcesFor, ensureTranscriptBindSources } = await import("../persistent-session-PZI32TLO.js");
22184
22242
  const mountConfig = resolveTranscriptMountConfig();
22185
22243
  const liveAgents = agentState.persistentSessionAgents;
22186
22244
  for (const tracked of [
@@ -22346,7 +22404,7 @@ async function pollCycleInner() {
22346
22404
  }
22347
22405
  try {
22348
22406
  const { scrapeMcpFailedBannerCount } = await import("../pane-mcp-banner-scraper-VR5QGP3J.js");
22349
- const { probeSessionAuth } = await import("../session-auth-dead-T57ORTYP.js");
22407
+ const { probeSessionAuth } = await import("../session-auth-dead-KYFRPM4G.js");
22350
22408
  const observations = [];
22351
22409
  const pendingCacheCommits = [];
22352
22410
  const modelApiErrorReportingOn = hostFlagStore().getBoolean("model-api-error-reporting");
@@ -26410,6 +26468,7 @@ async function ensurePersistentSessionUnchecked(agent, tasks, boardItems, refres
26410
26468
  }
26411
26469
  let stragglerGateRan = false;
26412
26470
  let grantedSingleStart = false;
26471
+ let singleStartGrantId = null;
26413
26472
  let subscriptionBacked = openRouterForAgentFrom(
26414
26473
  refreshData.openrouter ?? null
26415
26474
  ) ? false : null;
@@ -26590,16 +26649,18 @@ async function ensurePersistentSessionUnchecked(agent, tasks, boardItems, refres
26590
26649
  }
26591
26650
  }
26592
26651
  const healthyBeforeHold = isSessionHealthy(codeName);
26593
- if (await hostAuthRefreshHold.isHeld({ claimStart: !healthyBeforeHold })) {
26652
+ const { claim, grantId: claimedGrantId } = await hostAuthRefreshHold.claimSessionStart(healthyBeforeHold);
26653
+ if (claim === "held") {
26594
26654
  if (isSessionHealthy(codeName)) refreshLiveEgressAllowlist(agent, refreshData, modelPolicy);
26595
26655
  return authRefreshHeldOutcome(isSessionHealthy(codeName));
26596
26656
  }
26597
- grantedSingleStart = !healthyBeforeHold && hostAuthRefreshHold.wasHeld();
26657
+ grantedSingleStart = claim === "granted";
26598
26658
  if (grantedSingleStart && probeSessionProcess(codeName) !== "dead") {
26599
26659
  hostAuthRefreshHold.returnStart();
26600
26660
  grantedSingleStart = false;
26601
26661
  return authRefreshHeldOutcome(isSessionHealthy(codeName));
26602
26662
  }
26663
+ singleStartGrantId = grantedSingleStart ? claimedGrantId : null;
26603
26664
  } else if (!anthropicApiKey) {
26604
26665
  log(`[persistent-session] Skipping '${codeName}' \u2014 api_key mode but no key returned from exchange`);
26605
26666
  return {
@@ -27035,6 +27096,10 @@ ${truncateForLog(ctx.tail)}` : `; pane_tail_hash=sha256:${createHash21("sha256")
27035
27096
  closeSessionRunForCode(codeName, "cancelled", "held: the host Claude login refresh window opened before the spawn (ENG-12287)");
27036
27097
  return authRefreshHeldOutcome(isSessionHealthy(codeName));
27037
27098
  }
27099
+ if (grantedSingleStart && !singleStartLaunchAllowed(hostAuthRefreshHold, singleStartGrantId)) {
27100
+ closeSessionRunForCode(codeName, "cancelled", staleGrantReason(hostAuthRefreshHold.currentGrantId()));
27101
+ return authRefreshHeldOutcome(isSessionHealthy(codeName));
27102
+ }
27038
27103
  let spawnCopyFailedNow = false;
27039
27104
  const spawnMcpConfigPath = prepareSpawnMcpConfig({
27040
27105
  codeName,
@@ -27054,10 +27119,14 @@ ${truncateForLog(ctx.tail)}` : `; pane_tail_hash=sha256:${createHash21("sha256")
27054
27119
  }
27055
27120
  });
27056
27121
  if (!spawnCopyFailedNow) spawnCopyFailures.noteSuccess(codeName);
27122
+ const grantForLaunch = singleStartGrantId;
27123
+ const launchStillAllowed = grantedSingleStart ? () => singleStartLaunchAllowed(hostAuthRefreshHold, grantForLaunch) : void 0;
27057
27124
  const lateRefusal = startWithIsolationBackstop(() => startPersistentSession({
27058
27125
  codeName,
27059
27126
  agentId: agent.agent_id,
27060
27127
  isolationReadiness: startReadiness,
27128
+ launchStillAllowed,
27129
+ onLaunchFenced: grantedSingleStart ? () => closeSessionRunForCode(codeName, "cancelled", staleGrantReason(hostAuthRefreshHold.currentGrantId())) : void 0,
27061
27130
  projectDir,
27062
27131
  mcpConfigPath: spawnMcpConfigPath,
27063
27132
  claudeMdPath,
@@ -27569,7 +27638,7 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
27569
27638
  if (!refreshData) return;
27570
27639
  const framework = refreshData.agent?.framework ?? agentFrameworkCache.get(codeName) ?? DEFAULT_FRAMEWORK;
27571
27640
  const hostId = await getHostId();
27572
- const parkForRestart = await import("../responsiveness-probe-Q5PDMK2L.js").then(
27641
+ const parkForRestart = await import("../responsiveness-probe-MJOASK7A.js").then(
27573
27642
  (m) => m.parkPendingInbound,
27574
27643
  (err) => err
27575
27644
  );
@@ -27650,7 +27719,7 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
27650
27719
  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}`));
27651
27720
  void (async () => {
27652
27721
  try {
27653
- const { collectDiagnostics } = await import("../persistent-session-K5WFQVXD.js");
27722
+ const { collectDiagnostics } = await import("../persistent-session-PZI32TLO.js");
27654
27723
  await api.post("/host/heartbeat", {
27655
27724
  host_id: hostId,
27656
27725
  agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
@@ -27703,7 +27772,7 @@ async function respawnAgentAfterMcpStop(codeName, reason) {
27703
27772
  }
27704
27773
  try {
27705
27774
  const hostId = await getHostId();
27706
- const { collectDiagnostics } = await import("../persistent-session-K5WFQVXD.js");
27775
+ const { collectDiagnostics } = await import("../persistent-session-PZI32TLO.js");
27707
27776
  await api.post("/host/heartbeat", {
27708
27777
  host_id: hostId,
27709
27778
  agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
@@ -28579,7 +28648,7 @@ async function processClaudePairSessions(agents) {
28579
28648
  snapshotPairConfig,
28580
28649
  // ENG-11659: result -> report body + the manager.log line that records it.
28581
28650
  planPairStartReport
28582
- } = await import("../claude-pair-runtime-QA3AUNBF.js");
28651
+ } = await import("../claude-pair-runtime-OR72T4SI.js");
28583
28652
  const { resetClaudeSignin, describeSigninResetForLog, describeSigninResetFailure } = await import("../claude-signin-reset-6IJMMVYG.js");
28584
28653
  for (const pairId of pendingResp.cancelled_pair_ids ?? []) {
28585
28654
  log(`[claude-pair] sweeping orphan tmux session for pair ${pairId.slice(0, 8)}`);
@@ -29485,18 +29554,34 @@ async function reportSelfUpdateRestarts() {
29485
29554
  const deadline = new Promise((resolve2) => setTimeout(resolve2, 3e3));
29486
29555
  await Promise.race([posts, deadline]);
29487
29556
  }
29557
+ function restartManagerForUpgrade() {
29558
+ if (upgradeRestartInitiated) return;
29559
+ upgradeRestartInitiated = true;
29560
+ log(`[self-update] Restarting manager to load upgraded binary (${pendingUpgradeVersion ?? "unknown version"})`);
29561
+ void reportSelfUpdateRestarts().catch((err) => log(`[self-update] restart-event audit failed: ${err.message}`)).finally(() => {
29562
+ void stopPolling({ forcedExitCode: SUPERVISOR_RESTART_EXIT_CODE }).then(() => {
29563
+ process.exit(SUPERVISOR_RESTART_EXIT_CODE);
29564
+ });
29565
+ });
29566
+ }
29567
+ function upgradeRestartTiming(s) {
29568
+ if (!s.restartPending) return "nothing";
29569
+ return s.cycleInFlight ? "after-cycle" : "restart-now";
29570
+ }
29571
+ function restartPromptlyAfterUpgrade() {
29572
+ if (!running) return;
29573
+ const timing = upgradeRestartTiming({ restartPending: restartAfterUpgrade, cycleInFlight: pollCycleGuard.isRunning() });
29574
+ if (timing !== "restart-now") return;
29575
+ if (pollTimer) {
29576
+ clearTimeout(pollTimer);
29577
+ pollTimer = null;
29578
+ }
29579
+ log("[self-update] install complete and no poll cycle running: restarting now, not at the next poll timer [ENG-12290]");
29580
+ restartManagerForUpgrade();
29581
+ }
29488
29582
  function scheduleNext() {
29489
29583
  if (!running || !config) return;
29490
- const restartNow = () => {
29491
- if (upgradeRestartInitiated) return;
29492
- upgradeRestartInitiated = true;
29493
- log(`[self-update] Restarting manager to load upgraded binary (${pendingUpgradeVersion ?? "unknown version"})`);
29494
- void reportSelfUpdateRestarts().catch((err) => log(`[self-update] restart-event audit failed: ${err.message}`)).finally(() => {
29495
- void stopPolling({ forcedExitCode: SUPERVISOR_RESTART_EXIT_CODE }).then(() => {
29496
- process.exit(SUPERVISOR_RESTART_EXIT_CODE);
29497
- });
29498
- });
29499
- };
29584
+ const restartNow = restartManagerForUpgrade;
29500
29585
  if (restartAfterUpgrade) {
29501
29586
  restartNow();
29502
29587
  return;
@@ -30106,6 +30191,7 @@ export {
30106
30191
  stuckChannelSyncs,
30107
30192
  stuckRealtimeRebinds,
30108
30193
  supersededRuntimeImageIds,
30194
+ upgradeRestartTiming,
30109
30195
  verifiedChannelCredentials,
30110
30196
  writeManagedSettings
30111
30197
  };