Skip to content

Add feature of designating the default account. - #12

Open
FidesTherese wants to merge 1 commit into
dkraemerwork:mainfrom
FidesTherese:main
Open

FidesTherese wants to merge 1 commit into
dkraemerwork:mainfrom
FidesTherese:main

Conversation

@FidesTherese

Copy link
Copy Markdown

Summary

This PR adds manual default-account selection for OpenAI multi-account authentication.
Users can now select an existing account with:
multiauth -d user@example.com
The selected account is preferred for each OpenAI session until it reaches a rate limit. The plugin then automatically switches and rebinds the session to an eligible fallback account.

Changes

  • Added the multiauth command with -d and --default options.
  • Added optional defaultAccountIndex persistence to the existing version-1 account schema.
  • Added trimmed, case-insensitive email matching.
  • Rejects unknown or ambiguous email addresses without modifying storage.
  • Prefers the configured default on the first observable OpenAI request for each session and plugin process.
  • Preserves existing behavior when no default account is configured.
  • Persists rate-limit cooldowns before retrying.
  • Rebinds sessions to fallback accounts after a 429 response.
  • Keeps subsequent requests on the fallback account for the current session.
  • Supports numeric and HTTP-date Retry-After headers.
  • Clears or adjusts the default index when accounts are removed.
  • Preserves the existing installer executable while adding the multiauth package binary.
  • Replaced the POSIX-only build copy command with a cross-platform Node.js implementation.
  • Updated user, configuration, testing, changelog, and architecture documentation.

Runtime Behavior

OpenCode does not expose a session.selected hook. Therefore, the first observable OpenAI request is used as the session initialization boundary.
Non-OpenAI providers are unaffected.

Compatibility

  • Existing version-1 account files remain valid.
  • No storage migration is required.
  • Invalid or out-of-range default indexes are treated as unconfigured.
  • No new runtime dependency was introduced.

Verification

  • npm test: 304 tests passed.
  • npm run typecheck: passed.
  • npm run build: passed on Windows.
  • npm pack --dry-run: confirmed the CLI and OAuth assets are included.
  • multiauth --help: verified through PowerShell and CMD.
  • Local OpenCode plugin loading: verified with opencode debug config.

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