@gamegeek-saikel/dsh-cost-meter 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +116 -0
- package/README.zh-CN.md +116 -0
- package/cordis.patch.yml +12 -0
- package/lib/client.js +1481 -0
- package/lib/client.js.map +1 -0
- package/lib/index.js +2403 -0
- package/lib/invariant.js +38 -0
- package/lib/types/client/AssistantCostChip.d.ts +29 -0
- package/lib/types/client/AssistantCostChip.d.ts.map +1 -0
- package/lib/types/client/AssistantCostChip.js +75 -0
- package/lib/types/client/CostPluginCard.d.ts +10 -0
- package/lib/types/client/CostPluginCard.d.ts.map +1 -0
- package/lib/types/client/CostPluginCard.js +124 -0
- package/lib/types/client/CostView.d.ts +10 -0
- package/lib/types/client/CostView.d.ts.map +1 -0
- package/lib/types/client/CostView.js +66 -0
- package/lib/types/client/SessionCostLine.d.ts +21 -0
- package/lib/types/client/SessionCostLine.d.ts.map +1 -0
- package/lib/types/client/SessionCostLine.js +173 -0
- package/lib/types/client/SessionCostPill.d.ts +13 -0
- package/lib/types/client/SessionCostPill.d.ts.map +1 -0
- package/lib/types/client/SessionCostPill.js +123 -0
- package/lib/types/client/cost-math.d.ts +88 -0
- package/lib/types/client/cost-math.d.ts.map +1 -0
- package/lib/types/client/cost-math.js +199 -0
- package/lib/types/client/format.d.ts +35 -0
- package/lib/types/client/format.d.ts.map +1 -0
- package/lib/types/client/format.js +61 -0
- package/lib/types/client/index.d.ts +28 -0
- package/lib/types/client/index.d.ts.map +1 -0
- package/lib/types/client/index.js +59 -0
- package/lib/types/client/locales.d.ts +78 -0
- package/lib/types/client/locales.d.ts.map +1 -0
- package/lib/types/client/locales.js +149 -0
- package/lib/types/index.d.ts +136 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js +401 -0
- package/lib/types/invariant.d.ts +16 -0
- package/lib/types/invariant.d.ts.map +1 -0
- package/lib/types/invariant.js +38 -0
- package/lib/types/pricebook.d.ts +467 -0
- package/lib/types/pricebook.d.ts.map +1 -0
- package/lib/types/pricebook.js +696 -0
- package/lib/types/pricing.d.ts +93 -0
- package/lib/types/pricing.d.ts.map +1 -0
- package/lib/types/pricing.js +346 -0
- package/lib/types/session-cost-projection.d.ts +70 -0
- package/lib/types/session-cost-projection.d.ts.map +1 -0
- package/lib/types/session-cost-projection.js +198 -0
- package/lib/types/subagent-cost.d.ts +51 -0
- package/lib/types/subagent-cost.d.ts.map +1 -0
- package/lib/types/subagent-cost.js +79 -0
- package/lib/types/types.d.ts +334 -0
- package/lib/types/types.d.ts.map +1 -0
- package/lib/types/types.js +6 -0
- package/package.json +134 -0
- package/src/client/AssistantCostChip.module.css +81 -0
- package/src/client/AssistantCostChip.tsx +109 -0
- package/src/client/CostPluginCard.module.css +186 -0
- package/src/client/CostPluginCard.tsx +264 -0
- package/src/client/CostView.module.css +168 -0
- package/src/client/CostView.tsx +145 -0
- package/src/client/SessionCostLine.module.css +19 -0
- package/src/client/SessionCostLine.tsx +186 -0
- package/src/client/SessionCostPill.module.css +118 -0
- package/src/client/SessionCostPill.tsx +192 -0
- package/src/client/cost-math.ts +230 -0
- package/src/client/format.ts +63 -0
- package/src/client/index.ts +108 -0
- package/src/client/locales.ts +165 -0
- package/src/css-modules.d.ts +4 -0
- package/src/index.ts +489 -0
- package/src/invariant.ts +47 -0
- package/src/pricebook.ts +825 -0
- package/src/pricing.ts +378 -0
- package/src/session-cost-projection.ts +238 -0
- package/src/subagent-cost.ts +105 -0
- package/src/types.ts +364 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Saikel-Orado-Liu aka GameGeek-Saikel
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
<h1 align="center">DSH Cost Meter</h1>
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<strong>English</strong>
|
|
5
|
+
·
|
|
6
|
+
<a href="./README.zh-CN.md">简体中文</a>
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
**DSH Cost Meter** is a DeepSeek conversation cost-tracking plugin for the DeepSeek Harness (DSH) Web GUI — **price-snapshot-anchored per-turn cost** (peak/off-peak aware), **account balance**, a **cost view tab**, **per-message cost chips**, and a **header pill with live streaming estimates**. Every step's cost, price band, and snapshot version are computed *once* from the pricebook snapshot effective at the usage event's own time and then never recomputed — a later price change never rewrites an already-written conversation row.
|
|
10
|
+
|
|
11
|
+
- Host half (`src/`): DeepSeek `GET /user/balance` query, the persisted snapshot-anchored pricebook, the `sessionCost` projection, subagent cost aggregation, and the trust-fenced `/cost-meter` route.
|
|
12
|
+
- Client half (`src/client/`): composer-dock readout, Cost tab, per-reply chip, header pill, and the plugin configuration card — in Simplified Chinese and English.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
The plugin is published on npm as `@gamegeek-saikel/dsh-cost-meter` and ships as an official DSH plugin bundle (both halves — host and browser — are mounted by a single `cordis.patch.yml` row).
|
|
19
|
+
|
|
20
|
+
Install it into a web profile with the official DSH CLI (via npx — no global installation needed):
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npx @deepseek-ai/dsh plugin --profile web add @gamegeek-saikel/dsh-cost-meter
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Then start the harness:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npx @deepseek-ai/dsh web
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
If you have the DSH CLI installed globally, you can also use `dsh` instead of `npx @deepseek-ai/dsh`. To install into another profile, replace `web` with your profile name. The host half requires Node `^22.19.0 || >=24.0.0` and pnpm `11.7.0` for development.
|
|
33
|
+
|
|
34
|
+
## Overview
|
|
35
|
+
|
|
36
|
+
Chat costs in DeepSeek pricing change over time (list prices, USD→CNY exchange, and the upcoming 2026-08-17 peak/off-peak rollout), and a conversation spans many turns with cache-hit, cache-miss, cache-write, and output token buckets. Naively recomputing costs at *current* prices makes history drift every time the price table changes.
|
|
37
|
+
|
|
38
|
+
**Cost Meter** solves this with an **append-only pricebook**: every price/fx/band-table change starts a new immutable `PricebookSnapshot` (monotonic `version`, `effectiveAt`), and each usage event anchors to the snapshot effective at its own time. The result is an immutable per-step cost ledger that only grows — it never mutates. Live streaming estimates are explicitly labeled 估算/estimate because they use *current* prices; they are replaced by the exact anchored value once the step settles.
|
|
39
|
+
|
|
40
|
+
## Key Properties
|
|
41
|
+
|
|
42
|
+
| Property | Value |
|
|
43
|
+
|---|---|
|
|
44
|
+
| Cost anchoring | Append-only pricebook snapshots; step cost computed once at the event's own time |
|
|
45
|
+
| Price sources | Manual override > official pricing page > built-in fallback > OpenRouter (fallback only, USD→CNY) > none |
|
|
46
|
+
| Peak pricing | 2026-08-17 00:00 Beijing rollout; peak 09:00–12:00 / 14:00–18:00 Beijing, off-peak half price |
|
|
47
|
+
| Cost formula | Uncached input + cache reads (hit rate) + cache writes (billed at uncached input rate) + output, per 1M tokens, CNY |
|
|
48
|
+
| Account balance | Official `GET /user/balance`, cached 60 s, single in-flight request, trust-fenced route |
|
|
49
|
+
| Subagent support | BFS over the live agent tree; conversation totals = main session + descendants |
|
|
50
|
+
| UI surfaces | Composer dock · Cost tab · per-reply chip · header pill (live estimate) · settings card |
|
|
51
|
+
| Locale | Simplified Chinese (source) + English |
|
|
52
|
+
| Complexity | Fully synchronous fold; O(1) price lookups via in-memory mirror |
|
|
53
|
+
|
|
54
|
+
## Usage
|
|
55
|
+
|
|
56
|
+
Once installed, the plugin contributes five browser surfaces (all text shown in Simplified Chinese by default):
|
|
57
|
+
|
|
58
|
+
| Surface | Slot | Description |
|
|
59
|
+
|---|---|---|
|
|
60
|
+
| Composer dock readout | `conversation.composer.dock` | Anchored session spend + account balance, refreshed every minute; hover for the category breakdown and snapshot info |
|
|
61
|
+
| Cost view tab | `conversation.view` | Whole-conversation totals (main + subagents), category totals, per-subagent list, and the per-reply anchored ledger |
|
|
62
|
+
| Per-reply cost chip | `conversation.chat.assistant-actions` | The anchored cost of one finalized reply (dash `—` when unpriced) |
|
|
63
|
+
| Header pill | `conversation.session.header.utilities` | Anchored total, or a live `≈ ¥x.xx (estimate)` while streaming; click for the detail panel |
|
|
64
|
+
| Plugin card | `settings.plugin.item` | Per-model overrides, OpenRouter aliases, cache-read discount, FX mode, toggles, and manual refresh |
|
|
65
|
+
|
|
66
|
+
The `/cost-meter` host route serves the balance snapshot, the pricebook view, and the subagent totals over GET, and applies manual refresh over POST (`{"action":"refresh"}`). Like the `/api` fence, the route only answers requests whose `Host` header names a loopback address or a declared trusted host — the DNS-rebinding-safe check.
|
|
67
|
+
|
|
68
|
+
## Pricebook & Snapshot Anchoring
|
|
69
|
+
|
|
70
|
+
The pricebook (`src/pricebook.ts`) is the durable price source, persisted on the `pricebook` storage-domain global slot:
|
|
71
|
+
|
|
72
|
+
- **Priority chain** — per canonical model key (`provider/model`, bare model, or the `flash`/`pro` pricing key for DeepSeek-family models): manual override > official page > built-in fallback > OpenRouter (fallback only, USD→CNY, cache reads at the configured discount) > none.
|
|
73
|
+
- **Snapshot selection** — `snapshotForTime` picks the newest snapshot with `effectiveAt <= event time` (pre-install sessions anchor to the first snapshot once).
|
|
74
|
+
- **Peak/off-peak** — before the 2026-08-17 rollout all steps price at the single list price; after it, the band is chosen by Beijing time (peak 09:00–12:00 / 14:00–18:00, everything else off-peak).
|
|
75
|
+
- **Immutable ledger** — the `sessionCost` projection (`src/session-cost-projection.ts`) folds `request/header` (model) and usage-carrying events into per-step rows; a second usage sample for the same (turn, step) replaces the first (same-step finalization, not a re-price), with O(1) incremental totals.
|
|
76
|
+
|
|
77
|
+
## Project Structure
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
src/
|
|
81
|
+
index.ts # Host entry: apply() wiring, balance, route, trust fence
|
|
82
|
+
types.ts # Wire/public vocabulary + projection-map merge
|
|
83
|
+
pricing.ts # Official pricing-page parser, peak pricing, Beijing bands
|
|
84
|
+
pricebook.ts # Append-only snapshots, priority chain, storage domain
|
|
85
|
+
session-cost-projection.ts # sessionCost projection (immutable per-step ledger)
|
|
86
|
+
subagent-cost.ts # BFS subagent cost aggregation
|
|
87
|
+
invariant.ts # Route-disposer symmetry invariant companion
|
|
88
|
+
client/ # Browser half: 5 slot components + math/format/locales
|
|
89
|
+
shared/
|
|
90
|
+
tsdown.client.ts # Shared tsdown preset (CSS Modules, module table, purity gate)
|
|
91
|
+
web-platform.ts # Browser platform module list
|
|
92
|
+
tests/ # Hermetic vitest suites (network stubbed)
|
|
93
|
+
cordis.patch.yml # Web-profile plugin row (mounts both halves)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Development
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
pnpm install
|
|
100
|
+
pnpm typecheck # tsc -b (src only)
|
|
101
|
+
pnpm test # vitest run (hermetic, network stubbed)
|
|
102
|
+
pnpm build # tsc -b && tsdown (lib/ + lib/client.js)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
The test suites are fully offline: pricing-page HTML, OpenRouter models, and the FX endpoint are all stubbed. Tests cover the trust fence, balance parsing, the pricebook priority chain and snapshot selection, the immutable ledger fold (including same-step replacement and peak/off-peak band selection at the *event* time), subagent BFS aggregation, and the client surfaces (jsdom).
|
|
106
|
+
|
|
107
|
+
## Documentation
|
|
108
|
+
|
|
109
|
+
- [`src/pricing.ts`](src/pricing.ts), [`src/pricebook.ts`](src/pricebook.ts), [`src/session-cost-projection.ts`](src/session-cost-projection.ts) — detailed module docs on parsing, anchoring, and the ledger contract
|
|
110
|
+
- [`README.zh-CN.md`](README.zh-CN.md) — 简体中文版本
|
|
111
|
+
|
|
112
|
+
## License
|
|
113
|
+
|
|
114
|
+
This repository (source, tests, README, and the DSH plugin bundle shape) is licensed under the **MIT License** — see [`LICENSE`](LICENSE).
|
|
115
|
+
|
|
116
|
+
Copyright (c) 2026 Saikel-Orado-Liu aka GameGeek-Saikel
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
<h1 align="center">DSH Cost Meter(对话花费计量)</h1>
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<a href="./README.md">English</a>
|
|
5
|
+
·
|
|
6
|
+
<strong>简体中文</strong>
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
**DSH Cost Meter** 是为 DeepSeek Harness(DSH)Web GUI 打造的对话成本追踪插件——**价格快照锚定**的逐轮成本(感知**峰值/闲时**)、**账户余额**、**花费标签页**、**每条回复成本小标签**,以及带**流式实时估算**的**头部胶囊**。每一步的成本、价格档位与快照版本都**只计算一次**——锚定到该用量事件自身时刻生效的价格快照,此后永不重算——因此后续价格变动绝不会改写已写入的对话记录。
|
|
10
|
+
|
|
11
|
+
- Host 半区(`src/`):DeepSeek `GET /user/balance` 余额查询、持久化的快照锚定价格簿、`sessionCost` 投影、子代理成本聚合,以及带信任围栏的 `/cost-meter` 路由。
|
|
12
|
+
- Client 半区(`src/client/`):输入框下方读数、花费标签页、每条回复成本小标签、头部胶囊,以及插件配置卡——内置简体中文与英文。
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 安装
|
|
17
|
+
|
|
18
|
+
本插件已发布到 npm:`@gamegeek-saikel/dsh-cost-meter`,以官方 DSH 插件 bundle 形态交付(单个 `cordis.patch.yml` 行同时挂载 host 与浏览器两半)。
|
|
19
|
+
|
|
20
|
+
通过官方 DSH CLI(npx 方式,无需全局安装)装入 web profile:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npx @deepseek-ai/dsh plugin --profile web add @gamegeek-saikel/dsh-cost-meter
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
然后启动:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npx @deepseek-ai/dsh web
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
如果已全局安装 DSH CLI,也可以使用 `dsh` 代替 `npx @deepseek-ai/dsh`。安装到其他 profile 时,把 `web` 替换成你的 profile 名称即可。开发环境要求 Node `^22.19.0 || >=24.0.0` 与 pnpm `11.7.0`。
|
|
33
|
+
|
|
34
|
+
## 概述
|
|
35
|
+
|
|
36
|
+
DeepSeek 的价格随时间变化(官方价目表、USD→CNY 汇率、以及 2026-08-17 上线的峰值/闲时分时计价),而一次对话跨越很多轮,且每轮都含缓存命中、缓存未命中、缓存写入与输出等 token 桶。若按"当前价格"重算成本,每次价目变动都会让历史记录漂移。
|
|
37
|
+
|
|
38
|
+
**Cost Meter** 用**只追加的价格簿**解决这一问题:每次价格/汇率/分时表变化都会开启一个新的不可变 `PricebookSnapshot`(单调 `version`、`effectiveAt`),每个用量事件锚定到其自身时刻生效的快照。结果是一个**只增长、永不改写**的不可变逐步成本账本。流式实时估算明确标注为"估算"——因为它使用*当前*价格;一旦该步结算,即被精确的锚定值取代。
|
|
39
|
+
|
|
40
|
+
## 关键性质
|
|
41
|
+
|
|
42
|
+
| 性质 | 值 |
|
|
43
|
+
|---|---|
|
|
44
|
+
| 成本锚定 | 只追加价格簿快照;步成本在事件自身时刻只计算一次 |
|
|
45
|
+
| 价格来源 | 手动覆盖 > 官方价格页 > 内置回退 > OpenRouter(仅回退,USD→CNY)> 无 |
|
|
46
|
+
| 峰值定价 | 2026-08-17 00:00 北京生效;高峰 09:00–12:00 / 14:00–18:00(北京),闲时为半价 |
|
|
47
|
+
| 成本公式 | 未命中输入 + 缓存命中(命中价)+ 缓存写入(按未命中输入价计)+ 输出,每百万 tokens,CNY |
|
|
48
|
+
| 账户余额 | 官方 `GET /user/balance`,缓存 60 秒,单飞请求,路由带信任围栏 |
|
|
49
|
+
| 子代理支持 | 沿活跃代理树 BFS;对话总花费 = 主会话 + 全部后代 |
|
|
50
|
+
| UI 表面 | 输入框读数 · 花费标签页 · 回复小标签 · 头部胶囊(实时估算)· 设置卡 |
|
|
51
|
+
| 本地化 | 简体中文(键源)+ 英文 |
|
|
52
|
+
| 复杂度 | 全同步折叠;经内存镜像 O(1) 查价 |
|
|
53
|
+
|
|
54
|
+
## 用法
|
|
55
|
+
|
|
56
|
+
安装后,插件贡献五个浏览器表面(默认显示简体中文文案):
|
|
57
|
+
|
|
58
|
+
| 表面 | 插槽 | 说明 |
|
|
59
|
+
|---|---|---|
|
|
60
|
+
| 输入框下方读数 | `conversation.composer.dock` | 锚定的本会话花费 + 账户余额,每分钟刷新;悬停查看分类明细与快照信息 |
|
|
61
|
+
| 花费标签页 | `conversation.view` | 全对话总花费(主会话 + 子代理)、分类小计、子代理列表与逐回复锚定账本 |
|
|
62
|
+
| 每条回复成本小标签 | `conversation.chat.assistant-actions` | 单条已定稿回复的锚定成本(无价格时显示 `—`) |
|
|
63
|
+
| 头部胶囊 | `conversation.session.header.utilities` | 锚定总花费;流式中显示 `预计 ¥x.xx(估算)`;点击展开详情面板 |
|
|
64
|
+
| 插件配置卡 | `settings.plugin.item` | 按模型覆盖价、OpenRouter 别名、缓存折扣、汇率模式、开关与立即刷新 |
|
|
65
|
+
|
|
66
|
+
`/cost-meter` 宿主路由通过 GET 提供余额快照、价格簿视图与子代理合计;通过 POST(`{"action":"refresh"}`)执行手动刷新。与 `/api` 围栏一致,路由只应答 `Host` 头为回环地址或已声明可信主机的请求——这是防 DNS 重绑定的安全校验。
|
|
67
|
+
|
|
68
|
+
## 价格簿与快照锚定
|
|
69
|
+
|
|
70
|
+
价格簿(`src/pricebook.ts`)是持久的定价源,持久化在 `pricebook` 存储域全局槽上:
|
|
71
|
+
|
|
72
|
+
- **优先级链**——按规范模型键(`provider/model`、裸模型名,或 DeepSeek 系模型的 `flash`/`pro` 定价键):手动覆盖 > 官方页面 > 内置回退 > OpenRouter(仅回退,USD→CNY,缓存读按配置折扣)> 无。
|
|
73
|
+
- **快照选取**——`snapshotForTime` 取 `effectiveAt <= 事件时间` 的最新快照(安装前的会话一次性锚到首个快照)。
|
|
74
|
+
- **峰值/闲时**——2026-08-17 上线前所有步按单一价目计费;上线后按北京时间选档(高峰 09:00–12:00 / 14:00–18:00,其余闲时)。
|
|
75
|
+
- **不可变账本**——`sessionCost` 投影(`src/session-cost-projection.ts`)把 `request/header`(模型)与携带用量的事件折叠为逐步记录;同一 (turn, step) 的第二次用量样本**替换**第一条(同一步终结,而非重新计价),总计以 O(1) 增量维护。
|
|
76
|
+
|
|
77
|
+
## 项目结构
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
src/
|
|
81
|
+
index.ts # Host 入口:apply() 装配、余额、路由、信任围栏
|
|
82
|
+
types.ts # wire/公共类型 + 投影映射合并
|
|
83
|
+
pricing.ts # 官方价格页解析、峰值定价、北京时段
|
|
84
|
+
pricebook.ts # 只追加快照、优先级链、存储域
|
|
85
|
+
session-cost-projection.ts # sessionCost 投影(不可变逐步账本)
|
|
86
|
+
subagent-cost.ts # BFS 子代理成本聚合
|
|
87
|
+
invariant.ts # 路由释放对称性 invariant 伴生插件
|
|
88
|
+
client/ # 浏览器半区:5 个插槽组件 + 数学/格式化/本地化
|
|
89
|
+
shared/
|
|
90
|
+
tsdown.client.ts # 共享 tsdown 预设(CSS Modules、模块表、纯度门)
|
|
91
|
+
web-platform.ts # 浏览器平台模块清单
|
|
92
|
+
tests/ # 封闭式 vitest 套件(网络全部 stub)
|
|
93
|
+
cordis.patch.yml # web profile 插件行(同时挂载两半)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## 开发
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
pnpm install
|
|
100
|
+
pnpm typecheck # tsc -b(仅 src)
|
|
101
|
+
pnpm test # vitest run(封闭式,网络 stub)
|
|
102
|
+
pnpm build # tsc -b && tsdown(lib/ + lib/client.js)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
测试套件完全离线:价格页 HTML、OpenRouter 模型目录与汇率接口全部 stub。覆盖:信任围栏、余额解析、价格簿优先级链与快照选取、不可变账本折叠(含同一步替换与按*事件时间*选峰值/闲时档)、子代理 BFS 聚合,以及客户端表面(jsdom)。
|
|
106
|
+
|
|
107
|
+
## 文档
|
|
108
|
+
|
|
109
|
+
- [`src/pricing.ts`](src/pricing.ts)、[`src/pricebook.ts`](src/pricebook.ts)、[`src/session-cost-projection.ts`](src/session-cost-projection.ts)——解析、锚定与账本契约的详细模块注释
|
|
110
|
+
- [`README.md`](README.md) — English version
|
|
111
|
+
|
|
112
|
+
## 许可证
|
|
113
|
+
|
|
114
|
+
本仓库(源码、测试、README 与 DSH 插件 bundle 形态)以 **MIT License** 授权——见 [`LICENSE`](LICENSE)。
|
|
115
|
+
|
|
116
|
+
Copyright (c) 2026 Saikel-Orado-Liu aka GameGeek-Saikel
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# @gamegeek-saikel/dsh-cost-meter bundle patch: inserts its plugin row into the
|
|
2
|
+
# web profile roster. The bundle is the official dsh plugin shape — install it
|
|
3
|
+
# with `dsh plugin --profile web add <path-or-git-url-or-npm-name>`.
|
|
4
|
+
#
|
|
5
|
+
# The single row mounts BOTH halves: the host side (DeepSeek Get User Balance
|
|
6
|
+
# query + pricebook domain + sessionCost projection + the /cost-meter
|
|
7
|
+
# route) and the browser side (cost tab, per-message chips, header pill,
|
|
8
|
+
# composer readout and the settings card, via the dsh.client declaration in
|
|
9
|
+
# package.json).
|
|
10
|
+
- insert:
|
|
11
|
+
- id: cost-meter
|
|
12
|
+
name: '@gamegeek-saikel/dsh-cost-meter'
|