@kenz1117/dsh-ui-usage-billing 1.7.1 → 1.7.3

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.en.md CHANGED
@@ -9,7 +9,7 @@
9
9
  <a href="https://www.npmjs.com/package/@kenz1117/dsh-ui-usage-billing"><img alt="npm version" src="https://img.shields.io/npm/v/@kenz1117/dsh-ui-usage-billing?logo=npm"></a>
10
10
  <a href="https://www.npmjs.com/package/@kenz1117/dsh-ui-usage-billing"><img alt="npm downloads" src="https://img.shields.io/npm/dm/@kenz1117/dsh-ui-usage-billing?logo=npm"></a>
11
11
  <a href="https://github.com/kenz1117/dsh-ui-usage-billing/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/kenz1117/dsh-ui-usage-billing/actions/workflows/ci.yml/badge.svg"></a>
12
- <a href="https://github.com/kenz1117/dsh-ui-usage-billing/blob/main/COMPATIBILITY.md"><img alt="DSH compat" src="https://img.shields.io/badge/DSH-0.1.2_%7E_0.2.1--rc.2_%7C_0.1.0--rc.8%2B-blue"></a>
12
+ <a href="https://github.com/kenz1117/dsh-ui-usage-billing/blob/main/COMPATIBILITY.md"><img alt="DSH compat" src="https://img.shields.io/badge/DSH-0.1.2_%7E_0.2.1--rc.3_%7C_0.1.0--rc.8%2B-blue"></a>
13
13
  <a href="https://github.com/kenz1117/dsh-ui-usage-billing/blob/main/LICENSE"><img alt="License MIT" src="https://img.shields.io/github/license/kenz1117/dsh-ui-usage-billing"></a>
14
14
  <a href="https://github.com/kenz1117/dsh-ui-usage-billing/pulls"><img alt="PRs welcome" src="https://img.shields.io/badge/PRs-welcome-brightgreen"></a>
15
15
  <a href="https://github.com/kenz1117/dsh-ui-usage-billing"><img alt="GitHub last commit" src="https://img.shields.io/github/last-commit/kenz1117/dsh-ui-usage-billing?logo=github"></a>
@@ -25,11 +25,13 @@
25
25
  ---
26
26
 
27
27
  <div align="center">
28
- <img src="screenshots/demo.png" alt="dsh-ui-usage-billing — billing dashboard overview" width="80%">
28
+ <img src="screenshots/overview.png" alt="dsh-ui-usage-billing — billing dashboard overview" width="80%">
29
29
  </div>
30
30
 
31
31
  ### Demo GIF
32
32
 
33
+ The eight dashboard tabs in turn (Overview / Billing / Usage / Trends / Context / Agents / Rates / Settings):
34
+
33
35
  ![Demo](screenshots/demo.gif)
34
36
 
35
37
  ## ✨ Why this plugin
@@ -40,7 +42,7 @@ Most billing plugins stop at "token count × unit price". dsh-ui-usage-billing t
40
42
  Usage is aggregated live from persisted session logs — never fabricated (an empty snapshot shows until real data arrives); daily official-balance deltas are cross-checked against the local ledger, and deviations beyond the threshold prompt a review — a bill that survives scrutiny.
41
43
 
42
44
  ### Live prices, history never rewritten
43
- A live models.dev catalog + a built-in catalog of 239 models across 25 vendors + user-defined prices in the settings panel (bindable per relay origin) mean new models never wait for a release; DeepSeek time-of-day prices are **segmented by official change boundaries** (base price before 08-17, weekend peak hours 08-17~08-23, weekend all-day off-peak from 08-23) and later price changes never rewrite old bills.
45
+ A live models.dev catalog + a built-in catalog of 241 models across 25 vendors + user-defined prices in the settings panel (bindable per relay origin) mean new models never wait for a release; DeepSeek time-of-day prices are **segmented by official change boundaries** (base price before 08-17, weekend peak hours 08-17~08-23, weekend all-day off-peak from 08-23) and later price changes never rewrite old bills.
44
46
 
45
47
  ### Peak/off-peak aware, alerts follow the model
46
48
  The billing channel is detected from the current session's model: DeepSeek metered uses time-of-day prices (weekday 9-12 / 14-18 peak ×2, weekend all-day off-peak), Zhipu Coding Plan uses credit windows (weekday 14-18 peak at full rate, off-peak at **50% of base credits**) — the channel layer is extensible for more providers; a popover / system notification fires automatically before each switch, and only sessions whose current model actually involves peak/off-peak get alerted or show the tier section — no watching the clock.
@@ -63,24 +65,31 @@ The billing channel is detected from the current session's model: DeepSeek meter
63
65
  ## 📊 Dashboard
64
66
 
65
67
  - **Sidebar trigger card**: persistent above the Settings button — a single headline figure (today / this week / this month, selectable in settings, optional day-over-day badge) with a 7-day sparkline mini-trend and a today-vs-average gauge needle; collapses to an icon button; hover reveals a quick-look card (updated-at + metric grid + top spenders / quota alerts).
