DeepSeek Harness plugin

dsh-balance-monitor-alanzhao

DeepSeek account balance, remaining-ratio bar, and today's spend in the dsh sidebar footer.

Jump to install

Source facts

Repository
alanzhao0128/dsh-balance-monitor
Latest update
Aug 21, 2026
Category
Development & Runtime
GitHub stars
2
Format
plugin
Catalog evidence
Upstream dsh.bundle evidence
Evidence path
package.json#dsh.bundle
Checked against
0.1.0-rc.8
Upstream check date
2026-08-20

This evidence comes from the upstream catalog. This site has not installed, run, or security-reviewed the plugin.

Install

Start with a prompt that asks an agent to review the GitHub repository and source. Switch to the command if you want to install it yourself.

Copy this prompt into DSH, Codex, or another agent and ask it to review the GitHub repository and source first.

Do not install or run any commands yet. Read this plugin's GitHub repository, README, and relevant source code. Then answer the questions below clearly and directly so I can decide whether it fits my needs:

1. What is this plugin, and what problem does it solve?
2. Who is it for, and what are its typical use cases?
3. How is it used after installation? Include one minimal example.
4. What known limitations or privacy, security, compatibility, or maintenance risks does it have?
5. Give a clear recommendation: recommend, conditionally recommend, or do not recommend, with reasons.

Distinguish statements documented by the repository, inferences from source code, and unknowns. If evidence is insufficient, say so explicitly. Do not guess or simply repeat the README.

GitHub: https://github.com/alanzhao0128/dsh-balance-monitor
Plugin: dsh-balance-monitor-alanzhao
Author: alanzhao0128

Check the source files

Read the README and other files from this plugin directory before installing.

File explorer4 files
README.en.mdSource · read only
README language

English | 简体中文

dsh-balance-monitor

DeepSeek balance and spend windows, right in the dsh sidebar footer.

A minimal DeepSeek Harness (dsh) plugin that shows the current session's channel balance/usage in the sidebar footer, styled with the stock design tokens. The DeepSeek official channel shows balance plus today / 7-day / 30-day spend windows (official usage data when a platform token is set); the Volcano Ark channel shows Agent Plan quota bars (5h / weekly / monthly).

<p align="center"> <img src="docs/preview/balance-wide.png" alt="dsh-balance-monitor in the sidebar footer" width="280"> <img src="docs/preview/balance-rail.png" alt="dsh-balance-monitor collapsed to the rail" width="56"> </p>

Features

WhatHow
Live balanceQueries GET https://api.deepseek.com/user/balance through the host half, using the DEEPSEEK_API_KEY from $DSH_HOME/.credentials.yaml (env var wins)
Today / 7d / 30d spend (official)With DEEPSEEK_PLATFORM_TOKEN set, the host queries the official usage API platform.deepseek.com/api/v0/usage/cost (the same data the platform console shows) and sums per-day windows: 7d = today minus 6 days, 30d = today minus 29 days (both inclusive). Accurate no matter where else the API key is used
Balance-delta fallbackWithout the platform token (or when the official API fails), today falls back to a balance-drop ledger (only accumulating drops; refills never inflate or wash out spend); 7d/30d show
Channel awarenessThe card follows the current session's model provider: the DeepSeek official channel shows balance/spend; the Volcano Ark channel shows Agent Plan bars; other channels show a "channel not supported" placeholder; no session renders nothing
Volcano Ark Agent PlanWith AK/SK configured, calls the GetAFPUsage control-plane API (SigV4 signed) and shows 5h / weekly / monthly quota bars, colored by usage (green → amber → red)
PlacementRegistered on the official sidebar.footer.action slot — above Settings, no patch hacks
Collapsed railShrinks to a 36px circle with a compact balance and a tooltip
Resilience60s polling + re-poll on tab visibility; on upstream failure the last known numbers stay visible (dimmed as stale) instead of an error flash

