dsh-connect-workbuddy 5.19.0 → 5.20.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 CHANGED
@@ -1,5 +1,145 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.20.0 (2026-11-06)
4
+
5
+ > **新增一项设置,默认行为一个字节都没变。** 没有破坏性变更;不填就跟以前完全一样。
6
+
7
+ ### 新增:CN 网关主机可配置(issue #220)
8
+
9
+ 企业网络按 **TLS ClientHello 的 SNI** 做黑名单时,CN 网关 `copilot.tencent.com` 会被即时 RST
10
+ (`ECONNRESET`,<100ms),而同一台机器上的 WorkBuddy 桌面客户端**正常**——因为客户端读自己
11
+ `failover.json` 的 `trustedOrigins`,里面还有 `wb.tencentbuddy.com`。插件原先把这个主机**写死**,
12
+ 于是在那种网络里完全不可用,且看起来像插件自己坏了。
13
+
14
+ 现在「能力」栏可以填一个 CN 网关主机;留空即内置。**chat、模型目录、busy 探测、生图/生视频、
15
+ 签到、积分、领取权益**全部跟着走——只修 chat 的半个修复比不修更糟:用户会以为换号成功,
16
+ 而签到和积分仍然打在被拦的主机上。
17
+
18
+ **实测(2026-11-06,本机)**:九条 CN 路由在 `wb.tencentbuddy.com` 与 `copilot.tencent.com`
19
+ 上**状态码逐条相同**;`/v3/config` 的 252 字节信封在四个 CN 主机上逐个相同。详见
20
+ [`docs/CN_GATEWAY_FALLBACK.md`](docs/CN_GATEWAY_FALLBACK.md)。
21
+
22
+ ### 安全:允许清单,而不是「任意 URL」
23
+
24
+ 这个 base 会被拼在每一条带 `Authorization: Bearer <token>` 的请求前面,也包括 refresh token 交换。
25
+ **一个自由的 base 就是一枚凭据外泄原语**:能改设置的人(同步的 profile、共享 dotfile、论坛抄来的
26
+ 「修复」)就能把活 token 重定向到自己的主机,而且请求照样成功、看不出坏了。
27
+
28
+ 所以值必须是 **https**,且主机属于四个 CN 品牌的可注册域之一:`copilot.tencent.com`、
29
+ `tencentbuddy.com`、`workbuddy.cn`、`codebuddy.cn`(按可注册域匹配,子域放行,
30
+ `tencentbuddy.com.evil.example` 这类近似域拒绝)。路径 / 查询 / 锚点 / userinfo 一律丢弃。
31
+
32
+ **不改的东西**:`Origin` / `Referer` 仍然自称 CN 网页端(它们回答的是「来自哪个网页应用」,
33
+ 与连到哪台主机无关);**国际版完全不受影响**——全球 token 按品牌绑定,没有「换一个同构主机」
34
+ 这回事,所以该控件在国际版 tab 上连渲染都不渲染。
35
+
36
+ ### 三处细节,都是「看起来能用、其实是错的」那类
37
+
38
+ - **每次请求现读,不是构造期采样。** `regions` 是 volatile 字段,保存后不重启插件;
39
+ 构造期采样会让「填了没反应」——而那是本设置唯一的用途。
40
+ - **非法值拒绝保存,并按具体规则说明**(不是完整 URL / 必须 https / 不是 CN 品牌)。
41
+ 三种规则需要三种不同修法,一句「无效」等于没说。
42
+ - **诊断栏报告解析后生效的值,不是保存的原文。** 保存了但校验失败的值仍然走内置网关,
43
+ 回显原文会告诉用户「已生效」,而每个请求都去了别处。
44
+
45
+ Host 侧对配置里的坏值**退回内置网关并 warn 一次**(同一个值只警告一次——这条路径在每次请求上,
46
+ 不能把一次误配置变成每个请求一条日志)。
47
+
48
+ ### 新增:`doctor` 也能看到覆盖(`WORKBUDDY_CN_BASE`)
49
+
50
+ `doctor` 跑在自己的进程里,**从不加载插件设置**——所以卡片上填的值它看不见。没有这条通道,
51
+ 用户修好网络后跑 `doctor`,拿到的报告是**对着他那张网络会重置的网关**测的:一个谎报
52
+ 「我探了哪台主机」的诊断工具比没有更糟。这与 `WORKBUDDY_DEVICE_TOKEN_FILE` 是同一个原因、
53
+ 同一个模式,且两者都走同一个 `resolveCnGateway`,校验规则不可能分叉。
54
+
55
+ ### Tests
56
+
57
+ `3169/3169`(3119 → 3169),`skip 2`。新增三个文件 / 一节:
58
+
59
+ - `tests/cn-gateway.spec.ts`(22 条):允许清单与三类拒绝理由。吃重的是**近似域**用例——
60
+ `tencentbuddy.com.evil.example` 必须被拒,而那正是手写 `endsWith` 会放过的形状。
61
+ - `tests/cn-gateway-routes.spec.ts`(12 条):覆盖真的到达**每一条**路由(积分 / 签到读 /
62
+ 签到写 / 目录 / busy)、**每次请求现读**、`Origin`/`Referer` 不变、**国际凭据绝不走 CN 覆盖**、
63
+ token 不在 URL 里、以及不填时与 #220 之前逐字节相同。
64
+ - `tests/cn-base-card.spec.tsx`(11 条):草稿不随输入写盘、非法值零写入、三种拒绝各自措辞、
65
+ 清空即回到内置、国际版 tab 上控件不存在、诊断栏报告**解析后**的值。
66
+ - `tests/region.spec.ts` +5:`cnBase` 与同槽的模型目录/池偏好互不干扰、空串是显式值不是删除、坏值读成空而不抛。
67
+
68
+ **变异验证**:把允许清单改成 `includes()`(2 条失败)、把卡片改成接受非法值(8 条失败)、
69
+ 把 `billingBase` 的区域判断挪到覆盖判断之后(1 条失败——这条变异正是为它写的,
70
+ 其余用例在它下面全绿)。
71
+
72
+
73
+ ## 5.19.1 (2026-11-06)
74
+
75
+ > 纯显示修复 + 一份新的测量工装,不改任何行为、设置字段与路由。**没有破坏性变更。**
76
+
77
+ ### 修复(账号池在设置面板窄列里的显示)
78
+
79
+ 三条都是**同一份内容第一次被放进 564px 的列**之后才显形的问题,做法照同族
80
+ `dsh-connect-trae` 4.9.0 的同一次迁移(它踩过完全一样的三颗坑,其中第一颗它自己
81
+ 先发了一半)。
82
+
83
+ **1. 账号格仍然竖排五行,把每行撑到 157px。** 5.19.0 已经加了 `@container (max-width:700px)`
84
+ 把外层 `.dsm-workbuddy-pool-row` 塌缩成堆叠卡片,但**真正竖排的是更里层**——
85
+ `.dsm-workbuddy-pool-account-name` 自己带 `flex-direction:column`(宽版下名字 / 名次+↑↓ /
86
+ 当前使用 / 测试于 各占一行,读成一张小卡)。
87
+
88
+ 窄列里这四行没有理由继续各占一行,它们本来就是一句话。实测(549px 列):
89
+ - 账号格 81px → **20px**(五行 → 一行)
90
+ - 单行高 157px → **96px**
91
+ - 账号池表格 420px → **287px**
92
+
93
+ 这是 trae 4.9.0 里标注为「最容易漏掉」的那一处,它第一版也只改了外层包装。
94
+ 同时给名字补 `min-width:0`:`<b>` 带 nowrap+ellipsis,但作为 flex 项默认 `min-width:auto`
95
+ (即内容宽度),省略号永远咬不住,长账号名会把整行顶宽。
96
+
97
+ **2. 「账号」表头浮在留白里,不指着它标注的那一列。** 账号格以勾选框开头,
98
+ 所以名字比单元格左边缘缩进。实测(1120px 页面):表头 x=65、名字 x=103,差 **38px**。
99
+ 表头贴单元格边缘时,「账号」两个字浮在 padding 里,指向什么也没有。
100
+ 新类 `.dsm-workbuddy-pool-col-account` 用 `padding-inline-start` 把这 38px 补上,
101
+ 窄版整行表头都隐藏,所以这个偏移不需要第二套值。
102
+
103
+ **3. 滚到账号池就看不见「账号 / 模型 / 能力 / 诊断 / SDK」分栏条。**
104
+ 账号池在折叠线以下,滚到那里时分栏条已经滚出视野,想切分栏只能把整页滚回顶部。
105
+ 改成 `position:sticky`(`top:-1px`,带不透明底色与 `z-index:2`)。
106
+
107
+ **仍然不接管滚动**:设置面板自己的列本来就负责滚动,这里既不写 `height:100%` 也不写
108
+ `overflow`——那会是第二根滚动条。分栏条画的底色走新变量 `--dsm-workbuddy-surface`,
109
+ 由三个面(卡片 / 整页 / 设置)各自在自己的 `.dsm-workbuddy-usage` 规则里声明,
110
+ 所以面板列换成 layer-3 时,条子跟着换,不会变成一条更亮的浮动带。
111
+ `top:-1px` 而不是 `0`:条子自己的 border-bottom 画在盒子外侧,写 0 会留一条 1px 缝。
112
+
113
+ **顺带删掉一条永远不会触发的规则。** `@media (max-width:760px)` 里给账号表重新分栏
114
+ (`1fr 1fr`)的那半条——它量的是视口,设置面板里视口 1400px 永远不成立;而且它的
115
+ 2×2 形态正是 5.19.0 记录的那个缺陷本身。窄形态只能由 `@container` 表达,
116
+ 留一条半对的媒体查询比删掉更糟。
117
+
118
+ ### 新增(测量工装)
119
+
120
+ **`pnpm section:shot`**(`tools/section-shot.tsx` + `vitest.card.config.ts`,照 trae 同款)。
121
+ 把 `settings.section` 页面按**真实外壳尺寸**(800px 面板 − 188px 导航 − 48px 内边距 =
122
+ 564px 内容列)渲染到 `/tmp/wb-section-preview.html`,并附一份 `<pre id="audit">` 几何数据:
123
+ 表格解析出的轨道、每个单元格的宽高、哪些元素的内容宽超过盒宽、首个可点控件距页面顶端的像素。
124
+ 同一份渲染还会写出 `/tmp/wb-wide-preview.html`,用来**证明窄版规则在宽版上不生效**。
125
+
126
+ 在这之前,本仓库所有断点都是靠读代码推断的——5.19.0 的三处缺陷全是这么漏掉的。
127
+ `tools/` 不在默认 `vitest include` 里,所以 `pnpm test` 不会把它收成一个永远 skip 的用例。
128
+
129
+ ### Tests
130
+
131
+ `3119/3119`(3116 → 3119),`skip 2`。`tests/pool-card-render.spec.tsx` +3:
132
+
133
+ - 账号格**内层**也要塌缩(不是只塌外层包装)、当前使用徽章的堆叠间距同时归零、
134
+ 名字保留 `min-width:0`;
135
+ - 「账号」表头必须缩进到名字处,不是贴在单元格边缘;
136
+ - 分栏条必须 sticky、不得引入第二个滚动容器、底色必须走 surface 变量,
137
+ 且**每个**声明了 `.dsm-workbuddy-usage` 的面都必须声明这个变量。
138
+
139
+ 四条规则**逐条变异验证**:把内层改回 `column`、把表头缩进改回 0、把 sticky 去掉、
140
+ 把条子底色写成固定 layer-1 —— 四次都各自让对应用例失败,恢复后全绿。
141
+
142
+
3
143
  ## 5.19.0 (2026-11-06)
