dsh-cost-meter 1.9.57 → 1.9.59
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/README.md +124 -586
- package/README.zh-CN.md +124 -590
- package/docs/architecture.en.md +50 -0
- package/docs/architecture.md +50 -0
- package/docs/billing-currency.md +4 -4
- package/docs/billing.en.md +42 -0
- package/docs/billing.md +42 -0
- package/docs/billion-context-billing.md +39 -3
- package/docs/catalog-2026-11-05.md +38 -0
- package/docs/cliproxyapi-quota.md +23 -0
- package/docs/custom-balance-sources.en.md +150 -0
- package/docs/custom-balance-sources.md +206 -124
- package/docs/display-settings.md +67 -67
- package/docs/features.en.md +86 -0
- package/docs/features.md +86 -0
- package/docs/images/README.md +5 -0
- package/docs/images/agents.png +0 -0
- package/docs/images/call-details.png +0 -0
- package/docs/images/codex-quota.png +0 -0
- package/docs/images/conversation-dark.png +0 -0
- package/docs/images/conversation-light.png +0 -0
- package/docs/images/custom-balance.png +0 -0
- package/docs/images/display.png +0 -0
- package/docs/images/efficiency.png +0 -0
- package/docs/images/export.png +0 -0
- package/docs/images/gateway.png +0 -0
- package/docs/images/mobile-details.png +0 -0
- package/docs/images/mobile-overview.png +0 -0
- package/docs/images/model-pricing.png +0 -0
- package/docs/images/overview-dark.png +0 -0
- package/docs/images/overview-en.png +0 -0
- package/docs/images/overview.png +0 -0
- package/docs/images/peak-pricing.png +0 -0
- package/docs/images/plan-statistics.png +0 -0
- package/docs/images/quotas.png +0 -0
- package/docs/images/statistics.png +0 -0
- package/docs/images/step-costs.png +0 -0
- package/docs/images/treemap.png +0 -0
- package/docs/images/usage.png +0 -0
- package/docs/install.en.md +73 -0
- package/docs/install.md +73 -0
- package/docs/native-search-billing.md +48 -48
- package/docs/plugin-compatibility-watch.md +76 -76
- package/docs/provider-pricing-2026-10.md +2 -2
- package/docs/provider-pricing.json +19 -1
- package/docs/update-notes-1.9.47.md +27 -27
- package/docs/update-notes-1.9.48.md +26 -26
- package/docs/update-notes-1.9.58.md +17 -0
- package/docs/update-notes-1.9.59.md +41 -0
- package/docs/web-request-fees.md +52 -52
- package/lib/balance-expression.js +129 -129
- package/lib/billing-history.js +202 -202
- package/lib/billion-context-history.js +52 -2
- package/lib/client.js +9 -8
- package/lib/client.pricing.js +3 -2
- package/lib/custom-balance.js +209 -209
- package/lib/ledger-writer-worker.js +1 -1
- package/lib/native-search-fetch.js +48 -48
- package/lib/official-price-sync.js +46 -46
- package/lib/peak-schedule.js +51 -51
- package/lib/pricing.js +1590 -1577
- package/lib/provider-prices-2026-11-05.js +31 -0
- package/lib/provider-prices.js +6 -0
- package/lib/store.js +2 -0
- package/lib/turn-cost.js +18 -7
- package/package.json +279 -265
package/README.md
CHANGED
|
@@ -1,586 +1,124 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
<
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
</
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
<
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
|
63
|
-
|
|
64
|
-
|
|
|
65
|
-
|
|
|
66
|
-
|
|
|
67
|
-
|
|
|
68
|
-
|
|
|
69
|
-
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
|
76
|
-
|
|
77
|
-
|
|
|
78
|
-
|
|
79
|
-
|
|
|
80
|
-
|
|
81
|
-
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
|
88
|
-
|
|
89
|
-
|
|
|
90
|
-
|
|
|
91
|
-
|
|
|
92
|
-
|
|
|
93
|
-
|
|
|
94
|
-
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
Xiaomi MiMo Token Plan quotas are queried with the **MiMo console cookie**, not an API key: log in at `platform.xiaomimimo.com`, press F12 → Network → find the `balanceAlertConfig` request and paste the full `cookie` request header into the MiMo card in Settings → Cost → Quotas (it must include `serviceToken` and `userId`; the DSH credential store keeps it as `MIMO_COOKIE`). The card shows the plan/compensation credit windows with the period-end reset (Beijing time) plus a balance row. Copy a fresh console cookie when the card reports an expired login. Token Plan inference keys (`tp-*` / `ttp-*`) are not accepted by this console adapter. Local plan statistics use the calendar month; compensation and balance are displayed without estimates because local calls cannot be attributed to those pools.
|
|
127
|
-
|
|
128
|
-
Each CLIProxyAPI source has a **Gemini quota only** option for its Antigravity groups. It defaults to off. Intentional filtering to no visible quota shows an empty list; malformed quota data still reports an error.
|
|
129
|
-
|
|
130
|
-
The `extract` rules accept four forms: a numeric constant, a dot path string, `add`/`subtract` over multiple paths, and `divide` scaling by a `by` divisor. **`divide` fits NewApi and other endpoints that meter balance in integer quota** (1 USD = 500000 quota — the same conversion cc-switch uses).
|
|
131
|
-
|
|
132
|
-
- **`unit: "CREDITS"`**: displays non-monetary credits using the configured decimal precision and a Credits suffix. Dollar spend is not converted to credits or shown as today's credit usage. Credit bars use the endpoint's credit cap; the global monetary budget does not apply.
|
|
133
|
-
- **Plain HTTP is allowed for loopback endpoints**: `http://` is accepted when the host is `127.0.0.1` / `localhost` / `[::1]` (the traffic never leaves the machine), which covers local read-only routes that listen on loopback only and serve no TLS (e.g. `dsh-workbuddy-connect`'s `/plugins/dsh-workbuddy-connect/status`). **Every non-loopback host still requires https**; plaintext is refused.
|
|
134
|
-
|
|
135
|
-
### WorkBuddy credits example (local plugin route)
|
|
136
|
-
|
|
137
|
-
The dedicated **WorkBuddy credits** quota card now supports dsh-xdpool. Select **Credit source → dsh-xdpool** when using multiple connectors; current, all and selected accounts work across CN/global pools. See the [integration notes](docs/update-notes-1.9.38.md#english).
|
|
138
|
-
|
|
139
|
-
With `dsh-workbuddy-connect` installed, its web status route already returns the aggregated credit total — no credential needs to be copied:
|
|
140
|
-
|
|
141
|
-
```json
|
|
142
|
-
{
|
|
143
|
-
"enabled": true,
|
|
144
|
-
"display": "sidebar",
|
|
145
|
-
"refreshMinutes": 15,
|
|
146
|
-
"label": "WorkBuddy 积分",
|
|
147
|
-
"labelEn": "WorkBuddy Credits",
|
|
148
|
-
"unit": "CREDITS",
|
|
149
|
-
"request": { "url": "http://127.0.0.1:3080/plugins/dsh-workbuddy-connect/status", "method": "GET", "headers": {} },
|
|
150
|
-
"extract": { "remaining": "credits.total" }
|
|
151
|
-
}
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
Adjust the port and response fields to the local service. This example requires the other plugin to expose that route. Cost-meter refuses redirects and continues to enforce configured credential host allowlists.
|
|
155
|
-
|
|
156
|
-
For NewApi `GET /api/usage/token` (response `{ "code": 200, "data": { "total_granted": ..., "total_used": ..., "total_available": ..., "unlimited_quota": false } }`):
|
|
157
|
-
|
|
158
|
-
```json
|
|
159
|
-
{
|
|
160
|
-
"enabled": true,
|
|
161
|
-
"display": "both",
|
|
162
|
-
"refreshMinutes": 15,
|
|
163
|
-
"label": "NewApi",
|
|
164
|
-
"labelEn": "NewApi",
|
|
165
|
-
"unit": "USD",
|
|
166
|
-
"request": {
|
|
167
|
-
"url": "https://your-newapi-host/api/usage/token",
|
|
168
|
-
"method": "GET",
|
|
169
|
-
"headers": { "Authorization": "Bearer {{NEWAPI_API_KEY}}" }
|
|
170
|
-
},
|
|
171
|
-
"extract": {
|
|
172
|
-
"remaining": { "op": "divide", "path": "data.total_available", "by": 500000 },
|
|
173
|
-
"maxBudget": { "op": "divide", "path": "data.total_granted", "by": 500000 },
|
|
174
|
-
"spend": { "op": "divide", "path": "data.total_used", "by": 500000 },
|
|
175
|
-
"unit": "USD"
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
- `{{NEWAPI_API_KEY}}` resolves from the DSH credential vault or an environment variable (**placeholders work in headers only** — the URL must be a literal address);
|
|
181
|
-
- Unlimited-quota tokens (`unlimited_quota: true`) have no `total_available`, so `remaining` cannot be extracted and the query reports “remaining is missing or not numeric” — use a limited-quota token or a middle-layer endpoint that converts the units;
|
|
182
|
-
- Entry point: Settings → Cost (Quota tab) → “Custom provider balance” → expand config; or write `config.customBalance` in `storages/cost-meter/ledger.json`.
|
|
183
|
-
|
|
184
|
-
### Credentials & security
|
|
185
|
-
|
|
186
|
-
- **Variable naming**: `{{VAR_NAME}}` follows the `<ROUTE>_API_KEY` convention — `<ROUTE>` is the Provider ID from the DSH Models page (Settings → Models), uppercased with non-alphanumeric characters replaced by underscores, e.g. `openai`→`{{OPENAI_API_KEY}}`, `anthropic`→`{{ANTHROPIC_API_KEY}}`, `abc23-d`→`{{ABC23_D_API_KEY}}`. Sharing a name with the Models page means the balance query and model calls **share the same key** (both resolve from the DSH credential store). This note is also shown above the “Headers (JSON)” input in Settings.
|
|
187
|
-
- **Credential input fields**: after expanding an entry, the “Credential input” section renders one write-only field per `{{VAR}}` placeholder found in the headers — the key goes straight into the DSH credential store (never written to disk, never echoed back, never stored in `ledger.json`); no need to hand-edit environment variables or credential files.
|
|
188
|
-
- **Automatic plaintext migration**: older versions let a literal `Bearer sk-…` in the headers leak into `ledger.json` in plaintext. The plugin imports such keys into the DSH credential store at startup and replaces the header value with a `{{CUSTOM_BALANCE_KEY_…}}` placeholder (derived from the entry's host + header name, stable across restarts) — nothing breaks. From now on `ledger.json` and the config shipped to the browser **never contain plaintext keys**: suspected secret headers (Authorization / X-Api-Key / Bearer / sk- prefixes / long opaque strings) are blanked, while placeholders and ordinary headers pass through.
|
|
189
|
-
- **Credential allowlist `allowedHosts`**: when headers carry credentials (placeholders or plaintext), the outbound host must be on this list or the request is refused — protection against leaked keys when importing someone else's config. Without a list, requests proceed with a one-time logged warning. The entry panel provides an “Allowed hosts” input (comma-separated).
|
|
190
|
-
- **Mixed credential templates**: a header containing both a static secret and dynamic placeholders cannot be migrated as one nested credential. It is reported as pending and excluded from persisted/client config. Store the static part separately and use credential references throughout. Pure forms such as `Bearer {{VAR}}` and `{{USER}}:{{PASS}}` remain supported.
|
|
191
|
-
|
|
192
|
-
## CLIProxyAPI Gateway Quotas and WorkBuddy Credits (Issue #87)
|
|
193
|
-
|
|
194
|
-
Connects to a local or LAN-deployed [CLIProxyAPI](https://github.com/router-for-me/CLIProxyAPI) proxy gateway to observe quotas across upstream providers and WorkBuddy plugin credits in one place:
|
|
195
|
-
|
|
196
|
-
- **Native Multi-Provider Discovery & Quotas**: Auto-discovers active credentials via the CPA Management API and queries official native endpoints for Antigravity, Claude, Codex, Kimi, and xAI (Grok). Normalized into standard 5h / 7d / weekly / monthly usage percentage windows with ISO reset timestamps.
|
|
197
|
-
- **WorkBuddy Plugin Credits**: Queries WorkBuddy's read-only management route (`/v0/management/plugins/workbuddy/credits`) to display total, used, and remaining credit balances alongside package lifecycle end-dates, preserving separate account cards.
|
|
198
|
-
- **Zero Metering Side-Effects Guarantee**: Completely read-only — strictly avoids mutating actions such as Codex reset-credit consume, xAI token-consuming chat completion probes, and any WorkBuddy POST routes.
|
|
199
|
-
- **Strict Credential Isolation & Transport Security**:
|
|
200
|
-
- Management Keys are stored strictly write-only in the DSH credential store (`CLIPROXYAPI_MANAGEMENT_KEY_<SOURCE_ID>_<HASH>`), never exposed in config, state, or browser views.
|
|
201
|
-
- Management calls are strictly restricted to 3 fixed paths (`/v0/management/auth-files`, `/v0/management/api-call`, `/v0/management/plugins/workbuddy/credits`). Arbitrary upstream URLs are forbidden.
|
|
202
|
-
- Outbound host whitelist (`allowedHosts`): Non-loopback origins require exact host matches, and plain HTTP requires an explicit `allowInsecureHttp` opt-in.
|
|
203
|
-
- HTTP redirects are strictly forbidden (`redirect: 'manual'`; any 3xx response is rejected) to guard against credential leakage or request hijacking.
|
|
204
|
-
- Privacy and metadata sanitization: Strips raw tokens, cookies, and identity claims from auth-files discovery; emails are masked in public state (`s***@domain`).
|
|
205
|
-
|
|
206
|
-
## Bilingual UI
|
|
207
|
-
|
|
208
|
-
The plugin UI (session badge, sidebar balance row & budget box, and the entire Settings page) supports **Simplified Chinese** and **English**:
|
|
209
|
-
|
|
210
|
-
- Language options: **Simplified Chinese** / **English** / **Follow DSH (auto)**;
|
|
211
|
-
- Default is “Follow DSH”: auto uses DSH’s active language and updates live, including the statistics screen and Settings sidebar label. Older hosts without the locale face use the saved DSH preference when available, then the browser language (`zh*` → Chinese, otherwise English). Auto stays `auto` in the saved config;
|
|
212
|
-
- Switch it under **Settings → Cost → Display settings → Language** — the whole plugin UI updates instantly and auto-saves; the section label in the Settings sidebar switches too (费用 / Cost);
|
|
213
|
-
- An explicit Chinese/English plugin choice overrides DSH for both UI and server-generated notices. In auto mode, the Host reads DSH’s saved language preference; without an observable preference it retains the Chinese compatibility fallback. Browser/native-only provisional choices and different clients’ languages cannot be inferred by the Host, so notices may differ in those cases.
|
|
214
|
-
|
|
215
|
-
## Screenshots & walkthrough
|
|
216
|
-
|
|
217
|
-
> All screenshots were captured on a live DeepSeek Harness instance. They show the Chinese UI by default; the plugin UI itself is bilingual (Simplified Chinese / English) — switch to English under Settings → Cost → Display settings → Language.
|
|
218
|
-
|
|
219
|
-
### Main page
|
|
220
|
-
|
|
221
|
-
**Sidebar bottom** (top to bottom: official balance → quota/budget box → settings button):
|
|
222
|
-
|
|
223
|
-

|
|
224
|
-
|
|
225
|
-
- The balance row shows the official open-platform total balance; hovering reveals the granted/topped-up split; with “Balance progress bar” enabled, both official and custom balances use the same three-segment box (blue = remaining, orange = today, gray = spent);
|
|
226
|
-
- With no budget enabled, that spot shows the “Today ¥x” badge.
|
|
227
|
-
|
|
228
|
-
**Balance progress bar & custom provider settings**:
|
|
229
|
-
|
|
230
|
-
| Sidebar progress bar + display settings | Custom provider balance panel |
|
|
231
|
-
|---|---|
|
|
232
|
-
|  |  |
|
|
233
|
-
|
|
234
|
-
- Display settings → global “Balance progress bar” toggle; optional “Budget cap” overrides API `max_budget`;
|
|
235
|
-
- Settings → Cost → “Custom provider balance”: expand to edit URL / headers (JSON) / extract (JSON), bilingual names, and currency.
|
|
236
|
-
|
|
237
|
-
**Quota / budget box — three states** (OpenCode Go quota and the budget each toggle independently in the same rounded style; with both on they **merge into one card** — Go on top, budget below, thin divider, each keeps its own warning colors; the “box details” toggle collapses secondary rows to just label + used % + progress bar):
|
|
238
|
-
|
|
239
|
-
| Go quota only | Budget only | Merged |
|
|
240
|
-
|---|---|---|
|
|
241
|
-
|  |  |  |
|
|
242
|
-
|
|
243
|
-
- The budget box shows “budget · used % · progress bar · today's cost & share of budget · used/limit”; ≥80% warning, ≥100% over-budget; rail mode narrows to a percentage tile;
|
|
244
|
-
- The peak/off-peak hours display shows UTC peak hours 01:00–04:00 and 06:00–10:00 with the current tier; the budget box and today's cost area show a compact one-line period strip — a thin orange/blue track with a marker line on the current period, and text on the right showing the current period plus the countdown to the next switch (refreshed every 30 seconds); no prices are shown; it can be disabled independently in Settings, and the “Peak period strip style” option switches between the Compact and Classic looks; collapsed rail mode shows the same design vertically with a short horizontal label (“Peak / Off-peak”) below — the countdown and full text appear on hover;
|
|
245
|
-
|
|
246
|
-
**Peak/off-peak period strip & collapsed vertical progress bar**:
|
|
247
|
-
|
|
248
|
-
| Settings peak panel (notice toggle / style switch / preview) | Settings bottom-right (dock) display & box details |
|
|
249
|
-
|---|---|
|
|
250
|
-
|  |  |
|
|
251
|
-
|
|
252
|
-
Real captures from an actual DSH sidebar of the period strip and collapsed vertical bar (current looks), grouped by UI type (shown during peak hours):
|
|
253
|
-
|
|
254
|
-
**Expanded** — the budget box / today's cost area shows a one-line period strip:
|
|
255
|
-
|
|
256
|
-
| Compact | Classic |
|
|
257
|
-
|---|---|
|
|
258
|
-
|  |  |
|
|
259
|
-
|
|
260
|
-
- Compact: thin orange/blue track with a marker line on the current period and a short caption, e.g. “Peak · Off-peak in 1h 40m”;
|
|
261
|
-
- Classic: same track and marker line with the full caption “Peak · Off-peak in HH:MM:SS” countdown (refreshed every 30 seconds); no prices are shown.
|
|
262
|
-
|
|
263
|
-
**Collapsed (rail)** — a vertical period bar stacked at the sidebar bottom, centered with the percentage squares:
|
|
264
|
-
|
|
265
|
-
| Compact | Classic |
|
|
266
|
-
|---|---|
|
|
267
|
-
|  |  |
|
|
268
|
-
|
|
269
|
-
- Compact: only the short horizontal label (“Peak / Off-peak”) below the vertical bar;
|
|
270
|
-
- Classic: the full caption stacked vertically below the bar, including the countdown to the next switch; in both styles the full text is also available on hover.
|
|
271
|
-
|
|
272
|
-
- The display follows the `peakNotice` / `peakEnabled` / `peakEffectiveAt` / `peakWindows` gates and uses the configured UTC peak windows;
|
|
273
|
-
- Settings → Cost → Peak/off-peak pricing includes an independent “Prominent notice during peak hours” toggle; turning it off hides both the expanded strip and the collapsed vertical bar;
|
|
274
|
-
- The first image above is the Settings peak panel (notice toggle, style switch and live preview); see the grouped captures for the strip and collapsed vertical bar; the dock toggles and box-details switches are shown in the second image.
|
|
275
|
-
|
|
276
|
-
- The Go box shows the main window's used % and progress bar (default rolling 5h; switchable to weekly/monthly in Display settings), with the other two windows and reset times in a row below:
|
|
277
|
-
|
|
278
|
-

|
|
279
|
-
|
|
280
|
-
**Bottom-right (dock) quota / budget chips** (enabled in Display settings; four independent toggles: 5h / weekly / monthly quota + budget used %):
|
|
281
|
-
|
|
282
|
-
| Corner chips in action | Display settings (where the toggles live) |
|
|
283
|
-
|---|---|
|
|
284
|
-
|  |  |
|
|
285
|
-
|
|
286
|
-
**Per-conversation cost** (one merged row in the composer footer; the session title bar keeps only its compact “Cost details” button):
|
|
287
|
-
|
|
288
|
-
The row leads with the current currency symbol, then the session amount and hit-rate/input/cache/output details; the whole row opens the details dialog, and “Amount only” condenses it to the amount segment.
|
|
289
|
-
|
|
290
|
-

|
|
291
|
-
|
|
292
|
-
### Settings → Cost
|
|
293
|
-
|
|
294
|
-
**Overview** (OpenCode Go quota → budget → balance → summary cards → today's sessions → history → display settings → price table → data & sync):
|
|
295
|
-
|
|
296
|
-

|
|
297
|
-
|
|
298
|
-
**OpenCode Go quota panel** (very top of the Settings page: three progress bars, main window highlighted, manual refresh; a neutral hint when there is no subscription, one-click disable):
|
|
299
|
-
|
|
300
|
-

|
|
301
|
-
|
|
302
|
-
**Budget panel** (including custom date ranges):
|
|
303
|
-
|
|
304
|
-

|
|
305
|
-
|
|
306
|
-
**Balance panel** (total/granted/topped-up + manual refresh):
|
|
307
|
-
|
|
308
|
-

|
|
309
|
-
|
|
310
|
-
**Display settings** (Go main window & key, corner chips, box details, …):
|
|
311
|
-
|
|
312
|
-

|
|
313
|
-
|
|
314
|
-
**Summary cards**:
|
|
315
|
-
|
|
316
|
-

|
|
317
|
-
|
|
318
|
-
**Token usage stats** (all-time totals + a Codex-style 26-week heat grid filling the settings width; translucent glass cells for unused days):
|
|
319
|
-
|
|
320
|
-

|
|
321
|
-
|
|
322
|
-
**Today's sessions / history** (input, cache and output tokens in separate columns):
|
|
323
|
-
|
|
324
|
-
 
|
|
325
|
-
|
|
326
|
-
**Price table** (off-peak / peak tiers, with input/output shorthand support, USD / 1M tokens):
|
|
327
|
-
|
|
328
|
-

|
|
329
|
-
|
|
330
|
-
**Data & sync** (instant auto-save of settings + official price sync + clear history):
|
|
331
|
-
|
|
332
|
-

|
|
333
|
-
|
|
334
|
-
## Installation
|
|
335
|
-
|
|
336
|
-
> Requirements: Node.js ≥ 20 + DeepSeek Harness (a version with the `dsh plugin` command; `npm install -g @deepseek-ai/dsh`) + **pnpm on the DSH process's PATH**, including npm-name installs and Plugin Hub installs. Node.js ≥ 22.13 is recommended for the pinned pnpm 11 below; Node.js 20 users can use pnpm 10.
|
|
337
|
-
|
|
338
|
-
### One-click install (recommended)
|
|
339
|
-
|
|
340
|
-
**First-time setup on macOS / Linux:** install pnpm in the terminal you use to start DSH (the same commands also work on Windows):
|
|
341
|
-
|
|
342
|
-
```sh
|
|
343
|
-
npm install -g pnpm@11.21.0
|
|
344
|
-
pnpm --version
|
|
345
|
-
```
|
|
346
|
-
|
|
347
|
-
On Node.js 20, use `npm install -g pnpm@10` instead. See [pnpm installation and supported Node.js versions](https://pnpm.io/installation).
|
|
348
|
-
|
|
349
|
-
**npm package name** (published to the npm registry, always tracks the latest version; no git needed):
|
|
350
|
-
|
|
351
|
-
```sh
|
|
352
|
-
dsh plugin --profile web add dsh-cost-meter
|
|
353
|
-
```
|
|
354
|
-
|
|
355
|
-
**PowerShell one-click script** (copy the whole line, paste, press Enter; pnpm is provisioned automatically, git is auto-detected — no clone needed; the install chain is **pinned to the release tag `v1.9.57`** — review the script before running):
|
|
356
|
-
|
|
357
|
-
```powershell
|
|
358
|
-
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.9.57/install.ps1 | iex
|
|
359
|
-
```
|
|
360
|
-
|
|
361
|
-
**Or a plain command line** (the machine must already have pnpm and git; also pinned to the tag):
|
|
362
|
-
|
|
363
|
-
```sh
|
|
364
|
-
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.9.57
|
|
365
|
-
```
|
|
366
|
-
|
|
367
|
-
Without git, use the GitHub tag archive:
|
|
368
|
-
|
|
369
|
-
```sh
|
|
370
|
-
dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.9.57.tar.gz
|
|
371
|
-
```
|
|
372
|
-
|
|
373
|
-
After installing, **restart** `dsh web` (plugin rows, the Typert manifest and the client bundle are all scanned at startup):
|
|
374
|
-
|
|
375
|
-
```sh
|
|
376
|
-
dsh web
|
|
377
|
-
```
|
|
378
|
-
|
|
379
|
-
### Install troubleshooting: pnpm was not found (macOS / Linux)
|
|
380
|
-
|
|
381
|
-
`dsh: pnpm was not found; install pnpm and make it available on PATH.` means DSH cannot start its package manager; the plugin has not loaded yet. Installing by npm package name still requires pnpm.
|
|
382
|
-
|
|
383
|
-
After the setup above, check the commands from the **same terminal and OS user** that start DSH:
|
|
384
|
-
|
|
385
|
-
```sh
|
|
386
|
-
command -v node
|
|
387
|
-
command -v pnpm
|
|
388
|
-
command -v dsh
|
|
389
|
-
```
|
|
390
|
-
|
|
391
|
-
If npm installed pnpm but the shell cannot find it, add npm's global executable directory for the current shell, then retry:
|
|
392
|
-
|
|
393
|
-
```sh
|
|
394
|
-
export PATH="$(npm prefix -g)/bin:$PATH"
|
|
395
|
-
pnpm --version
|
|
396
|
-
dsh plugin --profile web add dsh-cost-meter@latest
|
|
397
|
-
dsh web
|
|
398
|
-
```
|
|
399
|
-
|
|
400
|
-
Stop the existing DSH process before restarting it. Plugin Hub runs inside DSH and inherits that process's PATH; reopening the browser alone will not refresh it. With nvm/fnm, select the Node.js version used by DSH before installing pnpm. If npm reports `EACCES`, use a user-owned Node.js installation/global prefix as described in the pnpm guide, then repeat the PATH check. For a persistent shell setup, add the executable directory to your shell profile. A successful install on your machine is confirmed by the plugin appearing after DSH restarts.
|
|
401
|
-
|
|
402
|
-
### Install troubleshooting: ERR_PNPM_MINIMUM_RELEASE_AGE_VIOLATION
|
|
403
|
-
|
|
404
|
-
Symptom: `dsh plugin --profile web add` fails with `[ERR_PNPM_MINIMUM_RELEASE_AGE_VIOLATION] N lockfile entries failed verification`.
|
|
405
|
-
|
|
406
|
-
Cause: your environment (pnpm config or a policy bundled into the invoking installer) enforces the "minimum release age" supply-chain protection — any lockfile entry **published more recently than the threshold** is rejected. Plugin releases from before runtime dependencies were exact-pinned declared floating ranges, so a fresh install resolved them to whatever was newest at that moment (a floating `@deepseek-ai/dsh-credentials` range was observed to land on a build published barely a week earlier), which such a policy refuses.
|
|
407
|
-
|
|
408
|
-
Fix:
|
|
409
|
-
|
|
410
|
-
1. **Upgrade the plugin and use the host's plugin installer**: `zod` remains exact-pinned. `@deepseek-ai/dsh-credentials` and `@deepseek-ai/dsh-home-paths` are now peer dependencies supplied by DSH, avoiding duplicate old host packages that can fail dependency preflight (issue #106). Pinning prevents version drift but cannot satisfy every age threshold;
|
|
411
|
-
2. If an age restriction remains, wait until the version reaches the threshold, or review the exact package and version in the error before choosing to add an individual exclusion to the profile's `pnpm-workspace.yaml` (default `$DSH_HOME/profiles/web/pnpm-workspace.yaml`):
|
|
412
|
-
|
|
413
|
-
```yaml
|
|
414
|
-
minimumReleaseAgeExclude:
|
|
415
|
-
- '<name@version from the error>'
|
|
416
|
-
```
|
|
417
|
-
|
|
418
|
-
DSH `0.2.0-rc.1` passes packed installation, Web startup, shared-module checks, synthetic billing, RPC and the full regression suite, and the current declaration accepts `>=0.2.0-rc.1 <0.3.0-0` while rejecting `0.1.x` and `0.3.0`. Earlier 0.1.x checks (`0.1.2-rc.1`, `0.1.3-alpha.2`, `0.1.5-alpha.1`) are kept in the compatibility record for reference only; `0.1.3-alpha.1` remains unknown because its official npm version was unavailable during the earlier check. See the [compatibility record](docs/host-compatibility.md) for the environment and limits.
|
|
419
|
-
|
|
420
|
-
If Plugin Hub reports only `diagnostics: .../.plugin-manager/logs/operation-.../pnpm.log`, that line does not identify the failed package or command. Open the named `pnpm.log` and include the first actual error when reporting the failure; remove credentials and private paths before sharing it. Git URL and npm-name installation on DSH `0.2.0-rc.1` are covered by isolated Windows checks, but an individual machine's failure still requires its diagnostic log.
|
|
421
|
-
|
|
422
|
-
Account-mode balance: in DSH Desktop a signed-in official account is read without any API key; if you still get HTTP 401, save a dedicated Open Platform key under **Settings → Cost → Account balance**. See [credential sources and priority](docs/balance-credentials.md).
|
|
423
|
-
|
|
424
|
-
### Install troubleshooting: uninstall fails with ERR_PNPM_RESOLUTION_POLICY_VIOLATIONS_UNHANDLED (DSH 0.2.1-rc.x)
|
|
425
|
-
|
|
426
|
-
On DSH **0.2.1-rc.1 / 0.2.1-rc.2** the host bundles pnpm **11.28.5**, which enables a built-in 24-hour `minimumReleaseAge`. Uninstalling or reinstalling a plugin can then fail with `ERR_PNPM_RESOLUTION_POLICY_VIOLATIONS_UNHANDLED`; the plugin page shows something like `Uninstall failed` plus `✓ Lockfile passes supply-chain policies (verified 28m ago)` and `Progress: resolved 1, reused 0, ...`. A package younger than 24 hours (the plugin version just installed, or a host `0.2.1-rc.x` package) is enough to trigger it. The unhandled-callback error comes from the host's bundled pnpm, so the plugin cannot patch it.
|
|
427
|
-
|
|
428
|
-
Workarounds:
|
|
429
|
-
|
|
430
|
-
1. Wait until the package is 24 hours old, then retry. The plugin keeps working in the meantime.
|
|
431
|
-
2. Add an exact exclusion to the profile's `pnpm-workspace.yaml` (keep existing entries), then fully restart DSH and retry:
|
|
432
|
-
|
|
433
|
-
```yaml
|
|
434
|
-
minimumReleaseAgeExclude:
|
|
435
|
-
- dsh-cost-meter@1.9.57
|
|
436
|
-
```
|
|
437
|
-
|
|
438
|
-
3. For a one-off CLI operation, forward the pnpm flag: `dsh plugin --profile desktop remove dsh-cost-meter --config.minimum-release-age=0` (or add `--trust-lockfile` when only lockfile verification fails). Both flags were verified against pnpm 11.28.5 in a temporary profile.
|
|
439
|
-
|
|
440
|
-
Read the first `ERR_PNPM_*` line in `<profile>/.plugin-manager/logs/operation-*/pnpm.log` before reporting and remove credentials. Do not delete the profile or the ledger. Details: [pnpm supply-chain policy](docs/pnpm-supply-chain-policy.md).
|
|
441
|
-
|
|
442
|
-
### Update / Uninstall
|
|
443
|
-
|
|
444
|
-
```sh
|
|
445
|
-
# update: re-run the new release's install.ps1 (the pinned tag inside it moves with the release)
|
|
446
|
-
dsh plugin --profile web remove dsh-cost-meter # uninstall
|
|
447
|
-
```
|
|
448
|
-
|
|
449
|
-
Installation errors and plugins still disabled after reinstall: see [troubleshooting](docs/install-troubleshooting.md).
|
|
450
|
-
|
|
451
|
-
### Local development
|
|
452
|
-
|
|
453
|
-
```sh
|
|
454
|
-
git clone https://github.com/Han-1413141/dsh-cost-meter.git
|
|
455
|
-
cd <parent directory of the clone>
|
|
456
|
-
dsh plugin --profile web add link:./dsh-cost-meter # symlink; edit lib/client.js, refresh the page, done
|
|
457
|
-
```
|
|
458
|
-
|
|
459
|
-
## Billing rules
|
|
460
|
-
|
|
461
|
-

|
|
462
|
-
|
|
463
|
-
- Price units match the official docs: **USD / 1M tokens**;
|
|
464
|
-
- cost = cache-missed input × cache-miss + output × output + (cache read + cache write) × cache-hit (cache writes follow the legacy official rule and are billed at the hit price);
|
|
465
|
-
- **Pure two-tier peak/off-peak pricing** (the official scheme since 2026-08): peak hours (01:00–04:00, 06:00–10:00 UTC) bill at the peak price and all other hours at the off-peak price (off-peak = half of peak). The base tier equals the off-peak tier, and billing falls back to off-peak when peak/off-peak is disabled; the Settings page shows the live tier (peak / off-peak); the budget/today's cost area shows a peak/off-peak period strip (current/next period with countdown), and the collapsed rail shows a vertical peak/off-peak progress bar;
|
|
466
|
-
- **Weekends and Chinese public holidays**: weekends are off-peak all day from 2026-08-23 00:00 Beijing time, including work-shift weekends. Chinese public holidays are also off-peak all day. `peakHolidays` contains Beijing dates in `YYYY-MM-DD` format and defaults to the published 2026 Mid-Autumn and National Day dates after the peak-pricing change; edit the list in Settings → Cost → Peak pricing for future holidays. The period strip labels holidays separately and counts down to the next actual price change. Historical DeepSeek costs are recalculated once from complete session logs; rows without complete logs keep their recorded amounts;
|
|
467
|
-
- **Historical billing correctness**: calls before 2026-08-16 16:00 UTC (the peak-era boundary) are billed at the base prices of that time, and later calls at the two-tier scheme;
|
|
468
|
-
- The ledger always stores amounts in **USD**; currency and FX rate only affect display (default 1 USD = 7.2 CNY, configurable);
|
|
469
|
-
- The session badge is **billed exactly** at the moment each call is made (host-exported per-call cost), just like daily/monthly/cumulative totals and the budget;
|
|
470
|
-
- Billing uses usage blocks reported through the host's `llm/stream`, including sub-agents, compression, title generation and other auxiliary calls in isolated LLM services. Child sessions retain their own `sessionId` and do not contribute to the parent badge; background calls without a `sessionId` contribute only to daily/monthly/lifetime totals. Memory or other plugins that call external APIs directly without reporting usage to the host cannot be tracked;
|
|
471
|
-
- **Peak/off-peak tiers follow the request-initiation moment**: a streaming call can span the tier boundary hour; attributing by completion time would put a request started minutes earlier into the wrong tier;
|
|
472
|
-
- **Peak effective-time anchoring**: the official pricing page no longer lists an effective time, and price sync no longer resets the peak effective moment to "now" — historical recomputes (session projection refolds / per-model backfill) always tier events against the 2026-08-16 16:00 UTC boundary, so peak-hour history is no longer re-costed at half price; ledgers polluted earlier are clamped back automatically on upgrade (idempotent migration);
|
|
473
|
-
- **Historical pricing**: changing pricing currency, rates or mappings affects subsequent calls. Saved price versions preserve older details; explicit recalculation requires confirmation and retains original amounts, price versions and a full ledger backup. See the [update notes](docs/update-notes-2026-10-15.md#english).
|
|
474
|
-
- **Aligning with official bills**: ① minute-level lag vs live official numbers is expected — the ledger flushes on a 2s debounce, and streams still in flight at shutdown are billed server-side while their usage block is never received (the gap concentrates in cache-hit columns); ② reasoning tokens are reported separately by the API and are **not billed** — the token columns sum five buckets and will never line up with the official three columns, so **reconcile by amount**; ③ with pricing currency set to CNY, entries are recorded directly on the official CNY price list (recommended for CNY-billed accounts); with USD, displayed amounts go through a fixed FX rate and carry a small structural difference (the two lists' per-column ratios are not uniform); ④ granted-balance expiry or reclaim is not consumption: when the day's balance drop is confined to the granted bucket (top-up balance unchanged) and local official-channel usage explains at most a quarter of it, the reconciliation baseline is reset with an informational expiry/reclaim notice instead of a consumption-drift warning;
|
|
475
|
-
- Budget and over-budget warnings **only warn — they never block calls**.
|
|
476
|
-
- **Plan/API dual-track billing** (issue #64): calls on subscription-style channels (MiniMax, Codex / ChatGPT subscription plugins, etc.) are recorded as catalog-price equivalents only; budget/today-cost/overview cards count the pay-as-you-go (API) channel exclusively.
|
|
477
|
-
- **Full-repo security audit fixes**: resolved 3 high-risk findings — ledger writes lost on exit (close/flush ordering), command injection in the release script, panel null-pointer crash on null Go monthly window — plus 30+ medium/low issues including missing hour-bucket entries for routed calls, dead balance-reconciliation warnings, failed custom-balance extraction silently showing $0, and leaked upstream streams on consumer abort; ledger corruption auto-backup, write-failure retry, config-patch atomicity and prototype-chain hardening included. Itemized list: [CHANGELOG.md](CHANGELOG.md).
|
|
478
|
-
- **"Include plan totals" toggle** under the overview cards switches every amount between real-money (API channels only, default) and total equivalent cost (plan subscriptions included); routed calls with a missing provider whose models match third-party catalogs are auto-classified into the matching plan, and legacy per-day residuals without model details count toward the API scope; The Token Plan stats panel in Settings → Usage provides per-1% and full-window token/equivalent-cost estimates plus daily/weekly/monthly usage curves; classification is configurable per vendor and per provider:model.
|
|
479
|
-
|
|
480
|
-
## Data storage
|
|
481
|
-
|
|
482
|
-
- Ledger: `$DSH_HOME/storages/cost-meter/ledger.json` (atomic write + 2-second debounce; retained per `historyDays`, up to 200 per-session entries per day);
|
|
483
|
-
- **API keys never touch disk**: all credentials (OpenCode Go key, coding-plan keys, Volcano AK/SK) live only in the DSH credential store — neither the ledger file nor anything sent back to the settings page contains plaintext; the settings inputs are write-only and never echo a saved key back;
|
|
484
|
-
- Every settings change is **saved instantly and automatically** (600 ms debounce) — no manual save needed;
|
|
485
|
-
- Delete the ledger file to reset everything, or use “Clear all history” in Settings;
|
|
486
|
-
- Privacy boundary: balance/quota endpoints (official balance and each coding plan) **only get contacted after you explicitly enable the corresponding provider** — no network traffic for disabled ones.
|
|
487
|
-
|
|
488
|
-
## Architecture
|
|
489
|
-
|
|
490
|
-

|
|
491
|
-
|
|
492
|
-
```
|
|
493
|
-
dsh-cost-meter
|
|
494
|
-
├── cordis.patch.yml # bundle patch: inserts the cost-meter row into the web profile
|
|
495
|
-
├── install.ps1 # one-click install/update script (irm … | iex)
|
|
496
|
-
├── .github/workflows/ # CI: install-smoke for the one-click install path
|
|
497
|
-
├── package.json # dsh.bundle patch declaration + dsh.client browser declaration
|
|
498
|
-
└── lib/
|
|
499
|
-
├── index.js # host plugin: llm/stream billing wrapper, costUsage session
|
|
500
|
-
│ # projection, costMeter service (hand-written typertRemote
|
|
501
|
-
│ # binding), balance lookup
|
|
502
|
-
├── pricing.js # official price table, official page HTML parsing, peak/off-peak math
|
|
503
|
-
├── store.js # ledger persistence & config management ($DSH_HOME/storages/cost-meter)
|
|
504
|
-
├── typert.host.js # ./typert export: Typert manifest (auto-registered by typert-loader)
|
|
505
|
-
└── client.js # ./client export: browser single-file bundle (badges/box/settings)
|
|
506
|
-
```
|
|
507
|
-
|
|
508
|
-
Data channels:
|
|
509
|
-
|
|
510
|
-
- **Per-conversation cost**: the host registers the `costUsage` session projection (pure token buckets, split per model); the browser reads it via `useProjection('costUsage')` and prices it with the current price table;
|
|
511
|
-
- **Global ledger / budget / balance / config**: `costMeter/getState | updateConfig | fetchPrices | refreshBalance | resetHistory` over the Typert gateway RPC (`remote.costMeter.*`);
|
|
512
|
-
- **Balance**: calls the official `GET {baseURL}/user/balance`, reusing the same API key as model requests (credential service / env var), with an in-process cache expiring per `refreshMinutes`.
|
|
513
|
-
|
|
514
|
-
The plugin never imports cordis/dsh Service/Context runtime classes (only Node builtins, zod, and pure functions from dsh-home-paths and dsh-credentials), so it shares one runtime instance with the host with no duplicated dependency risk.
|
|
515
|
-
|
|
516
|
-
## How official price sync works
|
|
517
|
-
|
|
518
|
-
`fetchPrices` fetches the official pricing page (Docusaurus server-side pre-rendered; the English page lists USD prices and the Chinese page CNY prices, selected by the "official price currency" setting — currency is auto-detected from the money symbols, and peak windows on the Chinese page are converted from Beijing time to UTC by −8h) and parses:
|
|
519
|
-
|
|
520
|
-
1. the base price table (transposed layout: first row MODEL + model ids, price labels followed by the prices);
|
|
521
|
-
2. the peak/off-peak price table (two rows per model: OFF-PEAK / PEAK);
|
|
522
|
-
3. the effective time (“take effect at …”) and the peak-hour windows (“Peak hours are …”).
|
|
523
|
-
|
|
524
|
-
The parsed result is written into the price table and persisted; if the page structure changes, sync reports an error and keeps the previous prices, with manual editing as a fallback.
|
|
525
|
-
|
|
526
|
-
## AI price sync
|
|
527
|
-
|
|
528
|
-
[docs/AI-PRICE-SYNC-PROMPT.en.md](docs/AI-PRICE-SYNC-PROMPT.en.md) (English) and [docs/AI-PRICE-SYNC-PROMPT.md](docs/AI-PRICE-SYNC-PROMPT.md) (中文) provide prompts you can copy straight into any AI:
|
|
529
|
-
the AI reads the official pricing on its own → outputs per-model, time-of-day (base/off-peak/peak + effective time) price JSON → you review and apply it (Settings page / RPC / file — pick one). Handy when the official prices change.
|
|
530
|
-
|
|
531
|
-
## Development & verification
|
|
532
|
-
|
|
533
|
-
```sh
|
|
534
|
-
corepack pnpm install # dependencies
|
|
535
|
-
node --check lib/index.js && node --check lib/pricing.js \
|
|
536
|
-
&& node --check lib/store.js && node --check lib/typert.host.js \
|
|
537
|
-
&& node --check lib/client.js # syntax checks
|
|
538
|
-
node test/verify.mjs # pure-module verification (parsing/billing/ledger/config)
|
|
539
|
-
node test/mock-balance.mjs # (optional) local balance API mock: 3101
|
|
540
|
-
dsh --profile web --dump-config # composition-tree check
|
|
541
|
-
dsh --profile web --port 3099 # real startup (watch logs and the UI)
|
|
542
|
-
```
|
|
543
|
-
|
|
544
|
-
## Known limitations
|
|
545
|
-
|
|
546
|
-
For loading placeholders followed by “No matching sessions” after opening Cost,
|
|
547
|
-
see [non-destructive sidebar search recovery](docs/session-sidebar-recovery.md).
|
|
548
|
-
Check and clear the host search before changing stored data.
|
|
549
|
-
|
|
550
|
-
- Official-page parsing depends on the current page structure; after a redesign, “Sync prices from official docs” fails — edit the price table manually as a fallback;
|
|
551
|
-
- The session badge's fallback estimate (used when ledger data is unavailable) prices all of a session's calls at the tier of the *current* moment, including plan-type sessions: a session spanning peak and off-peak hours gets its off-peak portion overestimated during peak hours; exact figures come from the ledger (which bills each call at its own initiation moment);
|
|
552
|
-
- Price sync overwrites the same-named models listed on the official page; custom model entries are unaffected;
|
|
553
|
-
- Balance lookup needs network access to api.deepseek.com and a valid API key; **the API key is only ever sent to the official domain** (if baseURL points at a non-official host, balance queries refuse to run — model requests are unaffected);
|
|
554
|
-
- The OpenCode Go quota endpoint is the official opencode.ai endpoint (community-documented); if its response shape changes, the Settings page shows an error and the display can be turned off in Display settings;
|
|
555
|
-
- The per-1% quota / full-window figures in Token Plan stats are estimates: vendors only report percentages with ones-digit quantization (a displayed 1% may really be 0.5%–1.5%), so the plugin derives them from end-to-end deltas over continuous sample segments to suppress quantization noise (segments spanning <5 percentage points are tagged "low reading precision"; samples older than 7 days fall back to live ratio; window edges align to whole hours). Server percentages cover ALL usage of the account — consumption of the same key on other machines/CLIs is not in the local ledger, so low estimates are expected; treat them as cross-plan comparisons only;
|
|
556
|
-
- Plan/API classification is inferred from channel and config; mixed subscription/PAYG usage of one vendor (e.g. Kimi) can be overridden per provider:model in settings.
|
|
557
|
-
- A restart of `dsh web` is required after installing/updating the plugin.
|
|
558
|
-
|
|
559
|
-
## Community
|
|
560
|
-
|
|
561
|
-
Join the WeChat group to discuss the plugin, share feedback, and suggest features.
|
|
562
|
-
|
|
563
|
-
<p align="center">
|
|
564
|
-
<a href="docs/community-wechat.png"><img src="docs/community-wechat.png" alt="dsh-cost-meter WeChat community QR code" width="320" /></a><br />
|
|
565
|
-
<a href="docs/community-wechat.png">View full-size QR code</a>
|
|
566
|
-
</p>
|
|
567
|
-
|
|
568
|
-
## Update history
|
|
569
|
-
|
|
570
|
-
**Version policy**: releases increment only the patch number (for example `1.9.0 → 1.9.1`), including feature releases, new plugin compatibility and UI updates. The minor/major positions stay fixed unless a breaking change requires them and is explicitly approved; 1.9.0 was the last minor bump.
|
|
571
|
-
|
|
572
|
-
A per-version overview and the community-issue resolution log live in [docs/UPDATE-HISTORY.md](docs/UPDATE-HISTORY.md) (中文); the itemized changelog is [CHANGELOG.md](CHANGELOG.md).
|
|
573
|
-
|
|
574
|
-
## Star History
|
|
575
|
-
|
|
576
|
-
<a href="https://www.star-history.com/?repos=han-1413141%2Fdsh-cost-meter&type=timeline&legend=bottom-right">
|
|
577
|
-
<picture>
|
|
578
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=han-1413141/dsh-cost-meter&type=timeline&theme=dark&legend=bottom-right" />
|
|
579
|
-
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=han-1413141/dsh-cost-meter&type=timeline&legend=bottom-right" />
|
|
580
|
-
<img alt="Star History Chart" src="https://api.star-history.com/chart?repos=han-1413141/dsh-cost-meter&type=timeline&legend=bottom-right" />
|
|
581
|
-
</picture>
|
|
582
|
-
</a>
|
|
583
|
-
|
|
584
|
-
## License
|
|
585
|
-
|
|
586
|
-
[MIT](LICENSE) © 2026 dsh-cost-meter contributors
|
|
1
|
+
<h1 align="center">dsh-cost-meter</h1>
|
|
2
|
+
|
|
3
|
+
<p align="center">Cost tracking and subscription quotas for DeepSeek Harness</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://github.com/Han-1413141/dsh-cost-meter/releases/latest"><img src="https://img.shields.io/badge/version-1.9.59-4176E6?style=flat-square" alt="version"></a>
|
|
7
|
+
<a href="https://www.npmjs.com/package/dsh-cost-meter"><img src="https://img.shields.io/npm/v/dsh-cost-meter?label=npm&style=flat-square" alt="npm"></a>
|
|
8
|
+
<a href="https://www.npmjs.com/package/dsh-cost-meter"><img src="https://img.shields.io/npm/dm/dsh-cost-meter?label=downloads&style=flat-square&color=4176E6" alt="npm monthly downloads"></a>
|
|
9
|
+
<a href="https://github.com/Han-1413141/dsh-cost-meter/stargazers"><img src="https://img.shields.io/github/stars/Han-1413141/dsh-cost-meter?label=stars&style=flat-square&color=D9A400" alt="GitHub stars"></a>
|
|
10
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-green?style=flat-square" alt="MIT license"></a>
|
|
11
|
+
<a href="https://github.com/deepseek-ai/deepseek-harness"><img src="https://img.shields.io/badge/DeepSeek%20Harness-dsh--plugin-4176E6?style=flat-square" alt="DSH plugin"></a>
|
|
12
|
+
<a href="https://dshfind.com/zh/plugins/Han-1413141/dsh-cost-meter?ref=badge"><img src="https://dshfind.com/api/badge/Han-1413141/dsh-cost-meter?metric=downloads&lang=zh" alt="dshfind"></a>
|
|
13
|
+
<a href="https://awesome-dsh-plugin.com"><img src="https://awesome-dsh-plugin.com/badge.svg" alt="awesome DSH plugin"></a>
|
|
14
|
+
<a href="https://whaleharness.com/audit-report.md"><img src="https://whaleharness.com/badge/Han-1413141/dsh-cost-meter/badge.svg" alt="WhaleHarness audit"></a>
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
<p align="center"><b>English</b> | <a href="README.zh-CN.md">简体中文</a></p>
|
|
18
|
+
<p align="center"><a href="#installation">Install</a> · <a href="#feature-overview">Features</a> · <a href="#screenshots--walkthrough">Screenshots</a> · <a href="#documentation">Docs</a> · <a href="#community">Community</a></p>
|
|
19
|
+
|
|
20
|
+
Track costs and tokens by conversation, model and call. View account balances, subscription quotas and budgets together, with separate API charges and Plan equivalents, multi-provider pricing, peak/off-peak alerts, and configurable sidebar and composer displays.
|
|
21
|
+
|
|
22
|
+
<picture>
|
|
23
|
+
<source media="(prefers-color-scheme: dark)" srcset="docs/images/conversation-dark.png">
|
|
24
|
+
<img src="docs/images/conversation-light.png" alt="Conversation costs, quotas and balances" width="1280">
|
|
25
|
+
</picture>
|
|
26
|
+
|
|
27
|
+
<p align="center"><sub>Light and dark conversation views. Documentation screenshots use sample data.</sub></p>
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
Requires **Node.js ≥ 20, DSH 0.2.0 or later**, and pnpm available to DSH. See [host compatibility](docs/host-compatibility.md).
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
dsh plugin --profile web add dsh-cost-meter
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Restart `dsh web` after installation or updates. **Desktop** uses its bundled CLI and the `desktop` profile; follow the [Desktop guide](docs/install-troubleshooting.md#desktop-安装与更新).
|
|
38
|
+
|
|
39
|
+
<details>
|
|
40
|
+
<summary>Windows installer / pinned version</summary>
|
|
41
|
+
|
|
42
|
+
The PowerShell installer checks pnpm and Git and uses the `web` profile by default:
|
|
43
|
+
|
|
44
|
+
```powershell
|
|
45
|
+
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.9.59/install.ps1 | iex
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Install a pinned Git tag:
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.9.59
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
See [installation and updates](docs/install.en.md) for uninstalling or installing without Git.
|
|
55
|
+
|
|
56
|
+
</details>
|
|
57
|
+
|
|
58
|
+
Current release **v1.9.59**: [release notes](docs/update-notes-1.9.59.md#english) · [troubleshooting](docs/install-troubleshooting.md)
|
|
59
|
+
|
|
60
|
+
## Feature overview
|
|
61
|
+
|
|
62
|
+
| Feature | What it provides |
|
|
63
|
+
|---|---|
|
|
64
|
+
| Conversation and call costs | Cost entries in the composer, header and each turn. Inspect rates, tokens, recorded inputs and tool results, including parent/subagent cost attribution. |
|
|
65
|
+
| Statistics and exports | Filter by date, provider and model; inspect trends, rankings, cache hit rates and token heatmaps. Export one conversation or all retained conversations. |
|
|
66
|
+
| Quotas and balances | Codex / ChatGPT, OpenCode Go, MiniMax, Claude, GLM, Kimi, Qianwen, MiMo, OpenDesign and other plans, plus CLIProxyAPI multi-account quotas and custom HTTP balance sources. |
|
|
67
|
+
| Multi-provider pricing | Automatic model matching, editable rates and multipliers, and peak/off-peak tiers. Sync DeepSeek official prices and the OpenRouter catalog; separate API charges from Plan equivalents. |
|
|
68
|
+
| Budgets and pricing alerts | Daily, monthly, cumulative or custom-date budgets. Peak/off-peak schedules and countdowns, with popup and system notifications before a change. |
|
|
69
|
+
| Display and history | Configure sidebar cards, composer entries, quota strips and turn costs. Chinese/English UI, dark themes and mobile layouts; historical imports, retention and storage controls. |
|
|
70
|
+
|
|
71
|
+
See [features and screenshots](docs/features.en.md) for entry points and [model and plan support](docs/model-and-plan-adaptation.en.md) for providers and credentials.
|
|
72
|
+
|
|
73
|
+
## Screenshots & walkthrough
|
|
74
|
+
|
|
75
|
+
| Cost trends and model ranking | Conversation cost distribution |
|
|
76
|
+
|---|---|
|
|
77
|
+
| [](docs/images/statistics.png) | [](docs/images/treemap.png) |
|
|
78
|
+
|
|
79
|
+
| Subscription quotas and balances | Display settings and interactive preview |
|
|
80
|
+
|---|---|
|
|
81
|
+
| [](docs/images/quotas.png) | [](docs/images/display.png) |
|
|
82
|
+
|
|
83
|
+
Select an image for full resolution. [More views: call details, prices, history, dark themes and mobile](docs/features.en.md).
|
|
84
|
+
|
|
85
|
+
## Documentation
|
|
86
|
+
|
|
87
|
+
| Topic | Guides |
|
|
88
|
+
|---|---|
|
|
89
|
+
| Setup and use | [Install, update and uninstall](docs/install.en.md) · [Troubleshooting](docs/install-troubleshooting.md) · [Display settings](docs/display-settings.md) |
|
|
90
|
+
| Statistics and billing | [Billing rules](docs/billing.en.md) · [Statistics and details](docs/billing-statistics.md#english) · [Models and plans](docs/model-and-plan-adaptation.en.md) · [Peak schedules](docs/provider-peak-schedules.md) |
|
|
91
|
+
| Balances and quotas | [Credentials](docs/balance-credentials.md) · [Custom balances](docs/custom-balance-sources.en.md) · [Gateway quotas](docs/cliproxyapi-quota.md) · [Plan estimates](docs/token-plan-stats.md#english) |
|
|
92
|
+
| History and storage | [Retention and cleanup](docs/pricing-history-storage.md) · [Repricing](docs/model-history-repricing.md) · [External usage](docs/external-usage.md) · [Ledger recovery](docs/ledger-lock-recovery.md#english) |
|
|
93
|
+
| Development | [Architecture and development](docs/architecture.en.md) · [Contributing](CONTRIBUTING.md) · [Host compatibility](docs/host-compatibility.md) |
|
|
94
|
+
| Releases | [Update history](docs/UPDATE-HISTORY.md) · [CHANGELOG](CHANGELOG.md) |
|
|
95
|
+
|
|
96
|
+
## Community
|
|
97
|
+
|
|
98
|
+
[Open an issue](https://github.com/Han-1413141/dsh-cost-meter/issues) with plugin and host versions, reproduction steps and relevant logs. The WeChat group is available for usage questions and feature discussions.
|
|
99
|
+
|
|
100
|
+
<p align="center">
|
|
101
|
+
<a href="docs/community-wechat.png"><img src="docs/community-wechat.png" alt="WeChat community QR code" width="280"></a>
|
|
102
|
+
</p>
|
|
103
|
+
|
|
104
|
+
## Contributors
|
|
105
|
+
|
|
106
|
+
Thanks to everyone who contributes reports, ideas, documentation and code.
|
|
107
|
+
|
|
108
|
+
<a href="https://github.com/Han-1413141/dsh-cost-meter/graphs/contributors">
|
|
109
|
+
<img src="https://contrib.rocks/image?repo=Han-1413141/dsh-cost-meter" alt="Contributors">
|
|
110
|
+
</a>
|
|
111
|
+
|
|
112
|
+
## Star History
|
|
113
|
+
|
|
114
|
+
<a href="https://www.star-history.com/?repos=han-1413141%2Fdsh-cost-meter&type=timeline&legend=bottom-right">
|
|
115
|
+
<picture>
|
|
116
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=han-1413141/dsh-cost-meter&type=timeline&theme=dark&legend=bottom-right" />
|
|
117
|
+
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=han-1413141/dsh-cost-meter&type=timeline&legend=bottom-right" />
|
|
118
|
+
<img alt="Star History Chart" src="https://api.star-history.com/chart?repos=han-1413141/dsh-cost-meter&type=timeline&legend=bottom-right" />
|
|
119
|
+
</picture>
|
|
120
|
+
</a>
|
|
121
|
+
|
|
122
|
+
## License
|
|
123
|
+
|
|
124
|
+
[MIT](LICENSE) © 2026 dsh-cost-meter contributors
|