dsh-client-ui-session-cost:Composer 统计栏 Session 费用估算

前言

在 DeepSeek Harness(DSH)里用 Composer 对话时,界面统计栏通常只显示速度与 token 用量。若要对照 DeepSeek 公开价目表估算「这一整段 Session 大概花了多少钱」,需要自己查 projection、手算分桶,或离开当前界面。下面介绍的客户端插件 dsh-client-ui-session-cost 在 Composer 输入框下方统计栏里增加一枚 Session 费用 小标签,与现有 speed、token 标签并列,数字随 Session 流式更新,悬停可看分桶与费率说明。

这是什么

dsh-client-ui-session-cost 是 DSH 的 客户端(client) 插件,维护者为 iskrantxusa,仓库 iskrantxusa/dsh-client-ui-session-cost。官方简介为:在 DeepSeek Harness Composer dock 中显示 Estimated session cost pill(Session 费用估算标签)。

插件不发起网络请求、不上报遥测,只读取 DSH 已为 Session 维护的 tokenUsage projection,按内置 DeepSeek 列表价(USD / 1M tokens)换算后展示。估算覆盖 整个 Session(不限于当前已加载的历史页),因为计价依据是 DSH 持久化的 token 用量投影。

社区目录页:https://www.skillhub.cn/plugins/iskrantxusa/dsh-client-ui-session-cost(独立站点,与 DeepSeek / 幻方无官方从属关系)。

核心功能

统计栏费用标签

安装并在 Web 或 Desktop DSH profile 中生效后,Composer 统计 dock(输入框下方、与 speed / token 同一行)会出现类似:

Cost ≈ $0.15

的展示。鼠标悬停该标签时,可查看 token 分桶、当前生效费率以及所用模型。

计价范围与数据来源

Wire 视图上的用量字段为:

{ uncachedInputTokens, outputTokens, cacheReadTokens, cacheWriteTokens }

合计逻辑为 cacheMiss + cacheRead + output;cache miss 侧包含 cacheWriteTokens。模型来自 modelSelection projection(优先 next,否则 lastUsed)。若模型未知,则按 deepseek-flash 费率估算,tooltip 会标明 assumed rates。Session 中途换模型时,整段 Session 按 最新模型 计价(projection 不保留逐请求模型历史)。

以下情况 不计入 该估算:Search/Fetch API 请求、自带计费的工具、账户赠金等。

内置费率与峰谷

费率对齐 DeepSeek 文档 Models & Pricing(USD / 1M tokens):

Model Cache hit (peak / off-peak) Cache miss (peak / off-peak) Output (peak / off-peak)
deepseek-flash $0.006 / $0.003 $0.30 / $0.15 $1.20 / $0.60
deepseek-v4-pro $0.044 / $0.022 $1.32 / $0.66 $3.96 / $1.98

Peak 为 UTC 周一到周五 01:00–04:00 与 06:00–10:00;其余时段、周末及 DSH 未识别的中国节假日按 off-peak(半价)处理。官方价目变更时,需自行修改仓库 lib/client.js 中的 PRICES、 bump 版本并重新安装。

实现要点(便于排查)

  • lib/index.js:host 侧空实现,仅满足 Loader 对 dsh.client 包的行声明。
  • lib/client.js:在 conversation.composer.dock 列表槽注册 id: cost、order: 2 的条目;无构建步骤,除平台 React 外无额外依赖。
  • 安装包同时是 bundle 与 patch 目标:cordis.patch.yml 插入 ui-session-cost loader 行,并在 dsh.profile.bundles 中选中本包。

安装与启用

插件以当前 DSH 进程权限运行;安装前建议浏览仓库源码与 MIT 许可证。下列命令与路径均来自项目 README。

从 Discover 市场索引安装

  1. 开启 Experimental plugins → Custom plugin markets。
  2. 打开 Plugins → Discover → Add index source,填入:
https://raw.githubusercontent.com/iskrantxusa/dsh-client-ui-session-cost/main/market/index.json
  1. 在市场中选择 Session cost pill,按确认流程安装所需版本。索引为 format-1 JSON,位于仓库 market/index.json,并 pin 到指定 Git commit。

从 GitHub 安装(README 推荐的无市场方式)

PowerShell:

dsh plugin add github:iskrantxusa/dsh-client-ui-session-cost

或在 Web GUI:Sidebar → Plugins → Add plugin,粘贴 github:iskrantxusa/dsh-client-ui-session-cost 后安装。

默认开启 HMR 时,patch 热应用,标签无需重启即可出现;若关闭 HMR,需重启 DSH。

从 release 压缩包安装

下载 dsh-client-ui-session-cost-0.1.0.tgz,在 Plugins → Add plugin 选择本地文件,或:

dsh plugin add C:\path\to\dsh-client-ui-session-cost-0.1.0.tgz

手动安装(无法使用插件管理器时)

将本仓库目录复制到:

%USERPROFILE%\.dsh\profiles\desktop\node_modules\dsh-client-ui-session-cost

并在 %USERPROFILE%\.dsh\profiles\desktop\cordis.patch.yml 增加:

- insert:
    - id: ui-session-cost
      name: dsh-client-ui-session-cost

不要 在已通过 bundle 安装后再保留上述 manual 块:两者插入相同 row id。若改用 bundle,请先删除 manual 块。

典型用法

经过上面的安装步骤后,正常使用 Composer 即可:统计栏会自动出现费用标签,Session 流式输出时数字会随 tokenUsage 更新。需要核对分桶或峰谷费率时,悬停 Cost ≈ $… 标签查看 tooltip。

本地开发或改价后,可在仓库根目录执行:

node test/test-cost.cjs

该测试在 VM 中加载 bundle 桩环境,校验官方费率数学、峰谷边界、展示舍入、未知模型回退以及 conversation.composer.dock 注册行为。

适用场景与注意

适合:在 Web / Desktop DSH 中长期使用 Composer、希望在同屏看到 整段 Session 参考费用、并与 token 速度信息对照的开发者。

注意:

  • 展示结果为 参考信息,不是账单;以 DeepSeek 价目页 为准。
  • 需要 Web 或 Desktop DSH profile;无 HMR 时需重启。
  • 卸载:Plugins → 对应 bundle → Remove,或等价的 dsh plugin remove;手动安装则删除包目录及 cordis.patch.yml 中 - id: ui-session-cost 块。

结尾

dsh-client-ui-session-cost 把 Session 级 token projection 转成 Composer 统计栏上的一枚费用标签,只读本地 projection、不联网,适合作为日常开发的用量与价目对照。目录页见 skillhub.cn/plugins/iskrantxusa/dsh-client-ui-session-cost,源码与安装说明见 GitHub 仓库。

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

小夜