4
144
 
5
145
  > **本版有破坏性变更(入口)**:配置界面从「插件市场详情页里的卡片」整体搬到
package/README.en.md CHANGED
@@ -93,6 +93,17 @@ Credentials are read (read-only) from the WorkBuddy desktop app's own auth file.
93
93
 
94
94
  **Encrypted credential fields**: newer desktop builds (Windows first) replace the auth file's `accessToken` / `refreshToken` strings with an AES-256-GCM envelope (`{"$wbEncrypted":1,"envelope":"…"}`), and the account's **display name (`nickname`) is encrypted the same way** — left unopened it degrades to a bare uin number. The envelope is sealed with a field key **compiled into the app itself**, not a user secret — so the plugin ships no key copy. When it meets an encrypted document it runs the installed app with `ELECTRON_RUN_AS_NODE` and calls that app's own native binding (`electron_browser_workbuddy_storage.loggerGet()`) to fetch the same payload and derive the key locally: it asks the very build that wrote the file. The key is cached in process memory only — never on disk, never in logs. Plain-string documents (macOS, older Windows builds) take the original path and never spawn a child process. `account.phoneNumber` is encrypted there too, and the plugin deliberately **neither reads nor displays it**. If the app lives somewhere unusual, point `WORKBUDDY_APP_EXECUTABLE` at its executable.
95
95
 
96
+ ## Every model times out on a corporate network?
97
+
98
+ If **every** model times out while the WorkBuddy desktop app works fine on the same machine, the likely cause is a gateway blocked by **TLS SNI**: `copilot.tencent.com` is reset before any HTTP is sent (fails in milliseconds), while the app itself also uses `wb.tencentbuddy.com`.
99
+
100
+ Open **Settings → WorkBuddy → Capabilities** and set **CN gateway host** to `https://wb.tencentbuddy.com`. Leave it empty for the built-in gateway. **Chat, the model catalog, check-in, credits and image generation all follow it** — a chat-only fix is worse than none.
101
+
102
+ Only **https** is accepted, on a subdomain of `copilot.tencent.com`, `tencentbuddy.com`, `workbuddy.cn` or `codebuddy.cn`. That is not pedantry: the value is prefixed onto every request carrying `Authorization: Bearer`, so accepting an arbitrary URL would mean accepting an arbitrary destination for your token. **The international region is unaffected** — its tokens are brand-bound, and a different host only ever 401s. Measurements and design notes: [`docs/CN_GATEWAY_FALLBACK.md`](docs/CN_GATEWAY_FALLBACK.md).
103
+
104
+ > `doctor` runs in its own process and cannot see plugin settings, so that path uses an environment variable: `WORKBUDDY_CN_BASE=https://wb.tencentbuddy.com dsh plugin --profile desktop exec dsh-connect-workbuddy doctor`
105
+
106
+
96
107
  ## Account pool
