@refeain/dsh-xdpool 3.0.8 → 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/README.en.md +46 -22
- package/README.md +48 -22
- package/lib/bin.js +61 -0
- package/lib/client.js +30 -2
- package/lib/index.d.ts +26 -0
- package/lib/index.js +107 -68
- package/package.json +1 -1
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
|
|
5
|
-
<a href="https://www.npmjs.com/package/dsh-xdpool"><img src="https://img.shields.io/npm/dm
|
|
6
|
-
<a href="LICENSE"><img src="https://img.shields.io/github/license/
|
|
7
|
-
<a href="https://github.com/
|
|
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/
|
|
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
|
|
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:
|
|
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 #
|
|
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,40 @@
|
|
|
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
|
|
5
|
-
<a href="https://www.npmjs.com/package/dsh-xdpool"><img src="https://img.shields.io/npm/dm
|
|
6
|
-
<a href="LICENSE"><img src="https://img.shields.io/github/license/
|
|
7
|
-
<a href="https://github.com/
|
|
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
|
+
|
|
12
38
|
**3.0.7** — UI 错位修复、一键更新真正生效、代际守卫不再空转。
|
|
13
39
|
|
|
14
40
|
- 修复账号池页整页错乱:账号卡回到详情列里,只在选中 WorkBuddy 国内版/国际版时显示
|
|
@@ -37,13 +63,13 @@
|
|
|
37
63
|
<b>左:微信(机器人)</b> —— 扫码添加机器人后<b>发送「XD」</b>,它才会拉你进群;只扫码不加不发是不会有反应的。<br>
|
|
38
64
|
<b>右:QQ 群</b> —— 直接扫码即可加入,群号 1103463688。
|
|
39
65
|
<br>
|
|
40
|
-
<sub>两个群都在,哪个方便用哪个。二维码失效了在 <a href="https://github.com/
|
|
66
|
+
<sub>两个群都在,哪个方便用哪个。二维码失效了在 <a href="https://github.com/Refeain/dsh-xdpool/issues">issues</a> 说一声会换新。</sub>
|
|
41
67
|
<br>
|
|
42
68
|
<sub>卡片右上角「点Star」旁边的「交流群」按钮打开的是同样这两张码 —— 不用回头找 README。</sub>
|
|
43
69
|
</p>
|
|
44
70
|
|
|
45
71
|
<p align="center">
|
|
46
|
-
<sub>下载量徽章读的是 npm 上 <code
|
|
72
|
+
<sub>下载量徽章读的是 npm 上 <code>@refeain/dsh-xdpool</code> 自己的实时统计,不再是改名前的快照。</sub>
|
|
47
73
|
</p>
|
|
48
74
|
|
|
49
75
|
[English](./README.en.md) | 中文
|
|
@@ -165,7 +191,7 @@
|
|
|
165
191
|
|
|
166
192
|
```sh
|
|
167
193
|
# dsh 不在 PATH 时,用 node ~/.dsh/profiles/node_modules/@deepseek-ai/dsh/lib/bin.js 代替 dsh
|
|
168
|
-
dsh plugin --profile desktop add dsh-xdpool
|
|
194
|
+
dsh plugin --profile desktop add @refeain/dsh-xdpool
|
|
169
195
|
```
|
|
170
196
|
|
|
171
197
|
> 推荐 npm:需要拉取的依赖只有插件自己(**约 1 个包,几秒搞定**)。
|
|
@@ -174,17 +200,17 @@ dsh plugin --profile desktop add dsh-xdpool
|
|
|
174
200
|
**方式二:从 GitHub 源码安装**
|
|
175
201
|
|
|
176
202
|
```sh
|
|
177
|
-
dsh plugin --profile desktop add github:
|
|
203
|
+
dsh plugin --profile desktop add github:Refeain/dsh-xdpool
|
|
178
204
|
```
|
|
179
205
|
|
|
180
206
|
**方式三:手动注册 bundle**
|
|
181
207
|
|
|
182
208
|
```sh
|
|
183
209
|
# 1) 先装包(npm 或 GitHub 任选)
|
|
184
|
-
dsh plugin --profile desktop add dsh-xdpool
|
|
210
|
+
dsh plugin --profile desktop add @refeain/dsh-xdpool
|
|
185
211
|
|
|
186
212
|
# 2) 注册 bundle:编辑 ~/.dsh/profiles/desktop/package.json,
|
|
187
|
-
# 在 "dsh" → "profile" → "bundles" 数组末尾加上 "dsh-xdpool"
|
|
213
|
+
# 在 "dsh" → "profile" → "bundles" 数组末尾加上 "@refeain/dsh-xdpool"
|
|
188
214
|
|
|
189
215
|
# 3) 重启 DSH Desktop
|
|
190
216
|
```
|
|
@@ -194,7 +220,7 @@ dsh plugin --profile desktop add dsh-xdpool
|
|
|
194
220
|
```sh
|
|
195
221
|
pnpm install
|
|
196
222
|
pnpm build # 产出 lib/index.js + lib/index.d.ts + lib/bin.js + lib/client.js
|
|
197
|
-
pnpm test #
|
|
223
|
+
pnpm test # 1753 项测试
|
|
198
224
|
pnpm typecheck # 宿主侧类型检查
|
|
199
225
|
pnpm typecheck:client # 客户端类型检查
|
|
200
226
|
```
|
|
@@ -242,17 +268,17 @@ agent-default-model:
|
|
|
242
268
|
|
|
243
269
|
## 命令行
|
|
244
270
|
|
|
245
|
-
统一用 `dsh plugin --profile desktop exec dsh-xdpool <子命令>` 调用:
|
|
271
|
+
统一用 `dsh plugin --profile desktop exec @refeain/dsh-xdpool <子命令>` 调用:
|
|
246
272
|
|
|
247
273
|
```sh
|
|
248
|
-
dsh plugin --profile desktop exec dsh-xdpool status # 池里几个号 / 几个冷却 + shim 状态(--credits 查积分、--json 机器可读、--rates 看倍率)
|
|
249
|
-
dsh plugin --profile desktop exec dsh-xdpool accounts # 已发现的账号(--json)
|
|
250
|
-
dsh plugin --profile desktop exec dsh-xdpool doctor # 诊断发现 / 冷却 / 上游连通性
|
|
251
|
-
dsh plugin --profile desktop exec dsh-xdpool reset # 立刻清掉所有 429 冷却
|
|
252
|
-
dsh plugin --profile desktop exec dsh-xdpool checkin # 查每个账号今天签到了没(--json 机器可读)
|
|
253
|
-
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
|
|
254
280
|
# 领掉所有账号今天的签到奖励;也可以只传一个账号标签领单个
|
|
255
|
-
dsh plugin --profile desktop exec dsh-xdpool login # 教你怎么在桌面再加一个号进池
|
|
281
|
+
dsh plugin --profile desktop exec @refeain/dsh-xdpool login # 教你怎么在桌面再加一个号进池
|
|
256
282
|
```
|
|
257
283
|
|
|
258
284
|
## 池里怎么多账号?
|
|
@@ -263,10 +289,10 @@ dsh plugin --profile desktop exec dsh-xdpool login # 教你怎么在桌面
|
|
|
263
289
|
|
|
264
290
|
```sh
|
|
265
291
|
# 在 WorkBuddy 桌面 App 登录账号后(key 自己起名):
|
|
266
|
-
dsh plugin --profile desktop exec dsh-xdpool import myKey
|
|
292
|
+
dsh plugin --profile desktop exec @refeain/dsh-xdpool import myKey
|
|
267
293
|
# 查看 / 删除已导入的快照:
|
|
268
|
-
dsh plugin --profile desktop exec dsh-xdpool accounts
|
|
269
|
-
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
|
|
270
296
|
```
|
|
271
297
|
|
|
272
298
|
导入的快照与自动保存的账号存在同一个目录 `~/.dsh/.xdpool/` 下,每次扫描都会被一并收进池——不再是「导入了但没人读」。快照以 key 的 **MD5 前 8 位**命名(key 本身记在文件里),中文、带 `/`、带空格的 key 都安全。长期使用靠 refresh token 自动续期;失效了就回桌面重新登录,再 `import <key> --force` 覆盖。
|
package/lib/bin.js
CHANGED
|
@@ -10857,6 +10857,53 @@ Object.freeze([
|
|
|
10857
10857
|
"jev-1.13-free"
|
|
10858
10858
|
]);
|
|
10859
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
|
|
10860
10907
|
//#region src/task-events.ts
|
|
10861
10908
|
/**
|
|
10862
10909
|
* The app the buddy chain enters.
|
|
@@ -11983,6 +12030,15 @@ var WorkBuddyScheduler = class {
|
|
|
11983
12030
|
* distinguishable from "0 tasks, everything already collected".
|
|
11984
12031
|
*/
|
|
11985
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 = [];
|
|
11986
12042
|
let progressNote;
|
|
11987
12043
|
try {
|
|
11988
12044
|
const revived = await this.pool.reviveBenched((credential) => this.client.fetchCredits(credential));
|
|
@@ -12066,6 +12122,9 @@ var WorkBuddyScheduler = class {
|
|
|
12066
12122
|
} catch (error) {
|
|
12067
12123
|
failed++;
|
|
12068
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}`);
|
|
12069
12128
|
}
|
|
12070
12129
|
if (index < accounts.length - 1 && this.delayMs > 0 && !this.stopped) await sleep(this.delayMs);
|
|
12071
12130
|
}
|
|
@@ -12080,6 +12139,8 @@ var WorkBuddyScheduler = class {
|
|
|
12080
12139
|
state.energy = energy;
|
|
12081
12140
|
state.claimed = claimed;
|
|
12082
12141
|
state.message = this.summarise(kind, ok, failed, claimed, credit, energy);
|
|
12142
|
+
if (failureNotes.length === 0) delete state.failures;
|
|
12143
|
+
else state.failures = failureNotes;
|
|
12083
12144
|
state.detail = detail;
|
|
12084
12145
|
state.items = items;
|
|
12085
12146
|
if (progressNote === void 0) delete state.progress;
|
package/lib/client.js
CHANGED
|
@@ -269,7 +269,7 @@ window.__ModuleLoader__.load({
|
|
|
269
269
|
const POOL_NAV_ICON_MASK_URL = `data:image/svg+xml;utf8,${encodeURIComponent(POOL_NAV_ICON_SVG)}`;
|
|
270
270
|
//#endregion
|
|
271
271
|
//#region src/version.ts
|
|
272
|
-
const POOL_VERSION = "3.0.
|
|
272
|
+
const POOL_VERSION = "3.0.9";
|
|
273
273
|
function compareVersions(left, right) {
|
|
274
274
|
const parse = (value) => {
|
|
275
275
|
const [core, ...rest] = value.trim().replace(/^v/u, "").split("-");
|
|
@@ -10314,7 +10314,7 @@ window.__ModuleLoader__.load({
|
|
|
10314
10314
|
return "签到失败";
|
|
10315
10315
|
}
|
|
10316
10316
|
}
|
|
10317
|
-
function ChannelPoolSection({ t, active, onAddAccount, autoClaim, autoClaimBusy, onAutoClaim, autoClaimRunning, onAutoClaimRun, banner, regionCards }) {
|
|
10317
|
+
function ChannelPoolSection({ t, active, onAddAccount, autoClaim, autoClaimBusy, onAutoClaim, autoClaimRunning, onAutoClaimRun, autoClaimReport, autoClaimFailing, banner, regionCards }) {
|
|
10318
10318
|
const [ownActive, setOwnActive] = (0, react.useState)("");
|
|
10319
10319
|
const [loginState, setLoginState] = (0, react.useState)(void 0);
|
|
10320
10320
|
const loginAbort = (0, react.useRef)(void 0);
|
|
@@ -11640,6 +11640,11 @@ window.__ModuleLoader__.load({
|
|
|
11640
11640
|
(0, react_jsx_runtime.jsx)("span", {
|
|
11641
11641
|
className: "policy-hint",
|
|
11642
11642
|
children: t?.("channelpool.autoClaimHint") ?? "开着就会在后台领每天的积分,不用手动点。"
|
|
11643
|
+
}),
|
|
11644
|
+
autoClaimReport === void 0 ? null : (0, react_jsx_runtime.jsx)("span", {
|
|
11645
|
+
className: "sum-sub",
|
|
11646
|
+
...autoClaimFailing === true ? { "data-tone": "err" } : {},
|
|
11647
|
+
children: autoClaimReport
|
|
11643
11648
|
})
|
|
11644
11649
|
]
|
|
11645
11650
|
})]
|
|
@@ -16142,9 +16147,30 @@ window.__ModuleLoader__.load({
|
|
|
16142
16147
|
}
|
|
16143
16148
|
const AUTOMATION_POLL_MS = 2e3;
|
|
16144
16149
|
const AUTOMATION_POLL_ATTEMPTS = 90;
|
|
16150
|
+
const AUTOMATION_JOBS = [
|
|
16151
|
+
"checkin",
|
|
16152
|
+
"report",
|
|
16153
|
+
"tasks",
|
|
16154
|
+
"streak",
|
|
16155
|
+
"travel",
|
|
16156
|
+
"compensation"
|
|
16157
|
+
];
|
|
16145
16158
|
function hoursOrDefault(configured, fallback) {
|
|
16146
16159
|
return configured !== void 0 && configured.length > 0 ? [...configured] : [...fallback];
|
|
16147
16160
|
}
|
|
16161
|
+
function automationJobs(status) {
|
|
16162
|
+
const jobs = status?.automation?.jobs;
|
|
16163
|
+
if (jobs === void 0) return [];
|
|
16164
|
+
return AUTOMATION_JOBS.map((kind) => jobs[kind]);
|
|
16165
|
+
}
|
|
16166
|
+
const FAILURE_LINES_SHOWN = 2;
|
|
16167
|
+
function automationFailures(status) {
|
|
16168
|
+
const lines = automationJobs(status).flatMap((job) => job.failures ?? []);
|
|
16169
|
+
if (lines.length === 0) return void 0;
|
|
16170
|
+
const shown = lines.slice(0, FAILURE_LINES_SHOWN);
|
|
16171
|
+
const hidden = lines.length - shown.length;
|
|
16172
|
+
return hidden > 0 ? `${shown.join(" · ")} · +${String(hidden)}` : shown.join(" · ");
|
|
16173
|
+
}
|
|
16148
16174
|
const REGION_CARDS = ["cn", "global"];
|
|
16149
16175
|
function PoolCard({ t, settingsScope }) {
|
|
16150
16176
|
const settingsWritable = settingsScope?.getSnapshot().writable === true;
|
|
@@ -16602,6 +16628,8 @@ window.__ModuleLoader__.load({
|
|
|
16602
16628
|
onAutoClaimRun: () => {
|
|
16603
16629
|
runAutomationJob("cn");
|
|
16604
16630
|
},
|
|
16631
|
+
autoClaimReport: automationFailures(statusOf("cn")),
|
|
16632
|
+
autoClaimFailing: automationJobs(statusOf("cn")).some((job) => job.failed > 0),
|
|
16605
16633
|
banner: flash === void 0 && error === void 0 ? void 0 : (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [flash === void 0 ? null : (0, react_jsx_runtime.jsx)("p", {
|
|
16606
16634
|
className: "note",
|
|
16607
16635
|
children: flash
|
package/lib/index.d.ts
CHANGED
|
@@ -2540,6 +2540,19 @@ interface PoolWebAutomationJob {
|
|
|
2540
2540
|
claimed: number;
|
|
2541
2541
|
/** One-line summary of the last run. */
|
|
2542
2542
|
message?: string;
|
|
2543
|
+
/**
|
|
2544
|
+
* Why each failing account failed, one line per account, already redacted.
|
|
2545
|
+
*
|
|
2546
|
+
* `message` counts the failures; this names them. Before it existed the card
|
|
2547
|
+
* could say "4 accounts ok, 2 failed" and nothing else, so an account that
|
|
2548
|
+
* failed because the gateway has no check-in activity read exactly like one
|
|
2549
|
+
* whose token expired — two opposite pieces of advice at the same glance.
|
|
2550
|
+
*
|
|
2551
|
+
* Absent rather than empty when the last run had no failures: the card keys
|
|
2552
|
+
* its warning line off presence, and an empty array would keep a stale line
|
|
2553
|
+
* of red on screen after a clean run.
|
|
2554
|
+
*/
|
|
2555
|
+
failures?: readonly string[];
|
|
2543
2556
|
/**
|
|
2544
2557
|
* What the last run actually did, in the words of the task board.
|
|
2545
2558
|
*
|
|
@@ -3850,6 +3863,19 @@ interface AutomationJobState {
|
|
|
3850
3863
|
*/
|
|
3851
3864
|
progress?: string;
|
|
3852
3865
|
message?: string;
|
|
3866
|
+
/**
|
|
3867
|
+
* Why each failing account failed, one line per account, already redacted.
|
|
3868
|
+
*
|
|
3869
|
+
* `message` counts the failures; this names them. Without it the card could
|
|
3870
|
+
* say "4 accounts ok, 2 failed" and nothing else — and the reason lived only
|
|
3871
|
+
* in `logger.warn`, which on a desktop box goes to a log nobody opens. That
|
|
3872
|
+
* made "this gateway has no check-in activity" (waiting will never help)
|
|
3873
|
+
* indistinguishable from "the token expired" (sign in again works).
|
|
3874
|
+
*
|
|
3875
|
+
* Absent when the last run had no failures, rather than an empty array, so a
|
|
3876
|
+
* stale reason from a previous run cannot survive a clean one.
|
|
3877
|
+
*/
|
|
3878
|
+
failures?: readonly string[];
|
|
3853
3879
|
}
|
|
3854
3880
|
/**
|
|
3855
3881
|
* What the automation earned for ONE account today.
|
package/lib/index.js
CHANGED
|
@@ -29380,7 +29380,7 @@ function parseBody(body) {
|
|
|
29380
29380
|
*
|
|
29381
29381
|
* @module dsh-xdpool/version
|
|
29382
29382
|
*/
|
|
29383
|
-
const POOL_VERSION = "3.0.
|
|
29383
|
+
const POOL_VERSION = "3.0.9";
|
|
29384
29384
|
//#endregion
|
|
29385
29385
|
//#region src/update-check.ts
|
|
29386
29386
|
/**
|
|
@@ -29559,6 +29559,96 @@ function extractNotes(readme) {
|
|
|
29559
29559
|
return {};
|
|
29560
29560
|
}
|
|
29561
29561
|
//#endregion
|
|
29562
|
+
//#region src/diagnostics.ts
|
|
29563
|
+
/**
|
|
29564
|
+
* A startup trace this plugin owns.
|
|
29565
|
+
*
|
|
29566
|
+
* The host's own logs have moved between at least three directories across the
|
|
29567
|
+
* 0.1.x / 0.2.x / DSH NEXT lines, and on a machine with no outbound network
|
|
29568
|
+
* they are not always where anyone thinks to look. When a provider fails to
|
|
29569
|
+
* register, "the model picker does not list xdpool" is the only symptom the
|
|
29570
|
+
* user can report, and answering it needs the exact throw — so the plugin
|
|
29571
|
+
* writes one small append-only file next to the settings it already owns.
|
|
29572
|
+
*
|
|
29573
|
+
* Everything here is best-effort: a diagnostic that can crash the thing it is
|
|
29574
|
+
* diagnosing is worse than no diagnostic, so every path swallows its own
|
|
29575
|
+
* failure and returns a value the caller can log instead.
|
|
29576
|
+
*
|
|
29577
|
+
* @module dsh-xdpool/diagnostics
|
|
29578
|
+
*/
|
|
29579
|
+
/**
|
|
29580
|
+
* Cap the trace so a plugin that restarts in a loop cannot fill the disk.
|
|
29581
|
+
* Half a megabyte is roughly a month of restarts, which is far more than the
|
|
29582
|
+
* single boot this file is meant to explain.
|
|
29583
|
+
*/
|
|
29584
|
+
const MAX_BYTES = 524288;
|
|
29585
|
+
/** The file lives beside the settings store, so one directory explains both. */
|
|
29586
|
+
function startupLogPath() {
|
|
29587
|
+
const home = process.env.DSH_HOME !== void 0 && process.env.DSH_HOME !== "" ? process.env.DSH_HOME : homedir();
|
|
29588
|
+
return join(home, ".xdpool", "startup.log");
|
|
29589
|
+
}
|
|
29590
|
+
/**
|
|
29591
|
+
* Render any thrown value as one line of text.
|
|
29592
|
+
*
|
|
29593
|
+
* `String(error)` on a real `Error` collapses the stack to "Error: message",
|
|
29594
|
+
* which is exactly the part worth keeping; the object form (`{}` for a
|
|
29595
|
+
* structured clone, `[object Object]` for anything else) is what produced the
|
|
29596
|
+
* unreadable `{}` markers in this project's earlier logs.
|
|
29597
|
+
*/
|
|
29598
|
+
function describeError(error) {
|
|
29599
|
+
if (error instanceof Error) {
|
|
29600
|
+
const code = "code" in error && typeof error.code === "string" ? ` (${String(error.code)})` : "";
|
|
29601
|
+
return `${error.name}: ${error.message}${code}`;
|
|
29602
|
+
}
|
|
29603
|
+
if (typeof error === "string") return error;
|
|
29604
|
+
try {
|
|
29605
|
+
return JSON.stringify(error) ?? String(error);
|
|
29606
|
+
} catch {
|
|
29607
|
+
return String(error);
|
|
29608
|
+
}
|
|
29609
|
+
}
|
|
29610
|
+
/**
|
|
29611
|
+
* Append one timestamped line. Returns the text that was written, so a caller
|
|
29612
|
+
* that cannot write the file can still put the same words in the host log.
|
|
29613
|
+
*/
|
|
29614
|
+
function recordStartupNote(line) {
|
|
29615
|
+
const text = `${(/* @__PURE__ */ new Date()).toISOString()} ${line}`;
|
|
29616
|
+
try {
|
|
29617
|
+
const path = startupLogPath();
|
|
29618
|
+
mkdirSync(join(path, ".."), { recursive: true });
|
|
29619
|
+
try {
|
|
29620
|
+
if (statSync(path).size > MAX_BYTES) truncateSync(path, 0);
|
|
29621
|
+
} catch {}
|
|
29622
|
+
appendFileSync(path, `${text}\n`, "utf8");
|
|
29623
|
+
} catch {}
|
|
29624
|
+
return text;
|
|
29625
|
+
}
|
|
29626
|
+
//#endregion
|
|
29627
|
+
//#region src/redact.ts
|
|
29628
|
+
/**
|
|
29629
|
+
* Strip credential-shaped substrings out of text that is about to be shown to a
|
|
29630
|
+
* person, or written to a log line we do not control.
|
|
29631
|
+
*
|
|
29632
|
+
* The rules are deliberately narrow: they match the two shapes this plugin
|
|
29633
|
+
* actually carries around — a JWT, and a token passed as a query parameter —
|
|
29634
|
+
* rather than trying to guess at "secrets" in general. A redactor that also
|
|
29635
|
+
* eats ordinary prose is worse than none: the reader stops believing the
|
|
29636
|
+
* message, and the next failure gets pasted into an issue by hand.
|
|
29637
|
+
*
|
|
29638
|
+
* Shared on purpose. The status route and the automation scheduler both surface
|
|
29639
|
+
* upstream failures, and two copies of this logic drifting apart would mean the
|
|
29640
|
+
* same account failure reads one way on the card and another in the log.
|
|
29641
|
+
*
|
|
29642
|
+
* @module dsh-xdpool/redact
|
|
29643
|
+
*/
|
|
29644
|
+
/** `eyJ…` header.payload.signature — what an access or refresh token looks like. */
|
|
29645
|
+
const JWT = /\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b/gu;
|
|
29646
|
+
/** `?code=…` / `token=…` in a URL or a request echo. The key is kept, the value is not. */
|
|
29647
|
+
const QUERY_SECRET = /(\b(?:code|token|refresh_token|access_token)=)[^&\s]+/giu;
|
|
29648
|
+
function redactSecrets(text) {
|
|
29649
|
+
return text.replace(JWT, "[redacted token]").replace(QUERY_SECRET, "$1[redacted]");
|
|
29650
|
+
}
|
|
29651
|
+
//#endregion
|
|
29562
29652
|
//#region src/task-events.ts
|
|
29563
29653
|
/**
|
|
29564
29654
|
* The app the buddy chain enters.
|
|
@@ -30713,6 +30803,15 @@ var WorkBuddyScheduler = class {
|
|
|
30713
30803
|
* distinguishable from "0 tasks, everything already collected".
|
|
30714
30804
|
*/
|
|
30715
30805
|
const items = [];
|
|
30806
|
+
/**
|
|
30807
|
+
* One line per account that threw, already redacted.
|
|
30808
|
+
*
|
|
30809
|
+
* Kept beside `detail` rather than read back out of it because `summarise`
|
|
30810
|
+
* needs the reasons WITHOUT the account labels it already prefixes — and
|
|
30811
|
+
* because `detail` also carries success lines ("签到 +5"), which a
|
|
30812
|
+
* positional convention over a mixed list would eventually get wrong.
|
|
30813
|
+
*/
|
|
30814
|
+
const failureNotes = [];
|
|
30716
30815
|
let progressNote;
|
|
30717
30816
|
try {
|
|
30718
30817
|
const revived = await this.pool.reviveBenched((credential) => this.client.fetchCredits(credential));
|
|
@@ -30796,6 +30895,9 @@ var WorkBuddyScheduler = class {
|
|
|
30796
30895
|
} catch (error) {
|
|
30797
30896
|
failed++;
|
|
30798
30897
|
this.logger.warn?.(`automation ${accountWord} ${account.label} failed:`, error);
|
|
30898
|
+
const reason = redactSecrets(describeError(error)).slice(0, 200);
|
|
30899
|
+
detail.push(`${account.label} ${accountWord} failed: ${reason}`);
|
|
30900
|
+
failureNotes.push(`${account.label}: ${reason}`);
|
|
30799
30901
|
}
|
|
30800
30902
|
if (index < accounts.length - 1 && this.delayMs > 0 && !this.stopped) await sleep$1(this.delayMs);
|
|
30801
30903
|
}
|
|
@@ -30810,6 +30912,8 @@ var WorkBuddyScheduler = class {
|
|
|
30810
30912
|
state.energy = energy;
|
|
30811
30913
|
state.claimed = claimed;
|
|
30812
30914
|
state.message = this.summarise(kind, ok, failed, claimed, credit, energy);
|
|
30915
|
+
if (failureNotes.length === 0) delete state.failures;
|
|
30916
|
+
else state.failures = failureNotes;
|
|
30813
30917
|
state.detail = detail;
|
|
30814
30918
|
state.items = items;
|
|
30815
30919
|
if (progressNote === void 0) delete state.progress;
|
|
@@ -32140,7 +32244,6 @@ async function updateToLatest() {
|
|
|
32140
32244
|
}
|
|
32141
32245
|
//#endregion
|
|
32142
32246
|
//#region src/web-status.ts
|
|
32143
|
-
/** Redact token-like content before it crosses to the browser. */
|
|
32144
32247
|
/**
|
|
32145
32248
|
* A zeroed-out automation job record.
|
|
32146
32249
|
*
|
|
@@ -32156,8 +32259,9 @@ function emptyAutomationJob() {
|
|
|
32156
32259
|
claimed: 0
|
|
32157
32260
|
};
|
|
32158
32261
|
}
|
|
32262
|
+
/** Redact token-like content before it crosses to the browser. */
|
|
32159
32263
|
function safeMessage(error) {
|
|
32160
|
-
return (error instanceof Error ? error.message : String(error)).
|
|
32264
|
+
return redactSecrets(error instanceof Error ? error.message : String(error)).slice(0, 500);
|
|
32161
32265
|
}
|
|
32162
32266
|
function json(res, status, body) {
|
|
32163
32267
|
const payload = JSON.stringify(body);
|
|
@@ -33406,71 +33510,6 @@ function registerPoolStatusRoute(ctx, deps) {
|
|
|
33406
33510
|
}, "dsh-xdpool: Web status route");
|
|
33407
33511
|
}
|
|
33408
33512
|
//#endregion
|
|
33409
|
-
//#region src/diagnostics.ts
|
|
33410
|
-
/**
|
|
33411
|
-
* A startup trace this plugin owns.
|
|
33412
|
-
*
|
|
33413
|
-
* The host's own logs have moved between at least three directories across the
|
|
33414
|
-
* 0.1.x / 0.2.x / DSH NEXT lines, and on a machine with no outbound network
|
|
33415
|
-
* they are not always where anyone thinks to look. When a provider fails to
|
|
33416
|
-
* register, "the model picker does not list xdpool" is the only symptom the
|
|
33417
|
-
* user can report, and answering it needs the exact throw — so the plugin
|
|
33418
|
-
* writes one small append-only file next to the settings it already owns.
|
|
33419
|
-
*
|
|
33420
|
-
* Everything here is best-effort: a diagnostic that can crash the thing it is
|
|
33421
|
-
* diagnosing is worse than no diagnostic, so every path swallows its own
|
|
33422
|
-
* failure and returns a value the caller can log instead.
|
|
33423
|
-
*
|
|
33424
|
-
* @module dsh-xdpool/diagnostics
|
|
33425
|
-
*/
|
|
33426
|
-
/**
|
|
33427
|
-
* Cap the trace so a plugin that restarts in a loop cannot fill the disk.
|
|
33428
|
-
* Half a megabyte is roughly a month of restarts, which is far more than the
|
|
33429
|
-
* single boot this file is meant to explain.
|
|
33430
|
-
*/
|
|
33431
|
-
const MAX_BYTES = 524288;
|
|
33432
|
-
/** The file lives beside the settings store, so one directory explains both. */
|
|
33433
|
-
function startupLogPath() {
|
|
33434
|
-
const home = process.env.DSH_HOME !== void 0 && process.env.DSH_HOME !== "" ? process.env.DSH_HOME : homedir();
|
|
33435
|
-
return join(home, ".xdpool", "startup.log");
|
|
33436
|
-
}
|
|
33437
|
-
/**
|
|
33438
|
-
* Render any thrown value as one line of text.
|
|
33439
|
-
*
|
|
33440
|
-
* `String(error)` on a real `Error` collapses the stack to "Error: message",
|
|
33441
|
-
* which is exactly the part worth keeping; the object form (`{}` for a
|
|
33442
|
-
* structured clone, `[object Object]` for anything else) is what produced the
|
|
33443
|
-
* unreadable `{}` markers in this project's earlier logs.
|
|
33444
|
-
*/
|
|
33445
|
-
function describeError(error) {
|
|
33446
|
-
if (error instanceof Error) {
|
|
33447
|
-
const code = "code" in error && typeof error.code === "string" ? ` (${String(error.code)})` : "";
|
|
33448
|
-
return `${error.name}: ${error.message}${code}`;
|
|
33449
|
-
}
|
|
33450
|
-
if (typeof error === "string") return error;
|
|
33451
|
-
try {
|
|
33452
|
-
return JSON.stringify(error) ?? String(error);
|
|
33453
|
-
} catch {
|
|
33454
|
-
return String(error);
|
|
33455
|
-
}
|
|
33456
|
-
}
|
|
33457
|
-
/**
|
|
33458
|
-
* Append one timestamped line. Returns the text that was written, so a caller
|
|
33459
|
-
* that cannot write the file can still put the same words in the host log.
|
|
33460
|
-
*/
|
|
33461
|
-
function recordStartupNote(line) {
|
|
33462
|
-
const text = `${(/* @__PURE__ */ new Date()).toISOString()} ${line}`;
|
|
33463
|
-
try {
|
|
33464
|
-
const path = startupLogPath();
|
|
33465
|
-
mkdirSync(join(path, ".."), { recursive: true });
|
|
33466
|
-
try {
|
|
33467
|
-
if (statSync(path).size > MAX_BYTES) truncateSync(path, 0);
|
|
33468
|
-
} catch {}
|
|
33469
|
-
appendFileSync(path, `${text}\n`, "utf8");
|
|
33470
|
-
} catch {}
|
|
33471
|
-
return text;
|
|
33472
|
-
}
|
|
33473
|
-
//#endregion
|
|
33474
33513
|
//#region src/model-switch-bridge.ts
|
|
33475
33514
|
/**
|
|
33476
33515
|
* The lane id the host's picker uses for each region.
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@refeain/dsh-xdpool",
|
|
3
3
|
"displayName": "DSH XD Pool",
|
|
4
4
|
"description": "One DSH model pool for every free quota you have: merge all locally signed-in WorkBuddy accounts with auto-failover, sign in to 22 vendors by QR/web, aggregate 77 external vendors' keys, plus a usage dashboard, model routing, a local OpenAI-compatible gateway and a points-automation suite.",
|
|
5
|
-
"version": "3.0.
|
|
5
|
+
"version": "3.0.9",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "XDTrees",
|
|
8
8
|
"homepage": "https://github.com/XDTrees/dsh-xdpool#readme",
|