dsh-xdpool 3.0.6 → 3.0.8

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/lib/client.js CHANGED
@@ -42,6 +42,7 @@ window.__ModuleLoader__.load({
42
42
  const POOL_STATUS_PATH = "/plugins/dsh-xdpool/status";
43
43
  const POOL_CATALOG_REFRESH_PATH = "/plugins/dsh-xdpool/models/refresh";
44
44
  const POOL_CHECKIN_PATH = "/plugins/dsh-xdpool/checkin";
45
+ const POOL_MODELS_SAVE_PATH = "/plugins/dsh-xdpool/models/save";
45
46
  const POOL_ACCOUNT_IGNORE_PATH = "/plugins/dsh-xdpool/accounts/ignored";
46
47
  const POOL_AUTOMATION_RUN_PATH = "/plugins/dsh-xdpool/automation/run";
47
48
  const POOL_UPDATE_CHECK_PATH = "/plugins/dsh-xdpool/update";
@@ -92,12 +93,16 @@ window.__ModuleLoader__.load({
92
93
  const POOL_DOUBAO_QUOTA_PATH = "/plugins/dsh-xdpool/doubao/quota";
93
94
  const POOL_DOUBAO_MODELS_PATH = "/plugins/dsh-xdpool/doubao/models";
94
95
  const POOL_DOUBAO_CLAIM_PATH = "/plugins/dsh-xdpool/doubao/claim";
96
+ const POOL_LOGIN_PREFERENCES_PATH = "/plugins/dsh-xdpool/login-preferences";
97
+ const POOL_ROUTE_TRACE_PATH = "/plugins/dsh-xdpool/route-trace";
95
98
  const ROUTE_OWNED_ELSEWHERE = "already-mounted-elsewhere";
96
99
  const POOL_COMBOS_PATH = "/plugins/dsh-xdpool/combos";
97
100
  const POOL_COMBOS_SAVE_PATH = "/plugins/dsh-xdpool/combos/save";
101
+ const POOL_GROUPS_PATH = "/plugins/dsh-xdpool/groups";
98
102
  const POOL_RELAY_PATH = "/plugins/dsh-xdpool/relay";
99
103
  const CHANNEL_PACK_RPC_PATH = "/api/channel-pack";
100
104
  const POOL_USAGE_PATH = "/plugins/dsh-xdpool/usage";
105
+ const POOL_SESSION_ROUTE_PATH = "/plugins/dsh-xdpool/session";
101
106
  Object.freeze([
102
107
  "priority",
103
108
  "round-robin",
@@ -189,7 +194,7 @@ window.__ModuleLoader__.load({
189
194
  onClick: () => {
190
195
  onPrefer(account.preferred ? null : account.id);
191
196
  },
192
- children: account.preferred ? t?.("row.accountPreferOn") ?? "优先" : t?.("row.accountPrefer") ?? "优先"
197
+ children: account.preferred ? t?.("row.accountPreferOn") ?? "取消优先" : t?.("row.accountPrefer") ?? "优先用此账号"
193
198
  }),
194
199
  (0, react_jsx_runtime.jsx)("button", {
195
200
  type: "button",
@@ -230,7 +235,7 @@ window.__ModuleLoader__.load({
230
235
  });
231
236
  }
232
237
  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)}
238
+ .xdp-accts{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:var(--s3)}
234
239
  .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
240
  .xdp-acct[data-serving="true"]{border-color:var(--accent-line)}
236
241
  .xdp-acct .xdp-acct-head{display:block;min-width:0}
@@ -269,7 +274,7 @@ window.__ModuleLoader__.load({
269
274
  const POOL_NAV_ICON_MASK_URL = `data:image/svg+xml;utf8,${encodeURIComponent(POOL_NAV_ICON_SVG)}`;
270
275
  //#endregion
271
276
  //#region src/version.ts
272
- const POOL_VERSION = "3.0.6";
277
+ const POOL_VERSION = "3.0.8";
273
278
  function compareVersions(left, right) {
274
279
  const parse = (value) => {
275
280
  const [core, ...rest] = value.trim().replace(/^v/u, "").split("-");
@@ -8078,6 +8083,7 @@ window.__ModuleLoader__.load({
8078
8083
  "baseUrl": "",
8079
8084
  "format": "openai-chat",
8080
8085
  "models": [],
8086
+ "modelsUrl": "/models",
8081
8087
  "notes": "Any OpenAI-compatible endpoint — vLLM, LiteLLM, one-api, LM Studio, a self-hosted gateway. Paste the base URL (ending in /v1) and the key on this card, then press Fetch models.",
8082
8088
  "website": null,
8083
8089
  "local": false,
@@ -8095,6 +8101,50 @@ window.__ModuleLoader__.load({
8095
8101
  "anthropic-messages": "/messages"
8096
8102
  });
8097
8103
  typeof process === "undefined" || process.platform;
8104
+ //#endregion
8105
+ //#region src/group-routing.ts
8106
+ function identityOrder(seats) {
8107
+ return seats.map((_, i) => i);
8108
+ }
8109
+ function smartOrder(seats) {
8110
+ const idx = seats.map((_, i) => i);
8111
+ const tier = (s) => {
8112
+ if (s.resting === true || s.spent === true || (s.used ?? 0) >= 1) return 2;
8113
+ if ((s.used ?? 0) >= .9) return 1;
8114
+ return 0;
8115
+ };
8116
+ return idx.sort((a, b) => {
8117
+ const ta = tier(seats[a]), tb = tier(seats[b]);
8118
+ if (ta !== tb) return ta - tb;
8119
+ const ra = seats[a].renewsInMs ?? Number.MAX_SAFE_INTEGER;
8120
+ const rb = seats[b].renewsInMs ?? Number.MAX_SAFE_INTEGER;
8121
+ if (ra !== rb) return ra - rb;
8122
+ return (seats[a].used ?? 0) - (seats[b].used ?? 0);
8123
+ });
8124
+ }
8125
+ function cheapestOrder(seats) {
8126
+ return seats.map((_, i) => i).sort((a, b) => {
8127
+ const ca = seats[a].cost ?? Number.MAX_SAFE_INTEGER;
8128
+ const cb = seats[b].cost ?? Number.MAX_SAFE_INTEGER;
8129
+ if (ca !== cb) return ca - cb;
8130
+ return (seats[a].window ?? Number.MAX_SAFE_INTEGER) - (seats[b].window ?? Number.MAX_SAFE_INTEGER);
8131
+ });
8132
+ }
8133
+ function freeFirstOrder(seats) {
8134
+ return seats.map((_, i) => i).sort((a, b) => {
8135
+ const fa = seats[a].free === true && (seats[a].used ?? 0) < 1 ? 0 : 1;
8136
+ const fb = seats[b].free === true && (seats[b].used ?? 0) < 1 ? 0 : 1;
8137
+ if (fa !== fb) return fa - fb;
8138
+ return smartOrder([seats[a], seats[b]])[0] === 0 ? -1 : 1;
8139
+ });
8140
+ }
8141
+ Object.freeze({
8142
+ smart: { order: smartOrder },
8143
+ ordered: { order: identityOrder },
8144
+ "round-robin": { order: identityOrder },
8145
+ cheapest: { order: cheapestOrder },
8146
+ "free-first": { order: freeFirstOrder }
8147
+ });
8098
8148
  Object.freeze({
8099
8149
  "openai-chat": "chat",
8100
8150
  "openai-responses": "responses",
@@ -9292,6 +9342,34 @@ window.__ModuleLoader__.load({
9292
9342
  })
9293
9343
  });
9294
9344
  }
9345
+ const BADGE_FREE_LABEL = "限时免费";
9346
+ const COLOR_TAIL = /^[0-9A-Fa-f]{3,8}$/;
9347
+ function parseBadgeTags(tags) {
9348
+ const out = [];
9349
+ for (const tag of tags ?? []) {
9350
+ if (!tag.startsWith("badge:")) continue;
9351
+ const rest = tag.slice(6);
9352
+ const hash = rest.lastIndexOf("#");
9353
+ const tail = hash === -1 ? "" : rest.slice(hash + 1);
9354
+ const isColor = hash !== -1 && COLOR_TAIL.test(tail);
9355
+ const cut = (hash === -1 ? rest : rest.slice(0, hash)).trim();
9356
+ const label = isColor ? cut.replace(/:$/, "").trim() : cut;
9357
+ if (label === "") continue;
9358
+ out.push(isColor ? {
9359
+ label,
9360
+ color: tail
9361
+ } : { label });
9362
+ }
9363
+ return out;
9364
+ }
9365
+ function hasFreeBadge(tags) {
9366
+ return parseBadgeTags(tags).some((badge) => badge.label === BADGE_FREE_LABEL);
9367
+ }
9368
+ function freeBadgeKind(model) {
9369
+ if (hasFreeBadge(model.tags)) return "badge";
9370
+ if (model.multiplier === 0 || (model.tags ?? []).includes("free")) return "generic";
9371
+ if (typeof model.id === "string" && /-free$/u.test(model.id)) return "generic";
9372
+ }
9295
9373
  //#endregion
9296
9374
  //#region src/client/channel-rpc.ts
9297
9375
  let packRpcBridge;
@@ -9425,13 +9503,17 @@ window.__ModuleLoader__.load({
9425
9503
  const provider = entry.provider;
9426
9504
  const expiresAt = entry.expiresAt;
9427
9505
  const refreshable = entry.refreshable;
9506
+ const createdAt = entry.createdAt;
9428
9507
  rows.push({
9429
9508
  id,
9430
9509
  provider: typeof provider === "string" ? provider : "",
9431
9510
  ...entry.nickname !== void 0 ? { nickname: String(entry.nickname) } : {},
9511
+ ...typeof entry.label === "string" && entry.label !== "" ? { label: entry.label } : {},
9432
9512
  ...entry.enabled !== void 0 ? { enabled: entry.enabled === true } : {},
9433
9513
  ...typeof expiresAt === "number" && Number.isFinite(expiresAt) && expiresAt > 0 ? { expiresAt } : {},
9434
- ...refreshable === true ? { refreshable: true } : {}
9514
+ ...typeof createdAt === "number" && Number.isFinite(createdAt) && createdAt > 0 ? { createdAt } : {},
9515
+ ...refreshable === true ? { refreshable: true } : {},
9516
+ ...entry.credits !== void 0 && entry.credits !== null && typeof entry.credits === "object" ? { credits: entry.credits } : {}
9435
9517
  });
9436
9518
  }
9437
9519
  return rows;
@@ -9449,13 +9531,21 @@ window.__ModuleLoader__.load({
9449
9531
  const description = value.description;
9450
9532
  const disabled = value.disabled;
9451
9533
  const isFree = value.isFree;
9534
+ const multiplier = value.multiplier;
9535
+ const tags = value.tags;
9452
9536
  const dead = value.dead;
9453
9537
  const reasoning = value.reasoning;
9454
9538
  return {
9455
9539
  id,
9456
9540
  name: typeof name === "string" && name !== "" ? name : id,
9457
9541
  ...disabled === true ? { disabled: true } : {},
9458
- ...isFree === true ? { isFree: true } : {},
9542
+ ...isFree === true || freeBadgeKind({
9543
+ id,
9544
+ multiplier,
9545
+ tags
9546
+ }) !== void 0 ? { isFree: true } : {},
9547
+ ...typeof multiplier === "number" && Number.isFinite(multiplier) ? { multiplier } : {},
9548
+ ...Array.isArray(tags) ? { tags: tags.filter((tag) => typeof tag === "string") } : {},
9459
9549
  ...dead === true ? { dead: true } : {},
9460
9550
  ...reasoning === true ? { reasoning: true } : {},
9461
9551
  ...typeof contextWindow === "number" && Number.isFinite(contextWindow) && contextWindow > 0 ? { contextWindow } : {},
@@ -9475,6 +9565,7 @@ window.__ModuleLoader__.load({
9475
9565
  }
9476
9566
  function isFreeChannelModel(model) {
9477
9567
  if (model.isFree === true) return true;
9568
+ if (freeBadgeKind(model) !== void 0) return true;
9478
9569
  const tag = /[·・]\s*(x\s*[\d.]+(?:\s*→\s*x?[\d.]+)?|免费|限时免费)\s*$/iu.exec(model.name ?? "")?.[1];
9479
9570
  if (tag === void 0) return false;
9480
9571
  if (/免费/u.test(tag)) return true;
@@ -9658,6 +9749,182 @@ window.__ModuleLoader__.load({
9658
9749
  };
9659
9750
  }
9660
9751
  //#endregion
9752
+ //#region src/client/channel-order.ts
9753
+ const ADDED_AT_KEY = "dsh-xdpool.channel-added-at.v1";
9754
+ function readChannelAddedAt() {
9755
+ try {
9756
+ const raw = globalThis.localStorage?.getItem(ADDED_AT_KEY);
9757
+ if (raw === null || raw === void 0) return {};
9758
+ const parsed = JSON.parse(raw);
9759
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) return {};
9760
+ const out = {};
9761
+ for (const [channelId, at] of Object.entries(parsed)) {
9762
+ if (channelId === "" || typeof at !== "number" || !Number.isFinite(at) || at <= 0) continue;
9763
+ out[channelId] = at;
9764
+ }
9765
+ return out;
9766
+ } catch {
9767
+ return {};
9768
+ }
9769
+ }
9770
+ function rememberChannelAddedAt(previous, channelId, at) {
9771
+ const next = {
9772
+ ...previous,
9773
+ [channelId]: at
9774
+ };
9775
+ try {
9776
+ globalThis.localStorage?.setItem(ADDED_AT_KEY, JSON.stringify(next));
9777
+ } catch {}
9778
+ return next;
9779
+ }
9780
+ function channelRecency(accounts, sessionStamps) {
9781
+ const newest = new Map();
9782
+ const offer = (channelId, at) => {
9783
+ if (at === void 0 || !Number.isFinite(at) || at <= 0) return;
9784
+ const current = newest.get(channelId);
9785
+ if (current === void 0 || at > current) newest.set(channelId, at);
9786
+ };
9787
+ for (const account of accounts) {
9788
+ if (account.provider === "") continue;
9789
+ offer(account.provider, account.createdAt);
9790
+ }
9791
+ for (const [channelId, at] of Object.entries(sessionStamps)) offer(channelId, at ?? void 0);
9792
+ return newest;
9793
+ }
9794
+ function orderChannelsByRecency(channels, recency) {
9795
+ return channels.map((channel, index) => ({
9796
+ channel,
9797
+ index,
9798
+ at: recency.get(channel.id) ?? 0
9799
+ })).sort((a, b) => b.at - a.at || a.index - b.index).map((entry) => entry.channel);
9800
+ }
9801
+ //#endregion
9802
+ //#region src/client/lane-helpers.ts
9803
+ function laneRegionOf(provider) {
9804
+ if (provider === "buddy") return "cn";
9805
+ if (provider === "workbuddy") return "global";
9806
+ }
9807
+ const POOL_LANE_NONE_ID = "__none__";
9808
+ const laneSelectionCache = new Map();
9809
+ async function readLaneStatus(region) {
9810
+ try {
9811
+ const response = await fetch(`${POOL_STATUS_PATH}?region=${region}`, {
9812
+ headers: { accept: "application/json" },
9813
+ credentials: "same-origin"
9814
+ });
9815
+ if (!response.ok) return {
9816
+ ok: false,
9817
+ error: { message: `HTTP ${String(response.status)}` }
9818
+ };
9819
+ const status = await response.json().catch(() => void 0);
9820
+ if (status !== void 0 && status.selection !== void 0) laneSelectionCache.set(region, status.selection);
9821
+ return {
9822
+ ok: true,
9823
+ value: status
9824
+ };
9825
+ } catch (cause) {
9826
+ return {
9827
+ ok: false,
9828
+ error: { message: cause instanceof Error ? cause.message : String(cause) }
9829
+ };
9830
+ }
9831
+ }
9832
+ async function readLaneModels(region) {
9833
+ const status = await readLaneStatus(region);
9834
+ if (!status.ok) return {
9835
+ ok: false,
9836
+ error: status.error
9837
+ };
9838
+ const rows = status.value?.models ?? [];
9839
+ const models = [];
9840
+ for (const row of rows) {
9841
+ if (typeof row.id !== "string" || row.id === "") continue;
9842
+ const free = freeBadgeKind(row);
9843
+ models.push({
9844
+ id: row.id,
9845
+ name: typeof row.name === "string" && row.name !== "" ? row.name : row.id,
9846
+ ...typeof row.description === "string" && row.description !== "" ? { description: row.description } : {},
9847
+ ...free === void 0 ? {} : { isFree: true },
9848
+ ...row.enabled === false ? { disabled: true } : {},
9849
+ ...typeof row.multiplier === "number" ? { multiplier: row.multiplier } : {},
9850
+ ...typeof row.contextWindow === "number" && row.contextWindow > 0 ? { contextWindow: row.contextWindow } : {},
9851
+ ...row.nativeContextWindow > 0 ? { nativeContextWindow: row.nativeContextWindow } : {},
9852
+ ...row.maxOutputTokens > 0 ? { maxTokens: row.maxOutputTokens } : {},
9853
+ ...row.supportsImages ? { inputModalities: ["text", "image"] } : {}
9854
+ });
9855
+ }
9856
+ return {
9857
+ ok: true,
9858
+ value: { models }
9859
+ };
9860
+ }
9861
+ async function readLaneAccounts(region) {
9862
+ const status = await readLaneStatus(region);
9863
+ if (!status.ok) return {
9864
+ ok: false,
9865
+ error: status.error
9866
+ };
9867
+ const rows = status.value?.accounts ?? [];
9868
+ const provider = region === "cn" ? "buddy" : "workbuddy";
9869
+ const accounts = rows.map((row) => ({
9870
+ id: row.id,
9871
+ provider,
9872
+ ...typeof row.nickname === "string" && row.nickname !== "" ? { nickname: row.nickname } : {},
9873
+ ...typeof row.label === "string" && row.label !== "" ? { label: row.label } : {},
9874
+ ...typeof row.expiresAt === "string" ? { expiresAt: Date.parse(row.expiresAt) } : {},
9875
+ enabled: !row.disabled,
9876
+ ...row.credits !== void 0 ? { credits: row.credits } : {}
9877
+ }));
9878
+ const checkin = [];
9879
+ for (const row of rows) {
9880
+ const today = row.checkin;
9881
+ if (today === void 0) continue;
9882
+ checkin.push({
9883
+ accountId: row.id,
9884
+ ...typeof row.nickname === "string" && row.nickname !== "" ? { nickname: row.nickname } : {},
9885
+ ...today.todayCheckedIn ? { todayCheckedIn: true } : {},
9886
+ ...typeof today.todayCredit === "number" ? { todayCredit: today.todayCredit } : {}
9887
+ });
9888
+ }
9889
+ return {
9890
+ ok: true,
9891
+ value: {
9892
+ accounts,
9893
+ checkin
9894
+ }
9895
+ };
9896
+ }
9897
+ async function laneSelectionOf(region) {
9898
+ if (!laneSelectionCache.has(region)) await readLaneModels(region);
9899
+ return laneSelectionCache.get(region);
9900
+ }
9901
+ async function saveLaneModels(region, ids) {
9902
+ const held = await laneSelectionOf(region);
9903
+ const response = await fetch(POOL_MODELS_SAVE_PATH, {
9904
+ method: "POST",
9905
+ headers: {
9906
+ "content-type": "application/json",
9907
+ accept: "application/json"
9908
+ },
9909
+ credentials: "same-origin",
9910
+ body: JSON.stringify({
9911
+ region,
9912
+ enabledModelIds: ids,
9913
+ ...Array.isArray(held?.imageModelIds) ? { imageModelIds: held.imageModelIds } : {},
9914
+ ...held?.contextBudgets !== void 0 ? { contextBudgets: held.contextBudgets } : {}
9915
+ })
9916
+ });
9917
+ const body = await response.json().catch(() => void 0);
9918
+ if (!response.ok) return {
9919
+ ok: false,
9920
+ error: { message: typeof body?.error === "string" ? body.error : `HTTP ${String(response.status)}` }
9921
+ };
9922
+ return {
9923
+ ok: true,
9924
+ value: body
9925
+ };
9926
+ }
9927
+ //#endregion
9661
9928
  //#region src/client/login-routes.ts
9662
9929
  const WINDOW_LOGIN_ROUTES = Object.freeze({
9663
9930
  "doubao": POOL_DOUBAO_SESSION_PATH,
@@ -9689,6 +9956,69 @@ window.__ModuleLoader__.load({
9689
9956
  return loginKindOf(channelId) !== "pack";
9690
9957
  }
9691
9958
  //#endregion
9959
+ //#region src/manual-callback.ts
9960
+ const LOOPBACK_HOSTS = new Set([
9961
+ "127.0.0.1",
9962
+ "localhost",
9963
+ "::1",
9964
+ "[::1]"
9965
+ ]);
9966
+ function checkManualCallback(raw, expected = {}) {
9967
+ const text = raw.trim();
9968
+ if (text === "") return {
9969
+ ok: false,
9970
+ reason: "empty"
9971
+ };
9972
+ let url;
9973
+ try {
9974
+ url = new URL(text);
9975
+ } catch {
9976
+ return {
9977
+ ok: false,
9978
+ reason: "not-a-url"
9979
+ };
9980
+ }
9981
+ const host = url.hostname.replace(/^\[|\]$/gu, "");
9982
+ if (!LOOPBACK_HOSTS.has(host) && host !== "127.0.0.1") return {
9983
+ ok: false,
9984
+ reason: "not-loopback"
9985
+ };
9986
+ if (expected.path !== void 0 && url.pathname !== expected.path) return {
9987
+ ok: false,
9988
+ reason: "wrong-path"
9989
+ };
9990
+ if (expected.port !== void 0 && url.port !== expected.port && url.port !== "") return {
9991
+ ok: false,
9992
+ reason: "wrong-port"
9993
+ };
9994
+ if (expected.state !== void 0 && url.searchParams.get("state") !== expected.state) return {
9995
+ ok: false,
9996
+ reason: "wrong-state"
9997
+ };
9998
+ const code = url.searchParams.get("code");
9999
+ if (code === null || code === "") return {
10000
+ ok: false,
10001
+ reason: "no-code"
10002
+ };
10003
+ return {
10004
+ ok: true,
10005
+ code
10006
+ };
10007
+ }
10008
+ function callbackReasonText(reason) {
10009
+ switch (reason) {
10010
+ case "empty": return "先把浏览器地址栏里那条完整链接复制过来。";
10011
+ case "not-a-url": return "这不像一条完整的地址。请复制地址栏里以 http:// 或 https:// 开头的整条链接。";
10012
+ case "not-loopback": return "这条地址的主机不是本机(127.0.0.1 / localhost)。请复制浏览器实际跳转到的那条本机地址。";
10013
+ case "wrong-path": return "这条地址不是本次登录的回调地址。请回到跳转失败的那一页重新复制。";
10014
+ case "wrong-port": return "这条地址的端口和本次登录不一致。请重新发起登录,再粘贴新的地址。";
10015
+ case "wrong-state": return "这条地址属于另一次登录。请用本次登录页面跳出来的那条地址。";
10016
+ case "no-code": return "这段地址里找不到授权码。如果只复制到了 ?code=… 的查询串,请把前面的地址一起带上。";
10017
+ case "expired":
10018
+ case "already-claimed": return "这份回调属于上一轮登录(已成功或已超时),本轮没有使用它。请重新点击「新建账号」发起登录。";
10019
+ }
10020
+ }
10021
+ //#endregion
9692
10022
  //#region src/doubao-models.ts
9693
10023
  const DOUBAO_MODELS = [
9694
10024
  {
@@ -9890,10 +10220,11 @@ window.__ModuleLoader__.load({
9890
10220
  try {
9891
10221
  const body = await (await fetch(POOL_DOUBAO_SESSION_PATH, { credentials: "same-origin" })).json().catch(() => void 0);
9892
10222
  if (body?.signedIn !== true) return void 0;
10223
+ const first = Array.isArray(body.accounts) ? body.accounts.find((a) => a.active !== false) ?? body.accounts[0] : void 0;
9893
10224
  return {
9894
10225
  id: "doubao:session",
9895
10226
  provider: "doubao",
9896
- nickname: typeof body.name === "string" && body.name !== "" ? body.name : "豆包账号",
10227
+ nickname: typeof first?.name === "string" && first.name !== "" ? first.name : "豆包账号",
9897
10228
  enabled: true
9898
10229
  };
9899
10230
  } catch {
@@ -9923,6 +10254,7 @@ window.__ModuleLoader__.load({
9923
10254
  if (windows.length === 0) return [{
9924
10255
  accountId: "doubao:session",
9925
10256
  nickname: "豆包账号",
10257
+ balance: { total: 0 },
9926
10258
  ...typeof body.error === "string" && body.error !== "" ? { error: body.error } : {}
9927
10259
  }];
9928
10260
  const packages = windows.map((window) => {
@@ -9943,7 +10275,7 @@ window.__ModuleLoader__.load({
9943
10275
  return [{
9944
10276
  accountId: "doubao:session",
9945
10277
  nickname: "豆包账号",
9946
- balance: pointsLeft > 0 ? pointsLeft : Math.round(lowestPercent),
10278
+ balance: { total: pointsLeft > 0 ? pointsLeft : Math.round(lowestPercent) },
9947
10279
  extra: {
9948
10280
  unit: pointsLeft > 0 ? "点" : "%",
9949
10281
  windows: windows.length
@@ -10185,8 +10517,9 @@ window.__ModuleLoader__.load({
10185
10517
  if (channel.credits?.quota === true) return t?.("channelpool.creditsQuota") ?? "quota";
10186
10518
  return t?.("channelpool.creditsUnit") ?? "credits";
10187
10519
  }
10188
- function accountLabel(account) {
10520
+ function accountLabel$1(account) {
10189
10521
  if (typeof account.nickname === "string" && account.nickname !== "") return account.nickname;
10522
+ if (typeof account.label === "string" && account.label !== "") return account.label;
10190
10523
  if (typeof account.id === "string" && account.id !== "") return account.id;
10191
10524
  if (typeof account.id === "number") return String(account.id);
10192
10525
  return "(未命名账号)";
@@ -10204,7 +10537,7 @@ window.__ModuleLoader__.load({
10204
10537
  return false;
10205
10538
  }
10206
10539
  function accountDisplay(account, channelName, index) {
10207
- const raw = accountLabel(account);
10540
+ const raw = accountLabel$1(account);
10208
10541
  const id = typeof account.id === "string" ? account.id : raw;
10209
10542
  const full = raw === id ? raw : `${raw}(${id})`;
10210
10543
  if (sameAsChannel(raw, channelName)) {
@@ -10247,6 +10580,23 @@ window.__ModuleLoader__.load({
10247
10580
  function amount(value) {
10248
10581
  return Number.isInteger(value) ? String(value) : value.toFixed(2);
10249
10582
  }
10583
+ function packageIsPercent(entry) {
10584
+ if (entry === void 0) return false;
10585
+ return entry.unit === "%" || entry.unit === "percent" || entry.unit === "quota";
10586
+ }
10587
+ function packagePercent(entry) {
10588
+ if (entry === void 0) return void 0;
10589
+ if (packageIsPercent(entry)) return typeof entry.remaining === "number" ? Math.max(0, Math.min(100, Math.round(entry.remaining))) : void 0;
10590
+ if (typeof entry.total === "number" && entry.total > 0 && typeof entry.remaining === "number") return Math.max(0, Math.min(100, Math.round(entry.remaining / entry.total * 100)));
10591
+ }
10592
+ function packageDetailText(entry) {
10593
+ const percent = packageIsPercent(entry);
10594
+ if (typeof entry.total === "number" && typeof entry.remaining === "number") return `${amount(percent ? Math.round(entry.total * entry.remaining / 100) : entry.remaining)} / ${amount(entry.total)}`;
10595
+ if (typeof entry.total === "number" && typeof entry.amount === "number") return `${amount(entry.amount)} / ${amount(entry.total)}`;
10596
+ if (typeof entry.remaining === "number") return percent ? `剩余 ${String(Math.round(entry.remaining))}%` : amount(entry.remaining);
10597
+ if (typeof entry.amount === "number") return amount(entry.amount);
10598
+ return "—";
10599
+ }
10250
10600
  async function cachedProviderStatus(providers) {
10251
10601
  const key = [...providers].sort().join("\0");
10252
10602
  const hit = providerStatusCache;
@@ -10314,7 +10664,7 @@ window.__ModuleLoader__.load({
10314
10664
  return "签到失败";
10315
10665
  }
10316
10666
  }
10317
- function ChannelPoolSection({ t, active, onAddAccount, autoClaim, autoClaimBusy, onAutoClaim, autoClaimRunning, onAutoClaimRun, banner }) {
10667
+ function ChannelPoolSection({ t, active, onAddAccount, autoClaim, autoClaimBusy, onAutoClaim, autoClaimRunning, onAutoClaimRun, banner, regionCards }) {
10318
10668
  const [ownActive, setOwnActive] = (0, react.useState)("");
10319
10669
  const [loginState, setLoginState] = (0, react.useState)(void 0);
10320
10670
  const loginAbort = (0, react.useRef)(void 0);
@@ -10433,10 +10783,10 @@ window.__ModuleLoader__.load({
10433
10783
  const channels = channelsRaw.filter((channel) => !REGION_OWNED_CHANNELS.has(channel.id));
10434
10784
  const statusAnswer = channels.some((channel) => !rosterIds.includes(channel.id)) ? await cachedProviderStatus(channels.map((channel) => channel.id)) : firstStatus;
10435
10785
  const statuses = providerStatusesFrom(statusAnswer);
10436
- const scanProviders = channels.map((channel) => channel.id).filter((id) => (statuses.get(id)?.accountsTotal ?? 0) > 0 || id === "doubao" && doubaoAccount !== void 0 || id === "marvis" && (marvisSession?.accounts.length ?? 0) > 0);
10786
+ const scanProviders = channels.map((channel) => channel.id).filter((id) => (statuses.get(id)?.accountsTotal ?? 0) > 0 || id === "doubao" && doubaoAccount !== void 0 || id === "marvis" && (marvisSession?.accounts.length ?? 0) > 0 || laneRegionOf(id) !== void 0);
10437
10787
  const perProvider = await Promise.all(scanProviders.map(async (provider) => {
10438
10788
  const wantBalances = channels.find((channel) => channel.id === provider)?.credits !== void 0;
10439
- const accountsPromise = provider === "doubao" ? Promise.resolve({
10789
+ const accountsPromise = laneRegionOf(provider) !== void 0 ? readLaneAccounts(laneRegionOf(provider)) : provider === "doubao" ? Promise.resolve({
10440
10790
  ok: true,
10441
10791
  value: { accounts: doubaoAccount === void 0 ? [] : [doubaoAccount] }
10442
10792
  }) : provider === "marvis" ? Promise.resolve({
@@ -10449,16 +10799,17 @@ window.__ModuleLoader__.load({
10449
10799
  })) : provider === "marvis" ? Promise.resolve({
10450
10800
  ok: true,
10451
10801
  value: { models: marvisSession?.models ?? [] }
10452
- }) : callPack("model.list", { provider });
10802
+ }) : laneRegionOf(provider) === void 0 ? callPack("model.list", { provider }) : readLaneModels(laneRegionOf(provider));
10453
10803
  const [accounts, models] = await Promise.all([accountsPromise.catch(() => refused("account.list failed")), modelsPromise.catch(() => refused("model.list failed"))]);
10454
- const modelRows = modelsFrom(models.value);
10804
+ const modelRows = modelsFrom(models.ok === true ? models.value : void 0);
10455
10805
  const modelEmptyBecauseRefused = modelRows.length === 0 && models.ok !== true;
10806
+ const laneCheckin = laneRegionOf(provider) !== void 0 && accounts.ok === true ? accounts.value.checkin ?? [] : [];
10456
10807
  return [provider, {
10457
10808
  accounts: dedupeAccounts(accountsFrom(accounts)),
10458
10809
  models: sortChannelModels(modelRows),
10459
10810
  facts: new Map(),
10460
10811
  balances: [],
10461
- statuses: [],
10812
+ statuses: laneCheckin,
10462
10813
  balancePending: wantBalances,
10463
10814
  balanceError: void 0,
10464
10815
  modelError: modelEmptyBecauseRefused ? models.error?.message ?? "model.list refused" : void 0
@@ -10634,7 +10985,12 @@ window.__ModuleLoader__.load({
10634
10985
  setEnabled((previous) => new Map(previous).set(provider, next));
10635
10986
  markBusy(provider, true);
10636
10987
  try {
10637
- if (provider === "doubao") {
10988
+ const laneRegion = laneRegionOf(provider);
10989
+ if (laneRegion !== void 0) {
10990
+ const ids = entry.models.map((model) => model.id).filter((id) => next.has(id));
10991
+ const saved = await saveLaneModels(laneRegion, ids.length === 0 ? [POOL_LANE_NONE_ID] : ids);
10992
+ if (!saved.ok) throw new Error(saved.error?.message ?? "model selection refused");
10993
+ } else if (provider === "doubao") {
10638
10994
  await saveDoubaoSkipped(modelId, !on);
10639
10995
  saveDoubaoHideAll(false);
10640
10996
  await mirrorDoubaoDisabled();
@@ -10690,7 +11046,11 @@ window.__ModuleLoader__.load({
10690
11046
  setEnabled((previous) => new Map(previous).set(provider, new Set(on ? entry.models.map((model) => model.id) : [])));
10691
11047
  markBusy(provider, true);
10692
11048
  try {
10693
- if (provider === "doubao") {
11049
+ const laneRegion = laneRegionOf(provider);
11050
+ if (laneRegion !== void 0) {
11051
+ const saved = await saveLaneModels(laneRegion, on ? entry.models.map((model) => model.id) : [POOL_LANE_NONE_ID]);
11052
+ if (!saved.ok) throw new Error(saved.error?.message ?? "model selection refused");
11053
+ } else if (provider === "doubao") {
10694
11054
  const skipped = on ? [] : entry.models.map((model) => model.id);
10695
11055
  globalThis.localStorage?.setItem(DOUBAO_SKIP_KEY, JSON.stringify(skipped));
10696
11056
  saveDoubaoHideAll(!on);
@@ -11083,16 +11443,18 @@ window.__ModuleLoader__.load({
11083
11443
  }
11084
11444
  };
11085
11445
  if (entries.length === 0 && error === void 0) {
11086
- if (!loading) return (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, {});
11087
- return (0, react_jsx_runtime.jsx)("section", {
11088
- className: "dsm-xdpool-cpool",
11089
- "aria-label": t?.("channelpool.title") ?? "Channels",
11090
- children: (0, react_jsx_runtime.jsx)("p", {
11091
- className: "note",
11092
- role: "status",
11093
- children: t?.("channelpool.loading") ?? "Reading scan channels…"
11094
- })
11095
- });
11446
+ if (!(regionCards !== void 0 && !loading)) {
11447
+ if (!loading) return (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, {});
11448
+ return (0, react_jsx_runtime.jsx)("section", {
11449
+ className: "dsm-xdpool-cpool",
11450
+ "aria-label": t?.("channelpool.title") ?? "Channels",
11451
+ children: (0, react_jsx_runtime.jsx)("p", {
11452
+ className: "note",
11453
+ role: "status",
11454
+ children: t?.("channelpool.loading") ?? "Reading scan channels…"
11455
+ })
11456
+ });
11457
+ }
11096
11458
  }
11097
11459
  const chosenEntry = entries.find((entry) => entry.channel.id === chosen) ?? entries[0];
11098
11460
  const totalAccounts = entries.reduce((sum, entry) => sum + entry.accounts.length, 0);
@@ -11224,19 +11586,23 @@ window.__ModuleLoader__.load({
11224
11586
  children: (0, react_jsx_runtime.jsxs)("div", {
11225
11587
  className: "mbody",
11226
11588
  style: { paddingTop: "var(--s5)" },
11227
- children: [banner, error === void 0 ? null : (0, react_jsx_runtime.jsxs)("p", {
11228
- className: "hint",
11229
- children: [t?.("channelpool.loadError", { message: error }) ?? `Could not load channels: ${error}`, (0, react_jsx_runtime.jsx)("button", {
11230
- type: "button",
11231
- className: "tiny",
11232
- style: { marginLeft: "auto" },
11233
- onClick: () => {
11234
- setEnabled(new Map());
11235
- load();
11236
- },
11237
- children: t?.("channelpool.retry") ?? "重试"
11238
- })]
11239
- })]
11589
+ children: [
11590
+ banner,
11591
+ regionCards,
11592
+ error === void 0 ? null : (0, react_jsx_runtime.jsxs)("p", {
11593
+ className: "hint",
11594
+ children: [t?.("channelpool.loadError", { message: error }) ?? `Could not load channels: ${error}`, (0, react_jsx_runtime.jsx)("button", {
11595
+ type: "button",
11596
+ className: "tiny",
11597
+ style: { marginLeft: "auto" },
11598
+ onClick: () => {
11599
+ setEnabled(new Map());
11600
+ load();
11601
+ },
11602
+ children: t?.("channelpool.retry") ?? "重试"
11603
+ })]
11604
+ })
11605
+ ]
11240
11606
  })
11241
11607
  })] });
11242
11608
  const { channel, accounts, models, facts, balances, statuses, status } = chosenEntry;
@@ -11244,7 +11610,7 @@ window.__ModuleLoader__.load({
11244
11610
  const isBusy = busy.has(channel.id);
11245
11611
  const unit = creditUnitLabel(channel, t);
11246
11612
  const chosenBalanceTotal = channel.credits === void 0 ? void 0 : balancesTotal(balances);
11247
- const chosenCredit = chosenEntry.balancePending && chosenBalanceTotal === void 0 ? t?.("channelpool.balanceLoading") ?? "…" : chosenBalanceTotal === void 0 ? "—" : amount(chosenBalanceTotal);
11613
+ const chosenCredit = chosenEntry.balancePending && chosenBalanceTotal === void 0 ? t?.("channelpool.balanceLoading") ?? "…" : chosenBalanceTotal === void 0 ? "0" : amount(chosenBalanceTotal);
11248
11614
  const modelsEnabled = models.filter((model) => enabledIds.has(model.id)).length;
11249
11615
  const statusOf = (accountId) => statuses.find((row) => row.accountId === accountId);
11250
11616
  const balanceOf = (accountId) => balances.find((row) => row.accountId === accountId);
@@ -11343,6 +11709,7 @@ window.__ModuleLoader__.load({
11343
11709
  className: "mbody",
11344
11710
  children: [
11345
11711
  banner,
11712
+ regionCards,
11346
11713
  loginState !== void 0 && loginState.channelId === channel.id && (loginState.phase === "paste" ? (0, react_jsx_runtime.jsxs)("div", {
11347
11714
  className: "banner",
11348
11715
  children: [
@@ -11837,12 +12204,13 @@ window.__ModuleLoader__.load({
11837
12204
  children: accounts.map((account, index) => {
11838
12205
  const shown = accountDisplay(account, channel.name, index);
11839
12206
  const balance = balanceOf(account.id);
11840
- const value = balance === void 0 ? void 0 : balanceAmount(balance.balance);
12207
+ const value = balance === void 0 ? account.credits?.total : balanceAmount(balance.balance);
11841
12208
  const checkin = statusOf(account.id);
11842
12209
  const buckets = balance === void 0 ? [] : balancePackages(balance.balance);
12210
+ const visibleBuckets = buckets.filter((b) => typeof b.remaining !== "number" || b.remaining > 0);
11843
12211
  const disabled = account.enabled === false;
11844
12212
  const soon = expiryText(account.expiresAt, t);
11845
- const pct = buckets[0]?.remaining;
12213
+ const pct = packagePercent(visibleBuckets[0]);
11846
12214
  return (0, react_jsx_runtime.jsxs)("article", {
11847
12215
  className: "acct",
11848
12216
  "data-off": disabled,
@@ -11911,7 +12279,7 @@ window.__ModuleLoader__.load({
11911
12279
  children: unit
11912
12280
  })] }) : (0, react_jsx_runtime.jsx)("span", {
11913
12281
  className: "acct-total-v",
11914
- children: chosenEntry.balancePending ? "…" : "—"
12282
+ children: chosenEntry.balancePending ? "…" : "0"
11915
12283
  }), soon === void 0 ? null : (0, react_jsx_runtime.jsx)("span", {
11916
12284
  className: "acct-soon",
11917
12285
  children: soon
@@ -11919,7 +12287,7 @@ window.__ModuleLoader__.load({
11919
12287
  }),
11920
12288
  pct === void 0 ? null : (0, react_jsx_runtime.jsx)("div", {
11921
12289
  className: "acct-bar",
11922
- title: buckets.map((b) => `${b.name} ${String(Math.round(b.remaining ?? 0))}%`).join(" · "),
12290
+ title: buckets.map((b) => `${b.name} ${packageDetailText(b)}`).join(" · "),
11923
12291
  children: (0, react_jsx_runtime.jsx)("span", { style: { width: `${String(Math.max(0, Math.min(100, Math.round(pct))))}%` } })
11924
12292
  }),
11925
12293
  (0, react_jsx_runtime.jsxs)("details", {
@@ -11928,13 +12296,9 @@ window.__ModuleLoader__.load({
11928
12296
  (0, react_jsx_runtime.jsx)("summary", { children: t?.("channelpool.accountDetail") ?? "积分明细" }),
11929
12297
  (0, react_jsx_runtime.jsxs)("dl", {
11930
12298
  className: "facts",
11931
- children: [buckets.map((b, i) => (0, react_jsx_runtime.jsxs)("div", {
12299
+ children: [visibleBuckets.map((b, i) => (0, react_jsx_runtime.jsxs)("div", {
11932
12300
  className: "fact",
11933
- children: [(0, react_jsx_runtime.jsx)("dt", { children: b.name }), (0, react_jsx_runtime.jsx)("dd", { children: typeof b.total === "number" ? (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
11934
- typeof b.remaining === "number" ? amount(Math.round(b.total * b.remaining / 100)) : typeof b.amount === "number" ? amount(b.amount) : "—",
11935
- " / ",
11936
- amount(b.total)
11937
- ] }) : typeof b.remaining === "number" ? `剩余 ${String(Math.round(b.remaining))}%` : "—" })]
12301
+ children: [(0, react_jsx_runtime.jsx)("dt", { children: b.name }), (0, react_jsx_runtime.jsx)("dd", { children: packageDetailText(b) })]
11938
12302
  }, `${b.name}-${String(i)}`)), channel.credits?.status !== true && checkin === void 0 ? null : (0, react_jsx_runtime.jsxs)("div", {
11939
12303
  className: "fact",
11940
12304
  children: [(0, react_jsx_runtime.jsx)("dt", { children: t?.("channelpool.todayClaimed") ?? "今日签到" }), checkin?.todayCheckedIn === true ? (0, react_jsx_runtime.jsxs)("dd", {
@@ -12211,8 +12575,8 @@ window.__ModuleLoader__.load({
12211
12575
  const byKey = new Map();
12212
12576
  const order = [];
12213
12577
  for (const account of accounts) {
12214
- const nickname = (account.nickname ?? "").trim();
12215
- const key = nickname === "" ? `id:${account.id}` : `n:${nickname}`;
12578
+ (account.nickname ?? "").trim();
12579
+ const key = `id:${account.id}`;
12216
12580
  if (!byKey.has(key)) order.push(key);
12217
12581
  byKey.set(key, account);
12218
12582
  }
@@ -12244,6 +12608,7 @@ window.__ModuleLoader__.load({
12244
12608
  const [ui, setUi] = (0, react.useState)({});
12245
12609
  const [query, setQuery] = (0, react.useState)("");
12246
12610
  const [connected, setConnected] = (0, react.useState)([]);
12611
+ const [addedAt, setAddedAt] = (0, react.useState)(() => readChannelAddedAt());
12247
12612
  const [ownCounts, setOwnCounts] = (0, react.useState)({});
12248
12613
  const [active, setActive] = (0, react.useState)(void 0);
12249
12614
  const mounted = (0, react.useRef)(true);
@@ -12307,7 +12672,7 @@ window.__ModuleLoader__.load({
12307
12672
  const loadConnected = (0, react.useCallback)(async () => {
12308
12673
  const roster = await fetchChannels();
12309
12674
  const statuses = providerStatusesFrom(await callPack("provider.status", { providers: roster.map((channel) => channel.id) }));
12310
- const connectedIds = roster.map((channel) => channel.id).filter((id) => (statuses.get(id)?.accountsTotal ?? 0) > 0);
12675
+ const connectedIds = roster.map((channel) => channel.id).filter((id) => laneRegionOf(id) === void 0 && (statuses.get(id)?.accountsTotal ?? 0) > 0);
12311
12676
  const accounts = [...(await Promise.all(connectedIds.map((id) => callPack("account.list", { provider: id })))).flatMap(accountsFrom), ...await loadPoolAccounts()];
12312
12677
  if (mounted.current) setConnected(accounts);
12313
12678
  return accounts;
@@ -12356,6 +12721,7 @@ window.__ModuleLoader__.load({
12356
12721
  timers.current.delete(channelId);
12357
12722
  }, []);
12358
12723
  const finishDone = (0, react.useCallback)((channelId, message) => {
12724
+ setAddedAt((prev) => rememberChannelAddedAt(prev, channelId, Date.now()));
12359
12725
  setUi((prev) => ({
12360
12726
  ...prev,
12361
12727
  [channelId]: {
@@ -12480,7 +12846,14 @@ window.__ModuleLoader__.load({
12480
12846
  fail(channel.id, "没有拿到登录页,可以再试一次。", "pack");
12481
12847
  return;
12482
12848
  }
12483
- window.open(created.loginUrl, "_blank", "noopener");
12849
+ let autoOpen = true;
12850
+ try {
12851
+ const pref = await (await fetch(POOL_LOGIN_PREFERENCES_PATH, { credentials: "same-origin" })).json().catch(() => void 0);
12852
+ if (typeof pref?.autoOpen === "boolean") autoOpen = pref.autoOpen;
12853
+ } catch {
12854
+ autoOpen = true;
12855
+ }
12856
+ if (autoOpen) window.open(created.loginUrl, "_blank", "noopener");
12484
12857
  setUi((prev) => ({
12485
12858
  ...prev,
12486
12859
  [channel.id]: {
@@ -12488,6 +12861,7 @@ window.__ModuleLoader__.load({
12488
12861
  via: "pack",
12489
12862
  accountId: created.accountId,
12490
12863
  loginUrl: created.loginUrl,
12864
+ manualOpen: !autoOpen,
12491
12865
  startCount
12492
12866
  }
12493
12867
  }));
@@ -12599,6 +12973,15 @@ window.__ModuleLoader__.load({
12599
12973
  if (route === void 0) return;
12600
12974
  const value = (ui[channelId]?.paste ?? "").trim();
12601
12975
  if (value === "") return;
12976
+ if (/^https?:\/\//iu.test(value)) {
12977
+ const check = checkManualCallback(value);
12978
+ if (!check.ok) {
12979
+ fail(channelId, callbackReasonText(check.reason ?? "not-a-url"), "paste");
12980
+ return;
12981
+ }
12982
+ fail(channelId, "这是一条登录回调地址。本渠道请粘贴凭据(token / cookie),回调地址会在后续版本支持。", "paste");
12983
+ return;
12984
+ }
12602
12985
  const token = bump(channelId);
12603
12986
  setUi((prev) => ({
12604
12987
  ...prev,
@@ -12638,8 +13021,12 @@ window.__ModuleLoader__.load({
12638
13021
  ]);
12639
13022
  const state = status?.state ?? "pending";
12640
13023
  const channels = (0, react.useMemo)(() => {
12641
- return (Array.isArray(status?.channels) ? status.channels : []).filter((c) => c !== null && typeof c === "object");
12642
- }, [status]);
13024
+ return orderChannelsByRecency((Array.isArray(status?.channels) ? status.channels : []).filter((c) => c !== null && typeof c === "object"), channelRecency(connected, addedAt));
13025
+ }, [
13026
+ status,
13027
+ connected,
13028
+ addedAt
13029
+ ]);
12643
13030
  const connectedCount = (0, react.useMemo)(() => channels.filter((channel) => countFor(channel) > 0).length, [channels, countFor]);
12644
13031
  const filtered = (0, react.useMemo)(() => {
12645
13032
  const needle = query.trim().toLowerCase();
@@ -12783,10 +13170,10 @@ window.__ModuleLoader__.load({
12783
13170
  className: "banner-body",
12784
13171
  children: [(0, react_jsx_runtime.jsx)("span", {
12785
13172
  className: "banner-t",
12786
- children: activeUi.via === "pack" ? "已打开登录页,请在里面完成登录" : "已打开登录窗口,请在里面完成登录"
13173
+ children: activeUi.via === "pack" ? activeUi.manualOpen ? "请手动打开登录页并完成登录" : "已打开登录页,请在里面完成登录" : "已打开登录窗口,请在里面完成登录"
12787
13174
  }), (0, react_jsx_runtime.jsx)("span", {
12788
13175
  className: "banner-d",
12789
- children: activeUi.via === "pack" ? "登录页在新标签页里,10 分钟没完成就会取消。凭据只留在这台机器上。" : "窗口关掉或长时间没完成就会取消。凭据只留在这台机器上。"
13176
+ children: activeUi.via === "pack" ? activeUi.manualOpen ? "按设置没有自动打开登录页,点下面的「打开登录页」。10 分钟没完成就会取消。" : "登录页在新标签页里,10 分钟没完成就会取消。凭据只留在这台机器上。" : "窗口关掉或长时间没完成就会取消。凭据只留在这台机器上。"
12790
13177
  })]
12791
13178
  })]
12792
13179
  }),
@@ -12864,7 +13251,7 @@ window.__ModuleLoader__.load({
12864
13251
  href: activeUi.loginUrl,
12865
13252
  target: "_blank",
12866
13253
  rel: "noopener noreferrer",
12867
- children: "重新打开登录页"
13254
+ children: activeUi.manualOpen ? "打开登录页" : "重新打开登录页"
12868
13255
  }),
12869
13256
  (0, react_jsx_runtime.jsx)("button", {
12870
13257
  type: "button",
@@ -13371,6 +13758,7 @@ window.__ModuleLoader__.load({
13371
13758
  const RULE_COLUMNS = "minmax(0,1fr) minmax(0,1.3fr) 56px 60px 128px";
13372
13759
  function RoutingPage({ t }) {
13373
13760
  const [status, setStatus] = (0, react.useState)(void 0);
13761
+ const [groups, setGroups] = (0, react.useState)([]);
13374
13762
  const [error, setError] = (0, react.useState)(void 0);
13375
13763
  const [flash, setFlash] = (0, react.useState)(void 0);
13376
13764
  const [drafts, setDrafts] = (0, react.useState)([]);
@@ -13413,7 +13801,16 @@ window.__ModuleLoader__.load({
13413
13801
  } catch {
13414
13802
  if (signal?.aborted === true) return;
13415
13803
  if (mounted.current) setError(failed);
13804
+ return;
13416
13805
  }
13806
+ try {
13807
+ const value = await (await fetch(POOL_GROUPS_PATH, {
13808
+ headers: { accept: "application/json" },
13809
+ credentials: "same-origin",
13810
+ ...signal === void 0 ? {} : { signal }
13811
+ })).json().catch(() => void 0);
13812
+ if (mounted.current && signal?.aborted !== true && Array.isArray(value?.groups)) setGroups(value.groups.filter((g) => g !== null && typeof g === "object" && typeof g.id === "string"));
13813
+ } catch {}
13417
13814
  }, []);
13418
13815
  (0, react.useEffect)(() => {
13419
13816
  const controller = new AbortController();
@@ -13596,6 +13993,97 @@ window.__ModuleLoader__.load({
13596
13993
  style: flash.ok ? void 0 : { color: "var(--danger)" },
13597
13994
  children: (0, react_jsx_runtime.jsx)("span", { children: flash.text })
13598
13995
  }),
13996
+ groups.length > 0 ? (0, react_jsx_runtime.jsxs)("section", {
13997
+ className: "sec",
13998
+ children: [
13999
+ (0, react_jsx_runtime.jsxs)("div", {
14000
+ className: "sec-head",
14001
+ children: [(0, react_jsx_runtime.jsx)("span", {
14002
+ className: "sec-title",
14003
+ children: "路由组"
14004
+ }), (0, react_jsx_runtime.jsx)("span", {
14005
+ className: "sec-n num",
14006
+ children: String(groups.length)
14007
+ })]
14008
+ }),
14009
+ (0, react_jsx_runtime.jsxs)("div", {
14010
+ className: "table",
14011
+ children: [(0, react_jsx_runtime.jsxs)("div", {
14012
+ className: "tr tr-head",
14013
+ style: { gridTemplateColumns: "minmax(0,1fr) 96px 88px 72px" },
14014
+ children: [
14015
+ (0, react_jsx_runtime.jsx)("span", {
14016
+ className: "td",
14017
+ children: "组 / 成员"
14018
+ }),
14019
+ (0, react_jsx_runtime.jsx)("span", {
14020
+ className: "td",
14021
+ children: "策略"
14022
+ }),
14023
+ (0, react_jsx_runtime.jsx)("span", {
14024
+ className: "td td-num",
14025
+ children: "状态"
14026
+ }),
14027
+ (0, react_jsx_runtime.jsx)("span", {
14028
+ className: "td td-num",
14029
+ children: "启用"
14030
+ })
14031
+ ]
14032
+ }), groups.map((group) => {
14033
+ const off = new Set(group.off ?? []);
14034
+ const usable = group.members.filter((m) => !off.has(m)).length;
14035
+ const auto = group.auto === true;
14036
+ return (0, react_jsx_runtime.jsxs)("div", {
14037
+ className: "tr",
14038
+ style: { gridTemplateColumns: "minmax(0,1fr) 96px 88px 72px" },
14039
+ children: [
14040
+ (0, react_jsx_runtime.jsxs)("span", {
14041
+ className: "td stack",
14042
+ children: [(0, react_jsx_runtime.jsxs)("span", {
14043
+ className: "mono",
14044
+ children: ["group:", group.id]
14045
+ }), (0, react_jsx_runtime.jsx)("span", {
14046
+ className: "td-dim",
14047
+ style: { textAlign: "left" },
14048
+ children: `${String(usable)} 个可用成员 · ${String(group.members.length)} 总计`
14049
+ })]
14050
+ }),
14051
+ (0, react_jsx_runtime.jsx)("span", {
14052
+ className: "td",
14053
+ children: (0, react_jsx_runtime.jsx)("span", {
14054
+ className: "pill",
14055
+ children: group.strategy === "round-robin" ? "按顺序轮换" : "额度优先"
14056
+ })
14057
+ }),
14058
+ (0, react_jsx_runtime.jsx)("span", {
14059
+ className: "td td-num",
14060
+ children: auto ? (0, react_jsx_runtime.jsx)("span", {
14061
+ className: "pill",
14062
+ "data-tone": "warn",
14063
+ children: "自动发现"
14064
+ }) : "已接管"
14065
+ }),
14066
+ (0, react_jsx_runtime.jsx)("span", {
14067
+ className: "td td-num",
14068
+ children: (0, react_jsx_runtime.jsx)("button", {
14069
+ type: "button",
14070
+ className: "sw",
14071
+ role: "switch",
14072
+ "aria-checked": group.enabled === true,
14073
+ "aria-label": "启用",
14074
+ disabled: auto
14075
+ })
14076
+ })
14077
+ ]
14078
+ }, group.id);
14079
+ })]
14080
+ }),
14081
+ (0, react_jsx_runtime.jsx)("p", {
14082
+ className: "hint",
14083
+ children: "自动发现的组默认关闭。保存任意改动后即归你管理,可正常启用。"
14084
+ })
14085
+ ]
14086
+ }) : null,
13599
14087
  (0, react_jsx_runtime.jsxs)("section", {
13600
14088
  className: "sec",
13601
14089
  children: [(0, react_jsx_runtime.jsxs)("div", {
@@ -15279,7 +15767,16 @@ window.__ModuleLoader__.load({
15279
15767
  })]
15280
15768
  });
15281
15769
  }
15282
- Object.freeze({
15770
+ //#endregion
15771
+ //#region src/client/region-card.tsx
15772
+ const REGION_CARD_ORDER = ["cn", "global"];
15773
+ function visibleRegionCards(accountCounts) {
15774
+ const answered = REGION_CARD_ORDER.filter((region) => accountCounts[region] !== void 0);
15775
+ const bound = answered.filter((region) => (accountCounts[region] ?? 0) > 0);
15776
+ if (bound.length > 0) return bound;
15777
+ return answered.length === REGION_CARD_ORDER.length ? REGION_CARD_ORDER : [];
15778
+ }
15779
+ const REGION_CHANNEL_BY_REGION = Object.freeze({
15283
15780
  cn: "buddy",
15284
15781
  global: "workbuddy"
15285
15782
  });
@@ -16136,7 +16633,7 @@ window.__ModuleLoader__.load({
16136
16633
  function hoursOrDefault(configured, fallback) {
16137
16634
  return configured !== void 0 && configured.length > 0 ? [...configured] : [...fallback];
16138
16635
  }
16139
- const REGION_CARDS = ["cn", "global"];
16636
+ const REGION_CARDS = REGION_CARD_ORDER;
16140
16637
  function PoolCard({ t, settingsScope }) {
16141
16638
  const settingsWritable = settingsScope?.getSnapshot().writable === true;
16142
16639
  const [sidebarRow, setSidebarRowState] = (0, react.useState)(() => readSidebarRow(settingsScope));
@@ -16503,6 +17000,11 @@ window.__ModuleLoader__.load({
16503
17000
  };
16504
17001
  t?.("row.title");
16505
17002
  t?.("row.desc");
17003
+ const showPoolAccounts = selectedChannel === REGION_CHANNEL_BY_REGION.cn || selectedChannel === REGION_CHANNEL_BY_REGION.global;
17004
+ const visibleRegions = visibleRegionCards({
17005
+ ...statusOf("cn") === void 0 ? {} : { cn: statusOf("cn")?.accounts.length ?? 0 },
17006
+ ...statusOf("global") === void 0 ? {} : { global: statusOf("global")?.accounts.length ?? 0 }
17007
+ });
16506
17008
  return (0, react_jsx_runtime.jsx)(PoolShell, {
16507
17009
  t,
16508
17010
  version: POOL_VERSION,
@@ -16538,46 +17040,47 @@ window.__ModuleLoader__.load({
16538
17040
  children: page === "aggregate" ? (0, react_jsx_runtime.jsx)(AggregatePage, { t }) : page === "channels" ? (0, react_jsx_runtime.jsx)(ChannelsPage, { t }) : page === "ledger" ? (0, react_jsx_runtime.jsx)(LedgerPage, {
16539
17041
  t,
16540
17042
  usage
16541
- }) : page === "routing" ? (0, react_jsx_runtime.jsx)(RoutingPage, { t }) : page === "gateway" ? (0, react_jsx_runtime.jsx)(GatewayPage, { t }) : page === "backup" ? (0, react_jsx_runtime.jsx)(BackupPanel, { t }) : (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: (0, react_jsx_runtime.jsxs)("div", {
17043
+ }) : page === "routing" ? (0, react_jsx_runtime.jsx)(RoutingPage, { t }) : page === "gateway" ? (0, react_jsx_runtime.jsx)(GatewayPage, { t }) : page === "backup" ? (0, react_jsx_runtime.jsx)(BackupPanel, { t }) : (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: (0, react_jsx_runtime.jsx)("div", {
16542
17044
  className: "dsm-xdpool-regions dsm-xdpool-region-grid",
16543
17045
  style: { display: "contents" },
16544
- children: [["cn", "global"].map((region) => {
16545
- const here = statusOf(region);
16546
- const rows = here?.accounts ?? [];
16547
- if (rows.length === 0) return null;
16548
- return (0, react_jsx_runtime.jsxs)("section", {
16549
- className: "sec",
16550
- children: [(0, react_jsx_runtime.jsx)("div", {
16551
- className: "sec-head",
16552
- children: (0, react_jsx_runtime.jsxs)("span", {
16553
- className: "sec-title",
16554
- children: [region === "cn" ? t?.("row.tabCn") ?? "CN" : t?.("row.tabGlobal") ?? "Global", ` · ${String(rows.length)}`]
16555
- })
16556
- }), (0, react_jsx_runtime.jsx)("div", {
16557
- className: "xdp-accts",
16558
- children: rows.map((account) => (0, react_jsx_runtime.jsx)(AccountCard, {
16559
- account,
16560
- t,
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);
16566
- },
16567
- onToggle: (disabled) => {
16568
- toggleAccountDisabled(region, account.id, disabled);
16569
- },
16570
- onPrefer: (id) => {
16571
- setPreferredAccount(region, id);
16572
- },
16573
- onIgnore: () => {
16574
- setAccountIgnored(region, account.id, true);
16575
- }
16576
- }, account.id))
16577
- })]
16578
- }, region);
16579
- }), (0, react_jsx_runtime.jsx)(ChannelPoolSection, {
17046
+ children: (0, react_jsx_runtime.jsx)(ChannelPoolSection, {
16580
17047
  t,
17048
+ regionCards: showPoolAccounts ? visibleRegions.map((region) => {
17049
+ const here = statusOf(region);
17050
+ const rows = here?.accounts ?? [];
17051
+ if (rows.length === 0) return null;
17052
+ return (0, react_jsx_runtime.jsxs)("section", {
17053
+ className: "sec",
17054
+ children: [(0, react_jsx_runtime.jsx)("div", {
17055
+ className: "sec-head",
17056
+ children: (0, react_jsx_runtime.jsxs)("span", {
17057
+ className: "sec-title",
17058
+ children: [region === "cn" ? t?.("row.tabCn") ?? "CN" : t?.("row.tabGlobal") ?? "Global", ` · ${String(rows.length)}`]
17059
+ })
17060
+ }), (0, react_jsx_runtime.jsx)("div", {
17061
+ className: "accts",
17062
+ children: rows.map((account) => (0, react_jsx_runtime.jsx)(AccountCard, {
17063
+ account,
17064
+ t,
17065
+ serving: here?.activeAccountId === account.id,
17066
+ ...checkinBusyId === account.id ? { claiming: true } : {},
17067
+ ...accountBusyId === account.id ? { busy: true } : {},
17068
+ onClaim: () => {
17069
+ claimCheckin(region, account.id);
17070
+ },
17071
+ onToggle: (disabled) => {
17072
+ toggleAccountDisabled(region, account.id, disabled);
17073
+ },
17074
+ onPrefer: (id) => {
17075
+ setPreferredAccount(region, id);
17076
+ },
17077
+ onIgnore: () => {
17078
+ setAccountIgnored(region, account.id, true);
17079
+ }
17080
+ }, account.id))
17081
+ })]
17082
+ }, region);
17083
+ }) : void 0,
16581
17084
  active: selectedChannel,
16582
17085
  onAddAccount: () => {
16583
17086
  setPage("channels");
@@ -16598,13 +17101,91 @@ window.__ModuleLoader__.load({
16598
17101
  className: "hint",
16599
17102
  children: t?.("row.error", { message: error }) ?? `Pool status unavailable: ${error}`
16600
17103
  })] })
16601
- })]
17104
+ })
16602
17105
  }) })
16603
17106
  });
16604
17107
  }
16605
17108
  //#endregion
17109
+ //#region src/client/free-recovery.ts
17110
+ const KEY_SEP = "\0";
17111
+ function cooldownKey(accountId, modelId) {
17112
+ return `${accountId}${KEY_SEP}${modelId}`;
17113
+ }
17114
+ function isFreeModelId(modelId) {
17115
+ const bare = modelId.replace(/\([^()]+\)\s*$/u, "").trim();
17116
+ if (bare.startsWith("free:")) return true;
17117
+ return /(?:^|[-_])free(?:$|[-_.])/u.test(bare);
17118
+ }
17119
+ function freeModelName(modelId) {
17120
+ const bare = modelId.replace(/\([^()]+\)\s*$/u, "").trim();
17121
+ const name = (bare.startsWith("free:") ? bare.slice(5) : bare).replace(/(?:^|[-_])free(?:$|[-_.])/u, "").replace(/[-_.]+/gu, " ").trim();
17122
+ return name === "" ? modelId : name;
17123
+ }
17124
+ function freeCooldownSnapshotOf(status, now) {
17125
+ const cooldowns = new Map();
17126
+ const available = new Map();
17127
+ if (status === void 0) return {
17128
+ cooldowns,
17129
+ available
17130
+ };
17131
+ const accounts = status["accounts"];
17132
+ if (!Array.isArray(accounts)) return {
17133
+ cooldowns,
17134
+ available
17135
+ };
17136
+ for (const raw of accounts) {
17137
+ if (raw === null || typeof raw !== "object") continue;
17138
+ const row = raw;
17139
+ const id = typeof row["id"] === "string" ? row["id"] : "";
17140
+ if (id === "") continue;
17141
+ const label = typeof row["label"] === "string" ? row["label"] : "";
17142
+ const nickname = typeof row["nickname"] === "string" ? row["nickname"] : "";
17143
+ const accountName = (label || nickname || id).trim() || id;
17144
+ available.set(id, row["cooling"] !== true && row["credentialDead"] !== true && row["disabled"] !== true);
17145
+ const list = row["modelCooldowns"];
17146
+ if (!Array.isArray(list)) continue;
17147
+ for (const item of list) {
17148
+ if (item === null || typeof item !== "object") continue;
17149
+ const entry = item;
17150
+ const modelId = typeof entry["modelId"] === "string" ? entry["modelId"] : "";
17151
+ const until = typeof entry["until"] === "string" ? entry["until"] : "";
17152
+ if (modelId === "" || until === "" || !isFreeModelId(modelId)) continue;
17153
+ const at = Date.parse(until);
17154
+ if (!Number.isFinite(at) || at <= now) continue;
17155
+ cooldowns.set(cooldownKey(id, modelId), {
17156
+ accountId: id,
17157
+ accountName,
17158
+ modelId,
17159
+ until
17160
+ });
17161
+ }
17162
+ }
17163
+ return {
17164
+ cooldowns,
17165
+ available
17166
+ };
17167
+ }
17168
+ function detectFreeRecoveries(before, after) {
17169
+ const found = [];
17170
+ const seen = new Set();
17171
+ for (const [key, entry] of before.cooldowns) {
17172
+ if (after.cooldowns.has(key)) continue;
17173
+ if (after.available.get(entry.accountId) !== true) continue;
17174
+ if (seen.has(entry.accountId)) continue;
17175
+ seen.add(entry.accountId);
17176
+ found.push({
17177
+ accountId: entry.accountId,
17178
+ accountName: entry.accountName,
17179
+ modelId: entry.modelId,
17180
+ modelName: freeModelName(entry.modelId)
17181
+ });
17182
+ }
17183
+ return found.sort((a, b) => a.accountId.localeCompare(b.accountId));
17184
+ }
17185
+ //#endregion
16606
17186
  //#region src/client/CreditDot.tsx
16607
17187
  const POLL_MS = 45e3;
17188
+ const RECOVERY_NOTICE_COOLDOWN_MS = 3e4;
16608
17189
  const POOL_STORE_KEY = "dsh-xdpool.pool-snapshot.v2";
16609
17190
  const MARVIS_DAILY_TOKENS = 1e7;
16610
17191
  const OWN_WALLET = new Set([
@@ -16932,10 +17513,79 @@ window.__ModuleLoader__.load({
16932
17513
  noStore: readStoredLanes().lanes.length === 0
16933
17514
  };
16934
17515
  }
16935
- function CreditDot({ t }) {
17516
+ async function fetchSessionRoute(sessionId) {
17517
+ const url = `${POOL_SESSION_ROUTE_PATH}?sessionId=${encodeURIComponent(sessionId)}`;
17518
+ const response = await fetch(url, {
17519
+ headers: { accept: "application/json" },
17520
+ credentials: "same-origin"
17521
+ }).catch(() => void 0);
17522
+ if (response === void 0 || !response.ok) return void 0;
17523
+ const body = await response.json().catch(() => void 0);
17524
+ if (body === void 0) return void 0;
17525
+ const pinnedAccountId = typeof body["pinnedAccountId"] === "string" && body["pinnedAccountId"] !== "" ? body["pinnedAccountId"] : void 0;
17526
+ if (body["known"] !== true) return {
17527
+ known: false,
17528
+ channel: "",
17529
+ region: "",
17530
+ model: "",
17531
+ account: "",
17532
+ at: 0,
17533
+ pinnedAccountId
17534
+ };
17535
+ const text = (key) => typeof body[key] === "string" ? body[key] : "";
17536
+ return {
17537
+ known: true,
17538
+ channel: text("channel"),
17539
+ region: text("region"),
17540
+ model: text("model"),
17541
+ account: text("account"),
17542
+ at: typeof body["at"] === "number" ? body["at"] : 0,
17543
+ pinnedAccountId
17544
+ };
17545
+ }
17546
+ function accountLabel(account) {
17547
+ return (account.label || account.nickname || account.id).trim() || account.id;
17548
+ }
17549
+ function accountChoicesOf(status) {
17550
+ if (status === void 0) return [];
17551
+ const accounts = status["accounts"];
17552
+ if (!Array.isArray(accounts)) return [];
17553
+ const choices = [];
17554
+ const seen = new Set();
17555
+ for (const raw of accounts) {
17556
+ if (raw === null || typeof raw !== "object") continue;
17557
+ const row = raw;
17558
+ const id = typeof row["id"] === "string" ? row["id"] : "";
17559
+ if (id === "" || seen.has(id)) continue;
17560
+ seen.add(id);
17561
+ const label = typeof row["label"] === "string" ? row["label"] : "";
17562
+ const nickname = typeof row["nickname"] === "string" ? row["nickname"] : "";
17563
+ choices.push({
17564
+ id,
17565
+ label: accountLabel({
17566
+ id,
17567
+ label,
17568
+ nickname
17569
+ })
17570
+ });
17571
+ }
17572
+ return choices;
17573
+ }
17574
+ function selectValueOf(pinnedId, accountName, choices) {
17575
+ if (pinnedId !== void 0 && pinnedId !== "") return pinnedId;
17576
+ if (accountName === "") return "";
17577
+ return choices.find((choice) => choice.label === accountName || choice.id === accountName)?.id ?? "";
17578
+ }
17579
+ function CreditDot(input) {
17580
+ const { t, sessionId } = input;
16936
17581
  const [snapshot, setSnapshot] = (0, react.useState)(void 0);
17582
+ const [routeTrace, setRouteTrace] = (0, react.useState)(void 0);
16937
17583
  const [open, setOpen] = (0, react.useState)(false);
16938
17584
  const [failed, setFailed] = (0, react.useState)(false);
17585
+ const [route, setRoute] = (0, react.useState)(void 0);
17586
+ const [accountChoices, setAccountChoices] = (0, react.useState)([]);
17587
+ const [pinnedId, setPinnedId] = (0, react.useState)(void 0);
17588
+ const [pinFailed, setPinFailed] = (0, react.useState)(false);
16939
17589
  const anchorRef = (0, react.useRef)(null);
16940
17590
  const panelRef = (0, react.useRef)(null);
16941
17591
  const [pos, setPos] = (0, react.useState)(void 0);
@@ -16943,6 +17593,10 @@ window.__ModuleLoader__.load({
16943
17593
  const rawRef = (0, react.useRef)(void 0);
16944
17594
  const liveRef = (0, react.useRef)(new Map());
16945
17595
  const liveAtRef = (0, react.useRef)(new Map());
17596
+ const prevFreeCooldownRef = (0, react.useRef)(void 0);
17597
+ const recoveryNotifiedAtRef = (0, react.useRef)(new Map());
17598
+ const [recoveryNotice, setRecoveryNotice] = (0, react.useState)(void 0);
17599
+ const [recoverySwitchedTo, setRecoverySwitchedTo] = (0, react.useState)(void 0);
16946
17600
  const recompose = (0, react.useCallback)(() => {
16947
17601
  const raw = rawRef.current;
16948
17602
  if (raw === void 0 || !mounted.current) return;
@@ -16954,6 +17608,12 @@ window.__ModuleLoader__.load({
16954
17608
  const poolMultiplier = typeof row?.["multiplier"] === "number" ? row["multiplier"] : void 0;
16955
17609
  const next = compose(raw, liveRef.current, caption, poolMultiplier);
16956
17610
  setSnapshot(next);
17611
+ const creditLane = next.channel;
17612
+ const creditKey = creditLane === void 0 ? void 0 : creditLane.id;
17613
+ if (creditLane !== void 0 && creditLane.metered && creditLane.total !== void 0 && creditKey !== void 0 && liveRef.current.get(creditKey) !== creditLane.total) {
17614
+ liveRef.current.set(creditKey, creditLane.total);
17615
+ setSnapshot(compose(raw, liveRef.current, caption, poolMultiplier));
17616
+ }
16957
17617
  const lane = next.channel;
16958
17618
  if (lane !== void 0 && lane.metered && !OWN_WALLET.has(lane.id) && Date.now() - (liveAtRef.current.get(lane.id) ?? 0) > POLL_MS) {
16959
17619
  liveAtRef.current.set(lane.id, Date.now());
@@ -16966,10 +17626,26 @@ window.__ModuleLoader__.load({
16966
17626
  }).catch(() => void 0);
16967
17627
  }
16968
17628
  }, []);
17629
+ (0, react.useEffect)(() => {
17630
+ if (!open) return;
17631
+ let alive = true;
17632
+ const read = () => {
17633
+ fetch(`${POOL_ROUTE_TRACE_PATH}?limit=4`, { headers: { accept: "application/json" } }).then((response) => response.ok ? response.json() : void 0).then((body) => {
17634
+ if (alive && body !== void 0 && typeof body === "object" && Array.isArray(body.routes)) setRouteTrace(body);
17635
+ }).catch(() => void 0);
17636
+ };
17637
+ read();
17638
+ const timer = setInterval(read, 5e3);
17639
+ return () => {
17640
+ alive = false;
17641
+ clearInterval(timer);
17642
+ };
17643
+ }, [open]);
16969
17644
  const load = (0, react.useCallback)(async () => {
16970
17645
  try {
16971
- const [statusRes, spendRes, usageRes] = await Promise.all([
16972
- fetch(POOL_STATUS_PATH, { headers: { accept: "application/json" } }).catch(() => void 0),
17646
+ const [statusCnRes, statusGlobalRes, spendRes, usageRes] = await Promise.all([
17647
+ fetch(`${POOL_STATUS_PATH}?region=cn`, { headers: { accept: "application/json" } }).catch(() => void 0),
17648
+ fetch(`${POOL_STATUS_PATH}?region=global`, { headers: { accept: "application/json" } }).catch(() => void 0),
16973
17649
  fetch(`${POOL_CREDITS_SPEND_PATH}?days=1`, { headers: { accept: "application/json" } }).catch(() => void 0),
16974
17650
  fetch(POOL_USAGE_PATH, {
16975
17651
  headers: { accept: "application/json" },
@@ -16977,7 +17653,25 @@ window.__ModuleLoader__.load({
16977
17653
  }).catch(() => void 0)
16978
17654
  ]);
16979
17655
  if (!mounted.current) return;
16980
- const status = statusRes?.ok === true ? await statusRes.json().catch(() => void 0) : void 0;
17656
+ const [statusCn, statusGlobal] = await Promise.all([statusCnRes?.ok === true ? await statusCnRes.json().catch(() => void 0) : void 0, statusGlobalRes?.ok === true ? await statusGlobalRes.json().catch(() => void 0) : void 0]);
17657
+ const status = statusCn ?? statusGlobal;
17658
+ if (status !== void 0) {
17659
+ const seen = new Set();
17660
+ const merged = [];
17661
+ const addAccounts = (list) => {
17662
+ for (const row of Array.isArray(list) ? list : []) {
17663
+ const id = row !== null && typeof row === "object" ? row["id"] : void 0;
17664
+ if (typeof id === "string") {
17665
+ if (seen.has(id)) continue;
17666
+ seen.add(id);
17667
+ }
17668
+ merged.push(row);
17669
+ }
17670
+ };
17671
+ addAccounts(status["accounts"]);
17672
+ addAccounts(statusGlobal?.["accounts"]);
17673
+ status["accounts"] = merged;
17674
+ }
16981
17675
  const activeChannels = new Set();
16982
17676
  const spendChannels = [];
16983
17677
  const spendRows = [];
@@ -17045,12 +17739,61 @@ window.__ModuleLoader__.load({
17045
17739
  spendRows,
17046
17740
  usage
17047
17741
  };
17742
+ setAccountChoices(accountChoicesOf(status));
17743
+ const now = Date.now();
17744
+ if (status !== void 0) {
17745
+ const currentCooldowns = freeCooldownSnapshotOf(status, now);
17746
+ const previousCooldowns = prevFreeCooldownRef.current;
17747
+ prevFreeCooldownRef.current = currentCooldowns;
17748
+ if (previousCooldowns !== void 0) {
17749
+ const fresh = detectFreeRecoveries(previousCooldowns, currentCooldowns).find((entry) => {
17750
+ const key = `${entry.accountId}\u0000${entry.modelId}`;
17751
+ const last = recoveryNotifiedAtRef.current.get(key) ?? 0;
17752
+ return now - last >= RECOVERY_NOTICE_COOLDOWN_MS;
17753
+ });
17754
+ if (fresh !== void 0) {
17755
+ recoveryNotifiedAtRef.current.set(`${fresh.accountId}\u0000${fresh.modelId}`, now);
17756
+ setRecoveryNotice(fresh);
17757
+ }
17758
+ }
17759
+ }
17760
+ if (sessionId !== void 0 && sessionId !== "") {
17761
+ const answered = await fetchSessionRoute(sessionId).catch(() => void 0);
17762
+ if (mounted.current) {
17763
+ setRoute(answered);
17764
+ if (answered !== void 0) setPinnedId(answered.pinnedAccountId);
17765
+ }
17766
+ }
17048
17767
  recompose();
17049
17768
  setFailed(false);
17050
17769
  } catch {
17051
17770
  if (mounted.current) setFailed(true);
17052
17771
  }
17053
- }, [recompose]);
17772
+ }, [recompose, sessionId]);
17773
+ const changePin = (0, react.useCallback)(async (value) => {
17774
+ if (sessionId === void 0 || sessionId === "") return;
17775
+ const accountId = value === "" ? null : value;
17776
+ try {
17777
+ if (!(await fetch(`/plugins/dsh-xdpool/session/pin?sessionId=${encodeURIComponent(sessionId)}`, {
17778
+ method: "POST",
17779
+ headers: { "content-type": "application/json" },
17780
+ credentials: "same-origin",
17781
+ body: JSON.stringify({ accountId })
17782
+ })).ok) throw new Error("pin rejected");
17783
+ if (!mounted.current) return;
17784
+ setPinnedId(accountId ?? void 0);
17785
+ setPinFailed(false);
17786
+ const answered = await fetchSessionRoute(sessionId).catch(() => void 0);
17787
+ if (mounted.current) setRoute(answered);
17788
+ } catch {
17789
+ if (mounted.current) setPinFailed(true);
17790
+ }
17791
+ }, [sessionId]);
17792
+ const switchToFreeAccount = (0, react.useCallback)((notice) => {
17793
+ setRecoveryNotice(void 0);
17794
+ changePin(notice.accountId);
17795
+ setRecoverySwitchedTo(notice.accountName);
17796
+ }, [changePin]);
17054
17797
  (0, react.useEffect)(() => {
17055
17798
  mounted.current = true;
17056
17799
  load();
@@ -17062,6 +17805,15 @@ window.__ModuleLoader__.load({
17062
17805
  window.clearInterval(timer);
17063
17806
  };
17064
17807
  }, [load]);
17808
+ (0, react.useEffect)(() => {
17809
+ if (recoverySwitchedTo === void 0) return void 0;
17810
+ const timer = window.setTimeout(() => {
17811
+ setRecoverySwitchedTo(void 0);
17812
+ }, 6e3);
17813
+ return () => {
17814
+ window.clearTimeout(timer);
17815
+ };
17816
+ }, [recoverySwitchedTo]);
17065
17817
  (0, react.useEffect)(() => {
17066
17818
  if (open) load();
17067
17819
  }, [open, load]);
@@ -17155,6 +17907,14 @@ window.__ModuleLoader__.load({
17155
17907
  };
17156
17908
  }, [open]);
17157
17909
  const ready = snapshot !== void 0 && !failed;
17910
+ const routeKnown = route !== void 0 && route.known && sessionId !== void 0 && sessionId !== "";
17911
+ const isPinned = pinnedId !== void 0 && pinnedId !== "";
17912
+ const pinnedBadge = isPinned ? (0, react_jsx_runtime.jsxs)("span", {
17913
+ className: "dsm-xdpool-dotpin",
17914
+ title: t?.("dot.accountPinned") ?? "已固定,不会自动切换",
17915
+ children: ["📌 ", t?.("dot.pinnedShort") ?? "固定"]
17916
+ }) : null;
17917
+ const selectedAccount = selectValueOf(pinnedId, route?.account ?? "", accountChoices);
17158
17918
  const total = snapshot?.channel?.total ?? 0;
17159
17919
  const alive = ready && snapshot.channel !== void 0 && snapshot.channel.metered && total > 0;
17160
17920
  const unmetered = ready && snapshot.channel !== void 0 && !snapshot.channel.metered;
@@ -17166,101 +17926,261 @@ window.__ModuleLoader__.load({
17166
17926
  return (0, react_jsx_runtime.jsxs)("span", {
17167
17927
  className: "dsm-xdpool-dotwrap",
17168
17928
  style: { ["--xdpool-dot-mask"]: `url("${POOL_NAV_ICON_MASK_URL}")` },
17169
- children: [(0, react_jsx_runtime.jsx)("button", {
17170
- ref: anchorRef,
17171
- type: "button",
17172
- className: "dsm-xdpool-dot",
17173
- "data-state": state,
17174
- "aria-label": label,
17175
- "aria-expanded": open,
17176
- title: lane === void 0 ? label : `${lane.name} · ${lane.total === void 0 ? "—" : withUnit(lane.total, lane.unit)}`,
17177
- onClick: () => {
17178
- setOpen((current) => !current);
17179
- },
17180
- children: (0, react_jsx_runtime.jsx)("span", {
17181
- className: "dsm-xdpool-dot-glyph",
17182
- "aria-hidden": "true"
17183
- })
17184
- }), !open ? null : (0, react_dom.createPortal)((0, react_jsx_runtime.jsxs)("div", {
17185
- ref: panelRef,
17186
- className: "dsm-xdpool-dotpanel",
17187
- role: "dialog",
17188
- "aria-label": t?.("dot.panelTitle") ?? "本会话积分",
17189
- style: pos === void 0 ? { visibility: "hidden" } : {
17190
- top: `${String(pos.top)}px`,
17191
- left: `${String(pos.left)}px`
17192
- },
17193
- children: [!ready ? (0, react_jsx_runtime.jsx)("p", {
17194
- className: "dsm-xdpool-dotpanel-hint",
17195
- children: failed ? t?.("dot.loadFailed") ?? "积分数据读取失败" : t?.("dot.loading") ?? "正在读取积分…"
17196
- }) : null, !ready ? null : (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
17197
- (0, react_jsx_runtime.jsx)("div", {
17198
- className: "dsm-xdpool-dotpanel-head",
17199
- children: (0, react_jsx_runtime.jsx)("span", {
17200
- className: "dsm-xdpool-dotpanel-channel",
17201
- children: lane === void 0 ? t?.("dot.channelUnknown") ?? "没认出当前模型的渠道" : !lane.metered ? `${lane.name} · 不按积分计费` : `${lane.name} · ${lane.total === void 0 ? "—" : withUnit(lane.total, lane.unit)}`
17202
- })
17203
- }),
17204
- lane === void 0 || snapshot.why === "" ? null : (0, react_jsx_runtime.jsx)("span", {
17205
- className: "dsm-xdpool-dotpanel-k-sub",
17206
- children: `依据:${snapshot.why}`
17207
- }),
17208
- fill === void 0 || lane === void 0 || !lane.metered ? null : (0, react_jsx_runtime.jsx)("div", {
17209
- className: "dsm-xdpool-dotbar",
17210
- role: "img",
17211
- "aria-label": t?.("dot.barLabel") ?? "今日已用占比",
17212
- children: (0, react_jsx_runtime.jsx)("div", {
17213
- className: "dsm-xdpool-dotbar-fill",
17214
- "data-full": fill >= 90 ? "true" : "false",
17215
- style: { width: `${String(fill)}%` }
17216
- })
17217
- }),
17218
- (0, react_jsx_runtime.jsxs)("div", {
17219
- className: "dsm-xdpool-dotpanel-sec",
17929
+ children: [
17930
+ (0, react_jsx_runtime.jsx)("button", {
17931
+ ref: anchorRef,
17932
+ type: "button",
17933
+ className: "dsm-xdpool-dot",
17934
+ "data-state": state,
17935
+ "aria-label": label,
17936
+ "aria-expanded": open,
17937
+ title: lane === void 0 ? label : `${lane.name} · ${lane.total === void 0 ? "—" : withUnit(lane.total, lane.unit)}`,
17938
+ onClick: () => {
17939
+ setOpen((current) => !current);
17940
+ },
17941
+ children: (0, react_jsx_runtime.jsx)("span", {
17942
+ className: "dsm-xdpool-dot-glyph",
17943
+ "aria-hidden": "true"
17944
+ })
17945
+ }),
17946
+ (0, react_jsx_runtime.jsx)("span", {
17947
+ className: "dsm-xdpool-dotlabel",
17948
+ "data-state": state,
17949
+ title: lane === void 0 ? "—" : `${lane.name} · ${lane.total === void 0 ? "—" : withUnit(lane.total, lane.unit)}`,
17950
+ children: lane === void 0 ? "—" : `${lane.name} ${lane.total === void 0 ? "—" : withUnit(lane.total, lane.unit)}`
17951
+ }),
17952
+ route === void 0 || !route.known ? null : (0, react_jsx_runtime.jsxs)("span", {
17953
+ className: "dsm-xdpool-dotroute",
17954
+ "aria-label": t?.("dot.sessionRouteInline") ?? "本会话归属",
17955
+ children: [(0, react_jsx_runtime.jsxs)("span", {
17956
+ className: "dsm-xdpool-dotroute-line",
17220
17957
  children: [(0, react_jsx_runtime.jsx)("span", {
17221
17958
  className: "dsm-xdpool-dotpanel-k",
17222
- children: t?.("dot.spentToday") ?? "今日已用"
17223
- }), (0, react_jsx_runtime.jsx)("span", {
17224
- className: "dsm-xdpool-dotpanel-v",
17225
- children: lane?.quotaTotal === void 0 ? spentText : `${spentText} / ${wan(lane.quotaTotal)}`
17959
+ children: t?.("dot.sessionChannel") ?? "本会话走"
17960
+ }), (0, react_jsx_runtime.jsxs)("span", {
17961
+ className: "dsm-xdpool-dotroute-v",
17962
+ children: [route.channel === "" ? "—" : brandName(route.channel), route.region === "" ? "" : ` · ${route.region === "global" ? "国际版" : "国内版"}`]
17226
17963
  })]
17227
- }),
17228
- (0, react_jsx_runtime.jsxs)("div", {
17229
- className: "dsm-xdpool-dotpanel-sec",
17964
+ }), (0, react_jsx_runtime.jsxs)("span", {
17965
+ className: "dsm-xdpool-dotroute-line",
17230
17966
  children: [(0, react_jsx_runtime.jsx)("span", {
17231
17967
  className: "dsm-xdpool-dotpanel-k",
17232
- children: t?.("dot.model") ?? "模型"
17968
+ children: t?.("dot.sessionAccount") ?? "本会话账号"
17233
17969
  }), (0, react_jsx_runtime.jsxs)("span", {
17234
- className: "dsm-xdpool-dotpanel-v",
17235
- children: [snapshot.model === "" ? "—" : snapshot.model, snapshot.multiplier === void 0 ? "" : ` · x${rate(snapshot.multiplier)}`]
17970
+ className: "dsm-xdpool-dotroute-v",
17971
+ title: route.account === "" ? t?.("dot.sessionAccountUnknown") ?? "这个渠道的账号由它自己挑选" : route.account,
17972
+ children: [route.account === "" ? t?.("dot.sessionAccountUnknownShort") ?? "由渠道自行挑选" : route.account, pinnedBadge]
17236
17973
  })]
17237
- }),
17238
- (snapshot.all ?? []).length === 0 ? null : (0, react_jsx_runtime.jsxs)("div", {
17239
- className: "dsm-xdpool-dotpanel-more",
17240
- children: [(0, react_jsx_runtime.jsx)("span", {
17974
+ })]
17975
+ }),
17976
+ recoveryNotice === void 0 ? null : (0, react_jsx_runtime.jsxs)("span", {
17977
+ className: "dsm-xdpool-dotrecovery",
17978
+ role: "status",
17979
+ children: [(0, react_jsx_runtime.jsx)("span", {
17980
+ className: "dsm-xdpool-dotrecovery-text",
17981
+ children: t?.("dot.freeRecovered", {
17982
+ account: recoveryNotice.accountName,
17983
+ model: recoveryNotice.modelName
17984
+ }) ?? `免费额度已恢复:${recoveryNotice.accountName} · ${recoveryNotice.modelName}`
17985
+ }), recoveryNotice.accountId === pinnedId ? null : (0, react_jsx_runtime.jsx)("button", {
17986
+ type: "button",
17987
+ className: "dsm-xdpool-dotrecovery-btn",
17988
+ onClick: () => {
17989
+ switchToFreeAccount(recoveryNotice);
17990
+ },
17991
+ children: t?.("dot.freeRecoveredSwitch") ?? "切换"
17992
+ })]
17993
+ }),
17994
+ recoverySwitchedTo === void 0 ? null : (0, react_jsx_runtime.jsx)("span", {
17995
+ className: "dsm-xdpool-dotrecovery-ok",
17996
+ role: "status",
17997
+ children: t?.("dot.freeRecoveredPinned", { account: recoverySwitchedTo }) ?? `已固定到免费账号:${recoverySwitchedTo}`
17998
+ }),
17999
+ !open ? null : (0, react_dom.createPortal)((0, react_jsx_runtime.jsxs)("div", {
18000
+ ref: panelRef,
18001
+ className: "dsm-xdpool-dotpanel",
18002
+ role: "dialog",
18003
+ "aria-label": t?.("dot.panelTitle") ?? "本会话积分",
18004
+ style: pos === void 0 ? { visibility: "hidden" } : {
18005
+ top: `${String(pos.top)}px`,
18006
+ left: `${String(pos.left)}px`
18007
+ },
18008
+ children: [!ready ? (0, react_jsx_runtime.jsx)("p", {
18009
+ className: "dsm-xdpool-dotpanel-hint",
18010
+ children: failed ? t?.("dot.loadFailed") ?? "积分数据读取失败" : t?.("dot.loading") ?? "正在读取积分…"
18011
+ }) : null, !ready ? null : (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
18012
+ (0, react_jsx_runtime.jsx)("div", {
18013
+ className: "dsm-xdpool-dotpanel-head",
18014
+ children: (0, react_jsx_runtime.jsx)("span", {
18015
+ className: "dsm-xdpool-dotpanel-channel",
18016
+ children: lane === void 0 ? t?.("dot.channelUnknown") ?? "没认出当前模型的渠道" : !lane.metered ? `${lane.name} · 不按积分计费` : `${lane.name} · ${lane.total === void 0 ? "—" : withUnit(lane.total, lane.unit)}`
18017
+ })
18018
+ }),
18019
+ lane === void 0 || snapshot.why === "" ? null : (0, react_jsx_runtime.jsx)("span", {
17241
18020
  className: "dsm-xdpool-dotpanel-k-sub",
17242
- children: "同一模型的其他渠道"
17243
- }), (snapshot.all ?? []).map((other) => {
17244
- const used = snapshot.usedChannels.some((row) => row.id === other.id);
17245
- return (0, react_jsx_runtime.jsxs)("div", {
17246
- className: "dsm-xdpool-dotpanel-row",
18021
+ children: `依据:${snapshot.why}`
18022
+ }),
18023
+ fill === void 0 || lane === void 0 || !lane.metered ? null : (0, react_jsx_runtime.jsx)("div", {
18024
+ className: "dsm-xdpool-dotbar",
18025
+ role: "img",
18026
+ "aria-label": t?.("dot.barLabel") ?? "今日已用占比",
18027
+ children: (0, react_jsx_runtime.jsx)("div", {
18028
+ className: "dsm-xdpool-dotbar-fill",
18029
+ "data-full": fill >= 90 ? "true" : "false",
18030
+ style: { width: `${String(fill)}%` }
18031
+ })
18032
+ }),
18033
+ (0, react_jsx_runtime.jsxs)("div", {
18034
+ className: "dsm-xdpool-dotpanel-sec",
18035
+ children: [(0, react_jsx_runtime.jsx)("span", {
18036
+ className: "dsm-xdpool-dotpanel-k",
18037
+ children: t?.("dot.spentToday") ?? "今日已用"
18038
+ }), (0, react_jsx_runtime.jsx)("span", {
18039
+ className: "dsm-xdpool-dotpanel-v",
18040
+ children: lane?.quotaTotal === void 0 ? spentText : `${spentText} / ${wan(lane.quotaTotal)}`
18041
+ })]
18042
+ }),
18043
+ (0, react_jsx_runtime.jsxs)("div", {
18044
+ className: "dsm-xdpool-dotpanel-sec",
18045
+ children: [(0, react_jsx_runtime.jsx)("span", {
18046
+ className: "dsm-xdpool-dotpanel-k",
18047
+ children: t?.("dot.model") ?? "模型"
18048
+ }), (0, react_jsx_runtime.jsxs)("span", {
18049
+ className: "dsm-xdpool-dotpanel-v",
18050
+ children: [snapshot.model === "" ? "—" : snapshot.model, snapshot.multiplier === void 0 ? "" : ` · x${rate(snapshot.multiplier)}`]
18051
+ })]
18052
+ }),
18053
+ route === void 0 || !route.known ? null : (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
18054
+ (0, react_jsx_runtime.jsxs)("div", {
18055
+ className: "dsm-xdpool-dotpanel-sec",
17247
18056
  children: [(0, react_jsx_runtime.jsx)("span", {
17248
- className: "dsm-xdpool-dotpanel-rowname",
17249
- "data-used": used ? "true" : "false",
17250
- children: other.name
18057
+ className: "dsm-xdpool-dotpanel-k",
18058
+ children: t?.("dot.sessionChannel") ?? "本会话走"
18059
+ }), (0, react_jsx_runtime.jsxs)("span", {
18060
+ className: "dsm-xdpool-dotpanel-v",
18061
+ children: [route.channel === "" ? "—" : brandName(route.channel), route.region === "" ? "" : ` · ${route.region === "global" ? "国际版" : "国内版"}`]
18062
+ })]
18063
+ }),
18064
+ (0, react_jsx_runtime.jsxs)("div", {
18065
+ className: "dsm-xdpool-dotpanel-sec",
18066
+ children: [(0, react_jsx_runtime.jsx)("span", {
18067
+ className: "dsm-xdpool-dotpanel-k",
18068
+ children: t?.("dot.sessionAccount") ?? "本会话账号"
18069
+ }), (0, react_jsx_runtime.jsxs)("span", {
18070
+ className: "dsm-xdpool-dotpanel-v",
18071
+ title: route.account === "" ? t?.("dot.sessionAccountUnknown") ?? "这个渠道的账号由它自己挑选" : route.account,
18072
+ children: [route.account === "" ? t?.("dot.sessionAccountUnknown") ?? "由渠道自行挑选" : route.account, pinnedBadge]
18073
+ })]
18074
+ }),
18075
+ routeKnown ? (0, react_jsx_runtime.jsxs)("div", {
18076
+ className: "dsm-xdpool-dotpanel-sec",
18077
+ children: [(0, react_jsx_runtime.jsx)("span", {
18078
+ className: "dsm-xdpool-dotpanel-k",
18079
+ children: t?.("dot.accountPinLabel") ?? "账号选择"
17251
18080
  }), (0, react_jsx_runtime.jsx)("span", {
17252
- className: "dsm-xdpool-dotpanel-rowval",
17253
- children: !other.metered ? "不计积分" : other.total === void 0 ? "—" : withUnit(other.total, other.unit)
18081
+ className: "dsm-xdpool-dotpanel-v",
18082
+ children: (0, react_jsx_runtime.jsxs)("select", {
18083
+ className: "dsm-xdpool-dotpin-select",
18084
+ "aria-label": t?.("dot.accountPinLabel") ?? "账号选择",
18085
+ value: selectedAccount,
18086
+ onChange: (event) => {
18087
+ changePin(event.target.value);
18088
+ },
18089
+ children: [(0, react_jsx_runtime.jsx)("option", {
18090
+ value: "",
18091
+ children: t?.("dot.accountAuto") ?? "自动(不固定)"
18092
+ }), accountChoices.map((choice) => (0, react_jsx_runtime.jsx)("option", {
18093
+ value: choice.id,
18094
+ children: choice.label
18095
+ }, choice.id))]
18096
+ })
17254
18097
  })]
17255
- }, other.id);
17256
- })]
17257
- }),
17258
- lane === void 0 && snapshot.noStore ? (0, react_jsx_runtime.jsx)("p", {
17259
- className: "dsm-xdpool-dotpanel-hint",
17260
- children: "打开一次 XD Pool 的账号池页面,这里就能认出登录渠道的模型和积分。"
17261
- }) : null
17262
- ] })]
17263
- }), document.body)]
18098
+ }) : null,
18099
+ routeKnown && isPinned ? (0, react_jsx_runtime.jsxs)("span", {
18100
+ className: "dsm-xdpool-dotpanel-k-sub",
18101
+ children: [
18102
+ t?.("dot.accountPinTo") ?? "固定到",
18103
+ " ",
18104
+ accountChoices.find((choice) => choice.id === pinnedId)?.label ?? pinnedId
18105
+ ]
18106
+ }) : null,
18107
+ pinFailed ? (0, react_jsx_runtime.jsx)("span", {
18108
+ className: "dsm-xdpool-dotpanel-k-sub",
18109
+ children: t?.("dot.accountPinFailed") ?? "固定失败,请重试"
18110
+ }) : null
18111
+ ] }),
18112
+ (snapshot.all ?? []).length === 0 ? null : (0, react_jsx_runtime.jsxs)("div", {
18113
+ className: "dsm-xdpool-dotpanel-more",
18114
+ children: [(0, react_jsx_runtime.jsx)("span", {
18115
+ className: "dsm-xdpool-dotpanel-k-sub",
18116
+ children: "同一模型的其他渠道"
18117
+ }), (snapshot.all ?? []).map((other) => {
18118
+ const used = snapshot.usedChannels.some((row) => row.id === other.id);
18119
+ return (0, react_jsx_runtime.jsxs)("div", {
18120
+ className: "dsm-xdpool-dotpanel-row",
18121
+ children: [(0, react_jsx_runtime.jsx)("span", {
18122
+ className: "dsm-xdpool-dotpanel-rowname",
18123
+ "data-used": used ? "true" : "false",
18124
+ children: other.name
18125
+ }), (0, react_jsx_runtime.jsx)("span", {
18126
+ className: "dsm-xdpool-dotpanel-rowval",
18127
+ children: !other.metered ? "不计积分" : other.total === void 0 ? "—" : withUnit(other.total, other.unit)
18128
+ })]
18129
+ }, other.id);
18130
+ })]
18131
+ }),
18132
+ lane === void 0 && snapshot.noStore ? (0, react_jsx_runtime.jsx)("p", {
18133
+ className: "dsm-xdpool-dotpanel-hint",
18134
+ children: "打开一次 XD Pool 的账号池页面,这里就能认出登录渠道的模型和积分。"
18135
+ }) : null,
18136
+ !ready || (routeTrace?.routes ?? []).length === 0 ? null : (0, react_jsx_runtime.jsxs)("div", {
18137
+ className: "dsm-xdpool-dotpanel-more",
18138
+ children: [(0, react_jsx_runtime.jsx)("span", {
18139
+ className: "dsm-xdpool-dotpanel-k-sub",
18140
+ children: "最近一个请求是怎么路由的"
18141
+ }), (() => {
18142
+ const d = routeTrace.routes[0];
18143
+ return (0, react_jsx_runtime.jsxs)("div", {
18144
+ className: "dsm-xdpool-dotroute",
18145
+ children: [(0, react_jsx_runtime.jsxs)("div", {
18146
+ className: "dsm-xdpool-dotroute-node",
18147
+ "data-served": "true",
18148
+ style: {
18149
+ borderLeftColor: "transparent",
18150
+ paddingLeft: 8,
18151
+ marginLeft: 0
18152
+ },
18153
+ children: [(0, react_jsx_runtime.jsx)("span", {
18154
+ className: "dsm-xdpool-dotroute-name",
18155
+ children: d.model
18156
+ }), (0, react_jsx_runtime.jsxs)("span", {
18157
+ className: "dsm-xdpool-dotroute-why",
18158
+ children: [
18159
+ d.steps.length,
18160
+ " 次尝试 · ",
18161
+ d.servedBy === void 0 ? "未命中" : "已命中"
18162
+ ]
18163
+ })]
18164
+ }), d.steps.map((step, i) => {
18165
+ const served = step.outcome === "served";
18166
+ return (0, react_jsx_runtime.jsxs)("div", {
18167
+ className: "dsm-xdpool-dotroute-node",
18168
+ "data-served": served ? "true" : "false",
18169
+ children: [(0, react_jsx_runtime.jsx)("span", {
18170
+ className: "dsm-xdpool-dotroute-name",
18171
+ children: step.member
18172
+ }), (0, react_jsx_runtime.jsx)("span", {
18173
+ className: "dsm-xdpool-dotroute-why",
18174
+ children: served ? "命中 · 已接入本次回复" : `${step.kind ?? "失败"} · ${String(step.status ?? "")} · 切下一个`
18175
+ })]
18176
+ }, `${step.member}-${String(i)}`);
18177
+ })]
18178
+ });
18179
+ })()]
18180
+ })
18181
+ ] })]
18182
+ }), document.body)
18183
+ ]
17264
18184
  });
17265
18185
  }
17266
18186
  //#endregion
@@ -17421,7 +18341,7 @@ window.__ModuleLoader__.load({
17421
18341
  .app ::-webkit-scrollbar-thumb:hover { background: var(--line-3); background-clip: content-box; }
17422
18342
 
17423
18343
  @media (prefers-reduced-motion: reduce) {
17424
- * { transition-duration: 1ms !important; animation-duration: 1ms !important; }
18344
+ .app * { transition-duration: 1ms !important; animation-duration: 1ms !important; }
17425
18345
  }
17426
18346
 
17427
18347
  /*
@@ -19322,7 +20242,7 @@ window.__ModuleLoader__.load({
19322
20242
 
19323
20243
  /* 减少动效 */
19324
20244
  @media (prefers-reduced-motion:reduce){
19325
- *{transition-duration:1ms !important;animation-duration:1ms !important}
20245
+ .app *{transition-duration:1ms !important;animation-duration:1ms !important}
19326
20246
  }
19327
20247
 
19328
20248
 
@@ -19641,7 +20561,10 @@ label.sw:has(input:disabled) { opacity: .5; cursor: not-allowed }
19641
20561
  is the whole at-a-glance message — green while the serving channel has credits, grey
19642
20562
  once it does not — and the detail lives behind a click, because that row already
19643
20563
  holds a back button, a model name, a multiplier and a reasoning level. */
19644
- .dsm-xdpool-dotwrap{position:relative;display:inline-flex;align-items:center;flex:none;margin:0 2px}
20564
+ .dsm-xdpool-dotwrap{position:relative;display:inline-flex;align-items:center;gap:5px;flex:none;margin:0 2px}
20565
+ .dsm-xdpool-dotlabel{font-size:12px;font-weight:500;line-height:16px;white-space:nowrap;color:var(--dsw-alias-label-secondary,#b9becd);font-variant-numeric:tabular-nums;max-width:180px;overflow:hidden;text-overflow:ellipsis}
20566
+ .dsm-xdpool-dotlabel[data-state='alive']{color:#22c55e}
20567
+ .dsm-xdpool-dotlabel[data-state='empty']{color:var(--dsw-alias-label-tertiary,#8a90a0)}
19645
20568
  .dsm-xdpool-dot{appearance:none;-webkit-appearance:none;display:grid;place-items:center;width:16px;height:16px;padding:0;margin:0;border:0;background:none;cursor:pointer;flex:none;border-radius:4px;transition:background-color .16s ease}
19646
20569
  .dsm-xdpool-dot:hover{background:color-mix(in srgb, var(--dsw-alias-label-primary,#e8eaf0) 12%, transparent)}
19647
20570
  .dsm-xdpool-dot-glyph{display:block;width:13px;height:13px;background-color:currentColor;-webkit-mask-image:var(--xdpool-dot-mask, none);mask-image:var(--xdpool-dot-mask, none);-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-position:center;mask-position:center;-webkit-mask-size:13px 13px;mask-size:13px 13px;transition:color .18s ease}
@@ -19681,6 +20604,46 @@ label.sw:has(input:disabled) { opacity: .5; cursor: not-allowed }
19681
20604
  /* 认出渠道的依据、「同一模型的其他渠道」这种小字 */
19682
20605
  .dsm-xdpool-dotpanel-k-sub{display:block;font-size:11px;line-height:15px;color:var(--dsw-alias-label-tertiary,#8a90a0);margin-top:-3px}
19683
20606
  .dsm-xdpool-dotpanel-more .dsm-xdpool-dotpanel-k-sub{margin:0 0 2px}
20607
+
20608
+ /* 工具行里的落位:20px 高,与模型选择器那一排对齐。克劳德风格把工具行收进卡片,
20609
+ 圆点落在模型名左边;它自家的 seat 自带 4px 内边距,这里再让出 6px 呼吸。 */
20610
+ .dsm-xdpool-dotwrap{height:20px}
20611
+ body[data-dsh-claude-style] .dsm-xdpool-dotwrap{margin:0 6px 0 0}
20612
+
20613
+
20614
+ /* 角标旁常驻的两行归属(和弹出面板里那两行同源,不用点开就能看见)。
20615
+ 横向排布、字号压到 10px,避免把输入框那一行撑高;值过长时省略号截断。 */
20616
+ .dsm-xdpool-dotroute{display:flex;flex-direction:column;justify-content:center;gap:1px;min-width:0;max-width:160px;margin-left:4px}
20617
+ .dsm-xdpool-dotroute-line{display:flex;align-items:baseline;gap:4px;min-width:0;font-size:10px;line-height:13px}
20618
+ .dsm-xdpool-dotroute-line .dsm-xdpool-dotpanel-k{font-size:10px;line-height:13px}
20619
+ .dsm-xdpool-dotroute-v{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-secondary,#b9bfcc)}
20620
+ /* 会话账号被固定时的小标记:角标旁两行里的小字,别把那一行撑高。 */
20621
+ .dsm-xdpool-dotpin{font-size:9px;line-height:13px;margin-left:4px;color:#22c55e;white-space:nowrap}
20622
+ /* 弹出面板里的账号下拉框:10.5px、宽度自适应、不撑破 max-content 的面板。
20623
+ max-width:100% + min-width:0 让长账号名由 option 自己截断,而不是把面板拉宽。 */
20624
+ .dsm-xdpool-dotpin-select{max-width:100%;min-width:0;font-size:10.5px;line-height:16px;padding:1px 4px;border-radius:6px;border:1px solid color-mix(in srgb, var(--dsw-alias-border-l2,#ffffff1f) 80%, transparent);background:var(--dsw-alias-bg-layer-1,#23262d);color:var(--dsw-alias-label-primary,#e8eaf0);cursor:pointer}
20625
+ .dsm-xdpool-dotpin-select:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:2px}
20626
+ /* 免费额度恢复提醒:角标旁一条紧凑提示 +「切换」按钮,点击复用 pin POST。
20627
+ 和常驻归属两行共用 10px 字号,避免把输入框那一行撑高。 */
20628
+ .dsm-xdpool-dotrecovery{display:inline-flex;align-items:center;gap:5px;max-width:210px;margin-left:6px;padding:1px 4px;border-radius:6px;font-size:10px;line-height:14px;color:#22c55e;background:rgb(34 197 94 / 12%);white-space:nowrap}
20629
+ .dsm-xdpool-dotrecovery-text{overflow:hidden;text-overflow:ellipsis;min-width:0}
20630
+ .dsm-xdpool-dotrecovery-btn{flex:none;appearance:none;-webkit-appearance:none;padding:0 5px;border:1px solid rgb(34 197 94 / 45%);border-radius:5px;background:none;color:#22c55e;font-size:10px;line-height:14px;cursor:pointer}
20631
+ .dsm-xdpool-dotrecovery-btn:hover{background:rgb(34 197 94 / 18%)}
20632
+ .dsm-xdpool-dotrecovery-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:2px}
20633
+ .dsm-xdpool-dotrecovery-ok{margin-left:6px;font-size:10px;line-height:14px;color:#22c55e;white-space:nowrap}
20634
+
20635
+ /* 实时路由链路(issue: magpie 式「最近一个请求怎么路由的」精简版)。
20636
+ 小弹窗空间有限,用左侧竖线串起账号/成员,命中的那个亮色 + 浅绿底。 */
20637
+ .dsm-xdpool-dotroute{display:flex;flex-direction:column;gap:0;padding:2px 0}
20638
+ .dsm-xdpool-dotroute-node{position:relative;padding:4px 6px 4px 14px;margin-left:5px;border-left:1px solid color-mix(in srgb, var(--dsw-alias-border-l2,#ffffff1f) 80%, transparent)}
20639
+ .dsm-xdpool-dotroute-node::before{content:'';position:absolute;left:-3.5px;top:10px;width:6px;height:6px;border-radius:50%;background:var(--dsw-alias-label-tertiary,#8a90a0)}
20640
+ .dsm-xdpool-dotroute-node[data-served='true']{border-left-color:#22c55e;background:rgb(34 197 94 / 7%);border-radius:0 6px 6px 0}
20641
+ .dsm-xdpool-dotroute-node[data-served='true']::before{background:#22c55e}
20642
+ .dsm-xdpool-dotroute-name{display:block;font-size:12px;line-height:16px;color:var(--dsw-alias-label-primary,#e8eaf0);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
20643
+ .dsm-xdpool-dotroute-why{display:block;font-size:12px;line-height:15px;color:var(--dsw-alias-label-tertiary,#8a90a0)}
20644
+ .dsm-xdpool-dotroute-bar{height:3px;border-radius:999px;background:color-mix(in srgb, var(--dsw-alias-label-tertiary,#8a90a0) 22%, transparent);margin-top:3px;overflow:hidden}
20645
+ .dsm-xdpool-dotroute-bar span{display:block;height:100%;border-radius:999px;background:#22c55e}
20646
+ .dsm-xdpool-dotroute-bar span[data-full='true']{background:#f59e0b}
19684
20647
  `;
19685
20648
  //#endregion
19686
20649
  //#region src/client/theme-css.ts
@@ -19728,7 +20691,7 @@ label.sw:has(input:disabled) { opacity: .5; cursor: not-allowed }
19728
20691
 
19729
20692
  /* ---- 状态色:暗色那套是给深底提亮的,白底上要压暗才读得清 ---- */
19730
20693
  --ok: #2E7D46; /* 5.1:1 */
19731
- --warn: #8A6410; /* 5.4:1 */
20694
+ --warn: #755309; /* 压暗到 #ECEADC 底上 ≥4.5:1(pill[data-tone=warn] 混色后) */
19732
20695
  --danger: #B23A26; /* 6.0:1 */
19733
20696
  --info: #2F6A9E; /* 5.7:1 */
19734
20697
 
@@ -20378,6 +21341,20 @@ label.sw:has(input:disabled) { opacity: .5; cursor: not-allowed }
20378
21341
  "dot.loadFailed": "Could not read the credit data",
20379
21342
  "dot.remaining": "Remaining",
20380
21343
  "dot.barLabel": "Share of the period budget used",
21344
+ "dot.sessionChannel": "Served by",
21345
+ "dot.sessionAccount": "Account",
21346
+ "dot.sessionAccountUnknown": "Chosen by the channel",
21347
+ "dot.sessionAccountUnknownShort": "channel-picked",
21348
+ "dot.sessionRouteInline": "This session",
21349
+ "dot.accountPinLabel": "Account selection",
21350
+ "dot.accountAuto": "Auto (unpinned)",
21351
+ "dot.accountPinTo": "Pin to",
21352
+ "dot.accountPinned": "Pinned — the pool will not rotate this session",
21353
+ "dot.pinnedShort": "pinned",
21354
+ "dot.accountPinFailed": "Could not pin the account — please retry",
21355
+ "dot.freeRecovered": "Free quota restored: {account} · {model}",
21356
+ "dot.freeRecoveredSwitch": "Switch",
21357
+ "dot.freeRecoveredPinned": "Pinned to free account: {account}",
20381
21358
  "gw.keyHint": "This key survives a DSH restart. Rotating it drops every device that still holds the old one. This is not the per-process secret of the pool itself — a client that learned that one would stop working the next time DSH restarts.",
20382
21359
  "gw.usage": "Using it",
20383
21360
  "gw.usageHint": "Any OpenAI-compatible app works. Set its base URL to the endpoint above, pick a model out of /v1/models, and send this key as the API key. The relay passes /v1/models and /v1/chat/completions only; everything else is refused before a byte is forwarded.",
@@ -20641,8 +21618,8 @@ label.sw:has(input:disabled) { opacity: .5; cursor: not-allowed }
20641
21618
  "row.accountToggleError": "切换账号失败:{message}",
20642
21619
  "row.accountIgnore": "移出池子",
20643
21620
  "row.accountIgnoreHint": "把这个账号永久移出池子 —— 不再读取它的凭据,即使重新登录也不会回来",
20644
- "row.accountPrefer": "优先",
20645
- "row.accountPreferOn": "已优先",
21621
+ "row.accountPrefer": "优先用此账号",
21622
+ "row.accountPreferOn": "取消优先",
20646
21623
  "row.accountPreferHint": "优先使用这个账号 —— 它健康时先用它,不可用时自动回到你设定的分发策略",
20647
21624
  "row.accountPreferClearHint": "取消优先,改回按你设定的分发策略轮换",
20648
21625
  "row.accountPreferError": "设置优先账号失败:{message}",
@@ -21101,6 +22078,20 @@ label.sw:has(input:disabled) { opacity: .5; cursor: not-allowed }
21101
22078
  "dot.loadFailed": "积分数据读取失败",
21102
22079
  "dot.remaining": "剩余积分",
21103
22080
  "dot.barLabel": "本期已用占比",
22081
+ "dot.sessionChannel": "本会话走",
22082
+ "dot.sessionAccount": "本会话账号",
22083
+ "dot.sessionAccountUnknown": "由渠道自行挑选",
22084
+ "dot.sessionAccountUnknownShort": "由渠道自行挑选",
22085
+ "dot.sessionRouteInline": "本会话归属",
22086
+ "dot.accountPinLabel": "账号选择",
22087
+ "dot.accountAuto": "自动(不固定)",
22088
+ "dot.accountPinTo": "固定到",
22089
+ "dot.accountPinned": "已固定,池子不会自动换号",
22090
+ "dot.pinnedShort": "固定",
22091
+ "dot.accountPinFailed": "固定失败,请重试",
22092
+ "dot.freeRecovered": "免费额度已恢复:{account} · {model}",
22093
+ "dot.freeRecoveredSwitch": "切换",
22094
+ "dot.freeRecoveredPinned": "已固定到免费账号:{account}",
21104
22095
  "gw.keyHint": "这把密钥在 DSH 重启后仍然有效。轮换会让所有还在用旧密钥的设备立刻断线。这里给的也不是账号池自己每进程生成的秘密 —— 客户端要是拿到它,DSH 下次一重启就全废了。",
21105
22096
  "gw.usage": "怎么用",
21106
22097
  "gw.usageHint": "任何 OpenAI 兼容的客户端都行:接口地址填上面那个入口,模型从 /v1/models 里挑,密钥填到这个 API 密钥的位置。中继只放行 /v1/models 和 /v1/chat/completions,其余路径在转发任何字节之前就拒掉。",
@@ -21363,12 +22354,22 @@ label.sw:has(input:disabled) { opacity: .5; cursor: not-allowed }
21363
22354
  console.error("[dsh-xdpool] sidebar entry unavailable (settings page unaffected):", error);
21364
22355
  }
21365
22356
  try {
21366
- ctx.slots.inject("conversation.composer.dock", () => ctx.slots.register({
21367
- name: "conversation.composer.dock",
22357
+ const dotEntry = (slotName) => ({
22358
+ name: slotName,
21368
22359
  id: "xdpool-credit-dot",
21369
22360
  order: 20,
21370
22361
  inject: () => t === void 0 ? {} : { t }
21371
- }, CreditDot));
22362
+ });
22363
+ const registerDot = (slotName) => () => {
22364
+ try {
22365
+ return ctx.slots.register(dotEntry(slotName), CreditDot);
22366
+ } catch (error) {
22367
+ console.error(`[dsh-xdpool] the credit dot could not use the ${slotName} slot:`, error);
22368
+ if (slotName === "conversation.composer.dock") return void 0;
22369
+ return ctx.slots.register(dotEntry("conversation.composer.dock"), CreditDot);
22370
+ }
22371
+ };
22372
+ ctx.slots.inject("conversation.input.right", registerDot("conversation.input.right"));
21372
22373
  } catch (error) {
21373
22374
  console.error("[dsh-xdpool] composer credit dot unavailable (everything else unaffected):", error);
21374
22375
  }