fix(quota): use /v1/token_plan/remains and honor custom base URL#175
Conversation
quotaEndpoint() ignored its baseUrl argument and rebuilt the host from a
`baseUrl.includes('minimaxi.com')` check, which broke `--base-url` /
custom gateways — it was the only endpoint in the file not using the
passed baseUrl. It also pointed at the legacy
`/v1/api/openplatform/coding_plan/remains` path; the server now serves
the quota under `/v1/token_plan/remains` (matching the Token Plan
naming). With a line-matched API key the old path returns
"cookie is missing, log in again" while the new path works.
- quotaEndpoint: return `${baseUrl}/v1/token_plan/remains`, dropping the
host rewrite (REGIONS base URLs are already api-subdomain hosts).
- detect-region: probe the same new path.
- update endpoint/sdk/timeout mocks and add a custom-base-URL test.
Verified live on both lines: `quota show` renders quota over
GET .../v1/token_plan/remains for global and cn.
|
dummy |
SummaryRenames the quota endpoint from Checks
Issues by FileNo blocking issues in the changed files.
Suggestions (non-blocking)The new test in Verdict✅ Approve — all required checks green, no blocking issues introduced by this PR. |
What
mmx quota show(and region auto-detection) call a stale, hardcoded quota endpoint. Two problems inquotaEndpoint():baseUrl— it rebuilds the host from aminimaxi.comsubstring check instead of using the argument. It's the only endpoint inendpoints.tsthat doesn't use the passedbaseUrl, so--base-url/MINIMAX_BASE_URL/ custom gateways are silently dropped for quota./v1/api/openplatform/coding_plan/remains. The server now serves quota at/v1/token_plan/remains(consistent with the Token Plan naming). This file originally usedtoken_plan/remains; it was changed to the openplatform path and that path now misbehaves.Evidence
With a line-matched API key (no OAuth needed):
…/v1/api/openplatform/coding_plan/remains1004 cookie is missing, log in again…/v1/token_plan/remainsmodel_remainsreturnedConfirmed on both lines (
api.minimax.ioandapi.minimaxi.com).Changes
src/client/endpoints.ts—return \${baseUrl}/v1/token_plan/remains`; drop the host rewrite.REGIONSbase URLs are alreadyapi.*` hosts, so no host fix-up is needed, and custom base URLs are now honored.src/config/detect-region.ts— region probe uses the same new path.endpoints/sdk/quota/auth/timeout-fixexpectations to the new path; add a test asserting a custom base URL is honored.Verification
bun test— 356 pass / 0 failtsc --noEmitcleanmmx quota showon both lines renders the quota table;--verboseconfirmsGET …/v1/token_plan/remains.Scope
Independent of #173/#174 (those fix quota rendering); this fixes the quota endpoint. Branches off
main.