What changed#
Rebase of #27166 onto current main (402d0623d5), with the conflict against #26165 resolved and the Effect 4.1.2 Digest migration preserved.
- Read active OpenCode 2 Console OAuth credentials (
type: "oauth") as well as stored API keys.
- Send the credential's workspace ID in
x-opencode-org-id when reading Go usage.
- Keep the existing fallback to stored
opencode / opencode-go keys and the legacy auth.json / OPENCODE_API_KEY path.
- Fingerprint Console credentials by workspace instead of token, so OAuth access-token rotation does not split one workspace into multiple limit accounts.
- Isolate the OpenCode driver tests from the host's real credential store.
Why#
OpenCode 2 stores a signed-in Console account as an active OAuth credential in opencode.db with its workspace ID in credential metadata. T3 only decoded stored credentials of type key, so it discarded the valid Console login and returned unsupported without attempting the usage endpoint. The account itself works: the same OAuth access token returns HTTP 200 from https://opencode.ai/zen/go/v1/usage.
Fixes #14983. Supersedes #27166; the original two commits are preserved with their authorship.
Verification#
pnpm --filter @t3tools/provider-opencode test — 170 passed.
pnpm run check:changed — passed format, lint, both knip checks, typecheck for 10 affected packages, and 53 tests across 3 files.
- Live check against this machine's real OpenCode 2 Console OAuth login (no mocks): rolling 4%, weekly 3%, monthly 6%, all three windows returned with no
unavailable reason.
- Added
OPENCODE_AUTH_CONTENT={} to the driver test factory after the full package suite exposed that the new OAuth read could otherwise reach the host's real credential store and the noHttp guard.
Full repository test suites and builds are left to CI.
Notes#
Original implementation and commits by @Fushi500 in #27166. Rebase, conflict resolution, and test isolation here were done with DeepSeek V4.1 Flash in OpenCode.
The
Mobile Fingerprint Checkrun is stuck ataction_requiredwith no jobs started — GitHub is waiting for a maintainer to approve the fork PR workflow run. This PR only touchespackages/provider-opencode, which is outside the workflow's native-input paths (packages/client-runtime,packages/contracts,packages/shared, mobile/assets/scripts/patches, and root package files), so the expected result is "unchanged". Could a maintainer approve that run? The main CI workflow is still running.