MiniMax spends a refresh token once: sent again it is invalid_grant, which signs the account out (MiniMax Code takes a lock across its processes and keeps a generation for it). The plugin's refresh request is MiniMax Code's own, so what drops the account is a refresh token spent a second time: - auth.refresh + refreshLead (10 minutes): magpie renews the account once, before its requests, models and usage ask for it. The 2-minute check before each request stays for OpenCode. - A refresh whose save failed kept its tokens a minute, then went back to the spent refresh token on disk. They are kept now until saved, and latest() follows them. - invalid_grant when the store holds a newer refresh token than the one spent (another magpie process renewed it) uses that one, not a sign-out. - A 401 retries with a newer saved token when there is one, and refreshes only when the token turned away is still the newest. Five tests in refresh.test.mjs, all failing on 0.1.0. HOME=$(mktemp -d) bun test: 353 pass.
13 lines
623 B
JSON
13 lines
623 B
JSON
{
|
|
"name": "@magpie-community/opencode-minimax-auth",
|
|
"version": "0.1.1",
|
|
"description": "OpenCode provider plugins for MiniMax Code accounts: their credits and M Plan, China (minimax-code) and international (minimax-code-global), with MiniMax Code's own device sign-in",
|
|
"type": "module",
|
|
"main": "./index.mjs",
|
|
"exports": "./index.mjs",
|
|
"files": ["index.mjs", "README.md"],
|
|
"keywords": ["opencode", "opencode-plugin", "minimax", "mcode", "minimax-code"],
|
|
"license": "MIT",
|
|
"repository": { "type": "git", "url": "git+https://github.com/magpie-community/plugins.git", "directory": "packages/minimax" }
|
|
}
|