dsh-model-allowance 1.0.0 → 1.0.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/README.md +14 -108
- package/README.zh.md +12 -90
- package/client.js +4 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,71 +3,21 @@
|
|
|
3
3
|
[中文](README.zh.md)
|
|
4
4
|
|
|
5
5
|
Shows the balance or remaining allowance of the provider behind the current
|
|
6
|
-
conversation model
|
|
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.
|
|
6
|
+
conversation model.
|
|
61
7
|
|
|
62
|
-
##
|
|
8
|
+
## Supported
|
|
9
|
+
|
|
10
|
+
- DeepSeek
|
|
11
|
+
- MiniMax Coding Plan
|
|
12
|
+
- Zhipu Coding Plan
|
|
13
|
+
- Kimi for Coding
|
|
14
|
+
- OpenCode Go
|
|
63
15
|
|
|
64
|
-
###
|
|
16
|
+
### Not supported
|
|
65
17
|
|
|
66
|
-
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
`ZAI_API_KEY` / `ZAI_CODING_CN_API_KEY`, `KIMI_API_KEY`, and
|
|
70
|
-
`OPENCODE_API_KEY` / `OPENCODE_GO_API_KEY`.
|
|
18
|
+
- Qwen Token Plan: the vendor publishes no balance API
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
71
21
|
|
|
72
22
|
### Install from npm (recommended)
|
|
73
23
|
|
|
@@ -87,56 +37,12 @@ The npm installation is eligible for the Plugin Manager's **Update** action.
|
|
|
87
37
|
|
|
88
38
|
### Install from GitHub
|
|
89
39
|
|
|
90
|
-
A tagged GitHub release is an alternative when npm is unavailable:
|
|
91
|
-
|
|
92
40
|
```
|
|
93
41
|
git+https://github.com/MeiK2333/dsh-model-allowance.git#v1.0.0
|
|
94
42
|
```
|
|
95
43
|
|
|
96
|
-
Git installations are not covered by the Plugin Manager's **Update** action
|
|
97
|
-
|
|
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.
|
|
44
|
+
Git installations are not covered by the Plugin Manager's **Update** action;
|
|
45
|
+
updating means removing the old version first, then installing the new tag.
|
|
140
46
|
|
|
141
47
|
## Compatibility
|
|
142
48
|
|
package/README.zh.md
CHANGED
|
@@ -2,58 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
[English](README.md)
|
|
4
4
|
|
|
5
|
-
|
|
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`);智谱没有机器可读的状态页,其卡片不显示状态行。
|
|
5
|
+
显示当前会话所用模型对应厂商的余额或剩余额度。
|
|
47
6
|
|
|
48
|
-
##
|
|
7
|
+
## 支持
|
|
8
|
+
|
|
9
|
+
- DeepSeek
|
|
10
|
+
- MiniMax Coding Plan
|
|
11
|
+
- 智谱 Coding Plan
|
|
12
|
+
- Kimi for Coding
|
|
13
|
+
- OpenCode Go
|
|
49
14
|
|
|
50
|
-
###
|
|
15
|
+
### 不支持
|
|
51
16
|
|
|
52
|
-
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
`ZAI_API_KEY` / `ZAI_CODING_CN_API_KEY`、`KIMI_API_KEY`、
|
|
56
|
-
`OPENCODE_API_KEY` / `OPENCODE_GO_API_KEY`。
|
|
17
|
+
- 千问 Token Plan:官方未提供余额接口
|
|
18
|
+
|
|
19
|
+
## 安装
|
|
57
20
|
|
|
58
21
|
### 从 npm 安装(推荐)
|
|
59
22
|
|
|
@@ -71,8 +34,6 @@ OpenCode(`status.opencode.ai`);智谱没有机器可读的状态页,其
|
|
|
71
34
|
|
|
72
35
|
### 从 GitHub 安装
|
|
73
36
|
|
|
74
|
-
npm 不可用时,可以安装打了 tag 的 GitHub Release:
|
|
75
|
-
|
|
76
37
|
```
|
|
77
38
|
git+https://github.com/MeiK2333/dsh-model-allowance.git#v1.0.0
|
|
78
39
|
```
|
|
@@ -80,45 +41,6 @@ git+https://github.com/MeiK2333/dsh-model-allowance.git#v1.0.0
|
|
|
80
41
|
Git 安装不受 Plugin Manager 的 **Update** 管理;更新时需要先移除旧版本,
|
|
81
42
|
再安装新的 tag。
|
|
82
43
|
|
|
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
44
|
## 兼容性
|
|
123
45
|
|
|
124
46
|
DeepSeek Harness `>=0.2.1-rc.5 <0.3.0`。
|
package/client.js
CHANGED
|
@@ -1501,11 +1501,10 @@ function BalanceBadge(props) {
|
|
|
1501
1501
|
style: { width: `${String(filled)}%` }
|
|
1502
1502
|
})
|
|
1503
1503
|
),
|
|
1504
|
-
// A window
|
|
1505
|
-
//
|
|
1506
|
-
//
|
|
1507
|
-
|
|
1508
|
-
typeof window.resetAt === "number" ? (0, import_react3.createElement)(
|
|
1504
|
+
// A window with zero usage has not started its rolling timer
|
|
1505
|
+
// yet, so the countdown would be misleading. Hide it until
|
|
1506
|
+
// consumption begins.
|
|
1507
|
+
typeof window.resetAt === "number" && (typeof window.remainingPercent !== "number" || window.remainingPercent < 100) ? (0, import_react3.createElement)(
|
|
1509
1508
|
"div",
|
|
1510
1509
|
{ className: "dsh-model-allowance-foot" },
|
|
1511
1510
|
(0, import_react3.createElement)(
|