dsh-codearts 1.4.11 → 1.4.13

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
@@ -3,6 +3,35 @@
3
3
  本文件记录本插件的重要改动。格式参考 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/),
4
4
  版本号遵循 [语义化版本](https://semver.org/lang/zh-CN/)。
5
5
 
6
+ ## [1.4.13] - 2026-11-24
7
+
8
+ ### 修复
9
+
10
+ - 清空「输出上限」后点弹层外面或按 Esc 收起,改动不提交、徽标停在旧值(#15):
11
+ 点外面/Esc 的监听器闭包只把窗口草稿列为依赖,清空输出只更新输出草稿、不重注册
12
+ 监听器,收起时拿的是不含输出改动的旧快照。两处草稿现在都是依赖。
13
+
14
+ ## [1.4.12] - 2026-11-24
15
+
16
+ ### 修复
17
+
18
+ - **不再把「请求体过大」误学成窗口上界**(#18):上游对真超窗和图片/附件撑大
19
+ 请求体回同一个 `InferHub.001001005.400`。以前 max_tokens 降到地板就无条件把
20
+ 本次 prompt 估算记成窗口上界,一次图片超限之后每条请求(含 `/compact`)都被
21
+ 本地拦住。现在只有报错文案明确是 `input token limit is N` 才学习窗口;其余
22
+ 按「请求体过大」报错,提示减少图片/附件,不再引导压缩上下文。
23
+ - 内联图片总预算从 20 MiB 降到 6 MiB:上游对约 10 MB 的请求体就回同一个 400,
24
+ 超预算时改由宿主把最老的图片换成占位文本(`read_image` 按需重读),不再让
25
+ 请求带着全部图片去撞上游。
26
+ - `MALFORMED_RESPONSE` 纳入默认重试码:模型偶尔把工具参数写成非法 JSON,
27
+ pi-ai 在派发工具前就判整轮失败,表现为「本轮运行失败、选项不弹」。重发让
28
+ 模型重新生成,多数可自愈。
29
+
30
+ ### 新增
31
+
32
+ - `CODEARTS_IGNORE_LEARNED=1`:读取窗口上界时忽略已学值(不清表),用于自救
33
+ 被旧逻辑锁死的会话。
34
+
6
35
  ## [1.4.11] - 2026-11-23
7
36
 
8
37
  ### 修复
@@ -584,7 +584,7 @@ async function clearCredential(path) {
584
584
  async function claimIfPossible(cred) {
585
585
  if (!cred.accessKeyId || !cred.secretAccessKey) return;
586
586
  try {
587
- const { claimBenefit } = await import("./upstream-BX6-klXI.mjs").then((n) => n.L);
587
+ const { claimBenefit } = await import("./upstream-DeRNnZdN.mjs").then((n) => n.R);
588
588
  await claimBenefit({
589
589
  token: cred.token,
590
590
  accessKeyId: cred.accessKeyId,
package/lib/bin.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import { i as codeartsAccountsPath, t as CodeArtsAccountStore } from "./auth-BaxN0iKC.mjs";
3
- import { K as isBenefitModel, l as fetchCallerIdentity } from "./upstream-BX6-klXI.mjs";
4
- import { i as discoverModels, n as CodeArtsUsageTracker, r as codeartsUsagePath, t as CODEARTS_VERSION } from "./version-D4fJX342.mjs";
2
+ import { i as codeartsAccountsPath, t as CodeArtsAccountStore } from "./auth-D-RmpxN3.mjs";
3
+ import { l as fetchCallerIdentity, q as isBenefitModel } from "./upstream-DeRNnZdN.mjs";
4
+ import { i as discoverModels, n as CodeArtsUsageTracker, r as codeartsUsagePath, t as CODEARTS_VERSION } from "./version-BnCFPeBL.mjs";
5
5
  import { existsSync, statSync } from "node:fs";
6
6
  //#region src/bin.ts
7
7
  /**
@@ -194,129 +194,129 @@ if (typeof document !== "undefined" && document.querySelector("style[data-plugin
194
194
  document.head.appendChild(tag);
195
195
  }
196
196
  var CodeArtsPluginCard_module_css_default = {
197
+ "check": "xoziZG_check",
198
+ "accountMenuItem": "xoziZG_accountMenuItem",
197
199
  "updated": "xoziZG_updated",
198
- "expiryLabel": "xoziZG_expiryLabel",
200
+ "hint": "xoziZG_hint",
201
+ "modelShare": "xoziZG_modelShare",
202
+ "expiryRow": "xoziZG_expiryRow",
203
+ "statGrid": "xoziZG_statGrid",
204
+ "manualForm": "xoziZG_manualForm",
205
+ "windowPopoverValue": "xoziZG_windowPopoverValue",
206
+ "choiceRow": "xoziZG_choiceRow",
207
+ "creditRows": "xoziZG_creditRows",
208
+ "accountEntry": "xoziZG_accountEntry",
209
+ "link": "xoziZG_link",
210
+ "concurrencyStepper": "xoziZG_concurrencyStepper",
211
+ "balance": "xoziZG_balance",
212
+ "accountConcurrencyLabel": "xoziZG_accountConcurrencyLabel",
213
+ "trendTip": "xoziZG_trendTip",
214
+ "accountInfo": "xoziZG_accountInfo",
215
+ "meta": "xoziZG_meta",
216
+ "statCard": "xoziZG_statCard",
217
+ "concurrencyValue": "xoziZG_concurrencyValue",
218
+ "accountMenu": "xoziZG_accountMenu",
219
+ "tabPanel": "xoziZG_tabPanel",
220
+ "usageTipSep": "xoziZG_usageTipSep",
199
221
  "creditHint": "xoziZG_creditHint",
200
- "modelName": "xoziZG_modelName",
222
+ "modelChart": "xoziZG_modelChart",
223
+ "choices": "xoziZG_choices",
224
+ "claimAllRow": "xoziZG_claimAllRow",
201
225
  "concurrencyButton": "xoziZG_concurrencyButton",
202
- "usageFill": "xoziZG_usageFill",
203
- "error": "xoziZG_error",
204
- "usageTipSep": "xoziZG_usageTipSep",
226
+ "modelRow": "xoziZG_modelRow",
227
+ "name": "xoziZG_name",
228
+ "creditRow": "xoziZG_creditRow",
229
+ "manualSummary": "xoziZG_manualSummary",
230
+ "sectionHead": "xoziZG_sectionHead",
231
+ "heatLegend": "xoziZG_heatLegend",
232
+ "accountGrid": "xoziZG_accountGrid",
233
+ "statusLine": "xoziZG_statusLine",
234
+ "accountRow": "xoziZG_accountRow",
235
+ "card": "xoziZG_card",
236
+ "field": "xoziZG_field",
205
237
  "accountMenuAnchor": "xoziZG_accountMenuAnchor",
206
- "heatCell": "xoziZG_heatCell",
207
- "trendTip": "xoziZG_trendTip",
208
- "desc": "xoziZG_desc",
209
- "groupHeadFirst": "xoziZG_groupHeadFirst",
210
- "claimAllRow": "xoziZG_claimAllRow",
211
- "sectionLabel": "xoziZG_sectionLabel",
212
- "windowRange": "xoziZG_windowRange",
213
- "accountConcurrencyInline": "xoziZG_accountConcurrencyInline",
214
- "choiceRow": "xoziZG_choiceRow",
238
+ "tabs": "xoziZG_tabs",
215
239
  "usageTip": "xoziZG_usageTip",
216
- "doctorRow": "xoziZG_doctorRow",
217
- "skeleton": "xoziZG_skeleton",
218
- "usageBar": "xoziZG_usageBar",
219
- "statLabel": "xoziZG_statLabel",
220
- "modelChart": "xoziZG_modelChart",
221
- "bar": "xoziZG_bar",
240
+ "error": "xoziZG_error",
241
+ "header": "xoziZG_header",
222
242
  "section": "xoziZG_section",
223
- "card": "xoziZG_card",
224
- "creditRow": "xoziZG_creditRow",
225
- "statusLine": "xoziZG_statusLine",
226
- "accountConcurrencyLabel": "xoziZG_accountConcurrencyLabel",
227
- "windowButtonOpen": "xoziZG_windowButtonOpen",
228
- "accountNameRow": "xoziZG_accountNameRow",
229
- "headText": "xoziZG_headText",
243
+ "windowButtonSet": "xoziZG_windowButtonSet",
244
+ "count": "xoziZG_count",
245
+ "creditBlock": "xoziZG_creditBlock",
246
+ "accountConcurrencyInline": "xoziZG_accountConcurrencyInline",
247
+ "windowPopover": "xoziZG_windowPopover",
248
+ "bar": "xoziZG_bar",
230
249
  "usageTipRow": "xoziZG_usageTipRow",
231
- "header": "xoziZG_header",
232
- "accountClearHint": "xoziZG_accountClearHint",
233
- "accountRow": "xoziZG_accountRow",
234
- "modelShare": "xoziZG_modelShare",
235
- "heatGrid": "xoziZG_heatGrid",
250
+ "actions": "xoziZG_actions",
251
+ "usageBar": "xoziZG_usageBar",
252
+ "accountCard": "xoziZG_accountCard",
253
+ "creditLink": "xoziZG_creditLink",
236
254
  "heatAxisSlot": "xoziZG_heatAxisSlot",
237
- "modelRow": "xoziZG_modelRow",
238
- "statCard": "xoziZG_statCard",
239
255
  "windowInput": "xoziZG_windowInput",
240
- "balanceMeta": "xoziZG_balanceMeta",
241
- "actions": "xoziZG_actions",
242
- "windowInputSet": "xoziZG_windowInputSet",
243
- "concurrencyStepper": "xoziZG_concurrencyStepper",
244
- "skeletonRow": "xoziZG_skeletonRow",
245
- "statValue": "xoziZG_statValue",
256
+ "modelFill": "xoziZG_modelFill",
257
+ "statLabel": "xoziZG_statLabel",
258
+ "windowUnit": "xoziZG_windowUnit",
259
+ "modelMeta": "xoziZG_modelMeta",
246
260
  "modelCheck": "xoziZG_modelCheck",
247
- "balanceRow": "xoziZG_balanceRow",
261
+ "groupLabel": "xoziZG_groupLabel",
248
262
  "body": "xoziZG_body",
249
- "creditFooter": "xoziZG_creditFooter",
250
- "accountToggle": "xoziZG_accountToggle",
251
- "hint": "xoziZG_hint",
252
- "name": "xoziZG_name",
253
- "modelTrack": "xoziZG_modelTrack",
254
- "windowCaret": "xoziZG_windowCaret",
255
- "modelMeta": "xoziZG_modelMeta",
256
- "usageTipName": "xoziZG_usageTipName",
257
- "windowButton": "xoziZG_windowButton",
258
- "windowHint": "xoziZG_windowHint",
263
+ "statValue": "xoziZG_statValue",
264
+ "heatGrid": "xoziZG_heatGrid",
265
+ "modelTokens": "xoziZG_modelTokens",
259
266
  "modelRequests": "xoziZG_modelRequests",
260
- "heatAxis": "xoziZG_heatAxis",
261
- "avatar": "xoziZG_avatar",
262
- "accountName": "xoziZG_accountName",
263
- "count": "xoziZG_count",
264
- "choices": "xoziZG_choices",
265
- "manualForm": "xoziZG_manualForm",
266
- "area": "xoziZG_area",
267
- "windowPopoverHead": "xoziZG_windowPopoverHead",
268
- "balanceUnit": "xoziZG_balanceUnit",
269
- "accountInfo": "xoziZG_accountInfo",
270
- "expiryRow": "xoziZG_expiryRow",
271
267
  "windowPopoverRow": "xoziZG_windowPopoverRow",
272
- "modelSpec": "xoziZG_modelSpec",
268
+ "heatAxis": "xoziZG_heatAxis",
273
269
  "statSub": "xoziZG_statSub",
274
- "check": "xoziZG_check",
275
- "accountMenu": "xoziZG_accountMenu",
276
- "field": "xoziZG_field",
277
- "windowUnit": "xoziZG_windowUnit",
278
- "sectionHead": "xoziZG_sectionHead",
279
- "accountCard": "xoziZG_accountCard",
280
- "heatHourCell": "xoziZG_heatHourCell",
281
- "accountEntry": "xoziZG_accountEntry",
282
- "accountClear": "xoziZG_accountClear",
283
- "choiceTail": "xoziZG_choiceTail",
284
- "doctorName": "xoziZG_doctorName",
270
+ "danger": "xoziZG_danger",
271
+ "windowInputSet": "xoziZG_windowInputSet",
285
272
  "manual": "xoziZG_manual",
286
- "manualSummary": "xoziZG_manualSummary",
287
- "fieldLabel": "xoziZG_fieldLabel",
288
- "creditBlock": "xoziZG_creditBlock",
289
- "modelTokens": "xoziZG_modelTokens",
290
- "windowAnchor": "xoziZG_windowAnchor",
273
+ "groupHead": "xoziZG_groupHead",
274
+ "headText": "xoziZG_headText",
291
275
  "windowSection": "xoziZG_windowSection",
292
- "windowPopover": "xoziZG_windowPopover",
293
- "accountGrid": "xoziZG_accountGrid",
276
+ "windowButtonOpen": "xoziZG_windowButtonOpen",
277
+ "windowAnchor": "xoziZG_windowAnchor",
278
+ "skeletonBreath": "xoziZG_skeletonBreath",
279
+ "windowPopoverHead": "xoziZG_windowPopoverHead",
280
+ "windowHint": "xoziZG_windowHint",
281
+ "accountName": "xoziZG_accountName",
282
+ "expiryLabel": "xoziZG_expiryLabel",
283
+ "creditFooter": "xoziZG_creditFooter",
284
+ "heatHourCell": "xoziZG_heatHourCell",
285
+ "accountHint": "xoziZG_accountHint",
286
+ "choiceTail": "xoziZG_choiceTail",
287
+ "avatar": "xoziZG_avatar",
288
+ "modelTrack": "xoziZG_modelTrack",
294
289
  "heatWeekday": "xoziZG_heatWeekday",
290
+ "windowCaret": "xoziZG_windowCaret",
291
+ "doctorName": "xoziZG_doctorName",
295
292
  "heatHours": "xoziZG_heatHours",
296
- "windowButtonSet": "xoziZG_windowButtonSet",
297
- "groupHead": "xoziZG_groupHead",
298
- "heatLegendChip": "xoziZG_heatLegendChip",
299
- "balance": "xoziZG_balance",
300
- "accountMenuItem": "xoziZG_accountMenuItem",
301
- "heatLegend": "xoziZG_heatLegend",
302
- "link": "xoziZG_link",
293
+ "groupHeadFirst": "xoziZG_groupHeadFirst",
294
+ "modelSpec": "xoziZG_modelSpec",
295
+ "doctorRow": "xoziZG_doctorRow",
296
+ "windowRange": "xoziZG_windowRange",
303
297
  "accountToolbar": "xoziZG_accountToolbar",
304
- "statGrid": "xoziZG_statGrid",
305
- "danger": "xoziZG_danger",
306
- "tabPanel": "xoziZG_tabPanel",
307
- "modelFill": "xoziZG_modelFill",
308
- "concurrencyValue": "xoziZG_concurrencyValue",
309
- "creditRows": "xoziZG_creditRows",
310
- "meta": "xoziZG_meta",
311
- "skeletonBreath": "xoziZG_skeletonBreath",
312
- "windowPopoverValue": "xoziZG_windowPopoverValue",
313
- "groupLabel": "xoziZG_groupLabel",
314
- "tabs": "xoziZG_tabs",
315
- "accountRowActions": "xoziZG_accountRowActions",
298
+ "modelName": "xoziZG_modelName",
299
+ "heatCell": "xoziZG_heatCell",
300
+ "heatLegendChip": "xoziZG_heatLegendChip",
301
+ "desc": "xoziZG_desc",
302
+ "accountToggle": "xoziZG_accountToggle",
303
+ "fieldLabel": "xoziZG_fieldLabel",
304
+ "balanceMeta": "xoziZG_balanceMeta",
316
305
  "doctorList": "xoziZG_doctorList",
317
- "accountHint": "xoziZG_accountHint",
318
- "creditLink": "xoziZG_creditLink",
319
- "barFill": "xoziZG_barFill"
306
+ "accountClear": "xoziZG_accountClear",
307
+ "skeletonRow": "xoziZG_skeletonRow",
308
+ "accountClearHint": "xoziZG_accountClearHint",
309
+ "usageFill": "xoziZG_usageFill",
310
+ "barFill": "xoziZG_barFill",
311
+ "accountNameRow": "xoziZG_accountNameRow",
312
+ "sectionLabel": "xoziZG_sectionLabel",
313
+ "balanceRow": "xoziZG_balanceRow",
314
+ "skeleton": "xoziZG_skeleton",
315
+ "windowButton": "xoziZG_windowButton",
316
+ "usageTipName": "xoziZG_usageTipName",
317
+ "balanceUnit": "xoziZG_balanceUnit",
318
+ "area": "xoziZG_area",
319
+ "accountRowActions": "xoziZG_accountRowActions"
320
320
  };
321
321
  //#endregion
322
322
  //#region src/client/CodeArtsPluginCard.tsx
@@ -1530,6 +1530,7 @@ function CodeArtsPluginCard({ t }) {
1530
1530
  }, [
1531
1531
  windowOpenFor,
1532
1532
  windowDrafts,
1533
+ outputDrafts,
1533
1534
  selection
1534
1535
  ]);
1535
1536
  (0, react.useEffect)(() => {
@@ -3630,14 +3631,14 @@ if (typeof document !== "undefined" && document.querySelector("style[data-plugin
3630
3631
  document.head.appendChild(tag);
3631
3632
  }
3632
3633
  var CodeArtsPanel_module_css_default = {
3634
+ "icon": "Z66cgG_icon",
3633
3635
  "head": "Z66cgG_head",
3636
+ "page": "Z66cgG_page",
3637
+ "desc": "Z66cgG_desc",
3638
+ "back": "Z66cgG_back",
3634
3639
  "body": "Z66cgG_body",
3635
3640
  "backCaret": "Z66cgG_backCaret",
3636
- "desc": "Z66cgG_desc",
3637
- "icon": "Z66cgG_icon",
3638
- "page": "Z66cgG_page",
3639
- "title": "Z66cgG_title",
3640
- "back": "Z66cgG_back"
3641
+ "title": "Z66cgG_title"
3641
3642
  };
3642
3643
  //#endregion
3643
3644
  //#region src/client/CodeArtsPanel.tsx
package/lib/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { a as codeartsAuthPath, c as credentialFromOAuth, g as startLogin, i as codeartsAccountsPath, n as CodeArtsCredentialStore, o as codeartsDebugLogPath, r as MANUAL_ACCOUNT_ID, s as codeartsRefreshLogPath, t as CodeArtsAccountStore } from "./auth-BaxN0iKC.mjs";
2
- import { $ as withMaxTokensOverride, A as prepareChatBody, C as isWelfareClaimedStatus, D as modelUnavailableReasonText, E as maxTokensCeilingFor, F as signedGet, G as isBenefitBlocked, H as creditRatioLabel, I as upstreamErrorMessage, K as isBenefitModel, M as rateLimitFrame, N as setMaxTokenOverride, O as overrideValueFor, P as setMaxTokenOverrides, Q as withContextWindowOverride, R as CodeArtsCatalog, S as isTpmLimit, T as learnedContextWindowFor, U as filterEnabledModels, V as clearBenefitBlocked, W as forgetModelUnavailable, X as modelUnavailableReason, _ as isNotMultimodal, a as claimDailyWelfare, b as isQueueRejectText, c as degradeTokenCeiling, d as fetchQueueStatus, f as fetchWelfareCampaigns, g as isModelNotAccessible, h as isIamTokenError, i as chatStream, j as queueFrame, k as pickDailyWelfareCampaign, l as fetchCallerIdentity, m as isConcurrencyCap, n as SNAP_HOST, o as clearQueueStatus, p as firstFrameError, q as markModelUnavailable, r as canonicalModel, s as contextWindowOverrideFor, t as MAX_TOKENS_FLOOR, u as fetchModels, v as isParamInvalidFrame, w as learnContextWindow, x as isQueueableRate, y as isQueueReject, z as FALLBACK_CODEARTS_MODELS } from "./upstream-BX6-klXI.mjs";
3
- import { a as refreshCatalog, i as discoverModels, n as CodeArtsUsageTracker, r as codeartsUsagePath, t as CODEARTS_VERSION } from "./version-D4fJX342.mjs";
1
+ import { a as codeartsAuthPath, c as credentialFromOAuth, g as startLogin, i as codeartsAccountsPath, n as CodeArtsCredentialStore, o as codeartsDebugLogPath, r as MANUAL_ACCOUNT_ID, s as codeartsRefreshLogPath, t as CodeArtsAccountStore } from "./auth-D-RmpxN3.mjs";
2
+ import { $ as withContextWindowOverride, A as pickDailyWelfareCampaign, B as FALLBACK_CODEARTS_MODELS, C as isTpmLimit, D as maxTokensCeilingFor, E as learnedContextWindowFor, F as setMaxTokenOverrides, G as forgetModelUnavailable, H as clearBenefitBlocked, I as signedGet, J as markModelUnavailable, K as isBenefitBlocked, L as upstreamErrorMessage, M as queueFrame, N as rateLimitFrame, O as modelUnavailableReasonText, P as setMaxTokenOverride, S as isQueueableRate, T as learnContextWindow, U as creditRatioLabel, W as filterEnabledModels, Z as modelUnavailableReason, _ as isModelNotAccessible, a as claimDailyWelfare, b as isQueueReject, c as degradeTokenCeiling, d as fetchQueueStatus, et as withMaxTokensOverride, f as fetchWelfareCampaigns, g as isIamTokenError, h as isContextOverflowText, i as chatStream, j as prepareChatBody, k as overrideValueFor, l as fetchCallerIdentity, m as isConcurrencyCap, n as SNAP_HOST, o as clearQueueStatus, p as firstFrameError, q as isBenefitModel, r as canonicalModel, s as contextWindowOverrideFor, t as MAX_TOKENS_FLOOR, u as fetchModels, v as isNotMultimodal, w as isWelfareClaimedStatus, x as isQueueRejectText, y as isParamInvalidFrame, z as CodeArtsCatalog } from "./upstream-DeRNnZdN.mjs";
3
+ import { a as refreshCatalog, i as discoverModels, n as CodeArtsUsageTracker, r as codeartsUsagePath, t as CODEARTS_VERSION } from "./version-BnCFPeBL.mjs";
4
4
  import { i as lazyApi, r as createProvider } from "./models-CgKCibpk.mjs";
5
5
  import { c as keeperLogPath, f as keeperStats, i as clearKeeperHandoff, l as keeperNextPassAt, m as stopKeeper, n as KEEPER_STALE_MS, p as spawnKeeper, s as keeperHandoffRecent, u as keeperScriptPath } from "./keeper-BWHQDFAh.mjs";
6
6
  import { appendFileSync, statSync, writeFileSync } from "node:fs";
@@ -768,6 +768,22 @@ const CODEARTS_PROVIDER = "codearts";
768
768
  const CODEARTS_STREAM_IDLE_TIMEOUT_MS = 9e4;
769
769
  const DEFAULT_CODEARTS_INITIAL_DELAY_MS = 500;
770
770
  const DEFAULT_CODEARTS_MAX_DELAY_MS = 1e4;
771
+ /**
772
+ * 重试码 = 宿主默认五项 + MALFORMED_RESPONSE。
773
+ *
774
+ * 模型偶尔把 tool_call 参数写成非法 JSON(未转义引号、流内 JSON 损坏),
775
+ * pi-ai 在**派发工具之前**就判整轮失败 —— 用户看到的是一轮报错、选项全无。
776
+ * 重发一次让模型重新生成,多数自愈。宿主的默认集合不含这个码,而
777
+ * `retryableCodes` 是替换语义(不是并入),所以五项默认值必须显式列全。
778
+ */
779
+ const RETRYABLE_CODES = [
780
+ "EMPTY_RESPONSE",
781
+ "RATE_LIMIT",
782
+ "SERVER",
783
+ "TIMEOUT",
784
+ "TRANSPORT",
785
+ "MALFORMED_RESPONSE"
786
+ ];
771
787
  /** 只认有限正整数;非法值忽略而不是抛错(值来自用户写的配置文件)。 */
772
788
  function positiveInt(value) {
773
789
  return typeof value === "number" && Number.isFinite(value) && value > 0 ? Math.floor(value) : void 0;
@@ -777,6 +793,7 @@ function resolveCodeArtsRetryPolicy(config) {
777
793
  const resolved = {
778
794
  mode: "normal",
779
795
  maxRetries: positiveInt(config?.maxRetries) ?? 8,
796
+ retryableCodes: [...RETRYABLE_CODES],
780
797
  backoff: {
781
798
  initialDelayMs: positiveInt(config?.initialDelayMs) ?? DEFAULT_CODEARTS_INITIAL_DELAY_MS,
782
799
  maxDelayMs: positiveInt(config?.maxDelayMs) ?? DEFAULT_CODEARTS_MAX_DELAY_MS
@@ -793,8 +810,15 @@ const NO_COST = {
793
810
  cacheRead: 0,
794
811
  cacheWrite: 0
795
812
  };
813
+ /**
814
+ * 6 MiB 而不是 20 MiB:上游网关对**整个请求体**约 10 MB 就拒(issue #18 实测
815
+ * 9.71 MB 过、10.41 MB 拒,且纯文本 1 MB 能过 ⇒ 是字节而非 token)。20 MiB 的
816
+ * 预算会让图片总量 10 MB 左右的请求直接发给上游,撞 InferHub.001001005.400,
817
+ * 再被误判成上下文超限。压到 6 MiB 后,宿主会把最老的图片换成占位文本
818
+ * (`read_image` 按需重读),给文本与工具定义留出约 4 MB 余量。
819
+ */
796
820
  const REQUEST_IMAGE_BUDGETS = {
797
- maxRequestImageBytes: 20971520,
821
+ maxRequestImageBytes: 6291456,
798
822
  requestImagePixelBudget: 4194304,
799
823
  requestImageMaxBytes: 1048576
800
824
  };
@@ -1414,18 +1438,31 @@ function createCodeArtsShim(options) {
1414
1438
  };
1415
1439
  await result.stream.cancel().catch(() => {});
1416
1440
  if (degradeTokenCeiling(prepared.model) === 0) {
1417
- if (prepared.promptTokens > 0) {
1441
+ const overflow = isContextOverflowText(headText ?? "");
1442
+ if (overflow && prepared.promptTokens > 0) {
1418
1443
  const learned = learnContextWindow(prepared.model, prepared.promptTokens);
1419
- logger?.warn(`dsh-codearts: ${prepared.model} 在 max_tokens 地板仍被判参数非法,按本次 prompt 估算 ${prepared.promptTokens} tokens 学习窗口上界 ${learned}`);
1444
+ logger?.warn(`dsh-codearts: ${prepared.model} 上游明确报超窗,按本次 prompt 估算 ${prepared.promptTokens} tokens 学习窗口上界 ${learned}`);
1445
+ }
1446
+ if (overflow) {
1447
+ const estimate = prepared.promptTokens > 0 ? `本次 prompt 估算约 ${prepared.promptTokens} tokens,` : "";
1448
+ return {
1449
+ prepared,
1450
+ result: {
1451
+ ok: false,
1452
+ kind: "client",
1453
+ status: 400,
1454
+ message: `${prepared.model}: 上下文放不下 —— ${estimate}max_tokens 已降到 ${MAX_TOKENS_FLOOR} 仍被上游判参数非法。请压缩上下文(/compact)或新建会话;如果目录里的窗口值不准,可在设置里覆盖该模型的 contextWindow。`
1455
+ }
1456
+ };
1420
1457
  }
1421
- const estimate = prepared.promptTokens > 0 ? `本次 prompt 估算约 ${prepared.promptTokens} tokens,` : "";
1458
+ logger?.warn(`dsh-codearts: ${prepared.model} 在 max_tokens 地板仍被判参数非法,但文案不是超窗 —— 按请求体过大处理,不学习窗口上界`);
1422
1459
  return {
1423
1460
  prepared,
1424
1461
  result: {
1425
1462
  ok: false,
1426
1463
  kind: "client",
1427
1464
  status: 400,
1428
- message: `${prepared.model}: 上下文放不下 —— ${estimate}max_tokens 已降到 ${MAX_TOKENS_FLOOR} 仍被上游判参数非法。请压缩上下文(/compact)或新建会话;如果目录里的窗口值不准,可在设置里覆盖该模型的 contextWindow。`
1465
+ message: `${prepared.model}: 上游判定参数非法,但 max_tokens 已降到 ${MAX_TOKENS_FLOOR},报错里也没有超窗口文案 —— 多半是请求体过大(内联图片/附件过多,上游约 10 MB 就拒)。请减少图片或附件后重试;这不是上下文窗口问题,本次没有记录窗口上界。`
1429
1466
  }
1430
1467
  };
1431
1468
  }
@@ -1,4 +1,4 @@
1
- import { d as refreshLockPath, f as withRefreshLock, h as refreshToken, i as codeartsAccountsPath, l as readAccountDocument, m as defaultLoginConfig, p as OAuthTokenError, u as writeJsonAtomic } from "./auth-BaxN0iKC.mjs";
1
+ import { d as refreshLockPath, f as withRefreshLock, h as refreshToken, i as codeartsAccountsPath, l as readAccountDocument, m as defaultLoginConfig, p as OAuthTokenError, u as writeJsonAtomic } from "./auth-D-RmpxN3.mjs";
2
2
  import { _ as writeKeeperState, a as clearKeeperState, c as keeperLogPath, d as keeperStatePath, f as keeperStats, g as writeKeeperHandoff, h as stopRequested, i as clearKeeperHandoff, o as isDshInstallerTempDir, r as KEEPER_TICK_MS, t as KEEPER_HEARTBEAT_MS } from "./keeper-BWHQDFAh.mjs";
3
3
  import { appendFileSync, existsSync, unlinkSync, watch } from "node:fs";
4
4
  import { dirname, join } from "node:path";
@@ -567,6 +567,7 @@ var upstream_exports = /* @__PURE__ */ __exportAll({
567
567
  firstFrameError: () => firstFrameError,
568
568
  isBenefitMissing: () => isBenefitMissing,
569
569
  isConcurrencyCap: () => isConcurrencyCap,
570
+ isContextOverflowText: () => isContextOverflowText,
570
571
  isIamTokenError: () => isIamTokenError,
571
572
  isModelNotAccessible: () => isModelNotAccessible,
572
573
  isNotMultimodal: () => isNotMultimodal,
@@ -697,6 +698,16 @@ function isParamInvalidFrame(text) {
697
698
  return text.includes("InferHub.001001005.400") || text.includes("The request param is invalid");
698
699
  }
699
700
  /**
701
+ * 上游的**真超窗**文案(`input token limit is 1048576`)。
702
+ *
703
+ * `InferHub.001001005.400` 是通用「参数非法」,图片/附件把请求体撑到约 10 MB
704
+ * 也会回它(issue #18)。两者共用错误码,只有超窗这一种才能拿来学窗口上界;
705
+ * 把字节问题当 token 问题上限记下来会把会话永久锁死。
706
+ */
707
+ function isContextOverflowText(text) {
708
+ return /input token limit is\s*\d+/i.test(text);
709
+ }
710
+ /**
700
711
  * 本次进程内学到的上限(小写 id → 上限)。
701
712
  *
702
713
  * 上游会把「实测过」的值悄悄调低(GLM-5.2 的 131072 于 2026-10-10 被收),
@@ -784,8 +795,15 @@ function degradeTokenCeiling(id) {
784
795
  * 上游窗口只会收紧、不会放宽,所以取历史最小值,不被后面更大的估算抬高。
785
796
  */
786
797
  const learnedContextWindow = /* @__PURE__ */ new Map();
787
- /** 该模型学到的真实窗口上界;没学过返回 undefined。 */
798
+ /**
799
+ * 该模型学到的真实窗口上界;没学过返回 undefined。
800
+ *
801
+ * `CODEARTS_IGNORE_LEARNED=1` 是逃生门:旧版把请求体字节超限误学成 token
802
+ * 上界,会话会在本地被永久拦住(issue #18)。置这个环境变量后读取侧忽略
803
+ * 已学值(不清表),重启进程仍有效,用于自救已锁死的会话。
804
+ */
788
805
  function learnedContextWindowFor(id) {
806
+ if (process.env.CODEARTS_IGNORE_LEARNED === "1") return void 0;
789
807
  return learnedContextWindow.get(ceilingKey(id));
790
808
  }
791
809
  /**
@@ -2252,4 +2270,4 @@ async function claimDailyWelfare(credential, signal) {
2252
2270
  };
2253
2271
  }
2254
2272
  //#endregion
2255
- export { withMaxTokensOverride as $, prepareChatBody as A, carryKnownWindows as B, isWelfareClaimedStatus as C, modelUnavailableReasonText as D, maxTokensCeilingFor as E, signedGet as F, isBenefitBlocked as G, creditRatioLabel as H, upstreamErrorMessage as I, mergeModelLists as J, isBenefitModel as K, upstream_exports as L, rateLimitFrame as M, setMaxTokenOverride as N, overrideValueFor as O, setMaxTokenOverrides as P, withContextWindowOverride as Q, CodeArtsCatalog as R, isTpmLimit as S, learnedContextWindowFor as T, filterEnabledModels as U, clearBenefitBlocked as V, forgetModelUnavailable as W, modelUnavailableReason as X, modelDisplayName as Y, setDiscoveredBenefitModels as Z, isNotMultimodal as _, claimDailyWelfare as a, isQueueRejectText as b, degradeTokenCeiling as c, fetchQueueStatus as d, fetchWelfareCampaigns as f, isModelNotAccessible as g, isIamTokenError as h, chatStream as i, queueFrame as j, pickDailyWelfareCampaign as k, fetchCallerIdentity as l, isConcurrencyCap as m, SNAP_HOST as n, clearQueueStatus as o, firstFrameError as p, markModelUnavailable as q, canonicalModel as r, contextWindowOverrideFor as s, MAX_TOKENS_FLOOR as t, fetchModels as u, isParamInvalidFrame as v, learnContextWindow as w, isQueueableRate as x, isQueueReject as y, FALLBACK_CODEARTS_MODELS as z };
2273
+ export { withContextWindowOverride as $, pickDailyWelfareCampaign as A, FALLBACK_CODEARTS_MODELS as B, isTpmLimit as C, maxTokensCeilingFor as D, learnedContextWindowFor as E, setMaxTokenOverrides as F, forgetModelUnavailable as G, clearBenefitBlocked as H, signedGet as I, markModelUnavailable as J, isBenefitBlocked as K, upstreamErrorMessage as L, queueFrame as M, rateLimitFrame as N, modelUnavailableReasonText as O, setMaxTokenOverride as P, setDiscoveredBenefitModels as Q, upstream_exports as R, isQueueableRate as S, learnContextWindow as T, creditRatioLabel as U, carryKnownWindows as V, filterEnabledModels as W, modelDisplayName as X, mergeModelLists as Y, modelUnavailableReason as Z, isModelNotAccessible as _, claimDailyWelfare as a, isQueueReject as b, degradeTokenCeiling as c, fetchQueueStatus as d, withMaxTokensOverride as et, fetchWelfareCampaigns as f, isIamTokenError as g, isContextOverflowText as h, chatStream as i, prepareChatBody as j, overrideValueFor as k, fetchCallerIdentity as l, isConcurrencyCap as m, SNAP_HOST as n, clearQueueStatus as o, firstFrameError as p, isBenefitModel as q, canonicalModel as r, contextWindowOverrideFor as s, MAX_TOKENS_FLOOR as t, fetchModels as u, isNotMultimodal as v, isWelfareClaimedStatus as w, isQueueRejectText as x, isParamInvalidFrame as y, CodeArtsCatalog as z };
@@ -1,5 +1,5 @@
1
- import { u as writeJsonAtomic } from "./auth-BaxN0iKC.mjs";
2
- import { B as carryKnownWindows, J as mergeModelLists, K as isBenefitModel, Y as modelDisplayName, Z as setDiscoveredBenefitModels, u as fetchModels } from "./upstream-BX6-klXI.mjs";
1
+ import { u as writeJsonAtomic } from "./auth-D-RmpxN3.mjs";
2
+ import { Q as setDiscoveredBenefitModels, V as carryKnownWindows, X as modelDisplayName, Y as mergeModelLists, q as isBenefitModel, u as fetchModels } from "./upstream-DeRNnZdN.mjs";
3
3
  import { existsSync } from "node:fs";
4
4
  import { readFile } from "node:fs/promises";
5
5
  import { homedir } from "node:os";
@@ -536,6 +536,6 @@ function percentileOf(buckets, ratio) {
536
536
  }
537
537
  //#endregion
538
538
  //#region src/version.ts
539
- const CODEARTS_VERSION = "1.4.11";
539
+ const CODEARTS_VERSION = "1.4.13";
540
540
  //#endregion
541
541
  export { refreshCatalog as a, discoverModels as i, CodeArtsUsageTracker as n, codeartsUsagePath as r, CODEARTS_VERSION as t };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "dsh-codearts",
3
3
  "displayName": "DSH CodeArts Connect",
4
4
  "description": "把华为云 CodeArts 接入 DeepSeek Harness —— 内置 OAuth2 登录(PKCE + DPoP),登录后即可在 DSH 对话窗口使用 CodeArts 的模型。",
5
- "version": "1.4.11",
5
+ "version": "1.4.13",
6
6
  "packageManager": "pnpm@11.24.0",
7
7
  "author": "elegant01",
8
8
  "keywords": [