返回目錄

dsh-all-usage

編輯精選維護狀態: 活躍

particlelight/dsh-all-usage

DeepSeek Harness 用量看板 / Usage dashboard: tokens, cache, model/provider/workspace analytics, DeepSeek balance, heatmap, and CSV export.

前往 GitHub專案首頁
$ dsh plugin add dsh-all-usage

安裝

dsh 沒有統一的安裝指令 —— 把該外掛 README(見下方)中的設定行加入你的 profile / patch 設定,然後重啟即可。

查看安裝教學

8

星數

0

Fork

JavaScript

語言

MIT

授權條款

2026-08-17

建立於

2026-09-29

最近推送

README

dsh-all-usage

awesome · DSH plugin npm downloads stars license CI DSH status

中文 · English

中文

DeepSeek Harness 全量用量看板:按模型、供应商、工作区和时间范围分析 Token、缓存与账户余额。

功能

  • 热力图:53 周使用热力图;按工作区筛选并查看每日回合与 Token 明细
  • 模型统计:支持混合查看、按模型合并、按供应商汇总三种维度,展示调用次数、各类 Token 与缓存命中率;模型行与筛选下拉显示真实厂商品牌 SVG 图标(未知/混牌保持中性)
  • 摘要与工作区:Token 用量、缓存命中、估算成本、账户余额、连续使用、工作区 Token 分布和明细
  • 成本统计 / 价格表:从 models.dev 同步模型价格;按输入、输出、缓存读取和缓存写入四个桶计算,保存价格快照,明确区分已计价、免费模型和未计价调用。成本设置是一张可编辑的价格表:每行一个账本模型,价格框直接编辑即写入该模型的手工价,「官方模型」列选定映射后该行自动改用官方目录价,并可为每行配置上下文费率档位与分时段(UTC 峰谷)计费;配置里存在但账本暂无用量的行同样可见、可改、可删。峰谷规则可额外开启「中国法定节假日全天按谷时计价」,节假日日期以显式列表保存在该模型的峰谷计划里(按北京时间 UTC+8 日历日判定,支持 2026-10-01..2026-10-07 区间写法,也可一键「从公开日历载入」当年放假安排后冻结进策略)。内置 DeepSeek 峰谷表已自带 2026 年官方放假安排(随插件版本更新),官方直连或已映射到官方条目的行无需任何配置即按节假日谷价计价;非官方直连的中转行仍按静态价,映射后生效
  • 导出:按当前时间范围和模型聚合方式导出 CSV
  • 时间范围:今日、近 30 天、近 90 天、全部,或在全部可扫描历史日数据中自定义起止日期;热力图始终展示最近 53 周
  • 工作区别名:在侧栏入口打开看板后管理,持久化保存到 $DSH_HOME/storages 的 KV 单元 all_usage_aliases
  • 界面语言:在看板顶部切换中文与 English;选择会保存到浏览器本地
  • 完整历史与增量重建:基线扫描全部可读历史会话;独立用量账本同时作为每会话游标——未变化的会话直接复用账本,新增事件只增量回填,长历史重启不再全量重建
  • 重启免读:用持久化日志的 revision 作为每会话的变更信号(只读头部行 + stat,不读全量)——日志未变的会话重启时连事件都不读,直接从账本复用;仅日志变化(新增/修改)的会话才做增量读取
  • 数据健康与按需刷新:扫描完成后浏览器只检查轻量状态版本,只有用量、别名或同步状态变化时才拉完整历史;显示本次数据更新时间、历史扫描健康、revision 免读、实际读取、账本恢复和失败,网络异常保留上次成功数据并可重试
  • 工作区注册同步:监听 DSH 的 domain/changed 事件自动跟随工作区注册表——注册表一有改动(创建/删除/重命名/重排/归档/成员变化)就重读 workspaceRegistry.list();只对新增/删除的工作区做增量处理,未变化的已有工作区直接复用已计算账本(零重扫)。统计严格限定已注册工作区:未注册 cwd(含存在但未登记目录)一律忽略
  • 性能优化:Host 在 ingest 时维护 local/UTC 的日期、工作区、模型身份日级 cube 与单日小时桶;scope 查询按 bucket 合并,成本使用精确 BigInt 小数累加,53 周热力图只生成实际需要的字段,并继续使用 revision-scoped snapshot/records 缓存和可回收的实时事件队列;Client 将热力图、tooltip、趋势、环形图、请求日志和定价对话框隔离为 memoized 边界,指针坐标通过 ref + requestAnimationFrame 更新,不再触发整页重渲染;浏览器入口在打包前确定性压缩
  • 趋势折线图:按当前范围、时区、工作区、供应商和模型显示输入、缓存读写、输出、推理及总处理量;单日范围按小时聚合并显示小时轴,跨日范围按日聚合;使用平滑单调曲线与入场动画,悬停查看精确值,图例可切换曲线,点击点位进入当日明细
  • 统一筛选与审计:工作区、供应商、模型和日期筛选贯穿摘要、热力图、趋势、表格与 CSV;工作区、供应商、模型三个筛选维度可独立自由组合,工作区、供应商和模型选项只展示当前日期范围内实际使用过的值;切换范围后失效筛选会自动清除;请求日志以紧凑分页表常驻显示,选择单条后查看分组 Token 详情
  • Token 口径:输入按「未含缓存命中」计,缓存命中 / 写入与推理独立成桶;全 0 用量的重放事件不会覆盖已记录的真实用量,仅缓存命中的请求也会计入
  • 成本口径:模型价格来自 models.dev 的 USD / 1M Token 目录;成本快照按 DSH 已归一化的 fresh input 和四类价格桶计算,倍率只作用于最终总价,已有正成本历史不会因价格更新重算;只按模型选择官方厂商条目,未找到官方价格时显示为未计价。同一官方模型的价格在所有行之间共享:价格框写入的是该模型的手工价条目;价格改动永不重算已有正成本,而峰谷规则改动会按新政策重新对账该模型历史

