nianpangzhi233/dsh-billing 预览 preview

nianpangzhi233/dsh-billing

DSH Web GUI实时计费监控:Token/费用计量,DeepSeek v4峰值定价,余额锚定,侧边栏标签+设置页面,billing_balance智能体工具

Project Overview项目介绍

This is a billing monitoring plugin built exclusively for the DeepSeek Harness (DSH) Web GUI. It tracks model call usage and estimated costs for DSH running on the local machine, supports custom pricing matched by provider and specific model, and adapts to DeepSeek v4's tiered peak and off-peak pricing rules. The plugin can be installed directly via the official DSH CLI, by running the command dsh plugin --profile web add github:nianpangzhi233/dsh-billing, or from a local checked out copy or tarball. Once installed, you only need to restart the dsh web process to activate the plugin, which requires no build steps or DSH source code modifications.

After activation, the plugin adds a small real-time balance indicator pill to the bottom of the DSH sidebar that refreshes automatically every two seconds. The pill changes visual state to indicate whether your balance is sufficient, running low, or completely exhausted, so you can see your balance status at a quick glance. When you click the pill, an overview panel expands in the sidebar showing your total accumulated cost, number of API calls, token counts broken down by cached, input, and output, and a history of your recent transaction logs. The panel automatically closes when you collapse the DSH sidebar, and it also adds an agent tool called billing_balance that lets you query usage details directly from the agent.

The plugin is written entirely in plain JavaScript, has no build dependencies or required compilation steps, and is released under the permissive MIT open source license. It only tracks API calls initiated by your local DSH instance, and your DeepSeek API key is stored in plain text in a local ledger file on your personal machine. All billing calculations generated by the plugin are estimates, so actual final costs and official pricing are always determined by DeepSeek, and you should regularly sync and calibrate your official DeepSeek balance to keep your local stats accurate.

这是专为 DeepSeek Harness(DSH)Web GUI 开发的原生实时计费监控插件,可统计本机DSH上的模型调用用量与估算费用,支持按供应商和模型自定义匹配单价计费,适配DeepSeek v4的峰谷定价规则,提供余额锚定、官方单价与余额同步、账本持久化功能,全部基于DSH官方接口和客户端插槽系统实现,不需要修改DSH源码即可运行。

安装完成后重启DSH Web即可使用,插件会在侧边栏底部显示实时余额标签,每2秒自动刷新一次,并根据预设的告警阈值显示余额充足、不足或耗尽的状态提示。点击标签可展开概览面板,查看累计消费、调用次数、输入输出token用量、最近调用流水,收起侧边栏时面板会自动收起,还提供billing_balance Agent工具供查询计费明细。

本插件是纯JavaScript实现,无额外构建步骤,通过DSH的插件命令安装即可使用,遵循MIT许可开源。它仅统计本机DSH发起的模型调用,API Key以明文保存在本地用户的账本文件中,计费结果为估算值,实际单价和最终费用请以DeepSeek官方公示为准,建议用户定期同步校准官方余额。

Pre-install check安装前体检Compatibility · Security兼容性 · 安全性 1 warning1 项注意
  • Only 3 stars - very few users, little community feedback星标只有 3,几乎没人在用,遇到问题缺少社区反馈
DSH walks through these 9 checksDSH 会逐条核对这 9 项

Compatibility兼容性

  • DSH, Node, OS and profile requirementsDSH 版本 / Node 版本 / 操作系统 / profile 是否满足要求
  • External dependencies and runtimes (Electron / Python / Docker, ...)外部依赖与运行时(Electron / Python / Docker 等)是否齐备
  • Conflicts with installed plugins: command names, skill / tool names, ports, duplicate MCP registration与已装插件是否冲突:命令名、skill / tool 重名、端口占用、重复 MCP 注册

Security安全性

  • Repo matches the facts registered here; archived or abandoned?仓库是否与页面登记一致,是否归档或长期停更
  • Safety of preinstall / install / postinstall and install.sh / setup.ps1preinstall / install / postinstall 与 install.sh、setup.ps1 是否安全
  • curl|bash, download-then-execute, obfuscation, unrelated domains → stop immediatelycurl|bash、下载即执行、混淆代码、无关域名 → 立刻停止
  • Typosquatting or unmaintained packages among the new dependencies新增依赖里有没有 typosquatting 或无人维护的包
  • Requested permissions vs. what the feature actually needs申请了哪些权限、是否超出功能所需(filesystem / network / shell / clipboard)
  • Any sudo / admin requirement, plus uninstall and rollback是否要求 sudo / 管理员权限,以及卸载与回滚方式

