dsh-wtq-pool 1.0.1 → 1.0.2

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,22 @@
1
1
  # 更新说明
2
2
 
3
+ ## [1.0.2]
4
+
5
+ ### 修复
6
+
7
+ - 输入框积分弹层的「刷新」不再与读端自己的时限等长:该通道按面板整段 20 秒预算执行,慢速凭据读取会让点击以超时收场。现在按留出序列化余量的预算作答,未完成的探测仍写入缓存,下一次轮询即可读到。
8
+ - 设置保存里越界的 token 预算不再丢掉整批改动:字段自带与后端一致的上限,超限值在保存前被挡下,不再等到整份选择载荷被拒收后只报一句 `invalid selection payload`。
9
+ - 签到开关在小时框留有无效文本时仍可关闭,不再提示错误却把计时器留在运行状态。
10
+ - 面板框在加载过程中不再产生一次读取错误:读取若落在面板文档就位、内容尚未到达的瞬间,此前会取到空对象。
11
+
12
+ ### 改进
13
+
14
+ - 账号卡与设置卡维持单列堆叠,间距收紧,多数窗口不必滚动即可看全;签到日志框限高可滚动,新结果自动滚到可见处。
15
+ - 输入框积分弹层宽度随内容变化并对齐触发器右侧,高度上限连内边距一起计算;账号名过长时在列内截断并保留悬停提示。
16
+ - 在输入框弹层里切换账号后积分不再短暂显示成「—」,保存的账号选择不再被当成宿主的设置改动。
17
+ - 输入框弹层里选中账号那一行的压暗程度与账号前的圆点颜色写进插件自己的样式,不再取自宿主。
18
+ - 插件页承载面板的框高度改为跟随面板内容,最长约四个账号,账号更多时由面板自身滚动,不再固定成一个视口高度。
19
+
3
20
  ## [1.0.1]
4
21
 
5
22
  ### 修复
package/README.en.md CHANGED
@@ -1,34 +1,62 @@
1
- # WTQ Pool
1
+ <p align="center">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="https://github.com/chengzhi-c/dsh-wtq-pool/raw/main/docs/logo-dark.png">
4
+ <source media="(prefers-color-scheme: light)" srcset="https://github.com/chengzhi-c/dsh-wtq-pool/raw/main/docs/logo.png">
5
+ <img src="https://github.com/chengzhi-c/dsh-wtq-pool/raw/main/docs/logo.png" width="240" alt="WTQ Pool">
6
+ </picture>
7
+ </p>
8
+
9
+ <h1 align="center">WTQ Pool</h1>
10
+
11
+ <p align="center"><b>Use local WorkBuddy, Trae and Qoder sign-ins in DeepSeek Harness, with automatic failover when an account is rate-limited or out of quota.</b></p>
12
+
13
+ <p align="center">
14
+ <b>English</b> | <a href="README.md">简体中文</a>
15
+ </p>
16
+
17
+ <p align="center">
18
+ <a href="#install">Install</a> ·
19
+ <a href="#features">Features</a> ·
20
+ <a href="#settings">Settings</a> ·
21
+ <a href="CHANGELOG.md">Changelog</a> ·
22
+ <a href="https://github.com/chengzhi-c/dsh-wtq-pool/issues">Issues</a>
23
+ </p>
24
+
25
+ <p align="center">
26
+ <a href="https://www.npmjs.com/package/dsh-wtq-pool"><img src="https://img.shields.io/npm/v/dsh-wtq-pool?style=flat-square&amp;label=npm&amp;color=cb3837" alt="npm version"></a>
27
+ <a href="https://www.npmjs.com/package/dsh-wtq-pool"><img src="https://img.shields.io/npm/d18m/dsh-wtq-pool?style=flat-square&amp;label=downloads&amp;color=cb3837" alt="npm downloads"></a>
28
+ <a href="LICENSE"><img src="https://img.shields.io/github/license/chengzhi-c/dsh-wtq-pool?style=flat-square" alt="MIT license"></a>
29
+ <a href="https://github.com/chengzhi-c/dsh-wtq-pool/releases"><img src="https://img.shields.io/github/v/release/chengzhi-c/dsh-wtq-pool?style=flat-square&amp;label=release" alt="release"></a>
30
+ <a href="https://github.com/chengzhi-c/dsh-wtq-pool/stargazers"><img src="https://img.shields.io/github/stars/chengzhi-c/dsh-wtq-pool?style=flat-square" alt="GitHub stars"></a>
31
+ </p>
2
32
 
3
33
  Use local WorkBuddy, Trae and Qoder desktop sign-ins in DeepSeek Harness. WorkBuddy fails over when an account is rate-limited or out of quota; Trae and Qoder select an account per request and do not guarantee retries after failure. Each source has its own switch, with domestic and international accounts grouped separately.
4
34
 
5
- [中文文档](./README.md)
6
-
7
35
  ## Preview
8
36
 
9
37
  The settings panel, in its default light theme:
10
38
 
11
- ![Account pool](docs/preview-pool.png)
39
+ ![Account pool](https://github.com/chengzhi-c/dsh-wtq-pool/raw/main/docs/preview-pool.png)
12
40
 
13
41
  The panel reads DeepSeek Harness's appearance setting on load. Reload the panel after changing the host theme:
14
42
 
15
- ![Dark theme](docs/preview-dark.png)
43
+ ![Dark theme](https://github.com/chengzhi-c/dsh-wtq-pool/raw/main/docs/preview-dark.png)
16
44
 
17
45
  The model page edits the display name, context window, output limit, thinking levels and image support. A Trae model whose directory states a rate carries a cost tag such as `x0.79`; models that state none (and every Qoder model) stay unlabelled:
18
46
 
19
- ![Model settings](docs/preview-models.png)
47
+ ![Model settings](https://github.com/chengzhi-c/dsh-wtq-pool/raw/main/docs/preview-models.png)
20
48
 
21
49
  Live preview: <https://chengzhi-c.github.io/dsh-wtq-pool/>.
22
50
 
23
51
  `docs/index.html` loads the actual panel code with synthetic demo data. It supports source switching, model settings and theme previews without reading local accounts or tokens.
24
52
 
25
- ![Preview page](docs/preview-page.png)
53
+ ![Preview page](https://github.com/chengzhi-c/dsh-wtq-pool/raw/main/docs/preview-page.png)
26
54
 
27
55
  With `showComposerPoints` enabled, the composer shows the current model's account credits. Click it to inspect the group and switch accounts. The image below is an off-screen render of the actual composer extension, not a conversation-test screenshot:
28
56
 
29
- ![Composer credits](docs/preview-composer.png)
57
+ ![Composer credits](https://github.com/chengzhi-c/dsh-wtq-pool/raw/main/docs/preview-composer.png)
30
58
 
31
- Run it locally: `node docs/serve.cjs`, then open the address it prints. (`docs/index.html` has to be served over http: a `file://` page cannot read the panel files beside it.)
59
+ Run it locally after cloning the repo: `node docs/serve.cjs`, then open the address it prints. (`docs/index.html` has to be served over http: a `file://` page cannot read the panel files beside it.)
32
60
 
33
61
  ## Features
34
62
 
@@ -44,7 +72,7 @@ Run it locally: `node docs/serve.cjs`, then open the address it prints. (`docs/i
44
72
  For a local package, run `pnpm install && pnpm run build && npm pack --pack-destination dist` in the source directory, then install the generated `.tgz`:
45
73
 
46
74
  ```powershell
47
- $package = (Resolve-Path .\dist\dsh-wtq-pool-1.0.1.tgz).Path
75
+ $package = (Resolve-Path .\dist\dsh-wtq-pool-1.0.2.tgz).Path
48
76
  dsh plugin --profile desktop add $package
49
77
  ```
50
78
 
package/README.md CHANGED
@@ -1,35 +1,62 @@
1
- # WTQ账号池
1
+ <p align="center">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="https://github.com/chengzhi-c/dsh-wtq-pool/raw/main/docs/logo-dark.png">
4
+ <source media="(prefers-color-scheme: light)" srcset="https://github.com/chengzhi-c/dsh-wtq-pool/raw/main/docs/logo.png">
5
+ <img src="https://github.com/chengzhi-c/dsh-wtq-pool/raw/main/docs/logo.png" width="240" alt="WTQ账号池">
6
+ </picture>
7
+ </p>
8
+
9
+ <h1 align="center">WTQ账号池</h1>
10
+
11
+ <p align="center"><b>把本机已登录的 WorkBuddy、Trae、Qoder 账号接入 DeepSeek Harness,限流或额度用尽时自动换号。</b></p>
12
+
13
+ <p align="center">
14
+ <a href="README.en.md">English</a> | <b>简体中文</b>
15
+ </p>
16
+
17
+ <p align="center">
18
+ <a href="#安装">安装</a> ·
19
+ <a href="#功能">功能</a> ·
20
+ <a href="#设置">设置</a> ·
21
+ <a href="CHANGELOG.md">更新日志</a> ·
22
+ <a href="https://github.com/chengzhi-c/dsh-wtq-pool/issues">问题反馈</a>
23
+ </p>
24
+
25
+ <p align="center">
26
+ <a href="https://www.npmjs.com/package/dsh-wtq-pool"><img src="https://img.shields.io/npm/v/dsh-wtq-pool?style=flat-square&amp;label=npm&amp;color=cb3837" alt="npm version"></a>
27
+ <a href="https://www.npmjs.com/package/dsh-wtq-pool"><img src="https://img.shields.io/npm/d18m/dsh-wtq-pool?style=flat-square&amp;label=downloads&amp;color=cb3837" alt="npm downloads"></a>
28
+ <a href="LICENSE"><img src="https://img.shields.io/github/license/chengzhi-c/dsh-wtq-pool?style=flat-square" alt="MIT license"></a>
29
+ <a href="https://github.com/chengzhi-c/dsh-wtq-pool/releases"><img src="https://img.shields.io/github/v/release/chengzhi-c/dsh-wtq-pool?style=flat-square&amp;label=release" alt="release"></a>
30
+ <a href="https://github.com/chengzhi-c/dsh-wtq-pool/stargazers"><img src="https://img.shields.io/github/stars/chengzhi-c/dsh-wtq-pool?style=flat-square" alt="GitHub stars"></a>
31
+ </p>
2
32
 
3
33
  把本机 WorkBuddy、Trae、Qoder 的桌面登录接入 DeepSeek Harness。WorkBuddy 被限流或额度用尽时自动换号;Trae、Qoder 按请求选择账号,不保证失败后重试。三个来源独立开关,国内与国际账号分别成组。
4
34
 
5
- [English](./README.en.md)
6
-
7
35
  ## 预览
8
36
 
9
37
  设置面板界面如下(默认亮色):
10
38
 
11
- ![账号池](docs/preview-pool.png)
39
+ ![账号池](https://github.com/chengzhi-c/dsh-wtq-pool/raw/main/docs/preview-pool.png)
12
40
 
13
41
  面板载入时读取 DeepSeek Harness 的外观设置;宿主切换主题后须重新载入面板:
14
42
 
15
- ![暗色主题](docs/preview-dark.png)
43
+ ![暗色主题](https://github.com/chengzhi-c/dsh-wtq-pool/raw/main/docs/preview-dark.png)
16
44
 
17
45
  模型页可以改显示名、上下文窗口、输出上限、思考等级和贴图。Trae 目录给出费率的模型会带上 `x0.79` 这样的费率标签,未给出费率的模型(以及 Qoder 全部模型)不标注:
18
46
 
19
- ![模型设置](docs/preview-models.png)
47
+ ![模型设置](https://github.com/chengzhi-c/dsh-wtq-pool/raw/main/docs/preview-models.png)
20
48
 
21
49
  在线预览:<https://chengzhi-c.github.io/dsh-wtq-pool/>。
22
50
 
23
51
  `docs/index.html` 加载实际面板代码并使用虚构演示数据,支持来源切换、模型设置和主题预览,不读取本机账号或令牌。
24
52
 
25
- ![预览页](docs/preview-page.png)
53
+ ![预览页](https://github.com/chengzhi-c/dsh-wtq-pool/raw/main/docs/preview-page.png)
26
54
 
27
55
  开启 `showComposerPoints` 后,输入区显示当前模型的账号积分,点击可查看该组账号并切换账号。下图由实际输入框扩展离屏渲染,非对话测试截图:
28
56
 
29
- ![输入框积分](docs/preview-composer.png)
57
+ ![输入框积分](https://github.com/chengzhi-c/dsh-wtq-pool/raw/main/docs/preview-composer.png)
30
58
 
31
- 本地运行:`node docs/serve.cjs`,然后打开它输出的地址。
32
- (`docs/index.html` 需经本地服务器打开:`file://` 页面无法读取同目录的面板文件。)
59
+ 本地预览需先克隆仓库,再运行 `node docs/serve.cjs` 并打开它输出的地址。该页面不能用 `file://` 打开,浏览器不允许它读取同目录的面板文件。
33
60
 
34
61
  ## 功能
35
62
 
@@ -45,7 +72,7 @@
45
72
  本地包:在源码目录执行 `pnpm install && pnpm run build && npm pack --pack-destination dist`,再安装生成的 `.tgz`:
46
73
 
47
74
  ```powershell
48
- $package = (Resolve-Path .\dist\dsh-wtq-pool-1.0.1.tgz).Path
75
+ $package = (Resolve-Path .\dist\dsh-wtq-pool-1.0.2.tgz).Path
49
76
  dsh plugin --profile desktop add $package
50
77
  ```
51
78
 
package/lib/client.js CHANGED
@@ -202,6 +202,15 @@ window.__ModuleLoader__.load({
202
202
  const PANEL_MARGIN = 8;
203
203
  /** The popup's own width cap, in px. */
204
204
  const PANEL_MAX_WIDTH = 360;
205
+ /**
206
+ * The width the popup is padded out to, in px.
207
+ *
208
+ * The stylesheet sizes the box to its contents, and a real row is only an
209
+ * address and a balance, so the box collapsed to roughly 220px and read as
210
+ * cramped next to the composer. A floor keeps that space without forcing the
211
+ * box wide for rows that do not need it.
212
+ */
213
+ const PANEL_MIN_WIDTH = 280;
205
214
  /** How tall the popup is allowed to get, in px. */
206
215
  const PANEL_MAX_HEIGHT = 320;
207
216
  /**
@@ -211,16 +220,27 @@ window.__ModuleLoader__.load({
211
220
  * the bottom of the window, so above is where the room is. Flipped below when
212
221
  * the trigger is near the top and the popup would not fit above it: a fixed
213
222
  * position is not scrolled into view by anything, so the rows above the trigger
214
- * would simply be cut off, and so would the popup's own first rows. The width is
215
- * capped to the window for the same reason, rather than trusting the viewport
216
- * to be wider than the stylesheet's own cap.
223
+ * would simply be cut off, and so would the popup's own first rows.
224
+ *
225
+ * Right-aligned by pinning `right`, not by a width this code would have to
226
+ * guess: the stylesheet sizes the box to its contents, so a two-column table of
227
+ * account and balance costs what it needs. A left edge plus a fixed width could
228
+ * only be right-aligned by knowing that width here, and the fixed 360px box it
229
+ * produced sat around rows that never filled it.
230
+ *
231
+ * The cap counts the column the right anchor already took, so the box stops at
232
+ * the window's left edge. Subtracting only the margin let a wide box hang past
233
+ * that edge whenever the trigger sat away from the right one.
217
234
  */
218
235
  function positionStyle(rect) {
219
- const width = typeof window === "undefined" ? PANEL_MAX_WIDTH : Math.max(0, Math.min(PANEL_MAX_WIDTH, window.innerWidth - 16));
220
236
  const above = rect.top - PANEL_MARGIN >= PANEL_MAX_HEIGHT;
237
+ const right = typeof window === "undefined" ? PANEL_MARGIN : Math.max(PANEL_MARGIN, window.innerWidth - rect.right);
238
+ const width = typeof window === "undefined" ? PANEL_MAX_WIDTH : Math.max(0, Math.min(PANEL_MAX_WIDTH, window.innerWidth - right - PANEL_MARGIN));
239
+ const floor = Math.min(PANEL_MIN_WIDTH, width);
221
240
  return {
222
- width: width + "px",
223
- left: Math.max(PANEL_MARGIN, rect.right - width) + "px",
241
+ right: right + "px",
242
+ minWidth: floor + "px",
243
+ maxWidth: width + "px",
224
244
  top: (above ? rect.top - PANEL_MARGIN : rect.bottom + PANEL_MARGIN) + "px",
225
245
  transform: above ? "translateY(-100%)" : void 0
226
246
  };
@@ -230,14 +250,28 @@ window.__ModuleLoader__.load({
230
250
  .xd-points-btn{border:0;background:transparent;color:inherit;font:inherit;font-size:12px;line-height:1;display:inline-flex;align-items:center;gap:5px;padding:4px 7px;border-radius:999px;cursor:pointer;max-width:220px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
231
251
  .xd-points-btn:hover{background:var(--dsw-alias-bg-layer-3,rgba(127,127,127,.12))}
232
252
  .xd-points-mark{display:inline-block;width:6px;height:6px;flex:0 0 auto;border-radius:50%;background:var(--dsw-alias-state-success-primary,#4f9f7c)}
233
- .xd-points-panel{position:fixed;z-index:40;min-width:240px;max-width:${PANEL_MAX_WIDTH}px;max-height:${PANEL_MAX_HEIGHT}px;overflow:auto;padding:8px;border-radius:12px;background:var(--dsw-alias-bg-layer-2,#1c1d21);color:var(--dsw-alias-label-primary,#e8e8ea);box-shadow:0 8px 28px rgba(0,0,0,.28);border:1px solid var(--dsw-alias-border-l2,rgba(127,127,127,.25))}
234
- .xd-points-table{width:100%;border-collapse:collapse;font-size:12px}
253
+ .xd-points-panel{position:fixed;z-index:40;box-sizing:border-box;width:max-content;max-width:${PANEL_MAX_WIDTH}px;max-height:${PANEL_MAX_HEIGHT}px;overflow:auto;padding:8px;border-radius:12px;background:var(--dsw-alias-bg-layer-2,#1c1d21);color:var(--dsw-alias-label-primary,#e8e8ea);box-shadow:0 8px 28px rgba(0,0,0,.28);border:1px solid var(--dsw-alias-border-l2,rgba(127,127,127,.25))}
254
+ .xd-points-table{width:100%;border-collapse:collapse;font-size:11px;line-height:1.4}
235
255
  .xd-points-table th{text-align:left;font-weight:600;padding:4px 6px;color:var(--dsw-alias-label-tertiary,#8b8d93)}
236
256
  .xd-points-table td{padding:4px 6px;vertical-align:top}
257
+ /* The row reuses the trigger's button, which is sized for a chip standing alone
258
+ in the composer: its 12px type, 1px leading and 220px cap all fight the cell,
259
+ and its padding would stack on the cell's and double the row's height. Those
260
+ are restated for the table, so the row follows the popup's own type and a long
261
+ account name is bounded by the cell instead of stretching the panel. */
262
+ .xd-points-table .xd-points-btn{font-size:inherit;line-height:inherit;padding:0;max-width:250px}
263
+ /* The selected row's name is a disabled button. The hosts disagree about how to
264
+ dim one - PI-Desktop has a global button:disabled rule that fades it, DeepSeek
265
+ Harness has none - so the fade is stated here and both read the same. */
266
+ .xd-points-table .xd-points-btn:disabled{opacity:.5}
267
+ /* A fixed green rather than the host's success token: that one resolves to a
268
+ saturated #22c55e here, which reads brighter than the same dot in the
269
+ PI-Desktop build of this plugin. The two panels are one product, so they carry
270
+ one colour. */
271
+ .xd-points-dot{display:inline-block;width:6px;height:6px;margin-right:6px;border-radius:50%;background:#4f9f7c;vertical-align:middle}
237
272
  .xd-points-row{cursor:pointer}
238
273
  .xd-points-row:hover{background:var(--dsw-alias-bg-layer-3,rgba(127,127,127,.12))}
239
274
  .xd-points-row.is-active{cursor:default}
240
- .xd-points-dot{display:inline-block;width:6px;height:6px;margin-right:6px;border-radius:50%;background:var(--dsw-alias-state-success-primary,#4f9f7c);vertical-align:middle}
241
275
  .xd-points-packs{margin:2px 0 0;padding:0;list-style:none;color:var(--dsw-alias-label-tertiary,#8b8d93)}
242
276
  .xd-points-bar{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:6px}
243
277
  .xd-points-refresh{border:0;background:transparent;color:var(--dsw-alias-label-tertiary,#8b8d93);font:inherit;font-size:12px;padding:3px 8px;border-radius:999px;cursor:pointer}
@@ -458,6 +492,7 @@ window.__ModuleLoader__.load({
458
492
  }) : null, react.createElement("button", {
459
493
  type: "button",
460
494
  className: "xd-points-btn",
495
+ title: account.label ?? "",
461
496
  disabled: account.active === true || busy,
462
497
  onClick: () => pick(account)
463
498
  }, account.label ?? "—")), react.createElement("td", null, typeof account.total === "number" ? formatCredits(account.total) : account.plan ?? "—", points.source === "qoder" && Array.isArray(account.packages) ? react.createElement("ul", { className: "xd-points-packs" }, account.packages.map((pack, index) => react.createElement("li", { key: index }, packageText(pack, t)))) : null)))))) : null);
@@ -530,6 +565,7 @@ window.__ModuleLoader__.load({
530
565
  */
531
566
  function PanelCard({ t, view }) {
532
567
  const [generation, setGeneration] = react.useState(0);
568
+ const [measured, setMeasured] = react.useState(0);
533
569
  const frameRef = react.useRef(null);
534
570
  const appearance = react.useMemo(() => {
535
571
  if (typeof document === "undefined") return {
@@ -542,11 +578,24 @@ window.__ModuleLoader__.load({
542
578
  lang: root.lang === "" ? "zh-CN" : root.lang
543
579
  };
544
580
  }, [generation]);
581
+ react.useEffect(() => {
582
+ if (view === "summary") return void 0;
583
+ const frame = frameRef.current;
584
+ const measure = () => {
585
+ const doc = frame === null ? null : frame.contentDocument;
586
+ if (doc === null || doc.body === null) return;
587
+ const height = Math.min(FRAME_MAX_HEIGHT, doc.body.scrollHeight + FRAME_BORDER);
588
+ setMeasured((current) => current === height ? current : height);
589
+ };
590
+ const timer = window.setInterval(measure, 400);
591
+ return () => window.clearInterval(timer);
592
+ }, [view, generation]);
545
593
  if (view === "summary") return react.createElement("p", { style: SUMMARY_STYLE }, t("row.desc"));
546
594
  return react.createElement("section", { style: CARD_STYLE }, react.createElement("header", { style: HEAD_STYLE }, react.createElement("div", null, react.createElement("strong", null, t("card.title")), react.createElement("p", { style: HINT_STYLE }, t("card.hint"))), react.createElement("button", {
547
595
  type: "button",
548
596
  style: BUTTON_STYLE,
549
597
  onClick: () => {
598
+ setMeasured(0);
550
599
  setGeneration((value) => value + 1);
551
600
  const frame = frameRef.current;
552
601
  if (frame !== null) frame.src = panelUrl(appearance);
@@ -556,7 +605,11 @@ window.__ModuleLoader__.load({
556
605
  ref: frameRef,
557
606
  title: t("card.frameTitle"),
558
607
  src: panelUrl(appearance),
559
- style: FRAME_STYLE
608
+ style: measured === 0 ? FRAME_PENDING : {
609
+ ...FRAME_PENDING,
610
+ height: measured,
611
+ minHeight: 0
612
+ }
560
613
  }));
561
614
  }
562
615
  const SUMMARY_STYLE = {
@@ -584,14 +637,17 @@ window.__ModuleLoader__.load({
584
637
  flex: "0 0 auto",
585
638
  cursor: "pointer"
586
639
  };
587
- const FRAME_STYLE = {
640
+ const FRAME_PENDING = {
588
641
  width: "100%",
589
642
  height: "72vh",
590
643
  minHeight: 460,
591
644
  border: "1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.25))",
592
645
  borderRadius: 10,
593
- background: "transparent"
646
+ background: "transparent",
647
+ boxSizing: "border-box"
594
648
  };
649
+ const FRAME_BORDER = 2;
650
+ const FRAME_MAX_HEIGHT = 1900;
595
651
  /**
596
652
  * Register the card on the Plugins page.
597
653
  *
package/lib/index.d.ts CHANGED
@@ -81,15 +81,25 @@ interface Config {
81
81
  sourceDistributions?: Record<string, string>;
82
82
  }
83
83
  declare const Config: z<Config>;
84
+ /**
85
+ * The slice of `ctx.llm` this plugin uses.
86
+ *
87
+ * Declared structurally rather than imported so the same source still compiles
88
+ * against a host that predates one of the calls. The return types mirror the
89
+ * published handles: both registrations hand back a disposer (the real ones also
90
+ * carry `replace`, which this plugin does not use), and `registerModelDiscovery`
91
+ * returns the disposer the activation effect relies on. Calling any of them
92
+ * after the fiber is disposed throws, so a stale write cannot leave an orphan.
93
+ */
84
94
  interface LlmSeam {
85
- registerAdapter(providerIds: string[], adapter: unknown): (() => void) | undefined;
95
+ registerAdapter(providerIds: string[], adapter: unknown): () => void;
86
96
  registerConfigurableProviders(rows: Array<{
87
97
  provider: string;
88
98
  displayName: string;
89
99
  settingsNs: string;
90
100
  settingsPath: string[];
91
101
  declared: boolean;
92
- }>): (() => void) | undefined;
102
+ }>): () => void;
93
103
  registerModelDiscovery(ns: string, fn: (request: {
94
104
  provider?: string;
95
105
  }, signal?: AbortSignal) => Promise<Array<{
@@ -98,7 +108,7 @@ interface LlmSeam {
98
108
  contextWindow?: number;
99
109
  maxTokens?: number;
100
110
  inputModalities?: string[];
101
- }>>): void;
111
+ }>>): () => void;
102
112
  }
103
113
  interface SettingsService {
104
114
  configure?(presentation: {
package/lib/index.js CHANGED
@@ -157,7 +157,13 @@ function hostnameOfHost(host) {
157
157
  if (colon !== -1 && /^\d+$/.test(hostname.slice(colon + 1))) hostname = hostname.slice(0, colon);
158
158
  return hostname;
159
159
  }
160
- /** Host must name loopback; drops DNS-rebinding attempts before routing. */
160
+ /**
161
+ * Host must name loopback.
162
+ *
163
+ * Used by the gateway handlers. The panel routes rely on the peer and Origin
164
+ * checks instead: a browser that could reach the panel is already same-origin
165
+ * loopback, so a forged Host adds nothing there.
166
+ */
161
167
  function hostIsLoopback(host) {
162
168
  if (host === void 0 || host.trim() === "") return false;
163
169
  return LOOPBACK_HOSTS.has(hostnameOfHost(host));
@@ -637,7 +643,7 @@ function registerPanelRoutes(ctx, deps) {
637
643
  const ROW_ID = "llm-dsh-xdpool";
638
644
  //#endregion
639
645
  //#region package.json
640
- var version = "1.0.1";
646
+ var version = "1.0.2";
641
647
  //#endregion
642
648
  //#region src/upstream.ts
643
649
  /**
@@ -10068,21 +10074,22 @@ async function onPanelInvoke(channel, payload) {
10068
10074
  * The popup lists one route's accounts, so the refresh covers exactly those:
10069
10075
  * a WorkBuddy region drops its probe cache and reads it back, a Trae or Qoder
10070
10076
  * region re-probes each of its rows. The polled readout stays cache-only;
10071
- * this channel is the one the click is allowed to wait on.
10077
+ * this channel is the one the click is allowed to wait on, and it waits only
10078
+ * as long as the readout's own call deadline leaves room for the answer.
10072
10079
  */
10073
10080
  case "xd.composerRefresh": {
10074
10081
  const hit = matchComposerModel(payload);
10075
10082
  if (hit === void 0) return composerPoints(payload);
10083
+ const deadline = Date.now() + COMPOSER_REFRESH_BUDGET_MS;
10076
10084
  if (hit.source === "workbuddy") {
10077
10085
  for (const account of core.pool.list(hit.region)) probeCache.delete(account.id);
10078
10086
  await settleWithin(statusDocument({
10079
10087
  allowNetwork: true,
10080
- budgetMs: PANEL_STEP_BUDGET_MS
10081
- }), PANEL_STEP_BUDGET_MS);
10088
+ budgetMs: COMPOSER_REFRESH_BUDGET_MS
10089
+ }), COMPOSER_REFRESH_BUDGET_MS);
10082
10090
  } else {
10083
10091
  const rows = hit.source === "trae" ? traeAccountRows : qoderAccountRows;
10084
10092
  const found = hit.source === "trae" ? await discoverTraeCredentials() : await discoverQoderCredentials();
10085
- const deadline = Date.now() + SOURCE_ACCOUNTS_BUDGET_MS;
10086
10093
  for (const row of rows) {
10087
10094
  if (row.region !== hit.region) continue;
10088
10095
  if (Date.now() >= deadline) break;
@@ -10092,7 +10099,6 @@ async function onPanelInvoke(channel, payload) {
10092
10099
  return itemLabel === row.label && itemRegion === row.region;
10093
10100
  });
10094
10101
  if (credential === void 0) continue;
10095
- if (credential === void 0) continue;
10096
10102
  const probe = hit.source === "trae" ? await traeRowProbe(credential, row) : await qoderRowProbe(credential, row);
10097
10103
  if (probe?.usage) row.usage = probe.usage;
10098
10104
  if (probe?.checkin) row.checkin = probe.checkin;
@@ -10248,6 +10254,16 @@ const PANEL_STEP_BUDGET_MS = 2e4;
10248
10254
  * reads: `allowNetwork: true` still probes inside this share.
10249
10255
  */
10250
10256
  const DOCUMENT_BUDGET_MS = 4e3;
10257
+ /**
10258
+ * What the composer popup's refresh may spend before it answers.
10259
+ *
10260
+ * The readout's own call deadline is 20 s (`INVOKE_TIMEOUT_MS`), and the route
10261
+ * still has to serialize the answer inside it, so this pass stops short of the
10262
+ * full figure. Past it the popup keeps the figures it already has and its poll
10263
+ * picks up whatever the abandoned probe wrote, which is what keeps a slow
10264
+ * credentials read from turning the click into a client-side timeout.
10265
+ */
10266
+ const COMPOSER_REFRESH_BUDGET_MS = 15e3;
10251
10267
  /** The one line a check-in pass reports, whichever way it finished. */
10252
10268
  function checkinSummaryText(result) {
10253
10269
  if (result == null || result.running === true) return "WTQ Pool - a check-in pass is already running";
@@ -11408,15 +11424,33 @@ function apply(ctx, config = {}) {
11408
11424
  let disposeRegistration;
11409
11425
  let stopped = false;
11410
11426
  const settingsService = ctx.settings;
11427
+ /**
11428
+ * How many of this plugin's own settings writes are in flight.
11429
+ *
11430
+ * DSH answers a plugin's volatile write by emitting `loader/volatile-update`
11431
+ * back at the writer's own fiber, and the loader delivers it synchronously
11432
+ * inside `mutate`. So a save this plugin made arrives here looking exactly
11433
+ * like an edit from the host's settings UI, and treating it as one cleared the
11434
+ * whole credit cache: every account switch blanked the readout to `—` until a
11435
+ * warm-up poll refilled it. PI's host never echoes a plugin's own write, which
11436
+ * is why only this build showed it. The writer is the one place that can tell
11437
+ * the two apart, so the echo is dropped here instead of guessed at downstream.
11438
+ */
11439
+ let writesInFlight = 0;
11411
11440
  /** Replace patched top-level fields without merging their dictionaries. */
11412
11441
  const writeSettings = async (patch) => {
11413
11442
  const mutate = settingsService?.mutate;
11414
11443
  if (mutate === void 0) throw new Error("this host exposes no settings mutate()");
11415
- await mutate.call(settingsService, settingsNamespace, Object.entries(patch).map(([key, value]) => ({
11416
- op: "set",
11417
- path: [key],
11418
- value
11419
- })));
11444
+ writesInFlight += 1;
11445
+ try {
11446
+ await mutate.call(settingsService, settingsNamespace, Object.entries(patch).map(([key, value]) => ({
11447
+ op: "set",
11448
+ path: [key],
11449
+ value
11450
+ })));
11451
+ } finally {
11452
+ writesInFlight -= 1;
11453
+ }
11420
11454
  };
11421
11455
  installPi({
11422
11456
  getSettings: () => current(),
@@ -11427,7 +11461,10 @@ function apply(ctx, config = {}) {
11427
11461
  return dir;
11428
11462
  },
11429
11463
  onSettingsChanged: (handler) => {
11430
- const listener = () => handler(current());
11464
+ const listener = () => {
11465
+ if (writesInFlight > 0) return;
11466
+ handler(current());
11467
+ };
11431
11468
  const dispose = ctx.on("loader/volatile-update", listener);
11432
11469
  if (typeof dispose === "function") unsubscribes.push(dispose);
11433
11470
  else unsubscribes.push(() => ctx.off?.("loader/volatile-update", listener));
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "dsh-wtq-pool",
3
3
  "displayName": "WTQ Pool",
4
4
  "description": "把本机 WorkBuddy、Trae、Qoder 的桌面登录接进 DeepSeek Harness。WorkBuddy 被限流时自动换号。三家各有开关,国内与国际各自成组。",
5
- "version": "1.0.1",
5
+ "version": "1.0.2",
6
6
  "license": "MIT",
7
7
  "author": "chengzhi-c",
8
8
  "homepage": "https://github.com/chengzhi-c/dsh-wtq-pool#readme",
@@ -42,7 +42,6 @@
42
42
  "files": [
43
43
  "lib",
44
44
  "renderer",
45
- "docs",
46
45
  "cordis.patch.yml",
47
46
  "README.md",
48
47
  "README.en.md",
@@ -219,12 +219,18 @@ html::-webkit-scrollbar-thumb { border-radius: 4px; background: color-mix(in srg
219
219
  caption. The same quiet surface the panel uses elsewhere, so it reads as part
220
220
  of the card without competing with the controls above it. */
221
221
  .log-box {
222
- margin: 10px 0 0;
223
- padding: 8px 10px;
222
+ margin: 8px 0 0;
223
+ padding: 7px 10px;
224
224
  border: 1px solid var(--xd-line);
225
225
  border-radius: var(--xd-radius-small);
226
226
  background: var(--xd-softer);
227
227
  font-size: 12.5px;
228
+ /* A pass over three sources plus their retries is a long list, and an
229
+ unbounded log pushed everything below it off the page. The box scrolls on
230
+ its own instead. Five rows exactly: a cap that falls inside a line would
231
+ leave half a sentence showing. */
232
+ max-height: 120px;
233
+ overflow-y: auto;
228
234
  }
229
235
  /* One source per line, so a pass over three of them reads down the box instead
230
236
  of across it. */
@@ -464,20 +470,19 @@ button.park:hover:not(:disabled) { filter: brightness(1.08); background: var(--x
464
470
 
465
471
  /* A non-pool source's own section: its own accounts, quota, and check-in pool,
466
472
  stacked the way the pool's cards are — a titled block, not one crowded line. */
467
- .source-group { margin-bottom: 12px; }
473
+ .source-group { margin-bottom: 10px; }
468
474
  .source-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
469
475
  .source-head strong { font-variant-numeric: tabular-nums; }
470
476
  .source-head .checkin-all { margin-left: auto; }
471
477
  .source-accounts .card { margin-bottom: 8px; }
472
478
  .source-foot { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12.5px; margin-top: 4px; }
473
479
 
474
-
475
480
  .card {
476
481
  border: 1px solid var(--xd-border);
477
482
  border-radius: var(--xd-radius);
478
483
  background: var(--xd-card);
479
- padding: 14px 16px;
480
- margin-bottom: 12px;
484
+ padding: 12px 14px;
485
+ margin-bottom: 10px;
481
486
  }
482
487
 
483
488
  .card-head {
@@ -595,7 +600,7 @@ button.park:hover:not(:disabled) { filter: brightness(1.08); background: var(--x
595
600
  .credits:not(.open) .credits-head .caret { transform: rotate(0deg); }
596
601
 
597
602
  .credit-total {
598
- font-size: 24px;
603
+ font-size: 20px;
599
604
  font-weight: 700;
600
605
  color: var(--xd-fg);
601
606
  font-variant-numeric: tabular-nums;
package/renderer/panel.js CHANGED
@@ -1512,6 +1512,10 @@ function paintAutoNote(host, auto) {
1512
1512
  line.appendChild(el("span", "log-text", row.text));
1513
1513
  host.appendChild(line);
1514
1514
  });
1515
+ // The log is a scroll region capped at a few rows, so a fresh pass would
1516
+ // otherwise leave the newest line - the one the user just waited for - below
1517
+ // the fold.
1518
+ host.scrollTop = host.scrollHeight;
1515
1519
  }
1516
1520
  function renderAccounts() {
1517
1521
  var host = $("accounts");
@@ -2579,16 +2583,25 @@ function modelSheetBody(model, entry) {
2579
2583
  }
2580
2584
 
2581
2585
 
2586
+ /**
2587
+ * The ceiling the host enforces on a token budget (`MAX_TOKEN_BUDGET`).
2588
+ *
2589
+ * A number past it invalidates the whole selection payload there, so the save
2590
+ * drops every edit in this pass rather than clamping one field. Keeping the
2591
+ * bound in the browser means the field itself refuses the value.
2592
+ */
2593
+ var MAX_TOKEN_BUDGET = 0xffffffff;
2582
2594
  function numberInput(value, onChange) {
2583
2595
  var input = document.createElement("input");
2584
2596
  input.type = "number";
2585
2597
  input.className = "num-input";
2598
+ input.max = String(MAX_TOKEN_BUDGET);
2586
2599
  input.min = "1";
2587
2600
  input.step = "1000";
2588
2601
  input.value = String(value);
2589
2602
  input.addEventListener("change", function () {
2590
2603
  var next = Number(input.value);
2591
- if (!Number.isFinite(next) || next <= 0) {
2604
+ if (!Number.isFinite(next) || next <= 0 || next > MAX_TOKEN_BUDGET) {
2592
2605
  input.value = String(value);
2593
2606
  return;
2594
2607
  }
@@ -2973,8 +2986,15 @@ function parseCheckinHours(text) {
2973
2986
  /** Switch the daily automatic check-in, or move its hours, in one request. */
2974
2987
  function setAutoCheckin(enabled, hours) {
2975
2988
  if (hours === null) {
2976
- note(t("auto.badHours"));
2977
- return Promise.resolve();
2989
+ // Only switching ON needs a readable hour list. Switching OFF must not: the
2990
+ // box can hold stale invalid text from an earlier edit, and bailing out there
2991
+ // leaves the timer running while the panel reports the schedule as off.
2992
+ if (enabled === true) {
2993
+ note(t("auto.badHours"));
2994
+ return Promise.resolve();
2995
+ }
2996
+ var current = state && state.autoCheckin && state.autoCheckin.hours;
2997
+ hours = Array.isArray(current) ? current : [];
2978
2998
  }
2979
2999
  return runBusy("autoCheckin", function () {
2980
3000
  return invoke("xd.setAutoCheckin", { enabled: enabled === true, hours: hours });