@integrity-labs/agt-cli 0.27.169 → 0.28.1

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.
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  claudeModelAlias,
3
3
  isClaudeFastMode
4
- } from "./chunk-L2UTBXZS.js";
4
+ } from "./chunk-I6QV3IE7.js";
5
5
  import {
6
6
  reapOrphanChannelMcps
7
7
  } from "./chunk-XWVM4KPK.js";
@@ -11,7 +11,6 @@ import { spawn, execSync, execFileSync as execFileSync3 } from "child_process";
11
11
  import { join as join2, dirname } from "path";
12
12
  import { homedir as homedir2, platform, userInfo } from "os";
13
13
  import { existsSync as existsSync3, readFileSync as readFileSync4, readdirSync as readdirSync2, writeFileSync as writeFileSync3, appendFileSync, mkdirSync as mkdirSync2, chmodSync, copyFileSync, rmSync } from "fs";
14
- import { fileURLToPath } from "url";
15
14
 
16
15
  // src/lib/mcp-sanitize.ts
17
16
  import { readFileSync, writeFileSync } from "fs";
@@ -708,60 +707,6 @@ function collectMcpServerNames(mcpConfigPath) {
708
707
  return [];
709
708
  }
710
709
  }
711
- var _acpxBin = null;
712
- function getAcpxBin() {
713
- if (_acpxBin) return _acpxBin;
714
- const moduleDir = dirname(fileURLToPath(import.meta.url));
715
- let dir = moduleDir;
716
- for (let i = 0; i < 6; i++) {
717
- const candidate = join2(dir, "node_modules", ".bin", "acpx");
718
- if (existsSync3(candidate)) {
719
- _acpxBin = candidate;
720
- return _acpxBin;
721
- }
722
- const parent = dirname(dir);
723
- if (parent === dir) break;
724
- dir = parent;
725
- }
726
- try {
727
- execSync("which acpx", { stdio: "ignore" });
728
- _acpxBin = "acpx";
729
- return _acpxBin;
730
- } catch {
731
- return "";
732
- }
733
- }
734
- function defaultAcpxSessionProbe(acpxBin, projectDir) {
735
- try {
736
- execFileSync3(acpxBin, ["claude", "list-sessions"], {
737
- cwd: projectDir,
738
- timeout: 5e3,
739
- stdio: "ignore"
740
- });
741
- return true;
742
- } catch {
743
- return false;
744
- }
745
- }
746
- var acpxSessionProbe = defaultAcpxSessionProbe;
747
- var acpxSessionAvailableCache = /* @__PURE__ */ new Map();
748
- var acpxExecFailureCounts = /* @__PURE__ */ new Map();
749
- function takeAcpxExecFailureCount(codeName) {
750
- const count = acpxExecFailureCounts.get(codeName) ?? 0;
751
- acpxExecFailureCounts.delete(codeName);
752
- return count;
753
- }
754
- function creditAcpxExecFailureCount(codeName, count) {
755
- if (count <= 0) return;
756
- acpxExecFailureCounts.set(codeName, (acpxExecFailureCounts.get(codeName) ?? 0) + count);
757
- }
758
- function hasAcpxSession(acpxBin, projectDir, codeName) {
759
- const cached = acpxSessionAvailableCache.get(codeName);
760
- if (cached !== void 0) return cached;
761
- const available = acpxSessionProbe(acpxBin, projectDir);
762
- acpxSessionAvailableCache.set(codeName, available);
763
- return available;
764
- }
765
710
  var sessions = /* @__PURE__ */ new Map();
766
711
  var PANE_LOG_DIR = join2(homedir2(), ".augmented");
767
712
  var PANE_TAIL_LINES = 20;
