@integrity-labs/agt-cli 0.28.240 → 0.28.242

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.
@@ -100,7 +100,7 @@ async function spawnPairSession(session) {
100
100
  return { ok: true };
101
101
  } catch {
102
102
  }
103
- const { resolveClaudeBinary } = await import("./persistent-session-RRCU7CQJ.js");
103
+ const { resolveClaudeBinary } = await import("./persistent-session-W2MICXSS.js");
104
104
  const claudeBin = resolveClaudeBinary();
105
105
  const pairEnv = {
106
106
  ...process.env,
@@ -373,4 +373,4 @@ export {
373
373
  startClaudePair,
374
374
  submitClaudePairCode
375
375
  };
376
- //# sourceMappingURL=claude-pair-runtime-422CI7SM.js.map
376
+ //# sourceMappingURL=claude-pair-runtime-4NHJGZBH.js.map
@@ -37,7 +37,7 @@ import {
37
37
  requireHost,
38
38
  safeWriteJsonAtomic,
39
39
  setConfigHash
40
- } from "../chunk-NKPLBXYS.js";
40
+ } from "../chunk-ISEWY25C.js";
41
41
  import {
42
42
  getProjectDir as getProjectDir2,
43
43
  getReadyTasks,
@@ -122,7 +122,7 @@ import {
122
122
  takeZombieDetection,
123
123
  transcriptActivityAgeSeconds,
124
124
  writeEgressAllowlist
125
- } from "../chunk-GO4VMK2P.js";
125
+ } from "../chunk-LSOXMJYA.js";
126
126
  import {
127
127
  reapOrphanChannelMcps
128
128
  } from "../chunk-XWVM4KPK.js";
@@ -6005,6 +6005,9 @@ async function maybeResumeReconcile(agent) {
6005
6005
  autoResumeInFlight.delete(codeName);
6006
6006
  }
6007
6007
  }
