dsh-connect-workbuddy 5.15.2 → 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/lib/bin.js CHANGED
@@ -1,8 +1,122 @@
1
1
  #!/usr/bin/env node
2
- import { C as WorkBuddyCredentialStore, D as defaultDesktopAuthDirs, E as defaultDesktopAuthCandidates, I as workbuddyOwnAuthPath, M as legacyWorkbuddyOwnAuthPath, Qt as hostPeersInfo, Rt as WORKBUDDY_APP_EXECUTABLE_ENV, S as WORKBUDDY_AUTH_FILE_ENV, V as WorkBuddyUpstreamClient, Wt as findWorkbuddyAppExecutableWithSource, a as readHostHeartbeat, c as WORKBUDDY_CONNECT_VERSION, d as rosterSeenPath, f as piAiRuntimeInfo, m as FALLBACK_WORKBUDDY_MODELS_GLOBAL, o as workbuddyHostHeartbeatPath, p as FALLBACK_WORKBUDDY_MODELS, r as isHeartbeatProcessAlive, u as describeRosterSeenPayload } from "./host-heartbeat-Dj8K0mMq.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
+ import { dirname, join } from "node:path";
4
5
  import { realpathSync } from "node:fs";
5
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
6
120
  //#region src/bin.ts
7
121
  /**
8
122
  * Standalone status/diagnostics CLI for the dsh-connect-workbuddy bundle.
@@ -30,10 +144,85 @@ import { fileURLToPath } from "node:url";
30
144
  * 4 → 5: added `rosterSeen`, so a first-sighting history that is corrupt or in
31
145
  * a version this build cannot read is REPORTED rather than silently answered as
32
146
  * "no new models".
147
+ *
148
+ * 5 → 6: added `credentialAcl` (issue #183). A store that could only ever ask
149
+ * for `mode: 0o600` looked identical to one that enforced it; the new block
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.
33
176
  */
34
- const JSON_SCHEMA_VERSION = 5;
177
+ const JSON_SCHEMA_VERSION = 10;
35
178
  /** Both regions, in reporting order. */
36
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
+ }
37
226
  /** Region labels for human output. */
38
227
  const REGION_LABELS = {
39
228
  cn: "CN (domestic)",
@@ -141,6 +330,96 @@ async function doctor(jsonOutput) {
141
330
  region,
142
331
  summary: await describeRosterSeen(region)
143
332
  })));
