dsh-cost-meter

August 18, 2026 · View on GitHub

DeepSeek Harness 会话费用计费插件(bundle 形态):统计条原位显示会话费用, 每条消息动作行显示单条 token/费用,回复进行中在运行状态标签后实时累计 「本轮回答」的 token 与费用(含思考 reasoning token)。无需翻到独立页面,一眼可见。

Deep diving... 38秒 · 本轮费用 ¥0.053 · 1.4K tok     ← 回复进行中(实时增长)
[时间 · 运行 49秒] · 412 tok · ¥0.0056               ← 每条消息完成后
费用 ¥1.76 · 输入 ¥0.11 · 缓存 ¥0.60 · 输出 ¥0.08 · 思考 104K tok ≈ ¥0.21 · 8-17后 峰 ¥X / 闲 ¥Y   ← 统计条

安装(GitHub)

本包 lib/预构建产物,从 git 安装无需 prepare 构建脚本:

npx -y @deepseek-ai/dsh plugin --profile web add github:LINGYIIIIIIII/dsh-cost-meter

如需锁定版本,追加 commit sha:github:LINGYIIIIIIII/dsh-cost-meter#<sha>

功能

位置显示
统计条(composer dock)会话总费用 + 输入/缓存/输出分桶 + 思考 token 金额 + 8-17 峰谷换算对比
消息动作行(assistant-actions)单条回答的 token 与费用(悬停看明细)
运行状态标签(Deep diving...)本轮回答实时累计:本轮思考+文本加总,流式中增长、跨 step 持续、下一轮从 0 重来

效果截图

回复进行中的实时累计(运行状态标签)与底部统计条一览:

功能截图

计价口径

  • 按模型查价:每条消息用自身 message.source.model 查价格表(flash/pro 不同价,未知模型兜底 0 不误报)
  • 峰谷计价(当前生效):2026-08-17 起官方峰谷定价——高峰 = 北京 9:00-12:00、14:00-18:00,空闲 × 0.5;按每条消息的事件时间自动判定,历史事件也按各自时间计价
  • 思考 token:官方无独立 reasoning 价,按输出价计
  • 价格表内置官方峰谷价(peakPrices)与 8-17 前的历史平峰价(prices,仅换算对比用),可在配置 prices / peakPrices / offPeakFactor / regimeStart 覆盖

配置示例

- id: cost-meter
  name: '@dsh-external/dsh-cost-meter'
  config:
    prices:             # 历史平峰价(8-17 前,仅换算对比用)
      deepseek-v4-flash: { input: 1, cacheRead: 0.02, output: 2 }
      deepseek-v4-pro:   { input: 3, cacheRead: 0.025, output: 6 }
    peakPrices:         # 峰谷高峰价(当前生效)
      deepseek-v4-flash: { input: 3, cacheRead: 0.10, output: 9 }
      deepseek-v4-pro:   { input: 9, cacheRead: 0.30, output: 27 }
    offPeakFactor: 0.5  # 空闲 = 高峰 × 0.5
    regimeStart: '2026-08-17T00:00:00+08:00'

结构

package.json        # dsh.bundle 声明(官方 publish.md 的 bundle 形态)
cordis.patch.yml    # 补丁层:插入 cost-meter 行
lib/index.js        # host:costUsage 投影 + /cost-meter/api/{message,live} 路由(零依赖)
lib/client.js       # client:统计条槽位 + 消息动作行槽位 + 运行状态标签注入
test/               # 回放与实时估算单测(node test/*.mjs)

已知限制

  • 实时估算以字符 ≈ token(reasoning/3、text/4),回复完成后被精确值替换;首条消息流式中途费用估算为 0
  • 运行状态标签的定位选择器含官方构建哈希 class(有 aria-live 语义选择器兜底),DSH 大版本重编译后若失效需更新选择器
  • /cost-meter/api/* 无鉴权(localhost 信任边界),仅返回 token/金额
  • 数据口径:统计条 = 全会话累计;消息动作行 = 单条;运行标签 = 本轮回答累计

License

MIT