6008
+ function restartReasonBindsNewMcp(breakerReason) {
6009
+ return breakerReason === "hot-reload-mcp" || breakerReason === "managed-mcp-churn" || breakerReason === "bind-remediation" || breakerReason === "channel-set-change";
6010
+ }
6008
6011
  function scheduleSessionRestart(codeName, delayMs, reason, breakerReason = "hot-reload-mcp", beforeStop) {
6009
6012
  const existing = pendingSessionRestarts.get(codeName);
6010
6013
  if (existing) {
@@ -6051,13 +6054,17 @@ function scheduleSessionRestart(codeName, delayMs, reason, breakerReason = "hot-
6051
6054
  runningMcpHashes.delete(codeName);
6052
6055
  recordRestartForBreaker(codeName, breakerReason);
6053
6056
  log(`[hot-reload] Session stopped for '${codeName}' \u2014 will respawn with ${reason}`);
6054
- if (breakerReason === "hot-reload-mcp" || breakerReason === "managed-mcp-churn" || breakerReason === "bind-remediation" || breakerReason === "channel-set-change") {
6057
+ const bindsNewMcp = restartReasonBindsNewMcp(breakerReason);
6058
+ if (bindsNewMcp) {
6055
6059
  const prior = pendingRestartVerifications.get(codeName);
6056
6060
  pendingRestartVerifications.set(codeName, {
6057
6061
  firedAt: Date.now(),
6058
6062
  attempts: prior?.attempts ?? 0
6059
6063
  });
6060
6064
  }
6065
+ if (bindsNewMcp && hostFlagStore().getBoolean("fast-mcp-restart-respawn")) {
6066
+ void respawnAgentAfterMcpStop(codeName, reason);
6067
+ }
6061
6068
  }, delayMs);
6062
6069
  timer.unref?.();
6063
6070
  pendingSessionRestarts.set(codeName, { timer, reason, breakerReason, beforeStop });
@@ -6502,7 +6509,7 @@ var agentRestartTimezoneInputs = /* @__PURE__ */ new Map();
6502
6509
  var lastVersionCheckAt = 0;
6503
6510
  var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
6504
6511
  var lastResponsivenessProbeAt = 0;
6505
- var agtCliVersion = true ? "0.28.240" : "dev";
6512
+ var agtCliVersion = true ? "0.28.242" : "dev";
6506
6513
  function resolveBrewPath(execFileSync2) {
6507
6514
  try {
6508
6515
  const out = execFileSync2("which", ["brew"], { timeout: 5e3 }).toString().trim();
@@ -7339,6 +7346,15 @@ ${SKILLS_INDEX_END}`;
7339
7346
  }
7340
7347
  }
7341
7348
  var consecutivePollFailures = 0;
7349
+ function reorderRestartedFirst(agents, restartedIds) {
7350
+ if (restartedIds.size === 0) return agents;
7351
+ const restarted = [];
7352
+ const rest = [];
7353
+ for (const a of agents) {
7354
+ (restartedIds.has(a.agent_id) ? restarted : rest).push(a);
7355
+ }
7356
+ return [...restarted, ...rest];
7357
+ }
7342
7358
  async function pollCycle() {
7343
7359
  if (!config) return;
7344
7360
  if (restartAfterUpgrade) return;
@@ -7427,7 +7443,7 @@ async function pollCycle() {
7427
7443
  }
7428
7444
  try {
7429
7445
  const { detectHostSecurity } = await import("../host-security-6PDFG7F5.js");
7430
- const { collectDiagnostics } = await import("../persistent-session-RRCU7CQJ.js");
7446
+ const { collectDiagnostics } = await import("../persistent-session-W2MICXSS.js");
7431
7447
  const diagCodeNames = [...agentState.persistentSessionAgents];
7432
7448
  const agentDiagnostics = diagCodeNames.length > 0 ? collectDiagnostics(diagCodeNames) : void 0;
7433
7449
  let tailscaleHostname;
@@ -7575,7 +7591,7 @@ async function pollCycle() {
7575
7591
  const {
7576
7592
  collectResponsivenessProbes,
7577
7593
  getResponsivenessIntervalMs
7578
- } = await import("../responsiveness-probe-K5HFFW5F.js");
7594
+ } = await import("../responsiveness-probe-R7NX5NRH.js");
7579
7595
  const probeIntervalMs = getResponsivenessIntervalMs();
7580
7596
  if (now - lastResponsivenessProbeAt > probeIntervalMs) {
7581
7597
  const probeCodeNames = [...agentState.persistentSessionAgents];
@@ -7607,7 +7623,7 @@ async function pollCycle() {
7607
7623
  collectResponsivenessProbes,
7608
7624
  livePendingInboundOldestAgeSeconds,
7609
7625
  parkPendingInbound
7610
- } = await import("../responsiveness-probe-K5HFFW5F.js");
7626
+ } = await import("../responsiveness-probe-R7NX5NRH.js");
7611
7627
  const { getProjectDir: wedgeProjectDir } = await import("../claude-scheduler-FATCLHDM.js");
7612
7628
  const wedgeNow = /* @__PURE__ */ new Date();
7613
7629
  const liveAgents = agentState.persistentSessionAgents;
@@ -7852,7 +7868,8 @@ async function pollCycle() {
7852
7868
  }
7853
7869
  activeChannels.clear();
7854
7870
  const agentStates = [];
7855
- for (const agent of agents) {
7871
+ const processOrder = hostFlagStore().getBoolean("fast-mcp-restart-respawn") ? reorderRestartedFirst(agents, new Set(restartAcks.keys())) : agents;
7872
+ for (const agent of processOrder) {
7856
7873
  if (restartInFlight.has(agent.agent_id)) {
7857
7874
  const existing = state6.agents.find((a) => a.agentId === agent.agent_id);
7858
7875
  if (existing) {
@@ -7903,7 +7920,7 @@ async function pollCycle() {
7903
7920
  if (restartedCodeNames.length > 0) {
7904
7921
  void (async () => {
7905
7922
  try {
7906
- const { collectDiagnostics } = await import("../persistent-session-RRCU7CQJ.js");
7923
+ const { collectDiagnostics } = await import("../persistent-session-W2MICXSS.js");
7907
7924
  const freshDiagnostics = collectDiagnostics(restartedCodeNames);
7908
7925
  await api.post("/host/heartbeat", {
7909
7926
  host_id: hostId,
@@ -10422,7 +10439,7 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
10422
10439
  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}`));
10423
10440
  void (async () => {
10424
10441
  try {
10425
- const { collectDiagnostics } = await import("../persistent-session-RRCU7CQJ.js");
10442
+ const { collectDiagnostics } = await import("../persistent-session-W2MICXSS.js");
10426
10443
  await api.post("/host/heartbeat", {
10427
10444
  host_id: hostId,
10428
10445
  agent_diagnostics: collectDiagnostics([codeName])
@@ -10442,6 +10459,53 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
10442
10459
  restartInFlight.delete(agentId);
10443
10460
  }
10444
10461
  }
10462
+ async function respawnAgentAfterMcpStop(codeName, reason) {
10463
+ const prev = state6.agents.find((a) => a.codeName === codeName);
10464
+ if (!prev) return;
10465
+ const agentId = prev.agentId;
10466
+ if (restartInFlight.has(agentId)) return;
10467
+ restartInFlight.add(agentId);
10468
+ try {
10469
+ if (isSessionHealthy(codeName)) return;
10470
+ let refreshData;
10471
+ try {
10472
+ refreshData = await api.post("/host/refresh", { agent_id: agentId });
10473
+ } catch (err) {
10474
+ log(`[fast-mcp-respawn] refresh failed for '${codeName}', leaving for slow poll: ${err.message}`);
10475
+ return;
10476
+ }
10477
+ const displayName = refreshData.agent?.display_name ?? codeName;
10478
+ const result = await ensurePersistentSession(
10479
+ { agent_id: agentId, code_name: codeName, display_name: displayName },
10480
+ [],
10481
+ [],
10482
+ refreshData
10483
+ );
10484
+ if (result.decision !== "spawn" || !result.sessionHealthyAfter) {
10485
+ log(
10486
+ `[fast-mcp-respawn] respawn not confirmed for '${codeName}' (decision=${result.decision}) - leaving for slow poll`
10487
+ );
10488
+ return;
10489
+ }
10490
+ try {
10491
+ const hostId = await getHostId();
10492
+ const { collectDiagnostics } = await import("../persistent-session-W2MICXSS.js");
10493
+ await api.post("/host/heartbeat", {
10494
+ host_id: hostId,
10495
+ agent_diagnostics: collectDiagnostics([codeName])
10496
+ });
10497
+ } catch (err) {
10498
+ log(`[fast-mcp-respawn] post-respawn diagnostics flush failed for '${codeName}': ${err.message}`);
10499
+ }
10500
+ log(
10501
+ `[fast-mcp-respawn] '${codeName}' respawned immediately after '${reason}' stop - skipped the ~poll-cycle wait (ENG-7401)`
10502
+ );
10503
+ } catch (err) {
10504
+ log(`[fast-mcp-respawn] unexpected error for '${codeName}', leaving for slow poll: ${err.message}`);
10505
+ } finally {
10506
+ restartInFlight.delete(agentId);
10507
+ }
10508
+ }
10445
10509
  function ensureRealtimeAssignStarted(agentStates) {
10446
10510
  if (realtimeAssignStarted) return;
10447
10511
  const apiKey = process.env["AGT_API_KEY"];
@@ -10816,7 +10880,7 @@ async function processClaudePairSessions(agents) {
10816
10880
  killPairSession,
10817
10881
  pairTmuxSession,
10818
10882
  finalizeClaudePairOnboarding
10819
- } = await import("../claude-pair-runtime-422CI7SM.js");
10883
+ } = await import("../claude-pair-runtime-4NHJGZBH.js");
10820
10884
  for (const pairId of pendingResp.cancelled_pair_ids ?? []) {
10821
10885
  log(`[claude-pair] sweeping orphan tmux session for pair ${pairId.slice(0, 8)}`);
10822
10886
  const killed = await killPairSession(pairTmuxSession(pairId));
@@ -11713,6 +11777,8 @@ export {
11713
11777
  markAgentForFreshMemorySync,
11714
11778
  maybeInjectKanbanCheck,
11715
11779
  maybeUpgradeClaudeCode,
11780
+ reorderRestartedFirst,
11781
+ restartReasonBindsNewMcp,
11716
11782
  shouldSkipRevokedCleanup,
11717
11783
  shouldUpdateOnLatest,
11718
11784
  stampClaudeCodeUpgradeMarker,