Skip to content

Conversation

@coleleavitt
Copy link

@coleleavitt coleleavitt commented Jan 15, 2026

Summary

This PR adds multi-account support to the Anthropic auth plugin, allowing users to manage and switch between multiple Anthropic accounts.

Features Added

Multi-Account Management

  • AccountManager class - Handles account storage, selection, and rotation
  • File locking - Prevents concurrent write corruption
  • Atomic writes - Safe storage updates
  • Custom storage location - ~/.config/opencode/anthropic-accounts.json

Account Selection

  • Sticky selection - Uses same account until rate-limited (preserves prompt cache)
  • Automatic rotation - On 429, switches to next available account
  • Rate limit tracking - Tracks cooldown per account
  • Manual switcher - Users can manually switch accounts via opencode auth login

Profile Information

  • Stores complete profile from Anthropic API:
    • name, email, fullName, displayName
    • uuid, hasClaudeMax, hasClaudePro, plan
    • organizationUuid, organizationName
    • organizationType, billingType
    • rateLimitTier, hasExtraUsageEnabled

UX Improvements

  • Toast notifications - Shows current account and rate limit switching
  • Auto account naming - Uses email as account name
  • Token refresh - Automatic background refresh

Files Changed

  • index.mjs - Main plugin with multi-account support (1 file changed, +603/-227 lines)

Features:
- Multi-account management with AccountManager class
- File locking and atomic writes for data safety
- Custom storage: ~/.config/opencode/anthropic-accounts.json
- Automatic account rotation on rate limits (429)
- Sticky account selection (preserves prompt cache)
- Token refresh handling
- Account switcher method (no OAuth code needed)
- Profile fetching (email, name, org, plan, rate limit tier)
- Toast notifications for account switching

Account fields stored:
- name, email, fullName, displayName
- uuid, hasClaudeMax, hasClaudePro, plan
- organizationUuid, organizationName
- organizationType, billingType
- rateLimitTier, hasExtraUsageEnabled
@coleleavitt coleleavitt force-pushed the multi-account-support branch from 465158e to b2d5745 Compare January 15, 2026 16:42
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