dsh-connect-trae 4.4.1 → 4.4.3

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/lib/index.d.ts CHANGED
@@ -2465,6 +2465,35 @@ declare function traeEndpoint(baseUrl: string, path: string): string;
2465
2465
  //#region src/raw-chat.d.ts
2466
2466
  declare const TRAE_RAW_CHAT_V2_PATH = "/api/ide/v2/llm_raw_chat";
2467
2467
  declare const TRAE_RAW_CHAT_V1_PATH = "/api/ide/v1/llm_raw_chat";
2468
+ /**
2469
+ * Normalise a tool `parameters` schema from JSON Schema draft-3 style to
2470
+ * draft-4 style (issue #49).
2471
+ *
2472
+ * Draft-3 declared a required property by putting a boolean `required: true`
2473
+ * INSIDE the property schema:
2474
+ *
2475
+ * { "type": "object", "properties": { "tool": { "type": "string", "required": true } } }
2476
+ *
2477
+ * Draft-4 removed the per-property boolean and uses a parent-level string
2478
+ * array instead: `{ "required": ["tool"] }`. The Trae backends disagree on how
2479
+ * strictly they check this: the Zhipu backend (glm-5.2) tolerates draft-3
2480
+ * `required: true`, but the DeepSeek backend (deepseek-v4.1-flash) rejects the
2481
+ * whole request with `4027 … tools.N.function.parameters/properties/X/required:
2482
+ * invalid JSON Schema` whenever ANY tool carries the boolean form — and
2483
+ * `tools.N` are validated as a batch, so one bad schema fails the entire turn
2484
+ * (issue #49, after #48). Since a model's backend is chosen by the upstream
2485
+ * router and can change per config, every tool-carrying request must be
2486
+ * draft-4 clean regardless of which backend the probe last saw.
2487
+ *
2488
+ * The rewrite is local, idempotent, and recursive: it lifts each boolean
2489
+ * `required` up to the enclosing schema's `required` array (merging with any
2490
+ * array already present), then drops the boolean. Non-object property entries
2491
+ * are left untouched — draft-4 forbids boolean schemas anyway, so no boolean
2492
+ * `required` can hide inside them.
2493
+ */
2494
+ declare function normalizeTraeToolSchema(value: unknown): unknown;
2495
+ /** Issue #49: apply `normalizeTraeToolSchema` to an OpenAI-style tool list. */
2496
+ declare function normalizeTraeToolSchemas<T>(tools: readonly T[]): T[];
2468
2497
  type RawChatRole = 'assistant' | 'system' | 'tool' | 'user';
