Skip to content

feat(auth): multi-account support with auto-rotation#13378

Open
IsraelAraujo70 wants to merge 12 commits intoanomalyco:devfrom
IsraelAraujo70:feature/multi-auth
Open

feat(auth): multi-account support with auto-rotation#13378
IsraelAraujo70 wants to merge 12 commits intoanomalyco:devfrom
IsraelAraujo70:feature/multi-auth

Conversation

@IsraelAraujo70
Copy link
Contributor

Summary

Add multi-account support to OpenCode authentication system, inspired by the Antigravity plugin.

Changes

  • New auth storage format: { provider: { accounts: {}, activeAccount } }
  • Auto-migration: seamless upgrade from legacy single-account format
  • Interactive CLI: no more --account flags, just run opencode auth login
  • Account management: switch, enable/disable accounts interactively
  • Environment variables: OPENCODE_ACCOUNT_OPENAI=work for account selection
  • Auto-rotation: getNextAccount() for rate-limit handling (WIP)

Example Usage

# Add first account
opencode auth login openai

# Add second account (will prompt interactively)
opencode auth login openai

# Switch account
opencode auth use

# Or use env var
OPENCODE_ACCOUNT_OPENAI=personal opencode run ...

Related

root added 3 commits February 12, 2026 21:58
- New auth store format: { provider: { accounts: {}, activeAccount } }
- Auto-migration from legacy format (single credential per provider)
- New functions: add, getAccounts, use, setEnabled, getNextAccount
- CLI updates: interactive account selection, enable/disable accounts
- Round-robin auto-rotation for rate-limit handling
- Use Auth.add instead of Auth.set for OAuth/API callbacks
- Auth.get now automatically returns active account or first available
- OPENCODE_ACCOUNT_<PROVIDER> to select specific account
- OPENCODE_ACCOUNT as general override
- Example: OPENCODE_ACCOUNT_OPENAI=work
@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found several potentially related PRs:

Potential Duplicates/Related PRs:

  1. PR feat: multi-account profile support per provider #13218 - feat: multi-account profile support per provider

    • Very similar feature focusing on multi-account profile support per provider
  2. PR feat(auth): multi-account OAuth support with auto-relogin #11832 - feat(auth): multi-account OAuth support with auto-relogin

    • Addresses multi-account OAuth support with auto-relogin functionality
  3. PR feat(auth): OAuth Marathon - multi-account credential rotation #8590 - feat(auth): OAuth Marathon - multi-account credential rotation

    • Previous attempt at multi-account credential rotation/auto-rotation feature
  4. PR feat(auth): merge auth methods from multiple plugins for same provider #10528 - feat(auth): merge auth methods from multiple plugins for same provider

    • Related to handling multiple authentication methods for the same provider
  5. PR feat(openai-oauth) OpenAI OAuth multi account support #8536 - feat(openai-oauth) OpenAI OAuth multi account support

    • Earlier work on OpenAI OAuth multi-account support

Note: PR #13218 and #11832 appear to be the most directly related to PR #13378, as they both address multi-account support with similar goals. You may want to check if these are addressing the same requirements or if they can be consolidated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant