DSH HUB
HomePlugin StorePlugin PacksCommunityRankingsResourcesPublish Guide
Plugin source
Back to catalog

xiaobaijunya /

xiaobaijunya/dsh-cost-meter

Verified

Estimated CNY cost for DSH token usage: per-turn and session cost with DeepSeek peak/off-peak and per-model pricing, plus a separate subagent breakdown.

★ 0 Stars0 Forks0 IssuesN/A Community rating0 Confirmed installs
View on GitHubProject homepage
READMESource: main@1bc294f3

dsh-cost-meter

English | 中文

Estimated CNY API cost for a DeepSeek Harness conversation, with per-model and peak/off-peak pricing and a separate subagent breakdown.

English

A display-only DSH plugin that turns the harness's token counters into estimated money:

  • Composer usage pill — the bottom-bar usage control reads 51M tok · ¥2.20 for the whole session. Opening it shows the token buckets, the current billing period, the session cost, and per-model costs with their off-peak/peak rates.
  • Per-turn cost — each completed turn's "usage" action gets · ¥0.0274 appended, and the shipped per-turn usage dialog gains turn cost, session total and billing period rows.
  • Subagent costs are listed separately — the usage dialog has its own "Subagent cost" section: every descendant subagent session (label, cost, tokens), a subtotal, and a grand total (session + subagents). Main-session numbers keep their original meaning and are not mixed with subagent spend.
  • Peak/off-peak and per-model pricing — DeepSeek Flash and Pro price tables are used with the official billing windows: Beijing time Mon–Fri 09:00–12:00 and 14:00–18:00 are peak (excluding Chinese statutory holidays); weekends and holidays are off-peak all day. A turn that spans both windows is labeled mixed.

Amounts are estimates from the official price list and the timestamps of recorded model calls — they are not a bill. The plugin makes no model calls and writes no session data.

Requirements

  • DSH 0.2.1-rc.5 was used for development and testing (Desktop and Web).
  • The plugin uses only DSH client APIs that already exist in that build (ctx.slots, ctx.sessionProjections, ctx.webServer, dsh.client module table).

Install

  • DSH Desktop / Web with the plugin market installed — once this repository is listed in the awesome-dsh-plugin market, search for dsh-cost-meter there.

  • Plain dsh web (CLI):

    dsh plugin --profile <profile> add github:xiaobaijunya/dsh-cost-meter
    
  • Release tarball (no build step):

    dsh plugin --profile <profile> add https://github.com/xiaobaijunya/dsh-cost-meter/releases/download/v0.2.0/dsh-cost-meter-0.2.0.tgz
    
  • Manual profile patch (any deployment): append one insert row to the profile's cordis.patch.yml pointing at this repository's lib/index.js; DSH's HMR applies it in a few seconds. See tools/INSTALL.md for the exact block, verification and rollback.

The official DSH Desktop app manages its reserved desktop profile itself — install through the app's Plugins page rather than the CLI.

Pricing rules

Source: https://api-docs.deepseek.com/zh-cn/quick_start/pricing (2026-11 pricing).

model cache hit off-peak/peak cache miss off-peak/peak output off-peak/peak
deepseek-flash (and deepseek-v4-flash, deepseek-v4-flash-vision-exp) 0.02 / 0.04 1 / 2 4 / 8
deepseek-v4-pro 0.15 / 0.30 4.5 / 9 13.5 / 27

CNY per million tokens. Unknown model names fall back to Flash pricing and are marked "estimated with Flash pricing". Cache-write tokens are priced as cache-miss input.

Billing windows are Beijing time: peak is Monday–Friday 09:00–12:00 and 14:00–18:00, excluding Chinese statutory holidays; all other time (weekends, holidays, nights) is off-peak. Weekend off-peak started 2026-08-23; the plugin keeps that cut-over for historical logs. The 2026 statutory holiday list is built in; 2027 dates need to be added to lib/pricing.js once the State Council publishes them.

How subagent costs are collected

Subagents (Agent Team members, delegated tasks) run in their own DSH Session. The plugin's host half reads the session logs under $DSH_HOME/sessions on demand, follows each log's parentSession header link to find descendants of the viewed session, folds each log with the same cost fold used for the main session, and serves the result through a localhost route (/dsh-cost-meter/subagents). The client refreshes it while the usage dialog is open (every 4 s). Logs are cached by mtime + size; nothing is written to the session directory.

Development

node tests/host/run-all.mjs     # pricing / projection / status / apply / subagents / optional real-log replay
node tests/client/harness.mjs   # materializes client/client.js with a mock module loader and fake DOM

Layout: lib/ is the host plugin (projection, pricing, status probe, subagent aggregation); client/client.js is the hand-written browser bundle; tests/ holds the two test suites above.

Privacy and scope

  • Reads the local DSH session logs only for the subagent breakdown; the aggregation is cached in memory.
  • Writes one diagnostics/status file ($DSH_HOME/.dsh-cost-meter-status.json) and exposes two localhost routes used by its own UI.
  • Makes no network requests to model providers; it does not send prompt, usage or log data anywhere.

