MeteorNOX/DeepSeek-Balance-Whale-Widget
DeepSeek Harness(DSH)一只住在 DSH 界面右下角的小鲸鱼娘,帮你盯着DeepSeek账户余额。QQ弹弹,支持拖拽吸附、左吸附翻转、数字滚动动画,随界面自动启用,建议直接喊来你的dsh安装
编辑导读Editor's Brief
## 核心特性
- 该插件会在 DSH Web 界面右下角添加一个常驻鲸鱼小组件,并在界面打开时自动启动。
- 它会显示 DeepSeek API 余额,支持每 60 秒自动刷新、点击鲸鱼手动刷新,并在余额变化时播放数字滚动动画。
- 它可通过本地余额差额记账方式显示当日用量(无需 platform token),也可通过 platform token 模式基于平台用量 API 计算当日用量。
- 该小组件支持拖拽和边缘吸附、吸附到左侧时水平镜像、根据窗口缩放,以及带可选音效的按压动画。
- 悬停菜单提供 0.6 到 2.5 倍缩放调节、声音开关、音量控制、音效集选择和用量模式选择,并会记住尺寸设置。
## 使用场景
- 用户可以在 DSH Web 界面中工作时持续查看 DeepSeek 余额和当日用量。
- 用户无需 platform session token,也可依靠本地用量文件中记录的余额差额来跟踪每日消耗。
- 用户可以通过为平台用量接口提供 platform session token,来计算按高峰和低谷计费的当日用量。
- 用户可以根据浏览器布局偏好,通过拖拽、吸附和悬停菜单来重新定位、调整大小并静音该小组件。
## 技术细节
- 该包是一个 DSH bundle 插件,可通过 dsh plugin 命令安装和移除;本地开发可使用 link: 源路径或 npm 发布。
- 余额数据需要 DEEPSEEK_API_KEY 并调用 api.deepseek.com/user/balance;可选的实时用量需要 DEEPSEEK_PLATFORM_TOKEN 并调用 platform.deepseek.com/api/v0/usage/by_api_key/amount。
- 该插件暴露了 /dsh-whale/image.png、/dsh-whale/balance.json 和 /dsh-whale/size.json 等本地端点,用于提供图片、余额数据和持久化的小组件设置。
- 资源包括鲸鱼使用的透明 PNG 和可选 MP3 音效文件;气泡由代码绘制,用量记录存储在 .dshw-usage.json 中。
## 注意事项
- 如果未配置 DEEPSEEK_API_KEY,余额显示会提示缺少凭据;基于 token 的用量功能需要单独配置 platform session token。
- 本地 link: 安装会存储绝对源路径,因此移动源目录后需要移除并重新添加插件。
- 音效文件为可选项,缺失文件会静默回退;使用 link: 时修改本地代码后,由于 ESM 缓存,需要重启 dsh web。
## Core Features
- The plugin adds a persistent whale widget to the lower-right corner of the DSH Web interface and starts automatically when the interface opens.
- It shows DeepSeek API balance with automatic refresh every 60 seconds, manual refresh by clicking the whale, and a rolling number animation when the balance changes.
- It displays today's usage through either local balance-difference bookkeeping without a platform token or a platform-token mode that calculates usage from the platform usage API.
- The widget supports dragging with edge snapping, horizontal mirroring when snapped to the left side, window-based scaling, and press animation with optional sound effects.
- A hover menu provides scale adjustment from 0.6 to 2.5 times, sound toggles, volume control, sound-set selection, and usage-mode selection while remembering size settings.
## Use Cases
- Users can keep DeepSeek balance and daily usage visible while working in the DSH Web interface.
- Users can track daily consumption without a platform session token by relying on balance-difference observations stored in a local usage file.
- Users can calculate today's usage with peak and off-peak pricing by supplying a platform session token for the platform usage endpoint.
- Users can reposition, resize, and mute the widget through dragging, snapping, and the hover menu according to browser layout preferences.
## Technical Details
- The package is a DSH bundle plugin installed and removed through dsh plugin commands, with local development using a link: source path or npm publication.
- Balance data requires DEEPSEEK_API_KEY and calls api.deepseek.com/user/balance, while optional real-time usage requires DEEPSEEK_PLATFORM_TOKEN and calls platform.deepseek.com/api/v0/usage/by_api_key/amount.
- The plugin exposes local endpoints such as /dsh-whale/image.png, /dsh-whale/balance.json, and /dsh-whale/size.json for image delivery, balance data, and persisted widget settings.
- Assets include a transparent PNG for the whale and optional MP3 sound files, while speech bubbles are drawn by code and usage records are stored in .dshw-usage.json.
## Notes
- If DEEPSEEK_API_KEY is not configured, balance display reports the missing credential, and token-based usage requires a separately configured platform session token.
- Local link: installations store an absolute source path, so moving the source directory requires removing and adding the plugin again.
- Sound files are optional and absent files cause silent fallback, while local code changes with link: require restarting dsh web because of ESM caching.
安装Install
dsh plugin --profile web add dsh-whale-widget
把 MeteorNOX/DeepSeek-Balance-Whale-Widget 加入你的 DSH 配置(web profile)即可启用。
READMEREADME
DSH 小鲸鱼余额挂件(DeepSeek Balance Whale Widget)
DeepSeek Harness(DSH)Web 界面右下角的常驻余额挂件:小鲸鱼气泡图 + DeepSeek API 余额 + 今日已用,每次打开界面自动启用。本项目是标准 DSH 插件包,可通过 dsh plugin 安装/卸载。
特性
- 🐋 常驻自启:随 DSH Web 界面每次打开自动出现(标准 DSH bundle 插件)
- 💰 余额:60 秒自动刷新 + 点击鲸鱼手动刷新;余额变化时数字滚动动画;瞬时网络抖动自动沿用最近余额不报错
- 📊 今日已用:两种模式任选(见下),显示今日消耗金额
- 小鲸鱼记账(推荐,免令牌):不需要任何会话令牌,鲸鱼娘每次观测余额后用余额差值自动记账(
.dshw-usage.json,跨天自动归零归档) - 实时·令牌:填入平台会话令牌后直接调用平台用量接口,按峰谷定价(空闲 9:00–12:00 与 14:00–18:00 之外 / 高峰 9–12 与 14–18 点)实时换算今日已用
- 小鲸鱼记账(推荐,免令牌):不需要任何会话令牌,鲸鱼娘每次观测余额后用余额差值自动记账(
- 🖱️ 拖拽 + 四边四分之一吸附(左/右/上/下,角落可组合)
- 🔄 左吸附时整体水平镜像翻转(文字同步反向、带动画)
- 🧸 按压 Q 弹玩偶效果(按压时底部坐标不变)
- 🎚️ 汉堡菜单(悬停鲸鱼右上角出现):大小滑块(0.6–2.5 倍,尺寸记忆)、音效切换(小黄鸭 / 音效1)、音量调节、用量模式选择
- 🔊 音效:按压/松手音效(可选包内 mp3,缺失时静默降级)
- 💬 随机台词:点击气泡切换随机台词段(6 组加权随机,含峰谷提示/今日已用/卖萌吐槽),再点一次关闭;气泡总显示 5 秒自动收起
- 📐 随浏览器窗口自动缩放;文字位置/字号与图片联动
目录结构
dsh-whale-widget/
├── package.json # DSH bundle 插件元数据
├── README.md # 本文件
├── cordis.patch.yml # 插件挂载声明
├── lib/
│ └── index.js # 宿主侧插件本体
├── assets/
│ ├── DSniang1.png # 小鲸鱼本体(cut-out,气泡由代码绘制)
│ ├── Ya1.mp3 / Ya2.mp3 # 小黄鸭音效(可选)
│ └── D1.mp3 / D2.mp3 # 音效1(可选)
└── whale-widget-prompt.md # 完整规格/维护提示词
安装
方式 A:本地开发安装(当前项目)
在项目根目录(DeepSeek-Balance-Whale-Widget-main)执行:
dsh plugin --profile web add link:.\dsh-whale-widget
说明:
dsh plugin会把参数转发给 pnpm,并在成功后自动把dsh-whale-widget加入dsh.profile.bundles- 使用
link:会在 profile 的node_modules里链接到当前源码目录,方便继续改代码 - 安装完成后重启
dsh web,再 F5 刷新浏览器 - 如果之后移动了源码目录,必须重新到新的项目根目录执行一次:
因为dsh plugin --profile web add link:.\dsh-whale-widgetlink:记录的是源目录的绝对路径;移动后旧链接会失效。若提示已存在/冲突,可先dsh plugin --profile web remove dsh-whale-widget再重新 add。
方式 B:发布到 npm 后安装
如果你把这个包发布到 npm:
cd dsh-whale-widget
npm publish
然后任意机器上安装:
dsh plugin --profile web add dsh-whale-widget
卸载
dsh plugin --profile web remove dsh-whale-widget
从旧手动安装升级
如果你之前按旧方式手动安装过(复制 whale-balance.mjs + 改 cordis.patch.yml),先清理:
$web = "$env:USERPROFILE\.dsh\profiles\web"
Remove-Item "$web\whale-balance.mjs" -ErrorAction SilentlyContinue
Remove-Item "$web\whale-balance.cjs" -ErrorAction SilentlyContinue
Remove-Item "$web\DSniang1.png" -ErrorAction SilentlyContinue
Remove-Item "$web\DSniang02.png" -ErrorAction SilentlyContinue
然后编辑 $web\cordis.patch.yml,删除这段旧补丁:
- insert:
- id: whale-balance-widget
name: ./whale-balance.mjs?v=1
如果里面只有这段,直接改成:
[]
清理后再执行上面的安装命令。
凭据与用量模式
- 余额:需要
DEEPSEEK_API_KEY(在 DSH 凭据服务中配置),用于api.deepseek.com/user/balance - 实时·令牌模式:需要
DEEPSEEK_PLATFORM_TOKEN(平台会话令牌,从浏览器 DevTools 的用量请求Authorization头获取),用于platform.deepseek.com/api/v0/usage/by_api_key/amount - 小鲸鱼记账模式(默认):不需要平台令牌,鲸鱼娘用余额差值自动记账,跨天自动归档
验证
dsh --profile web --dump-config | Select-String -Pattern "whale"
curl http://127.0.0.1:3080/dsh-whale/image.png
curl http://127.0.0.1:3080/dsh-whale/balance.json
curl http://127.0.0.1:3080/dsh-whale/size.json
/dsh-whale/image.png→ 200image/png/dsh-whale/balance.json→ 200,含{"ok":true,"totalBalance":...,"currency":"CNY","todayUsage":...}/dsh-whale/size.json→ GET 返回{scale,sound,vol,soundSet,usageMode};PUT 写入- 浏览器 F5 后右下角出现挂件
常见问题
- 挂件不出现:确认
dsh plugin add成功;dsh --profile web --dump-config里能看到dsh-whale-widget;重启dsh web后 F5。 - 图片不显示:确认
assets/DSniang1.png在插件包内,且没有把旧文件放在 profile 里占用了同名路由。 - 余额报「未配置 DEEPSEEK_API_KEY」:去 DSH 配置凭据。
- 今日已用显示 --:记账模式下需要先跑一次余额观测(60 秒内自动完成);令牌模式需要配置
DEEPSEEK_PLATFORM_TOKEN。 - 没有声音:确认
assets/*.mp3在包内;若不想带音效文件,静默降级为无声音。 - 本地开发改了代码不生效:使用
link:安装时,修改源码后重启dsh web(ESM 模块缓存);如果用已发布版本,需要npm publish新版本后dsh plugin --profile web update dsh-whale-widget。 - 自定义图片:气泡由代码绘制(SVG),鲸鱼本体为 cut-out PNG,放在右下角 59.45%;换图需保证透明背景 cut-out,否则按
whale-widget-prompt.md调整几何参数。
开发与维护
完整规格、视觉参数、架构结论和生成提示词见 whale-widget-prompt.md。修改文字位置、颜色、动画、吸附逻辑、台词组或定价表时参考该文件。
amruthpillai/reactive-resume
anywhere-labs/deepseek-harness-desktop
tt-a1i/archify
strukto-ai/mirage
liustack/modlens
omdsh-dev/DSH-better-sidebar
dsh-market/dsh-market