dsh-wtq-pool 1.3.1 → 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/CHANGELOG.md +29 -0
- package/README.en.md +76 -142
- package/README.md +75 -143
- package/THIRD-PARTY-NOTICES.md +47 -0
- package/lib/index.js +300 -219
- package/package.json +3 -2
- package/renderer/index.html +12 -12
- package/renderer/panel.js +115 -9
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.
|
|
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",
|
package/renderer/index.html
CHANGED
|
@@ -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
|
-
<
|
|
42
|
-
<button type="button" class="tab active" data-source="workbuddy"
|
|
43
|
-
<button type="button" class="tab" data-source="trae"
|
|
44
|
-
<button type="button" class="tab" data-source="qoder"
|
|
45
|
-
</
|
|
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
|
-
<
|
|
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
|
-
<
|
|
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",
|
|
@@ -317,6 +320,9 @@ var ZH = {
|
|
|
317
320
|
"tab.models": "模型",
|
|
318
321
|
"tab.check": "连接检查",
|
|
319
322
|
"tab.growth": "成长中心",
|
|
323
|
+
"tabs.sources": "账号来源",
|
|
324
|
+
"tabs.views": "插件页面",
|
|
325
|
+
"tabs.regions": "账号区域",
|
|
320
326
|
"risk.note": "非官方客户端可能触发账号风控,请遵守厂商服务条款。",
|
|
321
327
|
"host.missing": "宿主还没有注册本插件的 {count} 个模型组:重新加载插件。",
|
|
322
328
|
"btn.rescan": "重新检测账号",
|
|
@@ -956,7 +962,7 @@ function renderSourceTabs() {
|
|
|
956
962
|
for (var i = 0; i < tabs.length; i += 1) {
|
|
957
963
|
var on = tabs[i].getAttribute("data-source") === activeSource;
|
|
958
964
|
tabs[i].classList.toggle("active", on);
|
|
959
|
-
tabs[i].setAttribute("aria-
|
|
965
|
+
tabs[i].setAttribute("aria-pressed", on ? "true" : "false");
|
|
960
966
|
}
|
|
961
967
|
var groups = document.querySelectorAll("#poolView .source-group");
|
|
962
968
|
for (var j = 0; j < groups.length; j += 1) {
|
|
@@ -1057,15 +1063,14 @@ function sourceFoot(source) {
|
|
|
1057
1063
|
*/
|
|
1058
1064
|
function fillRegionNav(nav, source, regions, accounts, active) {
|
|
1059
1065
|
clear(nav);
|
|
1066
|
+
nav.setAttribute("role", "group");
|
|
1067
|
+
nav.setAttribute("aria-label", t("tabs.regions"));
|
|
1060
1068
|
regions.forEach(function (region) {
|
|
1061
1069
|
var on = region === active;
|
|
1062
1070
|
var button = el("button", on ? "active" : "");
|
|
1063
1071
|
button.type = "button";
|
|
1064
1072
|
button.disabled = busy !== null;
|
|
1065
|
-
button.setAttribute("
|
|
1066
|
-
// A `tab` without `aria-selected` is invalid ARIA, and it is what a screen
|
|
1067
|
-
// reader reads to say which one is current.
|
|
1068
|
-
button.setAttribute("aria-selected", on ? "true" : "false");
|
|
1073
|
+
button.setAttribute("aria-pressed", on ? "true" : "false");
|
|
1069
1074
|
button.textContent = sourceRegionLabel(region);
|
|
1070
1075
|
if (regionParked(source, region)) button.appendChild(el("span", "muted", " " + t("region.parkedShort")));
|
|
1071
1076
|
var count = accounts.filter(function (account) { return account.region === region; }).length;
|
|
@@ -1081,7 +1086,7 @@ function fillRegionNav(nav, source, regions, accounts, active) {
|
|
|
1081
1086
|
|
|
1082
1087
|
/** A fresh region row for a page that is rebuilt on every render. */
|
|
1083
1088
|
function sourceRegionNav(source, regions, accounts) {
|
|
1084
|
-
return fillRegionNav(el("
|
|
1089
|
+
return fillRegionNav(el("div", "regions"), source, regions, accounts, activeRegionOf(source));
|
|
1085
1090
|
}
|
|
1086
1091
|
|
|
1087
1092
|
/**
|
|
@@ -1811,9 +1816,11 @@ function renderAutoCheckin() {
|
|
|
1811
1816
|
// render the panel had ever drawn. The handler reads the hours field when it
|
|
1812
1817
|
// runs, so binding it once in `bind` is enough.
|
|
1813
1818
|
var run = $("autoRunNow");
|
|
1814
|
-
|
|
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");
|
|
1815
1822
|
run.title = t("auto.runNowHint");
|
|
1816
|
-
run.disabled = busy !== null || checkinBusy !== null;
|
|
1823
|
+
run.disabled = busy !== null || checkinBusy !== null || pending || passRunning;
|
|
1817
1824
|
|
|
1818
1825
|
// The keep-alive row: one button, run by hand. It is a static node, so the
|
|
1819
1826
|
// handler lives in `bind`. Its own card, its own log: it renews tokens rather
|
|
@@ -2023,6 +2030,8 @@ function renderGrowth() {
|
|
|
2023
2030
|
run.textContent = busy === "growth" ? t("growth.running") : t("growth.run");
|
|
2024
2031
|
run.title = t("growth.runHint");
|
|
2025
2032
|
run.disabled = busy !== null || running;
|
|
2033
|
+
if (running) pollGrowthRun();
|
|
2034
|
+
else stopGrowthPoll();
|
|
2026
2035
|
$("growthText").textContent = growthStateText();
|
|
2027
2036
|
paintGrowthAccounts($("growthAccounts"));
|
|
2028
2037
|
$("growthHint").textContent = t("growth.hint");
|
|
@@ -2258,6 +2267,7 @@ function readGrowth() {
|
|
|
2258
2267
|
/** Run the growth centre on its own. */
|
|
2259
2268
|
function runGrowth() {
|
|
2260
2269
|
if (busy !== null) return Promise.resolve();
|
|
2270
|
+
growthPollFailures = 0;
|
|
2261
2271
|
return runBusy("growth", function () {
|
|
2262
2272
|
return invoke("xd.growthRun").then(function (payload) {
|
|
2263
2273
|
// The run answers with the document beside its own counts, and this card
|
|
@@ -4201,6 +4211,65 @@ function stopCheckinPoll() {
|
|
|
4201
4211
|
}
|
|
4202
4212
|
}
|
|
4203
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
|
+
|
|
4204
4273
|
/**
|
|
4205
4274
|
* Whether this page is worth polling for.
|
|
4206
4275
|
*
|
|
@@ -4644,6 +4713,7 @@ function selectTab(name) {
|
|
|
4644
4713
|
var isActive = tabs[i].getAttribute("data-tab") === name;
|
|
4645
4714
|
tabs[i].className = isActive ? "subtab active" : "subtab";
|
|
4646
4715
|
tabs[i].setAttribute("aria-selected", isActive ? "true" : "false");
|
|
4716
|
+
tabs[i].tabIndex = isActive ? 0 : -1;
|
|
4647
4717
|
}
|
|
4648
4718
|
// Each page starts at its own top. Carrying the previous page's offset over
|
|
4649
4719
|
// landed the user mid-roster after leaving the pool scrolled to its third
|
|
@@ -4665,7 +4735,28 @@ function selectTab(name) {
|
|
|
4665
4735
|
&& !(state && state.growth && state.growth.running === true)) readGrowth();
|
|
4666
4736
|
}
|
|
4667
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
|
+
|
|
4668
4757
|
function labelTabs() {
|
|
4758
|
+
$("sourceTabs").setAttribute("aria-label", t("tabs.sources"));
|
|
4759
|
+
$("viewTabs").setAttribute("aria-label", t("tabs.views"));
|
|
4669
4760
|
var tabs = document.querySelectorAll("#viewTabs .subtab");
|
|
4670
4761
|
for (var i = 0; i < tabs.length; i += 1) {
|
|
4671
4762
|
var key = tabs[i].getAttribute("data-tab");
|
|
@@ -4690,12 +4781,16 @@ function bind() {
|
|
|
4690
4781
|
// A hidden page stops polling; showing it again re-arms whatever the current
|
|
4691
4782
|
// document says is still running.
|
|
4692
4783
|
document.addEventListener("visibilitychange", function () {
|
|
4693
|
-
if (!pageIsVisible()) { stopPolling(); stopCheckinPoll(); return; }
|
|
4784
|
+
if (!pageIsVisible()) { stopPolling(); stopCheckinPoll(); stopGrowthPoll(); return; }
|
|
4694
4785
|
if (state && state.refreshing === true) adoptAndMaybePoll(state, 0);
|
|
4695
4786
|
else if (state && state.autoCheckin && state.autoCheckin.last && state.autoCheckin.last.pending === true) {
|
|
4696
4787
|
checkinPollFailures = 0;
|
|
4697
4788
|
pollCheckinLog(0);
|
|
4698
4789
|
}
|
|
4790
|
+
if (state && state.growth && state.growth.running === true) {
|
|
4791
|
+
growthPollFailures = 0;
|
|
4792
|
+
pollGrowthRun();
|
|
4793
|
+
}
|
|
4699
4794
|
});
|
|
4700
4795
|
$("refreshBtn").addEventListener("click", refresh);
|
|
4701
4796
|
$("rescanBtn").addEventListener("click", rescan);
|
|
@@ -4768,8 +4863,19 @@ function bind() {
|
|
|
4768
4863
|
for (var i = 0; i < viewTabs.length; i += 1) {
|
|
4769
4864
|
(function (button) {
|
|
4770
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
|
+
});
|
|
4771
4869
|
})(viewTabs[i]);
|
|
4772
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
|
+
});
|
|
4773
4879
|
|
|
4774
4880
|
// A source tab owns both the pool page and the models page, so switching it
|
|
4775
4881
|
// re-renders whichever of the two is on screen.
|