DeepSeek Harness plugin

dsh-session-cost-doglin

Real-time session cost meter for the DeepSeek Harness web GUI: folds provider token usage into a per-session cost projection and displays it live under the composer.

Jump to install

Source facts

Repository
dog-lin/dsh-session-cost
Latest update
Aug 18, 2026
Category
Just for Fun
GitHub stars
0
Format
plugin
Catalog evidence
Upstream dsh.bundle evidence
Evidence path
package.json#dsh.bundle
Checked against
0.1.0-rc.8
Upstream check date
2026-08-20

This evidence comes from the upstream catalog. This site has not installed, run, or security-reviewed the plugin.

Install

Start with a prompt that asks an agent to review the GitHub repository and source. Switch to the command if you want to install it yourself.

Copy this prompt into DSH, Codex, or another agent and ask it to review the GitHub repository and source first.

Do not install or run any commands yet. Read this plugin's GitHub repository, README, and relevant source code. Then answer the questions below clearly and directly so I can decide whether it fits my needs:

1. What is this plugin, and what problem does it solve?
2. Who is it for, and what are its typical use cases?
3. How is it used after installation? Include one minimal example.
4. What known limitations or privacy, security, compatibility, or maintenance risks does it have?
5. Give a clear recommendation: recommend, conditionally recommend, or do not recommend, with reasons.

Distinguish statements documented by the repository, inferences from source code, and unknowns. If evidence is insufficient, say so explicitly. Do not guess or simply repeat the README.

GitHub: https://github.com/dog-lin/dsh-session-cost
Plugin: dsh-session-cost-doglin
Author: dog-lin

Check the source files

Read the README and other files from this plugin directory before installing.

File explorer3 files
README.mdSource · read only

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,重启不丢失。 每次变动都会在服务日志里打一条明显的变更记录;抓取失败则沿用上次价格并在投影中报告 pricingWarn,界面悬浮提示可见。

2. 本地配置可覆盖 / 冻结 pricing 里的条目是"种子":官网抓取到新价后会被更新。给某模型加 pin: true 即完全由你掌控,永不自动改动。fallback 仍是未收录模型的兜底(默认 0 = 未计价并计入 unpricedRequests)。

3. 来源可见 投影值携带 pricingSourceofficial-auto / official-auto-failed / config)、 pricingUpdatedAt(最近一次成功抓取时间)和 pricingWarn(抓取失败/疑似巨变待确认时非空), 客户端悬浮提示直接展示,价格是否"新鲜"一目了然。

价格变动时的行为:新请求按新价计费;过去请求按其发生时刻的价格计费(时间轴)。若你手动改了配置, profile 补丁热加载会重启该行并用当前时间轴重算全部历史(确定性重放,结果一致)。

峰谷定价

DeepSeek 自 2026-08-17 00:00(北京)起实行峰谷价:高峰 9:00–12:00、14:00–18:00(北京),闲时为高峰一半。 插件支持两种写法(可同时用于配置与自动同步):

pricing:
  deepseek-v4-flash:
    peak:    { input: 3.0, output: 9.0,  cacheRead: 0.10 }
    offPeak: { input: 1.5, output: 4.5,  cacheRead: 0.05 }

或显式时间轴(from 接受 ISO 时间、epoch 毫秒或中文日期"2026 年 8 月 17 日 00:00"):

pricing:
  deepseek-v4-flash:
    schedule:
      - from: 0
        input: 1
        output: 2
        cacheRead: 0.02
      - from: 2026-08-17T00:00:00+08:00
        peak:    { input: 3.0, output: 9.0,  cacheRead: 0.10 }
        offPeak: { input: 1.5, output: 4.5,  cacheRead: 0.05 }

peakWindow: ["09:00-12:00", "14:00-18:00"] 可自定义高峰时段(默认即官方窗口,北京时间)。

安装 / Install

从 GitHub 安装(推荐)

dsh plugin --profile web add git+https://github.com/dog-lin/dsh-session-cost.git

或用 pnpm 的 github: 简写:

dsh plugin --profile web add github:dog-lin/dsh-session-cost

本地安装:在插件包目录执行(<path> 可以是本目录或打包后的 tarball):

dsh plugin --profile web add <path>

