@moxxy/cli 0.50.1 → 0.50.2

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.
Files changed (2) hide show
  1. package/dist/bin.js +129 -8
  2. package/package.json +2 -2
package/dist/bin.js CHANGED
@@ -95069,6 +95069,9 @@ var init_agent_versions_blocked2 = __esm({
95069
95069
  BUNDLED_BLOCKED_AGENT_VERSIONS = parseBlockedAgentVersions(agent_versions_blocked_default) ?? {};
95070
95070
  }
95071
95071
  });
95072
+ function downloadInstaller(url, shell) {
95073
+ return `script=$(curl -fsSL '${url}') && printf '%s\\n' "$script" | ${shell}`;
95074
+ }
95072
95075
  function codexWindowsPrograms(arch) {
95073
95076
  const build2 = CODEX_WINDOWS_BUILDS[arch];
95074
95077
  if (!build2)
@@ -95541,8 +95544,34 @@ function installInvocation(desc, platform2 = process.platform) {
95541
95544
  }
95542
95545
  async function runAgentCliAction(desc, action, opts = {}) {
95543
95546
  const platform2 = opts.platform ?? process.platform;
95544
- if (action === "update")
95545
- return updateAgentCli(desc, opts, platform2);
95547
+ const printed = [];
95548
+ const log2 = opts.logFile ? startRunLog(opts.logFile, desc, action) : void 0;
95549
+ const watched = {
95550
+ ...opts,
95551
+ onLine: (line) => {
95552
+ if (action === "install") {
95553
+ printed.push(line);
95554
+ if (printed.length > DIAGNOSTIC_LINES)
95555
+ printed.shift();
95556
+ }
95557
+ log2?.line(line);
95558
+ opts.onLine?.(line);
95559
+ }
95560
+ };
95561
+ try {
95562
+ const result = action === "update" ? await updateAgentCli(desc, watched, platform2) : await installAgentCli(desc, watched, platform2, printed);
95563
+ log2?.line(`Result: ${result.ok ? "done" : "failed"} \u2014 ${result.message}`);
95564
+ if (result.details)
95565
+ log2?.line(`Details: ${result.details}`);
95566
+ return result;
95567
+ } finally {
95568
+ await log2?.close();
95569
+ }
95570
+ }
95571
+ function installStopped(desc, hint) {
95572
+ return `${desc.name}'s installer stopped before it finished. ${hint ?? "Try again in a moment."}`;
95573
+ }
95574
+ async function installAgentCli(desc, opts, platform2, printed) {
95546
95575
  const { command, args } = installInvocation(desc, platform2);
95547
95576
  const child = spawn(command, [...args], {
95548
95577
  env: { ...process.env, ...desc.installEnv },
@@ -95550,7 +95579,78 @@ async function runAgentCliAction(desc, action, opts = {}) {
95550
95579
  detached: platform2 !== "win32",
95551
95580
  windowsHide: true
95552
95581
  });
95553
- return watch(child, opts, "the installer");
95582
+ const result = await watch(child, opts, "the installer");
95583
+ if (!result.ok) {
95584
+ if (result.message === STOPPED)
95585
+ return result;
95586
+ const hint = installFailureHint([...printed, result.message]);
95587
+ return {
95588
+ ok: false,
95589
+ message: /^curl: \(\d+\)/.test(result.message) ? `Couldn't download ${desc.name}. ${hint ?? "Try again in a moment."}` : installStopped(desc, hint),
95590
+ details: installFailureDetails(printed, result.message)
95591
+ };
95592
+ }
95593
+ return await installLeftACopy(desc, opts) ? result : { ok: false, message: installLeftNothing(desc, platform2) };
95594
+ }
95595
+ async function installLeftACopy(desc, opts) {
95596
+ for (let attempt = 1; ; attempt += 1) {
95597
+ if (findAgentCli(desc, opts))
95598
+ return true;
95599
+ if (attempt === VERSION_TRIES)
95600
+ return false;
95601
+ await setTimeout$1(opts.versionRetryMs ?? VERSION_RETRY_MS);
95602
+ }
95603
+ }
95604
+ function installLeftNothing(desc, platform2 = process.platform) {
95605
+ const history = platform2 === "win32" ? "Windows Security \u2192 Protection history" : "its history";
95606
+ return `${desc.name}'s installer finished, but ${desc.name} is not on this computer afterwards. Antivirus software sometimes removes a program it has just installed: look in ${history}, allow ${desc.name}, and try again.`;
95607
+ }
95608
+ function installFailureHint(printed) {
95609
+ const text3 = printed.join("\n");
95610
+ return INSTALL_FAILURES.find((failure) => failure.seen.test(text3))?.hint ?? null;
95611
+ }
95612
+ function installFailureDetails(printed, last) {
95613
+ const end = printed.lastIndexOf(last);
95614
+ if (POWERSHELL_ERROR_ID.test(last)) {
95615
+ for (let i2 = end - 1; i2 >= 0; i2--) {
95616
+ const line = printed[i2];
95617
+ if (!line || POWERSHELL_ERROR_ID.test(line))
95618
+ break;
95619
+ const target = /^\+\s*CategoryInfo\s*:\s*ObjectNotFound:\s*\((.+):String\)\s*\[\],\s*CommandNotFoundException$/i.exec(line);
95620
+ if (target && /:\s*CommandNotFoundException$/i.test(last)) {
95621
+ return `The installer could not find the command '${target[1]}'.`;
95622
+ }
95623
+ if (/^[^+\s]\S*\s+:\s+\S/.test(line))
95624
+ return line;
95625
+ }
95626
+ } else if (NPM_LOG_FOOTER.test(last)) {
95627
+ for (let i2 = end - 1; i2 >= 0; i2--) {
95628
+ const line = printed[i2];
95629
+ if (!line || NPM_LOG_FOOTER.test(line))
95630
+ break;
95631
+ if (/^npm (?:error|ERR!)\s+\S/i.test(line))
95632
+ return line;
95633
+ }
95634
+ }
95635
+ return last;
95636
+ }
95637
+ function startRunLog(file, desc, action) {
95638
+ const stream2 = new PassThrough();
95639
+ const saved = writeFileAtomic(file, stream2).catch(() => {
95640
+ stream2.destroy();
95641
+ });
95642
+ stream2.write(`Moxxy \xB7 ${action} ${desc.name} (${desc.command}) \xB7 ${(/* @__PURE__ */ new Date()).toISOString()}
95643
+ `);
95644
+ return {
95645
+ line(text3) {
95646
+ if (!stream2.destroyed)
95647
+ stream2.write(text3 + "\n");
95648
+ },
95649
+ close() {
95650
+ stream2.end();
95651
+ return saved;
95652
+ }
95653
+ };
95554
95654
  }
95555
95655
  async function updateAgentCli(desc, opts, platform2) {
95556
95656
  const found = findAgentCli(desc, opts);
@@ -95681,7 +95781,7 @@ function watch(child, opts, runIt) {
95681
95781
  killTree$1(child, "SIGTERM");
95682
95782
  finish({ ok: false, message });
95683
95783
  };
95684
- const stop = () => end("Stopped.");
95784
+ const stop = () => end(STOPPED);
95685
95785
  let silence;
95686
95786
  const heard = () => {
95687
95787
  clearTimeout(silence);
@@ -95729,7 +95829,7 @@ function watch(child, opts, runIt) {
95729
95829
  });
95730
95830
  });
95731
95831
  }
