This commit is contained in:
Chris Tate
2026-01-11 04:24:44 -06:00
parent 83bcb6be73
commit e36d03c8d9
4 changed files with 536 additions and 157 deletions
+4 -25
View File
@@ -1,40 +1,19 @@
#!/bin/sh
# agent-browser CLI wrapper
# Tries native binary first, falls back to Node.js
# Resolve symlinks to find real script location
SCRIPT="$0"
while [ -L "$SCRIPT" ]; do
SCRIPT_DIR="$(cd "$(dirname "$SCRIPT")" && pwd)"
SCRIPT="$(readlink "$SCRIPT")"
# Handle relative symlinks
case "$SCRIPT" in
/*) ;;
*) SCRIPT="$SCRIPT_DIR/$SCRIPT" ;;
esac
case "$SCRIPT" in /*) ;; *) SCRIPT="$SCRIPT_DIR/$SCRIPT" ;; esac
done
SCRIPT_DIR="$(cd "$(dirname "$SCRIPT")" && pwd)"
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
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
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}"
# Try native binary if it exists
if [ -f "$BINARY" ] && [ -x "$BINARY" ]; then
exec "$BINARY" "$@"
fi
# Fall back to Node.js
[ -f "$BINARY" ] && [ -x "$BINARY" ] && exec "$BINARY" "$@"
exec node "$SCRIPT_DIR/../dist/index.js" "$@"
+2 -22
View File
@@ -1,28 +1,8 @@
@echo off
:: agent-browser CLI wrapper for Windows
:: Tries native binary first, falls back to Node.js
setlocal
set "SCRIPT_DIR=%~dp0"
:: Detect architecture
if "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
set "ARCH=x64"
) else if "%PROCESSOR_ARCHITECTURE%"=="ARM64" (
set "ARCH=arm64"
) else (
set "ARCH=x64"
)
if "%PROCESSOR_ARCHITECTURE%"=="AMD64" (set "ARCH=x64") else if "%PROCESSOR_ARCHITECTURE%"=="ARM64" (set "ARCH=arm64") else (set "ARCH=x64")
set "BINARY=%SCRIPT_DIR%agent-browser-win32-%ARCH%.exe"
:: Try native binary first
if exist "%BINARY%" (
"%BINARY%" %*
exit /b %errorlevel%
)
:: Fall back to Node.js
if exist "%BINARY%" ("%BINARY%" %* & exit /b %errorlevel%)
node "%SCRIPT_DIR%..\dist\index.js" %*
exit /b %errorlevel%