dsh-connect-workbuddy 5.19.1 → 5.20.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 CHANGED
@@ -1,5 +1,175 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.20.2 (2026-11-06)
4
+
5
+ > **模型行的上下文档位改成一个下拉框。** 没有行为变化:能选的档位、默认值、
6
+ > 写入的值与之前完全一致。
7
+
8
+ ### 改了什么
9
+
10
+ 原来是三个单选按钮(200K / 500K / 原生窗口)横排。在设置面板 564px 的列里,模型行还要放下
11
+ 模型名、两个复选框和两个按钮,这三个按钮会折到第二行——而**折行的单选按钮读起来像三个独立开关**,
12
+ 实际却是同一个选择。现在是一个 `<select>`,不会折行,也只有一个控件。
13
+
14
+ ### 没变的部分(重要)
15
+
16
+ 档位的**计算规则一字未改**,仍是 `effectiveContextBudget()`——即后端推导窗口所用的同一个函数。
17
+ 所以这个控件不会声称一个 DSH 并未采用的上限(issue #215 的 bug 形态)。
18
+
19
+ - 可选档位仍按模型的**真实窗口**生成:192K 的模型只给一个选项,256K 给 200K + 原生,
20
+ 1M 给 200K / 500K / 原生。**永远不会给出超过真实窗口的档位。**
21
+ - 选「原生」仍然**清除**预算键,而不是存下窗口数值——存数值会停止跟随上游上调窗口,
22
+ 也会让「无上限」在设置文件里无法表示。
23
+
24
+ ### 对齐
25
+
26
+ 三个下拉框现在左边界严格对齐(690 / 690 / 690,宽度均 58px)。不加 `min-inline-size`
27
+ 时控件宽度随最宽选项变化,只提供 192K 的那行会窄 2px,三行的左边缘呈阶梯状——正是折行单选按钮
28
+ 那个毛病的小型翻版。
29
+
30
+ ### Tests
31
+
32
+ `3184/3184`(3181 → 3184),`skip 2`。
33
+
34
+ - `tests/issue215-context-budget-radio.spec.tsx` 12 条:读侧从 radio 改为 select,
35
+ 断言不变——**仍然拿控件与 `applyContextBudgets` 比对,而不是与硬编码标签比对**。
36
+ 另外把「不会同时点亮两个档位」换成「选中值必须出现在选项里,且所有档位都不超过真实窗口」——
37
+ 前者 `<select>` 已无法表达,后者仍会坏。
38
+ - `tests/context-tiers.spec.tsx` 13 条(+3):新增「只渲染一个 select、零个 radio、零个 fieldset」
39
+ (防半吊子迁移)、档位升序、以及**选中值真的进入保存请求**(写侧,之前只测了读侧)。
40
+ 两条 #198 时代的折行 CSS 断言被替换:它们守的失败模式随控件形态消失了。
41
+ - `tools/capabilities-shot.tsx` 现在可用 `WB_SHOT_PANEL=models` 渲染模型页,
42
+ 并修掉了静态 `innerHTML` 丢 `<select>` 选中值的问题(1M 的模型在预览里看起来选了 200K,
43
+ 纯粹是转储假象)。
44
+
45
+ **变异验证**:把选中值改回 `?? 200_000`(5 条失败)、把「原生」改成存数值(1 条失败)、
46
+ 把 radio 与 select 一起渲染(1 条失败)。
47
+
48
+
49
+ ## 5.20.1 (2026-11-06) — 未发布到 npm
50
+
51
+ > **修复 5.20.0 引入的回归:诊断页与 SDK 页打不开。** 没有其他改动;5.20.0 的功能与默认行为不变。
52
+ >
53
+ > **这一版没有发布到 npm**:代码在 git 里(tag `v5.20.1`),修复随 5.20.2 一并发布。
54
+ > 所以在 npm 上 5.20.0 之后直接是 5.20.2,中间没有 5.20.1。
55
+
56
+ ### 症状
57
+
58
+ 点「诊断」或「SDK」分栏,内容不出现——实际上是被**能力页压在下面**。能力页本身看起来正常,
59
+ 所以从界面上看像是「这两个页面坏了」,而不是「有一个页面没被隐藏」。
60
+
61
+ ### 原因
62
+
63
+ 5.20.0 给能力页加了 `#dsm-workbuddy-panel-capabilities{display:flex;gap:18px}`,用来修组间距。
64
+ 但**ID 选择器的优先级是 (1,0,0),高于浏览器默认样式表里 `[hidden]{display:none}` 的 (0,1,0)**,
65
+ 于是这个面板开始无视自己的 `hidden` 属性,永远渲染。
66
+
67
+ 三个面板都在 DOM 里,靠 `hidden` 切换;能力页在诊断页与 SDK 页**之前**,所以一永久显示,
68
+ 后两者就被盖住了。
69
+
70
+ 浏览器里 6 行即可复现,且这是判断它到底修没修的唯一可靠办法:
71
+
72
+ ```html
73
+ <style>#p{display:flex} #p[hidden]{display:none!important}</style>
74
+ <div id="p">…</div>
75
+ <script>p.setAttribute('hidden','')</script>
76
+ ```
77
+
78
+ 不带第二条规则时 `getComputedStyle(p).display` 是 `flex`,带上是 `none`。
79
+
80
+ ### 修法
81
+
82
+ ```css
83
+ #dsm-workbuddy-panel-capabilities[hidden]{display:none!important}
84
+ ```
85
+
86
+ `!important` 不是装饰:没有它,下一次给这个面板加任何 display 规则,同一个 bug 就会回来。
87
+
88
+ ### 为什么工装没抓到
89
+
90
+ `tools/capabilities-shot.tsx` 为了在一屏里量出这一节,用 `display:none!important` 把其他面板藏了。
91
+ **那个覆盖恰好把本 bug 遮住了——工装在修它本该观察的东西。** 该工具现在已经不强制面板 display,
92
+ 并且新增测试断言工装不得再这么做。
93
+
94
+ ### Tests
95
+
96
+ `3182/3182`(3179 → 3182),`skip 2`。`tests/capabilities-layout.spec.tsx` +3:
97
+
98
+ - `[hidden]` 守卫存在且带 `!important`(去掉它即失败);
99
+ - **点五个分栏,每次只开一个面板**——用户可见的契约,直接把这次的症状钉住;
100
+ - 工装不得再用 `display:block!important` 强制面板可见。
101
+
102
+
103
+ ## 5.20.0 (2026-11-06)
104
+
105
+ > **新增一项设置,默认行为一个字节都没变。** 没有破坏性变更;不填就跟以前完全一样。
106
+
107
+ ### 新增:CN 网关主机可配置(issue #220)
108
+
109
+ 企业网络按 **TLS ClientHello 的 SNI** 做黑名单时,CN 网关 `copilot.tencent.com` 会被即时 RST
110
+ (`ECONNRESET`,<100ms),而同一台机器上的 WorkBuddy 桌面客户端**正常**——因为客户端读自己
111
+ `failover.json` 的 `trustedOrigins`,里面还有 `wb.tencentbuddy.com`。插件原先把这个主机**写死**,
112
+ 于是在那种网络里完全不可用,且看起来像插件自己坏了。
113
+
114
+ 现在「能力」栏可以填一个 CN 网关主机;留空即内置。**chat、模型目录、busy 探测、生图/生视频、
115
+ 签到、积分、领取权益**全部跟着走——只修 chat 的半个修复比不修更糟:用户会以为换号成功,
116
+ 而签到和积分仍然打在被拦的主机上。
117
+
118
+ **实测(2026-11-06,本机)**:九条 CN 路由在 `wb.tencentbuddy.com` 与 `copilot.tencent.com`
119
+ 上**状态码逐条相同**;`/v3/config` 的 252 字节信封在四个 CN 主机上逐个相同。详见
120
+ [`docs/CN_GATEWAY_FALLBACK.md`](docs/CN_GATEWAY_FALLBACK.md)。
121
+
122
+ ### 安全:允许清单,而不是「任意 URL」
123
+
124
+ 这个 base 会被拼在每一条带 `Authorization: Bearer <token>` 的请求前面,也包括 refresh token 交换。
125
+ **一个自由的 base 就是一枚凭据外泄原语**:能改设置的人(同步的 profile、共享 dotfile、论坛抄来的
126
+ 「修复」)就能把活 token 重定向到自己的主机,而且请求照样成功、看不出坏了。
127
+
128
+ 所以值必须是 **https**,且主机属于四个 CN 品牌的可注册域之一:`copilot.tencent.com`、
129
+ `tencentbuddy.com`、`workbuddy.cn`、`codebuddy.cn`(按可注册域匹配,子域放行,
130
+ `tencentbuddy.com.evil.example` 这类近似域拒绝)。路径 / 查询 / 锚点 / userinfo 一律丢弃。
131
+
132
+ **不改的东西**:`Origin` / `Referer` 仍然自称 CN 网页端(它们回答的是「来自哪个网页应用」,
133
+ 与连到哪台主机无关);**国际版完全不受影响**——全球 token 按品牌绑定,没有「换一个同构主机」
134
+ 这回事,所以该控件在国际版 tab 上连渲染都不渲染。
135
+
136
+ ### 三处细节,都是「看起来能用、其实是错的」那类
137
+
138
+ - **每次请求现读,不是构造期采样。** `regions` 是 volatile 字段,保存后不重启插件;
139
+ 构造期采样会让「填了没反应」——而那是本设置唯一的用途。
140
+ - **非法值拒绝保存,并按具体规则说明**(不是完整 URL / 必须 https / 不是 CN 品牌)。
141
+ 三种规则需要三种不同修法,一句「无效」等于没说。
142
+ - **诊断栏报告解析后生效的值,不是保存的原文。** 保存了但校验失败的值仍然走内置网关,
143
+ 回显原文会告诉用户「已生效」,而每个请求都去了别处。
144
+
145
+ Host 侧对配置里的坏值**退回内置网关并 warn 一次**(同一个值只警告一次——这条路径在每次请求上,
146
+ 不能把一次误配置变成每个请求一条日志)。
147
+
148
+ ### 新增:`doctor` 也能看到覆盖(`WORKBUDDY_CN_BASE`)
149
+
150
+ `doctor` 跑在自己的进程里,**从不加载插件设置**——所以卡片上填的值它看不见。没有这条通道,
151
+ 用户修好网络后跑 `doctor`,拿到的报告是**对着他那张网络会重置的网关**测的:一个谎报
152
+ 「我探了哪台主机」的诊断工具比没有更糟。这与 `WORKBUDDY_DEVICE_TOKEN_FILE` 是同一个原因、
153
+ 同一个模式,且两者都走同一个 `resolveCnGateway`,校验规则不可能分叉。
154
+
155
+ ### Tests
156
+
157
+ `3169/3169`(3119 → 3169),`skip 2`。新增三个文件 / 一节:
158
+
159
+ - `tests/cn-gateway.spec.ts`(22 条):允许清单与三类拒绝理由。吃重的是**近似域**用例——
160
+ `tencentbuddy.com.evil.example` 必须被拒,而那正是手写 `endsWith` 会放过的形状。
161
+ - `tests/cn-gateway-routes.spec.ts`(12 条):覆盖真的到达**每一条**路由(积分 / 签到读 /
162
+ 签到写 / 目录 / busy)、**每次请求现读**、`Origin`/`Referer` 不变、**国际凭据绝不走 CN 覆盖**、
163
+ token 不在 URL 里、以及不填时与 #220 之前逐字节相同。
164
+ - `tests/cn-base-card.spec.tsx`(11 条):草稿不随输入写盘、非法值零写入、三种拒绝各自措辞、
165
+ 清空即回到内置、国际版 tab 上控件不存在、诊断栏报告**解析后**的值。
166
+ - `tests/region.spec.ts` +5:`cnBase` 与同槽的模型目录/池偏好互不干扰、空串是显式值不是删除、坏值读成空而不抛。
167
+
168
+ **变异验证**:把允许清单改成 `includes()`(2 条失败)、把卡片改成接受非法值(8 条失败)、
169
+ 把 `billingBase` 的区域判断挪到覆盖判断之后(1 条失败——这条变异正是为它写的,
170
+ 其余用例在它下面全绿)。
171
+
172
+
3
173
  ## 5.19.1 (2026-11-06)
4
174
 
5
175
  > 纯显示修复 + 一份新的测量工装,不改任何行为、设置字段与路由。**没有破坏性变更。**
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">
@@ -194,7 +205,7 @@ One class of state in the pool **does not go through a draft**: probe results, c
194
205
  >
195
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.
196
207
  >
197
- > 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.0`.
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.20.2`.
198
209
 
199
210
  ### Supported host range
200
211
 
@@ -258,7 +269,7 @@ Once installed, the configuration lives in the **WorkBuddy page of the Settings
258
269
  > | exact `5.14.1` + `minimumReleaseAgeExclude: [dsh-connect-workbuddy]` in the profile's `pnpm-workspace.yaml` | **5.14.1** ✅ |
259
270
  > | setting absent (pnpm default) | floating `^5.13.1` → **5.14.1** ✅ |
260
271
  >
261
- > To pick up a new release right away, pin it: `dsh plugin --profile desktop add dsh-connect-workbuddy@5.19.0`; 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.20.2`; 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.
262
273
 
263
274
  The plugin also runs under **Web** and **TUI**; pick the command matching your profile:
264
275
 
@@ -275,7 +286,7 @@ dsh plugin --profile dsh-tui add dsh-connect-workbuddy # TUI
275
286
  **Manual update (one command)**:
276
287
 
277
288
  ```sh
278
- dsh plugin --profile desktop add dsh-connect-workbuddy@5.19.0
289
+ dsh plugin --profile desktop add dsh-connect-workbuddy@5.20.2
279
290
  dsh plugin --profile desktop exec dsh-connect-workbuddy doctor # first line carries the version
280
291
  ```
281
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">
@@ -205,7 +223,7 @@ DSH PiAiAdapter(每个 provider 一套)
205
223
  >
206
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 让它替你跑。
207
225
  >
208
- > 另一个会让人升级不到的原因:**pnpm 的 24 小时新版本等待期**(`minimumReleaseAge`)会把浮动范围**静默压回上一个版本**。需要立刻修复时请写**精确版本号**:`dsh plugin --profile desktop add dsh-connect-workbuddy@5.19.0`(原因见下方「刚发布的版本请写精确版本号」那条)。
226
+ > 另一个会让人升级不到的原因:**pnpm 的 24 小时新版本等待期**(`minimumReleaseAge`)会把浮动范围**静默压回上一个版本**。需要立刻修复时请写**精确版本号**:`dsh plugin --profile desktop add dsh-connect-workbuddy@5.20.2`(原因见下方「刚发布的版本请写精确版本号」那条)。
209
227
 
210
228
  ### 受支持的宿主范围
211
229
 
@@ -273,7 +291,7 @@ npm install dsh-connect-workbuddy
273
291
  > | 精确 `5.14.1` + profile `pnpm-workspace.yaml` 里 `minimumReleaseAgeExclude: [dsh-connect-workbuddy]` | **5.14.1** ✅ |
274
292
  > | 不设该项(pnpm 默认) | 浮动 `^5.13.1` → **5.14.1** ✅ |
275
293
  >
276
- > 想立刻用上新版,请写精确版本号:`dsh plugin --profile desktop add dsh-connect-workbuddy@5.19.0`;若被等待期拒绝,见 [`docs/PINNED-UPGRADE-LAG.md`](docs/PINNED-UPGRADE-LAG.md) §2 的两条路(等窗口过去,或加那行 exclude)。过了等待期之后,浮动范围会自然跟上。
294
+ > 想立刻用上新版,请写精确版本号:`dsh plugin --profile desktop add dsh-connect-workbuddy@5.20.2`;若被等待期拒绝,见 [`docs/PINNED-UPGRADE-LAG.md`](docs/PINNED-UPGRADE-LAG.md) §2 的两条路(等窗口过去,或加那行 exclude)。过了等待期之后,浮动范围会自然跟上。
277
295
 
278
296
  插件在 **Web**、**Desktop**、**TUI** 三种界面下均可运行,按你使用的 profile 选择对应命令:
279
297
 
@@ -358,7 +376,7 @@ dsh: plugin command failed; diagnostics: …/operation-xxxx/pnpm.log
358
376
  **手动更新(一条命令)**:
359
377
 
360
378
  ```sh
361
- dsh plugin --profile desktop add dsh-connect-workbuddy@5.19.0
379
+ dsh plugin --profile desktop add dsh-connect-workbuddy@5.20.2
362
380
  dsh plugin --profile desktop exec dsh-connect-workbuddy doctor # 第一行就是版本
363
381
  ```
364
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-hEksLFOK.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-CQ3ot5-F.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);