heybash-xdpool 1.0.5 → 1.0.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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "heybash-xdpool",
3
3
  "displayName": "Heybash",
4
4
  "description": "Heybash model pool for DeepSeek Harness: account rotation, provider aggregation, routing chains, usage insights and a local OpenAI-compatible gateway.",
5
- "version": "1.0.5",
5
+ "version": "1.0.7",
6
6
  "license": "MIT",
7
7
  "author": "Heybash",
8
8
  "contributors": [
@@ -45,10 +45,10 @@ export async function syncMirror({
45
45
  } = {}) {
46
46
  if (version !== undefined && !VERSION.test(version)) throw new Error('Invalid target version')
47
47
  const options = { attempts, intervalMs, sleep, log }
48
- // Match npm/pnpm's metadata representation. The mirror can cache its
49
- // generic */* representation separately from the package-manager response.
48
+ // Match npm/pnpm's install metadata representation. The mirror can cache
49
+ // generic JSON and install metadata independently for several minutes.
50
50
  const read = async (url) => (await request(fetchImpl, url, {
51
- headers: { accept: 'application/json' },
51
+ headers: { accept: 'application/vnd.npm.install-v1+json' },
52
52
  })).json()
53
53
  const official = await retry('Waiting for npm', async () => {
54
54
  const data = await read(NPM)
@@ -33373,12 +33373,27 @@ var CodeArtsAdapter = class extends LlmAdapter {
33373
33373
  let response;
33374
33374
  let queueAttempts = 0;
33375
33375
  let authRefreshed = false;
33376
- let benefitHeaderDropped = false;
33376
+ let benefitHeaderDropped = true;
33377
33377
  const rateLimitTried = /* @__PURE__ */ new Set();
33378
33378
  if (currentAccountId) rateLimitTried.add(currentAccountId);
33379
33379
  const isBenefitModel = isCodeArtsBenefitModel(options.model);
33380
33380
  for (; ; ) {
33381
- const extraSignedHeaders = isBenefitModel && !benefitHeaderDropped ? { maas_type: "benefit" } : void 0;
33381
+ /**
33382
+ * [xdpool-local] The benefit header is NEVER sent — issue #150.
33383
+ *
33384
+ * `maas_type: benefit` routes the request onto a lane the upstream has retired: with it
33385
+ * the first frame is `InferHub.APIG.0101.404`, which surfaces as
33386
+ * "The API does not exist or has not been published in the environment". Without it the
33387
+ * SAME model, account, body and endpoint answer normally — measured both ways on
33388
+ * `glm-5.3-flash` and `deepseek-v4.1-flash`.
33389
+ *
33390
+ * #149 read the same failure as "these model ids are no longer published" and proposed
33391
+ * switching them off. Its control group changed the ID rather than the header, and every
33392
+ * id it compared happened to be outside the benefit list — so the variable it meant to
33393
+ * isolate was never isolated, and disabling the ids would have removed two working
33394
+ * models while leaving the real cause in place.
33395
+ */
33396
+ const extraSignedHeaders = void 0;
33382
33397
  const signed = await signRequestHuawei(
33383
33398
  credential.access_key_id,
33384
33399
  credential.secret_access_key,
@@ -52376,6 +52391,25 @@ function hasZcodeUnusualActivity(body) {
52376
52391
  if (code !== void 0) return isZcodeUnusualActivityCode(code);
52377
52392
  return mentionsZcodeUnusualActivity(body);
52378
52393
  }
52394
+ /**
52395
+ * [xdpool-local] Recognise the risk-control refusal that arrives with NO code and a
52396
+ * non-401 status (#132).
52397
+ *
52398
+ * The reporter's screenshot showed `HTTP 405 · request has been blocked due to unusual
52399
+ * activity` reaching the user as a generic HTTP error, while the same condition on another
52400
+ * request produced the proper 3012 wording. The reason is that the body carries no
52401
+ * `code` field and the status is neither 401 nor 403, so every existing branch missed it —
52402
+ * `hasZcodeUnusualActivity` was consulted only AFTER the code checks, and the fallback
52403
+ * printed `HTTP 405: …`.
52404
+ *
52405
+ * A 405 here is never a real method error: this lane sends one fixed POST. It is the WAF
52406
+ * answering a request it decided not to inspect. Treated as risk control so the user gets
52407
+ * the cooldown warning instead of a status they can do nothing with.
52408
+ */
52409
+ function isZcodeBlockedWithoutCode(status, body) {
52410
+ if (status !== 405 && status !== 403) return false;
52411
+ return /blocked|unusual activity|forbidden/iu.test(body);
52412
+ }
52379
52413
  function looksLikeZcodeUnusualActivity(body) {
52380
52414
  return /(?<![0-9A-Za-z_-])3012(?![0-9A-Za-z_-])/.test(body);
52381
52415
  }
@@ -55713,7 +55747,7 @@ function describeUpstreamError(status, body, diagnostic) {
55713
55747
  if (code === 3007 || trimmed.includes("3007")) {
55714
55748
  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`;
55715
55749
  }
55716
- if (hasZcodeUnusualActivity(trimmed)) {
55750
+ if (hasZcodeUnusualActivity(trimmed) || isZcodeBlockedWithoutCode(status, trimmed)) {
55717
55751
  return formatZcodeUnusualActivityMessage({ diagnostic, rawResponse: suffix });
55718
55752
  }
55719
55753
  if (code === 1002 || status === 401) {
@@ -55724,7 +55758,7 @@ function describeUpstreamError(status, body, diagnostic) {
55724
55758
  function httpErrorCodeForZcode(status, body) {
55725
55759
  const trimmed = body.trim();
55726
55760
  if (trimmed.includes("3007")) return "RATE_LIMIT";
55727
- if (hasZcodeUnusualActivity(trimmed)) return "PERMISSION";
55761
+ if (hasZcodeUnusualActivity(trimmed) || isZcodeBlockedWithoutCode(status, trimmed)) return "PERMISSION";
55728
55762
  if (trimmed.includes("1113") || trimmed.includes("\u4F59\u989D\u4E0D\u8DB3")) return "QUOTA_EXCEEDED";
55729
55763
  if (status === 401 || trimmed.includes("1002")) return "AUTH";
55730
55764
  if (status === 429) return "RATE_LIMIT";
@@ -66957,7 +66991,26 @@ function createChannelFetch(options = {}) {
66957
66991
  let system;
66958
66992
  let systemAt = 0;
66959
66993
  let closed = false;
66960
- const fetchImpl = (input, init) => (options.fetchImpl ?? globalThis.fetch)(input, init);
66994
+ /**
66995
+ * [xdpool-local] Capture the fetch implementation ONCE, not at every call (#140).
66996
+ *
66997
+ * `options.fetchImpl ?? globalThis.fetch` read the global lazily, at call time. When
66998
+ * another plugin patches `globalThis.fetch` — billion-context does, to enforce an 8 MiB
66999
+ * direct-upload gate — that patch became the outbound transport for EVERY channel
67000
+ * request. It has no idea which conversation a request belongs to, so it either refused
67001
+ * the body (422, which the outer layer renders as a 400) or lost the session attribution
67002
+ * the channel needs.
67003
+ *
67004
+ * Binding here means this service uses the implementation that existed when it was
67005
+ * created, so a later patch cannot silently intercept the channel's traffic. An explicit
67006
+ * `options.fetchImpl` still wins — that is how a test or an embedder substitutes one on
67007
+ * purpose.
67008
+ */
67009
+ const boundFetch = options.fetchImpl ?? (typeof globalThis.fetch === "function" ? globalThis.fetch.bind(globalThis) : undefined);
67010
+ const fetchImpl = (input, init) => {
67011
+ if (boundFetch === undefined) throw new Error("\u6E20\u9053\u51FA\u7F51\u670D\u52A1\u7F3A\u5C11 fetch \u5B9E\u73B0");
67012
+ return boundFetch(input, init);
67013
+ };
66961
67014
  const fetcher = async (input, init) => {
66962
67015
  if (closed) throw new Error("\u6E20\u9053\u51FA\u7F51\u670D\u52A1\u5DF2\u505C\u6B62");
66963
67016
  const target = new URL(input instanceof Request ? input.url : String(input));