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-token-pricing

v0.1.0

Published

Per-model token pricing for the dsh web surface: durable USD rates with multi-window peak hours, a cost readout in the composer dock, and a collapsible draggable floating window with per-turn and per-model cost views

Readme

dsh-token-pricing

中文 | English

dsh-token-pricing 是一款第三方(非官方)插件,由社区维护,与 deepseek-ai 官方发布无关。

Web 界面的按提供方/模型 token 定价:按提供方/模型配置美元价格(未命中输入、缓存命中输入、输出,以及可在任意多个高峰时段内生效的高峰价格档),并在三个表面查看会话费用——底部数据栏,以及一个可折叠可拖拽的浮窗(「按轮计价」与「按模型计价」两种视图)。按轮用量由 tokenPricing 投影从会话日志派生,随会话持久化、随归档一并保留。node 半身注册设置命名空间与投影单元,其余全部复用现有 Host 服务。

安装

前置:Node ≥ 22、pnpm、可用的 dsh 安装。

# 安装到 web profile(自动初始化 profile、安装依赖、注册补丁层)
dsh plugin --profile web add dsh-token-pricing

# 启动
dsh web

dsh plugin add 走官方插件机制:把本包装进 $DSH_HOME/profiles/web/ 的依赖 → 依据 dsh.bundle 声明加入 profile 补丁层 → 补丁层的一行 row 同时挂载 node 半身与浏览器半身。本包只声明两个自用运行时依赖(schemasteryzod);其余 @deepseek-ai/dsh-* 由 dsh 安装本身提供(官方机制的双锚点解析),因此安装不会拉取任何内部包。更新与卸载:

dsh plugin --profile web update dsh-token-pricing
dsh plugin --profile web remove dsh-token-pricing

未发布到 npm 时可用 git 源安装(仓库内已提交构建好的 lib/):

dsh plugin --profile web add github:LightClear/dsh-token-pricing

功能亮点

配置模型价格与高峰时段规则

设置页:展示具体模型的设置页面,读取已设置的模型配置,并配置模型价格与高峰期计价规则

设置 → 模型定价 把模型目录按提供方分组为卡片,每个模型带已配置/未配置圆点。展开某个模型打开编辑器,自动载入已存配置,可编辑三档基础费率——输入未命中、输入命中、输出(美元/每百万 token)——以及高峰期计价规则:启用高峰定价后,可按需增删任意多个高峰时段(添加高峰时段 / 删除时段),全部时段共享一套高峰费率。默认只有一段,时段支持跨午夜(22:00–08:00),当前时间落入任一时段即按高峰价计费。

会话底部数据栏的实时费用

会话底部数据栏:展示对话框底部数据区域的计价数据

对话框底部数据栏在出厂统计行旁显示会话的 输入 $X · 输出 $Y · 总计 $Z。每一步按自身时间、在其派发路由下计价,读数对每个已计价步骤求和,因此与浮窗总计永远一致;未配置计价路由的用量不计入该数字。

可折叠、可拖拽的费用浮窗

费用浮窗折叠态:右下角小球显示会话总费用

折叠态是小球形状,显示当前会话的累计费用;点击小球展开面板。

费用浮窗展开态:完整窗口,含标题栏、视图切换与底部总计

展开态面板包含两个视图切换页签与底部总计栏。标题栏(顶部)与总计栏(底部)都是拖拽区域。

按轮计价与按模型计价

悬浮窗提供两种计价方式:按对话轮数计价与按模型计价。

费用浮窗的按轮计价页面

「按轮计价」按对话轮次列出每轮(轮次号与开始时间)使用的路由、token 数与费用;一轮中途切换模型时按路由拆分为多行。

费用浮窗的按模型计价页面

「按模型计价」按会话中使用过的所有模型聚合 token 数与费用,按首次使用顺序排列。两种视图中,未配置计价规则的模型仍显示 token 数并提示 未设置计价

数据来源

按轮用量不是单独存储的:tokenPricing 投影将会话的持久事件日志折叠为逐步用量事实——每条携带服务商上报 usageassistant/message,盖上其派发路由(最近一条 request/header)与该步自身的时间戳。由于折叠重放日志,数据随会话持久化、重启后还原,并随归档的会话一并保留(归档只隐藏列表行,从不改写日志)。投影只携带用量事实——费率住在设置作用域里——因此浏览器在渲染时逐步计价,事后修改价格条目会按新价重算历史。高峰/非高峰按每步自身时间判定:某步的时间落入其条目任一 peakWindows 即按高峰价计费。

/client 导出为插件主体(apply/inject)、dock、浮窗与设置页组件及其注入面类型。纯费用计算位于 src/client/pricing.ts,投影折叠位于 src/projection.ts

模型体验

基于已记录用量的费用读数

模型看到的内容

本插件不向任何模型请求添加任何内容:不注册工具、不注册提示段,也没有任何设置值进入请求路径。数据栏、浮窗与设置页只呈现线上已有的持久数据——tokenPricing 投影值与 token-pricing 设置段。

Token 影响

零:本包不添加、移除或改动任何提示内容、工具 schema 或消息。

KV Cache 影响

无:请求组成、缓存复用与压缩均不受影响;tokenPricing 折叠只在请求提交后运行。

已知限制与待办

  • 压缩摘要不计费 — 压缩步骤自身的模型调用不追加 usage 事件,其费用不出现在任何数字中(与 tokenUsage 计量口径一致)。
  • 无服务商用量的步骤不计费 — 未上报计费的适配器调用、或消息组装前中止的步骤不产生记录行。
  • 浮窗位置每次加载重置 — 拖拽位置保存在组件状态里,刷新页面后回到默认位置。
  • 数据栏数字只覆盖已配置路由 — 未配置计价路由的用量不贡献数据栏总计;这部分用量在浮窗的按模型视图中显示为未计价。