Skip to content

The agent that grows with you

Publish nousresearch/hermes-sandbox:desktop, the terminal-backend sandbox image with a display stack (#121110)

Teknium188a1a5efd09
diff --git a/.github/workflows/docker-lint.yml b/.github/workflows/docker-lint.yml
index 05297c93b75..a6df6563ed3 100644
--- a/.github/workflows/docker-lint.yml
+++ b/.github/workflows/docker-lint.yml
@@ -36,6 +36,13 @@ jobs:
config: .hadolint.yaml
failure-threshold: warning
+ - name: hadolint (sandbox desktop image)
+ uses: hadolint/hadolint-action@54c9adbab1582c2ef04b2016b760714a4bfde3cf # v3.1.0
+ with:
+ dockerfile: docker/sandbox-desktop.Dockerfile
+ config: .hadolint.yaml
+ failure-threshold: warning
+
shellcheck:
name: Lint docker/ shell scripts (shellcheck)
runs-on: ubuntu-latest
diff --git a/.github/workflows/sandbox-image.yml b/.github/workflows/sandbox-image.yml
new file mode 100644
index 00000000000..5d7cebc0d75
--- /dev/null
+++ b/.github/workflows/sandbox-image.yml
@@ -0,0 +1,183 @@
+name: Sandbox desktop image
+
+# nousresearch/hermes-sandbox:desktop is the terminal-backend sandbox base
+# (nikolaik/python-nodejs) plus a display stack; Bot Screen, computer_use and
+# the bot's browser run inside it when terminal.backend is docker/ssh/etc.
+# It contains NO Hermes code, so it does not need to track main: it changes
+# when its Dockerfile changes, not when the agent changes.
+#
+# Triggers: a PR that edits the Dockerfile/smoke (build + smoke, no push),
+# a release (publish :<tag>-desktop and roll :desktop), and manual dispatch.
+# Deliberately NOT on every main push: two 4 GB multi-arch builds per commit
+# for an image that changes a few times a year.
+
+on:
+ pull_request:
+ paths:
+ - docker/sandbox-desktop.Dockerfile
+ - docker/sandbox-desktop-smoke.sh
+ - .github/workflows/sandbox-image.yml
+ release:
+ types: [published]
+ workflow_dispatch:
+ inputs:
+ publish:
+ description: Push to Docker Hub (rolls :desktop)
+ type: boolean
+ default: false
+
+permissions:
+ contents: read
+
+concurrency:
+ group: sandbox-image-${{ github.event.pull_request.number || github.ref }}
+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}
+
+env:
+ IMAGE_NAME: nousresearch/hermes-sandbox
+
+jobs:
+ # PR code: secret-free build + smoke per arch.
+ build:
+ if: github.repository == 'NousResearch/hermes-agent'
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - arch: amd64
+ runner: ubuntu-latest-32-core
+ platform: linux/amd64
+ - arch: arm64
+ runner: ubuntu-latest-32-arm-core
+ platform: linux/arm64
+ runs-on: ${{ matrix.runner }}
+ timeout-minutes: 45
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
+
+ - name: Build (${{ matrix.arch }})
+ uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
+ with:
+ context: .
+ file: docker/sandbox-desktop.Dockerfile
+ platforms: ${{ matrix.platform }}
+ tags: ${{ env.IMAGE_NAME }}:test
+ load: true
+ cache-from: type=gha,scope=sandbox-${{ matrix.arch }}
+ cache-to: ${{ github.event_name != 'pull_request' && format('type=gha,mode=max,scope=sandbox-{0}', matrix.arch) || '' }}
+
+ # The contract: the launcher, cua-driver and a headed Chromium work as `pn`.
+ - name: Smoke
+ run: docker/sandbox-desktop-smoke.sh ${{ env.IMAGE_NAME }}:test
+
+ # Trusted source only; the sole Docker Hub credential boundary.
+ publish:
+ if: github.repository == 'NousResearch/hermes-agent' && (github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.publish))
+ needs: [build]
+ environment: container-publish
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - arch: amd64
+ runner: ubuntu-latest-32-core
+ platform: linux/amd64
+ - arch: arm64
+ runner: ubuntu-latest-32-arm-core
+ platform: linux/arm64
+ runs-on: ${{ matrix.runner }}
+ timeout-minutes: 30
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
+
+ - name: Log in to Docker Hub
+ uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
+ with:
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+ - name: Push ${{ matrix.arch }} by digest
+ id: push
+ uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
+ with:
+ context: .
+ file: docker/sandbox-desktop.Dockerfile
+ platforms: ${{ matrix.platform }}
+ labels: |
+ org.opencontainers.image.revision=${{ github.sha }}
+ outputs: type=image,name=${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
+ cache-from: type=gha,scope=sandbox-${{ matrix.arch }}
+
+ - name: Export digest
+ run: |
+ mkdir -p "$RUNNER_TEMP/digests"
+ digest="${{ steps.push.outputs.digest }}"
+ touch "$RUNNER_TEMP/digests/${digest#sha256:}"
+
+ - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
+ with:
+ name: sandbox-digest-${{ matrix.arch }}
+ path: ${{ runner.temp }}/digests/*
+ if-no-files-found: error
+ retention-days: 1
+
+ # Registry-side stitch of the two digests into one tagged manifest list.
+ merge:
+ if: ${{ !cancelled() && github.repository == 'NousResearch/hermes-agent' && (github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.publish)) }}
+ needs: [publish]
+ runs-on: ubuntu-latest
+ timeout-minutes: 10
+ environment: container-publish
+ steps:
+ - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
+ with:
+ path: ${{ runner.temp }}/digests
+ pattern: sandbox-digest-*
+ merge-multiple: true
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
+
+ - name: Log in to Docker Hub
+ uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
+ with:
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+ - name: Create manifest list and push
+ working-directory: ${{ runner.temp }}/digests
+ env:
+ RELEASE_TAG: ${{ github.event.release.tag_name }}
+ run: |
+ set -euo pipefail
+ shopt -s nullglob
+ args=()
+ for digest_file in *; do
+ args+=("${IMAGE_NAME}@sha256:${digest_file}")
+ done
+ if [ "${#args[@]}" -ne 2 ]; then
+ echo "::error::want 2 digests, found ${#args[@]} (a publish leg failed)"
+ exit 1
+ fi
+ # :desktop is the stable tag docker_image points at; releases also get a pinned tag.
+ tags=(-t "${IMAGE_NAME}:desktop")
+ if [ -n "${RELEASE_TAG}" ]; then
+ tags+=(-t "${IMAGE_NAME}:${RELEASE_TAG}-desktop")
+ fi
+ for i in 1 2 3; do
+ if docker buildx imagetools create "${tags[@]}" "${args[@]}"; then
+ break
+ fi
+ if [ "$i" = 3 ]; then
+ echo "::error::imagetools create failed after 3 attempts"
+ exit 1
+ fi
+ sleep 10
+ done
+ docker buildx imagetools inspect "${IMAGE_NAME}:desktop"
diff --git a/docker/sandbox-desktop-smoke.sh b/docker/sandbox-desktop-smoke.sh
new file mode 100755
index 00000000000..df2011e1eb5
--- /dev/null
+++ b/docker/sandbox-desktop-smoke.sh
@@ -0,0 +1,97 @@
+#!/usr/bin/env bash
+# Smoke test for the sandbox desktop image: what a terminal backend needs from it.
+#
+# docker/sandbox-desktop-smoke.sh <image>
+#
+# Proves, as the unprivileged `pn` user the gateway will exec desktop processes as:
+# 1. every binary tools/bot_desktop/launcher.sh and computer_use look for exists
+# 2. the real launcher.sh brings up Xvnc + Xfce and publishes its env file
+# 3. the RFB socket answers the protocol handshake when relayed over `docker exec -i`
+# stdio, which is exactly how the gateway bridge will reach it
+# 4. headed Chromium starts on that display (cua-driver and agent-browser both need it)
+set -euo pipefail
+
+IMAGE="${1:?usage: sandbox-desktop-smoke.sh <image>}"
+HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
+NAME="sbx-smoke-$$"
+cleanup() { docker rm -f "$NAME" >/dev/null 2>&1 || true; }
+trap cleanup EXIT
+
+docker run -d --name "$NAME" --memory=4g "$IMAGE" >/dev/null
+
+echo "== 1. binaries (as pn)"
+docker exec -u pn "$NAME" bash -c '
+ set -e
+ for b in Xvnc xfwm4 xfce4-panel xfdesktop xfsettingsd dbus-run-session xauth xdpyinfo xprop \
+ xfce4-terminal cua-driver agent-browser jq rg fd tmux rsync sudo python3 node; do
+ command -v "$b" >/dev/null || { echo "missing: $b"; exit 1; }
+ done
+ cua-driver --version
+ agent-browser --version
+ ls /opt/playwright/chromium-*/chrome-linux*/chrome >/dev/null || { echo "missing headed chromium"; exit 1; }
+ python3 -c "from PIL import ImageGrab" # the Screen pane thumbnail is grabbed inside the sandbox
+ # an ssh login session (pam_env) must find the browser the way docker exec does
+ env -i bash -c ". <(sed s/^/export\\ / /etc/environment); [ \"\$PLAYWRIGHT_BROWSERS_PATH\" = /opt/playwright ]"
+ sudo -n true
+ [ "$(id -u)" = 1000 ]'
+
+echo "== 2. launcher.sh publishes a display"
+docker cp "$HERE/tools/bot_desktop/launcher.sh" "$NAME:/tmp/launcher.sh"
+docker cp "$HERE/tools/bot_desktop/wallpaper.png" "$NAME:/tmp/wallpaper.png"
+docker exec -u pn -d "$NAME" bash -c '
+ mkdir -p /tmp/bd && HERMES_BD_PROFILE=smoke HERMES_BD_DISPLAY_NUM=20 HERMES_BD_SOCKET=/tmp/bd/rfb.sock \
+ HERMES_BD_XAUTH=/tmp/bd/Xauthority HERMES_BD_ENV_FILE=/tmp/bd/env HERMES_BD_CONFIG_HOME=/tmp/bd/xdg \
+ HERMES_BD_WALLPAPER=/tmp/wallpaper.png bash /tmp/launcher.sh >/tmp/bd/launcher.log 2>&1'
+for _ in $(seq 1 60); do
+ docker exec -u pn "$NAME" test -S /tmp/bd/rfb.sock -a -f /tmp/bd/env 2>/dev/null && break
+ sleep 0.5
+done
+docker exec -u pn "$NAME" bash -c '
+ set -e
+ grep -q "^DISPLAY=:20$" /tmp/bd/env
+ [ "$(pgrep -c -f "xfwm4|xfce4-panel|xfdesktop")" -ge 3 ]' || { docker exec "$NAME" cat /tmp/bd/launcher.log; exit 1; }
+
+echo "== 3. RFB handshake over docker exec -i stdio"
+python3 - "$NAME" <<'EOF'
+import subprocess, sys
+relay = ("import socket,os,threading\n"
+ "s=socket.socket(socket.AF_UNIX);s.connect('/tmp/bd/rfb.sock')\n"
+ "def up():\n"
+ " while True:\n"
+ " d=os.read(0,65536)\n"
+ " if not d: break\n"
+ " s.sendall(d)\n"
+ "threading.Thread(target=up,daemon=True).start()\n"
+ "while True:\n"
+ " d=s.recv(65536)\n"
+ " if not d: break\n"
+ " os.write(1,d)\n")
+p = subprocess.Popen(["docker", "exec", "-i", "-u", "pn", sys.argv[1], "python3", "-c", relay],
+ stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+banner = p.stdout.read(12)
+assert banner == b"RFB 003.008\n", banner
+p.stdin.write(b"RFB 003.008\n"); p.stdin.flush()
+n = p.stdout.read(1)[0]
+types = list(p.stdout.read(n))
+assert 1 in types, types # None: the bridge authenticates, Xvnc trusts its 0600 socket
+p.kill()
+print(" RFB 3.8, security types", types)
+EOF
+
+echo "== 4. headed Chromium opens on the display"
+# Docker's default seccomp profile denies unprivileged user namespaces, so Chromium's own
+# layer-2 sandbox cannot start in any container; the container is the sandbox. The gateway's
+# spawn sites already inject this (browser_tool_session._needs_chromium_sandbox_bypass).
+docker exec -u pn "$NAME" bash -c '
+ set -e; set -a; . /tmp/bd/env; set +a
+ chrome=$(ls /opt/playwright/chromium-*/chrome-linux*/chrome | head -1)
+ timeout 40 "$chrome" --no-sandbox --disable-dev-shm-usage --no-first-run --disable-gpu \
+ --user-data-dir=/tmp/bd/chrome about:blank >/tmp/bd/chrome.log 2>&1 &
+ for _ in $(seq 1 60); do
+ for w in $(xprop -root _NET_CLIENT_LIST 2>/dev/null | grep -o "0x[0-9a-f]*"); do
+ xprop -id "$w" WM_CLASS 2>/dev/null | grep -qi chrom && exit 0
+ done
+ sleep 0.5
+ done
+ cat /tmp/bd/chrome.log; exit 1'
+echo "OK: $IMAGE"
diff --git a/docker/sandbox-desktop.Dockerfile b/docker/sandbox-desktop.Dockerfile
new file mode 100644
index 00000000000..b8225b1c827
--- /dev/null
+++ b/docker/sandbox-desktop.Dockerfile
@@ -0,0 +1,94 @@
+# Terminal-backend sandbox image WITH a desktop: the default sandbox base every
+# docker/modal/daytona/singularity user already runs (nikolaik/python-nodejs), plus
+# the tools that base was missing, plus the same display stack the -desktop Hermes
+# image carries (TigerVNC + Xfce components + headed Chromium) and cua-driver, so
+# Bot Screen, computer_use and the browser can live INSIDE the sandbox instead of
+# on the gateway host. No Hermes runtime in here; the gateway shells in.
+#
+# docker build -f docker/sandbox-desktop.Dockerfile -t nousresearch/hermes-sandbox:desktop .
+#
+# Published as nousresearch/hermes-sandbox:desktop by .github/workflows/sandbox-image.yml
+# on releases and manual dispatch only: it carries no Hermes code, so it does not track main.
+# The tag lives in the ARG so CI and a local build read one place; hadolint cannot
+# see through the substitution, hence the inline ignore.
+ARG SANDBOX_BASE=nikolaik/python-nodejs:python3.13-nodejs26
+# hadolint ignore=DL3006
+FROM ${SANDBOX_BASE}
+SHELL ["/bin/bash", "-euo", "pipefail", "-c"]
+
+ARG CUA_DRIVER_VERSION=0.28.2
+ARG TARGETARCH
+
+ENV DEBIAN_FRONTEND=noninteractive \
+ PLAYWRIGHT_BROWSERS_PATH=/opt/playwright \
+ LANG=C.UTF-8
+
+# Everyday tools the nikolaik base lacks (checked 2026-09: no jq, rg, fd, tmux,
+# less, vim/nano, zip, rsync, tree, procps beyond ps). Kept to what agents reach
+# for from a shell; language toolchains come from the base.
+RUN apt-get -o Acquire::Retries=3 update && \
+ apt-get -o Acquire::Retries=3 install -y --no-install-recommends \
+ jq ripgrep fd-find tmux less nano vim-tiny zip rsync tree procps htop \
+ file bsdextrautils ca-certificates locales sudo && \
+ ln -sf /usr/bin/fdfind /usr/local/bin/fd && \
+ rm -rf /var/lib/apt/lists/*
+
+# Display stack: identical package set to the Hermes -desktop image (Dockerfile,
+# HERMES_BOT_DESKTOP=1) so tools/bot_desktop/launcher.sh finds the same binaries.
+# Components are launched individually by the launcher, never xfce4-session.
+RUN apt-get -o Acquire::Retries=3 update && \
+ apt-get -o Acquire::Retries=3 install -y --no-install-recommends \
+ tigervnc-standalone-server xfce4-panel xfwm4 xfdesktop4 xfce4-settings xfce4-terminal \
+ dbus-x11 x11-xserver-utils x11-utils x11-xkb-utils xauth fonts-dejavu-core \
+ at-spi2-core libgtk-3-0 libnss3 libasound2 libxss1 && \
+ rm -rf /var/lib/apt/lists/*
+
+# Headed Chromium through Playwright (the same build the Hermes -desktop image
+# uses), so agent-browser and the dock's Browser icon share one binary and one
+# --user-data-dir. --with-deps pulls the Chromium runtime libraries. agent-browser
+# itself is baked (the CLI the browser tools drive), pinned to the same range the
+# gateway resolves (tools/browser_tool.py AGENT_BROWSER_NPX_SPEC), scripts off:
+# the first browser_navigate in a fresh sandbox must not wait on an npm fetch.
+RUN for i in 1 2 3; do \
+ npx --yes playwright@1 install --with-deps chromium && break || \
+ { [ "$i" = 3 ] && exit 1; echo "playwright chromium install failed (attempt $i); retrying in 10s"; sleep 10; }; \
+ done && chmod -R a+rX /opt/playwright && \
+ npm install -g --ignore-scripts --no-audit --fetch-retries=5 "agent-browser@^0.26.0" && \
+ agent-browser --version
+
+# cua-driver: computer_use's MCP driver. Pinned release tarball from the
+# cua-driver-rs-v* tags (never releases/latest: prereleases publish 0 assets).
+RUN set -eu; \
+ case "${TARGETARCH:-amd64}" in \
+ amd64) arch=x86_64 ;; \
+ arm64) arch=arm64 ;; \
+ *) echo "unsupported TARGETARCH ${TARGETARCH}"; exit 1 ;; \
+ esac; \
+ mkdir -p /opt/cua-driver; \
+ curl -fsSL "https://github.com/trycua/cua/releases/download/cua-driver-rs-v${CUA_DRIVER_VERSION}/cua-driver-rs-${CUA_DRIVER_VERSION}-linux-${arch}-binary.tar.gz" \
+ | tar -xz -C /opt/cua-driver; \
+ ln -sf /opt/cua-driver/cua-driver /usr/local/bin/cua-driver; \
+ /usr/local/bin/cua-driver --version
+
+# Pillow: the Screen pane's thumbnail is grabbed INSIDE the sandbox (the X socket and its cookie live
+# here, not on the gateway host). Also used by the base for ad-hoc image work.
+RUN pip install --no-cache-dir "pillow>=10" && python3 -c "from PIL import ImageGrab"
+
+# The base's default user stays root, exactly like nikolaik today, so existing
+# docker_image users see no ownership or PATH change. Desktop processes (Xvnc,
+# Xfce, Chromium, cua-driver) are exec'd as the base's unprivileged `pn` (uid
+# 1000): Chromium refuses to run as root without --no-sandbox and cua-driver's
+# AT-SPI bus wants a real user session. `pn` may sudo for ad-hoc installs.
+RUN echo "pn ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/pn && chmod 0440 /etc/sudoers.d/pn && \
+ mkdir -p /tmp/.X11-unix && chmod 1777 /tmp/.X11-unix && \
+ mkdir -p /tmp/hermes-runtime && chown pn:pn /tmp/hermes-runtime && chmod 0700 /tmp/hermes-runtime
+
+# Runtime dir for dbus/Xvnc; containers have no logind to create it. Both /tmp
+# paths above are fixed by the X11 protocol / seeded per container, never shared.
+ENV XDG_RUNTIME_DIR=/tmp/hermes-runtime
+# Dockerfile ENV reaches `docker exec` only. When this image is the target of the
+# ssh backend (sshd added on top), a login session gets its environment from PAM,
+# so the browser location must also live where pam_env reads it or agent-browser
+# reports "Chrome not found" over ssh while working under docker exec.
+RUN printf 'PLAYWRIGHT_BROWSERS_PATH=/opt/playwright\nXDG_RUNTIME_DIR=/tmp/hermes-runtime\n' >> /etc/environment
+CMD ["sleep", "infinity"]