npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dsh-spend-meter

v0.1.0

Published

Per-turn DeepSeek spend, live official pricing, and current balance for DeepSeek Harness Web.

Readme

dsh-spend-meter

English

DeepSeek Harness Web 的费用监控插件:在每轮回答下显示该轮触发的全部 DeepSeek API 花费,并在输入框下方持续显示当前余额、会话总额和价格状态。

本轮 ¥0.0231 · 5 次调用 ▾

余额 ≈¥96.38 · 本会话 ¥1.27 · 价格刚刚更新

为什么不是另一个 dsh-turn-cost

dsh-turn-cost 是优秀的零网络、零凭据、内置人民币价格的轻量每轮显示插件。dsh-spend-meter 面向不同需求:实时抓取 DeepSeek 官方价格、查询官方余额、冻结每次请求的价格凭证,并统计主 Agent、子代理、上下文压缩、会话标题和其它 DSH 内部模型调用。

两者会产生重复的每轮费用 UI,请勿同时安装。

功能

  • 逐轮归因:一条用户消息触发的主 Agent 多步骤、子代理、压缩、标题和其它 DeepSeek 调用全部归入根会话的同一轮。
  • 真实 usage:使用 DSH rc.7 的未缓存输入、缓存读取、缓存写入和输出分桶;推理 token 已包含在输出中,不重复计费。
  • 实时官方价格:启动时获取人民币和美元官方价目,之后每 30 分钟刷新;支持手动刷新。
  • 当前余额:使用 DSH 当前 DEEPSEEK_API_KEY 查询官方 /user/balance;每轮结束后及页面可见时每 60 秒校准。
  • 价格凭证冻结:每个调用保留当时的模型、峰谷档、单价、价格来源和获取时间;未来调价不重算旧记录。
  • 明确的不确定性:缺少 usage 但存在输出时显示 估算;无法判断时显示“费用未知”,绝不按零处理。
  • 定点金额:费用以 pico-unit(1e-12 货币单位)的整数字符串保存、求和,避免浮点和逐轮舍入误差。
  • 安全伴随存储:费用历史保存在 ~/.dsh/storages/dsh_spend_meter.json,不向 session JSONL 写第三方事件。

计费公式

调用费用 =
  缓存命中输入 token × 缓存命中单价
  +(未缓存输入 token + cache-write token)× 缓存未命中单价
  + 输出 token × 输出单价

峰谷档以请求开始时间为准。币种跟随 /user/balance 返回的首个官方币种项:CNY 使用人民币价目表USD 使用美元价目表。不做汇率换算,也不把不同币种相加。

安装

从 npm 安装:

dsh plugin --profile web add dsh-spend-meter
dsh web

也可以使用本地 tgz 或源码目录的绝对路径安装:

dsh plugin --profile web add /absolute/path/to/dsh-spend-meter-0.1.0.tgz
dsh web

安装后刷新 DSH Web。插件要求 @deepseek-ai/dsh >= 0.1.0-rc.7 < 0.2.0

卸载

dsh plugin --profile web remove dsh-spend-meter

卸载不会改动或损坏任何会话。若确定不再需要历史费用,可在 DSH 停止后手动删除:

~/.dsh/storages/dsh_spend_meter.json

网络与隐私

Host 只访问三个固定官方地址:

  • https://api-docs.deepseek.com/zh-cn/quick_start/pricing/
  • https://api-docs.deepseek.com/quick_start/pricing/
  • https://api.deepseek.com/user/balance

API Key 每次余额操作都通过 ctx.credentials.resolve(DEEPSEEK_API_KEY) 解析,只放在 Host 的 Authorization 请求头中。浏览器、日志和伴随存储都不会收到密钥。插件不保存提示词、回答、工具参数或 API 响应正文。

费用凭证保存:session id、turn、调用分类、模型、usage、时间、价格凭证、精度状态和金额。余额只缓存最近一次官方快照,不保存长期余额趋势。

故障语义

  • 官方价格页不可用或结构变化:继续使用最后一次成功价格;没有成功记录时使用随包附带的 2026-08-19 快照,并显示“价格已过期”。
  • 余额查询失败:保留最近官方余额并显示过期/不可用状态。
  • 流式请求缺少 usage:有输出则按本地启发式估算并标 ;无可靠证据则记录未知。
  • 插件写盘失败:不影响模型流和 Agent 执行;该次计量记录可能缺失并写一条不含敏感信息的警告。
  • 插件永远不会阻止、取消或修改模型请求。

开发与验证

npm install --ignore-scripts --legacy-peer-deps
npm test
npm run verify

测试全部使用脱敏 fixture 和 mock stream,不主动产生 DeepSeek 模型费用。详见 docs/architecture.md

License

MIT。第三方参考与署名见 NOTICE