Sign inSign up

superbizon007/linux-gui-agent

By superbizon007

Updated 5 months ago

Linux GUI agent

Image
Machine learning & AI
0

943

superbizon007/linux-gui-agent repository overview

Linux GUI Agent

A Docker image that runs a full Xfce desktop with a VLM-powered GUI automation agent, exposed via A2A and OpenAI-compatible HTTPS APIs, and a noVNC browser viewer for visual debugging.

Implements an agent using the ReAct (Reasoning + Acting) pattern for intelligent desktop GUI automation.

Overview

The container bundles:

  • Xfce desktop — full graphical desktop running on TigerVNC (headless X11)
  • Chromium browser — pre-installed for web-based GUI tasks
  • VNC / noVNC — watch and interact with the desktop from a browser
  • Python agent server — FastAPI service that accepts tasks and autonomously controls the desktop using a Vision Language Model (VLM) via LangGraph

The agent observes the desktop through screenshots, reasons about the next action, and executes it — repeating until the task is complete or the step budget is exhausted.


Features

FeatureDetails
Desktop automationFull X11 control — click, double-click, drag, scroll, type, key combos, window management
VLM-driven agentAny OpenAI-compatible VLM (GPT-4o, Claude, Gemini, local models)
UI Locator modelOptional secondary model (UI-TARS) resolves natural-language element descriptions to pixel coordinates
Loop detectionWarns the VLM after 2 consecutive identical actions
SSE progress updatesPer-step status messages streamed to A2A clients (VLM call, decision, action execution)
A2A APIGoogle Agent-to-Agent JSON-RPC 2.0 protocol
OpenAI-compatible API/v1/chat/completions endpoint — drop-in for OpenAI clients
HTTPSSelf-signed TLS certificate generated at startup
Trajectory recordingSaves per-step screenshots, VLM requests/responses, and locator logs
Visual debuggingTigerVNC + noVNC web client for watching the agent live
FlatpakFlathub remote pre-configured; install GUI apps with flatpak install -y flathub <app-id>

Quick Start

Build
cd apps/linux_gui_agent
docker build \
  --build-context a2a_pkg=../../packages/a2a_agent \
  -f Dockerfile.ubuntu \
  -t linux_gui_agent:ubuntu .
Run
docker run -d \
  --name gui_agent \
  -p 443:443 \
  -p 6901:6901 \
  -p 5901:5901 \
  -e VLM_URL=https://api.openai.com/v1 \
  -e VLM_API_KEY=sk-... \
  -e VLM_MODEL=gpt-4o \
  linux_gui_agent:ubuntu --wait
Dev image (VNC only, no API server)

Build and run a desktop-only container for manually testing X11 tools:

docker build \
  --build-context a2a_pkg=../../packages/a2a_agent \
  -f Dockerfile.dev \
  -t linux_gui_agent:dev .

docker run -d \
  --name gui_agent_dev \
  -p 5901:5901 \
  -p 6901:6901 \
  -p 6001:6001 \
  linux_gui_agent:dev --wait
Access
ServiceURL / Address
Agent API (A2A + OpenAI)https://localhost/
noVNC web viewerhttp://localhost:6901/?password=vncpassword
VNC native clientlocalhost:5901 (password: vncpassword)
Trust the certificate (one-time)

The container generates a local CA on first start. Install it once and your browser will trust all future connections without warnings.

macOS:

curl -k https://localhost/ca.crt -o linux-gui-agent-ca.crt
sudo security add-trusted-cert -d -r trustRoot \
  -k /Library/Keychains/System.keychain linux-gui-agent-ca.crt

Linux (Debian/Ubuntu):

curl -k https://localhost/ca.crt -o /usr/local/share/ca-certificates/linux-gui-agent-ca.crt
sudo update-ca-certificates

Windows:

curl -k https://localhost/ca.crt -o linux-gui-agent-ca.crt
certutil -addstore Root linux-gui-agent-ca.crt

Chrome / Firefox (manual): download https://localhost/ca.crt then add it in Settings → Privacy and security → Manage certificates → Authorities → Import.


API

A2A — send a task
curl -sk -X POST https://localhost/ \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": "1",
    "method": "message/send",
    "params": {
      "message": {
        "role": "user",
        "messageId": "m1",
        "parts": [{"kind": "text", "text": "Open Chrome, go to example.com, and tell me the page title"}]
      }
    }
  }'
OpenAI-compatible
curl -sk -X POST https://localhost/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "desktop-agent",
    "messages": [{"role": "user", "content": "Open a terminal and run ls /"}]
  }'
Agent card
curl -sk https://localhost/.well-known/agent-card.json
Streaming (A2A)
curl -sk -N -X POST https://localhost/ \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": "1",
    "method": "message/stream",
    "params": {
      "message": {
        "role": "user",
        "messageId": "m1",
        "parts": [{"kind": "text", "text": "Take a screenshot and describe the desktop"}]
      }
    }
  }'

Environment Variables

