@rayadesu/dsh-billing 0.1.0-rc.9 → 0.2.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.
Files changed (115) hide show
  1. package/AGENTS.md +1 -1
  2. package/LICENSE +21 -21
  3. package/README.i18n.yaml +2 -2
  4. package/README.md +13 -10
  5. package/README.zh.md +9 -7
  6. package/package.json +8 -9
  7. package/packages/llm-billing/README.i18n.yaml +0 -6
  8. package/packages/llm-billing/README.md +0 -44
  9. package/packages/llm-billing/README.zh.md +0 -44
  10. package/packages/llm-billing/lib/index.js +0 -562
  11. package/packages/llm-billing/lib/invariant.js +0 -23
  12. package/packages/llm-billing/lib/tsconfig.tsbuildinfo +0 -1
  13. package/packages/llm-billing/lib/typert.host.d.ts +0 -3
  14. package/packages/llm-billing/lib/typert.host.js +0 -114
  15. package/packages/llm-billing/lib/typert.remote-client.d.ts +0 -27
  16. package/packages/llm-billing/lib/typert.remote-client.d.ts.map +0 -1
  17. package/packages/llm-billing/lib/typert.remote-client.js +0 -108
  18. package/packages/llm-billing/lib/types/balance.d.ts +0 -71
  19. package/packages/llm-billing/lib/types/balance.d.ts.map +0 -1
  20. package/packages/llm-billing/lib/types/balance.js +0 -187
  21. package/packages/llm-billing/lib/types/balance.js.map +0 -1
  22. package/packages/llm-billing/lib/types/billing.d.ts +0 -106
  23. package/packages/llm-billing/lib/types/billing.d.ts.map +0 -1
  24. package/packages/llm-billing/lib/types/billing.js +0 -163
  25. package/packages/llm-billing/lib/types/billing.js.map +0 -1
  26. package/packages/llm-billing/lib/types/index.d.ts +0 -49
  27. package/packages/llm-billing/lib/types/index.d.ts.map +0 -1
  28. package/packages/llm-billing/lib/types/index.js +0 -155
  29. package/packages/llm-billing/lib/types/index.js.map +0 -1
  30. package/packages/llm-billing/lib/types/invariant.d.ts +0 -16
  31. package/packages/llm-billing/lib/types/invariant.d.ts.map +0 -1
  32. package/packages/llm-billing/lib/types/invariant.js +0 -22
  33. package/packages/llm-billing/lib/types/invariant.js.map +0 -1
  34. package/packages/llm-billing/lib/types/types/balance.d.ts +0 -71
  35. package/packages/llm-billing/lib/types/types/balance.d.ts.map +0 -1
  36. package/packages/llm-billing/lib/types/types/balance.js +0 -187
  37. package/packages/llm-billing/lib/types/types/balance.js.map +0 -1
  38. package/packages/llm-billing/lib/types/types/billing.d.ts +0 -106
  39. package/packages/llm-billing/lib/types/types/billing.d.ts.map +0 -1
  40. package/packages/llm-billing/lib/types/types/billing.js +0 -170
  41. package/packages/llm-billing/lib/types/types/billing.js.map +0 -1
  42. package/packages/llm-billing/lib/types/types/index.d.ts +0 -49
  43. package/packages/llm-billing/lib/types/types/index.d.ts.map +0 -1
  44. package/packages/llm-billing/lib/types/types/index.js +0 -156
  45. package/packages/llm-billing/lib/types/types/index.js.map +0 -1
  46. package/packages/llm-billing/lib/types/types/invariant.d.ts +0 -16
  47. package/packages/llm-billing/lib/types/types/invariant.d.ts.map +0 -1
  48. package/packages/llm-billing/lib/types/types/invariant.js +0 -22
  49. package/packages/llm-billing/lib/types/types/invariant.js.map +0 -1
  50. package/packages/llm-billing/lib/types/types/types.d.ts +0 -63
  51. package/packages/llm-billing/lib/types/types/types.d.ts.map +0 -1
  52. package/packages/llm-billing/lib/types/types/types.js +0 -7
  53. package/packages/llm-billing/lib/types/types/types.js.map +0 -1
  54. package/packages/llm-billing/lib/types/types.d.ts +0 -63
  55. package/packages/llm-billing/lib/types/types.d.ts.map +0 -1
  56. package/packages/llm-billing/lib/types/types.js +0 -7
  57. package/packages/llm-billing/lib/types/types.js.map +0 -1
  58. package/packages/llm-billing/node_modules/.bin/cordis +0 -43
  59. package/packages/llm-billing/node_modules/.bin/cordis.CMD +0 -12
  60. package/packages/llm-billing/node_modules/.bin/cordis.ps1 +0 -41
  61. package/packages/llm-billing/package.json +0 -75
  62. package/packages/llm-billing/src/balance.ts +0 -164
  63. package/packages/llm-billing/src/billing.ts +0 -251
  64. package/packages/llm-billing/src/index.ts +0 -219
  65. package/packages/llm-billing/src/invariant.ts +0 -30
  66. package/packages/llm-billing/src/types.ts +0 -67
  67. package/packages/llm-billing/tests/balance.spec.ts +0 -254
  68. package/packages/llm-billing/tests/billing.spec.ts +0 -216
  69. package/packages/llm-billing/tsconfig.json +0 -42
  70. package/packages/ui-billing/README.i18n.yaml +0 -6
  71. package/packages/ui-billing/README.md +0 -30
  72. package/packages/ui-billing/README.zh.md +0 -30
  73. package/packages/ui-billing/lib/client.js +0 -4466
  74. package/packages/ui-billing/lib/client.js.map +0 -1
  75. package/packages/ui-billing/lib/index.js +0 -11
  76. package/packages/ui-billing/lib/invariant.js +0 -25
  77. package/packages/ui-billing/lib/tsconfig.tsbuildinfo +0 -1
  78. package/packages/ui-billing/lib/types/client/BalanceBadge.d.ts +0 -33
  79. package/packages/ui-billing/lib/types/client/BalanceBadge.d.ts.map +0 -1
  80. package/packages/ui-billing/lib/types/client/BalanceBadge.js +0 -166
  81. package/packages/ui-billing/lib/types/client/BalanceBadge.js.map +0 -1
  82. package/packages/ui-billing/lib/types/client/index.d.ts +0 -20
  83. package/packages/ui-billing/lib/types/client/index.d.ts.map +0 -1
  84. package/packages/ui-billing/lib/types/client/index.js +0 -55
  85. package/packages/ui-billing/lib/types/client/index.js.map +0 -1
  86. package/packages/ui-billing/lib/types/client/locales.d.ts +0 -26
  87. package/packages/ui-billing/lib/types/client/locales.d.ts.map +0 -1
  88. package/packages/ui-billing/lib/types/client/locales.js +0 -40
  89. package/packages/ui-billing/lib/types/client/locales.js.map +0 -1
  90. package/packages/ui-billing/lib/types/index.d.ts +0 -9
  91. package/packages/ui-billing/lib/types/index.d.ts.map +0 -1
  92. package/packages/ui-billing/lib/types/index.js +0 -9
  93. package/packages/ui-billing/lib/types/index.js.map +0 -1
  94. package/packages/ui-billing/lib/types/invariant.d.ts +0 -16
  95. package/packages/ui-billing/lib/types/invariant.d.ts.map +0 -1
  96. package/packages/ui-billing/lib/types/invariant.js +0 -24
  97. package/packages/ui-billing/lib/types/invariant.js.map +0 -1
  98. package/packages/ui-billing/node_modules/.bin/cordis +0 -43
  99. package/packages/ui-billing/node_modules/.bin/cordis.CMD +0 -12
  100. package/packages/ui-billing/node_modules/.bin/cordis.ps1 +0 -41
  101. package/packages/ui-billing/node_modules/.bin/vite +0 -43
  102. package/packages/ui-billing/node_modules/.bin/vite.CMD +0 -12
  103. package/packages/ui-billing/node_modules/.bin/vite.ps1 +0 -41
  104. package/packages/ui-billing/package.json +0 -76
  105. package/packages/ui-billing/src/client/BalanceBadge.module.css +0 -184
  106. package/packages/ui-billing/src/client/BalanceBadge.tsx +0 -266
  107. package/packages/ui-billing/src/client/index.ts +0 -80
  108. package/packages/ui-billing/src/client/locales.ts +0 -45
  109. package/packages/ui-billing/src/css-modules.d.ts +0 -6
  110. package/packages/ui-billing/src/index.ts +0 -9
  111. package/packages/ui-billing/src/invariant.ts +0 -32
  112. package/packages/ui-billing/tests/balance-badge.client.spec.tsx +0 -267
  113. package/packages/ui-billing/tests/browser-plugin.client.spec.ts +0 -205
  114. package/packages/ui-billing/tsconfig.json +0 -36
  115. package/packages/ui-billing/tsdown.config.ts +0 -3
