@refeain/dsh-xdpool 3.0.7 → 3.0.9

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,6 +1,33 @@
1
1
  # Changelog
2
2
  本项目的所有重要变更都会记录在此文件。
3
3
  版本号遵循 [语义化版本](https://semver.org/lang/zh-CN/)。
4
+ ## 3.0.7 — UI 错位修复、一键更新真正生效、代际守卫
5
+
6
+ ### UI 错位:账号卡回到正确的列
7
+
8
+ 3.0.4 起插件池账号卡被挂成了 `.app` 的网格子项。`.app` 是「功能栏 | 渠道列表 | 详情」三列,
9
+ 而 `display:contents` 容器让新增的 `section` 直接参与网格排列,把渠道列表和详情挤到第二行、
10
+ 被 `overflow:hidden` 裁掉 —— 账号池页整页错乱。
11
+
12
+ 现在账号卡由 `ChannelPoolSection` 渲染进**详情列的 `.mbody`**(和提示条同一条通路),
13
+ 并且只在选中 WorkBuddy 国内版 / 国际版时显示;选 CodeArts 等其它渠道、或未选渠道时不显示。
14
+ 结构复用设计稿的 `.sec / .sec-head / .accts / .acct*` 类名,没有新造一套样式。
15
+
16
+ ### 一键更新:之前从来没有真正生效过
17
+
18
+ 更新接口原来只改 profile 的 `package.json`,不碰 `pnpm-lock.yaml`。DSH 下次启动按 lockfile
19
+ 安装(或 frozen-lockfile 校验失败后从快照恢复),spec 被打回旧版本 —— 用户看到的就是
20
+ 「点了一键更新,版本号一直没变」。现在写完后调用 pnpm 同步 **package.json / lockfile /
21
+ node_modules** 三处;同步失败会回滚 manifest,宁可这次没更新,也不留下半更新的 profile。
22
+
23
+ ### pi-ai 代际守卫不再空转
24
+
25
+ 宿主模块路径原来多拼了一层 `node_modules`(`…/node_modules/node_modules/…`),
26
+ 守卫永远返回 `unknown` 且日志里和「对齐」一样静默 —— 真正撞上 0.82 / 1.5 代际错配时
27
+ (切到 xdpool 系模型第一条就报 PI_AI_ERROR)没有任何线索。现在先用 `createRequire` 解析
28
+ 宿主包,失败再退回少一层的相对路径;`unknown` / `aligned` / `mismatch` 都会写 startup.log。
29
+ README 补了「profile 需 `pnpm.overrides` 把 pi-ai 钉到宿主代」的说明。
30
+
4
31
  ## 3.0.6 — 账号卡重做,撤掉没用的关闭按钮
5
32
 
6
33
  3.0.4 把账号卡挂回账号池页时,直接用了 2.x 的 `AccountBlock`:它的根元素是渠道行的类名
package/README.en.md CHANGED
@@ -1,12 +1,36 @@
1
1
  # DSH XD Pool
2
2
 
3
3
  <p align="center">
4
- <a href="https://www.npmjs.com/package/dsh-xdpool"><img src="https://img.shields.io/npm/v/dsh-xdpool?style=flat-square&label=npm&color=cb3837" alt="npm version"></a>
5
- <a href="https://www.npmjs.com/package/dsh-xdpool"><img src="https://img.shields.io/npm/dm/dsh-xdpool?style=flat-square&label=downloads&color=cb3837" alt="npm downloads"></a>
6
- <a href="LICENSE"><img src="https://img.shields.io/github/license/XDTrees/dsh-xdpool?style=flat-square" alt="MIT license"></a>
7
- <a href="https://github.com/XDTrees/dsh-xdpool/stargazers"><img src="https://img.shields.io/github/stars/XDTrees/dsh-xdpool?style=flat-square" alt="GitHub stars"></a>
4
+ <a href="https://www.npmjs.com/package/@refeain/dsh-xdpool"><img src="https://img.shields.io/npm/v/%40refeain%2Fdsh-xdpool?style=flat-square&label=npm&color=cb3837" alt="npm version"></a>
5
+ <a href="https://www.npmjs.com/package/@refeain/dsh-xdpool"><img src="https://img.shields.io/npm/dm/%40refeain%2Fdsh-xdpool?style=flat-square&label=downloads&color=cb3837" alt="npm downloads"></a>
6
+ <a href="LICENSE"><img src="https://img.shields.io/github/license/Refeain/dsh-xdpool?style=flat-square" alt="MIT license"></a>
7
+ <a href="https://github.com/Refeain/dsh-xdpool/stargazers"><img src="https://img.shields.io/github/stars/Refeain/dsh-xdpool?style=flat-square" alt="GitHub stars"></a>
8
8
  </p>
9
9
 
10
+ ## About this repository
11
+
12
+ This is a personal fork of [XDTrees/dsh-xdpool](https://github.com/XDTrees/dsh-xdpool), published as **`@refeain/dsh-xdpool`**.
13
+ Publishing runs through this repository's own GitHub Actions workflow and npm trusted publishing — no token, no one-time password.
14
+
15
+ The code matches upstream file for file; only these six deltas are kept (typecheck, build and the full test suite all run locally):
16
+
17
+ | File | Change | Why |
18
+ | --- | --- | --- |
19
+ | `tsdown.config.ts` | `PLUGIN_ID` now reads `name` from `package.json` instead of hard-coding `dsh-xdpool` | The client bundle registers its module with the host under this id, while the host builds its row from the **package name**. Rename the package and the two no longer meet: every bit of the plugin's UI disappears silently, with nothing in the logs |
20
+ | `src/doubao-llm.ts` | Reasoning-level fallback now uses `DEFAULT_REASONING_LEVEL_ID` (`high`) | Upstream wrote `medium`, but the level table's id is `mid` — a fallback outside the table sends a level upstream does not recognise |
21
+ | `package.json` | Package name `@refeain/dsh-xdpool`, `publishConfig.access: public`, `repository` pointing here | Publishing and provenance |
22
+ | `cordis.patch.yml` | `name: '@refeain/dsh-xdpool'` | Must match the package name, or the host cannot find the plugin layer |
23
+ | `src/version.ts` | `POOL_VERSION` tracks `package.json` | The version shown on the card; `tests/version-sync.test.ts` keeps the two from drifting |
24
+ | `.github/workflows/publish.yml` | tag `v*` → OIDC publish (`--provenance`) | Publishing needs no secrets at all |
25
+
26
+ Install this fork by its scoped name:
27
+
28
+ ```sh
29
+ dsh plugin --profile desktop add @refeain/dsh-xdpool
30
+ ```
31
+
32
+ > It is the same plugin as upstream's `dsh-xdpool`, registering the same `xdpool` provider group — **do not install both**.
33
+
10
34
  ## Join the group
11
35
 
12
36
  <p align="center">
@@ -17,13 +41,13 @@
17
41
  <b>Left: WeChat (bot)</b> — scanning only adds the bot. <b>Send “XD”</b> and it pulls you into the group; scanning alone does nothing.<br>
18
42
  <b>Right: QQ group</b> — scan and you are in. Group number 1103463688.
19
43
  <br>
20
- <sub>Both groups are live; use whichever you prefer. If a code stops working, say so in <a href="https://github.com/XDTrees/dsh-xdpool/issues">issues</a> and it will be refreshed.</sub>
44
+ <sub>Both groups are live; use whichever you prefer. If a code stops working, say so in <a href="https://github.com/Refeain/dsh-xdpool/issues">issues</a> and it will be refreshed.</sub>
21
45
  <br>
22
46
  <sub>The 交流群 button next to “Star” in the card's top-right corner opens these same two codes — no need to come back to the README.</sub>
23
47
  </p>
24
48
 
25
49
  <p align="center">
26
- <sub>The downloads badge reads <code>dsh-xdpool</code>'s own live npm stats now, not the pre-rename snapshot.</sub>
50
+ <sub>The downloads badge reads <code>@refeain/dsh-xdpool</code>'s own live npm stats now, not the pre-rename snapshot.</sub>
27
51
  </p>
28
52
 
29
53
  English | [中文](./README.md)
@@ -136,7 +160,7 @@ Prerequisite: the WorkBuddy desktop app installed and signed in (the plugin reus
136
160
 
137
161
  ```sh
138
162
  # if dsh is not on PATH, use node ~/.dsh/profiles/node_modules/@deepseek-ai/dsh/lib/bin.js instead
139
- dsh plugin --profile desktop add dsh-xdpool
163
+ dsh plugin --profile desktop add @refeain/dsh-xdpool
140
164
  ```
141
165
 
142
166
  > npm is the fast path: the only dependency pulled in is the plugin itself (**roughly 1 package, a few seconds**).
@@ -145,17 +169,17 @@ dsh plugin --profile desktop add dsh-xdpool
145
169
  **Option B — install from the GitHub source**
146
170
 
147
171
  ```sh
148
- dsh plugin --profile desktop add github:XDTrees/dsh-xdpool
172
+ dsh plugin --profile desktop add github:Refeain/dsh-xdpool
149
173
  ```
150
174
 
151
175
  **Option C — register the bundle by hand**
152
176
 
153
177
  ```sh
154
178
  # 1) install the package (npm or GitHub)
155
- dsh plugin --profile desktop add dsh-xdpool
179
+ dsh plugin --profile desktop add @refeain/dsh-xdpool
156
180
 
157
181
  # 2) register the bundle: edit ~/.dsh/profiles/desktop/package.json and append
158
- # "dsh-xdpool" to the end of the "dsh" → "profile" → "bundles" array
182
+ # "@refeain/dsh-xdpool" to the end of the "dsh" → "profile" → "bundles" array
159
183
 
160
184
  # 3) restart DSH Desktop
161
185
  ```
@@ -165,7 +189,7 @@ dsh plugin --profile desktop add dsh-xdpool
165
189
  ```sh
166
190
  pnpm install
167
191
  pnpm build # produces lib/index.js + lib/index.d.ts + lib/bin.js + lib/client.js
168
- pnpm test # 138 tests
192
+ pnpm test # 1753 tests
169
193
  pnpm typecheck # host side
170
194
  pnpm typecheck:client # client side
171
195
  ```
@@ -213,17 +237,17 @@ Every startup writes this to `~/.dsh/.xdpool/startup.log`, so if you forget, the
213
237
 
214
238
  ## CLI
215
239
 
216
- All commands run through `dsh plugin --profile desktop exec dsh-xdpool <subcommand>`:
240
+ All commands run through `dsh plugin --profile desktop exec @refeain/dsh-xdpool <subcommand>`:
217
241
 
218
242
  ```sh
219
- dsh plugin --profile desktop exec dsh-xdpool status # pool accounts/cooldown + shim state (--credits, --json, --rates)
220
- dsh plugin --profile desktop exec dsh-xdpool accounts # discovered accounts (--json)
221
- dsh plugin --profile desktop exec dsh-xdpool doctor # diagnose discovery/cooldown/upstream
222
- dsh plugin --profile desktop exec dsh-xdpool reset # clear all 429 cooldowns now
223
- dsh plugin --profile desktop exec dsh-xdpool checkin # today's check-in state per account (--json)
224
- dsh plugin --profile desktop exec dsh-xdpool checkin all
243
+ dsh plugin --profile desktop exec @refeain/dsh-xdpool status # pool accounts/cooldown + shim state (--credits, --json, --rates)
244
+ dsh plugin --profile desktop exec @refeain/dsh-xdpool accounts # discovered accounts (--json)
245
+ dsh plugin --profile desktop exec @refeain/dsh-xdpool doctor # diagnose discovery/cooldown/upstream
246
+ dsh plugin --profile desktop exec @refeain/dsh-xdpool reset # clear all 429 cooldowns now
247
+ dsh plugin --profile desktop exec @refeain/dsh-xdpool checkin # today's check-in state per account (--json)
248
+ dsh plugin --profile desktop exec @refeain/dsh-xdpool checkin all
225
249
  # collect every account's daily reward (or pass one label)
226
- dsh plugin --profile desktop exec dsh-xdpool login # guide to adding another desktop account
250
+ dsh plugin --profile desktop exec @refeain/dsh-xdpool login # guide to adding another desktop account
227
251
  ```
228
252
 
229
253
  ## How accounts get into the pool
@@ -233,9 +257,9 @@ The desktop app keeps only the **currently signed-in** account on disk (each swi
233
257
  To snapshot an extra login explicitly (e.g. to pin one account for verification):
234
258
 
235
259
  ```sh
236
- dsh plugin --profile desktop exec dsh-xdpool import myKey
237
- dsh plugin --profile desktop exec dsh-xdpool accounts
238
- dsh plugin --profile desktop exec dsh-xdpool remove myKey
260
+ dsh plugin --profile desktop exec @refeain/dsh-xdpool import myKey
261
+ dsh plugin --profile desktop exec @refeain/dsh-xdpool accounts
262
+ dsh plugin --profile desktop exec @refeain/dsh-xdpool remove myKey
239
263
  ```
240
264
 
241
265
  Imported snapshots live in the same directory, `~/.dsh/.xdpool/`, and every scan absorbs them into the pool — they are no longer written and never read back. Snapshots are named by the **MD5-8 prefix** of their key (so keys with Chinese, `/`, or spaces are safe). Long-lived use relies on refresh-token auto-renewal; if it lapses, re-sign-in on the desktop and `import <key> --force`.
package/README.md CHANGED
@@ -1,14 +1,46 @@
1
1
  # DSH XD Pool
2
2
 
3
3
  <p align="center">
4
- <a href="https://www.npmjs.com/package/dsh-xdpool"><img src="https://img.shields.io/npm/v/dsh-xdpool?style=flat-square&label=npm&color=cb3837" alt="npm version"></a>
5
- <a href="https://www.npmjs.com/package/dsh-xdpool"><img src="https://img.shields.io/npm/dm/dsh-xdpool?style=flat-square&label=downloads&color=cb3837" alt="npm downloads"></a>
6
- <a href="LICENSE"><img src="https://img.shields.io/github/license/XDTrees/dsh-xdpool?style=flat-square" alt="MIT license"></a>
7
- <a href="https://github.com/XDTrees/dsh-xdpool/stargazers"><img src="https://img.shields.io/github/stars/XDTrees/dsh-xdpool?style=flat-square" alt="GitHub stars"></a>
4
+ <a href="https://www.npmjs.com/package/@refeain/dsh-xdpool"><img src="https://img.shields.io/npm/v/%40refeain%2Fdsh-xdpool?style=flat-square&label=npm&color=cb3837" alt="npm version"></a>
5
+ <a href="https://www.npmjs.com/package/@refeain/dsh-xdpool"><img src="https://img.shields.io/npm/dm/%40refeain%2Fdsh-xdpool?style=flat-square&label=downloads&color=cb3837" alt="npm downloads"></a>
6
+ <a href="LICENSE"><img src="https://img.shields.io/github/license/Refeain/dsh-xdpool?style=flat-square" alt="MIT license"></a>
7
+ <a href="https://github.com/Refeain/dsh-xdpool/stargazers"><img src="https://img.shields.io/github/stars/Refeain/dsh-xdpool?style=flat-square" alt="GitHub stars"></a>
8
8
  </p>
9
9
 
10
+ ## 关于本仓库
11
+
12
+ 这是 [XDTrees/dsh-xdpool](https://github.com/XDTrees/dsh-xdpool) 的个人分支,发布为 **`@refeain/dsh-xdpool`**。
13
+ 发布走本仓库自己的 GitHub Actions + npm trusted publishing,不需要 token,也不需要一次性验证码。
14
+
15
+ 代码与上游逐文件相同,只多保留了下面六处改动(都在本地跑过类型检查、构建与全部测试):
16
+
17
+ | 文件 | 改动 | 为什么 |
18
+ | --- | --- | --- |
19
+ | `tsdown.config.ts` | `PLUGIN_ID` 改成读 `package.json` 的 `name`,不再硬编码 `dsh-xdpool` | 客户端 bundle 用这个 id 向宿主注册模块,而宿主按**包名**建行。包名一变两者对不上,插件的所有 UI 会静默消失,日志里一个字都不报 |
20
+ | `src/doubao-llm.ts` | 推理档位兜底值改用 `DEFAULT_REASONING_LEVEL_ID`(`high`) | 上游写的是 `medium`,而档位表里的 id 叫 `mid` —— 兜底值不在表里,请求会带着上游不认的档位发出去 |
21
+ | `package.json` | 包名 `@refeain/dsh-xdpool`、`publishConfig.access: public`、`repository` 指向本仓库 | 发布与来源标注 |
22
+ | `cordis.patch.yml` | `name: '@refeain/dsh-xdpool'` | 与包名一致,否则宿主找不到插件层 |
23
+ | `src/version.ts` | `POOL_VERSION` 跟着 `package.json` 走 | 卡片上显示的版本号;`tests/version-sync.test.ts` 会盯着这两者不许漂 |
24
+ | `.github/workflows/publish.yml` | tag `v*` → OIDC 发布(`--provenance`) | 发布不需要任何 secret |
25
+
26
+ 装这个分支要认准 scope:
27
+
28
+ ```sh
29
+ dsh plugin --profile desktop add @refeain/dsh-xdpool
30
+ ```
31
+
32
+ > 它和上游的 `dsh-xdpool` 是同一个插件、注册同一个 `xdpool` provider 分组,**不要两个都装**。
33
+
10
34
  ## 更新公告
11
35
 
36
+ **3.0.8** — 包名换到 `@refeain/dsh-xdpool` 之后 UI 静默消失那个坑修好了(见上方「关于本仓库」)。
37
+
38
+ **3.0.7** — UI 错位修复、一键更新真正生效、代际守卫不再空转。
39
+
40
+ - 修复账号池页整页错乱:账号卡回到详情列里,只在选中 WorkBuddy 国内版/国际版时显示
41
+ - 修复一键更新「更新了但版本号一直没变」:现在会同步 lockfile 和 node_modules,不再被 DSH 启动时装回旧版
42
+ - pi-ai 代际守卫修正宿主路径,mismatch / aligned / unknown 都会写进启动日志,切 xdpool 模型崩溃时不再毫无线索
43
+
12
44
  **3.0.6** — 账号卡重做。
13
45
 
14
46
  - 账号池页的账号卡重画成自包含的卡片:昵称、状态徽章(当前使用 / 已停用 / 冷却中)、令牌到期、积分、以及优先/停用/签到/移出池子一排按钮
@@ -31,13 +63,13 @@
31
63
  <b>左:微信(机器人)</b> —— 扫码添加机器人后<b>发送「XD」</b>,它才会拉你进群;只扫码不加不发是不会有反应的。<br>
32
64
  <b>右:QQ 群</b> —— 直接扫码即可加入,群号 1103463688。
33
65
  <br>
34
- <sub>两个群都在,哪个方便用哪个。二维码失效了在 <a href="https://github.com/XDTrees/dsh-xdpool/issues">issues</a> 说一声会换新。</sub>
66
+ <sub>两个群都在,哪个方便用哪个。二维码失效了在 <a href="https://github.com/Refeain/dsh-xdpool/issues">issues</a> 说一声会换新。</sub>
35
67
  <br>
36
68
  <sub>卡片右上角「点Star」旁边的「交流群」按钮打开的是同样这两张码 —— 不用回头找 README。</sub>
37
69
  </p>
38
70
 
39
71
  <p align="center">
40
- <sub>下载量徽章读的是 npm 上 <code>dsh-xdpool</code> 自己的实时统计,不再是改名前的快照。</sub>
72
+ <sub>下载量徽章读的是 npm 上 <code>@refeain/dsh-xdpool</code> 自己的实时统计,不再是改名前的快照。</sub>
41
73
  </p>
42
74
 
43
75
  [English](./README.en.md) | 中文
@@ -159,7 +191,7 @@
159
191
 
160
192
  ```sh
161
193
  # dsh 不在 PATH 时,用 node ~/.dsh/profiles/node_modules/@deepseek-ai/dsh/lib/bin.js 代替 dsh
162
- dsh plugin --profile desktop add dsh-xdpool
194
+ dsh plugin --profile desktop add @refeain/dsh-xdpool
163
195
  ```
164
196
 
165
197
  > 推荐 npm:需要拉取的依赖只有插件自己(**约 1 个包,几秒搞定**)。
@@ -168,17 +200,17 @@ dsh plugin --profile desktop add dsh-xdpool
168
200
  **方式二:从 GitHub 源码安装**
169
201
 
170
202
  ```sh
171
- dsh plugin --profile desktop add github:XDTrees/dsh-xdpool
203
+ dsh plugin --profile desktop add github:Refeain/dsh-xdpool
172
204
  ```
173
205
 
174
206
  **方式三:手动注册 bundle**
175
207
 
176
208
  ```sh
177
209
  # 1) 先装包(npm 或 GitHub 任选)
178
- dsh plugin --profile desktop add dsh-xdpool
210
+ dsh plugin --profile desktop add @refeain/dsh-xdpool
179
211
 
180
212
  # 2) 注册 bundle:编辑 ~/.dsh/profiles/desktop/package.json,
181
- # 在 "dsh" → "profile" → "bundles" 数组末尾加上 "dsh-xdpool"
213
+ # 在 "dsh" → "profile" → "bundles" 数组末尾加上 "@refeain/dsh-xdpool"
182
214
 
183
215
  # 3) 重启 DSH Desktop
184
216
  ```
@@ -188,7 +220,7 @@ dsh plugin --profile desktop add dsh-xdpool
188
220
  ```sh
189
221
  pnpm install
190
222
  pnpm build # 产出 lib/index.js + lib/index.d.ts + lib/bin.js + lib/client.js
191
- pnpm test # 814 项测试
223
+ pnpm test # 1753 项测试
192
224
  pnpm typecheck # 宿主侧类型检查
193
225
  pnpm typecheck:client # 客户端类型检查
194
226
  ```
@@ -236,17 +268,17 @@ agent-default-model:
236
268
 
237
269
  ## 命令行
238
270
 
239
- 统一用 `dsh plugin --profile desktop exec dsh-xdpool <子命令>` 调用:
271
+ 统一用 `dsh plugin --profile desktop exec @refeain/dsh-xdpool <子命令>` 调用:
240
272
 
241
273
  ```sh
242
- dsh plugin --profile desktop exec dsh-xdpool status # 池里几个号 / 几个冷却 + shim 状态(--credits 查积分、--json 机器可读、--rates 看倍率)
243
- dsh plugin --profile desktop exec dsh-xdpool accounts # 已发现的账号(--json)
244
- dsh plugin --profile desktop exec dsh-xdpool doctor # 诊断发现 / 冷却 / 上游连通性
245
- dsh plugin --profile desktop exec dsh-xdpool reset # 立刻清掉所有 429 冷却
246
- dsh plugin --profile desktop exec dsh-xdpool checkin # 查每个账号今天签到了没(--json 机器可读)
247
- dsh plugin --profile desktop exec dsh-xdpool checkin all
274
+ dsh plugin --profile desktop exec @refeain/dsh-xdpool status # 池里几个号 / 几个冷却 + shim 状态(--credits 查积分、--json 机器可读、--rates 看倍率)
275
+ dsh plugin --profile desktop exec @refeain/dsh-xdpool accounts # 已发现的账号(--json)
276
+ dsh plugin --profile desktop exec @refeain/dsh-xdpool doctor # 诊断发现 / 冷却 / 上游连通性
277
+ dsh plugin --profile desktop exec @refeain/dsh-xdpool reset # 立刻清掉所有 429 冷却
278
+ dsh plugin --profile desktop exec @refeain/dsh-xdpool checkin # 查每个账号今天签到了没(--json 机器可读)
279
+ dsh plugin --profile desktop exec @refeain/dsh-xdpool checkin all
248
280
  # 领掉所有账号今天的签到奖励;也可以只传一个账号标签领单个
249
- dsh plugin --profile desktop exec dsh-xdpool login # 教你怎么在桌面再加一个号进池
281
+ dsh plugin --profile desktop exec @refeain/dsh-xdpool login # 教你怎么在桌面再加一个号进池
250
282
  ```
251
283
 
252
284
  ## 池里怎么多账号?
@@ -257,10 +289,10 @@ dsh plugin --profile desktop exec dsh-xdpool login # 教你怎么在桌面
257
289
 
258
290
  ```sh
259
291
  # 在 WorkBuddy 桌面 App 登录账号后(key 自己起名):
260
- dsh plugin --profile desktop exec dsh-xdpool import myKey
292
+ dsh plugin --profile desktop exec @refeain/dsh-xdpool import myKey
261
293
  # 查看 / 删除已导入的快照:
262
- dsh plugin --profile desktop exec dsh-xdpool accounts
263
- dsh plugin --profile desktop exec dsh-xdpool remove myKey
294
+ dsh plugin --profile desktop exec @refeain/dsh-xdpool accounts
295
+ dsh plugin --profile desktop exec @refeain/dsh-xdpool remove myKey
264
296
  ```
265
297
 
266
298
  导入的快照与自动保存的账号存在同一个目录 `~/.dsh/.xdpool/` 下,每次扫描都会被一并收进池——不再是「导入了但没人读」。快照以 key 的 **MD5 前 8 位**命名(key 本身记在文件里),中文、带 `/`、带空格的 key 都安全。长期使用靠 refresh token 自动续期;失效了就回桌面重新登录,再 `import <key> --force` 覆盖。
@@ -300,6 +332,22 @@ xdpool:
300
332
  - **构建**
301
333
  `tsdown` 产出 `lib/index.js`(宿主入口)+ `lib/index.d.ts`(类型)+ `lib/bin.js`(CLI)+ `lib/client.js`(CJS,用 `window.__ModuleLoader__.load` 包起来的浏览器 bundle)。四个产物都随仓库提交,所以安装时不需要任何构建脚本。
302
334
 
335
+ ## π-ai 代际对齐(重要)
336
+
337
+ 本插件在宿主里用 pi-ai 组装 provider,宿主适配器用**它自己**那份 pi-ai 消费事件流。
338
+ 两份大版本不一致时(典型:插件侧 0.82.x、宿主侧 1.5.x),第一次请求就会崩在适配器接缝,
339
+ 宿主把它归成不可重试的 `PI_AI_ERROR` —— 现象是「切到 xdpool 系模型,第一条就没内容」。
340
+
341
+ 如何确认:重启 DSH 后看 `~/.dsh/.xdpool/startup.log`,会写 `pi-ai generation: aligned at …`
342
+ 或 `mismatch`。一旦看到 mismatch,在 profile 的 `package.json` 里钉到宿主代:
343
+
344
+ ```json
345
+ { "pnpm": { "overrides": { "@earendil-works/pi-ai": "<宿主版本>" } } }
346
+ ```
347
+
348
+ 然后重装依赖并重启。日志里写 `unknown` 表示两侧只读到一份(比如宿主把它打进了 bundle),
349
+ 插件会继续工作,但代际无法自动核对。
350
+
303
351
  ## 已知限制
304
352
 
305
353
  - **WorkBuddy 主账号的登录仍走桌面 App**:XD Pool 可以为插件自己的二十多家登录渠道发起登录,但 WorkBuddy 本体的 token 由桌面 App 的腾讯 SSO 铸造并和设备绑定,池不会替你登录 WorkBuddy。加号 = 在桌面 App 里登录 / 切换,XD Pool 自动吸收。
package/lib/bin.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { createRequire } from "node:module";
1
2
  import { createDecipheriv, createHash, randomUUID } from "node:crypto";
2
3
  import { existsSync, mkdirSync, readFileSync, readdirSync, renameSync, writeFileSync } from "node:fs";
3
4
  import { chmod, copyFile, mkdir, readFile, readdir, rename, rm, unlink, writeFile, writeFile as writeFile$1 } from "node:fs/promises";
@@ -190,6 +191,23 @@ const SESSION_DEAD_MARKERS = [
190
191
  */
191
192
  const ALREADY_CHECKIN_MARKERS = ["已签到", "already"];
192
193
  /**
194
+ * 签到相关的业务码。
195
+ *
196
+ * 上游用 `code` 区分三种「不是成功也不是故障」的结果,而我们此前一律当失败抛出:
197
+ * 今天已经领过(1001/10001)会在每次自动领取时记一条失败;活动未开放(1002/1003/
198
+ * 40901/41000)也会,而且永远重试不到结果。它们必须分开对待:
199
+ *
200
+ * 已领 → 幂等成功(今天的分就在账上,不是错)
201
+ * 未开放 → inactive(等下一次,不报错、不重试)
202
+ */
203
+ const CHECKIN_ALREADY_CODES = /* @__PURE__ */ new Set([1001, 10001]);
204
+ const CHECKIN_INACTIVE_CODES = /* @__PURE__ */ new Set([
205
+ 1002,
206
+ 1003,
207
+ 40901,
208
+ 41e3
209
+ ]);
210
+ /**
193
211
  * Markers for "there is no compensation offer to collect".
194
212
  *
195
213
  * The offer is seasonal — an outage announcement opens one, and it closes on a
@@ -575,7 +593,17 @@ function billingHeaders(credential) {
575
593
  const headers = {
576
594
  "Authorization": `Bearer ${credential.accessToken}`,
577
595
  "Accept": "application/json",
578
- "Content-Type": "application/json"
596
+ "Content-Type": "application/json",
597
+ /**
598
+ * 产品身份头 —— 缺了它们,计费/签到端点会把请求当成「不是客户端发的」。
599
+ *
600
+ * 这三个头一直在客户端那边发(网页/IDE 的每个 billing 请求都带),我们只发了
601
+ * Authorization + X-Domain + X-User-Id。上游收紧校验之后,签到就只剩一个笼统的
602
+ * 失败,看不出原因。UA 用本插件已经在别处使用的桌面版本号,不再另造一个。
603
+ */
604
+ "X-Product": "SaaS",
605
+ "X-Product-Code": "workbuddy",
606
+ "User-Agent": DESKTOP_UA
579
607
  };
580
608
  if (credential.uid !== "" && credential.uid !== void 0) headers["X-User-Id"] = credential.uid;
581
609
  if (credential.enterpriseId !== void 0 && credential.enterpriseId !== "") {
@@ -1466,6 +1494,17 @@ var WorkBuddyUpstreamClient = class {
1466
1494
  signal: AbortSignal.timeout(JSON_TIMEOUT_MS)
1467
1495
  });
1468
1496
  const envelope = await readEnvelope(response);
1497
+ if (response.ok && CHECKIN_INACTIVE_CODES.has(envelope.code)) return {
1498
+ active: false,
1499
+ todayCheckedIn: false,
1500
+ streakDays: 0,
1501
+ dailyCredit: 0,
1502
+ todayCredit: 0,
1503
+ isStreakDay: false,
1504
+ nextStreakDay: 0,
1505
+ streakBonusDays: 0,
1506
+ streakBonusCredit: 0
1507
+ };
1469
1508
  if (!response.ok || envelope.code !== 0) throw envelopeError(response.status, envelope);
1470
1509
  const data = typeof envelope.data === "object" && envelope.data !== null ? envelope.data : {};
1471
1510
  const num = (key) => typeof data[key] === "number" ? data[key] : 0;
@@ -1491,8 +1530,22 @@ var WorkBuddyUpstreamClient = class {
1491
1530
  signal: AbortSignal.timeout(JSON_TIMEOUT_MS)
1492
1531
  });
1493
1532
  const envelope = await readEnvelope(response);
1533
+ const neutral = (data_) => ({
1534
+ credit: 0,
1535
+ streakDays: typeof data_["streak_days"] === "number" ? data_["streak_days"] : 0,
1536
+ isStreakDay: false
1537
+ });
1538
+ const payload = typeof envelope.data === "object" && envelope.data !== null ? envelope.data : {};
1539
+ /**
1540
+ * 已领过(1001/10001)就是成功:今天的分在账上,重复领取不该被记成失败 ——
1541
+ * 自动化每小时跑一次,记成失败会刷出一整片红字。
1542
+ *
1543
+ * 未开放(1002/1003/40901/41000)同样是「今天没有可领的」,不是故障;
1544
+ * 抛错会让调度器一直重试一个永远不会成功的结果。
1545
+ */
1546
+ if (response.ok && (CHECKIN_ALREADY_CODES.has(envelope.code) || CHECKIN_INACTIVE_CODES.has(envelope.code))) return neutral(payload);
1494
1547
  if (!response.ok || envelope.code !== 0) throw envelopeError(response.status, envelope);
1495
- const data = typeof envelope.data === "object" && envelope.data !== null ? envelope.data : {};
1548
+ const data = payload;
1496
1549
  const numberField = (key) => typeof data[key] === "number" ? data[key] : 0;
1497
1550
  return {
1498
1551
  credit: numberField("credit"),
@@ -4931,6 +4984,22 @@ var WorkBuddyAccountPool = class {
4931
4984
  * Returns true when the token is known good afterwards (refreshed, or still
4932
4985
  * valid), false when the credential was proven dead.
4933
4986
  */
4987
+ /**
4988
+ * 取一个账号「可以用来发一次请求」的凭据:过期就先刷新。
4989
+ *
4990
+ * 签到 / 积分这些端点走的是「按 id 直接找账号」的路径,和选号路径不同 ——
4991
+ * 以前它们直接拿池里的 `account.credential`,凭据过期时上游回 401,界面只能
4992
+ * 说「领取失败」,而同一时刻对话却正常(对话走 `getAvailableAccount`,那里会
4993
+ * 先 `ensureFresh`)。用户反馈的「积分领取全部失败」就是这一处。
4994
+ *
4995
+ * 返回 undefined 表示「刷新失败」:调用方应当直接告诉用户重新登录,
4996
+ * 而不是拿旧 token 再去撞一次 401。
4997
+ */
4998
+ async freshCredential(id) {
4999
+ const account = this.accounts.find((item) => item.id === id);
5000
+ if (account === void 0) return void 0;
5001
+ return await this.ensureFresh(account) ? account.credential : void 0;
5002
+ }
4934
5003
  async ensureFresh(account, force = false) {
4935
5004
  if (this.client === void 0) return true;
4936
5005
  const credential = account.credential;
@@ -10788,6 +10857,53 @@ Object.freeze([
10788
10857
  "jev-1.13-free"
10789
10858
  ]);
10790
10859
  //#endregion
10860
+ //#region src/diagnostics.ts
10861
+ /**
10862
+ * Render any thrown value as one line of text.
10863
+ *
10864
+ * `String(error)` on a real `Error` collapses the stack to "Error: message",
10865
+ * which is exactly the part worth keeping; the object form (`{}` for a
10866
+ * structured clone, `[object Object]` for anything else) is what produced the
10867
+ * unreadable `{}` markers in this project's earlier logs.
10868
+ */
10869
+ function describeError(error) {
10870
+ if (error instanceof Error) {
10871
+ const code = "code" in error && typeof error.code === "string" ? ` (${String(error.code)})` : "";
10872
+ return `${error.name}: ${error.message}${code}`;
10873
+ }
10874
+ if (typeof error === "string") return error;
10875
+ try {
10876
+ return JSON.stringify(error) ?? String(error);
10877
+ } catch {
10878
+ return String(error);
10879
+ }
10880
+ }
10881
+ //#endregion
10882
+ //#region src/redact.ts
10883
+ /**
10884
+ * Strip credential-shaped substrings out of text that is about to be shown to a
10885
+ * person, or written to a log line we do not control.
10886
+ *
10887
+ * The rules are deliberately narrow: they match the two shapes this plugin
10888
+ * actually carries around — a JWT, and a token passed as a query parameter —
10889
+ * rather than trying to guess at "secrets" in general. A redactor that also
10890
+ * eats ordinary prose is worse than none: the reader stops believing the
10891
+ * message, and the next failure gets pasted into an issue by hand.
10892
+ *
10893
+ * Shared on purpose. The status route and the automation scheduler both surface
10894
+ * upstream failures, and two copies of this logic drifting apart would mean the
10895
+ * same account failure reads one way on the card and another in the log.
10896
+ *
10897
+ * @module dsh-xdpool/redact
10898
+ */
10899
+ /** `eyJ…` header.payload.signature — what an access or refresh token looks like. */
10900
+ const JWT = /\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b/gu;
10901
+ /** `?code=…` / `token=…` in a URL or a request echo. The key is kept, the value is not. */
10902
+ const QUERY_SECRET = /(\b(?:code|token|refresh_token|access_token)=)[^&\s]+/giu;
10903
+ function redactSecrets(text) {
10904
+ return text.replace(JWT, "[redacted token]").replace(QUERY_SECRET, "$1[redacted]");
10905
+ }
10906
+ //#endregion
10791
10907
  //#region src/task-events.ts
10792
10908
  /**
10793
10909
  * The app the buddy chain enters.
@@ -11914,6 +12030,15 @@ var WorkBuddyScheduler = class {
11914
12030
  * distinguishable from "0 tasks, everything already collected".
11915
12031
  */
11916
12032
  const items = [];
12033
+ /**
12034
+ * One line per account that threw, already redacted.
12035
+ *
12036
+ * Kept beside `detail` rather than read back out of it because `summarise`
12037
+ * needs the reasons WITHOUT the account labels it already prefixes — and
12038
+ * because `detail` also carries success lines ("签到 +5"), which a
12039
+ * positional convention over a mixed list would eventually get wrong.
12040
+ */
12041
+ const failureNotes = [];
11917
12042
  let progressNote;
11918
12043
  try {
11919
12044
  const revived = await this.pool.reviveBenched((credential) => this.client.fetchCredits(credential));
@@ -11997,6 +12122,9 @@ var WorkBuddyScheduler = class {
11997
12122
  } catch (error) {
11998
12123
  failed++;
11999
12124
  this.logger.warn?.(`automation ${accountWord} ${account.label} failed:`, error);
12125
+ const reason = redactSecrets(describeError(error)).slice(0, 200);
12126
+ detail.push(`${account.label} ${accountWord} failed: ${reason}`);
12127
+ failureNotes.push(`${account.label}: ${reason}`);
12000
12128
  }
12001
12129
  if (index < accounts.length - 1 && this.delayMs > 0 && !this.stopped) await sleep(this.delayMs);
12002
12130
  }
@@ -12011,6 +12139,8 @@ var WorkBuddyScheduler = class {
12011
12139
  state.energy = energy;
12012
12140
  state.claimed = claimed;
12013
12141
  state.message = this.summarise(kind, ok, failed, claimed, credit, energy);
12142
+ if (failureNotes.length === 0) delete state.failures;
12143
+ else state.failures = failureNotes;
12014
12144
  state.detail = detail;
12015
12145
  state.items = items;
12016
12146
  if (progressNote === void 0) delete state.progress;
@@ -12643,10 +12773,25 @@ async function writePreferredId(accountId, path = preferredIdPath()) {
12643
12773
  }
12644
12774
  fileURLToPath(new URL("..", import.meta.url));
12645
12775
  (() => {
12776
+ /**
12777
+ * issue #208:原来用 `../../node_modules/@deepseek-ai/dsh-llm-pi-ai/`:
12778
+ * `import.meta.url` 是 `<profile>/node_modules/dsh-xdpool/lib/index.js`,`../../`
12779
+ * 已经落到 `<profile>/node_modules/`,再拼 `node_modules/...` 就成了
12780
+ * `<profile>/node_modules/node_modules/...` —— 多一层,永远解析不到,守卫因此
12781
+ * 长期返回 unknown、日志里一个字都不写,而真正的 0.82 / 1.5 代际错配照样崩。
12782
+ *
12783
+ * 现在优先用 createRequire 从插件自身解析宿主包(pnpm / hoisted / 全局安装都
12784
+ * 能覆盖),再退回少一层的相对路径。createRequire 在 ESM bundle 里也可用。
12785
+ */
12646
12786
  try {
12647
- return fileURLToPath(new URL("../../node_modules/@deepseek-ai/dsh-llm-pi-ai/", import.meta.url));
12787
+ const require_ = createRequire(import.meta.url);
12788
+ return dirname(require_.resolve("@deepseek-ai/dsh-llm-pi-ai/package.json"));
12648
12789
  } catch {
12649
- return "";
12790
+ try {
12791
+ return fileURLToPath(new URL("../node_modules/@deepseek-ai/dsh-llm-pi-ai/", import.meta.url));
12792
+ } catch {
12793
+ return "";
12794
+ }
12650
12795
  }
12651
12796
  })();
12652
12797
  /**