dsh-router-codebuddy
DSH plugin: CodeBuddy supplier family for dsh-router. Provides two same-family suppliers through the router.suppliers cordis service: codebuddy (Tencent CodeBuddy, copilot.tencent.com) and codebuddy-en (WorkBuddy international, www.workbuddy.ai). Both sha
Who this is for
- developers using DSH for coding with Git workflows
Install
dsh plugin --profile web add dsh-router-codebuddy
Sandbox test results
| Stage | Result |
|---|---|
| T0 static check | — |
| T1 install | ✓ |
| T2 list | ✓ |
| T3 mount | ✓ |
| T4 boot | — |
Four stages run in an isolated sandbox: install (network on) → list → mount → boot (last three with no network).
README
<h1 align="center">dsh-router-codebuddy</h1>
<p align="center">dsh-router 的 CodeBuddy 族供应商插件(国内 CodeBuddy + 国际版 WorkBuddy)</p>
<p align="center">
<a href="https://www.npmjs.com/package/dsh-router-codebuddy"><img src="https://img.shields.io/npm/v/dsh-router-codebuddy?style=flat-square&logo=npm&label=npm" alt="npm version"></a>
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-10b981?style=flat-square" alt="MIT license"></a>
<a href="https://www.npmjs.com/package/@deepseek-ai/dsh?activeTab=versions"><img alt="支持的 DSH 版本:0.2.0+" src="https://img.shields.io/badge/DSH-0.2.0%2B-4d6bfe" /></a>
</p>
<p align="center">
<a href="#快速安装">快速安装</a> ·
<a href="#两个供应商">两个供应商</a> ·
<a href="#能力">能力</a> ·
<a href="https://github.com/CARVIN94/dsh-router#readme">dsh-router 核心</a>
</p>
为 dsh-router 提供腾讯 CodeBuddy 族的两个供应商
(OAuth 轮询登录,OpenAI 兼容网关)。单独装它没用——它只是向核心注册供应商,面板、账号池、
组合回退都在核心里。
两个供应商
供应商 id · 面板名 · 上游 · 别名前缀
codebuddy · CodeBuddy · copilot.tencent.com(国内版) · codebuddy/
codebuddy-en · CodeBuddyEN · www.workbuddy.ai(WorkBuddy 国际版) · codebuddy-en/
WorkBuddy 是腾讯的国际版 AI 办公工作台,与国内 CodeBuddy 同族同契约:同样的
OAuth 轮询登录、同样的 /v2/chat/completions 网关、同样的 /billing/meter/* 签到积分。
因此两者共用同一份实现(src/core.ts),差异只落在各自的 profile 上:
src/
core.ts 共享实现 —— OAuth 登录、单账号 chat、token 刷新、签到、积分、模型拉取、
11128 重试阶梯
body.ts 出站请求体归一 —— 接口归一(developer/tool_choice/system 头)、
内容指纹按句改写、WAF 外壳剥离、11128 重试用的中性头与零宽散点
cn.ts codebuddy profile (copilot.tencent.com:/v2 单路径、CLI 指纹头)
en.ts codebuddy-en profile (www.workbuddy.ai:/console→/v2 回退、桌面端指纹头、WAF 净化)
index.ts 插件入口(host 半,一次注册两个供应商)
contract.ts 供应商契约(自含,与 dsh-router 契约同步)
types.ts 通用类型(SupplierStatus / ChatRequest 等)
cordis.patch.yml bundle patch,把插件插入 DSH cordis bundle stack
快速安装
需要 DSH 0.2.0 及以上(核心已单面 0.2.0,0.1.x 宿主不再支持)。先装核心,再装本插件,然后重启 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 与 CodeBuddyEN 两张卡片。
本地开发版:不用 npm,直接 dependencies 加
"dsh-router-codebuddy": "link:/path/to/dsh-router-codebuddy" 指向本地仓库。
能力
能力 · 说明
OAuth 轮询登录 · 生成登录链接 → 浏览器登录 → 后台轮询 token(每 5s,最多 5 分钟),自动落盘凭证。无粘贴回调步骤。
模型列表 · 「获取模型」从上游 GET /v3/config 实时拉取(带账号 token,服务端下发,新模型上游一上线就能刷出来);上游不可达时回退内置兜底表;仍可手动添加自定义模型。
接口归一(两个供应商) · chat 出站前 developer → system、tool_choice 对象形态 → string、首条非 system 时前置兜底 system —— 规避上游 11128 first message is not system prompt / 11101 Unmarshal chat params failed。国内网关同样会拿 11128 拒 DSH 自己的 system 开场白,所以归一两侧都跑。
内容指纹按句改写 · 出站前无条件跑:把上游实测拒收的那几句 DSH 提示词换成同义措辞(identity / coding agent / Web GUI / Agent Teams / @ 路径段逐句)。为什么不是零宽扰动:CN 网关匹配前会规范化掉不可见字符,root\u200b 这类插法仍 400/11128,只有真改词才 200(2026-10-29 本机实测:同一账号改写后 200、原文 400)。为什么按句:@ 路径段是组合指纹(逐句单发都 200、整段一起 400),且实测最小触发跨度只有该段前 112 字,所以行必须细到句子。没命中任何一行时返回入参原文,逐字节不变。
11128 重试阶梯 · 改写之后仍被渠道闸拒绝(Illegal API invocation from an unapproved channel)时,在同一个号上继续换请求形态重试,最多三级:原样 → 把被禁开场白挪到 You are a helpful assistant. 之后 → 在句读/词边界插零宽空格。每级只在确实改了字节时才发;三级都被拒才报 bad_request(请求级,不判账号死)。注意第三级对「规范化零宽」的网关无效,它是给不规范化、只做精确子串匹配的老规则留的;真正修掉这一族的是上面那层改写。
会话身份头 · chat 每请求现生成 X-Conversation-ID / -Request-ID / -Message-ID(官方客户端特征;缺了会撞 11128「不是官方客户端」那一支)。
连接池 · 多账号由核心按池顺序/策略(fallback / round-robin)选号回退,本插件只报告单个账号的成败与语义状态。
token 自动刷新 · 到期前 24 小时内用 refresh token 刷新(X-Refresh-Token 头),刷新失败继续用旧 token。
签到领积分 · 每日 100 积分(连续第 7 天 1000),核心遍历所有链接逐个调用。先读 checkin-activity-status:active=false(该区没办活动)→ 报「未开放」不发写请求;today_checked_in=true → 报「已签到」并发刷新积分。真签发时上游回 code=10001 也当成功(幂等两条腿都在)。状态读失败一律 fail-open,照旧直接签。
积分显示 · 面板账号积分 = get-user-resource 各额度包的剩余求和:统一读 cycle 家族(CycleCapacityRemain[Precise]),月度资源用 CapacityType === 4 判定,已过期/已耗尽的赠送包不计。请求体带分页/产品码/状态/到期时间窗(发 {} 会漏包)。企业号读 get-enterprise-user-usage,剩余 = limitNum − credit(credit 是已消耗)。内存缓存 10 分钟,签到后自动刷新。注意 TotalDosage 是累计已消耗,不是剩余。积分的持久化由核心统一做(supplier-config.json),本插件拿不到时报 -1 让核心顶上次的值。
使用
1. 重启 dsh web
2. 面板 → 供应商 → CodeBuddy / CodeBuddyEN 卡片 → 添加链接 → 浏览器登录 → 完成添加
新增账号会出现在面板账号池中;模型在供应商详情页点「获取模型」从上游拉取
(列表随服务端下发更新,无需升级插件),仍可手动添加自定义模型。
/v1/chat/completions 请求模型可写 glm-5.3-flash 或带别名前缀
codebuddy/glm-5.3-flash(插件自动剥前缀)。
模型从哪来:GET <base>/v3/config —— 官方客户端取云端产品配置的同一接口。
它不鉴权也返回 200,但 data.models 只有在带账号 accessToken 时才下发;所以必须
先添加链接再点获取模型,没账号时只会拿到内置兜底表。回包里的生图/视频模型
(tags含text-to-image等)走不了 chat 端点,会被过滤掉。
上游
国内 CodeBuddy(https://copilot.tencent.com):
- chat:
POST /v2/chat/completions(强制流式,非流式上游拒绝;转成 OpenAI SSE 交回核心写) - 模型:
GET /v3/config→data.models[](id/maxInputTokens/tags) - 登录:
POST /v2/plugin/auth/state生成链接 → 浏览器登录 → 轮询GET /v2/plugin/auth/token?state=...换 token 落盘 - 刷新:
POST /v2/plugin/auth/token/refresh(X-Refresh-Token头,到期前 24 小时内触发) - 积分/签到:
POST /v2/billing/meter/get-user-resource、POST /billing/meter/daily-checkin(404 回退/v2变体)、POST /v2/billing/meter/checkin-activity-status(只读预检)、POST /billing/meter/get-enterprise-user-usage(企业号余额) - 凭证:
auths/codebuddy/{uid}.json({nickname, accessToken, refreshToken, expiresAt})
国际版 WorkBuddy(https://www.workbuddy.ai)—— 与上面同契约,差异在路径与指纹:
- chat:
POST /console/chat/completions,404/405 回退POST /v2/chat/completions;出站前做接口归一(见上表) - 积分/签到:
POST /billing/meter/(无/v2前缀),404 回退/v2/billing/meter/;企业号另走/billing/meter/get-enterprise-user-usage - 出站指纹头:UA
WorkBuddy/5.5.4 WorkBuddy AI/5.5.4 CLI/2.137.1、同域Origin/Referer、Accept-Language: en-US、X-No-Enterprise-Id: 1 - WAF 净化(仅国际侧):剥掉
confirm/whoami的
…(truncated)
Rendered from the README published on npm. Formatted only, not edited.
Embed the badge
Two badges, each using its own site's identity: left is the **standard** (published by DSHIO), right is the **testing organization** (deepseekbase, which ran the inspection). Each links to the standard text and the test report.
Markdown(推荐,两个一起)
[](https://dshio.org/10/) [](https://deepseekbase.com/zh/plugins/dsh-router-codebuddy/)
Note: this is not a certification. DSHIO/T 32 is not in effect.
Versions
Published on npm::24,最后更新 2026-11-04
Links
Frequently asked
dsh plugin --profile web add dsh-router-codebuddy in DSH, or paste the package name into the DSH Desktop plugin page.dsh --version), then look at the first error in the test-results section. If it still fails, open an issue on the repository.dsh plugin --profile web remove dsh-router-codebuddy.