HarnessRouter Community Edition: the self-hosted, Apache-2.0 edition of the unified interface for agent harnesses. Run Codex, Claude Code, Hermes, PI, DSH, and more through one API, with sessions, streaming, files, cancellation, and failure handling. Implements the Unified Harness Protocol (UHP), an open standard. Your keys, your infrastructure.
Python agent-apiagent-frameworkagent-harnessai-agentsai-infrastructurecoding-agentconformance-testingdeepseek-harnessharness-engineeringhermesllmopen-protocolopen-sourceopen-standardpi-coding-agentself-hosteduhpunified-apiunified-harness-protocolunified-interface
zeroclaw as a base, driven through its ACP server (refs #442) (#456)
Arun Prabhakaranbaa355061288
diff --git a/docker/entrypoint.sh b/docker/entrypoint.shindex d16eb5d5..7f076845 100644--- a/docker/entrypoint.sh+++ b/docker/entrypoint.sh@@ -212,7 +212,7 @@ export NODE_PATH="$TOOLS/lib/node_modules"## gajae is NOT among them, and the gateway offers no gajae base either: its CLI cannot run under# this product's write-wall. gateway/app.py carries the measurement, above _MODEL_CATALOG["mimo"].-export HR_BACKENDS="${HR_BACKENDS:-claude,codex,hermes,pi,dsh,opencode,kilo,qwen,gemini,cline,omp,goose,kimi,minimax,grok,aider,openhands,agentzero,systemone,cheetahclaws,mimo,jcode,opensquilla,nanobot,qoder}"+export HR_BACKENDS="${HR_BACKENDS:-claude,codex,hermes,pi,dsh,opencode,kilo,qwen,gemini,cline,omp,goose,kimi,minimax,grok,aider,openhands,agentzero,systemone,cheetahclaws,mimo,jcode,opensquilla,nanobot,zeroclaw,qoder}"wanted() { [[ ",$HR_BACKENDS," == *",$1,"* ]]; }# The executable IS the definition of "installed" — an installer that exits 0 without producing@@ -249,6 +249,7 @@ backend_bin() {jcode) echo "$TOOLS/bin/jcode" ;;opensquilla) echo "$TOOLS/opensquilla-venv/bin/opensquilla" ;;nanobot) echo "$TOOLS/nanobot-venv/bin/nanobot" ;;+ zeroclaw) echo "$TOOLS/bin/zeroclaw" ;;esac}@@ -873,6 +874,45 @@ install_goose() {rm -rf "$gs_tmp"}+# zeroclaw (Apache-2.0, zeroclaw-labs/zeroclaw) ships prebuilt Rust binaries on GitHub releases, with+# a SHA256SUMS beside them. Pinned EXACTLY to the release runner/zeroclaw_driver.py was measured+# against (its ACP methods, the session/update shapes, the session store, the config schema), and+# verified against digests pinned HERE, read off that release's own SHA256SUMS on 2026-10-13 — the+# goose pattern, which does not trust a checksum file that can be re-uploaded beside the asset it+# describes. The archive also carries zerocode, zerorelay and a web bundle; only zeroclaw is kept.+install_zeroclaw() {+ case "$(uname -m)" in+ x86_64) zc_arch="x86_64"; zc_sha="9dbb53af95132e3a934ab61b229fb7aec3565f1c9bf31851f1698be9160655f9" ;;+ aarch64|arm64) zc_arch="aarch64"; zc_sha="aaa7e2c656dedf651217a70ea487e1e65f51b4ca771d114e60bf409165700986" ;;+ *) echo "unsupported architecture $(uname -m) for zeroclaw"; return 1 ;;+ esac+ zc_ver="${HR_ZEROCLAW_VERSION:-0.8.5}"; zc_ver="${zc_ver#v}"+ if [ "$zc_ver" != "0.8.5" ]; then+ if [ -n "${HR_ZEROCLAW_SHA256:-}" ]; then+ zc_sha="$HR_ZEROCLAW_SHA256"+ else+ echo "[harnessrouter] WARN: HR_ZEROCLAW_VERSION=$zc_ver overrides the pinned 0.8.5, and no"+ echo "[harnessrouter] HR_ZEROCLAW_SHA256 was given — this zeroclaw archive is UNVERIFIED."+ zc_sha=""+ fi+ fi+ zc_url="https://github.com/zeroclaw-labs/zeroclaw/releases/download/v${zc_ver}/zeroclaw-${zc_arch}-unknown-linux-gnu.tar.gz"+ zc_tmp="$(mktemp -d)"+ curl -fsSL "$zc_url" -o "$zc_tmp/zeroclaw.tar.gz" || { rm -rf "$zc_tmp"; return 1; }+ if [ -n "$zc_sha" ]; then+ zc_have="$(sha256sum "$zc_tmp/zeroclaw.tar.gz" | awk '{print $1}')"+ if [ "$zc_sha" != "$zc_have" ]; then+ echo "zeroclaw $zc_ver: archive digest mismatch for $zc_arch (want $zc_sha, have $zc_have)"+ rm -rf "$zc_tmp"; return 1+ fi+ fi+ tar -xzf "$zc_tmp/zeroclaw.tar.gz" -C "$zc_tmp" zeroclaw || { rm -rf "$zc_tmp"; return 1; }+ [ -f "$zc_tmp/zeroclaw" ] || { echo "release archive contained no zeroclaw binary"; rm -rf "$zc_tmp"; return 1; }+ mkdir -p "$TOOLS/bin" && install -m 755 "$zc_tmp/zeroclaw" "$TOOLS/bin/zeroclaw" \+ || { rm -rf "$zc_tmp"; return 1; }+ rm -rf "$zc_tmp"+}+# omp (Oh My Pi, MIT) ships standalone prebuilt binaries on GitHub releases, with a SHA256SUMS.txt# beside them. Pinned EXACTLY, like every other backend here: upstream releases almost daily# (18.1.8 through 18.1.13 in five days), and 18.1.13 is the release the runner's omp code was@@ -1304,6 +1344,15 @@ install_backends() {try_install "nanobot" install_nanobot || truefi[ -x "$TOOLS/nanobot-venv/bin/python" ] && export HR_NANOBOT_PYTHON="$TOOLS/nanobot-venv/bin/python"++ # `zeroclaw --version` prints "zeroclaw 0.8.5", so comparing it to the pin both installs a missing+ # binary and replaces one left by an older image.+ ZEROCLAW_PIN="${HR_ZEROCLAW_VERSION:-0.8.5}"; ZEROCLAW_PIN="${ZEROCLAW_PIN#v}"+ if wanted zeroclaw && [ "$("$(backend_bin zeroclaw)" --version 2>/dev/null | awk '{print $2}')" != "$ZEROCLAW_PIN" ]; then+ echo "[harnessrouter] installing zeroclaw $ZEROCLAW_PIN (Apache-2.0, version-pinned$([ "$ZEROCLAW_PIN" = 0.8.5 ] || [ -n "${HR_ZEROCLAW_SHA256:-}" ] && echo ", digest-verified"))…"+ try_install "zeroclaw" install_zeroclaw || true+ fi+ [ -x "$(backend_bin zeroclaw)" ] && export HR_ZEROCLAW_BIN="$(backend_bin zeroclaw)"# Both venv bases are reached by PATH from the runner, so the interpreter and the console script# are named explicitly — $TOOLS/bin is what PATH carries, and neither of these lives there.[ -x "$TOOLS/opensquilla-venv/bin/opensquilla" ] && export HR_OPENSQUILLA_BIN="$TOOLS/opensquilla-venv/bin/opensquilla"diff --git a/docs/self-hosting-guide.md b/docs/self-hosting-guide.mdindex f304e3e6..19e6e0ab 100644--- a/docs/self-hosting-guide.md+++ b/docs/self-hosting-guide.md@@ -365,18 +365,18 @@ offers you providers that work.| Connection `provider` | Backends that can use it ||---|---|-| `anthropic` | Claude Code, Hermes, Pi, DeepSeek Harness, OpenCode, Kilo Code, Qwen Code, Cline, Oh My Pi, goose, Kimi Code CLI, MiniMax Code, Grok Build, Aider, OpenHands, Agent Zero |-| `openai` | Codex, Hermes, Pi, DeepSeek Harness, OpenCode, Kilo Code, Qwen Code, Cline, Oh My Pi, goose, Kimi Code CLI, MiniMax Code, Grok Build, Aider, OpenHands, Agent Zero |-| `openrouter` | Codex, Hermes, Pi, DeepSeek Harness, OpenCode, Kilo Code, Qwen Code, Cline, Oh My Pi, goose, Kimi Code CLI, MiniMax Code, Grok Build, Aider, OpenHands, Agent Zero, System One, CheetahClaws |-| `azure-foundry` | Codex, Hermes, Pi, DeepSeek Harness, OpenCode, Kilo Code, Qwen Code, Cline, Oh My Pi, goose, Kimi Code CLI, MiniMax Code, Grok Build, Aider, OpenHands, Agent Zero |-| `google` | Hermes, Pi, DeepSeek Harness, OpenCode, Kilo Code, Qwen Code, Gemini CLI, Cline, Oh My Pi, Kimi Code CLI, MiniMax Code, Grok Build, Aider, OpenHands, Agent Zero |+| `anthropic` | Claude Code, Hermes, Pi, DeepSeek Harness, OpenCode, Kilo Code, Qwen Code, Cline, Oh My Pi, goose, Kimi Code CLI, MiniMax Code, Grok Build, Aider, OpenHands, Agent Zero, ZeroClaw |+| `openai` | Codex, Hermes, Pi, DeepSeek Harness, OpenCode, Kilo Code, Qwen Code, Cline, Oh My Pi, goose, Kimi Code CLI, MiniMax Code, Grok Build, Aider, OpenHands, Agent Zero, ZeroClaw |+| `openrouter` | Codex, Hermes, Pi, DeepSeek Harness, OpenCode, Kilo Code, Qwen Code, Cline, Oh My Pi, goose, Kimi Code CLI, MiniMax Code, Grok Build, Aider, OpenHands, Agent Zero, System One, CheetahClaws, ZeroClaw |+| `azure-foundry` | Codex, Hermes, Pi, DeepSeek Harness, OpenCode, Kilo Code, Qwen Code, Cline, Oh My Pi, goose, Kimi Code CLI, MiniMax Code, Grok Build, Aider, OpenHands, Agent Zero, ZeroClaw |+| `google` | Hermes, Pi, DeepSeek Harness, OpenCode, Kilo Code, Qwen Code, Gemini CLI, Cline, Oh My Pi, Kimi Code CLI, MiniMax Code, Grok Build, Aider, OpenHands, Agent Zero, ZeroClaw || `typesafe` | System One (Jev on TypeSafe's own API: `jev-latest`, `jev-preview`) || `bedrock` | Claude Code, Hermes |-| `tokenrouter` | Claude Code, Codex, Hermes, Pi, DeepSeek Harness, OpenCode, Kilo Code, Qwen Code, Gemini CLI, Cline, Oh My Pi, goose, Kimi Code CLI, MiniMax Code, Grok Build, Aider, OpenHands, Agent Zero, CheetahClaws, MiMo Code, jcode, OpenSquilla, nanobot |-| `harnessrouter` | Claude Code, Codex, Hermes, Pi, DeepSeek Harness, OpenCode, Kilo Code, Qwen Code, Gemini CLI, Cline, Oh My Pi, goose, Kimi Code CLI, MiniMax Code, Grok Build, Aider, OpenHands, Agent Zero, CheetahClaws, MiMo Code, jcode, OpenSquilla, nanobot, System One (the open-weight models `laya`, `openthai-systemone` and `system-one-phase2`, served by the hosted service and billed to the key's credits) |-| `vercel` | Claude Code, Codex, Hermes, Pi, DeepSeek Harness, OpenCode, Kilo Code, Qwen Code, Cline, Oh My Pi, goose, Kimi Code CLI, MiniMax Code, Grok Build, Aider, OpenHands, Agent Zero, CheetahClaws, MiMo Code, jcode, OpenSquilla, nanobot |-| `llmtr` | Claude Code, Codex, Hermes, Pi, DeepSeek Harness, OpenCode, Kilo Code, Qwen Code, Cline, Oh My Pi, goose, Kimi Code CLI, MiniMax Code, Grok Build, Aider, OpenHands, Agent Zero, MiMo Code, jcode, OpenSquilla, nanobot |-| `custom` | Claude Code, Codex (Responses format), Hermes, Pi, DeepSeek Harness, OpenCode, Kilo Code, Qwen Code, Cline, Oh My Pi, goose, Kimi Code CLI, MiniMax Code, Grok Build, Aider, OpenHands, Agent Zero, MiMo Code, jcode, OpenSquilla, nanobot, CheetahClaws (OpenAI format) |+| `tokenrouter` | Claude Code, Codex, Hermes, Pi, DeepSeek Harness, OpenCode, Kilo Code, Qwen Code, Gemini CLI, Cline, Oh My Pi, goose, Kimi Code CLI, MiniMax Code, Grok Build, Aider, OpenHands, Agent Zero, CheetahClaws, MiMo Code, jcode, OpenSquilla, nanobot, ZeroClaw |+| `harnessrouter` | Claude Code, Codex, Hermes, Pi, DeepSeek Harness, OpenCode, Kilo Code, Qwen Code, Gemini CLI, Cline, Oh My Pi, goose, Kimi Code CLI, MiniMax Code, Grok Build, Aider, OpenHands, Agent Zero, CheetahClaws, MiMo Code, jcode, OpenSquilla, nanobot, ZeroClaw, System One (the open-weight models `laya`, `openthai-systemone` and `system-one-phase2`, served by the hosted service and billed to the key's credits) |+| `vercel` | Claude Code, Codex, Hermes, Pi, DeepSeek Harness, OpenCode, Kilo Code, Qwen Code, Cline, Oh My Pi, goose, Kimi Code CLI, MiniMax Code, Grok Build, Aider, OpenHands, Agent Zero, CheetahClaws, MiMo Code, jcode, OpenSquilla, nanobot, ZeroClaw |+| `llmtr` | Claude Code, Codex, Hermes, Pi, DeepSeek Harness, OpenCode, Kilo Code, Qwen Code, Cline, Oh My Pi, goose, Kimi Code CLI, MiniMax Code, Grok Build, Aider, OpenHands, Agent Zero, MiMo Code, jcode, OpenSquilla, nanobot, ZeroClaw |+| `custom` | Claude Code, Codex (Responses format), Hermes, Pi, DeepSeek Harness, OpenCode, Kilo Code, Qwen Code, Cline, Oh My Pi, goose, Kimi Code CLI, MiniMax Code, Grok Build, Aider, OpenHands, Agent Zero, MiMo Code, jcode, OpenSquilla, nanobot, ZeroClaw, CheetahClaws (OpenAI format) |</details>@@ -958,7 +958,7 @@ Backends are installed into your data volume rather than baked into the image, swant is a run-time setting:```bash-docker run -e HR_BACKENDS=claude,codex,hermes,pi,dsh,opencode,kilo,qwen,gemini,cline,omp,goose,kimi,minimax,grok,aider,openhands,agentzero,systemone,cheetahclaws,mimo,jcode,opensquilla,nanobot ... # the default+docker run -e HR_BACKENDS=claude,codex,hermes,pi,dsh,opencode,kilo,qwen,gemini,cline,omp,goose,kimi,minimax,grok,aider,openhands,agentzero,systemone,cheetahclaws,mimo,jcode,opensquilla,nanobot,zeroclaw ... # the defaultdocker run -e HR_BACKENDS=opencode ... # lean```diff --git a/docs/support-matrix-notes.md b/docs/support-matrix-notes.mdindex 3a515671..de424d92 100644--- a/docs/support-matrix-notes.md+++ b/docs/support-matrix-notes.md@@ -29,6 +29,43 @@ offered model, the same lists as here.nanobot argument), and the model catalog route (0.6 s here, the same as the bases route; hosted'sslowness came from its remote secret store).+## zeroclaw reviewed on the review instance (2026-10-14, 0.34.0-rc.1 to rc.5)++Every model zeroclaw offered went through the five console scenarios, the plugin package (skill, stdio+MCP, rows, SSE, streamable HTTP), the browser column and a one-slide deck carrying a stamp; on top, the+family tour (13 of 13 families in one conversation), the environments column (3 of 3), the+custom-harness dimension, and the five-turn PDF conversation (5 of 5). Each fix below was measured+before and after on the same instance; the section further down (2026-10-13) is the contributor's own.++- **Paths.** zeroclaw's risk profile defaults to `workspace_only = true` and a denylist holding /etc+ and /usr: `head /etc/os-release`, `ls /env` and a python3 under /usr were refused as "forbidden+ absolute paths outside the workspace". Both are opened; the session's OS user is the boundary.+- **Skills with scripts were skipped** ("script-like files are blocked by skill security policy"):+ the Office skill, for its install.sh. `[skills] allow_scripts = true`.+- **The shell starts empty** and passes only the names it is given: the image skill's `HR_IMAGE_*`+ ("image generation is not configured for this Harness") and `OFFICECLI_RESIDENT_FLUSH` (seven+ decks handed back empty: officecli wrote on idle, after a ten-second turn had ended) are named now.+- **The step budget read as success.** zeroclaw summarises and stops with `end_turn` at+ `max_tool_iterations`; its note in the answer now ends the turn as `max_steps`.+- **34 tools, not 20.** Captured from the request zeroclaw sends (a fake chat/completions server):+ cron and schedule, channel and session messaging, pushover, git_forge, backup, canvas, weather,+ and none of the memory tools the first list named. `allowed_tools` is the measured set of 14+ (MCP tools are admitted on top of it); `delegate` fails ("Missing 'agent' parameter"); `llm_task`+ takes a model override and `deliver_file` hands back a copy the driver drops, so both are never offered.+- **"You are hr".** zeroclaw names the agent after its config alias in the persona it seeds; the+ alias is `zeroclaw` now.+- **State in the checkpoint repo**, every turn (three SQLite stores, the trace log, persona files,+ copied skills): `.harness/zeroclaw/` rides the tar (#460 did the same for nanobot, opensquilla, goose).+- **Not offered:** grok-4.20 (no deck twice: "invalid semantic completion", no text and no tool call);+ nemotron-3-super (no deck; off every sibling base already); qwen3.8-flash (answered the follow-up+ with the first turn's codeword, and provider errors on the artifact after an outage had cleared).+- **Known and left:** zeroclaw keeps a turn's messages only when the turn succeeds, so after a cancel+ the next turn does not know what the cancelled one did.+- **The PDF conversation's first turn** ("follow your instruction: say hi" under an instruction to make+ a PDF): GPT models answer "hi" without a PDF on zeroclaw, pi and opencode alike (32 of 55 zeroclaw+ models, every family represented). It is a property of the prompt, not of a base, and was not used+ to take models off; the rest of the conversation passes on every model tried.+## The four new bases offer only what they run reliably (2026-10-12, 0.33.0-rc.5 to rc.11, the review instance)The rule from here on, for every base: a base offers the models it was measured to run reliably on@@ -3908,3 +3945,104 @@ environment names. It could not read them — `control.db` and `graph.db` are `0`0700`, and a session uid already has traverse, so file contents are governed by each file's ownmode either way. The half that stops a session renaming or replacing another session's directory(which needs write on the parent, not on the target) is untouched by that change.++## zeroclaw, a new base (2026-10-13, refs #442)++zeroclaw (zeroclaw-labs/zeroclaw, Apache-2.0) is a Rust personal-agent runtime, pinned to 0.8.5+(released 2026-09-05) and installed from its GitHub release archive, verified against digests+pinned in `docker/entrypoint.sh` (read off that release's own SHA256SUMS). It is driven through its+ACP server, `zeroclaw acp`, by `runner/zeroclaw_driver.py`, which re-emits claude's stream-json, so+the normaliser is the passthrough. It speaks chat/completions through its `custom` provider and rides+the loopback relay, so it is wired row for row with nanobot and is in `CHAT_ONLY_BACKENDS`.++### Why ACP, and what the probes showed (against OpenRouter, claude-haiku-4.5)++- **`zeroclaw agent -m` cannot hold a conversation.** It prints the final answer as prose, and its+ `--session-state-file` is read only by the interactive REPL, so every one-shot run starts from the+ system prompt alone. ACP keeps sessions in `data/sessions/acp-sessions.db`, and `session/resume` in+ a later process seeds the agent with them: a second process named the file the first had written.+- **The model is the config's, and the config is rewritten every turn.** `session/resume` rebuilds the+ agent from the current `config.toml`, so a switch is a new `model` line. The switch rows below were+ served by the partner model on both pairs.+- **zeroclaw seeds seven files into its agent workspace** (AGENTS.md, SOUL.md, IDENTITY.md, USER.md,+ TOOLS.md, MEMORY.md, HEARTBEAT.md). With the agent workspace equal to the session directory all+ seven came back as produced files. The agent workspace is now `.harness/zeroclaw/agent` and the ACP+ `cwd` is the session directory: the file and shell tools are rooted at the `cwd` (`pwd` answered the+ session directory; a relative `file_write` landed there), and the instruction file and skills are+ read from the agent workspace. A sentinel written into `.harness/zeroclaw/agent/AGENTS.md` before+ the first turn was repeated by the agent, and the file was left as written.+- **Its shell refused ordinary commands even at level `full`.** `touch` and anything chained with `&&`+ answered "Command not allowed by security policy". The risk profile uses zeroclaw's documented+ trusted mode (`allowed_commands = ["*"]`, `block_high_risk_commands = false`); the session already+ runs as its own OS user in its own directory.+- **Its shell passes on only what it is told to.** A variable in the driver's environment came back+ empty and PATH was reset to the system default; names in `shell_env_passthrough` arrived. The runner+ names PATH, the environment layer's variables and the harness's own (nanobot's arrangement).+- **A custom endpoint gets prompt-guided tools by default.** Through the relay the model wrote its+ calls as `<tool_call>` text with invented `<tool_result>` lines, two of three arrived without their+ arguments ("Missing 'path' parameter"), and one file took three model calls (read off the session's+ stored transcript). zeroclaw's provider factory defaults a `custom` endpoint to prompt-guided tools+ (its own test: "custom OpenAI-compatible endpoints must default to prompt-guided tools"). The runner+ sets `native_tools = true`; the same turn then made one native call and used half the input tokens.+- **The context budget was left at zeroclaw's default (32,000 tokens), on a measurement.** A six-turn+ session on claude-haiku-4.5, four turns of it reading a 6 KB file, reached about 35,000 input tokens+ per model call; zeroclaw recorded no trim or compaction event, all 17 messages stayed in the store,+ and the last turn recalled a codeword from the first. A much longer session may still trim: zeroclaw+ then sends `_zeroclaw/history_trimmed`, which the driver does not yet surface.+- **The thinking level and attached images need nothing of their own.** The relay applies the turn's+ level to every request body it carries (`runner/reasoning.py`), and an attached image arrives as a+ file in the workspace, as on nanobot.+- **Failure reporting (checklist item 8).** A provider failure is a JSON-RPC error on the prompt+ (`-32603`, "The model provider custom.hr rejected its credentials", measured with a bad key), and a+ session the store does not hold is `-32000 Session not found` on `session/resume`. Both are+ structured, so nothing is parsed out of prose. The driver fails the turn on the first, and starts a+ new session on the second while `_resume_lost` reports the lost history.+- **Usage and the served model come from the relay.** The ACP stream carries no usage and names only+ the configured model. Neither the key nor anything derived from it was found in any file zeroclaw+ wrote.+- **Interactive tools are never offered.** `ask_user`, `escalate_to_human`, `reaction` and `poll` call+ back to the ACP client and wait for a person; `model_switch`, `model_routing_config` and+ `proxy_config` let the model change what serves the turn. All seven are in `excluded_tools` on every+ turn, and an excluded tool is absent from the list the agent reports.++### Measured (self-hosted, image built from this branch's final commit, 2026-10-13)++| Dimension | Result |+|---|---|+| Five scenarios, OpenRouter, claude-haiku-4.5 and gpt-5.4-mini | 10 of 10, every turn on `integration:openrouter`, none unlabelled |+| Custom harness (skill + script, disabled tool, MCP over streamable HTTP) | pass: skill reached, script ran through `shell` with the harness's variable, `web_fetch` disabled and unused, `deepwiki__read_wiki_structure` called |+| Install on a first start | `installing zeroclaw 0.8.5 …`, digest verified, listed among backends available |+| Five scenarios, 15 more OpenRouter models (the cheap and mid tier of every family) | 14 of 15; llama-3.3-70b is not offered (below) |+| Plugin matrix (`plugins/run-matrix.py --mode all`, gpt-5.4-mini) | 5 of 5: skills, stdio MCP, rows, remote SSE, remote streamable HTTP |+| Family tour, one conversation over ten families | 10 of 10, every turn served by its family; two passed on a retest (below) |+| Cancel mid-turn (a turn inside `sleep 120`) | cancelled at once; the driver, `zeroclaw acp`, its shell and `sleep` were all gone 5 s later; the next turn in the session recalled the first |+| zeroclaw's own web tools in the image | `web_fetch`, `web_search_tool` (DuckDuckGo) and `http_request` work |++- **Finding, prompt cache on Claude:** claude-haiku-4.5 read 7% of its input from cache against 70% for+ gpt-5.4-mini. zeroclaw's chat/completions requests carry no `cache_control`, so Anthropic models on+ an aggregator cache little. The agentzero, aider and cline rows report the same for the same reason.++- **llama-3.3-70b is not offered.** On OpenRouter it declined the first turn, a one-line echo, twice in+ a row ("The provided functions are insufficient for me to complete this task", then "I cannot perform+ this task as it requires additional information that is not provided"), with zeroclaw's tool list in+ the request. It is in `_NOT_OFFERED["zeroclaw"]`, as it is on goose, hermes, jcode, kilo, mimo, nanobot,+ opensquilla and pi.+- **The family tour's two retests.** kimi-k2.7-code's first turn failed with zeroclaw's "The model+ provider returned an invalid semantic completion": the provider returned no text and no tool call on+ the stream and again on zeroclaw's non-streaming fallback. The turn failed with that reason rather+ than completing empty. muse-glimmer-30b's first turn completed without rebuilding the deck. Both+ passed on a retest in the same conversation.+- **Three tools need a desktop and are not offered.** In the image, `browser_open` failed with "Failed+ to open system browser", `browser` with "agent-browser CLI is unavailable" and `screenshot` with "No+ screenshot tool found". They are in `_ZEROCLAW_NEVER` (rule 4).+- **The instance's own MCP server is reached over loopback.** On nanobot, reaching it needed+ `_BRIDGE_LOOPBACK_BACKENDS`. zeroclaw connected to `http://127.0.0.1:8080/v1/mcp/plugs` directly and+ called `plugs__browser_navigate`. The browser column itself could not be judged on this instance: the+ plug answered "The browser service is not set up on this deployment", and nanobot, run as a control,+ failed the same way.++### Not yet measured++The expensive models of the catalog (Sonnet, Opus, Fable, the GPT sol and terra lines, Gemini Pro), the+other providers (the direct Anthropic and OpenAI connections, Vercel, TokenRouter), the browser column+on an instance with a browser service, the environments column and the benchmark dimension.diff --git a/docs/support-matrix.md b/docs/support-matrix.mdindex f18a1627..3a033279 100644--- a/docs/support-matrix.md+++ b/docs/support-matrix.md@@ -3651,6 +3651,22 @@ session_id: 20260913_060549_70cbeb || qwen | qwen3.8-flash | pass | pass | pass (qwen3.7-max) | pass | pass | OpenRouter | served as qwen/qwen3.8-flash (the provider's alias of the same model) || qwen | qwen3.8-max | pass | pass | pass (qwen3.7-max) | pass | pass | OpenRouter | || qwen | step-3.7-flash | pass | pass | pass (qwen3.7-max) | pass | pass | OpenRouter | |+| zeroclaw | claude-haiku-4.5 | pass | pass | pass (gpt-5.4-mini) | pass | pass | OpenRouter | served as anthropic/claude-haiku-4.5 (the provider's alias of the same model) ; cache 7% of input (finding in the notes) |+| zeroclaw | gpt-5.4-mini | pass | pass | pass (claude-haiku-4.5) | pass | pass | OpenRouter | served as openai/gpt-5.4-mini (the provider's alias of the same model) ; cache 70% of input |+| zeroclaw | claude-haiku-5.5 | pass | pass | pass (gpt-6-luna) | pass | pass | OpenRouter | no prompt cache reads (finding below) ; served as anthropic/claude-haiku-5.5 (the provider's alias of the same model) |+| zeroclaw | deepseek-v4-flash | pass | pass | pass (gpt-6-luna) | pass | pass | OpenRouter | served as deepseek/deepseek-v4-flash (the provider's alias of the same model) ; cache 68% of input |+| zeroclaw | deepseek-v4.1-flash | pass | pass | pass (gpt-6-luna) | pass | pass | OpenRouter | served as deepseek/deepseek-v4.1-flash (the provider's alias of the same model) ; cache 68% of input |+| zeroclaw | gemini-3.1-flash-lite | pass | pass | pass (gpt-6-luna) | pass | pass | OpenRouter | served as google/gemini-3.1-flash-lite (the provider's alias of the same model) ; cache 65% of input |+| zeroclaw | gemini-3.5-flash-lite | pass | pass | pass (gpt-6-luna) | pass | pass | OpenRouter | served as google/gemini-3.5-flash-lite (the provider's alias of the same model) ; cache 65% of input |+| zeroclaw | glm-5.3-flash | pass | pass | pass (gpt-6-luna) | pass | pass | OpenRouter | served as z-ai/glm-5.3-flash (the provider's alias of the same model) ; cache 68% of input |+| zeroclaw | gpt-5.6-luna | pass | pass | pass (gpt-6-luna) | pass | pass | OpenRouter | served as openai/gpt-5.6-luna (the provider's alias of the same model) ; cache 67% of input |+| zeroclaw | gpt-6-luna | pass | pass | pass (gpt-5.6-luna) | pass | pass | OpenRouter | served as openai/gpt-6-luna (the provider's alias of the same model) ; cache 67% of input |+| zeroclaw | kimi-k2.7-code | pass | pass | pass (gpt-6-luna) | pass | pass | OpenRouter | served as moonshotai/kimi-k2.7-code (the provider's alias of the same model) ; cache 67% of input |+| zeroclaw | muse-glimmer-30b | pass | pass | pass (gpt-6-luna) | pass | pass | OpenRouter | served as meta/muse-glimmer-30b (the provider's alias of the same model) ; cache 69% of input |+| zeroclaw | nemotron-3.5-lightning | pass | pass | pass (gpt-6-luna) | pass | pass | OpenRouter | served as nvidia/nemotron-3.5-lightning (the provider's alias of the same model) ; cache 70% of input |+| zeroclaw | qwen3.8-27b | pass | pass | pass (gpt-6-luna) | pass | pass | OpenRouter | served as qwen/qwen3.8-27b (the provider's alias of the same model) ; cache 32% of input |+| zeroclaw | qwen3.8-flash | pass | pass | pass (gpt-6-luna) | pass | pass | OpenRouter | served as qwen/qwen3.8-flash (the provider's alias of the same model) ; cache 69% of input |+| zeroclaw | step-3.7-flash | pass | pass | pass (gpt-6-luna) | pass | pass | OpenRouter | served as stepfun/step-3.7-flash (the provider's alias of the same model) ; cache 68% of input |283 pairs, 1374 of 1380 scenario runs passed; 7 pairs served by another connection or as another model are findings, not counted.@@ -4517,6 +4533,7 @@ Not run in this column, 839 pairs the provider serves that the harness did not r- qwen x minimax-m3: not run, not in this harness's catalog (unmeasured or excluded, see the catalog's note)- qwen x nemotron-3-ultra: not run, not in this harness's catalog (unmeasured or excluded, see the catalog's note)- qwen x qwen3.7-flash: not run, not in this harness's catalog (unmeasured or excluded, see the catalog's note)+- zeroclaw x llama-3.3-70b: not offered, it declined the first turn twice ("The provided functions are insufficient for me to complete this task"); see the notes## Provider: tokenrouterdiff --git a/gateway/app.py b/gateway/app.pyindex acdba19f..df1094d1 100644--- a/gateway/app.py+++ b/gateway/app.py@@ -1517,6 +1517,14 @@ _INTEGRATION_WIRING: dict[tuple[str, str], str] = {("tokenrouter", "nanobot"): "tokenrouter", ("vercel", "nanobot"): "tokenrouter",("llmtr", "nanobot"): "tokenrouter", ("custom", "nanobot"): "openai-api",("google", "nanobot"): "openai-api", ("harnessrouter", "nanobot"): "tokenrouter",+ # zeroclaw speaks ONE OpenAI shape too — its `custom` provider posts chat/completions — through+ # the loopback relay, so it is wired row for row with nanobot.+ ("anthropic", "zeroclaw"): "anthropic", ("openai", "zeroclaw"): "openai",+ ("azure-foundry", "zeroclaw"): "azure",+ ("openrouter", "zeroclaw"): "openai-api",+ ("tokenrouter", "zeroclaw"): "tokenrouter", ("vercel", "zeroclaw"): "tokenrouter",+ ("llmtr", "zeroclaw"): "tokenrouter", ("custom", "zeroclaw"): "openai-api",+ ("google", "zeroclaw"): "openai-api", ("harnessrouter", "zeroclaw"): "tokenrouter",}@@ -5559,7 +5567,7 @@ _CUSTOM_FORMAT_BACKENDS = {# kilo passes api_format to the same ai-sdk package choice opencode makes (_opencode_npm)."openai": {"hermes", "opencode", "kilo", "pi", "dsh", "qwen", "cline", "omp", "goose", "kimi","aider", "openhands", "minimax", "cheetahclaws", "grok", "agentzero",- "mimo", "jcode", "opensquilla", "nanobot"},+ "mimo", "jcode", "opensquilla", "nanobot", "zeroclaw"},"anthropic": {"claude", "opencode", "kilo", "pi", "dsh", "omp", "goose", "hermes", "openhands","mimo"},# The OpenAI Responses API: what codex speaks, and only codex among the agent CLIs here.@@ -7541,7 +7549,7 @@ _MODEL_CATALOG["mimo"] = {"default": "gpt-5.4", "models": list(_MODEL_CATALOG["o# CHAT_ONLY_BACKENDS below. (jcode and opensquilla also have an Anthropic-Messages provider, used# only for a connection that IS Anthropic; the runner keeps a claude id on an aggregator on the# relay so its served model stays readable — see _build_jcode.)-for _b in ("jcode", "opensquilla", "nanobot"):+for _b in ("jcode", "opensquilla", "nanobot", "zeroclaw"):_MODEL_CATALOG[_b] = {"default": "gpt-5.4", "models": list(_MODEL_CATALOG["kimi"]["models"])}# systemone: Jev's ids across its two providers. `jev-latest` is served by both (TypeSafe's own API,# and OpenRouter's rolling alias of the same model) and is the default, so a harness made on either@@ -7632,6 +7640,20 @@ _NOT_OFFERED: dict[str, frozenset[str]] = {"nanobot": frozenset({"grok-build-0.1", "kimi-k3", "llama-3.3-70b", "grok-4.5", "nemotron-3-super","gpt-5.6-luna"}),"qoder": frozenset({"qfmodel", "efficient", "kmodel", "qmodel_latest"}),+ # zeroclaw (0.8.5, 2026-10-13): llama-3.3-70b on OpenRouter declines the FIRST turn — a one-line+ # echo — twice in a row ("The provided functions are insufficient for me to complete this task",+ # then "I cannot perform this task as it requires additional information that is not provided"),+ # with zeroclaw's tool list in the request. Fourteen other models passed all five scenarios.+ # Measured on every offered model on the review instance (0.34.0-rc.1 to rc.4, 2026-10-14: five+ # scenarios, the plugin package, the browser, a one-slide deck, the family tour):+ # grok-4.20 made no deck twice: zeroclaw's "The model provider returned an invalid+ # semantic completion" (no text and no tool call, after its own retries).+ # nemotron-3-super made no deck (no .pptx), no browser call on its first browser run, and a+ # provider error on its first artifact; off all four sibling bases already.+ # qwen3.8-flash answered the follow-up with the first turn's codeword ("M1" for "M2"), the+ # mix-up that took it off mimo, and failed its artifact on provider errors after+ # an outage had cleared (rc.2, rc.4, rc.5: no clean run).+ "zeroclaw": frozenset({"llama-3.3-70b", "grok-4.20", "nemotron-3-super", "qwen3.8-flash"}),}for _b, _e in _MODEL_CATALOG.items():_gone = _NOT_OFFERED.get(_b, frozenset())@@ -7661,7 +7683,7 @@ RESPONSES_ONLY_MODELS = frozenset({"gpt-5.3-codex", "gpt-6-astra"})# agentzero too: its model is litellm's openai provider (Agent Zero's `other`, a0_api_mode chat).CHAT_ONLY_BACKENDS = ("qwen", "cline", "goose", "kimi", "aider", "openhands", "minimax","cheetahclaws", "grok", "agentzero",- "jcode", "opensquilla", "nanobot")+ "jcode", "opensquilla", "nanobot", "zeroclaw")_BARE_MODELS = {"", "claude", "codex", "anthropic", "bedrock", "openai", "hermes", "pi", "dsh", "deepseek", "omp"}# Models whose serving CHANNEL refuses image input outright. Measured, not assumed — probed# 2026-08-19 on the TokenRouter connection with a data-URI image in a user message:@@ -17283,6 +17305,29 @@ _BASE_CATALOG: dict[str, dict] = {# limit — withholding a tool withholds that tool, not the capability."tool_enforcement": "hard",},+ "zeroclaw": {+ "label": "ZeroClaw", "backend": "zeroclaw", "status": "ready",+ "system_prompt": ("You are ZeroClaw, an autonomous agent. You work on a real git workspace "+ "with shell and file access, reading and editing files and running "+ "commands to complete the task end to end."),+ # The tools zeroclaw 0.8.5 offers a session under the runner's config, as the agent listed+ # them, pinned equal to the runner's ALL_ZEROCLAW_TOOLS, which is also the turn's allow-list:+ # the twenty tools zeroclaw would offer beyond it (scheduling, channels, outside accounts and+ # the rest; see the runner) are never offered, so there is nothing here to turn off.+ "tools": [("shell", "Shell"), ("file_read", "File Read"), ("file_write", "File Write"),+ ("file_edit", "Edit"), ("glob_search", "Find"), ("content_search", "Search"),+ ("git_operations", "Git"),+ ("web_fetch", "Web Fetch"), ("web_search_tool", "Web Search"),+ ("http_request", "HTTP Request"), ("image_info", "Image Info"), ("calculator", "Calculator"),+ ("TodoWrite", "Todo"),+ ("spawn_subagent", "Subagent")],+ # "hard": the runner writes the disabled tools into the risk profile's `excluded_tools`,+ # which removes them from the tool list the model is offered (measured: an excluded tool is+ # absent from the agent's own list) and is the one door that also removes MCP tools. As on+ # every base, withholding a tool withholds that tool, not the capability: with file_write+ # off, `shell` can still write a file.+ "tool_enforcement": "hard",+ },}# Bases this server can execute. Derived from the catalog above so the two cannot disagree —diff --git a/gateway/tests/test_zeroclaw_catalog.py b/gateway/tests/test_zeroclaw_catalog.pynew file mode 100644index 00000000..e86b74f3--- /dev/null+++ b/gateway/tests/test_zeroclaw_catalog.py@@ -0,0 +1,56 @@+"""The zeroclaw base as the gateway offers it, held to what the runner can actually do.++ * the tool ids are the runner's ALL_ZEROCLAW_TOOLS — the tools zeroclaw 0.8.5 offered a session+ under the runner's config, as the agent listed them — so no console toggle names a tool the+ risk profile's `excluded_tools` cannot withhold (UHP section 4.3)+ * the ids the runner never offers are not toggles at all+ * every provider wiring row maps to a provider the runner accepts for this backend, and a+ Responses-only model is not offered: zeroclaw's `custom` provider speaks chat/completions+"""+import os+import pathlib+import sys++sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))+sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[2] / "runner"))+os.environ.setdefault("HR_BACKING", "local")+import app as A # noqa: E402+from server import ALL_ZEROCLAW_TOOLS, BACKENDS, ZEROCLAW_PROVIDERS, _ZEROCLAW_NEVER # noqa: E402+++def _offered() -> set:+ return {tid for tid, _label in A._BASE_CATALOG["zeroclaw"]["tools"]}+++def test_zeroclaw_offers_exactly_the_tools_the_runner_can_withhold():+ offered = _offered()+ assert offered == set(ALL_ZEROCLAW_TOOLS), (+ f"only in catalog: {offered - set(ALL_ZEROCLAW_TOOLS)}, "+ f"only in the runner: {set(ALL_ZEROCLAW_TOOLS) - offered}")+ assert not offered & set(_ZEROCLAW_NEVER)+ assert A._BASE_CATALOG["zeroclaw"]["tool_enforcement"] == "hard"+++def test_zeroclaw_is_a_base_the_runner_can_execute_and_connect():+ entry = A._BASE_CATALOG["zeroclaw"]+ assert entry["backend"] == "zeroclaw" and entry["backend"] in BACKENDS+ assert A._MODEL_CATALOG["zeroclaw"]["models"]+ rows = {p: rp for (p, b), rp in A._INTEGRATION_WIRING.items() if b == "zeroclaw"}+ assert rows and set(rows.values()) <= ZEROCLAW_PROVIDERS+ # wired row for row with nanobot, the other chat/completions base driven through the relay+ assert rows == {p: rp for (p, b), rp in A._INTEGRATION_WIRING.items() if b == "nanobot"}+++def test_zeroclaw_is_chat_completions_only():+ assert "zeroclaw" in A.CHAT_ONLY_BACKENDS+ assert not set(A._MODEL_CATALOG["zeroclaw"]["models"]) & A.RESPONSES_ONLY_MODELS+ assert "zeroclaw" in A._CUSTOM_FORMAT_BACKENDS["openai"]+ assert "zeroclaw" not in A._CUSTOM_FORMAT_BACKENDS["anthropic"]+++def test_a_model_the_matrix_failed_twice_is_not_offered():+ assert "llama-3.3-70b" not in A._MODEL_CATALOG["zeroclaw"]["models"]+ # no deck from either (review instance, 2026-10-14)+ assert not {"grok-4.20", "nemotron-3-super", "qwen3.8-flash"} & set(A._MODEL_CATALOG["zeroclaw"]["models"])+ # withheld per base, not from the catalog: other bases still offer it+ assert any("llama-3.3-70b" in e["models"] for b, e in A._MODEL_CATALOG.items() if b != "zeroclaw")diff --git a/runner/server.py b/runner/server.pyindex 34556539..66d95778 100644--- a/runner/server.py+++ b/runner/server.py@@ -400,6 +400,25 @@ def _nanobot_session_present(cwd: str, cmd: list[str], session_id: str) -> bool:return False+def _zeroclaw_session_present(cwd: str, cmd: list[str], session_id: str) -> bool:+ """Ask zeroclaw's own ACP session store for the conversation: a row in acp_sessions with this+ uuid is exactly what `session/resume` loads. Read-only, so a turn never contends for the lock+ the ACP server takes."""+ db = pathlib.Path(cwd) / _ZEROCLAW_DIR / "data" / "sessions" / "acp-sessions.db"+ if not db.is_file() or not session_id:+ return False+ try:+ con = sqlite3.connect(f"file:{db}?mode=ro", uri=True, timeout=5)+ try:+ return con.execute("SELECT 1 FROM acp_sessions WHERE session_uuid = ?",+ (session_id,)).fetchone() is not None+ finally:+ con.close()+ except sqlite3.Error:+ return False+++_SESSION_PRESENT = {"claude": _argv_session_present,"opencode": _argv_session_present,@@ -426,6 +445,9 @@ _SESSION_PRESENT = {"jcode": _argv_session_present,"opensquilla": _opensquilla_session_present,"nanobot": _nanobot_session_present,+ # zeroclaw: the driver asks for `session/resume` on every turn that has an id and starts a new+ # session when the store says it is not there, so the store is asked here too.+ "zeroclaw": _zeroclaw_session_present,}@@ -517,7 +539,11 @@ def _isolate_session(ws: str) -> None:_CALLER_ENV_NAME = re.compile(r"^[A-Za-z_][A-Za-z0-9_]*$")# Prefixes the runner sets for the agent's own credentials, and the dynamic loader's; names that# would redirect an interpreter's imports, a process's trust roots or its network path.-_CALLER_ENV_RESERVED = ("HR_", "HARNESS_", "OPENAI_", "ANTHROPIC_", "GEMINI_", "GOOGLE_", "AWS_", "AZURE_", "LD_", "DYLD_")+_CALLER_ENV_RESERVED = ("HR_", "HARNESS_", "OPENAI_", "ANTHROPIC_", "GEMINI_", "GOOGLE_", "AWS_", "AZURE_", "LD_", "DYLD_",+ # zeroclaw reads ZEROCLAW_<section>__<key> as config overrides (the runner puts+ # the relay key there), so a harness variable named so could move its endpoint+ # or its excluded tools, or stop it from starting+ "ZEROCLAW_")_CALLER_ENV_RESERVED_NAMES = {"PATH", "HOME", "USER", "SHELL", "TERM", "LANG", "PWD", "TMPDIR","PYTHONPATH", "PYTHONHOME", "PYTHONSTARTUP", "NODE_OPTIONS", "NODE_EXTRA_CA_CERTS","SSL_CERT_FILE", "SSL_CERT_DIR", "REQUESTS_CA_BUNDLE", "CURL_CA_BUNDLE",@@ -765,6 +791,11 @@ CHECKPOINT_EXCLUDE = [*(f"./{c}" for c in _REBUILT_CACHES),# SESSIONS live in the same directory and MUST travel, so the exclusion is# the file, not the directory."./.harness/nanobot/config.json",+ # zeroclaw's config.toml carries no provider key (it is an environment+ # override), but its [[mcp.servers]] entries carry a server's env and headers+ # as written, and those commonly hold a bearer token. Rewritten every turn, so+ # nothing is lost by leaving it out; its data dir beside it MUST travel.+ "./.harness/zeroclaw/config.toml",# Dependency/scratch dirs (any depth): re-creatable by the agent, and they# dominate checkpoint size — a node project checkpointed 200MB+ and paid# that again on every hydrate. The agent reinstalls when it needs them.@@ -850,6 +881,7 @@ GAJAE_DEFAULT_MODEL = os.environ.get("GAJAE_DEFAULT_MODEL", "gpt-5.4")JCODE_DEFAULT_MODEL = os.environ.get("JCODE_DEFAULT_MODEL", "gpt-5.4")OPENSQUILLA_DEFAULT_MODEL = os.environ.get("OPENSQUILLA_DEFAULT_MODEL", "gpt-5.4")NANOBOT_DEFAULT_MODEL = os.environ.get("NANOBOT_DEFAULT_MODEL", "gpt-5.4")+ZEROCLAW_DEFAULT_MODEL = os.environ.get("ZEROCLAW_DEFAULT_MODEL", "gpt-5.4")CODEX_REASONING_EFFORT = os.environ.get("CODEX_REASONING_EFFORT", "medium")# The window Codex plans compaction against. Its own catalog says 272k for every gpt-5.x; a larger# number here made it compact late and let a long thread overflow the real window first.@@ -932,7 +964,7 @@ _PER_TURN_CONFIG = (".harness/opencode.json", ".harness/kilo.json", ".harness/mc".harness/mcp-bridge/")# A base's own state directory outside the CLI home, which it rewrites on every turn (see# _git_ensure). Not in the checkpoint repo; in the tar like .harness/home.-_STATE_DIRS = (".harness/nanobot/", ".harness/opensquilla/", ".harness/goose/")+_STATE_DIRS = (".harness/nanobot/", ".harness/opensquilla/", ".harness/goose/", ".harness/zeroclaw/")def _git_ensure(ws: str) -> None:@@ -965,6 +997,7 @@ def _git_ensure(ws: str) -> None:".harness/home/.config/jcode/",".harness/opensquilla/.env", ".harness/opensquilla/secrets.toml",".harness/nanobot/config.json",+ ".harness/zeroclaw/config.toml","# harness: the CLI home is checkpointed by tar, not by this repo (see _git_ensure)",".harness/home/",# Agent Zero's whole base, for the #193 reason: its chat.json stores the full rendered@@ -1468,6 +1501,12 @@ def _write_skills(cwd: str, skills: list[dict], backend: str = "claude") -> list# still. Written down here rather than quietly: see the PR body's follow-up.rootrels = [f"{_NANOBOT_WS}/skills"]entryroot = f"{_NANOBOT_WS}/skills"+ elif backend == "zeroclaw":+ # <agent workspace>/skills/<name>/SKILL.md, the per-agent root zeroclaw loads for a session+ # (docs/book/src/tools/skills.md). The agent workspace is under .harness/ (_ZEROCLAW_AGENT_WS),+ # so the bundle is never a produced file.+ rootrels = [str(_ZEROCLAW_AGENT_WS / "skills")]+ entryroot = str(_ZEROCLAW_AGENT_WS / "skills")else:# dsh has no skill loader; the AGENTS.md block below is the only door.# aider lands here on purpose too, and for a stronger reason: it has no skill loader AND no@@ -1845,6 +1884,12 @@ def _agent_doc_path(cwd: str, backend: str) -> pathlib.Path:# The one base whose agent workspace is a subdirectory of the session (see _NANOBOT_WS):# the file has to be where THAT workspace is, or it is written and never read.return pathlib.Path(cwd) / _NANOBOT_WS / "AGENTS.md"+ if backend == "zeroclaw":+ # zeroclaw reads AGENTS.md (with SOUL.md, IDENTITY.md and the rest of its persona set) from+ # the per-agent workspace, not the ACP cwd (system_prompt.rs). Measured on 0.8.5: a sentinel+ # written here before the first turn was repeated by the agent, and the file was left as+ # written while zeroclaw seeded the other six beside it.+ return pathlib.Path(cwd) / _ZEROCLAW_AGENT_WS / "AGENTS.md"if backend == "qwen":return pathlib.Path(cwd) / "QWEN.md" # qwen-code's own context file (bundle default)if backend == "gemini":@@ -10523,6 +10568,221 @@ def _build_nanobot(provider: str, auth: Auth, model: str, prompt: str, cwd: str,return [NANOBOT_PYTHON, NANOBOT_DRIVER, json.dumps(job)]+# ── zeroclaw (zeroclaw-labs/zeroclaw, Apache-2.0, a Rust binary) ─────────────────────────────────+# A self-hosted personal-agent runtime, driven through its ACP server (`zeroclaw acp`, JSON-RPC over+# stdio) by runner/zeroclaw_driver.py, which emits claude's stream-json directly — so this backend's+# normaliser is the passthrough, as nanobot's is. The driver's docstring holds the measured reasons+# ACP is the surface and `zeroclaw agent -m` is not (prose only, and no conversation across runs).+ZEROCLAW_PROVIDERS = {"anthropic", "openai", "azure", "openrouter", "tokenrouter", "openai-api"}+ZEROCLAW_BIN = os.environ.get("HR_ZEROCLAW_BIN", "/data/agent-tools/bin/zeroclaw")+ZEROCLAW_DRIVER = os.path.join(os.path.dirname(os.path.abspath(__file__)), "zeroclaw_driver.py")+# Everything zeroclaw keeps lives under one directory in the session's .harness/: config.toml, its+# data dir (the ACP session store at data/sessions/acp-sessions.db, its cost and trace logs) and the+# per-agent workspace. That last one is NOT the agent's working directory — the ACP `cwd` is the+# session directory, and zeroclaw's file and shell tools are rooted there (measured: `pwd` answered+# the session dir and a relative file_write landed in it). The agent workspace is where zeroclaw+# READS its instruction files and skills, and where it SEEDS its own: on the first turn it wrote+# AGENTS.md, SOUL.md, IDENTITY.md, USER.md, TOOLS.md, MEMORY.md and HEARTBEAT.md there. Measured with+# the agent workspace equal to the session dir, all seven came back as files the task produced;+# under .harness/ none does, and a runner-written AGENTS.md there is read and left as written.+_ZEROCLAW_DIR = pathlib.Path(".harness", "zeroclaw")+_ZEROCLAW_AGENT_WS = _ZEROCLAW_DIR / "agent"+# The variable zeroclaw's env-override walker maps onto [providers.models.custom.hr].api_key, so the+# credential is never written to config.toml. It is also what makes rule 2 answerable on this+# backend: _relay_served_model finds the relay route by the placeholder bearer among the turn's ENV+# values.+_ZEROCLAW_KEY_ENV = "ZEROCLAW_providers__models__custom__hr__api_key"+# Tools that are never offered. The first four call back to the ACP client and wait for a person+# (ask_user, escalate_to_human, reaction, poll); a runner turn has none, so the call would hang the+# turn until zeroclaw's own timeout. The last three let the MODEL change what serves the turn —+# model_switch and model_routing_config pick another model, proxy_config another route — and a turn+# that ran on a model nobody asked for is a substitution (matrix rule 2). The last three cannot work+# in the sandbox at all — MEASURED on 0.8.5 in the image: browser_open "Failed to open system browser",+# browser "agent-browser CLI is unavailable", screenshot "No screenshot tool found" — so offering them+# is a picker row that fails on use (rule 4). The instance's browser plugin is the browser here.+# llm_task takes a `model` argument ("Optional model override", crates/zeroclaw-tools/src/llm_task.rs)+# and sends it through the relay: model_switch's door again. deliver_file hands a file back to an ACP+# client as an embedded blob, which this driver drops (a turn's files come back from the workspace,+# where the file already is), and zeroclaw keeps a second copy of it beside the original.+_ZEROCLAW_NEVER = ("ask_user", "escalate_to_human", "reaction", "poll",+ "model_switch", "model_routing_config", "proxy_config", "llm_task",+ "browser_open", "browser", "screenshot", "deliver_file")+# The tools a zeroclaw turn offers, and the only ones: the config's `allowed_tools` (MCP tools,+# `<server>__<tool>`, are admitted by zeroclaw on top of it). CAPTURED, not asked of the agent: a+# fake chat/completions server recorded the request zeroclaw 0.8.5 sends under this config (2026-10-14).+# With only _ZEROCLAW_NEVER excluded it sent 34 tools, among them cron_add/list/remove/run/runs/update+# and schedule (no scheduler runs in a one-shot turn), channel_room, send_message_to_peer, send_via and+# sessions_current/history/list/send (no channels; claude-sonnet-5.5 spent a turn reading an empty+# session store and made no PDF), pushover and git_forge (accounts of their own), backup, canvas and+# weather; and no memory_store/recall/forget at all, which the first list named. Each tool here was+# seen to work in the image; delegate was not ("Missing 'agent' parameter": there is no other agent).+# Pinned equal to the gateway's _BASE_CATALOG["zeroclaw"] tool ids by its tests.+ALL_ZEROCLAW_TOOLS = (+ "shell", "file_read", "file_write", "file_edit", "glob_search", "content_search",+ "git_operations", "web_fetch", "web_search_tool", "http_request",+ "image_info", "calculator", "TodoWrite", "spawn_subagent",+)+# What `allowed_tools` holds when a harness turns every tool off: an empty list is zeroclaw's "no+# constraint", so a name no tool has keeps the list closed (MCP tools are still admitted).+_ZEROCLAW_NO_TOOLS = "no_builtin_tools"+# The variables a turn's shell needs that zeroclaw does not pass on by itself. Its shell tool builds+# a minimal environment — MEASURED: a variable in the driver's environment came back empty in the+# shell, PATH was reset to the system default and only names in `shell_env_passthrough` arrived —+# which is nanobot's `_build_env` shape exactly, so the same list is handed over by name: the+# environment layer's variables, PATH (the layer's bin dirs and the installed tools), and the+# harness's own variables. Names only: the values stay in the driver's environment.+_ZEROCLAW_SHELL_KEYS = ("PATH", "PROJECT_ROOT", "HR_ENVIRONMENT", "PYTHONPATH", "VIRTUAL_ENV",+ "NODE_PATH", "LD_LIBRARY_PATH", "TMPDIR")+++def _toml(v) -> str:+ """A TOML value. Strings go through _toml_str (grok's encoder: characters as themselves, since+ json.dumps's default escapes a character outside the BMP as a surrogate pair, which TOML+ refuses, so one emoji in an MCP argument made the whole file unreadable)."""+ if isinstance(v, bool):+ return "true" if v else "false"+ if isinstance(v, int):+ return str(v)+ if isinstance(v, dict):+ return "{ " + ", ".join(f"{_toml_str(k)} = {_toml(x)}" for k, x in v.items()) + " }"+ if isinstance(v, (list, tuple)):+ return "[" + ", ".join(_toml(x) for x in v) + "]"+ return _toml_str(v)+++def _zeroclaw_mcp(servers: list[dict] | None) -> list[dict]:+ """zeroclaw's `[[mcp.servers]]` entries: stdio (`command`/`args`/`env`) or a remote server over+ `http` or `sse` (`url`/`headers`). Unlike nanobot it takes the transport by name, so it is sent."""+ out: list[dict] = []+ for i, sv in enumerate(servers or []):+ if not isinstance(sv, dict):+ continue+ name = _mcp_name(sv.get("name") or sv.get("id") or f"server{i}")+ url = (sv.get("url") or "").strip()+ if sv.get("command"):+ cmd = sv["command"]+ argv = cmd if isinstance(cmd, list) else [str(cmd)]+ entry: dict = {"name": name, "transport": "stdio", "command": str(argv[0]),+ "args": [str(a) for a in argv[1:]] + [str(a) for a in (sv.get("args") or [])]}+ envv = sv.get("env")+ if isinstance(envv, dict) and envv:+ entry["env"] = {str(k): str(v) for k, v in envv.items()}+ elif url:+ kind = str(sv.get("transport") or sv.get("type") or "").lower()+ entry = {"name": name, "transport": "sse" if kind == "sse" or url.rstrip("/").endswith("/sse") else "http",+ "url": url}+ if _mcp_headers(sv):+ entry["headers"] = _mcp_headers(sv)+ else:+ continue+ out.append(entry)+ return out+++def _zeroclaw_config(base_url: str, model: str, cwd: str, mcp_servers: list[dict] | None,+ tools_disabled: list[str] | None, max_turns: int | None,+ shell_keys: list[str] | tuple = ()) -> pathlib.Path:+ """Write <cwd>/.harness/zeroclaw/config.toml and return its directory (zeroclaw's --config-dir).++ Rewritten on every turn, so a model switch is a new `model` here: `session/resume` rebuilds the+ agent from the CURRENT config and seeds it with the stored history. The api key is not in the+ file (_ZEROCLAW_KEY_ENV); MCP headers and env can be, so the file is in CHECKPOINT_EXCLUDE.++ What the risk profile says, and why:+ * level "full" — a supervised profile asks the ACP client before a tool runs, and there is+ nobody to answer.+ * allowed_commands ["*"] with block_high_risk_commands false — zeroclaw's documented trusted+ mode. Without it its shell refused `touch` and anything chained with `&&` even at level full+ (measured: "Command not allowed by security policy"). The session already runs as its own+ OS user in its own directory, which is the boundary every other base relies on.+ * excluded_tools — the harness's disabled tools plus _ZEROCLAW_NEVER. It is applied to the+ tool list the model is offered (measured: an excluded tool is not among the tools the agent+ lists), and it is the one door that covers MCP tools too: the profile's allow-list+ auto-admits `<server>__<tool>` names, and only excluded_tools subtracts them."""+ d = pathlib.Path(cwd) / _ZEROCLAW_DIR+ agent_ws = pathlib.Path(cwd) / _ZEROCLAW_AGENT_WS+ agent_ws.mkdir(parents=True, exist_ok=True)+ disabled = sorted({str(x).split(" (")[0].strip() for x in (tools_disabled or []) if x} | set(_ZEROCLAW_NEVER))+ mcp = _zeroclaw_mcp(mcp_servers)+ lines = [+ "# Written by the HarnessRouter runner on every turn; edits here do not survive the next one.",+ "schema_version = 3", "",+ "[providers.models.custom.hr]",+ f"uri = {_toml((base_url or '').rstrip('/'))}",+ f"model = {_toml(model)}",+ # A `custom` endpoint defaults to PROMPT-GUIDED tools: the tool list is described in the+ # system prompt and the model is asked to write <tool_call> blocks as text (zeroclaw's own+ # factory test: "custom OpenAI-compatible endpoints must default to prompt-guided tools").+ # MEASURED through the relay on 0.8.5 (claude-haiku-4.5): the model wrote the calls as prose+ # with invented <tool_result> lines, two of three arrived without their arguments ("Missing+ # 'path' parameter"), and the turn spent three model calls on one file. Every provider this+ # backend is wired to takes native tool calls on chat/completions, so they are switched on.+ "native_tools = true", "",+ "[agents.zeroclaw]", # the agent alias names the agent in its persona (zeroclaw_driver._AGENT)+ "enabled = true",+ 'model_provider = "custom.hr"',+ 'risk_profile = "hr"',+ 'runtime_profile = "hr"',+ ]+ if mcp:+ # MCP is opt-in per agent on ACP (`acp_enable_mcp`, off by default), and a server reaches an+ # agent only through a bundle the agent names: three switches, and a missing one is silent.+ lines += ['mcp_bundles = ["hr"]', "acp_enable_mcp = true"]+ # A skill folder holding a script file is skipped unless scripts are allowed ("install.sh:+ # script-like files are blocked by skill security policy"): MEASURED on 0.8.5, the built-in+ # Office skill was dropped from every session for its install.sh. The skills here are the+ # image's and the harness author's own, and their scripts run in the same shell either way.+ lines += ["", "[skills]", "allow_scripts = true"]+ lines += ["", "[agents.zeroclaw.workspace]", f"path = {_toml(str(agent_ws))}", "",+ "[risk_profiles.hr]", 'level = "full"', 'allowed_commands = ["*"]',+ "block_high_risk_commands = false",+ # zeroclaw's defaults are `workspace_only = true` and a path denylist that holds /etc+ # and /usr (crates/zeroclaw-config/src/schema.rs, RiskProfileConfig::default). MEASURED+ # on 0.8.5: `head -2 /etc/os-release`, `ls /env` and a python3 under /usr were all+ # refused as "forbidden absolute paths outside the workspace", and an environment's+ # script runs by its absolute path under /env. The boundary here is the session's own+ # OS user and its workspace, as for every other base.+ "workspace_only = false", "forbidden_paths = []",+ f"allowed_tools = {_toml(sorted(set(ALL_ZEROCLAW_TOOLS) - set(disabled)) or [_ZEROCLAW_NO_TOOLS])}",+ f"excluded_tools = {_toml(disabled)}",+ f"shell_env_passthrough = {_toml(sorted(set(shell_keys)))}", "",+ "[runtime_profiles.hr]"]+ if max_turns:+ lines.append(f"max_tool_iterations = {int(max_turns)}")+ if mcp:+ lines += ["", "[mcp_bundles.hr]", f"servers = {_toml([s['name'] for s in mcp])}"]+ for s in mcp:+ lines += ["", "[[mcp.servers]]"] + [f"{k} = {_toml(v)}" for k, v in s.items()]+ d.mkdir(parents=True, exist_ok=True)+ (d / "config.toml").write_text("\n".join(lines) + "\n")+ return d+++def _build_zeroclaw(provider: str, auth: Auth, model: str, prompt: str, cwd: str, env: dict,+ resume_session_id: str | None = None, mcp_servers: list[dict] | None = None,+ tools_disabled: list[str] | None = None, max_turns: int | None = None,+ caller_keys: list[str] | tuple = ()) -> list[str]:+ pr = provider or "openai-api"+ if pr not in ZEROCLAW_PROVIDERS:+ raise HTTPException(400, f"unknown zeroclaw provider '{pr}' (one of {sorted(ZEROCLAW_PROVIDERS)})")+ if not auth.base_url:+ raise HTTPException(400, f"zeroclaw provider '{pr}' needs a base_url (none configured)")+ if auth.api_key:+ # Every keyed turn rides the loopback relay, so the real key never reaches zeroclaw, and the+ # relay's taps supply what its ACP stream does not: the served model (rule 2) and fresh,+ # cached and output tokens. zeroclaw's `custom` provider speaks chat/completions.+ relay_base, relay_tok = _hermes_relay_route(auth.base_url, auth.api_key, stream_usage=True)+ auth = auth.model_copy(update={"base_url": relay_base, "api_key": relay_tok})+ env[_ZEROCLAW_KEY_ENV] = auth.api_key or ""+ shell_keys = [k for k in _ZEROCLAW_SHELL_KEYS if env.get(k)]+ shell_keys += [k for k in caller_keys if env.get(k) is not None and k not in shell_keys]+ shell_keys += [k for k in _TURN_SHELL_KEYS if env.get(k) and k not in shell_keys]+ cfg_dir = _zeroclaw_config(auth.base_url, model, cwd, mcp_servers, tools_disabled, max_turns, shell_keys)+ job = {"zeroclaw": ZEROCLAW_BIN, "config_dir": str(cfg_dir), "cwd": cwd, "model": model,+ "prompt": prompt, "resume_session_id": resume_session_id or ""}+ return [sys.executable, ZEROCLAW_DRIVER, json.dumps(job)]++def _jcode_has_session(env: dict, session_id: str) -> bool:"""Is this conversation in this workspace's session store?@@ -11178,6 +11438,9 @@ BACKENDS = {# normaliser is the passthrough, as systemone's is."nanobot": {"providers": sorted(NANOBOT_PROVIDERS), "default_model": NANOBOT_DEFAULT_MODEL,"normalize": _claude_passthrough},+ # The zeroclaw driver emits claude's stream-json itself (see zeroclaw_driver.py).+ "zeroclaw": {"providers": sorted(ZEROCLAW_PROVIDERS), "default_model": ZEROCLAW_DEFAULT_MODEL,+ "normalize": _claude_passthrough},}@@ -12921,6 +13184,13 @@ def turn(req: TurnReq, identifier: str = "") -> dict:# the harness's own variables and the platform's HR_ ones a turn carriescaller_keys=[*_caller_env(req.env),*(k for k in (req.env or {}) if isinstance(k, str) and k.startswith("HR_"))])+ elif backend == "zeroclaw":+ model = model or ZEROCLAW_DEFAULT_MODEL+ cmd = _build_zeroclaw(req.provider, auth, model, req.prompt, cwd, env,+ resume_session_id=req.resume_session_id, mcp_servers=req.mcp_servers,+ tools_disabled=req.tools_disabled, max_turns=req.max_turns,+ caller_keys=[*_caller_env(req.env),+ *(k for k in (req.env or {}) if isinstance(k, str) and k.startswith("HR_"))])else:mcp_config = _write_mcp_config_claude(cwd, req.mcp_servers)# Only a package that is ALSO a Claude Code plugin gets --plugin-dir; an Agent Pluginsdiff --git a/runner/tests/fixtures/zeroclaw/initialize.json b/runner/tests/fixtures/zeroclaw/initialize.jsonnew file mode 100644index 00000000..bc11d954--- /dev/null+++ b/runner/tests/fixtures/zeroclaw/initialize.json@@ -0,0 +1 @@+{"jsonrpc":"2.0","result":{"_meta":{"zeroclaw":{"defaultModel":"anthropic/claude-haiku-4.5","maxSessions":10,"sessionTimeoutSecs":3600}},"agentCapabilities":{"loadSession":true,"mcpCapabilities":{"http":false,"sse":false},"promptCapabilities":{"audio":false,"embeddedContext":true,"image":false},"sessionCapabilities":{"close":{},"resume":{}}},"agentInfo":{"name":"zeroclaw-acp","title":"ZeroClaw ACP","version":"0.8.5"},"authMethods":[],"protocolVersion":1},"id":"INIT"}diff --git a/runner/tests/fixtures/zeroclaw/provider-401.ndjson b/runner/tests/fixtures/zeroclaw/provider-401.ndjsonnew file mode 100644index 00000000..1ce5a099--- /dev/null+++ b/runner/tests/fixtures/zeroclaw/provider-401.ndjson@@ -0,0 +1 @@+{"jsonrpc":"2.0","error":{"code":-32603,"message":"The model provider custom.hr rejected its credentials. Check the configured credentials."},"id":"PROMPT"}diff --git a/runner/tests/fixtures/zeroclaw/write-file.ndjson b/runner/tests/fixtures/zeroclaw/write-file.ndjsonnew file mode 100644index 00000000..4b96ea8e--- /dev/null+++ b/runner/tests/fixtures/zeroclaw/write-file.ndjson@@ -0,0 +1,6 @@+{"jsonrpc":"2.0","method":"session/update","params":{"sessionId":"279c786c-c807-4181-a424-b0735dd64b88","update":{"content":{"text":"I'll create the file with","type":"text"},"sessionUpdate":"agent_message_chunk"}}}+{"jsonrpc":"2.0","method":"session/update","params":{"sessionId":"279c786c-c807-4181-a424-b0735dd64b88","update":{"content":{"text":" the exact content you requested.","type":"text"},"sessionUpdate":"agent_message_chunk"}}}+{"jsonrpc":"2.0","method":"session/update","params":{"sessionId":"279c786c-c807-4181-a424-b0735dd64b88","update":{"content":[{"newText":"HELLO","path":"hello.txt","type":"diff"}],"kind":"edit","name":"file_write","rawInput":{"newText":"HELLO","path":"hello.txt"},"sessionUpdate":"tool_call","status":"pending","title":"file_write","toolCallId":"bb50e99c-0a6a-4d4b-b6b2-80c449003cbc"}}}+{"jsonrpc":"2.0","method":"session/update","params":{"sessionId":"279c786c-c807-4181-a424-b0735dd64b88","update":{"body":"Written 5 bytes to hello.txt","content":[{"content":{"text":"Written 5 bytes to hello.txt","type":"text"},"type":"content"}],"kind":"edit","name":"file_write","rawOutput":"Written 5 bytes to hello.txt","sessionUpdate":"tool_call_update","status":"completed","title":"file_write","toolCallId":"bb50e99c-0a6a-4d4b-b6b2-80c449003cbc"}}}+{"jsonrpc":"2.0","method":"session/update","params":{"sessionId":"279c786c-c807-4181-a424-b0735dd64b88","update":{"content":{"text":"DONE","type":"text"},"sessionUpdate":"agent_message_chunk"}}}+{"jsonrpc":"2.0","result":{"content":"DONE","sessionId":"279c786c-c807-4181-a424-b0735dd64b88","stopReason":"end_turn"},"id":"PROMPT"}diff --git a/runner/tests/test_batch3_backends.py b/runner/tests/test_batch3_backends.pyindex 4c768fc9..e00f5cbe 100644--- a/runner/tests/test_batch3_backends.py+++ b/runner/tests/test_batch3_backends.py@@ -1247,7 +1247,8 @@ def test_a_layer_with_only_some_of_the_variables_passes_only_those():assert ex["pathPrepend"] == "/env/y/.venv/bin"[email protected]("build", ["_build_mimo", "_build_jcode", "_build_opensquilla", "_build_nanobot"])[email protected]("build", ["_build_mimo", "_build_jcode", "_build_opensquilla", "_build_nanobot",+ "_build_zeroclaw"])def test_the_provider_key_never_reaches_the_cli_whatever_the_connection_shape(build):"""The CLI's environment is the agent's shell's, and its config files ride the workspacecheckpoint: the real key belongs in neither, on any connection a base is offered. A directdiff --git a/runner/tests/test_zeroclaw_driver.py b/runner/tests/test_zeroclaw_driver.pynew file mode 100644index 00000000..cec49b12--- /dev/null+++ b/runner/tests/test_zeroclaw_driver.py@@ -0,0 +1,318 @@+"""runner/zeroclaw_driver.py and the zeroclaw backend in server.py (zeroclaw-labs/zeroclaw,+Apache-2.0, pinned to 0.8.5).++zeroclaw is not installed in the test environment (the entrypoint puts the binary on the data+volume), so a FAKE `zeroclaw acp` stands in for it: a script that speaks JSON-RPC over stdio and+answers each request with lines captured from the real 0.8.5 server (fixtures/zeroclaw/, recorded+against OpenRouter on 2026-10-13; the answer text of write-file.ndjson is shortened to DONE).++What each test pins is one thing that would otherwise be wrong SILENTLY:+ * a follow-up turn that starts a NEW conversation instead of resuming the stored one+ * a provider failure (a JSON-RPC error) reported as a turn that completed with no answer+ * a turn that hangs because zeroclaw asked a client question nobody answers+ * a provider key written into config.toml, or a relay that is not in the environment+ * the instruction file and skills written where zeroclaw never reads them+"""+import json+import pathlib+import sqlite3+import subprocess+import sys+import tempfile+import tomllib++sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))+import server as srv # noqa: E402++DRIVER = pathlib.Path(__file__).resolve().parents[1] / "zeroclaw_driver.py"+FIX = pathlib.Path(__file__).resolve().parent / "fixtures" / "zeroclaw"++# The fake `zeroclaw`: `zeroclaw acp --config-dir <d>` reading requests off stdin. The scenario (a+# JSON file named by FAKE_ZC) says which session ids the store holds, what the prompt answers with+# (a fixture file whose response line carries "id":"PROMPT"), and whether to ask the client a+# question first. Every request is appended to the scenario's log so a test can read what was sent.+_FAKE = r'''+import json, sys+sc = json.load(open(sys.argv[-1]))+log = open(sc["log"], "a")+def out(o):+ sys.stdout.write(json.dumps(o) + "\n"); sys.stdout.flush()+for line in sys.stdin:+ req = json.loads(line)+ if "method" not in req:+ log.write(json.dumps({"answer": req}) + "\n"); log.flush(); continue+ log.write(json.dumps(req) + "\n"); log.flush()+ m, rid = req["method"], req["id"]+ if m == "initialize":+ o = json.loads(open(sc["init"]).read()); o["id"] = rid; out(o)+ elif m == "session/new":+ out({"jsonrpc": "2.0", "id": rid, "result": {"sessionId": "new-session-uuid", "workspaceDir": req["params"]["cwd"]}})+ elif m == "session/resume":+ if req["params"]["sessionId"] in sc.get("known", []):+ out({"jsonrpc": "2.0", "id": rid, "result": {}})+ else:+ out({"jsonrpc": "2.0", "id": rid, "error": {"code": -32000, "message": "Session not found: " + req["params"]["sessionId"]}})+ elif m == "session/prompt":+ if sc.get("ask"):+ out({"jsonrpc": "2.0", "id": 900, "method": "session/request_permission", "params": {}})+ log.write(json.dumps({"answer": json.loads(sys.stdin.readline())}) + "\n"); log.flush() # hangs if none comes+ if sc.get("eof"):+ sys.exit(3)+ for l in open(sc["prompt"]):+ o = json.loads(l)+ if o.get("id") == "PROMPT":+ o["id"] = rid+ out(o)+'''+++def _run(tmp: pathlib.Path, scenario: dict, resume: str = "") -> tuple[list[dict], list[dict], int]:+ fake = tmp / "fake_zeroclaw.py"+ fake.write_text(_FAKE)+ launcher = tmp / "zeroclaw"+ sc = {"log": str(tmp / "requests.log"), "init": str(FIX / "initialize.json"), **scenario}+ (tmp / "scenario.json").write_text(json.dumps(sc))+ launcher.write_text(f"#!/bin/sh\nexec {sys.executable} {fake} \"$@\" {tmp / 'scenario.json'}\n")+ launcher.chmod(0o755)+ job = {"zeroclaw": str(launcher), "config_dir": str(tmp / "cfg"), "cwd": str(tmp),+ "model": "claude-haiku-4.5", "prompt": "write hello.txt", "resume_session_id": resume}+ p = subprocess.run([sys.executable, str(DRIVER), json.dumps(job)], capture_output=True, text=True,+ timeout=30)+ events = [json.loads(x) for x in p.stdout.splitlines() if x.strip()]+ sent = [json.loads(x) for x in (tmp / "requests.log").read_text().splitlines()] \+ if (tmp / "requests.log").exists() else []+ return events, sent, p.returncode+++def test_a_turn_becomes_claude_stream_json():+ with tempfile.TemporaryDirectory() as d:+ events, sent, rc = _run(pathlib.Path(d), {"prompt": str(FIX / "write-file.ndjson")})+ assert rc == 0+ assert [r["method"] for r in sent] == ["initialize", "session/new", "session/prompt"]+ assert sent[1]["params"] == {"cwd": d, "agentAlias": "zeroclaw"}+ assert sent[2]["params"]["prompt"] == [{"type": "text", "text": "write hello.txt"}]+ init = events[0]+ assert init == {"type": "system", "subtype": "init", "session_id": "new-session-uuid", "model": "claude-haiku-4.5"}+ blocks = [b for e in events if e["type"] in ("assistant", "user") for b in e["message"]["content"]]+ tool_use = [b for b in blocks if b["type"] == "tool_use"]+ assert tool_use == [{"type": "tool_use", "id": "bb50e99c-0a6a-4d4b-b6b2-80c449003cbc", "name": "file_write",+ "input": {"newText": "HELLO", "path": "hello.txt"}}]+ result = [b for b in blocks if b["type"] == "tool_result"]+ assert result == [{"type": "tool_result", "tool_use_id": "bb50e99c-0a6a-4d4b-b6b2-80c449003cbc",+ "is_error": False, "content": "Written 5 bytes to hello.txt"}]+ # the final answer is the prompt's own `content`, not every chunk of the turn run together+ assert events[-1] == {"type": "result", "subtype": "success", "is_error": False, "result": "DONE", "usage": {}}+++def test_a_follow_up_resumes_the_stored_session_rather_than_starting_another():+ with tempfile.TemporaryDirectory() as d:+ events, sent, rc = _run(pathlib.Path(d), {"prompt": str(FIX / "write-file.ndjson"),+ "known": ["old-session-uuid"]}, resume="old-session-uuid")+ assert rc == 0+ assert [r["method"] for r in sent] == ["initialize", "session/resume", "session/prompt"]+ assert sent[2]["params"]["sessionId"] == "old-session-uuid"+ assert events[0]["session_id"] == "old-session-uuid"+++def test_a_session_the_store_does_not_hold_starts_a_new_one():+ """zeroclaw answers -32000 "Session not found"; the turn still runs, on a new session, and+ server.py's _resume_lost (tested below) is what tells the person the history is gone."""+ with tempfile.TemporaryDirectory() as d:+ events, sent, rc = _run(pathlib.Path(d), {"prompt": str(FIX / "write-file.ndjson")}, resume="gone-uuid")+ assert rc == 0+ assert [r["method"] for r in sent] == ["initialize", "session/resume", "session/new", "session/prompt"]+ assert events[0]["session_id"] == "new-session-uuid"+++def test_a_provider_failure_is_a_failed_turn_with_the_reason():+ with tempfile.TemporaryDirectory() as d:+ events, _, rc = _run(pathlib.Path(d), {"prompt": str(FIX / "provider-401.ndjson")})+ assert rc == 1+ assert events[-1]["is_error"] is True and events[-1]["subtype"] == "error"+ assert "rejected its credentials" in events[-1]["result"]+++def test_a_stream_that_ends_without_an_answer_is_not_a_success():+ with tempfile.TemporaryDirectory() as d:+ events, _, rc = _run(pathlib.Path(d), {"prompt": str(FIX / "write-file.ndjson"), "eof": True})+ assert rc == 1+ assert events[-1] == {"type": "result", "subtype": "error", "is_error": True, "result": "", "usage": {}}+++def test_a_question_from_the_agent_is_answered_rather_than_left_to_hang_the_turn():+ with tempfile.TemporaryDirectory() as d:+ events, sent, rc = _run(pathlib.Path(d), {"prompt": str(FIX / "write-file.ndjson"), "ask": True})+ assert rc == 0 and events[-1]["result"] == "DONE"+ answers = [r["answer"] for r in sent if "answer" in r]+ assert answers == [{"jsonrpc": "2.0", "id": 900, "result": {"outcome": {"outcome": "cancelled"}}}]+++# ── server.py: the builder, the store lookup, where files land ─────────────────────────────────++def _build(tmp: str, **kw) -> tuple[list[str], dict, dict]:+ env = {"PATH": "/usr/bin:/data/agent-tools/bin", "STAMP_NONCE": "n-1"}+ cmd = srv._build_zeroclaw("openrouter", srv.Auth(api_key="sk-or-real", base_url="https://openrouter.ai/api/v1"),+ "anthropic/claude-haiku-4.5", "hi", tmp, env, **kw)+ cfg = tomllib.loads((pathlib.Path(tmp) / ".harness" / "zeroclaw" / "config.toml").read_text())+ return cmd, env, cfg+++def test_the_key_rides_the_relay_and_is_never_written_to_the_config():+ with tempfile.TemporaryDirectory() as d:+ cmd, env, cfg = _build(d)+ text = (pathlib.Path(d) / ".harness" / "zeroclaw" / "config.toml").read_text()+ assert "sk-or-real" not in text and "sk-or-real" not in json.dumps(cmd)+ tok = env[srv._ZEROCLAW_KEY_ENV]+ assert tok.startswith("hr-relay-") and tok in srv._HERMES_RELAY["routes"]+ assert cfg["providers"]["models"]["custom"]["hr"]["uri"].startswith("http://127.0.0.1:")+ assert cfg["providers"]["models"]["custom"]["hr"]["model"] == "anthropic/claude-haiku-4.5"+ # without it a custom endpoint gets prompt-guided tools: calls written as text, arguments lost+ assert cfg["providers"]["models"]["custom"]["hr"]["native_tools"] is True+ assert srv._relay_served_model(env) == "" # found by the placeholder in env; nothing served yet+ job = json.loads(cmd[2])+ assert cmd[:2] == [sys.executable, srv.ZEROCLAW_DRIVER]+ assert job["config_dir"] == str(pathlib.Path(d) / ".harness" / "zeroclaw") and job["cwd"] == d+++def test_the_risk_profile_runs_unattended_and_withholds_what_it_must():+ with tempfile.TemporaryDirectory() as d:+ _, _, cfg = _build(d, tools_disabled=["web_fetch (Web Fetch)"], max_turns=7)+ rp = cfg["risk_profiles"]["hr"]+ assert rp["level"] == "full" and rp["allowed_commands"] == ["*"] and rp["block_high_risk_commands"] is False+ assert set(rp["excluded_tools"]) == {"web_fetch", *srv._ZEROCLAW_NEVER}+ # and only the measured tools are offered at all: an allow-list, less the ones turned off+ assert rp["allowed_tools"] == sorted(set(srv.ALL_ZEROCLAW_TOOLS) - {"web_fetch"})+ assert cfg["runtime_profiles"]["hr"]["max_tool_iterations"] == 7+ # the shell gets the variables it needs by name: PATH and the harness's own+ assert "PATH" in rp["shell_env_passthrough"]+ assert cfg["agents"]["zeroclaw"]["workspace"]["path"].endswith(".harness/zeroclaw/agent")+ assert "mcp" not in cfg and "acp_enable_mcp" not in cfg["agents"]["zeroclaw"]+++def test_the_harness_variables_reach_the_shell_by_name():+ with tempfile.TemporaryDirectory() as d:+ _, _, cfg = _build(d, caller_keys=["STAMP_NONCE"])+ assert "STAMP_NONCE" in cfg["risk_profiles"]["hr"]["shell_env_passthrough"]+++def test_mcp_needs_all_three_switches_or_no_server_connects():+ servers = [{"name": "probe", "command": ["node", "srv.js"], "args": ["--x"], "env": {"TOKEN": "t"}},+ {"name": "remote", "url": "https://mcp.example/sse", "headers": {"Authorization": "Bearer b"}}]+ with tempfile.TemporaryDirectory() as d:+ _, _, cfg = _build(d, mcp_servers=servers)+ agent = cfg["agents"]["zeroclaw"]+ assert agent["acp_enable_mcp"] is True and agent["mcp_bundles"] == ["hr"]+ assert cfg["mcp_bundles"]["hr"]["servers"] == ["probe", "remote"]+ stdio, sse = cfg["mcp"]["servers"]+ assert stdio == {"name": "probe", "transport": "stdio", "command": "node", "args": ["srv.js", "--x"],+ "env": {"TOKEN": "t"}}+ assert sse["transport"] == "sse" and sse["url"] == "https://mcp.example/sse"+ # a file that can hold a server's bearer token never rides the checkpoint+ assert "./.harness/zeroclaw/config.toml" in srv.CHECKPOINT_EXCLUDE+++def test_a_lost_conversation_is_reported_and_a_kept_one_is_not():+ with tempfile.TemporaryDirectory() as d:+ db = pathlib.Path(d) / ".harness" / "zeroclaw" / "data" / "sessions" / "acp-sessions.db"+ assert srv._resume_lost("zeroclaw", [], "abc", d) == "abc" # no store at all+ db.parent.mkdir(parents=True)+ con = sqlite3.connect(db)+ con.execute("CREATE TABLE acp_sessions (id INTEGER PRIMARY KEY, session_uuid TEXT NOT NULL UNIQUE)")+ con.execute("INSERT INTO acp_sessions (session_uuid) VALUES ('abc')")+ con.commit(); con.close()+ assert srv._resume_lost("zeroclaw", [], "abc", d) is None+ assert srv._resume_lost("zeroclaw", [], "other", d) == "other"+++def test_instructions_and_skills_land_where_zeroclaw_reads_them():+ with tempfile.TemporaryDirectory() as d:+ assert srv._agent_doc_path(d, "zeroclaw") == pathlib.Path(d, ".harness", "zeroclaw", "agent", "AGENTS.md")+ installed = srv._write_skills(d, [{"name": "probe-skill", "content": "# probe\n\nSay PROBE.\n"}],+ backend="zeroclaw")+ assert (pathlib.Path(d) / ".harness" / "zeroclaw" / "agent" / "skills" / "probe-skill" / "SKILL.md").is_file()+ assert installed+++def test_the_backend_is_registered_with_the_passthrough_normaliser():+ spec = srv.BACKENDS["zeroclaw"]+ assert spec["normalize"] is srv._claude_passthrough+ assert set(spec["providers"]) == srv.ZEROCLAW_PROVIDERS+ assert not set(srv._ZEROCLAW_NEVER) & set(srv.ALL_ZEROCLAW_TOOLS)+++# ── found reviewing #456 on the review instance (0.34.0-rc.1, 2026-10-14) ───────────────────────++def test_a_turn_that_reaches_the_step_budget_says_so():+ """zeroclaw summarises and stops with `end_turn` at max_tool_iterations, appending its own note;+ the turn read as a finished one where every other base reports the step budget."""+ with tempfile.TemporaryDirectory() as d:+ fx = pathlib.Path(d) / "capped.ndjson"+ fx.write_text(json.dumps({"jsonrpc": "2.0", "id": "PROMPT", "result": {+ "content": "Made a.txt and b.txt.\n\n*Turn stopped: reached maximum tool iterations (2).*",+ "sessionId": "s", "stopReason": "end_turn"}}) + "\n")+ events, _, rc = _run(pathlib.Path(d), {"prompt": str(fx)})+ assert rc == 0 and events[-1]["subtype"] == "error_max_turns" and events[-1]["is_error"] is False+ assert "Made a.txt" in events[-1]["result"]+++def test_the_shell_reaches_any_path_its_user_can_and_skills_keep_their_scripts():+ """zeroclaw's defaults refused /etc, /usr and an environment's /env as "forbidden absolute paths+ outside the workspace", and skipped the Office skill for its install.sh."""+ with tempfile.TemporaryDirectory() as d:+ _, _, cfg = _build(d)+ rp = cfg["risk_profiles"]["hr"]+ assert rp["workspace_only"] is False and rp["forbidden_paths"] == []+ assert cfg["skills"]["allow_scripts"] is True+++def test_no_tool_lets_the_model_pick_another_model_or_hand_back_a_second_copy():+ with tempfile.TemporaryDirectory() as d:+ _, _, cfg = _build(d)+ assert {"llm_task", "deliver_file"} <= set(cfg["risk_profiles"]["hr"]["excluded_tools"])+ assert not {"llm_task", "deliver_file"} & set(srv.ALL_ZEROCLAW_TOOLS)+++def test_the_turns_image_credential_reaches_the_shell_by_name():+ """The image skill answered "image generation is not configured for this Harness": its+ HR_IMAGE_* names were never passed to zeroclaw's shell."""+ with tempfile.TemporaryDirectory() as d:+ env = {"PATH": "/usr/bin", "HR_IMAGE_BASE_URL": "http://127.0.0.1:8080/v1/llm", "HR_IMAGE_KEY": "hrtc-x",+ "HR_IMAGE_MODEL": "gpt-image-2", "OFFICECLI_RESIDENT_FLUSH": "each"}+ srv._build_zeroclaw("openrouter", srv.Auth(api_key="sk-or-real", base_url="https://openrouter.ai/api/v1"),+ "anthropic/claude-haiku-4.5", "hi", d, env)+ text = (pathlib.Path(d) / ".harness" / "zeroclaw" / "config.toml").read_text()+ keys = tomllib.loads(text)["risk_profiles"]["hr"]["shell_env_passthrough"]+ assert {"HR_IMAGE_BASE_URL", "HR_IMAGE_KEY", "HR_IMAGE_MODEL"} <= set(keys) and "hrtc-x" not in text+ # officecli's write-through: without it seven deck turns handed back the empty file it created+ assert "OFFICECLI_RESIDENT_FLUSH" in keys+++def test_an_emoji_in_an_mcp_argument_leaves_the_config_readable():+ servers = [{"name": "probe", "command": ["node", "srv.js"], "args": ["--title", "launch \U0001F680"],+ "env": {"GREETING": "hi \U0001F44B"}}]+ with tempfile.TemporaryDirectory() as d:+ _, _, cfg = _build(d, mcp_servers=servers) # tomllib raised on the surrogate pair before+ sv = cfg["mcp"]["servers"][0]+ assert sv["args"] == ["srv.js", "--title", "launch \U0001F680"] and sv["env"]["GREETING"] == "hi \U0001F44B"+++def test_a_harness_variable_cannot_reach_zeroclaws_config_overrides():+ assert srv._caller_env({"ZEROCLAW_providers__models__custom__hr__uri": "http://evil", "STAMP": "x"}) == {"STAMP": "x"}+++def test_zeroclaws_state_rides_the_tar_and_not_the_checkpoint_repo():+ """Its three SQLite stores, trace log, persona files and copied skills were committed on every turn."""+ assert ".harness/zeroclaw/" in srv._STATE_DIRS+++def test_only_the_measured_tools_are_offered_and_none_means_none():+ """zeroclaw sent 34 tools with only an exclusion list (cron, channels, sessions, pushover, weather+ and more, captured 2026-10-14); `allowed_tools` is the list now, and an empty one is zeroclaw's+ "no constraint", so every tool turned off still leaves it closed."""+ with tempfile.TemporaryDirectory() as d:+ _, _, cfg = _build(d)+ assert cfg["risk_profiles"]["hr"]["allowed_tools"] == sorted(srv.ALL_ZEROCLAW_TOOLS)+ assert not {"delegate", "memory_store", "cron_add", "schedule", "sessions_history", "pushover"} & set(srv.ALL_ZEROCLAW_TOOLS)+ with tempfile.TemporaryDirectory() as d:+ _, _, cfg = _build(d, tools_disabled=list(srv.ALL_ZEROCLAW_TOOLS))+ assert cfg["risk_profiles"]["hr"]["allowed_tools"] == [srv._ZEROCLAW_NO_TOOLS]diff --git a/runner/zeroclaw_driver.py b/runner/zeroclaw_driver.pynew file mode 100644index 00000000..bcf5b2c7--- /dev/null+++ b/runner/zeroclaw_driver.py@@ -0,0 +1,250 @@+"""One zeroclaw turn, as a runner subprocess.++Spawned per turn by server.py (the one-process-per-turn contract every backend has: the runner reads+NDJSON off stdout, cancel is a process-group kill). Inside, zeroclaw's own ACP server — `zeroclaw+acp`, JSON-RPC 2.0 over stdio — is started as a child, driven through ONE prompt, and the+`session/update` notifications it streams are re-emitted as CLAUDE'S stream-json, which is why this+backend's normaliser in server.py is the passthrough (the nanobot_driver precedent).++WHY ACP AND NOT `zeroclaw agent -m`, measured on the pinned 0.8.5:++ * `agent -m` prints the final answer as prose: no tool calls, no tool results, nothing a turn+ record can show the work from.+ * `agent -m` forgets. Its `--session-state-file` is read only by the interactive REPL; a one-shot+ run starts from the system prompt and the one message every time, so a follow-up turn would+ answer from an empty history.+ * ACP keeps the conversation in a SQLite store under the config's data dir+ (data/sessions/acp-sessions.db), and `session/resume` in a LATER process seeds the agent with+ that history. Measured across two processes: the second named the file the first had written.++WHAT THIS DRIVER OWES THE TURN, and where each answer comes from:++ * the served model and the token split — the relay's taps. zeroclaw's ACP stream carries no usage+ at all (its TurnEvent::Usage maps to no notification) and names only the model it was ASKED for,+ so the result is emitted without usage and server.py fills both from the relay+ (_fill_relay_usage, _relay_served_model), which is why the key reaches zeroclaw through the+ ENVIRONMENT rather than config.toml.+ * continuity — the ACP session id. zeroclaw mints it (a UUID) on `session/new`; it is reported as+ the init event's session_id, the gateway keeps it as the CLI session id, and the next turn asks+ `session/resume` for it. An id the store does not hold is answered "Session not found" (-32000);+ the turn then starts a new session and server.py's _resume_lost says the history was lost.+ * nobody to ask. A runner turn has no person on the other end, so the config excludes the tools+ that call back to the client (ask_user, escalate_to_human, reaction, poll) and the risk profile+ is `full`. A request zeroclaw sends anyway is answered at once — a permission request with+ `cancelled`, anything else with "method not found" — rather than left to hang the turn.+ * a failure that reads as a failure — a JSON-RPC error on any request, a `cancelled` stop reason,+ or a stream that ends without a response. Each ends the turn as an error with the reason.+"""+from __future__ import annotations++import json+import re+import subprocess+import sys+import threading++_OUT = sys.stdout+# The one [agents.<alias>] server.py writes. zeroclaw names the agent after it in the persona files it+# seeds ("You are **hr**. That is your name."): an agent that introduced itself by the runner's own+# config key, so it carries the product's name.+_AGENT = "zeroclaw"+_SESSION_NOT_FOUND = -32000+# What zeroclaw appends to the answer when a turn reaches `max_tool_iterations` (its English locale,+# crates/zeroclaw-runtime/locales/en/cli.ftl `turn-max-iterations-reached`). It then asks the model+# for a summary and stops with `end_turn`, so the stop reason alone reads as a finished turn.+# MEASURED on 0.8.5 with a step budget of 2 and a five-file task: two files, the note, `end_turn`.+_MAX_ITERATIONS = re.compile(r"\*Turn stopped: reached maximum tool iterations \(\d+\)\.\*")+++def _emit(ev: dict) -> None:+ _OUT.write(json.dumps(ev, default=str) + "\n")+ _OUT.flush()+++def _fail(reason: str) -> None:+ _emit({"type": "result", "subtype": "error", "is_error": True, "result": reason[:1000], "usage": {}})+++class _Acp:+ """A JSON-RPC 2.0 client on a child's stdio: requests out, and every line in until the response+ to that request — notifications are handed to `on_update`, requests from the agent are answered."""++ def __init__(self, proc: subprocess.Popen, on_update) -> None:+ self.proc, self.on_update, self.next_id = proc, on_update, 0++ def _send(self, obj: dict) -> None:+ self.proc.stdin.write(json.dumps(obj) + "\n")+ self.proc.stdin.flush()++ def call(self, method: str, params: dict) -> dict:+ """→ the response object ({"result": …} or {"error": …}); {} when the stream ended first."""+ self.next_id += 1+ rid = self.next_id+ self._send({"jsonrpc": "2.0", "id": rid, "method": method, "params": params})+ for line in self.proc.stdout:+ line = line.strip()+ if not line:+ continue+ try:+ msg = json.loads(line)+ except ValueError:+ continue # not protocol: zeroclaw logs to its trace file, but never trust that+ if not isinstance(msg, dict):+ continue+ if msg.get("id") == rid and "method" not in msg:+ return msg+ if "method" in msg and "id" in msg:+ self._answer(msg)+ elif msg.get("method") == "session/update":+ self.on_update((msg.get("params") or {}).get("update") or {})+ return {}++ def _answer(self, req: dict) -> None:+ if req.get("method") == "session/request_permission":+ self._send({"jsonrpc": "2.0", "id": req["id"], "result": {"outcome": {"outcome": "cancelled"}}})+ else:+ self._send({"jsonrpc": "2.0", "id": req["id"],+ "error": {"code": -32601, "message": f"not supported by this client: {req.get('method')}"}})+++class _Turn:+ """session/update → claude stream-json."""++ def __init__(self) -> None:+ self.text = ""++ def update(self, u: dict) -> None:+ kind = u.get("sessionUpdate")+ if kind == "agent_message_chunk":+ t = _chunk_text(u)+ if t:+ self.text += t+ _emit({"type": "assistant", "message": {"content": [{"type": "text", "text": t}]}})+ elif kind == "agent_thought_chunk":+ t = _chunk_text(u)+ if t:+ _emit({"type": "assistant", "message": {"content": [{"type": "thinking", "thinking": t}]}})+ elif kind == "tool_call":+ raw = u.get("rawInput")+ _emit({"type": "assistant", "message": {"content": [+ {"type": "tool_use", "id": str(u.get("toolCallId") or "tool"),+ "name": str(u.get("name") or u.get("title") or "tool"),+ "input": raw if isinstance(raw, dict) else {}}]}})+ elif kind == "tool_call_update" and u.get("status") in ("completed", "failed"):+ # Only the terminal update is a result; an in-progress update carries partial output the+ # final one repeats.+ body = u.get("rawOutput")+ if not isinstance(body, str):+ body = u.get("body") if isinstance(u.get("body"), str) else json.dumps(body, default=str)+ _emit({"type": "user", "message": {"content": [+ {"type": "tool_result", "tool_use_id": str(u.get("toolCallId") or "tool"),+ "is_error": u.get("status") == "failed", "content": (body or "")[:8000]}]}})+ # plan, history_trimmed and the rest are progress for an IDE, not part of the transcript+++def _chunk_text(u: dict) -> str:+ c = u.get("content")+ if isinstance(c, dict):+ return str(c.get("text") or "")+ if isinstance(c, list):+ return "".join(str(x.get("text") or "") for x in c if isinstance(x, dict))+ return ""+++def _err(resp: dict) -> str:+ e = resp.get("error") or {}+ return str(e.get("message") or e or "zeroclaw returned an error")+++def _run(job: dict) -> int:+ cwd = job["cwd"]+ proc = subprocess.Popen([job["zeroclaw"], "acp", "--config-dir", job["config_dir"]],+ stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=None,+ text=True, cwd=cwd, bufsize=1)+ turn = _Turn()+ acp = _Acp(proc, turn.update)+ try:+ r = acp.call("initialize", {"protocolVersion": 1, "clientCapabilities": {}})+ if "result" not in r:+ _fail(_err(r) if r else "")+ return 1+ sid = ""+ resume = str(job.get("resume_session_id") or "")+ if resume:+ r = acp.call("session/resume", {"sessionId": resume})+ if "result" in r:+ sid = resume+ elif (r.get("error") or {}).get("code") != _SESSION_NOT_FOUND:+ _fail(_err(r) if r else "")+ return 1+ # not found: a new session below, and server.py's _resume_lost says so on the turn+ if not sid:+ r = acp.call("session/new", {"cwd": cwd, "agentAlias": _AGENT})+ if "result" not in r:+ _fail(_err(r) if r else "")+ return 1+ sid = str(r["result"].get("sessionId") or "")+ _emit({"type": "system", "subtype": "init", "session_id": sid, "model": str(job.get("model") or "")})+ r = acp.call("session/prompt", {"sessionId": sid,+ "prompt": [{"type": "text", "text": str(job.get("prompt") or "")}]})+ if not r:+ # The stream ended without an answer. Empty text, so the runner's stderr tail is the+ # reason rather than a sentence invented here (nanobot_driver's rule).+ _fail("")+ return 1+ if "error" in r:+ _fail(_err(r))+ return 1+ res = r.get("result") or {}+ stop = str(res.get("stopReason") or "")+ # `content` is the turn's final answer (the text after its last tool call), so it is+ # authoritative over what the chunks assembled.+ answer = str(res.get("content") or turn.text)+ if stop not in ("", "end_turn"):+ _emit({"type": "result", "subtype": "error", "is_error": True, "result": answer or stop,+ "reason": stop, "usage": {}})+ return 1+ if _MAX_ITERATIONS.search(answer):+ # the step budget, as every base reports it: the turn stopped, it did not fail+ _emit({"type": "result", "subtype": "error_max_turns", "is_error": False, "result": answer, "usage": {}})+ return 0+ _emit({"type": "result", "subtype": "success", "is_error": False, "result": answer, "usage": {}})+ return 0+ finally:+ try:+ proc.stdin.close()+ except OSError:+ pass+ _reap(proc)+++def _reap(proc: subprocess.Popen) -> None:+ """zeroclaw exits when its stdin closes; one that does not is killed rather than outliving the turn."""+ t = threading.Timer(20, proc.kill)+ t.start()+ try:+ proc.wait()+ finally:+ t.cancel()+++def main() -> int:+ try:+ job = json.loads(sys.argv[1])+ except Exception as e: # noqa: BLE001+ print(f"zeroclaw driver: bad job: {e}", file=sys.stderr)+ return 2+ try:+ return _run(job)+ except KeyboardInterrupt:+ return 130+ except Exception as e: # noqa: BLE001+ # The exception text is the only reason anybody will have, so it goes to stderr (which the+ # runner collects into the turn's failure reason) AND the turn is failed explicitly.+ print(f"zeroclaw driver: {type(e).__name__}: {e}", file=sys.stderr)+ _fail(f"{type(e).__name__}: {e}")+ return 1+++if __name__ == "__main__":+ raise SystemExit(main())diff --git a/scripts/support-matrix/custom-harness.mjs b/scripts/support-matrix/custom-harness.mjsindex 0e61012a..77ce09f9 100644--- a/scripts/support-matrix/custom-harness.mjs+++ b/scripts/support-matrix/custom-harness.mjs@@ -14,7 +14,7 @@ import { chromium } from 'playwright';import crypto from 'node:crypto';const BASE = process.env.BASE;-const BASES = (process.env.BASES || 'codex,claude-code,hermes,pi,dsh,opencode,kilo,qwen,gemini,cline,omp,goose,kimi,minimax,grok,aider,openhands,cheetahclaws,agentzero,mimo,jcode,opensquilla,nanobot,qoder').split(','); // every built-in chat harness, all nineteen (systemone runs decision models only)+const BASES = (process.env.BASES || 'codex,claude-code,hermes,pi,dsh,opencode,kilo,qwen,gemini,cline,omp,goose,kimi,minimax,grok,aider,openhands,cheetahclaws,agentzero,mimo,jcode,opensquilla,nanobot,zeroclaw,qoder').split(','); // every built-in chat harness, all nineteen (systemone runs decision models only)const RESULTS = process.env.RESULTS || 'results-custom.json';// A harness's other kind of tool is an MCP server. A self-contained instance hosts only the// database and media servers, one needing a database and the other costing real money per call, so@@ -122,7 +122,8 @@ const results = {};// grok's and minimax's names alone picked `text_editor` — the tool the fixture writes with.// opensquilla and nanobot name theirs `exec` (and nanobot has `exec_session` too), which `execute`// does not match — so the list would have withheld the tool the fixture runs its script with.-const NEEDED_ID = /^(bash|shell|exec|exec_session|execute|run_command|run_terminal_command|terminal|code_execution_tool|python.*|node.*|read|read_file|write|write_file|edit|file_edit(or)?|text_editor|str_replace.*|create_file|view|search_replace|apply_patch|glob|grep|list_dir|ls|skills?_?tool|skill|task|search_tool|use_tool|mcp.*)$/i;+// zeroclaw names its file tools `file_read` and `file_write` (and `file_edit`, already matched).+const NEEDED_ID = /^(bash|shell|exec|exec_session|execute|run_command|run_terminal_command|terminal|code_execution_tool|python.*|node.*|read|read_file|file_read|write|write_file|file_write|edit|file_edit(or)?|text_editor|str_replace.*|create_file|view|search_replace|apply_patch|glob|grep|list_dir|ls|skills?_?tool|skill|task|search_tool|use_tool|mcp.*)$/i;const PREFERRED = /^(todo_write|todowrite|todo|web_?fetch|web_?search|browser.*|board_.*|link_pr|goal|wait)$/i;const pickDisabled = (tools) => {const names = (tools || []).map((t) => String((t && t.name) || t || '')).filter(Boolean);diff --git a/scripts/support-matrix/plugins/run-matrix.py b/scripts/support-matrix/plugins/run-matrix.pyindex eb66cfbe..883e488f 100755--- a/scripts/support-matrix/plugins/run-matrix.py+++ b/scripts/support-matrix/plugins/run-matrix.py@@ -47,7 +47,9 @@ BASES = ["claude-code", "codex", "hermes", "goose", "gemini", "qwen", "opencode"# MCP client at all ("HTTP/SSE entries are recognized and skipped with a log line")# and opensquilla takes stdio and SSE but not streamable HTTP, so both are in# _BRIDGED_TRANSPORTS and a remote column measures the bridge on them.- "mimo", "jcode", "opensquilla", "nanobot"]+ "mimo", "jcode", "opensquilla", "nanobot",+ # zeroclaw takes stdio, http and sse servers natively ([[mcp.servers]] `transport`)+ "zeroclaw"]NO_STDIO: set[str] = set()# The public probe the remote columns call: its SSE end answers PROBE-SSE-<id>, its streamable-HTTP# end PROBE-HTTP-<id>. Both are the same fixed server, so a wrong answer is the base, not the probe.diff --git a/ui/public/logos/zeroclaw.png b/ui/public/logos/zeroclaw.pngnew file mode 100644index 00000000..080bca2bBinary files /dev/null and b/ui/public/logos/zeroclaw.png differdiff --git a/ui/src/components/HarnessLogo.tsx b/ui/src/components/HarnessLogo.tsxindex 10e33c28..4dd57fe3 100644--- a/ui/src/components/HarnessLogo.tsx+++ b/ui/src/components/HarnessLogo.tsx@@ -29,6 +29,7 @@ const LOGO: Record<string, string> = {jcode: '/logos/jcode.png', // jcode's own app icon (assets/app-icons/Jcode.icns in the MIT 1jehuang/jcode repository), the 1024 px face resized. It is a BLACK mark on transparency, so it carries no contrast on a dark surface — upstream ships no light variantopensquilla: '/logos/opensquilla.png', // the OpenSquilla mark (assets/opensquilla-mark.png in the Apache-2.0 TokenRhythm/opensquilla repository), already squarenanobot: '/logos/nanobot.svg', // the nanobot mark (images/nanobot_mark.svg in the MIT HKUDS/nanobot repository); an SVG like cursor.svg, which this map already serves+ zeroclaw: '/logos/zeroclaw.png', // ZeroClaw's own mark, the ice crab: the zeroclaw-labs organization's avatar on GitHub (the same mascot leads its README and zeroclaw.com), cut square above its name band and scaled to 192 px so it reads at 26 px. The armored crab in the v0.8.5 dashboard (web/dist/logo.png) is an older mark (Richard, 2026-10-14)mimo: '/logos/mimo.png', // Xiaomi MiMo's own square mark: the site icon of mimo.xiaomi.com (the "Xiaomi" over "MiMO" wordmark, white on black) is 32 px only, so it is drawn again at 192 px from the full-size wordmark that mimo.xiaomi.com/coder serves (coder/assets/logo.png), in the same layout (Richard, 2026-10-12)};diff --git a/ui/src/lib/harness.ts b/ui/src/lib/harness.tsindex 3c62d930..40020630 100644--- a/ui/src/lib/harness.ts+++ b/ui/src/lib/harness.ts@@ -20,7 +20,7 @@ export interface OobHarness {defaultModel?: string; // the backend default, NOT necessarily models[0]moreModels?: number; // "+N" pillstatus: 'ready' | 'soon';- backend: 'claude' | 'codex' | 'hermes' | 'pi' | 'dsh' | 'opencode' | 'kilo' | 'qwen' | 'gemini' | 'cline' | 'omp' | 'goose' | 'kimi' | 'minimax' | 'aider' | 'openhands' | 'grok' | 'systemone' | 'cheetahclaws' | 'agentzero' | 'mimo' | 'jcode' | 'opensquilla' | 'nanobot' | 'qoder' | null; // gateway backend; null = coming soon+ backend: 'claude' | 'codex' | 'hermes' | 'pi' | 'dsh' | 'opencode' | 'kilo' | 'qwen' | 'gemini' | 'cline' | 'omp' | 'goose' | 'kimi' | 'minimax' | 'aider' | 'openhands' | 'grok' | 'systemone' | 'cheetahclaws' | 'agentzero' | 'mimo' | 'jcode' | 'opensquilla' | 'nanobot' | 'zeroclaw' | 'qoder' | null; // gateway backend; null = coming soonsystemPrompt: string; // the harness's built-in system prompt (shown read-only)tools: string[]; // built-in tools (read-only)skills: string[]; // built-in skills (read-only)@@ -244,6 +244,11 @@ export const OOB: OobHarness[] = [models: ['gpt-6.1-sol', 'gpt-6-sol', 'gpt-6-luna', 'gpt-5.6-sol', 'gpt-5.6-terra', 'gpt-5.5', 'gpt-5.4', 'gpt-5.4-mini', 'gpt-5.2', 'claude-fable-5-1', 'claude-fable-5', 'claude-opus-5.5', 'claude-opus-5', 'claude-sonnet-5.5', 'claude-sonnet-5', 'claude-opus-4.8', 'claude-opus-4.7', 'claude-sonnet-4.6', 'claude-haiku-5.5', 'claude-haiku-4.5', 'gemini-3.8-flash', 'gemini-3.7-flash', 'gemini-3.6-flash', 'gemini-3.5-flash', 'gemini-3.5-flash-lite', 'gemini-3.1-pro-preview', 'gemini-3.1-flash-lite', 'gemini-3-flash-preview', 'grok-4.6', 'grok-4.3', 'grok-4.20', 'muse-spark-1.3', 'muse-spark-1.2', 'muse-spark-1.1', 'muse-glimmer-30b', 'deepseek-v4.1-flash', 'deepseek-v4-pro', 'deepseek-v4-flash', 'kimi-k2.7-code', 'qwen3.8-max', 'qwen3.8-flash', 'qwen3.8-27b', 'qwen3.7-max', 'qwen3.7-plus', 'glm-5.3', 'glm-5.3-flash', 'mistral-medium-3.5', 'step-3.7-flash', 'hunyuan-4-preview', 'nemotron-3.5-lightning'], defaultModel: 'gpt-5.4', moreModels: 0,systemPrompt: 'You are nanobot, an autonomous agent. You work on a real git workspace with shell and file access, reading and editing files and running commands to complete the task end to end.',tools: [], skills: [] },+ { id: 'zeroclaw', name: 'ZeroClaw', version: 'v0.8.5', backend: 'zeroclaw', status: 'ready',+ // Placeholder only; the chat-completions list, for jcode's reason.+ models: ['gpt-6.1-sol', 'gpt-6-sol', 'gpt-6-luna', 'gpt-5.6-sol', 'gpt-5.6-terra', 'gpt-5.6-luna', 'gpt-5.5', 'gpt-5.4', 'gpt-5.4-mini', 'gpt-5.2', 'claude-fable-5-1', 'claude-fable-5', 'claude-opus-5.5', 'claude-opus-5', 'claude-sonnet-5.5', 'claude-sonnet-5', 'claude-opus-4.8', 'claude-opus-4.7', 'claude-sonnet-4.6', 'claude-haiku-5.5', 'claude-haiku-4.5', 'gemini-3.8-flash', 'gemini-3.7-flash', 'gemini-3.6-flash', 'gemini-3.5-flash', 'gemini-3.5-flash-lite', 'gemini-3.1-pro-preview', 'gemini-3.1-flash-lite', 'gemini-3-flash-preview', 'grok-4.6', 'grok-4.5', 'grok-4.3', 'grok-build-0.1', 'muse-spark-1.3', 'muse-spark-1.2', 'muse-spark-1.1', 'muse-glimmer-30b', 'deepseek-v4.1-flash', 'deepseek-v4-pro', 'deepseek-v4-flash', 'kimi-k3', 'kimi-k2.7-code', 'qwen3.8-max', 'qwen3.8-27b', 'qwen3.7-max', 'qwen3.7-plus', 'glm-5.3', 'glm-5.3-flash', 'mistral-medium-3.5', 'step-3.7-flash', 'hunyuan-4-preview', 'nemotron-3.5-lightning'], defaultModel: 'gpt-5.4', moreModels: 0,+ systemPrompt: 'You are ZeroClaw, an autonomous agent. You work on a real git workspace with shell and file access, reading and editing files and running commands to complete the task end to end.',+ tools: [], skills: [] },];export const oobById = (id: string) => OOB.find((o) => o.id === id) || null;@@ -268,7 +273,7 @@ export const INSTRUCTION_FILE: Record<string, string> = {const AGENTS_MD_BASES = ['codex', 'hermes', 'omp', 'pi', 'opencode', 'kilo', 'dsh', 'qwen', 'cline', 'goose', 'kimi','minimax', 'aider', 'openhands', 'grok', 'agentzero',- 'mimo', 'jcode', 'opensquilla', 'nanobot',+ 'mimo', 'jcode', 'opensquilla', 'nanobot', 'zeroclaw',];export function instructionFileLabel(baseId: string | null | undefined): string {const id = baseId || '';