dsh-web
zhu1090093659/dsh-webDeepSeek Harness(DSH)Web 插件聚合生态包 · 一切皆插件,创意工坊分发(dsh-market.com)
DeepSeek Harness side-bar balance badge: show DeepSeek account balance and estimated depletion time (dual-half cordis plugin)
插件包名:
dsh-balance
在 DeepSeek Harness 侧边栏左下角「设置」按钮上方显示你的 DeepSeek 开放平台账户余额的插件。
版本变更见 CHANGELOG.md。
DeepSeek API 不提供消费历史,所以插件会在服务端把每次成功查询的余额快照
记录到 ~/.dsh/dsh-balance/balance-history.json(保留最近 90 天)。
刻意放弃准确性,图一乐:不像以前那样要求「至少连续下降 1 天」——那样在
每 2 分钟采样 + 余额长期持平的现实里几乎永远凑不出来。现在只看最近几次查询
(默认最近 8 个采样点,可配 estimateLookback),把相邻采样之间的每次下降
累加为消耗,摊到整个窗口跨度上得到日均消耗,再除以当前余额得出剩余天数:
所有数字都是估算、且故意带娱乐色彩,别当真。充值后窗口会自然切到新的消耗段。
可配置项:estimateLookback(基于最近多少次查询,默认 8)、
historyMaxAgeDays(历史保留天数,默认 90)。
双半插件(dual-half cordis plugin):
| 半 | 文件 | 作用 |
|---|---|---|
| 服务端(host) | lib/index.js | 注册 GET /ds-balance/balance 路由(仅回环可信请求),解析 API Key,代理 https://api.deepseek.com/user/balance |
| 浏览器(client) | lib/client.js | 向 sidebar.footer.action 插槽注册余额徽标组件,定时拉取并渲染 |
按优先级:
推荐用凭证服务:Key 不进插件配置、不进浏览器,且与模型调用复用同一把 Key。
已在 DSH 0.1.5-rc.1 上验证(宿主路由 200、徽标正常渲染)。
客户端半边用 ctx.slots.inject("sidebar.footer.action", …) 等待侧边栏声明该插槽后再注册。
这不是可选的写法:0.1.5 起重写的 slots 运行时要求插槽先被父条目声明,若在 apply() 里直接
ctx.slots.register(...),整个 loader entry 会加载失败并报:
failed to apply loader entry <hash> (dsh-balance): slot "sidebar.footer.action" is not declared
(a parent entry's children table must declare it)
症状是宿主路由正常、boot 清单里也有 dsh-balance/client.js,但页面上徽标不出现。
# 1. 把插件放进 profile 的扁平回退目录(生效副本;纯拷贝,改源码后需重新拷贝)
$target = "$HOME\.dsh\profiles\node_modules\dsh-balance"
Copy-Item "<本目录>" $target -Recurse -Force
# 2. 在 $HOME\.dsh\profiles\web\cordis.patch.yml 里加入(不能注释掉,注释=完全不加载):
# - insert:
# - id: dsh-balance
# name: dsh-balance
# config:
# apiKeyEnv: DEEPSEEK_API_KEY
dsh --profile web(可用模型工具 dsh_restart_backend)。cordis.patch.yml 里的行没被注释,并重启一次。# 服务端路由(Key 已配置时;插件自注册的路由不受 GUI 认证栅栏影响)
curl http://127.0.0.1:3080/ds-balance/balance
# 期望 {"ok":true,"is_available":true,"balance_infos":[{"currency":"CNY",...}],
# "estimation":{"available":true,"daysLeft":...,"basedOnSamples":8,...},...}
Remove-Item "$HOME\.dsh\profiles\node_modules\dsh-balance" -Recurse
# 并从 $HOME\.dsh\profiles\web\cordis.patch.yml 删除 dsh-balance 条目