@integrity-labs/agt-cli 0.28.896 → 0.28.898

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 (23) hide show
  1. package/dist/bin/agt.js +5 -5
  2. package/dist/{chunk-HKG6EMAM.js → chunk-DDNFLITA.js} +4 -4
  3. package/dist/{chunk-5464FJVN.js → chunk-HQKGVPIV.js} +56 -2
  4. package/dist/{chunk-5464FJVN.js.map → chunk-HQKGVPIV.js.map} +1 -1
  5. package/dist/{chunk-RAEBKUW2.js → chunk-IVJVMR3S.js} +2 -2
  6. package/dist/{claude-pair-runtime-3MK5MUPN.js → claude-pair-runtime-CUFG7UQD.js} +2 -2
  7. package/dist/lib/manager-worker.js +144 -29
  8. package/dist/lib/manager-worker.js.map +1 -1
  9. package/dist/mcp/direct-chat-channel.js +55 -1
  10. package/dist/mcp/index.js +52 -1
  11. package/dist/mcp/origami.js +52 -1
  12. package/dist/mcp/slack-channel.js +55 -1
  13. package/dist/mcp/telegram-channel.js +55 -1
  14. package/dist/{persistent-session-5HSYQBF7.js → persistent-session-6QB3XNY2.js} +3 -3
  15. package/dist/{responsiveness-probe-ZSB3DLLI.js → responsiveness-probe-ULU4DHEO.js} +3 -3
  16. package/dist/{session-auth-dead-J7SQAYRR.js → session-auth-dead-UXZ5DDKQ.js} +2 -2
  17. package/package.json +1 -1
  18. /package/dist/{chunk-HKG6EMAM.js.map → chunk-DDNFLITA.js.map} +0 -0
  19. /package/dist/{chunk-RAEBKUW2.js.map → chunk-IVJVMR3S.js.map} +0 -0
  20. /package/dist/{claude-pair-runtime-3MK5MUPN.js.map → claude-pair-runtime-CUFG7UQD.js.map} +0 -0
  21. /package/dist/{persistent-session-5HSYQBF7.js.map → persistent-session-6QB3XNY2.js.map} +0 -0
  22. /package/dist/{responsiveness-probe-ZSB3DLLI.js.map → responsiveness-probe-ULU4DHEO.js.map} +0 -0
  23. /package/dist/{session-auth-dead-J7SQAYRR.js.map → session-auth-dead-UXZ5DDKQ.js.map} +0 -0
@@ -19,7 +19,7 @@ import {
19
19
  rotateDailySession,
20
20
  sessionFileExists,
21
21
  todayLocalIso
22
- } from "./chunk-5464FJVN.js";
22
+ } from "./chunk-HQKGVPIV.js";
23
23
  import {
24
24
  reapOrphanChannelMcps
25
25
  } from "./chunk-XWVM4KPK.js";
@@ -5730,4 +5730,4 @@ export {
5730
5730
  stopAllSessionsAndWait,
5731
5731
  getProjectDir
5732
5732
  };
5733
- //# sourceMappingURL=chunk-RAEBKUW2.js.map
5733
+ //# sourceMappingURL=chunk-IVJVMR3S.js.map
@@ -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-5HSYQBF7.js");
103
+ const { resolveClaudeBinary } = await import("./persistent-session-6QB3XNY2.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-3MK5MUPN.js.map
376
+ //# sourceMappingURL=claude-pair-runtime-CUFG7UQD.js.map
@@ -63,7 +63,7 @@ import {
63
63
  safeWriteJsonAtomic,
64
64
  setConfigHash,
65
65
  tripClass
66
- } from "../chunk-HKG6EMAM.js";
66
+ } from "../chunk-DDNFLITA.js";
67
67
  import {
68
68
  getProjectDir as getProjectDir2,
69
69
  getReadyTasks,
@@ -136,7 +136,7 @@ import {
136
136
  takeZombieDetection,
137
137
  toOpencodeModel,
138
138
  writeEgressAllowlist
139
- } from "../chunk-RAEBKUW2.js";
139
+ } from "../chunk-IVJVMR3S.js";
140
140
  import {
141
141
  ACCOUNT_ENFORCEMENT_MARKER_FILENAME,
142
142
  AnchorSessionClient,
@@ -231,7 +231,7 @@ import {
231
231
  subagentActivityAgeSeconds,
232
232
  sumTranscriptUsageInWindow,
233
233
  transcriptActivityAgeSeconds
234
- } from "../chunk-5464FJVN.js";
234
+ } from "../chunk-HQKGVPIV.js";
235
235
  import {
236
236
  reapOrphanChannelMcps
237
237
  } from "../chunk-XWVM4KPK.js";
