J-Chien/dsh-meter 预览 preview

J-Chien/dsh-meter

DeepSeek Harness 的按会话计费插件:会话头中的令牌桶、缓存命中率和峰值感知成本 + 价格表设置页面

Project Overview项目介绍

dsh-meter is a native plugin built exclusively for DeepSeek Harness that tracks and displays per-session API usage and cost. It adds a persistent billing badge to the top right corner of every active session, showing real-time total cost and distinguishing between cache hit, cache miss, and cache write token usage. It calculates pricing based on whether a request falls into peak or off-peak hours, and supports tiered pricing based on total request length, matching official billing rules from most LLM providers. To install the plugin, run npx @deepseek-ai/dsh plugin --profile web add dsh-meter then restart the DSH GUI after installation completes.

After you start a new session, the badge updates with the total cost as you send requests, and it shows an amber "unpriced" label if none of the models used in the session have configured pricing. If a model has peak hour pricing configured, the badge displays a colored tag indicating if the current time falls into peak or off-peak, updating every minute automatically. You can hover over or click the badge to open a detailed statistics card that breaks down usage by token type, shows current context window usage, and displays a mini-graph of per-round token usage. This plugin is ideal for developers who need to track exact LLM API costs for each DeepSeek Harness session.

This plugin requires DeepSeek Harness version 0.1.0-rc.7 or higher to work correctly, and it is released under the open-source MIT license. There are several known limitations: host changes do not support hot reload so you must restart DSH after any changes, and when accessing DSH from a remote non-local browser, the settings page becomes read-only and you cannot save changes. If you have saved a custom price table, any updates to default prices added in plugin upgrades will not be applied automatically, so you will need to manually add new prices if needed. All pricing data is stored with high precision to avoid floating point errors when calculating total session cost.

dsh-meter 是专为 DeepSeek Harness 开发的原生按会话计费插件,会在每个会话的右上角展示当前会话的 token 用量与费用,可区分缓存命中、未命中与写入,统计缓存命中率,还能按请求时刻归属高峰/空闲时段计价,支持按请求长度分段计费,自带图形界面设置页编辑价格表。作为第三方 bundle,它可直接装入任意 DSH 配置文件,无需修改主仓库任何代码。

用户开启新会话后,右上角会常驻显示当前会话已产生的费用,未配置价格的模型会显示「未登记价格」标签,配置了高峰时段的模型会自动标识当前时段类型。用户悬停或点击费用徽标即可打开统计卡片,查看详细的 token 用量、费用拆分、上下文占用和每轮消耗详情,还可进入设置页自定义不同模型、不同时段的价格。适合需要精准统计每次 DeepSeek Harness 会话 API 成本的开发者使用。

该插件要求搭配 DeepSeek Harness 0.1.0-rc.7 及以上版本使用,可通过 npx 命令一键安装,首次安装后需要重启 DSH GUI 才能生效。它遵循 MIT 开源许可,存在一些已知限制,比如主机改动无热重载需重启、远程浏览器访问时设置页会退化为只读,保存过自定义价格表后插件升级带来的默认价格更新不会自动生效。

Pre-install check安装前体检Compatibility · Security兼容性 · 安全性 2 warnings2 项注意
  • No license declared - all rights reserved by default; ask the author before commercial use or redistribution未声明开源许可证 —— 默认「保留所有权利」,商用或再分发前先问作者
  • Only 5 stars - very few users, little community feedback星标只有 5,几乎没人在用,遇到问题缺少社区反馈
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命令行安装

npx @deepseek-ai/dsh plugin --profile web add dsh-meter

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

READMEREADME

dsh-meter

DeepSeek Harness 的按会话计费插件:在每个会话右上角展示当前会话的 token 用量与费用(含缓存命中/未命中/写入区分、缓存命中率、按请求时刻归属的高峰/空闲计价、按请求长度取档的分段计价),并提供 GUI 设置页编辑价格表。

第三方 bundle:装进任意 dsh profile 即可,不改主仓库任何代码。复用 dsh-better-sidebar 的成熟第三方模式(自建 fenced /billing/api 路由 + session-projection 单元 + 纯平台模块的 client bundle)。

效果展示

会话头部费用徽标(含高峰/空闲标签):

会话头部-高峰标签 会话头部-空闲标签与多币种并列计费

