dsh-deepseek-balance

by lin-cheng-lab

开发与运行时github收录于 08-23

右下角悬浮的 DeepSeek API 余额监视器 —— 为 DeepSeek Harness (DSH) 实时显示账户余额与用量费用。

A bottom-right floating DeepSeek API balance monitor — live account balance and usage cost for DeepSeek Harness (DSH).

安装

dsh plugin --profile web add github:lin-cheng-lab/dsh-deepseek-balance

GitHub 源码安装:首次需按提示配置 allowBuilds 构建授权后重试

安装与环境配置指引、插件开发教程见 DSH 中文社区文档 ↗

安装即在你的机器上以你的权限运行第三方代码——它可读写文件、使用凭据、访问网络,DSH 的工具审批不会为插件代码加沙箱。「检测到 manifest」仅代表发现 dsh.bundle / dsh.plugin 清单,不构成兼容性或安全审查;安装前请审阅源码,不熟悉的插件先在不含密钥的环境试用。

README

目录

右下角悬浮的 DeepSeek API 余额监视器 —— 为 DeepSeek Harness (DSH) 实时显示账户余额与用量费用。

badge

功能

  • 🟢 右下角常驻悬浮徽章:状态色圆点 + 实时余额,任何页面/会话下都可见
  • 📊 用量费用图表:7 天 / 30 天柱状图,悬停查看每日金额
  • 🔄 每 60 秒自动刷新,也可手动刷新
  • 🎨 自动适配深浅色主题(使用 DSH 主题变量)
  • 🔑 自动读取已配置的 DEEPSEEK_API_KEY 凭证,无需手动填写
  • 🔒 Key 安全:通过环境变量传给 curl,命令行/日志不出现明文

余额数据来自官方接口 GET https://api.deepseek.com/user/balance; 用量数据来自本机 DSH 会话日志的真实 token 统计(按官方价格换算费用), 更早的历史因本地无账单记录以灰色示意柱展示。

安装

dsh plugin --profile web add "github:<你的用户名>/dsh-deepseek-balance#main"

然后重启 dsh --profile web,右下角即可看到余额徽章。

凭证配置

在 ~/.dsh/.credentials.yaml 中配置:

DEEPSEEK_API_KEY: sk-xxxxxxxxxxxxxxxxxxxxxxxx

开发

pnpm install
pnpm build    # tsc 编译 Host + tsdown 打包 Client

产物结构:

  • lib/index.js — Host 半(RPC handler:余额/用量查询)
  • lib/client.js — Client 半(悬浮徽章 UI,__ModuleLoader__ bundle)

工作原理

┌──────────────┐   connection.rpc.call   ┌──────────────────────────┐
│  Browser UI  │ ──────────────────────▶ │  Host (Node)             │
│  shell.overlay│  /deepseek-balance      │  ├─ credentials.resolve  │
│  悬浮徽章+图表 │ ◀────────────────────── │  ├─ shell curl 余额 API  │
└──────────────┘   RpcResult             │  └─ sessionQuery 用量统计 │
                                         └──────────────────────────┘

License

MIT

原始 README: https://github.com/lin-cheng-lab/dsh-deepseek-balance/blob/master/README.md ↗