dsh-xdpool 2.7.0 → 2.7.1

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,60 @@
1
1
  # Changelog
2
2
  本项目的所有重要变更都会记录在此文件。
3
3
  版本号遵循 [语义化版本](https://semver.org/lang/zh-CN/)。
4
+ ## 2.7.1 — 插件入口消失的修复,加四个 issue
5
+
6
+ > 2.7.0 的豆包卡片把 `node:fs` 拖进了浏览器 bundle,导致插件入口整个消失。已修。
7
+
8
+ ### 入口消失:客户端 bundle 混入 Node 模块
9
+
10
+ 豆包卡片要显示模型清单,从 `doubao-llm.ts` 导入了 `doubaoListing`。而那条链是:
11
+
12
+ ```
13
+ doubao-llm.ts → doubao-auth.ts → node:child_process, node:fs
14
+ ```
15
+
16
+ **整条 Node 依赖被打进了浏览器 bundle。** 页面里没有 `require("node:fs")`,一加载就抛错,
17
+ 入口随之消失——插件列表里仍显示已启用,侧边栏和设置页却看不到,而且哪里都不报错。
18
+
19
+ 修法:把模型清单抽成**零依赖**的 `doubao-models.ts`,客户端只读数据不碰 host 模块。
20
+ `lib/client.js` 里 `require("node:...")` 从 4 处降到 **0**。
21
+
22
+ 加了 `tests/client-bundle-purity.test.ts` 防回归。
23
+
24
+ ### #154 TRAE 模型列表永远回退兜底表
25
+
26
+ 扫码登录写的是 `TRAE_ACCOUNT_<hash>`,而模型拉取读的是 `TRAE_ACCESS_TOKEN` ——
27
+ **两个不同的 ref**,resolve 永远是 undefined,于是列表为空、静默放弃,退回 28 条硬编码的
28
+ 兜底模型(名字还是厂商从没发布过的)。重新扫码也修不好,因为它写的 ref 从来不是被读的那个。
29
+
30
+ 修法:池里拿不到可用账号时,退回到**池中任一账号**的凭据——列模型不需要账号可用,
31
+ 只需要一份真凭据,而这个厂商的目录对所有账号都一样。
32
+
33
+ ### #155 qodercn 上下文达限报 `unreachable`
34
+
35
+ 不是模型的上下文限制,是**加密通道的 WASM 内存溢出**:请求体整个写进 ~1MB 的线性内存,
36
+ 逼近上限时分配失败 → Rust panic → 到 DSH 只剩 `unreachable` 一个词。按中文 ≈1.6–2 char/token
37
+ 折算,1MB ≈ 240k–330k token,与「约 256k 崩溃」吻合。
38
+
39
+ 修法:序列化前收缩载荷到 700KB —— **先丢最旧的整轮对话**(丢一半的消息会让请求变非法,
40
+ 而不只是变短),工具 schema 不动(没有 schema 的调用比短历史更糟),仍超限才裁工具描述。
41
+
42
+ ### #127 WorkBuddy 风控被渲染成「API 密钥无效」
43
+
44
+ 403 + `code 11140` 是**账号被风控**,不是凭据失效。原来所有 403 都归成 `session_dead`,
45
+ 于是卡片显示「API 密钥无效」,用户反复重新登录——**但重新登录改不了风控标记**。
46
+
47
+ 新增 `risk_blocked` 分类:按 code 判(不被措辞变化影响)、只对 403 生效(401 带同样的数字
48
+ 仍是认证失败),并把该账号冷却 30 分钟后换下一个。
49
+
50
+ ### #153 积分面板被推到视口外
51
+
52
+ 宿主给 composer seat 加了 `will-change: transform`,而有 transform 的祖先会让
53
+ `position: fixed` **相对该元素**而不是视口定位——面板因此被摆到座位坐标加偏移处(视口下方
54
+ 数百像素),同时还撑开了对话区的滚动高度,看起来像「点一下就多出一大块空白」。
55
+
56
+ 修法:`createPortal` 到 `document.body`,彻底跳出那个包含块。
57
+
4
58
  ## 2.7.0 — 豆包渠道(第 14 家)
5
59
 
6
60
  > 浏览器扫码登录一次,对话与「工作任务」模型全部可用,外带额度看板。同时修掉
package/lib/bin.js CHANGED
@@ -704,8 +704,20 @@ function contentOfFrame(frame) {
704
704
  * Body markers win over status, because the upstream reuses 400/200 for
705
705
  * several distinct conditions.
706
706
  */
707
+ /** Business codes the gateway uses for "this account is risk-flagged". */
708
+ const RISK_BLOCK_CODES = ["11140", "11141"];
707
709
  function classifyUpstreamError(status, body) {
708
710
  if (status === 402) return "hard_credit";
711
+ /**
712
+ * Risk control first, and only for a 403.
713
+ *
714
+ * `11140` is what the gateway returns when the ACCOUNT is flagged. It arrives with 403, so
715
+ * the blanket rule below swallowed it into `session_dead` and the card told the user their
716
+ * key was invalid — several times, since re-signing in changes nothing about a flag.
717
+ */
718
+ if (status === 403) {
719
+ for (const code of RISK_BLOCK_CODES) if (body.includes(`"code":${code}`) || body.includes(`"code": ${code}`) || body.includes(`"code":"${code}"`)) return "risk_blocked";
720
+ }
709
721
  if (status === 401 || status === 403) return "session_dead";
710
722
  const lower = body.toLowerCase();
711
723
  for (const code of HARD_CREDIT_CODES) if (body.includes(`"code":${code}`) || body.includes(`"code": ${code}`) || body.includes(`"code":"${code}"`)) return "hard_credit";
package/lib/client.js CHANGED
@@ -4,33 +4,10 @@ window.__ModuleLoader__.load({
4
4
  var module = { exports: {} };
5
5
  var exports = module.exports;
6
6
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
7
- //#region \0rolldown/runtime.js
8
- var __create = Object.create;
9
- var __defProp = Object.defineProperty;
10
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
11
- var __getOwnPropNames = Object.getOwnPropertyNames;
12
- var __getProtoOf = Object.getPrototypeOf;
13
- var __hasOwnProp = Object.prototype.hasOwnProperty;
14
- var __copyProps = (to, from, except, desc) => {
15
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
16
- key = keys[i];
17
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
18
- get: ((k) => from[k]).bind(null, key),
19
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
- });
21
- }
22
- return to;
23
- };
24
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
25
- value: mod,
26
- enumerable: true
27
- }) : target, mod));
28
7
  //#endregion
