Leafyezi233/dsh-llm-rate-limiter

Project Overview项目介绍

dsh-llm-rate-limiter is a native Cordis plugin built for DeepSeek Harness (DSH) that enforces per-model rate limits on every llm/stream waterfall call. It targets one provider/model pair at a time, tracking concurrency, requests per minute, and burst size independently for each combination. Installation is done through dsh plugin add <your-profile> @leaf233/dsh-llm-rate-limiter (npm) or dsh plugin add <profile> ./path/to/dsh-llm-rate-limiter (local path), and the cordis.patch.yml bundle entry is picked up automatically by reconcilePlugins. Plugin 0.3.x requires DSH 0.1.7-rc.1 or newer because the client services it depended on were removed in 0.1.7, while plugin 0.2.x remains the supported line for DSH 0.1.5 where connection.rpc.handle() was still usable.

Two algorithms ship in the box: Token Bucket, which lets bursts through up to a configured ceiling, and Sliding Window, which enforces a strict rolling RPM ceiling. When a request would exceed the limit the operator can pick Queue mode — throttled calls park in a waiter list and drain as tokens become available — or Reject mode, which returns a RATE_LIMIT error immediately for dsh-llm-retry to back off and retry. The configuration UI lives under DSH Settings → Plugins → Configurable as a collapsible card with hot-reload; expanding it reveals a live status panel that polls /llm-rate-limiter once per second and backs off to 2s/4s/8s after failures, while a collapsed card stops polling entirely and leaves the rest of the form functional.

Beyond the 375-assertion unit test suite (covering strategies, status RPC, real client bundle on a miniature React runtime, host integration via real apply(ctx, config), the self-registered fallback route, and the Config schema contract), the project ships pnpm run verify:live which performs 19 live HTTP checks against a real DSH webserver socket and exits with code 2 when DSH is absent. Cordis ≥4.0.0 is the only runtime dependency, the source is MIT licensed, and a symlink install lets lib/ edits take effect on a Ctrl+Shift+R browser refresh without reinstalling. DSH 0.2.x and Cordis 5+ are explicitly listed as untested.

dsh-llm-rate-limiter 是面向 DeepSeek Harness(DSH)的原生 Cordis 插件,按 provider/model 维度为每一次 llm/stream 调用施加独立并发、RPM 与突发上限。通过 dsh plugin add <profile> @leaf233/dsh-llm-rate-limiter 或本地路径安装,cordis.patch.yml 由 reconcilePlugins 自动纳入,DSH 0.3.x 要求 0.1.7-rc.1 及以上,0.1.5 需固定 0.2.x。状态面板走 /llm-rate-limiter 鉴权通道,未启用时卡片其余功能不受影响。

插件提供令牌桶与滑动窗口两种算法,可选择排队等待或立即拒绝并交由 dsh-llm-retry 指数退避重试。配置入口位于 DSH 设置 → 插件 → 可配置项,采用可折叠卡片并支持热更新;v0.2.0 起卡片展开时轮询 1s,折叠后停止,内置每模型进度条与最近 8 条事件环形缓冲(容量 64)。典型用户是在多供应商/多模型下需要稳定节流并希望直观观察被拒、超时与排队时延的开发者与运维。

依赖方面仅要求 Cordis ≥4.0.0 与 DSH 0.1.7-rc.1+,测试套件共 375 项断言覆盖算法、状态 RPC、客户端 Bundle、宿主集成、自注册路由与配置 Schema;本地开发通过 pnpm test 验证,pnpm run verify:live 在真实 DSH 套接字上做 19 项 HTTP 校验。0.2.x 已覆盖 0.1.7-rc.1 移除 settingsScope/settings.plugin.item 后改用 configForms/plugins.item 与 Config 导出 Schema,DSH 0.2.x 与 Cordis 5+ 暂未测试,源码以 MIT 发布。

Pre-install check安装前体检Compatibility · Security兼容性 · 安全性 1 warning1 项注意
  • Only 3 stars - very few users, little community feedback星标只有 3,几乎没人在用,遇到问题缺少社区反馈
DSH walks through these 9 checksDSH 会逐条核对这 9 项