97
108
 
98
109
  <p align="center">
@@ -103,6 +114,8 @@ A machine usually carries more than one WorkBuddy sign-in. The **account pool**
103
114
 
104
115
  **Each region (domestic / international) has its own independent pool** — membership and target model never affect the other side, because the two sides' accounts belong to different upstream stacks.
105
116
 
117
+ > **In a narrow column this table becomes stacked cards.** The configuration page lives inside the Settings panel, whose content column is **564px** (800px panel minus a 188px nav rail) — five columns do not fit, so when the TABLE itself is narrower than 700px (a container query, not the viewport) each row turns into three lines: the account and its actions get a full line each, and the three facts between them share one. Measured in that column: **96px** per row (was 157px, with the account name clipped to "用户75"), and the name no longer truncates. The wide layout is unchanged.
118
+
106
119
  ### The two batch actions
107
120
 
108
121
  - **Check in selected** — signs in account by account. It **reads today's status first**, so an account that is already checked in is marked as such and receives **no write request at all** (idempotent — no duplicate claims); a single account failing marks only that row and **never aborts the batch**.
@@ -192,7 +205,7 @@ One class of state in the pool **does not go through a draft**: probe results, c
192
205
  >
193
206
  > ⚠️ **Do not treat the marketplace's "latest" as the schedule — it reads an index that lags.** The community marketplace serves a periodically built snapshot, collected per package: at the 2026-10-30 15:00 observation this plugin still listed only 5.13.1 while npm `latest` was already 5.14.1, and a desktop host separately flags any release under 24 hours old as "waiting". Trust `npm view dsh-connect-workbuddy version` and [Releases](https://github.com/dingminhua/dsh-connect-workbuddy/releases), and follow [Update](#update) below (pin the **exact version**); or hand [`docs/PINNED-UPGRADE-LAG.md`](docs/PINNED-UPGRADE-LAG.md) §3 to an AI and let it run.
