@bitkyc08/opencodex 2.96.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 +215 -20
- 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-BOPQyDbH.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/command-code.ts +15 -16
- package/src/adapters/cursor/transport-retry.ts +2 -2
- package/src/adapters/devin/cloud-direct/chat.ts +15 -6
- 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 +230 -14
- 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 +24 -1
- package/src/adapters/kiro-events.ts +31 -1
- package/src/adapters/kiro-retry.ts +3 -3
- package/src/adapters/kiro-tools.ts +14 -9
- package/src/adapters/kiro-wire.ts +9 -5
- package/src/adapters/ollama-native.ts +11 -1
- 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/empty-assistant.ts +15 -3
- package/src/adapters/openai-responses/opengateway-input.ts +18 -6
- package/src/adapters/openai-responses/passthrough.ts +5 -4
- package/src/adapters/openai-responses/reasoning.ts +9 -4
- package/src/adapters/openai-responses/request-strips.ts +1 -1
- package/src/adapters/openai-responses/tool-output-recovery.ts +79 -0
- package/src/adapters/physical-send.ts +3 -3
- package/src/adapters/qoder/live-models.ts +115 -1
- package/src/adapters/zed-openai-stream.ts +2 -1
- package/src/bridge/errors.ts +11 -2
- package/src/bridge/response-json.ts +2 -1
- package/src/bridge/sse.ts +14 -6
- package/src/chat/failure-verdict.ts +21 -0
- package/src/chat/outbound.ts +139 -21
- 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 +98 -22
- package/src/cli/capabilities-access-remote.ts +13 -0
- package/src/cli/capabilities-base.ts +26 -3
- package/src/cli/capabilities-command.ts +12 -3
- package/src/cli/capabilities-provider-models.ts +3 -3
- package/src/cli/capability-contracts.ts +2 -0
- package/src/cli/codex-launch-auth.ts +30 -1
- package/src/cli/codex-launcher.ts +12 -5
- package/src/cli/codex-shim-autorestore.ts +12 -4
- package/src/cli/config-command.ts +11 -2
- package/src/cli/connect.ts +17 -2
- package/src/cli/dispatch.ts +14 -177
- package/src/cli/doctor.ts +95 -7
- package/src/cli/help.ts +2 -2
- package/src/cli/index.ts +17 -8
- package/src/cli/link-apply-restart.ts +9 -2
- package/src/cli/link.ts +1 -1
- package/src/cli/models.ts +124 -38
- package/src/cli/registry.ts +12 -4
- package/src/cli/restart-failure.ts +17 -0
- package/src/cli/root.ts +8 -0
- package/src/cli/stop-approval.ts +2 -2
- package/src/cli/sync-command.ts +243 -0
- package/src/cli/sync-fanout-process.ts +92 -0
- package/src/cli/sync-fanout.ts +161 -0
- package/src/cli/sync-flags.ts +10 -0
- package/src/cli/sync-link-status.ts +39 -0
- package/src/cli/sync-update-guard.ts +18 -0
- 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 +35 -15
- package/src/client/hub-client.ts +5 -0
- package/src/client/link-home.ts +3 -2
- 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 +10 -0
- package/src/client/orphan-token-recovery.ts +322 -0
- package/src/client/restore-ownership.ts +19 -1
- package/src/client/runtime-restart.ts +12 -4
- package/src/client/runtime.ts +40 -11
- package/src/client/stop-routing.ts +62 -0
- package/src/client/sync-runtime.ts +65 -0
- package/src/clients/config-export.ts +32 -3
- package/src/codex/auth-context.ts +49 -103
- package/src/codex/catalog/antigravity-discovery.ts +16 -5
- package/src/codex/catalog/provider-models.ts +18 -12
- package/src/codex/forward-transport-headers.ts +35 -6
- package/src/codex/inject/config-toml.ts +88 -0
- package/src/codex/inject/multi-agent-v2.ts +30 -4
- package/src/codex/inject/plan.ts +34 -7
- package/src/codex/inject-coordination.ts +11 -0
- package/src/codex/inject.ts +18 -7
- package/src/codex/lineage.ts +13 -7
- package/src/codex/native-profile-api.ts +27 -1
- package/src/codex/quota.ts +22 -6
- package/src/codex/request-owned-affinity-key.ts +11 -0
- package/src/codex/request-owned-affinity.ts +118 -0
- package/src/codex/request-owned-main-pin.ts +86 -0
- package/src/codex/role-capability.ts +52 -41
- package/src/codex/routing/active-account.ts +13 -5
- package/src/codex/routing/selection.ts +40 -1
- package/src/codex/routing/thread-affinity-store.ts +916 -0
- package/src/codex/routing/thread-affinity.ts +90 -12
- 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/codex/toml-source-lines.ts +72 -13
- package/src/combos/failover.ts +6 -109
- package/src/combos/request.ts +2 -2
- package/src/combos/resolve.ts +29 -11
- package/src/config/diagnostics.ts +9 -9
- package/src/config/load-degrade.ts +27 -27
- package/src/config/process-state.ts +5 -0
- package/src/config/provider-validation.ts +9 -2
- package/src/config/removed-opencode-free-backup.ts +6 -3
- package/src/config/schema/leaf-validators.ts +1 -0
- package/src/config/tracked-runtime-inspection.ts +3 -3
- package/src/generated/compatibility-version.json +595 -255
- package/src/images/loop.ts +4 -3
- package/src/lib/client-error-body.ts +215 -0
- package/src/lib/client-retry-after.ts +66 -0
- package/src/lib/config-ownership-removal.ts +422 -0
- package/src/lib/config-ownership.ts +650 -81
- package/src/lib/context-overflow-verdict.ts +113 -0
- package/src/lib/crash-guard.ts +4 -2
- package/src/lib/desktop-cli-handoff.d.mts +4 -5
- package/src/lib/desktop-cli-handoff.mjs +18 -17
- package/src/lib/empty-tool-catalog.ts +25 -3
- package/src/lib/error-destination.ts +47 -0
- package/src/lib/errors.ts +1 -0
- package/src/lib/failure-detail.ts +66 -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/model-identity.ts +44 -0
- package/src/lib/passive-read.ts +9 -4
- package/src/lib/private-sqlite-path.ts +124 -0
- package/src/lib/response-service-tier.ts +17 -0
- package/src/lib/retry-after.ts +3 -0
- package/src/lib/socks5-fetch.ts +21 -9
- package/src/lib/spend-ledger-owner.ts +43 -4
- package/src/lib/upstream-condition.ts +142 -0
- package/src/lib/upstream-retry.ts +95 -12
- package/src/lib/windows-owner-acl.ts +22 -9
- package/src/lib/winsw.ts +5 -5
- package/src/lib/workflow-budget.ts +3 -1
- package/src/link/remote-platform.ts +14 -0
- package/src/link/remote-windows.ts +51 -9
- package/src/link/ssh-argv.ts +63 -10
- package/src/oauth/generic-account-failover.ts +13 -11
- package/src/oauth/index.ts +42 -73
- package/src/oauth/oauth-errors.ts +67 -0
- package/src/oauth/store.ts +21 -11
- package/src/protocols/codecs/messages-ir.ts +15 -9
- package/src/protocols/codecs/ollama.ts +197 -0
- package/src/protocols/encoders/adapter-events.ts +30 -7
- package/src/protocols/encoders/chat.ts +18 -10
- package/src/protocols/encoders/messages.ts +72 -28
- package/src/protocols/trace.ts +18 -0
- package/src/providers/antigravity-models.ts +45 -12
- package/src/providers/fastwire.ts +3 -2
- package/src/providers/free-directory.ts +2 -2
- package/src/providers/quota/anthropic-usage-windows.ts +13 -3
- package/src/providers/quota/vendor-probes-key.ts +60 -24
- package/src/providers/reasoning-metadata.ts +2 -1
- package/src/providers/registry/entries-extended.ts +9 -0
- package/src/providers/request-pacing.ts +3 -2
- package/src/reasoning-effort.ts +7 -2
- package/src/remote/hub-usage.ts +3 -0
- package/src/responses/apply-patch-envelope.ts +45 -19
- package/src/responses/compaction-history-framing.ts +5 -1
- package/src/responses/freeform-wrapper-scan.ts +5 -3
- package/src/responses/progressive-freeform-input.ts +354 -45
- package/src/routing/fallback-policy.ts +3 -1
- package/src/server/admission-model-scope.ts +17 -6
- package/src/server/admitted-http-turn.ts +57 -0
- package/src/server/anthropic-rate-limit-headers.ts +75 -3
- package/src/server/auth-cors.ts +5 -0
- package/src/server/chat-completions.ts +45 -20
- package/src/server/chat-native-sse.ts +52 -7
- package/src/server/chat-native.ts +60 -35
- package/src/server/claude-bridge-pool-session.ts +59 -0
- package/src/server/claude-messages.ts +174 -84
- package/src/server/context-history.ts +5 -1
- package/src/server/gui-static.ts +4 -1
- package/src/server/hub-usage.ts +7 -2
- package/src/server/inbound-body-admission.ts +11 -4
- package/src/server/index/link-management.ts +8 -0
- package/src/server/index/ollama-routes.ts +91 -0
- package/src/server/index/serve-options.ts +44 -24
- package/src/server/index/startup-warnings.ts +5 -12
- package/src/server/index/websocket-handler.ts +5 -2
- package/src/server/index.ts +6 -36
- package/src/server/inference/client-encoder-delivery.ts +9 -3
- package/src/server/json-serialized-bytes.ts +44 -0
- package/src/server/management/agent-settings-routes.ts +24 -21
- package/src/server/management/codex-cli-update-routes.ts +2 -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 +4 -1
- 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-scope.ts +2 -1
- package/src/server/messages-native-tool-guard.ts +12 -4
- package/src/server/messages-native.ts +123 -47
- package/src/server/messages-response-headers.ts +25 -11
- package/src/server/messages-shared.ts +99 -65
- package/src/server/messages-sse-error-filter.ts +199 -0
- package/src/server/native-final-log.ts +93 -0
- package/src/server/ollama-inbound.ts +349 -0
- package/src/server/ollama-native-paths.ts +21 -0
- package/src/server/ollama-route-policy.ts +73 -0
- package/src/server/relay.ts +22 -3
- package/src/server/request-decompress.ts +4 -2
- package/src/server/request-log-failure-attribution.ts +22 -0
- package/src/server/request-log-failure-detail.ts +80 -0
- package/src/server/request-log-terminal-status.ts +4 -2
- package/src/server/request-log.ts +91 -42
- package/src/server/response-log-body.ts +6 -1
- package/src/server/responses/account-change-state.ts +17 -6
- package/src/server/responses/adapter-continuation.ts +17 -6
- package/src/server/responses/adapter-delivery.ts +17 -10
- package/src/server/responses/adapter-dispatch.ts +32 -31
- package/src/server/responses/anthropic-thinking-recovery.ts +3 -0
- package/src/server/responses/codex-auth-error.ts +24 -19
- package/src/server/responses/codex-ws-exchange.ts +11 -8
- package/src/server/responses/codex-ws-metadata.ts +94 -21
- package/src/server/responses/codex-ws-request.ts +3 -1
- package/src/server/responses/codex-ws-wire.ts +19 -3
- package/src/server/responses/compact.ts +57 -24
- package/src/server/responses/compaction-recovery.ts +4 -2
- package/src/server/responses/compaction-routing.ts +9 -4
- package/src/server/responses/core-auth.ts +32 -14
- package/src/server/responses/core-codex-account.ts +17 -6
- package/src/server/responses/core-combo-failure.ts +7 -1
- package/src/server/responses/core-combo-native.ts +2 -1
- package/src/server/responses/core-combo.ts +43 -27
- package/src/server/responses/core-errors.ts +24 -21
- package/src/server/responses/core-lifetime.ts +6 -3
- package/src/server/responses/core-normalize.ts +1 -0
- package/src/server/responses/core-options.ts +9 -0
- package/src/server/responses/core-pipeline.ts +4 -3
- package/src/server/responses/empty-completion-guard.ts +4 -1
- package/src/server/responses/fetch-helpers.ts +7 -1
- package/src/server/responses/input-admission.ts +28 -2
- package/src/server/responses/native-injection.ts +1 -1
- package/src/server/responses/native-response-json.ts +13 -4
- package/src/server/responses/native-response-output.ts +1 -2
- package/src/server/responses/non-replayable-error.ts +2 -1
- package/src/server/responses/pacing-overload.ts +3 -2
- package/src/server/responses/passthrough-delivery.ts +55 -14
- package/src/server/responses/passthrough-dispatch.ts +20 -18
- package/src/server/responses/passthrough-error.ts +9 -9
- package/src/server/responses/policy-fallback.ts +2 -1
- package/src/server/responses/request-prepare.ts +69 -48
- package/src/server/responses/request-transport.ts +36 -31
- package/src/server/responses/response-effects.ts +3 -2
- package/src/server/responses/run-turn-execution.ts +6 -6
- package/src/server/responses/sidecar-execution.ts +16 -12
- package/src/server/responses/spend-storage-error.ts +2 -1
- package/src/server/responses/terminal-guard.ts +30 -0
- package/src/server/responses/ws-upstream.ts +9 -0
- package/src/server/responses-custom-tool-repair.ts +14 -3
- package/src/server/responses-terminal-repair.ts +5 -2
- package/src/server/responses-undeclared-tool-guard.ts +39 -16
- package/src/server/restart-replacement.ts +3 -1
- package/src/server/safe-response-headers.ts +162 -13
- package/src/server/sse-payload-rewrite.ts +23 -11
- package/src/server/turn-state-handles.ts +164 -0
- package/src/server/workflow-refusal.ts +2 -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/ownership-mutation-lease.d.mts +11 -2
- package/src/service/ownership-mutation-lease.mjs +53 -11
- 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/config.ts +2 -0
- 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 +148 -26
- package/src/update/npm-install.d.mts +8 -0
- package/src/update/npm-install.mjs +20 -1
- package/src/update/orchestrated-admission.d.mts +4 -0
- package/src/update/orchestrated-admission.mjs +12 -0
- package/src/update/orchestrated-arguments.d.mts +12 -0
- package/src/update/orchestrated-arguments.mjs +64 -0
- package/src/update/orchestrated-child.d.mts +12 -0
- package/src/update/orchestrated-child.mjs +70 -0
- package/src/update/orchestrated-entry.ts +234 -0
- package/src/update/orchestrated-identity-probe-entry.ts +20 -0
- package/src/update/orchestrated-identity.ts +53 -0
- package/src/update/orchestrated-live-identity.ts +48 -0
- package/src/update/orchestrated-node-driver.mjs +99 -0
- package/src/update/orchestrated-outcome.d.mts +21 -0
- package/src/update/orchestrated-outcome.mjs +40 -0
- package/src/update/orchestrated-plan.ts +49 -0
- package/src/update/orchestrated-pnpm.d.mts +8 -0
- package/src/update/orchestrated-pnpm.mjs +33 -0
- package/src/update/orchestrated-session.d.mts +37 -0
- package/src/update/orchestrated-session.mjs +264 -0
- package/src/update/orchestrated-token.d.mts +10 -0
- package/src/update/orchestrated-token.mjs +21 -0
- package/src/update/orchestrated-token.ts +3 -0
- package/src/update/orchestrated-tree.d.mts +1 -0
- package/src/update/orchestrated-tree.mjs +14 -0
- package/src/update/pnpm-global-install.d.mts +6 -0
- package/src/update/pnpm-global-install.mjs +9 -2
- package/src/update/posix-install-supervisor-entry.mjs +6 -0
- package/src/update/posix-install-supervisor.d.mts +10 -0
- package/src/update/posix-install-supervisor.mjs +88 -0
- package/src/update/sync-update-mutex.d.mts +10 -0
- package/src/update/sync-update-mutex.mjs +164 -0
- package/src/update/sync-update-mutex.ts +1 -0
- package/src/update/test-home-guard.mjs +33 -0
- package/src/update/transactional-install.mjs +2 -2
- package/src/usage/client.ts +43 -0
- package/src/usage/error-detail.ts +225 -0
- package/src/usage/log.ts +64 -27
- 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 +33 -6
- package/src/web-search/progress-stream.ts +64 -5
- package/gui/dist/assets/App-bwugJRKn.js +0 -58
- package/gui/dist/assets/index-ebuVUtB7.js +0 -94
- package/gui/dist/assets/quota-summary-6HsrHQAy.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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MessagesSseFrameContext, messagesSseFrameHooks, messagesSseLocalFrame } from "../lib/messages-sse-error-presentation";
|
|
1
2
|
import { anthropicErrorBody } from "../claude/outbound";
|
|
2
3
|
import { redactSecretString } from "../lib/redact";
|
|
3
4
|
import { sseFieldValue } from "../lib/sse-decoder";
|
|
@@ -49,8 +50,10 @@ export function guardNativeMessagesEmptyToolCatalog(
|
|
|
49
50
|
budget: TranslatorBudget,
|
|
50
51
|
onRefusal: (message: string) => void,
|
|
51
52
|
declared: ReadonlySet<string> = NO_DECLARED_TOOLS,
|
|
53
|
+
frames?: MessagesSseFrameContext,
|
|
52
54
|
): ReadableStream<Uint8Array> {
|
|
53
55
|
const reader = source.getReader();
|
|
56
|
+
const hooks = frames ? messagesSseFrameHooks(frames) : undefined;
|
|
54
57
|
const decoder = new TextDecoder();
|
|
55
58
|
const encoder = new TextEncoder();
|
|
56
59
|
const scope = { kind: "live_transient" as const };
|
|
@@ -66,15 +69,19 @@ export function guardNativeMessagesEmptyToolCatalog(
|
|
|
66
69
|
queuedBytes = 0;
|
|
67
70
|
};
|
|
68
71
|
const clear = () => {
|
|
72
|
+
hooks?.dispose();
|
|
69
73
|
buffer.clear();
|
|
70
74
|
budget.releaseRetained(permittedInputBlocks.size * 32, scope);
|
|
71
75
|
permittedInputBlocks.clear();
|
|
72
76
|
};
|
|
73
|
-
const enqueue = (controller: ReadableStreamDefaultController<Uint8Array>, text: string) => {
|
|
77
|
+
const enqueue = (controller: ReadableStreamDefaultController<Uint8Array>, text: string, original = text, refusal = false) => {
|
|
74
78
|
const bytes = Buffer.byteLength(text);
|
|
75
79
|
const reservation = budget.reserveTransient(bytes, scope);
|
|
76
80
|
try {
|
|
77
|
-
|
|
81
|
+
const encoded = encoder.encode(text);
|
|
82
|
+
if (refusal) frames?.register(encoded, { client: messagesSseLocalFrame("guard", "") });
|
|
83
|
+
else hooks?.output(original, encoded);
|
|
84
|
+
controller.enqueue(encoded);
|
|
78
85
|
reservation.commitRetained();
|
|
79
86
|
queuedBytes += bytes;
|
|
80
87
|
} catch (error) {
|
|
@@ -110,9 +117,9 @@ export function guardNativeMessagesEmptyToolCatalog(
|
|
|
110
117
|
&& (index === undefined || !permittedInputBlocks.has(index))) name ??= "<unnamed>";
|
|
111
118
|
if (name !== undefined) {
|
|
112
119
|
clear();
|
|
113
|
-
const message = redactSecretString(undeclaredToolCallMessage(
|
|
120
|
+
const message = redactSecretString(undeclaredToolCallMessage());
|
|
114
121
|
onRefusal(message);
|
|
115
|
-
enqueue(controller, `event: error\ndata: ${JSON.stringify(anthropicErrorBody(502, message, "api_error", UNDECLARED_TOOL_CALL_ERROR_CODE))}\n\n
|
|
122
|
+
enqueue(controller, `event: error\ndata: ${JSON.stringify(anthropicErrorBody(502, message, "api_error", UNDECLARED_TOOL_CALL_ERROR_CODE))}\n\n`, undefined, true);
|
|
116
123
|
settled = true;
|
|
117
124
|
cancelReader(new Error(message));
|
|
118
125
|
controller.close();
|
|
@@ -152,6 +159,7 @@ export function guardNativeMessagesEmptyToolCatalog(
|
|
|
152
159
|
const { done, value } = await reader.read();
|
|
153
160
|
if (settled) return;
|
|
154
161
|
if (!done) {
|
|
162
|
+
hooks?.input(value, buffer.isEmpty());
|
|
155
163
|
buffer.append(decoder.decode(value, { stream: true }));
|
|
156
164
|
continue;
|
|
157
165
|
}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import { MessagesSseFrameContext, messagesSseEchoRenamedError, messagesSseFrameHooks } from "../lib/messages-sse-error-presentation";
|
|
2
|
+
import { createMessagesSseErrorFilter } from "./messages-sse-error-filter";
|
|
3
|
+
import type { MessagesFailureVerdictSink } from "../claude/failure-verdict";
|
|
4
|
+
import { upstreamErrorIsLocal } from "./request-log-failure-detail";
|
|
5
|
+
import { boundedMessagesDisplayCount, ownedAnthropicErrorPayload, ownedAnthropicErrorResponse, messagesOverflowPresentation, messagesRelayedOverflowPresentation } from "../lib/messages-error-body";
|
|
6
|
+
import { attachComboFailureEvidence, isProxyError, markProxyError } from "../lib/client-error-body";
|
|
1
7
|
import { captureAccountAutoPauseAttempt, wasAccountAutoPaused } from "../oauth/account-auto-pause";
|
|
2
8
|
import { createPhysicalSendReporter } from "../lib/request-execution-budget";
|
|
3
9
|
import { createInferenceSendBudget } from "./inference/context";
|
|
@@ -38,13 +44,13 @@ import {
|
|
|
38
44
|
type AnthropicMessagesPassthroughRequest,
|
|
39
45
|
} from "../adapters/anthropic/passthrough";
|
|
40
46
|
import { effortFromOutputConfig, resolveInboundModel } from "../claude/inbound";
|
|
41
|
-
import { anthropicErrorBody,
|
|
47
|
+
import { anthropicErrorBody, claudeOverflowSsePayload, claudePromptTooLongMessage, collectAnthropicMessage, isContextOverflowText, isThroughputLimitText } from "../claude/outbound";
|
|
42
48
|
import type { AdmissionLease } from "../lib/admission";
|
|
43
49
|
import { readBoundedResponseBody } from "../lib/bounded-body";
|
|
44
50
|
import { classifyError } from "../lib/errors";
|
|
45
51
|
import { relaySseWithPayloadRewrite } from "./sse-payload-rewrite";
|
|
46
52
|
import { redactSecretString } from "../lib/redact";
|
|
47
|
-
import { resolveClientRetryAfter } from "../lib/retry-after";
|
|
53
|
+
import { formatClientRetryAfter, resolveClientRetryAfter } from "../lib/retry-after";
|
|
48
54
|
import { enrichOpenCodeZenUpstreamMessage } from "../providers/opencode-zen-rate-limit";
|
|
49
55
|
import { isTranslatorBudgetExceededError, type TranslatorBudget } from "../lib/translator-budget";
|
|
50
56
|
import {
|
|
@@ -76,7 +82,7 @@ import {
|
|
|
76
82
|
transientRetryPolicyFor,
|
|
77
83
|
} from "../providers/key-failover";
|
|
78
84
|
import { stampApiKeyAccountLabel } from "../providers/label";
|
|
79
|
-
import { OAuthAccountPausedError, OAuthLoginRequiredError, publicOAuthAuthenticationErrorMessage } from "../oauth";
|
|
85
|
+
import { publicOAuthErrorPresentation, OAuthAccountPausedError, OAuthLoginRequiredError, publicOAuthAuthenticationErrorMessage } from "../oauth";
|
|
80
86
|
import { AnthropicAccountCooldownError, formatAnthropicProviderForLog, anthropicRoutingFor } from "../oauth/anthropic-routing";
|
|
81
87
|
import { configuredAnthropicInstance } from "../providers/anthropic-instance";
|
|
82
88
|
import { resolveProtocolSettings } from "../protocols/settings";
|
|
@@ -130,7 +136,7 @@ import { linkAbortSignal } from "./responses/core-lifetime";
|
|
|
130
136
|
import { attachRequestSpendTracker } from "./responses/request-spend";
|
|
131
137
|
import { workflowRefusalResponse } from "./workflow-refusal";
|
|
132
138
|
import { sseFieldValue } from "../lib/sse-decoder";
|
|
133
|
-
import { admissionModelDeniedResponse, type AdmissionModelScope } from "./admission-model-scope";
|
|
139
|
+
import { admissionModelDeniedResponse, projectAdmissionModelDeniedLog, type AdmissionModelScope } from "./admission-model-scope";
|
|
134
140
|
import { nativeMessagesToolScopeDenial } from "./messages-native-scope";
|
|
135
141
|
import { retainUpstreamMessagesRequestId } from "./messages-response-headers";
|
|
136
142
|
|
|
@@ -233,7 +239,7 @@ function messageStartWithModel(frame: string, model: string): string | undefined
|
|
|
233
239
|
* (`responsesSseToAnthropicSse` is given the requested model). Works on bytes: frames before and
|
|
234
240
|
* including `message_start` are split on the blank line, and everything after is relayed as is.
|
|
235
241
|
*/
|
|
236
|
-
function echoRequestedModel(body: ReadableStream<Uint8Array>, model: string): ReadableStream<Uint8Array> {
|
|
242
|
+
function echoRequestedModel(body: ReadableStream<Uint8Array>, model: string, frames: MessagesSseFrameContext): ReadableStream<Uint8Array> {
|
|
237
243
|
const reader = body.getReader();
|
|
238
244
|
const encoder = new TextEncoder();
|
|
239
245
|
const decoder = new TextDecoder();
|
|
@@ -268,7 +274,9 @@ function echoRequestedModel(body: ReadableStream<Uint8Array>, model: string): Re
|
|
|
268
274
|
pending = pending.subarray(end);
|
|
269
275
|
const rewritten = messageStartWithModel(decoder.decode(frame), model);
|
|
270
276
|
if (rewritten !== undefined) {
|
|
271
|
-
|
|
277
|
+
const bytes = encoder.encode(rewritten);
|
|
278
|
+
if (messagesSseEchoRenamedError(decoder.decode(frame))) frames.register(bytes, { echoRenamedError: true });
|
|
279
|
+
controller.enqueue(bytes);
|
|
272
280
|
scanning = false;
|
|
273
281
|
} else {
|
|
274
282
|
controller.enqueue(frame);
|
|
@@ -372,19 +380,40 @@ export async function handleNativeMessages(options: HandleNativeMessagesOptions)
|
|
|
372
380
|
attempt.usage = usage;
|
|
373
381
|
}
|
|
374
382
|
};
|
|
375
|
-
const fail = (status: number, message: string, type?: string, code?: string): Response => {
|
|
383
|
+
const fail = (status: number, message: string, type?: string, code?: string, originalMessage = message): Response => {
|
|
376
384
|
const safeMessage = redactSecretString(message);
|
|
377
385
|
finishLog(status, safeMessage);
|
|
378
|
-
|
|
386
|
+
const legacy = anthropicErrorBody(status, redactSecretString(originalMessage), type, code);
|
|
387
|
+
return ownedAnthropicErrorResponse({ status, type, code, evidence: { status, message: originalMessage },
|
|
388
|
+
localError: markProxyError({ message: safeMessage }), overflow: messagesRelayedOverflowPresentation("", legacy) }, legacy);
|
|
389
|
+
};
|
|
390
|
+
const failEvidence = (status: number, message: string, type: string, contract?: "transport_failed", overflow?: boolean, rawError?: Rec, legacyBody?: Rec): Response => {
|
|
391
|
+
finishLog(status, message);
|
|
392
|
+
const legacy = legacyBody ?? anthropicErrorBody(status, redactSecretString(message), type);
|
|
393
|
+
return ownedAnthropicErrorResponse({ status, type, evidence: { status, message, type: typeof rawError?.type === "string" ? rawError.type : undefined, code: typeof rawError?.code === "string" ? rawError.code : undefined }, contract,
|
|
394
|
+
overflow: overflow ?? messagesRelayedOverflowPresentation("", legacy) }, legacy);
|
|
395
|
+
};
|
|
396
|
+
const preparationFailure = (error: unknown): Response => {
|
|
397
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
398
|
+
finishLog(400, message);
|
|
399
|
+
return fail(400, error instanceof Error && isProxyError(error) ? error.message : "The proxy could not translate the Messages request.", "invalid_request_error", undefined, message);
|
|
379
400
|
};
|
|
380
401
|
const localOAuthFailure = (error: unknown): Response | null => {
|
|
381
402
|
if (error instanceof AnthropicAccountCooldownError) {
|
|
382
|
-
const
|
|
383
|
-
|
|
403
|
+
const scope = error.routePosition === undefined ? "All Anthropic OAuth accounts" : "Anthropic OAuth accounts for this model route";
|
|
404
|
+
const reset = error.usageLimit?.resetsAt;
|
|
405
|
+
const date = typeof reset === "number" && Number.isFinite(reset) && reset >= 0 && reset <= 253402300799999
|
|
406
|
+
? new Date(Math.floor(reset / 1000) * 1000).toISOString().replace(".000Z", "Z") : undefined;
|
|
407
|
+
const message = error.usageLimit === null ? `${scope} are temporarily rate-limited`
|
|
408
|
+
: `${scope} have reached their usage limit${date ? `; the first one resets at ${date}` : ""}`;
|
|
409
|
+
finishLog(429, error.message);
|
|
410
|
+
const response = markProxyError(fail(429, message, "rate_limit_error"), date === undefined ? undefined : "usage");
|
|
411
|
+
const advice = error.retryAfterSeconds !== null ? formatClientRetryAfter(error.retryAfterSeconds) : undefined;
|
|
412
|
+
if (advice !== undefined) response.headers.set("retry-after", advice);
|
|
384
413
|
return response;
|
|
385
414
|
}
|
|
386
|
-
if (error instanceof OAuthAccountPausedError) return fail(403, publicOAuthAuthenticationErrorMessage(error), "permission_error");
|
|
387
|
-
if (error instanceof OAuthLoginRequiredError) return fail(401, publicOAuthAuthenticationErrorMessage(error), "authentication_error");
|
|
415
|
+
if (error instanceof OAuthAccountPausedError) return markProxyError(fail(403, publicOAuthAuthenticationErrorMessage(error), "permission_error"), publicOAuthErrorPresentation(error));
|
|
416
|
+
if (error instanceof OAuthLoginRequiredError) return markProxyError(fail(401, publicOAuthAuthenticationErrorMessage(error), "authentication_error"), publicOAuthErrorPresentation(error));
|
|
388
417
|
return null;
|
|
389
418
|
};
|
|
390
419
|
|
|
@@ -394,6 +423,7 @@ export async function handleNativeMessages(options: HandleNativeMessagesOptions)
|
|
|
394
423
|
|
|
395
424
|
const toolScopeDenial = nativeMessagesToolScopeDenial(options.modelScope, route.providerName, requestedModel, body);
|
|
396
425
|
if (toolScopeDenial) {
|
|
426
|
+
projectAdmissionModelDeniedLog(toolScopeDenial, logCtx);
|
|
397
427
|
finishLog(403, toolScopeDenial.message);
|
|
398
428
|
return admissionModelDeniedResponse(toolScopeDenial);
|
|
399
429
|
}
|
|
@@ -409,7 +439,7 @@ export async function handleNativeMessages(options: HandleNativeMessagesOptions)
|
|
|
409
439
|
return fail(413, "request translation buffer exceeded the safe limit", "request_too_large", "translation_buffer_limit");
|
|
410
440
|
}
|
|
411
441
|
// An AnthropicRequestError (empty tool id) or an image the guard cannot carry.
|
|
412
|
-
return
|
|
442
|
+
return preparationFailure(error);
|
|
413
443
|
}
|
|
414
444
|
|
|
415
445
|
const upstream = new AbortController();
|
|
@@ -442,8 +472,8 @@ export async function handleNativeMessages(options: HandleNativeMessagesOptions)
|
|
|
442
472
|
const localRefusal = localOAuthFailure(error);
|
|
443
473
|
if (localRefusal) return localRefusal;
|
|
444
474
|
if (error instanceof NativeOAuthSelectionChangedError) return fail(409, error.message, "api_error");
|
|
445
|
-
if (error instanceof NativeOAuthModelRouteError) return fail(400,
|
|
446
|
-
return fail(401, publicOAuthAuthenticationErrorMessage(error), "authentication_error");
|
|
475
|
+
if (error instanceof NativeOAuthModelRouteError) return fail(400, "Invalid Anthropic model routes", "invalid_request_error", undefined, error.message);
|
|
476
|
+
return markProxyError(fail(401, publicOAuthAuthenticationErrorMessage(error), "authentication_error"), publicOAuthErrorPresentation(error));
|
|
447
477
|
}
|
|
448
478
|
} else {
|
|
449
479
|
// Same pre-dispatch key preference every direct send path applies (see chat-native.ts).
|
|
@@ -453,8 +483,9 @@ export async function handleNativeMessages(options: HandleNativeMessagesOptions)
|
|
|
453
483
|
} catch (error) {
|
|
454
484
|
cleanupAbort(); upstream.abort();
|
|
455
485
|
if (!(error instanceof RequestPacingQueueOverloadError)) throw error;
|
|
456
|
-
const refusal = fail(429, error.message, "rate_limit_error");
|
|
457
|
-
|
|
486
|
+
const refusal = markProxyError(fail(429, error.message, "rate_limit_error"), error.reason === "keys_exhausted" ? undefined : "pacing");
|
|
487
|
+
const advice = formatClientRetryAfter(error.retryAfterSeconds);
|
|
488
|
+
if (advice !== undefined) refusal.headers.set("Retry-After", advice);
|
|
458
489
|
return refusal;
|
|
459
490
|
}
|
|
460
491
|
}
|
|
@@ -520,7 +551,7 @@ export async function handleNativeMessages(options: HandleNativeMessagesOptions)
|
|
|
520
551
|
logCtx.errorCode = "unsupported_feature";
|
|
521
552
|
return fail(400, error.message, "invalid_request_error", "unsupported_feature");
|
|
522
553
|
}
|
|
523
|
-
return
|
|
554
|
+
return preparationFailure(error);
|
|
524
555
|
}
|
|
525
556
|
|
|
526
557
|
// One inbound request owns one transient send allowance, captured before any key rotation.
|
|
@@ -554,7 +585,7 @@ export async function handleNativeMessages(options: HandleNativeMessagesOptions)
|
|
|
554
585
|
const send = async (recovery?: "rate-limit-429" | "oauth-401" | "oauth-account-403" | "key-429" | "key-401"): Promise<Response> => {
|
|
555
586
|
const remaining = remainingTransientSends();
|
|
556
587
|
if (requestTransientPolicy && remaining <= 0) {
|
|
557
|
-
throw new Error("native Messages transient send budget exhausted before recovery dispatch");
|
|
588
|
+
throw markProxyError(new Error("native Messages transient send budget exhausted before recovery dispatch"));
|
|
558
589
|
}
|
|
559
590
|
const fetchWithPolicy = requestTransientPolicy ? fetchWithTransientRetry : fetchWithResetRetry;
|
|
560
591
|
const request = activeRequest;
|
|
@@ -587,7 +618,7 @@ export async function handleNativeMessages(options: HandleNativeMessagesOptions)
|
|
|
587
618
|
}
|
|
588
619
|
} else {
|
|
589
620
|
for (let attempt = 0; !providerApiKeySelectionIsCurrent(config, route.providerName, activeProvider); attempt++) {
|
|
590
|
-
if (attempt >= 3) throw new Error("Provider key selection changed repeatedly before native Messages dispatch");
|
|
621
|
+
if (attempt >= 3) throw markProxyError(new Error("Provider key selection changed repeatedly before native Messages dispatch"));
|
|
591
622
|
let current = resolveCurrentProviderApiKeyTransport(config, route.providerName, activeProvider);
|
|
592
623
|
if (!current && activeProvider.requestPacing?.enabled
|
|
593
624
|
&& (activeProvider.requestPacing.keys || activeProvider.requestPacing.keySelection === "round-robin")) {
|
|
@@ -595,12 +626,12 @@ export async function handleNativeMessages(options: HandleNativeMessagesOptions)
|
|
|
595
626
|
if (fresh) current = selectProactiveApiKeyTransport(config, route.providerName, fresh) ?? fresh;
|
|
596
627
|
}
|
|
597
628
|
if (!current || nativeMessagesDeclineReason({ ...route, provider: current }, body, config, selector) !== undefined) {
|
|
598
|
-
throw new Error("Provider key selection is no longer available for native Messages");
|
|
629
|
+
throw markProxyError(new Error("Provider key selection is no longer available for native Messages"));
|
|
599
630
|
}
|
|
600
631
|
rebuildFor(current);
|
|
601
632
|
if (current.requestPacing?.enabled
|
|
602
633
|
&& (current.requestPacing.keys || current.requestPacing.keySelection === "round-robin")) {
|
|
603
|
-
if (!reacquirePacing) throw new Error("Refreshed native Messages dispatch requires pacing readmission");
|
|
634
|
+
if (!reacquirePacing) throw markProxyError(new Error("Refreshed native Messages dispatch requires pacing readmission"));
|
|
604
635
|
await reacquirePacing(current, route.modelId);
|
|
605
636
|
}
|
|
606
637
|
}
|
|
@@ -834,20 +865,21 @@ export async function handleNativeMessages(options: HandleNativeMessagesOptions)
|
|
|
834
865
|
settleDistributedFailure();
|
|
835
866
|
const sendError = error instanceof UpstreamRetryEvidenceError ? error.cause : error;
|
|
836
867
|
if (sendError instanceof RequestPacingQueueOverloadError) {
|
|
837
|
-
const refusal = fail(429, sendError.message, "rate_limit_error");
|
|
838
|
-
|
|
868
|
+
const refusal = markProxyError(fail(429, sendError.message, "rate_limit_error"), sendError.reason === "keys_exhausted" ? undefined : "pacing");
|
|
869
|
+
const advice = formatClientRetryAfter(sendError.retryAfterSeconds);
|
|
870
|
+
if (advice !== undefined) refusal.headers.set("Retry-After", advice);
|
|
839
871
|
return refusal;
|
|
840
872
|
}
|
|
841
873
|
if (sendError instanceof SendBudgetExhaustedError) return fail(429, sendError.message, "send_budget_exhausted", "send_budget_exhausted");
|
|
842
874
|
if (sendError instanceof NativeMessagesSpendRefusal) {
|
|
843
|
-
const refusal = workflowRefusalResponse("workflow-spend-exhausted", logCtx);
|
|
875
|
+
const refusal = workflowRefusalResponse("workflow-spend-exhausted", logCtx, undefined, undefined, logCtx.spendRefusalDetail);
|
|
844
876
|
finishLog(429);
|
|
845
877
|
return refusal;
|
|
846
878
|
}
|
|
847
879
|
const localRefusal = localOAuthFailure(sendError);
|
|
848
880
|
if (localRefusal) return localRefusal;
|
|
849
881
|
if (sendError instanceof NativeOAuthSelectionChangedError) return fail(409, sendError.message, "api_error");
|
|
850
|
-
if (sendError instanceof NativeOAuthModelRouteError) return fail(400,
|
|
882
|
+
if (sendError instanceof NativeOAuthModelRouteError) return fail(400, "Invalid Anthropic model routes", "invalid_request_error", undefined, sendError.message);
|
|
851
883
|
if (sendError instanceof NativeOpaqueStateRefusal) {
|
|
852
884
|
logCtx.errorCode = "unsupported_feature";
|
|
853
885
|
return fail(400, sendError.message, "invalid_request_error", "unsupported_feature");
|
|
@@ -855,7 +887,8 @@ export async function handleNativeMessages(options: HandleNativeMessagesOptions)
|
|
|
855
887
|
if (isTranslatorBudgetExceededError(error)) {
|
|
856
888
|
return fail(413, "request translation buffer exceeded the safe limit", "request_too_large", "translation_buffer_limit");
|
|
857
889
|
}
|
|
858
|
-
|
|
890
|
+
if (sendError instanceof Error && isProxyError(sendError)) return fail(502, sendError.message, "api_error");
|
|
891
|
+
return failEvidence(502, error instanceof Error ? error.message : String(error), "api_error", "transport_failed");
|
|
859
892
|
}
|
|
860
893
|
releaseRetainedRequest();
|
|
861
894
|
|
|
@@ -896,16 +929,18 @@ export async function handleNativeMessages(options: HandleNativeMessagesOptions)
|
|
|
896
929
|
const renamed = activeRequest.oauthToolNames
|
|
897
930
|
? restoreOAuthToolNamesInSse(observed, activeRequest.oauthToolNames, translatorBudget)
|
|
898
931
|
: observed;
|
|
899
|
-
const
|
|
932
|
+
const frames = new MessagesSseFrameContext();
|
|
933
|
+
const echoed = echoRequestedModel(renamed, requestedModel, frames);
|
|
900
934
|
let toolRefusal: string | undefined;
|
|
901
935
|
const source = clientDeclaredEmptyToolCatalog
|
|
902
936
|
? guardNativeMessagesEmptyToolCatalog(echoed, translatorBudget, message => {
|
|
903
937
|
toolRefusal = message;
|
|
904
938
|
logCtx.errorCode = UNDECLARED_TOOL_CALL_ERROR_CODE;
|
|
905
|
-
}, declaredInlineTools)
|
|
939
|
+
}, declaredInlineTools, frames)
|
|
906
940
|
: echoed;
|
|
907
941
|
if (requestedStream) {
|
|
908
942
|
transferTurnToStream();
|
|
943
|
+
const clientFilter = createMessagesSseErrorFilter(frames);
|
|
909
944
|
const relayed = tapAnthropicSseForLog(source, logCtx, (status, meta) => {
|
|
910
945
|
try {
|
|
911
946
|
cleanupAbort();
|
|
@@ -915,12 +950,12 @@ export async function handleNativeMessages(options: HandleNativeMessagesOptions)
|
|
|
915
950
|
} finally {
|
|
916
951
|
releaseStreamTurn();
|
|
917
952
|
}
|
|
918
|
-
}, bodyGuard);
|
|
953
|
+
}, bodyGuard, frames, nativeInstance ? clientFilter : undefined);
|
|
919
954
|
// A configured Messages provider words an oversized-input refusal its own way; Claude Code
|
|
920
955
|
// compacts only on Anthropic's wording (devlog/_plan/261009_claude_1m_default/010). The
|
|
921
956
|
// rewrite buffers whole frames, so it sits after the tap: stall detection keeps timing raw
|
|
922
957
|
// upstream bytes. Real Anthropic pools refuse pre-stream in that wording and keep one relay.
|
|
923
|
-
const clientStream = nativeInstance ? relayed : relaySseWithPayloadRewrite(relayed, claudeOverflowSsePayload, translatorBudget);
|
|
958
|
+
const clientStream = nativeInstance ? relayed : relaySseWithPayloadRewrite(relayed, claudeOverflowSsePayload, translatorBudget, messagesSseFrameHooks(frames), clientFilter);
|
|
924
959
|
return retainUpstreamMessagesRequestId(new Response(clientStream, {
|
|
925
960
|
status: 200,
|
|
926
961
|
headers: { "Content-Type": "text/event-stream; charset=utf-8", "Cache-Control": "no-cache", Connection: "keep-alive" },
|
|
@@ -932,8 +967,9 @@ export async function handleNativeMessages(options: HandleNativeMessagesOptions)
|
|
|
932
967
|
tapState.closeReason = meta.closeReason;
|
|
933
968
|
tapState.meta = meta;
|
|
934
969
|
}, bodyGuard);
|
|
970
|
+
const collectorVerdictSink: MessagesFailureVerdictSink = {};
|
|
935
971
|
try {
|
|
936
|
-
const message = await collectAnthropicMessage(tapped, requestedModel, translatorBudget);
|
|
972
|
+
const message = await collectAnthropicMessage(tapped, requestedModel, translatorBudget, collectorVerdictSink);
|
|
937
973
|
cleanupAbort();
|
|
938
974
|
if (tapState.closeReason === "client_cancel" || req.signal.aborted) {
|
|
939
975
|
return fail(499, "Client cancelled request", "api_error");
|
|
@@ -947,15 +983,41 @@ export async function handleNativeMessages(options: HandleNativeMessagesOptions)
|
|
|
947
983
|
finishLog(502, toolRefusal, { closeReason: "terminal", terminalStatus: "failed" });
|
|
948
984
|
return fail(502, toolRefusal, "api_error", UNDECLARED_TOOL_CALL_ERROR_CODE);
|
|
949
985
|
}
|
|
986
|
+
const baselineOverflow = isNativeOverflowError(error, text);
|
|
950
987
|
// The tap's own verdict (a reset, a stall, the byte cap) closes this row with the same meta
|
|
951
988
|
// as the streaming lane's row; a plain upstream error event keeps the non_stream row.
|
|
952
989
|
const tapMeta = tapState.meta;
|
|
953
990
|
if (tapMeta && (tapMeta.terminalStatus || tapMeta.closeReason !== "terminal")) finishLog(502, text, tapMeta);
|
|
954
|
-
if (
|
|
955
|
-
|
|
991
|
+
if (upstreamErrorIsLocal(logCtx) && (logCtx.terminalSource === "synthetic" || tapMeta?.closeReason === "body_stall" || tapMeta?.closeReason === "body_overflow")) {
|
|
992
|
+
const count = boundedMessagesDisplayCount(bodyGuard.maxBytes);
|
|
993
|
+
const seconds = boundedMessagesDisplayCount(Math.round(bodyGuard.stallMs / 1000));
|
|
994
|
+
const localMessage = new Map<string, string>([
|
|
995
|
+
["body_overflow", count === undefined ? "anthropic passthrough body exceeded the safe limit" : `anthropic passthrough body exceeded ${count} bytes`],
|
|
996
|
+
["body_stall", seconds === undefined ? "anthropic passthrough body stalled" : `anthropic passthrough body stalled: no upstream bytes for ${seconds}s`],
|
|
997
|
+
["stream_error_stop", 'upstream ended the turn with stop_reason "error"'],
|
|
998
|
+
["stream_ended_early", "anthropic passthrough upstream stream ended before message_stop"],
|
|
999
|
+
["stream_failed", "The proxy could not reach or read the provider."],
|
|
1000
|
+
]).get(logCtx.failureDetail?.code ?? "");
|
|
1001
|
+
if (localMessage !== undefined) return markProxyError(fail(502, localMessage, "api_error", undefined, text), logCtx.failureDetail?.code === "body_overflow" ? "body_overflow" : logCtx.failureDetail?.code === "body_stall" ? "body_stall" : undefined);
|
|
1002
|
+
}
|
|
1003
|
+
const legacy = anthropicErrorBody(baselineOverflow ? 400 : 502,
|
|
1004
|
+
redactSecretString(baselineOverflow ? claudePromptTooLongMessage(text) : text),
|
|
1005
|
+
baselineOverflow ? "invalid_request_error" : "api_error");
|
|
1006
|
+
const overflow = messagesOverflowPresentation((legacy.error as Rec).message);
|
|
1007
|
+
if (baselineOverflow) return failEvidence(400, text, "invalid_request_error", undefined, overflow, error, legacy);
|
|
1008
|
+
return failEvidence(502, text, "api_error", undefined, overflow, error, legacy);
|
|
956
1009
|
}
|
|
957
|
-
|
|
958
|
-
|
|
1010
|
+
const finalStatus = collectorVerdictSink.collectedErrorEvent ? 502 : 200;
|
|
1011
|
+
finishLog(finalStatus);
|
|
1012
|
+
const collected = collectorVerdictSink.collected ?? message;
|
|
1013
|
+
const originalError = isRec(collected.error) ? collected.error : {};
|
|
1014
|
+
const clientMessage = collectorVerdictSink.collectedErrorEvent ? ownedAnthropicErrorPayload({ status: 200,
|
|
1015
|
+
type: typeof originalError.type === "string" ? originalError.type : undefined,
|
|
1016
|
+
code: typeof originalError.code === "string" ? originalError.code : undefined,
|
|
1017
|
+
overflow: messagesRelayedOverflowPresentation(JSON.stringify(collected), collected),
|
|
1018
|
+
evidence: { status: 200, message: typeof originalError.message === "string" ? originalError.message : undefined },
|
|
1019
|
+
}) : message;
|
|
1020
|
+
return retainUpstreamMessagesRequestId(Response.json(clientMessage, { status: finalStatus }), response.headers);
|
|
959
1021
|
} catch (error) {
|
|
960
1022
|
cleanupAbort();
|
|
961
1023
|
upstream.abort();
|
|
@@ -963,7 +1025,7 @@ export async function handleNativeMessages(options: HandleNativeMessagesOptions)
|
|
|
963
1025
|
if (isTranslatorBudgetExceededError(error)) {
|
|
964
1026
|
return fail(413, "upstream translation buffer exceeded the safe limit", "request_too_large", "translation_buffer_limit");
|
|
965
1027
|
}
|
|
966
|
-
return
|
|
1028
|
+
return failEvidence(502, error instanceof Error ? error.message : String(error), "api_error", "transport_failed");
|
|
967
1029
|
}
|
|
968
1030
|
}
|
|
969
1031
|
|
|
@@ -980,7 +1042,7 @@ export async function handleNativeMessages(options: HandleNativeMessagesOptions)
|
|
|
980
1042
|
cleanupAbort();
|
|
981
1043
|
upstream.abort();
|
|
982
1044
|
if (req.signal.aborted) return fail(499, "Client cancelled request", "api_error");
|
|
983
|
-
return
|
|
1045
|
+
return failEvidence(502, error instanceof Error ? error.message : String(error), "api_error", "transport_failed");
|
|
984
1046
|
}
|
|
985
1047
|
cleanupAbort();
|
|
986
1048
|
if (read.oversized) {
|
|
@@ -1002,7 +1064,7 @@ export async function handleNativeMessages(options: HandleNativeMessagesOptions)
|
|
|
1002
1064
|
const undeclaredTool = clientDeclaredEmptyToolCatalog ? nativeMessagesClientToolName(message, declaredInlineTools) : undefined;
|
|
1003
1065
|
if (undeclaredTool !== undefined) {
|
|
1004
1066
|
logCtx.errorCode = UNDECLARED_TOOL_CALL_ERROR_CODE;
|
|
1005
|
-
return fail(502, undeclaredToolCallMessage(
|
|
1067
|
+
return fail(502, undeclaredToolCallMessage(), "api_error", UNDECLARED_TOOL_CALL_ERROR_CODE);
|
|
1006
1068
|
}
|
|
1007
1069
|
bindUsage(anthropicUsageToOcx(isRec(message.usage) ? message.usage : undefined));
|
|
1008
1070
|
if (logIds) recordFirstOutput(logCtx, logIds.start);
|
|
@@ -1055,7 +1117,7 @@ function nativeMessagesErrorResponse(response: Response, bodyText: string, finis
|
|
|
1055
1117
|
const detail = formatAnthropicErrorBody(response.status, response.headers, bodyText);
|
|
1056
1118
|
const rawMessage = upstreamMessage
|
|
1057
1119
|
?? (detail ? `Provider error ${response.status}: ${detail}` : `Provider error ${response.status}`);
|
|
1058
|
-
const
|
|
1120
|
+
const zenOptions = {
|
|
1059
1121
|
status: response.status,
|
|
1060
1122
|
providerName,
|
|
1061
1123
|
baseUrl: provider.baseUrl,
|
|
@@ -1066,7 +1128,12 @@ function nativeMessagesErrorResponse(response: Response, bodyText: string, finis
|
|
|
1066
1128
|
upstreamErrorType: upstreamType,
|
|
1067
1129
|
upstreamErrorCode: upstreamCode,
|
|
1068
1130
|
supportsHttpSameKeyRetry: true,
|
|
1069
|
-
}
|
|
1131
|
+
};
|
|
1132
|
+
const message = enrichOpenCodeZenUpstreamMessage(rawMessage, zenOptions);
|
|
1133
|
+
const clientZenMessage = message === rawMessage ? undefined : enrichOpenCodeZenUpstreamMessage(
|
|
1134
|
+
"The provider rate limit was reached; retry later.",
|
|
1135
|
+
{ ...zenOptions, upstreamRetryAfter: /try again in \d/i.test(rawMessage) ? "0" : zenOptions.upstreamRetryAfter },
|
|
1136
|
+
);
|
|
1070
1137
|
const classified = classifyError(
|
|
1071
1138
|
response.status,
|
|
1072
1139
|
upstreamType ?? (response.status === 401 ? "authentication_error"
|
|
@@ -1085,23 +1152,32 @@ function nativeMessagesErrorResponse(response: Response, bodyText: string, finis
|
|
|
1085
1152
|
?? (upstreamRetryAfter?.trim() === "0" ? "0" : undefined);
|
|
1086
1153
|
finishLog(response.status, safeMessage);
|
|
1087
1154
|
const headers = new Headers({ "Content-Type": "application/json" });
|
|
1088
|
-
|
|
1155
|
+
const clientRetryAfter = formatClientRetryAfter(retryAfter);
|
|
1156
|
+
if (clientRetryAfter) headers.set("Retry-After", clientRetryAfter);
|
|
1089
1157
|
else if (transient) headers.set("Retry-After", "2");
|
|
1090
1158
|
if (replayRefusal) applyReplayRefusalClientHeaders(headers);
|
|
1091
1159
|
// The native envelope keeps its shape (no added code); only an overflow's wording changes, so
|
|
1092
1160
|
// Claude Code recognizes it and compacts (010).
|
|
1093
1161
|
// Only a 400/413 refusal: the shared classifier also files a 429 "too many tokens per minute"
|
|
1094
1162
|
// under context_length_exceeded, and that one must stay a rate limit.
|
|
1095
|
-
const
|
|
1163
|
+
const legacyOverflow = !replayRefusal && (response.status === 400 || response.status === 413)
|
|
1096
1164
|
&& !isThroughputLimitText(safeMessage)
|
|
1097
1165
|
&& (classified.code === "context_length_exceeded" || upstreamCode === "context_length_exceeded"
|
|
1098
1166
|
|| isContextOverflowText(safeMessage));
|
|
1099
|
-
const
|
|
1100
|
-
|
|
1101
|
-
overflow ? claudePromptTooLongMessage(safeMessage) : safeMessage,
|
|
1167
|
+
const legacy = anthropicErrorBody(status,
|
|
1168
|
+
legacyOverflow ? claudePromptTooLongMessage(safeMessage) : safeMessage,
|
|
1102
1169
|
transient ? "overloaded_error" : upstreamType,
|
|
1103
1170
|
replayRefusal ? UPSTREAM_RESET_REPLAY_REFUSED_CODE : undefined,
|
|
1104
|
-
)
|
|
1171
|
+
);
|
|
1172
|
+
const overflow = messagesOverflowPresentation((legacy.error as Rec).message);
|
|
1173
|
+
const out = new Response(JSON.stringify(ownedAnthropicErrorPayload({
|
|
1174
|
+
status, type: transient ? "overloaded_error" : upstreamType,
|
|
1175
|
+
code: replayRefusal ? UPSTREAM_RESET_REPLAY_REFUSED_CODE : undefined,
|
|
1176
|
+
evidence: { status: response.status, type: upstreamType, code: upstreamCode, message: safeMessage }, overflow,
|
|
1177
|
+
...(replayRefusal ? { contract: "replay_refused" as const } : {}),
|
|
1178
|
+
...(clientZenMessage === undefined ? {} : { localError: markProxyError({ message: clientZenMessage }) }),
|
|
1179
|
+
})), { status, headers });
|
|
1180
|
+
attachComboFailureEvidence(out, JSON.stringify(legacy));
|
|
1105
1181
|
return replayRefusal ? retainReplayRefusal(out) : out;
|
|
1106
1182
|
}
|
|
1107
1183
|
|
|
@@ -1,14 +1,28 @@
|
|
|
1
|
-
/**
|
|
2
|
-
export function upstreamMessagesRequestIdHeaders(
|
|
3
|
-
const requestId = upstream.get("request-id");
|
|
4
|
-
return requestId && /^req_[A-Za-z0-9_-]{1,128}$/.test(requestId)
|
|
5
|
-
? { "request-id": requestId }
|
|
6
|
-
: {};
|
|
7
|
-
}
|
|
1
|
+
/** Messages metadata contains only IDs generated by the proxy ledger wrapper. */
|
|
2
|
+
export function upstreamMessagesRequestIdHeaders(_upstream: Headers): Record<string, string> { return {}; }
|
|
8
3
|
|
|
9
|
-
/**
|
|
10
|
-
export function retainUpstreamMessagesRequestId(response: Response,
|
|
11
|
-
|
|
12
|
-
if (requestId) response.headers.set("request-id", requestId);
|
|
4
|
+
/** Preserve the newly constructed response and its lifecycle markers. */
|
|
5
|
+
export function retainUpstreamMessagesRequestId(response: Response, _upstream: Headers): Response {
|
|
6
|
+
response.headers.delete("request-id");
|
|
13
7
|
return response;
|
|
14
8
|
}
|
|
9
|
+
|
|
10
|
+
const SUCCESS_MEDIA_TYPES = new Map([
|
|
11
|
+
["application/json", "application/json"], ["text/plain", "text/plain"], ["text/event-stream", "text/event-stream"],
|
|
12
|
+
]);
|
|
13
|
+
const SUCCESS_CHARSETS = new Map([["utf-8", "utf-8"], ["us-ascii", "us-ascii"]]);
|
|
14
|
+
|
|
15
|
+
/** Re-render only supported media types and charset parameters for successful bodies. */
|
|
16
|
+
export function messagesSuccessContentType(headers: Headers): string {
|
|
17
|
+
const raw = headers.get("content-type") ?? "";
|
|
18
|
+
if (raw.length > 128) return "application/octet-stream";
|
|
19
|
+
const [media, ...parameters] = raw.toLowerCase().split(";");
|
|
20
|
+
const type = SUCCESS_MEDIA_TYPES.get(media!.trim());
|
|
21
|
+
if (!type) return "application/octet-stream";
|
|
22
|
+
for (const parameter of parameters) {
|
|
23
|
+
const match = /^\s*charset\s*=\s*(?:"([^"\s]+)"|([^"\s]+))\s*$/.exec(parameter);
|
|
24
|
+
const charset = match && SUCCESS_CHARSETS.get(match[1] ?? match[2]!);
|
|
25
|
+
if (charset) return `${type}; charset=${charset}`;
|
|
26
|
+
}
|
|
27
|
+
return type;
|
|
28
|
+
}
|