dsh-connect-trae 2.4.0 → 2.7.0

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
@@ -225,12 +225,22 @@ interface TraeWireModel {
225
225
  * multiplier, reasoning and multimodal flags. `wire` (from `get_detail_param`)
226
226
  * supplies the real `llm_utils_chat` `config_name` — the only id the chat
227
227
  * endpoint actually accepts — plus the authoritative post-discount credit
228
- * multiplier when `display_contact_config` carries one. A remote row is only
229
- * callable when it maps to a wire `config_name`, so a remote row with no wire
230
- * match is DROPPED (it would otherwise be sent as an invalid `config_name` and
231
- * rejected with 4001 "param is invalid"). Verified 2026-08-30: the Remote
232
- * directory advertises `Doubao-Seed-Code` and `glm-5.3`, neither of which is a
233
- * current `config_name`; both fail every request, so they must not be exposed.
228
+ * multiplier when `display_contact_config` carries one.
229
+ *
230
+ * A remote row with no wire match is STILL KEPT (decision 2026-10-02, issue
231
+ * #19). It previously was dropped, on the reasoning that a row with no
232
+ * `config_name` is sent as an invalid one and rejected with 4001. That
233
+ * reasoning holds only for the accounts and functions we can measure, and
234
+ * measuring is the problem: whether a roster contains a model is ACCOUNT-
235
+ * SCOPED, so "no wire entry on a free account" cannot prove a paying account
236
+ * cannot call it. Dropping on that evidence silently denied those users models
237
+ * their own Trae IDE offers. The row therefore ships, and its call fails
238
+ * honestly: the bridge now translates the in-stream refusal into a readable
239
+ * error (`4001` → "Trae does not serve this model under the SOLO function the
240
+ * request used", `4011` → "Trae refused this model under the SOLO function the
241
+ * request used"), so a user who picks an unusable model is told why instead of
242
+ * seeing nothing. This reverses the 2026-08-30 note about `Doubao-Seed-Code`,
243
+ * which later turned out to be callable under `chat_v3`.
234
244
  *
235
245
  * Credit multiplier precedence: the wire's `display_contact_config` rate wins
236
246
  * whenever present (it is the post-discount figure the Trae IDE renders — the
@@ -1326,6 +1336,19 @@ interface TraePayStatus {
1326
1336
  enableSoloBuilder: boolean;
1327
1337
  enableSoloCoder: boolean;
1328
1338
  enableSoloWeb: boolean;
1339
+ /**
1340
+ * The account's plan identity (`user_pay_identity`), Trae's authoritative
1341
+ * tier number: `0` is Free. Measured 2026-10-01 on a live SG community
1342
+ * account, which reported `0` / `"Free"`.
1343
+ *
1344
+ * This is a DIFFERENT question from {@link hasPackage}, which asks whether a
1345
+ * package/entitlement object exists. A paying member can hold a plan
1346
+ * identity without any package row, which is why issue #19 saw "No active
1347
+ * package" on a Pro account — the card only ever read `has_package`.
1348
+ */
1349
+ payIdentity?: number;
1350
+ /** The plan identity as Trae spells it (`user_pay_identity_str`), e.g. `Free`. */
1351
+ payIdentityStr?: string;
1329
1352
  /** The fission (referral) program window and cap, when exposed. */
1330
1353
  fission?: {
1331
1354
  startTimeMs: number;
@@ -1492,6 +1515,13 @@ declare class TraeUsageClient {
1492
1515
  //#region src/status-paths.d.ts
1493
1516
  /** Plugin-owned usage endpoint consumed by its browser half. */
1494
1517
  declare const TRAE_USAGE_PATH = "/plugins/dsh-connect-trae/usage";
1518
+ /**
1519
+ * Plugin-owned availability probe: POST the model ids to test, get one verdict
1520
+ * per model. Unlike every read-only sibling this route SPENDS quota — a real
1521
+ * (minimal) chat call per model — so it is user-initiated only, and the card
1522
+ * labels the button as consuming a small amount.
1523
+ */
1524
+ declare const TRAE_MODELS_TEST_PATH = "/plugins/dsh-connect-trae/models/test";
1495
1525
  /**
1496
1526
  * Plugin-owned daily check-in claim endpoint. POST, loopback-only, and the only
1497
1527
  * route in this plugin that changes upstream account state.
@@ -1548,6 +1578,34 @@ interface TraeWebModel {
1548
1578
  * directory did not declare it, which is not a capability claim either way.
1549
1579
  */
1550
1580
  multimodal?: boolean;
1581
+ /**
1582
+ * The availability verdict from the one-click test, when this card session
1583
+ * has run one. Absent = not tested. Deliberately NOT persisted with the
1584
+ * settings: it describes one moment on one account, and a stale verdict shown
1585
+ * as current is worse than a blank field.
1586
+ */
1587
+ probe?: TraeModelProbeVerdict;
1588
+ /** Upstream's own words for the verdict, when it gave any. */
1589
+ probeDetail?: string;
1590
+ }
1591
+ /**
1592
+ * One model's availability verdict from the one-click test.
1593
+ *
1594
+ * `unknown` is a first-class outcome, not a failure: a timeout, a proxy drop or
1595
+ * a throttle says nothing about the model, and reporting it as unusable would
1596
+ * make the user delete a model that works. Only an upstream refusal is negative.
1597
+ */
1598
+ type TraeModelProbeVerdict = 'available' | 'gated' | 'unsupported' | 'rate_limited' | 'auth' | 'unknown';
1599
+ /** What the probe route answers with. */
1600
+ interface TraeModelsTestResponse {
1601
+ /** One entry per model tested, in the order they were sent. */
1602
+ results: {
1603
+ id: string;
1604
+ verdict: TraeModelProbeVerdict;
1605
+ detail: string;
1606
+ }[];
1607
+ /** Models skipped because the region has no live catalog row for them. */
1608
+ skipped?: string[];
1551
1609
  }
1552
1610
  /**
1553
1611
  * Daily check-in state rendered below the credit stats.
@@ -1695,6 +1753,10 @@ interface TraeWebPayStatus {
1695
1753
  enableSoloBuilder: boolean;
1696
1754
  enableSoloCoder: boolean;
1697
1755
  enableSoloWeb: boolean;
1756
+ /** Trae's authoritative tier number (`user_pay_identity`); `0` means Free. */
1757
+ payIdentity?: number;
1758
+ /** Trae's authoritative tier label (`user_pay_identity_str`), e.g. `Free`. */
1759
+ payIdentityStr?: string;
1698
1760
  fission?: {
1699
1761
  startTimeMs: number;
1700
1762
  expireTimeMs: number;
@@ -1767,6 +1829,18 @@ interface TraeUsageRouteOptions {
1767
1829
  regionEnabled(region: TraeRegion): boolean;
1768
1830
  /** Re-read one region's live directory from the upstream. */
1769
1831
  discoverModels?(region: TraeRegion, signal?: AbortSignal): Promise<readonly TraeModelInfo[]>;
1832
+ /**
1833
+ * Test the given model ids for availability, one real (minimal) chat call
1834
+ * each. Present only when the region's chat path is wired.
1835
+ */
1836
+ probeModels?(region: TraeRegion, ids: readonly string[]): Promise<{
1837
+ results: {
1838
+ id: string;
1839
+ verdict: string;
1840
+ detail: string;
1841
+ }[];
1842
+ skipped?: string[];
1843
+ }>;
1770
1844
  /** Raw-Chat capability state of the requested region. */
1771
1845
  rawDiagnostic?(region: TraeRegion): TraeRawDiagnostic;
1772
1846
  }
@@ -1781,6 +1855,64 @@ declare function traeWebUsage(deps: TraeUsageRouteOptions, region: TraeRegion):
1781
1855
  /** Mount the GET usage route on an optional webServer context. */
1782
1856
  declare function registerTraeUsageRoute(ctx: Context, deps: TraeUsageRouteOptions): void;
1783
1857
  //#endregion
1858
+ //#region src/model-probe.d.ts
1859
+ /** How one model answered. */
1860
+ type TraeProbeVerdict = 'available' | 'gated' | 'unsupported' | 'rate_limited' | 'auth' | 'unknown';
1861
+ interface TraeProbeResult {
1862
+ /** The model id as the card knows it. */
1863
+ id: string;
1864
+ verdict: TraeProbeVerdict;
1865
+ /** Upstream's own words (already translated), or a short note. */
1866
+ detail: string;
1867
+ }
1868
+ /**
1869
+ * How long one probe may take. Trae answers a one-word prompt in a few seconds;
1870
+ * beyond this the answer is not worth waiting for and is reported as unknown.
1871
+ */
1872
+ declare const TRAE_PROBE_TIMEOUT_MS = 30000;
1873
+ /**
1874
+ * Classify a failure that arrived as a thrown stream error rather than a
1875
+ * returned result.
1876
+ *
1877
+ * The bridge errors the stream (instead of returning a result) when a refusal
1878
+ * interrupts an answer that had already started; its message is the same
1879
+ * translated text, so a named code is still decisive. Anything without a
1880
+ * recognised code — an abort, a socket reset, a proxy — stays `unknown`.
1881
+ */
1882
+ declare function classifyProbeError(message: string): {
1883
+ verdict: TraeProbeVerdict;
1884
+ detail: string;
1885
+ };
1886
+ /**
1887
+ * Classify a completed upstream call.
1888
+ *
1889
+ * `result` is what `TraeSoloBridge.chatStream` returned, so a refusal that
1890
+ * arrived inside a 200 body has already been turned into a real error result
1891
+ * (and its code translated into `message`) by the bridge — this function only
1892
+ * has to read it back.
1893
+ */
1894
+ declare function classifyProbeResult(result: TraeChatResult, outputSeen: boolean): {
1895
+ verdict: TraeProbeVerdict;
1896
+ detail: string;
1897
+ };
1898
+ /** The minimal chat call one probe makes. */
1899
+ declare function probeBody(model: string): string;
1900
+ /**
1901
+ * Probe one model through the bridge the plugin actually chats with, so the
1902
+ * recorded verdict describes the user's real path (same wire resolution, same
1903
+ * function stamping, same error translation).
1904
+ */
1905
+ declare function probeOneModel(chat: (body: string, signal?: AbortSignal) => Promise<TraeChatResult>, id: string, timeoutMs?: number): Promise<TraeProbeResult>;
1906
+ /**
1907
+ * Probe a list of models ONE AT A TIME.
1908
+ *
1909
+ * Sequential on purpose: Trae throttles bursts, and a burst of parallel probes
1910
+ * would manufacture the very `rate_limited`/`unknown` verdicts this feature
1911
+ * must avoid. An authentication failure stops the run — every later probe would
1912
+ * fail the same way, and spending calls to learn that again is waste.
1913
+ */
1914
+ declare function probeModelsSequentially(chat: (body: string, signal?: AbortSignal) => Promise<TraeChatResult>, ids: readonly string[], onResult?: (result: TraeProbeResult, index: number) => void): Promise<TraeProbeResult[]>;
1915
+ //#endregion
1784
1916
  //#region src/index.d.ts
1785
1917
  declare const name = "dsh-connect-trae";
1786
1918
  declare const inject: string[];
@@ -1903,4 +2035,4 @@ declare function asVolatile<S>(schema: S): S;
1903
2035
  declare const Config: z<Config>;
1904
2036
  declare function apply(ctx: Context, config: Config): void;
1905
2037
  //#endregion
1906
- export { Config, FALLBACK_TRAE_MODELS, FALLBACK_TRAE_MODELS_AI, REGION_GATEWAYS, type RawChatDelta, type RawChatMessage, type RawChatTool, SseDecoder, type SseEvent, TRAE_AI_PROVIDER, TRAE_CHECKIN_PATH, TRAE_CN_AGENT_TASK_PATH, TRAE_CN_TITLE_PATH, TRAE_MODEL_DETAIL_FUNCTIONS, TRAE_MODEL_DETAIL_PATH, TRAE_PAY_BASE, TRAE_PROVIDER, TRAE_PROVIDERS, TRAE_PROVIDER_DISPLAY_NAMES, 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, TraeFallbackUpstreamClient, type TraeFallbackUpstreamOptions, type TraeFusionRawChatEnvelope, TraeGatedUpstreamClient, type TraeGatedUpstreamOptions, type TraeIdentity, type TraeInputModality, type TraeModelDetailRequest, type TraeModelInfo, type TraeObservedModelConfig, 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 TraeWebActivity, type TraeWebCheckin, type TraeWebCheckinClaim, type TraeWebCredits, type TraeWebUsage, type TraeWireModel, UnconfiguredTraeUpstreamClient, apply, applyContextBudgets, applyImageSelection, applyReasoningEffort, asVolatile, bridgeTraeSoloStream, buildTraeAgentTaskBody, buildTraeCnHeaders, buildTraeFusionRawChatEnvelope, buildTraeModelDetailRequest, buildTraeRawChatDraft, buildTraeRawChatRuntimeConfig, classifyTraeRawChatFailure, createTraeAdapter, createTraeRawGateway, createTraeShim, decodeRawChatChunk, decodeTraeEvent, decryptTraeStorageValue, deriveCatalog, describeIdShape, describeNameShape, discoveredCatalog, fallbackModelsFor, hashTraeRawChatArg, identityHeaders, inject, legacyTraeOwnAuthPath, maskUserPath, mergeTraeModelSources, name, nextRegionEnabled, nextRegionSlots, normalizeTraeCredential, normalizeTraeVersionCode, parseObservedModelConfig, parseReasoningCapability, parseTraeAuthValue, parseTraeCachedModel, parseTraeModelExtraConfigLogLine, parseTraeRawChatBehaviorConfig, parseTraeRemoteModel, parseTraeStorageDocument, pickTraeStorageIdentity, prepareSoloBody, probeTraeRawChatCapability, rawCapabilityDiagnostic, rawCapabilityFingerprint, readTraeCachedModel, readTraeCliIdentity, readTraeIdentity, refreshTraeCredential, regionEnabled, regionEnabledOf, regionOfCredential, regionOfEdition, regionOfHost, regionOfTraeProvider, regionOfTraeStatusUrl, regionOfUserRegion, regionStateOf, registerTraeUsageRoute, resolveTraeIdentity, resolveTraeRawRuntime, sanitizeCatalog, settingsNamespaceOf, traeEndpoint, traeInputModalities, traeModelDisplayName, traeOwnAuthPath, traeRawChatExtraInfo, traeStateDatabaseCandidates, traeStorageCandidates, traeWebUsage, traeWindowsAppNames, unwrapVolatile, unwrapVolatileDeep, withTraeRegion };
2038
+ export { Config, FALLBACK_TRAE_MODELS, FALLBACK_TRAE_MODELS_AI, REGION_GATEWAYS, type RawChatDelta, type RawChatMessage, type RawChatTool, SseDecoder, type SseEvent, TRAE_AI_PROVIDER, TRAE_CHECKIN_PATH, TRAE_CN_AGENT_TASK_PATH, TRAE_CN_TITLE_PATH, TRAE_MODELS_TEST_PATH, TRAE_MODEL_DETAIL_FUNCTIONS, TRAE_MODEL_DETAIL_PATH, TRAE_PAY_BASE, TRAE_PROBE_TIMEOUT_MS, TRAE_PROVIDER, TRAE_PROVIDERS, TRAE_PROVIDER_DISPLAY_NAMES, 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, TraeFallbackUpstreamClient, type TraeFallbackUpstreamOptions, type TraeFusionRawChatEnvelope, TraeGatedUpstreamClient, type TraeGatedUpstreamOptions, type TraeIdentity, type TraeInputModality, type TraeModelDetailRequest, type TraeModelInfo, type TraeModelProbeVerdict, type TraeModelsTestResponse, type TraeObservedModelConfig, type TraeProbeResult, type TraeProbeVerdict, 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 TraeWebActivity, type TraeWebCheckin, type TraeWebCheckinClaim, type TraeWebCredits, type TraeWebUsage, type TraeWireModel, UnconfiguredTraeUpstreamClient, apply, applyContextBudgets, applyImageSelection, applyReasoningEffort, asVolatile, bridgeTraeSoloStream, buildTraeAgentTaskBody, buildTraeCnHeaders, buildTraeFusionRawChatEnvelope, buildTraeModelDetailRequest, buildTraeRawChatDraft, buildTraeRawChatRuntimeConfig, classifyProbeError, classifyProbeResult, classifyTraeRawChatFailure, createTraeAdapter, createTraeRawGateway, createTraeShim, decodeRawChatChunk, decodeTraeEvent, decryptTraeStorageValue, deriveCatalog, describeIdShape, describeNameShape, discoveredCatalog, fallbackModelsFor, hashTraeRawChatArg, identityHeaders, inject, legacyTraeOwnAuthPath, maskUserPath, mergeTraeModelSources, name, nextRegionEnabled, nextRegionSlots, normalizeTraeCredential, normalizeTraeVersionCode, parseObservedModelConfig, parseReasoningCapability, parseTraeAuthValue, parseTraeCachedModel, parseTraeModelExtraConfigLogLine, parseTraeRawChatBehaviorConfig, parseTraeRemoteModel, parseTraeStorageDocument, pickTraeStorageIdentity, prepareSoloBody, probeBody, probeModelsSequentially, probeOneModel, probeTraeRawChatCapability, rawCapabilityDiagnostic, rawCapabilityFingerprint, readTraeCachedModel, readTraeCliIdentity, readTraeIdentity, refreshTraeCredential, regionEnabled, regionEnabledOf, regionOfCredential, regionOfEdition, regionOfHost, regionOfTraeProvider, regionOfTraeStatusUrl, regionOfUserRegion, regionStateOf, registerTraeUsageRoute, resolveTraeIdentity, resolveTraeRawRuntime, sanitizeCatalog, settingsNamespaceOf, traeEndpoint, traeInputModalities, traeModelDisplayName, traeOwnAuthPath, traeRawChatExtraInfo, traeStateDatabaseCandidates, traeStorageCandidates, traeWebUsage, traeWindowsAppNames, unwrapVolatile, unwrapVolatileDeep, withTraeRegion };