dsh-connect-workbuddy 5.24.2 → 5.24.5
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 +185 -0
- package/lib/bin.js +1 -1
- package/lib/{host-heartbeat-Q85k2yEL.js → host-heartbeat-COoAT4ZR.js} +260 -6
- package/lib/index.d.ts +20 -1
- package/lib/index.js +70 -7
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,190 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 5.24.5 (2026-11-14)
|
|
4
|
+
|
|
5
|
+
> 版本号是 **patch**:只改一句报错文案,外加一条测试。无行为变化。来自 issue #253 的收尾自查。
|
|
6
|
+
|
|
7
|
+
### 修复:11129 的报错文案落后于插件实际做的事
|
|
8
|
+
|
|
9
|
+
5.24.4 已经把「关键字的值类型写错」这一整类(36 种实测)修掉,但**用户看到的那句话还在只列原来的
|
|
10
|
+
4 种 draft-4 写法**。后果不是崩溃,是误导:如果他仍然撞上 11129,文案告诉他「插件已经试过这 4 种」,
|
|
11
|
+
而实际上插件试过的是一整类——读者会据此判断「那肯定是我这 4 种之外的问题」,方向就偏了。
|
|
12
|
+
|
|
13
|
+
这正是 `toolSchemaRejectAdvice` 存在的理由被违背了一次:它当初是为了替换上游那句「请新建任务,或换个
|
|
14
|
+
模型」,而它自己变成了新的不准确信息。
|
|
15
|
+
|
|
16
|
+
文案现在补上第二类,并且**加了三测试钉住这件事**——之前这条字符串**一条测试都没有**,所以它与实现
|
|
17
|
+
脱节时没有任何东西会变红。测试断言的是**性质**而不是措辞:插件做的每一类改写都必须被这句话点名;
|
|
18
|
+
不得声称是账号/额度/网络问题;必须承认「仍被拒说明还有别的写法」(不得假装穷举)。
|
|
19
|
+
|
|
20
|
+
变异验证:文案退回只列 4 类 → 红 1 条;删掉「仍被拒说明还有别的写法」→ 红 1 条。
|
|
21
|
+
|
|
22
|
+
### 仍未闭环的三件事(issue #253 报告者提出,本轮没有做)
|
|
23
|
+
|
|
24
|
+
写在这里以免它们因为「issue 已回复」而被当成已处理:
|
|
25
|
+
|
|
26
|
+
1. **按模型摘除 `tools` 的降级开关**。报告者建议为不接受工具 schema 的模型提供纯文本降级。没做:
|
|
27
|
+
这会让模型静默失去全部工具能力,比报错更难被发现,而且现在报错至少是准确的了。
|
|
28
|
+
2. **探针带代表性 tools**。没做,理由是具体的:探针结果会经 `probeUpdatesOf` → `exclusionOf` 直接让
|
|
29
|
+
账号**出池**,往里塞工具 schema 会把「某个工具定义有问题」记成「这个账号坏了」。
|
|
30
|
+
3. **`supportsToolCall` 仍无消费方**。报告者指出目录标志 parse 后没人用。属实。要接上它需要先决定
|
|
31
|
+
「标了支持但实际被拒」时怎么办,而这正是上面第 1 条要拍板的事。
|
|
32
|
+
|
|
33
|
+
## 5.24.4 (2026-11-14)
|
|
34
|
+
|
|
35
|
+
> **5.24.3 从未发布到 npm。** 它打了 tag、CI 通过、Release 建了草稿,但 `npm publish` 那一步被
|
|
36
|
+
> #253 的第二次报告打断,没有执行——registry 上 `5.24.3` 至今 404,`latest` 此前一直是 `5.24.2`。
|
|
37
|
+
> 这是流程上的缺口,不是发布失败。**5.24.4 已包含 5.24.3 的全部改动**(`isBodyOversizeRefusal`、
|
|
38
|
+
> `rescueCauseOf`、`BODY_OVERSIZE_TARGET_FRACTION` 与两个溢出标记都在发布包里核对过),
|
|
39
|
+
> 所以 5.24.3 不需要补发——它的 Release 保持草稿状态直接删除即可,用户装 5.24.4 就同时拿到 #258
|
|
40
|
+
> 与 #253 两次修复。与 5.24.0、5.21.5 一样的处置。
|
|
41
|
+
|
|
42
|
+
> 版本号是 **patch**:修一处「schema 里某个关键字的值类型不对就整个工具被拒」,并修好 5.24.2
|
|
43
|
+
> 自己引入的一处回归。无新增配置项、无接口变化。来自 issue #253 的第二份报告。
|
|
44
|
+
|
|
45
|
+
### 修复:关键字值类型错误导致 11129(36 种实测)
|
|
46
|
+
|
|
47
|
+
第二次报告给的是**方法**而不是结论,这一步很关键:报告者证明 `normalizeSchemaNode` 的遍历有盲区,
|
|
48
|
+
我顺着「盲区里漏了什么」去测,测出的是**另一类问题**。
|
|
49
|
+
|
|
50
|
+
按关键字逐个、**绕过 `prepareChatBody` 直接发原始 body** 测出来的,是 schema 自身的类型错误:
|
|
51
|
+
|
|
52
|
+
| 写法 | 结果 |
|
|
53
|
+
| --- | --- |
|
|
54
|
+
| `title: 1`、`description: 5`、`pattern: 123`、`format: 7` | 11129 |
|
|
55
|
+
| `minimum: "0"`、`maxLength: "5"`、`multipleOf: "2"` | 11129 |
|
|
56
|
+
| `uniqueItems: "true"`、`readOnly: "yes"` | 11129 |
|
|
57
|
+
| `allOf: {}`(非数组)、`allOf: []`(空数组) | 11129 |
|
|
58
|
+
| `not: "x"`、`items: "x"`、`additionalProperties: "x"`(非 schema) | 11129 |
|
|
59
|
+
| `type: "thing"`、`type: []` | 11129 |
|
|
60
|
+
|
|
61
|
+
一共 **36 种**,遍布每一个位置。现在会在发出前修掉:**类型不对的注解/约束值直接删除**,`type` 的非法成员
|
|
62
|
+
从联合里剔除(留一个就还原成字符串)。这不改变工具接受哪些参数——被删的都是注解或约束,不是
|
|
63
|
+
`properties` / `required` / 任何 schema 结构——只是让它不再被整体拒收。
|
|
64
|
+
|
|
65
|
+
**刻意没有选择「把整个工具删掉」**:那样更简单,但会静默移除用户装好的能力,模型随后还会去调一个
|
|
66
|
+
已经不存在的工具。
|
|
67
|
+
|
|
68
|
+
**只有真的写错的值才会被动**。完全合法的 schema 逐字节不变(真实 `stagehand_extract` 已钉住),
|
|
69
|
+
这样 prompt 前缀对缓存是稳定的。
|
|
70
|
+
|
|
71
|
+
### 修复:5.24.2 自己引入的回归——空 tuple 换了个 11129
|
|
72
|
+
|
|
73
|
+
5.24.2 把 draft-4 的 `items: []` 改写成 `prefixItems: []`,而**空 `prefixItems` 正是上游拒收的**。
|
|
74
|
+
也就是说那次「修复」对一个本来就是 11129 的输入,产出了另一个 11129,等于没修。
|
|
75
|
+
|
|
76
|
+
draft-4 的 `items: []` 意思是「任意数组」,对应 `items: {}`。现在空 tuple 直接给 `items: {}`,
|
|
77
|
+
并且 `additionalItems` 在 tuple 分支里成为 2020-12 的 `items`(尾元素 schema),才是它原本的语义。
|
|
78
|
+
|
|
79
|
+
### 报告者建议的三种写法:实测**不需要**改
|
|
80
|
+
|
|
81
|
+
报告者给了 3 种 draft-4 写法(`type` 数组、`dependencies`、`additionalItems`)和一份补丁。我逐个
|
|
82
|
+
**绕过规范化**发原始 body 实测,**三种全部 200**:
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
type: ["string","null"] 200
|
|
86
|
+
dependencies (array) 200
|
|
87
|
+
dependencies (object) 200
|
|
88
|
+
additionalItems 200 (配合对象 items,或不配合)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
所以迁移它们不会修好任何东西,那份补丁是个 no-op。**没有采纳**,理由写进代码注释。
|
|
92
|
+
|
|
93
|
+
但其中两件事值得留下:
|
|
94
|
+
|
|
95
|
+
- `dependencies` 的对象值**确实**需要被递归遍历(里面可能嵌着别的 draft-4 写法),所以加了遍历项;
|
|
96
|
+
- `additionalItems` 加进 `SCHEMA_CHILD_SINGLE`,只在 tuple 分支里消费。
|
|
97
|
+
|
|
98
|
+
这两处都不改变上游已接受的字节(有测试钉住 `additionalItems` 配合对象 `items` 时原样保留)。
|
|
99
|
+
|
|
100
|
+
### 一处顺序陷阱,写在这里免得下次再踩
|
|
101
|
+
|
|
102
|
+
draft-4 转换必须**先于**类型修复。类型修复会把布尔 `exclusiveMinimum`、tuple `items` 当成「类型错误」
|
|
103
|
+
删掉,转换逻辑就再也看不到它们了。第一版就是反的,`items: []` 被删成「没有 items」、tuple 尾元素
|
|
104
|
+
被静默丢弃,是往返测试抓到的。
|
|
105
|
+
|
|
106
|
+
### 验证
|
|
107
|
+
|
|
108
|
+
真实上游端到端(`deepseek-v4.1-flash`,绕过与经过规范化各测一遍):36 种类型错误**全部从 11129 变 ok**,
|
|
109
|
+
空数组族全部 ok,报告者的 3 种写法仍然 ok,真实 `stagehand_extract` 等 9 个合法 schema 逐字节未变。
|
|
110
|
+
|
|
111
|
+
变异验证五条,各自单独还原:去掉类型修复调用红 7 条;把 `required: []` 也当成非法红 2 条;
|
|
112
|
+
`additionalItems` 不带进尾元素红 1 条;`dependencies` 不遍历红 1 条;空 tuple 分支失效红 1 条。
|
|
113
|
+
|
|
114
|
+
**其中最后一条第一次做变异时是绿的**——因为后跑的类型修复会把 `prefixItems: []` 顺手删掉,掩盖了
|
|
115
|
+
那个分支的缺陷。改成给空 tuple 配一个 `additionalItems` 同级项之后才能区分。这条记在这里,
|
|
116
|
+
因为「测试通过了但证明的不是它自己声称的东西」比没有测试更危险。
|
|
117
|
+
|
|
118
|
+
## 5.24.3 (2026-11-14)
|
|
119
|
+
|
|
120
|
+
> 版本号是 **patch**:修一处「长会话永久 422、只能开新会话」的问题,无新增配置项、无接口变化。
|
|
121
|
+
> 来自 issue #258。
|
|
122
|
+
|
|
123
|
+
### 修复:请求体超过**字节**上限时,历史折叠从未触发
|
|
124
|
+
|
|
125
|
+
长会话在某一刻稳定报:
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
HTTP 422 / gate_oversize_refusal_unattributed_bytes
|
|
129
|
+
(8,401,132 B > 8,388,608 B)
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
外层看到的是 400,根因是**请求体超过了一个本地字节上限**,请求根本没发到上游。之后每一次重试都带上
|
|
133
|
+
同一份超限历史,于是这一会话永久卡死,只能新建。
|
|
134
|
+
|
|
135
|
+
插件本来就有折叠能力(`context-rescue.ts` → 宿主自带的 compaction),但那套东西**两个环节都接不上**,
|
|
136
|
+
而且它们是**独立失效**的:
|
|
137
|
+
|
|
138
|
+
**一、触发条件只认 token 溢出。** 唯一的判定是 pi-ai 的 `isContextOverflow`,它匹配的是
|
|
139
|
+
「prompt is too long」那一族**token 上下文溢出**文案。字节超限的措辞一条都不在它的模式表里,于是
|
|
140
|
+
`rescue` 一次都没被调用。
|
|
141
|
+
|
|
142
|
+
**二、就算调进去,也一次都不会折叠。** 折叠目标是 `window * 0.6`,而 `window` 是模型**声明的
|
|
143
|
+
token 窗口** 1,000,000 → 目标 600,000。可 8 MiB 这条线大约在 **15 万 token** 就被撞到,于是
|
|
144
|
+
`totalTokens(≈150k) <= target(600k)` 在**第一次测量时就成立**,循环直接返回、原样重发同一个 body。
|
|
145
|
+
**阈值单位是字节,折叠目标是 token,单位不一致时这个循环会被平凡满足。**
|
|
146
|
+
|
|
147
|
+
两条都修了:
|
|
148
|
+
|
|
149
|
+
- **触发**:`rescueCauseOf()` 在 `isContextOverflow` 之外,再按「请求体字节超限」这一**语义**识别一次
|
|
150
|
+
(见下面「按语义匹配」);
|
|
151
|
+
- **目标**:字节超限时目标改为 `当前测量 * 0.9`,从 payload 本身推出来。这样第一轮比较必然不成立,
|
|
152
|
+
折叠一定会真的发生;每轮至少折掉 10%,最多 8 轮,覆盖一次「只超出几个百分点」的越线
|
|
153
|
+
——报告者实测的 8,401,132 对 8,388,608 正是这种形状。
|
|
154
|
+
- **让宿主接手**:回复里补一句 `prompt is too long (request body exceeded the local byte limit)`。
|
|
155
|
+
宿主的溢出恢复只认这句英文(与 issue #101 的 11115 同一机制),不补它,宿主就只看到一个它不会恢复的
|
|
156
|
+
400。**原始错误原样保留在后面**,不伪装成 11115。
|
|
157
|
+
|
|
158
|
+
### 按语义匹配,不点名任何插件
|
|
159
|
+
|
|
160
|
+
识别用的是「请求体字节超限」这一类事实(字节比较形状 `8,401,132 B > 8,388,608 B`、
|
|
161
|
+
`request-body limit`、`byte limit`、`oversize` + `refused locally`),**不匹配任何插件的错误码**。
|
|
162
|
+
|
|
163
|
+
这不是措辞洁癖:`docs/DESIGN.md` §零 第 4 条要求本插件不因别的插件在场而改变行为,判别式是
|
|
164
|
+
「随**数据**走可以,随**代码**走不行」——写死别人的标识符属于后者,对方改名或消失之后那段代码还留着。
|
|
165
|
+
按语义识别的是**一类错误**,换个组件、换套措辞只要说的还是同一件事,仍然覆盖。代价是这一族匹配
|
|
166
|
+
比精确码宽,所以刻意排除了 `too many tokens` / `context length exceeded` / `11115`——那些是 token
|
|
167
|
+
溢出,宿主自己会处理,两边都插手只会互相竞争。
|
|
168
|
+
|
|
169
|
+
已知**不覆盖**:`oversized image attachment rejected` 这类「大」但不是「请求体大」的失败不会被误判
|
|
170
|
+
(有测试钉住),因为折掉历史对它们没有帮助。
|
|
171
|
+
|
|
172
|
+
### 关于原 issue #202 的关闭
|
|
173
|
+
|
|
174
|
+
#202 以「你让 AI 帮你更新插件,问题已经解决」关闭,**这个理由不成立**:代码里从来没有针对这个
|
|
175
|
+
字节上限的任何改动,5.24.1 的发布包里 `bili_gate_oversize` / `BILI_LOCAL_BODY` 这类标识都是零命中。
|
|
176
|
+
报告者这次拿 tarball 逐字核实过,是对的。这一版才是真正的修复。
|
|
177
|
+
|
|
178
|
+
### 仍未解决:bili 侧的归因死锁
|
|
179
|
+
|
|
180
|
+
即使上面都做了,该组件里这条 lane 仍然永远拿不到压缩能力——它在第二跳的归因返回 `none`,而
|
|
181
|
+
`learnConversation` 只在上游归因成功时调用,于是表永远是空的自举死锁。报告者已在
|
|
182
|
+
`ranxianglei/billion-context#6546` 提交实测数据,那一半需要对方提供显式的归属注册 API。
|
|
183
|
+
本插件这边能做的、也已做的,是不让它卡成永久 400。
|
|
184
|
+
|
|
185
|
+
**尚未验证**:报告者明确说明他「还没做」完整重启 DSH 后的真实长会话验证(确认折叠后重发的 body
|
|
186
|
+
确实低于 8 MiB)。8 MiB 是对方组件内部的常量,不在本仓库手里,所以这一条只能由报告者复现确认。
|
|
187
|
+
|
|
3
188
|
## 5.24.2 (2026-11-14)
|
|
4
189
|
|
|
5
190
|
> 版本号是 **patch**:修一处「某些模型完全不可用」的请求字节问题,无新增配置项、无接口变化。
|
package/lib/bin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { Cn as findWorkbuddyAppExecutableWithSource, F as WorkBuddyCredentialStore, J as workbuddyOwnAuthPath, Mn as resolveDshHome, N as WORKBUDDY_AUTH_FILE_ENV, P as WORKBUDDY_VAULT_DIRNAME, R as defaultDesktopAuthCandidates, T as FALLBACK_WORKBUDDY_MODELS_GLOBAL, W as legacyWorkbuddyOwnAuthPath, X as APP_VERSION, Y as workbuddyVaultDir, _n as WORKBUDDY_APP_EXECUTABLE_ENV, a as readHostHeartbeat, b as readDeviceSettings, c as WORKBUDDY_CONNECT_VERSION, d as rosterSeenPath, dn as ensureDeviceSalt, et as DEFAULT_WIRE_PROFILE, f as WORKBUDDY_CN_BASE_ENV, fn as readDeviceSalt, g as createTuringSdk, gn as protectCredentialDirectory, hn as inspectCredentialDirectory, jn as hostPeersInfo, ln as WORKBUDDY_DEVICE_TOKEN_FILE_ENV, m as piAiRuntimeInfo, o as workbuddyHostHeartbeatPath, p as resolveCnGateway, pn as deriveDeviceId, r as isHeartbeatProcessAlive, rt as WorkBuddyUpstreamClient, st as describeRequestHeaderNames, u as describeRosterSeenPayload, un as readDeviceTokenFile, w as FALLBACK_WORKBUDDY_MODELS, z as defaultDesktopAuthDirs } from "./host-heartbeat-COoAT4ZR.js";
|
|
3
3
|
import { readFile } from "node:fs/promises";
|
|
4
4
|
import { dirname, join } from "node:path";
|
|
5
5
|
import { realpathSync } from "node:fs";
|
|
@@ -3934,10 +3934,17 @@ function isToolSchemaRejectBody(body) {
|
|
|
3934
3934
|
* Deliberately a FIXED LIST rather than a parse of the offending body: the
|
|
3935
3935
|
* upstream never names the keyword, and the plugin has already rewritten every
|
|
3936
3936
|
* one of these on the way out. If a request still gets `11129` after that
|
|
3937
|
-
* rewrite, the cause is a keyword this build does not know — so the advice has
|
|
3938
|
-
* say "something else", not repeat the
|
|
3937
|
+
* rewrite, the cause is a keyword this build does not know — so the advice has
|
|
3938
|
+
* to say "something else", not repeat the shapes it already handled.
|
|
3939
|
+
*
|
|
3940
|
+
* KEPT IN STEP WITH THE REWRITE, by hand. It listed only the four draft-4
|
|
3941
|
+
* shapes for a while AFTER the type repair had landed, so a reader who hit a
|
|
3942
|
+
* surviving `11129` was told the plugin had tried four things when it had tried
|
|
3943
|
+
* the whole class — the exact "confident, wrong, and unhelpful" reply that this
|
|
3944
|
+
* function exists to replace. When `normalizeMetaSchemaTypes` learns a new
|
|
3945
|
+
* family, this string has to learn it too.
|
|
3939
3946
|
*/
|
|
3940
|
-
const TOOL_SCHEMA_REWRITTEN_KEYWORDS = "元组式 `items`、布尔 `exclusiveMinimum`/`exclusiveMaximum`、`required` 非数组或含重复项、外部 `$ref`";
|
|
3947
|
+
const TOOL_SCHEMA_REWRITTEN_KEYWORDS = "元组式 `items`、布尔 `exclusiveMinimum`/`exclusiveMaximum`、`required` 非数组或含重复项、外部 `$ref`,以及关键字的值类型写错(如 `title: 1`、`minimum: \"0\"`、`allOf: {}`、`type: []`、`enum`/`examples` 写成标量)";
|
|
3941
3948
|
/**
|
|
3942
3949
|
* One actionable sentence for a `11129` refusal, naming what was already fixed
|
|
3943
3950
|
* and what the user can still do.
|
|
@@ -3966,6 +3973,59 @@ function toolSchemaRejectAdvice() {
|
|
|
3966
3973
|
*/
|
|
3967
3974
|
const CONTEXT_OVERFLOW_MARKER = "prompt is too long (upstream code 11115)";
|
|
3968
3975
|
/**
|
|
3976
|
+
* The marker for a request refused because its BODY BYTES exceed a local limit
|
|
3977
|
+
* (issue #258).
|
|
3978
|
+
*
|
|
3979
|
+
* Deliberately the SAME English head pi-ai's `OVERFLOW_PATTERNS` already
|
|
3980
|
+
* matches (`prompt is too long`), with a parenthetical naming the real cause.
|
|
3981
|
+
* The host's rescue ladder keys on that phrase and on nothing else, so a
|
|
3982
|
+
* refusal it must recover from has to carry it — see the #101 comment in
|
|
3983
|
+
* `src/shim.ts` for how the 11115 case arrived at the same shape.
|
|
3984
|
+
*
|
|
3985
|
+
* The parenthetical is NOT the bili code. Naming another plugin's identifier
|
|
3986
|
+
* here would be plugin-specific code in this plugin's body — the line
|
|
3987
|
+
* `docs/DESIGN.md` §零 draws — and the code would keep describing a dependency
|
|
3988
|
+
* that may be gone tomorrow. What this string states is the fact that matters:
|
|
3989
|
+
* the request was too large to send.
|
|
3990
|
+
*/
|
|
3991
|
+
const BODY_OVERSIZE_MARKER = "prompt is too long (request body exceeded the local byte limit)";
|
|
3992
|
+
/**
|
|
3993
|
+
* Whether this text reports a body-size refusal rather than a token overflow
|
|
3994
|
+
* (issue #258).
|
|
3995
|
+
*
|
|
3996
|
+
* A local proxy/gateway in front of the provider may refuse a request whose
|
|
3997
|
+
* serialized body exceeds some byte ceiling it enforces. Measured shapes, from
|
|
3998
|
+
* a real report:
|
|
3999
|
+
*
|
|
4000
|
+
* bili_gate_oversize_refusal_unattributed_bytes
|
|
4001
|
+
* (8,401,132 B > 8,388,608 B)
|
|
4002
|
+
* "unattributed oversized model request refused locally with a 422"
|
|
4003
|
+
*
|
|
4004
|
+
* MATCHED BY MEANING, NOT BY NAME. That is the crux of the design decision
|
|
4005
|
+
* here: matching a plugin's identifier would be the "special-case another
|
|
4006
|
+
* plugin" this project forbids, while matching "a request body was too large"
|
|
4007
|
+
* is the same kind of reader as every other measured-wording matcher in this
|
|
4008
|
+
* module. A refusal that only says `oversize`/`too large` in BYTES is the class;
|
|
4009
|
+
* which component produced it is not this plugin's business, and a future
|
|
4010
|
+
* component with different wording that still says so is covered for free.
|
|
4011
|
+
*
|
|
4012
|
+
* What is deliberately NOT matched: `too_many_tokens`, `context length
|
|
4013
|
+
* exceeded`, `11115` and friends. Those are TOKEN overflow, which the host
|
|
4014
|
+
* already recovers from on its own; treating them here would make two
|
|
4015
|
+
* authorities compete over the same failure.
|
|
4016
|
+
*/
|
|
4017
|
+
function isBodyOversizeRefusal(text) {
|
|
4018
|
+
if (text === "") return false;
|
|
4019
|
+
const lower = text.toLowerCase();
|
|
4020
|
+
if (/[\d,]{4,}\s*b\s*>\s*[\d,]{4,}\s*b/u.test(lower)) return true;
|
|
4021
|
+
if (lower.includes("request-body limit") || lower.includes("request body limit")) return true;
|
|
4022
|
+
const oversize = lower.includes("oversize");
|
|
4023
|
+
const localByte = lower.includes("byte limit");
|
|
4024
|
+
const localRefusal = lower.includes("refused locally");
|
|
4025
|
+
if (localByte) return true;
|
|
4026
|
+
return oversize && localRefusal;
|
|
4027
|
+
}
|
|
4028
|
+
/**
|
|
3969
4029
|
* Wording that identifies the CHANNEL half of `11128` (the other halves being
|
|
3970
4030
|
* `conversation id missing` and `first message is not system prompt`).
|
|
3971
4031
|
*
|
|
@@ -5866,6 +5926,7 @@ function normalizeSchemaNode(node, depth = 0) {
|
|
|
5866
5926
|
normalizeExclusiveBound(schema, "exclusiveMaximum", "maximum");
|
|
5867
5927
|
normalizeRequired(schema);
|
|
5868
5928
|
dropExternalRef(schema);
|
|
5929
|
+
normalizeMetaSchemaTypes(schema);
|
|
5869
5930
|
for (const key of SCHEMA_CHILD_MAPS) {
|
|
5870
5931
|
const child = schema[key];
|
|
5871
5932
|
if (typeof child !== "object" || child === null || Array.isArray(child)) continue;
|
|
@@ -5876,6 +5937,11 @@ function normalizeSchemaNode(node, depth = 0) {
|
|
|
5876
5937
|
if (!Array.isArray(list)) continue;
|
|
5877
5938
|
for (const nested of list) normalizeSchemaNode(nested, depth + 1);
|
|
5878
5939
|
}
|
|
5940
|
+
for (const key of SCHEMA_CHILD_DEPENDENCIES) {
|
|
5941
|
+
const child = schema[key];
|
|
5942
|
+
if (typeof child !== "object" || child === null || Array.isArray(child)) continue;
|
|
5943
|
+
for (const nested of Object.values(child)) normalizeSchemaNode(nested, depth + 1);
|
|
5944
|
+
}
|
|
5879
5945
|
for (const key of SCHEMA_CHILD_SINGLE) normalizeSchemaNode(schema[key], depth + 1);
|
|
5880
5946
|
}
|
|
5881
5947
|
/**
|
|
@@ -5904,6 +5970,7 @@ const SCHEMA_CHILD_LISTS = [
|
|
|
5904
5970
|
/** Keywords whose value is a SINGLE schema (walked directly). */
|
|
5905
5971
|
const SCHEMA_CHILD_SINGLE = [
|
|
5906
5972
|
"items",
|
|
5973
|
+
"additionalItems",
|
|
5907
5974
|
"additionalProperties",
|
|
5908
5975
|
"not",
|
|
5909
5976
|
"contains",
|
|
@@ -5913,6 +5980,184 @@ const SCHEMA_CHILD_SINGLE = [
|
|
|
5913
5980
|
"propertyNames"
|
|
5914
5981
|
];
|
|
5915
5982
|
/**
|
|
5983
|
+
* Keywords whose value is a MAP whose values may be schemas, where only SOME of
|
|
5984
|
+
* those values are schemas at all (issue #253, second report).
|
|
5985
|
+
*
|
|
5986
|
+
* `dependencies` is draft-4's spelling of two different 2020-12 keywords: an
|
|
5987
|
+
* ARRAY value is `dependentRequired`, an OBJECT value is `dependentSchemas`.
|
|
5988
|
+
* Its object values are therefore descended into like `dependentSchemas`, so a
|
|
5989
|
+
* draft-4 leftover nested inside one is still rewritten.
|
|
5990
|
+
*
|
|
5991
|
+
* Measured raw: `dependencies` itself is ACCEPTED by the upstream, so nothing
|
|
5992
|
+
* here is a refusal fix — it is traversal, so that the rewrites this module owns
|
|
5993
|
+
* reach inside the keyword instead of stopping at it.
|
|
5994
|
+
*/
|
|
5995
|
+
const SCHEMA_CHILD_DEPENDENCIES = ["dependencies"];
|
|
5996
|
+
/**
|
|
5997
|
+
* Repair keyword values whose TYPE the upstream will not take (issue #253).
|
|
5998
|
+
*
|
|
5999
|
+
* THE SECOND REPORT ON #253 WAS A DIFFERENT BUG. The first round migrated
|
|
6000
|
+
* draft-4 SPELLINGS (tuple `items`, boolean exclusive bounds, string `required`,
|
|
6001
|
+
* external `$ref`). The reporter then supplied three more draft-4 spellings
|
|
6002
|
+
* (`type` arrays, `dependencies`, `additionalItems`) and a patch — but all three
|
|
6003
|
+
* were measured ACCEPTED, raw, on `deepseek-v4.1-flash`, so migrating them fixes
|
|
6004
|
+
* nothing. What was actually rejected, measured one keyword at a time against a
|
|
6005
|
+
* raw body, is a class of TYPE errors in the definition itself: 36 of them, in
|
|
6006
|
+
* every position. `title: 1`, `minimum: "0"`, `examples: "x"`, `pattern: 123`,
|
|
6007
|
+
* `allOf: {}`, `additionalProperties: "x"`, `uniqueItems: "true"` — each answers
|
|
6008
|
+
* `11129`, and each answers 200 once the value has the type the keyword takes.
|
|
6009
|
+
*
|
|
6010
|
+
* WHY REPAIR RATHER THAN REPORT. The upstream's own sentence names no keyword
|
|
6011
|
+
* and no tool, and the definition often comes from a third-party bundle or MCP
|
|
6012
|
+
* server the user did not write. Dropping the offending value is what keeps the
|
|
6013
|
+
* tool USABLE: every keyword here is an annotation or a constraint, never
|
|
6014
|
+
* structure — no `properties` map, no `required` list, no schema-valued keyword
|
|
6015
|
+
* is touched — so removing a malformed one cannot change which arguments the
|
|
6016
|
+
* tool accepts. It only stops the definition from being refused outright.
|
|
6017
|
+
*
|
|
6018
|
+
* THE ALTERNATIVE WAS CONSIDERED AND REJECTED: dropping the whole TOOL. It is
|
|
6019
|
+
* simpler, but it silently removes a capability the user installed, and the
|
|
6020
|
+
* model then invents calls to a tool that no longer exists.
|
|
6021
|
+
*
|
|
6022
|
+
* Only values that are WRONG are touched. A schema already carrying correct
|
|
6023
|
+
* types leaves this function byte-identical, which keeps the prompt prefix
|
|
6024
|
+
* stable for caching.
|
|
6025
|
+
*/
|
|
6026
|
+
function normalizeMetaSchemaTypes(schema) {
|
|
6027
|
+
for (const key of SCHEMA_STRING_KEYWORDS) {
|
|
6028
|
+
const value = schema[key];
|
|
6029
|
+
if (value !== void 0 && typeof value !== "string") delete schema[key];
|
|
6030
|
+
}
|
|
6031
|
+
for (const key of SCHEMA_NUMBER_KEYWORDS) {
|
|
6032
|
+
const value = schema[key];
|
|
6033
|
+
if (value !== void 0 && (typeof value !== "number" || !Number.isFinite(value))) delete schema[key];
|
|
6034
|
+
}
|
|
6035
|
+
for (const key of SCHEMA_BOOLEAN_KEYWORDS) {
|
|
6036
|
+
const value = schema[key];
|
|
6037
|
+
if (value !== void 0 && typeof value !== "boolean") delete schema[key];
|
|
6038
|
+
}
|
|
6039
|
+
for (const key of SCHEMA_LIST_KEYWORDS) {
|
|
6040
|
+
const value = schema[key];
|
|
6041
|
+
if (value === void 0) continue;
|
|
6042
|
+
if (!Array.isArray(value) || value.length === 0) delete schema[key];
|
|
6043
|
+
}
|
|
6044
|
+
for (const key of SCHEMA_STRING_LIST_KEYWORDS) {
|
|
6045
|
+
const value = schema[key];
|
|
6046
|
+
if (value !== void 0 && !Array.isArray(value)) delete schema[key];
|
|
6047
|
+
}
|
|
6048
|
+
for (const key of SCHEMA_CHILD_SINGLE) {
|
|
6049
|
+
const value = schema[key];
|
|
6050
|
+
if (value === void 0) continue;
|
|
6051
|
+
if (typeof value === "boolean") continue;
|
|
6052
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) delete schema[key];
|
|
6053
|
+
}
|
|
6054
|
+
normalizeTypeKeyword(schema);
|
|
6055
|
+
}
|
|
6056
|
+
/**
|
|
6057
|
+
* Repair `type`, keeping every member the upstream would have taken (issue #253).
|
|
6058
|
+
*
|
|
6059
|
+
* Measured: `type: ["string","null"]` is ACCEPTED as sent, and so is
|
|
6060
|
+
* `dependencies`; only an unknown member (`type: "thing"`) or an empty array is
|
|
6061
|
+
* refused. So this keeps valid members instead of rewriting the array into
|
|
6062
|
+
* `oneOf`, which would be a much larger change to a schema the upstream already
|
|
6063
|
+
* understands.
|
|
6064
|
+
*/
|
|
6065
|
+
function normalizeTypeKeyword(schema) {
|
|
6066
|
+
const type = schema["type"];
|
|
6067
|
+
if (type === void 0) return;
|
|
6068
|
+
const valid = (entry) => typeof entry === "string" && JSON_SCHEMA_TYPES.has(entry);
|
|
6069
|
+
if (typeof type === "string") {
|
|
6070
|
+
if (!valid(type)) delete schema["type"];
|
|
6071
|
+
return;
|
|
6072
|
+
}
|
|
6073
|
+
if (!Array.isArray(type)) {
|
|
6074
|
+
delete schema["type"];
|
|
6075
|
+
return;
|
|
6076
|
+
}
|
|
6077
|
+
const kept = type.filter(valid);
|
|
6078
|
+
if (kept.length === 0) {
|
|
6079
|
+
delete schema["type"];
|
|
6080
|
+
return;
|
|
6081
|
+
}
|
|
6082
|
+
if (kept.length === type.length) return;
|
|
6083
|
+
schema["type"] = kept.length === 1 ? kept[0] : kept;
|
|
6084
|
+
}
|
|
6085
|
+
/** The `type` values JSON Schema defines. */
|
|
6086
|
+
const JSON_SCHEMA_TYPES = /* @__PURE__ */ new Set([
|
|
6087
|
+
"array",
|
|
6088
|
+
"boolean",
|
|
6089
|
+
"integer",
|
|
6090
|
+
"null",
|
|
6091
|
+
"number",
|
|
6092
|
+
"object",
|
|
6093
|
+
"string"
|
|
6094
|
+
]);
|
|
6095
|
+
/** Keywords whose value must be a string. */
|
|
6096
|
+
const SCHEMA_STRING_KEYWORDS = [
|
|
6097
|
+
"title",
|
|
6098
|
+
"description",
|
|
6099
|
+
"pattern",
|
|
6100
|
+
"format",
|
|
6101
|
+
"$comment",
|
|
6102
|
+
"contentMediaType",
|
|
6103
|
+
"contentEncoding",
|
|
6104
|
+
"$id",
|
|
6105
|
+
"$schema",
|
|
6106
|
+
"$anchor",
|
|
6107
|
+
"$dynamicAnchor",
|
|
6108
|
+
"$dynamicRef"
|
|
6109
|
+
];
|
|
6110
|
+
/** Keywords whose value must be a number. */
|
|
6111
|
+
const SCHEMA_NUMBER_KEYWORDS = [
|
|
6112
|
+
"minimum",
|
|
6113
|
+
"maximum",
|
|
6114
|
+
"exclusiveMinimum",
|
|
6115
|
+
"exclusiveMaximum",
|
|
6116
|
+
"multipleOf",
|
|
6117
|
+
"minLength",
|
|
6118
|
+
"maxLength",
|
|
6119
|
+
"minItems",
|
|
6120
|
+
"maxItems",
|
|
6121
|
+
"minProperties",
|
|
6122
|
+
"maxProperties",
|
|
6123
|
+
"minContains",
|
|
6124
|
+
"maxContains"
|
|
6125
|
+
];
|
|
6126
|
+
/** Keywords whose value must be a boolean. */
|
|
6127
|
+
const SCHEMA_BOOLEAN_KEYWORDS = [
|
|
6128
|
+
"uniqueItems",
|
|
6129
|
+
"readOnly",
|
|
6130
|
+
"writeOnly",
|
|
6131
|
+
"deprecated"
|
|
6132
|
+
];
|
|
6133
|
+
/**
|
|
6134
|
+
* Keywords whose value must be a NON-EMPTY array of schemas.
|
|
6135
|
+
*
|
|
6136
|
+
* Measured: an empty `allOf` / `anyOf` / `oneOf` / `prefixItems` is refused
|
|
6137
|
+
* (`11129`), while an empty `required` / `enum` / `examples` is ACCEPTED. Only
|
|
6138
|
+
* these four are repaired, so a legal empty `required: []` keeps its bytes —
|
|
6139
|
+
* which also keeps 5.24.2's "empty required string becomes `[]`" behaviour
|
|
6140
|
+
* intact instead of turning it into an absent keyword.
|
|
6141
|
+
*/
|
|
6142
|
+
const SCHEMA_LIST_KEYWORDS = [
|
|
6143
|
+
"allOf",
|
|
6144
|
+
"anyOf",
|
|
6145
|
+
"oneOf",
|
|
6146
|
+
"prefixItems"
|
|
6147
|
+
];
|
|
6148
|
+
/**
|
|
6149
|
+
* Keywords whose value must be an array, where an EMPTY array is legal.
|
|
6150
|
+
*
|
|
6151
|
+
* `enum` and `examples` are accepted empty and NOT accepted as a scalar;
|
|
6152
|
+
* `required` is accepted empty. Split from {@link SCHEMA_LIST_KEYWORDS} because
|
|
6153
|
+
* that one also drops empties, which is wrong for these.
|
|
6154
|
+
*/
|
|
6155
|
+
const SCHEMA_STRING_LIST_KEYWORDS = [
|
|
6156
|
+
"required",
|
|
6157
|
+
"enum",
|
|
6158
|
+
"examples"
|
|
6159
|
+
];
|
|
6160
|
+
/**
|
|
5916
6161
|
* Convert draft-4's tuple `items` into the 2020-12 spelling.
|
|
5917
6162
|
*
|
|
5918
6163
|
* A tuple `items` is a LIST; the modern spec splits it into `prefixItems` (the
|
|
@@ -5930,8 +6175,17 @@ const SCHEMA_CHILD_SINGLE = [
|
|
|
5930
6175
|
function normalizeItems(schema) {
|
|
5931
6176
|
const items = schema["items"];
|
|
5932
6177
|
if (!Array.isArray(items)) return;
|
|
6178
|
+
if (items.length === 0) {
|
|
6179
|
+
delete schema["items"];
|
|
6180
|
+
delete schema["prefixItems"];
|
|
6181
|
+
delete schema["additionalItems"];
|
|
6182
|
+
schema["items"] = {};
|
|
6183
|
+
return;
|
|
6184
|
+
}
|
|
5933
6185
|
if (schema["prefixItems"] === void 0) schema["prefixItems"] = items;
|
|
5934
|
-
schema["
|
|
6186
|
+
const tail = schema["additionalItems"];
|
|
6187
|
+
schema["items"] = typeof tail === "object" && tail !== null && !Array.isArray(tail) ? tail : {};
|
|
6188
|
+
delete schema["additionalItems"];
|
|
5935
6189
|
}
|
|
5936
6190
|
/**
|
|
5937
6191
|
* Rewrite a draft-4 BOOLEAN exclusive bound into the numeric form.
|
|
@@ -10864,7 +11118,7 @@ function describeRosterSeenPayload(raw) {
|
|
|
10864
11118
|
//#endregion
|
|
10865
11119
|
//#region src/version.ts
|
|
10866
11120
|
/** The npm package version this build was produced from. */
|
|
10867
|
-
const WORKBUDDY_CONNECT_VERSION = "5.24.
|
|
11121
|
+
const WORKBUDDY_CONNECT_VERSION = "5.24.5";
|
|
10868
11122
|
//#endregion
|
|
10869
11123
|
//#region src/host-heartbeat.ts
|
|
10870
11124
|
/**
|
|
@@ -11098,4 +11352,4 @@ async function clearHostHeartbeat(owner) {
|
|
|
11098
11352
|
if (current === owner.contents) await rm(owner.path, { force: true });
|
|
11099
11353
|
}
|
|
11100
11354
|
//#endregion
|
|
11101
|
-
export {
|
|
11355
|
+
export { CREDENTIAL_REJECTED_CODE as $, isWatermarkFreeImageModel as $t, withoutRouters as A, workbuddyAppExecutableCandidates as An, REFUSES_OFF_MODEL_IDS as At, defaultDesktopAuthPath as B, parseSupportedSecondsRange as Bt, setDeviceMode as C, findWorkbuddyAppExecutableWithSource as Cn, regionOf as Ct, applyContextBudgets as D, macosNestedAppBundles as Dn, attachBusyLevels as Dt, WorkBuddyCatalog as E, macosBundleExecutable as En, toolSchemaRejectAdvice as Et, WorkBuddyCredentialStore as F, recordRefusal as Ft, parseWorkBuddyAuth as G, IMAGE_TAG_TEXT_TO_IMAGE as Gt, isEncryptedCredentialError as H, resolveVideoParams as Ht, WorkBuddyEncryptedCredentialError as I, withEffectiveOff as It, workbuddyOwnAuthPath as J, imageDataUrl as Jt, preferredAccountName as K, MAX_INPUT_IMAGE_BYTES as Kt, authFileName as L, VIDEO_TAG_IMAGE_TO_VIDEO as Lt, WORKBUDDY_AUTH_FILENAME as M, resolveDshHome as Mn, lastRefusalFor as Mt, WORKBUDDY_AUTH_FILE_ENV as N, withFileLock as Nn, offDefaultFor as Nt, deriveCatalog as O, openEncryptedField as On, promoBadgeTone as Ot, WORKBUDDY_VAULT_DIRNAME as P, writeFileAtomic as Pn, offRefused as Pt, CONTEXT_OVERFLOW_MARKER as Q, isBareBase64Image as Qt, defaultDesktopAuthCandidates as R, VIDEO_TAG_TEXT_TO_VIDEO as Rt, saveDeviceSdkSettings as S, findWorkbuddyAppExecutable as Sn, prepareChatBody as St, FALLBACK_WORKBUDDY_MODELS_GLOBAL as T, isWorkbuddyBundle as Tn, rewriteSessionTitleModel as Tt, isVaultAccountId as U, IMAGE_SIZE_LIMITS_WIDE as Ut, hasEncryptedCredentialFields as V, pickVideoModel as Vt, legacyWorkbuddyOwnAuthPath as W, IMAGE_TAG_IMAGE_TO_IMAGE as Wt, APP_VERSION as X, imageModelChoices as Xt, workbuddyVaultDir as Y, imageMimeForPath as Yt, BODY_OVERSIZE_MARKER as Z, imageSizeLimitsOf as Zt, createDeviceProfileLookup as _, WORKBUDDY_APP_EXECUTABLE_ENV as _n, openingEvidenceOfBody as _t, readHostHeartbeat as a, pruneTempDir as an, classifyUpstreamError as at, readDeviceSettings as b, deriveAtRestKeyId as bn, parseUpstreamModel as bt, WORKBUDDY_CONNECT_VERSION as c, nativeModalityOf as cn, forceNeutralHead as ct, rosterSeenPath as d, ensureDeviceSalt as dn, isConversationIdGateBody as dt, parseImageDataUrl as en, DEFAULT_WIRE_PROFILE as et, WORKBUDDY_CN_BASE_ENV as f, readDeviceSalt as fn, isCredentialRejectedError as ft, createTuringSdk as g, protectCredentialDirectory as gn, modelIdOfBody as gt, createDeviceSdkPort as h, inspectCredentialDirectory as hn, knownRegionOf as ht, processStartTimeMs as i, queueNoticeText as in, channelGateMemberOf as it, ENCRYPTED_CREDENTIAL_CODE as j, hostPeersInfo as jn, defaultOffModelIds as jt, fallbackModelsFor as k, readAtRestKey as kn, selectPromoBadge as kt, createFileRosterSeenStore as l, WORKBUDDY_DEVICE_TOKEN_FILE_ENV as ln, isBodyOversizeRefusal as lt, piAiRuntimeInfo as m, isDeviceId as mn, isToolSchemaRejectBody as mt, clearHostHeartbeat as n, sniffImageMime as nn, WorkBuddyCredentialRejectedError as nt, workbuddyHostHeartbeatPath as o, NATIVE_MODALITY_BY_MODEL_ID as on, declaredTools as ot, resolveCnGateway as p, deriveDeviceId as pn, isFirstMessageGateBody as pt, workbuddyAccountId as q, WorkBuddyImageError as qt, isHeartbeatProcessAlive as r, parseQueueAnswer as rn, WorkBuddyUpstreamClient as rt, writeHostHeartbeat as s, imageDefaultFor as sn, describeRequestHeaderNames as st, WORKBUDDY_HOST_HEARTBEAT_FILENAME as t, pickMediaModel as tn, WORKBUDDY_FALLBACK_SYSTEM_PROMPT as tt, describeRosterSeenPayload as u, readDeviceTokenFile as un, isContextTooLongBody as ut, describeDerivedDevices as v, clearAtRestKeyCache as vn, parseCreditMultiplier as vt, FALLBACK_WORKBUDDY_MODELS as w, isEncryptedFieldWrapper as wn, requestEvidenceOf as wt, saveDeviceProfile as x, fetchAtRestKeyPayload as xn, perturbChannelFingerprints as xt, isDeviceMode as y, deriveAtRestKey as yn, parseReasoning as yt, defaultDesktopAuthDirs as z, WorkBuddyVideoError as zt };
|
package/lib/index.d.ts
CHANGED
|
@@ -2711,10 +2711,29 @@ interface ContextRescue {
|
|
|
2711
2711
|
*
|
|
2712
2712
|
* @param sessionId - session whose history should be folded.
|
|
2713
2713
|
* @param window - context window of the route that just overflowed.
|
|
2714
|
+
* @param cause - what refused the request (issue #258).
|
|
2715
|
+
*
|
|
2716
|
+
* `'window'` (the default) is the token overflow this rescue was written
|
|
2717
|
+
* for: the target is a fraction of the model's declared window.
|
|
2718
|
+
*
|
|
2719
|
+
* `'body-bytes'` is a request refused because its SERIALIZED BODY exceeded
|
|
2720
|
+
* a byte ceiling some component enforces. The target is then a fraction of
|
|
2721
|
+
* the CURRENT measurement, never of the window — see
|
|
2722
|
+
* {@link BODY_OVERSIZE_TARGET_FRACTION} for why the window target would
|
|
2723
|
+
* silently fold nothing.
|
|
2724
|
+
*
|
|
2714
2725
|
* @returns whether any history was folded.
|
|
2715
2726
|
*/
|
|
2716
|
-
rescue(sessionId: string, window: number): Promise<boolean>;
|
|
2727
|
+
rescue(sessionId: string, window: number, cause?: RescueCause): Promise<boolean>;
|
|
2717
2728
|
}
|
|
2729
|
+
/**
|
|
2730
|
+
* What refused the request.
|
|
2731
|
+
*
|
|
2732
|
+
* Only two values, and the distinction is not cosmetic: it decides which number
|
|
2733
|
+
* the fold target is derived from, and getting it wrong makes the rescue a
|
|
2734
|
+
* no-op rather than a wrong-but-visible action (see the fraction constant).
|
|
2735
|
+
*/
|
|
2736
|
+
type RescueCause = 'window' | 'body-bytes';
|
|
2718
2737
|
//#endregion
|
|
2719
2738
|
//#region src/adapter.d.ts
|
|
2720
2739
|
/** Provider route this bundle owns for the domestic (CN) gateway. */
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $t as
|
|
1
|
+
import { $ as CREDENTIAL_REJECTED_CODE, $t as isWatermarkFreeImageModel, A as withoutRouters, An as workbuddyAppExecutableCandidates, At as REFUSES_OFF_MODEL_IDS, B as defaultDesktopAuthPath, Bt as parseSupportedSecondsRange, C as setDeviceMode, Ct as regionOf, D as applyContextBudgets, Dn as macosNestedAppBundles, Dt as attachBusyLevels, E as WorkBuddyCatalog, En as macosBundleExecutable, Et as toolSchemaRejectAdvice, F as WorkBuddyCredentialStore, Ft as recordRefusal, G as parseWorkBuddyAuth, Gt as IMAGE_TAG_TEXT_TO_IMAGE, H as isEncryptedCredentialError, Ht as resolveVideoParams, I as WorkBuddyEncryptedCredentialError, It as withEffectiveOff, J as workbuddyOwnAuthPath, Jt as imageDataUrl, K as preferredAccountName, Kt as MAX_INPUT_IMAGE_BYTES, L as authFileName, Lt as VIDEO_TAG_IMAGE_TO_VIDEO, M as WORKBUDDY_AUTH_FILENAME, Mn as resolveDshHome, Mt as lastRefusalFor, N as WORKBUDDY_AUTH_FILE_ENV, Nn as withFileLock, Nt as offDefaultFor, O as deriveCatalog, On as openEncryptedField, Ot as promoBadgeTone, Pn as writeFileAtomic, Pt as offRefused, Q as CONTEXT_OVERFLOW_MARKER, Qt as isBareBase64Image, R as defaultDesktopAuthCandidates, Rt as VIDEO_TAG_TEXT_TO_VIDEO, S as saveDeviceSdkSettings, Sn as findWorkbuddyAppExecutable, St as prepareChatBody, T as FALLBACK_WORKBUDDY_MODELS_GLOBAL, Tn as isWorkbuddyBundle, Tt as rewriteSessionTitleModel, U as isVaultAccountId, Ut as IMAGE_SIZE_LIMITS_WIDE, V as hasEncryptedCredentialFields, Vt as pickVideoModel, W as legacyWorkbuddyOwnAuthPath, Wt as IMAGE_TAG_IMAGE_TO_IMAGE, X as APP_VERSION, Xt as imageModelChoices, Yt as imageMimeForPath, Z as BODY_OVERSIZE_MARKER, Zt as imageSizeLimitsOf, _ as createDeviceProfileLookup, _n as WORKBUDDY_APP_EXECUTABLE_ENV, _t as openingEvidenceOfBody, a as readHostHeartbeat, an as pruneTempDir, at as classifyUpstreamError, b as readDeviceSettings, bn as deriveAtRestKeyId, bt as parseUpstreamModel, c as WORKBUDDY_CONNECT_VERSION, cn as nativeModalityOf, ct as forceNeutralHead, dt as isConversationIdGateBody, en as parseImageDataUrl, ft as isCredentialRejectedError, g as createTuringSdk, gt as modelIdOfBody, h as createDeviceSdkPort, ht as knownRegionOf, i as processStartTimeMs, in as queueNoticeText, it as channelGateMemberOf, j as ENCRYPTED_CREDENTIAL_CODE, jt as defaultOffModelIds, k as fallbackModelsFor, kn as readAtRestKey, kt as selectPromoBadge, l as createFileRosterSeenStore, lt as isBodyOversizeRefusal, m as piAiRuntimeInfo, mn as isDeviceId, mt as isToolSchemaRejectBody, n as clearHostHeartbeat, nn as sniffImageMime, nt as WorkBuddyCredentialRejectedError, o as workbuddyHostHeartbeatPath, on as NATIVE_MODALITY_BY_MODEL_ID, ot as declaredTools, p as resolveCnGateway, pt as isFirstMessageGateBody, q as workbuddyAccountId, qt as WorkBuddyImageError, r as isHeartbeatProcessAlive, rn as parseQueueAnswer, rt as WorkBuddyUpstreamClient, s as writeHostHeartbeat, sn as imageDefaultFor, t as WORKBUDDY_HOST_HEARTBEAT_FILENAME, tn as pickMediaModel, tt as WORKBUDDY_FALLBACK_SYSTEM_PROMPT, ut as isContextTooLongBody, v as describeDerivedDevices, vn as clearAtRestKeyCache, vt as parseCreditMultiplier, w as FALLBACK_WORKBUDDY_MODELS, wn as isEncryptedFieldWrapper, wt as requestEvidenceOf, x as saveDeviceProfile, xn as fetchAtRestKeyPayload, xt as perturbChannelFingerprints, y as isDeviceMode, yn as deriveAtRestKey, yt as parseReasoning, z as defaultDesktopAuthDirs, zt as WorkBuddyVideoError } from "./host-heartbeat-COoAT4ZR.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";
|
|
@@ -2131,6 +2131,28 @@ function withLegacyContext(api, generation, identity = WORKBUDDY_MODEL_IDENTITY,
|
|
|
2131
2131
|
};
|
|
2132
2132
|
}
|
|
2133
2133
|
/**
|
|
2134
|
+
* Which rescue, if any, an error event calls for (issue #258).
|
|
2135
|
+
*
|
|
2136
|
+
* ALL of an error message's text is searched, in the shapes pi-ai hands over:
|
|
2137
|
+
* `errorMessage` on the assistant message is the one that matters, but a
|
|
2138
|
+
* provider that fills only `content` or throws a bare string has been measured,
|
|
2139
|
+
* so the reader is deliberately tolerant. The scan never throws: a message with
|
|
2140
|
+
* no strings in it simply calls for no rescue.
|
|
2141
|
+
*
|
|
2142
|
+
* `'window'` wins when both readings somehow apply, because the token overflow
|
|
2143
|
+
* is the one this rescue was originally written for and its target is the more
|
|
2144
|
+
* conservative of the two.
|
|
2145
|
+
*/
|
|
2146
|
+
function rescueCauseOf(error) {
|
|
2147
|
+
if (isContextOverflow(error)) return "window";
|
|
2148
|
+
const text = [
|
|
2149
|
+
typeof error.errorMessage === "string" ? error.errorMessage : "",
|
|
2150
|
+
typeof error.content === "string" ? error.content : "",
|
|
2151
|
+
...Array.isArray(error.content) ? error.content.map((part) => typeof part === "object" && part !== null && typeof part.text === "string" ? part.text : "") : []
|
|
2152
|
+
].join(" ");
|
|
2153
|
+
return isBodyOversizeRefusal(text) ? "body-bytes" : void 0;
|
|
2154
|
+
}
|
|
2155
|
+
/**
|
|
2134
2156
|
* Layer the host-side context-overflow rescue onto a provider's streams.
|
|
2135
2157
|
*
|
|
2136
2158
|
* pi-ai reports a provider failure as an `error` event rather than a throw, so
|
|
@@ -2159,7 +2181,10 @@ function withContextRescue(api, resolve) {
|
|
|
2159
2181
|
for await (const event of source) {
|
|
2160
2182
|
if (event.type === "done") final = event.message;
|
|
2161
2183
|
if (event.type === "error") final = event.error;
|
|
2162
|
-
if (event.type === "error"
|
|
2184
|
+
if (event.type === "error") {
|
|
2185
|
+
const cause = rescueCauseOf(event.error);
|
|
2186
|
+
if (cause !== void 0) await rescue.rescue(sessionId, window, cause);
|
|
2187
|
+
}
|
|
2163
2188
|
out.push(event);
|
|
2164
2189
|
}
|
|
2165
2190
|
out.end(final);
|
|
@@ -2520,6 +2545,30 @@ function createWorkBuddyAdapter(options) {
|
|
|
2520
2545
|
const CHUNK_FRACTION = .35;
|
|
2521
2546
|
/** Post-fold measurement target: comfortably below the window the route allows. */
|
|
2522
2547
|
const TARGET_FRACTION = .6;
|
|
2548
|
+
/**
|
|
2549
|
+
* Post-fold target for a BYTE refusal, as a fraction of the CURRENT measurement
|
|
2550
|
+
* (issue #258).
|
|
2551
|
+
*
|
|
2552
|
+
* WHY NOT THE WINDOW. The ceiling that refuses these requests is in BYTES; the
|
|
2553
|
+
* measurement this rescue reads is in TOKENS. A reporter measured the crossing
|
|
2554
|
+
* point at roughly 150k tokens for an 8 MiB ceiling — while the model declares a
|
|
2555
|
+
* 1,000,000-token window, so `window * 0.6` is 600,000. The first measurement
|
|
2556
|
+
* then already satisfies `totalTokens <= target`, the loop returns on its first
|
|
2557
|
+
* pass, and the identical oversized body is re-sent: a rescue that reports
|
|
2558
|
+
* success while doing nothing is worse than one that reports failure.
|
|
2559
|
+
*
|
|
2560
|
+
* Deriving the target from the measurement itself avoids needing to know the
|
|
2561
|
+
* ceiling at all: one fold always removes at least 10% of what is there, so the
|
|
2562
|
+
* loop cannot be trivially satisfied, and repeated rounds converge on whatever
|
|
2563
|
+
* the ceiling happens to be.
|
|
2564
|
+
*
|
|
2565
|
+
* 0.9 rather than something smaller on purpose: the ceiling is unknown, so
|
|
2566
|
+
* folding aggressively would throw away far more history than necessary on a
|
|
2567
|
+
* request that only just crossed it. 10% per round, up to {@link MAX_ROUNDS},
|
|
2568
|
+
* covers a 57% reduction — enough for a body that overshot by a few percent,
|
|
2569
|
+
* which is the measured shape (8,401,132 B against a 8,388,608 B ceiling).
|
|
2570
|
+
*/
|
|
2571
|
+
const BODY_OVERSIZE_TARGET_FRACTION = .9;
|
|
2523
2572
|
/** A session is never folded more than this many times by one rescue. */
|
|
2524
2573
|
const MAX_ROUNDS = 8;
|
|
2525
2574
|
/** How many times one chunk may shrink its tail edge before giving up. */
|
|
@@ -2534,11 +2583,11 @@ const FOLD_TIMEOUT_MS = 18e4;
|
|
|
2534
2583
|
*/
|
|
2535
2584
|
function createContextRescue(resolve) {
|
|
2536
2585
|
const inflight = /* @__PURE__ */ new Set();
|
|
2537
|
-
return { async rescue(sessionId, window) {
|
|
2586
|
+
return { async rescue(sessionId, window, cause = "window") {
|
|
2538
2587
|
if (inflight.has(sessionId)) return false;
|
|
2539
2588
|
inflight.add(sessionId);
|
|
2540
2589
|
try {
|
|
2541
|
-
return await foldUntilFits(resolve(), sessionId, window);
|
|
2590
|
+
return await foldUntilFits(resolve(), sessionId, window, cause);
|
|
2542
2591
|
} catch (error) {
|
|
2543
2592
|
resolve().log?.("dsh-connect-workbuddy: context rescue failed", error);
|
|
2544
2593
|
return false;
|
|
@@ -2547,16 +2596,29 @@ function createContextRescue(resolve) {
|
|
|
2547
2596
|
}
|
|
2548
2597
|
} };
|
|
2549
2598
|
}
|
|
2550
|
-
|
|
2599
|
+
/**
|
|
2600
|
+
* The fold target for one rescue, in the MEASUREMENT's own unit (tokens).
|
|
2601
|
+
*
|
|
2602
|
+
* Split out and pure so the unit mismatch that caused issue #258 is testable
|
|
2603
|
+
* without a host: the two causes derive the same number from two different
|
|
2604
|
+
* quantities, and only one of them can be trivially satisfied by the first
|
|
2605
|
+
* measurement.
|
|
2606
|
+
*/
|
|
2607
|
+
function rescueTargetOf(cause, window, measuredTokens) {
|
|
2608
|
+
if (cause === "body-bytes") return Math.max(1, Math.floor(measuredTokens * BODY_OVERSIZE_TARGET_FRACTION));
|
|
2609
|
+
return Math.max(1, Math.floor(window * TARGET_FRACTION));
|
|
2610
|
+
}
|
|
2611
|
+
async function foldUntilFits(deps, sessionId, window, cause) {
|
|
2551
2612
|
const { meter, compaction, agents } = deps;
|
|
2552
2613
|
if (meter === void 0 || compaction === void 0 || agents === void 0) return false;
|
|
2553
2614
|
const agent = agents.get(sessionId);
|
|
2554
2615
|
if (agent === void 0) return false;
|
|
2555
|
-
|
|
2616
|
+
let target = NaN;
|
|
2556
2617
|
let foldedAny = false;
|
|
2557
2618
|
let previous = Number.POSITIVE_INFINITY;
|
|
2558
2619
|
for (let round = 0; round < MAX_ROUNDS; round += 1) {
|
|
2559
2620
|
const measurement = meter.measure(agent.session);
|
|
2621
|
+
if (round === 0) target = rescueTargetOf(cause, window, measurement.totalTokens);
|
|
2560
2622
|
if (measurement.totalTokens <= target) return foldedAny;
|
|
2561
2623
|
if (measurement.totalTokens >= previous) return foldedAny;
|
|
2562
2624
|
previous = measurement.totalTokens;
|
|
@@ -6157,7 +6219,8 @@ function createWorkBuddyShim(options) {
|
|
|
6157
6219
|
const toolSchemaRefused = result.kind === "client" && isToolSchemaRejectBody(result.message);
|
|
6158
6220
|
const receipt = refusedTier ?? (toolSchemaRefused ? toolSchemaRejectAdvice() : void 0) ?? detail?.tips ?? detail?.displayMsg ?? clippedUpstreamText(result.message, 400);
|
|
6159
6221
|
const advice = refusedTier !== void 0 ? "这不是账号或网络问题:该模型实测拒绝「off」推理档位,请到模型卡片里取消该行的「可关闭思考」勾选后重试" : toolSchemaRefused ? "按上面列出的写法检查工具定义;换模型只是绕开,不会修好它" : result.kind === "client" ? "该请求被上游按参数拒绝:与网络、账号、额度都无关,换账号也不会改变结果,请按上面的提示调整后重试" : shortfall === void 0 ? "" : "建议换一个模型继续,或稍后等待该账号的额度恢复";
|
|
6160
|
-
const
|
|
6222
|
+
const bodyOversize = isBodyOversizeRefusal(result.message);
|
|
6223
|
+
const body = `${isContextTooLongBody(result.message) ? `${CONTEXT_OVERFLOW_MARKER}。` : bodyOversize ? `${BODY_OVERSIZE_MARKER}。` : ""}${advice === "" ? receipt : `${receipt.replace(/[。.]$/u, "")}。${advice}`}`;
|
|
6161
6224
|
writeOpenAIError(res, KIND_STATUS[result.kind], result.kind, `workbuddy 上游失败:${failoverReasonText(result)}(http ${result.status})${note}${why}${stamp}。${body}`, hostErrorCode(result.kind));
|
|
6162
6225
|
return;
|
|
6163
6226
|
}
|
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.
|
|
5
|
+
"version": "5.24.5",
|
|
6
6
|
"author": "dingminhua",
|
|
7
7
|
"copyright": "Copyright (c) 2026 LaoDing",
|
|
8
8
|
"license": "MIT",
|