feat(agents): support agents whose harness you run yourself
Problem
Buzz only supports agents it can spawn. If your agent already runs somewhere else — a container on your own VPS, a remote box — there's no way to add it.
Why the harness moves, not the transport
The relay connection lives in buzz-acp, not in the vendor agent (relay.rs:3825 do_connect dials out over WebSocket). The agent leg is local stdio NDJSON JSON-RPC and nothing else — AcpClient is bound to ChildStdin/ChildStdout (acp.rs:139-176), with no Transport trait to slot a network implementation into.
So the answer is to run buzz-acp next to the agent, not to reach the agent over the network. Exposing the agent's own API to the desktop wouldn't help anyway: buzz-acp declares the buzz CLI as an MCP server and the agent spawns it (lib.rs:4179-4232), so tools execute wherever the agent runs either way — you'd get a WAN hop per JSON-RPC frame and no savings. The OpenClaw preset already documents this trap.
What actually blocks the user is identity, not networking. The agent keypair is generated in the desktop (commands/agents.rs:632) and the NIP-OA auth tag is signed by the owner's key (:665-676) — that tag is what makes the relay admit the agent (MembershipDecision::ViaOwner). A container cannot self-mint it.
What this adds
BackendKind::External: Buzz mints the identity and publishes the kind:0 profile — so the agent appears as a real community member before the container ever runs — then hands over a copy-pasteable env block. It never spawns, deploys, stops, or reads logs. Liveness comes from relay presence alone.
Generic across all harnesses. Hermes is the first caller, not a special case.
Out of scope, deliberately: the provider-binary deploy path (buzz-backend-ssh/-tailscale). The existing BackendKind::Provider protocol already supports that with zero Rust changes — it's a follow-up.
No changes to crates/buzz-acp. Verified unnecessary: resolve_agent_owner (lib.rs:117-143) verifies BUZZ_AUTH_TAG locally via verify_auth_tag — no network, no owner discovery.
Notable implementation details
Only 4 Rust guard sites changed. External is non-Local and every non-Local branch that matters already pattern-matches Provider, so ~24 existing guards were correct as-is. The four that weren't:
| Site | Problem |
|---|---|
runtime.rs:149 |
backend_agent_id is always None, so the provider mapping pinned External to not_deployed forever. Extracted to a pure, testable remote_backend_status. |
agents.rs:1125 |
External fell into StartTarget::Provider; build_deploy_payload succeeds (it never checks backend) and hits the keyring, so a start that was never valid failed with a misleading key error. Now an exhaustive match, so the next variant breaks the build here. |
agents.rs:1002, :1030 |
!= Local tests made External take a provider-only path (store lock + 3 disk reads for nothing). |
Env-block assembly deliberately does not reuse build_deploy_payload. That builds provider-protocol JSON from user env layers only — it never calls resolve_effective_harness_descriptor, so it omits the harness-definition env floor and runtime-metadata vars, and its own doc comment admits agent_args is pinned at create time. New external_env.rs reuses the authoritative resolvers instead, so the exported block and a local spawn of the same record cannot disagree.
Two subtleties worth a reviewer's eye:
meta.default_env(e.g.GOOSE_MODE=auto) is spawn-only and not indescriptor.env— a naive "just use the descriptor" would silently drop it. Spawn applies it only when absent from the desktop's own env so an operator's shell can override; a container inherits nothing, so that guard inverts and the default is applied unconditionally.- Conversely
runtime_metadata_env_varsandbaked_build_envare already indescriptor.env, so copying those spawn-site writes would have been redundant.
Host-specific values are excluded with a documented reason per group: absolute command paths (commands are emitted bare so the container resolves them on its own PATH), PATH/RUST_LOG, GIT_CONFIG_*, and the BUZZ_MANAGED_AGENT ownership stamps — emitting those last would make the orphan sweep try to reap the container.
Accepted debt, flagged in-code: there are now two env assemblers that can drift. Mitigated with a cross-reference comment, the same discipline readiness.rs:25-39 already uses. Extracting a shared assembler out of a 500-line function that also creates log files and spawns was judged the larger risk. Worth revisiting at a third consumer.
Security
Revealing an agent nsec to the frontend is the already-established posture — SecretRevealDialog renders privateKeyNsec verbatim on every create, and commands::identity::get_nsec exports the owner's nsec with no re-auth. This adds one thing: repeatability, which is required because the user rebuilds the container.
Guards: the command refuses any backend but External (without it this is a generic nsec-export endpoint for local agents, reachable by pubkey); spawn_key_refusal fails closed on a keyring outage; the response type deliberately has no Debug derive; and the frontend copies NsecRevealRow — plain useState, never React Query, so the secret never enters the query cache, cleared on collapse and unmount behind a late-resolve guard.
render_env_file emits values unquoted on purpose: --env-file does no quote or escape processing, so quoting would corrupt values rather than protect them. Safety comes from upstream POSIX key validation, which is why the test asserts lines().count() == env.len() — that's the injection check.
Two bugs the E2E test caught
Both are fixed here, and both are the reason the spec was worth writing:
- A third ungated start control.
canBuzzControlManagedAgentcovered the profile panel and members sidebar, but the agents-view card renders its own start button viaAgentRuntimeAvatarControl— external agents offered a Start that the backend refuses. It now takescanStartand hides the affordance (errors stay reachable). - The env block first landed in dead code.
ManagedAgentRowis imported only byAgentGroupRows, which nothing imports. The live surface is the profile panel's Runtime tab, which is where it lives now. (Deleting those two dead files is a separate cleanup — not in this PR.)
Verification
All 7 just ci steps pass: check, test-unit, desktop-test, desktop-build, desktop-tauri-check, desktop-tauri-test, web-build. Rust 1905 tests, frontend 3787, integration E2E 162 passed.
Two pre-existing failures, not from this change — each confirmed by re-running on a stashed tree:
just mobile-test—channel_detail_page_test.dart"keeps follow mode off while a tall newest message stays visible". This is why a fulljust ciexits non-zero.- 5 integration E2E specs, 4 of which need a live relay.
End-to-end, manual: create with "Somewhere I run myself" → agent appears as a member before the container runs (proves profile publish is backend-independent) → docker run --env-file → relay accepts NIP-42 AUTH (success proves the auth tag verified) → status external with a green PresenceDot, no Start button, no log pane.
Housekeeping notes for maintainers
commands/agents_archive.rsandshared/api/tauriAgentBackends.tsare pure extractions to satisfy the file-size ratchet, following the existingagents_deploy.rsprecedent. No behavior change.- Design spec committed at
docs/superpowers/specs/2026-07-30-external-agent-backend-design.md. - Unrelated, noticed while working: cargo can't fetch the private
mesh-llm-clientdep with its bundled libgit2 (git ls-remoteworks fine); every Rust command neededCARGO_NET_GIT_FETCH_WITH_CLI=true. Adding[net] git-fetch-with-cli = trueto.cargo/config.tomlwould fix it for everyone. Not done here — unrelated to this feature.