Feature/multi account support#36
Open
Shivprasadpravindongapure wants to merge 3 commits intoanomalyco:masterfrom
Open
Feature/multi account support#36Shivprasadpravindongapure wants to merge 3 commits intoanomalyco:masterfrom
Shivprasadpravindongapure wants to merge 3 commits intoanomalyco:masterfrom
Conversation
- Implement multi-account storage structure with rate limit tracking - Add automatic failover logic for 429 rate limit responses - Create standalone CLI tool for account management (multi-auth-cli.mjs) - Add in-session status tool (multi_auth_status) for real-time account info - Support for adding, listing, renaming, and removing accounts - Automatic migration from single-account to multi-account format - Backwards compatible with existing OAuth authentication - Comprehensive documentation and usage examples Resolves anomalyco#23
Author
|
feat: Complete multi-account support implementation
Ready for GSoC contribution review! 🎓 |
Author
|
he implementation demonstrates:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request: Multi-Account Support with Automatic Failover
🎯 Goal
Implement multi-account support for OpenCode Anthropic authentication with automatic failover when rate limits are encountered.
📋 Issue Reference
Closes #23
🚀 Features Added
✅ Core Multi-Account Functionality
retry-afterheaders✅ CLI Management Tool (
multi-auth-cli.mjs)✅ In-Session Status Tool
✅ Backwards Compatibility
🧪 Testing
CLI Tool Tests
Example Output
📁 Files Added
Core Implementation
index-multi-auth.mjs- Enhanced plugin with multi-account support and failover logicmulti-auth-config.js- Configuration structures and utility functionsmulti-auth-cli.mjs- Standalone CLI management toolDocumentation & Migration
README-MULTI-AUTH.md- Comprehensive user documentationIMPLEMENTATION-SUMMARY.md- Technical implementation detailsmigrate-multi-auth.mjs- Migration and test setup toolConfiguration
package.json- Updated with"type": "module"for ES modules🔄 How Automatic Failover Works
Rate Limit Detection: When a request returns 429 status:
retry-afterheader for wait timeAccount Switching: If auto-failover is enabled:
Token Refresh: Automatically refreshes expired tokens before making requests
Fallback: If all accounts are rate-limited, returns appropriate error message
🏗️ Architecture
Configuration Storage
Accounts are stored in
~/.config/opencode/multi-auth.json:{ "type": "multi-oauth", "accounts": [ { "id": "account-1234567890", "label": "Personal", "access": "oauth_access_token", "refresh": "oauth_refresh_token", "expires": 1704067200000, "rateLimitedUntil": null, "mode": "max" } ], "currentAccountIndex": 0, "autoFailover": true }Rate Limit Tracking
rateLimitedUntiltimestamps for each account🎓 GSoC Contribution
This implementation demonstrates:
📊 Impact
For Users
For Developers
🔧 Installation & Usage
Quick Start
Migration
Existing single-account users are automatically migrated when adding their first multi-account.
🧪 Development Testing
✅ Checklist
🎉 Ready for Review
This implementation provides a complete solution for multi-account support with automatic failover, making it perfect for users with multiple Claude subscriptions who want uninterrupted productivity. The code is well-documented, thoroughly tested, and ready for production use.