2469
2498
  interface RawChatTextContent {
2470
2499
  type: 'text';
@@ -3999,4 +4028,4 @@ declare function asVolatile<S>(schema: S): S;
3999
4028
  declare const Config: z<Config>;
4000
4029
  declare function apply(ctx: Context$1, config: Config): void;
4001
4030
  //#endregion
4002
- 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_CHECKIN_PATH, TRAE_CN_AGENT_TASK_PATH, TRAE_CN_TITLE_PATH, TRAE_ENTERPRISE_PROVIDER, TRAE_MODELS_TEST_PATH, TRAE_MODEL_DETAIL_FUNCTIONS, TRAE_MODEL_DETAIL_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 TraeModelInfo, type TraeModelProbeVerdict, type TraeModelsTestResponse, type TraeObservedModelConfig, 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, 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, generationOf, hashTraeRawChatArg, identityHeaders, inject, isEnterpriseAccount, isPromotableWireModel, legacyTraeOwnAuthPath, maskUserPath, mergeTraeModelSources, name, nextRegionCreditPosition, nextRegionEnabled, nextRegionSlots, normalizeTraeCredential, normalizeTraeVersionCode, panelOfKey, panelOfProvider, parseObservedModelConfig, parseReasoningCapability, parseTraeAuthValue, parseTraeCachedModel, parseTraeModelExtraConfigLogLine, 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, settingsNamespaceOf, traeEndpoint, traeInputModalities, traeModelDisplayName, traeOwnAuthPath, traeRawChatExtraInfo, traeStateDatabaseCandidates, traeStorageCandidates, traeWebUsage, traeWindowsAppNames, unwrapVolatile, unwrapVolatileDeep, wireTargetsOf, withContextAdaptation, withTraeRegion };
4031
+ 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_CHECKIN_PATH, TRAE_CN_AGENT_TASK_PATH, TRAE_CN_TITLE_PATH, TRAE_ENTERPRISE_PROVIDER, TRAE_MODELS_TEST_PATH, TRAE_MODEL_DETAIL_FUNCTIONS, TRAE_MODEL_DETAIL_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 TraeModelInfo, type TraeModelProbeVerdict, type TraeModelsTestResponse, type TraeObservedModelConfig, 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, 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, generationOf, hashTraeRawChatArg, identityHeaders, inject, isEnterpriseAccount, isPromotableWireModel, legacyTraeOwnAuthPath, maskUserPath, mergeTraeModelSources, name, nextRegionCreditPosition, nextRegionEnabled, nextRegionSlots, normalizeTraeCredential, normalizeTraeToolSchema, normalizeTraeToolSchemas, normalizeTraeVersionCode, panelOfKey, panelOfProvider, parseObservedModelConfig, parseReasoningCapability, parseTraeAuthValue, parseTraeCachedModel, parseTraeModelExtraConfigLogLine, 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, settingsNamespaceOf, traeEndpoint, traeInputModalities, traeModelDisplayName, traeOwnAuthPath, traeRawChatExtraInfo, traeStateDatabaseCandidates, traeStorageCandidates, traeWebUsage, traeWindowsAppNames, unwrapVolatile, unwrapVolatileDeep, wireTargetsOf, withContextAdaptation, withTraeRegion };
package/lib/index.js CHANGED
@@ -1364,8 +1364,9 @@ function regionsMapOf(value) {
1364
1364
  if (typeof unwrapped !== "object" || unwrapped === null || Array.isArray(unwrapped)) return {};
1365
1365
  const record = unwrapped;
1366
1366
  const nested = record["regions"];
1367
- if (typeof nested === "object" && nested !== null && !Array.isArray(nested)) return nested;
1368
- return record;
1367
+ if (typeof nested !== "object" || nested === null || Array.isArray(nested)) return record;
1368
+ const panelIds = TRAE_PANELS;
1369
+ return Object.keys(record).some((key) => panelIds.includes(key)) ? record : nested;
1369
1370
  }
1370
1371
  /** One region's stored slot as a plain object; any other shape reads as empty. */
