@buildautomaton/cli 0.1.71 → 0.1.72

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/cli.js CHANGED
@@ -31064,7 +31064,7 @@ var {
31064
31064
  } = import_index.default;
31065
31065
 
31066
31066
  // src/cli-version.ts
31067
- var CLI_VERSION = "0.1.71".length > 0 ? "0.1.71" : "0.0.0-dev";
31067
+ var CLI_VERSION = "0.1.72".length > 0 ? "0.1.72" : "0.0.0-dev";
31068
31068
 
31069
31069
  // src/cli/defaults.ts
31070
31070
  var DEFAULT_API_URL = process.env.BUILDAUTOMATON_API_URL ?? "https://api.buildautomaton.com";
@@ -34990,7 +34990,11 @@ __export(claude_code_acp_client_exports, {
34990
34990
 
34991
34991
  // src/agents/acp/clients/detect-command-on-path.ts
34992
34992
  init_cli_process_interrupt();
34993
+ import { constants } from "node:fs";
34994
+ import { access } from "node:fs/promises";
34993
34995
  import { execFile as execFile6 } from "node:child_process";
34996
+ import { homedir as homedir2 } from "node:os";
34997
+ import { join as join7 } from "node:path";
34994
34998
  import { promisify as promisify6 } from "node:util";
34995
34999
  var execFileAsync5 = promisify6(execFile6);
34996
35000
  var COMMAND_ON_PATH_PROBE_TIMEOUT_MS = 750;
@@ -35007,6 +35011,21 @@ async function execFileShutdownAware(file2, args, timeoutMs) {
35007
35011
  clearInterval(shutdownPoll);
35008
35012
  }
35009
35013
  }
35014
+ async function isExecutableFile(filePath) {
35015
+ try {
35016
+ await access(filePath, constants.X_OK);
35017
+ return true;
35018
+ } catch {
35019
+ return false;
35020
+ }
35021
+ }
35022
+ async function isCommandInBridgeAgentDirs(command) {
35023
+ const home = process.env.HOME ?? homedir2();
35024
+ for (const dir of getBridgeAgentPathEntries(home)) {
35025
+ if (await isExecutableFile(join7(dir, command))) return true;
35026
+ }
35027
+ return false;
35028
+ }
35010
35029
  async function isCommandOnPath(command, timeoutMs = COMMAND_ON_PATH_PROBE_TIMEOUT_MS) {
35011
35030
  if (isCliImmediateShutdownRequested()) return false;
35012
35031
  try {
@@ -35016,9 +35035,19 @@ async function isCommandOnPath(command, timeoutMs = COMMAND_ON_PATH_PROBE_TIMEOU
35016
35035
  });
35017
35036
  return true;
35018
35037
  } catch {
35019
- return false;
35038
+ return isCommandInBridgeAgentDirs(command);
35020
35039
  }
35021
35040
  }
