@kenz1117/dsh-ui-usage-billing 1.8.3-alpha.2 → 1.8.3-alpha.21
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 +30 -12
- package/README.md +52 -23
- package/lib/client.js +5 -5
- package/lib/index.js +2566 -407
- package/lib/types/aggregate.d.ts +46 -14
- package/lib/types/balance.d.ts +23 -2
- package/lib/types/builtin-catalog.d.ts +5 -0
- package/lib/types/client/PeakScheduleEditor.d.ts +9 -0
- package/lib/types/client/TaskQueuePanel.d.ts +5 -1
- package/lib/types/client/TokenPanel.d.ts +2 -0
- package/lib/types/client/UsageBilling.d.ts +2 -0
- package/lib/types/client/UsageBillingMainPanel.d.ts +7 -0
- package/lib/types/client/UsageBillingPanelIcon.d.ts +5 -0
- package/lib/types/client/api/balance.d.ts +1 -1
- package/lib/types/client/api/task-queue.d.ts +4 -0
- package/lib/types/client/api/usage-stats.d.ts +16 -2
- package/lib/types/client/constants.d.ts +9 -0
- package/lib/types/client/domain/channel-visibility.d.ts +68 -0
- package/lib/types/client/domain/floating-model.d.ts +31 -0
- package/lib/types/client/domain/types.d.ts +37 -1
- package/lib/types/client/footer-lane.d.ts +114 -0
- package/lib/types/client/live-cost.d.ts +10 -3
- package/lib/types/client/locales.d.ts +2 -1
- package/lib/types/client/panel-capability.d.ts +12 -0
- package/lib/types/client/peak-alert.d.ts +2 -1
- package/lib/types/client/peak-schedule-locales.d.ts +48 -0
- package/lib/types/client/price-drafts.d.ts +19 -0
- package/lib/types/client/price-picker.d.ts +17 -0
- package/lib/types/client/pricing.d.ts +22 -12
- package/lib/types/client/provider-display.d.ts +0 -2
- package/lib/types/client/queue-eligibility.d.ts +45 -0
- package/lib/types/client/round-chart.d.ts +5 -1
- package/lib/types/client/scheduled-band.d.ts +23 -0
- package/lib/types/client/task-queue-quick.d.ts +1 -1
- package/lib/types/client/usage-billing-settings.d.ts +62 -9
- package/lib/types/client/usage-command.d.ts +10 -5
- package/lib/types/config.d.ts +2 -0
- package/lib/types/guard.d.ts +30 -3
- package/lib/types/peak-ledger.d.ts +21 -0
- package/lib/types/peak-schedule-history.d.ts +7 -0
- package/lib/types/peak-schedule-models.d.ts +21 -0
- package/lib/types/peak-schedule-store.d.ts +10 -0
- package/lib/types/peak-schedule.d.ts +67 -0
- package/lib/types/pricing-shared.d.ts +81 -1
- package/lib/types/reconcile.d.ts +11 -2
- package/lib/types/routes/balance.d.ts +6 -3
- package/lib/types/routes/peak-schedule.d.ts +12 -0
- package/lib/types/routes/pricing-models.d.ts +11 -0
- package/lib/types/task-queue-band.d.ts +80 -0
- package/lib/types/task-queue-shared.d.ts +57 -0
- package/lib/types/task-queue.d.ts +110 -3
- package/package.json +75 -64
package/README.en.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<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>
|
|
8
8
|
<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>
|
|
9
9
|
<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>
|
|
10
|
-
<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.
|
|
10
|
+
<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.2--rc.5-blue"></a>
|
|
11
11
|
<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>
|
|
12
12
|
</p>
|
|
13
13
|
|
|
@@ -61,8 +61,9 @@ Most billing plugins stop at "token count × unit price". dsh-ui-usage-billing t
|
|
|
61
61
|
|
|
62
62
|
### Sidebar and live feedback
|
|
63
63
|
|
|
64
|
-
- **Trigger card**: today / week / month headline, 7-day trend and daily gauge; choose a full card, compact icon or hidden entry, with a quick look on hover.
|
|
64
|
+
- **Trigger card**: today / week / month headline, 7-day trend and daily gauge; choose a full card, compact icon or hidden entry, with a quick look on hover. The hover card ranks pay-as-you-go and subscription models over the selected period, which defaults to today (previously fixed to the current month). Metered models rank by dashboard cost, including custom prices. Subscription models rank by call count. Multiple channels or usage of unknown origin leave the wallet balance unconfirmed. If only one subscription channel can be identified, the card shows its quota and flags any remaining usage of unknown origin.
|
|
65
65
|
- **Cost bar and alerts**: live turn / Session cost, model-aware peak and quota warnings, plus optional system notifications for tier switches and Session completion.
|
|
66
|
+
- **Shortcut**: bind "Open usage billing dashboard" in the host's Settings → Shortcuts — `⌘⇧D` by default (`Ctrl+Shift+D` on Windows / Linux), rebindable or clearable — so the dashboard stays one keystroke away even with the sidebar entry hidden.
|
|
66
67
|
|
|
67
68
|

