Skip to content

Conversation

@Davincible
Copy link

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)

- Replace fromEntries() with merge loop in provider/auth.ts
- Deduplicate aliased plugin exports in plugin/index.ts
- Aggregate methods from all plugins in CLI auth.ts
- Add source labels for non-native plugins (except generic API key methods)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant