Files
yetone 24da52b8ca minimax 0.2.3: a China-site account call agent.minimaxi.com can't be reached goes once to agent.minimax.cn (#757)
youyo.p_10001 (Discord #feedback, Windows 11, magpie 0.1.2993): every
China-site account call to agent.minimaxi.com (usage, check-in, account,
membership) failed in magpie's plugin host with "unable to get issuer
certificate" for ~16h, while chats on agent.minimax.cn worked. They
checked that agent.minimax.cn serves the same account API with the same
tokens and answers.

accountCall now sends a call to site.agent once more to the site's
agentFallback (China: https://agent.minimax.cn) only when the fetch got
no HTTP answer: a TLS error, a refused/reset connection, a name that
didn't resolve. A 401/403, any other status, a statusInfo/base_resp error,
a redirect to another site (OtherSite) and a timeout or abort are the
answer and are never sent twice. Both attempts share the one 15s
deadline. When both hosts fail, the error names both hosts and why. The
international site has no fallback.

Tests (fallback.test.mjs): agent.minimaxi.com is played by a TLS server
serving a leaf issued by an intermediate the client never saw
(testdata/leaf.pem, generated for the test), so its fetch fails as the
reporter's did; agent.minimax.cn by the fake. The usage card and the
check-in claim go through the fallback; a 401, 404, 502, base_resp error
and a 307 to another site are not sent to the fallback; both hosts
failing names both; the global site doesn't fall back.

Run:
- mote (Bun 1.4.2): HOME=$(mktemp -d) bun test at the repo root: 5942
  pass, 19 skip, 0 fail. bun scripts/check.mjs: registry.json and minimax
  ok.
- xiaomi-gpu Windows 11 (win-run, Bun 1.4.2): fallback.test.mjs 9/9.
- Broken by hand on mote: no fallback at all -> card, check-in and
  both-fail tests red; falling back on any non-ok status -> 401/404/502
  red; falling back on OtherSite and on a body error -> redirect and
  business-error red.

Not tried: no MiniMax China-site tokens here, so no real call to
agent.minimax.cn's account API; that it answers the same is the
reporter's check. The reporter's own Bun 1.4.4 was not run.
2026-11-05 16:41:17 +08:00

48 lines
1.9 KiB
JavaScript

// A fake of MiniMax's hosts for the tests: one local server standing in
// for the account, agent and platform hosts of both sites, which the
// plugin's SITES are pointed at. route(method, path) answers a request;
// seen lists what came.
import { _internal } from "./index.mjs"
export function fakeMiniMax() {
const routes = new Map()
const seen = []
const server = Bun.serve({
port: 0,
hostname: "127.0.0.1",
async fetch(req) {
const url = new URL(req.url)
const text = await req.text()
const r = { method: req.method, path: url.pathname, query: url.searchParams, headers: req.headers, text, url: url.pathname + url.search }
if ((req.headers.get("content-type") ?? "").includes("x-www-form-urlencoded")) r.form = Object.fromEntries(new URLSearchParams(text))
else if (text) try { r.json = JSON.parse(text) } catch {}
seen.push(r)
const h = routes.get(req.method + " " + url.pathname)
if (!h) return new Response("no route " + req.method + " " + url.pathname, { status: 404 })
return h(r)
},
})
const origin = `http://127.0.0.1:${server.port}`
const was = {}
for (const [id, s] of Object.entries(_internal.SITES)) {
was[id] = { ...s }
Object.assign(s, { account: origin, llm: origin, agent: origin, platform: origin, ...(s.agentFallback ? { agentFallback: origin } : {}) })
}
_internal.renewing.clear()
_internal.renewed.clear()
return {
origin,
seen,
route: (key, h) => routes.set(key, h),
close() {
server.stop(true)
for (const [id, s] of Object.entries(was)) Object.assign(_internal.SITES[id], s)
},
}
}
export const json = (v, status = 200) => new Response(JSON.stringify(v), { status, headers: { "content-type": "application/json" } })
// a JWT as MiniMax's tokens are, with the claims given
export const jwtOf = (claims) => ["e30", Buffer.from(JSON.stringify(claims)).toString("base64url"), "sig"].join(".")