Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DockerfileLocal
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ EXPOSE 22 80 9000-9009
RUN chmod +x /exe/initialize.sh /exe/run_A0.sh /exe/run_searxng.sh /exe/run_tunnel_api.sh

# initialize runtime and switch to supervisord
CMD ["/exe/initialize.sh", "$BRANCH"]
CMD ["/exe/initialize.sh", "$BRANCH"]
16 changes: 6 additions & 10 deletions agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ class AgentConfig:
chat_model: models.ModelConfig
utility_model: models.ModelConfig
embeddings_model: models.ModelConfig
browser_model: models.ModelConfig
mcp_servers: str
profile: str = ""
memory_subdir: str = ""
Expand All @@ -287,7 +286,12 @@ class AgentConfig:
code_exec_ssh_user: str = "root"
code_exec_ssh_pass: str = ""
additional: Dict[str, Any] = field(default_factory=dict)

browser_control_headless: bool = False # Browser GUI enabled for interaction (uses VNC if available, otherwise X11 forwarding)
browser_control_cdp_url: str = "" # Chrome DevTools Protocol URL for native browser (e.g., "ws://host.docker.internal:9222/devtools/browser/..."), leave empty to use embedded browser with VNC
browser_control_start_url: str = "https://www.google.com"
browser_control_timeout: int = 5000 # milliseconds
# VNC is automatically enabled if available (configured in docker-compose.yml)
# Access browser control via noVNC when agent calls pause_for_user method

@dataclass
class UserMessage:
Expand Down Expand Up @@ -676,14 +680,6 @@ def get_utility_model(self):
**self.config.utility_model.build_kwargs(),
)

def get_browser_model(self):
return models.get_browser_model(
self.config.browser_model.provider,
self.config.browser_model.name,
model_config=self.config.browser_model,
**self.config.browser_model.build_kwargs(),
)

def get_embedding_model(self):
return models.get_embedding_model(
self.config.embeddings_model.provider,
Expand Down
6 changes: 6 additions & 0 deletions docker/base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ RUN bash /ins/install_base_packages4.sh
# install python after packages to ensure version overriding
RUN bash /ins/install_python.sh

# install X11 support for browser display
RUN bash /ins/install_x11_support.sh

# install VNC server and noVNC for remote browser control
RUN bash /ins/install_vnc.sh

# install searxng
RUN bash /ins/install_searxng.sh

Expand Down
51 changes: 48 additions & 3 deletions docker/run/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,53 @@
services:
agent-zero:
container_name: agent-zero
image: agent0ai/agent-zero:latest
# Use local development image (build with: docker build -f DockerfileLocal -t agent-zero-local --build-arg CACHE_DATE=$(date +%Y-%m-%d:%H:%M:%S) .)
image: agent-zero-local
# Use Docker Hub image for production deployments
# image: agent0ai/agent-zero:latest
volumes:
- ./agent-zero:/a0
# Mount the actual project root (not the outdated copy in ./agent-zero)
# This allows live development - changes reflected immediately without rebuild
- ../..:/a0
# X11 socket for GUI display on macOS (auto-configured)
- /tmp/.X11-unix:/tmp/.X11-unix:rw
ports:
- "50080:80"
- "55022:22"
- "50080:80"
- "56080:6080" # noVNC web client for browser control
- "50090:9000"
- "50091:9001"
- "50092:9002"
- "50093:9003"
- "50094:9004"
- "50095:9005"
- "50096:9006"
- "50097:9007"
- "50098:9008"
- "50099:9009"
environment:
# X11 display forwarding via TCP (Docker Desktop on macOS uses VM)
- DISPLAY=host.docker.internal:0
- XAUTHORITY=/tmp/.Xauthority
# VNC configuration for remote browser control
- VNC_DISPLAY=:99
- VNC_RESOLUTION=1920x1080x24
- VNC_PORT=5900
- NOVNC_PORT=6080
- NOVNC_EXTERNAL_PORT=56080 # External port mapping for noVNC access
- VNC_PASSWORD=agent-zero
# Allow container to reach host for X11
extra_hosts:
- "host.docker.internal:host-gateway"
# Security options for X11
security_opt:
- seccomp:unconfined
# Shared memory for browser (required for Chromium)
shm_size: '2gb'
# Auto-check and setup display and VNC on startup
command: >
bash -c "
/exe/check_display.sh || true &&
/exe/start_vnc.sh || true &&
/exe/initialize.sh development
"
13 changes: 13 additions & 0 deletions docker/run/fs/etc/supervisor/conf.d/vnc.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[program:run_vnc]
command=/exe/start_vnc.sh
environment=
user=root
stopwaitsecs=10
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
autorestart=true
startretries=3
stopasgroup=true
killasgroup=true
82 changes: 82 additions & 0 deletions docker/run/fs/exe/check_display.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/bin/bash
# Automatic X11 display setup checker
# Runs on container startup to verify display forwarding
# No user interaction required - fully automatic

set -e

echo "========================================"
echo "Agent Zero - Display Setup Check"
echo "========================================"

# Detect if running on macOS host
IS_MACOS=false
if [ -f /tmp/.X11-unix ] || [ "$DISPLAY" = "host.docker.internal:0" ]; then
IS_MACOS=true
fi

# Check if DISPLAY is set
if [ -z "$DISPLAY" ]; then
echo "⚠️ No display configured (headless mode)"
echo " Browser will run in headless mode (invisible)"
echo ""
echo "To enable visible browser on macOS:"
echo " 1. Install XQuartz: https://www.xquartz.org/"
echo " 2. Start XQuartz and restart Agent Zero"
exit 0
fi

# Display is configured - verify X11 libraries
echo "✓ Display configured: $DISPLAY"

# Check if X11 libraries are installed
if ! dpkg -l | grep -q libx11-6; then
echo "Installing X11 libraries for browser display..."
apt-get update -qq
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq \
libx11-6 libxcb1 libxcomposite1 libxcursor1 libxdamage1 \
libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 \
libxtst6 libgbm1 libasound2 libatk1.0-0 libatk-bridge2.0-0 \
libcups2 libdrm2 libgtk-3-0 libnspr4 libnss3 \
2>&1 | grep -v "^Reading" | grep -v "^Building" || true
fi

echo "✓ X11 libraries installed"

# Test X11 connection
if [ "$IS_MACOS" = true ]; then
echo "Testing X11 connection to macOS host..."

# Try to connect to X11
timeout 2 xdpyinfo -display "$DISPLAY" > /dev/null 2>&1 && {
echo "✓ X11 connection successful"
echo "✓ Browser will appear on your screen"
exit 0
} || {
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "⚠️ Cannot connect to X11 display"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "To see the browser window, you need XQuartz:"
echo ""
echo " 1. Download and install XQuartz:"
echo " https://www.xquartz.org/"
echo ""
echo " 2. Log out and log back in (required!)"
echo ""
echo " 3. Allow Docker connections:"
echo " xhost +localhost"
echo ""
echo " 4. Restart Agent Zero:"
echo " cd docker/run && docker-compose restart"
echo ""
echo "For now, browser will run in headless mode."
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
exit 0
}
fi

echo "✓ Display setup complete"
echo "========================================"
3 changes: 3 additions & 0 deletions docker/run/fs/exe/initialize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@ chmod 444 /root/.profile
# update package list to save time later
apt-get update > /dev/null 2>&1 &

# Start VNC server in the background (for browser control feature)
/exe/start_vnc.sh > /tmp/vnc_startup.log 2>&1 &

# let supervisord handle the services
exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
Loading