dsh-xdpool 2.7.2 → 2.7.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 +101 -0
- package/lib/bin.js +1 -1
- package/lib/client.js +293 -16
- package/lib/index.d.ts +12 -0
- package/lib/index.js +589 -68
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,107 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
本项目的所有重要变更都会记录在此文件。
|
|
3
3
|
版本号遵循 [语义化版本](https://semver.org/lang/zh-CN/)。
|
|
4
|
+
## 2.7.4 — 远程可用、只列已绑定渠道、检查更新
|
|
5
|
+
|
|
6
|
+
### 远程访问时所有按钮 403(#164)
|
|
7
|
+
|
|
8
|
+
通过 `tailscale serve`、局域网主机名或任何反向代理打开 Web UI 时,卡片**数据显示正常、所有
|
|
9
|
+
按钮报「请求失败」**。根因不是网络:插件的 `loopbackOrigin` 只认 loopback `Origin`,而浏览器
|
|
10
|
+
在非本机地址下必然发送公开主机名 —— 于是写请求全部 `403 origin-not-trusted`,而只读请求没事,
|
|
11
|
+
因为页面自己发的 GET 不带 `Origin`。
|
|
12
|
+
|
|
13
|
+
宿主其实早就放行了这些地址(`connection.trustedHosts`,宿主自己的 `/api` 桥用它),只有插件
|
|
14
|
+
还在说不。
|
|
15
|
+
|
|
16
|
+
现在按四条规则放行:
|
|
17
|
+
|
|
18
|
+
1. 没有 `Origin` —— 同源请求,页面自己发的那种
|
|
19
|
+
2. loopback `Origin` —— 默认部署
|
|
20
|
+
3. `Origin` 命中 `trustedHosts` 里的条目 —— 显式配置的服务面
|
|
21
|
+
4. `Origin` 的主机名等于请求自己的 `Host` —— 浏览器意义上的同源
|
|
22
|
+
|
|
23
|
+
第 4 条让反向代理无需配置即可工作;跨站页面伪造不了这一条,因为浏览器分别从页面和 URL 填这
|
|
24
|
+
两个头,只有页面真的由该地址提供时它们才会一致。
|
|
25
|
+
|
|
26
|
+
### 只列已绑定的渠道(#166)
|
|
27
|
+
|
|
28
|
+
首页原本把所有渠道都列出来,于是绑了一个豆包的账号池要滚过十几个「– 账号 – 模型 – 积分」的
|
|
29
|
+
空卡片才能看到它。
|
|
30
|
+
|
|
31
|
+
现在默认只列有账号的渠道,并给一个「显示全部渠道」的开关(要再加一个的时候用)。
|
|
32
|
+
**一个都没绑时仍然全部显示** —— 否则新装的用户看到的是空白页,没有任何入口添加第一个账号。
|
|
33
|
+
|
|
34
|
+
### 检查更新(#166)
|
|
35
|
+
|
|
36
|
+
升级原本要人肉去 GitHub 看,或者让 agent 定期跑任务。现在备份页顶部有「检查更新」:
|
|
37
|
+
读 npm registry 的 `dist-tags.latest`,与当前版本比较,答「有新版本 / 已是最新 / 没法检查」。
|
|
38
|
+
|
|
39
|
+
- 结果缓存 10 分钟;点按钮强制刷新
|
|
40
|
+
- **失败单独报**:告诉用户「已是最新」而实际是网络不通,是这里唯一不能给的答案
|
|
41
|
+
- 页面改名「更新与备份」 —— 两者都是偶尔做一次的维护,不是日常跑池子的一部分
|
|
42
|
+
|
|
43
|
+
## 2.7.3 — 豆包进模型选择器,开关能记住了
|
|
44
|
+
|
|
45
|
+
> 两个问题:豆包的模型在选择器里完全看不到;勾选和全开全关关掉面板就失效。
|
|
46
|
+
|
|
47
|
+
### 豆包为什么不在模型选择器里
|
|
48
|
+
|
|
49
|
+
模型选择器读的是**宿主的 adapter 注册表**(`ctx.llm.registerAdapter`),而豆包只走了
|
|
50
|
+
channelLane 的 HTTP 路由 —— 那条路让模型可用,但不会让它们出现在列表里。所以一个已登录、
|
|
51
|
+
十个模型全勾的账号,在选择器里一片空白。
|
|
52
|
+
|
|
53
|
+
现在按其他渠道的方式注册:
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
ctx.llm.registerAdapter([DOUBAO_PROVIDER_ID], new DoubaoHostAdapter({ ... }))
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
实现了 `LlmAdapter` 要求的五个方法(`providerInfo` / `listModels` / `resolveModel` /
|
|
60
|
+
`prepareCall` / `stream`),请求细节仍由 `doubao-upstream.ts` 决定。
|
|
61
|
+
|
|
62
|
+
### 模型参数、倍率、免费标注
|
|
63
|
+
|
|
64
|
+
`brief_list` 接口只返回功能入口,**不含**任何模型字段。倍率和上下文在**桌面客户端的
|
|
65
|
+
IndexedDB 记录里**:
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
model_item_key: person-kimi-k3-261111
|
|
69
|
+
name: Kimi K3
|
|
70
|
+
total_window_size: 300000
|
|
71
|
+
tag.text: "1.48x"
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
解析后卡片和选择器都能显示:
|
|
75
|
+
|
|
76
|
+
| 模型 | 倍率 |
|
|
77
|
+
| --- | --- |
|
|
78
|
+
| Kimi K3 | `1.48x` |
|
|
79
|
+
| GLM 5.3 | `0.80x` |
|
|
80
|
+
| Kimi K3.1 Pro 高速 | `1.44x` |
|
|
81
|
+
|
|
82
|
+
上下文窗口 256k,推理三档(低/中/高)。倍率写成字符串而不是数字 —— `1.48x` 是费率、
|
|
83
|
+
`免费` 根本不是倍率、`x0.12→x0.06` 是进行中的促销,压平成数字就等于替厂商改口径。
|
|
84
|
+
没有倍率数据的模型(例如某些套餐下的 DeepSeek)就不显示,不编造。
|
|
85
|
+
|
|
86
|
+
### 模型开关为什么记不住
|
|
87
|
+
|
|
88
|
+
`model.setDisabled` 和 `model.setAllDisabled` 都是 pack 的 RPC,指向 pack 自己的模型记录。
|
|
89
|
+
豆包在那里没有条目,所以两个调用都回答 `unknown provider`,接着 catch 回滚本地状态:
|
|
90
|
+
|
|
91
|
+
```js
|
|
92
|
+
setEnabled(previous => { const restored = new Map(previous); restored.delete(provider); return restored })
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
于是「全关 → 重新打开面板 → 又是全开」。
|
|
96
|
+
|
|
97
|
+
现在豆包自己存(其他渠道由 pack 存,因为 pack 拥有它们的目录):
|
|
98
|
+
|
|
99
|
+
- 单个开关:`saveDoubaoSkipped(modelId, disabled)`
|
|
100
|
+
- 全开全关:一次写入整个名单
|
|
101
|
+
|
|
102
|
+
读取端区分两种状态:`undefined` 是「从未配置」(全开),`[]` 是「配置为全关」。
|
|
103
|
+
混在一起会让新账号看起来像已经被配置过。
|
|
104
|
+
|
|
4
105
|
## 2.7.2 — 一个账号池,一组模型
|
|
5
106
|
|
|
6
107
|
> 模型选择器里同一个账号池出现了四个分组(XD Pool 国内版/国际版 + WorkBuddy 国内版/国际版)。
|
package/lib/bin.js
CHANGED
|
@@ -4,11 +4,11 @@ import { chmod, copyFile, mkdir, readFile, readdir, rename, rm, unlink, writeFil
|
|
|
4
4
|
import { homedir, platform } from "node:os";
|
|
5
5
|
import { basename, dirname, join, resolve } from "node:path";
|
|
6
6
|
import { execFile, execFileSync } from "node:child_process";
|
|
7
|
+
import "@deepseek-ai/dsh-llm";
|
|
7
8
|
import z from "@deepseek-ai/schemastery";
|
|
8
9
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
9
10
|
import "@earendil-works/pi-ai";
|
|
10
11
|
import "@earendil-works/pi-ai/api/openai-completions.lazy";
|
|
11
|
-
import "@deepseek-ai/dsh-llm";
|
|
12
12
|
import "@deepseek-ai/dsh-llm-pi-ai";
|
|
13
13
|
//#region src/badges.ts
|
|
14
14
|
/**
|
package/lib/client.js
CHANGED
|
@@ -112,6 +112,8 @@ window.__ModuleLoader__.load({
|
|
|
112
112
|
const POOL_ACCOUNT_IGNORE_PATH = "/plugins/dsh-xdpool/accounts/ignored";
|
|
113
113
|
/** Run one automation job immediately, so the card can verify it on demand. */
|
|
114
114
|
const POOL_AUTOMATION_RUN_PATH = "/plugins/dsh-xdpool/automation/run";
|
|
115
|
+
/** Is there a newer build of this plugin? */
|
|
116
|
+
const POOL_UPDATE_CHECK_PATH = "/plugins/dsh-xdpool/update";
|
|
115
117
|
/** Set or clear one account's reserved-credit floor. */
|
|
116
118
|
const POOL_CREDIT_RESERVE_PATH = "/plugins/dsh-xdpool/accounts/credit-reserve";
|
|
117
119
|
/**
|
|
@@ -746,6 +748,7 @@ window.__ModuleLoader__.load({
|
|
|
746
748
|
model always visible, and keeping the old names on the new shapes would
|
|
747
749
|
leave two rule sets fighting over one element. */
|
|
748
750
|
.dsm-xdpool-cpool{display:flex;flex-direction:column;gap:10px}
|
|
751
|
+
.dsm-xdpool-cpool-bar{display:flex;justify-content:flex-end;margin:0 0 8px}
|
|
749
752
|
.dsm-xdpool-cpool-grid{display:flex;flex-direction:column;gap:12px;min-width:0}
|
|
750
753
|
.dsm-xdpool-cpool-card{--dsm-xdpool-cpool-accent:var(--dsw-alias-brand-primary,#5686fe);position:relative;display:flex;flex-direction:column;gap:8px;padding:12px 13px 12px 15px;overflow:hidden;border:1px solid var(--dsw-alias-border-l2,#36373b);border-radius:13px;background:color-mix(in srgb, var(--dsw-alias-bg-layer-3,#2a2c33) 80%, transparent);box-shadow:inset 0 1px 0 rgb(255 255 255 / 6%), 0 1px 2px rgb(0 0 0 / 6%);transition:transform .22s cubic-bezier(.32,.72,0,1),box-shadow .24s ease,border-color .2s ease}
|
|
751
754
|
.dsm-xdpool-cpool-card:hover{transform:translateY(-3px);border-color:color-mix(in srgb, var(--dsm-xdpool-cpool-accent,#5686fe) 55%, var(--dsw-alias-border-l2,#36373b));box-shadow:inset 0 1px 0 rgb(255 255 255 / 8%),0 18px 40px rgb(0 0 0 / 15%)}
|
|
@@ -1937,6 +1940,16 @@ window.__ModuleLoader__.load({
|
|
|
1937
1940
|
.dsm-xdpool-bak-clear:hover{background:color-mix(in srgb, var(--dsw-alias-label-primary,#e8eaf0) 12%, transparent);color:var(--dsw-alias-label-primary,#e8eaf0)}
|
|
1938
1941
|
.dsm-xdpool-bak-note{margin:0;font-size:11px;line-height:16px;color:var(--dsw-alias-state-success-primary,#22a06b)}
|
|
1939
1942
|
.dsm-xdpool-bak-error{margin:0;font-size:11px;line-height:16px;color:var(--dsw-alias-state-error-primary,#e5534b)}
|
|
1943
|
+
.dsm-xdpool-update{display:flex;flex-direction:column;gap:8px;margin:0 0 14px;padding:12px 14px;border-radius:12px;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) 60%, transparent)}
|
|
1944
|
+
.dsm-xdpool-update-head{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
|
|
1945
|
+
.dsm-xdpool-update-title{font-size:13px;font-weight:650;color:var(--dsw-alias-label-primary,#e8eaf0)}
|
|
1946
|
+
.dsm-xdpool-update-versions{font-size:11.5px;color:var(--dsw-alias-label-tertiary,#8a90a0);font-variant-numeric:tabular-nums}
|
|
1947
|
+
.dsm-xdpool-update-versions b{color:var(--dsw-alias-label-secondary,#c6c9d0);font-weight:600}
|
|
1948
|
+
.dsm-xdpool-update-sep{margin:0 5px;opacity:.6}
|
|
1949
|
+
.dsm-xdpool-update-head .dsm-xdpool-btn{margin-left:auto}
|
|
1950
|
+
.dsm-xdpool-update-current{margin:0;font-size:11.5px;line-height:17px;color:var(--dsw-alias-state-success-primary,#22a06b)}
|
|
1951
|
+
.dsm-xdpool-update-newer{margin:0;font-size:11.5px;line-height:17px;color:var(--dsw-alias-state-warning-primary,#d99a2b)}
|
|
1952
|
+
.dsm-xdpool-update-error{margin:0;font-size:11.5px;line-height:17px;color:var(--dsw-alias-state-error-primary,#e5534b)}
|
|
1940
1953
|
`;
|
|
1941
1954
|
//#endregion
|
|
1942
1955
|
//#region src/client/avatar.ts
|
|
@@ -12436,7 +12449,7 @@ window.__ModuleLoader__.load({
|
|
|
12436
12449
|
* @module dsh-xdpool/client/DoubaoAutomationPane
|
|
12437
12450
|
*/
|
|
12438
12451
|
/** A short "3 小时前" style line for the last pass. */
|
|
12439
|
-
function agoText(iso) {
|
|
12452
|
+
function agoText$1(iso) {
|
|
12440
12453
|
if (iso === void 0) return void 0;
|
|
12441
12454
|
const at = Date.parse(iso);
|
|
12442
12455
|
if (Number.isNaN(at)) return void 0;
|
|
@@ -12485,7 +12498,7 @@ window.__ModuleLoader__.load({
|
|
|
12485
12498
|
}
|
|
12486
12499
|
}, []);
|
|
12487
12500
|
const enabled = state.enabled === true;
|
|
12488
|
-
const lastRun = agoText(state.lastRunAt);
|
|
12501
|
+
const lastRun = agoText$1(state.lastRunAt);
|
|
12489
12502
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
12490
12503
|
className: "dsm-xdpool-cpool-auto",
|
|
12491
12504
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
@@ -12599,6 +12612,34 @@ window.__ModuleLoader__.load({
|
|
|
12599
12612
|
* Versioned, because the shape will change and a stale blob must not be fed to new code.
|
|
12600
12613
|
*/
|
|
12601
12614
|
const COUNTS_STORE_KEY = "dsh-xdpool.channel-counts.v1";
|
|
12615
|
+
/** Where Doubao's own model selection lives. Versioned for the same reason as the counts. */
|
|
12616
|
+
const DOUBAO_SKIP_KEY = "dsh-xdpool.doubao-skipped-models.v1";
|
|
12617
|
+
/**
|
|
12618
|
+
* The Doubao models the user switched off.
|
|
12619
|
+
*
|
|
12620
|
+
* `undefined` means "never configured", which is different from "none switched off": the first
|
|
12621
|
+
* shows everything, the second shows nothing. Collapsing them would make a fresh account look
|
|
12622
|
+
* as though the user had already made choices.
|
|
12623
|
+
*/
|
|
12624
|
+
function readDoubaoSkipped() {
|
|
12625
|
+
try {
|
|
12626
|
+
const raw = globalThis.localStorage?.getItem(DOUBAO_SKIP_KEY);
|
|
12627
|
+
if (raw === null || raw === void 0) return void 0;
|
|
12628
|
+
const parsed = JSON.parse(raw);
|
|
12629
|
+
if (!Array.isArray(parsed)) return void 0;
|
|
12630
|
+
return new Set(parsed.filter((id) => typeof id === "string"));
|
|
12631
|
+
} catch {
|
|
12632
|
+
return;
|
|
12633
|
+
}
|
|
12634
|
+
}
|
|
12635
|
+
/** Record one model as switched off, or back on. */
|
|
12636
|
+
async function saveDoubaoSkipped(modelId, disabled) {
|
|
12637
|
+
const current = readDoubaoSkipped() ?? /* @__PURE__ */ new Set();
|
|
12638
|
+
const next = new Set(current);
|
|
12639
|
+
if (disabled) next.add(modelId);
|
|
12640
|
+
else next.delete(modelId);
|
|
12641
|
+
globalThis.localStorage?.setItem(DOUBAO_SKIP_KEY, JSON.stringify([...next]));
|
|
12642
|
+
}
|
|
12602
12643
|
/** Read the stored counts, or undefined when there is nothing usable. */
|
|
12603
12644
|
function readStoredCounts() {
|
|
12604
12645
|
try {
|
|
@@ -12761,8 +12802,15 @@ window.__ModuleLoader__.load({
|
|
|
12761
12802
|
const body = await (await fetch(POOL_DOUBAO_MODELS_PATH, { credentials: "same-origin" })).json().catch(() => void 0);
|
|
12762
12803
|
return (Array.isArray(body?.models) ? body.models : []).filter((model) => typeof model.id === "string" && typeof model.name === "string").map((model) => ({
|
|
12763
12804
|
id: model.id,
|
|
12764
|
-
|
|
12765
|
-
|
|
12805
|
+
/**
|
|
12806
|
+
* The multiplier is joined onto the name because that is the shape the card already
|
|
12807
|
+
* understands — every other channel writes it there (`DeepSeek-V4.1-Flash · x0.11`), and
|
|
12808
|
+
* `multiplierOf` splits it back out into its own badge. Doing it here keeps ONE rule for
|
|
12809
|
+
* every vendor instead of a Doubao-shaped exception in the renderer.
|
|
12810
|
+
*/
|
|
12811
|
+
name: typeof model.rate === "string" && model.rate !== "" ? `${model.name} · ${model.rate}` : model.name,
|
|
12812
|
+
...typeof model.badge === "string" && model.badge !== "" ? { description: model.badge } : {},
|
|
12813
|
+
...typeof model.contextWindow === "number" ? { contextWindow: model.contextWindow } : {}
|
|
12766
12814
|
}));
|
|
12767
12815
|
} catch {
|
|
12768
12816
|
return doubaoListing();
|
|
@@ -12964,6 +13012,15 @@ window.__ModuleLoader__.load({
|
|
|
12964
13012
|
const [busy, setBusy] = (0, react.useState)(/* @__PURE__ */ new Set());
|
|
12965
13013
|
/** Channels whose model catalogue is being re-read. */
|
|
12966
13014
|
const [catalogBusy, setCatalogBusy] = (0, react.useState)(/* @__PURE__ */ new Set());
|
|
13015
|
+
/**
|
|
13016
|
+
* Whether channels without an account are listed.
|
|
13017
|
+
*
|
|
13018
|
+
* They are hidden by default: a card for a channel nobody signed into says "– accounts, –
|
|
13019
|
+
* models, – credit" and takes a full row to say it, so an account pool with one signed-in
|
|
13020
|
+
* channel scrolled past a dozen empty ones to reach it (#166). The switch brings them back for
|
|
13021
|
+
* the one case where they are wanted — adding another.
|
|
13022
|
+
*/
|
|
13023
|
+
const [showAll, setShowAll] = (0, react.useState)(false);
|
|
12967
13024
|
/** provider → what the reader typed into that card's model search box. */
|
|
12968
13025
|
const [queries, setQueries] = (0, react.useState)(/* @__PURE__ */ new Map());
|
|
12969
13026
|
const entriesRef = (0, react.useRef)(entries);
|
|
@@ -13147,7 +13204,23 @@ window.__ModuleLoader__.load({
|
|
|
13147
13204
|
return next;
|
|
13148
13205
|
});
|
|
13149
13206
|
};
|
|
13150
|
-
const enabledFor = (provider, models) =>
|
|
13207
|
+
const enabledFor = (provider, models) => {
|
|
13208
|
+
const live = enabled.get(provider);
|
|
13209
|
+
if (live !== void 0) return live;
|
|
13210
|
+
/**
|
|
13211
|
+
* Doubao remembers its own selection.
|
|
13212
|
+
*
|
|
13213
|
+
* The pack keeps every other channel's disabled list; this lane has no entry there, so its
|
|
13214
|
+
* choice is stored beside the counts it already keeps. `undefined` means "never touched" and
|
|
13215
|
+
* the default (all enabled) applies — a channel the user has not configured must not look
|
|
13216
|
+
* half-configured.
|
|
13217
|
+
*/
|
|
13218
|
+
if (provider === "doubao") {
|
|
13219
|
+
const saved = readDoubaoSkipped();
|
|
13220
|
+
if (saved !== void 0) return new Set(models.filter((model) => !saved.has(model.id)).map((model) => model.id));
|
|
13221
|
+
}
|
|
13222
|
+
return new Set(models.filter((model) => model.disabled !== true).map((model) => model.id));
|
|
13223
|
+
};
|
|
13151
13224
|
const queryFor = (provider) => queries.get(provider) ?? "";
|
|
13152
13225
|
const setQuery = (provider, query) => {
|
|
13153
13226
|
setQueries((previous) => {
|
|
@@ -13196,12 +13269,24 @@ window.__ModuleLoader__.load({
|
|
|
13196
13269
|
setEnabled((previous) => new Map(previous).set(provider, next));
|
|
13197
13270
|
markBusy(provider, true);
|
|
13198
13271
|
try {
|
|
13199
|
-
|
|
13200
|
-
|
|
13201
|
-
|
|
13202
|
-
|
|
13203
|
-
|
|
13204
|
-
|
|
13272
|
+
/**
|
|
13273
|
+
* Doubao's selection is saved HERE, not through the pack.
|
|
13274
|
+
*
|
|
13275
|
+
* `model.setDisabled` is a pack RPC addressed to the pack's own model record, and Doubao
|
|
13276
|
+
* has no entry there — so the call answered "unknown provider", the catch below rolled the
|
|
13277
|
+
* local state back, and the checkbox snapped to its old value the moment the panel was
|
|
13278
|
+
* reopened. Every other channel persists through the pack because the pack owns its
|
|
13279
|
+
* catalogue; this lane owns its own, so it persists its own.
|
|
13280
|
+
*/
|
|
13281
|
+
if (provider === "doubao") await saveDoubaoSkipped(modelId, !on);
|
|
13282
|
+
else {
|
|
13283
|
+
const envelope = await callPack("model.setDisabled", {
|
|
13284
|
+
provider,
|
|
13285
|
+
modelId,
|
|
13286
|
+
disabled: !on
|
|
13287
|
+
});
|
|
13288
|
+
if (!envelope.ok) throw new Error(envelope.error?.message ?? "model.setDisabled refused");
|
|
13289
|
+
}
|
|
13205
13290
|
} catch (cause) {
|
|
13206
13291
|
setNotice(t?.("channelpool.saveError", { message: cause instanceof Error ? cause.message : String(cause) }) ?? `Could not save: ${cause instanceof Error ? cause.message : String(cause)}`);
|
|
13207
13292
|
setEnabled((previous) => {
|
|
@@ -13254,7 +13339,18 @@ window.__ModuleLoader__.load({
|
|
|
13254
13339
|
setEnabled((previous) => new Map(previous).set(provider, new Set(on ? entry.models.map((model) => model.id) : [])));
|
|
13255
13340
|
markBusy(provider, true);
|
|
13256
13341
|
try {
|
|
13257
|
-
|
|
13342
|
+
/**
|
|
13343
|
+
* Doubao persists its own all-on / all-off.
|
|
13344
|
+
*
|
|
13345
|
+
* Same reason as the single toggle: `model.setAllDisabled` is a pack RPC and Doubao has no
|
|
13346
|
+
* entry in the pack's model record. Calling it answered "unknown provider", the catch
|
|
13347
|
+
* rolled the state back — which is exactly the "I turned them all off, reopened the panel,
|
|
13348
|
+
* they were all on again" report.
|
|
13349
|
+
*/
|
|
13350
|
+
if (provider === "doubao") {
|
|
13351
|
+
const skipped = on ? [] : entry.models.map((model) => model.id);
|
|
13352
|
+
globalThis.localStorage?.setItem(DOUBAO_SKIP_KEY, JSON.stringify(skipped));
|
|
13353
|
+
} else await callPack("model.setAllDisabled", {
|
|
13258
13354
|
provider,
|
|
13259
13355
|
disabled: !on
|
|
13260
13356
|
});
|
|
@@ -13512,9 +13608,32 @@ window.__ModuleLoader__.load({
|
|
|
13512
13608
|
className: "dsm-xdpool-note",
|
|
13513
13609
|
children: notice
|
|
13514
13610
|
}),
|
|
13611
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
13612
|
+
className: "dsm-xdpool-cpool-bar",
|
|
13613
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
13614
|
+
type: "button",
|
|
13615
|
+
className: "dsm-xdpool-btn",
|
|
13616
|
+
"aria-pressed": showAll,
|
|
13617
|
+
onClick: () => {
|
|
13618
|
+
setShowAll(!showAll);
|
|
13619
|
+
},
|
|
13620
|
+
children: showAll ? t?.("channelpool.onlyBound") ?? "只显示已绑定" : t?.("channelpool.showAll") ?? `显示全部渠道(${String(entries.length)})`
|
|
13621
|
+
})
|
|
13622
|
+
}),
|
|
13515
13623
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
13516
13624
|
className: "dsm-xdpool-cpool-grid",
|
|
13517
|
-
children: [
|
|
13625
|
+
children: [(() => {
|
|
13626
|
+
const bound = entries.filter((entry) => entry.accounts.length > 0);
|
|
13627
|
+
/**
|
|
13628
|
+
* Nothing bound yet means EVERYTHING is shown.
|
|
13629
|
+
*
|
|
13630
|
+
* Hiding empty cards is only useful once there is something to hide them behind. On a
|
|
13631
|
+
* fresh install every card is empty, so the same rule would produce a blank page with
|
|
13632
|
+
* no way to add the first account.
|
|
13633
|
+
*/
|
|
13634
|
+
if (showAll || bound.length === 0) return entries;
|
|
13635
|
+
return bound;
|
|
13636
|
+
})().map((entry) => {
|
|
13518
13637
|
const { channel, accounts, models, facts, balances, statuses, status } = entry;
|
|
13519
13638
|
const icon = channelIcon(channel.id);
|
|
13520
13639
|
const tileMark = icon === void 0 ? { initials: channelInitials(channel.name) } : { icon };
|
|
@@ -13977,6 +14096,141 @@ window.__ModuleLoader__.load({
|
|
|
13977
14096
|
});
|
|
13978
14097
|
}
|
|
13979
14098
|
//#endregion
|
|
14099
|
+
//#region src/client/UpdatePanel.tsx
|
|
14100
|
+
/**
|
|
14101
|
+
* The update check, above the backup controls.
|
|
14102
|
+
*
|
|
14103
|
+
* WHY IT SITS HERE
|
|
14104
|
+
*
|
|
14105
|
+
* "Is there a newer version" and "put this machine back how it was" are the same kind of task —
|
|
14106
|
+
* maintenance the user does occasionally, not part of running the pool. They belong on one page,
|
|
14107
|
+
* which is why the tab is now 「更新与备份」 rather than just 备份.
|
|
14108
|
+
*
|
|
14109
|
+
* WHAT IT SAYS
|
|
14110
|
+
*
|
|
14111
|
+
* Three outcomes, three sentences: newer, current, or could not check. The third is why `error`
|
|
14112
|
+
* is kept apart from "no update": telling a user they are current when the registry was
|
|
14113
|
+
* unreachable is the one wrong answer this panel could give.
|
|
14114
|
+
*
|
|
14115
|
+
* @module dsh-xdpool/client/UpdatePanel
|
|
14116
|
+
*/
|
|
14117
|
+
/** A short "3 分钟前" line for the last check. */
|
|
14118
|
+
function agoText(iso) {
|
|
14119
|
+
if (iso === void 0) return void 0;
|
|
14120
|
+
const at = Date.parse(iso);
|
|
14121
|
+
if (Number.isNaN(at)) return void 0;
|
|
14122
|
+
const minutes = Math.floor((Date.now() - at) / 6e4);
|
|
14123
|
+
if (minutes < 1) return "刚刚";
|
|
14124
|
+
if (minutes < 60) return `${String(minutes)} 分钟前`;
|
|
14125
|
+
const hours = Math.floor(minutes / 60);
|
|
14126
|
+
if (hours < 24) return `${String(hours)} 小时前`;
|
|
14127
|
+
return `${String(Math.floor(hours / 24))} 天前`;
|
|
14128
|
+
}
|
|
14129
|
+
/** The published date, as a plain day. */
|
|
14130
|
+
function dayText(iso) {
|
|
14131
|
+
if (iso === void 0) return void 0;
|
|
14132
|
+
const at = Date.parse(iso);
|
|
14133
|
+
if (Number.isNaN(at)) return void 0;
|
|
14134
|
+
return new Date(at).toISOString().slice(0, 10);
|
|
14135
|
+
}
|
|
14136
|
+
function UpdatePanel({ t }) {
|
|
14137
|
+
const [status, setStatus] = (0, react.useState)(void 0);
|
|
14138
|
+
const [busy, setBusy] = (0, react.useState)(false);
|
|
14139
|
+
const mounted = (0, react.useRef)(true);
|
|
14140
|
+
(0, react.useEffect)(() => {
|
|
14141
|
+
mounted.current = true;
|
|
14142
|
+
return () => {
|
|
14143
|
+
mounted.current = false;
|
|
14144
|
+
};
|
|
14145
|
+
}, []);
|
|
14146
|
+
const check = (0, react.useCallback)(async (force) => {
|
|
14147
|
+
setBusy(true);
|
|
14148
|
+
try {
|
|
14149
|
+
const body = await (await fetch(POOL_UPDATE_CHECK_PATH, {
|
|
14150
|
+
method: force ? "POST" : "GET",
|
|
14151
|
+
credentials: "same-origin"
|
|
14152
|
+
})).json().catch(() => void 0);
|
|
14153
|
+
if (!mounted.current || body === void 0) return;
|
|
14154
|
+
setStatus(body);
|
|
14155
|
+
} catch {
|
|
14156
|
+
if (!mounted.current) return;
|
|
14157
|
+
setStatus({
|
|
14158
|
+
error: "无法连接插件(请确认页面已连上宿主)",
|
|
14159
|
+
checkedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
14160
|
+
});
|
|
14161
|
+
} finally {
|
|
14162
|
+
if (mounted.current) setBusy(false);
|
|
14163
|
+
}
|
|
14164
|
+
}, []);
|
|
14165
|
+
(0, react.useEffect)(() => {
|
|
14166
|
+
check(false);
|
|
14167
|
+
}, [check]);
|
|
14168
|
+
const newer = status?.newer === true;
|
|
14169
|
+
const checked = agoText(status?.checkedAt);
|
|
14170
|
+
const published = dayText(status?.publishedAt);
|
|
14171
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
14172
|
+
className: "dsm-xdpool-update",
|
|
14173
|
+
children: [
|
|
14174
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
14175
|
+
className: "dsm-xdpool-update-head",
|
|
14176
|
+
children: [
|
|
14177
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
14178
|
+
className: "dsm-xdpool-update-title",
|
|
14179
|
+
children: t?.("update.title") ?? "检查更新"
|
|
14180
|
+
}),
|
|
14181
|
+
status?.current === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
14182
|
+
className: "dsm-xdpool-update-versions",
|
|
14183
|
+
children: [
|
|
14184
|
+
t?.("update.current") ?? "当前",
|
|
14185
|
+
" ",
|
|
14186
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: status.current }),
|
|
14187
|
+
status.latest === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
14188
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
14189
|
+
className: "dsm-xdpool-update-sep",
|
|
14190
|
+
"aria-hidden": "true",
|
|
14191
|
+
children: "·"
|
|
14192
|
+
}),
|
|
14193
|
+
t?.("update.latest") ?? "最新",
|
|
14194
|
+
" ",
|
|
14195
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: status.latest })
|
|
14196
|
+
] })
|
|
14197
|
+
]
|
|
14198
|
+
}),
|
|
14199
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
14200
|
+
type: "button",
|
|
14201
|
+
className: "dsm-xdpool-btn",
|
|
14202
|
+
disabled: busy,
|
|
14203
|
+
onClick: () => {
|
|
14204
|
+
check(true);
|
|
14205
|
+
},
|
|
14206
|
+
children: busy ? t?.("update.checking") ?? "检查中…" : t?.("update.check") ?? "检查更新"
|
|
14207
|
+
})
|
|
14208
|
+
]
|
|
14209
|
+
}),
|
|
14210
|
+
status?.error === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
14211
|
+
className: "dsm-xdpool-update-error",
|
|
14212
|
+
children: [
|
|
14213
|
+
t?.("update.failed") ?? "没能检查更新",
|
|
14214
|
+
":",
|
|
14215
|
+
status.error
|
|
14216
|
+
]
|
|
14217
|
+
}),
|
|
14218
|
+
status?.error !== void 0 || status === void 0 ? null : newer ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
14219
|
+
className: "dsm-xdpool-update-newer",
|
|
14220
|
+
children: [
|
|
14221
|
+
t?.("update.available", { version: status.latest ?? "" }) ?? `有新版本 ${status.latest ?? ""}`,
|
|
14222
|
+
published === void 0 ? "" : `(发布于 ${published})`,
|
|
14223
|
+
". ",
|
|
14224
|
+
t?.("update.howTo") ?? "在 DSH 的插件设置里把它更新到该版本即可;数据与账号不受影响。"
|
|
14225
|
+
]
|
|
14226
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
14227
|
+
className: "dsm-xdpool-update-current",
|
|
14228
|
+
children: [t?.("update.upToDate") ?? "已是最新版本", checked === void 0 ? "" : `(${checked}检查)`]
|
|
14229
|
+
})
|
|
14230
|
+
]
|
|
14231
|
+
});
|
|
14232
|
+
}
|
|
14233
|
+
//#endregion
|
|
13980
14234
|
//#region src/client/backup-crypto.ts
|
|
13981
14235
|
/**
|
|
13982
14236
|
* Password-encrypted backup envelope for the credential export.
|
|
@@ -14295,6 +14549,7 @@ window.__ModuleLoader__.load({
|
|
|
14295
14549
|
className: "dsm-xdpool-bak",
|
|
14296
14550
|
children: [
|
|
14297
14551
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("style", { children: BACKUP_CSS }),
|
|
14552
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(UpdatePanel, { t }),
|
|
14298
14553
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
14299
14554
|
className: "dsm-xdpool-bak-head",
|
|
14300
14555
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
@@ -14403,7 +14658,7 @@ window.__ModuleLoader__.load({
|
|
|
14403
14658
|
*
|
|
14404
14659
|
* @module dsh-xdpool/version
|
|
14405
14660
|
*/
|
|
14406
|
-
const POOL_VERSION = "2.7.
|
|
14661
|
+
const POOL_VERSION = "2.7.4";
|
|
14407
14662
|
//#endregion
|
|
14408
14663
|
//#region src/client/PoolCard.tsx
|
|
14409
14664
|
/**
|
|
@@ -17517,6 +17772,17 @@ window.__ModuleLoader__.load({
|
|
|
17517
17772
|
* @module dsh-xdpool/client/locales
|
|
17518
17773
|
*/
|
|
17519
17774
|
const en = {
|
|
17775
|
+
"update.title": "Check for updates",
|
|
17776
|
+
"update.current": "current",
|
|
17777
|
+
"update.latest": "latest",
|
|
17778
|
+
"update.check": "Check",
|
|
17779
|
+
"update.checking": "Checking…",
|
|
17780
|
+
"update.upToDate": "Up to date",
|
|
17781
|
+
"update.available": "Version {version} is available",
|
|
17782
|
+
"update.howTo": "Update it from the plugin settings; your data and accounts are unaffected.",
|
|
17783
|
+
"update.failed": "Could not check",
|
|
17784
|
+
"channelpool.showAll": "Show all channels",
|
|
17785
|
+
"channelpool.onlyBound": "Show bound only",
|
|
17520
17786
|
"channelpool.reloadModels": "Reload models",
|
|
17521
17787
|
"channelpool.reloadModelsBusy": "Reading…",
|
|
17522
17788
|
"channelpool.reloadModelsHint": "Read the model list (and multipliers) from the vendor again",
|
|
@@ -17908,7 +18174,7 @@ window.__ModuleLoader__.load({
|
|
|
17908
18174
|
"shell.subRouting": "Chains that try models in order, so one busy or rate-limited model falls through to the next.",
|
|
17909
18175
|
"shell.tabGateway": "Gateway",
|
|
17910
18176
|
"shell.tabDoubao": "Doubao",
|
|
17911
|
-
"shell.tabBackup": "
|
|
18177
|
+
"shell.tabBackup": "Updates & backup",
|
|
17912
18178
|
"shell.subGateway": "Open the pool to the other devices on your network.",
|
|
17913
18179
|
"gw.title": "Gateway",
|
|
17914
18180
|
"gw.sub": "An OpenAI-compatible endpoint other devices on your network can point at. Off until you turn it on, and bound to this computer only until you say otherwise.",
|
|
@@ -18133,6 +18399,17 @@ window.__ModuleLoader__.load({
|
|
|
18133
18399
|
"channelpool.note": "Note"
|
|
18134
18400
|
};
|
|
18135
18401
|
const zh = {
|
|
18402
|
+
"update.title": "检查更新",
|
|
18403
|
+
"update.current": "当前",
|
|
18404
|
+
"update.latest": "最新",
|
|
18405
|
+
"update.check": "检查更新",
|
|
18406
|
+
"update.checking": "检查中…",
|
|
18407
|
+
"update.upToDate": "已是最新版本",
|
|
18408
|
+
"update.available": "有新版本 {version}",
|
|
18409
|
+
"update.howTo": "在插件设置里更新到该版本即可;数据和账号不受影响。",
|
|
18410
|
+
"update.failed": "没能检查更新",
|
|
18411
|
+
"channelpool.showAll": "显示全部渠道",
|
|
18412
|
+
"channelpool.onlyBound": "只显示已绑定",
|
|
18136
18413
|
"channelpool.reloadModels": "重新加载模型",
|
|
18137
18414
|
"channelpool.reloadModelsBusy": "正在读取…",
|
|
18138
18415
|
"channelpool.reloadModelsHint": "从上游重新读取这个渠道的模型列表(含倍率)",
|
|
@@ -18524,7 +18801,7 @@ window.__ModuleLoader__.load({
|
|
|
18524
18801
|
"shell.subRouting": "把几个模型串成一条链,按顺序试;一个忙了或被限流,就自动落到下一个。",
|
|
18525
18802
|
"shell.tabGateway": "网关",
|
|
18526
18803
|
"shell.tabDoubao": "豆包",
|
|
18527
|
-
"shell.tabBackup": "
|
|
18804
|
+
"shell.tabBackup": "更新与备份",
|
|
18528
18805
|
"shell.subGateway": "把账号池开放给同网络里的其它设备。",
|
|
18529
18806
|
"gw.title": "网关",
|
|
18530
18807
|
"gw.sub": "开一个 OpenAI 兼容的入口,同网络的其它设备可以指过来。默认关闭,默认只绑定本机 —— 你不改,它就一直只在你这台电脑上。",
|
package/lib/index.d.ts
CHANGED
|
@@ -4340,10 +4340,22 @@ export declare function readPreferredIdSync(path?: string): string | undefined;
|
|
|
4340
4340
|
*/
|
|
4341
4341
|
export declare function writePreferredId(accountId: string | undefined, path?: string): Promise<void>;
|
|
4342
4342
|
//#endregion
|
|
4343
|
+
//#region src/origin-trust.d.ts
|
|
4344
|
+
/** The authorities a deployment says it serves, as the host reports them. */
|
|
4345
|
+
type TrustedHosts = readonly string[];
|
|
4346
|
+
//#endregion
|
|
4343
4347
|
//#region src/web-status.d.ts
|
|
4344
4348
|
/** Constructor dependencies — a narrow slice of the pool runtime. */
|
|
4345
4349
|
interface PoolStatusRouteOptions {
|
|
4346
4350
|
pool: WorkBuddyAccountPool;
|
|
4351
|
+
/**
|
|
4352
|
+
* The authorities this deployment serves, read per request.
|
|
4353
|
+
*
|
|
4354
|
+
* Passed through from `connection.trustedHosts` so the plugin's gate agrees with the host's
|
|
4355
|
+
* own `/api` bridge. They disagreed once, and the symptom was a card that displayed its data
|
|
4356
|
+
* and refused every button — see `origin-trust.ts`.
|
|
4357
|
+
*/
|
|
4358
|
+
trustedHosts?: () => TrustedHosts;
|
|
4347
4359
|
/** One catalog per region; the card reads the one for its active tab. */
|
|
4348
4360
|
catalogs: Readonly<Record<PoolRegion, WorkBuddyCatalog>>;
|
|
4349
4361
|
client: WorkBuddyUpstreamClient;
|