@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
package/src/codex/shim.ts
CHANGED
|
@@ -4,11 +4,9 @@ import {
|
|
|
4
4
|
existsSync,
|
|
5
5
|
lstatSync,
|
|
6
6
|
readFileSync,
|
|
7
|
-
renameSync,
|
|
8
|
-
unlinkSync,
|
|
9
7
|
writeFileSync,
|
|
10
8
|
} from "node:fs";
|
|
11
|
-
import { delimiter,
|
|
9
|
+
import { delimiter, join, posix, win32 } from "node:path";
|
|
12
10
|
import { durableBunRuntime, type DurableBunRuntime } from "../lib/bun-runtime";
|
|
13
11
|
import type { FileIdentity } from "../lib/file-identity";
|
|
14
12
|
import { assertSelectedRuntimeWritable, RuntimePreflightError, type RuntimePreflightDeps } from "../lib/bun-runtime-preflight";
|
|
@@ -33,7 +31,6 @@ import {
|
|
|
33
31
|
} from "./shim-fingerprint";
|
|
34
32
|
import {
|
|
35
33
|
fileErrorCode,
|
|
36
|
-
readState,
|
|
37
34
|
readStateResult,
|
|
38
35
|
stateFiles,
|
|
39
36
|
statePath,
|
|
@@ -58,6 +55,18 @@ import {
|
|
|
58
55
|
type CodexPathScanDeps,
|
|
59
56
|
} from "./shim-path-resolution";
|
|
60
57
|
import { ownedWrapperFingerprint, windowsShimContent, wrapperInodeIsOurs, writeShim } from "./shim-wrapper-write";
|
|
58
|
+
import {
|
|
59
|
+
checkLegacyShimRecord,
|
|
60
|
+
hostShimPathApi,
|
|
61
|
+
guardedRenameSync as renameSync,
|
|
62
|
+
guardedUnlinkSync as unlinkSync,
|
|
63
|
+
legacyShimBackupPath,
|
|
64
|
+
legacyShimDirectoryUnchanged,
|
|
65
|
+
legacyShimFilesProblem,
|
|
66
|
+
legacyShimFreshLaunchersProblem,
|
|
67
|
+
legacyShimManualRestoreMessage,
|
|
68
|
+
setLegacyShimMutationGuard,
|
|
69
|
+
} from "./shim-legacy-record";
|
|
61
70
|
|
|
62
71
|
export { buildUnixCodexShim, buildWindowsCodexShim, buildWindowsPowerShellCodexShim } from "./shim-templates";
|
|
63
72
|
export { isVersionManagerOwnedCodexPath } from "./shim-fingerprint";
|
|
@@ -207,8 +216,7 @@ function findWindowsCodexTargets(): ShimFileState[] | null {
|
|
|
207
216
|
}
|
|
208
217
|
|
|
209
218
|
function backupPathFor(path: string): string {
|
|
210
|
-
|
|
211
|
-
return ext ? `${path.slice(0, -ext.length)}.opencodex-real${ext}` : `${path}.opencodex-real`;
|
|
219
|
+
return legacyShimBackupPath(path);
|
|
212
220
|
}
|
|
213
221
|
|
|
214
222
|
/**
|
|
@@ -770,8 +778,19 @@ function refreshObsoleteUnixShims(files: readonly ShimFileState[], runtime?: Dur
|
|
|
770
778
|
};
|
|
771
779
|
}
|
|
772
780
|
|
|
773
|
-
|
|
774
|
-
|
|
781
|
+
type InstallResult = { installed: boolean; message: string; refused?: boolean };
|
|
782
|
+
|
|
783
|
+
function installCodexShimInternal(options: InstallCodexShimInternalOptions): InstallResult {
|
|
784
|
+
const read = readStateResult();
|
|
785
|
+
// A record that is present but unreadable is not "no record": a fresh install would overwrite it.
|
|
786
|
+
if (read.present && !read.state) return { installed: false, refused: true, message: legacyShimManualRestoreMessage(read.warning ? "the shim record is unsafe to read" : "the shim record is unreadable", statePath()) };
|
|
787
|
+
const legacy = read.state ? checkLegacyShimRecord(read.state) : null;
|
|
788
|
+
if (legacy && !legacy.ok) return { installed: false, refused: true, message: legacyShimManualRestoreMessage(legacy.reason, statePath()) };
|
|
789
|
+
const release = setLegacyShimMutationGuard(legacy);
|
|
790
|
+
try { return installCodexShimFromState(options, read.state); } finally { release(); }
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
function installCodexShimFromState(options: InstallCodexShimInternalOptions, existing: ShimState | null): InstallResult {
|
|
775
794
|
const filesBefore = existing ? stateFiles(existing) : [];
|
|
776
795
|
if (filesBefore.length > 0 && filesBefore.every(file => {
|
|
777
796
|
if (file.preserveOnly) return existsSync(file.backupPath) && !existsSync(file.originalPath);
|
|
@@ -864,6 +883,11 @@ function installCodexShimInternal(options: InstallCodexShimInternalOptions): { i
|
|
|
864
883
|
return originalPath ? [{ wrapperPath: originalPath, originalPath, backupPath: backupPathFor(originalPath) }] : null;
|
|
865
884
|
})();
|
|
866
885
|
if (!targets) return { installed: false, message: lastShimDiscoveryError ?? "Could not find a codex executable on PATH." };
|
|
886
|
+
// The writer obeys the rules every later restore checks, so it never records a layout it would refuse.
|
|
887
|
+
const fresh = checkLegacyShimRecord(primaryState(targets));
|
|
888
|
+
const freshProblem = fresh.ok ? legacyShimFreshLaunchersProblem(fresh.files, fresh.resolvedDirectory) : fresh.reason;
|
|
889
|
+
if (!fresh.ok || freshProblem) return { installed: false, refused: true, message: `Refusing to install the Codex autostart shim: ${freshProblem}.` };
|
|
890
|
+
setLegacyShimMutationGuard(fresh); // released with the caller's guard
|
|
867
891
|
|
|
868
892
|
for (const target of targets) {
|
|
869
893
|
if (existsSync(target.backupPath)) return { installed: false, message: `Refusing to overwrite existing backup: ${target.backupPath}` };
|
|
@@ -1032,6 +1056,8 @@ function autoRestoreWindowsCodexShim(options: RuntimePreflightDeps & {
|
|
|
1032
1056
|
return { status: stateRead.present ? "ineligible" : "not-installed" };
|
|
1033
1057
|
}
|
|
1034
1058
|
if (state.platform !== process.platform) return { status: "ineligible" };
|
|
1059
|
+
const legacy = checkLegacyShimRecord(state);
|
|
1060
|
+
if (!legacy.ok) return { status: "ineligible", message: legacyShimManualRestoreMessage(legacy.reason, statePath()) };
|
|
1035
1061
|
|
|
1036
1062
|
const files = stateFiles(state);
|
|
1037
1063
|
const replacementProbes = new Map<string, StableShimPathProbe>();
|
|
@@ -1104,9 +1130,15 @@ function autoRestoreWindowsCodexShim(options: RuntimePreflightDeps & {
|
|
|
1104
1130
|
|| !sameStableShimPathProbe(firstProbe, secondProbe)) return { status: "deferred" };
|
|
1105
1131
|
}
|
|
1106
1132
|
if (state.platform === "win32") {
|
|
1133
|
+
// Recheck after the lock and the stability sleep, immediately before the wrappers are rewritten.
|
|
1134
|
+
const recheck = checkLegacyShimRecord(state);
|
|
1135
|
+
if (!recheck.ok) return { status: "ineligible", message: legacyShimManualRestoreMessage(recheck.reason, statePath()) };
|
|
1107
1136
|
const realFor = (path: string) => { const file = files.find(entry => entry.wrapperPath === path)!; return file.realPath ?? file.backupPath; };
|
|
1108
|
-
|
|
1109
|
-
|
|
1137
|
+
const release = setLegacyShimMutationGuard(recheck);
|
|
1138
|
+
try {
|
|
1139
|
+
return refreshAdmittedWindowsShims(obsoleteShimProbes, currentShimProbes, path => windowsShimContent(path, realFor(path), runtime))
|
|
1140
|
+
? { status: "restored", message: `Upgraded Codex autostart shim at ${[...obsoleteShimProbes.keys()].join(", ")}.` } : { status: "deferred" };
|
|
1141
|
+
} finally { release(); }
|
|
1110
1142
|
}
|
|
1111
1143
|
const result = refreshObsoleteUnixShims(files);
|
|
1112
1144
|
return result.installed
|
|
@@ -1130,13 +1162,13 @@ function autoRestoreWindowsCodexShim(options: RuntimePreflightDeps & {
|
|
|
1130
1162
|
});
|
|
1131
1163
|
return result.installed
|
|
1132
1164
|
? { status: "restored", message: result.message }
|
|
1133
|
-
: { status: "deferred" };
|
|
1165
|
+
: result.refused ? { status: "ineligible", message: result.message } : { status: "deferred" };
|
|
1134
1166
|
} finally {
|
|
1135
1167
|
lock.release();
|
|
1136
1168
|
}
|
|
1137
1169
|
}
|
|
1138
1170
|
|
|
1139
|
-
export function uninstallCodexShim(): { removed: boolean; message: string } {
|
|
1171
|
+
export function uninstallCodexShim(): { removed: boolean; message: string; refused?: boolean } {
|
|
1140
1172
|
if (process.platform !== "win32") return uninstallUnixCodexShim();
|
|
1141
1173
|
const gate = beginCodexCliSelectionParentWrite();
|
|
1142
1174
|
if (!gate.entered) return { removed: false, message: "codex_cli_selection_busy" };
|
|
@@ -1144,16 +1176,43 @@ export function uninstallCodexShim(): { removed: boolean; message: string } {
|
|
|
1144
1176
|
finally { gate.exit(); }
|
|
1145
1177
|
}
|
|
1146
1178
|
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1179
|
+
let legacyUninstallStepHookForTests: ((step: "unlink" | "rename", index: number) => void) | null = null;
|
|
1180
|
+
/** @internal Runs before each uninstall mutation, after validation; lets tests change the filesystem there. */
|
|
1181
|
+
export function setLegacyShimUninstallStepHookForTests(hook: typeof legacyUninstallStepHookForTests): void {
|
|
1182
|
+
legacyUninstallStepHookForTests = hook;
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
function uninstallWindowsCodexShim(): { removed: boolean; message: string; refused?: boolean } {
|
|
1186
|
+
const read = readStateResult();
|
|
1187
|
+
const refused = (reason: string, partial = false) => ({ removed: false, refused: true, message: legacyShimManualRestoreMessage(reason, statePath(), partial) });
|
|
1188
|
+
if (!read.state) return read.present ? refused(read.warning ? "the shim record is unsafe to read" : "the shim record is unreadable") : { removed: false, message: "Codex autostart shim is not installed." };
|
|
1189
|
+
if (read.state.mode !== undefined || read.state.platform !== "win32") {
|
|
1190
|
+
// Another platform's record (a config directory shared with WSL) names no Windows launcher.
|
|
1191
|
+
if (existsSync(statePath())) unlinkSync(statePath());
|
|
1192
|
+
return { removed: true, message: "Codex autostart shim record from another platform removed; no launcher file was changed." };
|
|
1154
1193
|
}
|
|
1155
|
-
|
|
1156
|
-
|
|
1194
|
+
const checked = checkLegacyShimRecord(read.state);
|
|
1195
|
+
if (!checked.ok) return refused(checked.reason);
|
|
1196
|
+
const { files, recordedDirectory, resolvedDirectory, directoryIdentity } = checked;
|
|
1197
|
+
if (resolvedDirectory !== null) {
|
|
1198
|
+
const api = hostShimPathApi();
|
|
1199
|
+
const at = (path: string) => api.join(resolvedDirectory, api.basename(path));
|
|
1200
|
+
// Act only inside the directory that was validated, and only while it still resolves there.
|
|
1201
|
+
const stillValid = () => legacyShimDirectoryUnchanged(recordedDirectory, resolvedDirectory, directoryIdentity)
|
|
1202
|
+
&& legacyShimFilesProblem(files, resolvedDirectory) === null;
|
|
1203
|
+
let step = 0;
|
|
1204
|
+
for (const [index, file] of files.entries()) {
|
|
1205
|
+
legacyUninstallStepHookForTests?.("unlink", index);
|
|
1206
|
+
if (!stillValid()) return refused("the launcher directory changed during removal", step > 0);
|
|
1207
|
+
const wrapper = at(file.wrapperPath);
|
|
1208
|
+
if (existsSync(wrapper) && isShim(wrapper)) { unlinkSync(wrapper); step++; }
|
|
1209
|
+
}
|
|
1210
|
+
for (const [index, file] of files.entries()) {
|
|
1211
|
+
legacyUninstallStepHookForTests?.("rename", index);
|
|
1212
|
+
if (!stillValid()) return refused("the launcher directory changed during removal", step > 0);
|
|
1213
|
+
const backup = at(file.backupPath), original = at(file.originalPath);
|
|
1214
|
+
if (existsSync(backup) && !existsSync(original)) { renameSync(backup, original); step++; }
|
|
1215
|
+
}
|
|
1157
1216
|
}
|
|
1158
1217
|
if (existsSync(statePath())) unlinkSync(statePath());
|
|
1159
1218
|
return { removed: true, message: `Codex autostart shim removed. Restored ${files.map(f => f.originalPath).join(", ")}.` };
|
|
@@ -84,22 +84,73 @@ export function sourceAssignmentSpan(lines: readonly SourceLine[], start: number
|
|
|
84
84
|
const decoded = sourceAssignment(lines, start, limit);
|
|
85
85
|
if (decoded) return decoded;
|
|
86
86
|
const span = lexicalAssignmentSpan(lines, start, limit);
|
|
87
|
-
|
|
88
|
-
//
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if (integer < -(1n << 63n) || integer >= (1n << 63n)) return null;
|
|
95
|
-
// Keep the parser responsible for the key, separator and comment grammar. Replacing
|
|
96
|
-
// this already validated integer for validation never edits or decodes the source value.
|
|
87
|
+
if (!span) return null;
|
|
88
|
+
// Bun rejects valid TOML integers outside the JS safe-integer range, as scalars and
|
|
89
|
+
// inside arrays or inline tables alike. Validate a copy in which each such integer that
|
|
90
|
+
// fits signed 64 bits reads `0`; the parser stays responsible for every other piece of
|
|
91
|
+
// grammar, and the returned span keeps the original bytes untouched.
|
|
92
|
+
const masked = maskWideIntegers(span.text);
|
|
93
|
+
if (masked === null) return null;
|
|
97
94
|
try {
|
|
98
|
-
const parsed = Bun.TOML.parse(
|
|
95
|
+
const parsed = Bun.TOML.parse(masked);
|
|
99
96
|
return Object.keys(parsed).length === 1 && Object.hasOwn(parsed, span.key) ? span : null;
|
|
100
97
|
} catch { return null; }
|
|
101
98
|
}
|
|
102
99
|
|
|
100
|
+
const integerToken = /^(?:[+-]?(?:0|[1-9](?:_?[0-9])*)|0x[0-9A-Fa-f](?:_?[0-9A-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[01](?:_?[01])*)$/;
|
|
101
|
+
const bareToken = /[A-Za-z0-9_+.:-]/;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* The assignment with every integer outside the JS safe range replaced by `0`, skipping
|
|
105
|
+
* strings and comments. Null when an integer does not fit signed 64 bits (TOML requires a
|
|
106
|
+
* reader to reject it) or when nothing needed masking, so the original parse failure stands.
|
|
107
|
+
*/
|
|
108
|
+
function maskWideIntegers(text: string): string | null {
|
|
109
|
+
let out = "";
|
|
110
|
+
let masked = false;
|
|
111
|
+
let index = 0;
|
|
112
|
+
const copyUntil = (end: number) => { out += text.slice(index, end); index = end; };
|
|
113
|
+
while (index < text.length) {
|
|
114
|
+
const char = text[index]!;
|
|
115
|
+
if (text.startsWith('"""', index) || text.startsWith("'''", index)) {
|
|
116
|
+
const delimiter = text.slice(index, index + 3);
|
|
117
|
+
let cursor = index + 3;
|
|
118
|
+
while (cursor < text.length && !text.startsWith(delimiter, cursor)) cursor += delimiter === '"""' && text[cursor] === "\\" ? 2 : 1;
|
|
119
|
+
cursor = Math.min(text.length, cursor + 3);
|
|
120
|
+
// A closing delimiter may carry up to two more quote characters of content.
|
|
121
|
+
for (let extra = 0; extra < 2 && text[cursor] === delimiter[0]; extra += 1) cursor += 1;
|
|
122
|
+
copyUntil(cursor);
|
|
123
|
+
} else if (char === '"' || char === "'") {
|
|
124
|
+
let cursor = index + 1;
|
|
125
|
+
while (cursor < text.length && text[cursor] !== char && text[cursor] !== "\n") cursor += char === '"' && text[cursor] === "\\" ? 2 : 1;
|
|
126
|
+
copyUntil(Math.min(text.length, cursor + 1));
|
|
127
|
+
} else if (char === "#") {
|
|
128
|
+
const newline = text.indexOf("\n", index);
|
|
129
|
+
copyUntil(newline === -1 ? text.length : newline);
|
|
130
|
+
} else if (bareToken.test(char)) {
|
|
131
|
+
let cursor = index + 1;
|
|
132
|
+
while (cursor < text.length && bareToken.test(text[cursor]!)) cursor += 1;
|
|
133
|
+
const token = text.slice(index, cursor);
|
|
134
|
+
// A digit-only bare key (`{ 9223372036854775808 = 1 }`) is a name, not a number.
|
|
135
|
+
const isKey = /^[ \t]*[=.]/.test(text.slice(cursor));
|
|
136
|
+
if (!isKey && integerToken.test(token)) {
|
|
137
|
+
const integer = BigInt(token.replaceAll("_", ""));
|
|
138
|
+
if (integer < -(1n << 63n) || integer >= (1n << 63n)) return null;
|
|
139
|
+
if (integer > BigInt(Number.MAX_SAFE_INTEGER) || integer < -BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
140
|
+
out += "0";
|
|
141
|
+
index = cursor;
|
|
142
|
+
masked = true;
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
copyUntil(cursor);
|
|
147
|
+
} else {
|
|
148
|
+
copyUntil(index + 1);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return masked ? out : null;
|
|
152
|
+
}
|
|
153
|
+
|
|
103
154
|
/** Cosmetic document whitespace only; opaque value lines retain every byte. */
|
|
104
155
|
export function normalizeStructuralWhitespace(content: string): string {
|
|
105
156
|
const { bom, lines } = rootSourceLines(content);
|
|
@@ -122,6 +173,13 @@ export function normalizeStructuralWhitespace(content: string): string {
|
|
|
122
173
|
|
|
123
174
|
type MultilineStringKind = "basic" | "literal" | null;
|
|
124
175
|
|
|
176
|
+
/** Length of a closing multiline delimiter: TOML allows a run of three to five quotes. */
|
|
177
|
+
function quoteRunLength(text: string, index: number, quote: string): number {
|
|
178
|
+
let end = index;
|
|
179
|
+
while (end < text.length && text[end] === quote && end - index < 5) end += 1;
|
|
180
|
+
return end - index;
|
|
181
|
+
}
|
|
182
|
+
|
|
125
183
|
/**
|
|
126
184
|
* TOML table-looking text inside a multiline string is data, not syntax. Keep
|
|
127
185
|
* a deliberately small lexical state machine so the format-preserving editor
|
|
@@ -139,8 +197,9 @@ function markStructuralLines(lines: SourceLine[]): void {
|
|
|
139
197
|
for (let index = 0; index < line.text.length;) {
|
|
140
198
|
if (multiline === "basic") {
|
|
141
199
|
if (line.text.startsWith('"""', index)) {
|
|
200
|
+
// A closing delimiter may carry up to two content quotes before it.
|
|
142
201
|
multiline = null;
|
|
143
|
-
index +=
|
|
202
|
+
index += quoteRunLength(line.text, index, '"');
|
|
144
203
|
} else if (line.text[index] === "\\") {
|
|
145
204
|
index += 2;
|
|
146
205
|
} else {
|
|
@@ -151,7 +210,7 @@ function markStructuralLines(lines: SourceLine[]): void {
|
|
|
151
210
|
if (multiline === "literal") {
|
|
152
211
|
if (line.text.startsWith("'''", index)) {
|
|
153
212
|
multiline = null;
|
|
154
|
-
index +=
|
|
213
|
+
index += quoteRunLength(line.text, index, "'");
|
|
155
214
|
} else {
|
|
156
215
|
index += 1;
|
|
157
216
|
}
|
package/src/combos/failover.ts
CHANGED
|
@@ -5,6 +5,10 @@ import { isAnthropicBillingFailure } from "../providers/anthropic-billing-refusa
|
|
|
5
5
|
import { isKiroAccountProfileRefusal } from "../adapters/kiro-refusal";
|
|
6
6
|
import type { OcxComboTarget } from "../types";
|
|
7
7
|
import { targetKey } from "./types";
|
|
8
|
+
import { isDefiniteContextOverflow } from "../lib/context-overflow-verdict";
|
|
9
|
+
|
|
10
|
+
// The verdict lives in a dependency-free leaf so the presentation classifier can share it.
|
|
11
|
+
export { isDefiniteContextOverflow };
|
|
8
12
|
import {
|
|
9
13
|
captureConfigGeneration,
|
|
10
14
|
sweepExpiredOnWrite,
|
|
@@ -433,6 +437,7 @@ function isProviderScopedQuotaCap(
|
|
|
433
437
|
message: string,
|
|
434
438
|
code?: string | null,
|
|
435
439
|
): boolean {
|
|
440
|
+
if (status === 400 || status === 422) return false; // Validation prose may reflect the caller's input.
|
|
436
441
|
const normalizedCode = normalizedFailureCode(code);
|
|
437
442
|
const text = message.toLowerCase();
|
|
438
443
|
if (
|
|
@@ -463,7 +468,7 @@ function isRequestLocalFreePromptCap(
|
|
|
463
468
|
message: string,
|
|
464
469
|
code?: string | null,
|
|
465
470
|
): boolean {
|
|
466
|
-
if (status !== 400) return false;
|
|
471
|
+
if (status !== 400 && status !== 422) return false;
|
|
467
472
|
const text = message.toLowerCase();
|
|
468
473
|
if (normalizedFailureCode(code) === "free_rate_limited") return true;
|
|
469
474
|
if (text.includes("err_free_prompt_cap")) return true;
|
|
@@ -704,114 +709,6 @@ function isProviderTargetContextOverflow(
|
|
|
704
709
|
&& /\bprompt\s+\d+\s*>\s*\d+\s+maximum context length\b/i.test(message);
|
|
705
710
|
}
|
|
706
711
|
|
|
707
|
-
/** A status can carry a verdict about the REQUEST; 401/403/429 speak about the credential. */
|
|
708
|
-
const CONTEXT_VERDICT_STATUSES: ReadonlySet<number> = new Set([400, 413, 422]);
|
|
709
|
-
|
|
710
|
-
/**
|
|
711
|
-
* Phrases a provider emits when the INPUT does not fit this model's context window. Matched
|
|
712
|
-
* against the innermost provider message only, so an unrelated refusal that merely quotes one
|
|
713
|
-
* of these tokens in a code field cannot authorize a replay.
|
|
714
|
-
*/
|
|
715
|
-
const DEFINITE_CONTEXT_OVERFLOW_PHRASES = [
|
|
716
|
-
"exceeds the context window",
|
|
717
|
-
"exceed the context window",
|
|
718
|
-
"context window exceeded",
|
|
719
|
-
"context length exceeded",
|
|
720
|
-
"maximum context length",
|
|
721
|
-
"maximum context window",
|
|
722
|
-
"too many tokens",
|
|
723
|
-
];
|
|
724
|
-
|
|
725
|
-
/**
|
|
726
|
-
* Short provider verdicts that a validation error could otherwise echo as the caller's own value
|
|
727
|
-
* (#7443). Each counts only at the very start of the provider's leaf message, after JSON envelopes
|
|
728
|
-
* are unwrapped, and Anthropic's only with its token counts. Text that merely contains one, including
|
|
729
|
-
* a serialized SDK exception or a quoted caller object, is not evidence: only the phrases dev already
|
|
730
|
-
* matched as substrings keep that wider reach.
|
|
731
|
-
*/
|
|
732
|
-
const ANCHORED_CONTEXT_OVERFLOW_VERDICTS: readonly RegExp[] = [
|
|
733
|
-
/^prompt is too long: \d+ tokens > \d+ maximum/i,
|
|
734
|
-
/^input is too long for requested model\b/i,
|
|
735
|
-
/^please reduce the length of the messages or completion\b/i,
|
|
736
|
-
];
|
|
737
|
-
|
|
738
|
-
/** Wrapper envelopes unwrapped before the leaf message is read. */
|
|
739
|
-
const MAX_CONTEXT_OVERFLOW_ENVELOPES = 4;
|
|
740
|
-
|
|
741
|
-
/**
|
|
742
|
-
* Parameter validation echoes the caller's own value, so its prose is not a context verdict even
|
|
743
|
-
* when the value reads like one: "Invalid 'tools[0].function.name': 'prompt is too long'". These
|
|
744
|
-
* markers are read anywhere in the text, so an SDK error wrapper that serializes such a record as a
|
|
745
|
-
* Python dict is refused too, while a quoted genuine verdict in the same wrapper stays evidence.
|
|
746
|
-
*/
|
|
747
|
-
const CONTEXT_PARAM_NAMES = "messages|input|input_text|input_tokens|prompt|contents?|max_tokens|max_completion_tokens|max_output_tokens";
|
|
748
|
-
/** A `param` naming the conversation or a token budget is consistent with an overflow. */
|
|
749
|
-
const CONTEXT_PARAM = new RegExp(`^(?:${CONTEXT_PARAM_NAMES})(?:$|[.[])`, "i");
|
|
750
|
-
const PARAMETER_VALIDATION_CODES: ReadonlySet<string> = new Set(["invalid_value", "invalid_type"]);
|
|
751
|
-
const PARAMETER_VALIDATION_MARKERS: readonly RegExp[] = [
|
|
752
|
-
/\binvalid_(?:value|type)\b/i,
|
|
753
|
-
new RegExp(`['"]param['"]\\s*:\\s*['"](?!(?:${CONTEXT_PARAM_NAMES})(?:['".[]))`, "i"),
|
|
754
|
-
/\binvalid\s+(?:value\s+for\s+)?['"`\u2018\u201c]/i,
|
|
755
|
-
/\binvalid\s+(?:tool|function|parameter|argument|field|value)\b/i,
|
|
756
|
-
/\binput_value\s*=/i,
|
|
757
|
-
/\bvalidation errors? for\b/i,
|
|
758
|
-
];
|
|
759
|
-
|
|
760
|
-
function isParameterValidationRecord(record: Record<string, unknown>): boolean {
|
|
761
|
-
if (typeof record.code === "string" && PARAMETER_VALIDATION_CODES.has(record.code.toLowerCase())) return true;
|
|
762
|
-
return typeof record.param === "string" && record.param.length > 0 && !CONTEXT_PARAM.test(record.param);
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
function isDefiniteContextOverflowMessage(text: string): boolean {
|
|
766
|
-
if (PARAMETER_VALIDATION_MARKERS.some(marker => marker.test(text))) return false;
|
|
767
|
-
const normalized = text.toLowerCase();
|
|
768
|
-
return normalized === "context_length_exceeded"
|
|
769
|
-
|| DEFINITE_CONTEXT_OVERFLOW_PHRASES.some(phrase => normalized.includes(phrase))
|
|
770
|
-
|| ANCHORED_CONTEXT_OVERFLOW_VERDICTS.some(verdict => verdict.test(text.trim()));
|
|
771
|
-
}
|
|
772
|
-
|
|
773
|
-
/**
|
|
774
|
-
* Confirm a context overflow from the provider MESSAGE rather than from a code token that
|
|
775
|
-
* merely appears somewhere in the envelope. An upstream controls both fields and can emit a
|
|
776
|
-
* contradictory pair -- `context_length_exceeded` beside `Unsupported parameter: user` -- and
|
|
777
|
-
* that is not evidence the turn is too large for this model. `classifyError` reads the whole
|
|
778
|
-
* blob, which is exactly the looseness this must not inherit.
|
|
779
|
-
*
|
|
780
|
-
* A JSON-shaped body that fails to parse is truncated or corrupt, not prose: `classificationText`
|
|
781
|
-
* is capped at 500 characters by `normalizeUpstreamErrorText` before it reaches this function, so
|
|
782
|
-
* a long envelope arrives here as a JSON prefix. Reading that prefix as plain text would let an
|
|
783
|
-
* arbitrary field that happens to sit in the first 500 bytes authorize a hop, so it fails closed.
|
|
784
|
-
*
|
|
785
|
-
* Only the exact proxy wrapper is unwrapped, within a fixed envelope budget and 16,384 characters.
|
|
786
|
-
* Exported for the sidecar loops, which classify their own provider failures with the same rule.
|
|
787
|
-
*/
|
|
788
|
-
export function isDefiniteContextOverflow(status: number, message: string): boolean {
|
|
789
|
-
if (!CONTEXT_VERDICT_STATUSES.has(status) && status < 500) return false;
|
|
790
|
-
if (message.length > 16_384) return false;
|
|
791
|
-
let text = message.trim();
|
|
792
|
-
// One pass per unwrapped envelope, plus one for the leaf the last envelope yields.
|
|
793
|
-
for (let unwrapped = 0; unwrapped <= MAX_CONTEXT_OVERFLOW_ENVELOPES; unwrapped += 1) {
|
|
794
|
-
const providerPrefix = /^Provider error \d{3}:\s*/.exec(text);
|
|
795
|
-
if (providerPrefix) text = text.slice(providerPrefix[0].length).trim();
|
|
796
|
-
if (!text.startsWith("{")) return isDefiniteContextOverflowMessage(text);
|
|
797
|
-
if (unwrapped === MAX_CONTEXT_OVERFLOW_ENVELOPES) return false;
|
|
798
|
-
let payload: unknown;
|
|
799
|
-
try { payload = JSON.parse(text); } catch { return false; }
|
|
800
|
-
if (!payload || typeof payload !== "object" || Array.isArray(payload)) return false;
|
|
801
|
-
const record = payload as Record<string, unknown>;
|
|
802
|
-
const response = record.response && typeof record.response === "object" && !Array.isArray(record.response)
|
|
803
|
-
? record.response as Record<string, unknown>
|
|
804
|
-
: undefined;
|
|
805
|
-
const source = [record.error, response?.error, response?.last_error, record.last_error, record]
|
|
806
|
-
.find((candidate): candidate is Record<string, unknown> =>
|
|
807
|
-
!!candidate && typeof candidate === "object" && !Array.isArray(candidate)
|
|
808
|
-
&& typeof (candidate as Record<string, unknown>).message === "string");
|
|
809
|
-
if (!source || isParameterValidationRecord(source)) return false;
|
|
810
|
-
text = (source.message as string).trim();
|
|
811
|
-
}
|
|
812
|
-
return false;
|
|
813
|
-
}
|
|
814
|
-
|
|
815
712
|
const CODEX_ACCOUNT_MODEL_REFUSAL = /^The '[^']{1,256}' model is not supported when using Codex with a ChatGPT account\.$/;
|
|
816
713
|
|
|
817
714
|
export type CodexAccountModelRefusal = "other" | "refusal" | "ambiguous";
|
package/src/combos/request.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { errorDestinationText, providerErrorDestinationLabel } from "../lib/error-destination";
|
|
1
2
|
import type { OcxComboDefaultEffort, OcxComboDefaultEffortMode, OcxComboReasoningEffortMode, OcxComboTarget, OcxConfig } from "../types";
|
|
2
3
|
import { isCodexReasoningEffort, isDeclaredReasoningEffort, resolveEffortAtOrBelow } from "../reasoning-effort";
|
|
3
4
|
import { resolveComboId } from "./types";
|
|
@@ -109,8 +110,7 @@ export function concreteComboRequestBody(
|
|
|
109
110
|
if (!warnedUnsupportedDefaults.has(key)) {
|
|
110
111
|
warnedUnsupportedDefaults.add(key);
|
|
111
112
|
console.debug("[opencodex] combo default effort omitted", {
|
|
112
|
-
provider: target.provider,
|
|
113
|
-
model: target.model,
|
|
113
|
+
provider: errorDestinationText(providerErrorDestinationLabel(target.provider)),
|
|
114
114
|
requestedEffort: defaultEffort,
|
|
115
115
|
capability: targetReasoningEfforts === undefined ? "unknown" : "unsupported",
|
|
116
116
|
});
|
package/src/combos/resolve.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { errorDestinationText, providerErrorDestinationLabel } from "../lib/error-destination";
|
|
1
2
|
import type { OcxComboTarget, OcxConfig } from "../types";
|
|
2
3
|
import { getCachedProviderRoutingQuota } from "../providers/quota-routing-cache";
|
|
3
4
|
import type { ProviderQuota, ProviderQuotaWindow } from "../providers/quota-types";
|
|
@@ -57,16 +58,31 @@ export class UnknownComboError extends Error {
|
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
|
|
61
|
+
declare const exclusionBrand: unique symbol;
|
|
62
|
+
/** Service diagnostics name configured positions and validated providers only. */
|
|
63
|
+
export function comboLogLabel(config: OcxConfig, comboId: string): string {
|
|
64
|
+
const index = Object.keys(config.combos ?? {}).indexOf(comboId);
|
|
65
|
+
return index < 0 ? "combo" : `combo ${index + 1}`;
|
|
66
|
+
}
|
|
67
|
+
export function comboTargetLogLabel(config: OcxConfig, comboId: string, target: OcxComboTarget): string {
|
|
68
|
+
const index = getCombo(config, comboId)?.targets.findIndex(item => targetKey(item) === targetKey(target)) ?? -1;
|
|
69
|
+
return `target ${index + 1} (${errorDestinationText(providerErrorDestinationLabel(target.provider))})`;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export type ComboExclusionReasons = string & { readonly [exclusionBrand]: true };
|
|
73
|
+
|
|
60
74
|
export class NoAvailableComboTargetsError extends Error {
|
|
61
75
|
readonly code = "combo_unavailable";
|
|
62
76
|
|
|
63
|
-
constructor(readonly comboId: string, readonly reasons
|
|
64
|
-
super(`No available targets for combo
|
|
77
|
+
constructor(readonly comboId: string, readonly reasons?: ComboExclusionReasons) {
|
|
78
|
+
super(`No available targets for combo${reasons ? ` (${reasons})` : ""}`);
|
|
65
79
|
this.name = "NoAvailableComboTargetsError";
|
|
66
80
|
}
|
|
67
81
|
}
|
|
68
82
|
|
|
69
|
-
|
|
83
|
+
type ComboExclusionReason = "provider missing" | "provider disabled" | "quota exhausted" | "cooldown" | "ineligible for this request";
|
|
84
|
+
|
|
85
|
+
function providerExclusionReason(config: OcxConfig, target: OcxComboTarget, now: number): ComboExclusionReason | undefined {
|
|
70
86
|
const provider = Object.hasOwn(config.providers, target.provider) ? config.providers[target.provider] : undefined;
|
|
71
87
|
if (!provider) return "provider missing";
|
|
72
88
|
if (provider.disabled === true) return "provider disabled";
|
|
@@ -93,18 +109,19 @@ export function comboTargetSkipTrigger(
|
|
|
93
109
|
|
|
94
110
|
/**
|
|
95
111
|
* Why each target of a combo cannot be picked right now, for a zero-attempt refusal. Only the
|
|
96
|
-
*
|
|
112
|
+
* target index, validated provider label and a closed exclusion reason are named.
|
|
97
113
|
*/
|
|
98
114
|
export function comboExclusionReasons(
|
|
99
115
|
config: OcxConfig,
|
|
100
116
|
comboId: string,
|
|
101
117
|
eligible?: (target: NormalizedComboTarget) => boolean,
|
|
102
118
|
now = Date.now(),
|
|
103
|
-
):
|
|
104
|
-
|
|
119
|
+
): ComboExclusionReasons {
|
|
120
|
+
const targets = getCombo(config, comboId)?.targets ?? [];
|
|
121
|
+
const reasons = targets.flatMap((target, index) => {
|
|
105
122
|
let reason = providerExclusionReason(config, target, now);
|
|
106
123
|
const cooldown = reason ? undefined : earliestComboCooldown(comboId, [target], now);
|
|
107
|
-
if (cooldown) reason =
|
|
124
|
+
if (cooldown) reason = "cooldown";
|
|
108
125
|
if (!reason && eligible) {
|
|
109
126
|
try {
|
|
110
127
|
if (!eligible(target)) reason = "ineligible for this request";
|
|
@@ -113,8 +130,9 @@ export function comboExclusionReasons(
|
|
|
113
130
|
reason = "ineligible for this request";
|
|
114
131
|
}
|
|
115
132
|
}
|
|
116
|
-
return reason ? [
|
|
133
|
+
return reason ? [`target ${index + 1} (${errorDestinationText(providerErrorDestinationLabel(target.provider))}): ${reason}`] : [];
|
|
117
134
|
}).join("; ");
|
|
135
|
+
return `${targets.length} target${targets.length === 1 ? "" : "s"}${reasons ? `; ${reasons}` : ""}` as ComboExclusionReasons;
|
|
118
136
|
}
|
|
119
137
|
|
|
120
138
|
/** Capture usable providers' quota cooldowns; request eligibility is deferred to exhaustion. */
|
|
@@ -324,7 +342,7 @@ function reserveAllCooledTargets(
|
|
|
324
342
|
const next = state ?? { successes: 0, currentWeights: new Map<string, number>(), successfulUses: new Map<string, number>() };
|
|
325
343
|
next.lastCooldownReprobeAt = now;
|
|
326
344
|
selectionState.set(comboId, next);
|
|
327
|
-
console.warn(`[combo] ${comboId}: reserving all-cooled targets for one request; minimum reprobe interval ${combo.cooldownReprobe.intervalMs}ms`);
|
|
345
|
+
console.warn(`[combo] ${comboLogLabel(config, comboId)}: reserving all-cooled targets for one request; minimum reprobe interval ${combo.cooldownReprobe.intervalMs}ms`);
|
|
328
346
|
return reserved;
|
|
329
347
|
}
|
|
330
348
|
|
|
@@ -624,7 +642,7 @@ export async function pickComboTargetWithWait(
|
|
|
624
642
|
const normalDelay = soonest === undefined ? undefined : soonest.expiry - now;
|
|
625
643
|
if (normalDelay !== undefined && normalDelay <= options.waitForCooldownMs) {
|
|
626
644
|
console.warn(
|
|
627
|
-
`[combo] ${comboId}: deferring last resort, waiting ${normalDelay}ms for ${
|
|
645
|
+
`[combo] ${comboLogLabel(config, comboId)}: deferring last resort, waiting ${normalDelay}ms for ${comboTargetLogLabel(config, comboId, soonest!.target)}`,
|
|
628
646
|
);
|
|
629
647
|
try {
|
|
630
648
|
await (options.sleep ?? sleepWithAbort)(normalDelay, options.abortSignal);
|
|
@@ -677,7 +695,7 @@ export async function pickComboTargetWithWait(
|
|
|
677
695
|
// Its target preserves configured order for ties.
|
|
678
696
|
const target = earliest.target;
|
|
679
697
|
console.warn(
|
|
680
|
-
`[combo] ${comboId}: all targets cooling, waiting ${delay}ms for ${
|
|
698
|
+
`[combo] ${comboLogLabel(config, comboId)}: all targets cooling, waiting ${delay}ms for ${comboTargetLogLabel(config, comboId, target)}`,
|
|
681
699
|
);
|
|
682
700
|
try {
|
|
683
701
|
await (options.sleep ?? sleepWithAbort)(delay, options.abortSignal);
|
|
@@ -783,24 +783,24 @@ export function validateConfigCandidate(value: unknown): { ok: true; config: Ocx
|
|
|
783
783
|
return { ok: false, error: schemaDiagnosticsError(result.error) };
|
|
784
784
|
}
|
|
785
785
|
|
|
786
|
-
export function configDiagnosticsFromRaw(raw: string): ConfigDiagnostics {
|
|
787
|
-
return configDiagnosticsFromText(raw);
|
|
786
|
+
export function configDiagnosticsFromRaw(raw: string, options: { warn?: (message: string) => void } = {}): ConfigDiagnostics {
|
|
787
|
+
return configDiagnosticsFromText(raw, undefined, options.warn);
|
|
788
788
|
}
|
|
789
789
|
|
|
790
|
-
function configDiagnosticsFromText(raw: string, file?: { path: string; bytes: Uint8Array }): ConfigDiagnostics {
|
|
790
|
+
function configDiagnosticsFromText(raw: string, file?: { path: string; bytes: Uint8Array }, warn?: (message: string) => void): ConfigDiagnostics {
|
|
791
791
|
try {
|
|
792
792
|
const parsed = JSON.parse(raw.replace(/^\uFEFF/, ""));
|
|
793
793
|
projectRemovedOpenCodeFreeSnapshot(parsed, file);
|
|
794
794
|
sanitizeOpenCodeOverridesForLoad(parsed);
|
|
795
|
-
sanitizeReasoningPinsForLoad(parsed);
|
|
795
|
+
sanitizeReasoningPinsForLoad(parsed, warn);
|
|
796
796
|
// Same degradation as loadConfig: a hand-edited invalid retryOn429 must not trip the
|
|
797
797
|
// schema and send the caller a default-config fallback (the config command could then
|
|
798
798
|
// persist that fallback over the user's providers/keys).
|
|
799
|
-
sanitizeModelDisplayNamesForLoad(parsed);
|
|
800
|
-
sanitizeAutoReviewForLoad(parsed);
|
|
801
|
-
sanitizeRetryOn429ForLoad(parsed);
|
|
802
|
-
sanitizeModelCostsForLoad(parsed);
|
|
803
|
-
sanitizeCapabilityDeclarationsForLoad(parsed);
|
|
799
|
+
sanitizeModelDisplayNamesForLoad(parsed, warn);
|
|
800
|
+
sanitizeAutoReviewForLoad(parsed, warn);
|
|
801
|
+
sanitizeRetryOn429ForLoad(parsed, warn);
|
|
802
|
+
sanitizeModelCostsForLoad(parsed, warn);
|
|
803
|
+
sanitizeCapabilityDeclarationsForLoad(parsed, warn);
|
|
804
804
|
const result = configSchema.safeParse(parsed);
|
|
805
805
|
if (result.success) {
|
|
806
806
|
return validFileConfigDiagnostics(normalizeApiKeyIds(result.data as OcxConfig), parsed);
|