Skip to main content
D

dsh-usage-bar

datameansfuture/dsh-usage-bar

Shows the official DeepSeek, MiniMax, GLM and Kimi quota and balance side by side at the end of the composer, with a quota dashboard and a per-vendor settings page.

Install

dsh plugin --profile web add github:datameansfuture/dsh-usage-bar

README

dsh-usage-bar

DeepSeek Harness plugin: shows the official quota and balance of DeepSeek, MiniMax, GLM and Kimi side by side at the end of every conversation.

MiniMax · 5h 55% (4h38m) · Credits 81万|GLM · 5h 91% (1h05m) · 7d 81%|DeepSeek ¥69.41|Kimi ¥65.00

Preview

It reads each vendor's own official quota or balance endpoint — no proxy, no shared pool, no change to your model routing. Credentials are read from the Harness credentials service and ~/.dsh/.env; the plugin never writes them back.

What it shows

VendorShownEndpointCredential
DeepSeekAccount balance when signed in, otherwise API-key balanceHarness account service / api.deepseek.com/user/balanceSigned-in account / DEEPSEEK_API_KEY
MiniMaxCoding Plan 5h window usage, plus credit balanceapi.minimaxi.com/v1/api/openplatform/coding_plan/remains, api.minimaxi.com/backend/account/token_plan_creditMINIMAX_API_KEY + console cookie
GLMCoding Plan 5h and weekly window usageopen.bigmodel.cn/api/monitor/usage/quota/limitZ_AI_API_KEY or GLM_API_KEY
KimiPay-as-you-go balanceapi.moonshot.cn/v1/users/me/balanceKIMI_API_KEY or MOONSHOT_API_KEY

The order is fixed: MiniMax → GLM → DeepSeek → Kimi. It does not follow the model you are currently talking to, and it never highlights the current vendor.

Colour bands

Every percentage is the used share of the window (100 - remaining), and the colour escalates as it grows:

UsedColour
0–25%deep green
25–50%light green
50–75%yellow
75–91%amber
91–100%red

Vendor names stay neutral grey. Balances are not percentages, so they are not banded — only a zero balance turns red. When a request fails but a previous value exists, the stale value is shown dimmed; when every vendor fails, the vendor shows as Vendor !.

Where the numbers come from

  • Usage windows. The GLM endpoint returns the remaining share, so the bar shows 100 - remaining. MiniMax has no weekly limit when current_weekly_status is 3, and the weekly window is then hidden.
  • MiniMax credits. The credit balance only exists in the console session — the open-platform API does not return it. It comes from GET /backend/account/token_plan_credit, field balance_breakdown.total_balance (falling back to remaining_credits, then to the sum of buckets[].balance), and is displayed in ten-thousands (810000 → 81万). Without a console cookie this row is simply not shown.
  • Token Plan vs Coding Plan. They are separate pools but report the same numbers, so only the Coding Plan row is shown.

Install

Install the plugin into a Harness profile with the dsh CLI:

dsh plugin install /path/to/dsh-usage-bar

Or clone the repository into the profile's dependency location and add one line to the profile's cordis.patch.yml:

- id: usage-bar
  name: 'dsh-usage-bar'
  config: {}

Replacing an already-installed package needs a DSH restart to load the new module generation.

Configuration

All credentials come from the Harness credentials service or ~/.dsh/.env (Z_AI_API_KEY, DEEPSEEK_API_KEY, MINIMAX_API_KEY, MOONSHOT_API_KEY, …). The plugin only reads them.

The MiniMax credit balance needs the console web-session cookie in addition:

mkdir -p ~/.dsh/usage-bar
printf '%s' 'your Cookie request header' > ~/.dsh/usage-bar/minimax-cookie
chmod 600 ~/.dsh/usage-bar/minimax-cookie

The file takes precedence over the MINIMAX_CONSOLE_COOKIE environment variable, and changes take effect immediately without restarting DSH.

Console endpoints are rate-limited harder than the open-platform APIs, so that one request gets its own random 5–50 minute cooldown (re-randomised every time, never a fixed interval). While the cooldown is active the cached value is reused. Every other vendor endpoint refreshes at a 60-second minimum interval.

Vendors page

The plugin registers two extra surfaces in the Harness UI:

  • Quota dashboard — a tab in the plugin manager, one card per vendor with a bar per window.
  • Settings — a page on this plugin's entry in the plugin manager, where each built-in vendor can be enabled or disabled and custom vendors can be added as JSON.

Custom vendors are declarative. Each one needs an id, a label, the credential names to read (refs) and at least one request:

{
  "id": "myco",
  "label": "MyCo",
  "refs": ["MYCO_API_KEY"],
  "requests": [
    {
      "key": "balance",
      "url": "https://api.myco.example/v1/balance",
      "auth": { "type": "bearer" },
      "parser": { "kind": "balance", "path": "data.balance", "currency": "CNY" }
    }
  ]
}

auth is one of bearer, raw (the key is sent as-is in Authorization), header (a custom header plus optional prefix) or cookie. parser is either the name of a built-in parser or an object describing where to read the numbers (kind, path, currency, and the field names for windowed quotas). Settings live in ~/.dsh/usage-bar/settings.json and are also editable by hand.

Mobile app (AI-HUB)

The composer bar is a client UI slot injection. The AI-HUB native chat screen is React Native and does not load third-party client bundles, so the bar is not visible there. The plugin therefore ships a mobile extension page:

ItemValue
Extension directoryextensions/usage-quota/ (entry point is always index.html)
Extension sluglocal.usage-bar.usage-quota
Host routeGET /api/usage-bar/state → {sources, snapshots, checkedAt}
Data serviceservice usage-bar, allows /api/usage-bar/

The host route is registered in the plugin's own index.js (ctx.inject(["webServer"], …) plus ctx.webServer.register); the extension page fetches through window.__dshHostFetch("usage-bar", "/api/usage-bar/state").

Development

npm test        # rebuilds client.js and extensions/usage-quota/shared.js, then runs node --test
npm run build   # only rebuilds those two artefacts
  • client-shared.js holds pure functions (no import/export) and is inlined into client.js at build time.
  • client.template.js + client-shared.js → client.js is produced by scripts/build-client.mjs.
  • The same client-shared.js also produces extensions/usage-quota/shared.js (window.__usageBarShared), so the mobile page and the composer bar share one set of rules.
  • Host code lives in lib/. Changes there are picked up by the plugin hot-reload (restart DSH if they do not apply); client-only changes need npm run build and a UI refresh.

License

MIT — see LICENSE.

Related plugins