feat(auth): merge auth methods from multiple plugins for same provider#10528
feat(auth): merge auth methods from multiple plugins for same provider#10528ndycode wants to merge 1 commit intoanomalyco:devfrom
Conversation
When multiple plugins register for the same provider (e.g., openai), all their auth methods are now merged into a single list. This allows external plugins to add auth methods alongside built-in options. Previously, only the first matching plugin's methods were shown due to .find() returning the first match. Now we use .filter() to collect all plugins and flatMap their methods. The first plugin's loader is still used (internal plugins take precedence), ensuring backward compatibility. Use case: Multi-account authentication plugins can add their auth methods alongside the built-in ChatGPT Pro/Plus option, giving users choice between single-account and multi-account auth flows.
|
Context on why this is needed: When OpenCode added first-party Codex support (PR #7537), plugins like However, there's a valid use case for extension rather than replacement: multi-account authentication. Users with multiple ChatGPT subscriptions want to see both options:
The current This is a minimal, backward-compatible change that enables plugin extensibility without breaking existing behavior. |
00637c0 to
71e0ba2
Compare
f1ae801 to
08fa7f7
Compare
Summary
When multiple plugins register for the same provider (e.g.,
openai), all their auth methods are now merged into a single list. This allows external plugins to add auth methods alongside built-in options.Problem
Currently,
auth.ts:310uses.find()which returns the first matching plugin:Since internal plugins load before external plugins, external plugins can never add auth methods to providers that have internal plugins (like
openai).Solution
Added
getMergedPluginAuth()function that:.filter()to collect ALL plugins that register for a provider.flatMap()to merge all their auth methodsUse Case
Multi-account authentication plugins can add their auth methods alongside built-in options:
Before:
After:
Backward Compatibility
Testing
openaiprovideropencode auth login→ select "OpenAI"