@bitkyc08/opencodex 2.100.5 → 2.100.6
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/README.md +1 -1
- package/bin/ocx.mjs +2 -0
- package/gui/dist/assets/App-BI8LQ7Qk.css +1 -0
- package/gui/dist/assets/App-CsZ1Gr7S.js +60 -0
- package/gui/dist/assets/Tray-CVqm4S4W.js +1 -0
- package/gui/dist/assets/brand-mark-BebhnAtV.js +1 -0
- package/gui/dist/assets/index-BtwVlpeQ.css +2 -0
- package/gui/dist/assets/index-CEeMegqE.js +138 -0
- package/gui/dist/assets/{segment-thumb-features-Bquysdn5.js → segment-thumb-features-COdzmORE.js} +1 -1
- package/gui/dist/classic/assets/App-BJgUWNJ8.js +59 -0
- package/gui/dist/classic/assets/App-CoiVLRW3.css +1 -0
- package/gui/dist/classic/assets/Tray-BDlcOLDK.js +1 -0
- package/gui/dist/classic/assets/index-B9Jgli_W.js +138 -0
- package/gui/dist/classic/assets/usage-companion-chart-vbzDcND0.js +1 -0
- package/gui/dist/classic/index.html +1 -1
- package/gui/dist/index.html +2 -2
- package/native/ocx-child/Cargo.lock +62 -0
- package/native/ocx-child/Cargo.toml +1 -0
- package/native/ocx-child/src/journal.rs +32 -10
- package/native/ocx-child/src/state.rs +2 -1
- package/native/ocx-child/src/toml_surgeon.rs +183 -72
- package/package.json +2 -2
- package/src/adapters/agy-acp/acp.ts +202 -0
- package/src/adapters/agy-acp/adapter.ts +554 -0
- package/src/adapters/agy-acp/binary.ts +79 -0
- package/src/adapters/agy-acp/options.ts +163 -0
- package/src/adapters/agy-acp/output-redaction.ts +270 -0
- package/src/adapters/agy-acp/policy.ts +105 -0
- package/src/adapters/agy-acp/process.ts +218 -0
- package/src/adapters/anthropic/account-metadata.ts +4 -1
- package/src/adapters/anthropic/advisor-tool.ts +43 -9
- package/src/adapters/anthropic/client-identity.ts +2 -0
- package/src/adapters/anthropic.ts +102 -14
- package/src/adapters/antigravity-refusal.ts +5 -1
- package/src/adapters/base.ts +25 -2
- package/src/adapters/claude-cli/adapter.ts +1 -0
- package/src/adapters/claude-cli/usage-admission.ts +12 -9
- package/src/adapters/codebuddy/adapter.ts +1 -0
- package/src/adapters/command-code.ts +2 -2
- package/src/adapters/cursor/http1-bidi.ts +7 -2
- package/src/adapters/cursor/live-transport.ts +2 -0
- package/src/adapters/cursor/request-builder.ts +4 -4
- package/src/adapters/cursor/tool-naming.ts +5 -5
- package/src/adapters/cursor/transport-retry.ts +14 -8
- package/src/adapters/cursor/transport.ts +2 -0
- package/src/adapters/cursor.ts +8 -2
- package/src/adapters/google-error-details.ts +105 -0
- package/src/adapters/google-errors.ts +183 -31
- package/src/adapters/google-http.ts +66 -22
- package/src/adapters/google-truncation.ts +48 -3
- package/src/adapters/google-vertex-endpoint.ts +12 -1
- package/src/adapters/google.ts +54 -26
- package/src/adapters/kiro/adapter.ts +39 -38
- package/src/adapters/kiro/stream.ts +59 -9
- package/src/adapters/kiro-retry.ts +5 -3
- package/src/adapters/m365-copilot/LICENSE +21 -0
- package/src/adapters/m365-copilot/fenced.ts +745 -0
- package/src/adapters/m365-copilot/images.ts +89 -0
- package/src/adapters/m365-copilot/tools.ts +284 -0
- package/src/adapters/m365-copilot/transport.ts +232 -0
- package/src/adapters/m365-copilot.ts +143 -0
- package/src/adapters/openai-chat/tool-schema.ts +2 -2
- package/src/adapters/openai-responses/passthrough.ts +1 -0
- package/src/adapters/openai-responses/reasoning.ts +23 -3
- package/src/adapters/physical-send.ts +11 -4
- package/src/adapters/qoder/adapter.ts +17 -3
- package/src/adapters/registry.ts +15 -1
- package/src/adapters/zed.ts +2 -1
- package/src/advisor/consult.ts +1 -0
- package/src/bridge/response-json.ts +6 -2
- package/src/bridge/sse.ts +21 -9
- package/src/chat/inbound.ts +11 -8
- package/src/chat/outbound.ts +28 -7
- package/src/claude/context-windows.ts +32 -8
- package/src/claude/desktop-3p.ts +18 -14
- package/src/claude/desktop-picker-platform.ts +1 -1
- package/src/claude/desktop-picker.ts +3 -3
- package/src/claude/inbound-content-options.ts +11 -1
- package/src/claude/intercept/picker-ca-cleanup.ts +17 -5
- package/src/claude/intercept/picker-ca.ts +162 -27
- package/src/claude/intercept/picker-trust-linux.ts +411 -0
- package/src/claude/intercept/picker-trust.ts +35 -3
- package/src/claude/intercept/runtime.ts +2 -2
- package/src/claude/subagent-force-status.ts +24 -5
- package/src/claude/subscription-reserve.ts +87 -0
- package/src/cli/account-api.ts +3 -0
- package/src/cli/account-auth.ts +65 -11
- package/src/cli/account-extended.ts +1 -1
- package/src/cli/account-next-actions.ts +4 -1
- package/src/cli/account-policy-dto.ts +1 -1
- package/src/cli/account-policy.ts +6 -3
- package/src/cli/account-probe.ts +66 -0
- package/src/cli/account.ts +8 -2
- package/src/cli/capabilities-accounts.ts +8 -1
- package/src/cli/capabilities-agents-routing.ts +2 -2
- package/src/cli/capabilities-base.ts +4 -4
- package/src/cli/capabilities-integrations.ts +44 -4
- package/src/cli/capabilities-provider-models.ts +6 -0
- package/src/cli/claude-context-settings.ts +60 -0
- package/src/cli/claude-desktop.ts +2 -2
- package/src/cli/claude.ts +15 -7
- package/src/cli/client-start-fence.ts +64 -1
- package/src/cli/combo-result.ts +1 -0
- package/src/cli/combo-stats.ts +1 -1
- package/src/cli/combo.ts +19 -2
- package/src/cli/config-command.ts +21 -8
- package/src/cli/connect.ts +16 -0
- package/src/cli/cross-home-owner.ts +65 -18
- package/src/cli/dispatch.ts +4 -0
- package/src/cli/gateway-client-command.ts +128 -0
- package/src/cli/index.ts +98 -97
- package/src/cli/init.ts +20 -4
- package/src/cli/integrations.ts +23 -3
- package/src/cli/launcher-context.ts +12 -1
- package/src/cli/link.ts +24 -5
- package/src/cli/models-runtime-subcommands.ts +1 -0
- package/src/cli/models-runtime.ts +32 -0
- package/src/cli/start-owner-fence.ts +5 -2
- package/src/cli/status.ts +3 -3
- package/src/cli/stop-client-process.ts +51 -0
- package/src/cli/stop-restore.ts +383 -36
- package/src/cli/sync-command.ts +2 -2
- package/src/cli/uninstall-client-state.ts +7 -0
- package/src/client/connect.ts +72 -13
- package/src/client/hub-client.ts +38 -0
- package/src/client/hub-relay.ts +61 -36
- package/src/client/hub-session.ts +106 -0
- package/src/client/lifecycle-lock.ts +6 -1
- package/src/client/link-relay.ts +2 -1
- package/src/client/machine-listener.ts +60 -1
- package/src/client/runtime-restart.ts +1 -0
- package/src/client/runtime.ts +104 -34
- package/src/client/state.ts +11 -0
- package/src/client/stop-darwin-process.ts +73 -0
- package/src/client/stop-file-routing.ts +49 -0
- package/src/client/stop-native-handoff.ts +108 -0
- package/src/client/stop-routing.ts +41 -7
- package/src/client/stop-teardown-owner.ts +173 -0
- package/src/client/sync-runtime.ts +23 -4
- package/src/clients/config-export/opencode-wire.ts +24 -0
- package/src/clients/config-export.ts +28 -19
- package/src/codex/auth-api/login-flow.ts +68 -33
- package/src/codex/auth-api/main-account-probe.ts +3 -3
- package/src/codex/auth-api/pool-quota-probe.ts +8 -7
- package/src/codex/auth-api/routes.ts +1 -1
- package/src/codex/catalog/aggregation.ts +22 -10
- package/src/codex/catalog/gather-capture.ts +11 -2
- package/src/codex/catalog/m365-copilot-models.ts +52 -0
- package/src/codex/catalog/provider-models.ts +126 -53
- package/src/codex/catalog/routed-gather.ts +26 -12
- package/src/codex/catalog-admission.ts +4 -6
- package/src/codex/catalog-auto-refresh.ts +4 -2
- package/src/codex/catalog-self-heal.ts +4 -2
- package/src/codex/control-plane-models.ts +6 -0
- package/src/codex/convergence.ts +10 -0
- package/src/codex/desktop-app/picker-freshness.ts +3 -14
- package/src/codex/desktop-app/types.ts +6 -0
- package/src/codex/desktop-app/windows-command-payload.ts +9 -0
- package/src/codex/desktop-app/windows.ts +20 -12
- package/src/codex/desktop-compatibility/installed-build.ts +61 -58
- package/src/codex/desktop-compatibility/runtime-ownership.ts +11 -5
- package/src/codex/desktop-compatibility/runtime.ts +51 -14
- package/src/codex/desktop-compatibility/windows-activation-source.ts +28 -13
- package/src/codex/desktop-compatibility/windows-package-command.ts +73 -33
- package/src/codex/desktop-compatibility/windows-package-launch.ts +41 -9
- package/src/codex/desktop-compatibility/windows-package-proof.ts +104 -0
- package/src/codex/inject/config-toml.ts +67 -73
- package/src/codex/inject/plan.ts +11 -10
- package/src/codex/inject/remove.ts +4 -1
- package/src/codex/inject.ts +1 -0
- package/src/codex/journal-config-restore.ts +31 -4
- package/src/codex/journal.ts +16 -4
- package/src/codex/model-cache.ts +98 -27
- package/src/codex/native-residue.ts +14 -13
- package/src/codex/paths.ts +65 -28
- package/src/codex/quota-observation-freshness.ts +4 -0
- package/src/codex/quota.ts +71 -8
- package/src/codex/routing/selection.ts +32 -8
- package/src/combos/capability-policy.ts +31 -0
- package/src/combos/failover.ts +82 -74
- package/src/combos/identifiers.ts +2 -2
- package/src/combos/index.ts +3 -0
- package/src/combos/jev-model-backend.ts +12 -4
- package/src/combos/jev-session-pin-config.ts +22 -9
- package/src/combos/jev.ts +15 -4
- package/src/combos/request-capability.ts +214 -0
- package/src/combos/request.ts +22 -15
- package/src/combos/resolve.ts +5 -2
- package/src/combos/suggestion-channel.ts +89 -0
- package/src/combos/types.ts +14 -1
- package/src/config/account-auto-pause-revisions.ts +33 -10
- package/src/config/atomic-write.ts +1 -1
- package/src/config/codex-ws-incremental-setting.ts +34 -0
- package/src/config/diagnostics.ts +47 -8
- package/src/config/live-topology.ts +4 -2
- package/src/config/load-degrade.ts +96 -2
- package/src/config/mutation-lock.ts +7 -3
- package/src/config/paths.ts +3 -0
- package/src/config/pending-teardown.ts +19 -3
- package/src/config/process-state.ts +30 -12
- package/src/config/provider-validation.ts +10 -0
- package/src/config/salvage.ts +2 -2
- package/src/config/schema/account-auto-pause.ts +15 -1
- package/src/config/schema/agy-acp-references.ts +257 -0
- package/src/config/schema/config-schema.ts +32 -0
- package/src/config/schema/leaf-validators.ts +42 -0
- package/src/config/schema/subscription-reserve.ts +33 -0
- package/src/config/windows-process-command-line.ts +27 -9
- package/src/config.ts +6 -0
- package/src/generated/compatibility-version.json +806 -402
- package/src/images/loop.ts +79 -39
- package/src/integrations/catalog-refresh.ts +19 -1
- package/src/integrations/gateway-clients/agy.ts +340 -0
- package/src/integrations/gateway-clients/antigravity.ts +224 -0
- package/src/integrations/gateway-clients/index.ts +89 -0
- package/src/integrations/gateway-clients/io.ts +278 -0
- package/src/integrations/gateway-clients/types.ts +80 -0
- package/src/integrations/route-intent-disconnect.ts +37 -21
- package/src/lib/app-owned-memory-stores.ts +9 -0
- package/src/lib/cloud-code-appeal-link.ts +30 -0
- package/src/lib/errors.ts +32 -0
- package/src/lib/executor-physical-send-receipt.ts +42 -0
- package/src/lib/failure-detail.ts +1 -0
- package/src/lib/gcp-adc.ts +5 -0
- package/src/lib/http-date.ts +91 -0
- package/src/lib/lab-passive-linker-registration.ts +2 -1
- package/src/lib/local-chat-completion.ts +13 -3
- package/src/lib/local-internal-call-capability.ts +1 -3
- package/src/lib/messages-error-body.ts +2 -1
- package/src/lib/outbound-credential-registry.ts +40 -4
- package/src/lib/pinned-http.ts +7 -2
- package/src/lib/process-control.ts +1 -0
- package/src/lib/provider-egress.ts +16 -0
- package/src/lib/provider-outbound.ts +3 -0
- package/src/lib/redact-folding.ts +12 -3
- package/src/lib/redact.ts +37 -19
- package/src/lib/request-execution-budget.ts +241 -32
- package/src/lib/request-peer-scope.ts +64 -0
- package/src/lib/response-send-readings.ts +41 -0
- package/src/lib/state-store-registrations.ts +5 -0
- package/src/lib/tool-envelope-echo-filter.ts +33 -5
- package/src/lib/upstream-condition.ts +10 -3
- package/src/lib/upstream-retry.ts +95 -20
- package/src/lib/windows-secret-acl.ts +24 -7
- package/src/link/child-activity.ts +60 -4
- package/src/link/codex-settings.ts +2 -1
- package/src/link/relay-auth.ts +1 -0
- package/src/link/route-rounds.ts +32 -9
- package/src/link/status-projection.ts +42 -5
- package/src/link/supervisor.ts +96 -11
- package/src/link/tunnel-history.ts +5 -0
- package/src/oauth/account-auto-pause-policy.ts +72 -19
- package/src/oauth/account-auto-pause.ts +40 -16
- package/src/oauth/anthropic-account-refusal.ts +7 -0
- package/src/oauth/anthropic-continuity.ts +70 -9
- package/src/oauth/anthropic-identity.ts +75 -11
- package/src/oauth/anthropic-login-slot.ts +258 -0
- package/src/oauth/anthropic-routing.ts +24 -9
- package/src/oauth/anthropic-send-ownership.ts +4 -3
- package/src/oauth/anthropic.ts +30 -11
- package/src/oauth/health.ts +7 -2
- package/src/oauth/index.ts +50 -48
- package/src/oauth/key-providers.ts +2 -0
- package/src/oauth/login-cli.ts +11 -0
- package/src/oauth/login-flow-state.ts +10 -4
- package/src/oauth/m365-copilot-browser.ts +222 -0
- package/src/oauth/m365-copilot-web-session.ts +25 -0
- package/src/oauth/m365-copilot.ts +57 -0
- package/src/oauth/model-discovery-auth.ts +5 -0
- package/src/oauth/plan.ts +44 -0
- package/src/oauth/pool-kernel.ts +22 -8
- package/src/oauth/pool-settings-capability.ts +14 -3
- package/src/oauth/reauth-precheck.ts +27 -0
- package/src/oauth/store-anthropic-instance.ts +3 -1
- package/src/oauth/store.ts +121 -23
- package/src/oauth/types.ts +27 -2
- package/src/protocols/codecs/chat-ir.ts +7 -4
- package/src/protocols/codecs/gemini-interactions.ts +770 -0
- package/src/protocols/codecs/gemini.ts +470 -0
- package/src/protocols/contract.ts +2 -0
- package/src/protocols/encoders/adapter-events.ts +5 -3
- package/src/protocols/encoders/chat.ts +23 -7
- package/src/protocols/settings.ts +3 -0
- package/src/providers/account-quota-disk.ts +26 -8
- package/src/providers/api-key-pause.ts +2 -2
- package/src/providers/api-key-response-ownership.ts +14 -4
- package/src/providers/claude-cli-usage-state.ts +1 -0
- package/src/providers/claude-cli-usage.ts +24 -7
- package/src/providers/default-aliases.ts +11 -5
- package/src/providers/derive.ts +5 -1
- package/src/providers/fastwire.ts +6 -5
- package/src/providers/free-directory.ts +2 -2
- package/src/providers/google-vertex-location.ts +2 -1
- package/src/providers/google-vertex-model-discovery.ts +22 -0
- package/src/providers/key-failover.ts +18 -23
- package/src/providers/m365-copilot-discovery-fetch.ts +17 -0
- package/src/providers/m365-copilot-discovery.ts +68 -0
- package/src/providers/m365-copilot-models.ts +32 -0
- package/src/providers/model-rename-fields.ts +6 -0
- package/src/providers/new-model-policy-runtime.ts +27 -6
- package/src/providers/openai-forward-destination.ts +19 -0
- package/src/providers/openai-tiers-destination.ts +3 -19
- package/src/providers/quota/account-cache.ts +183 -27
- package/src/providers/quota/anthropic-account-quota.ts +21 -17
- package/src/providers/quota/anthropic-cooldown-recovery.ts +57 -27
- package/src/providers/quota/anthropic-decision-windows.ts +7 -3
- package/src/providers/quota/anthropic-usage-windows.ts +34 -4
- package/src/providers/quota/antigravity-account-probe.ts +165 -0
- package/src/providers/quota/antigravity.ts +71 -3
- package/src/providers/quota/vendor-probes-oauth.ts +52 -28
- package/src/providers/quota-decision-publication.ts +1 -1
- package/src/providers/quota-decision-snapshot.ts +4 -1
- package/src/providers/quota-types.ts +2 -0
- package/src/providers/quota.ts +8 -7
- package/src/providers/registry/agy-acp-models.ts +3 -0
- package/src/providers/registry/entries-core.ts +9 -0
- package/src/providers/registry/entries-extended.ts +60 -0
- package/src/providers/registry/model-seeds.ts +51 -0
- package/src/providers/request-pacing.ts +37 -7
- package/src/providers/service-tier.ts +2 -0
- package/src/providers/xai-privacy-mode.ts +52 -0
- package/src/remote/hub-management-relay.ts +74 -0
- package/src/responses/id-limits.ts +2 -0
- package/src/responses/input-media.ts +15 -3
- package/src/responses/parser-tools.ts +74 -11
- package/src/responses/parser.ts +16 -14
- package/src/responses/provider-opaque-metadata.ts +10 -0
- package/src/responses/reasoning-envelope.ts +3 -0
- package/src/responses/schema.ts +2 -3
- package/src/responses/spill-store.ts +5 -3
- package/src/responses/state/connection-scope.ts +232 -0
- package/src/responses/state/entry-types.ts +47 -0
- package/src/responses/state/snapshot-codec.ts +75 -14
- package/src/responses/state/snapshot-select.ts +2 -0
- package/src/responses/state/spill-codec.ts +59 -0
- package/src/responses/state/spill-queue.ts +11 -2
- package/src/responses/state.ts +178 -159
- package/src/router.ts +2 -6
- package/src/routing/compatibility/behavior.ts +6 -2
- package/src/routing/compatibility/subject.ts +17 -12
- package/src/routing/machine-weighted-routing.ts +58 -0
- package/src/server/advisor-admission-scope.ts +15 -7
- package/src/server/auth-cors.ts +27 -0
- package/src/server/chat-completions.ts +37 -17
- package/src/server/chat-native-eligibility.ts +21 -0
- package/src/server/chat-native.ts +15 -6
- package/src/server/claude-messages.ts +54 -6
- package/src/server/credential-recovery-attempt.ts +32 -0
- package/src/server/effort-policy.ts +6 -3
- package/src/server/gemini-inbound.ts +267 -0
- package/src/server/gemini-interactions-inbound.ts +229 -0
- package/src/server/gemini-interactions-store.ts +129 -0
- package/src/server/gemini-native-catalog.ts +64 -0
- package/src/server/gemini-native-log.ts +33 -0
- package/src/server/gemini-native-paths.ts +88 -0
- package/src/server/gemini-native-wire.ts +201 -0
- package/src/server/gemini-native.ts +218 -0
- package/src/server/grok-upstream-envelope-echo.ts +8 -2
- package/src/server/hub-relay-auth.ts +87 -0
- package/src/server/hub-usage-windows.ts +135 -0
- package/src/server/hub-usage.ts +16 -3
- package/src/server/inbound-body-admission.ts +2 -1
- package/src/server/index/anthropic-model-listing.ts +75 -0
- package/src/server/index/gemini-routes.ts +147 -0
- package/src/server/index/link-management.ts +3 -22
- package/src/server/index/link-relay-sessions.ts +71 -13
- package/src/server/index/link-websocket.ts +2 -0
- package/src/server/index/passive-management-read.ts +55 -0
- package/src/server/index/serve-options.ts +93 -107
- package/src/server/index/websocket-handler.ts +15 -2
- package/src/server/index.ts +10 -0
- package/src/server/inference/client-encoder-delivery.ts +2 -1
- package/src/server/inference/context.ts +33 -6
- package/src/server/management/agent-settings-routes.ts +33 -16
- package/src/server/management/claude-code-settings-patch.ts +6 -0
- package/src/server/management/combo-routes.ts +21 -1
- package/src/server/management/combo-suggestion-routes.ts +212 -0
- package/src/server/management/config-routes.ts +12 -4
- package/src/server/management/context.ts +2 -0
- package/src/server/management/gateway-client-routes.ts +62 -0
- package/src/server/management/integration-routes.ts +5 -0
- package/src/server/management/link-routes.ts +5 -1
- package/src/server/management/m365-copilot-provider-probe.ts +23 -0
- package/src/server/management/model-routes.ts +32 -2
- package/src/server/management/model-rows.ts +36 -3
- package/src/server/management/oauth-account-routes.ts +68 -15
- package/src/server/management/protocol-settings-patch.ts +1 -0
- package/src/server/management/provider-omitted-fields.ts +25 -0
- package/src/server/management/provider-overwrite-carry.ts +33 -8
- package/src/server/management/provider-routes.ts +10 -16
- package/src/server/management/request-history-routes.ts +2 -2
- package/src/server/management/route-registry.ts +10 -0
- package/src/server/management/shared.ts +118 -30
- package/src/server/management/sibling-guard.ts +2 -1
- package/src/server/management/system-routes.ts +6 -0
- package/src/server/management-auth.ts +8 -1
- package/src/server/messages-native-scope.ts +19 -0
- package/src/server/messages-native.ts +156 -59
- package/src/server/messages-shared.ts +6 -0
- package/src/server/models-capabilities.ts +24 -0
- package/src/server/native-chat-bridge.ts +259 -0
- package/src/server/ollama-inbound.ts +36 -184
- package/src/server/passive-route-linker.ts +3 -1
- package/src/server/port-reclaim.ts +48 -4
- package/src/server/proxy-liveness.ts +79 -22
- package/src/server/relay.ts +16 -9
- package/src/server/request-log-account-rotation.ts +2 -1
- package/src/server/request-log-attempt-recovery.ts +24 -2
- package/src/server/request-log-attempt-usage.ts +5 -4
- package/src/server/request-log-committed-terminal.ts +87 -0
- package/src/server/request-log-failure-attribution.ts +3 -3
- package/src/server/request-log-failure-detail.ts +34 -0
- package/src/server/request-log-key-failure.ts +27 -0
- package/src/server/request-log-terminal-status.ts +25 -12
- package/src/server/request-log.ts +59 -63
- package/src/server/responses/adapter-continuation.ts +77 -44
- package/src/server/responses/adapter-delivery.ts +47 -22
- package/src/server/responses/adapter-dispatch.ts +150 -149
- package/src/server/responses/advisor-retention.ts +12 -4
- package/src/server/responses/advisor-slot.ts +97 -2
- package/src/server/responses/agent-task-recovery.ts +44 -11
- package/src/server/responses/agy-acp-preflight.ts +41 -0
- package/src/server/responses/anthropic-image-context.ts +44 -0
- package/src/server/responses/antigravity-validation-refusal.ts +25 -1
- package/src/server/responses/buffered-sse-json.ts +18 -1
- package/src/server/responses/codex-ws-correlation.ts +5 -2
- package/src/server/responses/codex-ws-exchange.ts +91 -8
- package/src/server/responses/codex-ws-incremental.ts +136 -0
- package/src/server/responses/codex-ws-pool.ts +22 -8
- package/src/server/responses/codex-ws-request.ts +5 -0
- package/src/server/responses/codex-ws-send-accounting.ts +8 -0
- package/src/server/responses/codex-ws-session.ts +14 -0
- package/src/server/responses/codex-ws-wire.ts +44 -22
- package/src/server/responses/combo-admission-snapshot.ts +93 -0
- package/src/server/responses/combo-required-tool-stream.ts +16 -4
- package/src/server/responses/combo-selection-keepalive.ts +5 -0
- package/src/server/responses/combo-stream-preflight.ts +182 -73
- package/src/server/responses/compact-response-body.ts +27 -0
- package/src/server/responses/compact.ts +174 -121
- package/src/server/responses/compaction-recovery.ts +7 -0
- package/src/server/responses/core-codex-account.ts +88 -62
- package/src/server/responses/core-combo-failure.ts +15 -0
- package/src/server/responses/core-combo-native.ts +12 -1
- package/src/server/responses/core-combo.ts +340 -94
- package/src/server/responses/core-normalize.ts +19 -12
- package/src/server/responses/core-opaque-recovery.ts +15 -4
- package/src/server/responses/core-options.ts +50 -5
- package/src/server/responses/core-pipeline.ts +11 -0
- package/src/server/responses/core.ts +7 -1
- package/src/server/responses/empty-completion-guard.ts +21 -7
- package/src/server/responses/estimated-usage.ts +2 -1
- package/src/server/responses/fetch-helpers.ts +95 -19
- package/src/server/responses/history-slim.ts +204 -0
- package/src/server/responses/hosted-advisor-spend.ts +49 -0
- package/src/server/responses/image-context-recovery.ts +199 -0
- package/src/server/responses/input-admission.ts +36 -11
- package/src/server/responses/jev-model-invoke.ts +23 -16
- package/src/server/responses/non-replayable-error.ts +12 -2
- package/src/server/responses/passthrough-build-error.ts +5 -3
- package/src/server/responses/passthrough-delivery.ts +74 -33
- package/src/server/responses/passthrough-dispatch.ts +170 -197
- package/src/server/responses/policy-fallback.ts +7 -2
- package/src/server/responses/policy-request-scope.ts +36 -2
- package/src/server/responses/replay-owner.ts +20 -0
- package/src/server/responses/request-prepare.ts +97 -16
- package/src/server/responses/request-send-budget.ts +97 -25
- package/src/server/responses/request-sidecar-auth.ts +138 -65
- package/src/server/responses/request-spend-target.ts +13 -1
- package/src/server/responses/request-spend.ts +228 -47
- package/src/server/responses/request-transport.ts +395 -70
- package/src/server/responses/run-turn-execution.ts +40 -9
- package/src/server/responses/sidecar-execution.ts +214 -67
- package/src/server/responses/sidecar-send-budget.ts +9 -9
- package/src/server/responses/terminal-guard.ts +35 -9
- package/src/server/responses/ws-upstream.ts +27 -6
- package/src/server/responses-phase-inference.ts +32 -9
- package/src/server/responses-terminal-repair.ts +14 -35
- package/src/server/system-env.ts +8 -5
- package/src/server/ws-bridge.ts +23 -17
- package/src/service/health-sentinel-linux.ts +16 -7
- package/src/service/systemd.ts +11 -2
- package/src/service/windows-checked-stop-live.ts +60 -55
- package/src/service/windows-checked-stop.ts +29 -11
- package/src/service/windows-guarded-manager.ts +14 -26
- package/src/service/windows-process-evidence.ts +82 -74
- package/src/service/windows-process-native.ts +69 -20
- package/src/service/windows-service-stop.ts +14 -12
- package/src/service/windows-stop-binding.ts +14 -5
- package/src/service/windows-stop-confirm.ts +1 -1
- package/src/service/windows-task-instance-stop.ts +98 -0
- package/src/service/windows-taskxml.ts +30 -7
- package/src/sidecar/anthropic-binding.ts +1 -1
- package/src/stall-timeout.ts +30 -0
- package/src/telemetry/aggregate.ts +6 -3
- package/src/types/account-auto-pause.ts +19 -1
- package/src/types/accounts.ts +21 -0
- package/src/types/anthropic-account-pool.ts +1 -1
- package/src/types/combo-capability-policy.ts +19 -0
- package/src/types/config.ts +22 -2
- package/src/types/provider.ts +42 -8
- package/src/types/request.ts +15 -0
- package/src/types/tools.ts +22 -5
- package/src/types/wire.ts +1 -0
- package/src/types.ts +4 -0
- package/src/update/check-types.ts +2 -0
- package/src/update/job.ts +8 -3
- package/src/update/managed-release.ts +6 -0
- package/src/update/orchestrated-entry.ts +13 -4
- package/src/update/refresh-scheduler.ts +17 -7
- package/src/usage/attempt-delivery.ts +6 -0
- package/src/usage/cache-provenance.ts +71 -0
- package/src/usage/cost.ts +216 -27
- package/src/usage/credit-billing.ts +88 -0
- package/src/usage/jev-stats.ts +13 -9
- package/src/usage/log.ts +5 -33
- package/src/usage/summary.ts +8 -43
- package/src/usage/user-cost-overlays.ts +13 -1
- package/src/vision/index.ts +8 -3
- package/src/vision/plan.ts +28 -14
- package/src/vision/routed-describe.ts +24 -36
- package/src/web-search/header-deadline.ts +14 -3
- package/src/web-search/index.ts +6 -4
- package/src/web-search/loop.ts +240 -78
- package/src/web-search/progress-stream.ts +29 -2
- package/src/web-search/run-turn-loop.ts +5 -1
- package/gui/dist/assets/App-BGP8I0V4.css +0 -1
- package/gui/dist/assets/App-BRExzhwL.js +0 -60
- package/gui/dist/assets/Tray-DHCWAn8V.js +0 -1
- package/gui/dist/assets/brand-mark-C70PuQ3j.js +0 -1
- package/gui/dist/assets/index-DJxM-imn.css +0 -2
- package/gui/dist/assets/index-Dy1jIGty.js +0 -138
- package/gui/dist/classic/assets/App-B4j-Txmb.css +0 -1
- package/gui/dist/classic/assets/App-CaC-E6Vl.js +0 -59
- package/gui/dist/classic/assets/Tray-BG253fiL.js +0 -1
- package/gui/dist/classic/assets/index-CR_AThOp.js +0 -138
- package/gui/dist/classic/assets/quota-summary-B7KQPpEC.js +0 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { OcxConfig } from "../../types";
|
|
2
|
+
import { hasOwnProvider, isValidProviderName } from "../../config/provider-name";
|
|
3
|
+
import { runPassiveRead } from "../../lib/passive-read";
|
|
4
|
+
import { handleManagementAPI, type ManagementApiDeps } from "../management-api";
|
|
5
|
+
import type { ManagementSessionControl } from "../management-auth";
|
|
6
|
+
|
|
7
|
+
const KEPT_RESPONSE_HEADERS = ["content-type", "content-language", "etag", "last-modified"];
|
|
8
|
+
|
|
9
|
+
async function serveHubProviderKeyRows(config: OcxConfig, name: string): Promise<Response> {
|
|
10
|
+
if (!isValidProviderName(name) || !hasOwnProvider(config.providers, name)) {
|
|
11
|
+
return Response.json({ error: "unknown provider" }, { status: 404 });
|
|
12
|
+
}
|
|
13
|
+
const { listProviderApiKeys } = await import("../../providers/api-keys");
|
|
14
|
+
// Account listing needs row IDs; the relay assigns positions and exposes only status.
|
|
15
|
+
const keys = listProviderApiKeys(config, name).keys.map(({ active, disabled }, index) => ({
|
|
16
|
+
id: `relay-key-${index + 1}`, active, ...(disabled ? { disabled: true } : {}),
|
|
17
|
+
}));
|
|
18
|
+
return Response.json({ activeId: keys.find(key => key.active)?.id ?? null, keys });
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Dispatch an already-authorized read without caller headers, credentials or side effects. */
|
|
22
|
+
export async function dispatchPassiveManagementRead(
|
|
23
|
+
method: string, target: string, config: OcxConfig, deps: ManagementApiDeps,
|
|
24
|
+
sessionControl?: ManagementSessionControl,
|
|
25
|
+
hubRelay?: { enrollment?: { keyId: string; stillAdmitted: () => boolean } },
|
|
26
|
+
): Promise<Response> {
|
|
27
|
+
const local = new URL(target, "http://127.0.0.1");
|
|
28
|
+
const inner = new Request(local.href, { headers: { accept: "application/json", host: "127.0.0.1" } });
|
|
29
|
+
const enrollment = hubRelay?.enrollment;
|
|
30
|
+
const response = await runPassiveRead(async () => {
|
|
31
|
+
if (hubRelay && local.pathname === "/api/providers/keys") {
|
|
32
|
+
return serveHubProviderKeyRows(config, (local.searchParams.get("name") ?? "").trim());
|
|
33
|
+
}
|
|
34
|
+
if (enrollment && local.pathname === "/api/usage") {
|
|
35
|
+
const { serveKeyScopedHubUsage } = await import("../hub-usage");
|
|
36
|
+
return serveKeyScopedHubUsage(local.searchParams, enrollment.keyId, enrollment.stillAdmitted);
|
|
37
|
+
}
|
|
38
|
+
return handleManagementAPI(inner, local, config, deps, undefined, sessionControl, { trustedLoopback: false });
|
|
39
|
+
});
|
|
40
|
+
const headers = new Headers({ "cache-control": "no-store" });
|
|
41
|
+
if (enrollment && !enrollment.stillAdmitted()) {
|
|
42
|
+
try { await response?.body?.cancel(); } catch { /* best effort */ }
|
|
43
|
+
return Response.json({ error: "hub relay credential refused" }, { status: 401, headers });
|
|
44
|
+
}
|
|
45
|
+
if (!response) return Response.json({ error: "not_found" }, { status: 404, headers });
|
|
46
|
+
for (const name of KEPT_RESPONSE_HEADERS) {
|
|
47
|
+
const value = response.headers.get(name);
|
|
48
|
+
if (value) headers.set(name, value);
|
|
49
|
+
}
|
|
50
|
+
if (method === "HEAD") {
|
|
51
|
+
try { await response.body?.cancel(); } catch { /* best effort */ }
|
|
52
|
+
return new Response(null, { status: response.status, headers });
|
|
53
|
+
}
|
|
54
|
+
return new Response(response.body, { status: response.status, headers });
|
|
55
|
+
}
|
|
@@ -47,7 +47,6 @@ import {
|
|
|
47
47
|
} from "../ws-bridge";
|
|
48
48
|
import { websocketsEnabled } from "../../config";
|
|
49
49
|
import { metricsExportEnabled } from "../../config/feature-flags";
|
|
50
|
-
import { grokDefaultReasoningEffort } from "../../grok/effort";
|
|
51
50
|
import { OPENAI_CODEX_PROVIDER_ID } from "../../providers/openai-tiers";
|
|
52
51
|
import { providerCodexAccountMode } from "../../providers/registry";
|
|
53
52
|
import {
|
|
@@ -93,6 +92,7 @@ import {
|
|
|
93
92
|
type RequestLogEntry,
|
|
94
93
|
} from "../request-log";
|
|
95
94
|
import { sessionLaneIdFromRequest } from "../request-log-conversation";
|
|
95
|
+
import { mintConnectionReplayScope, releaseConnectionReplayScope } from "../../responses/state/connection-scope";
|
|
96
96
|
import { responseWithDeferredRequestLog } from "../relay";
|
|
97
97
|
import { createRequestMetricsOwner } from "../request-metrics";
|
|
98
98
|
import { cachedKiroQuotaMetricRows } from "../../providers/kiro-quota-metrics";
|
|
@@ -110,6 +110,7 @@ import {
|
|
|
110
110
|
resolveApiAuth,
|
|
111
111
|
resolveResponsesApiAuth,
|
|
112
112
|
resolveFilteredReplayPrincipal,
|
|
113
|
+
resolveContextPrincipal,
|
|
113
114
|
type RequestPolicyView,
|
|
114
115
|
withCors,
|
|
115
116
|
withManagementCors,
|
|
@@ -128,12 +129,9 @@ import {
|
|
|
128
129
|
} from "../claude-messages";
|
|
129
130
|
import { handleChatCompletions } from "../chat-completions";
|
|
130
131
|
import { anthropicErrorResponse } from "../../claude/outbound";
|
|
131
|
-
import {
|
|
132
|
-
buildDesktop3pRegistry,
|
|
133
|
-
desktop3pModelOptions,
|
|
134
|
-
generateDesktop3pModels,
|
|
135
|
-
} from "../../claude/desktop-3p";
|
|
132
|
+
import { desktopSnapshotBusyResponse, renderAnthropicModelListing } from "./anthropic-model-listing";
|
|
136
133
|
import { buildDesktopDiscoveryInputs } from "../../claude/desktop-discovery-inputs";
|
|
134
|
+
import { observeModelCacheRevision } from "../../codex/model-cache";
|
|
137
135
|
import { handleImages } from "../images";
|
|
138
136
|
import {
|
|
139
137
|
handleLive,
|
|
@@ -174,6 +172,11 @@ import {
|
|
|
174
172
|
managementPrincipal,
|
|
175
173
|
requireManagementAuth,
|
|
176
174
|
} from "../management-auth";
|
|
175
|
+
import {
|
|
176
|
+
HUB_RELAY_CREDENTIAL_PATH, HUB_RELAY_ENROLLMENT_ID_HEADER, HUB_RELAY_READ_PREFIX, hubRelayReadTarget,
|
|
177
|
+
} from "../../remote/hub-management-relay";
|
|
178
|
+
import { issueHubRelayCredential, revokeHubRelayCredential } from "../hub-relay-auth";
|
|
179
|
+
import { dispatchPassiveManagementRead } from "./passive-management-read";
|
|
177
180
|
import {
|
|
178
181
|
LOCAL_ATTESTATION_CHALLENGE_HEADER,
|
|
179
182
|
LOCAL_ATTESTATION_PROOF_HEADER,
|
|
@@ -208,16 +211,20 @@ import { classifyUsageClient } from "../../usage/client";
|
|
|
208
211
|
import { isOllamaNativePath } from "../ollama-native-paths";
|
|
209
212
|
import { ollamaError } from "../ollama-inbound";
|
|
210
213
|
import { dispatchOllamaRoute } from "./ollama-routes";
|
|
214
|
+
import { isGeminiNativePath } from "../gemini-native-paths";
|
|
215
|
+
import { geminiError } from "../gemini-inbound";
|
|
216
|
+
import { dispatchGeminiRoute } from "./gemini-routes";
|
|
211
217
|
|
|
212
218
|
import { readyProtocolMetadata } from "../../remote/protocol";
|
|
213
219
|
import { homeInstanceId, stampServedBy } from "../../remote/served-by";
|
|
214
|
-
import { modelCapabilityFields } from "../models-capabilities";
|
|
220
|
+
import { grokEffortFields, modelCapabilityFields } from "../models-capabilities";
|
|
215
221
|
import { createWebsocketHandler } from "./websocket-handler";
|
|
216
222
|
import { reasoningArchiveErrorResponse } from "../responses/reasoning-archive-error";
|
|
217
223
|
import { withGrokSessionIdentity } from "../../grok/session-identity";
|
|
218
224
|
import { withCallerSessionIdentity } from "../caller-session-identity";
|
|
219
225
|
import { agentAssertionUnsupportedResponse, hasAgentAssertionAuthorization } from "../../lib/authorization-scheme";
|
|
220
226
|
import { runTurnStateCallerScope } from "../turn-state-handles";
|
|
227
|
+
import { classifyRequestPeer, runWithRequestPeer } from "../../lib/request-peer-scope";
|
|
221
228
|
|
|
222
229
|
export {
|
|
223
230
|
claudeInterceptRouteAllowed,
|
|
@@ -364,6 +371,7 @@ export function createServeOptions(ctx: ServeOptionsContext) {
|
|
|
364
371
|
|| readyzPath !== undefined
|
|
365
372
|
|| url.pathname.startsWith("/v1/")
|
|
366
373
|
|| isOllamaNativePath(url.pathname)
|
|
374
|
+
|| isGeminiNativePath(url.pathname)
|
|
367
375
|
)) {
|
|
368
376
|
const message = "OpenCodex package files changed while this proxy was running; it restarts on its own, or run 'ocx restart' ('ocx service restart' for a background service).";
|
|
369
377
|
const fencedPort = ctx.boundPort ?? requestServer.port ?? listenPort;
|
|
@@ -389,7 +397,9 @@ export function createServeOptions(ctx: ServeOptionsContext) {
|
|
|
389
397
|
}, 503, req, policy)
|
|
390
398
|
: isOllamaNativePath(url.pathname)
|
|
391
399
|
? withCors(ollamaError(503, message), req, policy)
|
|
392
|
-
:
|
|
400
|
+
: isGeminiNativePath(url.pathname)
|
|
401
|
+
? withCors(geminiError(503, message), req, policy)
|
|
402
|
+
: packageTreeChangedResponse(req, policy, message);
|
|
393
403
|
const headers = new Headers(response.headers);
|
|
394
404
|
headers.set("Retry-After", "5");
|
|
395
405
|
const challenge = fencedHealth ? req.headers.get(LOCAL_ATTESTATION_CHALLENGE_HEADER) : null;
|
|
@@ -407,6 +417,7 @@ export function createServeOptions(ctx: ServeOptionsContext) {
|
|
|
407
417
|
}
|
|
408
418
|
// The exact Ollama-compatible paths are data-plane routes and take data-plane CORS.
|
|
409
419
|
const managementPreflight = url.pathname.startsWith("/api/") && !isOllamaNativePath(url.pathname);
|
|
420
|
+
// Gemini routes are data-plane paths too (never under /api/), so they take the data-plane branch.
|
|
410
421
|
const allowed = managementPreflight
|
|
411
422
|
? isAllowedManagementOrigin(req, config)
|
|
412
423
|
: isAllowedRequestOrigin(req, policy);
|
|
@@ -571,19 +582,25 @@ export function createServeOptions(ctx: ServeOptionsContext) {
|
|
|
571
582
|
if (!websocketLease) return serverBusyResponse(req, "Codex WebSockets", policy);
|
|
572
583
|
const forwardHeaders = selectForwardHeaders(req.headers);
|
|
573
584
|
const replayPrincipal = resolveFilteredReplayPrincipal(req, config, admission, forwardHeaders);
|
|
585
|
+
// An unidentified loopback caller gets a server-minted replay scope bound to this
|
|
586
|
+
// socket and its handshake thread; a keyed caller keeps the durable principal path.
|
|
587
|
+
const replayScope = admission.kind === "loopback" && resolveContextPrincipal(req, config, admission) === undefined
|
|
588
|
+
? mintConnectionReplayScope(req.headers.get("thread-id") ?? undefined)
|
|
589
|
+
: undefined;
|
|
574
590
|
// Upgrade on the server that RECEIVED this request, not the captured `server`
|
|
575
591
|
// binding. They are the same object for the public listener, but the
|
|
576
592
|
// unauthenticated loopback listener (#1102) is a second Bun.serve, and handing its
|
|
577
593
|
// request to the public server's upgrade would fail or cross sockets.
|
|
578
594
|
if (requestServer.upgrade(req, {
|
|
579
|
-
data: buildResponsesWsData(
|
|
595
|
+
data: { ...buildResponsesWsData(
|
|
580
596
|
forwardHeaders,
|
|
581
597
|
admission,
|
|
582
598
|
websocketLease,
|
|
583
599
|
sessionLaneIdFromRequest(req.headers),
|
|
584
|
-
classifyUsageClient(req.headers), replayPrincipal,
|
|
585
|
-
),
|
|
600
|
+
classifyUsageClient(req.headers), replayPrincipal, replayScope,
|
|
601
|
+
), peerLocal: classifyRequestPeer(ingress, requestServer.requestIP?.(req)?.address, config.dashboardTrustedProxy, req.headers).local },
|
|
586
602
|
})) return undefined as unknown as Response;
|
|
603
|
+
releaseConnectionReplayScope(replayScope);
|
|
587
604
|
websocketLease.release();
|
|
588
605
|
return withCors(formatErrorResponse(426, "upgrade_required", "WebSocket upgrade failed"), req, policy);
|
|
589
606
|
}
|
|
@@ -656,8 +673,15 @@ export function createServeOptions(ctx: ServeOptionsContext) {
|
|
|
656
673
|
const native = await dispatchOllamaRoute(req, url, { config, policy, requestServer, requestMetricsLogContext, drainingResponse, runAdmittedHttpTurn });
|
|
657
674
|
if (native) return native;
|
|
658
675
|
}
|
|
676
|
+
if (isGeminiNativePath(url.pathname)) {
|
|
677
|
+
const native = await dispatchGeminiRoute(req, url, { config, policy, requestServer, requestMetricsLogContext, drainingResponse, runAdmittedHttpTurn });
|
|
678
|
+
if (native) return native;
|
|
679
|
+
}
|
|
659
680
|
|
|
660
681
|
if (url.pathname.startsWith("/api/")) {
|
|
682
|
+
if (url.pathname === HUB_RELAY_CREDENTIAL_PATH && req.method === "DELETE") {
|
|
683
|
+
return withManagementCors(revokeHubRelayCredential(managementAuth, req, config), req, config);
|
|
684
|
+
}
|
|
661
685
|
const localManagementAuth = {
|
|
662
686
|
attestationSecret: localAttestationSecret,
|
|
663
687
|
pid: process.pid,
|
|
@@ -669,6 +693,27 @@ export function createServeOptions(ctx: ServeOptionsContext) {
|
|
|
669
693
|
// gate used. Consent-bearing routes need this: request headers are forgeable
|
|
670
694
|
// by anything holding the admin token, the credential is not.
|
|
671
695
|
const principal = managementPrincipal(req, managementAuth, config, localManagementAuth) ?? undefined;
|
|
696
|
+
if (url.pathname === HUB_RELAY_CREDENTIAL_PATH) {
|
|
697
|
+
const response = principal === "admin-token"
|
|
698
|
+
|| (principal === "gui-session" && managementSessionControl.isPaired(req, config))
|
|
699
|
+
? issueHubRelayCredential(managementAuth, req, config)
|
|
700
|
+
: Response.json({ error: "hub relay enrollment authority required" }, { status: 403 });
|
|
701
|
+
return withManagementCors(response, req, config);
|
|
702
|
+
}
|
|
703
|
+
if (url.pathname.startsWith(HUB_RELAY_READ_PREFIX + "/")) {
|
|
704
|
+
const target = hubRelayReadTarget(req);
|
|
705
|
+
if (config.runtimeRole !== "hub" || !target
|
|
706
|
+
|| (principal !== "hub-relay-read" && principal !== "gui-session" && principal !== "admin-token")) {
|
|
707
|
+
return withManagementCors(Response.json({ error: "hub relay read refused" }, { status: 404 }), req, config);
|
|
708
|
+
}
|
|
709
|
+
const keyId = principal === "hub-relay-read" ? req.headers.get(HUB_RELAY_ENROLLMENT_ID_HEADER) : null;
|
|
710
|
+
if (principal === "hub-relay-read" && !keyId) {
|
|
711
|
+
return withManagementCors(Response.json({ error: "hub relay enrollment required" }, { status: 401 }), req, config);
|
|
712
|
+
}
|
|
713
|
+
const enrollment = keyId ? { keyId, stillAdmitted: () => managementPrincipal(req, managementAuth, config) === "hub-relay-read" } : undefined;
|
|
714
|
+
const response = await dispatchPassiveManagementRead(req.method, target, config, requestManagementApiDeps, undefined, { enrollment });
|
|
715
|
+
return withManagementCors(response, req, config);
|
|
716
|
+
}
|
|
672
717
|
if (url.pathname === GUI_PAIR_PATH || url.pathname === DESKTOP_GUI_PAIR_PATH) {
|
|
673
718
|
if (url.pathname === DESKTOP_GUI_PAIR_PATH && (!trustedLoopbackForIngress(ingress, config.hostname ?? "127.0.0.1")
|
|
674
719
|
|| !["127.0.0.1", "::1", "::ffff:127.0.0.1"].includes(requestServer.requestIP(req)?.address ?? "")
|
|
@@ -800,6 +845,11 @@ export function createServeOptions(ctx: ServeOptionsContext) {
|
|
|
800
845
|
return handleHubUsage(req, config, policy);
|
|
801
846
|
}
|
|
802
847
|
|
|
848
|
+
if (url.pathname === "/v1/usage/windows" && req.method === "GET") {
|
|
849
|
+
const { handleHubUsageWindows } = await import("../hub-usage-windows");
|
|
850
|
+
return handleHubUsageWindows(req, config, policy);
|
|
851
|
+
}
|
|
852
|
+
|
|
803
853
|
if (url.pathname === "/v1/hub-state" && (req.method === "GET" || req.method === "HEAD")) {
|
|
804
854
|
// #4236: a connected client had no way to learn which providers this hub can actually
|
|
805
855
|
// serve, so `ocx status` on the client reported the CLIENT's empty credential store as
|
|
@@ -878,6 +928,7 @@ export function createServeOptions(ctx: ServeOptionsContext) {
|
|
|
878
928
|
}
|
|
879
929
|
|
|
880
930
|
if (url.pathname === "/v1/models" && req.method === "GET") {
|
|
931
|
+
let config = ctx.config;
|
|
881
932
|
// #809: the catalog read sits immediately before model discovery because it shares
|
|
882
933
|
// that route's admission rationale exactly. Keep them adjacent so a future change to
|
|
883
934
|
// one is made in sight of the other.
|
|
@@ -896,11 +947,15 @@ export function createServeOptions(ctx: ServeOptionsContext) {
|
|
|
896
947
|
// The Integrations page reports whether a Cursor client has reached this proxy; the
|
|
897
948
|
// recorder keeps only a bounded User-Agent value and a timestamp, in memory.
|
|
898
949
|
recordCursorSeen(req.headers);
|
|
950
|
+
const providerContentRevisions = new Map<string, string>();
|
|
951
|
+
// Entitlement resolution and imports can outlive the gather that chose these rows.
|
|
952
|
+
const canInstallAliases = () => config === ctx.config
|
|
953
|
+
&& [...providerContentRevisions].every(([provider, revision]) => observeModelCacheRevision(provider) === revision);
|
|
899
954
|
let goModels;
|
|
900
955
|
let modelEntitlements;
|
|
901
956
|
try {
|
|
902
957
|
[goModels, modelEntitlements] = await Promise.all([
|
|
903
|
-
fetchAllModels(config),
|
|
958
|
+
fetchAllModels(config, { providerContentRevisions, allowSuperseded: true, publishProjection: projection => { config = projection; } }),
|
|
904
959
|
// Codex sends its own client_version on this request, and upstream filters the
|
|
905
960
|
// entitlement roster by it. Passing it through is what stops an entitled account
|
|
906
961
|
// being told it cannot use models a newer client can (#2886).
|
|
@@ -914,6 +969,7 @@ export function createServeOptions(ctx: ServeOptionsContext) {
|
|
|
914
969
|
]);
|
|
915
970
|
} catch (error) {
|
|
916
971
|
if (error instanceof CatalogGatherBusyError) {
|
|
972
|
+
if (wantsDesktopConfig && !canInstallAliases()) return desktopSnapshotBusyResponse(req, policy);
|
|
917
973
|
return withCors(new Response(JSON.stringify({ error: { type: "server_error", code: "catalog_busy", message: error.message } }), {
|
|
918
974
|
status: 503,
|
|
919
975
|
headers: { "content-type": "application/json", "Retry-After": "1" },
|
|
@@ -975,7 +1031,6 @@ export function createServeOptions(ctx: ServeOptionsContext) {
|
|
|
975
1031
|
config, models: goModels, modelEntitlements,
|
|
976
1032
|
desktopNativeCandidates: desktopVisibleNativeSlugs(config),
|
|
977
1033
|
});
|
|
978
|
-
const desktopNativeSlugs = desktopInputs.nativeSlugs;
|
|
979
1034
|
const goOrdered = desktopInputs.routedModels;
|
|
980
1035
|
// Claude Code / Claude Desktop gateway model discovery (GET /v1/models with
|
|
981
1036
|
// Anthropic-style headers; 003 G1-G8 + devlog 131). Entries use the official
|
|
@@ -994,10 +1049,6 @@ export function createServeOptions(ctx: ServeOptionsContext) {
|
|
|
994
1049
|
* `additional_speed_tiers` the Codex picker's own toggle is built from — but an
|
|
995
1050
|
* operator capability override or the final wire resolution can still make the
|
|
996
1051
|
* route ineligible, and `decideTier` would then drop the tier the row advertised.
|
|
997
|
-
*
|
|
998
|
-
* Declared here, above the Claude discovery call, because that call reads it while
|
|
999
|
-
* the raw OpenAI mapper further down does too; defining it there would leave this
|
|
1000
|
-
* use in its temporal dead zone.
|
|
1001
1052
|
*/
|
|
1002
1053
|
const nativeFastEligible = (metadataId: string): boolean =>
|
|
1003
1054
|
catalogFastRowEligible(config, { provider: OPENAI_CODEX_PROVIDER_ID, id: metadataId, native: true });
|
|
@@ -1010,64 +1061,17 @@ export function createServeOptions(ctx: ServeOptionsContext) {
|
|
|
1010
1061
|
* cannot classify it. Its aggregated `supportsServiceTier` is already true only
|
|
1011
1062
|
* when EVERY member supports the tier (aggregation.ts:201), which is the right
|
|
1012
1063
|
* rule for a row that fans out to all of them.
|
|
1013
|
-
*
|
|
1014
|
-
* Declared beside nativeFastEligible, above the Claude discovery call that reads
|
|
1015
|
-
* both; defining it near the raw OpenAI mapper below would leave that use in its
|
|
1016
|
-
* temporal dead zone.
|
|
1017
1064
|
*/
|
|
1018
1065
|
const catalogRowFastEligible = (m: { provider: string; id: string; supportsServiceTier?: boolean }): boolean =>
|
|
1019
1066
|
catalogFastRowEligible(config, m);
|
|
1020
1067
|
|
|
1021
1068
|
if (wantsAnthropicList && !url.searchParams.has("client_version")) {
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
const response = jsonResponse({ version: 1, models }, 200, req, policy);
|
|
1029
|
-
response.headers.set("Cache-Control", "no-store");
|
|
1030
|
-
return response;
|
|
1031
|
-
}
|
|
1032
|
-
if (config.claudeCode?.enabled === false) return jsonResponse({ data: [] }, 200, req, policy);
|
|
1033
|
-
// Build Desktop 3P registry so inbound alias resolution works for subsequent requests.
|
|
1034
|
-
buildDesktop3pRegistry(
|
|
1035
|
-
desktopNativeSlugs,
|
|
1036
|
-
desktopInputs.routedModels,
|
|
1037
|
-
config.claudeCode?.desktopProfile,
|
|
1038
|
-
desktopInputs.nativeContextCap,
|
|
1039
|
-
);
|
|
1040
|
-
const { buildAnthropicModelInfos, configuredRoutedDisplayName } = await import("../../claude/model-info");
|
|
1041
|
-
const { resolveAutoContext } = await import("../../claude/context-windows");
|
|
1042
|
-
const { resolvableDesktop3pAlias } = await import("../../claude/desktop-3p");
|
|
1043
|
-
// Per-surface id family (devlog 050): explicit ?ids= wins; otherwise the
|
|
1044
|
-
// Claude Code CLI discovery UA (`claude-code/<version>`, binary n_()) gets
|
|
1045
|
-
// readable claude-ocx ids and every other client (Desktop 3P) keeps the
|
|
1046
|
-
// hashed family its config was written with. Unknown UA -> hashed (safe).
|
|
1047
|
-
const idsParam = url.searchParams.get("ids");
|
|
1048
|
-
const idStyle = idsParam === "cli"
|
|
1049
|
-
? "readable" as const
|
|
1050
|
-
: idsParam === "desktop"
|
|
1051
|
-
? "desktop3p" as const
|
|
1052
|
-
: (/^claude-code\//i.test(req.headers.get("user-agent") ?? "") ? "readable" as const : "desktop3p" as const);
|
|
1053
|
-
const data = buildAnthropicModelInfos(
|
|
1054
|
-
desktopNativeSlugs,
|
|
1055
|
-
goOrdered,
|
|
1056
|
-
resolveAutoContext(config.claudeCode),
|
|
1057
|
-
idStyle,
|
|
1058
|
-
resolvableDesktop3pAlias,
|
|
1059
|
-
desktopInputs.nativeContextCap,
|
|
1060
|
-
config.fastMode,
|
|
1061
|
-
// Explicit opt-out omits the Fast predicate.
|
|
1062
|
-
config.fastRows !== false
|
|
1063
|
-
? (model: { provider: string; id: string; supportsServiceTier?: boolean }) =>
|
|
1064
|
-
model.provider === "native"
|
|
1065
|
-
? nativeFastEligible(model.id)
|
|
1066
|
-
: catalogRowFastEligible(model)
|
|
1067
|
-
: undefined,
|
|
1068
|
-
{ modelPickerOrder: config.modelPickerOrder, featured: config.subagentModels }, configuredRoutedDisplayName(config),
|
|
1069
|
-
);
|
|
1070
|
-
return jsonResponse({ data }, 200, req, policy);
|
|
1069
|
+
return renderAnthropicModelListing({
|
|
1070
|
+
req, url, policy, config, desktopInputs, wantsDesktopConfig, canInstallAliases,
|
|
1071
|
+
fastEligible: model => model.provider === "native"
|
|
1072
|
+
? nativeFastEligible(model.id)
|
|
1073
|
+
: catalogRowFastEligible(model),
|
|
1074
|
+
});
|
|
1071
1075
|
}
|
|
1072
1076
|
if (url.searchParams.has("client_version")) {
|
|
1073
1077
|
const { buildCodexModelList } = await import("../codex-model-list");
|
|
@@ -1079,28 +1083,6 @@ export function createServeOptions(ctx: ServeOptionsContext) {
|
|
|
1079
1083
|
}
|
|
1080
1084
|
// OpenAI list shape: native gpt bare + routed models namespaced "<provider>/<id>"
|
|
1081
1085
|
// (pure availability list — disabled natives are omitted entirely).
|
|
1082
|
-
// Grok Build discovers models through this endpoint too, and its model picker only
|
|
1083
|
-
// enables /effort for entries that advertise the reasoning ladder in the Grok model
|
|
1084
|
-
// catalog shape (supports_reasoning_effort + reasoning_efforts[]). The Codex catalog
|
|
1085
|
-
// branch above already carries the same ladders, so mirror them here — native rows
|
|
1086
|
-
// from the upstream snapshot, routed rows from the configured provider tiers. The
|
|
1087
|
-
// default uses the same canonical fallback as the Codex catalog resolver
|
|
1088
|
-
// (configured default, then medium, then high, then the first tier). Extra fields
|
|
1089
|
-
// are ignored by plain OpenAI clients.
|
|
1090
|
-
const grokEffortOption = (value: string, isDefault: boolean) => ({
|
|
1091
|
-
value,
|
|
1092
|
-
label: `${value[0].toUpperCase()}${value.slice(1)} Effort`,
|
|
1093
|
-
...(isDefault ? { default: true } : {}),
|
|
1094
|
-
});
|
|
1095
|
-
const grokEffortFields = (efforts: string[], configuredDefault?: string) => {
|
|
1096
|
-
const defaultEffort = grokDefaultReasoningEffort(efforts, configuredDefault);
|
|
1097
|
-
if (defaultEffort === undefined) return {};
|
|
1098
|
-
return {
|
|
1099
|
-
supports_reasoning_effort: true,
|
|
1100
|
-
reasoning_effort: defaultEffort,
|
|
1101
|
-
reasoning_efforts: efforts.map(effort => grokEffortOption(effort, effort === defaultEffort)),
|
|
1102
|
-
};
|
|
1103
|
-
};
|
|
1104
1086
|
// Cursor's local-agent runtime (Private Inference build) reads api_types + capabilities
|
|
1105
1087
|
// to enable its effort control; every other consumer ignores them. See
|
|
1106
1088
|
// src/server/models-capabilities.ts.
|
|
@@ -1203,9 +1185,13 @@ export function createServeOptions(ctx: ServeOptionsContext) {
|
|
|
1203
1185
|
));
|
|
1204
1186
|
};
|
|
1205
1187
|
const promoteAliasId = modelAliasIdPromoter(config);
|
|
1206
|
-
const
|
|
1188
|
+
const { effectiveModelAliases } = await import("../../providers/default-aliases");
|
|
1189
|
+
// One synchronous view per provider for this projection, including empty collision results.
|
|
1190
|
+
// Keep it request-local so later config or discovery changes cannot reuse stale aliases.
|
|
1191
|
+
const aliasViews = new Map<string, ReturnType<typeof effectiveModelAliases>>();
|
|
1192
|
+
const routedRows = uniqueCatalogModelsForRawPublicList(goOrdered)
|
|
1207
1193
|
.filter(m => listAllows(m.provider, m.id))
|
|
1208
|
-
.map(
|
|
1194
|
+
.map(m => {
|
|
1209
1195
|
// Same rule as the anthropic branch: with the global fast switch on, a client
|
|
1210
1196
|
// that has no Fast toggle is offered the fast identity directly. An operator
|
|
1211
1197
|
// alias is an explicit decision and still wins.
|
|
@@ -1213,14 +1199,12 @@ export function createServeOptions(ctx: ServeOptionsContext) {
|
|
|
1213
1199
|
const publicId = m.alias ?? `${m.provider}/${fastModelId ?? m.id}`;
|
|
1214
1200
|
const isCombo = m.provider === "combo" && exactComboSlugs.has(publicId);
|
|
1215
1201
|
const provider = config.providers[m.provider];
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
).get(m.id)
|
|
1223
|
-
: undefined;
|
|
1202
|
+
let aliases = aliasViews.get(m.provider);
|
|
1203
|
+
if (provider && aliases === undefined) {
|
|
1204
|
+
aliases = effectiveModelAliases(config, provider, knownModelIdsForProvider(m.provider, provider, config), m.provider);
|
|
1205
|
+
aliasViews.set(m.provider, aliases);
|
|
1206
|
+
}
|
|
1207
|
+
const effective = aliases?.get(m.id);
|
|
1224
1208
|
const effectiveId = !isCombo && !fastModelId && effective
|
|
1225
1209
|
? promoteAliasId(m.provider, m.id, effective.alias, catalogRowFastEligible(m)) ?? publicId
|
|
1226
1210
|
: publicId;
|
|
@@ -1258,7 +1242,7 @@ export function createServeOptions(ctx: ServeOptionsContext) {
|
|
|
1258
1242
|
config,
|
|
1259
1243
|
effortRowKnownIds,
|
|
1260
1244
|
));
|
|
1261
|
-
})
|
|
1245
|
+
});
|
|
1262
1246
|
const data = [
|
|
1263
1247
|
...visibleNatives
|
|
1264
1248
|
.filter(id => listAllows(OPENAI_CODEX_PROVIDER_ID, id))
|
|
@@ -1850,11 +1834,11 @@ export function createServeOptions(ctx: ServeOptionsContext) {
|
|
|
1850
1834
|
return withCors(formatErrorResponse(426, "upgrade_required", "WebSocket upgrade failed"), req, policy);
|
|
1851
1835
|
}
|
|
1852
1836
|
|
|
1853
|
-
// Data-plane guard: unknown /v1/* paths must fail with JSON 404, never fall through to the
|
|
1837
|
+
// Data-plane guard: unknown /v1/* and /v1beta/* paths must fail with JSON 404, never fall through to the
|
|
1854
1838
|
// GUI static handler (extensionless paths would get index.html with HTTP 200 and codex-rs
|
|
1855
1839
|
// endpoint clients — memories/*, realtime/* — would surface confusing
|
|
1856
1840
|
// serde decode errors instead of a clean not-found).
|
|
1857
|
-
if (url.pathname.startsWith("/v1/")) {
|
|
1841
|
+
if (url.pathname.startsWith("/v1/") || url.pathname.startsWith("/v1beta/")) {
|
|
1858
1842
|
return withCors(formatErrorResponse(404, "not_found", messagesUnknownEndpointMessage(req)), req, policy);
|
|
1859
1843
|
}
|
|
1860
1844
|
|
|
@@ -1942,6 +1926,8 @@ export function createServeOptions(ctx: ServeOptionsContext) {
|
|
|
1942
1926
|
const routeFetch = serveOptions.fetch;
|
|
1943
1927
|
// x-opencodex-served-by on GET /v1/models, whichever branch answered (src/remote/served-by.ts).
|
|
1944
1928
|
// Each request runs with its own caller slot, which admission fills for turn-state handle binding.
|
|
1945
|
-
|
|
1946
|
-
|
|
1929
|
+
// Each request also carries its peer snapshot (listener + kernel-observed address), read by local-only providers.
|
|
1930
|
+
return { ...serveOptions, fetch: (req: Request, requestServer: Server<WsData>): Promise<Response> => runWithRequestPeer(
|
|
1931
|
+
classifyRequestPeer(ingressForServer(requestServer), requestServer.requestIP?.(req)?.address, config.dashboardTrustedProxy, req.headers), () => runTurnStateCallerScope(async () =>
|
|
1932
|
+
stampServedBy(req.method, codexCompatibleUrl(req.url).pathname, await routeFetch(req, requestServer)))) } as const;
|
|
1947
1933
|
}
|
|
@@ -80,6 +80,7 @@ import {
|
|
|
80
80
|
withCors,
|
|
81
81
|
withManagementCors,
|
|
82
82
|
} from "../auth-cors";
|
|
83
|
+
import { connectionReplayScopeLive, releaseConnectionReplayScope } from "../../responses/state/connection-scope";
|
|
83
84
|
import {
|
|
84
85
|
disableResponsesRequestTimeout,
|
|
85
86
|
handleResponses,
|
|
@@ -96,6 +97,9 @@ import type { RequestMetricsRecorder } from "../request-metrics";
|
|
|
96
97
|
import { attachParsedRequestBody, resolveInboundBodyLimitBytes } from "../request-decompress";
|
|
97
98
|
import { responseToolOwnership } from "../responses/response-tool-ownership";
|
|
98
99
|
import { runTurnStateCallerScope } from "../turn-state-handles";
|
|
100
|
+
import { runWithRequestPeer } from "../../lib/request-peer-scope";
|
|
101
|
+
/** The socket recorded a local peer at its upgrade; any other socket has no local snapshot. */
|
|
102
|
+
const LOCAL_PEER = Object.freeze({ local: true });
|
|
99
103
|
import { admitHttpWorkflowTurn, workflowDecisionRefusalResponse } from "../workflow-refusal";
|
|
100
104
|
|
|
101
105
|
/**
|
|
@@ -318,7 +322,7 @@ export function createWebsocketHandler(
|
|
|
318
322
|
delete payload.type;
|
|
319
323
|
turnAdmissionLease.bindAbortController(turnAbort);
|
|
320
324
|
// The frame runs with its own caller slot, which admission fills for turn-state handle binding.
|
|
321
|
-
void runTurnStateCallerScope(async () => {
|
|
325
|
+
void runWithRequestPeer(ws.data.peerLocal === true ? LOCAL_PEER : undefined, () => runTurnStateCallerScope(async () => {
|
|
322
326
|
const start = Date.now();
|
|
323
327
|
const requestId = nextRequestLogId(start);
|
|
324
328
|
// Resolved once at the handshake — a frame has no request headers left
|
|
@@ -374,12 +378,17 @@ export function createWebsocketHandler(
|
|
|
374
378
|
const retainedPrincipal = ws.data.replayPrincipal;
|
|
375
379
|
const replayPrincipal = retainedPrincipal && (isContextPrincipalCurrent(retainedPrincipal.clientPrincipalId, config)
|
|
376
380
|
? retainedPrincipal : { clientPrincipalId: undefined });
|
|
381
|
+
// The connection scope is a live-socket capability, not a retained credential:
|
|
382
|
+
// once closed or expired it stops backfilling the replay owner entirely.
|
|
383
|
+
const retainedScope = ws.data.replayScope;
|
|
384
|
+
const replayScope = retainedScope && connectionReplayScopeLive(retainedScope) ? retainedScope : undefined;
|
|
377
385
|
const response = await handleResponses(req, config, logCtx, {
|
|
378
386
|
advisorAdmissionPolicy,
|
|
379
387
|
...(wsAdmission ? { admission: wsAdmission } : {}),
|
|
380
388
|
// Keep an empty holder after revocation: a different forwarded bearer
|
|
381
389
|
// must not become this connection's retained replay owner.
|
|
382
390
|
...(replayPrincipal ? { replayPrincipal } : {}),
|
|
391
|
+
...(replayScope ? { replayScope } : {}),
|
|
383
392
|
forceEmptyResponseId: true,
|
|
384
393
|
inboundTransport: "websocket",
|
|
385
394
|
nativeControl,
|
|
@@ -469,7 +478,7 @@ export function createWebsocketHandler(
|
|
|
469
478
|
ws.data.linkTurnEnded?.(turnId);
|
|
470
479
|
if (ws.data.cancel === cancelTurn) ws.data.cancel = undefined;
|
|
471
480
|
}
|
|
472
|
-
});
|
|
481
|
+
}));
|
|
473
482
|
},
|
|
474
483
|
close(ws: ServerWebSocket<WsData>, code: number, reason: string) {
|
|
475
484
|
if (ws.data.kind === "remote-workspace-agent") {
|
|
@@ -486,6 +495,10 @@ export function createWebsocketHandler(
|
|
|
486
495
|
unregisterCodexWebSocket(ws);
|
|
487
496
|
ws.data.admissionLease?.release();
|
|
488
497
|
ws.data.admissionLease = undefined;
|
|
498
|
+
// Close the connection scope before cancelling the turn so a late completion
|
|
499
|
+
// write is refused; then drop every entry this socket still owns.
|
|
500
|
+
releaseConnectionReplayScope(ws.data.replayScope);
|
|
501
|
+
ws.data.replayScope = undefined;
|
|
489
502
|
ws.data.cancel?.(); // RC2: abort the upstream when the client disconnects
|
|
490
503
|
},
|
|
491
504
|
} as const;
|
package/src/server/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { normalizeBindHostname } from "./bind-host";
|
|
|
5
5
|
import { configureInboundBodyBudget } from "./inbound-body-admission";
|
|
6
6
|
import { createAdmittedHttpTurn } from "./admitted-http-turn";
|
|
7
7
|
import { isOllamaNativePath } from "./ollama-native-paths";
|
|
8
|
+
import { geminiRouteAllows, isGeminiNativePath, parseGeminiNativePath } from "./gemini-native-paths";
|
|
8
9
|
import {
|
|
9
10
|
buildWarmupCompletionFrames,
|
|
10
11
|
buildWsErrorFrame,
|
|
@@ -34,6 +35,7 @@ import { migrateStartupReserveCapability } from "./reserve-capability-startup";
|
|
|
34
35
|
import { migrateStartupXaiResponses } from "./xai-responses-startup";
|
|
35
36
|
import { migrateStartupZaiResponses } from "./zai-responses-startup";
|
|
36
37
|
import { reconcileOAuthProviders } from "../oauth";
|
|
38
|
+
import { coolComboTargetForCommittedTerminal } from "../combos";
|
|
37
39
|
import { withCatalogWriteSerialization } from "../codex/catalog-write-serialization";
|
|
38
40
|
import { invalidateCodexModelsCacheWithPermit } from "../codex/catalog/sync";
|
|
39
41
|
import { currentServiceHomes, serviceStatePathsForOpenCodexHome } from "../service";
|
|
@@ -115,6 +117,7 @@ import {
|
|
|
115
117
|
inspectResponseLogSsePayload,
|
|
116
118
|
nextRequestLogId,
|
|
117
119
|
recordFirstOutput,
|
|
120
|
+
registerCommittedTerminalCooldownHandler,
|
|
118
121
|
type RequestLogContext,
|
|
119
122
|
type RequestLogEntry,
|
|
120
123
|
} from "./request-log";
|
|
@@ -232,6 +235,7 @@ function startServerWithSpendLedgerOwner(port: number | undefined, deps: StartSe
|
|
|
232
235
|
warnPlaintextV2AgentMessagesStartup(config);
|
|
233
236
|
warnAgentTaskRecoveryStartup(config);
|
|
234
237
|
setLiveStateStoreConfig(config);
|
|
238
|
+
registerCommittedTerminalCooldownHandler(coolComboTargetForCommittedTerminal);
|
|
235
239
|
applyProxyEnv(config, true);
|
|
236
240
|
assertServerAuthConfig(config);
|
|
237
241
|
const managementAuth = deps.managementAuthState ?? initializeManagementAuthState(config);
|
|
@@ -419,6 +423,10 @@ function startServerWithSpendLedgerOwner(port: number | undefined, deps: StartSe
|
|
|
419
423
|
return req.method === "POST";
|
|
420
424
|
}
|
|
421
425
|
if (path === "/v1/models") return req.method === "GET";
|
|
426
|
+
// Gemini wire (#8732): `ocx connect agy` points the CLI at this socket. Same admission as the
|
|
427
|
+
// chat wire it is translated into; each Gemini path admits only its own HTTP method.
|
|
428
|
+
const gemini = parseGeminiNativePath(path);
|
|
429
|
+
if (gemini) return geminiRouteAllows(gemini, req.method);
|
|
422
430
|
// Realtime voice — a directly-spawned `codex app-server` needs these for desktop voice
|
|
423
431
|
// the same way it needs /v1/responses. Two shapes, same trust model as /v1/responses:
|
|
424
432
|
// - standalone sessions (codex-rs thread/realtime/start, WebSocket transport):
|
|
@@ -452,6 +460,8 @@ function startServerWithSpendLedgerOwner(port: number | undefined, deps: StartSe
|
|
|
452
460
|
if (rawPath === "/opencodex-session") return req.method === "GET" || req.method === "POST";
|
|
453
461
|
// Ollama-compatible inference paths are data plane, not management: never via Tailscale Serve.
|
|
454
462
|
if (isOllamaNativePath(rawPath)) return false;
|
|
463
|
+
// Gemini-compatible inference paths are data plane too, and /v1beta/ is never a management route.
|
|
464
|
+
if (isGeminiNativePath(rawPath) || rawPath.startsWith("/v1beta/")) return false;
|
|
455
465
|
if (rawPath.startsWith("/api/")) return true;
|
|
456
466
|
if (req.method !== "GET" && req.method !== "HEAD") return false;
|
|
457
467
|
let decodedPath: string;
|
|
@@ -230,7 +230,8 @@ export async function deliverClientEncodedResponse(input: ClientEncodedDelivery)
|
|
|
230
230
|
hooks,
|
|
231
231
|
};
|
|
232
232
|
const encoded = encoder.protocol === "chat"
|
|
233
|
-
? encodeChatCompletionSse(events, { ...encodeOptions, failureVerdictSink, proxyErrorContext: logCtx,
|
|
233
|
+
? encodeChatCompletionSse(events, { ...encodeOptions, failureVerdictSink, proxyErrorContext: logCtx, includeUsage: encoder.includeUsage === true,
|
|
234
|
+
get localUpstream() { return input.localUpstream; } })
|
|
234
235
|
: encodeAnthropicMessageSse(events, {
|
|
235
236
|
...encodeOptions,
|
|
236
237
|
failureVerdictSink: encoder.stream ? undefined : messagesFailureVerdictSink,
|