兼容性与已知限制

  • 运行环境:需要 Node.js >=22 <25;CI 会在 Node 22 和 Node 24 上运行测试、语法检查和 npm 包内容检查。
  • DSH 兼容:package.json 声明 DSH runtime >=0.1.1-rc.1 <0.1.5-0 || >=0.1.5-rc.1 <0.1.6-0 || >=0.1.7-rc.2 <0.1.8-0 || >=0.2.0-rc.2 <0.2.1-0,已使用 0.2.0-rc.2、0.1.7-rc.2、0.1.5-rc.2、0.1.5-rc.1、0.1.1-rc.2 和 0.1.1-rc.1 的真实 Cordis 服务链验证,且全部纳入 CI smoke 矩阵(Node 22/24 双档);0.1.2-rc.1 已通过实际使用验证兼容,但未纳入 CI smoke 矩阵。声明按元组拆成四段而非写成单一区间,是因为 node-semver 只有在范围里存在与目标版本同 major.minor.patch 且自身带预发布标签的比较符时,才会放行该预发布版本 —— 例如必须写成 >=0.2.0-rc.2 才能让 0.2.0-rc.2 进入范围。
  • 桌面客户端(Electron,Windows):本插件在 DSH 桌面客户端上实测运行正常(实测 @deepseek-ai/dsh-desktop 0.1.7-rc.2)。桌面客户端会在窗口顶部为自身的最小化 / 最大化 / 关闭按钮保留一条 40px 顶栏,并在文档上标记 data-windows-titlebar 与 --dsh-windows-titlebar-height;面板据此从该条下方开始绘制,所以桌面端自己的关闭按钮永远不会被面板盖住。浏览器端没有该标记,不留白。顶栏高度优先取宿主声明,其次取 Window Controls Overlay 矩形,最后退回 UA;需要微调时可在 DevTools 执行 localStorage.setItem('dsh-all-usage:topInset', '48') 后刷新(0 表示不留白),无需重新构建。桌面客户端自带运行时,其运行时 0.1.7-rc.2 已纳入声明区间与 CI smoke 矩阵(见下表)。
  • Web 服务依赖:Host 将 webServer 声明为必需依赖,确保服务晚挂载时由 DSH 等待后再执行插件;该包面向 DSH Web profile,不提供无 WebServer 的 headless 路由。HTTP 守卫还会检查真实 socket peer,反向代理只有在连接本身来自 loopback 时才会被接受。写接口(价格保存、立即同步、节假日抓取、别名)以进程令牌为授权凭据,不强制要求 Origin:DSH 桌面端把 UI 跑在自定义协议上、请求由 Electron 主进程转发,转发时会删掉 Origin(连同 Host/Cookie/Sec-Fetch-*),强制 Origin 会让桌面端所有写入 403;而 Origin 若存在仍必须是 loopback 或桌面端自身 scheme,Host 仍必须是 loopback(防 DNS rebinding)。
