dsh-wtq-pool 1.3.0 → 1.3.6

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/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。限流或额度用尽时自动换号,三家各自开关,国内与国际账号分别成组。",
5
- "version": "1.3.0",
5
+ "version": "1.3.6",
6
6
  "license": "MIT",
7
7
  "author": "chengzhi-c",
8
8
  "homepage": "https://github.com/chengzhi-c/dsh-wtq-pool#readme",
@@ -46,7 +46,8 @@
46
46
  "README.md",
47
47
  "README.en.md",
48
48
  "CHANGELOG.md",
49
- "LICENSE"
49
+ "LICENSE",
50
+ "THIRD-PARTY-NOTICES.md"
50
51
  ],
51
52
  "scripts": {
52
53
  "build": "node -e \"require('node:fs').rmSync('lib',{recursive:true,force:true})\" && tsdown",
@@ -80,7 +81,9 @@
80
81
  "@earendil-works/pi-ai": "1.5.0",
81
82
  "@types/node": "^22.20.0",
82
83
  "@types/react": "~18.3.31",
84
+ "@types/react-dom": "18.3.7",
83
85
  "react": "^18.3.1",
86
+ "react-dom": "18.3.1",
84
87
  "tsdown": "^0.22.2",
85
88
  "typescript": "^5.9.3"
86
89
  },
@@ -38,11 +38,11 @@
38
38
  every view below, so the three sources never mix on one screen. The risk
39
39
  note shares their line: it applies to whichever of the three is chosen. -->
40
40
  <div class="tabs-row">
41
- <nav class="tabs" id="sourceTabs" role="tablist">
42
- <button type="button" class="tab active" data-source="workbuddy" role="tab" aria-selected="true">WorkBuddy</button>
43
- <button type="button" class="tab" data-source="trae" role="tab" aria-selected="false">Trae</button>
44
- <button type="button" class="tab" data-source="qoder" role="tab" aria-selected="false">Qoder</button>
45
- </nav>
41
+ <div class="tabs" id="sourceTabs" role="group" aria-label="Account source">
42
+ <button type="button" class="tab active" data-source="workbuddy" aria-pressed="true">WorkBuddy</button>
43
+ <button type="button" class="tab" data-source="trae" aria-pressed="false">Trae</button>
44
+ <button type="button" class="tab" data-source="qoder" aria-pressed="false">Qoder</button>
45
+ </div>
46
46
  <p class="tab-risk" id="riskNote"></p>
47
47
  </div>
48
48
 
@@ -51,17 +51,17 @@
51
51
  <p class="hint" id="hostHint" hidden></p>
52
52
 
53
53
  <!-- Second level: the three views of the selected source. -->
54
- <nav class="subtabs" id="viewTabs" role="tablist">
55
- <button type="button" class="subtab active" id="view-pool" data-tab="pool" role="tab" aria-controls="poolView" aria-selected="true"></button>
56
- <button type="button" class="subtab" id="view-models" data-tab="models" role="tab" aria-controls="modelsView" aria-selected="false"></button>
57
- <button type="button" class="subtab" id="view-check" data-tab="check" role="tab" aria-controls="checkView" aria-selected="false"></button>
58
- <button type="button" class="subtab" id="view-growth" data-tab="growth" role="tab" aria-controls="growthView" aria-selected="false"></button>
54
+ <nav class="subtabs" id="viewTabs" role="tablist" aria-label="Panel view">
55
+ <button type="button" class="subtab active" id="view-pool" data-tab="pool" role="tab" aria-controls="poolView" aria-selected="true" tabindex="0"></button>
56
+ <button type="button" class="subtab" id="view-models" data-tab="models" role="tab" aria-controls="modelsView" aria-selected="false" tabindex="-1"></button>
57
+ <button type="button" class="subtab" id="view-check" data-tab="check" role="tab" aria-controls="checkView" aria-selected="false" tabindex="-1"></button>
58
+ <button type="button" class="subtab" id="view-growth" data-tab="growth" role="tab" aria-controls="growthView" aria-selected="false" tabindex="-1"></button>
59
59
  </nav>
60
60
 
61
61
  <section id="poolView" class="view" role="tabpanel" aria-labelledby="view-pool">
62
62
  <div class="source-group" data-source="workbuddy">
63
63
  <div class="source-head" id="workbuddyHead"></div>
64
- <nav class="regions" id="regionTabs" role="tablist"></nav>
64
+ <div class="regions" id="regionTabs" role="group" aria-label="Region"></div>
65
65
  <div class="strip" id="poolStrip"></div>
66
66
  <div id="accounts"></div>
67
67
  </div>
@@ -120,7 +120,7 @@
120
120
  columns below are shared. What differs - which roster, which stored
121
121
  selection, which gateway the save writes - is answered in panel.js,
122
122
  so Trae and Qoder get the pool's own editor instead of a copy. -->
123
- <nav class="regions" id="modelRegionTabs" role="tablist"></nav>
123
+ <div class="regions" id="modelRegionTabs" role="group" aria-label="Region"></div>
124
124
  <!-- Two columns: the roster on the left, the settings of the ticked
125
125
  models on the right. The grid collapses to one column (roster above
126
126
  settings) once the window is dragged narrower than 720px - see the
package/renderer/panel.js CHANGED
@@ -29,6 +29,9 @@ var EN = {
29
29
  "tab.models": "Models",
30
30
  "tab.check": "Connection check",
31
31
  "tab.growth": "Growth centre",
32
+ "tabs.sources": "Account source",
33
+ "tabs.views": "Plugin views",
34
+ "tabs.regions": "Account region",
32
35
  "risk.note": "Unofficial clients may trigger account restrictions. Follow each vendor's terms of service.",
33
36
  "host.missing": "The host has not registered {count} model group(s) from this plugin yet: reload the plugin.",
34
37
  "btn.rescan": "Detect accounts again",
@@ -72,6 +75,7 @@ var EN = {
72
75
  "login.openAgain": "Open the link again",
73
76
  "login.waiting": "Finish the sign-in in your browser; this panel picks the account up by itself.",
74
77
  "login.timeout": "The sign-in did not finish. Start again for a new link.",
78
+ "login.noLink": "The plugin did not return a sign-in link.",
75
79
  "login.added": "Added {name}",
76
80
  "login.addedNoName": "Account added",
77
81
  "trae.title": "Trae",
@@ -316,6 +320,9 @@ var ZH = {
316
320
  "tab.models": "模型",
317
321
  "tab.check": "连接检查",
318
322
  "tab.growth": "成长中心",
323
+ "tabs.sources": "账号来源",
324
+ "tabs.views": "插件页面",
325
+ "tabs.regions": "账号区域",
319
326
  "risk.note": "非官方客户端可能触发账号风控,请遵守厂商服务条款。",
320
327
  "host.missing": "宿主还没有注册本插件的 {count} 个模型组:重新加载插件。",
321
328
  "btn.rescan": "重新检测账号",
@@ -359,6 +366,7 @@ var ZH = {
359
366
  "login.openAgain": "再打开一次链接",
360
367
  "login.waiting": "在浏览器里完成登录即可,面板会自己把这个账号收进来。",
361
368
  "login.timeout": "登录没有完成。重新开始一次拿新链接。",
369
+ "login.noLink": "插件没有返回登录链接。",
362
370
  "login.added": "已添加 {name}",
363
371
  "login.addedNoName": "账号已添加",
364
372
  "trae.title": "Trae",
@@ -954,7 +962,7 @@ function renderSourceTabs() {
954
962
  for (var i = 0; i < tabs.length; i += 1) {
955
963
  var on = tabs[i].getAttribute("data-source") === activeSource;
956
964
  tabs[i].classList.toggle("active", on);
957
- tabs[i].setAttribute("aria-selected", on ? "true" : "false");
965
+ tabs[i].setAttribute("aria-pressed", on ? "true" : "false");
958
966
  }
959
967
  var groups = document.querySelectorAll("#poolView .source-group");
960
968
  for (var j = 0; j < groups.length; j += 1) {
@@ -1055,15 +1063,14 @@ function sourceFoot(source) {
1055
1063
  */
1056
1064
  function fillRegionNav(nav, source, regions, accounts, active) {
1057
1065
  clear(nav);
1066
+ nav.setAttribute("role", "group");
1067
+ nav.setAttribute("aria-label", t("tabs.regions"));
1058
1068
  regions.forEach(function (region) {
1059
1069
  var on = region === active;
1060
1070
  var button = el("button", on ? "active" : "");
1061
1071
  button.type = "button";
1062
1072
  button.disabled = busy !== null;
1063
- button.setAttribute("role", "tab");
1064
- // A `tab` without `aria-selected` is invalid ARIA, and it is what a screen
1065
- // reader reads to say which one is current.
1066
- button.setAttribute("aria-selected", on ? "true" : "false");
1073
+ button.setAttribute("aria-pressed", on ? "true" : "false");
1067
1074
  button.textContent = sourceRegionLabel(region);
1068
1075
  if (regionParked(source, region)) button.appendChild(el("span", "muted", " " + t("region.parkedShort")));
1069
1076
  var count = accounts.filter(function (account) { return account.region === region; }).length;
@@ -1079,7 +1086,7 @@ function fillRegionNav(nav, source, regions, accounts, active) {
1079
1086
 
1080
1087
  /** A fresh region row for a page that is rebuilt on every render. */
1081
1088
  function sourceRegionNav(source, regions, accounts) {
1082
- return fillRegionNav(el("nav", "regions"), source, regions, accounts, activeRegionOf(source));
1089
+ return fillRegionNav(el("div", "regions"), source, regions, accounts, activeRegionOf(source));
1083
1090
  }
1084
1091
 
1085
1092
  /**
@@ -1604,7 +1611,7 @@ function startLogin() {
1604
1611
  render();
1605
1612
  invoke("xd.startLogin", { realm: realm }).then(function (answer) {
1606
1613
  loginUrl = answer && typeof answer.authUrl === "string" ? answer.authUrl : "";
1607
- if (loginUrl === "") throw new Error("the plugin did not return a login link");
1614
+ if (loginUrl === "") throw new Error(t("login.noLink"));
1608
1615
  // This page is a real browser tab, so the link opens the way its own footer
1609
1616
  // links do: a new tab, leaving the panel where it is.
1610
1617
  window.open(loginUrl, "_blank", "noopener,noreferrer");
@@ -1809,9 +1816,11 @@ function renderAutoCheckin() {
1809
1816
  // render the panel had ever drawn. The handler reads the hours field when it
1810
1817
  // runs, so binding it once in `bind` is enough.
1811
1818
  var run = $("autoRunNow");
1812
- run.textContent = busy === "checkin" ? t("auto.running") : t("auto.runNow");
1819
+ var pending = auto.last !== undefined && auto.last !== null && auto.last.pending === true;
1820
+ var passRunning = state !== null && state.growth !== undefined && state.growth !== null && state.growth.running === true;
1821
+ run.textContent = busy === "checkin" || pending || passRunning ? t("auto.running") : t("auto.runNow");
1813
1822
  run.title = t("auto.runNowHint");
1814
- run.disabled = busy !== null || checkinBusy !== null;
1823
+ run.disabled = busy !== null || checkinBusy !== null || pending || passRunning;
1815
1824
 
1816
1825
  // The keep-alive row: one button, run by hand. It is a static node, so the
1817
1826
  // handler lives in `bind`. Its own card, its own log: it renews tokens rather
@@ -2021,6 +2030,8 @@ function renderGrowth() {
2021
2030
  run.textContent = busy === "growth" ? t("growth.running") : t("growth.run");
2022
2031
  run.title = t("growth.runHint");
2023
2032
  run.disabled = busy !== null || running;
2033
+ if (running) pollGrowthRun();
2034
+ else stopGrowthPoll();
2024
2035
  $("growthText").textContent = growthStateText();
2025
2036
  paintGrowthAccounts($("growthAccounts"));
2026
2037
  $("growthHint").textContent = t("growth.hint");
@@ -2256,6 +2267,7 @@ function readGrowth() {
2256
2267
  /** Run the growth centre on its own. */
2257
2268
  function runGrowth() {
2258
2269
  if (busy !== null) return Promise.resolve();
2270
+ growthPollFailures = 0;
2259
2271
  return runBusy("growth", function () {
2260
2272
  return invoke("xd.growthRun").then(function (payload) {
2261
2273
  // The run answers with the document beside its own counts, and this card
@@ -2362,7 +2374,7 @@ function paintAccounts(host) {
2362
2374
  }
2363
2375
 
2364
2376
  /**
2365
- * Accounts the user removed for good, each with a button that brings it back.
2377
+ * Accounts the user removed, each with a button that brings it back.
2366
2378
  *
2367
2379
  * Shown because "remove" would otherwise be a one-way door: the account stops
2368
2380
  * being scanned, so there is nothing left in the account list to click.
@@ -4199,6 +4211,65 @@ function stopCheckinPoll() {
4199
4211
  }
4200
4212
  }
4201
4213
 
4214
+ var growthPoll = null;
4215
+ var GROWTH_POLL_MS = CHECKIN_POLL_MS;
4216
+ var GROWTH_POLL_MAX_FAILURES = CHECKIN_POLL_MAX_FAILURES;
4217
+ var growthPollFailures = 0;
4218
+
4219
+ function stopGrowthPoll() {
4220
+ if (growthPoll !== null) {
4221
+ window.clearTimeout(growthPoll);
4222
+ growthPoll = null;
4223
+ }
4224
+ }
4225
+
4226
+ /**
4227
+ * Keep asking for the document while a growth pass is still running.
4228
+ *
4229
+ * The host answers "run now" after its budget even when the pass continues and
4230
+ * leaves `growth.running` set. Without this watch the card's button stayed
4231
+ * disabled after that answer, so once the pass landed there was no way to start
4232
+ * another one.
4233
+ */
4234
+ function pollGrowthRun() {
4235
+ if (!state || !state.growth || state.growth.running !== true || !pageIsVisible()) {
4236
+ stopGrowthPoll();
4237
+ return;
4238
+ }
4239
+ // A pending check-in pass already has `pollCheckinLog` asking for the same
4240
+ // document, and that watch clears once the pass lands.
4241
+ if (state.autoCheckin && state.autoCheckin.last && state.autoCheckin.last.pending === true) {
4242
+ stopGrowthPoll();
4243
+ return;
4244
+ }
4245
+ if (busy !== null) { stopGrowthPoll(); return; }
4246
+ if (growthPoll !== null) return;
4247
+ growthPoll = window.setTimeout(function () {
4248
+ growthPoll = null;
4249
+ var revision = stateRevision;
4250
+ invoke("xd.state").then(function (again) {
4251
+ if (revision !== stateRevision) { pollGrowthRun(); return; }
4252
+ if (busy !== null) { stopGrowthPoll(); return; }
4253
+ var wasRunning = state && state.growth && state.growth.running === true;
4254
+ adopt(again);
4255
+ growthPollFailures = 0;
4256
+ render();
4257
+ if (wasRunning && !(again && again.growth && again.growth.running === true)
4258
+ && activeTab === "growth" && growthStale()) {
4259
+ readGrowth();
4260
+ }
4261
+ }).catch(function () {
4262
+ growthPollFailures += 1;
4263
+ if (growthPollFailures < GROWTH_POLL_MAX_FAILURES) { pollGrowthRun(); return; }
4264
+ stopGrowthPoll();
4265
+ if (state && state.growth && state.growth.running === true) {
4266
+ adopt(Object.assign({}, state, { growth: Object.assign({}, state.growth, { running: false }) }));
4267
+ render();
4268
+ }
4269
+ });
4270
+ }, GROWTH_POLL_MS);
4271
+ }
4272
+
4202
4273
  /**
4203
4274
  * Whether this page is worth polling for.
4204
4275
  *
@@ -4642,6 +4713,7 @@ function selectTab(name) {
4642
4713
  var isActive = tabs[i].getAttribute("data-tab") === name;
4643
4714
  tabs[i].className = isActive ? "subtab active" : "subtab";
4644
4715
  tabs[i].setAttribute("aria-selected", isActive ? "true" : "false");
4716
+ tabs[i].tabIndex = isActive ? 0 : -1;
4645
4717
  }
4646
4718
  // Each page starts at its own top. Carrying the previous page's offset over
4647
4719
  // landed the user mid-roster after leaving the pool scrolled to its third
@@ -4663,7 +4735,28 @@ function selectTab(name) {
4663
4735
  && !(state && state.growth && state.growth.running === true)) readGrowth();
4664
4736
  }
4665
4737
 
4738
+ /** Move focus inside a tablist without changing the selected view. */
4739
+ function moveTabFocus(list, current, key) {
4740
+ var tabs = Array.prototype.filter.call(list.querySelectorAll('[role="tab"]'), function (tab) {
4741
+ return !tab.hidden && !tab.disabled;
4742
+ });
4743
+ var index = tabs.indexOf(current);
4744
+ if (index < 0 || tabs.length < 2) return false;
4745
+ var targetIndex;
4746
+ if (key === "ArrowRight") targetIndex = (index + 1) % tabs.length;
4747
+ else if (key === "ArrowLeft") targetIndex = (index + tabs.length - 1) % tabs.length;
4748
+ else if (key === "Home") targetIndex = 0;
4749
+ else if (key === "End") targetIndex = tabs.length - 1;
4750
+ else return false;
4751
+ current.tabIndex = -1;
4752
+ tabs[targetIndex].tabIndex = 0;
4753
+ tabs[targetIndex].focus();
4754
+ return true;
4755
+ }
4756
+
4666
4757
  function labelTabs() {
4758
+ $("sourceTabs").setAttribute("aria-label", t("tabs.sources"));
4759
+ $("viewTabs").setAttribute("aria-label", t("tabs.views"));
4667
4760
  var tabs = document.querySelectorAll("#viewTabs .subtab");
4668
4761
  for (var i = 0; i < tabs.length; i += 1) {
4669
4762
  var key = tabs[i].getAttribute("data-tab");
@@ -4688,12 +4781,16 @@ function bind() {
4688
4781
  // A hidden page stops polling; showing it again re-arms whatever the current
4689
4782
  // document says is still running.
4690
4783
  document.addEventListener("visibilitychange", function () {
4691
- if (!pageIsVisible()) { stopPolling(); stopCheckinPoll(); return; }
4784
+ if (!pageIsVisible()) { stopPolling(); stopCheckinPoll(); stopGrowthPoll(); return; }
4692
4785
  if (state && state.refreshing === true) adoptAndMaybePoll(state, 0);
4693
4786
  else if (state && state.autoCheckin && state.autoCheckin.last && state.autoCheckin.last.pending === true) {
4694
4787
  checkinPollFailures = 0;
4695
4788
  pollCheckinLog(0);
4696
4789
  }
4790
+ if (state && state.growth && state.growth.running === true) {
4791
+ growthPollFailures = 0;
4792
+ pollGrowthRun();
4793
+ }
4697
4794
  });
4698
4795
  $("refreshBtn").addEventListener("click", refresh);
4699
4796
  $("rescanBtn").addEventListener("click", rescan);
@@ -4766,8 +4863,19 @@ function bind() {
4766
4863
  for (var i = 0; i < viewTabs.length; i += 1) {
4767
4864
  (function (button) {
4768
4865
  button.addEventListener("click", function () { selectTab(button.getAttribute("data-tab")); });
4866
+ button.addEventListener("keydown", function (event) {
4867
+ if (moveTabFocus($('viewTabs'), button, event.key)) event.preventDefault();
4868
+ });
4769
4869
  })(viewTabs[i]);
4770
4870
  }
4871
+ var viewTabList = $("viewTabs");
4872
+ viewTabList.addEventListener("focusout", function (event) {
4873
+ if (viewTabList.contains(event.relatedTarget)) return;
4874
+ var tabs = viewTabList.querySelectorAll('[role="tab"]');
4875
+ for (var i = 0; i < tabs.length; i += 1) {
4876
+ tabs[i].tabIndex = tabs[i].getAttribute("aria-selected") === "true" ? 0 : -1;
4877
+ }
4878
+ });
4771
4879
 
4772
4880
  // A source tab owns both the pool page and the models page, so switching it
4773
4881
  // re-renders whichever of the two is on screen.