-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·81 lines (69 loc) · 2.55 KB
/
install.sh
File metadata and controls
executable file
·81 lines (69 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
# SPDX-License-Identifier: GPL-3.0-only
# Copyright (c) 2026 Marcus Krueger
set -euo pipefail
VERSION="${VERSION:-latest}"
USERNAME="${USERNAME:-automatic}"
# Skip installation if version is "none"
if [ "${VERSION}" = "none" ]; then
echo "[agent-browser] Skipping installation (version=none)"
exit 0
fi
# Set headless as default for containers (bundled Chromium, no display needed)
export AGENT_BROWSER_HEADLESS=true
echo "[agent-browser] Starting installation..."
echo "[agent-browser] Version: ${VERSION}"
# Source nvm if available
if [ -f /usr/local/share/nvm/nvm.sh ]; then
source /usr/local/share/nvm/nvm.sh
fi
# Validate npm is available
if ! command -v npm &>/dev/null; then
echo "[agent-browser] ERROR: npm not available"
echo " Ensure node feature is installed first"
exit 1
fi
# Detect user
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
if [ -n "${_REMOTE_USER:-}" ]; then
USERNAME="${_REMOTE_USER}"
elif getent passwd vscode >/dev/null 2>&1; then
USERNAME="vscode"
elif getent passwd node >/dev/null 2>&1; then
USERNAME="node"
elif getent passwd codespace >/dev/null 2>&1; then
USERNAME="codespace"
else
USERNAME="root"
fi
fi
echo "[agent-browser] Installing for user: ${USERNAME}"
# Install via npm
if [ "${VERSION}" = "latest" ]; then
NPM_PACKAGE="agent-browser"
else
NPM_PACKAGE="agent-browser@${VERSION}"
fi
npm install -g "${NPM_PACKAGE}" 2>/dev/null || {
echo "[agent-browser] WARNING: Global install failed, trying user install"
su - "${USERNAME}" -c "npm install -g ${NPM_PACKAGE}" 2>/dev/null || true
}
npm cache clean --force 2>/dev/null || true
# Download Chromium and install system dependencies
echo "[agent-browser] Installing Chromium and system dependencies..."
agent-browser install --with-deps 2>/dev/null || {
echo "[agent-browser] WARNING: Chromium install with deps failed, trying without --with-deps"
agent-browser install 2>/dev/null || true
}
echo "[agent-browser] Installed: $(agent-browser --version 2>/dev/null || echo 'unknown')"
echo "[agent-browser] Installation complete"
echo ""
echo "Usage:"
echo " agent-browser open <url> # Open a page"
echo " agent-browser snapshot # Get accessibility tree"
echo " agent-browser screenshot # Capture screenshot"
echo " agent-browser close # Close browser"
echo ""
echo "Host Chrome connection (if container browser insufficient):"
echo " # Start Chrome on host with: chrome --remote-debugging-port=9222"
echo " agent-browser connect 9222"