|
|
68
69
|
|
|
@@ -75,17 +76,27 @@ Overview / Queue / Billing / Usage / Trends / Agents / Rates / Settings. The her
|
|
|
75
76
|
<details>
|
|
76
77
|
<summary><strong>Queue, agent and settings details</strong></summary>
|
|
77
78
|
|
|
78
|
-
- **Queue**: price-band countdown and queued / running / needs-review / completed tasks; up to 50 JSON items per batch, validated atomically. Locks and leases prevent duplicate submission across instances sharing one `DSH_HOME`.
|
|
79
|
+
- **Queue**: price-band countdown and queued / running / needs-review / completed tasks; up to 50 JSON items per batch, validated atomically. Locks and leases prevent duplicate submission across instances sharing one `DSH_HOME`. With “Continue tasks in the source Session” enabled, a task queued from a Session continues inside that Session at the next off-peak window (keeping its context and workspace grouping); the card shows “Will continue in Session X” **before** the run and links to it. A deleted, busy or archived source falls back to a new Session with the reason on the card. New Sessions land in their workspace instead of being orphaned in the sidebar.
|
|
79
80
|
- **Agents**: a parent conversation → sub-agent tree with own cost and chain total including every descendant.
|
|
80
81
|
- **Settings**: full-text search, global and per-model budgets, peak alerts, custom prices, native host settings and plugin information; a hidden sidebar entry can be restored from host Settings.
|
|
81
82
|
|
|
82
83
|
</details>
|
|
83
84
|
|
|
85
|
+
### Independent peak schedules
|
|
86
|
+
|
|
87
|
+
In Settings, choose a configured source and DeepSeek time-priced model. Set peak windows, a fixed UTC offset, weekend treatment or off-peak dates. The start of a window is inclusive and its end is exclusive. Empty windows mean all-day off-peak. Both relays and official sources inherit the 09:00–12:00 and 14:00–18:00 weekday windows in UTC+8 with weekends off-peak. Only official sources inherit the built-in holiday calendar. DeepSeek Account and its aliases keep native pricing even on an origin shared with an API key. The task queue uses the official calendar.
|
|
88
|
+
|
|
89
|
+
Changes and clears apply from the effective time shown in the editor. Replay looks up the revision active at each call. A batch save reports each rule separately and keeps rejected drafts for retry. New revisions identify the local API as their source. The caller's identity is unknown. Only consecutive identical settings for a key can be compacted. Reversions and clears keep their historical intervals.
|
|
90
|
+
|
|
91
|
+
When a session log is gone, billed amounts are preserved. For newly catalogued models, the ledger weights each source's own tokens at two Beijing-time probes (10:00 and 20:00 within the ledger's local day), looking up each probe's schedule revision independently. New records distinguish API-key, protected-account and exempt usage. Older records use an override only where historical routing data rules out shared account traffic. A missing source breakdown uses the native estimate. Known subscriptions, unknown channels and inseparable subscription mixtures incur no backfill charge. The daily blend remains an estimate.
|
|
92
|
+
|
|
93
|
+
Settings are stored in `DSH_HOME/.dsh-usage-peak-schedule.json`, configurable via `peakSchedulePath`. Untimed legacy rules do not affect billing. Invalid revisions or rules are skipped individually. On replacement, the original legacy or damaged file is preserved alongside the settings as `.recovery-<SHA-256>`. The `.bak` file holds the previous saved contents and can be restored while the plugin is stopped.
|
|
94
|
+
|
|
84
95
|
## 💰 Billing engine
|
|
85
96
|
|
|
86
97
|
- **Channel attribution**: official, direct, relay and unknown routes stay separate; route and model aliases repair historical attribution.
|
|
87
98
|
- **Time-based pricing**: live models.dev data, 247 built-in models across 25 vendors, segmented peak pricing and live FX; later changes never rewrite history.
|
|
88
|
-
- **Real-cost overrides**: set relay-specific prices for the same model and fill gaps for uncatalogued models.
|
|
99
|
+
- **Real-cost overrides**: set relay-specific prices for the same model and fill gaps for uncatalogued models. For each day and model, an existing site grid (even an empty one) leaves unattributed usage and mixed paid/subscription buckets at the host cost. A missing grid uses the model default or, if absent, the sole source price. The dashboard labels these source estimates because the source is unknown. The picker includes configured, used and catalog models. Save applies complete, unique rows and keeps the last saved price for rows with invalid drafts. Enter `0` explicitly for a free rate.
|
|
89
100
|
- **Budget controls**: global and per-model budgets, 50 / 80 / 100% alerts, balance warnings and last-40-turn spike attribution.
|
|
90
101
|
|
|
91
102
|

|
|
@@ -93,7 +104,9 @@ Overview / Queue / Billing / Usage / Trends / Agents / Rates / Settings. The her
|
|
|
93
104
|
## 🔌 Subscriptions & balance
|
|
94
105
|
|
|
95
106
|
- **Subscription quotas**: detect Kimi, Z.ai, OpenCode Go, MiniMax, Claude, CommandCode and more, with remaining quota and reset times; subscription-channel model cost is 0.
|
|
96
|
-
- **Official balances
|
|
107
|
+
- **Official balances** cover DeepSeek, Kimi, StepFun, SiliconFlow, xAI, Zhipu GLM and Tencent Cloud TokenHub. The dashboard estimates days remaining from the last seven days of spending for single-currency balances.
|
|
108
|
+
- **DeepSeek wallets** appear on separate rows. The Platform wallet uses the API key. The sign-in wallet requires the optional `deepseekAccount` host service and the UI’s host version, language and time zone. If the service or metadata is missing (for example, the host omits its optional `release` field), the sign-in row explains why. The sign-in integration has been tested with a simulated service; host `0.2.3-alpha.3` now provides that service — a signed-out account shows the reason on that row instead of 0. Reading the balance of a really signed-in account is still pending on-device verification.
|
|
109
|
+
- **DeepSeek reconciliation** compares the CNY Platform wallet’s balance change with spending attributable to that wallet since the same baseline. When both wallets are active, the plugin can still reconcile traffic to the official API site if the API-key route owns that site exclusively and there are no ambiguous direct calls. A source change, an unavailable wallet or ambiguous spending resets the baseline.
|
|
97
110
|
- **Relays and reconciliation**: merge keys by site, read New API / Sub2API rolling quotas, and cross-check custom endpoints or official balance deltas against the ledger.
|
|
98
111
|
|
|
99
112
|

