dsh-connect-minimaxcode 0.5.3 → 0.5.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/README.en.md CHANGED
@@ -297,10 +297,17 @@ The OAuth token is valid for about an hour and is refreshed automatically by the
297
297
  - **No settings card is provided**. The plugin does not register a card on the DSH settings page; the interface it adds is a single pill in the composer tool row (**drawn only while this plugin's model is selected**) and a small card on the plugin page.
298
298
  - **The upstream APIs are non-public** and may stop working when MiniMax updates its client. If the balance API breaks, the pill shows "credits unavailable", which does not affect model traffic.
299
299
  - **Image input depends on the host's attachment service.** The catalog declares the `image` modality (`M3`, `M3.1-Flash`), but turning a durable attachment into request bytes is the host's job: without that service the plugin still loads and serves text, and only image requests are refused.
300
+ - **The context window is declared as the gateway's real ceiling (1,000,000), not the 512,000 in the catalog.** Upstream's `limit.context` is the *default* window and the billing tier boundary (input above 512k costs more); the largest entry of `context_window_options` is the ceiling the gateway enforces. Measured on 2026-10-25: 946,206 tokens were served normally, 1,050,000 were refused (`invalid params, context window exceeds limit (2013)`). Declaring 512,000 meant every turn of a long conversation was reported as `pi-ai detected context overflow` — while the model had answered perfectly well and the reply was thrown away.
300
301
  - **The device code flow needs `account.minimax.cn` to be reachable**, and the browser that authorizes it has to be able to sign in to a MiniMax account. On some restricted networks the authorization page cannot be opened.
301
302
 
302
303
  ## Changelog
303
304
 
305
+ ### 0.5.4 (2026-10-29)
306
+
307
+ - **Fixed long conversations being reported as context overflow**: upstream's `limit.context` (512,000) is the *default* window and the billing tier boundary, while the ceiling the gateway enforces is the 1,000,000 in `context_window_options`. Declaring 512,000 meant that once a conversation crossed that line, *every* turn was reported as `pi-ai detected context overflow` — even though the model answered normally and the reply was discarded. The window is now declared as the ceiling the gateway actually enforces.
308
+ - The built-in fallback roster (used when the catalog cannot be fetched) now declares 1,000,000 as well.
309
+ - Four new cases pin the window parsing: the largest of `context_window_options` wins, upstream's `limit.context` is the fallback, a malformed option list is ignored, and the fallback roster does not claim 512k.
310
+
304
311
  ### 0.5.3 (2026-10-25)
305
312
 
306
313
  - **Fixed image input**: an upload used to fail every time — `pi-ai image input requires the durable attachment service` (`UNSUPPORTED_CONTENT`). The catalog always declared `image` among a model's input modalities, but the plugin built its `PiAiAdapter` without `resolveAttachments` or `resolveImageAccess`, so pi-ai had no way to turn a durable attachment reference into request bytes and refused the call before it reached the gateway. The plugin now reads the host's `attachments` service on demand and maps an attachment's host path into the current execution world with `fs.processPathFromHostPath`; a host that offers no attachment service gets `undefined` for both hooks, and text-only calls are unchanged.
@@ -455,6 +462,7 @@ dsh plugin --profile web exec dsh-workbuddy-connect status
455
462
  ## Contributors
456
463
 
457
464
  - **[eghrhegpe](https://github.com/eghrhegpe)** — raised the request for a plugin-page icon and Chinese/English copy ([#1](https://github.com/JeffTsuiCUG/dsh-connect-minimaxcode/issues/1)). It became 0.5.2: the plugin page has its own SVG artwork, the title and the introduction come in both languages, and the interface follows the host's language.
465
+ - **[qzz19970504](https://github.com/qzz19970504)** — found and fixed the wiring gap that made every image upload fail ([#3](https://github.com/JeffTsuiCUG/dsh-connect-minimaxcode/pull/3)): the catalog declared the `image` modality, but the adapter never connected the host's durable attachment service, so pi-ai refused image requests before they were sent. The fix became 0.5.3.
458
466
  - Plugin author: **[JeffTsuiCUG](https://github.com/JeffTsuiCUG)**
459
467
 
460
468
  ## Acknowledgements
package/README.md CHANGED
@@ -303,10 +303,17 @@ OAuth 令牌有效期约 1 小时,由客户端自动续期。插件**只在自
303
303
  - **不提供设置界面卡片**。插件不在 DSH 设置页注册卡片;界面只在输入框工具行增加一枚胶囊(**仅选中本插件的模型时显示**),以及插件页面里的一张小卡片。
304
304
  - **上游接口非公开**,MiniMax 客户端更新后可能失效。余额接口失效时胶囊会显示「积分不可用」,不会影响模型对话。
305
305
  - **发图依赖宿主的附件服务**。模型目录声明了 `image` 模态(`M3`、`M3.1-Flash`),但把持久化附件读成请求字节是宿主的活儿:宿主没有附件服务时插件仍能加载并服务文本,只是带图的请求会被拒绝。
306
+ - **上下文窗口按网关的真实上限声明(1,000,000),不是目录里的 512,000**。上游 `limit.context` 是**默认档位与计费分界**(输入超过 512k 的部分按更高倍率计费),`context_window_options` 里最大的一档才是网关执行的硬上限。实测(2026-10-25):946,206 tokens 正常受理,1,050,000 被拒(`invalid params, context window exceeds limit (2013)`)。此前按 512,000 声明,长会话一旦过线就**每一轮**都被判成「上下文溢出」,模型其实答得好好的,回复却被丢掉(`pi-ai detected context overflow`)。
306
307
  - **设备码流需要能访问 `account.minimax.cn`**,且授权时要在浏览器里能登录 MiniMax 账号。某些内网或受限网络下打不开授权页。
307
308
 
308
309
  ## 更新记录
309
310
 
311
+ ### 0.5.4(2026-10-29)
312
+
313
+ - **修复长会话被误判为「上下文溢出」**:上游 `limit.context`(512,000)是**默认档位与计费分界**,网关实际执行的上限是 `context_window_options` 里的 1,000,000。此前按 512,000 声明,会话一旦超过这条线,**每一轮**都会被判定为 `pi-ai detected context overflow` —— 而模型其实正常答了,回复却被丢弃。现在按网关的真实上限声明窗口。
314
+ - 兜底名录(离线时的内置猜测)同步改为 1,000,000。
315
+ - 新增 4 个用例钉住窗口解析:取 `context_window_options` 的最大值、上游没给就回落 `limit.context`、非法列表被忽略、兜底名录的窗口不是 512k。
316
+
310
317
  ### 0.5.3(2026-10-25)
311
318
 
312
319
  - **修复图片输入**:此前发图必然失败 —— `本轮运行失败 pi-ai image input requires the durable attachment service`(`UNSUPPORTED_CONTENT`)。模型目录一直把 `image` 写进模型的输入模态,但插件构造 `PiAiAdapter` 时没有给 `resolveAttachments` 与 `resolveImageAccess` 两个钩子,pi-ai 因此无法把持久化的附件引用变成请求字节,在发往网关之前就拒绝了调用。现在插件按需读取宿主的 `attachments` 服务,并用 `fs.processPathFromHostPath` 把附件的宿主路径映射进当前执行世界;宿主没有提供附件服务时这两个钩子为 `undefined`,纯文本调用不受影响。
@@ -461,6 +468,7 @@ dsh plugin --profile web exec dsh-workbuddy-connect status
461
468
  ## 贡献者
462
469
 
463
470
  - **[eghrhegpe](https://github.com/eghrhegpe)** —— 提出了插件页图标与中英文文案的建议([#1](https://github.com/JeffTsuiCUG/dsh-connect-minimaxcode/issues/1))。这条建议促成了 0.5.2:插件页有了自己的 SVG 图标,标题与简介有了中英两版,界面文案也开始跟随宿主语言。
471
+ - **[qzz19970504](https://github.com/qzz19970504)** —— 定位并修复了「发图必然失败」的接线缺口([#3](https://github.com/JeffTsuiCUG/dsh-connect-minimaxcode/pull/3)):模型目录声明了 `image` 模态,但适配器没有把宿主的持久化附件服务接上,导致带图请求被 pi-ai 在发出前拒掉。该修复成为 0.5.3。
464
472
  - 插件作者:**[JeffTsuiCUG](https://github.com/JeffTsuiCUG)**
465
473
 
466
474
  ## 致谢
package/lib/index.d.ts CHANGED
@@ -145,6 +145,11 @@ declare const MINIMAXCODE_PROVIDER_ID = "minimaxcode";
145
145
  * when upstream retired `MiniMax-M2.7` and `MiniMax-M2.7-highspeed` and
146
146
  * promoted the model previously served anonymously (internally "space bunny")
147
147
  * as `MiniMax-M3.1-Flash`.
148
+ *
149
+ * The window is 1,000,000 rather than the 512,000 the upstream `limit` block
150
+ * reports: 512k is the billing tier boundary, and the gateway itself was
151
+ * measured serving 946,206 tokens before refusing ~1,050,000 with
152
+ * `invalid params, context window exceeds limit (2013)`.
148
153
  */
149
154
  declare const FALLBACK_MODELS: readonly CatalogModel[];
150
155
  /** Where the currently served list came from. */
package/lib/index.js CHANGED
@@ -238,11 +238,16 @@ const MINIMAXCODE_PROVIDER_ID = "minimaxcode";
238
238
  * when upstream retired `MiniMax-M2.7` and `MiniMax-M2.7-highspeed` and
239
239
  * promoted the model previously served anonymously (internally "space bunny")
240
240
  * as `MiniMax-M3.1-Flash`.
241
+ *
242
+ * The window is 1,000,000 rather than the 512,000 the upstream `limit` block
243
+ * reports: 512k is the billing tier boundary, and the gateway itself was
244
+ * measured serving 946,206 tokens before refusing ~1,050,000 with
245
+ * `invalid params, context window exceeds limit (2013)`.
241
246
  */
242
247
  const FALLBACK_MODELS = [{
243
248
  id: "MiniMax-M3",
244
249
  name: "M3",
245
- contextWindow: 512e3,
250
+ contextWindow: 1e6,
246
251
  maxOutputTokens: 128e3,
247
252
  toolCall: true,
248
253
  reasoning: true,
@@ -255,7 +260,7 @@ const FALLBACK_MODELS = [{
255
260
  }, {
256
261
  id: "MiniMax-M3.1-Flash",
257
262
  name: "M3.1-Flash",
258
- contextWindow: 512e3,
263
+ contextWindow: 1e6,
259
264
  maxOutputTokens: 128e3,
260
265
  toolCall: true,
261
266
  reasoning: true,
@@ -278,12 +283,42 @@ function sameCatalog(a, b) {
278
283
  function usable(id, raw) {
279
284
  return id.length > 0 && id.startsWith("MiniMax-") && typeof raw === "object" && raw !== null;
280
285
  }
286
+ /**
287
+ * The window the gateway actually enforces.
288
+ *
289
+ * Upstream reports two different numbers, and they mean different things:
290
+ * `limit.context` is the *default* window — the billing tier boundary, above
291
+ * which input costs more — while `context_window_options` lists every window
292
+ * the gateway will accept, the largest being the hard ceiling.
293
+ *
294
+ * Measured against the live gateway on 2026-10-25: a prompt of 946,206 tokens
295
+ * was served normally, and one of ~1,050,000 was refused with
296
+ * `invalid params, context window exceeds limit (2013)`. The ceiling is
297
+ * therefore the largest option, not `limit.context`.
298
+ *
299
+ * Declaring the default instead of the ceiling is not a cosmetic difference:
300
+ * the adapter compares the gateway's own token count against this number, so a
301
+ * conversation that runs past 512k is reported as a context overflow on every
302
+ * turn even though the gateway answers it perfectly well.
303
+ *
304
+ * @param raw - The upstream model entry.
305
+ * @param limit - The upstream `limit` block, already read.
306
+ * @returns The window to declare, in tokens.
307
+ */
308
+ function readContextWindow(raw, limit) {
309
+ const options = raw.context_window_options;
310
+ if (Array.isArray(options)) {
311
+ const sizes = options.filter((value) => typeof value === "number" && Number.isInteger(value) && value > 0);
312
+ if (sizes.length > 0) return Math.max(...sizes);
313
+ }
314
+ return typeof limit.context === "number" ? limit.context : 2e5;
315
+ }
281
316
  /** Read the fields the upstream sends, tolerating their absence. */
282
317
  function readModel(id, raw) {
283
318
  const limit = raw.limit ?? {};
284
319
  const modalities = raw.modalities ?? {};
285
320
  const input = Array.isArray(modalities.input) ? modalities.input.filter((m) => typeof m === "string") : ["text"];
286
- const contextWindow = typeof limit.context === "number" ? limit.context : 2e5;
321
+ const contextWindow = readContextWindow(raw, limit);
287
322
  return {
288
323
  id,
289
324
  name: typeof raw.name === "string" ? raw.name : id,
package/package.json CHANGED
@@ -2,16 +2,20 @@
2
2
  "name": "dsh-connect-minimaxcode",
3
3
  "displayName": "DSH Connect MiniMax Code",
4
4
  "description": "把本机已登录的 MiniMax Code 桌面 App 模型接入 DeepSeek Harness:零配置、Anthropic Messages 兼容、动态模型目录,并显示积分余额与到期 — bring MiniMax Code desktop app models into DSH with a dynamic model catalog and a credit balance with expiry details.",
5
- "version": "0.5.3",
5
+ "version": "0.5.4",
6
6
  "author": "JeffTsuiCUG",
7
7
  "contributors": [
8
8
  {
9
9
  "name": "JeffTsuiCUG",
10
10
  "url": "https://github.com/JeffTsuiCUG"
11
11
  },
12
+ {
13
+ "name": "eghrhegpe",
14
+ "url": "https://github.com/eghrhegpe"
15
+ },
12
16
  {
13
- "name": "eghrhegpe",
14
- "url": "https://github.com/eghrhegpe"
17
+ "name": "qzz19970504",
18
+ "url": "https://github.com/qzz19970504"
15
19
  }
16
20
  ],
17
21
  "license": "MIT",