dsh-xdpool 2.6.6 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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.7.0",
6
6
  "license": "MIT",
7
7
  "author": "XDTrees",
8
8
  "homepage": "https://github.com/XDTrees/dsh-xdpool#readme",
@@ -33373,7 +33373,22 @@ var CodeArtsAdapter = class extends LlmAdapter {
33373
33373
  if (currentAccountId) rateLimitTried.add(currentAccountId);
33374
33374
  const isBenefitModel = isCodeArtsBenefitModel(options.model);
33375
33375
  for (; ; ) {
33376
- const extraSignedHeaders = isBenefitModel && !benefitHeaderDropped ? { maas_type: "benefit" } : void 0;
33376
+ /**
33377
+ * [xdpool-local] The benefit header is NEVER sent — issue #150.
33378
+ *
33379
+ * `maas_type: benefit` routes the request onto a lane the upstream has retired: with it
33380
+ * the first frame is `InferHub.APIG.0101.404`, which surfaces as
33381
+ * "The API does not exist or has not been published in the environment". Without it the
33382
+ * SAME model, account, body and endpoint answer normally — measured both ways on
33383
+ * `glm-5.3-flash` and `deepseek-v4.1-flash`.
33384
+ *
33385
+ * #149 read the same failure as "these model ids are no longer published" and proposed
33386
+ * switching them off. Its control group changed the ID rather than the header, and every
33387
+ * id it compared happened to be outside the benefit list — so the variable it meant to
33388
+ * isolate was never isolated, and disabling the ids would have removed two working
33389
+ * models while leaving the real cause in place.
33390
+ */
33391
+ const extraSignedHeaders = void 0;
33377
33392
  const signed = await signRequestHuawei(
33378
33393
  credential.access_key_id,
33379
33394
  credential.secret_access_key,
@@ -52353,6 +52368,25 @@ function hasZcodeUnusualActivity(body) {
52353
52368
  if (code !== void 0) return isZcodeUnusualActivityCode(code);
52354
52369
  return mentionsZcodeUnusualActivity(body);
52355
52370
  }
52371
+ /**
52372
+ * [xdpool-local] Recognise the risk-control refusal that arrives with NO code and a
52373
+ * non-401 status (#132).
52374
+ *
52375
+ * The reporter's screenshot showed `HTTP 405 · request has been blocked due to unusual
52376
+ * activity` reaching the user as a generic HTTP error, while the same condition on another
52377
+ * request produced the proper 3012 wording. The reason is that the body carries no
52378
+ * `code` field and the status is neither 401 nor 403, so every existing branch missed it —
52379
+ * `hasZcodeUnusualActivity` was consulted only AFTER the code checks, and the fallback
52380
+ * printed `HTTP 405: …`.
52381
+ *
52382
+ * A 405 here is never a real method error: this lane sends one fixed POST. It is the WAF
52383
+ * answering a request it decided not to inspect. Treated as risk control so the user gets
52384
+ * the cooldown warning instead of a status they can do nothing with.
52385
+ */
52386
+ function isZcodeBlockedWithoutCode(status, body) {
52387
+ if (status !== 405 && status !== 403) return false;
52388
+ return /blocked|unusual activity|forbidden/iu.test(body);
52389
+ }
52356
52390
  function looksLikeZcodeUnusualActivity(body) {
52357
52391
  return /(?<![0-9A-Za-z_-])3012(?![0-9A-Za-z_-])/.test(body);
52358
52392
  }
@@ -55690,7 +55724,7 @@ function describeUpstreamError(status, body, diagnostic) {
55690
55724
  if (code === 3007 || trimmed.includes("3007")) {
55691
55725
  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
55726
  }
55693
- if (hasZcodeUnusualActivity(trimmed)) {
55727
+ if (hasZcodeUnusualActivity(trimmed) || isZcodeBlockedWithoutCode(status, trimmed)) {
55694
55728
  return formatZcodeUnusualActivityMessage({ diagnostic, rawResponse: suffix });
55695
55729
  }
55696
55730
  if (code === 1002 || status === 401) {
@@ -55701,7 +55735,7 @@ function describeUpstreamError(status, body, diagnostic) {
55701
55735
  function httpErrorCodeForZcode(status, body) {
55702
55736
  const trimmed = body.trim();
55703
55737
  if (trimmed.includes("3007")) return "RATE_LIMIT";
55704
- if (hasZcodeUnusualActivity(trimmed)) return "PERMISSION";
55738
+ if (hasZcodeUnusualActivity(trimmed) || isZcodeBlockedWithoutCode(status, trimmed)) return "PERMISSION";
55705
55739
  if (trimmed.includes("1113") || trimmed.includes("\u4F59\u989D\u4E0D\u8DB3")) return "QUOTA_EXCEEDED";
55706
55740
  if (status === 401 || trimmed.includes("1002")) return "AUTH";
55707
55741
  if (status === 429) return "RATE_LIMIT";
@@ -66934,7 +66968,26 @@ function createChannelFetch(options = {}) {
66934
66968
  let system;
66935
66969
  let systemAt = 0;
66936
66970
  let closed = false;
66937
- const fetchImpl = (input, init) => (options.fetchImpl ?? globalThis.fetch)(input, init);
66971
+ /**
66972
+ * [xdpool-local] Capture the fetch implementation ONCE, not at every call (#140).
66973
+ *
66974
+ * `options.fetchImpl ?? globalThis.fetch` read the global lazily, at call time. When
66975
+ * another plugin patches `globalThis.fetch` — billion-context does, to enforce an 8 MiB
66976
+ * direct-upload gate — that patch became the outbound transport for EVERY channel
66977
+ * request. It has no idea which conversation a request belongs to, so it either refused
66978
+ * the body (422, which the outer layer renders as a 400) or lost the session attribution
66979
+ * the channel needs.
66980
+ *
66981
+ * Binding here means this service uses the implementation that existed when it was
66982
+ * created, so a later patch cannot silently intercept the channel's traffic. An explicit
66983
+ * `options.fetchImpl` still wins — that is how a test or an embedder substitutes one on
66984
+ * purpose.
66985
+ */
66986
+ const boundFetch = options.fetchImpl ?? (typeof globalThis.fetch === "function" ? globalThis.fetch.bind(globalThis) : undefined);
66987
+ const fetchImpl = (input, init) => {
66988
+ if (boundFetch === undefined) throw new Error("\u6E20\u9053\u51FA\u7F51\u670D\u52A1\u7F3A\u5C11 fetch \u5B9E\u73B0");
66989
+ return boundFetch(input, init);
66990
+ };
66938
66991
  const fetcher = async (input, init) => {
66939
66992
  if (closed) throw new Error("\u6E20\u9053\u51FA\u7F51\u670D\u52A1\u5DF2\u505C\u6B62");
66940
66993
  const target = new URL(input instanceof Request ? input.url : String(input));