rea
morluto
Reverse engineer anything with agents, from app behavior down to native binaries.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:Avenger233/dsh-session-cost-board
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
Per-session token & money accounting for DeepSeek Harness. A settings page that ranks every conversation by what it cost (models, requests, cache hit rate, search/fetch fees), plus a live price pill under the composer.
给 DeepSeek Harness 加一个「每个会话花了多少钱」的视图。
×,点一下即隐藏;也可以在「设置 → 会话花费」顶部用开关重新打开。偏好存在浏览器 localStorage,按访问端口隔离,换端口或换浏览器会回到默认显示。数据只来自本机会话日志(sessionPersistence + sessionStore),不联网、不上传;对日志只读。
DSH 0.2.2-rc.1 及以上(engines.dsh: >=0.2.2-rc.1 <0.3.0)。
从 npm 安装(推荐,可用版本号锁定,例如 dsh-session-cost-board@1.0.4):
dsh plugin --profile <profile> add dsh-session-cost-board
或从本仓库安装:
dsh plugin --profile <profile> add github:Avenger233/dsh-session-cost-board
或本地目录安装(link: 绝对路径,开发时改代码即生效):
git clone https://github.com/Avenger233/dsh-session-cost-board.git
dsh plugin --profile <profile> add "link:/absolute/path/to/dsh-session-cost-board"
装完页面会热加载;插件出现在「插件 → 已安装插件」,设置里多一页「会话花费」,输入框下方多一个 ● ¥x.xx 花费标签。
官方价目(抓取于 2026-11-13,中文价格页):
| 模型 | 缓存命中(谷/峰) | 缓存未命中(谷/峰) | 输出(谷/峰) |
|---|---|---|---|
deepseek-flash(V4.1-Flash-1017) |
¥0.02 / ¥0.04 | ¥1 / ¥2 | ¥4 / ¥8 |
deepseek-v4-pro(V4-Pro-0813) |
¥0.15 / ¥0.30 | ¥4.5 / ¥9 | ¥13.5 / ¥27 |
单位:人民币 / 百万 tokens。
assistant/message 的 usage 按它自己的时间戳判断峰谷,所以跨 12:00、跨周末的会话也算得对。inputTokens,DSH 里这个字段就是未命中部分)、缓存命中(cacheReadTokens)、输出(outputTokens)。缓存写入不单独收费,非 0 时按未命中价兜底;reasoning tokens 是 output 的子集,不另加。web_search、web_fetch 的成功调用按 ¥5 / 1000 次折算(失败的不算),单独列在明细里。DeepSeek-V4.1-Flash-1017、deepseek-ai/DeepSeek-V4.1-Flash、deepseek/deepseek-v4.1-flash-1017 等都会归到 deepseek-flash 价;deepseek-chat / deepseek-reasoner 已下线、按 Flash 计。不改也能用。想覆盖默认值时,在 ~/.dsh/profiles/<profile>/cordis.patch.yml 里给本插件的行加 config:
- id: session-cost
name: dsh-session-cost-board
config:
# 单价覆盖(元 / 百万 tokens,谷时基准;高峰自动 ×peakMultiplier)
rates:
deepseek-flash: { cacheHit: 0.02, cacheMiss: 1, output: 4 }
deepseek-v4-pro: { cacheHit: 0.15, cacheMiss: 4.5, output: 13.5 }
# 中转站 / 其它模型可以自己补:
# DeepSeek-V4.1-Flash-1017: { cacheHit: 0.02, cacheMiss: 1, output: 4 }
# claude-opus-5: { cacheHit: 0.5, cacheMiss: 15, output: 75 }
peakMultiplier: 2 # 高峰价 = 谷时 × 这个倍数
peakWindows: [[9, 12], [14, 18]] # 北京时间的小时区间
weekendOffPeak: true # 周末全天谷时
offPeakDays: [] # 法定节假日(YYYY-MM-DD):这两天也按谷时
peakOverrideDays: [] # 反过来强制按高峰
searchCallPrice: 0.005 # 每次成功搜索/抓取(¥5/千次)
maxSessions: 400 # 最多统计多少个会话(从新到旧)
showEmpty: false # true 时也列出没有任何用量的会话
listTtlMs: 30000 # 会话目录列表缓存多久(新建会话最多晚这么久出现)
titleTtlMs: 300000 # 会话标题缓存多久
rates 里的模型名会归一后再匹配,所以 DeepSeek-V4.1-Flash-1017 和 deepseek-v4.1-flash 是同一个键。
「设置 → 会话花费」每 20 秒自动刷新一次,但刷新是增量的:
seq)缓存,没有新事件就不重复折叠;visibilitychange 控制)。本机实测(41 个有用量的会话、约 34 亿 tokens):宿主重启后首次打开(冷缓存,要读全部日志)约 1.4–5 秒;之后每次 20 秒刷新 约 14 毫秒。界面底部显示「本次刷新耗时 N ms」,可以自己核对。
代价:新建的会话最多晚 30 秒出现在列表;标题最多晚 5 分钟变。
pricing.js 或 config.rates。offPeakDays 为空时不会多算成谷时,宁可略偏高);填上当年的节假日日期即可更准。gemini-4-argon、tencent/Hy4-preview、claude-opus-5 等)没有官方价,按 token 只统计不猜价;补上 config.rates 就会计费。调研时找到的成熟方案,按「每个会话花了多少」这个目标排序:
@dawn0608/dsh-session-cost(1.2.2,声明支持 DSH ≥0.2.2-rc.1):胶囊 + 明细,价格从官方页自动同步;不含子代理。dsh-cost-pill(1.3.2,DSH ≥0.2.2-rc.1):胶囊 + 余额 + 峰谷点,子代理并入本会话;费率随版本发布。dsh-cost-meter(1.9.64):预算、历史、多厂商额度,很重。@kidli1412/dsh-session-cost、dsh-plugin-session-spend、@shi-yangyang/dsh-token-dashboard 等。本插件选的是自建:数据口径贴 DSH 0.2.2 的 tokenUsage 投影语义(inputTokens = 未缓存输入)、逐笔峰谷、按模型归一、把子会话单独列出,并且不引第三方依赖。
| 文件 | 作用 |
|---|---|
index.js |
宿主:读会话日志、按 usage 计价、注册只读 HTTP 路由(/dsh-session-cost/api/*) |
pricing.js |
单价表、模型名归一、峰谷判定、单条 usage 计价 |
client.js |
客户端:设置页「会话花费」与输入框下方花费标签 |
test/host.test.mjs |
离线自检(假 ctx 跑真实 apply(),校验计价、token 桶、搜索费、路由) |
node test/host.test.mjs
设置 → 会话花费
┌──────────────────────────────────────────────────────────────┐
│ 会话花费 │
│ 把每个会话日志里的 token 用量,按单价表折算成金额。 │
│ │
│ ┌──────────┐ ┌────────┐ ┌────────┐ ┌──────────────────┐ │
│ │ ¥137.28 │ │ 41 │ │ 9660 │ │ 34.17 亿 │ │
│ │ 全部会话 │ │ 有用量 │ │ 模型请求│ │ 总 tokens(含缓存)│ │
│ └──────────┘ └────────┘ └────────┘ └──────────────────┘ │
│ 合计含搜索/抓取 140 次 ¥0.700(按 ¥5/千次估算) │
│ │
│ 按模型 │
│ deepseek-flash deepseek-account · 9178 次请求 · … ¥123.87│
│ DeepSeek-V4-Pro-0813 luoying-api · 189 次请求 · … ¥10.63 │
│ │
│ 按会话 │
│ QQ [进行中] ¥47.38 │
│ 2026-10-25 11:03 · deepseek-flash · 3109 次请求 · 缓存 99.4% │
└──────────────────────────────────────────────────────────────┘
输入框下方:
1 轮 157 步 · 219 tok/s · 36.5M tok · 缓存命中 99% · ● ¥1.37 · 29%
MIT(见 LICENSE)。截图未随仓库发布,因为界面里含真实会话标题与账户信息。
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: deepseek-harness。