68
+
69
+ ![Sidebar trigger card: today's spend, delta badge and mini-trend](screenshots/sidebar.png)
70
+
66
71
  - **Eight-tab dashboard**: Overview / Billing / Usage / Trends / Context / Agents / Rates / Settings — hero figures + comparisons + month projection + KPIs (hover for the metric definition) + usage heatmap, trends switchable between cost and tokens over 7/30 days, model price table, budgets (global + per model) and peak/off-peak alerts all live here; the settings page supports full-text search (zh/en keywords, empty state when nothing matches); tabs carry names only — no status badges.
67
72
  - **Context section**: an occupancy bar plus next-request / last-request occupancy, window capacity and the composition split (system / tools / messages). The figures come from the host's official context projections; a session without one hides the whole section rather than showing a fabricated 0.
68
73
  - **Agents section**: the agent network rebuilt from delegation relations — a parent conversation → sub-agent tree where each row carries its call count, own cost and **chain total** (itself + all descendants), which directly answers "which delegation was the most expensive".
69
74
 
70
- ![Overview: month cost hero, budget progress, KPIs and usage heatmap](screenshots/1.png)
75
+ ![Overview: month cost hero, year/today/month projection, KPIs and usage heatmap](screenshots/overview.png)
76
+ ![Context: occupancy, window capacity and the system / tools / messages split](screenshots/context.png)
77
+ ![Agents: parent conversation → sub-agent delegation tree with chain totals](screenshots/agents.png)
71
78
  - **Live cost bar**: persistent "this turn / session" cost with three positions (composer toolbar row / above / below, toolbar by default); the peak/off-peak tier & countdown section appears only when the current model involves peak/off-peak pricing; subscription low-quota chips appear at ≤20% remaining, red at ≤10%; hideable via the settings-tab toggle (display-only preference persisted locally; stats and alerts unaffected).
72
79
  - **Peak/off-peak switch alert**: a popover plus an optional system notification before a switch; lead time / position / mode / preview configurable; copy differs by billing channel (DeepSeek price halves, Zhipu credits at 50%).
73
80
  - **Session completion notification**: an optional system notification when a session transitions running → completed (off by default, enable it in the panel); multi-window / multi-instance dedup through the claim endpoint, so each session notifies once.
74
81
  - **Plugin info card**: a persistent "About" card in the Settings tab — version read server-side from the package's `package.json` (single source of truth, correct on publish), author / repo / npm / license one click away.
75
82
 
83
+ ![Settings: display preferences, monthly budget, peak alerts, usage-query injection, custom prices and the plugin info card](screenshots/settings.png)
84
+
76
85
  ## 💰 Billing engine
77
86
 
78
87
  - **Provider-first grouping**: usage is grouped by the llm entry the calls actually went through (channel) — Tencent Cloud TokenHub / Token Plan / DeepSeek official / direct:<route> / unknown routes; the model brand stays as a row logo + sub-line. Official judgement follows the channel origin (`api.deepseek.com`) instead of the route name, so gateway routes named `deepseek-*` no longer count as official. `routeAliases` relocates renamed/deleted historical routes; `modelKeyAliases` binds uncatalogued model ids to catalog keys (date suffixes, org prefixes and the TokenHub short id `hy3` are recognized out of the box).
79
88
  - **Live rate table**: models.dev fetched pricing + live-model alignment — all configured models included; peak/off-peak split (weekdays 9-12 / 14-18 peak ×2, weekends off-peak all day; history priced per official change boundaries, see "Billing details") + a live USD→CNY rate, auto-refreshed every 6 hours; the rate strip shows the last sync time with a **one-click "Sync now"** button (no host restart needed).
80
89
 
81
- ![Rates: model rate table (peak/off-peak split and live rate)](screenshots/5.png)
90
+ ![Rates: model rate table (peak/off-peak split and live rate)](screenshots/pricing.png)
82
91
  - **Custom unit prices**: set real paid prices (miss / cache-hit / output, optional USD and off-peak columns) for uncatalogued or repriced models; bindable per relay origin; an out-of-catalog model is priced as soon as you fill it in.
83
- - **Official vs third-party buckets**: the detail cost column splits official direct / third-party relay ("official x / third y" when mixed); the Stats tab has a summary card; web-search assist calls count as official.
92
+ - **Official vs third-party buckets**: the model cost column in the Billing tab splits official direct / third-party relay ("official x / third y" when mixed); web-search assist calls count as official.
84
93
  - **Monthly budget + tier alerts**: budget bar ≥80% amber, over-budget red pulse; one alert per 50/80/100% crossing; a balance below the CNY threshold alerts once a day. **Per-model budgets**: set a CNY cap per top-spending model of the month (independent of the global budget), with one alert per model per 80% / 100% crossing.
85
94
  - **Cost-spike attribution**: last-40-turn cost bars, amount at bar top, peak/off-peak background bands, >2× spikes flagged with attribution.
86
95
 
@@ -92,20 +101,23 @@ The billing channel is detected from the current session's model: DeepSeek meter
92
101
  - **Declared endpoints + balance reconcile**: `declaredEndpoints` self-declares balance/quota interfaces for vendors absent from the built-in table — dot-paths only ("where the number is"), no expressions; safety bounds (single-slash absolute path, GET only, no cross-origin redirects, response-size/timeout caps, credentials from the matched provider only) are enforced by `src/declarative.ts`; a wrong path is marked `declared` with a reason. **Balance reconcile** (`reconcilePath`) cross-checks the official balance change against the local ledger, flagging drift above the threshold (0.3 CNY and >15%); top-ups / grants / currency changes reset the baseline instead of alerting, and a flat balance (subscription spend) stays silent.
93
102
  - **Relay-site attribution & quota**: usage is grouped by `baseURL` origin — multiple keys on one relay merge into a row named by its domain; New API (`/api/status`) and Sub2API (`/v1/usage`) are auto-detected for balance and rolling quota windows, labeled "no quota" when unreadable, <20% remaining in red; recognition caches for 5 minutes (per-key fuse-breaking), and the `relay-quotas` endpoint attaches `diagnostics` for "why is my relay not showing"; project attribution prefers the workspace title.
94
103
 
95
- ![Providers: provider billing & subscriptions (balance, plan quota, model usage)](screenshots/3.png)
104
+ ![Billing: provider billing & subscriptions (balance, plan quota, model usage) and session detail](screenshots/billing.png)
96
105
 
97
106
  > For the full adapter matrix per channel (detection / endpoints / credentials / troubleshooting), see [docs/adapters.md](docs/adapters.md).
98
107
 
99
108
  ## 📈 Usage visualizations
100
109
 
101
- - **Session detail + heatmap**: sessions sorted by cost (title / project / calls / cost / last active); "view all N sessions" opens a full-screen viewer (substring search by title / project / id, capped at 100 rows); month / half-year / year calendar heatmap (5-color scale, hover detail; the year view is ~52 weeks, GitHub-style, and the **half-year view uses 26 weeks of large cells** — half a year of intensity in one screenshot-ready chart) with a **cost / tokens metric switch**; total, active-day and streak counts on top.
102
- - **Performance metrics**: per-model TTFT mean / P50 / P90, generation speed (tokens/s), total-latency mean; per-hour × per-model comparison curves — metric tabs, clickable model chips (top-5 by samples lit by default), hover snapping to the nearest hour with a crosshair and per-model values, broken lines for missing-sample hours (never fabricated); view preferences persist locally.
103
- - **Token insights**: the daily token chart switches between two views — "Structure" (cache-miss / cache-hit / output, including reasoning) and "By model" (the toggle hides itself when snapshots lack per-day-per-model detail); hover shows the day's exact breakdown (thousand-separated); clicking a legend swatch or a model-table row focuses that model (click again to release); structural KPIs (cache-hit rate / reasoning share / input-output ratio / peak day); per-day CSV and JSON export (JSON includes per-day-per-model detail).
104
-
105
- ![Trends: daily cost trend, per-turn costs and peak/off-peak share](screenshots/2.png)
106
- - **Export + drill-down**: daily / per-session / per-site CSV and full JSON from the Stats tab; cost breakdown / workspaces / session detail drillable (click a project row to expand its sessions); no chart library, no external CDN, pure design tokens.
110
+ - **Session detail (Billing tab)**: sessions sorted by cost (title / project / calls / actual cost / last active); "view all N sessions" opens a full-screen viewer (substring search by title / project / id, capped at 100 rows); **clicking a session title opens that conversation in the host** (hosts without a session-selection channel show a readable notice instead of silently doing nothing).
111
+ - **Usage heatmap (Overview tab)**: month / half-year / year calendar heatmap (5-color scale, hover detail; the year view is ~52 weeks, GitHub-style, and the **half-year view uses 26 weeks of large cells** — half a year of intensity in one screenshot-ready chart) with a **cost / tokens metric switch**; total, active-day and streak counts on top.
112
+ - **Token insights (Usage tab)**: the daily token chart switches between two views — "Structure" (cache-miss / cache-hit / output, including reasoning) and "By model" (the toggle hides itself when snapshots lack per-day-per-model detail); hover shows the day's exact breakdown (thousand-separated); clicking a legend swatch or a model-table row focuses that model (click again to release); the model table breaks down input / output / reasoning / cache-hit rate / share / calls.
113
+ - **Tool-call ranking (Usage tab)**: call counts per tool (tokens cannot be attributed per tool, so only counts and shares), showing which tools dominate an agent loop.
114
+ - **Cost composition (Usage tab)**: output cost is measured, input cost is apportioned by user / tool message text length (the log has no per-role token measurement, so the UI labels it as an estimate).
115
+ - **Performance metrics (Usage tab)**: per-model TTFT mean / P50 / P90, generation speed (tokens/s), total-latency mean; per-hour × per-model comparison curves — metric tabs, clickable model chips (top-5 by samples lit by default), hover snapping to the nearest hour with a crosshair and per-model values, broken lines for missing-sample hours (never fabricated); view preferences persist locally.
116
+ - **Trends (Trends tab)**: daily cost & call trend (7 / 30 days, cost / tokens metric switch), last-40-turn cost bars (amount at bar top, >2× spikes flagged with attribution), peak/off-peak time share and the amount saved in off-peak hours.
107
117
 
108
- ![Stats: export, cost breakdown, workspaces and session detail](screenshots/4.png)
118
+ ![Trends: daily cost trend, per-turn costs and peak/off-peak share](screenshots/trends.png)
119
+ ![Usage: daily tokens, per-model tokens, tool ranking and cost composition](screenshots/usage.png)
120
+ - **Export + drill-down**: daily / per-session / per-site CSV and full JSON from the Billing tab, daily-token CSV from the Usage tab; session detail is drillable (click a project row to expand its sessions); no chart library, no external CDN, pure design tokens.
109
121
 
110
122
  ## 🛡️ Robustness & privacy
111
123
 
@@ -121,7 +133,7 @@ The billing channel is detected from the current session's model: DeepSeek meter
121
133
 
122
134
  Check your host generation first (`dsh --version`), then pick the matching install command — **a mismatched line is rejected by the DSH Store via the `engines.dsh` declaration** (declared since v1.0.41). Note that `dsh plugin add` requires an explicit `--profile` (otherwise it fails with `required option '--profile <name>' not specified`), and prefer **pinning an exact version** over `@latest` (pnpm's `minimumReleaseAge` cooldown skips freshly published versions and may fall back to the other line):
123
135
 
124
- - **DSH 0.1.2 ~ 0.2.0 era** (0.1.2-alpha.1 and later; npm `latest` currently at 0.2.0-rc.2; `npm ls -g @deepseek-ai/dsh` shows 0.1.2-* ~ 0.2.0-*):
136
+ - **DSH 0.1.2 ~ 0.2.1 era** (0.1.2-alpha.1 and later; the host's npm `latest` is currently 0.2.1-rc.2 and the preview line has reached 0.2.1-rc.3; `npm ls -g @deepseek-ai/dsh` shows 0.1.2-* ~ 0.2.1-*):
125
137
 
126
138
  ```sh
127
139
  dsh plugin --profile web add npm:@kenz1117/dsh-ui-usage-billing@latest
@@ -184,9 +196,11 @@ cost (CNY) = (missInput × p_input + cacheHit × p_cacheHit + output × p_output
184
196
 
185
197
  `input` in the stats is total input (cacheHit + cacheMiss); estimation splits it into hit / miss to avoid double counting. Models with two-band billing are mixed by `DEFAULT_PEAK_SHARE` (default 0.5); weekends (Beijing Sat/Sun) are charged at the off-peak rate all day.
186
198
 
187
- ### Supported models (2026-10 lineup, OpenAI-compatible series, 239 models)
199
+ **Month-to-date forecast**: month-to-date spend + last-7-calendar-day pace × the days still left in the month. Only the days that have not happened yet are extrapolated, so a quiet recent week never inflates the number — earlier versions averaged over the month's *recorded* days and multiplied by the whole month length, which inflated sparsely used months several times over.
200
+
201
+ ### Supported models (2026-10 lineup, OpenAI-compatible series, 241 models)
188
202
 
189
- The full catalog lives in the Rates tab and in `BUILTIN_MODEL_CATALOG` of `src/builtin-catalog.ts` (238 active + 1 retired model kept for historical repricing); representative models per vendor below.
203
+ The full catalog lives in the Rates tab and in `BUILTIN_MODEL_CATALOG` of `src/builtin-catalog.ts` (240 active + 1 retired model kept for historical repricing); representative models per vendor below.
190
204
 
191
205
  | Provider | Representatives |
192
206
  | -------- | -------------------------------------------- |
@@ -194,7 +208,7 @@ The full catalog lives in the Rates tab and in `BUILTIN_MODEL_CATALOG` of `src/b
194
208
  | Zhipu AI | GLM-5.3, GLM-5.2 (17 models) |
195
209
  | Aliyun | Qwen3.8 Max, Qwen3-Coder 480B (27 models) |
196
210
  | Doubao | Doubao Seed-2.1 Pro, Doubao Seed-2.0 Pro (13 models) |
197
- | Moonshot | Kimi K3, Kimi K2.7 Code (16 models) |
211
+ | Moonshot | Kimi K3.1 Pro, Kimi K3.1 Pro Highspeed, Kimi K3, Kimi K2.7 Code (18 models) |
198
212
  | Xiaomi | MiMo V2.6 Pro (6 models) |
199
213
  | MiniMax | MiniMax-M3, MiniMax-M2.7 (8 models) |
200
214
  | Unisound | U2 Flash, Unisound U2 (3 models) |
@@ -232,7 +246,7 @@ The public HTTP endpoints and field definitions are documented in source: `GET /
232
246
  | `statsPath` | unset | Absolute path to a fallback `.dsh-usage-stats.json` (used when `sessionPersistence` is unavailable) |
233
247
  | `ledgerPath` | `<harness home>/.dsh-usage-ledger.json` | Independent durable ledger path; stores folded metrics only (no message bodies or session titles), so deletion does not erase recorded usage. The default root follows the host harness home (`DSH_HOME` env first, falling back to `~/.dsh`), so isolated environments never share ledger data (issue #52) |
234
248
  | `balanceApiKeyEnv` | `DEEPSEEK_API_KEY` | Credential ref for the DeepSeek balance query; only used as a fallback when llm-pi-ai has no `apiKeyEnv` for deepseek |
235
- | `subscriptionProviders` | built-in channel list (incl. `tencent-token-plan`) | Subscription (coding / token plan) provider id list — tokens counted, cost 0; aligned with the subscription-card recognition |
249
+ | `subscriptionProviders` | built-in channel list (incl. `tencent-token-plan`) | Subscription (coding / token plan) provider id list — tokens counted, cost 0; aligned with the subscription-card recognition. Note it **replaces** the built-in list rather than appending to it — when customizing, list the built-in entries too, otherwise removed subscription channels fall back to pay-as-you-go |
236
250
  | `routeAliases` | not set | Historical route aliases (old provider route name -> current route): renamed/deleted routes relocate into their channel instead of the "unknown" bucket. Example: `{ "deepseek-official": "tencent" }` |
237
251
  | `modelKeyAliases` | not set | User model aliases (log model id -> billing catalog key, value must be an existing `MODEL_CATALOG` key): bind uncatalogued ids without waiting for a release. Example: `{ "hy4-preview": "hunyuan" }` |
238
252
  | `monthlyBudget` | unset | Default monthly budget (CNY); sent with usage-stats as the budget bar's initial amount (user UI settings take precedence and persist locally) |
@@ -272,7 +286,7 @@ The host discovers the browser side automatically via the `dsh.client` declarati
272
286
 
273
287
  - **Permission level: high**: reads durable session logs (files), calls official multi-vendor / subscription / balance / pricing APIs (network), reads `apiKeyEnv` via the credentials seam (credentials), writes the ledger and stats snapshot under the harness home (`DSH_HOME` / `~/.dsh`) (persistent state); **no** command execution / shell.
274
288
  - **Update channel: `user-reviewed`**: with file / network / credential capabilities, DSH STORE requires local manual confirmation on every install; review the repo, pinned commit, lifecycle scripts, and impact scope before installing.
275
- - **Compatibility**: the preview line (npm `latest`/`alpha`, 1.6.x — kept above the stable line to kill the version inversion) targets DSH `0.1.2-alpha.1` ~ `0.2.1-rc.2` (host `latest` currently at 0.2.0-rc.2, preview at 0.2.1-rc.2; the full 0.2.1 series is declared per version); the stable line (npm `stable`, 1.1.x, **frozen**, final v1.1.17) targets legacy hosts `0.1.0-rc.8` ~ `0.1.1-rc.2`. Per-version declarations live in `package.json` under `dsh.compatibility`; the two-line mapping and monitoring mechanism are documented in [COMPATIBILITY.md](COMPATIBILITY.md). Node.js `^22.19.0 || >=24.0.0`.
289
+ - **Compatibility**: the preview line (npm `latest`/`alpha`, 1.7.x — kept above the stable line to kill the version inversion) targets DSH `0.1.2-alpha.1` ~ `0.2.1-rc.3` (the host's `latest` currently at 0.2.1-rc.2, preview at 0.2.1-rc.3; the full 0.2.1 series is declared per version); the stable line (npm `stable`, 1.1.x, **frozen**, final v1.1.17) targets legacy hosts `0.1.0-rc.8` ~ `0.1.1-rc.2`. Per-version declarations live in `package.json` under `dsh.compatibility`; the two-line mapping and monitoring mechanism are documented in [COMPATIBILITY.md](COMPATIBILITY.md). Node.js `^22.19.0 || >=24.0.0`.
276
290
  - **Lifecycle**: no `preinstall` / `install` / `postinstall` / `prepare` (ready on install).
277
291
  - **No impersonation**: adds only its own entry id `ui-usage-billing`; `@deepseek-ai/dsh-*` packages are `peerDependencies` only (no reinstall / replace / shadowing of official components); the package uses the third-party namespace `@kenz1117/*`.
278
292
  - **Build artifacts**: runtime files `lib/*` and `cordis.patch.yml` are committed at the pinned commit and declared in `files`.
@@ -295,7 +309,7 @@ Boundaries: the tool reads only this plugin's own aggregates — never session b
295
309
  - **Balance queries cover DeepSeek / Moonshot (Kimi) / StepFun / SiliconFlow / xAI / Zhipu GLM (Z.ai CN region) / Tencent Cloud TokenHub (token-plan quota)**: the first six use a standard Bearer API key; Tencent Cloud uses the cloud-API key pair (`<SecretId>:<SecretKey>`, TC3-signed management API). Other providers expose no public balance API or need non-Bearer auth (Xiaomi MiMo via console Cookie, SenseTime via AccessKey signing, MiniMax/Doubao via quota or AK/SK), so they currently show "not configured"; the extension point is `src/balance.ts` (add a querier per provider balance API).
296
310
  - **Relay quota depends on upstream private schemas**: New API / Sub2API interface fields are not public, so an unreadable station is labeled "no quota" rather than fabricating an amount; if a station's response fields differ, extend the parsers in `src/relay.ts`. An "unknown route" means that route exists neither in the current provider config nor in the host llm registry (deleted config, logs older than the install, …); historical call data is not lost — re-adding the same-named route restores attribution automatically. Cost in the unknown-route bucket is always 0 (issue #82): the spending party cannot be verified — same posture as uncatalogued models and subscription channels — while tokens are still counted, and the panel shows "—" for the group cost with an explanatory note. Channels registered by another plugin through `ctx.llm.registerAdapter` (e.g. CommandCode) are **not** unknown routes: the plugin discovers them from the host llm registry and bills them in the `direct:<provider>` bucket at the model's official catalog price (issue #91); the registry is read through `ctx.get('llm')` (no `inject` requirement), and an unreadable or empty registry warns once (panel numbers and the unknown policy are unchanged) so this class of failure is never silent again.
297
311
  - **Overspend notifications rely on the browser Notification API**: when permission is denied or the platform lacks support, only the in-UI red-pulse fallback remains — no host-level notification channel; notifications are capped at once per day.
298
- - **Session rows are not navigable**: clicking a session row does not open that session (cross-plugin navigation needs a host session-selection channel); the panel shows the top 20 by default and the "view all" full-screen viewer is capped at 100 rows.
312
+ - **Session-row navigation depends on a host channel**: clicking a session title in the panel opens that conversation in the host (both generations of the host's session-selection channel are probed); on very old hosts, or when the session was deleted / is not in the current session list, the UI shows a readable notice instead of silently doing nothing. The panel shows the top 20 by default and the "view all" full-screen viewer is capped at 100 rows.
299
313
  - **Cost is a catalog estimate**: models without published per-token pricing (iFlytek, SenseTime, Xiaomi) use estimates (feature-list footnote ¹); official billing is authoritative.
300
314
  - **The ledger starts at its first successful aggregation**: sessions permanently deleted before the upgrade and absent from the old snapshot cannot be recovered. Manually deleting `.dsh-usage-ledger.json` and its `.bak` clears independently retained history. Only calls successfully observed by this plugin are retained.
301
315
 
package/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
  <a href="https://github.com/kenz1117/dsh-ui-usage-billing/stargazers"><img alt="GitHub stars" src="https://img.shields.io/github/stars/kenz1117/dsh-ui-usage-billing?logo=github"></a>
10
10
  <a href="https://www.npmjs.com/package/@kenz1117/dsh-ui-usage-billing"><img alt="npm version" src="https://img.shields.io/npm/v/@kenz1117/dsh-ui-usage-billing?logo=npm"></a>
11
11
  <a href="https://www.npmjs.com/package/@kenz1117/dsh-ui-usage-billing"><img alt="npm downloads" src="https://img.shields.io/npm/dm/@kenz1117/dsh-ui-usage-billing?logo=npm"></a>
12
- <a href="https://github.com/kenz1117/dsh-ui-usage-billing/blob/main/COMPATIBILITY.md"><img alt="DSH 兼容" src="https://img.shields.io/badge/DSH-0.1.2_%7E_0.2.1--rc.2_%7C_0.1.0--rc.8%2B-blue"></a>
12
+ <a href="https://github.com/kenz1117/dsh-ui-usage-billing/blob/main/COMPATIBILITY.md"><img alt="DSH 兼容" src="https://img.shields.io/badge/DSH-0.1.2_%7E_0.2.1--rc.3_%7C_0.1.0--rc.8%2B-blue"></a>
13
13
  <a href="https://github.com/kenz1117/dsh-ui-usage-billing/blob/main/LICENSE"><img alt="License MIT" src="https://img.shields.io/github/license/kenz1117/dsh-ui-usage-billing"></a>
14
14
  <a href="https://github.com/kenz1117/dsh-ui-usage-billing/pulls"><img alt="PRs welcome" src="https://img.shields.io/badge/PRs-welcome-brightgreen"></a>
15
15
  <a href="https://github.com/kenz1117/dsh-ui-usage-billing"><img alt="GitHub last commit" src="https://img.shields.io/github/last-commit/kenz1117/dsh-ui-usage-billing?logo=github"></a>
@@ -25,11 +25,13 @@
25
25
  ---
26
26
 
27
27
  <div align="center">
28
- <img src="screenshots/demo.png" alt="dsh-ui-usage-billing — 计费仪表盘总览" width="80%">
28
+ <img src="screenshots/overview.png" alt="dsh-ui-usage-billing — 计费仪表盘总览" width="80%">
29
29
  </div>
30
30
 
31
31
  ### 演示动图
32
32
 
33
+ 新版仪表盘八个分区逐个切换(概览 / 账单 / 用量 / 趋势 / 上下文 / 智能体 / 费率 / 设置):
34
+
33
35
  ![演示](screenshots/demo.gif)
34
36
 
35
37
  ## ✨ 为什么选它
@@ -40,7 +42,7 @@
40
42
  用量从持久化会话日志实时聚合,绝不伪造样本(数据到达前显示空快照);官方余额当日变动与本地账本交叉对账,偏差超阈值主动提示核对——账单经得起质疑。
41
43
 
42
44
  ### 价格是活的,历史不重算
43
- models.dev 实时目录 + 内置 25 厂商 239 款模型 + 设置面板自定义单价(可按中转站绑定同模型不同价),新模型无需等发版;DeepSeek 分时价按官方变更节点**分段计价**(8-17 前基础价、8-17~8-23 周末计峰、8-23 起周末全谷),价格调整永不回写旧账。
45
+ models.dev 实时目录 + 内置 25 厂商 241 款模型 + 设置面板自定义单价(可按中转站绑定同模型不同价),新模型无需等发版;DeepSeek 分时价按官方变更节点**分段计价**(8-17 前基础价、8-17~8-23 周末计峰、8-23 起周末全谷),价格调整永不回写旧账。
44
46
 
45
47
  ### 峰谷全感知,提醒跟着模型走
46
48
  计费通道按当前会话使用的模型自动识别:DeepSeek 按量走分时价(工作日 9-12 / 14-18 高峰 ×2、周末全天低谷),智谱 Coding Plan 走积分峰谷(工作日 14-18 高峰全额、非高峰**积分 5 折**),通道层可扩展、更多厂商逐步接入;切档前弹窗 / 系统通知自动提醒,且只有当前模型真正涉及峰谷才会提醒、费用条才显示档位——不用你盯时间表。
@@ -64,24 +66,31 @@ DeepSeek / Kimi / 智谱 GLM / 腾讯云 TokenHub 等 7 家官方余额、Coding
64
66
  ## 📊 仪表盘
65
67
 
66
68
  - **侧边栏触发卡**:设置按钮上方常驻单值主数字(今日 / 本周 / 本月统计范围在设置里选,可选涨跌徽章),配近 7 天 sparkline 迷你趋势与当日水位仪表指针;折叠栏自动切为图标钮,悬停浮现速览卡(更新时间 + 指标网格 + 主力消耗 / 额度提醒)。
69
+
70
+ ![侧边栏触发卡:今日消耗金额、涨跌徽章与迷你趋势](screenshots/sidebar.png)
71
+
67
72
  - **八区仪表盘**:概览 / 账单 / 用量 / 趋势 / 上下文 / 智能体 / 费率 / 设置——Hero 大数字 + 环比 + 本月预计 + KPI(悬停显示口径说明)+ 用量热力图,趋势 7/30 天可切费用 / Token,模型单价表、预算(全局 + 按模型)与峰谷提醒都在;设置页支持全文搜索(中英关键词过滤分区,全不命中显示空态);克制冷调、深浅主题自适应。Tab 只保留名称,不再挂状态徽标(信息都在各自分区里)。
68
73
  - **上下文分区**:占用率进度条 + 下一次 / 最近一次请求占用 + 窗口上限 + 构成拆解(系统 / 工具 / 消息)。数据取自宿主官方 context 投影;**没有投影的会话整块不显示**,不拿 0 冒充。
69
74
  - **智能体分区**:按委派关系还原的智能体网络——父对话 → 子智能体的层级树,每行给调用数、自身费用与**链合计**(自身 + 全部后代),直接回答「哪次委派最贵」。
70
75
 
71
- ![概览:本月费用 Hero、预算进度、KPI 与用量热力图](screenshots/1.png)
76
+ ![概览:本月费用 Hero、本年 / 今日 / 本月预计、KPI 与用量热力图](screenshots/overview.png)
77
+ ![上下文:占用率、窗口上限与系统 / 工具 / 消息构成拆解](screenshots/context.png)
78
+ ![智能体:父对话 → 子智能体的委派树与链合计](screenshots/agents.png)
72
79
  - **即时代费用条**:常驻「本轮 / 会话」费用,位置三档可选(输入框内部工具行 / 上方 / 下方,默认工具行);峰谷档位与切换倒计时只在当前模型涉及峰谷时出现;订阅额度预警 chips 剩余 ≤20% 浮现、≤10% 标红;可在设置 Tab 整条隐藏(偏好本地持久化,统计与提醒不受影响)。
73
80
  - **峰 / 谷切换提醒**:切档前弹窗 + 可选系统通知,提前量 / 位置 / 模式 / 预览均可配;文案按计费通道区分(DeepSeek 价格减半、智谱积分 5 折)。
74
81
  - **会话完成提醒**:会话 running → completed 时弹系统通知(默认关闭,面板设置开启);多窗口 / 多实例按认领端点去重,同一会话只提醒一次。
75
82
  - **插件信息卡**:设置 Tab 常驻「关于」卡——版本号服务端读自包 `package.json`(单一来源,发布自动正确),作者 / 仓库 / npm / 许可证一键可达。
76
83
 
84
+ ![设置:显示偏好、本月预算、峰谷提醒、注入用量查询、自定义单价与插件信息卡](screenshots/settings.png)
85
+
77
86
  ## 💰 计费引擎
78
87
 
79
88
  - **提供商优先分组**:费用按调用实际发生的 llm 入口(通道)分组——腾讯云 TokenHub / Token Plan / DeepSeek 官方 / 直连·路由名 / 未知路由,模型品牌只是行内徽标 + 副标;官方判定按通道 origin(`api.deepseek.com`)而非路由名,`deepseek-*` 网关路由不再被误算官方。`routeAliases` 归位改名 / 删除的历史路由,`modelKeyAliases` 把目录外模型 id 绑定到计费键(日期后缀、组织前缀、TokenHub 短 id `hy3` 已内置识别)。
80
89
  - **实时费率表**:models.dev 抓价 + 探活模型对标,系统实际配置的模型全纳入;峰谷分时(工作日 9-12 / 14-18 高峰 ×2、周末全天低谷,历史费用按官方变更节点分段,见下方「计费细节」)+ 实时汇率(USD→CNY),每 6 小时自动刷新;费率条显示「上次同步」时间并可**一键立即同步**(无需重启宿主)。
81
90
  - **自定义单价**:设置面板为未收录或变价模型填实付价(未命中 / 缓存命中 / 输出,可选 USD 与低谷价),总览与日趋势按用户价重估;支持按中转站来源绑定同模型不同价,目录外模型填价即生效。
82
91
 
83
- ![费率:模型单价表(峰谷分时与实时汇率)](screenshots/5.png)
84
- - **官方 vs 三方分桶**:明细费用列按官方直连 / 第三方中转分解(混合时「官 x / 三 y」),统计 Tab 有汇总卡;联网搜索辅助请求计入官方。
92
+ ![费率:模型单价表(峰谷分时与实时汇率)](screenshots/pricing.png)
93
+ - **官方 vs 三方分桶**:账单 Tab 的模型明细费用列按官方直连 / 第三方中转分解(混合时「官 x / 三 y」);联网搜索辅助请求计入官方。
85
94
  - **月度预算 + 分档提醒**:预算条 ≥80% 琥珀、超支红脉;跨 50 / 80 / 100% 各提醒一次;余额折算 CNY 低于阈值每天提醒一次。**按模型预算**:为本月消耗 Top 模型逐个设人民币上限(与全局预算相互独立),单模型跨 80% / 100% 各提醒一次。
86
95
  - **成本突增归因**:最近 40 轮费用柱状图,金额贴柱顶、峰谷背景分带、超 2 倍红标归因。
87
96
 
@@ -93,20 +102,23 @@ DeepSeek / Kimi / 智谱 GLM / 腾讯云 TokenHub 等 7 家官方余额、Coding
93
102
  - **声明端点 + 余额对账**:内置表没有的供应商用 `declaredEndpoints` 自声明余额接口——只写「数字在哪里」的点路径、无表达式;安全边界(单斜杠绝对路径、仅 GET、拒跨源重定向、响应体 / 超时上限、凭据只取本 provider)由 `src/declarative.ts` 强制执行,取错路径在界面标 `declared` 与 reason。**余额差对账**(`reconcilePath`)用官方余额当日变动与本地账本交叉校验,偏差超阈值(0.3 元且 >15%)提示核对;充值 / 授信 / 币种变化重置基准而非告警,余额未减少(走订阅扣费)静默。
94
103
  - **中转站归组与额度**:按 `baseURL` 归一化 origin 归组,同站多把 key 合并一行、站名即域名;自动识别 New API 系(`/api/status`)与 Sub2API(`/v1/usage`)的余额与滚动额度窗口,读不出标「未读出额度」、剩余 <20% 标红;识别结果 5 分钟指纹缓存(同站多 key 独立熔断),`relay-quotas` 端点附 `diagnostics` 供「为什么不显示」自查;项目归属优先用工作区标题命名。
95
104
 
96
- ![明细:厂商计费与订阅(余额、套餐额度、模型用量)](screenshots/3.png)
105
+ ![账单:提供商计费与订阅(余额、套餐额度、模型用量)与会话明细](screenshots/billing.png)
97
106
 
98
107
  > 全部渠道的适配矩阵(识别方式 / 端点 / 凭据要求 / 排查顺序)见 [docs/adapters.md](docs/adapters.md)。
99
108
 
100
109
  ## 📈 用量可视化
101
110
 
102
- - **会话明细 + 热力图**:按会话费用倒序(标题 / 项目 / 调用 / 费用 / 最后活跃);「查看全部 N 个会话」打开全屏浮层(按标题 / 项目 / id 子串搜索,封顶 100 行);月 / 半年 / 年三档日历热力图(5 档色阶、悬停明细,年视图近 52 周 GitHub 风格,**半年视图 26 周大格**——一张图看完近半年强度,截图即用),**费用 / Token 双口径**切换,头部显示区间合计、活跃天数 / 连续使用天数。
103
- - **性能指标**:每模型 TTFT 均值 / P50 / P90、生成速度(tokens/s)、总延迟均值;按小时 × 模型对比曲线——指标 tab 切换、模型 chip 点击开关曲线(默认点亮样本数前 5)、悬停吸附最近小时显示十字线与逐模型数值,缺失样本小时断线不造假;视图偏好本地持久化。
104
- - **Token 统计洞察**:每日 token 堆叠双视角——「按结构」(输入未命中 / 命中 / 输出三桶,含 reasoning)与「按模型」(旧快照缺明细时自动隐藏切换);悬停显示当日精确明细(千分位不缩写),点击图例色块或 Token 表行聚焦单模型(再点解除);结构 KPI(缓存命中率 / 思考占比 / 输入输出比 / 峰值日);按日 CSV 与 JSON 导出(JSON 含按日 × 模型明细)。
105
-
106
- ![趋势:每日费用趋势、每轮费用与峰谷时段占比](screenshots/2.png)
107
- - **数据导出 + 下钻**:统计 Tab 导出按日 / 按会话 / 按站点 CSV 与全量 JSON;费用构成 / 工作区 / 会话明细可下钻(点项目行展开该项目的会话);无图表库、无外部 CDN、纯设计令牌。
111
+ - **会话明细(账单 Tab)**:按会话费用倒序(标题 / 项目 / 调用 / 实际费用 / 最后活跃),「查看全部 N 个会话」打开全屏浮层(按标题 / 项目 / id 子串搜索,封顶 100 行);**点会话标题直接打开宿主对话**(宿主不支持时给出可读提示,不静默无反应)。
112
+ - **用量热力图(概览 Tab)**:月 / 半年 / 年三档日历热力图(5 档色阶、悬停明细,年视图近 52 周 GitHub 风格,**半年视图 26 周大格**——一张图看完近半年强度,截图即用),**费用 / Token 双口径**切换,头部显示区间合计、活跃天数 / 连续使用天数。
113
+ - **Token 统计洞察(用量 Tab)**:每日 token 堆叠双视角——「按结构」(输入未命中 / 命中 / 输出三桶,含 reasoning)与「按模型」(旧快照缺明细时自动隐藏切换);悬停显示当日精确明细(千分位不缩写),点击图例色块或 Token 表行聚焦单模型(再点解除);模型 Token 表给出输入 / 输出 / 思考 / 缓存命中率 / 占比 / 调用数。
114
+ - **工具调用排行(用量 Tab)**:按工具计次的调用结构(token 无法按工具归因,只给次数与占比),看清 agent 循环里哪些工具在刷量。
115
+ - **费用构成(用量 Tab)**:输出成本按实测计价、输入成本按 user / tool 消息文本长度占比摊分(日志无角色级 token 实测,界面标注估算口径)。
116
+ - **性能指标(用量 Tab)**:每模型 TTFT 均值 / P50 / P90、生成速度(tokens/s)、总延迟均值;按小时 × 模型对比曲线——指标 tab 切换、模型 chip 点击开关曲线(默认点亮样本数前 5)、悬停吸附最近小时显示十字线与逐模型数值,缺失样本小时断线不造假;视图偏好本地持久化。
117
+ - **趋势(趋势 Tab)**:每日费用与调用趋势(7 / 30 天可切,费用 / Token 双口径)、最近 40 轮费用柱状图(金额贴柱顶、超 2 倍红标归因)、峰谷时段占比与低谷省下的金额。
108
118
 
109
- ![统计:导出、费用构成、工作区与会话明细](screenshots/4.png)
119
+ ![趋势:每日费用趋势、每轮费用与峰谷时段占比](screenshots/trends.png)
120
+ ![用量:每日 Token、模型 Token、工具排行与费用构成](screenshots/usage.png)
121
+ - **数据导出 + 下钻**:账单 Tab 导出按日 / 按会话 / 按站点 CSV 与全量 JSON,用量 Tab 导出按日 Token CSV;会话明细可下钻(点项目行展开该项目的会话);无图表库、无外部 CDN、纯设计令牌。
110
122
 
111
123
  ## 🛡️ 健壮性与隐私
112
124
 
@@ -122,7 +134,7 @@ DeepSeek / Kimi / 智谱 GLM / 腾讯云 TokenHub 等 7 家官方余额、Coding
122
134
 
123
135
  先确认宿主代际(`dsh --version`),再按代际选安装命令——**装错线会在市场侧被 `engines.dsh` 声明拦截**(v1.0.41 起声明生效)。注意 `dsh plugin add` 需要显式 `--profile`(缺省会报 `required option '--profile <name>' not specified`),且建议**钉具体版本号**而非 `@latest`(pnpm 的 `minimumReleaseAge` 冷静期会让刚发布的版本被跳过、回退到旧线):
124
136
 
125
- - **DSH 0.1.2 ~ 0.2.0 系**(0.1.2-alpha.1 起,现行 latest 为 0.2.0-rc.2;`npm ls -g @deepseek-ai/dsh` 显示 0.1.2-* ~ 0.2.0-*):
137
+ - **DSH 0.1.2 ~ 0.2.1 系**(0.1.2-alpha.1 起,宿主 `latest` 现为 0.2.1-rc.2、预览线已到 0.2.1-rc.3;`npm ls -g @deepseek-ai/dsh` 显示 0.1.2-* ~ 0.2.1-*):
126
138
 
127
139
  ```sh
128
140
  dsh plugin --profile web add npm:@kenz1117/dsh-ui-usage-billing@latest
@@ -191,11 +203,13 @@ cost(CNY)= (missInput × p_input + cacheHit × p_cacheHit + output × p_outp
191
203
 
192
204
  **联网搜索请求按次估算**(issue #15):DSH 的联网搜索绕过对话通道直连官方 `api.deepseek.com`,会话日志只记请求、无用量事件,而开放平台照常计费。插件对这类 `web/deepseek-search-llm-request` 事件按次估值计入费用(默认 0.02 元/次,配置 `searchCallEstimateCny` 可调整;设 0 关闭),并单独累计 `searchCalls` 供面板提示估算口径。
193
205
 
206
+ **「本月预计」的口径**:本月已发生 + 近 7 个自然日节奏 × 本月剩余天数。只外推还没发生的天数,近期没花钱就不虚增——早期版本拿「本月有记录的天数」当分母求日均再乘整月天数,稀疏使用的月份会被放大数倍(实测 4 天记录、其余 19 天没用的月份被外推成实际值的 4 倍)。
207
+
194
208
  **自定义单价(设置 Tab,issue #16)**:结构化条目表(模型 + 可选来源 + 输入/缓存命中/输出 + 币种),不再手编 JSON。来源(中转站域名)留空 = 该模型默认价;填入中转站域名(如 `https://api.my-relay.com`)= 仅该来源的同名模型用此价(同名模型可同时存在默认价与多个来源价,互不覆盖)。显示层按「模型 × 来源」精确匹配重算,命中不到来源时回落该模型默认价,再无则用内置目录价。
195
209
 
196
- ### 支持模型(2026-10 主流阵容,OpenAI 兼容系列,共 239 款)
210
+ ### 支持模型(2026-10 主流阵容,OpenAI 兼容系列,共 241 款)
197
211
 
198
- 完整目录见费率 Tab 及源码 `src/builtin-catalog.ts` 的 `BUILTIN_MODEL_CATALOG`(238 款在售 + 1 款退役型号保留历史回算),此处每厂商仅列代表型号。
212
+ 完整目录见费率 Tab 及源码 `src/builtin-catalog.ts` 的 `BUILTIN_MODEL_CATALOG`(240 款在售 + 1 款退役型号保留历史回算),此处每厂商仅列代表型号。
199
213
 
200
214
  | 厂商 | 代表模型 |
201
215
  | -------- | -------------------------------------------- |
@@ -203,7 +217,7 @@ cost(CNY)= (missInput × p_input + cacheHit × p_cacheHit + output × p_outp
203
217
  | 智谱 AI | GLM-5.3、GLM-5.2(等 17 款) |
204
218
  | 阿里通义 | Qwen3.8 Max、Qwen3-Coder 480B(等 27 款) |
205
219
  | 字节豆包 | Doubao Seed-2.1 Pro、Doubao Seed-2.0 Pro(等 13 款) |
206
- | 月之暗面 | Kimi K3、Kimi K2.7 Code(等 16 款) |
220
+ | 月之暗面 | Kimi K3.1 Pro、Kimi K3.1 Pro Highspeed、Kimi K3、Kimi K2.7 Code(等 18 款) |
207
221
  | 小米 | MiMo V2.6 Pro(等 6 款) |
208
222
  | MiniMax | MiniMax-M3、MiniMax-M2.7(等 8 款) |
209
223
  | 云知声 | U2 Flash、Unisound U2(等 3 款) |
@@ -241,7 +255,7 @@ cost(CNY)= (missInput × p_input + cacheHit × p_cacheHit + output × p_outp
241
255
  | `statsPath` | 未设置 | 回退统计文件 `.dsh-usage-stats.json` 的绝对路径(`sessionPersistence` 不可用时生效) |
242
256
  | `ledgerPath` | `<harness home>/.dsh-usage-ledger.json` | 独立持久用量账本的绝对路径;只保存折叠后的统计(不保存消息正文或会话标题),永久删除会话不会删除已记录的费用与 token。**默认根跟随宿主 harness home**(`DSH_HOME` 环境变量优先,回退 `~/.dsh`),自定义 `DSH_HOME` 的多套隔离环境互不污染(issue #52) |
243
257
  | `balanceApiKeyEnv` | `DEEPSEEK_API_KEY` | DeepSeek 余额查询的凭据引用;仅在 llm-pi-ai 未配置 deepseek 的 `apiKeyEnv` 时兜底使用 |
244
- | `subscriptionProviders` | 内置订阅通道清单(含 `tencent-token-plan`) | 订阅制(coding / token 套餐)provider id 列表,照常统计 token、费用记 0;与订阅卡识别口径对齐 |
258
+ | `subscriptionProviders` | 内置订阅通道清单(含 `tencent-token-plan`) | 订阅制(coding / token 套餐)provider id 列表,照常统计 token、费用记 0;与订阅卡识别口径对齐。**注意是「替换」默认清单,不是追加**——自定义时要把默认项一并写全,否则被移出的订阅通道会被拉回按量计费 |
245
259
  | `routeAliases` | 未设置 | 历史路由别名(旧 provider 路由名 → 当前路由名):改名/删除过的路由,其历史用量原落「未知路由」桶且订阅/官方判定失效;配置后按目标路由归位。例:`{ "deepseek-official": "tencent", "tencent-cloud": "tencent" }` |
246
260
  | `modelKeyAliases` | 未设置 | 用户自定义模型别名(真实日志 model id → 计费目录键,值须为 `MODEL_CATALOG` 既有 key):目录外新模型无需等发版,配一条别名即完成识别与计价。例:`{ "hy4-preview": "hunyuan" }` |
247
261
  | `monthlyBudget` | 未设置 | 月度预算默认金额(人民币元);随 usage-stats 下发,作为仪表盘预算条的初始金额(用户在界面上的设置优先并本地持久化) |
@@ -281,7 +295,7 @@ npm dist-tag add @kenz1117/dsh-ui-usage-billing@<版本> alpha
281
295
 
282
296
  - **权限等级:high**:读取持久会话日志(文件)、访问多厂商官方 / 订阅 / 余额 / 定价 API(网络)、经凭据 seam 读取 `apiKeyEnv`(凭据)、写入 harness home(`DSH_HOME` / `~/.dsh`)下的账本与快照(持久状态);**不含**命令执行 / Shell。
283
297
  - **更新通道:`user-reviewed`**:本插件具备文件 / 网络 / 凭据能力,DSH STORE 采用每次安装需本机人工确认的通道;安装前请复核仓库、固定 Commit、生命周期脚本与影响范围。
284
- - **兼容范围**:预览线(npm `latest`/`alpha`,1.6.x,自 v1.2.0 起恒高于稳定线以消除版本号倒挂)适配 DSH `0.1.2-alpha.1` ~ `0.2.1-rc.2`(宿主 `latest` 现指向 0.2.0-rc.2、预览线最新为 0.2.1-rc.2;0.2.1 全系列逐版本声明);稳定线(npm `stable`,1.1.x,**已冻结**,终版 v1.1.17)适配旧宿主 `0.1.0-rc.8` ~ `0.1.1-rc.2`。逐版本声明见 `package.json` 的 `dsh.compatibility`,双线对照与监控机制见 [COMPATIBILITY.md](COMPATIBILITY.md)。Node.js `^22.19.0 || >=24.0.0`。
298
+ - **兼容范围**:预览线(npm `latest`/`alpha`,1.7.x,自 v1.2.0 起恒高于稳定线以消除版本号倒挂)适配 DSH `0.1.2-alpha.1` ~ `0.2.1-rc.3`(宿主 `latest` 现指向 0.2.1-rc.2、预览线已到 0.2.1-rc.3;0.2.1 全系列逐版本声明);稳定线(npm `stable`,1.1.x,**已冻结**,终版 v1.1.17)适配旧宿主 `0.1.0-rc.8` ~ `0.1.1-rc.2`。逐版本声明见 `package.json` 的 `dsh.compatibility`,双线对照与监控机制见 [COMPATIBILITY.md](COMPATIBILITY.md)。Node.js `^22.19.0 || >=24.0.0`。
285
299
  - **生命周期**:无 `preinstall` / `install` / `postinstall` / `prepare`(安装即用)。
286
300
  - **不冒用官方**:仅新增自有 entry id `ui-usage-billing`;对 `@deepseek-ai/dsh-*` 仅为 `peerDependencies` 依赖(不重复安装 / 不替换 / 不遮蔽官方组件),包名使用第三方命名空间 `@kenz1117/*`。
287
301
  - **打包产物**:运行文件 `lib/*` 与 `cordis.patch.yml` 已随固定 Commit 提交并声明在 `files`。
@@ -304,7 +318,7 @@ npm dist-tag add @kenz1117/dsh-ui-usage-billing@<版本> alpha
304
318
  - **余额查询已接入 DeepSeek / 月之暗面(Kimi)/ 阶跃星辰(StepFun)/ 硅基流动 / xAI / 智谱 GLM(Z.ai 国内域)/ 腾讯云 TokenHub(Token Plan 余量)**:前六家用标准 Bearer API key,腾讯云用云 API 密钥对(TC3 签名)。其余厂商因无公开余额接口或需非 Bearer 鉴权(小米 MiMo 走控制台 Cookie、商汤走 AccessKey 签名、MiniMax/字节豆包走额度制或 AK/SK),暂显示「未配置」;扩展点在 `src/balance.ts`(按厂商余额 API 增加查询器)。
305
319
  - **中转站额度依赖上游私有 schema**:New API / Sub2API 的接口字段未公开,读不出时标「未读出额度」而非臆造金额;若某中转站响应字段不同,需按 `src/relay.ts` 的解析器扩展。未知路由表示该路由在当前 provider 配置与宿主 llm 注册表里都不存在(配置已删、日志比安装更早等),历史调用数据未丢,重新配置同名路由即可自动归位。未知路由桶的费用一律记 0(issue #82):支出主体无法核实,与未收录模型、订阅通道同姿态——token 照常统计,面板组头费用显示「—」并附说明。由独立插件经 `ctx.llm.registerAdapter` 注册的通道(如 CommandCode)不属于未知路由:插件从宿主 llm 注册表发现它们,按 `direct:<provider>` 桶以模型官方目录价计费(issue #91);注册表读取走 `ctx.get('llm')`(免 `inject` 声明),读不到/读到空集合时告警一次(面板数字不变,unknown 口径不变),避免这类失效无声无息。
306
320
  - **超支通知依赖浏览器 Notification**:权限被拒绝或平台不支持时只有界面红色脉冲兜底,没有宿主级通知通道;通知上限为每天一次。
307
- - **会话明细不可跳转**:点击会话行不会打开对应会话(跨插件导航需要宿主会话选择通道);面板默认只显示前 20 行,「查看全部」全屏浮层封顶 100 行。
321
+ - **会话行跳转依赖宿主通道**:面板里的会话标题点一下即可打开宿主对话(双代会话选择通道自动探测);宿主过旧、或会话已被删除 / 不在当前会话列表时,界面给出可读提示而不是静默无反应。面板默认只显示前 20 行,「查看全部」全屏浮层封顶 100 行。
308
322
  - **费用为目录价估算**:讯飞 / 商汤 / 小米等未公布按量单价的模型使用估算价(特性表脚注 ¹),正式定价以厂商账单为准。
309
323
  - **账本从首次成功聚合开始生效**:升级前已经永久删除且不在旧快照中的会话无法恢复;手动删除 `.dsh-usage-ledger.json` 及其 `.bak` 会清空独立保留的历史。账本只保留本插件已经成功观测过的调用。
310
324
  - **历史回放预热**:插件加载 3 秒后台自动全量折叠宿主全部历史会话日志(账本幂等,重复折叠不重复计数),首次打开面板即可看到完整历史统计,无需等一遍首次折叠。历史会话按「首次折叠时的模型单价」计价;厂商改价前的历史消耗不会按新价重算(价格目录无历史时点价,属估算口径)。