dsh-connect-workbuddy 5.20.32 → 5.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +151 -3
- package/lib/bin.js +1 -1
- package/lib/client.js +243 -12
- package/lib/{host-heartbeat-DekAOmo0.js → host-heartbeat-BLfxyXIA.js} +1 -1
- package/lib/index.js +80 -12
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,143 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 5.21.0 (2026-11-08)
|
|
4
|
+
|
|
5
|
+
> 版本号是 **minor**:注册的**条数**随宿主的声明变化(`single` 一条、`keyed` 每个
|
|
6
|
+
> provider 一条)。不改配置键、不动路由、不改用户可见的文案。
|
|
7
|
+
|
|
8
|
+
### 模型标签槽:按宿主的声明注册,为 `keyed` 做好准备
|
|
9
|
+
|
|
10
|
+
`conversation.input.model.label` 的 kind 写在宿主包里(`ui-model-selection`)。
|
|
11
|
+
在它改口之前是 `single`:只有一格,三家连接器只能按 `-101` / `-102` / `-105`
|
|
12
|
+
互相压价,而且每一轮都有人再往下压一格。目标形态是 `keyed`——每个 `options.key`
|
|
13
|
+
自成一格,宿主按 `provider.id` 派发 `{ entryKey }`,没人贡献的 provider 落回宿主
|
|
14
|
+
自己的 fallback。
|
|
15
|
+
|
|
16
|
+
本版做的是一件插件侧唯一该做的事:**注册几条跟着宿主声明的 kind 走。**
|
|
17
|
+
|
|
18
|
+
- 新增 `src/client/model-label-seat.ts`:运行时读 `ctx.slots.spec(key)?.kind`,
|
|
19
|
+
`keyed` 就为 `workbuddy` / `workbuddy-global` 各注册一格,其余情况(含读不到)
|
|
20
|
+
保持历史上的单条。**一个构建同时服务两条宿主线**,宿主改口那天不需要重新发版。
|
|
21
|
+
读不到时退回单条是保守方向:那正是每个已发布版本的行为。
|
|
22
|
+
- 诊断视图新增 `slotKind` / `seats`:选择器只有一个症状(没有徽标),但对应两种
|
|
23
|
+
完全不同的处境——`single` 宿主上被同优先级的对手抢了格子,和 `keyed` 宿主上漏了
|
|
24
|
+
某个 provider。有了这两个字段,报告就能区分它们,而两者的修法互为对方的 bug。
|
|
25
|
+
|
|
26
|
+
### 为什么不能只改宿主
|
|
27
|
+
|
|
28
|
+
两个方向都会**静默**失败,因为这里的注册包在吞错 try/catch 里:
|
|
29
|
+
|
|
30
|
+
| 情况 | 结果 |
|
|
31
|
+
| --- | --- |
|
|
32
|
+
| keyed 的两条打到 `single` 宿主 | 第二条抛 `already has a registration`,第一条已落地 → 半注册 |
|
|
33
|
+
| 无 key 的一条打到 `keyed` 宿主 | 抛 `keyed slot … requires options.key` → 标签消失 |
|
|
34
|
+
|
|
35
|
+
`keyed` **强制要求 `key`**,这是上游提案里没写的第一道陷阱:**此前已发布**的本族每个
|
|
36
|
+
版本都注册一条无 key 的条目,只改宿主声明会让它们一起失效(本版之后的新构建会跟着
|
|
37
|
+
声明走,所以受影响的正是「已经装在用户机器上」的那些版本)。第二道陷阱见下一节。
|
|
38
|
+
|
|
39
|
+
`MODEL_LABEL_PRIORITY = -105` 不改。keyed 下它不再决定可见性,只剩「同一格内谁先」;
|
|
40
|
+
三家之间不再有压制关系——停战靠的是换槽的基数,不是再压一次价。
|
|
41
|
+
|
|
42
|
+
外来行分支保留:keyed 下运行时走不到,但一个构建要同时服务两种宿主,而 `single`
|
|
43
|
+
宿主上它就是整行文字。它同时也是最便宜的哨兵——自己的行若走进那一支,说明 `key`
|
|
44
|
+
写错了。
|
|
45
|
+
|
|
46
|
+
### 导入大文件不再「传输失败:Failed to fetch」(issue #229 第二次报告)
|
|
47
|
+
|
|
48
|
+
第一轮修的是**包装**(`{accounts: […]}` 认不出来)。用户随后报的是另一半:Cockpit Tools
|
|
49
|
+
导出的**单个**账号文件就有 108 KiB,导入直接失败,而且报的是浏览器原生的
|
|
50
|
+
`Failed to fetch`——连一个 HTTP 响应都没收到。
|
|
51
|
+
|
|
52
|
+
两个独立缺陷叠在一起:
|
|
53
|
+
|
|
54
|
+
**① 传输路由借用了探测路由的体积上限。** `readJsonBody` 的上限是 64 KiB(那是 probe
|
|
55
|
+
路由的假设:只传模型 id),而 transfer 路由传的是**整份账号导出文件**。一个账号就超了。
|
|
56
|
+
|
|
57
|
+
**② 超限分支仍然是 `req.destroy()`。** 这会把底层 socket 拆掉,于是错误响应**根本发不
|
|
58
|
+
出去**,浏览器只能报 `Failed to fetch`。这一条 #174 ④ 已经修过——但只落在 chat 路由的
|
|
59
|
+
`readBody()` 上,`readJsonBody` 没同步改。因为 transfer 是唯一接收**文件**的路由,
|
|
60
|
+
所以这个遗留缺陷恰好在这里咬人。
|
|
61
|
+
|
|
62
|
+
修法:
|
|
63
|
+
|
|
64
|
+
| 项 | 之前 | 现在 |
|
|
65
|
+
| --- | --- | --- |
|
|
66
|
+
| transfer 上限 | 64 KiB(与 probe 共用) | 64 MiB(与 chat 路由同量级) |
|
|
67
|
+
| 超限行为 | `req.destroy()` → 无响应 | 摘监听 + `pause()` → **响应送达** |
|
|
68
|
+
| 超限状态码 | 500(且实际发不出去) | **413**(具名错误类分类,客户端的问题就报客户端) |
|
|
69
|
+
|
|
70
|
+
**③ 顺带剥掉纯冗余的原始快照。** 第三方文件里 `quota_raw` / `usage_raw` 合计约 59 KiB,
|
|
71
|
+
而本插件**从不读**它们(`credentialOfTransferRecord` 只取契约字段,`transferRecordOf`
|
|
72
|
+
也从不写)。现在解析时丢掉所有 `*_raw` 键,**唯独保留 `auth_raw`**——它带计费 `uin`,
|
|
73
|
+
丢了会改变「重新导入落到哪个账号」,不只是改变文件大小。
|
|
74
|
+
|
|
75
|
+
实测:同一份一个账号的文件 **62488 B → 3361 B**(约 1/18),契约字段与 `auth_raw` 全部保留。
|
|
76
|
+
|
|
77
|
+
**④ 网络层错误说人话。** `TypeError` 单独映射成「与本地插件服务通信失败(本次发送
|
|
78
|
+
N KiB)」,并提示可能是文件过大或服务重启——客户端分不清连接被重置和服务没起来,
|
|
79
|
+
所以两个原因都写出来,而不是猜一个。
|
|
80
|
+
|
|
81
|
+
测试(均做变异验证):
|
|
82
|
+
|
|
83
|
+
- `web-status.spec.ts`:110 KiB 上传**成功**走通(变异回 64 KiB → 红);真正超限时
|
|
84
|
+
**413 且 socket 未被销毁**(变异回 `req.destroy()` → 红;这条断言最初被我写成
|
|
85
|
+
「destroy 抛错」,实际会被 emitter 吞掉,改成记录标志位才有咬合力)。
|
|
86
|
+
- `transfer.spec.ts`:剥离 `*_raw` 且保留 `auth_raw`(变异成全剥 → 红)、剥离后
|
|
87
|
+
凭据仍能正确还原(`uid` 与 `uin` 路径都在)、包装形式同样会被剥离。
|
|
88
|
+
|
|
89
|
+
### 修一处自查出来的回归:同一失败被发布两次会重复告警
|
|
90
|
+
|
|
91
|
+
复核「改动后旧需求是否依然满足」时发现的,**不是测试红出来的**——测试全绿。
|
|
92
|
+
|
|
93
|
+
为了把 `slotKind` / `seats` 送进 `window`,`publishModelLabelState` 从「每次 rebind 调一次」
|
|
94
|
+
变成了两个调用点(`rebindSlots` + inject 回调)。但它的文档承诺是**每次 rebind 只告警一次**,
|
|
95
|
+
于是同一次失败会走两遍发布、把同一句话打两遍——正好破坏这个函数自己头部警告过的原则
|
|
96
|
+
(总是在响的告警就没人读了)。
|
|
97
|
+
|
|
98
|
+
改为按失败文本去重:同一条失败只说一次,失败内容变了仍然要说。
|
|
99
|
+
|
|
100
|
+
同时修正一句已经变假的话:`Exported for the test; never called outside rebindSlots`。
|
|
101
|
+
现在有两个调用点,后一次必然覆盖前一次(延迟回调才读得到 `slotKind` 与真正落地的 `seats`)。
|
|
102
|
+
|
|
103
|
+
新增测试:诊断侧「同一失败发布两次只告警一次 / 不同失败仍告警 / 健康发布永不告警」,
|
|
104
|
+
配线侧三条**旧契约**用例(disposer 真释放格子且重复释放安全、赢家仍是完整标签、
|
|
105
|
+
两个形状上优先级都还是 -105)。前两条都做了变异验证。
|
|
106
|
+
|
|
107
|
+
### 文档更正:是 `keyed`,不是 `list`
|
|
108
|
+
|
|
109
|
+
`docs/DESIGN.md` §零 第 3 条与 `docs/MODEL-LABEL-SPEC.md` 此前都说「把槽改成
|
|
110
|
+
`list` 或 `chain` 是唯一根治方向」。那两条判断都不成立:`list` 每次调用渲染
|
|
111
|
+
**全部**存活行,做不出「一个 provider 一行」,而且要求 `options.id`(同 id 同
|
|
112
|
+
优先级抛错);`chain` 按 `select()` 选唯一赢家,语义同 `single`。只有 **`keyed`**
|
|
113
|
+
成立。两处已更正(5.20.31 那条历史结论也已就近标注)。
|
|
114
|
+
|
|
115
|
+
### 关键前提:改声明不够,宿主还必须传 `entryKey`
|
|
116
|
+
|
|
117
|
+
这一条是复核实机产物时发现的,值得单独写下来——**光把槽声明成 `keyed` 会让全族
|
|
118
|
+
的标签一起消失,而且不报错。**
|
|
119
|
+
|
|
120
|
+
`@deepseek-ai/dsh-client-ui-model-selection@0.2.2-rc.1` 里渲染这个槽只有一个调用点:
|
|
121
|
+
|
|
122
|
+
```js
|
|
123
|
+
renderSlot("conversation.input.model.label",
|
|
124
|
+
{ provider, model, placement, selected },
|
|
125
|
+
{ fallback: model.badge === void 0 ? model.name : <badge> })
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
第三个参数只有 `fallback`,**没有 `entryKey`**。而渲染器的 keyed 分支是
|
|
129
|
+
`entriesOfSlot(key).find(e => e.options.key === opts?.entryKey)`——`opts.entryKey`
|
|
130
|
+
是 `undefined` 时匹配不到任何「以 provider id 为 key」的条目,于是**每一行**都走
|
|
131
|
+
`fallback`。插件侧的注册**成功**,没有抛错,也没有日志,只是再也不会被调用。
|
|
132
|
+
|
|
133
|
+
所以上游要改的是两处:**声明改成 `keyed`,且调用点补 `{ entryKey: provider.id }`**。
|
|
134
|
+
缺第二处时,本版本的代码无法自检(注册成功、回调也跑了),症状是「标签没了且没有
|
|
135
|
+
错误」——正是这次想根治的那种静默。
|
|
136
|
+
|
|
137
|
+
顺带:宿主自己的契约注册表把该槽登记为 `registerOptions: []` 并给了一个**无 key** 的
|
|
138
|
+
示例,README 同样如此。也就是说「无 key 注册」是它**文档化的写法**,这会放大上面
|
|
139
|
+
那个陷阱的半径——所有照文档写的第三方贡献者都会中招。
|
|
140
|
+
|
|
3
141
|
## 5.20.32 (2026-11-08)
|
|
4
142
|
|
|
5
143
|
> **导入闭环修好了;历史思考可以按需剥掉;页面宽度回到原来的样子。**
|
|
@@ -205,9 +343,19 @@ Tests 3320 → 3323(新增 4 条:静默、灰点、分隔符、面板那一
|
|
|
205
343
|
**这只是把问题挪到了另一边,不是修复。** `single` 语义下赢家要画所有行,
|
|
206
344
|
所以 trae 和 qoder 的胶囊现在会从选择器里消失——和我们之前遭遇的一模一样。
|
|
207
345
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
346
|
+
真正的修复在宿主一侧:这个槽位**不该是 `single`**。已向上游提交讨论,理由和实测数据都在里面。
|
|
347
|
+
`docs/DESIGN.md` §零 早就把这个方向列为「唯一能根治」的,这次终于有了真实案例。
|
|
348
|
+
|
|
349
|
+
> **2026-11-08 更正:是 `keyed`,不是 `list`。** 当时这条写的是 `list`,那个判断是错的:
|
|
350
|
+
> `list` 每次调用把**全部**存活行一起渲染,做不出「一个 provider 一行」;它还要求每条注册
|
|
351
|
+
> 带 `options.id`,同 id 同优先级抛错——只是把「抢一格」换成「抢一个 id」。`chain` 更不行,
|
|
352
|
+
> 它按 `select()` 选唯一赢家,语义与 `single` 相同。**`keyed` 才是**:每个 `options.key`
|
|
353
|
+
> 自成一格,宿主按 `provider.id` 派发 `{ entryKey }`,没人贡献的 provider 落回宿主自己的
|
|
354
|
+
> fallback。三家的注册也已按宿主的声明准备好(见 5.21.0)。
|
|
355
|
+
>
|
|
356
|
+
> ⚠️ 但**改声明不够**:实机产物里宿主渲染该槽的调用点并没有传 `entryKey`,只改了声明
|
|
357
|
+
> 会让**每一行**都落到 fallback,插件注册成功却再也不被调用(无异常、无日志)。完整
|
|
358
|
+
> 的上游要求见 5.21.0 的「关键前提」一节。
|
|
211
359
|
|
|
212
360
|
### 测试
|
|
213
361
|
|
package/lib/bin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { $ as DEFAULT_WIRE_PROFILE, Cn as hostPeersInfo, 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, an as deriveDeviceId, b as readDeviceSettings, c as WORKBUDDY_CONNECT_VERSION, cn as protectCredentialDirectory, d as rosterSeenPath, f as WORKBUDDY_CN_BASE_ENV, g as createTuringSdk, hn as findWorkbuddyAppExecutableWithSource, in as readDeviceSalt, ln as WORKBUDDY_APP_EXECUTABLE_ENV, m as piAiRuntimeInfo, nn as readDeviceTokenFile, nt as WorkBuddyUpstreamClient, o as workbuddyHostHeartbeatPath, ot as describeRequestHeaderNames, p as resolveCnGateway, r as isHeartbeatProcessAlive, rn as ensureDeviceSalt, sn as inspectCredentialDirectory, tn as WORKBUDDY_DEVICE_TOKEN_FILE_ENV, u as describeRosterSeenPayload, w as FALLBACK_WORKBUDDY_MODELS, wn as resolveDshHome, z as defaultDesktopAuthDirs } from "./host-heartbeat-
|
|
2
|
+
import { $ as DEFAULT_WIRE_PROFILE, Cn as hostPeersInfo, 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, an as deriveDeviceId, b as readDeviceSettings, c as WORKBUDDY_CONNECT_VERSION, cn as protectCredentialDirectory, d as rosterSeenPath, f as WORKBUDDY_CN_BASE_ENV, g as createTuringSdk, hn as findWorkbuddyAppExecutableWithSource, in as readDeviceSalt, ln as WORKBUDDY_APP_EXECUTABLE_ENV, m as piAiRuntimeInfo, nn as readDeviceTokenFile, nt as WorkBuddyUpstreamClient, o as workbuddyHostHeartbeatPath, ot as describeRequestHeaderNames, p as resolveCnGateway, r as isHeartbeatProcessAlive, rn as ensureDeviceSalt, sn as inspectCredentialDirectory, tn as WORKBUDDY_DEVICE_TOKEN_FILE_ENV, u as describeRosterSeenPayload, w as FALLBACK_WORKBUDDY_MODELS, wn as resolveDshHome, z as defaultDesktopAuthDirs } from "./host-heartbeat-BLfxyXIA.js";
|
|
3
3
|
import { readFile } from "node:fs/promises";
|
|
4
4
|
import { dirname, join } from "node:path";
|
|
5
5
|
import { realpathSync } from "node:fs";
|
package/lib/client.js
CHANGED
|
@@ -5765,6 +5765,27 @@ window.__ModuleLoader__.load({
|
|
|
5765
5765
|
});
|
|
5766
5766
|
}
|
|
5767
5767
|
};
|
|
5768
|
+
/**
|
|
5769
|
+
* Turn a transport-level failure into something a person can act on.
|
|
5770
|
+
*
|
|
5771
|
+
* `fetch()` rejects with a bare `TypeError: Failed to fetch` whenever no HTTP
|
|
5772
|
+
* response arrives at all — the connection was reset, or the text could not be
|
|
5773
|
+
* posted. Rendered verbatim that reads like a bug in the plugin (issue #229:
|
|
5774
|
+
* the user saw "传输失败:Failed to fetch" and had nothing to go on). The two
|
|
5775
|
+
* causes worth naming are a file too large to upload and a local service that
|
|
5776
|
+
* is not answering; anything else keeps its own message, which is more
|
|
5777
|
+
* informative than a generic one.
|
|
5778
|
+
*
|
|
5779
|
+
* Note this is the CLIENT's guess: the server now answers 413 for an oversized
|
|
5780
|
+
* body, so a size problem usually arrives as a normal error response and never
|
|
5781
|
+
* reaches here. This path is what is left when the request dies before an
|
|
5782
|
+
* answer — which is also what a half-open local port looks like.
|
|
5783
|
+
*/
|
|
5784
|
+
const transportMessage = (error, text) => {
|
|
5785
|
+
if (!(error instanceof TypeError)) return error instanceof Error ? error.message : String(error);
|
|
5786
|
+
const kilobytes = Math.round(new Blob([text]).size / 1024);
|
|
5787
|
+
return t("row.transferNoService", { size: String(kilobytes) });
|
|
5788
|
+
};
|
|
5768
5789
|
const readImportFile = async (file) => {
|
|
5769
5790
|
setPhase({ kind: "importing" });
|
|
5770
5791
|
try {
|
|
@@ -5794,7 +5815,7 @@ window.__ModuleLoader__.load({
|
|
|
5794
5815
|
} catch (error) {
|
|
5795
5816
|
if (mounted.current) setPhase({
|
|
5796
5817
|
kind: "error",
|
|
5797
|
-
message: error
|
|
5818
|
+
message: transportMessage(error, importText.current)
|
|
5798
5819
|
});
|
|
5799
5820
|
}
|
|
5800
5821
|
};
|
|
@@ -13641,6 +13662,16 @@ ${u} ${p}-pool .sw input:checked+.sw-track::after{transform:translateX(16px)}
|
|
|
13641
13662
|
/** The provider ids this plugin registers, and the region each one serves. */
|
|
13642
13663
|
const PROVIDER_REGIONS = /* @__PURE__ */ new Map([["workbuddy", "cn"], ["workbuddy-global", "global"]]);
|
|
13643
13664
|
/**
|
|
13665
|
+
* Every provider id this plugin owns, as a list.
|
|
13666
|
+
*
|
|
13667
|
+
* Exported because on a `keyed` host the label seat is one registration PER
|
|
13668
|
+
* provider id — the registration side needs the same list the component uses to
|
|
13669
|
+
* decide "is this row mine", and two copies of it would drift. Order is
|
|
13670
|
+
* irrelevant to the registry (each id is its own cell); it is stable so the
|
|
13671
|
+
* diagnostics line reads the same on every boot.
|
|
13672
|
+
*/
|
|
13673
|
+
const WORKBUDDY_PROVIDER_IDS = [...PROVIDER_REGIONS.keys()];
|
|
13674
|
+
/**
|
|
13644
13675
|
* The region a provider id serves, or `undefined` for a provider that is not
|
|
13645
13676
|
* this plugin's.
|
|
13646
13677
|
*
|
|
@@ -13960,6 +13991,17 @@ ${u} ${p}-pool .sw input:checked+.sw-track::after{transform:translateX(16px)}
|
|
|
13960
13991
|
* any other contributor (name + price + promotion + load + new-model mark), so
|
|
13961
13992
|
* it should be the one that takes the cell when several want it.
|
|
13962
13993
|
*
|
|
13994
|
+
* WHAT CHANGES WHEN THE HOST KEYS THE SLOT — and why the number stays. On a host
|
|
13995
|
+
* that declares this slot `keyed`, the seat is registered once per provider id
|
|
13996
|
+
* (see `modelLabelSeats` in `./model-label-seat.ts`), each `key` is its own
|
|
13997
|
+
* cell, and priority stops deciding WHO IS VISIBLE: qoder's `-101` and trae's
|
|
13998
|
+
* `-102` no longer share a cell with this `-105`, so none of the three can
|
|
13999
|
+
* shadow another. Priority keeps exactly one meaning inside a cell — the
|
|
14000
|
+
* tie-breaker between two registrations that claim the SAME provider id, where
|
|
14001
|
+
* an equal value throws and the lowest renders. The value is therefore not
|
|
14002
|
+
* lowered to keep winning an auction that no longer happens; it is kept because
|
|
14003
|
+
* it is this plugin's rank for its own rows.
|
|
14004
|
+
*
|
|
13963
14005
|
* WHAT THIS PLUGIN DELIBERATELY DOES NOT DO. It does not read the slot ledger,
|
|
13964
14006
|
* does not look for another plugin's registration, and does not render another
|
|
13965
14007
|
* plugin's component. Foreign rows get the plain catalog name PLUS the model's
|
|
@@ -13996,6 +14038,21 @@ ${u} ${p}-pool .sw input:checked+.sw-track::after{transform:translateX(16px)}
|
|
|
13996
14038
|
* provider published one. There is no forwarding and no consultation of other
|
|
13997
14039
|
* plugins' registrations — see `MODEL_LABEL_PRIORITY`.
|
|
13998
14040
|
*
|
|
14041
|
+
* WHY THE FOREIGN BRANCH STILL EXISTS ON A KEYED HOST. It is unreachable there —
|
|
14042
|
+
* each seat is registered under one provider id, the owner dispatches with
|
|
14043
|
+
* `entryKey: provider.id`, so a lookup only ever finds the entry whose key
|
|
14044
|
+
* matches the row it is drawing. But ONE build serves both contracts
|
|
14045
|
+
* (`./model-label-seat.ts` derives the seats from the host's declaration), and
|
|
14046
|
+
* on a `single` host this branch is not just reachable, it is the whole row:
|
|
14047
|
+
* that host renders one winner for every provider. Deleting it would fix the
|
|
14048
|
+
* keyed case by breaking the single one.
|
|
14049
|
+
*
|
|
14050
|
+
* Its continued presence is therefore also the cheapest possible check that the
|
|
14051
|
+
* seat keys are right: on a keyed host, reaching this branch with a WorkBuddy
|
|
14052
|
+
* provider id means a seat was registered under the wrong key, and the row has
|
|
14053
|
+
* silently degraded to the host's fallback — visible as a missing load badge on
|
|
14054
|
+
* exactly those rows, nowhere else.
|
|
14055
|
+
*
|
|
13999
14056
|
* @param props - The host's model identity and the placement of this label.
|
|
14000
14057
|
* @returns The catalog name, the promotion chip when one holds, the load badge
|
|
14001
14058
|
* when the probe reported one, or a sibling's badge on a foreign row.
|
|
@@ -14085,6 +14142,114 @@ ${u} ${p}-pool .sw input:checked+.sw-track::after{transform:translateX(16px)}
|
|
|
14085
14142
|
};
|
|
14086
14143
|
}
|
|
14087
14144
|
//#endregion
|
|
14145
|
+
//#region src/client/model-label-seat.ts
|
|
14146
|
+
/**
|
|
14147
|
+
* Read the declared kind of a slot, or `undefined` when it is not declared yet.
|
|
14148
|
+
*
|
|
14149
|
+
* `spec()` is the documented read-only accessor (`SlotRegistry.spec`), present
|
|
14150
|
+
* on 0.1.7 and on 0.2.2. It is also the only way to learn the kind: the
|
|
14151
|
+
* declaration lives in the host package, and a plugin's own `SlotMap`
|
|
14152
|
+
* augmentation says what this plugin HOPES the slot is, not what the running
|
|
14153
|
+
* host declared.
|
|
14154
|
+
*
|
|
14155
|
+
* Anything unexpected — no `spec` method on an older line, a throw from a
|
|
14156
|
+
* service that is not ready, a kind this build does not know — returns
|
|
14157
|
+
* `undefined`, and the caller falls back to the single-cell shape. That is the
|
|
14158
|
+
* conservative direction: it is what every released version of this plugin
|
|
14159
|
+
* already does.
|
|
14160
|
+
*
|
|
14161
|
+
* @param slots - The `slots` service (typed loosely: the accessor is optional).
|
|
14162
|
+
* @param key - The slot key to inspect.
|
|
14163
|
+
* @returns The declared kind, or `undefined`.
|
|
14164
|
+
*/
|
|
14165
|
+
function declaredSlotKind(slots, key) {
|
|
14166
|
+
const face = slots;
|
|
14167
|
+
if (face === void 0 || typeof face.spec !== "function") return void 0;
|
|
14168
|
+
let spec;
|
|
14169
|
+
try {
|
|
14170
|
+
spec = face.spec(key);
|
|
14171
|
+
} catch {
|
|
14172
|
+
return;
|
|
14173
|
+
}
|
|
14174
|
+
const kind = spec?.kind;
|
|
14175
|
+
if (kind === "single" || kind === "list" || kind === "keyed" || kind === "chain") return kind;
|
|
14176
|
+
}
|
|
14177
|
+
/**
|
|
14178
|
+
* The registrations this plugin should make for the model-label seat.
|
|
14179
|
+
*
|
|
14180
|
+
* `keyed` yields ONE seat per provider id: each is its own cell, each renders
|
|
14181
|
+
* only the rows whose owner props carry that provider id, and a provider this
|
|
14182
|
+
* plugin does not own falls through to the owner's own fallback (the catalog
|
|
14183
|
+
* name, plus that model's `badge` on hosts that have one).
|
|
14184
|
+
*
|
|
14185
|
+
* Every other kind — including `undefined`, i.e. a host that cannot be
|
|
14186
|
+
* inspected — yields the single historical seat. That is not a degraded mode:
|
|
14187
|
+
* it is what `single` requires, and on a not-yet-declared slot it is what the
|
|
14188
|
+
* inject callback is about to find.
|
|
14189
|
+
*
|
|
14190
|
+
* An empty provider list under `keyed` would silently disable the label, so it
|
|
14191
|
+
* falls back to the single seat instead: a wrong-shaped registration that still
|
|
14192
|
+
* draws something beats a correct-shaped registration that draws nothing.
|
|
14193
|
+
*
|
|
14194
|
+
* @param params - Slot key, declared kind, this plugin's provider ids, priority.
|
|
14195
|
+
* @returns One or more `register()` option objects, in registration order.
|
|
14196
|
+
*/
|
|
14197
|
+
function modelLabelSeats(params) {
|
|
14198
|
+
const { name, kind, providerIds, priority } = params;
|
|
14199
|
+
if (kind === "list" || kind === "chain") return [];
|
|
14200
|
+
if (kind === "keyed" && providerIds.length > 0) return providerIds.map((id) => ({
|
|
14201
|
+
name,
|
|
14202
|
+
key: id,
|
|
14203
|
+
priority
|
|
14204
|
+
}));
|
|
14205
|
+
return [{
|
|
14206
|
+
name,
|
|
14207
|
+
priority
|
|
14208
|
+
}];
|
|
14209
|
+
}
|
|
14210
|
+
/**
|
|
14211
|
+
* Claim every planned seat, atomically, and hand back ONE disposer.
|
|
14212
|
+
*
|
|
14213
|
+
* WHY ATOMIC. The seat list is 2-3 entries on a `keyed` host, and `register()`
|
|
14214
|
+
* can throw on any ONE of them — a rival plugin claiming the same provider id at
|
|
14215
|
+
* the same priority, or the declaration collapsing mid-loop. A plain `.map()`
|
|
14216
|
+
* would then leave the earlier seats landed on the ledger with their disposers
|
|
14217
|
+
* unreachable (they were only ever held by the array that the throw discarded),
|
|
14218
|
+
* which is worse than failing outright: the component stays mounted, the caller
|
|
14219
|
+
* believes registration failed, and nothing will ever release those cells. On a
|
|
14220
|
+
* `single` host it also means the identity keeps a live entry that the next
|
|
14221
|
+
* `inject` re-run cannot displace without a priority clash.
|
|
14222
|
+
*
|
|
14223
|
+
* So a partial failure is rolled back in reverse order before the error is
|
|
14224
|
+
* rethrown, exactly as if it had never been attempted. The rethrow is important:
|
|
14225
|
+
* each caller already has a catch that logs, and swallowing here would hide the
|
|
14226
|
+
* refusal from the diagnostics that exist to explain it.
|
|
14227
|
+
*
|
|
14228
|
+
* A disposal that itself throws must not mask the original error, hence the
|
|
14229
|
+
* inner catch — the registry treats a second dispose as a no-op, and a broken
|
|
14230
|
+
* one must not turn one failure into a crash.
|
|
14231
|
+
*
|
|
14232
|
+
* @param seats - The plan from {@link modelLabelSeats}, in registration order.
|
|
14233
|
+
* @param register - Claims one seat and returns its disposer.
|
|
14234
|
+
* @returns One disposer that releases every seat, in reverse registration order.
|
|
14235
|
+
*/
|
|
14236
|
+
function registerModelLabelSeats(seats, register) {
|
|
14237
|
+
const claimed = [];
|
|
14238
|
+
try {
|
|
14239
|
+
for (const seat of seats) claimed.push(register(seat));
|
|
14240
|
+
} catch (error) {
|
|
14241
|
+
for (const dispose of [...claimed].reverse()) try {
|
|
14242
|
+
dispose();
|
|
14243
|
+
} catch {}
|
|
14244
|
+
throw error;
|
|
14245
|
+
}
|
|
14246
|
+
return () => {
|
|
14247
|
+
for (const dispose of [...claimed].reverse()) try {
|
|
14248
|
+
dispose();
|
|
14249
|
+
} catch {}
|
|
14250
|
+
};
|
|
14251
|
+
}
|
|
14252
|
+
//#endregion
|
|
14088
14253
|
//#region src/client/CodebuddyLive.tsx
|
|
14089
14254
|
/**
|
|
14090
14255
|
* The composer pill that says what the CodeBuddy CLI route is doing RIGHT NOW.
|
|
@@ -14619,6 +14784,7 @@ ${u} ${p}-pool .sw input:checked+.sw-track::after{transform:translateX(16px)}
|
|
|
14619
14784
|
"row.transferNoToken": "no token in this record",
|
|
14620
14785
|
"row.transferCancel": "Cancel",
|
|
14621
14786
|
"row.transferError": "Transfer failed: {message}",
|
|
14787
|
+
"row.transferNoService": "Could not reach the local plugin service ({size} KiB sent). The file may be too large, or the service may be restarting — try again, and if it keeps failing, trim the file and retry.",
|
|
14622
14788
|
"row.poolTitle": "Account pool",
|
|
14623
14789
|
"row.poolNoCandidate": "No account in this pool can be used right now.",
|
|
14624
14790
|
"row.poolNoCandidateHint": "Members are rate-limited, out of credits, rejected, or unreachable. Rate limits, drained quotas and transient failures return to the pool on their own — at the time the upstream states, or after a 30-minute fallback. Only a rejected credential needs a new sign-in.",
|
|
@@ -15163,6 +15329,7 @@ ${u} ${p}-pool .sw input:checked+.sw-track::after{transform:translateX(16px)}
|
|
|
15163
15329
|
"row.transferNoToken": "此记录没有 token",
|
|
15164
15330
|
"row.transferCancel": "取消",
|
|
15165
15331
|
"row.transferError": "传输失败:{message}",
|
|
15332
|
+
"row.transferNoService": "与本地插件服务通信失败(本次发送 {size} KiB)。可能是文件过大,或服务正在重启——请重试;若持续失败,请精简文件后再导入。",
|
|
15166
15333
|
"row.poolTitle": "账号池",
|
|
15167
15334
|
"row.poolNoCandidate": "账号池里目前没有可用的账号。",
|
|
15168
15335
|
"row.poolNoCandidateHint": "成员要么在限流冷却中、要么积分耗尽、要么凭据被拒、要么上游无响应。限流、积分耗尽与瞬时故障都会自动回池——按上游给出的恢复时间,没给时间就按 30 分钟兜底,不需要你操作;只有「凭据被拒」需要重新登录。",
|
|
@@ -15795,7 +15962,11 @@ ${u} ${p}-pool .sw input:checked+.sw-track::after{transform:translateX(16px)}
|
|
|
15795
15962
|
* load stays silent — a warning that fires when nothing is wrong stops being
|
|
15796
15963
|
* read.
|
|
15797
15964
|
*
|
|
15798
|
-
* Exported for the test
|
|
15965
|
+
* Exported for the test. Called from `rebindSlots` (once, before the inject
|
|
15966
|
+
* callback exists) and again from inside the inject callback (the only place
|
|
15967
|
+
* that can observe a DEFERRED refusal or a late-arriving `slotKind`). Two
|
|
15968
|
+
* callers, one state object: the later call always supersedes the earlier, and
|
|
15969
|
+
* the warning is deduplicated so one failure still produces one line.
|
|
15799
15970
|
*
|
|
15800
15971
|
* @param state - What the registration path recorded.
|
|
15801
15972
|
* @param target - Where to publish; defaults to the global object.
|
|
@@ -15834,6 +16005,19 @@ ${u} ${p}-pool .sw input:checked+.sw-track::after{transform:translateX(16px)}
|
|
|
15834
16005
|
rebinds: state.rebinds,
|
|
15835
16006
|
failure: state.failure,
|
|
15836
16007
|
claimed: state.dispose !== void 0,
|
|
16008
|
+
/**
|
|
16009
|
+
* Which shape the host's declaration allowed, and how many seats were
|
|
16010
|
+
* claimed for it.
|
|
16011
|
+
*
|
|
16012
|
+
* Without these two the picker has ONE symptom ("no badges") for two very
|
|
16013
|
+
* different situations: a `single` host where an equal-priority rival won
|
|
16014
|
+
* the cell, and a `keyed` host where a provider id was missed. `slotKind`
|
|
16015
|
+
* says which contract was in force; `seats` says what this plugin did with
|
|
16016
|
+
* it. `<provider count>` on a keyed host and `1` on a single host are the
|
|
16017
|
+
* only healthy pairs.
|
|
16018
|
+
*/
|
|
16019
|
+
slotKind: state.slotKind,
|
|
16020
|
+
seats: state.seats,
|
|
15837
16021
|
at: Date.now()
|
|
15838
16022
|
};
|
|
15839
16023
|
try {
|
|
@@ -15841,9 +16025,13 @@ ${u} ${p}-pool .sw input:checked+.sw-track::after{transform:translateX(16px)}
|
|
|
15841
16025
|
} catch {
|
|
15842
16026
|
return;
|
|
15843
16027
|
}
|
|
15844
|
-
if (state.failure !== void 0)
|
|
15845
|
-
|
|
15846
|
-
|
|
16028
|
+
if (state.failure !== void 0) {
|
|
16029
|
+
const warned = target;
|
|
16030
|
+
if (warned.__dshWorkBuddyModelLabelWarned__ !== state.failure) try {
|
|
16031
|
+
target.warn?.("[dsh-connect-workbuddy] the model-picker badges could not be registered: " + state.failure);
|
|
16032
|
+
warned.__dshWorkBuddyModelLabelWarned__ = state.failure;
|
|
16033
|
+
} catch {}
|
|
16034
|
+
}
|
|
15847
16035
|
return view;
|
|
15848
16036
|
}
|
|
15849
16037
|
function apply(ctx) {
|
|
@@ -16042,6 +16230,18 @@ ${u} ${p}-pool .sw input:checked+.sw-track::after{transform:translateX(16px)}
|
|
|
16042
16230
|
* ordering, the measured evidence, and the deliberate absence of any
|
|
16043
16231
|
* inter-plugin coordination (project invariant, `docs/DESIGN.md` §零).
|
|
16044
16232
|
*
|
|
16233
|
+
* HOW MANY SEATS, AND WHY THAT IS READ AT MOUNT. `single` holds one cell, so
|
|
16234
|
+
* exactly one registration is legal there. A `keyed` host gives each
|
|
16235
|
+
* `options.key` its own cell, and one cell per provider id is what this
|
|
16236
|
+
* plugin actually wants: it then draws its OWN rows and nothing else, qoder
|
|
16237
|
+
* and trae stop sharing a cell with it, and a provider with no contribution
|
|
16238
|
+
* falls through to the host's own fallback. Which of the two shapes is
|
|
16239
|
+
* legal is the HOST's declaration, not this plugin's choice, so the kind is
|
|
16240
|
+
* read from `ctx.slots.spec(...)` at mount and the seat list is derived from
|
|
16241
|
+
* it (`./model-label-seat.ts`). One build therefore serves both lines — and
|
|
16242
|
+
* a host that cannot be inspected gets the single seat, which is what every
|
|
16243
|
+
* released version of this plugin already does.
|
|
16244
|
+
*
|
|
16045
16245
|
* THE COST IS PAID ON ANOTHER PLUGIN'S ROWS, and it is worth stating where
|
|
16046
16246
|
* the registration happens: holding this cell means the host's own
|
|
16047
16247
|
* `dsh-client-ui-deepseek-model-label-1017` badge is NOT rendered on the
|
|
@@ -16049,7 +16249,9 @@ ${u} ${p}-pool .sw input:checked+.sw-track::after{transform:translateX(16px)}
|
|
|
16049
16249
|
* to fix by inspecting the slot ledger — it is the price of §零, recorded in
|
|
16050
16250
|
* `docs/DESIGN.md` and argued in the 5.8.2 CHANGELOG. Issue #138 is a user
|
|
16051
16251
|
* meeting that price for the first time; the disposition is to state it
|
|
16052
|
-
* plainly rather than to coordinate at runtime.
|
|
16252
|
+
* plainly rather than to coordinate at runtime. On a `keyed` host that price
|
|
16253
|
+
* is not paid at all: each provider keeps its own cell, so 1017's badge
|
|
16254
|
+
* returns to the DeepSeek rows without anyone negotiating.
|
|
16053
16255
|
*/
|
|
16054
16256
|
/**
|
|
16055
16257
|
* WHY THIS RECORDS AN OUTCOME, not just a disposer.
|
|
@@ -16074,19 +16276,48 @@ ${u} ${p}-pool .sw input:checked+.sw-track::after{transform:translateX(16px)}
|
|
|
16074
16276
|
const modelLabelVerdict = () => modelLabelVerdictOf(modelLabelState);
|
|
16075
16277
|
const registerModelLabel = () => {
|
|
16076
16278
|
modelLabelState.askedAt = Date.now();
|
|
16279
|
+
/**
|
|
16280
|
+
* The refusal path, shared by the eager and the deferred call.
|
|
16281
|
+
*
|
|
16282
|
+
* REPUBLISHES, and that is not cosmetic. `rebindSlots` publishes once, and
|
|
16283
|
+
* on the normal boot it publishes BEFORE this callback exists: `inject()`
|
|
16284
|
+
* defers the callback until `conversation.input.model` mounts, so the
|
|
16285
|
+
* published view is a snapshot of a registration that has not happened
|
|
16286
|
+
* yet. Without this line the failure lands in a state object that nothing
|
|
16287
|
+
* reads again, and `window.__dshWorkBuddyModelLabel__` keeps
|
|
16288
|
+
* `failure: undefined` with verdict `parent-not-mounted` — the exact
|
|
16289
|
+
* opposite of the truth, in the surface built to state it.
|
|
16290
|
+
*/
|
|
16291
|
+
const refuse = (error) => {
|
|
16292
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
16293
|
+
modelLabelState.failure = message;
|
|
16294
|
+
console.error("[dsh-connect-workbuddy] model label slot failed to register (host provider unaffected):", error);
|
|
16295
|
+
publishModelLabelState(modelLabelState);
|
|
16296
|
+
};
|
|
16077
16297
|
try {
|
|
16078
16298
|
return ctx.slots.inject("conversation.input.model.label", () => {
|
|
16079
16299
|
modelLabelState.injectRanAt = Date.now();
|
|
16080
|
-
|
|
16300
|
+
const kind = declaredSlotKind(ctx.slots, "conversation.input.model.label");
|
|
16301
|
+
const seats = modelLabelSeats({
|
|
16081
16302
|
name: "conversation.input.model.label",
|
|
16303
|
+
kind,
|
|
16304
|
+
providerIds: WORKBUDDY_PROVIDER_IDS,
|
|
16082
16305
|
priority: MODEL_LABEL_PRIORITY
|
|
16083
|
-
}
|
|
16306
|
+
});
|
|
16307
|
+
const registry = ctx.slots;
|
|
16308
|
+
try {
|
|
16309
|
+
const dispose = registerModelLabelSeats(seats, (seat) => registry.register(seat, WorkBuddyModelLabel));
|
|
16310
|
+
modelLabelState.slotKind = kind ?? "unknown";
|
|
16311
|
+
modelLabelState.seats = seats.length;
|
|
16312
|
+
publishModelLabelState(modelLabelState);
|
|
16313
|
+
return dispose;
|
|
16314
|
+
} catch (error) {
|
|
16315
|
+
refuse(error);
|
|
16316
|
+
return () => {};
|
|
16317
|
+
}
|
|
16084
16318
|
});
|
|
16085
16319
|
} catch (error) {
|
|
16086
|
-
|
|
16087
|
-
modelLabelState.failure = message;
|
|
16088
|
-
console.error("[dsh-connect-workbuddy] model label slot failed to register (host provider unaffected):", error);
|
|
16089
|
-
return;
|
|
16320
|
+
return refuse(error);
|
|
16090
16321
|
}
|
|
16091
16322
|
};
|
|
16092
16323
|
/**
|
|
@@ -10527,7 +10527,7 @@ function describeRosterSeenPayload(raw) {
|
|
|
10527
10527
|
//#endregion
|
|
10528
10528
|
//#region src/version.ts
|
|
10529
10529
|
/** The npm package version this build was produced from. */
|
|
10530
|
-
const WORKBUDDY_CONNECT_VERSION = "5.
|
|
10530
|
+
const WORKBUDDY_CONNECT_VERSION = "5.21.0";
|
|
10531
10531
|
//#endregion
|
|
10532
10532
|
//#region src/host-heartbeat.ts
|
|
10533
10533
|
/**
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $t as imageDefaultFor, A as withoutRouters, At as offRefused, B as defaultDesktopAuthPath, Bt as IMAGE_TAG_TEXT_TO_IMAGE, C as setDeviceMode, Ct as attachBusyLevels, D as applyContextBudgets, Dt as defaultOffModelIds, E as WorkBuddyCatalog, En as writeFileAtomic, Et as REFUSES_OFF_MODEL_IDS, F as WorkBuddyCredentialStore, Ft as WorkBuddyVideoError, G as parseWorkBuddyAuth, Gt as isBareBase64Image, H as isEncryptedCredentialError, Ht as WorkBuddyImageError, I as WorkBuddyEncryptedCredentialError, It as parseSupportedSecondsRange, J as workbuddyOwnAuthPath, Jt as sniffImageMime, K as preferredAccountName, Kt as parseImageDataUrl, L as authFileName, Lt as pickVideoModel, M as WORKBUDDY_AUTH_FILENAME, Mt as withEffectiveOff, N as WORKBUDDY_AUTH_FILE_ENV, Nt as VIDEO_TAG_IMAGE_TO_VIDEO, O as deriveCatalog, Ot as lastRefusalFor, Pt as VIDEO_TAG_TEXT_TO_VIDEO, Q as CREDENTIAL_REJECTED_CODE, Qt as NATIVE_MODALITY_BY_MODEL_ID, R as defaultDesktopAuthCandidates, Rt as resolveVideoParams, S as saveDeviceSdkSettings, Sn as workbuddyAppExecutableCandidates, St as rewriteSessionTitleModel, T as FALLBACK_WORKBUDDY_MODELS_GLOBAL, Tn as withFileLock, Tt as selectPromoBadge, U as isVaultAccountId, Ut as imageDataUrl, V as hasEncryptedCredentialFields, Vt as MAX_INPUT_IMAGE_BYTES, W as legacyWorkbuddyOwnAuthPath, Wt as imageMimeForPath, X as APP_VERSION, Xt as queueNoticeText, Yt as parseQueueAnswer, Z as CONTEXT_OVERFLOW_MARKER, Zt as pruneTempDir, _ as createDeviceProfileLookup, _n as isWorkbuddyBundle, _t as parseUpstreamModel, a as readHostHeartbeat, at as declaredTools, b as readDeviceSettings, bn as openEncryptedField, bt as regionOf, c as WORKBUDDY_CONNECT_VERSION, ct as isContextTooLongBody, dn as deriveAtRestKey, dt as isFirstMessageGateBody, en as nativeModalityOf, et as WORKBUDDY_FALLBACK_SYSTEM_PROMPT, fn as deriveAtRestKeyId, ft as knownRegionOf, g as createTuringSdk, gn as isEncryptedFieldWrapper, gt as parseReasoning, h as createDeviceSdkPort, ht as parseCreditMultiplier, i as processStartTimeMs, it as classifyUpstreamError, j as ENCRYPTED_CREDENTIAL_CODE, jt as recordRefusal, k as fallbackModelsFor, kt as offDefaultFor, l as createFileRosterSeenStore, ln as WORKBUDDY_APP_EXECUTABLE_ENV, lt as isConversationIdGateBody, m as piAiRuntimeInfo, mn as findWorkbuddyAppExecutable, mt as openingEvidenceOfBody, n as clearHostHeartbeat, nt as WorkBuddyUpstreamClient, o as workbuddyHostHeartbeatPath, on as isDeviceId, p as resolveCnGateway, pn as fetchAtRestKeyPayload, pt as modelIdOfBody, q as workbuddyAccountId, qt as pickMediaModel, r as isHeartbeatProcessAlive, rt as channelGateMemberOf, s as writeHostHeartbeat, st as forceNeutralHead, t as WORKBUDDY_HOST_HEARTBEAT_FILENAME, tt as WorkBuddyCredentialRejectedError, un as clearAtRestKeyCache, ut as isCredentialRejectedError, v as describeDerivedDevices, vn as macosBundleExecutable, vt as perturbChannelFingerprints, w as FALLBACK_WORKBUDDY_MODELS, wn as resolveDshHome, wt as promoBadgeTone, x as saveDeviceProfile, xn as readAtRestKey, xt as requestEvidenceOf, y as isDeviceMode, yn as macosNestedAppBundles, yt as prepareChatBody, z as defaultDesktopAuthDirs, zt as IMAGE_TAG_IMAGE_TO_IMAGE } from "./host-heartbeat-
|
|
1
|
+
import { $t as imageDefaultFor, A as withoutRouters, At as offRefused, B as defaultDesktopAuthPath, Bt as IMAGE_TAG_TEXT_TO_IMAGE, C as setDeviceMode, Ct as attachBusyLevels, D as applyContextBudgets, Dt as defaultOffModelIds, E as WorkBuddyCatalog, En as writeFileAtomic, Et as REFUSES_OFF_MODEL_IDS, F as WorkBuddyCredentialStore, Ft as WorkBuddyVideoError, G as parseWorkBuddyAuth, Gt as isBareBase64Image, H as isEncryptedCredentialError, Ht as WorkBuddyImageError, I as WorkBuddyEncryptedCredentialError, It as parseSupportedSecondsRange, J as workbuddyOwnAuthPath, Jt as sniffImageMime, K as preferredAccountName, Kt as parseImageDataUrl, L as authFileName, Lt as pickVideoModel, M as WORKBUDDY_AUTH_FILENAME, Mt as withEffectiveOff, N as WORKBUDDY_AUTH_FILE_ENV, Nt as VIDEO_TAG_IMAGE_TO_VIDEO, O as deriveCatalog, Ot as lastRefusalFor, Pt as VIDEO_TAG_TEXT_TO_VIDEO, Q as CREDENTIAL_REJECTED_CODE, Qt as NATIVE_MODALITY_BY_MODEL_ID, R as defaultDesktopAuthCandidates, Rt as resolveVideoParams, S as saveDeviceSdkSettings, Sn as workbuddyAppExecutableCandidates, St as rewriteSessionTitleModel, T as FALLBACK_WORKBUDDY_MODELS_GLOBAL, Tn as withFileLock, Tt as selectPromoBadge, U as isVaultAccountId, Ut as imageDataUrl, V as hasEncryptedCredentialFields, Vt as MAX_INPUT_IMAGE_BYTES, W as legacyWorkbuddyOwnAuthPath, Wt as imageMimeForPath, X as APP_VERSION, Xt as queueNoticeText, Yt as parseQueueAnswer, Z as CONTEXT_OVERFLOW_MARKER, Zt as pruneTempDir, _ as createDeviceProfileLookup, _n as isWorkbuddyBundle, _t as parseUpstreamModel, a as readHostHeartbeat, at as declaredTools, b as readDeviceSettings, bn as openEncryptedField, bt as regionOf, c as WORKBUDDY_CONNECT_VERSION, ct as isContextTooLongBody, dn as deriveAtRestKey, dt as isFirstMessageGateBody, en as nativeModalityOf, et as WORKBUDDY_FALLBACK_SYSTEM_PROMPT, fn as deriveAtRestKeyId, ft as knownRegionOf, g as createTuringSdk, gn as isEncryptedFieldWrapper, gt as parseReasoning, h as createDeviceSdkPort, ht as parseCreditMultiplier, i as processStartTimeMs, it as classifyUpstreamError, j as ENCRYPTED_CREDENTIAL_CODE, jt as recordRefusal, k as fallbackModelsFor, kt as offDefaultFor, l as createFileRosterSeenStore, ln as WORKBUDDY_APP_EXECUTABLE_ENV, lt as isConversationIdGateBody, m as piAiRuntimeInfo, mn as findWorkbuddyAppExecutable, mt as openingEvidenceOfBody, n as clearHostHeartbeat, nt as WorkBuddyUpstreamClient, o as workbuddyHostHeartbeatPath, on as isDeviceId, p as resolveCnGateway, pn as fetchAtRestKeyPayload, pt as modelIdOfBody, q as workbuddyAccountId, qt as pickMediaModel, r as isHeartbeatProcessAlive, rt as channelGateMemberOf, s as writeHostHeartbeat, st as forceNeutralHead, t as WORKBUDDY_HOST_HEARTBEAT_FILENAME, tt as WorkBuddyCredentialRejectedError, un as clearAtRestKeyCache, ut as isCredentialRejectedError, v as describeDerivedDevices, vn as macosBundleExecutable, vt as perturbChannelFingerprints, w as FALLBACK_WORKBUDDY_MODELS, wn as resolveDshHome, wt as promoBadgeTone, x as saveDeviceProfile, xn as readAtRestKey, xt as requestEvidenceOf, y as isDeviceMode, yn as macosNestedAppBundles, yt as prepareChatBody, z as defaultDesktopAuthDirs, zt as IMAGE_TAG_IMAGE_TO_IMAGE } from "./host-heartbeat-BLfxyXIA.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";
|
|
@@ -10640,7 +10640,26 @@ function parseTransferFile(text) {
|
|
|
10640
10640
|
const records = recordsOf(parsed);
|
|
10641
10641
|
if (records === void 0) throw new Error("transfer file must be a JSON array of account records; this file is " + describeShape(parsed) + ". Accepted wrappers: {\"accounts\": [...]}, {\"data\": [...]}, {\"records\": [...]}.");
|
|
10642
10642
|
for (const [index, item] of records.entries()) if (typeof item !== "object" || item === null || Array.isArray(item)) throw new Error("transfer file item " + (index + 1) + " is not an account object");
|
|
10643
|
-
return records;
|
|
10643
|
+
return records.map((item) => stripRedundantRaw(item));
|
|
10644
|
+
}
|
|
10645
|
+
/**
|
|
10646
|
+
* Drop `*_raw` snapshots the importer never reads, keeping `auth_raw`.
|
|
10647
|
+
*
|
|
10648
|
+
* `auth_raw` is exempt because it carries the billing `uin`, which is what makes
|
|
10649
|
+
* a re-imported account converge on the same vault id — dropping it would change
|
|
10650
|
+
* behaviour, not just size.
|
|
10651
|
+
*/
|
|
10652
|
+
function stripRedundantRaw(record) {
|
|
10653
|
+
let changed = false;
|
|
10654
|
+
const kept = {};
|
|
10655
|
+
for (const [key, value] of Object.entries(record)) {
|
|
10656
|
+
if (key !== "auth_raw" && key.endsWith("_raw")) {
|
|
10657
|
+
changed = true;
|
|
10658
|
+
continue;
|
|
10659
|
+
}
|
|
10660
|
+
kept[key] = value;
|
|
10661
|
+
}
|
|
10662
|
+
return changed ? kept : record;
|
|
10644
10663
|
}
|
|
10645
10664
|
/**
|
|
10646
10665
|
* The record array inside whatever the file's top level happens to be.
|
|
@@ -11394,29 +11413,77 @@ function jsonPrivate(res, status, body) {
|
|
|
11394
11413
|
});
|
|
11395
11414
|
res.end(payload);
|
|
11396
11415
|
}
|
|
11397
|
-
/** Request-body cap for the
|
|
11416
|
+
/** Request-body cap for the PROBE route: model ids only, never content. */
|
|
11398
11417
|
const PROBE_BODY_LIMIT = 65536;
|
|
11399
11418
|
/**
|
|
11400
|
-
*
|
|
11419
|
+
* Request-body cap for routes that carry a FILE the user chose.
|
|
11401
11420
|
*
|
|
11402
|
-
*
|
|
11403
|
-
*
|
|
11404
|
-
*
|
|
11421
|
+
* WHY THIS IS NOT `PROBE_BODY_LIMIT` (issue #229, second report). The transfer
|
|
11422
|
+
* route takes the whole text of an account-export file, and those are not small:
|
|
11423
|
+
* a single account from a sibling tool measured 108 KiB, because the file carries
|
|
11424
|
+
* two raw upstream snapshots (`quota_raw` + `usage_raw`, ~59 KiB together) that
|
|
11425
|
+
* this plugin never reads. One account already exceeded the probe's 64 KiB, so a
|
|
11426
|
+
* perfectly valid import failed — with the *worst possible* error message (the
|
|
11427
|
+
* socket was destroyed, so the browser reported `Failed to fetch`).
|
|
11428
|
+
*
|
|
11429
|
+
* The number matches the chat route's limit for the same reason: a cap exists to
|
|
11430
|
+
* stop unbounded buffering, not to express an opinion about how big a user's
|
|
11431
|
+
* export file is allowed to be.
|
|
11432
|
+
*/
|
|
11433
|
+
const TRANSFER_BODY_LIMIT = 67108864;
|
|
11434
|
+
/**
|
|
11435
|
+
* Raised when a request body exceeds its route's cap.
|
|
11436
|
+
*
|
|
11437
|
+
* A CLASS, not a message, so the caller can answer 413 instead of 500: the
|
|
11438
|
+
* protocol says the client sent too much, and a 500 would send the reader
|
|
11439
|
+
* looking for a server-side fault that does not exist. Same reasoning (and the
|
|
11440
|
+
* same shape) as `RequestBodyTooLargeError` in `shim.ts`.
|
|
11405
11441
|
*/
|
|
11406
|
-
|
|
11442
|
+
var JsonBodyTooLargeError = class extends Error {
|
|
11443
|
+
limitBytes;
|
|
11444
|
+
constructor(limitBytes) {
|
|
11445
|
+
super("request body too large (limit " + String(limitBytes) + " bytes)");
|
|
11446
|
+
this.limitBytes = limitBytes;
|
|
11447
|
+
this.name = "JsonBodyTooLargeError";
|
|
11448
|
+
}
|
|
11449
|
+
};
|
|
11450
|
+
/**
|
|
11451
|
+
* Read a JSON object request body, bounded.
|
|
11452
|
+
*
|
|
11453
|
+
* AN OVER-LIMIT BODY IS STOPPED, NOT DESTROYED (issue #229). This used to call
|
|
11454
|
+
* `req.destroy()`, which tears down the SOCKET — so the error response could
|
|
11455
|
+
* never reach the client, and the browser reported a bare `Failed to fetch`.
|
|
11456
|
+
* The user then had no way to learn that the file was merely too large. The
|
|
11457
|
+
* chat route fixed exactly this in #174 ("the 413 can never reach the client
|
|
11458
|
+
* ... it saw a reset connection instead of an answer"); this reader was left
|
|
11459
|
+
* behind, and because the transfer route is the one route that takes a FILE, it
|
|
11460
|
+
* is the place the flaw actually bit. So the stream is paused and its listeners
|
|
11461
|
+
* dropped, the response still goes out, and the caller answers 413.
|
|
11462
|
+
*
|
|
11463
|
+
* @param req - The request to read.
|
|
11464
|
+
* @param limitBytes - The route's cap; defaults to the probe's small limit.
|
|
11465
|
+
*/
|
|
11466
|
+
function readJsonBody(req, limitBytes = PROBE_BODY_LIMIT) {
|
|
11407
11467
|
return new Promise((resolve, reject) => {
|
|
11408
11468
|
const chunks = [];
|
|
11409
11469
|
let size = 0;
|
|
11470
|
+
let settled = false;
|
|
11410
11471
|
req.on("data", (chunk) => {
|
|
11472
|
+
if (settled) return;
|
|
11411
11473
|
size += chunk.length;
|
|
11412
|
-
if (size >
|
|
11413
|
-
|
|
11414
|
-
|
|
11474
|
+
if (size > limitBytes) {
|
|
11475
|
+
settled = true;
|
|
11476
|
+
chunks.length = 0;
|
|
11477
|
+
req.removeAllListeners("data");
|
|
11478
|
+
req.removeAllListeners("end");
|
|
11479
|
+
req.pause();
|
|
11480
|
+
reject(new JsonBodyTooLargeError(limitBytes));
|
|
11415
11481
|
return;
|
|
11416
11482
|
}
|
|
11417
11483
|
chunks.push(chunk);
|
|
11418
11484
|
});
|
|
11419
11485
|
req.on("end", () => {
|
|
11486
|
+
if (settled) return;
|
|
11420
11487
|
try {
|
|
11421
11488
|
const parsed = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
11422
11489
|
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
@@ -12411,13 +12478,14 @@ function registerWorkBuddyStatusRoute(ctx, deps) {
|
|
|
12411
12478
|
if (answer.accounts.length === 0) return json(res, 409, { error: "none of the named accounts was found in this region" });
|
|
12412
12479
|
return jsonPrivate(res, 200, answer);
|
|
12413
12480
|
}
|
|
12414
|
-
const body = await readJsonBody(req);
|
|
12481
|
+
const body = await readJsonBody(req, TRANSFER_BODY_LIMIT);
|
|
12415
12482
|
if (typeof body.text !== "string" || body.text.trim() === "") return json(res, 400, { error: "text must be the transfer file's JSON content" });
|
|
12416
12483
|
if (action === "preview") return json(res, 200, await transfer.previewImport(region, body.text));
|
|
12417
12484
|
const indexes = Array.isArray(body.indexes) ? body.indexes.filter((value) => typeof value === "number" && Number.isInteger(value) && value >= 0) : [];
|
|
12418
12485
|
if (indexes.length === 0) return json(res, 400, { error: "indexes must name at least one file entry to import" });
|
|
12419
12486
|
return json(res, 200, await transfer.importAccounts(region, body.text, indexes));
|
|
12420
12487
|
} catch (error) {
|
|
12488
|
+
if (error instanceof JsonBodyTooLargeError) return json(res, 413, { error: safeMessage(error) });
|
|
12421
12489
|
json(res, 500, { error: safeMessage(error) });
|
|
12422
12490
|
}
|
|
12423
12491
|
}
|
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.21.0",
|
|
6
6
|
"author": "dingminhua",
|
|
7
7
|
"copyright": "Copyright (c) 2026 LaoDing",
|
|
8
8
|
"license": "MIT",
|