dsh-codearts 1.4.6 → 1.4.7
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 +19 -0
- package/lib/{auth-q6MY-TXM.mjs → auth-BRlNY6dB.mjs} +1 -1
- package/lib/bin.mjs +3 -3
- package/lib/client/index.js +105 -105
- package/lib/index.d.mts +1 -1
- package/lib/index.mjs +39 -17
- package/lib/keeper-main.mjs +1 -1
- package/lib/{upstream-COqsw56c.mjs → upstream-CgQXomCI.mjs} +29 -1
- package/lib/{version-BZuhJ6R9.mjs → version-DNEBIi8C.mjs} +6 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
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.7] - 2026-11-20
|
|
7
|
+
|
|
8
|
+
### 修复
|
|
9
|
+
|
|
10
|
+
- **「成功但不完整」的一轮发现不再把已知上下文窗口降级**(#12):发现是逐路并行
|
|
11
|
+
的,某一路(如企业租户 thirdparty)瞬时失败时,同一模型仍可能由别的路返回,但
|
|
12
|
+
不带 `contextWindow`,于是被 32768 兜底值覆盖,而且一直错到下一轮完整发现 ——
|
|
13
|
+
长会话在 400 context_overflow 上反复失败。现在提交前按 id 回查上一轮目录:本轮
|
|
14
|
+
没拿到可信窗口的记录沿用上一轮的值(`contextWindowKnown` 与标称值一起带过去),
|
|
15
|
+
本轮已可信的值不动,上游下架的模型照常消失。
|
|
16
|
+
- **无头 / 一次性进程启动时模型列表不再为空**(#13):`apply` 以前是同步函数,
|
|
17
|
+
模型发现与 provider 注册都在它返回之后的异步链里,而宿主只等 `apply` 的返回值 ——
|
|
18
|
+
`--list-models`、headless 任务、平台的本机运行时在 profile 加载完立刻下结论,
|
|
19
|
+
拿到空目录(`has no configured model`)且零日志。现在 `apply` 等待「shim 就绪 →
|
|
20
|
+
首轮发现 → 注册」整条链,首轮发现 10 秒超时、启动总预算 15 秒,超时按空目录继续
|
|
21
|
+
并告警,不会拖死启动;目录为空注册时补一条 `warn`。
|
|
22
|
+
- 首次发现不再多打一轮上游:启动引导跑完首轮后由退避循环接棒,而不是循环自己
|
|
23
|
+
立刻再发现一次。
|
|
24
|
+
|
|
6
25
|
## [1.4.6] - 2026-11-18
|
|
7
26
|
|
|
8
27
|
### 新增
|
|
@@ -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-CgQXomCI.mjs").then((n) => n.P);
|
|
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-BRlNY6dB.mjs";
|
|
3
|
+
import { U as isBenefitModel, l as fetchCallerIdentity } from "./upstream-CgQXomCI.mjs";
|
|
4
|
+
import { i as discoverModels, n as CodeArtsUsageTracker, r as codeartsUsagePath, t as CODEARTS_VERSION } from "./version-DNEBIi8C.mjs";
|
|
5
5
|
import { existsSync, statSync } from "node:fs";
|
|
6
6
|
//#region src/bin.ts
|
|
7
7
|
/**
|
package/lib/client/index.js
CHANGED
|
@@ -156,123 +156,123 @@ if (typeof document !== "undefined" && document.querySelector("style[data-plugin
|
|
|
156
156
|
document.head.appendChild(tag);
|
|
157
157
|
}
|
|
158
158
|
var CodeArtsPluginCard_module_css_default = {
|
|
159
|
-
"
|
|
160
|
-
"windowHint": "xoziZG_windowHint",
|
|
161
|
-
"creditRows": "xoziZG_creditRows",
|
|
162
|
-
"windowButton": "xoziZG_windowButton",
|
|
163
|
-
"creditFooter": "xoziZG_creditFooter",
|
|
164
|
-
"skeletonBreath": "xoziZG_skeletonBreath",
|
|
159
|
+
"expiryRow": "xoziZG_expiryRow",
|
|
165
160
|
"accountInfo": "xoziZG_accountInfo",
|
|
166
|
-
"
|
|
167
|
-
"
|
|
168
|
-
"
|
|
161
|
+
"sectionHead": "xoziZG_sectionHead",
|
|
162
|
+
"accountHint": "xoziZG_accountHint",
|
|
163
|
+
"modelRow": "xoziZG_modelRow",
|
|
164
|
+
"accountName": "xoziZG_accountName",
|
|
165
|
+
"accountMenuAnchor": "xoziZG_accountMenuAnchor",
|
|
166
|
+
"usageBar": "xoziZG_usageBar",
|
|
167
|
+
"barFill": "xoziZG_barFill",
|
|
168
|
+
"actions": "xoziZG_actions",
|
|
169
|
+
"modelChart": "xoziZG_modelChart",
|
|
170
|
+
"accountToggle": "xoziZG_accountToggle",
|
|
171
|
+
"desc": "xoziZG_desc",
|
|
172
|
+
"accountEntry": "xoziZG_accountEntry",
|
|
173
|
+
"modelShare": "xoziZG_modelShare",
|
|
174
|
+
"doctorName": "xoziZG_doctorName",
|
|
175
|
+
"accountCard": "xoziZG_accountCard",
|
|
176
|
+
"modelRequests": "xoziZG_modelRequests",
|
|
177
|
+
"balanceUnit": "xoziZG_balanceUnit",
|
|
169
178
|
"groupHead": "xoziZG_groupHead",
|
|
170
|
-
"
|
|
171
|
-
"
|
|
172
|
-
"
|
|
179
|
+
"statGrid": "xoziZG_statGrid",
|
|
180
|
+
"accountRow": "xoziZG_accountRow",
|
|
181
|
+
"statCard": "xoziZG_statCard",
|
|
182
|
+
"modelName": "xoziZG_modelName",
|
|
173
183
|
"heatGrid": "xoziZG_heatGrid",
|
|
184
|
+
"heatLegendChip": "xoziZG_heatLegendChip",
|
|
185
|
+
"manualSummary": "xoziZG_manualSummary",
|
|
186
|
+
"statusLine": "xoziZG_statusLine",
|
|
187
|
+
"check": "xoziZG_check",
|
|
188
|
+
"balance": "xoziZG_balance",
|
|
189
|
+
"expiryLabel": "xoziZG_expiryLabel",
|
|
190
|
+
"usageTipName": "xoziZG_usageTipName",
|
|
191
|
+
"skeletonBreath": "xoziZG_skeletonBreath",
|
|
192
|
+
"headText": "xoziZG_headText",
|
|
193
|
+
"creditRows": "xoziZG_creditRows",
|
|
194
|
+
"windowButton": "xoziZG_windowButton",
|
|
195
|
+
"groupLabel": "xoziZG_groupLabel",
|
|
174
196
|
"sectionLabel": "xoziZG_sectionLabel",
|
|
175
|
-
"
|
|
197
|
+
"modelTokens": "xoziZG_modelTokens",
|
|
198
|
+
"modelSpec": "xoziZG_modelSpec",
|
|
199
|
+
"body": "xoziZG_body",
|
|
176
200
|
"creditHint": "xoziZG_creditHint",
|
|
177
|
-
"
|
|
178
|
-
"
|
|
201
|
+
"danger": "xoziZG_danger",
|
|
202
|
+
"statLabel": "xoziZG_statLabel",
|
|
203
|
+
"creditBlock": "xoziZG_creditBlock",
|
|
179
204
|
"count": "xoziZG_count",
|
|
180
|
-
"
|
|
181
|
-
"
|
|
182
|
-
"
|
|
183
|
-
"
|
|
205
|
+
"doctorRow": "xoziZG_doctorRow",
|
|
206
|
+
"link": "xoziZG_link",
|
|
207
|
+
"accountMenuItem": "xoziZG_accountMenuItem",
|
|
208
|
+
"usageTipRow": "xoziZG_usageTipRow",
|
|
209
|
+
"windowHint": "xoziZG_windowHint",
|
|
210
|
+
"hint": "xoziZG_hint",
|
|
211
|
+
"accountGrid": "xoziZG_accountGrid",
|
|
212
|
+
"fieldLabel": "xoziZG_fieldLabel",
|
|
213
|
+
"windowPopoverValue": "xoziZG_windowPopoverValue",
|
|
214
|
+
"accountNameRow": "xoziZG_accountNameRow",
|
|
215
|
+
"heatCell": "xoziZG_heatCell",
|
|
216
|
+
"heatAxis": "xoziZG_heatAxis",
|
|
217
|
+
"field": "xoziZG_field",
|
|
218
|
+
"header": "xoziZG_header",
|
|
219
|
+
"accountMenu": "xoziZG_accountMenu",
|
|
220
|
+
"section": "xoziZG_section",
|
|
221
|
+
"manualForm": "xoziZG_manualForm",
|
|
222
|
+
"groupHeadFirst": "xoziZG_groupHeadFirst",
|
|
184
223
|
"statSub": "xoziZG_statSub",
|
|
185
|
-
"
|
|
186
|
-
"
|
|
187
|
-
"statValue": "xoziZG_statValue",
|
|
188
|
-
"heatHourCell": "xoziZG_heatHourCell",
|
|
224
|
+
"tabs": "xoziZG_tabs",
|
|
225
|
+
"modelTrack": "xoziZG_modelTrack",
|
|
189
226
|
"modelCheck": "xoziZG_modelCheck",
|
|
227
|
+
"windowPopover": "xoziZG_windowPopover",
|
|
228
|
+
"windowRange": "xoziZG_windowRange",
|
|
229
|
+
"manual": "xoziZG_manual",
|
|
230
|
+
"windowInputSet": "xoziZG_windowInputSet",
|
|
231
|
+
"usageTip": "xoziZG_usageTip",
|
|
232
|
+
"area": "xoziZG_area",
|
|
233
|
+
"accountRowActions": "xoziZG_accountRowActions",
|
|
234
|
+
"windowAnchor": "xoziZG_windowAnchor",
|
|
235
|
+
"claimAllRow": "xoziZG_claimAllRow",
|
|
236
|
+
"heatHourCell": "xoziZG_heatHourCell",
|
|
237
|
+
"accountToolbar": "xoziZG_accountToolbar",
|
|
190
238
|
"usageFill": "xoziZG_usageFill",
|
|
239
|
+
"accountClearHint": "xoziZG_accountClearHint",
|
|
240
|
+
"creditLink": "xoziZG_creditLink",
|
|
241
|
+
"doctorList": "xoziZG_doctorList",
|
|
242
|
+
"heatHours": "xoziZG_heatHours",
|
|
243
|
+
"modelMeta": "xoziZG_modelMeta",
|
|
244
|
+
"windowUnit": "xoziZG_windowUnit",
|
|
245
|
+
"choiceTail": "xoziZG_choiceTail",
|
|
246
|
+
"name": "xoziZG_name",
|
|
191
247
|
"windowPopoverHead": "xoziZG_windowPopoverHead",
|
|
248
|
+
"choiceRow": "xoziZG_choiceRow",
|
|
249
|
+
"accountClear": "xoziZG_accountClear",
|
|
250
|
+
"skeleton": "xoziZG_skeleton",
|
|
192
251
|
"meta": "xoziZG_meta",
|
|
193
|
-
"
|
|
194
|
-
"
|
|
195
|
-
"
|
|
196
|
-
"desc": "xoziZG_desc",
|
|
197
|
-
"updated": "xoziZG_updated",
|
|
198
|
-
"windowPopover": "xoziZG_windowPopover",
|
|
199
|
-
"windowInput": "xoziZG_windowInput",
|
|
200
|
-
"modelSpec": "xoziZG_modelSpec",
|
|
201
|
-
"danger": "xoziZG_danger",
|
|
202
|
-
"modelName": "xoziZG_modelName",
|
|
203
|
-
"heatAxisSlot": "xoziZG_heatAxisSlot",
|
|
204
|
-
"check": "xoziZG_check",
|
|
205
|
-
"tabs": "xoziZG_tabs",
|
|
206
|
-
"header": "xoziZG_header",
|
|
207
|
-
"doctorRow": "xoziZG_doctorRow",
|
|
252
|
+
"heatLegend": "xoziZG_heatLegend",
|
|
253
|
+
"card": "xoziZG_card",
|
|
254
|
+
"windowPopoverRow": "xoziZG_windowPopoverRow",
|
|
208
255
|
"balanceMeta": "xoziZG_balanceMeta",
|
|
209
256
|
"error": "xoziZG_error",
|
|
210
|
-
"
|
|
211
|
-
"
|
|
212
|
-
"
|
|
213
|
-
"modelRequests": "xoziZG_modelRequests",
|
|
214
|
-
"statusLine": "xoziZG_statusLine",
|
|
215
|
-
"manualForm": "xoziZG_manualForm",
|
|
216
|
-
"accountCard": "xoziZG_accountCard",
|
|
217
|
-
"skeletonRow": "xoziZG_skeletonRow",
|
|
218
|
-
"accountRow": "xoziZG_accountRow",
|
|
219
|
-
"hint": "xoziZG_hint",
|
|
220
|
-
"creditBlock": "xoziZG_creditBlock",
|
|
221
|
-
"usageBar": "xoziZG_usageBar",
|
|
257
|
+
"heatWeekday": "xoziZG_heatWeekday",
|
|
258
|
+
"heatAxisSlot": "xoziZG_heatAxisSlot",
|
|
259
|
+
"balanceRow": "xoziZG_balanceRow",
|
|
222
260
|
"usageTipSep": "xoziZG_usageTipSep",
|
|
261
|
+
"avatar": "xoziZG_avatar",
|
|
262
|
+
"choices": "xoziZG_choices",
|
|
263
|
+
"skeletonRow": "xoziZG_skeletonRow",
|
|
223
264
|
"trendTip": "xoziZG_trendTip",
|
|
224
|
-
"
|
|
225
|
-
"
|
|
226
|
-
"accountMenuAnchor": "xoziZG_accountMenuAnchor",
|
|
227
|
-
"accountMenuItem": "xoziZG_accountMenuItem",
|
|
228
|
-
"modelRow": "xoziZG_modelRow",
|
|
229
|
-
"accountToolbar": "xoziZG_accountToolbar",
|
|
230
|
-
"heatAxis": "xoziZG_heatAxis",
|
|
231
|
-
"creditRow": "xoziZG_creditRow",
|
|
232
|
-
"statCard": "xoziZG_statCard",
|
|
233
|
-
"windowButtonOpen": "xoziZG_windowButtonOpen",
|
|
234
|
-
"modelShare": "xoziZG_modelShare",
|
|
235
|
-
"statLabel": "xoziZG_statLabel",
|
|
236
|
-
"modelChart": "xoziZG_modelChart",
|
|
237
|
-
"accountEntry": "xoziZG_accountEntry",
|
|
238
|
-
"heatHours": "xoziZG_heatHours",
|
|
239
|
-
"creditLink": "xoziZG_creditLink",
|
|
240
|
-
"fieldLabel": "xoziZG_fieldLabel",
|
|
241
|
-
"groupLabel": "xoziZG_groupLabel",
|
|
242
|
-
"bar": "xoziZG_bar",
|
|
243
|
-
"body": "xoziZG_body",
|
|
265
|
+
"updated": "xoziZG_updated",
|
|
266
|
+
"windowCaret": "xoziZG_windowCaret",
|
|
244
267
|
"tabPanel": "xoziZG_tabPanel",
|
|
245
|
-
"
|
|
246
|
-
"
|
|
247
|
-
"
|
|
248
|
-
"
|
|
249
|
-
"
|
|
250
|
-
"
|
|
251
|
-
"barFill": "xoziZG_barFill",
|
|
252
|
-
"link": "xoziZG_link",
|
|
268
|
+
"creditFooter": "xoziZG_creditFooter",
|
|
269
|
+
"windowButtonSet": "xoziZG_windowButtonSet",
|
|
270
|
+
"bar": "xoziZG_bar",
|
|
271
|
+
"windowButtonOpen": "xoziZG_windowButtonOpen",
|
|
272
|
+
"windowInput": "xoziZG_windowInput",
|
|
273
|
+
"creditRow": "xoziZG_creditRow",
|
|
253
274
|
"modelFill": "xoziZG_modelFill",
|
|
254
|
-
"
|
|
255
|
-
"accountMenu": "xoziZG_accountMenu",
|
|
256
|
-
"heatWeekday": "xoziZG_heatWeekday",
|
|
257
|
-
"actions": "xoziZG_actions",
|
|
258
|
-
"modelTokens": "xoziZG_modelTokens",
|
|
259
|
-
"heatCell": "xoziZG_heatCell",
|
|
260
|
-
"section": "xoziZG_section",
|
|
261
|
-
"windowInputSet": "xoziZG_windowInputSet",
|
|
262
|
-
"choices": "xoziZG_choices",
|
|
263
|
-
"windowPopoverValue": "xoziZG_windowPopoverValue",
|
|
264
|
-
"windowCaret": "xoziZG_windowCaret",
|
|
265
|
-
"field": "xoziZG_field",
|
|
266
|
-
"doctorName": "xoziZG_doctorName",
|
|
267
|
-
"choiceRow": "xoziZG_choiceRow",
|
|
268
|
-
"headText": "xoziZG_headText",
|
|
269
|
-
"usageTipName": "xoziZG_usageTipName",
|
|
270
|
-
"doctorList": "xoziZG_doctorList",
|
|
271
|
-
"statGrid": "xoziZG_statGrid",
|
|
272
|
-
"accountToggle": "xoziZG_accountToggle",
|
|
273
|
-
"expiryLabel": "xoziZG_expiryLabel",
|
|
274
|
-
"groupHeadFirst": "xoziZG_groupHeadFirst",
|
|
275
|
-
"skeleton": "xoziZG_skeleton"
|
|
275
|
+
"statValue": "xoziZG_statValue"
|
|
276
276
|
};
|
|
277
277
|
//#endregion
|
|
278
278
|
//#region src/client/CodeArtsPluginCard.tsx
|
|
@@ -3289,14 +3289,14 @@ if (typeof document !== "undefined" && document.querySelector("style[data-plugin
|
|
|
3289
3289
|
document.head.appendChild(tag);
|
|
3290
3290
|
}
|
|
3291
3291
|
var CodeArtsPanel_module_css_default = {
|
|
3292
|
-
"back": "Z66cgG_back",
|
|
3293
|
-
"title": "Z66cgG_title",
|
|
3294
3292
|
"body": "Z66cgG_body",
|
|
3295
3293
|
"page": "Z66cgG_page",
|
|
3296
|
-
"icon": "Z66cgG_icon",
|
|
3297
|
-
"desc": "Z66cgG_desc",
|
|
3298
3294
|
"head": "Z66cgG_head",
|
|
3299
|
-
"backCaret": "Z66cgG_backCaret"
|
|
3295
|
+
"backCaret": "Z66cgG_backCaret",
|
|
3296
|
+
"title": "Z66cgG_title",
|
|
3297
|
+
"desc": "Z66cgG_desc",
|
|
3298
|
+
"icon": "Z66cgG_icon",
|
|
3299
|
+
"back": "Z66cgG_back"
|
|
3300
3300
|
};
|
|
3301
3301
|
//#endregion
|
|
3302
3302
|
//#region src/client/CodeArtsPanel.tsx
|
package/lib/index.d.mts
CHANGED
|
@@ -1923,6 +1923,6 @@ interface Config {
|
|
|
1923
1923
|
queueWaitUntilReady?: boolean;
|
|
1924
1924
|
}
|
|
1925
1925
|
declare const Config: z<Config>;
|
|
1926
|
-
declare function apply(ctx: Context, rawConfig: Config): void
|
|
1926
|
+
declare function apply(ctx: Context, rawConfig: Config): Promise<void>;
|
|
1927
1927
|
//#endregion
|
|
1928
1928
|
export { type AccountRuntime, BENEFIT_GATEWAY_HOST, CODEARTS_PROVIDER, CODEARTS_SETTINGS_NS, CodeArtsAccountPool, CodeArtsAccountStore, type CodeArtsAccountSummary, type CodeArtsAdapter, CodeArtsCatalog, type CodeArtsCredential, CodeArtsCredentialStore, CodeArtsCreditCache, type CodeArtsCreditCategory, type CodeArtsCreditSnapshot, type CodeArtsCreditState, type CodeArtsCredits, type CodeArtsModelInfo, type CodeArtsShim, type CodeArtsTokenQuota, CodeArtsUsageTracker, Config, type DiscoveryOutcome, FALLBACK_CODEARTS_MODELS, type ModelDiscoveryResult, SNAP_HOST, type UpstreamErrorKind, type UsageSnapshot, type UsageTotals, apply, canonicalModel, chatStream, codeartsAccountsPath, codeartsAuthPath, codeartsUsagePath, createCodeArtsAdapter, createCodeArtsShim, discoverModels, fetchCredits, fetchModels, filterEnabledModels, inject, maxTokensCeilingFor, name, parseCreditStatistics, parseTokenBalance, prepareChatBody, refreshCatalog };
|
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 queueFrame, B as
|
|
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-BRlNY6dB.mjs";
|
|
2
|
+
import { A as queueFrame, B as filterEnabledModels, C as isWelfareClaimedStatus, D as modelUnavailableReasonText, E as maxTokensCeilingFor, F as CodeArtsCatalog, H as isBenefitBlocked, I as FALLBACK_CODEARTS_MODELS, M as signedGet, N as upstreamErrorMessage, O as pickDailyWelfareCampaign, R as clearBenefitBlocked, S as isTpmLimit, T as learnedContextWindowFor, U as isBenefitModel, V as forgetModelUnavailable, W as markModelUnavailable, _ 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 rateLimitFrame, k as prepareChatBody, l as fetchCallerIdentity, m as isConcurrencyCap, n as SNAP_HOST, o as clearQueueStatus, p as firstFrameError, q as modelUnavailableReason, 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 creditRatioLabel } from "./upstream-CgQXomCI.mjs";
|
|
3
|
+
import { a as refreshCatalog, i as discoverModels, n as CodeArtsUsageTracker, r as codeartsUsagePath, t as CODEARTS_VERSION } from "./version-DNEBIi8C.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";
|
|
@@ -3138,7 +3138,7 @@ const Config = z.object({
|
|
|
3138
3138
|
function settingsCompatNamespace(ctx) {
|
|
3139
3139
|
return resolveSettingsNamespaceCompat(ctx, ctx.get("settings"), CODEARTS_SETTINGS_NS);
|
|
3140
3140
|
}
|
|
3141
|
-
function apply(ctx, rawConfig) {
|
|
3141
|
+
async function apply(ctx, rawConfig) {
|
|
3142
3142
|
const config = unwrapConfig(rawConfig);
|
|
3143
3143
|
const accountsPath = codeartsAccountsPath();
|
|
3144
3144
|
/**
|
|
@@ -3542,11 +3542,22 @@ function apply(ctx, rawConfig) {
|
|
|
3542
3542
|
const CATALOG_REFRESH_MS = 36e5;
|
|
3543
3543
|
const CATALOG_EMPTY_RETRY_MS = 6e4;
|
|
3544
3544
|
const CATALOG_EMPTY_RETRY_MAX_MS = 3e5;
|
|
3545
|
+
/**
|
|
3546
|
+
* 启动首轮发现的预算(issue #13)。
|
|
3547
|
+
*
|
|
3548
|
+
* 一次性宿主(`--list-models`、`dsh headless`、Multica 的本机运行时)在 profile
|
|
3549
|
+
* 加载完就列模型 / 解析模型,等不到后台的任何一轮重试 —— 目录空就是定论。所以
|
|
3550
|
+
* 首轮发现要挡在注册之前、并让 `apply` 等它。但上游挂住时不能把启动一起拖死:
|
|
3551
|
+
* 超时按空目录继续注册,循环随后照常补。手动刷新那条路是 60s,启动不能照抄。
|
|
3552
|
+
*/
|
|
3553
|
+
const STARTUP_DISCOVERY_MS = 1e4;
|
|
3554
|
+
/** 启动引导的总预算:发现另有 10s 自己的预算,这里防的是 shim 启动 / probe 卡住。 */
|
|
3555
|
+
const STARTUP_WAIT_MS = 15e3;
|
|
3545
3556
|
const abort = new AbortController();
|
|
3546
|
-
const discover = async () => {
|
|
3557
|
+
const discover = async (signal = abort.signal) => {
|
|
3547
3558
|
if (stopped) return;
|
|
3548
3559
|
try {
|
|
3549
|
-
const outcome = await refreshCatalog(store, catalog,
|
|
3560
|
+
const outcome = await refreshCatalog(store, catalog, signal, current().contextWindowOverrides);
|
|
3550
3561
|
if (outcome === void 0 || stopped) return;
|
|
3551
3562
|
if (outcome.anySucceeded) {
|
|
3552
3563
|
const free = outcome.models.filter((model) => model.benefit === true).length;
|
|
@@ -3559,21 +3570,26 @@ function apply(ctx, rawConfig) {
|
|
|
3559
3570
|
let discoveryTimer;
|
|
3560
3571
|
/** 连续多少轮目录是空的(用来算退避);一旦有货就归零。 */
|
|
3561
3572
|
let emptyStreak = 0;
|
|
3562
|
-
/**
|
|
3563
|
-
const
|
|
3564
|
-
await discover();
|
|
3565
|
-
if (stopped) return;
|
|
3566
|
-
let delay;
|
|
3573
|
+
/** 下一轮发现该隔多久:目录为空时退避(60s → 5min 封顶),有货后回到每小时。 */
|
|
3574
|
+
const nextDiscoveryDelay = () => {
|
|
3567
3575
|
if (catalog.current().length === 0) {
|
|
3568
|
-
delay = Math.min(CATALOG_EMPTY_RETRY_MS * 2 ** emptyStreak, CATALOG_EMPTY_RETRY_MAX_MS);
|
|
3576
|
+
const delay = Math.min(CATALOG_EMPTY_RETRY_MS * 2 ** emptyStreak, CATALOG_EMPTY_RETRY_MAX_MS);
|
|
3569
3577
|
emptyStreak += 1;
|
|
3570
|
-
|
|
3571
|
-
emptyStreak = 0;
|
|
3572
|
-
delay = CATALOG_REFRESH_MS;
|
|
3578
|
+
return delay;
|
|
3573
3579
|
}
|
|
3580
|
+
emptyStreak = 0;
|
|
3581
|
+
return CATALOG_REFRESH_MS;
|
|
3582
|
+
};
|
|
3583
|
+
const scheduleDiscovery = (delay) => {
|
|
3574
3584
|
discoveryTimer = setTimeout(() => void discoverLoop(), delay);
|
|
3575
3585
|
discoveryTimer.unref?.();
|
|
3576
3586
|
};
|
|
3587
|
+
/** 自我重排的发现循环:首轮由启动引导跑完后从这里接棒,不再立刻多打一轮上游。 */
|
|
3588
|
+
const discoverLoop = async () => {
|
|
3589
|
+
await discover();
|
|
3590
|
+
if (stopped) return;
|
|
3591
|
+
scheduleDiscovery(nextDiscoveryDelay());
|
|
3592
|
+
};
|
|
3577
3593
|
ctx.effect(() => () => {
|
|
3578
3594
|
abort.abort();
|
|
3579
3595
|
if (discoveryTimer !== void 0) clearTimeout(discoveryTimer);
|
|
@@ -3711,12 +3727,13 @@ function apply(ctx, rawConfig) {
|
|
|
3711
3727
|
waitInQueue: () => current().queueWaitUntilReady === true
|
|
3712
3728
|
});
|
|
3713
3729
|
usage.load().catch(() => {});
|
|
3714
|
-
shim.ready.then(async () => {
|
|
3730
|
+
const settled = shim.ready.then(async () => {
|
|
3715
3731
|
if (stopped) return;
|
|
3716
|
-
discoverLoop();
|
|
3717
3732
|
keepAliveLoop();
|
|
3718
3733
|
armAutoClaim();
|
|
3719
3734
|
armKeepAliveDaemon();
|
|
3735
|
+
await discover(AbortSignal.any([abort.signal, AbortSignal.timeout(STARTUP_DISCOVERY_MS)]));
|
|
3736
|
+
if (stopped) return;
|
|
3720
3737
|
const incompatible = await probePiAiCompat();
|
|
3721
3738
|
if (incompatible !== void 0) ctx.logger.error(`dsh-codearts: ${incompatible}`);
|
|
3722
3739
|
const codearts = createCodeArtsAdapter({
|
|
@@ -3751,9 +3768,14 @@ function apply(ctx, rawConfig) {
|
|
|
3751
3768
|
releaseAdapter?.();
|
|
3752
3769
|
releaseDirectory?.();
|
|
3753
3770
|
}
|
|
3771
|
+
if (catalog.current().length === 0) ctx.logger.warn("dsh-codearts: CodeArts provider registered with an empty model catalog; models stay unavailable until discovery succeeds");
|
|
3772
|
+
if (!stopped) scheduleDiscovery(nextDiscoveryDelay());
|
|
3754
3773
|
}).catch((error) => {
|
|
3755
3774
|
ctx.logger.error("dsh-codearts: loopback shim failed to start; provider not registered", error);
|
|
3756
3775
|
});
|
|
3776
|
+
await Promise.race([settled, new Promise((resolve) => {
|
|
3777
|
+
setTimeout(resolve, STARTUP_WAIT_MS).unref?.();
|
|
3778
|
+
})]);
|
|
3757
3779
|
}
|
|
3758
3780
|
//#endregion
|
|
3759
3781
|
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-BRlNY6dB.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";
|
|
@@ -321,6 +321,34 @@ function richerThan(a, b) {
|
|
|
321
321
|
return a.id !== a.id.toLowerCase() && b.id === b.id.toLowerCase();
|
|
322
322
|
}
|
|
323
323
|
/**
|
|
324
|
+
* 提交前用上一轮目录兜住上下文窗口(issue #12)。
|
|
325
|
+
*
|
|
326
|
+
* 发现是逐路并行的:某一路(例如租户 thirdparty)瞬时失败时,同一模型仍可能由别的路
|
|
327
|
+
* 返回,但那条记录不带 `contextWindow`,`fetchModels` 于是落 32768 兜底。整份覆盖后,
|
|
328
|
+
* 已经确认过的好窗口(1M)就被抹掉了,而且一直错到下一轮完整发现。
|
|
329
|
+
*
|
|
330
|
+
* 这里只做一件事:本轮没拿到**可信窗口**的记录(`contextWindowKnown !== true`),
|
|
331
|
+
* 沿用上一轮同 id 的可信窗口。两条边界必须守住:
|
|
332
|
+
* - 不保留上一轮多出来的模型 —— 上游下架的必须消失;
|
|
333
|
+
* - 不覆盖本轮已可信的值(用户覆盖、实测学习、上游真给的都算)。
|
|
334
|
+
*/
|
|
335
|
+
function carryKnownWindows(previous, next) {
|
|
336
|
+
const known = /* @__PURE__ */ new Map();
|
|
337
|
+
for (const model of previous) if (model.contextWindowKnown === true && model.contextWindow > 0) known.set(model.id.trim().toLowerCase(), model);
|
|
338
|
+
if (known.size === 0) return next;
|
|
339
|
+
return next.map((model) => {
|
|
340
|
+
if (model.contextWindowKnown === true) return model;
|
|
341
|
+
const old = known.get(model.id.trim().toLowerCase());
|
|
342
|
+
if (old === void 0) return model;
|
|
343
|
+
return {
|
|
344
|
+
...model,
|
|
345
|
+
contextWindow: old.contextWindow,
|
|
346
|
+
contextWindowKnown: true,
|
|
347
|
+
...old.contextWindowDiscovered === void 0 ? {} : { contextWindowDiscovered: old.contextWindowDiscovered }
|
|
348
|
+
};
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
324
352
|
* 用参数表给**发现结果**补 0 值字段。参数表里有、上游这次没返回的模型 —— 不塞进目录。
|
|
325
353
|
*
|
|
326
354
|
* 为什么不能把参数表一起丢进 `mergeModelLists`:那个函数按「参数更全/大小写更像注册名」
|
|
@@ -2096,4 +2124,4 @@ async function claimDailyWelfare(credential, signal) {
|
|
|
2096
2124
|
};
|
|
2097
2125
|
}
|
|
2098
2126
|
//#endregion
|
|
2099
|
-
export { queueFrame as A,
|
|
2127
|
+
export { queueFrame as A, filterEnabledModels as B, isWelfareClaimedStatus as C, modelUnavailableReasonText as D, maxTokensCeilingFor as E, CodeArtsCatalog as F, mergeModelLists as G, isBenefitBlocked as H, FALLBACK_CODEARTS_MODELS as I, setDiscoveredBenefitModels as J, modelDisplayName as K, carryKnownWindows as L, signedGet as M, upstreamErrorMessage as N, pickDailyWelfareCampaign as O, upstream_exports as P, clearBenefitBlocked as R, isTpmLimit as S, learnedContextWindowFor as T, isBenefitModel as U, forgetModelUnavailable as V, markModelUnavailable as W, 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, rateLimitFrame as j, prepareChatBody as k, fetchCallerIdentity as l, isConcurrencyCap as m, SNAP_HOST as n, clearQueueStatus as o, firstFrameError as p, modelUnavailableReason 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, creditRatioLabel as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { u as writeJsonAtomic } from "./auth-
|
|
2
|
-
import { G as
|
|
1
|
+
import { u as writeJsonAtomic } from "./auth-BRlNY6dB.mjs";
|
|
2
|
+
import { G as mergeModelLists, J as setDiscoveredBenefitModels, K as modelDisplayName, L as carryKnownWindows, U as isBenefitModel, u as fetchModels } from "./upstream-CgQXomCI.mjs";
|
|
3
3
|
import { existsSync } from "node:fs";
|
|
4
4
|
import { readFile } from "node:fs/promises";
|
|
5
5
|
import { homedir } from "node:os";
|
|
@@ -85,8 +85,9 @@ async function discoverModels(store, signal, contextWindowOverrides) {
|
|
|
85
85
|
async function refreshCatalog(store, catalog, signal, contextWindowOverrides) {
|
|
86
86
|
const outcome = await discoverModels(store, signal, contextWindowOverrides);
|
|
87
87
|
if (!outcome.anySucceeded || outcome.models.length === 0) return outcome;
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
const models = carryKnownWindows(catalog.current(), outcome.models);
|
|
89
|
+
setDiscoveredBenefitModels(models.filter((model) => model.benefit === true).map((model) => model.id));
|
|
90
|
+
catalog.set(models.map((model) => {
|
|
90
91
|
const benefit = isBenefitModel(model.id);
|
|
91
92
|
return {
|
|
92
93
|
...model,
|
|
@@ -535,6 +536,6 @@ function percentileOf(buckets, ratio) {
|
|
|
535
536
|
}
|
|
536
537
|
//#endregion
|
|
537
538
|
//#region src/version.ts
|
|
538
|
-
const CODEARTS_VERSION = "1.4.
|
|
539
|
+
const CODEARTS_VERSION = "1.4.7";
|
|
539
540
|
//#endregion
|
|
540
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.7",
|
|
6
6
|
"packageManager": "pnpm@11.24.0",
|
|
7
7
|
"author": "elegant01",
|
|
8
8
|
"keywords": [
|