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-router-codebuddy

v0.3.1

Published

DSH plugin: CodeBuddy supplier for dsh-router. Provides the codebuddy supplier (OAuth login, OpenAI-compatible chat gateway) to dsh-router through the router.suppliers cordis service.

Readme

dsh-router 提供 codebuddy 供应商(OAuth 轮询登录,OpenAI 兼容网关)。 单独装它没用——它只是向核心注册一个供应商,面板、账号池、组合回退都在核心里。

快速安装

先装核心,再装本插件,然后重启 dsh web

dsh plugin --profile web add dsh-router-core
dsh plugin --profile web add dsh-router-codebuddy

dsh plugin add 会在 profile 里 pnpm add,并自动把声明了 dsh.bundle.patch 的包加入 dsh.profile.bundles(本插件即声明了,即 cordis.patch.yml)。

重启后本插件以 cordis service router.suppliers 向 dsh-router 注册 codebuddy 供应商,面板「供应商」出现 CodeBuddy 卡片。

本地开发版:不用 npm,直接 dependencies"dsh-router-codebuddy": "link:/path/to/dsh-router-codebuddy" 指向本地仓库。

能力

| 能力 | 说明 | |---|---| | OAuth 轮询登录 | 生成登录链接 → 浏览器登录 → 后台轮询 token(每 5s,最多 5 分钟),自动落盘凭证。无粘贴回调步骤。 | | 内置模型列表 | 上游无公开 models 接口,列表取自 WorkBuddy.app(CodeBuddy 官方桌面客户端)的 product.json + 9router 实际使用记录,只保留各系列最新版本(DeepSeek-V4 / GLM-5.2 / MiniMax-M3 / Kimi-K2.7 / Hy4+Hy3 / Hunyuan-2.0);仍可手动添加自定义模型。 | | 连接池 | 多账号由核心按池顺序/策略(fallback / round-robin)选号回退,本插件只报告单个账号的成败与语义状态。 | | token 自动刷新 | 到期前 24 小时内用 refresh token 刷新(X-Refresh-Token 头),刷新失败继续用旧 token。 | | 签到领积分 | 每日 100 积分(连续第 7 天 1000),核心遍历所有链接逐个调用。已签到上游返回 code=10001(HTTP 400 + 该码),幂等视为成功。 | | 积分显示 | 面板账号积分 = get-user-resource 各额度包的剩余求和(CapacityRemain,会续期的基础包取 CycleCapacityRemain),10 分钟缓存,签到后自动刷新。注意 TotalDosage累计已消耗,不是剩余。 |

使用

  1. 重启 dsh web
  2. 面板 → 供应商 → CodeBuddy 卡片 → 添加链接 → 浏览器登录 → 完成添加

新增的 CodeBuddy 账号会出现在面板账号池中;模型列表已内置(自动出现在面板 「可用模型」),仍可手动添加自定义模型。/v1/chat/completions 请求模型可写 glm-5.2 或带别名前缀 cbcn/glm-5.2(插件自动剥前缀)。

与核心的分工

本插件只管对单个账号调通上游:OAuth 协议、token 刷新、SSE 转换、签到、积分。

策略全在核心AccountPool):选号、冷却、禁用、连续错误累计、遍历回退、 响应写入。所以:

  • chatOnce(uid, req) 一次只服务一个账号,不遍历账号、不维护冷却表、不写响应
  • 失败时返回语义状态(rate_limit / quota / session_dead / unavailable / transport / unknown),由核心决定冷却多久、是否禁用、要不要换号
  • status() 只报「现在状态」(凭证 + 积分),冷却/禁用由核心叠加后给面板

完整契约见 dsh-router 的 docs/suppliers.md

上游

  • chatPOST /v2/chat/completions(强制流式,非流式上游拒绝;转成 OpenAI SSE 交回核心写,成败与语义状态报给核心换号)
  • 登录POST /v2/plugin/auth/state 生成链接 → 浏览器登录 → 轮询 GET /v2/plugin/auth/token?state=...(每 5s,最多 5 分钟)换 token 落盘
  • 刷新POST /v2/plugin/auth/token/refreshX-Refresh-Token 头,到期前 24 小时内触发)
  • 凭证:auths/codebuddy/{uid}.json{nickname, accessToken, refreshToken, expiresAt}

架构

通过 cordis service router.suppliers共享聚合表向 dsh-router 注册 codebuddy 供应商工厂(cordis 每个 service name 只允许一个插件 provide,本插件 inject 等其它 插件先提供该表后追加并广播 internal/service 触发重扫,与加载顺序无关)。

src/
  index.ts     插件入口(host 半,通过 cordis service router.suppliers 暴露供应商工厂表)
  plugin.ts    codebuddy 供应商实现(OAuth 登录、单账号 chat、token 刷新)
  contract.ts  供应商契约(自含,与 dsh-router 契约同步)
  types.ts     通用类型(SupplierStatus / ChatRequest 等)
cordis.patch.yml  bundle patch,把插件插入 DSH cordis bundle stack

开发

pnpm install
pnpm build        # lib/index.js
pnpm typecheck

致谢

许可证

MIT