dsh-wtq-pool 1.0.2 → 1.0.3

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。WorkBuddy 被限流时自动换号。三家各有开关,国内与国际各自成组。",
5
- "version": "1.0.2",
5
+ "version": "1.0.3",
6
6
  "license": "MIT",
7
7
  "author": "chengzhi-c",
8
8
  "homepage": "https://github.com/chengzhi-c/dsh-wtq-pool#readme",
@@ -26,7 +26,7 @@
26
26
  "type": "module",
27
27
  "engines": {
28
28
  "node": "^22.19.0 || >=24.0.0",
29
- "dsh": ">=0.1.7-rc.1 <0.3.0"
29
+ "dsh": ">=0.2.0-rc.1 <0.2.1"
30
30
  },
31
31
  "main": "lib/index.js",
32
32
  "types": "lib/index.d.ts",
@@ -50,6 +50,7 @@
50
50
  ],
51
51
  "scripts": {
52
52
  "build": "tsdown",
53
+ "prepare": "pnpm run build",
53
54
  "prepack": "tsdown",
54
55
  "prepublishOnly": "tsdown",
55
56
  "typecheck": "tsc -p tsconfig.json --noEmit",
@@ -73,11 +74,6 @@
73
74
  },
74
75
  "devDependencies": {
75
76
  "@deepseek-ai/cordis": "^4.0.4",
76
- "@deepseek-ai/dsh-client-locale": "0.2.0-rc.2",
77
- "@deepseek-ai/dsh-client-ui-primitives": "0.2.0-rc.2",
78
- "@deepseek-ai/dsh-client-ui-settings": "0.2.0-rc.2",
79
- "@deepseek-ai/dsh-client-ui-settings-plugins": "0.2.0-rc.2",
80
- "@deepseek-ai/dsh-client-ui-slots": "0.2.0-rc.2",
81
77
  "@deepseek-ai/dsh-host-webserver": "0.2.0-rc.2",
82
78
  "@deepseek-ai/dsh-llm": "0.2.0-rc.2",
83
79
  "@deepseek-ai/dsh-llm-pi-ai": "0.2.0-rc.2",
@@ -92,30 +88,15 @@
92
88
  },
93
89
  "peerDependencies": {
94
90
  "@deepseek-ai/cordis": ">=4.0.4 <5.0.0",
95
- "@deepseek-ai/dsh-llm": ">=0.2.0-rc.1 <0.3.0",
96
- "@deepseek-ai/dsh-llm-pi-ai": ">=0.2.0-rc.1 <0.3.0",
97
- "@deepseek-ai/dsh-settings": ">=0.2.0-rc.1 <0.3.0",
91
+ "@deepseek-ai/dsh-llm": ">=0.2.0-rc.1 <0.2.1",
92
+ "@deepseek-ai/dsh-llm-pi-ai": ">=0.2.0-rc.1 <0.2.1",
93
+ "@deepseek-ai/dsh-settings": ">=0.2.0-rc.1 <0.2.1",
98
94
  "@deepseek-ai/schemastery": "^3.18.4",
99
- "@earendil-works/pi-ai": ">=0.87.1 <0.88.0"
95
+ "@earendil-works/pi-ai": ">=0.82.1 <0.88.0"
100
96
  },
101
97
  "peerDependenciesMeta": {
102
- "@deepseek-ai/cordis": {
103
- "optional": true
104
- },
105
- "@deepseek-ai/dsh-llm": {
106
- "optional": true
107
- },
108
- "@deepseek-ai/dsh-llm-pi-ai": {
109
- "optional": true
110
- },
111
98
  "@deepseek-ai/dsh-settings": {
112
99
  "optional": true
113
- },
114
- "@deepseek-ai/schemastery": {
115
- "optional": true
116
- },
117
- "@earendil-works/pi-ai": {
118
- "optional": true
119
100
  }
120
101
  }
121
102
  }