194
207
  >
195
- > The other thing that stops people from upgrading: **pnpm's 24-hour release-age window** (`minimumReleaseAge`) **silently resolves a floating range back to the previous version**. When you need this fixed right now, pin the **exact version**: `dsh-connect-workbuddy@5.15.1`.
208
+ > The other thing that stops people from upgrading: **pnpm's 24-hour release-age window** (`minimumReleaseAge`) **silently resolves a floating range back to the previous version**. When you need this fixed right now, pin the **exact version**: `dsh-connect-workbuddy@5.19.1`.
196
209
 
197
210
  ### Supported host range
198
211
 
@@ -256,7 +269,7 @@ Once installed, the configuration lives in the **WorkBuddy page of the Settings
256
269
  > | exact `5.14.1` + `minimumReleaseAgeExclude: [dsh-connect-workbuddy]` in the profile's `pnpm-workspace.yaml` | **5.14.1** ✅ |
257
270
  > | setting absent (pnpm default) | floating `^5.13.1` → **5.14.1** ✅ |
258
271
  >
259
- > To pick up a new release right away, pin it: `dsh plugin --profile desktop add dsh-connect-workbuddy@5.15.1`; if the window refuses it, see [`docs/PINNED-UPGRADE-LAG.md`](docs/PINNED-UPGRADE-LAG.md) §2 for the two routes (wait out the window, or add that exclude line). A floating range catches up once the window elapses.
272
+ > To pick up a new release right away, pin it: `dsh plugin --profile desktop add dsh-connect-workbuddy@5.19.1`; if the window refuses it, see [`docs/PINNED-UPGRADE-LAG.md`](docs/PINNED-UPGRADE-LAG.md) §2 for the two routes (wait out the window, or add that exclude line). A floating range catches up once the window elapses.
260
273
 
261
274
  The plugin also runs under **Web** and **TUI**; pick the command matching your profile:
262
275
 
@@ -273,7 +286,7 @@ dsh plugin --profile dsh-tui add dsh-connect-workbuddy # TUI
273
286
  **Manual update (one command)**:
274
287
 
275
288
  ```sh
276
- dsh plugin --profile desktop add dsh-connect-workbuddy@5.15.1
289
+ dsh plugin --profile desktop add dsh-connect-workbuddy@5.19.1
277
290
  dsh plugin --profile desktop exec dsh-connect-workbuddy doctor # first line carries the version
278
291
  ```
279
292
 
package/README.md CHANGED
@@ -103,6 +103,24 @@ DSH PiAiAdapter(每个 provider 一套)
103
103
 
104
104
  **加密凭据字段**:新版桌面端(Windows 先行)把 auth 文件里的 `accessToken` / `refreshToken` 从纯字符串改为 `{"$wbEncrypted":1,"envelope":"…"}` 的 AES-256-GCM 信封,**账号昵称 `nickname` 同样被加密**(不解密就会退回成一串 uin 数字)。信封用的是 App **自身构建期内置**的字段密钥,并非用户密钥,因此插件不内置任何密钥副本,而是在需要时用 `ELECTRON_RUN_AS_NODE` 调用已安装 App 的原生绑定(`electron_browser_workbuddy_storage.loggerGet()`)取回同一份载荷并就地派生密钥——也就是「向写下这个文件的那个构建本身询问」。密钥只在本进程内存中缓存,不落盘、不进日志;纯字符串文件(macOS 与旧版 Windows)走原路径,一次子进程都不会启动。其中的 `account.phoneNumber` 虽同样加密,插件**不读取也不显示**。若 App 安装在非常规位置,用 `WORKBUDDY_APP_EXECUTABLE` 指定其可执行文件。
105
105
 
