dsh-connect-workbuddy 5.23.1 → 5.24.2
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 +180 -0
- package/README.en.md +29 -3
- package/README.md +30 -4
- package/lib/bin.js +1 -1
- package/lib/{host-heartbeat-BfSlXO19.js → host-heartbeat-Q85k2yEL.js} +292 -7
- package/lib/index.d.ts +16 -5
- package/lib/index.js +12 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,185 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 5.24.2 (2026-11-14)
|
|
4
|
+
|
|
5
|
+
> 版本号是 **patch**:修一处「某些模型完全不可用」的请求字节问题,无新增配置项、无接口变化。
|
|
6
|
+
> 来自 issue #253。
|
|
7
|
+
|
|
8
|
+
### 修复:`deepseek-v4.1-flash` 等 8 个模型在 agent 模式下必定 400
|
|
9
|
+
|
|
10
|
+
报告者的现象是:选 `deepseek-v4.1-flash` 发**一句普通消息**(不提工具)就必报
|
|
11
|
+
`400 / code 11129 / 工具的参数结构不符合当前模型要求`,换账号、重连、重装都不变;同账号换
|
|
12
|
+
`hy3`、`deepseek-v4-pro` 之外的模型又正常。
|
|
13
|
+
|
|
14
|
+
根因不在插件丢没丢 `tools`,也不在 `$ref`——**这两条都是排查过程中的错误结论,已各自被实测推翻**:
|
|
15
|
+
|
|
16
|
+
- 「插件从不处理 tools」不成立:`normalizeToolChoice` 早就会在 `tool_choice: none` 时删掉 `tools`;
|
|
17
|
+
- 「上游不认 `$ref`」也不成立:宿主 `docs/tool-catalog.md` 里 `stagehand_extract` 那份**递归
|
|
18
|
+
`$defs`** schema 实测 200,宿主的**全部 75 个工具**一起发也 200。
|
|
19
|
+
|
|
20
|
+
真正被拒的是 DSH 宿主(zod 生成)与手写 MCP schema 会带出的 **draft-4 遗留写法**,逐条实测如下:
|
|
21
|
+
|
|
22
|
+
| 写法 | 上游怎么答 | 改写后 |
|
|
23
|
+
| --- | --- | --- |
|
|
24
|
+
| `items` 写成**元组数组**(draft-4)`items: [{type:'string'}]` | 11129(DeepSeek)/ 11133(GLM、Kimi、MiMo) | `prefixItems: […]` + `items: {}` |
|
|
25
|
+
| `exclusiveMinimum` / `exclusiveMaximum` 写成**布尔**(draft-4) | 11129 | 由同级的 `minimum` / `maximum` 推出的**数值**形式 |
|
|
26
|
+
| `required` 写成**字符串** | 11129 | 单元素数组 |
|
|
27
|
+
| `required` 数组含**重复项** | 11129 | 去重 |
|
|
28
|
+
| **外部** `$ref`(`https://…`、`//host/…`) | 11129 | 删掉该引用 |
|
|
29
|
+
|
|
30
|
+
`prepareChatBody` 现在会在发出去之前递归改写这五种写法。用同一份请求体逐模型验证(2026-11-14,
|
|
31
|
+
CN 网关,本构建自己的凭据):
|
|
32
|
+
|
|
33
|
+
| 模型 | 修复前 | 修复后 |
|
|
34
|
+
| --- | --- | --- |
|
|
35
|
+
| `deepseek-v4.1-flash`、`deepseek-v4-pro` | ❌ 11129 | ✅ 200 |
|
|
36
|
+
| `glm-5.3`、`glm-5.3-flash`、`kimi-k3.1-pro`、`kimi-k3-1`、`kimi-k2.8-preview`、`mimo-v2.6-pro` | ❌ 11133 | ✅ 200 |
|
|
37
|
+
| `hy3`、`hy4free`、`hy4std`、`hy3-x`、`glm-5.2`、`space-bunny`、`minimax-m3.1-flash`、`step-5-preview` | ✅ 200(原本就通过) | ✅ 200(未被误伤) |
|
|
38
|
+
|
|
39
|
+
### 刻意**没有**改的四处,理由都在代码注释里
|
|
40
|
+
|
|
41
|
+
- **内部 `$ref`(`#/…`)保留**:实测被接受,展开递归 schema 是一处大得多、且没有任何实测证据支撑的改动。
|
|
42
|
+
- **布尔 `exclusiveMinimum` 没有同级界时直接删掉,不硬造一个 `0`**:硬造等于**发明一个调用方从未写过的约束**,
|
|
43
|
+
而上游会照收——一个语义错误的 schema 比一个明确失败的请求更糟。
|
|
44
|
+
- **11129 不单独成类**:它继续落在 `client`(该类本来就不换号、不重试)。改类别会动到重试与换账号行为,
|
|
45
|
+
证据不足以支撑那么大的主张;这次只改**建议文案**。
|
|
46
|
+
- **探针不加工具**:探针结果会直接让账号出池,往里塞工具 schema 会让「某个工具定义有问题」被记成
|
|
47
|
+
「这个账号坏了」。
|
|
48
|
+
|
|
49
|
+
### 说明:报错现在会指向工具定义
|
|
50
|
+
|
|
51
|
+
原来 11129 的回复照抄上游的 `displayTips`——「工具的参数结构不符合当前模型要求,被服务端拒绝。请新建任务,
|
|
52
|
+
或换个模型。」这两条建议都**不会**让请求变好(换模型只是绕开,新建任务什么也没改),报告者因此在
|
|
53
|
+
换账号、重登、重装里耗了一天。现在这一族会被单独识别,回复改成:点名是**工具定义**被拒、列出插件已经
|
|
54
|
+
改写过的四种写法、并给出最快验证路径(关掉提供该工具的浏览器自动化 / MCP server / 第三方插件后重发)。
|
|
55
|
+
|
|
56
|
+
修复本身不依赖这条文案:即使某个未知写法仍然被拒,至少不会再让人去换账号。
|
|
57
|
+
|
|
58
|
+
## 5.24.1 (2026-11-14)
|
|
59
|
+
|
|
60
|
+
> 版本号是 **patch**:修一处宿主状态回执的清理归属,不动配置键、路由语义与请求字节。
|
|
61
|
+
> 来自 PR #256(vb2250158 / 秋雨之忆)。
|
|
62
|
+
|
|
63
|
+
### 修复:失败的启动、或已被替换的旧实例,会删掉当前宿主的心跳回执
|
|
64
|
+
|
|
65
|
+
`doctor` 判断「宿主在不在」靠的是 `$DSH_HOME/.workbuddy-host-heartbeat.json` 这份回执,
|
|
66
|
+
而它的清理此前是**无条件删除**:
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
export async function clearHostHeartbeat(): Promise<void> {
|
|
70
|
+
await rm(workbuddyHostHeartbeatPath(), { force: true })
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
三条路径因此都会误删**别人写的**回执:
|
|
75
|
+
|
|
76
|
+
- **注册抛错的启动**:这类启动根本没有写过自己的回执,却照样在 dispose 时执行清理——
|
|
77
|
+
删掉的是另一个仍在运行的宿主的文件。用户看到的是「明明开着 DSH,`doctor` 却说宿主没运行」。
|
|
78
|
+
- **两个宿主先后写同一个文件**:后写的那个先退出时,旧实例一删,新宿主的回执就没了。
|
|
79
|
+
- **写入是异步的**:`void writeHostHeartbeat()` 之后的 dispose 可能跑在落盘**之前**,
|
|
80
|
+
于是清理删了个空,过一会儿旧记录又冒出来,状态查询继续报陈旧信息。
|
|
81
|
+
|
|
82
|
+
修法是**归属**:`writeHostHeartbeat()` 现在返回它这次写入的 `{ path, contents }`,
|
|
83
|
+
清理只删仍然与它逐字节相同的那一份。
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
const owner = await writeHostHeartbeat()
|
|
87
|
+
await clearHostHeartbeat(owner) // 文件已改、已消失、或 owner 为空 → 什么都不做
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
细节与理由:
|
|
91
|
+
|
|
92
|
+
- **路径在写入时捕获**,所以之后改 `DSH_HOME` 不会把清理重定向到别的目录;
|
|
93
|
+
- 读取失败里**只有 `ENOENT` 算正常**,别的错误照常抛给调用方(例如把回执路径做成目录,
|
|
94
|
+
那种情况不该被当成「没有回执」轻轻放过);
|
|
95
|
+
- 每次写入带一个 `registrationId`(UUID),区分**同 PID、同一毫秒内**的两次注册。
|
|
96
|
+
它是**只写不读**的字段:`readHostHeartbeat()` 的 v2 字段集合与版本判定都没有变,
|
|
97
|
+
所以旧构建写下的回执仍读得回来;
|
|
98
|
+
- 真实 disposer 改为 `async`:先 `await` 尚未完成的写入再清理;写入失败只记一条 error 日志,
|
|
99
|
+
实例随后**不带 owner** 退出,下次 dispose 不会误删。
|
|
100
|
+
|
|
101
|
+
**边界(这一版没做):跨进程原子互斥。** 「读 → 比对 → 删」之间仍有一个很窄的窗口,
|
|
102
|
+
外部进程可以在这个窗口里替换文件。本次保证的是**实例归属**,不是互斥;要彻底关掉这个窗口
|
|
103
|
+
需要另设计一套跨进程锁。写成这里而不是只写在 PR 描述里,是因为它决定了这个修复能承诺什么、
|
|
104
|
+
不能承诺什么。
|
|
105
|
+
|
|
106
|
+
### 测试:写侧此前没有任何一条用例,本轮补上
|
|
107
|
+
|
|
108
|
+
这不是文案问题,是覆盖缺口:`tests/host-heartbeat.spec.ts` 里所有用例都是**手工构造**一个
|
|
109
|
+
heartbeat 对象喂给 `isHeartbeatProcessAlive`,也就是说——如果 `writeHostHeartbeat()` 写出
|
|
110
|
+
`readHostHeartbeat()` 拒收的文档,**整个套件依然全绿**,症状只会在真实 `doctor` 上报成
|
|
111
|
+
「没有心跳」。合并时补了两条往返用例(写 → 读回 → 断言字段与存活判定;并钉住
|
|
112
|
+
`owner.contents` 与磁盘字节完全相同、`registrationId` 不出现在读取结果里)与一个独立夹具,
|
|
113
|
+
后者用两个**真实子进程**覆盖跨进程互斥不到的那部分场景。
|
|
114
|
+
|
|
115
|
+
变异验证(各自单独还原,最后 16 条心跳用例全绿):返回字节与磁盘分叉 → 红 2 条;
|
|
116
|
+
把 `registrationId` 泄漏进读取结果 → 红 1 条;恢复无条件清理 → 红 3 条;
|
|
117
|
+
去掉 UUID → 红 1 条;disposer 不 await 未完成写入 → 红 1 条。
|
|
118
|
+
|
|
119
|
+
### 说明:5.24.0 没有发布到 npm
|
|
120
|
+
|
|
121
|
+
5.24.0 是**开发依赖栈跟随到 `0.2.2-rc.3`** 的那一版(不改任何用户可见行为),有 CHANGELOG 记录、
|
|
122
|
+
有 `package.json` 里的版本号,但**没有打 tag、也没有发到 npm**——registry 上 `5.23.1` 之后直接是
|
|
123
|
+
`5.24.1`。这与 5.21.5 的处置一致(那一版同样只有版本号与 CHANGELOG,没有 `v5.21.5` tag):
|
|
124
|
+
中间态保留记录,以免读者从 registry 的版本序列反推出一段「不存在的空档」。
|
|
125
|
+
|
|
126
|
+
## 5.24.0 (2026-11-14)
|
|
127
|
+
|
|
128
|
+
> 版本号是 **minor**:开发依赖栈跟随宿主换到 DSH `0.2.2-rc.3` 线,并按惯例留下一份复核档案。
|
|
129
|
+
> **不改任何用户可见行为** —— 本轮一行源码都没动。**这一版没有发布到 npm**,见 5.24.1 的最后一节。
|
|
130
|
+
|
|
131
|
+
### 变更:依赖栈跟随到 0.2.2-rc.3
|
|
132
|
+
|
|
133
|
+
桌面宿主已升到 `0.2.2-rc.3`。逐包比对(37 个包的 npm tarball 逐个文件 sha1)的结论是
|
|
134
|
+
**本插件不需要任何适配**:
|
|
135
|
+
|
|
136
|
+
- **31 个包的 `lib/` 与 rc.2 逐字节相同**,只有 `package.json` 的版本号不同 —— 其中包含本插件
|
|
137
|
+
import 的 13 个包里的 12 个,以及 `dsh-app-boot`(兼容闸门没动);
|
|
138
|
+
- 有代码变化的 6 个包中,**只有 1 个是本插件依赖的**:`dsh-client-ui-primitives` 新增了两个
|
|
139
|
+
`upload-outline` 图标导出,**纯加法**(本插件本来就刻意不依赖这个包);
|
|
140
|
+
- 另外 5 个是 `dsh-client-ui-sidebar`(新增 `hoc` 槽 `sidebar.session.action`)、
|
|
141
|
+
`dsh-client-ui-workspace`(新增 `workspace.picker` Factory)、`dsh-client-ui-plugin-manager`
|
|
142
|
+
(名单里加了一个实验包)、`dsh-client-modules`(只改了内嵌 commit 哈希)、`dsh-web-frontend`
|
|
143
|
+
(前端重建)。**本插件一个都不碰。**
|
|
144
|
+
|
|
145
|
+
随包升级指南的最新一节仍是 `## v0.2.2-rc.1`,rc.3 没有自己的破坏性清单。闸门实算:
|
|
146
|
+
`0.2.2-rc.3` ADMITTED,`0.3.0-rc.1` 仍被 `<0.3.0-0` 挡住(10 条 `dsh-*` peer 全部不满足)。
|
|
147
|
+
|
|
148
|
+
`package.json` 的 devDeps 写的是范围而非精确版本,所以这一跳**只动 `pnpm-workspace.yaml`**
|
|
149
|
+
(overrides 整块换线),装完实测 `dsh-*` 全部 `0.2.2-rc.3`、`cordis` 4.1.0、`schemastery`
|
|
150
|
+
3.19.0、`pi-ai` 1.3.0,lockfile 中 `0.2.2-rc.2` 残留为 0 条。
|
|
151
|
+
|
|
152
|
+
### 修复:删掉一条锁着「从未发布版本」的死 override
|
|
153
|
+
|
|
154
|
+
整块换线时顺带发现 `@deepseek-ai/dsh-invariants` 这条 override 有两个问题叠在一起:
|
|
155
|
+
|
|
156
|
+
1. 上游已在 **0.2.1-rc.3 把这个包从捆绑集里删除**;
|
|
157
|
+
2. 本仓库这条一直跟着整块换线走,被推到了 `0.2.2-rc.2` —— 而 **npm 上从来没有发布过那个版本**
|
|
158
|
+
(该包 0.2.x 线只有 `0.2.0-rc.2`,`rc.1`/`rc.2`/`rc.3` 全部 404)。
|
|
159
|
+
|
|
160
|
+
它一年多没被发现,是因为**已经没有包再依赖它**,pnpm 根本不去解析:既不在 lockfile 里,也不在
|
|
161
|
+
`node_modules` 里。也就是说这条 override 一直在清单里**声称一份并不存在的依赖**。它与
|
|
162
|
+
`dsh-client-runtime` 那条同类,处置一致:删除。**不改变任何行为**(本来就没装)。
|
|
163
|
+
|
|
164
|
+
`RELEASING.md` §2.6 因此新增一条核对项:**overrides 每一条都要真的能解析**
|
|
165
|
+
(`pnpm why <pkg>` 无输出且 lockfile 里也没有它 = 死条目)。
|
|
166
|
+
|
|
167
|
+
### 文档
|
|
168
|
+
|
|
169
|
+
- 新增 [`docs/DSH-0.2.2-RC3-FOLLOWUP.md`](docs/DSH-0.2.2-RC3-FOLLOWUP.md):rc.3 的逐面复核,
|
|
170
|
+
含 37 包比对表、闸门实算、槽位账本、16 条路由探针,以及两个只有这一轮才看得见的结论
|
|
171
|
+
(`hoc` 槽种本插件刻意不识别;死 override 的识别方法)。配套新增一条 POLICY 守卫用例。
|
|
172
|
+
- 两条 README 的实测表把 `0.2.2-rc.3` 加进去(`rc.1` / `rc.2` / `rc.3`),并把「本仓库套件在
|
|
173
|
+
`0.2.2-rc.2` + pi-ai `1.3.0` 上全绿」更新为 rc.3。
|
|
174
|
+
|
|
175
|
+
### 说明:一条既有的偶发失败,本轮未修
|
|
176
|
+
|
|
177
|
+
`tests/pool-e2e.spec.ts` 的「claims an account the status read reports as not checked in」在
|
|
178
|
+
**全量并行**时偶发超时(`waitFor` 的 10 秒预算),本轮 8 次全量运行里失败 2 次。**它不是本轮
|
|
179
|
+
引入的**:其中一次发生在源码完全未改动时(只换了依赖)。单跑该文件连跑 5 次全过。
|
|
180
|
+
本轮**没有**改它——没有稳定可复现的失败,改宽预算再跑绿什么都证明不了。已记进
|
|
181
|
+
[`docs/DSH-0.2.2-RC3-FOLLOWUP.md`](docs/DSH-0.2.2-RC3-FOLLOWUP.md) §5.1 留待下一轮处理。
|
|
182
|
+
|
|
3
183
|
## 5.23.1 (2026-11-13)
|
|
4
184
|
|
|
5
185
|
> 版本号是 **patch**:修一个明确的 bug,无新增配置项、无接口变化。
|
package/README.en.md
CHANGED
|
@@ -226,9 +226,9 @@ DSH's shipped gate (`evaluatePluginCompatibility` in `packages/boot/app-boot/src
|
|
|
226
226
|
| `0.3.0-0` and above | ❌ explicitly refused (that line is unverified) |
|
|
227
227
|
| `0.1.6` and earlier | ❌ explicitly refused (0.1.5 users should stay on v2.0.15) |
|
|
228
228
|
|
|
229
|
-
> **`0.2.2-rc.1` / `0.2.2-rc.2` are verified working** (5.
|
|
230
|
-
> ADMITTED, the plugin loads completely on a running host (16 routes, 6 of 8 slots, all client modules registered), and this
|
|
231
|
-
> repository's suite is green on the real `0.2.2-rc.
|
|
229
|
+
> **`0.2.2-rc.1` / `0.2.2-rc.2` / `0.2.2-rc.3` are verified working** (5.24.0): all three hosts' shipped gates evaluate the declared
|
|
230
|
+
> range as ADMITTED, the plugin loads completely on a running host (16 routes, 6 of 8 slots, all client modules registered), and this
|
|
231
|
+
> repository's suite is green on the real `0.2.2-rc.3` + pi-ai `1.3.0` combination. The "⚠️ outside the declared range" row
|
|
232
232
|
> above still describes **bare semver** evaluation, which is a different question from "does it run" — see the next note.
|
|
233
233
|
|
|
234
234
|
> **On `0.2.x` prereleases (corrected in v4.7.0)**: this table previously listed `0.2.0-rc.1` as "✅ supported". That was **wrong**.
|
|
@@ -580,6 +580,32 @@ node scripts/verify-entry-artifacts.mjs <installed dir> # a specific installe
|
|
|
580
580
|
> Installing from npm (`dsh plugin add dsh-connect-workbuddy`) needs none of this: the published
|
|
581
581
|
> tarball already contains `lib/`, and `prepack` only regenerates it.
|
|
582
582
|
|
|
583
|
+
### Host heartbeat: cleanup belongs to the instance that **wrote** it
|
|
584
|
+
|
|
585
|
+
`writeHostHeartbeat()` writes a Host receipt to `$DSH_HOME/.workbuddy-host-heartbeat.json`, and `doctor` reads it to decide whether a Host is alive. Disposal no longer deletes that file unconditionally — it removes only the exact write it made.
|
|
586
|
+
|
|
587
|
+
Three real failures all came from "anyone may delete it":
|
|
588
|
+
|
|
589
|
+
- **A failed startup still cleaned up.** Registration threw, so there was no receipt of its own to remove — what it deleted belonged to **another Host still running**.
|
|
590
|
+
- **Two Hosts write the same file.** The newer one exits first; the older instance's cleanup removed its receipt and `doctor` then reported "host not running".
|
|
591
|
+
- **The write is asynchronous.** A disposal that finished before the write landed deleted nothing, and the stale record reappeared a moment later.
|
|
592
|
+
|
|
593
|
+
So:
|
|
594
|
+
|
|
595
|
+
```ts
|
|
596
|
+
const owner = await writeHostHeartbeat() // returns { path, contents }
|
|
597
|
+
// …while the plugin is alive…
|
|
598
|
+
await clearHostHeartbeat(owner) // removes only this one; no-op if absent, replaced, or undefined
|
|
599
|
+
```
|
|
600
|
+
|
|
601
|
+
- The path is captured **at write time**, so a later `DSH_HOME` change cannot redirect cleanup into another directory.
|
|
602
|
+
- If the bytes no longer match (another instance overwrote the file), the **current file is kept** — that is the whole of "a new Host is not deleted by an old instance".
|
|
603
|
+
- Of the read failures only `ENOENT` is treated as normal; everything else rejects to the caller.
|
|
604
|
+
- Each write carries a `registrationId` (a UUID) that distinguishes two registrations landing in the same millisecond under the same PID. It is **write-only**: `readHostHeartbeat()`'s v2 fields and its version rule are unchanged.
|
|
605
|
+
- The real disposer awaits a pending write before cleaning up; a failed write is logged once as an error and the instance then exits owning nothing.
|
|
606
|
+
|
|
607
|
+
**Known limit: cross-process atomic exclusion is not implemented.** A narrow window remains between read, compare and unlink, in which an external process could replace the file. What this change guarantees is **instance ownership**, not mutual exclusion; closing that window needs a separate cross-process lock design and is out of scope here.
|
|
608
|
+
|
|
583
609
|
### Calling `chatStream()` from a script: it returns an **envelope**, not a stream
|
|
584
610
|
|
|
585
611
|
```ts
|
package/README.md
CHANGED
|
@@ -243,10 +243,10 @@ DSH 的随包门禁(`packages/boot/app-boot/src/plugin-compatibility.ts` 的 `
|
|
|
243
243
|
| `0.3.0-0` 及以上 | ❌ 明确拒绝(该线尚未验证) |
|
|
244
244
|
| `0.1.6` 及更早 | ❌ 明确拒绝(0.1.5 线请停留在 v2.0.15) |
|
|
245
245
|
|
|
246
|
-
> **`0.2.2-rc.1` / `0.2.2-rc.2` 已实测可用**(5.
|
|
247
|
-
>
|
|
248
|
-
> `0.2.2-rc.
|
|
249
|
-
> 的判定,与「能不能跑」是两件事,原因见下条。
|
|
246
|
+
> **`0.2.2-rc.1` / `0.2.2-rc.2` / `0.2.2-rc.3` 已实测可用**(5.24.0):三版的随包门禁都把现声明判为
|
|
247
|
+
> ADMITTED,插件在运行中的宿主上完整加载(16 条路由、8 个槽位里的 6 处、客户端模块全部注册),
|
|
248
|
+
> 本仓库套件也在 `0.2.2-rc.3` + pi-ai `1.3.0` 的真实组合上全绿。上表那行「⚠️ 不落在声明范围内」
|
|
249
|
+
> 描述的仍是**裸 semver** 的判定,与「能不能跑」是两件事,原因见下条。
|
|
250
250
|
|
|
251
251
|
> **关于 `0.2.x` 预发布(v4.7.0 更正)**:此前本表把 `0.2.0-rc.1` 写作「✅ 支持」,那是**错的**。
|
|
252
252
|
> npm semver 规定:预发布版本只有当一个比较器**在同一条 `major.minor.patch` 元组上**带预发布标签时才被放行。
|
|
@@ -670,6 +670,32 @@ node scripts/verify-entry-artifacts.mjs <已安装的目录> # 具体某个
|
|
|
670
670
|
> 从 npm 安装(`dsh plugin add dsh-connect-workbuddy`)不需要这一步:发布包里 `lib/` 已经在,
|
|
671
671
|
> `prepack` 也只负责把它重新生成一遍。
|
|
672
672
|
|
|
673
|
+
### 宿主心跳:清理由**写入它的那个实例**负责
|
|
674
|
+
|
|
675
|
+
`writeHostHeartbeat()` 在 `$DSH_HOME/.workbuddy-host-heartbeat.json` 写一份宿主回执,`doctor` 据此判断宿主是否活着。它的 `dispose` **不再无条件删除这个文件**,而是只删自己那次成功写入的那一份。
|
|
676
|
+
|
|
677
|
+
原因是三类真实故障都出自「谁都能删」:
|
|
678
|
+
|
|
679
|
+
- **启动失败也要清理**:注册抛错时没有回执可清,删掉的是**另一个仍在运行的宿主**写的文件;
|
|
680
|
+
- **两个宿主先后写同一文件**:后写的那个先退出,旧实例一删,新宿主的回执就没了,`doctor` 报「宿主未运行」;
|
|
681
|
+
- **写入是异步的**:`dispose` 在写入落盘之前就完成时,清理反而删不到东西,过一会儿旧记录又出现。
|
|
682
|
+
|
|
683
|
+
所以:
|
|
684
|
+
|
|
685
|
+
```ts
|
|
686
|
+
const owner = await writeHostHeartbeat() // 返回 { path, contents }
|
|
687
|
+
// …插件存活期间…
|
|
688
|
+
await clearHostHeartbeat(owner) // 只删这份;文件已变、已消失或 owner 为空时什么都不做
|
|
689
|
+
```
|
|
690
|
+
|
|
691
|
+
- 文件路径在**写入时**捕获,所以之后改 `DSH_HOME` 不会把清理重定向到别的目录;
|
|
692
|
+
- 字节比对不通过(别的实例已覆盖)就**保留当前文件**,这就是「新宿主不会被旧实例删掉」的全部实现;
|
|
693
|
+
- 读取失败里只有 `ENOENT` 被视为正常,其他错误照常抛给调用方;
|
|
694
|
+
- 每次写入带一个 `registrationId`(UUID),用来区分同 PID、同一毫秒内的两次注册。它是**只写不读**的字段:`readHostHeartbeat()` 的 v2 字段与版本判定都没变;
|
|
695
|
+
- 真实 disposer 会先 `await` 未完成的写入再清理,写入失败只记一条 error 日志,实例随后不带 owner 退出。
|
|
696
|
+
|
|
697
|
+
**已知边界:跨进程原子互斥没有做。** 「读 → 比对 → 删」之间仍有一个很窄的窗口,外部进程可以在这个窗口里替换文件。本改动保证的是**实例归属**,不是互斥;要彻底消除这个窗口得另设计一套跨进程锁,不在这一版的范围里。
|
|
698
|
+
|
|
673
699
|
### 写脚本调用 `chatStream()` 时注意:它返回的是**信封**,不是可迭代流
|
|
674
700
|
|
|
675
701
|
```ts
|
package/lib/bin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { $ as DEFAULT_WIRE_PROFILE,
|
|
2
|
+
import { $ as DEFAULT_WIRE_PROFILE, An as resolveDshHome, F as WorkBuddyCredentialStore, J as workbuddyOwnAuthPath, 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, a as readHostHeartbeat, b as readDeviceSettings, c as WORKBUDDY_CONNECT_VERSION, cn as readDeviceTokenFile, d as rosterSeenPath, dn as deriveDeviceId, f as WORKBUDDY_CN_BASE_ENV, g as createTuringSdk, hn as WORKBUDDY_APP_EXECUTABLE_ENV, kn as hostPeersInfo, ln as ensureDeviceSalt, m as piAiRuntimeInfo, mn as protectCredentialDirectory, nt as WorkBuddyUpstreamClient, o as workbuddyHostHeartbeatPath, ot as describeRequestHeaderNames, p as resolveCnGateway, pn as inspectCredentialDirectory, r as isHeartbeatProcessAlive, sn as WORKBUDDY_DEVICE_TOKEN_FILE_ENV, u as describeRosterSeenPayload, un as readDeviceSalt, w as FALLBACK_WORKBUDDY_MODELS, xn as findWorkbuddyAppExecutableWithSource, z as defaultDesktopAuthDirs } from "./host-heartbeat-Q85k2yEL.js";
|
|
3
3
|
import { readFile } from "node:fs/promises";
|
|
4
4
|
import { dirname, join } from "node:path";
|
|
5
5
|
import { realpathSync } from "node:fs";
|
|
@@ -3904,6 +3904,56 @@ const CONTEXT_TOO_LONG_CODE = /"code"\s*:\s*11115(?!\d)|code\s+11115(?!\d)/u;
|
|
|
3904
3904
|
function isContextTooLongBody(body) {
|
|
3905
3905
|
return CONTEXT_TOO_LONG_CODE.test(body);
|
|
3906
3906
|
}
|
|
3907
|
+
/** The tool-schema refusal (issue #253). */
|
|
3908
|
+
const TOOL_SCHEMA_REJECT_CODE = 11129;
|
|
3909
|
+
/**
|
|
3910
|
+
* Whether this body is the upstream refusing a TOOL DEFINITION (issue #253).
|
|
3911
|
+
*
|
|
3912
|
+
* `11129` arrives as `{"code":11129,"msg":"invalid function call parameters"}`
|
|
3913
|
+
* with `extError.code: "invalid_function_parameters"`. Its `param` field is an
|
|
3914
|
+
* EMPTY STRING — the upstream knows the definition is wrong but never says
|
|
3915
|
+
* which tool or which keyword — so the plugin is the only party that can turn
|
|
3916
|
+
* this into an actionable sentence.
|
|
3917
|
+
*
|
|
3918
|
+
* Read by CODE rather than by the wording, for the reason every other code
|
|
3919
|
+
* reader in this module does it: the same `msg` is short and generic enough that
|
|
3920
|
+
* a request id or a prompt could contain the phrase, while `11129` has so far
|
|
3921
|
+
* only ever meant this. Recognising it changes ADVICE ONLY — the kind stays
|
|
3922
|
+
* `client`, which already means "refused on parameters, no account can help" and
|
|
3923
|
+
* already skips failover. Giving it a kind of its own would move it out of that
|
|
3924
|
+
* bucket and silently change retry behaviour, which is a much larger claim than
|
|
3925
|
+
* the evidence supports.
|
|
3926
|
+
*/
|
|
3927
|
+
function isToolSchemaRejectBody(body) {
|
|
3928
|
+
return statesBusinessCode(body, TOOL_SCHEMA_REJECT_CODE);
|
|
3929
|
+
}
|
|
3930
|
+
/**
|
|
3931
|
+
* Which schema keywords the rewrite in {@link normalizeToolSchemas} can fix,
|
|
3932
|
+
* for the reply's advice (issue #253).
|
|
3933
|
+
*
|
|
3934
|
+
* Deliberately a FIXED LIST rather than a parse of the offending body: the
|
|
3935
|
+
* upstream never names the keyword, and the plugin has already rewritten every
|
|
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 to
|
|
3938
|
+
* say "something else", not repeat the four shapes it already handled.
|
|
3939
|
+
*/
|
|
3940
|
+
const TOOL_SCHEMA_REWRITTEN_KEYWORDS = "元组式 `items`、布尔 `exclusiveMinimum`/`exclusiveMaximum`、`required` 非数组或含重复项、外部 `$ref`";
|
|
3941
|
+
/**
|
|
3942
|
+
* One actionable sentence for a `11129` refusal, naming what was already fixed
|
|
3943
|
+
* and what the user can still do.
|
|
3944
|
+
*
|
|
3945
|
+
* WHY THE PLUGIN MUST SPEAK HERE. The upstream's own advice is "请新建任务,或换
|
|
3946
|
+
* 个模型" — and issue #253's reporter spent a day on account swaps, re-logins and
|
|
3947
|
+
* a reinstall because nothing in that sentence points at a TOOL DEFINITION. The
|
|
3948
|
+
* plugin rewrites the four known shapes automatically, so a surviving `11129`
|
|
3949
|
+
* means either (a) the offending definition is one of a further shape this build
|
|
3950
|
+
* does not know, or (b) a tool supplied by a third-party bundle/MCP server is
|
|
3951
|
+
* sending something the gateway will not take. Both are actionable, and neither
|
|
3952
|
+
* is "switch accounts".
|
|
3953
|
+
*/
|
|
3954
|
+
function toolSchemaRejectAdvice() {
|
|
3955
|
+
return `这次是工具定义被拒,与账号、积分、额度、网络都无关,换账号或重试都不会改变结果。插件已自动改写过这些上游不接受的写法:${TOOL_SCHEMA_REWRITTEN_KEYWORDS};仍被拒说明还有别的写法。最快的验证是关掉提供该工具的能力(例如浏览器自动化、某个 MCP server 或第三方插件)后重发同一句话——能通过就说明是那个工具的定义有问题,把它的参数结构贴到 issue 里即可定位`;
|
|
3956
|
+
}
|
|
3907
3957
|
/**
|
|
3908
3958
|
* An English clause the HOST's overflow detector recognises, for issue #101.
|
|
3909
3959
|
*
|
|
@@ -5596,6 +5646,7 @@ function prepareChatBody(source, options) {
|
|
|
5596
5646
|
rewriteChannelFingerprintPhrasesInBody(obj);
|
|
5597
5647
|
neutralizeChannelFingerprints(obj);
|
|
5598
5648
|
normalizeToolChoice(obj);
|
|
5649
|
+
normalizeToolSchemas(obj);
|
|
5599
5650
|
dropRefusedReasoning(obj);
|
|
5600
5651
|
return JSON.stringify(obj);
|
|
5601
5652
|
}
|
|
@@ -5744,6 +5795,217 @@ function normalizeToolChoice(obj) {
|
|
|
5744
5795
|
delete obj["tool_choice"];
|
|
5745
5796
|
}
|
|
5746
5797
|
/**
|
|
5798
|
+
* Rewrite JSON Schema spellings the CN gateway REFUSES inside `tools[].function.parameters`
|
|
5799
|
+
* (issue #253, business code 11129 / 11133).
|
|
5800
|
+
*
|
|
5801
|
+
* WHY THIS EXISTS. The host builds tool schemas with zod and ships whatever the
|
|
5802
|
+
* library emits; `prepareChatBody` forwarded `tools` untouched. Four shapes
|
|
5803
|
+
* measured on 2026-11-14 as refused by the upstream, each with the same body
|
|
5804
|
+
* answering 200 once rewritten:
|
|
5805
|
+
*
|
|
5806
|
+
* | shape | refused as | rewritten to |
|
|
5807
|
+
* | --- | --- | --- |
|
|
5808
|
+
* | `items` as a TUPLE ARRAY (draft-4 tuple form) | 11129 (DeepSeek) / 11133 (GLM, Kimi, MiMo) | `prefixItems: [...]` + `items: {}` |
|
|
5809
|
+
* | `exclusiveMinimum` / `exclusiveMaximum` as a BOOLEAN (draft-4) | 11129 | the numeric form, derived from the sibling `minimum` / `maximum` |
|
|
5810
|
+
* | `required` as a STRING instead of an array | 11129 | one-element array |
|
|
5811
|
+
* | `required` containing DUPLICATES | 11129 | de-duplicated |
|
|
5812
|
+
* | an EXTERNAL `$ref` (`https://…`, `//host/…`) | 11129 | the reference object removed |
|
|
5813
|
+
*
|
|
5814
|
+
* WHAT IS DELIBERATELY NOT TOUCHED.
|
|
5815
|
+
*
|
|
5816
|
+
* - **Internal `$ref` (`#/…`) stays.** Measured: the recursive
|
|
5817
|
+
* `$defs`/`additionalProperties` schema of `stagehand_extract` — the shape
|
|
5818
|
+
* issue #253 originally blamed — answers 200 on every model tested, as does
|
|
5819
|
+
* the host's whole 75-tool catalog sent at once. Only the EXTERNAL form is
|
|
5820
|
+
* refused. Rewriting internal references would be a large, riskier change
|
|
5821
|
+
* bought with no measured evidence.
|
|
5822
|
+
* - **The boolean `exclusiveMinimum` rewrite is only made when it is safe.** A
|
|
5823
|
+
* draft-4 boolean means "minimum is exclusive"; with no sibling bound there is
|
|
5824
|
+
* nothing to derive, so the key is dropped rather than guessed. Silently
|
|
5825
|
+
* turning `exclusiveMinimum: true` into `exclusiveMinimum: 0` would INVENT a
|
|
5826
|
+
* constraint — a wrong schema that the upstream accepts is worse than a
|
|
5827
|
+
* request that fails loudly.
|
|
5828
|
+
* - **Nothing outside `tools` / `functions` is examined.** `tool_choice`,
|
|
5829
|
+
* messages, and every other body byte keep their existing treatment; a
|
|
5830
|
+
* session-title body or a plain conversation cannot be changed by this.
|
|
5831
|
+
*
|
|
5832
|
+
* Order matters only in that this runs AFTER {@link normalizeToolChoice}: a
|
|
5833
|
+
* suppressed `tools` (from `tool_choice: 'none'`) is already gone, and
|
|
5834
|
+
* normalizing an array that is about to be deleted would be wasted work.
|
|
5835
|
+
*/
|
|
5836
|
+
function normalizeToolSchemas(obj) {
|
|
5837
|
+
normalizeToolArray(obj["tools"]);
|
|
5838
|
+
normalizeToolArray(obj["functions"]);
|
|
5839
|
+
}
|
|
5840
|
+
/** Walk the entries of a `tools` / `functions` array, rewriting each schema. */
|
|
5841
|
+
function normalizeToolArray(value) {
|
|
5842
|
+
if (!Array.isArray(value)) return;
|
|
5843
|
+
for (const entry of value) {
|
|
5844
|
+
if (typeof entry !== "object" || entry === null || Array.isArray(entry)) continue;
|
|
5845
|
+
const tool = entry;
|
|
5846
|
+
const fn = tool["function"];
|
|
5847
|
+
if (typeof fn === "object" && fn !== null && !Array.isArray(fn)) normalizeSchemaNode(fn["parameters"]);
|
|
5848
|
+
if (tool["function"] === void 0) normalizeSchemaNode(tool["parameters"]);
|
|
5849
|
+
}
|
|
5850
|
+
}
|
|
5851
|
+
/**
|
|
5852
|
+
* Recursively rewrite ONE schema node in place.
|
|
5853
|
+
*
|
|
5854
|
+
* Recursion is required, not decorative: every one of the measured refusals can
|
|
5855
|
+
* appear at any depth (a tuple `items` inside `properties.a.items`, a bad
|
|
5856
|
+
* `required` inside a nested object). The walk is depth-limited because the
|
|
5857
|
+
* input is arbitrary JSON from a third party — a malformed or pathological
|
|
5858
|
+
* document must not be able to hang a request.
|
|
5859
|
+
*/
|
|
5860
|
+
function normalizeSchemaNode(node, depth = 0) {
|
|
5861
|
+
if (typeof node !== "object" || node === null || Array.isArray(node)) return;
|
|
5862
|
+
if (depth > MAX_SCHEMA_DEPTH) return;
|
|
5863
|
+
const schema = node;
|
|
5864
|
+
normalizeItems(schema);
|
|
5865
|
+
normalizeExclusiveBound(schema, "exclusiveMinimum", "minimum");
|
|
5866
|
+
normalizeExclusiveBound(schema, "exclusiveMaximum", "maximum");
|
|
5867
|
+
normalizeRequired(schema);
|
|
5868
|
+
dropExternalRef(schema);
|
|
5869
|
+
for (const key of SCHEMA_CHILD_MAPS) {
|
|
5870
|
+
const child = schema[key];
|
|
5871
|
+
if (typeof child !== "object" || child === null || Array.isArray(child)) continue;
|
|
5872
|
+
for (const nested of Object.values(child)) normalizeSchemaNode(nested, depth + 1);
|
|
5873
|
+
}
|
|
5874
|
+
for (const key of SCHEMA_CHILD_LISTS) {
|
|
5875
|
+
const list = schema[key];
|
|
5876
|
+
if (!Array.isArray(list)) continue;
|
|
5877
|
+
for (const nested of list) normalizeSchemaNode(nested, depth + 1);
|
|
5878
|
+
}
|
|
5879
|
+
for (const key of SCHEMA_CHILD_SINGLE) normalizeSchemaNode(schema[key], depth + 1);
|
|
5880
|
+
}
|
|
5881
|
+
/**
|
|
5882
|
+
* Bound the recursion.
|
|
5883
|
+
*
|
|
5884
|
+
* The host's own schemas nest a handful of levels. 64 is far past anything real
|
|
5885
|
+
* and still terminates on a hostile document; the value is a guard against a
|
|
5886
|
+
* hang, not a format rule.
|
|
5887
|
+
*/
|
|
5888
|
+
const MAX_SCHEMA_DEPTH = 64;
|
|
5889
|
+
/** Keywords whose value is a MAP of schemas (each value walked). */
|
|
5890
|
+
const SCHEMA_CHILD_MAPS = [
|
|
5891
|
+
"properties",
|
|
5892
|
+
"patternProperties",
|
|
5893
|
+
"dependentSchemas",
|
|
5894
|
+
"$defs",
|
|
5895
|
+
"definitions"
|
|
5896
|
+
];
|
|
5897
|
+
/** Keywords whose value is a LIST of schemas (each entry walked). */
|
|
5898
|
+
const SCHEMA_CHILD_LISTS = [
|
|
5899
|
+
"allOf",
|
|
5900
|
+
"anyOf",
|
|
5901
|
+
"oneOf",
|
|
5902
|
+
"prefixItems"
|
|
5903
|
+
];
|
|
5904
|
+
/** Keywords whose value is a SINGLE schema (walked directly). */
|
|
5905
|
+
const SCHEMA_CHILD_SINGLE = [
|
|
5906
|
+
"items",
|
|
5907
|
+
"additionalProperties",
|
|
5908
|
+
"not",
|
|
5909
|
+
"contains",
|
|
5910
|
+
"if",
|
|
5911
|
+
"then",
|
|
5912
|
+
"else",
|
|
5913
|
+
"propertyNames"
|
|
5914
|
+
];
|
|
5915
|
+
/**
|
|
5916
|
+
* Convert draft-4's tuple `items` into the 2020-12 spelling.
|
|
5917
|
+
*
|
|
5918
|
+
* A tuple `items` is a LIST; the modern spec splits it into `prefixItems` (the
|
|
5919
|
+
* per-position schemas, same order) plus `items` (the schema for everything
|
|
5920
|
+
* past the end). Emitting `items: {}` for the tail is the faithful reading of a
|
|
5921
|
+
* draft-4 tuple: draft-4 said nothing about additional items, so "anything" is
|
|
5922
|
+
* correct — inventing `false` would FORBID extra elements, which the original
|
|
5923
|
+
* never said.
|
|
5924
|
+
*
|
|
5925
|
+
* Measured: `prefixItems` + `items: {}` answers 200 on `deepseek-v4.1-flash`,
|
|
5926
|
+
* `deepseek-v4-pro`, `glm-5.3`, `kimi-k3.1-pro` and `mimo-v2.6-pro` — the five
|
|
5927
|
+
* strictest models in the catalog — and on every model that accepted the tuple
|
|
5928
|
+
* form already.
|
|
5929
|
+
*/
|
|
5930
|
+
function normalizeItems(schema) {
|
|
5931
|
+
const items = schema["items"];
|
|
5932
|
+
if (!Array.isArray(items)) return;
|
|
5933
|
+
if (schema["prefixItems"] === void 0) schema["prefixItems"] = items;
|
|
5934
|
+
schema["items"] = {};
|
|
5935
|
+
}
|
|
5936
|
+
/**
|
|
5937
|
+
* Rewrite a draft-4 BOOLEAN exclusive bound into the numeric form.
|
|
5938
|
+
*
|
|
5939
|
+
* Draft-4: `{minimum: 0, exclusiveMinimum: true}` means "greater than 0".
|
|
5940
|
+
* 2020-12: `{exclusiveMinimum: 0}` means the same. The value is therefore
|
|
5941
|
+
* DERIVED from the sibling bound — and when that sibling is absent or not a
|
|
5942
|
+
* finite number there is nothing to derive, so the key is dropped.
|
|
5943
|
+
*
|
|
5944
|
+
* Dropping is the safe direction: it WEAKENS a constraint the upstream already
|
|
5945
|
+
* could not read, and every request that fails today fails on the shape, not on
|
|
5946
|
+
* the constraint. Inventing `0` would attach a bound the caller never wrote.
|
|
5947
|
+
*/
|
|
5948
|
+
function normalizeExclusiveBound(schema, exclusiveKey, boundKey) {
|
|
5949
|
+
if (schema[exclusiveKey] !== true) {
|
|
5950
|
+
if (schema[exclusiveKey] === false) delete schema[exclusiveKey];
|
|
5951
|
+
return;
|
|
5952
|
+
}
|
|
5953
|
+
const bound = schema[boundKey];
|
|
5954
|
+
if (typeof bound === "number" && Number.isFinite(bound)) {
|
|
5955
|
+
schema[exclusiveKey] = bound;
|
|
5956
|
+
delete schema[boundKey];
|
|
5957
|
+
return;
|
|
5958
|
+
}
|
|
5959
|
+
delete schema[exclusiveKey];
|
|
5960
|
+
}
|
|
5961
|
+
/**
|
|
5962
|
+
* Force `required` into the de-duplicated string array the upstream accepts.
|
|
5963
|
+
*
|
|
5964
|
+
* A non-array `required` is not JSON Schema at all, so there is no "faithful"
|
|
5965
|
+
* conversion for it: a string is read as one property name, and anything else
|
|
5966
|
+
* (a number, `null`) carries no names and is dropped. Duplicates are removed
|
|
5967
|
+
* because the upstream refuses them (measured) and they never meant anything:
|
|
5968
|
+
* `required` is a set.
|
|
5969
|
+
*/
|
|
5970
|
+
function normalizeRequired(schema) {
|
|
5971
|
+
const required = schema["required"];
|
|
5972
|
+
if (required === void 0) return;
|
|
5973
|
+
if (typeof required === "string") {
|
|
5974
|
+
schema["required"] = required === "" ? [] : [required];
|
|
5975
|
+
return;
|
|
5976
|
+
}
|
|
5977
|
+
if (!Array.isArray(required)) {
|
|
5978
|
+
delete schema["required"];
|
|
5979
|
+
return;
|
|
5980
|
+
}
|
|
5981
|
+
const names = [];
|
|
5982
|
+
for (const entry of required) {
|
|
5983
|
+
if (typeof entry !== "string" || names.includes(entry)) continue;
|
|
5984
|
+
names.push(entry);
|
|
5985
|
+
}
|
|
5986
|
+
if (names.length === required.length) return;
|
|
5987
|
+
schema["required"] = names;
|
|
5988
|
+
}
|
|
5989
|
+
/**
|
|
5990
|
+
* Remove an EXTERNAL `$ref`, which the upstream refuses, while leaving internal
|
|
5991
|
+
* ones alone.
|
|
5992
|
+
*
|
|
5993
|
+
* `#/…` is a reference into the same document and is accepted (measured on the
|
|
5994
|
+
* recursive `$defs` shape of `stagehand_extract`, and on the host's whole
|
|
5995
|
+
* catalog). Anything with a URI part is not resolvable by the upstream at all,
|
|
5996
|
+
* so the pointer is deleted in place: the object degrades to "any value", which
|
|
5997
|
+
* accepts more than the original said rather than rejecting a valid call.
|
|
5998
|
+
*
|
|
5999
|
+
* A sibling `description` / `title` / `default` is kept — deleting the whole
|
|
6000
|
+
* object would throw away author documentation along with the reference.
|
|
6001
|
+
*/
|
|
6002
|
+
function dropExternalRef(schema) {
|
|
6003
|
+
const ref = schema["$ref"];
|
|
6004
|
+
if (typeof ref !== "string" || ref === "") return;
|
|
6005
|
+
if (ref.startsWith("#")) return;
|
|
6006
|
+
delete schema["$ref"];
|
|
6007
|
+
}
|
|
6008
|
+
/**
|
|
5747
6009
|
* What a PREPARED request body declares, as the input to DSML recovery.
|
|
5748
6010
|
*
|
|
5749
6011
|
* This exists so the recovery path can answer the one question its gates turn
|
|
@@ -10602,7 +10864,7 @@ function describeRosterSeenPayload(raw) {
|
|
|
10602
10864
|
//#endregion
|
|
10603
10865
|
//#region src/version.ts
|
|
10604
10866
|
/** The npm package version this build was produced from. */
|
|
10605
|
-
const WORKBUDDY_CONNECT_VERSION = "5.
|
|
10867
|
+
const WORKBUDDY_CONNECT_VERSION = "5.24.2";
|
|
10606
10868
|
//#endregion
|
|
10607
10869
|
//#region src/host-heartbeat.ts
|
|
10608
10870
|
/**
|
|
@@ -10614,7 +10876,7 @@ const WORKBUDDY_CONNECT_VERSION = "5.23.1";
|
|
|
10614
10876
|
* — 该机制由其设计:浏览器端无法写文件,其健康只能靠 console.error 上报,
|
|
10615
10877
|
* 因此由宿主写心跳文件,缺失即代表宿主从未启动;崩溃后的陈旧心跳
|
|
10616
10878
|
* 通过 PID 存活检查识别。
|
|
10617
|
-
*
|
|
10879
|
+
* 改动:清理由成功写入该记录的插件实例负责,避免失败启动删除另一宿主的回执。
|
|
10618
10880
|
*
|
|
10619
10881
|
* @module dsh-connect-workbuddy/host-heartbeat
|
|
10620
10882
|
*/
|
|
@@ -10797,6 +11059,7 @@ async function readHostHeartbeat() {
|
|
|
10797
11059
|
* moment this function is exercised from a child process.
|
|
10798
11060
|
*/
|
|
10799
11061
|
async function writeHostHeartbeat() {
|
|
11062
|
+
const path = workbuddyHostHeartbeatPath();
|
|
10800
11063
|
const hostStartedAt = processStartTimeMs(process.pid);
|
|
10801
11064
|
const heartbeat = {
|
|
10802
11065
|
version: HEARTBEAT_FORMAT_VERSION,
|
|
@@ -10806,11 +11069,33 @@ async function writeHostHeartbeat() {
|
|
|
10806
11069
|
pid: process.pid,
|
|
10807
11070
|
...hostStartedAt === void 0 ? {} : { hostStartedAt }
|
|
10808
11071
|
};
|
|
10809
|
-
|
|
11072
|
+
const contents = `${JSON.stringify({
|
|
11073
|
+
...heartbeat,
|
|
11074
|
+
registrationId: randomUUID()
|
|
11075
|
+
}, null, 2)}\n`;
|
|
11076
|
+
await writeFile(path, contents, { mode: 384 });
|
|
11077
|
+
return {
|
|
11078
|
+
path,
|
|
11079
|
+
contents
|
|
11080
|
+
};
|
|
10810
11081
|
}
|
|
10811
|
-
/**
|
|
10812
|
-
|
|
10813
|
-
|
|
11082
|
+
/**
|
|
11083
|
+
* Remove only this instance's successful write, if it is still current.
|
|
11084
|
+
*
|
|
11085
|
+
* A failed startup has no owner. The captured path also keeps a later DSH_HOME
|
|
11086
|
+
* change from redirecting cleanup. Missing/replaced records are left alone;
|
|
11087
|
+
* unexpected read/removal errors reject so the disposer can report them.
|
|
11088
|
+
*/
|
|
11089
|
+
async function clearHostHeartbeat(owner) {
|
|
11090
|
+
if (owner === void 0) return;
|
|
11091
|
+
let current;
|
|
11092
|
+
try {
|
|
11093
|
+
current = await readFile(owner.path, "utf8");
|
|
11094
|
+
} catch (error) {
|
|
11095
|
+
if (error.code === "ENOENT") return;
|
|
11096
|
+
throw error;
|
|
11097
|
+
}
|
|
11098
|
+
if (current === owner.contents) await rm(owner.path, { force: true });
|
|
10814
11099
|
}
|
|
10815
11100
|
//#endregion
|
|
10816
|
-
export { DEFAULT_WIRE_PROFILE as $,
|
|
11101
|
+
export { DEFAULT_WIRE_PROFILE as $, pickMediaModel as $t, withoutRouters as A, resolveDshHome as An, lastRefusalFor as At, defaultDesktopAuthPath as B, resolveVideoParams as Bt, setDeviceMode as C, isWorkbuddyBundle as Cn, rewriteSessionTitleModel as Ct, applyContextBudgets as D, readAtRestKey as Dn, selectPromoBadge as Dt, WorkBuddyCatalog as E, openEncryptedField as En, promoBadgeTone as Et, WorkBuddyCredentialStore as F, VIDEO_TAG_IMAGE_TO_VIDEO as Ft, parseWorkBuddyAuth as G, WorkBuddyImageError as Gt, isEncryptedCredentialError as H, IMAGE_TAG_IMAGE_TO_IMAGE as Ht, WorkBuddyEncryptedCredentialError as I, VIDEO_TAG_TEXT_TO_VIDEO as It, workbuddyOwnAuthPath as J, imageModelChoices as Jt, preferredAccountName as K, imageDataUrl as Kt, authFileName as L, WorkBuddyVideoError as Lt, WORKBUDDY_AUTH_FILENAME as M, writeFileAtomic as Mn, offRefused as Mt, WORKBUDDY_AUTH_FILE_ENV as N, recordRefusal as Nt, deriveCatalog as O, workbuddyAppExecutableCandidates as On, REFUSES_OFF_MODEL_IDS as Ot, WORKBUDDY_VAULT_DIRNAME as P, withEffectiveOff as Pt, CREDENTIAL_REJECTED_CODE as Q, parseImageDataUrl as Qt, defaultDesktopAuthCandidates as R, parseSupportedSecondsRange as Rt, saveDeviceSdkSettings as S, isEncryptedFieldWrapper as Sn, requestEvidenceOf as St, FALLBACK_WORKBUDDY_MODELS_GLOBAL as T, macosNestedAppBundles as Tn, attachBusyLevels as Tt, isVaultAccountId as U, IMAGE_TAG_TEXT_TO_IMAGE as Ut, hasEncryptedCredentialFields as V, IMAGE_SIZE_LIMITS_WIDE as Vt, legacyWorkbuddyOwnAuthPath as W, MAX_INPUT_IMAGE_BYTES as Wt, APP_VERSION as X, isBareBase64Image as Xt, workbuddyVaultDir as Y, imageSizeLimitsOf as Yt, CONTEXT_OVERFLOW_MARKER as Z, isWatermarkFreeImageModel as Zt, createDeviceProfileLookup as _, deriveAtRestKey as _n, parseReasoning as _t, readHostHeartbeat as a, imageDefaultFor as an, declaredTools as at, readDeviceSettings as b, findWorkbuddyAppExecutable as bn, prepareChatBody as bt, WORKBUDDY_CONNECT_VERSION as c, readDeviceTokenFile as cn, isContextTooLongBody as ct, rosterSeenPath as d, deriveDeviceId as dn, isFirstMessageGateBody as dt, sniffImageMime as en, WORKBUDDY_FALLBACK_SYSTEM_PROMPT as et, WORKBUDDY_CN_BASE_ENV as f, isDeviceId as fn, isToolSchemaRejectBody as ft, createTuringSdk as g, clearAtRestKeyCache as gn, parseCreditMultiplier as gt, createDeviceSdkPort as h, WORKBUDDY_APP_EXECUTABLE_ENV as hn, openingEvidenceOfBody as ht, processStartTimeMs as i, NATIVE_MODALITY_BY_MODEL_ID as in, classifyUpstreamError as it, ENCRYPTED_CREDENTIAL_CODE as j, withFileLock as jn, offDefaultFor as jt, fallbackModelsFor as k, hostPeersInfo as kn, defaultOffModelIds as kt, createFileRosterSeenStore as l, ensureDeviceSalt as ln, isConversationIdGateBody as lt, piAiRuntimeInfo as m, protectCredentialDirectory as mn, modelIdOfBody as mt, clearHostHeartbeat as n, queueNoticeText as nn, WorkBuddyUpstreamClient as nt, workbuddyHostHeartbeatPath as o, nativeModalityOf as on, describeRequestHeaderNames as ot, resolveCnGateway as p, inspectCredentialDirectory as pn, knownRegionOf as pt, workbuddyAccountId as q, imageMimeForPath as qt, isHeartbeatProcessAlive as r, pruneTempDir as rn, channelGateMemberOf as rt, writeHostHeartbeat as s, WORKBUDDY_DEVICE_TOKEN_FILE_ENV as sn, forceNeutralHead as st, WORKBUDDY_HOST_HEARTBEAT_FILENAME as t, parseQueueAnswer as tn, WorkBuddyCredentialRejectedError as tt, describeRosterSeenPayload as u, readDeviceSalt as un, isCredentialRejectedError as ut, describeDerivedDevices as v, deriveAtRestKeyId as vn, parseUpstreamModel as vt, FALLBACK_WORKBUDDY_MODELS as w, macosBundleExecutable as wn, toolSchemaRejectAdvice as wt, saveDeviceProfile as x, findWorkbuddyAppExecutableWithSource as xn, regionOf as xt, isDeviceMode as y, fetchAtRestKeyPayload as yn, perturbChannelFingerprints as yt, defaultDesktopAuthDirs as z, pickVideoModel as zt };
|
package/lib/index.d.ts
CHANGED
|
@@ -3200,7 +3200,7 @@ declare function resolveCredentialRecovery(options: {
|
|
|
3200
3200
|
* — 该机制由其设计:浏览器端无法写文件,其健康只能靠 console.error 上报,
|
|
3201
3201
|
* 因此由宿主写心跳文件,缺失即代表宿主从未启动;崩溃后的陈旧心跳
|
|
3202
3202
|
* 通过 PID 存活检查识别。
|
|
3203
|
-
*
|
|
3203
|
+
* 改动:清理由成功写入该记录的插件实例负责,避免失败启动删除另一宿主的回执。
|
|
3204
3204
|
*
|
|
3205
3205
|
* @module dsh-connect-workbuddy/host-heartbeat
|
|
3206
3206
|
*/
|
|
@@ -3232,6 +3232,11 @@ interface WorkBuddyHostHeartbeat {
|
|
|
3232
3232
|
*/
|
|
3233
3233
|
hostStartedAt?: number;
|
|
3234
3234
|
}
|
|
3235
|
+
/** A successful write's exact location and bytes, retained by its plugin instance. */
|
|
3236
|
+
interface WorkBuddyHostHeartbeatOwner {
|
|
3237
|
+
readonly path: string;
|
|
3238
|
+
readonly contents: string;
|
|
3239
|
+
}
|
|
3235
3240
|
/** Absolute path of the host heartbeat file. */
|
|
3236
3241
|
declare function workbuddyHostHeartbeatPath(): string;
|
|
3237
3242
|
/**
|
|
@@ -3271,9 +3276,15 @@ declare function readHostHeartbeat(): Promise<WorkBuddyHostHeartbeat | undefined
|
|
|
3271
3276
|
* than cached: the value is cheap, and a module-level cache would be wrong the
|
|
3272
3277
|
* moment this function is exercised from a child process.
|
|
3273
3278
|
*/
|
|
3274
|
-
declare function writeHostHeartbeat(): Promise<
|
|
3275
|
-
/**
|
|
3276
|
-
|
|
3279
|
+
declare function writeHostHeartbeat(): Promise<WorkBuddyHostHeartbeatOwner>;
|
|
3280
|
+
/**
|
|
3281
|
+
* Remove only this instance's successful write, if it is still current.
|
|
3282
|
+
*
|
|
3283
|
+
* A failed startup has no owner. The captured path also keeps a later DSH_HOME
|
|
3284
|
+
* change from redirecting cleanup. Missing/replaced records are left alone;
|
|
3285
|
+
* unexpected read/removal errors reject so the disposer can report them.
|
|
3286
|
+
*/
|
|
3287
|
+
declare function clearHostHeartbeat(owner?: WorkBuddyHostHeartbeatOwner): Promise<void>;
|
|
3277
3288
|
//#endregion
|
|
3278
3289
|
//#region src/version.d.ts
|
|
3279
3290
|
/**
|
|
@@ -6315,4 +6326,4 @@ declare function legacyAttributionRegion(value: Config, accountsFor: (region: Wo
|
|
|
6315
6326
|
*/
|
|
6316
6327
|
declare function apply(ctx: Context, config: Config): void;
|
|
6317
6328
|
//#endregion
|
|
6318
|
-
export { CREDENTIAL_REJECTED_CODE, Config, DEFAULT_PROBE_INPUT_TOKENS, ENCRYPTED_CREDENTIAL_CODE, FALLBACK_WORKBUDDY_MODELS, FALLBACK_WORKBUDDY_MODELS_GLOBAL, NATIVE_MODALITY_BY_MODEL_ID, PROBE_INPUT_TOKEN_CHOICES, PROBE_MAX_TOKENS, PROBE_SYSTEM_PROMPT, REFUSES_OFF_MODEL_IDS, type UpstreamErrorKind, WORKBUDDY_ACCOUNTS_REFRESH_PATH, WORKBUDDY_APP_EXECUTABLE_ENV, WORKBUDDY_AUTH_FILENAME, WORKBUDDY_AUTH_FILE_ENV, WORKBUDDY_CHECKIN_PATH, WORKBUDDY_CONNECT_VERSION, WORKBUDDY_GLOBAL_PROVIDER, WORKBUDDY_HOST_HEARTBEAT_FILENAME, WORKBUDDY_MODELS_REFRESH_PATH, WORKBUDDY_PROBE_PATH, WORKBUDDY_PROVIDER, WORKBUDDY_PROVIDERS, WORKBUDDY_PROVIDER_DISPLAY_NAMES, WORKBUDDY_REGIONS, WORKBUDDY_REGION_PARAM, WORKBUDDY_SETTINGS_NS, WORKBUDDY_STREAM_IDLE_TIMEOUT_MS, WORKBUDDY_TPS_PATH, WORKBUDDY_USAGE_PATH, type WorkBuddyAccountChoice, type WorkBuddyAdapter, type WorkBuddyAuthStatus, type WorkBuddyCandidateFailure, WorkBuddyCatalog, type WorkBuddyChatResult, type WorkBuddyCredential, type WorkBuddyCredentialRecovery, WorkBuddyCredentialRejectedError, WorkBuddyCredentialStore, type WorkBuddyCreditPackage, type WorkBuddyCredits, WorkBuddyEncryptedCredentialError, type WorkBuddyEncryptedField, type WorkBuddyHostHeartbeat, type WorkBuddyModelInfo, type WorkBuddyNativeModality, WorkBuddyPoolPreferences, type WorkBuddyProbeClient, type WorkBuddyProbeOutcome, type WorkBuddyProbeResult, type WorkBuddyProbeStore, type WorkBuddyReasoning, type WorkBuddyRecoveryCandidate, type WorkBuddyRefreshOutcome, WorkBuddyRegionState, type WorkBuddyShim, type WorkBuddyStatusRouteOptions, type WorkBuddyStoreOptions, WorkBuddyUpstreamClient, type WorkBuddyUpstreamModel, type WorkBuddyUsabilityProbeOptions, apply, asVolatile, authFileName, classifyUpstreamError, clearAtRestKeyCache, clearHostHeartbeat, cooldownOf, createAccountUsabilityProbe, createWorkBuddyAdapter, createWorkBuddyShim, creditOfStream, defaultDesktopAuthCandidates, defaultDesktopAuthDirs, defaultDesktopAuthPath, defaultOffModelIds, deriveAtRestKey, deriveAtRestKeyId, deriveCatalog, fallbackModelsFor, fetchAtRestKeyPayload, findWorkbuddyAppExecutable, hasEncryptedCredentialFields, imageDefaultFor, imageToolRegionOf, inject, isCredentialRejectedError, isEncryptedCredentialError, isEncryptedFieldWrapper, isHeartbeatProcessAlive, isWorkbuddyBundle, knownRegionOf, legacyAttributionRegion, legacyWorkbuddyOwnAuthPath, macosBundleExecutable, macosNestedAppBundles, modelIdOfBody, name, nativeModalityOf, nextRegionEnabled, nextRegionSlots, offDefaultFor, openEncryptedField, outcomeOfFailure, parseCreditMultiplier, parseReasoning, parseRetryAfter, parseUpstreamModel, parseWorkBuddyAuth, prepareChatBody, probeModel, probeRequestBody, probeSucceeded, processStartTimeMs, readAtRestKey, readHostHeartbeat, realTierAvailabilityFor, regionCleared, regionEnabled, regionEnabledOf, regionOf, regionOfProvider, regionOfStatusUrl, regionStateOf, regionsFieldIsCorrupt, regionsMapOf, registerWorkBuddyStatusRoute, resolveCredentialRecovery, selectAccountFor, settingsNamespaceOf, toPersistedWorkBuddyModel, unwrapVolatileDeep, videoToolRegionOf, withEffectiveOff, withWorkBuddyRegion, workBuddyDisplayName, workBuddyModelInput, workBuddyThinkingLevelMap, workBuddyWebStatus, workbuddyAccountId, workbuddyAppExecutableCandidates, workbuddyHostHeartbeatPath, workbuddyOwnAuthPath, writeHostHeartbeat };
|
|
6329
|
+
export { CREDENTIAL_REJECTED_CODE, Config, DEFAULT_PROBE_INPUT_TOKENS, ENCRYPTED_CREDENTIAL_CODE, FALLBACK_WORKBUDDY_MODELS, FALLBACK_WORKBUDDY_MODELS_GLOBAL, NATIVE_MODALITY_BY_MODEL_ID, PROBE_INPUT_TOKEN_CHOICES, PROBE_MAX_TOKENS, PROBE_SYSTEM_PROMPT, REFUSES_OFF_MODEL_IDS, type UpstreamErrorKind, WORKBUDDY_ACCOUNTS_REFRESH_PATH, WORKBUDDY_APP_EXECUTABLE_ENV, WORKBUDDY_AUTH_FILENAME, WORKBUDDY_AUTH_FILE_ENV, WORKBUDDY_CHECKIN_PATH, WORKBUDDY_CONNECT_VERSION, WORKBUDDY_GLOBAL_PROVIDER, WORKBUDDY_HOST_HEARTBEAT_FILENAME, WORKBUDDY_MODELS_REFRESH_PATH, WORKBUDDY_PROBE_PATH, WORKBUDDY_PROVIDER, WORKBUDDY_PROVIDERS, WORKBUDDY_PROVIDER_DISPLAY_NAMES, WORKBUDDY_REGIONS, WORKBUDDY_REGION_PARAM, WORKBUDDY_SETTINGS_NS, WORKBUDDY_STREAM_IDLE_TIMEOUT_MS, WORKBUDDY_TPS_PATH, WORKBUDDY_USAGE_PATH, type WorkBuddyAccountChoice, type WorkBuddyAdapter, type WorkBuddyAuthStatus, type WorkBuddyCandidateFailure, WorkBuddyCatalog, type WorkBuddyChatResult, type WorkBuddyCredential, type WorkBuddyCredentialRecovery, WorkBuddyCredentialRejectedError, WorkBuddyCredentialStore, type WorkBuddyCreditPackage, type WorkBuddyCredits, WorkBuddyEncryptedCredentialError, type WorkBuddyEncryptedField, type WorkBuddyHostHeartbeat, type WorkBuddyHostHeartbeatOwner, type WorkBuddyModelInfo, type WorkBuddyNativeModality, WorkBuddyPoolPreferences, type WorkBuddyProbeClient, type WorkBuddyProbeOutcome, type WorkBuddyProbeResult, type WorkBuddyProbeStore, type WorkBuddyReasoning, type WorkBuddyRecoveryCandidate, type WorkBuddyRefreshOutcome, WorkBuddyRegionState, type WorkBuddyShim, type WorkBuddyStatusRouteOptions, type WorkBuddyStoreOptions, WorkBuddyUpstreamClient, type WorkBuddyUpstreamModel, type WorkBuddyUsabilityProbeOptions, apply, asVolatile, authFileName, classifyUpstreamError, clearAtRestKeyCache, clearHostHeartbeat, cooldownOf, createAccountUsabilityProbe, createWorkBuddyAdapter, createWorkBuddyShim, creditOfStream, defaultDesktopAuthCandidates, defaultDesktopAuthDirs, defaultDesktopAuthPath, defaultOffModelIds, deriveAtRestKey, deriveAtRestKeyId, deriveCatalog, fallbackModelsFor, fetchAtRestKeyPayload, findWorkbuddyAppExecutable, hasEncryptedCredentialFields, imageDefaultFor, imageToolRegionOf, inject, isCredentialRejectedError, isEncryptedCredentialError, isEncryptedFieldWrapper, isHeartbeatProcessAlive, isWorkbuddyBundle, knownRegionOf, legacyAttributionRegion, legacyWorkbuddyOwnAuthPath, macosBundleExecutable, macosNestedAppBundles, modelIdOfBody, name, nativeModalityOf, nextRegionEnabled, nextRegionSlots, offDefaultFor, openEncryptedField, outcomeOfFailure, parseCreditMultiplier, parseReasoning, parseRetryAfter, parseUpstreamModel, parseWorkBuddyAuth, prepareChatBody, probeModel, probeRequestBody, probeSucceeded, processStartTimeMs, readAtRestKey, readHostHeartbeat, realTierAvailabilityFor, regionCleared, regionEnabled, regionEnabledOf, regionOf, regionOfProvider, regionOfStatusUrl, regionStateOf, regionsFieldIsCorrupt, regionsMapOf, registerWorkBuddyStatusRoute, resolveCredentialRecovery, selectAccountFor, settingsNamespaceOf, toPersistedWorkBuddyModel, unwrapVolatileDeep, videoToolRegionOf, withEffectiveOff, withWorkBuddyRegion, workBuddyDisplayName, workBuddyModelInput, workBuddyThinkingLevelMap, workBuddyWebStatus, workbuddyAccountId, workbuddyAppExecutableCandidates, workbuddyHostHeartbeatPath, workbuddyOwnAuthPath, writeHostHeartbeat };
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $t as
|
|
1
|
+
import { $t as pickMediaModel, A as withoutRouters, An as resolveDshHome, At as lastRefusalFor, B as defaultDesktopAuthPath, Bt as resolveVideoParams, C as setDeviceMode, Cn as isWorkbuddyBundle, Ct as rewriteSessionTitleModel, D as applyContextBudgets, Dn as readAtRestKey, Dt as selectPromoBadge, E as WorkBuddyCatalog, En as openEncryptedField, Et as promoBadgeTone, F as WorkBuddyCredentialStore, Ft as VIDEO_TAG_IMAGE_TO_VIDEO, G as parseWorkBuddyAuth, Gt as WorkBuddyImageError, H as isEncryptedCredentialError, Ht as IMAGE_TAG_IMAGE_TO_IMAGE, I as WorkBuddyEncryptedCredentialError, It as VIDEO_TAG_TEXT_TO_VIDEO, J as workbuddyOwnAuthPath, Jt as imageModelChoices, K as preferredAccountName, Kt as imageDataUrl, L as authFileName, Lt as WorkBuddyVideoError, M as WORKBUDDY_AUTH_FILENAME, Mn as writeFileAtomic, Mt as offRefused, N as WORKBUDDY_AUTH_FILE_ENV, Nt as recordRefusal, O as deriveCatalog, On as workbuddyAppExecutableCandidates, Ot as REFUSES_OFF_MODEL_IDS, Pt as withEffectiveOff, Q as CREDENTIAL_REJECTED_CODE, Qt as parseImageDataUrl, R as defaultDesktopAuthCandidates, Rt as parseSupportedSecondsRange, S as saveDeviceSdkSettings, Sn as isEncryptedFieldWrapper, St as requestEvidenceOf, T as FALLBACK_WORKBUDDY_MODELS_GLOBAL, Tn as macosNestedAppBundles, Tt as attachBusyLevels, U as isVaultAccountId, Ut as IMAGE_TAG_TEXT_TO_IMAGE, V as hasEncryptedCredentialFields, Vt as IMAGE_SIZE_LIMITS_WIDE, W as legacyWorkbuddyOwnAuthPath, Wt as MAX_INPUT_IMAGE_BYTES, X as APP_VERSION, Xt as isBareBase64Image, Yt as imageSizeLimitsOf, Z as CONTEXT_OVERFLOW_MARKER, Zt as isWatermarkFreeImageModel, _ as createDeviceProfileLookup, _n as deriveAtRestKey, _t as parseReasoning, a as readHostHeartbeat, an as imageDefaultFor, at as declaredTools, b as readDeviceSettings, bn as findWorkbuddyAppExecutable, bt as prepareChatBody, c as WORKBUDDY_CONNECT_VERSION, ct as isContextTooLongBody, dt as isFirstMessageGateBody, en as sniffImageMime, et as WORKBUDDY_FALLBACK_SYSTEM_PROMPT, fn as isDeviceId, ft as isToolSchemaRejectBody, g as createTuringSdk, gn as clearAtRestKeyCache, gt as parseCreditMultiplier, h as createDeviceSdkPort, hn as WORKBUDDY_APP_EXECUTABLE_ENV, ht as openingEvidenceOfBody, i as processStartTimeMs, in as NATIVE_MODALITY_BY_MODEL_ID, it as classifyUpstreamError, j as ENCRYPTED_CREDENTIAL_CODE, jn as withFileLock, jt as offDefaultFor, k as fallbackModelsFor, kt as defaultOffModelIds, l as createFileRosterSeenStore, lt as isConversationIdGateBody, m as piAiRuntimeInfo, mt as modelIdOfBody, n as clearHostHeartbeat, nn as queueNoticeText, nt as WorkBuddyUpstreamClient, o as workbuddyHostHeartbeatPath, on as nativeModalityOf, p as resolveCnGateway, pt as knownRegionOf, q as workbuddyAccountId, qt as imageMimeForPath, r as isHeartbeatProcessAlive, rn as pruneTempDir, rt as channelGateMemberOf, s as writeHostHeartbeat, st as forceNeutralHead, t as WORKBUDDY_HOST_HEARTBEAT_FILENAME, tn as parseQueueAnswer, tt as WorkBuddyCredentialRejectedError, ut as isCredentialRejectedError, v as describeDerivedDevices, vn as deriveAtRestKeyId, vt as parseUpstreamModel, w as FALLBACK_WORKBUDDY_MODELS, wn as macosBundleExecutable, wt as toolSchemaRejectAdvice, x as saveDeviceProfile, xt as regionOf, y as isDeviceMode, yn as fetchAtRestKeyPayload, yt as perturbChannelFingerprints, z as defaultDesktopAuthDirs, zt as pickVideoModel } from "./host-heartbeat-Q85k2yEL.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";
|
|
@@ -6154,8 +6154,9 @@ function createWorkBuddyShim(options) {
|
|
|
6154
6154
|
if (detail?.requestId !== void 0) meta.push(`requestId ${detail.requestId}`);
|
|
6155
6155
|
const stamp = meta.length === 0 ? "" : `(${meta.join(",")})`;
|
|
6156
6156
|
const refusedTier = reasoningTierRefusal(result);
|
|
6157
|
-
const
|
|
6158
|
-
const
|
|
6157
|
+
const toolSchemaRefused = result.kind === "client" && isToolSchemaRejectBody(result.message);
|
|
6158
|
+
const receipt = refusedTier ?? (toolSchemaRefused ? toolSchemaRejectAdvice() : void 0) ?? detail?.tips ?? detail?.displayMsg ?? clippedUpstreamText(result.message, 400);
|
|
6159
|
+
const advice = refusedTier !== void 0 ? "这不是账号或网络问题:该模型实测拒绝「off」推理档位,请到模型卡片里取消该行的「可关闭思考」勾选后重试" : toolSchemaRefused ? "按上面列出的写法检查工具定义;换模型只是绕开,不会修好它" : result.kind === "client" ? "该请求被上游按参数拒绝:与网络、账号、额度都无关,换账号也不会改变结果,请按上面的提示调整后重试" : shortfall === void 0 ? "" : "建议换一个模型继续,或稍后等待该账号的额度恢复";
|
|
6159
6160
|
const body = `${isContextTooLongBody(result.message) ? `${CONTEXT_OVERFLOW_MARKER}。` : ""}${advice === "" ? receipt : `${receipt.replace(/[。.]$/u, "")}。${advice}`}`;
|
|
6160
6161
|
writeOpenAIError(res, KIND_STATUS[result.kind], result.kind, `workbuddy 上游失败:${failoverReasonText(result)}(http ${result.status})${note}${why}${stamp}。${body}`, hostErrorCode(result.kind));
|
|
6161
6162
|
return;
|
|
@@ -15650,10 +15651,12 @@ function apply(ctx, config) {
|
|
|
15650
15651
|
} catch {}
|
|
15651
15652
|
})();
|
|
15652
15653
|
let stopped = false;
|
|
15653
|
-
|
|
15654
|
+
let heartbeatWrite;
|
|
15655
|
+
ctx.effect(() => async () => {
|
|
15654
15656
|
stopped = true;
|
|
15655
15657
|
for (const region of REGION_KEYS) stacks[region].shim.close();
|
|
15656
|
-
|
|
15658
|
+
const owner = await heartbeatWrite;
|
|
15659
|
+
if (owner !== void 0) await clearHostHeartbeat(owner);
|
|
15657
15660
|
});
|
|
15658
15661
|
Promise.all(REGION_KEYS.map((region) => stacks[region].shim.ready)).then(async () => {
|
|
15659
15662
|
if (stopped) return;
|
|
@@ -15754,7 +15757,10 @@ function apply(ctx, config) {
|
|
|
15754
15757
|
inputModalities: workBuddyModelInput(model)
|
|
15755
15758
|
}));
|
|
15756
15759
|
});
|
|
15757
|
-
|
|
15760
|
+
const logger = ctx.logger;
|
|
15761
|
+
heartbeatWrite = writeHostHeartbeat().catch((error) => {
|
|
15762
|
+
logger.error("dsh-connect-workbuddy: host heartbeat write failed", error);
|
|
15763
|
+
});
|
|
15758
15764
|
} catch (error) {
|
|
15759
15765
|
ctx.logger.error("dsh-connect-workbuddy: provider registration failed", error);
|
|
15760
15766
|
return;
|
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.
|
|
5
|
+
"version": "5.24.2",
|
|
6
6
|
"author": "dingminhua",
|
|
7
7
|
"copyright": "Copyright (c) 2026 LaoDing",
|
|
8
8
|
"license": "MIT",
|