Repository navigation
feat(opencode): support native OpenCode v2 provider - #131
Merged
Merged
Conversation
Awen's OpenCode provider still spoke the OpenCode 1 server contract: it waited for the `opencode server listening` banner, called v1 root HTTP routes, and assumed no server authentication. OpenCode 2 prints `server listening on <url>`, serves its API under `/api/*`, and requires a server password, so every managed server start ended in `Timed out waiting for OpenCode server start after 30000ms` (issue #125). Port the native v2 integration (adapting pingdotgg/t3code#13008 / gidorah/t3code#3) and drop v1 (ADR-0021): - Replace the v1 `@opencode-ai/sdk` with the official `@opencode/client`, pinned to 2.0.12, and raise MINIMUM_OPENCODE_VERSION to 2.0.12. - Parse the v2 ready line with a tolerant `server listening on <url>` match instead of requiring the v1 prefix, and stop assuming the URL arrives newline-terminated. - Probe health through `server.info`, and load providers, models, agents, skills, and commands through the v2 client with the Workspace directory. - Generate a per-server password for managed servers, inject it as `OPENCODE_PASSWORD`, authenticate with Basic auth, and redact it from startup diagnostics. - Delete the v1 CLI-parser inventory fallback and its tests; rewrite the runtime, provider, adapter, and text-generation tests against native v2 execution/inbox events; add an opt-in real-binary integration test that also proves the managed server rejects unauthenticated requests. Awen-specific provider presentation (`approvalRequestKinds`) and `@awen/*` scopes are preserved. The upstream merged ready-line band-aid (pingdotgg/t3code#13651) is superseded. Machines on OpenCode 1.x must upgrade to 2.0.12 or newer. Refs #125
OpenCode v2 prints its serve banner before its provider registry finishes loading, so `/api/provider` and `/api/model` can briefly report nothing. `checkOpenCodeProviderStatus` read that empty inventory once and cached a false "did not report any connected upstream providers" warning with 0 models on the first check after startup, even though a later refresh showed the providers. Poll the inventory until providers and models are both present, or a bounded wall-clock deadline passes, so the first status check reflects the warm server instead of a transient empty registry. The client is created once and reused across attempts, and the wait deliberately uses a wall-clock timer so it does not freeze under a test clock. Refs #125
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements #125: Awen's OpenCode provider now speaks the native OpenCode v2 server contract instead of the v1 contract. OpenCode v1 is no longer supported (ADR-0021).
@opencode-ai/sdkwith the official@opencode/client, pinned to2.0.12;MINIMUM_OPENCODE_VERSIONis now2.0.12.server listening on <url>, case-insensitive, matched anywhere on the line), and keep an unterminated readiness line pending instead of resolving a truncated URL.server.info; load providers, models, agents, skills, and commands through the v2 client per Workspace directory.OPENCODE_PASSWORD) and authenticate with Basic auth; startup diagnostics redact it.OPENCODE_CONFIG_CONTENTno longer defaults to{}, so the managed server reads the user's own OpenCode config.Verification
pnpm typecheckgreen for the workspace; lint andfmt:checkclean.AWEN_TEST_OPENCODE_V2_BINARY): managed startup, auth rejection without a password, chat/approval/fork/compaction, and a real adapter turn over an externalserverUrl.Notes
docs/adr/0021-opencode-v2-only-support.md.pingdotgg/t3code#13651); this ports the full native v2 migration.Closes #125