package/AGENTS.md CHANGED
@@ -41,7 +41,7 @@ cordis.patch.yml DSH profile bundle 补丁层:挂载 llm-billing + ui-
41
41
  - **密钥不进仓库**:`DEEPSEEK_API_KEY` 等一律由用户环境或凭据 seam 提供,仓库不含真实值。
42
42
  - **README 双语**:每个 README 遵循 DSH 结构 `README.md`(EN) + `README.zh.md`(ZH) +
43
43
  `README.i18n.yaml`(记录两文件 git blob hash,改动后需更新)。
44
- - **版本对齐**:根 bundle 与两个包统一版本号(当前 0.1.0-rc.8),`pnpm-lock.yaml` 随依赖变更更新。
44
+ - **版本对齐**:根 bundle 与两个包统一版本号(当前 0.1.0),`pnpm-lock.yaml` 随依赖变更更新。
45
45
  - **文本规范**:LF 换行、文件末尾一个换行(`.editorconfig`/`.gitattributes` 已声明)。
46
46
 
47
47
  ## 常用命令
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 WilliamLIiii
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.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 WilliamLIiii
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.i18n.yaml CHANGED
@@ -2,5 +2,5 @@
2
2
  # last confirmed-consistent state. Both languages carry equal authority; after
3
3
  # editing either side, bring the other along and re-record both hashes with:
