Skip to content

fix(opencode): support native v2 server integration - #3

Merged
gidorah merged 1 commit into
mainfrom
fix/opencode-v2-integration
Sep 24, 2026
Merged

gidorah merged 1 commit into
mainfrom
fix/opencode-v2-integration

Conversation

@gidorah

@gidorah gidorah commented Sep 24, 2026

Copy link
Copy Markdown
Owner

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/client v2 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:

  • 161 focused OpenCode tests, 52 provider registry tests, and 18 license tests passed.
  • The isolated real-binary integration test passed with OpenCode 2.0.15, including an external Server URL and an adapter turn.
  • Server typecheck, touched-file lint and formatting, and git diff --check passed.

Model: GPT-6. Harness: Codex.

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.
@gidorah
gidorah merged commit 2d225e2 into main Sep 24, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant