dsh-connect-workbuddy 5.16.0 → 5.17.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,181 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.17.0 (2026-11-01)
4
+
5
+ ### 修复
6
+
7
+ - **暗色主题下「虚拟值 / 真实值」的选中项是一格空白**:选中态原来用
8
+ `background: 品牌色 + color: #fff`,而暗色主题里 `--dsw-alias-brand-primary` 本身就是浅色,
9
+ 白字落上去等于同色叠同色。现在改成「前景色做底、底色做字」这一对(`label-primary` /
10
+ `bg-base`),亮色是深底浅字、暗色是浅底深字,按定义互为反色,不再依赖某个具体色值。
11
+ 悬停样式同时排除选中项——它的选择器权重更高,不排除会把选中态冲掉。
12
+ - **弹窗里「真实设备 Token」几乎看不见**:标题从 `label-dimmed` 改为 `label-primary` + 600,
13
+ 说明文字从 tertiary 提到 secondary。虚线边框已经表达了"占位",不需要再靠文字颜色降级。
14
+ - **留空时的派生值现在显示出来**:设备参数弹窗在两个空输入框下面各自列出**真正会发出去的**
15
+ `X-Machine-ID` / `X-Session-ID`(等宽、可整段选中)。派生输入是 uid(与构头同一份),
16
+ 因此同一台机器上不同账号必然不同、同一账号跨重启必然相同。算不出来时分开两种原因:
17
+ 本机没有设备盐、与这个账号没有 uid——用户能做的事不一样。
18
+ - **`lib/` 不再可能"声明了但不存在"**:`pnpm install` 现在通过 `prepare` 构建一次;`build`
19
+ 结束时会核对 `main` / `types` / `bin` / `exports` / `dsh.bundle.patch` 声明的每个文件是否
20
+ 真的生成,并新增 `pnpm run verify:entries`(可对任意已安装目录运行)。
21
+ - 触发这次修复的现象:从源码检出 `link:` 安装后,DSH 报「声明的入口产物缺失(源码检出或
22
+ 构建被拦),下次启动会失败」。`lib/` 是 gitignore 的构建产物,而 `link:` 安装**不执行**
23
+ 包的 `prepare`,此前仓库里也只有 `prepack`(只在打包时跑),所以 `pnpm install` 之后
24
+ 源码目录里依然没有入口文件。DSH 的判定本身是对的,缺的是构建这一步。
25
+
26
+ ### 变更
27
+
28
+ - **SDK token 改为后台自动获取**:插件启动即取一次,此后在 10 分钟 TTL 到期前 15 秒
29
+ 自动换新;取数失败 60 秒后重试,本机没有 SDK 则 5 分钟复查一次。此前只有请求路径
30
+ 会取 token,于是一个空闲进程的「SDK」分区永远停在"已加载、没取过"——那与"SDK 坏了"
31
+ 在界面上长得一模一样,也是重启后看不到 token 的原因。
32
+ - 预热是单链定时器(间隔按当时的时间重算,不是固定 `setInterval`),插件卸载时
33
+ `stopAutoRefresh()` 清掉,不会留下一个永远关不掉的子进程工厂。
34
+ - 失败仍走请求路径的 30 秒退避:一轮对话十几条并发请求不会变成十几个子进程。
35
+ - **「SDK」分区可以直接填 SDK 目录**(评审意见 #1,@susulqx)。
36
+ - 之前只有环境变量 `WORKBUDDY_TURING_SDK_DIR` 一条旁路:自动发现链不命中时
37
+ (装在非默认盘、或另一份副本),用户能做的只有改环境变量再重启。
38
+ - 现在卡片 `GET`/`POST /device-profiles`(`kind: 'sdk'`)保存
39
+ `sdkDir` 与 `sdkFallbackToVirtual`,落在
40
+ `$DSH_HOME/.workbuddy-device-profiles.json`。**留空 = 回到自动发现**,不是
41
+ "路径为空";填错时状态行会答 `missing`/`error` 并带上那个路径,而不是静默
42
+ 回退成自动发现的结果(后者会让人以为保存失败,然后反复保存)。
43
+ - **保存后立刻生效,不用重启**:`createTuringSdk` 的目录从构造期常量改成
44
+ 每次 `probe` 现问一次(`dirSource`),probe 缓存也按**解析结果**判有效——
45
+ 否则填了新目录要等 10 秒的缓存过期,而那 10 秒里用户看到的还是旧目录。
46
+ - 优先级:显式 `dir`(测试)→ `WORKBUDDY_TURING_SDK_DIR` → 卡片手填 →
47
+ 自动发现。环境变量压过卡片,因为它是排障旁路(`doctor` 只能读环境变量),
48
+ 反过来会让一个排障时设的变量在下一次点保存后静默失效。
49
+ - 路径只去首尾空白,**不**规范化分隔符与大小写:那是用户从资源管理器复制来的
50
+ 路径,改了之后"我填的和看到的不一样"会让人怀疑没存上。
51
+
52
+ - **取不到真实设备时退回虚拟值,默认开**(评审意见 #2,@susulqx)。
53
+ - 之前「真实值」档在 SDK 不可用时**一个设备头都不发**(P3 的取舍:静默退回会
54
+ 让界面写着"真实值"、线上跑着虚拟值)。这个取舍有道理,但风控严的时候
55
+ "有总比没有好"也是合理的诉求,所以改成**用户可选,默认开**。
56
+ - 退回时档位**降成 `virtual`**,不是保留 `real` 再补一对派生 id:`deviceTier`
57
+ 既决定发哪些头,也决定界面与 `doctor` 怎么称呼"现在发的是什么"。保留 `real`
58
+ 会让报告与出站字节相反,而报告正是用户判断"到底退没退"的唯一依据。
59
+ - 退回**不读**逐账号覆盖值:这一跳是"真实值档塌回虚拟值",不是"用户切到了虚拟
60
+ 值档"。把齿轮里那对覆盖值混进来,等于让一次降级顺手改变这台机器对外声称的
61
+ 身份,而用户并没有要求这件事。
62
+ - `doctor` 的 `--json` 因此增 `deviceIdentity.tierSent` 与
63
+ `deviceIdentity.fallbackToVirtual`(schemaVersion 9 → 10),**只在分岔时
64
+ 出现**——`tierSent === tier` 是常态,多一个恒等字段只会让人以为两者永远可能
65
+ 不同。人类可读那一行读作
66
+ `real requested, virtual values (fell back: no real device token)`,并照常印出
67
+ 派生设备与文件源那一行(退回时它们真的被用上了)。
68
+
69
+ ### 测试
70
+
71
+ - 新增 **17** 例(2879 总例,较本套改动前净增 17):
72
+ - `tests/device-profile.spec.ts` +9:留空 = 自动发现、`undefined` 不动这一项、
73
+ 两个控件互不覆盖、坏路径保留不静默回退、缺字段 = 回退开(5.16.0 的文件升级
74
+ 即生效)、只有显式 `false` 才关、保存目录不动档位与覆盖值、lookup 暴露两项。
75
+ - `tests/turing-sdk.spec.ts` +4:新填的目录**下一次 `info()` 就命中**、probe
76
+ 缓存不跨目录复用、`WORKBUDDY_TURING_SDK_DIR` 压过卡片、显式 `dir` 压过两者。
77
+ - `tests/wire-profile.spec.ts` +3:开关开时发派生对、**不复用**逐账号覆盖值、
78
+ 有真 token 时照旧发真 token(开关无关)。
79
+ - `tests/device-state.spec.ts` +4:退回时 `tier` 保留 `real` 而 `tierSent` 是
80
+ `virtual` 且 `onWire` 是派生对、开关关时零设备头、有 token 时退回不发生、
81
+ 虚拟值档里这条分支不可达。
82
+ - **Windows 11 真机端到端**:把 `mode: real` + 一个不存在的 `sdkDir` 写进设置文件,
83
+ `doctor` 输出 `Device SDK: missing (... — Z:\nope\turing-sdk)` 且首行为
84
+ `real requested, virtual values (fell back: no real device token)`;把
85
+ `sdkFallbackToVirtual` 改回 `false`,首行变回 `real values: X-Device-Token`
86
+ (P3 原行为)。两条都在真机上跑过,不是纸面推演。
87
+ - **全仓** 2879 例中 2878 通过(171 文件),类型检查通过,build 通过。
88
+ `tests/issue12-region-hiding.spec.ts` 那条轮询 flake 依旧失败——已在未修改的
89
+ `d5183b2` 上同样复现,与本套改动无关(详见 5.16.0 那一条记录)。
90
+
91
+ - **设备身份取证面(P0)**:新增 `src/device-id.ts`(36 位十六进制 id,
92
+ `sha256(namespace + salt + purpose + uid)`,命名空间与用途进哈希、不进线上)、
93
+ `src/device-salt.ts`(本机盐,`$DSH_HOME/.workbuddy-device.json`,首建后只读——
94
+ 文件缺失与不可读分开处理,**不可读永不重键**:重键等于给同一台机器换身份)、
95
+ `src/device-state.ts`(`onWire` 为算出的实际发出头)。`doctor` 增 `deviceIdentity`
96
+ 块(schemaVersion 6 → 7)。
97
+ - **出站身份统一到 `WorkBuddy`(P1)**:chat 的 `X-Product: SaaS`、`X-IDE-Type: CLI`
98
+ 与 billing 的裸 HTTP 形态统一为 `X-Product` / `X-IDE-Type` / `X-Agent-Purpose:
99
+ conversation` + billing 补齐 `User-Agent: WorkBuddy/<ver>` / `Origin` / `Referer` /
100
+ `X-Requested-With` / `X-CodeBuddy-Request`,`Accept-Language` 按区 `zh-CN` /
101
+ `en-US`,并加 `X-Root-Request-ID`(与 `X-Conversation-Request-ID` 同值)。
102
+ 元数据读(`/v3/config`、`/v2/chat/busy`)与 refresh 一跳**字节不动**。
103
+ 配置项 `wireProfile: conservative` 逐字节还原 5.16.0(含 `X-Product: SaaS`),
104
+ 默认 `balanced`(schemaVersion 7,字段级见 `doctor`)。
105
+ - **外部 deviceToken 文件源(P2)**:`WORKBUDDY_DEVICE_TOKEN_FILE` 指向别的工具
106
+ (A / B 面板)维护的 token 文件,5 分钟重读、4 KB 上限,裸值与 `{"token":…}`
107
+ 信封都吃;token 字节绝不进日志与 `doctor`(schemaVersion 7 → 8,
108
+ `deviceIdentity.token`)。
109
+ - **设备头档位 UI(P2.5)**:卡片设备头档位「虚拟值 / 真实值」切换与逐账号齿轮
110
+ (覆盖 `X-Machine-ID` / `X-Session-ID`),落盘
111
+ `$DSH_HOME/.workbuddy-device-profiles.json`(`0600`、锁内合并写)。路由
112
+ `GET`/`POST /plugins/dsh-connect-workbuddy/device-profile`(loopback-only)。
113
+ - **真实设备参数(P3)**:新增「真实值」档,卡片新增「SDK」分区。
114
+ - **档位互斥落在档位上**:`虚拟值` 发派生的 `X-Machine-ID` / `X-Session-ID`(可逐账号
115
+ 覆盖),`真实值` **只发** `X-Device-Token`,派生对整条路径不存在。此前的过渡形态
116
+ (真 token + 派生对同时发)不再是可达的组合——真 token 内含设备信息,旁边挂一对
117
+ 按 uid 算出来的 id 等于自证不一致。
118
+ - **真实值档下所有账号共用这台机器的真实设备**,因此每行的齿轮关闭,点击时说明原因。
119
+ 取不到 token 时**一个设备头都不发**,不退回派生对:界面写着「真实值」而线上跑着
120
+ 虚拟值,正是分档要消灭的那种不一致。
121
+ - **SDK 用本机已安装的桌面端,不随包分发**:插件包**不再**包含 Turing Shield
122
+ 的二进制(`.node` 里的 pdb 路径证明它是桌面端仓库的构建产物;重新分发闭源
123
+ 厂商二进制需要回答"从哪来、什么版本、依不依得着 EULA",这些答案属于桌面端
124
+ 发行方,不属于我们)。目录解析:`WORKBUDDY_TURING_SDK_DIR` 显式指定优先,
125
+ 否则按桌面端安装形状自动发现(Windows 默认布局 + 卸载注册表,macOS
126
+ `/Applications` 与 `~/Applications` 的 bundle;见
127
+ `native/turing-sdk/README.md`)。**子进程**调用(`worker.cjs`):原生模块的
128
+ 加载失败与不可取消的死等只该是"这一条命令失败",不该是插件进程失败。
129
+ 子进程只拿白名单环境变量,不整份继承。
130
+ - **macOS 现状如实记录**:probe 能过(真机验证),token 取不到——SDK 向
131
+ dispatch 主队列 `dispatch_sync`,纯 libuv 进程永不排空它(`sample` 栈实测,
132
+ 见 `native/turing-sdk/README.md`)。mac 上表现为 `ready` 但 token 不可用,
133
+ 真实值档按上面的规则降级。修它需要排空主队列的伴生原生模块,不在本次范围。
134
+ - token 10 分钟重取、失败时 24 h 内旧值可用并标 `stale`、**不落盘**;完整值只在用户
135
+ 点「显示 / 复制」时经 `POST ?action=reveal` 给一次,其余输出只有掩码与长度。
136
+ - 卡片新增「SDK」分区(与「模型 / 能力 / 诊断」同一行):连接状态、SDK 目录与运行时、
137
+ 最近取到时间与当前档位、`X-Device-Token` 的掩码 + 长度,附「显示 / 复制 / 重新获取」。
138
+ 路由 `GET`/`POST /plugins/dsh-connect-workbuddy/device-sdk`(loopback-only)。
139
+ - `doctor` 增 `deviceIdentity.tier` 与 `deviceIdentity.sdk`(schemaVersion 8 → 9;
140
+ 相对 5.16.0 的 schemaVersion 6,本套变更合起来是 **6 → 9**)。
141
+
142
+ ### 测试
143
+
144
+ - **修掉 `refreshes itself when the token expires` 的竞态**(在作者的 `26be06e`
145
+ 上 4/4 复现,不是本套改动引入的)。
146
+ - 症状:该用例间歇性红,报
147
+ `AssertionError: expected 1793477227956 to be greater than 1793477227956`。
148
+ - 根因:假 worker 在**启动时**就把 `calls` 加一,而 `cached.fetchedAtMs` 要等
149
+ 子进程**退出**、父进程收下答案才更新——两者之间有几十毫秒的窗口。旧写法先
150
+ `waitFor` 到 `calls` 变大、再**立刻**比较时间戳,正好落在这个窗口里,于是
151
+ 约一半的跑法拿到的是上一个值。
152
+ - 改法:`waitFor` 的条件换成"时间戳确实前进了",断言的仍然是同一件事,只是不再
153
+ 假设两个计数器同步;跑完再确认 `calls` 也变大了(证明不是把时间戳改了个名字)。
154
+ - 变异验证:把断言换回旧写法,连跑 4 次红 3 次;换成新写法连跑 6 次全绿。
155
+
156
+ - **`hasTuringSdkBinding` 的兜底不再随宿主平台分岔**(Windows 腿上发现的真分岔)。
157
+ - 症状:`tests/turing-sdk.spec.ts` 的 "exposes the binding gate as a
158
+ platform-aware helper" 在 **Windows 腿确定性失败**、在 macOS 腿上绿。macOS 上
159
+ 跑过整套的评审看不到它,所以它一路绿到了这里。
160
+ - 根因在被测代码,不在测试:兜底拼法取的是**宿主**的 `join`
161
+ (`process.platform === 'win32' ? win32.join : posix.join`),而
162
+ `process.platform === 'win32'` 时它恰好等于数据的 `win32.join`,于是
163
+ `hostPath !== dataPath` **恒为假**,兜底分支被整个短路。同一个调用
164
+ `(dir, exists, 'win32')` 因此在 Windows 上只试一种拼法、在 macOS 上试两种。
165
+ - 改法:兜底显式取**另一种**拼法(`platform === 'win32' ? posix.join :
166
+ win32.join`),答案只由参数决定。测试侧补一条反向用例(数据 POSIX、喂 win32
167
+ 形状的目录)——两个方向一起断言,这个分岔在**任意宿主**上都会红。
168
+ - 变异验证:把兜底改回宿主 `join`,正向断言当场打红(1 failed / 28 passed);
169
+ 恢复后 29 passed。
170
+ - **Windows 11 真机全量**(Node 24.22.1):`typecheck` 通过、`build` 通过、
171
+ **2829 例中 2828 通过**。唯一失败是 `tests/issue12-region-hiding.spec.ts` 的
172
+ 轮询 flake,已在**未修改的 `d5183b2` 上同样复现**(2690/2691),与本 PR 无关。
173
+ - **Windows 上真实 SDK 链路跑通**:发现链命中
174
+ `%LOCALAPPDATA%\Programs\WorkBuddy\resources\app.asar.unpacked\native\turing-sdk`,
175
+ `probe` 返回 `ready`(`win32-x64`,napi 10),`tokens.refresh()` 取回 `v3:` 前缀
176
+ token、长度 1210、耗时 **418 ms**。macOS 上那条 `dispatch_sync` 主队列死锁在
177
+ Windows 上不复现——Windows 的原生 binding 不走 dispatch 主队列。
178
+
3
179
  ## 5.16.0 (2026-10-31)
4
180
 
5
181
  > **Windows 上凭据库的明文 token 之前对同机低权限进程可读。** issue #183。
package/README.en.md CHANGED
@@ -463,6 +463,20 @@ dsh plugin --profile <web|desktop|dsh-tui> exec dsh-connect-workbuddy logout #
463
463
 
464
464
  `status` and `doctor` accept `--json` for machine-readable output.
465
465
 
466
+ ### Device-identity environment variables
467
+
468
+ The outbound identity profile (`wireProfile`) and the device-header tier (`deviceTier`) are **card settings**, not environment variables. The variables below are the escape hatches for cases a card setting cannot reach:
469
+
470
+ | Variable | Default | Notes |
471
+ |---|---|---|
472
+ | `WORKBUDDY_DEVICE_TOKEN_FILE` | unset | File source for an external `X-Device-Token` in the *virtual* tier: points at a token file another tool maintains (bare value or `{"token":…}` envelope), re-read every 5 min, 4 KB cap; token bytes never reach logs or `doctor`. Same meaning as the card setting `deviceToken.file`, used when that is empty |
473
+ | `WORKBUDDY_HEADER_TRACE` | unset | Set to `1` and `doctor` prints one more section: the header **name** list each request path would send (names only — never values). For answering "what does this tier actually send" |
474
+ | `WORKBUDDY_TURING_SDK_DIR` | unset | Turing Shield SDK directory for the *real* tier. When unset the plugin **auto-discovers** the desktop app's install layouts (`/Applications`, `%LOCALAPPDATA%`, the uninstall registry hive, …); set it when the desktop app is installed yet `doctor` still reports "not found". The card's **SDK** section accepts the same directory (no env var, applies on save) and this variable takes precedence. What happens when no real device can be obtained is the next-but-one row |
475
+ | `WORKBUDDY_TURING_CHANNEL_ID` | `109144` | SDK channel id, matching the desktop app's `product.json` |
476
+ | `WORKBUDDY_TURING_PRODUCT_NAME` | `WorkBuddy` | Product name the SDK initialises with |
477
+ | `WORKBUDDY_TURING_PRODUCT_VERSION` | plugin version | Product version the SDK initialises with |
478
+ | `WORKBUDDY_TURING_KEYCHAIN_STORAGE` | unset (= off) | Set to `1` to let the SDK enable its own device-cache storage; off by default — the plugin does not write device state into the user's keychain |
479
+
466
480
  > **Why these three commands work on a machine with nothing installed (issue #47)**
467
481
  >
468
482
  > The plugin declares `@deepseek-ai/dsh-atomic-write`, `@deepseek-ai/dsh-home-paths`, and the rest of the DSH packages as **peers**: the host supplies them and the plugin ships no copy. That works inside a **booted DSH process** (the host's runtime interception layer resolves those names against the installation), but `dsh plugin … exec` is not that — it runs one `pnpm exec` in the profile directory, and that child uses **stock Node resolution**. The profile is created with `autoInstallPeers: false`, so the peers are never installed there and the two packages cannot be found.
@@ -495,6 +509,38 @@ Local dev via a `link:` install to the desktop profile (restart DSH Desktop afte
495
509
  dsh plugin --profile desktop add /Users/dmh2002/DshProject/dsh-connect-workbuddy
496
510
  ```
497
511
 
512
+ #### A `link:` install must be built first, or DSH refuses to load it
513
+
514
+ `lib/` is a build product and is gitignored, while a `link:` install runs **no lifecycle scripts**
515
+ (`prepare` never fires). Install from a source checkout that was never built and the files named by
516
+ `package.json`'s `main` / `exports` simply are not there, so DSH's plugin market answers:
517
+
518
+ ```
519
+ 声明的入口产物缺失(源码检出或构建被拦),下次启动会失败
520
+ the declared entry artifact is missing (source-only checkout or blocked build) — the next boot would fail
521
+ ```
522
+
523
+ That verdict comes from `dshmarket`'s `entryArtifactExists()`: it reads `main` and `exports` in the
524
+ installed directory and that is the whole evidence. So:
525
+
526
+ ```sh
527
+ pnpm install # `prepare` builds once (lib/ appears)
528
+ # or just build
529
+ pnpm run build
530
+ ```
531
+
532
+ Re-run a build after editing source (or `pnpm install` again), then restart DSH Desktop. If the warning
533
+ survives that, run the check — it prints every declared artifact, and separates "never built" from
534
+ "manifest and build disagree":
535
+
536
+ ```sh
537
+ pnpm run verify:entries # this checkout
538
+ node scripts/verify-entry-artifacts.mjs <installed dir> # a specific installed copy
539
+ ```
540
+
541
+ > Installing from npm (`dsh plugin add dsh-connect-workbuddy`) needs none of this: the published
542
+ > tarball already contains `lib/`, and `prepack` only regenerates it.
543
+
498
544
  ### Calling `chatStream()` from a script: it returns an **envelope**, not a stream
499
545
 
500
546
  ```ts
package/README.md CHANGED
@@ -478,6 +478,20 @@ dsh plugin --profile <web|desktop|dsh-tui> exec dsh-connect-workbuddy logout #
478
478
 
479
479
  `status` 与 `doctor` 支持 `--json` 输出机器可读格式。
480
480
 
481
+ ### 设备身份相关的环境变量
482
+
483
+ 出站身份档位(`wireProfile`)与设备头档位(`deviceTier`)都是**卡片配置项**,不是环境变量。下面这些是给"配置项够不着的场景"留的旁路:
484
+
485
+ | 变量 | 默认 | 说明 |
486
+ |---|---|---|
487
+ | `WORKBUDDY_DEVICE_TOKEN_FILE` | 未设 | 「虚拟值」档外部 `X-Device-Token` 的文件源:指向别的工具维护的 token 文件(裸值或 `{"token":…}` 信封都吃),5 分钟重读、4 KB 上限;token 字节不进日志与 `doctor`。与卡片配置 `deviceToken.file` 同义,配置为空时读它 |
488
+ | `WORKBUDDY_HEADER_TRACE` | 未设 | 设 `1` 后 `doctor` 多打一节:每条请求路径**将要发出的头名清单**(只有名字,永远没有值)——排查"这一档到底发了什么"用 |
489
+ | `WORKBUDDY_TURING_SDK_DIR` | 未设 | 「真实值」档的 Turing Shield SDK 目录。不设置时插件按桌面端安装形状**自动发现**(`/Applications`、`%LOCALAPPDATA%`、卸载注册表等);装了桌面端却仍报「未找到」时,用它显式指路。**卡片「SDK」分区也能直接填**(不用改环境变量、保存即生效),本变量优先级更高。取不到真实设备时的行为见下一行 |
490
+ | `WORKBUDDY_TURING_CHANNEL_ID` | `109144` | SDK 的渠道号,与桌面端 `product.json` 一致 |
491
+ | `WORKBUDDY_TURING_PRODUCT_NAME` | `WorkBuddy` | SDK 初始化自称的产品名 |
492
+ | `WORKBUDDY_TURING_PRODUCT_VERSION` | 插件版本 | SDK 初始化自称的产品版本 |
493
+ | `WORKBUDDY_TURING_KEYCHAIN_STORAGE` | 未设(=关) | 设 `1` 允许 SDK 启用其自身的设备缓存存储;默认关闭——插件不把自己的设备状态写进用户机器的钥匙串 |
494
+
481
495
  > **为什么这三条命令能在「什么都没装」的机器上跑(issue #47)**
482
496
  >
483
497
  > 该插件把 `@deepseek-ai/dsh-atomic-write`、`@deepseek-ai/dsh-home-paths` 等一整套 DSH 包声明为 **peer**:由宿主提供,插件不自己带一份。这在**已启动的 DSH 进程内**工作正常(宿主有运行期拦截层负责按宿主安装位置解析这些名字),但 `dsh plugin … exec` 不是那种环境——它就是在 profile 目录里跑一次 `pnpm exec`,子进程用**普通 Node 解析规则**,而 profile 是按 `autoInstallPeers: false` 建的,peer 根本不会装进去。于是这两个包解析不到。
@@ -510,6 +524,37 @@ pnpm run check # typecheck + test + build
510
524
  dsh plugin --profile desktop add /Users/dmh2002/DshProject/dsh-connect-workbuddy
511
525
  ```
512
526
 
527
+ #### `link:` 安装必须先构建,否则 DSH 会拒绝加载
528
+
529
+ `lib/` 是构建产物且被 gitignore,而 `link:` 安装**不执行包的生命周期脚本**(`prepare` 不会跑)。
530
+ 于是从一份没构建过的源码检出安装时,`package.json` 里声明的 `main` / `exports` 指向的文件并不存在,
531
+ DSH 的插件市场据此判定:
532
+
533
+ ```
534
+ 声明的入口产物缺失(源码检出或构建被拦),下次启动会失败
535
+ ```
536
+
537
+ 这个判定来自 `dshmarket` 的 `entryArtifactExists()`——它只读安装目录里的 `main` 与 `exports`,
538
+ 文件在不在就是全部依据。所以:
539
+
540
+ ```sh
541
+ pnpm install # prepare 会构建一次(lib/ 出现)
542
+ # 或只构建
543
+ pnpm run build
544
+ ```
545
+
546
+ 改完源码也要再 `pnpm run build` 一次(或重跑 `pnpm install`),然后重启 DSH Desktop。
547
+ `pnpm install` 之后仍报同样的话,先跑这一条自查——它打印每个被声明的产物在不在,
548
+ 并区分「从没构建过」和「manifest 与构建不一致」两种原因:
549
+
550
+ ```sh
551
+ pnpm run verify:entries # 当前仓库
552
+ node scripts/verify-entry-artifacts.mjs <已安装的目录> # 具体某个安装副本
553
+ ```
554
+
555
+ > 从 npm 安装(`dsh plugin add dsh-connect-workbuddy`)不需要这一步:发布包里 `lib/` 已经在,
556
+ > `prepack` 也只负责把它重新生成一遍。
557
+
513
558
  ### 写脚本调用 `chatStream()` 时注意:它返回的是**信封**,不是可迭代流
514
559
 
515
560
  ```ts
package/lib/bin.js CHANGED
@@ -1,9 +1,122 @@
1
1
  #!/usr/bin/env node
2
- import { Bt as inspectCredentialDirectory, C as WORKBUDDY_VAULT_DIRNAME, D as defaultDesktopAuthCandidates, Ht as WORKBUDDY_APP_EXECUTABLE_ENV, Jt as findWorkbuddyAppExecutableWithSource, L as workbuddyOwnAuthPath, N as legacyWorkbuddyOwnAuthPath, O as defaultDesktopAuthDirs, R as workbuddyVaultDir, S as WORKBUDDY_AUTH_FILE_ENV, U as WorkBuddyUpstreamClient, Vt as protectCredentialDirectory, a as readHostHeartbeat, c as WORKBUDDY_CONNECT_VERSION, d as rosterSeenPath, f as piAiRuntimeInfo, m as FALLBACK_WORKBUDDY_MODELS_GLOBAL, nn as hostPeersInfo, o as workbuddyHostHeartbeatPath, p as FALLBACK_WORKBUDDY_MODELS, r as isHeartbeatProcessAlive, rn as resolveDshHome, u as describeRosterSeenPayload, w as WorkBuddyCredentialStore } from "./host-heartbeat-DpnLfJws.js";
2
+ import { $t as readDeviceTokenFile, 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 WORKBUDDY_DEVICE_TOKEN_FILE_ENV, S as FALLBACK_WORKBUDDY_MODELS, Z as DEFAULT_WIRE_PROFILE, a as readHostHeartbeat, an as protectCredentialDirectory, bn as hostPeersInfo, c as WORKBUDDY_CONNECT_VERSION, d as rosterSeenPath, en as ensureDeviceSalt, et as WorkBuddyUpstreamClient, f as piAiRuntimeInfo, fn as findWorkbuddyAppExecutableWithSource, in as inspectCredentialDirectory, it as describeRequestHeaderNames, j as WORKBUDDY_AUTH_FILE_ENV, m as createTuringSdk, nn as deriveDeviceId, o as workbuddyHostHeartbeatPath, on as WORKBUDDY_APP_EXECUTABLE_ENV, q as workbuddyVaultDir, r as isHeartbeatProcessAlive, tn as readDeviceSalt, u as describeRosterSeenPayload, v as readDeviceSettings, xn as resolveDshHome } from "./host-heartbeat-09tOJATV.js";
3
3
  import { readFile } from "node:fs/promises";
4
4
  import { dirname, join } from "node:path";
5
5
  import { realpathSync } from "node:fs";
6
6
  import { fileURLToPath } from "node:url";
7
+ //#region src/device-state.ts
8
+ /**
9
+ * 设备身份的**只读取证视图**(审计报告 P0,P1 起同时是"派生档会发什么"的唯一答案)。
10
+ *
11
+ * 这一层不注入头、不写盘、不发请求,只回答两个问题:
12
+ *
13
+ * 1. **现在**有没有设备身份真的上了线?——答案不是写死的文案,而是把请求路径
14
+ * 上同一批构造器跑出来的头名集合过滤一遍({@link describeRequestHeaderNames})。
15
+ * 于是它随代码自动变化:P1 之前是空数组,P1 之后是 `X-Machine-ID` /
16
+ * `X-Session-ID`,而没有任何地方需要改两次。
17
+ * 2. **派生档**会给这台机器的每个账号发什么?——同一个盐算出 machine/session
18
+ * 一对 id,并统计"N 个账号 → 几个不同设备"。第二个数字是审计 §5.4 的核心
19
+ * 问题:池子里的号是共用一台设备(易被聚成一群),还是各自一台(隔离)。
20
+ *
21
+ * ## 为什么盐由调用方传进来
22
+ *
23
+ * P0 时这个模块自己 `ensureDeviceSalt()`,因为那时它是唯一的调用者。P1 之后
24
+ * `doctor` 还要把同一个盐交给 {@link describeRequestHeaderNames} 去渲染完整的
25
+ * 头名清单——两处各自读一次盐,就可能各自读到不同的状态(一次读到 absent、
26
+ * 一次读到 ok),于是报告会在同一屏里自相矛盾。盐是调用方的事实,这里只做算术。
27
+ *
28
+ * 两者都不含凭据、不含盐本身。
29
+ *
30
+ * @module dsh-connect-workbuddy/device-state
31
+ */
32
+ /**
33
+ * 承载设备身份的**全部**头名。P2/P3 加 `X-Device-Token` 的读取时,这个常量不变
34
+ * ——它描述的是"哪些头算设备身份",不是"我们发了哪些"。
35
+ */
36
+ const WORKBUDDY_DEVICE_HEADER_NAMES = [
37
+ "X-Device-Token",
38
+ "X-Machine-ID",
39
+ "X-Session-ID"
40
+ ];
41
+ /**
42
+ * 把已经读到的盐与本地账号,组合成 `doctor` 要的那份报告。
43
+ *
44
+ * `credentials` 只用来取 `uid`:报告里不出现账号名、账号 id 或任何令牌。重复的
45
+ * uid 会被折叠(同一个号的两个历史凭据文件不该被算成两台设备)。
46
+ *
47
+ * 纯函数(无 IO、无时钟),所以测试不需要临时目录,也不会因为读写顺序不同而
48
+ * 得到两种答案。
49
+ */
50
+ function describeDeviceState(credentials, saltReadout, tokenReadout, real) {
51
+ const tier = real?.tier ?? "virtual";
52
+ /**
53
+ * 退回是否发生:真实值档 + 没有真 token + 开关开。
54
+ *
55
+ * 与 `upstream.ts` 的 `wireIdentity` 用**同一条判据**。两处各写一遍是这次改动
56
+ * 里唯一无法消除的重复(那个函数在请求路径上,不能 import 这个纯函数模块的
57
+ * 调用方;反过来会让 `device-state` 变成请求路径的依赖)。因此这条判据被写得
58
+ * 尽量小,且两边各有一条用例钉住同一种组合。
59
+ */
60
+ const fellBack = tier === "real" && real?.value === void 0 && real?.fallbackToVirtual === true;
61
+ const tierSent = fellBack ? "virtual" : tier;
62
+ const salt = {
63
+ path: saltReadout.path,
64
+ state: saltReadout.state,
65
+ ..."reason" in saltReadout ? { reason: saltReadout.reason } : {}
66
+ };
67
+ const token = tokenReadout === void 0 ? void 0 : {
68
+ path: tokenReadout.path,
69
+ state: tokenReadout.state,
70
+ ...tokenReadout.ageMs === void 0 ? {} : { ageMs: tokenReadout.ageMs },
71
+ ..."reason" in tokenReadout ? { reason: tokenReadout.reason } : {}
72
+ };
73
+ const identity = tierSent === "real" ? {
74
+ deviceTier: "real",
75
+ ...real?.value === void 0 ? {} : { deviceReal: real.value }
76
+ } : {
77
+ ...saltReadout.state === "ok" ? { deviceSalt: saltReadout.salt } : {},
78
+ ...tokenReadout?.state === "ok" ? { deviceToken: tokenReadout.token } : {}
79
+ };
80
+ const probe = credentials[0];
81
+ const onWire = probe === void 0 ? [] : describeRequestHeaderNames("chat", probe, identity).filter((name) => WORKBUDDY_DEVICE_HEADER_NAMES.includes(name));
82
+ const sdk = real === void 0 ? void 0 : {
83
+ state: real.sdk.state,
84
+ bundle: real.sdk.bundle,
85
+ path: real.sdk.path,
86
+ ...real.sdk.reason === void 0 ? {} : { reason: real.sdk.reason },
87
+ token: {
88
+ state: real.token.state,
89
+ length: real.token.length,
90
+ ...real.token.fetchedAtMs === void 0 ? {} : { ageMs: Date.now() - real.token.fetchedAtMs },
91
+ ...real.token.reason === void 0 ? {} : { reason: real.token.reason }
92
+ }
93
+ };
94
+ const uids = [...new Set(credentials.map((credential) => credential.uid).filter((uid) => uid !== ""))];
95
+ const base = {
96
+ tier,
97
+ ...fellBack ? { tierSent } : {},
98
+ ...fellBack ? { fallbackToVirtual: true } : {},
99
+ onWire,
100
+ salt,
101
+ ...token === void 0 ? {} : { token },
102
+ ...sdk === void 0 ? {} : { sdk }
103
+ };
104
+ if (tierSent === "real") return base;
105
+ if (uids.length === 0 || saltReadout.state !== "ok") return base;
106
+ const machineIds = uids.map((uid) => deriveDeviceId(uid, "machine", saltReadout.salt));
107
+ return {
108
+ ...base,
109
+ derived: {
110
+ accounts: uids.length,
111
+ distinct: new Set(machineIds).size,
112
+ sample: {
113
+ machineId: machineIds[0],
114
+ sessionId: deriveDeviceId(uids[0], "session", saltReadout.salt)
115
+ }
116
+ }
117
+ };
118
+ }
119
+ //#endregion
7
120
  //#region src/bin.ts
8
121
  /**
9
122
  * Standalone status/diagnostics CLI for the dsh-connect-workbuddy bundle.
@@ -35,10 +148,81 @@ import { fileURLToPath } from "node:url";
35
148
  * 5 → 6: added `credentialAcl` (issue #183). A store that could only ever ask
36
149
  * for `mode: 0o600` looked identical to one that enforced it; the new block
37
150
  * answers what the folder permissions actually ARE on this machine.
151
+ *
152
+ * 6 → 7: added `deviceIdentity` — which device headers are actually attached
153
+ * (nothing before P1, the derived `X-Machine-ID` / `X-Session-ID` pair from P1
154
+ * on) plus how many distinct virtual devices the pool would present. Added
155
+ * because "the plugin has no device identity" was a fact only a source reader
156
+ * could know; `doctor` is where it has to be visible
157
+ * (docs/DEVICE-IDENTITY-AUDIT.md).
158
+ *
159
+ * 7 → 8: added `deviceIdentity.token` (P2). The field is absent when this CLI did
160
+ * not inspect a token file at all — which is a different answer from "I looked
161
+ * and found none", so a consumer must be able to tell them apart rather than
162
+ * guess whether the absence means "old build" or "not configured".
163
+ *
164
+ * 8 → 9: added `deviceIdentity.tier` and `deviceIdentity.sdk` (P3). `tier` is
165
+ * required because the same `onWire` list now has two explanations: in the real
166
+ * tier it is one header and derived devices do not exist. Without it a consumer
167
+ * reading `onWire: ['X-Device-Token']` cannot tell "real tier, working" from
168
+ * "virtual tier with a file token".
169
+ *
170
+ * 9 → 10: `deviceIdentity.tierSent` / `deviceIdentity.fallbackToVirtual` (作者
171
+ * 意见 #2). Once the real tier may fall back to the virtual device, `tier` alone
172
+ * is no longer a description of the wire — it is the INTENT. Both fields appear
173
+ * only when they diverge, so a consumer that only knows version 9 keeps working
174
+ * for every machine that never turned the switch on, and a machine that did
175
+ * becomes legible instead of self-contradictory.
38
176
  */
39
- const JSON_SCHEMA_VERSION = 6;
177
+ const JSON_SCHEMA_VERSION = 10;
40
178
  /** Both regions, in reporting order. */
41
179
  const REGIONS = ["cn", "global"];
180
+ /**
181
+ * Set to `1` to have `doctor` print the header NAME list each request path
182
+ * would send. Names only — see the call site for why values are never printed.
183
+ */
184
+ const HEADER_TRACE_ENV = "WORKBUDDY_HEADER_TRACE";
185
+ /** 毫秒 → `42s` / `3m` / `2h5m`,只用于人读的诊断。 */
186
+ function describeAge(ms) {
187
+ const seconds = Math.max(0, Math.round(ms / 1e3));
188
+ if (seconds < 60) return `${seconds}s`;
189
+ const minutes = Math.round(seconds / 60);
190
+ if (minutes < 120) return `${minutes}m`;
191
+ return `${Math.floor(minutes / 60)}h${minutes % 60 === 0 ? "" : `${minutes % 60}m`}`;
192
+ }
193
+ /**
194
+ * The human form of the `deviceIdentity` block.
195
+ *
196
+ * Three lines on purpose: what is on the wire, whether an external token was
197
+ * inspected at all, and how many distinct virtual devices the pool would
198
+ * present. Collapsing them would let "3 accounts → 3 devices" read as "we send
199
+ * three devices".
200
+ *
201
+ * The first line names the tier because `doctor` runs outside the plugin and
202
+ * therefore cannot see the configured `wireProfile`: it renders the DEFAULT
203
+ * tier. A user who set `conservative` will see `balanced` here — stated rather
204
+ * than silently assumed, so the discrepancy is at least visible.
205
+ */
206
+ function describeDeviceLines(device, accounts) {
207
+ const onWire = device.onWire.length === 0 ? "none — no X-Device-Token / X-Machine-ID / X-Session-ID is attached" : device.onWire.join(", ");
208
+ /**
209
+ * 档位这一句要能读出**分岔**(作者意见 #2)。
210
+ *
211
+ * 退回生效时用户设的是 real、线上发的是 virtual。只印 `device.tier` 会让这一行
212
+ * 与后头的头名清单互相打脸("real values: X-Machine-ID, X-Session-ID" 读起来像
213
+ * bug)。所以分岔时就把它明写出来,并说出为什么——退回是用户自己开的开关。
214
+ */
215
+ const tierWords = device.tierSent === void 0 ? `${device.tier} values` : `${device.tier} requested, ${device.tierSent} values (fell back: no real device token)`;
216
+ const head = `Device identity on the wire (${DEFAULT_WIRE_PROFILE} headers, ${tierWords}): ${onWire}`;
217
+ const salt = `${device.salt.state}${device.salt.reason === void 0 ? "" : `: ${device.salt.reason}`} — ${device.salt.path}`;
218
+ const derived = device.tierSent === "real" ? "Derived devices: not used in the real tier — every account shares this machine's real device" : accounts === 0 ? `Derived devices: no signed-in account to derive from; salt ${salt}` : device.derived === void 0 ? `Derived devices: unavailable; salt ${salt}` : `Derived devices: ${accounts} account(s) → ${device.derived.distinct} distinct, sample machine=${device.derived.sample.machineId} session=${device.derived.sample.sessionId}; salt ${salt}`;
219
+ return [
220
+ head,
221
+ device.tierSent === "real" ? `Device token file: not consulted in the real tier (the SDK is the source there)` : device.token === void 0 ? `Device token: not inspected here — set ${WORKBUDDY_DEVICE_TOKEN_FILE_ENV} to the same file the plugin reads` : `Device token: ${device.token.state}${device.token.ageMs === void 0 ? "" : `, written ${describeAge(device.token.ageMs)} ago`}${device.token.reason === void 0 ? "" : ` (${device.token.reason})`} — ${device.token.path}`,
222
+ ...device.sdk === void 0 ? [] : [`Device SDK: ${device.sdk.state}${device.sdk.reason === void 0 ? "" : `: ${device.sdk.reason}`} (${device.sdk.bundle} — ${device.sdk.path === "" ? "no installed SDK found" : device.sdk.path}); token ${device.sdk.token.state}${device.sdk.token.length === 0 ? "" : ` (${device.sdk.token.length} chars)`}${device.sdk.token.ageMs === void 0 ? "" : `, fetched ${describeAge(device.sdk.token.ageMs)} ago`}${device.sdk.token.reason === void 0 ? "" : ` (${device.sdk.token.reason})`}`],
223
+ derived
224
+ ];
225
+ }
42
226
  /** Region labels for human output. */
43
227
  const REGION_LABELS = {
44
228
  cn: "CN (domestic)",
@@ -172,6 +356,70 @@ async function doctor(jsonOutput) {
172
356
  cn: credentialAcl.find(([region]) => region === "cn")[1],
173
357
  global: credentialAcl.find(([region]) => region === "global")[1]
174
358
  };
359
+ /**
360
+ * 设备身份取证(审计 `docs/DEVICE-IDENTITY-AUDIT.md` §4 的 D1 / §5.4 的隔离性)。
361
+ *
362
+ * 只读地算出两件事:现在**有没有**设备头上了线,以及派生档会给池子里的每个号
363
+ * 算出什么。唯一可能的写入是首次生成 `$DSH_HOME/.workbuddy-device.json`——
364
+ * 没有盐就算不出"这个池子会不会塌成一台设备",而这个答案离线推不出来。
365
+ * 只在确有账号时生成:一台没登录的机器不该留下设备身份。
366
+ *
367
+ * 盐在这里读**一次**,同一份读数同时喂给报告和下面的头名清单。两处各读一次
368
+ * 就可能读到两种状态(一次 absent、一次 ok),于是同一屏里自相矛盾。
369
+ */
370
+ const deviceCredentials = (await Promise.all((await anyStore.accounts()).map(async (account) => anyStore.credentialFor(account.id)))).filter((credential) => credential !== void 0);
371
+ const deviceSalt = deviceCredentials.length === 0 ? await readDeviceSalt() : await ensureDeviceSalt();
372
+ /**
373
+ * 外部设备 token(P2)。
374
+ *
375
+ * `doctor` 读不到插件配置,只能读环境变量——所以路径只有一种写法时两侧才一致
376
+ * (见 `WORKBUDDY_DEVICE_TOKEN_FILE_ENV` 的注释)。没设就**不去猜**:报告里
377
+ * 明确写"这里没查",而不是假装"没有 token"。
378
+ */
379
+ const deviceTokenFile = (process.env["WORKBUDDY_DEVICE_TOKEN_FILE"] ?? "").trim();
380
+ const deviceToken = deviceTokenFile === "" ? void 0 : await readDeviceTokenFile(deviceTokenFile);
381
+ /**
382
+ * 真实值档(P3)。
383
+ *
384
+ * 档位来自磁盘上的设备设置,不是猜的:同一台机器上插件与 `doctor` 读的是同一份
385
+ * 文件。`probe` 只起一个 6 ms 的子进程读 `isSupported`,**不发网络请求**;只有
386
+ * 真的处于真实值档时才去取一枚 token——那正是"SDK 现在能不能工作"的答案,
387
+ * 而它恰好是排障时最想知道的。
388
+ */
389
+ const deviceSettings = await readDeviceSettings();
390
+ const deviceTier = deviceSettings.mode;
391
+ const turing = createTuringSdk({
392
+ productVersion: APP_VERSION,
393
+ dirSource: async () => (await readDeviceSettings()).sdkDir
394
+ });
395
+ const turingInfo = await turing.info();
396
+ const turingToken = deviceTier === "real" ? await turing.tokens.current() : void 0;
397
+ const device = describeDeviceState(deviceCredentials, deviceSalt, deviceToken, {
398
+ tier: deviceTier,
399
+ sdk: turingInfo,
400
+ token: turing.tokens.readout(),
401
+ ...turingToken === void 0 ? {} : { value: turingToken },
402
+ fallbackToVirtual: deviceSettings.sdkFallbackToVirtual
403
+ });
404
+ const wireIdentity = deviceTier === "real" ? {
405
+ deviceTier: "real",
406
+ ...turingToken === void 0 ? {} : { deviceReal: turingToken }
407
+ } : {
408
+ ...deviceSalt.state === "ok" ? { deviceSalt: deviceSalt.salt } : {},
409
+ ...deviceToken?.state === "ok" ? { deviceToken: deviceToken.token } : {}
410
+ };
411
+ /**
412
+ * `WORKBUDDY_HEADER_TRACE=1` 时的头名清单。
413
+ *
414
+ * 只打**名字**,从不打值:这份输出是要贴进 issue 的,而头里混着令牌、会话 id
415
+ * 与派生设备 id。chat 与 billing 成对出现,是因为它们同 token 同分钟却曾经声称
416
+ * 两种客户端(审计 §1.3 的 D2)——能被看见才谈得上验证"现在统一了"。
417
+ */
418
+ const probeCredential = deviceCredentials[0];
419
+ const tracedHeaders = process.env[HEADER_TRACE_ENV] === "1" && probeCredential !== void 0 ? ["chat", "billing"].map((kind) => ({
420
+ kind,
421
+ names: describeRequestHeaderNames(kind, probeCredential, wireIdentity)
422
+ })) : void 0;
175
423
  const report = {
176
424
  schemaVersion: JSON_SCHEMA_VERSION,
177
425
  package: "dsh-connect-workbuddy",
@@ -233,6 +481,21 @@ async function doctor(jsonOutput) {
233
481
  vaultDirectory: join(resolveDshHome(), WORKBUDDY_VAULT_DIRNAME),
234
482
  regions: Object.fromEntries(credentialAcl)
235
483
  },
484
+ /**
485
+ * 设备身份:现在发了什么(`onWire`,由真实构造器算出而非写死)与派生档会发
486
+ * 什么。见 `docs/DEVICE-IDENTITY-AUDIT.md`。盐值本身永不出现,只报状态与路径。
487
+ */
488
+ deviceIdentity: {
489
+ tier: device.tier,
490
+ ...device.tierSent === void 0 ? {} : { tierSent: device.tierSent },
491
+ ...device.fallbackToVirtual === void 0 ? {} : { fallbackToVirtual: device.fallbackToVirtual },
492
+ onWire: device.onWire,
493
+ salt: device.salt,
494
+ ...device.token === void 0 ? {} : { token: device.token },
495
+ ...device.sdk === void 0 ? {} : { sdk: device.sdk },
496
+ ...device.derived === void 0 ? {} : { derived: device.derived },
497
+ ...tracedHeaders === void 0 ? {} : { requestHeaders: Object.fromEntries(tracedHeaders.map(({ kind, names }) => [kind, names])) }
498
+ },
236
499
  hostHeartbeat: {
237
500
  path: workbuddyHostHeartbeatPath(),
238
501
  present: heartbeat !== void 0,
@@ -279,6 +542,8 @@ async function doctor(jsonOutput) {
279
542
  `Atomic writes: ${hostPeers.atomicWrite === "host" ? "host-provided (@deepseek-ai/dsh-atomic-write)" : "built-in copy (host peer not resolvable here; normal outside a booted DSH)"}`,
280
543
  `Desktop auth file: ${report.desktopAuthFile.present ? "present" : "missing"} (${report.desktopAuthFile.path})`,
281
544
  `Encrypted-credential support: ${report.atRestDecryption.available ? "available" : "unavailable"} (${report.atRestDecryption.appExecutable}${report.atRestDecryption.appExecutableSource === void 0 ? "" : `, via ${report.atRestDecryption.appExecutableSource}`})`,
545
+ ...describeDeviceLines(device, deviceCredentials.length),
546
+ ...tracedHeaders === void 0 ? [] : tracedHeaders.map(({ kind, names }) => `Headers (${kind}, ${names.length}): ${names.join(", ")}`),
282
547
  `Host bundle: ${hostAlive ? `running (pid ${heartbeat.pid})` : heartbeat !== void 0 ? "stale heartbeat (process exited)" : "not started"}`,
283
548
  ...regionLists.flatMap(({ region, accounts }) => [`${REGION_LABELS[region]} accounts: ${accounts.length} (own copy ${workbuddyOwnAuthPath(region)})`, ...accounts.map((account) => ` - ${account.accountName === "" ? "(unnamed)" : account.accountName} (${account.id})${account.selected ? " [selected]" : ""} expires ${new Date(account.tokenExpiresAtMs).toISOString()}`)]),
284
549
  `Static fallback models: CN ${report.fallbackModels.cn}, Global ${report.fallbackModels.global}`,