🚀 Camoufox default web engine — auto-install + auto-start

Full integration:
- install.sh now installs camoufox-browser via npm (preferred) or Docker
- install.sh creates systemd/launchd auto-start service on Linux/macOS
- New browser_manager.rs — health-check, auto-start, wait-for-ready
- AgentLoop::run() auto-inits Camoufox and registers web_search/web_browse
- System prompt tells LLM to use web_search/web_browse as PRIMARY tools
- Graceful fallback: if Camoufox unavailable, logs warning, uses bash tools
- ToolExecutor is now Arc<Mutex<>> for runtime tool registration

GyanDoot v2 now: install → Camoufox auto-starts → web tools available →
"search NSE India" uses Camoufox with anti-detection 🎯
This commit is contained in:
2026-06-11 23:12:57 +05:30
parent 59ef28ffab
commit f2d612bd28
6 changed files with 369 additions and 203 deletions

View File

@@ -61,72 +61,99 @@ install_node_if_needed() {
}
install_camofox_browser() {
local root_dir
root_dir="$(cd "$(dirname "$0")" && pwd)"
local camofox_dir="${CAMOFOX_DIR:-$HOME/camofox-browser}"
if [ -d "$camofox_dir" ] && [ -f "$camofox_dir/package.json" ]; then
info "Camofox-browser already cloned. Updating..."
cd "$camofox_dir" && git pull --ff-only 2>/dev/null || true
cd "$root_dir"
info "Installing camofox-browser (anti-detection browser)..."
if command -v npx &>/dev/null; then
info "Installing via npm..."
npm install -g camoufox-browser 2>&1 | tail -5
npx camoufox-browser@latest install 2>&1 | tail -5
ok "Camoufox browser installed (npx camoufox-browser start)"
elif command -v docker &>/dev/null; then
info "Installing via Docker..."
docker run -d --name camoufox -p 9377:9377 \
-e CAMOUFOX_WS_PORT=9377 \
--restart unless-stopped \
ghcr.io/nousresearch/camoufox-browser:latest 2>&1 | tail -3
ok "Camoufox browser installed (Docker)"
else
info "Cloning camofox-browser..."
git clone https://github.com/jo-inc/camofox-browser.git "$camofox_dir"
info "Installing camofox-browser dependencies..."
cd "$camofox_dir"
npm install --ignore-scripts 2>&1 | tail -3
cd "$root_dir"
warn "Neither npm nor docker found. Install manually: npm install -g camoufox-browser"
fi
ok "Camofox-browser ready"
}
setup_camofox_service() {
local os
os=$(detect_os)
info "Setting up camofox-browser as a background service..."
info "Setting up camofox-browser to auto-start..."
case "$os" in
linux)
# Create systemd service
local service_file="/etc/systemd/system/camofox-browser.service"
if [ ! -f "$service_file" ]; then
cat > /tmp/camofox-browser.service << 'SYSTEMD'
[Unit]
Description=Camofox Browser — Anti-detection browser server for AI agents
Description=Camofox Browser — Anti-detection browser for AI agents
After=network.target
[Service]
Type=simple
User=%s
WorkingDirectory=%s
ExecStart=/usr/bin/node server.js
ExecStart=npx camoufox-browser start --port 9377
Restart=on-failure
RestartSec=5
Environment=NODE_ENV=production
Environment=PORT=9377
[Install]
WantedBy=multi-user.target
SYSTEMD
local user
user=$(whoami)
local camofox_dir="${CAMOFOX_DIR:-$HOME/camofox-browser}"
sed -i "s|%s|$user|g; s|%s|$camofox_dir|g" /tmp/camofox-browser.service
sudo mv /tmp/camofox-browser.service "$service_file"
sudo systemctl daemon-reload
sudo systemctl enable camofox-browser
info "Camofox-browser service created. Start with: sudo systemctl start camofox-browser"
sudo systemctl start camofox-browser
ok "Camoufox auto-start service installed and started"
else
ok "Camofox-browser service already exists"
sudo systemctl start camofox-browser 2>/dev/null || true
ok "Camoufox service already exists"
fi
;;
darwin)
info "macOS detected. Add 'cd $HOME/camofox-browser && npm start' to your startup items."
;;
windows)
info "Windows detected. Use 'npm start' in the camofox-browser directory."
# macOS: create a launchd plist for auto-start
local plist="$HOME/Library/LaunchAgents/com.camoufox.browser.plist"
if [ ! -f "$plist" ]; then
mkdir -p "$HOME/Library/LaunchAgents"
local home_dir="$HOME"
cat > "$plist" << LAUNCHD
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.camoufox.browser</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/npx</string>
<string>camoufox-browser</string>
<string>start</string>
<string>--port</string>
<string>9377</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>StandardOutPath</key>
<string>${home_dir}/.gyandoot/camoufox.log</string>
<key>StandardErrorPath</key>
<string>${home_dir}/.gyandoot/camoufox.log</string>
</dict>
</plist>
LAUNCHD
launchctl load "$plist"
ok "Camoufox auto-start configured (launchd)"
else
launchctl load "$plist" 2>/dev/null || true
ok "Camoufox launchd plist already exists"
fi
;;
esac
ok "Camofox-browser setup complete"
ok "Camofox-browser auto-start setup complete"
}
build_release() {