DeepSeek Harness Plugin

Mikajin1206/dsh-glm-quota

Stars ★ 0 Category Usage & Billing Added 2026-11-16

GLM Coding Plan quota, as a glm_quota tool, a left-sidebar panel, an always-visible sidebar footer strip, a settings section and a plugin-page card. Reads /api/monitor/usage/quota/limit from open.bigmodel.cn or api.z.ai and shows the REMAINING allowance (100% untouched, 0% exhausted) for the 5-hour and weekly token windows plus the monthly MCP budget, each with a reset countdown. Parses both upstream shapes: CREDIT_LIMIT with unit 3/6, and TOKENS_LIMIT. The key goes to the DSH credential store, not a config file.

Install

# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)

dsh plugin --profile web add github:Mikajin1206/dsh-glm-quota

Any plugin you install runs third-party code with your own permissions — it can read your files, use your credentials, and reach the network, and tool approvals don’t sandbox it. GitHub-sourced plugins also run build scripts at install time — pnpm blocks those until you allow them, so an install can stop with ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED or ERR_PNPM_IGNORED_BUILDS; dsh prints the exact key to add under allowBuilds in your profile’s pnpm-workspace.yaml, and the install works on the next run. Allowing a build is a trust decision: only install sources you trust, and pin a commit (github:owner/repo#sha).

README

View GLM Coding Plan quota (5-hour window / weekly window / monthly MCP calls) inside DeepSeek Harness — as a glm_quota tool, as a strip at the sidebar foot, as a left-sidebar panel, as a settings page, and as a card on the plugin's own page.

Reference implementation follows the structure of dsh-codex-subscription (manifest + cordis patch insert + host plugin exporting apply/Config + a hand-written client bundle), with zero framework imports:

  • the glm_quota tool is built as a plain literal object (same shape defineTool produces),
  • the API key is resolved through DSH's credentials service (config literal → credential ref → env vars),
  • HTTP uses global fetch,
  • the UI is a hand-written window.__ModuleLoader__ bundle registering sidebar.footer.action, sidebar.panellist, main, settings.section, and plugins.bundle.config,
  • data reaches the UI over a host route (connection.fetch.register) at POST /api/glm-quota/query.
  • @deepseek-ai/schemastery + @deepseek-ai/cosmokit are ordinary dependencies, installed from the public registry with the package — nothing is vendored into the repository.

Sidebar entry

A sidebar icon only exists if the bundle registers the pair itself:

Slot Key What it draws
sidebar.footer.action id = package name the quota strip beside the sidebar's Settings button (order 2 here)
sidebar.panellist id = package name one row in the panel list (order 20 here)
main key = package name the central column for that panel id

The row glyph is an inline SVG gauge using currentColor, sized by the size prop the sidebar passes. The page reuses the card component with variant: 'page', so the four UI entry points cannot drift apart.

The footer slot hands each action only { wide }. Wide shows a title row and one bar per window, each with its remaining percentage and a countdown to the window's reset (1h 32m后重置); the 56px rail shows a single GLM 74% label for whichever window is closest to running out. Because the footer is mounted all the time, the strip polls every 5 minutes rather than refreshing only when opened, and clicking it calls ctx.layout.selectPanel('dsh-glm-quota').

The strip's reset label is a countdown, not a timestamp: the sidebar is too narrow for a locale-formatted date, and "how long until it recovers" is the figure worth watching. See formatResetIn in lib/client.js.

Credentials are asynchronous

Credentials.resolve/describe return promises of record objects, never bare strings:

const record = await credentials.resolve('GLM_API_KEY') // => { value, source } | undefined

Reading it without await silently yields undefined, which is what made "API key saved." appear next to "No API key configured." in 0.2.0. The card also now confirms the write by re-reading status before reporting success, so a failed read-back surfaces as an error instead of a false positive.

Install

DSH installs plugins from a market index, an npm package, a git repository, or a local directory/tarball.

From this repository:

# DSH: plugin_manager install_bundle with the absolute package directory,
# or from a packed tarball produced by `npm pack`.

The bundle declares dsh.bundle.patch (which inserts the glm-quota entry) and engines.dsh (>=0.2.2-rc.1 <0.3.0-0), so the harness can check compatibility before activating it.

After installing, the plugin appears in four places:

Where What
Sidebar foot the quota strip (wide) or the GLM n% label (56px rail)
Sidebar panel list the gauge icon, opening the full quota page
Settings a GLM Quota section
Plugins → GLM Quota the plugin page card

Upstream

GET {base}/api/monitor/usage/quota/limit, header Authorization: <raw token>:

  • cn → https://open.bigmodel.cn
  • global → https://api.z.ai

Response: { code, msg, success, data: { level, limits: [...] } }.

limits carries the two usage windows in one of two shapes, and both are handled:

Shape 5-hour window Weekly window
TOKENS_LIMIT × 2 first after sorting by nextResetTime second
CREDIT_LIMIT × 2 unit: 3 unit: 6

lite plans answer with CREDIT_LIMIT, which is why a parser that only knew TOKENS_LIMIT reported an empty quota. A TIME_LIMIT row is the monthly MCP allowance (usage total, currentValue used, remaining) and applies under either shape. nextResetTime is epoch milliseconds upstream and ISO in the plugin's output.

Remaining, not consumed

Upstream's percentage is the share already used — 100 means the window is exhausted. Every surface here reports the opposite: remainingPercentage, where 100 is a full allowance and 0 is nothing left. The conversion happens once, in normalizeQuota/makeWindow (lib/index.js), so no renderer has to remember the direction. Bar tones follow the same sense: a nearly empty bar is the warning, not a nearly full one.

Layout

lib/index.js        host plugin (tool + config + /api/glm-quota/query route)
lib/client.js       client bundle (sidebar strip + panel + settings page + plugins-page card)
cordis.patch.yml    bundle patch (insert id: glm-quota)
locale/*.json       plugin meta (en/zh)
docs/DETAIL*.md     plugin detail page text
icon-glm-quota.svg  plugin icon

License

MIT

Content from the project README on GitHub ↗

Links

More in this category

View the whole category →

Community comments

Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.