dsh-token-dash 2.5.0 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +2 -2
- package/README.en.md +55 -91
- package/README.md +54 -91
- package/client.js +134 -33
- package/index.js +19 -2
- package/locale/en.json +10 -1
- package/locale/zh.json +10 -1
- package/package.json +8 -3
- package/src/adapters.js +394 -84
- package/src/collect.js +39 -12
- package/src/core.js +26 -5
- package/src/providers.js +19 -1
- package/src/quota-sources.js +132 -3
- package/src/store.js +15 -0
package/AGENTS.md
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
| 用户说明 / 变更历史 | `README.md` / `README.en.md` | `CHANGELOG.md`、`docs/pic/` |
|
|
14
14
|
| 组件预览 / 草图 | `tools/preview/README.md` | `tools/preview/spec.mjs`、`tools/preview/templates/` |
|
|
15
15
|
| 假数据 / 截图 | `tools/mock/AGENTS.md` | `tools/mock/fixtures.mjs`、`tools/mock/shots.mjs` |
|
|
16
|
-
| Skill 维护 | `.agents/skills/`(项目) | `D:\
|
|
16
|
+
| Skill 维护 | `.agents/skills/`(项目) | `D:\ZProjects\Context-Engineer\skills\`(全局真源) |
|
|
17
17
|
|
|
18
18
|
- active plan / checklist 不在此复制,进目录后按文件头状态判断,避免本文件与文档状态漂移。
|
|
19
19
|
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
### 4.3 Skill 归属
|
|
55
55
|
|
|
56
56
|
- 项目 skill 只放仓库 `.agents/skills/`,不复制到用户层。
|
|
57
|
-
- 全局 skill 真源只放 `D:\
|
|
57
|
+
- 全局 skill 真源只放 `D:\ZProjects\Context-Engineer\skills\`;`~/.agents/skills/<name>` 用 junction 指向 CE,不保留副本。
|
|
58
58
|
- 新增或修改全局 skill 在 CE 内完成再建 junction;项目 skill 与全局 skill 不混放。
|
|
59
59
|
|
|
60
60
|
## 5. 验证、提交与版本
|
package/README.en.md
CHANGED
|
@@ -9,9 +9,8 @@
|
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
11
|
<p align="center">
|
|
12
|
-
See today's model spend, monthly budget headroom, and subscription windows for
|
|
13
|
-
Paste a key and the billing mode is detected automatically; cost, Tokens and cache hits are estimated locally
|
|
14
|
-
export the current month and import it back after switching machines or reinstalling.
|
|
12
|
+
See today's model spend, monthly budget headroom, plus usage and subscription windows for 9 providers right next to the DSH input box.<br />
|
|
13
|
+
Paste a key and the billing mode is detected automatically; cost, Tokens and cache hits are estimated locally, and the current month can be exported.
|
|
15
14
|
</p>
|
|
16
15
|
|
|
17
16
|
<p align="center">
|
|
@@ -23,85 +22,72 @@
|
|
|
23
22
|
<p align="center">
|
|
24
23
|
<img src="https://img.shields.io/github/v/tag/spartawhy117/dsh-token-dash?label=version&sort=semver" alt="version" />
|
|
25
24
|
<img src="https://img.shields.io/npm/dt/dsh-token-dash?logo=npm&label=npm%20downloads" alt="npm downloads" />
|
|
26
|
-
<img src="https://img.shields.io/badge/DSH-0.2.2--rc.
|
|
27
|
-
<img src="https://img.shields.io/github/license/spartawhy117/dsh-token-dash" alt="license" />
|
|
25
|
+
<img src="https://img.shields.io/badge/DSH-0.2.2--rc.5_tested-4c8bf5" alt="DSH tested" />
|
|
26
|
+
<img src="https://img.shields.io/github/license/spartawhy117/dsh-token-dash?label=license" alt="license" />
|
|
28
27
|
<a href="https://awesome-dsh-plugin.com/p/spartawhy117/dsh-token-dash"><img src="https://img.shields.io/badge/awesome--dsh--plugin-listed-6ea8ff" alt="awesome-dsh-plugin" /></a>
|
|
29
28
|
</p>
|
|
30
29
|
|
|
31
|
-
|
|
30
|
+
## Three entry points
|
|
32
31
|
|
|
33
|
-
|
|
32
|
+
- **Pill**: sits at the right of the composer footer; one line shows the current model's budget ring, today's spend and real balance, or one ring per subscription window.
|
|
33
|
+
- **Panel**: click the Pill for budget, balance and the usage table, or 2–3 subscription windows with remaining percentage and countdown; the footer opens the full dashboard.
|
|
34
|
+
- **Full dashboard**: cards for configured providers, a four-cell summary (Tokens / cost / cache hit rate / requests), a metric-switchable trend chart (dual-currency, dual-axis for cost), the model breakdown and the settings capsule.
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
Providers without a key get no card. A failed query keeps the last value and marks it "Data may be stale", or shows "Query failed" when there is none; rate-limited cards keep their last values with a "Rate limited" note.
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
|---|---|---|---|---|
|
|
39
|
-
| DeepSeek | DS account wallet / `DEEPSEEK_API_KEY` | `GET api.deepseek.com/user/balance` | API usage | Balance, month-to-date spend, budget |
|
|
40
|
-
| Zhipu GLM Coding | `ZHIPU_API_KEY` / `GLM_API_KEY` / `ZAI_API_KEY` | `GET bigmodel.cn/api/monitor/usage/quota/limit` | Subscription / API usage | 5h + weekly windows |
|
|
41
|
-
| Kimi Coding | `KIMI_API_KEY` / `KIMI_CODING_API_KEY`, optional `MOONSHOT_API_KEY` | `GET api.kimi.com/coding/v1/usages`; falls back to `GET api.moonshot.cn/v1/users/me/balance` | Subscription / API usage | 5h + weekly/monthly windows; falls back to balance |
|
|
42
|
-
| OpenRouter | `OPENROUTER_API_KEY` | `GET openrouter.ai/api/v1/credits` | API usage | Credits (USD) |
|
|
43
|
-
| Qwen | `DASHSCOPE_API_KEY` (CNY) / `DASHSCOPE_INTL_API_KEY` (USD) | No balance endpoint | API usage | Local usage only; balance unsupported |
|
|
44
|
-
| OpenCode Go | `OPENCODE_API_KEY` / `OPENCODE_GO_API_KEY` | `GET opencode.ai/zen/go/v1/usage`, falls back to `GET opencode.ai/api/v1/usage` | Subscription | 5h / weekly / monthly windows (USD) |
|
|
45
|
-
| Command Code | `COMMAND_CODE_API_KEY` + `COMMAND_CODE_ORG_ID` | `GET api.commandcode.ai/alpha/billing/credits` (with `orgId`) | Subscription | 5h + weekly windows, credits (CNY) |
|
|
46
|
-
| Ollama Cloud | `OLLAMA_API_KEY` | `GET ollama.com/api/balance`; `GET ollama.com/api/usage?range=30d` | API usage | Plan + purchased credits (USD), plan usage, cycle, 30-day channel usage |
|
|
47
|
-
| Any other provider (self-hosted, relay, local Ollama) | None | No endpoint | API usage | Priced by model name only; unpriced rows can be backfilled |
|
|
48
|
-
|
|
49
|
-
- Save keys under the names above in DSH's credential settings; the plugin reads them through the host `credentials` service, not environment variables or local login files.
|
|
50
|
-
- Ollama is added through DSH's custom OpenAI-compatible provider: the route id must be `ollama` (the key reference is derived as `<ROUTE>_API_KEY` → `OLLAMA_API_KEY`). Any other id will not resolve the key and the balance card will not appear.
|
|
51
|
-
- OpenCode Go reads `OPENCODE_API_KEY`, the same name pi-ai uses for its routes, so configuring the LLM route is enough; `OPENCODE_GO_API_KEY` remains accepted. The `<ROUTE>_API_KEY` derivation applies to custom providers only — built-in providers get their names from the pi-ai catalog.
|
|
52
|
-
- Keys are detected automatically; GLM / Kimi / OpenCode Go / Command Code can be re-detected from the dashboard footer.
|
|
53
|
-
- Subscription models count toward Tokens but not cost; billing mode is pinned per key instead of following quota flakiness.
|
|
54
|
-
- Balance, quota and usage are separate; a balance failure never resets today's Token ledger to zero.
|
|
55
|
-
- **Not covered**: no cookies, no provider console scraping, no host config or local login state; balances come from official endpoints only, never through a relay; prices come from the community catalog and OpenRouter's public prices, not from provider bills, so every amount is a local estimate.
|
|
56
|
-
|
|
57
|
-
## Interface
|
|
58
|
-
|
|
59
|
-
Screenshots use mock data so the full layout is visible at once.
|
|
60
|
-
|
|
61
|
-
**P1 · Composer footer-right Pill**: API usage / subscription variants; click to open, click outside, `×` or `Esc` to close. The API variant shows one line of budget ring + today's spend + real balance; the subscription variant shows a ring per window. Colour only signals alerts — a healthy state stays neutral.
|
|
38
|
+
## Preview
|
|
62
39
|
|
|
63
40
|
<p align="center">
|
|
64
|
-
<img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/en/pill-api.png" alt="API usage
|
|
41
|
+
<a href="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/en/pill-api.png"><img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/en/pill-api.png" alt="P1 Pill - API usage" width="49%" /></a>
|
|
42
|
+
<a href="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/en/pill-sub.png"><img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/en/pill-sub.png" alt="P1 Pill - subscription" width="49%" /></a>
|
|
65
43
|
</p>
|
|
66
44
|
|
|
67
45
|
<p align="center">
|
|
68
|
-
<img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/en/
|
|
46
|
+
<a href="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/en/panel-api.png"><img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/en/panel-api.png" alt="P2 panel - API usage" width="49%" /></a>
|
|
47
|
+
<a href="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/en/panel-sub-3.png"><img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/en/panel-sub-3.png" alt="P2 panel - subscription" width="49%" /></a>
|
|
69
48
|
</p>
|
|
70
49
|
|
|
71
|
-
**P2 · Floating panel (current model)**: fixed 380, one row with three groups — used ring / used-budget / real balance — with the balance right-aligned to the panel edge, a full-width range control and the usage table.
|
|
72
|
-
|
|
73
50
|
<p align="center">
|
|
74
|
-
<img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/en/
|
|
51
|
+
<a href="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/en/settings.png"><img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/en/settings.png" alt="P3 full dashboard" width="60%" /></a>
|
|
75
52
|
</p>
|
|
76
53
|
|
|
77
|
-
|
|
78
|
-
<img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/en/panel-sub-2.png" alt="Floating panel - two subscription windows" />
|
|
79
|
-
</p>
|
|
54
|
+
## Supported subscriptions & API keys
|
|
80
55
|
|
|
81
|
-
|
|
82
|
-
<img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/en/panel-sub-3.png" alt="Floating panel - three subscription windows" />
|
|
83
|
-
</p>
|
|
56
|
+
Five of the nine providers expose subscription windows (GLM / Kimi / OpenCode Go / Command Code / MiniMax); the other four expose balance or usage only (DeepSeek / OpenRouter / Qwen / Ollama). GLM and Kimi fall back to API usage when their key returns no subscription windows. GLM / Kimi / Qwen / MiniMax support a China / global switch; after switching, card amounts, the detail table and the four summary cells count only rows in that region's currency, and switch back restores the rest. Any other provider is still recorded, but gets no balance card.
|
|
84
57
|
|
|
85
|
-
|
|
86
|
-
|
|
58
|
+
| Provider | Key / credential | What you get |
|
|
59
|
+
|---|---|---|
|
|
60
|
+
| DeepSeek | DS account wallet / `DEEPSEEK_API_KEY` | API: balance, month-to-date spend, budget |
|
|
61
|
+
| Zhipu GLM Coding | `ZAI_CODING_CN_API_KEY` (China) / `ZAI_API_KEY` (global) / `ZHIPU_API_KEY` / `GLM_API_KEY` | Subscription: 5h + weekly windows; card pill switches China / global |
|
|
62
|
+
| Kimi Coding | `KIMI_API_KEY` / `KIMI_CODING_API_KEY`; optional `MOONSHOT_API_KEY` | Subscription: 5h + weekly/monthly windows; balance fallback; card pill switches China / global |
|
|
63
|
+
| OpenRouter | `OPENROUTER_API_KEY` | API: credits (USD) |
|
|
64
|
+
| Qwen | `DASHSCOPE_API_KEY` (CNY) / `DASHSCOPE_INTL_API_KEY` (USD) / `QWEN_API_KEY` | API: local usage only; no balance; card pill switches China / global |
|
|
65
|
+
| OpenCode Go | `OPENCODE_API_KEY` / `OPENCODE_GO_API_KEY` | Subscription: 5h / weekly / monthly windows (USD) |
|
|
66
|
+
| Command Code | `COMMAND_CODE_API_KEY` + `COMMAND_CODE_ORG_ID` | Subscription: 5h + weekly windows, credits (CNY) |
|
|
67
|
+
| Ollama Cloud | `OLLAMA_API_KEY` | API: plan + purchased credits (USD), 30-day channel usage |
|
|
68
|
+
| MiniMax | `MINIMAX_CN_API_KEY` (China) / `MINIMAX_API_KEY` (global) | Subscription: 5h + weekly windows, region auto-detected; `sk-api-` keys show balance |
|
|
69
|
+
| Any other provider | None | API: priced by model name; unpriced rows can be backfilled |
|
|
87
70
|
|
|
88
|
-
|
|
71
|
+
- Save keys under the names above in DSH's credential settings; the plugin reads only host `credentials` (not env vars or login files) and detects them automatically. Subscription providers can be rechecked from the dashboard footer.
|
|
72
|
+
- For Ollama, use a custom OpenAI-compatible provider with route id `ollama`; OpenCode Go reuses `OPENCODE_API_KEY` once the LLM route is configured.
|
|
73
|
+
- Region (China / global) is a two-segment pill in the card's top-right corner, stored in local settings so it survives restarts. GLM / Kimi / Qwen default from the key name (`ZAI_CODING_CN_API_KEY` → China, `ZAI_API_KEY` → global, `DASHSCOPE_INTL_API_KEY` → global); clicking the other segment switches, and picking the wrong one only changes the currency or fails the query. MiniMax is the exception: a single key is detected automatically, and the other segment is greyed out when only one region is available.
|
|
74
|
+
- Subscription models count Tokens but not cost; the billing mode is fixed per key, and a failed balance query never resets today's ledger.
|
|
75
|
+
- **Not covered**: no cookies, console scraping, host config or local login state.
|
|
89
76
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
77
|
+
## Billing & data sources
|
|
78
|
+
|
|
79
|
+
| Item | Rule |
|
|
80
|
+
|---|---|
|
|
81
|
+
| Tokens | Read from the local session `usage`; input / cache read / cache write / output are accumulated separately; title generation is excluded. |
|
|
82
|
+
| Cost | Prices are matched by model name; each of the four token buckets is multiplied by its price and divided by one million. Estimates are local and marked `≈`, never provider invoices. |
|
|
83
|
+
| Cache hit rate | `cache read ÷ (input + cache write + cache read)`; shows `—` when there is no data. |
|
|
84
|
+
| Subscription | Counts toward Tokens, not cost; the card's "estimated this month" and the subscription estimate in total cost are reference values at API prices. |
|
|
93
85
|
|
|
94
|
-
|
|
95
|
-
- Trend chart: the vertical axis takes its own column outside the plot, with three ticks that follow the selected metric; three grid lines line up with those ticks; the hit-rate axis is pinned to 100% at the top, and a single 0% day cannot drag its floor back to zero. With **two currencies** the cost metric switches to a **dual-axis, two-bar** layout — CNY on the left axis, USD on the right, each scaled to its own maximum, with a colour legend in the header.
|
|
96
|
-
- Total cost tile: includes subscription estimates alongside actual billing, captioned “{n} currencies · incl. estimates”.
|
|
97
|
-
- Breakdown: its own section heading, then model / Tokens / input / cache / output / requests / hit rate / cost; everything except the model column is right-aligned. Cost is always marked `≈` as a local estimate, and subscription rows show what those tokens would cost at API rates (or “not priced”, or `—` when no estimate exists).
|
|
98
|
-
- Settings capsule: refresh interval + account-balance toggle; logs, export/import, price table and version below.
|
|
99
|
-
- The settings section has an external "Settings and data" title above the capsule; the capsule itself keeps the refresh interval, logs/data controls and version row.
|
|
100
|
-
- Spacing uses only 4 / 8 / 12 / 16 / 24 / 32; P2 and P3 share the same tokens.
|
|
86
|
+
Prices come from the community model-price-table ([Gitee mirror](https://gitee.com/oyw125/model-price-table) first, [GitHub](https://github.com/LaoYueHanNi/model-price-table) fallback), with a bundled snapshot when neither is reachable; USD providers also use [OpenRouter](https://openrouter.ai/models) public prices. Matching is by model name; unmatched models show "Unpriced".
|
|
101
87
|
|
|
102
88
|
## Install
|
|
103
89
|
|
|
104
|
-
Requires DSH `0.2.1` or newer
|
|
90
|
+
Requires DSH `0.2.1` or newer (the tested version is shown in the badge); DSH 0.2.2 itself requires Node **24.9+**.
|
|
105
91
|
|
|
106
92
|
```bash
|
|
107
93
|
# Option 1: install from npm (recommended)
|
|
@@ -114,56 +100,34 @@ dsh plugin --profile desktop add github:spartawhy117/dsh-token-dash
|
|
|
114
100
|
dsh plugin --profile desktop add /path/to/dsh-token-dash-x.y.z.tgz
|
|
115
101
|
```
|
|
116
102
|
|
|
117
|
-
Update: run `update` with the same name, or use the update button on the right of
|
|
103
|
+
Update: run `update` with the same name, or use the update button on the right of "Pricing & version" in settings. The plugin checks once at every DSH start and every 4 hours while running; when a new version exists the button shows the version number directly. Remove: run `remove` with the same name; data stays in `$DSH_HOME/dsh-token-dash/`.
|
|
118
104
|
|
|
119
105
|
> If the plugin disappears from the profile after a DSH 0.2.2 upgrade, reinstall the same tarball. The ledger and settings are not deleted with the plugin package.
|
|
120
106
|
|
|
121
107
|
## Compatibility & limitations
|
|
122
108
|
|
|
123
|
-
- DSH `0.2.1+`; verified on `0.2.2-rc.3`. DSH 0.2.2 is a pre-release and itself requires Node 24.9.
|
|
124
109
|
- The UI currently ships Chinese / English only. Other DSH languages (Japanese, German, Russian, etc.) fall back to English.
|
|
125
|
-
- After a DSH upgrade the plugin may disappear from the profile; reinstall the same tarball — the ledger is not deleted.
|
|
126
|
-
- Qwen tracks usage only; its balance endpoint is unsupported. Other balances/quotas follow what each API returns.
|
|
127
110
|
- A USD-billed provider that only matches the CNY price table shows "Unpriced" with a reason instead of rendering CNY numbers as USD.
|
|
128
111
|
- Ollama's balance and usage endpoints share a 10 requests/minute limit; when rate limited the card keeps the last values with a "Rate limited" note and recovers automatically.
|
|
129
|
-
- Upstream APIs are rate-limited;
|
|
112
|
+
- Upstream APIs are rate-limited; balance and quota results are cached for about a minute, failures retry after about 10 seconds, and concurrent requests are coalesced.
|
|
130
113
|
|
|
131
114
|
## Data & privacy
|
|
132
115
|
|
|
133
|
-
-
|
|
116
|
+
- Everything runs locally; no billing requests are made.
|
|
134
117
|
- Balances come from official endpoints only; credentials are resolved by the host and are never written to disk or logs.
|
|
135
118
|
- Data lives in `$DSH_HOME/dsh-token-dash/`: `daily.json`, `months/`, `prefs.json`.
|
|
136
119
|
- Export/import is local: settings + current-month usage, without quotas, balances or logs; the existing files are backed up before an import overwrites them.
|
|
137
120
|
|
|
138
|
-
## Logs &
|
|
139
|
-
|
|
140
|
-
Logs live in `$DSH_HOME/logs/dsh-token-dash/` as JSONL; every line carries `prefix: "[TD:<module>]"` and `module`:
|
|
141
|
-
|
|
142
|
-
```bash
|
|
143
|
-
npm run logs -- --tail 50 # recent 50 lines
|
|
144
|
-
npm run logs -- --module adapter.* # provider detection only
|
|
145
|
-
npm run logs -- --module provider,route # cache / routing issues
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
Common events:
|
|
149
|
-
|
|
150
|
-
- `[TD:adapter.*]`: `quota.ok` / `quota.fail` / `quota.parse` / `balance.*` / `detect.fail`
|
|
151
|
-
- `[TD:provider]`: `probe.miss` (none / hidden / error), `subscriptions.refreshed`, `cache.state`
|
|
152
|
-
- `[TD:route]`: `forbidden` (non-loopback), `failed`
|
|
153
|
-
- Errors carry `errorKind` (http / timeout / network / parse) and `httpStatus`; 5xx adds `upstream: true`.
|
|
154
|
-
|
|
155
|
-
## Development
|
|
121
|
+
## Logs & development
|
|
156
122
|
|
|
157
123
|
```bash
|
|
158
|
-
npm
|
|
159
|
-
npm
|
|
160
|
-
npm run
|
|
161
|
-
npm run shots
|
|
162
|
-
npm run pack
|
|
124
|
+
npm run logs -- --tail 50 # $DSH_HOME/logs/dsh-token-dash/; the settings page opens the folder
|
|
125
|
+
npm test # unit tests
|
|
126
|
+
npm run e2e # end-to-end
|
|
127
|
+
npm run shots # regenerate implementation screenshots
|
|
128
|
+
npm run pack # build the release tarball
|
|
163
129
|
```
|
|
164
130
|
|
|
165
|
-
Releases: pushing a `v*` tag triggers the GitHub Release (tarball) and a direct npm publish automatically (Trusted Publishing via OIDC, with provenance); see [docs/release.md](./docs/release.md) for the full checklist.
|
|
166
|
-
|
|
167
131
|
## Acknowledgements
|
|
168
132
|
|
|
169
133
|
Attribution and billing semantics learned from these community plugins:
|
|
@@ -174,5 +138,5 @@ Attribution and billing semantics learned from these community plugins:
|
|
|
174
138
|
- [dsh-spend](https://github.com/nonewind/dsh-spend)
|
|
175
139
|
- [dsh-stats-panel](https://github.com/zhang-jiazhi/dsh-stats-panel)
|
|
176
140
|
- [DshCockpit](https://github.com/Lxiayu/DshCockpit)
|
|
177
|
-
- [shy3130/dsh-quota](https://github.com/shy3130/dsh-quota)
|
|
178
|
-
- [InvisibleSirius/dsh-quota-dashboard](https://github.com/InvisibleSirius/dsh-quota-dashboard)
|
|
141
|
+
- [shy3130/dsh-quota](https://github.com/shy3130/dsh-quota)
|
|
142
|
+
- [InvisibleSirius/dsh-quota-dashboard](https://github.com/InvisibleSirius/dsh-quota-dashboard)
|
package/README.md
CHANGED
|
@@ -9,9 +9,8 @@
|
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
11
|
<p align="center">
|
|
12
|
-
在 DSH
|
|
13
|
-
填 Key 自动识别订阅或 API 用量;费用、Tokens
|
|
14
|
-
当月数据可导出备份,换机或重装后一键导入恢复。
|
|
12
|
+
在 DSH 输入框旁看清今天的模型消耗、本月预算余量和 9 家供应商的用量与订阅窗口。<br />
|
|
13
|
+
填 Key 自动识别订阅或 API 用量;费用、Tokens 与缓存命中全部在本地估算,当月数据可导出备份。
|
|
15
14
|
</p>
|
|
16
15
|
|
|
17
16
|
<p align="center">
|
|
@@ -23,84 +22,70 @@
|
|
|
23
22
|
<p align="center">
|
|
24
23
|
<img src="https://img.shields.io/github/v/tag/spartawhy117/dsh-token-dash?label=version&sort=semver" alt="version" />
|
|
25
24
|
<img src="https://img.shields.io/npm/dt/dsh-token-dash?logo=npm&label=npm%20downloads" alt="npm downloads" />
|
|
26
|
-
<img src="https://img.shields.io/badge/DSH-0.2.2--rc.
|
|
27
|
-
<img src="https://img.shields.io/github/license/spartawhy117/dsh-token-dash" alt="license" />
|
|
25
|
+
<img src="https://img.shields.io/badge/DSH-0.2.2--rc.5_tested-4c8bf5" alt="DSH tested" />
|
|
26
|
+
<img src="https://img.shields.io/github/license/spartawhy117/dsh-token-dash?label=license" alt="license" />
|
|
28
27
|
<a href="https://awesome-dsh-plugin.com/zh/p/spartawhy117/dsh-token-dash"><img src="https://img.shields.io/badge/awesome--dsh--plugin-listed-6ea8ff" alt="awesome-dsh-plugin" /></a>
|
|
29
28
|
</p>
|
|
30
29
|
|
|
31
|
-
|
|
30
|
+
## 三个入口
|
|
32
31
|
|
|
33
|
-
|
|
32
|
+
- **Pill**:输入框底栏右侧,一行看当前模型的预算环、今日花费与真实余额;订阅模型显示各窗口的用量环。
|
|
33
|
+
- **浮层**:点 Pill 展开,API 态看预算、余额与用量表,订阅态看 2–3 个窗口的剩余百分比与倒计时;底部可进全量看板。
|
|
34
|
+
- **整页看板**:已配置供应商的卡片、四格摘要(Tokens / 费用 / 缓存命中率 / 请求)、可切指标的趋势图(费用支持双币种双轴)、模型明细与底部设置胶囊。
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
未配置的供应商不出卡;查询失败时保留上一次结果并标「数据待更新」,没有旧数据则显示「查询失败」;限流时保留数值并标「限流中」。
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
|---|---|---|---|---|
|
|
39
|
-
| DeepSeek | DS 账号钱包 / `DEEPSEEK_API_KEY` | `GET api.deepseek.com/user/balance` | API 用量 | 账户余额、本月已花、预算 |
|
|
40
|
-
| Zhipu GLM Coding | `ZHIPU_API_KEY` / `GLM_API_KEY` / `ZAI_API_KEY` | `GET bigmodel.cn/api/monitor/usage/quota/limit` | 订阅 / API 用量 | 5h + 周窗口 |
|
|
41
|
-
| Kimi Coding | `KIMI_API_KEY` / `KIMI_CODING_API_KEY`,可选 `MOONSHOT_API_KEY` | `GET api.kimi.com/coding/v1/usages`;回落 `GET api.moonshot.cn/v1/users/me/balance` | 订阅 / API 用量 | 5h + 周/月窗口;订阅查询失败可回落余额 |
|
|
42
|
-
| OpenRouter | `OPENROUTER_API_KEY` | `GET openrouter.ai/api/v1/credits` | API 用量 | Credits(USD) |
|
|
43
|
-
| Qwen | `DASHSCOPE_API_KEY`(CNY)/ `DASHSCOPE_INTL_API_KEY`(USD) | 不请求余额接口 | API 用量 | 仅本地用量;余额不支持 |
|
|
44
|
-
| OpenCode Go | `OPENCODE_API_KEY` / `OPENCODE_GO_API_KEY` | `GET opencode.ai/zen/go/v1/usage`,回落 `GET opencode.ai/api/v1/usage` | 订阅 | 5h / 周 / 月窗口(USD) |
|
|
45
|
-
| Command Code | `COMMAND_CODE_API_KEY` + `COMMAND_CODE_ORG_ID` | `GET api.commandcode.ai/alpha/billing/credits`(带 `orgId`) | 订阅 | 5h + 周窗口、Credits(CNY) |
|
|
46
|
-
| Ollama Cloud | `OLLAMA_API_KEY` | `GET ollama.com/api/balance`;`GET ollama.com/api/usage?range=30d` | API 用量 | 套餐剩余 + 购买余额(USD)、套餐已用、周期、渠道 30 天用量 |
|
|
47
|
-
| 其他任意 provider(自建、中转、Ollama 本地) | 无需凭据 | 不请求任何接口 | API 用量 | 只按模型名计价;未定价可补算 |
|
|
48
|
-
|
|
49
|
-
- 在 DSH 的凭据设置中按上表名称保存 Key;插件只通过宿主 `credentials` 读取,不读环境变量或本机登录文件。
|
|
50
|
-
- Ollama 在 DSH 里需要用「自定义 OpenAI 兼容供应商」接入:route id 必须填 `ollama`(凭据按 `<ROUTE>_API_KEY` 派生成 `OLLAMA_API_KEY`),自定义名填别的会取不到 Key,余额卡也不会出现。
|
|
51
|
-
- OpenCode Go 的 `OPENCODE_API_KEY` 与 pi-ai 路由配置同名,配好 LLM 路由后无需再填第二份;旧名 `OPENCODE_GO_API_KEY` 仍兼容。`<ROUTE>_API_KEY` 派生只适用于自定义供应商,内置供应商的凭据名由 pi-ai 目录决定。
|
|
52
|
-
- 填 Key 后自动探测;GLM / Kimi / OpenCode Go / Command Code 可在「全量看板」底部重新检测订阅。
|
|
53
|
-
- 订阅模型计入 Tokens,但不计费用;计费形态按 Key 固化,不随配额接口抖动。
|
|
54
|
-
- 余额、配额、用量分开展示;余额失败不会把当天的 Token 记账清零。
|
|
55
|
-
- **不覆盖**:不读 Cookie、不抓供应商控制台页面、不读宿主配置文件或本机登录态;余额只查官方接口,不经第三方中转;价格来自社区价目表与 OpenRouter 公开价,不来自供应商账单,金额均为本地估算。
|
|
56
|
-
|
|
57
|
-
## 界面
|
|
58
|
-
|
|
59
|
-
以下截图使用假数据演示,便于一次看到完整效果。
|
|
60
|
-
|
|
61
|
-
**P1 · 输入框底栏右侧 Pill**:API 用量 / 订阅两种形态,点击展开浮层,点击外部、`×` 或 `Esc` 收起。API 态一行显示「预算环 + 今日花费 + 真实余额」,订阅态显示各窗口的用量环;颜色只表达告警,正常时保持中性色。
|
|
38
|
+
## 页面预览
|
|
62
39
|
|
|
63
40
|
<p align="center">
|
|
64
|
-
<img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/
|
|
41
|
+
<a href="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/readme-p1.png"><img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/readme-p1.png" alt="P1 输入框 Pill" width="60%" /></a>
|
|
65
42
|
</p>
|
|
66
43
|
|
|
67
44
|
<p align="center">
|
|
68
|
-
<img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/
|
|
45
|
+
<a href="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/readme-p2.png"><img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/readme-p2.png" alt="P2 浮层" width="60%" /></a>
|
|
69
46
|
</p>
|
|
70
47
|
|
|
71
|
-
**P2 · 浮层(当前模型)**:固定 380,单行三组「已用环 / 已用·预算 / 真实余额」,真实余额右对齐到面板右缘;时间范围撑满,下面是用量表。
|
|
72
|
-
|
|
73
48
|
<p align="center">
|
|
74
|
-
<img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/
|
|
49
|
+
<a href="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/settings.png"><img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/settings.png" alt="P3 整页看板" width="60%" /></a>
|
|
75
50
|
</p>
|
|
76
51
|
|
|
77
|
-
|
|
78
|
-
<img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/panel-sub-2.png" alt="浮层 · 订阅两窗" />
|
|
79
|
-
</p>
|
|
52
|
+
## 支持的订阅与 API Key
|
|
80
53
|
|
|
81
|
-
|
|
82
|
-
<img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/panel-sub-3.png" alt="浮层 · 订阅三窗" />
|
|
83
|
-
</p>
|
|
54
|
+
9 家里 5 家能读订阅窗口(GLM / Kimi / OpenCode Go / Command Code / MiniMax),4 家读余额或只统计用量(DeepSeek / OpenRouter / Qwen / Ollama);GLM / Kimi 的 Key 探测不到订阅窗口时,按 API 用量记账。GLM / Kimi / Qwen / MiniMax 支持中国 / 海外区切换;切换后卡片金额、明细与四格合计只统计该区币种的账,切回即恢复。任意其它 provider 仍可记账,但没有余额卡。
|
|
84
55
|
|
|
85
|
-
|
|
86
|
-
|
|
56
|
+
| 供应商 | 需要的 Key / 凭据 | 你能看到 |
|
|
57
|
+
|---|---|---|
|
|
58
|
+
| DeepSeek | DS 账号钱包 / `DEEPSEEK_API_KEY` | API:余额、本月已花、预算 |
|
|
59
|
+
| Zhipu GLM Coding | `ZAI_CODING_CN_API_KEY`(中国)/ `ZAI_API_KEY`(海外)/ `ZHIPU_API_KEY` / `GLM_API_KEY` | 订阅:5h + 周窗口;卡顶胶囊切中国 / 海外 |
|
|
60
|
+
| Kimi Coding | `KIMI_API_KEY` / `KIMI_CODING_API_KEY`;可选 `MOONSHOT_API_KEY` | 订阅:5h + 周/月窗口;可回落余额;卡顶胶囊切中国 / 海外 |
|
|
61
|
+
| OpenRouter | `OPENROUTER_API_KEY` | API:Credits(USD) |
|
|
62
|
+
| Qwen | `DASHSCOPE_API_KEY`(CNY)/ `DASHSCOPE_INTL_API_KEY`(USD)/ `QWEN_API_KEY` | API:仅本地用量;余额不支持;卡顶胶囊切中国 / 海外 |
|
|
63
|
+
| OpenCode Go | `OPENCODE_API_KEY` / `OPENCODE_GO_API_KEY` | 订阅:5h / 周 / 月窗口(USD) |
|
|
64
|
+
| Command Code | `COMMAND_CODE_API_KEY` + `COMMAND_CODE_ORG_ID` | 订阅:5h + 周窗口、Credits(CNY) |
|
|
65
|
+
| Ollama Cloud | `OLLAMA_API_KEY` | API:套餐剩余 + 购买余额(USD)、30 天渠道用量 |
|
|
66
|
+
| MiniMax | `MINIMAX_CN_API_KEY`(国内)/ `MINIMAX_API_KEY`(国际) | 订阅:5h + 周窗口,自动识别国内/国际站;`sk-api-` 按量 Key 显示余额 |
|
|
67
|
+
| 其它任意 provider | 无需凭据 | API:按模型名计价;未定价可补算 |
|
|
87
68
|
|
|
88
|
-
|
|
69
|
+
- 在 DSH 凭据设置里按上表名称保存 Key;插件只读宿主 `credentials`,不读环境变量或登录文件,保存后自动探测,订阅类可在看板底部重新检测。
|
|
70
|
+
- Ollama 用「自定义 OpenAI 兼容供应商」接入,route id 必须填 `ollama`;OpenCode Go 配好 LLM 路由即可复用 `OPENCODE_API_KEY`。
|
|
71
|
+
- 区域(中国 / 海外)用卡顶右上角的两段胶囊切换,写在本地设置里、重启保持:GLM / Kimi / Qwen 由 Key 名给出默认区(`ZAI_CODING_CN_API_KEY` → 中国、`ZAI_API_KEY` → 海外、`DASHSCOPE_INTL_API_KEY` → 海外),点另一段即可切换、切错只是币种不对或查询失败;MiniMax 例外,只填 Key 就自动识别,单 Key 时另一段置灰。
|
|
72
|
+
- 订阅模型只计 Tokens、不计费用;计费形态按 Key 固定,余额查询失败不会清零当天记账。
|
|
73
|
+
- **不覆盖**:不读 Cookie、控制台、宿主配置或本机登录态。
|
|
89
74
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
75
|
+
## 计费与统计口径
|
|
76
|
+
|
|
77
|
+
| 项 | 规则 |
|
|
78
|
+
|---|---|
|
|
79
|
+
| Tokens | 只读本地会话 `usage`,输入 / 缓存读 / 缓存写 / 输出分开累计;标题生成不计。 |
|
|
80
|
+
| 费用 | 按模型名匹配价目表,四段 Tokens 分别乘单价后按百万 Tokens 折算;全程本地估算,界面用 `≈` 标注,不是供应商账单。 |
|
|
81
|
+
| 缓存命中率 | `缓存读 ÷(输入 + 缓存写 + 缓存读)`;没有数据时显示 `—`。 |
|
|
82
|
+
| 订阅 | 计入 Tokens,不计费用;卡片「本月估算」与总费用里的订阅估算,都是按 API 价折算的参考值。 |
|
|
93
83
|
|
|
94
|
-
-
|
|
95
|
-
- 趋势图:纵坐标独立占左侧一列(在绘图区之外),三档刻度随指标切换;上 / 中 / 下三条网格线与刻度对齐;命中率轴顶档固定 100%,单个 0% 日不会把下限拉回 0。切到「费用」且出现两种币种时改为**双轴双柱**:人民币走左轴、美元走右轴,各自按自身最大值缩放,标题行给色块图例。
|
|
96
|
-
- 四格总费用:与实际计费同列,**含订阅估算**,副行标注「{n} 个币种 · 含估算」。
|
|
97
|
-
- 明细表:独立「模型明细」区块,模型 / Tokens / 输入 / 缓存 / 输出 / 请求 / 命中 / 费用;除模型列外全部右对齐。费用一律以 `≈` 标注为本地估算,订阅行给出「若按 API 计」的估算金额(无价显示「未定价」,无估算数据显示 `—`)。
|
|
98
|
-
- 设置区:胶囊外是「设置与数据管理」区块标题;胶囊内第一行刷新间隔 + 账户余额开关,下面是日志、导出导入、价格表与版本。
|
|
99
|
-
- 间距只使用 4 / 8 / 12 / 16 / 24 / 32 六档,P2 / P3 同一套 token。
|
|
84
|
+
价格来源:社区价目表([Gitee 镜像](https://gitee.com/oyw125/model-price-table) 优先,[GitHub](https://github.com/LaoYueHanNi/model-price-table) 兜底),取不到时用插件内置快照;美元供应商再参考 [OpenRouter 公开价](https://openrouter.ai/models)。按模型名匹配,匹配不到显示「未定价」。
|
|
100
85
|
|
|
101
86
|
## 安装
|
|
102
87
|
|
|
103
|
-
需要 DSH `0.2.1`
|
|
88
|
+
需要 DSH `0.2.1` 或更新版本(已验证版本见徽章);DSH 0.2.2 自身要求 Node **24.9+**。
|
|
104
89
|
|
|
105
90
|
```bash
|
|
106
91
|
# 方式一:npm 安装(推荐)
|
|
@@ -109,60 +94,38 @@ dsh plugin --profile desktop add dsh-token-dash
|
|
|
109
94
|
# 方式二:GitHub 仓库直装(纯 JS 无构建,源码即产物)
|
|
110
95
|
dsh plugin --profile desktop add github:spartawhy117/dsh-token-dash
|
|
111
96
|
|
|
112
|
-
# 方式三:从 Releases 下载 dsh-token-dash-x.y.z.tgz
|
|
97
|
+
# 方式三:从 Releases 下载 dsh-token-dash-x.y.z.tgz 后本地安装(离线)
|
|
113
98
|
dsh plugin --profile desktop add /path/to/dsh-token-dash-x.y.z.tgz
|
|
114
99
|
```
|
|
115
100
|
|
|
116
|
-
更新:`update`
|
|
101
|
+
更新:`update` 同名命令,或在插件设置页「价格与版本」右侧的更新按钮内完成——每次启动 DSH 与运行中每 4 小时会自动检查,发现新版本时按钮直接显示版本号。卸载:`remove` 同名命令,数据保留在 `$DSH_HOME/dsh-token-dash/`。
|
|
117
102
|
|
|
118
103
|
> DSH 0.2.2 升级后如果插件从 profile 消失,重装同一个 tarball 即可;账本与设置不随插件包删除。
|
|
119
104
|
|
|
120
105
|
## 兼容与限制
|
|
121
106
|
|
|
122
|
-
- DSH `0.2.1+`;已在 `0.2.2-rc.3` 上验证。DSH 0.2.2 是预发布版,且自身要求 Node 24.9。
|
|
123
107
|
- 界面语言当前仅中文 / English;选择日语、德语、俄语等其他 DSH 语言时,插件文案显示英文回退。
|
|
124
|
-
- 升级 DSH 后插件可能从 profile 消失,重装同一个 tarball 即可,账本不会被删。
|
|
125
|
-
- Qwen 只统计用量,余额接口不支持;其余供应商的余额/配额以接口实际返回为准。
|
|
126
108
|
- 美元结算的供应商如果只命中人民币价目表,该模型会显示「未定价」并给出原因,不会把人民币数值当成美元。
|
|
127
109
|
- Ollama 的余额与用量接口共享 10 次/分钟限流;触发限流时卡片保留上次数值并标「限流中」,恢复后自动更新。
|
|
128
|
-
-
|
|
110
|
+
- 上游接口有速率限制;余额与配额结果会缓存约 1 分钟,失败后约 10 秒重试,并发请求会合并。
|
|
129
111
|
|
|
130
112
|
## 数据与隐私
|
|
131
113
|
|
|
132
|
-
-
|
|
114
|
+
- 数据只在本机处理,不发起任何计费请求。
|
|
133
115
|
- 余额只访问官方接口;凭据经宿主解析,不落盘、不写日志。
|
|
134
116
|
- 数据默认在 `$DSH_HOME/dsh-token-dash/`:`daily.json`、`months/`、`prefs.json`。
|
|
135
117
|
- 导出 / 导入都在本地完成:导出设置 + 当月使用数据,不含配额、余额与日志;导入覆盖前会备份原文件。
|
|
136
118
|
|
|
137
|
-
##
|
|
138
|
-
|
|
139
|
-
日志在 `$DSH_HOME/logs/dsh-token-dash/`,JSONL,每行带 `prefix: "[TD:<module>]"` 与 `module`:
|
|
140
|
-
|
|
141
|
-
```bash
|
|
142
|
-
npm run logs -- --tail 50 # 最近 50 条
|
|
143
|
-
npm run logs -- --module adapter.* # 只看供应商侦测
|
|
144
|
-
npm run logs -- --module provider,route # 缓存 / 路由异常
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
常见事件:
|
|
148
|
-
|
|
149
|
-
- `[TD:adapter.*]`:`quota.ok` / `quota.fail` / `quota.parse` / `balance.*` / `detect.fail`
|
|
150
|
-
- `[TD:provider]`:`probe.miss`(未配置 / 隐藏 / 失败)、`subscriptions.refreshed`、`cache.state`
|
|
151
|
-
- `[TD:route]`:`forbidden`(非回环请求)、`failed`
|
|
152
|
-
- 错误带 `errorKind`(http / timeout / network / parse)与 `httpStatus`;5xx 额外 `upstream: true`
|
|
153
|
-
|
|
154
|
-
## 开发
|
|
119
|
+
## 日志与开发
|
|
155
120
|
|
|
156
121
|
```bash
|
|
157
|
-
npm
|
|
158
|
-
npm
|
|
159
|
-
npm run
|
|
160
|
-
npm run shots
|
|
161
|
-
npm run pack
|
|
122
|
+
npm run logs -- --tail 50 # 日志:$DSH_HOME/logs/dsh-token-dash/,设置页可打开
|
|
123
|
+
npm test # 单元测试
|
|
124
|
+
npm run e2e # 端到端
|
|
125
|
+
npm run shots # 重生成实现侧截图
|
|
126
|
+
npm run pack # 生成发布 tarball
|
|
162
127
|
```
|
|
163
128
|
|
|
164
|
-
发版:推 `v*` tag 自动触发 GitHub Release(tarball)与 npm 直发(Trusted Publishing / OIDC,含 provenance);完整流程见 [docs/release.md](./docs/release.md)。
|
|
165
|
-
|
|
166
129
|
## 致谢
|
|
167
130
|
|
|
168
131
|
归属与计费语义参考了以下社区插件:
|
|
@@ -173,5 +136,5 @@ npm run pack # 发布 tarball 生成到 build/
|
|
|
173
136
|
- [dsh-spend](https://github.com/nonewind/dsh-spend)
|
|
174
137
|
- [dsh-stats-panel](https://github.com/zhang-jiazhi/dsh-stats-panel)
|
|
175
138
|
- [DshCockpit](https://github.com/Lxiayu/DshCockpit)
|
|
176
|
-
- [shy3130/dsh-quota](https://github.com/shy3130/dsh-quota)
|
|
177
|
-
- [InvisibleSirius/dsh-quota-dashboard](https://github.com/InvisibleSirius/dsh-quota-dashboard)
|
|
139
|
+
- [shy3130/dsh-quota](https://github.com/shy3130/dsh-quota)
|
|
140
|
+
- [InvisibleSirius/dsh-quota-dashboard](https://github.com/InvisibleSirius/dsh-quota-dashboard)
|