@pinkbanana/dsh-balance 0.11.0 → 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 CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  [简体中文](./README.md) | [English](./README_EN.md)
4
4
 
5
- DeepSeek Harness 插件,用于查询 DeepSeek / StepFun API 余额、各提供方的可用模型和多维消费统计。API Key 仅由本机 Host 使用,不会发送到浏览器。
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,6 +12,7 @@ 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` 接口读取可用模型、所属组织与创建时间
@@ -28,7 +29,9 @@ DeepSeek Harness 插件,用于查询 DeepSeek / StepFun API 余额、各提供
28
29
 
29
30
  ## 兼容性
30
31
 
31
- 0.11.0 适配 DeepSeek Harness **0.2.1-rc.2**([上游版本](https://github.com/deepseek-ai/deepseek-harness/releases/tag/dsh-v0.2.1-rc.2)),需要 Node.js **22.19+(22.x)或 24+**。所有 DSH peer 依赖和开发依赖均锁定为 `0.2.1-rc.2`。Harness `0.2.0-rc.2` 用户请继续使用插件 `0.10.2`;本次源码不再兼容 Harness 0.1 的接口。
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,6 +85,23 @@ 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,也可选择“全部提供方”;会话页保留混用模型的完整历史。
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 provider models, and multidimensional usage costs. The API key is used only by the local Host and is never sent to the browser.
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 StepFun. Run `pnpm preview` to explore it with sample data.
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.11.0 targets DeepSeek Harness **0.2.1-rc.2** ([upstream release](https://github.com/deepseek-ai/deepseek-harness/releases/tag/dsh-v0.2.1-rc.2)). Use Node.js **22.19+ (22.x) or 24+**. All DSH peer and development dependencies are pinned to `0.2.1-rc.2`. 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
+ 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.