dsh-codearts 1.4.13 → 1.4.15
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 +38 -0
- package/lib/{auth-D-RmpxN3.mjs → auth-qnSuuDGW.mjs} +1 -1
- package/lib/bin.mjs +3 -3
- package/lib/client/index.d.cts +2 -0
- package/lib/client/index.js +164 -143
- package/lib/index.d.mts +15 -0
- package/lib/index.mjs +152 -12
- package/lib/keeper-main.mjs +1 -1
- package/lib/{upstream-DeRNnZdN.mjs → upstream-D1NN-sbL.mjs} +74 -2
- package/lib/{version-BnCFPeBL.mjs → version-BJniJ4eN.mjs} +3 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,44 @@
|
|
|
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.15] - 2026-11-27
|
|
7
|
+
|
|
8
|
+
### 修复
|
|
9
|
+
|
|
10
|
+
- **冷却期不再把请求打回宿主盲退避**(#22):账号全在冷却时,以前立刻回 429,
|
|
11
|
+
而解冻时刻插件自己精确知道(冷却最长 30 秒)—— 落在冷却窗内的宿主重试注定
|
|
12
|
+
失败,一次上游 5xx 会被放大成一串失败记录。现在轮换在两轮之间内联等到最近
|
|
13
|
+
一个号解冻再发;超过轮换截止点的冷却(例如积分耗尽的 30 分钟)仍立即报错,
|
|
14
|
+
并写明本地已等冷却多少秒。
|
|
15
|
+
- **与 billion-context 共存时的大请求不再被拒**(#23):bili 会对「未归属会话、
|
|
16
|
+
又超过静默直连上限(8 MiB)」的请求在本地回 422 + `x-bili-gate:
|
|
17
|
+
oversize-refusal*`,根本没出网。现在认出这个标记后改走插件自己的
|
|
18
|
+
`node:http(s)` 连接直发,签名与请求体原样保留;真正的上游 422 不带该标记头,
|
|
19
|
+
仍按原分类处理。
|
|
20
|
+
|
|
21
|
+
## [1.4.14] - 2026-11-26
|
|
22
|
+
|
|
23
|
+
### 修复
|
|
24
|
+
|
|
25
|
+
- **带图请求必失败**(#21):`REQUEST_IMAGE_BUDGETS` 是手搓的 resolved profile,漏了
|
|
26
|
+
宿主 0.2.3 起用来算字节预算的 `requestImageBudgetCount`;除法得到 NaN,`NaN < 1`
|
|
27
|
+
绕过宿主自检,请求在附件层抛 `INVALID_ATTACHMENT_REF`。补上该字段(取 4:6 MiB
|
|
28
|
+
总预算下,均分仍盖过 1 MiB 单图上限),并补齐 0.2.3 改了名字的 `maxImageBytes`
|
|
29
|
+
以及 0.2.2-rc.1 起的必填项 `maxRequestImages` / `imageOffloadCountQuantum`。
|
|
30
|
+
- **单账号积分耗尽不再判死整轮**(#20):上游回 HTTP 400 + `TM.00001050`(同一错误
|
|
31
|
+
也会以流内首帧出现)时识别为 `hard_credit`,轮转循环换下一个号并冷却 30 分钟;
|
|
32
|
+
全部账号耗尽时回 402 并说明「积分按账号独立计算、不能跨号挪用」。流内报错日志里
|
|
33
|
+
的错误码不再被脱敏器打成 `****`。
|
|
34
|
+
- **provider 注册不再被首轮发现拖住**(#19):启动引导改为先注册 provider、再做
|
|
35
|
+
首轮发现(一次性宿主仍然等首轮发现拿清单);体检新增 `provider` 一项(是否注册、
|
|
36
|
+
卡在哪个阶段、注册报错原文),启动等待超时时也会留一条可见的 warn。
|
|
37
|
+
|
|
38
|
+
### 新增
|
|
39
|
+
|
|
40
|
+
- **积分弹层标出耗尽的号**(#20):余额为 0 的账号在卡片里降为警戒色圆点并挂
|
|
41
|
+
「已耗尽」标签;账号多于一个时,表头下方补一句「积分按账号独立计算、不能跨号
|
|
42
|
+
挪用;底部合计是所有号的总和」。合计数字本身不变。
|
|
43
|
+
|
|
6
44
|
## [1.4.13] - 2026-11-24
|
|
7
45
|
|
|
8
46
|
### 修复
|
|
@@ -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-D1NN-sbL.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 {
|
|
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-qnSuuDGW.mjs";
|
|
3
|
+
import { J as isBenefitModel, l as fetchCallerIdentity } from "./upstream-D1NN-sbL.mjs";
|
|
4
|
+
import { i as discoverModels, n as CodeArtsUsageTracker, r as codeartsUsagePath, t as CODEARTS_VERSION } from "./version-BJniJ4eN.mjs";
|
|
5
5
|
import { existsSync, statSync } from "node:fs";
|
|
6
6
|
//#region src/bin.ts
|
|
7
7
|
/**
|
package/lib/client/index.d.cts
CHANGED
|
@@ -201,6 +201,8 @@ interface CodeArtsSettingsKey {
|
|
|
201
201
|
creditsDockEmpty: string;
|
|
202
202
|
creditsDockExpiring: string;
|
|
203
203
|
creditsDockUpdated: string;
|
|
204
|
+
creditsDockExhausted: string;
|
|
205
|
+
creditsDockPerAccountNote: string;
|
|
204
206
|
dockProvider: string;
|
|
205
207
|
dockModel: string;
|
|
206
208
|
dockNoModel: string;
|
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
|
-
"
|
|
202
|
-
"expiryRow": "xoziZG_expiryRow",
|
|
203
|
-
"statGrid": "xoziZG_statGrid",
|
|
197
|
+
"statValue": "xoziZG_statValue",
|
|
198
|
+
"balanceMeta": "xoziZG_balanceMeta",
|
|
199
|
+
"groupHead": "xoziZG_groupHead",
|
|
200
|
+
"area": "xoziZG_area",
|
|
201
|
+
"accountHint": "xoziZG_accountHint",
|
|
204
202
|
"manualForm": "xoziZG_manualForm",
|
|
205
|
-
"
|
|
206
|
-
"
|
|
207
|
-
"
|
|
208
|
-
"
|
|
209
|
-
"link": "xoziZG_link",
|
|
203
|
+
"expiryLabel": "xoziZG_expiryLabel",
|
|
204
|
+
"sectionLabel": "xoziZG_sectionLabel",
|
|
205
|
+
"creditFooter": "xoziZG_creditFooter",
|
|
206
|
+
"heatGrid": "xoziZG_heatGrid",
|
|
210
207
|
"concurrencyStepper": "xoziZG_concurrencyStepper",
|
|
211
|
-
"
|
|
212
|
-
"
|
|
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",
|
|
221
|
-
"creditHint": "xoziZG_creditHint",
|
|
222
|
-
"modelChart": "xoziZG_modelChart",
|
|
223
|
-
"choices": "xoziZG_choices",
|
|
224
|
-
"claimAllRow": "xoziZG_claimAllRow",
|
|
225
|
-
"concurrencyButton": "xoziZG_concurrencyButton",
|
|
208
|
+
"actions": "xoziZG_actions",
|
|
209
|
+
"accountRowActions": "xoziZG_accountRowActions",
|
|
226
210
|
"modelRow": "xoziZG_modelRow",
|
|
227
|
-
"
|
|
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",
|
|
237
|
-
"accountMenuAnchor": "xoziZG_accountMenuAnchor",
|
|
238
|
-
"tabs": "xoziZG_tabs",
|
|
239
|
-
"usageTip": "xoziZG_usageTip",
|
|
240
|
-
"error": "xoziZG_error",
|
|
241
|
-
"header": "xoziZG_header",
|
|
242
|
-
"section": "xoziZG_section",
|
|
243
|
-
"windowButtonSet": "xoziZG_windowButtonSet",
|
|
244
|
-
"count": "xoziZG_count",
|
|
245
|
-
"creditBlock": "xoziZG_creditBlock",
|
|
246
|
-
"accountConcurrencyInline": "xoziZG_accountConcurrencyInline",
|
|
247
|
-
"windowPopover": "xoziZG_windowPopover",
|
|
211
|
+
"updated": "xoziZG_updated",
|
|
248
212
|
"bar": "xoziZG_bar",
|
|
249
|
-
"usageTipRow": "xoziZG_usageTipRow",
|
|
250
|
-
"actions": "xoziZG_actions",
|
|
251
|
-
"usageBar": "xoziZG_usageBar",
|
|
252
|
-
"accountCard": "xoziZG_accountCard",
|
|
253
213
|
"creditLink": "xoziZG_creditLink",
|
|
254
|
-
"heatAxisSlot": "xoziZG_heatAxisSlot",
|
|
255
|
-
"windowInput": "xoziZG_windowInput",
|
|
256
214
|
"modelFill": "xoziZG_modelFill",
|
|
257
|
-
"statLabel": "xoziZG_statLabel",
|
|
258
215
|
"windowUnit": "xoziZG_windowUnit",
|
|
259
|
-
"
|
|
260
|
-
"
|
|
261
|
-
"
|
|
262
|
-
"
|
|
263
|
-
"
|
|
264
|
-
"
|
|
265
|
-
"
|
|
266
|
-
"
|
|
267
|
-
"
|
|
268
|
-
"heatAxis": "xoziZG_heatAxis",
|
|
216
|
+
"usageTipName": "xoziZG_usageTipName",
|
|
217
|
+
"accountName": "xoziZG_accountName",
|
|
218
|
+
"choiceRow": "xoziZG_choiceRow",
|
|
219
|
+
"statusLine": "xoziZG_statusLine",
|
|
220
|
+
"usageTipSep": "xoziZG_usageTipSep",
|
|
221
|
+
"concurrencyButton": "xoziZG_concurrencyButton",
|
|
222
|
+
"accountInfo": "xoziZG_accountInfo",
|
|
223
|
+
"windowAnchor": "xoziZG_windowAnchor",
|
|
224
|
+
"fieldLabel": "xoziZG_fieldLabel",
|
|
269
225
|
"statSub": "xoziZG_statSub",
|
|
270
|
-
"
|
|
271
|
-
"
|
|
226
|
+
"usageTipRow": "xoziZG_usageTipRow",
|
|
227
|
+
"heatLegend": "xoziZG_heatLegend",
|
|
228
|
+
"groupLabel": "xoziZG_groupLabel",
|
|
229
|
+
"concurrencyValue": "xoziZG_concurrencyValue",
|
|
230
|
+
"skeletonRow": "xoziZG_skeletonRow",
|
|
231
|
+
"statLabel": "xoziZG_statLabel",
|
|
232
|
+
"statGrid": "xoziZG_statGrid",
|
|
233
|
+
"heatLegendChip": "xoziZG_heatLegendChip",
|
|
234
|
+
"windowButtonSet": "xoziZG_windowButtonSet",
|
|
235
|
+
"usageBar": "xoziZG_usageBar",
|
|
236
|
+
"modelSpec": "xoziZG_modelSpec",
|
|
237
|
+
"accountGrid": "xoziZG_accountGrid",
|
|
238
|
+
"groupHeadFirst": "xoziZG_groupHeadFirst",
|
|
239
|
+
"field": "xoziZG_field",
|
|
240
|
+
"barFill": "xoziZG_barFill",
|
|
241
|
+
"skeleton": "xoziZG_skeleton",
|
|
272
242
|
"manual": "xoziZG_manual",
|
|
273
|
-
"
|
|
274
|
-
"
|
|
275
|
-
"
|
|
243
|
+
"heatAxisSlot": "xoziZG_heatAxisSlot",
|
|
244
|
+
"accountMenuItem": "xoziZG_accountMenuItem",
|
|
245
|
+
"windowPopoverRow": "xoziZG_windowPopoverRow",
|
|
276
246
|
"windowButtonOpen": "xoziZG_windowButtonOpen",
|
|
277
|
-
"
|
|
247
|
+
"expiryRow": "xoziZG_expiryRow",
|
|
278
248
|
"skeletonBreath": "xoziZG_skeletonBreath",
|
|
279
|
-
"
|
|
249
|
+
"creditHint": "xoziZG_creditHint",
|
|
250
|
+
"creditRows": "xoziZG_creditRows",
|
|
251
|
+
"heatWeekday": "xoziZG_heatWeekday",
|
|
252
|
+
"modelChart": "xoziZG_modelChart",
|
|
280
253
|
"windowHint": "xoziZG_windowHint",
|
|
281
|
-
"
|
|
282
|
-
"
|
|
283
|
-
"
|
|
284
|
-
"
|
|
285
|
-
"accountHint": "xoziZG_accountHint",
|
|
254
|
+
"hint": "xoziZG_hint",
|
|
255
|
+
"trendTip": "xoziZG_trendTip",
|
|
256
|
+
"windowSection": "xoziZG_windowSection",
|
|
257
|
+
"modelMeta": "xoziZG_modelMeta",
|
|
286
258
|
"choiceTail": "xoziZG_choiceTail",
|
|
287
|
-
"
|
|
259
|
+
"modelRequests": "xoziZG_modelRequests",
|
|
260
|
+
"accountMenuAnchor": "xoziZG_accountMenuAnchor",
|
|
261
|
+
"balanceRow": "xoziZG_balanceRow",
|
|
288
262
|
"modelTrack": "xoziZG_modelTrack",
|
|
289
|
-
"
|
|
290
|
-
"
|
|
291
|
-
"
|
|
292
|
-
"
|
|
293
|
-
"
|
|
294
|
-
"
|
|
295
|
-
"doctorRow": "xoziZG_doctorRow",
|
|
296
|
-
"windowRange": "xoziZG_windowRange",
|
|
263
|
+
"accountConcurrencyInline": "xoziZG_accountConcurrencyInline",
|
|
264
|
+
"creditRow": "xoziZG_creditRow",
|
|
265
|
+
"tabs": "xoziZG_tabs",
|
|
266
|
+
"body": "xoziZG_body",
|
|
267
|
+
"header": "xoziZG_header",
|
|
268
|
+
"accountEntry": "xoziZG_accountEntry",
|
|
297
269
|
"accountToolbar": "xoziZG_accountToolbar",
|
|
298
|
-
"modelName": "xoziZG_modelName",
|
|
299
|
-
"heatCell": "xoziZG_heatCell",
|
|
300
|
-
"heatLegendChip": "xoziZG_heatLegendChip",
|
|
301
|
-
"desc": "xoziZG_desc",
|
|
302
270
|
"accountToggle": "xoziZG_accountToggle",
|
|
303
|
-
"fieldLabel": "xoziZG_fieldLabel",
|
|
304
|
-
"balanceMeta": "xoziZG_balanceMeta",
|
|
305
|
-
"doctorList": "xoziZG_doctorList",
|
|
306
|
-
"accountClear": "xoziZG_accountClear",
|
|
307
|
-
"skeletonRow": "xoziZG_skeletonRow",
|
|
308
271
|
"accountClearHint": "xoziZG_accountClearHint",
|
|
309
|
-
"
|
|
310
|
-
"
|
|
311
|
-
"
|
|
312
|
-
"
|
|
313
|
-
"
|
|
314
|
-
"
|
|
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",
|
|
315
279
|
"windowButton": "xoziZG_windowButton",
|
|
316
|
-
"
|
|
280
|
+
"count": "xoziZG_count",
|
|
281
|
+
"windowPopover": "xoziZG_windowPopover",
|
|
282
|
+
"link": "xoziZG_link",
|
|
283
|
+
"avatar": "xoziZG_avatar",
|
|
284
|
+
"windowPopoverValue": "xoziZG_windowPopoverValue",
|
|
285
|
+
"windowRange": "xoziZG_windowRange",
|
|
286
|
+
"accountConcurrencyLabel": "xoziZG_accountConcurrencyLabel",
|
|
287
|
+
"modelName": "xoziZG_modelName",
|
|
288
|
+
"name": "xoziZG_name",
|
|
289
|
+
"balance": "xoziZG_balance",
|
|
290
|
+
"tabPanel": "xoziZG_tabPanel",
|
|
291
|
+
"doctorName": "xoziZG_doctorName",
|
|
292
|
+
"desc": "xoziZG_desc",
|
|
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",
|
|
317
307
|
"balanceUnit": "xoziZG_balanceUnit",
|
|
318
|
-
"
|
|
319
|
-
"
|
|
308
|
+
"manualSummary": "xoziZG_manualSummary",
|
|
309
|
+
"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
|
+
"heatHours": "xoziZG_heatHours",
|
|
319
|
+
"heatHourCell": "xoziZG_heatHourCell"
|
|
320
320
|
};
|
|
321
321
|
//#endregion
|
|
322
322
|
//#region src/client/CodeArtsPluginCard.tsx
|
|
@@ -3553,52 +3553,69 @@ function CodeArtsCreditDock({ useProjection, t, zone = "dock", onOpenSettings })
|
|
|
3553
3553
|
fontSize: 12,
|
|
3554
3554
|
color: "var(--dsw-alias-label-tertiary)"
|
|
3555
3555
|
},
|
|
3556
|
-
children: [
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3556
|
+
children: [
|
|
3557
|
+
rows.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("creditsDockEmpty") }),
|
|
3558
|
+
rows.length > 1 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3559
|
+
style: {
|
|
3560
|
+
fontSize: 11,
|
|
3561
|
+
lineHeight: "15px"
|
|
3562
|
+
},
|
|
3563
|
+
children: t("creditsDockPerAccountNote")
|
|
3564
|
+
}),
|
|
3565
|
+
rows.map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3564
3566
|
style: {
|
|
3565
|
-
display: "
|
|
3566
|
-
|
|
3567
|
-
gap:
|
|
3568
|
-
alignItems: "center",
|
|
3567
|
+
display: "flex",
|
|
3568
|
+
flexDirection: "column",
|
|
3569
|
+
gap: 2,
|
|
3569
3570
|
minWidth: 0
|
|
3570
3571
|
},
|
|
3571
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("
|
|
3572
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3572
3573
|
style: {
|
|
3573
|
-
display: "
|
|
3574
|
+
display: "grid",
|
|
3575
|
+
gridTemplateColumns: PANEL_ROW_COLUMNS,
|
|
3576
|
+
gap: "0 8px",
|
|
3574
3577
|
alignItems: "center",
|
|
3575
|
-
gap: 5,
|
|
3576
3578
|
minWidth: 0
|
|
3577
3579
|
},
|
|
3578
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.
|
|
3580
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
3579
3581
|
style: {
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3582
|
+
display: "flex",
|
|
3583
|
+
alignItems: "center",
|
|
3584
|
+
gap: 5,
|
|
3585
|
+
minWidth: 0
|
|
3584
3586
|
},
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
+
children: [
|
|
3588
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.StateDot, { state: row.remain === null || row.remain < 1 ? "warning" : "done" }),
|
|
3589
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3590
|
+
style: {
|
|
3591
|
+
overflow: "hidden",
|
|
3592
|
+
textOverflow: "ellipsis",
|
|
3593
|
+
whiteSpace: "nowrap",
|
|
3594
|
+
color: "var(--dsw-alias-label-primary)"
|
|
3595
|
+
},
|
|
3596
|
+
title: row.error === void 0 ? row.name : row.error,
|
|
3597
|
+
children: row.name
|
|
3598
|
+
}),
|
|
3599
|
+
row.remain !== null && row.remain < 1 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, {
|
|
3600
|
+
tone: "warning",
|
|
3601
|
+
children: t("creditsDockExhausted")
|
|
3602
|
+
})
|
|
3603
|
+
]
|
|
3604
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3605
|
+
style: PANEL_NUM_CELL,
|
|
3606
|
+
children: row.remain === null ? "—" : formatNumber(row.remain)
|
|
3587
3607
|
})]
|
|
3588
3608
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3589
|
-
style:
|
|
3590
|
-
|
|
3609
|
+
style: {
|
|
3610
|
+
paddingLeft: 11,
|
|
3611
|
+
fontSize: 11,
|
|
3612
|
+
lineHeight: "15px",
|
|
3613
|
+
color: "var(--dsw-alias-label-tertiary)"
|
|
3614
|
+
},
|
|
3615
|
+
children: row.usage === void 0 ? t("creditsDockNoTokens") : `${t("usageToday")} ${usageLine(row.usage, t)}`
|
|
3591
3616
|
})]
|
|
3592
|
-
}
|
|
3593
|
-
|
|
3594
|
-
paddingLeft: 11,
|
|
3595
|
-
fontSize: 11,
|
|
3596
|
-
lineHeight: "15px",
|
|
3597
|
-
color: "var(--dsw-alias-label-tertiary)"
|
|
3598
|
-
},
|
|
3599
|
-
children: row.usage === void 0 ? t("creditsDockNoTokens") : `${t("usageToday")} ${usageLine(row.usage, t)}`
|
|
3600
|
-
})]
|
|
3601
|
-
}, row.id))]
|
|
3617
|
+
}, row.id))
|
|
3618
|
+
]
|
|
3602
3619
|
}),
|
|
3603
3620
|
rows.filter((row) => row.expiring > 0).map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3604
3621
|
style: {
|
|
@@ -3631,14 +3648,14 @@ if (typeof document !== "undefined" && document.querySelector("style[data-plugin
|
|
|
3631
3648
|
document.head.appendChild(tag);
|
|
3632
3649
|
}
|
|
3633
3650
|
var CodeArtsPanel_module_css_default = {
|
|
3634
|
-
"
|
|
3651
|
+
"title": "Z66cgG_title",
|
|
3635
3652
|
"head": "Z66cgG_head",
|
|
3636
|
-
"
|
|
3637
|
-
"desc": "Z66cgG_desc",
|
|
3653
|
+
"backCaret": "Z66cgG_backCaret",
|
|
3638
3654
|
"back": "Z66cgG_back",
|
|
3639
3655
|
"body": "Z66cgG_body",
|
|
3640
|
-
"
|
|
3641
|
-
"
|
|
3656
|
+
"icon": "Z66cgG_icon",
|
|
3657
|
+
"desc": "Z66cgG_desc",
|
|
3658
|
+
"page": "Z66cgG_page"
|
|
3642
3659
|
};
|
|
3643
3660
|
//#endregion
|
|
3644
3661
|
//#region src/client/CodeArtsPanel.tsx
|
|
@@ -3964,6 +3981,8 @@ const zh = {
|
|
|
3964
3981
|
creditsDockEmpty: "暂时没有积分数据",
|
|
3965
3982
|
creditsDockExpiring: "{account}:{expiring} 积分将在本周期结束时作废",
|
|
3966
3983
|
creditsDockUpdated: "最近刷新 {time}",
|
|
3984
|
+
creditsDockExhausted: "已耗尽",
|
|
3985
|
+
creditsDockPerAccountNote: "积分按账号独立计算、不能跨号挪用;底部合计是所有号的总和。",
|
|
3967
3986
|
dockProvider: "Provider {provider}",
|
|
3968
3987
|
dockModel: "Model {model}",
|
|
3969
3988
|
dockNoModel: "未选择模型",
|
|
@@ -4191,6 +4210,8 @@ const en = {
|
|
|
4191
4210
|
creditsDockEmpty: "No credit data yet",
|
|
4192
4211
|
creditsDockExpiring: "{account}: {expiring} credits expire when this cycle ends",
|
|
4193
4212
|
creditsDockUpdated: "Last updated {time}",
|
|
4213
|
+
creditsDockExhausted: "Exhausted",
|
|
4214
|
+
creditsDockPerAccountNote: "Credits are counted per account and cannot be pooled; the dock total is just the sum of every account.",
|
|
4194
4215
|
dockProvider: "Provider {provider}",
|
|
4195
4216
|
dockModel: "Model {model}",
|
|
4196
4217
|
dockNoModel: "No model selected",
|
package/lib/index.d.mts
CHANGED
|
@@ -1366,6 +1366,21 @@ declare class CodeArtsAccountPool {
|
|
|
1366
1366
|
* subagent)必然误伤;现在与上游排队对齐 —— 先短时等待,等不到再报错。
|
|
1367
1367
|
*/
|
|
1368
1368
|
waitForFreeSlot(maxWaitMs: number, signal?: AbortSignal): Promise<boolean>;
|
|
1369
|
+
/**
|
|
1370
|
+
* 最近一个冷却账号的解冻时刻(epoch ms);没有冷却中的号返回 undefined。
|
|
1371
|
+
*
|
|
1372
|
+
* 与「槽位满」不同:解冻时刻是池子自己记的倒计时,精确已知 —— 值得内联等到
|
|
1373
|
+
* 那一刻再发,而不是立刻回 429 让宿主在冷却窗里盲退避(issue #22)。禁用/暂停
|
|
1374
|
+
* 的号不会自己恢复,不参与。
|
|
1375
|
+
*/
|
|
1376
|
+
earliestCooldownEnd(): number | undefined;
|
|
1377
|
+
/**
|
|
1378
|
+
* 睡到最近一个冷却账号解冻,最多 `maxWaitMs`。
|
|
1379
|
+
*
|
|
1380
|
+
* 返回 true = 已经醒了(可能刚好到解冻时刻);false = 没有冷却中的号、预算不够
|
|
1381
|
+
* 或等待被中止。调用方醒后要重新走一遍选号:解冻的号可能又发了新请求。
|
|
1382
|
+
*/
|
|
1383
|
+
waitForCooldownEnd(maxWaitMs: number, signal?: AbortSignal): Promise<boolean>;
|
|
1369
1384
|
/**
|
|
1370
1385
|
* 撞到上游并发上限。
|
|
1371
1386
|
*
|
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 {
|
|
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-qnSuuDGW.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-D1NN-sbL.mjs";
|
|
3
|
+
import { a as refreshCatalog, i as discoverModels, n as CodeArtsUsageTracker, r as codeartsUsagePath, t as CODEARTS_VERSION } from "./version-BJniJ4eN.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";
|
|
@@ -33,6 +33,8 @@ const CAP_SAMPLE_MIN_MS = 5e3;
|
|
|
33
33
|
const CAP_SAMPLE_MAX_MS = 12e4;
|
|
34
34
|
/** 参与中位数的最近样本数。 */
|
|
35
35
|
const CAP_SAMPLE_KEEP = 5;
|
|
36
|
+
/** 睡到解冻时刻后再多醒一点,防止定时器抖动导致醒来时 `coolUntil` 还差几毫秒。 */
|
|
37
|
+
const COOLDOWN_WAKE_EPSILON_MS = 250;
|
|
36
38
|
/**
|
|
37
39
|
* 这个号的「优先避开」窗口:量到过就用实测中位数,没量过用默认提示。
|
|
38
40
|
*
|
|
@@ -256,6 +258,48 @@ var CodeArtsAccountPool = class {
|
|
|
256
258
|
});
|
|
257
259
|
}
|
|
258
260
|
/**
|
|
261
|
+
* 最近一个冷却账号的解冻时刻(epoch ms);没有冷却中的号返回 undefined。
|
|
262
|
+
*
|
|
263
|
+
* 与「槽位满」不同:解冻时刻是池子自己记的倒计时,精确已知 —— 值得内联等到
|
|
264
|
+
* 那一刻再发,而不是立刻回 429 让宿主在冷却窗里盲退避(issue #22)。禁用/暂停
|
|
265
|
+
* 的号不会自己恢复,不参与。
|
|
266
|
+
*/
|
|
267
|
+
earliestCooldownEnd() {
|
|
268
|
+
const now = this.now();
|
|
269
|
+
let soonest;
|
|
270
|
+
for (const account of this.accounts.values()) {
|
|
271
|
+
if (account.disabled || this.paused.has(account.id) || account.coolUntil <= now) continue;
|
|
272
|
+
if (soonest === void 0 || account.coolUntil < soonest) soonest = account.coolUntil;
|
|
273
|
+
}
|
|
274
|
+
return soonest;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* 睡到最近一个冷却账号解冻,最多 `maxWaitMs`。
|
|
278
|
+
*
|
|
279
|
+
* 返回 true = 已经醒了(可能刚好到解冻时刻);false = 没有冷却中的号、预算不够
|
|
280
|
+
* 或等待被中止。调用方醒后要重新走一遍选号:解冻的号可能又发了新请求。
|
|
281
|
+
*/
|
|
282
|
+
waitForCooldownEnd(maxWaitMs, signal) {
|
|
283
|
+
const thawAt = this.earliestCooldownEnd();
|
|
284
|
+
if (thawAt === void 0 || maxWaitMs <= 0) return Promise.resolve(false);
|
|
285
|
+
if (signal?.aborted === true) return Promise.resolve(false);
|
|
286
|
+
const waitMs = Math.min(maxWaitMs, Math.max(0, thawAt - this.now()));
|
|
287
|
+
return new Promise((resolve) => {
|
|
288
|
+
let settled = false;
|
|
289
|
+
const finish = (value) => {
|
|
290
|
+
if (settled) return;
|
|
291
|
+
settled = true;
|
|
292
|
+
clearTimeout(timer);
|
|
293
|
+
signal?.removeEventListener("abort", onAbort);
|
|
294
|
+
resolve(value);
|
|
295
|
+
};
|
|
296
|
+
const onAbort = () => finish(false);
|
|
297
|
+
const timer = setTimeout(() => finish(true), waitMs + COOLDOWN_WAKE_EPSILON_MS);
|
|
298
|
+
timer.unref?.();
|
|
299
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
259
303
|
* 撞到上游并发上限。
|
|
260
304
|
*
|
|
261
305
|
* **不冷却账号** —— 账号没坏,只是会话槽位暂时满了(约 52 秒释放)。冷却会
|
|
@@ -820,7 +864,32 @@ const NO_COST = {
|
|
|
820
864
|
const REQUEST_IMAGE_BUDGETS = {
|
|
821
865
|
maxRequestImageBytes: 6291456,
|
|
822
866
|
requestImagePixelBudget: 4194304,
|
|
823
|
-
|
|
867
|
+
/**
|
|
868
|
+
* 单图上限。这个字段在宿主里有两个拼写:0.2.2 及以前读 `requestImageMaxBytes`,
|
|
869
|
+
* 0.2.3 起 resolved profile 改叫 `maxImageBytes`(配置里的旧名由 resolveProfiles
|
|
870
|
+
* 映射过去)。本插件是手搓 profile、不走 resolveProfiles,两处都得写,各自忽略
|
|
871
|
+
* 不认识的那一个。
|
|
872
|
+
*/
|
|
873
|
+
requestImageMaxBytes: 1048576,
|
|
874
|
+
maxImageBytes: 1048576,
|
|
875
|
+
/**
|
|
876
|
+
* 0.2.3 起宿主要求的字节预算除数(issue #21):
|
|
877
|
+
* allocated = floor(maxRequestImageBytes / requestImageBudgetCount / 4) * 3
|
|
878
|
+
* cap = min(allocated, maxImageBytes)
|
|
879
|
+
* 漏掉它时分母是 undefined ⇒ NaN,`NaN < 1` 为 false 绕过宿主自检,带图请求
|
|
880
|
+
* 必然在附件层抛 INVALID_ATTACHMENT_REF。
|
|
881
|
+
*
|
|
882
|
+
* 取 4 而不是宿主默认的 20:allocated 只是 min() 的候选,除数必须让商仍盖过
|
|
883
|
+
* 1 MiB 单图上限,否则没人选的更小数字会悄悄顶替单图上限(6 MiB 时
|
|
884
|
+
* 20 → 235,929 字节,4 → 1,179,648)。5 已差一点(943,716),所以是 4。
|
|
885
|
+
*/
|
|
886
|
+
requestImageBudgetCount: 4,
|
|
887
|
+
/**
|
|
888
|
+
* 0.2.2-rc.1 起 resolved profile 的必填项(宿主默认 50 / 10)。
|
|
889
|
+
* 不写等于「数量不设限」,在带图长会话里会先撞上游请求体上限才轮到宿主 offload。
|
|
890
|
+
*/
|
|
891
|
+
maxRequestImages: 50,
|
|
892
|
+
imageOffloadCountQuantum: 10
|
|
824
893
|
};
|
|
825
894
|
/** Inert pi-ai auth plane: the codearts route authenticates only via the shim secret. */
|
|
826
895
|
const INERT_AUTH = {
|
|
@@ -1186,6 +1255,11 @@ const MAX_CEILING_HEALS = 3;
|
|
|
1186
1255
|
*/
|
|
1187
1256
|
const ROTATE_MIN_ATTEMPTS = 3;
|
|
1188
1257
|
const ROTATE_MAX_ATTEMPTS = 6;
|
|
1258
|
+
/**
|
|
1259
|
+
* 轮换最多跑几轮:每轮重新按账号试一遍。轮间要么等本地槽位释放(槽满),
|
|
1260
|
+
* 要么等冷却到点解冻(全在冷却)—— 两种都会让时间往前走,所以是有限的。
|
|
1261
|
+
*/
|
|
1262
|
+
const ROTATE_MAX_ROUNDS = 3;
|
|
1189
1263
|
/** 开始下一次尝试前必须留下的预算:一次挂号短探(默认 5 秒)再加一次开流。 */
|
|
1190
1264
|
const ATTEMPT_RESERVE_MS = 2e4;
|
|
1191
1265
|
/**
|
|
@@ -1218,6 +1292,13 @@ const QUEUE_HEARTBEAT_MS = 2e4;
|
|
|
1218
1292
|
const SERVER_COOLDOWN_MS = 3e4;
|
|
1219
1293
|
/** 零散错误累计到阈值后冷却该账号。 */
|
|
1220
1294
|
const ERROR_COOLDOWN_MS = 6e4;
|
|
1295
|
+
/**
|
|
1296
|
+
* 积分耗尽后的冷却。积分是账号级的,不会在几十秒内回来(要等套餐周期刷新或
|
|
1297
|
+
* 领取活动积分),30 秒的短冷却只会让它被反复选中、反复失败一遍。30 分钟是
|
|
1298
|
+
* 「不反复白撞」与「用户中途领到积分后还能恢复」之间的折中;用户也可以在
|
|
1299
|
+
* 卡片上暂停这个号。
|
|
1300
|
+
*/
|
|
1301
|
+
const CREDIT_COOLDOWN_MS = 18e5;
|
|
1221
1302
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
1222
1303
|
const recentShapes = [];
|
|
1223
1304
|
/** 最近的请求形状,最新在前。 */
|
|
@@ -1411,12 +1492,12 @@ function createCodeArtsShim(options) {
|
|
|
1411
1492
|
const upstreamError = headText === void 0 ? void 0 : firstFrameError(headText);
|
|
1412
1493
|
if (upstreamError !== void 0) {
|
|
1413
1494
|
const detail = `${upstreamError.code}: ${upstreamError.message}`.replace(/^: /, "");
|
|
1414
|
-
if (isIamTokenError(detail) || isModelNotAccessible(detail) || isNotMultimodal(detail)) {
|
|
1495
|
+
if (isIamTokenError(detail) || isModelNotAccessible(detail) || isNotMultimodal(detail) || isCreditExhausted(detail)) {
|
|
1415
1496
|
reader.releaseLock();
|
|
1416
1497
|
await result.stream.cancel().catch(() => {});
|
|
1417
1498
|
logger?.warn(`dsh-codearts: ${prepared.model} 首帧报上游错误(${detail.slice(0, 160)})`);
|
|
1418
1499
|
if (isModelNotAccessible(detail)) markModelUnavailable(prepared.model, modelUnavailableReasonText(detail));
|
|
1419
|
-
const kind = isIamTokenError(detail) ? "iam_stale" : isModelNotAccessible(detail) ? "not_found" : "client";
|
|
1500
|
+
const kind = isIamTokenError(detail) ? "iam_stale" : isModelNotAccessible(detail) ? "not_found" : isCreditExhausted(detail) ? "hard_credit" : "client";
|
|
1420
1501
|
return {
|
|
1421
1502
|
prepared,
|
|
1422
1503
|
result: {
|
|
@@ -1573,6 +1654,7 @@ function createCodeArtsShim(options) {
|
|
|
1573
1654
|
let queuedAccount;
|
|
1574
1655
|
let queueWaitedMs = 0;
|
|
1575
1656
|
let localSlotWaitedMs = 0;
|
|
1657
|
+
let cooldownWaitedMs = 0;
|
|
1576
1658
|
let lastKind;
|
|
1577
1659
|
let lastAccountId;
|
|
1578
1660
|
let lastStatus = 0;
|
|
@@ -1586,7 +1668,7 @@ function createCodeArtsShim(options) {
|
|
|
1586
1668
|
* 再跑第二轮。以前这里直接落到「没有可用账号」的 429,并发派发(一次 5 个
|
|
1587
1669
|
* subagent)必然误伤(issue #8)。
|
|
1588
1670
|
*/
|
|
1589
|
-
for (let round = 0; round <
|
|
1671
|
+
for (let round = 0; round < ROTATE_MAX_ROUNDS; round += 1) {
|
|
1590
1672
|
tried.clear();
|
|
1591
1673
|
for (let attempt = 0; attempt < attempts; attempt += 1) {
|
|
1592
1674
|
if (Date.now() + ATTEMPT_RESERVE_MS > rotateDeadline) break;
|
|
@@ -1657,6 +1739,10 @@ function createCodeArtsShim(options) {
|
|
|
1657
1739
|
pool.disable(id, result.message);
|
|
1658
1740
|
continue;
|
|
1659
1741
|
}
|
|
1742
|
+
if (result.kind === "hard_credit") {
|
|
1743
|
+
pool.cooldown(id, CREDIT_COOLDOWN_MS, "该账号积分已耗尽(TM.00001050),额度刷新或领取积分后恢复");
|
|
1744
|
+
continue;
|
|
1745
|
+
}
|
|
1660
1746
|
if (result.kind === "server" || result.kind === "soft_rate") {
|
|
1661
1747
|
pool.cooldown(id, SERVER_COOLDOWN_MS, result.message);
|
|
1662
1748
|
break;
|
|
@@ -1669,7 +1755,19 @@ function createCodeArtsShim(options) {
|
|
|
1669
1755
|
}
|
|
1670
1756
|
}
|
|
1671
1757
|
if (lastKind !== void 0 || controller.signal.aborted) break;
|
|
1672
|
-
if (!pool.hasBusyWaitable())
|
|
1758
|
+
if (!pool.hasBusyWaitable()) {
|
|
1759
|
+
const thawAt = pool.earliestCooldownEnd();
|
|
1760
|
+
const thawBudget = rotateDeadline - ATTEMPT_RESERVE_MS - Date.now();
|
|
1761
|
+
if (thawAt === void 0 || thawBudget <= 0) break;
|
|
1762
|
+
if (thawAt - Date.now() > thawBudget) break;
|
|
1763
|
+
const coolingSince = Date.now();
|
|
1764
|
+
debug?.(`cooldown wait start req=${requestTag} thawIn=${thawAt - coolingSince}ms`);
|
|
1765
|
+
const thawed = await pool.waitForCooldownEnd(thawBudget, controller.signal);
|
|
1766
|
+
cooldownWaitedMs += Date.now() - coolingSince;
|
|
1767
|
+
debug?.(`cooldown wait ${thawed ? "done" : "timeout"} req=${requestTag} waited=${Date.now() - coolingSince}ms`);
|
|
1768
|
+
if (!thawed) break;
|
|
1769
|
+
continue;
|
|
1770
|
+
}
|
|
1673
1771
|
const waitBudget = Math.min(localSlotWaitBudgetMs, rotateDeadline - ATTEMPT_RESERVE_MS - Date.now());
|
|
1674
1772
|
if (waitBudget <= 0) break;
|
|
1675
1773
|
const waitingSince = Date.now();
|
|
@@ -1725,6 +1823,7 @@ function createCodeArtsShim(options) {
|
|
|
1725
1823
|
const waits = [];
|
|
1726
1824
|
if (queueWaitedMs >= 1e3) waits.push(`排队重试 ${Math.round(queueWaitedMs / 1e3)} 秒`);
|
|
1727
1825
|
if (localSlotWaitedMs >= 1e3) waits.push(`等本地槽位 ${Math.round(localSlotWaitedMs / 1e3)} 秒`);
|
|
1826
|
+
if (cooldownWaitedMs >= 1e3) waits.push(`等冷却解冻 ${Math.round(cooldownWaitedMs / 1e3)} 秒`);
|
|
1728
1827
|
const waited = waits.length > 0 ? `(本地已${waits.join("、")})` : "";
|
|
1729
1828
|
const failedKind = isQueueRejectText(lastMessage) ? "queued" : lastKind;
|
|
1730
1829
|
usage?.noteFailure(failedKind, lastAccountId);
|
|
@@ -1842,7 +1941,7 @@ function createCodeArtsShim(options) {
|
|
|
1842
1941
|
if (ev.error === void 0) return;
|
|
1843
1942
|
const code = String(ev.error.code ?? "");
|
|
1844
1943
|
const message = String(ev.error.message ?? "").slice(0, 200);
|
|
1845
|
-
logger?.error(`dsh-codearts: 上游流内报错 model=${model}
|
|
1944
|
+
logger?.error(`dsh-codearts: 上游流内报错 model=${model} 错误码 ${code} msg=${message}`);
|
|
1846
1945
|
} catch {}
|
|
1847
1946
|
}
|
|
1848
1947
|
/** 把上游 SSE 按事件边界转发给 DSH,直到流结束或被中止。 */
|
|
@@ -2382,6 +2481,15 @@ async function doctorReport(deps) {
|
|
|
2382
2481
|
detail: `${models.length}`
|
|
2383
2482
|
});
|
|
2384
2483
|
if (models.length === 0) hints.add("empty-catalog");
|
|
2484
|
+
const provider = deps.providerStatus?.();
|
|
2485
|
+
if (provider !== void 0) {
|
|
2486
|
+
checks.push({
|
|
2487
|
+
id: "provider",
|
|
2488
|
+
ok: provider.registered,
|
|
2489
|
+
detail: provider.registered ? `registered (stage=${provider.stage})` : `not registered (stage=${provider.stage}${provider.error === void 0 ? "" : `; ${provider.error}`})`
|
|
2490
|
+
});
|
|
2491
|
+
if (!provider.registered) hints.add("provider-not-registered");
|
|
2492
|
+
}
|
|
2385
2493
|
checks.push({
|
|
2386
2494
|
id: "usage",
|
|
2387
2495
|
ok: deps.usage !== void 0,
|
|
@@ -3850,9 +3958,25 @@ async function apply(ctx, rawConfig) {
|
|
|
3850
3958
|
}
|
|
3851
3959
|
return summarizeClaims(results);
|
|
3852
3960
|
};
|
|
3961
|
+
/**
|
|
3962
|
+
* 启动引导的进度(issue #19)。
|
|
3963
|
+
*
|
|
3964
|
+
* 「插件 HTTP 面全活、模型选择器里却没有 CodeArts」是宿主上真实出现过的分裂状态;
|
|
3965
|
+
* 那一刻唯一能区分「shim 没起来 / 注册被首轮发现拖住 / 注册抛错」的证据就在这里,
|
|
3966
|
+
* 由 /api/codearts/doctor 的 `provider` 一项读出去。
|
|
3967
|
+
*/
|
|
3968
|
+
const startup = {
|
|
3969
|
+
stage: "shim",
|
|
3970
|
+
registered: false
|
|
3971
|
+
};
|
|
3853
3972
|
ctx.inject(["webServer"], (webCtx) => registerCodeArtsStatusRoute(webCtx, {
|
|
3854
3973
|
store,
|
|
3855
3974
|
models: () => catalog.current(),
|
|
3975
|
+
providerStatus: () => ({
|
|
3976
|
+
registered: startup.registered,
|
|
3977
|
+
stage: startup.stage,
|
|
3978
|
+
...startup.error === void 0 ? {} : { error: startup.error }
|
|
3979
|
+
}),
|
|
3856
3980
|
enabledModels,
|
|
3857
3981
|
setEnabledModels,
|
|
3858
3982
|
contextWindowOverrides: () => current().contextWindowOverrides,
|
|
@@ -4112,10 +4236,10 @@ async function apply(ctx, rawConfig) {
|
|
|
4112
4236
|
keepAliveLoop();
|
|
4113
4237
|
armAutoClaim();
|
|
4114
4238
|
armKeepAliveDaemon();
|
|
4115
|
-
|
|
4116
|
-
if (stopped) return;
|
|
4239
|
+
startup.stage = "register";
|
|
4117
4240
|
const incompatible = await probePiAiCompat();
|
|
4118
4241
|
if (incompatible !== void 0) ctx.logger.error(`dsh-codearts: ${incompatible}`);
|
|
4242
|
+
writeDebugLog?.(`bootstrap: shim ready, registering provider (catalog=${catalog.current().length})`);
|
|
4119
4243
|
const codearts = createCodeArtsAdapter({
|
|
4120
4244
|
shim,
|
|
4121
4245
|
catalog,
|
|
@@ -4134,6 +4258,11 @@ async function apply(ctx, rawConfig) {
|
|
|
4134
4258
|
settingsPath: [],
|
|
4135
4259
|
declared: false
|
|
4136
4260
|
}]);
|
|
4261
|
+
startup.registered = true;
|
|
4262
|
+
writeDebugLog?.("bootstrap: provider registered");
|
|
4263
|
+
} catch (error) {
|
|
4264
|
+
startup.error = error instanceof Error ? error.message : String(error);
|
|
4265
|
+
throw error;
|
|
4137
4266
|
} finally {
|
|
4138
4267
|
if (releaseAdapter === void 0 || releaseDirectory === void 0) {
|
|
4139
4268
|
releaseAdapter?.();
|
|
@@ -4149,14 +4278,25 @@ async function apply(ctx, rawConfig) {
|
|
|
4149
4278
|
releaseAdapter?.();
|
|
4150
4279
|
releaseDirectory?.();
|
|
4151
4280
|
}
|
|
4281
|
+
startup.stage = "discovery";
|
|
4282
|
+
await discover(AbortSignal.any([abort.signal, AbortSignal.timeout(STARTUP_DISCOVERY_MS)]));
|
|
4283
|
+
if (stopped) return;
|
|
4152
4284
|
if (catalog.current().length === 0) ctx.logger.warn("dsh-codearts: CodeArts provider registered with an empty model catalog; models stay unavailable until discovery succeeds");
|
|
4285
|
+
startup.stage = "ready";
|
|
4286
|
+
writeDebugLog?.(`bootstrap: ready (catalog=${catalog.current().length})`);
|
|
4153
4287
|
if (!stopped) scheduleDiscovery(nextDiscoveryDelay());
|
|
4154
4288
|
}).catch((error) => {
|
|
4289
|
+
startup.error = error instanceof Error ? error.message : String(error);
|
|
4155
4290
|
ctx.logger.error("dsh-codearts: loopback shim failed to start; provider not registered", error);
|
|
4156
4291
|
});
|
|
4292
|
+
let startupTimedOut = false;
|
|
4157
4293
|
await Promise.race([settled, new Promise((resolve) => {
|
|
4158
|
-
setTimeout(
|
|
4294
|
+
setTimeout(() => {
|
|
4295
|
+
startupTimedOut = true;
|
|
4296
|
+
resolve();
|
|
4297
|
+
}, STARTUP_WAIT_MS).unref?.();
|
|
4159
4298
|
})]);
|
|
4299
|
+
if (startupTimedOut) ctx.logger.warn(`dsh-codearts: 启动等待超时(阶段 ${startup.stage},provider ${startup.registered ? "已注册" : "尚未注册"}),引导链继续在后台执行;可打开设置卡片查看体检,或读取 /api/codearts/doctor 自查`);
|
|
4160
4300
|
}
|
|
4161
4301
|
//#endregion
|
|
4162
4302
|
export { BENEFIT_GATEWAY_HOST, CODEARTS_PROVIDER, CODEARTS_SETTINGS_NS, CodeArtsAccountPool, CodeArtsAccountStore, CodeArtsCatalog, CodeArtsCredentialStore, CodeArtsCreditCache, CodeArtsUsageTracker, Config, FALLBACK_CODEARTS_MODELS, SNAP_HOST, apply, canonicalModel, chatStream, codeartsAccountsPath, codeartsAuthPath, codeartsUsagePath, createCodeArtsAdapter, createCodeArtsShim, discoverModels, fetchCredits, fetchModels, filterEnabledModels, inject, maxTokensCeilingFor, name, parseCreditStatistics, parseTokenBalance, prepareChatBody, refreshCatalog };
|
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-qnSuuDGW.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";
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { n as __exportAll } from "./rolldown-runtime-B4iAMlE-.mjs";
|
|
2
2
|
import { createHash, createHmac, randomBytes } from "node:crypto";
|
|
3
|
+
import { request } from "node:http";
|
|
4
|
+
import { request as request$1 } from "node:https";
|
|
5
|
+
import { Readable } from "node:stream";
|
|
3
6
|
//#region src/catalog.ts
|
|
4
7
|
/**
|
|
5
8
|
* 参数表(不是模型名单):只给**发现到的**模型补 `contextWindow` / `maxTokens` /
|
|
@@ -545,6 +548,7 @@ function signRequest(req, body, cred) {
|
|
|
545
548
|
var upstream_exports = /* @__PURE__ */ __exportAll({
|
|
546
549
|
BENEFIT_MISSING_CODE: () => BENEFIT_MISSING_CODE,
|
|
547
550
|
CONCURRENCY_CAP_CODE: () => CONCURRENCY_CAP_CODE,
|
|
551
|
+
CREDIT_EXHAUSTED_CODE: () => CREDIT_EXHAUSTED_CODE,
|
|
548
552
|
MAX_TOKENS_CEILING: () => MAX_TOKENS_CEILING,
|
|
549
553
|
MAX_TOKENS_FLOOR: () => MAX_TOKENS_FLOOR,
|
|
550
554
|
PARAM_INVALID_CODE: () => PARAM_INVALID_CODE,
|
|
@@ -568,6 +572,7 @@ var upstream_exports = /* @__PURE__ */ __exportAll({
|
|
|
568
572
|
isBenefitMissing: () => isBenefitMissing,
|
|
569
573
|
isConcurrencyCap: () => isConcurrencyCap,
|
|
570
574
|
isContextOverflowText: () => isContextOverflowText,
|
|
575
|
+
isCreditExhausted: () => isCreditExhausted,
|
|
571
576
|
isIamTokenError: () => isIamTokenError,
|
|
572
577
|
isModelNotAccessible: () => isModelNotAccessible,
|
|
573
578
|
isNotMultimodal: () => isNotMultimodal,
|
|
@@ -1246,12 +1251,27 @@ function upstreamErrorMessage(message, status = 0) {
|
|
|
1246
1251
|
return `${inner === "" ? "上游提示请求量较大、需要排队。" : inner} 插件已在本地排队重试,仍未轮到,请稍后重试或临时切换模型。`;
|
|
1247
1252
|
}
|
|
1248
1253
|
if (isIamTokenError(message)) return "上游判定本次登录凭据(IAM token)已失效。插件已尝试自动续期;若反复出现,请到设置卡片重新登录。";
|
|
1254
|
+
if (isCreditExhausted(message)) return "该账号的 CodeArts 积分已耗尽(上游 TM.00001050)。积分按账号独立计算、不能跨号挪用:多账号时到这个号的冷却结束或暂停它即可,积分周期刷新/领取活动积分后自动恢复。";
|
|
1249
1255
|
if (isModelNotAccessible(message)) return "上游说这个模型不存在或当前账号没有权限(可能已下线或改名)。请刷新模型列表后换一个模型;换号没有用,这是模型级的限制。";
|
|
1250
1256
|
if (isNotMultimodal(message)) return "这个模型不支持图片输入(上游 406)。请移除消息里的图片,或改用支持识图的模型。";
|
|
1251
1257
|
if (message.toLowerCase().includes("model is not registered")) return "上游没有注册这个模型,它可能已经下线;请刷新模型列表后重选。";
|
|
1252
1258
|
return `codearts 上游错误 (http ${status}): ${message.slice(0, 400)}`;
|
|
1253
1259
|
}
|
|
1254
1260
|
/**
|
|
1261
|
+
* 「这个账号的套餐积分已耗尽」。
|
|
1262
|
+
*
|
|
1263
|
+
* 2026-11-25 实测(issue #20):上游回 HTTP 400 + body
|
|
1264
|
+
* `{"text":"[DONE]","error_code":"TM.00001050","error_msg":"您的积分已耗尽…"}`;
|
|
1265
|
+
* 同一错误也可能以**流内首帧**(HTTP 200)出现,所以两条路都要认。
|
|
1266
|
+
*
|
|
1267
|
+
* 它是**确定不可恢复的单号属性**:积分是账号级的,不能跨号挪用,重发同一个号
|
|
1268
|
+
* 只会再撞一次。处置和 iam_stale 一样 —— 换下一个号,并把这个号冷却足够久。
|
|
1269
|
+
*/
|
|
1270
|
+
const CREDIT_EXHAUSTED_CODE = "TM.00001050";
|
|
1271
|
+
function isCreditExhausted(text) {
|
|
1272
|
+
return text.includes("TM.00001050") || text.includes("积分已耗尽");
|
|
1273
|
+
}
|
|
1274
|
+
/**
|
|
1255
1275
|
* 「这个账号当前没有该模型的限时福利权益」。2026-10-21 实测:上游回 HTTP 200,
|
|
1256
1276
|
* 错误在**流内帧**里(不在状态码上),所以它既不走 retry 也不走换号,用户看到的
|
|
1257
1277
|
* 就是正文里裸裸一句 `benefit not found`。
|
|
@@ -1336,6 +1356,7 @@ function classify(status, message) {
|
|
|
1336
1356
|
if (isResignRefusal(message)) return "client";
|
|
1337
1357
|
if (isIamTokenError(message)) return "iam_stale";
|
|
1338
1358
|
if (isModelNotAccessible(message)) return "not_found";
|
|
1359
|
+
if (isCreditExhausted(message)) return "hard_credit";
|
|
1339
1360
|
if (status === 401 || status === 403) return "session_dead";
|
|
1340
1361
|
if (status === 402) return "hard_credit";
|
|
1341
1362
|
if (status === 429) return "soft_rate";
|
|
@@ -1366,12 +1387,63 @@ async function dispatch(req, body, signal) {
|
|
|
1366
1387
|
req.headers.forEach((value, key) => {
|
|
1367
1388
|
headers[key] = value;
|
|
1368
1389
|
});
|
|
1369
|
-
|
|
1390
|
+
const res = await fetch(req.url, {
|
|
1370
1391
|
method: req.method,
|
|
1371
1392
|
headers,
|
|
1372
1393
|
...body === void 0 ? {} : { body },
|
|
1373
1394
|
...signal === void 0 ? {} : { signal }
|
|
1374
1395
|
});
|
|
1396
|
+
if (!isNeighborGateRefusal(res)) return res;
|
|
1397
|
+
await res.body?.cancel().catch(() => {});
|
|
1398
|
+
return dispatchDirect(req.url, req.method, headers, body, signal);
|
|
1399
|
+
}
|
|
1400
|
+
/**
|
|
1401
|
+
* billion-context 这类宿主层压缩代理会**在本地**拒收「不属于 bili 会话、又超过
|
|
1402
|
+
* 静默直连字节上限」的请求(实测上限 8 MiB),回 422 + `x-bili-gate:
|
|
1403
|
+
* oversize-refusal*`,根本没出网(issue #23)。它的拦截只挂在 `globalThis.fetch`
|
|
1404
|
+
* 上,所以收到这个标记时换一份自己的 node:http(s) 连接直发 —— 签名与请求体
|
|
1405
|
+
* 都不变,只是不再经过这层代理。
|
|
1406
|
+
*
|
|
1407
|
+
* 只认它自己的标记头:真正的上游 422 不带这个头,照常按 no_live_state 等
|
|
1408
|
+
* 分类处理。
|
|
1409
|
+
*/
|
|
1410
|
+
function isNeighborGateRefusal(res) {
|
|
1411
|
+
if (res.status !== 422) return false;
|
|
1412
|
+
return (res.headers.get("x-bili-gate") ?? "").startsWith("oversize-refusal");
|
|
1413
|
+
}
|
|
1414
|
+
/** 绕开 `globalThis.fetch` 的直连发送;响应流原样转成 web Response。 */
|
|
1415
|
+
function dispatchDirect(url, method, headers, body, signal) {
|
|
1416
|
+
const target = new URL(url);
|
|
1417
|
+
const send = target.protocol === "http:" ? request : request$1;
|
|
1418
|
+
return new Promise((resolve, reject) => {
|
|
1419
|
+
if (signal?.aborted === true) {
|
|
1420
|
+
reject(/* @__PURE__ */ new Error("This operation was aborted"));
|
|
1421
|
+
return;
|
|
1422
|
+
}
|
|
1423
|
+
const req = send(target, {
|
|
1424
|
+
method,
|
|
1425
|
+
headers
|
|
1426
|
+
}, (res) => {
|
|
1427
|
+
const stream = Readable.toWeb(res);
|
|
1428
|
+
resolve(new Response(stream, {
|
|
1429
|
+
status: res.statusCode ?? 502,
|
|
1430
|
+
headers: res.headers
|
|
1431
|
+
}));
|
|
1432
|
+
});
|
|
1433
|
+
const onAbort = () => {
|
|
1434
|
+
const error = /* @__PURE__ */ new Error("This operation was aborted");
|
|
1435
|
+
error.name = "AbortError";
|
|
1436
|
+
req.destroy(error);
|
|
1437
|
+
};
|
|
1438
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
1439
|
+
req.on("error", (error) => {
|
|
1440
|
+
signal?.removeEventListener("abort", onAbort);
|
|
1441
|
+
reject(error);
|
|
1442
|
+
});
|
|
1443
|
+
req.on("close", () => signal?.removeEventListener("abort", onAbort));
|
|
1444
|
+
if (body !== void 0) req.write(body);
|
|
1445
|
+
req.end();
|
|
1446
|
+
});
|
|
1375
1447
|
}
|
|
1376
1448
|
const enc = new TextEncoder();
|
|
1377
1449
|
function openAIData(obj) {
|
|
@@ -2270,4 +2342,4 @@ async function claimDailyWelfare(credential, signal) {
|
|
|
2270
2342
|
};
|
|
2271
2343
|
}
|
|
2272
2344
|
//#endregion
|
|
2273
|
-
export {
|
|
2345
|
+
export { setDiscoveredBenefitModels as $, overrideValueFor as A, CodeArtsCatalog as B, isQueueableRate as C, learnedContextWindowFor as D, learnContextWindow as E, setMaxTokenOverride as F, filterEnabledModels as G, carryKnownWindows as H, setMaxTokenOverrides as I, isBenefitModel as J, forgetModelUnavailable as K, signedGet as L, prepareChatBody as M, queueFrame as N, maxTokensCeilingFor as O, rateLimitFrame as P, modelUnavailableReason as Q, upstreamErrorMessage as R, isQueueRejectText as S, isWelfareClaimedStatus as T, clearBenefitBlocked as U, FALLBACK_CODEARTS_MODELS as V, creditRatioLabel as W, mergeModelLists as X, markModelUnavailable as Y, modelDisplayName as Z, isIamTokenError as _, claimDailyWelfare as a, isParamInvalidFrame as b, degradeTokenCeiling as c, fetchQueueStatus as d, withContextWindowOverride as et, fetchWelfareCampaigns as f, isCreditExhausted as g, isContextOverflowText as h, chatStream as i, pickDailyWelfareCampaign as j, modelUnavailableReasonText as k, fetchCallerIdentity as l, isConcurrencyCap as m, SNAP_HOST as n, clearQueueStatus as o, firstFrameError as p, isBenefitBlocked as q, canonicalModel as r, contextWindowOverrideFor as s, MAX_TOKENS_FLOOR as t, withMaxTokensOverride as tt, fetchModels as u, isModelNotAccessible as v, isTpmLimit as w, isQueueReject as x, isNotMultimodal as y, upstream_exports as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { u as writeJsonAtomic } from "./auth-
|
|
2
|
-
import {
|
|
1
|
+
import { u as writeJsonAtomic } from "./auth-qnSuuDGW.mjs";
|
|
2
|
+
import { $ as setDiscoveredBenefitModels, H as carryKnownWindows, J as isBenefitModel, X as mergeModelLists, Z as modelDisplayName, u as fetchModels } from "./upstream-D1NN-sbL.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.15";
|
|
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.15",
|
|
6
6
|
"packageManager": "pnpm@11.24.0",
|
|
7
7
|
"author": "elegant01",
|
|
8
8
|
"keywords": [
|