cartethyia 2.7.0 → 2.7.1
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 +107 -106
- package/README.md +25 -2
- package/dist/dashboard/assets/{BannedPage-P76QLGJA.js → BannedPage-D-J75hBM.js} +1 -1
- package/dist/dashboard/assets/BannedPage-D-J75hBM.js.gz +0 -0
- package/dist/dashboard/assets/{CliToolDetailPage-DdBggJS9.js → CliToolDetailPage-CVe6RaBH.js} +1 -1
- package/dist/dashboard/assets/CliToolDetailPage-CVe6RaBH.js.gz +0 -0
- package/dist/dashboard/assets/{CliToolsPage-aN1iXhhP.js → CliToolsPage-Dd8ZSamp.js} +1 -1
- package/dist/dashboard/assets/CliToolsPage-Dd8ZSamp.js.gz +0 -0
- package/dist/dashboard/assets/{CombosPage-DE-F1nxZ.js → CombosPage-QoJ6foxo.js} +1 -1
- package/dist/dashboard/assets/CombosPage-QoJ6foxo.js.gz +0 -0
- package/dist/dashboard/assets/ConsoleLogPage-DpNRay4C.js +1 -0
- package/dist/dashboard/assets/ConsoleLogPage-DpNRay4C.js.gz +0 -0
- package/dist/dashboard/assets/{CustomizationPage-3CUxMy2X.js → CustomizationPage-CKUFTcW4.js} +1 -1
- package/dist/dashboard/assets/CustomizationPage-CKUFTcW4.js.gz +0 -0
- package/dist/dashboard/assets/HealthEventsModal-CzSLiDzr.js +1 -0
- package/dist/dashboard/assets/HealthEventsModal-CzSLiDzr.js.gz +0 -0
- package/dist/dashboard/assets/LoginPage-DubdQcvX.js +1 -0
- package/dist/dashboard/assets/LoginPage-DubdQcvX.js.gz +0 -0
- package/dist/dashboard/assets/{ModelPicker-DKVslqG3.js → ModelPicker-BH8Tehdi.js} +1 -1
- package/dist/dashboard/assets/ModelPicker-BH8Tehdi.js.gz +0 -0
- package/dist/dashboard/assets/OverviewPage-DuWzAQFL.js +1 -0
- package/dist/dashboard/assets/OverviewPage-DuWzAQFL.js.gz +0 -0
- package/dist/dashboard/assets/ProviderDetailPage-BKEKe2Fm.js +4 -0
- package/dist/dashboard/assets/ProviderDetailPage-BKEKe2Fm.js.gz +0 -0
- package/dist/dashboard/assets/ProviderIcon-FB6yS4v1.js +1 -0
- package/dist/dashboard/assets/ProviderIcon-FB6yS4v1.js.gz +0 -0
- package/dist/dashboard/assets/ProvidersPage-Bwotu8UJ.js +1 -0
- package/dist/dashboard/assets/ProvidersPage-Bwotu8UJ.js.gz +0 -0
- package/dist/dashboard/assets/ProxyPage-D7hpWbg9.js +9 -0
- package/dist/dashboard/assets/ProxyPage-D7hpWbg9.js.gz +0 -0
- package/dist/dashboard/assets/{QuotaPage-BjldQwIU.js → QuotaPage-ATpaxrbl.js} +1 -1
- package/dist/dashboard/assets/QuotaPage-ATpaxrbl.js.gz +0 -0
- package/dist/dashboard/assets/{SettingsPage-DUIoLRxk.js → SettingsPage-CETophpx.js} +1 -1
- package/dist/dashboard/assets/SettingsPage-CETophpx.js.gz +0 -0
- package/dist/dashboard/assets/SetupPage-BdgECjqq.js +1 -0
- package/dist/dashboard/assets/SetupPage-BdgECjqq.js.gz +0 -0
- package/dist/dashboard/assets/{SortableList-fI7JkdIB.js → SortableList-CAK-EN9z.js} +1 -1
- package/dist/dashboard/assets/SortableList-CAK-EN9z.js.gz +0 -0
- package/dist/dashboard/assets/{StudioPage-CHVZqskZ.js → StudioPage-B7W2_RhT.js} +3 -3
- package/dist/dashboard/assets/StudioPage-B7W2_RhT.js.gz +0 -0
- package/dist/dashboard/assets/UsagePage-6T4EFDjW.js +56 -0
- package/dist/dashboard/assets/UsagePage-6T4EFDjW.js.gz +0 -0
- package/dist/dashboard/assets/{api-keys-DFY_fZU4.js → api-keys-CUi6UXsR.js} +1 -1
- package/dist/dashboard/assets/api-keys-CUi6UXsR.js.gz +0 -0
- package/dist/dashboard/assets/app-KvsUJUMF.css +2 -0
- package/dist/dashboard/assets/app-KvsUJUMF.css.gz +0 -0
- package/dist/dashboard/assets/{assert-CwdnZARt.js → assert-67xXH5rf.js} +1 -1
- package/dist/dashboard/assets/assert-67xXH5rf.js.gz +0 -0
- package/dist/dashboard/assets/{badge-Dr-uf0Au.js → badge-DC2L43Mj.js} +1 -1
- package/dist/dashboard/assets/badge-DC2L43Mj.js.gz +0 -0
- package/dist/dashboard/assets/{banner-BddmMdoS.js → banner-BBVcb0J3.js} +1 -1
- package/dist/dashboard/assets/banner-BBVcb0J3.js.gz +0 -0
- package/dist/dashboard/assets/{card-CK0PXWlX.js → card-Cca1XC6G.js} +1 -1
- package/dist/dashboard/assets/card-Cca1XC6G.js.gz +0 -0
- package/dist/dashboard/assets/{cli-tools-CcB6mGh2.js → cli-tools-KvsWa1Jl.js} +1 -1
- package/dist/dashboard/assets/cli-tools-KvsWa1Jl.js.gz +0 -0
- package/dist/dashboard/assets/{clipboard-button-DGb2P9Yx.js → clipboard-button-DUzEbynq.js} +1 -1
- package/dist/dashboard/assets/clipboard-button-DUzEbynq.js.gz +0 -0
- package/dist/dashboard/assets/{dialog-LkfuL50u.js → dialog-DFvWhwTa.js} +1 -1
- package/dist/dashboard/assets/dialog-DFvWhwTa.js.gz +0 -0
- package/dist/dashboard/assets/{drawer-ZbEZ_84c.js → drawer-CFM2sMX1.js} +1 -1
- package/dist/dashboard/assets/drawer-CFM2sMX1.js.gz +0 -0
- package/dist/dashboard/assets/{entry-CWBY5A0f.js → entry-BLBLxX0h.js} +3 -3
- package/dist/dashboard/assets/entry-BLBLxX0h.js.gz +0 -0
- package/dist/dashboard/assets/{entry-BJfsVMvA.js → entry-Bqy8RFvM.js} +1 -1
- package/dist/dashboard/assets/entry-Bqy8RFvM.js.gz +0 -0
- package/dist/dashboard/assets/{entry-CvC1-Zqx.js → entry-_xHo5x6r.js} +1 -1
- package/dist/dashboard/assets/entry-_xHo5x6r.js.gz +0 -0
- package/dist/dashboard/assets/formatters-mpBPqAQ8.js +1 -0
- package/dist/dashboard/assets/formatters-mpBPqAQ8.js.gz +0 -0
- package/dist/dashboard/assets/{github-badge-BxpznFLt.js → github-badge-C9e8Ts7e.js} +1 -1
- package/dist/dashboard/assets/github-badge-C9e8Ts7e.js.gz +0 -0
- package/dist/dashboard/assets/{index-CDzP3ovJ.js → index-D6QzEC_n.js} +2 -2
- package/dist/dashboard/assets/index-D6QzEC_n.js.gz +0 -0
- package/dist/dashboard/assets/{inline-Ae13MQ5w.js → inline-BFUcvllj.js} +1 -1
- package/dist/dashboard/assets/inline-BFUcvllj.js.gz +0 -0
- package/dist/dashboard/assets/{input-D23fo7cp.js → input-C_ILAvBb.js} +1 -1
- package/dist/dashboard/assets/input-C_ILAvBb.js.gz +0 -0
- package/dist/dashboard/assets/{layout-CSsxjj5P.js → layout-CBIyT6Rt.js} +1 -1
- package/dist/dashboard/assets/layout-CBIyT6Rt.js.gz +0 -0
- package/dist/dashboard/assets/{list-row-dmbwZMDY.js → list-row-ebJ_-Nsb.js} +1 -1
- package/dist/dashboard/assets/list-row-ebJ_-Nsb.js.gz +0 -0
- package/dist/dashboard/assets/{live-BG1oUsZZ.js → live-D0mm--ME.js} +1 -1
- package/dist/dashboard/assets/live-D0mm--ME.js.gz +0 -0
- package/dist/dashboard/assets/{mutation-DSF-e4ho.js → mutation-sMD965oO.js} +1 -1
- package/dist/dashboard/assets/mutation-sMD965oO.js.gz +0 -0
- package/dist/dashboard/assets/{numbers-Bm_aECY7.js → numbers-BO9dKaFr.js} +1 -1
- package/dist/dashboard/assets/numbers-BO9dKaFr.js.gz +0 -0
- package/dist/dashboard/assets/providers/inception.svg +5 -0
- package/dist/dashboard/assets/providers/inception.svg.gz +0 -0
- package/dist/dashboard/assets/{query-keys-CF56nYIV.js → query-keys-CfL_Zdoh.js} +1 -1
- package/dist/dashboard/assets/query-keys-CfL_Zdoh.js.gz +0 -0
- package/dist/dashboard/assets/{routing-CeA71n7G.js → routing-BnIpi1IJ.js} +1 -1
- package/dist/dashboard/assets/routing-BnIpi1IJ.js.gz +0 -0
- package/dist/dashboard/assets/{select-KIT0rC6G.js → select-Cj5Nw43g.js} +1 -1
- package/dist/dashboard/assets/select-Cj5Nw43g.js.gz +0 -0
- package/dist/dashboard/assets/{settings-B_2gkePf.js → settings-BAFhDgX8.js} +1 -1
- package/dist/dashboard/assets/settings-BAFhDgX8.js.gz +0 -0
- package/dist/dashboard/assets/{stack-D7WOSzcX.js → stack-EMrOMt4I.js} +1 -1
- package/dist/dashboard/assets/stack-EMrOMt4I.js.gz +0 -0
- package/dist/dashboard/assets/{state-BBxtKZOQ.js → state-CWoo7ty5.js} +1 -1
- package/dist/dashboard/assets/state-CWoo7ty5.js.gz +0 -0
- package/dist/dashboard/assets/{switch-DNS_D5Ea.js → switch-CCjT6IkF.js} +1 -1
- package/dist/dashboard/assets/switch-CCjT6IkF.js.gz +0 -0
- package/dist/dashboard/assets/{useMutation-BgoxdoMk.js → useMutation-DjkLHUcE.js} +1 -1
- package/dist/dashboard/assets/useMutation-DjkLHUcE.js.gz +0 -0
- package/dist/dashboard/index.html +1 -1
- package/dist/dashboard/index.html.gz +0 -0
- package/dist/dashboard/precompressed-assets.json +54 -53
- package/migrations/full-postgres/0024_add_pool_provider_cooldowns.sql +12 -0
- package/migrations/full-postgres/0025_add_pool_random_strategy.sql +3 -0
- package/migrations/lite-sqlite3/0024_add_pool_provider_cooldowns.sql +12 -0
- package/migrations/lite-sqlite3/0025_add_pool_random_strategy.sql +20 -0
- package/package.json +96 -96
- package/scripts/cli/console-menu.ts +5 -2
- package/scripts/cli/tray.ts +21 -6
- package/src/boot/app.ts +684 -714
- package/src/boot/dependencies.ts +65 -62
- package/src/config/cooldowns.ts +16 -0
- package/src/config/providers.ts +13 -1
- package/src/config/resources.ts +70 -70
- package/src/config/security.ts +37 -37
- package/src/config/spec.ts +371 -358
- package/src/console/console-router.ts +233 -225
- package/src/console/domain-registration.ts +398 -381
- package/src/console/providers/catalog/catalog-projections.ts +2 -6
- package/src/console/providers/catalog/contracts.ts +19 -0
- package/src/console/providers/catalog/provider-operations.ts +38 -0
- package/src/console/providers/catalog/routes.ts +14 -0
- package/src/console/providers/catalog/store-helpers.ts +326 -0
- package/src/console/providers/catalog/store.ts +1292 -1563
- package/src/console/quota/account-quota-global.ts +2 -2
- package/src/console/quota/account-quota-shared.ts +1 -1
- package/src/console/quota/account-quota-tenant.ts +35 -12
- package/src/console/quota/quota-view.ts +2 -2
- package/src/console/routing/pools/contracts.ts +41 -1
- package/src/console/routing/pools/operations.ts +183 -4
- package/src/console/routing/pools/relay-deploy.ts +17 -4
- package/src/console/routing/pools/routes.ts +30 -0
- package/src/console/routing/pools/store.ts +98 -8
- package/src/main.ts +183 -167
- package/src/network/outbound-fetch.ts +226 -365
- package/src/network/pool/agent.ts +8 -0
- package/src/network/pool/pool-state.ts +7 -0
- package/src/network/pool/selector.ts +110 -2
- package/src/network/pool-cooldown-store.ts +252 -0
- package/src/network/pool-health-machine.ts +5 -3
- package/src/network/pool-health.ts +36 -9
- package/src/observability/event-query.ts +57 -0
- package/src/observability/metrics.ts +467 -467
- package/src/observability/runtime-metrics.ts +269 -269
- package/src/persistence/health-event-flush.ts +2 -0
- package/src/persistence/schema.ts +19 -0
- package/src/persistence/usage-flush.ts +8 -3
- package/src/protocol/canonical-model.ts +1 -1
- package/src/protocol/dsml.ts +377 -0
- package/src/protocol/gateway-error.ts +232 -232
- package/src/{providers/provider-reasoning.ts → protocol/reasoning.ts} +10 -9
- package/src/protocol/request/chat.ts +7 -7
- package/src/protocol/request/codex.ts +2 -2
- package/src/protocol/request/gemini.ts +1 -1
- package/src/protocol/request/messages.ts +6 -6
- package/src/protocol/request/responses.ts +7 -7
- package/src/protocol/response/dsml.ts +12 -133
- package/src/{transport → protocol}/translation/attachment-integrity.ts +2 -2
- package/src/{transport → protocol}/translation/cache-controls.ts +1 -1
- package/src/{transport → protocol}/translation/capabilities.ts +2 -2
- package/src/{transport → protocol}/translation/normalize.ts +1 -1
- package/src/{transport → protocol}/translation/quirks.ts +1 -1
- package/src/{transport → protocol}/translation/search.ts +1 -1
- package/src/{transport → protocol}/translation/thinking.ts +23 -1
- package/src/{transport → protocol}/translation/tool-id.ts +1 -1
- package/src/{transport → protocol}/translation/tool-repair.ts +2 -2
- package/src/protocol/upstream-parsing.ts +176 -0
- package/src/providers/adapters/compatible-adapter.ts +11 -2
- package/src/providers/authentication/oauth-refresh-service.ts +9 -5
- package/src/providers/default-registry.ts +21 -5
- package/src/providers/discovery/probe-phases.ts +16 -3
- package/src/providers/discovery/probing-service.ts +4 -1
- package/src/providers/integrations/anthropic.ts +1 -1
- package/src/providers/integrations/buddy/buddy-catalog-shared.ts +1 -4
- package/src/providers/integrations/buddy/buddy-chat-shared.ts +141 -8
- package/src/providers/integrations/buddy/buddy-checkin.ts +5 -1
- package/src/providers/integrations/buddy/buddy-growth-shared.ts +0 -82
- package/src/providers/integrations/buddy/buddy-identity.ts +25 -0
- package/src/providers/integrations/buddy/buddy-server-tools.ts +240 -0
- package/src/providers/integrations/buddy/codebuddy/cn-catalog.ts +36 -0
- package/src/providers/integrations/buddy/codebuddy/cn-provider.ts +6 -31
- package/src/providers/integrations/buddy/codebuddy/provider.ts +2 -0
- package/src/providers/integrations/buddy/codebuddy/shared.ts +19 -4
- package/src/providers/integrations/buddy/turing-device-token.ts +262 -0
- package/src/providers/integrations/buddy/workbuddy/provider.ts +2 -0
- package/src/providers/integrations/buddy/workbuddy/shared.ts +56 -3
- package/src/providers/integrations/claude/claude.ts +1 -1
- package/src/providers/integrations/cloudflareai/cloudflareai.ts +1 -1
- package/src/providers/integrations/codex/codex-errors.ts +1 -1
- package/src/providers/integrations/codex/codex.ts +1 -1
- package/src/providers/integrations/factory/factory.ts +1 -1
- package/src/providers/integrations/github/github.ts +1 -1
- package/src/providers/integrations/grok/grok.ts +1 -1
- package/src/providers/integrations/inception/provider.ts +91 -0
- package/src/providers/integrations/inferhub.ts +1 -1
- package/src/providers/integrations/kiro/kiro-request.ts +1 -1
- package/src/providers/integrations/mistral.ts +193 -19
- package/src/providers/integrations/opencode/fingerprint.ts +19 -2
- package/src/providers/integrations/opencode/prompt.ts +111 -0
- package/src/providers/integrations/opencode/provider.ts +101 -23
- package/src/providers/integrations/opencode/tool-definitions.ts +4 -4
- package/src/providers/integrations/qoder/qoder-checkin.ts +303 -0
- package/src/providers/integrations/qoder/qoder.ts +1641 -1458
- package/src/providers/integrations/shared/install-id.ts +2 -1
- package/src/providers/integrations/trae/trae-cache.ts +110 -0
- package/src/providers/integrations/trae/trae-oauth.ts +29 -4
- package/src/providers/integrations/trae/trae-protocol.ts +2 -1
- package/src/providers/integrations/trae/trae.ts +106 -23
- package/src/providers/operations/account-error-classification.ts +1660 -0
- package/src/providers/operations/account-health-service.ts +621 -2097
- package/src/providers/operations/account-reset-service.ts +2 -0
- package/src/providers/provider-contracts.ts +0 -2
- package/src/providers/provider-metadata.ts +25 -4
- package/src/providers/provider-probe.ts +2 -2
- package/src/{console → providers}/quota/cache.ts +1 -1
- package/src/{console → providers}/quota/refresh.ts +5 -5
- package/src/transport/dispatch/attempt-finalize.ts +114 -12
- package/src/transport/dispatch/attempt-loop.ts +3 -0
- package/src/transport/dispatch/empty-stream.ts +224 -217
- package/src/transport/dispatch/generation.ts +37 -55
- package/src/transport/dispatch/handler-deps.ts +32 -0
- package/src/transport/dispatch/leases.ts +9 -4
- package/src/transport/dispatch/proxy-request.ts +6 -30
- package/src/transport/dispatch/responses-compact.ts +22 -43
- package/src/transport/dispatch/streaming/finalize.ts +3 -0
- package/src/transport/dispatch/streaming/stream.ts +0 -8
- package/src/transport/dispatch/systemone.ts +22 -42
- package/src/transport/dispatch/token-count.ts +23 -39
- package/src/transport/dispatch/upstream.ts +1 -3
- package/src/transport/dispatch/websearch.ts +22 -41
- package/src/transport/failure-policy.ts +59 -178
- package/src/transport/guards/abuse-guard.ts +10 -0
- package/src/transport/guards/auth-guard.ts +109 -109
- package/src/transport/guards/error-lifecycle.ts +1 -1
- package/src/transport/guards/pipeline.ts +220 -220
- package/src/transport/guards/request-context.ts +245 -238
- package/src/transport/request/degradation.ts +20 -1
- package/src/transport/request/inflight.ts +4 -114
- package/src/transport/request/preparer.ts +6 -6
- package/src/transport/request/state.ts +66 -38
- package/src/transport/request/tenant-preferences.ts +1 -1
- package/src/transport/routing/route-catalog.ts +41 -31
- package/src/transport/routing/router.ts +2 -2
- package/src/transport/surface/messages/parse.ts +1 -1
- package/src/workers/buddy-growth-tasks.ts +346 -425
- package/src/workers/daily-checkin.ts +17 -6
- package/src/workers/quota-refresh-sweep.ts +2 -2
- package/src/workers/scheduler.ts +17 -1
- package/dist/dashboard/assets/BannedPage-P76QLGJA.js.gz +0 -0
- package/dist/dashboard/assets/CliToolDetailPage-DdBggJS9.js.gz +0 -0
- package/dist/dashboard/assets/CliToolsPage-aN1iXhhP.js.gz +0 -0
- package/dist/dashboard/assets/CombosPage-DE-F1nxZ.js.gz +0 -0
- package/dist/dashboard/assets/ConsoleLogPage-5SpmfLyw.js +0 -1
- package/dist/dashboard/assets/ConsoleLogPage-5SpmfLyw.js.gz +0 -0
- package/dist/dashboard/assets/CustomizationPage-3CUxMy2X.js.gz +0 -0
- package/dist/dashboard/assets/HealthEventsModal-BkmJQKC0.js +0 -1
- package/dist/dashboard/assets/HealthEventsModal-BkmJQKC0.js.gz +0 -0
- package/dist/dashboard/assets/LoginPage-B_0FUKWc.js +0 -1
- package/dist/dashboard/assets/LoginPage-B_0FUKWc.js.gz +0 -0
- package/dist/dashboard/assets/ModelPicker-DKVslqG3.js.gz +0 -0
- package/dist/dashboard/assets/OverviewPage-D-H4MEiT.js +0 -1
- package/dist/dashboard/assets/OverviewPage-D-H4MEiT.js.gz +0 -0
- package/dist/dashboard/assets/ProviderDetailPage-CEJw6Guo.js +0 -3
- package/dist/dashboard/assets/ProviderDetailPage-CEJw6Guo.js.gz +0 -0
- package/dist/dashboard/assets/ProviderIcon-CmfzxpVM.js +0 -1
- package/dist/dashboard/assets/ProviderIcon-CmfzxpVM.js.gz +0 -0
- package/dist/dashboard/assets/ProvidersPage-CEplAR-i.js +0 -1
- package/dist/dashboard/assets/ProvidersPage-CEplAR-i.js.gz +0 -0
- package/dist/dashboard/assets/ProxyPage-CAN7hy0f.js +0 -7
- package/dist/dashboard/assets/ProxyPage-CAN7hy0f.js.gz +0 -0
- package/dist/dashboard/assets/QuotaPage-BjldQwIU.js.gz +0 -0
- package/dist/dashboard/assets/SettingsPage-DUIoLRxk.js.gz +0 -0
- package/dist/dashboard/assets/SetupPage-_bCaTM0v.js +0 -1
- package/dist/dashboard/assets/SetupPage-_bCaTM0v.js.gz +0 -0
- package/dist/dashboard/assets/SortableList-fI7JkdIB.js.gz +0 -0
- package/dist/dashboard/assets/StudioPage-CHVZqskZ.js.gz +0 -0
- package/dist/dashboard/assets/UsagePage-DiFBymHj.js +0 -56
- package/dist/dashboard/assets/UsagePage-DiFBymHj.js.gz +0 -0
- package/dist/dashboard/assets/api-keys-DFY_fZU4.js.gz +0 -0
- package/dist/dashboard/assets/app-BOJ1_xUB.css +0 -2
- package/dist/dashboard/assets/app-BOJ1_xUB.css.gz +0 -0
- package/dist/dashboard/assets/assert-CwdnZARt.js.gz +0 -0
- package/dist/dashboard/assets/badge-Dr-uf0Au.js.gz +0 -0
- package/dist/dashboard/assets/banner-BddmMdoS.js.gz +0 -0
- package/dist/dashboard/assets/card-CK0PXWlX.js.gz +0 -0
- package/dist/dashboard/assets/cli-tools-CcB6mGh2.js.gz +0 -0
- package/dist/dashboard/assets/clipboard-button-DGb2P9Yx.js.gz +0 -0
- package/dist/dashboard/assets/cog-CdWhsajs.js +0 -1
- package/dist/dashboard/assets/cog-CdWhsajs.js.gz +0 -0
- package/dist/dashboard/assets/dialog-LkfuL50u.js.gz +0 -0
- package/dist/dashboard/assets/drawer-ZbEZ_84c.js.gz +0 -0
- package/dist/dashboard/assets/entry-BJfsVMvA.js.gz +0 -0
- package/dist/dashboard/assets/entry-CWBY5A0f.js.gz +0 -0
- package/dist/dashboard/assets/entry-CvC1-Zqx.js.gz +0 -0
- package/dist/dashboard/assets/github-badge-BxpznFLt.js.gz +0 -0
- package/dist/dashboard/assets/index-CDzP3ovJ.js.gz +0 -0
- package/dist/dashboard/assets/inline-Ae13MQ5w.js.gz +0 -0
- package/dist/dashboard/assets/input-D23fo7cp.js.gz +0 -0
- package/dist/dashboard/assets/layout-CSsxjj5P.js.gz +0 -0
- package/dist/dashboard/assets/list-row-dmbwZMDY.js.gz +0 -0
- package/dist/dashboard/assets/live-BG1oUsZZ.js.gz +0 -0
- package/dist/dashboard/assets/mutation-DSF-e4ho.js.gz +0 -0
- package/dist/dashboard/assets/numbers-Bm_aECY7.js.gz +0 -0
- package/dist/dashboard/assets/query-keys-CF56nYIV.js.gz +0 -0
- package/dist/dashboard/assets/routing-CeA71n7G.js.gz +0 -0
- package/dist/dashboard/assets/select-KIT0rC6G.js.gz +0 -0
- package/dist/dashboard/assets/settings-B_2gkePf.js.gz +0 -0
- package/dist/dashboard/assets/stack-D7WOSzcX.js.gz +0 -0
- package/dist/dashboard/assets/state-BBxtKZOQ.js.gz +0 -0
- package/dist/dashboard/assets/switch-DNS_D5Ea.js.gz +0 -0
- package/dist/dashboard/assets/useMutation-BgoxdoMk.js.gz +0 -0
- /package/dist/dashboard/assets/{app-CaXZ9SCn.js → app-BaWd0puM.js} +0 -0
- /package/dist/dashboard/assets/{app-CaXZ9SCn.js.gz → app-BaWd0puM.js.gz} +0 -0
|
@@ -1,232 +1,232 @@
|
|
|
1
|
-
// Typed gateway failures: the stable public error codes, the error class, and
|
|
2
|
-
// the sanitizers that keep upstream payloads out of public envelopes.
|
|
3
|
-
|
|
4
|
-
/** Stable typed error codes returned at gateway boundaries. */
|
|
5
|
-
export type GatewayErrorCode =
|
|
6
|
-
| "capability_unsupported"
|
|
7
|
-
| "ambiguous_model"
|
|
8
|
-
| "model_not_found"
|
|
9
|
-
| "upstream_not_found"
|
|
10
|
-
| "context_length_exceeded"
|
|
11
|
-
| "request_too_large"
|
|
12
|
-
| "accounts_unavailable"
|
|
13
|
-
| "accounts_rate_limited"
|
|
14
|
-
| "capacity_exhausted"
|
|
15
|
-
| "provider_capacity_exhausted"
|
|
16
|
-
| "upstream_queued"
|
|
17
|
-
| "proxy_pool_capacity_exceeded"
|
|
18
|
-
| "proxy_pool_provider_capacity_exceeded"
|
|
19
|
-
| "proxy_pool_blocked"
|
|
20
|
-
| "proxy_pool_cooldown"
|
|
21
|
-
| "proxy_pool_unavailable"
|
|
22
|
-
| "proxy_pool_unhealthy"
|
|
23
|
-
| "invalid_pool_limits"
|
|
24
|
-
| "admission_unavailable"
|
|
25
|
-
| "slug_reserved"
|
|
26
|
-
| "quota_exceeded"
|
|
27
|
-
| "authentication_failed"
|
|
28
|
-
| "policy_rejected"
|
|
29
|
-
| "invalid_request"
|
|
30
|
-
| "not_found"
|
|
31
|
-
| "link_not_found"
|
|
32
|
-
| "link_expired"
|
|
33
|
-
| "link_revoked"
|
|
34
|
-
| "link_disabled"
|
|
35
|
-
| "invalid_sequence"
|
|
36
|
-
| "invalid_lifecycle"
|
|
37
|
-
| "unsupported_field"
|
|
38
|
-
| "unsupported_media_type"
|
|
39
|
-
| "upstream_conflict"
|
|
40
|
-
| "upstream_unprocessable"
|
|
41
|
-
| "internal_error"
|
|
42
|
-
| "transport_unavailable"
|
|
43
|
-
| "tunnel_setup_failed"
|
|
44
|
-
| "platform_unavailable"
|
|
45
|
-
| "tenant_capacity_exhausted"
|
|
46
|
-
| "tls_rejected"
|
|
47
|
-
| "proxy_auth_required"
|
|
48
|
-
| "deadline_exceeded"
|
|
49
|
-
| "transport_closed"
|
|
50
|
-
| "max_connections_exceeded"
|
|
51
|
-
| "overloaded"
|
|
52
|
-
| "proxy_unreachable"
|
|
53
|
-
| "tool_call_loop_detected"
|
|
54
|
-
| "client_router_denied"
|
|
55
|
-
| "shutting_down"
|
|
56
|
-
| "restart_for_update";
|
|
57
|
-
|
|
58
|
-
/** Identifies which boundary produced a safe public error. */
|
|
59
|
-
export type GatewayErrorOrigin = "cartethyia" | "upstream" | "network";
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Error with a client-safe stable code, origin, and sanitized metadata.
|
|
63
|
-
*/
|
|
64
|
-
export class GatewayError extends Error {
|
|
65
|
-
readonly code: GatewayErrorCode;
|
|
66
|
-
readonly status: number;
|
|
67
|
-
readonly origin: GatewayErrorOrigin;
|
|
68
|
-
readonly details: Readonly<Record<string, unknown>>;
|
|
69
|
-
|
|
70
|
-
constructor(
|
|
71
|
-
code: GatewayErrorCode,
|
|
72
|
-
status: number,
|
|
73
|
-
message: string,
|
|
74
|
-
details: Readonly<Record<string, unknown>> = {},
|
|
75
|
-
origin: GatewayErrorOrigin = "cartethyia",
|
|
76
|
-
) {
|
|
77
|
-
super(message);
|
|
78
|
-
this.name = "GatewayError";
|
|
79
|
-
this.code = code;
|
|
80
|
-
this.status = status;
|
|
81
|
-
this.origin = origin;
|
|
82
|
-
this.details = details;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Legacy origin brand prefixes. Older builds stamped these into the public
|
|
88
|
-
* `message`; strip them so a value that crossed two shapers is not doubled
|
|
89
|
-
* and so clients never see product branding in the error text.
|
|
90
|
-
*
|
|
91
|
-
* Blame lives in the structured `origin` field (`cartethyia` | `upstream` |
|
|
92
|
-
* `network`). The public message is always `code: explanatory` for every
|
|
93
|
-
* origin — gateway and upstream look the same on the wire.
|
|
94
|
-
*/
|
|
95
|
-
const LEGACY_ORIGIN_LABELS: readonly string[] = [
|
|
96
|
-
"Cartethyia Error:",
|
|
97
|
-
"Upstream Error:",
|
|
98
|
-
"Network Error:",
|
|
99
|
-
];
|
|
100
|
-
|
|
101
|
-
function stripLegacyOriginLabel(message: string): string {
|
|
102
|
-
const trimmed = message.trim();
|
|
103
|
-
for (const prefix of LEGACY_ORIGIN_LABELS) {
|
|
104
|
-
if (trimmed.startsWith(prefix)) return trimmed.slice(prefix.length).trimStart();
|
|
105
|
-
}
|
|
106
|
-
return trimmed;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Public client-facing error text: a plain sentence, with no machine code
|
|
111
|
-
* stamped into it.
|
|
112
|
-
*
|
|
113
|
-
* The code is not lost — it travels in the envelope's `error.code` field, and
|
|
114
|
-
* the HTTP status carries the class. Stamping it into the text
|
|
115
|
-
* (`accounts_unavailable: Model 'x' has no available account (52 candidate(s)
|
|
116
|
-
* unusable: credit_floor_reached, model_cooldown)`) would put internal enum
|
|
117
|
-
* names in front of the operator's sentence and make the message unreadable
|
|
118
|
-
* while adding nothing the field does not already carry.
|
|
119
|
-
*
|
|
120
|
-
* Stripping is idempotent, and that is the point: a message that already
|
|
121
|
-
* carries a `code:` prefix — stamped by an older builder, or by a code path
|
|
122
|
-
* that formats before it reaches here — loses it once instead of being
|
|
123
|
-
* doubled. Origin is never written into the text either; clients that need the
|
|
124
|
-
* layer read `error.origin`.
|
|
125
|
-
*/
|
|
126
|
-
export function formatPublicErrorMessage(code: string, message: string): string {
|
|
127
|
-
const strippedOrigin = stripLegacyOriginLabel(message);
|
|
128
|
-
// A leading `<code>:` is the old stamping; drop it so the sentence stands on
|
|
129
|
-
// its own. Matched against the code this call is formatting, so a message
|
|
130
|
-
// that legitimately begins with some other word is left alone.
|
|
131
|
-
const prefix = `${code}:`;
|
|
132
|
-
const explanatory = strippedOrigin.startsWith(prefix)
|
|
133
|
-
? strippedOrigin.slice(prefix.length).trimStart()
|
|
134
|
-
: strippedOrigin;
|
|
135
|
-
if (explanatory.length === 0) return code;
|
|
136
|
-
return explanatory;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/** Formats a gateway error for public/internal clients without mutating it. */
|
|
140
|
-
export function explainGatewayError(error: GatewayError): string {
|
|
141
|
-
return formatPublicErrorMessage(error.code, error.message);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const PUBLIC_ERROR_DETAIL_KEYS = new Set([
|
|
145
|
-
"accountId",
|
|
146
|
-
"accountScope",
|
|
147
|
-
"available",
|
|
148
|
-
"capacity",
|
|
149
|
-
"configuredPools",
|
|
150
|
-
"cooldownReason",
|
|
151
|
-
"gateway_hint",
|
|
152
|
-
"currentInflight",
|
|
153
|
-
"credentialEvidence",
|
|
154
|
-
"model",
|
|
155
|
-
"poolId",
|
|
156
|
-
"pools",
|
|
157
|
-
"providerCode",
|
|
158
|
-
"providerId",
|
|
159
|
-
"providerStatus",
|
|
160
|
-
"providerScope",
|
|
161
|
-
"raw",
|
|
162
|
-
"rateLimitScope",
|
|
163
|
-
"reason",
|
|
164
|
-
"reasons",
|
|
165
|
-
"candidate_count",
|
|
166
|
-
"requestId",
|
|
167
|
-
"retryAfterMs",
|
|
168
|
-
"retryAt",
|
|
169
|
-
"safeMessage",
|
|
170
|
-
"scope",
|
|
171
|
-
"status",
|
|
172
|
-
"upstreamRequestId",
|
|
173
|
-
"upstreamStatus",
|
|
174
|
-
"maxInflight",
|
|
175
|
-
"weight",
|
|
176
|
-
]);
|
|
177
|
-
function sanitizePublicDetail(value: unknown, depth = 0): unknown {
|
|
178
|
-
if (typeof value === "string") return value.slice(0, 500);
|
|
179
|
-
if (typeof value !== "object" || value === null) return value;
|
|
180
|
-
if (depth >= 3) return "[redacted]";
|
|
181
|
-
if (Array.isArray(value))
|
|
182
|
-
return value.slice(0, 32).map((entry) => sanitizePublicDetail(entry, depth + 1));
|
|
183
|
-
return Object.fromEntries(
|
|
184
|
-
Object.entries(value).map(([key, entry]) => [
|
|
185
|
-
key,
|
|
186
|
-
sanitizePublicDetail(entry, depth + 1),
|
|
187
|
-
]),
|
|
188
|
-
);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/** Returns bounded allowlisted details suitable for public error envelopes. */
|
|
192
|
-
export function publicGatewayErrorDetails(
|
|
193
|
-
error: GatewayError,
|
|
194
|
-
): Readonly<Record<string, unknown>> {
|
|
195
|
-
return Object.fromEntries(
|
|
196
|
-
Object.entries(error.details)
|
|
197
|
-
.filter(([key]) => PUBLIC_ERROR_DETAIL_KEYS.has(key))
|
|
198
|
-
.map(([key, value]) => [key, sanitizePublicDetail(value)]),
|
|
199
|
-
);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
/** Serializes a GatewayError with the same public shape as transport errors. */
|
|
203
|
-
export function publicGatewayErrorBody(error: GatewayError): {
|
|
204
|
-
readonly error: {
|
|
205
|
-
readonly origin: GatewayErrorOrigin;
|
|
206
|
-
readonly code: GatewayErrorCode;
|
|
207
|
-
readonly message: string;
|
|
208
|
-
readonly details: Readonly<Record<string, unknown>>;
|
|
209
|
-
};
|
|
210
|
-
} {
|
|
211
|
-
return {
|
|
212
|
-
error: {
|
|
213
|
-
origin: error.origin,
|
|
214
|
-
code: error.code,
|
|
215
|
-
message: explainGatewayError(error),
|
|
216
|
-
details: publicGatewayErrorDetails(error),
|
|
217
|
-
},
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
/** Creates the typed rejection required when a semantic feature is unavailable. */
|
|
222
|
-
export function capabilityUnsupported(
|
|
223
|
-
capability: string,
|
|
224
|
-
details: Readonly<Record<string, unknown>> = {},
|
|
225
|
-
): GatewayError {
|
|
226
|
-
return new GatewayError(
|
|
227
|
-
"capability_unsupported",
|
|
228
|
-
400,
|
|
229
|
-
`The selected route does not support capability: ${capability}`,
|
|
230
|
-
{ capability, ...details },
|
|
231
|
-
);
|
|
232
|
-
}
|
|
1
|
+
// Typed gateway failures: the stable public error codes, the error class, and
|
|
2
|
+
// the sanitizers that keep upstream payloads out of public envelopes.
|
|
3
|
+
|
|
4
|
+
/** Stable typed error codes returned at gateway boundaries. */
|
|
5
|
+
export type GatewayErrorCode =
|
|
6
|
+
| "capability_unsupported"
|
|
7
|
+
| "ambiguous_model"
|
|
8
|
+
| "model_not_found"
|
|
9
|
+
| "upstream_not_found"
|
|
10
|
+
| "context_length_exceeded"
|
|
11
|
+
| "request_too_large"
|
|
12
|
+
| "accounts_unavailable"
|
|
13
|
+
| "accounts_rate_limited"
|
|
14
|
+
| "capacity_exhausted"
|
|
15
|
+
| "provider_capacity_exhausted"
|
|
16
|
+
| "upstream_queued"
|
|
17
|
+
| "proxy_pool_capacity_exceeded"
|
|
18
|
+
| "proxy_pool_provider_capacity_exceeded"
|
|
19
|
+
| "proxy_pool_blocked"
|
|
20
|
+
| "proxy_pool_cooldown"
|
|
21
|
+
| "proxy_pool_unavailable"
|
|
22
|
+
| "proxy_pool_unhealthy"
|
|
23
|
+
| "invalid_pool_limits"
|
|
24
|
+
| "admission_unavailable"
|
|
25
|
+
| "slug_reserved"
|
|
26
|
+
| "quota_exceeded"
|
|
27
|
+
| "authentication_failed"
|
|
28
|
+
| "policy_rejected"
|
|
29
|
+
| "invalid_request"
|
|
30
|
+
| "not_found"
|
|
31
|
+
| "link_not_found"
|
|
32
|
+
| "link_expired"
|
|
33
|
+
| "link_revoked"
|
|
34
|
+
| "link_disabled"
|
|
35
|
+
| "invalid_sequence"
|
|
36
|
+
| "invalid_lifecycle"
|
|
37
|
+
| "unsupported_field"
|
|
38
|
+
| "unsupported_media_type"
|
|
39
|
+
| "upstream_conflict"
|
|
40
|
+
| "upstream_unprocessable"
|
|
41
|
+
| "internal_error"
|
|
42
|
+
| "transport_unavailable"
|
|
43
|
+
| "tunnel_setup_failed"
|
|
44
|
+
| "platform_unavailable"
|
|
45
|
+
| "tenant_capacity_exhausted"
|
|
46
|
+
| "tls_rejected"
|
|
47
|
+
| "proxy_auth_required"
|
|
48
|
+
| "deadline_exceeded"
|
|
49
|
+
| "transport_closed"
|
|
50
|
+
| "max_connections_exceeded"
|
|
51
|
+
| "overloaded"
|
|
52
|
+
| "proxy_unreachable"
|
|
53
|
+
| "tool_call_loop_detected"
|
|
54
|
+
| "client_router_denied"
|
|
55
|
+
| "shutting_down"
|
|
56
|
+
| "restart_for_update";
|
|
57
|
+
|
|
58
|
+
/** Identifies which boundary produced a safe public error. */
|
|
59
|
+
export type GatewayErrorOrigin = "cartethyia" | "upstream" | "network";
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Error with a client-safe stable code, origin, and sanitized metadata.
|
|
63
|
+
*/
|
|
64
|
+
export class GatewayError extends Error {
|
|
65
|
+
readonly code: GatewayErrorCode;
|
|
66
|
+
readonly status: number;
|
|
67
|
+
readonly origin: GatewayErrorOrigin;
|
|
68
|
+
readonly details: Readonly<Record<string, unknown>>;
|
|
69
|
+
|
|
70
|
+
constructor(
|
|
71
|
+
code: GatewayErrorCode,
|
|
72
|
+
status: number,
|
|
73
|
+
message: string,
|
|
74
|
+
details: Readonly<Record<string, unknown>> = {},
|
|
75
|
+
origin: GatewayErrorOrigin = "cartethyia",
|
|
76
|
+
) {
|
|
77
|
+
super(message);
|
|
78
|
+
this.name = "GatewayError";
|
|
79
|
+
this.code = code;
|
|
80
|
+
this.status = status;
|
|
81
|
+
this.origin = origin;
|
|
82
|
+
this.details = details;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Legacy origin brand prefixes. Older builds stamped these into the public
|
|
88
|
+
* `message`; strip them so a value that crossed two shapers is not doubled
|
|
89
|
+
* and so clients never see product branding in the error text.
|
|
90
|
+
*
|
|
91
|
+
* Blame lives in the structured `origin` field (`cartethyia` | `upstream` |
|
|
92
|
+
* `network`). The public message is always `code: explanatory` for every
|
|
93
|
+
* origin — gateway and upstream look the same on the wire.
|
|
94
|
+
*/
|
|
95
|
+
const LEGACY_ORIGIN_LABELS: readonly string[] = [
|
|
96
|
+
"Cartethyia Error:",
|
|
97
|
+
"Upstream Error:",
|
|
98
|
+
"Network Error:",
|
|
99
|
+
];
|
|
100
|
+
|
|
101
|
+
function stripLegacyOriginLabel(message: string): string {
|
|
102
|
+
const trimmed = message.trim();
|
|
103
|
+
for (const prefix of LEGACY_ORIGIN_LABELS) {
|
|
104
|
+
if (trimmed.startsWith(prefix)) return trimmed.slice(prefix.length).trimStart();
|
|
105
|
+
}
|
|
106
|
+
return trimmed;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Public client-facing error text: a plain sentence, with no machine code
|
|
111
|
+
* stamped into it.
|
|
112
|
+
*
|
|
113
|
+
* The code is not lost — it travels in the envelope's `error.code` field, and
|
|
114
|
+
* the HTTP status carries the class. Stamping it into the text
|
|
115
|
+
* (`accounts_unavailable: Model 'x' has no available account (52 candidate(s)
|
|
116
|
+
* unusable: credit_floor_reached, model_cooldown)`) would put internal enum
|
|
117
|
+
* names in front of the operator's sentence and make the message unreadable
|
|
118
|
+
* while adding nothing the field does not already carry.
|
|
119
|
+
*
|
|
120
|
+
* Stripping is idempotent, and that is the point: a message that already
|
|
121
|
+
* carries a `code:` prefix — stamped by an older builder, or by a code path
|
|
122
|
+
* that formats before it reaches here — loses it once instead of being
|
|
123
|
+
* doubled. Origin is never written into the text either; clients that need the
|
|
124
|
+
* layer read `error.origin`.
|
|
125
|
+
*/
|
|
126
|
+
export function formatPublicErrorMessage(code: string, message: string): string {
|
|
127
|
+
const strippedOrigin = stripLegacyOriginLabel(message);
|
|
128
|
+
// A leading `<code>:` is the old stamping; drop it so the sentence stands on
|
|
129
|
+
// its own. Matched against the code this call is formatting, so a message
|
|
130
|
+
// that legitimately begins with some other word is left alone.
|
|
131
|
+
const prefix = `${code}:`;
|
|
132
|
+
const explanatory = strippedOrigin.startsWith(prefix)
|
|
133
|
+
? strippedOrigin.slice(prefix.length).trimStart()
|
|
134
|
+
: strippedOrigin;
|
|
135
|
+
if (explanatory.length === 0) return code;
|
|
136
|
+
return explanatory;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** Formats a gateway error for public/internal clients without mutating it. */
|
|
140
|
+
export function explainGatewayError(error: GatewayError): string {
|
|
141
|
+
return formatPublicErrorMessage(error.code, error.message);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const PUBLIC_ERROR_DETAIL_KEYS = new Set([
|
|
145
|
+
"accountId",
|
|
146
|
+
"accountScope",
|
|
147
|
+
"available",
|
|
148
|
+
"capacity",
|
|
149
|
+
"configuredPools",
|
|
150
|
+
"cooldownReason",
|
|
151
|
+
"gateway_hint",
|
|
152
|
+
"currentInflight",
|
|
153
|
+
"credentialEvidence",
|
|
154
|
+
"model",
|
|
155
|
+
"poolId",
|
|
156
|
+
"pools",
|
|
157
|
+
"providerCode",
|
|
158
|
+
"providerId",
|
|
159
|
+
"providerStatus",
|
|
160
|
+
"providerScope",
|
|
161
|
+
"raw",
|
|
162
|
+
"rateLimitScope",
|
|
163
|
+
"reason",
|
|
164
|
+
"reasons",
|
|
165
|
+
"candidate_count",
|
|
166
|
+
"requestId",
|
|
167
|
+
"retryAfterMs",
|
|
168
|
+
"retryAt",
|
|
169
|
+
"safeMessage",
|
|
170
|
+
"scope",
|
|
171
|
+
"status",
|
|
172
|
+
"upstreamRequestId",
|
|
173
|
+
"upstreamStatus",
|
|
174
|
+
"maxInflight",
|
|
175
|
+
"weight",
|
|
176
|
+
]);
|
|
177
|
+
function sanitizePublicDetail(value: unknown, depth = 0): unknown {
|
|
178
|
+
if (typeof value === "string") return value.slice(0, 500);
|
|
179
|
+
if (typeof value !== "object" || value === null) return value;
|
|
180
|
+
if (depth >= 3) return "[redacted]";
|
|
181
|
+
if (Array.isArray(value))
|
|
182
|
+
return value.slice(0, 32).map((entry) => sanitizePublicDetail(entry, depth + 1));
|
|
183
|
+
return Object.fromEntries(
|
|
184
|
+
Object.entries(value).map(([key, entry]) => [
|
|
185
|
+
key,
|
|
186
|
+
sanitizePublicDetail(entry, depth + 1),
|
|
187
|
+
]),
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** Returns bounded allowlisted details suitable for public error envelopes. */
|
|
192
|
+
export function publicGatewayErrorDetails(
|
|
193
|
+
error: GatewayError,
|
|
194
|
+
): Readonly<Record<string, unknown>> {
|
|
195
|
+
return Object.fromEntries(
|
|
196
|
+
Object.entries(error.details)
|
|
197
|
+
.filter(([key]) => PUBLIC_ERROR_DETAIL_KEYS.has(key))
|
|
198
|
+
.map(([key, value]) => [key, sanitizePublicDetail(value)]),
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** Serializes a GatewayError with the same public shape as transport errors. */
|
|
203
|
+
export function publicGatewayErrorBody(error: GatewayError): {
|
|
204
|
+
readonly error: {
|
|
205
|
+
readonly origin: GatewayErrorOrigin;
|
|
206
|
+
readonly code: GatewayErrorCode;
|
|
207
|
+
readonly message: string;
|
|
208
|
+
readonly details: Readonly<Record<string, unknown>>;
|
|
209
|
+
};
|
|
210
|
+
} {
|
|
211
|
+
return {
|
|
212
|
+
error: {
|
|
213
|
+
origin: error.origin,
|
|
214
|
+
code: error.code,
|
|
215
|
+
message: explainGatewayError(error),
|
|
216
|
+
details: publicGatewayErrorDetails(error),
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** Creates the typed rejection required when a semantic feature is unavailable. */
|
|
222
|
+
export function capabilityUnsupported(
|
|
223
|
+
capability: string,
|
|
224
|
+
details: Readonly<Record<string, unknown>> = {},
|
|
225
|
+
): GatewayError {
|
|
226
|
+
return new GatewayError(
|
|
227
|
+
"capability_unsupported",
|
|
228
|
+
400,
|
|
229
|
+
`The selected route does not support capability: ${capability}`,
|
|
230
|
+
{ capability, ...details },
|
|
231
|
+
);
|
|
232
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { CanonicalRequest, ReasoningEffort, ReasoningIntent } from "
|
|
2
|
-
import { budgetToLevel } from "
|
|
3
|
-
import { isRecord } from "
|
|
1
|
+
import type { CanonicalRequest, ReasoningEffort, ReasoningIntent } from "./canonical-model";
|
|
2
|
+
import { budgetToLevel } from "./translation/thinking";
|
|
3
|
+
import { isRecord } from "./codecs";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The effective reasoning effort for a canonical intent, deriving one from an
|
|
@@ -132,12 +132,13 @@ const CLAMPED_EFFORT_MIN_OUTPUT_TOKENS = 16_384;
|
|
|
132
132
|
const BUDDY_LEVEL_RANK: Readonly<Record<string, number>> = {
|
|
133
133
|
off: 0,
|
|
134
134
|
none: 0,
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
135
|
+
instant: 1,
|
|
136
|
+
minimal: 2,
|
|
137
|
+
low: 3,
|
|
138
|
+
medium: 4,
|
|
139
|
+
high: 5,
|
|
140
|
+
xhigh: 6,
|
|
141
|
+
max: 7,
|
|
141
142
|
};
|
|
142
143
|
|
|
143
144
|
/** Builds the Anthropic thinking block from canonical reasoning intent. */
|
|
@@ -3,18 +3,18 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { CanonicalRequest, ResponseFormat } from "../canonical-model";
|
|
5
5
|
import { isRecord } from "../codecs";
|
|
6
|
-
import { markLatestBreakpoint } from "../../
|
|
7
|
-
import { isWebSearchTool } from "../../
|
|
8
|
-
import { pickWireSupportedControls } from "../../
|
|
9
|
-
import { normalizeWireMaxTokens } from "../../
|
|
10
|
-
import { resolveWireMaxTokens } from "../../
|
|
6
|
+
import { markLatestBreakpoint } from "../../protocol/translation/cache-controls";
|
|
7
|
+
import { isWebSearchTool } from "../../protocol/translation/search";
|
|
8
|
+
import { pickWireSupportedControls } from "../../protocol/translation/capabilities";
|
|
9
|
+
import { normalizeWireMaxTokens } from "../../protocol/translation/normalize";
|
|
10
|
+
import { resolveWireMaxTokens } from "../../protocol/translation/quirks";
|
|
11
11
|
import {
|
|
12
12
|
clampReasoningEffort,
|
|
13
13
|
resolveSupportedReasoningEfforts,
|
|
14
|
-
} from "../../
|
|
14
|
+
} from "../../protocol/translation/thinking";
|
|
15
15
|
import { isClaudeBillingHeaderText, resolveImageSource } from "../codecs";
|
|
16
16
|
import { resolvePromptCacheKey } from "../../providers/operations/session-resolution";
|
|
17
|
-
import { reasoningEffortFromIntent } from "../../
|
|
17
|
+
import { reasoningEffortFromIntent } from "../../protocol/reasoning";
|
|
18
18
|
import { parseChatResponseToEvents, decodeChatSseStream } from "../response/chat";
|
|
19
19
|
|
|
20
20
|
/**
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import type { CanonicalMessage, CanonicalRequest, ContentPart } from "../canonical-model";
|
|
11
11
|
import { canContainToolResult, toolResultParts } from "../canonical-model";
|
|
12
|
-
import { isWebSearchTool } from "../../
|
|
13
|
-
import { reasoningEffortFromIntent } from "../../
|
|
12
|
+
import { isWebSearchTool } from "../../protocol/translation/search";
|
|
13
|
+
import { reasoningEffortFromIntent } from "../../protocol/reasoning";
|
|
14
14
|
import {
|
|
15
15
|
decodeCodexToolCallId,
|
|
16
16
|
encodeCodexToolCallId,
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
splitDataUrl,
|
|
15
15
|
type RewriteWalk,
|
|
16
16
|
} from "../codecs";
|
|
17
|
-
import { geminiThinkingOutputFloor } from "../../
|
|
17
|
+
import { geminiThinkingOutputFloor } from "../../protocol/reasoning";
|
|
18
18
|
import { base64DecodedByteLength, clampImage } from "../image-clamp";
|
|
19
19
|
|
|
20
20
|
export function geminiModelUrl(base: string, model: string, action: string): string {
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
* Canonical → Claude Messages request builder.
|
|
3
3
|
*/
|
|
4
4
|
import { allParts, type CanonicalRequest, type ContentPart } from "../canonical-model";
|
|
5
|
-
import { buildAnthropicThinkingPayload } from "../../
|
|
6
|
-
import { anthropicCacheControl } from "../../
|
|
5
|
+
import { buildAnthropicThinkingPayload } from "../../protocol/reasoning";
|
|
6
|
+
import { anthropicCacheControl } from "../../protocol/translation/cache-controls";
|
|
7
7
|
import {
|
|
8
8
|
THINKING_STRIPPED_SAMPLING_CONTROLS,
|
|
9
9
|
ensureMaxTokensForThinking,
|
|
10
10
|
isThinkingEnabled,
|
|
11
|
-
} from "../../
|
|
12
|
-
import { normalizeWireMaxTokens } from "../../
|
|
13
|
-
import { resolveWireMaxTokens, WIRE_TOKEN_BOUNDS } from "../../
|
|
11
|
+
} from "../../protocol/translation/capabilities";
|
|
12
|
+
import { normalizeWireMaxTokens } from "../../protocol/translation/normalize";
|
|
13
|
+
import { resolveWireMaxTokens, WIRE_TOKEN_BOUNDS } from "../../protocol/translation/quirks";
|
|
14
14
|
import {
|
|
15
15
|
isClaudeBillingHeaderText,
|
|
16
16
|
normalizeAnthropicToolCallId,
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
} from "../codecs";
|
|
29
29
|
import { log } from "../../observability/logger";
|
|
30
30
|
import { base64DecodedByteLength, clampImage } from "../image-clamp";
|
|
31
|
-
import { clampReasoningEffort, claudeUsesAdaptiveThinking, LEVEL_TO_BUDGET, resolveSupportedReasoningEfforts } from "../../
|
|
31
|
+
import { clampReasoningEffort, claudeUsesAdaptiveThinking, LEVEL_TO_BUDGET, resolveSupportedReasoningEfforts } from "../../protocol/translation/thinking";
|
|
32
32
|
import { claudeResponseToEvents, parseClaudeSseStream } from "../response/messages";
|
|
33
33
|
|
|
34
34
|
/**
|
|
@@ -3,18 +3,18 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { CanonicalRequest } from "../canonical-model";
|
|
5
5
|
import { clampToolCallId, isRecord } from "../codecs";
|
|
6
|
-
import { markLatestBreakpoint } from "../../
|
|
7
|
-
import { pickWireSupportedControls } from "../../
|
|
8
|
-
import { normalizeGenerationControls } from "../../
|
|
9
|
-
import { resolveWireMaxTokens } from "../../
|
|
6
|
+
import { markLatestBreakpoint } from "../../protocol/translation/cache-controls";
|
|
7
|
+
import { pickWireSupportedControls } from "../../protocol/translation/capabilities";
|
|
8
|
+
import { normalizeGenerationControls } from "../../protocol/translation/normalize";
|
|
9
|
+
import { resolveWireMaxTokens } from "../../protocol/translation/quirks";
|
|
10
10
|
import {
|
|
11
11
|
clampReasoningEffort,
|
|
12
12
|
resolveSupportedReasoningEfforts,
|
|
13
|
-
} from "../../
|
|
13
|
+
} from "../../protocol/translation/thinking";
|
|
14
14
|
import { isClaudeBillingHeaderText, resolveImageSource, resolveOutputVerbosity } from "../codecs";
|
|
15
15
|
import { resolvePromptCacheKey } from "../../providers/operations/session-resolution";
|
|
16
|
-
import { reasoningEffortFromIntent } from "../../
|
|
17
|
-
import { isWebSearchTool } from "../../
|
|
16
|
+
import { reasoningEffortFromIntent } from "../../protocol/reasoning";
|
|
17
|
+
import { isWebSearchTool } from "../../protocol/translation/search";
|
|
18
18
|
import { parseResponsesResponseToEvents, decodeResponsesSseStream } from "../response/responses";
|
|
19
19
|
import { repairToolArguments } from "../../transport/surface/chat/encode";
|
|
20
20
|
|