1371
1372
  function regionSlotOf(value, panel) {
@@ -3874,6 +3875,147 @@ function traeEndpoint(baseUrl, path) {
3874
3875
  return `${baseUrl.replace(/\/$/, "")}/${path.replace(/^\//, "")}`;
3875
3876
  }
3876
3877
  //#endregion
3878
+ //#region src/raw-chat.ts
3879
+ const TRAE_RAW_CHAT_V2_PATH = "/api/ide/v2/llm_raw_chat";
3880
+ const TRAE_RAW_CHAT_V1_PATH = "/api/ide/v1/llm_raw_chat";
3881
+ /**
3882
+ * Normalise a tool `parameters` schema from JSON Schema draft-3 style to
3883
+ * draft-4 style (issue #49).
3884
+ *
3885
+ * Draft-3 declared a required property by putting a boolean `required: true`
3886
+ * INSIDE the property schema:
3887
+ *
3888
+ * { "type": "object", "properties": { "tool": { "type": "string", "required": true } } }
3889
+ *
3890
+ * Draft-4 removed the per-property boolean and uses a parent-level string
3891
+ * array instead: `{ "required": ["tool"] }`. The Trae backends disagree on how
3892
+ * strictly they check this: the Zhipu backend (glm-5.2) tolerates draft-3
3893
+ * `required: true`, but the DeepSeek backend (deepseek-v4.1-flash) rejects the
3894
+ * whole request with `4027 … tools.N.function.parameters/properties/X/required:
3895
+ * invalid JSON Schema` whenever ANY tool carries the boolean form — and
3896
+ * `tools.N` are validated as a batch, so one bad schema fails the entire turn
3897
+ * (issue #49, after #48). Since a model's backend is chosen by the upstream
3898
+ * router and can change per config, every tool-carrying request must be
3899
+ * draft-4 clean regardless of which backend the probe last saw.
3900
+ *
3901
+ * The rewrite is local, idempotent, and recursive: it lifts each boolean
3902
+ * `required` up to the enclosing schema's `required` array (merging with any
3903
+ * array already present), then drops the boolean. Non-object property entries
3904
+ * are left untouched — draft-4 forbids boolean schemas anyway, so no boolean
3905
+ * `required` can hide inside them.
3906
+ */
3907
+ function normalizeTraeToolSchema(value) {
3908
+ if (Array.isArray(value)) {
3909
+ let changed = false;
3910
+ const items = value.map((item) => {
3911
+ const next = normalizeTraeToolSchema(item);
3912
+ if (next !== item) changed = true;
3913
+ return next;
3914
+ });
3915
+ return changed ? items : value;
3916
+ }
3917
+ if (typeof value !== "object" || value === null) return value;
3918
+ const source = value;
3919
+ const result = {};
3920
+ for (const [key, entry] of Object.entries(source)) {
3921
+ if (key === "required" && typeof entry === "boolean") continue;
3922
+ result[key] = normalizeTraeToolSchema(entry);
3923
+ }
3924
+ const properties = source["properties"];
3925
+ if (typeof properties === "object" && properties !== null && !Array.isArray(properties)) {
3926
+ const promoted = [];
3927
+ if (Array.isArray(source["required"])) {
3928
+ for (const name of source["required"]) if (typeof name === "string" && !promoted.includes(name)) promoted.push(name);
3929
+ }
3930
+ for (const [name, property] of Object.entries(properties)) if (typeof property === "object" && property !== null && property["required"] === true && !promoted.includes(name)) promoted.push(name);
3931
+ if (promoted.length > 0) result["required"] = promoted;
3932
+ }
3933
+ return JSON.stringify(result) === JSON.stringify(value) ? value : result;
3934
+ }
3935
+ /** Issue #49: apply `normalizeTraeToolSchema` to an OpenAI-style tool list. */
3936
+ function normalizeTraeToolSchemas(tools) {
3937
+ return tools.map((tool) => normalizeTraeToolSchema(tool));
3938
+ }
3939
+ /**
3940
+ * Evidence-bounded OpenAI-like draft inferred from Trae's LLMRaw* DTO symbols.
3941
+ * Pure/offline only: the upstream remains disabled until one controlled probe.
3942
+ */
3943
+ function buildTraeRawChatDraft(input) {
3944
+ if (input.model.trim() === "") throw new Error("Trae raw chat requires a model");
3945
+ if (input.messages.length === 0) throw new Error("Trae raw chat requires messages");
3946
+ return {
3947
+ model: input.model,
3948
+ messages: structuredClone([...input.messages]),
3949
+ stream: true,
3950
+ ...input.tools === void 0 || input.tools.length === 0 ? {} : { tools: normalizeTraeToolSchemas(structuredClone([...input.tools])) },
3951
+ ...input.maxTokens === void 0 ? {} : { max_tokens: input.maxTokens },
3952
+ ...input.temperature === void 0 ? {} : { temperature: input.temperature },
3953
+ ...input.reasoningEffort === void 0 ? {} : { reasoning_effort: input.reasoningEffort },
3954
+ ...input.extraInfo === void 0 ? {} : { extra_info: structuredClone(input.extraInfo) }
3955
+ };
3956
+ }
3957
+ /** Decode OpenAI-like raw-chat chunks while preserving unknown structures. */
3958
+ function decodeRawChatChunk(value) {
3959
+ if (value === "[DONE]") return [{
3960
+ type: "done",
3961
+ finishReason: "stop"
3962
+ }];
3963
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return [{
3964
+ type: "unknown",
3965
+ value
3966
+ }];
3967
+ const record = value;
3968
+ const result = [];
3969
+ const choices = Array.isArray(record["choices"]) ? record["choices"] : [];
3970
+ for (const rawChoice of choices) {
3971
+ if (typeof rawChoice !== "object" || rawChoice === null) continue;
3972
+ const choice = rawChoice;
3973
+ const delta = typeof choice["delta"] === "object" && choice["delta"] !== null ? choice["delta"] : {};
3974
+ if (typeof delta["reasoning_content"] === "string" && delta["reasoning_content"] !== "") result.push({
3975
+ type: "reasoning",
3976
+ text: delta["reasoning_content"]
3977
+ });
3978
+ if (typeof delta["content"] === "string" && delta["content"] !== "") result.push({
3979
+ type: "text",
3980
+ text: delta["content"]
3981
+ });
3982
+ if (Array.isArray(delta["tool_calls"])) for (const rawTool of delta["tool_calls"]) {
3983
+ if (typeof rawTool !== "object" || rawTool === null) continue;
3984
+ const tool = rawTool;
3985
+ const fn = typeof tool["function"] === "object" && tool["function"] !== null ? tool["function"] : {};
3986
+ result.push({
3987
+ type: "tool-call",
3988
+ index: typeof tool["index"] === "number" ? tool["index"] : 0,
3989
+ ...typeof tool["id"] === "string" ? { id: tool["id"] } : {},
3990
+ ...typeof fn["name"] === "string" ? { name: fn["name"] } : {},
3991
+ ...typeof fn["arguments"] === "string" ? { arguments: fn["arguments"] } : {}
3992
+ });
3993
+ }
3994
+ if (typeof choice["finish_reason"] === "string" && choice["finish_reason"] !== "") result.push({
3995
+ type: "done",
3996
+ finishReason: choice["finish_reason"]
3997
+ });
3998
+ }
3999
+ if (typeof record["usage"] === "object" && record["usage"] !== null) {
4000
+ const usage = record["usage"];
4001
+ const details = typeof usage["prompt_tokens_details"] === "object" && usage["prompt_tokens_details"] !== null ? usage["prompt_tokens_details"] : {};
4002
+ const cacheRead = details["cached_tokens"] ?? usage["prompt_cache_hit_tokens"] ?? usage["cached_tokens"];
4003
+ const cacheWrite = details["cache_write_tokens"];
4004
+ result.push({
4005
+ type: "usage",
4006
+ ...typeof usage["prompt_tokens"] === "number" ? { inputTokens: usage["prompt_tokens"] } : {},
4007
+ ...typeof usage["completion_tokens"] === "number" ? { outputTokens: usage["completion_tokens"] } : {},
4008
+ ...typeof usage["total_tokens"] === "number" ? { totalTokens: usage["total_tokens"] } : {},
4009
+ ...typeof cacheRead === "number" ? { cacheReadTokens: cacheRead } : {},
4010
+ ...typeof cacheWrite === "number" ? { cacheWriteTokens: cacheWrite } : {}
4011
+ });
4012
+ }
4013
+ return result.length === 0 ? [{
4014
+ type: "unknown",
4015
+ value
4016
+ }] : result;
4017
+ }
4018
+ //#endregion
3877
4019
  //#region src/promo.ts
3878
4020
  function record$1(value) {
3879
4021
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
@@ -4127,7 +4269,7 @@ function prepareSoloBody(source, defaultModel = "glm-5.2", functionName) {
4127
4269
  const fn = raw["function"];
4128
4270
  if (typeof fn !== "object" || fn === null) continue;
4129
4271
  const record = fn;
4130
- if (typeof record["parameters"] === "object" && record["parameters"] !== null) record["parameters"] = JSON.stringify(record["parameters"]);
4272
+ if (typeof record["parameters"] === "object" && record["parameters"] !== null) record["parameters"] = JSON.stringify(normalizeTraeToolSchema(record["parameters"]));
4131
4273
  }
4132
4274
  return JSON.stringify(body);
4133
4275
  }
@@ -5588,89 +5730,6 @@ var TraeSoloRemoteCatalogClient = class TraeSoloRemoteCatalogClient {
5588
5730
  }
5589
5731
  };
5590
5732
  //#endregion
5591
- //#region src/raw-chat.ts
5592
- const TRAE_RAW_CHAT_V2_PATH = "/api/ide/v2/llm_raw_chat";
5593
- const TRAE_RAW_CHAT_V1_PATH = "/api/ide/v1/llm_raw_chat";
5594
- /**
5595
- * Evidence-bounded OpenAI-like draft inferred from Trae's LLMRaw* DTO symbols.
5596
- * Pure/offline only: the upstream remains disabled until one controlled probe.
5597
- */
5598
- function buildTraeRawChatDraft(input) {
5599
- if (input.model.trim() === "") throw new Error("Trae raw chat requires a model");
5600
- if (input.messages.length === 0) throw new Error("Trae raw chat requires messages");
5601
- return {
5602
- model: input.model,
5603
- messages: structuredClone([...input.messages]),
5604
- stream: true,
5605
- ...input.tools === void 0 || input.tools.length === 0 ? {} : { tools: structuredClone([...input.tools]) },
5606
- ...input.maxTokens === void 0 ? {} : { max_tokens: input.maxTokens },
5607
- ...input.temperature === void 0 ? {} : { temperature: input.temperature },
5608
- ...input.reasoningEffort === void 0 ? {} : { reasoning_effort: input.reasoningEffort },
5609
- ...input.extraInfo === void 0 ? {} : { extra_info: structuredClone(input.extraInfo) }
5610
- };
5611
- }
5612
- /** Decode OpenAI-like raw-chat chunks while preserving unknown structures. */
5613
- function decodeRawChatChunk(value) {
5614
- if (value === "[DONE]") return [{
5615
- type: "done",
5616
- finishReason: "stop"
5617
- }];
5618
- if (typeof value !== "object" || value === null || Array.isArray(value)) return [{
5619
- type: "unknown",
5620
- value
5621
- }];
5622
- const record = value;
5623
- const result = [];
5624
- const choices = Array.isArray(record["choices"]) ? record["choices"] : [];
5625
- for (const rawChoice of choices) {
5626
- if (typeof rawChoice !== "object" || rawChoice === null) continue;
5627
- const choice = rawChoice;
5628
- const delta = typeof choice["delta"] === "object" && choice["delta"] !== null ? choice["delta"] : {};
5629
- if (typeof delta["reasoning_content"] === "string" && delta["reasoning_content"] !== "") result.push({
5630
- type: "reasoning",
5631
- text: delta["reasoning_content"]
5632
- });
5633
- if (typeof delta["content"] === "string" && delta["content"] !== "") result.push({
5634
- type: "text",
5635
- text: delta["content"]
5636
- });
5637
- if (Array.isArray(delta["tool_calls"])) for (const rawTool of delta["tool_calls"]) {
5638
- if (typeof rawTool !== "object" || rawTool === null) continue;
5639
- const tool = rawTool;
5640
- const fn = typeof tool["function"] === "object" && tool["function"] !== null ? tool["function"] : {};
5641
- result.push({
5642
- type: "tool-call",
5643
- index: typeof tool["index"] === "number" ? tool["index"] : 0,
5644
- ...typeof tool["id"] === "string" ? { id: tool["id"] } : {},
5645
- ...typeof fn["name"] === "string" ? { name: fn["name"] } : {},
5646
- ...typeof fn["arguments"] === "string" ? { arguments: fn["arguments"] } : {}
5647
- });
5648
- }
5649
- if (typeof choice["finish_reason"] === "string" && choice["finish_reason"] !== "") result.push({
5650
- type: "done",
5651
- finishReason: choice["finish_reason"]
5652
- });
5653
- }
5654
- if (typeof record["usage"] === "object" && record["usage"] !== null) {
5655
- const usage = record["usage"];
5656
- const details = typeof usage["prompt_tokens_details"] === "object" && usage["prompt_tokens_details"] !== null ? usage["prompt_tokens_details"] : {};
5657
- const cacheRead = details["cached_tokens"] ?? usage["prompt_cache_hit_tokens"] ?? usage["cached_tokens"];
5658
- const cacheWrite = details["cache_write_tokens"];
5659
- result.push({
5660
- type: "usage",
5661
- ...typeof usage["prompt_tokens"] === "number" ? { inputTokens: usage["prompt_tokens"] } : {},
5662
- ...typeof usage["completion_tokens"] === "number" ? { outputTokens: usage["completion_tokens"] } : {},
5663
- ...typeof usage["total_tokens"] === "number" ? { totalTokens: usage["total_tokens"] } : {},
5664
- ...typeof cacheRead === "number" ? { cacheReadTokens: cacheRead } : {},
5665
- ...typeof cacheWrite === "number" ? { cacheWriteTokens: cacheWrite } : {}
5666
- });
5667
- }
5668
- return result.length === 0 ? [{
5669
- type: "unknown",
5670
- value
5671
- }] : result;
5672
- }
5673
- //#endregion
5674
5733
  //#region src/raw-runtime-config.ts
5675
5734
  /** Merge safe current-cache facts with observed behavior flags; no network credentials enter this object. */
5676
5735
  function traeRawChatExtraInfo(config) {
@@ -10235,4 +10294,4 @@ function apply(ctx, config) {
10235
10294
  });
10236
10295
  }
10237
10296
  //#endregion
10238
- export { Config, FALLBACK_TRAE_MODELS, FALLBACK_TRAE_MODELS_AI, MAX_PROBE_INPUT_TOKENS, REGION_GATEWAYS, SseDecoder, TRAE_ACCOUNT_STATUS_PATH, TRAE_AI_PROVIDER, TRAE_CHECKIN_PATH, TRAE_CN_AGENT_TASK_PATH, TRAE_CN_TITLE_PATH, TRAE_ENTERPRISE_PROVIDER, TRAE_MODELS_TEST_PATH, TRAE_MODEL_DETAIL_FUNCTIONS, TRAE_MODEL_DETAIL_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, TraeRawCapabilityController, TraeRawCapabilityState, TraeRawChatUpstreamClient, TraeSoloBridge, TraeSoloRemoteCatalogClient, TraeSoloUpstreamClient, TraeUsageClient, UnconfiguredTraeUpstreamClient, adaptLegacyPiAiContext, adaptModernPiAiContext, apply, applyContextBudgets, applyImageSelection, 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, generationOf, hashTraeRawChatArg, identityHeaders, inject, isEnterpriseAccount, isPromotableWireModel, legacyTraeOwnAuthPath, maskUserPath, mergeTraeModelSources, name, nextRegionCreditPosition, nextRegionEnabled, nextRegionSlots, normalizeTraeCredential, normalizeTraeVersionCode, panelOfKey, panelOfProvider, parseObservedModelConfig, parseReasoningCapability, parseTraeAuthValue, parseTraeCachedModel, parseTraeModelExtraConfigLogLine, 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, settingsNamespaceOf, traeEndpoint, traeInputModalities, traeModelDisplayName, traeOwnAuthPath, traeRawChatExtraInfo, traeStateDatabaseCandidates, traeStorageCandidates, traeWebUsage, traeWindowsAppNames, unwrapVolatile, unwrapVolatileDeep, wireTargetsOf, withContextAdaptation, withTraeRegion };
10297
+ export { Config, FALLBACK_TRAE_MODELS, FALLBACK_TRAE_MODELS_AI, MAX_PROBE_INPUT_TOKENS, REGION_GATEWAYS, SseDecoder, TRAE_ACCOUNT_STATUS_PATH, TRAE_AI_PROVIDER, TRAE_CHECKIN_PATH, TRAE_CN_AGENT_TASK_PATH, TRAE_CN_TITLE_PATH, TRAE_ENTERPRISE_PROVIDER, TRAE_MODELS_TEST_PATH, TRAE_MODEL_DETAIL_FUNCTIONS, TRAE_MODEL_DETAIL_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, TraeRawCapabilityController, TraeRawCapabilityState, TraeRawChatUpstreamClient, TraeSoloBridge, TraeSoloRemoteCatalogClient, TraeSoloUpstreamClient, TraeUsageClient, UnconfiguredTraeUpstreamClient, adaptLegacyPiAiContext, adaptModernPiAiContext, apply, applyContextBudgets, applyImageSelection, 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, generationOf, hashTraeRawChatArg, identityHeaders, inject, isEnterpriseAccount, isPromotableWireModel, legacyTraeOwnAuthPath, maskUserPath, mergeTraeModelSources, name, nextRegionCreditPosition, nextRegionEnabled, nextRegionSlots, normalizeTraeCredential, normalizeTraeToolSchema, normalizeTraeToolSchemas, normalizeTraeVersionCode, panelOfKey, panelOfProvider, parseObservedModelConfig, parseReasoningCapability, parseTraeAuthValue, parseTraeCachedModel, parseTraeModelExtraConfigLogLine, 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, settingsNamespaceOf, traeEndpoint, traeInputModalities, traeModelDisplayName, traeOwnAuthPath, traeRawChatExtraInfo, traeStateDatabaseCandidates, traeStorageCandidates, traeWebUsage, traeWindowsAppNames, unwrapVolatile, unwrapVolatileDeep, wireTargetsOf, 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.4.1",
5
+ "version": "4.4.3",
6
6
  "author": "dingminhua",
7
7
  "copyright": "Copyright (c) 2026 LaoDing",
8
8
  "license": "MIT",