Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ The MiniMax Code Agent communicates through the host MCP client. Business reques

| MiniApp | What it does | Author |
| --- | --- | --- |
| [Token Usage Widget / Token 用量悬浮窗](plugins/nahyuw/token-usage-widget/) | A floating dial for your MiniMax account's Token quota, consumption rate and recent usage, with an always-on-top popup window and a bilingual settings page | [nahyuw](https://github.com/nahyuw) |
| [Work Group](plugins/liuhaolin07/miniapp-af37075b-6a0d-41c1-bc4e-8817be9656b8/) | A chat-style work group where several MiniMax Code Agents reply in one thread, mention each other to hand work over, and ask you for tool approvals and answers as cards in the page | [liuhaolin07](https://github.com/liuhaolin07) |
| [Prompt Enhancer](plugins/skypata/prompt-enhancer/) | Rewrite a one-line request into a complete prompt for a coding assistant; the model list and reasoning levels come from MiniMax Code's own configuration, and the rewrite runs on your signed-in account | [skypata](https://github.com/skypata) |
| [Postman Lite](plugins/ssugarr/postman-lite/) | A lightweight local API request tool: build requests, send them through a local proxy that sidesteps browser CORS limits, and inspect responses, with collections kept as plain JSON | [ssugarr](https://github.com/ssugarr) |
Expand Down
1 change: 1 addition & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ MiniMax Code Agent 通过宿主 MCP 客户端与 MiniApp 协作。业务请求

| MiniApp | 功能 | 作者 |
| --- | --- | --- |
| [Token 用量悬浮窗 / Token Usage Widget](plugins/nahyuw/token-usage-widget/) | 用悬浮窗实时查看 MiniMax 账号的 Token 额度、消耗速率与近期用量,支持独立置顶悬浮窗与中英双语设置页 | [nahyuw](https://github.com/nahyuw) |
| [工作群](plugins/liuhaolin07/miniapp-af37075b-6a0d-41c1-bc4e-8817be9656b8/README.zh-CN.md) | 聊天式工作群:多个 MiniMax Code Agent 在同一个群里回复、互相 @ 接力,工具审批和提问以卡片形式在页面里完成 | [liuhaolin07](https://github.com/liuhaolin07) |
| [提示词增强器](plugins/skypata/prompt-enhancer/) | 把一句话改写成可以直接交给编码助手的完整提示词,模型清单与推理等级取自 MiniMax Code 自己的配置,改写走你已登录的账号 | [skypata](https://github.com/skypata) |
| [Postman Lite](plugins/ssugarr/postman-lite/README.zh-CN.md) | 轻量的本地 API 请求工具:构建请求、通过本地代理转发(绕过浏览器 CORS 限制)、查看响应,集合以纯 JSON 保存 | [ssugarr](https://github.com/ssugarr) |
Expand Down
19 changes: 19 additions & 0 deletions plugins/nahyuw/token-usage-widget/.minimax-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"schemaVersion": 1,
"name": "token-usage-widget",
"displayName": "Token Usage Widget / Token 用量悬浮窗",
"version": "1.0.0",
"description": "A floating dial for your MiniMax account's Token quota, consumption rate and recent usage, with an always-on-top popup window and a bilingual settings page. / 圆形悬浮窗展示 MiniMax 账号的 5 小时与 7 天周期额度、消耗速率与近期用量,支持独立置顶悬浮窗与中英文双语设置页。",
"author": "nahyuw",
"icon": "icon.png",
"category": "Productivity",
"exampleQueries": [
"Open the Token Usage Widget",
"Show my Token usage for the current 5-hour cycle",
"Open Token 用量悬浮窗",
"看看我本周的 Token 用量比例"
],
"apps": [],
"mcpServers": [],
"skills": []
}
21 changes: 21 additions & 0 deletions plugins/nahyuw/token-usage-widget/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 nahyuw

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
173 changes: 173 additions & 0 deletions plugins/nahyuw/token-usage-widget/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
# Token Usage Widget / Token 用量悬浮窗

A floating dial that shows how much of your MiniMax account's Token quota you have used, how fast
you are spending it, and how much you used over the last 7 days. Pop it out of the side panel into
its own always-on-top window, hover the dial to open the detail panel, and configure which metrics
it shows from the settings page.

Everything it shows comes from your signed-in MiniMax Code account, and reading that account needs
your say-so: the switch in the settings page is **off by default**, and while it is off the Mini
App reads no file of yours at all and shows a grey dial with one line telling you how to turn it
on.

[简体中文](README.zh-CN.md)

![The Account data switch in the settings page](docs/account-data-switch.png)

*The Account data switch in the settings page, after you turn it on.*

## What it shows

The dial carries three readings at once, and you choose each one:

- **Centre readout** — one metric as a number, for example today's Token total.
- **Water level** — how full the current 5-hour or 7-day cycle is, drawn as water inside the glass.
- **Outer ring** — a third metric as a progress ring: a cycle's usage, a reset countdown, or the
share of the current 5-hour cycle that your present speed would burn.

Hovering the dial opens a detail panel that lists every metric you enabled, the last 7 days as a
sparkline, and one line each naming the metric behind the centre, the water and the ring — so a
rate-driven ring never leaves you guessing which reading it stands for.

Every metric comes from your MiniMax account. The trend curve on the dial is the difference of the
account's live Token counter, and its window is yours to pick: 10 minutes, 30 minutes, 60 minutes
or 2 hours.

The settings page covers:

- **Account data** — the switch that lets the widget read your signed-in credential. Off by default.
- **Displayed metrics** — check, uncheck and reorder the metrics in the detail panel.
- **Refresh rate** — from 3 seconds to 1 minute.
- **Widget window** — size across 5 steps, position reset, and the window the trend curve covers.
- **Dial display** — which metric fills the centre, the water and the ring.
- **Appearance** — theme (follow system, light or dark) and **language** (follow system, 简体中文 or
English).
- **Data sources** — whether the account feed is reachable.

The window remembers its size and position between runs, and the page follows the system language
unless you pick one explicitly.

## Install and open

1. Download or copy this plugin directory, then install it as a local plugin in MiniMax Code
(see the MiniMax Code plugin documentation for the local-plugin folder).
2. Open **Plugins** in MiniMax Code and enable *Token Usage Widget*.
3. Open it from the plugin list, or ask the Agent to "open the Token Usage Widget".
4. Open the settings page and turn on **Account data**. The dial stays grey until you do — that
is the switch keeping your credential unread.
5. Press **Popup mode** on the page to pop the widget into its own always-on-top window.

The widget needs a signed-in MiniMax Code account: the 5-hour and 7-day cycle progress, today's
total and the last 7 days come from the MiniMax account API, and the rate and the trend come from
the difference of that account's live Token counter. When the account feed cannot be reached, the
widget says so under **Data sources** instead of showing a number it cannot stand behind.

## Tested environment

- MiniMax Code 3.1.19 on macOS 26.6.2.
- Minimum client version: **MiniMax Code 3.1.2** — the manifest declares `surface.window`, which
older clients reject.
- Installed locally, published through the Host, then checked in the in-app Browser: the dial
renders, the water level and the outer ring each follow their own metric, hovering opens the
detail panel with all three enabled metrics visible and no scrolling, the 7-day sparkline draws,
and the console stays free of errors and warnings.
- The **Account data** switch was exercised in both positions. Off: the dial turns grey, the
readout shows `--`, one line says the account data is off, the service reports
`account_disabled`, the sampling file in `dataDir` stops being written, and no Host file is
read at all. On: the account feed returns, the readings come back and the trend curve draws
again.
- The trend window was exercised at all four settings. The service returns one bucket per minute of
the chosen window (10, 30, 60 or 120 buckets), the curve is redrawn with that many points, and
the accessible label names the window.
- An idle stretch was exercised as well. While the account's live Token counter reports no change,
the minutes of that stretch stay at zero. The delta the counter reports when it catches up
afterwards is attributed to the minutes just before it was seen, not spread across the whole gap.
- A window with no consumption at all draws no curve: the dial shows the readout and the water only,
and the accessible label says "no consumption" rather than "steady".
- Both languages were exercised. With the language set to follow the system the page renders in
the system language; switching the setting to 简体中文 or English re-renders the dial, the detail
panel, the settings page, the metric names and the accessible labels in place.
- Not verified: the widget was not exercised on Windows, and the separate desktop window was
verified through the in-app Browser rather than as a floating window on the macOS desktop.

## Data & access

### The switch that gates the account feed

Reading your credential takes an explicit opt-in. The setting **Account data** lives in
`settings.json` and is **off by default**. While it is off, the service does not resolve the
runtime root, does not read a single Host file, does not call the account API and does not write
the sampling file; the page shows a grey dial and one line telling you to turn the switch on. Turn
it on in the settings page and the account feed starts on the next poll.

### Files read

With the switch on, two files that belong to MiniMax Code itself are read. The Host offers no API
for them, so this relies on an **unspecified internal layout** that may change between client
versions.

| File | Why it is read |
| --- | --- |
| `<runtime root>/auth/**/auth.json` | The signed-in MiniMax Code access token. It is used only inside the Node process to call the account API, and never reaches the page, a log message or a response body. A record is only used when it carries an explicit expiry that has not passed; a record without one is never sent. |
| `<runtime root>/auth/**/auth-state.json` | The login region, which picks the account API host. Nothing else from that file is read. |

The runtime root is resolved by trying `$MINIMAX_DATA_DIR`, `$MAVIS_DATA_DIR` and
`$MCODE_DATA_DIR` first, then `~/.minimax`. The candidate that actually holds the credentials
wins, so an environment variable pointing at another install does not fall through to `~/.minimax`
and end up on a different login. Deciding that means asking whether `<runtime root>/auth/prod` is a
directory or whether `<runtime root>/auth/**/auth.json` exists. Only when no candidate shows
credentials does the widget fall back to `<runtime root>/v2/sqlite/runtime-state.sqlite` as a hint
that this is a runtime root — and there it asks for the file's **type** only; its contents are never
read. The layout underneath the runtime root is undocumented and may change; the widget degrades to
"this feed is unavailable" instead of failing when a path moves.

### Files written

Only inside the Host-provided `context.dataDir`, which this Mini App treats as opaque:

- `settings.json` — the enabled metrics, refresh rate, theme, language, scale, the trend window, the
centre / water / ring assignment, the window position and the **Account data** switch. Written
atomically: a temporary file in the same directory, then renamed over the target.
- `account-rate.json` — the sampling history that turns the account's quota percentage into a
Token rate: quota samples, the account's daily total samples and the live Token counter samples.
It holds Token counts and timestamps only — never a credential. Written atomically, and not
written at all while the switch is off.

No file outside `context.dataDir` is created, edited or deleted.

### Network hosts

- `https://api.minimax.cn` — the MiniMax account API for the region you are signed in to.
- `https://api.minimax.io` and `https://api.minimaxi.com` — the same account API for the other
MiniMax regions. The host is chosen from your login region.

Requests go to `/backend/account/token_plan/remains_percent`, `/usage_summary` and
`/usage_overview`. The access token is sent as an `Authorization` header to that account host
only. Redirects are not followed, so the credential cannot be handed to another host. Nothing else
leaves the machine.

### Spawned processes

None. The Mini App starts no child process.

### Tests

`node --test tests/` runs the package's own tests: the credential switch (off means no Host file
is read, on means it is), the expiry rules, the runtime-root resolution, the account error mapping
and the trend buckets.

### Everything else

- **Agent turns**: none. The Mini App never runs an Agent turn.
- **Conversations read**: none.
- **Tools called**: none.
- **Microphone, camera, notifications**: none.
- **Host navigation**: not read. The page does read the MiniMax Code **theme** and **language**, so
it can follow the system; neither needs a permission declaration.
- **State**: the durable state above lives in `context.dataDir`. The widget's size and position,
and whether the page is showing the widget or the settings view, are kept in `sessionStorage`
and `localStorage` as view preferences.

## License

MIT — see [LICENSE](LICENSE).
Loading