opencode icon indicating copy to clipboard operation
opencode copied to clipboard

feat: add multi-account support for auth providers

Open coleleavitt opened this issue 3 weeks ago • 2 comments

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 ProviderAuth data structure with accounts map and active field
  • 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 list now shows accounts grouped by provider with active indicator
  • auth login accepts --account / -a flag to specify account name
  • auth logout allows removing specific accounts (not just entire providers)

TUI (src/cli/cmd/tui/component/dialog-provider.tsx)

  • New DialogAccounts component for listing/switching accounts
  • New DialogAccountName component for naming new accounts
  • Updated DialogAuthMethod to 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

coleleavitt avatar Dec 30 '25 00:12 coleleavitt