dsh-tencent-channel-fix:修復 buddy / workbuddy 渠道 400(code 11128)

前言

在 DeepSeek Harness(DSH)裏走 buddy、workbuddy 這類騰訊系渠道時,常見現象是:新會話第一條消息就失敗,返回 400,錯誤碼 11128,文案類似「Illegal API invocation from an unapproved channel」或「請求被攔截,請重新發送」。報錯往往不指明具體是哪段請求頭或哪句系統提示觸發了攔截,排查成本高。

dsh-our-free-model 升級會整包覆蓋相關文件;若只靠手工改本地 node_modules,修復會在下一次插件更新後丟失。下面介紹社區插件 dsh-tencent-channel-fix(維護者 basaltfold,分類:工作流),如何在每次 DSH 啓動時自動修補兩處已知問題,並在上游錨點漂移時給出可觀測狀態。

這是什麼

dsh-tencent-channel-fix 是 DSH 插件,針對 dsh-our-free-model 內與騰訊渠道網關相關的兩處缺陷做冪等修補,並在 dsh-our-free-model 每次升級後重新應用,避免迴歸。

插件只改動 dsh-our-free-model 下的兩個文件:adapter/kernel.js 與 vendor/channel-pack/pack.js,不修改 provider、模型行、路由、憑證或其他 DSH 配置。

網關實際拒絕的兩件事

騰訊渠道網關會獨立檢查請求中的兩類內容;只修其一仍會 400。

1. 歸因 User-Agent

dsh-our-free-model/adapter/kernel.js 會把 Harness 身份寫進請求的 User-Agent,例如:

deepseek-harness/0.2.1-rc.2 (+https://github.com/deepseek-ai/deepseek-harness)

其中 deepseek-harness 在網關黑名單內,且大小寫不敏感(DeepSeek-Harness/0.2.1 同樣會被拒)。README 記載,測試中 curl、node、axios 等 UA 均可通過。

2. 系統提示中的 Harness 身份句

DSH 基礎系統提示開頭包含:

You are an AI agent powered by DeepSeek Harness.

網關將 powered by DeepSeek Harness 視爲內容指紋,出現在 system 消息中即整包拒絕。

dsh-our-free-model 已有 rewriteTencentContentFingerprints,但僅在 gateway 路徑(convertMessage / toMessages)執行;buddy 實際使用的 direct adapter 路徑用 messages.unshift(...) 組裝 system 消息且未走 rewriter,因此該句會原樣發出。

README 在真實端點上的對照結果:

請求組合 結果
原始 system + 原始 UA 400 code 11128
原始 system + 修復 UA 400 code 11128
改寫 system + 修復 UA 200 OK

爲什麼用插件而不是手改文件

兩處問題都是 dsh-our-free-model 包內文本;其更新器會整文件重寫,手工修改會在下次更新後消失——這也是同類問題反覆出現的直接原因。

該插件在每次啓動的 apply() 中(早於首次模型請求、相關模塊懶加載之前)修補上述文件,並具備:

  • 冪等:已修補文件帶標記則不再改寫;
  • 漂移感知:上游移動錨點時跳過對應 patch 並報告,不強行半寫;
  • 可回滾:寫入前備份,寫入後用 node --check 校驗,失敗則恢復原件。

因此 dsh-our-free-model 升級後,修補可在下次啓動自動重做,而不是靜默迴歸。

核心功能

  1. 啓動時自動應用三組修補(歸因 UA、內容指紋、direct 路徑 system 改寫)。
  2. 斜槓命令 /tencent-fix:status(默認)、apply、restore、why。
  3. 本機 loopback:GET /dsh-tencent-channel-fix 返回與 status 相同的 JSON(非 GET 返回 405)。
  4. 可選配置:autoApply、target、verbose(見下文)。
  5. pack.js 內改寫範圍限定爲 TENCENT_PROVIDERS = ["buddy", "workbuddy"],其他渠道不受影響;UA 仍保留版本等信息,僅去掉被攔的 token 與 URL。

安裝與啓用

官方安裝命令(來自 README):

dsh plugin add dsh-tencent-channel-fix

或從 GitHub 倉庫安裝:

dsh plugin add github:basaltfold/dsh-tencent-channel-fix

安裝後重啓 DSH 一次。啓動日誌可能出現:

[dsh-tencent-channel-fix] repair applied — applied attribution-user-agent, content-fingerprints, direct-system-rewrite. Active from the next model request.

或在上游變更導致錨點不匹配時:

[dsh-tencent-channel-fix] repair incomplete (upstream dsh-our-free-model changed) — drifted ...

插件以當前 DSH 進程權限運行,會在 profile 下的 dsh-our-free-model 目錄寫文件;安裝前請閱讀倉庫源碼與 MIT 許可證,確認符合你的安全與合規要求。

典型用法

查看修補狀態

在 DSH 對話或命令入口執行:

/tencent-fix

或顯式:

/tencent-fix status

示例輸出(來自 README):

dsh-tencent-channel-fix · patch revision 1
target: C:\Users\you\.dsh\profiles\desktop\node_modules\dsh-our-free-model
dsh-our-free-model: 2.5.7

OK      attribution-user-agent — Attribution User-Agent (400 / code 11128)
OK      content-fingerprints — Rejected system-prompt fingerprints (400 / code 11128)
OK      direct-system-rewrite — Direct adapter path system rewrite (400 / code 11128)

3/3 patches in place.

立即重打與恢復

  • /tencent-fix apply:強制立即修補,並打印成功項與 drift 項。
  • /tencent-fix restore:用最新備份還原,撤銷修補。
  • /tencent-fix why:在會話內輸出根因說明。

可選配置

在 bundle 中可插入(字段名以 README 爲準):

- insert:
    - id: tencent-channel-fix
      name: 'dsh-tencent-channel-fix'
      config:
        autoApply: true    # false = 僅報告 drift,不寫文件
        target: ''         # 顯式指定 dsh-our-free-model 目錄
        verbose: false     # 記錄每一步,含無操作的啓動

target 爲空時,會按當前 profile 解析 ${profile}/node_modules/dsh-our-free-model,再嘗試 Node 解析路徑與 ~/.dsh/profiles/*/node_modules/。

本地只讀檢查(不寫安裝目錄)

node -e "import('dsh-tencent-channel-fix/patcher').then(m => console.log(m.formatStatus(m.resolveTarget({}))))"

適用場景與注意

適合誰:在 DSH 中配置並使用 buddy、workbuddy 渠道,且遇到首條消息即 400 / code 11128 的開發者;需要在 dsh-our-free-model 頻繁升級後仍保持可用的工作流場景。

注意:

  • 修補針對 DSH 自身發出的 UA 與 system 指紋;同類錯誤也可能來自其他 CLI 代理項目的提示詞或頭字段(README 提及與 buddy-proxy、magpie 等 issue 同源網關行爲),本插件範圍僅限上述兩個文件內的 DSH 相關項。
  • 若未來 dsh-our-free-model 改動導致錨點漂移,/tencent-fix status 會標爲 drifted 並跳過該 patch;需根據新文件重新推導錨點並更新插件內 PATCHES(維護者側工作)。
  • 社區插件目錄(如 SkillHub)與 DeepSeek / 幻方無官方從屬關係;安裝與寫盤行爲由你本機 DSH 進程承擔,請自行審計源碼。

倉庫提供 npm test(README:29 個測試,無網絡、不觸碰真實安裝)用於維護者驗證;普通用戶以安裝後 status 與渠道請求是否 200 爲準即可。

結尾

dsh-tencent-channel-fix 把「騰訊渠道 11128」從反覆手改 node_modules 變成可觀測、可回滾、升級後可自愈的啓動修補,專注 buddy / workbuddy 兩條路徑上的 UA 與 system 指紋問題。

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

小夜