dsh-model-allowance 0.0.0-stage → 1.0.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 +147 -2
- package/README.zh.md +128 -0
- package/client.js +1897 -0
- package/cordis.patch.yml +3 -0
- package/icon.svg +7 -0
- package/index.js +457 -0
- package/lib/balance.js +413 -0
- package/lib/credentials.js +174 -0
- package/lib/debug.js +70 -0
- package/lib/providers/deepseek.js +408 -0
- package/lib/providers/kimi.js +474 -0
- package/lib/providers/minimax.js +383 -0
- package/lib/providers/opencode.js +209 -0
- package/lib/providers/schedule.js +153 -0
- package/lib/providers/shared.js +324 -0
- package/lib/providers/status.js +133 -0
- package/lib/providers/zhipu.js +185 -0
- package/lib/providers.js +112 -0
- package/lib/remote.js +214 -0
- package/lib/status.js +196 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +82 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MeiK2333
|
|
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,3 +1,148 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-model-allowance
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[中文](README.zh.md)
|
|
4
|
+
|
|
5
|
+
Shows the balance or remaining allowance of the provider behind the current
|
|
6
|
+
conversation model, right beside the composer in DeepSeek Harness.
|
|
7
|
+
|
|
8
|
+
## Why
|
|
9
|
+
|
|
10
|
+
DSH's account page only shows your official DeepSeek account balance. Switch a
|
|
11
|
+
session to a third-party provider such as MiniMax or Zhipu, and nothing on
|
|
12
|
+
screen tells you how much allowance is left. This plugin fills that gap with a
|
|
13
|
+
badge that follows the session's model and reads that provider's balance or
|
|
14
|
+
plan allowance.
|
|
15
|
+
|
|
16
|
+
## Features
|
|
17
|
+
|
|
18
|
+
- A badge beside the model selector follows the session's model: a money
|
|
19
|
+
balance (e.g. `¥46.71`) for DeepSeek, remaining percent or time for coding plans.
|
|
20
|
+
A plan with several windows speaks through the shortest one (the 5-hour
|
|
21
|
+
window on coding plans), and shows `0%` as soon as any window runs out.
|
|
22
|
+
MiniMax reports one bucket per model; the session's model picks the bucket,
|
|
23
|
+
with the canonical `general` plan as the fallback
|
|
24
|
+
- Refreshes automatically after every turn, briefly showing the change
|
|
25
|
+
(e.g. `↓0.90`)
|
|
26
|
+
- Click the badge for details: per-window progress bars, reset countdowns,
|
|
27
|
+
manual refresh, and a link to the provider's console
|
|
28
|
+
- Switch between the providers configured on this machine; ones without a
|
|
29
|
+
credential stay out of the way
|
|
30
|
+
- Shows the provider's own platform status, read from its official status
|
|
31
|
+
page, so a bad reading can be told apart from a bad day: the dot on the
|
|
32
|
+
badge is green while the service is available, red when its status page
|
|
33
|
+
says otherwise, and grey when no status source exists for the route
|
|
34
|
+
- Vendors that price by the wall clock get a schedule block: DeepSeek's peak
|
|
35
|
+
windows (weekdays 09:00–12:00 and 14:00–18:00 Beijing time, holidays
|
|
36
|
+
excluded) and Zhipu's (weekdays 14:00–18:00), the phase the clock is in
|
|
37
|
+
now, and a live countdown to the flip
|
|
38
|
+
- Credentials never leave the host process — the web UI only ever sees readings
|
|
39
|
+
|
|
40
|
+
## Supported providers
|
|
41
|
+
|
|
42
|
+
| Provider | Shows | Credential |
|
|
43
|
+
| --------------------- | ------------------------------ | --------------------------- |
|
|
44
|
+
| DeepSeek account | Balance | none (DSH login) |
|
|
45
|
+
| DeepSeek API key | Balance | `DEEPSEEK_API_KEY` |
|
|
46
|
+
| MiniMax coding plan | 5-hour + weekly allowance | `MINIMAX_CN_API_KEY` |
|
|
47
|
+
| Zhipu coding plan | 5-hour + weekly quota | `ZAI_API_KEY` / `ZAI_CODING_CN_API_KEY` |
|
|
48
|
+
| Kimi for Coding | weekly + 5-hour allowance | `KIMI_API_KEY` |
|
|
49
|
+
| OpenCode Go | 5-hour + weekly + monthly | `OPENCODE_API_KEY` / `OPENCODE_GO_API_KEY` |
|
|
50
|
+
|
|
51
|
+
The plugin reuses the credentials DSH already has: it asks the harness which
|
|
52
|
+
credential each provider route uses, so if these keys are configured, it works
|
|
53
|
+
out of the box — including routes whose profile names a non-default
|
|
54
|
+
`apiKeyEnv`. The names above are the defaults.
|
|
55
|
+
|
|
56
|
+
Platform status comes from the vendors' own pages where they publish one:
|
|
57
|
+
DeepSeek (`status.deepseek.com`), MiniMax (`status.minimaxi.com`),
|
|
58
|
+
Moonshot/Kimi (`status.moonshot.cn`), and OpenCode (`status.opencode.ai`).
|
|
59
|
+
Zhipu publishes no machine-readable status page, so its card shows no status
|
|
60
|
+
row.
|
|
61
|
+
|
|
62
|
+
## Installation
|
|
63
|
+
|
|
64
|
+
### Requirements
|
|
65
|
+
|
|
66
|
+
- DeepSeek Harness `>=0.2.1-rc.5 <0.3.0`.
|
|
67
|
+
- Credentials for the providers you want to see, configured in DSH:
|
|
68
|
+
DeepSeek login or `DEEPSEEK_API_KEY`, `MINIMAX_CN_API_KEY`,
|
|
69
|
+
`ZAI_API_KEY` / `ZAI_CODING_CN_API_KEY`, `KIMI_API_KEY`, and
|
|
70
|
+
`OPENCODE_API_KEY` / `OPENCODE_GO_API_KEY`.
|
|
71
|
+
|
|
72
|
+
### Install from npm (recommended)
|
|
73
|
+
|
|
74
|
+
1. Open the **Plugins** page in the DSH sidebar.
|
|
75
|
+
2. Choose **Install** and enter:
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
dsh-model-allowance@1.0.0
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Use the latest published version instead of `1.0.0` when a newer one
|
|
82
|
+
exists.
|
|
83
|
+
3. Confirm the installation. If DSH reports **restart required**, restart
|
|
84
|
+
DSH; otherwise refresh the page.
|
|
85
|
+
|
|
86
|
+
The npm installation is eligible for the Plugin Manager's **Update** action.
|
|
87
|
+
|
|
88
|
+
### Install from GitHub
|
|
89
|
+
|
|
90
|
+
A tagged GitHub release is an alternative when npm is unavailable:
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
git+https://github.com/MeiK2333/dsh-model-allowance.git#v1.0.0
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Git installations are not covered by the Plugin Manager's **Update** action.
|
|
97
|
+
Install the new tag after removing the old version.
|
|
98
|
+
|
|
99
|
+
### Update
|
|
100
|
+
|
|
101
|
+
- **npm install**: use **Update** on the Plugins page, or install the new
|
|
102
|
+
exact version.
|
|
103
|
+
- **GitHub install**: remove the bundle, then install the new tag.
|
|
104
|
+
|
|
105
|
+
### Uninstall
|
|
106
|
+
|
|
107
|
+
Open the **Plugins** page, select this bundle, and choose **Remove**. Restart
|
|
108
|
+
DSH if the page asks for it.
|
|
109
|
+
|
|
110
|
+
### Local development
|
|
111
|
+
|
|
112
|
+
Install the checkout directly:
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
link:F:\DSH\model-balance-plugin
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
After changing Host code, restart DSH; after changing client code, run
|
|
119
|
+
`npm run build` and refresh the page.
|
|
120
|
+
|
|
121
|
+
## Development
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
npm ci
|
|
125
|
+
npm test # node:test unit tests plus the integration verifiers
|
|
126
|
+
npm run typecheck # tsc --checkJs over the Host half and the Client's pure modules
|
|
127
|
+
npm run lint # Biome
|
|
128
|
+
npm run build # regenerate client.js from src/client
|
|
129
|
+
npm run check:dist # fail when client.js is out of date with its source
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
The browser half is authored under `src/client/` and built into `client.js` by
|
|
133
|
+
`tools/build-client.mjs`. The built file is committed because DSH installs the
|
|
134
|
+
package directly; `check:dist` keeps it honest.
|
|
135
|
+
|
|
136
|
+
Provider fixtures are part of each adapter, and `npm test` fails when
|
|
137
|
+
DeepSeek's statutory-holiday list no longer covers the current year — extend
|
|
138
|
+
`SCHEDULE.holidays` in `lib/providers/deepseek.js` when the next notice is
|
|
139
|
+
published.
|
|
140
|
+
|
|
141
|
+
## Compatibility
|
|
142
|
+
|
|
143
|
+
DeepSeek Harness `>=0.2.1-rc.5 <0.3.0`.
|
|
144
|
+
|
|
145
|
+
## License
|
|
146
|
+
|
|
147
|
+
[MIT](LICENSE). Provider icons are trademarks of their respective owners,
|
|
148
|
+
used only to identify them.
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# dsh-model-allowance
|
|
2
|
+
|
|
3
|
+
[English](README.md)
|
|
4
|
+
|
|
5
|
+
在 DeepSeek Harness 输入框旁,显示当前会话所用模型对应厂商的余额或剩余额度。
|
|
6
|
+
|
|
7
|
+
## 为什么
|
|
8
|
+
|
|
9
|
+
DSH 自带的账户页只显示 DeepSeek 官方账号余额。会话切到 MiniMax、智谱等第三方
|
|
10
|
+
厂商时,界面上没有任何地方能看到正在消耗的额度。这个插件补上这一块:一个跟随
|
|
11
|
+
会话模型的徽标,读取该厂商的余额或套餐剩余额度。
|
|
12
|
+
|
|
13
|
+
## 功能
|
|
14
|
+
|
|
15
|
+
- 徽标位于模型选择器旁,跟随当前会话的模型:DeepSeek 显示余额(如 `¥46.71`),
|
|
16
|
+
Coding Plan 显示剩余百分比或剩余时长;多窗口套餐以最短窗口(编程套餐的
|
|
17
|
+
5 小时窗)为准,任一窗口耗尽即显示 `剩余 0%`;MiniMax 按会话模型匹配
|
|
18
|
+
`model_remains` 条目,未匹配时优先 `general` 计划
|
|
19
|
+
- 每轮对话结束自动刷新,并短暂显示读数的变化(如 `↓0.90`)
|
|
20
|
+
- 点击徽章查看详情:分窗口进度条、重置倒计时、手动刷新、直达厂商控制台
|
|
21
|
+
- 可切换查看本机已配置的其他厂商;未配置凭证的厂商不会出现
|
|
22
|
+
- 显示厂商官方的平台状态(读取其状态页),把"读数拿不到"和"平台故障"区分开来:
|
|
23
|
+
徽章左侧圆点绿色表示服务可用,红色表示状态页报告异常;无状态源的路由显示灰点
|
|
24
|
+
- 按时段定价的厂商(DeepSeek:工作日 9:00–12:00、14:00–18:00 为高峰,法定节假日
|
|
25
|
+
除外;智谱:工作日 14:00–18:00 为高峰)在卡片上显示时段表、当前处于高峰还是
|
|
26
|
+
低谷,以及距离切换的实时倒计时
|
|
27
|
+
- 凭证只在本机进程内使用,网页端只看到读数
|
|
28
|
+
|
|
29
|
+
## 支持的厂商
|
|
30
|
+
|
|
31
|
+
| 厂商 | 显示内容 | 凭证 |
|
|
32
|
+
| ------------------- | -------------------------- | --------------------------- |
|
|
33
|
+
| DeepSeek 账号 | 余额 | 无需配置(DSH 登录) |
|
|
34
|
+
| DeepSeek API Key | 余额 | `DEEPSEEK_API_KEY` |
|
|
35
|
+
| MiniMax Coding Plan | 5 小时窗 + 每周窗剩余额度 | `MINIMAX_CN_API_KEY` |
|
|
36
|
+
| 智谱 Coding Plan | 5 小时窗 + 每周窗剩余配额 | `ZAI_API_KEY` / `ZAI_CODING_CN_API_KEY` |
|
|
37
|
+
| Kimi for Coding | 每周窗 + 5 小时窗剩余额度 | `KIMI_API_KEY` |
|
|
38
|
+
| OpenCode Go | 5 小时窗 + 每周窗 + 每月窗 | `OPENCODE_API_KEY` / `OPENCODE_GO_API_KEY` |
|
|
39
|
+
|
|
40
|
+
插件复用 DSH 已有的凭证配置:它会向 harness 询问每条厂商路由用的是哪个凭证,
|
|
41
|
+
这些 Key 只要配过,装完即用;profile 里自定义了 `apiKeyEnv` 的路由也能覆盖。
|
|
42
|
+
上表列出的是默认凭证名。
|
|
43
|
+
|
|
44
|
+
平台状态取自各厂商自己的状态页:DeepSeek(`status.deepseek.com`)、
|
|
45
|
+
MiniMax(`status.minimaxi.com`)、Moonshot/Kimi(`status.moonshot.cn`)、
|
|
46
|
+
OpenCode(`status.opencode.ai`);智谱没有机器可读的状态页,其卡片不显示状态行。
|
|
47
|
+
|
|
48
|
+
## 安装
|
|
49
|
+
|
|
50
|
+
### 前置条件
|
|
51
|
+
|
|
52
|
+
- DeepSeek Harness `>=0.2.1-rc.5 <0.3.0`。
|
|
53
|
+
- 需要在 DSH 中配置好要查看的厂商凭证:
|
|
54
|
+
DeepSeek 登录或 `DEEPSEEK_API_KEY`、`MINIMAX_CN_API_KEY`、
|
|
55
|
+
`ZAI_API_KEY` / `ZAI_CODING_CN_API_KEY`、`KIMI_API_KEY`、
|
|
56
|
+
`OPENCODE_API_KEY` / `OPENCODE_GO_API_KEY`。
|
|
57
|
+
|
|
58
|
+
### 从 npm 安装(推荐)
|
|
59
|
+
|
|
60
|
+
1. 打开 DSH 侧边栏的 **Plugins(插件)** 页面。
|
|
61
|
+
2. 点击 **Install(安装)**,填入:
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
dsh-model-allowance@1.0.0
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
如果已有更新版本,请把 `1.0.0` 换成最新的精确版本。
|
|
68
|
+
3. 确认安装。如果 DSH 提示需要重启,重启 DSH;否则刷新页面即可。
|
|
69
|
+
|
|
70
|
+
通过 npm 安装的版本可以在 Plugin Manager 中使用 **Update** 更新。
|
|
71
|
+
|
|
72
|
+
### 从 GitHub 安装
|
|
73
|
+
|
|
74
|
+
npm 不可用时,可以安装打了 tag 的 GitHub Release:
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
git+https://github.com/MeiK2333/dsh-model-allowance.git#v1.0.0
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Git 安装不受 Plugin Manager 的 **Update** 管理;更新时需要先移除旧版本,
|
|
81
|
+
再安装新的 tag。
|
|
82
|
+
|
|
83
|
+
### 更新
|
|
84
|
+
|
|
85
|
+
- **npm 安装**:在 Plugins 页面点击 **Update**,或安装新的精确版本。
|
|
86
|
+
- **GitHub 安装**:移除旧 bundle,再安装新的 tag。
|
|
87
|
+
|
|
88
|
+
### 卸载
|
|
89
|
+
|
|
90
|
+
打开 **Plugins(插件)** 页面,选中该 bundle,点击 **Remove**。如果提示
|
|
91
|
+
需要重启,重启 DSH。
|
|
92
|
+
|
|
93
|
+
### 本地开发
|
|
94
|
+
|
|
95
|
+
直接链接本地目录:
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
link:F:\DSH\model-balance-plugin
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
修改 Host 代码后重启 DSH;修改 Client 代码后执行 `npm run build` 并刷新页面。
|
|
102
|
+
|
|
103
|
+
## 开发
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
npm ci
|
|
107
|
+
npm test # node:test 单元测试 + 集成验证脚本
|
|
108
|
+
npm run typecheck # 对 Host 半侧和 Client 纯逻辑模块执行 tsc --checkJs
|
|
109
|
+
npm run lint # Biome
|
|
110
|
+
npm run build # 从 src/client 重新生成 client.js
|
|
111
|
+
npm run check:dist # client.js 与源码不一致时失败
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
浏览器半侧在 `src/client/` 下编写,由 `tools/build-client.mjs` 构建为
|
|
115
|
+
`client.js`。DSH 直接安装该包,所以构建产物需要提交;`check:dist` 保证它
|
|
116
|
+
不会悄悄过期。
|
|
117
|
+
|
|
118
|
+
各厂商的 fixture 随适配器一起维护;当 DeepSeek 的法定节假日列表不再覆盖
|
|
119
|
+
当前年份时,`npm test` 会失败——下一份通知发布后更新
|
|
120
|
+
`lib/providers/deepseek.js` 的 `SCHEDULE.holidays` 即可。
|
|
121
|
+
|
|
122
|
+
## 兼容性
|
|
123
|
+
|
|
124
|
+
DeepSeek Harness `>=0.2.1-rc.5 <0.3.0`。
|
|
125
|
+
|
|
126
|
+
## 许可
|
|
127
|
+
|
|
128
|
+
[MIT](LICENSE)。各厂商图标为其所有者的商标,仅用于标识对应厂商。
|