DSH Plugins Marketplace

DSH Plugins

Plugins

/

dsh-deepseek-balance

w

dsh-deepseek-balance

Manifest valid

DSH Sidebar Real-Time DeepSeek Account Balance Plugin (Account Login, No API Key Required) | Live DeepSeek account balance in the DSH sidebar

UI (client)hasBundlePatchMachine translated

dsh-deepseek-balance — DeepSeek 余额插件 | DeepSeek Balance Plugin

DeepSeek Harness(DSH)余额插件:在侧边栏底部实时显示 DeepSeek 账户余额。

面向 DeepSeek Harness 0.2.0-rc.2(桌面端 / desktop profile) 适配。

为什么用账号余额,而不是 API Key

一个直觉的做法是让插件拿 sk- API Key 去请求 https://api.deepseek.com/user/balance。但这条路在桌面端有个绕不过去的坑:

桌面端用账号登录(deepseek-account-platform)时,凭据里保存的是平台 OAuth 令牌,不是 API Key;直接拿它调用 /user/balance 会返回 401 Authentication Fails。

也就是说,用户点一下账号登录之后,这条路仍然拿不到余额,除非他再跑去开放平台单独生成一个 sk- API Key。

本插件改走 DSH 自己读账户余额的那条链路:

胶囊 → ctx.remote.account.getBalance(client)   (浏览器半边)
     → accountController.getBalance             (@deepseek-ai/dsh-api-account-controller)
     → ctx.deepseekAccount.getBalance           (Host 账户服务)
     → platform.deepseek.com 钱包余额

这就是「设置 → 账户」页面用的同一个接口,所以不需要 API Key,账号登录即可用,数字也和设置页一致。

功能

  • 侧边栏余额徽标:注册在 sidebar.footer.action 槽位(齿轮「设置」旁边),图标 + 「余额」+ 实时金额。
  • 侧边栏收成 56px 窄条时只显示图标(36×36 圆形)。
  • 悬停显示明细 tooltip:充值余额、赠送余额、上次更新时间、点击刷新提示。
  • 点击徽标立即重新读取。
  • 中英双语(跟随界面语言)。

刷新时机

时机说明
插件加载立即读一次
每 30 秒页面可见时轮询(POLL_INTERVAL_MS)
账户状态流关注 remote.account.watch,登录 / 退出立即反映
窗口获得焦点立即读一次
页面重新可见立即读一次
连接重置立即读一次
点击徽标立即读一次

重新读取失败不会清空已经拿到的金额,只在 tooltip 里标注「显示的是上一次成功读取的余额」,避免网络抖动把余额变成空白。

安装

方式一:插件管理器(推荐)

本仓库通过 dsh.bundle.patch 声明了自带的 cordis.patch.yml,因此不需要手写补丁行:

dsh plugin --profile desktop add github:wangxiang0605qvq/dsh-deepseek-balance

方式二:手动放进解析根(离线可用)

要点:包必须放在 $DSH_HOME\profiles\node_modules\ 下——那是运行期模块解析的查找根。放进 profiles\desktop\node_modules\ 不会被解析到,只写补丁行同样找不到模块。

$dest = "$env:USERPROFILE\.dsh\profiles\node_modules\@deepseek-ai\dsh-deepseek-balance"
New-Item -ItemType Directory -Force -Path (Split-Path $dest) | Out-Null
Copy-Item -Recurse -Force . $dest
Remove-Item "$dest\.git" -Recurse -Force -ErrorAction SilentlyContinue

然后在 ~/.dsh/profiles/desktop/cordis.patch.yml 末尾追加:

- insert:
    - id: deepseek-balance
      name: "@deepseek-ai/dsh-deepseek-balance"
      config: {}

重启 DSH,然后硬刷新(Ctrl+F5)页面。

方式三:作为 profile 本地插件(实测通过的路径)

不需要动 node_modules,把 lib/ 下的两个文件当作插件的两个半边即可:

~/.dsh/profiles/desktop/plugins/deepseek-balance/
├── package.json   # name 任意唯一值,声明 exports["./client"] 与 dsh.client.platform = "web"
├── index.js       # 即 lib/index.js
└── client.js      # 即 lib/client.js(把 window.__ModuleLoader__.load 的 id 改成与 package.json.name 一致)

