dog-lin/dsh-session-cost
dog-lin★ 0JavaScriptLast synced: 2026-08-15
Real-time session cost meter for the DeepSeek Harness web GUI: folds provider token usage into a per-session cost projection (official DeepSeek price auto-sync) and displays it live under the composer.
README excerpt
dsh-session-cost 一个 DeepSeek Harness Web 插件:实时显示当前会话已花费的金额(费用),显示在输入框下方的状态条区域。 A DeepSeek Harness web plugin that shows, in real time, how much the current session has spent — rendered as a cost line under the composer (next to the stats line). 原理 / How it works - 宿主侧( lib/index.js ) :注册一个 sessionCost 会话投影单元。它重放会话的持久化日志,把每次模型调用的 token 用量( assistant/chunk 的 usage 采样与 assistant/message 的最终 usage)按当时生效的模型路由( request/header 快照)乘以价格表换算成金额。 - 浏览器侧( lib/client.js ) :一个手写的客户端 bundle,通过框架标准的 useProjection('sessionCost') 座位读取该投影,挂载到 conversation.composer.dock 插槽(自带统计条 StatsLine 所在的位置)。宿主每次推送新的 session/projection 帧,金额实时刷新;悬浮提示会显示价格来源与更新时间。 计费口径与 dsh-token-meter 一致:input / cacheRead / cacheWrite / output 四个桶互不相交;同一 (turn, step) 先出现 usage 采样、后有最终 usage 时以后者替换前者,一步只计费一次。 价格怎么保持正确(重点) 三层机制,价格变动时要么自动跟上、要么明确提示,不会静默算错: 1. 官网价格自动同步(默认开启) 插件在启动时和每 updateIntervalHours (默认 24h)抓取 DeepSeek 官方价格页 (模型 & 价格), 模型无关地自动识别价格表里的全部模型 (价格表按"每模型一列"排布,解析器按列数发现模型、 逐列取价——所以将来 DeepSeek 出新模型(比如 v5),只要官网价格表列出,插件就会自动为它取价), 并把检测到的变动 按生效时间追加到每个模型的价格时间轴 (每次请求按其自身时间戳取价)。 官方页面若预告了未来调价(例如 2026-08-17 的峰谷定价公告),解析器会连同 生效日期 一起读入, 到时自动切换,无需人工操作。已观测到的价格历史持久化在 $DSH HOME/storages/dsh-session-cost-pricing.json ,重启不丢失。 每次变动都会在服务日志里打一条明显的…
View full README on GitHub →