opencode
opencode copied to clipboard
feat: add multi-account support for auth providers
Summary
- Add support for multiple accounts per provider with active account switching
- Automatic migration from legacy single-auth format
Changes
Auth Module (src/auth/index.ts)
- New
ProviderAuthdata structure withaccountsmap andactivefield - New functions:
listAccounts,setAccount,setActive,removeAccount,getAccount,hasAccounts,getActive - Backward-compatible migration: legacy single-auth entries auto-convert to multi-account format on read
CLI (src/cli/cmd/auth.ts)
-
auth listnow shows accounts grouped by provider with active indicator -
auth loginaccepts--account/-aflag to specify account name -
auth logoutallows removing specific accounts (not just entire providers)
TUI (src/cli/cmd/tui/component/dialog-provider.tsx)
- New
DialogAccountscomponent for listing/switching accounts - New
DialogAccountNamecomponent for naming new accounts - Updated
DialogAuthMethodto support account context
Server (src/server/server.ts)
- New endpoints:
-
GET /auth/:providerID/accounts- List accounts -
PUT /auth/:providerID/accounts/:accountName- Set account credentials -
POST /auth/:providerID/accounts/:accountName/active- Set active account -
DELETE /auth/:providerID/accounts/:accountName- Remove account
-
SDK
- Regenerated with new
auth.accounts.*methods