@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 { projectLocalModelRefusalLog } from "../request-log-failure-detail";
|
|
2
|
+
import { inputAdmissionRefusalMessage } from "./input-admission";
|
|
3
|
+
import { clientFacingModelLabel, clientFacingModelText } from "../../lib/error-destination";
|
|
4
|
+
import { markProxyError } from "../../lib/client-error-body";
|
|
5
|
+
import { completeClaudeBridgePoolIdentity } from "../claude-bridge-pool-session";
|
|
1
6
|
import type { HandleResponsesOptions, ResponsesRequestContext, ResponsesAdmissionState, ResponsesDispatchers } from "./core-options";
|
|
2
7
|
import type { PolicyRequestEvidence } from "../../routing/evaluator";
|
|
3
8
|
import type { RequestLogContext } from "../request-log";
|
|
@@ -53,6 +58,7 @@ import {
|
|
|
53
58
|
} from "./encrypted-payload";
|
|
54
59
|
import {
|
|
55
60
|
codexPoolAffinityKey,
|
|
61
|
+
codexRequestAffinityKey,
|
|
56
62
|
previewCodexPoolLineage,
|
|
57
63
|
applyCodexAuthContextToProvider,
|
|
58
64
|
releaseCodexAuthContextProbeLease,
|
|
@@ -140,7 +146,7 @@ import {
|
|
|
140
146
|
import { checkComboTargetInputAdmission, checkInputAdmission } from "./input-admission";
|
|
141
147
|
import {
|
|
142
148
|
admissionMayUseMeteredComboTargets,
|
|
143
|
-
admissionModelDeniedResponse,
|
|
149
|
+
admissionModelDeniedResponse, projectAdmissionModelDeniedLog,
|
|
144
150
|
AdmissionModelDeniedError,
|
|
145
151
|
assertRouteAllowedByScope,
|
|
146
152
|
resolveAdmissionModelScope,
|
|
@@ -152,6 +158,7 @@ import {
|
|
|
152
158
|
currentTurnWireToolCatalogBody,
|
|
153
159
|
hasExplicitEmptyToolCatalog,
|
|
154
160
|
collectDeclaredWireToolNames,
|
|
161
|
+
collectTranslatedHostedToolNames,
|
|
155
162
|
collectDeclaredBareCustomWireToolNames,
|
|
156
163
|
} from "../responses-undeclared-tool-guard";
|
|
157
164
|
import { streamingContextOverflowResponse } from "./context-overflow";
|
|
@@ -242,6 +249,11 @@ export async function prepareResponsesRequest(
|
|
|
242
249
|
return decodeRequestErrorResponse(err, "responses");
|
|
243
250
|
}
|
|
244
251
|
// Remove display-only artifact paths before helpers, combo dispatch and upstream replay.
|
|
252
|
+
const originalSelector = options.mainHardLockFallbackOverride?.sourceModel ?? options.compactionRoutingOverride?.sourceModel
|
|
253
|
+
?? (options.comboAttempt || options.policyFallbackCandidate || options.internalDecisionCall || options.memoryModelPhase
|
|
254
|
+
|| options.visionDescribeTerminal || options.shadowCallIntercepted ? undefined
|
|
255
|
+
: body && typeof body === "object" ? (body as { model?: unknown }).model : undefined);
|
|
256
|
+
options.clientModelLabel ??= clientFacingModelLabel(originalSelector);
|
|
245
257
|
redactHostedImageDisplayPaths(body);
|
|
246
258
|
observeCacheDiagnosticInbound(
|
|
247
259
|
logCtx,
|
|
@@ -386,7 +398,7 @@ export async function prepareResponsesRequest(
|
|
|
386
398
|
// A decision model may be a plain model or a non-JEV combo. A JEV combo here would recurse
|
|
387
399
|
// into another decision, so the call is refused and the parent decision fails open.
|
|
388
400
|
if (options.internalDecisionCall && comboId && config.combos?.[comboId]?.strategy === "jev") {
|
|
389
|
-
return formatErrorResponse(400, "invalid_request_error", "A JEV decision model cannot be a JEV combo");
|
|
401
|
+
return markProxyError(formatErrorResponse(400, "invalid_request_error", "A JEV decision model cannot be a JEV combo"));
|
|
390
402
|
}
|
|
391
403
|
if (comboId && Object.hasOwn(config.combos ?? {}, comboId)) {
|
|
392
404
|
options.onRequestBodyRead?.();
|
|
@@ -427,11 +439,11 @@ export async function prepareResponsesRequest(
|
|
|
427
439
|
}
|
|
428
440
|
// Local replay failures require full client replay.
|
|
429
441
|
if (replayFailure) {
|
|
430
|
-
return formatErrorResponse(
|
|
442
|
+
return markProxyError(formatErrorResponse(
|
|
431
443
|
400,
|
|
432
444
|
"previous_response_not_found",
|
|
433
445
|
"Continuation state is unavailable or corrupt; resend the full conversation without previous_response_id.",
|
|
434
|
-
);
|
|
446
|
+
));
|
|
435
447
|
}
|
|
436
448
|
}
|
|
437
449
|
const previousResponseInputExpanded = options.comboReplaySnapshot?.previousResponseInputExpanded
|
|
@@ -482,22 +494,29 @@ export async function prepareResponsesRequest(
|
|
|
482
494
|
if (options.directRequest) parsed = options.directRequest.decode(parsed);
|
|
483
495
|
parsed._nativeReasoningRetention = resolveNativeReasoningRetention(config);
|
|
484
496
|
// Capture before route rewrites or hosted sidecars can add tools; replayed catalogs are history.
|
|
485
|
-
//
|
|
486
|
-
//
|
|
487
|
-
const catalogBody = options.directRequest &&
|
|
488
|
-
?
|
|
497
|
+
// Direct decoders already own current function names (including legacy Chat functions).
|
|
498
|
+
// Project only those names; bridging the conversation would retain its reasoning twice.
|
|
499
|
+
const catalogBody = options.directRequest && parsed.context.tools?.length
|
|
500
|
+
? { tools: parsed.context.tools.map(tool => ({ type: "function", name: tool.name })) } : parsed._rawBody;
|
|
489
501
|
const currentCatalog = currentTurnWireToolCatalogBody(catalogBody, parsed._replayPrefixLen);
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
502
|
+
// A hosted tool declared this turn authorizes the function name its translation uses.
|
|
503
|
+
const translatedHostedNames = collectTranslatedHostedToolNames(currentCatalog);
|
|
504
|
+
clientToolCatalogRestriction = {
|
|
505
|
+
declaredToolNames: new Set([...collectDeclaredWireToolNames(currentCatalog), ...translatedHostedNames]),
|
|
506
|
+
bareCustomToolNames: collectDeclaredBareCustomWireToolNames(currentCatalog),
|
|
507
|
+
canonicalToolNames: new Set([...collectDeclaredWireToolNames(currentCatalog, { canonicalOnly: true }), ...translatedHostedNames]),
|
|
508
|
+
// Ordinary Responses validation stays with its delivery owner; replay cannot add authority.
|
|
509
|
+
enforceDeclaredToolNames: (inboundWire === "responses" && (parsed._replayPrefixLen ?? 0) > 0)
|
|
510
|
+
|| options.clientDeclaredEmptyToolCatalog === true
|
|
511
|
+
|| hasExplicitEmptyToolCatalog(currentCatalog),
|
|
512
|
+
};
|
|
496
513
|
if (options.inboundWire === "anthropic") {
|
|
497
514
|
parsed._nativeReasoningReplay = options.nativeReasoningReplay;
|
|
498
515
|
parsed._nativeReasoningMint = options.nativeReasoningMint;
|
|
499
516
|
parsed._anthropicServerTools = options.anthropicServerTools;
|
|
500
517
|
parsed._anthropicServerReplay = options.anthropicServerReplay;
|
|
518
|
+
parsed._anthropicSystemCachePrefix = options.anthropicSystemCachePrefix;
|
|
519
|
+
if (parsed.options.textFormat?.type === "json_schema") parsed._structuredOutputConformance = true;
|
|
501
520
|
}
|
|
502
521
|
parsed._promptCacheKeyIsSharedCohort = options.promptCacheKeyIsSharedCohort;
|
|
503
522
|
// The body may have been rebuilt since the inbound observation (previous-response
|
|
@@ -568,9 +587,9 @@ export async function prepareResponsesRequest(
|
|
|
568
587
|
}
|
|
569
588
|
} catch (err) {
|
|
570
589
|
if (isTranslatorBudgetExceededError(err)) {
|
|
571
|
-
return formatErrorResponse(413, "request_too_large", "request translation buffer exceeded the safe limit", {
|
|
590
|
+
return markProxyError(formatErrorResponse(413, "request_too_large", "request translation buffer exceeded the safe limit", {
|
|
572
591
|
code: "translation_buffer_limit",
|
|
573
|
-
});
|
|
592
|
+
}));
|
|
574
593
|
}
|
|
575
594
|
return formatErrorResponse(400, "invalid_request_error", err instanceof Error ? err.message : String(err));
|
|
576
595
|
}
|
|
@@ -646,7 +665,8 @@ export async function prepareResponsesRequest(
|
|
|
646
665
|
// The selector the caller actually sent, captured before shadow interception
|
|
647
666
|
// or a subagent fallback rewrites it, so a refusal names the client's own
|
|
648
667
|
// request rather than a destination it never asked for.
|
|
649
|
-
const inboundSelector = options.
|
|
668
|
+
const inboundSelector = options.clientModelLabel;
|
|
669
|
+
const inboundRoutingSelector = options.mainHardLockFallbackOverride?.sourceModel ?? parsed.modelId;
|
|
650
670
|
const selectorTargetsSecondary = (selector: string): boolean => {
|
|
651
671
|
const slash = selector.indexOf("/");
|
|
652
672
|
if (slash <= 0) return false;
|
|
@@ -656,13 +676,13 @@ export async function prepareResponsesRequest(
|
|
|
656
676
|
return qualifier === "anthropic2"
|
|
657
677
|
|| config.providers.anthropic2?.alias?.trim().toLowerCase() === qualifier.toLowerCase();
|
|
658
678
|
};
|
|
659
|
-
const explicitlyRequestsSecondary = selectorTargetsSecondary(
|
|
679
|
+
const explicitlyRequestsSecondary = selectorTargetsSecondary(inboundRoutingSelector);
|
|
660
680
|
const secondaryProvider = config.providers.anthropic2;
|
|
661
681
|
// Reserve an explicit B selector before an absent row can default-route it to A.
|
|
662
682
|
// Combo parents have already dispatched above; concrete children retain their own target.
|
|
663
683
|
if (explicitlyRequestsSecondary && (!secondaryProvider || secondaryProvider.disabled === true
|
|
664
684
|
|| secondaryProvider.authMode === "oauth" && configuredAnthropicInstance(config, "anthropic2") !== "anthropic2")) {
|
|
665
|
-
return formatErrorResponse(401, "authentication_error", "Anthropic Pool 2 requires an enabled configured provider");
|
|
685
|
+
return markProxyError(formatErrorResponse(401, "authentication_error", "Anthropic Pool 2 requires an enabled configured provider"));
|
|
666
686
|
}
|
|
667
687
|
const admissionScope = options.admissionScope ?? resolveAdmissionModelScope(config, options.admission);
|
|
668
688
|
const advisorAdmissionPolicy = options.advisorAdmissionPolicy;
|
|
@@ -839,11 +859,11 @@ export async function prepareResponsesRequest(
|
|
|
839
859
|
logCtx.policyEligibility = route.policyEligibility;
|
|
840
860
|
} catch (err) {
|
|
841
861
|
if (err instanceof AnthropicSecondaryInstanceUnavailableError) {
|
|
842
|
-
return formatErrorResponse(401, "authentication_error", err.message);
|
|
862
|
+
return markProxyError(formatErrorResponse(401, "authentication_error", err.message));
|
|
843
863
|
}
|
|
844
864
|
const policyRefusal = policyCandidateRefusalResponse(err);
|
|
845
865
|
if (policyRefusal) return policyRefusal;
|
|
846
|
-
if (err instanceof AdmissionModelDeniedError) return admissionModelDeniedResponse(err);
|
|
866
|
+
if (err instanceof AdmissionModelDeniedError) return admissionModelDeniedResponse(projectAdmissionModelDeniedLog(err, logCtx));
|
|
847
867
|
if (err instanceof NoAvailableComboTargetsError) {
|
|
848
868
|
return comboUnavailable(err.comboId, undefined, err.reasons);
|
|
849
869
|
}
|
|
@@ -951,17 +971,17 @@ export async function prepareResponsesRequest(
|
|
|
951
971
|
let subagentFallbackModelEligibleAccountIdsForModel: SubagentModelEligibleAccountIds | undefined;
|
|
952
972
|
let subagentQuotaFailureModel = parsed.modelId;
|
|
953
973
|
const parentThreadId = req.headers.get("x-codex-parent-thread-id")?.trim() ?? null;
|
|
954
|
-
const poolAffinityKey = codexPoolAffinityKey(req.headers) ?? null;
|
|
974
|
+
const poolAffinityKey = codexPoolAffinityKey(completeClaudeBridgePoolIdentity(req.headers, options)) ?? null;
|
|
955
975
|
// Preview has to see the same lineage resolve does. Without it, a child's first turn is
|
|
956
976
|
// previewed as a cold pick and resolved onto the family account, and the subagent fallback
|
|
957
977
|
// then decides model eligibility against an account the request will never use.
|
|
958
978
|
//
|
|
959
979
|
// "The same" means both halves of the question the final resolution asks. The Authorization
|
|
960
980
|
// it will be given, because the lineage scope is an HMAC of exactly that header; and its own
|
|
961
|
-
// Pool-state predicate
|
|
962
|
-
//
|
|
963
|
-
// hand model fallback an account this request
|
|
964
|
-
//
|
|
981
|
+
// Pool-state predicate: fixed selectors and request-owned credentials never use stored-credential
|
|
982
|
+
// lineage. An opt-in request-owned key has its own namespace; previewing a stored family binding
|
|
983
|
+
// would hand model fallback an account this request will not use. Preview is read-only: only
|
|
984
|
+
// eligible stored-credential resolutions record lineage.
|
|
965
985
|
const poolLineage = previewCodexPoolLineage(previewAuthHeaders, options.codexAuthPolicy ?? config, {
|
|
966
986
|
accountId: route.codexAccountId,
|
|
967
987
|
modelId: route.modelId,
|
|
@@ -1000,7 +1020,7 @@ export async function prepareResponsesRequest(
|
|
|
1000
1020
|
});
|
|
1001
1021
|
const fallbackNow = Date.now();
|
|
1002
1022
|
subagentFallbackAccountPreview = (modelId, previewNow, modelEligibleAccountIds) => previewCodexAccountForRequest(
|
|
1003
|
-
|
|
1023
|
+
codexRequestAffinityKey(previewAuthHeaders, config, options.codexAuthPolicy ?? config, { accountId: route.codexAccountId, modelId, admission: options.admission, requestScopedMainCredential: previewRequestScopedMainCredential }) ?? null,
|
|
1004
1024
|
config,
|
|
1005
1025
|
previewNow,
|
|
1006
1026
|
codexQuotaScopeForModel(modelId),
|
|
@@ -1063,7 +1083,7 @@ export async function prepareResponsesRequest(
|
|
|
1063
1083
|
} catch (err) {
|
|
1064
1084
|
const policyRefusal = policyCandidateRefusalResponse(err);
|
|
1065
1085
|
if (policyRefusal) return policyRefusal;
|
|
1066
|
-
if (err instanceof AdmissionModelDeniedError) return admissionModelDeniedResponse(err);
|
|
1086
|
+
if (err instanceof AdmissionModelDeniedError) return admissionModelDeniedResponse(projectAdmissionModelDeniedLog(err, logCtx));
|
|
1067
1087
|
if (err instanceof NoAvailableComboTargetsError) {
|
|
1068
1088
|
return comboUnavailable(err.comboId, undefined, err.reasons);
|
|
1069
1089
|
}
|
|
@@ -1218,7 +1238,7 @@ export async function prepareResponsesRequest(
|
|
|
1218
1238
|
// and then fail closed at final auth — the same class of stale-selection bug as
|
|
1219
1239
|
// the quota scope, one layer over.
|
|
1220
1240
|
subagentFallbackAccountPreview = (modelId, previewNow, modelEligibleAccountIds) => previewCodexAccountForRequest(
|
|
1221
|
-
|
|
1241
|
+
codexRequestAffinityKey(recoveryAuthHeaders, config, options.codexAuthPolicy ?? config, { accountId: route.codexAccountId, modelId, admission: options.admission, requestScopedMainCredential: recoveryRequestScopedMainCredential }) ?? null,
|
|
1222
1242
|
config,
|
|
1223
1243
|
previewNow,
|
|
1224
1244
|
codexQuotaScopeForModel(modelId),
|
|
@@ -1238,7 +1258,7 @@ export async function prepareResponsesRequest(
|
|
|
1238
1258
|
}),
|
|
1239
1259
|
},
|
|
1240
1260
|
modelId,
|
|
1241
|
-
|
|
1261
|
+
previewCodexPoolLineage(recoveryAuthHeaders, options.codexAuthPolicy ?? config, { accountId: route.codexAccountId, modelId, admission: options.admission, requestScopedMainCredential: recoveryRequestScopedMainCredential }),
|
|
1242
1262
|
);
|
|
1243
1263
|
const recoveryPreviewAccountId = subagentFallbackAccountPreview(
|
|
1244
1264
|
parsed.modelId,
|
|
@@ -1285,7 +1305,7 @@ export async function prepareResponsesRequest(
|
|
|
1285
1305
|
} catch (err) {
|
|
1286
1306
|
const policyRefusal = policyCandidateRefusalResponse(err);
|
|
1287
1307
|
if (policyRefusal) return policyRefusal;
|
|
1288
|
-
if (err instanceof AdmissionModelDeniedError) return admissionModelDeniedResponse(err);
|
|
1308
|
+
if (err instanceof AdmissionModelDeniedError) return admissionModelDeniedResponse(projectAdmissionModelDeniedLog(err, logCtx));
|
|
1289
1309
|
if (err instanceof NoAvailableComboTargetsError) {
|
|
1290
1310
|
return comboUnavailable(err.comboId, undefined, err.reasons);
|
|
1291
1311
|
}
|
|
@@ -1385,11 +1405,11 @@ export async function prepareResponsesRequest(
|
|
|
1385
1405
|
hasUnexpandedPreviousResponse
|
|
1386
1406
|
&& isCanonicalOpenAiForwardProvider(route.provider)
|
|
1387
1407
|
) {
|
|
1388
|
-
return formatErrorResponse(
|
|
1408
|
+
return markProxyError(formatErrorResponse(
|
|
1389
1409
|
400,
|
|
1390
1410
|
"previous_response_not_found",
|
|
1391
1411
|
"Continuation state is unavailable or corrupt; resend the full conversation without previous_response_id.",
|
|
1392
|
-
);
|
|
1412
|
+
));
|
|
1393
1413
|
}
|
|
1394
1414
|
|
|
1395
1415
|
if (hasUnexpandedPreviousResponse) {
|
|
@@ -1411,11 +1431,11 @@ export async function prepareResponsesRequest(
|
|
|
1411
1431
|
// An unknown adapter is left to the resolution error it already raises below.
|
|
1412
1432
|
: continuationWire === undefined || PROVIDER_OWNED_CONTINUATION_WIRES.has(continuationWire);
|
|
1413
1433
|
if (!upstreamOwnsOmittedHistory) {
|
|
1414
|
-
return formatErrorResponse(
|
|
1434
|
+
return markProxyError(formatErrorResponse(
|
|
1415
1435
|
400,
|
|
1416
1436
|
"previous_response_not_found",
|
|
1417
1437
|
"Continuation state is unavailable or corrupt; resend the full conversation without previous_response_id.",
|
|
1418
|
-
);
|
|
1438
|
+
));
|
|
1419
1439
|
}
|
|
1420
1440
|
}
|
|
1421
1441
|
|
|
@@ -1453,8 +1473,14 @@ export async function prepareResponsesRequest(
|
|
|
1453
1473
|
const scopedDestination = parsed._wireModelOverride === undefined
|
|
1454
1474
|
? route
|
|
1455
1475
|
: { providerName: route.providerName, modelId: parsed._wireModelOverride };
|
|
1476
|
+
// Synthetic turns keep the original client envelope label across provider normalization.
|
|
1477
|
+
if (options.compactionRoutingOverride || options.mainHardLockFallbackOverride || options.clientResponseModelLabel
|
|
1478
|
+
|| options.internalDecisionCall || options.memoryModelPhase || options.visionDescribeTerminal
|
|
1479
|
+
|| options.policyFallbackCandidate || parsed._memoryModelPhase || logCtx.shadowCallRewrittenFrom) {
|
|
1480
|
+
parsed._responseModelId = clientFacingModelText(options.clientResponseModelLabel ?? inboundSelector);
|
|
1481
|
+
}
|
|
1456
1482
|
if (!routeAllowedByScope(admissionScope, scopedDestination)) {
|
|
1457
|
-
return admissionModelDeniedResponse(new AdmissionModelDeniedError(inboundSelector, scopedDestination));
|
|
1483
|
+
return admissionModelDeniedResponse(projectAdmissionModelDeniedLog(new AdmissionModelDeniedError(inboundSelector, scopedDestination), logCtx));
|
|
1458
1484
|
}
|
|
1459
1485
|
// Attribute local auth/cooldown failures to the public selector too; exact auth may fail before
|
|
1460
1486
|
// the normal post-resolution provider label is assigned.
|
|
@@ -1467,7 +1493,7 @@ export async function prepareResponsesRequest(
|
|
|
1467
1493
|
if (isCanonicalOpenAiForwardProvider(route.provider)
|
|
1468
1494
|
&& isCodexReserveHelperUnsupported(options.codexAuthPolicy ?? config, route.modelId,
|
|
1469
1495
|
options.admission, options.visionDescribeTerminal === true)) {
|
|
1470
|
-
return formatErrorResponse(400, "invalid_request_error", CODEX_RESERVE_HELPER_UNSUPPORTED_MESSAGE);
|
|
1496
|
+
return markProxyError(formatErrorResponse(400, "invalid_request_error", CODEX_RESERVE_HELPER_UNSUPPORTED_MESSAGE));
|
|
1471
1497
|
}
|
|
1472
1498
|
// #4940: the opt-in is off, so every Reserve affordance in this process is inert -- no catalog
|
|
1473
1499
|
// row, no main-credential substitution, no authorization handshake, and no `luna-reserve` header
|
|
@@ -1488,7 +1514,7 @@ export async function prepareResponsesRequest(
|
|
|
1488
1514
|
&& options.visionDescribeTerminal !== true
|
|
1489
1515
|
&& isCanonicalOpenAiForwardProvider(route.provider)
|
|
1490
1516
|
&& isCodexReserveOptInMissing(options.codexAuthPolicy ?? config, route.modelId, options.admission)) {
|
|
1491
|
-
return formatErrorResponse(400, "invalid_request_error", CODEX_RESERVE_OPT_IN_REQUIRED_MESSAGE);
|
|
1517
|
+
return markProxyError(formatErrorResponse(400, "invalid_request_error", CODEX_RESERVE_OPT_IN_REQUIRED_MESSAGE));
|
|
1492
1518
|
}
|
|
1493
1519
|
// Refuse an input that cannot plausibly fit the model context window before spending auth,
|
|
1494
1520
|
// circuit budget, or upstream bandwidth on a turn the provider will reject anyway (#1412).
|
|
@@ -1509,23 +1535,18 @@ export async function prepareResponsesRequest(
|
|
|
1509
1535
|
// instead of treating the first incompatible candidate as the end of the chain. The
|
|
1510
1536
|
// distinct code is what lets the fallback layer tell the two apart -- an upstream
|
|
1511
1537
|
// `context_length_exceeded` still stops, because retrying it elsewhere is guesswork.
|
|
1538
|
+
projectLocalModelRefusalLog(logCtx, inboundSelector);
|
|
1512
1539
|
if (clientRequestedStream && !options.comboAttempt) {
|
|
1513
1540
|
return streamingContextOverflowResponse(
|
|
1514
|
-
|
|
1541
|
+
clientFacingModelText(inboundSelector),
|
|
1515
1542
|
translatorBudget,
|
|
1516
1543
|
);
|
|
1517
1544
|
}
|
|
1518
|
-
return formatErrorResponse(
|
|
1545
|
+
return markProxyError(formatErrorResponse(
|
|
1519
1546
|
413,
|
|
1520
1547
|
"input_admission_refused",
|
|
1521
|
-
inputAdmission
|
|
1522
|
-
|
|
1523
|
-
+ `tokens of requested output headroom cannot fit the context window of ${parsed.modelId} `
|
|
1524
|
-
+ `(${inputAdmission.ceiling} tokens).`
|
|
1525
|
-
: `Estimated input (~${inputAdmission.estimatedTokens} tokens) is far past the context window `
|
|
1526
|
-
+ `of ${parsed.modelId} (${inputAdmission.ceiling} tokens). Start a new session or choose a `
|
|
1527
|
-
+ `model with a larger context window.`,
|
|
1528
|
-
);
|
|
1548
|
+
inputAdmissionRefusalMessage(inputAdmission, inboundSelector),
|
|
1549
|
+
), "input");
|
|
1529
1550
|
}
|
|
1530
1551
|
}
|
|
1531
1552
|
const preAuthHostKey = preAuthUpstreamHostCircuitKey(route, config);
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { publicOAuthErrorPresentation } from "../../oauth";
|
|
2
|
+
import { projectLocalModelRefusalLog } from "../request-log-failure-detail";
|
|
3
|
+
import { markProxyError } from "../../lib/client-error-body";
|
|
4
|
+
import { formatClientRetryAfter } from "../../lib/client-retry-after";
|
|
5
|
+
import { SendBudgetExhaustedError, errorDestinationText, providerErrorDestinationLabel } from "../../lib/upstream-retry";
|
|
2
6
|
import { appendLoadedToolDefinitions, appendOnlyToolLoadingMatches } from "../../claude/inbound-tool-loading";
|
|
3
7
|
import { isRec } from "../../claude/inbound-records";
|
|
4
8
|
import { isOpenCodeGoResponsesUrl } from "../../adapters/opencode-go-additional-tools";
|
|
@@ -67,7 +71,7 @@ import { captureRouteStaticPolicy } from "../../router";
|
|
|
67
71
|
import { CopilotAutoHttpError, resolveCopilotAuto } from "../../providers/github-copilot-auto";
|
|
68
72
|
import {
|
|
69
73
|
AdmissionModelDeniedError,
|
|
70
|
-
admissionModelDeniedResponse,
|
|
74
|
+
admissionModelDeniedResponse, projectAdmissionModelDeniedLog,
|
|
71
75
|
assertRouteAllowedByScope,
|
|
72
76
|
} from "../admission-model-scope";
|
|
73
77
|
import { renameRoutedIdentityInContext } from "../../adapters/identity";
|
|
@@ -141,7 +145,7 @@ export async function prepareResponsesTransport(
|
|
|
141
145
|
? configuredAnthropicInstance(config, route.providerName) : undefined;
|
|
142
146
|
// Refuse custom/orphan B OAuth before any generic resolver can observe its auth row.
|
|
143
147
|
if (route.providerName === "anthropic2" && route.provider.authMode === "oauth" && !anthropicInstance) {
|
|
144
|
-
return formatErrorResponse(401, "authentication_error", "Anthropic Pool 2 requires an enabled builtin OAuth provider");
|
|
148
|
+
return markProxyError(formatErrorResponse(401, "authentication_error", "Anthropic Pool 2 requires an enabled builtin OAuth provider"));
|
|
145
149
|
}
|
|
146
150
|
const anthropicRouting = anthropicInstance ? anthropicRoutingFor(anthropicInstance) : undefined;
|
|
147
151
|
const anthropicQuota = anthropicInstance ? anthropicModelQuotaFor(anthropicInstance) : undefined;
|
|
@@ -158,7 +162,7 @@ export async function prepareResponsesTransport(
|
|
|
158
162
|
} catch { return false; }
|
|
159
163
|
};
|
|
160
164
|
if (!anthropicAdmissionIsCurrent()) {
|
|
161
|
-
return formatErrorResponse(401, "authentication_error", "Anthropic Pool 2 provider target changed; retry the request");
|
|
165
|
+
return markProxyError(formatErrorResponse(401, "authentication_error", "Anthropic Pool 2 provider target changed; retry the request"));
|
|
162
166
|
}
|
|
163
167
|
const requireAnthropicAdmission = (): void => {
|
|
164
168
|
if (!anthropicAdmissionIsCurrent()) throw new OAuthLoginRequiredError(anthropicInstance!);
|
|
@@ -178,9 +182,9 @@ export async function prepareResponsesTransport(
|
|
|
178
182
|
&& (kiroCap !== undefined || (config.pool?.kernel === true
|
|
179
183
|
&& config.providers.kiro?.oauthAccountFailover?.strategy === "least-loaded"
|
|
180
184
|
&& isProactivePreferenceEnabled(config, "kiro", Date.now())));
|
|
181
|
-
const capacityResponse = () => new Response(JSON.stringify({ error: {
|
|
185
|
+
const capacityResponse = () => markProxyError(new Response(JSON.stringify({ error: {
|
|
182
186
|
type: "server_error", code: "account_capacity", message: "Kiro account capacity is temporarily full; retry shortly.",
|
|
183
|
-
} }), { status: 503, headers: { "content-type": "application/json", "retry-after": "1" } });
|
|
187
|
+
} }), { status: 503, headers: { "content-type": "application/json", "retry-after": "1" } }));
|
|
184
188
|
|
|
185
189
|
|
|
186
190
|
// OAuth providers: swap in a fresh access token (auto-refreshed) as the Bearer key, so the
|
|
@@ -344,11 +348,12 @@ export async function prepareResponsesTransport(
|
|
|
344
348
|
const copilotRequestedModel = route.modelId;
|
|
345
349
|
/** Project only bounded Copilot refusal metadata; upstream bodies and session tokens never reach the client. */
|
|
346
350
|
const copilotRefusalResponse = (error: unknown): Response | undefined => {
|
|
347
|
-
if (error instanceof AdmissionModelDeniedError) return admissionModelDeniedResponse(error);
|
|
351
|
+
if (error instanceof AdmissionModelDeniedError) return admissionModelDeniedResponse(projectAdmissionModelDeniedLog(error, logCtx));
|
|
348
352
|
if (!(error instanceof CopilotAutoHttpError) || ![401, 403, 429].includes(error.status)) return;
|
|
349
|
-
const response = formatErrorResponse(error.status, error.status === 429 ? "rate_limit_error" : "authentication_error",
|
|
350
|
-
error.message);
|
|
351
|
-
|
|
353
|
+
const response = markProxyError(formatErrorResponse(error.status, error.status === 429 ? "rate_limit_error" : "authentication_error",
|
|
354
|
+
error.message), "copilot");
|
|
355
|
+
const advice = formatClientRetryAfter(error.retryAfter);
|
|
356
|
+
if (advice !== undefined) response.headers.set("retry-after", advice);
|
|
352
357
|
return response;
|
|
353
358
|
};
|
|
354
359
|
let copilotSessionExpiresAt = Infinity;
|
|
@@ -950,7 +955,7 @@ export async function prepareResponsesTransport(
|
|
|
950
955
|
const bodySize = checkOutboundBodySize(rebuilt.body, config.maxUpstreamBodyBytes);
|
|
951
956
|
if (!bodySize.admitted) {
|
|
952
957
|
rebuilt.releaseBodyObservation?.();
|
|
953
|
-
return formatErrorResponse(413, "outbound_body_too_large", describeOutboundBodyRefusal(bodySize));
|
|
958
|
+
return markProxyError(formatErrorResponse(413, "outbound_body_too_large", describeOutboundBodyRefusal(bodySize)), "outbound");
|
|
954
959
|
}
|
|
955
960
|
const headers = new Headers(dispatchInit.headers);
|
|
956
961
|
for (const name of Object.keys(wireRequest.headers)) headers.delete(name);
|
|
@@ -988,11 +993,11 @@ export async function prepareResponsesTransport(
|
|
|
988
993
|
try {
|
|
989
994
|
if (anthropicInstance !== undefined && anthropicRouting!.isAnthropicAccountPoolEnabled(config)) {
|
|
990
995
|
const routeResult = resolveAnthropicModelRouteForInstance(anthropicInstance, config, route.modelId);
|
|
991
|
-
if (routeResult.error) return formatErrorResponse(400, "invalid_request_error",
|
|
996
|
+
if (routeResult.error) return markProxyError(formatErrorResponse(400, "invalid_request_error", "Invalid Anthropic model routes"));
|
|
992
997
|
anthropicRouteDecision = routeResult.decision;
|
|
993
998
|
const selection = anthropicRouting!.resolveAnthropicAccountForSession(anthropicSessionKey, config, Date.now(), anthropicRouteDecision, route.modelId);
|
|
994
999
|
if (!selection.accountId) {
|
|
995
|
-
if (selection.reason === "paused") return formatErrorResponse(403, "permission_error", "Anthropic OAuth accounts are paused. Resume an account in account settings and retry.");
|
|
1000
|
+
if (selection.reason === "paused") return markProxyError(formatErrorResponse(403, "permission_error", "Anthropic OAuth accounts are paused. Resume an account in account settings and retry."));
|
|
996
1001
|
// Route names may resemble account IDs; log only the matched rule position.
|
|
997
1002
|
if (anthropicRouteDecision) console.warn(`[${anthropicInstance}-pool] route:#${anthropicRouteDecision.position} ${selection.reason}; answering locally`);
|
|
998
1003
|
if (selection.reason === "all-cooled") {
|
|
@@ -1001,10 +1006,10 @@ export async function prepareResponsesTransport(
|
|
|
1001
1006
|
{ comboAttempt: options.comboAttempt, logCtx },
|
|
1002
1007
|
);
|
|
1003
1008
|
}
|
|
1004
|
-
return formatErrorResponse(401, "authentication_error", anthropicRouteDecision ? "No eligible Anthropic OAuth account for this model route" : "No eligible Anthropic OAuth account available");
|
|
1009
|
+
return markProxyError(formatErrorResponse(401, "authentication_error", anthropicRouteDecision ? "No eligible Anthropic OAuth account for this model route" : "No eligible Anthropic OAuth account available"));
|
|
1005
1010
|
}
|
|
1006
1011
|
const admitted = await commitResolvedOAuthSelection(await anthropicRouting!.getAnthropicPoolAccessSnapshot(selection.accountId), true, selection.reason);
|
|
1007
|
-
if (!admitted) return formatErrorResponse(409, "conflict_error", "OAuth account selection changed; retry the request");
|
|
1012
|
+
if (!admitted) return markProxyError(formatErrorResponse(409, "conflict_error", "OAuth account selection changed; retry the request"));
|
|
1008
1013
|
anthropicPoolAccountId = admitted.accountId;
|
|
1009
1014
|
if (anthropicRouteDecision) console.info(`[${anthropicInstance}-pool] route:#${anthropicRouteDecision.position} ${selection.reason}`);
|
|
1010
1015
|
route.provider = { ...route.provider, apiKey: admitted.accessToken };
|
|
@@ -1025,8 +1030,8 @@ export async function prepareResponsesTransport(
|
|
|
1025
1030
|
// #7500: an Antigravity account whose own discovery omits the model is never sent to.
|
|
1026
1031
|
// A usable listing (or not-yet-discovered) sibling replaces it, or the request is refused.
|
|
1027
1032
|
const modelRoute = routeAntigravityModel(config, route.providerName,
|
|
1028
|
-
proposedAccountId ?? oauthSelection?.accountId, route.modelId);
|
|
1029
|
-
if (modelRoute.kind === "refuse") return formatErrorResponse(403, "permission_error", modelRoute.message);
|
|
1033
|
+
proposedAccountId ?? oauthSelection?.accountId, route.modelId, undefined, requestState.inboundSelector);
|
|
1034
|
+
if (modelRoute.kind === "refuse") { projectLocalModelRefusalLog(logCtx, requestState.inboundSelector); return markProxyError(formatErrorResponse(403, "permission_error", modelRoute.message), "roster"); }
|
|
1030
1035
|
const routedAccountId = modelRoute.kind === "reroute" ? modelRoute.accountId : proposedAccountId;
|
|
1031
1036
|
// An unchanged active choice must retain the ordinary resolver's terminal-refresh
|
|
1032
1037
|
// recovery (not the speculative-preference fallback that resolves the same dead grant).
|
|
@@ -1093,12 +1098,12 @@ export async function prepareResponsesTransport(
|
|
|
1093
1098
|
}
|
|
1094
1099
|
// Resolution fallbacks can still land on an omitting account; answer with the refusal
|
|
1095
1100
|
// here, since the commit below would only report it as a changed selection.
|
|
1096
|
-
const unlisted = antigravityModelRefusal(config, route.providerName, resolved.accountId, route.modelId);
|
|
1097
|
-
if (unlisted) return formatErrorResponse(403, "permission_error", unlisted);
|
|
1101
|
+
const unlisted = antigravityModelRefusal(config, route.providerName, resolved.accountId, route.modelId, undefined, requestState.inboundSelector);
|
|
1102
|
+
if (unlisted) { projectLocalModelRefusalLog(logCtx, requestState.inboundSelector); return markProxyError(formatErrorResponse(403, "permission_error", unlisted), "roster"); }
|
|
1098
1103
|
const admitted = await commitResolvedOAuthSelection(resolved, safetyAlternateId === null);
|
|
1099
|
-
if (!admitted) return formatErrorResponse(409, "conflict_error", "OAuth account selection changed; retry the request");
|
|
1104
|
+
if (!admitted) return markProxyError(formatErrorResponse(409, "conflict_error", "OAuth account selection changed; retry the request"));
|
|
1100
1105
|
if (safetyAlternateId && admitted.accountId !== safetyAlternateId)
|
|
1101
|
-
return formatErrorResponse(409, "conflict_error", "OAuth account selection changed; retry the request");
|
|
1106
|
+
return markProxyError(formatErrorResponse(409, "conflict_error", "OAuth account selection changed; retry the request"));
|
|
1102
1107
|
if (kiroLoadEnabled) {
|
|
1103
1108
|
const transportSignal = options.abortSignal ?? req.signal;
|
|
1104
1109
|
const lease = await acquireAccountLease("kiro", admitted.accountId, {
|
|
@@ -1165,27 +1170,27 @@ export async function prepareResponsesTransport(
|
|
|
1165
1170
|
// Project identity belongs to the admitted account on EVERY request, including
|
|
1166
1171
|
// the request after a pool transition made that account the persisted active one.
|
|
1167
1172
|
if (route.provider.googleMode === "cloud-code-assist") {
|
|
1168
|
-
if (!resolved.projectId) return formatErrorResponse(401, "authentication_error", publicOAuthAuthenticationErrorMessage(new Error("Cloud Code Assist account project is unavailable")));
|
|
1173
|
+
if (!resolved.projectId) return markProxyError(formatErrorResponse(401, "authentication_error", publicOAuthAuthenticationErrorMessage(new Error("Cloud Code Assist account project is unavailable"))));
|
|
1169
1174
|
route.provider = { ...route.provider, project: resolved.projectId };
|
|
1170
1175
|
}
|
|
1171
1176
|
}
|
|
1172
1177
|
} catch (err) {
|
|
1173
1178
|
if (err instanceof UnsupportedOAuthProviderError) {
|
|
1174
|
-
const safeProviderName = redactSecretString(route.providerName);
|
|
1175
|
-
return formatErrorResponse(
|
|
1179
|
+
const safeProviderName = redactSecretString(errorDestinationText(providerErrorDestinationLabel(route.providerName)));
|
|
1180
|
+
return markProxyError(formatErrorResponse(
|
|
1176
1181
|
400,
|
|
1177
1182
|
"invalid_request_error",
|
|
1178
1183
|
`${redactSecretString(err.message)}. Remove or reconfigure provider '${safeProviderName}' in the OpenCodex configuration.`,
|
|
1179
|
-
);
|
|
1184
|
+
), "config");
|
|
1180
1185
|
}
|
|
1181
1186
|
if (err instanceof OAuthTokenRefreshBusyError) {
|
|
1182
1187
|
return options.abortSignal?.aborted || req.signal.aborted ? clientCancelledResponse()
|
|
1183
|
-
: formatErrorResponse(503, "server_error", err.message, { retryAfter: "1" });
|
|
1188
|
+
: markProxyError(formatErrorResponse(503, "server_error", err.message, { retryAfter: "1" }));
|
|
1184
1189
|
}
|
|
1185
1190
|
if (err instanceof OAuthAccountPausedError) {
|
|
1186
|
-
return formatErrorResponse(403, "permission_error", publicOAuthAuthenticationErrorMessage(err));
|
|
1191
|
+
return markProxyError(formatErrorResponse(403, "permission_error", publicOAuthAuthenticationErrorMessage(err)), publicOAuthErrorPresentation(err));
|
|
1187
1192
|
}
|
|
1188
|
-
return formatErrorResponse(401, "authentication_error", publicOAuthAuthenticationErrorMessage(err));
|
|
1193
|
+
return markProxyError(formatErrorResponse(401, "authentication_error", publicOAuthAuthenticationErrorMessage(err)), publicOAuthErrorPresentation(err));
|
|
1189
1194
|
}
|
|
1190
1195
|
}
|
|
1191
1196
|
// Key-auth twin of the OAuth preference above: pick a warm key BEFORE the first attempt when
|
|
@@ -1221,7 +1226,7 @@ export async function prepareResponsesTransport(
|
|
|
1221
1226
|
if ((options.abortSignal ?? req.signal).aborted) return clientCancelledResponse();
|
|
1222
1227
|
const refusal = copilotRefusalResponse(error);
|
|
1223
1228
|
if (refusal) return refusal;
|
|
1224
|
-
return formatErrorResponse(502, "provider_error", "GitHub Copilot Auto negotiation failed; retry or check your Copilot account permissions.");
|
|
1229
|
+
return markProxyError(formatErrorResponse(502, "provider_error", "GitHub Copilot Auto negotiation failed; retry or check your Copilot account permissions."));
|
|
1225
1230
|
}
|
|
1226
1231
|
let adapterProvider = resolveWireProtocolOverride(route.providerName, route.modelId, route.provider, inboundWire, route.staticPolicy);
|
|
1227
1232
|
if (copilotAutoAdapter) adapterProvider = { ...adapterProvider, adapter: copilotAutoAdapter };
|
|
@@ -1294,11 +1299,11 @@ export async function prepareResponsesTransport(
|
|
|
1294
1299
|
if (!isPassthrough && Array.isArray(rawInput) && rawInput.some(
|
|
1295
1300
|
item => item !== null && typeof item === "object" && item.type === "computer_call_output",
|
|
1296
1301
|
)) {
|
|
1297
|
-
return formatErrorResponse(
|
|
1302
|
+
return markProxyError(formatErrorResponse(
|
|
1298
1303
|
400,
|
|
1299
1304
|
"invalid_request_error",
|
|
1300
1305
|
"computer_call_output requires a Responses passthrough route; send screenshots as user input_image content on translated routes.",
|
|
1301
|
-
);
|
|
1306
|
+
));
|
|
1302
1307
|
}
|
|
1303
1308
|
|
|
1304
1309
|
// Freeze the request ceiling before any 429 writes cooldowns. Selection still reads
|
|
@@ -106,8 +106,9 @@ export function createResponsesEffects(
|
|
|
106
106
|
// The compaction turn is a plain prose summary; a surviving structured-output format
|
|
107
107
|
// would force schema-constrained JSON into the synthetic compaction item. The flag and
|
|
108
108
|
// the raw `text` control go too: the key-mode openai-responses adapter builds from
|
|
109
|
-
// _rawBody, so a surviving format there would still reach the upstream. (
|
|
110
|
-
//
|
|
109
|
+
// _rawBody, so a surviving format there would still reach the upstream. (Kiro reads
|
|
110
|
+
// options.textFormat, never _rawBody.text, and would emulate a surviving format through
|
|
111
|
+
// its structured-output tool, so it must go here too.)
|
|
111
112
|
delete parsed.options.textFormat;
|
|
112
113
|
delete parsed._structuredOutput;
|
|
113
114
|
if (parsed._rawBody && typeof parsed._rawBody === "object") {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { formatClientRetryAfter } from "../../lib/client-retry-after";
|
|
1
2
|
import { mapSpendLedgerStorageError } from "./spend-storage-error";
|
|
2
3
|
import type { ResponsesRequestContext, ResponsesAdmissionState } from "./core-options";
|
|
3
4
|
import type { PreparedResponsesRequest } from "./request-prepare";
|
|
@@ -49,7 +50,7 @@ import { rememberResponseState } from "../../responses/state";
|
|
|
49
50
|
import { trackStreamLifetime } from "../lifecycle";
|
|
50
51
|
import { awaitThoughtSignatureDurability } from "../../responses/thought-signature-replay";
|
|
51
52
|
import { undeclaredToolCallMessage } from "../responses-undeclared-tool-guard";
|
|
52
|
-
import { emptyToolCatalogRefusal, guardEmptyToolCatalogEvents, guardEmptyToolCatalogStream } from "../../lib/empty-tool-catalog";
|
|
53
|
+
import { currentTurnToolBridgeMaps, emptyToolCatalogRefusal, guardEmptyToolCatalogEvents, guardEmptyToolCatalogStream } from "../../lib/empty-tool-catalog";
|
|
53
54
|
// LOCAL PATCH (runturn-websearch)
|
|
54
55
|
import { planWebSearch } from "../../web-search";
|
|
55
56
|
import { runTurnWebSearchInitialParsed, runTurnWebSearchLoop } from "../../web-search/run-turn-loop";
|
|
@@ -196,7 +197,7 @@ export async function executeResponsesRunTurn(
|
|
|
196
197
|
} }), {
|
|
197
198
|
status: 429,
|
|
198
199
|
headers: { "Content-Type": "application/json",
|
|
199
|
-
...(usage.resetAt ? { "Retry-After":
|
|
200
|
+
...(usage.resetAt ? { "Retry-After": formatClientRetryAfter(Math.max(1, Math.ceil((usage.resetAt - Date.now()) / 1000)))! } : {}),
|
|
200
201
|
},
|
|
201
202
|
});
|
|
202
203
|
markResponseNonReplayable(refusal);
|
|
@@ -755,8 +756,7 @@ export async function executeResponsesRunTurn(
|
|
|
755
756
|
|
|
756
757
|
const clientToolCatalog = requestState.clientToolCatalogRestriction && route.provider.authMode !== "forward"
|
|
757
758
|
? requestState.clientToolCatalogRestriction : undefined;
|
|
758
|
-
const { toolNsMap, declaredToolNames, toolParameterSchemas, freeformToolNames, bareCustomToolNames, toolSearchToolNames } = clientToolCatalog
|
|
759
|
-
? { ...toolBridgeMaps, ...clientToolCatalog } : toolBridgeMaps;
|
|
759
|
+
const { toolNsMap, declaredToolNames, toolParameterSchemas, freeformToolNames, bareCustomToolNames, toolSearchToolNames } = currentTurnToolBridgeMaps(toolBridgeMaps, clientToolCatalog);
|
|
760
760
|
const enforceDeclaredToolNames = inboundWire !== "chat" && inboundWire !== "anthropic";
|
|
761
761
|
const classifyUndeclaredFirstTool = (
|
|
762
762
|
event: AdapterEvent,
|
|
@@ -772,7 +772,7 @@ export async function executeResponsesRunTurn(
|
|
|
772
772
|
type: "error",
|
|
773
773
|
status: 502,
|
|
774
774
|
errorType: "upstream_error",
|
|
775
|
-
message: undeclaredToolCallMessage(
|
|
775
|
+
message: undeclaredToolCallMessage(),
|
|
776
776
|
};
|
|
777
777
|
};
|
|
778
778
|
const grokDevinPreflight = !options.comboAttempt && logCtx.surface === "grok" && inboundWire === "responses"
|
|
@@ -896,7 +896,7 @@ export async function executeResponsesRunTurn(
|
|
|
896
896
|
queue.close();
|
|
897
897
|
}, 2_000,
|
|
898
898
|
{
|
|
899
|
-
translatorBudget,
|
|
899
|
+
translatorBudget, proxyErrorContext: logCtx,
|
|
900
900
|
replayCacheScope: parsed._reasoningReplayScope,
|
|
901
901
|
...(options.forceEmptyResponseId ? { responseId: "" } : {}),
|
|
902
902
|
stallTimeoutSec,
|