heybash-xdpool 1.0.6 → 1.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
@@ -71,6 +71,22 @@ window.__ModuleLoader__.load({
71
71
  if (option === "expiry") return at?.("row.distExpiryHint") ?? "";
72
72
  return at?.("row.distRoundRobinHint") ?? "";
73
73
  }
74
+ // src/client/automation-note.ts
75
+ /** Localize known scheduler reasons; preserve upstream error details verbatim. */
76
+ function automationNote(note, t) {
77
+ const key = {
78
+ "not covered by automation": "row.autoNote.uncovered",
79
+ "automatic completion failed": "row.autoNote.failed",
80
+ "not scored yet": "row.autoNote.unscored",
81
+ "not accepted": "row.autoNote.notAccepted",
82
+ locked: "row.autoNote.locked"
83
+ }[note];
84
+ return key === void 0 ? note : t?.(key) ?? note;
85
+ }
86
+ /** Show unsupported tasks separately from supported tasks awaiting scoring. */
87
+ function automationGroup(item) {
88
+ return item.status === "skipped" && item.note === "not covered by automation" ? "uncovered" : item.status;
89
+ }
74
90
  // src/status-paths.ts
75
91
  /**
76
92
  * Node-free constants and types shared by the Host and browser halves of the
@@ -209,6 +225,29 @@ window.__ModuleLoader__.load({
209
225
  */
210
226
  const POOL_CHANNELS_PATH = "/plugins/dsh-xdpool/channels";
211
227
  /**
228
+ * The Doubao lane's session.
229
+ *
230
+ * POST starts an interactive browser sign-in and answers once it lands;
231
+ * GET reports whether a session is stored; DELETE forgets it.
232
+ */
233
+ const POOL_DOUBAO_SESSION_PATH = "/plugins/dsh-xdpool/doubao/session";
234
+ /** The Doubao quota: the windows the account has, with their reset countdowns. */
235
+ const POOL_DOUBAO_QUOTA_PATH = "/plugins/dsh-xdpool/doubao/quota";
236
+ /**
237
+ * The `reason` the channel document carries when the login-channel route is
238
+ * already owned by another plugin.
239
+ *
240
+ * The pack we vendor is byte-identical to the one the sibling login-channel
241
+ * build mounts, and both claim the same fetch route; the host has no query for
242
+ * what is already registered, so the loser of that race can only tell it lost.
243
+ * Both halves need the same string — the host to say it, the card to choose
244
+ * between "this host cannot run the channels" and "another plugin already runs
245
+ * them", which are opposite sentences — so it is declared with the other wire
246
+ * constants rather than in `channels.ts`, which the browser bundle may not
247
+ * import for value.
248
+ */
249
+ const ROUTE_OWNED_ELSEWHERE = "already-mounted-elsewhere";
250
+ /**
212
251
  * The routing chains, and the whole model roster a member may name.
213
252
  *
214
253
  * One route for both because the editor cannot be drawn without the roster: a
@@ -2237,8 +2276,11 @@ window.__ModuleLoader__.load({
2237
2276
  (0, react.useEffect)(() => {
2238
2277
  if (shared !== void 0) setOwn(shared);
2239
2278
  }, [shared]);
2240
- (0, react.useEffect)(() => () => {
2241
- mounted.current = false;
2279
+ (0, react.useEffect)(() => {
2280
+ mounted.current = true;
2281
+ return () => {
2282
+ mounted.current = false;
2283
+ };
2242
2284
  }, []);
2243
2285
  /**
2244
2286
  * Poll only while this page is mounted.
@@ -2666,7 +2708,16 @@ window.__ModuleLoader__.load({
2666
2708
  * "TRAE" a bare "T", which looks sparse at 40px. CamelCase splitting resolves
2667
2709
  * both: LobsterAI -> LA, Loomy -> L, TRAE -> TR, MiniMax Code -> MM.
2668
2710
  */
2711
+ /**
2712
+ * Initials for a name the generic rule cannot letter.
2713
+ *
2714
+ * A Chinese display name has no ASCII letters to take, so the rule below returns an empty
2715
+ * mark — a channel with a blank tile. Doubao is the first such name.
2716
+ */
2717
+ const INITIALS_BY_NAME = { 豆包: "DB" };
2669
2718
  function channelInitials(name) {
2719
+ const fixed = INITIALS_BY_NAME[name.trim()];
2720
+ if (fixed !== void 0) return fixed;
2670
2721
  const segments = name.split(/\s+/u).flatMap((word) => word.replace(/([a-z0-9])([A-Z])/gu, "$1 $2").split(" ")).map((segment) => [...segment].filter((character) => /[0-9A-Za-z]/u.test(character)).join("")).filter((segment) => segment !== "");
2671
2722
  if (segments.length >= 2) return (([...segments[0] ?? ""][0] ?? "") + ([...segments[1] ?? ""][0] ?? "")).toUpperCase();
2672
2723
  return [...segments[0] ?? ""].slice(0, 2).join("").toUpperCase();
@@ -8230,8 +8281,11 @@ window.__ModuleLoader__.load({
8230
8281
  /** The pair currently being measured, so only one button shows a spinner. */
8231
8282
  const [probing, setProbing] = (0, react.useState)(void 0);
8232
8283
  const mounted = (0, react.useRef)(true);
8233
- (0, react.useEffect)(() => () => {
8234
- mounted.current = false;
8284
+ (0, react.useEffect)(() => {
8285
+ mounted.current = true;
8286
+ return () => {
8287
+ mounted.current = false;
8288
+ };
8235
8289
  }, []);
8236
8290
  /**
8237
8291
  * Ask the host to run one real request against a model, and keep the reading.
@@ -9762,10 +9816,13 @@ window.__ModuleLoader__.load({
9762
9816
  const mounted = (0, react.useRef)(true);
9763
9817
  /** Timers for in-flight logins, keyed by channel id. */
9764
9818
  const timers = (0, react.useRef)(/* @__PURE__ */ new Map());
9765
- (0, react.useEffect)(() => () => {
9766
- mounted.current = false;
9767
- for (const handle of timers.current.values()) window.clearInterval(handle);
9768
- timers.current.clear();
9819
+ (0, react.useEffect)(() => {
9820
+ mounted.current = true;
9821
+ return () => {
9822
+ mounted.current = false;
9823
+ for (const handle of timers.current.values()) window.clearInterval(handle);
9824
+ timers.current.clear();
9825
+ };
9769
9826
  }, []);
9770
9827
  const load = (0, react.useCallback)(async (signal) => {
9771
9828
  try {
@@ -9992,7 +10049,7 @@ window.__ModuleLoader__.load({
9992
10049
  }
9993
10050
  }, [autoCheckin]);
9994
10051
  const state = status?.state ?? "pending";
9995
- const channels = status?.channels ?? [];
10052
+ const channels = (status?.channels ?? []).filter((channel) => channel.id !== "doubao");
9996
10053
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
9997
10054
  className: "dsm-xdpool-channels",
9998
10055
  children: [
@@ -10048,6 +10105,16 @@ window.__ModuleLoader__.load({
10048
10105
  t,
10049
10106
  ui: ui[channel.id] ?? IDLE,
10050
10107
  connectedCount: connectedFor(channel).length,
10108
+ /**
10109
+ * When the pack is mounted ELSEWHERE, this page cannot log anybody in.
10110
+ *
10111
+ * `account.create` is answered by the pack, and the pack that owns it lives in
10112
+ * another plugin — so pressing the button produced the host's "not supported"
10113
+ * line for a channel that works perfectly well, on a page the user was told to
10114
+ * use. The row says where the sign-in actually is instead of offering a button
10115
+ * that cannot work.
10116
+ */
10117
+ ownedElsewhere: status?.reason === ROUTE_OWNED_ELSEWHERE,
10051
10118
  onSignIn: () => {
10052
10119
  signIn(channel);
10053
10120
  },
@@ -10056,7 +10123,7 @@ window.__ModuleLoader__.load({
10056
10123
  ]
10057
10124
  });
10058
10125
  }
10059
- function ChannelRow({ channel, t, ui, connectedCount, onSignIn, onCancel }) {
10126
+ function ChannelRow({ channel, t, ui, connectedCount, onSignIn, onCancel, ownedElsewhere }) {
10060
10127
  const busy = ui.phase === "signing-in";
10061
10128
  const icon = channelIcon(channel.id);
10062
10129
  const tileMark = icon === void 0 ? { initials: channelInitials(channel.name) } : { icon };
@@ -10111,7 +10178,10 @@ window.__ModuleLoader__.load({
10111
10178
  children: t?.("agg.clear") ?? "Cancel"
10112
10179
  })
10113
10180
  ] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
10114
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
10181
+ ownedElsewhere === true ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10182
+ className: "dsm-xdpool-channel-hint",
10183
+ children: t?.("chan.ownedElsewhereRow") ?? "在「我们的免费模型」里登录"
10184
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
10115
10185
  type: "button",
10116
10186
  className: "dsm-xdpool-btn",
10117
10187
  onClick: onSignIn,
@@ -10262,8 +10332,11 @@ window.__ModuleLoader__.load({
10262
10332
  /** True once the drafts were seeded from the server, so later polls don't stomp edits. */
10263
10333
  const seeded = (0, react.useRef)(false);
10264
10334
  const mounted = (0, react.useRef)(true);
10265
- (0, react.useEffect)(() => () => {
10266
- mounted.current = false;
10335
+ (0, react.useEffect)(() => {
10336
+ mounted.current = true;
10337
+ return () => {
10338
+ mounted.current = false;
10339
+ };
10267
10340
  }, []);
10268
10341
  const load = (0, react.useCallback)(async (signal) => {
10269
10342
  try {
@@ -11078,8 +11151,11 @@ window.__ModuleLoader__.load({
11078
11151
  /** True once the server's values were adopted, so polls do not stomp edits. */
11079
11152
  const seeded = (0, react.useRef)(false);
11080
11153
  const mounted = (0, react.useRef)(true);
11081
- (0, react.useEffect)(() => () => {
11082
- mounted.current = false;
11154
+ (0, react.useEffect)(() => {
11155
+ mounted.current = true;
11156
+ return () => {
11157
+ mounted.current = false;
11158
+ };
11083
11159
  }, []);
11084
11160
  const load = (0, react.useCallback)(async (signal) => {
11085
11161
  try {
@@ -11531,6 +11607,265 @@ window.__ModuleLoader__.load({
11531
11607
  ]
11532
11608
  });
11533
11609
  }
11610
+ // src/client/doubao-work-icon.ts
11611
+ /** Artwork from the installed Doubao Work desktop application. */
11612
+ const DOUBAO_WORK_ICON = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAQKADAAQAAAABAAAAQAAAAACU3PoRAAAACXBIWXMAABYlAAAWJQFJUiTwAAACnmlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9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uSLU2vX/ND75x4cMTMfjHAFC5q2py1e2hcOibGkBfeEso1qApfX9DS+8y7k1a4Kbv1sHouYvmYClj+5WLF6C4jB8/aBORO8EpMt3bsh8DAwM862tEDz+RSXF3qHIyvyvYtRfHK89DcUWdsTNiUB9HGubTzBnGWSBGVc7/xpgaxg2nEoSH3xO13fXt65brU1ktBVVt3KR454+l1NDw0B8CeQEv1X6Zy+m0+Xk+7yLTDgb9Pm71Sgs0FThVMErJ3XD5Gtxy0w08EKkxn8clgkOI9fdgtLsDQa4cC3jOd7D1KLZueQWLFp2FY/yM3sV4PxjnXwLUn20kbZgj2Wb9TwotiWcYp2YwT1wZIFSZSRsznA6p7hNH/43M38osqmF25tXmTwKA9RL8zP1Vn8/fkpvrnxuOhAuDoRC1wQqKRqnGGRDku6+/aBXqGPWFB3oRHuxDL/cBd773Lh576hk8/fJmNLc0YdWypegfiWDrG69jQeMsNB3cB1ftUozk1Rg7I4bj5F68ZcAwKs53sWs9y2/I2rvM1IuEg83Hjhz855u/uvrHrMLIyuDEW/b0pwCg1hozGQyO7AyGgk/RuHU5XI583gtoD1zWvNRcZEDEiVqR50ao7wT6eKjROZzAzpZOvPj+EbSOcu4EKnCYf9vR2j2ClUuW4pl9nZhaXYOdnaMINK6EK6/U2BMbtUvHZbrsfDaXpp/yeZeFlwWLxxPBaCS8iyDf8+yz9377/h/90xbSmo7IRPrEiV382UltBAj/ziG/nl9yTqU9KOblUkwkK1xN327n/v68lZfjrNUXcz7z46gcD8NhD6Vled5RfgaLZITr/gCX1SH6a1FtRyCXO8QEUQaPXZngKvMsSuWNOBY/NnfyTwyCPSeOtzStu/PGZhb188rQpqp/9fSXgPfXIur/Ei1/LR7P9HsGgTMInEHgfx+B/wLm3zGy2Haa+AAAAABJRU5ErkJggg==";
11613
+ // src/client/DoubaoPage.tsx
11614
+ /**
11615
+ * The Doubao card: sign in, then read the quota.
11616
+ *
11617
+ * WHAT THIS SURFACE IS FOR
11618
+ *
11619
+ * Doubao's models already appear in the picker (the channel lane serves them), so this card
11620
+ * is not a second model list. It is the two things that have no other home:
11621
+ *
11622
+ * - the SIGN-IN, because Doubao's QR entrance is closed and the only door left is a
11623
+ * browser window this plugin starts;
11624
+ * - the QUOTA, because Doubao reports promotional windows with reset countdowns and
11625
+ * nothing else in the plugin knows how to read them.
11626
+ *
11627
+ * THE COPY SAYS WHAT ACTUALLY HAPPENS
11628
+ *
11629
+ * The button opens a Chromium window and waits. A user who is told "sign in" and sees a blank
11630
+ * panel for a minute concludes the feature is broken, so the waiting states name the step
11631
+ * they are on and the window stays open for the whole budget.
11632
+ *
11633
+ * @module dsh-xdpool/client/DoubaoPage
11634
+ */
11635
+ /** How the card describes one window. */
11636
+ function windowLabel(window) {
11637
+ if (typeof window.label === "string" && window.label !== "") return window.label;
11638
+ if (window.type === "five_hour") return "5 小时限额";
11639
+ if (window.type === "weekly") return "周额度";
11640
+ if (window.type === "incentive") return "活动赠送额度";
11641
+ return "额度";
11642
+ }
11643
+ /** A countdown, or a plain statement when the window has no reset. */
11644
+ function resetText(window) {
11645
+ if (window.resetUnknown === true || window.resetsAt === void 0 || window.resetsAt <= 0) return "用后开始计算";
11646
+ const left = window.resetsAt - Date.now();
11647
+ if (left <= 0) return "已重置";
11648
+ const hours = Math.floor(left / 36e5);
11649
+ const days = Math.floor(hours / 24);
11650
+ if (days > 0) return `${String(days)} 天 ${String(hours % 24)} 小时后重置`;
11651
+ const minutes = Math.floor(left % 36e5 / 6e4);
11652
+ return `${String(hours)} 小时 ${String(minutes)} 分后重置`;
11653
+ }
11654
+ function DoubaoPage({ t }) {
11655
+ const [signedIn, setSignedIn] = (0, react.useState)(false);
11656
+ const [busy, setBusy] = (0, react.useState)(false);
11657
+ const [message, setMessage] = (0, react.useState)(void 0);
11658
+ const [error, setError] = (0, react.useState)(void 0);
11659
+ const [windows, setWindows] = (0, react.useState)([]);
11660
+ const [exhausted, setExhausted] = (0, react.useState)(false);
11661
+ const mounted = (0, react.useRef)(true);
11662
+ const poll = (0, react.useRef)(void 0);
11663
+ (0, react.useEffect)(() => {
11664
+ mounted.current = true;
11665
+ return () => {
11666
+ mounted.current = false;
11667
+ if (poll.current !== void 0) window.clearTimeout(poll.current);
11668
+ };
11669
+ }, []);
11670
+ /** Read the session and, when there is one, the quota. */
11671
+ const load = (0, react.useCallback)(async () => {
11672
+ try {
11673
+ const body = await (await fetch(POOL_DOUBAO_SESSION_PATH, { credentials: "same-origin" })).json().catch(() => void 0);
11674
+ if (!mounted.current) return;
11675
+ const signed = body?.signedIn === true;
11676
+ setSignedIn(signed);
11677
+ if (!signed) {
11678
+ setWindows([]);
11679
+ return;
11680
+ }
11681
+ const quota = await (await fetch(POOL_DOUBAO_QUOTA_PATH, { credentials: "same-origin" })).json().catch(() => void 0);
11682
+ if (!mounted.current) return;
11683
+ setWindows(Array.isArray(quota?.windows) ? quota.windows : []);
11684
+ setExhausted(quota?.exhausted === true);
11685
+ if (typeof quota?.error === "string" && quota.error !== "") setError(quota.error);
11686
+ } catch (cause) {
11687
+ if (mounted.current) setError(cause instanceof Error ? cause.message : String(cause));
11688
+ }
11689
+ }, []);
11690
+ /** Open the sign-in browser and wait for it. */
11691
+ const signIn = (0, react.useCallback)(async () => {
11692
+ setError(void 0);
11693
+ setMessage("已打开浏览器,请在弹出的窗口里扫码或短信登录…");
11694
+ setBusy(true);
11695
+ try {
11696
+ const body = await (await fetch(POOL_DOUBAO_SESSION_PATH, {
11697
+ method: "POST",
11698
+ credentials: "same-origin"
11699
+ })).json().catch(() => void 0);
11700
+ if (!mounted.current) return;
11701
+ if (body?.signedIn === true) {
11702
+ setMessage(body.message ?? "登录成功");
11703
+ load();
11704
+ return;
11705
+ }
11706
+ setMessage(body?.message ?? "没有等到登录完成,可以再试一次");
11707
+ } catch (cause) {
11708
+ if (mounted.current) setError(cause instanceof Error ? cause.message : String(cause));
11709
+ } finally {
11710
+ if (mounted.current) setBusy(false);
11711
+ }
11712
+ }, [load]);
11713
+ /** Forget the session. */
11714
+ const signOut = (0, react.useCallback)(async () => {
11715
+ setError(void 0);
11716
+ setMessage(void 0);
11717
+ setBusy(true);
11718
+ try {
11719
+ await fetch(POOL_DOUBAO_SESSION_PATH, {
11720
+ method: "DELETE",
11721
+ credentials: "same-origin"
11722
+ });
11723
+ if (!mounted.current) return;
11724
+ setSignedIn(false);
11725
+ setWindows([]);
11726
+ setMessage("已退出登录");
11727
+ } catch (cause) {
11728
+ if (mounted.current) setError(cause instanceof Error ? cause.message : String(cause));
11729
+ } finally {
11730
+ if (mounted.current) setBusy(false);
11731
+ }
11732
+ }, []);
11733
+ (0, react.useEffect)(() => {
11734
+ load();
11735
+ }, [load]);
11736
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
11737
+ className: "dsm-xdpool-doubao",
11738
+ children: [
11739
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("style", { children: DOUBAO_CSS }),
11740
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
11741
+ className: "dsm-xdpool-doubao-head",
11742
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
11743
+ className: "dsm-xdpool-doubao-id",
11744
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
11745
+ className: "dsm-xdpool-doubao-mark",
11746
+ src: DOUBAO_WORK_ICON,
11747
+ alt: ""
11748
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
11749
+ className: "dsm-xdpool-doubao-title",
11750
+ children: "豆包 · 字节跳动"
11751
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
11752
+ className: "dsm-xdpool-doubao-sub",
11753
+ children: signedIn ? t?.("doubao.ready") ?? "已登录,会话保存在本机" : t?.("doubao.sub") ?? "浏览器登录后使用豆包直接对话模型"
11754
+ })] })]
11755
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
11756
+ className: "dsm-xdpool-doubao-acts",
11757
+ children: signedIn ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
11758
+ type: "button",
11759
+ className: "dsm-xdpool-doubao-btn",
11760
+ disabled: busy,
11761
+ onClick: () => {
11762
+ load();
11763
+ },
11764
+ children: t?.("doubao.refresh") ?? "刷新额度"
11765
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
11766
+ type: "button",
11767
+ className: "dsm-xdpool-doubao-btn",
11768
+ disabled: busy,
11769
+ onClick: () => {
11770
+ signOut();
11771
+ },
11772
+ children: t?.("doubao.signOut") ?? "退出登录"
11773
+ })] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
11774
+ type: "button",
11775
+ className: "dsm-xdpool-doubao-btn",
11776
+ "data-tone": "primary",
11777
+ disabled: busy,
11778
+ onClick: () => {
11779
+ signIn();
11780
+ },
11781
+ children: busy ? t?.("doubao.waiting") ?? "等待登录…" : t?.("doubao.signIn") ?? "扫码登录"
11782
+ })
11783
+ })]
11784
+ }),
11785
+ message === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
11786
+ className: "dsm-xdpool-doubao-note",
11787
+ children: message
11788
+ }),
11789
+ error === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
11790
+ className: "dsm-xdpool-doubao-error",
11791
+ children: error
11792
+ }),
11793
+ signedIn ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
11794
+ exhausted ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
11795
+ className: "dsm-xdpool-doubao-error",
11796
+ children: "额度已用完,等待窗口重置。"
11797
+ }) : null,
11798
+ windows.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
11799
+ className: "dsm-xdpool-doubao-hint",
11800
+ children: "这个账号暂时没有可显示的额度窗口。"
11801
+ }) : windows.map((window, index) => {
11802
+ const percent = typeof window.usedPercent === "number" ? window.usedPercent : 0;
11803
+ const used = typeof window.usedAmount === "number" ? window.usedAmount : void 0;
11804
+ const total = typeof window.totalAmount === "number" ? window.totalAmount : void 0;
11805
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
11806
+ className: "dsm-xdpool-doubao-window",
11807
+ children: [
11808
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
11809
+ className: "dsm-xdpool-doubao-window-head",
11810
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
11811
+ className: "dsm-xdpool-doubao-window-name",
11812
+ children: windowLabel(window)
11813
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
11814
+ className: "dsm-xdpool-doubao-window-reset",
11815
+ children: resetText(window)
11816
+ })]
11817
+ }),
11818
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
11819
+ className: "dsm-xdpool-doubao-bar",
11820
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
11821
+ className: "dsm-xdpool-doubao-bar-fill",
11822
+ "data-exhausted": percent >= 100 ? "true" : "false",
11823
+ style: { width: `${String(Math.min(100, Math.max(0, percent)))}%` }
11824
+ })
11825
+ }),
11826
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
11827
+ className: "dsm-xdpool-doubao-window-foot",
11828
+ children: used === void 0 || total === void 0 ? `已用 ${String(Math.round(percent))}%` : `已用 ${String(used)} / ${String(total)}`
11829
+ })
11830
+ ]
11831
+ }, `${window.type ?? "w"}-${String(index)}`);
11832
+ }),
11833
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
11834
+ className: "dsm-xdpool-doubao-hint",
11835
+ children: t?.("doubao.modelsNote") ?? "模型在对话的模型选择器里:豆包 快速 / 2.1 Turbo。"
11836
+ })
11837
+ ] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
11838
+ className: "dsm-xdpool-doubao-hint",
11839
+ children: t?.("doubao.why") ?? "豆包已关闭第三方扫码入口(服务端返回 2035),所以这里拉起一个浏览器窗口:在窗口里扫码或填手机号,登录成功后会话自动取回并保存在本机。"
11840
+ })
11841
+ ]
11842
+ });
11843
+ }
11844
+ /** The card's own stylesheet, travelling with the component. */
11845
+ const DOUBAO_CSS = `
11846
+ .dsm-xdpool-doubao{display:flex;flex-direction:column;gap:11px;padding:14px 16px 16px;border-radius:14px;border:1px solid color-mix(in srgb, var(--dsw-alias-border-l2,#ffffff1f) 82%, transparent);background:color-mix(in srgb, var(--dsw-alias-bg-layer-2,#1c1e22) 70%, transparent)}
11847
+ .dsm-xdpool-doubao-head{display:flex;align-items:flex-start;gap:12px;flex-wrap:wrap}
11848
+ .dsm-xdpool-doubao-id{display:flex;align-items:center;gap:10px;min-width:0}
11849
+ .dsm-xdpool-doubao-mark{width:34px;height:34px;border-radius:9px;display:grid;place-items:center;font-size:12px;font-weight:700;letter-spacing:.02em;color:#fff;background:linear-gradient(135deg,#4B7BF5,#2E5BD8);flex:none}
11850
+ .dsm-xdpool-doubao-title{font-size:13.5px;font-weight:650;color:var(--dsw-alias-label-primary,#e8eaf0)}
11851
+ .dsm-xdpool-doubao-sub{margin-top:2px;font-size:11px;line-height:16px;color:var(--dsw-alias-label-tertiary,#8a90a0)}
11852
+ .dsm-xdpool-doubao-acts{margin-left:auto;display:flex;gap:8px;flex:none}
11853
+ .dsm-xdpool-doubao-btn{appearance:none;-webkit-appearance:none;padding:5px 13px;border-radius:8px;cursor:pointer;font:inherit;font-size:12px;line-height:18px;border:1px solid color-mix(in srgb, var(--dsw-alias-border-l2,#ffffff1f) 95%, transparent);background:transparent;color:var(--dsw-alias-label-secondary,#b9bfcc);white-space:nowrap}
11854
+ .dsm-xdpool-doubao-btn:hover:not(:disabled){border-color:color-mix(in srgb, #3B6FD4 55%, transparent);color:var(--dsw-alias-label-primary,#e8eaf0)}
11855
+ .dsm-xdpool-doubao-btn:disabled{opacity:.5;cursor:not-allowed}
11856
+ .dsm-xdpool-doubao-btn[data-tone='primary']{border-color:color-mix(in srgb, #3B6FD4 62%, transparent);background:color-mix(in srgb, #3B6FD4 16%, transparent);color:#6E9AF0;font-weight:600}
11857
+ .dsm-xdpool-doubao-note{margin:0;font-size:11.5px;line-height:17px;color:var(--dsw-alias-state-success-primary,#22a06b)}
11858
+ .dsm-xdpool-doubao-error{margin:0;font-size:11.5px;line-height:17px;color:var(--dsw-alias-state-error-primary,#e5534b)}
11859
+ .dsm-xdpool-doubao-hint{margin:0;font-size:11px;line-height:16px;color:var(--dsw-alias-label-tertiary,#8a90a0)}
11860
+ .dsm-xdpool-doubao-window{display:flex;flex-direction:column;gap:6px;padding:10px 12px;border-radius:10px;background:color-mix(in srgb, #3B6FD4 8%, transparent);border:1px solid color-mix(in srgb, #3B6FD4 24%, transparent)}
11861
+ .dsm-xdpool-doubao-window-head{display:flex;align-items:baseline;gap:10px}
11862
+ .dsm-xdpool-doubao-window-name{font-size:12px;font-weight:600;color:var(--dsw-alias-label-primary,#e8eaf0)}
11863
+ .dsm-xdpool-doubao-window-reset{margin-left:auto;font-size:10.5px;color:var(--dsw-alias-label-tertiary,#8a90a0)}
11864
+ .dsm-xdpool-doubao-bar{height:6px;border-radius:999px;background:color-mix(in srgb, var(--dsw-alias-label-primary,#e8eaf0) 10%, transparent);overflow:hidden}
11865
+ .dsm-xdpool-doubao-bar-fill{display:block;height:100%;border-radius:999px;background:#3B6FD4;transition:width .2s ease}
11866
+ .dsm-xdpool-doubao-bar-fill[data-exhausted='true']{background:#e5534b}
11867
+ .dsm-xdpool-doubao-window-foot{font-size:10.5px;color:var(--dsw-alias-label-secondary,#b9bfcc);font-variant-numeric:tabular-nums}
11868
+ `;
11534
11869
  // src/client/region-card.tsx