DSH runtime Node.js 支持 真实 Cordis smoke 结论
0.2.0-rc.2 >=22 <25,CI 覆盖 22/24 通过(真实 Cordis 服务链,CI 覆盖 Node 22/24) 已声明、已验证(DSH 官方 next 线;本机 web profile 即运行于此版本)
0.1.7-rc.2 >=22 <25,CI 覆盖 22/24 通过(真实 Cordis 服务链,CI 覆盖 Node 22/24) 已声明、已验证(DSH 桌面客户端即运行于此版本)
0.1.5-rc.2 >=22 <25,CI 覆盖 22/24 通过(真实 Cordis 服务链,CI 覆盖 Node 22/24) 已声明、已验证
0.1.5-rc.1 >=22 <25,CI 覆盖 22/24 通过(真实 Cordis 服务链,CI 覆盖 Node 22/24) 已声明、已验证
0.1.2-rc.1 >=22 <25 通过(实际使用验证,未纳入 CI) 已实际验证兼容
0.1.1-rc.2 >=22 <25,CI 覆盖 22/24 通过(真实 Cordis 服务链,CI 覆盖 Node 22/24) 已声明、已验证
0.1.1-rc.1 >=22 <25,CI 覆盖 22/24 通过(真实 Cordis 服务链,CI 覆盖 Node 22/24) 已声明、已验证
其他版本 >=22 <25 未测试 不在已验证矩阵内

未列出的 DSH 版本不代表一定不兼容;提交问题时请附 DSH、Node.js 和插件版本。

  • 中断请求:上游请求被中断时可能只有 assistant/chunk 的 usage,没有最终 assistant/message;本插件会保留该 chunk 用量。同一 turn / step 后续出现最终 message 时,message 会替换 chunk。若上游完全没有 usage 事件,则无法从响应内容精确恢复 Token。
  • 估算成本:成本是基于 models.dev 价格和 DSH usage 桶的估算,不是供应商账单;目录不可用或模型没有官方匹配时不会猜测价格,而是显示未计价。缓存读取、缓存写入和 reasoning 的口径取决于 DSH 上游事件。
  • 分层价格:models.dev 的 tiered/context-dependent 价格按本次请求的输入上下文(fresh input + cache read + cache write)选择对应档位;阈值边界遵循目录定义,无法验证的异常 tier 仍显示为 unsupported。
  • 工作区边界:只有 cwd 能映射到 DSH 已注册工作区的会话才进入统计;未注册 cwd(包括已存在但未在 registry 中登记的目录)会被忽略。工作区注册列表通过 DSH 的 domain/changed 探针自动同步:注册表一有改动就重读并只对新增/删除的工作区做增量处理,未变化的已有工作区直接复用已计算账本,不会全量重扫。会话尚未成功 flush 前删除或损坏的日志无法由独立账本恢复。工作区被删除时历史用量不会丢失:它会被保留并汇总为一行「已删除」。

本地统计与官方账单

本插件展示的是 DSH 本地事件日志上的可重放统计,不是供应商账单的镜像:

  • 本地统计读取 DSH 的 assistant/chunk、最终 assistant/message 和其他会话事件,按同一 turn / step 去重和替换;官方账单可能按供应商自己的请求、分词器、舍入、折扣、免费额度和结算周期计算。
  • 失败请求只要留下 usage chunk,就会进入本地统计;供应商是否对该失败请求收费,应以官方账单为准。
  • 价格来自 models.dev 的公开模型目录和本地显式覆盖;目录价格、供应商实际价格、区域费率和账单折扣可能不同。成本字段应理解为估算值。
  • 本地统计只包含已注册工作区;未注册 cwd 的旧 ledger 不进入统计。已删除工作区的历史用量会保留并汇总为一行「已删除」,删除工作区不会让历史统计变小。统计仍可能因日志损坏、清理或上游没有发出 usage 而少于官方账单。

可复现事件示例

下面的事件是脱敏的最小示例;完整可运行数据见 fixtures/usage-events.json。

失败请求仍保留 usage chunk