35041
+ async function waitForCommandOnPath(command, opts = {}) {
35042
+ const maxAttempts = opts.maxAttempts ?? 8;
35043
+ const delayMs = opts.delayMs ?? 400;
35044
+ const timeoutMs = opts.timeoutMs ?? COMMAND_ON_PATH_PROBE_TIMEOUT_MS;
35045
+ for (let attempt = 0; attempt < maxAttempts; attempt++) {
35046
+ if (await isCommandOnPath(command, timeoutMs)) return true;
35047
+ if (attempt < maxAttempts - 1) await new Promise((r) => setTimeout(r, delayMs));
35048
+ }
35049
+ return false;
35050
+ }
35022
35051
  async function execProbeShutdownAware(file2, args, timeoutMs) {
35023
35052
  if (isCliImmediateShutdownRequested()) return false;
35024
35053
  try {
@@ -37681,11 +37710,11 @@ init_cli_process_interrupt();
37681
37710
  var BRIDGE_MCP_SERVER_NAME2 = "buildautomaton-bridge";
37682
37711
 
37683
37712
  // src/mcp/resolve-bridge-mcp-server-path.ts
37684
- import { dirname as dirname7, join as join7 } from "node:path";
37713
+ import { dirname as dirname7, join as join8 } from "node:path";
37685
37714
  import { fileURLToPath as fileURLToPath7 } from "node:url";
37686
37715
  function resolveBridgeMcpServerScriptPath() {
37687
37716
  const cliDir = dirname7(fileURLToPath7(import.meta.url));
37688
- return join7(cliDir, "bridge-mcp-server.js");
37717
+ return join8(cliDir, "bridge-mcp-server.js");
37689
37718
  }
37690
37719
 
37691
37720
  // src/mcp/build-acp-mcp-servers.ts
@@ -52944,9 +52973,22 @@ var handleInstallSkillsMessage = (msg, deps) => {
52944
52973
  // src/agents/install/commands/run-npm-global-install.ts
52945
52974
  import { execFile as execFile9 } from "node:child_process";
52946
52975
  import { promisify as promisify10 } from "node:util";
52976
+
52977
+ // src/agents/install/format-command-output.ts
52978
+ function formatCommandOutput(stdout, stderr) {
52979
+ const parts = [String(stdout ?? "").trimEnd(), String(stderr ?? "").trimEnd()].filter(Boolean);
52980
+ return parts.join("\n");
52981
+ }
52982
+
52983
+ // src/agents/install/commands/run-npm-global-install.ts
52947
52984
  var execFileAsync8 = promisify10(execFile9);
52948
52985
  async function runNpmGlobalInstall(packageName, env, timeoutMs = 3e5) {
52949
- await execFileAsync8("npm", ["install", "-g", packageName], { timeout: timeoutMs, env: bridgeAgentPathEnv(env) });
52986
+ const { stdout, stderr } = await execFileAsync8("npm", ["install", "-g", packageName], {
52987
+ timeout: timeoutMs,
52988
+ env: bridgeAgentPathEnv(env),
52989
+ maxBuffer: 10 * 1024 * 1024
52990
+ });
52991
+ return formatCommandOutput(stdout, stderr);
52950
52992
  }
52951
52993
 
52952
52994
  // src/agents/install/commands/claude-code.ts
@@ -52954,11 +52996,11 @@ var claudeCodeInstallCommand = {
52954
52996
  agentType: "claude-code",
52955
52997
  detectCommand: "claude",
52956
52998
  async install(ctx) {
52957
- ctx.onProgress?.("Installing Anthropic Claude Code");
52958
- await runNpmGlobalInstall("@anthropic-ai/claude-code", {
52999
+ const logOutput = await runNpmGlobalInstall("@anthropic-ai/claude-code", {
52959
53000
  ...ctx.env,
52960
53001
  ANTHROPIC_API_KEY: ctx.authToken
52961
53002
  });
53003
+ ctx.onProgress?.("Installing Anthropic Claude Code", logOutput || void 0);
52962
53004
  }
52963
53005
  };
52964
53006
 
@@ -52967,11 +53009,11 @@ var codexAcpInstallCommand = {
52967
53009
  agentType: "codex-acp",
52968
53010
  detectCommand: "codex",
52969
53011
  async install(ctx) {
52970
- ctx.onProgress?.("Installing Codex");
52971
- await runNpmGlobalInstall("@openai/codex", {
53012
+ const logOutput = await runNpmGlobalInstall("@openai/codex", {
52972
53013
  ...ctx.env,
52973
53014
  OPENAI_API_KEY: ctx.authToken
52974
53015
  });
53016
+ ctx.onProgress?.("Installing Codex", logOutput || void 0);
52975
53017
  }
52976
53018
  };
52977
53019
 
@@ -52982,12 +53024,19 @@ var execFileAsync9 = promisify11(execFile10);
52982
53024
  var cursorCliInstallCommand = {
52983
53025
  agentType: "cursor-cli",
52984
53026
  detectCommand: "agent",
53027
+ alternateDetectCommands: ["cursor-agent"],
52985
53028
  async install(ctx) {
52986
- ctx.onProgress?.("Installing Cursor CLI");
52987
- await execFileAsync9("bash", ["-lc", "curl -fsSL https://cursor.com/install | bash"], {
52988
- timeout: 3e5,
52989
- env: { ...bridgeAgentPathEnv(ctx.env), CURSOR_API_KEY: ctx.authToken }
52990
- });
53029
+ const { stdout, stderr } = await execFileAsync9(
53030
+ "bash",
53031
+ ["-lc", "curl -fsSL https://cursor.com/install | bash"],
53032
+ {
53033
+ timeout: 3e5,
53034
+ env: { ...bridgeAgentPathEnv(ctx.env), CURSOR_API_KEY: ctx.authToken },
53035
+ maxBuffer: 10 * 1024 * 1024
53036
+ }
53037
+ );
53038
+ const logOutput = formatCommandOutput(stdout, stderr);
53039
+ ctx.onProgress?.("Installing Cursor CLI", logOutput || void 0);
52991
53040
  }
52992
53041
  };
52993
53042
 
@@ -52996,11 +53045,11 @@ var opencodeInstallCommand = {
52996
53045
  agentType: "opencode",
52997
53046
  detectCommand: "opencode",
52998
53047
  async install(ctx) {
52999
- ctx.onProgress?.("Installing OpenCode");
53000
- await runNpmGlobalInstall("opencode-ai", {
53048
+ const logOutput = await runNpmGlobalInstall("opencode-ai", {
53001
53049
  ...ctx.env,
53002
53050
  OPENCODE_API_KEY: ctx.authToken
53003
53051
  });
53052
+ ctx.onProgress?.("Installing OpenCode", logOutput || void 0);
53004
53053
  }
53005
53054
  };
53006
53055
 
@@ -53034,7 +53083,17 @@ async function installLocalAgentOnBridge(params) {
53034
53083
  return { success: false, error: msg };
53035
53084
  }
53036
53085
  ensureBridgeAgentPathInProcessEnv();
53037
- const found = await isCommandOnPath(command.detectCommand);
53086
+ const detectNames = [
53087
+ command.detectCommand,
53088
+ ...command.alternateDetectCommands ?? []
53089
+ ];
53090
+ let found = false;
53091
+ for (const name of detectNames) {
53092
+ if (await waitForCommandOnPath(name)) {
53093
+ found = true;
53094
+ break;
53095
+ }
53096
+ }
53038
53097
  if (!found) {
53039
53098
  return { success: false, error: `${command.detectCommand} not found on PATH after install` };
53040
53099
  }
@@ -53051,7 +53110,7 @@ var handleInstallAgentMessage = (msg, deps) => {
53051
53110
  if (!processId || !agentId || !tokenId || !agentType || !authToken) return;
53052
53111
  void (async () => {
53053
53112
  const socket = deps.getWs();
53054
- const report = (step, message) => {
53113
+ const report = (step, message, logOutput) => {
53055
53114
  if (socket) {
53056
53115
  sendWsMessage(socket, {
53057
53116
  type: "install_agent_progress",
@@ -53060,14 +53119,15 @@ var handleInstallAgentMessage = (msg, deps) => {
53060
53119
  tokenId,
53061
53120
  agentType,
53062
53121
  step,
53063
- message
53122
+ message,
53123
+ ...logOutput ? { logOutput } : {}
53064
53124
  });
53065
53125
  }
53066
53126
  };
53067
53127
  const result = await installLocalAgentOnBridge({
53068
53128
  agentType,
53069
53129
  authToken,
53070
- onProgress: (message) => report("agent_install_package", message)
53130
+ onProgress: (message, logOutput) => report("agent_install_package", message, logOutput)
53071
53131
  });
53072
53132
  if (socket) {
53073
53133
  sendWsMessage(socket, {