cartethyia 2.7.8 → 2.8.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/.env.example +3 -3
- package/README.md +29 -59
- package/dist/dashboard/assets/BannedPage-Cc0vKpMG.js +1 -0
- package/dist/dashboard/assets/BannedPage-Cc0vKpMG.js.gz +0 -0
- package/dist/dashboard/assets/{CliToolDetailPage-BRWKPQPf.js → CliToolDetailPage-Bqj2aa1T.js} +1 -1
- package/dist/dashboard/assets/CliToolDetailPage-Bqj2aa1T.js.gz +0 -0
- package/dist/dashboard/assets/{CliToolsPage-BP-Y5iHN.js → CliToolsPage-CXsaOAO2.js} +1 -1
- package/dist/dashboard/assets/CliToolsPage-CXsaOAO2.js.gz +0 -0
- package/dist/dashboard/assets/CombosPage-BeLpJ4ma.js +1 -0
- package/dist/dashboard/assets/CombosPage-BeLpJ4ma.js.gz +0 -0
- package/dist/dashboard/assets/ConsoleLogPage-DnV0uZ3m.js +1 -0
- package/dist/dashboard/assets/ConsoleLogPage-DnV0uZ3m.js.gz +0 -0
- package/dist/dashboard/assets/CustomizationPage-CBxAjo63.js +1 -0
- package/dist/dashboard/assets/CustomizationPage-CBxAjo63.js.gz +0 -0
- package/dist/dashboard/assets/HealthEventsModal-B5yEE0k6.js +1 -0
- package/dist/dashboard/assets/HealthEventsModal-B5yEE0k6.js.gz +0 -0
- package/dist/dashboard/assets/{InjectSystemPromptPanel-Cv-2Ol_K.js → InjectSystemPromptPanel-BWFLECmz.js} +2 -2
- package/dist/dashboard/assets/InjectSystemPromptPanel-BWFLECmz.js.gz +0 -0
- package/dist/dashboard/assets/{LoginPage-bKfz_b1K.js → LoginPage-CgoPc5B9.js} +1 -1
- package/dist/dashboard/assets/LoginPage-CgoPc5B9.js.gz +0 -0
- package/dist/dashboard/assets/{ModelPicker-B-WQxx_H.js → ModelPicker-D9bFQern.js} +1 -1
- package/dist/dashboard/assets/ModelPicker-D9bFQern.js.gz +0 -0
- package/dist/dashboard/assets/OverviewPage-B_p4tL8k.js +1 -0
- package/dist/dashboard/assets/OverviewPage-B_p4tL8k.js.gz +0 -0
- package/dist/dashboard/assets/ProviderDetailPage-rs5E2rxv.js +8 -0
- package/dist/dashboard/assets/ProviderDetailPage-rs5E2rxv.js.gz +0 -0
- package/dist/dashboard/assets/ProviderIcon-D_0PiZtg.js +1 -0
- package/dist/dashboard/assets/ProviderIcon-D_0PiZtg.js.gz +0 -0
- package/dist/dashboard/assets/ProvidersPage-CLI2bJTK.js +1 -0
- package/dist/dashboard/assets/ProvidersPage-CLI2bJTK.js.gz +0 -0
- package/dist/dashboard/assets/{ProxyPage-emlTuxz6.js → ProxyPage-BwNC_-Cx.js} +1 -1
- package/dist/dashboard/assets/ProxyPage-BwNC_-Cx.js.gz +0 -0
- package/dist/dashboard/assets/QuotaPage-DA-a1iSN.js +1 -0
- package/dist/dashboard/assets/QuotaPage-DA-a1iSN.js.gz +0 -0
- package/dist/dashboard/assets/SettingsPage-CctTga2C.js +1 -0
- package/dist/dashboard/assets/SettingsPage-CctTga2C.js.gz +0 -0
- package/dist/dashboard/assets/{SetupPage-CUZrKs9r.js → SetupPage-febLU4r1.js} +1 -1
- package/dist/dashboard/assets/SetupPage-febLU4r1.js.gz +0 -0
- package/dist/dashboard/assets/{StudioPage-jWmUdDpy.js → StudioPage-M6fvR5Wz.js} +1 -1
- package/dist/dashboard/assets/StudioPage-M6fvR5Wz.js.gz +0 -0
- package/dist/dashboard/assets/UsagePage-nyeuRqz9.js +56 -0
- package/dist/dashboard/assets/UsagePage-nyeuRqz9.js.gz +0 -0
- package/dist/dashboard/assets/api-keys-BFOlvrJC.js +1 -0
- package/dist/dashboard/assets/api-keys-BFOlvrJC.js.gz +0 -0
- package/dist/dashboard/assets/app-Dx2QgsNj.css +2 -0
- package/dist/dashboard/assets/app-Dx2QgsNj.css.gz +0 -0
- package/dist/dashboard/assets/{assert-CidQVoNo.js → assert-CqTLw5e7.js} +1 -1
- package/dist/dashboard/assets/assert-CqTLw5e7.js.gz +0 -0
- package/dist/dashboard/assets/{badge-DyI_mJfi.js → badge-C83EqLB0.js} +1 -1
- package/dist/dashboard/assets/badge-C83EqLB0.js.gz +0 -0
- package/dist/dashboard/assets/ban-durations-B58FyRxC.js +1 -0
- package/dist/dashboard/assets/ban-durations-B58FyRxC.js.gz +0 -0
- package/dist/dashboard/assets/{banner-B-yXtCqb.js → banner-D1xn7pIe.js} +1 -1
- package/dist/dashboard/assets/banner-D1xn7pIe.js.gz +0 -0
- package/dist/dashboard/assets/brand/bansos_page.webp +0 -0
- package/dist/dashboard/assets/brand/denia_bansos.webp +0 -0
- package/dist/dashboard/assets/brand/favicon.webp +0 -0
- package/dist/dashboard/assets/brand/login_register.webp +0 -0
- package/dist/dashboard/assets/brand/login_register_initial.webp +0 -0
- package/dist/dashboard/assets/brand/og_bansos.webp +0 -0
- package/dist/dashboard/assets/brand/og_image.webp +0 -0
- package/dist/dashboard/assets/brand/sidebar_ico.webp +0 -0
- package/dist/dashboard/assets/{card-_HwAEqFF.js → card-DU3Lq5Lm.js} +1 -1
- package/dist/dashboard/assets/card-DU3Lq5Lm.js.gz +0 -0
- package/dist/dashboard/assets/cli-tools-Dw1U_drK.js +1 -0
- package/dist/dashboard/assets/cli-tools-Dw1U_drK.js.gz +0 -0
- package/dist/dashboard/assets/{clipboard-button-ByjCk0o9.js → clipboard-button-CEL5Sg_J.js} +1 -1
- package/dist/dashboard/assets/clipboard-button-CEL5Sg_J.js.gz +0 -0
- package/dist/dashboard/assets/{dialog-BZhOlfz-.js → dialog-BjFR5UHy.js} +1 -1
- package/dist/dashboard/assets/dialog-BjFR5UHy.js.gz +0 -0
- package/dist/dashboard/assets/{drawer-BADqIRYP.js → drawer-HvBW0AjI.js} +1 -1
- package/dist/dashboard/assets/drawer-HvBW0AjI.js.gz +0 -0
- package/dist/dashboard/assets/entry-BSu3gFlt.js +4 -0
- package/dist/dashboard/assets/entry-BSu3gFlt.js.gz +0 -0
- package/dist/dashboard/assets/{entry-COaC-irN.js → entry-CECVELyy.js} +1 -1
- package/dist/dashboard/assets/entry-CECVELyy.js.gz +0 -0
- package/dist/dashboard/assets/entry-DYYofQ7W.js +1 -0
- package/dist/dashboard/assets/entry-DYYofQ7W.js.gz +0 -0
- package/dist/dashboard/assets/{formatters-DcHJyRiu.js → formatters-DLW4i8zK.js} +1 -1
- package/dist/dashboard/assets/formatters-DLW4i8zK.js.gz +0 -0
- package/dist/dashboard/assets/{index-CgKmFngv.js → index-1-fCqe64.js} +2 -2
- package/dist/dashboard/assets/index-1-fCqe64.js.gz +0 -0
- package/dist/dashboard/assets/{inline-B2BirKry.js → inline-DGvU2oLK.js} +1 -1
- package/dist/dashboard/assets/inline-DGvU2oLK.js.gz +0 -0
- package/dist/dashboard/assets/{input-D-qV9dKY.js → input-iNnO1X2K.js} +1 -1
- package/dist/dashboard/assets/input-iNnO1X2K.js.gz +0 -0
- package/dist/dashboard/assets/{layout-B7tVWhtV.js → layout-0q8UGypb.js} +1 -1
- package/dist/dashboard/assets/layout-0q8UGypb.js.gz +0 -0
- package/dist/dashboard/assets/{list-row-CtkGE3bF.js → list-row-C0w2bQjJ.js} +1 -1
- package/dist/dashboard/assets/list-row-C0w2bQjJ.js.gz +0 -0
- package/dist/dashboard/assets/{live-DGizF06-.js → live-M5aJ_xCa.js} +1 -1
- package/dist/dashboard/assets/live-M5aJ_xCa.js.gz +0 -0
- package/dist/dashboard/assets/{mutation-GU7XdEjz.js → mutation-BQ0ccH_A.js} +1 -1
- package/dist/dashboard/assets/mutation-BQ0ccH_A.js.gz +0 -0
- package/dist/dashboard/assets/{network-C9UE-bOr.js → network-BKeQGT3K.js} +1 -1
- package/dist/dashboard/assets/network-BKeQGT3K.js.gz +0 -0
- package/dist/dashboard/assets/{numbers-BnAd22a_.js → numbers-CivAk3da.js} +1 -1
- package/dist/dashboard/assets/numbers-CivAk3da.js.gz +0 -0
- package/dist/dashboard/assets/{pagination-BAywyMzS.js → pagination-CpzvI5ep.js} +1 -1
- package/dist/dashboard/assets/pagination-CpzvI5ep.js.gz +0 -0
- package/dist/dashboard/assets/providers/devin.svg +9 -0
- package/dist/dashboard/assets/providers/devin.svg.gz +0 -0
- package/dist/dashboard/assets/providers/windsurf.svg +10 -0
- package/dist/dashboard/assets/providers/windsurf.svg.gz +0 -0
- package/dist/dashboard/assets/providers/zro.svg +3 -0
- package/dist/dashboard/assets/providers/zro.svg.gz +0 -0
- package/dist/dashboard/assets/{query-keys-YSoQOUh6.js → query-keys-IKLh0YFd.js} +1 -1
- package/dist/dashboard/assets/query-keys-IKLh0YFd.js.gz +0 -0
- package/dist/dashboard/assets/quota-DiPD6UKH.js +1 -0
- package/dist/dashboard/assets/quota-DiPD6UKH.js.gz +0 -0
- package/dist/dashboard/assets/routing-BFQX2VBc.js +1 -0
- package/dist/dashboard/assets/routing-BFQX2VBc.js.gz +0 -0
- package/dist/dashboard/assets/{select-BCOcv8WK.js → select-CXbck0jG.js} +2 -2
- package/dist/dashboard/assets/select-CXbck0jG.js.gz +0 -0
- package/dist/dashboard/assets/settings-C_XvMHh9.js +1 -0
- package/dist/dashboard/assets/settings-C_XvMHh9.js.gz +0 -0
- package/dist/dashboard/assets/{stack-ByKt3Q1g.js → stack-DggRiCxE.js} +1 -1
- package/dist/dashboard/assets/stack-DggRiCxE.js.gz +0 -0
- package/dist/dashboard/assets/{state-DXbGTx7N.js → state-ClFzfbYp.js} +1 -1
- package/dist/dashboard/assets/state-ClFzfbYp.js.gz +0 -0
- package/dist/dashboard/assets/story/25817331.webp +0 -0
- package/dist/dashboard/assets/story/Shorekeeper.webp +0 -0
- package/dist/dashboard/assets/story/cartethyia-god.webp +0 -0
- package/dist/dashboard/assets/story/fleurdelys_plus.webp +0 -0
- package/dist/dashboard/assets/story/jinhsi-blossom.webp +0 -0
- package/dist/dashboard/assets/story/phrolova-a.webp +0 -0
- package/dist/dashboard/assets/story/requestdeniawokkjpg.webp +0 -0
- package/dist/dashboard/assets/story/wuthering-waves-hiyuki-aemeath-hiyuki-rover.webp +0 -0
- package/dist/dashboard/assets/{switch-ZeTsW623.js → switch-CTIFxKqS.js} +1 -1
- package/dist/dashboard/assets/switch-CTIFxKqS.js.gz +0 -0
- package/dist/dashboard/assets/{useMutation-CbCP4w1o.js → useMutation-BClG3yWj.js} +1 -1
- package/dist/dashboard/assets/useMutation-BClG3yWj.js.gz +0 -0
- package/dist/dashboard/console-backgrounds.webp +0 -0
- package/dist/dashboard/console-backgrounds_initial.webp +0 -0
- package/dist/dashboard/donation/qris-risun-marke.webp +0 -0
- package/dist/dashboard/index.html +3 -3
- package/dist/dashboard/index.html.gz +0 -0
- package/dist/dashboard/precompressed-assets.json +59 -56
- package/migrations/full-postgres/0044_add_models_warning_metadata.sql +10 -0
- package/migrations/full-postgres/0045_migrate_workbuddy_to_codebuddy.sql +156 -0
- package/migrations/full-postgres/0046_add_accounts_quota_plan_fetched_at.sql +7 -0
- package/migrations/lite-sqlite3/0044_add_models_warning_metadata.sql +11 -0
- package/migrations/lite-sqlite3/0045_migrate_workbuddy_to_codebuddy.sql +156 -0
- package/migrations/lite-sqlite3/0046_add_accounts_quota_plan_fetched_at.sql +4 -0
- package/package.json +1 -1
- package/src/boot/app.ts +10 -13
- package/src/boot/dependencies.ts +12 -4
- package/src/boot/flush.ts +20 -0
- package/src/boot/lifecycle.ts +7 -5
- package/src/config/cooldowns.ts +1 -1
- package/src/config/routing.ts +26 -0
- package/src/config/spec-metadata.ts +72 -0
- package/src/config/spec.ts +20 -6
- package/src/console/api-keys/contracts.ts +12 -1
- package/src/console/api-keys/routes.ts +50 -31
- package/src/console/auth/account-reset.ts +7 -9
- package/src/console/backup/contracts.ts +4 -0
- package/src/console/backup/export-endpoint.ts +7 -5
- package/src/console/cli-tools/service.ts +6 -12
- package/src/console/console-router-guards.ts +23 -16
- package/src/console/console-router.ts +7 -0
- package/src/console/dashboard-assets.ts +5 -5
- package/src/console/domain-registration.ts +27 -2
- package/src/console/inferhub/normalize.ts +24 -28
- package/src/console/inferhub/types.ts +3 -0
- package/src/console/ip-bans/routes.ts +93 -0
- package/src/console/observability/store.ts +0 -53
- package/src/console/providers/catalog/catalog-projections.ts +5 -2
- package/src/console/providers/catalog/contracts.ts +123 -0
- package/src/console/providers/catalog/discover-constants.ts +6 -0
- package/src/console/providers/catalog/model-operations.ts +122 -10
- package/src/console/providers/catalog/provider-operations.ts +116 -8
- package/src/console/providers/catalog/public-model-store.ts +0 -0
- package/src/console/providers/catalog/routes.ts +65 -4
- package/src/console/providers/catalog/store-helpers.ts +30 -1
- package/src/console/providers/catalog/store.ts +249 -4
- package/src/console/quota/account-quota-global.ts +97 -19
- package/src/console/quota/account-quota-shared.ts +49 -0
- package/src/console/quota/account-quota-tenant.ts +6 -18
- package/src/console/quota/native-identity.ts +2 -0
- package/src/console/quota/quota-view.ts +19 -3
- package/src/console/routing/pools/operations.ts +31 -46
- package/src/console/settings/contracts.ts +18 -0
- package/src/console/settings/store.ts +32 -0
- package/src/console/shared/errors.ts +33 -6
- package/src/console/system-prompt/contracts.ts +0 -1
- package/src/main.ts +3 -3
- package/src/network/pool/byte-accounting.ts +3 -2
- package/src/network/pool/selector.ts +182 -39
- package/src/network/pool-cooldown-store.ts +89 -14
- package/src/network/pool-health.ts +49 -61
- package/src/network/rate-limit-verdict.ts +1 -1
- package/src/network/ssrf.ts +6 -6
- package/src/observability/event-log.ts +7 -361
- package/src/observability/event-query.ts +18 -4
- package/src/observability/performance-metrics.ts +9 -0
- package/src/observability/runtime-metrics.ts +14 -9
- package/src/observability/telemetry-buffer.ts +15 -25
- package/src/observability/telemetry-reconciliation.ts +9 -37
- package/src/observability/telemetry-row.ts +125 -0
- package/src/persistence/db-mode.ts +4 -1
- package/src/persistence/dialect.ts +30 -0
- package/src/persistence/migrate.ts +6 -3
- package/src/persistence/schema.ts +28 -2
- package/src/persistence/ttl-cache.ts +20 -2
- package/src/protocol/codecs.ts +1 -1
- package/src/protocol/dsml.ts +35 -87
- package/src/protocol/gateway-error.ts +1 -0
- package/src/protocol/markup-stream-parser.ts +195 -0
- package/src/protocol/reasoning-text.ts +19 -0
- package/src/protocol/reasoning.ts +1 -1
- package/src/protocol/request/chat.ts +14 -14
- package/src/protocol/request/gemini.ts +8 -2
- package/src/protocol/request/messages.ts +4 -5
- package/src/protocol/response/chat.ts +12 -20
- package/src/protocol/response/gemini.ts +6 -1
- package/src/protocol/response/omp-tool-call-markup.ts +43 -86
- package/src/protocol/response/responses.ts +18 -2
- package/src/protocol/sse-decoder.ts +25 -8
- package/src/protocol/stop-reason.ts +23 -1
- package/src/protocol/stream-error-frames.ts +13 -3
- package/src/protocol/think-split.ts +112 -0
- package/src/protocol/translation/dialect/qwen.ts +26 -58
- package/src/protocol/translation/quirks.ts +1 -1
- package/src/protocol/translation/tool-repair.ts +2 -2
- package/src/protocol/upstream/send-claude-messages.ts +15 -4
- package/src/protocol/upstream-parsing.ts +1 -1
- package/src/providers/adapters/compatible-adapter.ts +78 -17
- package/src/providers/authentication/oauth-client.ts +1 -1
- package/src/providers/authentication/oauth-device-flow.ts +98 -8
- package/src/providers/authentication/oauth-refresh-service.ts +153 -59
- package/src/providers/configured-provider.ts +148 -0
- package/src/providers/default-registry.ts +117 -27
- package/src/providers/discovery/discovery-types.ts +12 -0
- package/src/providers/discovery/probe-phases.ts +74 -33
- package/src/providers/discovery/probing-service.ts +293 -165
- package/src/providers/integrations/alibabacp/alibabacp-models.ts +1 -2
- package/src/providers/integrations/{dashscope-models.ts → alibabacp/dashscope-models.ts} +2 -2
- package/src/providers/integrations/antigravity/antigravity-protocol.ts +121 -2
- package/src/providers/integrations/antigravity/antigravity.ts +13 -2
- package/src/providers/integrations/buddy/buddy-catalog-shared.ts +72 -34
- package/src/providers/integrations/buddy/buddy-chat-shared.ts +191 -35
- package/src/providers/integrations/buddy/buddy-checkin.ts +17 -39
- package/src/providers/integrations/buddy/buddy-conversation-headers.ts +2 -2
- package/src/providers/integrations/buddy/buddy-discovery-shared.ts +5 -5
- package/src/providers/integrations/buddy/buddy-identity.ts +89 -6
- package/src/providers/integrations/buddy/buddy-media.ts +4 -5
- package/src/providers/integrations/buddy/buddy-oauth-shared.ts +2 -2
- package/src/providers/integrations/buddy/buddy-quota-shared.ts +1 -1
- package/src/providers/integrations/buddy/buddy-usage-shared.ts +1 -3
- package/src/providers/integrations/buddy/capabilities.ts +6 -43
- package/src/providers/integrations/buddy/codebuddy/cn-catalog.ts +2 -1
- package/src/providers/integrations/buddy/codebuddy/cn-provider.ts +23 -1
- package/src/providers/integrations/buddy/codebuddy/provider.ts +6 -2
- package/src/providers/integrations/buddy/codebuddy/shared.ts +38 -27
- package/src/providers/integrations/claude/claude-quota.ts +14 -17
- package/src/providers/integrations/cline/cline.ts +2 -2
- package/src/providers/integrations/commandcode/quota.ts +22 -28
- package/src/providers/integrations/cursor/cursor-auth.ts +0 -8
- package/src/providers/integrations/cursor/cursor-catalog.ts +2 -0
- package/src/providers/integrations/cursor/cursor-exec.ts +745 -0
- package/src/providers/integrations/cursor/cursor-http2.ts +2 -0
- package/src/providers/integrations/cursor/cursor-request.ts +35 -20
- package/src/providers/integrations/cursor/cursor-shared.ts +26 -5
- package/src/providers/integrations/cursor/cursor.ts +139 -70
- package/src/providers/integrations/cursor/protocol/messages.ts +22 -29
- package/src/providers/integrations/cursor/protocol/protobuf-schema.ts +37 -0
- package/src/providers/integrations/cursor/protocol/tool-canonical.ts +26 -100
- package/src/providers/integrations/devin/devin-auth.ts +353 -0
- package/src/providers/integrations/devin/devin-catalog.ts +207 -0
- package/src/providers/integrations/devin/devin-http.ts +91 -0
- package/src/providers/integrations/devin/devin-quota.ts +214 -0
- package/src/providers/integrations/devin/devin-shared.ts +111 -0
- package/src/providers/integrations/devin/devin.ts +539 -0
- package/src/providers/integrations/devin/protocol/devin-proto.ts +558 -0
- package/src/providers/integrations/devin/protocol/framing.ts +124 -0
- package/src/providers/integrations/factory/factory-oauth.ts +17 -44
- package/src/providers/integrations/factory/factory.ts +2 -2
- package/src/providers/integrations/freebuff/assets/official-system-manager.txt +88 -0
- package/src/providers/integrations/freebuff/assets/official-system-worker.txt +57 -0
- package/src/providers/integrations/freebuff/assets/official-tools.json +1070 -0
- package/src/providers/integrations/freebuff/freebuff-catalog.ts +120 -0
- package/src/providers/integrations/freebuff/freebuff-constants.ts +1233 -0
- package/src/providers/integrations/freebuff/freebuff-discovery.ts +108 -0
- package/src/providers/integrations/freebuff/freebuff-oauth.ts +240 -0
- package/src/providers/integrations/freebuff/freebuff-quota.ts +260 -0
- package/src/providers/integrations/freebuff/freebuff-virtual.ts +89 -0
- package/src/providers/integrations/freebuff/freebuff.ts +682 -0
- package/src/providers/integrations/freepi/freepi-catalog.ts +60 -0
- package/src/providers/integrations/freepi/freepi-discovery.ts +82 -0
- package/src/providers/integrations/freepi/freepi-headers.ts +21 -0
- package/src/providers/integrations/freepi/freepi-oauth.ts +142 -0
- package/src/providers/integrations/freepi/freepi-protocol.ts +242 -0
- package/src/providers/integrations/freepi/freepi-quota.ts +126 -0
- package/src/providers/integrations/freepi/freepi-realm.ts +35 -0
- package/src/providers/integrations/freepi/freepi.ts +292 -0
- package/src/providers/integrations/gemini.ts +2 -2
- package/src/providers/integrations/grok/grok-oauth.ts +48 -45
- package/src/providers/integrations/grok/grok-ratelimit-store.ts +10 -17
- package/src/providers/integrations/grok/grok-turn-index.ts +11 -16
- package/src/providers/integrations/hermes/hermes-oauth.ts +94 -0
- package/src/providers/integrations/{hermes.ts → hermes/hermes.ts} +13 -21
- package/src/providers/integrations/hermes/index.ts +2 -0
- package/src/providers/integrations/kiro/kiro-catalog.ts +17 -1
- package/src/providers/integrations/kiro/kiro-discovery.ts +10 -12
- package/src/providers/integrations/kiro/kiro-quota.ts +8 -4
- package/src/providers/integrations/kiro/kiro.ts +15 -19
- package/src/providers/integrations/ollamacloud/index.ts +2 -0
- package/src/providers/integrations/{ollamacloud-models.ts → ollamacloud/models.ts} +2 -2
- package/src/providers/integrations/{ollamacloud-quota.ts → ollamacloud/quota.ts} +3 -3
- package/src/providers/integrations/opencode/fingerprint.ts +1 -1
- package/src/providers/integrations/opencode/opencode-go-quota.ts +2 -8
- package/src/providers/integrations/perch/perch-catalog.ts +105 -0
- package/src/providers/integrations/perch/perch-credential.ts +25 -0
- package/src/providers/integrations/perch/perch-oauth.ts +170 -0
- package/src/providers/integrations/perch/perch-protocol.ts +208 -0
- package/src/providers/integrations/perch/perch-quota.ts +123 -0
- package/src/providers/integrations/perch/perch-realm.ts +82 -0
- package/src/providers/integrations/perch/perch-system-prompt.ts +13 -0
- package/src/providers/integrations/perch/perch.ts +305 -0
- package/src/providers/integrations/perch/saffron-system-prompt.txt +8 -0
- package/src/providers/integrations/qoder/chat-proto.ts +328 -328
- package/src/providers/integrations/qoder/claim-qoder-credits.ts +19 -60
- package/src/providers/integrations/qoder/qoder-adapter.ts +90 -40
- package/src/providers/integrations/qoder/qoder-auth.ts +101 -29
- package/src/providers/integrations/qoder/qoder-cache.ts +32 -0
- package/src/providers/integrations/qoder/qoder-catalog.ts +26 -6
- package/src/providers/integrations/qoder/qoder-chat.ts +7 -21
- package/src/providers/integrations/qoder/qoder-checkin.ts +6 -6
- package/src/providers/integrations/qoder/qoder-grpc.ts +210 -7
- package/src/providers/integrations/qoder/qoder-ide.ts +5 -108
- package/src/providers/integrations/qoder/qoder-identity-cache.ts +184 -0
- package/src/providers/integrations/qoder/qoder-native-identity-store.ts +83 -18
- package/src/providers/integrations/qoder/qoder-realm.ts +9 -6
- package/src/providers/integrations/qoder/qoder-umid.ts +109 -342
- package/src/providers/integrations/qoder/qoder-virtual.ts +33 -1
- package/src/providers/integrations/qoder/qoder.ts +3 -7
- package/src/providers/integrations/trae/trae-catalog.ts +9 -14
- package/src/providers/integrations/trae/trae-headers.ts +36 -11
- package/src/providers/integrations/trae/trae-oauth.ts +14 -17
- package/src/providers/integrations/trae/trae-protocol.ts +12 -11
- package/src/providers/integrations/trae/trae-quota.ts +96 -36
- package/src/providers/integrations/trae/trae-realm.ts +74 -15
- package/src/providers/integrations/trae/trae.ts +99 -26
- package/src/providers/integrations/zcode-start-plan/provider.ts +226 -23
- package/src/providers/integrations/zcode-start-plan/quota.ts +19 -2
- package/src/providers/integrations/zro/zro.ts +204 -0
- package/src/providers/operations/account-error-classification.ts +235 -278
- package/src/providers/operations/account-health-service.ts +273 -26
- package/src/providers/operations/account-refresh-status.ts +269 -0
- package/src/providers/operations/account-tier.ts +66 -0
- package/src/providers/operations/client-version-resolver.ts +1 -1
- package/src/providers/operations/client-versions.ts +42 -150
- package/src/providers/operations/cooldown-rules.ts +56 -0
- package/src/providers/operations/{model-catalog-cache.ts → provider-caches.ts} +68 -16
- package/src/providers/operations/provider-catalog-seeder.ts +4 -0
- package/src/providers/operations/provider-catalog-service.ts +1 -1
- package/src/providers/operations/provider-credential-service.ts +102 -32
- package/src/providers/operations/provider-rules/github.ts +48 -0
- package/src/providers/operations/provider-rules/grok.ts +33 -0
- package/src/providers/operations/provider-rules/inception.ts +49 -0
- package/src/providers/operations/provider-rules/index.ts +32 -0
- package/src/providers/operations/provider-rules/perch.ts +37 -0
- package/src/providers/operations/provider-rules/qoder.ts +70 -0
- package/src/providers/operations/provider-rules/trae.ts +81 -0
- package/src/providers/provider-contracts.ts +33 -2
- package/src/providers/{provider-credential-resolver.ts → provider-credentials.ts} +40 -3
- package/src/providers/provider-metadata.ts +99 -14
- package/src/providers/provider-model-definition.ts +36 -0
- package/src/providers/provider-probe.ts +15 -1
- package/src/providers/provider-registry.ts +42 -33
- package/src/providers/quota/quota-limit-windows.ts +16 -5
- package/src/providers/quota/quota-support.ts +1 -1
- package/src/providers/quota/quota-window-parser.ts +90 -18
- package/src/providers/quota/refresh.ts +96 -18
- package/src/security/abuse.ts +71 -0
- package/src/security/api-key-auth-cache.ts +1 -1
- package/src/security/api-key-auth.ts +6 -2
- package/src/transport/dispatch/attempt-finalize.ts +14 -13
- package/src/transport/dispatch/attempt-loop.ts +71 -17
- package/src/transport/dispatch/generation.ts +2 -8
- package/src/transport/dispatch/native-shared.ts +25 -0
- package/src/transport/dispatch/proxy-request.ts +9 -46
- package/src/transport/dispatch/responses-compact.ts +2 -8
- package/src/transport/dispatch/streaming/finalize.ts +9 -6
- package/src/transport/dispatch/streaming/stream.ts +9 -36
- package/src/transport/dispatch/systemone.ts +2 -8
- package/src/transport/dispatch/token-count.ts +2 -6
- package/src/transport/dispatch/upstream.ts +67 -1
- package/src/transport/drain-endpoint.ts +31 -4
- package/src/transport/failure-policy.ts +129 -37
- package/src/transport/guards/body-policy.ts +7 -1
- package/src/transport/guards/error-lifecycle.ts +13 -1
- package/src/transport/guards/request-context.ts +22 -14
- package/src/transport/request/preparer.ts +81 -71
- package/src/transport/routing/bounded-lru.ts +14 -0
- package/src/transport/routing/drain-reserve.ts +129 -0
- package/src/transport/routing/plan-gate.ts +7 -1
- package/src/transport/routing/round-robin.ts +60 -0
- package/src/transport/routing/route-catalog.ts +123 -111
- package/src/transport/routing/route-model.ts +51 -9
- package/src/transport/routing/router.ts +418 -33
- package/src/transport/surface/adapters.ts +11 -2
- package/src/transport/surface/chat/adapter.ts +2 -2
- package/src/transport/surface/chat/encode.ts +47 -4
- package/src/transport/surface/chat/parse.ts +2 -12
- package/src/transport/surface/completion.ts +44 -33
- package/src/transport/surface/content-parts.ts +21 -0
- package/src/transport/surface/messages/adapter.ts +9 -2
- package/src/transport/surface/messages/encode.ts +11 -3
- package/src/transport/surface/messages/parse.ts +2 -1
- package/src/transport/surface/messages/stream.ts +33 -17
- package/src/transport/surface/responses/encode.ts +34 -6
- package/src/transport/surface/responses/parse.ts +3 -11
- package/src/workers/daily-checkin.ts +1 -1
- package/src/workers/quota-refresh-sweep.ts +1 -1
- package/src/workers/scheduler.ts +22 -4
- package/dist/dashboard/assets/BannedPage-DeIbIiBU.js +0 -1
- package/dist/dashboard/assets/BannedPage-DeIbIiBU.js.gz +0 -0
- package/dist/dashboard/assets/CliToolDetailPage-BRWKPQPf.js.gz +0 -0
- package/dist/dashboard/assets/CliToolsPage-BP-Y5iHN.js.gz +0 -0
- package/dist/dashboard/assets/CombosPage-B7JHozVa.js +0 -1
- package/dist/dashboard/assets/CombosPage-B7JHozVa.js.gz +0 -0
- package/dist/dashboard/assets/ConsoleLogPage-GX7iGGcu.js +0 -1
- package/dist/dashboard/assets/ConsoleLogPage-GX7iGGcu.js.gz +0 -0
- package/dist/dashboard/assets/CustomizationPage-HVonbGEa.js +0 -1
- package/dist/dashboard/assets/CustomizationPage-HVonbGEa.js.gz +0 -0
- package/dist/dashboard/assets/HealthEventsModal-xaut4OJ9.js +0 -1
- package/dist/dashboard/assets/HealthEventsModal-xaut4OJ9.js.gz +0 -0
- package/dist/dashboard/assets/InjectSystemPromptPanel-Cv-2Ol_K.js.gz +0 -0
- package/dist/dashboard/assets/LoginPage-bKfz_b1K.js.gz +0 -0
- package/dist/dashboard/assets/ModelPicker-B-WQxx_H.js.gz +0 -0
- package/dist/dashboard/assets/OverviewPage-Z9pJZFo8.js +0 -1
- package/dist/dashboard/assets/OverviewPage-Z9pJZFo8.js.gz +0 -0
- package/dist/dashboard/assets/ProviderDetailPage-CMeDBxR1.js +0 -7
- package/dist/dashboard/assets/ProviderDetailPage-CMeDBxR1.js.gz +0 -0
- package/dist/dashboard/assets/ProviderIcon-jjqXJDA3.js +0 -1
- package/dist/dashboard/assets/ProviderIcon-jjqXJDA3.js.gz +0 -0
- package/dist/dashboard/assets/ProvidersPage-BXPdOpG4.js +0 -1
- package/dist/dashboard/assets/ProvidersPage-BXPdOpG4.js.gz +0 -0
- package/dist/dashboard/assets/ProxyPage-emlTuxz6.js.gz +0 -0
- package/dist/dashboard/assets/QuotaPage-CMJKNYWb.js +0 -1
- package/dist/dashboard/assets/QuotaPage-CMJKNYWb.js.gz +0 -0
- package/dist/dashboard/assets/SettingsPage-BSy7EwGo.js +0 -1
- package/dist/dashboard/assets/SettingsPage-BSy7EwGo.js.gz +0 -0
- package/dist/dashboard/assets/SetupPage-CUZrKs9r.js.gz +0 -0
- package/dist/dashboard/assets/StudioPage-jWmUdDpy.js.gz +0 -0
- package/dist/dashboard/assets/UsagePage-5F9tGVGG.js +0 -56
- package/dist/dashboard/assets/UsagePage-5F9tGVGG.js.gz +0 -0
- package/dist/dashboard/assets/api-keys-KvX83mRe.js +0 -1
- package/dist/dashboard/assets/api-keys-KvX83mRe.js.gz +0 -0
- package/dist/dashboard/assets/app-BEsU8hKs.css +0 -2
- package/dist/dashboard/assets/app-BEsU8hKs.css.gz +0 -0
- package/dist/dashboard/assets/assert-CidQVoNo.js.gz +0 -0
- package/dist/dashboard/assets/badge-DyI_mJfi.js.gz +0 -0
- package/dist/dashboard/assets/banner-B-yXtCqb.js.gz +0 -0
- package/dist/dashboard/assets/brand/bansos_page.png +0 -0
- package/dist/dashboard/assets/brand/denia_bansos.jpg +0 -0
- package/dist/dashboard/assets/brand/favicon.jpg +0 -0
- package/dist/dashboard/assets/brand/login_register.jpg +0 -0
- package/dist/dashboard/assets/brand/login_register_initial.jpg +0 -0
- package/dist/dashboard/assets/brand/og_bansos.jpg +0 -0
- package/dist/dashboard/assets/brand/og_image.jpg +0 -0
- package/dist/dashboard/assets/brand/sidebar_ico.jpg +0 -0
- package/dist/dashboard/assets/card-_HwAEqFF.js.gz +0 -0
- package/dist/dashboard/assets/cli-tools-Bwv5-zGZ.js +0 -1
- package/dist/dashboard/assets/cli-tools-Bwv5-zGZ.js.gz +0 -0
- package/dist/dashboard/assets/clipboard-button-ByjCk0o9.js.gz +0 -0
- package/dist/dashboard/assets/dialog-BZhOlfz-.js.gz +0 -0
- package/dist/dashboard/assets/drawer-BADqIRYP.js.gz +0 -0
- package/dist/dashboard/assets/entry-COaC-irN.js.gz +0 -0
- package/dist/dashboard/assets/entry-Ca7LSCet.js +0 -4
- package/dist/dashboard/assets/entry-Ca7LSCet.js.gz +0 -0
- package/dist/dashboard/assets/entry-PDd27uCd.js +0 -1
- package/dist/dashboard/assets/entry-PDd27uCd.js.gz +0 -0
- package/dist/dashboard/assets/formatters-DcHJyRiu.js.gz +0 -0
- package/dist/dashboard/assets/index-CgKmFngv.js.gz +0 -0
- package/dist/dashboard/assets/inline-B2BirKry.js.gz +0 -0
- package/dist/dashboard/assets/input-D-qV9dKY.js.gz +0 -0
- package/dist/dashboard/assets/layout-B7tVWhtV.js.gz +0 -0
- package/dist/dashboard/assets/list-row-CtkGE3bF.js.gz +0 -0
- package/dist/dashboard/assets/live-DGizF06-.js.gz +0 -0
- package/dist/dashboard/assets/minimize-2-BTmMTK4o.js +0 -1
- package/dist/dashboard/assets/minimize-2-BTmMTK4o.js.gz +0 -0
- package/dist/dashboard/assets/mutation-GU7XdEjz.js.gz +0 -0
- package/dist/dashboard/assets/network-C9UE-bOr.js.gz +0 -0
- package/dist/dashboard/assets/numbers-BnAd22a_.js.gz +0 -0
- package/dist/dashboard/assets/pagination-BAywyMzS.js.gz +0 -0
- package/dist/dashboard/assets/query-keys-YSoQOUh6.js.gz +0 -0
- package/dist/dashboard/assets/quota-DJ1QlAOq.js +0 -1
- package/dist/dashboard/assets/quota-DJ1QlAOq.js.gz +0 -0
- package/dist/dashboard/assets/routing-fnCsxgNO.js +0 -1
- package/dist/dashboard/assets/routing-fnCsxgNO.js.gz +0 -0
- package/dist/dashboard/assets/select-BCOcv8WK.js.gz +0 -0
- package/dist/dashboard/assets/settings-BxslsErn.js +0 -1
- package/dist/dashboard/assets/settings-BxslsErn.js.gz +0 -0
- package/dist/dashboard/assets/stack-ByKt3Q1g.js.gz +0 -0
- package/dist/dashboard/assets/state-DXbGTx7N.js.gz +0 -0
- package/dist/dashboard/assets/switch-ZeTsW623.js.gz +0 -0
- package/dist/dashboard/assets/useMutation-CbCP4w1o.js.gz +0 -0
- package/dist/dashboard/console-backgrounds.jpg +0 -0
- package/dist/dashboard/console-backgrounds_initial.jpg +0 -0
- package/dist/dashboard/donation/qris-risun-marke.png +0 -0
- package/src/providers/bundled-discovery-providers.ts +0 -98
- package/src/providers/configured-openai-providers.ts +0 -120
- package/src/providers/integrations/buddy/turing-device-token.ts +0 -262
- package/src/providers/integrations/buddy/workbuddy/cn-oauth.ts +0 -30
- package/src/providers/integrations/buddy/workbuddy/cn-provider.ts +0 -58
- package/src/providers/integrations/buddy/workbuddy/oauth.ts +0 -31
- package/src/providers/integrations/buddy/workbuddy/provider.ts +0 -209
- package/src/providers/integrations/buddy/workbuddy/quota.ts +0 -161
- package/src/providers/integrations/buddy/workbuddy/shared.ts +0 -285
- package/src/providers/operations/model-discovery-cache.ts +0 -34
- package/src/providers/operations/probe-fetch.ts +0 -15
- package/src/providers/operations/provider-version-cache.ts +0 -30
- package/src/providers/provider-capabilities.ts +0 -33
- package/src/providers/provider-credential-envelope.ts +0 -43
- /package/dist/dashboard/assets/{app-CTxoqyYB.js → app-DIXLjojg.js} +0 -0
- /package/dist/dashboard/assets/{app-CTxoqyYB.js.gz → app-DIXLjojg.js.gz} +0 -0
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
// X-Device-Type, X-Os-Version (all encodeURIComponent'd)
|
|
9
9
|
// - User-Agent: TraeClient/TTNet
|
|
10
10
|
//
|
|
11
|
-
// The
|
|
12
|
-
//
|
|
13
|
-
//
|
|
11
|
+
// The native Agent transport also sends x-ide-token alongside Authorization.
|
|
12
|
+
// Version headers remain separate: they are not universally required by Agent
|
|
13
|
+
// and commercial requests.
|
|
14
14
|
|
|
15
15
|
import { createHash } from "node:crypto";
|
|
16
16
|
import {
|
|
@@ -32,9 +32,9 @@ export interface TraeDeviceIdentity {
|
|
|
32
32
|
* Derives the device pair the upstream client sends.
|
|
33
33
|
*
|
|
34
34
|
* Both are pure one-way derivations from the account id, so one account always
|
|
35
|
-
* presents one device and two accounts never share one —
|
|
36
|
-
*
|
|
37
|
-
*
|
|
35
|
+
* presents one device and two accounts never share one — this is the
|
|
36
|
+
* risk-control correlation surface, so a per-process random id would look like
|
|
37
|
+
* many devices behind one account and a shared id would link them.
|
|
38
38
|
*/
|
|
39
39
|
export function traeDeviceIdentity(uid: string): TraeDeviceIdentity {
|
|
40
40
|
const seed = String(uid ?? "").trim() || "anonymous";
|
|
@@ -52,9 +52,9 @@ export function traeDeviceIdentity(uid: string): TraeDeviceIdentity {
|
|
|
52
52
|
/**
|
|
53
53
|
* OS string reported as `X-Os-Version`.
|
|
54
54
|
*
|
|
55
|
-
*
|
|
56
|
-
* Windows build
|
|
57
|
-
*
|
|
55
|
+
* Upstream reads this from the host registry, which would leak the operator's
|
|
56
|
+
* real Windows build. This gateway is not the operator's desktop, so a fixed
|
|
57
|
+
* value of the same shape is both more private and more stable.
|
|
58
58
|
*/
|
|
59
59
|
export const TRAE_OS_VERSION = "Windows 11 Pro";
|
|
60
60
|
|
|
@@ -70,6 +70,13 @@ export interface TraeHeaderInput {
|
|
|
70
70
|
readonly uid: string;
|
|
71
71
|
/** Version code sent as `x-ide-version-code`. */
|
|
72
72
|
readonly versionCode?: string;
|
|
73
|
+
/** Client semver (e.g. `3.6.13`), sent as `X-App-Version`/`x-ide-version`. */
|
|
74
|
+
readonly appVersion?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Traffic class, sent as `request-traffic-type`. Defaults to `chat`;
|
|
77
|
+
* the agent surface overrides to `agent`.
|
|
78
|
+
*/
|
|
79
|
+
readonly trafficType?: string;
|
|
73
80
|
/** True for the streaming chat call, which overrides `Accept`. */
|
|
74
81
|
readonly stream?: boolean;
|
|
75
82
|
/** Extra/replacement headers, applied case-insensitively. */
|
|
@@ -79,7 +86,15 @@ export interface TraeHeaderInput {
|
|
|
79
86
|
/**
|
|
80
87
|
* Builds the header set for one Trae request.
|
|
81
88
|
*
|
|
82
|
-
* `null` in `extra` deletes the header
|
|
89
|
+
* `null` in `extra` deletes the header.
|
|
90
|
+
*
|
|
91
|
+
* Deliberately does NOT send:
|
|
92
|
+
* - `x-ide-token` — the canonical client (Trae 1.107.1 bundle, commit
|
|
93
|
+
* `b6786417`) does not send it on the chat/agent data plane; it is an
|
|
94
|
+
* OAuth/business-host header only. Sending it changed nothing for auth but
|
|
95
|
+
* diverges from the reference wire.
|
|
96
|
+
* - `store-country-code` — not sent on the data plane either. The pay/quota
|
|
97
|
+
* collector adds it explicitly where the commercial surface requires it.
|
|
83
98
|
*/
|
|
84
99
|
export function buildTraeHeaders(input: TraeHeaderInput): Record<string, string> {
|
|
85
100
|
const config = TRAE_REALMS[input.realm];
|
|
@@ -88,7 +103,6 @@ export function buildTraeHeaders(input: TraeHeaderInput): Record<string, string>
|
|
|
88
103
|
"X-App-Id": TRAE_APP_ID,
|
|
89
104
|
"x-plugin-channel": TRAE_PLUGIN_CHANNEL,
|
|
90
105
|
"x-ide-version-code": input.versionCode ?? config.versionCode,
|
|
91
|
-
"x-ide-token": input.token,
|
|
92
106
|
Authorization: `Cloud-IDE-JWT ${input.token}`,
|
|
93
107
|
"Content-Type": "application/json",
|
|
94
108
|
Accept: "application/json",
|
|
@@ -99,6 +113,17 @@ export function buildTraeHeaders(input: TraeHeaderInput): Record<string, string>
|
|
|
99
113
|
"X-Device-Brand": encodeURIComponent(TRAE_DEVICE_BRAND),
|
|
100
114
|
"X-Device-Type": encodeURIComponent("windows"),
|
|
101
115
|
"X-Os-Version": encodeURIComponent(TRAE_OS_VERSION),
|
|
116
|
+
// Semver + traffic-class headers the 3.6.13 harness sends; verified live
|
|
117
|
+
// (2026-11-06) that they are accepted and change nothing (A/B sweep
|
|
118
|
+
// identical). Only sent when the caller supplies a version.
|
|
119
|
+
...(input.appVersion === undefined
|
|
120
|
+
? {}
|
|
121
|
+
: {
|
|
122
|
+
"X-App-Version": input.appVersion,
|
|
123
|
+
"X-App-Version-Code": input.appVersion,
|
|
124
|
+
"x-ide-version": input.appVersion,
|
|
125
|
+
}),
|
|
126
|
+
"request-traffic-type": input.trafficType ?? "chat",
|
|
102
127
|
};
|
|
103
128
|
|
|
104
129
|
if (input.stream === true) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Trae credential login and refresh.
|
|
2
2
|
//
|
|
3
|
-
// Trae has a real browser authorization flow, just not a device-code one:
|
|
4
|
-
//
|
|
3
|
+
// Trae has a real browser authorization flow, just not a device-code one: an
|
|
4
|
+
// earlier probe of the device-authorization surface answered `unsupported`,
|
|
5
5
|
// which is what led to the earlier claim that Trae had no OAuth login at all.
|
|
6
6
|
// The browser path is `GetLoginGuidance` (discovers the login host) → the
|
|
7
7
|
// operator signs in at `/authorization` → the callback carries a refresh token
|
|
@@ -18,9 +18,6 @@
|
|
|
18
18
|
// NEW refresh token and invalidates the one sent. A refresh that persisted only
|
|
19
19
|
// the access token would leave the account holding a dead refresh token and
|
|
20
20
|
// unrecoverable on its next expiry.
|
|
21
|
-
//
|
|
22
|
-
// Sourced from the donor hub `Public/trae2api-hub` (`_refresh_account_request`
|
|
23
|
-
// in `trae_client.py`).
|
|
24
21
|
|
|
25
22
|
import { randomUUID } from "node:crypto";
|
|
26
23
|
import { firstNonEmptyString as firstString } from "../../../shared/coerce";
|
|
@@ -50,10 +47,9 @@ const TRAE_OAUTH_USER_AGENT = "Trae/1.0.0 antigravity-cockpit-tools";
|
|
|
50
47
|
/**
|
|
51
48
|
* Plugin version the desktop client reports.
|
|
52
49
|
*
|
|
53
|
-
* Observed in a real authorize URL as `2.3.93439`. The
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* is used here.
|
|
50
|
+
* Observed in a real authorize URL as `2.3.93439`. The web build reports
|
|
51
|
+
* `local`; the login page accepts it, but the value is part of the fingerprint
|
|
52
|
+
* upstream correlates, so the desktop shape is used here.
|
|
57
53
|
*/
|
|
58
54
|
const TRAE_PLUGIN_VERSION = "2.3.93439";
|
|
59
55
|
|
|
@@ -61,9 +57,9 @@ const TRAE_PLUGIN_VERSION = "2.3.93439";
|
|
|
61
57
|
* Device context for the login.
|
|
62
58
|
*
|
|
63
59
|
* Derived with the same function the data plane uses, so one account presents
|
|
64
|
-
* one device across login and requests. A per-process random pair
|
|
65
|
-
*
|
|
66
|
-
*
|
|
60
|
+
* one device across login and requests. A per-process random pair would make
|
|
61
|
+
* every gateway restart look like a brand new device to the risk-control
|
|
62
|
+
* surface that correlates them.
|
|
67
63
|
*
|
|
68
64
|
* The seed is the login trace id because no account identity exists yet: the
|
|
69
65
|
* authorize step is what produces the account.
|
|
@@ -102,10 +98,11 @@ interface TraeExchangeResponse extends TraeExchangeResult {
|
|
|
102
98
|
|
|
103
99
|
export class TraeOAuthClient extends OAuthClient {
|
|
104
100
|
/**
|
|
105
|
-
* Trae has no device-code flow —
|
|
106
|
-
* `unsupported` for it — but it does have a browser
|
|
107
|
-
* `GetLoginGuidance` discovers the login host, the
|
|
108
|
-
* and the callback carries a refresh token that
|
|
101
|
+
* Trae has no device-code flow — an earlier probe of the device-authorization
|
|
102
|
+
* surface answered `unsupported` for it — but it does have a browser
|
|
103
|
+
* authorization flow: `GetLoginGuidance` discovers the login host, the
|
|
104
|
+
* operator signs in there, and the callback carries a refresh token that
|
|
105
|
+
* `ExchangeToken` redeems.
|
|
109
106
|
*
|
|
110
107
|
* Declaring only the browser half is what keeps the console from offering a
|
|
111
108
|
* device login that cannot work.
|
|
@@ -691,7 +688,7 @@ interface TraeCallbackPayload {
|
|
|
691
688
|
* Upstream has two shapes and the page picks by how the login started:
|
|
692
689
|
*
|
|
693
690
|
* - `?isRedirect=true&refreshToken=…&refreshExpireAt=…` — the refresh-token
|
|
694
|
-
* flow
|
|
691
|
+
* flow.
|
|
695
692
|
* - `?isRedirect=true&scope=trae&authCodeInfo={"AuthCode":…}&host=…` — the PKCE
|
|
696
693
|
* flow, which is what the live page actually produces here. The code inside
|
|
697
694
|
* `authCodeInfo` is what `public/oauth/ExchangeToken` redeems against the
|
|
@@ -8,9 +8,6 @@
|
|
|
8
8
|
// 2. Message `content` must be an array of parts. A plain string is refused
|
|
9
9
|
// (400/4001), so every message is normalized to parts even when there is
|
|
10
10
|
// only text.
|
|
11
|
-
//
|
|
12
|
-
// Sourced from the donor hub `Public/trae2api-hub` (`build_chat_body` and
|
|
13
|
-
// `iter_events` in `trae_client.py`).
|
|
14
11
|
|
|
15
12
|
import type { CanonicalRequest, ContentPart } from "../../../protocol/canonical-model";
|
|
16
13
|
import { resolveWireMaxTokens } from "../../../protocol/translation/quirks";
|
|
@@ -79,9 +76,9 @@ export interface TraeToolCall {
|
|
|
79
76
|
/**
|
|
80
77
|
* Generation fields upstream accepts.
|
|
81
78
|
*
|
|
82
|
-
* Undeclared fields are deliberately omitted:
|
|
83
|
-
*
|
|
84
|
-
*
|
|
79
|
+
* Undeclared fields are deliberately omitted: sending anything outside this
|
|
80
|
+
* set risks a 4001, so `provider_options` is never spread into the body
|
|
81
|
+
* wholesale.
|
|
85
82
|
*/
|
|
86
83
|
const PASSTHROUGH_OPTIONS = ["temperature", "top_p", "max_tokens", "stop"] as const;
|
|
87
84
|
|
|
@@ -190,7 +187,7 @@ export function buildTraeChatBody(
|
|
|
190
187
|
}
|
|
191
188
|
const parts: TraeContentPart[] = [];
|
|
192
189
|
const toolCalls: TraeToolCall[] = [];
|
|
193
|
-
|
|
190
|
+
const toolResults: Array<{ callId: string; text: string }> = [];
|
|
194
191
|
for (const part of message.content) {
|
|
195
192
|
if (part.kind === "toolCall") {
|
|
196
193
|
toolCalls.push({
|
|
@@ -201,7 +198,7 @@ export function buildTraeChatBody(
|
|
|
201
198
|
continue;
|
|
202
199
|
}
|
|
203
200
|
if (part.kind === "toolResult") {
|
|
204
|
-
|
|
201
|
+
toolResults.push({ callId: part.call_id, text: toolResultText(part.content) });
|
|
205
202
|
continue;
|
|
206
203
|
}
|
|
207
204
|
const mapped = toTraePart(part);
|
|
@@ -210,15 +207,19 @@ export function buildTraeChatBody(
|
|
|
210
207
|
|
|
211
208
|
// A tool answer becomes its own `tool` turn, which is the only shape
|
|
212
209
|
// upstream accepts for it — leaving it inside the assistant turn is
|
|
213
|
-
// rejected as a broken tool sequence.
|
|
214
|
-
|
|
210
|
+
// rejected as a broken tool sequence. One turn per result: a message
|
|
211
|
+
// whose content carries multiple `toolResult` parts (parallel tool calls)
|
|
212
|
+
// must emit one `tool` turn per call id, or upstream rejects the missing
|
|
213
|
+
// ones with `tool call failed: … No tool output found for function call
|
|
214
|
+
// <id>`.
|
|
215
|
+
for (const toolResult of toolResults) {
|
|
215
216
|
messages.push({
|
|
216
217
|
role: "tool",
|
|
217
218
|
content: [{ type: "text", text: toolResult.text }],
|
|
218
219
|
tool_call_id: toolResult.callId,
|
|
219
220
|
});
|
|
220
|
-
continue;
|
|
221
221
|
}
|
|
222
|
+
if (toolResults.length > 0) continue;
|
|
222
223
|
// Empty turns are skipped: upstream rejects them, and emitting
|
|
223
224
|
// `content: ""` turns leaves a ghost turn in the conversation.
|
|
224
225
|
if (parts.length === 0 && toolCalls.length === 0) continue;
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
// - `ide_user_ent_usage` on the **pay** host is the entitlement: which package
|
|
10
10
|
// the account holds and when it lapses.
|
|
11
11
|
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
12
|
+
// Both are read and either may fail without the other: entitlement is a *pay*
|
|
13
|
+
// host, which is the first thing a region-blocked or unpaid account loses.
|
|
14
|
+
// Letting a dead pay host fail the whole read would report "no quota" for an
|
|
15
|
+
// account whose session meter is perfectly readable — and "no quota" is what
|
|
16
|
+
// the router parks on.
|
|
17
17
|
//
|
|
18
18
|
// Headers come from `buildTraeHeaders` rather than being rebuilt here: the
|
|
19
19
|
// device fingerprint is derived from the uid, and an account that reports one
|
|
@@ -39,14 +39,15 @@ import { buildTraeHeaders } from "./trae-headers";
|
|
|
39
39
|
import { log } from "../../../observability/logger";
|
|
40
40
|
import {
|
|
41
41
|
TRAE_ENT_USAGE_PATH,
|
|
42
|
-
|
|
43
|
-
TRAE_REALMS,
|
|
42
|
+
TRAE_ENT_USAGE_PATH_V2,
|
|
44
43
|
TRAE_SESSION_USAGE_PATH,
|
|
44
|
+
traeCoreForAccount,
|
|
45
|
+
traePayHostForAccount,
|
|
45
46
|
type TraeRealm,
|
|
46
47
|
} from "./trae-realm";
|
|
47
48
|
|
|
48
49
|
/**
|
|
49
|
-
* The buckets `remain_usage` carries, in the order
|
|
50
|
+
* The buckets `remain_usage` carries, in the order they are read.
|
|
50
51
|
*
|
|
51
52
|
* `advanced_model` and `premium_model_*` are request counts; `dollar_basic` and
|
|
52
53
|
* `dollar_bonus` are spend balances. They are separate budgets and must never
|
|
@@ -210,30 +211,96 @@ function parseSessionUsage(payload: unknown): {
|
|
|
210
211
|
return { windows, plan };
|
|
211
212
|
}
|
|
212
213
|
|
|
213
|
-
/**
|
|
214
|
+
/**
|
|
215
|
+
* The entitlement payload, from the pay host.
|
|
216
|
+
*
|
|
217
|
+
* Shape verified live (2026-11-06, intl Free plan):
|
|
218
|
+
*
|
|
219
|
+
* {
|
|
220
|
+
* "billing_version": 3,
|
|
221
|
+
* "is_dollar_usage_billing": true,
|
|
222
|
+
* "user_entitlement_pack_list": [{
|
|
223
|
+
* "display_desc": "Free plan",
|
|
224
|
+
* "entitlement_base_info": {
|
|
225
|
+
* "end_time": 1796083199,
|
|
226
|
+
* "quota": { "advanced_model_request_limit": 1000, ... }
|
|
227
|
+
* },
|
|
228
|
+
* "quota": { "advanced_model_request_limit": 1000, ... },
|
|
229
|
+
* "usage": { "basic_usage_amount": 0, ... },
|
|
230
|
+
* "status": 1,
|
|
231
|
+
* "expire_time": 0
|
|
232
|
+
* }]
|
|
233
|
+
* }
|
|
234
|
+
*
|
|
235
|
+
* The v2 surface (CN realm) instead carries a `usage_summary` block:
|
|
236
|
+
*
|
|
237
|
+
* { "total_amount": 900, "consumed_amount": 0.39, ... }
|
|
238
|
+
*
|
|
239
|
+
* Limits live in `entitlement_base_info.quota` (or the sibling `quota`)
|
|
240
|
+
* as `<bucket>_limit` fields. There is no consumed/remaining count in the
|
|
241
|
+
* v1 shape — `used` stays null, and the window reports just the cap.
|
|
242
|
+
*/
|
|
214
243
|
function parseEntitlement(payload: unknown): {
|
|
215
244
|
readonly windows: readonly ProviderQuotaWindow[];
|
|
216
245
|
readonly plan: string | null;
|
|
217
246
|
} {
|
|
218
247
|
const root = record(payload) ?? {};
|
|
219
248
|
const data = record(root["data"]) ?? root;
|
|
220
|
-
const
|
|
221
|
-
? data["
|
|
222
|
-
: Array.isArray(data["
|
|
223
|
-
? data["
|
|
249
|
+
const packs = Array.isArray(data["user_entitlement_pack_list"])
|
|
250
|
+
? data["user_entitlement_pack_list"]
|
|
251
|
+
: Array.isArray(data["entitlement_list"])
|
|
252
|
+
? data["entitlement_list"]
|
|
224
253
|
: [];
|
|
225
254
|
const windows: ProviderQuotaWindow[] = [];
|
|
226
255
|
let plan: string | null = null;
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
256
|
+
|
|
257
|
+
// The pack's `quota` block names its fields `<bucket>_limit` — with the
|
|
258
|
+
// word `request` inside for the model buckets (`advanced_model_request_limit`),
|
|
259
|
+
// and `usage_limit` for the dollar buckets (`basic_usage_limit`). Mapping
|
|
260
|
+
// them explicitly beats string-concatenating the bucket id.
|
|
261
|
+
const LIMIT_FIELDS: Readonly<Record<string, string>> = {
|
|
262
|
+
advanced_model: "advanced_model_request_limit",
|
|
263
|
+
premium_model_fast_request: "premium_model_fast_request_limit",
|
|
264
|
+
premium_model_slow_request: "premium_model_slow_request_limit",
|
|
265
|
+
dollar_basic: "basic_usage_limit",
|
|
266
|
+
dollar_bonus: "bonus_usage_limit",
|
|
267
|
+
};
|
|
268
|
+
const LABELS = new Map<string, string>([...REQUEST_BUCKETS, ...DOLLAR_BUCKETS]);
|
|
269
|
+
|
|
270
|
+
for (const entry of packs) {
|
|
271
|
+
const pack = record(entry);
|
|
272
|
+
if (!pack) continue;
|
|
273
|
+
const base = record(pack["entitlement_base_info"]) ?? {};
|
|
274
|
+
const quota = record(base["quota"]) ?? record(pack["quota"]) ?? {};
|
|
275
|
+
const name = text(pack["display_desc"]) ?? text(pack["name"]) ?? text(pack["title"]);
|
|
231
276
|
if (!plan && name) plan = name;
|
|
232
|
-
const
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
277
|
+
const resetsAt = isoDate(
|
|
278
|
+
number(base["end_time"]) ?? number(pack["end_time"]) ?? number(pack["expire_time"]),
|
|
279
|
+
);
|
|
280
|
+
|
|
281
|
+
// v2 surface (CN realm): the summary carries the total and consumed
|
|
282
|
+
// amounts; use it as a single window when present.
|
|
283
|
+
const summary = record(record(data["usage_summary"]) ?? record(pack["usage_summary"]));
|
|
284
|
+
if (summary) {
|
|
285
|
+
const window = bucketWindow(
|
|
286
|
+
name ?? "Plan",
|
|
287
|
+
number(summary["consumed_amount"]),
|
|
288
|
+
number(summary["total_amount"]),
|
|
289
|
+
resetsAt,
|
|
290
|
+
);
|
|
291
|
+
if (window) windows.push(window);
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// v1 surface: `<bucket>_limit` fields, no consumption count — the cap
|
|
296
|
+
// is all this shape can report.
|
|
297
|
+
for (const [key, limitField] of Object.entries(LIMIT_FIELDS)) {
|
|
298
|
+
const limit = number(quota[limitField]);
|
|
299
|
+
if (limit === null) continue;
|
|
300
|
+
const label = LABELS.get(key) ?? key;
|
|
301
|
+
const window = percentWindow(`trae:${key}`, label, null, resetsAt, null, limit, "independent");
|
|
302
|
+
if (window) windows.push(window);
|
|
303
|
+
}
|
|
237
304
|
}
|
|
238
305
|
return { windows, plan };
|
|
239
306
|
}
|
|
@@ -258,16 +325,6 @@ function logTraeQuotaMiss(errors: readonly string[]): void {
|
|
|
258
325
|
* whose pay host is unreachable still has a readable meter, and reporting
|
|
259
326
|
* "no quota" for it would park an account that can still serve.
|
|
260
327
|
*/
|
|
261
|
-
/**
|
|
262
|
-
* The core host for this account.
|
|
263
|
-
*
|
|
264
|
-
* A provisioned region overrides the realm default: an `sg` account sent to the
|
|
265
|
-
* US core is answered 401 code 1001, which looks exactly like a dead token.
|
|
266
|
-
*/
|
|
267
|
-
function coreHost(region: string, config: (typeof TRAE_REALMS)[TraeRealm]): string {
|
|
268
|
-
return (region !== "" ? TRAE_REGION_CORE_HOSTS[region] : undefined) ?? config.core;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
328
|
export async function fetchTraeQuota(
|
|
272
329
|
credential: string,
|
|
273
330
|
fetcher: FetchLike,
|
|
@@ -333,13 +390,13 @@ export async function fetchTraeQuota(
|
|
|
333
390
|
* realm is tried: one of them accepts, and that is the answer.
|
|
334
391
|
*/
|
|
335
392
|
const tryRealms = async (
|
|
336
|
-
path: (
|
|
393
|
+
path: (realm: TraeRealm) => string,
|
|
337
394
|
surface: string,
|
|
338
395
|
parse: (payload: unknown) => { readonly windows: readonly ProviderQuotaWindow[]; readonly plan: string | null },
|
|
339
396
|
): Promise<{ readonly windows: readonly ProviderQuotaWindow[]; readonly plan: string | null } | null> => {
|
|
340
397
|
for (const candidate of realm === "cn" ? (["cn", "intl"] as const) : (["intl", "cn"] as const)) {
|
|
341
398
|
try {
|
|
342
|
-
const payload = await call(candidate, path(
|
|
399
|
+
const payload = await call(candidate, path(candidate), surface);
|
|
343
400
|
return parse(payload);
|
|
344
401
|
} catch (error) {
|
|
345
402
|
errors.push(`${candidate} ${surface}: ${cleanError(error)}`);
|
|
@@ -348,8 +405,11 @@ export async function fetchTraeQuota(
|
|
|
348
405
|
return null;
|
|
349
406
|
};
|
|
350
407
|
|
|
351
|
-
const session = await tryRealms((
|
|
352
|
-
|
|
408
|
+
const session = await tryRealms((r) => traeCoreForAccount(r, region) + TRAE_SESSION_USAGE_PATH, "session usage", parseSessionUsage);
|
|
409
|
+
// The entitlement path differs by realm: the CN realm answers v2 (v1 lacks
|
|
410
|
+
// `usage_summary` there), the intl realm answers v1 (v2 is a 404).
|
|
411
|
+
const entPath = realm === "cn" ? TRAE_ENT_USAGE_PATH_V2 : TRAE_ENT_USAGE_PATH;
|
|
412
|
+
const entitlement = await tryRealms((r) => traePayHostForAccount(r, region) + entPath, "entitlement", parseEntitlement);
|
|
353
413
|
|
|
354
414
|
const windows = [...(session?.windows ?? []), ...(entitlement?.windows ?? [])];
|
|
355
415
|
if (!session && !entitlement) {
|
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// `
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
// a CN account to `*.traeapi.us` and get it refused.
|
|
1
|
+
// Regions are per-realm constants: `trae` (global / intl) and `traecn`
|
|
2
|
+
// (China) share the wire protocol — an `x-ide-token` credential, a
|
|
3
|
+
// `model_name` body, an SSE stream — but nothing else about the address:
|
|
4
|
+
// different core host, different account/oauth host, different UA, a
|
|
5
|
+
// *different authorization scheme*, and a different model roster. Treating
|
|
6
|
+
// them as one provider with a region flag is what would send a CN account to
|
|
7
|
+
// `*.traeapi.us` and get it refused.
|
|
9
8
|
//
|
|
10
9
|
// Everything per-realm lives here so the adapter, the auth builder, and the
|
|
11
10
|
// discovery fetcher cannot drift apart on host, UA, or version code.
|
|
12
|
-
//
|
|
13
|
-
// Sourced from the donor hub `Public/trae2api-hub` (`REALMS` in
|
|
14
|
-
// `trae_client.py`, `TRAEREALMS`-shaped config in `trae_accounts.py`).
|
|
15
11
|
|
|
16
12
|
/** One Trae deployment. */
|
|
17
13
|
export type TraeRealm = "intl" | "cn";
|
|
18
14
|
|
|
15
|
+
/** Provider ids served by the Trae integration (intl + CN). */
|
|
16
|
+
export const TRAE_PROVIDER_IDS: ReadonlySet<string> = new Set(["trae", "traecn"]);
|
|
17
|
+
|
|
19
18
|
/** Per-realm upstream addresses, client identity, and auth scheme. */
|
|
20
19
|
export interface TraeRealmConfig {
|
|
21
20
|
/** Data-plane host: chat + model list (`/api/ide/v1/*`). */
|
|
@@ -43,7 +42,7 @@ export interface TraeRealmConfig {
|
|
|
43
42
|
/**
|
|
44
43
|
* Chat path, identical across realms.
|
|
45
44
|
*
|
|
46
|
-
* The list endpoint takes a body (`{"type":"chat"}`);
|
|
45
|
+
* The list endpoint takes a body (`{"type":"chat"}`); upstream posts it, so
|
|
47
46
|
* this is not a bare GET.
|
|
48
47
|
*/
|
|
49
48
|
export const TRAE_CHAT_PATH = "/api/ide/v1/llm_raw_chat";
|
|
@@ -101,8 +100,8 @@ export const TRAE_AUTHORIZATION_PATH = "/authorization";
|
|
|
101
100
|
* `/`, a trailing slash — is answered with "Login Failed" before the operator
|
|
102
101
|
* gets to sign in, so the gateway's own `/callback` default cannot be used.
|
|
103
102
|
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
103
|
+
* This gateway serves this on its own configured port and only the path is
|
|
104
|
+
* fixed.
|
|
106
105
|
*/
|
|
107
106
|
export const TRAE_CALLBACK_PATH = "/authorize";
|
|
108
107
|
|
|
@@ -123,6 +122,14 @@ export const TRAE_LOGIN_GUIDANCE_URLS: readonly string[] = [
|
|
|
123
122
|
/** Usage / entitlement paths, relative to the realm's `pay` host. */
|
|
124
123
|
export const TRAE_SESSION_USAGE_PATH = "/api/v1/commercial/get_session_usage";
|
|
125
124
|
export const TRAE_ENT_USAGE_PATH = "/trae/api/v1/pay/ide_user_ent_usage";
|
|
125
|
+
/**
|
|
126
|
+
* The v2 entitlement path, used by the CN realm.
|
|
127
|
+
*
|
|
128
|
+
* Verified live (2026-11-06): the CN realm answers v2 — v1 lacks the
|
|
129
|
+
* `usage_summary` block there — while the intl realm answers v1 (v2 is a
|
|
130
|
+
* 404 on the intl pay host).
|
|
131
|
+
*/
|
|
132
|
+
export const TRAE_ENT_USAGE_PATH_V2 = "/trae/api/v2/pay/ide_user_ent_usage";
|
|
126
133
|
|
|
127
134
|
/**
|
|
128
135
|
* Realm → deployment.
|
|
@@ -169,7 +176,10 @@ export const TRAE_REALMS: Readonly<Record<TraeRealm, TraeRealmConfig>> = {
|
|
|
169
176
|
coreFallbacks: ["https://core-normal.traeapi.us", "https://core-normal.trae.ai"],
|
|
170
177
|
account: "https://grow-normal.trae.ai",
|
|
171
178
|
accountFallbacks: ["https://grow-normal.traeapi.us"],
|
|
172
|
-
|
|
179
|
+
// SG default, like the core: the pay surface is region-correlated too, and
|
|
180
|
+
// the SG host answers an sg-provisioned (or region-unrecorded intl) account
|
|
181
|
+
// that the US host refuses with 401 code 1001 (verified live 2026-11-06).
|
|
182
|
+
pay: "https://grow-normal.trae.ai",
|
|
173
183
|
ug: "https://grow-normal.traeapi.us",
|
|
174
184
|
userAgent: "Trae/3.6.2",
|
|
175
185
|
versionCode: "20260212",
|
|
@@ -196,6 +206,20 @@ export const TRAE_REGION_CORE_HOSTS: Readonly<Record<string, string>> = {
|
|
|
196
206
|
us: "https://core-normal.traeapi.us",
|
|
197
207
|
};
|
|
198
208
|
|
|
209
|
+
/**
|
|
210
|
+
* Pay host per account region, when the login reported one.
|
|
211
|
+
*
|
|
212
|
+
* Verified live (2026-11-06): an `sg` account's token is refused by the US
|
|
213
|
+
* pay host with `401 code 1001` ("we are not able to authenticate you"), and
|
|
214
|
+
* accepted by the SG pay host. Same region-routing rule as the core host —
|
|
215
|
+
* the pay surface correlates the credential against its region, so a
|
|
216
|
+
* provisioned region must pick its own pay host too.
|
|
217
|
+
*/
|
|
218
|
+
export const TRAE_REGION_PAY_HOSTS: Readonly<Record<string, string>> = {
|
|
219
|
+
sg: "https://grow-normal.trae.ai",
|
|
220
|
+
us: "https://grow-normal.traeapi.us",
|
|
221
|
+
};
|
|
222
|
+
|
|
199
223
|
/** The app id is constant across realms. */
|
|
200
224
|
export const TRAE_APP_ID = "6eefa01c-1036-4c7e-9ca5-d891f63bfcd8";
|
|
201
225
|
|
|
@@ -224,3 +248,38 @@ export function traeAccountCandidates(realm: TraeRealm): readonly string[] {
|
|
|
224
248
|
const config = TRAE_REALMS[realm];
|
|
225
249
|
return [config.account, ...config.accountFallbacks];
|
|
226
250
|
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* The core host for this account.
|
|
254
|
+
*
|
|
255
|
+
* A provisioned region overrides the realm default: an `sg` account sent to the
|
|
256
|
+
* US core is answered 401 code 1001 (which looks exactly like a dead token), so
|
|
257
|
+
* the region lookup must win when it is known. Falling back to the realm keeps
|
|
258
|
+
* older accounts (stored before the region was captured) working exactly as
|
|
259
|
+
* before.
|
|
260
|
+
*/
|
|
261
|
+
export function traeCoreForAccount(
|
|
262
|
+
realm: TraeRealm,
|
|
263
|
+
region: string,
|
|
264
|
+
): string {
|
|
265
|
+
const regional = TRAE_REGION_CORE_HOSTS[region];
|
|
266
|
+
if (regional !== undefined) return regional;
|
|
267
|
+
return traeCoreCandidates(realm)[0] ?? "";
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* The pay host for this account.
|
|
272
|
+
*
|
|
273
|
+
* The pay surface correlates the credential against its region, too: an `sg`
|
|
274
|
+
* account sent to the US pay host is answered 401 code 1001, while the SG pay
|
|
275
|
+
* host accepts the same token (verified live 2026-11-06). Falls back to the
|
|
276
|
+
* realm default host when no region is provisioned.
|
|
277
|
+
*/
|
|
278
|
+
export function traePayHostForAccount(
|
|
279
|
+
realm: TraeRealm,
|
|
280
|
+
region: string,
|
|
281
|
+
): string {
|
|
282
|
+
const regional = TRAE_REGION_PAY_HOSTS[region];
|
|
283
|
+
if (regional !== undefined) return regional;
|
|
284
|
+
return TRAE_REALMS[realm].pay;
|
|
285
|
+
}
|