dsh-connect-workbuddy 5.24.13 → 5.24.15

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/CHANGELOG.md CHANGED
@@ -1,5 +1,95 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.24.15 (2026-11-18)
4
+
5
+ > 版本号是 **patch**:两处改动——`package.json` 的一处 peer 元数据声明(#277),以及把
6
+ > `stableConversationId` 的默认值从 `false` 翻成 `true`(#275,会改变出站的一个头)。
7
+ > 池子选号、账号身份、开关语义一律未动。来自 issue #277 与 #275。
8
+
9
+ ### 改进:稳定会话键(路线 A)默认开启,提升前缀缓存复用
10
+
11
+ `stableConversationId` 自 5.24.15 起默认 `true`:默认路径从请求体**不变前缀**(model +
12
+ 首条 system + 第一条真实 user)派生 `X-Conversation-ID` 亲和键,让同一段对话复用上游隐式
13
+ 前缀缓存;`X-Conversation-Request-ID` / `X-Conversation-Message-ID` / `X-Root-Request-ID`
14
+ 仍每请求现生成。设为 `false` 即回到「每请求现生成三件套」的原形状。
15
+
16
+ 默认值从 `false` 翻到 `true` 依据 #275 的完整证据链:冻结单变量实验(20 组冷前缀,
17
+ `BENEFIT_SUPPORTED`),维护者本人在全新 checkout 上的独立复现(`MEAN_D 87.1pp
18
+ [81.9, 92.0]`,240/240 完整,与此前报告者读数同向、CI 重叠),加上真实多轮稳态 80–90%
19
+ 的观察。这是**独立决策**,不是实验成功的自动结果。
20
+
21
+ **边界(如实说明)**:`87.1pp` 来自逐字节固定的人工长前缀逐轮重发,不等于真实多轮收益;
22
+ `MECHANISM_PROVEN=false`,区分不了缓存键分区与路由亲和,不外推到其它账号 / 模型 / 端点。
23
+ 该值是前缀派生亲和键、不是宿主会话标识,相同前缀的独立会话会共享同一个键。开关在插件
24
+ 挂载时采样一次,改动后需重载插件才生效。路线 B(`sessionConversationId`)仍默认关闭。
25
+ 语义与限制见 `docs/STABLE-KEY-SEMANTICS.md`。
26
+
27
+ ### 改进:把 `react` 标成可选 peer,允许在 DSH Go(鸿蒙 / iOS)上安装
28
+
29
+ 此前 `peerDependencies.react` 是 `^18.2.0`,但 `peerDependenciesMeta` 只把
30
+ `@earendil-works/pi-ai` 标成了 optional。DSH Go 的鸿蒙 / iOS 安装器共用同一份依赖图
31
+ 解析器(`resolveGraph`),对每个 peer 只接受两种落点:命中宿主包表,或
32
+ `peerDependenciesMeta[name].optional === true`。`react` 两者都不占,于是在解析阶段直接报
33
+ `ERR_OHOS_PLUGIN_PACKAGE: unsupported non-host peer react`——尚未下载、未写 profile。
34
+
35
+ 本插件的 `lib/client.js` 确实 require `react` / `react/jsx-runtime` / `react-dom`,但这些前端库
36
+ 由宿主 Web 运行时的 `window.__ModuleLoader__` 注入,不来自 node_modules;`lib/index.js` 与
37
+ `lib/bin.js` 对 React 零引用。因此把 `react` 标成 optional 只移除安装期的硬校验,不改变运行时
38
+ 行为:一旦环境提供 react,仍须满足 `^18.2.0` 的版本约束。
39
+
40
+ **证据边界(如实说明)**:iOS 侧有实测——runtime 压缩包内无 react / react-dom 的 package.json,
41
+ 而 runtime 自带 client 包在同一注入机制下 require React 能正常运行;鸿蒙侧尚无真机 / 模拟器
42
+ 实测,安装包解析通过后 client 能否加载取决于宿主 WebView 是否同样注入 React。本次只解决
43
+ 「装不上」,不代表已验证鸿蒙端运行。
44
+
45
+ ## 5.24.14 (2026-11-17)
46
+
47
+ > 版本号是 **patch**:只在工具 schema 的发送前改写链里增加一种形状,默认行为、出站字节、
48
+ > 既有开关与池子排序一律未动;无破坏性改动。来自 issue #274。
49
+
50
+ ### 修复:启用 REA MCP 后的 400 / 11129——`pattern` 里的 UTF-16 代理区转义
51
+
52
+ 报告者开启 REA MCP server 后,在 `deepseek-v4.1-flash` 上发任意消息都稳定得到
53
+ `400 / code 11129`,关掉该 server、保留其它能力后同一句话立刻通过。他按插件报错提示
54
+ 做了对照,并把 REA 导出的**全部 260 个工具**的 `inputSchema` 原样贴出——这是定位的关键。
55
+
56
+ 与 issue #253 的第二次报告一样,这些 schema 对插件已覆盖的每一种改写都是干净的:把它们
57
+ 逐字节送过 `prepareChatBody`,**260 个全部原样输出**,没有任何一处命中五类 draft-4 遗留
58
+ 写法或关键字值类型错误。所以被拒的是一种此前没人查过的形状:
59
+
60
+ ```
61
+ "allOf": [{ "pattern": "^[^\\uD800-\\uDFFF]*$" }]
62
+ ```
63
+
64
+ REA 用这条正则禁止文件系统路径里出现 UTF-16 代理码元。上游的 schema 解析器读不了
65
+ `\uXXXX` 形式的**代理区转义**,于是整个工具定义被拒。逐条真实实测(`deepseek-v4.1-flash`,
66
+ CN 网关,每次只改一处)确认:
67
+
68
+ - 带这条转义的两个工具(`close_binary`、`binary_session`)单独发就是 11129,另三个暴露的
69
+ 工具单独发都是 200;
70
+ - 只删掉那个 `allOf` 成员即通过,改删 NUL / 斜杠两个成员则仍 11129——是这条转义,不是
71
+ `allOf` 或字符类本身;
72
+ - 边界精确:`\uD7FF` 与 `\uE000` 通过,D800–DFFF 区间内每个转义都 11129(十六进制大小写
73
+ 不敏感);
74
+ - 拒绝**只针对 `pattern`**:同样的字面量放进 `description` / `title` / `const` / `enum` /
75
+ `default` / `format` 都是 200;
76
+ - 其它转义都通过:`\u0000`–`\uFFFF`、`\x00`、`\d`、ASCII 十六进制区间,乃至真实 emoji
77
+ (JSON 里的真代理对)。被拒的只是代理码元的 `\uXXXX` **写法**。
78
+
79
+ 改法是发送前改写链里加一条:`pattern` 字符串若含 `\uD800`–`\uDFFF` 的转义(大小写不敏感),
80
+ 就删掉这个 `pattern`。它与 #253 的既有规则同源——只动上游读不了的值、保留工具可用性、
81
+ 不猜写一个等价字符类、正确 schema 保持字节不变(缓存前缀稳定)。这条 `pattern` 是展示层的
82
+ 注解约束,REA 服务端仍对完整规范输入做校验,删掉它不会让非法路径真正通过。
83
+
84
+ 守护测试在 `tests/issue274-pattern-surrogate-escape.spec.ts`:正例(各类代理转义被删、递归
85
+ 到任意深度)与反例(边界外转义、其它关键字里的同款字面量、真实 emoji 一律不动)共 10 项。
86
+ 双向变异验证都做实:关掉修复 → 5 项正例变红;把匹配放宽到任意 `pattern` → 4 项反例变红。
87
+ 端到端复核:用**本报告原始 schema**、经真实 `prepareChatBody`(未手工修补)发送,精简 5 工具
88
+ 与完整 255 工具目录均从 11129 变为 **200 OK**,且只有那两个工具的输出发生变化。
89
+
90
+ 报错文案 `toolSchemaRejectAdvice()` 同步列入这条新改写,避免读者看到存活的 11129 时被
91
+ 告知插件只试过旧形状——那是 #253 留下过一次的「自信但错」的答复。
92
+
3
93
  ## 5.24.13 (2026-11-17)
4
94
 
5
95
  > 版本号是 **patch**:只改一处显示名回退顺序与一句错误文案;默认行为、出站字节、
@@ -14,7 +14,7 @@
14
14
  会话时,稳定它是否与更高命中相关。** 本文与实现都不对"上游究竟如何分区缓存"
15
15
  作任何断言(`MECHANISM_PROVEN = false`)。
16
16
 
17
- 路线 B 与路线 A **相互独立**,默认都关闭。两者同时打开时,路线 B 优先。
17
+ 路线 B 与路线 A **相互独立**:路线 B 默认关闭,路线 A(`stableConversationId`)自 5.24.15 起默认开启。两者同时打开时,路线 B 优先。
18
18
 
19
19
  ## 2. 会话 ID 如何到达上游(且真值不外发)
20
20
 
@@ -72,4 +72,4 @@
72
72
  | 换键条件 | 压缩 / 首问 / 换模型 / 分叉 | 换会话 |
73
73
  | 稳定性 | 挂载时采样配置 | 每请求 live getter |
74
74
  | 真值外发 | 无(只有前缀摘要) | 无(只有 sessionId 摘要) |
75
- | 默认 | 关 | 关 |
75
+ | 默认 | 开(5.24.15 起) | 关 |
@@ -1,6 +1,7 @@
1
1
  # 稳定 `X-Conversation-ID` 的语义:路线 A(请求前缀派生的亲和键实验)
2
2
 
3
- > 适用对象:`stableConversationId`(默认 `false`)开启后由 `deriveStableConversationId(bodyJson)` 生成的值。
3
+ > 适用对象:`stableConversationId` 开启后由 `deriveStableConversationId(bodyJson)` 生成的值。
4
+ > 该开关自 **5.24.15 起默认 `true`**(#275:冻结单变量实验 + 维护者独立复现后翻默认);设为 `false` 恢复每请求现生成的原形状。
4
5
  > 本文件是该开关语义的**唯一权威定义**;`CHANGELOG.md` / `docs/DESIGN.md` / 实现注释均须与之一致。
5
6
  > 本文不写任何真实账号、机器、路径值;账号一律称「账号A / 账号别名」,本机路径一律 `/Users/<you>`。
6
7
 
@@ -11,7 +12,7 @@
11
12
  - 它**不是**宿主 `sessionId`,**不是**官方会话标识,**不是**真正的会话稳定键。
12
13
  - 它只是一个由请求内容决定的、在一次连续对话中尽量不变的请求头取值,目的是让「同一不变前缀 + 同一 `X-Conversation-ID`」这一组合可复现,便于单变量对照。
13
14
  - 上游内部究竟是「按缓存键分区」「按路由亲和」还是二者混合,本文件及所有相关文档**不做机制断言**;本 PR 也不声称稳定 ID 能改善命中,改善与否须由使用者自行在指定构建/账号/模型/时间窗口下验证。
14
- - 默认 `stableConversationId` 为 `false`。**默认 `false` 不因任何实验成功自动改变;推广默认值属于单独决策。**
15
+ - 该开关最初以默认 `false` 落地,作为受控对照的可选能力;**默认值的推广属于单独决策**。5.24.15 依据 #275 的冻结单变量实验与维护者独立复现(87.1pp [81.9, 92.0],BENEFIT_SUPPORTED)翻为默认 `true`。
15
16
 
16
17
  路线 B(真正的会话稳定且互斥隔离,需要可信的宿主会话标识,例如由 DSH 透传 `sessionId`)能做到「整段会话稳定 + 不同会话之间互斥隔离」,但超出本次最小范围:**本次不采用,需另行设计并提交用户确认**。
17
18
 
@@ -34,23 +35,23 @@
34
35
  - **NUL 歧义已修**:元组使用**无歧义编码**(JSON 数组),不同元组不会因为字段内出现 NUL 字符(U+0000)或简单拼接而产生相同输入。即三元组(a、b、c)与把 a、b 用 NUL 拼成一个字段的二元组之类不会碰撞。
35
36
  - **多模态**:首问含非文本 part(如图片、tool 结果)时,按**规范化完整内容**编码,而不是只取文本片段;**纯图片首问**显式处理——不再隐式忽略非文本 part、不再静默回落到随机 ID。若规范化后仍无法派生(缺字段 / 无法解析),则**显式回退**到每请求现生成,并把该回退路径记入本文件与实现注释。
36
37
 
37
- ## 4. 默认关闭与默认值纪律
38
+ ## 4. 默认值与默认值纪律
38
39
 
39
- - `stableConversationId` 默认 `false`:默认路径每请求现生成三件套,相对基线 commit `d03282f` 默认路径请求构造逻辑不变(随机 ID 逐次不同;仅相对该基线描述,不覆盖更早版本)。
40
- - 开启只影响 `X-Conversation-ID`;`X-Conversation-Request-ID` / `X-Conversation-Message-ID` / `X-Root-Request-ID` 仍每请求现生成。
40
+ - `stableConversationId` 自 5.24.15 起默认 `true`:默认路径从请求体不变前缀派生 `X-Conversation-ID`,以复用上游前缀缓存。设为 `false` 则回到「每请求现生成三件套」的原形状,相对基线 commit `d03282f` 的默认路径请求构造逻辑不变(随机 ID 逐次不同;仅相对该基线描述,不覆盖更早版本)。
41
+ - 开关只影响 `X-Conversation-ID`;`X-Conversation-Request-ID` / `X-Conversation-Message-ID` / `X-Root-Request-ID` 始终每请求现生成。
41
42
  - 配置在插件挂载时采样一次,改动后需重载插件才生效。
42
- - **默认 `false` 不因任何实验成功自动改变;推广默认值属于单独决策。**
43
- - 本 PR 只落地「默认关闭的可选开关 + 派生函数 + 离线 wire 级单测」,**不包含**真实上游实验、安装/重载完整链路验证或 GA 结论;这些属于后续单独工作。
43
+ - **默认值不是实验成功的自动结果,而是单独决策**:最初落地为 `false`,5.24.15 经 #275 的独立复现后才翻为 `true`。该决策的证据边界见第 5 节,不外推、不作机制断言。
44
+ - 最初的 PR 只落地「可选开关 + 派生函数 + 离线 wire 级单测」,真实上游实验、安装/重载完整链路验证经由 #275 的冻结实验与维护者独立复现补齐。
44
45
 
45
46
  ## 5. 结论措辞纪律
46
47
 
47
- 本开关是实验性、默认关闭的可选能力,相关叙述一律采用**限定措辞**,不得升级为机制证明或因果宣称:
48
+ 本开关源自实验、现已默认开启,但相关叙述一律采用**限定措辞**,不得升级为机制证明或因果宣称:
48
49
 
49
50
  > 在指定构建、账号别名、模型和时间窗口下,观察到稳定 `X-Conversation-ID` 与更高的隐式前缀缓存命中相关。该观察不能区分缓存键分区与路由亲和等内部机制,也不能外推到所有账号/模型;它不构成稳定 ID「导致」命中提升的证明。
50
51
 
51
52
  以下类别的过强表述一律不得作为结论出现:对 warm 轮命中作确定性宣称、把内部机制当作已证明、把本键描述为等价于宿主会话标识、对会话之间的隔离性或互斥性作肯定宣称、对全部历史版本声称字节级一致、声称控制组排除了全部混淆、把工具输出状态词当作实验证实。
52
53
 
53
- 本 PR 不附带任何命中率实测数字;若使用者自行验证,须自行记录条件、限定范围并避免上述过强表述。
54
+ 最初落地的 PR 不附带任何命中率实测数字;#275 的冻结实验与维护者独立复现提供了受控读数(见该 issue),但其口径仍是人工长前缀逐轮重发、**不等于真实多轮收益**。若使用者自行验证,须自行记录条件、限定范围并避免上述过强表述。
54
55
 
55
56
  ## 6. 术语对照
56
57
 
package/lib/bin.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { F as WorkBuddyCredentialStore, J as workbuddyOwnAuthPath, N as WORKBUDDY_AUTH_FILE_ENV, Nn as hostPeersInfo, P as WORKBUDDY_VAULT_DIRNAME, Pn as resolveDshHome, R as defaultDesktopAuthCandidates, T as FALLBACK_WORKBUDDY_MODELS_GLOBAL, Tn as findWorkbuddyAppExecutableWithSource, W as legacyWorkbuddyOwnAuthPath, X as APP_VERSION, Y as workbuddyVaultDir, _n as inspectCredentialDirectory, a as readHostHeartbeat, b as readDeviceSettings, c as WORKBUDDY_CONNECT_VERSION, d as rosterSeenPath, dn as WORKBUDDY_DEVICE_TOKEN_FILE_ENV, et as DEFAULT_WIRE_PROFILE, f as WORKBUDDY_CN_BASE_ENV, fn as readDeviceTokenFile, g as createTuringSdk, hn as deriveDeviceId, lt as describeRequestHeaderNames, m as piAiRuntimeInfo, mn as readDeviceSalt, o as workbuddyHostHeartbeatPath, p as resolveCnGateway, pn as ensureDeviceSalt, r as isHeartbeatProcessAlive, rt as WorkBuddyUpstreamClient, u as describeRosterSeenPayload, vn as protectCredentialDirectory, w as FALLBACK_WORKBUDDY_MODELS, yn as WORKBUDDY_APP_EXECUTABLE_ENV, z as defaultDesktopAuthDirs } from "./host-heartbeat-Dlyz9ZUB.js";
2
+ import { F as WorkBuddyCredentialStore, J as workbuddyOwnAuthPath, N as WORKBUDDY_AUTH_FILE_ENV, Nn as hostPeersInfo, P as WORKBUDDY_VAULT_DIRNAME, Pn as resolveDshHome, R as defaultDesktopAuthCandidates, T as FALLBACK_WORKBUDDY_MODELS_GLOBAL, Tn as findWorkbuddyAppExecutableWithSource, W as legacyWorkbuddyOwnAuthPath, X as APP_VERSION, Y as workbuddyVaultDir, _n as inspectCredentialDirectory, a as readHostHeartbeat, b as readDeviceSettings, c as WORKBUDDY_CONNECT_VERSION, d as rosterSeenPath, dn as WORKBUDDY_DEVICE_TOKEN_FILE_ENV, et as DEFAULT_WIRE_PROFILE, f as WORKBUDDY_CN_BASE_ENV, fn as readDeviceTokenFile, g as createTuringSdk, hn as deriveDeviceId, lt as describeRequestHeaderNames, m as piAiRuntimeInfo, mn as readDeviceSalt, o as workbuddyHostHeartbeatPath, p as resolveCnGateway, pn as ensureDeviceSalt, r as isHeartbeatProcessAlive, rt as WorkBuddyUpstreamClient, u as describeRosterSeenPayload, vn as protectCredentialDirectory, w as FALLBACK_WORKBUDDY_MODELS, yn as WORKBUDDY_APP_EXECUTABLE_ENV, z as defaultDesktopAuthDirs } from "./host-heartbeat-BqK7yBp2.js";
3
3
  import { readFile } from "node:fs/promises";
4
4
  import { dirname, join } from "node:path";
5
5
  import { realpathSync } from "node:fs";
@@ -3944,7 +3944,7 @@ function isToolSchemaRejectBody(body) {
3944
3944
  * function exists to replace. When `normalizeMetaSchemaTypes` learns a new
3945
3945
  * family, this string has to learn it too.
3946
3946
  */
3947
- const TOOL_SCHEMA_REWRITTEN_KEYWORDS = "元组式 `items`、布尔 `exclusiveMinimum`/`exclusiveMaximum`、`required` 非数组或含重复项、外部 `$ref`,以及关键字的值类型写错(如 `title: 1`、`minimum: \"0\"`、`allOf: {}`、`type: []`、`enum`/`examples` 写成标量)";
3947
+ const TOOL_SCHEMA_REWRITTEN_KEYWORDS = "元组式 `items`、布尔 `exclusiveMinimum`/`exclusiveMaximum`、`required` 非数组或含重复项、外部 `$ref`,以及关键字的值类型写错(如 `title: 1`、`minimum: \"0\"`、`allOf: {}`、`type: []`、`enum`/`examples` 写成标量),以及 `pattern` 里的 UTF-16 代理区转义 `\\uD800`–`\\uDFFF`";
3948
3948
  /**
3949
3949
  * One actionable sentence for a `11129` refusal, naming what was already fixed
3950
3950
  * and what the user can still do.
@@ -4447,19 +4447,18 @@ function commonHeaders(credential, identity = {}) {
4447
4447
  * VALUES. The gateway does not verify where these ids come from — any well-formed
4448
4448
  * UUID passes — so nothing here is a secret and nothing is persisted.
4449
4449
  *
4450
- * DEFAULT: `X-Conversation-ID` is freshly generated per request, like the other
4451
- * two ids. That is the shape the gate was bisected with and the shape the tests
4452
- * below pin; it is also the shape the plugin has always sent on this path. There
4453
- * is an OPT-IN A/B mode (`stableConversationId`, see
4454
- * {@link deriveStableConversationId}) that instead pins a v4-SHAPED value derived
4455
- * from the request's stable prefix — a prefix-derived AFFINITY KEY, not a host
4456
- * session id. Only `X-Conversation-ID` is pinned: the request, message and root
4457
- * ids stay per-request. This switch exists for an offline single-variable hit-rate
4458
- * comparison; it makes NO claim about how the upstream keys or partitions any
4459
- * cache, and it does not prove that stable ids improve anything. The mode is OFF
4460
- * by default — enabling it changes a byte the gateway sees, and a hypothesis is
4461
- * not a reason to change the default shape for every account before it has been
4462
- * measured. See docs/STABLE-KEY-SEMANTICS.md.
4450
+ * DEFAULT (since 5.24.15): `X-Conversation-ID` is pinned to a v4-SHAPED value
4451
+ * derived from the request's stable prefix — a prefix-derived AFFINITY KEY, not a
4452
+ * host session id (see {@link deriveStableConversationId}). Only `X-Conversation-ID`
4453
+ * is pinned: the request, message and root ids stay fresh per request. This was
4454
+ * promoted from an opt-in A/B mode after #275's frozen single-variable experiment
4455
+ * plus the maintainer's independent replication (87.1pp [81.9, 92.0],
4456
+ * BENEFIT_SUPPORTED); before 5.24.15 every id was freshly generated per request.
4457
+ * Setting `stableConversationId: false` restores that original shape, which is
4458
+ * also what the per-request tests below pin. No claim is made about how the
4459
+ * upstream keys or partitions any cache — cache-key partitioning vs routing
4460
+ * affinity are indistinguishable from the client side. See
4461
+ * docs/STABLE-KEY-SEMANTICS.md.
4463
4462
  *
4464
4463
  * APPLIED TO BOTH REGIONS on purpose. The CN gateway tolerates their absence
4465
4464
  * today, so this is harmless there — and a header that is only ever sent on one
@@ -4570,7 +4569,7 @@ function canonicalContentKey(content, stripAcp) {
4570
4569
  /**
4571
4570
  * Derive a request-prefix AFFINITY KEY and return it in `X-Conversation-ID` shape.
4572
4571
  *
4573
- * ROUTE A / OPT-IN EXPERIMENT (`stableConversationId`, default off). This is a
4572
+ * ROUTE A (`stableConversationId`, default on since 5.24.15). This is a
4574
4573
  * prefix-derived affinity key, not a host session id: the value hashes the model
4575
4574
  * id, the first `system` message's FULL content and the FIRST REAL `user`
4576
4575
  * message's FULL content (skipping the harness's injected context blocks via
@@ -6023,6 +6022,7 @@ function normalizeToolChoice(obj) {
6023
6022
  * | `required` as a STRING instead of an array | 11129 | one-element array |
6024
6023
  * | `required` containing DUPLICATES | 11129 | de-duplicated |
6025
6024
  * | an EXTERNAL `$ref` (`https://…`, `//host/…`) | 11129 | the reference object removed |
6025
+ * | a `pattern` with a `\uD800`–`\uDFFF` surrogate escape (issue #274) | 11129 | the offending `pattern` dropped |
6026
6026
  *
6027
6027
  * WHAT IS DELIBERATELY NOT TOUCHED.
6028
6028
  *
@@ -6080,6 +6080,7 @@ function normalizeSchemaNode(node, depth = 0) {
6080
6080
  normalizeRequired(schema);
6081
6081
  dropExternalRef(schema);
6082
6082
  normalizeMetaSchemaTypes(schema);
6083
+ normalizePatternSurrogates(schema);
6083
6084
  for (const key of SCHEMA_CHILD_MAPS) {
6084
6085
  const child = schema[key];
6085
6086
  if (typeof child !== "object" || child === null || Array.isArray(child)) continue;
@@ -6207,6 +6208,63 @@ function normalizeMetaSchemaTypes(schema) {
6207
6208
  normalizeTypeKeyword(schema);
6208
6209
  }
6209
6210
  /**
6211
+ * Drop a `pattern` whose regex contains a UTF-16 SURROGATE escape (issue #274).
6212
+ *
6213
+ * THE REPORT. A user enabled the REA MCP server and every message answered
6214
+ * `400 / 11129` on `deepseek-v4.1-flash`; turning the server off made the same
6215
+ * sentence pass. The reporter pasted all 260 tool schemas — and, as with the
6216
+ * second #253 report, their value was the METHOD: the definitions were clean of
6217
+ * every rewrite this module already owns (fed through `prepareChatBody`, all 260
6218
+ * came out BYTE-IDENTICAL), so the refusal had to be a shape nobody had looked
6219
+ * for. The one construct no other tool shared was a regex escape for the
6220
+ * surrogate code-unit range:
6221
+ *
6222
+ * "allOf": [{ "pattern": "^[^\\uD800-\\uDFFF]*$" }]
6223
+ *
6224
+ * MEASURED, one body at a time on the real CN gateway, `deepseek-v4.1-flash`:
6225
+ *
6226
+ * - the two tools carrying that escape (`close_binary`, `binary_session`)
6227
+ * answer 11129 alone; the other three exposed tools answer 200;
6228
+ * - removing ONLY that `allOf` member makes the tool pass (removing the NUL
6229
+ * and slash members instead does not) — it is this escape, not `allOf`
6230
+ * or the regex class around it;
6231
+ * - the boundary is exact: `\uD7FF` and `\uE000` answer 200, every escape in
6232
+ * `\uD800`–`\uDFFF` answers 11129 (upper/lower/mixed hex digits alike);
6233
+ * - the rejection is SPECIFIC TO `pattern`: the same literal in `description`,
6234
+ * `title`, `const`, `enum`, `default` and `format` all answer 200;
6235
+ * - other escapes are fine — `\u0000`–`\uFFFF`, `\x00`, `\d`, an ASCII hex
6236
+ * range, even a literal emoji (a real surrogate pair in the JSON) all pass.
6237
+ * It is specifically the `\uXXXX` SPELLING of a surrogate code unit that
6238
+ * the upstream's schema parser cannot take.
6239
+ *
6240
+ * WHY DROP THE PATTERN, NOT THE TOOL OR THE ESCAPE. The pattern is an ANNOTATION
6241
+ * constraint — REA used it to reject lone surrogates in a filesystem path. The
6242
+ * MCP server still validates complete canonical inputs on its side, so removing
6243
+ * the display copy cannot let an invalid path through. Rewriting `\uD800` into
6244
+ * an equivalent character class would be a guess about the upstream parser the
6245
+ * evidence does not support; dropping one member's constraint keeps the tool
6246
+ * callable and matches the "repair, never silently remove a capability" rule
6247
+ * from {@link normalizeMetaSchemaTypes}. The member left `{}` is harmless:
6248
+ * `allOf: [{}]` was measured at 200, and an `allOf` emptied entirely is already
6249
+ * dropped by `normalizeMetaSchemaTypes` (an absent constraint means what an
6250
+ * empty one says). So the drop is all that is needed — no pruning pass, no
6251
+ * change to the schema's structure.
6252
+ *
6253
+ * A correct schema — no surrogate escape — leaves this function byte-identical,
6254
+ * so the prompt prefix stays stable for caching.
6255
+ */
6256
+ function normalizePatternSurrogates(schema) {
6257
+ const pattern = schema["pattern"];
6258
+ if (typeof pattern !== "string" || !SURROGATE_ESCAPE_RE.test(pattern)) return;
6259
+ delete schema["pattern"];
6260
+ }
6261
+ /**
6262
+ * A `\u` escape whose four hex digits name a UTF-16 surrogate code unit
6263
+ * (D800–DFFF). Case-insensitive on the hex digits: `\ud800` and `\uDaFf` are
6264
+ * refused just like the uppercase spelling (measured).
6265
+ */
6266
+ const SURROGATE_ESCAPE_RE = /\\u[dD][89aAbBfF][0-9a-fA-F]{2}/u;
6267
+ /**
6210
6268
  * Repair `type`, keeping every member the upstream would have taken (issue #253).
6211
6269
  *
6212
6270
  * Measured: `type: ["string","null"]` is ACCEPTED as sent, and so is
@@ -11267,7 +11325,7 @@ function describeRosterSeenPayload(raw) {
11267
11325
  //#endregion
11268
11326
  //#region src/version.ts
11269
11327
  /** The npm package version this build was produced from. */
11270
- const WORKBUDDY_CONNECT_VERSION = "5.24.13";
11328
+ const WORKBUDDY_CONNECT_VERSION = "5.24.15";
11271
11329
  //#endregion
11272
11330
  //#region src/host-heartbeat.ts
11273
11331
  /**
package/lib/index.d.ts CHANGED
@@ -1623,7 +1623,7 @@ declare function knownRegionOf(domain: string): WorkBuddyRegion | undefined;
1623
1623
  /**
1624
1624
  * Derive a request-prefix AFFINITY KEY and return it in `X-Conversation-ID` shape.
1625
1625
  *
1626
- * ROUTE A / OPT-IN EXPERIMENT (`stableConversationId`, default off). This is a
1626
+ * ROUTE A (`stableConversationId`, default on since 5.24.15). This is a
1627
1627
  * prefix-derived affinity key, not a host session id: the value hashes the model
1628
1628
  * id, the first `system` message's FULL content and the FIRST REAL `user`
1629
1629
  * message's FULL content (skipping the harness's injected context blocks via
@@ -1700,20 +1700,20 @@ interface WorkBuddyWireIdentity {
1700
1700
  */
1701
1701
  usageIdentity?: boolean;
1702
1702
  /**
1703
- * 请求前缀亲和键 A/B 开关(`chatStream` 专用,默认关,路线 A)。
1703
+ * 请求前缀亲和键开关(`chatStream` 专用,5.24.15 起默认开,路线 A)。
1704
1704
  *
1705
1705
  * 开启后 {@link deriveStableConversationId} 从请求体**不变前缀**派生一个
1706
- * v4 形状的 `X-Conversation-ID`;其余三件套仍是每请求现生成。默认关闭时
1707
- * 派生函数不运行、`chatHeaders` 收到 `undefined`,因此不进入稳定键分支。
1706
+ * v4 形状的 `X-Conversation-ID`;其余三件套仍是每请求现生成。设为 `false` 时
1707
+ * 派生函数不运行、`chatHeaders` 收到 `undefined`,回到每请求现生成的原形状。
1708
1708
  *
1709
- * 这是**只改一个变量**的离线对照实验,见 `docs/STABLE-KEY-SEMANTICS.md`:
1710
1709
  * 该值是从请求正文派生的亲和键,不是宿主 `sessionId`,不宣称会话隔离,也
1711
1710
  * 不证明上游按会话分区或具备路由亲和等内部机制。相同前缀的独立会话会共享
1712
1711
  * 同一个键,压缩 / 首问变化 / 模型切换都可能换键。客户端无法区分缓存键分区
1713
- * 与路由亲和,因此这里只做可观测的命中率对照,不做机制断言。
1712
+ * 与路由亲和,见 `docs/STABLE-KEY-SEMANTICS.md`,不做机制断言。
1714
1713
  *
1715
- * 默认 `false` 是单独决策,不因任何实验成功自动改变;推广默认值需用户另行
1716
- * 确认。配置文件里的开关由使用者按 `onUpstreamUsage` 的命中率自行决定。
1714
+ * 默认值由 #275 的冻结单变量实验与维护者独立复现后翻为 `true`(87.1pp
1715
+ * [81.9, 92.0],BENEFIT_SUPPORTED);这是单独决策,不因实验本身自动改变。
1716
+ * 使用者仍可在配置里设为 `false` 恢复原形状。
1717
1717
  */
1718
1718
  stableConversationId?: boolean;
1719
1719
  /**
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as CREDENTIAL_REJECTED_CODE, $t as imageSizeLimitsOf, A as withoutRouters, An as openEncryptedField, At as promoBadgeTone, B as defaultDesktopAuthPath, Bt as VIDEO_TAG_TEXT_TO_VIDEO, C as setDeviceMode, Cn as fetchAtRestKeyPayload, Ct as perturbChannelFingerprints, D as applyContextBudgets, Dn as isWorkbuddyBundle, Dt as rewriteSessionTitleModel, E as WorkBuddyCatalog, En as isEncryptedFieldWrapper, Et as requestEvidenceOf, F as WorkBuddyCredentialStore, Fn as withFileLock, Ft as offDefaultFor, G as parseWorkBuddyAuth, Gt as IMAGE_SIZE_LIMITS_WIDE, H as isEncryptedCredentialError, Ht as parseSupportedSecondsRange, I as WorkBuddyEncryptedCredentialError, In as writeFileAtomic, It as offRefused, J as workbuddyOwnAuthPath, Jt as MAX_INPUT_IMAGE_BYTES, K as preferredAccountName, Kt as IMAGE_TAG_IMAGE_TO_IMAGE, L as authFileName, Lt as recordRefusal, M as WORKBUDDY_AUTH_FILENAME, Mn as workbuddyAppExecutableCandidates, Mt as REFUSES_OFF_MODEL_IDS, N as WORKBUDDY_AUTH_FILE_ENV, Nt as defaultOffModelIds, O as deriveCatalog, On as macosBundleExecutable, Ot as toolSchemaRejectAdvice, Pn as resolveDshHome, Pt as lastRefusalFor, Q as CONTEXT_OVERFLOW_MARKER, Qt as imageModelChoices, R as defaultDesktopAuthCandidates, Rt as withEffectiveOff, S as saveDeviceSdkSettings, Sn as deriveAtRestKeyId, St as parseUpstreamModel, T as FALLBACK_WORKBUDDY_MODELS_GLOBAL, Tt as regionOf, U as isVaultAccountId, Ut as pickVideoModel, V as hasEncryptedCredentialFields, Vt as WorkBuddyVideoError, W as legacyWorkbuddyOwnAuthPath, Wt as resolveVideoParams, X as APP_VERSION, Xt as imageDataUrl, Yt as WorkBuddyImageError, Z as BODY_OVERSIZE_MARKER, Zt as imageMimeForPath, _ as createDeviceProfileLookup, _t as knownRegionOf, a as readHostHeartbeat, an as parseQueueAnswer, at as classifyUpstreamError, b as readDeviceSettings, bn as clearAtRestKeyCache, bt as parseCreditMultiplier, c as WORKBUDDY_CONNECT_VERSION, cn as NATIVE_MODALITY_BY_MODEL_ID, ct as deriveStableConversationId, dt as isBodyOversizeRefusal, en as isBareBase64Image, ft as isContextTooLongBody, g as createTuringSdk, gn as isDeviceId, gt as isToolSchemaRejectBody, h as createDeviceSdkPort, ht as isFirstMessageGateBody, i as processStartTimeMs, in as sniffImageMime, it as channelGateMemberOf, j as ENCRYPTED_CREDENTIAL_CODE, jn as readAtRestKey, jt as selectPromoBadge, k as fallbackModelsFor, kn as macosNestedAppBundles, kt as attachBusyLevels, l as createFileRosterSeenStore, ln as imageDefaultFor, m as piAiRuntimeInfo, mt as isCredentialRejectedError, n as clearHostHeartbeat, nn as parseImageDataUrl, nt as WorkBuddyCredentialRejectedError, o as workbuddyHostHeartbeatPath, on as queueNoticeText, ot as conversationIdFromSessionId, p as resolveCnGateway, pt as isConversationIdGateBody, q as workbuddyAccountId, qt as IMAGE_TAG_TEXT_TO_IMAGE, r as isHeartbeatProcessAlive, rn as pickMediaModel, rt as WorkBuddyUpstreamClient, s as writeHostHeartbeat, sn as pruneTempDir, st as declaredTools, t as WORKBUDDY_HOST_HEARTBEAT_FILENAME, tn as isWatermarkFreeImageModel, tt as WORKBUDDY_FALLBACK_SYSTEM_PROMPT, un as nativeModalityOf, ut as forceNeutralHead, v as describeDerivedDevices, vt as modelIdOfBody, w as FALLBACK_WORKBUDDY_MODELS, wn as findWorkbuddyAppExecutable, wt as prepareChatBody, x as saveDeviceProfile, xn as deriveAtRestKey, xt as parseReasoning, y as isDeviceMode, yn as WORKBUDDY_APP_EXECUTABLE_ENV, yt as openingEvidenceOfBody, z as defaultDesktopAuthDirs, zt as VIDEO_TAG_IMAGE_TO_VIDEO } from "./host-heartbeat-Dlyz9ZUB.js";
1
+ import { $ as CREDENTIAL_REJECTED_CODE, $t as imageSizeLimitsOf, A as withoutRouters, An as openEncryptedField, At as promoBadgeTone, B as defaultDesktopAuthPath, Bt as VIDEO_TAG_TEXT_TO_VIDEO, C as setDeviceMode, Cn as fetchAtRestKeyPayload, Ct as perturbChannelFingerprints, D as applyContextBudgets, Dn as isWorkbuddyBundle, Dt as rewriteSessionTitleModel, E as WorkBuddyCatalog, En as isEncryptedFieldWrapper, Et as requestEvidenceOf, F as WorkBuddyCredentialStore, Fn as withFileLock, Ft as offDefaultFor, G as parseWorkBuddyAuth, Gt as IMAGE_SIZE_LIMITS_WIDE, H as isEncryptedCredentialError, Ht as parseSupportedSecondsRange, I as WorkBuddyEncryptedCredentialError, In as writeFileAtomic, It as offRefused, J as workbuddyOwnAuthPath, Jt as MAX_INPUT_IMAGE_BYTES, K as preferredAccountName, Kt as IMAGE_TAG_IMAGE_TO_IMAGE, L as authFileName, Lt as recordRefusal, M as WORKBUDDY_AUTH_FILENAME, Mn as workbuddyAppExecutableCandidates, Mt as REFUSES_OFF_MODEL_IDS, N as WORKBUDDY_AUTH_FILE_ENV, Nt as defaultOffModelIds, O as deriveCatalog, On as macosBundleExecutable, Ot as toolSchemaRejectAdvice, Pn as resolveDshHome, Pt as lastRefusalFor, Q as CONTEXT_OVERFLOW_MARKER, Qt as imageModelChoices, R as defaultDesktopAuthCandidates, Rt as withEffectiveOff, S as saveDeviceSdkSettings, Sn as deriveAtRestKeyId, St as parseUpstreamModel, T as FALLBACK_WORKBUDDY_MODELS_GLOBAL, Tt as regionOf, U as isVaultAccountId, Ut as pickVideoModel, V as hasEncryptedCredentialFields, Vt as WorkBuddyVideoError, W as legacyWorkbuddyOwnAuthPath, Wt as resolveVideoParams, X as APP_VERSION, Xt as imageDataUrl, Yt as WorkBuddyImageError, Z as BODY_OVERSIZE_MARKER, Zt as imageMimeForPath, _ as createDeviceProfileLookup, _t as knownRegionOf, a as readHostHeartbeat, an as parseQueueAnswer, at as classifyUpstreamError, b as readDeviceSettings, bn as clearAtRestKeyCache, bt as parseCreditMultiplier, c as WORKBUDDY_CONNECT_VERSION, cn as NATIVE_MODALITY_BY_MODEL_ID, ct as deriveStableConversationId, dt as isBodyOversizeRefusal, en as isBareBase64Image, ft as isContextTooLongBody, g as createTuringSdk, gn as isDeviceId, gt as isToolSchemaRejectBody, h as createDeviceSdkPort, ht as isFirstMessageGateBody, i as processStartTimeMs, in as sniffImageMime, it as channelGateMemberOf, j as ENCRYPTED_CREDENTIAL_CODE, jn as readAtRestKey, jt as selectPromoBadge, k as fallbackModelsFor, kn as macosNestedAppBundles, kt as attachBusyLevels, l as createFileRosterSeenStore, ln as imageDefaultFor, m as piAiRuntimeInfo, mt as isCredentialRejectedError, n as clearHostHeartbeat, nn as parseImageDataUrl, nt as WorkBuddyCredentialRejectedError, o as workbuddyHostHeartbeatPath, on as queueNoticeText, ot as conversationIdFromSessionId, p as resolveCnGateway, pt as isConversationIdGateBody, q as workbuddyAccountId, qt as IMAGE_TAG_TEXT_TO_IMAGE, r as isHeartbeatProcessAlive, rn as pickMediaModel, rt as WorkBuddyUpstreamClient, s as writeHostHeartbeat, sn as pruneTempDir, st as declaredTools, t as WORKBUDDY_HOST_HEARTBEAT_FILENAME, tn as isWatermarkFreeImageModel, tt as WORKBUDDY_FALLBACK_SYSTEM_PROMPT, un as nativeModalityOf, ut as forceNeutralHead, v as describeDerivedDevices, vt as modelIdOfBody, w as FALLBACK_WORKBUDDY_MODELS, wn as findWorkbuddyAppExecutable, wt as prepareChatBody, x as saveDeviceProfile, xn as deriveAtRestKey, xt as parseReasoning, y as isDeviceMode, yn as WORKBUDDY_APP_EXECUTABLE_ENV, yt as openingEvidenceOfBody, z as defaultDesktopAuthDirs, zt as VIDEO_TAG_IMAGE_TO_VIDEO } from "./host-heartbeat-BqK7yBp2.js";
2
2
  import z from "@deepseek-ai/schemastery";
3
3
  import { appendFile, mkdir, open, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
4
4
  import { randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
@@ -13574,7 +13574,7 @@ const Config = z.object({
13574
13574
  z.const("always")
13575
13575
  ]).default("failure").description("When to perturb scanned messages with invisible characters: \"off\" only rescues after a channel-gate refusal, \"failure\" (default) learns from a successful rescue and starts later requests perturbed, \"always\" starts every request with the dense rescue for a gateway whose plain attempt is guaranteed to fail.")),
13576
13576
  usageIdentity: asVolatile(z.boolean().default(false).description("Send the chat conversation ids in the official client's 32-hex UUIDv7 shape and add a mirroring X-Request-ID. Off by default — it is a display alignment measured by a reporter, not by this plugin, and the chat channel identity (User-Agent) and request body never change.")),
13577
- stableConversationId: asVolatile(z.boolean().default(false).description("A/B 开关(路线 A,默认关):开启时把 X-Conversation-ID 固定为从请求体不变前缀派生的亲和键(其余三件套仍每请求现生成)。该值不是宿主会话标识,不宣称会话隔离,也不证明上游按会话分区;相同前缀的独立会话会共享键。关闭时不进入派生分支。用于离线单变量命中率对照,详见 docs/STABLE-KEY-SEMANTICS.md。改动后需重载插件(配置在挂载时采样一次)。")),
13577
+ stableConversationId: asVolatile(z.boolean().default(true).description("路线 A(默认开):把 X-Conversation-ID 固定为从请求体不变前缀派生的亲和键(其余三件套仍每请求现生成),以复用上游前缀缓存。该值不是宿主会话标识,不宣称会话隔离,也不证明上游按会话分区;相同前缀的独立会话会共享键。设为 false 则回到每请求现生成的默认形状。依据 #275 的冻结单变量实验与维护者独立复现(87.1pp [81.9,92.0],BENEFIT_SUPPORTED)翻为默认开;实验口径与边界见 docs/STABLE-KEY-SEMANTICS.md。改动后需重载插件(配置在挂载时采样一次)。")),
13578
13578
  sessionConversationId: asVolatile(z.boolean().default(false).description("Route B (默认关): derive the upstream X-Conversation-ID from the HOST session id instead of the request prefix. The session id reaches the loopback shim as pi-ai session-affinity headers and is replaced by a domain-separated digest before anything is sent upstream — the real session id never leaves the process. Independent of route A; takes effect on the next request without a reload. See docs/ROUTE-B-SESSION-ID.md. No upstream cache-key or routing mechanism is asserted.")),
13579
13579
  wireProfile: asVolatile(z.union([z.const("conservative"), z.const("balanced")]).default("balanced").description("Outbound identity profile. \"balanced\" (default) makes every request claim the same client (WorkBuddy product/IDE/agent headers, X-CodeBuddy-Request, Accept-Language, X-Root-Request-ID, and a per-account X-Machine-ID/X-Session-ID pair) and gives the billing routes a User-Agent plus Origin/Referer. \"conservative\" restores the 5.16.0 bytes exactly, including X-Product: SaaS.")),
13580
13580
  /**
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "dsh-connect-workbuddy",
3
3
  "displayName": "DSH Connect WorkBuddy",
4
4
  "description": "把本机登录的 WorkBuddy 模型(国内版与国际版)接入 DeepSeek Harness:每次刷新按上游目录自动读取每个模型的积分倍率,支持逐模型图片输入开关、多账号切换与账号池自动换号,并提供每日签到、卡片与输入框里的胶囊积分读数等只读积分概览。",
5
- "version": "5.24.13",
5
+ "version": "5.24.15",
6
6
  "author": "dingminhua",
7
7
  "copyright": "Copyright (c) 2026 LaoDing",
8
8
  "license": "MIT",
@@ -107,6 +107,9 @@
107
107
  "peerDependenciesMeta": {
108
108
  "@earendil-works/pi-ai": {
109
109
  "optional": true
110
+ },
111
+ "react": {
112
+ "optional": true
110
113
  }
111
114
  },
112
115
  "devDependencies": {