然后刷新浏览器页面(F5)。dsh plugin add 会把插件写入 profile 的 dsh.profile.bundles,插件自带的 cordis.patch.yml(bundle 层)会在每次启动时自动注册 session-cost 这一行——不要再把同一行 insert 复制到 $DSH_HOME/profiles/web/cordis.patch.yml(profile 层):同一个 loader entry id 被两层各插入一次, 下次冷启动会直接报 duplicate loader entry id: session-cost 并启动失败。

宿主代码变更(如本插件的功能升级)需要重启一次 dsh web,因为宿主模块走 Node 模块缓存。

想改配置但不想重启?

Profile 补丁支持热加载,但要用按 id 覆盖,而不是再 insert 一次:

# $DSH_HOME/profiles/web/cordis.patch.yml
- id: session-cost
  name: 'dsh-session-cost'   # 可选:与现有行做名称校验
  config:
    currency: CNY
    autoUpdate: true
    updateIntervalHours: 24
    pricing:
      deepseek-v4-flash: { input: 1, output: 2, cacheRead: 0.02, cacheWrite: 0 }
      deepseek-v4-pro:   { input: 3, output: 6, cacheRead: 0.025, cacheWrite: 0 }
    fallback: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }

注意 config整体替换,要写全;autoUpdate 默认开启,官网抓取会覆盖种子价。 保存后 profile 层热加载,只更新这一行的配置,不会产生第二条同名 entry。

故障排查 / Troubleshooting

启动报 duplicate loader entry id: session-costsession-cost 这一行同时出现在 插件自带的 cordis.patch.yml(bundle 层)和 profile 的 cordis.patch.yml(profile 层)。 删掉 profile 层里的那一份(保留 bundle 层),重启即可。

配置 / Configuration

config:
  currency: CNY            # 显示与计价货币(ISO 4217)
  autoUpdate: true         # 是否自动同步官网价格(默认 true)
  updateIntervalHours: 24  # 抓取间隔(默认 24)
  pricing:                 # 按模型 id 计价;种子值会被官网新价更新,加 pin: true 则冻结
    deepseek-v4-flash: { input: 1, output: 2, cacheRead: 0.02, cacheWrite: 0 }
    deepseek-v4-pro:   { input: 3, output: 6, cacheRead: 0.025, cacheWrite: 0 }
  fallback:                # 未在 pricing 中的模型(默认全 0 = 未计价)
    input: 0
    output: 0
    cacheRead: 0
    cacheWrite: 0

投影值 / Projection value

sessionCost 投影的值为:

{
  "currency": "CNY",
  "totalCost": 0.0123,        // 本会话累计费用
  "requests": 3,              // 已计费的模型调用步数
  "unpricedRequests": 0,      // 价格表中没有的模型调用步数
  "inputTokens": 12000,
  "outputTokens": 600,
  "cacheReadTokens": 3000,
  "cacheWriteTokens": 200,
  "lastModel": "deepseek-v4-flash",
  "pricingSource": "official-auto",   // official-auto | official-auto-failed | config
  "pricingUpdatedAt": 1786805927947,  // 最近一次官网抓取时间(epoch ms)
  "pricingWarn": null                 // 抓取失败或疑似巨变待确认时非空
}

已知限制 / Limitations

  • 费用按会话自身日志统计;子代理(subagent)的模型调用发生在子会话的日志里,不会计入父会话的金额。
  • 推理 token(reasoningTokens)是输出桶的子集,按输出价计费,不再重复加价。
  • 新模型计价有一个窗口:模型首次出现在官网价格表后,插件要等下一次抓取(启动或每 24h)才认识它;

在认识之前,该模型的请求计入 unpricedRequests 并在悬浮提示标注「未计价」(不会静默漏算——你总能看见)。 认识之后按官网价从时间 0 起算。若你关闭了 autoUpdate,新模型需手动加入 pricing

  • 官网页面是唯一自动价格源,解析基于页面结构,失败即安全降级(沿用上次价格并提示),不会给出错误的"自动"数字;若官网改版导致连续抓取失败,pricingWarn 会一直提示,届时应手动更新配置。
  • 价格终归是部署事实:自动同步只是让"默认跟随官网"成为常态,pin: true 的条目和 fallback 始终由你掌控。