4
4
  # git hash-object README.md README.zh.md
5
- README.md: a9771710292f8567ecbf3eb0cca14157ffe28bba
6
- README.zh.md: f8b2f62ea4c4ad46d4e05e2625ae1e9c70806e1c
5
+ README.md: 6ba8f7b92f1815c54688bc77b63dbf8408565eae
6
+ README.zh.md: 6efa6759a56cdaeeffa48319fff42e95d246029f
package/README.md CHANGED
@@ -45,9 +45,9 @@ A [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) plugin tha
45
45
  ### Installation (published to npm, one command)
46
46
 
47
47
  The three packages are published to npm under the `@rayadesu` scope. Install
48
- the bundle plus the two plugin packages in one command (pnpm does not install
49
- the bundle's local dependencies into the profile, so the two plugin packages
50
- must be named explicitly):
48
+ the bundle plus the two plugin packages in one command (the bundle declares the
49
+ two plugin packages as peer dependencies, which pnpm does not auto-install into
50
+ the profile, so they must be named explicitly):
51
51
 
52
52
  ```bash
53
53
  dsh plugin --profile web add @rayadesu/dsh-billing @rayadesu/dsh-llm-billing @rayadesu/dsh-client-ui-billing
@@ -66,10 +66,13 @@ Manual rows (only when you do not want the bundle):
66
66
 
67
67
  ### Dependency notes
68
68
 
69
- The runtime dependencies (`@deepseek-ai/dsh-credentials` and friends) are published
70
- to npm (`0.1.0-rc.8` on the `next` tag); both manifests declare them as
71
- `^0.1.0-rc.8` (the published form of the official `workspace:^`), so `pnpm install`
72
- resolves them directly.
69
+ The two plugin packages declare the DeepSeek Harness packages they build on
70
+ (`@deepseek-ai/cordis`, `@deepseek-ai/dsh-credentials`, `@deepseek-ai/dsh-session`,
71
+ and the client runtime packages) as `peerDependencies` at `^0.1.0-rc.8`. A dsh
72
+ profile does not auto-install peers, so these are provided by the dsh
73
+ installation itself through the `profiles/node_modules` fallback rather than
74
+ fetched from the registry — no extra packages to install, and no registry token
75
+ needed on the installing machine.
73
76
 
74
77
  ### Configure your DeepSeek API key
75
78
 
@@ -96,15 +99,15 @@ Both packages ship sane defaults; everything below is optional.
96
99
  | `apiKeyEnv` | `DEEPSEEK_API_KEY` | Credential-reference (environment-variable) name resolved per call. |
97
100
  | `baseURL` | `$DEEPSEEK_BASE_URL` then `https://api.deepseek.com` | Endpoint base; `/user/balance` is appended. |
