A new package, @magpie-community/opencode-minimax-auth, written from MiniMax Code 0.6.2's bundle. Sign-in: MiniMax Code's OAuth device flow, the same one mcode uses (account.minimax.cn / account.minimax.io, client mcode-public, scope agent.default, audience agent-backend, PKCE S256). It also handles MiniMax's own variant, where there is no device_code, the user_code is polled for, and expired_in may be an at-ms. The account is named from MiniMax's signed /v1/api/user/info. mcode's ~/.minimax sign-in is never read or written. Each account is a sign-in of its own, so magpie can hold several. Refresh: two minutes before the token ends, or once on a 401. One refresh runs per account (keyed by the refresh token it spends), and its result answers for the old token for a minute, so a late reader doesn't spend a rotated token twice. Only invalid_grant with HTTP 400 signs the account out (signIn: expired); any other failure keeps it and uses the token in hand while it lasts. Chats: Anthropic messages at <agent>/mavis/api/v1/llm/v1/messages, carrying: - Authorization: Bearer <token> - x-api-key sk-xxx (mcode's placeholder) - User-Agent MiniMaxAgent - X-Mavis-Agent-Id main - X-Mavis-Timezone-Offset - X-Mavis-Session-Id, from chat.headers' sessionID (otherwise a fixed id per run) A 402, 403 or 429 whose body says credits or quota ran out goes on as a 429 "usage limit reached". Models: the live config at GET /mavis/api/v1/models?region=&buildEnv=prod (asked again without auth on a 401/403), with mcode's built-in four as the fallback: MiniMax-M3.1-Flash-Preview, MiniMax-M3, MiniMax-M2.7 and MiniMax-M2.7-highspeed. Variants follow what mcode sends: adaptive thinking at an effort (output_config.effort), and none to turn thinking off. Usage: mcode's signed account API: user info, the type-0 workspace from get_user_extra_info, then get_membership_info. The card shows credits left (op_credit_summary / opcredit_balance), Free or "M Plan <tier>" with its end, and, for an M Plan, coding_plan/remains with X-Group-Id. That is read as magpie's readMiniMaxPlan reads it. There is no check-in. Tests: fakes only. nonet.mjs is imported first, so only 127.0.0.1 can be reached. They cover: - sign-in, the variant, refused, and other errors - refresh, a three-way race plus a late stale reader, per-account refreshes, invalid_grant, other failures, and 401 then refresh then retry - request headers and chat.headers - credits running out going on as a 429 - the live list, the retry without auth, and the fallback (the given object back) - signing, against fixed vectors and the bundle's formula - usage parsing (readMiniMaxPlan's own fixture), Free, M Plan, and a refused account bun test packages/minimax (27 pass) and bun scripts/check.mjs pass. End to end through magpie: origin/main b0486663, built with -tags nogui in a worktree since removed, under env -i with a sandbox HOME, a fake upstream on 127.0.0.1:47811, and a copy of the package with its hosts pointed there: - plugin add - plugin login minimax-code: the device flow and the account named; a second login of the same account merged into one - the live list: 2 models - provider test minimax-code: the chat went out with the headers above - quota: M Plan Plus, 321.5 credits, 5 hours and 7 days windows - an expired token refreshed and saved No request was made to MiniMax.
105 lines
4.8 KiB
Markdown
105 lines
4.8 KiB
Markdown
# magpie-community plugins
|
|
|
|
[OpenCode](https://opencode.ai) provider plugins for coding-plan
|
|
subscriptions, maintained by the community. Each package signs in to one
|
|
subscription and makes its requests. The packages work in OpenCode and in
|
|
[magpie](https://usemagpie.ai), which runs OpenCode's provider plugins.
|
|
|
|
| Package | Signs in to | Provider id |
|
|
|---|---|---|
|
|
| [commandcode](packages/commandcode) | Command Code plans (Pro, GOAT, Max, Ultra, Go, Teams Pro) | `commandcode-plan` |
|
|
| [cursor](packages/cursor) | Cursor subscriptions (Pro, Pro+, Ultra, Teams), on the API cursor-agent talks to | `cursor` |
|
|
| [devin](packages/devin) | Devin subscription (the devin CLI's account) | `devin` |
|
|
| [factory](packages/factory) | Factory (Droid) subscription | `factory` |
|
|
| [grok](packages/grok) | Grok (SuperGrok / X Premium+), through the Grok Build CLI's sign-in | `grok` |
|
|
| [kiro](packages/kiro) | Kiro (Free, Pro, Pro+, Power), with Kiro's sign-in, kiro-cli's or the IDE's, or an API key | `kiro` |
|
|
| [minimax](packages/minimax) | MiniMax Code (China): account credits and M Plan, with MiniMax Code's device sign-in | `minimax-code` |
|
|
| [minimax](packages/minimax) | MiniMax Code (international): account credits and M Plan, with MiniMax Code's device sign-in | `minimax-code-global` |
|
|
| [mimo](packages/mimo) | Xiaomi MiMo, with a Xiaomi account | `mimo-app` |
|
|
| [qoder](packages/qoder) | Qoder subscription (qoder.com), with Qoder's device sign-in | `qoder` |
|
|
| [qoder](packages/qoder) | Qoder CN subscription (qoder.cn), with Qoder CN's device sign-in | `qoder-cn` |
|
|
| [workbuddy](packages/workbuddy) | WorkBuddy (China build, CodeBuddy plan) | `workbuddy` |
|
|
| [workbuddy](packages/workbuddy) | WorkBuddy (international build) | `workbuddy-ai` |
|
|
| [zcode](packages/zcode) | ZCode: Z.ai / BigModel (智谱) GLM Coding Plan, team seats, Start Plan | `zcode` |
|
|
| [zed](packages/zed) | Zed (Pro, Pro Trial, Student, Business): Anthropic, OpenAI, Google and xAI models hosted by Zed | `zed` |
|
|
|
|
## Use
|
|
|
|
magpie:
|
|
|
|
```sh
|
|
magpie plugin add @magpie-community/opencode-<name>-auth
|
|
magpie plugin login <provider id>
|
|
```
|
|
|
|
In the app, the Plugins tab lists these packages: install one there, then
|
|
sign in.
|
|
|
|
OpenCode, in `opencode.json`:
|
|
|
|
```json
|
|
{ "plugin": ["@magpie-community/opencode-<name>-auth"] }
|
|
```
|
|
|
|
then `opencode auth login`.
|
|
|
|
## Writing a package
|
|
|
|
Each package is a folder under `packages/<name>/`:
|
|
|
|
- **`package.json`**
|
|
- name: `@magpie-community/opencode-<name>-auth`
|
|
- `"type": "module"`, `"main": "./index.mjs"`
|
|
- version, `"license": "MIT"`
|
|
- no runtime dependencies unless one is really needed. Bun's and Node's
|
|
`fetch`, `crypto` and `fs` usually cover it.
|
|
- **`index.mjs`**
|
|
- Exports one async plugin function, as OpenCode's `Plugin` type
|
|
describes.
|
|
- Returns an `auth` hook: `{ provider, loader, methods }`.
|
|
- A browser sign-in is `{ type: "oauth", label, prompts?, authorize }`.
|
|
`authorize` returns `{ url, instructions, method: "auto" | "code", callback }`.
|
|
- A key is `{ type: "api", label }`.
|
|
- `loader(getAuth, provider)` returns what the AI SDK is given:
|
|
`baseURL`, `apiKey`, `headers` and a `fetch` that signs each request
|
|
and refreshes the token (saving it with `client.auth.set`).
|
|
- A provider that models.dev doesn't list is declared in a `config` hook
|
|
that sets `config.provider[<id>] = { name, npm, api, models }`. The npm
|
|
field names the AI SDK package the models speak:
|
|
`@ai-sdk/openai-compatible` (chat completions), `@ai-sdk/openai`
|
|
(Responses) or `@ai-sdk/anthropic` (Messages).
|
|
- A list the account decides goes in the `provider: { id, models(provider, { auth }) }`
|
|
hook.
|
|
- **`README.md`**: what the package signs in to, how, where the sign-in is
|
|
kept, and the models.
|
|
|
|
The provider id is the one magpie's built-in subscription has (`grok`,
|
|
`zcode`, `workbuddy`, `commandcode-plan`, …). While magpie still has the
|
|
built-in, the plugin's provider shows as `<id>-plugin`. Once the built-in
|
|
is gone, it takes over the same id, so an agent set to `<id>/<model>` keeps
|
|
working.
|
|
|
|
## Checking a package
|
|
|
|
```sh
|
|
bun scripts/check.mjs [<name>] # loads each plugin and checks its hooks; signs in to nothing
|
|
MAGPIE=/path/to/magpie scripts/try.sh <name> [login <id> | provider test <id>-plugin]
|
|
```
|
|
|
|
`try.sh` runs magpie in a sandbox HOME (`.sandbox/<name>`), so your own
|
|
magpie, agents and sign-ins are left alone.
|
|
|
|
## License
|
|
|
|
MIT
|
|
|
|
## The market
|
|
|
|
`registry.json` is the list magpie's Plugins tab shows. The packages here
|
|
come first, then other OpenCode provider plugins worth knowing. magpie
|
|
fetches it every few hours and keeps a copy built into the app for when
|
|
it can't. To list a plugin, add an entry with its npm `package`, a
|
|
`name`, `providers` (the provider ids it signs in to), an `icon` and a
|
|
`summary` in English and Chinese (`{"en": …, "zh": …}`), and open a pull
|
|
request.
|