[PR #6260] fix: merge auth methods from multiple plugins for the same provider #11807

Open
opened 2026-02-16 18:16:44 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/6260

State: open
Merged: No


Fixes auth method conflicts when multiple plugins register for the same provider.

Problem

  • fromEntries() in provider/auth.ts overwrites duplicate provider keys (last plugin wins)
  • .find() in CLI auth.ts returns only the first matching plugin
  • Plugins exporting aliases (e.g., GoogleOAuthPlugin = AntigravityCLIOAuthPlugin) get loaded twice

Solution

  1. Plugin loader (plugin/index.ts): Track called functions to skip aliased exports; store package name in _source field

  2. Auth aggregation (provider/auth.ts): Replace fromEntries() with merge loop that accumulates methods from all plugins

  3. CLI auth (cli/cmd/auth.ts): Aggregate methods from all matching plugins instead of using .find()

  4. Labeling: Non-native plugins show source in label (e.g., "Google API key (websearch-cited)"), except for generic "Manually enter API Key" which is the same as native fallback

Before

{ "google": [{ "type": "api", "label": "Google API key" }] }

After

{
  "google": [
    { "type": "oauth", "label": "OAuth with Google (Antigravity) (antigravity)" },
    { "type": "api", "label": "Manually enter API Key" },
    { "type": "api", "label": "Google API key (websearch-cited)" }
  ]
}

Test Cases

  • Single plugin per provider: works unchanged
  • Multiple plugins, same provider: all methods merged
  • Aliased exports: deduplicated (same function reference)
  • Native plugins: no source suffix
  • Non-native plugins: source suffix on distinctive methods
  • Generic "Manually enter API Key": no suffix (same as native fallback)
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/6260 **State:** open **Merged:** No --- Fixes auth method conflicts when multiple plugins register for the same provider. ## Problem - `fromEntries()` in `provider/auth.ts` overwrites duplicate provider keys (last plugin wins) - `.find()` in CLI `auth.ts` returns only the first matching plugin - Plugins exporting aliases (e.g., `GoogleOAuthPlugin = AntigravityCLIOAuthPlugin`) get loaded twice ## Solution 1. **Plugin loader** (`plugin/index.ts`): Track called functions to skip aliased exports; store package name in `_source` field 2. **Auth aggregation** (`provider/auth.ts`): Replace `fromEntries()` with merge loop that accumulates methods from all plugins 3. **CLI auth** (`cli/cmd/auth.ts`): Aggregate methods from all matching plugins instead of using `.find()` 4. **Labeling**: Non-native plugins show source in label (e.g., "Google API key (websearch-cited)"), except for generic "Manually enter API Key" which is the same as native fallback ## Before ```json { "google": [{ "type": "api", "label": "Google API key" }] } ``` ## After ```json { "google": [ { "type": "oauth", "label": "OAuth with Google (Antigravity) (antigravity)" }, { "type": "api", "label": "Manually enter API Key" }, { "type": "api", "label": "Google API key (websearch-cited)" } ] } ``` ## Test Cases - Single plugin per provider: works unchanged - Multiple plugins, same provider: all methods merged - Aliased exports: deduplicated (same function reference) - Native plugins: no source suffix - Non-native plugins: source suffix on distinctive methods - Generic "Manually enter API Key": no suffix (same as native fallback)
yindo added the pull-request label 2026-02-16 18:16:44 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11807