
Headmesh Agent Sandbox
io.github.headmesh-dev由 GitHub 帳號 headmesh-dev 發布v0.1.0更新於 Nov 5, 2026
Run commands, edit files and manage Git and persistent sessions in your own isolated sandbox.
概覽
針對自架 Headmesh 沙箱容器的 MCP 伺服器,讓助理在隔離環境中執行指令、編輯檔案、使用 Git 並維持持續工作階段。
- 可以做什麼
- 在沙箱容器內執行 shell 指令
- 讀寫沙箱檔案系統中的檔案
- 管理 Git 儲存庫與工作副本
- 啟動、列出並重新連線持續的 tmux 工作階段
- 查詢守護程式狀態與稽核資訊
- 適用情境
- 適合已自架 Headmesh 沙箱、希望雲端或桌面助理在隔離容器裡使用真實檔案、真實相依套件與私有服務(而非在你自己的機器上)工作的情境。
- 執行需求
- 需要你自己沙箱主機上的遠端 MCP 端點,並透過 tailnet 存取。需在 Authorization 標頭提供由主機 CLI 建立、可撤銷的限定範圍 bearer 權杖。主機上須已部署沙箱容器、守護程式並完成 tailnet 註冊。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Headmesh Agent Sandbox,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Web executable,透過 Streamable HTTP。 遠端服務在工作區中設定後即可從網頁執行環境執行。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
Headmesh agent sandbox
A persistent Docker container on the ASUS that joins Aaryn's Headscale tailnet as its own tagged node, so cloud agents can work with real files, real dependencies and private services. Agents reach it through several front doors:
- an MCP server,
headmesh-sandboxd; - the Claude self-hosted runner and Claude Remote Control;
- Codex over Tailscale SSH;
- the OpenAI Secure MCP Tunnel;
codex exec-server, driven from the host through the Agents API.
It implements plan §6 and §7 (docs/plan.md).
This is its own Go module, github.com/headmesh-dev/headmesh/sandbox; the
root go.work includes it. Run go test -race ./... here.
What's verified (2026-10-27)
All of this was run locally, without tailnet enrollment:
go test -race ./...passes. That includes integration tests on real tmux and real git, and the harness against an in-process sandboxd.golangci-lint runwith the repo config reports 0 issues.docker buildx bake -f sandbox/image/docker-bake.hcl sandbox-localbuildsheadmesh-sandbox:dev(2.39 GB). hadolint is clean, and container-structure-test passes 43/43.headmesh-sandbox upstarts the container through Compose with the §6.3 hardening. It reports healthy with tailscaled logged out, and the unconfigured front doors idle and say why.statusanddoctorwork.- Against the running container,
tools/list(31 tools),exec,session_*andfs_*pass over the unix socket, and over HTTP with a bearer token. Both protocol versions work: 2026-07-28 stateless and the 2025-11-25 handshake (tests/e2e). - Acceptance, route
mcpand routessh(run inside the container, phase 1, then phase 2 from a new process):- Checks 1–3 pass: uid 1000, Ubuntu 26.04, the file hash matches the host's copy, and the dependency runs.
- Check 5's mechanics pass: the session is still running after the reconnect, and the marker exists.
- Checks 4 and 5 still fail because the node isn't enrolled yet.
acceptance recreatepasses 5/5: home and~/.bash_historypersist, the boot identity changes, and old sessions reportlost (container restarted at …). The tailnet identity part was skipped (not enrolled).- YOLO:
- It is refused without a fresh backup record.
- With one, it starts with the per-subtree read-only
/host. Writes fail even as root, propagation isprivate,/etc/shadowreads as 0 bytes,~/.sshis masked, and the host tailscaled state and Docker data-root are left out. - It halts itself at the TTL, with an audit entry, and the next
upis Regular.
Spike outcomes are in docs/adr/spike-t0{1,2,3,7,8}-*.md and
docs/adr/spike-t16-*.md. Other implementation decisions are in
docs/adr/0001-sandbox-implementation-decisions.md.
Security findings to act on
- Install the egress firewall before enrolling (
host/firewall, step 1 below). A Docker bridge container can otherwise reach whatever the host can: its LAN, its own services and, on a host that is itself a tailnet node, that tailnet. Host-specific findings are in the internal ops notes. - YOLO shows the host read-only. That includes data directories and
certificates, wherever file permissions allow. Agents run as uid
1000; root-only files stay unreadable to them, but tailscaled and the runner
run as root in the container. Add anything sensitive to
[mounts] extra_denylist: denylisted subtrees are left out of/host. - Inside the sandbox,
UV_PROJECT_ENVIRONMENT=.venv-sandbox, souvnever rebuilds a project's host.venvagainst container paths. Make sure each project's.gitignorecovers.venv-sandbox(or.venv*).
Quick start (host)
Other commands: down [--yolo|--all], recreate, logs [service|audit] [-f],
shell [--root], attach (watch agents in tmux), backup,
token list|revoke, acceptance run|verify|report|recreate, and
agent run --provider openai.
Secrets live in /mnt/storage/headmesh/sandbox/secrets/<name>, mode 0600; an
empty file means that front door is off. They are never mounted. The CLI passes
them to docker compose through the environment, and Compose copies each one
into the container as root:root 0400 (spike T-1).
Steps that need Aaryn
Each step needs sudo, a production change or an account. None of them has been done.
1. Host (sudo)
- Install the egress firewall and the home backup units, then run a first backup.
The exact commands are in
host/README.md. Check the result withheadmesh-sandbox doctor; it should showegress firewall ✓andhome backup ✓. - Install restic (plan §5.3). Sleep targets are already masked (
doctorchecks this).
2. Headscale policy (production ACL change; maintenance window)
This builds on plan §5.2 and §6.6. Add the tags and grants to
api/infra/headscale/policy.hujson in the Xcelsior repo. Run
headscale policy check first; the policy tests must pass.
xcelsior@ must mean Aaryn's own devices only. That's true once the provider
hosts are tagged (§5.2).
3. Enroll the node
- The key alone sets the tags.
--advertise-tagsis never passed, because Headscale rejects it with a tagged key (spike T-8).tailscale-upchecks the enrolled tags againstTS_TAGSinstead. tailscale upruns with the key only while no state exists, so later restarts never re-authenticate. Tagged nodes don't expire. Clear the key file after enrollment.- YOLO is a separate node (
asus-sandbox-yolo,tag:sandbox-yolo) with its own state directory. Enroll it the same way, with a tag:sandbox-yolo key, during the firstup --yolo.
4. Front doors
MCP over the tailnet (Claude Code, any MCP client):
Tokens are scoped (sandbox:read|exec|write|admin) and can be revoked:
headmesh-sandbox token revoke claude-code-mac takes effect within seconds.
OAuth (RFC 9728 metadata is already served at
/.well-known/oauth-protected-resource/mcp) arrives with the Headmesh
authorization server in M3.
Claude self-hosted runner (plan §7.1):
- Turn on "Allow self-hosted environments" in claude.ai admin settings.
- Put the environment secret in
secrets/claude_env_secret, and fillsecrets/github_tokenwith a fine-grained PAT. - Set
[entrypoints.claude_runner] enabled = true, then runheadmesh-sandbox up.
The runner runs as root. Every session goes through claude-session, which
drops to agent with setpriv, so sessions can't read the secret (spike T-1).
The checkout hook links repos mapped in [repos] to the shared working copy, on
main. One live check is still pending: what the runner puts in the sessions'
environment.
Claude Remote Control (plan §7.2):
- Set
[entrypoints.claude_rc] enabled = true, then runheadmesh-sandbox up. - Run
headmesh-sandbox shell, thenclaude auth login(a full claude.ai login), trust/home/agent, and runclaude remote-controlonce to answer "Enable Remote Control? y". - Run
headmesh-sandbox recreate.
Never set DISABLE_TELEMETRY, DO_NOT_TRACK,
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC or DISABLE_GROWTHBOOK: Remote
Control refuses to start with any of them (spike T-2). Whether it restarts on its
own without a TTY still needs checking after this login.
Codex over Tailscale SSH (plan §7.3):
- This needs the
sshrule from step 2. - In Codex desktop, add the remote host
[email protected]. - Smoke test:
ssh [email protected] codex --version. - Tailscale SSH works inside the container (spike T-3). Codex desktop itself is untested.
OpenAI Secure MCP Tunnel (plan §7.4):
- In the Platform, create a Tunnel and a runtime key with Read+Use only. Put the
key in
secrets/openai_tunnel_keyand the id in[entrypoints.openai_tunnel] tunnel_id. Setenabled = true, then runup. - Create a token for the tunnel route:
headmesh-sandbox token create chatgpt-tunnel --route tunnel(exec ≤ 110 s, responses ≤ 8 MiB). - In ChatGPT: Plugins → Add custom MCP server → Connection: Tunnel, with bearer auth using that token.
Codex exec-server via the Agents API (plan §7.6):
-
Store the application key outside the sandbox. The CLI runs as you, so use
secrets/openai_app_key(0600; never mounted, and denylisted from YOLO's/host)./etc/headmesh/openai-app.keyis also accepted if you can read it. -
Put the environment key (Agents tab, every other permission None) in
secrets/openai_env_key. -
Run:
The executor runs as agent in the repo with --linux-sandbox-pid-namespace inherit and full access inside the container. Codex's bubblewrap sandbox can't
run under the container's seccomp and AppArmor profiles, so the container is the
boundary (spike T-16). The environment key reaches the executor through stdin,
and the transcript goes to logs/agent-runs/<session>.jsonl.
5. Acceptance (plan §6.15)
Set the targets in sandbox.toml [acceptance]:
allowed_targetmust be granted totag:sandbox.denied_targetmust be blocked. Run that probe only after the firewall is installed.
Check 4 accepts only a tailnet address for the MagicDNS name; a public DNS record for the same name doesn't count.
6. YOLO
-
Make a dedicated deploy key, add it to GitHub as "headmesh-sandbox-yolo (asus)", and pin
known_hosts:It is passed only to the YOLO container.
-
Run
headmesh-sandbox backup, thenheadmesh-sandbox up --yolo --ttl 4h.
The CLI refuses without a backup younger than backup_max_age and asks you to
confirm you're watching.
7. Publish the image
Push a sandbox-v0.1.0 tag. .github/workflows/sandbox-image.yml builds it,
runs hadolint, container-structure-test and trivy, pushes to
ghcr.io/headmesh-dev/sandbox, and signs it with cosign. Then set
image = "ghcr.io/headmesh-dev/sandbox:0.1.0@sha256:…".
Troubleshooting
- Run
headmesh-sandbox doctorfirst; every failure comes with a fix. headmesh-sandbox logs sandboxd|tailscaled|tailscale-up|claude-runner|claude-rc|openai-tunnel|audit.- To watch agents live:
headmesh-sandbox attach. - "IP works, names fail":
dns-checkexplains the fix (pitfall 3).
來源:sandbox/README.md,提交 92b720b
工具
0版本歷史
1- v0.1.0最新Nov 5, 2026
評分
已滿足適用檢查項的 60%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通必需25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式必需10 分
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分
