@bitkyc08/opencodex 2.100.5 → 2.100.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/ocx.mjs +2 -0
- package/gui/dist/assets/App-BI8LQ7Qk.css +1 -0
- package/gui/dist/assets/App-CsZ1Gr7S.js +60 -0
- package/gui/dist/assets/Tray-CVqm4S4W.js +1 -0
- package/gui/dist/assets/brand-mark-BebhnAtV.js +1 -0
- package/gui/dist/assets/index-BtwVlpeQ.css +2 -0
- package/gui/dist/assets/index-CEeMegqE.js +138 -0
- package/gui/dist/assets/{segment-thumb-features-Bquysdn5.js → segment-thumb-features-COdzmORE.js} +1 -1
- package/gui/dist/classic/assets/App-BJgUWNJ8.js +59 -0
- package/gui/dist/classic/assets/App-CoiVLRW3.css +1 -0
- package/gui/dist/classic/assets/Tray-BDlcOLDK.js +1 -0
- package/gui/dist/classic/assets/index-B9Jgli_W.js +138 -0
- package/gui/dist/classic/assets/usage-companion-chart-vbzDcND0.js +1 -0
- package/gui/dist/classic/index.html +1 -1
- package/gui/dist/index.html +2 -2
- package/native/ocx-child/Cargo.lock +62 -0
- package/native/ocx-child/Cargo.toml +1 -0
- package/native/ocx-child/src/journal.rs +32 -10
- package/native/ocx-child/src/state.rs +2 -1
- package/native/ocx-child/src/toml_surgeon.rs +183 -72
- package/package.json +2 -2
- package/src/adapters/agy-acp/acp.ts +202 -0
- package/src/adapters/agy-acp/adapter.ts +554 -0
- package/src/adapters/agy-acp/binary.ts +79 -0
- package/src/adapters/agy-acp/options.ts +163 -0
- package/src/adapters/agy-acp/output-redaction.ts +270 -0
- package/src/adapters/agy-acp/policy.ts +105 -0
- package/src/adapters/agy-acp/process.ts +218 -0
- package/src/adapters/anthropic/account-metadata.ts +4 -1
- package/src/adapters/anthropic/advisor-tool.ts +43 -9
- package/src/adapters/anthropic/client-identity.ts +2 -0
- package/src/adapters/anthropic.ts +102 -14
- package/src/adapters/antigravity-refusal.ts +5 -1
- package/src/adapters/base.ts +25 -2
- package/src/adapters/claude-cli/adapter.ts +1 -0
- package/src/adapters/claude-cli/usage-admission.ts +12 -9
- package/src/adapters/codebuddy/adapter.ts +1 -0
- package/src/adapters/command-code.ts +2 -2
- package/src/adapters/cursor/http1-bidi.ts +7 -2
- package/src/adapters/cursor/live-transport.ts +2 -0
- package/src/adapters/cursor/request-builder.ts +4 -4
- package/src/adapters/cursor/tool-naming.ts +5 -5
- package/src/adapters/cursor/transport-retry.ts +14 -8
- package/src/adapters/cursor/transport.ts +2 -0
- package/src/adapters/cursor.ts +8 -2
- package/src/adapters/google-error-details.ts +105 -0
- package/src/adapters/google-errors.ts +183 -31
- package/src/adapters/google-http.ts +66 -22
- package/src/adapters/google-truncation.ts +48 -3
- package/src/adapters/google-vertex-endpoint.ts +12 -1
- package/src/adapters/google.ts +54 -26
- package/src/adapters/kiro/adapter.ts +39 -38
- package/src/adapters/kiro/stream.ts +59 -9
- package/src/adapters/kiro-retry.ts +5 -3
- package/src/adapters/m365-copilot/LICENSE +21 -0
- package/src/adapters/m365-copilot/fenced.ts +745 -0
- package/src/adapters/m365-copilot/images.ts +89 -0
- package/src/adapters/m365-copilot/tools.ts +284 -0
- package/src/adapters/m365-copilot/transport.ts +232 -0
- package/src/adapters/m365-copilot.ts +143 -0
- package/src/adapters/openai-chat/tool-schema.ts +2 -2
- package/src/adapters/openai-responses/passthrough.ts +1 -0
- package/src/adapters/openai-responses/reasoning.ts +23 -3
- package/src/adapters/physical-send.ts +11 -4
- package/src/adapters/qoder/adapter.ts +17 -3
- package/src/adapters/registry.ts +15 -1
- package/src/adapters/zed.ts +2 -1
- package/src/advisor/consult.ts +1 -0
- package/src/bridge/response-json.ts +6 -2
- package/src/bridge/sse.ts +21 -9
- package/src/chat/inbound.ts +11 -8
- package/src/chat/outbound.ts +28 -7
- package/src/claude/context-windows.ts +32 -8
- package/src/claude/desktop-3p.ts +18 -14
- package/src/claude/desktop-picker-platform.ts +1 -1
- package/src/claude/desktop-picker.ts +3 -3
- package/src/claude/inbound-content-options.ts +11 -1
- package/src/claude/intercept/picker-ca-cleanup.ts +17 -5
- package/src/claude/intercept/picker-ca.ts +162 -27
- package/src/claude/intercept/picker-trust-linux.ts +411 -0
- package/src/claude/intercept/picker-trust.ts +35 -3
- package/src/claude/intercept/runtime.ts +2 -2
- package/src/claude/subagent-force-status.ts +24 -5
- package/src/claude/subscription-reserve.ts +87 -0
- package/src/cli/account-api.ts +3 -0
- package/src/cli/account-auth.ts +65 -11
- package/src/cli/account-extended.ts +1 -1
- package/src/cli/account-next-actions.ts +4 -1
- package/src/cli/account-policy-dto.ts +1 -1
- package/src/cli/account-policy.ts +6 -3
- package/src/cli/account-probe.ts +66 -0
- package/src/cli/account.ts +8 -2
- package/src/cli/capabilities-accounts.ts +8 -1
- package/src/cli/capabilities-agents-routing.ts +2 -2
- package/src/cli/capabilities-base.ts +4 -4
- package/src/cli/capabilities-integrations.ts +44 -4
- package/src/cli/capabilities-provider-models.ts +6 -0
- package/src/cli/claude-context-settings.ts +60 -0
- package/src/cli/claude-desktop.ts +2 -2
- package/src/cli/claude.ts +15 -7
- package/src/cli/client-start-fence.ts +64 -1
- package/src/cli/combo-result.ts +1 -0
- package/src/cli/combo-stats.ts +1 -1
- package/src/cli/combo.ts +19 -2
- package/src/cli/config-command.ts +21 -8
- package/src/cli/connect.ts +16 -0
- package/src/cli/cross-home-owner.ts +65 -18
- package/src/cli/dispatch.ts +4 -0
- package/src/cli/gateway-client-command.ts +128 -0
- package/src/cli/index.ts +98 -97
- package/src/cli/init.ts +20 -4
- package/src/cli/integrations.ts +23 -3
- package/src/cli/launcher-context.ts +12 -1
- package/src/cli/link.ts +24 -5
- package/src/cli/models-runtime-subcommands.ts +1 -0
- package/src/cli/models-runtime.ts +32 -0
- package/src/cli/start-owner-fence.ts +5 -2
- package/src/cli/status.ts +3 -3
- package/src/cli/stop-client-process.ts +51 -0
- package/src/cli/stop-restore.ts +383 -36
- package/src/cli/sync-command.ts +2 -2
- package/src/cli/uninstall-client-state.ts +7 -0
- package/src/client/connect.ts +72 -13
- package/src/client/hub-client.ts +38 -0
- package/src/client/hub-relay.ts +61 -36
- package/src/client/hub-session.ts +106 -0
- package/src/client/lifecycle-lock.ts +6 -1
- package/src/client/link-relay.ts +2 -1
- package/src/client/machine-listener.ts +60 -1
- package/src/client/runtime-restart.ts +1 -0
- package/src/client/runtime.ts +104 -34
- package/src/client/state.ts +11 -0
- package/src/client/stop-darwin-process.ts +73 -0
- package/src/client/stop-file-routing.ts +49 -0
- package/src/client/stop-native-handoff.ts +108 -0
- package/src/client/stop-routing.ts +41 -7
- package/src/client/stop-teardown-owner.ts +173 -0
- package/src/client/sync-runtime.ts +23 -4
- package/src/clients/config-export/opencode-wire.ts +24 -0
- package/src/clients/config-export.ts +28 -19
- package/src/codex/auth-api/login-flow.ts +68 -33
- package/src/codex/auth-api/main-account-probe.ts +3 -3
- package/src/codex/auth-api/pool-quota-probe.ts +8 -7
- package/src/codex/auth-api/routes.ts +1 -1
- package/src/codex/catalog/aggregation.ts +22 -10
- package/src/codex/catalog/gather-capture.ts +11 -2
- package/src/codex/catalog/m365-copilot-models.ts +52 -0
- package/src/codex/catalog/provider-models.ts +126 -53
- package/src/codex/catalog/routed-gather.ts +26 -12
- package/src/codex/catalog-admission.ts +4 -6
- package/src/codex/catalog-auto-refresh.ts +4 -2
- package/src/codex/catalog-self-heal.ts +4 -2
- package/src/codex/control-plane-models.ts +6 -0
- package/src/codex/convergence.ts +10 -0
- package/src/codex/desktop-app/picker-freshness.ts +3 -14
- package/src/codex/desktop-app/types.ts +6 -0
- package/src/codex/desktop-app/windows-command-payload.ts +9 -0
- package/src/codex/desktop-app/windows.ts +20 -12
- package/src/codex/desktop-compatibility/installed-build.ts +61 -58
- package/src/codex/desktop-compatibility/runtime-ownership.ts +11 -5
- package/src/codex/desktop-compatibility/runtime.ts +51 -14
- package/src/codex/desktop-compatibility/windows-activation-source.ts +28 -13
- package/src/codex/desktop-compatibility/windows-package-command.ts +73 -33
- package/src/codex/desktop-compatibility/windows-package-launch.ts +41 -9
- package/src/codex/desktop-compatibility/windows-package-proof.ts +104 -0
- package/src/codex/inject/config-toml.ts +67 -73
- package/src/codex/inject/plan.ts +11 -10
- package/src/codex/inject/remove.ts +4 -1
- package/src/codex/inject.ts +1 -0
- package/src/codex/journal-config-restore.ts +31 -4
- package/src/codex/journal.ts +16 -4
- package/src/codex/model-cache.ts +98 -27
- package/src/codex/native-residue.ts +14 -13
- package/src/codex/paths.ts +65 -28
- package/src/codex/quota-observation-freshness.ts +4 -0
- package/src/codex/quota.ts +71 -8
- package/src/codex/routing/selection.ts +32 -8
- package/src/combos/capability-policy.ts +31 -0
- package/src/combos/failover.ts +82 -74
- package/src/combos/identifiers.ts +2 -2
- package/src/combos/index.ts +3 -0
- package/src/combos/jev-model-backend.ts +12 -4
- package/src/combos/jev-session-pin-config.ts +22 -9
- package/src/combos/jev.ts +15 -4
- package/src/combos/request-capability.ts +214 -0
- package/src/combos/request.ts +22 -15
- package/src/combos/resolve.ts +5 -2
- package/src/combos/suggestion-channel.ts +89 -0
- package/src/combos/types.ts +14 -1
- package/src/config/account-auto-pause-revisions.ts +33 -10
- package/src/config/atomic-write.ts +1 -1
- package/src/config/codex-ws-incremental-setting.ts +34 -0
- package/src/config/diagnostics.ts +47 -8
- package/src/config/live-topology.ts +4 -2
- package/src/config/load-degrade.ts +96 -2
- package/src/config/mutation-lock.ts +7 -3
- package/src/config/paths.ts +3 -0
- package/src/config/pending-teardown.ts +19 -3
- package/src/config/process-state.ts +30 -12
- package/src/config/provider-validation.ts +10 -0
- package/src/config/salvage.ts +2 -2
- package/src/config/schema/account-auto-pause.ts +15 -1
- package/src/config/schema/agy-acp-references.ts +257 -0
- package/src/config/schema/config-schema.ts +32 -0
- package/src/config/schema/leaf-validators.ts +42 -0
- package/src/config/schema/subscription-reserve.ts +33 -0
- package/src/config/windows-process-command-line.ts +27 -9
- package/src/config.ts +6 -0
- package/src/generated/compatibility-version.json +806 -402
- package/src/images/loop.ts +79 -39
- package/src/integrations/catalog-refresh.ts +19 -1
- package/src/integrations/gateway-clients/agy.ts +340 -0
- package/src/integrations/gateway-clients/antigravity.ts +224 -0
- package/src/integrations/gateway-clients/index.ts +89 -0
- package/src/integrations/gateway-clients/io.ts +278 -0
- package/src/integrations/gateway-clients/types.ts +80 -0
- package/src/integrations/route-intent-disconnect.ts +37 -21
- package/src/lib/app-owned-memory-stores.ts +9 -0
- package/src/lib/cloud-code-appeal-link.ts +30 -0
- package/src/lib/errors.ts +32 -0
- package/src/lib/executor-physical-send-receipt.ts +42 -0
- package/src/lib/failure-detail.ts +1 -0
- package/src/lib/gcp-adc.ts +5 -0
- package/src/lib/http-date.ts +91 -0
- package/src/lib/lab-passive-linker-registration.ts +2 -1
- package/src/lib/local-chat-completion.ts +13 -3
- package/src/lib/local-internal-call-capability.ts +1 -3
- package/src/lib/messages-error-body.ts +2 -1
- package/src/lib/outbound-credential-registry.ts +40 -4
- package/src/lib/pinned-http.ts +7 -2
- package/src/lib/process-control.ts +1 -0
- package/src/lib/provider-egress.ts +16 -0
- package/src/lib/provider-outbound.ts +3 -0
- package/src/lib/redact-folding.ts +12 -3
- package/src/lib/redact.ts +37 -19
- package/src/lib/request-execution-budget.ts +241 -32
- package/src/lib/request-peer-scope.ts +64 -0
- package/src/lib/response-send-readings.ts +41 -0
- package/src/lib/state-store-registrations.ts +5 -0
- package/src/lib/tool-envelope-echo-filter.ts +33 -5
- package/src/lib/upstream-condition.ts +10 -3
- package/src/lib/upstream-retry.ts +95 -20
- package/src/lib/windows-secret-acl.ts +24 -7
- package/src/link/child-activity.ts +60 -4
- package/src/link/codex-settings.ts +2 -1
- package/src/link/relay-auth.ts +1 -0
- package/src/link/route-rounds.ts +32 -9
- package/src/link/status-projection.ts +42 -5
- package/src/link/supervisor.ts +96 -11
- package/src/link/tunnel-history.ts +5 -0
- package/src/oauth/account-auto-pause-policy.ts +72 -19
- package/src/oauth/account-auto-pause.ts +40 -16
- package/src/oauth/anthropic-account-refusal.ts +7 -0
- package/src/oauth/anthropic-continuity.ts +70 -9
- package/src/oauth/anthropic-identity.ts +75 -11
- package/src/oauth/anthropic-login-slot.ts +258 -0
- package/src/oauth/anthropic-routing.ts +24 -9
- package/src/oauth/anthropic-send-ownership.ts +4 -3
- package/src/oauth/anthropic.ts +30 -11
- package/src/oauth/health.ts +7 -2
- package/src/oauth/index.ts +50 -48
- package/src/oauth/key-providers.ts +2 -0
- package/src/oauth/login-cli.ts +11 -0
- package/src/oauth/login-flow-state.ts +10 -4
- package/src/oauth/m365-copilot-browser.ts +222 -0
- package/src/oauth/m365-copilot-web-session.ts +25 -0
- package/src/oauth/m365-copilot.ts +57 -0
- package/src/oauth/model-discovery-auth.ts +5 -0
- package/src/oauth/plan.ts +44 -0
- package/src/oauth/pool-kernel.ts +22 -8
- package/src/oauth/pool-settings-capability.ts +14 -3
- package/src/oauth/reauth-precheck.ts +27 -0
- package/src/oauth/store-anthropic-instance.ts +3 -1
- package/src/oauth/store.ts +121 -23
- package/src/oauth/types.ts +27 -2
- package/src/protocols/codecs/chat-ir.ts +7 -4
- package/src/protocols/codecs/gemini-interactions.ts +770 -0
- package/src/protocols/codecs/gemini.ts +470 -0
- package/src/protocols/contract.ts +2 -0
- package/src/protocols/encoders/adapter-events.ts +5 -3
- package/src/protocols/encoders/chat.ts +23 -7
- package/src/protocols/settings.ts +3 -0
- package/src/providers/account-quota-disk.ts +26 -8
- package/src/providers/api-key-pause.ts +2 -2
- package/src/providers/api-key-response-ownership.ts +14 -4
- package/src/providers/claude-cli-usage-state.ts +1 -0
- package/src/providers/claude-cli-usage.ts +24 -7
- package/src/providers/default-aliases.ts +11 -5
- package/src/providers/derive.ts +5 -1
- package/src/providers/fastwire.ts +6 -5
- package/src/providers/free-directory.ts +2 -2
- package/src/providers/google-vertex-location.ts +2 -1
- package/src/providers/google-vertex-model-discovery.ts +22 -0
- package/src/providers/key-failover.ts +18 -23
- package/src/providers/m365-copilot-discovery-fetch.ts +17 -0
- package/src/providers/m365-copilot-discovery.ts +68 -0
- package/src/providers/m365-copilot-models.ts +32 -0
- package/src/providers/model-rename-fields.ts +6 -0
- package/src/providers/new-model-policy-runtime.ts +27 -6
- package/src/providers/openai-forward-destination.ts +19 -0
- package/src/providers/openai-tiers-destination.ts +3 -19
- package/src/providers/quota/account-cache.ts +183 -27
- package/src/providers/quota/anthropic-account-quota.ts +21 -17
- package/src/providers/quota/anthropic-cooldown-recovery.ts +57 -27
- package/src/providers/quota/anthropic-decision-windows.ts +7 -3
- package/src/providers/quota/anthropic-usage-windows.ts +34 -4
- package/src/providers/quota/antigravity-account-probe.ts +165 -0
- package/src/providers/quota/antigravity.ts +71 -3
- package/src/providers/quota/vendor-probes-oauth.ts +52 -28
- package/src/providers/quota-decision-publication.ts +1 -1
- package/src/providers/quota-decision-snapshot.ts +4 -1
- package/src/providers/quota-types.ts +2 -0
- package/src/providers/quota.ts +8 -7
- package/src/providers/registry/agy-acp-models.ts +3 -0
- package/src/providers/registry/entries-core.ts +9 -0
- package/src/providers/registry/entries-extended.ts +60 -0
- package/src/providers/registry/model-seeds.ts +51 -0
- package/src/providers/request-pacing.ts +37 -7
- package/src/providers/service-tier.ts +2 -0
- package/src/providers/xai-privacy-mode.ts +52 -0
- package/src/remote/hub-management-relay.ts +74 -0
- package/src/responses/id-limits.ts +2 -0
- package/src/responses/input-media.ts +15 -3
- package/src/responses/parser-tools.ts +74 -11
- package/src/responses/parser.ts +16 -14
- package/src/responses/provider-opaque-metadata.ts +10 -0
- package/src/responses/reasoning-envelope.ts +3 -0
- package/src/responses/schema.ts +2 -3
- package/src/responses/spill-store.ts +5 -3
- package/src/responses/state/connection-scope.ts +232 -0
- package/src/responses/state/entry-types.ts +47 -0
- package/src/responses/state/snapshot-codec.ts +75 -14
- package/src/responses/state/snapshot-select.ts +2 -0
- package/src/responses/state/spill-codec.ts +59 -0
- package/src/responses/state/spill-queue.ts +11 -2
- package/src/responses/state.ts +178 -159
- package/src/router.ts +2 -6
- package/src/routing/compatibility/behavior.ts +6 -2
- package/src/routing/compatibility/subject.ts +17 -12
- package/src/routing/machine-weighted-routing.ts +58 -0
- package/src/server/advisor-admission-scope.ts +15 -7
- package/src/server/auth-cors.ts +27 -0
- package/src/server/chat-completions.ts +37 -17
- package/src/server/chat-native-eligibility.ts +21 -0
- package/src/server/chat-native.ts +15 -6
- package/src/server/claude-messages.ts +54 -6
- package/src/server/credential-recovery-attempt.ts +32 -0
- package/src/server/effort-policy.ts +6 -3
- package/src/server/gemini-inbound.ts +267 -0
- package/src/server/gemini-interactions-inbound.ts +229 -0
- package/src/server/gemini-interactions-store.ts +129 -0
- package/src/server/gemini-native-catalog.ts +64 -0
- package/src/server/gemini-native-log.ts +33 -0
- package/src/server/gemini-native-paths.ts +88 -0
- package/src/server/gemini-native-wire.ts +201 -0
- package/src/server/gemini-native.ts +218 -0
- package/src/server/grok-upstream-envelope-echo.ts +8 -2
- package/src/server/hub-relay-auth.ts +87 -0
- package/src/server/hub-usage-windows.ts +135 -0
- package/src/server/hub-usage.ts +16 -3
- package/src/server/inbound-body-admission.ts +2 -1
- package/src/server/index/anthropic-model-listing.ts +75 -0
- package/src/server/index/gemini-routes.ts +147 -0
- package/src/server/index/link-management.ts +3 -22
- package/src/server/index/link-relay-sessions.ts +71 -13
- package/src/server/index/link-websocket.ts +2 -0
- package/src/server/index/passive-management-read.ts +55 -0
- package/src/server/index/serve-options.ts +93 -107
- package/src/server/index/websocket-handler.ts +15 -2
- package/src/server/index.ts +10 -0
- package/src/server/inference/client-encoder-delivery.ts +2 -1
- package/src/server/inference/context.ts +33 -6
- package/src/server/management/agent-settings-routes.ts +33 -16
- package/src/server/management/claude-code-settings-patch.ts +6 -0
- package/src/server/management/combo-routes.ts +21 -1
- package/src/server/management/combo-suggestion-routes.ts +212 -0
- package/src/server/management/config-routes.ts +12 -4
- package/src/server/management/context.ts +2 -0
- package/src/server/management/gateway-client-routes.ts +62 -0
- package/src/server/management/integration-routes.ts +5 -0
- package/src/server/management/link-routes.ts +5 -1
- package/src/server/management/m365-copilot-provider-probe.ts +23 -0
- package/src/server/management/model-routes.ts +32 -2
- package/src/server/management/model-rows.ts +36 -3
- package/src/server/management/oauth-account-routes.ts +68 -15
- package/src/server/management/protocol-settings-patch.ts +1 -0
- package/src/server/management/provider-omitted-fields.ts +25 -0
- package/src/server/management/provider-overwrite-carry.ts +33 -8
- package/src/server/management/provider-routes.ts +10 -16
- package/src/server/management/request-history-routes.ts +2 -2
- package/src/server/management/route-registry.ts +10 -0
- package/src/server/management/shared.ts +118 -30
- package/src/server/management/sibling-guard.ts +2 -1
- package/src/server/management/system-routes.ts +6 -0
- package/src/server/management-auth.ts +8 -1
- package/src/server/messages-native-scope.ts +19 -0
- package/src/server/messages-native.ts +156 -59
- package/src/server/messages-shared.ts +6 -0
- package/src/server/models-capabilities.ts +24 -0
- package/src/server/native-chat-bridge.ts +259 -0
- package/src/server/ollama-inbound.ts +36 -184
- package/src/server/passive-route-linker.ts +3 -1
- package/src/server/port-reclaim.ts +48 -4
- package/src/server/proxy-liveness.ts +79 -22
- package/src/server/relay.ts +16 -9
- package/src/server/request-log-account-rotation.ts +2 -1
- package/src/server/request-log-attempt-recovery.ts +24 -2
- package/src/server/request-log-attempt-usage.ts +5 -4
- package/src/server/request-log-committed-terminal.ts +87 -0
- package/src/server/request-log-failure-attribution.ts +3 -3
- package/src/server/request-log-failure-detail.ts +34 -0
- package/src/server/request-log-key-failure.ts +27 -0
- package/src/server/request-log-terminal-status.ts +25 -12
- package/src/server/request-log.ts +59 -63
- package/src/server/responses/adapter-continuation.ts +77 -44
- package/src/server/responses/adapter-delivery.ts +47 -22
- package/src/server/responses/adapter-dispatch.ts +150 -149
- package/src/server/responses/advisor-retention.ts +12 -4
- package/src/server/responses/advisor-slot.ts +97 -2
- package/src/server/responses/agent-task-recovery.ts +44 -11
- package/src/server/responses/agy-acp-preflight.ts +41 -0
- package/src/server/responses/anthropic-image-context.ts +44 -0
- package/src/server/responses/antigravity-validation-refusal.ts +25 -1
- package/src/server/responses/buffered-sse-json.ts +18 -1
- package/src/server/responses/codex-ws-correlation.ts +5 -2
- package/src/server/responses/codex-ws-exchange.ts +91 -8
- package/src/server/responses/codex-ws-incremental.ts +136 -0
- package/src/server/responses/codex-ws-pool.ts +22 -8
- package/src/server/responses/codex-ws-request.ts +5 -0
- package/src/server/responses/codex-ws-send-accounting.ts +8 -0
- package/src/server/responses/codex-ws-session.ts +14 -0
- package/src/server/responses/codex-ws-wire.ts +44 -22
- package/src/server/responses/combo-admission-snapshot.ts +93 -0
- package/src/server/responses/combo-required-tool-stream.ts +16 -4
- package/src/server/responses/combo-selection-keepalive.ts +5 -0
- package/src/server/responses/combo-stream-preflight.ts +182 -73
- package/src/server/responses/compact-response-body.ts +27 -0
- package/src/server/responses/compact.ts +174 -121
- package/src/server/responses/compaction-recovery.ts +7 -0
- package/src/server/responses/core-codex-account.ts +88 -62
- package/src/server/responses/core-combo-failure.ts +15 -0
- package/src/server/responses/core-combo-native.ts +12 -1
- package/src/server/responses/core-combo.ts +340 -94
- package/src/server/responses/core-normalize.ts +19 -12
- package/src/server/responses/core-opaque-recovery.ts +15 -4
- package/src/server/responses/core-options.ts +50 -5
- package/src/server/responses/core-pipeline.ts +11 -0
- package/src/server/responses/core.ts +7 -1
- package/src/server/responses/empty-completion-guard.ts +21 -7
- package/src/server/responses/estimated-usage.ts +2 -1
- package/src/server/responses/fetch-helpers.ts +95 -19
- package/src/server/responses/history-slim.ts +204 -0
- package/src/server/responses/hosted-advisor-spend.ts +49 -0
- package/src/server/responses/image-context-recovery.ts +199 -0
- package/src/server/responses/input-admission.ts +36 -11
- package/src/server/responses/jev-model-invoke.ts +23 -16
- package/src/server/responses/non-replayable-error.ts +12 -2
- package/src/server/responses/passthrough-build-error.ts +5 -3
- package/src/server/responses/passthrough-delivery.ts +74 -33
- package/src/server/responses/passthrough-dispatch.ts +170 -197
- package/src/server/responses/policy-fallback.ts +7 -2
- package/src/server/responses/policy-request-scope.ts +36 -2
- package/src/server/responses/replay-owner.ts +20 -0
- package/src/server/responses/request-prepare.ts +97 -16
- package/src/server/responses/request-send-budget.ts +97 -25
- package/src/server/responses/request-sidecar-auth.ts +138 -65
- package/src/server/responses/request-spend-target.ts +13 -1
- package/src/server/responses/request-spend.ts +228 -47
- package/src/server/responses/request-transport.ts +395 -70
- package/src/server/responses/run-turn-execution.ts +40 -9
- package/src/server/responses/sidecar-execution.ts +214 -67
- package/src/server/responses/sidecar-send-budget.ts +9 -9
- package/src/server/responses/terminal-guard.ts +35 -9
- package/src/server/responses/ws-upstream.ts +27 -6
- package/src/server/responses-phase-inference.ts +32 -9
- package/src/server/responses-terminal-repair.ts +14 -35
- package/src/server/system-env.ts +8 -5
- package/src/server/ws-bridge.ts +23 -17
- package/src/service/health-sentinel-linux.ts +16 -7
- package/src/service/systemd.ts +11 -2
- package/src/service/windows-checked-stop-live.ts +60 -55
- package/src/service/windows-checked-stop.ts +29 -11
- package/src/service/windows-guarded-manager.ts +14 -26
- package/src/service/windows-process-evidence.ts +82 -74
- package/src/service/windows-process-native.ts +69 -20
- package/src/service/windows-service-stop.ts +14 -12
- package/src/service/windows-stop-binding.ts +14 -5
- package/src/service/windows-stop-confirm.ts +1 -1
- package/src/service/windows-task-instance-stop.ts +98 -0
- package/src/service/windows-taskxml.ts +30 -7
- package/src/sidecar/anthropic-binding.ts +1 -1
- package/src/stall-timeout.ts +30 -0
- package/src/telemetry/aggregate.ts +6 -3
- package/src/types/account-auto-pause.ts +19 -1
- package/src/types/accounts.ts +21 -0
- package/src/types/anthropic-account-pool.ts +1 -1
- package/src/types/combo-capability-policy.ts +19 -0
- package/src/types/config.ts +22 -2
- package/src/types/provider.ts +42 -8
- package/src/types/request.ts +15 -0
- package/src/types/tools.ts +22 -5
- package/src/types/wire.ts +1 -0
- package/src/types.ts +4 -0
- package/src/update/check-types.ts +2 -0
- package/src/update/job.ts +8 -3
- package/src/update/managed-release.ts +6 -0
- package/src/update/orchestrated-entry.ts +13 -4
- package/src/update/refresh-scheduler.ts +17 -7
- package/src/usage/attempt-delivery.ts +6 -0
- package/src/usage/cache-provenance.ts +71 -0
- package/src/usage/cost.ts +216 -27
- package/src/usage/credit-billing.ts +88 -0
- package/src/usage/jev-stats.ts +13 -9
- package/src/usage/log.ts +5 -33
- package/src/usage/summary.ts +8 -43
- package/src/usage/user-cost-overlays.ts +13 -1
- package/src/vision/index.ts +8 -3
- package/src/vision/plan.ts +28 -14
- package/src/vision/routed-describe.ts +24 -36
- package/src/web-search/header-deadline.ts +14 -3
- package/src/web-search/index.ts +6 -4
- package/src/web-search/loop.ts +240 -78
- package/src/web-search/progress-stream.ts +29 -2
- package/src/web-search/run-turn-loop.ts +5 -1
- package/gui/dist/assets/App-BGP8I0V4.css +0 -1
- package/gui/dist/assets/App-BRExzhwL.js +0 -60
- package/gui/dist/assets/Tray-DHCWAn8V.js +0 -1
- package/gui/dist/assets/brand-mark-C70PuQ3j.js +0 -1
- package/gui/dist/assets/index-DJxM-imn.css +0 -2
- package/gui/dist/assets/index-Dy1jIGty.js +0 -138
- package/gui/dist/classic/assets/App-B4j-Txmb.css +0 -1
- package/gui/dist/classic/assets/App-CaC-E6Vl.js +0 -59
- package/gui/dist/classic/assets/Tray-BG253fiL.js +0 -1
- package/gui/dist/classic/assets/index-CR_AThOp.js +0 -138
- package/gui/dist/classic/assets/quota-summary-B7KQPpEC.js +0 -1
|
@@ -3,9 +3,11 @@ import { TRANSIENT_RETRY_MAX_ATTEMPTS, type TransientSendBudget } from "../../li
|
|
|
3
3
|
import { GENERIC_OAUTH_MAX_ACCOUNTS_PER_REQUEST } from "../../oauth/generic-account-failover";
|
|
4
4
|
import type { RequestLogContext } from "../request-log";
|
|
5
5
|
import { attachRequestSpendTracker } from "../responses/request-spend";
|
|
6
|
+
import type { SpendAdmissionPolicy } from "../../lib/spend-reservation-ledger";
|
|
6
7
|
|
|
7
8
|
// Only ingress owns an expandable policy. Exact caller budgets and combo-derived scopes
|
|
8
9
|
// never enter this map, even when their policy happens to equal the default profile.
|
|
10
|
+
const oauthExpanded = new WeakSet<TransientSendBudget>();
|
|
9
11
|
const ingressPolicies = new WeakMap<TransientSendBudget, {
|
|
10
12
|
maxTotalModelSends: number;
|
|
11
13
|
baseSendAllowance: number;
|
|
@@ -19,9 +21,10 @@ const ingressPolicies = new WeakMap<TransientSendBudget, {
|
|
|
19
21
|
export function createInferenceSendBudget(
|
|
20
22
|
req: Pick<Request, "headers">,
|
|
21
23
|
logCtx: RequestLogContext,
|
|
24
|
+
capturedPolicy?: SpendAdmissionPolicy,
|
|
22
25
|
): RequestExecutionBudget {
|
|
23
26
|
const policy = { ...CODEX_TEXT_GUARDED_BUDGET_POLICY };
|
|
24
|
-
const budget = createRequestExecutionBudget(policy, undefined, attachRequestSpendTracker(req, logCtx));
|
|
27
|
+
const budget = createRequestExecutionBudget(policy, undefined, attachRequestSpendTracker(req, logCtx, undefined, capturedPolicy));
|
|
25
28
|
ingressPolicies.set(budget, policy);
|
|
26
29
|
return budget;
|
|
27
30
|
}
|
|
@@ -32,12 +35,36 @@ export function createInferenceSendBudget(
|
|
|
32
35
|
* GENERIC_OAUTH_MAX_ACCOUNTS_PER_REQUEST × TRANSIENT_RETRY_MAX_ATTEMPTS.
|
|
33
36
|
*/
|
|
34
37
|
export function expandInferenceOAuthSendBudget(budget: TransientSendBudget | undefined, accounts: number): void {
|
|
35
|
-
|
|
38
|
+
const fundedAccounts = Number.isSafeInteger(accounts) && accounts >= 2 ? Math.min(accounts, GENERIC_OAUTH_MAX_ACCOUNTS_PER_REQUEST) : 0;
|
|
39
|
+
expandIngressSendBudget(budget, fundedAccounts * TRANSIENT_RETRY_MAX_ATTEMPTS);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Fund an explicitly configured standalone ChatGPT retry ladder before any send. */
|
|
43
|
+
export function fundChatGptRetryAttempts(budget: TransientSendBudget | undefined, attempts: number): void {
|
|
44
|
+
if (Number.isInteger(attempts) && attempts > TRANSIENT_RETRY_MAX_ATTEMPTS && attempts <= 10) {
|
|
45
|
+
expandIngressSendBudget(budget, attempts);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function expandIngressSendBudget(budget: TransientSendBudget | undefined, sends: number): void {
|
|
50
|
+
if (!budget) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
36
53
|
const policy = ingressPolicies.get(budget);
|
|
37
|
-
if (!policy || budget.used !== 0 || ("physicalStarted" in budget && Number(budget.physicalStarted) > 0))
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
54
|
+
if (!policy || oauthExpanded.has(budget) || budget.used !== 0 || ("physicalStarted" in budget && Number(budget.physicalStarted) > 0)) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
// One ingress expansion per request; the policy stays for the hosted-search allowance.
|
|
58
|
+
oauthExpanded.add(budget);
|
|
41
59
|
policy.baseSendAllowance = Math.max(policy.baseSendAllowance, sends);
|
|
42
60
|
policy.maxTotalModelSends = Math.max(policy.maxTotalModelSends, sends);
|
|
43
61
|
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
/** Fund the hosted loop's bounded model sends before its first dispatch. */
|
|
65
|
+
export function expandInferenceSearchSendBudget(budget: TransientSendBudget | undefined, baseSends: number): void {
|
|
66
|
+
const policy = budget && ingressPolicies.get(budget);
|
|
67
|
+
if (!policy || baseSends <= policy.baseSendAllowance) return;
|
|
68
|
+
policy.maxTotalModelSends += baseSends - policy.baseSendAllowance;
|
|
69
|
+
policy.baseSendAllowance = baseSends;
|
|
70
|
+
}
|
|
@@ -21,7 +21,9 @@ import { mergeModelPinnedEfforts, modelPinnedEffortsConfigError } from "../../co
|
|
|
21
21
|
import { MULTI_AGENT_SURFACE_ADVISORY_VERSION, multiAgentSurfaceAdvisory, resolveMultiAgentMode } from "../../config/multi-agent-surface";
|
|
22
22
|
import { isPlaintextV2AgentMessagesEnabled } from "../../config/multi-agent-surface";
|
|
23
23
|
import { captureConfigTopLevelRollback, parsedConfigRebaseDeletionKeys, projectConfigRebaseProvenance } from "../../config/rebase-provenance";
|
|
24
|
+
import { ConfigWritePublishedError } from "../../config/persist-unlocked";
|
|
24
25
|
import { anthropicSidecarPatchError } from "../../config/schema/anthropic-account-pool";
|
|
26
|
+
import { agyAcpUnattendedTargetIssues } from "../../config/schema/agy-acp-references";
|
|
25
27
|
import { isAnthropicInstanceId } from "../../providers/anthropic-instance-id";
|
|
26
28
|
import {
|
|
27
29
|
adoptPersistedClaudeCode,
|
|
@@ -756,6 +758,11 @@ async function handleAgentSettingsRoutesImpl(ctx: ManagementContext): Promise<Re
|
|
|
756
758
|
if (nextSyncCodexSubagentDefaults && nextEffort !== undefined && !isCodexReasoningEffort(nextEffort)) {
|
|
757
759
|
return jsonResponse({ error: "syncCodexSubagentDefaults requires a supported Codex reasoning effort" }, 400);
|
|
758
760
|
}
|
|
761
|
+
if (nextSyncCodexSubagentDefaults) {
|
|
762
|
+
const issue = agyAcpUnattendedTargetIssues({ ...config, injectionModel: nextModel, syncCodexSubagentDefaults: true })
|
|
763
|
+
.find(({ path }) => path[0] === "injectionModel");
|
|
764
|
+
if (issue) return jsonResponse({ error: `injectionModel: ${issue.message}` }, 400);
|
|
765
|
+
}
|
|
759
766
|
|
|
760
767
|
config.multiAgentGuidanceEnabled = nextEnabled;
|
|
761
768
|
if (nextSyncCodexSubagentDefaults) config.syncCodexSubagentDefaults = true;
|
|
@@ -1532,7 +1539,7 @@ async function handleAgentSettingsRoutesImpl(ctx: ManagementContext): Promise<Re
|
|
|
1532
1539
|
const models = await fetchAllModels(config);
|
|
1533
1540
|
const { listCatalogNativeSlugs } = await import("../../codex/catalog");
|
|
1534
1541
|
const { claudeCodeAlias, claudeCodeNativeAlias } = await import("../../claude/alias");
|
|
1535
|
-
const { buildClaudeContextWindows, effectiveModelEnv, nativeClaudePassthroughFor } = await import("../../claude/context-windows");
|
|
1542
|
+
const { buildClaudeContextWindows, effectiveModelEnv, nativeClaudePassthroughFor, probeClaudeCodeVersionForTierFill } = await import("../../claude/context-windows");
|
|
1536
1543
|
const { visibleNativeSlugs } = await import("../../codex/catalog");
|
|
1537
1544
|
const disabled = new Set(config.disabledModels ?? []);
|
|
1538
1545
|
const isDisabled = (provider: string, id: string) =>
|
|
@@ -1574,6 +1581,14 @@ async function handleAgentSettingsRoutesImpl(ctx: ManagementContext): Promise<Re
|
|
|
1574
1581
|
nativeContextLimits(config),
|
|
1575
1582
|
nativeClaudePassthroughFor(config.claudeCode, resolvedAuthMode.markerMode),
|
|
1576
1583
|
);
|
|
1584
|
+
const launchState = {
|
|
1585
|
+
enabled: config.claudeCode?.enabled !== false,
|
|
1586
|
+
forceAvailable: [...visibleNativeSlugs(config), ...filterCatalogVisibleModels(models, config).map(catalogModelSlug)],
|
|
1587
|
+
contextWindows,
|
|
1588
|
+
};
|
|
1589
|
+
// The launcher probes its own CLI. Only the dashboard snapshot needs the daemon's version.
|
|
1590
|
+
if (url.searchParams.get("view") === "launch") return jsonResponse(launchState);
|
|
1591
|
+
const claudeCodeVersion = await probeClaudeCodeVersionForTierFill(config.claudeCode, contextWindows);
|
|
1577
1592
|
const webSearchOverride = config.claudeCode?.webSearchSidecar;
|
|
1578
1593
|
const visionOverride = config.claudeCode?.visionSidecar;
|
|
1579
1594
|
const helperParent = config.claudeCode?.model?.includes("/") ? config.claudeCode.model.split("/")[0] : undefined;
|
|
@@ -1590,7 +1605,7 @@ async function handleAgentSettingsRoutesImpl(ctx: ManagementContext): Promise<Re
|
|
|
1590
1605
|
const eligible = claudeInterceptEnabled(config);
|
|
1591
1606
|
const sharedProxy = readFirstPartyProxyStatus(config, bound?.proxyPort ?? null);
|
|
1592
1607
|
return jsonResponse({
|
|
1593
|
-
|
|
1608
|
+
...launchState,
|
|
1594
1609
|
cliFirstParty: config.claudeCode?.cliFirstParty === true,
|
|
1595
1610
|
cliFirstPartyApplied: config.claudeCode?.cliFirstParty === true && sharedProxy === "live",
|
|
1596
1611
|
desktopFirstParty: desired.desktop,
|
|
@@ -1626,6 +1641,7 @@ async function handleAgentSettingsRoutesImpl(ctx: ManagementContext): Promise<Re
|
|
|
1626
1641
|
contextAccounting: config.claudeCode?.contextAccounting === "200k" ? "200k" : "1m",
|
|
1627
1642
|
blockedSkills: config.claudeCode?.blockedSkills ?? null,
|
|
1628
1643
|
injectAgents: config.claudeCode?.injectAgents !== false,
|
|
1644
|
+
nativePassthrough: config.claudeCode?.nativePassthrough !== false,
|
|
1629
1645
|
sidecarPools: {
|
|
1630
1646
|
webSearchSidecar: sidecarAnthropicPoolOptions(config, { ...config.webSearchSidecar, ...webSearchOverride }, helperParent),
|
|
1631
1647
|
visionSidecar: sidecarAnthropicPoolOptions(config, { ...helperVision, backend: helperVisionBackend }, helperParent),
|
|
@@ -1637,9 +1653,7 @@ async function handleAgentSettingsRoutesImpl(ctx: ManagementContext): Promise<Re
|
|
|
1637
1653
|
? { visionSidecar: { enabled: visionOverride.enabled, backend: visionOverride.backend, model: visionOverride.model, ...(visionOverride.anthropicInstance ? { anthropicInstance: visionOverride.anthropicInstance } : {}) } }
|
|
1638
1654
|
: {}),
|
|
1639
1655
|
fastMode: config.fastMode,
|
|
1640
|
-
|
|
1641
|
-
contextWindows,
|
|
1642
|
-
effectiveModelEnv: effectiveModelEnv(config.claudeCode, contextWindows),
|
|
1656
|
+
effectiveModelEnv: effectiveModelEnv(config.claudeCode, contextWindows, undefined, claudeCodeVersion),
|
|
1643
1657
|
available,
|
|
1644
1658
|
aliases,
|
|
1645
1659
|
port: config.port,
|
|
@@ -1660,7 +1674,7 @@ async function handleAgentSettingsRoutesImpl(ctx: ManagementContext): Promise<Re
|
|
|
1660
1674
|
return prototype === Object.prototype || prototype === null;
|
|
1661
1675
|
};
|
|
1662
1676
|
if (!isPlainObject(parsedBody)) return jsonResponse({ error: "body must be an object" }, 400);
|
|
1663
|
-
const body = parsedBody as { enabled?: unknown; cliFirstParty?: unknown; authMode?: unknown; model?: unknown; smallFastModel?: unknown; modelMap?: unknown; classifierModel?: unknown; classifierFallbacks?: unknown; systemEnv?: unknown; fastMode?: unknown; maxContextTokens?: unknown; alwaysEnableEffort?: unknown; tierModels?: unknown; autoContext?: unknown; autoCompactWindow?: unknown; contextAccounting?: unknown; blockedSkills?: unknown; injectAgents?: unknown; webSearchSidecar?: unknown; visionSidecar?: unknown };
|
|
1677
|
+
const body = parsedBody as { enabled?: unknown; cliFirstParty?: unknown; authMode?: unknown; model?: unknown; smallFastModel?: unknown; modelMap?: unknown; classifierModel?: unknown; classifierFallbacks?: unknown; systemEnv?: unknown; fastMode?: unknown; maxContextTokens?: unknown; alwaysEnableEffort?: unknown; tierModels?: unknown; autoContext?: unknown; autoCompactWindow?: unknown; contextAccounting?: unknown; blockedSkills?: unknown; injectAgents?: unknown; nativePassthrough?: unknown; webSearchSidecar?: unknown; visionSidecar?: unknown };
|
|
1664
1678
|
if (body.cliFirstParty !== undefined && typeof body.cliFirstParty !== "boolean")
|
|
1665
1679
|
return jsonResponse({ error: "cliFirstParty must be a boolean" }, 400);
|
|
1666
1680
|
if (body.cliFirstParty !== undefined && Object.keys(body).length !== 1)
|
|
@@ -1787,6 +1801,7 @@ async function handleAgentSettingsRoutesImpl(ctx: ManagementContext): Promise<Re
|
|
|
1787
1801
|
&& readFirstPartyProxyStatus(config, bound?.proxyPort ?? null) !== "none";
|
|
1788
1802
|
await syncClaudeAgentDefsBestEffort();
|
|
1789
1803
|
return jsonResponse({ ok: true, enabled: config.claudeCode?.enabled !== false,
|
|
1804
|
+
nativePassthrough: config.claudeCode?.nativePassthrough !== false,
|
|
1790
1805
|
cliFirstParty: body.cliFirstParty,
|
|
1791
1806
|
warnings: [
|
|
1792
1807
|
...(committed.retainedAmbiguous ? ["shared_proxy_retained"] : []),
|
|
@@ -1803,7 +1818,6 @@ async function handleAgentSettingsRoutesImpl(ctx: ManagementContext): Promise<Re
|
|
|
1803
1818
|
const webEvidence = isPlainObject(webPatch) && (webPatch.model !== undefined || webPatch.backend !== undefined || webPatch.anthropicInstance !== undefined)
|
|
1804
1819
|
? await webSearchCandidateRows({ ...config, webSearchSidecar: { ...config.webSearchSidecar, ...sidecarSettingsAfterPatch(config.claudeCode?.webSearchSidecar, webPatch) } }) : undefined;
|
|
1805
1820
|
const { commitClaudeCodeBlock } = await import("../../claude/claude-code-block");
|
|
1806
|
-
const { saveConfigPreservingClaudeCode: save } = await import("../../config");
|
|
1807
1821
|
const refusal = await settleConfigRoot(configRoot(), () => {
|
|
1808
1822
|
if ((visionEvidence || webEvidence) && JSON.stringify(config) !== evidenceState) return jsonResponse({ error: "Sidecar validation state changed during discovery", code: "config_changed" }, 409);
|
|
1809
1823
|
const instanceError = anthropicSidecarPatchError(config, body, true);
|
|
@@ -1875,14 +1889,16 @@ async function handleAgentSettingsRoutesImpl(ctx: ManagementContext): Promise<Re
|
|
|
1875
1889
|
// refuse before anything changes when that cannot be saved.
|
|
1876
1890
|
const captureRefused = body.enabled !== undefined ? captureHomeRouteDefaultsBeforeHomeSwitch() : null;
|
|
1877
1891
|
if (captureRefused) return jsonResponse({ error: captureRefused.message, code: "route_intent_unavailable" }, captureRefused.retryable ? 409 : 500);
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1892
|
+
const rollback = captureConfigTopLevelRollback(config, body.fastMode === undefined
|
|
1893
|
+
? ["claudeCode"] : ["claudeCode", "fastMode"]);
|
|
1894
|
+
try {
|
|
1895
|
+
if (body.fastMode !== undefined) config.fastMode = nextFastMode;
|
|
1896
|
+
commitClaudeCodeBlock(config, next);
|
|
1897
|
+
saveConfigPreservingClaudeCode(config);
|
|
1898
|
+
} catch (error) {
|
|
1899
|
+
if (!(error instanceof ConfigWritePublishedError)) rollback();
|
|
1900
|
+
throw error;
|
|
1901
|
+
}
|
|
1886
1902
|
return null;
|
|
1887
1903
|
});
|
|
1888
1904
|
if (refusal) return refusal;
|
|
@@ -1904,7 +1920,8 @@ async function handleAgentSettingsRoutesImpl(ctx: ManagementContext): Promise<Re
|
|
|
1904
1920
|
// Keep the file-backed live registry symmetric: OFF prunes immediately, while
|
|
1905
1921
|
// ON and config changes restore definitions without requiring a restart.
|
|
1906
1922
|
await syncClaudeAgentDefsBestEffort();
|
|
1907
|
-
return jsonResponse({ ok: true, enabled: config.claudeCode?.enabled !== false,
|
|
1923
|
+
return jsonResponse({ ok: true, enabled: config.claudeCode?.enabled !== false,
|
|
1924
|
+
nativePassthrough: config.claudeCode?.nativePassthrough !== false, warnings });
|
|
1908
1925
|
}
|
|
1909
1926
|
return null;
|
|
1910
1927
|
}
|
|
@@ -114,6 +114,12 @@ export function prepareClaudeCodePatch(config: OcxConfig, body: Record<string, u
|
|
|
114
114
|
if (body.injectAgents) delete next.injectAgents;
|
|
115
115
|
else next.injectAgents = false;
|
|
116
116
|
}
|
|
117
|
+
if (body.nativePassthrough !== undefined) {
|
|
118
|
+
// Default-on boolean: true = drop the key, false = store. Off routes bare Claude ids.
|
|
119
|
+
if (typeof body.nativePassthrough !== "boolean") return jsonResponse({ error: "nativePassthrough must be a boolean" }, 400);
|
|
120
|
+
if (body.nativePassthrough) delete next.nativePassthrough;
|
|
121
|
+
else next.nativePassthrough = false;
|
|
122
|
+
}
|
|
117
123
|
if (body.autoCompactWindow !== undefined) {
|
|
118
124
|
// null resets to the 350k default; otherwise the binary-accepted range
|
|
119
125
|
// 100_000..1_000_000 (2.1.207 pSo/yDs — audit 021 #1).
|
|
@@ -94,7 +94,9 @@ function sparseComboConfig<T extends {
|
|
|
94
94
|
reasoningEffortMode?: "strict" | "adaptive";
|
|
95
95
|
defaultEffortMode?: "fallback" | "force";
|
|
96
96
|
jevEffortMode?: "decide" | "client";
|
|
97
|
-
|
|
97
|
+
capabilityPolicy?: "intersection" | "union";
|
|
98
|
+
onUnservable?: "degrade" | "reject";
|
|
99
|
+
}>(combo: T): Omit<T, "cooldownMs" | "waitForCooldownMs" | "cooldownWaitPolicy" | "imageInput" | "reasoningEffortMode" | "defaultEffortMode" | "jevEffortMode" | "capabilityPolicy" | "onUnservable"> & {
|
|
98
100
|
cooldownMs?: number;
|
|
99
101
|
waitForCooldownMs?: number;
|
|
100
102
|
cooldownWaitPolicy?: OcxComboCooldownWaitPolicy;
|
|
@@ -102,6 +104,8 @@ function sparseComboConfig<T extends {
|
|
|
102
104
|
reasoningEffortMode?: "adaptive";
|
|
103
105
|
defaultEffortMode?: "force";
|
|
104
106
|
jevEffortMode?: "client";
|
|
107
|
+
capabilityPolicy?: "union";
|
|
108
|
+
onUnservable?: "reject";
|
|
105
109
|
} {
|
|
106
110
|
const {
|
|
107
111
|
cooldownMs,
|
|
@@ -111,6 +115,8 @@ function sparseComboConfig<T extends {
|
|
|
111
115
|
reasoningEffortMode,
|
|
112
116
|
defaultEffortMode,
|
|
113
117
|
jevEffortMode,
|
|
118
|
+
capabilityPolicy,
|
|
119
|
+
onUnservable,
|
|
114
120
|
...rest
|
|
115
121
|
} = combo;
|
|
116
122
|
return {
|
|
@@ -126,6 +132,8 @@ function sparseComboConfig<T extends {
|
|
|
126
132
|
...(reasoningEffortMode === "adaptive" ? { reasoningEffortMode: "adaptive" as const } : {}),
|
|
127
133
|
...(defaultEffortMode === "force" ? { defaultEffortMode: "force" as const } : {}),
|
|
128
134
|
...(jevEffortMode === "client" ? { jevEffortMode: "client" as const } : {}),
|
|
135
|
+
...(capabilityPolicy === "union" ? { capabilityPolicy: "union" as const } : {}),
|
|
136
|
+
...(onUnservable === "reject" ? { onUnservable: "reject" as const } : {}),
|
|
129
137
|
};
|
|
130
138
|
}
|
|
131
139
|
|
|
@@ -170,6 +178,12 @@ function parseVisionSidecarTargets(
|
|
|
170
178
|
export async function handleComboRoutes(ctx: ManagementContext): Promise<Response | null> {
|
|
171
179
|
const { req, url, config, deps, convergeCodexCatalog, syncClaudeAgentDefsBestEffort } = ctx;
|
|
172
180
|
|
|
181
|
+
// Only the Combos page reads the suggested combos' excluded-provider list; load it on demand.
|
|
182
|
+
if (url.pathname === "/api/combo-suggestions" || url.pathname === "/api/combo-suggestions/save") {
|
|
183
|
+
const { handleComboSuggestionRoutes } = await import("./combo-suggestion-routes");
|
|
184
|
+
return handleComboSuggestionRoutes(ctx);
|
|
185
|
+
}
|
|
186
|
+
|
|
173
187
|
if (url.pathname === "/api/combos" && req.method === "GET") {
|
|
174
188
|
const { comboPublicModelId, getCombo, listComboIds } = await import("../../combos");
|
|
175
189
|
return jsonResponse({ combos: listComboIds(config).map(id => {
|
|
@@ -257,6 +271,12 @@ export async function handleComboRoutes(ctx: ManagementContext): Promise<Respons
|
|
|
257
271
|
...(!Object.hasOwn(requestedCombo, "imageInput") && previous?.imageInput !== undefined
|
|
258
272
|
? { imageInput: previous.imageInput }
|
|
259
273
|
: {}),
|
|
274
|
+
...(!Object.hasOwn(requestedCombo, "capabilityPolicy") && previous?.capabilityPolicy !== undefined
|
|
275
|
+
? { capabilityPolicy: previous.capabilityPolicy }
|
|
276
|
+
: {}),
|
|
277
|
+
...(!Object.hasOwn(requestedCombo, "onUnservable") && previous?.onUnservable !== undefined
|
|
278
|
+
? { onUnservable: previous.onUnservable }
|
|
279
|
+
: {}),
|
|
260
280
|
// #7229: the dashboard does not edit the row description, so a round trip that omits it
|
|
261
281
|
// (including a rename) keeps it. An explicit empty string still clears it.
|
|
262
282
|
...(!Object.hasOwn(requestedCombo, "description") && previous?.description !== undefined
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `GET|PUT /api/combo-suggestions`: the providers left out of the Combos page's suggested
|
|
3
|
+
* combos (`comboSuggestionExcludedProviders`). Suggestions are computed in the dashboard; this
|
|
4
|
+
* persists the exclusion list and saves suggested targets against current config policy.
|
|
5
|
+
*/
|
|
6
|
+
import { clearComboSelectionState, clearComboTargetCooldowns, comboPublicModelId } from "../../combos";
|
|
7
|
+
import { comboConfigIssues } from "../../combos/types";
|
|
8
|
+
import { channelTier, TIER_RANK } from "../../combos/suggestion-channel";
|
|
9
|
+
import { codexAccountNamespaceForModel } from "../../codex/account-namespace-match";
|
|
10
|
+
import { reconcileLiveStateStores } from "../../lib/state-store-registrations";
|
|
11
|
+
import type { OcxComboConfig, OcxConfig } from "../../types";
|
|
12
|
+
import { normalizeDecisionModelSelector, decisionModelRouteError } from "./decision-model-validation";
|
|
13
|
+
import type { ManagementContext } from "./context";
|
|
14
|
+
import { jsonResponse } from "../auth-cors";
|
|
15
|
+
import { readConfigFileSnapshot } from "../../config/diagnostics";
|
|
16
|
+
import { mutatePersistedConfig } from "../../config";
|
|
17
|
+
import { managementBodyTooLargeResponse, readManagementJsonBody } from "./body";
|
|
18
|
+
import { hasHumanDashboardSession } from "./consent-session";
|
|
19
|
+
import { isPlainRecord } from "./shared";
|
|
20
|
+
|
|
21
|
+
const MAX_PROVIDERS = 256;
|
|
22
|
+
const MAX_NAME_LENGTH = 256;
|
|
23
|
+
|
|
24
|
+
/** Trimmed, deduplicated, in the order given; null when the value is not a list of names. */
|
|
25
|
+
export function parseExcludedProviders(value: unknown): string[] | null {
|
|
26
|
+
if (!Array.isArray(value) || value.length > MAX_PROVIDERS) return null;
|
|
27
|
+
const out: string[] = [];
|
|
28
|
+
for (const entry of value) {
|
|
29
|
+
if (typeof entry !== "string") return null;
|
|
30
|
+
const name = entry.trim();
|
|
31
|
+
if (!name || name.length > MAX_NAME_LENGTH) return null;
|
|
32
|
+
if (!out.includes(name)) out.push(name);
|
|
33
|
+
}
|
|
34
|
+
return out;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function suggestionPolicy(config: OcxConfig) {
|
|
38
|
+
return {
|
|
39
|
+
excludedProviders: config.comboSuggestionExcludedProviders ?? [],
|
|
40
|
+
meteredComboIds: Object.entries(config.combos ?? {})
|
|
41
|
+
.filter(([, combo]) => combo.allowMeteredTargets === true)
|
|
42
|
+
.map(([id]) => id),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function view(ctx: ManagementContext, policy: ReturnType<typeof suggestionPolicy>): Response {
|
|
47
|
+
const response = jsonResponse(policy, 200, ctx.req, ctx.config);
|
|
48
|
+
response.headers.set("cache-control", "no-store");
|
|
49
|
+
return response;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export async function handleComboSuggestionRoutes(ctx: ManagementContext): Promise<Response | null> {
|
|
53
|
+
const { req, url } = ctx;
|
|
54
|
+
const allowed = hasHumanDashboardSession(ctx);
|
|
55
|
+
const denied = () => jsonResponse({ error: "dashboard session required" }, 403, req, ctx.config);
|
|
56
|
+
if (url.pathname === "/api/combo-suggestions/save" && req.method === "POST") {
|
|
57
|
+
return allowed ? await saveSuggestion(ctx) : denied();
|
|
58
|
+
}
|
|
59
|
+
if (url.pathname === "/api/combo-suggestions" && req.method === "GET") {
|
|
60
|
+
if (!allowed) return denied();
|
|
61
|
+
const { diagnostics } = readConfigFileSnapshot();
|
|
62
|
+
return diagnostics.source === "file"
|
|
63
|
+
? view(ctx, suggestionPolicy(diagnostics.config))
|
|
64
|
+
: jsonResponse({ error: "suggestion policy unavailable", code: "config_unavailable" }, 409, req, ctx.config);
|
|
65
|
+
}
|
|
66
|
+
if (url.pathname === "/api/combo-suggestions" && req.method === "PUT") {
|
|
67
|
+
return allowed ? await writeExcluded(ctx) : denied();
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async function writeExcluded(ctx: ManagementContext): Promise<Response> {
|
|
73
|
+
const { req, config } = ctx;
|
|
74
|
+
let body: unknown;
|
|
75
|
+
try {
|
|
76
|
+
body = await readManagementJsonBody(req);
|
|
77
|
+
} catch (error) {
|
|
78
|
+
return managementBodyTooLargeResponse(error, req, config)
|
|
79
|
+
?? jsonResponse({ error: "invalid JSON body", code: "invalid_request" }, 400, req, config);
|
|
80
|
+
}
|
|
81
|
+
if (!isPlainRecord(body) || Object.keys(body).some(key => key !== "provider" && key !== "excluded")
|
|
82
|
+
|| typeof body.excluded !== "boolean") {
|
|
83
|
+
return jsonResponse({ error: "expected a provider and exclusion state", code: "invalid_request" }, 400, req, config);
|
|
84
|
+
}
|
|
85
|
+
const provider = parseExcludedProviders([body.provider])?.[0];
|
|
86
|
+
if (!provider) return jsonResponse({ error: "invalid provider name", code: "invalid_request" }, 400, req, config);
|
|
87
|
+
const { excluded } = body;
|
|
88
|
+
const outcome = mutatePersistedConfig(persisted => {
|
|
89
|
+
const before = persisted.comboSuggestionExcludedProviders ?? [];
|
|
90
|
+
if (before.includes(provider) === excluded) return { changed: false, value: suggestionPolicy(persisted) };
|
|
91
|
+
const next = excluded ? [...before, provider] : before.filter(name => name !== provider);
|
|
92
|
+
if (next.length > MAX_PROVIDERS) return { changed: false, value: null };
|
|
93
|
+
if (next.length === 0) delete persisted.comboSuggestionExcludedProviders;
|
|
94
|
+
else persisted.comboSuggestionExcludedProviders = next;
|
|
95
|
+
return { changed: true, value: suggestionPolicy(persisted) };
|
|
96
|
+
});
|
|
97
|
+
if (outcome.status === "unavailable") {
|
|
98
|
+
return jsonResponse({ error: `config.json is ${outcome.reason}; excluded providers were not saved`, code: "config_unavailable" }, 409, req, config);
|
|
99
|
+
}
|
|
100
|
+
if (!outcome.value) return jsonResponse({ error: "too many excluded providers", code: "invalid_request" }, 400, req, config);
|
|
101
|
+
const { excludedProviders } = outcome.value;
|
|
102
|
+
if (excludedProviders.length === 0) delete config.comboSuggestionExcludedProviders;
|
|
103
|
+
else config.comboSuggestionExcludedProviders = excludedProviders;
|
|
104
|
+
return view(ctx, outcome.value);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
type Target = Pick<OcxComboConfig["targets"][number], "provider" | "model">;
|
|
108
|
+
|
|
109
|
+
function parseTargets(value: unknown): Target[] | null {
|
|
110
|
+
if (!Array.isArray(value) || !value.length || value.length > MAX_PROVIDERS) return null;
|
|
111
|
+
const targets: Target[] = [];
|
|
112
|
+
for (const entry of value) {
|
|
113
|
+
if (!isPlainRecord(entry) || Object.keys(entry).some(key => key !== "provider" && key !== "model")
|
|
114
|
+
|| typeof entry.provider !== "string" || typeof entry.model !== "string") return null;
|
|
115
|
+
const provider = entry.provider.trim();
|
|
116
|
+
const model = entry.model.trim();
|
|
117
|
+
if (!provider || provider.length > MAX_NAME_LENGTH || !model) return null;
|
|
118
|
+
if (!targets.some(target => target.provider === provider && target.model === model)) {
|
|
119
|
+
targets.push({ provider, model });
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return targets;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
type SuggestionSaveResult =
|
|
126
|
+
| { code: string; status: number }
|
|
127
|
+
| { combos: NonNullable<OcxConfig["combos"]> };
|
|
128
|
+
|
|
129
|
+
async function saveSuggestion(ctx: ManagementContext): Promise<Response> {
|
|
130
|
+
const { req, config } = ctx;
|
|
131
|
+
let body: unknown;
|
|
132
|
+
try {
|
|
133
|
+
body = await readManagementJsonBody(req);
|
|
134
|
+
} catch (error) {
|
|
135
|
+
return managementBodyTooLargeResponse(error, req, config)
|
|
136
|
+
?? jsonResponse({ error: "invalid JSON body", code: "invalid_request" }, 400, req, config);
|
|
137
|
+
}
|
|
138
|
+
const invalid = () => jsonResponse({ error: "invalid suggested combo", code: "invalid_request" }, 400, req, config);
|
|
139
|
+
if (!isPlainRecord(body) || Object.keys(body).some(key => key !== "id" && key !== "mode" && key !== "targets" && key !== "allowMeteredTargets")
|
|
140
|
+
|| typeof body.id !== "string" || (body.mode !== "create" && body.mode !== "append")) return invalid();
|
|
141
|
+
const id = body.id.trim();
|
|
142
|
+
const targets = parseTargets(body.targets);
|
|
143
|
+
if (!targets || !id) return invalid();
|
|
144
|
+
const create = body.mode === "create";
|
|
145
|
+
const consent = body.allowMeteredTargets;
|
|
146
|
+
if (!create && Object.hasOwn(body, "allowMeteredTargets")) return invalid();
|
|
147
|
+
|
|
148
|
+
const outcome = mutatePersistedConfig<SuggestionSaveResult>(persisted => {
|
|
149
|
+
const previous = Object.hasOwn(persisted.combos ?? {}, id) ? persisted.combos![id] : undefined;
|
|
150
|
+
const rejected = (code: string, status = 409) => ({ changed: false, value: { code, status } });
|
|
151
|
+
if (create ? previous : !previous) return rejected("suggestion_combo_changed");
|
|
152
|
+
|
|
153
|
+
if (create && consent !== undefined && typeof consent !== "boolean") return rejected("invalid_request", 400);
|
|
154
|
+
if ((create ? consent : previous?.allowMeteredTargets) !== true) return rejected("suggestion_consent_required");
|
|
155
|
+
|
|
156
|
+
const nextTargets = [...(previous?.targets ?? [])];
|
|
157
|
+
const providerFor = (snapshot: OcxConfig, name: string) =>
|
|
158
|
+
Object.hasOwn(snapshot.providers, name) ? snapshot.providers[name] : undefined;
|
|
159
|
+
const tierOf = (snapshot: OcxConfig, { provider, model }: Target) => {
|
|
160
|
+
const current = providerFor(snapshot, provider);
|
|
161
|
+
return current ? channelTier({ ...current, name: provider }, model) : "metered";
|
|
162
|
+
};
|
|
163
|
+
// Use the lower placement preference when live and persisted channel classifications differ.
|
|
164
|
+
const rankOf = (target: Target) => Math.max(TIER_RANK[tierOf(persisted, target)], TIER_RANK[tierOf(config, target)]);
|
|
165
|
+
const inserted = new Set<OcxComboConfig["targets"][number]>();
|
|
166
|
+
for (const target of targets) {
|
|
167
|
+
if (nextTargets.some(({ provider, model }) => provider.trim() === target.provider && model.trim() === target.model)) continue;
|
|
168
|
+
const provider = providerFor(persisted, target.provider);
|
|
169
|
+
if (!provider || provider.disabled || provider.adapter === "jev-decision") {
|
|
170
|
+
return rejected("suggestion_provider_unavailable");
|
|
171
|
+
}
|
|
172
|
+
if (persisted.comboSuggestionExcludedProviders?.includes(target.provider)) return rejected("suggestion_provider_excluded");
|
|
173
|
+
const rank = rankOf(target);
|
|
174
|
+
const at = create ? -1 : nextTargets.findIndex(existing =>
|
|
175
|
+
(existing.metered === true && !inserted.has(existing) ? TIER_RANK.metered : rankOf(existing)) > rank);
|
|
176
|
+
const added = { ...target, metered: true };
|
|
177
|
+
inserted.add(added);
|
|
178
|
+
nextTargets.splice(at < 0 ? nextTargets.length : at, 0, added);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const combo: OcxComboConfig = { strategy: "failover", ...previous, allowMeteredTargets: true, targets: nextTargets };
|
|
182
|
+
const combos = { ...persisted.combos, [id]: combo };
|
|
183
|
+
const prospective = { ...persisted, combos };
|
|
184
|
+
if (comboConfigIssues(id, combo, persisted.providers, {
|
|
185
|
+
requireEnabledTarget: true,
|
|
186
|
+
requireUsableDecisionService: true,
|
|
187
|
+
combos,
|
|
188
|
+
excludeComboId: id,
|
|
189
|
+
normalizeDecisionModel: model => normalizeDecisionModelSelector(prospective, model),
|
|
190
|
+
}).length) return rejected("invalid_request", 400);
|
|
191
|
+
if (codexAccountNamespaceForModel(persisted.codexAccountNamespaces, comboPublicModelId(id, combo))) {
|
|
192
|
+
return rejected("suggestion_combo_changed");
|
|
193
|
+
}
|
|
194
|
+
if (Object.entries(combos).some(([comboId, row]) => row.decisionModel
|
|
195
|
+
&& decisionModelRouteError(prospective, comboId, row.decisionModel))) return rejected("invalid_request", 400);
|
|
196
|
+
|
|
197
|
+
persisted.combos = combos;
|
|
198
|
+
return { changed: nextTargets.length !== (previous?.targets.length ?? 0), value: { combos } };
|
|
199
|
+
});
|
|
200
|
+
if (outcome.status === "unavailable") {
|
|
201
|
+
return jsonResponse({ error: "suggestion could not be saved", code: "config_unavailable" }, 409, req, config);
|
|
202
|
+
}
|
|
203
|
+
if ("code" in outcome.value) {
|
|
204
|
+
return jsonResponse({ error: "suggestion could not be saved", code: outcome.value.code }, outcome.value.status, req, config);
|
|
205
|
+
}
|
|
206
|
+
config.combos = outcome.value.combos;
|
|
207
|
+
reconcileLiveStateStores();
|
|
208
|
+
clearComboSelectionState(id);
|
|
209
|
+
clearComboTargetCooldowns(id);
|
|
210
|
+
const catalogRefresh = await ctx.convergeCodexCatalog();
|
|
211
|
+
return jsonResponse({ success: true, catalogRefresh }, 200, req, config);
|
|
212
|
+
}
|
|
@@ -6,6 +6,7 @@ import { resolveMainAccountHardLockThresholds } from "../../codex/main-account-h
|
|
|
6
6
|
import { getMainAccountExternalUsageWarning } from "../../codex/main-account-external-usage";
|
|
7
7
|
import { getObservedMainQuotaIdentityKey } from "../../codex/main-account-cache";
|
|
8
8
|
import { compactionRoutingSchema, memoryModelsSchema, reasoningRetentionSchema } from "../../config/schema/leaf-validators";
|
|
9
|
+
import { agyAcpUnattendedTargetIssues } from "../../config/schema/agy-acp-references";
|
|
9
10
|
import { compactionRecoverySchema } from "../../config/schema/compaction-recovery";
|
|
10
11
|
import { mainAccountHardLockFallbackSchema } from "../../config/schema/main-account-hard-lock-fallback";
|
|
11
12
|
import { anthropicSidecarPatchError } from "../../config/schema/anthropic-account-pool";
|
|
@@ -342,7 +343,7 @@ export async function syncEnabledClientIntegrations(
|
|
|
342
343
|
}
|
|
343
344
|
|
|
344
345
|
if (stale()) return out;
|
|
345
|
-
const { refreshOwnedCatalogIntegrations } = await import("../../integrations/catalog-refresh");
|
|
346
|
+
const { catalogRefreshClientIds, refreshOwnedCatalogIntegrations } = await import("../../integrations/catalog-refresh");
|
|
346
347
|
const refreshOwned = deps.refreshOwnedCatalogIntegrations ?? refreshOwnedCatalogIntegrations;
|
|
347
348
|
out.push(...await refreshOwned({
|
|
348
349
|
models: async () => {
|
|
@@ -351,9 +352,7 @@ export async function syncEnabledClientIntegrations(
|
|
|
351
352
|
},
|
|
352
353
|
config,
|
|
353
354
|
port,
|
|
354
|
-
}, unattended
|
|
355
|
-
? ["mcode", "pi", "aside", "raycast", "omo", "commandcode", "droid", "opencode", "kilo", "qoder", "qoder-cn", "workbuddy", "workbuddy-ai", "hermes", "t3code"]
|
|
356
|
-
: ["mcode", "pi", "aside", "raycast", "omo", "cline", "commandcode", "droid", "opencode", "kilo", "qoder", "qoder-cn", "workbuddy", "workbuddy-ai", "hermes", "t3code"],
|
|
355
|
+
}, catalogRefreshClientIds(unattended ? "unattended" : "serverSync"),
|
|
357
356
|
...unattended ? [{ refreshOnly: true, admit }] as const : []));
|
|
358
357
|
|
|
359
358
|
return out;
|
|
@@ -705,6 +704,15 @@ async function handleConfigRoutesImpl(ctx: ManagementContext): Promise<Response
|
|
|
705
704
|
let authlessIsEnabled = false, clientCompactionIsEnabled = false, fastRowsIsEnabled = false;
|
|
706
705
|
let desktopSwitchesChanged = false, fastRowsChanged = false, reserveIsEnabled = false, reserveChanged = false;
|
|
707
706
|
const refusal = await settleConfigRoot(configRoot(), () => {
|
|
707
|
+
if (memoryModels?.success || compactionRouting?.success) {
|
|
708
|
+
const issue = agyAcpUnattendedTargetIssues({
|
|
709
|
+
...config,
|
|
710
|
+
...(memoryModels?.success ? { memoryModels: memoryModels.data } : {}),
|
|
711
|
+
...(compactionRouting?.success ? { compactionRouting: compactionRouting.data } : {}),
|
|
712
|
+
}).find(({ path }) => (path[0] === "memoryModels" && memoryModels?.success)
|
|
713
|
+
|| (path[0] === "compactionRouting" && compactionRouting?.success));
|
|
714
|
+
if (issue) return jsonResponse({ error: `${issue.path.join(".")}: ${issue.message}` }, 400);
|
|
715
|
+
}
|
|
708
716
|
if (hardLockThresholds) {
|
|
709
717
|
hardLockThresholds = { ...config.codexMainAccountHardLockThresholds, ...hardLockThresholds };
|
|
710
718
|
const defaults = resolveMainAccountHardLockThresholds(undefined);
|
|
@@ -175,6 +175,8 @@ export interface ManagementApiDeps {
|
|
|
175
175
|
revokeApiKey?: (config: OcxConfig, id: string) => boolean;
|
|
176
176
|
loadLinkCandidates?: () => Array<{ alias: string; source: "ssh_config" | "tailscale" }>;
|
|
177
177
|
resolveChildBinarySource?: typeof import("../../link/child-binary-source").resolveChildBinarySource;
|
|
178
|
+
/** Home, platform and state dir for the Antigravity gateway connectors; route tests point it at temp homes. */
|
|
179
|
+
gatewayClientContext?: () => import("../../integrations/gateway-clients").GatewayClientContext;
|
|
178
180
|
/** Bound public inference port, not the ingress receiving this management request. */
|
|
179
181
|
liveListenPort?: () => number | undefined;
|
|
180
182
|
now?: () => number;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dashboard and CLI routes that point Google's Antigravity clients (desktop app, `agy`)
|
|
3
|
+
* at this proxy. Adapter only: what is written, stashed and restored lives in
|
|
4
|
+
* `src/integrations/gateway-clients`. Auth and origin checks run before dispatch, so a
|
|
5
|
+
* mutation here is gated like every other management POST.
|
|
6
|
+
*/
|
|
7
|
+
import { GATEWAY_CLIENT_IDS, connectGatewayClient, gatewayActionBody, disconnectGatewayClient, gatewayClientsStatus, isGatewayClientId, productionGatewayClientContext, resolveGatewayTarget, type GatewayClientContext, type GatewayClientId } from "../../integrations/gateway-clients";
|
|
8
|
+
import { jsonResponse } from "../auth-cors";
|
|
9
|
+
import { readOptionalManagementJsonBody, rethrowManagementBodyTooLarge } from "./body";
|
|
10
|
+
import { managementInferencePort, type ManagementContext } from "./context";
|
|
11
|
+
|
|
12
|
+
const COLLECTION_PATH = "/api/gateway-clients";
|
|
13
|
+
const ACTION_PATH = /^\/api\/gateway-clients\/([^/]+)\/(connect|disconnect)$/;
|
|
14
|
+
|
|
15
|
+
function refusal(ctx: ManagementContext, status: number, code: string, message: string): Response {
|
|
16
|
+
return jsonResponse({ ok: false, code, message }, status, ctx.req, ctx.config);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async function connectModel(ctx: ManagementContext, id: GatewayClientId): Promise<{ model?: string } | Response> {
|
|
20
|
+
let body: unknown;
|
|
21
|
+
try { body = await readOptionalManagementJsonBody(ctx.req); } catch (error) {
|
|
22
|
+
rethrowManagementBodyTooLarge(error);
|
|
23
|
+
return refusal(ctx, 400, "invalid-body", "The request body must be a JSON object.");
|
|
24
|
+
}
|
|
25
|
+
if (body === null || typeof body !== "object" || Array.isArray(body)) return refusal(ctx, 400, "invalid-body", "The request body must be a JSON object.");
|
|
26
|
+
if (id === "agy" && Object.hasOwn(body, "model")) {
|
|
27
|
+
return refusal(ctx, 400, "invalid-body", "model is only supported by Antigravity connect.");
|
|
28
|
+
}
|
|
29
|
+
const model = (body as { model?: unknown }).model;
|
|
30
|
+
if (model === undefined || model === null) return {};
|
|
31
|
+
if (typeof model !== "string") return refusal(ctx, 400, "invalid-body", "model must be a string.");
|
|
32
|
+
return { model };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export async function handleGatewayClientRoutes(ctx: ManagementContext): Promise<Response | null> {
|
|
36
|
+
const { req, url, config, deps } = ctx;
|
|
37
|
+
const clientCtx: GatewayClientContext = deps.gatewayClientContext?.() ?? productionGatewayClientContext();
|
|
38
|
+
if (url.pathname === "/api/gateway-clients" && req.method === "GET") {
|
|
39
|
+
const resolved = resolveGatewayTarget(config, managementInferencePort(ctx));
|
|
40
|
+
return jsonResponse({ clients: gatewayClientsStatus(clientCtx, resolved.ok ? resolved.target : undefined) }, 200, req, config);
|
|
41
|
+
}
|
|
42
|
+
const match = req.method === "POST" ? ACTION_PATH.exec(url.pathname) : null;
|
|
43
|
+
if (!match) return null;
|
|
44
|
+
const id = match[1]!;
|
|
45
|
+
if (!isGatewayClientId(id)) {
|
|
46
|
+
return refusal(ctx, 404, "unknown-client", `Unknown gateway client "${id.slice(0, 40)}". Known: ${GATEWAY_CLIENT_IDS.join(", ")}.`);
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
if (match[2] === "disconnect") {
|
|
50
|
+
const resolved = resolveGatewayTarget(config, managementInferencePort(ctx));
|
|
51
|
+
const outcome = disconnectGatewayClient(id, clientCtx, resolved.ok ? resolved.target : undefined);
|
|
52
|
+
return jsonResponse(gatewayActionBody(outcome), outcome.ok ? 200 : 409, req, config);
|
|
53
|
+
}
|
|
54
|
+
const parsed = await connectModel(ctx, id);
|
|
55
|
+
if (parsed instanceof Response) return parsed;
|
|
56
|
+
const outcome = connectGatewayClient(id, clientCtx, config, managementInferencePort(ctx), parsed.model);
|
|
57
|
+
return jsonResponse(gatewayActionBody(outcome), outcome.ok ? 200 : 409, req, config);
|
|
58
|
+
} catch (error) {
|
|
59
|
+
rethrowManagementBodyTooLarge(error);
|
|
60
|
+
return refusal(ctx, 409, "io-error", `Could not update the client files: ${error instanceof Error ? error.message : String(error)}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -746,6 +746,11 @@ async function handleJournalDelete(ctx: ManagementContext): Promise<Response> {
|
|
|
746
746
|
}
|
|
747
747
|
|
|
748
748
|
export async function handleIntegrationRoutes(ctx: ManagementContext): Promise<Response | null> {
|
|
749
|
+
// The Antigravity app and agy CLI connectors are only read by their dashboard tab and CLI; load on demand.
|
|
750
|
+
if (ctx.url.pathname === "/api/gateway-clients" || ctx.url.pathname.startsWith("/api/gateway-clients/")) {
|
|
751
|
+
const { handleGatewayClientRoutes } = await import("./gateway-client-routes");
|
|
752
|
+
return handleGatewayClientRoutes(ctx);
|
|
753
|
+
}
|
|
749
754
|
// Aside delegates before the ordinary client handler. Reject unsupported intent before that
|
|
750
755
|
// delegation can enumerate profiles, load catalogs, or write a different preference.
|
|
751
756
|
let asideBody: unknown;
|
|
@@ -13,7 +13,7 @@ import { loadHostCandidates } from "../../link/ssh-config";
|
|
|
13
13
|
import { effectiveLinkRoutes, newLinkId, type LinkStore } from "../../link/store";
|
|
14
14
|
import { claimLinkRetirement, clearLinkRetirement, disownLinkRetirement, readLinkRetirement, reownLinkRetirement, type LinkRetirement, type LinkRetirementMode } from "../../link/retirement";
|
|
15
15
|
import { sshFailureHint, sshRunnerErrorHint } from "../../link/ssh-runner";
|
|
16
|
-
import { attachLinkPeers, attachLinkRoutes, attachLinkTransport, attachLinkTunnelDiagnostics, projectLinkStatus, type LinkStatusDto } from "../../link/status-projection";
|
|
16
|
+
import { attachLinkPeers, attachLinkRelayHealth, attachLinkRoutes, attachLinkTransport, attachLinkTunnelDiagnostics, projectLinkStatus, type LinkStatusDto } from "../../link/status-projection";
|
|
17
17
|
import { homeLinkChildParity } from "../../link/child-parity";
|
|
18
18
|
import { codexSettingsDigest, projectHomeCodexSettings } from "../../link/codex-settings";
|
|
19
19
|
import { localLinkPeer } from "../../link/compatibility";
|
|
@@ -776,6 +776,10 @@ export async function handleLinkRoutes(ctx: ManagementContext, suppliedState?: L
|
|
|
776
776
|
}
|
|
777
777
|
// The same opt-in for each Home-initiated tunnel's retry progress and last failure cause.
|
|
778
778
|
if (url.searchParams.get("diagnostics") === "1") attachLinkTunnelDiagnostics(dto, supervisorStates);
|
|
779
|
+
if (url.searchParams.get("relayHealth") === "1") {
|
|
780
|
+
const now = (ctx.deps.now ?? Date.now)();
|
|
781
|
+
attachLinkRelayHealth(dto, id => state.supervisor.connectionGeneration?.(id), id => state.listener.linkActivity?.(id, now));
|
|
782
|
+
}
|
|
779
783
|
// The same opt-in for the route each multi-route link uses and why the others rest.
|
|
780
784
|
if (url.searchParams.get("routes") === "1") attachLinkRoutes(dto, supervisorStates);
|
|
781
785
|
// The same opt-in for each row's live link WebSocket counters and hold count (design 9.3).
|