Repository navigation
fix(opencode): support native v2 server integration - #3
Merged
Merged
Conversation
Replace the v1 SDK paths with the official OpenCode v2 client for local and external servers. Update the adapter, inventory, text generation, tests, dependency notices, and user guidance.
AllenReder
added a commit
to AllenReder/awen-legacy
that referenced
this pull request
Sep 26, 2026
* feat(opencode): support native OpenCode v2 provider 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 * fix(opencode): wait for the v2 provider registry before reporting status 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.
OpenCode 2 changed server startup and API routes, so T3 Code's v1 health request receives HTML and the provider cannot connect.
Migrate the existing OpenCode provider to the official
@opencode/clientv2 API for local and configured external servers. This adapts upstream PR #13008, including its session, event, approval, inventory, text generation, and recovery changes. OpenCode 2.0.12 or newer is required; the v1 adapter is removed. Update the provider guide and dependency notices.Validation:
git diff --checkpassed.Model: GPT-6. Harness: Codex.