dsh-xdpool 3.0.3 → 3.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,32 @@
1
1
  # Changelog
2
2
  本项目的所有重要变更都会记录在此文件。
3
3
  版本号遵循 [语义化版本](https://semver.org/lang/zh-CN/)。
4
+ ## 3.0.4 — 账号卡回来了,签到回来了,重复分组没了
5
+
6
+ > 3.0 重构砍掉的三块界面与两处数据源,这一版接回来。
7
+
8
+ ### 账号卡与每日签到回到账号池页
9
+
10
+ 3.0 重做账号池时,渲染插件池账号的那一段被整段删掉,`AccountBlock` 组件却原样留着,
11
+ 于是:桌面客户端读到的账号在界面上消失(用户以为「更新后账号丢了」),每日签到按钮也
12
+ 跟着没了(它就在这张卡里)。现在两个区域各自渲染账号卡:余额、积分明细、签到、停用、
13
+ 忽略、首选、积分保底都在原位。
14
+
15
+ **卡上带「正在使用」**:卡片本来就有一个 `serving` 状态,那是池子上一次真正服务过的
16
+ 账号,重新挂回后它就显示出来了 —— 不用再猜「现在是谁在跑」。
17
+
18
+ ### 模型选择器里国内版/国际版不再各出现两次
19
+
20
+ 两个 lane 有两条注册来源:本插件注册 `xdpool` / `xdpool-global`,pack 注册
21
+ `buddy` / `workbuddy`。插件启动时按「自己池里有没有账号」写下的让位开关,pack 侧
22
+ 从来没有读过,于是四个分组同时出现。现在 pack 在注册层就跳过这两个 lane;池里一个
23
+ 账号都没有的机器不写这个开关,pack 照旧提供目录,不会变空。
24
+
25
+ ### 「登录通道」页看得见插件池的账号
26
+
27
+ 那一页只问 pack 的账号表,而桌面客户端读到的账号活在插件自己的池里,两套池子互不
28
+ 可见 —— 主池 5 个账号,页面上写着「1 个」。现在两边合并显示。
29
+
4
30
  ## 3.0.3 — 豆包档位、全关、立即执行、关闭按钮
5
31
 
6
32
  > 四件事,都是能用眼睛立刻验的。
package/README.md CHANGED
@@ -9,13 +9,14 @@
9
9
 
10
10
  ## 更新公告
11
11
 
12
- **3.0.3** — 豆包档位、全关、立即执行、右上角关闭。
12
+ **3.0.4** — 账号卡回来了,签到回来了,重复分组没了。
13
13
 
14
- - 豆包每个模型用自己发布的思考档位(含「极高 / 最高」),选中什么就发什么
15
- - 豆包「全关」之后模型选择器里真的会空,不再残留全部模型
16
- - 积分自动化一行加了「立即执行」,随时跑一轮领取
17
- - 右上角加了关闭按钮,点一下关掉设置对话框
18
- - 其余反馈(账号池账号卡、登录通道账号数、模型重复分组等)正在按 issue 逐条处理
14
+ - 账号池页重新显示插件池账号:余额、积分明细、每日签到、停用/忽略/首选都在原位
15
+ - 账号卡上标出「正在使用」:池子上一次真正服务过的那个账号
16
+ - 模型选择器里「国内版 / 国际版」不再各出现两次
17
+ - 「登录通道」页把插件池的账号也算进来,不再写着 1 个而实际有 5 个
18
+
19
+ **3.0.3** — 豆包每个模型用自己的思考档位、全关真的会空、积分自动化「立即执行」、右上角关闭按钮。
19
20
 
20
21
  **3.0.2 / 3.0.1** — 自动更新不再变成「本地开发」;护眼绿亮色模式与五条反馈(明细见 CHANGELOG)。
21
22
 
package/lib/client.js CHANGED
@@ -41,6 +41,8 @@ window.__ModuleLoader__.load({
41
41
  //#region src/status-paths.ts
42
42
  const POOL_STATUS_PATH = "/plugins/dsh-xdpool/status";
43
43
  const POOL_CATALOG_REFRESH_PATH = "/plugins/dsh-xdpool/models/refresh";
44
+ const POOL_CHECKIN_PATH = "/plugins/dsh-xdpool/checkin";
45
+ const POOL_ACCOUNT_IGNORE_PATH = "/plugins/dsh-xdpool/accounts/ignored";
44
46
  const POOL_AUTOMATION_RUN_PATH = "/plugins/dsh-xdpool/automation/run";
45
47
  const POOL_UPDATE_CHECK_PATH = "/plugins/dsh-xdpool/update";
46
48
  const POOL_MARVIS_SESSION_PATH = "/plugins/dsh-xdpool/marvis/session";
@@ -76,7 +78,9 @@ window.__ModuleLoader__.load({
76
78
  const POOL_AUTOCLAW_CN_SESSION_PATH = "/plugins/dsh-xdpool/autoclaw-cn/session";
77
79
  const POOL_AUTOCLAW_CN_WALLET_PATH = "/plugins/dsh-xdpool/autoclaw-cn/wallet";
78
80
  const POOL_UPDATE_INSTALL_PATH = "/plugins/dsh-xdpool/update/install";
81
+ const POOL_CREDIT_RESERVE_PATH = "/plugins/dsh-xdpool/accounts/credit-reserve";
79
82
  const POOL_CREDITS_SPEND_PATH = "/plugins/dsh-xdpool/credits/spend";
83
+ const POOL_ACCOUNT_PREFER_PATH = "/plugins/dsh-xdpool/accounts/preferred";
80
84
  const POOL_AGGREGATE_PATH = "/plugins/dsh-xdpool/aggregate";
81
85
  const POOL_AGGREGATE_SAVE_PATH = "/plugins/dsh-xdpool/aggregate/save";
82
86
  const POOL_AGGREGATE_TEST_PATH = "/plugins/dsh-xdpool/aggregate/test";
@@ -136,7 +140,7 @@ window.__ModuleLoader__.load({
136
140
  const POOL_NAV_ICON_MASK_URL = `data:image/svg+xml;utf8,${encodeURIComponent(POOL_NAV_ICON_SVG)}`;
137
141
  //#endregion
138
142
  //#region src/version.ts
139
- const POOL_VERSION = "3.0.3";
143
+ const POOL_VERSION = "3.0.4";
140
144
  function compareVersions(left, right) {
141
145
  const parse = (value) => {
142
146
  const [core, ...rest] = value.trim().replace(/^v/u, "").split("-");
@@ -12180,11 +12184,31 @@ window.__ModuleLoader__.load({
12180
12184
  if (mounted.current) setError(zh$2(cause instanceof Error ? cause.message : void 0, "读取登录通道失败"));
12181
12185
  }
12182
12186
  }, []);
12187
+ const loadPoolAccounts = (0, react.useCallback)(async () => {
12188
+ return (await Promise.all([["buddy", "/plugins/dsh-xdpool/status?region=cn"], ["workbuddy", "/plugins/dsh-xdpool/status?region=global"]].map(async ([provider, route]) => {
12189
+ try {
12190
+ const response = await fetch(route, {
12191
+ credentials: "same-origin",
12192
+ headers: { accept: "application/json" }
12193
+ });
12194
+ if (!response.ok) return [];
12195
+ const body = await response.json().catch(() => void 0);
12196
+ return (Array.isArray(body?.accounts) ? body.accounts : []).filter((row) => typeof row.id === "string" && row.id !== "").map((row) => ({
12197
+ id: row.id,
12198
+ provider,
12199
+ nickname: typeof row.nickname === "string" && row.nickname !== "" ? row.nickname : typeof row.label === "string" && row.label !== "" ? row.label : row.id,
12200
+ enabled: true
12201
+ }));
12202
+ } catch {
12203
+ return [];
12204
+ }
12205
+ }))).flat();
12206
+ }, []);
12183
12207
  const loadConnected = (0, react.useCallback)(async () => {
12184
12208
  const roster = await fetchChannels();
12185
12209
  const statuses = providerStatusesFrom(await callPack("provider.status", { providers: roster.map((channel) => channel.id) }));
12186
12210
  const connectedIds = roster.map((channel) => channel.id).filter((id) => (statuses.get(id)?.accountsTotal ?? 0) > 0);
12187
- const accounts = (await Promise.all(connectedIds.map((id) => callPack("account.list", { provider: id })))).flatMap(accountsFrom);
12211
+ const accounts = [...(await Promise.all(connectedIds.map((id) => callPack("account.list", { provider: id })))).flatMap(accountsFrom), ...await loadPoolAccounts()];
12188
12212
  if (mounted.current) setConnected(accounts);
12189
12213
  return accounts;
12190
12214
  }, []);
@@ -15176,6 +15200,27 @@ window.__ModuleLoader__.load({
15176
15200
  })
15177
15201
  });
15178
15202
  //#endregion
15203
+ //#region src/siblings.ts
15204
+ function paidSiblingOf(model, models) {
15205
+ let best;
15206
+ for (const candidate of models) {
15207
+ if (candidate.id === model.id) continue;
15208
+ if (candidate.name !== model.name) continue;
15209
+ const multiplier = candidate.multiplier;
15210
+ if (multiplier === void 0 || multiplier <= 0) continue;
15211
+ if (best === void 0 || multiplier < best.multiplier) best = {
15212
+ id: candidate.id,
15213
+ name: candidate.name,
15214
+ multiplier
15215
+ };
15216
+ }
15217
+ return best;
15218
+ }
15219
+ function paidAlternativeFor(model, models) {
15220
+ if (model.multiplier !== 0) return void 0;
15221
+ return paidSiblingOf(model, models);
15222
+ }
15223
+ //#endregion
15179
15224
  //#region src/client/backup-crypto.ts
15180
15225
  const ENCRYPTED_FORMAT = "dsh-xdpool/backup-encrypted";
15181
15226
  const ITERATIONS = 31e4;
@@ -16003,12 +16048,54 @@ window.__ModuleLoader__.load({
16003
16048
  //#endregion
16004
16049
  //#region src/client/PoolCard.tsx
16005
16050
  const POLL_INTERVAL_MS = 3e4;
16051
+ function formatNumber(value) {
16052
+ if (value === void 0) return "–";
16053
+ return new Intl.NumberFormat(void 0, { maximumFractionDigits: 0 }).format(value);
16054
+ }
16055
+ function formatTime(value) {
16056
+ return new Intl.DateTimeFormat(void 0, {
16057
+ month: "2-digit",
16058
+ day: "2-digit",
16059
+ hour: "2-digit",
16060
+ minute: "2-digit"
16061
+ }).format(new Date(value));
16062
+ }
16063
+ function formatDateTime(value) {
16064
+ if (value === void 0) return "";
16065
+ const ms = Date.parse(value);
16066
+ if (Number.isNaN(ms)) return value;
16067
+ return new Intl.DateTimeFormat(void 0, {
16068
+ month: "2-digit",
16069
+ day: "2-digit",
16070
+ hour: "2-digit",
16071
+ minute: "2-digit"
16072
+ }).format(new Date(ms));
16073
+ }
16006
16074
  const AUTOMATION_POLL_MS = 2e3;
16007
16075
  const AUTOMATION_POLL_ATTEMPTS = 90;
16008
16076
  function hoursOrDefault(configured, fallback) {
16009
16077
  return configured !== void 0 && configured.length > 0 ? [...configured] : [...fallback];
16010
16078
  }
16011
16079
  const REGION_CARDS = ["cn", "global"];
16080
+ function formatExpiry(ms) {
16081
+ if (ms === void 0 || !Number.isFinite(ms)) return "";
16082
+ return new Intl.DateTimeFormat(void 0, {
16083
+ month: "2-digit",
16084
+ day: "2-digit",
16085
+ hour: "2-digit",
16086
+ minute: "2-digit",
16087
+ hour12: false
16088
+ }).format(new Date(ms));
16089
+ }
16090
+ function daysUntil(ms) {
16091
+ if (ms === void 0 || !Number.isFinite(ms)) return void 0;
16092
+ return Math.max(0, Math.floor((ms - Date.now()) / 864e5));
16093
+ }
16094
+ function isExpiringSoon(pack) {
16095
+ if (pack.monthly === true) return false;
16096
+ const days = daysUntil(pack.expiresAtMs);
16097
+ return days !== void 0 && days <= 3;
16098
+ }
16012
16099
  function PoolCard({ t, settingsScope }) {
16013
16100
  const settingsWritable = settingsScope?.getSnapshot().writable === true;
16014
16101
  const [sidebarRow, setSidebarRowState] = (0, react.useState)(() => readSidebarRow(settingsScope));
@@ -16198,7 +16285,96 @@ window.__ModuleLoader__.load({
16198
16285
  controller.abort();
16199
16286
  };
16200
16287
  }, [refreshUsage]);
16288
+ const claimCheckin = async (region, accountId) => {
16289
+ setCheckinBusyId(accountId);
16290
+ setFlash(void 0);
16291
+ try {
16292
+ const response = await fetch(POOL_CHECKIN_PATH, {
16293
+ method: "POST",
16294
+ headers: {
16295
+ accept: "application/json",
16296
+ "content-type": "application/json"
16297
+ },
16298
+ credentials: "same-origin",
16299
+ body: JSON.stringify({ accountId })
16300
+ });
16301
+ const body = await response.json().catch(() => void 0);
16302
+ if (!response.ok) throw new Error(body?.error ?? `HTTP ${response.status}`);
16303
+ await refresh(region);
16304
+ const credit = body?.claim?.credit ?? 0;
16305
+ if (mounted.current) setFlash(t?.("row.checkinClaimedReward", { credit: formatNumber(credit) }) ?? `Claimed +${formatNumber(credit)} credits`);
16306
+ } catch (cause) {
16307
+ if (mounted.current) setError(cause instanceof Error ? cause.message : String(cause));
16308
+ } finally {
16309
+ if (mounted.current) setCheckinBusyId(void 0);
16310
+ }
16311
+ };
16201
16312
  const statusOf = (region) => statusByRegion[region];
16313
+ const toggleAccountDisabled = async (region, accountId, disabled) => {
16314
+ const write = settingsScope?.set;
16315
+ if (write === void 0) {
16316
+ setError(t?.("row.modelsSaveError", { message: "settings scope is read-only" }) ?? "settings scope is read-only");
16317
+ return;
16318
+ }
16319
+ setAccountBusyId(accountId);
16320
+ setFlash(void 0);
16321
+ try {
16322
+ const current = (statusOf(region)?.accounts ?? []).filter((account) => account.disabled === true).map((account) => account.id);
16323
+ const next = disabled ? current.includes(accountId) ? current : [...current, accountId] : current.filter((id) => id !== accountId);
16324
+ await write.call(settingsScope, "disabledAccountIds", next);
16325
+ await refresh(region);
16326
+ } catch (cause) {
16327
+ const message = cause instanceof Error ? cause.message : String(cause);
16328
+ if (mounted.current) setError(t?.("row.accountToggleError", { message }) ?? "Could not switch the account: " + message);
16329
+ } finally {
16330
+ if (mounted.current) setAccountBusyId(void 0);
16331
+ }
16332
+ };
16333
+ const setAccountIgnored = async (region, accountId, ignored) => {
16334
+ setAccountBusyId(accountId);
16335
+ setFlash(void 0);
16336
+ try {
16337
+ const response = await fetch(POOL_ACCOUNT_IGNORE_PATH, {
16338
+ method: "POST",
16339
+ headers: { "Content-Type": "application/json" },
16340
+ body: JSON.stringify({
16341
+ accountId,
16342
+ ignored
16343
+ })
16344
+ });
16345
+ if (!response.ok) {
16346
+ const detail = await response.json().catch(() => ({}));
16347
+ throw new Error(detail.error ?? `HTTP ${response.status}`);
16348
+ }
16349
+ await refresh(region);
16350
+ } catch (cause) {
16351
+ const message = cause instanceof Error ? cause.message : String(cause);
16352
+ if (mounted.current) setError(t?.("row.accountIgnoreError", { message }) ?? "Could not change the ignore list: " + message);
16353
+ } finally {
16354
+ if (mounted.current) setAccountBusyId(void 0);
16355
+ }
16356
+ };
16357
+ const setPreferredAccount = async (region, accountId) => {
16358
+ setAccountBusyId(accountId ?? "none");
16359
+ setFlash(void 0);
16360
+ try {
16361
+ const response = await fetch(POOL_ACCOUNT_PREFER_PATH, {
16362
+ method: "POST",
16363
+ headers: { "Content-Type": "application/json" },
16364
+ body: JSON.stringify({ accountId })
16365
+ });
16366
+ if (!response.ok) {
16367
+ const detail = await response.json().catch(() => ({}));
16368
+ throw new Error(detail.error ?? `HTTP ${response.status}`);
16369
+ }
16370
+ await Promise.all(REGION_CARDS.map((other) => refresh(other)));
16371
+ } catch (cause) {
16372
+ const message = cause instanceof Error ? cause.message : String(cause);
16373
+ if (mounted.current) setError(t?.("row.accountPreferError", { message }) ?? "Could not set the preferred account: " + message);
16374
+ } finally {
16375
+ if (mounted.current) setAccountBusyId(void 0);
16376
+ }
16377
+ };
16202
16378
  const setSidebarRow = async (next) => {
16203
16379
  const write = settingsScope?.set;
16204
16380
  if (write === void 0) {
@@ -16284,6 +16460,34 @@ window.__ModuleLoader__.load({
16284
16460
  }
16285
16461
  }
16286
16462
  };
16463
+ const saveCreditReserve = async (region, accountId, reserve) => {
16464
+ setReserveBusy(accountId);
16465
+ setFlash(void 0);
16466
+ try {
16467
+ const response = await fetch(POOL_CREDIT_RESERVE_PATH, {
16468
+ method: "POST",
16469
+ headers: {
16470
+ "accept": "application/json",
16471
+ "content-type": "application/json"
16472
+ },
16473
+ credentials: "same-origin",
16474
+ body: JSON.stringify({
16475
+ accountId,
16476
+ reserve
16477
+ })
16478
+ });
16479
+ const body = await response.json();
16480
+ if (!response.ok) throw new Error(body.error ?? `HTTP ${response.status}`);
16481
+ await refresh(region);
16482
+ if (mounted.current) setFlash(reserve > 0 ? t?.("row.reserveSaved", { credits: reserve }) ?? `Keeping ${reserve} credits` : t?.("row.reserveCleared") ?? "Reserve cleared");
16483
+ return true;
16484
+ } catch (cause) {
16485
+ if (mounted.current) setError(cause instanceof Error ? cause.message : String(cause));
16486
+ return false;
16487
+ } finally {
16488
+ if (mounted.current) setReserveBusy(void 0);
16489
+ }
16490
+ };
16287
16491
  t?.("row.title");
16288
16492
  t?.("row.desc");
16289
16493
  return (0, react_jsx_runtime.jsx)(PoolShell, {
@@ -16321,10 +16525,48 @@ window.__ModuleLoader__.load({
16321
16525
  children: page === "aggregate" ? (0, react_jsx_runtime.jsx)(AggregatePage, { t }) : page === "channels" ? (0, react_jsx_runtime.jsx)(ChannelsPage, { t }) : page === "ledger" ? (0, react_jsx_runtime.jsx)(LedgerPage, {
16322
16526
  t,
16323
16527
  usage
16324
- }) : page === "routing" ? (0, react_jsx_runtime.jsx)(RoutingPage, { t }) : page === "gateway" ? (0, react_jsx_runtime.jsx)(GatewayPage, { t }) : page === "backup" ? (0, react_jsx_runtime.jsx)(BackupPanel, { t }) : (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: (0, react_jsx_runtime.jsx)("div", {
16528
+ }) : page === "routing" ? (0, react_jsx_runtime.jsx)(RoutingPage, { t }) : page === "gateway" ? (0, react_jsx_runtime.jsx)(GatewayPage, { t }) : page === "backup" ? (0, react_jsx_runtime.jsx)(BackupPanel, { t }) : (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: (0, react_jsx_runtime.jsxs)("div", {
16325
16529
  className: "dsm-xdpool-regions dsm-xdpool-region-grid",
16326
16530
  style: { display: "contents" },
16327
- children: (0, react_jsx_runtime.jsx)(ChannelPoolSection, {
16531
+ children: [["cn", "global"].map((region) => {
16532
+ const here = statusOf(region);
16533
+ const rows = here?.accounts ?? [];
16534
+ if (rows.length === 0) return null;
16535
+ return (0, react_jsx_runtime.jsxs)("section", {
16536
+ className: "sec dsm-xdpool-accounts",
16537
+ children: [(0, react_jsx_runtime.jsx)("div", {
16538
+ className: "sec-head",
16539
+ children: (0, react_jsx_runtime.jsxs)("span", {
16540
+ className: "sec-title",
16541
+ children: [region === "cn" ? t?.("row.tabCn") ?? "CN" : t?.("row.tabGlobal") ?? "Global", ` · ${String(rows.length)}`]
16542
+ })
16543
+ }), (0, react_jsx_runtime.jsx)("div", {
16544
+ className: "accts",
16545
+ children: rows.map((account) => (0, react_jsx_runtime.jsx)(AccountBlock, {
16546
+ account,
16547
+ models: here?.models ?? [],
16548
+ t,
16549
+ ...checkinBusyId === void 0 ? {} : { checkinBusyId },
16550
+ onClaimCheckin: (id) => {
16551
+ claimCheckin(region, id);
16552
+ },
16553
+ ...accountBusyId === void 0 ? {} : { accountBusyId },
16554
+ onToggleDisabled: (id, disabled) => {
16555
+ toggleAccountDisabled(region, id, disabled);
16556
+ },
16557
+ onIgnoreAccount: (id) => {
16558
+ setAccountIgnored(region, id, true);
16559
+ },
16560
+ onPreferAccount: (id) => {
16561
+ setPreferredAccount(region, id);
16562
+ },
16563
+ onSaveCreditReserve: (id, reserve) => saveCreditReserve(region, id, reserve),
16564
+ ...reserveBusy === void 0 ? {} : { reserveBusyId: reserveBusy },
16565
+ serving: here?.activeAccountId === account.id
16566
+ }, account.id))
16567
+ })]
16568
+ }, region);
16569
+ }), (0, react_jsx_runtime.jsx)(ChannelPoolSection, {
16328
16570
  t,
16329
16571
  active: selectedChannel,
16330
16572
  onAddAccount: () => {
@@ -16346,10 +16588,350 @@ window.__ModuleLoader__.load({
16346
16588
  className: "hint",
16347
16589
  children: t?.("row.error", { message: error }) ?? `Pool status unavailable: ${error}`
16348
16590
  })] })
16349
- })
16591
+ })]
16350
16592
  }) })
16351
16593
  });
16352
16594
  }
16595
+ function AccountBlock({ account, models, t, checkinBusyId, onClaimCheckin, accountBusyId, onToggleDisabled, onIgnoreAccount, onPreferAccount, onSaveCreditReserve, reserveBusyId, serving }) {
16596
+ const isDisabled = account.disabled === true;
16597
+ const isPreferred = account.preferred === true;
16598
+ const isCooling = account.cooling === true;
16599
+ const isDead = account.credentialDead === true;
16600
+ const cooldownUntil = account.cooldownUntil !== void 0 ? Date.parse(account.cooldownUntil) : void 0;
16601
+ const modelCooldowns = account.modelCooldowns ?? [];
16602
+ const tag = isDead ? {
16603
+ text: t?.("row.credentialDeadTag") ?? "Sign-in rejected",
16604
+ cls: "pill"
16605
+ } : isCooling ? {
16606
+ text: t?.("row.cooling") ?? "Cooling",
16607
+ cls: "pill"
16608
+ } : null;
16609
+ return (0, react_jsx_runtime.jsxs)("div", {
16610
+ className: isDisabled ? "is-off" : "ch",
16611
+ "data-serving": serving === true ? "true" : void 0,
16612
+ children: [(0, react_jsx_runtime.jsxs)("div", {
16613
+ className: "ch-head",
16614
+ children: [
16615
+ (0, react_jsx_runtime.jsx)("span", {
16616
+ className: "ch-title",
16617
+ children: account.label
16618
+ }),
16619
+ serving === true ? (0, react_jsx_runtime.jsxs)("span", {
16620
+ className: "acct-head",
16621
+ children: [(0, react_jsx_runtime.jsx)("span", { className: "acct-dot" }), (0, react_jsx_runtime.jsx)("span", {
16622
+ className: "acct-name",
16623
+ children: t?.("row.currentAccount") ?? "In use now"
16624
+ })]
16625
+ }) : null,
16626
+ tag === null ? null : (0, react_jsx_runtime.jsx)("span", {
16627
+ className: tag.cls,
16628
+ children: tag.text
16629
+ }),
16630
+ (0, react_jsx_runtime.jsxs)("button", {
16631
+ type: "button",
16632
+ className: isPreferred ? "is-on" : "tiny",
16633
+ "aria-pressed": isPreferred,
16634
+ title: isPreferred ? t?.("row.accountPreferClearHint") ?? "Stop preferring this account; the distribution strategy decides again" : t?.("row.accountPreferHint") ?? "Try this account first while it stays healthy",
16635
+ disabled: accountBusyId === account.id || accountBusyId === "none",
16636
+ onClick: () => {
16637
+ onPreferAccount(isPreferred ? null : account.id);
16638
+ },
16639
+ children: [(0, react_jsx_runtime.jsx)("span", {
16640
+ className: "tiny",
16641
+ "aria-hidden": "true",
16642
+ children: "★"
16643
+ }), isPreferred ? t?.("row.accountPreferOn") ?? "Preferred" : t?.("row.accountPrefer") ?? "Prefer"]
16644
+ }),
16645
+ (0, react_jsx_runtime.jsxs)("button", {
16646
+ type: "button",
16647
+ role: "switch",
16648
+ "aria-checked": !isDisabled,
16649
+ className: isDisabled ? "sw" : "is-on",
16650
+ title: t?.("row.accountToggleHint") ?? "Enable this account (uncheck to keep it out of the pool)",
16651
+ disabled: accountBusyId === account.id,
16652
+ onClick: () => {
16653
+ onToggleDisabled(account.id, !isDisabled);
16654
+ },
16655
+ children: [(0, react_jsx_runtime.jsx)("span", { className: "acct-dot" }), isDisabled ? t?.("row.accountOff") ?? "Disabled" : t?.("row.accountInRotation") ?? "Enabled"]
16656
+ }),
16657
+ (0, react_jsx_runtime.jsx)("button", {
16658
+ type: "button",
16659
+ className: "ch-count",
16660
+ title: t?.("row.accountIgnoreHint") ?? "Remove this account from the pool for good",
16661
+ disabled: accountBusyId === account.id,
16662
+ onClick: () => {
16663
+ onIgnoreAccount(account.id);
16664
+ },
16665
+ children: t?.("row.accountIgnore") ?? "Remove"
16666
+ })
16667
+ ]
16668
+ }), (0, react_jsx_runtime.jsxs)("div", {
16669
+ className: "ch-titles",
16670
+ children: [
16671
+ (0, react_jsx_runtime.jsxs)("div", {
16672
+ className: "ch-titles",
16673
+ children: [
16674
+ account.expiresAt !== void 0 ? (0, react_jsx_runtime.jsx)("span", {
16675
+ className: "ch-org",
16676
+ children: t?.("row.tokenExpiry", { time: formatDateTime(account.expiresAt) }) ?? `token ${formatDateTime(account.expiresAt)}`
16677
+ }) : null,
16678
+ isCooling && cooldownUntil !== void 0 && !Number.isNaN(cooldownUntil) ? (0, react_jsx_runtime.jsxs)("span", {
16679
+ className: "ch-org",
16680
+ children: [
16681
+ t?.("row.cooldownUntil", { time: formatTime(cooldownUntil) }) ?? `until ${formatTime(cooldownUntil)}`,
16682
+ " · ",
16683
+ t?.("row.cooldownHits", { hits: account.rateLimitHits ?? 0 }) ?? `${account.rateLimitHits ?? 0} hit(s)`
16684
+ ]
16685
+ }) : null,
16686
+ isDead ? (0, react_jsx_runtime.jsx)("span", {
16687
+ className: "ch-org",
16688
+ children: t?.("row.credentialDeadHint") ?? "Sign in again in the WorkBuddy desktop app to restore it"
16689
+ }) : null,
16690
+ modelCooldowns.length > 0 ? (0, react_jsx_runtime.jsx)("div", {
16691
+ className: "ch-note",
16692
+ children: modelCooldowns.map((mc) => {
16693
+ const coolingModel = models.find((model) => model.id === mc.modelId);
16694
+ const twin = coolingModel === void 0 ? void 0 : paidAlternativeFor(coolingModel, models);
16695
+ return (0, react_jsx_runtime.jsxs)("span", {
16696
+ className: "badge",
16697
+ children: [t?.("row.modelCooling", {
16698
+ model: mc.modelId,
16699
+ time: formatDateTime(mc.until)
16700
+ }) ?? `${mc.modelId} cooling to ${formatDateTime(mc.until)}`, twin === void 0 ? null : (0, react_jsx_runtime.jsx)("span", {
16701
+ className: "badge",
16702
+ title: t?.("row.paidTwinHint") ?? "Same model, paid row",
16703
+ children: t?.("row.rateLimitedPaidTwin", {
16704
+ id: twin.id,
16705
+ rate: twin.multiplier.toFixed(2)
16706
+ }) ?? `→ ${twin.id} (${twin.multiplier.toFixed(2)}x) still works`
16707
+ })]
16708
+ }, mc.modelId);
16709
+ })
16710
+ }) : null
16711
+ ]
16712
+ }),
16713
+ (0, react_jsx_runtime.jsx)(AccountStats, {
16714
+ account,
16715
+ t,
16716
+ checkinBusy: checkinBusyId === account.id,
16717
+ onClaim: onClaimCheckin
16718
+ }),
16719
+ (0, react_jsx_runtime.jsx)(CreditReserveRow, {
16720
+ account,
16721
+ t,
16722
+ busy: reserveBusyId === account.id,
16723
+ onSave: onSaveCreditReserve
16724
+ }),
16725
+ account.automationToday === void 0 ? null : (0, react_jsx_runtime.jsxs)("div", {
16726
+ className: "fact",
16727
+ children: [(0, react_jsx_runtime.jsx)("span", {
16728
+ className: "td-name",
16729
+ children: t?.("row.autoEarned") ?? "Automation today"
16730
+ }), (0, react_jsx_runtime.jsxs)("span", {
16731
+ className: "facts",
16732
+ children: [
16733
+ account.automationToday.credit > 0 ? (0, react_jsx_runtime.jsx)("span", {
16734
+ className: "fact",
16735
+ children: t?.("row.autoFromTasks", {
16736
+ credit: account.automationToday.credit,
16737
+ energy: account.automationToday.energy,
16738
+ count: account.automationToday.claimed
16739
+ }) ?? `Tasks +${account.automationToday.credit}`
16740
+ }) : null,
16741
+ account.automationToday.checkinCredit > 0 ? (0, react_jsx_runtime.jsx)("span", {
16742
+ className: "fact",
16743
+ children: t?.("row.autoFromCheckin", { credit: account.automationToday.checkinCredit }) ?? `Check-in +${account.automationToday.checkinCredit}`
16744
+ }) : null,
16745
+ account.automationToday.bonusCredit > 0 ? (0, react_jsx_runtime.jsx)("span", {
16746
+ className: "fact",
16747
+ children: t?.("row.autoFromBonus", { credit: account.automationToday.bonusCredit }) ?? `Streak +${account.automationToday.bonusCredit}`
16748
+ }) : null,
16749
+ account.automationToday.travelCredit > 0 ? (0, react_jsx_runtime.jsx)("span", {
16750
+ className: "fact",
16751
+ children: t?.("row.autoFromTravel", { credit: account.automationToday.travelCredit }) ?? `Buddy +${account.automationToday.travelCredit}`
16752
+ }) : null,
16753
+ account.automationToday.compensationCredit > 0 ? (0, react_jsx_runtime.jsx)("span", {
16754
+ className: "fact",
16755
+ children: t?.("row.autoFromCompensation", { credit: account.automationToday.compensationCredit }) ?? `Compensation +${account.automationToday.compensationCredit}`
16756
+ }) : null
16757
+ ]
16758
+ })]
16759
+ })
16760
+ ]
16761
+ })]
16762
+ });
16763
+ }
16764
+ function CreditReserveRow({ account, t, busy, onSave }) {
16765
+ const saved = account.creditReserve ?? 0;
16766
+ const [draft, setDraft] = (0, react.useState)(String(saved));
16767
+ const [settled, setSettled] = (0, react.useState)(saved);
16768
+ const [note, setNote] = (0, react.useState)(void 0);
16769
+ (0, react.useEffect)(() => {
16770
+ setSettled(saved);
16771
+ setDraft((current) => current === String(saved) ? current : String(saved));
16772
+ }, [saved]);
16773
+ const parsed = Number.parseInt(draft, 10);
16774
+ const next = Number.isFinite(parsed) && parsed > 0 ? Math.floor(parsed) : 0;
16775
+ const dirty = next !== settled;
16776
+ const commit = async () => {
16777
+ if (busy || !dirty) return;
16778
+ setNote(void 0);
16779
+ if (await onSave(account.id, next)) {
16780
+ setSettled(next);
16781
+ setDraft(String(next));
16782
+ setNote("saved");
16783
+ } else setNote("failed");
16784
+ };
16785
+ return (0, react_jsx_runtime.jsxs)("div", {
16786
+ className: "row",
16787
+ children: [
16788
+ (0, react_jsx_runtime.jsx)("span", {
16789
+ className: "field",
16790
+ children: t?.("row.reserveTitle") ?? "Keep at least"
16791
+ }),
16792
+ (0, react_jsx_runtime.jsx)("input", {
16793
+ type: "number",
16794
+ min: 0,
16795
+ step: 1,
16796
+ value: draft,
16797
+ disabled: busy,
16798
+ className: "input",
16799
+ "aria-label": t?.("row.reserveTitle") ?? "Keep at least",
16800
+ onChange: (event) => {
16801
+ setDraft(event.target.value);
16802
+ setNote(void 0);
16803
+ },
16804
+ onKeyDown: (event) => {
16805
+ if (event.key === "Enter") commit();
16806
+ }
16807
+ }),
16808
+ (0, react_jsx_runtime.jsx)("span", {
16809
+ className: "kpi-u",
16810
+ children: t?.("row.reserveUnit") ?? "credits"
16811
+ }),
16812
+ (0, react_jsx_runtime.jsx)("button", {
16813
+ type: "button",
16814
+ className: "tiny",
16815
+ disabled: busy || !dirty,
16816
+ onClick: () => {
16817
+ commit();
16818
+ },
16819
+ children: busy ? t?.("row.reserveSaving") ?? "Saving…" : t?.("row.reserveSave") ?? "Save"
16820
+ }),
16821
+ note === "saved" ? (0, react_jsx_runtime.jsx)("span", {
16822
+ className: "hint",
16823
+ children: next > 0 ? t?.("row.reserveSaved", { credits: next }) ?? `Keeping ${next} credits` : t?.("row.reserveCleared") ?? "Reserve cleared"
16824
+ }) : null,
16825
+ note === "failed" ? (0, react_jsx_runtime.jsx)("span", {
16826
+ className: "hint",
16827
+ children: t?.("row.reserveFailed") ?? "Not saved — try again"
16828
+ }) : null,
16829
+ account.reserved === true ? (0, react_jsx_runtime.jsx)("span", {
16830
+ className: "pill",
16831
+ children: t?.("row.reserveHolding") ?? "Reserved: skipped"
16832
+ }) : null
16833
+ ]
16834
+ });
16835
+ }
16836
+ function AccountStats({ account, t, checkinBusy, onClaim }) {
16837
+ const credits = account.credits;
16838
+ const checkin = account.checkin;
16839
+ const hasCredits = credits !== void 0 || account.creditsError !== void 0;
16840
+ const hasCheckin = checkin !== void 0 || account.checkinError !== void 0;
16841
+ if (!hasCredits && !hasCheckin) return null;
16842
+ const packages = (credits?.packages ?? []).filter((p) => (p.size ?? 0) > 0).slice(0, 6);
16843
+ return (0, react_jsx_runtime.jsxs)("div", {
16844
+ className: "kpis",
16845
+ children: [
16846
+ (0, react_jsx_runtime.jsxs)("span", {
16847
+ className: "sec kpi-v",
16848
+ children: [(0, react_jsx_runtime.jsx)("span", {
16849
+ className: "sec-title",
16850
+ children: t?.("row.creditsTotal") ?? "Total"
16851
+ }), (0, react_jsx_runtime.jsx)("span", {
16852
+ className: "kpi-v",
16853
+ children: formatNumber(credits?.total)
16854
+ })]
16855
+ }),
16856
+ hasCheckin ? (0, react_jsx_runtime.jsx)("div", {
16857
+ className: "sec",
16858
+ children: account.checkinError !== void 0 ? (0, react_jsx_runtime.jsx)("span", {
16859
+ className: "hint",
16860
+ title: account.checkinError,
16861
+ children: t?.("row.checkinUnavailable") ?? "check-in unavailable"
16862
+ }) : checkin === void 0 ? null : (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
16863
+ (0, react_jsx_runtime.jsxs)("div", {
16864
+ className: "hint",
16865
+ children: [(0, react_jsx_runtime.jsx)("span", {
16866
+ className: "pill",
16867
+ children: t?.("row.checkinStreak", { days: checkin.streakDays }) ?? `${checkin.streakDays}-day streak`
16868
+ }), checkin.dailyCredit > 0 ? (0, react_jsx_runtime.jsx)("span", {
16869
+ className: "fact",
16870
+ children: t?.("row.checkinDaily", { credit: formatNumber(checkin.dailyCredit) }) ?? `+${formatNumber(checkin.dailyCredit)}/day`
16871
+ }) : null]
16872
+ }),
16873
+ checkin.isStreakDay && checkin.streakBonusCredit > 0 ? (0, react_jsx_runtime.jsx)("span", {
16874
+ className: "fact",
16875
+ children: t?.("row.checkinStreakBonus", {
16876
+ days: formatNumber(checkin.nextStreakDay),
16877
+ credit: formatNumber(checkin.streakBonusCredit)
16878
+ }) ?? `bonus +${formatNumber(checkin.streakBonusCredit)}`
16879
+ }) : null,
16880
+ (0, react_jsx_runtime.jsx)("button", {
16881
+ type: "button",
16882
+ className: "tiny",
16883
+ disabled: !checkin.active || checkin.todayCheckedIn || checkinBusy,
16884
+ onClick: () => {
16885
+ onClaim(account.id);
16886
+ },
16887
+ children: !checkin.active ? t?.("row.checkinInactive") ?? "Unavailable" : checkin.todayCheckedIn ? t?.("row.checkinClaimed") ?? "Checked in" : checkinBusy ? t?.("row.checkinClaiming") ?? "Checking in…" : t?.("row.checkinClaim") ?? "Check in"
16888
+ })
16889
+ ] })
16890
+ }) : null,
16891
+ hasCredits ? (0, react_jsx_runtime.jsxs)("ul", {
16892
+ className: "facts sec",
16893
+ children: [account.creditsError !== void 0 ? (0, react_jsx_runtime.jsx)("li", { children: (0, react_jsx_runtime.jsx)("span", {
16894
+ className: `hint${account.credentialDead === true ? " is-bad" : ""}`,
16895
+ title: account.creditsError,
16896
+ children: account.credentialDead === true ? t?.("row.credentialDead") ?? "Sign-in rejected" : t?.("row.creditsError") ?? "credits unavailable"
16897
+ }) }) : packages.length === 0 ? (0, react_jsx_runtime.jsx)("li", {
16898
+ className: "hint",
16899
+ children: "–"
16900
+ }) : packages.map((pack, index) => {
16901
+ const expiry = formatExpiry(pack.expiresAtMs);
16902
+ const refresh = formatExpiry(pack.cycleRefreshMs);
16903
+ const soon = isExpiringSoon(pack);
16904
+ const when = pack.monthly === true ? refresh === "" ? null : t?.("row.creditsRefreshAt", { time: refresh }) ?? `Refreshes ${refresh}` : expiry === "" ? null : t?.("row.creditsExpiresAt", { time: expiry }) ?? `Expires ${expiry}`;
16905
+ return (0, react_jsx_runtime.jsxs)("li", { children: [
16906
+ (0, react_jsx_runtime.jsx)("span", {
16907
+ className: "td-name",
16908
+ children: pack.packageName
16909
+ }),
16910
+ (0, react_jsx_runtime.jsx)("span", {
16911
+ className: "td-num",
16912
+ children: t?.("row.creditsPackage", {
16913
+ remain: formatNumber(pack.remain),
16914
+ size: formatNumber(pack.size)
16915
+ }) ?? `${formatNumber(pack.remain)} / ${formatNumber(pack.size)}`
16916
+ }),
16917
+ when === null ? null : (0, react_jsx_runtime.jsx)("span", {
16918
+ className: `hint${soon ? " hint" : ""}`,
16919
+ title: t?.("row.creditsExpiresSoonTitle") ?? "Expiring within 3 days",
16920
+ children: when
16921
+ })
16922
+ ] }, `${pack.packageName}-${String(index)}`);
16923
+ }), credits?.expiringSoon !== void 0 && credits.expiringSoon > 0 ? (0, react_jsx_runtime.jsxs)("li", {
16924
+ className: "hint",
16925
+ children: [
16926
+ t?.("row.creditsSoon") ?? "Expiring in 3 days",
16927
+ " ",
16928
+ formatNumber(credits.expiringSoon)
16929
+ ]
16930
+ }) : null]
16931
+ }) : null
16932
+ ]
16933
+ });
16934
+ }
16353
16935
  //#endregion
16354
16936
  //#region src/client/CreditDot.tsx
16355
16937
  const POLL_MS = 45e3;
package/lib/index.js CHANGED
@@ -29306,7 +29306,7 @@ function parseBody(body) {
29306
29306
  *
29307
29307
  * @module dsh-xdpool/version
29308
29308
  */
29309
- const POOL_VERSION = "3.0.3";
29309
+ const POOL_VERSION = "3.0.4";
29310
29310
  //#endregion
29311
29311
  //#region src/update-check.ts
29312
29312
  /**
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "dsh-xdpool",
3
3
  "displayName": "DSH XD Pool",
4
4
  "description": "One DSH model pool for every free quota you have: merge all locally signed-in WorkBuddy accounts with auto-failover, sign in to 22 vendors by QR/web, aggregate 77 external vendors' keys, plus a usage dashboard, model routing, a local OpenAI-compatible gateway and a points-automation suite.",
5
- "version": "3.0.3",
5
+ "version": "3.0.4",
6
6
  "license": "MIT",
7
7
  "author": "XDTrees",
8
8
  "homepage": "https://github.com/XDTrees/dsh-xdpool#readme",
@@ -32788,6 +32788,26 @@ async function* recordThroughStream(openStream, meta) {
32788
32788
  }
32789
32789
  }
32790
32790
  function registerAdapterIdempotent(llm, providers, adapter, warn) {
32791
+ /**
32792
+ * [xdpool-local] 让位:dsh-xdpool 自己服务 buddy / workbuddy 时,pack 不再注册。
32793
+ *
32794
+ * 这两个 lane 有两条注册来源 —— 本插件注册 `xdpool` / `xdpool-global`(桌面
32795
+ * 客户端读到的账号只活在我们的池里),pack 注册 `buddy` / `workbuddy`。两边
32796
+ * 都注册时,模型选择器里「WorkBuddy 国内版 / 国际版」各出现两次(issue #201)。
32797
+ *
32798
+ * 插件在 mount 时按「自己池里有没有账号」决定要不要写
32799
+ * `DSH_XDPOOL_OWNS_POOL_LANES`:有账号就让位,没账号就删掉这个变量让 pack
32800
+ * 继续提供目录(否则那台机器上一个模型都看不到)。判断放在注册这一层,是因为
32801
+ * pack 的 pool-owned 清单只负责「不静音」,从来不是「不注册」。
32802
+ */
32803
+ const owned = (typeof process === 'undefined' ? '' : process.env.DSH_XDPOOL_OWNS_POOL_LANES ?? '')
32804
+ .split(',')
32805
+ .map((id) => id.trim())
32806
+ .filter((id) => id !== '')
32807
+ if (owned.length > 0 && providers.length > 0 && providers.every((id) => owned.includes(id))) {
32808
+ warn?.(`[llm-register] ${providers.join(', ')} 由 dsh-xdpool 自己服务,pack 跳过注册(避免重复分组)`)
32809
+ return void 0
32810
+ }
32791
32811
  let target = wrapAdapterWithTokenLedger(providers, adapter);
32792
32812
  if (typeof adapter === "object" && adapter !== null) {
32793
32813
  try {