Install

Works from source directly — the browser bundle is a hand-written classic script with no build step, so a git install needs no prepare script:

dsh plugin --profile web add "github:alanzhao0128/dsh-balance-monitor#main"

or from npm (once published):

dsh plugin --profile web add dsh-balance-monitor

Then restart the Web UI (dsh --profile web). The widget appears at the bottom of the expanded sidebar, above Settings.

Configuration

Both credentials live in $DSH_HOME/.credentials.yaml (write them from the Web UI Models page, or edit the file directly):

CredentialRequiredPurpose
DEEPSEEK_API_KEYBalance lookup api.deepseek.com/user/balance
DEEPSEEK_PLATFORM_TOKENoptionalOfficial usage (today/7d/30d). Get it: sign in at platform.deepseek.com → DevTools Console, run JSON.parse(localStorage.getItem('userToken')).value, store the output as the credential

> ⚠️ DEEPSEEK_PLATFORM_TOKEN is a web-session token and expires (the official API returns code 40002/40003 when stale). On expiry the plugin silently falls back to the balance-delta estimate; refresh the token from the console and update the credential. Balance lookup is unaffected.

CredentialRequiredPurpose
ARK_ACCESS_KEY_IDVolcano Ark channelVolcengine access key for the control-plane API (Agent Plan quota)
ARK_SECRET_ACCESS_KEYVolcano Ark channelVolcengine secret access key

> Get Ark AK/SK: sign in at console.volcengine.com → Access Control → API Access Keys → create a key. Note: AK/SK are IAM account-level credentials that can operate all resources — keep them private.

How it works

One combined plugin row (dsh.bundle patch + dsh.client roster declaration):

  • Host half (lib/index.js) — registers two RPC channels (loopback trust fence) on ctx.connection: /balance (DeepSeek balance + official usage windows + fallback ledger) and /ark-quota (Volcano Ark Agent Plan quota, signed with AK/SK SigV4 against GetAFPUsage, cached for 40s — strictly below the browser's 60s poll so every poll triggers a fresh upstream fetch).
  • Browser half (lib/client.js) — a zero-dependency classic-script bundle registering a sidebar.footer.action entry. It tracks the current session's provider via sessions.list subscription plus a light 1s poll of session.models (a local RPC), then dispatches through the channel registry: deepseek-official renders the balance card (60s polling, re-poll on tab visibility); huoshan renders the Ark quota bars; unregistered channels render the unsupported placeholder; no session renders nothing. The llm/adapters-updated remote event triggers an immediate re-check.

State file ($DSH_HOME/storages/balance-monitor.json):

{
  "date": "2026-08-17",
  "dayStart": 100.0,
  "lastTotal": 97.7,
  "lastCurrency": "CNY",
  "spent": 1.65,
  "spent7d": 5.24,
  "spent30d": 18.54,
  "spentSource": "official",
  "updatedAt": 1755400000000
}

spentSource is official (platform API) or estimate (balance-delta ledger).

Security notes

  • The API key, platform token, and Ark AK/SK never leave the host: the browser half only ever sees balance/spend/quota numbers over the RPC channel, never the credentials.
  • The channel is served under the loopback trust authority.
  • No telemetry, no network beyond the official balance, usage, and Ark quota endpoints.

Layout

dsh-balance-monitor/
├── package.json        # dsh.bundle (patch) + dsh.client (browser roster)
├── cordis.patch.yml    # inserts the one combined plugin row
└── lib/
    ├── index.js        # host half: /balance + /ark-quota RPC channels
    ├── client.js       # browser half: sidebar footer card (hand-written, no build)
    └── signature.js    # Volcengine OpenAPI SigV4 signing (AK/SK)

Development

No toolchain required. Edit lib/*.js directly; the bundle format mirrors what the official tsdown preset emits (window.__ModuleLoader__.load({ id, factory })).

License

MIT