[
  {"type": "assistant/chunk", "data": {"turn": 1, "step": 1, "chunk": {"type": "usage", "usage": {"inputTokens": 100, "outputTokens": 20}}}},
  {"type": "request/error", "data": {"code": "upstream-failed"}}
]

没有最终 assistant/message 时,chunk 仍计为一个本地调用;这不等于官方一定收费。

孤立 usage chunk

{"type": "assistant/chunk", "data": {"turn": 1, "step": 1, "chunk": {"type": "usage", "usage": {"inputTokens": 7, "cacheReadTokens": 8}}}}

缺少 request/context 或 request/header 时,Token 仍可统计,但模型身份显示为 Unknown;插件不会从 Provider 名称或展示字符串猜测模型。

缓存 Token 的四桶含义

{"inputTokens": 100, "outputTokens": 20, "cacheReadTokens": 40, "cacheWriteTokens": 5, "reasoningTokens": 3}

本地 processed total 为 100 + 20 + 40 + 5 + 3 = 168;成本只对 input、output、cacheRead、cacheWrite 四个桶定价,reasoning 不会再次加到 output。

使用仓库中的 fixture 复现:

node scripts/replay-fixture.mjs fixtures/usage-events.json

该命令会加载真实插件 Host、调用兼容 API、校验预期 Token/records,并输出不含敏感信息的摘要。

报告问题

最近更新

v1.1.17

  • 修复:DSH 桌面端无法保存成本设置。 写接口(保存价格、立即同步、节假日抓取、别名)原先要求请求带 Origin 且与 loopback Host 同源,而桌面端把 UI 跑在自定义协议 dsh-app://app 上、请求由 Electron 主进程转发时会删掉 Origin(连同 Host/Cookie/Sec-Fetch-*),于是桌面端的所有写入必然 403——保存价格报「没有权限」、models.dev 目录永远同步不下来、自动同步勾选后回滚。现在写入以进程令牌为授权凭据(跨域页面既读不到也塞不进表单 POST),Origin 存在时仍必须是 loopback 或桌面端自身 scheme,Host 仍必须是 loopback(防 DNS rebinding)。
  • 健壮性修复:宿主未下发 usageBacked 时不再断言「账本无用量」,改为「用量未知」三态(独立标记、行样式与页脚计数);/api/all-usage/status 新增派生的 capabilityId(令牌轮换时变化,令牌本身只在完整快照里下发)与 pluginVersion,页面据此察觉宿主被重新加载、写入遇 403 时自动重取令牌并重试一次,宿主与页面版本不一致时直接提示「请重启 DSH」。

完整版本记录见 CHANGELOG.md。

截图 / Screenshots

dsh-all-usage 看板总览 / Dashboard overview

dsh-all-usage 成本统计设置 / Cost statistics settings

dsh-all-usage 请求日志与审计 / Request logs and audit

安装

本插件是标准的 DSH 社区插件包(声明 dsh.bundle manifest 与 Web Client),数据来自持久化会话日志和独立用量账本,安装后自动回填历史。

官方插件命令(推荐)

dsh plugin --profile web add github:ParticleLight/dsh-all-usage

安装命令会装配 bundle;随后刷新浏览器页面以加载 Client,无需手动修改 profile。若当前 DSH 版本未动态装配新包,请按 DSH 的提示重载包或重启进程。

手动注册(本地包)

  1. 把本目录放入任意位置,并在 $DSH_HOME/profiles/node_modules/ 下创建指向本目录的符号链接(Windows 用 junction):

    New-Item -ItemType Junction -Path (Join-Path $env:DSH_HOME 'profiles/node_modules/dsh-all-usage') -Target '<本目录绝对路径>'
    
  2. 在 $DSH_HOME/profiles/web/cordis.patch.yml 添加一行:

    - insert:
        - id: all-usage
          name: dsh-all-usage
    

用户 patch 层会被热重载:保存后刷新页面即可。

