Sttrevens/dsh-cost-meter
dsh plugin: per-turn USD cost badge in the Web UI (session total + per-message footer, hover breakdown) from token usage x a configurable pricing table.
已收录
1
Usage
Bundle 已验证
预览
功能介绍
Web UI 美元成本徽标:头部显示会话总成本、每条回复结尾显示该轮成本,悬停看分项。
适合
- 希望在聊天过程中查看每轮及整场会话美元成本估算的 DSH Web 用户。
- 需要通过自定义的每百万 token 价格表比较不同 provider 或模型成本的团队。
- 需要在悬停分项中区分输入、输出、缓存读取和缓存写入成本的用户。
不适合
- 需要账单强制控制、支出上限或自动预算管理,而非信息性估算的工作流。
- 无法维护准确价格表的部署;未列出的模型会使用默认价格,未配置默认值时则显示为零。
- 不使用 DSH Web 对话界面、因而无法受益于可视成本徽标的用户。
README
@steven-wu/dsh-cost-meter
Out-of-tree dsh plugin that shows a live USD cost badge for the open conversation in the Web UI.
It is a dual-face dsh.client package:
-
Host half (
lib/index.js) registers asessionCostprojection on the session-projection seam. The fold tracks the current provider/model fromrequest/headerevents and accumulates cost from the provider-reported usage buckets (uncached input / output / cache-read / cache-write), reusing token-meter’s “replace the same(turn, step)sample instead of double-counting” rule. The view exposes the whole-session totals plus abyTurnmap keyed by turn number. -
Client half (
lib/client.js) registers a badge into theconversation.chat.assistant-actionsslot — the action row at the end of each assistant message, alongside the turn’s time/duration info. Each badge shows that turn’s cost; hovering opens a tooltip with the per-bucket breakdown (input / output / cache-read / cache-write) plus the session total.
Pricing table
Pricing is USD per million tokens, keyed by provider/model:
{
"per": 1000000,
"currency": "USD",
"default": { "input": 0.6525, "output": 1.9575, "cacheRead": 0.02175, "cacheWrite": 0 },
"models": {
"deepseek-official/deepseek-v4-pro": { "input": 0.6525, "output": 1.9575, "cacheRead": 0.02175, "cacheWrite": 0 },
"deepseek-official/deepseek-v4-flash": { "input": 0.2175, "output": 0.6525, "cacheRead": 0.00725, "cacheWrite": 0 }
}
}
The plugin reads ~/.dsh/cost-pricing.json on boot (override the path with the
DSH_COST_PRICING env var or the row’s config.pricingPath). On first run it
writes the default table to that path; edit it and restart dsh web to apply
changes. A model without a models entry falls back to default (zero cost
when no default is present).
Install
The package declares a dsh.bundle manifest, so dsh plugin add installs it
and adds it to the profile’s bundle layers automatically — no manual patch
edit:
dsh plugin --profile web add @steven-wu/dsh-cost-meter
# restart the web profile, then refresh the page
For a local checkout during development:
dsh plugin --profile web add file:/path/to/dsh-cost-meter
Notes:
-
@deepseek-ai/dsh-*are declared as peerDependencies (resolved from the harness), never asdependencies— installing them into a profile shadows the harness copy and can pull a stale dist-tag. - The Settings “Plugins” panel is read-only (inventory + config cards); install
happens only through
dsh plugin --profile … add. - Purely-cordis mounting (a
cordis.patch.ymlinsert row) also works — the shippedcordis.patch.ymlholds that row for either path.
The sessionCost projection is delivered through the same seam as
tokenUsage / sessionStats, so it also appears in every projection carrier
(history tail page, session/projection push frames) without extra wiring.
常见问题常见问题
在启用了 DSH 的终端中执行已验证命令 dsh plugin --profile default add github:Sttrevens/dsh-cost-meter。命令会解析公开 package 元数据,并保持插件与本页展示的目录身份一致。
兼容性以页面上展示的 bundle 与 profile 状态为准。如果某个 profile 尚未检测到,请先保持禁用,并在生产启用前阅读仓库文档。
GitHub 链接和 activity 元数据是 release 与维护状态的来源。新版本发布后重新查看本页,确认目录已经观察到最新版本。