@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,8 @@
|
|
|
1
|
+
import { comboLogLabel, comboTargetLogLabel } from "../../combos/resolve";
|
|
2
|
+
import { clientFacingModelLabel, clientFacingModelText } from "../../lib/error-destination";
|
|
3
|
+
import { projectLocalModelRefusalLog } from "../request-log-failure-detail";
|
|
4
|
+
import { carryProxyErrorContext, hasProxyErrorMessage, markProxyError } from "../../lib/client-error-body";
|
|
5
|
+
import { classifyUpstreamCondition } from "../../lib/upstream-condition";
|
|
1
6
|
import { effectiveAzureOutputBudget } from "../../adapters/azure";
|
|
2
7
|
import { buildResponsesTransport } from "../../adapters/openai-responses/transport";
|
|
3
8
|
import { isMetaAiResponsesDestination } from "../../responses/muse-tool-name-alias";
|
|
@@ -54,7 +59,6 @@ import {
|
|
|
54
59
|
} from "../../combos";
|
|
55
60
|
import { formatErrorResponse } from "../../bridge";
|
|
56
61
|
import { SEND_BUDGET_EXHAUSTED_CODE } from "../../lib/errors";
|
|
57
|
-
import { redactSecretString, sanitizeLogMetadataString } from "../../lib/redact";
|
|
58
62
|
import {
|
|
59
63
|
expandPreviousResponseInput,
|
|
60
64
|
previousResponseReplayFailure,
|
|
@@ -383,19 +387,22 @@ export async function executeComboResponses(
|
|
|
383
387
|
options: HandleResponsesOptions & { translatorBudget: TranslatorBudget },
|
|
384
388
|
requestDispatchers: ResponsesDispatchers,
|
|
385
389
|
): Promise<Response> {
|
|
390
|
+
const clientModelLabel = options.clientModelLabel ?? clientFacingModelLabel(undefined);
|
|
391
|
+
const responseModel = clientFacingModelText(clientModelLabel);
|
|
386
392
|
const requestedModel = options.mainHardLockFallbackOverride?.sourceModel
|
|
387
393
|
?? (typeof (rawBody as { model?: unknown } | null)?.model === "string"
|
|
388
394
|
? (rawBody as { model: string }).model
|
|
389
395
|
: `combo/${comboId}`);
|
|
396
|
+
if (requestedModel !== responseModel) options = { ...options, clientResponseModelLabel: clientModelLabel };
|
|
390
397
|
Object.assign(logCtx, {
|
|
391
|
-
requestedModel,
|
|
392
|
-
model:
|
|
398
|
+
requestedModel: responseModel,
|
|
399
|
+
model: responseModel,
|
|
393
400
|
provider: "combo",
|
|
394
401
|
comboId,
|
|
395
402
|
});
|
|
396
403
|
const combo = getCombo(config, comboId);
|
|
397
404
|
if (!combo) {
|
|
398
|
-
return formatErrorResponse(404, "invalid_request_error",
|
|
405
|
+
return formatErrorResponse(404, "invalid_request_error", "Unknown combo");
|
|
399
406
|
}
|
|
400
407
|
// Resolve against the original request once; every bridge candidate receives the same trusted
|
|
401
408
|
// result after its provisional Authorization is removed, including an explicitly keyless result.
|
|
@@ -459,7 +466,7 @@ export async function executeComboResponses(
|
|
|
459
466
|
);
|
|
460
467
|
}
|
|
461
468
|
if (combo.imageInput === "disabled" && comboRequestHasImageInput(body)) {
|
|
462
|
-
return formatErrorResponse(400, "invalid_request_error",
|
|
469
|
+
return formatErrorResponse(400, "invalid_request_error", "This combo does not accept image input");
|
|
463
470
|
}
|
|
464
471
|
const comboReplaySnapshot = {
|
|
465
472
|
sourceBody: body,
|
|
@@ -509,9 +516,11 @@ export async function executeComboResponses(
|
|
|
509
516
|
attempt: childLog.activeAttempt,
|
|
510
517
|
});
|
|
511
518
|
}
|
|
519
|
+
carryProxyErrorContext(childLog, logCtx);
|
|
512
520
|
Object.assign(logCtx, childLog, {
|
|
513
|
-
|
|
514
|
-
|
|
521
|
+
client: logCtx.client,
|
|
522
|
+
requestedModel: responseModel,
|
|
523
|
+
model: responseModel,
|
|
515
524
|
provider: "combo",
|
|
516
525
|
comboId,
|
|
517
526
|
routeDecision: logCtx.routeDecision,
|
|
@@ -519,6 +528,11 @@ export async function executeComboResponses(
|
|
|
519
528
|
activeAttempt: undefined,
|
|
520
529
|
activeAttemptStartedAt: undefined,
|
|
521
530
|
});
|
|
531
|
+
if (requestedModel !== responseModel) {
|
|
532
|
+
projectLocalModelRefusalLog(logCtx, clientModelLabel);
|
|
533
|
+
logCtx.model = responseModel; logCtx.requestedModel = responseModel;
|
|
534
|
+
if (options.clientModelLabel) logCtx.jevDecision = undefined;
|
|
535
|
+
}
|
|
522
536
|
};
|
|
523
537
|
|
|
524
538
|
const unreadableEncryptedAgentTask = hasUnreadableEncryptedAgentTask(
|
|
@@ -678,7 +692,7 @@ export async function executeComboResponses(
|
|
|
678
692
|
{ parentThreadId: inboundClientThreadId },
|
|
679
693
|
);
|
|
680
694
|
if (!options.abortSignal?.aborted && onlyMuseToolIncompatible()) {
|
|
681
|
-
return comboUnavailableResponse(
|
|
695
|
+
return comboUnavailableResponse("No available targets for combo; targets cannot preserve mandatory tool_choice");
|
|
682
696
|
}
|
|
683
697
|
return options.abortSignal?.aborted
|
|
684
698
|
? clientCancelledResponse()
|
|
@@ -698,7 +712,7 @@ export async function executeComboResponses(
|
|
|
698
712
|
if (protocolRefusal) return protocolRefusal;
|
|
699
713
|
if (onlyReplayIncompatibleTargetsRemain()) return targetIncompatibleResponse();
|
|
700
714
|
if (!options.abortSignal?.aborted && onlyMuseToolIncompatible()) {
|
|
701
|
-
return comboUnavailableResponse(
|
|
715
|
+
return comboUnavailableResponse("No available targets for combo; targets cannot preserve mandatory tool_choice");
|
|
702
716
|
}
|
|
703
717
|
return options.abortSignal?.aborted
|
|
704
718
|
? clientCancelledResponse()
|
|
@@ -812,7 +826,7 @@ export async function executeComboResponses(
|
|
|
812
826
|
if (pinReuse?.released) decision = { ...decision, pinReason: pinReuse.released };
|
|
813
827
|
jevDecision = decision;
|
|
814
828
|
pick = { ...selected.pick, attempted: [targetKey(selected.pick.target)] };
|
|
815
|
-
logCtx.jevDecision = normalizePersistedJevDecision({
|
|
829
|
+
logCtx.jevDecision = !options.clientModelLabel || requestedModel === responseModel ? normalizePersistedJevDecision({
|
|
816
830
|
version: 1,
|
|
817
831
|
comboId,
|
|
818
832
|
selected: {
|
|
@@ -831,10 +845,10 @@ export async function executeComboResponses(
|
|
|
831
845
|
...(decision.quota ? { quota: decision.quota } : {}),
|
|
832
846
|
...(decision.pinned ? { pinned: true } : {}),
|
|
833
847
|
...(decision.pinReason ? { pinReason: decision.pinReason } : {}),
|
|
834
|
-
});
|
|
848
|
+
}) : undefined;
|
|
835
849
|
console.debug("[combo] JEV decision", {
|
|
836
850
|
backend: decision.backend,
|
|
837
|
-
|
|
851
|
+
target: comboTargetLogLabel(config, comboId, pick.target),
|
|
838
852
|
effort: decision.effort,
|
|
839
853
|
gate: decision.gate,
|
|
840
854
|
latencyMs: decision.latencyMs,
|
|
@@ -853,7 +867,7 @@ export async function executeComboResponses(
|
|
|
853
867
|
}
|
|
854
868
|
// One immutable combo selection trace, before any child dispatch; child
|
|
855
869
|
// adoption below must never replace it with a concrete child route trace.
|
|
856
|
-
const decision = comboRouteDecisionTrace(config, comboId, pick,
|
|
870
|
+
const decision = comboRouteDecisionTrace(config, comboId, pick, responseModel);
|
|
857
871
|
const selectedReason = options.memoryModelPhase
|
|
858
872
|
? memoryModelRouteReason(options.memoryModelPhase)
|
|
859
873
|
: toolLoopPin ? COMBO_TOOL_LOOP_PIN_REASON : jevDecision?.pinned ? JEV_SESSION_PIN_ROUTE_REASON : undefined;
|
|
@@ -931,7 +945,7 @@ export async function executeComboResponses(
|
|
|
931
945
|
}
|
|
932
946
|
const remainingQuotaCooldownMs = quotaCooldownUntil === undefined ? 0 : quotaCooldownUntil - Date.now();
|
|
933
947
|
return remainingQuotaCooldownMs > 0
|
|
934
|
-
? comboUnavailableResponse(
|
|
948
|
+
? comboUnavailableResponse("No available targets for combo", {
|
|
935
949
|
retryAfter: String(Math.max(1, Math.ceil(remainingQuotaCooldownMs / 1000))),
|
|
936
950
|
}) : lastFailure;
|
|
937
951
|
};
|
|
@@ -1287,9 +1301,11 @@ export async function executeComboResponses(
|
|
|
1287
1301
|
attemptRetained = true;
|
|
1288
1302
|
noteComboSuccess(comboId, combo, pick.target, pick.writerGeneration);
|
|
1289
1303
|
settleComboReprobeSuccess(pick);
|
|
1304
|
+
carryProxyErrorContext(childLog, logCtx);
|
|
1290
1305
|
Object.assign(logCtx, childLog, {
|
|
1291
|
-
|
|
1292
|
-
|
|
1306
|
+
client: logCtx.client,
|
|
1307
|
+
requestedModel: responseModel,
|
|
1308
|
+
model: responseModel,
|
|
1293
1309
|
provider: "combo",
|
|
1294
1310
|
comboId,
|
|
1295
1311
|
routeDecision: logCtx.routeDecision,
|
|
@@ -1315,6 +1331,7 @@ export async function executeComboResponses(
|
|
|
1315
1331
|
try {
|
|
1316
1332
|
failure = consumedChildFailure
|
|
1317
1333
|
?? await consumeComboFailure(response, options.abortSignal);
|
|
1334
|
+
if (hasProxyErrorMessage(childLog, failure.upstreamMessage ?? "", { type: failure.upstreamType, code: failure.upstreamCode })) markProxyError(failure.response);
|
|
1318
1335
|
if (preflightModelRefusal !== undefined) failure = { ...failure, codexModelRefusal: preflightModelRefusal };
|
|
1319
1336
|
} catch (error) {
|
|
1320
1337
|
if (options.abortSignal?.aborted) {
|
|
@@ -1425,7 +1442,7 @@ export async function executeComboResponses(
|
|
|
1425
1442
|
adoptFailedChildLog(childLog);
|
|
1426
1443
|
if (classifyOverflow && failureDecision === "stop") {
|
|
1427
1444
|
return wantsStream
|
|
1428
|
-
? streamingContextOverflowResponse(
|
|
1445
|
+
? streamingContextOverflowResponse(responseModel, options.translatorBudget)
|
|
1429
1446
|
: jsonContextOverflowResponse();
|
|
1430
1447
|
}
|
|
1431
1448
|
return lastFailure;
|
|
@@ -1434,7 +1451,7 @@ export async function executeComboResponses(
|
|
|
1434
1451
|
adoptFailedChildLog(childLog);
|
|
1435
1452
|
if (classifyOverflow) {
|
|
1436
1453
|
return wantsStream
|
|
1437
|
-
? streamingContextOverflowResponse(
|
|
1454
|
+
? streamingContextOverflowResponse(responseModel, options.translatorBudget)
|
|
1438
1455
|
: jsonContextOverflowResponse();
|
|
1439
1456
|
}
|
|
1440
1457
|
return lastFailure;
|
|
@@ -1445,14 +1462,13 @@ export async function executeComboResponses(
|
|
|
1445
1462
|
contextFailure = { childLog, response: formatErrorResponse(400, "invalid_request_error",
|
|
1446
1463
|
failure.upstreamMessage ?? failure.classificationText, { code: "context_length_exceeded", classified: true }) };
|
|
1447
1464
|
}
|
|
1448
|
-
// A bare status made a revoked credential read as a provider outage. Log
|
|
1449
|
-
//
|
|
1450
|
-
const failureReason =
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
);
|
|
1465
|
+
// A bare status made a revoked credential read as a provider outage. Log the classified
|
|
1466
|
+
// condition (a closed member), never upstream-authored code or message text.
|
|
1467
|
+
const failureReason = classifyUpstreamCondition({
|
|
1468
|
+
status: failure.response.status, code: failure.upstreamCode, type: failure.upstreamType, message: failure.upstreamMessage,
|
|
1469
|
+
});
|
|
1454
1470
|
console.warn(
|
|
1455
|
-
`[combo] ${comboId}: ${
|
|
1471
|
+
`[combo] ${comboLogLabel(config, comboId)}: ${comboTargetLogLabel(config, comboId, pick.target)} failed with ${failure.response.status}`
|
|
1456
1472
|
+ ` after ${Date.now() - started}ms${failureReason ? `: ${failureReason}` : ""}`,
|
|
1457
1473
|
);
|
|
1458
1474
|
const failureNow = Date.now();
|
|
@@ -1575,11 +1591,11 @@ export async function executeComboResponses(
|
|
|
1575
1591
|
) {
|
|
1576
1592
|
if (localAdmissionRefusals?.length) logCtx.errorCode = "input_admission_refused";
|
|
1577
1593
|
const localMessage = localAdmissionRefusals?.length
|
|
1578
|
-
? `opencodex refused this turn locally; nothing was sent upstream. No target of combo
|
|
1594
|
+
? `opencodex refused this turn locally; nothing was sent upstream. No target of this combo `
|
|
1579
1595
|
+ `that was tried can fit its input: ${localAdmissionRefusals.join(" ")} Compact the conversation before retrying.`
|
|
1580
1596
|
: undefined;
|
|
1581
1597
|
return (rawBody as { stream?: unknown } | null)?.stream === true
|
|
1582
|
-
? streamingContextOverflowResponse(
|
|
1598
|
+
? streamingContextOverflowResponse(responseModel, options.translatorBudget, localMessage)
|
|
1583
1599
|
: jsonContextOverflowResponse(localMessage);
|
|
1584
1600
|
}
|
|
1585
1601
|
return failure;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { ComboExclusionReasons } from "../../combos/resolve";
|
|
2
|
+
import { markProxyError } from "../../lib/client-error-body";
|
|
3
|
+
import { formatClientRetryAfter } from "../../lib/client-retry-after";
|
|
1
4
|
import { readBoundedResponseBody } from "../../lib/bounded-body";
|
|
2
5
|
import { redactSecretString } from "../../lib/redact";
|
|
3
6
|
import { isCyberPolicyMessage, isCyberPolicyCode } from "../../lib/errors";
|
|
@@ -80,18 +83,18 @@ export function normalizeUpstreamErrorText(text: string, fallback: string): Norm
|
|
|
80
83
|
|
|
81
84
|
export function decodeRequestErrorResponse(err: unknown, label: string): Response {
|
|
82
85
|
if (isTranslatorBudgetExceededError(err)) {
|
|
83
|
-
return formatErrorResponse(413, "request_too_large", "request translation buffer exceeded the safe limit", {
|
|
86
|
+
return markProxyError(formatErrorResponse(413, "request_too_large", "request translation buffer exceeded the safe limit", {
|
|
84
87
|
code: "translation_buffer_limit",
|
|
85
|
-
});
|
|
88
|
+
}));
|
|
86
89
|
}
|
|
87
90
|
if (err instanceof UnsupportedContentEncodingError) {
|
|
88
|
-
return formatErrorResponse(415, "invalid_request_error", err.message);
|
|
91
|
+
return markProxyError(formatErrorResponse(415, "invalid_request_error", err.message));
|
|
89
92
|
}
|
|
90
93
|
if (err instanceof DecompressedBodyTooLargeError) {
|
|
91
|
-
return formatErrorResponse(413, "inbound_body_too_large", describeInboundBodyRefusal(err));
|
|
94
|
+
return markProxyError(formatErrorResponse(413, "inbound_body_too_large", describeInboundBodyRefusal(err)), "inbound");
|
|
92
95
|
}
|
|
93
96
|
console.warn(`[${label}] request body decode/parse failed: ${err instanceof Error ? `${err.name}: ${err.message}` : String(err)}`);
|
|
94
|
-
return formatErrorResponse(400, "invalid_request_error", "Invalid JSON body");
|
|
97
|
+
return markProxyError(formatErrorResponse(400, "invalid_request_error", "Invalid JSON body"));
|
|
95
98
|
}
|
|
96
99
|
|
|
97
100
|
|
|
@@ -99,25 +102,25 @@ export function decodeRequestErrorResponse(err: unknown, label: string): Respons
|
|
|
99
102
|
|
|
100
103
|
export function comboUnavailableResponse(
|
|
101
104
|
message: string,
|
|
102
|
-
options?: { retryAfter?: string | null },
|
|
105
|
+
options?: { retryAfter?: string | null; presentation?: "combo" },
|
|
103
106
|
): Response {
|
|
104
107
|
const headers = new Headers({ "Content-Type": "application/json" });
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return new Response(
|
|
108
|
+
// Advice leaves in this proxy's format, whatever form the earliest cooldown was recorded in.
|
|
109
|
+
const advice = formatClientRetryAfter(options?.retryAfter);
|
|
110
|
+
if (advice !== undefined) headers.set("Retry-After", advice);
|
|
111
|
+
return markProxyError(new Response(
|
|
110
112
|
JSON.stringify({
|
|
111
113
|
error: { message, type: "server_error", code: "combo_unavailable" },
|
|
112
114
|
}),
|
|
113
115
|
{ status: 503, headers },
|
|
114
|
-
);
|
|
116
|
+
), options?.presentation);
|
|
115
117
|
}
|
|
116
118
|
|
|
117
119
|
|
|
118
|
-
export function comboUnavailable(comboId: string, now = Date.now(), reasons
|
|
120
|
+
export function comboUnavailable(comboId: string, now = Date.now(), reasons?: ComboExclusionReasons): Response {
|
|
119
121
|
return comboUnavailableResponse(new NoAvailableComboTargetsError(comboId, reasons).message, {
|
|
120
122
|
retryAfter: comboCooldownRetryAfterSeconds(comboId, now),
|
|
123
|
+
presentation: reasons === undefined ? undefined : "combo",
|
|
121
124
|
});
|
|
122
125
|
}
|
|
123
126
|
|
|
@@ -129,7 +132,7 @@ export function comboUnavailable(comboId: string, now = Date.now(), reasons = ""
|
|
|
129
132
|
* response completes (`client_cancelled`).
|
|
130
133
|
*/
|
|
131
134
|
export function clientCancelledResponse(): Response {
|
|
132
|
-
return formatErrorResponse(499, "client_cancelled", "Client cancelled request");
|
|
135
|
+
return markProxyError(formatErrorResponse(499, "client_cancelled", "Client cancelled request"));
|
|
133
136
|
}
|
|
134
137
|
|
|
135
138
|
/**
|
|
@@ -154,10 +157,10 @@ export function anthropicPoolCooldownResponse(
|
|
|
154
157
|
): Response {
|
|
155
158
|
if (refusal.usageLimit !== null && !options.comboAttempt) {
|
|
156
159
|
if (options.logCtx) options.logCtx.errorCode = "usage_limit_reached";
|
|
157
|
-
return formatUsageLimitReachedResponse(refusal.message, refusal.usageLimit.resetsAt, refusal.retryAfterSeconds);
|
|
160
|
+
return markProxyError(formatUsageLimitReachedResponse(refusal.message, refusal.usageLimit.resetsAt, refusal.retryAfterSeconds), refusal.usageLimit.resetsAt === null ? undefined : "usage");
|
|
158
161
|
}
|
|
159
|
-
return formatErrorResponse(429, "rate_limit_error", refusal.retryableMessage,
|
|
160
|
-
refusal.retryAfterSeconds === null ? undefined : { retryAfter: String(refusal.retryAfterSeconds) });
|
|
162
|
+
return markProxyError(formatErrorResponse(429, "rate_limit_error", refusal.retryableMessage,
|
|
163
|
+
refusal.retryAfterSeconds === null ? undefined : { retryAfter: String(refusal.retryAfterSeconds) }));
|
|
161
164
|
}
|
|
162
165
|
|
|
163
166
|
|
|
@@ -166,7 +169,7 @@ export const UNREADABLE_ENCRYPTED_AGENT_TASK_MESSAGE =
|
|
|
166
169
|
|
|
167
170
|
|
|
168
171
|
export function unreadableEncryptedAgentTaskResponse(reason?: AgentTaskRecoveryFailureReason): Response {
|
|
169
|
-
return new Response(
|
|
172
|
+
return markProxyError(new Response(
|
|
170
173
|
JSON.stringify({
|
|
171
174
|
error: {
|
|
172
175
|
message: UNREADABLE_ENCRYPTED_AGENT_TASK_MESSAGE,
|
|
@@ -176,7 +179,7 @@ export function unreadableEncryptedAgentTaskResponse(reason?: AgentTaskRecoveryF
|
|
|
176
179
|
},
|
|
177
180
|
}),
|
|
178
181
|
{ status: 400, headers: { "Content-Type": "application/json" } },
|
|
179
|
-
);
|
|
182
|
+
));
|
|
180
183
|
}
|
|
181
184
|
|
|
182
185
|
|
|
@@ -185,7 +188,7 @@ export const TARGET_INCOMPATIBLE_MESSAGE =
|
|
|
185
188
|
|
|
186
189
|
|
|
187
190
|
export function targetIncompatibleResponse(): Response {
|
|
188
|
-
return new Response(
|
|
191
|
+
return markProxyError(new Response(
|
|
189
192
|
JSON.stringify({
|
|
190
193
|
error: {
|
|
191
194
|
message: TARGET_INCOMPATIBLE_MESSAGE,
|
|
@@ -194,5 +197,5 @@ export function targetIncompatibleResponse(): Response {
|
|
|
194
197
|
},
|
|
195
198
|
}),
|
|
196
199
|
{ status: 400, headers: { "Content-Type": "application/json" } },
|
|
197
|
-
);
|
|
200
|
+
));
|
|
198
201
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { carryProxyError } from "../../lib/client-error-body";
|
|
1
2
|
import type { TranslatorBudget } from "../../lib/translator-budget";
|
|
2
3
|
import { carryResponseToolOwnership } from "./response-tool-ownership";
|
|
3
4
|
import { finalizeTranslatorBudgetResponse } from "../../lib/translator-budget";
|
|
4
5
|
import { carryReplayRefusal, isNonReplayableResponse, markResponseNonReplayable } from "../../lib/upstream-retry";
|
|
5
6
|
import { isVerifiedModelNotInPlanResponse, markVerifiedModelNotInPlanResponse } from "../../lib/errors";
|
|
6
7
|
import { carryCodexAccountCooldownResponse } from "../../codex/account-cooldown-response";
|
|
8
|
+
import { carryFormattedQuotaSource } from "../../bridge/errors";
|
|
7
9
|
import {
|
|
8
10
|
isNativePassthroughSseResponse,
|
|
9
11
|
markNativePassthroughSseResponse,
|
|
@@ -43,7 +45,7 @@ export const UPSTREAM_JSON_BODY_READ_OPTIONS = {
|
|
|
43
45
|
|
|
44
46
|
|
|
45
47
|
export function finalizeOwnedTranslatorBudget(response: Response, budget: TranslatorBudget, signal?: AbortSignal): Response {
|
|
46
|
-
const finalizedResponse = finalizeTranslatorBudgetResponse(response, budget, signal);
|
|
48
|
+
const finalizedResponse = carryProxyError(response, finalizeTranslatorBudgetResponse(response, budget, signal));
|
|
47
49
|
if (isNativePassthroughSseResponse(response)) {
|
|
48
50
|
markNativePassthroughSseResponse(finalizedResponse);
|
|
49
51
|
}
|
|
@@ -55,7 +57,7 @@ export function finalizeOwnedTranslatorBudget(response: Response, budget: Transl
|
|
|
55
57
|
if (isVerifiedModelNotInPlanResponse(response)) markVerifiedModelNotInPlanResponse(finalizedResponse);
|
|
56
58
|
if (runTurnAdapterSseResponses.has(response)) runTurnAdapterSseResponses.add(finalizedResponse);
|
|
57
59
|
carryCodexAccountCooldownResponse(response, finalizedResponse);
|
|
58
|
-
return carryResponseToolOwnership(response, finalizedResponse);
|
|
60
|
+
return carryResponseToolOwnership(response, carryFormattedQuotaSource(response, finalizedResponse));
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
/** Release a serving-account slot when the client body ends, errors or is cancelled. */
|
|
@@ -75,6 +77,7 @@ export function finalizeAccountLease(response: Response, release: () => void, on
|
|
|
75
77
|
async cancel(reason) { onCancel?.(); try { await reader.cancel(reason); } finally { finish(); } },
|
|
76
78
|
});
|
|
77
79
|
const wrapped = new Response(body, { status: response.status, statusText: response.statusText, headers: response.headers });
|
|
80
|
+
carryProxyError(response, wrapped);
|
|
78
81
|
if (isNonReplayableResponse(response)) markResponseNonReplayable(wrapped);
|
|
79
82
|
if (isVerifiedModelNotInPlanResponse(response)) markVerifiedModelNotInPlanResponse(wrapped);
|
|
80
83
|
if (isNativePassthroughSseResponse(response)) markNativePassthroughSseResponse(wrapped);
|
|
@@ -83,7 +86,7 @@ export function finalizeAccountLease(response: Response, release: () => void, on
|
|
|
83
86
|
if (runTurnAdapterSseResponses.has(response)) runTurnAdapterSseResponses.add(wrapped);
|
|
84
87
|
// Retained compaction delivers through this lease wrapper; keep a local cooldown refusal local (#7850).
|
|
85
88
|
carryCodexAccountCooldownResponse(response, wrapped);
|
|
86
|
-
return carryResponseToolOwnership(response, carryReplayRefusal(response, wrapped));
|
|
89
|
+
return carryResponseToolOwnership(response, carryReplayRefusal(response, carryFormattedQuotaSource(response, wrapped)));
|
|
87
90
|
}
|
|
88
91
|
|
|
89
92
|
|
|
@@ -156,6 +156,7 @@ export async function applyFinalRouteRequestNormalization(args: {
|
|
|
156
156
|
|
|
157
157
|
// Only Anthropic message routes retain the Codex-facing selector. Other providers must keep
|
|
158
158
|
// their existing response.model contract even when their public and wire model ids differ.
|
|
159
|
+
// Request preparation assigns the original client label separately for synthetic turns.
|
|
159
160
|
const responseModelId = parsed.modelId;
|
|
160
161
|
const preserveAnthropicResponseModel = route.providerName === "anthropic"
|
|
161
162
|
|| route.provider.adapter === "anthropic";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ClientFacingModelLabel } from "../../lib/error-destination";
|
|
1
2
|
import type { CodexAccountModelRefusal } from "../../combos/failover";
|
|
2
3
|
import type { NativeResponseControl } from "./native-response-control";
|
|
3
4
|
import type { AdapterEvent, OcxUsage, OcxProviderContinuationState, OcxConfig } from "../../types";
|
|
@@ -96,6 +97,10 @@ export interface DirectRequestOption {
|
|
|
96
97
|
}
|
|
97
98
|
|
|
98
99
|
export interface HandleResponsesOptions {
|
|
100
|
+
/** Original caller label, carried through synthetic children without route substitution. */
|
|
101
|
+
clientModelLabel?: ClientFacingModelLabel;
|
|
102
|
+
/** Original client envelope label when a combo was selected by a synthetic rewrite. */
|
|
103
|
+
clientResponseModelLabel?: ClientFacingModelLabel;
|
|
99
104
|
/** Immutable caller scope inherited by a capability-authenticated internal sidecar request. */
|
|
100
105
|
admissionScope?: AdmissionModelScope;
|
|
101
106
|
/** Captured synchronously at ingress, before parsing or child replay can suspend. */
|
|
@@ -118,6 +123,8 @@ export interface HandleResponsesOptions {
|
|
|
118
123
|
claudeGoAffinity?: { sessionLane?: string };
|
|
119
124
|
/** Validated Claude metadata identity; projected only into final canonical attempt headers. */
|
|
120
125
|
claudeNativeSessionId?: string;
|
|
126
|
+
/** Private Claude bridge pool identity (validated, principal-scoped when derived); completes session-id/thread-id only on Codex account-selection headers. */
|
|
127
|
+
claudeBridgePoolSession?: string;
|
|
121
128
|
/** Original live policy owner; separate from caller-specific routing/sidecar snapshots. */
|
|
122
129
|
codexAuthPolicy?: CodexAuthPolicyConfig;
|
|
123
130
|
turnAdmissionLease?: AdmissionLease;
|
|
@@ -191,6 +198,8 @@ export interface HandleResponsesOptions {
|
|
|
191
198
|
anthropicServerTools?: readonly Record<string, unknown>[];
|
|
192
199
|
/** The Claude client's replayable server-tool exchanges (`replayedAnthropicServerBlocks`); same scope. */
|
|
193
200
|
anthropicServerReplay?: ReadonlyMap<string, readonly Record<string, unknown>[]>;
|
|
201
|
+
/** The caller's cached system prefix (`systemCachePrefix`); same scope. */
|
|
202
|
+
anthropicSystemCachePrefix?: string;
|
|
194
203
|
/** Metadata-qualified Messages discovery evidence, never caller JSON or a preselected destination. */
|
|
195
204
|
anthropicToolLoadingSource?: Readonly<Record<string, unknown>>;
|
|
196
205
|
/** Droid's per-request effort default; each concrete combo or policy target applies it only if its ladder allows it. */
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { markProxyError } from "../../lib/client-error-body";
|
|
1
2
|
import { supportsNativeResponsesCompactionTrigger } from "../../providers/openai-tiers";
|
|
2
3
|
import type { OcxConfig } from "../../types";
|
|
3
4
|
import type { RequestLogContext } from "../request-log";
|
|
@@ -44,7 +45,7 @@ export async function handleResponsesInner(
|
|
|
44
45
|
const requestState = await prepareResponsesRequest(requestContext, admissionState, requestDispatchers);
|
|
45
46
|
if (requestState instanceof Response) return requestState;
|
|
46
47
|
const transportState = await prepareResponsesTransport(requestContext, admissionState, requestState);
|
|
47
|
-
if (transportState instanceof Response) return transportState;
|
|
48
|
+
if (transportState instanceof Response) return markProxyError(transportState);
|
|
48
49
|
options.onCompactionRecoveryRoute?.(requestState.route);
|
|
49
50
|
if (requestState.parsed._compactionRequest && options.compactionRecoveryKind !== "compaction-v1"
|
|
50
51
|
&& (requestState.parsed._portableCompaction || !supportsNativeResponsesCompactionTrigger(requestState.route.provider))) {
|
|
@@ -54,7 +55,7 @@ export async function handleResponsesInner(
|
|
|
54
55
|
}
|
|
55
56
|
const execute = async (): Promise<Response> => {
|
|
56
57
|
const sidecarState = await prepareResponsesSidecarAuth(requestContext, requestState, transportState);
|
|
57
|
-
if (sidecarState instanceof Response) return sidecarState;
|
|
58
|
+
if (sidecarState instanceof Response) return markProxyError(sidecarState);
|
|
58
59
|
const responseEffects = createResponsesEffects(
|
|
59
60
|
requestContext,
|
|
60
61
|
admissionState,
|
|
@@ -62,7 +63,7 @@ export async function handleResponsesInner(
|
|
|
62
63
|
sidecarState,
|
|
63
64
|
);
|
|
64
65
|
const sendBudgetState = createResponsesSendBudget(requestContext);
|
|
65
|
-
if (sendBudgetState instanceof Response) return sendBudgetState;
|
|
66
|
+
if (sendBudgetState instanceof Response) return markProxyError(sendBudgetState);
|
|
66
67
|
if ("passthrough" in transportState.adapter && transportState.adapter.passthrough && !sidecarState.routedCompaction) {
|
|
67
68
|
const passthroughResult = await executePassthroughResponse(
|
|
68
69
|
requestContext,
|
|
@@ -204,6 +204,8 @@ export interface EmptyCompletionGuardOptions {
|
|
|
204
204
|
* Receives no arguments — the request must not be modified between attempts.
|
|
205
205
|
*/
|
|
206
206
|
continuation: () => AsyncIterable<AdapterEvent> | Promise<AsyncIterable<AdapterEvent>>;
|
|
207
|
+
/** Preserve locally classified retry failures whose precise status must reach the caller. */
|
|
208
|
+
preserveRetryError?: (event: AdapterEvent) => boolean;
|
|
207
209
|
/** How many times an empty completion is retried; default 1 (the router's single retry). */
|
|
208
210
|
maxRetries?: number;
|
|
209
211
|
}
|
|
@@ -317,7 +319,8 @@ export async function* guardEmptyCompletionEventStream(
|
|
|
317
319
|
terminalSeen = true;
|
|
318
320
|
break;
|
|
319
321
|
}
|
|
320
|
-
if (retries > 0 && event.status !== 499 && event.replaySafeBeforeOutput !== true
|
|
322
|
+
if (retries > 0 && event.status !== 499 && event.replaySafeBeforeOutput !== true
|
|
323
|
+
&& !options.preserveRetryError?.(event)) {
|
|
321
324
|
// The retry failed upstream. Its body cannot reach the client (the
|
|
322
325
|
// 200 head went out with the first attempt), so state the failure in
|
|
323
326
|
// the stream's own error framing — same move as the router's
|
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
import { redactSecretString } from "../../lib/redact";
|
|
34
34
|
import { outboundCredentials } from "../../lib/outbound-credential-registry";
|
|
35
35
|
import { compressUpstreamRequestBody, isCanonicalCodexResponsesUrl } from "./request-compression";
|
|
36
|
+
import { redeemOutboundTurnState, TURN_STATE_BINDING_INIT, turnStateBinding } from "../turn-state-handles";
|
|
36
37
|
|
|
37
38
|
export { withUpstreamHttpVersion };
|
|
38
39
|
|
|
@@ -382,6 +383,10 @@ export function providerFetch(
|
|
|
382
383
|
// else keeps the provider's HTTP fetch. See ws-upstream.ts for the details.
|
|
383
384
|
const unobserved = async (input: Parameters<typeof globalThis.fetch>[0], init?: RequestInit,
|
|
384
385
|
reacquirePacing?: (provider: OcxProviderConfig, modelId?: string) => Promise<void>) => {
|
|
386
|
+
// Turn-state handles are redeemed here, at the send, where the admitted caller, the provider and
|
|
387
|
+
// the outbound account are all settled; a handle bound to anything else is not forwarded.
|
|
388
|
+
const sendHeaders = (sent?: RequestInit) => new Headers(sent?.headers ?? (input instanceof Request ? input.headers : undefined));
|
|
389
|
+
init = redeemOutboundTurnState(init, turnStateBinding(providerName, sendHeaders(init)));
|
|
385
390
|
const upstreamWebsocket = provider.upstreamWebsocket;
|
|
386
391
|
if (!options.httpOnly && typeof input === "string" && init
|
|
387
392
|
&& shouldUseCodexWsUpstream(input, init, runtime, upstreamWebsocket)) {
|
|
@@ -412,7 +417,8 @@ export function providerFetch(
|
|
|
412
417
|
};
|
|
413
418
|
const fallback = ((url: Parameters<typeof globalThis.fetch>[0], fallbackInit?: RequestInit) =>
|
|
414
419
|
httpFetch(url, { ...fallbackInit, [WS_FALLBACK_RECEIPT]: notifyOnce } as RequestInit, reacquirePacing, null)) as typeof globalThis.fetch;
|
|
415
|
-
const wsSend = codexWsExecutor((url: Parameters<typeof globalThis.fetch>[0], wsInit?: RequestInit) => codexWsUpstreamFetch(String(url),
|
|
420
|
+
const wsSend = codexWsExecutor((url: Parameters<typeof globalThis.fetch>[0], wsInit?: RequestInit) => codexWsUpstreamFetch(String(url),
|
|
421
|
+
{ ...(wsInit ?? init), [TURN_STATE_BINDING_INIT]: turnStateBinding(providerName, sendHeaders(wsInit ?? init)) } as RequestInit,
|
|
416
422
|
fallback, runtime, options.onCodexWsQuota, options.beforeDispatch, options.nativeControl,
|
|
417
423
|
async () => { (await waitForPacing(init.signal ?? undefined))?.release(); }, notifyOnce, options.preOutputRefusalHold),
|
|
418
424
|
{ provider, http: markEgressTransparentExecutor(fallback) });
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { clientFacingModelText, type ClientFacingModelLabel } from "../../lib/error-destination";
|
|
1
2
|
/**
|
|
2
3
|
* Pre-dispatch input admission (#1412).
|
|
3
4
|
*
|
|
@@ -63,6 +64,8 @@ export interface InputAdmissionResult {
|
|
|
63
64
|
estimatedTokens: number;
|
|
64
65
|
/** Resolved ceiling, or null when nothing could be resolved (=> always admitted). */
|
|
65
66
|
ceiling: number | null;
|
|
67
|
+
/** Actual shared context window when an input-only ceiling differs. */
|
|
68
|
+
contextWindow?: number | null;
|
|
66
69
|
/** Output space reserved by the combo preflight; absent on the loose direct gate. */
|
|
67
70
|
requiredOutputHeadroom?: number;
|
|
68
71
|
}
|
|
@@ -310,6 +313,7 @@ export function checkComboTargetInputAdmission(
|
|
|
310
313
|
estimatedTokens,
|
|
311
314
|
ceiling,
|
|
312
315
|
requiredOutputHeadroom,
|
|
316
|
+
...(window !== ceiling ? { contextWindow: window } : {}),
|
|
313
317
|
};
|
|
314
318
|
}
|
|
315
319
|
|
|
@@ -325,8 +329,30 @@ export function checkInputAdmission(
|
|
|
325
329
|
modelId: string,
|
|
326
330
|
nativeContextCap?: NativeContextLimitsInput,
|
|
327
331
|
): InputAdmissionResult {
|
|
328
|
-
const ceiling =
|
|
332
|
+
const { window, ceiling } = resolveContextLimits(provider, providerName, modelId, nativeContextCap);
|
|
329
333
|
if (ceiling === null) return { admitted: true, estimatedTokens: 0, ceiling: null };
|
|
330
334
|
const estimatedTokens = estimateInputTokens(parsed, modelId, provider);
|
|
331
|
-
return { admitted: estimatedTokens <= ceiling * ADMISSION_TOLERANCE, estimatedTokens, ceiling
|
|
335
|
+
return { admitted: estimatedTokens <= ceiling * ADMISSION_TOLERANCE, estimatedTokens, ceiling,
|
|
336
|
+
...(window !== ceiling ? { contextWindow: window } : {}) };
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
export function inputAdmissionRefusalMessage(input: InputAdmissionResult, model: ClientFacingModelLabel): string {
|
|
340
|
+
const count = (value: number | null) => value !== null && Number.isFinite(value) && value >= 0 ? Math.trunc(value) : 0;
|
|
341
|
+
const label = clientFacingModelText(model);
|
|
342
|
+
const estimate = count(input.estimatedTokens);
|
|
343
|
+
const ceiling = count(input.ceiling);
|
|
344
|
+
if (input.contextWindow !== undefined && input.estimatedTokens > ceiling) {
|
|
345
|
+
const window = input.contextWindow === null ? "" : `; context window: ${count(input.contextWindow)} tokens`;
|
|
346
|
+
return `Estimated input (~${estimate} tokens) exceeds the input limit of ${label} (${ceiling} tokens${window}). `
|
|
347
|
+
+ "Start a new session or choose a model with a larger input limit.";
|
|
348
|
+
}
|
|
349
|
+
const window = count(input.contextWindow ?? input.ceiling);
|
|
350
|
+
const inputLimit = input.contextWindow !== undefined ? `; input limit: ${ceiling} tokens` : "";
|
|
351
|
+
return input.requiredOutputHeadroom !== undefined
|
|
352
|
+
? `Estimated input (~${estimate} tokens) plus ${count(input.requiredOutputHeadroom)} `
|
|
353
|
+
+ `tokens of requested output headroom cannot fit the context window of ${label} `
|
|
354
|
+
+ `(${window} tokens${inputLimit}).`
|
|
355
|
+
: `Estimated input (~${estimate} tokens) is far past the context window `
|
|
356
|
+
+ `of ${label} (${window} tokens${inputLimit}). Start a new session or choose a `
|
|
357
|
+
+ `model with a larger context window.`;
|
|
332
358
|
}
|
|
@@ -120,7 +120,7 @@ export class NativeInjectionChannel implements NativeResponseControl {
|
|
|
120
120
|
this.providerExecutedCallTypes, this.declaredBareToolNames,
|
|
121
121
|
);
|
|
122
122
|
if (undeclared !== undefined) {
|
|
123
|
-
injectionError(UNDECLARED_TOOL_CALL_ERROR_CODE, undeclaredToolCallMessage(
|
|
123
|
+
injectionError(UNDECLARED_TOOL_CALL_ERROR_CODE, undeclaredToolCallMessage());
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
/** Advertise client-owned function/custom calls and approvals, never hosted execution. */
|
|
@@ -5,10 +5,19 @@ export function nativeResponseRecord(value: unknown): value is Record<string, un
|
|
|
5
5
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
const canonical = (item: unknown): string => Array.isArray(item) ? `[${item.map(canonical).join(",")}]`
|
|
9
|
+
: nativeResponseRecord(item) ? `{${Object.keys(item).sort().map(key => `${JSON.stringify(key)}:${canonical(item[key])}`).join(",")}}`
|
|
10
|
+
: JSON.stringify(item) ?? "null";
|
|
11
|
+
const fingerprint = (json: string): string => createHash("sha256").update(json).digest("hex");
|
|
12
|
+
|
|
8
13
|
/** Compare JSON content by value: object-key order is irrelevant, array order is not. */
|
|
9
14
|
export function nativeResponseFingerprint(value: unknown): string {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
return fingerprint(canonical(value));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Keep transient body keys within the existing 64-byte digest payload bound. */
|
|
19
|
+
export function nativeResponseOutputIdentity(item: Record<string, unknown>): string {
|
|
20
|
+
if (typeof item.id === "string") return `id:${item.id}`;
|
|
21
|
+
const json = canonical(item);
|
|
22
|
+
return Buffer.byteLength(json, "utf8") <= 64 ? `json:${json}` : `body:${fingerprint(json)}`;
|
|
14
23
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { nativeResponseFingerprint as injectionFingerprint, nativeResponseRecord as record } from "./native-response-json";
|
|
1
|
+
import { nativeResponseFingerprint as injectionFingerprint, nativeResponseOutputIdentity as identity, nativeResponseRecord as record } from "./native-response-json";
|
|
2
2
|
type Frame = Record<string, unknown>;
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -10,7 +10,6 @@ export function nativeResponseOutput(done: ReadonlyMap<number, Frame>, terminal:
|
|
|
10
10
|
const observed = [...done.entries()].sort((a, b) => a[0] - b[0]).map(([, item]) => item);
|
|
11
11
|
if (terminal == null || (Array.isArray(terminal) && !terminal.length)) return observed;
|
|
12
12
|
if (!Array.isArray(terminal) || terminal.some(item => !record(item))) throw new Error("Invalid native response output.");
|
|
13
|
-
const identity = (item: Frame) => typeof item.id === "string" ? `id:${item.id}` : `body:${injectionFingerprint(item)}`;
|
|
14
13
|
const positions = new Map<string, number>();
|
|
15
14
|
observed.forEach((item, index) => {
|
|
16
15
|
const key = identity(item);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { carryProxyError } from "../../lib/client-error-body";
|
|
1
2
|
import { isNonReplayableResponse, isReplayRefusalResponse, markResponseNonReplayable } from "../../lib/upstream-retry";
|
|
2
3
|
import { clientCancelledResponse, readDisplaySafeErrorText } from "./core-errors";
|
|
3
4
|
|
|
@@ -44,5 +45,5 @@ export async function sanitizeNonReplayableUpstreamError(
|
|
|
44
45
|
status: response.status, headers,
|
|
45
46
|
});
|
|
46
47
|
markResponseNonReplayable(safe);
|
|
47
|
-
return safe;
|
|
48
|
+
return carryProxyError(response, safe);
|
|
48
49
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
import { markProxyError } from "../../lib/client-error-body";
|
|
1
2
|
import { formatErrorResponse } from "../../bridge";
|
|
2
3
|
import { RequestPacingQueueOverloadError } from "../../providers/request-pacing";
|
|
3
4
|
|
|
4
5
|
/** Convert local request-pacing admission failures into a retryable HTTP response. */
|
|
5
6
|
export function requestPacingOverloadResponse(error: unknown): Response | undefined {
|
|
6
7
|
if (!(error instanceof RequestPacingQueueOverloadError)) return undefined;
|
|
7
|
-
return formatErrorResponse(
|
|
8
|
+
return markProxyError(formatErrorResponse(
|
|
8
9
|
429,
|
|
9
10
|
"rate_limit_error",
|
|
10
11
|
error.message,
|
|
11
12
|
{ retryAfter: String(error.retryAfterSeconds) },
|
|
12
|
-
);
|
|
13
|
+
), error.reason === "keys_exhausted" ? undefined : "pacing");
|
|
13
14
|
}
|