29
8
  let react = require("react");
30
9
  let react_jsx_runtime = require("react/jsx-runtime");
31
- let node_crypto = require("node:crypto");
32
- node_crypto = __toESM(node_crypto, 1);
33
- let node_fs = require("node:fs");
10
+ let react_dom = require("react-dom");
34
11
  //#region src/client/sidebar-row.ts
35
12
  /**
36
13
  * The `sidebarRow` switch, read and written from one place.
@@ -12375,51 +12352,13 @@ window.__ModuleLoader__.load({
12375
12352
  return paidSiblingOf(model, models);
12376
12353
  }
12377
12354
  //#endregion
12378
- //#region src/doubao-catalog.ts
12355
+ //#region src/doubao-models.ts
12379
12356
  /**
12380
- * DSH-side alias for "generate an image".
12381
- *
12382
- * NOT a Doubao `model_item_key` — Doubao has no model by this name. Selecting it
12383
- * makes the shim send an ordinary chat turn with `input_skill: imageGen`, and
12384
- * Doubao answers with Seedream. Keeping it in the catalog is what puts 生图 in
12385
- * DSH's model picker without inventing a second UI.
12386
- */
12387
- const DOUBAO_IMAGE_MODEL_ID = "image-gen";
12388
- /**
12389
- * IMAGEGEN_LABEL_OVERLAY: 生图版本名以插件根目录的 image-models.json 为准,
12390
- * 该文件由 doubao_imagemodels.py --sync 从服务端 get_item_conf 生成。
12391
- */
12392
- function imageModelLabelFromOverlay() {
12393
- try {
12394
- const url = new URL("../image-models.json", require("url").pathToFileURL(__filename).href);
12395
- const parsed = JSON.parse((0, node_fs.readFileSync)(url, "utf8"));
12396
- return typeof parsed.label === "string" && parsed.label !== "" ? parsed.label : void 0;
12397
- } catch {
12398
- return;
12399
- }
12400
- }
12401
- /**
12402
- * The entries DSH may offer.
12403
- *
12404
- * WHY THESE ENTRIES. Doubao groups models by MODE, and the model list is per-mode:
12405
- *
12406
- * 对话 → 豆包 快速 (0), 豆包 2.1 Turbo·专家 (3)
12407
- * 工作任务 → 自动 (9), 2.1 Lite (seed-lite-7b), 2.1 Pro (5), Turbo (3)
12408
- *
12409
- * The 「工作任务」 group (`seed-lite-7b`, `5`, `9`) runs through `Agent-GeneralTask`
12410
- * (`mode_id: "3"`, `agent_mode: 1`) and is accompanied by an HTTP `tool_local`
12411
- * workspace responder (`msg/ack` -> `upload_command_result` -> `msg/complete`)
12412
- * so external turns complete without `710010702`.
12413
- *
12414
- * MEASURED, 2026-10-22: `model_item_key` is forwarded verbatim (the server stores
12415
- * it on the message), but in 对话 mode it does NOT change what answers —
12416
- * 0 / 3 / 5 / seed-lite-7b AND a deliberately bogus key all returned answers of
12417
- * indistinguishable length and latency (12.3–14.0 s). So this list is honest
12418
- * about what the PICKER can offer; it does not claim per-key routing.
12357
+ * The models Doubao publishes.
12419
12358
  *
12420
- * 「豆包 快速」 leads because it is the app's own chat-mode default, so an
12421
- * unconfigured install reproduces the app rather than something that merely
12422
- * happens to work.
12359
+ * Every id was read off a real request the desktop app sent, not inferred. ⚠️ The encoding is
12360
+ * MIXED: `seed-lite-7b` is a string slug, `3`/`5`/`9` are numeric enum values — they travel as
12361
+ * JSON strings either way and must be forwarded verbatim, never parsed to a number.
12423
12362
  */
