libs/computer-use/README.md
This package provides a Computer Use plugin used by the Daytona Daemon to allow agents to control VNC desktop environments.
The ComputerUse package manages four main processes in the correct order:
To use the ComputerUse package, your Dockerfile must include the following VNC-related packages and setup:
# Prevent interactive prompts during package installation
ENV DEBIAN_FRONTEND=noninteractive
ENV DISPLAY=:1
ENV VNC_PORT=5901
ENV NO_VNC_PORT=6080
ENV VNC_RESOLUTION=1280x720
# Install VNC and desktop environment packages
RUN apt-get update && apt-get install -y \
wget \
git \
vim \
xfce4 \
xfce4-terminal \
dbus-x11 \
xfonts-base \
xfonts-100dpi \
xfonts-75dpi \
xfonts-scalable \
x11vnc \
novnc \
supervisor \
net-tools \
locales \
xvfb \
x11-utils \
x11-xserver-utils \
gnome-screenshot \
scrot \
imagemagick \
xdotool \
xautomation \
wmctrl \
build-essential \
libx11-dev \
libxext-dev \
libxtst-dev \
libxinerama-dev \
libx11-xcb-dev \
libxkbcommon-dev \
libxkbcommon-x11-dev \
libxcb-xkb-dev \
libpng-dev \
chromium \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Setup VNC
RUN mkdir -p /home/daytona/.vnc && \
chown -R daytona:daytona /home/daytona/.vnc
# NoVNC setup
RUN ln -sf /usr/share/novnc/vnc.html /usr/share/novnc/index.html && \
sed -i 's/websockify =/websockify = --heartbeat 30/' /usr/share/novnc/utils/launch.sh
The NoVNC launch script (/usr/share/novnc/utils/launch.sh) is used to start the web-based VNC client. The Dockerfile modifies this script to add heartbeat support:
# Add heartbeat to websockify for better connection stability
sed -i 's/websockify =/websockify = --heartbeat 30/' /usr/share/novnc/utils/launch.sh
This ensures that the WebSocket connection remains stable during long-running sessions.
The Dockerfile also installs several useful tools for VNC desktop interaction:
These tools are used by the toolbox API endpoints for desktop interaction.
The following environment variables should be set in your Dockerfile:
ENV DEBIAN_FRONTEND=noninteractive
ENV DISPLAY=:1
ENV VNC_PORT=5901
ENV NO_VNC_PORT=6080
ENV VNC_RESOLUTION=1280x720
Ensure you have a non-root user with proper permissions:
# Create the Daytona user and configure sudo access
RUN useradd -m daytona && echo "daytona ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/91-daytona
# Switch to the user for VNC operations
USER daytona
VNC_RESOLUTION: Set the VNC resolution (default: "1920x1080")VNC_PORT: VNC server port (default: 5901)NO_VNC_PORT: NoVNC web port (default: 6080)DISPLAY: X display (default: ":1")VNC_USER: User to run VNC processes (default: "daytona")The processes are configured with the following settings based on environment variables:
| Process | Command | Priority | Auto-restart | Log Files | Environment |
|---|---|---|---|---|---|
| xvfb | /usr/bin/Xvfb $DISPLAY -screen 0 $VNC_RESOLUTIONx24 | 100 | Yes | No | DISPLAY |
| xfce4 | /usr/bin/startxfce4 | 200 | Yes | Yes | DISPLAY, HOME, USER, DBUS_SESSION_BUS_ADDRESS |
| x11vnc | /usr/bin/x11vnc -display $DISPLAY -forever -shared -rfbport $VNC_PORT | 300 | Yes | No | DISPLAY |
| novnc | /usr/share/novnc/utils/launch.sh --vnc localhost:$VNC_PORT --listen $NO_VNC_PORT | 400 | Yes | No | DISPLAY |
Default Values:
DISPLAY: :1VNC_RESOLUTION: 1920x1080VNC_PORT: 5901NO_VNC_PORT: 6080VNC_USER: daytonaLog files are stored in ~/.daytona/computeruse/:
xfce4.log - Standard output from xfce4xfce4.err - Error output from xfce4The ComputerUse package is integrated into the toolbox server and provides HTTP endpoints for:
These endpoints are available under the /computer route group in the toolbox API.
The implementation includes comprehensive error handling:
All operations are thread-safe using appropriate mutexes:
sync.RWMutex for the main ComputerUse structsync.Mutex for individual Process structsThis allows safe concurrent access from multiple goroutines.