11535
11870
  /**
11536
11871
  * Which login channel each lane IS.
@@ -11905,6 +12240,13 @@ window.__ModuleLoader__.load({
11905
12240
  *
11906
12241
  * @module dsh-xdpool/client/ChannelPoolSection
11907
12242
  */
12243
+ const doubaoListing = () => [{
12244
+ id: "0",
12245
+ name: "豆包 快速"
12246
+ }, {
12247
+ id: "3",
12248
+ name: "豆包 2.1 Turbo"
12249
+ }];
11908
12250
  let poolSnapshot;
11909
12251
  /**
11910
12252
  * `provider.status` answered recently, kept across unmounts.
@@ -11999,6 +12341,57 @@ window.__ModuleLoader__.load({
11999
12341
  * moment a login lands), so the newest entry wins: it is the one whose
12000
12342
  * credential was written last.
12001
12343
  */
12344
+ /**
12345
+ * Doubao's account, described in the pack's account shape.
12346
+ *
12347
+ * The lane is the plugin's own, so this reads its session route and translates the answer
12348
+ * into the row the rest of this page already knows how to draw. `undefined` means "no
12349
+ * session", which is the ordinary state before a sign-in.
12350
+ */
12351
+ async function readDoubaoAccount() {
12352
+ try {
12353
+ const body = await (await fetch(POOL_DOUBAO_SESSION_PATH, { credentials: "same-origin" })).json().catch(() => void 0);
12354
+ if (body?.signedIn !== true) return void 0;
12355
+ return {
12356
+ id: "doubao:session",
12357
+ provider: "doubao",
12358
+ nickname: body.savedAt === void 0 ? "豆包账号" : `豆包(${String(body.savedAt).slice(0, 10)} 登录)`,
12359
+ enabled: true
12360
+ };
12361
+ } catch {
12362
+ return;
12363
+ }
12364
+ }
12365
+ /**
12366
+ * Doubao's quota, in the pack's balance row shape.
12367
+ *
12368
+ * The card prints one number per account, so it is the NARROWEST window: that is the one
12369
+ * that stops the next request, and reporting the widest would overstate what is left.
12370
+ */
12371
+ async function readDoubaoBalance() {
12372
+ try {
12373
+ const body = await (await fetch(POOL_DOUBAO_QUOTA_PATH, { credentials: "same-origin" })).json().catch(() => void 0);
12374
+ if (body?.signedIn !== true) return [];
12375
+ const windows = Array.isArray(body.windows) ? body.windows : [];
12376
+ if (windows.length === 0) return [{
12377
+ accountId: "doubao:session",
12378
+ nickname: "豆包账号",
12379
+ ...typeof body.error === "string" && body.error !== "" ? { error: body.error } : {}
12380
+ }];
12381
+ const lowest = windows.reduce((low, window) => {
12382
+ const used = typeof window.usedPercent === "number" ? window.usedPercent : 0;
12383
+ return Math.min(low, Math.max(0, 100 - used));
12384
+ }, 100);
12385
+ return [{
12386
+ accountId: "doubao:session",
12387
+ nickname: "豆包账号",
12388
+ balance: Math.round(lowest),
12389
+ extra: { unit: "%" }
12390
+ }];
12391
+ } catch {
12392
+ return [];
12393
+ }
12394
+ }
12002
12395
  function dedupeAccounts(accounts) {
12003
12396
  const byNickname = /* @__PURE__ */ new Map();
12004
12397
  const order = [];
@@ -12097,8 +12490,11 @@ window.__ModuleLoader__.load({
12097
12490
  * from painting over a newer wave-1 one.
12098
12491
  */
12099
12492
  const loadSeq = (0, react.useRef)(0);
12100
- (0, react.useEffect)(() => () => {
12101
- mountedRef.current = false;
12493
+ (0, react.useEffect)(() => {
12494
+ mountedRef.current = true;
12495
+ return () => {
12496
+ mountedRef.current = false;
12497
+ };
12102
12498
  }, []);
12103
12499
  const markBusy = (provider, on) => {
12104
12500
  setBusy((previous) => {
@@ -12111,14 +12507,41 @@ window.__ModuleLoader__.load({
12111
12507
  const load = async () => {
12112
12508
  loadSeq.current += 1;
12113
12509
  try {
12114
- const channels = (await fetchChannels()).filter((channel) => !REGION_OWNED_CHANNELS.has(channel.id));
12510
+ const channels = (await fetchChannels()).filter((channel) => !REGION_OWNED_CHANNELS.has(channel.id) && channel.id !== "doubao");
12115
12511
  const statusAnswer = await cachedProviderStatus(channels.map((channel) => channel.id));
12116
12512
  const statuses = providerStatusesFrom(statusAnswer);
12117
- const scanProviders = channels.map((channel) => channel.id).filter((id) => (statuses.get(id)?.accountsTotal ?? 0) > 0);
12513
+ /**
12514
+ * Doubao is added to the scan list by hand.
12515
+ *
12516
+ * `provider.status` counts accounts by walking the PACK's pools, and Doubao has no pack
12517
+ * adapter — so its count is always zero, and a filter keyed on that count drops the
12518
+ * channel before anything can be drawn. A signed-in Doubao session would then exist,
12519
+ * work, and appear nowhere on this page.
12520
+ */
12521
+ const doubaoAccount = await readDoubaoAccount();
12522
+ const scanProviders = channels.map((channel) => channel.id).filter((id) => (statuses.get(id)?.accountsTotal ?? 0) > 0 || id === "doubao" && doubaoAccount !== void 0);
12118
12523
  const perProvider = await Promise.all(scanProviders.map(async (provider) => {
12119
12524
  const wantBalances = channels.find((channel) => channel.id === provider)?.credits !== void 0;
12120
- const accountsPromise = callPack("account.list", { provider });
12121
- const modelsPromise = callPack("model.list", { provider });
12525
+ /**
12526
+ * Doubao answers from THIS plugin's routes, not from the pack.
12527
+ *
12528
+ * `account.list` and `model.list` are pack RPCs, and the pack has no Doubao adapter —
12529
+ * both answer "unknown provider". Calling them anyway would draw a card reading
12530
+ * "0 accounts, 0 models" for a lane that has one session and six models, and the
12531
+ * empty numbers would look like a failed sign-in.
12532
+ */
12533
+ const accountsPromise = provider === "doubao" ? Promise.resolve({
12534
+ ok: true,
12535
+ value: { accounts: doubaoAccount === void 0 ? [] : [doubaoAccount] }
12536
+ }) : callPack("account.list", { provider });
12537
+ const modelsPromise = provider === "doubao" ? Promise.resolve({
12538
+ ok: true,
12539
+ value: { models: doubaoListing().map((model) => ({
12540
+ id: model.id,
12541
+ name: model.name,
12542
+ ...model.description === void 0 ? {} : { description: model.description }
12543
+ })) }
12544
+ }) : callPack("model.list", { provider });
12122
12545
  const [accounts, models] = await Promise.all([accountsPromise.catch(() => refused("account.list failed")), modelsPromise.catch(() => refused("model.list failed"))]);
12123
12546
  const modelRows = modelsFrom(models.value);
12124
12547
  const modelEmptyBecauseRefused = modelRows.length === 0 && models.ok !== true;
@@ -12354,6 +12777,22 @@ window.__ModuleLoader__.load({
12354
12777
  balancePending: true
12355
12778
  } : entry));
12356
12779
  try {
12780
+ /**
12781
+ * Doubao reports its own balance, from its quota route.
12782
+ *
12783
+ * `credits.balances` is a pack RPC with no Doubao adapter, so it answers "unsupported
12784
+ * provider" and the card printed "no balance reported" under a signed-in account.
12785
+ */
12786
+ if (provider === "doubao") {
12787
+ const rows = await readDoubaoBalance();
12788
+ setEntries((previous) => previous.map((entry) => entry.channel.id === provider ? {
12789
+ ...entry,
12790
+ balancePending: false,
12791
+ balanceError: void 0,
12792
+ balances: rows
12793
+ } : entry));
12794
+ return;
12795
+ }
12357
12796
  const envelope = await callPack("credits.balances", force ? {
12358
12797
  provider,
12359
12798
  force: true
@@ -12487,6 +12926,26 @@ window.__ModuleLoader__.load({
12487
12926
  }
12488
12927
  markBusy(provider, true);
12489
12928
  try {
12929
+ /**
12930
+ * Doubao's account IS the session, so its actions are the session's.
12931
+ *
12932
+ * `account.delete` / `test` / `refresh` are pack RPCs addressed to the pack's credential
12933
+ * store, and Doubao has no entry there — every one of them answered "unsupported
12934
+ * provider", so the buttons did nothing and the row could not be removed.
12935
+ */
12936
+ if (provider === "doubao") {
12937
+ if (action === "delete") await fetch(POOL_DOUBAO_SESSION_PATH, {
12938
+ method: "DELETE",
12939
+ credentials: "same-origin"
12940
+ });
12941
+ else if (action === "refresh") await fetch(POOL_DOUBAO_QUOTA_PATH, { credentials: "same-origin" });
12942
+ else if (action === "test") await fetch(POOL_DOUBAO_SESSION_PATH, { credentials: "same-origin" });
12943
+ if (!mountedRef.current) return;
12944
+ invalidatePoolSnapshot();
12945
+ await load();
12946
+ setNotice(action === "delete" ? "已删除豆包会话" : "已刷新");
12947
+ return;
12948
+ }
12490
12949
  const enabledNow = entries.find((item) => item.channel.id === provider)?.accounts.find((account) => account.id === accountId)?.enabled !== false;
12491
12950
  const envelope = await callPack(action === "refresh" ? "account.refresh" : action === "test" ? "account.test" : action === "delete" ? "account.delete" : "account.update", action === "toggle" ? {
12492
12951
  accountId,
@@ -13318,7 +13777,7 @@ window.__ModuleLoader__.load({
13318
13777
  }
13319
13778
  // src/version.ts
13320
13779
  /** Version embedded in the browser bundle at build time from the package manifest. */
13321
- const POOL_VERSION = "1.0.6";
13780
+ const POOL_VERSION = "1.0.8";
13322
13781
  // src/client/PoolCard.tsx
13323
13782
  /**
13324
13783
  * Heybash card contributed to DSH Plugin configuration.
@@ -13763,7 +14222,7 @@ window.__ModuleLoader__.load({
13763
14222
  * Whether a region's model pane is showing the WHOLE roster.
13764
14223
  *
13765
14224
  * Per region, and default off, because the pane opens on a card the user
13766
- * scrolled to reach: fourteen full rows of mostly-disabled models pushed
14225
+ * scrolled to reach: thirteen full rows of mostly-disabled models pushed
13767
14226
  * everything else a screen and a half further down (the reported "无限往下
13768
14227
  * 续"). The enabled rows are what "my models" means; the rest are one click
13769
14228
  * away and the button says how many there are.
@@ -15232,14 +15691,15 @@ window.__ModuleLoader__.load({
15232
15691
  children: [
15233
15692
  "claimed",
15234
15693
  "already",
15694
+ "uncovered",
15235
15695
  "skipped",
15236
15696
  "failed"
15237
15697
  ].map((status) => {
15238
- const group = job.items?.filter((item) => item.status === status) ?? [];
15698
+ const group = job.items?.filter((item) => automationGroup(item) === status) ?? [];
15239
15699
  if (group.length === 0) return null;
15240
15700
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
15241
- className: `dsm-xdpool-auto-job-item dsm-xdpool-auto-job-item-${status}`,
15242
- title: group.map((item) => item.title + (item.note === void 0 ? "" : ` (${item.note})`)).join("\n"),
15701
+ className: `dsm-xdpool-auto-job-item dsm-xdpool-auto-job-item-${status === "uncovered" ? "skipped" : status}`,
15702
+ title: group.map((item) => item.title + (item.note === void 0 ? "" : ` (${automationNote(item.note, t)})`)).join("\n"),
15243
15703
  children: [
15244
15704
  t?.(`row.autoItem.${status}`) ?? status,
15245
15705
  " ",
@@ -15260,6 +15720,11 @@ window.__ModuleLoader__.load({
15260
15720
  })
15261
15721
  })
15262
15722
  }),
15723
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("section", {
15724
+ className: "dsm-xdpool-cpool",
15725
+ "aria-label": "豆包账号",
15726
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DoubaoPage, { t })
15727
+ }),
15263
15728
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ChannelPoolSection, { t }),
15264
15729
  flash === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
15265
15730
  className: "dsm-xdpool-note",
@@ -16633,7 +17098,13 @@ window.__ModuleLoader__.load({
16633
17098
  "row.autoItem.claimed": "claimed",
16634
17099
  "row.autoItem.already": "already",
16635
17100
  "row.autoItem.skipped": "not yet",
17101
+ "row.autoItem.uncovered": "manual",
16636
17102
  "row.autoItem.failed": "failed",
17103
+ "row.autoNote.uncovered": "Not supported by automation; complete manually",
17104
+ "row.autoNote.failed": "Automatic completion failed; retry later",
17105
+ "row.autoNote.unscored": "Not completed or awaiting scoring",
17106
+ "row.autoNote.notAccepted": "Task not accepted",
17107
+ "row.autoNote.locked": "Task locked",
16637
17108
  "row.autoJob_report": "Activity report",
16638
17109
  "row.autoJob_tasks": "Task rewards",
16639
17110
  "row.autoJob_checkin": "Daily check-in",
@@ -16705,6 +17176,14 @@ window.__ModuleLoader__.load({
16705
17176
  "agg.noKeyNeeded": "No key needed",
16706
17177
  "agg.models": "{count} models",
16707
17178
  "agg.unsupported": "This vendor signs in via OAuth/ADC, which this lane cannot drive.",
17179
+ "doubao.ready": "Signed in; the session is stored locally",
17180
+ "doubao.sub": "Sign in with a browser to use direct chat models",
17181
+ "doubao.signIn": "Sign in with a browser",
17182
+ "doubao.signOut": "Sign out",
17183
+ "doubao.waiting": "Waiting for sign-in…",
17184
+ "doubao.refresh": "Refresh quota",
17185
+ "doubao.why": "Doubao has closed third-party QR login (the server answers 2035), so this opens a browser window: scan or enter a phone number there, and the session is taken back and stored on this machine.",
17186
+ "doubao.modelsNote": "The models are in the conversation picker: Doubao Quick / 2.1 Turbo.",
16708
17187
  "agg.listingYes": "Model list available",
16709
17188
  "agg.saved": "Saved",
16710
17189
  "agg.cleared": "Cleared",
@@ -16806,6 +17285,7 @@ window.__ModuleLoader__.load({
16806
17285
  "chan.pending": "The login channels are still loading…",
16807
17286
  "chan.unavailable": "The login channels could not start on this host.",
16808
17287
  "chan.ownedElsewhere": "These login channels are already served by another plugin — the same thirteen sign-in methods are one click away on that build’s own page.",
17288
+ "chan.ownedElsewhereRow": "Sign in on the “Our Free Model” page",
16809
17289
  "chan.empty": "No channel is connected yet.",
16810
17290
  "shell.brand": "Heybash",
16811
17291
  "shell.project": "Heybash project",
@@ -16821,6 +17301,7 @@ window.__ModuleLoader__.load({
16821
17301
  "shell.tabRouting": "Routing",
16822
17302
  "shell.subRouting": "Chains that try models in order, so one busy or rate-limited model falls through to the next.",
16823
17303
  "shell.tabGateway": "Gateway",
17304
+ "shell.tabDoubao": "Doubao",
16824
17305
  "shell.tabBackup": "Backup",
16825
17306
  "shell.subGateway": "Open the pool to the other devices on your network.",
16826
17307
  "gw.title": "Gateway",
@@ -17221,7 +17702,13 @@ window.__ModuleLoader__.load({
17221
17702
  "row.autoItem.claimed": "已领",
17222
17703
  "row.autoItem.already": "早已领过",
17223
17704
  "row.autoItem.skipped": "暂不可领",
17705
+ "row.autoItem.uncovered": "需手动完成",
17224
17706
  "row.autoItem.failed": "失败",
17707
+ "row.autoNote.uncovered": "暂不支持自动完成,请手动操作",
17708
+ "row.autoNote.failed": "自动完成失败,请稍后重试",
17709
+ "row.autoNote.unscored": "尚未完成或正在等待计分",
17710
+ "row.autoNote.notAccepted": "尚未领取任务",
17711
+ "row.autoNote.locked": "任务尚未解锁",
17225
17712
  "row.autoJob_report": "活跃上报",
17226
17713
  "row.autoJob_tasks": "任务奖励",
17227
17714
  "row.autoJob_checkin": "每日签到",
@@ -17293,6 +17780,14 @@ window.__ModuleLoader__.load({
17293
17780
  "agg.noKeyNeeded": "无需 key",
17294
17781
  "agg.models": "{count} 个模型",
17295
17782
  "agg.unsupported": "该厂商需要 OAuth/ADC 授权,这条通道暂时接不了。",
17783
+ "doubao.ready": "已登录,会话保存在本机",
17784
+ "doubao.sub": "浏览器登录后使用豆包直接对话模型",
17785
+ "doubao.signIn": "扫码登录",
17786
+ "doubao.signOut": "退出登录",
17787
+ "doubao.waiting": "等待登录…",
17788
+ "doubao.refresh": "刷新额度",
17789
+ "doubao.why": "豆包已关闭第三方扫码入口(服务端返回 2035),所以这里拉起一个浏览器窗口:在窗口里扫码或填手机号,登录成功后会话自动取回并保存在本机。",
17790
+ "doubao.modelsNote": "模型在对话的模型选择器里:豆包 快速 / 2.1 Turbo。",
17296
17791
  "agg.listingYes": "支持拉取模型列表",
17297
17792
  "agg.saved": "已保存",
17298
17793
  "agg.cleared": "已清除",
@@ -17394,6 +17889,7 @@ window.__ModuleLoader__.load({
17394
17889
  "chan.pending": "扫码登录通道正在加载…",
17395
17890
  "chan.unavailable": "本机上扫码登录通道没能启动。",
17396
17891
  "chan.ownedElsewhere": "这些扫码登录通道已经由另一个插件接管了——同样这十三种登录方式,在它自己的页面上点一下就能用。",
17892
+ "chan.ownedElsewhereRow": "在「我们的免费模型」里登录",
17397
17893
  "chan.empty": "还没有任何渠道连上来。",
17398
17894
  "shell.brand": "Heybash",
17399
17895
  "shell.project": "Heybash 项目",
@@ -17409,6 +17905,7 @@ window.__ModuleLoader__.load({
17409
17905
  "shell.tabRouting": "路由",
17410
17906
  "shell.subRouting": "把几个模型串成一条链,按顺序试;一个忙了或被限流,就自动落到下一个。",
17411
17907
  "shell.tabGateway": "网关",
17908
+ "shell.tabDoubao": "豆包",
17412
17909
  "shell.tabBackup": "备份",
17413
17910
  "shell.subGateway": "把账号池开放给同网络里的其它设备。",
17414
17911
  "gw.title": "网关",