deepseek-harness
deepseek-ai
DeepSeek Harness: Everything is a Plugin.
PROJECT TOPICS
PROJECT README
既然都知道输入输出的token数目了,为什么不自动计算价格呢?
DeepSeek Harness(DSH)Web 插件:在对话统计行(缓存命中率 / 输入 / 输出)之后追加展示当前会话的累计花费,并提供可在设置页中编辑的按模型价格表(支持峰谷定价)。
价格单位为所选币种(CNY / USD)下每 1,000,000 tokens 的单价,支持三种计费项:
| 计费项 | 统计来源(tokenUsage 投影) |
|---|---|
| 输入缓存命中 | cacheReadTokens |
| 输入缓存未命中 | uncachedInputTokens + cacheWriteTokens |
| 输出 | outputTokens |
每轮费用 =(缓存命中 × 命中价 + 缓存未命中 × 未命中价 + 输出 × 输出价)/ 1,000,000。 每轮按该轮发生时的模型与峰谷时段独立计价并存为一条不可变条目,会话展示的累计花费为所有条目之和。
每个模型可以启用任意数量的峰值时段,每个时段自带三档单价:
HH:mm,start > end 表示跨午夜(如 22:00–06:00);dsh-cost-meter domain,sessions 表),按会话隔离,不写入 settings.yaml;首次安装时预置 CNY 价格表如下(1M tokens,峰谷定价默认关闭):
| 模型 | 输入缓存命中 | 输入缓存未命中 | 输出 |
|---|---|---|---|
deepseek-v4-flash |
¥0.02 | ¥1 | ¥2 |
deepseek-v4-pro |
¥0.025 | ¥3 | ¥6 |
| 默认价格(未匹配模型) | ¥0.025 | ¥3 | ¥6 |
conversation.composer.dock,随会话切换与新一轮计费自动刷新;悬停显示模型、已计费轮次、峰谷时段与各分项明细;$DSH_HOME/settings.yaml 的 dsh-cost-meter: 段,保存后即生效;zh / en)。

安装并重启服务端后:
无可用用量、无已计费条目、或价格表尚未加载时,花费行自动隐藏,不占用布局。
在 harness 目录中把本插件加入 web profile:
cd <harness 目录>
# 本地源码(link 方式)
dsh plugin --profile web add "link:<dsh-cost-meter 目录>"
# 发布到 registry 后
dsh plugin --profile web add dsh-cost-meter
或者直接在 .dsh\profiles\web\node_modules 下运行:
git clone git@github.com:Creakono/dsh-cost-meter.git
随后重启 web 服务端,刷新页面即可。
如果通过 pnpm 脚本启动 harness,插件命令同样写为 pnpm dsh plugin ...。
源码开发时可重新构建插件产物:
cd dsh-cost-meter
pnpm install
pnpm run build
构建输出:
index.mjs:价格表设置命名空间、逐轮费用侧车表、归档清理与自有配置/账本路由(schemastery 已内联);client.js:累计花费行(含峰值提醒)+ 价格表设置页。$DSH_HOME/settings.yaml 中的用户价格配置结构:
dsh-cost-meter:
currency: CNY # CNY 或 USD
default: # 未匹配模型的兜底价格
cacheHitPrice: 0.025
cacheMissPrice: 3
outputPrice: 6
peakWindows: []
models: # 按模型覆盖
deepseek-v4-flash:
cacheHitPrice: 0.02
cacheMissPrice: 1
outputPrice: 2
peakWindows: # 可多个;start > end 表示跨午夜
- id: peak-9
start: 09:00
end: 12:00
cacheHitPrice: 0.1
cacheMissPrice: 3
outputPrice: 9
schema 默认值只在用户未写入 models 时生效,因此把 models 清空后保存即可真正移除全部模型条目。
tokenUsage 会话投影,与内置统计行同源:分页与压缩(compaction)都不影响数字;session/event,在 usage 事件落盘时按当时配置生成条目并写入 storage-domain,客户端只做条目求和;ctx.modelDirectories(可选服务),缺失时回退到「默认价格」档;GET /dsh-cost-meter/config、POST /dsh-cost-meter/config(整段写入)、
POST /dsh-cost-meter/reset(恢复默认)、
GET /dsh-cost-meter/sessions/:sessionId/ledger(会话条目汇总);currency + 三个顶层单价)会在读取时自动折叠进 default 档。CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: 无有效分类标签。