@bitkyc08/opencodex 2.100.5 → 2.100.6-preview.20261119.1
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-D5qUBOoF.js +60 -0
- package/gui/dist/assets/Tray-DMwQSAli.js +1 -0
- package/gui/dist/assets/brand-mark-ycThul7d.js +1 -0
- package/gui/dist/assets/index-Bp_GaFFu.js +138 -0
- package/gui/dist/assets/index-BtwVlpeQ.css +2 -0
- package/gui/dist/assets/{segment-thumb-features-Bquysdn5.js → segment-thumb-features-BLUW2Fb1.js} +1 -1
- package/gui/dist/classic/assets/App-CoiVLRW3.css +1 -0
- package/gui/dist/classic/assets/App-D39mkP2w.js +59 -0
- package/gui/dist/classic/assets/Tray-nUmdL7K9.js +1 -0
- package/gui/dist/classic/assets/index-BJ4uxZk0.js +138 -0
- package/gui/dist/classic/assets/usage-companion-chart-DFoYm2RY.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
|
@@ -14,6 +14,7 @@ import { reconcileLiveStateStores } from "../../lib/state-store-registrations";
|
|
|
14
14
|
import { emailMaskingEnabled, projectEmail } from "../../lib/privacy";
|
|
15
15
|
import { CodexWarmupError, codexWarmupFailureReason, isCodexWarmupProvisioningFailure, warmCodexAccount } from "../warmup";
|
|
16
16
|
import type { CodexAccount, CodexAccountCredentials, OcxConfig } from "../../types";
|
|
17
|
+
import type { OAuthCredentials } from "../../oauth/types";
|
|
17
18
|
import type { CatalogDisposition } from "../convergence-types";
|
|
18
19
|
import { isValidCodexAccountId } from "../account-id";
|
|
19
20
|
import { codexAccountIdNamespaceCollisionError } from "../account-namespace-match";
|
|
@@ -176,6 +177,9 @@ export async function convergeAccountNamespaceCatalog(
|
|
|
176
177
|
}
|
|
177
178
|
}
|
|
178
179
|
|
|
180
|
+
// Once synchronous pool publication starts, a cancellation can no longer undo it.
|
|
181
|
+
const publishingPoolLogins = new WeakSet<CodexLoginStateRow>();
|
|
182
|
+
|
|
179
183
|
export async function handleCodexAuthLoginStart(req: Request, config: OcxConfig, convergeCodexCatalog?: CodexAuthCatalogConvergence): Promise<Response> {
|
|
180
184
|
const body = (await req.json().catch(() => ({}))) as {
|
|
181
185
|
id?: string;
|
|
@@ -183,9 +187,6 @@ export async function handleCodexAuthLoginStart(req: Request, config: OcxConfig,
|
|
|
183
187
|
openBrowser?: unknown;
|
|
184
188
|
device?: unknown;
|
|
185
189
|
};
|
|
186
|
-
// Device mode: no local browser, no loopback listener. The only way to add
|
|
187
|
-
// an account to a headless hub (#3366).
|
|
188
|
-
const useDeviceFlow = body.device === true;
|
|
189
190
|
const requestedAccountId = body.id?.trim();
|
|
190
191
|
const reauth = body.reauth === true;
|
|
191
192
|
if (requestedAccountId && !isValidCodexAccountId(requestedAccountId)) {
|
|
@@ -193,6 +194,12 @@ export async function handleCodexAuthLoginStart(req: Request, config: OcxConfig,
|
|
|
193
194
|
}
|
|
194
195
|
const accountId = requestedAccountId || `chatgpt-${Date.now()}`;
|
|
195
196
|
const runtimeConfig = getRuntimeConfig(config);
|
|
197
|
+
// Device mode: no local browser, no loopback listener. The only way to add
|
|
198
|
+
// an account to a headless hub (#3366). `codexAuthMethod: "device-only"`
|
|
199
|
+
// enforces it for every caller, so a dashboard or CLI that did not ask for
|
|
200
|
+
// it still never starts a localhost callback login (#8082).
|
|
201
|
+
const deviceOnly = runtimeConfig.codexAuthMethod === "device-only";
|
|
202
|
+
const useDeviceFlow = body.device === true || deviceOnly;
|
|
196
203
|
const preflightConflict = !reauth
|
|
197
204
|
? codexAccountPersistenceConflict(runtimeConfig, accountId, "create")
|
|
198
205
|
: undefined;
|
|
@@ -213,12 +220,23 @@ export async function handleCodexAuthLoginStart(req: Request, config: OcxConfig,
|
|
|
213
220
|
const flowId = `flow-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
214
221
|
const loginOwner: CodexLoginStateRow = { status: "starting", startedAt: Date.now() };
|
|
215
222
|
codexAuthLoginState.set(flowId, loginOwner);
|
|
223
|
+
const ownsFlow = () => codexAuthLoginState.get(flowId) === loginOwner;
|
|
224
|
+
const ownsPendingFlow = () => ownsFlow() && loginOwner.status === "pending";
|
|
225
|
+
const settlePoolLogin = (patch: Partial<CodexLoginStateRow>) => {
|
|
226
|
+
if (ownsPendingFlow()) setCodexLoginState(flowId, patch);
|
|
227
|
+
};
|
|
228
|
+
let persistedCredential: OAuthCredentials | undefined;
|
|
216
229
|
try {
|
|
217
230
|
const { startLoginFlow, getLoginStatus, publicOAuthAuthenticationErrorMessage } = await import("../../oauth");
|
|
218
231
|
const result = await startLoginFlow("chatgpt", {
|
|
219
232
|
forceLogin: true,
|
|
220
233
|
...(useDeviceFlow ? { flow: "device" as const } : {}),
|
|
221
|
-
}, {
|
|
234
|
+
}, {
|
|
235
|
+
flowId,
|
|
236
|
+
retainOutcome: () => ownsFlow() && (loginOwner.status === "starting" || loginOwner.status === "pending"),
|
|
237
|
+
// ChatGPT's scratch slot can be replaced by another login before this poller wakes up.
|
|
238
|
+
onCredentialPersisted: credential => { persistedCredential = credential; },
|
|
239
|
+
});
|
|
222
240
|
|
|
223
241
|
// Open the browser server-side (same pattern as /api/oauth/login in management-api.ts).
|
|
224
242
|
// The GUI's window.open is popup-blocked because it runs after an await, not a direct click.
|
|
@@ -248,14 +266,26 @@ export async function handleCodexAuthLoginStart(req: Request, config: OcxConfig,
|
|
|
248
266
|
const pollAttempts = useDeviceFlow ? 480 : 150;
|
|
249
267
|
for (let i = 0; i < pollAttempts; i++) {
|
|
250
268
|
await new Promise(r => setTimeout(r, 2000));
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
269
|
+
if (!ownsPendingFlow()) return;
|
|
270
|
+
const st = getLoginStatus("chatgpt", true, flowId);
|
|
271
|
+
if (st.status === "error") {
|
|
272
|
+
settlePoolLogin({
|
|
273
|
+
status: "error",
|
|
274
|
+
// startLoginFlow projects background failures before storing login status, so
|
|
275
|
+
// fixed actionable OAuth messages retain their type-derived remediation here.
|
|
276
|
+
error: st.error,
|
|
277
|
+
doneAt: Date.now(),
|
|
278
|
+
});
|
|
279
|
+
completed = true;
|
|
280
|
+
break;
|
|
281
|
+
}
|
|
282
|
+
if (st.status === "complete") {
|
|
283
|
+
const cred = persistedCredential;
|
|
284
|
+
persistedCredential = undefined;
|
|
255
285
|
if (cred) {
|
|
256
286
|
const oauthAccountId = cred.accountId;
|
|
257
287
|
if (!oauthAccountId) {
|
|
258
|
-
|
|
288
|
+
settlePoolLogin({
|
|
259
289
|
status: "error",
|
|
260
290
|
error: "Could not determine account identity from OAuth tokens. Please retry OAuth login.",
|
|
261
291
|
doneAt: Date.now(),
|
|
@@ -282,6 +312,7 @@ export async function handleCodexAuthLoginStart(req: Request, config: OcxConfig,
|
|
|
282
312
|
policyQuota = poolWhamPolicyObservation(data, quota);
|
|
283
313
|
}
|
|
284
314
|
} catch { /* wham fetch is non-blocking */ }
|
|
315
|
+
if (!ownsPendingFlow()) return;
|
|
285
316
|
// Reauth must refresh the same ChatGPT identity already bound to this pool slot.
|
|
286
317
|
// Otherwise a different login would silently overwrite credentials under a trusted id.
|
|
287
318
|
if (reauth) {
|
|
@@ -292,7 +323,7 @@ export async function handleCodexAuthLoginStart(req: Request, config: OcxConfig,
|
|
|
292
323
|
const gotEmail = email.trim().toLowerCase();
|
|
293
324
|
if (expectedChatgptId) {
|
|
294
325
|
if (expectedChatgptId !== oauthAccountId) {
|
|
295
|
-
|
|
326
|
+
settlePoolLogin({
|
|
296
327
|
status: "error",
|
|
297
328
|
error: "Signed-in ChatGPT account does not match this pool account. Sign in with the same account, or remove it and add a new one.",
|
|
298
329
|
doneAt: Date.now(),
|
|
@@ -302,7 +333,7 @@ export async function handleCodexAuthLoginStart(req: Request, config: OcxConfig,
|
|
|
302
333
|
}
|
|
303
334
|
} else if (expectedEmail) {
|
|
304
335
|
if (!gotEmail || gotEmail !== expectedEmail) {
|
|
305
|
-
|
|
336
|
+
settlePoolLogin({
|
|
306
337
|
status: "error",
|
|
307
338
|
error: "Signed-in ChatGPT account does not match this pool account. Sign in with the same account, or remove it and add a new one.",
|
|
308
339
|
doneAt: Date.now(),
|
|
@@ -313,7 +344,7 @@ export async function handleCodexAuthLoginStart(req: Request, config: OcxConfig,
|
|
|
313
344
|
} else {
|
|
314
345
|
// No chatgptAccountId and no pool email — refuse silent identity replacement
|
|
315
346
|
// (including empty credential slots that still have a pool row).
|
|
316
|
-
|
|
347
|
+
settlePoolLogin({
|
|
317
348
|
status: "error",
|
|
318
349
|
error: "Cannot verify account identity for reauth. Remove this account and add it again.",
|
|
319
350
|
doneAt: Date.now(),
|
|
@@ -325,8 +356,9 @@ export async function handleCodexAuthLoginStart(req: Request, config: OcxConfig,
|
|
|
325
356
|
|
|
326
357
|
// 1.2: Duplicate check is scoped by personal vs workspace plan bucket.
|
|
327
358
|
const collision = await checkAccountIdCollision(oauthAccountId, email, plan, reauth ? accountId : undefined);
|
|
359
|
+
if (!ownsPendingFlow()) return;
|
|
328
360
|
if (collision.collision) {
|
|
329
|
-
|
|
361
|
+
settlePoolLogin({
|
|
330
362
|
status: "error", error: collision.reason, doneAt: Date.now(),
|
|
331
363
|
});
|
|
332
364
|
completed = true;
|
|
@@ -341,9 +373,10 @@ export async function handleCodexAuthLoginStart(req: Request, config: OcxConfig,
|
|
|
341
373
|
const warmup = isCodexQuotaExhausted(quota, plan)
|
|
342
374
|
? { ok: true as const, validatedAt: undefined }
|
|
343
375
|
: await verifyCodexAccountWarmup(accountId, cred.access, oauthAccountId);
|
|
376
|
+
if (!ownsPendingFlow()) return;
|
|
344
377
|
if (!warmup.ok) {
|
|
345
378
|
const body = await warmup.response.json().catch(() => ({})) as { error?: string; code?: string; reason?: string };
|
|
346
|
-
|
|
379
|
+
settlePoolLogin({
|
|
347
380
|
status: "error",
|
|
348
381
|
error: body.reason ? `${body.error ?? "Codex account warmup failed"} (${body.reason})` : body.error ?? "Codex account warmup failed",
|
|
349
382
|
code: body.code,
|
|
@@ -364,7 +397,7 @@ export async function handleCodexAuthLoginStart(req: Request, config: OcxConfig,
|
|
|
364
397
|
reauth ? "reauth" : "create",
|
|
365
398
|
);
|
|
366
399
|
if (commitConflict) {
|
|
367
|
-
|
|
400
|
+
settlePoolLogin({
|
|
368
401
|
status: "error",
|
|
369
402
|
error: commitConflict,
|
|
370
403
|
doneAt: Date.now(),
|
|
@@ -380,6 +413,8 @@ export async function handleCodexAuthLoginStart(req: Request, config: OcxConfig,
|
|
|
380
413
|
chatgptAccountId: oauthAccountId,
|
|
381
414
|
};
|
|
382
415
|
|
|
416
|
+
if (!ownsPendingFlow()) return;
|
|
417
|
+
publishingPoolLogins.add(loginOwner);
|
|
383
418
|
if (existingIdx >= 0) {
|
|
384
419
|
const generation = saveCodexAccountCredential(accountId, credential, {
|
|
385
420
|
validationPending: warmup.validatedAt === undefined,
|
|
@@ -439,14 +474,14 @@ export async function handleCodexAuthLoginStart(req: Request, config: OcxConfig,
|
|
|
439
474
|
convergeCodexCatalog,
|
|
440
475
|
);
|
|
441
476
|
if (newAccountPersistence?.status === "publication-failed") {
|
|
442
|
-
|
|
477
|
+
settlePoolLogin({
|
|
443
478
|
status: "error",
|
|
444
479
|
...codexCredentialPersistenceFailure(accountId, catalogRefreshPending),
|
|
445
480
|
doneAt: Date.now(),
|
|
446
481
|
});
|
|
447
482
|
completed = true;
|
|
448
483
|
} else {
|
|
449
|
-
|
|
484
|
+
settlePoolLogin({
|
|
450
485
|
status: "done",
|
|
451
486
|
accountId,
|
|
452
487
|
email,
|
|
@@ -456,23 +491,19 @@ export async function handleCodexAuthLoginStart(req: Request, config: OcxConfig,
|
|
|
456
491
|
});
|
|
457
492
|
completed = true;
|
|
458
493
|
}
|
|
494
|
+
} else {
|
|
495
|
+
settlePoolLogin({
|
|
496
|
+
status: "error",
|
|
497
|
+
error: "OAuth login completed without a usable credential. Please retry OAuth login.",
|
|
498
|
+
doneAt: Date.now(),
|
|
499
|
+
});
|
|
500
|
+
completed = true;
|
|
459
501
|
}
|
|
460
502
|
break;
|
|
461
503
|
}
|
|
462
|
-
if (st.done && st.error) {
|
|
463
|
-
setCodexLoginState(flowId, {
|
|
464
|
-
status: "error",
|
|
465
|
-
// startLoginFlow projects background failures before storing login status, so
|
|
466
|
-
// fixed actionable OAuth messages retain their type-derived remediation here.
|
|
467
|
-
error: st.error,
|
|
468
|
-
doneAt: Date.now(),
|
|
469
|
-
});
|
|
470
|
-
completed = true;
|
|
471
|
-
break;
|
|
472
|
-
}
|
|
473
504
|
}
|
|
474
505
|
if (!completed) {
|
|
475
|
-
|
|
506
|
+
settlePoolLogin({
|
|
476
507
|
status: "error",
|
|
477
508
|
error: "Login timed out before OAuth completed.",
|
|
478
509
|
doneAt: Date.now(),
|
|
@@ -487,12 +518,13 @@ export async function handleCodexAuthLoginStart(req: Request, config: OcxConfig,
|
|
|
487
518
|
: error instanceof CodexCredentialRefreshBusyError || error instanceof CodexCredentialRefreshStaleError
|
|
488
519
|
? "Credential refresh is busy; retry login shortly."
|
|
489
520
|
: publicOAuthAuthenticationErrorMessage(error);
|
|
490
|
-
|
|
521
|
+
settlePoolLogin({
|
|
491
522
|
status: "error",
|
|
492
523
|
error: message,
|
|
493
524
|
doneAt: Date.now(),
|
|
494
525
|
});
|
|
495
526
|
} finally {
|
|
527
|
+
persistedCredential = undefined;
|
|
496
528
|
// TTL: keep completed flow state available for clients that miss a short polling window.
|
|
497
529
|
setTimeout(() => { if (codexAuthLoginState.get(flowId) === loginOwner) codexAuthLoginState.delete(flowId); }, CODEX_LOGIN_TERMINAL_TTL_MS);
|
|
498
530
|
}
|
|
@@ -509,6 +541,8 @@ export async function handleCodexAuthLoginStart(req: Request, config: OcxConfig,
|
|
|
509
541
|
// Dropped before #3366: every device-code surface renders this field,
|
|
510
542
|
// so withholding it left the GUI and CLI with no code to show.
|
|
511
543
|
...(result.deviceCode ? { deviceCode: result.deviceCode } : {}),
|
|
544
|
+
// Tells the caller the device grant was imposed by configuration, not chosen by it.
|
|
545
|
+
...(deviceOnly ? { authMethod: "device-only" as const } : {}),
|
|
512
546
|
});
|
|
513
547
|
} catch (e) {
|
|
514
548
|
if (codexAuthLoginState.get(flowId) === loginOwner) codexAuthLoginState.delete(flowId);
|
|
@@ -550,12 +584,13 @@ export async function handleCodexAuthLoginCancel(req: Request): Promise<Response
|
|
|
550
584
|
? (body as { flowId?: unknown }).flowId : undefined;
|
|
551
585
|
const flowId = typeof suppliedId === "string" ? suppliedId.trim() : "";
|
|
552
586
|
if (!flowId) return jsonResponse({ error: "flowId required" }, 400);
|
|
553
|
-
const { cancelLoginFlow } = await import("../../oauth");
|
|
587
|
+
const { cancelLoginFlow, getLoginStatus } = await import("../../oauth");
|
|
554
588
|
const flow = codexAuthLoginState.get(flowId);
|
|
555
|
-
if (!flow || flow.status !== "pending") {
|
|
589
|
+
if (!flow || flow.status !== "pending" || publishingPoolLogins.has(flow)) {
|
|
556
590
|
return jsonResponse({ error: "login flow expired or unknown" }, 400);
|
|
557
591
|
}
|
|
558
|
-
|
|
592
|
+
// OAuth may have settled while the pool login is still checking the identity and quota.
|
|
593
|
+
if (!cancelLoginFlow("chatgpt", flowId) && getLoginStatus("chatgpt", true, flowId).status !== "complete") {
|
|
559
594
|
return jsonResponse({ error: "login flow expired or unknown" }, 400);
|
|
560
595
|
}
|
|
561
596
|
expireCodexAuthFlow(flowId);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import {
|
|
3
|
+
import { rememberCodexCredits } from "../credits";
|
|
4
4
|
import { fetchCodexUsage } from "../quota-query-backoff";
|
|
5
5
|
import type { CodexUsageOwner } from "../quota-query-backoff";
|
|
6
6
|
import { loadConfig } from "../../config";
|
|
@@ -8,7 +8,7 @@ import { isCanonicalOpenAiForwardProvider, OPENAI_CODEX_PROVIDER_ID } from "../.
|
|
|
8
8
|
import { providerCodexAccountMode } from "../../providers/registry";
|
|
9
9
|
import { isSelectableCodexPoolAccount } from "../account-id";
|
|
10
10
|
import type { OcxConfig } from "../../types";
|
|
11
|
-
import { isValidWhamHistoryObservation, parseMainPolicyUsageQuota, parseUsageQuota, setAccountQuotaFromParsed } from "../quota";
|
|
11
|
+
import { isValidWhamHistoryObservation, parseMainPolicyUsageQuota, parseUsageQuota, parseWhamCredits, setAccountQuotaFromParsed } from "../quota";
|
|
12
12
|
import type { StoredAccountQuota, WhamUsageResponse } from "../quota";
|
|
13
13
|
import { reconcileMainCodexAccountRuntimeState } from "../account-lifecycle";
|
|
14
14
|
import { getMainChatgptAccountId, readCodexTokensResult } from "../auth-collision";
|
|
@@ -424,7 +424,7 @@ export async function fetchMainAccountInfoWhileOwned(
|
|
|
424
424
|
// Tag the count with the identity it was read from, so a later response that omits the
|
|
425
425
|
// summary can restore the badge without ever crossing an account boundary.
|
|
426
426
|
rememberMainResetCredits(requestAccountId, freshResetCredits);
|
|
427
|
-
if (requestAccountId !== null) rememberCodexCredits(MAIN_CODEX_ACCOUNT_ID, requestAccountId,
|
|
427
|
+
if (requestAccountId !== null) rememberCodexCredits(MAIN_CODEX_ACCOUNT_ID, requestAccountId, parseWhamCredits(usage));
|
|
428
428
|
setMainAccountInfoCache(result);
|
|
429
429
|
// Only an explicit refresh may retract a reauth quarantine. A 200 from
|
|
430
430
|
// /wham/usage proves the token authenticates to the usage endpoint; it does not
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { rememberCodexCredits } from "../credits";
|
|
2
2
|
import { fetchCodexUsage } from "../quota-query-backoff";
|
|
3
3
|
import type { CodexUsageOwner } from "../quota-query-backoff";
|
|
4
4
|
import { capturePoolQuotaWriter, getValidCodexToken, isCodexAccountGenerationLive, forceRefreshCodexPoolToken, markCodexAccountValidated, markCodexAccountValidationFailed, readCodexAccountRecord, isTerminalCodexPoolRefreshFailure, CodexCredentialGenerationConflictError, CodexCredentialRefreshLockTimeoutError, CodexCredentialRefreshBusyError, CodexCredentialRefreshStaleError, TokenRefreshError } from "../account-store";
|
|
5
5
|
import type { PoolQuotaWriter } from "../quota-types";
|
|
6
|
-
import { isValidWhamHistoryObservation, getAccountQuota, isCompleteCodexQuotaRecoverySnapshot, parseUsageQuota, poolWhamPolicyObservation, setAccountQuotaFromParsed } from "../quota";
|
|
6
|
+
import { isValidWhamHistoryObservation, getAccountQuota, isCompleteCodexQuotaRecoverySnapshot, parseUsageQuota, parseWhamCredits, poolWhamPolicyObservation, setAccountQuotaFromParsed } from "../quota";
|
|
7
7
|
import type { StoredAccountQuota, WhamUsageResponse } from "../quota";
|
|
8
8
|
import type { ManualResetRefreshLineage } from "../routing";
|
|
9
9
|
import { clearAccountNeedsReauth, markAccountNeedsReauth } from "../account-runtime-state";
|
|
@@ -359,11 +359,12 @@ export async function commitPoolQuotaResponse(
|
|
|
359
359
|
if (ctx.mayPublish?.() === false) {
|
|
360
360
|
return { quota: getAccountQuota(accountId), needsReauth: false, credentialGeneration: generation };
|
|
361
361
|
}
|
|
362
|
+
const freshPlan = nonEmptyPlan(data.plan_type) ?? undefined;
|
|
363
|
+
const usage = { ...data, plan_type: freshPlan ?? configuredPlan };
|
|
362
364
|
if (ctx.poolWriter && isCodexAccountGenerationLive(accountId, generation)) {
|
|
363
|
-
rememberCodexCredits(accountId, ctx.poolWriter.historyIdentity,
|
|
365
|
+
rememberCodexCredits(accountId, ctx.poolWriter.historyIdentity, parseWhamCredits(usage));
|
|
364
366
|
}
|
|
365
|
-
const
|
|
366
|
-
const quota = parseUsageQuota({ ...data, plan_type: freshPlan ?? configuredPlan });
|
|
367
|
+
const quota = parseUsageQuota(usage);
|
|
367
368
|
const freshResetCredits = quota?.resetCredits;
|
|
368
369
|
if (!quota) {
|
|
369
370
|
return {
|
|
@@ -376,8 +377,8 @@ export async function commitPoolQuotaResponse(
|
|
|
376
377
|
if (!isCodexAccountGenerationLive(accountId, generation)) {
|
|
377
378
|
return { quota: null, needsReauth: false, credentialGeneration: generation };
|
|
378
379
|
}
|
|
379
|
-
const validPolicyObservation = isValidWhamHistoryObservation(
|
|
380
|
-
setAccountQuotaFromParsed(accountId, quota, writerGeneration, undefined, poolWhamPolicyObservation(
|
|
380
|
+
const validPolicyObservation = isValidWhamHistoryObservation(usage);
|
|
381
|
+
setAccountQuotaFromParsed(accountId, quota, writerGeneration, undefined, poolWhamPolicyObservation(usage, quota),
|
|
381
382
|
ctx.poolWriter && validPolicyObservation ? { writer: ctx.poolWriter, observedAt, source: "wham", raw: quota } : undefined,
|
|
382
383
|
true);
|
|
383
384
|
return {
|
|
@@ -385,7 +385,7 @@ export async function handleCodexAuthAPI(
|
|
|
385
385
|
if (body.strategy !== undefined) {
|
|
386
386
|
const parsed = parseCodexAccountPoolStrategy(body.strategy);
|
|
387
387
|
if (parsed === null) {
|
|
388
|
-
return jsonResponse({ error: 'strategy must be one of: quota, round-robin, fill-first, reset-first' }, 400);
|
|
388
|
+
return jsonResponse({ error: 'strategy must be one of: quota, round-robin, fill-first, reset-first, reset-near-weighted' }, 400);
|
|
389
389
|
}
|
|
390
390
|
nextStrategy = parsed;
|
|
391
391
|
}
|
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
targetKey,
|
|
30
30
|
} from "../../combos";
|
|
31
31
|
import type { NormalizedComboConfig } from "../../combos/types";
|
|
32
|
+
import { comboAdvertisesEffortUnion, unionEfforts, unionStrings } from "../../combos/capability-policy";
|
|
32
33
|
import { providerDestinationResolvedError } from "../../lib/destination-policy";
|
|
33
34
|
import { redactSecretString } from "../../lib/redact";
|
|
34
35
|
import upstreamModelsSnapshot from "../data/upstream-models.json";
|
|
@@ -113,13 +114,19 @@ export function comboCatalogOmissionReason(
|
|
|
113
114
|
return "incomplete_metadata";
|
|
114
115
|
}
|
|
115
116
|
|
|
116
|
-
const inputModalities =
|
|
117
|
-
members.map(member => member.inputModalities ?? ["text"]),
|
|
118
|
-
);
|
|
117
|
+
const inputModalities = comboInputModalities(combo, members);
|
|
119
118
|
if (inputModalities.length === 0) return "incompatible_modalities";
|
|
120
119
|
return null;
|
|
121
120
|
}
|
|
122
121
|
|
|
122
|
+
/** Union dispatch cannot verify video support on the selected wire. */
|
|
123
|
+
function comboInputModalities(combo: NormalizedComboConfig, members: readonly CatalogModel[]): string[] {
|
|
124
|
+
const lists = members.map(member => member.inputModalities ?? ["text"]);
|
|
125
|
+
return combo.capabilityPolicy === "union"
|
|
126
|
+
? unionStrings(lists).filter(modality => modality !== "video")
|
|
127
|
+
: intersectStrings(lists);
|
|
128
|
+
}
|
|
129
|
+
|
|
123
130
|
export function deriveComboCatalogModel(
|
|
124
131
|
id: string,
|
|
125
132
|
combo: NormalizedComboConfig,
|
|
@@ -127,9 +134,7 @@ export function deriveComboCatalogModel(
|
|
|
127
134
|
): CatalogModel | null {
|
|
128
135
|
if (comboCatalogOmissionReason(combo, members) !== null) return null;
|
|
129
136
|
|
|
130
|
-
const derivedInputModalities =
|
|
131
|
-
members.map(member => member.inputModalities ?? ["text"]),
|
|
132
|
-
);
|
|
137
|
+
const derivedInputModalities = comboInputModalities(combo, members);
|
|
133
138
|
const inputModalities = combo.imageInput === "disabled"
|
|
134
139
|
? derivedInputModalities.filter(modality => modality !== "image")
|
|
135
140
|
: derivedInputModalities;
|
|
@@ -147,16 +152,22 @@ export function deriveComboCatalogModel(
|
|
|
147
152
|
const advertisedLadders = combo.reasoningEffortMode === "adaptive"
|
|
148
153
|
? knownLadders.filter(ladder => ladder.length > 0)
|
|
149
154
|
: knownLadders;
|
|
150
|
-
|
|
155
|
+
// The JEV decision owns effort in decide mode, so the picker has no effort control.
|
|
156
|
+
// Client mode keeps the ladder from ordinary Combo policy.
|
|
157
|
+
const decisionOwnsEffort = combo.strategy === "jev" && combo.jevEffortMode !== "client";
|
|
158
|
+
const reasoningEfforts = decisionOwnsEffort || advertisedLadders.length === 0
|
|
151
159
|
? []
|
|
152
|
-
:
|
|
160
|
+
: comboAdvertisesEffortUnion(combo.capabilityPolicy, combo.reasoningEffortMode)
|
|
161
|
+
? unionEfforts(advertisedLadders)
|
|
162
|
+
: intersectStrings(advertisedLadders);
|
|
163
|
+
// Publish a window safe across all targets. Request admission can still use larger members.
|
|
153
164
|
const contextWindow = Math.min(...members.map(member => member.contextWindow!));
|
|
154
165
|
const limitingMembers = members.filter(member => member.contextWindow === contextWindow);
|
|
155
166
|
const hasLimitingContextCapMetadata = limitingMembers.some(
|
|
156
167
|
member => typeof member.contextCapped === "boolean",
|
|
157
168
|
);
|
|
158
|
-
// A combo is cap-limited only when every member defining its effective
|
|
159
|
-
// itself reduced by a provider cap. An uncapped member at the same
|
|
169
|
+
// A combo is cap-limited only when every member defining its effective window was
|
|
170
|
+
// itself reduced by a provider cap. An uncapped member at the same window means the
|
|
160
171
|
// combo would have the same window even without the cap.
|
|
161
172
|
const contextCapped = limitingMembers.every(member => member.contextCapped === true);
|
|
162
173
|
const maxInputTokens = Math.min(
|
|
@@ -170,6 +181,7 @@ export function deriveComboCatalogModel(
|
|
|
170
181
|
? Math.min(...knownMaxOutputTokens)
|
|
171
182
|
: undefined;
|
|
172
183
|
const autoCompactTokenLimit = Math.min(
|
|
184
|
+
maxInputTokens,
|
|
173
185
|
...members.map(member => clampAutoCompactTokenLimit(
|
|
174
186
|
member.contextWindow!,
|
|
175
187
|
member.maxInputTokens,
|
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
} from "../../oauth";
|
|
34
34
|
import { getAccountSet } from "../../oauth/store";
|
|
35
35
|
import { mayResolveModelsOAuth } from "../../oauth/model-discovery-auth";
|
|
36
|
-
import { buildVertexProviderModelsRequest } from "../../providers/google-vertex-model-discovery";
|
|
36
|
+
import { buildVertexProviderModelsRequest, captureVertexDiscoveryCredentialIdentity } from "../../providers/google-vertex-model-discovery";
|
|
37
37
|
import type { OcxConfig, OcxProviderConfig } from "../../types";
|
|
38
38
|
import { modelInList } from "../../types";
|
|
39
39
|
import { CODEX_REASONING_LEVELS, codexEffortRank, configuredReasoningEfforts, modelRecordValue, sanitizeCodexReasoningEfforts } from "../../reasoning-effort";
|
|
@@ -121,6 +121,7 @@ export interface CatalogGatherProviderModelOutcome {
|
|
|
121
121
|
readonly state: "authoritative" | "degraded";
|
|
122
122
|
}
|
|
123
123
|
export interface ModelsAuthResolution {
|
|
124
|
+
readonly m365?: import("../../oauth/types").M365CopilotWebSession;
|
|
124
125
|
readonly workbuddy?: import("../../oauth/types").WorkBuddyOAuthMetadata;
|
|
125
126
|
readonly apiKey: string | undefined;
|
|
126
127
|
readonly observed: boolean;
|
|
@@ -462,6 +463,7 @@ export function captureProviderGather(
|
|
|
462
463
|
export function captureGatherFlight(
|
|
463
464
|
config: OcxConfig,
|
|
464
465
|
createAuthResolver: ModelsAuthResolverFactory,
|
|
466
|
+
onlyProvider?: string,
|
|
465
467
|
): GatherFlightCapture {
|
|
466
468
|
const providerAuthOutcomes: CatalogGatherProviderAuthOutcome[] = [];
|
|
467
469
|
const authResolver = createAuthResolver(providerAuthOutcomes);
|
|
@@ -469,7 +471,8 @@ export function captureGatherFlight(
|
|
|
469
471
|
const providers = Object.entries(config.providers)
|
|
470
472
|
// A decision service (canonical TypeSafe or a self-hosted `jev-decision` row) owns no model
|
|
471
473
|
// transport: never probe its endpoint for /models and never publish its model id as routable.
|
|
472
|
-
.filter(([, provider]) => provider.disabled !== true && provider.adapter !== "jev-decision"
|
|
474
|
+
.filter(([name, provider]) => provider.disabled !== true && provider.adapter !== "jev-decision"
|
|
475
|
+
&& (onlyProvider === undefined || name === onlyProvider))
|
|
473
476
|
.map(([name, provider]) => captureProviderGather(
|
|
474
477
|
name,
|
|
475
478
|
provider,
|
|
@@ -490,6 +493,12 @@ export function captureGatherFlight(
|
|
|
490
493
|
liveModels: provider.provider.liveModels ?? null,
|
|
491
494
|
credential: provider.provider.apiKey ?? null,
|
|
492
495
|
observedAuth: provider.observedAuth ?? null,
|
|
496
|
+
// Vertex credential incarnations can change with identical config and API-key bytes.
|
|
497
|
+
vertexCredentialIdentity: onlyProvider === undefined && provider.provider.authMode !== "forward"
|
|
498
|
+
&& provider.provider.authMode !== "oauth" && provider.provider.liveModels !== false
|
|
499
|
+
&& effectiveGoogleMode(provider.name, provider.provider) === "vertex"
|
|
500
|
+
? captureVertexDiscoveryCredentialIdentity(provider.provider, authResolver.kind === "refreshing")
|
|
501
|
+
: undefined,
|
|
493
502
|
oauthAccount: provider.refreshingOAuthAccountId ?? null,
|
|
494
503
|
headers: provider.request.headersWithCredential,
|
|
495
504
|
url: provider.request.url,
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { M365_COPILOT_BASE_URL, M365_COPILOT_DISPLAY_PREFIX } from "../../providers/m365-copilot-models";
|
|
3
|
+
import { normalizeM365WebSession } from "../../providers/m365-copilot-discovery";
|
|
4
|
+
import { fetchM365ModelRoster } from "../../providers/m365-copilot-discovery-fetch";
|
|
5
|
+
import { credentialGeneration, getAccountCredentialWithStatus, getAccountSet } from "../../oauth/store";
|
|
6
|
+
import { m365CopilotClaims } from "../../oauth/m365-copilot";
|
|
7
|
+
import { getFreshCached, getStaleCached, isModelsFetchCoolingDown, markModelsFetchFailure, markProviderDiscoveryFailed, markProviderDiscoveryOk, setCached } from "../model-cache";
|
|
8
|
+
import { applyConfigHintsToCachedModels, applyProviderConfigHints } from "./model-hints";
|
|
9
|
+
import type { CatalogModel } from "./parsing";
|
|
10
|
+
import type { CapturedProviderGather, ModelsAuthResolution } from "./gather-capture";
|
|
11
|
+
|
|
12
|
+
export async function fetchM365CopilotCatalog(captured: CapturedProviderGather, auth: ModelsAuthResolution, ttlMs: number, contextCap: number | undefined, isCurrent: () => boolean): Promise<{ models: CatalogModel[]; state: "authoritative" | "degraded" }> {
|
|
13
|
+
const { name, provider, metadataModelIdCaseFold, effectiveAlias, metadataConfigDir } = captured;
|
|
14
|
+
const session = normalizeM365WebSession(auth.m365);
|
|
15
|
+
if (name !== "m365-copilot" || provider.disabled || provider.authMode !== "oauth" || provider.baseUrl.replace(/\/+$/, "") !== M365_COPILOT_BASE_URL || !auth.apiKey || !session) {
|
|
16
|
+
if (isCurrent()) markProviderDiscoveryFailed(name, { reason: "provider" });
|
|
17
|
+
return { models: [], state: "degraded" };
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
const claims = m365CopilotClaims(auth.apiKey);
|
|
21
|
+
if (session.accountId.toLowerCase() !== (claims.oid + "@" + claims.tid).toLowerCase()) throw new Error("Account mismatch");
|
|
22
|
+
} catch {
|
|
23
|
+
// The identity changed, so stale cached rows must not be advertised; surface the failure like every other path.
|
|
24
|
+
if (isCurrent()) markProviderDiscoveryFailed(name, { reason: "provider" });
|
|
25
|
+
return { models: [], state: "degraded" };
|
|
26
|
+
}
|
|
27
|
+
const identity = createHash("sha256").update(JSON.stringify([auth.oauthAccountId, session.accountId, session.cookie])).digest("hex");
|
|
28
|
+
const hinted = (models: CatalogModel[]) => applyConfigHintsToCachedModels(name, provider, models, contextCap, metadataModelIdCaseFold, effectiveAlias, metadataConfigDir, false);
|
|
29
|
+
const fresh = getFreshCached(name, ttlMs, Date.now(), identity);
|
|
30
|
+
if (fresh) return { models: hinted(fresh), state: "authoritative" };
|
|
31
|
+
if (isModelsFetchCoolingDown(name, undefined, undefined, identity)) return { models: hinted(getStaleCached(name, identity) ?? []), state: "degraded" };
|
|
32
|
+
const maySend = () => {
|
|
33
|
+
if (!isCurrent()) return false;
|
|
34
|
+
if (auth.observed) return true;
|
|
35
|
+
const row = auth.oauthAccountId ? getAccountCredentialWithStatus(name, auth.oauthAccountId) : null;
|
|
36
|
+
return !!row && !row.paused && !row.needsReauth && getAccountSet(name)?.activeAccountId === auth.oauthAccountId
|
|
37
|
+
&& row.credential.access === auth.apiKey && credentialGeneration(row.credential) === auth.oauthGeneration && row.credential.m365?.cookie === session.cookie;
|
|
38
|
+
};
|
|
39
|
+
try {
|
|
40
|
+
const signal = AbortSignal.timeout(15_000);
|
|
41
|
+
const items = await fetchM365ModelRoster(name, provider, { accessToken: auth.apiKey, m365: session }, signal, maySend);
|
|
42
|
+
const models = items.map(item => applyProviderConfigHints(name, provider, { id: item.id, provider: name, displayName: M365_COPILOT_DISPLAY_PREFIX + (item.name as string), inputModalities: ["text", "image"] }, contextCap, metadataModelIdCaseFold, effectiveAlias, metadataConfigDir, false));
|
|
43
|
+
if (!maySend()) return { models: [], state: "degraded" };
|
|
44
|
+
setCached(name, models, Date.now(), undefined, identity);
|
|
45
|
+
markProviderDiscoveryOk(name, models.length);
|
|
46
|
+
return { models, state: "authoritative" };
|
|
47
|
+
} catch {
|
|
48
|
+
if (!maySend()) return { models: [], state: "degraded" };
|
|
49
|
+
if (isCurrent()) { markModelsFetchFailure(name, undefined, identity); markProviderDiscoveryFailed(name, { reason: "provider" }); }
|
|
50
|
+
return { models: hinted(getStaleCached(name, identity) ?? []), state: "degraded" };
|
|
51
|
+
}
|
|
52
|
+
}
|