fix(oauth): read OPENCODE_API_KEY in e2e models opencode-console
Merged
YI
13d ago+148+148+012345678901234567890123456789-44-44-01234567890123456789
Fixes #1014.
e2e models opencode-consolereadsOPENCODE_API_KEYwhen it is set, in place of the stored login, asopencodeConsole()already does. With both set, the listing now shows the workspace the tests actually run on.e2e modelswith no provider includes OpenCode Console when only the key is set.- With no credential, both errors name the key along with
npx e2e login opencode-console. A rejected key sayscheck OPENCODE_API_KEY. - The key lookup lives in one place:
apiKeyEnvon the provider (packages/e2e/src/oauth/types.ts) andcredentialSource()inpackages/e2e/src/oauth/providers.ts, used by bothopencodeConsole()andlistModels().
Verified
Ran it locally: yes
- Built CLI (
dist/cli/bin.js models) on main and on this branch. A stub server stood in foropencode.ai/console/api/config(fetch redirected by a--importpreload) and logged the bearer each run sent.
| case | main | this branch |
|---|---|---|
key only, models opencode-console | no OpenCode Console login is stored; run npx e2e login opencode-console, exit 1 | 2 models (Zen + go/), Bearer <key>, no x-org-id, exit 0 |
key only, bare models | no login is stored; sign in with e2e login <...>, exit 1 | lists OpenCode Console, exit 0 |
| neither | ... run npx e2e login opencode-console, exit 1 | ... run npx e2e login opencode-console or set OPENCODE_API_KEY, exit 1 |
| key + stored login | lists via the login (Bearer st_tok, x-org-id: org_1) | lists via the key (Bearer <key>), same as opencodeConsole() |
| rejected key + stored login | lists via the login, ignoring the key the tests use | OpenCode Console rejected the stored token (401: invalid key); check OPENCODE_API_KEY, exit 1 |
| login only | lists via the login | unchanged |
- Not verified against the live service, since no OpenCode key was available. OpenCode's docs describe a single
oc_sk_key kind bound to a workspace, and Go as a property of the workspace, so a Go subscription key is most likely the same key as a service account key. The listing reads the same configopencodeConsole()already reads with the key.