14 Commits
Author SHA1 Message Date
a69c9190b4 fix(install): relative global bin link and clean failed downloads (#2675)
* fix(install): link global bin entry relatively

Volta installs into a staging directory and renames it afterwards, which left the absolute bin symlink dangling. A relative link survives the rename.

* fix(install): keep failed downloads out of bin/

The fallback download created the binary before checking the HTTP status, so a 404 left a 0-byte executable that the launcher then ran (ENOEXEC). Download to a temp file, rename on success, remove on failure, follow 301/302/307/308, and skip empty candidates when locating the binary.

Co-Authored-By: Lykin <293371022+xunguangzlj-cloud@users.noreply.github.com>
Co-Authored-By: hassnalalshaikh <51247426+hassnalalshaikh@users.noreply.github.com>

* fixup! fix(install): keep failed downloads out of bin/

* fix(install): name empty binaries in the launcher error and bound postinstall tests

---------

Co-authored-by: Lykin <293371022+xunguangzlj-cloud@users.noreply.github.com>
Co-authored-by: hassnalalshaikh <51247426+hassnalalshaikh@users.noreply.github.com>
2026-11-19 20:11:11 -03:00
Chris TateandLahfir d129226078 Ship native binaries as per-platform packages (#2150)
* Ship native binaries as per-platform packages

- Publish each platform binary as an @agent-browser/cli-* optional dependency, so installs download only the host's binary
- Link the global command to the native binary on first run when install scripts are blocked (npm 12, pnpm, bun), and in postinstall when they run
- Release and CI publish the platform packages and test global installs with scripts blocked and allowed

* fix: link the native binary on pnpm 12 and keep skills resolvable

Three fixes on top of the per-platform packaging work.

relinkPnpmShim compared the shim's cmd-shim-target marker to argv[1] with
string equality. On pnpm 12 the marker keeps the ./ from the package's
"./bin/agent-browser.js" and argv[1] does not, so the shim was never
rewritten and every command still started Node. It now compares resolved
paths, which also covers the pnpm 10 and 11 spellings.

The launcher spawned the binary straight out of the platform package.
npm hoists that package beside agent-browser, so skills.rs, chat.rs and
upgrade.rs, which resolve their files by walking up from the executable,
found nothing. It now materializes into agent-browser/bin first and runs
from there.

postinstall only linked when npm_config_global was set, which only npm
does, so pnpm, yarn and bun never linked at install time. It now asks the
invoking manager for its global bin directory and also considers the
enclosing node_modules/.bin, which Yarn Classic links through. The probe
is skipped for local installs so they do not pay a subprocess.

The Windows shims are rewritten in a format npm's read-cmd-shim can parse,
each file's own target is checked before it is replaced, and replacement
is staged then renamed so a failure leaves the working launcher in place.

Verified with real global installs on macOS and Linux: npm with scripts
allowed and blocked, pnpm 11 and 12, and bun. Yarn could not be verified
locally because it fails when an optionalDependency is unresolvable and
the platform packages are unpublished. Windows is unverified.

* fix(pnpm): link the shim to the binary in the package bin

The pnpm branch wrote the platform package's own path into the shim, so
once that package resolved, the binary ran from a directory with no
skills/ above it. It now links the same materialized path the symlink and
Windows branches already use.

---------

Co-authored-by: Lahfir <70215676+lahfir@users.noreply.github.com>
2026-11-10 13:56:18 -06:00
EternalRights 8e70c78d73 fix: fall back to x64 binary on Windows ARM64 (#1269)
Windows ARM64 does not have a native build in CI. Previously, the
postinstall script tried to download gent-browser-win32-arm64.exe
which does not exist in GitHub releases, resulting in a 0kb install.

Fall back to the x64 binary on Windows ARM64, which runs via the OS
built-in x64 emulation. This matches the behavior of the existing
ixWindowsShims() function and unifies the arch detection logic.

Fixes #1256
2026-06-12 17:40:58 -05:00
Chris Tateandctate fb1e860b4e Improve upgrade command installation method detection robustness (#960)
* Improve upgrade command installation method detection robustness

The upgrade command was failing to detect installation method for users who installed via pnpm, yarn, or bun, showing "Could not detect installation method" errors.

## Changes Made

- **Added support for additional package managers**: Extended detection to include pnpm, yarn, and bun alongside existing npm, Homebrew, and Cargo support
- **Implemented install-time marker system**: Modified `postinstall.js` to write a `.install-method` marker file during installation, providing reliable detection that doesn't depend on fragile path heuristics
- **Enhanced path-based fallback detection**: Improved executable path analysis to better identify installation locations for all supported package managers
- **Added command probing**: Implemented fallback checks that query package managers directly to verify global installations

The detection now follows this robust hierarchy:
1. Read install-time marker file (most reliable)
2. Analyze executable path patterns
3. Probe package managers via subprocess calls

This ensures users can successfully upgrade regardless of their chosen package manager.

Fixes #954

* Add .install-method to .gitignore and note Yarn v2+ limitation

- Prevent bin/.install-method marker file from being accidentally
  committed during development
- Add comment clarifying that yarn global upgrade path only works
  with Yarn Classic (v1), not Yarn Berry (v2+)

---------

Co-authored-by: ctate <366502+ctate@users.noreply.github.com>
2026-03-22 09:51:58 -05:00
Chris Tateandctate 02d1a7ad7c Improve postinstall message to detect existing Chrome installations (#815)
* Improve postinstall message to detect existing Chrome installations

Previously, the npm postinstall script always recommended running `agent-browser install` to download Chrome for Testing, even when users already had a working Chrome installation on their system.

This change adds Chrome detection logic to the postinstall script that mirrors the runtime behavior:

- Checks for system Chrome installations on macOS, Linux, and Windows
- Shows a success message when Chrome is found, indicating it will be used automatically
- Only shows the `agent-browser install` warning when no Chrome is detected
- Provides platform-specific guidance (Linux `--with-deps` flag, `--executable-path` alternative)

The detection logic matches the existing Rust `find_chrome()` implementation to ensure consistency between postinstall messaging and runtime behavior.

Fixes #814

* Mention --cdp, --provider, --engine as alternatives in postinstall message

---------

Co-authored-by: ctate <366502+ctate@users.noreply.github.com>
2026-03-15 03:32:34 -05:00
Manolis TzanidakisandClaude Opus 4.6 388f19e1bb feat: add linux-musl (Alpine) builds for x64 and arm64 (#784)
* feat: add linux-musl (Alpine) builds for x64 and arm64

Add x86_64-unknown-linux-musl and aarch64-unknown-linux-musl targets to
the release workflow using cargo-zigbuild. Update the JS wrapper and
postinstall script to detect musl libc and select the correct binary.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: simplify isMusl() and add musl targets to build script

Address PR #784 review feedback:
- Remove redundant first try block in isMusl() (ldd --version always
  throws on musl, so only the `|| true` variant works)
- Add x86_64-unknown-linux-musl and aarch64-unknown-linux-musl targets
  to build-all-platforms.sh to stay in sync with the release workflow

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-14 12:51:35 -05:00
Chris Tate 8e43469c8b full native (#754)
* full native

* fix: apply cargo fmt formatting

* fix: prevent zip path traversal in Chromium installer

Use enclosed_name() to sanitize zip entry paths, preventing malicious
archives from writing outside the extraction directory.

* improvements

* fix: apply cargo fmt formatting

* benchmarks

* bench

* updates

* fixes
2026-03-13 19:59:21 -05:00
Chris Tate c6a33b6338 fix(windows): resolve daemon startup failures and Git Bash compatibility (#582)
* fix(windows): resolve daemon startup failures and Git Bash compatibility

Three root causes behind 27 open Windows issues:

1. Path::canonicalize() returns \\?\ prefixed paths on Windows that
   Node.js cannot parse, preventing daemon startup. Strip the prefix
   before passing to Node. (fixes #522, #390, #56, #25, #37, #89)

2. Git Bash/MSYS2 translates Unix-style paths and resolves node to
   a shell wrapper script. Use node.exe explicitly and set
   MSYS_NO_PATHCONV/MSYS2_ARG_CONV_EXCL to prevent argument mangling.
   (fixes #148, #108, #171)

3. postinstall fixWindowsShims() hardcoded x64 arch and did not verify
   the native binary exists before rewriting shims. Now detects arch
   dynamically and validates the binary path. (fixes #262)

Also:
- Error messages now show TCP port on Windows instead of Unix socket path
- Windows CI expanded to test full daemon lifecycle (open, snapshot, close)

* fix(windows): strip \\?\ prefix in auth-cli path (fixes #579)

Same canonicalize() issue as the daemon spawn path, but in
run_auth_cli() which passes the script path to Node.js.
2026-03-03 08:00:14 -06:00
Chris Tate 18a1abda6e test: add Windows npm global install CI test (reproduces #262) (#293)
* test: add Windows npm global install CI test (reproduces #262)

This test packs the package and installs it globally with npm,
then runs agent-browser --version. This reproduces the issue where
npm-generated shims on Windows try to invoke /bin/sh which doesn't exist.

The bin/agent-browser.js wrapper is added but not yet wired up,
so this commit should fail CI to confirm the issue.

* fix: Windows npm global install and npx support

The shell script wrapper (bin/agent-browser) with #!/bin/sh shebang
causes npm to generate Windows shims that try to invoke /bin/sh,
which doesn't exist on Windows.

This fix uses a hybrid approach:

1. Node.js wrapper (bin/agent-browser.js) as bin entry
   - Makes npx work on all platforms
   - ~100ms overhead (acceptable since npx has its own overhead)

2. postinstall patches bin entries for global installs
   - Windows: Overwrites .cmd/.ps1 shims to invoke .exe directly
   - Mac/Linux: Replaces symlink to point to native binary
   - Zero overhead for `npm i -g agent-browser` users on all platforms

Also fixes PowerShell glob expansion in CI test.

Fixes #262

* fix: Windows npm global install and npx support

The shell script wrapper (bin/agent-browser) with #!/bin/sh shebang
causes npm to generate Windows shims that try to invoke /bin/sh,
which doesn't exist on Windows.

This fix uses a hybrid approach:

1. Node.js wrapper (bin/agent-browser.js) as bin entry
   - Makes npx work on all platforms
   - ~100ms overhead (acceptable since npx has its own overhead)

2. postinstall patches bin entries for global installs
   - Windows: Overwrites .cmd/.ps1 shims to invoke .exe directly
   - Mac/Linux: Replaces symlink to point to native binary
   - Zero overhead for `npm i -g agent-browser` users on all platforms

Also adds cross-platform CI tests for npm global install to catch
regressions on all platforms (Ubuntu, macOS, Windows).

Fixes #262

* test global install

* remove dead code
2026-01-27 00:09:51 -06:00
Chris Tate 957b5e5994 fix: ensure binary is executable after npm install (#229) 2026-01-23 15:40:46 -06:00
Chris Tate 57dc7602fc auto-release (#216)
* auto-release

* fixes

* fix secret name
2026-01-23 11:19:43 -06:00
Chris Tate 6b3bae760b fixes 2026-01-11 03:23:39 -06:00
Chris Tate e7c25e9030 --with-deps 2026-01-10 23:50:09 -06:00
Chris Tate a7e5de5e4f install 2026-01-10 23:47:30 -06:00