架构

  • Host 端(入口 lib/index.js,组装 lib/plugin.js):按职责拆分为 aggregation.js(聚合与查询)、ledger.js(持久账本)、session-sync.js(历史/实时同步)、pricing-runtime.js(运行时定价)、balance.js(余额)、http.js(安全路由);扫描 turn/end、assistant/chunk usage 和最终 assistant/message.usage,监听 session/event 实时折叠,并通过 webServer 服务注册数据路由:
    • GET /api/all-usage — 兼容统计快照
    • GET /api/all-usage/status — 轻量 revision 与同步健康状态,并附带最近一次客户端环境报告(clientEnv)、运行中插件的版本号(pluginVersion)与写入令牌的派生 ID(capabilityId,令牌轮换时变化,用于让页面察觉宿主被重新加载;令牌本身只在完整快照里下发)
    • GET /api/all-usage/query — 按 scope 返回聚合、daily/hourly 趋势和 heatmap 数据;单日 scope 填充 hourly,跨日 scope 的 hourly 为空
    • GET /api/all-usage/records — 按 scope 分页返回脱敏 canonical usage rows
    • GET /api/all-usage/balance?force=1 — 账户余额(复用 llm-deepseek 的 API Key 配置)
    • POST /api/all-usage/alias — 设置工作区别名
    • GET /api/all-usage/pricing — 读取可编辑价格表所需的完整配置:逐模型的生效费率与状态、映射、手工价、峰谷计划(含内置表来源与完整规则)以及仅存在于配置中的行
    • GET /api/all-usage/pricing/models?q=... — 检索官方模型 ID 与名称匹配结果(含预览费率、是否分层计费、是否有内置峰谷表)
    • POST /api/all-usage/pricing — 保存同步、mapping、手工价,以及上下文费率档位与峰谷时段规则(请求形状不变)
    • POST /api/all-usage/pricing/sync — 手动同步 models.dev 并回填未计价调用
    • POST /api/all-usage/pricing/holidays — 按年份抓取中国法定节假日安排(holiday-cn 数据集,jsDelivr 主源、GitHub raw 兜底,主机侧缓存 24 小时),只返回放假日日期列表与来源;不写入任何配置,由客户端冻结进峰谷计划
    • GET /api/all-usage/client-env — 客户端环境诊断上报(UA、窗口控件遮罩高度、预留顶栏值及其来源、视口、面板矩形);客户端在加载与打开面板时各上报一次,只在内存保留
  • Client 端:可读源码位于 src/client.js,npm run build:client 使用固定版本 Terser 生成 window.__ModuleLoader__ 工厂格式的 lib/client.js 浏览器 bundle,并注册侧边栏「用量统计」入口(sidebar.footer.action 槽位)。所有 API 仅接受本机 loopback 请求并拒绝显式跨域请求;余额读取与别名写入还要求插件启动时生成、仅在当前进程有效的令牌(余额 GET 兼容浏览器省略 Origin)。英文模式的日期分桶、范围筛选、连续使用、热力图和导出时间统一按 UTC;中文模式按本地时区。