补丁行用相对路径,由 patch 文件所在目录解析:

- insert:
    - id: deepseek-balance
      name: ./plugins/deepseek-balance/index.js

这个 profile 已启用 HMR,改 patch 会热生效;没有热生效就重启 DSH。

注意:window.__ModuleLoader__.load({ id }) 必须与 package.json 的 name 完全一致,否则 browser 模块表找不到对应的 factory,插件会静默不生效。

配置项

无。插件不接收 Host 侧 config:client 半边拿不到它,而余额来源、刷新节奏都由上面那张表固定。要改轮询间隔就改 lib/client.js 里的 POLL_INTERVAL_MS。

实现说明

文件作用
lib/client.js浏览器半边:余额 store、徽标组件、样式、sidebar.footer.action 注册
lib/index.jsHost 半边:空的 apply,只为让 Loader 有一个可挂载的条目
cordis.patch.ymlbundle 层:把包作为一个 bundle 挂进 profile

lib/index.js 刻意留空:本插件的数据源是 Host 既有的 account Remote 命名空间,Host 半边再注册服务或工具只会引入它不需要的依赖。真正的门禁在 lib/client.js 的 inject = ["slots", "remote", "remote.account", "locale"] 里。

已知边界

  • 未登录时显示「未登录」;Host 侧 getBalance 在未登录时直接返回 null,不发平台请求。
  • 金额格式对齐 Platform Web:两位小数、千分位、正的不足 1 分显示为 <¥0.01、负数最小显示幅值 0.01。为了不引入 Big.js 依赖,这里用字符串截断而非 Big.roundDown,极端小数(如恰好半分的负数)可能与账户页面差 1 分。
  • AccountClientMetadata.version 优先读 globalThis.__DSH_CLIENT_VERSION__,读不到则回退为 0.2.0-rc.2。升级 Harness 后如需精确版本,改 CLIENT_VERSION 一处即可。
  • 无头 / TUI 环境下没有侧边栏,徽标不显示。

License

MIT

Comments

Loading…

Similar plugins

dsh-plugin-deepseek-balance

by hnmrxz

在 DeepSeek Harness (dsh) 底部状态栏实时显示 DeepSeek 账户余额。

Manifest valid

★ 4

MIT

JavaScript

Aug 15, 2026

dsh plugin --profile web add dsh-plugin-deepseek-balance

by Jianwen-Xu

DSH 插件:在 Web 侧边栏显示 DeepSeek API 余额与高峰/空闲计费时段

Development & InfrastructureManifest valid

★ 0

MIT

TypeScript

Sep 18, 2026

dsh plugin --profile web add dsh-deepseek-balance

by PengPeng6845

DeepSeek Harness 侧边栏真实 API 余额监控:直连官方 /user/balance,SSE 即时推送,只显示真实数据不做估算。

Development & InfrastructureManifest valid

★ 0

MIT

JavaScript

Aug 21, 2026

dsh plugin --profile web add @pengpeng6845/dsh-balance

by zhangjianyu1006156

DeepSeek API 余额显示插件:左下角余额胶囊、低余额预警、余额趋势、一键充值。密钥不出主机端。

Manifest valid

★ 3

↓ 148/wk

MIT

JavaScript

Aug 15, 2026

dsh plugin --profile web add dsh-balance-display

by etony668

DeepSeek API 余额常驻显示(侧边栏「设置」旁)· DeepSeek API balance badge beside Settings in the DSH sidebar

Tools & CapabilitiesDevelopment & InfrastructureTerminal & ClientsManifest valid

★ 0

MIT

JavaScript

Sep 25, 2026

dsh plugin --profile web add @etony668/dsh-balance

by novaschai7

DeepSeek account balance, today's token usage and estimated spend in the dsh Web client sidebar. · 在 dsh 侧边栏显示 DeepSeek 余额、今日 token 用量与花费估算。

Manifest valid

★ 0

MIT

JavaScript

Sep 30, 2026

dsh plugin --profile web add dsh-plugin-balance-ui