dsh-connect-workbuddy 5.15.1 → 5.16.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,142 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.16.0 (2026-10-31)
4
+
5
+ > **Windows 上凭据库的明文 token 之前对同机低权限进程可读。** issue #183。
6
+ > `mode: 0o600` 在 Windows 上不生效,而插件一直把它当成已经做了权限限制。
7
+
8
+ ### 变更
9
+
10
+ - **凭据库在 Windows 上显式加固文件夹权限**(issue #183)。
11
+ - **问题**:`~/.dsh/workbuddy-vault/<region>/<accountId>.json` 存着解密后的
12
+ `accessToken` / `refreshToken` 明文,写入时传 `mode: 0o600`。Node 的
13
+ `fs.writeFile` / `fs.rename` 在 Windows 上**忽略** `mode`——权限完全由继承的
14
+ DACL 决定。报告者用 `Get-Acl` 实测:该文件对
15
+ `<机器>\CodexSandboxUsers`(DSH 自己沙箱进程的账户)可写可读,也就是本机
16
+ 任何沙箱进程 / 插件 / 脚本都能取到一枚可用 JWT。
17
+ - **改法**:新增 `src/windows-acl.ts`。`writeVaultEntry()` 在写入**之前**加固
18
+ vault **根目录**(`dirname(dir)`——它才是承载 `~/.dsh` 那个
19
+ `Everyone: FullControl` 的一层),**一次 `icacls` 调用**,不遍历子目录:
20
+ 实测 Windows 会把新的可继承 ACE 沿树重新传播,父目录加固后,子目录与其中的
21
+ 既有文件都变成恰好那三条 ACE(`weak=0`)。ACE 只保留
22
+ `OWNER RIGHTS`(S-1-3-4) / `SYSTEM`(S-1-5-18) / `Administrators`(S-1-5-32-544),
23
+ 全部用 SID 而非账户名,因此在任意语言的 Windows 上行为一致。
24
+ - **为什么必须加固在写入之前**:`writeFileAtomic` 是「写临时 inode → rename
25
+ 覆盖」,替换产生的是**新 inode**。写在之后加固,既留下 pre-rename 窗口,也
26
+ 会被下一次替换抹掉。加固目录在前,替换出来的 inode 一出生就继承受限 ACE。
27
+ - **为什么不用 `icacls /T`**:实测 `/T` 配合 `(OI)(CI)` 会让它走过的**每个
28
+ 文件得到空 DACL**(`ACEcount=0`),谁都读不了。正确形态是目录用
29
+ `(OI)(CI)`、文件用裸 `(F)`;本实现的写入路径只加固目录,靠传播覆盖文件。
30
+ - **成本与并发**:`icacls` 是子进程,实测静止态 19–52 ms、**并行负载下最高
31
+ 1242 ms**。因此除了「一个目录一次调用」,同一路径**正在进行的**加固会被
32
+ join 而不是重复发起,突发写入只排一个子进程。这个数字是实测得来的:
33
+ 最初「每次写入再加固一次文件」的版本把
34
+ `tests/issue12-region-hiding.spec.ts` 的 1 s 轮询预算顶穿,才改成现在的形态。
35
+ - **失败不致命**:加固是纵深防御,不是写入前置条件。`icacls` 失败时凭据照常
36
+ 落盘,`doctor` 会把失败情况报出来。
37
+ - **POSIX 不付任何代价**:非 Windows 直接返回 `not-windows`,不 spawn 任何子
38
+ 进程——那里的 `mode 0600` 本来就是这个意思。
39
+ - **没有实现的**:issue 的建议 1(DPAPI / `safeStorage` 加密落盘)。落盘内容
40
+ 仍是明文,只是权限收紧了;管理员、SYSTEM 服务,或已取得该用户令牌的攻击者
41
+ 仍可读取。要做到那一步需要改 vault 的磁盘格式并做迁移,属独立改动。
42
+
43
+ - **`doctor` 新增 `credentialAcl` 块**(`--json` schema 5 → 6)。逐 region 报告
44
+ vault 目录的权限状态,并在报告前**先尝试修复**——所以这个命令对已经被旧版本
45
+ 暴露过的机器是有用的,而不只是描述问题。取值:
46
+ - `protected`:只有 OWNER RIGHTS / SYSTEM / Administrators
47
+ - `exposed`:还有别的持有者,并在 `unexpected` 里点名 SID
48
+ - `unverified`:读不回来(PowerShell 缺失 / 超时)。**故意不折进 `exposed`**
49
+ ——「没测到」和「测到是脏的」需要用户做不同的事,谎报暴露本身就是一种误导
50
+ - `not-windows`:POSIX,`mode 0600` 已表达同样意图,因此不产生任何提示
51
+
52
+ - **人类可读输出新增一行** `Credential vault ACL (<region>): <state> — <detail>`,
53
+ 且在 `exposed` 时给出可直接粘贴的 `icacls` 修复命令。
54
+
55
+ ### 文档
56
+
57
+ - 新增 `docs/CACHE-HIT-70-RESEARCH.md` + `docs/ISSUE-184-REPLY.md`(issue #184
58
+ 「缓存命中太低,一直在 70 左右徘徊」的取证报告与可直接粘贴的 issue 回复)。
59
+ **只是记录,不含任何产品代码改动**——`src/upstream.ts` / `src/shim.ts` /
60
+ `src/index.ts` / `src/adapter.ts` / `src/account-pool.ts` / `src/body-report.ts`
61
+ 与 `tests/upstream.spec.ts` 均未修改,`keepPromptLast` 保持原样。
62
+ - **本机复现不出 70%**:全机 workbuddy 加权命中率 97.5%,主力模型
63
+ `deepseek-v4.1-flash` 97.9%(13,282 请求 / 3,157,473,803 prompt token)。
64
+ - **量级足够解释 70% 的机制**:会话混用模型,其中 `minimax-m3.1-flash`
65
+ 完全不复用缓存(44.6%);反推混入 52.3% 的 prompt 量即可落到 70%,
66
+ 本机 61 个混用会话实测落在 55–75%。
67
+ - **缓存按账号隔离**(A 97.4% / B 0.0% / A 复测 97.3%,同分钟同字节),
68
+ 但账号池换号要每 3.8 请求一次才能造成 70%,实测远低。
69
+ - **`keepPromptLast` 确实是 bug**(开启后每轮边界必断,断点在 message[1]
70
+ 这类极早期位置),但真实代价只有 **−1.74 个点**——真实宿主并不每个 step
71
+ 注入(两个真实会话分别 386 step/12 条、682 step/34 条)。
72
+ - **追加取证(§8)**:`billion-context` 确实在请求链路上(`127.0.0.1:18787`),
73
+ 但以代理 `startedAt` 为界做**同会话**前后对照只掉 0.31 个点;真正的最大
74
+ 单一成因是**工具注册表在会话中途增删工具**——单会话 7 个 `system/message`
75
+ 版本两两不同,每次变更整段前缀失效,turn 12 之后不再变化时命中率立刻回到
76
+ 96% 以上。次因是 `trae` 通道上游不报缓存(34 个请求 `read=0`,占该会话
77
+ 未命中的 33.7%)。
78
+ - 报告里同时记录了我自己的两次判断修正:用「`read` 冻结不动」当断裂信号是
79
+ **错的**(短 step 也会满足),改用「相对上一请求缩水 >20%」;以及用
80
+ **安装时间**而非**代理启动时间**做分界会把跨越期错算进「生效后」。
81
+
82
+ ### 测试
83
+
84
+ - 新增 **12** 例(`tests/issue183-credential-acl.spec.ts`):
85
+ - 写入路径对 vault 根目录发起**恰好一次** `icacls`(既是「加固了」,也是
86
+ 「没有退化成逐目录遍历」——后者是实测 1242 ms 的来源)
87
+ - `icacls` 失败时凭据**照样落盘**(纵深防御不能变成故障)
88
+ - POSIX 上**一个子进程都不 spawn**
89
+ - 传的是 SID 不是账户名(zh-CN 主机上账户名会被本地化)
90
+ - 目录授权必须带 `(OI)(CI)`、文件授权必须**不带**
91
+ - `/T` 永不出现
92
+ - `doctor` 的四个状态各有一条
93
+ - 记忆化只在**成功**时生效(失败必须让下次写入重试)
94
+ - **变异验证**:9 个变异体,8 个被当场打红。第 9 个(把文件授权改成
95
+ `*:(OI)(CI)(F)`)**首轮 12/12 全绿**——因为测试当时用
96
+ `filter(arg => arg.startsWith('*S-1-'))` 取授权,而变异体产生的畸形串根本
97
+ 进不了那个过滤器。已把取法改成「取 `/grant:r` 后面的那个值」并断言**恰好 3
98
+ 条**,重跑后该变异体转红。这条留在注释里,免得下一个人再写出同样取不到的断言。
99
+ - **全仓结果**:2691 例通过(160 文件),类型检查通过。
100
+ - 需要说明的是,`tests/issue12-region-hiding.spec.ts` 的
101
+ 「does not report the in-use model as withdrawn after a directoryless
102
+ save」在本机**改动前**就不稳定:未修改的 HEAD 连跑 5 次,4 次失败、1 次
103
+ 通过;本改动落地后连跑 5 次,3 次失败、2 次通过。两者属同一量级,且该用例
104
+ 断言的是上游目录内容而非文件权限,因此判定为**既有 flake**,不是本改动的
105
+ 回归。本改动与它的唯一交集是 icacls 的调用耗时,现已压到「一目录一次、
106
+ 并发合并」,不再让该用例的 1 s 轮询预算受此影响。
107
+
108
+ ## 5.15.2 (2026-10-30)
109
+
110
+ > **英文界面下的「最近刷新」不再显示成中文式的时间。** 同步自
111
+ > `dsh-connect-trae` 的 issue #71。
112
+
113
+ ### 变更
114
+
115
+ - **「最近刷新」的时刻跟随读者语言**(同步自 `dsh-connect-trae` 的 issue #71)。
116
+ - **问题**:`formatClock` 把 locale 钉死成 `'zh-CN'`,于是英文界面印的是
117
+ `23:59`(中文习惯的 24 小时制),而不是 `11:59 PM`。用户看的是一个
118
+ **显示**格式,却按一个写死的语言来排。
119
+ - **改法**:`toLocaleTimeString('zh-CN', …)` → `toLocaleTimeString(undefined, …)`,
120
+ 即跟随读者语言——与同仓库 `AccountPool.tsx` 里那个 `formatClock` 的做法一致
121
+ (它本来就用 `Intl.DateTimeFormat(undefined, …)`)。
122
+ - **影响面**:这个 `formatClock` 只有一个调用点——页脚的「最近刷新」
123
+ (`composer.lastRefresh`)。它是「当下」的同一时刻,不需要日期。
124
+ - **没有连带改的**:`AccountPool.tsx` 的池日志时间戳**本来就**跟随读者语言,
125
+ 不在本次范围;`credit-format.ts` 的 `toLocaleString('en-US')` 是金额分组的
126
+ 刻意选择(千分位一致),与语言无关,不动。
127
+
128
+ ### 测试
129
+
130
+ - 新增 **2** 例(2677 总例,较 5.15.1 净增 2):
131
+ - **源码级**:`formatClock` 不得再出现硬编码的 locale。这一条不依赖测试环境的
132
+ locale——行为级断言在 zh-CN 环境下会因两种写法结果相同而失效,源码级不会。
133
+ - **行为级**:渲染出的「最近刷新」时刻必须等于**读者 locale** 对该时刻的写法。
134
+ `lastRefresh` 是「最近一次刷新的时刻」(即当下),所以期望值取渲染前后两个
135
+ 瞬间,容许跨过一分钟边界。
136
+ - **变异验证**:把 locale 改回 `'zh-CN'`,两条用例**同时**转红(源码级点名
137
+ 「still pins a locale」,行为级报出实际渲染值 `19:36` 与期望的 `07:36 PM`)。
138
+ - 全仓 **2677** 例通过(159 文件),类型检查通过。
139
+
3
140
  ## 5.15.1 (2026-10-30)
4
141
 
5
142
  > **积分读数从「权限切换器旁边」挪到「模型选择器左边」。** 两者原本相隔 8px 且都是
package/README.en.md CHANGED
@@ -186,9 +186,9 @@ One class of state in the pool **does not go through a draft**: probe results, c
186
186
 
187
187
  > ⚠️ **For the CN 「channel verification」 400 (`code 11128`), make sure the plugin is ≥ 5.14.1.** From 5.13.1 the plugin rewrites the known fixed fingerprints **before the request is sent**, and 5.14.0 adds the Web-GUI paragraph's SECOND sentence (#167, the branch still reproducing on 5.13.1); 5.12.x and earlier only had the neutral-head + zero-width ladder, which measured **400 on every rung** for the same body (matrix in [#164](https://github.com/dingminhua/dsh-connect-workbuddy/issues/164)). Anyone left on an older build keeps hitting a 400 that is already fixed, and it looks like "fails every single time, restarting does nothing".
188
188
  >
189
- > ⚠️ **Do not treat the marketplace's "latest" as the schedule — it reads an index that lags.** The community marketplace serves a `dsh-plugin-catalog` snapshot, collected per package: **the snapshot built on 2026-10-30 still listed only 5.13.1 for this plugin** while npm `latest` was **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.
189
+ > ⚠️ **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.
190
190
  >
191
- > 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.14.1`.
191
+ > 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`.
192
192
 
193
193
  ### Supported host range
194
194
 
@@ -250,7 +250,7 @@ Restart the DSH process after install/update/uninstall.
250
250
  > | exact `5.14.1` + `minimumReleaseAgeExclude: [dsh-connect-workbuddy]` in the profile's `pnpm-workspace.yaml` | **5.14.1** ✅ |
251
251
  > | setting absent (pnpm default) | floating `^5.13.1` → **5.14.1** ✅ |
252
252
  >
253
- > To pick up a new release right away, pin it: `dsh plugin --profile desktop add dsh-connect-workbuddy@5.14.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.
253
+ > 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.
254
254
 
255
255
  The plugin also runs under **Web** and **TUI**; pick the command matching your profile:
256
256
 
@@ -267,7 +267,7 @@ dsh plugin --profile dsh-tui add dsh-connect-workbuddy # TUI
267
267
  **Manual update (one command)**:
268
268
 
269
269
  ```sh
270
- dsh plugin --profile desktop add dsh-connect-workbuddy@5.14.1
270
+ dsh plugin --profile desktop add dsh-connect-workbuddy@5.15.1
271
271
  dsh plugin --profile desktop exec dsh-connect-workbuddy doctor # first line carries the version
272
272
  ```
273
273
 
@@ -288,7 +288,7 @@ My profile is desktop.
288
288
 
289
289
  > Do not tell an AI to "retry until it succeeds": inside the window every retry gets the same refusal, and pnpm offers no one-shot bypass.
290
290
 
291
- **Confirming it actually changed**: the first line of `doctor` (`WorkBuddy Connect 5.14.1 on …`), or the top-level `version` in `status --json`. **Do not** look for `/workbuddy status` (the slash command this plugin registers is `/codebuddy`, which forwards to the local CodeBuddy CLI), and **do not** look for a version row in the card's Diagnostics tab (it has exactly eight rows — region, domain, serving account, sign-in expiry, catalog size, enabled count, account pool, last failure — and no version). Restart or reload, then judge.
291
+ **Confirming it actually changed**: the first line of `doctor` (`WorkBuddy Connect 5.15.1 on …`), or the top-level `version` in `status --json`. **Do not** look for `/workbuddy status` (the slash command this plugin registers is `/codebuddy`, which forwards to the local CodeBuddy CLI), and **do not** look for a version row in the card's Diagnostics tab (it has exactly eight rows — region, domain, serving account, sign-in expiry, catalog size, enabled count, account pool, last failure — and no version). Restart or reload, then judge.
292
292
 
293
293
  Details (how the market index and the pnpm window each stop you, and both ways through) are in [`docs/PINNED-UPGRADE-LAG.md`](docs/PINNED-UPGRADE-LAG.md); the same text is posted as a long-term pinned issue.
294
294
 
@@ -303,13 +303,15 @@ All three platforms are supported targets; the differences below are **implement
303
303
  | Process-heartbeat timestamp source | PowerShell `Get-Process` `StartTime` (POSIX has no `ps -lstart` equivalent) | `ps -o lstart=` | `ps -o lstart=` |
304
304
  | Child-process window | **`windowsHide` is required**: the host itself has no console (it is a GUI process), so without it every probe flashes a visible black window on screen | Not applicable (the option only takes effect on Windows) | Not applicable |
305
305
  | Transient settings-file contention | **Does hit it**: an antivirus scanner / OneDrive / an editor locking the profile's `cordis.patch.yml` briefly makes the rename replace fail, and `@deepseek-ai/dsh-atomic-write`'s retries are enabled **only on `win32`** | Does not: POSIX rename replaces outright, so the same code never enters the retry branch | Same as macOS |
306
+ | Credential vault file permissions | **`mode: 0o600` has no effect**, because permissions come from the inherited DACL → the plugin hardens the directory and file with `icacls` around each write (owner / SYSTEM / Administrators only). `doctor` reads it back and reports `protected` / `exposed` / `unverified` | Enforced by `mode 0600` | Enforced by `mode 0600` |
306
307
  | CI coverage | `windows-latest`, full suite | The developer's own Mac | `ubuntu-latest`, full suite |
307
308
 
308
- **Three Windows-specific things worth knowing**:
309
+ **Four Windows-specific things worth knowing**:
309
310
 
310
311
  1. **An account change may fail to save** (the profile's `cordis.patch.yml` held open). The plugin **reads the value back after writing**: it reports "cleared" only once the write is confirmed on disk, and otherwise reports the failure and keeps your previous choice. Close whatever holds the file and retry. See [Known limitations](#known-limitations).
311
312
  2. **Credential paths are partly verified on real Windows hardware.** The candidate list is derived from platform conventions and pinned by unit tests (including both the unset and the blank-string fallback for `LOCALAPPDATA` / `APPDATA`). On a real Windows 11 machine, `%LOCALAPPDATA%\CodeBuddyExtension\Data\Public\auth` and `%LOCALAPPDATA%\Programs\WorkBuddy\WorkBuddy.exe` **did resolve**, and the encrypted credential's `keyId` matched the registered vector verbatim. **The remaining candidates are still not verified per-item** — if your credential or app lives elsewhere, point `WORKBUDDY_AUTH_FILE` / `WORKBUDDY_APP_EXECUTABLE` at it and please report what you see.
312
313
  3. **Encrypted credentials (from 5.6.0) require the desktop app to be present**, on Windows exactly as on macOS; if the app lives in a custom directory (e.g. `E:\WorkBuddy\WorkBuddy.exe`), point `WORKBUDDY_APP_EXECUTABLE` at it.
314
+ 4. **The credential vault stores PLAINTEXT tokens** (issue #183). The plugin's vault directory `<DSH home>/workbuddy-vault/<region>/<accountId>.json` holds the decrypted `accessToken` / `refreshToken`, **unencrypted**. From 5.16.0 on Windows, each write hardens that directory with `icacls` so only the owner / SYSTEM / Administrators can read it, and `doctor` prints a `Credential vault ACL` line that reads the result back. But **restricted permissions are not encryption** — an administrator, a SYSTEM service, or an attacker who already has your user token can still read it. For encryption at rest, keep the DSH home on a BitLocker / FileVault volume. POSIX platforms rely on `mode 0600`.
313
315
 
314
316
  ### Using it on a server: carry the credential over
315
317
 
package/README.md CHANGED
@@ -196,9 +196,9 @@ DSH PiAiAdapter(每个 provider 一套)
196
196
 
197
197
  > ⚠️ **国内区的「渠道校验」400(`code 11128`)请确保插件 ≥ 5.14.0。** 5.13.1 起会在**发出请求之前**按句改写已知的固定指纹,5.14.0 又补上了 Web GUI 段落的第二句(#167,5.13.1 上仍然必现的那一支);5.12.x 及更早只有「中性头 + 零宽扰动」三级救援,在同一份 body 上实测**全部 400**(对照矩阵见 [#164](https://github.com/dingminhua/dsh-connect-workbuddy/issues/164))。停在旧版的人会反复撞上这个已经修好的 400,而表现是「每次必现、重启也没用」。
198
198
  >
199
- > ⚠️ **别把插件市场里那个「最新」当日程表——它读的是一份会落后的索引。** 社区市场走 `dsh-plugin-catalog` 的快照(按包各自收录),**2026-10-30 那份快照里本插件只到 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 让它替你跑。
199
+ > ⚠️ **别把插件市场里那个「最新」当日程表——它读的是一份会落后的索引。** 社区市场走定期构建的快照(按包各自收录),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 让它替你跑。
200
200
  >
201
- > 另一个会让人升级不到的原因:**pnpm 的 24 小时新版本等待期**(`minimumReleaseAge`)会把浮动范围**静默压回上一个版本**。需要立刻修复时请写**精确版本号**:`dsh plugin --profile desktop add dsh-connect-workbuddy@5.14.1`(原因见下方「刚发布的版本请写精确版本号」那条)。
201
+ > 另一个会让人升级不到的原因:**pnpm 的 24 小时新版本等待期**(`minimumReleaseAge`)会把浮动范围**静默压回上一个版本**。需要立刻修复时请写**精确版本号**:`dsh plugin --profile desktop add dsh-connect-workbuddy@5.15.1`(原因见下方「刚发布的版本请写精确版本号」那条)。
202
202
 
203
203
  ### 受支持的宿主范围
204
204
 
@@ -262,7 +262,7 @@ npm install dsh-connect-workbuddy
262
262
  > | 精确 `5.14.1` + profile `pnpm-workspace.yaml` 里 `minimumReleaseAgeExclude: [dsh-connect-workbuddy]` | **5.14.1** ✅ |
263
263
  > | 不设该项(pnpm 默认) | 浮动 `^5.13.1` → **5.14.1** ✅ |
264
264
  >
265
- > 想立刻用上新版,请写精确版本号:`dsh plugin --profile desktop add dsh-connect-workbuddy@5.14.1`;若被等待期拒绝,见 [`docs/PINNED-UPGRADE-LAG.md`](docs/PINNED-UPGRADE-LAG.md) §2 的两条路(等窗口过去,或加那行 exclude)。过了等待期之后,浮动范围会自然跟上。
265
+ > 想立刻用上新版,请写精确版本号:`dsh plugin --profile desktop add dsh-connect-workbuddy@5.15.1`;若被等待期拒绝,见 [`docs/PINNED-UPGRADE-LAG.md`](docs/PINNED-UPGRADE-LAG.md) §2 的两条路(等窗口过去,或加那行 exclude)。过了等待期之后,浮动范围会自然跟上。
266
266
 
267
267
  插件在 **Web**、**Desktop**、**TUI** 三种界面下均可运行,按你使用的 profile 选择对应命令:
268
268
 
@@ -274,12 +274,12 @@ dsh plugin --profile dsh-tui add dsh-connect-workbuddy # TUI
274
274
  ## 更新
275
275
 
276
276
  > **市场里显示几就是几,那是快照;`npm view dsh-connect-workbuddy version` 与 [Releases](https://github.com/dingminhua/dsh-connect-workbuddy/releases) 才是准的。**
277
- > 2026-10-30 实测:社区市场索引(`dsh-plugin-catalog` 当天构建)里本插件仍只列到 **5.13.1**,npm `latest` 已是 **5.14.1**。滞后是**按包各自发生**的——同一份索引里 `@changfenhuang/dsh-genui` 0.15.0、`dsh-client-auto-continue` 0.17.0、`billion-context` 0.1.209 都是新的,所以「别人那个包有新版」不能证明「你这个包也该有」。
277
+ > 2026-10-30 15:00 实测:社区市场索引里本插件还只列到 **5.13.1**,而 npm `latest` 当时已是 **5.14.1**(现在是 5.15.1)。滞后是**按包各自发生**的——同一份索引里 `@changfenhuang/dsh-genui` 0.15.0、`dsh-client-auto-continue` 0.17.0、`billion-context` 0.1.209 都是新的,所以「别人那个包有新版」不能证明「你这个包也该有」。
278
278
 
279
279
  **手动更新(一条命令)**:
280
280
 
281
281
  ```sh
282
- dsh plugin --profile desktop add dsh-connect-workbuddy@5.14.1
282
+ dsh plugin --profile desktop add dsh-connect-workbuddy@5.15.1
283
283
  dsh plugin --profile desktop exec dsh-connect-workbuddy doctor # 第一行就是版本
284
284
  ```
285
285
 
@@ -300,7 +300,7 @@ dsh plugin --profile desktop exec dsh-connect-workbuddy doctor # 第一行就
300
300
 
301
301
  > 别让 AI「反复重试到成功」:等待期内重试只会拿到同一个拒绝,pnpm 没有一次性的绕过开关。
302
302
 
303
- **怎么确认真的升上去了**:`doctor` 的第一行(`WorkBuddy Connect 5.14.1 on …`),或 `status --json` 顶层的 `version`。**不要**找 `/workbuddy status`(本插件注册的斜杠命令是 `/codebuddy`,用于转发本机 CodeBuddy CLI),也**不要**在卡片「诊断」栏找版本号(那一栏只有区域 / 域名 / 服务账号 / 登录有效期 / 目录模型数 / 已启用数 / 账号池 / 最近一次失败八行,没有版本行)。装完**重启或重载**再判断。
303
+ **怎么确认真的升上去了**:`doctor` 的第一行(`WorkBuddy Connect 5.15.1 on …`),或 `status --json` 顶层的 `version`。**不要**找 `/workbuddy status`(本插件注册的斜杠命令是 `/codebuddy`,用于转发本机 CodeBuddy CLI),也**不要**在卡片「诊断」栏找版本号(那一栏只有区域 / 域名 / 服务账号 / 登录有效期 / 目录模型数 / 已启用数 / 账号池 / 最近一次失败八行,没有版本行)。装完**重启或重载**再判断。
304
304
 
305
305
  细节(市场索引与 pnpm 等待期分别怎么拦住你、两条绕过路径)见 [`docs/PINNED-UPGRADE-LAG.md`](docs/PINNED-UPGRADE-LAG.md),同一份正文也贴成了长期置顶 issue。
306
306
 
@@ -315,13 +315,15 @@ dsh plugin --profile desktop exec dsh-connect-workbuddy doctor # 第一行就
315
315
  | 进程心跳的时间戳来源 | PowerShell `Get-Process` 的 `StartTime`(POSIX 无 `ps -lstart` 等价物) | `ps -o lstart=` | `ps -o lstart=` |
316
316
  | 子进程的窗口 | **必须 `windowsHide`**:宿主本身没有控制台(GUI 进程),漏设会让每次探测都在屏幕上闪一个可见的黑框 | 不适用(该选项仅 Windows 生效) | 不适用 |
317
317
  | 设置写入的瞬时占用 | **会踩到**:profile 的配置文件 `cordis.patch.yml` 被杀毒软件 / OneDrive / 编辑器短暂锁定会拒绝 rename 覆盖,`@deepseek-ai/dsh-atomic-write` 的重试**只在 `win32` 生效** | 不踩:POSIX 的 rename 直接替换,同一段代码不进重试分支 | 同 macOS |
318
+ | 凭据库(vault)的文件权限 | **`mode: 0o600` 不生效**,权限由继承的 DACL 决定 → 写入前后用 `icacls` 显式加固(只允许 所有者 / SYSTEM / Administrators)。`doctor` 会回读并报告 `protected` / `exposed` / `unverified` | 由 `mode 0600` 生效 | 由 `mode 0600` 生效 |
318
319
  | CI 覆盖 | `windows-latest` 跑完整套件 | 开发者本机(macOS) | `ubuntu-latest` 跑完整套件 |
319
320
 
320
- **Windows 上需要知道的三个具体点**:
321
+ **Windows 上需要知道的四个具体点**:
321
322
 
322
323
  1. **账号改动可能保存失败**(profile 的配置文件 `cordis.patch.yml` 被占用)。插件会在写入后**回读校验**:确认落盘才显示「已清除」,失败则明确报错并保留原选择。遇到提示时关闭占用该文件的程序后重试。详见[已知限制](#已知限制)。
323
324
  2. **凭据路径已部分经真机验证**。候选列表按平台约定推导并有单元测试钉住(含 `LOCALAPPDATA` / `APPDATA` 缺省与空白串两种回落)。已在真实 Windows 11 上确认:`%LOCALAPPDATA%\CodeBuddyExtension\Data\Public\auth` 与 `%LOCALAPPDATA%\Programs\WorkBuddy\WorkBuddy.exe` **命中**,加密凭据的 `keyId` 与登记向量逐字一致。**其余候选仍未经真机逐项验证**——若你的凭据或 App 不在默认位置,用 `WORKBUDDY_AUTH_FILE` / `WORKBUDDY_APP_EXECUTABLE` 指定,并欢迎回报现场。
324
325
  3. **加密凭据(5.6.0 起)需要桌面 App 在场**,Windows 与 macOS 同样如此;App 装在自定义目录(如 `E:\WorkBuddy\WorkBuddy.exe`)时用 `WORKBUDDY_APP_EXECUTABLE` 指定。
326
+ 4. **凭据库里存的是明文 token**(issue #183)。插件的 vault 目录 `<DSH home>/workbuddy-vault/<region>/<accountId>.json` 保存解密后的 `accessToken` / `refreshToken`,**未加密**。Windows 上从 5.16.0 起会在写入前后用 `icacls` 把该目录限制为所有者 / SYSTEM / Administrators 可读,并用 `doctor` 的 `Credential vault ACL` 一行回读确认;但**权限收紧不等于加密**——管理员、SYSTEM 服务,或已取得你用户令牌的攻击者仍可读取。若你需要磁盘加密,请把 DSH home 放在 BitLocker / FileVault 卷上。POSIX 平台依靠 `mode 0600`。
325
327
 
326
328
  ### 在服务器上使用:搬运已登录的凭据
327
329
 
package/docs/WINDOWS.md CHANGED
@@ -14,9 +14,9 @@ Windows 在本项目里不是「顺带能跑」的平台,而是**有专属分
14
14
  >
15
15
  > 因此**「在 Mac 上试过了,没问题」不足以判定 Windows 行为**。这类结论必须来自:CI 的 windows-latest、Windows 用户回报的现场、或真机取证的向量。
16
16
 
17
- ## 1. 五个 Windows 专属分支
17
+ ## 1. 七个 Windows 专属分支
18
18
 
19
- 改动这五处中的任何一处,都要考虑 Windows。
19
+ 改动这七处中的任何一处,都要考虑 Windows。
20
20
 
21
21
  | # | 位置 | Windows 行为 | 若改错会怎样 |
22
22
  | --- | --- | --- | --- |
@@ -26,6 +26,20 @@ Windows 在本项目里不是「顺带能跑」的平台,而是**有专属分
26
26
  | 4 | 设置写入回读校验(`src/client/account-selection.ts`) | 写入后**回读校验**:profile 的 `cordis.patch.yml` 被占用会让 rename 覆盖失败,而 `set()` 的 promise 仍 resolve | 用户看到假确认(显示「已清除」但没落盘)→ issue #11 |
27
27
  | 5 | 子进程启动选项:`src/host-heartbeat.ts` `PROCESS_PROBE_OPTIONS` 与 `src/at-rest.ts` `fetchAtRestKeyPayload()` | 一律带 `windowsHide: true`(POSIX 忽略该选项) | **宿主本身没有控制台**(Electron GUI 进程,实测 `MainWindowHandle = 0`),Windows 会给子进程**新建一个可见的控制台窗口** → 每次进程存活判定都在屏幕上闪一次黑框 |
28
28
  | 6 | `src/at-rest.ts` `readAtRestKey()` → `findWorkbuddyAppExecutableWithSource()` | 字段密钥**不带参数**调用时才走注册表回退(`reg query` × 3 个卸载 hive);这个探测曾被**只按成功结果**缓存 | 桌面端不在候选目录、凭据又是加密的机器上,`scanAll()` 会**逐文件**重跑整套探测。issue #77 实测:19.1 s 的请求里 15.3 s 花在 `spawnSync`,约 **135 个 `reg query` 子进程**(`findWorkbuddyAppExecutable()` 被调用 45 次)→ 打开页面白等 60 s。POSIX 上这一支根本不跑,**在 macOS 开发机上永远看不到** |
29
+ | 7 | `src/windows-acl.ts` `protectCredentialDirectory()`(issue #183) | 凭据库的访问权限**不能靠 `mode: 0o600`**:Windows 上 `fs.writeFile` / `fs.rename` 的 `mode` 被接受但不生效,权限完全由继承的 DACL 决定。改为在**写入之前**对 vault 根目录发一次 `icacls`(`/inheritance:r` + `*S-1-3-4`、`*S-1-5-18`、`*S-1-5-32-544`,含 `(OI)(CI)`),靠 Windows 的继承传播覆盖整棵子树 | vault 里是**明文** `accessToken` / `refreshToken`。未加固时实测该文件被 `<机器>\CodexSandboxUsers`(DSH 自己沙箱账户)以 `Modify` 读取,且本机 `~/.dsh` 还额外带着 `Everyone: FullControl` → 本机任何低权限进程都能取到可用 JWT |
30
+
31
+ **第 7 条为什么单列**:它是本项目里**第一个「静默失效的防御」**——`mode: 0o600` 看起来像已做了权限限制,代码注释、目录名(`vault`)和既有文档都暗示这一点,而 Windows 上它**什么都不做**。这类缺陷的危险不在于写错,而在于**看起来已经写对了**:没有报错、没有日志、`doctor` 也一切正常。真机取证(2026-10-27,Windows 11)用 `Get-Acl` 读到的事实与代码意图相反,这才把它暴露出来。
32
+
33
+ **加固的四条实测结论**(A 档,真机 `icacls` / `Get-Acl`):
34
+
35
+ 1. **`/T` 必须禁用**。`icacls <dir> /T /inheritance:r /grant:r "*S-1-3-4:(OI)(CI)(F)"` 会让它走过的**每个文件得到空 DACL**(实测 `ACEcount=0`)——比原来更糟,因为谁都读不了,包括插件自己。正确形态是目录用 `(OI)(CI)`、文件用裸 `(F)`;本实现的写入路径只加固目录,靠传播覆盖文件。
36
+ 2. **一次 `icacls` 覆盖整棵树,不需要遍历**。实测:对一个同时含 `cn/`、`global/` 子目录与文件、且全部带 `Everyone`/`CodexSandboxUsers` 的根目录只跑一次 `icacls`,事后根、两个子目录、子目录里的文件全部变成恰好三条 ACE(`weak=0`)。因此实现里没有按目录遍历,也没有按文件逐个加固。
37
+ 3. **加固必须在写入之前**。`writeFileAtomic` 是「写临时 inode → rename 覆盖」,替换出来的是**新 inode**;写在之后加固既留下 pre-rename 窗口,也会被下一次替换抹掉。
38
+ 4. **要加固 vault 根目录,不只是 region 目录**。`Everyone: FullControl` 是从 `~/.dsh` 继承到 `…/workbuddy-vault` 上的;只加固 `<vault>/<region>` 时根目录仍可写,任何进程都能替换掉 region 目录本身。`writeVaultEntry()` 传的是 `dirname(dir)`。
39
+
40
+ **成本是这里的一等约束**(A 档实测):`icacls` 是子进程,静止态 19–52 ms,**并行负载下最高 1242 ms**。因此实现遵守两条:一个目录**一次**调用;同一路径**正在进行的**加固被 join 而不重复发起。这不是提前优化——最初「每次写入后再加固一次文件」的版本把 `tests/issue12-region-hiding.spec.ts` 的 1 s 轮询预算顶穿,才定位到成本形态并改成现在这样。**改动这里的调用次数或等待策略时,请以该用例为成本哨兵。**
41
+
42
+ **没有做的事**(诚实登记):issue #183 的建议 1(DPAPI / `safeStorage` 加密落盘)**未实现**。当前落盘的仍是明文,只是权限收紧了;管理员、SYSTEM 服务,或已经拿到该用户令牌的攻击者仍可读取。要做到那一步需要改变 vault 的**磁盘格式**并做迁移,属独立改动。README 明写「此文件含明文 token」。
29
43
 
30
44
  **第 6 条为什么单列**:这是**第 5 条之外的第二个**「只在 Windows 才付费」形态——不是正确性错误,而是**成本随文件数 × 读取次数放大**的性能缺陷,且两个乘数都在 Windows 特有的分支里。`tests/issue77-at-rest-key-cache.spec.ts` 用 `process.platform` 影子 + `execFileSync` 打桩,在**任何宿主**上都能数出这三件事(失败结果被记住、一次探测 3 次 `reg`、5 个加密文件的一轮读取仍是 3 次)。
31
45
 
package/lib/bin.js CHANGED
@@ -1,6 +1,7 @@
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-891AaZGW.js";
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";
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";
6
7
  //#region src/bin.ts
@@ -30,8 +31,12 @@ import { fileURLToPath } from "node:url";
30
31
  * 4 → 5: added `rosterSeen`, so a first-sighting history that is corrupt or in
31
32
  * a version this build cannot read is REPORTED rather than silently answered as
32
33
  * "no new models".
34
+ *
35
+ * 5 → 6: added `credentialAcl` (issue #183). A store that could only ever ask
36
+ * for `mode: 0o600` looked identical to one that enforced it; the new block
37
+ * answers what the folder permissions actually ARE on this machine.
33
38
  */
34
- const JSON_SCHEMA_VERSION = 5;
39
+ const JSON_SCHEMA_VERSION = 6;
35
40
  /** Both regions, in reporting order. */
36
41
  const REGIONS = ["cn", "global"];
37
42
  /** Region labels for human output. */
@@ -141,6 +146,32 @@ async function doctor(jsonOutput) {
141
146
  region,
142
147
  summary: await describeRosterSeen(region)
143
148
  })));
149
+ /**
150
+ * Per-region folder permissions of the plaintext credential vault (issue #183).
151
+ *
152
+ * Computed BEFORE the report object because both the report AND its `hints`
153
+ * read it, and a hint that reached back into the half-built report would be a
154
+ * use-before-declaration. It also runs the repair, so `doctor` fixes an
155
+ * exposed directory rather than only describing it.
156
+ */
157
+ const credentialAcl = await Promise.all(REGIONS.map(async (region) => {
158
+ const directory = workbuddyVaultDir(region);
159
+ const rootOutcome = await protectCredentialDirectory(dirname(directory));
160
+ const outcome = await protectCredentialDirectory(directory);
161
+ const acl = await inspectCredentialDirectory(directory);
162
+ return [region, {
163
+ directory: acl.directory,
164
+ state: acl.state,
165
+ ...acl.weak === void 0 ? {} : { unexpected: acl.weak },
166
+ ...acl.reason === void 0 ? {} : { reason: acl.reason },
167
+ ...outcome.state === "failed" ? { protectError: outcome.reason } : rootOutcome.state === "failed" ? { protectError: rootOutcome.reason } : {}
168
+ }];
169
+ }));
170
+ /** Indexed by region so the human output cannot silently skip a missing one. */
171
+ const credentialAclByRegion = {
172
+ cn: credentialAcl.find(([region]) => region === "cn")[1],
173
+ global: credentialAcl.find(([region]) => region === "global")[1]
174
+ };
144
175
  const report = {
145
176
  schemaVersion: JSON_SCHEMA_VERSION,
146
177
  package: "dsh-connect-workbuddy",
@@ -185,6 +216,23 @@ async function doctor(jsonOutput) {
185
216
  global: workbuddyOwnAuthPath("global"),
186
217
  legacy: legacyWorkbuddyOwnAuthPath()
187
218
  },
219
+ /**
220
+ * Whether the plaintext credential vault is actually restricted (issue #183).
221
+ *
222
+ * The `mode: 0o600` the writer passes is a POSIX concept; on Windows the
223
+ * DACL decides. Reporting it here is the difference between "we asked for
224
+ * 0600" and "the token file is readable only by its owner" — the reporter
225
+ * found out it was the former while believing the latter. Per region,
226
+ * because the two directories are hardened independently.
227
+ *
228
+ * On POSIX every entry reads `not-windows` and no hint is emitted: `mode`
229
+ * carries the same intent there, and warning every macOS user about a
230
+ * Windows-only measure would be noise.
231
+ */
232
+ credentialAcl: {
233
+ vaultDirectory: join(resolveDshHome(), WORKBUDDY_VAULT_DIRNAME),
234
+ regions: Object.fromEntries(credentialAcl)
235
+ },
188
236
  hostHeartbeat: {
189
237
  path: workbuddyHostHeartbeatPath(),
190
238
  present: heartbeat !== void 0,
@@ -217,6 +265,10 @@ async function doctor(jsonOutput) {
217
265
  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
266
  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
267
  return [];
268
+ }),
269
+ ...credentialAcl.flatMap(([region, entry]) => {
270
+ if (entry.state !== "exposed") return [];
271
+ 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
272
  })
221
273
  ]
222
274
  };
@@ -230,6 +282,11 @@ async function doctor(jsonOutput) {
230
282
  `Host bundle: ${hostAlive ? `running (pid ${heartbeat.pid})` : heartbeat !== void 0 ? "stale heartbeat (process exited)" : "not started"}`,
231
283
  ...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
284
  `Static fallback models: CN ${report.fallbackModels.cn}, Global ${report.fallbackModels.global}`,
285
+ ...REGIONS.map((region) => {
286
+ const entry = credentialAclByRegion[region];
287
+ 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";
288
+ return `Credential vault ACL (${REGION_LABELS[region]}): ${entry.state} — ${detail} (${entry.directory})`;
289
+ }),
233
290
  ...REGIONS.map((region) => {
234
291
  const summary = report.rosterSeen[region];
235
292
  if (summary === void 0) return `New-model history (${REGION_LABELS[region]}): not available`;
package/lib/client.js CHANGED
@@ -9583,8 +9583,20 @@ window.__ModuleLoader__.load({
9583
9583
  const value = usage.showCreditsInMainUi;
9584
9584
  return typeof value === "boolean" ? value : void 0;
9585
9585
  }
9586
+ /**
9587
+ * A same-day instant, as the READER's locale writes it.
9588
+ *
9589
+ * The locale is `undefined` — the reader's, not a fixed one — so an English UI
9590
+ * shows `11:59 PM` rather than the Chinese convention's `23:59`. It used to
9591
+ * hardcode `'zh-CN'`, which meant the English interface printed a Chinese-style
9592
+ * time. Ported from dsh-connect-trae (issue #71).
9593
+ *
9594
+ * Only for instants that are the same day as the reader: a bare clock time on
9595
+ * a timestamp from another day is a different question (and a different
9596
+ * design), which is why this is not reused for anything but "now".
9597
+ */
9586
9598
  function formatClock(value) {
9587
- return new Date(value).toLocaleTimeString("zh-CN", {
9599
+ return new Date(value).toLocaleTimeString(void 0, {
9588
9600
  hour: "2-digit",
9589
9601
  minute: "2-digit"
9590
9602
  });
@@ -962,6 +962,277 @@ function clearAtRestKeyCache() {
962
962
  cachedAppExecutable = void 0;
963
963
  }
964
964
  //#endregion
965
+ //#region src/windows-acl.ts
966
+ /**
967
+ * Windows ACL hardening for the plugin's credential vault (issue #183).
968
+ *
969
+ * THE REPORT. `<dsh home>/workbuddy-vault/<region>/<accountId>.json` holds the
970
+ * decrypted WorkBuddy `accessToken` / `refreshToken` as plaintext JSON, and the
971
+ * writer asked for `mode: 0o600`. On POSIX that is the whole story. On Windows
972
+ * `mode` is accepted and effectively ignored: a file's permissions come from the
973
+ * DACL it inherits from its parent directory, and nothing in `fs.writeFile` or
974
+ * `fs.rename` consults the mode argument there. The reporter measured the
975
+ * result with `Get-Acl`: the vault files came out readable by
976
+ * `<machine>\CodexSandboxUsers` — the account DSH's own sandbox runs as — so any
977
+ * sandboxed process, sibling plugin or script on that machine could read a
978
+ * usable JWT straight off disk.
979
+ *
980
+ * WHY HARDEN THE DIRECTORY, NOT JUST THE FILE. Two reasons, both measured:
981
+ *
982
+ * 1. The writer commits with an atomic replace (`writeFileAtomic`): a fresh
983
+ * `<name>.<hex>.tmp` inode is created and renamed over the target. A
984
+ * per-file ACL applied AFTER the rename leaves a window in which the new
985
+ * inode carries whatever it inherited, and a crash mid-sequence leaves a
986
+ * file that was never hardened. Children of a hardened directory inherit
987
+ * the hardened ACEs at creation, so the replacement is born correct.
988
+ * 2. Windows RE-PROPAGATES inheritable ACEs down an existing tree, so
989
+ * hardening the directory also repairs the files already sitting in it.
990
+ * Verified on a real Windows 11 host: a file carrying
991
+ * `Everyone: FullControl` inherited from `~/.dsh` came out with exactly the
992
+ * three intended ACEs after only the directory was hardened.
993
+ *
994
+ * WHY NOT `icacls /T`. Measured on the same host: `/T` combined with an
995
+ * `(OI)(CI)` grant spec blanks the DACL of the FILES it walks — they end up with
996
+ * zero ACEs, which reads as "nobody may read this" and would break the plugin's
997
+ * own reads. The two-pass form (directories with `(OI)(CI)`, then files with a
998
+ * plain `(F)` grant) produces the correct result, so `/T` is deliberately not
999
+ * used anywhere here.
1000
+ *
1001
+ * WHY WINDOWS SIDS AND NOT NAMES. `icacls` prints and accepts localized account
1002
+ * names, and this project's hosts are frequently zh-CN (`Everyone` shows up as
1003
+ * `Everyone` but `BUILTIN\Administrators` does not). The `*S-1-5-…` form makes
1004
+ * every argument locale-independent, so the same argv works on any UI language.
1005
+ *
1006
+ * WHY `OWNER RIGHTS` (S-1-3-4) RATHER THAN THE CURRENT USER. Resolving the
1007
+ * current user's SID costs a child process (`whoami`) on every hardening round,
1008
+ * and the answer is already implied: the process that creates a file becomes its
1009
+ * owner, so `OWNER RIGHTS` grants exactly the account that will read it back.
1010
+ * `SYSTEM` and `Administrators` are kept so backup/AV/service software that
1011
+ * legitimately expects to reach user files is not locked out — removing them
1012
+ * would make the vault unmanageable on a machine where the user's own session is
1013
+ * not the one repairing it.
1014
+ *
1015
+ * WHAT THIS IS AND IS NOT. This is the issue's suggestion #2 (explicit ACLs
1016
+ * after writing), which it calls "the smallest change". It is NOT DPAPI
1017
+ * encryption (suggestion #1): the bytes on disk remain plaintext, so an
1018
+ * administrator, a SYSTEM service, or an attacker who has already achieved the
1019
+ * user's own token can still read them. Closing that gap requires encrypting the
1020
+ * document with a key bound to the user profile, which is a format change to the
1021
+ * vault and cannot be done without a migration; it is tracked separately. The
1022
+ * README says plainly that the file holds plaintext tokens.
1023
+ *
1024
+ * FAILURE IS NOT FATAL. A credential write is on the sign-in path: refusing to
1025
+ * persist a credential because the ACL could not be applied would turn a
1026
+ * defence-in-depth measure into an outage. Every function here is therefore
1027
+ * best-effort and reports its outcome instead of throwing, and `doctor` surfaces
1028
+ * that outcome so a machine where hardening silently failed is visible rather
1029
+ * than assumed safe.
1030
+ *
1031
+ * @module dsh-connect-workbuddy/windows-acl
1032
+ */
1033
+ /**
1034
+ * Well-known SID for "the owner of this object".
1035
+ *
1036
+ * Deliberately a SID rather than an account name: it needs no lookup, it works
1037
+ * on every UI language, and `icacls` accepts it in the `*S-…` form.
1038
+ */
1039
+ const OWNER_RIGHTS_SID = "S-1-3-4";
1040
+ /** Well-known SID for `NT AUTHORITY\SYSTEM`. */
1041
+ const SYSTEM_SID = "S-1-5-18";
1042
+ /** Well-known SID for `BUILTIN\Administrators`. */
1043
+ const ADMINISTRATORS_SID = "S-1-5-32-544";
1044
+ /**
1045
+ * Principals allowed to keep access, as SIDs.
1046
+ *
1047
+ * Used by {@link inspectCredentialDirectory} to tell "hardened" from "somebody
1048
+ * widened it again"; keeping the list beside the grant specs is what stops the
1049
+ * two from drifting.
1050
+ */
1051
+ const ALLOWED_SIDS = /* @__PURE__ */ new Set([
1052
+ OWNER_RIGHTS_SID,
1053
+ SYSTEM_SID,
1054
+ ADMINISTRATORS_SID
1055
+ ]);
1056
+ /**
1057
+ * Grant specs for a DIRECTORY: `(OI)` object-inherit and `(CI)` container-inherit
1058
+ * make the ACE apply to files and subdirectories created later, which is the
1059
+ * whole mechanism this module relies on.
1060
+ */
1061
+ const DIRECTORY_GRANTS = [
1062
+ `*${OWNER_RIGHTS_SID}:(OI)(CI)(F)`,
1063
+ `*${SYSTEM_SID}:(OI)(CI)(F)`,
1064
+ `*${ADMINISTRATORS_SID}:(OI)(CI)(F)`
1065
+ ];
1066
+ /** How long one `icacls` (or PowerShell) child may take before it is abandoned. */
1067
+ const ACL_COMMAND_TIMEOUT_MS = 1e4;
1068
+ /** Paths already hardened by THIS process, so repeat writes cost nothing. */
1069
+ const protectedDirectories = /* @__PURE__ */ new Set();
1070
+ /** Hardening attempts in flight, keyed by path: a burst joins one child. */
1071
+ const inflightProtection = /* @__PURE__ */ new Map();
1072
+ /** Whether this process is running on Windows; a seam for tests. */
1073
+ function isWindows() {
1074
+ return process.platform === "win32";
1075
+ }
1076
+ /**
1077
+ * Run one child process, resolving to its stdout.
1078
+ *
1079
+ * `windowsHide` is mandatory for the same reason recorded in `at-rest.ts` and
1080
+ * `docs/WINDOWS.md` §1-5: the DSH Desktop host is an Electron GUI process with
1081
+ * no console, so spawning a console program without it flashes a visible black
1082
+ * window. `icacls` here runs on the credential-write path, which a user can
1083
+ * trigger repeatedly from the card — an un-hidden spawn would blink at them on
1084
+ * every account switch.
1085
+ *
1086
+ * Sets `windowsVerbatimArguments: false` implicitly (the default) so each argv
1087
+ * element is quoted by Node rather than concatenated: the grant specs contain
1088
+ * parentheses, which a raw command-line join would hand to `cmd` for parsing.
1089
+ * This is why the arguments go through `execFile` as an ARRAY and never as a
1090
+ * single shell string.
1091
+ */
1092
+ function runCommand(file, args) {
1093
+ return new Promise((resolve, reject) => {
1094
+ execFile(file, [...args], {
1095
+ encoding: "utf8",
1096
+ windowsHide: true,
1097
+ timeout: ACL_COMMAND_TIMEOUT_MS
1098
+ }, (error, stdout) => {
1099
+ if (error !== null) {
1100
+ reject(/* @__PURE__ */ new Error(`${file} exited ${String(error.code ?? error.message)}`));
1101
+ return;
1102
+ }
1103
+ resolve(stdout);
1104
+ });
1105
+ });
1106
+ }
1107
+ /**
1108
+ * Apply one ownership set to `path` with `icacls`.
1109
+ *
1110
+ * `/inheritance:r` drops the inherited ACEs (that is what removes the
1111
+ * `Everyone: FullControl` arriving from `~/.dsh`) and `/grant:r` replaces the
1112
+ * ACE for each named principal rather than adding a duplicate, so the call is
1113
+ * idempotent — measured: running it twice on the same file leaves the same three
1114
+ * ACEs.
1115
+ */
1116
+ async function applyAcl(path, grants) {
1117
+ const args = [path, "/inheritance:r"];
1118
+ for (const grant of grants) args.push("/grant:r", grant);
1119
+ await runCommand("icacls", args);
1120
+ }
1121
+ /**
1122
+ * Harden one credential directory tree so that the files inside are readable
1123
+ * only by their owner, SYSTEM and Administrators.
1124
+ *
1125
+ * ONE `icacls` CALL, NOT A WALK. Measured on a real Windows 11 host: hardening
1126
+ * the parent directory makes Windows RE-PROPAGATE the new inheritable ACEs down
1127
+ * the tree, repairing existing subdirectories AND existing files in the same
1128
+ * step — a file carrying `Everyone: FullControl` inherited from `~/.dsh` came out
1129
+ * with exactly the three intended ACEs (`weak=0`) after only its parent was
1130
+ * hardened. Walking the children would spawn one child process per directory to
1131
+ * re-derive a guarantee this single call already delivers.
1132
+ *
1133
+ * WHY THAT COST MATTERS HERE. This runs on the credential-write path, which the
1134
+ * card can trigger per account switch. `icacls` measured 19–52 ms at rest and
1135
+ * **up to 1242 ms under parallel load** — enough to blow the 1 s polling budget
1136
+ * of `tests/issue12-region-hiding.spec.ts` when the whole suite ran
1137
+ * concurrently. The shape below is therefore deliberate on two axes:
1138
+ *
1139
+ * - CALLS: one, never a walk.
1140
+ * - CONCURRENCY: an attempt already in flight for the same path is JOINED
1141
+ * rather than repeated, so a burst of writes queues one child for one
1142
+ * directory instead of one per write.
1143
+ *
1144
+ * Staying ON the write path is not negotiable: the atomic commit creates a fresh
1145
+ * temp inode and renames it over the target, so a file-level pass AFTERwards
1146
+ * would leave the pre-rename window open and would be undone by the next
1147
+ * replace. Hardening before the write is what makes the replacement inode
1148
+ * inherit the restricted ACEs.
1149
+ *
1150
+ * Memoized per process on SUCCESS only: a failed attempt must be retried by the
1151
+ * next write, or one transient lock on the directory would leave the machine
1152
+ * unhardened for the rest of the session.
1153
+ */
1154
+ async function protectCredentialDirectory(directory) {
1155
+ if (!isWindows()) return { state: "not-windows" };
1156
+ if (protectedDirectories.has(directory)) return { state: "protected" };
1157
+ const pending = inflightProtection.get(directory);
1158
+ if (pending !== void 0) return pending;
1159
+ const attempt = hardenDirectory(directory);
1160
+ inflightProtection.set(directory, attempt);
1161
+ try {
1162
+ return await attempt;
1163
+ } finally {
1164
+ inflightProtection.delete(directory);
1165
+ }
1166
+ }
1167
+ /** The work behind {@link protectCredentialDirectory}: one `icacls` call. */
1168
+ async function hardenDirectory(directory) {
1169
+ try {
1170
+ await mkdir(directory, { recursive: true });
1171
+ await applyAcl(directory, DIRECTORY_GRANTS);
1172
+ protectedDirectories.add(directory);
1173
+ return { state: "protected" };
1174
+ } catch (error) {
1175
+ return {
1176
+ state: "failed",
1177
+ reason: error instanceof Error ? error.message : String(error)
1178
+ };
1179
+ }
1180
+ }
1181
+ /**
1182
+ * Read back the ACL of one credential directory as SIDs, for diagnostics.
1183
+ *
1184
+ * PowerShell rather than `icacls` because the answer has to be COMPARABLE:
1185
+ * `icacls` prints localized account names, so testing "is `Everyone` absent"
1186
+ * against its output would silently pass on a zh-CN host where the name is
1187
+ * spelled differently. `Get-Acl` + `SecurityIdentifier.Value` yields the
1188
+ * language-independent form.
1189
+ *
1190
+ * Read-only and token-free: it never opens the JSON, only the ACL. A failure to
1191
+ * read is reported as `unverified` rather than being folded into `exposed` — the
1192
+ * two need different user actions, and claiming exposure that was not measured
1193
+ * would be its own kind of lie.
1194
+ */
1195
+ async function inspectCredentialDirectory(directory) {
1196
+ if (!isWindows()) return {
1197
+ directory,
1198
+ state: "not-windows"
1199
+ };
1200
+ /**
1201
+ * Deliberately a single quoted expression with no interpolation of `directory`
1202
+ * beyond the literal path: `-LiteralPath` keeps a path containing `[` or `$`
1203
+ * from being treated as a wildcard or a subexpression.
1204
+ */
1205
+ const script = [`$a = Get-Acl -LiteralPath '${directory.replace(/'/gu, "''")}'`, "$a.Access | ForEach-Object { $_.IdentityReference.Translate([System.Security.Principal.SecurityIdentifier]).Value }"].join("; ");
1206
+ let stdout;
1207
+ try {
1208
+ stdout = await runCommand("powershell", [
1209
+ "-NoProfile",
1210
+ "-NonInteractive",
1211
+ "-Command",
1212
+ script
1213
+ ]);
1214
+ } catch (error) {
1215
+ return {
1216
+ directory,
1217
+ state: "unverified",
1218
+ reason: error instanceof Error ? error.message : String(error)
1219
+ };
1220
+ }
1221
+ const entries = stdout.split(/\r?\n/u).map((line) => line.trim()).filter((line) => line !== "" && /^S-1-/u.test(line));
1222
+ if (entries.length === 0) return {
1223
+ directory,
1224
+ state: "unverified",
1225
+ reason: "Get-Acl returned no principals"
1226
+ };
1227
+ const weak = entries.filter((sid) => !ALLOWED_SIDS.has(sid));
1228
+ return {
1229
+ directory,
1230
+ state: weak.length === 0 ? "protected" : "exposed",
1231
+ entries,
1232
+ weak
1233
+ };
1234
+ }
1235
+ //#endregion
965
1236
  //#region src/native-modality.ts
