Sign inSign up

ajeetraina777/sbx-openhands-kits:dmr

Manifest digest

sha256:406061063b3c239cd48f7ad4eae7bc0357d01e1bfdcd5a69b6fdb42a1df48a3b

Last pushed

23 days by ajeetraina777

Type

Sandbox Kit

Manifest digest

sha256:406061063b3c239cd48f7ad4eae7bc0357d01e1bfdcd5a69b6fdb42a1df48a3b

yaml
schemaVersion: "2"
kind: mixin
name: openhands
displayName: OpenHands Agent Canvas (Docker Model Runner)
description: Installs OpenHands Agent Canvas — the browser UI + backend server (`agent-canvas`, port 8000) that replaced the deprecated interactive CLI — plus the still-supported headless `openhands` runner, wired to a local Docker Model Runner over host.docker.internal:12434 — no cloud key, no external LLM. Pull a coding model on the host first (e.g. `docker model pull ai/qwen2.5-coder`). Forward port 8000 (`sbx run -p 8000 …`) and open http://localhost:8000, or run the headless smoke test.
sourceURL: https://github.com/ajeetraina/sbx-kits-openhands
requires:
    agent: shell
agentInstructions:
    content: |
        ## OpenHands Agent Canvas (Docker Model Runner)

        OpenHands' interactive CLI/TUI is deprecated in favour of **Agent Canvas**, a
        browser UI + backend server. This kit installs both surfaces, wired to a
        local Docker Model Runner over `http://host.docker.internal:12434/engines/v1`
        — no cloud credentials. The model is `LLM_MODEL` (default
        `openai/ai/qwen2.5-coder`); it must be pulled on the host first with
        `docker model pull ai/qwen2.5-coder`.

        **Agent Canvas (primary, interactive)** — installed on PATH as
        `agent-canvas` (via `npm i -g @openhands/agent-canvas`). Launch it with the
        runbook, which also seeds the model:

            bash ~/runbooks/canvas.sh        # serves http://localhost:8000

        Agent Canvas does NOT read the `LLM_*` env vars (its LLM config lives in the
        web UI). `canvas.sh` works around this: after the backend is healthy it seeds
        `LLM_MODEL` / `LLM_BASE_URL` / `LLM_API_KEY` into Canvas via its local
        settings API, so the UI opens preconfigured. Port 8000 must be forwarded to
        the host — start the sandbox with `sbx run -p 8000 …`, then open
        http://localhost:8000.

        **Headless runner (automation / verification)** — the still-supported
        `openhands` binary (via `uv tool install openhands`). It ignores the `LLM_*`
        env vars unless you pass `--override-with-envs`:

            openhands --headless --override-with-envs --exit-without-confirmation -t "…"

        If OpenHands can't reach the model, confirm DMR is running on the host
        (`docker model ls`) and that the model in `LLM_MODEL` is pulled. A one-shot
        smoke test lives at `~/runbooks/smoke.sh`.
permissions:
    network:
        allow:
            - pypi.org
            - files.pythonhosted.org
            - github.com
            - objects.githubusercontent.com
            - release-assets.githubusercontent.com
            - astral.sh
            - nodejs.org
            - registry.npmjs.org
            - ghcr.io
            - pkg-containers.githubusercontent.com
            - host.docker.internal:12434
environment:
    variables:
        LLM_API_KEY: dmr
        LLM_BASE_URL: http://host.docker.internal:12434/engines/v1
        LLM_MODEL: openai/ai/qwen2.5-coder
        NO_PROXY: localhost,127.0.0.1,host.docker.internal
        OH_SECRET_KEY: sbx-openhands-dev
        OPENHANDS_SUPPRESS_BANNER: "1"
        PATH: /home/agent/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
        no_proxy: localhost,127.0.0.1,host.docker.internal
setup:
    install:
        - command: 'bash -lc ''set -e; V=$(node --version 2>/dev/null || true); V=${V#v}; MAJ=${V%%.*}; R=${V#*.}; MIN=${R%%.*}; if [ -n "$MAJ" ] && { [ "$MAJ" -gt 22 ] || { [ "$MAJ" -eq 22 ] && [ "$MIN" -ge 12 ]; }; }; then echo "node v$V already present (>=22.12), skipping"; exit 0; fi; A=$(uname -m); case "$A" in x86_64) N=x64;; aarch64|arm64) N=arm64;; *) echo "unsupported arch: $A" >&2; exit 1;; esac; NV=v22.12.0; curl -fsSL "https://nodejs.org/dist/$NV/node-$NV-linux-$N.tar.gz" | tar -xz -C /usr/local --strip-components=1'''
          user: "0"
          description: Ensure Node.js >=22.12 for Agent Canvas (present in sbx base images; else fetch the tar.gz)
        - command: bash -lc 'i=0; while [ $i -lt 3 ]; do i=$((i+1)); npm install -g --prefix /usr/local @openhands/agent-canvas --no-audit --no-fund --maxsockets 3 --fetch-retries 5 --fetch-retry-maxtimeout 120000 && exit 0; echo "npm attempt $i failed; retrying in 5s" >&2; sleep 5; done; echo "npm install failed after $i attempts" >&2; exit 1'
          user: "0"
          description: 'Install OpenHands Agent Canvas (bin: agent-canvas) into /usr/local/bin; retries + low concurrency for the apply-time proxy'
        - command: pip install --break-system-packages 'uv>=0.11.6'
          user: "0"
          description: Install uv (used to install the headless OpenHands runner on Python 3.12)
        - command: uv tool install openhands --python 3.12
          user: "1000"
          description: 'Install the headless OpenHands runner (bin: openhands) into ~/.local/bin'