dsh-codearts 1.4.15 → 1.4.16
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 +17 -0
- package/lib/{auth-qnSuuDGW.mjs → auth-T5qnGSPp.mjs} +1 -1
- package/lib/bin.mjs +3 -3
- package/lib/client/index.js +112 -112
- package/lib/index.d.mts +1 -1
- package/lib/index.mjs +41 -5
- package/lib/keeper-main.mjs +1 -1
- package/lib/{upstream-D1NN-sbL.mjs → upstream-Cr5tUI75.mjs} +18 -0
- package/lib/{version-BJniJ4eN.mjs → version-CxhGukAi.mjs} +3 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,23 @@
|
|
|
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.16] - 2026-11-30
|
|
7
|
+
|
|
8
|
+
### 优化
|
|
9
|
+
|
|
10
|
+
- **5xx 冷却单独取短值、连续失败递增**(#22 辅建议):上游 5xx 多为瞬时抖动,
|
|
11
|
+
首次只冷却 4 秒,连续 5xx 按倍数递增、封顶到软限流的 30 秒;软限流与 IAM
|
|
12
|
+
失效仍保持 30 秒,任何非 5xx 结果清零连续计数。内联等待落地后冷却时长就是
|
|
13
|
+
用户实打实的等待,缩短 5xx 冷却可直接省掉白等的时间。
|
|
14
|
+
|
|
15
|
+
### 修复
|
|
16
|
+
|
|
17
|
+
- **API 网关限流(APIG.0308)单独冷却、报文改中文**(#22 后续):上游 API 网关
|
|
18
|
+
的 429(`policy user over ratelimit, limit:100, time:1 minute`)以前与后端软
|
|
19
|
+
限流共用 30 秒冷却,短于网关 1 分钟窗口,可能「解冻即再撞」。现在本地识别该
|
|
20
|
+
错误码与措辞,冷却 65 秒盖过窗口,报文给出中文说明,不再透传网关英文原文。
|
|
21
|
+
纯本地退避,不涉及任何上游操作。
|
|
22
|
+
|
|
6
23
|
## [1.4.15] - 2026-11-27
|
|
7
24
|
|
|
8
25
|
### 修复
|
|
@@ -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-
|
|
587
|
+
const { claimBenefit } = await import("./upstream-Cr5tUI75.mjs").then((n) => n.z);
|
|
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-
|
|
3
|
-
import { J as isBenefitModel, l as fetchCallerIdentity } from "./upstream-
|
|
4
|
-
import { i as discoverModels, n as CodeArtsUsageTracker, r as codeartsUsagePath, t as CODEARTS_VERSION } from "./version-
|
|
2
|
+
import { i as codeartsAccountsPath, t as CodeArtsAccountStore } from "./auth-T5qnGSPp.mjs";
|
|
3
|
+
import { J as isBenefitModel, l as fetchCallerIdentity } from "./upstream-Cr5tUI75.mjs";
|
|
4
|
+
import { i as discoverModels, n as CodeArtsUsageTracker, r as codeartsUsagePath, t as CODEARTS_VERSION } from "./version-CxhGukAi.mjs";
|
|
5
5
|
import { existsSync, statSync } from "node:fs";
|
|
6
6
|
//#region src/bin.ts
|
|
7
7
|
/**
|
package/lib/client/index.js
CHANGED
|
@@ -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
|
-
"
|
|
198
|
-
"
|
|
199
|
-
"
|
|
200
|
-
"
|
|
201
|
-
"
|
|
197
|
+
"hint": "xoziZG_hint",
|
|
198
|
+
"creditBlock": "xoziZG_creditBlock",
|
|
199
|
+
"windowButtonSet": "xoziZG_windowButtonSet",
|
|
200
|
+
"creditLink": "xoziZG_creditLink",
|
|
201
|
+
"headText": "xoziZG_headText",
|
|
202
|
+
"groupHeadFirst": "xoziZG_groupHeadFirst",
|
|
203
|
+
"sectionHead": "xoziZG_sectionHead",
|
|
204
|
+
"balanceUnit": "xoziZG_balanceUnit",
|
|
205
|
+
"link": "xoziZG_link",
|
|
206
|
+
"heatCell": "xoziZG_heatCell",
|
|
207
|
+
"skeletonBreath": "xoziZG_skeletonBreath",
|
|
208
|
+
"concurrencyStepper": "xoziZG_concurrencyStepper",
|
|
209
|
+
"modelTokens": "xoziZG_modelTokens",
|
|
210
|
+
"windowPopoverHead": "xoziZG_windowPopoverHead",
|
|
211
|
+
"statCard": "xoziZG_statCard",
|
|
212
|
+
"skeleton": "xoziZG_skeleton",
|
|
213
|
+
"modelSpec": "xoziZG_modelSpec",
|
|
214
|
+
"accountToggle": "xoziZG_accountToggle",
|
|
202
215
|
"manualForm": "xoziZG_manualForm",
|
|
203
|
-
"
|
|
216
|
+
"windowInput": "xoziZG_windowInput",
|
|
217
|
+
"usageTipName": "xoziZG_usageTipName",
|
|
218
|
+
"fieldLabel": "xoziZG_fieldLabel",
|
|
219
|
+
"windowPopoverValue": "xoziZG_windowPopoverValue",
|
|
220
|
+
"modelCheck": "xoziZG_modelCheck",
|
|
221
|
+
"balance": "xoziZG_balance",
|
|
222
|
+
"windowRange": "xoziZG_windowRange",
|
|
204
223
|
"sectionLabel": "xoziZG_sectionLabel",
|
|
224
|
+
"danger": "xoziZG_danger",
|
|
225
|
+
"barFill": "xoziZG_barFill",
|
|
205
226
|
"creditFooter": "xoziZG_creditFooter",
|
|
206
|
-
"
|
|
207
|
-
"
|
|
208
|
-
"
|
|
227
|
+
"modelChart": "xoziZG_modelChart",
|
|
228
|
+
"heatAxis": "xoziZG_heatAxis",
|
|
229
|
+
"error": "xoziZG_error",
|
|
230
|
+
"header": "xoziZG_header",
|
|
231
|
+
"windowPopoverRow": "xoziZG_windowPopoverRow",
|
|
232
|
+
"trendTip": "xoziZG_trendTip",
|
|
233
|
+
"accountInfo": "xoziZG_accountInfo",
|
|
234
|
+
"heatAxisSlot": "xoziZG_heatAxisSlot",
|
|
235
|
+
"body": "xoziZG_body",
|
|
236
|
+
"tabPanel": "xoziZG_tabPanel",
|
|
237
|
+
"accountMenu": "xoziZG_accountMenu",
|
|
238
|
+
"expiryRow": "xoziZG_expiryRow",
|
|
239
|
+
"concurrencyButton": "xoziZG_concurrencyButton",
|
|
240
|
+
"area": "xoziZG_area",
|
|
241
|
+
"accountConcurrencyInline": "xoziZG_accountConcurrencyInline",
|
|
209
242
|
"accountRowActions": "xoziZG_accountRowActions",
|
|
210
|
-
"
|
|
211
|
-
"
|
|
243
|
+
"usageTip": "xoziZG_usageTip",
|
|
244
|
+
"claimAllRow": "xoziZG_claimAllRow",
|
|
245
|
+
"name": "xoziZG_name",
|
|
212
246
|
"bar": "xoziZG_bar",
|
|
213
|
-
"
|
|
214
|
-
"
|
|
215
|
-
"
|
|
216
|
-
"
|
|
247
|
+
"expiryLabel": "xoziZG_expiryLabel",
|
|
248
|
+
"choiceTail": "xoziZG_choiceTail",
|
|
249
|
+
"accountToolbar": "xoziZG_accountToolbar",
|
|
250
|
+
"windowButton": "xoziZG_windowButton",
|
|
251
|
+
"windowSection": "xoziZG_windowSection",
|
|
252
|
+
"check": "xoziZG_check",
|
|
253
|
+
"accountClearHint": "xoziZG_accountClearHint",
|
|
254
|
+
"accountCard": "xoziZG_accountCard",
|
|
255
|
+
"choices": "xoziZG_choices",
|
|
256
|
+
"windowInputSet": "xoziZG_windowInputSet",
|
|
257
|
+
"windowAnchor": "xoziZG_windowAnchor",
|
|
258
|
+
"accountEntry": "xoziZG_accountEntry",
|
|
259
|
+
"heatLegend": "xoziZG_heatLegend",
|
|
260
|
+
"creditRow": "xoziZG_creditRow",
|
|
261
|
+
"modelTrack": "xoziZG_modelTrack",
|
|
262
|
+
"manualSummary": "xoziZG_manualSummary",
|
|
263
|
+
"statusLine": "xoziZG_statusLine",
|
|
264
|
+
"heatLegendChip": "xoziZG_heatLegendChip",
|
|
217
265
|
"accountName": "xoziZG_accountName",
|
|
218
266
|
"choiceRow": "xoziZG_choiceRow",
|
|
219
|
-
"
|
|
220
|
-
"usageTipSep": "xoziZG_usageTipSep",
|
|
221
|
-
"concurrencyButton": "xoziZG_concurrencyButton",
|
|
222
|
-
"accountInfo": "xoziZG_accountInfo",
|
|
223
|
-
"windowAnchor": "xoziZG_windowAnchor",
|
|
224
|
-
"fieldLabel": "xoziZG_fieldLabel",
|
|
225
|
-
"statSub": "xoziZG_statSub",
|
|
267
|
+
"balanceRow": "xoziZG_balanceRow",
|
|
226
268
|
"usageTipRow": "xoziZG_usageTipRow",
|
|
227
|
-
"
|
|
228
|
-
"groupLabel": "xoziZG_groupLabel",
|
|
229
|
-
"concurrencyValue": "xoziZG_concurrencyValue",
|
|
230
|
-
"skeletonRow": "xoziZG_skeletonRow",
|
|
269
|
+
"balanceMeta": "xoziZG_balanceMeta",
|
|
231
270
|
"statLabel": "xoziZG_statLabel",
|
|
232
|
-
"
|
|
233
|
-
"
|
|
234
|
-
"
|
|
235
|
-
"
|
|
236
|
-
"
|
|
237
|
-
"accountGrid": "xoziZG_accountGrid",
|
|
238
|
-
"groupHeadFirst": "xoziZG_groupHeadFirst",
|
|
271
|
+
"usageFill": "xoziZG_usageFill",
|
|
272
|
+
"accountMenuAnchor": "xoziZG_accountMenuAnchor",
|
|
273
|
+
"accountClear": "xoziZG_accountClear",
|
|
274
|
+
"windowUnit": "xoziZG_windowUnit",
|
|
275
|
+
"heatHourCell": "xoziZG_heatHourCell",
|
|
239
276
|
"field": "xoziZG_field",
|
|
240
|
-
"barFill": "xoziZG_barFill",
|
|
241
|
-
"skeleton": "xoziZG_skeleton",
|
|
242
|
-
"manual": "xoziZG_manual",
|
|
243
|
-
"heatAxisSlot": "xoziZG_heatAxisSlot",
|
|
244
|
-
"accountMenuItem": "xoziZG_accountMenuItem",
|
|
245
|
-
"windowPopoverRow": "xoziZG_windowPopoverRow",
|
|
246
|
-
"windowButtonOpen": "xoziZG_windowButtonOpen",
|
|
247
|
-
"expiryRow": "xoziZG_expiryRow",
|
|
248
|
-
"skeletonBreath": "xoziZG_skeletonBreath",
|
|
249
|
-
"creditHint": "xoziZG_creditHint",
|
|
250
|
-
"creditRows": "xoziZG_creditRows",
|
|
251
|
-
"heatWeekday": "xoziZG_heatWeekday",
|
|
252
|
-
"modelChart": "xoziZG_modelChart",
|
|
253
277
|
"windowHint": "xoziZG_windowHint",
|
|
254
|
-
"hint": "xoziZG_hint",
|
|
255
|
-
"trendTip": "xoziZG_trendTip",
|
|
256
|
-
"windowSection": "xoziZG_windowSection",
|
|
257
|
-
"modelMeta": "xoziZG_modelMeta",
|
|
258
|
-
"choiceTail": "xoziZG_choiceTail",
|
|
259
|
-
"modelRequests": "xoziZG_modelRequests",
|
|
260
|
-
"accountMenuAnchor": "xoziZG_accountMenuAnchor",
|
|
261
|
-
"balanceRow": "xoziZG_balanceRow",
|
|
262
|
-
"modelTrack": "xoziZG_modelTrack",
|
|
263
|
-
"accountConcurrencyInline": "xoziZG_accountConcurrencyInline",
|
|
264
|
-
"creditRow": "xoziZG_creditRow",
|
|
265
278
|
"tabs": "xoziZG_tabs",
|
|
266
|
-
"body": "xoziZG_body",
|
|
267
|
-
"header": "xoziZG_header",
|
|
268
|
-
"accountEntry": "xoziZG_accountEntry",
|
|
269
|
-
"accountToolbar": "xoziZG_accountToolbar",
|
|
270
|
-
"accountToggle": "xoziZG_accountToggle",
|
|
271
|
-
"accountClearHint": "xoziZG_accountClearHint",
|
|
272
|
-
"section": "xoziZG_section",
|
|
273
|
-
"check": "xoziZG_check",
|
|
274
|
-
"meta": "xoziZG_meta",
|
|
275
|
-
"doctorList": "xoziZG_doctorList",
|
|
276
|
-
"card": "xoziZG_card",
|
|
277
|
-
"heatCell": "xoziZG_heatCell",
|
|
278
|
-
"windowInput": "xoziZG_windowInput",
|
|
279
|
-
"windowButton": "xoziZG_windowButton",
|
|
280
|
-
"count": "xoziZG_count",
|
|
281
|
-
"windowPopover": "xoziZG_windowPopover",
|
|
282
|
-
"link": "xoziZG_link",
|
|
283
279
|
"avatar": "xoziZG_avatar",
|
|
284
|
-
"
|
|
285
|
-
"
|
|
286
|
-
"accountConcurrencyLabel": "xoziZG_accountConcurrencyLabel",
|
|
280
|
+
"doctorRow": "xoziZG_doctorRow",
|
|
281
|
+
"statValue": "xoziZG_statValue",
|
|
287
282
|
"modelName": "xoziZG_modelName",
|
|
288
|
-
"
|
|
289
|
-
"
|
|
290
|
-
"
|
|
291
|
-
"
|
|
292
|
-
"
|
|
293
|
-
"accountCard": "xoziZG_accountCard",
|
|
294
|
-
"accountNameRow": "xoziZG_accountNameRow",
|
|
295
|
-
"statCard": "xoziZG_statCard",
|
|
296
|
-
"claimAllRow": "xoziZG_claimAllRow",
|
|
297
|
-
"heatAxis": "xoziZG_heatAxis",
|
|
298
|
-
"usageFill": "xoziZG_usageFill",
|
|
299
|
-
"modelCheck": "xoziZG_modelCheck",
|
|
300
|
-
"error": "xoziZG_error",
|
|
301
|
-
"modelShare": "xoziZG_modelShare",
|
|
302
|
-
"sectionHead": "xoziZG_sectionHead",
|
|
303
|
-
"windowCaret": "xoziZG_windowCaret",
|
|
304
|
-
"accountMenu": "xoziZG_accountMenu",
|
|
305
|
-
"headText": "xoziZG_headText",
|
|
306
|
-
"creditBlock": "xoziZG_creditBlock",
|
|
307
|
-
"balanceUnit": "xoziZG_balanceUnit",
|
|
308
|
-
"manualSummary": "xoziZG_manualSummary",
|
|
283
|
+
"manual": "xoziZG_manual",
|
|
284
|
+
"heatGrid": "xoziZG_heatGrid",
|
|
285
|
+
"updated": "xoziZG_updated",
|
|
286
|
+
"creditHint": "xoziZG_creditHint",
|
|
287
|
+
"section": "xoziZG_section",
|
|
309
288
|
"accountRow": "xoziZG_accountRow",
|
|
310
|
-
"choices": "xoziZG_choices",
|
|
311
|
-
"modelTokens": "xoziZG_modelTokens",
|
|
312
|
-
"windowPopoverHead": "xoziZG_windowPopoverHead",
|
|
313
|
-
"doctorRow": "xoziZG_doctorRow",
|
|
314
|
-
"usageTip": "xoziZG_usageTip",
|
|
315
|
-
"windowInputSet": "xoziZG_windowInputSet",
|
|
316
|
-
"danger": "xoziZG_danger",
|
|
317
|
-
"accountClear": "xoziZG_accountClear",
|
|
318
289
|
"heatHours": "xoziZG_heatHours",
|
|
319
|
-
"
|
|
290
|
+
"groupLabel": "xoziZG_groupLabel",
|
|
291
|
+
"creditRows": "xoziZG_creditRows",
|
|
292
|
+
"windowPopover": "xoziZG_windowPopover",
|
|
293
|
+
"concurrencyValue": "xoziZG_concurrencyValue",
|
|
294
|
+
"count": "xoziZG_count",
|
|
295
|
+
"modelFill": "xoziZG_modelFill",
|
|
296
|
+
"desc": "xoziZG_desc",
|
|
297
|
+
"actions": "xoziZG_actions",
|
|
298
|
+
"windowCaret": "xoziZG_windowCaret",
|
|
299
|
+
"doctorList": "xoziZG_doctorList",
|
|
300
|
+
"modelShare": "xoziZG_modelShare",
|
|
301
|
+
"statGrid": "xoziZG_statGrid",
|
|
302
|
+
"doctorName": "xoziZG_doctorName",
|
|
303
|
+
"windowButtonOpen": "xoziZG_windowButtonOpen",
|
|
304
|
+
"accountGrid": "xoziZG_accountGrid",
|
|
305
|
+
"card": "xoziZG_card",
|
|
306
|
+
"modelMeta": "xoziZG_modelMeta",
|
|
307
|
+
"usageBar": "xoziZG_usageBar",
|
|
308
|
+
"heatWeekday": "xoziZG_heatWeekday",
|
|
309
|
+
"modelRow": "xoziZG_modelRow",
|
|
310
|
+
"modelRequests": "xoziZG_modelRequests",
|
|
311
|
+
"accountMenuItem": "xoziZG_accountMenuItem",
|
|
312
|
+
"skeletonRow": "xoziZG_skeletonRow",
|
|
313
|
+
"groupHead": "xoziZG_groupHead",
|
|
314
|
+
"accountConcurrencyLabel": "xoziZG_accountConcurrencyLabel",
|
|
315
|
+
"usageTipSep": "xoziZG_usageTipSep",
|
|
316
|
+
"accountHint": "xoziZG_accountHint",
|
|
317
|
+
"meta": "xoziZG_meta",
|
|
318
|
+
"statSub": "xoziZG_statSub",
|
|
319
|
+
"accountNameRow": "xoziZG_accountNameRow"
|
|
320
320
|
};
|
|
321
321
|
//#endregion
|
|
322
322
|
//#region src/client/CodeArtsPluginCard.tsx
|
|
@@ -3648,14 +3648,14 @@ if (typeof document !== "undefined" && document.querySelector("style[data-plugin
|
|
|
3648
3648
|
document.head.appendChild(tag);
|
|
3649
3649
|
}
|
|
3650
3650
|
var CodeArtsPanel_module_css_default = {
|
|
3651
|
-
"title": "Z66cgG_title",
|
|
3652
|
-
"head": "Z66cgG_head",
|
|
3653
|
-
"backCaret": "Z66cgG_backCaret",
|
|
3654
|
-
"back": "Z66cgG_back",
|
|
3655
3651
|
"body": "Z66cgG_body",
|
|
3656
3652
|
"icon": "Z66cgG_icon",
|
|
3653
|
+
"backCaret": "Z66cgG_backCaret",
|
|
3654
|
+
"title": "Z66cgG_title",
|
|
3657
3655
|
"desc": "Z66cgG_desc",
|
|
3658
|
-
"
|
|
3656
|
+
"back": "Z66cgG_back",
|
|
3657
|
+
"page": "Z66cgG_page",
|
|
3658
|
+
"head": "Z66cgG_head"
|
|
3659
3659
|
};
|
|
3660
3660
|
//#endregion
|
|
3661
3661
|
//#region src/client/CodeArtsPanel.tsx
|
package/lib/index.d.mts
CHANGED
|
@@ -896,7 +896,7 @@ interface OAuthToken {
|
|
|
896
896
|
//#endregion
|
|
897
897
|
//#region src/upstream.d.ts
|
|
898
898
|
declare const SNAP_HOST = "https://snap-access.cn-north-4.myhuaweicloud.com";
|
|
899
|
-
type UpstreamErrorKind = 'hard_credit' | 'soft_rate' | 'session_dead' | 'iam_stale' | 'not_found' | 'server' | 'client';
|
|
899
|
+
type UpstreamErrorKind = 'hard_credit' | 'soft_rate' | 'gate_rate' | 'session_dead' | 'iam_stale' | 'not_found' | 'server' | 'client';
|
|
900
900
|
interface ChatResultOk {
|
|
901
901
|
ok: true;
|
|
902
902
|
/** 已转成 OpenAI 增量 SSE 的 ReadableStream(文本,data: ...\n\n)。 */
|
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-
|
|
2
|
-
import { A as overrideValueFor, B as CodeArtsCatalog, C as isQueueableRate, D as learnedContextWindowFor, E as learnContextWindow, F as setMaxTokenOverride, G as filterEnabledModels, I as setMaxTokenOverrides, J as isBenefitModel, K as forgetModelUnavailable, L as signedGet, M as prepareChatBody, N as queueFrame, O as maxTokensCeilingFor, P as rateLimitFrame, Q as modelUnavailableReason, R as upstreamErrorMessage, S as isQueueRejectText, T as isWelfareClaimedStatus, U as clearBenefitBlocked, V as FALLBACK_CODEARTS_MODELS, W as creditRatioLabel, Y as markModelUnavailable, _ as isIamTokenError, a as claimDailyWelfare, b as isParamInvalidFrame, c as degradeTokenCeiling, d as fetchQueueStatus, et as withContextWindowOverride, f as fetchWelfareCampaigns, g as isCreditExhausted, h as isContextOverflowText, i as chatStream, j as pickDailyWelfareCampaign, k as modelUnavailableReasonText, l as fetchCallerIdentity, m as isConcurrencyCap, n as SNAP_HOST, o as clearQueueStatus, p as firstFrameError, q as isBenefitBlocked, r as canonicalModel, s as contextWindowOverrideFor, t as MAX_TOKENS_FLOOR, tt as withMaxTokensOverride, u as fetchModels, v as isModelNotAccessible, w as isTpmLimit, x as isQueueReject, y as isNotMultimodal } from "./upstream-
|
|
3
|
-
import { a as refreshCatalog, i as discoverModels, n as CodeArtsUsageTracker, r as codeartsUsagePath, t as CODEARTS_VERSION } from "./version-
|
|
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-T5qnGSPp.mjs";
|
|
2
|
+
import { A as overrideValueFor, B as CodeArtsCatalog, C as isQueueableRate, D as learnedContextWindowFor, E as learnContextWindow, F as setMaxTokenOverride, G as filterEnabledModels, I as setMaxTokenOverrides, J as isBenefitModel, K as forgetModelUnavailable, L as signedGet, M as prepareChatBody, N as queueFrame, O as maxTokensCeilingFor, P as rateLimitFrame, Q as modelUnavailableReason, R as upstreamErrorMessage, S as isQueueRejectText, T as isWelfareClaimedStatus, U as clearBenefitBlocked, V as FALLBACK_CODEARTS_MODELS, W as creditRatioLabel, Y as markModelUnavailable, _ as isIamTokenError, a as claimDailyWelfare, b as isParamInvalidFrame, c as degradeTokenCeiling, d as fetchQueueStatus, et as withContextWindowOverride, f as fetchWelfareCampaigns, g as isCreditExhausted, h as isContextOverflowText, i as chatStream, j as pickDailyWelfareCampaign, k as modelUnavailableReasonText, l as fetchCallerIdentity, m as isConcurrencyCap, n as SNAP_HOST, o as clearQueueStatus, p as firstFrameError, q as isBenefitBlocked, r as canonicalModel, s as contextWindowOverrideFor, t as MAX_TOKENS_FLOOR, tt as withMaxTokensOverride, u as fetchModels, v as isModelNotAccessible, w as isTpmLimit, x as isQueueReject, y as isNotMultimodal } from "./upstream-Cr5tUI75.mjs";
|
|
3
|
+
import { a as refreshCatalog, i as discoverModels, n as CodeArtsUsageTracker, r as codeartsUsagePath, t as CODEARTS_VERSION } from "./version-CxhGukAi.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";
|
|
@@ -1156,6 +1156,7 @@ const REQUEST_BODY_LIMIT = 67108864;
|
|
|
1156
1156
|
const KIND_STATUS = {
|
|
1157
1157
|
hard_credit: 402,
|
|
1158
1158
|
soft_rate: 429,
|
|
1159
|
+
gate_rate: 429,
|
|
1159
1160
|
session_dead: 401,
|
|
1160
1161
|
iam_stale: 401,
|
|
1161
1162
|
not_found: 502,
|
|
@@ -1288,8 +1289,22 @@ const QUEUE_RETRY_GAP = 5e3;
|
|
|
1288
1289
|
const QUEUE_WAIT_LIMIT_MS = 9e5;
|
|
1289
1290
|
/** 空帧间隔:宿主按「可解析的流事件」算 90 秒空闲,20 秒留足余量。 */
|
|
1290
1291
|
const QUEUE_HEARTBEAT_MS = 2e4;
|
|
1291
|
-
/**
|
|
1292
|
+
/**
|
|
1293
|
+
* 软限流的冷却:上游实测真的会拒约 30 秒、且无 Retry-After 头(issue #22)。
|
|
1294
|
+
* 这是上游的罚站时长,不动。
|
|
1295
|
+
*/
|
|
1292
1296
|
const SERVER_COOLDOWN_MS = 3e4;
|
|
1297
|
+
/**
|
|
1298
|
+
* 上游 5xx 的首次冷却:5xx 多为瞬时抖动,几秒即恢复。借用软限流的 30 秒属于
|
|
1299
|
+
* 保守误伤 —— 内联等待落地后,冷却时长就是用户实打实的等待(issue #22)。
|
|
1300
|
+
* 连续 5xx 按倍数递增、封顶到 SERVER_COOLDOWN_MS,避免持续故障被短冷却连打。
|
|
1301
|
+
*/
|
|
1302
|
+
const SERVER_5XX_COOLDOWN_MS = 4e3;
|
|
1303
|
+
/**
|
|
1304
|
+
* API 网关限流(APIG.0308)的冷却:官方窗口是 1 分钟,必须长于它才能让下次请求
|
|
1305
|
+
* 落在窗口外。65 秒留出边界抖动余量(issue #22 后续,纯本地退避)。
|
|
1306
|
+
*/
|
|
1307
|
+
const GATEWAY_COOLDOWN_MS = 65e3;
|
|
1293
1308
|
/** 零散错误累计到阈值后冷却该账号。 */
|
|
1294
1309
|
const ERROR_COOLDOWN_MS = 6e4;
|
|
1295
1310
|
/**
|
|
@@ -1345,6 +1360,11 @@ function createCodeArtsShim(options) {
|
|
|
1345
1360
|
const localSlotWaitBudgetMs = options.localSlotWaitMs ?? 3e4;
|
|
1346
1361
|
const queueRetryGapMs = options.queueRetryGapMs ?? QUEUE_RETRY_GAP;
|
|
1347
1362
|
const pool = options.pool ?? new CodeArtsAccountPool([]);
|
|
1363
|
+
/**
|
|
1364
|
+
* 连续 5xx 次数(按账号):5xx 冷却按 4s 起翻倍递增、封顶 30s(issue #22 辅建议)。
|
|
1365
|
+
* 跨请求保留,任何非 5xx 结果(成功、软限流、客户端错误)清零。
|
|
1366
|
+
*/
|
|
1367
|
+
const serverStreaks = /* @__PURE__ */ new Map();
|
|
1348
1368
|
const SHARED_SECRET = randomBytes(32).toString("base64url");
|
|
1349
1369
|
function bearerOk(req) {
|
|
1350
1370
|
const header = req.headers.authorization;
|
|
@@ -1699,6 +1719,7 @@ function createCodeArtsShim(options) {
|
|
|
1699
1719
|
}
|
|
1700
1720
|
if (result.ok) {
|
|
1701
1721
|
pool.noteSuccess(id);
|
|
1722
|
+
serverStreaks.delete(id);
|
|
1702
1723
|
await pipeToResponse(res, result.stream, controller.signal, {
|
|
1703
1724
|
accountId: id,
|
|
1704
1725
|
model: prepared.model,
|
|
@@ -1710,6 +1731,7 @@ function createCodeArtsShim(options) {
|
|
|
1710
1731
|
lastAccountId = id;
|
|
1711
1732
|
lastStatus = result.status;
|
|
1712
1733
|
lastMessage = result.message;
|
|
1734
|
+
if (result.kind !== "server") serverStreaks.delete(id);
|
|
1713
1735
|
if (isConcurrencyCap(result)) {
|
|
1714
1736
|
pool.noteConcurrencyCap(id);
|
|
1715
1737
|
cappedAccount = id;
|
|
@@ -1743,7 +1765,19 @@ function createCodeArtsShim(options) {
|
|
|
1743
1765
|
pool.cooldown(id, CREDIT_COOLDOWN_MS, "该账号积分已耗尽(TM.00001050),额度刷新或领取积分后恢复");
|
|
1744
1766
|
continue;
|
|
1745
1767
|
}
|
|
1746
|
-
if (result.kind === "server"
|
|
1768
|
+
if (result.kind === "server") {
|
|
1769
|
+
const streak = (serverStreaks.get(id) ?? 0) + 1;
|
|
1770
|
+
serverStreaks.set(id, streak);
|
|
1771
|
+
const cooldownMs = Math.min(SERVER_COOLDOWN_MS, SERVER_5XX_COOLDOWN_MS * 2 ** Math.min(streak - 1, 10));
|
|
1772
|
+
pool.cooldown(id, cooldownMs, result.message);
|
|
1773
|
+
debug?.(`server 5xx cooldown account=${id} streak=${streak} ms=${cooldownMs}`);
|
|
1774
|
+
break;
|
|
1775
|
+
}
|
|
1776
|
+
if (result.kind === "gate_rate") {
|
|
1777
|
+
pool.cooldown(id, GATEWAY_COOLDOWN_MS, result.message);
|
|
1778
|
+
break;
|
|
1779
|
+
}
|
|
1780
|
+
if (result.kind === "soft_rate") {
|
|
1747
1781
|
pool.cooldown(id, SERVER_COOLDOWN_MS, result.message);
|
|
1748
1782
|
break;
|
|
1749
1783
|
}
|
|
@@ -1797,6 +1831,7 @@ function createCodeArtsShim(options) {
|
|
|
1797
1831
|
if (result.ok) {
|
|
1798
1832
|
pool.noteCapRelease(queueAccount);
|
|
1799
1833
|
pool.noteSuccess(queueAccount);
|
|
1834
|
+
serverStreaks.delete(queueAccount);
|
|
1800
1835
|
await pipeToResponse(res, result.stream, controller.signal, {
|
|
1801
1836
|
accountId: queueAccount,
|
|
1802
1837
|
model: opened.prepared.model,
|
|
@@ -1865,6 +1900,7 @@ function createCodeArtsShim(options) {
|
|
|
1865
1900
|
}
|
|
1866
1901
|
if (opened.result.ok) {
|
|
1867
1902
|
pool.noteSuccess(id);
|
|
1903
|
+
serverStreaks.delete(id);
|
|
1868
1904
|
await pipeToResponse(res, opened.result.stream, controller.signal, {
|
|
1869
1905
|
accountId: id,
|
|
1870
1906
|
model: opened.prepared.model,
|
package/lib/keeper-main.mjs
CHANGED
|
@@ -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-
|
|
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-T5qnGSPp.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";
|
|
@@ -549,6 +549,7 @@ var upstream_exports = /* @__PURE__ */ __exportAll({
|
|
|
549
549
|
BENEFIT_MISSING_CODE: () => BENEFIT_MISSING_CODE,
|
|
550
550
|
CONCURRENCY_CAP_CODE: () => CONCURRENCY_CAP_CODE,
|
|
551
551
|
CREDIT_EXHAUSTED_CODE: () => CREDIT_EXHAUSTED_CODE,
|
|
552
|
+
GATEWAY_THROTTLE_CODE: () => GATEWAY_THROTTLE_CODE,
|
|
552
553
|
MAX_TOKENS_CEILING: () => MAX_TOKENS_CEILING,
|
|
553
554
|
MAX_TOKENS_FLOOR: () => MAX_TOKENS_FLOOR,
|
|
554
555
|
PARAM_INVALID_CODE: () => PARAM_INVALID_CODE,
|
|
@@ -573,6 +574,7 @@ var upstream_exports = /* @__PURE__ */ __exportAll({
|
|
|
573
574
|
isConcurrencyCap: () => isConcurrencyCap,
|
|
574
575
|
isContextOverflowText: () => isContextOverflowText,
|
|
575
576
|
isCreditExhausted: () => isCreditExhausted,
|
|
577
|
+
isGatewayThrottle: () => isGatewayThrottle,
|
|
576
578
|
isIamTokenError: () => isIamTokenError,
|
|
577
579
|
isModelNotAccessible: () => isModelNotAccessible,
|
|
578
580
|
isNotMultimodal: () => isNotMultimodal,
|
|
@@ -1255,9 +1257,24 @@ function upstreamErrorMessage(message, status = 0) {
|
|
|
1255
1257
|
if (isModelNotAccessible(message)) return "上游说这个模型不存在或当前账号没有权限(可能已下线或改名)。请刷新模型列表后换一个模型;换号没有用,这是模型级的限制。";
|
|
1256
1258
|
if (isNotMultimodal(message)) return "这个模型不支持图片输入(上游 406)。请移除消息里的图片,或改用支持识图的模型。";
|
|
1257
1259
|
if (message.toLowerCase().includes("model is not registered")) return "上游没有注册这个模型,它可能已经下线;请刷新模型列表后重选。";
|
|
1260
|
+
if (isGatewayThrottle(message)) return "上游 API 网关触发了限流(约 1 分钟窗口,通常与共享配额有关),不是你的账号或插件问题。本地已冷却约 1 分钟,稍后重试即可。";
|
|
1258
1261
|
return `codearts 上游错误 (http ${status}): ${message.slice(0, 400)}`;
|
|
1259
1262
|
}
|
|
1260
1263
|
/**
|
|
1264
|
+
* API 网关层的限流(与后端软限流是两回事)。
|
|
1265
|
+
*
|
|
1266
|
+
* 2026-11-27 观测(issue #22 后续):429 + `{"error_msg":"The throttling threshold
|
|
1267
|
+
* has been reached: policy user over ratelimit,limit:100,time:1 minute",
|
|
1268
|
+
* "error_code":"APIG.0308",...}`。窗口是 1 分钟,比后端软限流(约 30 秒)长,
|
|
1269
|
+
* 用后者的冷却去等会在窗口里「解冻即再撞」。这层限流纯客户端无法核实配额归属,
|
|
1270
|
+
* 只在本地按 1 分钟窗口退避,不涉及任何上游操作。
|
|
1271
|
+
*/
|
|
1272
|
+
const GATEWAY_THROTTLE_CODE = "APIG.0308";
|
|
1273
|
+
const GATEWAY_THROTTLE_TEXT = /policy\s+\w+\s+over\s+ratelimit/i;
|
|
1274
|
+
function isGatewayThrottle(text) {
|
|
1275
|
+
return text.includes("APIG.0308") || GATEWAY_THROTTLE_TEXT.test(text);
|
|
1276
|
+
}
|
|
1277
|
+
/**
|
|
1261
1278
|
* 「这个账号的套餐积分已耗尽」。
|
|
1262
1279
|
*
|
|
1263
1280
|
* 2026-11-25 实测(issue #20):上游回 HTTP 400 + body
|
|
@@ -1359,6 +1376,7 @@ function classify(status, message) {
|
|
|
1359
1376
|
if (isCreditExhausted(message)) return "hard_credit";
|
|
1360
1377
|
if (status === 401 || status === 403) return "session_dead";
|
|
1361
1378
|
if (status === 402) return "hard_credit";
|
|
1379
|
+
if (isGatewayThrottle(message)) return "gate_rate";
|
|
1362
1380
|
if (status === 429) return "soft_rate";
|
|
1363
1381
|
if (status === 404) return "not_found";
|
|
1364
1382
|
if (status >= 500) return "server";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { u as writeJsonAtomic } from "./auth-
|
|
2
|
-
import { $ as setDiscoveredBenefitModels, H as carryKnownWindows, J as isBenefitModel, X as mergeModelLists, Z as modelDisplayName, u as fetchModels } from "./upstream-
|
|
1
|
+
import { u as writeJsonAtomic } from "./auth-T5qnGSPp.mjs";
|
|
2
|
+
import { $ as setDiscoveredBenefitModels, H as carryKnownWindows, J as isBenefitModel, X as mergeModelLists, Z as modelDisplayName, u as fetchModels } from "./upstream-Cr5tUI75.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.
|
|
539
|
+
const CODEARTS_VERSION = "1.4.16";
|
|
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.
|
|
5
|
+
"version": "1.4.16",
|
|
6
6
|
"packageManager": "pnpm@11.24.0",
|
|
7
7
|
"author": "elegant01",
|
|
8
8
|
"keywords": [
|