dsh-xdpool 3.0.2 → 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 +54 -0
- package/README.md +7 -9
- package/lib/bin.js +3 -1
- package/lib/client.js +739 -21
- package/lib/index.d.ts +9 -0
- package/lib/index.js +125 -34
- package/package.json +1 -1
- package/vendor/channel-pack/pack.js +20 -0
package/lib/index.d.ts
CHANGED
|
@@ -4837,6 +4837,15 @@ export interface Config {
|
|
|
4837
4837
|
* for `enabledModelIds`, and it is avoided by keeping the polarity.
|
|
4838
4838
|
*/
|
|
4839
4839
|
doubaoDisabledModels?: string[];
|
|
4840
|
+
/**
|
|
4841
|
+
* The card's 「全关」 — issue: 「豆包模型全关了但选择器还在」.
|
|
4842
|
+
*
|
|
4843
|
+
* The disable-list alone cannot carry this: an all-off that stored `[]` (the
|
|
4844
|
+
* card's roster had not loaded yet) reads back as "nothing disabled", and an
|
|
4845
|
+
* all-off that stored every id stops working the moment a NEW model appears
|
|
4846
|
+
* upstream. One explicit flag says exactly what the user pressed.
|
|
4847
|
+
*/
|
|
4848
|
+
doubaoHideAllModels?: boolean;
|
|
4840
4849
|
}
|
|
4841
4850
|
/** One region's saved model selection. */
|
|
4842
4851
|
export interface ModelSelectionConfig {
|
package/lib/index.js
CHANGED
|
@@ -1188,7 +1188,7 @@ let cached$4;
|
|
|
1188
1188
|
/** The reasoning ladder's numeric levels, as the vendor names them. */
|
|
1189
1189
|
const LEVEL_NAMES = {
|
|
1190
1190
|
3: "low",
|
|
1191
|
-
4: "
|
|
1191
|
+
4: "mid",
|
|
1192
1192
|
5: "high",
|
|
1193
1193
|
6: "xhigh",
|
|
1194
1194
|
7: "max",
|
|
@@ -1497,11 +1497,23 @@ async function fetchLiveModels(session, options = {}) {
|
|
|
1497
1497
|
for (const model of DOUBAO_MODELS) byId.set(model.id, model);
|
|
1498
1498
|
for (const model of discovered) {
|
|
1499
1499
|
if (byId.has(model.id)) {
|
|
1500
|
+
/**
|
|
1501
|
+
* Keep the known-good name; add what the SERVER published, if it has any.
|
|
1502
|
+
*
|
|
1503
|
+
* The effort ladder has to survive this merge — issue #207. Before, only
|
|
1504
|
+
* `badge` was copied, so every model already present in the static table
|
|
1505
|
+
* threw away the 低/中/高/极高/最高 it had just been handed, and the picker
|
|
1506
|
+
* fell back to three fixed levels. Only overwrite when the server really
|
|
1507
|
+
* said something: the IndexedDB-cache path carries no ladder, and an empty
|
|
1508
|
+
* value there must not wipe one that is already known.
|
|
1509
|
+
*/
|
|
1500
1510
|
const known = byId.get(model.id);
|
|
1501
|
-
if (known !== void 0
|
|
1502
|
-
...known
|
|
1503
|
-
badge
|
|
1504
|
-
|
|
1511
|
+
if (known !== void 0) {
|
|
1512
|
+
const next = { ...known };
|
|
1513
|
+
if (known.badge === void 0 && model.badge !== void 0) next.badge = model.badge;
|
|
1514
|
+
if (model.efforts !== void 0 && model.efforts.length > 0) next.efforts = model.efforts;
|
|
1515
|
+
if (next.badge !== known.badge || next.efforts !== known.efforts) byId.set(model.id, next);
|
|
1516
|
+
}
|
|
1505
1517
|
continue;
|
|
1506
1518
|
}
|
|
1507
1519
|
byId.set(model.id, model);
|
|
@@ -4452,7 +4464,8 @@ function registerDoubaoRoutes(ctx, deps) {
|
|
|
4452
4464
|
*/
|
|
4453
4465
|
if (req.method === "POST") {
|
|
4454
4466
|
if (deps.saveDoubaoSelection === void 0) return json$9(res, 503, { error: "settings service unavailable; doubao selection cannot be saved" });
|
|
4455
|
-
const
|
|
4467
|
+
const body = await readJson$1(req);
|
|
4468
|
+
const raw = body["disabledModelIds"];
|
|
4456
4469
|
if (!Array.isArray(raw)) return json$9(res, 400, { error: "disabledModelIds must be an array" });
|
|
4457
4470
|
const ids = [];
|
|
4458
4471
|
for (const entry of raw) {
|
|
@@ -4460,10 +4473,19 @@ function registerDoubaoRoutes(ctx, deps) {
|
|
|
4460
4473
|
if (!ids.includes(entry)) ids.push(entry);
|
|
4461
4474
|
}
|
|
4462
4475
|
try {
|
|
4463
|
-
|
|
4476
|
+
/**
|
|
4477
|
+
* `hideAll` is the card's 「全关」 button.
|
|
4478
|
+
*
|
|
4479
|
+
* It travels separately from the id list because the list cannot say
|
|
4480
|
+
* it: an all-off stored as `[]` (the card's roster had not loaded)
|
|
4481
|
+
* reads back as "nothing disabled", and one stored as "every id"
|
|
4482
|
+
* breaks the moment upstream adds a model.
|
|
4483
|
+
*/
|
|
4484
|
+
await deps.saveDoubaoSelection(ids, body["hideAll"] === true);
|
|
4464
4485
|
return json$9(res, 200, {
|
|
4465
4486
|
ok: true,
|
|
4466
|
-
disabledModelIds: ids
|
|
4487
|
+
disabledModelIds: ids,
|
|
4488
|
+
hideAll: body["hideAll"] === true
|
|
4467
4489
|
});
|
|
4468
4490
|
} catch (error) {
|
|
4469
4491
|
return json$9(res, 500, { error: error instanceof Error ? error.message : String(error) });
|
|
@@ -4880,6 +4902,51 @@ const DOUBAO_PROVIDER_NAME = "豆包";
|
|
|
4880
4902
|
* model, which reads as a broken channel.
|
|
4881
4903
|
*/
|
|
4882
4904
|
const CONTEXT_WINDOW = 256e3;
|
|
4905
|
+
/** The ladder's display names, in the vendor's own words for this language. */
|
|
4906
|
+
const EFFORT_LABELS$6 = {
|
|
4907
|
+
low: "低",
|
|
4908
|
+
mid: "中",
|
|
4909
|
+
medium: "中",
|
|
4910
|
+
high: "高",
|
|
4911
|
+
xhigh: "极高",
|
|
4912
|
+
max: "最高",
|
|
4913
|
+
auto: "自动"
|
|
4914
|
+
};
|
|
4915
|
+
/**
|
|
4916
|
+
* What a model falls back to when the listing carried no ladder of its own.
|
|
4917
|
+
*
|
|
4918
|
+
* The five static rows have no `efforts`, and the picker has always shown
|
|
4919
|
+
* 低/中/高 for them — keeping that is what makes this change invisible to
|
|
4920
|
+
* anyone whose account does not publish ladders (issue #207).
|
|
4921
|
+
*/
|
|
4922
|
+
const FALLBACK_EFFORTS = [
|
|
4923
|
+
"low",
|
|
4924
|
+
"mid",
|
|
4925
|
+
"high"
|
|
4926
|
+
];
|
|
4927
|
+
/**
|
|
4928
|
+
* Three levels that sit at the same POSITIONS on whatever ladder a model has.
|
|
4929
|
+
*
|
|
4930
|
+
* Not "filter by name": Qwen 4 Max publishes 低/高/极高 (three levels, no 最高 at
|
|
4931
|
+
* all), so a `['low','high','max']` filter left it with two — fewer than the
|
|
4932
|
+
* client itself offers. Taking the first, the middle and the last gives every
|
|
4933
|
+
* model three levels, and the top one is always the top one it really publishes.
|
|
4934
|
+
*/
|
|
4935
|
+
function collapseLadder(efforts) {
|
|
4936
|
+
const ladder = (efforts ?? []).filter((level) => typeof level === "string" && level !== "");
|
|
4937
|
+
if (ladder.length === 0) return FALLBACK_EFFORTS;
|
|
4938
|
+
if (ladder.length <= 3) return ladder;
|
|
4939
|
+
const middle = ladder[Math.floor((ladder.length - 1) / 2)];
|
|
4940
|
+
return [
|
|
4941
|
+
ladder[0],
|
|
4942
|
+
middle,
|
|
4943
|
+
ladder[ladder.length - 1]
|
|
4944
|
+
];
|
|
4945
|
+
}
|
|
4946
|
+
/** The label for one level id, falling back to the id itself. */
|
|
4947
|
+
function effortLabel(level) {
|
|
4948
|
+
return EFFORT_LABELS$6[level] ?? level;
|
|
4949
|
+
}
|
|
4883
4950
|
/** The output ceiling the lane requests. */
|
|
4884
4951
|
const MAX_OUTPUT_TOKENS$1 = 65536;
|
|
4885
4952
|
/**
|
|
@@ -4936,6 +5003,15 @@ var DoubaoHostAdapter = class extends LlmAdapter {
|
|
|
4936
5003
|
};
|
|
4937
5004
|
}
|
|
4938
5005
|
async listModels(_provider) {
|
|
5006
|
+
/**
|
|
5007
|
+
* 「全关」 is an explicit state, not a very long disable-list — see the
|
|
5008
|
+
* `hideAll` option. Answered before the session read so it holds even when
|
|
5009
|
+
* the listing itself cannot be fetched.
|
|
5010
|
+
*/
|
|
5011
|
+
if (this.options.hideAll?.() === true) {
|
|
5012
|
+
this.cached = void 0;
|
|
5013
|
+
return [];
|
|
5014
|
+
}
|
|
4939
5015
|
const session = this.options.session();
|
|
4940
5016
|
/**
|
|
4941
5017
|
* No session, no models — issue #169.
|
|
@@ -5001,11 +5077,15 @@ var DoubaoHostAdapter = class extends LlmAdapter {
|
|
|
5001
5077
|
const prompt = system === "" ? body : `${system}\n\n${body}`;
|
|
5002
5078
|
if (prompt === "") throw new LlmError("这条请求没有可发送的文字", "invalid");
|
|
5003
5079
|
const requested = options["reasoningEffort"];
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5080
|
+
/**
|
|
5081
|
+
* Accept every level the vendor publishes — issue #207.
|
|
5082
|
+
*
|
|
5083
|
+
* The whitelist used to be the literal `['low','mid','high']`, so a picker
|
|
5084
|
+
* showing 极高/最高 still had them silently downgraded to 中 on the way out:
|
|
5085
|
+
* the display and the wire disagreed. `DOUBAO_REASONING_LEVELS` is the same
|
|
5086
|
+
* table the picker's labels come from, so the two cannot drift.
|
|
5087
|
+
*/
|
|
5088
|
+
const level = typeof requested === "string" && DOUBAO_REASONING_LEVELS.some((entry) => entry.id === requested) ? requested : "mid";
|
|
5009
5089
|
const signal = options["signal"] instanceof AbortSignal ? options["signal"] : new AbortController().signal;
|
|
5010
5090
|
const textQueue = [];
|
|
5011
5091
|
const reasoningQueue = [];
|
|
@@ -5073,23 +5153,29 @@ var DoubaoHostAdapter = class extends LlmAdapter {
|
|
|
5073
5153
|
inputModalities: ["text", "image"],
|
|
5074
5154
|
defaultMaxTokens: MAX_OUTPUT_TOKENS$1,
|
|
5075
5155
|
context: { contextWindow: model.contextWindow ?? CONTEXT_WINDOW },
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
]
|
|
5091
|
-
|
|
5092
|
-
|
|
5156
|
+
/**
|
|
5157
|
+
* The ladder each model actually publishes — issue #207.
|
|
5158
|
+
*
|
|
5159
|
+
* This used to be a hard-coded 低/中/高 for every row, so Kimi's 最高 and
|
|
5160
|
+
* Qwen's 极高 were unreachable from the picker even though the client's own
|
|
5161
|
+
* menu had been parsed into `efforts` all along. `collapseLadder` keeps
|
|
5162
|
+
* three levels for the picker but takes them from the model's real list.
|
|
5163
|
+
*
|
|
5164
|
+
* `reasoning: false` (豆包快速) carries no ladder at all: offering a
|
|
5165
|
+
* thinking control for a model that does not think is worse than offering
|
|
5166
|
+
* none.
|
|
5167
|
+
*/
|
|
5168
|
+
...model.reasoning === false ? {} : (() => {
|
|
5169
|
+
const levels = collapseLadder(model.efforts);
|
|
5170
|
+
const middle = levels[Math.floor((levels.length - 1) / 2)];
|
|
5171
|
+
return {
|
|
5172
|
+
efforts: levels.map((level) => ({
|
|
5173
|
+
id: ReasoningEffortId(level),
|
|
5174
|
+
name: effortLabel(level)
|
|
5175
|
+
})),
|
|
5176
|
+
defaultEffort: ReasoningEffortId(middle)
|
|
5177
|
+
};
|
|
5178
|
+
})(),
|
|
5093
5179
|
...rate === void 0 ? {} : { tags: [{
|
|
5094
5180
|
text: rate,
|
|
5095
5181
|
tone: free ? "free" : "price"
|
|
@@ -29220,7 +29306,7 @@ function parseBody(body) {
|
|
|
29220
29306
|
*
|
|
29221
29307
|
* @module dsh-xdpool/version
|
|
29222
29308
|
*/
|
|
29223
|
-
const POOL_VERSION = "3.0.
|
|
29309
|
+
const POOL_VERSION = "3.0.4";
|
|
29224
29310
|
//#endregion
|
|
29225
29311
|
//#region src/update-check.ts
|
|
29226
29312
|
/**
|
|
@@ -37844,7 +37930,9 @@ const Config = z.object({
|
|
|
37844
37930
|
* card needs (client writes, host reads without a restart); it is also why the
|
|
37845
37931
|
* polarity matters — the default `[]` has to be the harmless answer.
|
|
37846
37932
|
*/
|
|
37847
|
-
doubaoDisabledModels: asVolatile(z.array(z.string()).default([]).description("Doubao model ids switched off in the picker (mirrored from the Doubao card; empty shows the whole roster)"))
|
|
37933
|
+
doubaoDisabledModels: asVolatile(z.array(z.string()).default([]).description("Doubao model ids switched off in the picker (mirrored from the Doubao card; empty shows the whole roster)")),
|
|
37934
|
+
/** The card's 「全关」, mirrored so the picker can empty the group (see the Config doc). */
|
|
37935
|
+
doubaoHideAllModels: asVolatile(z.boolean().default(false).description("Hide every Doubao model in the picker (the card's 全关 switch)"))
|
|
37848
37936
|
});
|
|
37849
37937
|
/** Live API, published for the CLI. */
|
|
37850
37938
|
let api;
|
|
@@ -38542,9 +38630,10 @@ function apply(ctx, config = {}) {
|
|
|
38542
38630
|
* `setSetting` re-reads and throws when the document did not change, so a
|
|
38543
38631
|
* refused write reaches the card as a 500 instead of looking saved.
|
|
38544
38632
|
*/
|
|
38545
|
-
saveDoubaoSelection: async (ids) => {
|
|
38633
|
+
saveDoubaoSelection: async (ids, hideAll) => {
|
|
38546
38634
|
const payload = [...ids];
|
|
38547
38635
|
await setSetting("doubaoDisabledModels", payload, payload);
|
|
38636
|
+
await setSetting("doubaoHideAllModels", hideAll === true, hideAll === true);
|
|
38548
38637
|
}
|
|
38549
38638
|
});
|
|
38550
38639
|
/**
|
|
@@ -38954,7 +39043,9 @@ function apply(ctx, config = {}) {
|
|
|
38954
39043
|
* settings change is visible without re-registering anything —
|
|
38955
39044
|
* unlike the pi-ai lanes, which need `invalidateCatalog`.
|
|
38956
39045
|
*/
|
|
38957
|
-
disabled: () => current().doubaoDisabledModels
|
|
39046
|
+
disabled: () => current().doubaoDisabledModels,
|
|
39047
|
+
/** 「全关」 — an explicit state, not a long disable-list. */
|
|
39048
|
+
hideAll: () => current().doubaoHideAllModels === true
|
|
38958
39049
|
}));
|
|
38959
39050
|
/**
|
|
38960
39051
|
* Marvis, the fifteenth channel.
|
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.
|
|
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 {
|