98
101
  | `models` | V4 Flash + V4 Pro + V4 Flash Vision Exp | Advisory display rows, in presentation order. |
99
- | `billing.peakHours` | 09:00–12:00, 14:00–18:00 (Beijing) | Peak-hour windows; all other hours are off-peak. |
102
+ | `billing.peakHours` | 09:00–12:00, 14:00–18:00 (Beijing, weekdays) | Peak-hour windows, applied weekdays (Mon–Fri) only; weekends and all other hours are off-peak. |
100
103
  | `billing.models` | Published V4 rates | Per-model peak/off-peak price rows (`cacheHitInput`, `cacheMissInput`, `output`, in CNY per 1M tokens). |
101
104
 
102
105
  ## How session spend is computed
103
106
 
104
107
  - Each `assistant/message` event reports three billed token buckets: **cache-hit input**, **cache-miss input** (uncached input + cache writes), and **output** (including reasoning).
105
- - Each message is priced at the peak/off-peak rate of its own **Beijing-time** hour, the three buckets are billed separately (`缓存命中 ¥X · 未命中输入 ¥Y · 输出 ¥Z`), then summed per model.
108
+ - Each message is priced at the peak/off-peak rate of its own **Beijing-time** hour, the three buckets are billed separately (`缓存命中 ¥X · 未命中输入 ¥Y · 输出 ¥Z`), then summed per model. Peak windows apply weekdays (Monday–Friday) only; weekends are always off-peak.
106
109
  - **Today's spend** aggregates every session's events on the current Beijing-time calendar day with the same pricing rules; event dates are also assigned in Beijing time.
107
- - Models without a rate row are not priced (the built-in catalog currently has the three V4 rows: V4 Flash, V4 Pro, and V4 Flash Vision Exp). Rates follow the DeepSeek pricing effective **August 17** (Beijing-time peak/off-peak hours).
110
+ - Models without a rate row are not priced (the built-in catalog currently has the three V4 rows: V4 Flash, V4 Pro, and V4 Flash Vision Exp). Rates follow the DeepSeek pricing effective **August 17**; the weekend-off-peak rule (weekends billed at off-peak prices all day) follows the adjustment effective **August 23**.
108
111
 
109
112
  ## Known limitations
110
113
 
package/README.zh.md CHANGED
@@ -44,7 +44,7 @@
44
44
  ### 安装(已发布到 npm,一条命令)
45
45
 
46
46
  三个包已发布到 npm 的 `@rayadesu` scope。一条命令同时安装 bundle 与两个插件包
47
- pnpm 不会把 bundle 的本地依赖装进 profile,所以两个插件包要显式列出):
47
+ bundle 把两个插件包声明为 peer 依赖,而 profile 默认不自动安装 peer,所以要显式列出):
48
48
 
