@integrity-labs/agt-cli 0.28.884 → 0.28.885

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.
package/dist/bin/agt.js CHANGED
@@ -40,12 +40,12 @@ import {
40
40
  success,
41
41
  table,
42
42
  warn
43
- } from "../chunk-5P4R3IPC.js";
43
+ } from "../chunk-MT3CF4UQ.js";
44
44
  import {
45
45
  getProjectDir,
46
46
  isSessionResumeDisabled,
47
47
  readDirectChatSessionState
48
- } from "../chunk-YNYWVGHB.js";
48
+ } from "../chunk-FP5M5OVX.js";
49
49
  import {
50
50
  AnchorSessionClient,
51
51
  CHANNEL_REGISTRY,
@@ -5467,7 +5467,7 @@ import { execFileSync, execSync } from "child_process";
5467
5467
  import { existsSync as existsSync11, realpathSync as realpathSync2 } from "fs";
5468
5468
  import chalk18 from "chalk";
5469
5469
  import ora16 from "ora";
5470
- var cliVersion = true ? "0.28.884" : "dev";
5470
+ var cliVersion = true ? "0.28.885" : "dev";
5471
5471
  async function fetchLatestVersion() {
5472
5472
  const host2 = getHost();
5473
5473
  if (!host2) return null;
@@ -6658,7 +6658,7 @@ function handleError(err) {
6658
6658
  }
6659
6659
 
6660
6660
  // src/bin/agt.ts
6661
- var cliVersion2 = true ? "0.28.884" : "dev";
6661
+ var cliVersion2 = true ? "0.28.885" : "dev";
6662
6662
  var program = new Command();
6663
6663
  program.name("agt").description("Augmented CLI \u2014 agent provisioning and management").version(cliVersion2).option("--json", "Emit machine-readable JSON output (suppress spinners and colors)").option("--skip-update-check", "Skip the automatic update check on startup");
6664
6664
  program.hook("preAction", async (thisCommand, actionCommand) => {
@@ -3985,6 +3985,77 @@ function collectMcpServerNames(mcpConfigPath) {
3985
3985
  }
3986
3986
  }
3987
3987
  var PANE_AGENT_ID_PROBE_TIMEOUT_MS = 2e3;
3988
+ function applyPaneAgentIdVerdict(args) {
3989
+ const { session, mismatch, codeName, tmuxSession, log: log2 } = args;
3990
+ if (!mismatch) return false;
3991
+ log2(
3992
+ `[persistent-session] PANE AGENT ID MISMATCH agent=${codeName} isolation=${args.isolation} \u2014 ${mismatch}`
3993
+ );
3994
+ session.status = "crashed";
3995
+ session.startedAt = args.now ? args.now() : Date.now();
3996
+ log2(
3997
+ `[persistent-session] requesting kill of session '${tmuxSession}' for '${codeName}' \u2014 refusing to run an agent under another agent's identity (ENG-8800)`
3998
+ );
3999
+ let teardown;
4000
+ try {
4001
+ teardown = Promise.resolve(args.killSession(tmuxSession));
4002
+ } catch (err) {
4003
+ teardown = Promise.resolve({
4004
+ ok: false,
4005
+ reason: `could not start the kill: ${err instanceof Error ? err.message : String(err)}`
4006
+ });
4007
+ }
4008
+ void teardown.catch((err) => ({
4009
+ ok: false,
4010
+ reason: `the kill rejected: ${err instanceof Error ? err.message : String(err)}`
4011
+ })).then((result) => {
4012
+ if (result?.ok) {
4013
+ log2(`[persistent-session] killed session '${tmuxSession}' for '${codeName}' (ENG-8800)`);
4014
+ } else {
4015
+ const reason = result && !result.ok ? result.reason : "no result from the kill";
4016
+ log2(
4017
+ `[persistent-session] FAILED TO KILL session '${tmuxSession}' for '${codeName}': ${reason}. It is marked crashed, but its pane may still be running under another agent's identity. Kill it by hand: tmux kill-session -t ${tmuxSession} (ENG-8800)`
4018
+ );
4019
+ }
4020
+ args.onTeardownSettled?.(result ?? { ok: false, reason: "no result from the kill" });
4021
+ });
4022
+ return true;
4023
+ }
4024
+ function killTmuxSessionBounded(tmuxSession, deps = {}) {
4025
+ const spawnFn = deps.spawnFn ?? spawn2;
4026
+ const timeoutMs = deps.timeoutMs ?? PANE_AGENT_ID_PROBE_TIMEOUT_MS;
4027
+ return new Promise((resolve) => {
4028
+ let deadline;
4029
+ let settled = false;
4030
+ const settle = (result) => {
4031
+ if (settled) return;
4032
+ settled = true;
4033
+ if (deadline) clearTimeout(deadline);
4034
+ resolve(result);
4035
+ };
4036
+ let killer;
4037
+ try {
4038
+ killer = spawnFn("tmux", ["kill-session", "-t", tmuxSession], { stdio: "ignore" });
4039
+ } catch (err) {
4040
+ settle({ ok: false, reason: `could not spawn tmux: ${err instanceof Error ? err.message : String(err)}` });
4041
+ return;
4042
+ }
4043
+ deadline = setTimeout(() => {
4044
+ try {
4045
+ killer.kill("SIGKILL");
4046
+ } catch {
4047
+ }
4048
+ settle({ ok: false, reason: `tmux kill-session did not exit within ${timeoutMs}ms` });
4049
+ }, timeoutMs);
4050
+ deadline.unref?.();
4051
+ killer.on("error", (err) => {
4052
+ settle({ ok: false, reason: `tmux kill-session could not run: ${err.message}` });
4053
+ });
4054
+ killer.on("close", (code, signal) => {
4055
+ settle(code === 0 ? { ok: true } : { ok: false, reason: `tmux kill-session exited ${code ?? signal}` });
4056
+ });
4057
+ });
4058
+ }
3988
4059
  var REQUIRED_SPAWN_ENV = ["AGT_AGENT_ID", "AGT_HOST", "AGT_API_KEY"];
3989
4060
  function buildSpawnEnv(args) {
3990
4061
  const { base, agentId, runId } = args;
@@ -4670,31 +4741,15 @@ function spawnSession(config, session) {
4670
4741
  showEnvOutput: output,
4671
4742
  expectedAgentId: config.agentId
4672
4743
  });
4673
- if (mismatch) {
4674
- log2(
4675
- `[persistent-session] PANE AGENT ID MISMATCH agent=${codeName} isolation=${effectiveMode} \u2014 ${mismatch}`
4676
- );
4677
- session.status = "crashed";
4678
- session.startedAt = Date.now();
4679
- try {
4680
- const killer = spawn2("tmux", ["kill-session", "-t", tmuxSession], {
4681
- stdio: "ignore"
4682
- });
4683
- const killDeadline = setTimeout(() => {
4684
- try {
4685
- killer.kill("SIGKILL");
4686
- } catch {
4687
- }
4688
- }, PANE_AGENT_ID_PROBE_TIMEOUT_MS);
4689
- killDeadline.unref?.();
4690
- killer.on("error", () => clearTimeout(killDeadline));
4691
- killer.on("close", () => clearTimeout(killDeadline));
4692
- } catch {
4693
- }
4694
- log2(
4695
- `[persistent-session] killed session '${tmuxSession}' for '${codeName}' \u2014 refusing to run an agent under another agent's identity (ENG-8800)`
4696
- );
4697
- }
4744
+ applyPaneAgentIdVerdict({
4745
+ session,
4746
+ mismatch,
4747
+ codeName,
4748
+ tmuxSession,
4749
+ isolation: effectiveMode,
4750
+ log: log2,
4751
+ killSession: killTmuxSessionBounded
4752
+ });
4698
4753
  };
4699
4754
  const deadline = setTimeout(() => {
4700
4755
  settle(null);
@@ -5401,6 +5456,8 @@ export {
5401
5456
  buildDockerRunCommand,
5402
5457
  writePersistentClaudeWrapper,
5403
5458
  PANE_AGENT_ID_PROBE_TIMEOUT_MS,
5459
+ applyPaneAgentIdVerdict,
5460
+ killTmuxSessionBounded,
5404
5461
  REQUIRED_SPAWN_ENV,
5405
5462
  buildSpawnEnv,
5406
5463
  findMissingSpawnEnv,
@@ -5441,4 +5498,4 @@ export {
5441
5498
  stopAllSessionsAndWait,
5442
5499
  getProjectDir
5443
5500
  };
5444
- //# sourceMappingURL=chunk-YNYWVGHB.js.map
5501
+ //# sourceMappingURL=chunk-FP5M5OVX.js.map