@integrity-labs/agt-cli 0.28.840 → 0.28.842

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-24AILXID.js";
43
+ } from "../chunk-F4WQSKKU.js";
44
44
  import {
45
45
  getProjectDir,
46
46
  isSessionResumeDisabled,
47
47
  readDirectChatSessionState
48
- } from "../chunk-W4KAZQBS.js";
48
+ } from "../chunk-KOVJCGBN.js";
49
49
  import {
50
50
  AnchorSessionClient,
51
51
  CHANNEL_REGISTRY,
@@ -79,7 +79,7 @@ import {
79
79
  serializeManifestForSlackCli,
80
80
  sessionFileExists,
81
81
  sessionTranscriptDir
82
- } from "../chunk-DUOFKTAD.js";
82
+ } from "../chunk-XBLODN73.js";
83
83
  import "../chunk-XWVM4KPK.js";
84
84
 
85
85
  // src/bin/agt.ts
@@ -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.840" : "dev";
5470
+ var cliVersion = true ? "0.28.842" : "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.840" : "dev";
6661
+ var cliVersion2 = true ? "0.28.842" : "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) => {
@@ -16,7 +16,7 @@ import {
16
16
  parseEnvIntegrations,
17
17
  shellQuote,
18
18
  summarizeUnanswerablePane
19
- } from "./chunk-W4KAZQBS.js";
19
+ } from "./chunk-KOVJCGBN.js";
20
20
  import {
21
21
  BIND_FAILURE_QUARANTINE_THRESHOLD,
22
22
  INTEGRATIONS_SECTION_END,
@@ -76,7 +76,7 @@ import {
76
76
  sessionTranscriptDir,
77
77
  worseConnectivityOutcome,
78
78
  wrapScheduledTaskPrompt
79
- } from "./chunk-DUOFKTAD.js";
79
+ } from "./chunk-XBLODN73.js";
80
80
  import {
81
81
  parsePsRows
82
82
  } from "./chunk-XWVM4KPK.js";
@@ -6566,7 +6566,7 @@ function exchangeFailureKind(err) {
6566
6566
  }
6567
6567
 
6568
6568
  // src/lib/api-client.ts
6569
- var agtCliVersion = true ? "0.28.840" : "dev";
6569
+ var agtCliVersion = true ? "0.28.842" : "dev";
6570
6570
  var lastConfigHash = null;
6571
6571
  function setConfigHash(hash) {
6572
6572
  lastConfigHash = hash && hash.length > 0 ? hash : null;
@@ -10924,4 +10924,4 @@ export {
10924
10924
  managerInstallSystemUnitCommand,
10925
10925
  managerUninstallSystemUnitCommand
10926
10926
  };
10927
- //# sourceMappingURL=chunk-24AILXID.js.map
10927
+ //# sourceMappingURL=chunk-F4WQSKKU.js.map
@@ -18,7 +18,7 @@ import {
18
18
  rotateDailySession,
19
19
  sessionFileExists,
20
20
  todayLocalIso
21
- } from "./chunk-DUOFKTAD.js";
21
+ } from "./chunk-XBLODN73.js";
22
22
  import {
23
23
  reapOrphanChannelMcps
24
24
  } from "./chunk-XWVM4KPK.js";
@@ -4228,6 +4228,90 @@ function startPersistentSession(config) {
4228
4228
  spawnSession(config, session);
4229
4229
  return session;
4230
4230
  }
