@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
|
@@ -5,12 +5,13 @@ import { getValidAccessToken } from "../../oauth";
|
|
|
5
5
|
import { loadConfig } from "../../config";
|
|
6
6
|
import { configuredAnthropicInstance, type AnthropicInstanceId } from "../anthropic-instance";
|
|
7
7
|
import { isAnthropicPoolEnabledFor } from "../../oauth/anthropic-pool-config";
|
|
8
|
-
import {
|
|
8
|
+
import { anthropicCredentialEvidenceKey, captureOAuthAccountSelection, getAccountCredential, getAccountSet } from "../../oauth/store";
|
|
9
9
|
import { hydrateKiroAccountState, persistKiroAccountState } from "../kiro-account-state-disk";
|
|
10
10
|
import { kiroProbeCurrent, kiroProbeIdentity } from "./kiro-account-probe";
|
|
11
11
|
import { fetchMuseKeyQuotaSnapshot } from "../muse-key-quota";
|
|
12
|
-
import { probeAnthropicUsageQuota
|
|
12
|
+
import { probeAnthropicUsageQuota } from "../claude-cli-usage";
|
|
13
13
|
import { claudeSignedInIdentity, peekClaudeUsageObservation } from "../claude-cli-usage-state";
|
|
14
|
+
import { readXaiLegacyPrivacyError, XAI_LEGACY_PRIVACY_MESSAGE } from "../xai-privacy-mode";
|
|
14
15
|
import { XAI_GROK_CLIENT_VERSION, XAI_GROK_COMPATIBILITY } from "../xai-transport";
|
|
15
16
|
import {
|
|
16
17
|
commitKiroAccountUsageState,
|
|
@@ -37,16 +38,23 @@ import {
|
|
|
37
38
|
} from "./report-cache";
|
|
38
39
|
import {
|
|
39
40
|
accountCacheKey,
|
|
41
|
+
reserveAnthropicQuotaDispatch,
|
|
42
|
+
anthropicQuotaDispatchIsCurrent,
|
|
40
43
|
captureProviderAccountQuotaEpoch,
|
|
41
44
|
accountQuotaCache,
|
|
45
|
+
commitAnthropicAccountQuota,
|
|
42
46
|
getCachedProviderAccountQuota,
|
|
43
47
|
hydrateAccountQuotaCache,
|
|
44
48
|
mayCommitAccountQuotaKey,
|
|
45
49
|
persistAccountQuotaCache,
|
|
50
|
+
anthropicAccountProbeEvidence,
|
|
46
51
|
} from "./account-cache";
|
|
47
52
|
import type { OcxConfig, OcxProviderConfig } from "../../types";
|
|
48
53
|
import type { ProviderQuota, ProviderQuotaWindow } from "../quota-types";
|
|
49
|
-
import {
|
|
54
|
+
import {
|
|
55
|
+
AnthropicQuotaProbeOwnershipError, anthropicCooldownRecoveryFor,
|
|
56
|
+
type AnthropicQuotaRecoveryResult, type DispatchedAnthropicUsageProbe,
|
|
57
|
+
} from "./anthropic-cooldown-recovery";
|
|
50
58
|
|
|
51
59
|
const XAI_BILLING_URL = "https://cli-chat-proxy.grok.com/v1/billing";
|
|
52
60
|
const XAI_CREDITS_URL = `${XAI_BILLING_URL}?format=credits`;
|
|
@@ -168,7 +176,12 @@ export function parseXaiCreditsResponse(value: unknown): { percent: number; rese
|
|
|
168
176
|
};
|
|
169
177
|
}
|
|
170
178
|
|
|
171
|
-
|
|
179
|
+
function xaiQuotaPrivacyRefusal(): typeof TERMINAL_QUOTA_FAILURE {
|
|
180
|
+
console.warn(`[opencodex] xAI quota probe failed with HTTP 403. ${XAI_LEGACY_PRIVACY_MESSAGE}`);
|
|
181
|
+
return TERMINAL_QUOTA_FAILURE;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
async function fetchXaiWeeklyCredits(accessToken: string, userId: string): Promise<ProviderQuota | typeof TERMINAL_QUOTA_FAILURE | null> {
|
|
172
185
|
try {
|
|
173
186
|
const response = await fetch(XAI_CREDITS_URL, {
|
|
174
187
|
redirect: "error",
|
|
@@ -182,7 +195,7 @@ async function fetchXaiWeeklyCredits(accessToken: string, userId: string): Promi
|
|
|
182
195
|
},
|
|
183
196
|
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
|
|
184
197
|
});
|
|
185
|
-
if (!response.ok) return null;
|
|
198
|
+
if (!response.ok) return await readXaiLegacyPrivacyError(response) ? xaiQuotaPrivacyRefusal() : null;
|
|
186
199
|
const parsed = parseXaiCreditsResponse(await readQuotaJson(response));
|
|
187
200
|
if (!parsed) return null;
|
|
188
201
|
return {
|
|
@@ -195,13 +208,14 @@ async function fetchXaiWeeklyCredits(accessToken: string, userId: string): Promi
|
|
|
195
208
|
}
|
|
196
209
|
}
|
|
197
210
|
|
|
198
|
-
export async function fetchXaiQuota(provider: string, context: { accessToken: string; upstreamAccountId?: string }): Promise<
|
|
211
|
+
export async function fetchXaiQuota(provider: string, context: { accessToken: string; upstreamAccountId?: string }): Promise<ProviderQuotaProbeResult> {
|
|
199
212
|
const { accessToken } = context;
|
|
200
213
|
|
|
201
214
|
// Prefer the SuperGrok weekly credits window that actually gates prompting (#1283).
|
|
202
215
|
const userId = context.upstreamAccountId?.trim() || xaiUserIdFromAccessToken(accessToken);
|
|
203
216
|
if (userId) {
|
|
204
217
|
const weekly = await fetchXaiWeeklyCredits(accessToken, userId);
|
|
218
|
+
if (weekly === TERMINAL_QUOTA_FAILURE) return weekly;
|
|
205
219
|
if (weekly) return report(provider, "xai:grok-billing-credits", weekly);
|
|
206
220
|
}
|
|
207
221
|
|
|
@@ -212,7 +226,7 @@ export async function fetchXaiQuota(provider: string, context: { accessToken: st
|
|
|
212
226
|
headers: { Accept: "application/json", Authorization: `Bearer ${accessToken}` },
|
|
213
227
|
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
|
|
214
228
|
});
|
|
215
|
-
if (!response.ok) return null;
|
|
229
|
+
if (!response.ok) return await readXaiLegacyPrivacyError(response) ? xaiQuotaPrivacyRefusal() : null;
|
|
216
230
|
const body = asRecord(await readQuotaJson(response));
|
|
217
231
|
const config = asRecord(body?.config);
|
|
218
232
|
if (!config) return null;
|
|
@@ -231,7 +245,7 @@ export async function fetchXaiQuota(provider: string, context: { accessToken: st
|
|
|
231
245
|
}
|
|
232
246
|
}
|
|
233
247
|
|
|
234
|
-
const anthropicUsageInflight = new Map<string, Promise<
|
|
248
|
+
const anthropicUsageInflight = new Map<string, Promise<DispatchedAnthropicUsageProbe>>();
|
|
235
249
|
|
|
236
250
|
/**
|
|
237
251
|
* Anthropic per-credential usage.
|
|
@@ -263,21 +277,27 @@ export async function fetchAnthropicUsageQuotaForInstance(
|
|
|
263
277
|
return (await fetchAnthropicUsageProbeForInstance(instance, accessToken, requireFreshDispatch)).quota;
|
|
264
278
|
}
|
|
265
279
|
|
|
266
|
-
/** The
|
|
280
|
+
/** The shared flight with failure, retirement and physical-dispatch ownership evidence. */
|
|
267
281
|
export async function fetchAnthropicUsageProbeForInstance(
|
|
268
282
|
instance: AnthropicInstanceId,
|
|
269
283
|
accessToken: string,
|
|
270
284
|
requireFreshDispatch = false,
|
|
271
|
-
): Promise<
|
|
285
|
+
): Promise<DispatchedAnthropicUsageProbe> {
|
|
272
286
|
// Recovery evidence must be requested after the claimed cooldown. Joining an older request
|
|
273
287
|
// can return after the 429 while still describing provider state from before that refusal.
|
|
274
|
-
const
|
|
275
|
-
|
|
288
|
+
const accounts = getAccountSet(instance)?.accounts.filter(row => row.credential.access === accessToken) ?? [];
|
|
289
|
+
const credentialIdentity = accounts.map(row => [row.id, anthropicCredentialEvidenceKey(row)]);
|
|
276
290
|
const key = `${instance}\0${captureProviderAccountQuotaEpoch(instance)}\0${JSON.stringify(credentialIdentity)}\0${accessToken}`;
|
|
277
291
|
const joinable = requireFreshDispatch ? undefined : anthropicUsageInflight.get(key);
|
|
278
292
|
if (joinable) return joinable;
|
|
279
293
|
|
|
280
|
-
|
|
294
|
+
// Joiners inherit the ordering of the physical request, even after a competing observation.
|
|
295
|
+
const dispatch = reserveAnthropicQuotaDispatch();
|
|
296
|
+
const probe = probeAnthropicUsageQuota(accessToken).then(result => ({
|
|
297
|
+
...result, dispatch,
|
|
298
|
+
isQuotaDispatchCurrent: (id: string) =>
|
|
299
|
+
anthropicQuotaDispatchIsCurrent(accountCacheKey(instance, id), dispatch, result.quota?.monthlyPercent !== undefined),
|
|
300
|
+
})).finally(() => {
|
|
281
301
|
if (anthropicUsageInflight.get(key) === probe) anthropicUsageInflight.delete(key);
|
|
282
302
|
});
|
|
283
303
|
anthropicUsageInflight.set(key, probe);
|
|
@@ -288,7 +308,7 @@ export async function fetchAnthropicUsageProbeForInstance(
|
|
|
288
308
|
function anthropicPoolState(config: OcxConfig, instance: AnthropicInstanceId): string {
|
|
289
309
|
const accounts = getAccountSet(instance)?.accounts ?? [];
|
|
290
310
|
return JSON.stringify([isAnthropicPoolEnabledFor(config, instance),
|
|
291
|
-
accounts.map(row => [row.id, row.paused === true, row.needsReauth === true])]);
|
|
311
|
+
accounts.map(row => [row.id, row.paused === true, row.needsReauth === true, anthropicCredentialEvidenceKey(row)])]);
|
|
292
312
|
}
|
|
293
313
|
|
|
294
314
|
/**
|
|
@@ -357,32 +377,36 @@ export async function fetchAnthropicQuota(provider: string, config: OcxConfig =
|
|
|
357
377
|
const currentRow = getAccountSet(instance)?.accounts.find(row => row.id === probedAccountId);
|
|
358
378
|
if (!initialRow || !currentRow || initialRow.loginId !== currentRow.loginId || initialRow.addedAt !== currentRow.addedAt
|
|
359
379
|
|| epoch !== captureProviderAccountQuotaEpoch(instance) || recovery.anthropicAccountIncarnation(probedAccountId) !== incarnation) return null;
|
|
360
|
-
let
|
|
361
|
-
let anthropicCurrent: (() => boolean) | undefined; let anthropicPublish: (() => void) | undefined;
|
|
380
|
+
let result: AnthropicQuotaRecoveryResult | null;
|
|
362
381
|
try {
|
|
363
|
-
|
|
382
|
+
result = await recovery.probeAnthropicQuotaWithRecovery(probedAccountId, accessToken,
|
|
364
383
|
fresh => {
|
|
365
384
|
if (!targetCurrent()) throw new AnthropicQuotaProbeOwnershipError("quota target changed");
|
|
366
385
|
recovery.assertAnthropicQuotaSendAllowed(probedAccountId, accessToken);
|
|
367
|
-
return
|
|
386
|
+
return fetchAnthropicUsageProbeForInstance(instance, accessToken, fresh);
|
|
368
387
|
},
|
|
369
388
|
() => targetCurrent() && mayCommitAccountQuotaKey(probedAccountKey, writerGeneration));
|
|
370
|
-
if (result && !result.isCurrent()) return null;
|
|
371
|
-
quota = result?.quota ?? null;
|
|
372
|
-
anthropicCurrent = result?.isCurrent; anthropicPublish = result?.publishDecisionQuota;
|
|
373
389
|
} catch (error) {
|
|
374
390
|
if (error instanceof AnthropicQuotaProbeOwnershipError) return null;
|
|
375
391
|
throw error;
|
|
376
392
|
}
|
|
377
|
-
if (!
|
|
393
|
+
if (!result?.isCurrent()) return null;
|
|
394
|
+
const { quota, isCurrent: anthropicCurrent } = result;
|
|
378
395
|
// Share the active-account probe with the per-account cache so Providers-page
|
|
379
396
|
// loads do not double-hit Anthropic's rate-limited usage endpoint.
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
397
|
+
const stillOwnsToken = getAccountCredential(instance, probedAccountId)?.access === accessToken;
|
|
398
|
+
if (stillOwnsToken && anthropicCurrent() && mayCommitAccountQuotaKey(probedAccountKey, writerGeneration)) {
|
|
399
|
+
// The snapshot writer serializes the whole cache, including other accounts on a cold start.
|
|
400
|
+
hydrateAccountQuotaCache();
|
|
401
|
+
const ts = Date.now();
|
|
402
|
+
const evidence = anthropicAccountProbeEvidence(instance, probedAccountId, ts, result);
|
|
403
|
+
commitAnthropicAccountQuota(probedAccountKey, {
|
|
404
|
+
ts, ...evidence, isCurrent: anthropicCurrent, ...result.failureFields,
|
|
405
|
+
}, quota?.monthlyPercent === undefined, result.dispatch);
|
|
406
|
+
result.publishDecisionQuota();
|
|
407
|
+
persistAccountQuotaCache();
|
|
385
408
|
}
|
|
409
|
+
if (!quota) return null;
|
|
386
410
|
const pooledReport = anthropicPoolReport(provider, instance, config, probedAccountId, quota);
|
|
387
411
|
const quotaReport = pooledReport ?? report(provider, "anthropic:oauth-usage", quota);
|
|
388
412
|
// The estimate carries no reset times, so reset detection keeps observing the active seat's reading.
|
|
@@ -390,7 +414,7 @@ export async function fetchAnthropicQuota(provider: string, config: OcxConfig =
|
|
|
390
414
|
// Current only while the pool switch and membership are unchanged: pausing, resuming or reauthorizing
|
|
391
415
|
// an inactive seat changes the aggregate, and turning the pool on or adding a seat changes the report.
|
|
392
416
|
const poolState = anthropicPoolState(config, instance);
|
|
393
|
-
if (quotaReport
|
|
417
|
+
if (quotaReport) {
|
|
394
418
|
accountReportCurrent.set(quotaReport, () => anthropicCurrent() && anthropicPoolState(config, instance) === poolState
|
|
395
419
|
&& getAccountSet(instance)?.activeAccountId === probedAccountId);
|
|
396
420
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Producer
|
|
1
|
+
/** Producer projections for measured advisory quota windows. */
|
|
2
2
|
import type { ProviderQuota } from "./quota-types";
|
|
3
3
|
import type { StoredAccountQuota } from "../codex/quota-types";
|
|
4
4
|
import { resetAtToMs } from "../codex/quota-types";
|
|
@@ -126,7 +126,10 @@ export function publishDecisionAccountQuota(provider: string, id: string, genera
|
|
|
126
126
|
if (roster?.root !== getConfigDir() || !roster.accounts.some(row => row.id === id && row.generation === generation)) return;
|
|
127
127
|
const key = accountKey(provider, id);
|
|
128
128
|
const previous = accounts.get(key);
|
|
129
|
-
|
|
129
|
+
// Anthropic monthly and included-plan windows come from mutually exclusive observations.
|
|
130
|
+
const monthlyFallback = provider === "anthropic" && windows.some(row => row.window === "monthly");
|
|
131
|
+
const retained = partial && !monthlyFallback && previous?.generation === generation ? previous.windows.filter(row =>
|
|
132
|
+
(provider !== "anthropic" || row.window !== "monthly") && !windows.some(next => row.window === next.window)) : [];
|
|
130
133
|
accounts.set(key, { generation, windows: copyWindows([...retained, ...windows]) });
|
|
131
134
|
}
|
|
132
135
|
/** Read a pool's already-loaded roster with generation-matched windows; undefined when nothing is loaded for the current config root. */
|
|
@@ -74,6 +74,8 @@ export interface ProviderQuotaCreditsUsd {
|
|
|
74
74
|
export interface ProviderQuota {
|
|
75
75
|
/** Display-only budget windows for which the upstream did not provide a usable entitlement. */
|
|
76
76
|
unknownBudgetWindows?: { label: string; resetAt?: number }[];
|
|
77
|
+
/** Claude CLI extra-usage entitlement/cap only; enabled does not prove wallet funds. */
|
|
78
|
+
claudeExtraUsage?: "enabled" | "disabled" | "exhausted";
|
|
77
79
|
/** Display-only subscription credits; not a routing or exhaustion window. */
|
|
78
80
|
workbuddyCredits?: import("./workbuddy-credit-balance").WorkBuddyCreditBalance;
|
|
79
81
|
fiveHourPercent?: number;
|
package/src/providers/quota.ts
CHANGED
|
@@ -48,9 +48,7 @@ import {
|
|
|
48
48
|
accountQuotaInflight,
|
|
49
49
|
explicitAccountEpoch,
|
|
50
50
|
explicitAccountReader,
|
|
51
|
-
explicitQuotaConfig,
|
|
52
|
-
explicitQuotaDestination,
|
|
53
|
-
explicitQuotaIdentity,
|
|
51
|
+
explicitQuotaConfig, explicitQuotaDestination, explicitQuotaIdentity, quotaCredentialIdentity,
|
|
54
52
|
accountQuotaProbeSkip, getTokenForAccountQuotaProbe,
|
|
55
53
|
hasPassiveAccountQuota,
|
|
56
54
|
hydrateAccountQuotaCache,
|
|
@@ -364,7 +362,7 @@ async function readExplicitAccountQuota(provider: string, accountId: string, con
|
|
|
364
362
|
const credential = getAccountCredential(provider, accountId);
|
|
365
363
|
if (!credential || credential.access !== accessToken) return null;
|
|
366
364
|
// Pair the post-renewal credential with the destination captured before renewal.
|
|
367
|
-
const identity =
|
|
365
|
+
const identity = quotaCredentialIdentity(provider, accountId, credential, config);
|
|
368
366
|
const isCurrent = () => epoch === explicitAccountEpoch
|
|
369
367
|
&& identity === explicitQuotaIdentity(provider, accountId, configured);
|
|
370
368
|
if (!isCurrent()) return null;
|
|
@@ -402,10 +400,12 @@ async function fetchExplicitAccountQuota(provider: string, accountId: string, fo
|
|
|
402
400
|
const current = epoch === explicitAccountEpoch && isCurrent();
|
|
403
401
|
const quota = current && result && typeof result !== "symbol" ? result.quota : null;
|
|
404
402
|
const empty = result === AUTHORITATIVE_EMPTY_QUOTA;
|
|
403
|
+
const retained = current && result !== TERMINAL_QUOTA_FAILURE && !empty
|
|
404
|
+
&& lastGood && Date.now() - lastGood.updatedAt < LAST_GOOD_MAX_AGE_MS ? lastGood : null;
|
|
405
405
|
const entry: AccountQuotaCacheEntry = {
|
|
406
406
|
ts: Date.now(),
|
|
407
|
-
quota: quota ??
|
|
408
|
-
|
|
407
|
+
quota: quota ?? retained,
|
|
408
|
+
quotaOwnerIsCurrent: quota ? isCurrent : retained ? cached?.quotaOwnerIsCurrent : undefined,
|
|
409
409
|
...(!current || (!quota && !empty) ? { unavailable: true as const } : {}),
|
|
410
410
|
identity: read?.identity ?? identity,
|
|
411
411
|
isCurrent: () => epoch === explicitAccountEpoch && isCurrent(),
|
|
@@ -472,6 +472,7 @@ async function fetchAccountQuota(
|
|
|
472
472
|
const entry: AccountQuotaCacheEntry = {
|
|
473
473
|
ts: Date.now(),
|
|
474
474
|
quota: cached?.quota ?? null,
|
|
475
|
+
quotaOwnerIsCurrent: cached?.quotaOwnerIsCurrent,
|
|
475
476
|
unavailable: true,
|
|
476
477
|
...(provider === "kiro" ? { identity: kiroIdentity } : {}),
|
|
477
478
|
...(provider === "google-antigravity" ? { isCurrent: antigravityIsCurrent } : {}),
|
|
@@ -513,7 +514,7 @@ async function fetchAccountQuota(
|
|
|
513
514
|
const entry: AccountQuotaCacheEntry = {
|
|
514
515
|
ts: Date.now(), quota,
|
|
515
516
|
...(provider === "kiro" ? { identity: kiroIdentity } : {}),
|
|
516
|
-
...(provider === "google-antigravity" ? { isCurrent: antigravityIsCurrent } : {}),
|
|
517
|
+
...(provider === "google-antigravity" ? { isCurrent: antigravityIsCurrent, quotaOwnerIsCurrent: antigravityIsCurrent } : {}),
|
|
517
518
|
};
|
|
518
519
|
if (mayCommitAccountQuotaKey(key, writerGeneration)
|
|
519
520
|
&& entry.isCurrent?.() !== false
|
|
@@ -24,6 +24,8 @@ import { cursorFastCapableBases } from "../../adapters/cursor/catalog";
|
|
|
24
24
|
import { COMMAND_CODE_MODEL_REASONING_EFFORTS } from "../command-code-efforts";
|
|
25
25
|
import { isCanonicalOpenRouterTarget } from "../openrouter-routing";
|
|
26
26
|
import type { ProviderRegistryEntry } from "./types";
|
|
27
|
+
import { M365_COPILOT_BASE_URL } from "../m365-copilot-models";
|
|
28
|
+
import { M365_COPILOT_WEB_URL } from "../m365-copilot-discovery";
|
|
27
29
|
import type { AnthropicInstanceId } from "../anthropic-instance-id";
|
|
28
30
|
import { ANTHROPIC_FAST_MODE_BETA } from "../anthropic-fast";
|
|
29
31
|
import {
|
|
@@ -177,6 +179,13 @@ function anthropicOAuthEntry(id: AnthropicInstanceId, label: string): ProviderRe
|
|
|
177
179
|
}
|
|
178
180
|
|
|
179
181
|
export const PROVIDER_REGISTRY_CORE: readonly ProviderRegistryEntry[] = [
|
|
182
|
+
{
|
|
183
|
+
id: "m365-copilot", label: "Microsoft 365 Copilot", adapter: "m365-copilot", baseUrl: M365_COPILOT_BASE_URL,
|
|
184
|
+
authKind: "oauth", featured: false, dashboardPreset: true, dashboardUrl: "https://copilot.cloud.microsoft/", liveModels: true,
|
|
185
|
+
models: [], defaultModel: "Magic", inputModalities: ["text", "image"],
|
|
186
|
+
modelDiscovery: { url: M365_COPILOT_WEB_URL, maxResponseBytes: 2 * 1024 * 1024, maxModels: 256 },
|
|
187
|
+
note: "Experimental unofficial Microsoft 365 Copilot ChatHub connector. Work/school accounts only. Sign-in uses Microsoft's M365 Chat Client in an isolated Chrome, Chromium or Edge window and captures the Copilot web session locally. Models are discovered from your account's live chat picker. Tools are prompt-emulated and executed by your client. No Copilot Studio agents are created.",
|
|
188
|
+
},
|
|
180
189
|
{
|
|
181
190
|
id: "openai",
|
|
182
191
|
label: "OpenAI (Codex login)",
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
} from "../codebuddy-models";
|
|
27
27
|
import { QODER_CN_MODELS, QODER_GLOBAL_MODELS, QODER_REASONING_EFFORTS } from "../qoder-models";
|
|
28
28
|
import type { ProviderRegistryEntry } from "./types";
|
|
29
|
+
import { AGY_ACP_DEFAULT_MODEL, AGY_ACP_SEED_MODELS } from "./agy-acp-models";
|
|
29
30
|
import {
|
|
30
31
|
ZAI_GLM_53_MODELS,
|
|
31
32
|
ZAI_GLM_5X_MODELS,
|
|
@@ -125,6 +126,9 @@ import {
|
|
|
125
126
|
MORPH_ULTRA_MODEL_INPUT_MODALITIES,
|
|
126
127
|
MORPH_ULTRA_REASONING_EFFORTS,
|
|
127
128
|
MORPH_ULTRA_REASONING_EFFORT_MAPS,
|
|
129
|
+
ABLITERATEDLLM_MODELS,
|
|
130
|
+
ABLITERATEDLLM_MODEL_CONTEXT_WINDOWS,
|
|
131
|
+
ABLITERATEDLLM_MODEL_INPUT_MODALITIES,
|
|
128
132
|
ANTHROPIC_MODELS,
|
|
129
133
|
ANTHROPIC_MODEL_CONTEXT_WINDOWS,
|
|
130
134
|
ANTHROPIC_MODEL_INPUT_MODALITIES,
|
|
@@ -1423,6 +1427,38 @@ export const PROVIDER_REGISTRY_EXTENDED: readonly ProviderRegistryEntry[] = [
|
|
|
1423
1427
|
modelReasoningEffortMap: { "deepseek-v4-1-flash": { ...deepseekReasoningMapFor("deepseek-v4-1-flash"), none: "none" } },
|
|
1424
1428
|
note: "Pay-per-token API gateway for open-weight models (DeepSeek, GLM, Kimi) and Grok, billed from a prepaid USD balance. Create an API key at console.cheapaimodel.ai. Live discovery lists the models your key can call; deepseek-v4-1-flash is the default. Chat Completions only.",
|
|
1425
1429
|
},
|
|
1430
|
+
{
|
|
1431
|
+
// AbliteratedLLM. Contract checked 2026-11-14: https://abliteratedllm.dev/docs/chat-completions
|
|
1432
|
+
// and https://abliteratedllm.dev/docs/models. GET /v1/models is public and answers 200 for any
|
|
1433
|
+
// Bearer value, so discovery needs no key but cannot verify one (GET /v1/balance is the
|
|
1434
|
+
// key-gated route). Chat Completions serves every catalog model, so every inbound stays on Chat;
|
|
1435
|
+
// the stateless Responses and the Anthropic Messages endpoints are not used. reasoning_effort is
|
|
1436
|
+
// documented as low, medium or high for every model, so higher Codex levels clamp to high.
|
|
1437
|
+
// glm-5.3-flash-abliterated lists 131,072 output tokens; every other row's output limit equals
|
|
1438
|
+
// its window. The env reference derived from the id is ${ABLITERATEDLLM_API_KEY}.
|
|
1439
|
+
// Routing checked 2026-11-15: GET /v1/models listed 15 models, glm-5.3-flash-abliterated
|
|
1440
|
+
// (variant "abliterated") and 14 with provider_label "Stock model". None carried "Official
|
|
1441
|
+
// DeepSeek API", the label https://abliteratedllm.dev/privacy uses for requests forwarded to
|
|
1442
|
+
// DeepSeek's own API; the listed models, the DeepSeek ones included, run on Fireworks AI with
|
|
1443
|
+
// zero data retention. The note states only that observation, not a retention promise for any
|
|
1444
|
+
// model the service lists later.
|
|
1445
|
+
id: "abliteratedllm",
|
|
1446
|
+
label: "AbliteratedLLM",
|
|
1447
|
+
adapter: "openai-chat",
|
|
1448
|
+
baseUrl: "https://api.abliteratedllm.dev/v1",
|
|
1449
|
+
authKind: "key",
|
|
1450
|
+
dashboardUrl: "https://abliteratedllm.dev/dashboard/keys",
|
|
1451
|
+
liveModels: false,
|
|
1452
|
+
apiKeyValidation: "unknown",
|
|
1453
|
+
preserveCustomDestination: true,
|
|
1454
|
+
defaultModel: "glm-5.3-flash-abliterated",
|
|
1455
|
+
models: ABLITERATEDLLM_MODELS,
|
|
1456
|
+
modelContextWindows: ABLITERATEDLLM_MODEL_CONTEXT_WINDOWS,
|
|
1457
|
+
modelMaxOutputTokens: { "glm-5.3-flash-abliterated": 131_072 },
|
|
1458
|
+
modelInputModalities: ABLITERATEDLLM_MODEL_INPUT_MODALITIES,
|
|
1459
|
+
reasoningEfforts: ["low", "medium", "high"],
|
|
1460
|
+
note: "Pay-per-token API for abliterated (refusal-removed) and stock open-weight models, prepaid in USD by card or crypto. Create an API key at abliteratedllm.dev/dashboard/keys. glm-5.3-flash-abliterated is the default. On 2026-11-15 the public model list showed 15 models: glm-5.3-flash-abliterated, the only abliterated one, and 14 labelled Stock model, the vendors' original weights. None was labelled Official DeepSeek API, the privacy policy's label for requests forwarded to DeepSeek's own API; the listed models, the DeepSeek ones included, run on Fireworks AI with zero data retention. The preset uses this seeded model list: the public model list answers without a key and cannot validate one, so live discovery is off. The preset sends every client through Chat Completions.",
|
|
1461
|
+
},
|
|
1426
1462
|
// Xiaomi retires mimo-v2.5 and mimo-v2.5-pro on 2026-10-21 with no redirect
|
|
1427
1463
|
// (https://mimo.mi.com/docs/en-US/updates/deprecate), so the first-party presets default to V2.6.
|
|
1428
1464
|
// Saved defaults are not rewritten; V2.5 stays listed until it stops answering.
|
|
@@ -1752,4 +1788,28 @@ export const PROVIDER_REGISTRY_EXTENDED: readonly ProviderRegistryEntry[] = [
|
|
|
1752
1788
|
defaultMaxOutputTokens: ANTHROPIC_DEFAULT_MAX_OUTPUT_TOKENS,
|
|
1753
1789
|
note: "Runs Claude subscription traffic through Anthropic's own harness: the official Claude Code CLI headlessly (`claude -p`), one turn per request. OpenCodex stores no Claude token and injects none into CLI requests (quota admission only reads it in memory) — the CLI signs in and bills the account itself, which is why this row is keyless and an API key saved here never reaches the harness (use `anthropic-apikey` for key billing). The sign-in is the one of the user this proxy runs as, so every request served through this row — by any client of this proxy — spends that same account; OpenCodex neither pools nor multiplexes Claude sign-ins. Requires the CLI (`npm i -g @anthropic-ai/claude-code`) and a signed-in session (`claude` -> /login). v1 disables CLI tools (--tools \"\", --strict-mcp-config) so the client retains tool ownership; text, reasoning and native image input are supported. Subscription routing authorization flagged for maintainer review.",
|
|
1754
1790
|
},
|
|
1791
|
+
{
|
|
1792
|
+
// The official Antigravity CLI over the Agent Client Protocol (`agy acp`), the owner-approved
|
|
1793
|
+
// alternative to credential replay (#8480, plan 080). Like claude-cli it is keyless rather than
|
|
1794
|
+
// `local`: traffic still reaches Google, through the CLI's own sign-in. One account (the CLI's),
|
|
1795
|
+
// no rotation, local requests only, Gemini only, interactive use only; config validation and
|
|
1796
|
+
// the adapter's policy gate enforce those. The existing google-antigravity provider is unchanged.
|
|
1797
|
+
id: "antigravity-acp",
|
|
1798
|
+
label: "Antigravity CLI (ACP, local)",
|
|
1799
|
+
adapter: "agy-acp",
|
|
1800
|
+
// Identity only: the transport is stdio and this URL is never fetched.
|
|
1801
|
+
baseUrl: "https://antigravity.google/docs/cli/acp",
|
|
1802
|
+
authKind: "key",
|
|
1803
|
+
keyOptional: true,
|
|
1804
|
+
dashboardUrl: "https://antigravity.google/docs/cli/acp",
|
|
1805
|
+
defaultModel: AGY_ACP_DEFAULT_MODEL,
|
|
1806
|
+
// Static seed; the ACP model options the CLI advertises at turn time decide what is accepted.
|
|
1807
|
+
models: [...AGY_ACP_SEED_MODELS],
|
|
1808
|
+
liveModels: false,
|
|
1809
|
+
modelContextWindows: { "gemini-3.8-flash": 1_048_576, "gemini-4-argon": 1_048_576, "gemini-3.7-flash": 1_048_576 },
|
|
1810
|
+
// ACP prompts carry text only; client function tools are not offered to the model.
|
|
1811
|
+
inputModalities: ["text"],
|
|
1812
|
+
reasoningEfforts: ["low", "medium", "high", "xhigh", "max"],
|
|
1813
|
+
note: "Drives the official Antigravity CLI (`agy acp`, 1.5.3 or newer) as a local child process over the Agent Client Protocol. The CLI owns its Google sign-in (`agy acp --login`); OpenCodex never reads or stores it, so no key or account belongs on this row. Google permits this only for interactive, user-directed use: OpenCodex refuses subagent, spawned-thread and Codex memory turns, combo members and decision calls, subagent-fallback routing and requests classified as remote from the observed connection. An undeclared loopback relay that forwards no recognized forwarding headers can appear local. On the public listener, declare a reverse proxy in dashboardTrustedProxy or keep this port out of the relay. OpenCodex serves Gemini models only. Use a Gemini API key or Vertex AI for programmatic or shared workloads. Each turn runs in an empty private workspace with `--sandbox`, every permission request is refused, and client tools are not offered; allow rules in your own agy settings still apply.",
|
|
1814
|
+
},
|
|
1755
1815
|
];
|
|
@@ -1298,3 +1298,54 @@ export const MORPH_ULTRA_REASONING_EFFORT_MAPS: Record<string, Record<string, st
|
|
|
1298
1298
|
"morph-kimik31": { none: "none" },
|
|
1299
1299
|
"morph-dsv41flash-1017": { none: "none", medium: "high" },
|
|
1300
1300
|
};
|
|
1301
|
+
|
|
1302
|
+
/*
|
|
1303
|
+
* AbliteratedLLM catalog as listed by the public GET https://api.abliteratedllm.dev/v1/models on
|
|
1304
|
+
* 2026-11-14 (https://abliteratedllm.dev/docs/models). glm-5.3-flash-abliterated is the service's
|
|
1305
|
+
* abliterated model and the default; every other row is a stock model (the vendor's original
|
|
1306
|
+
* weights). Windows are each row's `context_length`. Modalities are each row's `input_modalities`:
|
|
1307
|
+
* glm-5.3 and glm-5.3-fast are text only, and the gateway answers an image part sent to a model
|
|
1308
|
+
* that does not list images with 400 `unsupported_content`. glm-5.3-flash also lists video, which
|
|
1309
|
+
* the Codex catalog cannot carry, so it is seeded as text and image. The preset uses this seeded
|
|
1310
|
+
* list (liveModels: false): the public model list answers without a key and cannot validate one.
|
|
1311
|
+
*/
|
|
1312
|
+
export const ABLITERATEDLLM_MODELS = [
|
|
1313
|
+
"glm-5.3-flash-abliterated",
|
|
1314
|
+
"deepseek-v4.1-flash-1017",
|
|
1315
|
+
"deepseek-v4.1-flash-1017-ultrafast",
|
|
1316
|
+
"deepseek-v4.1-flash-original",
|
|
1317
|
+
"glm-5.3-flash",
|
|
1318
|
+
"glm-5.3",
|
|
1319
|
+
"glm-5.3-fast",
|
|
1320
|
+
"kimi-k3",
|
|
1321
|
+
"kimi-k3.1-pro",
|
|
1322
|
+
"kimi-k3-fast",
|
|
1323
|
+
"ember-1",
|
|
1324
|
+
"muse-spark-open",
|
|
1325
|
+
"qwen3.8-max",
|
|
1326
|
+
"qwen3.8-2.4t-a95b",
|
|
1327
|
+
"minimax-m3",
|
|
1328
|
+
];
|
|
1329
|
+
export const ABLITERATEDLLM_MODEL_CONTEXT_WINDOWS: Record<string, number> = {
|
|
1330
|
+
"glm-5.3-flash-abliterated": 1_048_576,
|
|
1331
|
+
"deepseek-v4.1-flash-1017": 1_048_576,
|
|
1332
|
+
"deepseek-v4.1-flash-1017-ultrafast": 1_048_576,
|
|
1333
|
+
"deepseek-v4.1-flash-original": 1_048_576,
|
|
1334
|
+
"glm-5.3-flash": 1_048_576,
|
|
1335
|
+
"glm-5.3": 1_048_576,
|
|
1336
|
+
"glm-5.3-fast": 1_048_576,
|
|
1337
|
+
"kimi-k3": 1_048_576,
|
|
1338
|
+
"kimi-k3.1-pro": 1_048_576,
|
|
1339
|
+
"kimi-k3-fast": 1_048_576,
|
|
1340
|
+
"ember-1": 1_048_576,
|
|
1341
|
+
"muse-spark-open": 1_048_576,
|
|
1342
|
+
"qwen3.8-max": 262_144,
|
|
1343
|
+
"qwen3.8-2.4t-a95b": 262_144,
|
|
1344
|
+
"minimax-m3": 512_000,
|
|
1345
|
+
};
|
|
1346
|
+
const ABLITERATEDLLM_TEXT_ONLY_MODELS = ["glm-5.3", "glm-5.3-fast"];
|
|
1347
|
+
export const ABLITERATEDLLM_MODEL_INPUT_MODALITIES: Record<string, string[]> = Object.fromEntries(
|
|
1348
|
+
ABLITERATEDLLM_MODELS.map(id => [
|
|
1349
|
+
id, ABLITERATEDLLM_TEXT_ONLY_MODELS.includes(id) ? ["text"] : ["text", "image"],
|
|
1350
|
+
]),
|
|
1351
|
+
);
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { OcxProviderConfig, RequestPacingRule } from "../types";
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
3
|
import type { GenerationContext } from "../lib/state-store-sweeper";
|
|
4
|
-
import { carryReplayRefusal, isNonReplayableResponse, markResponseNonReplayable } from "../lib/upstream-retry";
|
|
4
|
+
import { carryReplayRefusal, isNonReplayableResponse, markResponseNonReplayable, registerPacedRetryResponse } from "../lib/upstream-retry";
|
|
5
|
+
import { clearableDeadline } from "../lib/abort";
|
|
6
|
+
import { BOUNDED_BODY_MAX_BYTES, BOUNDED_BODY_TIMEOUT_MS, readBoundedResponseBytes } from "../lib/bounded-body";
|
|
5
7
|
import { redactSecretString } from "../lib/redact";
|
|
6
8
|
import { errorDestinationText, providerErrorDestinationLabel } from "../lib/error-destination";
|
|
7
9
|
|
|
@@ -507,6 +509,17 @@ export async function waitForProviderRequestSlot(
|
|
|
507
509
|
});
|
|
508
510
|
}
|
|
509
511
|
|
|
512
|
+
async function readPacedRetryErrorBytes(response: Response, signal?: AbortSignal): Promise<Uint8Array<ArrayBuffer>> {
|
|
513
|
+
const deadline = clearableDeadline(BOUNDED_BODY_TIMEOUT_MS, signal);
|
|
514
|
+
try {
|
|
515
|
+
const result = await readBoundedResponseBytes(response, { signal: deadline.signal, maxBytes: BOUNDED_BODY_MAX_BYTES });
|
|
516
|
+
if (result.oversized) throw new DOMException("Response body size limit reached", "QuotaExceededError");
|
|
517
|
+
return result.bytes;
|
|
518
|
+
} finally {
|
|
519
|
+
deadline.clear();
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
|
|
510
523
|
/**
|
|
511
524
|
* Tie a pacing slot lease to an upstream response body: the lease is released when the
|
|
512
525
|
* body completes, errors, or is cancelled by the consumer. A null body (204/304/HEAD)
|
|
@@ -641,11 +654,28 @@ export function trackProviderRequestSlotBody(
|
|
|
641
654
|
}
|
|
642
655
|
// Retry helpers mark the response they return from, and recovery decisions key on these
|
|
643
656
|
// identity markers; the rewrap must not make a non-replayable response look replayable.
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
657
|
+
const carryMarkers = (source: Response, target: Response): Response => {
|
|
658
|
+
if (isNonReplayableResponse(source)) markResponseNonReplayable(target);
|
|
659
|
+
for (const markers of responseProvenance) {
|
|
660
|
+
if (markers.has(source)) markers.set(target, markers.get(source));
|
|
661
|
+
}
|
|
662
|
+
return carryReplayRefusal(source, target);
|
|
663
|
+
};
|
|
664
|
+
registerPacedRetryResponse(wrapped, async (signal, readBody = readPacedRetryErrorBytes) => {
|
|
665
|
+
let body: BodyInit;
|
|
666
|
+
try {
|
|
667
|
+
body = await readBody(wrapped, signal);
|
|
668
|
+
} catch (error) {
|
|
669
|
+
// The receiver applies its normal read-failure policy if the retry cannot send.
|
|
670
|
+
// Keep the upstream status and markers available to the recovery and accounting paths.
|
|
671
|
+
body = new ReadableStream<Uint8Array>({ start: controller => controller.error(error) });
|
|
672
|
+
}
|
|
673
|
+
const headers = new Headers(wrapped.headers);
|
|
674
|
+
headers.delete("content-length");
|
|
675
|
+
headers.delete("content-encoding");
|
|
676
|
+
return carryMarkers(wrapped, new Response(body, { status: wrapped.status, statusText: wrapped.statusText, headers }));
|
|
677
|
+
});
|
|
678
|
+
return carryMarkers(response, wrapped);
|
|
649
679
|
}
|
|
650
680
|
|
|
651
681
|
/**
|
|
@@ -654,7 +684,7 @@ export function trackProviderRequestSlotBody(
|
|
|
654
684
|
* and a no-op for interval-only slots, so every boundary can call it unconditionally.
|
|
655
685
|
*/
|
|
656
686
|
export function releaseProviderRequestSlot(slot: ProviderRequestSlot | undefined): void {
|
|
657
|
-
if (!slot || slot.bodyTracked) return;
|
|
687
|
+
if (!slot || slot.bodyTracked || slot.released) return;
|
|
658
688
|
slot.release();
|
|
659
689
|
}
|
|
660
690
|
|
|
@@ -195,11 +195,13 @@ export function fastPolicyForModel(
|
|
|
195
195
|
providerName?: string,
|
|
196
196
|
inbound: InboundWire = "responses",
|
|
197
197
|
capabilityProvider?: ServiceTierCapabilityProvider,
|
|
198
|
+
effectiveAdapter?: string,
|
|
198
199
|
): ResolvedFastPolicy {
|
|
199
200
|
return resolveFastPolicy(
|
|
200
201
|
authorityForProvider(provider, providerName, capabilityProvider),
|
|
201
202
|
modelId,
|
|
202
203
|
inbound,
|
|
204
|
+
effectiveAdapter,
|
|
203
205
|
);
|
|
204
206
|
}
|
|
205
207
|
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { BOUNDED_BODY_MAX_BYTES, readBoundedResponseBody } from "../lib/bounded-body";
|
|
2
|
+
import { markProxyError } from "../lib/client-error-body";
|
|
3
|
+
import type { OcxProviderConfig } from "../types";
|
|
4
|
+
import type { RequestFailureCause } from "../usage/telemetry-contract";
|
|
5
|
+
|
|
6
|
+
const LEGACY_PRIVACY_MARKER = "[WKE=privacy-mode:legacy]";
|
|
7
|
+
const MAX_PROBE_ERROR_BYTES = 16_384;
|
|
8
|
+
export const XAI_LEGACY_PRIVACY_MESSAGE = "The xAI account uses Legacy (no storage), which blocks Grok Build. Switch the xAI account to Privacy Mode in the xAI/Grok privacy settings, then retry.";
|
|
9
|
+
|
|
10
|
+
export function isXaiGrokOAuth(providerName: string, provider: Pick<OcxProviderConfig, "authMode">): boolean {
|
|
11
|
+
return providerName === "xai" && provider.authMode === "oauth";
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Callers must have a bounded error body from the Grok OAuth endpoint. */
|
|
15
|
+
export function isXaiLegacyPrivacyError(status: number, text: string): boolean {
|
|
16
|
+
if (status !== 403 || text.length > BOUNDED_BODY_MAX_BYTES) return false;
|
|
17
|
+
try {
|
|
18
|
+
const payload = JSON.parse(text) as { error?: string | { message?: unknown } } | null;
|
|
19
|
+
const error = payload?.error;
|
|
20
|
+
const message = typeof error === "string" ? error : error?.message;
|
|
21
|
+
return typeof message === "string" && message.includes(LEGACY_PRIVACY_MARKER);
|
|
22
|
+
} catch {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Consume a Grok OAuth 403 probe body. Missing, oversized and incomplete bodies keep the generic result. */
|
|
28
|
+
export async function readXaiLegacyPrivacyError(response: Response): Promise<boolean> {
|
|
29
|
+
if (response.status !== 403) return false;
|
|
30
|
+
try {
|
|
31
|
+
const body = await readBoundedResponseBody(response, { maxBytes: MAX_PROBE_ERROR_BYTES, fatalUtf8: true });
|
|
32
|
+
return body.displaySafe && !body.truncated && isXaiLegacyPrivacyError(response.status, body.text);
|
|
33
|
+
} catch {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const privacyRefusals = new WeakSet<Response>();
|
|
39
|
+
|
|
40
|
+
/** The 403 expresses the provider's account policy and carries no credential-recovery signal. */
|
|
41
|
+
export function xaiPrivacyModeRefusal(logCtx?: { causeHint?: RequestFailureCause }): Response {
|
|
42
|
+
if (logCtx) logCtx.causeHint = "policy-refusal";
|
|
43
|
+
const response = Response.json({
|
|
44
|
+
error: { message: XAI_LEGACY_PRIVACY_MESSAGE, type: "permission_error", param: null, code: "permission_denied" },
|
|
45
|
+
}, { status: 403 });
|
|
46
|
+
privacyRefusals.add(response);
|
|
47
|
+
return markProxyError(response);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function isXaiPrivacyModeRefusal(response: Response): boolean {
|
|
51
|
+
return privacyRefusals.has(response);
|
|
52
|
+
}
|