966
1237
  /**
967
1238
  * Reviewed vendor classifications, keyed by EXACT model id (never a prefix).
@@ -6277,9 +6548,42 @@ async function readVaultEntries(dir) {
6277
6548
  }
6278
6549
  return entries;
6279
6550
  }
6280
- /** Write one vault entry atomically under the file lock. */
6551
+ /**
6552
+ * Write one vault entry atomically under the file lock.
6553
+ *
6554
+ * The directory is hardened BEFORE the file is created (issue #183). Order
6555
+ * matters: `writeFileAtomic` commits by creating a temp inode and renaming it
6556
+ * over the target, so an ACL applied to the file afterwards would leave the
6557
+ * pre-rename window open, and a crash between the two would leave a plaintext
6558
+ * token in a file nobody hardened. Hardening the directory first means the
6559
+ * replacement inode inherits the restricted ACEs at creation.
6560
+ *
6561
+ * The hardening is best-effort on purpose: it is defence in depth, and refusing
6562
+ * to persist a credential because an ACL call failed would turn it into an
6563
+ * outage. `doctor` reports the outcome so a machine where it failed is visible.
6564
+ * On POSIX this call is a no-op, and `mode` below carries the same intent.
6565
+ */
6281
6566
  async function writeVaultEntry(dir, accountId, credential, refreshedFrom) {
6282
6567
  const path = join(dir, `${accountId}.json`);
6568
+ /**
6569
+ * Harden the vault ROOT, which also hardens this region's directory and sweeps
6570
+ * the files already inside (issue #183).
6571
+ *
6572
+ * The root, not just `dir`: `dir` is `<vault>/<region>`, and the root is what
6573
+ * carries the inherited `Everyone: FullControl` from `~/.dsh`. Leaving the
6574
+ * root widened would let any local process delete or replace the region
6575
+ * directory itself, which defeats the file-level restriction inside it.
6576
+ *
6577
+ * BEFORE the write, so the commit's temp inode — and the file it is renamed
6578
+ * over — inherit the hardened ACEs instead of the widened ones. A file-level
6579
+ * pass AFTER the write would leave the pre-rename window open and would be
6580
+ * lost by the next atomic replace, which creates a fresh inode each time.
6581
+ *
6582
+ * Memoized per directory per process, so the second account costs nothing: see
6583
+ * the cost model in `src/windows-acl.ts` for why the per-write budget matters
6584
+ * here.
6585
+ */
6586
+ await protectCredentialDirectory(dirname(dir));
6283
6587
  await withFileLock(path, async () => {
6284
6588
  await writeFileAtomic(path, `${JSON.stringify(vaultDocument(credential, accountId, refreshedFrom), null, 2)}\n`, {
6285
6589
  mode: 384,
@@ -7932,7 +8236,7 @@ function describeRosterSeenPayload(raw) {
7932
8236
  //#endregion
7933
8237
  //#region src/version.ts
7934
8238
  /** The npm package version this build was produced from. */
7935
- const WORKBUDDY_CONNECT_VERSION = "5.15.1";
8239
+ const WORKBUDDY_CONNECT_VERSION = "5.16.0";
7936
8240
  //#endregion
7937
8241
  //#region src/host-heartbeat.ts
7938
8242
  /**
@@ -8143,4 +8447,4 @@ async function clearHostHeartbeat() {
8143
8447
  await rm(workbuddyHostHeartbeatPath(), { force: true });
8144
8448
  }
8145
8449
  //#endregion
8146
- export { parseCreditMultiplier as $, resolveDshHome as $t, isEncryptedCredentialError as A, pickMediaModel as At, WorkBuddyCredentialRejectedError as B, deriveAtRestKey as Bt, WorkBuddyCredentialStore as C, IMAGE_TAG_TEXT_TO_IMAGE as Ct, defaultDesktopAuthDirs as D, imageMimeForPath as Dt, defaultDesktopAuthCandidates as E, imageDataUrl as Et, workbuddyAccountId as F, NATIVE_MODALITY_BY_MODEL_ID as Ft, forceNeutralHead as G, isEncryptedFieldWrapper as Gt, channelGateMemberOf as H, fetchAtRestKeyPayload as Ht, workbuddyOwnAuthPath as I, imageDefaultFor as It, isCredentialRejectedError as J, macosNestedAppBundles as Jt, isContextTooLongBody as K, isWorkbuddyBundle as Kt, CONTEXT_OVERFLOW_MARKER as L, nativeModalityOf as Lt, legacyWorkbuddyOwnAuthPath as M, parseQueueAnswer as Mt, parseWorkBuddyAuth as N, queueNoticeText as Nt, defaultDesktopAuthPath as O, isBareBase64Image as Ot, preferredAccountName as P, pruneTempDir as Pt, openingEvidenceOfBody as Q, hostPeersInfo as Qt, CREDENTIAL_REJECTED_CODE as R, WORKBUDDY_APP_EXECUTABLE_ENV as Rt, WORKBUDDY_AUTH_FILE_ENV as S, IMAGE_TAG_IMAGE_TO_IMAGE as St, authFileName as T, WorkBuddyImageError as Tt, classifyUpstreamError as U, findWorkbuddyAppExecutable as Ut, WorkBuddyUpstreamClient as V, deriveAtRestKeyId as Vt, declaredTools as W, findWorkbuddyAppExecutableWithSource as Wt, knownRegionOf as X, readAtRestKey as Xt, isFirstMessageGateBody as Y, openEncryptedField as Yt, modelIdOfBody as Z, workbuddyAppExecutableCandidates as Zt, deriveCatalog as _, WorkBuddyVideoError as _t, readHostHeartbeat as a, requestEvidenceOf as at, ENCRYPTED_CREDENTIAL_CODE as b, resolveVideoParams as bt, WORKBUDDY_CONNECT_VERSION as c, REFUSES_OFF_MODEL_IDS as ct, rosterSeenPath as d, offDefaultFor as dt, withFileLock as en, parseReasoning as et, piAiRuntimeInfo as f, offRefused as ft, applyContextBudgets as g, VIDEO_TAG_TEXT_TO_VIDEO as gt, WorkBuddyCatalog as h, VIDEO_TAG_IMAGE_TO_VIDEO as ht, processStartTimeMs as i, regionOf as it, isVaultAccountId as j, sniffImageMime as jt, hasEncryptedCredentialFields as k, parseImageDataUrl as kt, createFileRosterSeenStore as l, defaultOffModelIds as lt, FALLBACK_WORKBUDDY_MODELS_GLOBAL as m, withEffectiveOff as mt, clearHostHeartbeat as n, perturbChannelFingerprints as nt, workbuddyHostHeartbeatPath as o, rewriteSessionTitleModel as ot, FALLBACK_WORKBUDDY_MODELS as p, recordRefusal as pt, isConversationIdGateBody as q, macosBundleExecutable as qt, isHeartbeatProcessAlive as r, prepareChatBody as rt, writeHostHeartbeat as s, attachBusyLevels as st, WORKBUDDY_HOST_HEARTBEAT_FILENAME as t, writeFileAtomic as tn, parseUpstreamModel as tt, describeRosterSeenPayload as u, lastRefusalFor as ut, fallbackModelsFor as v, parseSupportedSecondsRange as vt, WorkBuddyEncryptedCredentialError as w, MAX_INPUT_IMAGE_BYTES as wt, WORKBUDDY_AUTH_FILENAME as x, DEFAULT_IMAGE_SIZE as xt, withoutRouters as y, pickVideoModel as yt, WORKBUDDY_FALLBACK_SYSTEM_PROMPT as z, clearAtRestKeyCache as zt };
8450
+ export { modelIdOfBody as $, openEncryptedField as $t, hasEncryptedCredentialFields as A, isBareBase64Image as At, CREDENTIAL_REJECTED_CODE as B, inspectCredentialDirectory as Bt, WORKBUDDY_VAULT_DIRNAME as C, DEFAULT_IMAGE_SIZE as Ct, defaultDesktopAuthCandidates as D, WorkBuddyImageError as Dt, authFileName as E, MAX_INPUT_IMAGE_BYTES as Et, preferredAccountName as F, queueNoticeText as Ft, classifyUpstreamError as G, deriveAtRestKeyId as Gt, WorkBuddyCredentialRejectedError as H, WORKBUDDY_APP_EXECUTABLE_ENV as Ht, workbuddyAccountId as I, pruneTempDir as It, isContextTooLongBody as J, findWorkbuddyAppExecutableWithSource as Jt, declaredTools as K, fetchAtRestKeyPayload as Kt, workbuddyOwnAuthPath as L, NATIVE_MODALITY_BY_MODEL_ID as Lt, isVaultAccountId as M, pickMediaModel as Mt, legacyWorkbuddyOwnAuthPath as N, sniffImageMime as Nt, defaultDesktopAuthDirs as O, imageDataUrl as Ot, parseWorkBuddyAuth as P, parseQueueAnswer as Pt, knownRegionOf as Q, macosNestedAppBundles as Qt, workbuddyVaultDir as R, imageDefaultFor as Rt, WORKBUDDY_AUTH_FILE_ENV as S, resolveVideoParams as St, WorkBuddyEncryptedCredentialError as T, IMAGE_TAG_TEXT_TO_IMAGE as Tt, WorkBuddyUpstreamClient as U, clearAtRestKeyCache as Ut, WORKBUDDY_FALLBACK_SYSTEM_PROMPT as V, protectCredentialDirectory as Vt, channelGateMemberOf as W, deriveAtRestKey as Wt, isCredentialRejectedError as X, isWorkbuddyBundle as Xt, isConversationIdGateBody as Y, isEncryptedFieldWrapper as Yt, isFirstMessageGateBody as Z, macosBundleExecutable as Zt, deriveCatalog as _, VIDEO_TAG_IMAGE_TO_VIDEO as _t, readHostHeartbeat as a, writeFileAtomic as an, prepareChatBody as at, ENCRYPTED_CREDENTIAL_CODE as b, parseSupportedSecondsRange as bt, WORKBUDDY_CONNECT_VERSION as c, rewriteSessionTitleModel as ct, rosterSeenPath as d, defaultOffModelIds as dt, readAtRestKey as en, openingEvidenceOfBody as et, piAiRuntimeInfo as f, lastRefusalFor as ft, applyContextBudgets as g, withEffectiveOff as gt, WorkBuddyCatalog as h, recordRefusal as ht, processStartTimeMs as i, withFileLock as in, perturbChannelFingerprints as it, isEncryptedCredentialError as j, parseImageDataUrl as jt, defaultDesktopAuthPath as k, imageMimeForPath as kt, createFileRosterSeenStore as l, attachBusyLevels as lt, FALLBACK_WORKBUDDY_MODELS_GLOBAL as m, offRefused as mt, clearHostHeartbeat as n, hostPeersInfo as nn, parseReasoning as nt, workbuddyHostHeartbeatPath as o, regionOf as ot, FALLBACK_WORKBUDDY_MODELS as p, offDefaultFor as pt, forceNeutralHead as q, findWorkbuddyAppExecutable as qt, isHeartbeatProcessAlive as r, resolveDshHome as rn, parseUpstreamModel as rt, writeHostHeartbeat as s, requestEvidenceOf as st, WORKBUDDY_HOST_HEARTBEAT_FILENAME as t, workbuddyAppExecutableCandidates as tn, parseCreditMultiplier as tt, describeRosterSeenPayload as u, REFUSES_OFF_MODEL_IDS as ut, fallbackModelsFor as v, VIDEO_TAG_TEXT_TO_VIDEO as vt, WorkBuddyCredentialStore as w, IMAGE_TAG_IMAGE_TO_IMAGE as wt, WORKBUDDY_AUTH_FILENAME as x, pickVideoModel as xt, withoutRouters as y, WorkBuddyVideoError as yt, CONTEXT_OVERFLOW_MARKER as z, nativeModalityOf as zt };
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as parseCreditMultiplier, $t as resolveDshHome, A as isEncryptedCredentialError, At as pickMediaModel, B as WorkBuddyCredentialRejectedError, Bt as deriveAtRestKey, C as WorkBuddyCredentialStore, Ct as IMAGE_TAG_TEXT_TO_IMAGE, D as defaultDesktopAuthDirs, Dt as imageMimeForPath, E as defaultDesktopAuthCandidates, Et as imageDataUrl, F as workbuddyAccountId, Ft as NATIVE_MODALITY_BY_MODEL_ID, G as forceNeutralHead, Gt as isEncryptedFieldWrapper, H as channelGateMemberOf, Ht as fetchAtRestKeyPayload, I as workbuddyOwnAuthPath, It as imageDefaultFor, J as isCredentialRejectedError, Jt as macosNestedAppBundles, K as isContextTooLongBody, Kt as isWorkbuddyBundle, L as CONTEXT_OVERFLOW_MARKER, Lt as nativeModalityOf, M as legacyWorkbuddyOwnAuthPath, Mt as parseQueueAnswer, N as parseWorkBuddyAuth, Nt as queueNoticeText, O as defaultDesktopAuthPath, Ot as isBareBase64Image, P as preferredAccountName, Pt as pruneTempDir, Q as openingEvidenceOfBody, R as CREDENTIAL_REJECTED_CODE, Rt as WORKBUDDY_APP_EXECUTABLE_ENV, S as WORKBUDDY_AUTH_FILE_ENV, St as IMAGE_TAG_IMAGE_TO_IMAGE, T as authFileName, Tt as WorkBuddyImageError, U as classifyUpstreamError, Ut as findWorkbuddyAppExecutable, V as WorkBuddyUpstreamClient, Vt as deriveAtRestKeyId, W as declaredTools, X as knownRegionOf, Xt as readAtRestKey, Y as isFirstMessageGateBody, Yt as openEncryptedField, Z as modelIdOfBody, Zt as workbuddyAppExecutableCandidates, _ as deriveCatalog, _t as WorkBuddyVideoError, a as readHostHeartbeat, at as requestEvidenceOf, b as ENCRYPTED_CREDENTIAL_CODE, bt as resolveVideoParams, c as WORKBUDDY_CONNECT_VERSION, ct as REFUSES_OFF_MODEL_IDS, dt as offDefaultFor, en as withFileLock, et as parseReasoning, f as piAiRuntimeInfo, ft as offRefused, g as applyContextBudgets, gt as VIDEO_TAG_TEXT_TO_VIDEO, h as WorkBuddyCatalog, ht as VIDEO_TAG_IMAGE_TO_VIDEO, i as processStartTimeMs, it as regionOf, j as isVaultAccountId, jt as sniffImageMime, k as hasEncryptedCredentialFields, kt as parseImageDataUrl, l as createFileRosterSeenStore, lt as defaultOffModelIds, m as FALLBACK_WORKBUDDY_MODELS_GLOBAL, mt as withEffectiveOff, n as clearHostHeartbeat, nt as perturbChannelFingerprints, o as workbuddyHostHeartbeatPath, ot as rewriteSessionTitleModel, p as FALLBACK_WORKBUDDY_MODELS, pt as recordRefusal, q as isConversationIdGateBody, qt as macosBundleExecutable, r as isHeartbeatProcessAlive, rt as prepareChatBody, s as writeHostHeartbeat, st as attachBusyLevels, t as WORKBUDDY_HOST_HEARTBEAT_FILENAME, tn as writeFileAtomic, tt as parseUpstreamModel, ut as lastRefusalFor, v as fallbackModelsFor, vt as parseSupportedSecondsRange, w as WorkBuddyEncryptedCredentialError, wt as MAX_INPUT_IMAGE_BYTES, x as WORKBUDDY_AUTH_FILENAME, xt as DEFAULT_IMAGE_SIZE, y as withoutRouters, yt as pickVideoModel, z as WORKBUDDY_FALLBACK_SYSTEM_PROMPT, zt as clearAtRestKeyCache } from "./host-heartbeat-891AaZGW.js";
1
+ import { $ as modelIdOfBody, $t as openEncryptedField, A as hasEncryptedCredentialFields, At as isBareBase64Image, B as CREDENTIAL_REJECTED_CODE, Ct as DEFAULT_IMAGE_SIZE, D as defaultDesktopAuthCandidates, Dt as WorkBuddyImageError, E as authFileName, Et as MAX_INPUT_IMAGE_BYTES, F as preferredAccountName, Ft as queueNoticeText, G as classifyUpstreamError, Gt as deriveAtRestKeyId, H as WorkBuddyCredentialRejectedError, Ht as WORKBUDDY_APP_EXECUTABLE_ENV, I as workbuddyAccountId, It as pruneTempDir, J as isContextTooLongBody, K as declaredTools, Kt as fetchAtRestKeyPayload, L as workbuddyOwnAuthPath, Lt as NATIVE_MODALITY_BY_MODEL_ID, M as isVaultAccountId, Mt as pickMediaModel, N as legacyWorkbuddyOwnAuthPath, Nt as sniffImageMime, O as defaultDesktopAuthDirs, Ot as imageDataUrl, P as parseWorkBuddyAuth, Pt as parseQueueAnswer, Q as knownRegionOf, Qt as macosNestedAppBundles, Rt as imageDefaultFor, S as WORKBUDDY_AUTH_FILE_ENV, St as resolveVideoParams, T as WorkBuddyEncryptedCredentialError, Tt as IMAGE_TAG_TEXT_TO_IMAGE, U as WorkBuddyUpstreamClient, Ut as clearAtRestKeyCache, V as WORKBUDDY_FALLBACK_SYSTEM_PROMPT, W as channelGateMemberOf, Wt as deriveAtRestKey, X as isCredentialRejectedError, Xt as isWorkbuddyBundle, Y as isConversationIdGateBody, Yt as isEncryptedFieldWrapper, Z as isFirstMessageGateBody, Zt as macosBundleExecutable, _ as deriveCatalog, _t as VIDEO_TAG_IMAGE_TO_VIDEO, a as readHostHeartbeat, an as writeFileAtomic, at as prepareChatBody, b as ENCRYPTED_CREDENTIAL_CODE, bt as parseSupportedSecondsRange, c as WORKBUDDY_CONNECT_VERSION, ct as rewriteSessionTitleModel, dt as defaultOffModelIds, en as readAtRestKey, et as openingEvidenceOfBody, f as piAiRuntimeInfo, ft as lastRefusalFor, g as applyContextBudgets, gt as withEffectiveOff, h as WorkBuddyCatalog, ht as recordRefusal, i as processStartTimeMs, in as withFileLock, it as perturbChannelFingerprints, j as isEncryptedCredentialError, jt as parseImageDataUrl, k as defaultDesktopAuthPath, kt as imageMimeForPath, l as createFileRosterSeenStore, lt as attachBusyLevels, m as FALLBACK_WORKBUDDY_MODELS_GLOBAL, mt as offRefused, n as clearHostHeartbeat, nt as parseReasoning, o as workbuddyHostHeartbeatPath, ot as regionOf, p as FALLBACK_WORKBUDDY_MODELS, pt as offDefaultFor, q as forceNeutralHead, qt as findWorkbuddyAppExecutable, r as isHeartbeatProcessAlive, rn as resolveDshHome, rt as parseUpstreamModel, s as writeHostHeartbeat, st as requestEvidenceOf, t as WORKBUDDY_HOST_HEARTBEAT_FILENAME, tn as workbuddyAppExecutableCandidates, tt as parseCreditMultiplier, ut as REFUSES_OFF_MODEL_IDS, v as fallbackModelsFor, vt as VIDEO_TAG_TEXT_TO_VIDEO, w as WorkBuddyCredentialStore, wt as IMAGE_TAG_IMAGE_TO_IMAGE, x as WORKBUDDY_AUTH_FILENAME, xt as pickVideoModel, y as withoutRouters, yt as WorkBuddyVideoError, z as CONTEXT_OVERFLOW_MARKER, zt as nativeModalityOf } from "./host-heartbeat-DpnLfJws.js";
2
2
  import z from "@deepseek-ai/schemastery";
3
3
  import { appendFile, mkdir, open, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
4
4
  import { randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "dsh-connect-workbuddy",
3
3
  "displayName": "DSH Connect WorkBuddy",
4
4
  "description": "把本机登录的 WorkBuddy 模型(国内版与国际版)接入 DeepSeek Harness:每次刷新按上游目录自动读取每个模型的积分倍率,支持逐模型图片输入开关、多账号切换与账号池自动换号,并提供每日签到、卡片与输入框里的胶囊积分读数等只读积分概览。",
5
- "version": "5.15.1",
5
+ "version": "5.16.0",
6
6
  "author": "dingminhua",
7
7
  "copyright": "Copyright (c) 2026 LaoDing",
8
8
  "license": "MIT",