@pinkbanana/dsh-balance 0.10.3 → 0.12.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/README.md +26 -5
- package/README_EN.md +24 -3
- package/lib/client.js +730 -87
- package/lib/client.js.map +1 -1
- package/lib/index.js +586 -20
- package/lib/index.js.map +1 -1
- package/lib/types/billing.d.ts +9 -1
- package/lib/types/client/DeepSeekPanel.d.ts +4 -3
- package/lib/types/client/format.d.ts +2 -0
- package/lib/types/client/locales.d.ts +8 -0
- package/lib/types/client/styles.d.ts +1 -1
- package/lib/types/providers.d.ts +18 -0
- package/lib/types/tokener-pricing.d.ts +7 -0
- package/lib/types/types.d.ts +1 -1
- package/package.json +34 -33
package/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
[简体中文](./README.md) | [English](./README_EN.md)
|
|
4
4
|
|
|
5
|
-
DeepSeek Harness 插件,用于查询 DeepSeek / StepFun API
|
|
5
|
+
DeepSeek Harness 插件,用于查询 DeepSeek / StepFun API 余额,以及 DeepSeek / StepFun / Tokener 的可用模型和多维消费统计。API Key 仅由本机 Host 使用,不会发送到浏览器。
|
|
6
6
|
|
|
7
|
-
界面使用 Harness 原生侧栏、主页面和主题变量。侧栏“插件”下方新增“用量统计”,独立查看所有对话的提供方、模型、会话和日期统计;默认显示全部提供方与全部时间,支持提供方和日期范围筛选。活动打卡图按浏览器时区的星期 × 24 小时汇总请求次数,圆点大小随次数变化;悬停或使用方向键可查看请求数与 token 明细。选择器采用主题化浮层菜单,支持方向键、Home/End、Enter、Escape 和按名称检索。设置页支持 DeepSeek / StepFun 切换。运行 `pnpm preview` 可查看使用示例数据的新版界面。
|
|
7
|
+
界面使用 Harness 原生侧栏、主页面和主题变量。侧栏“插件”下方新增“用量统计”,独立查看所有对话的提供方、模型、会话和日期统计;默认显示全部提供方与全部时间,支持提供方和日期范围筛选。活动打卡图按浏览器时区的星期 × 24 小时汇总请求次数,圆点大小随次数变化;悬停或使用方向键可查看请求数与 token 明细。选择器采用主题化浮层菜单,支持方向键、Home/End、Enter、Escape 和按名称检索。设置页支持 DeepSeek / StepFun / Tokener 切换。运行 `pnpm preview` 可查看使用示例数据的新版界面。
|
|
8
8
|
|
|
9
9
|
聊天框底部会跟随当前会话所选的提供方与模型更新余额;设置页可独立切换提供方。
|
|
10
10
|
|
|
@@ -12,11 +12,12 @@ DeepSeek Harness 插件,用于查询 DeepSeek / StepFun API 余额、各提供
|
|
|
12
12
|
|
|
13
13
|
- DeepSeek:查看总余额、充值余额和赠送余额
|
|
14
14
|
- StepFun:查看可用余额、总充值金额、总赠送金额及预付费 / 后付费账户类型
|
|
15
|
+
- Tokener:按提供方、模型、会话、日期统计本地请求和 token,以公开目录价估算美元费用;通过官方 `/v1/models` 查询模型
|
|
15
16
|
- 提供方独立缓存;支持大小写不敏感的 Provider ID
|
|
16
17
|
- 在聊天框下方显示当前 provider、模型和余额,兼容模型选择器与 `/model` 切换
|
|
17
18
|
- 从当前提供方的 `/models` 接口读取可用模型、所属组织与创建时间
|
|
18
19
|
- 在设置页按所选 provider、模型、会话和日期查看实际 usage 消费,并在当前会话的“消费”Tab 查看请求明细
|
|
19
|
-
-
|
|
20
|
+
- 明确区分已计费、免费(已知价格且费用为 0)与未计费请求;缺少 provider usage、未知 provider 或未知模型时不进行费用估算
|
|
20
21
|
- 日期按浏览器 IANA 时区分组;DeepSeek 峰谷价格始终按北京时间计算
|
|
21
22
|
- DeepSeek 费用显示 USD、StepFun 显示原生 CNY;配置 `usdToCny` 后显示人民币合计
|
|
22
23
|
- 缓存查询结果并支持手动刷新
|
|
@@ -28,7 +29,9 @@ DeepSeek Harness 插件,用于查询 DeepSeek / StepFun API 余额、各提供
|
|
|
28
29
|
|
|
29
30
|
## 兼容性
|
|
30
31
|
|
|
31
|
-
0.
|
|
32
|
+
0.12.0 适配 DeepSeek Harness **0.2.1-rc.5**([上游版本](https://github.com/deepseek-ai/deepseek-harness/releases/tag/dsh-v0.2.1-rc.5)),需要 Node.js **22.19+(22.x)或 24+**。所有 DSH peer 依赖和开发依赖均锁定为 `0.2.1-rc.5`。Harness `0.2.0-rc.2` 用户请继续使用插件 `0.10.2`;本次源码不再兼容 Harness 0.1 的接口。
|
|
33
|
+
|
|
34
|
+
新版 dsh 会在安装及启动时校验插件兼容版本。旧插件锁定 `rc.2`,会被 `rc.5` 拒绝加载;请升级到插件 `0.12.0`,无需添加版本豁免。仍使用 dsh `0.2.1-rc.2` 的用户请保留插件 `0.11.0`。
|
|
32
35
|
|
|
33
36
|
也可在本地构建并打包源码,再用 `dsh plugin --profile web add /absolute/path/to/package.tgz` 安装生成的 `.tgz` 文件,随后重启 Harness:
|
|
34
37
|
|
|
@@ -48,6 +51,7 @@ pnpm pack
|
|
|
48
51
|
## 安装
|
|
49
52
|
|
|
50
53
|
```bash
|
|
54
|
+
npm install -g @deepseek-ai/dsh@latest
|
|
51
55
|
dsh plugin --profile web add @pinkbanana/dsh-balance@latest
|
|
52
56
|
dsh --profile web
|
|
53
57
|
```
|
|
@@ -81,13 +85,30 @@ providers:
|
|
|
81
85
|
|
|
82
86
|
模型列表按 [StepFun 列表 API](https://platform.stepfun.com/docs/zh/api-reference/models/list) 请求 `GET /v1/models`,解析 [Model 对象](https://platform.stepfun.com/docs/zh/api-reference/models/object) 的 `id`、`owned_by`、`created`(秒级 Unix 时间戳)。列表已包含这些信息,不需要逐个调用单模型详情接口。Host 路由为 `GET /dsh-balance/api/models?provider=StepFun`,模型缓存按 provider 隔离,`refresh=1` 强制刷新。
|
|
83
87
|
|
|
88
|
+
## Tokener 配置与统计
|
|
89
|
+
|
|
90
|
+
在“设置 → 模型”中添加自定义提供方,Provider ID 使用 `Tokener`(大小写不限,也支持 `tokener.ai`),Base URL 使用 `https://api.tokener.ai/v1`,并保存 API Key。插件默认使用 `TOKENER_API_KEY`,也支持 `providers` 配置覆盖:
|
|
91
|
+
|
|
92
|
+
```yaml
|
|
93
|
+
providers:
|
|
94
|
+
- id: tokener
|
|
95
|
+
apiKeyRef: TOKENER_API_KEY
|
|
96
|
+
baseUrl: https://api.tokener.ai/v1
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
根据 [Tokener API 文档](https://www.tokener.ai/zh/docs/reference/api-endpoint),可用模型由 Host 使用 Bearer 认证查询 `/v1/models`,密钥不发送到浏览器。文档没有公开 API Key 可访问的余额或组织用量接口,因此设置页提供控制台入口,聊天框提示查看“用量统计”,不尝试未知端点。
|
|
100
|
+
|
|
101
|
+
统计仅覆盖当前 dsh 保存的本地会话,不包含其他客户端或整个组织的调用,也不提供 API Key 维度。请求数、输入、输出、缓存读取与缓存写入按 dsh 标准化的 usage 统计;缓存读取已从标准化输入中拆出,不重复计数。支持提供方、模型、会话、日期和活动时段明细,提供方别名统一归为 Tokener。
|
|
102
|
+
|
|
103
|
+
内置 2026-11-03 核验的 [Tokener 模型目录](https://www.tokener.ai/zh/models) 对话/推理模型美元参考价,逐个匹配完整模型 ID。使用 Tokener 目录价格,不套用原厂价格或 DeepSeek 峰谷倍率。参考价快照同样用于已有历史记录的估算,不代表历史实际扣款。未知模型、缺少 usage,以及包含未公开价格的缓存写入请求,保留请求数与 token 并标为“未计费”。账户余额、折扣和实际消费以 [Tokener 控制台](https://console.tokener.ai) 为准。
|
|
104
|
+
|
|
84
105
|
## 统计口径
|
|
85
106
|
|
|
86
107
|
每条请求按实际返回消息的 provider / model 归属,兼容旧日志的请求头;日期和峰谷价格按该次请求时间计算。Token 总量包括未缓存输入、输出、缓存读取与缓存写入。设置页默认筛选所选 provider,也可选择“全部提供方”;会话页保留混用模型的完整历史。
|
|
87
108
|
|
|
88
109
|
内置 DeepSeek 美元定价,以及 2026-09-30 核验的 [StepFun 官方人民币标准价](https://platform.stepfun.com/docs/zh/guides/pricing/details):`step-5-preview`、`step-3.7-flash`、`step-3.5-flash` 和 `step-3.5-flash-2603`。StepFun 未缓存输入(含缓存写入)、缓存读取、输出分别计价,不套用 DeepSeek 峰谷倍率。费用是公开标准价估算,不代表账户实际账单;套餐、折扣和未保存的历史调价不包含在内。
|
|
89
110
|
|
|
90
|
-
美元和原生人民币费用分别展示;设置 `usdToCny`
|
|
111
|
+
美元和原生人民币费用分别展示;设置 `usdToCny` 后,人民币合计才会包含美元折算金额,并明确标为固定汇率换算。未设置汇率时,原生人民币金额不会被表述为包含美元费用的完整人民币合计。已知价格且费用为 0 的请求单列为“免费”;未知 provider / model 和缺失 usage 的请求保留请求数与 token,显示“未计费”。账户余额是实时查询值,与本地用量估算独立;赠送余额与充值余额分别展示,StepFun 的总充值/总赠送为累计值而非剩余余额。会话消费页采用居中内容宽度、响应式外边距,并为底部输入框保留空间。
|
|
91
112
|
|
|
92
113
|
## 扩展与设计
|
|
93
114
|
|
package/README_EN.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
[简体中文](./README.md) | [English](./README_EN.md)
|
|
4
4
|
|
|
5
|
-
A DeepSeek Harness plugin for checking DeepSeek / StepFun API balances, available
|
|
5
|
+
A DeepSeek Harness plugin for checking DeepSeek / StepFun API balances, plus available models and multidimensional usage costs for DeepSeek / StepFun / Tokener. The API key is used only by the local Host and is never sent to the browser.
|
|
6
6
|
|
|
7
|
-
The redesigned account ledger switches between DeepSeek and
|
|
7
|
+
The redesigned account ledger switches between DeepSeek, StepFun, and Tokener. Run `pnpm preview` to explore it with sample data.
|
|
8
8
|
|
|
9
9
|
The composer readout follows the current session’s provider and model. The Settings provider selection is independent.
|
|
10
10
|
|
|
@@ -12,6 +12,7 @@ The composer readout follows the current session’s provider and model. The Set
|
|
|
12
12
|
|
|
13
13
|
- DeepSeek: total, topped-up, and granted balances
|
|
14
14
|
- StepFun: available balance, total cash credited, total vouchers granted, and prepaid / postpaid account type
|
|
15
|
+
- Tokener: local requests/tokens grouped by provider, model, session and date, USD estimates from its published catalog, and models from `/v1/models`
|
|
15
16
|
- Independent provider caches and case-insensitive Provider IDs
|
|
16
17
|
- Show the current provider, model, and balance below the composer, following both the selector and `/model`
|
|
17
18
|
- Fetch available models, owners, and creation dates from the selected provider’s `/models` API
|
|
@@ -26,7 +27,7 @@ The composer readout follows the current session’s provider and model. The Set
|
|
|
26
27
|
|
|
27
28
|
## Compatibility
|
|
28
29
|
|
|
29
|
-
Version 0.
|
|
30
|
+
Version 0.12.0 targets DeepSeek Harness **0.2.1-rc.5** ([upstream release](https://github.com/deepseek-ai/deepseek-harness/releases/tag/dsh-v0.2.1-rc.5)). Use Node.js **22.19+ (22.x) or 24+**. All DSH peer and development dependencies are pinned to `0.2.1-rc.5`. Harness `0.2.0-rc.2` users should keep plugin `0.10.2`; Harness 0.1 APIs are no longer supported by this checkout.
|
|
30
31
|
|
|
31
32
|
To install from source, build and pack it locally, then pass the generated `.tgz` path to `dsh plugin --profile web add /absolute/path/to/package.tgz` and restart Harness:
|
|
32
33
|
|
|
@@ -46,6 +47,7 @@ Usage breakdowns use counted tabs for models, providers, sessions, and dates, wi
|
|
|
46
47
|
## Install
|
|
47
48
|
|
|
48
49
|
```bash
|
|
50
|
+
npm install -g @deepseek-ai/dsh@latest
|
|
49
51
|
dsh plugin --profile web add @pinkbanana/dsh-balance@latest
|
|
50
52
|
dsh --profile web
|
|
51
53
|
```
|
|
@@ -60,6 +62,25 @@ usdToCny: 7.2
|
|
|
60
62
|
|
|
61
63
|
Both the official provider ID `deepseek-official` and legacy `deepseek` are supported case-insensitively and share DeepSeek credentials, balance caches, and model caches. The composer retains the actual model ID, such as `deepseek-flash`; new models with unknown pricing remain unpriced.
|
|
62
64
|
|
|
65
|
+
## Tokener configuration and usage
|
|
66
|
+
|
|
67
|
+
Add a custom provider in Settings → Models with ID `Tokener` (case-insensitive; `tokener.ai` is also accepted), base URL `https://api.tokener.ai/v1`, and your API key. The default credential reference is `TOKENER_API_KEY`; it can be overridden:
|
|
68
|
+
|
|
69
|
+
```yaml
|
|
70
|
+
providers:
|
|
71
|
+
- id: tokener
|
|
72
|
+
apiKeyRef: TOKENER_API_KEY
|
|
73
|
+
baseUrl: https://api.tokener.ai/v1
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The Host queries the documented `GET /v1/models` with Bearer authentication; credentials never reach the browser. [Tokener's API documentation](https://www.tokener.ai/zh/docs/reference/api-endpoint) does not publish an API-key balance or organization-usage endpoint. Settings link to the console, and the composer points to Usage Statistics without querying an undocumented endpoint.
|
|
77
|
+
|
|
78
|
+
Statistics cover locally saved dsh sessions only, not other clients or organization-wide usage, and do not group by API key. Requests and tokens are grouped by provider, model, session, date and activity hour. DSH usage already separates cache reads from uncached input; the plugin does not count them twice.
|
|
79
|
+
|
|
80
|
+
Conversation/reasoning model estimates use the [Tokener model catalog](https://www.tokener.ai/zh/models) USD reference snapshot checked on 2026-11-03, matching exact model IDs without vendor rates or DeepSeek peak multipliers. This snapshot also estimates older records; it does not reconstruct historical charges. Unknown models, missing usage, and requests with unpublished cache-write pricing retain their requests/tokens but stay unpriced. Account balances and actual bills remain in the [Tokener console](https://console.tokener.ai).
|
|
81
|
+
|
|
82
|
+
New dsh versions validate compatibility before installation and startup. Plugin `0.11.0` declares `rc.2` peers and is rejected on `rc.5`; upgrade to `0.12.0` without a version exemption. Keep plugin `0.11.0` if you remain on dsh `0.2.1-rc.2`.
|
|
83
|
+
|
|
63
84
|
## StepFun setup
|
|
64
85
|
|
|
65
86
|
Add a custom provider in Settings → Models with Provider ID `StepFun` (`stepfun`, `STEPFUN`, and other case variants work) and save its API key. Harness derives the credential reference `STEPFUN_API_KEY`; setting that environment variable also works. Select StepFun in Settings → Model Balances.
|