|
|
@@ -118,12 +131,12 @@ Overview / Queue / Billing / Usage / Trends / Agents / Rates / Settings. The her
|
|
|
118
131
|
|
|
119
132
|
## 🚀 Quick start
|
|
120
133
|
|
|
121
|
-
One codebase currently supports DSH `0.1.2-alpha.1` through `0.2.
|
|
134
|
+
One codebase currently supports DSH `0.1.2-alpha.1` through `0.2.3-alpha.3`. Stable and preview releases share the same compatibility matrix: stable releases use npm `latest`, while previews use `alpha`. npm `latest` currently points to stable `1.8.14` (everything in `1.8.13`, the verified `1.8.3-alpha.19` preview, and PR #151 — write endpoints behind a reverse proxy with `trustedHosts` no longer return 403); `alpha` remains at `1.8.3-alpha.19`, whose content is covered by this stable release, and the next preview starts at `1.8.3-alpha.20`.
|
|
122
135
|
|
|
123
136
|
`dsh plugin add` requires an explicit `--profile`. Pinning an exact version is recommended so a package manager's release cooldown cannot resolve a different version. Install the current stable release with:
|
|
124
137
|
|
|
125
138
|
```sh
|
|
126
|
-
dsh plugin --profile web add npm:@kenz1117/dsh-ui-usage-billing@1.8.
|
|
139
|
+
dsh plugin --profile web add npm:@kenz1117/dsh-ui-usage-billing@1.8.14
|
|
127
140
|
```
|
|
128
141
|
|
|
129
142
|
Default installations can also use `@latest`. Check the host with `dsh --version` or `npm ls -g @deepseek-ai/dsh`.
|
|
@@ -175,7 +188,7 @@ Browser Server (Node)
|
|
|
175
188
|
|
|
176
189
|
## 💡 Billing details
|
|
177
190
|
|
|
178
|
-
The rate table (`src/client/pricing.ts`) stores each model in its **native currency**: domestic providers enter CNY directly, overseas providers enter USD. Cost is computed and displayed in CNY uniformly — USD models convert via the **live rate**, domestic models never pass through a rate. At startup the server fetches the live rate and model prices (`src/pricing-fetch.ts`): USD→CNY prefers the Tencent Finance quote (keyless, reachable in China), falling back to open.er-api then the built-in default; it then refreshes every 6 hours, and the rate-table modal shows a "today's rate" marker plus live / built-in badge. The **display currency follows the user**: switching ¥ / $ converts each per-1M-token unit price via `convertUnitPrice` at the live rate (falling back to the native currency when the rate is unavailable).
|
|
191
|
+
The rate table (`src/client/pricing.ts`) stores each model in its **native currency**: domestic providers enter CNY directly, overseas providers enter USD. Cost is computed and displayed in CNY uniformly — USD models convert via the **live rate**, domestic models never pass through a rate. At startup the server fetches the live rate and model prices (`src/pricing-fetch.ts`): USD→CNY prefers the Tencent Finance quote (keyless, reachable in China), falling back to open.er-api, then the keyless AllRatesToday endpoint (ECB reference rates, [Exchange rates by AllRatesToday](https://allratestoday.com)), then the built-in default; it then refreshes every 6 hours, and the rate-table modal shows a "today's rate" marker plus live / built-in badge. The **display currency follows the user**: switching ¥ / $ converts each per-1M-token unit price via `convertUnitPrice` at the live rate (falling back to the native currency when the rate is unavailable).
|
|
179
192
|
|
|
180
193
|
```
|
|
181
194
|
cost (CNY) = (missInput × p_input + cacheHit × p_cacheHit + output × p_output) / 10⁶
|
|
@@ -225,6 +238,8 @@ To add a model: append an entry to `BUILTIN_MODEL_CATALOG` in `src/builtin-catal
|
|
|
225
238
|
|
|
226
239
|
## 🔌 HTTP API
|
|
227
240
|
|
|
241
|
+
`GET /api/billing/peak-schedule` returns available source/model pairs, current rules, the latest revision's effective time and notices. `POST /api/billing/peak-schedule` accepts `{ "version": 3, "changes": { … } }`. Each key is a JSON-stringified source/model pair. Its value is a rule or `null` to clear it. The response includes `results` with `accepted`, `invalidRule` or `unavailableModel` per key. A malformed envelope returns 400 and a clock conflict returns 409. Both methods require a local request.
|
|
242
|
+
|
|
228
243
|
The public HTTP endpoints and field definitions are documented in source, including usage, pricing, balances, subscriptions, relay quotas, `GET/POST /api/billing/task-queue` and `GET /api/billing/task-queue-summary` (see `src/index.ts`, `src/aggregate.ts`, `src/relay.ts`, `src/routes/task-queue.ts`). The queue returns host capability, workspaces, official models and durable tasks; mutations are `enqueue` / `enqueueMany`, remove-not-started and clear-finished. The summary returns only the price-band state and queued count, never Prompts. All endpoints accept loopback requests only; queue writes additionally require a loopback Origin, JSON Content-Type and a body no larger than 10 MiB.
|
|
229
244
|
|
|
230
245
|
## ⚙️ Configuration
|
|
@@ -261,7 +276,7 @@ For on-machine debugging: `dsh plugin --profile web add "link:<absolute path to
|
|
|
261
276
|
|
|
262
277
|
## 📦 Release
|
|
263
278
|
|
|
264
|
-
This standalone npm package maintains one `main` codebase. Stable releases use non-prerelease versions and npm `latest`; previews use prerelease versions and npm `alpha`. npm `latest` currently points to
|
|
279
|
+
This standalone npm package maintains one `main` codebase. Stable releases use non-prerelease versions and npm `latest`; previews use prerelease versions and npm `alpha`. npm `latest` currently points to stable `1.8.14`, while `alpha` remains at `1.8.3-alpha.19`; see [COMPATIBILITY.md](COMPATIBILITY.md).
|
|
265
280
|
|
|
266
281
|
```sh
|
|
267
282
|
pnpm test && pnpm run build # full tests + build before release
|
|
@@ -276,7 +291,7 @@ The host discovers the browser side automatically via the `dsh.client` declarati
|
|
|
276
291
|
|
|
277
292
|
- **Permission level: high**: reads durable Session logs, calls vendor / subscription / balance / pricing APIs, reads `apiKeyEnv` through the credentials seam, and writes the ledger, snapshots and task queue under the harness home. The plugin itself has **no** command-execution / shell capability; only explicit enqueueing creates a host Session and submits a Prompt, while Agent tools remain governed by the host's existing permissions and approvals.
|
|
278
293
|
- **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.
|
|
279
|
-
- **Compatibility**: stable and preview releases from the current `main` share one matrix covering DSH `0.1.2-alpha.1` through `0.2.
|
|
294
|
+
- **Compatibility**: stable and preview releases from the current `main` share one matrix covering DSH `0.1.2-alpha.1` through `0.2.3-alpha.3`, with 41 per-version declarations. The current stable release is `1.8.14` (npm `latest`; `1.8.13`, the verified `1.8.3-alpha.19` preview, and PR #151 — write endpoints behind a reverse proxy with `trustedHosts` no longer return 403); the preview channel remains `1.8.3-alpha.19` (npm `alpha`), whose content is covered by this stable release. Release channels and monitoring are documented in [COMPATIBILITY.md](COMPATIBILITY.md). Node.js `^22.19.0 || >=24.0.0`.
|
|
280
295
|
- **Lifecycle**: no `preinstall` / `install` / `postinstall` / `prepare` (ready on install).
|
|
281
296
|
- **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/*`.
|
|
282
297
|
- **Build artifacts**: runtime files `lib/*` and `cordis.patch.yml` are committed at the pinned commit and declared in `files`.
|
|
@@ -292,11 +307,12 @@ After the user explicitly enables that setting, exactly **one** read-only tool i
|
|
|
292
307
|
| --- | --- | --- |
|
|
293
308
|
| `usage_stats` | `range`: `today` / `month` / `session` / `all` / `bySite` / `relay` | Queries the usage and estimated cost this plugin already aggregated (CNY, estimated from the official price catalog — not a bill); `session` requires an agent session context |
|
|
294
309
|
|
|
295
|
-
Boundaries: the tool reads only this plugin's own aggregates — never Session bodies or Prompts — and never writes back to the log or touches Session KV cache. The plugin injects no system prompt. The off-peak queue is not a model tool: it is a separate, explicitly authorized action whose Prompt becomes a user message in a new Session, so it must not be confused with this read-only tool boundary. The tool consumes context on every request, which is why it stays off by default.
|
|
310
|
+
Boundaries: the tool reads only this plugin's own aggregates — never Session bodies or Prompts — and never writes back to the log or touches Session KV cache. The plugin injects no system prompt. The off-peak queue is not a model tool: it is a separate, explicitly authorized action whose Prompt becomes a user message in a host Session (its own new Session by default, or the source Session when “Continue tasks in the source Session” is on), so it must not be confused with this read-only tool boundary. The tool consumes context on every request, which is why it stays off by default.
|
|
296
311
|
|
|
297
312
|
## ⚠️ Known Limitations and Deferred Work
|
|
298
313
|
|
|
299
|
-
- **The off-peak queue is still a preview**: it accepts only time-of-day models on the host's built-in `deepseek-official` route; relays and custom routes are excluded. There is no automatic pause, cancellation or retry. After host shutdown, a dropped result stream or lease expiry, the task becomes "Needs review"; open its Session and decide manually whether to enqueue a new task.
|
|
314
|
+
- **The off-peak queue is still a preview**: it accepts only time-of-day models on the host's built-in `deepseek-official` route; relays and custom routes are excluded. There is no automatic pause, cancellation or retry. With source-Session reuse on, the task keeps the source Session's **current** model (the plugin never switches it — that would change your global default model) and only continues there while the Session is idle; otherwise it falls back to a new Session with the reason recorded. After host shutdown, a dropped result stream or lease expiry, the task becomes "Needs review"; open its Session and decide manually whether to enqueue a new task.
|
|
315
|
+
- **An empty candidate list is explained by cause (issue #143)**: the dashboard queue tab and the composer entry share one verdict — "the host has no built-in official route (`deepseek-official`)", "the official route exposes no time-of-day model", "the host registered no workspace", and "the current Session model is not an official time-of-day model" each get their own next step; nothing collapses into a generic "model unsupported". The host's built-in sign-in route (`deepseek-account`) is not a queue candidate either: it is billed at the official time-of-day price, but enqueuing means spending the sign-in wallet unattended.
|
|
300
316
|
- **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).
|
|
301
317
|
- **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.
|
|
302
318
|
- **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.
|
|
@@ -327,6 +343,8 @@ Boundaries: the tool reads only this plugin's own aggregates — never Session b
|
|
|
327
343
|
- [@yuxu4468-hash](https://github.com/yuxu4468-hash) — cataloging for bare relay-exposed model ids: Grok 4.5/4.6, GPT-5.5, GPT-6.1 Sol, Claude Opus 4.7/4.8 and Fable 5 (PR #87), plus the GPT image models `gpt-image-2` / `gpt-image-2.5-sunburst` (PR #88)
|
|
328
344
|
- [@JinruiWang](https://github.com/JinruiWang) — workbuddy adapter channel pricing and the fold-before-live-catalog dual-caliber fix: the known-channel list, three lazy-reprice gates (ledger, cache hit, incremental cursor) and the stable-stamp reproduction test (issue #90)
|
|
329
345
|
- [@gitfangj](https://github.com/gitfangj) — `sync.sh` brace-variable compatibility under the macOS default bash 3.2
|
|
346
|
+
- [@Calorios](https://github.com/Calorios) — per-source peak/valley schedules, pricing-picker candidates and source prices, attributable floating-card balances, the sign-in wallet row and sticky settings navigation (PR #134 ~ #138), plus the settings-navigation surface and scroll-container fixes (PR #142)
|
|
347
|
+
- [@python-rust](https://github.com/python-rust) — the cascade fix for the dashboard modal being narrowed by the host Modal's default styles (issue #146, PR #147)
|
|
330
348
|
|
|
331
349
|
</details>
|
|
332
350
|
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<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>
|
|
8
8
|
<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>
|
|
9
9
|
<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>
|
|
10
|
-
<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.
|
|
10
|
+
<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.2--rc.5-blue"></a>
|
|
11
11
|
<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>
|
|
12
12
|
</p>
|
|
13
13
|
|
|
@@ -61,8 +61,10 @@
|
|
|
61
61
|
|
|
62
62
|
### 侧栏与即时反馈
|
|
63
63
|
|
|
64
|
-
- **触发卡**:今日 / 本周 / 本月主数字、近 7
|
|
64
|
+
- **触发卡**:今日 / 本周 / 本月主数字、近 7 天趋势与当日水位;支持完整卡片、紧凑图标、完全隐藏,悬停可看速览。速览中的按量模型与订阅模型跟随触发卡的统计范围,默认看今天(此前固定看本月)。按量模型按仪表盘显示的费用排名,包含自定义单价;订阅模型按调用数排名。多个通道或部分用量来源不明时,卡片不推测余额。若只能确认一个订阅通道,会显示该通道的额度,并标注仍有用量来源不明。
|
|
65
|
+
- **与其它插件共存**:侧栏底部入口被多个插件同时占用时,触发卡自动收成 36×36 图标钮(不占满整行、不挤走邻居),悬停仍出速览、点击照常打开仪表盘;邻居卸载后自动还原成完整卡片。
|
|
65
66
|
- **费用条与提醒**:常驻本轮 / 会话费用,按当前模型显示峰谷和订阅额度预警;切档与会话完成可发系统通知。
|
|
67
|
+
- **快捷键**:宿主「设置 → 快捷键」可绑定「打开用量计费仪表盘」,默认 `⌘⇧D`(Windows / Linux `Ctrl+Shift+D`),可改绑或清空;侧栏隐藏后也能一键打开面板。
|
|
66
68
|
|
|
67
69
|

|
|
68
70
|
|
|
@@ -75,12 +77,22 @@
|
|
|
75
77
|
<details>
|
|
76
78
|
<summary><strong>队列、智能体与设置细节</strong></summary>
|
|
77
79
|
|
|
78
|
-
- **队列**:显示峰谷倒计时和待执行 / 执行中 / 需核对 / 已完成任务;JSON 单批最多 50 条,任一无效则整批不写入。文件锁与租约避免同一 `DSH_HOME`
|
|
80
|
+
- **队列**:显示峰谷倒计时和待执行 / 执行中 / 需核对 / 已完成任务;JSON 单批最多 50 条,任一无效则整批不写入。文件锁与租约避免同一 `DSH_HOME` 多实例重复提交。开启设置里的「任务在来源会话继续」后,从会话入队的任务到点优先在该会话内续跑(保留上下文与工作区分组),卡片上会**事前**显示「计划在会话 X 继续」并可一键跳转;来源会话已删除 / 正在使用 / 已归档时回退为新建会话,卡片注明原因。新建的会话落在其所属工作区下,不再是侧栏里没有分组的孤立会话。
|
|
79
81
|
- **智能体**:按委派关系还原父对话 → 子智能体树,每行同时给出自身费用与包含全部后代的链合计。
|
|
80
82
|
- **设置**:全文搜索、全局与按模型预算、峰谷提醒、自定义单价、原生设置页和插件信息卡;侧栏隐藏后可从宿主设置恢复。
|
|
81
83
|
|
|
82
84
|
</details>
|
|
83
85
|
|
|
86
|
+
### 独立峰谷时段
|
|
87
|
+
|
|
88
|
+
在「设置」中选一个已配置的来源与 DeepSeek 分时价模型,填写高峰窗口、固定 UTC 偏移、周末和指定低谷日期后保存。窗口开始分钟计入高峰,结束分钟不计入;空窗口表示全天低谷。规则只修改该来源与模型的判档,不修改模型单价或官方历史调价节点。没有规则时保留原有计价;DeepSeek 账号通道及其别名始终走原规则,即使与 API Key 共用站点也是如此。低谷任务队列仍按官方时段调度。
|
|
89
|
+
|
|
90
|
+
中转与官方来源均继承 09:00–12:00、14:00–18:00 的工作日峰窗,周末全天低谷,默认时区 UTC+8。只有官方来源自动继承内置节假日。每个更改或清除自面板显示的生效时间起作用,历史日志按调用时刻查修订。批量保存会逐条返回结果,修正失败的草稿即可重试。新修订记录本机 API 来源,调用者身份未知。持久化只合并同一键连续重复的设置,保留改动、恢复和清除的历史区间。
|
|
91
|
+
|
|
92
|
+
仅剩账本时,已计费用原样保留。新收录模型按各来源的实际 token 桶,在账本自然日内取北京时间 10:00 和 20:00 两个探针,分别使用探针时刻生效的规则,再按既定比例混合估价。新账本区分 API Key、账号和豁免用量;旧账本只有在历史路由信息能排除账号共用时才套用该来源规则。缺少来源明细的部分沿用内置估价;已知订阅或未知通道,以及无法拆分的订阅混合桶,不补收费用。日级估价仍有别于逐请求实算。
|
|
93
|
+
|
|
94
|
+
配置默认保存在 `DSH_HOME/.dsh-usage-peak-schedule.json`,可用 `peakSchedulePath` 指定其他位置。没有生效时间的旧版规则不参与计价。损坏的修订或规则会单独跳过,其他有效历史保留。首次替换旧版或损坏文件时,原始字节保存在同目录 `.recovery-<SHA-256>` 文件中。`.bak` 文件保留上一次保存内容,可停用插件后从备份恢复。
|
|
95
|
+
|
|
84
96
|
## 💰 计费引擎
|
|
85
97
|
|
|
86
98
|
- **按通道归账**:官方、直连、中转与未知路由分开统计;路由别名和模型别名可修复历史归属。
|
|
@@ -93,7 +105,7 @@
|
|
|
93
105
|
## 🔌 订阅与余额
|
|
94
106
|
|
|
95
107
|
- **订阅额度**:自动识别 Kimi、Z.ai、OpenCode Go、MiniMax、Claude、CommandCode 等通道,展示剩余额度与重置时间;订阅模型费用记 0。
|
|
96
|
-
- **官方余额**:覆盖 DeepSeek、Kimi、阶跃星辰、硅基流动、xAI、智谱 GLM、腾讯云 TokenHub,并按近 7 天消耗估算可用天数。
|
|
108
|
+
- **官方余额**:覆盖 DeepSeek、Kimi、阶跃星辰、硅基流动、xAI、智谱 GLM、腾讯云 TokenHub,并按近 7 天消耗估算可用天数。DeepSeek 开放平台余额通过 API Key 查询。登录钱包是可选服务适配:仅当宿主注入 `deepseekAccount` 且界面提供版本、语言与时区时才查询,与 API Key 钱包分别展示。宿主启动信息可省略 `release`;缺少元数据或服务时会显示原因。此路径经桩服务验证;宿主 `0.2.3-alpha.3` 已提供该服务——未登录时该行显示「未登录」而不是 0,真实登录账号的余额读取仍待实机验收。余额差对账仅比较同一开放平台人民币钱包、同一基准之后可归属的费用;同时登录时,仅当官方 API 站点由该路由独占且没有无法区分的直连费用时才对账。来源切换、钱包不可用或费用混合无法分辨时重置基准。
|
|
97
109
|
- **中转与对账**:同站多 key 合并,识别 New API / Sub2API 滚动额度;自定义端点与官方余额差可和本地账本交叉验证。
|
|
98
110
|
|
|
99
111
|

|
|
@@ -118,12 +130,12 @@
|
|
|
118
130
|
|
|
119
131
|
## 🚀 快速开始
|
|
120
132
|
|
|
121
|
-
当前维护 DSH `0.1.2-alpha.1` ~ `0.2.
|
|
133
|
+
当前维护 DSH `0.1.2-alpha.1` ~ `0.2.3-alpha.3` 的一份代码。正式版与预览版共享同一兼容矩阵:正式版使用 npm `latest`,预览版使用 `alpha`。当前 `latest` 指向 `1.8.14` 正式版(= `1.8.13` + 已验收的 `1.8.3-alpha.19` + PR #151 反代写操作 403 修复);`alpha` 仍指向 `1.8.3-alpha.19`(其内容已由本正式版覆盖),下一轮预览从 `1.8.3-alpha.20` 起。
|
|
122
134
|
|
|
123
135
|
`dsh plugin add` 需要显式 `--profile`,且建议钉具体版本号,避免包管理器的发布冷静期解析到其他版本。当前正式版安装命令:
|
|
124
136
|
|
|
125
137
|
```sh
|
|
126
|
-
dsh plugin --profile web add npm:@kenz1117/dsh-ui-usage-billing@1.8.
|
|
138
|
+
dsh plugin --profile web add npm:@kenz1117/dsh-ui-usage-billing@1.8.14
|
|
127
139
|
```
|
|
128
140
|
|
|
129
141
|
默认安装也可使用 `@latest`。可用 `dsh --version` 或 `npm ls -g @deepseek-ai/dsh` 确认宿主版本。
|
|
@@ -179,44 +191,54 @@ GitHub Pages 发布。
|
|
|
179
191
|
|
|
180
192
|
## 💡 计费细节
|
|
181
193
|
|
|
182
|
-
单价表(`src/client/pricing.ts`)采用**原生币种**存储:国内厂商直接录入人民币价格,国外厂商录入美元价格。费用统一以人民币计算与展示——美元模型按**实时汇率**折算,国内模型全程不经过汇率换算。启动时服务端拉取实时汇率与模型价(`src/pricing-fetch.ts`):USD→CNY 优先腾讯财经行情(免 key、国内可达),失败依次降级 open.er-api
|
|
194
|
+
单价表(`src/client/pricing.ts`)采用**原生币种**存储:国内厂商直接录入人民币价格,国外厂商录入美元价格。费用统一以人民币计算与展示——美元模型按**实时汇率**折算,国内模型全程不经过汇率换算。启动时服务端拉取实时汇率与模型价(`src/pricing-fetch.ts`):USD→CNY 优先腾讯财经行情(免 key、国内可达),失败依次降级 open.er-api、AllRatesToday 免 key 端点(ECB 参考汇率,[Exchange rates by AllRatesToday](https://allratestoday.com))与内置默认值;之后每 6 小时后台刷新,单价表弹窗标注「今日汇率」与实时 / 内置徽标。金额与费率表的**展示币种跟随用户所选**:切 ¥ / $ 时把每条每百万 token 单价经 `convertUnitPrice` 按实时汇率换算到目标币种再显示(汇率缺失时回退原生币种)。
|
|
183
195
|
|
|
184
196
|
```
|
|
185
|
-
cost(CNY)= (missInput × p_input + cacheHit × p_cacheHit + output × p_output) / 10⁶
|
|
197
|
+
cost(CNY)= (missInput × p_input + cacheWrite × p_cacheWrite + cacheHit × p_cacheHit + output × p_output) / 10⁶
|
|
186
198
|
—— 价格为原生币种;美元模型按实时 USD → CNY 汇率折算
|
|
187
199
|
```
|
|
188
200
|
|
|
189
201
|
统计中的 `input` 为总输入(cacheHit + cacheMiss),估算按命中 / 未命中分拆计价,避免重复计费。支持双档计费的模型按 `DEFAULT_PEAK_SHARE`(默认 0.5)混合高峰与低谷档;周末(北京时间周六 / 周日)全天按低谷价计费。
|
|
190
202
|
|
|
203
|
+
**缓存写入独立计价(issue #123)**:厂商上报的「写入缓存」token(`cacheWriteTokens`)是未命中输入的子集,厂商对它**单独收费**时按其单价计——OpenAI / Anthropic 恒为输入价的 125%(models.dev 原生 `cache_write`),百炼按官方「显式缓存创建」价。插件把这部分从普通输入价里拆出来单列计价,厂商不单列缓存写入费时(DeepSeek、月之暗面等)仍按输入价计——与旧口径一致。目录里的缓存写入单价只从有据来源派生:厂商加价规则 + 条目内官方价,不凭空取值。
|
|
204
|
+
|
|
205
|
+
**上下文压缩调用计入统计(issue #123)**:DSH 触发上下文压缩时会产生一次真实的模型调用(厂商照常计费),宿主把它落成 `compaction/summary` 事件(自带 provider / model / usage)。插件此前只统计对话主循环的 `assistant/message`,压缩调用整段漏计(报告者实测 222 次 ≈ $25.33)。现在压缩调用与普通调用同一口径计入:调用数、输入 / 输出 / 缓存 token、费用,以及模型 / 日期 / 通道 / 峰谷各维度。
|
|
206
|
+
|
|
191
207
|
**联网搜索请求按次估算**(issue #15):DSH 的联网搜索绕过对话通道直连官方 `api.deepseek.com`,会话日志只记请求、无用量事件,而开放平台照常计费。插件对这类 `web/deepseek-search-llm-request` 事件按次估值计入费用(默认 0.02 元/次,配置 `searchCallEstimateCny` 可调整;设 0 关闭),并单独累计 `searchCalls` 供面板提示估算口径。
|
|
192
208
|
|
|
193
209
|
**「本月预计」的口径**:本月已发生 + 近 7 个自然日节奏 × 本月剩余天数。只外推还没发生的天数,近期没花钱就不虚增——早期版本拿「本月有记录的天数」当分母求日均再乘整月天数,稀疏使用的月份会被放大数倍(实测 4 天记录、其余 19 天没用的月份被外推成实际值的 4 倍)。
|
|
194
210
|
|
|
195
|
-
**自定义单价(设置 Tab,issue #16)**:结构化条目表(模型 + 可选来源 + 输入/缓存命中/输出 + 币种),不再手编 JSON。来源(中转站域名)留空 = 该模型默认价;填入中转站域名(如 `https://api.my-relay.com`)= 仅该来源的同名模型用此价(同名模型可同时存在默认价与多个来源价,互不覆盖)。显示层按「模型 ×
|
|
211
|
+
**自定义单价(设置 Tab,issue #16)**:结构化条目表(模型 + 可选来源 + 输入/缓存命中/输出 + 币种),不再手编 JSON。来源(中转站域名)留空 = 该模型默认价;填入中转站域名(如 `https://api.my-relay.com`)= 仅该来源的同名模型用此价(同名模型可同时存在默认价与多个来源价,互不覆盖)。显示层按「模型 × 来源」精确匹配重算,已归属的用量没有对应来源价时回落该模型默认价。按日期和模型逐格判断:已有站点格(包括空格)时,未归属的剩余用量与无法拆分订阅 token 的混合格保留宿主计价。该格缺少站点信息时优先用模型默认价,否则仅在该模型恰有一个来源价时使用其估算费用。仪表盘会标注按唯一来源价估算的模型,因为实际来源无法验证。下拉可选已配置、已用和目录模型。保存时逐行校验,完整且无重复的行可保存,草稿有误的行沿用上次保存的价格。免费价请显式输入 `0`。
|
|
212
|
+
|
|
213
|
+
**未收录模型的补价入口(issue #125)**:概览顶部的「N 个模型未收录计价」提示条现在**直接列出未收录的模型 id**,并带「去补价」按钮(跳到设置页的自定义单价分区);这些 id 同时进入自定义单价的候选列表(下拉直接选),不必回会话日志手抄——中转站的 id 常带路由前缀与全角冒号,抄错就是「自定义价没效果」。
|
|
214
|
+
|
|
215
|
+
**通道可见性(设置 Tab,issue #126)**:通道多起来后(官方、直连、几个中转、未知路由)账单列表很长,可在设置里逐个通道勾选「显示」。隐藏的通道**不参与统计口径**——账单分组少掉该通道,概览累计、趋势与用量随之联动扣除。口径两条:只扣**可归属**的用量,旧格式会话(无通道维度)的用量宁可多算也不静默丢数;会话 / 工具 / 角色等没有通道维度的指标仍为全量。偏好存浏览器本地(`dsh.ui-usage-billing.channels`),按通道桶 key 记录(显示名随语言变,桶 key 稳定)。
|
|
196
216
|
|
|
197
|
-
|
|
217
|
+
**用量行的提供方标注(issue #126)**:用量分区的模型排行在模型名下标出该模型走过的通道与 token 占比(如「直连 · zai-coding-cn · 100%」)——同名模型经不同通道(官方 / 直连 / 中转)时据此区分,不再只看到一行合并数字。
|
|
198
218
|
|
|
199
|
-
|
|
219
|
+
### 支持模型(2026-11 主流阵容,OpenAI 兼容系列,共 262 款)
|
|
220
|
+
|
|
221
|
+
完整目录见费率 Tab 及源码 `src/builtin-catalog.ts` 的 `BUILTIN_MODEL_CATALOG`(261 款在售 + 1 款退役型号保留历史回算),此处每厂商仅列代表型号。
|
|
200
222
|
|
|
201
223
|
| 厂商 | 代表模型 |
|
|
202
224
|
| -------- | -------------------------------------------- |
|
|
203
225
|
| DeepSeek | V4.1 Flash、V4 Pro(等 3 款;按官方变更节点分段计价:基础价 → 峰谷 v1 → 周末全谷) |
|
|
204
|
-
| 智谱 AI | GLM-5.3、GLM-5.2(等
|
|
205
|
-
| 阿里通义 | Qwen3.8 Max
|
|
226
|
+
| 智谱 AI | GLM-5.3、GLM-5.2(等 18 款) |
|
|
227
|
+
| 阿里通义 | Qwen4 Max、Qwen3.8 Max(等 28 款) |
|
|
206
228
|
| 字节豆包 | Doubao Seed-2.1 Pro、Doubao Seed-2.0 Pro(等 13 款) |
|
|
207
229
|
| 月之暗面 | Kimi K3.1 Pro、Kimi K3.1 Pro Highspeed、Kimi K3、Kimi K2.7 Code(等 18 款) |
|
|
208
230
|
| 小米 | MiMo V2.6 Pro(等 6 款) |
|
|
209
231
|
| MiniMax | MiniMax-M3、MiniMax-M2.7(等 8 款) |
|
|
210
232
|
| 云知声 | U2 Flash、Unisound U2(等 3 款) |
|
|
211
233
|
| 百度文心 | ERNIE-5.1、ERNIE-4.5 300B(等 2 款) |
|
|
212
|
-
| 腾讯混元 | 混元 Hy4(限时 5 折)、混元 Hy4 Preview、混元 Hy3(等
|
|
213
|
-
| Anthropic | Claude
|
|
234
|
+
| 腾讯混元 | 混元 Hy4(限时 5 折)、混元 Hy4 Preview、混元 Hy3(等 10 款) |
|
|
235
|
+
| Anthropic | Claude Fable 5.2、Claude Opus 5(等 15 款) |
|
|
214
236
|
| Mistral AI | Mistral Large 3、Mistral Small 4(等 30 款) |
|
|
215
237
|
| Cohere | Command A、Command R(等 7 款) |
|
|
216
|
-
| OpenAI | GPT-6 Astra、GPT-
|
|
217
|
-
| Google | Gemini
|
|
238
|
+
| OpenAI | GPT-6.2 Sol / Astra、GPT-6 Astra(等 45 款) |
|
|
239
|
+
| Google | Gemini 4 Neon、Gemini 3.1 Pro(等 28 款) |
|
|
218
240
|
| xAI | Grok 4.7、Grok 4.20(等 8 款) |
|
|
219
|
-
| Meta | Llama 4 Maverick、Muse
|
|
241
|
+
| Meta | Llama 4 Maverick、Muse Ember 1.0(等 9 款) |
|
|
220
242
|
| 美团 | LongCat 2.0(估算价) |
|
|
221
243
|
| 面壁智能 | MiniCPM-V 4.5(估算价) |
|
|
222
244
|
| 小红书 | Dots3-Note Preview(估算价) |
|
|
@@ -231,9 +253,13 @@ cost(CNY)= (missInput × p_input + cacheHit × p_cacheHit + output × p_outp
|
|
|
231
253
|
|
|
232
254
|
新增模型:在 `src/builtin-catalog.ts` 的 `BUILTIN_MODEL_CATALOG` 追加条目(别名表 `BUILTIN_MODEL_KEY_ALIASES` 同文件维护;目录只随 node 半构建,经 `/api/billing/pricing` 由宿主下发注入客户端)。**价源口径**:海外厂商取 models.dev 实时目录原生 USD;国内厂商优先取官方 CN 价(models.dev 的 `-cn` 目录),该目录缺项时按 USD 价 × 汇率折算并在条目注释标注。存量条目的价格更正走独立的调价节点,不与扩容混在一起。
|
|
233
255
|
|
|
256
|
+
**模型 id 归一口径**:日志里的真实 model id 先按别名表精确匹配,再做归一化匹配(忽略大小写 / 分隔符 / 括号附注),最后由「派生候选」兜底 —— 剥组织前缀(`deepseek/deepseek-v4.1-flash`)、剥冒号分段(中转站的线路前缀 `cn:` / `us:`、网关的变体后缀 `:free` / `:1017`,全角「:」等价)、剥尾部日期段(`-202605` / `-0731`)。派生只用于**找到同一模型的另一种写法**:剥完仍不命中目录就保持原样(回退「其他模型」,费用记 0),绝不按别的模型的价格记账。
|
|
257
|
+
|
|
234
258
|
## 🔌 HTTP API
|
|
235
259
|
|
|
236
|
-
|
|
260
|
+
`GET /api/billing/peak-schedule` 返回可选来源/模型、当前规则、最近修订生效时间和读取提示。`POST /api/billing/peak-schedule` 接收 `{ "version": 3, "changes": { … } }`(键为来源/模型 JSON 数组字符串,值为规则或表示清除的 `null`)。响应的 `results` 逐键返回 `accepted`、`invalidRule` 或 `unavailableModel`。请求整体格式错误返回 400,宿主时钟冲突返回 409。端点限本机访问。
|
|
261
|
+
|
|
262
|
+
对外 HTTP 接口与字段定义详见源码:`GET /api/billing/pricing`、`/api/billing/balance`、`/api/billing/usage-stats`、`/api/billing/subscriptions`、`/api/billing/relay-quotas`、`GET/POST /api/billing/task-queue`、`GET /api/billing/task-queue-summary` 等(见 `src/index.ts`、`src/aggregate.ts`、`src/relay.ts`、`src/routes/task-queue.ts`)。其中 `usage-stats` 返回的 `bySite` 字段为按中转站归组后的用量分布,`relay-quotas` 返回额度与路由诊断;`task-queue` 返回能力、工作区、官方模型、候选为空的根因(`blockedReason`)和持久任务快照,写操作为 `enqueue` / `enqueueMany`、移除未启动任务与清理已结束历史;`task-queue-summary` 只返回峰谷状态与待执行数量,不返回 Prompt。全部端点仅接受回环请求;队列写操作另校验回环 Origin、JSON Content-Type 与 10 MiB body 上限。
|
|
237
263
|
|
|
238
264
|
## ⚙️ 配置
|
|
239
265
|
|
|
@@ -269,7 +295,7 @@ pnpm run build # tsc -b && tsdown,产出 lib/index.js 与 lib/client.js
|
|
|
269
295
|
|
|
270
296
|
## 📦 发布
|
|
271
297
|
|
|
272
|
-
本包为独立 npm 包,只维护一份 `main` 代码。正式版使用非预发布版本号并切 `latest`,预览版使用预发布版本号并切 `alpha`;当前 `latest` 指向 `1.8.
|
|
298
|
+
本包为独立 npm 包,只维护一份 `main` 代码。正式版使用非预发布版本号并切 `latest`,预览版使用预发布版本号并切 `alpha`;当前 `latest` 指向 `1.8.14` 正式版,`alpha` 仍指向 `1.8.3-alpha.19`,详见 [COMPATIBILITY.md](COMPATIBILITY.md)。
|
|
273
299
|
|
|
274
300
|
```sh
|
|
275
301
|
pnpm test && pnpm run build # 发版前全量测试 + 构建
|
|
@@ -284,7 +310,7 @@ npm dist-tag add @kenz1117/dsh-ui-usage-billing@<版本> latest # 正式版
|
|
|
284
310
|
|
|
285
311
|
- **权限等级:high**:读取持久会话日志(文件)、访问多厂商官方 / 订阅 / 余额 / 定价 API(网络)、经凭据 seam 读取 `apiKeyEnv`(凭据)、写入 harness home 下的账本、快照与任务队列(持久状态)。插件自身**不含**命令执行 / Shell;仅用户显式入队时才经宿主创建会话并提交 Prompt,Agent 的工具调用仍由宿主原有权限与审批控制。
|
|
286
312
|
- **更新通道:`user-reviewed`**:本插件具备文件 / 网络 / 凭据能力,DSH STORE 采用每次安装需本机人工确认的通道;安装前请复核仓库、固定 Commit、生命周期脚本与影响范围。
|
|
287
|
-
- **兼容范围**:当前 `main` 的正式版与预览版共享同一兼容矩阵,适配 DSH `0.1.2-alpha.1` ~ `0.2.
|
|
313
|
+
- **兼容范围**:当前 `main` 的正式版与预览版共享同一兼容矩阵,适配 DSH `0.1.2-alpha.1` ~ `0.2.3-alpha.3`,共 41 项逐版本声明。当前正式版为 `1.8.14`(npm `latest`,= `1.8.13` + 已验收的 `1.8.3-alpha.19` + PR #151 反代写操作 403 修复),预览通道仍为 `1.8.3-alpha.19`(npm `alpha`,其内容已由本正式版覆盖)。发行通道与监控机制见 [COMPATIBILITY.md](COMPATIBILITY.md)。Node.js `^22.19.0 || >=24.0.0`。
|
|
288
314
|
- **生命周期**:无 `preinstall` / `install` / `postinstall` / `prepare`(安装即用)。
|
|
289
315
|
- **不冒用官方**:仅新增自有 entry id `ui-usage-billing`;对 `@deepseek-ai/dsh-*` 仅为 `peerDependencies` 依赖(不重复安装 / 不替换 / 不遮蔽官方组件),包名使用第三方命名空间 `@kenz1117/*`。
|
|
290
316
|
- **打包产物**:运行文件 `lib/*` 与 `cordis.patch.yml` 已随固定 Commit 提交并声明在 `files`。
|
|
@@ -300,11 +326,12 @@ npm dist-tag add @kenz1117/dsh-ui-usage-billing@<版本> latest # 正式版
|
|
|
300
326
|
| --- | --- | --- |
|
|
301
327
|
| `usage_stats` | `range`:`today` / `month` / `session` / `all` / `bySite` / `relay` | 查询本插件已聚合的用量与估算费用(人民币,按官方目录价估算,非账单);`session` 需处于 agent 会话上下文 |
|
|
302
328
|
|
|
303
|
-
边界声明:该工具只读本插件自己的聚合结果,**不读会话正文、不读提示词、不写回会话日志**,也不触及会话 KV 缓存;插件不注入系统提示。低谷队列不是模型工具,而是用户显式授权的独立路径:入队 Prompt
|
|
329
|
+
边界声明:该工具只读本插件自己的聚合结果,**不读会话正文、不读提示词、不写回会话日志**,也不触及会话 KV 缓存;插件不注入系统提示。低谷队列不是模型工具,而是用户显式授权的独立路径:入队 Prompt 会作为用户消息写入宿主会话(默认写入任务自己的新会话;开启「任务在来源会话继续」后写入入队时的那个会话),不能与前述只读工具边界混为一谈。工具会占用每次请求的上下文,因此保持默认关闭。
|
|
304
330
|
|
|
305
331
|
## ⚠️ Known Limitations and Deferred Work
|
|
306
332
|
|
|
307
|
-
- **低谷队列仍是预览能力**:只接受宿主内置 `deepseek-official`
|
|
333
|
+
- **低谷队列仍是预览能力**:只接受宿主内置 `deepseek-official` 路由中具有官方峰谷价的模型,中转站和自定义路由一律排除;不提供自动暂停、取消或失败重试。开启「任务在来源会话继续」后,任务沿用来源会话**当时的模型**(不为它切换模型——那会改动你的全局默认模型),且只在来源会话空闲时续跑;不可用时一律回退为新建会话并注明原因。宿主停止、结果流中断或租约失效后,任务只标记「需核对」,用户应打开对应 Session 确认实际结果后手动决定是否重新入队。
|
|
334
|
+
- **候选为空时按根因分层提示(issue #143)**:面板与会话入队入口共用同一份判定——「宿主没有内置官方通道(`deepseek-official`)」「官方通道里没有带峰谷价的模型」「宿主没有登记工作区」「当前会话模型不是官方峰谷模型(订阅 / 中转通道没有官方峰谷价)」分别给出各自的下一步动作,不再笼统说「模型不支持」。宿主内置的登录账号通道(`deepseek-account`)同样不在候选内:它在账单里按官方分时价计入,但入队等于无人值守地用登录钱包付费,候选范围暂不放开。
|
|
308
335
|
- **余额查询已接入 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 增加查询器)。
|
|
309
336
|
- **中转站额度依赖上游私有 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 口径不变),避免这类失效无声无息。
|
|
310
337
|
- **超支通知依赖浏览器 Notification**:权限被拒绝或平台不支持时只有界面红色脉冲兜底,没有宿主级通知通道;通知上限为每天一次。
|
|
@@ -336,6 +363,8 @@ npm dist-tag add @kenz1117/dsh-ui-usage-billing@<版本> latest # 正式版
|
|
|
336
363
|
- [@yuxu4468-hash](https://github.com/yuxu4468-hash) — 中转站裸模型 id 计费补录:Grok 4.5/4.6、GPT-5.5、GPT-6.1 Sol、Claude Opus 4.7/4.8、Fable 5(PR #87),GPT 绘图模型 `gpt-image-2` / `gpt-image-2.5-sunburst`(PR #88)
|
|
337
364
|
- [@JinruiWang](https://github.com/JinruiWang) — workbuddy adapter 通道计价与「折叠早于实时价目表」双口径修复:已知通道名单、惰性补折三门(账本 / cache 命中 / 增量游标)与 stable-stamp 复现测试(issue #90)
|
|
338
365
|
- [@gitfangj](https://github.com/gitfangj) — `sync.sh` 在 macOS 缺省 bash 3.2 下的花括号变量兼容修复
|
|
366
|
+
- [@Calorios](https://github.com/Calorios) — 独立峰谷时段、补价候选与来源价、悬浮卡余额归属、登录钱包与设置页吸顶导航(PR #134 ~ #138),设置导航的面板底色与滚动容器修正(PR #142)
|
|
367
|
+
- [@python-rust](https://github.com/python-rust) — 仪表盘弹窗被宿主 Modal 默认样式压窄的层叠修复(issue #146、PR #147)
|
|
339
368
|
|
|
340
369
|
</details>
|
|
341
370
|
|