@jxgame2020/dsh-token-quota 0.1.4 → 0.1.5

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 jxgame2020
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,34 +1,38 @@
1
1
  # @jxgame2020/dsh-token-quota
2
2
 
3
- DeepSeek Harness 的**每日按模型 Token 限额**插件:后端按模型累计当日 token 用量并持久化、
4
- 达到上限时拦截请求;前端在 Web UI 右侧提供浮窗,实时显示每个被监控模型的
5
- 「实际/上限」,可对每个模型单独设置限额,满额时一键或自动切换模型。
3
+ DeepSeek Harness 的**每日按模型 Token 限额**插件:后端按模型累计当日 token 用量并持久化、达到上限时拦截请求;前端在 Web UI 右侧提供浮窗,实时显示每个被监控模型的「实际/上限」,可对每个模型单独设置限额,满额时一键或自动切换模型。
6
4
 
7
- DSH 核心仓库**零改动**:不修改任何核心文件、不挂载官方 bundle、不依赖转发事件
8
- 白名单;数据通过插件自有的 HTTP 路由(`GET /token-quota`)轮询读取,配置通过
9
- settings 的 `token-quota` 命名空间读写。
5
+ A daily per-model token quota plugin for the DeepSeek Harness: the host counts each model's token usage for the day (persisted), blocks requests once a cap is reached, and a floating panel on the right side of the Web UI shows live usage/limit per monitored model, lets you set per-model caps, and switches models in one click or automatically when a model is full.
10
6
 
11
- ## 功能
7
+ DSH 核心仓库**零改动**:不修改任何核心文件、不挂载官方 bundle、不依赖转发事件白名单;数据通过插件自有的 HTTP 路由(`GET /token-quota`)轮询读取,配置通过 settings 的 `token-quota` 命名空间读写。
12
8
 
13
- - **按模型独立计数**:输入 + 输出 + 缓存 token 全部计入当日用量;重启不丢
14
- (持久化到 `$DSH_HOME/token-quota.json`)。
9
+ Zero changes to the DSH core repo: no core file is modified, no official bundle is mounted, and no forwarded-event allowlist is required. The panel polls a plugin-owned HTTP route (`GET /token-quota`), and configuration lives in the `token-quota` settings namespace.
10
+
11
+ ## 功能 / Features
12
+
13
+ - **按模型独立计数**:输入 + 输出 + 缓存 token 全部计入当日用量;重启不丢(持久化到 `$DSH_HOME/token-quota.json`)。
14
+ **Per-model counting**: input + output + cache tokens all count toward the daily usage, persisted to `$DSH_HOME/token-quota.json` across restarts.
15
15
  - **硬拦截**:达到上限后请求直接停止并提示切换,不会继续消耗额度。
16
- - **满额策略**(四选一,面板设置里切换,即时生效):
17
- - 停止请求并提示
18
- - 自动切换到其它已监控且未满的限额模型
19
- - 自动切换到其它任意可用模型(含非限额)
20
- - 自动切换(优先非限额,其次未监控)
21
- - **每日自动重置**:默认本机时区午夜;可在设置里改为任意时区(UTC−12 ~ +14)
22
- 与时刻(0:00–23:55),到点清零当日计数并归档用量日志。
16
+ **Hard enforcement**: once a cap is hit, requests are stopped and you are prompted to switch — no extra tokens are spent.
17
+ - **满额策略**(四选一,面板设置里切换,即时生效)/ **Full-quota strategy** (pick one in the panel settings; applies immediately):
18
+ - 停止请求并提示 / Stop and prompt
19
+ - 自动切换到其它已监控且未满的限额模型 / Auto-switch to another monitored, capped-but-available model
20
+ - 自动切换到其它任意可用模型(含非限额)/ Auto-switch to any other available model (incl. uncapped)
21
+ - 自动切换(优先非限额,其次未监控)/ Prefer uncapped models, then unmonitored ones
22
+ - **每日自动重置**:默认本机时区午夜;可在设置里改为任意时区(UTC−12 ~ +14)与时刻(0:00–23:55),到点清零当日计数并归档用量日志。
23
+ **Daily auto-reset**: defaults to local midnight; pick any timezone (UTC−12 ~ +14) and time (0:00–23:55) in settings — counters reset and the finished day is archived into the usage log.
23
24
  - **用量日志**:每模型每天一条(日期 / 模型 / 用量),与监控勾选无关。