hover/点击展开的统计卡片(token 用量、费用、逐轮消耗):

统计卡片-多轮价格展示 逐轮消耗详情面板

设置卡片(GUI 编辑价格表;截图为 rc.6 时代的独立设置页版式,rc.7 起位于 设置 →「插件」配置页):

设置页-分段区间计费 设置页-高峰时段定价

功能特性

会话头部入口(常驻)

  • 每个会话右上角有一个常驻费用徽标(新会话显示 ¥0.00)——官方统计药丸同款:28px 高、全圆角、6px 8px 内边距、13px tertiary 文字 + 图标,hover/展开态用 interactive-bg-hover 底色。
  • 未登记价格:会话用到的模型全部没有配置价格时,徽标显示琥珀色「未登记价格」标签而不是 ¥0.00;部分登记时只合计已登记部分。
  • 高峰/空闲标识:会话用到配置了高峰窗口的模型时,徽标旁显示圆角状态标签——当前处于高峰显示红色「高峰」,否则灰色「空闲」(每分钟自动更新);未配置高峰时段则不显示任何标签。判定按 provider 时区(缺省北京时区),host 折叠与浏览器标签一致。
  • DeepSeek 官方规则一键预设:deepseek-official provider 设置区提供「应用」按钮——一键把该 provider 的模型高峰窗口设为**仅工作日(周一至五)**并把 provider 时区置为 Asia/Shanghai,对应 DeepSeek 2026-08-23 起「周末全天低谷价」的新规;价格保留用户现有配置。
  • 多币种徽标:会话用到多种币种时按币种并列展示(¥1.20 + $0.35),不混算。
  • hover 或点击都能打开统计卡片(hover 200ms 展开、离开 300ms 关闭;点击固定展开,点击外部/Esc 关闭)。

统计卡片

卡片沿用官方统计面板(会话内「本轮用量」弹层)的版式:12px 圆角浮层 + --dsw-specific-menu 底色 + 官方 prominent 阴影,标题行右侧为本次会话总费用,其下 0.5px 细线 + 一个 dt/dd 网格(标签走 tertiary、数值走 secondary 且右对齐、等宽数字),小节之间共用同一条细线。

  • 提供方 / 模型:网格首行显示当前会话的 provider/model(含 reasoning effort,长路由按任意位置换行——与官方一致)。
  • token 用量:缓存命中(一位小数百分比,部分命中绝不四舍五入成 100%)→ 未缓存输入 → 缓存读取 → 缓存写入(仅存在时显示)→ 输出;数值为精确计数(千位分隔 + tok 单位,如 110,663 tok)。
  • 费用:标题右侧的总费用按币种并列(¥1.20 + $0.35);配置了高峰时段时额外展示「空闲时段」「高峰时段」两行拆分。
  • 上下文占用条(压缩预测):最近一次请求输入 ÷ provider 声明的输入+输出总窗口(来自日志 request/context),显示进度条 + 已用 / 窗口 + 输出上限;≥85% 预警「接近上限,建议开新会话」。含 80% 压缩触发参考线、压缩历史(已压缩 N 次 · 释放 X tokens · 摘要花费——压缩摘要调用是真实 provider 请求,其费用计入总额)与压缩预估(快照差分增速外推「约 N 轮后触发压缩」,余量可心算验证)。任一数据缺省则不显示(不估算)。
  • 每轮新增迷你图:每轮一根新增占用 token 竖条(快照差分口径,免疫缓存失效;最老轮在左、从左到右 3px 等距排列;第 1 轮的新增 = 其整轮快照——它的前驱是空上下文,首轮装载的所有内容都是新增),高峰轮暖色着色,hover 出统一 tooltip;按卡片实际宽度自适应轮数。
  • 卡片标题行的图标按钮(hover/focus 卡片时显形,无 hover 设备常显):刷新(按最新价格重算当前会话)+ 查看详情(打开逐轮消耗面板)+ 齿轮设置(打开设置面板并排队定位请求;计费卡片挂载时自动展开并定位当前模型——rc.7 的设置面板无导航 API,「插件」页需手动点开)。

Showing the opening section of the README — the full document lives in the repository以上为 README 开头摘要,完整文档在仓库内 · View the full README on GitHub →在 GitHub 查看完整 README →

← 上一个 Prev dsh-quant-workbench 下一个 Next ashare-agent →