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

@unchen/dsh-ustc-usage

v0.0.5

Published

为 DSH 中上游是 USTC(api.llm.ustc.edu.cn)的模型显示用量窗口与容量

Readme

dsh-ustc-usage

为 DSH 里「上游是 USTC」的模型显示用量窗口与容量的插件。

它能显示什么

当「设置 → 模型」里某个 provider 的 baseURL 主机是 api.llm.ustc.edu.cn 时:

  • 用量窗口:上游给该 Key 设置的预算档(典型 3h / 12h / 24h)——每档一条进度条,剩 ¥X / ¥上限 与重置倒计时;上游没给窗口内用量的档显示「上限 + 倒计时」,不画假百分比;超出上限显示「超出 ¥X / ¥上限」,不把负数当剩余。
  • 作废额度:某一档重置在先、短档又把额度卡着,剩下的钱来不及用就作废。这部分仍然算在「剩余」里(剩 ¥X 的 X 不因此变小),只是用不到——进度条把剩余拆成前后两截:前一截(品牌色)是重置前真正用得到的,后一截(红斜纹)是用不到、重置即作废的。鼠标停在条上显示可用额度与受限档位。
  • 容量:上游返回的限额(RPM / 并发 / TPM);显式 null 显示 ∞,缺失显示 —。
  • 本机计数:本机 60 秒内的请求数、进行中的请求、进程启动以来的请求数。

两个位置:

  • 「设置 → 模型」里该 provider 的卡片内嵌一块用量面板,带「刷新」按钮;
  • 对话页输入框下方(与上下文用量同一行)一个紧凑卡片:小环形(用量百分比)+ 剩余最少、最先耗尽的那档,点击展开完整面板。

自动刷新默认 60 秒一次,可切 30s / 60s / 5m / 关,两个界面共用同一个选择并记住;30 秒内命中缓存,不重复打上游。

适用范围

只做手动填 Key 的 provider:在「设置 → 模型」里自己添加、填了上游地址和 API Key 的那种,且上游主机是 api.llm.ustc.edu.cn。通过登录等方式自动下发的路由不在范围内——那种 Key 只存在于宿主内部,插件取不到。

安装

  • 应用里:侧栏「插件」→ 添加插件 → 填 @unchen/dsh-ustc-usage(可带版本,如 @unchen/[email protected])→ 安装 → 立即启用。
  • 命令行:dsh plugin --profile <profile> add @unchen/dsh-ustc-usage@<版本>(装之前先退出应用)。

几点:

  • 安装前 DSH 会做兼容性预检:@deepseek-ai/dsh-* 的 peer 范围必须覆盖运行时版本,否则拒装(按提示放宽 peer,或 dsh plugin allow-version <包@版本> --dsh-version <精确版本> --accept-risk)。
  • 插件没有自动更新:升级先卸载(remove @unchen/dsh-ustc-usage)再装新版。
  • 刚发布时镜像源可能尚未同步,安装源选 npm 官方源。

工作原理

客户端拿不到明文 Key,也直连不了上游(USTC 网关没有 CORS 头),探测由 host 半完成:

设置里的手动 provider(baseURL / apiKeyEnv)
  → 按 baseURL 主机名匹配白名单(api.llm.ustc.edu.cn)
  → 从 DSH 凭据库取明文 Key
  → GET {site}/key/info 与 GET {site}/user/info(Bearer Key)
  → 解析、合并、缓存,经插件自建的 Remote 命名空间发给界面
  • {site} 由 baseURL 派生:去尾斜杠、剥离末尾 /v1。
  • Key 只用于向你配置的那个上游地址发这两个请求;插件不落盘、不发给别处,界面与错误提示只出现凭据引用名,不出现 Key 本身。

已知限制

  • 本机计数不等于 Key 的真实用量(同一 Key 可能在别处使用);上游接口不提供「已用 RPM / 并发」。
  • 作废额度按「重置即回满」估算:短档在长档重置前每重置一次,就还能再花一档;缺窗口内用量的档按它的上限算。缺重置时刻、重置时刻已过、时长写法认不出来的档不参与估算——宁可少标,也不会把可用额度标成作废。
  • 设置页的面板只挂在 pi-ai 家族的 provider 卡片上(DSH 里手动添加的 provider 都是这一族);用别的家族挂的上游,对话页仍会显示用量,设置页那张卡片不会出现。
  • 上游响应头里的 x-ratelimit-* 拿不到:USTC 只对非流式请求返回,而 DSH 的模型请求全部是流式。
  • 探测失败时保留上一次有效数据并在面板上标注错误,不会把失败显示成「不限额」。