数据说明

  • 使用次数与 Token 来自 DSH 会话日志;session/flush 只在存在新的相关事件时重建并将派生账本写入异步队列,同一 session 的 pending record 会合并,插件退出时 drain;插件激活时会回填日志与账本历史,插件卸载/重启后已成功持久化的数据不丢
  • 按日范围统计会保留全部可读取历史会话的有使用记录日期;热力图仅作为最近 53 周的固定视图窗口
  • 会话删除后,已成功 flush 的用量仍从独立账本恢复;工作区删除同样不会丢数据——其历史用量汇总为一行「已删除」(含未落账的实时用量)。会话销毁提示和周期对账只负责触发重建,不会删除账本记录
  • 同一会话的同一 turn / step 只保留一份最终 usage;重试或替换消息会替换旧贡献,不重复累计
  • 输入 Token 按「未含缓存命中」计(缓存命中 / 写入独立成桶);全 0 用量的重放事件不会覆盖已记录的真实用量,纯缓存命中的请求仍会计入
  • 轻量状态接口只公开 Host 实例、统计 revision、扫描进度、同步计数与最近一次客户端环境报告(UA、视口、预留顶栏值及其来源、面板矩形——由本机客户端上报且只存内存),不公开会话 ID、工作区路径、提示词或回复正文;完整快照仅在状态变化或手动刷新时获取
  • scope query 将回合(turns)、模型调用(calls)和去重会话(sessions)分开统计;Provider/模型筛选缺少路由信息时明确归为 Unknown,不从展示字符串猜测
  • records 接口只返回短 hash、时间、工作区 ID、结构化模型身份、turn/step、Token buckets 和当前物化来源,不返回原始 session ID、路径、提示词、回复或凭据
  • 看板中的总处理量 = 输入 + 输出 + 缓存读写 + 推理;缓存命中表示复用的上下文 Token,不等于新生成 Token 或实际费用
  • 成本计算沿用 cc-switch 的四桶公式:输入、输出、缓存读取和缓存写入分别乘每百万价格,四项相加后再乘倍率;context tier 在输入上下文严格大于阈值时为整次请求切换四项费率,不做渐进分段;DSH 的 reasoning 字段不再次加到 output,避免底层 completion/thoughts 已含推理时重复计费
  • 分时段计费以 UTC 周几与半开时间窗判定:命中规则的请求使用峰时四项费率,未命中时使用该行基础价(谷时=基础价);生效起点之前的用量没有可验证档位,会失败关闭为未计价而不会套用今天的费率;同一峰谷计划被所有使用该价格条目的行共享;开启节假日规则后,节假日当天不再命中任何峰时规则,成本快照会记下 pricingHoliday,明细里显示为「节假日谷时」而不是普通「谷时」
  • 历史账本中带 tiered 标志的旧 flat 成本会在加载升级时迁移为 unsupported(tiered-pricing-not-modeled),不再继续显示为当前精确 priced;Token 统计不受影响。
  • 价格同步默认关闭;models.dev 不可用时保留最近一次成功目录,未匹配模型不会套用默认价格;成本设置的价格框即手工价入口(同一官方模型的所有行共享该价格),每行可展开配置上下文档位与 UTC 峰谷规则(含可选的中国法定节假日全天谷价),内置 DeepSeek 峰谷表可一键复制后自定义、也可恢复;看板范围与明细视图保存在浏览器本地,6 小时自动同步开关会立即写入受保护的 pricing API
  • Mapping 语义:带 identityKey 的 mapping 只对精确路由身份生效;不带身份键的 mapping 才按模型做全局回退;旧配置中的 usageIdentityKey 会在加载时归一化。
  • 节假日日历只在用户点击「从公开日历载入」时抓取:目标主机是 cdn.jsdelivr.net(失败时 raw.githubusercontent.com),请求里只有年份,不发送任何用量、会话或凭据数据;返回的日期串在用户保存前不会生效,保存后连同来源说明一起冻结进该模型的峰谷计划(来源不参与政策哈希)
  • 余额查询走 DeepSeek 官方 /user/balance 接口;未配置 API Key 时卡片显示引导文案
  • 账本按 session ID 稳定 hash 到 32 个 JSON shard,单次 flush 只重写对应 shard;旧的 all_usage_ledger.json 会在首次加载时迁移,异步写失败或退出前未落盘不会丢失内存统计,只会让下次启动重新扫描
  • 仅统计能归属到已注册工作区(按会话 cwd 匹配)的会话

开发

  • 修改 src/client.js 后先运行 npm run build:client,再让 DSH 重载客户端模块并刷新页面;lib/client.js 是生成产物,不直接编辑。修改 lib/plugin.js 或其他 Host 模块后,需由 DSH 重载该包或重启进程
  • 插件无第三方运行时依赖:Host 端只使用 Cordis 服务,Client 端只使用 runtime 提供的 React 模块;Terser 仅作为固定版本开发依赖生成浏览器产物
  • 手动恢复 npm 发布时,GitHub Actions 要求输入目标 v<package.version> tag 和完整 commit SHA,并在 checkout 后校验 tag、SHA 与包版本一致;Release 事件同样执行 commit 校验。

English

A full usage dashboard for DeepSeek Harness. Analyze tokens, cache behavior, estimated cost, account balance, and activity by model, provider, workspace, and time range.