4231
+ var TMUX_BOOTSTRAP_HOLD_CMD = "sleep 60";
4232
+ var TMUX_BOOTSTRAP_SESSION_PREFIX = "augmented-tmuxsrv-";
4233
+ function tmuxBootstrapSessionName(seed) {
4234
+ const unique = seed ?? `${process.pid}-${Date.now()}-${randomUUID().slice(0, 8)}`;
4235
+ return `${TMUX_BOOTSTRAP_SESSION_PREFIX}${unique}`;
4236
+ }
4237
+ function buildTmuxSpawnPlan(args) {
4238
+ const bootstrapSession = args.bootstrapSession ?? tmuxBootstrapSessionName();
4239
+ return {
4240
+ bootstrap: { argv: ["new-session", "-d", "-s", bootstrapSession, TMUX_BOOTSTRAP_HOLD_CMD] },
4241
+ session: {
4242
+ argv: [
4243
+ "new-session",
4244
+ "-d",
4245
+ "-s",
4246
+ args.tmuxSession,
4247
+ "-c",
4248
+ args.projectDir,
4249
+ ...args.sessionEnvArgs,
4250
+ args.claudeCmd
4251
+ ]
4252
+ },
4253
+ cleanup: { argv: ["kill-session", "-t", bootstrapSession] }
4254
+ };
4255
+ }
4256
+ function runTmuxSpawnPlan(opts) {
4257
+ const spawnFn = opts.spawnImpl ?? spawn2;
4258
+ const prefix = opts.tmuxArgsPrefix ?? [];
4259
+ const stepTimeoutMs = opts.stepTimeoutMs ?? 1e4;
4260
+ const quiet = { ...opts.spawnOptions, stdio: "ignore" };
4261
+ let cleanedUp = false;
4262
+ const runCleanup = () => {
4263
+ if (cleanedUp || !opts.plan.cleanup) return;
4264
+ cleanedUp = true;
4265
+ try {
4266
+ const child = spawnFn("tmux", [...prefix, ...opts.plan.cleanup.argv], quiet);
4267
+ child.on("error", () => {
4268
+ });
4269
+ } catch {
4270
+ }
4271
+ };
4272
+ const spawnRealSession = () => {
4273
+ let child;
4274
+ try {
4275
+ child = spawnFn("tmux", [...prefix, ...opts.plan.session.argv], opts.spawnOptions);
4276
+ } catch (err) {
4277
+ runCleanup();
4278
+ opts.onSpawnFailed(`session spawn threw: ${err.message}`);
4279
+ return;
4280
+ }
4281
+ child.once("close", runCleanup);
4282
+ child.once("error", runCleanup);
4283
+ opts.onSessionSpawned(child);
4284
+ };
4285
+ if (!opts.plan.bootstrap) {
4286
+ spawnRealSession();
4287
+ return;
4288
+ }
4289
+ let settled = false;
4290
+ let deadline;
4291
+ const settle = (failure) => {
4292
+ if (settled) return;
4293
+ settled = true;
4294
+ if (deadline) clearTimeout(deadline);
4295
+ if (failure === null) spawnRealSession();
4296
+ else opts.onSpawnFailed(failure);
4297
+ };
4298
+ let boot;
4299
+ try {
4300
+ boot = spawnFn("tmux", [...prefix, ...opts.plan.bootstrap.argv], quiet);
4301
+ } catch (err) {
4302
+ settle(`spawn threw: ${err.message}`);
4303
+ return;
4304
+ }
4305
+ boot.on("error", (err) => settle(`tmux could not be started: ${err.message}`));
4306
+ boot.on("close", (code) => settle(code === 0 ? null : `bootstrap tmux exited ${code}`));
4307
+ deadline = setTimeout(() => {
4308
+ settle(`bootstrap tmux did not exit within ${stepTimeoutMs}ms`);
4309
+ try {
4310
+ boot.kill("SIGKILL");
4311
+ } catch {
4312
+ }
4313
+ }, stepTimeoutMs);
4314
+ }
4231
4315
  function spawnSession(config, session) {
4232
4316
  const { codeName, projectDir, mcpConfigPath, claudeMdPath, channels, devChannels, apiHost, log: log2 } = config;
4233
4317
  const claudeAuthMode = config.claudeAuthMode ?? "subscription";
@@ -4546,21 +4630,13 @@ function spawnSession(config, session) {
4546
4630
  }
4547
4631
  } catch {
4548
4632
  }