12424
12363
  const DOUBAO_MODELS = [
12425
12364
  {
@@ -12437,46 +12376,38 @@ window.__ModuleLoader__.load({
12437
12376
  id: "seed-lite-7b",
12438
12377
  name: "豆包 2.1 Lite",
12439
12378
  badge: "工作任务",
12440
- reasoning: true,
12441
- taskMode: true
12379
+ reasoning: true
12442
12380
  },
12443
12381
  {
12444
12382
  id: "5",
12445
12383
  name: "豆包 2.1 Pro",
12446
12384
  badge: "工作任务",
12447
- reasoning: true,
12448
- taskMode: true
12385
+ reasoning: true
12449
12386
  },
12450
12387
  {
12451
12388
  id: "9",
12452
12389
  name: "自动",
12453
12390
  badge: "工作任务",
12454
- reasoning: true,
12455
- taskMode: true
12391
+ reasoning: true
12456
12392
  },
12457
12393
  {
12458
- id: DOUBAO_IMAGE_MODEL_ID,
12459
- name: imageModelLabelFromOverlay() ?? "豆包 生图(Seedream 5.5)",
12394
+ id: "image-gen",
12395
+ name: "豆包 生图",
12460
12396
  reasoning: true
12461
12397
  }
12462
12398
  ];
12463
- (0, node_crypto.randomUUID)();
12464
- //#endregion
12465
- //#region src/doubao-llm.ts
12466
- /** The listings, derived from the catalog the reference implementation measured. */
12399
+ /** The listing rows the card and the lane both show. */
12467
12400
  function doubaoListing() {
12468
- const rows = [];
12469
- for (const model of DOUBAO_MODELS) {
12401
+ return DOUBAO_MODELS.map((model) => {
12470
12402
  const parts = [];
12471
- if (typeof model.badge === "string" && model.badge !== "") parts.push(model.badge);
12403
+ if (model.badge !== void 0 && model.badge !== "") parts.push(model.badge);
12472
12404
  if (model.reasoning === true) parts.push("推理");
12473
- rows.push({
12405
+ return {
12474
12406
  id: model.id,
12475
12407
  name: model.name,
12476
12408
  ...parts.length === 0 ? {} : { description: parts.join(" · ") }
12477
- });
12478
- }
12479
- return rows;
12409
+ };
12410
+ });
12480
12411
  }
12481
12412
  //#endregion
12482
12413
  //#region src/client/ChannelPoolSection.tsx
@@ -14053,7 +13984,7 @@ window.__ModuleLoader__.load({
14053
13984
  *
14054
13985
  * @module dsh-xdpool/version
14055
13986
  */
14056
- const POOL_VERSION = "2.7.0";
13987
+ const POOL_VERSION = "2.7.1";
14057
13988
  //#endregion
14058
13989
  //#region src/client/PoolCard.tsx
14059
13990
  /**
@@ -17057,7 +16988,7 @@ window.__ModuleLoader__.load({
17057
16988
  "aria-hidden": "true"
17058
16989
  })
17059
16990
  }),
17060
- !open ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
16991
+ !open ? null : (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
17061
16992
  ref: panelRef,
17062
16993
  className: "dsm-xdpool-dotpanel",
17063
16994
  role: "dialog",
@@ -17125,7 +17056,7 @@ window.__ModuleLoader__.load({
17125
17056
  })
17126
17057
  }) : null
17127
17058
  ] })]
17128
- })
17059
+ }), document.body)
17129
17060
  ]
17130
17061
  });
17131
17062
  }
package/lib/index.d.ts CHANGED
@@ -192,7 +192,20 @@ interface ChatMessage {
192
192
  //#endregion
193
193
  //#region src/upstream.d.ts
194
194
  /** Upstream failure classes the shim maps onto distinct HTTP answers. */
195
- type UpstreamErrorKind = 'hard_credit' | 'soft_rate' | 'session_dead' | 'not_found' | 'server' | 'client';
195
+ type UpstreamErrorKind = 'hard_credit' | 'soft_rate' | 'session_dead' |
196
+ /**
197
+ * The account is blocked by the vendor's risk control — issue #127.
198
+ *
199
+ * A 403 whose body carries `code 11140` means "this account is flagged", not "this
200
+ * credential is invalid". The two were merged into `session_dead`, so the card printed
201
+ * "API 密钥无效" and the user was sent to re-authenticate over and over for a problem that
202
+ * re-authentication cannot fix — the sign-in succeeds, the flag remains.
203
+ *
204
+ * Separated because the remedy differs: a dead session wants a refresh, a flagged account
205
+ * wants the other accounts in the pool and, if all of them are flagged, a word with the
206
+ * vendor.
207
+ */
208
+ 'risk_blocked' | 'not_found' | 'server' | 'client';
196
209
  /** Token-refresh answer; fields the upstream omits stay absent. */
197
210
  interface WorkBuddyRefreshOutcome {
198
211
  accessToken: string;
@@ -322,11 +335,6 @@ interface UpstreamClientOptions {
322
335
  /** Region for a login domain; an empty domain means CN (matching upstream tooling). */
323
336
  /** The two gateways WorkBuddy serves: the domestic one and the international one. */
324
337
  type WorkBuddyRegion = 'cn' | 'global';
325
- /**
326
- * Classify an upstream failure from its HTTP status and body excerpt.
327
- * Body markers win over status, because the upstream reuses 400/200 for
328
- * several distinct conditions.
329
- */
330
338
  export declare function classifyUpstreamError(status: number, body: string): UpstreamErrorKind;
331
339
  /**
332
340
  * Parse the reset time the upstream reports for a rate limit, when present.
package/lib/index.js CHANGED
@@ -472,7 +472,7 @@ function imageModelLabelFromOverlay() {
472
472
  * unconfigured install reproduces the app rather than something that merely
473
473
  * happens to work.
474
474
  */
475
- const DOUBAO_MODELS = [
475
+ const DOUBAO_MODELS$1 = [
476
476
  {
477
477
  id: "0",
478
478
  name: "豆包 快速",
@@ -514,7 +514,7 @@ const DOUBAO_MODELS = [
514
514
  /** True when `id` is a 「工作任务」-mode model (`seed-lite-7b`, `5`, `9`). */
515
515
  function isTaskModel(id) {
516
516
  if (id === void 0) return false;
517
- return DOUBAO_MODELS.some((model) => model.id === id && model.taskMode === true);
517
+ return DOUBAO_MODELS$1.some((model) => model.id === id && model.taskMode === true);
518
518
  }
519
519
  /**
520
520
  * Catalog entry for a model id, falling back to {@link DOUBAO_DEFAULT_MODEL_ID}.
@@ -524,8 +524,8 @@ function isTaskModel(id) {
524
524
  * the request. `describeRequestedModel` in the shim is what surfaces the miss.
525
525
  */
526
526
  function findDoubaoModel(id) {
527
- if (id === void 0) return DOUBAO_MODELS.find((model) => model.id === "0");
528
- const known = DOUBAO_MODELS.find((model) => model.id === id);
527
+ if (id === void 0) return DOUBAO_MODELS$1.find((model) => model.id === "0");
528
+ const known = DOUBAO_MODELS$1.find((model) => model.id === id);
529
529
  if (known !== void 0) return known;
530
530
  return {
531
531
  id,
@@ -534,6 +534,64 @@ function findDoubaoModel(id) {
534
534
  };
535
535
  }
536
536
  //#endregion
537
+ //#region src/doubao-models.ts
538
+ /**
539
+ * The models Doubao publishes.
540
+ *
541
+ * Every id was read off a real request the desktop app sent, not inferred. ⚠️ The encoding is
542
+ * MIXED: `seed-lite-7b` is a string slug, `3`/`5`/`9` are numeric enum values — they travel as
543
+ * JSON strings either way and must be forwarded verbatim, never parsed to a number.
544
+ */
545
+ const DOUBAO_MODELS = [
546
+ {
547
+ id: "0",
548
+ name: "豆包 快速",
549
+ reasoning: false
550
+ },
551
+ {
552
+ id: "3",
553
+ name: "豆包 2.1 Turbo",
554
+ badge: "专家",
555
+ reasoning: true
556
+ },
557
+ {
558
+ id: "seed-lite-7b",
559
+ name: "豆包 2.1 Lite",
560
+ badge: "工作任务",
561
+ reasoning: true
562
+ },
563
+ {
564
+ id: "5",
565
+ name: "豆包 2.1 Pro",
566
+ badge: "工作任务",
567
+ reasoning: true
568
+ },
569
+ {
570
+ id: "9",
571
+ name: "自动",
572
+ badge: "工作任务",
573
+ reasoning: true
574
+ },
575
+ {
576
+ id: "image-gen",
577
+ name: "豆包 生图",
578
+ reasoning: true
579
+ }
580
+ ];
581
+ /** The listing rows the card and the lane both show. */
582
+ function doubaoListing() {
583
+ return DOUBAO_MODELS.map((model) => {
584
+ const parts = [];
585
+ if (model.badge !== void 0 && model.badge !== "") parts.push(model.badge);
586
+ if (model.reasoning === true) parts.push("推理");
587
+ return {
588
+ id: model.id,
589
+ name: model.name,
590
+ ...parts.length === 0 ? {} : { description: parts.join(" · ") }
591
+ };
592
+ });
593
+ }
594
+ //#endregion
537
595
  //#region src/doubao-upstream.ts
538
596
  /**
539
597
  * Doubao upstream client.
@@ -1710,21 +1768,6 @@ const THINKING_BLOCK_TYPE = 10040;
1710
1768
  * client has nothing to register, so the agent has nowhere to run.
1711
1769
  */
1712
1770
  const CODE_TASK_RUNTIME_UNAVAILABLE = 710010702;
1713
- /** The listings, derived from the catalog the reference implementation measured. */
1714
- function doubaoListing() {
1715
- const rows = [];
1716
- for (const model of DOUBAO_MODELS) {
1717
- const parts = [];
1718
- if (typeof model.badge === "string" && model.badge !== "") parts.push(model.badge);
1719
- if (model.reasoning === true) parts.push("推理");
1720
- rows.push({
1721
- id: model.id,
1722
- name: model.name,
1723
- ...parts.length === 0 ? {} : { description: parts.join(" · ") }
1724
- });
1725
- }
1726
- return rows;
1727
- }
1728
1771
  /** The text of a host content value, which may be a string or a block list. */
1729
1772
  function textOf$1(content) {
1730
1773
  if (typeof content === "string") return content;
@@ -3435,8 +3478,20 @@ function contentOfFrame(frame) {
3435
3478
  * Body markers win over status, because the upstream reuses 400/200 for
3436
3479
  * several distinct conditions.
3437
3480
  */
3481
+ /** Business codes the gateway uses for "this account is risk-flagged". */
3482
+ const RISK_BLOCK_CODES = ["11140", "11141"];
3438
3483
  function classifyUpstreamError(status, body) {
3439
3484
  if (status === 402) return "hard_credit";
3485
+ /**
3486
+ * Risk control first, and only for a 403.
3487
+ *
3488
+ * `11140` is what the gateway returns when the ACCOUNT is flagged. It arrives with 403, so
3489
+ * the blanket rule below swallowed it into `session_dead` and the card told the user their
3490
+ * key was invalid — several times, since re-signing in changes nothing about a flag.
3491
+ */
3492
+ if (status === 403) {
3493
+ for (const code of RISK_BLOCK_CODES) if (body.includes(`"code":${code}`) || body.includes(`"code": ${code}`) || body.includes(`"code":"${code}"`)) return "risk_blocked";
3494
+ }
3440
3495
  if (status === 401 || status === 403) return "session_dead";
3441
3496
  const lower = body.toLowerCase();
3442
3497
  for (const code of HARD_CREDIT_CODES) if (body.includes(`"code":${code}`) || body.includes(`"code": ${code}`) || body.includes(`"code":"${code}"`)) return "hard_credit";
@@ -22549,6 +22604,7 @@ const KIND_STATUS = {
22549
22604
  hard_credit: 402,
22550
22605
  soft_rate: 429,
22551
22606
  session_dead: 401,
22607
+ risk_blocked: 403,
22552
22608
  not_found: 502,
22553
22609
  server: 502,
22554
22610
  client: 400
@@ -23453,6 +23509,7 @@ function createWorkBuddyShim(options) {
23453
23509
  };
23454
23510
  if (result.kind === "soft_rate") pool.penalize(account.id, parseRateLimitReset(result.message), member.modelId);
23455
23511
  else if (result.kind === "session_dead") pool.penalizeCredentialDead(account.id);
23512
+ else if (result.kind === "risk_blocked") pool.penalize(account.id, 18e5, member.modelId);
23456
23513
  else if (result.kind === "hard_credit") pool.penalizeExhausted(account.id);
23457
23514
  noteSwitch(member.modelId, result.kind, result.status);
23458
23515
  continue;
@@ -25937,7 +25994,7 @@ function apply(ctx, config = {}) {
25937
25994
  });
25938
25995
  const doubaoLlm = createDoubaoLlm({ session: () => doubaoSession });
25939
25996
  /** The ids Doubao's catalogue knows, so `stream` can tell its models from the host's. */
25940
- const doubaoModelIds = new Set(DOUBAO_MODELS.map((model) => model.id));
25997
+ const doubaoModelIds = new Set(DOUBAO_MODELS$1.map((model) => model.id));
25941
25998
  const hostLlm = ctx.llm;
25942
25999
  const channelLane = createChannelLane({
25943
26000
  llm: {
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.7.0",
5
+ "version": "2.7.1",
6
6
  "license": "MIT",
7
7
  "author": "XDTrees",
8
8
  "homepage": "https://github.com/XDTrees/dsh-xdpool#readme",
@@ -37771,6 +37771,59 @@ function buildQoderInferPayload(ask, requestId = crypto.randomUUID()) {
37771
37771
  };
37772
37772
  }
37773
37773
  var gluePromise = null;
37774
+ /**
37775
+ * [xdpool-local] Keep a Qoder payload inside the WASM's memory budget — issue #155.
37776
+ *
37777
+ * WHAT IS CUT, AND IN WHICH ORDER
37778
+ *
37779
+ * Oldest conversation turns go first: they are the least likely to matter for the next reply,
37780
+ * and dropping one whole turn keeps the message list valid (a lone tool result without its
37781
+ * call is what makes a request *invalid* rather than merely shorter). Tool schemas are never
37782
+ * cut — a call without its schema is worse than a shorter history — but the largest ones are
37783
+ * trimmed of their `description`, which is prose the model can do without.
37784
+ *
37785
+ * The budget is deliberately below the ceiling: serialisation produces several copies at
37786
+ * once, so a payload that merely FITS is not enough.
37787
+ */
37788
+ const QODER_PAYLOAD_BYTE_BUDGET = 700 * 1024;
37789
+
37790
+ function shrinkQoderPayload(payload) {
37791
+ const measure = (value) => {
37792
+ try {
37793
+ return Buffer.byteLength(JSON.stringify(value), "utf8");
37794
+ } catch {
37795
+ return Number.MAX_SAFE_INTEGER;
37796
+ }
37797
+ };
37798
+ if (measure(payload) <= QODER_PAYLOAD_BYTE_BUDGET) return payload;
37799
+ const out = { ...payload, messages: Array.isArray(payload.messages) ? [...payload.messages] : [] };
37800
+ // Oldest first, but never the last message: that is the actual question.
37801
+ while (out.messages.length > 2 && measure(out) > QODER_PAYLOAD_BYTE_BUDGET) {
37802
+ out.messages.shift();
37803
+ }
37804
+ // Still too big: drop tool descriptions, which are prose rather than contract.
37805
+ if (measure(out) > QODER_PAYLOAD_BYTE_BUDGET && Array.isArray(out.tools)) {
37806
+ out.tools = out.tools.map((tool) => {
37807
+ const fn = tool && typeof tool === "object" ? tool.function : void 0;
37808
+ if (!fn || typeof fn !== "object" || typeof fn.description !== "string") return tool;
37809
+ return { ...tool, function: { ...fn, description: "" } };
37810
+ });
37811
+ }
37812
+ // Last resort: trim the longest message bodies from the front of the list.
37813
+ let guard = 0;
37814
+ while (measure(out) > QODER_PAYLOAD_BYTE_BUDGET && out.messages.length > 1 && guard < 64) {
37815
+ guard += 1;
37816
+ const first = out.messages[0];
37817
+ if (first && typeof first === "object" && typeof first.content === "string" && first.content.length > 2000) {
37818
+ out.messages[0] = { ...first, content: `${first.content.slice(0, 2000)}
37819
+ …(已截断)` };
37820
+ continue;
37821
+ }
37822
+ out.messages.shift();
37823
+ }
37824
+ return out;
37825
+ }
37826
+
37774
37827
  async function getGlue() {
37775
37828
  gluePromise ??= createGlue();
37776
37829
  return gluePromise;
@@ -37990,7 +38043,22 @@ var QoderEncryptedInfer = class _QoderEncryptedInfer {
37990
38043
  const result = g.callPointer((stack) => {
37991
38044
  const host = g.writeString(this.host);
37992
38045
  const hostLen = g.lastLength();
37993
- const body = g.writeString(JSON.stringify(payload));
38046
+ /**
38047
+ * [xdpool-local] Shrink the payload before it reaches the WASM — issue #155.
38048
+ *
38049
+ * The encrypted-infer glue declares ~1 MB of linear memory, and the whole request is
38050
+ * written into it as UTF-8: the plaintext JSON string, its encoded copy and the WASM
38051
+ * copy all exist at once. A body approaching that ceiling makes `__wbindgen_export2`
38052
+ * fail to allocate, the Rust side panics, and the panic surfaces to DSH as the bare
38053
+ * word `unreachable` — which reads like a network fault and is an out-of-memory abort.
38054
+ *
38055
+ * At a Chinese ratio of ~1.6–2 char/token, 1 MB is ~240k–330k tokens, which is why the
38056
+ * failure was reported as "breaks around 256k context": the limit is BYTES, not the
38057
+ * model's advertised window. Trimming here keeps the request sendable; the caller's
38058
+ * context budget is untouched, so nothing else has to know.
38059
+ */
38060
+ const shrunk = shrinkQoderPayload(payload);
38061
+ const body = g.writeString(JSON.stringify(shrunk));
37994
38062
  const bodyLen = g.lastLength();
37995
38063
  const key = g.writeString(ask.modelKey);
37996
38064
  const keyLen = g.lastLength();
@@ -46791,6 +46859,29 @@ var TraeAuth = class _TraeAuth extends Service5 {
46791
46859
  if (pool) {
46792
46860
  const available2 = await pool.getAvailableAccount(this.product.id, "").catch(() => void 0);
46793
46861
  if (available2) credential = available2.credential;
46862
+ /**
46863
+ * [xdpool-local] Fall back to ANY account the pool holds — issue #154.
46864
+ *
46865
+ * `getAvailableAccount` skips accounts that are cooling down, disabled, or simply not
46866
+ * the current pick. When it answers nothing, the code below resolved
46867
+ * `TRAE_ACCESS_TOKEN`, a ref that only exists on the single-credential path — a scan
46868
+ * login writes `TRAE_ACCOUNT_<hash>` instead, so the resolve was always undefined for
46869
+ * anyone who signed in through the card.
46870
+ *
46871
+ * The result was an empty list, `ensureRemoteModels` silently giving up, and
46872
+ * `listModels` returning the 28 hard-coded fallback rows — models the account does not
46873
+ * have, under names the vendor never published. Re-signing in could not help, because
46874
+ * the ref it wrote was never the one being read.
46875
+ *
46876
+ * Listing one turn does not need a usable account, only a real credential: the model
46877
+ * catalogue is the same for every account of this vendor.
46878
+ */
46879
+ if (credential === void 0) {
46880
+ const all = pool.listAccountsByProvider(this.product.id) ?? [];
46881
+ for (const entry of all) {
46882
+ if (entry.credential !== void 0) { credential = entry.credential; break }
46883
+ }
46884
+ }
46794
46885
  }
46795
46886
  if (credential === void 0) {
46796
46887
  const resolved = await this.ctx.credentials.resolve(credentialRef6(this.credentialRefName));