106
+ ## 公司网络连不上 CN 网关?
107
+
108
+ 如果插件在某个网络里**全部模型都超时**,而同一台机器上的 WorkBuddy 桌面客户端**正常**,那多半是网关按
109
+ **TLS SNI** 被拦了:`copilot.tencent.com` 会被即时重置(连接在毫秒级就失败),但客户端自己还有一条
110
+ 备选主机 `wb.tencentbuddy.com`。
111
+
112
+ 在**设置 → WorkBuddy → 能力**栏的「CN 网关主机」里填 `https://wb.tencentbuddy.com` 并保存即可,
113
+ 留空则回到内置网关。**chat、模型目录、签到、积分、生图都会跟着走**——只改 chat 的半个修复比不改更糟。
114
+
115
+ 这条设置只接受 **https**,且主机必须是 `copilot.tencent.com` / `tencentbuddy.com` / `workbuddy.cn` /
116
+ `codebuddy.cn` 之一下的子域。这不是为了刁难:这个值会被拼在每一条带 `Authorization: Bearer` 的请求前面,
117
+ 允许任意 URL 就等于允许把 token 转发到任意主机。**国际版不受影响**——全球 token 按品牌绑定,
118
+ 换主机只会 401。技术细节与实测数据见 [`docs/CN_GATEWAY_FALLBACK.md`](docs/CN_GATEWAY_FALLBACK.md)。
119
+
120
+ > `doctor` 跑在独立进程里、读不到插件设置,所以那条路上用环境变量:
121
+ > `WORKBUDDY_CN_BASE=https://wb.tencentbuddy.com dsh plugin --profile desktop exec dsh-connect-workbuddy doctor`
122
+
123
+
106
124
  ## 账号池
107
125
 
108
126
  <p align="center">
@@ -113,6 +131,8 @@ DSH PiAiAdapter(每个 provider 一套)
113
131
 
114
132
  **每个区域(国内版 / 国际版)各有独立的一池**:成员与目标模型互不影响——两边的账号本来就属于不同的上游栈。**签到只有国内版有**:海外区域不显示签到按钮,也没有那一列。
115
133
 
134
+ > **窄栏下这张表会变成堆叠卡片。** 配置页住在设置面板里,内容列只有 **564px**(800px 面板减去 188px 导航)——五列表格塞不进去,所以窗口宽度小于 700px(量的是**表格自己**的宽度,不是视口)时,每一行改成三行:账号与操作各占一行,中间三个事实共享一行。窄栏下实测单行 **96px**(此前 157px,账号名被压成「用户75」),账号名不再截断。宽栏形态一行未改。
135
+
116
136
  ### 自动换号(开启账号池即生效)
117
137
 
118
138
  - **谁来服务由排序决定**:开启账号池后,**每一次请求**都发给池子里排序最靠前的可用账号——所以「当前使用」显示的是排序的结果,不一定是你手动选的那个。排序规则见下一节。
@@ -203,7 +223,7 @@ DSH PiAiAdapter(每个 provider 一套)
203
223
  >