Features

  • Heatmap: a 53-week activity heatmap with workspace filters and daily turn/token details
  • Model analytics: mixed view, model-merged view, and provider summary with calls, token categories, and cache hit rate; model rows and the model filter dropdown render vendor brand SVG icons (neutral for unknown or mixed brands)
  • Summary and workspaces: processed tokens, cache hits, estimated cost, account balance, usage streaks, workspace distribution, and details
  • Cost statistics / price table: sync model prices from models.dev, calculate four cost buckets, persist price snapshots, and distinguish priced, free, ambiguous, and unpriced calls. Cost Settings is one editable price table: each row is a ledger model, its price boxes write that model's manual price, the official-model column switches the row to the catalog price, and every row can carry context rate bands and time-of-day (UTC peak/off-peak) rules, including an optional "Chinese statutory holidays price as off-peak all day" switch whose explicit date list lives in that model's peak plan (China Standard Time calendar days, 2026-10-01..2026-10-07 ranges supported, and one click loads the year's arrangement from a public calendar before it is frozen into the policy); rows that exist only in the saved configuration stay visible, editable, and removable
  • CSV export: export data using the selected time range and aggregation mode
  • Time ranges: today, last 30 days, last 90 days, all time, or a custom start/end date across all available historical daily data; the heatmap always shows the latest 53 weeks
  • Workspace aliases: manage aliases from the sidebar dashboard; values persist in the $DSH_HOME/storages KV cell all_usage_aliases
  • Interface language: switch between Chinese and English from the dashboard header; your choice persists locally in the browser
  • Full history & incremental rebuild: the baseline scans every readable historical session; the durable usage ledger doubles as a per-session cursor, so unchanged sessions are reused straight from the ledger and only newly appended events are folded — long histories restart without a full rebuild
  • Restart with no re-read: the persisted log revision (a header-line + stat via sessionPersistence.listSnapshots()) acts as a per-session change signal — sessions whose log is unchanged are applied from the ledger on restart without reading their events at all; only changed/new sessions are read incrementally
  • Workspace registry sync: follows DSH's domain/changed event so the workspace registry stays fresh automatically — any durable registry write (create/delete/rename/reorder/archive/membership) triggers a reread of workspaceRegistry.list(), with only added/removed workspaces reprocessed incrementally while unchanged workspaces reuse their computed aggregates and ledger (zero rescan). Usage is strictly limited to registered workspaces: unregistered cwds, including existing directories absent from the registry, are ignored.
  • Data health and on-demand refresh: after a scan completes, the browser polls only a lightweight status revision and fetches full history only after usage, alias, or sync state changes; it shows the latest full-data update, historical scan health, revision skips, rereads, ledger recovery, and failures while preserving last-good data on network errors
  • Performance: Host maintains ingest-time local/UTC day, workspace, model-identity cubes and single-day hour buckets; scope queries merge buckets, exact costs use BigInt decimal accumulators, and the 53-week heatmap emits only the fields it consumes, while revision-scoped snapshot/records caches and recyclable live-event queues remain in place. Client isolates the heatmap, tooltip, trend, donuts, request records, and pricing dialog behind memoized boundaries; pointer coordinates update through refs plus requestAnimationFrame instead of rerendering the page, and the browser entry is deterministically minified before packing
  • Trend line chart: show input, cache read/write, output, reasoning, and total processed tokens for the active range, timezone, workspace, provider, and model scope; use hourly buckets for a single-day scope and daily buckets for cross-day scopes, with smooth monotone curves, staged entrance animation, hover for exact values, and click a point to inspect that day
  • Unified filters and audit: workspace, provider, model, and date filters apply to the summary, heatmap, trend, tables, and CSV; workspace, provider, and model filters remain independent and can be combined freely, while workspace, provider, and model options are limited to values used in the selected date range and stale selections clear automatically; request logs stay visible as a compact paginated table with grouped Token details for the selected row
  • Token accounting semantics: input tokens are fresh (exclude cache hits/writes, which sit in separate buckets along with reasoning); all-zero usage replays never overwrite recorded usage, while cache-only requests still count
  • Cost semantics: prices come from the models.dev USD per 1M token catalog; DSH-normalized fresh input and the four cost buckets are snapshotted at calculation time, the multiplier applies only to final total, and existing positive historical costs are not recalculated; matching uses the model's official vendor entry and ignores the DSH provider, while missing official prices stay unpriced

Compatibility and Known Limitations

  • Runtime: Node.js >=22 <25 is required. CI runs the test suite, syntax checks, and package-content checks on Node 22 and Node 24.
  • DSH compatibility: package.json declares DSH runtime >=0.1.1-rc.1 <0.1.5-0 || >=0.1.5-rc.1 <0.1.6-0 || >=0.1.7-rc.2 <0.1.8-0 || >=0.2.0-rc.2 <0.2.1-0; the real Cordis service chain is verified on 0.2.0-rc.2, 0.1.7-rc.2, 0.1.5-rc.2, 0.1.5-rc.1, 0.1.1-rc.2 and 0.1.1-rc.1, all of them covered by the CI smoke matrix on Node 22 and 24. 0.1.2-rc.1 has also been verified compatible through real-world use, but is not covered by the CI smoke matrix. The declaration is split per tuple rather than written as one interval because node-semver only admits a prerelease version when some comparator shares its exact major.minor.patch tuple and itself carries a prerelease tag — 0.2.0-rc.2 is admitted only because the range says >=0.2.0-rc.2.
  • Desktop client (Electron, Windows): the plugin is verified running in the DSH desktop client (@deepseek-ai/dsh-desktop 0.1.7-rc.2 as measured). The desktop client keeps a 40px caption strip across the top of its window for its own minimise / maximise / close buttons and marks the document with data-windows-titlebar and --dsh-windows-titlebar-height; the panel draws from below that strip, so the client's own close button is never covered. Browsers carry no such marker and reserve nothing. The strip height comes from the host's declaration first, then the Window Controls Overlay rectangle, then the user agent; to tune it, run localStorage.setItem('dsh-all-usage:topInset', '48') in DevTools and reload (0 reserves nothing) — no rebuild required. The desktop client ships its own runtime, and that runtime — 0.1.7-rc.2 — is now part of the declared range and of the CI smoke matrix below.
  • Web service dependency: the Host declares webServer as a required dependency, so DSH waits for a late-mounted service before applying the plugin; this package targets the DSH Web profile and does not expose routes without WebServer. The HTTP guard also checks the actual socket peer, so a reverse proxy is accepted only when the connection itself is loopback.
DSH runtime Node.js support Real Cordis smoke Conclusion
0.2.0-rc.2 >=22 <25, CI covers 22/24 Passed (real Cordis service chain, CI covers Node 22/24) Declared and verified (the current DSH next line; this machine's web profile runs it)
0.1.7-rc.2 >=22 <25, CI covers 22/24 Passed (real Cordis service chain, CI covers Node 22/24) Declared and verified (the DSH desktop client runs this version)
0.1.5-rc.2 >=22 <25, CI covers 22/24 Passed (real Cordis service chain, CI covers Node 22/24) Declared and verified
0.1.5-rc.1 >=22 <25, CI covers 22/24 Passed (real Cordis service chain, CI covers Node 22/24) Declared and verified
0.1.2-rc.1 >=22 <25 Passed through real-world use (not in CI) Verified compatible in real-world use
0.1.1-rc.2 >=22 <25, CI covers 22/24 Passed (real Cordis service chain, CI covers Node 22/24) Declared and verified
0.1.1-rc.1 >=22 <25, CI covers 22/24 Passed (real Cordis service chain, CI covers Node 22/24) Declared and verified
Other versions >=22 <25 Not tested Outside the verified matrix

An unlisted DSH version is not necessarily incompatible. Include the DSH, Node.js, and plugin versions when reporting an issue.

  • Interrupted requests: an interrupted upstream request may emit only assistant/chunk usage and never produce a final assistant/message; that chunk is retained. A later final message for the same turn/step replaces it. If the upstream emits no usage event at all, exact token usage cannot be reconstructed from response text.
  • Estimated cost: cost is an estimate based on models.dev rates and DSH usage buckets, not a provider invoice. Unavailable catalogs and unmatched models remain unpriced instead of receiving guessed rates. Cache reads, cache writes, and reasoning follow the buckets reported by the upstream DSH event.
  • Tiered prices: models.dev context-tiered entries select the applicable rate from the request input context (fresh input plus cache read/write tokens); malformed schedules remain unsupported.
  • Workspace boundary: only sessions whose cwd maps to a DSH-registered workspace are included. Unregistered cwds, including existing directories absent from the registry, are ignored. The registry is kept fresh by a domain/changed probe: any durable workspace-domain write triggers a reread, and only added/removed workspaces are reprocessed incrementally — unchanged workspaces reuse their computed aggregates and ledger. Data deleted or corrupted before a successful session flush cannot be recovered from the separate ledger.

Local Statistics vs Official Billing

This plugin reports replayable statistics from local DSH event logs; it is not a mirror of a provider invoice:

前往 GitHub

DSH Plugins 是獨立的 DeepSeek Harness 外掛市集,與 DeepSeek 官方無關,也不代表官方背書。第三方外掛未經安全稽核,安裝前請審查原始碼。

每週取得最新的 DeepSeek Harness 外掛,絕不濫發。