@bitkyc08/opencodex 2.97.0 → 2.98.0-preview.20261107
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/bin/ocx.mjs +1 -1
- package/gui/dist/assets/App-6TFtZsUF.css +1 -0
- package/gui/dist/assets/App-B8_sOxoz.js +59 -0
- package/gui/dist/assets/Tray-DpWEp6ee.js +1 -0
- package/gui/dist/assets/WantedSansVariable.split.0-Dwvb1WRx.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.1-1wKD2RxI.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.10-CAKA6LIP.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.11-k5H85R4b.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.12-BHboLsUv.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.13-9GV377ix.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.14-DovDXnrj.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.15-DTdykCig.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.16-CKz2ccgK.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.17-Z2RD_KRZ.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.18-BcKtfonJ.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.19-DEQPOSZn.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.2-DryboyuA.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.20-Bia5JMls.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.21-Cr4jFw-E.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.22-DjjB69TZ.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.23-CvUzJskt.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.24-i_eMg5ox.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.25-2aKHwPX-.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.26-B6wXoCEL.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.27-D4h1WfGM.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.28-kvRPCStd.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.29-DHAiwleD.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.3-7H--eyZi.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.30-C66cfAY2.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.31-FDmtiNim.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.32-DouHt2Dd.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.33-B8HVvkJX.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.34-BtkRu1FN.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.35-DBylQbtk.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.36-Sg089Kgh.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.37-CYtvbriS.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.38-DKkSLf8Z.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.39-CecotKZD.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.4-Bv8O3ZMb.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.40-DdCvkmOU.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.41-ESn674Hc.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.42-DL9V7NNV.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.43-yipO0cyk.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.44-6rTmLZhm.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.45-BJAj8lrm.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.46-BDTzMn2c.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.47-Bxd4wGgi.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.48-DxnFBLnH.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.49-DnVD0aOD.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.5-B1wI2pp5.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.50-D9JlkZd6.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.51-D9Vw6Bu3.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.52-ClEJk4kn.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.53-BSXU0vh-.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.54-EcuxkR9v.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.55-CYiFhQX8.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.56--Gk9g8BK.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.57-DnkOPZcy.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.58-9MB8504z.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.59-ByxIsN72.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.6-Bmk0dRVw.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.60-Bxwx_aWQ.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.61-DA2z5sm7.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.62-C5iJPJZn.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.63-DAqrmaEc.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.64-BgXFsljb.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.65-DKiWujvu.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.66-8po4vUZ4.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.67-Cy5qyI9O.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.68-BKny7Fy3.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.69-B4VU4u_b.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.7-BuqwNpgA.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.70-BCd4n346.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.71-CkQppaWn.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.72-Db7vaoFs.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.73-DI80TYWl.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.74-tMCtDAHB.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.75-Ciw0D5WG.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.76-DoLjFgp-.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.77-CpT2uvMy.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.78-CkcJ4iZ1.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.79-DsOUJjEM.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.8-DsjypPd6.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.80-C0VwHTte.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.81-DTelu57i.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.82-BiMndGN1.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.83-CVcC6eDG.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.84-DlhZVt_O.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.85-S8I2D3pA.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.86-DozXXpH5.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.87-Dsn0Vuuo.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.88-iNwxxDCr.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.89-B63u_9CZ.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.9-Bi3IzpMI.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.90-ByeH1Pqf.woff2 +0 -0
- package/gui/dist/assets/WantedSansVariable.split.91-UQLlagpm.woff2 +0 -0
- package/gui/dist/assets/brand-mark-VPhzz-WE.js +1 -0
- package/gui/dist/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
- package/gui/dist/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
- package/gui/dist/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
- package/gui/dist/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
- package/gui/dist/assets/geist-mono-cyrillic-ext-wght-normal-X_5orZeX.woff2 +0 -0
- package/gui/dist/assets/geist-mono-cyrillic-wght-normal-DiZS0aHC.woff2 +0 -0
- package/gui/dist/assets/geist-mono-latin-ext-wght-normal-Bwz-egvJ.woff2 +0 -0
- package/gui/dist/assets/geist-mono-latin-wght-normal-XN7g48iV.woff2 +0 -0
- package/gui/dist/assets/geist-mono-symbols2-wght-normal-CO5SzqOn.woff2 +0 -0
- package/gui/dist/assets/geist-mono-vietnamese-wght-normal-DadHysG0.woff2 +0 -0
- package/gui/dist/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
- package/gui/dist/assets/index-5REODpG3.css +2 -0
- package/gui/dist/assets/index-BWKBeK77.js +94 -0
- package/gui/dist/assets/segment-thumb-features-BQYzrze9.js +1 -0
- package/gui/dist/classic/assets/App-Bz65x1J6.js +58 -0
- package/gui/dist/{assets/Tray-CEw0y0jR.js → classic/assets/Tray-kk7mdO6I.js} +1 -1
- package/gui/dist/classic/assets/index-Dp2j8bSc.js +94 -0
- package/gui/dist/classic/assets/quota-summary-CvamtHjB.js +1 -0
- package/gui/dist/classic/index.html +47 -0
- package/gui/dist/favicon.png +0 -0
- package/gui/dist/favicon.svg +14 -0
- package/gui/dist/index.html +15 -2
- package/package.json +1 -1
- package/src/adapters/anthropic.ts +17 -8
- package/src/adapters/google.ts +7 -7
- package/src/adapters/kiro/adapter.ts +18 -3
- package/src/adapters/kiro/conversation.ts +8 -8
- package/src/adapters/kiro/payload.ts +45 -12
- package/src/adapters/kiro/stream.ts +169 -12
- package/src/adapters/kiro/structured-output-json.ts +191 -0
- package/src/adapters/kiro/structured-output-schema.ts +542 -0
- package/src/adapters/kiro/structured-output.ts +367 -0
- package/src/adapters/kiro-constants.ts +9 -0
- package/src/adapters/kiro-tools.ts +14 -9
- package/src/adapters/kiro-wire.ts +9 -5
- package/src/adapters/openai-chat/messages.ts +58 -5
- package/src/adapters/openai-chat/mistral-image-limit.ts +50 -0
- package/src/adapters/openai-chat/passthrough.ts +5 -3
- package/src/adapters/openai-chat/tool-schema.ts +83 -13
- package/src/adapters/openai-responses/opengateway-input.ts +18 -6
- package/src/adapters/openai-responses/tool-output-recovery.ts +79 -0
- package/src/adapters/qoder/live-models.ts +115 -1
- package/src/claude/failure-verdict.ts +21 -0
- package/src/claude/inbound-content-options.ts +15 -2
- package/src/claude/inbound-model-options.ts +2 -1
- package/src/claude/inbound-records.ts +2 -0
- package/src/claude/inbound.ts +17 -11
- package/src/claude/outbound.ts +52 -23
- package/src/cli/capabilities-access-remote.ts +13 -0
- package/src/cli/capabilities-base.ts +1 -0
- package/src/cli/capabilities-provider-models.ts +3 -3
- package/src/cli/codex-shim-autorestore.ts +7 -0
- package/src/cli/config-command.ts +11 -2
- package/src/cli/connect.ts +17 -2
- package/src/cli/dispatch.ts +3 -1
- package/src/cli/doctor.ts +95 -7
- package/src/cli/index.ts +12 -7
- package/src/cli/link-apply-restart.ts +9 -2
- package/src/cli/models.ts +124 -38
- package/src/cli/registry.ts +1 -1
- package/src/cli/restart-failure.ts +17 -0
- package/src/cli/stop-approval.ts +2 -2
- package/src/cli/sync-command.ts +1 -1
- package/src/cli/sync-fanout.ts +15 -4
- package/src/cli/system-restart-client.ts +5 -0
- package/src/cli/uninstall-client-state.ts +12 -1
- package/src/cli/update-restart-child.ts +13 -3
- package/src/cli/update-restart-home.ts +6 -3
- package/src/cli/update-restart.ts +36 -19
- package/src/client/connect.ts +4 -1
- package/src/client/hub-client.ts +5 -0
- package/src/client/link-management-relay.ts +39 -2
- package/src/client/link-readiness.ts +3 -1
- package/src/client/machine-api.ts +2 -1
- package/src/client/machine-listener.ts +7 -0
- package/src/client/orphan-token-recovery.ts +322 -0
- package/src/codex/catalog/provider-models.ts +12 -4
- package/src/codex/native-profile-api.ts +27 -1
- package/src/codex/shim-diagnostics.ts +7 -0
- package/src/codex/shim-legacy-record.ts +290 -0
- package/src/codex/shim-windows-refresh.ts +9 -2
- package/src/codex/shim-wrapper-write.ts +7 -0
- package/src/codex/shim.ts +80 -21
- package/src/config/diagnostics.ts +9 -9
- package/src/config/load-degrade.ts +27 -27
- package/src/config/provider-validation.ts +9 -2
- package/src/config/removed-opencode-free-backup.ts +6 -3
- package/src/config/tracked-runtime-inspection.ts +3 -3
- package/src/generated/compatibility-version.json +219 -147
- package/src/images/loop.ts +2 -2
- package/src/lib/client-error-body.ts +37 -6
- package/src/lib/config-ownership-removal.ts +422 -0
- package/src/lib/config-ownership.ts +646 -81
- package/src/lib/context-overflow-verdict.ts +3 -3
- package/src/lib/crash-guard.ts +4 -2
- package/src/lib/desktop-cli-handoff.d.mts +3 -4
- package/src/lib/desktop-cli-handoff.mjs +7 -16
- package/src/lib/errors.ts +1 -0
- package/src/lib/local-management-capability.ts +3 -1
- package/src/lib/messages-error-body.ts +162 -0
- package/src/lib/messages-sse-error-presentation.ts +93 -0
- package/src/lib/passive-read.ts +9 -4
- package/src/lib/socks5-fetch.ts +21 -9
- package/src/lib/upstream-retry.ts +81 -1
- package/src/lib/windows-owner-acl.ts +9 -3
- package/src/lib/winsw.ts +5 -5
- package/src/lib/workflow-budget.ts +3 -1
- package/src/oauth/index.ts +7 -0
- package/src/oauth/store.ts +20 -10
- package/src/protocols/codecs/messages-ir.ts +15 -9
- package/src/protocols/encoders/adapter-events.ts +26 -7
- package/src/protocols/encoders/messages.ts +72 -28
- package/src/providers/antigravity-models.ts +45 -12
- package/src/providers/free-directory.ts +2 -2
- package/src/providers/reasoning-metadata.ts +2 -1
- package/src/providers/registry/entries-extended.ts +9 -0
- package/src/reasoning-effort.ts +7 -2
- package/src/remote/hub-usage.ts +3 -0
- package/src/server/admission-model-scope.ts +1 -1
- package/src/server/admitted-http-turn.ts +2 -1
- package/src/server/anthropic-rate-limit-headers.ts +75 -3
- package/src/server/claude-messages.ts +130 -67
- package/src/server/gui-static.ts +4 -1
- package/src/server/hub-usage.ts +7 -2
- package/src/server/index/link-management.ts +8 -0
- package/src/server/index/ollama-routes.ts +2 -0
- package/src/server/index/serve-options.ts +23 -20
- package/src/server/index/startup-warnings.ts +5 -12
- package/src/server/index/websocket-handler.ts +1 -0
- package/src/server/inference/client-encoder-delivery.ts +5 -1
- package/src/server/management/logs-usage-routes.ts +89 -4
- package/src/server/management/provider-routes.ts +2 -22
- package/src/server/management/qoder-provider-probe.ts +105 -0
- package/src/server/management/route-registry.ts +3 -0
- package/src/server/management/usage-aggregate-cache.ts +15 -5
- package/src/server/management/usage-source-facets.ts +38 -0
- package/src/server/messages-native-tool-guard.ts +11 -3
- package/src/server/messages-native.ts +111 -40
- package/src/server/messages-response-headers.ts +25 -11
- package/src/server/messages-shared.ts +94 -64
- package/src/server/messages-sse-error-filter.ts +199 -0
- package/src/server/request-log.ts +12 -0
- package/src/server/responses/adapter-continuation.ts +11 -5
- package/src/server/responses/adapter-delivery.ts +14 -8
- package/src/server/responses/adapter-dispatch.ts +8 -8
- package/src/server/responses/anthropic-thinking-recovery.ts +2 -2
- package/src/server/responses/codex-auth-error.ts +8 -4
- package/src/server/responses/codex-ws-wire.ts +19 -3
- package/src/server/responses/compact.ts +4 -1
- package/src/server/responses/core-auth.ts +1 -1
- package/src/server/responses/core-combo-failure.ts +2 -0
- package/src/server/responses/core-combo.ts +2 -0
- package/src/server/responses/core-errors.ts +5 -4
- package/src/server/responses/core-options.ts +2 -0
- package/src/server/responses/empty-completion-guard.ts +4 -1
- package/src/server/responses/pacing-overload.ts +1 -1
- package/src/server/responses/passthrough-dispatch.ts +5 -5
- package/src/server/responses/request-prepare.ts +3 -1
- package/src/server/responses/request-transport.ts +9 -8
- package/src/server/responses/response-effects.ts +3 -2
- package/src/server/responses/terminal-guard.ts +30 -0
- package/src/server/restart-replacement.ts +3 -1
- package/src/server/sse-payload-rewrite.ts +23 -11
- package/src/server/workflow-refusal.ts +1 -1
- package/src/server/ws-bridge.ts +4 -0
- package/src/service/definition.ts +36 -4
- package/src/service/launchd.ts +89 -32
- package/src/service/logging.ts +34 -7
- package/src/service/plist-xml.ts +59 -0
- package/src/service/state.ts +8 -0
- package/src/service/systemd-env.ts +2 -0
- package/src/service/systemd.ts +31 -7
- package/src/service/windows-taskxml.ts +16 -7
- package/src/service-manager-probe.ts +4 -10
- package/src/types/provider.ts +2 -0
- package/src/types/request.ts +13 -1
- package/src/update/config-preflight.ts +48 -0
- package/src/update/index.ts +15 -1
- package/src/usage/client.ts +43 -0
- package/src/usage/error-detail.ts +1 -1
- package/src/usage/log.ts +4 -0
- package/src/usage/source-facets.ts +51 -0
- package/src/usage/source-filter.ts +65 -0
- package/src/usage/summary.ts +50 -8
- package/src/web-search/anthropic-executor.ts +105 -24
- package/src/web-search/executor.ts +5 -3
- package/src/web-search/loop.ts +2 -1
- package/src/web-search/progress-stream.ts +64 -5
- package/gui/dist/assets/App-DuNhggE1.js +0 -58
- package/gui/dist/assets/index-CynE_Rue.js +0 -94
- package/gui/dist/assets/quota-summary-VHFSlUuM.js +0 -1
- /package/gui/dist/{assets → classic/assets}/App-B4j-Txmb.css +0 -0
- /package/gui/dist/{assets → classic/assets}/index-CHWwDo9L.css +0 -0
|
@@ -12,7 +12,7 @@ export const FREE_PROVIDER_ACCESS_GROUPS = {
|
|
|
12
12
|
"cloudflare-ai", "cohere", "coze", "duckduckgo-web", "felo-web", "friendliai", "gemini", "github-models",
|
|
13
13
|
"groq", "hackclub", "huggingchat", "huggingface", "iflytek", "inference-net", "kiro", "liquid", "llm7",
|
|
14
14
|
"mistral", "morph", "muse-spark-web", "nara", "navy", "nlpcloud", "ollama-cloud", "opencode", "openrouter",
|
|
15
|
-
"ovhcloud", "pollinations", "puter", "qwen-web", "reka", "runcrate", "sambanova", "sparkdesk", "t3-web", "uncloseai",
|
|
15
|
+
"ovhcloud", "perch", "pollinations", "puter", "qwen-web", "reka", "runcrate", "sambanova", "sparkdesk", "t3-web", "uncloseai",
|
|
16
16
|
],
|
|
17
17
|
"recurring-uncapped": [
|
|
18
18
|
"agnes", "ainative", "aion", "baidu", "glm", "glm-cn", "kilo-gateway", "opencode-zen", "requesty",
|
|
@@ -204,7 +204,7 @@ const LABELS: Record<string, string> = {
|
|
|
204
204
|
gemini: "Google Gemini", "github-models": "GitHub Models", huggingchat: "HuggingChat", huggingface: "Hugging Face",
|
|
205
205
|
iflytek: "iFlytek", "inference-net": "Inference.net", llm7: "LLM7", "muse-spark-web": "Muse Spark Web",
|
|
206
206
|
nlpcloud: "NLP Cloud", "ollama-cloud": "Ollama Cloud", ovhcloud: "OVHcloud", "qwen-web": "Qwen Web",
|
|
207
|
-
"t3-web": "T3 Web", uncloseai: "UncloseAI", ainative: "AI Native", baidu: "Baidu Qianfan",
|
|
207
|
+
"t3-web": "T3 Web", uncloseai: "UncloseAI", perch: "Perch", ainative: "AI Native", baidu: "Baidu Qianfan",
|
|
208
208
|
glm: "Z.AI GLM", "glm-cn": "BigModel GLM (CN)", "kilo-gateway": "Kilo Gateway", "opencode-zen": "OpenCode Zen",
|
|
209
209
|
sealion: "SEA-LION", bytez: "Bytez", "nous-research": "Nous Research", agentrouter: "AgentRouter",
|
|
210
210
|
ai21: "AI21", baichuan: "Baichuan", crusoe: "Crusoe", deepinfra: "DeepInfra", deepseek: "DeepSeek", doubao: "Doubao",
|
|
@@ -324,8 +324,9 @@ export function dropLearnedUnsupportedReasoningEfforts(
|
|
|
324
324
|
): string[] {
|
|
325
325
|
if (efforts.length === 0) return [...efforts];
|
|
326
326
|
const key = metadataProviderKey(provider);
|
|
327
|
+
if (!key) return [...efforts];
|
|
327
328
|
const credential = credentialIdentity(provider);
|
|
328
|
-
if (!
|
|
329
|
+
if (!credential) return [...efforts];
|
|
329
330
|
const support = loadSupport();
|
|
330
331
|
if (support.size === 0) return [...efforts];
|
|
331
332
|
const kept = efforts.filter(effort => !support.has(supportKey(key, credential, modelId, effort)));
|
|
@@ -1046,6 +1046,15 @@ export const PROVIDER_REGISTRY_EXTENDED: readonly ProviderRegistryEntry[] = [
|
|
|
1046
1046
|
dashboardUrl: "https://console.mistral.ai/api-keys", defaultModel: "codestral-latest", promptCacheKey: true,
|
|
1047
1047
|
// Native text-only input enrolls this model in the existing vision sidecar.
|
|
1048
1048
|
modelInputModalities: { "zai-glm-5-3": ["text"] },
|
|
1049
|
+
// Images per request above the documented 8, measured on api.mistral.ai on 2026-11-04 as the
|
|
1050
|
+
// largest count accepted before a refusal (Flash answers HTTP 503, code 3800, at 21; Large 4
|
|
1051
|
+
// answers HTTP 400 at 101). GLM 5.3 Flash accepted every count tried, up to 256.
|
|
1052
|
+
modelCapabilities: {
|
|
1053
|
+
"deepseek-v4-1-flash-1017": { mistralMaxImages: 20 },
|
|
1054
|
+
"mistral-large-4": { mistralMaxImages: 100 },
|
|
1055
|
+
"mistral-large-4-0": { mistralMaxImages: 100 },
|
|
1056
|
+
"zai-glm-5-3-flash": { mistralMaxImages: 256 },
|
|
1057
|
+
},
|
|
1049
1058
|
},
|
|
1050
1059
|
{
|
|
1051
1060
|
id: "minimax", label: "MiniMax — Coding Plan", baseUrl: "https://api.minimax.io/v1", adapter: "openai-chat", authKind: "key",
|
package/src/reasoning-effort.ts
CHANGED
|
@@ -153,8 +153,13 @@ export function sanitizeCodexReasoningEfforts(efforts: readonly string[] | undef
|
|
|
153
153
|
/**
|
|
154
154
|
* Provider/model configured reasoning levels for the Codex catalog. `undefined` means “no override”,
|
|
155
155
|
* while an empty array means “intentionally expose no effort control for this model”.
|
|
156
|
+
* Read-only callers can suppress stale-snapshot refresh without changing the returned ladder.
|
|
156
157
|
*/
|
|
157
|
-
export function configuredReasoningEfforts(
|
|
158
|
+
export function configuredReasoningEfforts(
|
|
159
|
+
provider: OcxProviderConfig,
|
|
160
|
+
modelId: string,
|
|
161
|
+
options?: { refreshMetadata?: boolean },
|
|
162
|
+
): string[] | undefined {
|
|
158
163
|
if (modelInList(provider.noReasoningModels, modelId)) return [];
|
|
159
164
|
const modelEfforts = modelRecordValue(provider.modelReasoningEfforts, modelId);
|
|
160
165
|
// Rungs this account actually had refused are removed for every ladder source (registry
|
|
@@ -180,7 +185,7 @@ export function configuredReasoningEfforts(provider: OcxProviderConfig, modelId:
|
|
|
180
185
|
// not request work.
|
|
181
186
|
const fromMetadata = reasoningEffortsFromMetadata(provider, modelId);
|
|
182
187
|
if (fromMetadata !== undefined) {
|
|
183
|
-
ensureReasoningMetadataSnapshot();
|
|
188
|
+
if (options?.refreshMetadata !== false) ensureReasoningMetadataSnapshot();
|
|
184
189
|
return dropLearnedUnsupportedReasoningEfforts(provider, modelId, healMappedTiers(provider, modelId, fromMetadata));
|
|
185
190
|
}
|
|
186
191
|
return undefined;
|
package/src/remote/hub-usage.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { USAGE_SOURCE_CLIENTS } from "../usage/source-filter";
|
|
2
3
|
|
|
3
4
|
export const MAX_HUB_USAGE_BYTES = 1024 * 1024;
|
|
4
5
|
const count = z.number().finite().nonnegative();
|
|
@@ -20,6 +21,8 @@ const hubUsageSchema = z.object({
|
|
|
20
21
|
days: z.array(z.object({ date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/), ...costs })).max(366),
|
|
21
22
|
filter: z.object({ provider: label.nullable(), model: label.nullable(),
|
|
22
23
|
matched: z.boolean(), comboOverlap: z.boolean() }),
|
|
24
|
+
sourceFilter: z.object({ client: z.enum(USAGE_SOURCE_CLIENTS), scope: z.literal("authenticated-key") }).optional(),
|
|
25
|
+
legacyUnclassifiedRequests: count.optional(),
|
|
23
26
|
usageIncomplete: z.literal(true).optional(),
|
|
24
27
|
usageIncompleteReason: z.literal("oversized_rows").optional(),
|
|
25
28
|
});
|
|
@@ -206,7 +206,7 @@ export function admissionModelDeniedResponse(error: AdmissionModelDeniedError):
|
|
|
206
206
|
headers: { "Content-Type": "application/json" },
|
|
207
207
|
});
|
|
208
208
|
markResponseNonReplayable(response);
|
|
209
|
-
return markProxyError(response);
|
|
209
|
+
return markProxyError(response, "scope");
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { normalizeMessagesProxyRefusal } from "../lib/messages-error-body";
|
|
1
2
|
import { withCors, type RequestPolicyView } from "./auth-cors";
|
|
2
3
|
import { runAdmittedBodyWork } from "./inbound-body-admission";
|
|
3
4
|
import { tryAdmitTurn, type ActiveTurnLease } from "./lifecycle";
|
|
@@ -32,7 +33,7 @@ export function createAdmittedHttpTurn(
|
|
|
32
33
|
catch (error) { lease.release(); throw error; }
|
|
33
34
|
if (workflow && !workflow.admitted) {
|
|
34
35
|
lease.release();
|
|
35
|
-
return withCors(map(workflowDecisionRefusalResponse(workflow, undefined, refusalLog)), req, policy);
|
|
36
|
+
return withCors(await normalizeMessagesProxyRefusal(req, map(workflowDecisionRefusalResponse(workflow, undefined, refusalLog))), req, policy);
|
|
36
37
|
}
|
|
37
38
|
if (workflow?.admitted) lease.attach(workflow.lease);
|
|
38
39
|
try {
|
|
@@ -1,7 +1,79 @@
|
|
|
1
|
+
type Normalize = (value: string) => string | undefined;
|
|
2
|
+
const MAX_EPOCH = 253402300799;
|
|
3
|
+
const STATUS: ReadonlyMap<string, string> = new Map([["allowed", "allowed"], ["rejected", "rejected"]]);
|
|
4
|
+
const count: Normalize = value => {
|
|
5
|
+
if (!/^[0-9]{1,16}$/.test(value)) return undefined;
|
|
6
|
+
const n = Number(value);
|
|
7
|
+
return n <= 1e12 ? String(n) : undefined;
|
|
8
|
+
};
|
|
9
|
+
/** Decimal arithmetic keeps half-up rounding independent of binary floating point. */
|
|
10
|
+
function decimal(value: string, grammar: RegExp, max: bigint, digits: number): string | undefined {
|
|
11
|
+
if (!grammar.test(value)) return undefined;
|
|
12
|
+
const [whole = "0", fraction = ""] = value.split(".");
|
|
13
|
+
const scale = 10n ** BigInt(fraction.length);
|
|
14
|
+
const exact = BigInt(whole) * scale + BigInt(fraction || "0");
|
|
15
|
+
if (exact > max * scale) return undefined;
|
|
16
|
+
const outputScale = 10n ** BigInt(digits);
|
|
17
|
+
const rounded = (exact * outputScale * 2n + scale) / (scale * 2n);
|
|
18
|
+
const bounded = rounded > max * outputScale ? max * outputScale : rounded;
|
|
19
|
+
const tail = String(bounded % outputScale).padStart(digits, "0").replace(/0+$/, "");
|
|
20
|
+
return `${bounded / outputScale}${tail ? `.${tail}` : ""}`;
|
|
21
|
+
}
|
|
22
|
+
const epoch: Normalize = value => decimal(value, /^[0-9]{1,12}(\.[0-9]{1,6})?$/, BigInt(MAX_EPOCH), 3);
|
|
23
|
+
const utilization: Normalize = value => decimal(value, /^[0-9]{1,6}(\.[0-9]{1,12})?$/, 100n, 4);
|
|
24
|
+
const date: Normalize = value => {
|
|
25
|
+
const match = /^(\d{4})-(\d{2})-(\d{2})[Tt](\d{2}):(\d{2}):(\d{2})(?:\.([0-9]{1,9}))?([Zz]|[+-]\d{2}:\d{2})$/.exec(value);
|
|
26
|
+
if (!match) return undefined;
|
|
27
|
+
const [year, month, day, hour, minute, second] = match.slice(1, 7).map(Number) as [number, number, number, number, number, number];
|
|
28
|
+
const zone = match[8]!;
|
|
29
|
+
const zoneHour = zone.length === 1 ? 0 : Number(zone.slice(1, 3));
|
|
30
|
+
const zoneMinute = zone.length === 1 ? 0 : Number(zone.slice(4, 6));
|
|
31
|
+
if (year < 1970 || month < 1 || month > 12 || day < 1 || hour > 23 || minute > 59 || second > 59
|
|
32
|
+
|| zoneHour > 23 || zoneMinute > 59 || zone === "-00:00") return undefined;
|
|
33
|
+
const monthDays = (y: number, m: number): number => m === 2
|
|
34
|
+
? (y % 4 === 0 && (y % 100 !== 0 || y % 400 === 0) ? 29 : 28)
|
|
35
|
+
: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][m - 1]!;
|
|
36
|
+
if (day > monthDays(year, month)) return undefined;
|
|
37
|
+
let utcYear = year, utcMonth = month, utcDay = day;
|
|
38
|
+
const offset = (zoneHour * 60 + zoneMinute) * 60 * (zone[0] === "-" ? -1 : 1);
|
|
39
|
+
let utcSecond = hour * 3600 + minute * 60 + second - offset;
|
|
40
|
+
if (utcSecond < 0) {
|
|
41
|
+
utcSecond += 86400;
|
|
42
|
+
if (--utcDay === 0) {
|
|
43
|
+
if (--utcMonth === 0) { utcMonth = 12; utcYear--; }
|
|
44
|
+
utcDay = monthDays(utcYear, utcMonth);
|
|
45
|
+
}
|
|
46
|
+
} else if (utcSecond >= 86400) {
|
|
47
|
+
utcSecond -= 86400;
|
|
48
|
+
if (++utcDay > monthDays(utcYear, utcMonth)) {
|
|
49
|
+
utcDay = 1;
|
|
50
|
+
if (++utcMonth === 13) { utcMonth = 1; utcYear++; }
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (utcYear < 1970 || utcYear > 9999) return undefined;
|
|
54
|
+
const pad = (n: number, digits = 2): string => n.toString().padStart(digits, "0");
|
|
55
|
+
const fraction = (match[7] ?? "").replace(/0+$/, "");
|
|
56
|
+
return `${pad(utcYear, 4)}-${pad(utcMonth)}-${pad(utcDay)}T${pad(Math.floor(utcSecond / 3600))}:${pad(Math.floor(utcSecond / 60) % 60)}:${pad(utcSecond % 60)}${fraction ? `.${fraction}` : ""}Z`;
|
|
57
|
+
};
|
|
58
|
+
const EXACT: ReadonlyMap<string, Normalize> = new Map([
|
|
59
|
+
...["requests", "tokens", "input-tokens", "output-tokens"].flatMap(family => [
|
|
60
|
+
[`anthropic-ratelimit-${family}-limit`, count],
|
|
61
|
+
[`anthropic-ratelimit-${family}-remaining`, count],
|
|
62
|
+
[`anthropic-ratelimit-${family}-reset`, date],
|
|
63
|
+
] as [string, Normalize][]),
|
|
64
|
+
...["", "-5h", "-7d", "-7d_oi"].flatMap(window => [
|
|
65
|
+
[`anthropic-ratelimit-unified${window}-status`, value => STATUS.get(value)],
|
|
66
|
+
[`anthropic-ratelimit-unified${window}-reset`, epoch],
|
|
67
|
+
...(window ? [[`anthropic-ratelimit-unified${window}-utilization`, utilization] as [string, Normalize]] : []),
|
|
68
|
+
] as [string, Normalize][]),
|
|
69
|
+
]);
|
|
1
70
|
export function anthropicRateLimitHeaders(upstream: Headers): Record<string, string> {
|
|
2
71
|
const headers: Record<string, string> = {};
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
72
|
+
for (const [name, normalize] of EXACT) {
|
|
73
|
+
const input = upstream.get(name);
|
|
74
|
+
if (input === null || input.length > 128) continue;
|
|
75
|
+
const value = normalize(input.replace(/^[ \t]+|[ \t]+$/g, ""));
|
|
76
|
+
if (value !== undefined) headers[name] = value;
|
|
77
|
+
}
|
|
6
78
|
return headers;
|
|
7
79
|
}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { MessagesSseFrameContext } from "../lib/messages-sse-error-presentation";
|
|
2
|
+
import { createMessagesSseErrorFilter } from "./messages-sse-error-filter";
|
|
3
|
+
import { normalizeMessagesProxyRefusal, ownedAnthropicErrorPayload, ownedAnthropicErrorResponse, boundedMessagesDisplayCount, messagesOverflowPresentation, messagesRelayedOverflowPresentation } from "../lib/messages-error-body";
|
|
4
|
+
import { CLAUDE_CONTEXT_OVERFLOW_MESSAGE, isProxyError, markProxyError, carryProxyError, attachComboFailureEvidence, comboFailureEvidence } from "../lib/client-error-body";
|
|
5
|
+
import type { MessagesFailureVerdictSink } from "../claude/failure-verdict";
|
|
1
6
|
import { clientFacingModelLabel, clientFacingModelText } from "../lib/error-destination";
|
|
2
7
|
import { classifyUpstreamCondition } from "../lib/upstream-condition";
|
|
3
8
|
import { CodexInstallationIdUnavailableError } from "../codex/installation-id";
|
|
@@ -40,7 +45,7 @@ import { stripOneMillionMarker } from "../claude/context-windows";
|
|
|
40
45
|
import { captureAdmissionPolicy } from "./capture-admission-policy";
|
|
41
46
|
import type { CapturedAdmissionPolicy } from "../types/admission-policy";
|
|
42
47
|
import { captureClaudeInbound } from "../claude/inbound-debug";
|
|
43
|
-
import { declaredAnthropicServerTools, replayedAnthropicServerBlocks } from "../claude/inbound-content-options";
|
|
48
|
+
import { declaredAnthropicServerTools, replayedAnthropicServerBlocks, systemCachePrefix } from "../claude/inbound-content-options";
|
|
44
49
|
import { claudeCodeForIngress } from "../claude/intercept/model-bindings";
|
|
45
50
|
import { classifyInterceptClient } from "../claude/intercept/client-class";
|
|
46
51
|
import { analyzeClaudeCompatibility, isClaudeCompatibilityMode } from "../claude/compatibility";
|
|
@@ -56,12 +61,13 @@ import {
|
|
|
56
61
|
import { isClientClosedMessage, recognizedUpstreamError, UNDECLARED_TOOL_CALL_ERROR_CODE } from "../lib/errors";
|
|
57
62
|
import { formatClientRetryAfter, resolveClientRetryAfter } from "../lib/retry-after";
|
|
58
63
|
import { anthropicRateLimitHeaders } from "./anthropic-rate-limit-headers";
|
|
59
|
-
import { upstreamMessagesRequestIdHeaders } from "./messages-response-headers";
|
|
64
|
+
import { messagesSuccessContentType, upstreamMessagesRequestIdHeaders } from "./messages-response-headers";
|
|
60
65
|
import {
|
|
61
66
|
anthropicErrorBody,
|
|
62
67
|
anthropicErrorResponse,
|
|
63
68
|
collectAnthropicMessage,
|
|
64
69
|
isContextOverflowError,
|
|
70
|
+
isThroughputLimitText,
|
|
65
71
|
responsesJsonToAnthropicMessage,
|
|
66
72
|
responsesSseToAnthropicSse,
|
|
67
73
|
} from "../claude/outbound";
|
|
@@ -216,7 +222,7 @@ async function readAnthropicBody(req: Request, budget: TranslatorBudget, maxByte
|
|
|
216
222
|
return await readJsonRequestBody(req, budget, maxBytes);
|
|
217
223
|
} catch (err) {
|
|
218
224
|
if (isTranslatorBudgetExceededError(err)) throw err;
|
|
219
|
-
throw new AnthropicRequestError(err instanceof Error && err.message ?
|
|
225
|
+
throw markProxyError(new AnthropicRequestError(err instanceof Error && messagesOverflowPresentation(err.message) ? CLAUDE_CONTEXT_OVERFLOW_MESSAGE : "Invalid JSON body"));
|
|
220
226
|
}
|
|
221
227
|
}
|
|
222
228
|
|
|
@@ -341,11 +347,13 @@ async function anthropicNativePassthrough(
|
|
|
341
347
|
// Locally generated diagnostics are fixed text plus validated guard limits. Runtime
|
|
342
348
|
// fetch errors retain their existing client response but use a fixed stored reason.
|
|
343
349
|
const fail = (status: number, closeReason: PassthroughCloseReason | "non_stream", message: string, type: string,
|
|
344
|
-
detail: FailureDetail, storedReason = message) => {
|
|
350
|
+
detail: FailureDetail, storedReason = message, originalMessage = message) => {
|
|
345
351
|
const safeMessage = redactSecretString(message);
|
|
346
352
|
recordLocalFailureDetail(logCtx, storedReason, detail);
|
|
347
353
|
finalize(status, { closeReason });
|
|
348
|
-
|
|
354
|
+
const legacy = anthropicErrorBody(status, redactSecretString(originalMessage), type);
|
|
355
|
+
return markProxyError(ownedAnthropicErrorResponse({ status, type, evidence: { status }, localError: markProxyError({ message: safeMessage }),
|
|
356
|
+
overflow: messagesRelayedOverflowPresentation("", legacy) }, legacy), closeReason === "body_stall" ? "body_stall" : closeReason === "body_overflow" ? "body_overflow" : undefined);
|
|
349
357
|
};
|
|
350
358
|
|
|
351
359
|
const base = (config.claudeCode?.anthropicBaseUrl ?? "https://api.anthropic.com").replace(/\/$/, "");
|
|
@@ -378,8 +386,8 @@ async function anthropicNativePassthrough(
|
|
|
378
386
|
return fail(504, "non_stream", "anthropic passthrough timed out waiting for response headers", "timeout_error", { code: "header_timeout" });
|
|
379
387
|
}
|
|
380
388
|
if (result.kind === "error") {
|
|
381
|
-
const
|
|
382
|
-
return fail(502, "non_stream",
|
|
389
|
+
const originalMessage = result.error instanceof Error ? result.error.message : String(result.error);
|
|
390
|
+
return fail(502, "non_stream", "anthropic passthrough failed: upstream connection error", "api_error", { code: "connect_failed" }, "anthropic passthrough failed: upstream connection error", `anthropic passthrough failed: ${originalMessage}`);
|
|
383
391
|
}
|
|
384
392
|
const upstream = result.upstream;
|
|
385
393
|
|
|
@@ -390,11 +398,12 @@ async function anthropicNativePassthrough(
|
|
|
390
398
|
};
|
|
391
399
|
const bodyGuard = resolvePassthroughBodyGuard(config, req.signal);
|
|
392
400
|
if (upstream.ok && contentType.includes("text/event-stream") && upstream.body) {
|
|
393
|
-
|
|
401
|
+
const frames = new MessagesSseFrameContext();
|
|
402
|
+
return new Response(tapAnthropicSseForLog(upstream.body, logCtx, finalize, bodyGuard, frames, createMessagesSseErrorFilter(frames)), {
|
|
394
403
|
status: upstream.status,
|
|
395
404
|
headers: {
|
|
396
405
|
...rateLimitHeaders,
|
|
397
|
-
"Content-Type":
|
|
406
|
+
"Content-Type": "text/event-stream",
|
|
398
407
|
"Cache-Control": "no-cache",
|
|
399
408
|
"Connection": "keep-alive",
|
|
400
409
|
},
|
|
@@ -407,11 +416,11 @@ async function anthropicNativePassthrough(
|
|
|
407
416
|
return fail(499, "client_cancel", "client closed request during anthropic passthrough", "api_error", { code: "client_closed" });
|
|
408
417
|
}
|
|
409
418
|
if (bodyResult.kind === "stall") {
|
|
410
|
-
return fail(504, "body_stall", `anthropic passthrough body stalled: no upstream bytes for ${Math.round(bodyGuard.stallMs / 1000)}s
|
|
419
|
+
return fail(504, "body_stall", boundedMessagesDisplayCount(Math.round(bodyGuard.stallMs / 1000)) !== undefined ? `anthropic passthrough body stalled: no upstream bytes for ${boundedMessagesDisplayCount(Math.round(bodyGuard.stallMs / 1000))}s` : "anthropic passthrough body stalled", "timeout_error",
|
|
411
420
|
{ code: "body_stall", value: bodyGuard.stallMs });
|
|
412
421
|
}
|
|
413
422
|
if (bodyResult.kind === "overflow") {
|
|
414
|
-
return fail(502, "body_overflow", `anthropic passthrough body exceeded ${bodyGuard.maxBytes} bytes
|
|
423
|
+
return fail(502, "body_overflow", boundedMessagesDisplayCount(bodyGuard.maxBytes) !== undefined ? `anthropic passthrough body exceeded ${boundedMessagesDisplayCount(bodyGuard.maxBytes)} bytes` : "anthropic passthrough body exceeded the safe limit", "api_error",
|
|
415
424
|
{ code: "body_overflow", value: bodyGuard.maxBytes });
|
|
416
425
|
}
|
|
417
426
|
const text = bodyResult.text;
|
|
@@ -443,10 +452,29 @@ async function anthropicNativePassthrough(
|
|
|
443
452
|
}
|
|
444
453
|
finalize(upstream.status, { closeReason: "non_stream" });
|
|
445
454
|
const retryAfter = formatClientRetryAfter(upstream.headers.get("retry-after"));
|
|
446
|
-
return new Response(text, {
|
|
455
|
+
if (upstream.ok) return new Response(text, {
|
|
447
456
|
status: upstream.status,
|
|
448
|
-
headers: { ...rateLimitHeaders, "Content-Type":
|
|
457
|
+
headers: { ...rateLimitHeaders, "Content-Type": messagesSuccessContentType(upstream.headers), ...(retryAfter ? { "Retry-After": retryAfter } : {}) },
|
|
449
458
|
});
|
|
459
|
+
let parsed: unknown;
|
|
460
|
+
try { parsed = JSON.parse(text); } catch { /* non-JSON errors keep original recognition evidence */ }
|
|
461
|
+
const error = isRec(parsed) && isRec(parsed.error) ? parsed.error : isRec(parsed) ? parsed : {};
|
|
462
|
+
const isError = !upstream.ok;
|
|
463
|
+
const originalMessage = typeof error.message === "string" ? error.message : "";
|
|
464
|
+
const throughput = isThroughputLimitText(originalMessage);
|
|
465
|
+
const overflow = messagesRelayedOverflowPresentation(text, parsed);
|
|
466
|
+
const clientBody = isError ? JSON.stringify(ownedAnthropicErrorPayload({ status: upstream.status,
|
|
467
|
+
overflow, ...(throughput ? { condition: "rate_limited" as const } : {}),
|
|
468
|
+
type: typeof error.type === "string" ? error.type : undefined,
|
|
469
|
+
code: typeof error.code === "string" ? error.code : undefined,
|
|
470
|
+
evidence: { status: upstream.status, type: typeof error.type === "string" ? error.type : undefined,
|
|
471
|
+
code: typeof error.code === "string" ? error.code : undefined, message: typeof error.message === "string" ? error.message : undefined },
|
|
472
|
+
})) : text;
|
|
473
|
+
const out = new Response(clientBody, {
|
|
474
|
+
status: upstream.status,
|
|
475
|
+
headers: { ...rateLimitHeaders, "Content-Type": isError ? "application/json" : messagesSuccessContentType(upstream.headers), ...(retryAfter ? { "Retry-After": retryAfter } : {}) },
|
|
476
|
+
});
|
|
477
|
+
return isError ? attachComboFailureEvidence(out, text) : out;
|
|
450
478
|
}
|
|
451
479
|
|
|
452
480
|
type BoundedPassthroughBody =
|
|
@@ -568,11 +596,10 @@ export async function handleClaudeMessages(
|
|
|
568
596
|
): Promise<Response> {
|
|
569
597
|
const translatorBudget = createTranslatorBudget();
|
|
570
598
|
try {
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
);
|
|
599
|
+
const response = await handleClaudeMessagesWithBudget(req, config, logCtx, translatorBudget, logIds, requestPolicy, ingress);
|
|
600
|
+
const finalized = carryProxyError(response, finalizeTranslatorBudgetResponse(response, translatorBudget, req.signal));
|
|
601
|
+
const evidence = comboFailureEvidence(response);
|
|
602
|
+
return normalizeMessagesProxyRefusal(req, evidence === undefined ? finalized : attachComboFailureEvidence(finalized, evidence));
|
|
576
603
|
} catch (error) {
|
|
577
604
|
translatorBudget.dispose();
|
|
578
605
|
throw error;
|
|
@@ -586,12 +613,14 @@ function translationFailure(err: unknown, logCtx: RequestLogContext, logIds: { r
|
|
|
586
613
|
const status = overflow ? 413 : unavailable ? 503 : err instanceof AnthropicRequestError ? 400 : 500;
|
|
587
614
|
if (logIds) addFinalRequestLog(logIds.requestId, logIds.start, logCtx, status, { closeReason: "non_stream" });
|
|
588
615
|
if (unavailable) return desktopMappingUnavailableResponse(err);
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
);
|
|
616
|
+
const originalMessage = err instanceof Error ? err.message : String(err);
|
|
617
|
+
const clientMessage = overflow ? "request translation buffer exceeded the safe limit"
|
|
618
|
+
: err instanceof Error && isProxyError(err) ? err.message : "The proxy could not translate the Messages request.";
|
|
619
|
+
const code = overflow ? "translation_buffer_limit" : undefined;
|
|
620
|
+
const type = overflow ? "request_too_large" : undefined;
|
|
621
|
+
const legacy = anthropicErrorBody(status, overflow ? clientMessage : originalMessage, type, code);
|
|
622
|
+
return ownedAnthropicErrorResponse({ status, type, code, evidence: { status, message: originalMessage },
|
|
623
|
+
localError: markProxyError({ message: clientMessage }), overflow: messagesRelayedOverflowPresentation("", legacy) }, legacy);
|
|
595
624
|
}
|
|
596
625
|
|
|
597
626
|
/**
|
|
@@ -957,12 +986,16 @@ async function handleClaudeMessagesWithBudget(
|
|
|
957
986
|
if (err instanceof UnknownRoutingPolicyError) {
|
|
958
987
|
logCtx.requestedModel = requestedModel;
|
|
959
988
|
if (logIds) addFinalRequestLog(logIds.requestId, logIds.start, logCtx, 404, { closeReason: "non_stream" });
|
|
960
|
-
|
|
989
|
+
const legacy = anthropicErrorBody(404, err.message, "invalid_request_error");
|
|
990
|
+
return ownedAnthropicErrorResponse({ status: 404, type: "invalid_request_error", evidence: { status: 404 },
|
|
991
|
+
localError: markProxyError({ message: "Unknown routing policy" }), overflow: messagesRelayedOverflowPresentation("", legacy) }, legacy);
|
|
961
992
|
}
|
|
962
993
|
if (err instanceof NoEligiblePolicyCandidateError) {
|
|
963
994
|
logCtx.routeDecision = err.trace;
|
|
964
995
|
if (logIds) addFinalRequestLog(logIds.requestId, logIds.start, logCtx, 404, { closeReason: "non_stream" });
|
|
965
|
-
|
|
996
|
+
const legacy = anthropicErrorBody(404, err.message, "invalid_request_error");
|
|
997
|
+
return ownedAnthropicErrorResponse({ status: 404, type: "invalid_request_error", evidence: { status: 404 },
|
|
998
|
+
localError: markProxyError({ message: "No eligible candidates for policy profile" }), overflow: messagesRelayedOverflowPresentation("", legacy) }, legacy);
|
|
966
999
|
}
|
|
967
1000
|
/* unknown model: let handleResponses shape the 404 */
|
|
968
1001
|
}
|
|
@@ -1073,7 +1106,7 @@ async function handleClaudeMessagesWithBudget(
|
|
|
1073
1106
|
const nativeMessagesRoute = settledRoute && nativeDecline === undefined ? settledRoute : undefined;
|
|
1074
1107
|
if (nativeProjectionOnlyError && !nativeMessagesRoute) {
|
|
1075
1108
|
if (logIds) addFinalRequestLog(logIds.requestId, logIds.start, logCtx, 400, { closeReason: "non_stream" });
|
|
1076
|
-
return anthropicErrorResponse(400, nativeProjectionOnlyError.message, "invalid_request_error");
|
|
1109
|
+
return anthropicErrorResponse(400, isProxyError(nativeProjectionOnlyError) ? nativeProjectionOnlyError.message : "The proxy could not translate the Messages request.", "invalid_request_error");
|
|
1077
1110
|
}
|
|
1078
1111
|
// With the switch on, a declined route says why on its bridge mark, as native Chat does.
|
|
1079
1112
|
const antigravityDecline = settledRoute && !nativeMessagesRoute && !directRoute
|
|
@@ -1253,6 +1286,7 @@ async function handleClaudeMessagesWithBudget(
|
|
|
1253
1286
|
// Out of body like the replay above: the core hands these to an Anthropic destination only.
|
|
1254
1287
|
anthropicServerTools: declaredAnthropicServerTools(anthropicBody),
|
|
1255
1288
|
anthropicServerReplay: replayedAnthropicServerBlocks(anthropicBody),
|
|
1289
|
+
anthropicSystemCachePrefix: isRec(anthropicBody) ? systemCachePrefix(anthropicBody.system) : undefined,
|
|
1256
1290
|
// Preserve the original catalog through late fallback; only the physical adapter projects it.
|
|
1257
1291
|
anthropicToolLoadingSource: cacheKeySource === "metadata" && isRec(anthropicBody)
|
|
1258
1292
|
&& Array.isArray(cc?.appendOnlyToolLoadingModels) && cc.appendOnlyToolLoadingModels.length > 0
|
|
@@ -1287,6 +1321,8 @@ async function handleClaudeMessagesWithBudget(
|
|
|
1287
1321
|
let message = `upstream error (${response.status})`;
|
|
1288
1322
|
let contextError = false;
|
|
1289
1323
|
let catalogRefusal = false;
|
|
1324
|
+
let originalType: string | undefined;
|
|
1325
|
+
let originalCode: string | undefined;
|
|
1290
1326
|
try {
|
|
1291
1327
|
const text = await response.text();
|
|
1292
1328
|
try {
|
|
@@ -1296,12 +1332,19 @@ async function handleClaudeMessagesWithBudget(
|
|
|
1296
1332
|
const flat = typeof parsed?.error === "string" ? parsed.error : parsed?.message;
|
|
1297
1333
|
message = nested || flat || (text ? `upstream error (${response.status}): ${text.slice(0, 400)}` : message);
|
|
1298
1334
|
const errorObject = typeof parsed?.error === "object" && parsed.error ? parsed.error : {};
|
|
1335
|
+
originalType = typeof errorObject.type === "string" ? errorObject.type : undefined;
|
|
1336
|
+
originalCode = typeof errorObject.code === "string" ? errorObject.code : undefined;
|
|
1299
1337
|
// An uncoded overflow counts too (#8127); a rate-limit or credential status never does.
|
|
1300
1338
|
contextError = errorObject.code === "context_length_exceeded"
|
|
1301
1339
|
|| (![401, 403, 429].includes(response.status) && Boolean(nested || flat)
|
|
1302
1340
|
&& isContextOverflowError(errorObject, message));
|
|
1303
1341
|
} catch {
|
|
1304
|
-
|
|
1342
|
+
// A plain-text gateway body carries the same verdict with no envelope to read a code from.
|
|
1343
|
+
const inspected = text.trim().slice(0, 16_384);
|
|
1344
|
+
const plain = inspected.slice(0, 400);
|
|
1345
|
+
contextError = Boolean(inspected) && ![401, 402, 403, 429].includes(response.status)
|
|
1346
|
+
&& isContextOverflowError({}, inspected);
|
|
1347
|
+
if (text) message = contextError ? plain : `upstream error (${response.status}): ${text.slice(0, 400)}`;
|
|
1305
1348
|
}
|
|
1306
1349
|
} catch { /* keep fallback message */ }
|
|
1307
1350
|
const upstreamRetryAfter = response.headers.get("retry-after");
|
|
@@ -1337,27 +1380,31 @@ async function handleClaudeMessagesWithBudget(
|
|
|
1337
1380
|
if (clientRetryAfter) outHeaders.set("Retry-After", clientRetryAfter);
|
|
1338
1381
|
else if (transient) outHeaders.set("Retry-After", "2");
|
|
1339
1382
|
if (replayRefusal) applyReplayRefusalClientHeaders(outHeaders);
|
|
1340
|
-
const
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1383
|
+
const decidedCode = replayRefusal ? UPSTREAM_RESET_REPLAY_REFUSED_CODE : contextError ? "context_length_exceeded" : catalogRefusal ? UNDECLARED_TOOL_CALL_ERROR_CODE : undefined;
|
|
1384
|
+
const legacy = anthropicErrorBody(outStatus, message, undefined, decidedCode);
|
|
1385
|
+
const legacyBody = JSON.stringify(legacy);
|
|
1386
|
+
const out = new Response(JSON.stringify(ownedAnthropicErrorPayload({
|
|
1387
|
+
status: outStatus,
|
|
1388
|
+
evidence: { status: response.status, type: originalType, code: originalCode, message },
|
|
1389
|
+
code: decidedCode,
|
|
1390
|
+
overflow: messagesOverflowPresentation((legacy.error as Rec).message),
|
|
1391
|
+
...(contextError && isThroughputLimitText(message) ? { condition: "rate_limited" as const } : {}),
|
|
1392
|
+
...(replayRefusal ? { contract: "replay_refused" as const } : {}),
|
|
1393
|
+
...(isProxyError(response) ? { localError: carryProxyError(response, { message }) } : {}),
|
|
1394
|
+
})), {
|
|
1350
1395
|
status: outStatus,
|
|
1351
1396
|
headers: outHeaders,
|
|
1352
1397
|
});
|
|
1353
|
-
return carryReplayRefusal(response, out);
|
|
1398
|
+
return attachComboFailureEvidence(carryProxyError(response, carryReplayRefusal(response, out)), legacyBody);
|
|
1354
1399
|
}
|
|
1355
1400
|
|
|
1356
1401
|
const contentType = response.headers.get("content-type") ?? "";
|
|
1357
1402
|
if (contentType.includes("text/event-stream") && response.body) {
|
|
1403
|
+
const failureVerdictSink: MessagesFailureVerdictSink = {};
|
|
1358
1404
|
const anthropicSse = responsesSseToAnthropicSse(response.body, clientFacingModelText(clientModelLabel), {
|
|
1359
1405
|
translatorBudget,
|
|
1360
1406
|
nativeReasoningTagFor: blob => nativeReasoningTag(nativeReasoningMint.owner, blob),
|
|
1407
|
+
failureVerdictSink: stream ? undefined : failureVerdictSink, proxyErrorContext: logCtx,
|
|
1361
1408
|
// Only a floor, and only for the first frame: an upstream that reports usage early wins
|
|
1362
1409
|
// over it inside the translator, and the terminal `message_delta` carries the
|
|
1363
1410
|
// authoritative count either way (#4857).
|
|
@@ -1375,26 +1422,28 @@ async function handleClaudeMessagesWithBudget(
|
|
|
1375
1422
|
}
|
|
1376
1423
|
let message: Rec;
|
|
1377
1424
|
try {
|
|
1378
|
-
message = await collectAnthropicMessage(anthropicSse, clientFacingModelText(clientModelLabel), translatorBudget);
|
|
1425
|
+
message = await collectAnthropicMessage(anthropicSse, clientFacingModelText(clientModelLabel), translatorBudget, failureVerdictSink);
|
|
1379
1426
|
} catch (error) {
|
|
1380
1427
|
if (isTranslatorBudgetExceededError(error)) {
|
|
1381
|
-
|
|
1428
|
+
const legacy = anthropicErrorBody(413, error.message, "request_too_large", "translation_buffer_limit");
|
|
1429
|
+
return ownedAnthropicErrorResponse({ status: 413, type: "request_too_large", code: "translation_buffer_limit",
|
|
1430
|
+
evidence: { status: 413, message: error.message }, overflow: messagesRelayedOverflowPresentation("", legacy) }, legacy);
|
|
1382
1431
|
}
|
|
1383
|
-
|
|
1432
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1433
|
+
const legacy = anthropicErrorBody(502, message, "api_error");
|
|
1434
|
+
return ownedAnthropicErrorResponse({ status: 502, type: "api_error", evidence: { status: 502, message },
|
|
1435
|
+
contract: "transport_failed", overflow: messagesRelayedOverflowPresentation("", legacy) }, legacy);
|
|
1384
1436
|
}
|
|
1385
|
-
const
|
|
1386
|
-
const
|
|
1387
|
-
|
|
1437
|
+
const legacy = failureVerdictSink.collected ?? message;
|
|
1438
|
+
const isError = legacy.type === "error";
|
|
1439
|
+
const translatedError = isError && typeof legacy.error === "object"
|
|
1440
|
+
? (legacy as { error: { code?: unknown; message?: unknown } }).error
|
|
1388
1441
|
: undefined;
|
|
1389
1442
|
if (translatedError?.code === "translation_buffer_limit") {
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
: "upstream translation buffer exceeded the safe limit",
|
|
1395
|
-
"request_too_large",
|
|
1396
|
-
"translation_buffer_limit",
|
|
1397
|
-
);
|
|
1443
|
+
const originalMessage = typeof translatedError.message === "string" ? translatedError.message : "upstream translation buffer exceeded the safe limit";
|
|
1444
|
+
const legacy = anthropicErrorBody(413, originalMessage, "request_too_large", "translation_buffer_limit");
|
|
1445
|
+
return ownedAnthropicErrorResponse({ status: 413, type: "request_too_large", code: "translation_buffer_limit",
|
|
1446
|
+
evidence: { status: 413, message: originalMessage }, overflow: messagesRelayedOverflowPresentation("", legacy) }, legacy);
|
|
1398
1447
|
}
|
|
1399
1448
|
// A declared client refusal keeps its 4xx: as a 502 Claude Code retries a verdict that cannot
|
|
1400
1449
|
// change. Server classes and rate limits keep the 502 this path has always answered. A 400
|
|
@@ -1420,19 +1469,26 @@ async function handleClaudeMessagesWithBudget(
|
|
|
1420
1469
|
}
|
|
1421
1470
|
const status = (json as Rec)?.status;
|
|
1422
1471
|
if (status === "failed") {
|
|
1423
|
-
const error = (json as { error?: { message?: string; code?: string } }).error;
|
|
1472
|
+
const error = (json as { error?: { message?: string; type?: string; code?: string } }).error;
|
|
1424
1473
|
if (error?.code === "translation_buffer_limit") {
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
"
|
|
1429
|
-
"translation_buffer_limit",
|
|
1430
|
-
);
|
|
1474
|
+
const originalMessage = error.message ?? "upstream translation buffer exceeded the safe limit";
|
|
1475
|
+
const legacy = anthropicErrorBody(413, originalMessage, "request_too_large", "translation_buffer_limit");
|
|
1476
|
+
return ownedAnthropicErrorResponse({ status: 413, type: "request_too_large", code: "translation_buffer_limit",
|
|
1477
|
+
evidence: { status: 413, message: originalMessage }, overflow: messagesRelayedOverflowPresentation("", legacy) }, legacy);
|
|
1431
1478
|
}
|
|
1432
|
-
|
|
1433
|
-
|
|
1479
|
+
const originalMessage = typeof error?.message === "string" ? error.message : "";
|
|
1480
|
+
if (error && isContextOverflowError(error, originalMessage)) {
|
|
1481
|
+
const throughput = isThroughputLimitText(originalMessage);
|
|
1482
|
+
const legacy = anthropicErrorBody(400, originalMessage, "invalid_request_error", "context_length_exceeded");
|
|
1483
|
+
return Response.json(ownedAnthropicErrorPayload({
|
|
1484
|
+
status: 400, type: "invalid_request_error", code: "context_length_exceeded", overflow: messagesOverflowPresentation((legacy.error as Rec).message),
|
|
1485
|
+
...(throughput ? { condition: "rate_limited" as const } : {}), evidence: { status: 400, message: originalMessage },
|
|
1486
|
+
}), { status: 400 });
|
|
1434
1487
|
}
|
|
1435
|
-
|
|
1488
|
+
const legacy = anthropicErrorBody(502, originalMessage, "api_error");
|
|
1489
|
+
return Response.json(ownedAnthropicErrorPayload({ status: 502, type: "api_error",
|
|
1490
|
+
overflow: messagesOverflowPresentation((legacy.error as Rec).message),
|
|
1491
|
+
evidence: { status: 502, message: error?.message, type: error?.type, code: error?.code } }), { status: 502 });
|
|
1436
1492
|
}
|
|
1437
1493
|
let message: Rec;
|
|
1438
1494
|
try {
|
|
@@ -1547,7 +1603,10 @@ function thinkingProjectionForPreview(config: OcxConfig, modelId: string): Claud
|
|
|
1547
1603
|
}
|
|
1548
1604
|
}
|
|
1549
1605
|
|
|
1550
|
-
export async function handleClaudeCountTokens(
|
|
1606
|
+
export async function handleClaudeCountTokens(...args: Parameters<typeof handleClaudeCountTokensInner>): Promise<Response> {
|
|
1607
|
+
return normalizeMessagesProxyRefusal(args[0], await handleClaudeCountTokensInner(...args));
|
|
1608
|
+
}
|
|
1609
|
+
async function handleClaudeCountTokensInner(
|
|
1551
1610
|
req: Request,
|
|
1552
1611
|
config: OcxConfig,
|
|
1553
1612
|
requestPolicy: RequestPolicyView = config,
|
|
@@ -1563,8 +1622,12 @@ export async function handleClaudeCountTokens(
|
|
|
1563
1622
|
body = await readAnthropicBody(req, translatorBudget, resolveInboundBodyLimitBytes(config.maxInboundBodyBytes));
|
|
1564
1623
|
} catch (err) {
|
|
1565
1624
|
if (err instanceof DesktopModelMappingUnavailableError) return desktopMappingUnavailableResponse(err);
|
|
1566
|
-
if (err instanceof AnthropicRequestError) return anthropicErrorResponse(400, err.message);
|
|
1567
|
-
|
|
1625
|
+
if (err instanceof AnthropicRequestError) return anthropicErrorResponse(400, isProxyError(err) ? err.message : "Invalid JSON body");
|
|
1626
|
+
const originalMessage = err instanceof Error ? err.message : String(err);
|
|
1627
|
+
const legacy = anthropicErrorBody(500, originalMessage);
|
|
1628
|
+
return ownedAnthropicErrorResponse({ status: 500, evidence: { status: 500 },
|
|
1629
|
+
localError: markProxyError({ message: "The proxy could not read the Messages request." }),
|
|
1630
|
+
overflow: messagesRelayedOverflowPresentation("", legacy) }, legacy);
|
|
1568
1631
|
} finally { translatorBudget.dispose(); }
|
|
1569
1632
|
if (!body || typeof body !== "object" || Array.isArray(body)) {
|
|
1570
1633
|
return anthropicErrorResponse(400, "request body must be a JSON object");
|
|
@@ -1623,7 +1686,7 @@ export async function handleClaudeCountTokens(
|
|
|
1623
1686
|
});
|
|
1624
1687
|
} catch (error) {
|
|
1625
1688
|
if (error instanceof DesktopModelMappingUnavailableError) return desktopMappingUnavailableResponse(error);
|
|
1626
|
-
if (error instanceof AnthropicRequestError) return anthropicErrorResponse(400, error.message);
|
|
1689
|
+
if (error instanceof AnthropicRequestError) return anthropicErrorResponse(400, isProxyError(error) ? error.message : "The proxy could not translate the Messages request.");
|
|
1627
1690
|
throw error;
|
|
1628
1691
|
}
|
|
1629
1692
|
}
|
package/src/server/gui-static.ts
CHANGED
|
@@ -205,7 +205,10 @@ export function serveGuiFile(
|
|
|
205
205
|
|
|
206
206
|
if (!isFile(filePath)) {
|
|
207
207
|
if (!extname(pathname)) {
|
|
208
|
-
|
|
208
|
+
// A directory with its own index.html is a separate app (the classic dashboard at
|
|
209
|
+
// /classic/); every other extensionless path is the main dashboard's SPA fallback.
|
|
210
|
+
const nestedIndex = join(filePath, "index.html");
|
|
211
|
+
const indexPath = isFile(nestedIndex) ? nestedIndex : join(guiDist, "index.html");
|
|
209
212
|
if (isFile(indexPath)) {
|
|
210
213
|
return htmlResponse(indexPath, session, runtimeRole, managementAuthRequired);
|
|
211
214
|
}
|