204
224
  > ⚠️ **别把插件市场里那个「最新」当日程表——它读的是一份会落后的索引。** 社区市场走定期构建的快照(按包各自收录),2026-10-30 15:00 那次观测里本插件还停在 5.13.1,而当时 npm `latest` 已是 5.14.1;桌面宿主另有「24 小时内发布的版本先标成「新版等待中」」这条规则。以 `npm view dsh-connect-workbuddy version` 与 [Releases](https://github.com/dingminhua/dsh-connect-workbuddy/releases) 为准,按下方[「更新」](#更新)一节做(写**精确版本号**),或者把 [`docs/PINNED-UPGRADE-LAG.md`](docs/PINNED-UPGRADE-LAG.md) §3 那段话丢给 AI 让它替你跑。
205
225
  >
206
- > 另一个会让人升级不到的原因:**pnpm 的 24 小时新版本等待期**(`minimumReleaseAge`)会把浮动范围**静默压回上一个版本**。需要立刻修复时请写**精确版本号**:`dsh plugin --profile desktop add dsh-connect-workbuddy@5.15.1`(原因见下方「刚发布的版本请写精确版本号」那条)。
226
+ > 另一个会让人升级不到的原因:**pnpm 的 24 小时新版本等待期**(`minimumReleaseAge`)会把浮动范围**静默压回上一个版本**。需要立刻修复时请写**精确版本号**:`dsh plugin --profile desktop add dsh-connect-workbuddy@5.19.1`(原因见下方「刚发布的版本请写精确版本号」那条)。
207
227
 
208
228
  ### 受支持的宿主范围
209
229
 
@@ -271,7 +291,7 @@ npm install dsh-connect-workbuddy
271
291
  > | 精确 `5.14.1` + profile `pnpm-workspace.yaml` 里 `minimumReleaseAgeExclude: [dsh-connect-workbuddy]` | **5.14.1** ✅ |
272
292
  > | 不设该项(pnpm 默认) | 浮动 `^5.13.1` → **5.14.1** ✅ |
273
293
  >
274
- > 想立刻用上新版,请写精确版本号:`dsh plugin --profile desktop add dsh-connect-workbuddy@5.15.1`;若被等待期拒绝,见 [`docs/PINNED-UPGRADE-LAG.md`](docs/PINNED-UPGRADE-LAG.md) §2 的两条路(等窗口过去,或加那行 exclude)。过了等待期之后,浮动范围会自然跟上。
294
+ > 想立刻用上新版,请写精确版本号:`dsh plugin --profile desktop add dsh-connect-workbuddy@5.19.1`;若被等待期拒绝,见 [`docs/PINNED-UPGRADE-LAG.md`](docs/PINNED-UPGRADE-LAG.md) §2 的两条路(等窗口过去,或加那行 exclude)。过了等待期之后,浮动范围会自然跟上。
275
295
 
276
296
  插件在 **Web**、**Desktop**、**TUI** 三种界面下均可运行,按你使用的 profile 选择对应命令:
277
297
 
@@ -356,7 +376,7 @@ dsh: plugin command failed; diagnostics: …/operation-xxxx/pnpm.log
356
376
  **手动更新(一条命令)**:
357
377
 
358
378
  ```sh
359
- dsh plugin --profile desktop add dsh-connect-workbuddy@5.15.1
379
+ dsh plugin --profile desktop add dsh-connect-workbuddy@5.19.1
360
380
  dsh plugin --profile desktop exec dsh-connect-workbuddy doctor # 第一行就是版本
361
381
  ```
362
382
 
package/lib/bin.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { $t as ensureDeviceSalt, C as FALLBACK_WORKBUDDY_MODELS_GLOBAL, H as legacyWorkbuddyOwnAuthPath, I as defaultDesktopAuthCandidates, J as APP_VERSION, K as workbuddyOwnAuthPath, L as defaultDesktopAuthDirs, M as WORKBUDDY_VAULT_DIRNAME, N as WorkBuddyCredentialStore, Qt as readDeviceTokenFile, S as FALLBACK_WORKBUDDY_MODELS, Z as DEFAULT_WIRE_PROFILE, Zt as WORKBUDDY_DEVICE_TOKEN_FILE_ENV, a as readHostHeartbeat, an as WORKBUDDY_APP_EXECUTABLE_ENV, bn as resolveDshHome, c as WORKBUDDY_CONNECT_VERSION, d as rosterSeenPath, dn as findWorkbuddyAppExecutableWithSource, en as readDeviceSalt, et as WorkBuddyUpstreamClient, f as piAiRuntimeInfo, in as protectCredentialDirectory, it as describeRequestHeaderNames, j as WORKBUDDY_AUTH_FILE_ENV, m as createTuringSdk, o as workbuddyHostHeartbeatPath, q as workbuddyVaultDir, r as isHeartbeatProcessAlive, rn as inspectCredentialDirectory, tn as deriveDeviceId, u as describeRosterSeenPayload, v as readDeviceSettings, yn as hostPeersInfo } from "./host-heartbeat-uMQXkyai.js";
2
+ import { $ as DEFAULT_WIRE_PROFILE, $t as WORKBUDDY_DEVICE_TOKEN_FILE_ENV, F as WorkBuddyCredentialStore, J as workbuddyOwnAuthPath, N as WORKBUDDY_AUTH_FILE_ENV, P as WORKBUDDY_VAULT_DIRNAME, R as defaultDesktopAuthCandidates, Sn as resolveDshHome, T as FALLBACK_WORKBUDDY_MODELS_GLOBAL, W as legacyWorkbuddyOwnAuthPath, X as APP_VERSION, Y as workbuddyVaultDir, a as readHostHeartbeat, an as inspectCredentialDirectory, b as readDeviceSettings, c as WORKBUDDY_CONNECT_VERSION, d as rosterSeenPath, en as readDeviceTokenFile, f as WORKBUDDY_CN_BASE_ENV, g as createTuringSdk, m as piAiRuntimeInfo, nn as readDeviceSalt, nt as WorkBuddyUpstreamClient, o as workbuddyHostHeartbeatPath, on as protectCredentialDirectory, ot as describeRequestHeaderNames, p as resolveCnGateway, pn as findWorkbuddyAppExecutableWithSource, r as isHeartbeatProcessAlive, rn as deriveDeviceId, sn as WORKBUDDY_APP_EXECUTABLE_ENV, tn as ensureDeviceSalt, u as describeRosterSeenPayload, w as FALLBACK_WORKBUDDY_MODELS, xn as hostPeersInfo, z as defaultDesktopAuthDirs } from "./host-heartbeat-BTTe5VDs.js";
3
3
  import { readFile } from "node:fs/promises";
4
4
  import { dirname, join } from "node:path";
5
5
  import { realpathSync } from "node:fs";
@@ -246,9 +246,31 @@ function printHelp() {
246
246
  function printJson(value) {
247
247
  process.stdout.write(`${JSON.stringify(value)}\n`);
248
248
  }
249
+ /**
250
+ * The CN gateway override as the CLI can see it (issue #220).
251
+ *
252
+ * `doctor` runs in its own process and never loads the plugin's settings, so the
253
+ * card's field is invisible here. Without this, a user who fixed their network
254
+ * would run `doctor` and get a report measured against the gateway their network
255
+ * resets — a diagnostics tool lying about which host it probed.
256
+ *
257
+ * An invalid value is REPORTED and then ignored rather than silently dropped:
258
+ * `doctor` is where a user goes to find out why nothing works, so "your
259
+ * override was rejected because X" is exactly the answer they need.
260
+ */
261
+ function cliCnBase() {
262
+ const raw = (process.env["WORKBUDDY_CN_BASE"] ?? "").trim();
263
+ if (raw === "") return "";
264
+ const resolved = resolveCnGateway(raw);
265
+ if (!resolved.ok) {
266
+ process.stderr.write(`warning: ignoring ${WORKBUDDY_CN_BASE_ENV}="${raw}" — ${resolved.reason === "malformed" ? "not an absolute URL" : resolved.reason === "insecure" ? "only https is accepted" : "host is not one of the CN brands"}\n`);
267
+ return "";
268
+ }
269
+ return resolved.overridden ? resolved.base : "";
270
+ }
249
271
  /** One region-scoped credential store (its own plugin-owned copy file). */
250
272
  function makeStore(region) {
251
- const client = new WorkBuddyUpstreamClient();
273
+ const client = new WorkBuddyUpstreamClient(void 0, {}, { cnBase: cliCnBase });
252
274
  return new WorkBuddyCredentialStore({
253
275
  region,
254
276
  refresh: (credential) => client.refreshToken(credential)
@@ -256,7 +278,7 @@ function makeStore(region) {
256
278
  }
257
279
  /** The region-unscoped store (reads every plugin-owned copy). */
258
280
  function makeAnyStore() {
259
- const client = new WorkBuddyUpstreamClient();
281
+ const client = new WorkBuddyUpstreamClient(void 0, {}, { cnBase: cliCnBase });
260
282
  return new WorkBuddyCredentialStore({ refresh: (credential) => client.refreshToken(credential) });
261
283
  }
262
284
  /**
@@ -575,7 +597,7 @@ async function doctor(jsonOutput) {
575
597
  /** One region's sign-in and credit summary. */
576
598
  async function regionStatus(region) {
577
599
  const store = makeStore(region);
578
- const client = new WorkBuddyUpstreamClient();
600
+ const client = new WorkBuddyUpstreamClient(void 0, {}, { cnBase: cliCnBase });
579
601
  const authStatus = await store.status();
580
602
  const accounts = await store.accounts();
581
603
  const selected = accounts.find((account) => account.selected);