Compatibility兼容性

  • DSH, Node, OS and profile requirementsDSH 版本 / Node 版本 / 操作系统 / profile 是否满足要求
  • External dependencies and runtimes (Electron / Python / Docker, ...)外部依赖与运行时(Electron / Python / Docker 等)是否齐备
  • Conflicts with installed plugins: command names, skill / tool names, ports, duplicate MCP registration与已装插件是否冲突:命令名、skill / tool 重名、端口占用、重复 MCP 注册

Security安全性

  • Repo matches the facts registered here; archived or abandoned?仓库是否与页面登记一致,是否归档或长期停更
  • Safety of preinstall / install / postinstall and install.sh / setup.ps1preinstall / install / postinstall 与 install.sh、setup.ps1 是否安全
  • curl|bash, download-then-execute, obfuscation, unrelated domains → stop immediatelycurl|bash、下载即执行、混淆代码、无关域名 → 立刻停止
  • Typosquatting or unmaintained packages among the new dependencies新增依赖里有没有 typosquatting 或无人维护的包
  • Requested permissions vs. what the feature actually needs申请了哪些权限、是否超出功能所需(filesystem / network / shell / clipboard)
  • Any sudo / admin requirement, plus uninstall and rollback是否要求 sudo / 管理员权限,以及卸载与回滚方式

Anything uncertain must be marked unknown with a note on how to confirm it. This site's signal screen is a static snapshot, not a security audit.拿不准的必须标「未知」并说明要我怎么确认。本站的信号筛查是静态快照,不能替代安全审计。

Or use CLI install (for developers)或使用命令行安装(适合开发者)

CLI Install命令行安装

dsh plugin --profile web add github:Leafyezi233/dsh-llm-rate-limiter

把 Leafyezi233/dsh-llm-rate-limiter 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

dsh-llm-rate-limiter

npm License: MIT DSH 0.1.7+ Cordis 4.x Tests

English | 中文

Per-model LLM call rate limiter for DeepSeek Harness with queue/reject support and interactive GUI configuration.


Features

  • Per-model rate limiting — independent concurrency, RPM, and burst limits for each provider/model
  • Two algorithms — Token Bucket (allows bursts) or Sliding Window (smooth, strict RPM)
  • Queue mode — throttled requests wait in queue and are released when a slot opens
  • Reject mode — throttled requests fail immediately (integrates with dsh-llm-retry for auto-backoff)
  • Interactive GUI — collapsible card in DSH Settings → Plugins → Configurable
  • Live status panel — real-time counters, per-model progress bars and an event log (v0.2.0)
  • Hot-reload — settings changes take effect immediately, no restart needed
  • Every request checked — intercepts llm/stream waterfall, covering every LLM call in every agent turn

Status Panel (v0.2.0)

Expanding the card shows a live panel at the top of its body:

📊 实时状态                          ● 实时   [清零]
 请求 42 · 通过 38 · 拒绝 2 · 超时 1 · 中止 1 · 平均等待 214ms
 deepseek/deepseek-chat   [令牌桶]  ▓▓▓▓▓▓▓░░░ 7.5/10   并发 2/5   排队 1
 openai/gpt-4o            [滑动窗口] ▓▓▓▓▓▓▓▓▓▓ 3/3 rpm  并发 1/5
 12:00:03  timeout   openai/gpt-4o              等待 1m
 12:00:01  rejected  openai/gpt-4o
 12:00:00  granted   deepseek/deepseek-chat     等待 4.2s
Aspect Behaviour
Data channel Channel /llm-rate-limiter — authenticated (401/403 fence), POST+JSON, auto-cleaned with the plugin fiber
Carrier Prefers the framework's connection.rpc.handle(); falls back to a self-registered prefix route that reuses connection.requestRejection() when the framework path is broken (see below)
Cadence 1 s polling while the card is expanded; backs off 2 s → 4 s → 8 s after failures
Collapsed card The panel unmounts, so no polling runs at all
Endpoints snapshot (live counters) and reset (zero the statistics)
Without a channel Shows "状态通道不可用" and leaves the rest of the card fully functional
Counters requests / granted / rejected / timeouts / aborted / totalWaitMs, plus the last 8 events (ring buffer of 64)
Progress bars Token bucket shows tokens/burstSize; sliding window shows countInWindow/maxRpm; both turn amber as the limit approaches

Showing the opening section of the README — the full document lives in the repository以上为 README 开头摘要,完整文档在仓库内 · View the full README on GitHub →在 GitHub 查看完整 README →

← 上一个 Prev AItelier 下一个 Next Amadeus →