Anything uncertain must be marked unknown with a note on how to confirm it. This site's signal screen is a static snapshot, not a security audit.拿不准的必须标「未知」并说明要我怎么确认。本站的信号筛查是静态快照,不能替代安全审计。

Or use CLI install (for developers)或使用命令行安装(适合开发者)

CLI Install命令行安装

dsh plugin --profile web add github:nianpangzhi233/dsh-billing

把 nianpangzhi233/dsh-billing 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

dsh-billing — DSH Web GUI 实时计费监控插件

English · 中文

为 DeepSeek Harness(DSH)Web GUI 定制的计费 监控插件:实时统计本机模型调用用量与费用,按供应商/模型单价计费(DeepSeek v4 峰谷价),支持余额锚定、官方单价同步与账本持久化。全部通过官方接口与客户端 slots 系统实现,不修改 DSH 源码。

能力

能力 说明
实时余额 侧边栏底部余额 pill,2 秒刷新;余额状态点(充足 / 不足 / 耗尽,告警闪烁)
概览面板 点击 pill 在侧边栏内展开:已消费 / 调用次数 / 输入 / 输出 token + 最近流水(峰谷标签),收起侧边栏自动收起
供应商计费 按 供应商+模型 → 同名模型 → 供应商默认 → 全局默认 匹配单价;DeepSeek v4 自 08-17 起峰谷定价(高峰 = 北京 9–12、14–18,空闲半价),命中缓存输入按低单价计
官方余额同步 填入 DeepSeek API Key,一键调用官方 GET /user/balance 拉取余额(总余额 / 赠金 / 充值)并自动锚定;也支持手动粘贴校准
官方同步 一键拉取 DeepSeek 官方模型单价(内置基础价 + 持久化覆盖合并)
设置页 DSH 设置 → 「计费」分段:余额、阈值、默认单价、供应商单价表格、数据管理
Agent 工具 billing_balance:查询余额、费用、token 用量与按模型明细
持久化 账本 JSON 原子写入工作区,DSH 重启后自动恢复(余额、单价、流水)

截图

侧边栏余额 pill 与概览面板

计费监控界面演示

安装

本包为纯 JS、无构建步骤(lib/ 即发布产物),git 安装即可用,无需 prepare 脚本、无需构建授权(符合官方打包规范):

# 从本仓库安装
dsh plugin --profile web add github:nianpangzhi233/dsh-billing

# 或本地 checkout / tarball
dsh plugin --profile web add ./dsh-billing
dsh plugin --profile web add ./dsh-billing-0.1.0.tgz

安装后重启 dsh web:侧边栏底部出现余额 pill(设置按钮上方)、 DSH 设置中出现「计费」分段,Agent 提示词中自动出现 billing_balance 工具说明。

配置

DSH 设置 → 「计费」分段(或侧边栏底部 pill 展开面板):

  • 余额:DeepSeek API Key(sk-…)自动同步官方余额(总余额 / 赠金 / 充值, 限流约 1 次/分钟)、手动粘贴锚定、初始余额、低余额告警阈值(默认 ¥20)
  • 计费单价:未知供应商默认单价(¥ / 1M tokens)+ 按供应商/模型单价表, 可增删行;「同步官方单价」一键拉取 DeepSeek 官方价目
  • 数据:账本路径与保存时间、保存配置、重置用量(两次点击确认)

数据

  • 账本文件:.dsh-billing-ledger.json(工作区目录优先,spRoot 兜底), v2 结构:config(初始余额 / 阈值 / API Key / 单价嵌套表)/ usage(token 分项计数)/ ledger(每次调用流水,含峰谷费率)/ startedAt
  • 单价匹配顺序:供应商+模型 → 任意供应商同名模型 → 该供应商默认 → 全局默认
  • 峰谷价:高峰 = 北京 9–12、14–18;其余为谷(半价);08-17 起对 deepseek 供应商 v4 模型生效

注意事项

  • 只统计本机 DSH 的模型调用;官方余额含其他渠道消费,建议定期同步校准。
  • API Key 以明文存于本机账本文件(与 ~/.dsh/dsh-ssh.json 同一信任模型, 文件权限 0600);同步请求仅发给 api.deepseek.com,响应只取余额字段。
  • token 用量按分离计数:未命中输入(inputTokens)、缓存命中输入 (cacheReadTokens)、输出(outputTokens)。
  • 计费为估算,单价与费率以 DeepSeek 官方为准;「同步官方单价」仅在官方 价目页可达时生效(需要平台 web provider)。
  • 路由 /api/dsh-billing/* 仅限 loopback(同源校验)。

许可

MIT

← 上一个 Prev dsh-token-usage-sidebar 下一个 Next deepseek-rainbow-fart →