dsh-xdpool 2.6.6 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +97 -0
- package/lib/bin.js +47 -30
- package/lib/client.js +632 -25
- package/lib/index.js +3342 -747
- package/package.json +1 -1
- package/vendor/channel-pack/pack.js +57 -4
package/lib/client.js
CHANGED
|
@@ -4,9 +4,33 @@ window.__ModuleLoader__.load({
|
|
|
4
4
|
var module = { exports: {} };
|
|
5
5
|
var exports = module.exports;
|
|
6
6
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
|
+
//#region \0rolldown/runtime.js
|
|
8
|
+
var __create = Object.create;
|
|
9
|
+
var __defProp = Object.defineProperty;
|
|
10
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
11
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
16
|
+
key = keys[i];
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
18
|
+
get: ((k) => from[k]).bind(null, key),
|
|
19
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
25
|
+
value: mod,
|
|
26
|
+
enumerable: true
|
|
27
|
+
}) : target, mod));
|
|
7
28
|
//#endregion
|
|
8
29
|
let react = require("react");
|
|
9
30
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
+
let node_crypto = require("node:crypto");
|
|
32
|
+
node_crypto = __toESM(node_crypto, 1);
|
|
33
|
+
let node_fs = require("node:fs");
|
|
10
34
|
//#region src/client/sidebar-row.ts
|
|
11
35
|
/**
|
|
12
36
|
* The `sidebarRow` switch, read and written from one place.
|
|
@@ -211,6 +235,29 @@ window.__ModuleLoader__.load({
|
|
|
211
235
|
*/
|
|
212
236
|
const POOL_CHANNELS_PATH = "/plugins/dsh-xdpool/channels";
|
|
213
237
|
/**
|
|
238
|
+
* The Doubao lane's session.
|
|
239
|
+
*
|
|
240
|
+
* POST starts an interactive browser sign-in and answers once it lands;
|
|
241
|
+
* GET reports whether a session is stored; DELETE forgets it.
|
|
242
|
+
*/
|
|
243
|
+
const POOL_DOUBAO_SESSION_PATH = "/plugins/dsh-xdpool/doubao/session";
|
|
244
|
+
/** The Doubao quota: the windows the account has, with their reset countdowns. */
|
|
245
|
+
const POOL_DOUBAO_QUOTA_PATH = "/plugins/dsh-xdpool/doubao/quota";
|
|
246
|
+
/**
|
|
247
|
+
* The `reason` the channel document carries when the login-channel route is
|
|
248
|
+
* already owned by another plugin.
|
|
249
|
+
*
|
|
250
|
+
* The pack we vendor is byte-identical to the one the sibling login-channel
|
|
251
|
+
* build mounts, and both claim the same fetch route; the host has no query for
|
|
252
|
+
* what is already registered, so the loser of that race can only tell it lost.
|
|
253
|
+
* Both halves need the same string — the host to say it, the card to choose
|
|
254
|
+
* between "this host cannot run the channels" and "another plugin already runs
|
|
255
|
+
* them", which are opposite sentences — so it is declared with the other wire
|
|
256
|
+
* constants rather than in `channels.ts`, which the browser bundle may not
|
|
257
|
+
* import for value.
|
|
258
|
+
*/
|
|
259
|
+
const ROUTE_OWNED_ELSEWHERE = "already-mounted-elsewhere";
|
|
260
|
+
/**
|
|
214
261
|
* The routing chains, and the whole model roster a member may name.
|
|
215
262
|
*
|
|
216
263
|
* One route for both because the editor cannot be drawn without the roster: a
|
|
@@ -2409,8 +2456,11 @@ window.__ModuleLoader__.load({
|
|
|
2409
2456
|
(0, react.useEffect)(() => {
|
|
2410
2457
|
if (shared !== void 0) setOwn(shared);
|
|
2411
2458
|
}, [shared]);
|
|
2412
|
-
(0, react.useEffect)(() =>
|
|
2413
|
-
mounted.current =
|
|
2459
|
+
(0, react.useEffect)(() => {
|
|
2460
|
+
mounted.current = true;
|
|
2461
|
+
return () => {
|
|
2462
|
+
mounted.current = false;
|
|
2463
|
+
};
|
|
2414
2464
|
}, []);
|
|
2415
2465
|
/**
|
|
2416
2466
|
* Poll only while this page is mounted.
|
|
@@ -2840,7 +2890,16 @@ window.__ModuleLoader__.load({
|
|
|
2840
2890
|
* "TRAE" a bare "T", which looks sparse at 40px. CamelCase splitting resolves
|
|
2841
2891
|
* both: LobsterAI -> LA, Loomy -> L, TRAE -> TR, MiniMax Code -> MM.
|
|
2842
2892
|
*/
|
|
2893
|
+
/**
|
|
2894
|
+
* Initials for a name the generic rule cannot letter.
|
|
2895
|
+
*
|
|
2896
|
+
* A Chinese display name has no ASCII letters to take, so the rule below returns an empty
|
|
2897
|
+
* mark — a channel with a blank tile. Doubao is the first such name.
|
|
2898
|
+
*/
|
|
2899
|
+
const INITIALS_BY_NAME = { 豆包: "DB" };
|
|
2843
2900
|
function channelInitials(name) {
|
|
2901
|
+
const fixed = INITIALS_BY_NAME[name.trim()];
|
|
2902
|
+
if (fixed !== void 0) return fixed;
|
|
2844
2903
|
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 !== "");
|
|
2845
2904
|
if (segments.length >= 2) return (([...segments[0] ?? ""][0] ?? "") + ([...segments[1] ?? ""][0] ?? "")).toUpperCase();
|
|
2846
2905
|
return [...segments[0] ?? ""].slice(0, 2).join("").toUpperCase();
|
|
@@ -8385,8 +8444,11 @@ window.__ModuleLoader__.load({
|
|
|
8385
8444
|
/** The pair currently being measured, so only one button shows a spinner. */
|
|
8386
8445
|
const [probing, setProbing] = (0, react.useState)(void 0);
|
|
8387
8446
|
const mounted = (0, react.useRef)(true);
|
|
8388
|
-
(0, react.useEffect)(() =>
|
|
8389
|
-
mounted.current =
|
|
8447
|
+
(0, react.useEffect)(() => {
|
|
8448
|
+
mounted.current = true;
|
|
8449
|
+
return () => {
|
|
8450
|
+
mounted.current = false;
|
|
8451
|
+
};
|
|
8390
8452
|
}, []);
|
|
8391
8453
|
/**
|
|
8392
8454
|
* Ask the host to run one real request against a model, and keep the reading.
|
|
@@ -9919,10 +9981,13 @@ window.__ModuleLoader__.load({
|
|
|
9919
9981
|
const mounted = (0, react.useRef)(true);
|
|
9920
9982
|
/** Timers for in-flight logins, keyed by channel id. */
|
|
9921
9983
|
const timers = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
9922
|
-
(0, react.useEffect)(() =>
|
|
9923
|
-
mounted.current =
|
|
9924
|
-
|
|
9925
|
-
|
|
9984
|
+
(0, react.useEffect)(() => {
|
|
9985
|
+
mounted.current = true;
|
|
9986
|
+
return () => {
|
|
9987
|
+
mounted.current = false;
|
|
9988
|
+
for (const handle of timers.current.values()) window.clearInterval(handle);
|
|
9989
|
+
timers.current.clear();
|
|
9990
|
+
};
|
|
9926
9991
|
}, []);
|
|
9927
9992
|
const load = (0, react.useCallback)(async (signal) => {
|
|
9928
9993
|
try {
|
|
@@ -10201,6 +10266,16 @@ window.__ModuleLoader__.load({
|
|
|
10201
10266
|
t,
|
|
10202
10267
|
ui: ui[channel.id] ?? IDLE,
|
|
10203
10268
|
connectedCount: connectedFor(channel).length,
|
|
10269
|
+
/**
|
|
10270
|
+
* When the pack is mounted ELSEWHERE, this page cannot log anybody in.
|
|
10271
|
+
*
|
|
10272
|
+
* `account.create` is answered by the pack, and the pack that owns it lives in
|
|
10273
|
+
* another plugin — so pressing the button produced the host's "not supported"
|
|
10274
|
+
* line for a channel that works perfectly well, on a page the user was told to
|
|
10275
|
+
* use. The row says where the sign-in actually is instead of offering a button
|
|
10276
|
+
* that cannot work.
|
|
10277
|
+
*/
|
|
10278
|
+
ownedElsewhere: status?.reason === ROUTE_OWNED_ELSEWHERE,
|
|
10204
10279
|
onSignIn: () => {
|
|
10205
10280
|
signIn(channel);
|
|
10206
10281
|
},
|
|
@@ -10209,7 +10284,7 @@ window.__ModuleLoader__.load({
|
|
|
10209
10284
|
]
|
|
10210
10285
|
});
|
|
10211
10286
|
}
|
|
10212
|
-
function ChannelRow({ channel, t, ui, connectedCount, onSignIn, onCancel }) {
|
|
10287
|
+
function ChannelRow({ channel, t, ui, connectedCount, onSignIn, onCancel, ownedElsewhere }) {
|
|
10213
10288
|
const busy = ui.phase === "signing-in";
|
|
10214
10289
|
const icon = channelIcon(channel.id);
|
|
10215
10290
|
const tileMark = icon === void 0 ? { initials: channelInitials(channel.name) } : { icon };
|
|
@@ -10264,7 +10339,10 @@ window.__ModuleLoader__.load({
|
|
|
10264
10339
|
children: t?.("agg.clear") ?? "Cancel"
|
|
10265
10340
|
})
|
|
10266
10341
|
] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
10267
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("
|
|
10342
|
+
ownedElsewhere === true ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
10343
|
+
className: "dsm-xdpool-channel-hint",
|
|
10344
|
+
children: t?.("chan.ownedElsewhereRow") ?? "在「我们的免费模型」里登录"
|
|
10345
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
10268
10346
|
type: "button",
|
|
10269
10347
|
className: "dsm-xdpool-btn",
|
|
10270
10348
|
onClick: onSignIn,
|
|
@@ -10326,7 +10404,19 @@ window.__ModuleLoader__.load({
|
|
|
10326
10404
|
const out = [];
|
|
10327
10405
|
const seen = /* @__PURE__ */ new Set();
|
|
10328
10406
|
for (const platform of platforms) for (const model of platform.models) {
|
|
10329
|
-
|
|
10407
|
+
/**
|
|
10408
|
+
* A channel member is ALREADY composite (#141).
|
|
10409
|
+
*
|
|
10410
|
+
* `owner` here is the editor's grouping label. For a scan-login channel the
|
|
10411
|
+
* member's own id is `<channel>:<model>` and already carries the owner, so
|
|
10412
|
+
* prefixing it again produced `trae/trae:deepseek-v4.1-flash`. The runtime then
|
|
10413
|
+
* matched nothing and the chain reported every member missing — and a save in that
|
|
10414
|
+
* state would have rewritten the chain with the doubled ids.
|
|
10415
|
+
*
|
|
10416
|
+
* The colon is the test, matching `channelMemberOf` in `combos.ts`.
|
|
10417
|
+
*/
|
|
10418
|
+
const selfOwned = /^[A-Za-z0-9_-]+:/u.test(model);
|
|
10419
|
+
const id = platform.owner === "workbuddy" || selfOwned ? model : `${platform.owner}/${model}`;
|
|
10330
10420
|
if (seen.has(id)) continue;
|
|
10331
10421
|
seen.add(id);
|
|
10332
10422
|
out.push(id);
|
|
@@ -10357,9 +10447,19 @@ window.__ModuleLoader__.load({
|
|
|
10357
10447
|
const known = new Set(Array.isArray(combo.models) ? combo.models : []);
|
|
10358
10448
|
for (const modelId of Array.isArray(combo.missing) ? combo.missing : []) {
|
|
10359
10449
|
if (known.has(modelId)) continue;
|
|
10450
|
+
/**
|
|
10451
|
+
* Read the owner the same way `combos.ts` does, so a missing CHANNEL member is filed
|
|
10452
|
+
* under its channel rather than under a slash prefix (#141).
|
|
10453
|
+
*
|
|
10454
|
+
* `raccoon:sn-…` belongs to `raccoon`; splitting on `/` would find no slash, call it a
|
|
10455
|
+
* pool model, and then `flattenDraft` would write `workbuddy/raccoon:…` back.
|
|
10456
|
+
*/
|
|
10457
|
+
const colon = modelId.indexOf(":");
|
|
10458
|
+
const channelHead = colon > 0 ? modelId.slice(0, colon) : "";
|
|
10459
|
+
const isChannelMember = channelHead !== "" && /^[A-Za-z0-9_-]+$/u.test(channelHead);
|
|
10360
10460
|
const slash = modelId.indexOf("/");
|
|
10361
|
-
const owner = slash === -1 ? "workbuddy" : modelId.slice(0, slash);
|
|
10362
|
-
const model = slash === -1 ? modelId : modelId.slice(slash + 1);
|
|
10461
|
+
const owner = isChannelMember ? channelHead : slash === -1 ? "workbuddy" : modelId.slice(0, slash);
|
|
10462
|
+
const model = isChannelMember ? modelId : slash === -1 ? modelId : modelId.slice(slash + 1);
|
|
10363
10463
|
const group = platforms.find((entry) => entry.owner === owner);
|
|
10364
10464
|
if (group === void 0) platforms.push({
|
|
10365
10465
|
owner,
|
|
@@ -10408,8 +10508,11 @@ window.__ModuleLoader__.load({
|
|
|
10408
10508
|
/** True once the drafts were seeded from the server, so later polls don't stomp edits. */
|
|
10409
10509
|
const seeded = (0, react.useRef)(false);
|
|
10410
10510
|
const mounted = (0, react.useRef)(true);
|
|
10411
|
-
(0, react.useEffect)(() =>
|
|
10412
|
-
mounted.current =
|
|
10511
|
+
(0, react.useEffect)(() => {
|
|
10512
|
+
mounted.current = true;
|
|
10513
|
+
return () => {
|
|
10514
|
+
mounted.current = false;
|
|
10515
|
+
};
|
|
10413
10516
|
}, []);
|
|
10414
10517
|
const load = (0, react.useCallback)(async (signal) => {
|
|
10415
10518
|
try {
|
|
@@ -11211,8 +11314,11 @@ window.__ModuleLoader__.load({
|
|
|
11211
11314
|
/** True once the server's values were adopted, so polls do not stomp edits. */
|
|
11212
11315
|
const seeded = (0, react.useRef)(false);
|
|
11213
11316
|
const mounted = (0, react.useRef)(true);
|
|
11214
|
-
(0, react.useEffect)(() =>
|
|
11215
|
-
mounted.current =
|
|
11317
|
+
(0, react.useEffect)(() => {
|
|
11318
|
+
mounted.current = true;
|
|
11319
|
+
return () => {
|
|
11320
|
+
mounted.current = false;
|
|
11321
|
+
};
|
|
11216
11322
|
}, []);
|
|
11217
11323
|
const load = (0, react.useCallback)(async (signal) => {
|
|
11218
11324
|
try {
|
|
@@ -11664,6 +11770,262 @@ window.__ModuleLoader__.load({
|
|
|
11664
11770
|
]
|
|
11665
11771
|
});
|
|
11666
11772
|
}
|
|
11773
|
+
//#endregion
|
|
11774
|
+
//#region src/client/DoubaoPage.tsx
|
|
11775
|
+
/**
|
|
11776
|
+
* The Doubao card: sign in, then read the quota.
|
|
11777
|
+
*
|
|
11778
|
+
* WHAT THIS SURFACE IS FOR
|
|
11779
|
+
*
|
|
11780
|
+
* Doubao's models already appear in the picker (the channel lane serves them), so this card
|
|
11781
|
+
* is not a second model list. It is the two things that have no other home:
|
|
11782
|
+
*
|
|
11783
|
+
* - the SIGN-IN, because Doubao's QR entrance is closed and the only door left is a
|
|
11784
|
+
* browser window this plugin starts;
|
|
11785
|
+
* - the QUOTA, because Doubao reports promotional windows with reset countdowns and
|
|
11786
|
+
* nothing else in the plugin knows how to read them.
|
|
11787
|
+
*
|
|
11788
|
+
* THE COPY SAYS WHAT ACTUALLY HAPPENS
|
|
11789
|
+
*
|
|
11790
|
+
* The button opens a Chromium window and waits. A user who is told "sign in" and sees a blank
|
|
11791
|
+
* panel for a minute concludes the feature is broken, so the waiting states name the step
|
|
11792
|
+
* they are on and the window stays open for the whole budget.
|
|
11793
|
+
*
|
|
11794
|
+
* @module dsh-xdpool/client/DoubaoPage
|
|
11795
|
+
*/
|
|
11796
|
+
/** How the card describes one window. */
|
|
11797
|
+
function windowLabel(window) {
|
|
11798
|
+
if (typeof window.label === "string" && window.label !== "") return window.label;
|
|
11799
|
+
if (window.type === "five_hour") return "5 小时限额";
|
|
11800
|
+
if (window.type === "weekly") return "周额度";
|
|
11801
|
+
if (window.type === "incentive") return "活动赠送额度";
|
|
11802
|
+
return "额度";
|
|
11803
|
+
}
|
|
11804
|
+
/** A countdown, or a plain statement when the window has no reset. */
|
|
11805
|
+
function resetText(window) {
|
|
11806
|
+
if (window.resetUnknown === true || window.resetsAt === void 0 || window.resetsAt <= 0) return "用后开始计算";
|
|
11807
|
+
const left = window.resetsAt - Date.now();
|
|
11808
|
+
if (left <= 0) return "已重置";
|
|
11809
|
+
const hours = Math.floor(left / 36e5);
|
|
11810
|
+
const days = Math.floor(hours / 24);
|
|
11811
|
+
if (days > 0) return `${String(days)} 天 ${String(hours % 24)} 小时后重置`;
|
|
11812
|
+
const minutes = Math.floor(left % 36e5 / 6e4);
|
|
11813
|
+
return `${String(hours)} 小时 ${String(minutes)} 分后重置`;
|
|
11814
|
+
}
|
|
11815
|
+
function DoubaoPage({ t }) {
|
|
11816
|
+
const [signedIn, setSignedIn] = (0, react.useState)(false);
|
|
11817
|
+
const [busy, setBusy] = (0, react.useState)(false);
|
|
11818
|
+
const [message, setMessage] = (0, react.useState)(void 0);
|
|
11819
|
+
const [error, setError] = (0, react.useState)(void 0);
|
|
11820
|
+
const [windows, setWindows] = (0, react.useState)([]);
|
|
11821
|
+
const [exhausted, setExhausted] = (0, react.useState)(false);
|
|
11822
|
+
const mounted = (0, react.useRef)(true);
|
|
11823
|
+
const poll = (0, react.useRef)(void 0);
|
|
11824
|
+
(0, react.useEffect)(() => {
|
|
11825
|
+
mounted.current = true;
|
|
11826
|
+
return () => {
|
|
11827
|
+
mounted.current = false;
|
|
11828
|
+
if (poll.current !== void 0) window.clearTimeout(poll.current);
|
|
11829
|
+
};
|
|
11830
|
+
}, []);
|
|
11831
|
+
/** Read the session and, when there is one, the quota. */
|
|
11832
|
+
const load = (0, react.useCallback)(async () => {
|
|
11833
|
+
try {
|
|
11834
|
+
const body = await (await fetch(POOL_DOUBAO_SESSION_PATH, { credentials: "same-origin" })).json().catch(() => void 0);
|
|
11835
|
+
if (!mounted.current) return;
|
|
11836
|
+
const signed = body?.signedIn === true;
|
|
11837
|
+
setSignedIn(signed);
|
|
11838
|
+
if (!signed) {
|
|
11839
|
+
setWindows([]);
|
|
11840
|
+
return;
|
|
11841
|
+
}
|
|
11842
|
+
const quota = await (await fetch(POOL_DOUBAO_QUOTA_PATH, { credentials: "same-origin" })).json().catch(() => void 0);
|
|
11843
|
+
if (!mounted.current) return;
|
|
11844
|
+
setWindows(Array.isArray(quota?.windows) ? quota.windows : []);
|
|
11845
|
+
setExhausted(quota?.exhausted === true);
|
|
11846
|
+
if (typeof quota?.error === "string" && quota.error !== "") setError(quota.error);
|
|
11847
|
+
} catch (cause) {
|
|
11848
|
+
if (mounted.current) setError(cause instanceof Error ? cause.message : String(cause));
|
|
11849
|
+
}
|
|
11850
|
+
}, []);
|
|
11851
|
+
/** Open the sign-in browser and wait for it. */
|
|
11852
|
+
const signIn = (0, react.useCallback)(async () => {
|
|
11853
|
+
setError(void 0);
|
|
11854
|
+
setMessage("已打开浏览器,请在弹出的窗口里扫码或短信登录…");
|
|
11855
|
+
setBusy(true);
|
|
11856
|
+
try {
|
|
11857
|
+
const body = await (await fetch(POOL_DOUBAO_SESSION_PATH, {
|
|
11858
|
+
method: "POST",
|
|
11859
|
+
credentials: "same-origin"
|
|
11860
|
+
})).json().catch(() => void 0);
|
|
11861
|
+
if (!mounted.current) return;
|
|
11862
|
+
if (body?.signedIn === true) {
|
|
11863
|
+
setMessage(body.message ?? "登录成功");
|
|
11864
|
+
load();
|
|
11865
|
+
return;
|
|
11866
|
+
}
|
|
11867
|
+
setMessage(body?.message ?? "没有等到登录完成,可以再试一次");
|
|
11868
|
+
} catch (cause) {
|
|
11869
|
+
if (mounted.current) setError(cause instanceof Error ? cause.message : String(cause));
|
|
11870
|
+
} finally {
|
|
11871
|
+
if (mounted.current) setBusy(false);
|
|
11872
|
+
}
|
|
11873
|
+
}, [load]);
|
|
11874
|
+
/** Forget the session. */
|
|
11875
|
+
const signOut = (0, react.useCallback)(async () => {
|
|
11876
|
+
setError(void 0);
|
|
11877
|
+
setMessage(void 0);
|
|
11878
|
+
setBusy(true);
|
|
11879
|
+
try {
|
|
11880
|
+
await fetch(POOL_DOUBAO_SESSION_PATH, {
|
|
11881
|
+
method: "DELETE",
|
|
11882
|
+
credentials: "same-origin"
|
|
11883
|
+
});
|
|
11884
|
+
if (!mounted.current) return;
|
|
11885
|
+
setSignedIn(false);
|
|
11886
|
+
setWindows([]);
|
|
11887
|
+
setMessage("已退出登录");
|
|
11888
|
+
} catch (cause) {
|
|
11889
|
+
if (mounted.current) setError(cause instanceof Error ? cause.message : String(cause));
|
|
11890
|
+
} finally {
|
|
11891
|
+
if (mounted.current) setBusy(false);
|
|
11892
|
+
}
|
|
11893
|
+
}, []);
|
|
11894
|
+
(0, react.useEffect)(() => {
|
|
11895
|
+
load();
|
|
11896
|
+
}, [load]);
|
|
11897
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
11898
|
+
className: "dsm-xdpool-doubao",
|
|
11899
|
+
children: [
|
|
11900
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("style", { children: DOUBAO_CSS }),
|
|
11901
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
11902
|
+
className: "dsm-xdpool-doubao-head",
|
|
11903
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
11904
|
+
className: "dsm-xdpool-doubao-id",
|
|
11905
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
11906
|
+
className: "dsm-xdpool-doubao-mark",
|
|
11907
|
+
children: "DB"
|
|
11908
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
11909
|
+
className: "dsm-xdpool-doubao-title",
|
|
11910
|
+
children: "豆包 · 字节跳动"
|
|
11911
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
11912
|
+
className: "dsm-xdpool-doubao-sub",
|
|
11913
|
+
children: signedIn ? t?.("doubao.ready") ?? "已登录,会话保存在本机" : t?.("doubao.sub") ?? "浏览器扫码登录一次,对话与工作任务模型都能用"
|
|
11914
|
+
})] })]
|
|
11915
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
11916
|
+
className: "dsm-xdpool-doubao-acts",
|
|
11917
|
+
children: signedIn ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
11918
|
+
type: "button",
|
|
11919
|
+
className: "dsm-xdpool-doubao-btn",
|
|
11920
|
+
disabled: busy,
|
|
11921
|
+
onClick: () => {
|
|
11922
|
+
load();
|
|
11923
|
+
},
|
|
11924
|
+
children: t?.("doubao.refresh") ?? "刷新额度"
|
|
11925
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
11926
|
+
type: "button",
|
|
11927
|
+
className: "dsm-xdpool-doubao-btn",
|
|
11928
|
+
disabled: busy,
|
|
11929
|
+
onClick: () => {
|
|
11930
|
+
signOut();
|
|
11931
|
+
},
|
|
11932
|
+
children: t?.("doubao.signOut") ?? "退出登录"
|
|
11933
|
+
})] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
11934
|
+
type: "button",
|
|
11935
|
+
className: "dsm-xdpool-doubao-btn",
|
|
11936
|
+
"data-tone": "primary",
|
|
11937
|
+
disabled: busy,
|
|
11938
|
+
onClick: () => {
|
|
11939
|
+
signIn();
|
|
11940
|
+
},
|
|
11941
|
+
children: busy ? t?.("doubao.waiting") ?? "等待登录…" : t?.("doubao.signIn") ?? "扫码登录"
|
|
11942
|
+
})
|
|
11943
|
+
})]
|
|
11944
|
+
}),
|
|
11945
|
+
message === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
11946
|
+
className: "dsm-xdpool-doubao-note",
|
|
11947
|
+
children: message
|
|
11948
|
+
}),
|
|
11949
|
+
error === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
11950
|
+
className: "dsm-xdpool-doubao-error",
|
|
11951
|
+
children: error
|
|
11952
|
+
}),
|
|
11953
|
+
signedIn ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
11954
|
+
exhausted ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
11955
|
+
className: "dsm-xdpool-doubao-error",
|
|
11956
|
+
children: "额度已用完,等待窗口重置。"
|
|
11957
|
+
}) : null,
|
|
11958
|
+
windows.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
11959
|
+
className: "dsm-xdpool-doubao-hint",
|
|
11960
|
+
children: "这个账号暂时没有可显示的额度窗口。"
|
|
11961
|
+
}) : windows.map((window, index) => {
|
|
11962
|
+
const percent = typeof window.usedPercent === "number" ? window.usedPercent : 0;
|
|
11963
|
+
const used = typeof window.usedAmount === "number" ? window.usedAmount : void 0;
|
|
11964
|
+
const total = typeof window.totalAmount === "number" ? window.totalAmount : void 0;
|
|
11965
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
11966
|
+
className: "dsm-xdpool-doubao-window",
|
|
11967
|
+
children: [
|
|
11968
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
11969
|
+
className: "dsm-xdpool-doubao-window-head",
|
|
11970
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
11971
|
+
className: "dsm-xdpool-doubao-window-name",
|
|
11972
|
+
children: windowLabel(window)
|
|
11973
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
11974
|
+
className: "dsm-xdpool-doubao-window-reset",
|
|
11975
|
+
children: resetText(window)
|
|
11976
|
+
})]
|
|
11977
|
+
}),
|
|
11978
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
11979
|
+
className: "dsm-xdpool-doubao-bar",
|
|
11980
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
11981
|
+
className: "dsm-xdpool-doubao-bar-fill",
|
|
11982
|
+
"data-exhausted": percent >= 100 ? "true" : "false",
|
|
11983
|
+
style: { width: `${String(Math.min(100, Math.max(0, percent)))}%` }
|
|
11984
|
+
})
|
|
11985
|
+
}),
|
|
11986
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
11987
|
+
className: "dsm-xdpool-doubao-window-foot",
|
|
11988
|
+
children: used === void 0 || total === void 0 ? `已用 ${String(Math.round(percent))}%` : `已用 ${String(used)} / ${String(total)}`
|
|
11989
|
+
})
|
|
11990
|
+
]
|
|
11991
|
+
}, `${window.type ?? "w"}-${String(index)}`);
|
|
11992
|
+
}),
|
|
11993
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
11994
|
+
className: "dsm-xdpool-doubao-hint",
|
|
11995
|
+
children: t?.("doubao.modelsNote") ?? "模型在对话的模型选择器里:豆包 快速 / 2.1 Turbo / 2.1 Lite / 2.1 Pro / 自动 / 生图。"
|
|
11996
|
+
})
|
|
11997
|
+
] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
11998
|
+
className: "dsm-xdpool-doubao-hint",
|
|
11999
|
+
children: t?.("doubao.why") ?? "豆包已关闭第三方扫码入口(服务端返回 2035),所以这里拉起一个浏览器窗口:在窗口里扫码或填手机号,登录成功后会话自动取回并保存在本机。"
|
|
12000
|
+
})
|
|
12001
|
+
]
|
|
12002
|
+
});
|
|
12003
|
+
}
|
|
12004
|
+
/** The card's own stylesheet, travelling with the component. */
|
|
12005
|
+
const DOUBAO_CSS = `
|
|
12006
|
+
.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)}
|
|
12007
|
+
.dsm-xdpool-doubao-head{display:flex;align-items:flex-start;gap:12px;flex-wrap:wrap}
|
|
12008
|
+
.dsm-xdpool-doubao-id{display:flex;align-items:center;gap:10px;min-width:0}
|
|
12009
|
+
.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}
|
|
12010
|
+
.dsm-xdpool-doubao-title{font-size:13.5px;font-weight:650;color:var(--dsw-alias-label-primary,#e8eaf0)}
|
|
12011
|
+
.dsm-xdpool-doubao-sub{margin-top:2px;font-size:11px;line-height:16px;color:var(--dsw-alias-label-tertiary,#8a90a0)}
|
|
12012
|
+
.dsm-xdpool-doubao-acts{margin-left:auto;display:flex;gap:8px;flex:none}
|
|
12013
|
+
.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}
|
|
12014
|
+
.dsm-xdpool-doubao-btn:hover:not(:disabled){border-color:color-mix(in srgb, #3B6FD4 55%, transparent);color:var(--dsw-alias-label-primary,#e8eaf0)}
|
|
12015
|
+
.dsm-xdpool-doubao-btn:disabled{opacity:.5;cursor:not-allowed}
|
|
12016
|
+
.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}
|
|
12017
|
+
.dsm-xdpool-doubao-note{margin:0;font-size:11.5px;line-height:17px;color:var(--dsw-alias-state-success-primary,#22a06b)}
|
|
12018
|
+
.dsm-xdpool-doubao-error{margin:0;font-size:11.5px;line-height:17px;color:var(--dsw-alias-state-error-primary,#e5534b)}
|
|
12019
|
+
.dsm-xdpool-doubao-hint{margin:0;font-size:11px;line-height:16px;color:var(--dsw-alias-label-tertiary,#8a90a0)}
|
|
12020
|
+
.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)}
|
|
12021
|
+
.dsm-xdpool-doubao-window-head{display:flex;align-items:baseline;gap:10px}
|
|
12022
|
+
.dsm-xdpool-doubao-window-name{font-size:12px;font-weight:600;color:var(--dsw-alias-label-primary,#e8eaf0)}
|
|
12023
|
+
.dsm-xdpool-doubao-window-reset{margin-left:auto;font-size:10.5px;color:var(--dsw-alias-label-tertiary,#8a90a0)}
|
|
12024
|
+
.dsm-xdpool-doubao-bar{height:6px;border-radius:999px;background:color-mix(in srgb, var(--dsw-alias-label-primary,#e8eaf0) 10%, transparent);overflow:hidden}
|
|
12025
|
+
.dsm-xdpool-doubao-bar-fill{display:block;height:100%;border-radius:999px;background:#3B6FD4;transition:width .2s ease}
|
|
12026
|
+
.dsm-xdpool-doubao-bar-fill[data-exhausted='true']{background:#e5534b}
|
|
12027
|
+
.dsm-xdpool-doubao-window-foot{font-size:10.5px;color:var(--dsw-alias-label-secondary,#b9bfcc);font-variant-numeric:tabular-nums}
|
|
12028
|
+
`;
|
|
11667
12029
|
//#endregion
|
|
11668
12030
|
//#region src/client/region-card.tsx
|
|
11669
12031
|
/**
|
|
@@ -12013,6 +12375,110 @@ window.__ModuleLoader__.load({
|
|
|
12013
12375
|
return paidSiblingOf(model, models);
|
|
12014
12376
|
}
|
|
12015
12377
|
//#endregion
|
|
12378
|
+
//#region src/doubao-catalog.ts
|
|
12379
|
+
/**
|
|
12380
|
+
* DSH-side alias for "generate an image".
|
|
12381
|
+
*
|
|
12382
|
+
* NOT a Doubao `model_item_key` — Doubao has no model by this name. Selecting it
|
|
12383
|
+
* makes the shim send an ordinary chat turn with `input_skill: imageGen`, and
|
|
12384
|
+
* Doubao answers with Seedream. Keeping it in the catalog is what puts 生图 in
|
|
12385
|
+
* DSH's model picker without inventing a second UI.
|
|
12386
|
+
*/
|
|
12387
|
+
const DOUBAO_IMAGE_MODEL_ID = "image-gen";
|
|
12388
|
+
/**
|
|
12389
|
+
* IMAGEGEN_LABEL_OVERLAY: 生图版本名以插件根目录的 image-models.json 为准,
|
|
12390
|
+
* 该文件由 doubao_imagemodels.py --sync 从服务端 get_item_conf 生成。
|
|
12391
|
+
*/
|
|
12392
|
+
function imageModelLabelFromOverlay() {
|
|
12393
|
+
try {
|
|
12394
|
+
const url = new URL("../image-models.json", require("url").pathToFileURL(__filename).href);
|
|
12395
|
+
const parsed = JSON.parse((0, node_fs.readFileSync)(url, "utf8"));
|
|
12396
|
+
return typeof parsed.label === "string" && parsed.label !== "" ? parsed.label : void 0;
|
|
12397
|
+
} catch {
|
|
12398
|
+
return;
|
|
12399
|
+
}
|
|
12400
|
+
}
|
|
12401
|
+
/**
|
|
12402
|
+
* The entries DSH may offer.
|
|
12403
|
+
*
|
|
12404
|
+
* WHY THESE ENTRIES. Doubao groups models by MODE, and the model list is per-mode:
|
|
12405
|
+
*
|
|
12406
|
+
* 对话 → 豆包 快速 (0), 豆包 2.1 Turbo·专家 (3)
|
|
12407
|
+
* 工作任务 → 自动 (9), 2.1 Lite (seed-lite-7b), 2.1 Pro (5), Turbo (3)
|
|
12408
|
+
*
|
|
12409
|
+
* The 「工作任务」 group (`seed-lite-7b`, `5`, `9`) runs through `Agent-GeneralTask`
|
|
12410
|
+
* (`mode_id: "3"`, `agent_mode: 1`) and is accompanied by an HTTP `tool_local`
|
|
12411
|
+
* workspace responder (`msg/ack` -> `upload_command_result` -> `msg/complete`)
|
|
12412
|
+
* so external turns complete without `710010702`.
|
|
12413
|
+
*
|
|
12414
|
+
* MEASURED, 2026-10-22: `model_item_key` is forwarded verbatim (the server stores
|
|
12415
|
+
* it on the message), but in 对话 mode it does NOT change what answers —
|
|
12416
|
+
* 0 / 3 / 5 / seed-lite-7b AND a deliberately bogus key all returned answers of
|
|
12417
|
+
* indistinguishable length and latency (12.3–14.0 s). So this list is honest
|
|
12418
|
+
* about what the PICKER can offer; it does not claim per-key routing.
|
|
12419
|
+
*
|
|
12420
|
+
* 「豆包 快速」 leads because it is the app's own chat-mode default, so an
|
|
12421
|
+
* unconfigured install reproduces the app rather than something that merely
|
|
12422
|
+
* happens to work.
|
|
12423
|
+
*/
|
|
12424
|
+
const DOUBAO_MODELS = [
|
|
12425
|
+
{
|
|
12426
|
+
id: "0",
|
|
12427
|
+
name: "豆包 快速",
|
|
12428
|
+
reasoning: false
|
|
12429
|
+
},
|
|
12430
|
+
{
|
|
12431
|
+
id: "3",
|
|
12432
|
+
name: "豆包 2.1 Turbo",
|
|
12433
|
+
badge: "专家",
|
|
12434
|
+
reasoning: true
|
|
12435
|
+
},
|
|
12436
|
+
{
|
|
12437
|
+
id: "seed-lite-7b",
|
|
12438
|
+
name: "豆包 2.1 Lite",
|
|
12439
|
+
badge: "工作任务",
|
|
12440
|
+
reasoning: true,
|
|
12441
|
+
taskMode: true
|
|
12442
|
+
},
|
|
12443
|
+
{
|
|
12444
|
+
id: "5",
|
|
12445
|
+
name: "豆包 2.1 Pro",
|
|
12446
|
+
badge: "工作任务",
|
|
12447
|
+
reasoning: true,
|
|
12448
|
+
taskMode: true
|
|
12449
|
+
},
|
|
12450
|
+
{
|
|
12451
|
+
id: "9",
|
|
12452
|
+
name: "自动",
|
|
12453
|
+
badge: "工作任务",
|
|
12454
|
+
reasoning: true,
|
|
12455
|
+
taskMode: true
|
|
12456
|
+
},
|
|
12457
|
+
{
|
|
12458
|
+
id: DOUBAO_IMAGE_MODEL_ID,
|
|
12459
|
+
name: imageModelLabelFromOverlay() ?? "豆包 生图(Seedream 5.5)",
|
|
12460
|
+
reasoning: true
|
|
12461
|
+
}
|
|
12462
|
+
];
|
|
12463
|
+
(0, node_crypto.randomUUID)();
|
|
12464
|
+
//#endregion
|
|
12465
|
+
//#region src/doubao-llm.ts
|
|
12466
|
+
/** The listings, derived from the catalog the reference implementation measured. */
|
|
12467
|
+
function doubaoListing() {
|
|
12468
|
+
const rows = [];
|
|
12469
|
+
for (const model of DOUBAO_MODELS) {
|
|
12470
|
+
const parts = [];
|
|
12471
|
+
if (typeof model.badge === "string" && model.badge !== "") parts.push(model.badge);
|
|
12472
|
+
if (model.reasoning === true) parts.push("推理");
|
|
12473
|
+
rows.push({
|
|
12474
|
+
id: model.id,
|
|
12475
|
+
name: model.name,
|
|
12476
|
+
...parts.length === 0 ? {} : { description: parts.join(" · ") }
|
|
12477
|
+
});
|
|
12478
|
+
}
|
|
12479
|
+
return rows;
|
|
12480
|
+
}
|
|
12481
|
+
//#endregion
|
|
12016
12482
|
//#region src/client/ChannelPoolSection.tsx
|
|
12017
12483
|
/**
|
|
12018
12484
|
* Account-pool page, scan-channel section.
|
|
@@ -12136,6 +12602,57 @@ window.__ModuleLoader__.load({
|
|
|
12136
12602
|
* moment a login lands), so the newest entry wins: it is the one whose
|
|
12137
12603
|
* credential was written last.
|
|
12138
12604
|
*/
|
|
12605
|
+
/**
|
|
12606
|
+
* Doubao's account, described in the pack's account shape.
|
|
12607
|
+
*
|
|
12608
|
+
* The lane is the plugin's own, so this reads its session route and translates the answer
|
|
12609
|
+
* into the row the rest of this page already knows how to draw. `undefined` means "no
|
|
12610
|
+
* session", which is the ordinary state before a sign-in.
|
|
12611
|
+
*/
|
|
12612
|
+
async function readDoubaoAccount() {
|
|
12613
|
+
try {
|
|
12614
|
+
const body = await (await fetch(POOL_DOUBAO_SESSION_PATH, { credentials: "same-origin" })).json().catch(() => void 0);
|
|
12615
|
+
if (body?.signedIn !== true) return void 0;
|
|
12616
|
+
return {
|
|
12617
|
+
id: "doubao:session",
|
|
12618
|
+
provider: "doubao",
|
|
12619
|
+
nickname: body.savedAt === void 0 ? "豆包账号" : `豆包(${String(body.savedAt).slice(0, 10)} 登录)`,
|
|
12620
|
+
enabled: true
|
|
12621
|
+
};
|
|
12622
|
+
} catch {
|
|
12623
|
+
return;
|
|
12624
|
+
}
|
|
12625
|
+
}
|
|
12626
|
+
/**
|
|
12627
|
+
* Doubao's quota, in the pack's balance row shape.
|
|
12628
|
+
*
|
|
12629
|
+
* The card prints one number per account, so it is the NARROWEST window: that is the one
|
|
12630
|
+
* that stops the next request, and reporting the widest would overstate what is left.
|
|
12631
|
+
*/
|
|
12632
|
+
async function readDoubaoBalance() {
|
|
12633
|
+
try {
|
|
12634
|
+
const body = await (await fetch(POOL_DOUBAO_QUOTA_PATH, { credentials: "same-origin" })).json().catch(() => void 0);
|
|
12635
|
+
if (body?.signedIn !== true) return [];
|
|
12636
|
+
const windows = Array.isArray(body.windows) ? body.windows : [];
|
|
12637
|
+
if (windows.length === 0) return [{
|
|
12638
|
+
accountId: "doubao:session",
|
|
12639
|
+
nickname: "豆包账号",
|
|
12640
|
+
...typeof body.error === "string" && body.error !== "" ? { error: body.error } : {}
|
|
12641
|
+
}];
|
|
12642
|
+
const lowest = windows.reduce((low, window) => {
|
|
12643
|
+
const used = typeof window.usedPercent === "number" ? window.usedPercent : 0;
|
|
12644
|
+
return Math.min(low, Math.max(0, 100 - used));
|
|
12645
|
+
}, 100);
|
|
12646
|
+
return [{
|
|
12647
|
+
accountId: "doubao:session",
|
|
12648
|
+
nickname: "豆包账号",
|
|
12649
|
+
balance: Math.round(lowest),
|
|
12650
|
+
extra: { unit: "%" }
|
|
12651
|
+
}];
|
|
12652
|
+
} catch {
|
|
12653
|
+
return [];
|
|
12654
|
+
}
|
|
12655
|
+
}
|
|
12139
12656
|
function dedupeAccounts(accounts) {
|
|
12140
12657
|
const byNickname = /* @__PURE__ */ new Map();
|
|
12141
12658
|
const order = [];
|
|
@@ -12234,8 +12751,11 @@ window.__ModuleLoader__.load({
|
|
|
12234
12751
|
* from painting over a newer wave-1 one.
|
|
12235
12752
|
*/
|
|
12236
12753
|
const loadSeq = (0, react.useRef)(0);
|
|
12237
|
-
(0, react.useEffect)(() =>
|
|
12238
|
-
mountedRef.current =
|
|
12754
|
+
(0, react.useEffect)(() => {
|
|
12755
|
+
mountedRef.current = true;
|
|
12756
|
+
return () => {
|
|
12757
|
+
mountedRef.current = false;
|
|
12758
|
+
};
|
|
12239
12759
|
}, []);
|
|
12240
12760
|
const markBusy = (provider, on) => {
|
|
12241
12761
|
setBusy((previous) => {
|
|
@@ -12251,11 +12771,38 @@ window.__ModuleLoader__.load({
|
|
|
12251
12771
|
const channels = (await fetchChannels()).filter((channel) => !REGION_OWNED_CHANNELS.has(channel.id));
|
|
12252
12772
|
const statusAnswer = await cachedProviderStatus(channels.map((channel) => channel.id));
|
|
12253
12773
|
const statuses = providerStatusesFrom(statusAnswer);
|
|
12254
|
-
|
|
12774
|
+
/**
|
|
12775
|
+
* Doubao is added to the scan list by hand.
|
|
12776
|
+
*
|
|
12777
|
+
* `provider.status` counts accounts by walking the PACK's pools, and Doubao has no pack
|
|
12778
|
+
* adapter — so its count is always zero, and a filter keyed on that count drops the
|
|
12779
|
+
* channel before anything can be drawn. A signed-in Doubao session would then exist,
|
|
12780
|
+
* work, and appear nowhere on this page.
|
|
12781
|
+
*/
|
|
12782
|
+
const doubaoAccount = await readDoubaoAccount();
|
|
12783
|
+
const scanProviders = channels.map((channel) => channel.id).filter((id) => (statuses.get(id)?.accountsTotal ?? 0) > 0 || id === "doubao" && doubaoAccount !== void 0);
|
|
12255
12784
|
const perProvider = await Promise.all(scanProviders.map(async (provider) => {
|
|
12256
12785
|
const wantBalances = channels.find((channel) => channel.id === provider)?.credits !== void 0;
|
|
12257
|
-
|
|
12258
|
-
|
|
12786
|
+
/**
|
|
12787
|
+
* Doubao answers from THIS plugin's routes, not from the pack.
|
|
12788
|
+
*
|
|
12789
|
+
* `account.list` and `model.list` are pack RPCs, and the pack has no Doubao adapter —
|
|
12790
|
+
* both answer "unknown provider". Calling them anyway would draw a card reading
|
|
12791
|
+
* "0 accounts, 0 models" for a lane that has one session and six models, and the
|
|
12792
|
+
* empty numbers would look like a failed sign-in.
|
|
12793
|
+
*/
|
|
12794
|
+
const accountsPromise = provider === "doubao" ? Promise.resolve({
|
|
12795
|
+
ok: true,
|
|
12796
|
+
value: { accounts: doubaoAccount === void 0 ? [] : [doubaoAccount] }
|
|
12797
|
+
}) : callPack("account.list", { provider });
|
|
12798
|
+
const modelsPromise = provider === "doubao" ? Promise.resolve({
|
|
12799
|
+
ok: true,
|
|
12800
|
+
value: { models: doubaoListing().map((model) => ({
|
|
12801
|
+
id: model.id,
|
|
12802
|
+
name: model.name,
|
|
12803
|
+
...model.description === void 0 ? {} : { description: model.description }
|
|
12804
|
+
})) }
|
|
12805
|
+
}) : callPack("model.list", { provider });
|
|
12259
12806
|
const [accounts, models] = await Promise.all([accountsPromise.catch(() => refused("account.list failed")), modelsPromise.catch(() => refused("model.list failed"))]);
|
|
12260
12807
|
const modelRows = modelsFrom(models.value);
|
|
12261
12808
|
const modelEmptyBecauseRefused = modelRows.length === 0 && models.ok !== true;
|
|
@@ -12491,6 +13038,22 @@ window.__ModuleLoader__.load({
|
|
|
12491
13038
|
balancePending: true
|
|
12492
13039
|
} : entry));
|
|
12493
13040
|
try {
|
|
13041
|
+
/**
|
|
13042
|
+
* Doubao reports its own balance, from its quota route.
|
|
13043
|
+
*
|
|
13044
|
+
* `credits.balances` is a pack RPC with no Doubao adapter, so it answers "unsupported
|
|
13045
|
+
* provider" and the card printed "no balance reported" under a signed-in account.
|
|
13046
|
+
*/
|
|
13047
|
+
if (provider === "doubao") {
|
|
13048
|
+
const rows = await readDoubaoBalance();
|
|
13049
|
+
setEntries((previous) => previous.map((entry) => entry.channel.id === provider ? {
|
|
13050
|
+
...entry,
|
|
13051
|
+
balancePending: false,
|
|
13052
|
+
balanceError: void 0,
|
|
13053
|
+
balances: rows
|
|
13054
|
+
} : entry));
|
|
13055
|
+
return;
|
|
13056
|
+
}
|
|
12494
13057
|
const envelope = await callPack("credits.balances", force ? {
|
|
12495
13058
|
provider,
|
|
12496
13059
|
force: true
|
|
@@ -12624,6 +13187,26 @@ window.__ModuleLoader__.load({
|
|
|
12624
13187
|
}
|
|
12625
13188
|
markBusy(provider, true);
|
|
12626
13189
|
try {
|
|
13190
|
+
/**
|
|
13191
|
+
* Doubao's account IS the session, so its actions are the session's.
|
|
13192
|
+
*
|
|
13193
|
+
* `account.delete` / `test` / `refresh` are pack RPCs addressed to the pack's credential
|
|
13194
|
+
* store, and Doubao has no entry there — every one of them answered "unsupported
|
|
13195
|
+
* provider", so the buttons did nothing and the row could not be removed.
|
|
13196
|
+
*/
|
|
13197
|
+
if (provider === "doubao") {
|
|
13198
|
+
if (action === "delete") await fetch(POOL_DOUBAO_SESSION_PATH, {
|
|
13199
|
+
method: "DELETE",
|
|
13200
|
+
credentials: "same-origin"
|
|
13201
|
+
});
|
|
13202
|
+
else if (action === "refresh") await fetch(POOL_DOUBAO_QUOTA_PATH, { credentials: "same-origin" });
|
|
13203
|
+
else if (action === "test") await fetch(POOL_DOUBAO_SESSION_PATH, { credentials: "same-origin" });
|
|
13204
|
+
if (!mountedRef.current) return;
|
|
13205
|
+
invalidatePoolSnapshot();
|
|
13206
|
+
await load();
|
|
13207
|
+
setNotice(action === "delete" ? "已删除豆包会话" : "已刷新");
|
|
13208
|
+
return;
|
|
13209
|
+
}
|
|
12627
13210
|
const enabledNow = entries.find((item) => item.channel.id === provider)?.accounts.find((account) => account.id === accountId)?.enabled !== false;
|
|
12628
13211
|
const envelope = await callPack(action === "refresh" ? "account.refresh" : action === "test" ? "account.test" : action === "delete" ? "account.delete" : "account.update", action === "toggle" ? {
|
|
12629
13212
|
accountId,
|
|
@@ -13470,7 +14053,7 @@ window.__ModuleLoader__.load({
|
|
|
13470
14053
|
*
|
|
13471
14054
|
* @module dsh-xdpool/version
|
|
13472
14055
|
*/
|
|
13473
|
-
const POOL_VERSION = "2.
|
|
14056
|
+
const POOL_VERSION = "2.7.0";
|
|
13474
14057
|
//#endregion
|
|
13475
14058
|
//#region src/client/PoolCard.tsx
|
|
13476
14059
|
/**
|
|
@@ -13864,6 +14447,10 @@ window.__ModuleLoader__.load({
|
|
|
13864
14447
|
id: "gateway",
|
|
13865
14448
|
label: t?.("shell.tabGateway") ?? "Gateway"
|
|
13866
14449
|
},
|
|
14450
|
+
{
|
|
14451
|
+
id: "doubao",
|
|
14452
|
+
label: t?.("shell.tabDoubao") ?? "Doubao"
|
|
14453
|
+
},
|
|
13867
14454
|
{
|
|
13868
14455
|
id: "backup",
|
|
13869
14456
|
label: t?.("shell.tabBackup") ?? "Backup"
|
|
@@ -13916,7 +14503,7 @@ window.__ModuleLoader__.load({
|
|
|
13916
14503
|
* Whether a region's model pane is showing the WHOLE roster.
|
|
13917
14504
|
*
|
|
13918
14505
|
* Per region, and default off, because the pane opens on a card the user
|
|
13919
|
-
* scrolled to reach:
|
|
14506
|
+
* scrolled to reach: thirteen full rows of mostly-disabled models pushed
|
|
13920
14507
|
* everything else a screen and a half further down (the reported "无限往下
|
|
13921
14508
|
* 续"). The enabled rows are what "my models" means; the rest are one click
|
|
13922
14509
|
* away and the button says how many there are.
|
|
@@ -14753,7 +15340,7 @@ window.__ModuleLoader__.load({
|
|
|
14753
15340
|
children: page === "aggregate" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AggregatePage, { t }) : page === "channels" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ChannelsPage, { t }) : page === "ledger" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LedgerPage, {
|
|
14754
15341
|
t,
|
|
14755
15342
|
usage
|
|
14756
|
-
}) : page === "routing" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RoutingPage, { t }) : page === "gateway" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GatewayPage, { t }) : page === "backup" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BackupPanel, { t }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
15343
|
+
}) : page === "routing" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RoutingPage, { t }) : page === "doubao" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DoubaoPage, { t }) : page === "gateway" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GatewayPage, { t }) : page === "backup" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BackupPanel, { t }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
14757
15344
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("style", { children: POOL_CARD_CSS }),
|
|
14758
15345
|
usage === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
14759
15346
|
className: "dsm-xdpool-card dsm-xdpool-usage",
|
|
@@ -16863,6 +17450,14 @@ window.__ModuleLoader__.load({
|
|
|
16863
17450
|
"agg.noKeyNeeded": "No key needed",
|
|
16864
17451
|
"agg.models": "{count} models",
|
|
16865
17452
|
"agg.unsupported": "This vendor signs in via OAuth/ADC, which this lane cannot drive.",
|
|
17453
|
+
"doubao.ready": "Signed in; the session is stored locally",
|
|
17454
|
+
"doubao.sub": "One browser sign-in, then the chat and work-task models are available",
|
|
17455
|
+
"doubao.signIn": "Sign in with a browser",
|
|
17456
|
+
"doubao.signOut": "Sign out",
|
|
17457
|
+
"doubao.waiting": "Waiting for sign-in…",
|
|
17458
|
+
"doubao.refresh": "Refresh quota",
|
|
17459
|
+
"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.",
|
|
17460
|
+
"doubao.modelsNote": "The models are in the conversation picker: Doubao Quick / 2.1 Turbo / 2.1 Lite / 2.1 Pro / Auto / Image.",
|
|
16866
17461
|
"agg.listingYes": "Model list available",
|
|
16867
17462
|
"agg.saved": "Saved",
|
|
16868
17463
|
"agg.cleared": "Cleared",
|
|
@@ -16961,6 +17556,7 @@ window.__ModuleLoader__.load({
|
|
|
16961
17556
|
"chan.pending": "The login channels are still loading…",
|
|
16962
17557
|
"chan.unavailable": "The login channels could not start on this host.",
|
|
16963
17558
|
"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.",
|
|
17559
|
+
"chan.ownedElsewhereRow": "Sign in on the “Our Free Model” page",
|
|
16964
17560
|
"chan.empty": "No channel is connected yet.",
|
|
16965
17561
|
"shell.brand": "XD Pool",
|
|
16966
17562
|
"shell.star": "Star",
|
|
@@ -16987,6 +17583,7 @@ window.__ModuleLoader__.load({
|
|
|
16987
17583
|
"shell.tabRouting": "Routing",
|
|
16988
17584
|
"shell.subRouting": "Chains that try models in order, so one busy or rate-limited model falls through to the next.",
|
|
16989
17585
|
"shell.tabGateway": "Gateway",
|
|
17586
|
+
"shell.tabDoubao": "Doubao",
|
|
16990
17587
|
"shell.tabBackup": "Backup",
|
|
16991
17588
|
"shell.subGateway": "Open the pool to the other devices on your network.",
|
|
16992
17589
|
"gw.title": "Gateway",
|
|
@@ -17459,6 +18056,14 @@ window.__ModuleLoader__.load({
|
|
|
17459
18056
|
"agg.noKeyNeeded": "无需 key",
|
|
17460
18057
|
"agg.models": "{count} 个模型",
|
|
17461
18058
|
"agg.unsupported": "该厂商需要 OAuth/ADC 授权,这条通道暂时接不了。",
|
|
18059
|
+
"doubao.ready": "已登录,会话保存在本机",
|
|
18060
|
+
"doubao.sub": "浏览器扫码登录一次,对话与工作任务模型都能用",
|
|
18061
|
+
"doubao.signIn": "扫码登录",
|
|
18062
|
+
"doubao.signOut": "退出登录",
|
|
18063
|
+
"doubao.waiting": "等待登录…",
|
|
18064
|
+
"doubao.refresh": "刷新额度",
|
|
18065
|
+
"doubao.why": "豆包已关闭第三方扫码入口(服务端返回 2035),所以这里拉起一个浏览器窗口:在窗口里扫码或填手机号,登录成功后会话自动取回并保存在本机。",
|
|
18066
|
+
"doubao.modelsNote": "模型在对话的模型选择器里:豆包 快速 / 2.1 Turbo / 2.1 Lite / 2.1 Pro / 自动 / 生图。",
|
|
17462
18067
|
"agg.listingYes": "支持拉取模型列表",
|
|
17463
18068
|
"agg.saved": "已保存",
|
|
17464
18069
|
"agg.cleared": "已清除",
|
|
@@ -17557,6 +18162,7 @@ window.__ModuleLoader__.load({
|
|
|
17557
18162
|
"chan.pending": "扫码登录通道正在加载…",
|
|
17558
18163
|
"chan.unavailable": "本机上扫码登录通道没能启动。",
|
|
17559
18164
|
"chan.ownedElsewhere": "这些扫码登录通道已经由另一个插件接管了——同样这十三种登录方式,在它自己的页面上点一下就能用。",
|
|
18165
|
+
"chan.ownedElsewhereRow": "在「我们的免费模型」里登录",
|
|
17560
18166
|
"chan.empty": "还没有任何渠道连上来。",
|
|
17561
18167
|
"shell.brand": "XD Pool",
|
|
17562
18168
|
"shell.star": "点Star",
|
|
@@ -17583,6 +18189,7 @@ window.__ModuleLoader__.load({
|
|
|
17583
18189
|
"shell.tabRouting": "路由",
|
|
17584
18190
|
"shell.subRouting": "把几个模型串成一条链,按顺序试;一个忙了或被限流,就自动落到下一个。",
|
|
17585
18191
|
"shell.tabGateway": "网关",
|
|
18192
|
+
"shell.tabDoubao": "豆包",
|
|
17586
18193
|
"shell.tabBackup": "备份",
|
|
17587
18194
|
"shell.subGateway": "把账号池开放给同网络里的其它设备。",
|
|
17588
18195
|
"gw.title": "网关",
|