Limitations

  • Estimates only: pricing changes, subscription discounts, and provider-side rounding are not reflected.
  • The peak/off-peak bucket of one request is taken from its recorded settlement time; a request spanning a window boundary is attributed to the later bucket.
  • Historical prices before the current price list (e.g. Flash before 2026-09-10) are not modeled.
  • Subagent costs appear only while their logs exist in $DSH_HOME/sessions; archived or pruned sessions are not listed.

License

MIT — see LICENSE.

中文

一个只做展示的 DSH 插件:把 DeepSeek Harness 里的 token 统计换算成按官方价目与峰谷时段估算的人民币费用。

  • 底边栏用量 pill:显示本会话累计费用,形如 51M tok · ¥2.20;点开是「用量与费用」弹窗(token 分桶、当前计费时段、会话费用、按模型费用与谷/峰单价)。
  • 每轮费用:每轮回答结束的「用量」按钮后追加 · ¥0.0274,原生「本轮用量」弹窗末尾追加本轮费用 / 会话累计 / 计费时段三行。
  • 子智能体费用单独列出:弹窗里有独立的「子智能体费用」区块,按子会话逐行显示标签、金额、token 数,并给出子智能体小计与「合计(主会话 + 子智能体)」。主会话金额口径不变,不与子智能体混算。
  • 区分模型与峰谷:内置 DeepSeek Flash / Pro 价目,按北京时间工作日 9:00–12:00、14:00–18:00(不含法定节假日)为高峰,其余时段(周末、节假日、夜间)为谷价;跨时段的一轮标为「高峰/空闲混合」。

金额是按官方价目表与已记录调用时间估算的,不是账单;插件不发起模型请求,也不写会话数据。

安装

  • 已装插件市场的 DSH 桌面端 / Web:本仓库被 awesome-dsh-plugin 收录后,在市场里搜索 dsh-cost-meter 一键安装。

  • 普通 dsh web(CLI):

    dsh plugin --profile <profile> add github:xiaobaijunya/dsh-cost-meter
    
  • Release tarball(无需构建):

    dsh plugin --profile <profile> add https://github.com/xiaobaijunya/dsh-cost-meter/releases/download/v0.2.0/dsh-cost-meter-0.2.0.tgz
    
  • 手动 profile patch(任意部署):在 profile 的 cordis.patch.yml 追加一个 insert 条目指向本仓库 lib/index.js,DSH 的 HMR 会在数秒内热加载。完整步骤、验收与回滚见 tools/INSTALL.md。

官方 DSH 桌面端自己管理保留的 desktop profile,请在应用内 Plugins 页安装,不要用 CLI 改桌面 profile。

计价规则

来源:https://api-docs.deepseek.com/zh-cn/quick_start/pricing(2026-11 现行价)。

模型 缓存命中(谷/峰) 未缓存输入(谷/峰) 输出(谷/峰)
deepseek-flash(含 deepseek-v4-flash、deepseek-v4-flash-vision-exp) 0.02 / 0.04 1 / 2 4 / 8
deepseek-v4-pro 0.15 / 0.30 4.5 / 9 13.5 / 27

单位:元 / 百万 token。未知模型名回落到 Flash 价目并标注「按 Flash 价估算」;缓存写入 token 按未命中输入价计。

峰谷按北京时间:工作日(不含中国法定节假日)9:00–12:00、14:00–18:00 为高峰,其余时段为谷价。2026-08-23 起周末全天谷价(插件对历史日志保留该分界);内置 2026 年法定节假日表,2027 年安排公布后需补到 lib/pricing.js。

子智能体费用怎么统计

子智能体(Agent Team 成员 / 委派任务)跑在各自独立的 Session 里。插件的 Host 侧在弹窗需要时扫描 $DSH_HOME/sessions 下的会话日志,按每个日志 header 的 parentSession 关系找出当前会话的全部后代,用与主会话相同的费用 fold 计算每个子会话的金额,通过本机路由 /dsh-cost-meter/subagents 提供给前端;弹窗打开期间每 4 秒刷新一次。日志按 mtime + size 缓存,不写会话目录。

开发与测试

node tests/host/run-all.mjs     # 价目 / 投影 / 状态 / 注册 / 子智能体 / 可选的真实日志回放
node tests/client/harness.mjs   # 用 mock 模块表与假 DOM 物化 client/client.js

隐私与范围

  • 只为子智能体汇总读取本机会话日志,结果只在内存缓存。
  • 只写一个诊断/状态文件($DSH_HOME/.dsh-cost-meter-status.json),并注册两条供自身 UI 使用的 localhost 路由。
  • 不向任何模型提供方发请求,不上传 prompt、用量或日志数据。

局限

  • 仅为估算:不反映价格调整、订阅折扣与提供方侧舍入。
  • 单次请求的峰谷按记录到的结算时间归段,跨时段边界会有归段误差。
  • 历史价目(如 2026-09-10 之前的 Flash 旧价)未建模。
  • 子智能体费用仅在其日志仍存在于 $DSH_HOME/sessions 时出现,归档/清理掉的会话不会列出。

License

MIT,见 LICENSE。

—/ 5

No ratings yet

Verified DSH bundle

Commit 1bc294f3f115

Community comments

No comments yet. Be the first to write one.

DSH HUB

A community index for DSH plugins. Not an official GitHub or DeepSeek AI product.

CommunityResourcesAPIAbout