@@ -2261,13 +2261,63 @@ function decideReaperActions(file, isAlive, looksLikeClaude = () => true) {
2261
2261
  }
2262
2262
  function formatDrainShutdownLine(opts) {
2263
2263
  const killed = opts.killedPids && opts.killedPids.length > 0 ? ` killed_pids=${opts.killedPids.join(",")}` : "";
2264
+ const scanned = opts.scanned === void 0 ? "" : ` scanned=${opts.scanned}`;
2265
+ const acted = opts.acted === void 0 ? "" : ` acted=${opts.acted}`;
2264
2266
  const note = opts.note ? ` note="${opts.note.replace(/"/g, '\\"')}"` : "";
2265
- return `[drain] step=${opts.step} elapsed_ms=${opts.elapsedMs}${killed}${note}`;
2267
+ return `[drain] step=${opts.step} elapsed_ms=${opts.elapsedMs}${killed}${scanned}${acted}${note}`;
2266
2268
  }
2267
2269
  function formatReaperBootLine(opts) {
2268
2270
  return `[drain] step=boot-reaper total=${opts.totalRecorded} killed=${opts.killed} already_dead=${opts.alreadyDead} pid_reused_skipped=${opts.pidReusedSkipped}`;
2269
2271
  }
2270
2272
 
2273
+ // src/lib/drain-card-release.ts
2274
+ function decideDrainReleaseTargets(liveAgents, resolveAgentId) {
2275
+ const targets = [];
2276
+ const unresolved = [];
2277
+ for (const codeName of liveAgents) {
2278
+ const agentId = resolveAgentId(codeName);
2279
+ if (agentId) targets.push({ codeName, agentId });
2280
+ else unresolved.push(codeName);
2281
+ }
2282
+ return { targets, unresolved };
2283
+ }
2284
+ function drainReleaseScanned(enumerated, liveAgentCount) {
2285
+ return enumerated ? liveAgentCount : "not-scanned";
2286
+ }
2287
+ function tallyDrainReleases(results) {
2288
+ let released = 0;
2289
+ let failed = 0;
2290
+ for (const r of results) {
2291
+ if (r.status !== "fulfilled") {
2292
+ failed += 1;
2293
+ continue;
2294
+ }
2295
+ if (r.value && r.value.error !== void 0 && r.value.error !== null) {
2296
+ failed += 1;
2297
+ continue;
2298
+ }
2299
+ const n = r.value?.released;
2300
+ if (typeof n === "number" && Number.isFinite(n) && n > 0) released += n;
2301
+ const f = r.value?.failed;
2302
+ if (typeof f === "number" && Number.isFinite(f) && f > 0) failed += f;
2303
+ }
2304
+ return { released, failed };
2305
+ }
2306
+
2307
+ // src/lib/drain-session-kill.ts
2308
+ async function killSessionsConcurrently(sessions, killOne) {
2309
+ const killed = [];
2310
+ const failed = [];
2311
+ if (sessions.length === 0) return { killed, failed };
2312
+ const settled = await Promise.allSettled(sessions.map((s) => killOne(s)));
2313
+ settled.forEach((r, i) => {
2314
+ const session = sessions[i];
2315
+ if (r.status === "fulfilled") killed.push(session);
2316
+ else failed.push(session);
2317
+ });
2318
+ return { killed, failed };
2319
+ }
2320
+
2271
2321
  // src/lib/direct-chat-delivery.ts
2272
2322
  import { join as join7 } from "path";
2273
2323
  var DEFAULT_DIRECT_CHAT_MAX_AGE_MS = 30 * 6e4;
@@ -13003,7 +13053,7 @@ var pendingDayRolloverReset = /* @__PURE__ */ new Set();
13003
13053
  var dayRolloverInboundHold = /* @__PURE__ */ new Map();
13004
13054
  var INBOUND_HOLD_EPISODE_GAP_MS = 12e4;