49
49
  ```bash
50
50
  dsh plugin --profile web add @rayadesu/dsh-billing @rayadesu/dsh-llm-billing @rayadesu/dsh-client-ui-billing
@@ -63,9 +63,11 @@ dsh plugin --profile web add @rayadesu/dsh-billing @rayadesu/dsh-llm-billing @ra
63
63
 
64
64
  ### 依赖说明
65
65
 
66
- `@deepseek-ai/dsh-credentials` 等运行时依赖已发布到 npm(`0.1.0-rc.8`,`next` tag),
67
- 两个包的 manifest 以 `^0.1.0-rc.8` 声明(官方 monorepo 中 `workspace:^` 的发布形态),
68
- `pnpm install` 可直接解析。
66
+ 两个插件包把它们依赖的 DeepSeek Harness 包(`@deepseek-ai/cordis`、
67
+ `@deepseek-ai/dsh-credentials`、`@deepseek-ai/dsh-session` 以及客户端运行时包)
68
+ 声明为 `peerDependencies`(`^0.1.0-rc.8`)。dsh profile 默认不自动安装 peer,所以
69
+ 这些由 dsh 安装本身通过 `profiles/node_modules` 回退提供,而不是从 registry 拉取——
70
+ 无需额外安装,安装机也不需要 registry token。
69
71
 
70
72
  ### 配置你的 DeepSeek API key
71
73
 
@@ -92,15 +94,15 @@ dsh web
92
94
  | `apiKeyEnv` | `DEEPSEEK_API_KEY` | 每次调用时解析的凭据引用(环境变量)名。 |
93
95
  | `baseURL` | `$DEEPSEEK_BASE_URL`,其次 `https://api.deepseek.com` | 端点基础地址;会追加 `/user/balance`。 |
94
96
  | `models` | V4 Flash + V4 Pro + V4 Flash Vision Exp | 展示用的模型行,按展示顺序。 |
95
- | `billing.peakHours` | 09:00–12:00、14:00–18:00(北京) | 高峰时段窗口;其余时段为低谷。 |
97
+ | `billing.peakHours` | 09:00–12:00、14:00–18:00(北京,仅工作日) | 高峰时段窗口,仅周一至周五适用;周末与其余时段均为低谷。 |
96
98
  | `billing.models` | 官方 V4 费率 | 每个模型的峰/谷单价行(`cacheHitInput`、`cacheMissInput`、`output`,单位:元/百万 token)。 |
97
99
 
98
100
  ## 会话花费是怎么算的
99
101
 
100
102
  - 每条 `assistant/message` 事件报告三个计费 token 桶:**缓存命中输入**、**未命中输入**(未缓存输入 + 缓存写入)、**输出**(含推理)。
101
- - 每条消息按其**发生时刻(北京时间)**所在的峰/谷时段单价计价,三个桶分别计费(`缓存命中 ¥X · 未命中输入 ¥Y · 输出 ¥Z`),再按模型汇总。
103
+ - 每条消息按其**发生时刻(北京时间)**所在的峰/谷时段单价计价,三个桶分别计费(`缓存命中 ¥X · 未命中输入 ¥Y · 输出 ¥Z`),再按模型汇总。高峰窗口仅周一至周五适用;周末全天按低谷价计费。
102
104
  - **今日共花费**按同一个计价规则汇总当天(北京时间自然日)所有会话的事件;事件归属的日期同样按北京时间计算。
103
- - 没有费率行的模型不计入(内置价目表目前含三个 V4 行:V4 Flash、V4 Pro、V4 Flash Vision Exp)。计费按 DeepSeek **8 月 17 日实行**的费率(北京时间峰/谷时段)。
105
+ - 没有费率行的模型不计入(内置价目表目前含三个 V4 行:V4 Flash、V4 Pro、V4 Flash Vision Exp)。计费按 DeepSeek **8 月 17 日实行**的费率;**周末按低谷价计费**的规则按 **8 月 23 日**生效的调整执行。
104
106
 
105
107
  ## 已知限制
106
108
 
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@rayadesu/dsh-billing",
3
- "version": "0.1.0-rc.9",
3
+ "version": "0.2.0",
4
4
  "description": "DeepSeek Harness billing plugin: account balance and this session's billed spend with a session-header badge.",
5
5
  "license": "MIT",
6
+ "packageManager": "pnpm@11.7.0",
6
7
  "engines": {
7
8
  "node": "^22.19 || >=24"
8
9
  },
@@ -11,10 +12,11 @@
11
12
  "patch": "./cordis.patch.yml"
12
13
  }
13
14
  },