333
+ /**
334
+ * Per-region folder permissions of the plaintext credential vault (issue #183).
335
+ *
336
+ * Computed BEFORE the report object because both the report AND its `hints`
337
+ * read it, and a hint that reached back into the half-built report would be a
338
+ * use-before-declaration. It also runs the repair, so `doctor` fixes an
339
+ * exposed directory rather than only describing it.
340
+ */
341
+ const credentialAcl = await Promise.all(REGIONS.map(async (region) => {
342
+ const directory = workbuddyVaultDir(region);
343
+ const rootOutcome = await protectCredentialDirectory(dirname(directory));
344
+ const outcome = await protectCredentialDirectory(directory);
345
+ const acl = await inspectCredentialDirectory(directory);
346
+ return [region, {
347
+ directory: acl.directory,
348
+ state: acl.state,
349
+ ...acl.weak === void 0 ? {} : { unexpected: acl.weak },
350
+ ...acl.reason === void 0 ? {} : { reason: acl.reason },
351
+ ...outcome.state === "failed" ? { protectError: outcome.reason } : rootOutcome.state === "failed" ? { protectError: rootOutcome.reason } : {}
352
+ }];
353
+ }));
354
+ /** Indexed by region so the human output cannot silently skip a missing one. */
355
+ const credentialAclByRegion = {
356
+ cn: credentialAcl.find(([region]) => region === "cn")[1],
357
+ global: credentialAcl.find(([region]) => region === "global")[1]
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;
144
423
  const report = {
145
424
  schemaVersion: JSON_SCHEMA_VERSION,
146
425
  package: "dsh-connect-workbuddy",
@@ -185,6 +464,38 @@ async function doctor(jsonOutput) {
185
464
  global: workbuddyOwnAuthPath("global"),
186
465
  legacy: legacyWorkbuddyOwnAuthPath()
187
466
  },
467
+ /**
468
+ * Whether the plaintext credential vault is actually restricted (issue #183).
469
+ *
470
+ * The `mode: 0o600` the writer passes is a POSIX concept; on Windows the
471
+ * DACL decides. Reporting it here is the difference between "we asked for
472
+ * 0600" and "the token file is readable only by its owner" — the reporter
473
+ * found out it was the former while believing the latter. Per region,
474
+ * because the two directories are hardened independently.
475
+ *
476
+ * On POSIX every entry reads `not-windows` and no hint is emitted: `mode`
477
+ * carries the same intent there, and warning every macOS user about a
478
+ * Windows-only measure would be noise.
479
+ */
480
+ credentialAcl: {
481
+ vaultDirectory: join(resolveDshHome(), WORKBUDDY_VAULT_DIRNAME),
482
+ regions: Object.fromEntries(credentialAcl)
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
+ },
188
499
  hostHeartbeat: {
189
500
  path: workbuddyHostHeartbeatPath(),
190
501
  present: heartbeat !== void 0,
@@ -217,6 +528,10 @@ async function doctor(jsonOutput) {
217
528
  if (!summary.readable) return summary.present ? [`${REGION_LABELS[region]} first-sighting history is present but unreadable (${summary.path}); remove it to reseed on the next reconcile.`] : [];
218
529
  if (summary.versionKnown === false) return [`${REGION_LABELS[region]} first-sighting history is version ${summary.version === void 0 ? "unknown" : summary.version}, which this build cannot read (${summary.path}); it is answered as empty, so the pill shows no new-model marker.`];
219
530
  return [];
531
+ }),
532
+ ...credentialAcl.flatMap(([region, entry]) => {
533
+ if (entry.state !== "exposed") return [];
534
+ return [`The ${region} credential vault holds PLAINTEXT tokens but its folder permissions do not restrict them${entry.unexpected === void 0 ? "" : ` (readable by ${entry.unexpected.join(", ")})`}: ${entry.directory}. Re-run doctor to retry the repair, or fix it by hand with: icacls "${entry.directory}" /inheritance:r /grant:r "*S-1-3-4:(OI)(CI)(F)" /grant:r "*S-1-5-18:(OI)(CI)(F)" /grant:r "*S-1-5-32-544:(OI)(CI)(F)"`];
220
535
  })
221
536
  ]
222
537
  };
@@ -227,9 +542,16 @@ async function doctor(jsonOutput) {
227
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)"}`,
228
543
  `Desktop auth file: ${report.desktopAuthFile.present ? "present" : "missing"} (${report.desktopAuthFile.path})`,
229
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(", ")}`),
230
547
  `Host bundle: ${hostAlive ? `running (pid ${heartbeat.pid})` : heartbeat !== void 0 ? "stale heartbeat (process exited)" : "not started"}`,
231
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()}`)]),
232
549
  `Static fallback models: CN ${report.fallbackModels.cn}, Global ${report.fallbackModels.global}`,
550
+ ...REGIONS.map((region) => {
551
+ const entry = credentialAclByRegion[region];
552
+ const detail = entry.state === "protected" ? "owner / SYSTEM / Administrators only" : entry.state === "not-windows" ? "POSIX mode 0600 applies" : entry.state === "exposed" ? `EXPOSED${entry.unexpected === void 0 ? "" : ` to ${entry.unexpected.join(", ")}`}` : "unverified";
553
+ return `Credential vault ACL (${REGION_LABELS[region]}): ${entry.state} — ${detail} (${entry.directory})`;
554
+ }),
233
555
  ...REGIONS.map((region) => {
234
556
  const summary = report.rosterSeen[region];
235
557
  if (summary === void 0) return `New-model history (${REGION_LABELS[region]}): not available`;