13005
13055
  async function channelInboundActivityAgeSecondsFor(codeName) {
13006
- const { newestPendingInboundActivityMtimeMs } = await import("../responsiveness-probe-ZSB3DLLI.js");
13056
+ const { newestPendingInboundActivityMtimeMs } = await import("../responsiveness-probe-ULU4DHEO.js");
13007
13057
  const newest = newestPendingInboundActivityMtimeMs(dirname11(paneLogPath(codeName)));
13008
13058
  if (newest === null) return null;
13009
13059
  return Math.max(0, Math.floor((Date.now() - newest) / 1e3));
@@ -13671,7 +13721,7 @@ var agentRestartTimezoneInputs = /* @__PURE__ */ new Map();
13671
13721
  var lastVersionCheckAt = 0;
13672
13722
  var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
13673
13723
  var lastResponsivenessProbeAt = 0;
13674
- var agtCliVersion = true ? "0.28.896" : "dev";
13724
+ var agtCliVersion = true ? "0.28.898" : "dev";
13675
13725
  function resolveBrewPath(execFileSync2) {
13676
13726
  try {
13677
13727
  const out = execFileSync2("which", ["brew"], { timeout: 5e3 }).toString().trim();
@@ -15261,7 +15311,7 @@ function flushRestartedAgentDiagnostics(hostId, codeNames) {
15261
15311
  if (codeNames.length === 0) return;
15262
15312
  void (async () => {
15263
15313
  try {
15264
- const { collectDiagnostics } = await import("../persistent-session-5HSYQBF7.js");
15314
+ const { collectDiagnostics } = await import("../persistent-session-6QB3XNY2.js");
15265
15315
  await api.post("/host/heartbeat", {
15266
15316
  host_id: hostId,
15267
15317
  agent_diagnostics: collectDiagnostics(codeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor)
@@ -15403,7 +15453,7 @@ async function pollCycleInner() {
15403
15453
  }
15404
15454
  try {
15405
15455
  const { detectHostSecurity } = await import("../host-security-6PDFG7F5.js");
15406
- const { collectDiagnostics } = await import("../persistent-session-5HSYQBF7.js");
15456
+ const { collectDiagnostics } = await import("../persistent-session-6QB3XNY2.js");
15407
15457
  const diagCodeNames = [...agentState.persistentSessionAgents];
15408
15458
  const agentDiagnostics = diagCodeNames.length > 0 ? collectDiagnostics(diagCodeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor) : void 0;
15409
15459
  let tailscaleHostname;
@@ -15572,7 +15622,7 @@ async function pollCycleInner() {
15572
15622
  collectPanelessActivityProbes,
15573
15623
  getResponsivenessIntervalMs,
15574
15624
  occupancyQualificationClassifications
15575
- } = await import("../responsiveness-probe-ZSB3DLLI.js");
15625
+ } = await import("../responsiveness-probe-ULU4DHEO.js");
15576
15626
  const probeIntervalMs = getResponsivenessIntervalMs();
15577
15627
  if (now - lastResponsivenessProbeAt > probeIntervalMs) {
15578
15628
  const probeCodeNames = [...agentState.persistentSessionAgents];
@@ -15689,7 +15739,7 @@ async function pollCycleInner() {
15689
15739
  collectResponsivenessProbes,
15690
15740
  livePendingInboundOldestAgeSeconds,
15691
15741
  parkPendingInbound
15692
- } = await import("../responsiveness-probe-ZSB3DLLI.js");
15742
+ } = await import("../responsiveness-probe-ULU4DHEO.js");
15693
15743
  const { getProjectDir: wedgeProjectDir } = await import("../scheduler-engine-NDP36U7O.js");
15694
15744
  const wedgeNow = /* @__PURE__ */ new Date();
15695
15745
  const liveAgents = agentState.persistentSessionAgents;
@@ -15845,7 +15895,7 @@ async function pollCycleInner() {
15845
15895
  }
15846
15896
  try {
15847
15897
  const { scrapeMcpFailedBannerCount } = await import("../pane-mcp-banner-scraper-JA437JIB.js");
15848
- const { probeSessionAuth } = await import("../session-auth-dead-J7SQAYRR.js");
15898
+ const { probeSessionAuth } = await import("../session-auth-dead-UXZ5DDKQ.js");
15849
15899
  const observations = [];
15850
15900
  const pendingCacheCommits = [];
15851
15901
  const modelApiErrorReportingOn = hostFlagStore().getBoolean("model-api-error-reporting");
@@ -20103,7 +20153,7 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
20103
20153
  try {
20104
20154
  const freshId = rotateSessionForWedge(codeName);
20105
20155
  consecutiveWedgeCycles.delete(codeName);
20106
- const { parkPendingInbound: parkForRestart } = await import("../responsiveness-probe-ZSB3DLLI.js");
20156
+ const { parkPendingInbound: parkForRestart } = await import("../responsiveness-probe-ULU4DHEO.js");
20107
20157
  const { parked, deadLettered } = parkForRestart(codeName, /* @__PURE__ */ new Date());
20108
20158
  const parkNote = parked > 0 ? `, ${parked} inbound parked` : "";
20109
20159
  const deadNote = deadLettered > 0 ? `, ${deadLettered} undeliverable dead-lettered` : "";
@@ -20146,7 +20196,7 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
20146
20196
  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}`));
20147
20197
  void (async () => {
20148
20198
  try {
20149
- const { collectDiagnostics } = await import("../persistent-session-5HSYQBF7.js");
20199
+ const { collectDiagnostics } = await import("../persistent-session-6QB3XNY2.js");
20150
20200
  await api.post("/host/heartbeat", {
20151
20201
  host_id: hostId,
20152
20202
  agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor)
@@ -20197,7 +20247,7 @@ async function respawnAgentAfterMcpStop(codeName, reason) {
20197
20247
  }
20198
20248
  try {
20199
20249
  const hostId = await getHostId();
20200
- const { collectDiagnostics } = await import("../persistent-session-5HSYQBF7.js");
20250
+ const { collectDiagnostics } = await import("../persistent-session-6QB3XNY2.js");
20201
20251
  await api.post("/host/heartbeat", {
20202
20252
  host_id: hostId,
20203
20253
  agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor)
@@ -20839,7 +20889,7 @@ async function processClaudePairSessions(agents) {
20839
20889
  killPairSession,
20840
20890
  pairTmuxSession,
20841
20891
  finalizeClaudePairOnboarding
20842
- } = await import("../claude-pair-runtime-3MK5MUPN.js");
20892
+ } = await import("../claude-pair-runtime-CUFG7UQD.js");
20843
20893
  for (const pairId of pendingResp.cancelled_pair_ids ?? []) {
20844
20894
  log(`[claude-pair] sweeping orphan tmux session for pair ${pairId.slice(0, 8)}`);
20845
20895
  const killed = await killPairSession(pairTmuxSession(pairId));
@@ -21688,22 +21738,70 @@ async function killAllAgtTmuxSessions() {
21688
21738
  { timeout: 2e3, stdin: "ignore" }
21689
21739
  );
21690
21740
  const sessions = output.trim().split("\n").filter((s) => s.startsWith("agt-"));
21691
- for (const session of sessions) {
21692
- try {
21693
- await execFilePromiseLong("tmux", ["kill-session", "-t", session], {
21694
- timeout: 2e3,
21695
- stdin: "ignore"
21696
- });
21697
- log(`Killed tmux session '${session}'`);
21698
- } catch {
21699
- }
21700
- }
21741
+ const { killed, failed } = await killSessionsConcurrently(sessions, async (session) => {
21742
+ await execFilePromiseLong("tmux", ["kill-session", "-t", session], {
21743
+ timeout: 2e3,
21744
+ stdin: "ignore"
21745
+ });
21746
+ });
21747
+ for (const session of killed) log(`Killed tmux session '${session}'`);
21701
21748
  if (sessions.length > 0) {
21702
- log(`Cleaned up ${sessions.length} agt-* tmux session(s)`);
21749
+ log(
21750
+ `Cleaned up ${killed.length} agt-* tmux session(s)` + (failed.length > 0 ? ` (${failed.length} already gone or unkillable)` : "")
21751
+ );
21703
21752
  }
21704
21753
  } catch {
21705
21754
  }
21706
21755
  }
21756
+ function snapshotDrainReleaseTargets() {
21757
+ try {
21758
+ return { enumerated: true, liveAgents: [...agentState.persistentSessionAgents] };
21759
+ } catch {
21760
+ return { enumerated: false, liveAgents: [] };
21761
+ }
21762
+ }
21763
+ async function releaseInterruptedCardsOnDrain(snapshot) {
21764
+ const startedAt = Date.now();
21765
+ const { enumerated, liveAgents } = snapshot;
21766
+ const { targets, unresolved } = decideDrainReleaseTargets(
21767
+ liveAgents,
21768
+ (codeName) => agentState.codeNameToAgentId.get(codeName)
21769
+ );
21770
+ let released = 0;
21771
+ let failed = 0;
21772
+ if (targets.length > 0) {
21773
+ const reason = restartAfterUpgrade ? `manager drain: CLI self-update${pendingUpgradeVersion ? ` to ${pendingUpgradeVersion}` : ""}` : "manager drain: manager shutdown";
21774
+ const posts = Promise.allSettled(
21775
+ targets.map(
21776
+ (t) => api.post("/host/kanban/release-interrupted", {
21777
+ agent_id: t.agentId,
21778
+ reason
21779
+ })
21780
+ )
21781
+ );
21782
+ const deadline = new Promise((resolve2) => setTimeout(() => resolve2([]), 3e3));
21783
+ const settled = await Promise.race([posts, deadline]);
21784
+ if (settled.length === 0 && targets.length > 0) {
21785
+ failed = targets.length;
21786
+ } else {
21787
+ const tally = tallyDrainReleases(settled);
21788
+ released = tally.released;
21789
+ failed = tally.failed;
21790
+ }
21791
+ }
21792
+ const noteParts = [];
21793
+ if (unresolved.length > 0) noteParts.push(`unresolved_agent_ids=${unresolved.length}`);
21794
+ if (failed > 0) noteParts.push(`post_failures=${failed}`);
21795
+ log(
21796
+ formatDrainShutdownLine({
21797
+ step: "release-interrupted-cards",
21798
+ elapsedMs: Date.now() - startedAt,
21799
+ scanned: drainReleaseScanned(enumerated, liveAgents.length),
21800
+ acted: released,
21801
+ note: noteParts.length > 0 ? noteParts.join(" ") : void 0
21802
+ })
21803
+ );
21804
+ }
21707
21805
  async function stopPolling(opts = {}) {
21708
21806
  running = false;
21709
21807
  if (pollTimer) {
@@ -21730,9 +21828,21 @@ async function stopPolling(opts = {}) {
21730
21828
  } catch {
21731
21829
  }
21732
21830
  }
21733
- log(formatDrainShutdownLine({ step: "sigterm-claude-pids", elapsedMs: Date.now() - drainStartedAt, killedPids: livePids }));
21831
+ log(formatDrainShutdownLine({
21832
+ step: "sigterm-claude-pids",
21833
+ elapsedMs: Date.now() - drainStartedAt,
21834
+ killedPids: livePids,
21835
+ scanned: livePids.length,
21836
+ acted: livePids.length
21837
+ }));
21734
21838
  } else {
21735
- log(formatDrainShutdownLine({ step: "sigterm-claude-pids", elapsedMs: 0, note: "no in-flight claude -p children" }));
21839
+ log(formatDrainShutdownLine({
21840
+ step: "sigterm-claude-pids",
21841
+ elapsedMs: 0,
21842
+ scanned: 0,
21843
+ acted: 0,
21844
+ note: "no in-flight claude -p children (this step scans claude -p children only)"
21845
+ }));
21736
21846
  }
21737
21847
  const subsysStartedAt = Date.now();
21738
21848
  stopCaffeinate();
@@ -21746,8 +21856,13 @@ async function stopPolling(opts = {}) {
21746
21856
  for (const codeName of [...sessionRunsByCode.keys()]) {
21747
21857
  closeSessionRunForCode(codeName, "completed", "manager shutdown");
21748
21858
  }
21859
+ const drainReleaseSnapshot = snapshotDrainReleaseTargets();
21749
21860
  log("Killing tmux sessions...");
21750
- await killAllAgtTmuxSessions();
21861
+ try {
21862
+ await killAllAgtTmuxSessions();
21863
+ } finally {
21864
+ await releaseInterruptedCardsOnDrain(drainReleaseSnapshot);
21865
+ }
21751
21866
  log("Stopping persistent sessions...");
21752
21867
  await stopAllSessionsAndWait(log, { timeoutMs: 4e3 });
21753
21868
  clearTimeout(shutdownTimer);