heybash-xdpool 1.0.0 → 1.0.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,5 +1,12 @@
1
1
  # Heybash
2
2
 
3
+ ## 1.0.1 — 模型回退与推理档位修复
4
+
5
+ - CodeArts benefit 模型遇到 APIG.0101 时去掉 benefit 头、重新签名并仅重试一次。
6
+ - 推理路由链提供 Low / High / Max,按每次实际命中的模型转换档位;不支持 Max 时降为 High。只有开关的模型将 Low 映射为关闭,High / Max 映射为开启。
7
+ - 长会话压缩的 CodeArts 请求遇到网络或网关超时,可使用已有同模型路由链回退一次。
8
+ - 侧边栏显示 Heybash-Xdpool,账号池深色按钮改用白色文字。
9
+
3
10
  ## 1.0.0 — Heybash-xdpool 首个独立版本
4
11
 
5
12
  - 独立版本从 1.0.0 开始;npm 包名 `heybash-xdpool`,通过 DSH 插件安装入口直接安装。
package/README.en.md CHANGED
@@ -76,9 +76,15 @@ Measured across four accounts, one pass collected **3300 credits and 135 energy*
76
76
 
77
77
  > **The global region doesn't show this panel** — that gateway has no growth system at all.
78
78
 
79
+ ### 3. Routing-chain reasoning effort
80
+
81
+ Chains containing a reasoning model offer **Low / High / Max**. Each selected member receives a supported native effort: Max falls back to High when Max is unavailable; binary models map Low to off and High / Max to on. The mapping is recalculated for each member.
82
+
83
+ If a CodeArts context-summary call encounters a network or gateway timeout, the plugin can retry once through an existing chain containing that model. This requires a matching chain to be configured; a failed fallback follows normal error handling.
84
+
79
85
  ## Install
80
86
 
81
- Since DSH 0.2.0, settings use peer tabs. Open **Heybash** from the sidebar, or press `Ctrl+Alt+,` and choose **Heybash**.
87
+ Since DSH 0.2.0, settings use peer tabs. Open **Heybash-Xdpool** from the sidebar, or press `Ctrl+Alt+,` and choose **Heybash**.
82
88
 
83
89
  Install Heybash from npm (recommended):
84
90
 
package/README.md CHANGED
@@ -79,9 +79,15 @@ Heybash-xdpool 使用独立版本号,从 **1.0.0** 开始。
79
79
 
80
80
  > **国际版不显示这个面板**——那边的网关压根没有积分系统。
81
81
 
82
+ ### 三、路由链推理强度
83
+
84
+ 包含推理模型的路由链提供 **Low / High / Max**。每次实际请求按候选模型的原生档位转换:不支持 Max 而支持 High 时,Max 降为 High;只有开关的模型将 Low 映射为关闭,High / Max 映射为开启。切换候选时重新计算,不沿用上一个候选的降档结果。
85
+
86
+ 长会话压缩的 CodeArts 请求若遇到网络或网关超时,会使用已有的同模型路由链回退一次。需要已配置包含该 CodeArts 模型的路由链;回退仍失败时保留原错误处理。
87
+
82
88
  ## 安装
83
89
 
84
- DSH 0.2.0 起,设置面板使用平级标签。安装后从左侧栏 **Heybash** 进入,或按 `Ctrl+Alt+,` 打开设置并选择 **Heybash**。
90
+ DSH 0.2.0 起,设置面板使用平级标签。安装后从左侧栏 **Heybash-Xdpool** 进入,或按 `Ctrl+Alt+,` 打开设置并选择 **Heybash**。
85
91
 
86
92
  从 npm 安装 Heybash(推荐):
87
93
 