15
+ "scripts": {
16
+ "build": "pnpm -r build"
17
+ },
14
18
  "files": [
15
19
  "cordis.patch.yml",
16
- "packages/llm-billing",
17
- "packages/ui-billing",
18
20
  "README.md",
19
21
  "README.zh.md",
20
22
  "LICENSE",
@@ -24,10 +26,7 @@
24
26
  "access": "public"
25
27
  },
26
28
  "peerDependencies": {
27
- "@rayadesu/dsh-llm-billing": "^0.1.0-rc.8",
28
- "@rayadesu/dsh-client-ui-billing": "^0.1.0-rc.8"
29
- },
30
- "scripts": {
31
- "build": "pnpm -r build"
29
+ "@rayadesu/dsh-llm-billing": "^0.2.0",
30
+ "@rayadesu/dsh-client-ui-billing": "^0.2.0"
32
31
  }
33
- }
32
+ }
@@ -1,6 +0,0 @@
1
- # Bilingual-pair consistency record: the git blob hash of each side as of the
2
- # last confirmed-consistent state. Both languages carry equal authority; after
3
- # editing either side, bring the other along and re-record both hashes with:
4
- # git hash-object README.md README.zh.md
5
- README.md: 655288ebdb37cee4ecd3edfad8b3953e3a4e87ee
6
- README.zh.md: e8ac4a2716ffe57200bb9757e1f0c6dabaf77c2f
@@ -1,44 +0,0 @@
1
- # @rayadesu/dsh-llm-billing
2
-
3
- English | [中文](README.zh.md)
4
-
5
- Standalone host plugin that turns the DeepSeek account balance and per-session spend into a `billing` Remote. It owns the `/user/balance` transport, the peak/off-peak pricing table, and the per-session spend pricing, so a deployment can surface "how much is left, and what this session cost" without coupling that to the chat-completions adapter. The browser half is [`dsh-client-ui-billing`](../ui-billing/README.md).
6
-
7
- ## Install
8
-
9
- Add the plugin to a composition (a `cordis.yml` row) and give it a credential. It resolves the API key from the credential seam (or the environment variable named by `apiKeyEnv`) and the endpoint from `baseURL`, then `$DEEPSEEK_BASE_URL`, then the public API.
10
-
11
- ```yaml
12
- - id: llm-billing
13
- name: '@rayadesu/dsh-llm-billing'
14
- config:
15
- # apiKeyEnv: DEEPSEEK_API_KEY # default
16
- # baseURL: https://api.deepseek.com
17
- ```
18
-
19
- The plugin registers the `billing` Remote with three methods: `getBalance()` (the parsed `/user/balance` snapshot), `getSessionSpend(sessionId)` (one session's billed cost), and `getTodaySpend()` (every session's billed cost on the current Beijing-time calendar day). The spend prices each `assistant/message` event's billed tokens (cache-hit input, cache-miss input including cache writes, and output including reasoning) at the official rate of the event's own Beijing-time peak/off-peak hour, then sums per model.
20
-
21
- ## Configuration
22
-
23
- | Field | Default | Meaning |
24
- | --- | --- | --- |
25
- | `apiKeyEnv` | `DEEPSEEK_API_KEY` | Credential-reference (environment-variable) name resolved per call. |
26
- | `baseURL` | `$DEEPSEEK_BASE_URL` then `https://api.deepseek.com` | Endpoint base; `/user/balance` is appended. |
27
- | `models` | V4 Flash + V4 Pro + V4 Flash Vision Exp | Advisory display rows, in presentation order. |
28
- | `billing.peakHours` | 09:00–12:00, 14:00–18:00 (Beijing) | Peak-hour windows; all other hours are off-peak. |
29
- | `billing.models` | Published V4 rates | Per-model peak/off-peak price rows (`cacheHitInput`, `cacheMissInput`, `output`, in CNY per 1M tokens). |
30
-
31
- Override one model without dropping the others by supplying a non-empty `billing.models` list; an empty or omitted list falls back to the published defaults.
32
-
33
- ## Model Experience
34
-
35
- None, as this package is a read-only Remote projection of provider and session facts and touches no prompt, message, schema, stream, or tool result.
36
-
37
- #### KV Cache effect
38
-
39
- None; its only provider call is a credential-authenticated `/user/balance` read, which is not cached in the provider KV store.
40
-
41
- ## Known Limitations and Deferred Work
42
-
43
- - **Priced rows only** — the session and today spends only price models that have a `billing.models` row; a model without a rate row is omitted.
44
- - **On-demand read** — the session spend reads the session's full event log on each call rather than maintaining an incremental aggregate, so cost grows with the per-session log size; `getTodaySpend()` reads every session's log, and a session whose log cannot be read is skipped with a warning instead of failing the whole day's total.
@@ -1,44 +0,0 @@
1
- # @rayadesu/dsh-llm-billing
2
-
3
- [English](README.md) | 中文
4
-
5
- 独立的宿主插件,把 DeepSeek 账户余额与会话花费变成 `billing` Remote。它拥有 `/user/balance` 传输、峰谷计价表与每会话的计费花费计价,因此部署可以在不把这个能力与聊天补全适配器耦合的前提下,展示「还剩多少、这个会话花了多少」。浏览器侧是 [`dsh-client-ui-billing`](../ui-billing/README.md)。
6
-
7
- ## 安装
8
-
9
- 把插件加进组合(一个 `cordis.yml` 行)并给它一个凭据。它先从凭据 seam(或 `apiKeyEnv` 指定的环境变量)解析 API key,再从 `baseURL`、其次 `$DEEPSEEK_BASE_URL`、最后公共 API 解析端点。
10
-
11
- ```yaml
12
- - id: llm-billing
13
- name: '@rayadesu/dsh-llm-billing'
14
- config:
15
- # apiKeyEnv: DEEPSEEK_API_KEY # default
16
- # baseURL: https://api.deepseek.com
17
- ```
18
-
19
- 插件注册 `billing` Remote,含三个方法:`getBalance()`(解析后的 `/user/balance` 快照)、`getSessionSpend(sessionId)`(单个会话的计费花费)与 `getTodaySpend()`(当前北京时间自然日内所有会话的计费花费合计)。会话花费把每条 `assistant/message` 事件的计费 token(缓存命中输入、含缓存写入的未命中输入、含推理的输出)按事件自身发生时刻(北京时间)所在的峰/谷单价计价,再按模型汇总。
20
-
21
- ## 配置
22
-
23
- | 字段 | 默认 | 含义 |
24
- | --- | --- | --- |
25
- | `apiKeyEnv` | `DEEPSEEK_API_KEY` | 每次调用时解析的凭据引用(环境变量)名。 |
26
- | `baseURL` | `$DEEPSEEK_BASE_URL`,其次 `https://api.deepseek.com` | 端点基础地址;会追加 `/user/balance`。 |
27
- | `models` | V4 Flash + V4 Pro + V4 Flash Vision Exp | 展示用的模型行,按展示顺序。 |
28
- | `billing.peakHours` | 09:00–12:00、14:00–18:00(北京) | 高峰时段窗口;其余时段为低谷。 |
29
- | `billing.models` | 官方 V4 费率 | 每个模型的峰/谷单价行(`cacheHitInput`、`cacheMissInput`、`output`,单位:元/百万 token)。 |
30
-
31
- 只想覆盖某个模型而不丢其它,就提供一个非空的 `billing.models` 列表;空或省略则回退到官方默认费率。
32
-
33
- ## 模型体验
34
-
35
- 无,因为本包是 provider 与会话事实的只读 Remote 投影,不触及 prompt、消息、schema、流或工具结果。
36
-
37
- #### KV Cache effect
38
-
39
- 无;它唯一的 provider 调用是一次带凭据的 `/user/balance` 读取,不落在 provider 的 KV 缓存里。
40
-
41
- ## 已知限制与暂缓事项
42
-
43
- - **有费率行才计价** —— 会话花费与今日花费只统计价目表(`billing.models`)里有的模型;没有费率行的模型不计入。
44
- - **按需读取** —— 会话花费在每次调用时读取该会话的完整事件日志,而非维护增量聚合,因此成本随单会话日志大小增长;`getTodaySpend()` 会读取每个会话的日志,日志无法读取的会话带警告跳过,而不是让整日合计失败。