Skip to content

feat(plugin): add MiniMax Token Plan OAuth provider#27460

Open
kapelame wants to merge 1 commit into
anomalyco:devfrom
kapelame:feat/minimax-token-plan-oauth
Open

feat(plugin): add MiniMax Token Plan OAuth provider#27460
kapelame wants to merge 1 commit into
anomalyco:devfrom
kapelame:feat/minimax-token-plan-oauth

Conversation

@kapelame
Copy link
Copy Markdown

Issue for this PR

N/A — new provider integration

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds an internal plugin that registers OAuth + API key auth methods on the existing minimax-coding-plan and minimax-cn-coding-plan providers (already in models.dev). Both regions get:

  • "Sign in with MiniMax" — OAuth 2.0 Device Code Flow (RFC 8628) with PKCE against account.{minimax.io,minimaxi.com}
  • "Paste Token Plan key" — API key fallback

The plugin handles refresh proactively (5-min buffer before expiry) and persists the new refresh_token to disk before updating in-memory state — a crash mid-refresh can't lose a rotated refresh_token. Refresh requests retry on transient 5xx/network errors but bail immediately on 4xx (the refresh_token is genuinely invalid).

Also promotes the four MiniMax providers in the TUI provider picker (PROVIDER_PRIORITY) so they appear together as a contiguous block, instead of being scattered among other "non-popular" providers in the catalog tail.

How did you verify your code works?

  • bun typecheck clean
  • New test/plugin/minimax.test.ts — 8 tests, all passing — covers refresh edge cases:
    • persist-before-update ordering (rotated refresh_token survives a persist failure — no silent logout)
    • expired_in: 0 not treated as "infinite token, never refresh"
    • 5xx retry with backoff; 4xx no retry
    • Missing refresh_token in OAuth success response → fail loud (don't store empty string)
    • Happy path round-trips
  • Manually verified end-to-end via bun dev: provider picker → "MiniMax Token Plan (minimax.io)" → "Sign in with MiniMax" → browser opens to account.minimax.io device-code page → returns to TUI → can chat with MiniMax-M2.7.

Notes

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Adds an internal plugin that registers OAuth + API key auth methods
on the existing minimax-coding-plan and minimax-cn-coding-plan
providers. Both regions get a "Sign in with MiniMax" entry that
runs OAuth 2.0 Device Code Flow (RFC 8628) with PKCE against
account.{minimax.io,minimaxi.com}, plus a "Paste Token Plan key"
fallback for manual API-key entry.

The plugin handles token refresh proactively (5-min buffer before
expiry) and persists the new refresh_token to disk before updating
in-memory state, so a crash mid-refresh can't lose a rotated
refresh_token. Refresh requests retry on transient 5xx/network
errors but bail immediately on 4xx (the refresh_token is genuinely
invalid).

Promotes the four MiniMax providers in the TUI provider picker so
they appear together as a contiguous block, instead of being
scattered among other "non-popular" providers in the catalog tail.

Companion catalog rename PR at sst/models.dev rebrands the two
Token Plan entries from "Coding Plan" to "Token Plan" in display
labels.
@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate Found

PR #27011: feat(opencode): add MiniMax OAuth device code flow plugin
#27011

This appears to be a related or possibly duplicate PR that also adds MiniMax OAuth support with Device Code Flow. Since both PRs target the same provider (MiniMax) and implement OAuth authentication, they may be addressing the same feature or there may be overlapping work.

Recommendation: Check PR #27011 to see if it's already implementing this functionality or if it covers the same scope.

Comment thread packages/opencode/src/cli/cmd/tui/component/dialog-provider.tsx
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.

2 participants