From c635e0bd296ae09c3a0455e240bb9f0e0bb7dbe8 Mon Sep 17 00:00:00 2001 From: Ookay <1170488531@qq.com> Date: Wed, 21 Jan 2026 16:01:03 +0800 Subject: [PATCH] fix(windows): Fix npm wrapper scripts for Windows This commit fixes the Windows wrapper scripts generated by npm to properly call the native Windows binary instead of failing to find /bin/sh. Changes: - Updated bin/agent-browser.cmd to detect architecture and directly call the agent-browser-win32-{arch}.exe binary - Updated bin/agent-browser shell script to properly add .exe extension for Windows binaries when running in Git Bash/MSYS environments - Added proper error messages when binary is not found Fixes the issue where running 'agent-browser' on Windows would fail with "The system cannot find the path specified" or "/bin/sh.exe not found" errors. Testing: - Tested on Windows 11 with PowerShell - Tested on Windows 11 with CMD - Verified binary detection and execution works correctly --- bin/agent-browser | 6 +++++- bin/agent-browser.cmd | 23 ++++++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/bin/agent-browser b/bin/agent-browser index e9239fe0..aaefaa67 100755 --- a/bin/agent-browser +++ b/bin/agent-browser @@ -15,7 +15,11 @@ ARCH=$(uname -m) case "$OS" in darwin) OS="darwin" ;; linux) OS="linux" ;; mingw*|msys*|cygwin*) OS="win32" ;; esac case "$ARCH" in x86_64|amd64) ARCH="x64" ;; aarch64|arm64) ARCH="arm64" ;; esac -BINARY="$SCRIPT_DIR/agent-browser-${OS}-${ARCH}" +# Add .exe extension for Windows binaries +EXT="" +case "$OS" in win32) EXT=".exe" ;; esac + +BINARY="$SCRIPT_DIR/agent-browser-${OS}-${ARCH}${EXT}" if [ -f "$BINARY" ] && [ -x "$BINARY" ]; then exec "$BINARY" "$@" diff --git a/bin/agent-browser.cmd b/bin/agent-browser.cmd index 58750e28..f76ffcdd 100644 --- a/bin/agent-browser.cmd +++ b/bin/agent-browser.cmd @@ -1,5 +1,26 @@ @echo off setlocal + +:: Detect architecture +set "ARCH=x64" +if "%PROCESSOR_ARCHITECTURE%"=="ARM64" set "ARCH=arm64" +if "%PROCESSOR_ARCHITECTURE%"=="x86" ( + if not defined PROCESSOR_ARCHITEW6432 set "ARCH=x86" +) + +:: Get script directory set "SCRIPT_DIR=%~dp0" -node "%SCRIPT_DIR%..\dist\index.js" %* + +:: Path to the Windows binary +set "BINARY=%SCRIPT_DIR%agent-browser-win32-%ARCH%.exe" + +:: Check if binary exists +if not exist "%BINARY%" ( + echo Error: agent-browser binary not found at %BINARY% >&2 + echo Run 'npm install' to download the binary, or 'npm run build:native' to build it locally. >&2 + exit /b 1 +) + +:: Run the binary with all arguments +"%BINARY%" %* exit /b %errorlevel%