Repository navigation
fix(providers): live Token Plan quota + configurable fallback for xiaomi-mimo (#15753) - #15759
Merged
diegosouzapw merged 1 commit intoOct 8, 2026
Conversation
…omi-mimo (diegosouzapw#15753) Xiaomi MiMo quota self-tracked routed tokens against a hardcoded 4.1B (the Lite tier's Credits), so after a plan upgrade the connection stayed Exhausted until the calendar-month reset. Two layers fix it: 1. Live console fetch: with a MiMo console session cookie on the connection (xiaomiMimoConsoleCookie / XIAOMI_MIMO_CONSOLE_COOKIE) the fetcher reads tokenPlan/usage + tokenPlan/detail and reports the real plan window — plan label like "Xiaomi MiMo Token Plan · Pro", used/limit in Credits, resetAt from currentPeriodEnd. A missing or expired session returns a hint message and falls back to the self-tracked numbers instead of failing hard. 2. Configurable fallback budget: providerSpecificData.monthlyTokenLimit, then XIAOMI_MIMO_MONTHLY_TOKEN_LIMIT, then the historical 4.1B default. Also exposes the cookie in the connection modal (mirroring the qwen/volc console-cookie fields), strips it from API responses and audit summaries, validates the new providerSpecificData fields, and documents both env vars.
Contributor
Author
|
CI triage — every red check is pre-existing Base tip when branched and as of now: Verified two ways:
The PR's own tests/gates are green ( |
diegosouzapw
merged commit Oct 8, 2026
d7070a5
into
diegosouzapw:release/v3.8.52
29 of 51 checks passed
5 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #15753.
For
xiaomi-mimo, the quota adapter compared locally routed tokens against a hardcoded4_100_000_000— the Lite tier's monthly Credits — so after upgrading the plan (Lite → Pro) the connection stayedremainingPercentage: 0/Exhausteduntil the calendar-month reset, while the real plan sits at 38%.This PR adds the two layers proposed in the issue:
providerSpecificData.monthlyTokenLimit→XIAOMI_MIMO_MONTHLY_TOKEN_LIMIT→ historical4.1e9.Changes
open-sse/services/usage/xiaomi-mimo.ts— live fetch ofGET https://platform.xiaomimimo.com/api/v1/tokenPlan/usage+/tokenPlan/detail(8s timeout, sharedthrottleQuotaFetch):quotas.monthlyfrom themonth_total_tokenitem (used/limit in Credits), plan label likeXiaomi MiMo Token Plan · Pro,resetAtfromcurrentPeriodEnd(parsed deterministically as UTC — the value is a naive wall time). Session rejected (401/403,code !== 0, SSOloginUrl, non-JSON body) or cookie missing ⇒ a hint message plus the self-tracked numbers, so the dashboard keeps working instead of failing hard. Without a cookie the previous self-track behavior is unchanged except that the budget is now configurable.open-sse/services/usage.ts— dispatch now forwardsproviderSpecificDatatogetXiaomiMimoUsageforxiaomi-mimo/xiaomi-mimo-token-plan.quotaScrapingFieldValues.ts,QuotaScrapingFields.tsx,EditConnectionModal.tsx) — newxiaomiMimoConsoleCookiefield mirroring the existingvolc/alibaba/qwenconsole-cookie fields (blank values never overwrite an existing secret).src/shared/validation/providerSpecificData.ts— validation forxiaomiMimoConsoleCookie(string ≤ 10k) andmonthlyTokenLimit(positive number).src/lib/providers/requestDefaults.ts,src/lib/compliance/providerAudit.ts— cookie stripped from API responses and audit summaries..env.example,docs/reference/ENVIRONMENT.md—XIAOMI_MIMO_CONSOLE_COOKIEandXIAOMI_MIMO_MONTHLY_TOKEN_LIMITdocumented (with instructions for obtaining the cookie).changelog.d/fixes/15753-xiaomi-mimo-live-token-plan-quota.md— changelog fragment.Tests
tests/unit/xiaomi-mimo-live-quota-15753.test.ts— live payload → numbers/plan/resetAt and cookie forwarding; dispatch wiring; 401 +loginUrl⇒ hint + fallback; cookie missing ⇒ hint + default 4.1B;providerSpecificDataoverride; env override (psd wins); env cookie.tests/unit/xiaomi-mimo-cookie-field.test.ts— assign/blank/partial + schema validation (mirrors the qwen cookie-field test).Run with the repo runner (
node --import tsx/esm --import ./open-sse/utils/setupPolyfill.ts --import ./tests/_setup/isolateDataDir.ts --test):usage-service-hardening,qwen-token-plan-quota-fetcher, volc-cookie/request-sanitization, provider-specific-data-schema: 67 passcheck:complexity,check:file-size,check:dead-code: greentypecheck:*/check:env-doc-sync: unchanged pre-existing failures on the base branch (verified identical on cleanrelease/v3.8.52inapiKeyRotator.ts,useModelImportHandlers.ts,engineConfigSave.ts, and 4 unrelated env vars); neither touches this PR's files.Notes
used/limitare Credits, matching the MiMo dashboard exactly (verified against a live capture:14,954,038,035 / 38,000,000,000,currentPeriodEnd 2026-11-05 23:59:59).steipete/CodexBar(MiMoUsageFetcher.swift).