package/renderer/panel.js CHANGED
@@ -57,6 +57,7 @@ var EN = {
57
57
  "pool.checkinAllBusy": "Checking in…",
58
58
  "pool.checkinAllDone": "Checked in {count} account(s)",
59
59
  "pool.checkinAllNone": "Every account is already checked in today",
60
+ "pool.checkinAllFailed": "Checked in {count}, {failed} failed",
60
61
  "pool.emptyRegion": "No {region} account is signed in yet.",
61
62
  "pool.emptyHint": "Sign in to that edition in the WorkBuddy desktop app, then press “Detect accounts again”.",
62
63
  "pool.sourceOff": "The WorkBuddy source is switched off in plugin settings.",
@@ -90,6 +91,7 @@ var EN = {
90
91
  "source.checkedIn": "Checked in today",
91
92
  "source.claimable": "Can claim today",
92
93
  "source.noCampaign": "no daily check-in",
94
+ "source.campaignUnknown": "check-in state unavailable",
93
95
  "source.claimableAt": "Can claim after {time}",
94
96
  "source.deviceCheckedIn": "This device checked in today",
95
97
  "qoder.fallback": "using a spare port; the provider row still names {port}",
@@ -237,6 +239,7 @@ var EN = {
237
239
  "foot.docs": "Docs",
238
240
  "foot.license": "License",
239
241
  "err.bridge": "The panel bridge is unavailable.",
242
+ "err.busy": "The panel is busy with another action; try again in a moment.",
240
243
  "tag.free": "free",
241
244
  "tag.rate": "x{rate}",
242
245
  "tag.promoNight": "free until {hour}",
@@ -281,6 +284,7 @@ var ZH = {
281
284
  "pool.checkinAllBusy": "签到中…",
282
285
  "pool.checkinAllDone": "已签到 {count} 个账号",
283
286
  "pool.checkinAllNone": "所有账号今天都已签到",
287
+ "pool.checkinAllFailed": "已签到 {count} 个,{failed} 个失败",
284
288
  "pool.emptyRegion": "{region}这一侧还没有登录的账号。",
285
289
  "pool.emptyHint": "请在该版本的 WorkBuddy 桌面 App 里登录,再点「重新检测账号」。",
286
290
  "pool.sourceOff": "WorkBuddy 来源已在插件设置里关闭。",
@@ -314,6 +318,7 @@ var ZH = {
314
318
  "source.claimable": "今日可签到",
315
319
  "source.noAccounts": "未找到本机登录",
316
320
  "source.noCampaign": "该账号无签到活动",
321
+ "source.campaignUnknown": "签到状态读取失败",
317
322
  "source.deviceCheckedIn": "本机今日已签到",
318
323
  "qoder.fallback": "用的是备用端口;供应商行仍指向 {port}",
319
324
  "badge.next": "下一个",
@@ -461,6 +466,7 @@ var ZH = {
461
466
  "foot.docs": "文档",
462
467
  "foot.license": "许可",
463
468
  "err.bridge": "面板桥不可用。",
469
+ "err.busy": "面板正在处理其他操作,请稍候再试。",
464
470
  "tag.free": "免费",
465
471
  "tag.rate": "x{rate}",
466
472
  "tag.promoNight": "夜间免费 · 到 {hour}",
@@ -589,6 +595,12 @@ function clockHour(hour) {
589
595
  return (value < 10 ? "0" : "") + value + ":00";
590
596
  }
591
597
 
598
+ /**
599
+ * The banner text currently shown, so a later pass can tell its own message
600
+ * from one another action put up (or cleared).
601
+ */
602
+ var bannerText = "";
603
+
592
604
  /**
593
605
  * Show the banner. A failure reaching the panel arrives wrapped in whatever
594
606
  * envelope the bridge used; the reason itself is what the user needs, so the
@@ -596,10 +608,11 @@ function clockHour(hour) {
596
608
  */
597
609
  function note(message, kind) {
598
610
  var banner = $("banner");
599
- if (!message) { show(banner, false); banner.textContent = ""; return; }
611
+ if (!message) { show(banner, false); banner.textContent = ""; bannerText = ""; return; }
600
612
  banner.textContent = String(message)
601
613
  .replace(/^Error invoking remote method '[^']*':\s*/, "")
602
614
  .replace(/^Error:\s*/, "");
615
+ bannerText = banner.textContent;
603
616
  banner.className = kind === "warn" ? "banner warn" : "banner";
604
617
  show(banner, true);
605
618
  }
@@ -711,7 +724,7 @@ function renderHeader() {
711
724
  // away would keep naming a problem the state document no longer reports. Only
712
725
  // the banner this pass itself last showed is cleared, so a message another
713
726
  // action put up is not wiped by the poll landing behind it.
714
- if (warning !== headerWarning) {
727
+ if (warning !== headerWarning || (warning !== "" && bannerText === "")) {
715
728
  headerWarning = warning;
716
729
  note(warning === "" ? null : warning, "warn");
717
730
  }
@@ -1063,7 +1076,8 @@ function sourceAccountCard(account, kind) {
1063
1076
  ? t("source.checkedIn")
1064
1077
  : deviceDone ? t("source.deviceCheckedIn")
1065
1078
  : opensLabel !== "" ? opensLabel
1066
- : checkin.active ? t("source.claimable") : t("source.noCampaign")));
1079
+ : checkin.campaignsUnavailable === true ? t("source.campaignUnknown")
1080
+ : checkin.active ? t("source.claimable") : t("source.noCampaign")));
1067
1081
  if (!doneToday && checkin.active && checkin.amount > 0) {
1068
1082
  row.appendChild(el("span", "muted", checkin.amount + " "
1069
1083
  + (checkin.unit === undefined || checkin.unit === "credits" ? t("credits.keepUnit") : checkin.unit)));
@@ -1265,7 +1279,15 @@ function claimSourceCheckins(source) {
1265
1279
  }
1266
1280
  var counts = payload ? payload[source] : null;
1267
1281
  var claimed = counts && typeof counts.claimed === "number" ? counts.claimed : 0;
1268
- announce(claimed > 0 ? t("pool.checkinAllDone", { count: claimed }) : t("pool.checkinAllNone"));
1282
+ var failed = counts && typeof counts.failed === "number" ? counts.failed : 0;
1283
+ // A round that failed used to read as "every account is already checked in
1284
+ // today": the counts carry `failed` (and the reason), a source whose round
1285
+ // threw carries none of its own, and the panel read the missing number as
1286
+ // "nothing to collect". The user was told the day was done while nothing
1287
+ // had been collected.
1288
+ announce(failed > 0
1289
+ ? checkinFailureText(claimed, failed, counts && counts.reason)
1290
+ : claimed > 0 ? t("pool.checkinAllDone", { count: claimed }) : t("pool.checkinAllNone"));
1269
1291
  }).catch(function (error) {
1270
1292
  checkinBusy = null;
1271
1293
  note(String(error && error.message ? error.message : error));
@@ -1273,6 +1295,17 @@ function claimSourceCheckins(source) {
1273
1295
  });
1274
1296
  }
1275
1297
 
1298
+ /**
1299
+ * What to say when a check-in round reports failures.
1300
+ *
1301
+ * The counts alone cannot name the cause, and the upstream's own words are
1302
+ * worth more than "failed": the reason is appended when the host has one.
1303
+ */
1304
+ function checkinFailureText(claimed, failed, reason) {
1305
+ var text = t("pool.checkinAllFailed", { count: claimed, failed: failed });
1306
+ return typeof reason === "string" && reason !== "" ? text + " · " + reason : text;
1307
+ }
1308
+
1276
1309
  /** The busy key of one source account row: source, region and label together. */
1277
1310
  function sourceCheckinKey(source, account) {
1278
1311
  return source + ":" + account.region + ":" + account.label;
@@ -2509,8 +2542,9 @@ function modelSheetBody(model, entry) {
2509
2542
  body.appendChild(pair);
2510
2543
 
2511
2544
  // Thinking levels: only a model whose catalog offers a reason menu gets the
2512
- // control. Trae and Qoder report no levels at all, so a menu there could
2513
- // never take effect.
2545
+ // control. WorkBuddy reports its own table, and Trae and Qoder advertise
2546
+ // theirs through the gateway, so the menu appears wherever the upstream
2547
+ // actually offers levels and the save reaches the declaration.
2514
2548
  var levels = effectiveLevels(model, entry);
2515
2549
  if (levels.length > 0) {
2516
2550
  var levelsWrap = el("div", "field");
@@ -2794,7 +2828,14 @@ function adopt(next) {
2794
2828
  }
2795
2829
 
2796
2830
  function runBusy(id, work) {
2797
- if (busy !== null) return Promise.reject(new Error("panel is busy"));
2831
+ // A second action while one is running used to reject here and nowhere else:
2832
+ // every caller answers with its own `.catch(function () {})`, so the click did
2833
+ // nothing and said nothing. The banner is raised here, once, so a busy panel
2834
+ // answers every control the same way.
2835
+ if (busy !== null) {
2836
+ note(t("err.busy"), "warn");
2837
+ return Promise.reject(new Error("panel is busy"));
2838
+ }
2798
2839
  notePress(document.activeElement);
2799
2840
  busy = id;
2800
2841
  render();
@@ -2840,7 +2881,15 @@ function adoptAndMaybePoll(next, attempts) {
2840
2881
  adopt(next);
2841
2882
  render();
2842
2883
  if (!next || next.refreshing !== true) { stopPolling(); return; }
2843
- if (attempts >= 15) { stopPolling(); return; }
2884
+ if (attempts >= 15) {
2885
+ // Giving up on the pass, not on the document. Leaving `refreshing` set here
2886
+ // left the header saying "detecting…" for good: nothing else comes back for
2887
+ // it, so the flag had to be cleared by the one who stopped watching.
2888
+ stopPolling();
2889
+ adopt(next && typeof next === "object" ? Object.assign({}, next, { refreshing: false }) : next);
2890
+ render();
2891
+ return;
2892
+ }
2844
2893
  stopPolling();
2845
2894
  refreshPoll = window.setTimeout(function () {
2846
2895
  refreshPoll = null;
@@ -3036,7 +3085,10 @@ function claimAllCheckins() {
3036
3085
  return;
3037
3086
  }
3038
3087
  var claimed = payload && typeof payload.claimed === "number" ? payload.claimed : 0;
3039
- announce(claimed > 0 ? t("pool.checkinAllDone", { count: claimed }) : t("pool.checkinAllNone"));
3088
+ var failed = payload && typeof payload.failed === "number" ? payload.failed : 0;
3089
+ announce(failed > 0
3090
+ ? checkinFailureText(claimed, failed, payload && payload.reason)
3091
+ : claimed > 0 ? t("pool.checkinAllDone", { count: claimed }) : t("pool.checkinAllNone"));
3040
3092
  }).catch(function (error) {
3041
3093
  checkinBusy = null;
3042
3094
  note(String(error && error.message ? error.message : error));
@@ -3081,6 +3133,24 @@ function toggleAllVisible() {
3081
3133
  function fetchModelList() {
3082
3134
  return runBusy("fetch", function () { return invoke("xd.rescan"); }).catch(function () {});
3083
3135
  }
3136
+
3137
+ /**
3138
+ * Ask the plugin for a live model roster, silently, once per panel.
3139
+ *
3140
+ * Opening the panel is when the list has to be right: a roster read that timed
3141
+ * out while the host was starting leaves the plugin's static fallback in force,
3142
+ * and the model page then listed the fallback's own models and reported the
3143
+ * user's saved choice as retired - on every start, until a manual fetch. The
3144
+ * model page keeps its own "fetch list" button for a deliberate re-read.
3145
+ */
3146
+ var modelRosterRequested = false;
3147
+ function requestModelRoster() {
3148
+ if (modelRosterRequested || bridge === null) return;
3149
+ modelRosterRequested = true;
3150
+ invoke("xd.fetchModels").then(function (next) {
3151
+ adoptAndMaybePoll(next, 0);
3152
+ }).catch(function () {});
3153
+ }
3084
3154
  function discardDraft() {
3085
3155
  // Only the page in view: another page's unsaved edits are not this button's to
3086
3156
  // throw away.
@@ -3203,6 +3273,9 @@ function selectTab(name) {
3203
3273
  tabs[i].setAttribute("aria-selected", isActive ? "true" : "false");
3204
3274
  }
3205
3275
  if (name === "check" && doctorResult === null) runDoctor();
3276
+ // The model page shows a roster, so entering it is the moment to make sure
3277
+ // that roster is the vendor's and not this plugin's own fallback.
3278
+ if (name === "models") requestModelRoster();
3206
3279
  }
3207
3280
 
3208
3281
  function labelTabs() {
@@ -3323,6 +3396,9 @@ function boot() {
3323
3396
  invoke("xd.state").then(function (next) {
3324
3397
  adoptAndMaybePoll(next, 0);
3325
3398
  pollCheckinLog(0);
3399
+ // After the first document, so a panel opened while the plugin process is
3400
+ // still starting does not burn its one roster request on a dead bridge.
3401
+ requestModelRoster();
3326
3402
  }).catch(function (error) {
3327
3403
  bootAttempts += 1;
3328
3404
  if (bootAttempts < 4) {