dsh-xdpool 3.0.4 → 3.0.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 CHANGED
@@ -1,6 +1,38 @@
1
1
  # Changelog
2
2
  本项目的所有重要变更都会记录在此文件。
3
3
  版本号遵循 [语义化版本](https://semver.org/lang/zh-CN/)。
4
+ ## 3.0.6 — 账号卡重做,撤掉没用的关闭按钮
5
+
6
+ 3.0.4 把账号卡挂回账号池页时,直接用了 2.x 的 `AccountBlock`:它的根元素是渠道行的类名
7
+ (`.ch-head`),内部还依赖一批在 3.0 被重新定义过的类。结果卡片没有边框和内边距、内容横向
8
+ 挤成一行、互相重叠 —— 那一版把页面弄坏了。
9
+
10
+ 这一版重画成一张自包含的小卡片:独立类名(`xdp-acct*`),只用 `.app` 上的设计变量,不引用
11
+ 任何现有页面的类,以后设计稿怎么改都不会再把它带坏。四行内容:昵称(长文本省略)→ 状态徽章
12
+ (当前使用 / 已停用 / 冷却中)→ 令牌到期 + 积分 → 优先 / 停用 / 签到 / 移出池子。1280 与 390
13
+ 两种宽度都用无头浏览器量过。
14
+
15
+ 右上角的关闭按钮撤掉:宿主的设置面板不在 `[role="dialog"]` 里,它的关闭控件也不靠
16
+ `aria-label` 能认出来,派发的 Escape 会被宿主吞掉 —— 插件拿不到「关闭自己」的能力,
17
+ 猜不准的按钮留着只会让人多点一次。
18
+
19
+ ## 3.0.5 — 没登录不再显示模型,账号表不会被空快照抹掉
20
+
21
+ ### 没登录就不发布模型
22
+
23
+ 池里没有某个区域的账号时,这个区域的 provider 以前照样发布内置目录 —— 没登录的人也
24
+ 看到一整组 WorkBuddy 模型,点任何一个都只会失败(issue #204)。现在按区域判断:一个
25
+ 账号都没有就返回空目录,分组不出现。豆包与 pack 的各渠道早就是这个规矩,这两条 lane
26
+ 只是漏了。
27
+
28
+ ### 账号表不会被空快照覆盖
29
+
30
+ 升级/重装过程中出现过「账号表被写成空、磁盘上没有可恢复旧版本」的报告,用户的账号在
31
+ 界面上消失(issue #200)。现在写账号表时比对进程内旧表:**用空表覆盖一张非空表**会被
32
+ 拒绝并留下日志 —— 那条路径几乎总是故障(读失败、并发写、装包时的空状态),不是用户
33
+ 意图。逐个删除账号走的是 `removeAccount`,它显式允许清空,行为不变;真要一次性重置可以
34
+ 设 `DSH_XDPOOL_ALLOW_EMPTY_ACCOUNTS=1`。
35
+
4
36
  ## 3.0.4 — 账号卡回来了,签到回来了,重复分组没了
5
37
 
6
38
  > 3.0 重构砍掉的三块界面与两处数据源,这一版接回来。
package/README.md CHANGED
@@ -9,16 +9,17 @@
9
9
 
10
10
  ## 更新公告
11
11
 
12
- **3.0.4** — 账号卡回来了,签到回来了,重复分组没了。
12
+ **3.0.6** — 账号卡重做。
13
13
 
14
- - 账号池页重新显示插件池账号:余额、积分明细、每日签到、停用/忽略/首选都在原位
15
- - 账号卡上标出「正在使用」:池子上一次真正服务过的那个账号
16
- - 模型选择器里「国内版 / 国际版」不再各出现两次
17
- - 「登录通道」页把插件池的账号也算进来,不再写着 1 个而实际有 5 个
14
+ - 账号池页的账号卡重画成自包含的卡片:昵称、状态徽章(当前使用 / 已停用 / 冷却中)、令牌到期、积分、以及优先/停用/签到/移出池子一排按钮
15
+ - 3.0.4 那一版卡片沿用了旧组件,会挤成一行、互相重叠 —— 已修
16
+ - 撤掉右上角的关闭按钮(宿主的设置面板认不出它,点了没反应)
18
17
 
19
- **3.0.3** — 豆包每个模型用自己的思考档位、全关真的会空、积分自动化「立即执行」、右上角关闭按钮。
18
+ **3.0.5** — 没登录不再显示模型;写账号表时拒绝「空表覆盖非空表」。
20
19
 
21
- **3.0.2 / 3.0.1** — 自动更新不再变成「本地开发」;护眼绿亮色模式与五条反馈(明细见 CHANGELOG)。
20
+ **3.0.4** — 账号卡回到账号池页、模型选择器不再出现两份、登录通道页算上插件池账号。
21
+
22
+ **3.0.3** — 豆包每个模型用自己的思考档位、全关真的会空、积分自动化「立即执行」。
22
23
 
23
24
  ## 先加群
24
25
 
package/lib/client.js CHANGED
@@ -78,7 +78,6 @@ window.__ModuleLoader__.load({
78
78
  const POOL_AUTOCLAW_CN_SESSION_PATH = "/plugins/dsh-xdpool/autoclaw-cn/session";
79
79
  const POOL_AUTOCLAW_CN_WALLET_PATH = "/plugins/dsh-xdpool/autoclaw-cn/wallet";
80
80
  const POOL_UPDATE_INSTALL_PATH = "/plugins/dsh-xdpool/update/install";
81
- const POOL_CREDIT_RESERVE_PATH = "/plugins/dsh-xdpool/accounts/credit-reserve";
82
81
  const POOL_CREDITS_SPEND_PATH = "/plugins/dsh-xdpool/credits/spend";
83
82
  const POOL_ACCOUNT_PREFER_PATH = "/plugins/dsh-xdpool/accounts/preferred";
84
83
  const POOL_AGGREGATE_PATH = "/plugins/dsh-xdpool/aggregate";
@@ -117,6 +116,136 @@ window.__ModuleLoader__.load({
117
116
  //#endregion
118
117
  //#region src/client/avatar.ts
119
118
  const POOL_CARD_AVATAR = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAQDAwQDAwQEAwQFBAQFBgoHBgYGBg0JCggKDw0QEA8NDw4RExgUERIXEg4PFRwVFxkZGxsbEBQdHx0aHxgaGxr/2wBDAQQFBQYFBgwHBwwaEQ8RGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhr/wAARCACAAIADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAH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16Cf7KbTDTPzt2Z7+3+NcJ4e8Uvq9pCJI0y6gqwckEeopSfNFMuK5ZNHzp8avg3f+EJ5td0S3Nx4eugJHMS/8echHzKwHRCc4bpzg9OfFYWOGVVznv6V9j+PPj1o/h/T7zTNKlTVtXIaNoUGYkJBGGboR6gZ9K+Tl8mJSsmCzHLkDqa6qLk4+8ctVRUtCpbxNNOAAyqBhWHYVoLC8Y43/APAjmqht13s0B/dkdFPQ0ixsHwXlwfRjxXQYt6GrEVwMqRjrxUcsgKk9F7E1UCOBjzXx9eaJEDEb2J2njJ60EMrXV0BwB1rO6mprly0nzLtx0FQ0FpWCtDRtGudcvUtrNev33b7qD1NZ9ejfDDT/ADZJ5jJksdqpngf7R96Bnq/wu00+G0FpE7TW6yZLtwd5xu4HavpvwvrsjKkCMFOBjdXzr4VkNje/ZpkUsTu3lsd+v8q9i0d3jmiNvKuwkZye9Te4juPHUhm8J6mkoIk8gsDnOCvI/lVr4a+IFutLs5CeSgVhmom2anp8ltdsGSRChOR3H/1682+F+qPZ+dYSPh7eVosZ7q2D/KuOuup1UHuj2f4i6JF4o8N6jptygkhvLZ4WB9GUivzCude8R6cJ9Fn1i4S2sXe22RvjIVsY3DnHHrX6hx3w1CzaJpArMpUNnpnjNflXrdnPpWs6np96Ct1a3UsMobqGVyD/ACqcPrJplYh2s0VbgCQl4vvKMDHYjtShxOik8kiqkshjl3Rn7w5HaliuVACsu0e3Negcdkwkja2O+JsrViOdnjVgx3d+aaJVOMEGoARFJlHAB6igltFovLj79QF8ACRufU01rkYOOarFi3Uk0xctx0r72z6cCmUUUjQ//9k=";
119
+ //#endregion
120
+ //#region src/client/account-card.tsx
121
+ const CREDITS = new Intl.NumberFormat();
122
+ function formatExpiry(value) {
123
+ if (value === void 0) return void 0;
124
+ const at = Date.parse(value);
125
+ if (!Number.isFinite(at)) return void 0;
126
+ return new Intl.DateTimeFormat(void 0, {
127
+ month: "2-digit",
128
+ day: "2-digit",
129
+ hour: "2-digit",
130
+ minute: "2-digit",
131
+ hour12: false
132
+ }).format(new Date(at));
133
+ }
134
+ function AccountCard({ account, serving = false, busy = false, claiming = false, t, onClaim, onToggle, onPrefer, onIgnore }) {
135
+ const total = account.credits?.total;
136
+ const expiry = formatExpiry(account.expiresAt);
137
+ const checkin = account.checkin;
138
+ const claimed = checkin?.todayCheckedIn === true;
139
+ return (0, react_jsx_runtime.jsxs)("article", {
140
+ className: "xdp-acct",
141
+ "data-serving": serving ? "true" : void 0,
142
+ children: [
143
+ (0, react_jsx_runtime.jsx)("header", {
144
+ className: "xdp-acct-head",
145
+ children: (0, react_jsx_runtime.jsx)("span", {
146
+ className: "xdp-acct-name",
147
+ title: account.nickname ?? account.label,
148
+ children: account.nickname ?? account.label
149
+ })
150
+ }),
151
+ !serving && !account.disabled && !account.cooling ? null : (0, react_jsx_runtime.jsxs)("div", {
152
+ className: "xdp-acct-badges",
153
+ children: [
154
+ serving ? (0, react_jsx_runtime.jsx)("span", {
155
+ className: "xdp-acct-badge",
156
+ children: t?.("row.currentAccount") ?? "当前使用"
157
+ }) : null,
158
+ account.disabled ? (0, react_jsx_runtime.jsx)("span", {
159
+ className: "xdp-acct-badge is-off",
160
+ children: "已停用"
161
+ }) : null,
162
+ account.cooling ? (0, react_jsx_runtime.jsx)("span", {
163
+ className: "xdp-acct-badge is-warn",
164
+ children: "冷却中"
165
+ }) : null
166
+ ]
167
+ }),
168
+ (0, react_jsx_runtime.jsxs)("p", {
169
+ className: "xdp-acct-meta",
170
+ children: [expiry === void 0 ? "令牌有效期未知" : `令牌到期 ${expiry}`, account.lastUsedAt === void 0 ? "" : ` · 上次使用 ${formatExpiry(account.lastUsedAt) ?? ""}`]
171
+ }),
172
+ (0, react_jsx_runtime.jsxs)("div", {
173
+ className: "xdp-acct-credits",
174
+ children: [
175
+ (0, react_jsx_runtime.jsx)("strong", { children: total === void 0 ? "—" : CREDITS.format(total) }),
176
+ (0, react_jsx_runtime.jsx)("span", { children: t?.("row.creditsTotal") ?? "积分" }),
177
+ checkinError(account)
178
+ ]
179
+ }),
180
+ (0, react_jsx_runtime.jsxs)("footer", {
181
+ className: "xdp-acct-actions",
182
+ children: [
183
+ (0, react_jsx_runtime.jsx)("button", {
184
+ type: "button",
185
+ className: account.preferred ? "tiny is-on" : "tiny",
186
+ "aria-pressed": account.preferred,
187
+ disabled: busy,
188
+ title: account.preferred ? t?.("row.accountPreferClearHint") ?? "取消优先,交回按使用方式选号" : t?.("row.accountPreferHint") ?? "让它排在前面,仍然健康时才用",
189
+ onClick: () => {
190
+ onPrefer(account.preferred ? null : account.id);
191
+ },
192
+ children: account.preferred ? t?.("row.accountPreferOn") ?? "优先" : t?.("row.accountPrefer") ?? "优先"
193
+ }),
194
+ (0, react_jsx_runtime.jsx)("button", {
195
+ type: "button",
196
+ className: "tiny",
197
+ disabled: busy,
198
+ onClick: () => {
199
+ onToggle(!account.disabled);
200
+ },
201
+ children: account.disabled ? "启用" : "停用"
202
+ }),
203
+ checkin === void 0 ? null : (0, react_jsx_runtime.jsx)("button", {
204
+ type: "button",
205
+ className: "tiny",
206
+ disabled: claiming || claimed || checkin.active !== true,
207
+ title: checkin.active === true ? void 0 : "这个账号当前没有签到活动",
208
+ onClick: onClaim,
209
+ children: claimed ? t?.("row.checkinClaimed") ?? "今日已签" : claiming ? t?.("row.checkinClaiming") ?? "签到中…" : t?.("row.checkinClaim") ?? "签到"
210
+ }),
211
+ (0, react_jsx_runtime.jsx)("button", {
212
+ type: "button",
213
+ className: "tiny",
214
+ disabled: busy,
215
+ title: "把这个账号从池子里永久移除(可在「已忽略」里恢复)",
216
+ onClick: onIgnore,
217
+ children: "移出池子"
218
+ })
219
+ ]
220
+ })
221
+ ]
222
+ });
223
+ }
224
+ function checkinError(account) {
225
+ if (account.checkinError === void 0) return null;
226
+ return (0, react_jsx_runtime.jsx)("span", {
227
+ className: "xdp-acct-warn",
228
+ title: account.checkinError,
229
+ children: "签到不可用"
230
+ });
231
+ }
232
+ const ACCOUNT_CARD_CSS = `
233
+ .xdp-accts{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:var(--s3);padding:0 var(--s5) var(--s4)}
234
+ .xdp-acct{display:flex;flex-direction:column;gap:var(--s2);min-width:0;padding:var(--s3);border:1px solid var(--line);border-radius:var(--r-lg);background:var(--surface)}
235
+ .xdp-acct[data-serving="true"]{border-color:var(--accent-line)}
236
+ .xdp-acct .xdp-acct-head{display:block;min-width:0}
237
+ .xdp-acct .xdp-acct-name{display:block;max-width:100%;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:var(--fs-sm);font-weight:600;color:var(--text)}
238
+ .xdp-acct .xdp-acct-badges{display:flex;flex-wrap:wrap;gap:var(--s1)}
239
+ .xdp-acct .xdp-acct-badge{flex:0 0 auto;padding:0 6px;border:1px solid var(--accent-line);border-radius:var(--r-pill);background:var(--accent-dim);color:var(--accent);font-size:var(--fs-xs);line-height:16px;white-space:nowrap}
240
+ .xdp-acct-badge.is-off{border-color:var(--line-2);background:transparent;color:var(--faint)}
241
+ .xdp-acct-badge.is-warn{border-color:color-mix(in oklch, var(--warn) 40%, transparent);background:color-mix(in oklch, var(--warn) 10%, transparent);color:var(--warn)}
242
+ .xdp-acct-meta{margin:0;font-size:var(--fs-xs);line-height:1.5;color:var(--faint);font-variant-numeric:tabular-nums;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
243
+ .xdp-acct-credits{display:flex;align-items:baseline;gap:var(--s2);min-width:0;flex-wrap:wrap}
244
+ .xdp-acct-credits strong{font-size:var(--fs-lg);font-weight:600;color:var(--text);font-variant-numeric:tabular-nums}
245
+ .xdp-acct-credits > span{font-size:var(--fs-xs);color:var(--faint)}
246
+ .xdp-acct-warn{font-size:var(--fs-xs);color:var(--warn)}
247
+ .xdp-acct-actions{display:flex;flex-wrap:wrap;gap:var(--s1);padding-top:2px}
248
+ `;
120
249
  //#endregion
121
250
  //#region src/client/nav-icon.ts
122
251
  const POOL_NAV_ICON_PATHS = [{
@@ -140,7 +269,7 @@ window.__ModuleLoader__.load({
140
269
  const POOL_NAV_ICON_MASK_URL = `data:image/svg+xml;utf8,${encodeURIComponent(POOL_NAV_ICON_SVG)}`;
141
270
  //#endregion
142
271
  //#region src/version.ts
143
- const POOL_VERSION = "3.0.4";
272
+ const POOL_VERSION = "3.0.6";
144
273
  function compareVersions(left, right) {
145
274
  const parse = (value) => {
146
275
  const [core, ...rest] = value.trim().replace(/^v/u, "").split("-");
@@ -934,18 +1063,6 @@ window.__ModuleLoader__.load({
934
1063
  select,
935
1064
  tabs
936
1065
  ]);
937
- const closeHostDialog = (0, react.useCallback)(() => {
938
- if (typeof document === "undefined") return;
939
- const candidate = document.querySelector("[role=\"dialog\"]")?.querySelector("[aria-label*=\"lose\" i], [aria-label*=\"关闭\"], [aria-label*=\"ismiss\" i], [data-dismiss]");
940
- if (candidate !== void 0 && candidate !== null) {
941
- candidate.click();
942
- return;
943
- }
944
- window.dispatchEvent(new KeyboardEvent("keydown", {
945
- key: "Escape",
946
- bubbles: true
947
- }));
948
- }, []);
949
1066
  return (0, react_jsx_runtime.jsxs)("div", {
950
1067
  ref: appRef,
951
1068
  className: wide ? "app app-wide" : "app",
@@ -1008,23 +1125,6 @@ window.__ModuleLoader__.load({
1008
1125
  })
1009
1126
  ]
1010
1127
  }),
1011
- (0, react_jsx_runtime.jsx)("button", {
1012
- type: "button",
1013
- className: "app-close",
1014
- "data-testid": "xdpool-close",
1015
- title: t?.("shell.close") ?? "关闭",
1016
- "aria-label": t?.("shell.close") ?? "关闭",
1017
- onClick: closeHostDialog,
1018
- children: (0, react_jsx_runtime.jsx)("svg", {
1019
- viewBox: "0 0 24 24",
1020
- fill: "none",
1021
- stroke: "currentColor",
1022
- strokeWidth: "1.8",
1023
- strokeLinecap: "round",
1024
- "aria-hidden": "true",
1025
- children: (0, react_jsx_runtime.jsx)("path", { d: "M6 6l12 12M18 6L6 18" })
1026
- })
1027
- }),
1028
1128
  pop !== "update" ? null : (0, react_jsx_runtime.jsxs)("div", {
1029
1129
  ref: popRef,
1030
1130
  className: "pop",
@@ -15200,27 +15300,6 @@ window.__ModuleLoader__.load({
15200
15300
  })
15201
15301
  });
15202
15302
  //#endregion
15203
- //#region src/siblings.ts
15204
- function paidSiblingOf(model, models) {
15205
- let best;
15206
- for (const candidate of models) {
15207
- if (candidate.id === model.id) continue;
15208
- if (candidate.name !== model.name) continue;
15209
- const multiplier = candidate.multiplier;
15210
- if (multiplier === void 0 || multiplier <= 0) continue;
15211
- if (best === void 0 || multiplier < best.multiplier) best = {
15212
- id: candidate.id,
15213
- name: candidate.name,
15214
- multiplier
15215
- };
15216
- }
15217
- return best;
15218
- }
15219
- function paidAlternativeFor(model, models) {
15220
- if (model.multiplier !== 0) return void 0;
15221
- return paidSiblingOf(model, models);
15222
- }
15223
- //#endregion
15224
15303
  //#region src/client/backup-crypto.ts
15225
15304
  const ENCRYPTED_FORMAT = "dsh-xdpool/backup-encrypted";
15226
15305
  const ITERATIONS = 31e4;
@@ -16052,50 +16131,12 @@ window.__ModuleLoader__.load({
16052
16131
  if (value === void 0) return "–";
16053
16132
  return new Intl.NumberFormat(void 0, { maximumFractionDigits: 0 }).format(value);
16054
16133
  }
16055
- function formatTime(value) {
16056
- return new Intl.DateTimeFormat(void 0, {
16057
- month: "2-digit",
16058
- day: "2-digit",
16059
- hour: "2-digit",
16060
- minute: "2-digit"
16061
- }).format(new Date(value));
16062
- }
16063
- function formatDateTime(value) {
16064
- if (value === void 0) return "";
16065
- const ms = Date.parse(value);
16066
- if (Number.isNaN(ms)) return value;
16067
- return new Intl.DateTimeFormat(void 0, {
16068
- month: "2-digit",
16069
- day: "2-digit",
16070
- hour: "2-digit",
16071
- minute: "2-digit"
16072
- }).format(new Date(ms));
16073
- }
16074
16134
  const AUTOMATION_POLL_MS = 2e3;
16075
16135
  const AUTOMATION_POLL_ATTEMPTS = 90;
16076
16136
  function hoursOrDefault(configured, fallback) {
16077
16137
  return configured !== void 0 && configured.length > 0 ? [...configured] : [...fallback];
16078
16138
  }
16079
16139
  const REGION_CARDS = ["cn", "global"];
16080
- function formatExpiry(ms) {
16081
- if (ms === void 0 || !Number.isFinite(ms)) return "";
16082
- return new Intl.DateTimeFormat(void 0, {
16083
- month: "2-digit",
16084
- day: "2-digit",
16085
- hour: "2-digit",
16086
- minute: "2-digit",
16087
- hour12: false
16088
- }).format(new Date(ms));
16089
- }
16090
- function daysUntil(ms) {
16091
- if (ms === void 0 || !Number.isFinite(ms)) return void 0;
16092
- return Math.max(0, Math.floor((ms - Date.now()) / 864e5));
16093
- }
16094
- function isExpiringSoon(pack) {
16095
- if (pack.monthly === true) return false;
16096
- const days = daysUntil(pack.expiresAtMs);
16097
- return days !== void 0 && days <= 3;
16098
- }
16099
16140
  function PoolCard({ t, settingsScope }) {
16100
16141
  const settingsWritable = settingsScope?.getSnapshot().writable === true;
16101
16142
  const [sidebarRow, setSidebarRowState] = (0, react.useState)(() => readSidebarRow(settingsScope));
@@ -16460,34 +16501,6 @@ window.__ModuleLoader__.load({
16460
16501
  }
16461
16502
  }
16462
16503
  };
16463
- const saveCreditReserve = async (region, accountId, reserve) => {
16464
- setReserveBusy(accountId);
16465
- setFlash(void 0);
16466
- try {
16467
- const response = await fetch(POOL_CREDIT_RESERVE_PATH, {
16468
- method: "POST",
16469
- headers: {
16470
- "accept": "application/json",
16471
- "content-type": "application/json"
16472
- },
16473
- credentials: "same-origin",
16474
- body: JSON.stringify({
16475
- accountId,
16476
- reserve
16477
- })
16478
- });
16479
- const body = await response.json();
16480
- if (!response.ok) throw new Error(body.error ?? `HTTP ${response.status}`);
16481
- await refresh(region);
16482
- if (mounted.current) setFlash(reserve > 0 ? t?.("row.reserveSaved", { credits: reserve }) ?? `Keeping ${reserve} credits` : t?.("row.reserveCleared") ?? "Reserve cleared");
16483
- return true;
16484
- } catch (cause) {
16485
- if (mounted.current) setError(cause instanceof Error ? cause.message : String(cause));
16486
- return false;
16487
- } finally {
16488
- if (mounted.current) setReserveBusy(void 0);
16489
- }
16490
- };
16491
16504
  t?.("row.title");
16492
16505
  t?.("row.desc");
16493
16506
  return (0, react_jsx_runtime.jsx)(PoolShell, {
@@ -16533,7 +16546,7 @@ window.__ModuleLoader__.load({
16533
16546
  const rows = here?.accounts ?? [];
16534
16547
  if (rows.length === 0) return null;
16535
16548
  return (0, react_jsx_runtime.jsxs)("section", {
16536
- className: "sec dsm-xdpool-accounts",
16549
+ className: "sec",
16537
16550
  children: [(0, react_jsx_runtime.jsx)("div", {
16538
16551
  className: "sec-head",
16539
16552
  children: (0, react_jsx_runtime.jsxs)("span", {
@@ -16541,28 +16554,25 @@ window.__ModuleLoader__.load({
16541
16554
  children: [region === "cn" ? t?.("row.tabCn") ?? "CN" : t?.("row.tabGlobal") ?? "Global", ` · ${String(rows.length)}`]
16542
16555
  })
16543
16556
  }), (0, react_jsx_runtime.jsx)("div", {
16544
- className: "accts",
16545
- children: rows.map((account) => (0, react_jsx_runtime.jsx)(AccountBlock, {
16557
+ className: "xdp-accts",
16558
+ children: rows.map((account) => (0, react_jsx_runtime.jsx)(AccountCard, {
16546
16559
  account,
16547
- models: here?.models ?? [],
16548
16560
  t,
16549
- ...checkinBusyId === void 0 ? {} : { checkinBusyId },
16550
- onClaimCheckin: (id) => {
16551
- claimCheckin(region, id);
16552
- },
16553
- ...accountBusyId === void 0 ? {} : { accountBusyId },
16554
- onToggleDisabled: (id, disabled) => {
16555
- toggleAccountDisabled(region, id, disabled);
16561
+ serving: here?.activeAccountId === account.id,
16562
+ ...checkinBusyId === account.id ? { claiming: true } : {},
16563
+ ...accountBusyId === account.id ? { busy: true } : {},
16564
+ onClaim: () => {
16565
+ claimCheckin(region, account.id);
16556
16566
  },
16557
- onIgnoreAccount: (id) => {
16558
- setAccountIgnored(region, id, true);
16567
+ onToggle: (disabled) => {
16568
+ toggleAccountDisabled(region, account.id, disabled);
16559
16569
  },
16560
- onPreferAccount: (id) => {
16570
+ onPrefer: (id) => {
16561
16571
  setPreferredAccount(region, id);
16562
16572
  },
16563
- onSaveCreditReserve: (id, reserve) => saveCreditReserve(region, id, reserve),
16564
- ...reserveBusy === void 0 ? {} : { reserveBusyId: reserveBusy },
16565
- serving: here?.activeAccountId === account.id
16573
+ onIgnore: () => {
16574
+ setAccountIgnored(region, account.id, true);
16575
+ }
16566
16576
  }, account.id))
16567
16577
  })]
16568
16578
  }, region);
@@ -16592,346 +16602,6 @@ window.__ModuleLoader__.load({
16592
16602
  }) })
16593
16603
  });
16594
16604
  }
16595
- function AccountBlock({ account, models, t, checkinBusyId, onClaimCheckin, accountBusyId, onToggleDisabled, onIgnoreAccount, onPreferAccount, onSaveCreditReserve, reserveBusyId, serving }) {
16596
- const isDisabled = account.disabled === true;
16597
- const isPreferred = account.preferred === true;
16598
- const isCooling = account.cooling === true;
16599
- const isDead = account.credentialDead === true;
16600
- const cooldownUntil = account.cooldownUntil !== void 0 ? Date.parse(account.cooldownUntil) : void 0;
16601
- const modelCooldowns = account.modelCooldowns ?? [];
16602
- const tag = isDead ? {
16603
- text: t?.("row.credentialDeadTag") ?? "Sign-in rejected",
16604
- cls: "pill"
16605
- } : isCooling ? {
16606
- text: t?.("row.cooling") ?? "Cooling",
16607
- cls: "pill"
16608
- } : null;
16609
- return (0, react_jsx_runtime.jsxs)("div", {
16610
- className: isDisabled ? "is-off" : "ch",
16611
- "data-serving": serving === true ? "true" : void 0,
16612
- children: [(0, react_jsx_runtime.jsxs)("div", {
16613
- className: "ch-head",
16614
- children: [
16615
- (0, react_jsx_runtime.jsx)("span", {
16616
- className: "ch-title",
16617
- children: account.label
16618
- }),
16619
- serving === true ? (0, react_jsx_runtime.jsxs)("span", {
16620
- className: "acct-head",
16621
- children: [(0, react_jsx_runtime.jsx)("span", { className: "acct-dot" }), (0, react_jsx_runtime.jsx)("span", {
16622
- className: "acct-name",
16623
- children: t?.("row.currentAccount") ?? "In use now"
16624
- })]
16625
- }) : null,
16626
- tag === null ? null : (0, react_jsx_runtime.jsx)("span", {
16627
- className: tag.cls,
16628
- children: tag.text
16629
- }),
16630
- (0, react_jsx_runtime.jsxs)("button", {
16631
- type: "button",
16632
- className: isPreferred ? "is-on" : "tiny",
16633
- "aria-pressed": isPreferred,
16634
- title: isPreferred ? t?.("row.accountPreferClearHint") ?? "Stop preferring this account; the distribution strategy decides again" : t?.("row.accountPreferHint") ?? "Try this account first while it stays healthy",
16635
- disabled: accountBusyId === account.id || accountBusyId === "none",
16636
- onClick: () => {
16637
- onPreferAccount(isPreferred ? null : account.id);
16638
- },
16639
- children: [(0, react_jsx_runtime.jsx)("span", {
16640
- className: "tiny",
16641
- "aria-hidden": "true",
16642
- children: "★"
16643
- }), isPreferred ? t?.("row.accountPreferOn") ?? "Preferred" : t?.("row.accountPrefer") ?? "Prefer"]
16644
- }),
16645
- (0, react_jsx_runtime.jsxs)("button", {
16646
- type: "button",
16647
- role: "switch",
16648
- "aria-checked": !isDisabled,
16649
- className: isDisabled ? "sw" : "is-on",
16650
- title: t?.("row.accountToggleHint") ?? "Enable this account (uncheck to keep it out of the pool)",
16651
- disabled: accountBusyId === account.id,
16652
- onClick: () => {
16653
- onToggleDisabled(account.id, !isDisabled);
16654
- },
16655
- children: [(0, react_jsx_runtime.jsx)("span", { className: "acct-dot" }), isDisabled ? t?.("row.accountOff") ?? "Disabled" : t?.("row.accountInRotation") ?? "Enabled"]
16656
- }),
16657
- (0, react_jsx_runtime.jsx)("button", {
16658
- type: "button",
16659
- className: "ch-count",
16660
- title: t?.("row.accountIgnoreHint") ?? "Remove this account from the pool for good",
16661
- disabled: accountBusyId === account.id,
16662
- onClick: () => {
16663
- onIgnoreAccount(account.id);
16664
- },
16665
- children: t?.("row.accountIgnore") ?? "Remove"
16666
- })
16667
- ]
16668
- }), (0, react_jsx_runtime.jsxs)("div", {
16669
- className: "ch-titles",
16670
- children: [
16671
- (0, react_jsx_runtime.jsxs)("div", {
16672
- className: "ch-titles",
16673
- children: [
16674
- account.expiresAt !== void 0 ? (0, react_jsx_runtime.jsx)("span", {
16675
- className: "ch-org",
16676
- children: t?.("row.tokenExpiry", { time: formatDateTime(account.expiresAt) }) ?? `token ${formatDateTime(account.expiresAt)}`
16677
- }) : null,
16678
- isCooling && cooldownUntil !== void 0 && !Number.isNaN(cooldownUntil) ? (0, react_jsx_runtime.jsxs)("span", {
16679
- className: "ch-org",
16680
- children: [
16681
- t?.("row.cooldownUntil", { time: formatTime(cooldownUntil) }) ?? `until ${formatTime(cooldownUntil)}`,
16682
- " · ",
16683
- t?.("row.cooldownHits", { hits: account.rateLimitHits ?? 0 }) ?? `${account.rateLimitHits ?? 0} hit(s)`
16684
- ]
16685
- }) : null,
16686
- isDead ? (0, react_jsx_runtime.jsx)("span", {
16687
- className: "ch-org",
16688
- children: t?.("row.credentialDeadHint") ?? "Sign in again in the WorkBuddy desktop app to restore it"
16689
- }) : null,
16690
- modelCooldowns.length > 0 ? (0, react_jsx_runtime.jsx)("div", {
16691
- className: "ch-note",
16692
- children: modelCooldowns.map((mc) => {
16693
- const coolingModel = models.find((model) => model.id === mc.modelId);
16694
- const twin = coolingModel === void 0 ? void 0 : paidAlternativeFor(coolingModel, models);
16695
- return (0, react_jsx_runtime.jsxs)("span", {
16696
- className: "badge",
16697
- children: [t?.("row.modelCooling", {
16698
- model: mc.modelId,
16699
- time: formatDateTime(mc.until)
16700
- }) ?? `${mc.modelId} cooling to ${formatDateTime(mc.until)}`, twin === void 0 ? null : (0, react_jsx_runtime.jsx)("span", {
16701
- className: "badge",
16702
- title: t?.("row.paidTwinHint") ?? "Same model, paid row",
16703
- children: t?.("row.rateLimitedPaidTwin", {
16704
- id: twin.id,
16705
- rate: twin.multiplier.toFixed(2)
16706
- }) ?? `→ ${twin.id} (${twin.multiplier.toFixed(2)}x) still works`
16707
- })]
16708
- }, mc.modelId);
16709
- })
16710
- }) : null
16711
- ]
16712
- }),
16713
- (0, react_jsx_runtime.jsx)(AccountStats, {
16714
- account,
16715
- t,
16716
- checkinBusy: checkinBusyId === account.id,
16717
- onClaim: onClaimCheckin
16718
- }),
16719
- (0, react_jsx_runtime.jsx)(CreditReserveRow, {
16720
- account,
16721
- t,
16722
- busy: reserveBusyId === account.id,
16723
- onSave: onSaveCreditReserve
16724
- }),
16725
- account.automationToday === void 0 ? null : (0, react_jsx_runtime.jsxs)("div", {
16726
- className: "fact",
16727
- children: [(0, react_jsx_runtime.jsx)("span", {
16728
- className: "td-name",
16729
- children: t?.("row.autoEarned") ?? "Automation today"
16730
- }), (0, react_jsx_runtime.jsxs)("span", {
16731
- className: "facts",
16732
- children: [
16733
- account.automationToday.credit > 0 ? (0, react_jsx_runtime.jsx)("span", {
16734
- className: "fact",
16735
- children: t?.("row.autoFromTasks", {
16736
- credit: account.automationToday.credit,
16737
- energy: account.automationToday.energy,
16738
- count: account.automationToday.claimed
16739
- }) ?? `Tasks +${account.automationToday.credit}`
16740
- }) : null,
16741
- account.automationToday.checkinCredit > 0 ? (0, react_jsx_runtime.jsx)("span", {
16742
- className: "fact",
16743
- children: t?.("row.autoFromCheckin", { credit: account.automationToday.checkinCredit }) ?? `Check-in +${account.automationToday.checkinCredit}`
16744
- }) : null,
16745
- account.automationToday.bonusCredit > 0 ? (0, react_jsx_runtime.jsx)("span", {
16746
- className: "fact",
16747
- children: t?.("row.autoFromBonus", { credit: account.automationToday.bonusCredit }) ?? `Streak +${account.automationToday.bonusCredit}`
16748
- }) : null,
16749
- account.automationToday.travelCredit > 0 ? (0, react_jsx_runtime.jsx)("span", {
16750
- className: "fact",
16751
- children: t?.("row.autoFromTravel", { credit: account.automationToday.travelCredit }) ?? `Buddy +${account.automationToday.travelCredit}`
16752
- }) : null,
16753
- account.automationToday.compensationCredit > 0 ? (0, react_jsx_runtime.jsx)("span", {
16754
- className: "fact",
16755
- children: t?.("row.autoFromCompensation", { credit: account.automationToday.compensationCredit }) ?? `Compensation +${account.automationToday.compensationCredit}`
16756
- }) : null
16757
- ]
16758
- })]
16759
- })
16760
- ]
16761
- })]
16762
- });
16763
- }
16764
- function CreditReserveRow({ account, t, busy, onSave }) {
16765
- const saved = account.creditReserve ?? 0;
16766
- const [draft, setDraft] = (0, react.useState)(String(saved));
16767
- const [settled, setSettled] = (0, react.useState)(saved);
16768
- const [note, setNote] = (0, react.useState)(void 0);
16769
- (0, react.useEffect)(() => {
16770
- setSettled(saved);
16771
- setDraft((current) => current === String(saved) ? current : String(saved));
16772
- }, [saved]);
16773
- const parsed = Number.parseInt(draft, 10);
16774
- const next = Number.isFinite(parsed) && parsed > 0 ? Math.floor(parsed) : 0;
16775
- const dirty = next !== settled;
16776
- const commit = async () => {
16777
- if (busy || !dirty) return;
16778
- setNote(void 0);
16779
- if (await onSave(account.id, next)) {
16780
- setSettled(next);
16781
- setDraft(String(next));
16782
- setNote("saved");
16783
- } else setNote("failed");
16784
- };
16785
- return (0, react_jsx_runtime.jsxs)("div", {
16786
- className: "row",
16787
- children: [
16788
- (0, react_jsx_runtime.jsx)("span", {
16789
- className: "field",
16790
- children: t?.("row.reserveTitle") ?? "Keep at least"
16791
- }),
16792
- (0, react_jsx_runtime.jsx)("input", {
16793
- type: "number",
16794
- min: 0,
16795
- step: 1,
16796
- value: draft,
16797
- disabled: busy,
16798
- className: "input",
16799
- "aria-label": t?.("row.reserveTitle") ?? "Keep at least",
16800
- onChange: (event) => {
16801
- setDraft(event.target.value);
16802
- setNote(void 0);
16803
- },
16804
- onKeyDown: (event) => {
16805
- if (event.key === "Enter") commit();
16806
- }
16807
- }),
16808
- (0, react_jsx_runtime.jsx)("span", {
16809
- className: "kpi-u",
16810
- children: t?.("row.reserveUnit") ?? "credits"
16811
- }),
16812
- (0, react_jsx_runtime.jsx)("button", {
16813
- type: "button",
16814
- className: "tiny",
16815
- disabled: busy || !dirty,
16816
- onClick: () => {
16817
- commit();
16818
- },
16819
- children: busy ? t?.("row.reserveSaving") ?? "Saving…" : t?.("row.reserveSave") ?? "Save"
16820
- }),
16821
- note === "saved" ? (0, react_jsx_runtime.jsx)("span", {
16822
- className: "hint",
16823
- children: next > 0 ? t?.("row.reserveSaved", { credits: next }) ?? `Keeping ${next} credits` : t?.("row.reserveCleared") ?? "Reserve cleared"
16824
- }) : null,
16825
- note === "failed" ? (0, react_jsx_runtime.jsx)("span", {
16826
- className: "hint",
16827
- children: t?.("row.reserveFailed") ?? "Not saved — try again"
16828
- }) : null,
16829
- account.reserved === true ? (0, react_jsx_runtime.jsx)("span", {
16830
- className: "pill",
16831
- children: t?.("row.reserveHolding") ?? "Reserved: skipped"
16832
- }) : null
16833
- ]
16834
- });
16835
- }
16836
- function AccountStats({ account, t, checkinBusy, onClaim }) {
16837
- const credits = account.credits;
16838
- const checkin = account.checkin;
16839
- const hasCredits = credits !== void 0 || account.creditsError !== void 0;
16840
- const hasCheckin = checkin !== void 0 || account.checkinError !== void 0;
16841
- if (!hasCredits && !hasCheckin) return null;
16842
- const packages = (credits?.packages ?? []).filter((p) => (p.size ?? 0) > 0).slice(0, 6);
16843
- return (0, react_jsx_runtime.jsxs)("div", {
16844
- className: "kpis",
16845
- children: [
16846
- (0, react_jsx_runtime.jsxs)("span", {
16847
- className: "sec kpi-v",
16848
- children: [(0, react_jsx_runtime.jsx)("span", {
16849
- className: "sec-title",
16850
- children: t?.("row.creditsTotal") ?? "Total"
16851
- }), (0, react_jsx_runtime.jsx)("span", {
16852
- className: "kpi-v",
16853
- children: formatNumber(credits?.total)
16854
- })]
16855
- }),
16856
- hasCheckin ? (0, react_jsx_runtime.jsx)("div", {
16857
- className: "sec",
16858
- children: account.checkinError !== void 0 ? (0, react_jsx_runtime.jsx)("span", {
16859
- className: "hint",
16860
- title: account.checkinError,
16861
- children: t?.("row.checkinUnavailable") ?? "check-in unavailable"
16862
- }) : checkin === void 0 ? null : (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
16863
- (0, react_jsx_runtime.jsxs)("div", {
16864
- className: "hint",
16865
- children: [(0, react_jsx_runtime.jsx)("span", {
16866
- className: "pill",
16867
- children: t?.("row.checkinStreak", { days: checkin.streakDays }) ?? `${checkin.streakDays}-day streak`
16868
- }), checkin.dailyCredit > 0 ? (0, react_jsx_runtime.jsx)("span", {
16869
- className: "fact",
16870
- children: t?.("row.checkinDaily", { credit: formatNumber(checkin.dailyCredit) }) ?? `+${formatNumber(checkin.dailyCredit)}/day`
16871
- }) : null]
16872
- }),
16873
- checkin.isStreakDay && checkin.streakBonusCredit > 0 ? (0, react_jsx_runtime.jsx)("span", {
16874
- className: "fact",
16875
- children: t?.("row.checkinStreakBonus", {
16876
- days: formatNumber(checkin.nextStreakDay),
16877
- credit: formatNumber(checkin.streakBonusCredit)
16878
- }) ?? `bonus +${formatNumber(checkin.streakBonusCredit)}`
16879
- }) : null,
16880
- (0, react_jsx_runtime.jsx)("button", {
16881
- type: "button",
16882
- className: "tiny",
16883
- disabled: !checkin.active || checkin.todayCheckedIn || checkinBusy,
16884
- onClick: () => {
16885
- onClaim(account.id);
16886
- },
16887
- children: !checkin.active ? t?.("row.checkinInactive") ?? "Unavailable" : checkin.todayCheckedIn ? t?.("row.checkinClaimed") ?? "Checked in" : checkinBusy ? t?.("row.checkinClaiming") ?? "Checking in…" : t?.("row.checkinClaim") ?? "Check in"
16888
- })
16889
- ] })
16890
- }) : null,
16891
- hasCredits ? (0, react_jsx_runtime.jsxs)("ul", {
16892
- className: "facts sec",
16893
- children: [account.creditsError !== void 0 ? (0, react_jsx_runtime.jsx)("li", { children: (0, react_jsx_runtime.jsx)("span", {
16894
- className: `hint${account.credentialDead === true ? " is-bad" : ""}`,
16895
- title: account.creditsError,
16896
- children: account.credentialDead === true ? t?.("row.credentialDead") ?? "Sign-in rejected" : t?.("row.creditsError") ?? "credits unavailable"
16897
- }) }) : packages.length === 0 ? (0, react_jsx_runtime.jsx)("li", {
16898
- className: "hint",
16899
- children: "–"
16900
- }) : packages.map((pack, index) => {
16901
- const expiry = formatExpiry(pack.expiresAtMs);
16902
- const refresh = formatExpiry(pack.cycleRefreshMs);
16903
- const soon = isExpiringSoon(pack);
16904
- const when = pack.monthly === true ? refresh === "" ? null : t?.("row.creditsRefreshAt", { time: refresh }) ?? `Refreshes ${refresh}` : expiry === "" ? null : t?.("row.creditsExpiresAt", { time: expiry }) ?? `Expires ${expiry}`;
16905
- return (0, react_jsx_runtime.jsxs)("li", { children: [
16906
- (0, react_jsx_runtime.jsx)("span", {
16907
- className: "td-name",
16908
- children: pack.packageName
16909
- }),
16910
- (0, react_jsx_runtime.jsx)("span", {
16911
- className: "td-num",
16912
- children: t?.("row.creditsPackage", {
16913
- remain: formatNumber(pack.remain),
16914
- size: formatNumber(pack.size)
16915
- }) ?? `${formatNumber(pack.remain)} / ${formatNumber(pack.size)}`
16916
- }),
16917
- when === null ? null : (0, react_jsx_runtime.jsx)("span", {
16918
- className: `hint${soon ? " hint" : ""}`,
16919
- title: t?.("row.creditsExpiresSoonTitle") ?? "Expiring within 3 days",
16920
- children: when
16921
- })
16922
- ] }, `${pack.packageName}-${String(index)}`);
16923
- }), credits?.expiringSoon !== void 0 && credits.expiringSoon > 0 ? (0, react_jsx_runtime.jsxs)("li", {
16924
- className: "hint",
16925
- children: [
16926
- t?.("row.creditsSoon") ?? "Expiring in 3 days",
16927
- " ",
16928
- formatNumber(credits.expiringSoon)
16929
- ]
16930
- }) : null]
16931
- }) : null
16932
- ]
16933
- });
16934
- }
16935
16605
  //#endregion
16936
16606
  //#region src/client/CreditDot.tsx
16937
16607
  const POLL_MS = 45e3;
@@ -19962,26 +19632,6 @@ label.sw:has(input:disabled) { opacity: .5; cursor: not-allowed }
19962
19632
  .app[data-w="phone"] .sec-actions{margin-left:0;width:100%}
19963
19633
  .app[data-w="phone"] .vendors{grid-template-columns:minmax(0,1fr)}
19964
19634
  .app[data-w="phone"] .kpis .kpi:last-child:nth-child(odd){grid-column:1 / -1}
19965
- /* ============================================================
19966
- 插件自己加的:右上角关闭
19967
- ------------------------------------------------------------
19968
- 不属于设计稿。设置对话框撑满整个插件页面,宿主的关闭按钮在它自己的
19969
- 标题栏里、位置随宿主管;这里给一个就地入口,点击的落点见 shell.tsx
19970
- 的 closeHostDialog。样式跟随设计变量,两套主题都不用另写。
19971
- ============================================================ */
19972
- .app-close{
19973
- position:absolute;top:8px;right:8px;z-index:70;
19974
- width:28px;height:28px;display:grid;place-items:center;
19975
- border:1px solid var(--line-2);border-radius:var(--r-sm);
19976
- background:color-mix(in oklch, var(--surface) 88%, transparent);
19977
- color:var(--muted);cursor:pointer;
19978
- transition:color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
19979
- }
19980
- .app-close svg{width:14px;height:14px}
19981
- .app-close:hover{color:var(--text);background:var(--surface-2);border-color:var(--line-3)}
19982
- .app-close:active{transform:translateY(1px)}
19983
- .app[data-w="phone"] .app-close{top:6px;right:6px;width:24px;height:24px}
19984
-
19985
19635
  `;
19986
19636
  //#endregion
19987
19637
  //#region src/client/credit-dot-css.ts
@@ -20184,7 +19834,7 @@ label.sw:has(input:disabled) { opacity: .5; cursor: not-allowed }
20184
19834
  //#endregion
20185
19835
  //#region src/client/design-style.ts
20186
19836
  const STYLE_ID = "dsh-xdpool/design.css";
20187
- const FULL_CSS = `${DESIGN_TOKENS_CSS}\n${DESIGN_DETAIL_CSS}\n${RESPONSIVE_CSS}\n${CREDIT_DOT_CSS}\n${LIGHT_THEME_CSS}`;
19837
+ const FULL_CSS = `${DESIGN_TOKENS_CSS}\n${DESIGN_DETAIL_CSS}\n${RESPONSIVE_CSS}\n${CREDIT_DOT_CSS}\n${ACCOUNT_CARD_CSS}\n${LIGHT_THEME_CSS}`;
20188
19838
  function installDesignCss() {
20189
19839
  if (typeof document === "undefined") return;
20190
19840
  const head = document.head;
@@ -20601,7 +20251,6 @@ label.sw:has(input:disabled) { opacity: .5; cursor: not-allowed }
20601
20251
  "chan.ownedElsewhereRow": "Sign in on the “Our Free Model” page",
20602
20252
  "chan.empty": "No channel is connected yet.",
20603
20253
  "shell.brand": "XD Pool",
20604
- "shell.close": "Close",
20605
20254
  "shell.themeLight": "Eye-care green",
20606
20255
  "shell.themeDark": "Dark",
20607
20256
  "shell.themeToLight": "Switch to the eye-care green (light) theme",
@@ -21325,7 +20974,6 @@ label.sw:has(input:disabled) { opacity: .5; cursor: not-allowed }
21325
20974
  "chan.ownedElsewhereRow": "在「我们的免费模型」里登录",
21326
20975
  "chan.empty": "还没有任何渠道连上来。",
21327
20976
  "shell.brand": "XD Pool",
21328
- "shell.close": "关闭",
21329
20977
  "shell.themeLight": "护眼绿",
21330
20978
  "shell.themeDark": "暗色",
21331
20979
  "shell.themeToLight": "切换到护眼绿(亮色)主题",
package/lib/index.d.ts CHANGED
@@ -3661,6 +3661,16 @@ interface WorkBuddyAdapterOptions {
3661
3661
  * without a restart.
3662
3662
  */
3663
3663
  extraRows?: (() => readonly FreeModelRow[]) | undefined;
3664
+ /**
3665
+ * Whether this region's pool holds at least one account — issue #204.
3666
+ *
3667
+ * Without it the provider published the built-in roster even on a machine with
3668
+ * nobody signed in: the picker showed a full WorkBuddy group whose every call
3669
+ * could only fail. Both other adapters answer "no catalogue" when they have no
3670
+ * credential (`providerCatalogVisible` in the pack, and the Doubao adapter
3671
+ * since #169), and this one is no different.
3672
+ */
3673
+ hasAccounts?: (() => boolean) | undefined;
3664
3674
  }
3665
3675
  /** What {@link createWorkBuddyAdapter} hands back. */
3666
3676
  interface WorkBuddyAdapter {
package/lib/index.js CHANGED
@@ -26954,6 +26954,12 @@ function createWorkBuddyAdapter(options) {
26954
26954
  const aggregateCatalog = isAggregateCatalog(catalog);
26955
26955
  const extraRows = options.extraRows;
26956
26956
  const buildModels = () => {
26957
+ /**
26958
+ * No account, no catalogue — issue #204. Answered before anything else so a
26959
+ * machine that never signed in shows no group at all rather than a list of
26960
+ * models that cannot answer.
26961
+ */
26962
+ if (options.hasAccounts?.() === false) return [];
26957
26963
  const baseUrl = `${shim.baseUrl()}/v1`;
26958
26964
  if (extraRows !== void 0) return (extraRows() ?? []).map((row) => toExtraLaneModel(row, baseUrl, providerId));
26959
26965
  if (aggregateCatalog) return [...catalog.providerRows().map((row) => toAggregateModel(row, baseUrl, providerId)), ...catalog.comboRows().map((row) => toComboModel(row, baseUrl, providerId))];
@@ -29306,7 +29312,7 @@ function parseBody(body) {
29306
29312
  *
29307
29313
  * @module dsh-xdpool/version
29308
29314
  */
29309
- const POOL_VERSION = "3.0.4";
29315
+ const POOL_VERSION = "3.0.6";
29310
29316
  //#endregion
29311
29317
  //#region src/update-check.ts
29312
29318
  /**
@@ -38962,14 +38968,30 @@ function apply(ctx, config = {}) {
38962
38968
  shim: shims.cn,
38963
38969
  catalog: core.catalogs.cn,
38964
38970
  providerId: POOL_PROVIDER_BY_REGION.cn,
38965
- displayName: POOL_NAME_BY_REGION.cn
38971
+ displayName: POOL_NAME_BY_REGION.cn,
38972
+ /**
38973
+ * 池里没有这个区域的账号时,不发布任何模型 —— issue #204。
38974
+ *
38975
+ * 之前会照发内置目录,于是没登录的人也看到一整组 WorkBuddy 模型,
38976
+ * 点任何一个都只会失败。区域按账号自己的 domain 判定,和池子的
38977
+ * 选号逻辑用同一个函数。
38978
+ */
38979
+ hasAccounts: () => core.pool.list("cn").length > 0
38966
38980
  }),
38967
38981
  global: createWorkBuddyAdapter({
38968
38982
  ctx,
38969
38983
  shim: shims.global,
38970
38984
  catalog: core.catalogs.global,
38971
38985
  providerId: POOL_PROVIDER_BY_REGION.global,
38972
- displayName: POOL_NAME_BY_REGION.global
38986
+ displayName: POOL_NAME_BY_REGION.global,
38987
+ /**
38988
+ * 池里没有这个区域的账号时,不发布任何模型 —— issue #204。
38989
+ *
38990
+ * 之前会照发内置目录,于是没登录的人也看到一整组 WorkBuddy 模型,
38991
+ * 点任何一个都只会失败。区域按账号自己的 domain 判定,和池子的
38992
+ * 选号逻辑用同一个函数。
38993
+ */
38994
+ hasAccounts: () => core.pool.list("global").length > 0
38973
38995
  }),
38974
38996
  aggregate: createWorkBuddyAdapter({
38975
38997
  ctx,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "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.4",
5
+ "version": "3.0.6",
6
6
  "license": "MIT",
7
7
  "author": "XDTrees",
8
8
  "homepage": "https://github.com/XDTrees/dsh-xdpool#readme",
@@ -30199,7 +30199,28 @@ var AccountPool = class {
30199
30199
  * **必须连同黑名单一起写回**:两种后端都是整体写入,
30200
30200
  * 只写 `{ accounts }` 会把同一文档里的 `disabledModels` 抹掉。
30201
30201
  */
30202
- async writeAccounts(accounts) {
30202
+ async writeAccounts(accounts, options = {}) {
30203
+ /**
30204
+ * [xdpool-local] 空表保护 —— issue #200。
30205
+ *
30206
+ * 升级/重装过程中出现过「账号表被写成空、且没有 .bak」的报告:用户的 5 个
30207
+ * 账号在界面上消失,磁盘上也没有可恢复的旧版本。一条空快照覆盖一张非空表
30208
+ * 几乎总是故障(读失败、并发写、装包时的空状态),而不是用户意图 —— 逐个
30209
+ * 删除账号走的是 `removeAccount`,那条路径显式传 `allowEmpty`。
30210
+ *
30211
+ * 拒绝时保留内存与磁盘上的旧表,并留下可查的日志;真要一次性清空(迁移、
30212
+ * 重置)可以设 `DSH_XDPOOL_ALLOW_EMPTY_ACCOUNTS=1`。
30213
+ */
30214
+ const empty = Array.isArray(accounts) && accounts.length === 0
30215
+ const hadRows = Array.isArray(this.cache) && this.cache.length > 0
30216
+ const forced = typeof process !== 'undefined' && process.env.DSH_XDPOOL_ALLOW_EMPTY_ACCOUNTS === '1'
30217
+ if (empty && hadRows && options.allowEmpty !== true && !forced) {
30218
+ this.ctx.logger?.warn?.(
30219
+ `[channel-pack] 拒绝用空账号表覆盖现有 ${this.cache.length} 个账号(疑似升级/重装时的空快照);`
30220
+ + '确需清空请逐个删除,或设 DSH_XDPOOL_ALLOW_EMPTY_ACCOUNTS=1'
30221
+ )
30222
+ return
30223
+ }
30203
30224
  this.cache = accounts;
30204
30225
  this.loaded = true;
30205
30226
  if (this.store.kind === "memory") {
@@ -30664,7 +30685,8 @@ var AccountPool = class {
30664
30685
  await this.ctx.credentials.unset(credentialRef(entry.credentialRef));
30665
30686
  } catch {
30666
30687
  }
30667
- await this.writeAccounts(this.readAccounts().filter((a) => a.id !== id));
30688
+ // 显式删除:删到空也要写进去,所以带上 allowEmpty。
30689
+ await this.writeAccounts(this.readAccounts().filter((a) => a.id !== id), { allowEmpty: true });
30668
30690
  }
30669
30691
  /**
30670
30692
  * 重排某 provider 下账号的顺序(Channel Pack 拖拽排序)。