DSH HUB
HomePlugin StorePlugin PacksCommunityRankingsResourcesPublish Guide
Plugin source
Back to catalog

limingwei-88 /

limingwei-88/dsh-session-usage-meter

Verified

DeepSeek Harness plugin: per-session token usage and estimated cost in the sidebar session-row hover card.

★ 0 Stars0 Forks0 IssuesN/A Community rating0 Confirmed installs
View on GitHub
READMESource: main@63c9da89

dsh-session-usage-meter

一个 DeepSeek Harness 插件:在侧边栏会话行的悬浮卡片里显示该会话的累计 Token 消耗与预估成本。

English: shows per-Session cumulative token usage and an estimated cost inside the sidebar session-row hover card.

功能

  • 汇总当前会话每个 assistant/message 事件上的 usage(输入 / 输出 / 缓存命中 / 缓存写入)。
  • 按内置价格表估算成本,价格可在本地覆盖(见下文),无需重新构建。
  • 悬浮卡片里一行显示:12.4k Tokens · 估算 ¥0.0081;鼠标悬停可见分项明细。
  • 跟随 DSH 主题,不引入新的配色体系;中英文文案随界面语言切换。

安装

# 从 npm 安装(发布后)
dsh plugin --profile web add dsh-session-usage-meter

# 从 GitHub 安装
dsh plugin --profile web add github:<owner>/dsh-session-usage-meter

# 从本地目录安装(开发调试)
dsh plugin --profile web add "C:\\path\\to\\dsh-session-usage-meter"

profile 说明:--profile web 是 DSH 的默认 Web profile;本机若运行的是别的 profile(例如 Desktop 使用 desktop),把它换成你实际启动的 profile 名即可,否则装到了另一个 profile 里,当前界面不会出现该插件。

安装后重启 dsh 并刷新页面。dsh plugin ... add 只是把包加进 profile 的依赖;要让 bundle 真正挂载,还需要该包的 dsh.bundle.patch 被 profile 选中(本包已自带 cordis.patch.yml,在支持 dsh.bundle 的 DSH 版本上会自动登记)。

工作原理

半边 作用
Host (index.js) 仅用于让 bundle 行可解析,不注册任何资源。
Client (client.js) 通过 ctx.slots.inject('sidebar.session.row.hover', ...) 注册一个区块,读取该会话已落盘的 assistant/message.usage 并求和。

数据全部来自会话自身的事件窗口,不发额外请求,也不把用量写回会话。

价格表

默认价格(人民币 / 每百万 Token)写在 client.js 的 DEFAULT_PRICES 中,按模型名匹配,匹配不到时使用 default:

字段 含义 默认值
input 输入(缓存未命中) 2
cacheRead 缓存命中 0.2
cacheWrite 缓存写入 2
output 输出 3

不改代码覆盖价格:在浏览器控制台写入 localStorage 后刷新页面。

localStorage.setItem(
  'dsh-session-usage-meter.prices',
  JSON.stringify({ default: { input: 2, cacheRead: 0.2, cacheWrite: 2, output: 3 } })
)

金额是估算值,不是账单:它不包含套餐折扣、阶梯计价、缓存策略差异,也不计入未被 usage 覆盖的部分。

已知限制

  • 只统计事件里带 usage 的 assistant/message;早期历史或中断的调用可能没有 usage。
  • 悬浮卡片仅在该会话行被悬停时挂载,因此没有常驻的数字显示。
  • 价格表按模型名精确匹配;自定义 provider 的模型名会落到 default。

开发

node --check index.js
node --check client.js
node -e "JSON.parse(require('fs').readFileSync('locale/zh.json','utf8'))"

本仓库无构建步骤:client.js 直接是浏览器模块加载器接受的格式。

License

MIT

—/ 5

No ratings yet

Verified DSH bundle

Commit 63c9da8986d2

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