95732
- var CLAUDE_CLI, CODEX_WINDOWS_BUILDS, CODEX_CLI, OPENCODE_CLI, AGENT_CLIS, PATH_FALLBACK_ENV, PACKAGE_TOOLS, MISE_PATH, WINDOWS_NATIVE, WINDOWS_SHIMS, SHIM_TARGET, HOUR_MS3, SOURCE_TIMEOUT_MS, cacheChanges, UPDATER_STDIO, VERSION_TRIES, VERSION_RETRY_MS, SILENCE_LIMIT_MS, ASKS_TO_CONFIRM, ANSI, PERCENT;
95832
+ var CLAUDE_CLI, CODEX_WINDOWS_BUILDS, CODEX_CLI, OPENCODE_CLI, AGENT_CLIS, PATH_FALLBACK_ENV, PACKAGE_TOOLS, MISE_PATH, WINDOWS_NATIVE, WINDOWS_SHIMS, SHIM_TARGET, HOUR_MS3, SOURCE_TIMEOUT_MS, cacheChanges, INSTALL_FAILURES, POWERSHELL_ERROR_ID, NPM_LOG_FOOTER, DIAGNOSTIC_LINES, STOPPED, UPDATER_STDIO, VERSION_TRIES, VERSION_RETRY_MS, SILENCE_LIMIT_MS, ASKS_TO_CONFIRM, ANSI, PERCENT;
95733
95833
  var init_agent_cli2 = __esm({
95734
95834
  "../agent-connection-kit/dist/agent-cli.js"() {
95735
95835
  init_cli_version();
@@ -95747,7 +95847,7 @@ var init_agent_cli2 = __esm({
95747
95847
  setting: "autoUpdatesChannel",
95748
95848
  fallback: "latest"
95749
95849
  },
95750
- install: { posix: "curl -fsSL https://claude.ai/install.sh | bash", windows: "irm https://claude.ai/install.ps1 | iex" },
95850
+ install: { posix: downloadInstaller("https://claude.ai/install.sh", "bash"), windows: "irm https://claude.ai/install.ps1 | iex" },
95751
95851
  installDirs: [".local/bin"],
95752
95852
  windowsShim: { entry: "node_modules/@anthropic-ai/claude-code/cli.js", runs: "node" }
95753
95853
  };
@@ -95763,7 +95863,7 @@ var init_agent_cli2 = __esm({
95763
95863
  minimumVersion: "0.155.1",
95764
95864
  updateArgs: ["update"],
95765
95865
  install: {
95766
- posix: "curl -fsSL https://chatgpt.com/codex/install.sh | sh",
95866
+ posix: downloadInstaller("https://chatgpt.com/codex/install.sh", "sh"),
95767
95867
  windows: "irm https://chatgpt.com/codex/install.ps1 | iex"
95768
95868
  },
95769
95869
  // install.ps1 puts it in %LOCALAPPDATA%\Programs\OpenAI\Codex\bin.
@@ -95783,7 +95883,7 @@ var init_agent_cli2 = __esm({
95783
95883
  // OpenCode 1's `upgrade` stays on 1; `--major` replaces it with OpenCode 2 the way it was installed.
95784
95884
  majorUpdateArgs: ["upgrade", "--major"],
95785
95885
  // OpenCode's install script is POSIX only; on Windows it ships through npm. `/install` still installs OpenCode 1.
95786
- install: { posix: "curl -fsSL https://opencode.ai/v2/install | bash", windows: "npm install -g @opencode/cli" },
95886
+ install: { posix: downloadInstaller("https://opencode.ai/v2/install", "bash"), windows: "npm install -g @opencode/cli" },
95787
95887
  installDirs: [".opencode/bin"],
95788
95888
  // OpenCode 2 is published as @opencode/cli; OpenCode 1 as opencode-ai.
95789
95889
  windowsShim: {
@@ -95822,6 +95922,25 @@ var init_agent_cli2 = __esm({
95822
95922
  HOUR_MS3 = 60 * 6e4;
95823
95923
  SOURCE_TIMEOUT_MS = 2e4;
95824
95924
  cacheChanges = /* @__PURE__ */ new Map();
95925
+ INSTALL_FAILURES = [
95926
+ { seen: /\bENOSPC\b|not enough space|no space left/i, hint: "Free some disk space and try again." },
95927
+ {
95928
+ seen: /CERT_|SSL\/TLS|certificate|SELF_SIGNED/i,
95929
+ hint: "Check the computer's date and time. A school or work network can also block the download."
95930
+ },
95931
+ {
95932
+ seen: /curl: \((?:5|6|7|28)\)|could not (?:be )?resolved?|\bENOTFOUND\b|\bEAI_AGAIN\b|getaddrinfo|\bETIMEDOUT\b|\bECONNREFUSED\b|\bECONNRESET\b|unable to connect to the remote server|network is unreachable|no such host is known/i,
95933
+ hint: "Check the internet connection and try again."
95934
+ },
95935
+ {
95936
+ seen: /\bEACCES\b|\bEPERM\b|access (?:to the path .*)?is denied|permission denied|operation not permitted/i,
95937
+ hint: "This account may not be allowed to install programs here. Ask the computer's administrator."
95938
+ }
95939
+ ];
95940
+ POWERSHELL_ERROR_ID = /^\+\s*FullyQualifiedErrorId\s*:/i;
95941
+ NPM_LOG_FOOTER = /^npm (?:error|ERR!)\s+A complete log of this run can be found in:/i;
95942
+ DIAGNOSTIC_LINES = 2e3;
95943
+ STOPPED = "Stopped.";
95825
95944
  UPDATER_STDIO = ["ignore", "pipe", "pipe"];
95826
95945
  VERSION_TRIES = 3;
95827
95946
  VERSION_RETRY_MS = 2e3;
@@ -95942,6 +96061,8 @@ async function runAgentsCommand(argv, deps = {}) {
95942
96061
  });
95943
96062
  if (!result.ok) {
95944
96063
  err(`${desc.name}: ${result.message}
96064
+ `);
96065
+ if (result.details) err(`${colors.dim(result.details)}
95945
96066
  `);
95946
96067
  return 1;
95947
96068
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moxxy/cli",
3
- "version": "0.50.1",
3
+ "version": "0.50.2",
4
4
  "description": "moxxy command-line agent: TUI, one-shot prompts, setup, services, and API-key or installed-CLI subscription providers.",
5
5
  "keywords": [
6
6
  "moxxy",
@@ -49,7 +49,7 @@
49
49
  "dependencies": {
50
50
  "undici": "^8.12.2",
51
51
  "zod": "^4.6.7",
52
- "@moxxy/sdk": "0.50.1"
52
+ "@moxxy/sdk": "0.50.2"
53
53
  },
54
54
  "optionalDependencies": {
55
55
  "@napi-rs/keyring": "^2.1.2"