Skip to content

feat: add MiniMax quota fetcher and brand icon#1662

Open
ilteoood wants to merge 5 commits into
getpaseo:mainfrom
ilteoood:feat/minimax-quota-fetcher
Open

feat: add MiniMax quota fetcher and brand icon#1662
ilteoood wants to merge 5 commits into
getpaseo:mainfrom
ilteoood:feat/minimax-quota-fetcher

Conversation

@ilteoood

Copy link
Copy Markdown
Contributor

Mirrors the live multi-provider quota panel (#1278) for MiniMax, plus the brand icon so the usage card stops showing the generic robot.

Server

New MiniMaxQuotaProvider (packages/server/src/services/quota-fetcher/providers/minimax.ts) that resolves the bearer token from:

  • $MINIMAX_API_KEY (with optional $MINIMAX_BASE_URL override), or
  • the MiniMax CLI ~/.mmx/credentials.json (OAuth access_token + resource_url, with an expires_at guard), or
  • the MiniMax CLI ~/.mmx/config.json (api_key or oauth.access_token, honoring region and base_url).

It hits {baseUrl}/v1/token_plan/remains (defaulting to https://api.minimax.io, switching to https://api.minimaxi.com when region='cn') and renders one ProviderUsageWindow per model_remains entry for both the rolling interval and the weekly limit, with reset timestamps from end_time / weekly_end_time. A current_interval_status of 2 (exhausted) maps to a danger tone, and 3 (unlimited) maps to default.

Wired into PROVIDER_USAGE_FETCHERS in packages/server/src/services/quota-fetcher/manifest.ts — no other registration points needed; the existing tooltip / Host Usage screen already iterates the manifest.

Tests in packages/server/src/services/quota-fetcher/service.test.ts:

  • happy path via MINIMAX_API_KEY against the global endpoint
  • missing credentials → status: unavailable
  • OAuth credentials fallback in ~/.mmx/credentials.json (with custom resource_url)
  • api_key + region: 'cn' fallback in ~/.mmx/config.json → CN endpoint
  • exhausted interval status → tone: 'danger'

App

MiniMaxIcon component (packages/app/src/components/icons/minimax-icon.tsx) using the official 24×24 brand mark (single Path, currentColor) so the usage card colors it via the existing mutedIconColor theme token. Registered in:

  • packages/protocol/src/provider-icon-names.ts — added "minimax" to BUILTIN_PROVIDER_ICON_NAMES so resolveProviderIconName("minimax") returns { kind: "builtin" } instead of falling through to { kind: "bot" }.
  • packages/app/src/components/provider-icons.ts — import + BUILTIN_PROVIDER_ICONS entry.

Test extended in packages/app/src/components/provider-icon-name.test.ts to assert the new built-in mapping.

ilteoood added 2 commits June 20, 2026 20:37
Mirror the live multi-provider quota panel (getpaseo#1278) for MiniMax. Resolves the
bearer token from $MINIMAX_API_KEY or the MiniMax CLI config at
~/.mmx/config.json (api_key, oauth.access_token) and credentials at
~/.mmx/credentials.json, then queries the /v1/token_plan/remains endpoint on
the configured region (global by default, cn when region='cn'). The response
is normalized into ProviderUsage windows per model_remains entry, surfacing
the interval and weekly limits with their reset times and a danger tone when
the server reports status=2.
The quota panel resolves the icon via resolveProviderIconName, which falls
back to a generic Bot for any provider not in BUILTIN_PROVIDER_ICON_NAMES.
Register 'minimax' as a built-in icon and vendor the official 24×24 brand
mark (single Path, currentColor) as MiniMaxIcon so the usage card stops
showing the generic robot.
@greptile-apps

greptile-apps Bot commented Jun 22, 2026

Copy link
Copy Markdown

Greptile Summary

Adds a MiniMax quota provider and brand icon, mirroring the pattern established by Copilot, Kimi, Grok, and other providers already in the quota-fetcher manifest. The feature is well-contained: one new provider file, a thin manifest registration, and the icon wired into two existing lookup maps.

  • minimax.ts — four-step auth fallback (env → credentials.json OAuth → config.json api_key → config.json oauth), hits /v1/token_plan/remains, and produces one interval window plus one weekly window per model entry. Status 2 maps to danger, 3 to default, and the CN region routes to api.minimaxi.com.
  • service.test.ts — five integration tests covering the happy path, no-credentials early exit, OAuth credentials file, CN config fallback, and exhausted-interval tone; all exercise the feature through the public listUsage() service interface.
  • Icon + protocolMiniMaxIcon follows the identical structure of ClaudeIcon; the "minimax" name is registered in both BUILTIN_PROVIDER_ICON_NAMES and BUILTIN_PROVIDER_ICONS in one step each.

Confidence Score: 5/5

Safe to merge — the change is fully additive, follows established provider patterns throughout, and each auth fallback path is covered by tests.

All logic is correct: the usedPct derivation from remaining_percent and from raw counts agrees across the interval and weekly window helpers, the isExpired guard handles invalid date strings safely, and resolveBaseUrl correctly precedences an explicit URL over a region hint. Integration points are minimal — one manifest entry and one icon entry each. The tests cross the service interface rather than reaching into provider internals.

No files require special attention.

Important Files Changed

Filename Overview
packages/server/src/services/quota-fetcher/providers/minimax.ts New MiniMax quota provider with four-step auth resolution (env → credentials.json → config.json api_key → config.json oauth). Logic is correct and follows existing provider patterns; schema validation, HTTP timeout, and expired-token handling are all in place.
packages/server/src/services/quota-fetcher/service.test.ts Five new MiniMax test cases exercising: env-var happy path, no-credentials short-circuit, OAuth credentials fallback, CN-region config fallback, and exhausted-interval tone. All tests cross the service interface rather than reaching into internals.
packages/app/src/components/icons/minimax-icon.tsx New MiniMax brand icon component following the identical structure of ClaudeIcon and other existing icons (Svg + Path, fill on Svg container, currentColor default).
packages/server/src/services/quota-fetcher/manifest.ts Minimal registration of MiniMaxQuotaProvider in PROVIDER_USAGE_FETCHERS; matches the pattern of all other providers in the manifest.
packages/protocol/src/provider-icon-names.ts Adds 'minimax' to BUILTIN_PROVIDER_ICON_NAMES so the icon resolver returns { kind: 'builtin' } instead of the generic bot fallback.
packages/app/src/components/provider-icons.ts Wires MiniMaxIcon into BUILTIN_PROVIDER_ICONS under the 'minimax' key, consistent with every other provider icon in the map.
packages/app/src/components/provider-icon-name.test.ts Extends the existing builtin icon name test to assert the minimax mapping resolves correctly.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[fetchUsage called] --> B{MINIMAX_API_KEY set?}
    B -- yes --> C[Use env token + resolve base URL from MINIMAX_BASE_URL]
    B -- no --> D[Read ~/.mmx/credentials.json]
    D --> E{access_token present and not expired?}
    E -- yes --> F[Use OAuth token + resource_url as base URL]
    E -- no --> G[Read ~/.mmx/config.json]
    G --> H{api_key present?}
    H -- yes --> I[Use api_key + region/base_url]
    H -- no --> J{oauth.access_token present and not expired?}
    J -- yes --> K[Use oauth token + oauth.resource_url / base_url]
    J -- no --> L[return unavailable]
    C --> M[GET baseUrl/v1/token_plan/remains]
    F --> M
    I --> M
    K --> M
    M --> N{res.ok?}
    N -- no --> O[return unavailable]
    N -- yes --> P[Parse model_remains]
    P --> Q[For each model: build interval + weekly windows]
    Q --> R{windows.length > 0?}
    R -- yes --> S[return available]
    R -- no --> T[return unavailable]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[fetchUsage called] --> B{MINIMAX_API_KEY set?}
    B -- yes --> C[Use env token + resolve base URL from MINIMAX_BASE_URL]
    B -- no --> D[Read ~/.mmx/credentials.json]
    D --> E{access_token present and not expired?}
    E -- yes --> F[Use OAuth token + resource_url as base URL]
    E -- no --> G[Read ~/.mmx/config.json]
    G --> H{api_key present?}
    H -- yes --> I[Use api_key + region/base_url]
    H -- no --> J{oauth.access_token present and not expired?}
    J -- yes --> K[Use oauth token + oauth.resource_url / base_url]
    J -- no --> L[return unavailable]
    C --> M[GET baseUrl/v1/token_plan/remains]
    F --> M
    I --> M
    K --> M
    M --> N{res.ok?}
    N -- no --> O[return unavailable]
    N -- yes --> P[Parse model_remains]
    P --> Q[For each model: build interval + weekly windows]
    Q --> R{windows.length > 0?}
    R -- yes --> S[return available]
    R -- no --> T[return unavailable]
Loading

Reviews (3): Last reviewed commit: "fix: format" | Re-trigger Greptile

Comment thread packages/server/src/services/quota-fetcher/providers/minimax.ts Outdated
Comment thread packages/server/src/services/quota-fetcher/providers/minimax.ts Outdated
Comment thread packages/server/src/services/quota-fetcher/providers/minimax.ts Outdated
ilteoood added 3 commits June 22, 2026 10:13
Greptile review on getpaseo#1662 called out two nested ternaries in toIntervalWindow
and toWeeklyWindow. Extract a toneForStatus helper that uses an explicit
if/else chain so the same status-to-tone mapping is shared between the
interval and weekly windows, and add the missing trailing newline.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant