dsh-connect-trae 4.6.10 → 4.6.12
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 +94 -0
- package/lib/client.js +7 -1
- package/lib/index.d.ts +38 -1
- package/lib/index.js +45 -34
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,99 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.6.12 (2026-10-31)
|
|
4
|
+
|
|
5
|
+
> **4.6.11 的上下文窗口守卫补上了第二条出口。** issue #72 指出:#70 把兜底做进了
|
|
6
|
+
> `toPiModel`(适配器出口),但 `registerModelDiscovery` 回调——模型发现走向 DSH 的
|
|
7
|
+
> 另一条出口——仍把 `contextWindow` 原样透出,而宿主对发现行**不做任何校验**。一条
|
|
8
|
+
> 畸形的目录行因此能绕过 #70。
|
|
9
|
+
|
|
10
|
+
### 变更
|
|
11
|
+
|
|
12
|
+
- **发现回调永远发出正整数窗口**(issue #72 的主点,`src/index.ts`)。
|
|
13
|
+
- **问题**:宿主 `discoverModels()` 只按 id 去重,`contextWindow`/`maxTokens`
|
|
14
|
+
原样透传;模型管理界面把发现行**逐字**采纳进 `models` 配置项,而那一项的 schema
|
|
15
|
+
要求 `step(1).min(1)`。所以原样透出意味着两件事之一:畸形值被带进下游,或者
|
|
16
|
+
(目录省略窗口时)行以「无窗口」抵达 DSH——正是 #70 的故障形态,只是绕开了
|
|
17
|
+
适配器。症状同为一条坏行 ⇒ `INVALID_MODEL_CONTEXT` ⇒ 整个区域离线。
|
|
18
|
+
- **改法**:回调改为永远发出 `contextWindow: servedContextWindow(model)`——
|
|
19
|
+
与适配器出口同一条规则、同一个兜底值(200 000)。两条「字段缺失即不发」的
|
|
20
|
+
分支合并成一条恒发字段,两个出口对同一行给出的值因此不可能分叉。
|
|
21
|
+
- **目录层把「在场但畸形」归一化(三处),「省略」依旧合法**(issue #72 的后半 +
|
|
22
|
+
评审判断,`src/catalog.ts`)。
|
|
23
|
+
- `mergeTraeModelSources` 的目录分支、`mergeTraeModelSources` 的 wire 提升分支、
|
|
24
|
+
`discoveredCatalog` 各加一条 `servedContextWindow` 归一化:窗口缺失仍按缺失
|
|
25
|
+
上报(`tests/catalog.spec.ts` 里钉住这条既有契约的用例保持绿),但**在场**的
|
|
26
|
+
值必须是正整数,否则换成兜底。
|
|
27
|
+
- **为什么目录层也值得补**:上游解析门 `finitePositive` 只查 `isFinite && > 0`,
|
|
28
|
+
所以 `200000.5` 能活着走完解析;一个分数窗口若跟着目录行存进 `lastCatalog`,
|
|
29
|
+
会让**整次设置写入**被 schema 拒绝(`modelConfig` 的 `step(1).min(1)`)。
|
|
30
|
+
归一化留在生产侧,坏值就永远进不了持久化。
|
|
31
|
+
- **评审修正**:报告者建议 wire 提升分支不打守卫,理由是其上游
|
|
32
|
+
(`get_detail_param`)「结构上产不出畸形值」。核对该分支的取值链
|
|
33
|
+
`contextWindow = prompt_max_tokens ?? context_window_tokens.dev`——两个来源
|
|
34
|
+
都出自 `finitePositive`,分数值(如 `300000.5`)**能**从那里活着到达。
|
|
35
|
+
故本次三个出口一起补;`FALLBACK_CONTEXT_WINDOW` 与 `servedContextWindow`
|
|
36
|
+
自 `src/adapter.ts` 移入 `src/catalog.ts` 导出(无循环依赖),两处出口共用。
|
|
37
|
+
- **`maxTokens` 有意不动**:宿主对发现行的 `maxTokens` 同样不校验,但它的
|
|
38
|
+
校验发生在 `normalizeModelInfo`(`INVALID_MODEL_MAX_TOKENS`,适配器路径,
|
|
39
|
+
#70 已覆盖);目录行里 `maxTokens` 畸形只影响「最大输出」展示,没有
|
|
40
|
+
`INVALID_*` 硬失败面。与 #70 的口径保持一致:本补丁只管上下文窗口。
|
|
41
|
+
- **未采纳(留待单独评估)**:把 `finitePositive` 收紧为 `finitePositiveInteger`
|
|
42
|
+
——报告者自己标注的行为变更,会同时改变目录解析与 wire 解析的入站语义,
|
|
43
|
+
不适合作为一个守卫补丁的顺车。
|
|
44
|
+
|
|
45
|
+
### 测试
|
|
46
|
+
|
|
47
|
+
- 新增 **6** 例(1240 总例,较 4.6.11 净增 6):
|
|
48
|
+
- **真实路径**(`tests/discovery-context-window.spec.ts`,5 例):与
|
|
49
|
+
`tests/settings-integration.spec.ts` 同款宿主挂具(`LlmRuntime` +
|
|
50
|
+
0.1.7 形状的内存 settings + 临时 DSH_HOME + 临时 storage.json 凭据,含
|
|
51
|
+
`readTraeIdentity` 要求的 `telemetry.*` 身份字段),`vi.stubGlobal('fetch')`
|
|
52
|
+
桩出目录 / wire 花名册 / IDE 花名册三个端点,走
|
|
53
|
+
`ctx.llm.discoverModels(TRAE_SETTINGS_NS, { provider: 'trae' })` 断言宿主
|
|
54
|
+
**读回**的行:分数目录行 → 兜底、省略窗口行 → **显式**兜底(`Object.hasOwn`
|
|
55
|
+
钉住「恒发字段」)、正常 168 000 原样保留(兜底是背板不是钳位)、wire 提升
|
|
56
|
+
行的分数 `prompt_max_tokens` → 兜底、以及一条「所有行都是正整数」的全量扫描。
|
|
57
|
+
- **目录单元**(`tests/catalog.spec.ts`,1 例,覆盖
|
|
58
|
+
分数/0/负数/NaN × 三处出口 + 正常值不动)。
|
|
59
|
+
- **变异验证**:把发现回调改回原样透出 → 真实路径 5 例中 2 例转红(全量扫描、
|
|
60
|
+
省略窗口);把 `src/catalog.ts` 三处守卫改回原样 → 目录单元例转红。恢复守卫后
|
|
61
|
+
全绿。
|
|
62
|
+
- 全仓 **1240** 例通过(97 文件),双 tsconfig 类型检查通过。
|
|
63
|
+
|
|
64
|
+
## 4.6.11 (2026-10-30)
|
|
65
|
+
|
|
66
|
+
> **英文界面下的「最近刷新」不再显示成中文式的时间。** issue #71 里顺带提到的那点:
|
|
67
|
+
> `formatClock` 把 locale 硬编码成 `'zh-CN'`,所以英文界面印的是 `23:59` 而不是
|
|
68
|
+
> `11:59 PM`。
|
|
69
|
+
|
|
70
|
+
### 变更
|
|
71
|
+
|
|
72
|
+
- **`formatClock` 不再硬编码 locale**(issue #71 的第 1 节「顺带一提」)。
|
|
73
|
+
- **问题**:`formatClock` 写死 `'zh-CN'`,于是英文界面按中文习惯排 24 小时制,
|
|
74
|
+
显示 `23:59` 而不是 `11:59 PM`。同一文件里的 `formatDateTime` 用的是
|
|
75
|
+
`undefined`(跟随读者语言)——两个函数对「按谁的格式」各说各话。
|
|
76
|
+
- **改法**:`toLocaleTimeString('zh-CN', …)` → `toLocaleTimeString(undefined, …)`,
|
|
77
|
+
与 `formatDateTime` 对齐。
|
|
78
|
+
- **影响面**:`formatClock` 现在只剩一个调用点——`composer.lastRefresh`
|
|
79
|
+
(「最近刷新」)。到期时刻早已改用 `formatDateTime`(4.6.7),所以本次**不影响**
|
|
80
|
+
到期提示的渲染。
|
|
81
|
+
- **姊妹插件暂未同步**:`dsh-connect-workbuddy` 与 `@dmh2002/dsh-connect-qoder`
|
|
82
|
+
各自的 `formatClock` 里也有同样的硬编码(`ComposerCredits.tsx`),但它们不在
|
|
83
|
+
issue #71 的范围内,故本次**只改 trae**。三家的差异见下。
|
|
84
|
+
|
|
85
|
+
### 测试
|
|
86
|
+
|
|
87
|
+
- 新增 **2** 例(1234 总例,较 4.6.10 净增 2):
|
|
88
|
+
- **源码级**:`formatClock` 不得再出现硬编码的 locale。这一条不依赖测试环境的
|
|
89
|
+
locale——行为级断言在 zh-CN 环境下会因两种写法结果相同而失效,源码级不会。
|
|
90
|
+
- **行为级**:渲染出的「最近刷新」戳必须等于**读者 locale** 对该时刻的写法。
|
|
91
|
+
`composer.lastRefresh` 是「最近一次刷新的时刻」(即当前时间),所以期望值取
|
|
92
|
+
渲染前后两个瞬间,容许跨过一分钟边界。
|
|
93
|
+
- **变异验证**:把 locale 改回 `'zh-CN'`,两条用例**同时**转红(源码级点名
|
|
94
|
+
「still pins a locale」,行为级报出实际渲染值 `19:31` 与期望的 `07:31 PM`)。
|
|
95
|
+
- 全仓 **1234** 例通过(96 文件),双 tsconfig 类型检查通过。
|
|
96
|
+
|
|
3
97
|
## 4.6.10 (2026-10-30)
|
|
4
98
|
|
|
5
99
|
> **到期提示加了一档「3 天内」。** 一个两天后过期的套餐,之前显示的是「7 天内过期」
|
package/lib/client.js
CHANGED
|
@@ -6465,9 +6465,15 @@ window.__ModuleLoader__.load({
|
|
|
6465
6465
|
* (`row.expiryEarliest`) through `formatDateTime`, so one key had two
|
|
6466
6466
|
* granularities in one plugin. Expiry goes through `formatDateTime`; only
|
|
6467
6467
|
* same-day instants may use this.
|
|
6468
|
+
*
|
|
6469
|
+
* The locale is `undefined` — the READER's, not a fixed one — so an English UI
|
|
6470
|
+
* shows `11:59 PM` rather than the Chinese convention's `23:59`. It used to
|
|
6471
|
+
* hardcode `'zh-CN'`, which meant the English interface printed a Chinese-style
|
|
6472
|
+
* time (issue #71's aside). `formatDateTime` already worked this way; this
|
|
6473
|
+
* brings the two into agreement.
|
|
6468
6474
|
*/
|
|
6469
6475
|
function formatClock(value) {
|
|
6470
|
-
return new Date(value).toLocaleTimeString(
|
|
6476
|
+
return new Date(value).toLocaleTimeString(void 0, {
|
|
6471
6477
|
hour: "2-digit",
|
|
6472
6478
|
minute: "2-digit"
|
|
6473
6479
|
});
|
package/lib/index.d.ts
CHANGED
|
@@ -286,6 +286,43 @@ interface TraeModelInfo {
|
|
|
286
286
|
*/
|
|
287
287
|
activityDiscount?: TraeActivityDiscount;
|
|
288
288
|
}
|
|
289
|
+
/**
|
|
290
|
+
* Conservative context capacity used when a row must be advertised with a
|
|
291
|
+
* number but states no usable one of its own. Every fallback row and every
|
|
292
|
+
* live Trae row is expected to carry its real window; this is the backstop
|
|
293
|
+
* that keeps one unsized row from failing the entire provider route
|
|
294
|
+
* (`INVALID_MODEL_CONTEXT`).
|
|
295
|
+
*
|
|
296
|
+
* APPLIED AT EVERY EXIT TOWARD DSH, NOT ONLY IN THE ADAPTER. The pi-ai
|
|
297
|
+
* profile's `defaultContextWindow` is read by the kernel's catalog-resolution
|
|
298
|
+
* step, which this plugin never runs: it builds its provider BY HAND through
|
|
299
|
+
* `createProvider({ models })`, so `Models.getModel()` returns the raw
|
|
300
|
+
* `toPiModel` row with no defaulting applied anywhere. Leaving the fallback on
|
|
301
|
+
* the profile alone is what produced
|
|
302
|
+
* `adapter returned invalid context metadata for provider "trae" model
|
|
303
|
+
* "doubao_1.8"` — a row the live directory published without a window reached
|
|
304
|
+
* DSH unsized and took the whole `trae` route down (#70).
|
|
305
|
+
*
|
|
306
|
+
* The model-DISCOVERY callback is a second exit with no adapter in between
|
|
307
|
+
* (#72): the host passes its rows through UNVALIDATED, and a settings surface
|
|
308
|
+
* adopts one verbatim into a `models` entry, where the schema demands a
|
|
309
|
+
* positive integer. So this rule guards the row PRODUCERS here as well.
|
|
310
|
+
*/
|
|
311
|
+
declare const FALLBACK_CONTEXT_WINDOW = 200000;
|
|
312
|
+
/**
|
|
313
|
+
* The window a row is actually advertised with.
|
|
314
|
+
*
|
|
315
|
+
* Positive integers pass through untouched — a row's own window is never
|
|
316
|
+
* second-guessed. Anything else (missing, `NaN`, `0`, a negative or a
|
|
317
|
+
* fractional count from a malformed directory entry) falls back, because DSH
|
|
318
|
+
* accepts ONLY a positive integer and rejects the entire provider otherwise.
|
|
319
|
+
*
|
|
320
|
+
* The fractional case is not hypothetical: the parsers that fill these rows
|
|
321
|
+
* gate the field through `finitePositive`, which checks
|
|
322
|
+
* `Number.isFinite && > 0` and nothing about integer-ness, so a directory or
|
|
323
|
+
* wire roster publishing `200000.5` reaches here intact.
|
|
324
|
+
*/
|
|
325
|
+
declare function servedContextWindow(info: Pick<TraeModelInfo, 'contextWindow'>): number;
|
|
289
326
|
/**
|
|
290
327
|
* Bootstrap catalog: identity only where current Trae metadata has not been
|
|
291
328
|
* fetched yet.
|
|
@@ -4718,4 +4755,4 @@ declare function asVolatile<S>(schema: S): S;
|
|
|
4718
4755
|
declare const Config: z<Config>;
|
|
4719
4756
|
declare function apply(ctx: Context$1, config: Config): void;
|
|
4720
4757
|
//#endregion
|
|
4721
|
-
export { Config, FALLBACK_TRAE_MODELS, FALLBACK_TRAE_MODELS_AI, MAX_PROBE_INPUT_TOKENS, type PiAiGeneration, type PiAiRuntimeInfo, REGION_GATEWAYS, type RawChatDelta, type RawChatMessage, type RawChatTool, SseDecoder, type SseEvent, TRAE_ACCOUNT_STATUS_PATH, TRAE_AI_PROVIDER, TRAE_CHANNEL_PRIORITY, TRAE_CHECKIN_PATH, TRAE_CN_AGENT_TASK_PATH, TRAE_CN_TITLE_PATH, TRAE_COMMON_FUNCTIONS, TRAE_ENTERPRISE_PROVIDER, TRAE_MODELS_TEST_PATH, TRAE_MODEL_DETAIL_FUNCTIONS, TRAE_MODEL_DETAIL_PATH, TRAE_OFFICIAL_ROSTER_PATH, TRAE_PANELS, TRAE_PAY_BASE, TRAE_PROBE_TIMEOUT_MS, TRAE_PROVIDER, TRAE_PROVIDERS, TRAE_PROVIDER_DISPLAY_NAMES, TRAE_PROVIDER_IDS, TRAE_PROVIDER_ID_DISPLAY_NAMES, TRAE_PROVIDER_ROUTES, TRAE_RAW_CHAT_V1_PATH, TRAE_RAW_CHAT_V2_PATH, TRAE_REASONING_EFFORTS, TRAE_REGIONS, TRAE_REGION_PARAM, TRAE_SETTINGS_NS, TRAE_SOLO_CHAT_PATH, TRAE_SOLO_FUNCTION, TRAE_SOLO_MODELS_PATH, TRAE_SOLO_REMOTE_BASE, TRAE_STATE_DB_FILENAME, TRAE_STREAM_IDLE_TIMEOUT_MS, TRAE_USAGE_PATH, TRAE_VERSION_CODE_FALLBACK, type TraeActivityRule, type TraeAdapter, type TraeCachedModelConfig, TraeCatalog, type TraeChatResult, type TraeCheckinClaim, type TraeCheckinStatus, type TraeContextBudget, type TraeCredential, TraeCredentialStore, TraeDelegatingUpstreamClient, type TraeDiscoveredModel, type TraeDiscoveredReasoning, type TraeEdition, type TraeFailure, TraeFallbackUpstreamClient, type TraeFallbackUpstreamOptions, type TraeFusionRawChatEnvelope, TraeGatedUpstreamClient, type TraeGatedUpstreamOptions, type TraeIdentity, type TraeInputModality, type TraeModelDetailRequest, type TraeModelGroup, type TraeModelInfo, type TraeModelProbeVerdict, type TraeModelView, type TraeModelsTestResponse, type TraeObservedModelConfig, type TraeOfficialChannel, type TraeOfficialFilterResult, type TraeOfficialRoster, TraeOfficialRosterClient, type TraeOfficialVerdict, type TraeOrderableModel, type TraePanel, type TraeProbeResult, type TraeProbeVerdict, type TraeProviderRoute, TraeRawCapabilityController, type TraeRawCapabilityControllerOptions, type TraeRawCapabilitySnapshot, TraeRawCapabilityState, type TraeRawChatBehaviorConfig, type TraeRawChatCapability, type TraeRawChatClientOptions, type TraeRawChatConfig, type TraeRawChatFailureReason, type TraeRawChatRuntimeConfig, TraeRawChatUpstreamClient, type TraeRawDiagnostic, type TraeRawDiagnosticState, type TraeRawGateway, type TraeRawGatewayOptions, type TraeRawResolverResult, type TraeReasoningCapability, type TraeReasoningEffort, type TraeRefreshDevice, type TraeRegion, type TraeRegionGateways, TraeRegionState, type TraeShim, TraeSoloBridge, type TraeSoloClientOptions, TraeSoloRemoteCatalogClient, type TraeSoloRemoteCatalogOptions, TraeSoloUpstreamClient, type TraeStorageCandidate, type TraeStreamEvent, type TraeUpstreamClient, TraeUsageClient, type TraeUsageOptions, type TraeUsagePack, type TraeUsageRouteOptions, type TraeUsageSnapshot, type TraeUsageSummary, type TraeUsageView, type TraeWebAccountState, type TraeWebActivity, type TraeWebCheckin, type TraeWebCheckinClaim, type TraeWebCredits, type TraeWebUsage, type TraeWireModel, type TraeWireTarget, UnconfiguredTraeUpstreamClient, adaptLegacyPiAiContext, adaptModernPiAiContext, apply, applyContextBudgets, applyImageSelection, applyOfficialRoster, applyReasoningEffort, asVolatile, bridgeTraeSoloStream, buildTraeAgentTaskBody, buildTraeCnHeaders, buildTraeFusionRawChatEnvelope, buildTraeModelDetailRequest, buildTraeRawChatDraft, buildTraeRawChatRuntimeConfig, classifyProbeError, classifyProbeResult, classifyTraeRawChatFailure, configuredAccountsOf, createTraeAdapter, createTraeRawGateway, createTraeShim, creditPosition, decidePiAiGeneration, decodeRawChatChunk, decodeTraeEvent, decryptTraeStorageValue, deriveCatalog, describeIdShape, describeNameShape, describeTraeFailure, discoveredCatalog, displayNameOfTraeProvider, fallbackModelsFor, filterTraeModels, generationOf, groupTraeModels, hashTraeRawChatArg, identityHeaders, inject, isEnterpriseAccount, isPromotableWireModel, legacyTraeOwnAuthPath, maskUserPath, mergeTraeModelSources, name, nextRegionCreditPosition, nextRegionEnabled, nextRegionSlots, normalizeTraeCredential, normalizeTraeToolSchema, normalizeTraeToolSchemas, normalizeTraeVersionCode, officialVerdictOf, orderTraeModels, panelOfKey, panelOfProvider, parseObservedModelConfig, parseReasoningCapability, parseTraeAuthValue, parseTraeCachedModel, parseTraeModelExtraConfigLogLine, parseTraeOfficialRoster, parseTraeRawChatBehaviorConfig, parseTraeRemoteModel, parseTraeStorageDocument, piAiRuntimeInfo, pickTraeStorageIdentity, prepareSoloBody, probeBody, probeModelsSequentially, probeOneModel, probeTraeRawChatCapability, providerOfPanel, rawCapabilityDiagnostic, rawCapabilityFingerprint, readTraeCachedModel, readTraeCliIdentity, readTraeIdentity, refreshTraeCredential, regionCreditPositionOf, regionEnabled, regionEnabledOf, regionOfCredential, regionOfEdition, regionOfHost, regionOfPanel, regionOfTraeProvider, regionOfTraeStatusUrl, regionOfUserRegion, regionStateOf, registerTraeUsageRoute, resolveTraeIdentity, resolveTraeRawRuntime, routeOfTraeProvider, sanitizeCatalog, scopeTraeModels, settingsNamespaceOf, traeEndpoint, traeInputModalities, traeModelCallChannel, traeModelDisplayName, traeModelInView, traeModelMatchesQuery, traeOwnAuthPath, traeRawChatExtraInfo, traeStateDatabaseCandidates, traeStorageCandidates, traeWebUsage, traeWindowsAppNames, unwrapVolatile, unwrapVolatileDeep, wireTargetsOf, withChatCallableFunctions, withContextAdaptation, withTraeRegion };
|
|
4758
|
+
export { Config, FALLBACK_CONTEXT_WINDOW, FALLBACK_TRAE_MODELS, FALLBACK_TRAE_MODELS_AI, MAX_PROBE_INPUT_TOKENS, type PiAiGeneration, type PiAiRuntimeInfo, REGION_GATEWAYS, type RawChatDelta, type RawChatMessage, type RawChatTool, SseDecoder, type SseEvent, TRAE_ACCOUNT_STATUS_PATH, TRAE_AI_PROVIDER, TRAE_CHANNEL_PRIORITY, TRAE_CHECKIN_PATH, TRAE_CN_AGENT_TASK_PATH, TRAE_CN_TITLE_PATH, TRAE_COMMON_FUNCTIONS, TRAE_ENTERPRISE_PROVIDER, TRAE_MODELS_TEST_PATH, TRAE_MODEL_DETAIL_FUNCTIONS, TRAE_MODEL_DETAIL_PATH, TRAE_OFFICIAL_ROSTER_PATH, TRAE_PANELS, TRAE_PAY_BASE, TRAE_PROBE_TIMEOUT_MS, TRAE_PROVIDER, TRAE_PROVIDERS, TRAE_PROVIDER_DISPLAY_NAMES, TRAE_PROVIDER_IDS, TRAE_PROVIDER_ID_DISPLAY_NAMES, TRAE_PROVIDER_ROUTES, TRAE_RAW_CHAT_V1_PATH, TRAE_RAW_CHAT_V2_PATH, TRAE_REASONING_EFFORTS, TRAE_REGIONS, TRAE_REGION_PARAM, TRAE_SETTINGS_NS, TRAE_SOLO_CHAT_PATH, TRAE_SOLO_FUNCTION, TRAE_SOLO_MODELS_PATH, TRAE_SOLO_REMOTE_BASE, TRAE_STATE_DB_FILENAME, TRAE_STREAM_IDLE_TIMEOUT_MS, TRAE_USAGE_PATH, TRAE_VERSION_CODE_FALLBACK, type TraeActivityRule, type TraeAdapter, type TraeCachedModelConfig, TraeCatalog, type TraeChatResult, type TraeCheckinClaim, type TraeCheckinStatus, type TraeContextBudget, type TraeCredential, TraeCredentialStore, TraeDelegatingUpstreamClient, type TraeDiscoveredModel, type TraeDiscoveredReasoning, type TraeEdition, type TraeFailure, TraeFallbackUpstreamClient, type TraeFallbackUpstreamOptions, type TraeFusionRawChatEnvelope, TraeGatedUpstreamClient, type TraeGatedUpstreamOptions, type TraeIdentity, type TraeInputModality, type TraeModelDetailRequest, type TraeModelGroup, type TraeModelInfo, type TraeModelProbeVerdict, type TraeModelView, type TraeModelsTestResponse, type TraeObservedModelConfig, type TraeOfficialChannel, type TraeOfficialFilterResult, type TraeOfficialRoster, TraeOfficialRosterClient, type TraeOfficialVerdict, type TraeOrderableModel, type TraePanel, type TraeProbeResult, type TraeProbeVerdict, type TraeProviderRoute, TraeRawCapabilityController, type TraeRawCapabilityControllerOptions, type TraeRawCapabilitySnapshot, TraeRawCapabilityState, type TraeRawChatBehaviorConfig, type TraeRawChatCapability, type TraeRawChatClientOptions, type TraeRawChatConfig, type TraeRawChatFailureReason, type TraeRawChatRuntimeConfig, TraeRawChatUpstreamClient, type TraeRawDiagnostic, type TraeRawDiagnosticState, type TraeRawGateway, type TraeRawGatewayOptions, type TraeRawResolverResult, type TraeReasoningCapability, type TraeReasoningEffort, type TraeRefreshDevice, type TraeRegion, type TraeRegionGateways, TraeRegionState, type TraeShim, TraeSoloBridge, type TraeSoloClientOptions, TraeSoloRemoteCatalogClient, type TraeSoloRemoteCatalogOptions, TraeSoloUpstreamClient, type TraeStorageCandidate, type TraeStreamEvent, type TraeUpstreamClient, TraeUsageClient, type TraeUsageOptions, type TraeUsagePack, type TraeUsageRouteOptions, type TraeUsageSnapshot, type TraeUsageSummary, type TraeUsageView, type TraeWebAccountState, type TraeWebActivity, type TraeWebCheckin, type TraeWebCheckinClaim, type TraeWebCredits, type TraeWebUsage, type TraeWireModel, type TraeWireTarget, UnconfiguredTraeUpstreamClient, adaptLegacyPiAiContext, adaptModernPiAiContext, apply, applyContextBudgets, applyImageSelection, applyOfficialRoster, applyReasoningEffort, asVolatile, bridgeTraeSoloStream, buildTraeAgentTaskBody, buildTraeCnHeaders, buildTraeFusionRawChatEnvelope, buildTraeModelDetailRequest, buildTraeRawChatDraft, buildTraeRawChatRuntimeConfig, classifyProbeError, classifyProbeResult, classifyTraeRawChatFailure, configuredAccountsOf, createTraeAdapter, createTraeRawGateway, createTraeShim, creditPosition, decidePiAiGeneration, decodeRawChatChunk, decodeTraeEvent, decryptTraeStorageValue, deriveCatalog, describeIdShape, describeNameShape, describeTraeFailure, discoveredCatalog, displayNameOfTraeProvider, fallbackModelsFor, filterTraeModels, generationOf, groupTraeModels, hashTraeRawChatArg, identityHeaders, inject, isEnterpriseAccount, isPromotableWireModel, legacyTraeOwnAuthPath, maskUserPath, mergeTraeModelSources, name, nextRegionCreditPosition, nextRegionEnabled, nextRegionSlots, normalizeTraeCredential, normalizeTraeToolSchema, normalizeTraeToolSchemas, normalizeTraeVersionCode, officialVerdictOf, orderTraeModels, panelOfKey, panelOfProvider, parseObservedModelConfig, parseReasoningCapability, parseTraeAuthValue, parseTraeCachedModel, parseTraeModelExtraConfigLogLine, parseTraeOfficialRoster, parseTraeRawChatBehaviorConfig, parseTraeRemoteModel, parseTraeStorageDocument, piAiRuntimeInfo, pickTraeStorageIdentity, prepareSoloBody, probeBody, probeModelsSequentially, probeOneModel, probeTraeRawChatCapability, providerOfPanel, rawCapabilityDiagnostic, rawCapabilityFingerprint, readTraeCachedModel, readTraeCliIdentity, readTraeIdentity, refreshTraeCredential, regionCreditPositionOf, regionEnabled, regionEnabledOf, regionOfCredential, regionOfEdition, regionOfHost, regionOfPanel, regionOfTraeProvider, regionOfTraeStatusUrl, regionOfUserRegion, regionStateOf, registerTraeUsageRoute, resolveTraeIdentity, resolveTraeRawRuntime, routeOfTraeProvider, sanitizeCatalog, scopeTraeModels, servedContextWindow, settingsNamespaceOf, traeEndpoint, traeInputModalities, traeModelCallChannel, traeModelDisplayName, traeModelInView, traeModelMatchesQuery, traeOwnAuthPath, traeRawChatExtraInfo, traeStateDatabaseCandidates, traeStorageCandidates, traeWebUsage, traeWindowsAppNames, unwrapVolatile, unwrapVolatileDeep, wireTargetsOf, withChatCallableFunctions, withContextAdaptation, withTraeRegion };
|
package/lib/index.js
CHANGED
|
@@ -66,6 +66,46 @@ function contextBudgetOptions(model) {
|
|
|
66
66
|
//#endregion
|
|
67
67
|
//#region src/catalog.ts
|
|
68
68
|
/**
|
|
69
|
+
* Conservative context capacity used when a row must be advertised with a
|
|
70
|
+
* number but states no usable one of its own. Every fallback row and every
|
|
71
|
+
* live Trae row is expected to carry its real window; this is the backstop
|
|
72
|
+
* that keeps one unsized row from failing the entire provider route
|
|
73
|
+
* (`INVALID_MODEL_CONTEXT`).
|
|
74
|
+
*
|
|
75
|
+
* APPLIED AT EVERY EXIT TOWARD DSH, NOT ONLY IN THE ADAPTER. The pi-ai
|
|
76
|
+
* profile's `defaultContextWindow` is read by the kernel's catalog-resolution
|
|
77
|
+
* step, which this plugin never runs: it builds its provider BY HAND through
|
|
78
|
+
* `createProvider({ models })`, so `Models.getModel()` returns the raw
|
|
79
|
+
* `toPiModel` row with no defaulting applied anywhere. Leaving the fallback on
|
|
80
|
+
* the profile alone is what produced
|
|
81
|
+
* `adapter returned invalid context metadata for provider "trae" model
|
|
82
|
+
* "doubao_1.8"` — a row the live directory published without a window reached
|
|
83
|
+
* DSH unsized and took the whole `trae` route down (#70).
|
|
84
|
+
*
|
|
85
|
+
* The model-DISCOVERY callback is a second exit with no adapter in between
|
|
86
|
+
* (#72): the host passes its rows through UNVALIDATED, and a settings surface
|
|
87
|
+
* adopts one verbatim into a `models` entry, where the schema demands a
|
|
88
|
+
* positive integer. So this rule guards the row PRODUCERS here as well.
|
|
89
|
+
*/
|
|
90
|
+
const FALLBACK_CONTEXT_WINDOW = 2e5;
|
|
91
|
+
/**
|
|
92
|
+
* The window a row is actually advertised with.
|
|
93
|
+
*
|
|
94
|
+
* Positive integers pass through untouched — a row's own window is never
|
|
95
|
+
* second-guessed. Anything else (missing, `NaN`, `0`, a negative or a
|
|
96
|
+
* fractional count from a malformed directory entry) falls back, because DSH
|
|
97
|
+
* accepts ONLY a positive integer and rejects the entire provider otherwise.
|
|
98
|
+
*
|
|
99
|
+
* The fractional case is not hypothetical: the parsers that fill these rows
|
|
100
|
+
* gate the field through `finitePositive`, which checks
|
|
101
|
+
* `Number.isFinite && > 0` and nothing about integer-ness, so a directory or
|
|
102
|
+
* wire roster publishing `200000.5` reaches here intact.
|
|
103
|
+
*/
|
|
104
|
+
function servedContextWindow(info) {
|
|
105
|
+
const window = info.contextWindow;
|
|
106
|
+
return Number.isInteger(window) && window > 0 ? window : FALLBACK_CONTEXT_WINDOW;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
69
109
|
* Bootstrap catalog: identity only where current Trae metadata has not been
|
|
70
110
|
* fetched yet.
|
|
71
111
|
*
|
|
@@ -397,7 +437,7 @@ function mergeTraeModelSources(remote, wire) {
|
|
|
397
437
|
result.push({
|
|
398
438
|
id: model.id,
|
|
399
439
|
name: model.name,
|
|
400
|
-
...model.contextWindow === void 0 ? {} : { contextWindow: model
|
|
440
|
+
...model.contextWindow === void 0 ? {} : { contextWindow: servedContextWindow(model) },
|
|
401
441
|
...model.maxContextWindow === void 0 ? {} : { maxContextWindow: model.maxContextWindow },
|
|
402
442
|
...creditMultiplier === void 0 ? {} : { creditMultiplier },
|
|
403
443
|
...activityDiscount === void 0 ? {} : { activityDiscount },
|
|
@@ -469,7 +509,7 @@ function mergeTraeModelSources(remote, wire) {
|
|
|
469
509
|
result.push({
|
|
470
510
|
id: wireModel.id,
|
|
471
511
|
name,
|
|
472
|
-
...wireModel.contextWindow === void 0 ? {} : { contextWindow: wireModel
|
|
512
|
+
...wireModel.contextWindow === void 0 ? {} : { contextWindow: servedContextWindow(wireModel) },
|
|
473
513
|
...wireModel.maxTokens === void 0 ? {} : { maxTokens: wireModel.maxTokens },
|
|
474
514
|
...wireModel.creditMultiplier === void 0 ? {} : { creditMultiplier: wireModel.creditMultiplier },
|
|
475
515
|
...wireModel.activityDiscount === void 0 ? {} : { activityDiscount: wireModel.activityDiscount },
|
|
@@ -544,7 +584,7 @@ function discoveredCatalog(models) {
|
|
|
544
584
|
for (const model of models) result.push({
|
|
545
585
|
id: model.id,
|
|
546
586
|
name: model.name,
|
|
547
|
-
...model.contextWindow === void 0 ? {} : { contextWindow: model
|
|
587
|
+
...model.contextWindow === void 0 ? {} : { contextWindow: servedContextWindow(model) },
|
|
548
588
|
...model.maxContextWindow === void 0 ? {} : { maxContextWindow: model.maxContextWindow },
|
|
549
589
|
input: ["text"],
|
|
550
590
|
...model.creditMultiplier === void 0 ? {} : { creditMultiplier: model.creditMultiplier },
|
|
@@ -861,35 +901,6 @@ const REQUEST_IMAGE_BUDGETS = {
|
|
|
861
901
|
requestImagePixelBudget: 4194304,
|
|
862
902
|
requestImageMaxBytes: 1048576
|
|
863
903
|
};
|
|
864
|
-
/**
|
|
865
|
-
* Conservative context capacity used only when a served model row carries no
|
|
866
|
-
* window of its own. Every fallback row and every live Trae row is expected to
|
|
867
|
-
* state its real window; this is the backstop that keeps one unsized row from
|
|
868
|
-
* failing the entire provider route (`INVALID_MODEL_CONTEXT`).
|
|
869
|
-
*
|
|
870
|
-
* APPLIED IN {@link toPiModel}, NOT ONLY ON THE PROFILE. The profile's
|
|
871
|
-
* `defaultContextWindow` is read by the kernel's catalog-resolution step, which
|
|
872
|
-
* this plugin never runs: it builds its pi-ai provider BY HAND through
|
|
873
|
-
* `createProvider({ models })`, and `Models.getModel()` then returns the raw
|
|
874
|
-
* `toPiModel` row with no defaulting applied anywhere. Leaving the fallback on
|
|
875
|
-
* the profile alone is what produced
|
|
876
|
-
* `adapter returned invalid context metadata for provider "trae" model
|
|
877
|
-
* "doubao_1.8"` — a row the live directory published without a window reached
|
|
878
|
-
* DSH unsized and took the whole `trae` route down.
|
|
879
|
-
*/
|
|
880
|
-
const FALLBACK_CONTEXT_WINDOW = 2e5;
|
|
881
|
-
/**
|
|
882
|
-
* The window a served row is actually advertised with.
|
|
883
|
-
*
|
|
884
|
-
* Positive integers pass through untouched — a row's own window is never
|
|
885
|
-
* second-guessed. Anything else (missing, `NaN`, `0`, a negative or a
|
|
886
|
-
* fractional count from a malformed directory entry) falls back, because DSH
|
|
887
|
-
* accepts ONLY a positive integer and rejects the entire provider otherwise.
|
|
888
|
-
*/
|
|
889
|
-
function servedContextWindow(info) {
|
|
890
|
-
const window = info.contextWindow;
|
|
891
|
-
return Number.isInteger(window) && window > 0 ? window : FALLBACK_CONTEXT_WINDOW;
|
|
892
|
-
}
|
|
893
904
|
function toPiModel(info, baseUrl, providerId, withRate = true) {
|
|
894
905
|
return {
|
|
895
906
|
id: info.id,
|
|
@@ -12117,7 +12128,7 @@ function apply(ctx, config) {
|
|
|
12117
12128
|
return next.map((model) => ({
|
|
12118
12129
|
id: model.id,
|
|
12119
12130
|
name: traeModelDisplayName(model, withRate),
|
|
12120
|
-
|
|
12131
|
+
contextWindow: servedContextWindow(model),
|
|
12121
12132
|
...model.maxTokens === void 0 ? {} : { maxTokens: model.maxTokens },
|
|
12122
12133
|
inputModalities: traeInputModalities(model)
|
|
12123
12134
|
}));
|
|
@@ -12160,4 +12171,4 @@ function apply(ctx, config) {
|
|
|
12160
12171
|
});
|
|
12161
12172
|
}
|
|
12162
12173
|
//#endregion
|
|
12163
|
-
export { Config, FALLBACK_TRAE_MODELS, FALLBACK_TRAE_MODELS_AI, MAX_PROBE_INPUT_TOKENS, REGION_GATEWAYS, SseDecoder, TRAE_ACCOUNT_STATUS_PATH, TRAE_AI_PROVIDER, TRAE_CHANNEL_PRIORITY, TRAE_CHECKIN_PATH, TRAE_CN_AGENT_TASK_PATH, TRAE_CN_TITLE_PATH, TRAE_COMMON_FUNCTIONS, TRAE_ENTERPRISE_PROVIDER, TRAE_MODELS_TEST_PATH, TRAE_MODEL_DETAIL_FUNCTIONS, TRAE_MODEL_DETAIL_PATH, TRAE_OFFICIAL_ROSTER_PATH, TRAE_PANELS, TRAE_PAY_BASE, TRAE_PROBE_TIMEOUT_MS, TRAE_PROVIDER, TRAE_PROVIDERS, TRAE_PROVIDER_DISPLAY_NAMES, TRAE_PROVIDER_IDS, TRAE_PROVIDER_ID_DISPLAY_NAMES, TRAE_PROVIDER_ROUTES, TRAE_RAW_CHAT_V1_PATH, TRAE_RAW_CHAT_V2_PATH, TRAE_REASONING_EFFORTS, TRAE_REGIONS, TRAE_REGION_PARAM, TRAE_SETTINGS_NS, TRAE_SOLO_CHAT_PATH, TRAE_SOLO_FUNCTION, TRAE_SOLO_MODELS_PATH, TRAE_SOLO_REMOTE_BASE, TRAE_STATE_DB_FILENAME, TRAE_STREAM_IDLE_TIMEOUT_MS, TRAE_USAGE_PATH, TRAE_VERSION_CODE_FALLBACK, TraeCatalog, TraeCredentialStore, TraeDelegatingUpstreamClient, TraeFallbackUpstreamClient, TraeGatedUpstreamClient, TraeOfficialRosterClient, TraeRawCapabilityController, TraeRawCapabilityState, TraeRawChatUpstreamClient, TraeSoloBridge, TraeSoloRemoteCatalogClient, TraeSoloUpstreamClient, TraeUsageClient, UnconfiguredTraeUpstreamClient, adaptLegacyPiAiContext, adaptModernPiAiContext, apply, applyContextBudgets, applyImageSelection, applyOfficialRoster, applyReasoningEffort, asVolatile, bridgeTraeSoloStream, buildTraeAgentTaskBody, buildTraeCnHeaders, buildTraeFusionRawChatEnvelope, buildTraeModelDetailRequest, buildTraeRawChatDraft, buildTraeRawChatRuntimeConfig, classifyProbeError, classifyProbeResult, classifyTraeRawChatFailure, configuredAccountsOf, createTraeAdapter, createTraeRawGateway, createTraeShim, creditPosition, decidePiAiGeneration, decodeRawChatChunk, decodeTraeEvent, decryptTraeStorageValue, deriveCatalog, describeIdShape, describeNameShape, describeTraeFailure, discoveredCatalog, displayNameOfTraeProvider, fallbackModelsFor, filterTraeModels, generationOf, groupTraeModels, hashTraeRawChatArg, identityHeaders, inject, isEnterpriseAccount, isPromotableWireModel, legacyTraeOwnAuthPath, maskUserPath, mergeTraeModelSources, name, nextRegionCreditPosition, nextRegionEnabled, nextRegionSlots, normalizeTraeCredential, normalizeTraeToolSchema, normalizeTraeToolSchemas, normalizeTraeVersionCode, officialVerdictOf, orderTraeModels, panelOfKey, panelOfProvider, parseObservedModelConfig, parseReasoningCapability, parseTraeAuthValue, parseTraeCachedModel, parseTraeModelExtraConfigLogLine, parseTraeOfficialRoster, parseTraeRawChatBehaviorConfig, parseTraeRemoteModel, parseTraeStorageDocument, piAiRuntimeInfo, pickTraeStorageIdentity, prepareSoloBody, probeBody, probeModelsSequentially, probeOneModel, probeTraeRawChatCapability, providerOfPanel, rawCapabilityDiagnostic, rawCapabilityFingerprint, readTraeCachedModel, readTraeCliIdentity, readTraeIdentity, refreshTraeCredential, regionCreditPositionOf, regionEnabled, regionEnabledOf, regionOfCredential, regionOfEdition, regionOfHost, regionOfPanel, regionOfTraeProvider, regionOfTraeStatusUrl, regionOfUserRegion, regionStateOf, registerTraeUsageRoute, resolveTraeIdentity, resolveTraeRawRuntime, routeOfTraeProvider, sanitizeCatalog, scopeTraeModels, settingsNamespaceOf, traeEndpoint, traeInputModalities, traeModelCallChannel, traeModelDisplayName, traeModelInView, traeModelMatchesQuery, traeOwnAuthPath, traeRawChatExtraInfo, traeStateDatabaseCandidates, traeStorageCandidates, traeWebUsage, traeWindowsAppNames, unwrapVolatile, unwrapVolatileDeep, wireTargetsOf, withChatCallableFunctions, withContextAdaptation, withTraeRegion };
|
|
12174
|
+
export { Config, FALLBACK_CONTEXT_WINDOW, FALLBACK_TRAE_MODELS, FALLBACK_TRAE_MODELS_AI, MAX_PROBE_INPUT_TOKENS, REGION_GATEWAYS, SseDecoder, TRAE_ACCOUNT_STATUS_PATH, TRAE_AI_PROVIDER, TRAE_CHANNEL_PRIORITY, TRAE_CHECKIN_PATH, TRAE_CN_AGENT_TASK_PATH, TRAE_CN_TITLE_PATH, TRAE_COMMON_FUNCTIONS, TRAE_ENTERPRISE_PROVIDER, TRAE_MODELS_TEST_PATH, TRAE_MODEL_DETAIL_FUNCTIONS, TRAE_MODEL_DETAIL_PATH, TRAE_OFFICIAL_ROSTER_PATH, TRAE_PANELS, TRAE_PAY_BASE, TRAE_PROBE_TIMEOUT_MS, TRAE_PROVIDER, TRAE_PROVIDERS, TRAE_PROVIDER_DISPLAY_NAMES, TRAE_PROVIDER_IDS, TRAE_PROVIDER_ID_DISPLAY_NAMES, TRAE_PROVIDER_ROUTES, TRAE_RAW_CHAT_V1_PATH, TRAE_RAW_CHAT_V2_PATH, TRAE_REASONING_EFFORTS, TRAE_REGIONS, TRAE_REGION_PARAM, TRAE_SETTINGS_NS, TRAE_SOLO_CHAT_PATH, TRAE_SOLO_FUNCTION, TRAE_SOLO_MODELS_PATH, TRAE_SOLO_REMOTE_BASE, TRAE_STATE_DB_FILENAME, TRAE_STREAM_IDLE_TIMEOUT_MS, TRAE_USAGE_PATH, TRAE_VERSION_CODE_FALLBACK, TraeCatalog, TraeCredentialStore, TraeDelegatingUpstreamClient, TraeFallbackUpstreamClient, TraeGatedUpstreamClient, TraeOfficialRosterClient, TraeRawCapabilityController, TraeRawCapabilityState, TraeRawChatUpstreamClient, TraeSoloBridge, TraeSoloRemoteCatalogClient, TraeSoloUpstreamClient, TraeUsageClient, UnconfiguredTraeUpstreamClient, adaptLegacyPiAiContext, adaptModernPiAiContext, apply, applyContextBudgets, applyImageSelection, applyOfficialRoster, applyReasoningEffort, asVolatile, bridgeTraeSoloStream, buildTraeAgentTaskBody, buildTraeCnHeaders, buildTraeFusionRawChatEnvelope, buildTraeModelDetailRequest, buildTraeRawChatDraft, buildTraeRawChatRuntimeConfig, classifyProbeError, classifyProbeResult, classifyTraeRawChatFailure, configuredAccountsOf, createTraeAdapter, createTraeRawGateway, createTraeShim, creditPosition, decidePiAiGeneration, decodeRawChatChunk, decodeTraeEvent, decryptTraeStorageValue, deriveCatalog, describeIdShape, describeNameShape, describeTraeFailure, discoveredCatalog, displayNameOfTraeProvider, fallbackModelsFor, filterTraeModels, generationOf, groupTraeModels, hashTraeRawChatArg, identityHeaders, inject, isEnterpriseAccount, isPromotableWireModel, legacyTraeOwnAuthPath, maskUserPath, mergeTraeModelSources, name, nextRegionCreditPosition, nextRegionEnabled, nextRegionSlots, normalizeTraeCredential, normalizeTraeToolSchema, normalizeTraeToolSchemas, normalizeTraeVersionCode, officialVerdictOf, orderTraeModels, panelOfKey, panelOfProvider, parseObservedModelConfig, parseReasoningCapability, parseTraeAuthValue, parseTraeCachedModel, parseTraeModelExtraConfigLogLine, parseTraeOfficialRoster, parseTraeRawChatBehaviorConfig, parseTraeRemoteModel, parseTraeStorageDocument, piAiRuntimeInfo, pickTraeStorageIdentity, prepareSoloBody, probeBody, probeModelsSequentially, probeOneModel, probeTraeRawChatCapability, providerOfPanel, rawCapabilityDiagnostic, rawCapabilityFingerprint, readTraeCachedModel, readTraeCliIdentity, readTraeIdentity, refreshTraeCredential, regionCreditPositionOf, regionEnabled, regionEnabledOf, regionOfCredential, regionOfEdition, regionOfHost, regionOfPanel, regionOfTraeProvider, regionOfTraeStatusUrl, regionOfUserRegion, regionStateOf, registerTraeUsageRoute, resolveTraeIdentity, resolveTraeRawRuntime, routeOfTraeProvider, sanitizeCatalog, scopeTraeModels, servedContextWindow, settingsNamespaceOf, traeEndpoint, traeInputModalities, traeModelCallChannel, traeModelDisplayName, traeModelInView, traeModelMatchesQuery, traeOwnAuthPath, traeRawChatExtraInfo, traeStateDatabaseCandidates, traeStorageCandidates, traeWebUsage, traeWindowsAppNames, unwrapVolatile, unwrapVolatileDeep, wireTargetsOf, withChatCallableFunctions, withContextAdaptation, withTraeRegion };
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "dsh-connect-trae",
|
|
3
3
|
"displayName": "DSH Connect Trae",
|
|
4
4
|
"description": "把本机登录的 Trae 模型接入 DeepSeek Harness:国内版与国际版双供应商并行,提供用量/积分概览与每日签到领取。",
|
|
5
|
-
"version": "4.6.
|
|
5
|
+
"version": "4.6.12",
|
|
6
6
|
"author": "dingminhua",
|
|
7
7
|
"copyright": "Copyright (c) 2026 LaoDing",
|
|
8
8
|
"license": "MIT",
|