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.