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

@xidong-ai/dsh-rate-limiter

v0.3.4

Published

DeepSeek Harness 主动限速插件:按供应商令牌桶限速,超限延迟排队而非失败

Readme

dsh-rate-limiter

English | 中文

DeepSeek Harness(dsh)的主动限速插件:在模型请求发出之前按供应商控制请求速率(令牌桶),超限时延迟排队而不是失败,从而避免触发上游 429。

与官方 dsh-llm-retry(失败后指数退避)互补:限速在前(预防),退避在后(兜底),互不干扰。

特性

  • 按供应商令牌桶限速,且在请求发出之前生效(主动预防)
  • 超限请求延迟排队而非拒绝(不触发 429、不丢请求)
  • 未配置的供应商原样放行(零侵入)
  • 排队等待响应取消信号,用户停止时立即中断
  • 手写预约式令牌桶(并发安全),零第三方限速库依赖
  • 挂载 agent/request,与 dsh-llm-retry 天然共存

安装

从 npm 安装:

dsh plugin --profile web add @xidong-ai/dsh-rate-limiter

npm registry 的 URL 区分大小写,请使用小写包名。

或直接从 GitHub 安装:

dsh plugin --profile web add github:Xidong-AI/dsh-rate-limiter

本地开发时直接添加当前目录:

dsh plugin --profile web add .

安装后 dsh --profile web --dump-config 应能看到插件行:

- id: rate-limiter
  name: @xidong-ai/dsh-rate-limiter
  config:
    enabled: true
    providers: {}

配置

在 profile 的 cordis.patch.yml(或本插件 cordis.patch.yml)中按供应商配置令牌桶:

- id: rate-limiter
  config:
    enabled: true
    providers:
      nvidia:
        rate: 0.5        # 词元每秒(长期平均 QPS)
        burst: 1         # 桶容量(允许的突发请求数)
      sensenova:
        rate: 0.02778
        burst: 1
  • rate:补充速率(词元每秒),即长期平均请求速率。
  • burst:桶容量,允许的突发请求数。
  • 未列出的供应商不限速,请求原样放行(零侵入)。
  • enabled: false 可整体关闭插件。

工作原理

插件挂在 agent/request waterfall 上,先 await next() 拿到含供应商的调用配置,再按供应商做令牌桶检查,不足则延迟排队(等待期间响应取消信号,用户停止时立即中断),然后原样返回配置。不修改请求内容、不改路由、不吞错误,只控制何时发出。

限速算法为手写令牌桶(预约式,并发安全),零第三方限速库依赖。

与 dsh-llm-retry 的关系

| 插件 | 时机 | 行为 | | ---- | ---- | ---- | | dsh-rate-limiter | 请求发出前 | 超限延迟排队(预防 429) | | dsh-llm-retry | 请求失败后 | 指数退避重试(兜底) |

两者挂载点不同(agent/request vs agent/request-error),天然共存。

兼容性

运行时特性探测使同一份构建可同时运行在 dsh 0.1.x 与 0.2.x 宿主上。0.2.x 下保存设置不再报 has no volatile fields,卡片同时注册在 bundle 级与插件行 级配置座位。0.3.3 起支持。

卸载

dsh plugin --profile web remove @xidong-ai/dsh-rate-limiter

开发

npm install
npm run typecheck   # tsc --noEmit
npm run test        # vitest run
npm run build       # esbuild 转译 lib/*.ts → lib/*.js

鸣谢

感谢 Linux.do 社区的支持。