dsh-token-workbench
dragonestdwolf/dsh-token-workbench
给 token plan 用户的 Token 用量工作台:把会话日志里的 assistant/message usage 折成按天分片的调用级明细(按跨会话 responseId 去重,fork/resume 复制的历史只算一次),并按你填写的套餐口径把本机用量换算成积分(默认 1M token = 0.2 积分,日 600 / 周 2500 / 月 6000,可只统计指定通道),在输入框下方给常驻读数、在设置页给分通道成本表、7/30 天柱状与折线趋势、近半年热力图。不读取任何凭据:厂商藏在控制面接口里的剩余百分比,用明确标注「本机换算」的本地口径替代;参考金额来自公开的 DeepSeek 定价页。
安装
dsh plugin --profile web add github:dragonestdwolf/dsh-token-workbenchREADME
dsh-token-workbench
Token usage workbench for DeepSeek Harness (dsh). It reads the model-usage records already present in the session log, keeps a per-day detail store, turns them into tokens / cost / call numbers, and shows them in two places inside the app:
- Composer dock readout — today's tokens, reference cost and today's plan credits right above the composer, at a glance.
- Settings page → 「Token 工作台」 — overview card, plan-quota block (day / week / month credits with an inline「口径」editor), per-provider table, 7-day / 30-day trend charts and a rolling six-month heatmap, with paging for the granularity you picked and for the heatmap window.
The plan-quota block converts local token volume into plan credits with the terms you enter (default: 1M tokens = 0.2 credits, caps 600 / 2500 / 6000, all four usage buckets scored). Windows are Beijing natural day / week (Monday 00:00) / month. It is a local estimate — the provider console is the only authority — and it reuses the same fork-deduped call log as the other blocks, so it can only be as complete as what this machine captured.
The「口径」editor also carries a channel filter (统计通道): the block scores
either every channel (the default, providers: []) or only the ones you tick —
the plan is usually bought on one gateway, so counting a second gateway's local
traffic would inflate the percentage. The block title always states the current
scope (「全部通道」/「仅 volcano-gateway」), and the dock's credit segment follows
the same filter.
Cost is a reference figure: tokens are multiplied by the official DeepSeek price list (peak / off-peak tiers, Beijing time 00:30–08:30 is off-peak). The price list is fetched from the DeepSeek pricing page and cached; when it cannot be fetched, a frozen default list is used and the UI says so.
Install
# from the published package
dsh plugin --profile web add dsh-token-workbench
# or straight from the release tarball
dsh plugin --profile web add https://github.com/dragonestdwolf/dsh-token-workbench/releases/download/v0.1.0/dsh-token-workbench-0.1.0.tgz
dsh plugin is the supported path: it records the package in the profile and
applies the dsh.bundle.patch entry (cordis.patch.yml) that inserts the
plugin into that profile's layer stack. A bare npm install does not mount
anything. It needs a dsh ^0.2.1-rc.0 host with the web (client) platform
enabled, then a restart of the app.
Privacy
- Everything is computed locally from the session logs dsh already writes to your DSH home; the plugin does not upload usage data anywhere.
- The only outbound request is the pricing page fetch (DeepSeek official pricing), and only to read numbers; if it fails the frozen default applies.
- No credentials, cookies or API keys are read or stored.
Development
The repository ships a set of local checks. None of them are part of the published package.
npm run check # syntax-check the three entry points
npm run fixtures # regenerate the synthetic session-log fixtures
npm run smoke # Host-half assertions against the synthetic fixtures
npm run probe # browser harness: client bundle + settings jump
npm run pack:dry # npm pack --dry-run (what would be published)
node scripts/plan-selfcheck.mjs # read-only: plan credits from the real store
node scripts/check-alignment.mjs --page client # layout baseline of the real bundle
scripts/make-fixtures.mjs writes fixtures/:
The fixtures are synthetic. They are generated session logs with invented provider and model names, invented token usage and invented prompt/tool text (
synthetic fixture ...). They exist only so the smoke suite can fold real event shapes without shipping anyone's conversation content, and they are excluded from the published package. The generator is deterministic: running it twice produces byte-identical files.
The browser probes (scripts/probe-*.mjs) drive headless Chrome/Chromium
($DSH_CHROME overrides the binary) and load the harness pages from
scripts/; those pages resolve React UMD from ?nodeModules= or a
checkout-local node_modules ($DSH_NODE_MODULES overrides the lookup). React
is a dev-only tool for the harness, never a package dependency.
License
MIT — see LICENSE.