oc-codex-multi-auth icon indicating copy to clipboard operation
oc-codex-multi-auth copied to clipboard

Support opencode v2?

Open eoleedi opened this issue 2 months ago • 2 comments

Feature Description As stated in the title

eoleedi avatar Sep 23 '26 13:09 eoleedi

I can reproduce the V2 incompatibility with [email protected] and the published @opencode/[email protected].

When the V2 loader reaches the plugin's built dist entry, registration fails with:

Plugin must export a default definition with an id and an effect or setup function.

The package currently default-exports the V1 OpenAIOAuthPlugin function. V2 resolves a server entry (falling back to the root entry) and expects an identified setup/effect definition. Merely changing the export shape is not sufficient: auth registration, request interception, retry/rotation, tools, and lifecycle cleanup need their actual V2 contracts.

Native V2 baseline

I also ran six controlled scenarios against the real 2.0.16 executable with the built-in OpenAI provider, two synthetic OAuth credential records and a local Responses/SSE fixture. No external plugins, real accounts, or subscription quota were used. Transport was explicitly HTTP, not WebSocket.

  • Credential A and B each succeeded independently.
  • 429 insufficient_quota on A failed without trying B.
  • Explicitly activating B and resending recovered the same failed session.
  • Synthetic 429 usage_limit_reached and 429 rate_limit_exceeded each made 11 requests (initial + 10 retries), all using A, then failed. B was never selected.

These are controlled HTTP observations, not a real ChatGPT login/refresh or default-WebSocket acceptance test. They distinguish native multiple-credential storage/selection from automatic rotation; they should not be generalized to every possible provider response or future V2 release.

Proposed contribution scope

I am investigating an additive V2 server adapter, keeping the V1 entry intact and reusing the existing account/storage/request logic rather than replacing it with a second account manager. Proposed acceptance gates:

  1. V2 loader registration and unload cleanup.
  2. Existing V1 build/typecheck/tests remain valid.
  3. Isolated positive and negative tests for credential selection, bounded retries, account isolation and cancellation, respecting existing cooldowns/provider limits.
  4. Explicit HTTP versus WebSocket support boundaries; no silent claim of full parity.
  5. Documentation and package entry points that do not rewrite an existing user's configuration unexpectedly.

I will keep implementation linked to this issue rather than opening a duplicate. If there is already an unpublished V2 branch or a preferred adapter direction, please point me to it before overlapping work grows. This is an investigation/contribution start, not a claim that V2 support is implemented or ready to release.

marcelokarval avatar Sep 24 '26 16:09 marcelokarval

OpenCode V2 support was added in merged PR #269, which directly addresses this request

lubshad avatar Sep 25 '26 03:09 lubshad