@integrity-labs/agt-cli 0.28.578 → 0.28.580

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,7 +40,7 @@ import {
40
40
  success,
41
41
  table,
42
42
  warn
43
- } from "../chunk-5YFIIWS2.js";
43
+ } from "../chunk-YU2B3L6G.js";
44
44
  import {
45
45
  AnchorSessionClient,
46
46
  CHANNEL_REGISTRY,
@@ -71,7 +71,7 @@ import {
71
71
  requiredMcpWildcard,
72
72
  resolveChannels,
73
73
  serializeManifestForSlackCli
74
- } from "../chunk-L24SX6LH.js";
74
+ } from "../chunk-RC5YRTZU.js";
75
75
  import "../chunk-XWVM4KPK.js";
76
76
 
77
77
  // src/bin/agt.ts
@@ -4853,7 +4853,7 @@ import { execFileSync, execSync } from "child_process";
4853
4853
  import { existsSync as existsSync10, realpathSync as realpathSync2 } from "fs";
4854
4854
  import chalk18 from "chalk";
4855
4855
  import ora16 from "ora";
4856
- var cliVersion = true ? "0.28.578" : "dev";
4856
+ var cliVersion = true ? "0.28.580" : "dev";
4857
4857
  async function fetchLatestVersion() {
4858
4858
  const host2 = getHost();
4859
4859
  if (!host2) return null;
@@ -6031,7 +6031,7 @@ function handleError(err) {
6031
6031
  }
6032
6032
 
6033
6033
  // src/bin/agt.ts
6034
- var cliVersion2 = true ? "0.28.578" : "dev";
6034
+ var cliVersion2 = true ? "0.28.580" : "dev";
6035
6035
  var program = new Command();
6036
6036
  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");
6037
6037
  program.hook("preAction", async (thisCommand, actionCommand) => {
@@ -14738,6 +14738,7 @@ function collectMcpServerNames(mcpConfigPath) {
14738
14738
  return [];
14739
14739
  }
14740
14740
  }
14741
+ var PANE_AGENT_ID_PROBE_TIMEOUT_MS = 2e3;
14741
14742
  var REQUIRED_SPAWN_ENV = ["AGT_AGENT_ID", "AGT_HOST", "AGT_API_KEY"];
14742
14743
  function buildSpawnEnv(args) {
14743
14744
  const { base, agentId, runId } = args;
@@ -14753,6 +14754,22 @@ function buildSpawnEnv(args) {
14753
14754
  function findMissingSpawnEnv(env2) {
14754
14755
  return REQUIRED_SPAWN_ENV.filter((k) => !env2[k]?.trim());
14755
14756
  }
14757
+ function describePaneAgentIdMismatch(args) {
14758
+ const out = args.showEnvOutput.trim();
14759
+ if (!out) return null;
14760
+ if (/unknown variable/i.test(out)) {
14761
+ return `no session-scoped AGT_AGENT_ID \u2014 the pane will inherit the tmux SERVER's global value, which on a shared host belongs to whichever agent started the server (ENG-8800)`;
14762
+ }
14763
+ if (/^-AGT_AGENT_ID$/m.test(out)) {
14764
+ return "AGT_AGENT_ID is explicitly unset at session scope (ENG-8800)";
14765
+ }
14766
+ const match = /^AGT_AGENT_ID=(.*)$/m.exec(out);
14767
+ if (!match) return null;
14768
+ const actual = (match[1] ?? "").trim();
14769
+ if (!actual) return "AGT_AGENT_ID is empty at session scope (ENG-8800)";
14770
+ if (actual === args.expectedAgentId) return null;
14771
+ return `pane has AGT_AGENT_ID=${actual} but this session is agent ${args.expectedAgentId} \u2014 broker lookups keyed on the agent id will resolve to the WRONG agent (ENG-8800)`;
14772
+ }
14756
14773
  function findForeignAgentIdsInMcpConfig(args) {
14757
14774
  const { mcpConfigText, agentId } = args;
14758
14775
  const expected = agentId.trim();
@@ -15033,6 +15050,7 @@ function spawnSession(config, session) {
15033
15050
  claudeArgsJoined
15034
15051
  });
15035
15052
  const tmuxSessionEnvArgs = [];
15053
+ tmuxSessionEnvArgs.push("-e", `AGT_AGENT_ID=${config.agentId}`);
15036
15054
  if (openRouterMode) {
15037
15055
  const or = config.openRouter;
15038
15056
  tmuxSessionEnvArgs.push("-e", `ANTHROPIC_BASE_URL=${OPENROUTER_ANTHROPIC_BASE_URL}`);
@@ -15169,6 +15187,65 @@ function spawnSession(config, session) {
15169
15187
  return;
15170
15188
  }
15171
15189
  log2(`[persistent-session] tmux session '${tmuxSession}' created for '${codeName}'`);
15190
+ try {
15191
+ const probe = spawn2("tmux", ["show-environment", "-t", tmuxSession, "AGT_AGENT_ID"], {
15192
+ stdio: ["ignore", "pipe", "pipe"]
15193
+ });
15194
+ let out = "";
15195
+ let done = false;
15196
+ const settle = (output) => {
15197
+ if (done) return;
15198
+ done = true;
15199
+ clearTimeout(deadline);
15200
+ if (output === null) return;
15201
+ const mismatch = describePaneAgentIdMismatch({
15202
+ showEnvOutput: output,
15203
+ expectedAgentId: config.agentId
15204
+ });
15205
+ if (mismatch) {
15206
+ log2(
15207
+ `[persistent-session] PANE AGENT ID MISMATCH agent=${codeName} isolation=${isolationMode(codeName)} \u2014 ${mismatch}`
15208
+ );
15209
+ session.status = "crashed";
15210
+ session.startedAt = Date.now();
15211
+ try {
15212
+ const killer = spawn2("tmux", ["kill-session", "-t", tmuxSession], {
15213
+ stdio: "ignore"
15214
+ });
15215
+ const killDeadline = setTimeout(() => {
15216
+ try {
15217
+ killer.kill("SIGKILL");
15218
+ } catch {
15219
+ }
15220
+ }, PANE_AGENT_ID_PROBE_TIMEOUT_MS);
15221
+ killDeadline.unref?.();
15222
+ killer.on("error", () => clearTimeout(killDeadline));
15223
+ killer.on("close", () => clearTimeout(killDeadline));
15224
+ } catch {
15225
+ }
15226
+ log2(
15227
+ `[persistent-session] killed session '${tmuxSession}' for '${codeName}' \u2014 refusing to run an agent under another agent's identity (ENG-8800)`
15228
+ );
15229
+ }
15230
+ };
15231
+ const deadline = setTimeout(() => {
15232
+ settle(null);
15233
+ try {
15234
+ probe.kill("SIGKILL");
15235
+ } catch {
15236
+ }
15237
+ }, PANE_AGENT_ID_PROBE_TIMEOUT_MS);
15238
+ deadline.unref?.();
15239
+ probe.stdout?.on("data", (d) => {
15240
+ out += d.toString();
15241
+ });
15242
+ probe.stderr?.on("data", (d) => {
15243
+ out += d.toString();
15244
+ });
15245
+ probe.on("error", () => settle(null));
15246
+ probe.on("close", () => settle(out));
15247
+ } catch {
15248
+ }
15172
15249
  setupPaneLog2(tmuxSession, codeName, log2);
15173
15250
  session.currentSessionId = sessionId;
15174
15251
  acceptDialogs(tmuxSession, codeName, log2, config.primaryModel ?? null, sessionId).catch(() => {
@@ -15903,9 +15980,11 @@ export {
15903
15980
  restartEgressSidecar,
15904
15981
  buildDockerRunCommand,
15905
15982
  writePersistentClaudeWrapper,
15983
+ PANE_AGENT_ID_PROBE_TIMEOUT_MS,
15906
15984
  REQUIRED_SPAWN_ENV,
15907
15985
  buildSpawnEnv,
15908
15986
  findMissingSpawnEnv,
15987
+ describePaneAgentIdMismatch,
15909
15988
  findForeignAgentIdsInMcpConfig,
15910
15989
  paneLogPath,
15911
15990
  rotatePaneLogForDayRollover,
@@ -15934,4 +16013,4 @@ export {
15934
16013
  stopAllSessionsAndWait,
15935
16014
  getProjectDir
15936
16015
  };
15937
- //# sourceMappingURL=chunk-L24SX6LH.js.map
16016
+ //# sourceMappingURL=chunk-RC5YRTZU.js.map