24
- - **浮窗面板**:实时显示各模型「今日已用 / 上限」,行内一键「选择」切换模型、
25
- `⚙` 折叠设置单模型限额。
25
+ **Usage log**: one row per model per day (date / model / usage), independent of the monitored set.
26
+ - **浮窗面板**:实时显示各模型「今日已用 / 上限」,行内一键「选择」切换模型、`⚙` 折叠设置单模型限额。
27
+ **Floating panel**: live used/limit per model, a one-click Select button per row, and a folded `⚙` per-model limit editor.
28
+
29
+ ## 安装 / Installation
26
30
 
27
- ## 安装
31
+ ### 方式一:npm 安装(推荐)/ Option A: npm install (recommended)
28
32
 
29
- ### 方式一:npm 安装(推荐)
33
+ 在你的 web profile(`~/.dsh/profiles/web`)下安装依赖:
30
34
 
31
- 在你的 web profile(`~/.dsh/profiles/web`)下:
35
+ Install the dependency in your web profile (`~/.dsh/profiles/web`):
32
36
 
33
37
  ```bash
34
38
  cd ~/.dsh/profiles/web
@@ -36,9 +40,12 @@ npm install @jxgame2020/dsh-token-quota
36
40
  ```
37
41
 
38
42
  > 用 pnpm 管理 profile 的话:`pnpm add @jxgame2020/dsh-token-quota`。
43
+ > With pnpm: `pnpm add @jxgame2020/dsh-token-quota`.
39
44
 
40
45
  在 `cordis.patch.yml` 中挂载插件:
41
46
 
47
+ Mount the plugin in `cordis.patch.yml`:
48
+
42
49
  ```yaml
43
50
  - insert:
44
51
  - id: token-quota
@@ -47,87 +54,83 @@ npm install @jxgame2020/dsh-token-quota
47
54
 
48
55
  重启 `dsh web`,浏览器右侧出现「每日 Token 限额」浮窗即安装成功。
49
56
 
50
- ### 方式二:从 GitHub 源码安装
57
+ Restart `dsh web`; the floating panel appears on the right side once installed.
58
+
59
+ ### 方式二:从 GitHub 源码安装 / Option B: install from source (GitHub)
60
+
61
+ 适合想改源码、离线分发或审阅代码的情况。源码仓库不提交构建产物(`lib/`),clone 后需在本机构建(工具链来自 DSH 仓库的 workspace)。
51
62
 
52
- 适合想改源码、离线分发或审阅代码的情况。源码仓库不提交构建产物(`lib/`),
53
- clone 后需在本机构建(工具链来自 DSH 仓库的 workspace)。
63
+ For modifying the source, offline distribution, or code review. The source repo does not ship build output (`lib/`); clone and build locally (the toolchain resolves from the DSH repo workspace).
54
64
 
55
- 1. 克隆到与 `deepseek-harness` 同级的开发目录:
65
+ 1. 克隆到与 `deepseek-harness` 同级的开发目录 / Clone next to your `deepseek-harness` checkout:
56
66
 
57
67
  ```bash
58
68
  git clone https://github.com/jxgame/dsh-token-quota.git deepseek-harness-package/dsh-token-quota
59
69
  ```
60
70
 
61
- 2. 在 `deepseek-harness/pnpm-workspace.yaml` 的 `packages:` 下注册该包(让它的
62
- peer 依赖从仓库 workspace 解析):
71
+ 2. 在 `deepseek-harness/pnpm-workspace.yaml` 的 `packages:` 下注册该包(让 peer 依赖从仓库 workspace 解析)/ Register the package under `packages:` in `deepseek-harness/pnpm-workspace.yaml` so peer deps resolve from the repo workspace:
63
72
 
64
73
  ```yaml
65
74
  packages:
66
75
  - ../deepseek-harness-package/dsh-token-quota/packages/token-quota
67
76
  ```
68
77
 
69
- 然后在仓库根执行 `cd deepseek-harness && pnpm install`。
78
+ 然后在仓库根执行 `cd deepseek-harness && pnpm install`。/ Then run `cd deepseek-harness && pnpm install`.
70
79
 
71
- 3. 构建:
80
+ 3. 构建 / Build:
72
81
 
73
82
  ```bash
74
83
  cd deepseek-harness-package/dsh-token-quota/packages/token-quota
75
- pnpm exec tsc -p tsconfig.json # 类型检查 + 产出 lib/types
84
+ pnpm exec tsc -p tsconfig.json # 类型检查 + 产出 lib/types / type-check + emit lib/types
76
85
  pnpm exec tsdown # 产出 lib/index.js + lib/client.js
77
86
  ```
78
87
 
79
- 4. 挂载到 profile:`~/.dsh/profiles/web/package.json` 的 dependencies 使用本地路径:
88
+ 4. 挂载到 profile:`~/.dsh/profiles/web/package.json` 的 dependencies 使用本地路径 / Mount into the profile with a local path dependency:
80
89
 
81
90
  ```json
82
- "@jxgame2020/dsh-token-quota": "link:/<绝对路径>/deepseek-harness-package/dsh-token-quota/packages/token-quota"
91
+ "@jxgame2020/dsh-token-quota": "link:/<absolute-path>/deepseek-harness-package/dsh-token-quota/packages/token-quota"
83
92
  ```
84
93
 
85
- 然后 `cd ~/.dsh/profiles/web && pnpm install`;`cordis.patch.yml` 挂载与
86
- 方式一相同;重启 `dsh web`。
94
+ 然后 `cd ~/.dsh/profiles/web && pnpm install`;`cordis.patch.yml` 挂载与方式一相同;重启 `dsh web`。/ Then `cd ~/.dsh/profiles/web && pnpm install`; the `cordis.patch.yml` mount is the same as Option A; restart `dsh web`.
87
95
 
88
- ## 使用
96
+ ## 使用 / Usage
89
97
 
90
- - 头部「设置」弹窗(改动即时自动保存,右上角 × 关闭)
91
- - **监控模型**:勾选要监控的模型(默认全部)。未勾选的模型不显示、
92
- 不计入当日用量、不受限额拦截(切换时仍可选)。
93
- - **满额后处理**:四选一(见上文「功能」)。
94
- - **每日重置时间**:时区(UTC−12 ~ UTC+14)与时刻(0:00–23:55,5 分钟步进),
95
- 到点自动清零;不设置则沿用「本机时区午夜」。
96
- - 头部「日志」按钮(设置左侧):用量日志弹窗,表格列出日期 / 模型 / 用量,
97
- 每模型每天一条。
98
- - 模型行:
99
- - 名称后的「选择」按钮:一键切换当前会话到该模型。
100
- - 行尾 `⚙`:展开该行限额输入框(数字,`0`=不限),保存后收起。
101
- - 进度条:绿 <80%,黄 80–100%,红 = 已满额。
98
+ - 头部「设置」弹窗(改动即时自动保存,右上角 × 关闭)/ The header Settings dialog (changes auto-save instantly; close with × at the top-right):
99
+ - **监控模型** / **Monitored models**:勾选要监控的模型(默认全部)。未勾选的模型不显示、不计入当日用量、不受限额拦截(切换时仍可选)。/ Check the models to monitor (all by default). Unchecked models are hidden, not metered, and never capped (they remain selectable).
100
+ - **满额后处理** / **When a model is full**:四选一(见上文「功能」)。/ one of four strategies (see Features above).
101
+ - **每日重置时间** / **Daily reset**:时区(UTC−12 ~ UTC+14)与时刻(0:00–23:55,5 分钟步进),到点自动清零;不设置则沿用「本机时区午夜」。/ timezone (UTC−12 ~ UTC+14) and time (0:00–23:55, 5-min steps); defaults to machine-local midnight.
102
+ - 头部「日志」按钮(设置左侧):用量日志弹窗,表格列出日期 / 模型 / 用量,每模型每天一条。/ The Logs button (left of Settings) opens the usage-log dialog: date / model / usage, one row per model per day.
103
+ - 模型行 / Model rows:
104
+ - 名称后的「选择」按钮:一键切换当前会话到该模型。/ The Select button after the name switches the current session to that model.
105
+ - 行尾 `⚙`:展开该行限额输入框(数字,`0`=不限),保存后收起。/ The `⚙` at the row end unfolds the limit editor (number, `0` = unlimited); it folds back after saving.
106
+ - 进度条:绿 <80%,黄 80–100%,红 = 已满额。/ Progress bar: green <80%, yellow 80–100%, red = full.
102
107
 
103
- ## 数据与重置
108
+ ## 数据与重置 / Data & Reset
104
109
 
105
- - 计数文件:`$DSH_HOME/token-quota.json`(默认 `~/.dsh/token-quota.json`)。
106
- - 重置周期默认「本机时区午夜」;可改为任意时区与时刻。跨过重置时刻时当日计数
107
- 清零并归档进用量日志。
108
- - 限额与面板配置保存在 `~/.dsh/settings.yaml` `token-quota` 命名空间
109
- (`limits` / `monitored` / `onFull` / `reset`)。
110
- - 面板数据读取:`GET /token-quota`(当前快照)、`GET /token-quota/log`(历史用量)。
110
+ - 计数文件:`$DSH_HOME/token-quota.json`(默认 `~/.dsh/token-quota.json`)。/ Counter file: `$DSH_HOME/token-quota.json` (default `~/.dsh/token-quota.json`).
111
+ - 重置周期默认「本机时区午夜」;可改为任意时区与时刻。跨过重置时刻时当日计数清零并归档进用量日志。/ The reset cycle defaults to machine-local midnight and can be changed to any timezone/time; crossing the reset moment zeroes the counters and archives the finished day into the usage log.
112
+ - 限额与面板配置保存在 `~/.dsh/settings.yaml` 的 `token-quota` 命名空间(`limits` / `monitored` / `onFull` / `reset`)。/ Limits and panel preferences live in the `token-quota` namespace of `~/.dsh/settings.yaml` (`limits` / `monitored` / `onFull` / `reset`).
113
+ - 面板数据读取:`GET /token-quota`(当前快照)、`GET /token-quota/log`(历史用量)。/ Panel data endpoints: `GET /token-quota` (live snapshot), `GET /token-quota/log` (usage history).
111
114
 
112
- ## 目录结构
115
+ ## 目录结构 / Project Structure
113
116
 
114
117
  ```
115
118
  dsh-token-quota/
116
119
  └── packages/token-quota/
117
120
  ├── src/
118
- │ ├── index.ts # Host 服务:计量/持久化/拦截/HTTP 快照路由
119
- │ ├── types.ts # 共享类型与 wire 常量
120
- │ ├── invariant.ts # 运行时守卫
121
- │ └── client/ # 浏览器面板(shell.overlay 浮窗)
122
- │ ├── index.ts # apply:轮询 + 满额策略 + 面板注册
121
+ │ ├── index.ts # Host 服务:计量/持久化/拦截/HTTP 快照路由 / host service: metering, persistence, enforcement, snapshot route
122
+ │ ├── types.ts # 共享类型与 wire 常量 / shared types and wire constants
123
+ │ ├── invariant.ts # 运行时守卫 / runtime guards
124
+ │ └── client/ # 浏览器面板(shell.overlay 浮窗)/ browser panel (shell.overlay)
125
+ │ ├── index.ts # apply:轮询 + 满额策略 + 面板注册 / polling + full-quota strategy + registration
123
126
  │ ├── TokenQuotaPanel.tsx
124
127
  │ ├── store.ts
125
128
  │ ├── locales.ts
126
129
  │ └── TokenQuotaPanel.module.css
127
- ├── tsconfig.json # host + client 一起编译
128
- └── tsdown.config.ts # host 库 + 浏览器 bundle(closure-factory
130
+ ├── tsconfig.json # host + client 一起编译 / compiles host + client
131
+ └── tsdown.config.ts # host 库 + 浏览器 bundle(closure-factory)/ host lib + browser bundle
129
132
  ```
130
133
 
131
- ## License
134
+ ## License / 许可证
132
135
 
133
136
  MIT
package/lib/client.js CHANGED
@@ -129,59 +129,59 @@ window.__ModuleLoader__.load({
129
129
  document.head.appendChild(tag);
130
130
  }
131
131
  var TokenQuotaPanel_module_css_default = {
132
- "logUsedCol": "NPLLIq_logUsedCol",
133
- "fillIdle": "NPLLIq_fillIdle",
134
- "monitorHint": "NPLLIq_monitorHint",
135
- "logScroll": "NPLLIq_logScroll",
136
- "title": "NPLLIq_title",
137
132
  "body": "NPLLIq_body",
138
- "row": "NPLLIq_row",
139
- "gearBtn": "NPLLIq_gearBtn",
140
- "monitorName": "NPLLIq_monitorName",
141
- "radioRow": "NPLLIq_radioRow",
142
- "header": "NPLLIq_header",
143
- "fillOver": "NPLLIq_fillOver",
144
- "tabLabel": "NPLLIq_tabLabel",
145
- "selectBtn": "NPLLIq_selectBtn",
146
- "input": "NPLLIq_input",
147
133
  "notice": "NPLLIq_notice",
148
- "dialogSection": "NPLLIq_dialogSection",
149
- "dialogLabel": "NPLLIq_dialogLabel",
150
- "dialogActions": "NPLLIq_dialogActions",
151
- "headerActions": "NPLLIq_headerActions",
152
- "rowName": "NPLLIq_rowName",
153
- "rowMeta": "NPLLIq_rowMeta",
154
134
  "collapse": "NPLLIq_collapse",
155
- "save": "NPLLIq_save",
156
- "resetSelect": "NPLLIq_resetSelect",
157
- "logDialog": "NPLLIq_logDialog",
158
- "dialogClose": "NPLLIq_dialogClose",
159
- "dialog": "NPLLIq_dialog",
160
- "dialogBtnPrimary": "NPLLIq_dialogBtnPrimary",
135
+ "radioRow": "NPLLIq_radioRow",
161
136
  "rowHeader": "NPLLIq_rowHeader",
162
- "controls": "NPLLIq_controls",
163
- "currentBadge": "NPLLIq_currentBadge",
164
- "tabIcon": "NPLLIq_tabIcon",
165
- "dialogHeader": "NPLLIq_dialogHeader",
166
- "tab": "NPLLIq_tab",
137
+ "dialogClose": "NPLLIq_dialogClose",
138
+ "dialogActions": "NPLLIq_dialogActions",
139
+ "logHeader": "NPLLIq_logHeader",
140
+ "monitorRow": "NPLLIq_monitorRow",
167
141
  "dialogTitle": "NPLLIq_dialogTitle",
168
- "logDayCol": "NPLLIq_logDayCol",
169
- "settingsBtn": "NPLLIq_settingsBtn",
170
- "fillWarn": "NPLLIq_fillWarn",
171
- "fullNotice": "NPLLIq_fullNotice",
172
142
  "bar": "NPLLIq_bar",
173
- "dialogBtn": "NPLLIq_dialogBtn",
143
+ "monitorHint": "NPLLIq_monitorHint",
144
+ "monitorList": "NPLLIq_monitorList",
145
+ "dialogBtnPrimary": "NPLLIq_dialogBtnPrimary",
146
+ "selectBtn": "NPLLIq_selectBtn",
147
+ "headerActions": "NPLLIq_headerActions",
174
148
  "switch": "NPLLIq_switch",
149
+ "input": "NPLLIq_input",
150
+ "logModelCol": "NPLLIq_logModelCol",
151
+ "rowName": "NPLLIq_rowName",
152
+ "fillIdle": "NPLLIq_fillIdle",
153
+ "subtitle": "NPLLIq_subtitle",
175
154
  "panel": "NPLLIq_panel",
155
+ "dialog": "NPLLIq_dialog",
156
+ "fullNotice": "NPLLIq_fullNotice",
176
157
  "headerText": "NPLLIq_headerText",
177
- "monitorRow": "NPLLIq_monitorRow",
178
- "logHeader": "NPLLIq_logHeader",
158
+ "save": "NPLLIq_save",
159
+ "rowMeta": "NPLLIq_rowMeta",
160
+ "fillOver": "NPLLIq_fillOver",
161
+ "tabIcon": "NPLLIq_tabIcon",
162
+ "header": "NPLLIq_header",
163
+ "tab": "NPLLIq_tab",
164
+ "gearBtn": "NPLLIq_gearBtn",
165
+ "dialogLabel": "NPLLIq_dialogLabel",
166
+ "monitorName": "NPLLIq_monitorName",
167
+ "dialogBtn": "NPLLIq_dialogBtn",
168
+ "dialogHeader": "NPLLIq_dialogHeader",
169
+ "logScroll": "NPLLIq_logScroll",
179
170
  "resetRow": "NPLLIq_resetRow",
180
- "monitorList": "NPLLIq_monitorList",
181
- "logTable": "NPLLIq_logTable",
182
- "subtitle": "NPLLIq_subtitle",
171
+ "currentBadge": "NPLLIq_currentBadge",
172
+ "controls": "NPLLIq_controls",
173
+ "title": "NPLLIq_title",
174
+ "logUsedCol": "NPLLIq_logUsedCol",
183
175
  "noticeError": "NPLLIq_noticeError",
184
- "logModelCol": "NPLLIq_logModelCol"
176
+ "resetSelect": "NPLLIq_resetSelect",
177
+ "row": "NPLLIq_row",
178
+ "tabLabel": "NPLLIq_tabLabel",
179
+ "dialogSection": "NPLLIq_dialogSection",
180
+ "logTable": "NPLLIq_logTable",
181
+ "logDialog": "NPLLIq_logDialog",
182
+ "logDayCol": "NPLLIq_logDayCol",
183
+ "settingsBtn": "NPLLIq_settingsBtn",
184
+ "fillWarn": "NPLLIq_fillWarn"
185
185
  };
186
186
  //#endregion
187
187
  //#region lib/types/client/TokenQuotaPanel.js
@@ -768,7 +768,8 @@ window.__ModuleLoader__.load({
768
768
  fullSwitchAll: "自动切换到其它可用模型(含非限额)",
769
769
  fullSwitchPriority: "自动切换(优先非限额,其次未监控)",
770
770
  fullNotice: "当前模型今日额度已用尽,请求已停止。请选择其它模型或调整限额。",
771
- fullSwitchFailed: "没有可切换的模型(所有限额模型均已满额)",
771
+ fullSwitchFailed: "没有可切换的模型,请手动选择其它模型或调整限额",
772
+ fullSwitchTo: "已自动切换到 {model}",
772
773
  close: "关闭",
773
774
  logs: "日志",
774
775
  logsTitle: "用量日志",
@@ -813,7 +814,8 @@ window.__ModuleLoader__.load({
813
814
  fullSwitchAll: "Switch to any other model (incl. uncapped)",
814
815
  fullSwitchPriority: "Prefer uncapped, then unmonitored",
815
816
  fullNotice: "Today’s quota for the current model is exhausted; the request was stopped. Pick another model or raise its limit.",
816
- fullSwitchFailed: "No switchable model (all quota models are full)",
817
+ fullSwitchFailed: "No switchable model pick one manually or raise a limit",
818
+ fullSwitchTo: "Auto-switched to {model}",
817
819
  close: "Close",
818
820
  logs: "Logs",
819
821
  logsTitle: "Usage Log",
@@ -868,6 +870,19 @@ window.__ModuleLoader__.load({
868
870
  return `${selection.provider}/${selection.model}`;
869
871
  };
870
872
  const isMonitoredKey = (key) => lastMonitored === null || lastMonitored.includes(key);
873
+ /** Transient auto-switch confirmation: shows for a few seconds, then clears. */
874
+ let fullNoticeTimer;
875
+ const flashFullNotice = (message) => {
876
+ if (fullNoticeTimer !== void 0) {
877
+ clearTimeout(fullNoticeTimer);
878
+ fullNoticeTimer = void 0;
879
+ }
880
+ bound?.setFullNotice(message);
881
+ fullNoticeTimer = setTimeout(() => {
882
+ bound?.setFullNotice(null);
883
+ fullNoticeTimer = void 0;
884
+ }, 6e3);
885
+ };
871
886
  /** Pick an auto-switch target for the configured strategy. */
872
887
  const pickSwitchTarget = (snapshot, currentKey) => {
873
888
  const entryByKey = new Map(snapshot.entries.map((entry) => [entry.key, entry]));
@@ -916,7 +931,7 @@ window.__ModuleLoader__.load({
916
931
  }).then(({ result }) => {
917
932
  if (result.ok) {
918
933
  lastCurrent = result.value.selected;
919
- bound?.setFullNotice(null);
934
+ flashFullNotice(t("fullSwitchTo").replace("{model}", target.model));
920
935
  pull();
921
936
  } else bound?.setFullNotice(t("fullSwitchFailed"));
922
937
  }, () => {
@@ -1013,6 +1028,7 @@ window.__ModuleLoader__.load({
1013
1028
  }).then(({ result }) => {
1014
1029
  if (result.ok) {
1015
1030
  lastCurrent = result.value.selected;
1031
+ bound?.setFullNotice(null);
1016
1032
  bound?.setDirectory(lastGroups, result.value.selected);
1017
1033
  pull();
1018
1034
  } else bound?.setError(`${result.error.code}: ${result.error.message}`);
@@ -38,6 +38,19 @@ export function apply(ctx) {
38
38
  return `${selection.provider}/${selection.model}`;
39
39
  };
40
40
  const isMonitoredKey = (key) => lastMonitored === null || lastMonitored.includes(key);
41
+ /** Transient auto-switch confirmation: shows for a few seconds, then clears. */
42
+ let fullNoticeTimer;
43
+ const flashFullNotice = (message) => {
44
+ if (fullNoticeTimer !== undefined) {
45
+ clearTimeout(fullNoticeTimer);
46
+ fullNoticeTimer = undefined;
47
+ }
48
+ bound?.setFullNotice(message);
49
+ fullNoticeTimer = setTimeout(() => {
50
+ bound?.setFullNotice(null);
51
+ fullNoticeTimer = undefined;
52
+ }, 6000);
53
+ };
41
54
  /** Pick an auto-switch target for the configured strategy. */
42
55
  const pickSwitchTarget = (snapshot, currentKey) => {
43
56
  const entryByKey = new Map(snapshot.entries.map(entry => [entry.key, entry]));
@@ -101,7 +114,7 @@ export function apply(ctx) {
101
114
  }).then(({ result }) => {
102
115
  if (result.ok) {
103
116
  lastCurrent = result.value.selected;
104
- bound?.setFullNotice(null);
117
+ flashFullNotice(t('fullSwitchTo').replace('{model}', target.model));
105
118
  pull();
106
119
  }
107
120
  else {
@@ -203,6 +216,8 @@ export function apply(ctx) {
203
216
  void connection.api.sessions.selectModel({ sessionId, provider, model }).then(({ result }) => {
204
217
  if (result.ok) {
205
218
  lastCurrent = result.value.selected;
219
+ // A manual pick clears any leftover auto-switch / exhausted notice.
220
+ bound?.setFullNotice(null);
206
221
  bound?.setDirectory(lastGroups, result.value.selected);
207
222
  // Immediately re-pull the snapshot so the previous model's final
208
223
  // usage (credited around the switch) shows without waiting 3 s.
@@ -37,6 +37,7 @@ export declare const zh: {
37
37
  fullSwitchPriority: string;
38
38
  fullNotice: string;
39
39
  fullSwitchFailed: string;
40
+ fullSwitchTo: string;
40
41
  close: string;
41
42
  logs: string;
42
43
  logsTitle: string;
@@ -84,6 +85,7 @@ export declare const en: {
84
85
  fullSwitchPriority: string;
85
86
  fullNotice: string;
86
87
  fullSwitchFailed: string;
88
+ fullSwitchTo: string;
87
89
  close: string;
88
90
  logs: string;
89
91
  logsTitle: string;
@@ -36,7 +36,8 @@ export const zh = {
36
36
  fullSwitchAll: '自动切换到其它可用模型(含非限额)',
37
37
  fullSwitchPriority: '自动切换(优先非限额,其次未监控)',
38
38
  fullNotice: '当前模型今日额度已用尽,请求已停止。请选择其它模型或调整限额。',
39
- fullSwitchFailed: '没有可切换的模型(所有限额模型均已满额)',
39
+ fullSwitchFailed: '没有可切换的模型,请手动选择其它模型或调整限额',
40
+ fullSwitchTo: '已自动切换到 {model}',
40
41
  close: '关闭',
41
42
  logs: '日志',
42
43
  logsTitle: '用量日志',
@@ -81,7 +82,8 @@ export const en = {
81
82
  fullSwitchAll: 'Switch to any other model (incl. uncapped)',
82
83
  fullSwitchPriority: 'Prefer uncapped, then unmonitored',
83
84
  fullNotice: 'Today\u2019s quota for the current model is exhausted; the request was stopped. Pick another model or raise its limit.',
84
- fullSwitchFailed: 'No switchable model (all quota models are full)',
85
+ fullSwitchFailed: 'No switchable model \u2014 pick one manually or raise a limit',
86
+ fullSwitchTo: 'Auto-switched to {model}',
85
87
  close: 'Close',
86
88
  logs: 'Logs',
87
89
  logsTitle: 'Usage Log',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jxgame2020/dsh-token-quota",
3
3
  "description": "Daily per-model token quota accounting, enforcement, and a floating quota panel for the DeepSeek Harness — a fully self-contained plugin (no core-Harness wiring, no generated RPC contract)",
4
- "version": "0.1.4",
4
+ "version": "0.1.5",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },