dsh-free-model 0.2.4 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/README_EN.md +4 -2
- package/SECURITY-AUDIT.md +3 -3
- package/package.json +1 -1
- package/vendor/channel-pack/NOTICE.md +17 -0
- package/vendor/channel-pack/pack.js +233 -47
package/README.md
CHANGED
|
@@ -88,7 +88,7 @@ dsh plugin --profile web add dsh-our-free-model # 回滚到上游 2.1.0
|
|
|
88
88
|
| `packages/standalone/`(独立 Web 产品)、`worker/`(EAC 的 Cloudflare 授权网关)、`feed/` + `catalog/`(公告源与发布清单) | 三块卫星全部 `import` 被删车道,留着就是一套永远跑不起来的代码。 |
|
|
89
89
|
|
|
90
90
|
规模变化:`src/` 从 **58 个模块 → 5 个**(`store/key/chan-relay/egress/trust`),宿主 `index.js` 从
|
|
91
|
-
**2343 行 → 684 行**,浏览器半身 `client.js` 从 **5992 行 → 2531 行**,离线测试从 45 个套件 → **
|
|
91
|
+
**2343 行 → 684 行**,浏览器半身 `client.js` 从 **5992 行 → 2531 行**,离线测试从 45 个套件 → **18 个**。
|
|
92
92
|
界面里所有 `animation` 与 `@keyframes` 也已删除。
|
|
93
93
|
|
|
94
94
|
## 配置
|
|
@@ -142,7 +142,7 @@ POST /chan-gateway/rotate 轮换中继密钥
|
|
|
142
142
|
## 测试
|
|
143
143
|
|
|
144
144
|
```bash
|
|
145
|
-
npm test #
|
|
145
|
+
npm test # 18 个离线套件,无需网络、不花额度
|
|
146
146
|
node scripts/host-smoke-test.mjs # 只跑宿主 HTTP 面
|
|
147
147
|
node scripts/client-lint.mjs # 只跑浏览器半身(字典键一一对应 + CSS 规则可达)
|
|
148
148
|
```
|
|
@@ -160,6 +160,8 @@ node scripts/client-lint.mjs # 只跑浏览器半身(字典键一一
|
|
|
160
160
|
| `channel-cline-dev` | Cline 的 models.dev 目录:`Accept-Encoding: br, gzip`、ETag/条件请求、**304 回退成上次结果**(不许变空表)、超时 60s、`supportsImage: false` 保真 |
|
|
161
161
|
| `channel-officeace-lock` / `channel-officeace-login` | 移植渠道 OfficeAce:登录闭环真走 RPC(authorize URL → poll → 换 token → 落库);锁定分道的**判定与执行**逐条断言(未锁定逐字走旧路径、锁定+只剩永久桶必须抛错不回落)|
|
|
162
162
|
| `channel-accio` | 移植渠道 Accio:真走 RPC 完成回调式登录(授权页 → 本地回调 → 换 token → 按**账号 ref** 落库),并断言自动续期表覆盖 accio / officeace(漏一项 = 静默不续期且零日志)|
|
|
163
|
+
| `channel-buddy-conv` | WorkBuddy/CodeBuddy:`send()` 必发三枚非空 `X-Conversation-*`(缺则特定账号整条渠道 `400/11128` 全灭);渠道校验档换号、**不写冷却**、报 `PERMISSION_DENIED` 指向账号;单账号池不误报 `QUOTA_EXCEEDED`;11140 仍写冷却 |
|
|
164
|
+
| `channel-fingerprint` | 腾讯系内容指纹改写:assistant 正文那格一旦漏改,带毒历史每轮重放 ⇒ **会话报废且换任何腾讯系模型都一样**;白名单严格只有 buddy/workbuddy;良性文本不被破坏 |
|
|
163
165
|
|
|
164
166
|
上游的 45 个套件里,其余的都在测被删掉的车道,已一并移除。测试**只在仓库里跑**(npm 包不含 `scripts/`)。
|
|
165
167
|
|
package/README_EN.md
CHANGED
|
@@ -95,7 +95,7 @@ Four settings pages (down from nine):
|
|
|
95
95
|
|
|
96
96
|
Sizes: `src/` went from **58 modules to 5** (`store/key/chan-relay/egress/trust`), the host `index.js`
|
|
97
97
|
from **2343 to 684 lines**, the browser half `client.js` from **5992 to 2538 lines**, and the offline
|
|
98
|
-
suites from 45 to **
|
|
98
|
+
suites from 45 to **18**. Every `animation` and `@keyframes` rule is gone as well.
|
|
99
99
|
|
|
100
100
|
## Configuration
|
|
101
101
|
|
|
@@ -148,7 +148,7 @@ the browser half talks to it over the shell's `connection` RPC (`usage.tokenLedg
|
|
|
148
148
|
## Tests
|
|
149
149
|
|
|
150
150
|
```bash
|
|
151
|
-
npm test #
|
|
151
|
+
npm test # 18 offline suites: no network, no quota
|
|
152
152
|
node scripts/host-smoke-test.mjs # the host HTTP surface only
|
|
153
153
|
node scripts/client-lint.mjs # the browser half only (dictionary keys, CSS reachability)
|
|
154
154
|
```
|
|
@@ -166,6 +166,8 @@ node scripts/client-lint.mjs # the browser half only (dictionary keys, C
|
|
|
166
166
|
| `channel-cline-dev` | Cline's models.dev catalog: `Accept-Encoding: br, gzip`, ETag conditional requests, **304 falling back to the previous result** (never an empty catalog), 60s timeout, and `supportsImage: false` preserved |
|
|
167
167
|
| `channel-officeace-lock` / `channel-officeace-login` | The ported OfficeAce channel: the login loop really goes through RPC (authorize URL → poll → token → persisted); the lock **decision and its execution** are asserted case by case (unlocked keeps the old path verbatim, locked-with-only-permanent must throw and never fall back to the pool) |
|
|
168
168
|
| `channel-accio` | The ported Accio channel: a callback-style login really goes through RPC (authorize page → local callback → token exchange → persisted under the **account's own ref**), plus the auto-renew table is asserted to cover accio / officeace (a missing entry = silently never renewed, with no log) |
|
|
169
|
+
| `channel-buddy-conv` | WorkBuddy/CodeBuddy: `send()` must emit three non-empty `X-Conversation-*` headers (without them, certain accounts get the whole channel dead on `400/11128` every turn); the channel-verification tier rotates accounts, **writes no cooldown**, and reports `PERMISSION_DENIED` pointing at the account; a single-account pool must not misreport `QUOTA_EXCEEDED`; 11140 still writes its cooldown |
|
|
170
|
+
| `channel-fingerprint` | Tencent content-fingerprint rewriting: missing the assistant-body case means a poisoned history replays every turn — the session is dead **and switching to any other Tencent model does not help**; the allowlist is exactly buddy/workbuddy; benign text is left intact |
|
|
169
171
|
|
|
170
172
|
The other 37 of upstream's 45 suites tested lanes this fork deletes. The suites run **from a checkout
|
|
171
173
|
only** — the npm package does not ship `scripts/`.
|
package/SECURITY-AUDIT.md
CHANGED
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
| --- | --- |
|
|
13
13
|
| `index.js` | `a932bcb6bdeef608496071a60d1f9e8499997fca52765e0eb300171d8728aa57` |
|
|
14
14
|
| `client.js` | `13332f9b4102e5cc7125998983126df7b50cfa6a32ef5e20aefc51aca0a5e820` |
|
|
15
|
-
| `vendor/channel-pack/pack.js` | `
|
|
15
|
+
| `vendor/channel-pack/pack.js` | `e1d8d46c772b8276c9e6f2d638ee21ea8100cd4fd2094053d24f27f172c16660` |
|
|
16
16
|
|
|
17
17
|
⚠️ `pack.js` 的指纹随每次「刷新模型数据 / 移植上游修复」而变(它是构建产物)。
|
|
18
|
-
|
|
18
|
+
上面的值对应**腾讯内容指纹改写到 assistant 正文(2026-10-21,会话报废根因)之后**的版本;
|
|
19
19
|
域名面结论未变,`scripts/egress-audit.mjs` 可随时重跑复验。
|
|
20
|
-
(上一版 `
|
|
20
|
+
(上一版 `6ab1bc17…` 是 WorkBuddy 三头 + 渠道校验移植后的产物。)
|
|
21
21
|
|
|
22
22
|
## 结论
|
|
23
23
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-free-model",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "dsh 插件(DeepSeek Harness / cordis bundle)· 模型接入 —— 把 CodeArts、CodeBuddy / WorkBuddy、LobsterAI、Qoder / Qoder CN、TRAE、Cline、Loomy、Raccoon、MiniMax Code、ZCode、Gemini、OfficeAce、Accio Work 十五个账号渠道接进 dsh 的模型选择器,并保留数据看板、运行日志与本地网关(含局域网中继)。上游 2.1.0 的匿名免费车道、EAC 协付车道、聚合渠道、省 Token、路由、公告/升级/热重载与独立 Web 产品已全部移除。",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -44,6 +44,23 @@ Cline、Loomy、Raccoon、MiniMax Code、ZCode、Gemini、OfficeAce、Accio Work
|
|
|
44
44
|
`STS5.1806 invalid refresh token: 'decode jwt header failed'`(2026-10-19 实发)。
|
|
45
45
|
现全部脚本进程级隔离该变量。
|
|
46
46
|
|
|
47
|
+
### 后续单点修复移植(2026-10-21)
|
|
48
|
+
|
|
49
|
+
| 上游 | 修的是什么 | 本地改动 |
|
|
50
|
+
| --- | --- | --- |
|
|
51
|
+
| `83ced0d`(IKM3A0) | `officeace-product.ts` 的 `contextWindow` 初版**全是估值**(GLM 三行 202_752 抄自 CodeArts 表、`deepseek-v4.1-flash` 196_608 查无出处)⇒ 比真实上限小 5.3 倍,DSH 压缩阈值 `0.8×contextWindow` 提前触发,**1M 能力永远吃不到**(静默降级,不报错)| 逐字覆盖为上游真机取证值(glm-5.3/deepseek-v4.1-flash `1_048_576`、glm-5.2/deepseek-v4-flash `1_044_480`、kimi-k2.6 `262_144`,含取证注释整段)|
|
|
52
|
+
| `b554b73`+`eeda381`+`510bf91`+`7b24e23`(IKM73W/IKM7SG) | WorkBuddy 的 `send()` **缺 `X-Conversation-*` 三头** ⇒ 特定账号每轮 `HTTP 400 {"code":11128,"msg":"request illegal"}`,**整条渠道全灭**(真机探针复现:无三头 400 → 带三头 200);且 11128 不满足 `isRateLimited` ⇒ 落进「非限流即抛」,换号救不了 | `send()` 补三头(根因);`buddy-adapter.ts` 搬入渠道校验判据三条腿 + 排除腿(`isContentRejection` 不再把 11128 误判成 11140 而误封可用账号 30 分钟)+ 四处集成(认证/限流两换号循环、两处出口、流内帧),调用点 7 处与上游对齐 |
|
|
53
|
+
|
|
54
|
+
⚠️ 11128 判据**必须按 `msg` 措辞、绝不按 `code===11128` 放宽**:同码至少四族子原因
|
|
55
|
+
(渠道校验=换号 / unapproved channel=改内容 / 非 system 首条=补 system / 内容指纹=改写),
|
|
56
|
+
按 code 会把后几族也拖进换号 ⇒ 误伤。回归钉子:`scripts/channel-buddy-conv-test.mjs`
|
|
57
|
+
(三头非空 / 单账号 11128 报 PERMISSION_DENIED 不写冷却 / 换号 / 11140 仍写冷却;
|
|
58
|
+
两条变异验证过有牙)。
|
|
59
|
+
|
|
60
|
+
⚠️ 本轮还修了测试桩 `scripts/lib/channel-pack-kernel.mjs` 的一个错位:`LlmError`
|
|
61
|
+
形参写成 `(code, message)`,真实签名是 `(message, code)` ⇒ 桩不校验,任何断言
|
|
62
|
+
`err.code` 的用例拿到的都是 message。桩对齐真实签名后 4 条断言才可信。
|
|
63
|
+
|
|
47
64
|
⚠️ **移植一个带「锁定永久积分」的渠道,必须同时登记 `channel-pack-rpc.ts` 的
|
|
48
65
|
`PERMANENT_LOCK_PROVIDERS`** —— 上游那个 issue 的缺陷是「UI 有按钮、执行代码没有」,
|
|
49
66
|
而**只接执行代码、漏登记白名单是它的镜像**:写入被白名单先一步拒掉 ⇒
|
|
@@ -34536,6 +34536,112 @@ function isPositiveFinite(value) {
|
|
|
34536
34536
|
return typeof value === "number" && Number.isFinite(value) && value > 0;
|
|
34537
34537
|
}
|
|
34538
34538
|
|
|
34539
|
+
// vendor/channel-pack/src/openai-gateway/tencent-fingerprint.ts
|
|
34540
|
+
var TENCENT_PROVIDERS = ["buddy", "workbuddy"];
|
|
34541
|
+
var CONTENT_FINGERPRINTS = [
|
|
34542
|
+
{
|
|
34543
|
+
// ZCode 内建常量:`$Js="Main branch (you will usually use this for PRs)"`。
|
|
34544
|
+
// 每个 git 仓库里的会话都会被注入(拼在 `Main branch … : <分支名>` 这一行)。
|
|
34545
|
+
find: "Main branch (you will usually use this for PRs)",
|
|
34546
|
+
replace: "Main branch (PRs usually go here)",
|
|
34547
|
+
note: "Gitee IKJNA1\uFF1B\u672C\u673A 2026-10-05 \u5BF9 workbuddy / CodeBuddy \u53CC\u7AEF\u70B9\u5B9E\u6D4B\u590D\u73B0"
|
|
34548
|
+
},
|
|
34549
|
+
{
|
|
34550
|
+
// Claude Code 内建常量(v2.1.295 的 `yl`):
|
|
34551
|
+
// `"You are Claude Code, Anthropic's official CLI for Claude."`
|
|
34552
|
+
//
|
|
34553
|
+
// ⚠️ **`find` 刻意不带尾句点**,一条同时覆盖两个常量(本机实测两者改写后都放行):
|
|
34554
|
+
// - `yl` = `You are Claude Code, Anthropic's official CLI for Claude.`
|
|
34555
|
+
// - `sf` = 同句 + `, running within the Claude Agent SDK.`
|
|
34556
|
+
// 第三个常量 `af`(`You are a Claude agent, built on Anthropic's Claude Agent SDK.`)
|
|
34557
|
+
// 实测**不被拦**,故刻意不登记(多一条就是替上游无谓改写用户提示词)。
|
|
34558
|
+
//
|
|
34559
|
+
// ## ⚠️⚠️ 本条的匹配语义**不是**「位置无关」,而是**行首锚定**(与 ZCode 那条相反)
|
|
34560
|
+
//
|
|
34561
|
+
// 2026-10-14 本机对两个端点的逐格实测(详见 `docs/agent-notes/providers-buddy.md`
|
|
34562
|
+
// 「Claude Code 身份句」一节):该指纹**只在文本绝对开头**被拦 ——
|
|
34563
|
+
// | 形态 | 结果 |
|
|
34564
|
+
// |---|---|
|
|
34565
|
+
// | 裸串 | ❌ 400/11128 |
|
|
34566
|
+
// | 前接空格 / 前换行 / 前接任意前言 | ✅ **200 放行** |
|
|
34567
|
+
// | 后接句点 / 破折号 / 中文句号 / 长正文 | ❌ 400/11128 |
|
|
34568
|
+
// 即**前导字符一个都不容忍、后缀完全自由**,与 ZCode 那条的「位置无关」不同。
|
|
34569
|
+
//
|
|
34570
|
+
// 这不影响改写本身(下面 `replaceAll` 照样生效),但**影响怎么为新指纹做探针**:
|
|
34571
|
+
// 只测「夹在句中」会得到「已放行」的**假阴性**(真因是锚点,不是这句不再触发)。
|
|
34572
|
+
// 故本条的实测凭据必须含**贪心探针**(覆盖行首与非行首两侧),见
|
|
34573
|
+
// `tests/e2e/buddy-fingerprint-roles.e2e.spec.ts` 的 Claude 段。
|
|
34574
|
+
//
|
|
34575
|
+
// ⚠️ **改成行首锚定的正则**(如 `^` 配 `m`)是**错**的:改写范围宁可略宽 ——
|
|
34576
|
+
// 漏改一处就换来整轮 400,多改一处只是语义等价的措辞变化(原文已不存在
|
|
34577
|
+
// 「位置无关」的相反证据)。故与上一条共用同一条实现路径。
|
|
34578
|
+
find: "You are Claude Code, Anthropic's official CLI for Claude",
|
|
34579
|
+
replace: "You are Claude Code, Anthropic's CLI for Claude",
|
|
34580
|
+
note: "Gitee IKLS2L\uFF1B\u672C\u673A 2026-10-14 \u5BF9 workbuddy / CodeBuddy \u53CC\u7AEF\u70B9\u5B9E\u6D4B\uFF1Asystem \u4E0E assistant \u6B63\u6587\u4F4D\u7F6E\u5747 400/11128\uFF0C\u6539\u5199\u540E\u4E24\u7AEF\u70B9\u5747 200\uFF08\u542B SDK \u53D8\u4F53\uFF09"
|
|
34581
|
+
},
|
|
34582
|
+
{
|
|
34583
|
+
// Claude Code system prompt 的「帮助 / 反馈」段默认句(Gitee issue IKLYCT):
|
|
34584
|
+
// `To give feedback, users should report the issue at
|
|
34585
|
+
// https://github.com/anthropics/claude-code/issues`
|
|
34586
|
+
//
|
|
34587
|
+
// ## 与上一条(身份句)不同:这一条**每轮必带**,不是概率性泄漏
|
|
34588
|
+
//
|
|
34589
|
+
// 身份句只有 cc-switch 的 `mrt()` 探测路径漏传 `skipSystemPromptPrefix` 时才注入
|
|
34590
|
+
// (实测约 34%);本句属于 Claude Code system prompt 的**固定段落**,
|
|
34591
|
+
// 只要客户端把默认 system 整份发过来就必然带上 ⇒ **漏登记 = 必然命中**。
|
|
34592
|
+
// 用户侧实测:单日 buddy/workbuddy 因它白撞 647 次。
|
|
34593
|
+
//
|
|
34594
|
+
// ## ⚠️ 匹配语义:**位置无关**(与身份句的「行首锚定」相反)
|
|
34595
|
+
//
|
|
34596
|
+
// 2026-10-18 本机对 `www.workbuddy.ai` + `copilot.tencent.com` 双端点逐格实测:
|
|
34597
|
+
// | 形态 | 结果 |
|
|
34598
|
+
// |---|---|
|
|
34599
|
+
// | 裸串 / 前接 `Note: ` / 前接行首 ` - ` | ❌ 400/11128 ⇒ 位置无关 |
|
|
34600
|
+
// | 后接换行 + 其他文本 | ❌ 400/11128 |
|
|
34601
|
+
// | 全大写 | ❌ 400/11128 ⇒ 与另两条同型(大小写不敏感) |
|
|
34602
|
+
// | 换 org/repo、换域名、改一个词、只留 URL | ✅ 200 ⇒ **逐字符** |
|
|
34603
|
+
// | **砍掉前半 / 砍掉后半** | ✅ 200 ⇒ **`find` 必须写整句** |
|
|
34604
|
+
//
|
|
34605
|
+
// ⚠️ 最后那一格是本条的**要害**:子串本身不触发,写短了等于空跑 ——
|
|
34606
|
+
// 而空跑的症状是「登记了却仍每轮 400」,极难归因。
|
|
34607
|
+
//
|
|
34608
|
+
// ⚠️ 本条的 `find`(整句 99 字符)已经**贴着**上游屏蔽名单的粒度,
|
|
34609
|
+
// 不要再按 ZCode 那条的思路去「缩短 find 覆盖更多变体」:实测换域名即放行。
|
|
34610
|
+
// ⚠️⚠️ **「缩短/删字」这类变异只有实发能验,单测锁不住**:
|
|
34611
|
+
// 单测能证明「砍掉半句时我们**不**改写」(那是真事实),但证明不了
|
|
34612
|
+
// 「砍掉半句后上游**仍会拦**」—— 那只有 e2e 能验(见上面那两格)。
|
|
34613
|
+
// ⇒ 改本行时**必须**跑一遍 `DSH_BUDDY_FINGERPRINT_E2E=1` 那节。
|
|
34614
|
+
//
|
|
34615
|
+
// ⚠️ 与身份句同理**不做行首锚定**:改写宁可略宽(漏改 = 整轮 400,
|
|
34616
|
+
// 多改 = 语义等价的措辞变化)。
|
|
34617
|
+
find: "To give feedback, users should report the issue at https://github.com/anthropics/claude-code/issues",
|
|
34618
|
+
// 实测两端点均 200(buddy / workbuddy,2026-10-18)。措辞与原文等义。
|
|
34619
|
+
replace: "To give feedback, users should report the issue at the project issue tracker",
|
|
34620
|
+
note: "Gitee IKLYCT\uFF1B\u672C\u673A 2026-10-18 \u5BF9 workbuddy / CodeBuddy \u53CC\u7AEF\u70B9\u5B9E\u6D4B\uFF1Asystem\uFF08\u542B\u975E\u9996\u4F4D\uFF09\u4E0E assistant \u6B63\u6587\u5747 400/11128\uFF0Cuser / reasoning_content / tool \u7ED3\u679C\u653E\u884C\uFF0C\u6539\u5199\u540E\u4E24\u7AEF\u70B9\u5747 200"
|
|
34621
|
+
}
|
|
34622
|
+
];
|
|
34623
|
+
function escapeRegExp(literal) {
|
|
34624
|
+
return literal.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
34625
|
+
}
|
|
34626
|
+
var COMPILED = CONTENT_FINGERPRINTS.map((rule) => ({
|
|
34627
|
+
replace: rule.replace,
|
|
34628
|
+
findLower: rule.find.toLowerCase(),
|
|
34629
|
+
// `g` = 全部出现都改写;`i` = 大小写不敏感(实测全小写 / 全大写同样被拦)。
|
|
34630
|
+
pattern: new RegExp(escapeRegExp(rule.find), "gi")
|
|
34631
|
+
}));
|
|
34632
|
+
function isTencentContentFingerprintProvider(provider) {
|
|
34633
|
+
return TENCENT_PROVIDERS.includes(provider);
|
|
34634
|
+
}
|
|
34635
|
+
function rewriteTencentContentFingerprints(text, provider) {
|
|
34636
|
+
if (!isTencentContentFingerprintProvider(provider)) return text;
|
|
34637
|
+
let out = text;
|
|
34638
|
+
for (const rule of COMPILED) {
|
|
34639
|
+
if (!out.toLowerCase().includes(rule.findLower)) continue;
|
|
34640
|
+
out = out.replace(rule.pattern, rule.replace);
|
|
34641
|
+
}
|
|
34642
|
+
return out;
|
|
34643
|
+
}
|
|
34644
|
+
|
|
34539
34645
|
// vendor/channel-pack/src/buddy-adapter.ts
|
|
34540
34646
|
function isDeepSeekModel(model) {
|
|
34541
34647
|
return /^deepseek/i.test(model.trim());
|
|
@@ -34621,7 +34727,7 @@ function contentToText2(content) {
|
|
|
34621
34727
|
return content.filter((block) => typeof block === "object" && block !== null && block.type === "text").map((block) => String(block.text)).join("");
|
|
34622
34728
|
}
|
|
34623
34729
|
var TOOL_RESULT_IMAGE_TEXT = "Attached image(s) from tool result:";
|
|
34624
|
-
function serializeMessages2(messages, imageUrls) {
|
|
34730
|
+
function serializeMessages2(messages, imageUrls, provider) {
|
|
34625
34731
|
const wire = [];
|
|
34626
34732
|
let pendingToolImages = [];
|
|
34627
34733
|
const flushToolImages = () => {
|
|
@@ -34647,7 +34753,7 @@ function serializeMessages2(messages, imageUrls) {
|
|
|
34647
34753
|
function: { name: String(block.name), arguments: normalizeToolArguments(String(block.arguments)) }
|
|
34648
34754
|
}));
|
|
34649
34755
|
const reasoning = content2.filter((block) => typeof block === "object" && block !== null && block.type === "reasoning").map((block) => String(block.text)).join("");
|
|
34650
|
-
const text2 = contentToText2(content2);
|
|
34756
|
+
const text2 = rewriteTencentContentFingerprints(contentToText2(content2), provider);
|
|
34651
34757
|
flushToolImages();
|
|
34652
34758
|
wire.push({
|
|
34653
34759
|
role: "assistant",
|
|
@@ -34660,7 +34766,7 @@ function serializeMessages2(messages, imageUrls) {
|
|
|
34660
34766
|
}
|
|
34661
34767
|
if (message2.role === "system") {
|
|
34662
34768
|
flushToolImages();
|
|
34663
|
-
wire.push({ role: "system", content: contentToText2(message2.content) });
|
|
34769
|
+
wire.push({ role: "system", content: rewriteTencentContentFingerprints(contentToText2(message2.content), provider) });
|
|
34664
34770
|
continue;
|
|
34665
34771
|
}
|
|
34666
34772
|
const content = Array.isArray(message2.content) ? message2.content : [];
|
|
@@ -34709,8 +34815,65 @@ function errorMessage2(error) {
|
|
|
34709
34815
|
return "unknown error";
|
|
34710
34816
|
}
|
|
34711
34817
|
}
|
|
34818
|
+
var ILLEGAL_CODE = /"code"\s*:\s*"?11128(?![\d.])/iu;
|
|
34819
|
+
var ILLEGAL_MSG = /"m(?:sg|essage)"\s*:\s*"[^"]{0,200}?request(?:[\s:_\-\p{Cf}]|\\[nrt])+illegal/iu;
|
|
34820
|
+
var CONTENT_BLOCKED_CODE = /"code"\s*:\s*"?11128(?![\d.])/iu;
|
|
34821
|
+
var CONTENT_BLOCKED_MSG = /"m(?:sg|essage)"\s*:\s*"[^"]{0,200}?illegal\s+api\s+invocation/iu;
|
|
34822
|
+
var CHANNEL_VERIFICATION_MSG_FIELD = /"m(?:sg|essage)"\s*:\s*"[^"]*conversation(?:[\s:_\-\p{Cf}]|\\[nrt])+id(?:[\s:_\-\p{Cf}]|\\[nrt])+missing/iu;
|
|
34823
|
+
var CHANNEL_VERIFICATION_BARE = /conversation(?:[\s:_\-\p{Cf}]|\\[nrt])+id(?:[\s:_\-\p{Cf}]|\\[nrt])+missing/iu;
|
|
34824
|
+
var CHANNEL_VERIFICATION_PHRASE = /"m(?:sg|essage)"\s*:\s*"[^"]*?(?:conversation(?:[\s:_\-\p{Cf}]|\\[nrt])+id(?:[\s:_\-\p{Cf}]|\\[nrt])+missing|request(?:[\s:_\-\p{Cf}]|\\[nrt])+illegal)/iu;
|
|
34825
|
+
function isChannelVerificationIllegalBody(body) {
|
|
34826
|
+
return ILLEGAL_CODE.test(body) && ILLEGAL_MSG.test(body);
|
|
34827
|
+
}
|
|
34828
|
+
function isChannelVerificationBody(body) {
|
|
34829
|
+
return ILLEGAL_CODE.test(body) && CHANNEL_VERIFICATION_PHRASE.test(body);
|
|
34830
|
+
}
|
|
34831
|
+
function isContentBlockedIllegalBody(body) {
|
|
34832
|
+
return CONTENT_BLOCKED_CODE.test(body) && CONTENT_BLOCKED_MSG.test(body);
|
|
34833
|
+
}
|
|
34834
|
+
function isChannelVerificationRejection(body, status) {
|
|
34835
|
+
if (body.length === 0) return false;
|
|
34836
|
+
if (CHANNEL_VERIFICATION_MSG_FIELD.test(body)) return true;
|
|
34837
|
+
if (isChannelVerificationIllegalBody(body)) return true;
|
|
34838
|
+
if (status !== void 0 && status !== 400 && status !== 403) return false;
|
|
34839
|
+
if (/"m(?:sg|essage)"\s*:/.test(body)) return false;
|
|
34840
|
+
if (/^\s*\{/.test(body) && /"code"\s*:/.test(body)) return false;
|
|
34841
|
+
return CHANNEL_VERIFICATION_BARE.test(body);
|
|
34842
|
+
}
|
|
34843
|
+
function redactUpstreamActionHints(text) {
|
|
34844
|
+
const REDACTED = "\uFF08\u5DF2\u62B9\u53BB\u4E0A\u6E38\u7684\u884C\u52A8\u6307\u5F15\uFF09";
|
|
34845
|
+
return text.replace(/请[^。;\n]{0,12}?(?:重新发送|重新傳送|重新传|重发)/g, REDACTED).replace(/\b(?:please\s+)?(?:re)?send\b[^.\n]{0,20}?(?:\bagain\b|from the official client)/gi, REDACTED);
|
|
34846
|
+
}
|
|
34847
|
+
function channelVerificationUpstreamId(body) {
|
|
34848
|
+
try {
|
|
34849
|
+
const data = JSON.parse(body);
|
|
34850
|
+
const inner = typeof data.error === "object" && data.error !== null ? data.error : void 0;
|
|
34851
|
+
const asText2 = (value) => typeof value === "string" || typeof value === "number" ? String(value) : void 0;
|
|
34852
|
+
const code = asText2(data.code) ?? asText2(inner?.code);
|
|
34853
|
+
const msg = asText2(data.msg) ?? asText2(data.message) ?? asText2(inner?.msg) ?? asText2(inner?.message);
|
|
34854
|
+
const requestId = asText2(data.requestId) ?? asText2(inner?.requestId);
|
|
34855
|
+
const parts = [
|
|
34856
|
+
code === void 0 ? void 0 : `code ${code}`,
|
|
34857
|
+
msg === void 0 ? void 0 : `msg ${msg}`,
|
|
34858
|
+
requestId === void 0 ? void 0 : `requestId ${requestId}`
|
|
34859
|
+
].filter((value) => value !== void 0);
|
|
34860
|
+
if (parts.length > 0) return redactUpstreamActionHints(parts.join(" / "));
|
|
34861
|
+
} catch {
|
|
34862
|
+
}
|
|
34863
|
+
return redactUpstreamActionHints(errorDetail2(body).slice(0, 200));
|
|
34864
|
+
}
|
|
34865
|
+
function channelVerificationError(productId, status, body, rotated) {
|
|
34866
|
+
const scope = rotated ? `\u5168\u90E8\u8D26\u53F7\u5747\u672A\u901A\u8FC7\u6E20\u9053\u6821\u9A8C\uFF08HTTP ${status}\uFF0C\u5DF2\u9010\u4E2A\u6362\u53F7\u91CD\u8BD5\uFF09` : `\u5F53\u524D\u8D26\u53F7\u672A\u901A\u8FC7\u6E20\u9053\u6821\u9A8C\uFF08HTTP ${status}\uFF0C\u6D41\u5185\u9519\u8BEF\u5E27\u4E0B\u53D1\uFF09`;
|
|
34867
|
+
return new LlmError3(
|
|
34868
|
+
`${productId}: ${scope}\u3002\u8BE5\u62D2\u7EDD\u6309\u8D26\u53F7\u751F\u6548\uFF08\u540C\u4E00\u8BF7\u6C42\u5728\u5176\u4ED6\u8D26\u53F7\u53EF\u6B63\u5E38\u8FD4\u56DE\uFF09\uFF0C\u4E14\u91CD\u53D1\u65E0\u6548 \u2014\u2014 \u8BF7\u5728 Channel Pack \u505C\u7528\u6216\u8C03\u6574\u8BE5\u8D26\u53F7\u7684\u987A\u5E8F\u540E\u91CD\u8BD5\uFF0C\u6216\u6539\u7528\u5176\u5B83 provider\u3002\u4E0A\u6E38\uFF1A${channelVerificationUpstreamId(body)}`,
|
|
34869
|
+
"PERMISSION_DENIED",
|
|
34870
|
+
{ status }
|
|
34871
|
+
);
|
|
34872
|
+
}
|
|
34712
34873
|
function isContentRejection(body) {
|
|
34713
34874
|
if (body.length === 0) return false;
|
|
34875
|
+
if (isChannelVerificationBody(body)) return false;
|
|
34876
|
+
if (isContentBlockedIllegalBody(body)) return false;
|
|
34714
34877
|
return /"code"\s*:\s*11140/.test(body) || /request illegal/i.test(body) || /安全审核|safety review/i.test(body);
|
|
34715
34878
|
}
|
|
34716
34879
|
var BUDDY_POLICY_BLOCK_COOLDOWN_MS = 30 * 6e4;
|
|
@@ -35248,9 +35411,12 @@ var BuddyAdapter = class _BuddyAdapter extends LlmAdapter2 {
|
|
|
35248
35411
|
imageUrls.set(id, `data:${image.mediaType};base64,${Buffer.from(image.data).toString("base64")}`);
|
|
35249
35412
|
}
|
|
35250
35413
|
}
|
|
35251
|
-
const messages = serializeMessages2(options.messages, imageUrls);
|
|
35414
|
+
const messages = serializeMessages2(options.messages, imageUrls, this.product.id);
|
|
35252
35415
|
if (options.system !== void 0 && options.system.length > 0) {
|
|
35253
|
-
messages.unshift({
|
|
35416
|
+
messages.unshift({
|
|
35417
|
+
role: "system",
|
|
35418
|
+
content: rewriteTencentContentFingerprints(options.system, this.product.id)
|
|
35419
|
+
});
|
|
35254
35420
|
}
|
|
35255
35421
|
const tools = options.tools?.map((tool) => ({
|
|
35256
35422
|
type: "function",
|
|
@@ -35294,6 +35460,7 @@ var BuddyAdapter = class _BuddyAdapter extends LlmAdapter2 {
|
|
|
35294
35460
|
if (!response.ok && (response.status === 401 || response.status === 403)) {
|
|
35295
35461
|
const rejectedBody = await response.clone().text().catch(() => "");
|
|
35296
35462
|
const contentRejected = isContentRejection(rejectedBody);
|
|
35463
|
+
const channelRejected = isChannelVerificationRejection(rejectedBody, response.status);
|
|
35297
35464
|
if (contentRejected) {
|
|
35298
35465
|
console.warn(
|
|
35299
35466
|
`[${this.product.id}] \u8D26\u53F7 ${currentAccountId || "(current)"} \u88AB\u5B89\u5168\u7B56\u7565\u62E6\u622A\uFF08HTTP ${response.status}\uFF0Ccode 11140\uFF09\uFF0C\u7EE7\u7EED\u6362\u53F7\uFF1A${errorDetail2(rejectedBody).slice(0, 200)}`
|
|
@@ -35327,6 +35494,9 @@ var BuddyAdapter = class _BuddyAdapter extends LlmAdapter2 {
|
|
|
35327
35494
|
let sawContentRejection = contentRejected;
|
|
35328
35495
|
let rejectionStatus = contentRejected ? authStatus : 0;
|
|
35329
35496
|
let rejectionBody = contentRejected ? rejectedBody : "";
|
|
35497
|
+
let sawChannelVerification = channelRejected;
|
|
35498
|
+
let channelVerificationStatus = channelRejected ? authStatus : 0;
|
|
35499
|
+
let channelVerificationBody = channelRejected ? rejectedBody : "";
|
|
35330
35500
|
if ((response.status === 401 || response.status === 403) && this.options.accountPool !== void 0) {
|
|
35331
35501
|
for (; ; ) {
|
|
35332
35502
|
const next = await this.options.accountPool.getAvailableAccount(
|
|
@@ -35356,6 +35526,11 @@ var BuddyAdapter = class _BuddyAdapter extends LlmAdapter2 {
|
|
|
35356
35526
|
options.model
|
|
35357
35527
|
);
|
|
35358
35528
|
}
|
|
35529
|
+
if (isChannelVerificationRejection(rotatedBody, response.status)) {
|
|
35530
|
+
sawChannelVerification = true;
|
|
35531
|
+
channelVerificationStatus = response.status;
|
|
35532
|
+
channelVerificationBody = rotatedBody;
|
|
35533
|
+
}
|
|
35359
35534
|
if (response.status !== 401 && response.status !== 403) break;
|
|
35360
35535
|
}
|
|
35361
35536
|
}
|
|
@@ -35368,6 +35543,14 @@ var BuddyAdapter = class _BuddyAdapter extends LlmAdapter2 {
|
|
|
35368
35543
|
true
|
|
35369
35544
|
);
|
|
35370
35545
|
}
|
|
35546
|
+
if (sawChannelVerification) {
|
|
35547
|
+
throw channelVerificationError(
|
|
35548
|
+
this.product.id,
|
|
35549
|
+
channelVerificationStatus === 0 ? authStatus : channelVerificationStatus,
|
|
35550
|
+
channelVerificationBody.length === 0 ? rejectedBody : channelVerificationBody,
|
|
35551
|
+
true
|
|
35552
|
+
);
|
|
35553
|
+
}
|
|
35371
35554
|
throw new LlmError3(`${this.product.id}: credential expired and refresh failed`, "AUTH", { status: authStatus });
|
|
35372
35555
|
}
|
|
35373
35556
|
if (response.status === 401 || response.status === 403) {
|
|
@@ -35380,6 +35563,14 @@ var BuddyAdapter = class _BuddyAdapter extends LlmAdapter2 {
|
|
|
35380
35563
|
true
|
|
35381
35564
|
);
|
|
35382
35565
|
}
|
|
35566
|
+
if (sawChannelVerification || isChannelVerificationRejection(detail, authStatus)) {
|
|
35567
|
+
throw channelVerificationError(
|
|
35568
|
+
this.product.id,
|
|
35569
|
+
channelVerificationStatus === 0 ? authStatus : channelVerificationStatus,
|
|
35570
|
+
channelVerificationBody.length === 0 ? detail : channelVerificationBody,
|
|
35571
|
+
true
|
|
35572
|
+
);
|
|
35573
|
+
}
|
|
35383
35574
|
throw new LlmError3(
|
|
35384
35575
|
`${this.product.id}: \u6240\u6709\u8D26\u53F7\u5747\u88AB\u62D2\u7EDD\uFF08HTTP ${authStatus}${authStatus === 401 ? "\uFF0C\u8BF7\u5728 Channel Pack \u91CD\u65B0\u767B\u5F55" : ""}\uFF09\uFF1A${errorDetail2(detail)}`,
|
|
35385
35576
|
httpErrorCode2(authStatus, detail),
|
|
@@ -35412,12 +35603,16 @@ var BuddyAdapter = class _BuddyAdapter extends LlmAdapter2 {
|
|
|
35412
35603
|
);
|
|
35413
35604
|
}
|
|
35414
35605
|
}
|
|
35415
|
-
|
|
35606
|
+
const channelRejected = isChannelVerificationRejection(errorText, response.status);
|
|
35607
|
+
if (this.options.accountPool && (isRateLimited(errorText, response.status) || channelRejected)) {
|
|
35416
35608
|
const tried = /* @__PURE__ */ new Set();
|
|
35417
35609
|
if (currentAccountId) tried.add(currentAccountId);
|
|
35418
35610
|
let sawContentRejection = false;
|
|
35419
35611
|
let contentRejectionStatus = 0;
|
|
35420
35612
|
let contentRejectionBody = "";
|
|
35613
|
+
let sawChannelVerification = channelRejected;
|
|
35614
|
+
let channelVerificationStatus = channelRejected ? response.status : 0;
|
|
35615
|
+
let channelVerificationBody = channelRejected ? errorText : "";
|
|
35421
35616
|
const rateLimitMarked = /* @__PURE__ */ new Set();
|
|
35422
35617
|
for (; ; ) {
|
|
35423
35618
|
if (currentAccountId !== "" && isRateLimited(errorText, response.status) && !rateLimitMarked.has(currentAccountId)) {
|
|
@@ -35459,6 +35654,15 @@ var BuddyAdapter = class _BuddyAdapter extends LlmAdapter2 {
|
|
|
35459
35654
|
);
|
|
35460
35655
|
continue;
|
|
35461
35656
|
}
|
|
35657
|
+
if (isChannelVerificationRejection(errorText, response.status)) {
|
|
35658
|
+
sawChannelVerification = true;
|
|
35659
|
+
channelVerificationStatus = response.status;
|
|
35660
|
+
channelVerificationBody = errorText;
|
|
35661
|
+
console.warn(
|
|
35662
|
+
`[${this.product.id}] \u8D26\u53F7 ${currentAccountId || "(current)"} \u672A\u901A\u8FC7\u6E20\u9053\u6821\u9A8C\uFF08HTTP ${response.status}\uFF0Ccode 11128\uFF09\uFF0C\u7EE7\u7EED\u6362\u53F7\uFF08\u4E0D\u5199\u51B7\u5374\uFF09\uFF1A${errorDetail2(errorText).slice(0, 200)}`
|
|
35663
|
+
);
|
|
35664
|
+
continue;
|
|
35665
|
+
}
|
|
35462
35666
|
if (response.status === 401 || response.status === 403) continue;
|
|
35463
35667
|
if (!isRateLimited(errorText, response.status)) {
|
|
35464
35668
|
throw new LlmError3(`${this.product.id}: ${errorDetail2(errorText)}`, httpErrorCode2(response.status, errorText), { status: response.status });
|
|
@@ -35472,6 +35676,14 @@ var BuddyAdapter = class _BuddyAdapter extends LlmAdapter2 {
|
|
|
35472
35676
|
true
|
|
35473
35677
|
);
|
|
35474
35678
|
}
|
|
35679
|
+
if (sawChannelVerification) {
|
|
35680
|
+
throw channelVerificationError(
|
|
35681
|
+
this.product.id,
|
|
35682
|
+
channelVerificationStatus || 400,
|
|
35683
|
+
channelVerificationBody,
|
|
35684
|
+
true
|
|
35685
|
+
);
|
|
35686
|
+
}
|
|
35475
35687
|
throw new LlmError3(`${this.product.id}: \u6A21\u578B ${options.model} \u6240\u6709\u8D26\u53F7\u5747\u53D7\u9650\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5`, "QUOTA_EXCEEDED");
|
|
35476
35688
|
}
|
|
35477
35689
|
throw new LlmError3(`${this.product.id}: ${errorDetail2(errorText)}`, httpErrorCode2(response.status, errorText), { status: response.status });
|
|
@@ -35487,6 +35699,10 @@ var BuddyAdapter = class _BuddyAdapter extends LlmAdapter2 {
|
|
|
35487
35699
|
headers.set(HTTP_HEADER_DOMAIN, this.product.apiDomain || credential.domain || "");
|
|
35488
35700
|
headers.set(HTTP_HEADER_PRODUCT_CODE, this.product.productCode);
|
|
35489
35701
|
headers.set("X-Agent-Purpose", "conversation");
|
|
35702
|
+
const conversationId = crypto.randomUUID().replace(/-/g, "");
|
|
35703
|
+
headers.set("X-Conversation-ID", conversationId);
|
|
35704
|
+
headers.set("X-Conversation-Request-ID", conversationId);
|
|
35705
|
+
headers.set("X-Conversation-Message-ID", conversationId);
|
|
35490
35706
|
headers.set("X-IDE-Name", this.product.attributionName);
|
|
35491
35707
|
headers.set("X-IDE-Type", this.product.attributionName);
|
|
35492
35708
|
headers.set("X-IDE-Version", this.product.clientVersion);
|
|
@@ -35568,6 +35784,9 @@ var BuddyAdapter = class _BuddyAdapter extends LlmAdapter2 {
|
|
|
35568
35784
|
} catch {
|
|
35569
35785
|
continue;
|
|
35570
35786
|
}
|
|
35787
|
+
if (data.choices === void 0 && isChannelVerificationRejection(payload, response.status)) {
|
|
35788
|
+
throw channelVerificationError(this.product.id, 200, payload, false);
|
|
35789
|
+
}
|
|
35571
35790
|
if (data.choices === void 0 && isContentRejection(payload)) {
|
|
35572
35791
|
await markPolicyBlockedAccount(
|
|
35573
35792
|
this.options.accountPool,
|
|
@@ -56300,12 +56519,12 @@ var OFFICEACE = {
|
|
|
56300
56519
|
chunkTimeoutMs: 3e5
|
|
56301
56520
|
};
|
|
56302
56521
|
var OFFICEACE_MODELS = [
|
|
56303
|
-
{ id: "glm-5.3", name: "GLM-5.3", contextWindow:
|
|
56304
|
-
{ id: "glm-5.2", name: "GLM-5.2", contextWindow:
|
|
56305
|
-
{ id: "glm-5.1", name: "GLM-5.1", contextWindow:
|
|
56306
|
-
{ id: "deepseek-v4.1-flash", name: "DeepSeek-V4.1-Flash", contextWindow:
|
|
56307
|
-
{ id: "deepseek-v4-flash", name: "DeepSeek-V4-Flash", contextWindow:
|
|
56308
|
-
{ id: "kimi-k2.6", name: "Kimi-K2.6", contextWindow:
|
|
56522
|
+
{ id: "glm-5.3", name: "GLM-5.3", contextWindow: 1048576, maxTokens: 131072 },
|
|
56523
|
+
{ id: "glm-5.2", name: "GLM-5.2", contextWindow: 1044480, maxTokens: 131072 },
|
|
56524
|
+
{ id: "glm-5.1", name: "GLM-5.1", contextWindow: 196608, maxTokens: 131072 },
|
|
56525
|
+
{ id: "deepseek-v4.1-flash", name: "DeepSeek-V4.1-Flash", contextWindow: 1048576, maxTokens: 393216, multimodal: true },
|
|
56526
|
+
{ id: "deepseek-v4-flash", name: "DeepSeek-V4-Flash", contextWindow: 1044480, maxTokens: 393216 },
|
|
56527
|
+
{ id: "kimi-k2.6", name: "Kimi-K2.6", contextWindow: 262144, maxTokens: 131072, multimodal: true },
|
|
56309
56528
|
{ id: "qwen3-32b", name: "Qwen3-32B", contextWindow: 131072, maxTokens: 65536 },
|
|
56310
56529
|
{ id: "qwen3-30b-a3b", name: "Qwen3-30B-A3B", contextWindow: 131072, maxTokens: 65536 }
|
|
56311
56530
|
];
|
|
@@ -63340,39 +63559,6 @@ async function toImageBlock2(url, bridge, limits, already) {
|
|
|
63340
63559
|
return { type: "image", attachment: ref };
|
|
63341
63560
|
}
|
|
63342
63561
|
|
|
63343
|
-
// vendor/channel-pack/src/openai-gateway/tencent-fingerprint.ts
|
|
63344
|
-
var TENCENT_PROVIDERS = ["buddy", "workbuddy"];
|
|
63345
|
-
var CONTENT_FINGERPRINTS = [
|
|
63346
|
-
{
|
|
63347
|
-
// ZCode 内建常量:`$Js="Main branch (you will usually use this for PRs)"`。
|
|
63348
|
-
// 每个 git 仓库里的会话都会被注入(拼在 `Main branch … : <分支名>` 这一行)。
|
|
63349
|
-
find: "Main branch (you will usually use this for PRs)",
|
|
63350
|
-
replace: "Main branch (PRs usually go here)",
|
|
63351
|
-
note: "Gitee IKJNA1\uFF1B\u672C\u673A 2026-10-05 \u5BF9 workbuddy / CodeBuddy \u53CC\u7AEF\u70B9\u5B9E\u6D4B\u590D\u73B0"
|
|
63352
|
-
}
|
|
63353
|
-
];
|
|
63354
|
-
function escapeRegExp(literal) {
|
|
63355
|
-
return literal.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
63356
|
-
}
|
|
63357
|
-
var COMPILED = CONTENT_FINGERPRINTS.map((rule) => ({
|
|
63358
|
-
replace: rule.replace,
|
|
63359
|
-
findLower: rule.find.toLowerCase(),
|
|
63360
|
-
// `g` = 全部出现都改写;`i` = 大小写不敏感(实测全小写 / 全大写同样被拦)。
|
|
63361
|
-
pattern: new RegExp(escapeRegExp(rule.find), "gi")
|
|
63362
|
-
}));
|
|
63363
|
-
function isTencentContentFingerprintProvider(provider) {
|
|
63364
|
-
return TENCENT_PROVIDERS.includes(provider);
|
|
63365
|
-
}
|
|
63366
|
-
function rewriteTencentContentFingerprints(text, provider) {
|
|
63367
|
-
if (!isTencentContentFingerprintProvider(provider)) return text;
|
|
63368
|
-
let out = text;
|
|
63369
|
-
for (const rule of COMPILED) {
|
|
63370
|
-
if (!out.toLowerCase().includes(rule.findLower)) continue;
|
|
63371
|
-
out = out.replace(rule.pattern, rule.replace);
|
|
63372
|
-
}
|
|
63373
|
-
return out;
|
|
63374
|
-
}
|
|
63375
|
-
|
|
63376
63562
|
// vendor/channel-pack/src/openai-gateway/messages.ts
|
|
63377
63563
|
var OpenAiGatewayError = class extends Error {
|
|
63378
63564
|
constructor(message2, status = 400, type = "invalid_request_error", code = "invalid_request") {
|
|
@@ -63514,7 +63700,7 @@ async function convertMessage(raw, provider, model, bridge, limits) {
|
|
|
63514
63700
|
return createGatewayMessage("user", await partsFromContent(value.content, bridge, limits), { kind: "user" });
|
|
63515
63701
|
}
|
|
63516
63702
|
if (role === "assistant") {
|
|
63517
|
-
const text = textFromContent(value.content);
|
|
63703
|
+
const text = rewriteTencentContentFingerprints(textFromContent(value.content), provider);
|
|
63518
63704
|
const content = text.length > 0 ? [{ type: "text", text }] : [];
|
|
63519
63705
|
if (value.tool_calls !== void 0) content.push(...convertToolCalls(value.tool_calls));
|
|
63520
63706
|
return createGatewayMessage("assistant", content, { kind: "model", provider, model });
|
|
@@ -64064,7 +64250,7 @@ async function toMessages(input, provider, model, bridge, limits) {
|
|
|
64064
64250
|
continue;
|
|
64065
64251
|
}
|
|
64066
64252
|
if (raw.role === "assistant") {
|
|
64067
|
-
const text = textFromContent(content);
|
|
64253
|
+
const text = rewriteTencentContentFingerprints(textFromContent(content), provider);
|
|
64068
64254
|
pushAssistant(text.length > 0 ? [{ type: "text", text }] : []);
|
|
64069
64255
|
continue;
|
|
64070
64256
|
}
|