Core
VariableDefaultDescription
VLM_URLhttps://api.openai.com/v1Base URL of the VLM API
VLM_API_KEYAPI key for the VLM
VLM_MODELgpt-4oModel name
API_KEYBearer token to protect the agent API (optional)
PORT443HTTPS port for the agent server
AGENT_URLPublic URL published in the AgentCard (e.g. https://my-agent.example.com/). Defaults to https://localhost:{PORT}/
DISPLAY:1X11 display used by the agent
VIEWPORT_WIDTH1920Desktop width in pixels
VIEWPORT_HEIGHT1080Desktop height in pixels
SEND_IMAGEtrueSet to false for text-only LLMs (disables screenshot in VLM prompt)
TRAJECTORY_DIRDirectory to save trajectory data; each run creates a YYYYMMDD_HHMMSS/ subdirectory
UI Locator model (optional)

The locator is a secondary vision model (e.g. UI-TARS) specialised in resolving natural-language element descriptions to exact pixel coordinates. When configured, the agent describes elements by name (query) instead of estimating x/y coordinates, and the locator finds the exact click target.

VariableDefaultDescription
LOCATOR_URLOpenAI-compatible API base URL for the locator model
LOCATOR_API_KEYBearer token for locator API auth (optional)
LOCATOR_MODELui-tarsModel name passed to the locator API
Container
VariableDefaultDescription
VNC_PWvncpasswordVNC password
VNC_RESOLUTION1920x1080Screen resolution

Pre-installed Applications

ApplicationCommandPurpose
Chromiumchromium-browser &Web browser (--no-sandbox included automatically)
xfce4-terminalxfce4-terminal &Terminal emulator
mousepadmousepad &Text editor
Thunarthunar &File manager
Evinceevince &PDF viewer
Ristrettoristretto &Image viewer
File-Rollerfile-roller &Archive manager
galculatorgalculator &Calculator

Package managers available: apt-get and flatpak (Flathub configured). snap is not available.


Trajectory Recording

When TRAJECTORY_DIR is set, each agent run creates a timestamped subdirectory containing one folder per step:

$TRAJECTORY_DIR/
  20260313_181523/              # run timestamp (YYYYMMDD_HHMMSS)
    summary.md                  # task, result, and final plan summary
    turn_0000/
      screenshot.png            # desktop state at start of step
      llm_0_request.json        # messages sent to the VLM
      llm_0_response.json       # raw VLM reply + parsed action/args/reasoning
      locator.json              # locator model request + response (when LOCATOR_URL is set)
    turn_0001/
      ...
  20260313_182041/              # next run
    ...

Example:

docker run -d \
  -e VLM_URL=... -e VLM_API_KEY=... \
  -e TRAJECTORY_DIR=/data/trajectory \
  -v /tmp/agent-logs:/data/trajectory \
  linux_gui_agent:ubuntu --wait

Agent Tools

ToolDescription
screenshotFull-screen JPEG screenshot (base64) — taken automatically at every step
mouse_clickClick at (x, y) with left/right/middle button
mouse_double_clickDouble-click at (x, y)
mouse_moveMove mouse to (x, y) (hover)
mouse_scrollScroll at (x, y); positive scroll_y = down, negative = up
key_pressPress a key or modifier combo: Return, Escape, ctrl+c, alt+F4, etc.
type_textType Unicode text into the currently focused element
dragClick-drag from (x1, y1) to (x2, y2)
get_windowsList all open windows with id, title, position, and size
focus_windowBring a window to front by window id
run_commandRun a shell command in the desktop session (360 s timeout; background GUI apps with &)
get_cursor_posReturn the current mouse cursor position

Architecture

┌──────────────────────────────────────────────┐
│               Docker Container               │
│                                              │
│  Xfce desktop (DISPLAY :1)                  │
│    Chromium browser                          │
│    xfce4-terminal, mousepad, evince          │
│    flatpak + Flathub                         │
│         │                                    │
│  X11Client (python-xlib + wmctrl + xdotool)  │
│                                              │
│  LangGraph (graph.py)                        │
│    screenshot ──► X11Client.screenshot()     │
│    call_vlm   ──► VLM (OpenAI-compatible)    │
│    execute_action                            │
│       │   Locator model (optional)           │
│    generate_summary                          │
│         │                                    │
│  TigerVNC (:5901) + noVNC (:6901)           │
│                                              │
│  FastAPI Server (:443 HTTPS)                 │
│    ├── A2A router  (POST /)                  │
│    └── OpenAI router (/v1/...)               │
└──────────────────────────────────────────────┘

License

MIT

MCP tools

The agent image exposes an MCP (Model Context Protocol) server on the same port as A2A at /mcp. Any MCP client — Claude Desktop, Cursor, Windsurf, ChatGPT Connectors, OpenAI Agents SDK — can list and invoke these tools using the pod's API_KEY as Bearer.

In production, Core proxies https://linux-gui-agent.agents.forfetch.ai/mcp → the worker pod's /mcp.

Tool (skill_id)Description
take_screenshotTake a screenshot of the desktop
clickClick at coordinates or on an element
double_clickDouble-click at coordinates or on an element
typeType text using keyboard input
scrollScroll using the mouse wheel
key_pressPress a keyboard key or key combination
mouse_moveMove the mouse cursor to coordinates

Input schemas are authored in apps/agents_mcp/app/seed.py. Skills without an explicit schema advertise a single {task: str} freeform parameter.

Tag summary

Content type

Image

Digest

sha256:a9195f69a

Size

803.8 MB

Last updated

5 months ago

docker pull superbizon007/linux-gui-agent