4549
- const child = spawn2("tmux", [
4550
- "new-session",
4551
- "-d",
4552
- "-s",
4633
+ const spawnPlan = buildTmuxSpawnPlan({
4553
4634
  tmuxSession,
4554
- "-c",
4555
4635
  projectDir,
4556
- ...tmuxSessionEnvArgs,
4636
+ sessionEnvArgs: tmuxSessionEnvArgs,
4557
4637
  claudeCmd
4558
- ], {
4559
- cwd: projectDir,
4560
- stdio: ["ignore", "pipe", "pipe"],
4561
- env: tmuxEnv
4562
4638
  });
4563
- child.on("close", (code) => {
4639
+ const onTmuxSessionClose = (code) => {
4564
4640
  if (code !== 0) {
4565
4641
  log2(`[persistent-session] Failed to create tmux session for '${codeName}' (exit ${code})`);
4566
4642
  session.status = "crashed";
@@ -4632,15 +4708,39 @@ function spawnSession(config, session) {
4632
4708
  session.currentSessionId = sessionId;
4633
4709
  acceptDialogs(tmuxSession, codeName, log2, config.primaryModel ?? null, sessionId).catch(() => {
4634
4710
  });
4635
- });
4636
- child.on("error", (err) => {
4711
+ };
4712
+ const onTmuxSessionError = (err) => {
4637
4713
  log2(`[persistent-session] Failed to start tmux for '${codeName}': ${err.message}`);
4638
4714
  session.status = "crashed";
4639
4715
  session.startedAt = Date.now();
4640
4716
  session.restartCount++;
4717
+ };
4718
+ let spawnFailed = false;
4719
+ runTmuxSpawnPlan({
4720
+ plan: spawnPlan,
4721
+ spawnOptions: {
4722
+ cwd: projectDir,
4723
+ stdio: ["ignore", "pipe", "pipe"],
4724
+ env: tmuxEnv
4725
+ },
4726
+ onSessionSpawned: (child) => {
4727
+ child.on("close", onTmuxSessionClose);
4728
+ child.on("error", onTmuxSessionError);
4729
+ },
4730
+ onSpawnFailed: (reason) => {
4731
+ spawnFailed = true;
4732
+ log2(
4733
+ `[persistent-session] tmux bootstrap failed for '${codeName}': ${reason} \u2014 refusing to spawn rather than put this session's -e secrets on the tmux server argv for its lifetime (ENG-10092)`
4734
+ );
4735
+ session.status = "crashed";
4736
+ session.startedAt = Date.now();
4737
+ session.restartCount++;
4738
+ }
4641
4739
  });
4642
- session.startedAt = Date.now();
4643
- session.status = "running";
4740
+ if (!spawnFailed) {
4741
+ session.startedAt = Date.now();
4742
+ session.status = "running";
4743
+ }
4644
4744
  } catch (err) {
4645
4745
  log2(`[persistent-session] Failed to start session for '${codeName}': ${err.message}`);
4646
4746
  session.status = "crashed";
@@ -5310,6 +5410,11 @@ export {
5310
5410
  writeDirectChatSessionState,
5311
5411
  spawnBackoffMs,
5312
5412
  startPersistentSession,
5413
+ TMUX_BOOTSTRAP_HOLD_CMD,
5414
+ TMUX_BOOTSTRAP_SESSION_PREFIX,
5415
+ tmuxBootstrapSessionName,
5416
+ buildTmuxSpawnPlan,
5417
+ runTmuxSpawnPlan,
5313
5418
  SEND_KEYS_ENTER_DELAY_MS,
5314
5419
  sendToAgent,
5315
5420
  isAgentPromptReady,
@@ -5326,4 +5431,4 @@ export {
5326
5431
  stopAllSessionsAndWait,
5327
5432
  getProjectDir
5328
5433
  };
5329
- //# sourceMappingURL=chunk-W4KAZQBS.js.map
5434
+ //# sourceMappingURL=chunk-KOVJCGBN.js.map