Skip to content

Support multi-account Anthropic OAuth across all chat bridge and runtime combos #51

@chubes4

Description

@chubes4

Problem

wp-coding-agents supports multiple runtimes (OpenCode, Claude Code, Studio Code) and multiple chat bridges (Kimaki, cc-connect, opencode-telegram, or none). None of these combos have a documented or automated way to set up multi-account Anthropic OAuth with rotation.

The need is universal — any configuration using Anthropic models benefits from account rotation to distribute rate limits and avoid single-account limits. But the setup path differs per combo:

Runtime Chat bridge Auth mechanism today Multi-account support
OpenCode Kimaki (Discord) opencode-claude-auth plugin + kimaki credential sync wrapper Kimaki v0.6.0 has built-in AnthropicAuthPlugin — but opencode-claude-auth is also loaded, creating a conflict
OpenCode cc-connect opencode-claude-auth plugin No rotation
OpenCode none (terminal) opencode-claude-auth plugin No rotation
Claude Code cc-connect Native claude auth (~/.claude/.credentials.json) No rotation
Claude Code none Native claude auth No rotation
Studio Code cc-connect Studio Code native auth Unknown

Current state

Plugin conflict (kimaki v0.6.0+)

Kimaki v0.6.0 ships a built-in AnthropicAuthPlugin that handles OAuth login, token refresh, request/response rewriting (tool names, system prompt, beta headers), and multi-account rotation. But opencode.sh unconditionally installs opencode-claude-auth@latest (lines 208-213):

# opencode-claude-auth: Safe to always include — no-op when Claude credentials aren't present.
OPENCODE_PLUGINS="${OPENCODE_PLUGINS}\n    \"opencode-claude-auth@latest\","

When both plugins are loaded, they compete for the same anthropic auth provider in OpenCode. The fix: skip opencode-claude-auth@latest when CHAT_BRIDGE=kimaki, since kimaki's built-in plugin supersedes it. Keep it for cc-connect / no-bridge setups.

Other issues

  • Kimaki + OpenCode (VPS): opencode.sh installs a custom wrapper (_install_opencode_wrapper) that syncs kimaki's anthropic-oauth-accounts.json into ~/.claude/.credentials.json. May be simplifiable now that kimaki core handles rotation.
  • Kimaki + OpenCode (local): No account management flow. Running kimaki anthropic-accounts subcommands or kimaki connect starts the full bot and crashes into the launchd-managed instance (port eviction loop).
  • No anthropic-accounts add CLI: Accounts are added through OpenCode's OAuth flow (triggered when an Anthropic model call happens). The kimaki CLI only has list, current, remove. No standalone way to bootstrap the first account or add additional accounts for rotation.
  • All combos: No documentation on multi-account setup or rotation.

What should happen

  1. Fix plugin conflict in opencode.sh: Make opencode-claude-auth@latest conditional — skip when CHAT_BRIDGE=kimaki (kimaki has built-in auth). This is the most immediate fix.

  2. Cross-bridge auth story: Define how multi-account Anthropic OAuth works for each supported combo. Kimaki has built-in rotation for its sessions; cc-connect and direct terminal don't have an equivalent. Either document per-bridge paths or build something bridge-agnostic.

  3. Setup flow: setup.sh should offer an account setup step appropriate to the chosen bridge/runtime:

    • Kimaki: accounts are added through the OpenCode OAuth flow (first model call triggers it) — document this, and ensure the plugin conflict above is resolved so it works
    • cc-connect / none: document how to add accounts, or provide a helper script
  4. Fix crash loop (local mode): On macOS with the launchd agent (com.wp.kimaki), running any kimaki subcommand that starts the bot evicts the launchd instance on port 29988, then launchd respawns and evicts back. The subcommand needs to work alongside a running instance, or the launchd agent needs to be stoppable/startable via setup.

  5. Plugin wipe on upgrade: When kimaki auto-upgrades via npm, the global node_modules/kimaki/ dir is replaced, wiping the DM plugins (dm-agent-sync.ts, dm-context-filter.ts) that opencode.sh copies there during setup. post-upgrade.sh only removes unwanted skills, doesn't re-copy plugins.

  6. Documentation: README should cover multi-account auth setup for each combo.

Non-goals

  • Don't rebuild what kimaki already does — use kimaki's built-in AnthropicAuthPlugin where kimaki is the bridge
  • Don't couple to Anthropic-specific internals more than necessary (the credential format may change)

Environment

  • wp-coding-agents setup with launchd on macOS
  • Kimaki v0.6.0 (auto-upgraded from v0.5.0)
  • OpenCode runtime

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions