@gehennawu/dsh-service 0.17.0 → 0.20.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.en.md CHANGED
@@ -2,13 +2,13 @@
2
2
 
3
3
  [中文](./README.md)
4
4
 
5
- A service-control and operations plugin for self-hosted DSH Web. Provides safe restart, version management and one-click upgrade, health diagnostics, model-usage statistics, backup management, task notifications, and Linux file-permission maintenance.
5
+ A service-control and operations plugin for self-hosted DSH Web. Provides safe restart, version management and one-click upgrade, health diagnostics, model-usage statistics, remote quota, backup management, task notifications, and Linux file-permission maintenance.
6
6
 
7
7
  ![Overview](./screenshots/overview_en.png)
8
8
 
9
9
  ## Features
10
10
 
11
- The Settings panel "Service Control" page has six top-level tabs: **Overview, Notifications, Health, Model stats, Backups, Restart**; the Restart tab can also enable a `Restart` quick entry at the bottom of the settings left navigation (off by default).
11
+ The Settings panel "Service Control" page has seven top-level tabs: **Overview, Notifications, Health, Model stats, Quota lookup, Backups, Restart**; the Restart and Quota lookup tabs can each enable a quick entry at the bottom of the settings left navigation (off by default).
12
12
 
13
13
  ### Version and updates
14
14
 
@@ -21,14 +21,14 @@ The Settings panel "Service Control" page has six top-level tabs: **Overview, No
21
21
  - Detects active agents, background jobs, and terminals before restart; lists them and requires explicit confirmation
22
22
  - `/restart` command also available in conversations; automatically refuses when active work is detected
23
23
  - Automatically probes for the new process after restart and reloads the page; manual reload available after 60 seconds
24
- - Overview shows the runtime environment; when a manual terminal launch is suspected, the confirmation flow warns that nothing will bring the process back
24
+ - When a manual terminal launch is suspected, the restart confirmation flow warns that nothing will bring the process back, and Health diagnostics marks it with a yellow inline caution
25
25
  - Optional `Restart` entry at the bottom of the settings left navigation, enabled by a switch in the Restart tab (off by default), sharing the exact same confirmation flow as the Restart tab
26
26
 
27
27
  ### Health diagnostics
28
28
 
29
29
  - Shows uptime, memory, session count, active agents, and background jobs
30
30
  - The "Process and runtime" card shows platform, architecture, and Node version
31
- - Full diagnostics check session storage, workspace registry, backup storage, tar availability, file permissions, runtime environment, and Node runtime version; a manual launch is flagged as a warning (no restart assurance), while an unrecognized environment is informational only (not a warning)both can be declared explicitly via `DSH_SERVICE_RUNTIME_ENV`
31
+ - Full diagnostics check session storage, workspace registry, backup storage, tar availability, file permissions, runtime environment, and Node runtime version; a manual launch is marked with a yellow inline caution (no restart assurance) that does not trigger the health alert banner, the service-control reminder, or the tab ⚠; an unrecognized environment and an empty backup list are informational only all can be declared explicitly via `DSH_SERVICE_RUNTIME_ENV`
32
32
  - Having no backups is an informational note, not a warning, and does not light the Health tab ⚠
33
33
  - File-permission deep scan and repair: checks whether the Agent can read/write DSH_HOME and workspaces; repair requires two-step confirmation
34
34
 
@@ -40,6 +40,15 @@ The Settings panel "Service Control" page has six top-level tabs: **Overview, No
40
40
  - Steps whose provider reports no token usage are excluded from the statistics
41
41
  - Last-24-hour model/tool error statistics, collapsed by default
42
42
 
43
+ ### Quota lookup
44
+
45
+ - A dedicated "Quota lookup" tab shows adapted providers as separate cards, each window rendered as a percentage with its own bar and a reset countdown on its own line, plus a refresh icon beside the updated time that force-refreshes that provider on click (bypassing the poll interval); unadapted providers take no space — a "Manual adapt" row at the bottom enables one by picking its type, and each card's footer can switch type, fall back to auto-detect, or disable lookup at any time
46
+ - A quota ring inside the conversation composer follows the provider selected by the current session and shows the tightest budget window as a percentage (green below 80%, amber at or above); clicking opens a panel headed by the provider name, with a bar and used percentage for each window and reset times on their own lines
47
+ - A "Show a remote quota entry in the settings left navigation" switch lives in the Quota lookup tab (off by default), mirroring the Restart entry
48
+ - Built-in adaptations: **OpenCode Go** (`{baseURL}/usage`), **Zhipu GLM Coding Plan / zai-coding-cn** (official monitor `quota/limit` endpoint with three windows — 5-hour rolling tokens, weekly tokens, monthly MCP quota; an idle 5-hour window hides its reset time, matching the official console), **OpenRouter** (credits used %), **Kimi/Moonshot** and **SiliconFlow** (CNY balance text); dialects that natively report remaining percentage flip the panel word to "Remaining" and invert the warn threshold; transient network errors retry automatically and the Zhipu dual-domain candidate chain switches automatically; the provider-to-kind mapping lives in `DSH_HOME/dsh-service-quota.json`, and known services are auto-detected from their baseURL (e.g. opencode.ai, bigmodel.cn) with no manual picking; no upstream request is ever made for unadapted or disabled providers; disabling can be done via "Disable" in a card's footer or by writing `"<provider>": null` in the config file (both are equivalent). Zhipu reset cards have no API-key-queryable endpoint yet — you can add any number of them via each provider card's "Add reset card" button on the tab (name plus expiry time, down to the minute), and remove each one independently — the ring panel shows them too (stored in the same config file); expired cards are flagged automatically
49
+ - Anti-rate-limit pacing is enforced by the host: successful results are cached for 60 seconds (shared across tabs), failures back off exponentially (30 s doubling, capped at 15 minutes), upstream timeout is 15 s; the panel can set auto query to manual only / 1 / 2 / 5 / 10 minutes (manual only by default), paused automatically while the page is hidden
50
+ - API keys are resolved and used only inside the host process — the browser receives normalized percentages only; data flows through the plugin's own loopback RPC with no webServer routes exposed
51
+
43
52
  ### Backup management
44
53
 
45
54
  - Creates `.tar.gz` archives of sessions, configuration, and plugin profile manifests
@@ -93,7 +102,7 @@ dsh plugin --profile web add link:/path/to/dsh-service
93
102
 
94
103
  The plugin only sends an exit signal; it does not start the process again. Without a process manager, selecting restart stops DSH Web.
95
104
 
96
- The plugin passively detects whether a process manager is present (environment variables, `/.dockerenv`, `/proc/1/cgroup`, terminal TTY): with Docker/systemd/pm2/supervisord/Kubernetes detected it restarts as usual; when nothing is detected and stdin/stdout are an interactive terminal, it treats the environment as a likely manual launch, labels the runtime environment in the overview, and switches one-click upgrade to keep the process running with manual-restart instructions. Heuristics cannot cover redirected output or wrappers like NSSM/WinSW; set `DSH_SERVICE_RUNTIME_ENV=managed|manual` to declare it explicitly.
105
+ The plugin passively detects whether a process manager is present (environment variables, `/.dockerenv`, `/proc/1/cgroup`, terminal TTY): with Docker/systemd/pm2/supervisord/Kubernetes detected it restarts as usual; when nothing is detected and stdin/stdout are an interactive terminal, it treats the environment as a likely manual launch, flags it in Health diagnostics with a yellow caution, and switches one-click upgrade to keep the process running with manual-restart instructions. Heuristics cannot cover redirected output or wrappers like NSSM/WinSW; set `DSH_SERVICE_RUNTIME_ENV=managed|manual` to declare it explicitly.
97
106
 
98
107
  ### Docker Compose
99
108
 
package/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  ## 功能
10
10
 
11
- 设置页「服务控制」面板包含六个顶部标签:**概览、通知、健康诊断、模型统计、备份维护、重启**;重启标签还可在设置页左侧标签列底部开启「重启」快捷入口(默认关闭)。
11
+ 设置页「服务控制」面板包含七个顶部标签:**概览、通知、健康诊断、模型统计、额度查询、备份维护、重启**;重启与额度查询标签还可在设置页左侧标签列底部开启快捷入口(默认关闭)。
12
12
 
13
13
  ### 版本与更新
14
14
 
@@ -21,14 +21,14 @@
21
21
  - 重启前检测活跃 Agent、后台任务和终端,展示清单并要求显式确认
22
22
  - 对话中输入 `/restart` 也可触发,检测到运行中工作时自动拒绝
23
23
  - 重启后自动探测新进程并刷新页面,60 秒未恢复时提供手动刷新
24
- - 概览显示「运行环境」;疑似终端手动启动时,确认流程会提示「退出后不会自动拉起」
24
+ - 疑似终端手动启动时,重启确认流程会提示「退出后不会自动拉起」,健康诊断中以黄色行内警示标注
25
25
  - 可在「重启」标签开启「设置页左列显示入口」开关(默认关闭),开启后在设置页左侧标签列底部显示「重启」快捷入口,与「重启」标签共用同一套确认流程
26
26
 
27
27
  ### 健康诊断
28
28
 
29
29
  - 显示运行时间、内存、会话数、活跃 Agent 和后台任务
30
30
  - 「进程与运行环境」卡显示平台、架构和 Node 版本
31
- - 完整诊断检查会话存储、工作区注册表、备份目录、tar 可用性、文件权限、运行环境和 Node 运行时版本;手动启动环境按警告提示重启无保障,未识别环境为信息级提示(不算警告),均可通过 `DSH_SERVICE_RUNTIME_ENV` 显式声明
31
+ - 完整诊断检查会话存储、工作区注册表、备份目录、tar 可用性、文件权限、运行环境和 Node 运行时版本;手动启动环境以黄色行内警示标注重启无保障(不触发健康提醒横幅、服务控制提醒和标签 ⚠),未识别环境与空备份为信息级提示(不算警告),均可通过 `DSH_SERVICE_RUNTIME_ENV` 显式声明
32
32
  - 没有备份属于信息级提示,不算警告,也不点亮健康诊断标签的 ⚠
33
33
  - 文件权限深检与修复:检查 Agent 是否能读写 DSH_HOME 和工作区,修复需两段式确认
34
34
 
@@ -40,6 +40,15 @@
40
40
  - 提供方未上报 token 用量的模型步骤不纳入统计
41
41
  - 最近 24 小时模型/工具报错统计,默认折叠
42
42
 
43
+ ### 额度查询
44
+
45
+ - 独立的「额度查询」标签:以卡片分区展示已适配的供应商,每个窗口显示百分比、独立进度条,重置时间单独一行;卡片头部更新时间旁有刷新图标,点击即强制重拉该供应商(不受轮询间隔限制);未适配的不占位置,统一收进底部「手动适配」行选择类型启用,卡片脚部可随时切换适配类型、回退自动识别或停用查询
46
+ - 对话输入框内一枚额度圆环,跟随当前会话所选模型的供应商,显示最紧预算窗口的已用百分比(<80% 绿色、≥80% 黄色);点击弹出面板——头部标明供应商,各窗口带独立进度条与已用百分比、重置时间单独一行
47
+ - 可在「额度查询」标签开启「设置页左列显示入口」开关(默认关闭),开启后在设置页左侧标签列底部显示「额度查询」快捷入口(与「重启」入口同模式)
48
+ - 内置适配:**OpenCode Go**(`{baseURL}/usage`)、**智谱 GLM Coding Plan / zai-coding-cn**(官方监控端点 `quota/limit`,含 5 小时滚动 Token、每周 Token、MCP 月度配额三个窗口,5 小时窗口空闲时与官网一致地不显示重置时间)、**OpenRouter**(credits 已用%)、**Kimi/Moonshot** 与 **硅基流动**(人民币余额);原生报「剩余百分比」的方言会自动把面板头部切换为「剩余」并把预警阈值反向;上游瞬时网络错误自动重试,智谱双域候选链自动切换;供应商与适配类型的对应关系保存在 `DSH_HOME/dsh-service-quota.json`,已知服务商按 baseURL 自动识别适配(如 opencode.ai、bigmodel.cn),无需手选;未适配或已停用的供应商不会被发起任何上游请求,停用可在卡片脚部选「停用查询」或在配置文件写 `"<provider>": null`(两者等价)。智谱的重置卡暂无 API Key 可查的接口,可在「额度查询」标签内点各供应商卡片的「添加重置卡」填写名称与到期时间(可精确到分钟),可连续添加多条、每条独立移除;圆环面板同步显示(数据存入同一配置文件),过期自动标注
49
+ - 防风控节律由宿主统一控制:成功结果缓存 60 秒(多标签共享)、失败指数退避(30 秒起 ×2、封顶 15 分钟)、上游超时 15 秒;面板可把自动查询调成仅手动 / 1 / 2 / 5 / 10 分钟(默认仅手动),页面不可见时自动暂停
50
+ - API key 只在宿主进程内解析使用,浏览器只会收到归一化后的百分比数字;数据走插件自有 loopback RPC,不在 webServer 上暴露任何路由
51
+
43
52
  ### 备份管理
44
53
 
45
54
  - 创建会话、配置和插件 profile 清单的 `.tar.gz` 归档
@@ -93,7 +102,7 @@ dsh plugin --profile web add link:/path/to/dsh-service
93
102
 
94
103
  插件只发送退出信号,不负责重新启动进程。没有进程管理器时,点击重启会直接停止 DSH Web。
95
104
 
96
- 插件会用被动信号(环境变量、`/.dockerenv`、`/proc/1/cgroup`、终端 TTY)判断当前是否由进程管理器拉起:检测到 Docker/systemd/pm2/supervisord/Kubernetes 时照常自动重启;都没有且 stdin/stdout 是交互终端时视为「疑似手动启动」,概览会标注运行环境,一键升级改为「不自动退出 + 提示手动重启」。启发式无法覆盖输出重定向、NSSM/WinSW 等场景,可用环境变量 `DSH_SERVICE_RUNTIME_ENV=managed|manual` 显式声明。
105
+ 插件会用被动信号(环境变量、`/.dockerenv`、`/proc/1/cgroup`、终端 TTY)判断当前是否由进程管理器拉起:检测到 Docker/systemd/pm2/supervisord/Kubernetes 时照常自动重启;都没有且 stdin/stdout 是交互终端时视为「疑似手动启动」,健康诊断会以黄色警示标注,一键升级改为「不自动退出 + 提示手动重启」。启发式无法覆盖输出重定向、NSSM/WinSW 等场景,可用环境变量 `DSH_SERVICE_RUNTIME_ENV=managed|manual` 显式声明。
97
106
 
98
107
  ### Docker Compose
99
108