dsh-xdpool 3.0.7 → 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",
@@ -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.7";
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;
@@ -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);
@@ -11250,7 +11610,7 @@ window.__ModuleLoader__.load({
11250
11610
  const isBusy = busy.has(channel.id);
11251
11611
  const unit = creditUnitLabel(channel, t);
11252
11612
  const chosenBalanceTotal = channel.credits === void 0 ? void 0 : balancesTotal(balances);
11253
- 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);
11254
11614
  const modelsEnabled = models.filter((model) => enabledIds.has(model.id)).length;
11255
11615
  const statusOf = (accountId) => statuses.find((row) => row.accountId === accountId);
11256
11616
  const balanceOf = (accountId) => balances.find((row) => row.accountId === accountId);
@@ -11844,12 +12204,13 @@ window.__ModuleLoader__.load({
11844
12204
  children: accounts.map((account, index) => {
11845
12205
  const shown = accountDisplay(account, channel.name, index);
11846
12206
  const balance = balanceOf(account.id);
11847
- const value = balance === void 0 ? void 0 : balanceAmount(balance.balance);
12207
+ const value = balance === void 0 ? account.credits?.total : balanceAmount(balance.balance);
11848
12208
  const checkin = statusOf(account.id);
11849
12209
  const buckets = balance === void 0 ? [] : balancePackages(balance.balance);
12210
+ const visibleBuckets = buckets.filter((b) => typeof b.remaining !== "number" || b.remaining > 0);
11850
12211
  const disabled = account.enabled === false;
11851
12212
  const soon = expiryText(account.expiresAt, t);
11852
- const pct = buckets[0]?.remaining;
12213
+ const pct = packagePercent(visibleBuckets[0]);
11853
12214
  return (0, react_jsx_runtime.jsxs)("article", {
11854
12215
  className: "acct",
11855
12216
  "data-off": disabled,
@@ -11918,7 +12279,7 @@ window.__ModuleLoader__.load({
11918
12279
  children: unit
11919
12280
  })] }) : (0, react_jsx_runtime.jsx)("span", {
11920
12281
  className: "acct-total-v",
11921
- children: chosenEntry.balancePending ? "…" : "—"
12282
+ children: chosenEntry.balancePending ? "…" : "0"
11922
12283
  }), soon === void 0 ? null : (0, react_jsx_runtime.jsx)("span", {
11923
12284
  className: "acct-soon",
11924
12285
  children: soon
@@ -11926,7 +12287,7 @@ window.__ModuleLoader__.load({
11926
12287
  }),
11927
12288
  pct === void 0 ? null : (0, react_jsx_runtime.jsx)("div", {
11928
12289
  className: "acct-bar",
11929
- title: buckets.map((b) => `${b.name} ${String(Math.round(b.remaining ?? 0))}%`).join(" · "),
12290
+ title: buckets.map((b) => `${b.name} ${packageDetailText(b)}`).join(" · "),
11930
12291
  children: (0, react_jsx_runtime.jsx)("span", { style: { width: `${String(Math.max(0, Math.min(100, Math.round(pct))))}%` } })
11931
12292
  }),
11932
12293
  (0, react_jsx_runtime.jsxs)("details", {
@@ -11935,13 +12296,9 @@ window.__ModuleLoader__.load({
11935
12296
  (0, react_jsx_runtime.jsx)("summary", { children: t?.("channelpool.accountDetail") ?? "积分明细" }),
11936
12297
  (0, react_jsx_runtime.jsxs)("dl", {
11937
12298
  className: "facts",
11938
- children: [buckets.map((b, i) => (0, react_jsx_runtime.jsxs)("div", {
12299
+ children: [visibleBuckets.map((b, i) => (0, react_jsx_runtime.jsxs)("div", {
11939
12300
  className: "fact",
11940
- 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: [
11941
- typeof b.remaining === "number" ? amount(Math.round(b.total * b.remaining / 100)) : typeof b.amount === "number" ? amount(b.amount) : "—",
11942
- " / ",
11943
- amount(b.total)
11944
- ] }) : 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) })]
11945
12302
  }, `${b.name}-${String(i)}`)), channel.credits?.status !== true && checkin === void 0 ? null : (0, react_jsx_runtime.jsxs)("div", {
11946
12303
  className: "fact",
11947
12304
  children: [(0, react_jsx_runtime.jsx)("dt", { children: t?.("channelpool.todayClaimed") ?? "今日签到" }), checkin?.todayCheckedIn === true ? (0, react_jsx_runtime.jsxs)("dd", {
@@ -12218,8 +12575,8 @@ window.__ModuleLoader__.load({
12218
12575
  const byKey = new Map();
12219
12576
  const order = [];
12220
12577
  for (const account of accounts) {
12221
- const nickname = (account.nickname ?? "").trim();
12222
- const key = nickname === "" ? `id:${account.id}` : `n:${nickname}`;
12578
+ (account.nickname ?? "").trim();
12579
+ const key = `id:${account.id}`;
12223
12580
  if (!byKey.has(key)) order.push(key);
12224
12581
  byKey.set(key, account);
12225
12582
  }
@@ -12251,6 +12608,7 @@ window.__ModuleLoader__.load({
12251
12608
  const [ui, setUi] = (0, react.useState)({});
12252
12609
  const [query, setQuery] = (0, react.useState)("");
12253
12610
  const [connected, setConnected] = (0, react.useState)([]);
12611
+ const [addedAt, setAddedAt] = (0, react.useState)(() => readChannelAddedAt());
12254
12612
  const [ownCounts, setOwnCounts] = (0, react.useState)({});
12255
12613
  const [active, setActive] = (0, react.useState)(void 0);
12256
12614
  const mounted = (0, react.useRef)(true);
@@ -12314,7 +12672,7 @@ window.__ModuleLoader__.load({
12314
12672
  const loadConnected = (0, react.useCallback)(async () => {
12315
12673
  const roster = await fetchChannels();
12316
12674
  const statuses = providerStatusesFrom(await callPack("provider.status", { providers: roster.map((channel) => channel.id) }));
12317
- 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);
12318
12676
  const accounts = [...(await Promise.all(connectedIds.map((id) => callPack("account.list", { provider: id })))).flatMap(accountsFrom), ...await loadPoolAccounts()];
12319
12677
  if (mounted.current) setConnected(accounts);
12320
12678
  return accounts;
@@ -12363,6 +12721,7 @@ window.__ModuleLoader__.load({
12363
12721
  timers.current.delete(channelId);
12364
12722
  }, []);
12365
12723
  const finishDone = (0, react.useCallback)((channelId, message) => {
12724
+ setAddedAt((prev) => rememberChannelAddedAt(prev, channelId, Date.now()));
12366
12725
  setUi((prev) => ({
12367
12726
  ...prev,
12368
12727
  [channelId]: {
@@ -12487,7 +12846,14 @@ window.__ModuleLoader__.load({
12487
12846
  fail(channel.id, "没有拿到登录页,可以再试一次。", "pack");
12488
12847
  return;
12489
12848
  }
12490
- 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");
12491
12857
  setUi((prev) => ({
12492
12858
  ...prev,
12493
12859
  [channel.id]: {
@@ -12495,6 +12861,7 @@ window.__ModuleLoader__.load({
12495
12861
  via: "pack",
12496
12862
  accountId: created.accountId,
12497
12863
  loginUrl: created.loginUrl,
12864
+ manualOpen: !autoOpen,
12498
12865
  startCount
12499
12866
  }
12500
12867
  }));
@@ -12606,6 +12973,15 @@ window.__ModuleLoader__.load({
12606
12973
  if (route === void 0) return;
12607
12974
  const value = (ui[channelId]?.paste ?? "").trim();
12608
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
+ }
12609
12985
  const token = bump(channelId);
12610
12986
  setUi((prev) => ({
12611
12987
  ...prev,
@@ -12645,8 +13021,12 @@ window.__ModuleLoader__.load({
12645
13021
  ]);
12646
13022
  const state = status?.state ?? "pending";
12647
13023
  const channels = (0, react.useMemo)(() => {
12648
- return (Array.isArray(status?.channels) ? status.channels : []).filter((c) => c !== null && typeof c === "object");
12649
- }, [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
+ ]);
12650
13030
  const connectedCount = (0, react.useMemo)(() => channels.filter((channel) => countFor(channel) > 0).length, [channels, countFor]);
12651
13031
  const filtered = (0, react.useMemo)(() => {
12652
13032
  const needle = query.trim().toLowerCase();
@@ -12790,10 +13170,10 @@ window.__ModuleLoader__.load({
12790
13170
  className: "banner-body",
12791
13171
  children: [(0, react_jsx_runtime.jsx)("span", {
12792
13172
  className: "banner-t",
12793
- children: activeUi.via === "pack" ? "已打开登录页,请在里面完成登录" : "已打开登录窗口,请在里面完成登录"
13173
+ children: activeUi.via === "pack" ? activeUi.manualOpen ? "请手动打开登录页并完成登录" : "已打开登录页,请在里面完成登录" : "已打开登录窗口,请在里面完成登录"
12794
13174
  }), (0, react_jsx_runtime.jsx)("span", {
12795
13175
  className: "banner-d",
12796
- children: activeUi.via === "pack" ? "登录页在新标签页里,10 分钟没完成就会取消。凭据只留在这台机器上。" : "窗口关掉或长时间没完成就会取消。凭据只留在这台机器上。"
13176
+ children: activeUi.via === "pack" ? activeUi.manualOpen ? "按设置没有自动打开登录页,点下面的「打开登录页」。10 分钟没完成就会取消。" : "登录页在新标签页里,10 分钟没完成就会取消。凭据只留在这台机器上。" : "窗口关掉或长时间没完成就会取消。凭据只留在这台机器上。"
12797
13177
  })]
12798
13178
  })]
12799
13179
  }),
@@ -12871,7 +13251,7 @@ window.__ModuleLoader__.load({
12871
13251
  href: activeUi.loginUrl,
12872
13252
  target: "_blank",
12873
13253
  rel: "noopener noreferrer",
12874
- children: "重新打开登录页"
13254
+ children: activeUi.manualOpen ? "打开登录页" : "重新打开登录页"
12875
13255
  }),
12876
13256
  (0, react_jsx_runtime.jsx)("button", {
12877
13257
  type: "button",
@@ -13378,6 +13758,7 @@ window.__ModuleLoader__.load({
13378
13758
  const RULE_COLUMNS = "minmax(0,1fr) minmax(0,1.3fr) 56px 60px 128px";
13379
13759
  function RoutingPage({ t }) {
13380
13760
  const [status, setStatus] = (0, react.useState)(void 0);
13761
+ const [groups, setGroups] = (0, react.useState)([]);
13381
13762
  const [error, setError] = (0, react.useState)(void 0);
13382
13763
  const [flash, setFlash] = (0, react.useState)(void 0);
13383
13764
  const [drafts, setDrafts] = (0, react.useState)([]);
@@ -13420,7 +13801,16 @@ window.__ModuleLoader__.load({
13420
13801
  } catch {
13421
13802
  if (signal?.aborted === true) return;
13422
13803
  if (mounted.current) setError(failed);
13804
+ return;
13423
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 {}
13424
13814
  }, []);
13425
13815
  (0, react.useEffect)(() => {
13426
13816
  const controller = new AbortController();
@@ -13603,6 +13993,97 @@ window.__ModuleLoader__.load({
13603
13993
  style: flash.ok ? void 0 : { color: "var(--danger)" },
13604
13994
  children: (0, react_jsx_runtime.jsx)("span", { children: flash.text })
13605
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,
13606
14087
  (0, react_jsx_runtime.jsxs)("section", {
13607
14088
  className: "sec",
13608
14089
  children: [(0, react_jsx_runtime.jsxs)("div", {
@@ -15288,6 +15769,13 @@ window.__ModuleLoader__.load({
15288
15769
  }
15289
15770
  //#endregion
15290
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
+ }
15291
15779
  const REGION_CHANNEL_BY_REGION = Object.freeze({
15292
15780
  cn: "buddy",
15293
15781
  global: "workbuddy"
@@ -16145,7 +16633,7 @@ window.__ModuleLoader__.load({
16145
16633
  function hoursOrDefault(configured, fallback) {
16146
16634
  return configured !== void 0 && configured.length > 0 ? [...configured] : [...fallback];
16147
16635
  }
16148
- const REGION_CARDS = ["cn", "global"];
16636
+ const REGION_CARDS = REGION_CARD_ORDER;
16149
16637
  function PoolCard({ t, settingsScope }) {
16150
16638
  const settingsWritable = settingsScope?.getSnapshot().writable === true;
16151
16639
  const [sidebarRow, setSidebarRowState] = (0, react.useState)(() => readSidebarRow(settingsScope));
@@ -16513,6 +17001,10 @@ window.__ModuleLoader__.load({
16513
17001
  t?.("row.title");
16514
17002
  t?.("row.desc");
16515
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
+ });
16516
17008
  return (0, react_jsx_runtime.jsx)(PoolShell, {
16517
17009
  t,
16518
17010
  version: POOL_VERSION,
@@ -16553,7 +17045,7 @@ window.__ModuleLoader__.load({
16553
17045
  style: { display: "contents" },
16554
17046
  children: (0, react_jsx_runtime.jsx)(ChannelPoolSection, {
16555
17047
  t,
16556
- regionCards: showPoolAccounts ? ["cn", "global"].map((region) => {
17048
+ regionCards: showPoolAccounts ? visibleRegions.map((region) => {
16557
17049
  const here = statusOf(region);
16558
17050
  const rows = here?.accounts ?? [];
16559
17051
  if (rows.length === 0) return null;
@@ -16614,8 +17106,86 @@ window.__ModuleLoader__.load({
16614
17106
  });
16615
17107
  }
16616
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
16617
17186
  //#region src/client/CreditDot.tsx
16618
17187
  const POLL_MS = 45e3;
17188
+ const RECOVERY_NOTICE_COOLDOWN_MS = 3e4;
16619
17189
  const POOL_STORE_KEY = "dsh-xdpool.pool-snapshot.v2";
16620
17190
  const MARVIS_DAILY_TOKENS = 1e7;
16621
17191
  const OWN_WALLET = new Set([
@@ -16943,10 +17513,79 @@ window.__ModuleLoader__.load({
16943
17513
  noStore: readStoredLanes().lanes.length === 0
16944
17514
  };
16945
17515
  }
16946
- 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;
16947
17581
  const [snapshot, setSnapshot] = (0, react.useState)(void 0);
17582
+ const [routeTrace, setRouteTrace] = (0, react.useState)(void 0);
16948
17583
  const [open, setOpen] = (0, react.useState)(false);
16949
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);
16950
17589
  const anchorRef = (0, react.useRef)(null);
16951
17590
  const panelRef = (0, react.useRef)(null);
16952
17591
  const [pos, setPos] = (0, react.useState)(void 0);
@@ -16954,6 +17593,10 @@ window.__ModuleLoader__.load({
16954
17593
  const rawRef = (0, react.useRef)(void 0);
16955
17594
  const liveRef = (0, react.useRef)(new Map());
16956
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);
16957
17600
  const recompose = (0, react.useCallback)(() => {
16958
17601
  const raw = rawRef.current;
16959
17602
  if (raw === void 0 || !mounted.current) return;
@@ -16965,6 +17608,12 @@ window.__ModuleLoader__.load({
16965
17608
  const poolMultiplier = typeof row?.["multiplier"] === "number" ? row["multiplier"] : void 0;
16966
17609
  const next = compose(raw, liveRef.current, caption, poolMultiplier);
16967
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
+ }
16968
17617
  const lane = next.channel;
16969
17618
  if (lane !== void 0 && lane.metered && !OWN_WALLET.has(lane.id) && Date.now() - (liveAtRef.current.get(lane.id) ?? 0) > POLL_MS) {
16970
17619
  liveAtRef.current.set(lane.id, Date.now());
@@ -16977,10 +17626,26 @@ window.__ModuleLoader__.load({
16977
17626
  }).catch(() => void 0);
16978
17627
  }
16979
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]);
16980
17644
  const load = (0, react.useCallback)(async () => {
16981
17645
  try {
16982
- const [statusRes, spendRes, usageRes] = await Promise.all([
16983
- 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),
16984
17649
  fetch(`${POOL_CREDITS_SPEND_PATH}?days=1`, { headers: { accept: "application/json" } }).catch(() => void 0),
16985
17650
  fetch(POOL_USAGE_PATH, {
16986
17651
  headers: { accept: "application/json" },
@@ -16988,7 +17653,25 @@ window.__ModuleLoader__.load({
16988
17653
  }).catch(() => void 0)
16989
17654
  ]);
16990
17655
  if (!mounted.current) return;
16991
- 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
+ }
16992
17675
  const activeChannels = new Set();
16993
17676
  const spendChannels = [];
16994
17677
  const spendRows = [];
@@ -17056,12 +17739,61 @@ window.__ModuleLoader__.load({
17056
17739
  spendRows,
17057
17740
  usage
17058
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
+ }
17059
17767
  recompose();
17060
17768
  setFailed(false);
17061
17769
  } catch {
17062
17770
  if (mounted.current) setFailed(true);
17063
17771
  }
17064
- }, [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]);
17065
17797
  (0, react.useEffect)(() => {
17066
17798
  mounted.current = true;
17067
17799
  load();
@@ -17073,6 +17805,15 @@ window.__ModuleLoader__.load({
17073
17805
  window.clearInterval(timer);
17074
17806
  };
17075
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]);
17076
17817
  (0, react.useEffect)(() => {
17077
17818
  if (open) load();
17078
17819
  }, [open, load]);
@@ -17166,6 +17907,14 @@ window.__ModuleLoader__.load({
17166
17907
  };
17167
17908
  }, [open]);
17168
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);
17169
17918
  const total = snapshot?.channel?.total ?? 0;
17170
17919
  const alive = ready && snapshot.channel !== void 0 && snapshot.channel.metered && total > 0;
17171
17920
  const unmetered = ready && snapshot.channel !== void 0 && !snapshot.channel.metered;
@@ -17177,101 +17926,261 @@ window.__ModuleLoader__.load({
17177
17926
  return (0, react_jsx_runtime.jsxs)("span", {
17178
17927
  className: "dsm-xdpool-dotwrap",
17179
17928
  style: { ["--xdpool-dot-mask"]: `url("${POOL_NAV_ICON_MASK_URL}")` },
17180
- children: [(0, react_jsx_runtime.jsx)("button", {
17181
- ref: anchorRef,
17182
- type: "button",
17183
- className: "dsm-xdpool-dot",
17184
- "data-state": state,
17185
- "aria-label": label,
17186
- "aria-expanded": open,
17187
- title: lane === void 0 ? label : `${lane.name} · ${lane.total === void 0 ? "—" : withUnit(lane.total, lane.unit)}`,
17188
- onClick: () => {
17189
- setOpen((current) => !current);
17190
- },
17191
- children: (0, react_jsx_runtime.jsx)("span", {
17192
- className: "dsm-xdpool-dot-glyph",
17193
- "aria-hidden": "true"
17194
- })
17195
- }), !open ? null : (0, react_dom.createPortal)((0, react_jsx_runtime.jsxs)("div", {
17196
- ref: panelRef,
17197
- className: "dsm-xdpool-dotpanel",
17198
- role: "dialog",
17199
- "aria-label": t?.("dot.panelTitle") ?? "本会话积分",
17200
- style: pos === void 0 ? { visibility: "hidden" } : {
17201
- top: `${String(pos.top)}px`,
17202
- left: `${String(pos.left)}px`
17203
- },
17204
- children: [!ready ? (0, react_jsx_runtime.jsx)("p", {
17205
- className: "dsm-xdpool-dotpanel-hint",
17206
- children: failed ? t?.("dot.loadFailed") ?? "积分数据读取失败" : t?.("dot.loading") ?? "正在读取积分…"
17207
- }) : null, !ready ? null : (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
17208
- (0, react_jsx_runtime.jsx)("div", {
17209
- className: "dsm-xdpool-dotpanel-head",
17210
- children: (0, react_jsx_runtime.jsx)("span", {
17211
- className: "dsm-xdpool-dotpanel-channel",
17212
- children: lane === void 0 ? t?.("dot.channelUnknown") ?? "没认出当前模型的渠道" : !lane.metered ? `${lane.name} · 不按积分计费` : `${lane.name} · ${lane.total === void 0 ? "—" : withUnit(lane.total, lane.unit)}`
17213
- })
17214
- }),
17215
- lane === void 0 || snapshot.why === "" ? null : (0, react_jsx_runtime.jsx)("span", {
17216
- className: "dsm-xdpool-dotpanel-k-sub",
17217
- children: `依据:${snapshot.why}`
17218
- }),
17219
- fill === void 0 || lane === void 0 || !lane.metered ? null : (0, react_jsx_runtime.jsx)("div", {
17220
- className: "dsm-xdpool-dotbar",
17221
- role: "img",
17222
- "aria-label": t?.("dot.barLabel") ?? "今日已用占比",
17223
- children: (0, react_jsx_runtime.jsx)("div", {
17224
- className: "dsm-xdpool-dotbar-fill",
17225
- "data-full": fill >= 90 ? "true" : "false",
17226
- style: { width: `${String(fill)}%` }
17227
- })
17228
- }),
17229
- (0, react_jsx_runtime.jsxs)("div", {
17230
- 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",
17231
17957
  children: [(0, react_jsx_runtime.jsx)("span", {
17232
17958
  className: "dsm-xdpool-dotpanel-k",
17233
- children: t?.("dot.spentToday") ?? "今日已用"
17234
- }), (0, react_jsx_runtime.jsx)("span", {
17235
- className: "dsm-xdpool-dotpanel-v",
17236
- 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" ? "国际版" : "国内版"}`]
17237
17963
  })]
17238
- }),
17239
- (0, react_jsx_runtime.jsxs)("div", {
17240
- className: "dsm-xdpool-dotpanel-sec",
17964
+ }), (0, react_jsx_runtime.jsxs)("span", {
17965
+ className: "dsm-xdpool-dotroute-line",
17241
17966
  children: [(0, react_jsx_runtime.jsx)("span", {
17242
17967
  className: "dsm-xdpool-dotpanel-k",
17243
- children: t?.("dot.model") ?? "模型"
17968
+ children: t?.("dot.sessionAccount") ?? "本会话账号"
17244
17969
  }), (0, react_jsx_runtime.jsxs)("span", {
17245
- className: "dsm-xdpool-dotpanel-v",
17246
- 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]
17247
17973
  })]
17248
- }),
17249
- (snapshot.all ?? []).length === 0 ? null : (0, react_jsx_runtime.jsxs)("div", {
17250
- className: "dsm-xdpool-dotpanel-more",
17251
- 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", {
17252
18020
  className: "dsm-xdpool-dotpanel-k-sub",
17253
- children: "同一模型的其他渠道"
17254
- }), (snapshot.all ?? []).map((other) => {
17255
- const used = snapshot.usedChannels.some((row) => row.id === other.id);
17256
- return (0, react_jsx_runtime.jsxs)("div", {
17257
- 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",
18056
+ children: [(0, react_jsx_runtime.jsx)("span", {
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",
17258
18077
  children: [(0, react_jsx_runtime.jsx)("span", {
17259
- className: "dsm-xdpool-dotpanel-rowname",
17260
- "data-used": used ? "true" : "false",
17261
- children: other.name
18078
+ className: "dsm-xdpool-dotpanel-k",
18079
+ children: t?.("dot.accountPinLabel") ?? "账号选择"
17262
18080
  }), (0, react_jsx_runtime.jsx)("span", {
17263
- className: "dsm-xdpool-dotpanel-rowval",
17264
- 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
+ })
17265
18097
  })]
17266
- }, other.id);
17267
- })]
17268
- }),
17269
- lane === void 0 && snapshot.noStore ? (0, react_jsx_runtime.jsx)("p", {
17270
- className: "dsm-xdpool-dotpanel-hint",
17271
- children: "打开一次 XD Pool 的账号池页面,这里就能认出登录渠道的模型和积分。"
17272
- }) : null
17273
- ] })]
17274
- }), 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
+ ]
17275
18184
  });
17276
18185
  }
17277
18186
  //#endregion
@@ -17432,7 +18341,7 @@ window.__ModuleLoader__.load({
17432
18341
  .app ::-webkit-scrollbar-thumb:hover { background: var(--line-3); background-clip: content-box; }
17433
18342
 
17434
18343
  @media (prefers-reduced-motion: reduce) {
17435
- * { transition-duration: 1ms !important; animation-duration: 1ms !important; }
18344
+ .app * { transition-duration: 1ms !important; animation-duration: 1ms !important; }
17436
18345
  }
17437
18346
 
17438
18347
  /*
@@ -19333,7 +20242,7 @@ window.__ModuleLoader__.load({
19333
20242
 
19334
20243
  /* 减少动效 */
19335
20244
  @media (prefers-reduced-motion:reduce){
19336
- *{transition-duration:1ms !important;animation-duration:1ms !important}
20245
+ .app *{transition-duration:1ms !important;animation-duration:1ms !important}
19337
20246
  }
19338
20247
 
19339
20248
 
@@ -19652,7 +20561,10 @@ label.sw:has(input:disabled) { opacity: .5; cursor: not-allowed }
19652
20561
  is the whole at-a-glance message — green while the serving channel has credits, grey
19653
20562
  once it does not — and the detail lives behind a click, because that row already
19654
20563
  holds a back button, a model name, a multiplier and a reasoning level. */
19655
- .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)}
19656
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}
19657
20569
  .dsm-xdpool-dot:hover{background:color-mix(in srgb, var(--dsw-alias-label-primary,#e8eaf0) 12%, transparent)}
19658
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}
@@ -19692,6 +20604,46 @@ label.sw:has(input:disabled) { opacity: .5; cursor: not-allowed }
19692
20604
  /* 认出渠道的依据、「同一模型的其他渠道」这种小字 */
19693
20605
  .dsm-xdpool-dotpanel-k-sub{display:block;font-size:11px;line-height:15px;color:var(--dsw-alias-label-tertiary,#8a90a0);margin-top:-3px}
19694
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}
19695
20647
  `;
19696
20648
  //#endregion
19697
20649
  //#region src/client/theme-css.ts
@@ -19739,7 +20691,7 @@ label.sw:has(input:disabled) { opacity: .5; cursor: not-allowed }
19739
20691
 
19740
20692
  /* ---- 状态色:暗色那套是给深底提亮的,白底上要压暗才读得清 ---- */
19741
20693
  --ok: #2E7D46; /* 5.1:1 */
19742
- --warn: #8A6410; /* 5.4:1 */
20694
+ --warn: #755309; /* 压暗到 #ECEADC 底上 ≥4.5:1(pill[data-tone=warn] 混色后) */
19743
20695
  --danger: #B23A26; /* 6.0:1 */
19744
20696
  --info: #2F6A9E; /* 5.7:1 */
19745
20697
 
@@ -20389,6 +21341,20 @@ label.sw:has(input:disabled) { opacity: .5; cursor: not-allowed }
20389
21341
  "dot.loadFailed": "Could not read the credit data",
20390
21342
  "dot.remaining": "Remaining",
20391
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}",
20392
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.",
20393
21359
  "gw.usage": "Using it",
20394
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.",
@@ -20652,8 +21618,8 @@ label.sw:has(input:disabled) { opacity: .5; cursor: not-allowed }
20652
21618
  "row.accountToggleError": "切换账号失败:{message}",
20653
21619
  "row.accountIgnore": "移出池子",
20654
21620
  "row.accountIgnoreHint": "把这个账号永久移出池子 —— 不再读取它的凭据,即使重新登录也不会回来",
20655
- "row.accountPrefer": "优先",
20656
- "row.accountPreferOn": "已优先",
21621
+ "row.accountPrefer": "优先用此账号",
21622
+ "row.accountPreferOn": "取消优先",
20657
21623
  "row.accountPreferHint": "优先使用这个账号 —— 它健康时先用它,不可用时自动回到你设定的分发策略",
20658
21624
  "row.accountPreferClearHint": "取消优先,改回按你设定的分发策略轮换",
20659
21625
  "row.accountPreferError": "设置优先账号失败:{message}",
@@ -21112,6 +22078,20 @@ label.sw:has(input:disabled) { opacity: .5; cursor: not-allowed }
21112
22078
  "dot.loadFailed": "积分数据读取失败",
21113
22079
  "dot.remaining": "剩余积分",
21114
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}",
21115
22095
  "gw.keyHint": "这把密钥在 DSH 重启后仍然有效。轮换会让所有还在用旧密钥的设备立刻断线。这里给的也不是账号池自己每进程生成的秘密 —— 客户端要是拿到它,DSH 下次一重启就全废了。",
21116
22096
  "gw.usage": "怎么用",
21117
22097
  "gw.usageHint": "任何 OpenAI 兼容的客户端都行:接口地址填上面那个入口,模型从 /v1/models 里挑,密钥填到这个 API 密钥的位置。中继只放行 /v1/models 和 /v1/chat/completions,其余路径在转发任何字节之前就拒掉。",
@@ -21374,12 +22354,22 @@ label.sw:has(input:disabled) { opacity: .5; cursor: not-allowed }
21374
22354
  console.error("[dsh-xdpool] sidebar entry unavailable (settings page unaffected):", error);
21375
22355
  }
21376
22356
  try {
21377
- ctx.slots.inject("conversation.composer.dock", () => ctx.slots.register({
21378
- name: "conversation.composer.dock",
22357
+ const dotEntry = (slotName) => ({
22358
+ name: slotName,
21379
22359
  id: "xdpool-credit-dot",
21380
22360
  order: 20,
21381
22361
  inject: () => t === void 0 ? {} : { t }
21382
- }, 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"));
21383
22373
  } catch (error) {
21384
22374
  console.error("[dsh-xdpool] composer credit dot unavailable (everything else unaffected):", error);
21385
22375
  }