@yyfather/dsh-balance 0.1.0 → 0.1.2

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 CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 YYfather
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 YYfather
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 CHANGED
@@ -1,55 +1,63 @@
1
- # dsh-balance
2
-
3
- DeepSeek Harness 余额与开销插件。在对话底部状态栏(composer dock)显示 DeepSeek / MiMo 账户余额与话费开销,支持**逐请求计价**、**高峰/空闲分时段**、**多模型价目**与**花费超线提醒**(点击状态栏即可设置)。
4
-
5
- ## 功能
6
-
7
- - **余额**:实时查询 DeepSeek 账户余额(仅本机可访问,密钥只存在于 Host 侧;当前会话为 MiMo 等外部模型时不显示 DeepSeek 余额)
8
- - **开销(逐请求精确计价)**:按每个请求时间戳选高峰/空闲档价、按该请求的模型选价、同一步骤的 usage 样本按官方投影替换规则去重
9
- - `本会话` = 当前会话从创建至今的全部花费
10
- - `本次活跃` = 自本次插件启用以来新产生的花费
11
- - `最近一次` = 当前会话最新一步请求的花费
12
- - `上次对话` = 当前会话之前的上一会话花费(MiMo 会话按小米美元价 × 汇率折算)
13
- - **多模型价目**:内置 DeepSeek V4 Flash / V4 Flash Vision Exp / V4 Pro(官方价,空闲/高峰双档)与小米 MiMo V2.5 系(美元价),可在点击面板中按模型+时段编辑,美元模型按可配置汇率换算
14
- - **提醒**:本次活跃花费 提醒线(默认 ¥1)时状态栏变橙色徽标;DeepSeek 余额 < 提醒线(默认 ¥10)同样提醒;点击面板可改两线
15
- - **刷新**:每次对话结束后自动刷新 + 5 分钟自动刷新(可在面板中开关)
16
-
17
- ## 安装
18
-
19
- 1. 克隆仓库到 DSH 的 profile 依赖目录(`%USERPROFILE%\.dsh\profiles\node_modules\@yyfather\dsh-balance` 或你的 `$DSH_HOME/profiles/<name>/node_modules/@yyfather/dsh-balance`):
20
- ```sh
21
- git clone https://github.com/YYfather/dsh-balance.git "$USERPROFILE\.dsh\profiles\node_modules\@yyfather\dsh-balance"
22
- ```
23
- 2. profile `cordis.patch.yml` 末尾追加(该文件是用户 patch 层,重装/升级不会覆盖;`%USERPROFILE%\.dsh\profiles\desktop\cordis.patch.yml`):
24
- ```yaml
25
- - insert:
26
- - id: dsh-balance
27
- name: '@yyfather/dsh-balance'
28
- ```
29
- 3. 重启 DSH Desktop。状态栏底部即出现余额/开销一行;点击可打开设置面板。
30
-
31
- ### 依赖
32
-
33
- - Host 侧:`webServer`、`credentials`(DeepSeek 密钥在 设置→模型 保存,默认引用 `DEEPSEEK_API_KEY`)、`sessions` / `sessionQuery`(会话与历史投影)、`timer`
34
- - Client 侧:`slots`(`conversation.composer.dock`)、React
35
- - Node ≥ 20(Host 使用原生 `fetch`)
36
-
37
- ## 配置(Host `cordis.patch.yml` 行内可覆盖)
38
-
39
- | 字段 | 默认 | 说明 |
40
- |---|---|---|
41
- | `apiKeyRef` | `DEEPSEEK_API_KEY` | 余额查询所用凭据引用 |
42
- | `baseUrl` | `https://api.deepseek.com` | DeepSeek API 根地址 |
43
- | `timeoutMs` | `20000` | 上游查询超时 |
44
- | `allowRemote` | `false` | 不允许非本机访问插件路由(安全默认,勿随意外开) |
45
-
46
- 运行时价格/提醒线在点击面板中修改(进程内生效)。
47
-
48
- ## 安全
49
-
50
- - 密钥仅在 Host 侧解析,浏览器端只访问 `dsh-balance/api/*` 本机同源路由(默认拒绝本机以外的来源)
51
- - 路由响应不含任何上游原文、密钥或未经校验的字段
52
-
53
- ## License
54
-
55
- MIT
1
+ # dsh-balance
2
+
3
+ DeepSeek Harness 余额与开销插件。在对话底部状态栏(composer dock)显示 DeepSeek / MiMo 账户余额与话费开销,支持**逐请求计价**、**高峰/空闲分时段**、**多模型价目**与**花费超线提醒**(点击状态栏即可设置)。
4
+
5
+ > 📦 已发布 npm:`@yyfather/dsh-balance`(npm registry,可一键安装)
6
+
7
+ ## 功能
8
+
9
+ - **余额**:实时查询 DeepSeek 账户余额(仅本机可访问,密钥只存在于 Host 侧;当前会话为 MiMo 等外部模型时不显示 DeepSeek 余额)
10
+ - **开销(逐请求精确计价)**:按每个请求时间戳选高峰/空闲档价、按该请求的模型选价、同一步骤的 usage 样本按官方投影替换规则去重
11
+ - `本会话` = 当前会话从创建至今的全部花费
12
+ - `本次活跃` = 自本次插件启用以来新产生的花费
13
+ - `最近一次` = 当前会话最新一步请求的花费
14
+ - `上次对话` = 当前会话之前的上一会话花费(MiMo 会话按小米美元价 × 汇率折算)
15
+ - **多模型价目**:内置 DeepSeek V4 Flash / V4 Flash Vision Exp / V4 Pro(官方价,空闲/高峰双档)与小米 MiMo V2.5 系(美元价),可在点击面板中按模型+时段编辑,美元模型按可配置汇率换算
16
+ - **提醒**:本次活跃花费 ≥ 提醒线(默认 ¥1)时状态栏变橙色徽标;DeepSeek 余额 < 提醒线(默认 ¥10)同样提醒;点击面板可改两线
17
+ - **刷新**:每次对话结束后自动刷新 + 每 5 分钟自动刷新(可在面板中开关)
18
+
19
+ ## 安装
20
+
21
+ ### 方式一:插件市场一键安装(推荐)
22
+
23
+ 市场(设置 插件市场)中出现本插件后,在**可安装**页点击卡片即可走 DSH 官方的受管安装(npm 身份校验 + 安全快照 + 重启验证)。
24
+
25
+ ### 方式二:手动安装
26
+
27
+ 1. 克隆仓库到 DSH 的 profile 依赖目录(`%USERPROFILE%\.dsh\profiles\node_modules\@yyfather\dsh-balance` 或你的 `$DSH_HOME/profiles/<name>/node_modules/@yyfather/dsh-balance`):
28
+ ```sh
29
+ git clone https://github.com/YYfather/dsh-balance.git "$USERPROFILE\.dsh\profiles\node_modules\@yyfather\dsh-balance"
30
+ ```
31
+ 2. 在 profile 的 `cordis.patch.yml` 末尾追加(该文件是用户 patch 层,重装/升级不会覆盖;`%USERPROFILE%\.dsh\profiles\desktop\cordis.patch.yml`):
32
+ ```yaml
33
+ - insert:
34
+ - id: dsh-balance
35
+ name: '@yyfather/dsh-balance'
36
+ ```
37
+ 3. 重启 DSH Desktop。状态栏底部即出现余额/开销一行;点击可打开设置面板。
38
+
39
+ ### 依赖
40
+
41
+ - Host 侧:`webServer`、`credentials`(DeepSeek 密钥在 设置→模型 保存,默认引用 `DEEPSEEK_API_KEY`)、`sessions` / `sessionQuery`(会话与历史投影)、`timer`
42
+ - Client 侧:`slots`(`conversation.composer.dock`)、React
43
+ - Node 20(Host 使用原生 `fetch`)
44
+
45
+ ## 配置(Host `cordis.patch.yml` 行内可覆盖)
46
+
47
+ | 字段 | 默认 | 说明 |
48
+ |---|---|---|
49
+ | `apiKeyRef` | `DEEPSEEK_API_KEY` | 余额查询所用凭据引用 |
50
+ | `baseUrl` | `https://api.deepseek.com` | DeepSeek API 根地址 |
51
+ | `timeoutMs` | `20000` | 上游查询超时 |
52
+ | `allowRemote` | `false` | 不允许非本机访问插件路由(安全默认,勿随意外开) |
53
+
54
+ 运行时价格/提醒线在点击面板中修改(进程内生效)。
55
+
56
+ ## 安全
57
+
58
+ - 密钥仅在 Host 侧解析,浏览器端只访问 `dsh-balance/api/*` 本机同源路由(默认拒绝本机以外的来源)
59
+ - 路由响应不含任何上游原文、密钥或未经校验的字段
60
+
61
+ ## License
62
+
63
+ MIT
package/README_EN.md CHANGED
@@ -1,55 +1,63 @@
1
- # dsh-balance
2
-
3
- A DeepSeek Harness plugin that shows DeepSeek / MiMo account balance and per-request conversation cost in the composer dock, with model-aware peak/off-peak pricing and spend alerts (click the dock readout to configure).
4
-
5
- ## Features
6
-
7
- - **Balance**: live DeepSeek account balance (loopback-only routes; the credential never leaves the Host; hidden when the current session uses an external provider such as Xiaomi MiMo)
8
- - **Per-request cost**: each usage sample is priced by its own request timestamp (peak/off-peak) and its own model, with the same `(turn, step)` replacement rule as the official token-usage projection
9
- - `本会话 / this conversation` = full cost of the current session since its creation
10
- - `本次活跃 / active period` = cost of requests since this plugin instance started
11
- - `最近一次 / last request` = cost of the most recent request
12
- - `上次对话 / previous conversation` = cost of the immediately preceding session (MiMo sessions converted via a configurable USD rate)
13
- - **Model price table**: DeepSeek V4 Flash / V4 Flash Vision Exp / V4 Pro (official CNY, off-peak/peak tiers) and Xiaomi MiMo V2.5 family (USD, editable), editable per model + tier in the click panel; USD entries converted at a configurable rate
14
- - **Alerts**: orange pill badge when active-period spend spend line (default ¥1) or DeepSeek balance < balance line (default ¥10); both editable in the panel
15
- - **Refresh**: after each conversation turn and every 5 minutes (toggleable)
16
-
17
- ## Installation
18
-
19
- 1. Clone into the profile dependency folder (`$DSH_HOME/profiles/<name>/node_modules/@yyfather/dsh-balance`):
20
- ```sh
21
- git clone https://github.com/YYfather/dsh-balance.git "$HOME/.dsh/profiles/node_modules/@yyfather/dsh-balance"
22
- ```
23
- 2. Append to the profile's `cordis.patch.yml` (the user patch layer; survives reinstalls):
24
- ```yaml
25
- - insert:
26
- - id: dsh-balance
27
- name: '@yyfather/dsh-balance'
28
- ```
29
- 3. Restart DSH Desktop. The dock readout appears; click it to open the settings panel.
30
-
31
- ### Requirements
32
-
33
- - Host: `webServer`, `credentials` (store the DeepSeek key in Settings → Models, default ref `DEEPSEEK_API_KEY`), `sessions` / `sessionQuery`, `timer`
34
- - Client: `slots` (`conversation.composer.dock`), React
35
- - Node ≥ 20 (native fetch)
36
-
37
- ## Host config (overridable in the plugin row)
38
-
39
- | Field | Default | Notes |
40
- |---|---|---|
41
- | `apiKeyRef` | `DEEPSEEK_API_KEY` | credential reference for balance queries |
42
- | `baseUrl` | `https://api.deepseek.com` | DeepSeek API root |
43
- | `timeoutMs` | `20000` | upstream timeout |
44
- | `allowRemote` | `false` | keep false; routes are loopback-only by design |
45
-
46
- Run-time pricing and alert lines are edited in the click panel (in-memory).
47
-
48
- ## Security
49
-
50
- - Credentials resolve only on the Host; the browser talks exclusively to the loopback-only `dsh-balance/api/*` same-origin routes
51
- - Responses never include upstream bodies, credentials, or unvalidated fields
52
-
53
- ## License
54
-
55
- MIT
1
+ # dsh-balance
2
+
3
+ A DeepSeek Harness plugin that shows DeepSeek / MiMo account balance and per-request conversation cost in the composer dock, with model-aware peak/off-peak pricing and spend alerts (click the dock readout to configure).
4
+
5
+ > 📦 Published on npm as `@yyfather/dsh-balance` (one-click install via the DSH plugin market)
6
+
7
+ ## Features
8
+
9
+ - **Balance**: live DeepSeek account balance (loopback-only routes; the credential never leaves the Host; hidden when the current session uses an external provider such as Xiaomi MiMo)
10
+ - **Per-request cost**: each usage sample is priced by its own request timestamp (peak/off-peak) and its own model, with the same `(turn, step)` replacement rule as the official token-usage projection
11
+ - `本会话 / this conversation` = full cost of the current session since its creation
12
+ - `本次活跃 / active period` = cost of requests since this plugin instance started
13
+ - `最近一次 / last request` = cost of the most recent request
14
+ - `上次对话 / previous conversation` = cost of the immediately preceding session (MiMo sessions converted via a configurable USD rate)
15
+ - **Model price table**: DeepSeek V4 Flash / V4 Flash Vision Exp / V4 Pro (official CNY, off-peak/peak tiers) and Xiaomi MiMo V2.5 family (USD, editable), editable per model + tier in the click panel; USD entries converted at a configurable rate
16
+ - **Alerts**: orange pill badge when active-period spend ≥ spend line (default ¥1) or DeepSeek balance < balance line (default ¥10); both editable in the panel
17
+ - **Refresh**: after each conversation turn and every 5 minutes (toggleable)
18
+
19
+ ## Installation
20
+
21
+ ### Option 1: one-click via the plugin market (recommended)
22
+
23
+ Once the plugin appears in the market (Settings → Plugin Market), open its card in the **Installable** tab to use DSH's managed installer (npm identity verification + config snapshots + boot verification).
24
+
25
+ ### Option 2: manual
26
+
27
+ 1. Clone into the profile dependency folder (`$DSH_HOME/profiles/<name>/node_modules/@yyfather/dsh-balance`):
28
+ ```sh
29
+ git clone https://github.com/YYfather/dsh-balance.git "$HOME/.dsh/profiles/node_modules/@yyfather/dsh-balance"
30
+ ```
31
+ 2. Append to the profile's `cordis.patch.yml` (the user patch layer; survives reinstalls):
32
+ ```yaml
33
+ - insert:
34
+ - id: dsh-balance
35
+ name: '@yyfather/dsh-balance'
36
+ ```
37
+ 3. Restart DSH Desktop. The dock readout appears; click it to open the settings panel.
38
+
39
+ ### Requirements
40
+
41
+ - Host: `webServer`, `credentials` (store the DeepSeek key in Settings → Models, default ref `DEEPSEEK_API_KEY`), `sessions` / `sessionQuery`, `timer`
42
+ - Client: `slots` (`conversation.composer.dock`), React
43
+ - Node 20 (native fetch)
44
+
45
+ ## Host config (overridable in the plugin row)
46
+
47
+ | Field | Default | Notes |
48
+ |---|---|---|
49
+ | `apiKeyRef` | `DEEPSEEK_API_KEY` | credential reference for balance queries |
50
+ | `baseUrl` | `https://api.deepseek.com` | DeepSeek API root |
51
+ | `timeoutMs` | `20000` | upstream timeout |
52
+ | `allowRemote` | `false` | keep false; routes are loopback-only by design |
53
+
54
+ Run-time pricing and alert lines are edited in the click panel (in-memory).
55
+
56
+ ## Security
57
+
58
+ - Credentials resolve only on the Host; the browser talks exclusively to the loopback-only `dsh-balance/api/*` same-origin routes
59
+ - Responses never include upstream bodies, credentials, or unvalidated fields
60
+
61
+ ## License
62
+
63
+ MIT