feat(harness): support managed OpenCode v2.1.4
OpenCode v2.1.4 cannot start a managed Dagu session: its server banner and health endpoint changed, and the v1 session/message/permission APIs no longer match. Add a version-selected v2 protocol adapter while retaining the existing v1 path.
- Recognize the v2 server, configure its password, and validate sharing through its ordered config documents.
- Adapt session creation, model/agent selection, prompts and command templates, paginated messages, cancellation, cleanup, permissions, and built-in question forms.
- Normalize v2 results into Dagu's existing runtime/UI contract and reconcile v2 interaction events.
- Pin @opencode/cli 2.1.4 alongside opencode-ai 1.18.11 in compatibility CI and document version-specific CLI and managed-command limitations.
Validation:
- Real OpenCode v2.1.4 binary with a local deterministic OpenAI-compatible provider: prompt, command template, permission approval, question answer/resume, and session deletion (race detector enabled).
- Real OpenCode v1.18.11 host capability regression.
- Affected host, harness, and configuration package tests with the race detector.
- Harness conformance suite: 32 tests passed.
- make fmt and make check, including native, Windows, and Darwin lint.
Scope: managed v2 commands must submit a prompt in the current session (such as template commands); settings-only and subagent-only commands cannot supply a harness result. The form adapter targets built-in question-tool forms. Native v2 CLI flags follow upstream behavior; v1-only --command/--variant flags are documented rather than silently rewritten.
Summary by cubic
OpenCode v2.1.4 cannot start a managed Dagu session: its server banner and health endpoint changed, and the v1 session, message, and permission APIs no longer match. This adds a version-selected v2 protocol adapter while keeping the v1 path intact. CI now pins @opencode/cli 2.1.4 alongside opencode-ai 1.18.11.
Scope and limitations
- A managed v2 command must submit a prompt in the current session, as template commands do; settings-only and subagent-only commands cannot produce a harness result.
- Built-in question-tool forms are supported through the existing question interface; v1-only
--commandand--variantflags are documented, not rewritten. - For v2,
variantrequiresmodel(or usemodel: provider/model#variant), andOPENCODE_PASSWORDis now a reserved env passthrough variable.
Summary by CodeRabbit
- New Features
- Managed OpenCode sessions now support version 2, including message history, commands, permissions, and question forms.
- OpenCode 2.x sessions support model and variant configuration.
- Bug Fixes
OPENCODE_PASSWORDis now rejected in OpenCode environment passthrough settings.
- Documentation
- Added compatibility and setup guidance for supported OpenCode versions, including v2 configuration and command requirements.