@integrity-labs/agt-cli 0.28.1279 → 0.28.1281

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 (34) hide show
  1. package/dist/{api-client-YA7657ZN.js → api-client-UW5GPDR5.js} +3 -3
  2. package/dist/bin/agt.js +7 -7
  3. package/dist/{chunk-AW6F22KT.js → chunk-A26WJ7TB.js} +2 -2
  4. package/dist/{chunk-IEZRWDI2.js → chunk-CCWVPE2F.js} +3 -3
  5. package/dist/{chunk-VB63HJVE.js → chunk-FQMFWJUD.js} +2 -2
  6. package/dist/{chunk-QAK6K6YV.js → chunk-O5D6I72R.js} +48 -3
  7. package/dist/chunk-O5D6I72R.js.map +1 -0
  8. package/dist/{chunk-XTLIEWQ6.js → chunk-SHBU7NAQ.js} +5 -5
  9. package/dist/{chunk-TGYLUTCA.js → chunk-XNHTH267.js} +6 -3
  10. package/dist/{chunk-TGYLUTCA.js.map → chunk-XNHTH267.js.map} +1 -1
  11. package/dist/{claude-code-updater-HAUG3LWF.js → claude-code-updater-L3NMDSSG.js} +3 -3
  12. package/dist/{claude-pair-runtime-EBORDHDL.js → claude-pair-runtime-TUVLJDJZ.js} +3 -3
  13. package/dist/lib/manager-worker.js +249 -77
  14. package/dist/lib/manager-worker.js.map +1 -1
  15. package/dist/mcp/direct-chat-channel.js +41 -2
  16. package/dist/mcp/index.js +41 -2
  17. package/dist/mcp/origami.js +41 -2
  18. package/dist/mcp/slack-channel.js +41 -2
  19. package/dist/mcp/telegram-channel.js +41 -2
  20. package/dist/{persistent-session-GT56CLOE.js → persistent-session-LMR3WHVO.js} +4 -4
  21. package/dist/{responsiveness-probe-CNKJ7AW2.js → responsiveness-probe-FWPQTPQ5.js} +4 -4
  22. package/dist/{session-auth-dead-TDZADZTZ.js → session-auth-dead-5PNG5ILK.js} +3 -3
  23. package/package.json +1 -1
  24. package/dist/chunk-QAK6K6YV.js.map +0 -1
  25. /package/dist/{api-client-YA7657ZN.js.map → api-client-UW5GPDR5.js.map} +0 -0
  26. /package/dist/{chunk-AW6F22KT.js.map → chunk-A26WJ7TB.js.map} +0 -0
  27. /package/dist/{chunk-IEZRWDI2.js.map → chunk-CCWVPE2F.js.map} +0 -0
  28. /package/dist/{chunk-VB63HJVE.js.map → chunk-FQMFWJUD.js.map} +0 -0
  29. /package/dist/{chunk-XTLIEWQ6.js.map → chunk-SHBU7NAQ.js.map} +0 -0
  30. /package/dist/{claude-code-updater-HAUG3LWF.js.map → claude-code-updater-L3NMDSSG.js.map} +0 -0
  31. /package/dist/{claude-pair-runtime-EBORDHDL.js.map → claude-pair-runtime-TUVLJDJZ.js.map} +0 -0
  32. /package/dist/{persistent-session-GT56CLOE.js.map → persistent-session-LMR3WHVO.js.map} +0 -0
  33. /package/dist/{responsiveness-probe-CNKJ7AW2.js.map → responsiveness-probe-FWPQTPQ5.js.map} +0 -0
  34. /package/dist/{session-auth-dead-TDZADZTZ.js.map → session-auth-dead-5PNG5ILK.js.map} +0 -0
@@ -13,9 +13,9 @@ import {
13
13
  probeClaudeInstalls,
14
14
  readsAsNativeInstall,
15
15
  shouldRunClaudeCodeUpdater
16
- } from "./chunk-AW6F22KT.js";
16
+ } from "./chunk-A26WJ7TB.js";
17
17
  import "./chunk-XWVM4KPK.js";
