feat(agents): add opencode support - #315
Conversation
Adds opencode (pkgs.opencode, MIT — no unfree allowance needed) as a third supported agent CLI alongside claude and codex. Resume identity works like codex's: since opencode has no --session-id equivalent, the kickoff prompt is stamped with a "[agent-box session <bid>]" marker and a respawn looks it up again. Unlike codex's per-session rollout files, every opencode session lives in one shared SQLite database, so the lookup goes through opencode's own `db` query subcommand instead of a grep (verified live against opencode 1.18.18, fully offline, no provider configured — the TUI writes the kickoff prompt into that database before it would ever reach a model). remoteControl is deliberately ignored for opencode (MVP): it has no vendor pairing app, so sessions are reachable only through the browser terminal or a local tmux attach. Settings-page transcript download is scoped out and filed separately as #314: opencode's shared-database session store doesn't fit the one-file-per-session model every other transcript_of branch assumes. tests/sessions.nix exercises the new agent against the real opencode binary (no stub) — AGENTS.md seeding, session add/rm, and the kickoff/ resume marker round-trip. tests/golden updated via `nix run .#update-golden` for the new agent showing up in AGENT_BOX_AGENT_BINS/PATH and the two source-file comments it touches. Closes #80. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AMbiL3ux2XbUTrGQqP15U1
CI (run 32513310738) showed the resume path working correctly — it found
the stamped session and passed --session ses_... — but the test's own
assertion was too broad: it checked "agent-box session" not in the resumed
command, and the default resume steer prompt's own wording ("...restarted
(agent-box session <bid>)...") legitimately contains that bare phrase
without brackets. Only the bracketed "[agent-box session <bid>]" MARKER
should be absent on a successful resume; check for that specifically.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AMbiL3ux2XbUTrGQqP15U1
|
Heads-up from #317, which just merged: master's Relevant to opencode specifically: the settings page now has guided sign-in cards driven by a table in the settings daemon ( |
Summary
Adds
opencode(pkgs.opencode, MIT — no unfree allowance needed) as athird supported agent CLI alongside
claudeandcodex. Closes #80.supportedAgents,agentPackage, option docs/enums: opencode joins theclaude/codexset everywhere it's data-driven (installAgents, thesettings page's session UI,
agent-box-session, AWSAgentparameter).--session-idto mint up front, same problem codex has): stamp[agent-box session <bid>]into the kickoff prompt, then find it againon respawn. Codex greps its per-session rollout files for the marker;
opencode keeps every session (across every session name and working
directory) in ONE shared SQLite database, so the lookup goes through
opencode's own
dbquery subcommand instead — no new sqlite dependency.Verified live against opencode 1.18.18, fully offline with no provider
configured: the TUI writes the kickoff prompt into that database as soon
as it starts, well before it would ever reach a model — which is also
what makes
tests/sessions.nix's new subtest able to exercise thisagainst the real binary instead of a stub.
plan from Add opencode support #80's feasibility comment): no vendor pairing app exists yet,
so an opencode session is reachable only through the browser terminal or
a local
tmuxattach.opencode serve/webbehind the box's own Caddyfront end could stand in for it later — a separate product decision.
settings page: opencode transcript download #314:
transcript_ofassumes one file per session (claude's.jsonl,codex's per-rollout file), and opencode's shared-database store doesn't
fit that shape without an on-demand export step.
settings-daemon.py'scomments point at settings page: opencode transcript download #314 instead of promising it here.
Test plan
python3 bin/assemble-module.py—modules/agent-box.nixregeneratednix build .#checks.aarch64-linux.{module-generated-up-to-date,module-single-file,assemble-module-escaping,golden-snapshot,multi-user,download-route,webhook-route}— all greennix run .#update-golden— reviewed the diff (opencode joiningAGENT_BOX_AGENT_BINS/PATH, the two source comments it touches) and committed itnix eval .#checks.x86_64-linux.*.drvPathfor every x86-only VM test (this box is aarch64, can't build/run them) — all evaluate cleanly, no Nix errors~/bin/check-testscript.sh tests/sessions.nix(the driver's ownty/ruffgates) — cleancfn-lint aws/template.yaml— clean, same as mastershellcheck modules/src/supervisor.sh— no new warnings from the added function/case branchtests/sessions.nixsubtests added: opencode binary installed,agent-box-session add --agent opencode, AGENTS.md seeding, and the kickoff-prompt-marker / resume-by-session-id round trip against the real opencode binary (not evaluatable on this aarch64 box beyond eval-check — needs a maintainer's x86 CI run)🤖 Generated with Claude Code
https://claude.ai/code/session_01AMbiL3ux2XbUTrGQqP15U1