@@ -895,7 +840,6 @@ function spawnSession(config, session) {
895
840
  log(`[persistent-session] Starting tmux session '${tmuxSession}' for '${codeName}' (auth=${claudeAuthMode})`);
896
841
  try {
897
842
  sanitizeMcpJson(mcpConfigPath, apiHost);
898
- writeAcpxConfig(config);
899
843
  try {
900
844
  execSync(`tmux kill-session -t ${tmuxSession} 2>/dev/null`, { stdio: "ignore" });
901
845
  } catch {
@@ -1251,26 +1195,11 @@ var _internals = {
1251
1195
  __setHygieneKeySender(fn) {
1252
1196
  hygieneKeySender = fn ?? defaultHygieneKeySender;
1253
1197
  },
1254
- // ENG-5758 test seam: swap the acpx session probe so unit tests can
1255
- // simulate "session present" / "no session" without spawning acpx.
1256
- __setAcpxSessionProbe(fn) {
1257
- acpxSessionProbe = fn ?? defaultAcpxSessionProbe;
1258
- acpxSessionAvailableCache.clear();
1259
- },
1260
- // ENG-5758 test seam: pin the resolved acpx binary path so unit tests can
1261
- // exercise the "acpx present but no session" branch deterministically,
1262
- // independent of what's installed in the test node_modules. null re-resolves.
1263
- __setAcpxBin(path) {
1264
- _acpxBin = path;
1265
- },
1266
1198
  // Test-only resets so each test starts from a clean slate.
1267
1199
  __resetZombieState() {
1268
1200
  zombieProbeCache.clear();
1269
1201
  pendingZombieDetections.clear();
1270
1202
  },
1271
- __resetAcpxSessionCache() {
1272
- acpxSessionAvailableCache.clear();
1273
- },
1274
1203
  __getSessionsMap() {
1275
1204
  return sessions;
1276
1205
  },
@@ -1291,44 +1220,6 @@ async function injectMessageWithStatus(codeName, type, content, meta, log) {
1291
1220
  }
1292
1221
  const prefix = meta?.task_name ? `[Task: ${meta.task_name}] ` : "";
1293
1222
  const text = prefix + content;
1294
- const projectDir = getProjectDir(codeName);
1295
- const acpx = getAcpxBin();
1296
- if (acpx && hasAcpxSession(acpx, projectDir, codeName)) {
1297
- try {
1298
- const tmpDir = join2(projectDir, ".claude");
1299
- mkdirSync2(tmpDir, { recursive: true });
1300
- const tmpFile = join2(tmpDir, ".agt-inject-prompt.txt");
1301
- writeFileSync3(tmpFile, text);
1302
- _log(`[inject] acpx exec (fire-and-forget): cwd=${projectDir}, file=${tmpFile}`);
1303
- const child = spawn(acpx, ["claude", "exec", "-f", tmpFile], {
1304
- cwd: projectDir,
1305
- stdio: "ignore",
1306
- detached: true
1307
- });
1308
- child.on("error", (err) => {
1309
- _log(`[inject] acpx spawn error for '${codeName}': ${err.message}`);
1310
- acpxExecFailureCounts.set(codeName, (acpxExecFailureCounts.get(codeName) ?? 0) + 1);
1311
- });
1312
- child.on("exit", (code) => {
1313
- if (code && code !== 0) {
1314
- const exit4Detail = code === 4 ? " (no acpx session)" : "";
1315
- _log(
1316
- `[inject] acpx exec exited ${code}${exit4Detail} for '${codeName}' \u2014 type=${type} input_hash=${simpleTextHash(text)} len=${text.length} \u2014 message may not have been delivered`
1317
- );
1318
- acpxExecFailureCounts.set(codeName, (acpxExecFailureCounts.get(codeName) ?? 0) + 1);
1319
- acpxSessionAvailableCache.delete(codeName);
1320
- }
1321
- });
1322
- child.unref();
1323
- return { delivered: true, fallbackUsed: false };
1324
- } catch (err) {
1325
- _log(`[inject] acpx exec failed for '${codeName}': ${err.message}`);
1326
- }
1327
- } else if (acpx) {
1328
- _log(`[inject] no acpx session for '${codeName}' \u2014 falling back to tmux send-keys`);
1329
- } else {
1330
- _log(`[inject] acpx binary not found \u2014 falling back to tmux send-keys`);
1331
- }
1332
1223
  const singleLineText = text.replace(/\s*\n+\s*/g, " ").trim();
1333
1224
  await preSendPaneHygiene(`agt-${codeName}`, codeName, _log);
1334
1225
  const sent = sendToAgent(`agt-${codeName}`, singleLineText);
@@ -1355,24 +1246,7 @@ function stopPersistentSession(codeName, log) {
1355
1246
  );
1356
1247
  }
1357
1248
  }
1358
- try {
1359
- const acpx = getAcpxBin();
1360
- if (acpx) {
1361
- execFileSync3(acpx, ["claude", "sessions", "close", `agt-${codeName}`], {
1362
- cwd: getProjectDir(codeName),
1363
- timeout: 5e3,
1364
- stdio: ["ignore", "ignore", "pipe"]
1365
- });
1366
- }
1367
- } catch (err) {
1368
- const stderr = (err.stderr ?? "").toString().trim();
1369
- const benign = /not found|no such session|unknown session/i.test(stderr);
1370
- if (stderr && !benign) {
1371
- log(`[persistent-session] acpx sessions close for '${codeName}' failed: ${stderr} (ENG-6174)`);
1372
- }
1373
- }
1374
1249
  sessions.delete(codeName);
1375
- acpxSessionAvailableCache.delete(codeName);
1376
1250
  setTimeout(() => {
1377
1251
  reapOrphanChannelMcps({ log });
1378
1252
  }, 3e3).unref();
@@ -1550,53 +1424,6 @@ async function stopAllSessionsAndWait(log, opts) {
1550
1424
  function getProjectDir(codeName) {
1551
1425
  return join2(homedir2(), ".augmented", codeName, "project");
1552
1426
  }
1553
- function writeAcpxConfig(config) {
1554
- const {
1555
- projectDir,
1556
- mcpConfigPath,
1557
- claudeMdPath,
1558
- channels,
1559
- devChannels,
1560
- anthropicApiKey
1561
- } = config;
1562
- const claudeAuthMode = config.claudeAuthMode ?? "subscription";
1563
- const claudeArgs = [];
1564
- if (channels.length > 0) claudeArgs.push("--channels", ...channels);
1565
- if (devChannels.length > 0) claudeArgs.push("--dangerously-load-development-channels", ...devChannels);
1566
- claudeArgs.push("--mcp-config", mcpConfigPath);
1567
- if (existsSync3(claudeMdPath)) claudeArgs.push("--system-prompt-file", claudeMdPath);
1568
- const acpModelAlias = claudeModelAlias(config.primaryModel);
1569
- if (acpModelAlias) claudeArgs.push("--model", acpModelAlias);
1570
- claudeArgs.push("--allow-dangerously-skip-permissions");
1571
- claudeArgs.push("--dangerously-skip-permissions");
1572
- claudeArgs.push("--strict-mcp-config");
1573
- const mcpServerNames2 = collectMcpServerNames(mcpConfigPath);
1574
- claudeArgs.push("--allowedTools", buildAllowedTools(mcpServerNames2));
1575
- const acpCmd = `npx -y @agentclientprotocol/claude-agent-acp ${claudeArgs.map((a) => a.includes(" ") || a.includes("*") ? JSON.stringify(a) : a).join(" ")}`;
1576
- const envIntegrationsPath = join2(projectDir, ".env.integrations");
1577
- const wrapperPath = join2(projectDir, ".claude", "acpx-agent.sh");
1578
- const wrapperLines = ["#!/usr/bin/env bash"];
1579
- if (existsSync3(envIntegrationsPath)) {
1580
- wrapperLines.push(`set -a`, `source ${JSON.stringify(envIntegrationsPath)}`, `set +a`);
1581
- }
1582
- if (claudeAuthMode === "api_key" && anthropicApiKey) {
1583
- wrapperLines.push(`export ANTHROPIC_API_KEY=${JSON.stringify(anthropicApiKey)}`);
1584
- }
1585
- wrapperLines.push(`exec ${acpCmd}`);
1586
- mkdirSync2(join2(projectDir, ".claude"), { recursive: true });
1587
- writeFileSync3(wrapperPath, wrapperLines.join("\n") + "\n", { mode: 493 });
1588
- chmodSync(wrapperPath, 493);
1589
- const acpxConfig = {
1590
- defaultAgent: "claude",
1591
- defaultPermissions: "approve-all",
1592
- agents: {
1593
- claude: {
1594
- command: wrapperPath
1595
- }
1596
- }
1597
- };
1598
- writeFileSync3(join2(projectDir, ".acpxrc.json"), JSON.stringify(acpxConfig, null, 2));
1599
- }
1600
1427
 
1601
1428
  export {
1602
1429
  formatMissingVar,
@@ -1616,8 +1443,6 @@ export {
1616
1443
  creditWatchdogGiveUpCount,
1617
1444
  resolveClaudeBinary,
1618
1445
  writePersistentClaudeWrapper,
1619
- takeAcpxExecFailureCount,
1620
- creditAcpxExecFailureCount,
1621
1446
  paneLogPath,
1622
1447
  readPaneLogTail,
1623
1448
  prepareForRespawn,
@@ -1641,4 +1466,4 @@ export {
1641
1466
  stopAllSessionsAndWait,
1642
1467
  getProjectDir
1643
1468
  };
1644
- //# sourceMappingURL=chunk-4ULNASXC.js.map
1469
+ //# sourceMappingURL=chunk-K2HIV5DB.js.map