dsh-xdpool 2.6.6 → 2.6.7

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,47 @@
1
1
  # Changelog
2
2
  本项目的所有重要变更都会记录在此文件。
3
3
  版本号遵循 [语义化版本](https://semver.org/lang/zh-CN/)。
4
+ ## 2.6.7 — 路由链的渠道成员不再被双重加前缀
5
+
6
+ > 四张 issue:一条数据会被写坏的路由缺陷,两条真实代码缺陷,一条「说清楚」的改动。
7
+
8
+ ### 渠道成员 id 被加了两次前缀(#141)
9
+
10
+ 一条 9 成员的混合链在路由页报「这些成员暂时不在册」,实际存下来的形态是:
11
+
12
+ ```
13
+ trae/trae:deepseek-v4.1-flash
14
+ raccoon/raccoon:sn-deepseek-v4-1-flash-1017
15
+ cline/cline:deepseek/deepseek-v4.1-flash-1017:batch
16
+ ```
17
+
18
+ 两个根因叠加:
19
+
20
+ - `splitPlatforms` 按第一个 `/` 切分。`cline:deepseek/…` 被切成 provider `cline`、model `cline:deepseek/…`,编辑器于是显示双前缀。
21
+ - `flattenDraft` 给所有非池子泳道拼 `${owner}/${model}`,而渠道成员自己的 id(`raccoon:sn-…`)已经带着 owner。
22
+
23
+ 结果是运行时匹配不到任何成员,**在这种状态下保存会把双前缀写回配置**——报告里最危险的部分。
24
+
25
+ 修法是认冒号:`<channel>:<model>` 本身完整,`<owner>/<model>` 才是第三方 provider 行的写法。渠道头必须是裸标识符(字母、数字、`_`、`-`),所以 `https://host/x` 不会被误认成渠道 `https`。缺成员的归属判断也改成同一套规则,否则 `raccoon:sn-…` 会被归到 `workbuddy` 下。
26
+
27
+ ### 出网 fetch 在调用时才读全局(#140)
28
+
29
+ `options.fetchImpl ?? globalThis.fetch` 每次请求都重新读全局。billion-context 会打补丁拦截 `globalThis.fetch` 来做 8 MiB 直连闸门,于是那个补丁成了**所有渠道请求的传输层**——它不知道请求属于哪个会话,结果要么拒绝请求体(422,外层渲染成 400),要么丢掉渠道需要的会话归属。
30
+
31
+ 改成创建时捕获一次。显式传入的 `options.fetchImpl` 仍然优先,测试和嵌入方照旧可以替换。
32
+
33
+ ### 明确指定的模型不再被显示过滤挡住(#143)
34
+
35
+ 卡片勾选决定选择器**列出**什么,不该决定 provider **能服务**什么。`kimi-k3.1-pro` 在名册上、账号也能跑,却因为不在勾选的四项里报 `has no configured model`——拒绝来自一个显示过滤器。
36
+
37
+ 现在返回「勾选的在前、其余在后」的并集:默认选择不变,显式指定的 id 也能解析。图片开关和上下文预算仍取 `visible()` 的结果,因为那两项是用户明确说了算的。
38
+
39
+ ### zcode 无 code 的风控拒绝被当成裸 405(#132)
40
+
41
+ 截图里 `HTTP 405 · request has been blocked due to unusual activity` 被渲染成普通 HTTP 错误,而同一种情况在别处能得到正确的 3012 提示。原因是响应体没有 `code` 字段、状态码既不是 401 也不是 403,所有分支都没命中。
42
+
43
+ 这条车道只发一个固定的 POST,405 不可能是真的方法错误——那是 WAF 在回应一个它决定不检查的请求。现在按风控归类,用户看到的是冷却警告而不是一个无从下手的状态码。
44
+
4
45
  ## 2.6.6 — 免费线上游已关闭;国际版每日活跃;网关支持非流式
5
46
 
6
47
  > 三处独立改动:一个必须如实说明的坏消息,两个来自社区的修复。
package/lib/client.js CHANGED
@@ -10326,7 +10326,19 @@ window.__ModuleLoader__.load({
10326
10326
  const out = [];
10327
10327
  const seen = /* @__PURE__ */ new Set();
10328
10328
  for (const platform of platforms) for (const model of platform.models) {
10329
- const id = platform.owner === "workbuddy" ? model : `${platform.owner}/${model}`;
10329
+ /**
10330
+ * A channel member is ALREADY composite (#141).
10331
+ *
10332
+ * `owner` here is the editor's grouping label. For a scan-login channel the
10333
+ * member's own id is `<channel>:<model>` and already carries the owner, so
10334
+ * prefixing it again produced `trae/trae:deepseek-v4.1-flash`. The runtime then
10335
+ * matched nothing and the chain reported every member missing — and a save in that
10336
+ * state would have rewritten the chain with the doubled ids.
10337
+ *
10338
+ * The colon is the test, matching `channelMemberOf` in `combos.ts`.
10339
+ */
10340
+ const selfOwned = /^[A-Za-z0-9_-]+:/u.test(model);
10341
+ const id = platform.owner === "workbuddy" || selfOwned ? model : `${platform.owner}/${model}`;
10330
10342
  if (seen.has(id)) continue;
10331
10343
  seen.add(id);
10332
10344
  out.push(id);
@@ -10357,9 +10369,19 @@ window.__ModuleLoader__.load({
10357
10369
  const known = new Set(Array.isArray(combo.models) ? combo.models : []);
10358
10370
  for (const modelId of Array.isArray(combo.missing) ? combo.missing : []) {
10359
10371
  if (known.has(modelId)) continue;
10372
+ /**
10373
+ * Read the owner the same way `combos.ts` does, so a missing CHANNEL member is filed
10374
+ * under its channel rather than under a slash prefix (#141).
10375
+ *
10376
+ * `raccoon:sn-…` belongs to `raccoon`; splitting on `/` would find no slash, call it a
10377
+ * pool model, and then `flattenDraft` would write `workbuddy/raccoon:…` back.
10378
+ */
10379
+ const colon = modelId.indexOf(":");
10380
+ const channelHead = colon > 0 ? modelId.slice(0, colon) : "";
10381
+ const isChannelMember = channelHead !== "" && /^[A-Za-z0-9_-]+$/u.test(channelHead);
10360
10382
  const slash = modelId.indexOf("/");
10361
- const owner = slash === -1 ? "workbuddy" : modelId.slice(0, slash);
10362
- const model = slash === -1 ? modelId : modelId.slice(slash + 1);
10383
+ const owner = isChannelMember ? channelHead : slash === -1 ? "workbuddy" : modelId.slice(0, slash);
10384
+ const model = isChannelMember ? modelId : slash === -1 ? modelId : modelId.slice(slash + 1);
10363
10385
  const group = platforms.find((entry) => entry.owner === owner);
10364
10386
  if (group === void 0) platforms.push({
10365
10387
  owner,
@@ -13470,7 +13492,7 @@ window.__ModuleLoader__.load({
13470
13492
  *
13471
13493
  * @module dsh-xdpool/version
13472
13494
  */
13473
- const POOL_VERSION = "2.6.6";
13495
+ const POOL_VERSION = "2.6.7";
13474
13496
  //#endregion
13475
13497
  //#region src/client/PoolCard.tsx
13476
13498
  /**
package/lib/index.js CHANGED
@@ -11177,6 +11177,20 @@ function flattenPlatforms(platforms) {
11177
11177
  * owner is read from its shape (`workbuddy` for a bare id, the prefix otherwise)
11178
11178
  * and groups come out in first-seen order — which is the order the members were
11179
11179
  * in, so re-flattening reproduces exactly what was stored.
11180
+ *
11181
+ * ## A channel member's id is NOT `owner/model` (#141)
11182
+ *
11183
+ * A scan-login channel publishes members as `<channel>:<model>`, and the model id
11184
+ * may itself contain slashes (`cline:deepseek/deepseek-v4.1-flash-1017:batch`).
11185
+ * Splitting on the first `/` turns that into provider `cline` and model
11186
+ * `cline:deepseek/…`, so the editor showed a doubled prefix and the round-trip
11187
+ * write added one more (`trae/trae:deepseek-v4.1-flash`), at which point the
11188
+ * runtime could no longer match any member and the chain reported every one of
11189
+ * them missing.
11190
+ *
11191
+ * The colon is the discriminator: `<channel>:<model>` names a channel member as a
11192
+ * single token, while `<owner>/<model>` is how a third-party provider row is
11193
+ * written. Checked BEFORE the slash split so a channel id is never cut.
11180
11194
  */
11181
11195
  function splitPlatforms(models) {
11182
11196
  const groups = /* @__PURE__ */ new Map();
@@ -11184,9 +11198,15 @@ function splitPlatforms(models) {
11184
11198
  for (const raw of models) {
11185
11199
  const id = text$6(raw);
11186
11200
  if (id === "") continue;
11187
- const parsed = parseProviderModelId(id);
11188
- const owner = parsed === null ? POOL_OWNER : parsed.providerId;
11189
- const model = parsed === null ? id : parsed.modelId;
11201
+ /**
11202
+ * `channel:model` — keep the whole thing as the model and file it under the
11203
+ * channel. `indexOf('/') === -1` is not required: the model half may contain
11204
+ * slashes, and the colon is what marks the shape.
11205
+ */
11206
+ const channelMember = channelMemberOf(id);
11207
+ const parsed = channelMember === void 0 ? parseProviderModelId(id) : null;
11208
+ const owner = channelMember === void 0 ? parsed === null ? POOL_OWNER : parsed.providerId : channelMember.channel;
11209
+ const model = channelMember === void 0 ? parsed === null ? id : parsed.modelId : channelMember.model;
11190
11210
  let bucket = groups.get(owner);
11191
11211
  if (bucket === void 0) {
11192
11212
  bucket = [];
@@ -11200,6 +11220,26 @@ function splitPlatforms(models) {
11200
11220
  models: groups.get(owner) ?? []
11201
11221
  }));
11202
11222
  }
11223
+ /**
11224
+ * Read `<channel>:<model>` where the channel is a bare identifier.
11225
+ *
11226
+ * Returns undefined for anything else, so a provider-row id (`openai/gpt-4`) and a
11227
+ * bare pool id (`hy3`) both keep whatever handling they had. The channel half is
11228
+ * required to look like an identifier rather than a URL scheme: `https://…` has a
11229
+ * colon too, and treating that as a channel would file the row under `https`.
11230
+ */
11231
+ function channelMemberOf(id) {
11232
+ const colon = id.indexOf(":");
11233
+ if (colon <= 0) return void 0;
11234
+ const channel = id.slice(0, colon);
11235
+ const model = id.slice(colon + 1);
11236
+ if (model === "") return void 0;
11237
+ if (!/^[A-Za-z0-9_-]+$/u.test(channel)) return void 0;
11238
+ return {
11239
+ channel,
11240
+ model
11241
+ };
11242
+ }
11203
11243
  /** Windows assumed when nothing on the chain declares one. */
11204
11244
  const COMBO_DEFAULT_CONTEXT_WINDOW = 131072;
11205
11245
  /** Output ceiling assumed when nothing on the chain declares one. */
@@ -13629,7 +13669,35 @@ function createWorkBuddyAdapter(options) {
13629
13669
  const baseUrl = `${shim.baseUrl()}/v1`;
13630
13670
  if (extraRows !== void 0) return (extraRows() ?? []).map((row) => toExtraLaneModel(row, baseUrl, providerId));
13631
13671
  if (aggregateCatalog) return [...catalog.providerRows().map((row) => toAggregateModel(row, baseUrl, providerId)), ...catalog.comboRows().map((row) => toComboModel(row, baseUrl, providerId))];
13632
- return catalog.visible().map((info) => toPiModel(info, baseUrl, providerId));
13672
+ /**
13673
+ * EVERY model, with the user's selection applied where it is meaningful (#143).
13674
+ *
13675
+ * The card's tick-boxes narrow what the picker LISTS, and `visible()` is the right
13676
+ * answer for "what should be offered". It is the wrong answer for "what can this
13677
+ * provider serve": a user who types or picks a model by id — `kimi-k3.1-pro` in the
13678
+ * report — got `pi-ai provider "xdpool" has no configured model "kimi-k3.1-pro"`,
13679
+ * because that model was not in the four ticked boxes. The model existed, the account
13680
+ * could serve it, and the refusal came from a display filter.
13681
+ *
13682
+ * So the selection is applied as an ORDER and a per-model capability override, not as
13683
+ * a hard allow-list:
13684
+ *
13685
+ * - ticked models come first, in catalogue order (what the picker shows);
13686
+ * - unticked models follow, so an explicit id still resolves;
13687
+ * - the image flag and the context budget still come from `visible()`, because those
13688
+ * are the two settings where "the user said so" must win.
13689
+ *
13690
+ * `visible()` cannot express the ordering on its own — it returns a filtered list — so
13691
+ * the two are merged here, keyed by id, with the per-model overrides taken from the
13692
+ * visible row when it exists.
13693
+ */
13694
+ const withSelection = () => {
13695
+ const shown = catalog.visible();
13696
+ const shownIds = new Set(shown.map((info) => info.id));
13697
+ const rest = catalog.current().filter((info) => !shownIds.has(info.id));
13698
+ return [...shown, ...rest].map((info) => toPiModel(info, baseUrl, providerId));
13699
+ };
13700
+ return withSelection();
13633
13701
  };
13634
13702
  /**
13635
13703
  * Build a fresh provider object whose `models` array is the catalog as it
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 13 vendors by QR/web, aggregate 76 vendors' free tiers, plus a usage dashboard, model routing, a local OpenAI-compatible gateway and a points-automation suite.",
5
- "version": "2.6.6",
5
+ "version": "2.6.7",
6
6
  "license": "MIT",
7
7
  "author": "XDTrees",
8
8
  "homepage": "https://github.com/XDTrees/dsh-xdpool#readme",
@@ -52353,6 +52353,25 @@ function hasZcodeUnusualActivity(body) {
52353
52353
  if (code !== void 0) return isZcodeUnusualActivityCode(code);
52354
52354
  return mentionsZcodeUnusualActivity(body);
52355
52355
  }
52356
+ /**
52357
+ * [xdpool-local] Recognise the risk-control refusal that arrives with NO code and a
52358
+ * non-401 status (#132).
52359
+ *
52360
+ * The reporter's screenshot showed `HTTP 405 · request has been blocked due to unusual
52361
+ * activity` reaching the user as a generic HTTP error, while the same condition on another
52362
+ * request produced the proper 3012 wording. The reason is that the body carries no
52363
+ * `code` field and the status is neither 401 nor 403, so every existing branch missed it —
52364
+ * `hasZcodeUnusualActivity` was consulted only AFTER the code checks, and the fallback
52365
+ * printed `HTTP 405: …`.
52366
+ *
52367
+ * A 405 here is never a real method error: this lane sends one fixed POST. It is the WAF
52368
+ * answering a request it decided not to inspect. Treated as risk control so the user gets
52369
+ * the cooldown warning instead of a status they can do nothing with.
52370
+ */
52371
+ function isZcodeBlockedWithoutCode(status, body) {
52372
+ if (status !== 405 && status !== 403) return false;
52373
+ return /blocked|unusual activity|forbidden/iu.test(body);
52374
+ }
52356
52375
  function looksLikeZcodeUnusualActivity(body) {
52357
52376
  return /(?<![0-9A-Za-z_-])3012(?![0-9A-Za-z_-])/.test(body);
52358
52377
  }
@@ -55690,7 +55709,7 @@ function describeUpstreamError(status, body, diagnostic) {
55690
55709
  if (code === 3007 || trimmed.includes("3007")) {
55691
55710
  return `\u963F\u91CC\u4E91 captcha \u6821\u9A8C\u5931\u8D25\uFF083007\uFF09\u3002\u8BF7\u91CD\u8BD5\uFF1B\u82E5\u6301\u7EED\u5931\u8D25\uFF0C\u68C0\u67E5\u6D4F\u89C8\u5668\u662F\u5426\u53EF\u7528\u3002`;
55692
55711
  }
55693
- if (hasZcodeUnusualActivity(trimmed)) {
55712
+ if (hasZcodeUnusualActivity(trimmed) || isZcodeBlockedWithoutCode(status, trimmed)) {
55694
55713
  return formatZcodeUnusualActivityMessage({ diagnostic, rawResponse: suffix });
55695
55714
  }
55696
55715
  if (code === 1002 || status === 401) {
@@ -55701,7 +55720,7 @@ function describeUpstreamError(status, body, diagnostic) {
55701
55720
  function httpErrorCodeForZcode(status, body) {
55702
55721
  const trimmed = body.trim();
55703
55722
  if (trimmed.includes("3007")) return "RATE_LIMIT";
55704
- if (hasZcodeUnusualActivity(trimmed)) return "PERMISSION";
55723
+ if (hasZcodeUnusualActivity(trimmed) || isZcodeBlockedWithoutCode(status, trimmed)) return "PERMISSION";
55705
55724
  if (trimmed.includes("1113") || trimmed.includes("\u4F59\u989D\u4E0D\u8DB3")) return "QUOTA_EXCEEDED";
55706
55725
  if (status === 401 || trimmed.includes("1002")) return "AUTH";
55707
55726
  if (status === 429) return "RATE_LIMIT";
@@ -66934,7 +66953,26 @@ function createChannelFetch(options = {}) {
66934
66953
  let system;
66935
66954
  let systemAt = 0;
66936
66955
  let closed = false;
66937
- const fetchImpl = (input, init) => (options.fetchImpl ?? globalThis.fetch)(input, init);
66956
+ /**
66957
+ * [xdpool-local] Capture the fetch implementation ONCE, not at every call (#140).
66958
+ *
66959
+ * `options.fetchImpl ?? globalThis.fetch` read the global lazily, at call time. When
66960
+ * another plugin patches `globalThis.fetch` — billion-context does, to enforce an 8 MiB
66961
+ * direct-upload gate — that patch became the outbound transport for EVERY channel
66962
+ * request. It has no idea which conversation a request belongs to, so it either refused
66963
+ * the body (422, which the outer layer renders as a 400) or lost the session attribution
66964
+ * the channel needs.
66965
+ *
66966
+ * Binding here means this service uses the implementation that existed when it was
66967
+ * created, so a later patch cannot silently intercept the channel's traffic. An explicit
66968
+ * `options.fetchImpl` still wins — that is how a test or an embedder substitutes one on
66969
+ * purpose.
66970
+ */
66971
+ const boundFetch = options.fetchImpl ?? (typeof globalThis.fetch === "function" ? globalThis.fetch.bind(globalThis) : undefined);
66972
+ const fetchImpl = (input, init) => {
66973
+ if (boundFetch === undefined) throw new Error("\u6E20\u9053\u51FA\u7F51\u670D\u52A1\u7F3A\u5C11 fetch \u5B9E\u73B0");
66974
+ return boundFetch(input, init);
66975
+ };
66938
66976
  const fetcher = async (input, init) => {
66939
66977
  if (closed) throw new Error("\u6E20\u9053\u51FA\u7F51\u670D\u52A1\u5DF2\u505C\u6B62");
66940
66978
  const target = new URL(input instanceof Request ? input.url : String(input));