dsh-connect-trae 2.0.3 → 2.0.4

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,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.0.4 (2026-09-16)
4
+
5
+ ### Fixes
6
+
7
+ - **修复「某个区域没有实时模型目录时,该区域的 provider 整个加载失败」**(issue #8:未安装国际版的用户看到 `Trae Global 加载失败:adapter returned invalid context metadata for provider "trae-global" model "gemini-3.1-pro"`):
8
+ - **根因**:两个区域的内置兜底目录里,每个模型都缺少 `contextWindow`。DSH 要求它必须是正整数(`INVALID_MODEL_CONTEXT`),而 `dsh-llm-pi-ai` 的回退链是 `entry.contextWindow → 已安装 catalog → request.defaultContextWindow`——本插件既没传 `defaultContextWindow`,兜底模型也不在已安装 catalog 里,三条全空,于是校验失败。
9
+ - **失败粒度是 provider 级**:不是丢单个模型,而是**整个区域不可用**。触发场景包括未安装该区客户端、未登录、目录拉取失败(该端点有已知的间歇性 401)、以及首次安装尚未刷新过目录。因此这不是「没装国际版拖累国内版」,而是**两个区域各自独立地有这个缺陷**。
10
+ - **修复**:(1) 兜底目录补上实测 `contextWindow`——国际版依据 2026-09-15 实测目录(`gemini-3.1-pro`/`gemini-3-flash-solo`/`minimax-m3`/`minimax-m2.7`/`kimi-k2.5` = 200000,`gpt-5.4`/`gpt-5.2` = 272000),国内版依据 SOLO 通道实测(200000);(2) adapter 传 `defaultContextWindow` 作为最终防线,将来任何来源的条目不慎缺字段时降级为「一个保守尺寸的模型」而非「整区不可用」。
11
+ - 新增不变量测试:**两个区域的兜底行都必须带正整数 `contextWindow`**。原先有一条测试断言「兜底条目没有 `contextWindow`」——它固化的正是这个 bug,已改正。
12
+
3
13
  ## 2.0.3 (2026-09-16)
4
14
 
5
15
  ### Fixes
package/lib/index.d.ts CHANGED
@@ -126,6 +126,14 @@ interface TraeModelInfo {
126
126
  * `DeepSeek-V4-Pro-Official` carry the `-Official` suffix, and there is no
127
127
  * `auto` config_name — an `auto` row was previously served here and would have
128
128
  * failed on selection.
129
+ *
130
+ * Every row MUST also carry a positive-integer `contextWindow`. DSH rejects an
131
+ * adapter whose model has no usable context (`INVALID_MODEL_CONTEXT`), and that
132
+ * failure is per-provider — one bad row takes the whole region offline. These
133
+ * rows are exactly the ones served when no live directory is available (no
134
+ * install for that region, signed out, or a failed refresh), which is precisely
135
+ * when the fallback is doing its job, so a missing field here is fatal rather
136
+ * than cosmetic. See docs/ISSUE8_DIAGNOSIS.md.
129
137
  */
130
138
  declare const FALLBACK_TRAE_MODELS: readonly TraeModelInfo[];
131
139
  /**
@@ -135,6 +143,10 @@ declare const FALLBACK_TRAE_MODELS: readonly TraeModelInfo[];
135
143
  * has no Gemini/GPT/MiniMax entries), so an international account must never
136
144
  * be seeded with the CN list. Like the CN fallback it is replaced by the live
137
145
  * refresh; image input stays the user's explicit opt-in (`imageModelIds`).
146
+ *
147
+ * The `contextWindow` values are the measured ones from that same capture
148
+ * (`docs/INTL_SG_EVIDENCE.md` §3) and are required for the same reason as the
149
+ * CN fallback: without them the whole `trae-global` provider fails to load.
138
150
  */
139
151
  declare const FALLBACK_TRAE_MODELS_AI: readonly TraeModelInfo[];
140
152
  /**
package/lib/index.js CHANGED
@@ -29,23 +29,35 @@ import { promisify } from "node:util";
29
29
  * `DeepSeek-V4-Pro-Official` carry the `-Official` suffix, and there is no
30
30
  * `auto` config_name — an `auto` row was previously served here and would have
31
31
  * failed on selection.
32
+ *
33
+ * Every row MUST also carry a positive-integer `contextWindow`. DSH rejects an
34
+ * adapter whose model has no usable context (`INVALID_MODEL_CONTEXT`), and that
35
+ * failure is per-provider — one bad row takes the whole region offline. These
36
+ * rows are exactly the ones served when no live directory is available (no
37
+ * install for that region, signed out, or a failed refresh), which is precisely
38
+ * when the fallback is doing its job, so a missing field here is fatal rather
39
+ * than cosmetic. See docs/ISSUE8_DIAGNOSIS.md.
32
40
  */
33
41
  const FALLBACK_TRAE_MODELS = [
34
42
  {
35
43
  id: "DeepSeek-V4-Flash-Official",
36
- name: "DeepSeek-V4-Flash"
44
+ name: "DeepSeek-V4-Flash",
45
+ contextWindow: 2e5
37
46
  },
38
47
  {
39
48
  id: "DeepSeek-V4-Pro-Official",
40
- name: "DeepSeek-V4-Pro"
49
+ name: "DeepSeek-V4-Pro",
50
+ contextWindow: 2e5
41
51
  },
42
52
  {
43
53
  id: "glm-5.2",
44
- name: "GLM-5.2"
54
+ name: "GLM-5.2",
55
+ contextWindow: 2e5
45
56
  },
46
57
  {
47
58
  id: "kimi-k2.6",
48
- name: "Kimi-K2.6"
59
+ name: "Kimi-K2.6",
60
+ contextWindow: 2e5
49
61
  }
50
62
  ];
51
63
  /**
@@ -55,35 +67,46 @@ const FALLBACK_TRAE_MODELS = [
55
67
  * has no Gemini/GPT/MiniMax entries), so an international account must never
56
68
  * be seeded with the CN list. Like the CN fallback it is replaced by the live
57
69
  * refresh; image input stays the user's explicit opt-in (`imageModelIds`).
70
+ *
71
+ * The `contextWindow` values are the measured ones from that same capture
72
+ * (`docs/INTL_SG_EVIDENCE.md` §3) and are required for the same reason as the
73
+ * CN fallback: without them the whole `trae-global` provider fails to load.
58
74
  */
59
75
  const FALLBACK_TRAE_MODELS_AI = [
60
76
  {
61
77
  id: "gemini-3.1-pro",
62
- name: "Gemini-3.1-Pro-Preview"
78
+ name: "Gemini-3.1-Pro-Preview",
79
+ contextWindow: 2e5
63
80
  },
64
81
  {
65
82
  id: "gemini-3-flash-solo",
66
- name: "Gemini-3-Flash-Preview"
83
+ name: "Gemini-3-Flash-Preview",
84
+ contextWindow: 2e5
67
85
  },
68
86
  {
69
87
  id: "minimax-m3",
70
- name: "MiniMax-M3"
88
+ name: "MiniMax-M3",
89
+ contextWindow: 2e5
71
90
  },
72
91
  {
73
92
  id: "minimax-m2.7",
74
- name: "MiniMax-M2.7"
93
+ name: "MiniMax-M2.7",
94
+ contextWindow: 2e5
75
95
  },
76
96
  {
77
97
  id: "kimi-k2.5",
78
- name: "Kimi-K2.5"
98
+ name: "Kimi-K2.5",
99
+ contextWindow: 2e5
79
100
  },
80
101
  {
81
102
  id: "gpt-5.4",
82
- name: "GPT-5.4"
103
+ name: "GPT-5.4",
104
+ contextWindow: 272e3
83
105
  },
84
106
  {
85
107
  id: "gpt-5.2",
86
- name: "GPT-5.2"
108
+ name: "GPT-5.2",
109
+ contextWindow: 272e3
87
110
  }
88
111
  ];
89
112
  /**
@@ -292,6 +315,13 @@ const REQUEST_IMAGE_BUDGETS = {
292
315
  requestImagePixelBudget: 4194304,
293
316
  requestImageMaxBytes: 1048576
294
317
  };
318
+ /**
319
+ * Conservative context capacity used only when a served model row carries no
320
+ * window of its own. Every fallback row and every live Trae row is expected to
321
+ * state its real window; this is the backstop that keeps one unsized row from
322
+ * failing the entire provider route (`INVALID_MODEL_CONTEXT`).
323
+ */
324
+ const FALLBACK_CONTEXT_WINDOW = 2e5;
295
325
  function toPiModel(info, baseUrl, providerId) {
296
326
  return {
297
327
  id: info.id,
@@ -351,6 +381,7 @@ function createTraeAdapter(options) {
351
381
  retryPolicy: resolveRetryPolicy(void 0, "dsh-connect-trae retryPolicy"),
352
382
  configuredMaxTokens: /* @__PURE__ */ new Map(),
353
383
  modelErrors: /* @__PURE__ */ new Map(),
384
+ defaultContextWindow: FALLBACK_CONTEXT_WINDOW,
354
385
  ...REQUEST_IMAGE_BUDGETS,
355
386
  piProvider: provider
356
387
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "dsh-connect-trae",
3
3
  "displayName": "DSH Connect Trae",
4
4
  "description": "Connect locally signed-in Trae models to DeepSeek Harness, plus a read-only usage/credits summary.",
5
- "version": "2.0.3",
5
+ "version": "2.0.4",
6
6
  "author": "dingminhua",
7
7
  "copyright": "Copyright (c) 2026 LaoDing",
8
8
  "license": "MIT",