18
- import "./chunk-QAK6K6YV.js";
18
+ import "./chunk-O5D6I72R.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-HAUG3LWF.js.map
37
+ //# sourceMappingURL=claude-code-updater-L3NMDSSG.js.map
@@ -10,7 +10,7 @@ import {
10
10
  import {
11
11
  redactPaneFrame,
12
12
  sanitizeTerminalFrame
13
- } from "./chunk-QAK6K6YV.js";
13
+ } from "./chunk-O5D6I72R.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-GT56CLOE.js");
326
+ const { resolveClaudeBinary } = await import("./persistent-session-LMR3WHVO.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-EBORDHDL.js.map
841
+ //# sourceMappingURL=claude-pair-runtime-TUVLJDJZ.js.map
@@ -70,7 +70,7 @@ import {
70
70
  tripClass,
71
71
  writeEtcEnvironment,
72
72
  writeProfileDScript
73
- } from "../chunk-XTLIEWQ6.js";
73
+ } from "../chunk-SHBU7NAQ.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-IEZRWDI2.js";
91
+ } from "../chunk-CCWVPE2F.js";
92
92
  import {
93
93
  BLOCKED_ON_PROMPT_DECISION,
94
94
  CHANNEL_SECRET_ENV_KEYS,
@@ -180,7 +180,7 @@ import {
180
180
  webFetchBaselineValue,
181
181
  webFetchRestartNeeded,
182
182
  writeEgressAllowlist
183
- } from "../chunk-TGYLUTCA.js";
183
+ } from "../chunk-XNHTH267.js";
184
184
  import {
185
185
  isAgentIdle,
186
186
  isStaleForToday,
@@ -191,7 +191,7 @@ import {
191
191
  subagentActivityAgeSeconds,
192
192
  subagentTranscriptDir,
193
193
  transcriptActivityAgeSeconds
194
- } from "../chunk-VB63HJVE.js";
194
+ } from "../chunk-FQMFWJUD.js";
195
195
  import {
196
196
  classifyUnanswerablePane,
197
197
  focusedConfirmDialogBlock,
@@ -217,7 +217,7 @@ import {
217
217
  runSafeCleanup,
218
218
  tightestDiskStat,
219
219
  withPackageCacheLock
220
- } from "../chunk-AW6F22KT.js";
220
+ } from "../chunk-A26WJ7TB.js";
221
221
  import {
222
222
  parsePsRows,
223
223
  reapOrphanChannelMcps
@@ -346,7 +346,7 @@ import {
346
346
  stabiliseResetInstant,
347
347
  sumTranscriptUsageInWindow,
348
348
  summarizeTranscriptActivity
349
- } from "../chunk-QAK6K6YV.js";
349
+ } from "../chunk-O5D6I72R.js";
350
350
  import {
351
351
  CLAUDE_CONFIG_DIR_ENV,
352
352
  claudeConfigDirFor,
@@ -467,6 +467,14 @@ var ConfigReloadLedger = class {
467
467
  * b4cfce82 hit). Cleared whenever the reload is re-torn-down or acked.
468
468
  */
469
469
  freshRenderAt = /* @__PURE__ */ new Map();
470
+ /**
471
+ * ENG-12141: the RENDER REVISION of that fresh render, i.e. a hash of the
472
+ * `.mcp.json` exactly as a spawn would load it (`projectMcpHash`, spawn view).
473
+ * A later fresh render with a different revision is a different config, so the
474
+ * marker moves to it; one with the same revision is the same config, so the
475
+ * earliest stays. See `noteFreshRender`.
476
+ */
477
+ freshRenderRevision = /* @__PURE__ */ new Map();
470
478
  /** What the poll does with this agent's integration-change request. Records a teardown. */
471
479
  service(agentId, requested) {
472
480
  const action = configReloadAction({ requested, pendingRequested: this.pending.get(agentId) });
@@ -474,12 +482,59 @@ var ConfigReloadLedger = class {
474
482
  this.pending.set(agentId, requested);
475
483
  this.confirmed.delete(agentId);
476
484
  this.freshRenderAt.delete(agentId);
485
+ this.freshRenderRevision.delete(agentId);
477
486
  }
478
487
  return action;
479
488
  }
480
- /** ENG-12052: a fresh render landed for the pending reload; keeps the earliest. */
481
- noteFreshRender(agentId, atMs) {
482
- if (this.pending.has(agentId) && !this.freshRenderAt.has(agentId)) this.freshRenderAt.set(agentId, atMs);
489
+ /**
490
+ * ENG-12052: a fresh render landed for the pending reload. Keeps the EARLIEST
491
+ * render of a given config.
492
+ *
493
+ * ENG-12141: `revision` is what the spawn will actually read, hashed: the
494
+ * spawn-view `.mcp.json` (`projectMcpHash`). When it differs from the revision
495
+ * the marker was set at, the rendered config CHANGED during the pending reload
496
+ * (a new `remoteMcp.url`, a tool-tier change, a server added or removed), so a
497
+ * session started from the earlier render is now stale and the marker moves to
498
+ * this render. Same revision: same config, earliest kept, so a session started
499
+ * from it is still fresh and is never restarted.
500
+ *
501
+ * INVARIANT (Sherlock, ENG-12141): anything that changes WHICH servers or tools a
502
+ * session gets must live in .mcp.json; .env holds live values only and is
503
+ * deliberately not hashed. Pinned by eng-12141-fresh-render-revision.test.ts.
504
+ *
505
+ * Why the rendered `.mcp.json` and nothing else. It is template-only: every
506
+ * writer emits `${VAR}` references and the ENG-5901 literal-secret lint refuses
507
+ * a write carrying a literal secret. So the values a reload must NOT restart
508
+ * for live outside it by construction: credentials and OAuth tokens (ENG-6918)
509
+ * in `.env.integrations` / the proxy token file, which the proxy re-reads per
510
+ * request or the hot-reload reap applies, and the Anchor `session_id`, which
511
+ * lands as `ANCHOR_BROWSER_SESSION_ID` and is read live per request. The
512
+ * values a reload MUST act on are spawn-fixed and live inside it: the server
513
+ * set, each URL (`AGT_REMOTE_MCP_URL`), and the tool tiers
514
+ * (`AGT_REMOTE_MCP_TOOL_TIERS`, read once at proxy start). No input allowlist,
515
+ * no deny list (the approach reverted on #7666).
516
+ *
517
+ * A `null`/absent revision (the file could not be read) can't be compared, so
518
+ * it keeps the earliest, which is the pre-ENG-12141 behaviour and fails safe:
519
+ * at worst it misses a rare reload, it never stops a fresh session.
520
+ */
521
+ noteFreshRender(agentId, atMs, revision = null) {
522
+ if (!this.pending.has(agentId)) return;
523
+ if (!this.freshRenderAt.has(agentId)) {
524
+ this.freshRenderAt.set(agentId, atMs);
525
+ this.freshRenderRevision.set(agentId, revision);
526
+ return;
527
+ }
528
+ const was = this.freshRenderRevision.get(agentId) ?? null;
529
+ if (revision === null) return;
530
+ if (was === null) {
531
+ this.freshRenderRevision.set(agentId, revision);
532
+ return;
533
+ }
534
+ if (revision !== was) {
535
+ this.freshRenderAt.set(agentId, atMs);
536
+ this.freshRenderRevision.set(agentId, revision);
537
+ }
483
538
  }
484
539
  /** ENG-12052: when the pending reload's first fresh render landed, or null. */
485
540
  freshRenderedAt(agentId) {
@@ -501,6 +556,7 @@ var ConfigReloadLedger = class {
501
556
  this.confirmed.delete(agentId);
502
557
  this.pending.delete(agentId);
503
558
  this.freshRenderAt.delete(agentId);
559
+ this.freshRenderRevision.delete(agentId);
504
560
  if (requestedAt) out.push({ agentId, requestedAt });
505
561
  }
506
562
  return out;
@@ -510,6 +566,7 @@ var ConfigReloadLedger = class {
510
566
  this.pending.delete(agentId);
511
567
  this.confirmed.delete(agentId);
512
568
  this.freshRenderAt.delete(agentId);
569
+ this.freshRenderRevision.delete(agentId);
513
570
  }
514
571
  };
515
572
  function stampIsOlder(a, b) {
@@ -4979,6 +5036,26 @@ function decideAuthResolveFailureAction(args) {
4979
5036
  };
4980
5037
  }
4981
5038
 
5039
+ // src/lib/manager/not-authenticated-skip.ts
5040
+ function notAuthenticatedSkipOutcome() {
5041
+ return { decision: "skipped-not-authenticated", spawnAttempted: false, sessionHealthyAfter: false, detail: NOT_AUTHENTICATED_CAUSE };
5042
+ }
5043
+ var NOT_AUTHENTICATED_CAUSE = "Claude Code is logged out on this host (subscription mode); log in again as the host user, a manager restart will not fix it";
5044
+
5045
+ // src/lib/heartbeat-claude-auth-absent.ts
5046
+ function fileAuthAfterHeartbeat(current, input) {
5047
+ if (input.rawMode !== "subscription" || input.detectionFailed) return current;
5048
+ if (input.detected === null) return false;
5049
+ if (typeof input.detected === "object" && input.detected.status === "expired") return false;
5050
+ return current;
5051
+ }
5052
+ function heartbeatClaudeAuthAbsentField(input) {
5053
+ if (input.rawMode !== "subscription") return {};
5054
+ if (input.detectionFailed) return {};
5055
+ if (input.detected !== null) return {};
5056
+ return { claude_auth_absent: true };
5057
+ }
5058
+
4982
5059
  // ../../packages/core/dist/host-config/capture.js
4983
5060
  import { createHash as createHash6 } from "crypto";
4984
5061
  var NON_SECRET_ENV_GATES = [
@@ -5459,22 +5536,7 @@ async function detectClaudeAuth() {
5459
5536
  return computeSubscriptionStatus(creds);
5460
5537
  }
5461
5538
  async function findClaudeCredentialsPaths() {
5462
- const candidates = [
5463
- join16(homedir5(), ".claude", ".credentials.json"),
5464
- join16(homedir5(), ".claude", "credentials.json")
5465
- ];
5466
- const isLinuxRoot = platform() === "linux" && typeof process.getuid === "function" && process.getuid() === 0;
5467
- if (isLinuxRoot) {
5468
- try {
5469
- const entries = await readdir2("/home", { withFileTypes: true });
5470
- for (const entry of entries.filter((entry2) => entry2.isDirectory()).sort((a, b) => a.name.localeCompare(b.name))) {
5471
- candidates.push(join16("/home", entry.name, ".claude", ".credentials.json"));
5472
- candidates.push(join16("/home", entry.name, ".claude", "credentials.json"));
5473
- }
5474
- } catch {
5475
- }
5476
- }
5477
- return candidates;
5539
+ return (await discoverCredentialCandidates()).paths;
5478
5540
  }
5479
5541
  async function readOauthCredentials() {
5480
5542
  if (platform() === "darwin") {
@@ -5511,6 +5573,79 @@ async function readJsonSilently(path) {
5511
5573
  return null;
5512
5574
  }
5513
5575
  }
5576
+ function credentialPresenceFrom(outcomes) {
5577
+ if (outcomes.includes("parsed")) return "present";
5578
+ if (outcomes.includes("unreadable")) return "unreadable";
5579
+ return "absent";
5580
+ }
5581
+ async function discoverCredentialCandidates(deps = {}) {
5582
+ const home = deps.home ?? homedir5();
5583
+ const paths = [join16(home, ".claude", ".credentials.json"), join16(home, ".claude", "credentials.json")];
5584
+ const outcomes = [];
5585
+ const linuxRoot = deps.linuxRoot ?? (platform() === "linux" && typeof process.getuid === "function" && process.getuid() === 0);
5586
+ if (linuxRoot) {
5587
+ const list = deps.readdirImpl ?? ((path) => readdir2(path, { withFileTypes: true }));
5588
+ try {
5589
+ const entries = await list("/home");
5590
+ for (const entry of entries.filter((e) => e.isDirectory()).sort((x, y) => x.name.localeCompare(y.name))) {
5591
+ paths.push(join16("/home", entry.name, ".claude", ".credentials.json"));
5592
+ paths.push(join16("/home", entry.name, ".claude", "credentials.json"));
5593
+ }
5594
+ } catch (err) {
5595
+ const code = err.code;
5596
+ outcomes.push(code === "ENOENT" || code === "ENOTDIR" ? "missing" : "unreadable");
5597
+ }
5598
+ }
5599
+ return { paths, outcomes };
5600
+ }
5601
+ function keychainOutcomeFrom(result) {
5602
+ if ("error" in result) return "unreadable";
5603
+ try {
5604
+ JSON.parse(result.stdout.trim());
5605
+ return "parsed";
5606
+ } catch {
5607
+ return "unreadable";
5608
+ }
5609
+ }
5610
+ async function keychainOutcome() {
5611
+ try {
5612
+ const { stdout } = await execFileAsync("security", ["find-generic-password", "-s", "Claude Code-credentials", "-w"], { timeout: 3e3 });
5613
+ return keychainOutcomeFrom({ stdout });
5614
+ } catch (error) {
5615
+ return keychainOutcomeFrom({ error });
5616
+ }
5617
+ }
5618
+ async function claudeCredentialPresence(deps = {}) {
5619
+ if (process.env["ANTHROPIC_API_KEY"] || process.env["ANTHROPIC_AUTH_TOKEN"]) return "present";
5620
+ const outcomes = [];
5621
+ const keychain = deps.keychain === void 0 ? platform() === "darwin" ? keychainOutcome : null : deps.keychain;
5622
+ if (keychain) outcomes.push(await keychain());
5623
+ let paths;
5624
+ if (deps.paths) {
5625
+ paths = deps.paths;
5626
+ } else {
5627
+ const discovered = await discoverCredentialCandidates();
5628
+ paths = discovered.paths;
5629
+ outcomes.push(...discovered.outcomes);
5630
+ }
5631
+ for (const path of paths) {
5632
+ let raw;
5633
+ try {
5634
+ raw = await readFile2(path, "utf-8");
5635
+ } catch (err) {
5636
+ const code = err.code;
5637
+ outcomes.push(code === "ENOENT" || code === "ENOTDIR" ? "missing" : "unreadable");
5638
+ continue;
5639
+ }
5640
+ try {
5641
+ JSON.parse(raw);
5642
+ outcomes.push("parsed");
5643
+ } catch {
5644
+ outcomes.push("unreadable");
5645
+ }
5646
+ }
5647
+ return credentialPresenceFrom(outcomes);
5648
+ }
5514
5649
  function computeSubscriptionStatus(creds) {
5515
5650
  const expiresAtMs = parseExpiresAt(creds.expiresAt);
5516
5651
  const hasRefreshToken = typeof creds.refreshToken === "string" && creds.refreshToken.trim().length > 0;
@@ -10550,6 +10685,12 @@ function foldRuntimeAuthVerdict(input) {
10550
10685
  }
10551
10686
  return { reported: previous, consecutiveFailures };
10552
10687
  }
10688
+ function shouldRecordRuntimeVerdict(input) {
10689
+ const { verdict, before, folded, requiredConsecutiveFailures } = input;
10690
+ if (verdict === "authenticated") return true;
10691
+ if (folded.reported !== before) return true;
10692
+ return verdict === "not-authenticated" && folded.consecutiveFailures >= requiredConsecutiveFailures;
10693
+ }
10553
10694
  function heartbeatRuntimeAuthReport(probeVerdict) {
10554
10695
  return probeVerdict ?? void 0;
10555
10696
  }
@@ -15144,7 +15285,7 @@ function createFileMigrationReportIO(codeName, log2) {
15144
15285
  };
15145
15286
  }
15146
15287
  var managerHostPost = async (path, body) => {
15147
- const { api: api2, ApiError: ApiError3 } = await import("../api-client-YA7657ZN.js");
15288
+ const { api: api2, ApiError: ApiError3 } = await import("../api-client-UW5GPDR5.js");
15148
15289
  try {
15149
15290
  const json = await api2.post(path, body);
15150
15291
  return { status: 200, json };
@@ -15673,6 +15814,10 @@ function refreshSlackRestartContextHints(codeNames, opts = {}) {
15673
15814
  }
15674
15815
 
15675
15816
  // src/lib/persistent-session-stuck-tracker.ts
15817
+ function stuckWarnHint(detail) {
15818
+ const cause = detail?.replace(/\s+/g, " ").trim();
15819
+ return cause ? `cause: ${cause}` : "manager-worker may need restart, or upstream guard is mis-firing (see ENG-5116)";
15820
+ }
15676
15821
  var DEFAULT_STUCK_WARN_THRESHOLD = 3;
15677
15822
  var DEFAULT_SPAWN_LOOP_WARN_THRESHOLD = 3;
15678
15823
  var PersistentSessionStuckTracker = class {
@@ -17195,7 +17340,7 @@ var pendingDayRolloverReset = /* @__PURE__ */ new Set();
17195
17340
  var dayRolloverInboundHold = /* @__PURE__ */ new Map();
17196
17341
  var INBOUND_HOLD_EPISODE_GAP_MS = 12e4;
17197
17342
  async function channelInboundActivityAgeSecondsFor(codeName) {
17198
- const { newestPendingInboundActivityMtimeMs } = await import("../responsiveness-probe-CNKJ7AW2.js");
17343
+ const { newestPendingInboundActivityMtimeMs } = await import("../responsiveness-probe-FWPQTPQ5.js");
17199
17344
  const newest = newestPendingInboundActivityMtimeMs(dirname11(paneLogPath(codeName)));
17200
17345
  if (newest === null) return null;
17201
17346
  return Math.max(0, Math.floor((Date.now() - newest) / 1e3));
@@ -18076,7 +18221,7 @@ var agentRestartTimezoneInputs = /* @__PURE__ */ new Map();
18076
18221
  var lastVersionCheckAt = 0;
18077
18222
  var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
18078
18223
  var lastResponsivenessProbeAt = 0;
18079
- var agtCliVersion = true ? "0.28.1279" : "dev";
18224
+ var agtCliVersion = true ? "0.28.1281" : "dev";
18080
18225
  function resolveBrewPath(execFileSync5) {
18081
18226
  try {
18082
18227
  const out = execFileSync5("which", ["brew"], { timeout: 5e3 }).toString().trim();
@@ -19378,7 +19523,12 @@ async function maybeProbeClaudeRuntimeAuth() {
19378
19523
  requiredConsecutiveFailures: RUNTIME_AUTH_PROBE_FAILURES_TO_CONDEMN
19379
19524
  });
19380
19525
  runtimeAuthConsecutiveFailures = folded.consecutiveFailures;
19381
- if (result.verdict === "authenticated" || folded.reported !== before) {
19526
+ if (shouldRecordRuntimeVerdict({
19527
+ verdict: result.verdict,
19528
+ before,
19529
+ folded,
19530
+ requiredConsecutiveFailures: RUNTIME_AUTH_PROBE_FAILURES_TO_CONDEMN
19531
+ })) {
19382
19532
  runtimeAuthProbeVerdict = folded.reported;
19383
19533
  }
19384
19534
  if (folded.reported !== before) {
@@ -20085,7 +20235,7 @@ function flushRestartedAgentDiagnostics(hostId, codeNames) {
20085
20235
  if (codeNames.length === 0) return;
20086
20236
  void (async () => {
20087
20237
  try {
20088
- const { collectDiagnostics } = await import("../persistent-session-GT56CLOE.js");
20238
+ const { collectDiagnostics } = await import("../persistent-session-LMR3WHVO.js");
20089
20239
  await api.post("/host/heartbeat", {
20090
20240
  host_id: hostId,
20091
20241
  agent_diagnostics: collectDiagnostics(codeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
@@ -20228,7 +20378,7 @@ async function pollCycleInner() {
20228
20378
  }
20229
20379
  try {
20230
20380
  const { detectHostSecurity } = await import("../host-security-KQYYZZVW.js");
20231
- const { collectDiagnostics } = await import("../persistent-session-GT56CLOE.js");
20381
+ const { collectDiagnostics } = await import("../persistent-session-LMR3WHVO.js");
20232
20382
  const diagCodeNames = [...agentState.persistentSessionAgents];
20233
20383
  const agentDiagnostics = diagCodeNames.length > 0 ? collectDiagnostics(diagCodeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor) : void 0;
20234
20384
  let tailscaleHostname;
@@ -20254,15 +20404,29 @@ async function pollCycleInner() {
20254
20404
  } catch {
20255
20405
  }
20256
20406
  let claudeAuth = null;
20407
+ let claudeAuthDetectionFailed = false;
20257
20408
  try {
20258
20409
  claudeAuth = await detectClaudeAuth();
20259
20410
  } catch (err) {
20411
+ claudeAuthDetectionFailed = true;
20260
20412
  const errText = err instanceof Error ? err.message : String(err);
20261
20413
  const errId = createHash21("sha256").update(errText).digest("hex").slice(0, 12);
20262
20414
  log(`Claude auth detection failed (error_id=${errId})`);
20263
20415
  }
20416
+ if (!claudeAuthDetectionFailed && claudeAuth === null) {
20417
+ try {
20418
+ if (await claudeCredentialPresence() !== "absent") claudeAuthDetectionFailed = true;
20419
+ } catch {
20420
+ claudeAuthDetectionFailed = true;
20421
+ }
20422
+ }
20264
20423
  let claudeAccountEmail = null;
20265
20424
  const claudeAuthModeRaw = getCachedClaudeAuthModeRaw();
20425
+ agentRuntimeAuthenticated = fileAuthAfterHeartbeat(agentRuntimeAuthenticated, {
20426
+ rawMode: claudeAuthModeRaw,
20427
+ detected: claudeAuth,
20428
+ detectionFailed: claudeAuthDetectionFailed
20429
+ });
20266
20430
  if (mayReportAccountEmail(claudeAuthModeRaw)) {
20267
20431
  try {
20268
20432
  const observation = await getClaudeAccountEmailObservation();
@@ -20325,6 +20489,13 @@ async function pollCycleInner() {
20325
20489
  hostname: tailscaleHostname,
20326
20490
  os_username: osUsername,
20327
20491
  claude_auth: claudeAuth ?? void 0,
20492
+ // ENG-12236: a subscription host with NO credential says so, instead of
20493
+ // omitting `claude_auth` and leaving a stale `valid` in place.
20494
+ ...heartbeatClaudeAuthAbsentField({
20495
+ rawMode: claudeAuthModeRaw,
20496
+ detected: claudeAuth,
20497
+ detectionFailed: claudeAuthDetectionFailed
20498
+ }),
20328
20499
  // OMITTED rather than sent as null when it cannot be read. The API
20329
20500
  // treats absence as "no observation" and leaves the stored label
20330
20501
  // alone; sending null would let a transient unreadable config WIPE a
@@ -20500,7 +20671,7 @@ async function pollCycleInner() {
20500
20671
  }
20501
20672
  try {
20502
20673
  const desiredClaudeCodeVersion = hbResp?.desired_claude_code_version?.trim();
20503
- const { maybeUpdateClaudeCode, shouldRunClaudeCodeUpdater } = await import("../claude-code-updater-HAUG3LWF.js");
20674
+ const { maybeUpdateClaudeCode, shouldRunClaudeCodeUpdater } = await import("../claude-code-updater-L3NMDSSG.js");
20504
20675
  const securityFloor = currentSecurityFloor();
20505
20676
  claudeUpdaterInFlight = true;
20506
20677
  if (desiredClaudeCodeVersion && (claudePairLoop.busy || claudePairingInProgress())) {
@@ -20535,7 +20706,7 @@ async function pollCycleInner() {
20535
20706
  collectPanelessActivityProbes,
20536
20707
  getResponsivenessIntervalMs,
20537
20708
  occupancyQualificationClassifications
20538
- } = await import("../responsiveness-probe-CNKJ7AW2.js");
20709
+ } = await import("../responsiveness-probe-FWPQTPQ5.js");
20539
20710
  const probeIntervalMs = getResponsivenessIntervalMs();
20540
20711
  if (now - lastResponsivenessProbeAt > probeIntervalMs) {
20541
20712
  const probeCodeNames = [...agentState.persistentSessionAgents];
@@ -20652,7 +20823,7 @@ async function pollCycleInner() {
20652
20823
  collectResponsivenessProbes,
20653
20824
  livePendingInboundOldestAgeSeconds,
20654
20825
  parkPendingInbound
20655
- } = await import("../responsiveness-probe-CNKJ7AW2.js");
20826
+ } = await import("../responsiveness-probe-FWPQTPQ5.js");
20656
20827
  const { getProjectDir: wedgeProjectDir } = await import("../scheduler-engine-5PCBGRNY.js");
20657
20828
  const wedgeNow = /* @__PURE__ */ new Date();
20658
20829
  const liveAgents = agentState.persistentSessionAgents;
@@ -20938,7 +21109,7 @@ async function pollCycleInner() {
20938
21109
  }
20939
21110
  }
20940
21111
  );
20941
- const { parkPendingInbound } = await import("../responsiveness-probe-CNKJ7AW2.js");
21112
+ const { parkPendingInbound } = await import("../responsiveness-probe-FWPQTPQ5.js");
20942
21113
  const { parked, deadLettered } = parkPendingInbound(codeName, new Date(fatalNowMs));
20943
21114
  paneFatalStreak.delete(codeName);
20944
21115
  paneFatalRestarts.set(codeName, [...history, fatalNowMs]);
@@ -20969,7 +21140,7 @@ async function pollCycleInner() {
20969
21140
  TRANSCRIPT_MOUNT_ESCALATION_REFRESH_MS,
20970
21141
  bindSourceEscalations
20971
21142
  } = await import("../transcript-mount-health-OHE6IVJV.js");
20972
- const { transcriptBindSourcesFor, ensureTranscriptBindSources } = await import("../persistent-session-GT56CLOE.js");
21143
+ const { transcriptBindSourcesFor, ensureTranscriptBindSources } = await import("../persistent-session-LMR3WHVO.js");
20973
21144
  const mountConfig = resolveTranscriptMountConfig();
20974
21145
  const liveAgents = agentState.persistentSessionAgents;
20975
21146
  for (const tracked of [
@@ -21134,7 +21305,7 @@ async function pollCycleInner() {
21134
21305
  }
21135
21306
  try {
21136
21307
  const { scrapeMcpFailedBannerCount } = await import("../pane-mcp-banner-scraper-VR5QGP3J.js");
21137
- const { probeSessionAuth } = await import("../session-auth-dead-TDZADZTZ.js");
21308
+ const { probeSessionAuth } = await import("../session-auth-dead-5PNG5ILK.js");
21138
21309
  const observations = [];
21139
21310
  const pendingCacheCommits = [];
21140
21311
  const modelApiErrorReportingOn = hostFlagStore().getBoolean("model-api-error-reporting");
@@ -23731,7 +23902,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
23731
23902
  }
23732
23903
  const reloadRendered = rotationHandled && !orphanPruneFailed && !mcpWriteFailed;
23733
23904
  if (configReloads.isPending(agent.agent_id) && integrationsFresh && reloadRendered) {
23734
- configReloads.noteFreshRender(agent.agent_id, Date.now());
23905
+ configReloads.noteFreshRender(agent.agent_id, Date.now(), projectMcpHash(agent.code_name, getProjectDir(agent.code_name)));
23735
23906
  }
23736
23907
  confirmConfigReload(
23737
23908
  {
@@ -24327,7 +24498,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
24327
24498
  });
24328
24499
  if (stuck.shouldWarn) {
24329
24500
  log(
24330
- `[persistent-session-stuck] WARN: agent=${agent.code_name} unhealthy with no spawn attempt for ${stuck.consecutiveTicks} consecutive ticks (last_decision=${psResult.decision}) \u2014 manager-worker may need restart, or upstream guard is mis-firing (see ENG-5116)`
24501
+ `[persistent-session-stuck] WARN: agent=${agent.code_name} unhealthy with no spawn attempt for ${stuck.consecutiveTicks} consecutive ticks (last_decision=${psResult.decision}) \u2014 ${stuckWarnHint(psResult.detail)}`
24331
24502
  );
24332
24503
  } else if (stuck.recovered) {
24333
24504
  log(`[persistent-session-stuck] agent=${agent.code_name} recovered from stuck state`);
@@ -25087,6 +25258,38 @@ async function ensurePersistentSession(...args) {
25087
25258
  const blocked = result.sessionHealthyAfter ? sessionBlockedOnPrompt(args[0].code_name) : null;
25088
25259
  return applyBlockedPromptVerdict(result, blocked);
25089
25260
  }
25261
+ function refreshLiveEgressAllowlist(agent, refreshData, modelPolicy) {
25262
+ const codeName = agent.code_name;
25263
+ if (egressMode(codeName) === "allowlist") {
25264
+ const allowlist = deriveEgressAllowlist(
25265
+ refreshData.tools?.raw_content,
25266
+ modelPolicy,
25267
+ integrationEgressDomainsFor(agent, "live-refresh")
25268
+ );
25269
+ const prev = egressAllowlistBySession.get(codeName);
25270
+ if (!prev || !egressAllowlistEqual(prev, allowlist)) {
25271
+ try {
25272
+ writeEgressAllowlist(codeName, allowlist);
25273
+ const removed = prev ? prev.some((d) => !allowlist.includes(d)) : true;
25274
+ const applied = removed ? restartEgressSidecar(codeName) : reloadEgressSidecar(codeName);
25275
+ if (applied) {
25276
+ egressAllowlistBySession.set(codeName, allowlist);
25277
+ log(
25278
+ `[persistent-session] egress allowlist for '${codeName}' changed (${allowlist.length} domains), ${removed ? "restarted" : "reloaded"} squid sidecar`
25279
+ );
25280
+ } else {
25281
+ log(
25282
+ `[persistent-session] egress allowlist for '${codeName}' written (${allowlist.length} domains) but sidecar not running; will apply on next tick/spawn`
25283
+ );
25284
+ }
25285
+ } catch (err) {
25286
+ log(
25287
+ `[persistent-session] egress allowlist refresh for '${codeName}' failed (will retry next tick): ${err.message}`
25288
+ );
25289
+ }
25290
+ }
25291
+ }
25292
+ }
25090
25293
  async function ensurePersistentSessionUnchecked(agent, tasks, boardItems, refreshData) {
25091
25294
  const codeName = agent.code_name;
25092
25295
  if ((agentFrameworkCache.get(codeName) ?? DEFAULT_FRAMEWORK) === "claude-code" && !isSessionHealthy(codeName)) {
@@ -25292,11 +25495,8 @@ async function ensurePersistentSessionUnchecked(agent, tasks, boardItems, refres
25292
25495
  agentRuntimeAuthenticated = await checkClaudeAuth();
25293
25496
  if (!agentRuntimeAuthenticated) {
25294
25497
  log(`[persistent-session] Skipping '${codeName}' \u2014 Claude Code not authenticated (subscription mode)`);
25295
- return {
25296
- decision: "skipped-not-authenticated",
25297
- spawnAttempted: false,
25298
- sessionHealthyAfter: isSessionHealthy(codeName)
25299
- };
25498
+ if (isSessionHealthy(codeName)) refreshLiveEgressAllowlist(agent, refreshData, modelPolicy);
25499
+ return notAuthenticatedSkipOutcome();
25300
25500
  }
25301
25501
  }
25302
25502
  } else if (!anthropicApiKey) {
@@ -25796,35 +25996,7 @@ ${truncateForLog(ctx.tail)}` : `; pane_tail_hash=sha256:${createHash21("sha256")
25796
25996
  scheduleSessionRestart(codeName, 0, "network policy change (ENG-11168)");
25797
25997
  }
25798
25998
  denyWebFetchBySession.set(codeName, liveDenyWebFetch);
25799
- if (egressMode(codeName) === "allowlist") {
25800
- const allowlist = deriveEgressAllowlist(
25801
- refreshData.tools?.raw_content,
25802
- modelPolicy,
25803
- integrationEgressDomainsFor(agent, "live-refresh")
25804
- );
25805
- const prev = egressAllowlistBySession.get(codeName);
25806
- if (!prev || !egressAllowlistEqual(prev, allowlist)) {
25807
- try {
25808
- writeEgressAllowlist(codeName, allowlist);
25809
- const removed = prev ? prev.some((d) => !allowlist.includes(d)) : true;
25810
- const applied = removed ? restartEgressSidecar(codeName) : reloadEgressSidecar(codeName);
25811
- if (applied) {
25812
- egressAllowlistBySession.set(codeName, allowlist);
25813
- log(
25814
- `[persistent-session] egress allowlist for '${codeName}' changed (${allowlist.length} domains), ${removed ? "restarted" : "reloaded"} squid sidecar`
25815
- );
25816
- } else {
25817
- log(
25818
- `[persistent-session] egress allowlist for '${codeName}' written (${allowlist.length} domains) but sidecar not running; will apply on next tick/spawn`
25819
- );
25820
- }
25821
- } catch (err) {
25822
- log(
25823
- `[persistent-session] egress allowlist refresh for '${codeName}' failed (will retry next tick): ${err.message}`
25824
- );
25825
- }
25826
- }
25827
- }
25999
+ refreshLiveEgressAllowlist(agent, refreshData, modelPolicy);
25828
26000
  if (effectiveIsolationMode(codeName) === "docker") {
25829
26001
  syncContainerMemory(
25830
26002
  codeName,
@@ -26202,7 +26374,7 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
26202
26374
  if (!refreshData) return;
26203
26375
  const framework = refreshData.agent?.framework ?? agentFrameworkCache.get(codeName) ?? DEFAULT_FRAMEWORK;
26204
26376
  const hostId = await getHostId();
26205
- const parkForRestart = await import("../responsiveness-probe-CNKJ7AW2.js").then(
26377
+ const parkForRestart = await import("../responsiveness-probe-FWPQTPQ5.js").then(
26206
26378
  (m) => m.parkPendingInbound,
26207
26379
  (err) => err
26208
26380
  );
@@ -26279,7 +26451,7 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
26279
26451
  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}`));
26280
26452
  void (async () => {
26281
26453
  try {
26282
- const { collectDiagnostics } = await import("../persistent-session-GT56CLOE.js");
26454
+ const { collectDiagnostics } = await import("../persistent-session-LMR3WHVO.js");
26283
26455
  await api.post("/host/heartbeat", {
26284
26456
  host_id: hostId,
26285
26457
  agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
@@ -26332,7 +26504,7 @@ async function respawnAgentAfterMcpStop(codeName, reason) {
26332
26504
  }
26333
26505
  try {
26334
26506
  const hostId = await getHostId();
26335
- const { collectDiagnostics } = await import("../persistent-session-GT56CLOE.js");
26507
+ const { collectDiagnostics } = await import("../persistent-session-LMR3WHVO.js");
26336
26508
  await api.post("/host/heartbeat", {
26337
26509
  host_id: hostId,
26338
26510
  agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
@@ -27059,7 +27231,7 @@ async function processClaudePairSessions(agents) {
27059
27231
  snapshotPairConfig,
27060
27232
  // ENG-11659: result -> report body + the manager.log line that records it.
27061
27233
  planPairStartReport
27062
- } = await import("../claude-pair-runtime-EBORDHDL.js");
27234
+ } = await import("../claude-pair-runtime-TUVLJDJZ.js");
27063
27235
  const { resetClaudeSignin, describeSigninResetForLog, describeSigninResetFailure } = await import("../claude-signin-reset-6IJMMVYG.js");
27064
27236
  for (const pairId of pendingResp.cancelled_pair_ids ?? []) {
27065
27237
  log(`[claude-pair] sweeping orphan tmux session for pair ${pairId.slice(0, 8)}`);