package/lib/client.js CHANGED
@@ -810,8 +810,8 @@ window.__ModuleLoader__.load({
810
810
  .dsm-xdpool-cpool-card .dsm-xdpool-cpool-fold:hover:not(:disabled),.dsm-xdpool-cpool-card .dsm-xdpool-cpool-fold[aria-expanded=true]{border-color:var(--dsw-alias-border-l2,#36373b)}
811
811
  .dsm-xdpool-cpool-card .dsm-xdpool-cpool-fold:hover:not(:disabled){background:color-mix(in srgb, var(--dsw-alias-label-primary,#f2f3f5) 7%, transparent)}
812
812
  .dsm-xdpool-cpool-card .dsm-xdpool-minibtn:hover:not(:disabled){border-color:var(--dsw-alias-border-l2,#36373b);background:color-mix(in srgb, var(--dsw-alias-label-primary,#f2f3f5) 6%, transparent)}
813
- .dsm-xdpool-btn[data-tone="primary"]{border-color:transparent;background:color-mix(in srgb, var(--dsw-alias-brand-primary,#5686fe) 82%, #ffffff 4%);color:#0d1014;font-weight:640}
814
- .dsm-xdpool-btn[data-tone="primary"]:hover:not(:disabled){background:color-mix(in srgb, var(--dsw-alias-brand-primary,#5686fe) 94%, #ffffff 6%);color:#0d1014}
813
+ .dsm-xdpool-btn[data-tone="primary"]{border-color:transparent;background:color-mix(in srgb, var(--dsw-alias-brand-primary,#5686fe) 82%, #ffffff 4%);color:#fff;font-weight:640}
814
+ .dsm-xdpool-btn[data-tone="primary"]:hover:not(:disabled){background:color-mix(in srgb, var(--dsw-alias-brand-primary,#5686fe) 94%, #ffffff 6%);color:#fff}
815
815
  .dsm-xdpool-btn[data-tone="quiet"]{border-color:transparent;background:transparent;color:var(--dsw-alias-label-secondary,#c9ccd1);font-weight:500}
816
816
  .dsm-xdpool-btn[data-tone="claimed"]{border-color:var(--dsw-alias-border-l2,#36373b);background:transparent;color:var(--dsw-alias-label-tertiary,#9aa0a8);font-weight:600;cursor:default}
817
817
  @media (prefers-reduced-motion: reduce){
@@ -16411,7 +16411,7 @@ window.__ModuleLoader__.load({
16411
16411
  * @module dsh-xdpool/client/locales
16412
16412
  */
16413
16413
  const en = {
16414
- "row.navLabel": "Heybash",
16414
+ "row.navLabel": "Heybash-Xdpool",
16415
16415
  "row.title": "Account pool",
16416
16416
  "row.desc": "",
16417
16417
  "row.expand": "Expand",
@@ -16521,8 +16521,8 @@ window.__ModuleLoader__.load({
16521
16521
  "row.modelsDiscard": "Discard",
16522
16522
  "row.modelsSaved": "Model selection saved",
16523
16523
  "row.sidebarRowTitle": "Sidebar entry",
16524
- "row.sidebarRowOn": "Heybash has its own row in the left sidebar. Turn it off to open the pool from Settings instead.",
16525
- "row.sidebarRowOff": "The sidebar row is hidden; the pool still opens from Settings → Heybash, and models are unaffected.",
16524
+ "row.sidebarRowOn": "Heybash-Xdpool has its own row in the left sidebar. Turn it off to open the pool from Settings instead.",
16525
+ "row.sidebarRowOff": "The sidebar row is hidden; the pool still opens from Settings → Heybash-Xdpool, and models are unaffected.",
16526
16526
  "row.modelsConflict": "The settings changed elsewhere; review and save again",
16527
16527
  "row.modelsSaveError": "Could not save: {message}",
16528
16528
  "row.modelsEmpty": "No model enabled — enable at least one before saving.",
@@ -16996,7 +16996,7 @@ window.__ModuleLoader__.load({
16996
16996
  "channelpool.note": "Note"
16997
16997
  };
16998
16998
  const zh = {
16999
- "row.navLabel": "Heybash",
16999
+ "row.navLabel": "Heybash-Xdpool",
17000
17000
  "row.title": "账号池",
17001
17001
  "row.desc": "",
17002
17002
  "row.expand": "展开",
@@ -17106,8 +17106,8 @@ window.__ModuleLoader__.load({
17106
17106
  "row.modelsDiscard": "放弃修改",
17107
17107
  "row.modelsSaved": "模型选择已保存",
17108
17108
  "row.sidebarRowTitle": "侧栏入口",
17109
- "row.sidebarRowOn": "左侧栏会给 Heybash 留一行入口。关掉后改为从「设置 → Heybash」进入,模型池不受影响。",
17110
- "row.sidebarRowOff": "侧栏入口已隐藏;仍可从「设置 → Heybash」进入,模型池不受影响。",
17109
+ "row.sidebarRowOn": "左侧栏会给 Heybash-Xdpool 留一行入口。关掉后改为从「设置 → Heybash-Xdpool」进入,模型池不受影响。",
17110
+ "row.sidebarRowOff": "侧栏入口已隐藏;仍可从「设置 → Heybash-Xdpool」进入,模型池不受影响。",
17111
17111
  "row.modelsConflict": "设置已在别处被修改,请确认后重新保存",
17112
17112
  "row.modelsSaveError": "保存失败:{message}",
17113
17113
  "row.modelsEmpty": "至少要启用一个模型才能保存。",
package/lib/index.d.ts CHANGED
@@ -2712,12 +2712,32 @@ interface ComboModelRow {
2712
2712
  contextWindow: number;
2713
2713
  maxOutputTokens: number;
2714
2714
  supportsImages: boolean;
2715
+ /** Chain controls are resolved against each selected member's native ladder. */
2716
+ supportedEfforts?: readonly string[];
2715
2717
  /**
2716
2718
  * Discriminator. Aggregate rows carry `providerId`, pool rows carry neither,
2717
2719
  * and only this shape is `true`.
2718
2720
  */
2719
2721
  combo: true;
2720
2722
  }
2723
+ /**
2724
+ * One model served by a 扫码登录 channel, as the route editor sees it.
2725
+ *
2726
+ * These are the channels the vendored pack registers with the HOST (`trae`,
2727
+ * `qoder`, `codebuddy`…). They are in neither catalog above: the pool catalog
2728
+ * describes the WorkBuddy account lanes, and the aggregate catalog describes the
2729
+ * vendors in this plugin's own registry. A chain could not name them at all, which
2730
+ * is why the routing page offered exactly ONE platform — the pool — while the login
2731
+ * page happily showed thirteen.
2732
+ */
2733
+ interface HostModelRow {
2734
+ /** `<channel>:<modelId>` — the id the shim already resolves to its fifth lane. */
2735
+ id: string;
2736
+ channel: string;
2737
+ modelId: string;
2738
+ name: string;
2739
+ supportedEfforts?: readonly string[];
2740
+ }
2721
2741
  /**
2722
2742
  * The aggregate section as it lives on disk.
2723
2743
  *
@@ -3035,6 +3055,8 @@ interface AggregateModelRow {
3035
3055
  contextWindow: number;
3036
3056
  maxOutputTokens: number;
3037
3057
  supportsImages: boolean;
3058
+ /** Optional declared reasoning ladder; absent means unknown. */
3059
+ supportedEfforts?: readonly string[];
3038
3060
  wire: AggregateWire;
3039
3061
  /** `static` from the registry, `discovered` from a live listing. */
3040
3062
  source: 'static' | 'discovered';
@@ -3043,6 +3065,7 @@ interface AggregateModelRow {
3043
3065
  declare class AggregateCatalog {
3044
3066
  private readonly read;
3045
3067
  private readonly poolRows;
3068
+ private readonly hostRows;
3046
3069
  private rows;
3047
3070
  private chainRows;
3048
3071
  /**
@@ -3051,7 +3074,7 @@ declare class AggregateCatalog {
3051
3074
  * that names a WorkBuddy model. A chain may mix pool models with aggregate
3052
3075
  * ones, so without this a perfectly valid chain would lose its pool half.
3053
3076
  */
3054
- constructor(read: () => AggregateStore | Promise<AggregateStore>, poolRows?: () => readonly WorkBuddyModelInfo[]);
3077
+ constructor(read: () => AggregateStore | Promise<AggregateStore>, poolRows?: () => readonly WorkBuddyModelInfo[], hostRows?: () => readonly HostModelRow[]);
3055
3078
  /**
3056
3079
  * Every row this catalog offers: third-party rows first, then chain rows.
3057
3080
  *
@@ -3081,6 +3104,7 @@ interface ChannelLaneRow {
3081
3104
  channel: string;
3082
3105
  modelId: string;
3083
3106
  name: string;
3107
+ supportedEfforts?: readonly string[];
3084
3108
  }
3085
3109
  /** One translated event, so the caller decides how to frame it as SSE. */
3086
3110
  type ChannelLaneEvent = {
package/lib/index.js CHANGED
@@ -10910,6 +10910,41 @@ function modelsEndpoint(provider) {
10910
10910
  function hasModelsListing(provider) {
10911
10911
  return typeof provider.modelsUrl === "string" && provider.modelsUrl.trim() !== "";
10912
10912
  }
10913
+ // src/reasoning.ts
10914
+ /** A chain's controls are routing intent; each member resolves to its own ladder. */
10915
+ const CHAIN_REASONING_EFFORTS = [
10916
+ "low",
10917
+ "high",
10918
+ "max"
10919
+ ];
10920
+ const LEVELS = [
10921
+ "minimal",
10922
+ "low",
10923
+ "medium",
10924
+ "high",
10925
+ "xhigh",
10926
+ "max"
10927
+ ];
10928
+ /** Select a real native effort, keeping Max -> High explicit where Max is absent. */
10929
+ function resolveMemberReasoningEffort(requested, supported) {
10930
+ if (supported === void 0) return requested;
10931
+ if (supported.includes(requested)) return requested;
10932
+ const rank = LEVELS.indexOf(requested);
10933
+ if (rank < 0) return void 0;
10934
+ if (supported.includes("on")) return requested === "low" && supported.includes("off") ? "off" : "on";
10935
+ if (requested === "max" && supported.includes("high")) return "high";
10936
+ const native = LEVELS.filter((level) => supported.includes(level));
10937
+ return native.filter((level) => LEVELS.indexOf(level) <= rank).at(-1) ?? native[0];
10938
+ }
10939
+ /** A fresh request per member prevents one fallback's downgrade leaking to the next. */
10940
+ function withMemberReasoningEffort(raw, supported) {
10941
+ const body = JSON.parse(raw);
10942
+ if (typeof body.reasoning_effort !== "string") return raw;
10943
+ const effort = resolveMemberReasoningEffort(body.reasoning_effort, supported);
10944
+ if (effort === void 0) delete body.reasoning_effort;
10945
+ else body.reasoning_effort = effort;
10946
+ return JSON.stringify(body);
10947
+ }
10913
10948
  // src/combos.ts
10914
10949
  /** Id prefix every combo row advertises under. */
10915
10950
  const COMBO_PREFIX = "combo:";
@@ -11115,7 +11150,8 @@ function resolveComboMember(modelId, sources) {
11115
11150
  name: aggregateRow.name,
11116
11151
  contextWindow: aggregateRow.contextWindow,
11117
11152
  maxOutputTokens: aggregateRow.maxOutputTokens,
11118
- supportsImages: aggregateRow.supportsImages
11153
+ supportsImages: aggregateRow.supportsImages,
11154
+ ...aggregateRow.supportedEfforts === void 0 ? {} : { supportedEfforts: aggregateRow.supportedEfforts }
11119
11155
  };
11120
11156
  }
11121
11157
  /**
@@ -11132,16 +11168,25 @@ function resolveComboMember(modelId, sources) {
11132
11168
  * defaults. That is the honest answer: an unknown window must not be treated as a
11133
11169
  * large one, or the host would size a compaction against a limit nobody promised.
11134
11170
  */
11135
- const hostRow = sources.host?.find((row) => row.id === id);
11171
+ const hostRow = sources.host?.find((row) => {
11172
+ if (row.id === id) return true;
11173
+ let bare = id;
11174
+ while (bare.startsWith(`${row.channel}/`) || bare.startsWith(`${row.channel}:`)) {
11175
+ bare = bare.slice(row.channel.length + 1);
11176
+ if (bare === row.modelId) return true;
11177
+ }
11178
+ return false;
11179
+ });
11136
11180
  if (hostRow !== void 0) return {
11137
- modelId: id,
11181
+ modelId: hostRow.id,
11138
11182
  aggregate: false,
11139
11183
  host: true,
11140
11184
  channel: hostRow.channel,
11141
11185
  name: hostRow.name,
11142
11186
  contextWindow: COMBO_DEFAULT_CONTEXT_WINDOW,
11143
11187
  maxOutputTokens: COMBO_DEFAULT_MAX_OUTPUT,
11144
- supportsImages: false
11188
+ supportsImages: false,
11189
+ ...hostRow.supportedEfforts === void 0 ? {} : { supportedEfforts: hostRow.supportedEfforts }
11145
11190
  };
11146
11191
  const poolRow = sources.pool.find((row) => row.id === id);
11147
11192
  if (poolRow === void 0) return void 0;
@@ -11151,7 +11196,8 @@ function resolveComboMember(modelId, sources) {
11151
11196
  name: poolRow.name,
11152
11197
  contextWindow: poolRow.contextWindow,
11153
11198
  maxOutputTokens: poolRow.maxOutputTokens,
11154
- supportsImages: poolRow.supportsImages
11199
+ supportsImages: poolRow.supportsImages,
11200
+ ...poolRow.supportedEfforts === void 0 ? {} : { supportedEfforts: poolRow.supportedEfforts }
11155
11201
  };
11156
11202
  }
11157
11203
  /**
@@ -11221,6 +11267,7 @@ function buildComboCatalog(chains, sources) {
11221
11267
  if (member !== void 0) members.push(member);
11222
11268
  }
11223
11269
  if (members.length === 0) continue;
11270
+ const supportedEfforts = members.some((member) => member.supportedEfforts?.some((effort) => effort !== "off")) ? CHAIN_REASONING_EFFORTS : [];
11224
11271
  rows.push({
11225
11272
  id,
11226
11273
  name: chain.name,
@@ -11230,6 +11277,7 @@ function buildComboCatalog(chains, sources) {
11230
11277
  contextWindow: Math.min(...members.map((member) => member.contextWindow || 131072)),
11231
11278
  maxOutputTokens: Math.min(...members.map((member) => member.maxOutputTokens || 32768)),
11232
11279
  supportsImages: members.every((member) => member.supportsImages),
11280
+ ...supportedEfforts.length === 0 ? {} : { supportedEfforts },
11233
11281
  combo: true
11234
11282
  });
11235
11283
  }
@@ -12428,6 +12476,7 @@ function buildAggregateCatalog(store) {
12428
12476
  var AggregateCatalog = class {
12429
12477
  read;
12430
12478
  poolRows;
12479
+ hostRows;
12431
12480
  rows = [];
12432
12481
  chainRows = [];
12433
12482
  /**
@@ -12436,9 +12485,10 @@ var AggregateCatalog = class {
12436
12485
  * that names a WorkBuddy model. A chain may mix pool models with aggregate
12437
12486
  * ones, so without this a perfectly valid chain would lose its pool half.
12438
12487
  */
12439
- constructor(read, poolRows = () => []) {
12488
+ constructor(read, poolRows = () => [], hostRows = () => []) {
12440
12489
  this.read = read;
12441
12490
  this.poolRows = poolRows;
12491
+ this.hostRows = hostRows;
12442
12492
  }
12443
12493
  /**
12444
12494
  * Every row this catalog offers: third-party rows first, then chain rows.
@@ -12463,10 +12513,11 @@ var AggregateCatalog = class {
12463
12513
  const next = buildAggregateCatalog(store);
12464
12514
  const chains = buildComboCatalog(combosOf(store), {
12465
12515
  pool: this.poolRows(),
12466
- aggregate: next
12516
+ aggregate: next,
12517
+ host: this.hostRows()
12467
12518
  });
12468
12519
  pruneRotation(combosOf(store));
12469
- if (next.length === this.rows.length && chains.length === this.chainRows.length && next.every((row, index) => row.id === this.rows[index]?.id) && chains.every((row, index) => row.id === this.chainRows[index]?.id)) return this.current();
12520
+ if (JSON.stringify(next) === JSON.stringify(this.rows) && JSON.stringify(chains) === JSON.stringify(this.chainRows)) return this.current();
12470
12521
  this.rows = next;
12471
12522
  this.chainRows = chains;
12472
12523
  for (const listener of this.listeners) listener();
@@ -13333,6 +13384,7 @@ function toAggregateModel(row, baseUrl, providerId) {
13333
13384
  * letting the turn run past it.
13334
13385
  */
13335
13386
  function toComboModel(row, baseUrl, providerId) {
13387
+ const map = thinkingLevelMap(row);
13336
13388
  return {
13337
13389
  id: row.id,
13338
13390
  name: row.name,
@@ -13343,8 +13395,9 @@ function toComboModel(row, baseUrl, providerId) {
13343
13395
  cost: NO_COST,
13344
13396
  contextWindow: row.contextWindow,
13345
13397
  maxTokens: row.maxOutputTokens,
13346
- reasoning: false,
13347
- compat: { supportsReasoningEffort: false }
13398
+ reasoning: map !== void 0,
13399
+ ...map === void 0 ? {} : { thinkingLevelMap: map },
13400
+ compat: { supportsReasoningEffort: map !== void 0 }
13348
13401
  };
13349
13402
  }
13350
13403
  /**
@@ -13358,14 +13411,7 @@ function toComboModel(row, baseUrl, providerId) {
13358
13411
  */
13359
13412
  function toExtraLaneModel(row, baseUrl, providerId) {
13360
13413
  const efforts = "efforts" in row && Array.isArray(row.efforts) && row.efforts.length > 0 ? row.efforts : void 0;
13361
- const map = efforts === void 0 ? void 0 : thinkingLevelMap({
13362
- id: row.id,
13363
- name: row.name,
13364
- contextWindow: row.contextWindow,
13365
- maxOutputTokens: row.maxOutput,
13366
- supportsImages: row.vision,
13367
- supportedEfforts: efforts
13368
- });
13414
+ const map = efforts === void 0 ? void 0 : thinkingLevelMap({ supportedEfforts: efforts });
13369
13415
  return {
13370
13416
  id: row.modelId,
13371
13417
  name: row.name,
@@ -18727,6 +18773,70 @@ function recordStartupNote(line) {
18727
18773
  } catch {}
18728
18774
  return text;
18729
18775
  }
18776
+ // src/compaction-recovery.ts
18777
+ /** Match transport/gateway failures without retrying auth, quota, or bad input. */
18778
+ function transportFailure(value) {
18779
+ if (value === null || typeof value !== "object") return false;
18780
+ const error = value;
18781
+ if ([
18782
+ 408,
18783
+ 502,
18784
+ 503,
18785
+ 504
18786
+ ].includes(Number(error.status ?? error.statusCode))) return true;
18787
+ if (typeof error.code === "string" && /^(?:TRANSPORT|NETWORK|TIMEOUT|ECONNRESET|ECONNREFUSED|EPIPE|ETIMEDOUT|ENOTFOUND|UND_ERR_CONNECT_TIMEOUT|UND_ERR_HEADERS_TIMEOUT|UND_ERR_BODY_TIMEOUT|UND_ERR_SOCKET)$/u.test(error.code)) return true;
18788
+ if (typeof error.message === "string" && /fetch failed|network error|socket hang up|\bHTTP (?:408|502|503|504)\b|\bAPIG\.0203\b/iu.test(error.message)) return true;
18789
+ return error.cause !== value && error.cause !== void 0 ? transportFailure(error.cause) : false;
18790
+ }
18791
+ function failedFinish(chunk) {
18792
+ return chunk.type === "finish" && chunk.reason.kind === "error" ? chunk.reason.failure : void 0;
18793
+ }
18794
+ /**
18795
+ * A compaction is an auxiliary call and bypasses the agent's normal request retry.
18796
+ * Buffer its first attempt so a transport failure cannot mix partial summaries.
18797
+ * Ordinary CodeArts calls keep their own behavior, including the benefit retry.
18798
+ */
18799
+ function recoverCompactionStream(options, next, recovery) {
18800
+ if (options.purpose !== "compaction" || options.provider !== "codearts") return next();
18801
+ return (async function* () {
18802
+ const initial = [];
18803
+ let thrown;
18804
+ let failure;
18805
+ try {
18806
+ for await (const chunk of next()) {
18807
+ initial.push(chunk);
18808
+ if (failedFinish(chunk) !== void 0) failure = failedFinish(chunk);
18809
+ }
18810
+ } catch (error) {
18811
+ thrown = error;
18812
+ failure = error;
18813
+ }
18814
+ const target = !options.signal?.aborted && transportFailure(failure) ? recovery.target() : void 0;
18815
+ if (target === void 0 || target.provider === options.provider && target.model === options.model) {
18816
+ if (thrown !== void 0) throw thrown;
18817
+ yield* initial;
18818
+ return;
18819
+ }
18820
+ const from = {
18821
+ provider: options.provider,
18822
+ model: options.model
18823
+ };
18824
+ const replacement = [];
18825
+ let replacementCompleted = false;
18826
+ for await (const chunk of recovery.stream({
18827
+ ...options,
18828
+ ...target
18829
+ })) {
18830
+ replacement.push(chunk);
18831
+ if (chunk.type === "finish") replacementCompleted = chunk.reason.kind === "stop";
18832
+ }
18833
+ if (replacementCompleted) {
18834
+ if (!Object.isFrozen(options)) Object.assign(options, target);
18835
+ recovery.recovered?.(from, target);
18836
+ }
18837
+ yield* replacement;
18838
+ })();
18839
+ }
18730
18840
  // src/model-switch-bridge.ts
18731
18841
  /**
18732
18842
  * The lane id the host's picker uses for each region.
@@ -19195,6 +19305,60 @@ function paidAlternativeFor(model, models) {
19195
19305
  }
19196
19306
  // src/channel-lane.ts
19197
19307
  /**
19308
+ * The channel lane: 扫码登录 vendors served through the host's own LLM seam.
19309
+ *
19310
+ * ## Why this is a separate lane
19311
+ *
19312
+ * Every other lane reaches its upstream over HTTP this plugin owns: the pool
19313
+ * posts to WorkBuddy, the aggregate lane posts to a provider the user keyed, the
19314
+ * free lane posts to a pooled gateway. The login channels do not work that way.
19315
+ * `vendor/channel-pack` registers each one as a HOST adapter
19316
+ * (`llm.registerAdapter([product.id], adapter)`) — the credential, the wire
19317
+ * dialect and the endpoint all belong to the pack, and there is no
19318
+ * OpenAI-compatible port for a client to point at.
19319
+ *
19320
+ * So this lane opens no socket. It calls `ctx.llm`, which already knows how to
19321
+ * reach every registered provider, and translates between the two vocabularies.
19322
+ * The listing is built the same way, from `llm.listModels`, which is what the
19323
+ * card's own model list already calls: a channel that is not signed in throws,
19324
+ * the throw becomes "contributes nothing", and the gateway therefore cannot
19325
+ * advertise a channel the card would not show.
19326
+ *
19327
+ * ## What is translated
19328
+ *
19329
+ * The host stream vocabulary is `block-start | text-delta | reasoning-delta |
19330
+ * tool-call-delta | block-end | usage | finish` (dsh-llm `types.d.ts`), and each
19331
+ * of the four that carry content has an OpenAI spelling, so nothing is dropped on
19332
+ * the way out — including tool calls, which a gateway that silently swallowed
19333
+ * them would make look like a model that refuses to use tools.
19334
+ *
19335
+ * On the way in, every message becomes the host's `content: ContentBlock[]`;
19336
+ * a bare string is rejected by the host's own validation, which is the exact bug
19337
+ * fixed in `model-probe.ts`, so this lane does not repeat it.
19338
+ *
19339
+ * Images must go through the host's durable attachment store, for the same
19340
+ * reason: the typed `ImageBlock` (dsh-llm `types.d.ts`) has no `url` field at
19341
+ * all — only `attachment: ImageAttachmentRef`. A base64 `image_url` part is
19342
+ * therefore decoded and handed to `attachments.saveImage`, and the reference that
19343
+ * comes back is what goes into the block. Emitting `{ type: 'image', url }` is
19344
+ * the failure mode this note exists for: the host does not reject it, it simply
19345
+ * is not an image as far as the host is concerned, so the picture is dropped and
19346
+ * the model narrates the text alone — a solid red square came back described as
19347
+ * white, with a token count that proved nothing had arrived. A remote `http(s)`
19348
+ * URL is refused rather than fetched, matching the pack's own bridge, so the
19349
+ * gateway never becomes a fetch primitive on someone else's behalf.
19350
+ *
19351
+ * ## One deliberate difference from the pool lane
19352
+ *
19353
+ * The pool forces `stream: true` (`prepareChatBody`), so a client asking for a
19354
+ * non-streaming completion still receives SSE from it. This lane honours
19355
+ * `stream: false`. Copying the deviation would make the gateway's behaviour
19356
+ * depend on which lane a model happens to sit in — the kind of difference a
19357
+ * client cannot see coming and discovers as a parse error.
19358
+ *
19359
+ * @module dsh-xdpool/channel-lane
19360
+ */
19361
+ /**
19198
19362
  * A request this lane will not serve as written, and that is the caller's to fix.
19199
19363
  *
19200
19364
  * Kept as its own type so the route can answer 400 for it: a refused image and a
@@ -19274,11 +19438,19 @@ function createChannelLane(options) {
19274
19438
  if (hit !== void 0 && Date.now() - hit.at < LISTING_TTL_MS) return Promise.resolve(hit.rows);
19275
19439
  const running = inflight.get(channel);
19276
19440
  if (running !== void 0) return running;
19277
- const tracked = llm.listModels(channel).then((models) => models.map((model) => ({
19278
- id: toId(channel, model.id),
19279
- channel,
19280
- modelId: model.id,
19281
- name: model.name ?? model.id
19441
+ const tracked = llm.listModels(channel).then((models) => Promise.all(models.map(async (model) => {
19442
+ let supportedEfforts;
19443
+ if (llm.resolveModelInfo !== void 0) try {
19444
+ const info = await llm.resolveModelInfo(channel, model.id);
19445
+ supportedEfforts = [...new Set((info.reasoning?.efforts ?? []).map((effort) => effort.id === "on" ? "high" : effort.id))];
19446
+ } catch {}
19447
+ return {
19448
+ id: toId(channel, model.id),
19449
+ channel,
19450
+ modelId: model.id,
19451
+ name: model.name ?? model.id,
19452
+ ...supportedEfforts === void 0 ? {} : { supportedEfforts }
19453
+ };
19282
19454
  }))).catch((error) => {
19283
19455
  logger?.warn?.(`heybash-xdpool: channel ${channel} listed no models: ${String(error)}`);
19284
19456
  return [];
@@ -19436,10 +19608,19 @@ async function* runTurn(input) {
19436
19608
  messages: converted.filter((message) => message.role !== "system"),
19437
19609
  signal
19438
19610
  };
19439
- if (system.length > 0) options.system = system[0].content;
19611
+ if (system.length > 0) options.system = system.map((message) => message.content.map((block) => typeof block.text === "string" ? block.text : "").join("")).join("\n\n");
19440
19612
  if (typeof body.max_tokens === "number") options.maxTokens = body.max_tokens;
19441
19613
  if (typeof body.temperature === "number") options.temperature = body.temperature;
19442
- if (Array.isArray(body.tools) && body.tools.length > 0) options.tools = body.tools;
19614
+ if (Array.isArray(body.tools) && body.tools.length > 0) options.tools = body.tools.map((tool) => {
19615
+ const fn = tool.function;
19616
+ return typeof fn === "object" && fn !== null ? fn : tool;
19617
+ });
19618
+ if (typeof body.reasoning_effort === "string" && body.reasoning_effort.trim() !== "") {
19619
+ const requested = body.reasoning_effort.trim();
19620
+ let selected = requested;
19621
+ if (llm.resolveModelInfo !== void 0) selected = resolveMemberReasoningEffort(requested, (await llm.resolveModelInfo(channel, modelId, signal)).reasoning?.efforts.map((effort) => effort.id) ?? []) ?? "";
19622
+ if (selected !== "") options.reasoningEffort = selected;
19623
+ }
19443
19624
  for await (const chunk of llm.stream(options)) {
19444
19625
  const event = toChannelEvent(chunk);
19445
19626
  if (event !== void 0) yield event;
@@ -20261,7 +20442,8 @@ function createWorkBuddyShim(options) {
20261
20442
  const store = aggregate?.readStore();
20262
20443
  const sources = {
20263
20444
  pool: catalog.current(),
20264
- aggregate: aggregate === void 0 ? [] : aggregate.catalog.providerRows()
20445
+ aggregate: aggregate === void 0 ? [] : aggregate.catalog.providerRows(),
20446
+ host: channels === void 0 ? [] : await channels.rows()
20265
20447
  };
20266
20448
  const members = comboChain(row).map((modelId) => resolveComboMember(modelId, sources)).filter((member) => member !== void 0);
20267
20449
  if (members.length === 0) {
@@ -20416,10 +20598,10 @@ function createWorkBuddyShim(options) {
20416
20598
  noteSwitch(member.modelId, why.reason, last.status);
20417
20599
  continue;
20418
20600
  }
20419
- const memberRaw = JSON.stringify({
20601
+ const memberRaw = withMemberReasoningEffort(JSON.stringify({
20420
20602
  ...JSON.parse(raw),
20421
20603
  model: member.modelId
20422
- });
20604
+ }), member.supportedEfforts);
20423
20605
  const prepared = client.prepareChatBodyFor(memberRaw, region ?? "cn");
20424
20606
  const result = await client.chatStream(account.credential, prepared, memberSignal, conversationKey);
20425
20607
  if (result.ok) {
@@ -20476,7 +20658,7 @@ function createWorkBuddyShim(options) {
20476
20658
  }
20477
20659
  const frames = [];
20478
20660
  try {
20479
- await forwardAggregateStreamed(resolved, parsed.modelId, withBareModelId(raw, parsed.modelId), {
20661
+ await forwardAggregateStreamed(resolved, parsed.modelId, withMemberReasoningEffort(withBareModelId(raw, parsed.modelId), member.supportedEfforts), {
20480
20662
  signal: memberSignal,
20481
20663
  onData: (payload) => frames.push(payload),
20482
20664
  ...usageRecorder === void 0 ? {} : { usage: {
@@ -22767,8 +22949,23 @@ function apply(ctx, config = {}) {
22767
22949
  const storedLedger = current().automationEarnings;
22768
22950
  if (storedLedger !== void 0) core.scheduler.applyEarningsLedger(storedLedger);
22769
22951
  const usageRecorder = new UsageRecorder();
22770
- const aggregateCatalog = new AggregateCatalog(() => readAggregateSettingsSync(), () => core.catalogs.cn.current());
22952
+ let hostRosterCache = [];
22953
+ const aggregateCatalog = new AggregateCatalog(() => readAggregateSettingsSync(), () => core.catalogs.cn.current(), () => hostRosterCache);
22771
22954
  aggregateCatalog.refresh();
22955
+ ctx.on("llm/stream", (options, next) => recoverCompactionStream(options, next, {
22956
+ target: () => {
22957
+ const matching = aggregateCatalog.comboRows().find((row) => row.models.some((model) => model === options.model || model === `${options.provider}:${options.model}` || model === `${options.provider}/${options.model}`));
22958
+ if (matching !== void 0) recordStartupNote(`compaction transport retry ${options.provider}/${options.model} -> ${XDPOOL_AGGREGATE_PROVIDER}/${matching.id}`);
22959
+ return matching === void 0 ? void 0 : {
22960
+ provider: XDPOOL_AGGREGATE_PROVIDER,
22961
+ model: matching.id
22962
+ };
22963
+ },
22964
+ stream: (request) => ctx.llm.stream(request),
22965
+ recovered: (from, to) => {
22966
+ recordStartupNote(`compaction transport recovery ${from.provider}/${from.model} -> ${to.provider}/${to.model}`);
22967
+ }
22968
+ }), { global: true });
22772
22969
  const freeCatalog = new FreeCatalog();
22773
22970
  freeLaneSwitch = (enabled) => {
22774
22971
  freeCatalog.setEnabled(enabled);
@@ -22817,14 +23014,14 @@ function apply(ctx, config = {}) {
22817
23014
  * The two pool-owned channels are excluded by `channelLane` itself, so the same
22818
23015
  * model cannot appear once as a pool row and again as a channel row.
22819
23016
  */
22820
- let hostRosterCache = [];
22821
23017
  const hostRoster = async () => {
22822
23018
  try {
22823
23019
  hostRosterCache = (await channelLane.rows()).map((row) => ({
22824
23020
  id: row.id,
22825
23021
  channel: row.channel,
22826
23022
  modelId: row.modelId,
22827
- name: row.name
23023
+ name: row.name,
23024
+ ...row.supportedEfforts === void 0 ? {} : { supportedEfforts: row.supportedEfforts }
22828
23025
  }));
22829
23026
  } catch (error) {
22830
23027
  ctx.logger?.warn?.("heybash-xdpool: could not list login-channel models:", error);
@@ -23009,6 +23206,8 @@ function apply(ctx, config = {}) {
23009
23206
  },
23010
23207
  refreshCatalog: async () => {
23011
23208
  const result = await seedCatalog();
23209
+ await hostRoster();
23210
+ await aggregateCatalog.refresh();
23012
23211
  invalidateCatalog();
23013
23212
  return result;
23014
23213
  },
@@ -23208,6 +23407,8 @@ function apply(ctx, config = {}) {
23208
23407
  const accounts = await core.pool.scan();
23209
23408
  ctx.logger.info?.(`heybash-xdpool: discovered ${accounts.length} account(s)`);
23210
23409
  await seedCatalog();
23410
+ await hostRoster();
23411
+ await aggregateCatalog.refresh();
23211
23412
  invalidateCatalog();
23212
23413
  return accounts.length;
23213
23414
  },
@@ -23436,6 +23637,8 @@ function apply(ctx, config = {}) {
23436
23637
  });
23437
23638
  (async () => {
23438
23639
  await seedCatalog();
23640
+ await hostRoster();
23641
+ await aggregateCatalog.refresh();
23439
23642
  invalidateCatalog();
23440
23643
  })().catch((error) => {
23441
23644
  ctx.logger.warn("heybash-xdpool: account catalog seed failed", error);
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.0",
5
+ "version": "1.0.1",
6
6
  "license": "MIT",
7
7
  "author": "Heybash",
8
8
  "contributors": [
@@ -32689,6 +32689,10 @@ var CHAT_API_BASE = "https://snap-access.cn-north-4.myhuaweicloud.com/api/v2";
32689
32689
  var PROVIDER = "codearts";
32690
32690
  var BENEFIT_NOT_FOUND_CODE = "BENEFIT_NOT_FOUND";
32691
32691
  var CODEARTS_BENEFIT_NOT_FOUND_ERROR_CODE = "InferHub.4004.200";
32692
+ // [patch:codearts-benefit-apig] benefit 通道被拒(APIG.0101 / 404)≠ 凭据或模型无效:
32693
+ // 同凭据对照实测,去掉 maas_type: benefit 头即恢复 200。单独一个错误码,
32694
+ // 供调用侧只对该情形做一次有限回退(不重复循环)。
32695
+ var BENEFIT_HEADER_REJECTED_CODE = "BENEFIT_HEADER_REJECTED";
32692
32696
  var DEFAULT_MODELS = [
32693
32697
  "GLM-5.2",
32694
32698
  "GLM-5.1",
@@ -33472,7 +33476,8 @@ var CodeArtsAdapter = class extends LlmAdapter {
33472
33476
  throw new LlmError2(message2, QUOTA_EXCEEDED_CODE, { status: 200 });
33473
33477
  }
33474
33478
  if (error instanceof SseQueueRetryError) {
33475
- } else if (error instanceof LlmError2 && error.code === BENEFIT_NOT_FOUND_CODE && isBenefitModel && !benefitHeaderDropped) {
33479
+ } else if (error instanceof LlmError2 && (error.code === BENEFIT_NOT_FOUND_CODE || error.code === BENEFIT_HEADER_REJECTED_CODE) && isBenefitModel && !benefitHeaderDropped) {
33480
+ // [patch:codearts-benefit-apig] One header-free retry, shared with the existing benefit fallback.
33476
33481
  benefitHeaderDropped = true;
33477
33482
  continue;
33478
33483
  } else {
@@ -33481,6 +33486,12 @@ var CodeArtsAdapter = class extends LlmAdapter {
33481
33486
  }
33482
33487
  } else {
33483
33488
  const errorText = await response.text().catch(() => "");
33489
+ // [patch:codearts-benefit-apig] benefit 通道被拒:404 或 APIG.0101 —— 去掉 maas_type 重签重试一次;
33490
+ // benefitHeaderDropped 置位后不会再走这里,失败即按普通错误抛出,不会循环。
33491
+ if (isBenefitModel && !benefitHeaderDropped && (response.status === 404 || errorText.includes("APIG.0101"))) {
33492
+ benefitHeaderDropped = true;
33493
+ continue;
33494
+ }
33484
33495
  if (isAuthError(response.status, errorText) && !authRefreshed) {
33485
33496
  authRefreshed = true;
33486
33497
  // [xdpool-local] auth failure rotates the account, not just refresh it.
@@ -33731,6 +33742,11 @@ var CodeArtsAdapter = class extends LlmAdapter {
33731
33742
  if (data.error_code === CODEARTS_BENEFIT_NOT_FOUND_ERROR_CODE) {
33732
33743
  throw new LlmError2(`codearts: ${message2}`, BENEFIT_NOT_FOUND_CODE, { status: 200 });
33733
33744
  }
33745
+ // [patch:codearts-benefit-apig] 同样的问题也可能以 200 + SSE error frame 出现,
33746
+ // 且插件的报错只带 error_msg,丢了 error_code(本机 10:06 即此路径)。
33747
+ if (data.error_code.includes("APIG.0101") || message2.includes("APIG.0101")) {
33748
+ throw new LlmError2(`codearts: ${data.error_code} ${message2}`, BENEFIT_HEADER_REJECTED_CODE, { status: 200 });
33749
+ }
33734
33750
  throw new LlmError2(`codearts: ${message2}`, "INVALID_REQUEST", { status: 200 });
33735
33751
  }
33736
33752
  const choice = data.choices?.[0];