@bitkyc08/opencodex 2.93.0 → 2.95.0
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 +27 -8
- package/bin/ocx.mjs +215 -63
- package/gui/dist/assets/App-8yedBkhm.js +58 -0
- package/gui/dist/assets/App-B4j-Txmb.css +1 -0
- package/gui/dist/assets/Tray-erSMzxPG.js +1 -0
- package/gui/dist/assets/index-CHWwDo9L.css +1 -0
- package/gui/dist/assets/index-D7DCm5eQ.js +94 -0
- package/gui/dist/assets/quota-summary-BK4VuQNc.js +1 -0
- package/gui/dist/index.html +2 -2
- package/gui/dist/provider-icons/t3code.svg +4 -0
- package/package.json +7 -4
- package/src/adapters/anthropic/account-metadata.ts +34 -3
- package/src/adapters/anthropic/beta-allowlist.ts +5 -5
- package/src/adapters/anthropic/passthrough.ts +5 -2
- package/src/adapters/anthropic.ts +27 -7
- package/src/adapters/antigravity-refusal.ts +29 -0
- package/src/adapters/base.ts +11 -1
- package/src/adapters/client-fingerprint.ts +43 -9
- package/src/adapters/coding-agent/protocol.ts +19 -9
- package/src/adapters/command-code-project-context.ts +3 -3
- package/src/adapters/command-code.ts +4 -5
- package/src/adapters/cursor/catalog.ts +5 -3
- package/src/adapters/cursor/claude-id.ts +30 -19
- package/src/adapters/cursor/cursor-errors.ts +5 -2
- package/src/adapters/cursor/h2-pool.ts +9 -7
- package/src/adapters/cursor/http1-bidi.ts +1 -0
- package/src/adapters/cursor/live-models.ts +4 -2
- package/src/adapters/cursor.ts +4 -1
- package/src/adapters/devin/cloud-direct/chat.ts +18 -2
- package/src/adapters/google-antigravity-replay.ts +13 -2
- package/src/adapters/google-antigravity-wire.ts +8 -3
- package/src/adapters/google-errors.ts +33 -0
- package/src/adapters/google-http.ts +41 -16
- package/src/adapters/google-wire-compiler.ts +4 -0
- package/src/adapters/google.ts +21 -10
- package/src/adapters/kiro/adapter.ts +7 -1
- package/src/adapters/kiro/stream.ts +19 -13
- package/src/adapters/kiro-events.ts +1 -0
- package/src/adapters/openai-chat/completed-tool-blocks.ts +65 -0
- package/src/adapters/openai-chat/messages.ts +42 -17
- package/src/adapters/openai-chat/passthrough.ts +4 -2
- package/src/adapters/openai-chat/required-tool-result.ts +3 -3
- package/src/adapters/openai-chat/serialized-tool-call-content.ts +5 -0
- package/src/adapters/openai-chat/single-system.ts +24 -0
- package/src/adapters/openai-chat/wire.ts +9 -0
- package/src/adapters/openai-chat.ts +18 -17
- package/src/adapters/openai-responses/image-gen.ts +15 -1
- package/src/adapters/openai-responses/muse-tool-catalog.ts +87 -0
- package/src/adapters/openai-responses/passthrough.ts +53 -41
- package/src/adapters/openai-responses/prompt-cache.ts +3 -1
- package/src/adapters/openai-responses/request-strips.ts +23 -4
- package/src/adapters/openai-responses/tool-output-recovery.ts +21 -8
- package/src/adapters/openai-responses/tool-schema.ts +20 -8
- package/src/adapters/openai-responses/transport.ts +20 -2
- package/src/adapters/openai-responses/usage.ts +34 -0
- package/src/adapters/opencode-go-additional-tools.ts +39 -6
- package/src/adapters/qoder/adapter.ts +9 -15
- package/src/adapters/qoder/image-input.ts +52 -0
- package/src/adapters/routed-agent-messages.ts +3 -0
- package/src/adapters/unique-tool-call-ids.ts +2 -2
- package/src/adapters/xai-web-search.ts +6 -3
- package/src/adapters/zed-additional-tools.ts +51 -0
- package/src/adapters/zed-diagnostic-usage.ts +22 -0
- package/src/adapters/zed-json-tokens.ts +166 -0
- package/src/adapters/zed-openai-stream.ts +723 -0
- package/src/adapters/zed-tool-arguments.ts +79 -0
- package/src/adapters/zed.ts +48 -3
- package/src/advisor/consult.ts +39 -5
- package/src/advisor/runtime.ts +12 -3
- package/src/bridge/errors.ts +22 -1
- package/src/bridge/max-output-completion.ts +41 -0
- package/src/bridge/response-json.ts +13 -5
- package/src/bridge/sse.ts +34 -14
- package/src/chat/inbound.ts +13 -2
- package/src/chatgpt/app-server-shim/bundle-trust-async.ts +111 -0
- package/src/chatgpt/app-server-shim/bundle-trust-policy.ts +88 -0
- package/src/chatgpt/app-server-shim/bundle-trust.ts +15 -72
- package/src/chatgpt/app-server-shim/launcher.ts +40 -6
- package/src/claude/compatibility.ts +5 -1
- package/src/claude/desktop-3p.ts +27 -6
- package/src/claude/desktop-first-party.ts +16 -5
- package/src/claude/desktop-gateway-state.ts +4 -0
- package/src/claude/desktop-model-visibility.ts +141 -0
- package/src/claude/desktop-remote-store-io.ts +8 -8
- package/src/claude/inbound-content-options.ts +11 -1
- package/src/claude/inbound-tool-loading.ts +93 -0
- package/src/claude/intercept/picker-listener.ts +33 -1
- package/src/claude/intercept/proxy-auth.ts +16 -16
- package/src/claude/model-info.ts +29 -4
- package/src/claude/outbound.ts +33 -13
- package/src/cli/account-main.ts +44 -5
- package/src/cli/capabilities-base.ts +22 -5
- package/src/cli/capabilities-integrations.ts +4 -4
- package/src/cli/capabilities-provider-models.ts +7 -0
- package/src/cli/chatgpt-command.ts +1 -1
- package/src/cli/claude-desktop.ts +139 -98
- package/src/cli/codex-cli-update.ts +102 -48
- package/src/cli/codex-launch-auth.ts +93 -0
- package/src/cli/codex-launch-command.ts +32 -0
- package/src/cli/codex-launch-diagnostics.ts +37 -0
- package/src/cli/codex-launch-ownership.ts +307 -0
- package/src/cli/codex-launch-policy.ts +84 -0
- package/src/cli/codex-launcher.ts +322 -0
- package/src/cli/codex-shim-autorestore.ts +21 -1
- package/src/cli/config-command.ts +9 -4
- package/src/cli/config-mutation.ts +13 -0
- package/src/cli/dispatch.ts +19 -13
- package/src/cli/doctor.ts +5 -5
- package/src/cli/effort.ts +19 -14
- package/src/cli/ensure-desired-integrations.ts +21 -14
- package/src/cli/ensure-desktop-cold-start.ts +41 -10
- package/src/cli/export-command.ts +8 -4
- package/src/cli/help.ts +3 -1
- package/src/cli/index.ts +62 -73
- package/src/cli/init.ts +2 -2
- package/src/cli/integration-input.ts +12 -0
- package/src/cli/integration-plan-dto.ts +2 -0
- package/src/cli/integration-preview.ts +6 -3
- package/src/cli/integrations.ts +2 -1
- package/src/cli/internal-command.ts +29 -2
- package/src/cli/link-cleanup.ts +8 -23
- package/src/cli/link-enrollment.ts +1 -4
- package/src/cli/link.ts +1 -1
- package/src/cli/loopback-family.ts +2 -31
- package/src/cli/models.ts +62 -49
- package/src/cli/provider-cc-switch-import.ts +185 -0
- package/src/cli/provider.ts +151 -139
- package/src/cli/registry.ts +35 -3
- package/src/cli/restart-scope.ts +2 -2
- package/src/cli/root.ts +8 -6
- package/src/cli/start-owner-fence.ts +22 -3
- package/src/cli/status-link.ts +28 -0
- package/src/cli/status.ts +15 -0
- package/src/cli/stop-approval.ts +15 -1
- package/src/cli/stop-restore-guard.ts +48 -0
- package/src/cli/stop-restore.ts +117 -36
- package/src/cli/system-command.ts +2 -0
- package/src/cli/v2.ts +86 -23
- package/src/client/lifecycle-lock.ts +1 -1
- package/src/client/link-connection.ts +19 -0
- package/src/client/link-relay-transport.ts +25 -3
- package/src/client/link-tunnel.ts +10 -0
- package/src/client/machine-api.ts +2 -2
- package/src/client/machine-listener.ts +7 -1
- package/src/client/restore-ownership.ts +45 -0
- package/src/client/runtime.ts +13 -1
- package/src/client/state.ts +1 -1
- package/src/clients/client-ids.ts +7 -0
- package/src/clients/client-path.ts +13 -5
- package/src/clients/config-export/agent-clients.ts +3 -6
- package/src/clients/config-export/alias-selectors.ts +85 -0
- package/src/clients/config-export/contracts.ts +6 -25
- package/src/clients/config-export/dsh.ts +8 -1
- package/src/clients/config-export/model-metadata.ts +19 -0
- package/src/clients/config-export/model-names.ts +31 -0
- package/src/clients/config-export/qoder.ts +3 -11
- package/src/clients/config-export/t3code.ts +141 -0
- package/src/clients/config-export.ts +65 -18
- package/src/clients/gentle-shell-path.ts +3 -3
- package/src/codex/account-cooldown-response.ts +18 -0
- package/src/codex/account-lifecycle.ts +27 -13
- package/src/codex/account-store.ts +32 -6
- package/src/codex/app-server-processes.ts +84 -1
- package/src/codex/app-server-restart-service.ts +2 -2
- package/src/codex/auth-api/login-flow.ts +2 -2
- package/src/codex/auth-api/main-account-probe.ts +50 -11
- package/src/codex/auth-api/pool-mode-gate.ts +16 -8
- package/src/codex/auth-api/pool-quota-probe.ts +2 -2
- package/src/codex/auth-context.ts +49 -8
- package/src/codex/catalog/antigravity-discovery.ts +59 -0
- package/src/codex/catalog/build-entries.ts +12 -13
- package/src/codex/catalog/bundled.ts +67 -10
- package/src/codex/catalog/derive-entry.ts +2 -0
- package/src/codex/catalog/gather-capture.ts +3 -0
- package/src/codex/catalog/metadata.ts +10 -10
- package/src/codex/catalog/model-hints.ts +36 -4
- package/src/codex/catalog/native-omission.ts +28 -0
- package/src/codex/catalog/native-priority.ts +63 -0
- package/src/codex/catalog/native-template.ts +58 -0
- package/src/codex/catalog/parsing.ts +3 -29
- package/src/codex/catalog/provider-models.ts +22 -5
- package/src/codex/catalog/retained-sync.ts +16 -6
- package/src/codex/catalog/write-audit.ts +18 -18
- package/src/codex/chatgpt-refresh-failure.ts +2 -2
- package/src/codex/cli-install-provenance.ts +103 -74
- package/src/codex/cli-installation-identity.ts +1 -1
- package/src/codex/cli-installation-limits.ts +7 -0
- package/src/codex/cli-update-apply.ts +391 -0
- package/src/codex/cli-update-artifacts.ts +259 -0
- package/src/codex/cli-update-files.ts +100 -0
- package/src/codex/cli-update-inspection-context.ts +49 -0
- package/src/codex/cli-update-job-execution.ts +77 -0
- package/src/codex/cli-update-job-store-windows.ts +1082 -0
- package/src/codex/cli-update-job-worker.ts +385 -0
- package/src/codex/cli-update-job.ts +369 -0
- package/src/codex/cli-update-lease.ts +71 -0
- package/src/codex/cli-update-paths.ts +76 -0
- package/src/codex/cli-update-plan.ts +180 -47
- package/src/codex/cli-update-recovery.ts +282 -0
- package/src/codex/cli-update-selection-gate.ts +305 -0
- package/src/codex/cli-update-windows-apply.ts +308 -0
- package/src/codex/cli-update-windows-layout.ts +110 -0
- package/src/codex/cli-update-windows-observation.ts +91 -0
- package/src/codex/cli-update-windows-paths.ts +26 -0
- package/src/codex/cli-update-worker-recovery.ts +32 -0
- package/src/codex/cli-update-worker.ts +185 -0
- package/src/codex/cli-windows-plan-provenance.ts +268 -0
- package/src/codex/codex-home-owner.ts +9 -8
- package/src/codex/convergence.ts +13 -3
- package/src/codex/coordinator-doctor.ts +14 -8
- package/src/codex/desktop-app/handoff.ts +1 -1
- package/src/codex/desktop-app-restart.ts +32 -3
- package/src/codex/exec-boundary.ts +229 -0
- package/src/codex/forward-transport-headers.ts +80 -0
- package/src/codex/history-job.ts +7 -0
- package/src/codex/history-provider.ts +16 -12
- package/src/codex/history-worker.ts +20 -1
- package/src/codex/inject/bounded-config-reader.ts +14 -13
- package/src/codex/inject/restore.ts +57 -25
- package/src/codex/internal/history-writer.ts +2 -1
- package/src/codex/mac-app-bundle.ts +52 -0
- package/src/codex/main-account.ts +167 -29
- package/src/codex/native-main-auth-temp.ts +3 -2
- package/src/codex/native-main-lock-file.ts +13 -12
- package/src/codex/native-main-refresh-mode.ts +18 -3
- package/src/codex/native-profile-manager.ts +8 -6
- package/src/codex/native-profile-store.ts +9 -0
- package/src/codex/native-residue.ts +18 -14
- package/src/codex/ocx-compaction-history.ts +3 -2
- package/src/codex/orca-auth-source.ts +8 -7
- package/src/codex/prompt-text-probe.ts +211 -69
- package/src/codex/quota-types.ts +5 -0
- package/src/codex/quota.ts +58 -7
- package/src/codex/role-auto-assign.ts +50 -26
- package/src/codex/role-capability.ts +160 -0
- package/src/codex/role-model-history.ts +253 -0
- package/src/codex/role-sizing.ts +24 -6
- package/src/codex/routing/cooldown-math.ts +3 -2
- package/src/codex/runtime.ts +161 -72
- package/src/codex/shim-fingerprint.ts +11 -9
- package/src/codex/shim-inspect.ts +3 -2
- package/src/codex/shim-overlay.ts +22 -3
- package/src/codex/shim-restore-lock.ts +11 -14
- package/src/codex/shim-state-file.ts +22 -14
- package/src/codex/shim-templates.ts +5 -2
- package/src/codex/shim-wrapper-write.ts +137 -0
- package/src/codex/shim.ts +48 -126
- package/src/codex/transition-state.ts +5 -4
- package/src/codex/windows-cli-child-native.ts +119 -0
- package/src/codex/windows-cli-child-pipe.ts +87 -0
- package/src/codex/windows-cli-child.ts +260 -0
- package/src/codex/windows-cli-recovery-guardian.ts +89 -0
- package/src/codex/windows-cli-recovery.ts +39 -0
- package/src/codex/windows-installation-files.ts +52 -6
- package/src/codex/windows-npm-execution.ts +25 -0
- package/src/combos/failover.ts +127 -9
- package/src/combos/index.ts +1 -0
- package/src/combos/resolve.ts +60 -22
- package/src/config/atomic-write.ts +113 -29
- package/src/config/diagnostics.ts +21 -10
- package/src/config/initialize.ts +6 -6
- package/src/config/live-reconcile.ts +11 -3
- package/src/config/load-degrade.ts +2 -0
- package/src/config/owner-registry.ts +5 -4
- package/src/config/persist-unlocked.ts +34 -8
- package/src/config/persisted-mutation.ts +7 -0
- package/src/config/process-state.ts +32 -10
- package/src/config/removed-opencode-free-backup.ts +99 -0
- package/src/config/removed-opencode-free.ts +4 -8
- package/src/config/salvage.ts +2 -0
- package/src/config/schema/config-schema.ts +44 -1
- package/src/config/schema/leaf-validators.ts +22 -0
- package/src/config/schema/workflow-budget.ts +43 -0
- package/src/config/tracked-runtime-inspection.ts +188 -0
- package/src/config.ts +4 -4
- package/src/generated/compatibility-version.json +962 -434
- package/src/grok/inject.ts +2 -1
- package/src/grok/sync.ts +5 -2
- package/src/images/loop.ts +14 -5
- package/src/integrations/aside-profile-context.ts +1 -1
- package/src/integrations/catalog-refresh.ts +1 -1
- package/src/integrations/droid-settings.ts +4 -4
- package/src/integrations/hermes-profiles.ts +3 -3
- package/src/integrations/hermes-refresh.ts +28 -0
- package/src/integrations/model-name-guard.ts +31 -0
- package/src/integrations/mutation-plan.ts +17 -4
- package/src/integrations/ownership.ts +3 -0
- package/src/integrations/registry.ts +10 -1
- package/src/integrations/state.ts +6 -0
- package/src/integrations/writer.ts +64 -59
- package/src/lib/abort.ts +8 -4
- package/src/lib/bounded-body.ts +7 -1
- package/src/lib/bounded-file-read.ts +3 -9
- package/src/lib/bun-runtime-preflight.ts +9 -8
- package/src/lib/config-ownership.ts +4 -0
- package/src/lib/errors.ts +2 -0
- package/src/lib/eventstream-decoder.ts +3 -2
- package/src/lib/file-identity.ts +15 -0
- package/src/lib/http-response-semantics.ts +9 -6
- package/src/lib/inbound-body-policy.ts +11 -0
- package/src/lib/jsonc.ts +7 -2
- package/src/lib/local-chat-completion.ts +8 -6
- package/src/lib/local-destinations.ts +32 -3
- package/src/lib/local-management-capability.ts +3 -1
- package/src/lib/local-upstream.ts +22 -26
- package/src/lib/loopback-family.ts +31 -0
- package/src/lib/plain-data.ts +7 -5
- package/src/lib/process-control.ts +30 -5
- package/src/lib/redact-folding.ts +9 -0
- package/src/lib/shadow-call.ts +55 -1
- package/src/lib/spend-pool-alias-validation.ts +6 -6
- package/src/lib/state-store-registrations.ts +2 -0
- package/src/lib/test-home-guard.ts +37 -9
- package/src/lib/tool-argument-integers.ts +99 -7
- package/src/lib/upstream-retry.ts +6 -1
- package/src/lib/windows-elevation.ts +34 -11
- package/src/lib/windows-owner-acl.ts +272 -32
- package/src/lib/windows-secret-acl.ts +328 -44
- package/src/lib/windows-service-wrappers.ts +10 -7
- package/src/lib/winsw.ts +8 -4
- package/src/lib/workflow-budget-config.ts +39 -0
- package/src/link/relay-auth.ts +38 -1
- package/src/link/remote-platform.ts +11 -23
- package/src/link/remote-probe.ts +3 -1
- package/src/link/remote-windows.ts +150 -0
- package/src/link/ssh-argv.ts +13 -5
- package/src/link/store.ts +4 -1
- package/src/link/supervisor.ts +9 -0
- package/src/local-credentials/generation.ts +242 -0
- package/src/local-credentials/inventory.ts +405 -0
- package/src/local-credentials/observation-lease.ts +83 -0
- package/src/local-credentials/publication-fence.ts +81 -0
- package/src/local-credentials/references.ts +36 -0
- package/src/local-credentials/runtime-observation.ts +28 -0
- package/src/messaging/remote-forward-failure.ts +35 -0
- package/src/messaging/remote-ports.ts +27 -5
- package/src/messaging/remote-process.ts +30 -4
- package/src/messaging/remote-tunnels.ts +80 -15
- package/src/oauth/account-auto-pause-policy.ts +11 -0
- package/src/oauth/anthropic-account-refusal.ts +1 -0
- package/src/oauth/anthropic-rate-limit-policy.ts +26 -2
- package/src/oauth/anthropic-routing.ts +34 -44
- package/src/oauth/anthropic-session-affinity-store.ts +177 -0
- package/src/oauth/antigravity-discovery-diagnostics.ts +65 -0
- package/src/oauth/chatgpt.ts +11 -9
- package/src/oauth/cursor.ts +8 -2
- package/src/oauth/generic-account-failover.ts +33 -2
- package/src/oauth/generic-session-affinity.ts +7 -0
- package/src/oauth/google-antigravity.ts +49 -12
- package/src/oauth/index.ts +3 -0
- package/src/oauth/kiro-device-login.ts +87 -30
- package/src/oauth/kiro-iam-identity-center.ts +107 -0
- package/src/oauth/store.ts +41 -11
- package/src/protocols/encoders/adapter-events.ts +7 -4
- package/src/protocols/encoders/messages.ts +1 -1
- package/src/providers/account-quota-disk.ts +18 -4
- package/src/providers/antigravity-account-roster.ts +73 -7
- package/src/providers/antigravity-models.ts +8 -4
- package/src/providers/api-key-resolve.ts +16 -3
- package/src/providers/cc-switch-import-bytes.ts +991 -0
- package/src/providers/cc-switch-import-source.ts +1083 -0
- package/src/providers/cc-switch-import.ts +942 -0
- package/src/providers/claude-cli-identity.ts +2 -0
- package/src/providers/codex-capacity.ts +3 -2
- package/src/providers/derive.ts +6 -0
- package/src/providers/free-directory.ts +10 -2
- package/src/providers/key-store.ts +7 -2
- package/src/providers/model-discovery-diagnostic.ts +4 -0
- package/src/providers/model-discovery.ts +4 -4
- package/src/providers/model-rename-fields.ts +2 -0
- package/src/providers/model-rename-migration.ts +41 -6
- package/src/providers/provider-id-rewrite.ts +3 -0
- package/src/providers/quota/antigravity.ts +6 -4
- package/src/providers/quota/report-cache.ts +17 -4
- package/src/providers/quota/vendor-probes-oauth.ts +0 -1
- package/src/providers/quota.ts +2 -2
- package/src/providers/reasoning-metadata.ts +31 -15
- package/src/providers/registry/entries-core.ts +1 -1
- package/src/providers/registry/entries-extended.ts +1 -1
- package/src/providers/registry/model-ids.ts +1 -0
- package/src/providers/registry/model-seeds.ts +2 -1
- package/src/providers/registry/types.ts +3 -1
- package/src/providers/resolved-model-policy.ts +2 -2
- package/src/providers/routed-config.ts +2 -0
- package/src/providers/stale-model-roster-migration.ts +8 -1
- package/src/providers/xai-transport.ts +4 -4
- package/src/quota-pool/assemble.ts +51 -21
- package/src/quota-pool/pooled.ts +162 -0
- package/src/remote-control/workspace-codex-runtime.ts +63 -20
- package/src/remote-control/workspace-executor.ts +14 -13
- package/src/responses/apply-patch-envelope.ts +35 -0
- package/src/responses/compaction-history-framing.ts +15 -4
- package/src/responses/custom-tool-compat.ts +2 -1
- package/src/responses/item-provenance.ts +79 -0
- package/src/responses/namespace-tool-compat.ts +21 -3
- package/src/responses/turn-membership.ts +111 -0
- package/src/router.ts +21 -2
- package/src/routing/analytics.ts +3 -5
- package/src/routing/fallback-policy.ts +7 -3
- package/src/routing/health.ts +5 -3
- package/src/routing/history/build-file.ts +6 -0
- package/src/routing/history/indexer.ts +158 -31
- package/src/routing/history/ingest.ts +1 -1
- package/src/routing/history/integrity.ts +208 -0
- package/src/routing/history/rebuild-job.ts +20 -6
- package/src/routing/history/rebuild-protocol.ts +2 -1
- package/src/routing/history/rebuild-worker.ts +18 -0
- package/src/routing/history/sqlite-errors.ts +9 -0
- package/src/server/admission-model-scope.ts +21 -4
- package/src/server/advisor-admission-scope.ts +72 -0
- package/src/server/audio-upstream.ts +10 -2
- package/src/server/auth-cors.ts +28 -2
- package/src/server/bind-host.ts +5 -0
- package/src/server/capture-admission-policy.ts +91 -0
- package/src/server/chat-completions.ts +47 -6
- package/src/server/chat-native.ts +16 -11
- package/src/server/claude-messages.ts +99 -3
- package/src/server/codex-model-list.ts +47 -0
- package/src/server/configured-credentials.ts +5 -0
- package/src/server/gui-session.ts +5 -2
- package/src/server/inbound-body-admission.ts +21 -13
- package/src/server/inbound-body-budget.ts +128 -0
- package/src/server/index/link-listener.ts +3 -1
- package/src/server/index/link-relay-sessions.ts +9 -2
- package/src/server/index/optional-listeners.ts +1 -0
- package/src/server/index/serve-options.ts +21 -45
- package/src/server/index/websocket-handler.ts +10 -0
- package/src/server/index.ts +6 -5
- package/src/server/inference/client-encoder-delivery.ts +3 -1
- package/src/server/lifecycle.ts +8 -1
- package/src/server/management/advisor-routes.ts +26 -9
- package/src/server/management/agent-settings-routes.ts +455 -549
- package/src/server/management/anthropic-reset-grant-routes.ts +2 -1
- package/src/server/management/claude-code-settings-patch.ts +211 -0
- package/src/server/management/claude-desktop-config-writers.ts +78 -0
- package/src/server/management/codex-agent-role-routes.ts +80 -2
- package/src/server/management/codex-cli-update-routes.ts +55 -0
- package/src/server/management/codex-prompt-routes.ts +2 -1
- package/src/server/management/codex-role-auto-assign.ts +50 -6
- package/src/server/management/config-routes.ts +459 -384
- package/src/server/management/consent-session.ts +6 -0
- package/src/server/management/context.ts +3 -0
- package/src/server/management/desktop-compatibility-authorization.ts +12 -0
- package/src/server/management/desktop-compatibility-routes.ts +3 -2
- package/src/server/management/desktop-compatibility-runtime-routes.ts +2 -1
- package/src/server/management/desktop-compatibility-settings-routes.ts +2 -1
- package/src/server/management/integration-routes.ts +45 -5
- package/src/server/management/link-enrollment.ts +21 -32
- package/src/server/management/link-route-state.ts +1 -0
- package/src/server/management/link-routes.ts +4 -1
- package/src/server/management/model-routes.ts +22 -6
- package/src/server/management/model-rows.ts +3 -1
- package/src/server/management/native-integration-routes.ts +112 -38
- package/src/server/management/oauth-account-routes.ts +28 -11
- package/src/server/management/provider-overwrite-carry.ts +21 -0
- package/src/server/management/provider-routes.ts +3 -1
- package/src/server/management/route-registry.ts +10 -3
- package/src/server/management/session-routes.ts +20 -2
- package/src/server/management/shadow-call-validation.ts +43 -2
- package/src/server/management/shared.ts +17 -1
- package/src/server/management/sidebar-routes.ts +2 -1
- package/src/server/management/system-restart.ts +47 -7
- package/src/server/management/workflow-budget-routes.ts +70 -3
- package/src/server/management-api.ts +61 -51
- package/src/server/management-auth.ts +11 -3
- package/src/server/messages-native-eligibility.ts +6 -5
- package/src/server/messages-native-scope.ts +6 -1
- package/src/server/messages-native.ts +21 -7
- package/src/server/messages-shared.ts +161 -29
- package/src/server/persistent-gui-session.ts +155 -0
- package/src/server/port-reclaim.ts +29 -5
- package/src/server/proxy-liveness.ts +110 -33
- package/src/server/request-decompress.ts +5 -1
- package/src/server/request-log.ts +30 -2
- package/src/server/responses/account-change-state.ts +14 -2
- package/src/server/responses/adapter-continuation.ts +5 -4
- package/src/server/responses/adapter-delivery.ts +24 -5
- package/src/server/responses/adapter-dispatch.ts +39 -45
- package/src/server/responses/advisor-plan-slot.ts +7 -0
- package/src/server/responses/advisor-slot.ts +77 -48
- package/src/server/responses/antigravity-model-denial-recovery.ts +70 -0
- package/src/server/responses/antigravity-validation-refusal.ts +6 -0
- package/src/server/responses/codex-auth-error.ts +5 -1
- package/src/server/responses/combo-required-tool-contract.ts +29 -1
- package/src/server/responses/combo-required-tool-fulfillments.ts +58 -0
- package/src/server/responses/combo-required-tool-stream.ts +119 -0
- package/src/server/responses/combo-stream-preflight.ts +47 -7
- package/src/server/responses/compact.ts +18 -8
- package/src/server/responses/compaction-recovery.ts +2 -1
- package/src/server/responses/core-auth.ts +2 -1
- package/src/server/responses/core-codex-account.ts +1 -0
- package/src/server/responses/core-combo-failure.ts +13 -6
- package/src/server/responses/core-combo-native.ts +6 -5
- package/src/server/responses/core-combo.ts +159 -25
- package/src/server/responses/core-lifetime.ts +4 -0
- package/src/server/responses/core-options.ts +16 -0
- package/src/server/responses/core.ts +2 -0
- package/src/server/responses/fetch-helpers.ts +5 -1
- package/src/server/responses/jev-model-invoke.ts +10 -3
- package/src/server/responses/memory-models.ts +3 -2
- package/src/server/responses/passthrough-delivery.ts +36 -8
- package/src/server/responses/passthrough-dispatch.ts +17 -16
- package/src/server/responses/policy-fallback.ts +2 -0
- package/src/server/responses/request-prepare.ts +14 -6
- package/src/server/responses/request-send-budget.ts +2 -1
- package/src/server/responses/request-sidecar-auth.ts +1 -0
- package/src/server/responses/request-transport.ts +43 -9
- package/src/server/responses/run-turn-execution.ts +15 -3
- package/src/server/responses/sidecar-execution.ts +26 -5
- package/src/server/responses/turn-membership.ts +30 -0
- package/src/server/responses-custom-tool-repair.ts +86 -11
- package/src/server/responses-image-gen-repair.ts +1 -1
- package/src/server/responses-snapshot-repair.ts +18 -4
- package/src/server/responses-undeclared-tool-guard.ts +4 -0
- package/src/server/restart-parent-ownership.ts +49 -0
- package/src/server/stop-teardown.ts +46 -9
- package/src/server/windows-tcp-drop.ts +4 -2
- package/src/server/workflow-refusal.ts +2 -1
- package/src/service/desktop-recovery-process.ts +341 -0
- package/src/service/desktop-recovery.ts +172 -0
- package/src/service/state-lock.ts +12 -11
- package/src/service/windows-ops.ts +6 -3
- package/src/service/windows-scheduler.ts +29 -6
- package/src/service-manager-probe.ts +53 -8
- package/src/stall-timeout.ts +47 -0
- package/src/tray/windows.ts +6 -4
- package/src/types/admission-policy.ts +13 -0
- package/src/types/config.ts +86 -10
- package/src/types/provider.ts +10 -0
- package/src/types/request.ts +8 -1
- package/src/types.ts +2 -0
- package/src/update/async-check.ts +4 -3
- package/src/update/bind-probe.ts +2 -2
- package/src/update/codex-cli-update-launch-policy.mjs +9 -0
- package/src/update/guarded-port-reclaim.ts +14 -0
- package/src/update/guarded-runtime-ops.ts +58 -0
- package/src/update/guarded-tray-ops.ts +9 -0
- package/src/update/index.ts +196 -58
- package/src/update/job-pinned-start.ts +53 -0
- package/src/update/job-supervised-restart.ts +23 -6
- package/src/update/job-update-home.ts +62 -0
- package/src/update/job-update-tray.ts +29 -0
- package/src/update/job-windows-restart.ts +39 -0
- package/src/update/job.ts +199 -193
- package/src/update/mutation-guard.d.mts +30 -0
- package/src/update/mutation-guard.mjs +103 -0
- package/src/update/notify.ts +2 -2
- package/src/update/npm-cache-preflight.mjs +4 -4
- package/src/update/npm-install.mjs +5 -3
- package/src/update/pnpm-read-policy.mjs +3 -2
- package/src/update/proxy-liveness-probe.mjs +2 -2
- package/src/update/service-home-authority.ts +35 -0
- package/src/update/service-home-package-only-protocol.json +1 -0
- package/src/update/service-home-policy.d.mts +25 -0
- package/src/update/service-home-policy.mjs +112 -0
- package/src/update/service-home-probe-entry.ts +9 -0
- package/src/update/service-home-probe.d.mts +15 -0
- package/src/update/service-home-probe.mjs +79 -0
- package/src/update/service-home-protocol.json +1 -0
- package/src/update/supervised-recovery.d.mts +2 -2
- package/src/update/supervised-recovery.mjs +14 -7
- package/src/update/transactional-install.d.mts +3 -1
- package/src/update/transactional-install.mjs +29 -19
- package/src/update/update-failure-guidance.mjs +1 -1
- package/src/update/worker-launch.ts +74 -4
- package/src/usage/log.ts +25 -4
- package/src/vision/anthropic-describe.ts +2 -1
- package/src/vision/index.ts +2 -0
- package/src/vision/plan.ts +4 -0
- package/src/vision/routed-describe.ts +38 -23
- package/src/web-search/anthropic-executor.ts +2 -1
- package/src/web-search/anthropic-history.ts +1 -0
- package/src/web-search/format-result.ts +3 -2
- package/src/web-search/header-deadline.ts +3 -2
- package/src/web-search/loop.ts +113 -12
- package/src/web-search/parse.ts +201 -40
- package/gui/dist/assets/App-CizjBqyk.js +0 -58
- package/gui/dist/assets/App-DMps4OLk.css +0 -1
- package/gui/dist/assets/Tray-DamiMqcX.js +0 -1
- package/gui/dist/assets/index-DQsht3vH.js +0 -94
- package/gui/dist/assets/index-DRe8Hhfz.css +0 -1
- package/gui/dist/assets/quota-summary-BXu4zE8H.js +0 -1
|
@@ -254,6 +254,7 @@ export function requestLogDto(
|
|
|
254
254
|
): Record<string, unknown> {
|
|
255
255
|
return {
|
|
256
256
|
...entry,
|
|
257
|
+
...(entry.attemptNormalizationDropped === true ? { attemptNormalizationDropped: true } : {}),
|
|
257
258
|
...resendVerdict(entry),
|
|
258
259
|
displayMetrics: {
|
|
259
260
|
tokPerSecond: tokPerSecondResult(entry),
|
|
@@ -409,10 +410,14 @@ export async function buildClaudeDesktopState(config: OcxConfig, stored?: OcxCla
|
|
|
409
410
|
for (const id of desktopVisibleNativeSlugs(config)) {
|
|
410
411
|
effortByRoute.set(`native/${id}`, true);
|
|
411
412
|
}
|
|
413
|
+
const { desktopRouteVisible, filterDesktopModelsByVisibility, readDesktopModelVisibility } = await import("../../claude/desktop-model-visibility");
|
|
414
|
+
const visibility = readDesktopModelVisibility(config.claudeCode);
|
|
412
415
|
const models = Object.keys(profile.assignments).sort().map(route => ({
|
|
413
416
|
route,
|
|
414
417
|
label: modelByRoute.get(route)?.label ?? route,
|
|
415
418
|
available: available.has(route),
|
|
419
|
+
// Desktop list membership (#7702), separate from the tier assignment below.
|
|
420
|
+
visible: desktopRouteVisible(visibility, route),
|
|
416
421
|
...(modelByRoute.get(route)?.contextWindow ? { contextWindow: modelByRoute.get(route)!.contextWindow } : {}),
|
|
417
422
|
effortSupported: effortByRoute.get(route) ?? false,
|
|
418
423
|
// Read-only view of the 1M capability the written Desktop config already emits,
|
|
@@ -420,10 +425,21 @@ export async function buildClaudeDesktopState(config: OcxConfig, stored?: OcxCla
|
|
|
420
425
|
supports1m: routeSupportsOneMillion(route, modelByRoute.get(route)?.contextWindow),
|
|
421
426
|
assignment: profile.assignments[route]!,
|
|
422
427
|
}));
|
|
428
|
+
const rendered = renderDesktopProfile(profile, profileModels);
|
|
429
|
+
const selected = filterDesktopModelsByVisibility(
|
|
430
|
+
rendered.map(model => ({ ...model, anthropicFamilyTier: model.family })),
|
|
431
|
+
rendered.map(model => model.route),
|
|
432
|
+
visibility,
|
|
433
|
+
);
|
|
434
|
+
// Match the writer's empty-selection fallback without changing the saved intent.
|
|
435
|
+
const listed = selected.length > 0 ? selected : rendered;
|
|
423
436
|
return {
|
|
424
437
|
profile,
|
|
425
438
|
models,
|
|
426
|
-
rendered
|
|
439
|
+
rendered,
|
|
440
|
+
visibility: visibility ?? null,
|
|
441
|
+
// What the next apply writes, including generateDesktop3pModels' empty-selection fallback.
|
|
442
|
+
listed: listed.map(({ route, name, label, family, isFamilyDefault }) => ({ route, name, label, family, isFamilyDefault: !!isFamilyDefault })),
|
|
427
443
|
port: config.port,
|
|
428
444
|
};
|
|
429
445
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { hasHumanDashboardSession } from "./consent-session";
|
|
1
2
|
/**
|
|
2
3
|
* /api/github/star and /api/update/badge — the two cheap polls behind the
|
|
3
4
|
* sidebar's GitHub star and update controls.
|
|
@@ -40,7 +41,7 @@ import type { ManagementContext } from "./context";
|
|
|
40
41
|
* request an agent cannot fabricate, so that is what this now reads.
|
|
41
42
|
*/
|
|
42
43
|
function hasBrowserSessionEvidence(ctx: ManagementContext): boolean {
|
|
43
|
-
return ctx
|
|
44
|
+
return hasHumanDashboardSession(ctx);
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
// Known edge, deliberately fail-closed: a non-loopback operator dashboard that signs
|
|
@@ -61,6 +61,7 @@ import {
|
|
|
61
61
|
isDesktopSupervised,
|
|
62
62
|
} from "../../lib/system-restart-contract";
|
|
63
63
|
import { spawnReplacementStart } from "../restart-replacement";
|
|
64
|
+
import { retireRestartParentOwnership } from "../restart-parent-ownership";
|
|
64
65
|
|
|
65
66
|
export { MEMORY_DRAIN_RESTART_MS, REPLACEMENT_READY_TIMEOUT_MS } from "../../lib/system-restart-contract";
|
|
66
67
|
export { waitForReplacementReady, type ReplacementReadinessIo } from "../restart-replacement";
|
|
@@ -170,13 +171,31 @@ function waitForBoundedSettlement(
|
|
|
170
171
|
}
|
|
171
172
|
|
|
172
173
|
/**
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
174
|
+
* Accepted stops and signals permanently veto automatic handoff. Management requests carry
|
|
175
|
+
* separate temporary intents while teardown awaits, so a refusal can release its own intent
|
|
176
|
+
* without clearing another pending stop, an accepted stop, or a signal.
|
|
176
177
|
*/
|
|
177
178
|
let explicitShutdownRequested = false;
|
|
179
|
+
const pendingShutdownIntents = new Set<object>();
|
|
180
|
+
const shutdownIntentWaiters = new Set<() => void>();
|
|
181
|
+
function shutdownIntentChanged(): void {
|
|
182
|
+
const waiters = [...shutdownIntentWaiters];
|
|
183
|
+
shutdownIntentWaiters.clear();
|
|
184
|
+
for (const resolve of waiters) resolve();
|
|
185
|
+
}
|
|
186
|
+
function nextShutdownIntentChange(): Promise<void> {
|
|
187
|
+
return new Promise(resolve => { shutdownIntentWaiters.add(resolve); });
|
|
188
|
+
}
|
|
178
189
|
export function noteExplicitShutdownRequested(): void {
|
|
179
190
|
explicitShutdownRequested = true;
|
|
191
|
+
shutdownIntentChanged();
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** Veto automatic handoff while a stop is pending; release only this caller's intent. */
|
|
195
|
+
export function acquireExplicitShutdownIntent(): () => void {
|
|
196
|
+
const intent = {};
|
|
197
|
+
pendingShutdownIntents.add(intent);
|
|
198
|
+
return () => { if (pendingShutdownIntents.delete(intent)) shutdownIntentChanged(); };
|
|
180
199
|
}
|
|
181
200
|
|
|
182
201
|
/** Test seam — reset between tests. */
|
|
@@ -185,6 +204,8 @@ export function setSystemRestartIoForTests(io: SystemRestartIo = {}): void {
|
|
|
185
204
|
restartAccepted = false;
|
|
186
205
|
acceptedDrainGraceMs = MEMORY_DRAIN_RESTART_MS;
|
|
187
206
|
explicitShutdownRequested = false;
|
|
207
|
+
pendingShutdownIntents.clear();
|
|
208
|
+
shutdownIntentChanged();
|
|
188
209
|
}
|
|
189
210
|
|
|
190
211
|
/** The port this process is listening on, or undefined when that cannot be established. */
|
|
@@ -269,6 +290,9 @@ function spawnDetachedStart(
|
|
|
269
290
|
let env: NodeJS.ProcessEnv;
|
|
270
291
|
try {
|
|
271
292
|
env = replacementStartEnvironment(waitForHealthBeforeParentExit);
|
|
293
|
+
// Prepare the sibling handoff while its runtime record still exists. Only completed
|
|
294
|
+
// drain + listener stop may release parent ownership before waiting for child health.
|
|
295
|
+
if (waitForHealthBeforeParentExit) retireRestartParentOwnership(port);
|
|
272
296
|
} catch (err) {
|
|
273
297
|
return Promise.reject(err);
|
|
274
298
|
}
|
|
@@ -281,7 +305,9 @@ async function completeDeferredParentExitHandoff(
|
|
|
281
305
|
port: number | undefined,
|
|
282
306
|
phase: "deadline" | "listener-stop fallback",
|
|
283
307
|
canHandoff: () => boolean = () => true,
|
|
308
|
+
automatic = false,
|
|
284
309
|
): Promise<void> {
|
|
310
|
+
while (automatic && pendingShutdownIntents.size > 0 && !explicitShutdownRequested) await nextShutdownIntentChange();
|
|
285
311
|
if (!canHandoff()) return;
|
|
286
312
|
try {
|
|
287
313
|
await (io.spawnStart ?? spawnDetachedStart)(port, false);
|
|
@@ -304,7 +330,9 @@ async function completeDeadlineRestartHandoff(
|
|
|
304
330
|
port: number | undefined,
|
|
305
331
|
scheduleDeadline: NonNullable<SystemRestartIo["scheduleDeadline"]>,
|
|
306
332
|
canHandoff: () => boolean = () => true,
|
|
333
|
+
automatic = false,
|
|
307
334
|
): Promise<void> {
|
|
335
|
+
while (automatic && pendingShutdownIntents.size > 0 && !explicitShutdownRequested) await nextShutdownIntentChange();
|
|
308
336
|
if (!canHandoff()) return;
|
|
309
337
|
if (handOffToDesktop(io, exitProcess)) return;
|
|
310
338
|
const supervised = (io.isSupervisedServiceChild ?? (() => isSupervisedServiceChild(io)))();
|
|
@@ -330,7 +358,7 @@ async function completeDeadlineRestartHandoff(
|
|
|
330
358
|
}
|
|
331
359
|
// The ordinary child must survive parent exit: a failed/pending socket close
|
|
332
360
|
// or overdue cleanup is completed by process teardown, without a hidden mode.
|
|
333
|
-
await completeDeferredParentExitHandoff(io, exitProcess, port, "deadline", canHandoff);
|
|
361
|
+
await completeDeferredParentExitHandoff(io, exitProcess, port, "deadline", canHandoff, automatic);
|
|
334
362
|
}
|
|
335
363
|
|
|
336
364
|
/**
|
|
@@ -378,6 +406,7 @@ export function acceptSystemRestart(io: SystemRestartIo = restartIo, admission:
|
|
|
378
406
|
pending = false;
|
|
379
407
|
vetoed = true;
|
|
380
408
|
releasePending();
|
|
409
|
+
shutdownIntentChanged();
|
|
381
410
|
});
|
|
382
411
|
const now = io.now ?? Date.now;
|
|
383
412
|
const acceptedAtMs = now();
|
|
@@ -402,12 +431,15 @@ export function acceptSystemRestart(io: SystemRestartIo = restartIo, admission:
|
|
|
402
431
|
}, drainGraceMs);
|
|
403
432
|
}
|
|
404
433
|
schedule(async () => {
|
|
434
|
+
if (vetoed) return;
|
|
435
|
+
// Keep the one admitted restart queued until every temporary stop intent settles.
|
|
436
|
+
while (automatic && pendingShutdownIntents.size > 0 && !explicitShutdownRequested && !vetoed) await nextShutdownIntentChange();
|
|
405
437
|
if (vetoed) return;
|
|
406
438
|
pending = false;
|
|
407
439
|
const canHandoff = () => {
|
|
408
440
|
// Only admission-bound (automatic) restarts yield to an explicit stop; manual restart
|
|
409
441
|
// requests keep their existing semantics.
|
|
410
|
-
if (admission.onAccepted && explicitShutdownRequested) return false;
|
|
442
|
+
if (admission.onAccepted && (explicitShutdownRequested || pendingShutdownIntents.size > 0)) return false;
|
|
411
443
|
try { return admission.beforeScheduledDrain?.() ?? true; }
|
|
412
444
|
catch { return false; } // Unknown ownership is not authority to restart.
|
|
413
445
|
};
|
|
@@ -426,12 +458,14 @@ export function acceptSystemRestart(io: SystemRestartIo = restartIo, admission:
|
|
|
426
458
|
const drainPromise = Promise.resolve().then(
|
|
427
459
|
() => drain(undefined, Math.max(0, drainDeadlineMs - now())),
|
|
428
460
|
);
|
|
429
|
-
|
|
461
|
+
let drainOutcome = await waitForRestartDrain(drainPromise, restartDeadlineMs, now, scheduleDeadline);
|
|
462
|
+
while (automatic && pendingShutdownIntents.size > 0 && !explicitShutdownRequested) await nextShutdownIntentChange();
|
|
430
463
|
if (!canHandoff()) return;
|
|
464
|
+
if (automatic && now() >= restartDeadlineMs) drainOutcome = "deadline";
|
|
431
465
|
const exitProcess = io.exitProcess ?? ((code: number) => { process.exit(code); });
|
|
432
466
|
if (drainOutcome === "deadline") {
|
|
433
467
|
console.warn("Drain-and-restart deadline expired; forcing terminal restart handoff");
|
|
434
|
-
await completeDeadlineRestartHandoff(io, exitProcess, restartPort, scheduleDeadline, canHandoff);
|
|
468
|
+
await completeDeadlineRestartHandoff(io, exitProcess, restartPort, scheduleDeadline, canHandoff, automatic);
|
|
435
469
|
return;
|
|
436
470
|
}
|
|
437
471
|
if (drainOutcome === "failed" || drainOutcome === "rejected") {
|
|
@@ -457,11 +491,17 @@ export function acceptSystemRestart(io: SystemRestartIo = restartIo, admission:
|
|
|
457
491
|
restartPort,
|
|
458
492
|
"listener-stop fallback",
|
|
459
493
|
canHandoff,
|
|
494
|
+
automatic,
|
|
460
495
|
);
|
|
461
496
|
return;
|
|
462
497
|
}
|
|
463
498
|
try {
|
|
499
|
+
while (automatic && pendingShutdownIntents.size > 0 && !explicitShutdownRequested) await nextShutdownIntentChange();
|
|
464
500
|
if (!canHandoff()) return;
|
|
501
|
+
if (automatic && now() >= restartDeadlineMs) {
|
|
502
|
+
await completeDeferredParentExitHandoff(io, exitProcess, restartPort, "deadline", canHandoff, automatic);
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
465
505
|
// A rejected drain has uncertain cleanup ownership, so it uses the same
|
|
466
506
|
// parent-exit handoff as a deadline. Only a fully completed drain waits
|
|
467
507
|
// for replacement health in the old process.
|
|
@@ -10,14 +10,27 @@
|
|
|
10
10
|
* chain runs, so these handlers add no auth code of their own. The GET spends no user identity.
|
|
11
11
|
* The POST clears one root's windowed count ceilings; it does not spend identity, and the
|
|
12
12
|
* underlying ledger leaves in-flight concurrency and the token spend record untouched.
|
|
13
|
+
*
|
|
14
|
+
* `/api/workflow-budget/settings` reads and writes the per-install count ceilings. A write
|
|
15
|
+
* mutates the live config object, which the request path reads per decision, so it applies to
|
|
16
|
+
* the next admission without a restart and never resets what a root has already used.
|
|
13
17
|
*/
|
|
14
18
|
|
|
15
19
|
import { jsonResponse } from "../auth-cors";
|
|
16
20
|
import type { OcxConfig } from "../../types";
|
|
17
21
|
import type { ManagementContext } from "./context";
|
|
18
22
|
import { readManagementJsonBodyOr } from "./body";
|
|
23
|
+
import { captureConfigTopLevelRollback, deleteConfigTopLevelKey } from "../../config/rebase-provenance";
|
|
24
|
+
import { ConfigWritePublishedError } from "../../config/persist-unlocked";
|
|
25
|
+
import {
|
|
26
|
+
WORKFLOW_BUDGET_BOUNDS,
|
|
27
|
+
WORKFLOW_BUDGET_SHAPE_HINT,
|
|
28
|
+
workflowBudgetSchema,
|
|
29
|
+
} from "../../config/schema/workflow-budget";
|
|
30
|
+
import { resolveWorkflowBudgetPolicy } from "../../lib/workflow-budget-config";
|
|
19
31
|
import {
|
|
20
32
|
clearWorkflowBudgetForRoot,
|
|
33
|
+
DEFAULT_WORKFLOW_BUDGET_POLICY,
|
|
21
34
|
listTrackedWorkflowRoots,
|
|
22
35
|
listWorkflowBudgetEvents,
|
|
23
36
|
workflowBudgetSnapshot,
|
|
@@ -27,6 +40,54 @@ import {
|
|
|
27
40
|
const DEFAULT_LIMIT = 20;
|
|
28
41
|
const MAX_LIMIT = WORKFLOW_EVENT_CAPACITY;
|
|
29
42
|
const MAX_ROOT_ID_LENGTH = 200;
|
|
43
|
+
const INVALID_BODY = Symbol("invalid-body");
|
|
44
|
+
|
|
45
|
+
/** Effective ceilings plus what the dashboard needs to draw them: defaults, bounds, the fixed window. */
|
|
46
|
+
function workflowBudgetSettings(config: OcxConfig) {
|
|
47
|
+
const policy = resolveWorkflowBudgetPolicy(config);
|
|
48
|
+
return {
|
|
49
|
+
maxConcurrentChildren: policy.maxConcurrentChildren,
|
|
50
|
+
maxPhysicalSends: policy.maxPhysicalSends,
|
|
51
|
+
maxDistinctChildren: policy.maxDistinctChildren,
|
|
52
|
+
interactiveReserve: policy.interactiveReserve,
|
|
53
|
+
windowMs: DEFAULT_WORKFLOW_BUDGET_POLICY.windowMs,
|
|
54
|
+
defaults: {
|
|
55
|
+
maxConcurrentChildren: DEFAULT_WORKFLOW_BUDGET_POLICY.maxConcurrentChildren,
|
|
56
|
+
maxPhysicalSends: DEFAULT_WORKFLOW_BUDGET_POLICY.maxPhysicalSends,
|
|
57
|
+
maxDistinctChildren: DEFAULT_WORKFLOW_BUDGET_POLICY.maxDistinctChildren,
|
|
58
|
+
},
|
|
59
|
+
bounds: WORKFLOW_BUDGET_BOUNDS,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Partial PUTs preserve omitted ceilings; JSON null removes the block and restores the defaults. */
|
|
64
|
+
async function putWorkflowBudgetSettings(ctx: ManagementContext): Promise<Response> {
|
|
65
|
+
const { req, config } = ctx;
|
|
66
|
+
const body = await readManagementJsonBodyOr(req, INVALID_BODY);
|
|
67
|
+
const parsed = body === null ? null : workflowBudgetSchema.safeParse(body);
|
|
68
|
+
if (parsed !== null && !parsed.success) {
|
|
69
|
+
return jsonResponse(
|
|
70
|
+
{ error: { code: "invalid_workflow_budget", message: "body must be null or an object that " + WORKFLOW_BUDGET_SHAPE_HINT } },
|
|
71
|
+
400,
|
|
72
|
+
req,
|
|
73
|
+
config,
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
// Resolve the saver before changing the live object: no await may interleave mutation/save.
|
|
77
|
+
const persist = ctx.deps.saveConfigPreservingClaudeCode
|
|
78
|
+
?? (await import("../../config")).saveConfigPreservingClaudeCode;
|
|
79
|
+
const restore = captureConfigTopLevelRollback(config, ["workflowBudget"]);
|
|
80
|
+
try {
|
|
81
|
+
if (parsed === null) deleteConfigTopLevelKey(config, "workflowBudget");
|
|
82
|
+
else config.workflowBudget = { ...config.workflowBudget, ...parsed.data };
|
|
83
|
+
persist(config);
|
|
84
|
+
} catch (error) {
|
|
85
|
+
// Published bytes remain authoritative even if later bookkeeping failed.
|
|
86
|
+
if (!(error instanceof ConfigWritePublishedError)) restore();
|
|
87
|
+
throw error;
|
|
88
|
+
}
|
|
89
|
+
return jsonResponse(workflowBudgetSettings(config), 200, req, config);
|
|
90
|
+
}
|
|
30
91
|
|
|
31
92
|
/**
|
|
32
93
|
* A root id is an opaque caller-thread token, not a path. Without a length cap a client
|
|
@@ -60,6 +121,12 @@ function parseLimitParam(rawLimit: string | null): { ok: true; limit: number } |
|
|
|
60
121
|
export async function handleWorkflowBudgetRoutes(ctx: ManagementContext): Promise<Response | null> {
|
|
61
122
|
const { url, req, config } = ctx;
|
|
62
123
|
|
|
124
|
+
if (url.pathname === "/api/workflow-budget/settings" && req.method === "GET") {
|
|
125
|
+
return jsonResponse(workflowBudgetSettings(config), 200, req, config);
|
|
126
|
+
}
|
|
127
|
+
if (url.pathname === "/api/workflow-budget/settings" && req.method === "PUT") return putWorkflowBudgetSettings(ctx);
|
|
128
|
+
const policy = resolveWorkflowBudgetPolicy(config);
|
|
129
|
+
|
|
63
130
|
if (url.pathname === "/api/workflow-budget") {
|
|
64
131
|
if (req.method !== "GET") return null;
|
|
65
132
|
|
|
@@ -78,7 +145,7 @@ export async function handleWorkflowBudgetRoutes(ctx: ManagementContext): Promis
|
|
|
78
145
|
if (rawRoot !== null) {
|
|
79
146
|
const rootId = parseRootId(rawRoot);
|
|
80
147
|
if (rootId === null) return invalidRootResponse(req, config);
|
|
81
|
-
const snapshot = workflowBudgetSnapshot(rootId);
|
|
148
|
+
const snapshot = workflowBudgetSnapshot(rootId, policy);
|
|
82
149
|
// An unknown id is a 200 with `root: null`, not a 404: the operator asked what this
|
|
83
150
|
// process currently holds for that token, and "nothing" is a legitimate answer. POST
|
|
84
151
|
// /clear is the opposite — claiming to forgive a ceiling that was never tracked would
|
|
@@ -98,7 +165,7 @@ export async function handleWorkflowBudgetRoutes(ctx: ManagementContext): Promis
|
|
|
98
165
|
|
|
99
166
|
return jsonResponse(
|
|
100
167
|
{
|
|
101
|
-
roots: listTrackedWorkflowRoots(limit),
|
|
168
|
+
roots: listTrackedWorkflowRoots(limit, policy),
|
|
102
169
|
events: listWorkflowBudgetEvents(limit),
|
|
103
170
|
},
|
|
104
171
|
200,
|
|
@@ -117,7 +184,7 @@ export async function handleWorkflowBudgetRoutes(ctx: ManagementContext): Promis
|
|
|
117
184
|
const rootId = parseRootId(rawRoot);
|
|
118
185
|
if (rootId === null) return invalidRootResponse(req, config);
|
|
119
186
|
|
|
120
|
-
const before = clearWorkflowBudgetForRoot(rootId);
|
|
187
|
+
const before = clearWorkflowBudgetForRoot(rootId, policy);
|
|
121
188
|
if (!before) {
|
|
122
189
|
return jsonResponse(
|
|
123
190
|
{ error: { code: "unknown_root", message: "root is not currently tracked" } },
|
|
@@ -50,7 +50,7 @@ import {
|
|
|
50
50
|
import type { OcxClaudeCodeConfig, OcxClaudeDesktopProfile, OcxConfig, OcxCustomModel, OcxProviderConfig } from "../types";
|
|
51
51
|
import type { DesktopProfileModel } from "../claude/desktop-profile";
|
|
52
52
|
import { drainAndShutdown } from "./lifecycle";
|
|
53
|
-
import { noteExplicitShutdownRequested } from "./management/system-restart";
|
|
53
|
+
import { acquireExplicitShutdownIntent, noteExplicitShutdownRequested } from "./management/system-restart";
|
|
54
54
|
import { filterRequestLogs, getRequestLogEntries, type RequestLogEntry } from "./request-log";
|
|
55
55
|
import { estimateComboCost, estimateRequestCost, normalizeCostTokens, tokensPerSecond } from "../usage/cost";
|
|
56
56
|
import type { PersistedUsageAttempt } from "../usage/log";
|
|
@@ -83,6 +83,7 @@ import { handleClaudeDesktopPickerRoutes } from "./management/claude-desktop-pic
|
|
|
83
83
|
import { handleDesktopCompatibilityRoutes } from "./management/desktop-compatibility-routes";
|
|
84
84
|
import { handleDesktopCompatibilityRuntimeRoutes } from "./management/desktop-compatibility-runtime-routes";
|
|
85
85
|
import { handleDesktopCompatibilitySettingsRoutes } from "./management/desktop-compatibility-settings-routes";
|
|
86
|
+
import { handleCodexCliUpdateRoutes } from "./management/codex-cli-update-routes";
|
|
86
87
|
import { handleCursorIntegrationRoutes } from "./management/cursor-integration-routes";
|
|
87
88
|
import type { ManagementContext } from "./management/context";
|
|
88
89
|
import type { ManagementPrincipal, ManagementSessionControl } from "./management-auth";
|
|
@@ -384,6 +385,7 @@ export async function handleManagementAPI(
|
|
|
384
385
|
?? (await handleDesktopCompatibilityRoutes(ctx))
|
|
385
386
|
?? (await handleDesktopCompatibilityRuntimeRoutes(ctx))
|
|
386
387
|
?? (await handleDesktopCompatibilitySettingsRoutes(ctx))
|
|
388
|
+
?? (await handleCodexCliUpdateRoutes(ctx))
|
|
387
389
|
?? (await handleAgentSettingsRoutes(ctx))
|
|
388
390
|
?? (await handleCodexPromptRoutes(ctx))
|
|
389
391
|
?? (await handleOauthAccountRoutes(ctx))
|
|
@@ -434,7 +436,7 @@ export async function handleManagementAPI(
|
|
|
434
436
|
// outcome. This process cannot verify its own post-exit respawn window; only the
|
|
435
437
|
// receipt-backed parent `ocx stop` can, which is what the deferral exists for.
|
|
436
438
|
const { deferralMatchesReceipt } = await import("../config/pending-teardown");
|
|
437
|
-
const { deferralHonored, desktopSupervisedStopRefusal, performStopTeardown } = await import("./stop-teardown");
|
|
439
|
+
const { deferralHonored, desktopSupervisedStopRefusal, performStopTeardown, preflightStopTeardownOwnership } = await import("./stop-teardown");
|
|
438
440
|
// The desktop app would start this proxy again within seconds; refuse before anything is
|
|
439
441
|
// touched and point at its tray, whose Stop it honours (#3008 refuses an undone stop the same way).
|
|
440
442
|
const desktopRefusal = desktopSupervisedStopRefusal(principal);
|
|
@@ -475,58 +477,65 @@ export async function handleManagementAPI(
|
|
|
475
477
|
message: "The Windows Task Scheduler state could not be read, so this proxy cannot tell whether a wrapper would respawn it. Nothing was changed. Run `ocx service status` to see the query error, repair Task Scheduler access, then retry.",
|
|
476
478
|
}, 409, req, config);
|
|
477
479
|
}
|
|
478
|
-
|
|
480
|
+
// Block automatic handoff while deciding, without committing a refused stop.
|
|
481
|
+
const releaseStopIntent = acquireExplicitShutdownIntent();
|
|
479
482
|
try {
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
// The installed service belongs to another CODEX_HOME/OPENCODEX_HOME: it would respawn
|
|
484
|
-
// this proxy immediately, and its shared config is not ours to tear down. Refuse the
|
|
485
|
-
// stop instead of half-performing it. 409, not 500 — the request is well-formed.
|
|
486
|
-
return jsonResponse({ success: false, message: err.message }, 409, req, config);
|
|
483
|
+
if (!holdsReceipt && !sibling) {
|
|
484
|
+
const refusal = preflightStopTeardownOwnership();
|
|
485
|
+
if (refusal) return jsonResponse(refusal, 409, req, config);
|
|
487
486
|
}
|
|
488
|
-
|
|
489
|
-
}
|
|
490
|
-
// The boolean helper collapses "failed" into the same false as "no service installed",
|
|
491
|
-
// so this route used to tear down shared config and exit while a manager that refused
|
|
492
|
-
// to stop was still there to respawn the proxy (#3008).
|
|
493
|
-
if (serviceStop === "failed") {
|
|
494
|
-
return jsonResponse({
|
|
495
|
-
success: false,
|
|
496
|
-
message: "The installed service manager did not stop; it may respawn the proxy. Shared client config was left alone. Run `ocx stop` from the home that owns the service.",
|
|
497
|
-
}, 409, req, config);
|
|
498
|
-
}
|
|
499
|
-
if (serviceStop === "state-unknown") {
|
|
500
|
-
// Same case, same remedy as the pre-check: the query is what needs fixing.
|
|
501
|
-
return jsonResponse({
|
|
502
|
-
success: false,
|
|
503
|
-
code: "service_state_unknown",
|
|
504
|
-
message: "The Windows Task Scheduler state could not be read, so this proxy cannot tell whether a wrapper would respawn it. Shared client config was left alone. Run `ocx service status` to see the query error, repair Task Scheduler access, then retry.",
|
|
505
|
-
}, 409, req, config);
|
|
506
|
-
}
|
|
507
|
-
// The pre-check above already refused the respawnable case without a receipt, so
|
|
508
|
-
// reaching here with one means the parent owns the verification.
|
|
509
|
-
// Both managed configs come down together on an explicit teardown. The daemon's own
|
|
510
|
-
// syncCleanup skips this when OCX_SERVICE is set (so a crash/respawn keeps the fence),
|
|
511
|
-
// which is exactly why an intentional stop has to do it here — unless the caller is
|
|
512
|
-
// `ocx stop`, which does it itself once the proxy is proven down.
|
|
513
|
-
// Mark the stop before the first await after acceptance, so an automatic restart draining
|
|
514
|
-
// concurrently cannot reach its handoff while teardown is still pending.
|
|
515
|
-
noteExplicitShutdownRequested();
|
|
516
|
-
const teardown = await performStopTeardown(url, { ownsReceipt: deferralMatchesReceipt });
|
|
517
|
-
setTimeout(async () => {
|
|
518
|
-
let shutdownSucceeded = false;
|
|
487
|
+
let serviceStop: import("../service").ServiceStopOutcome;
|
|
519
488
|
try {
|
|
520
|
-
|
|
521
|
-
} catch {
|
|
522
|
-
|
|
489
|
+
serviceStop = sibling ? "absent" : stopServiceIfInstalledDetailed();
|
|
490
|
+
} catch (err) {
|
|
491
|
+
if (isServiceOwnershipError(err)) {
|
|
492
|
+
// The installed service belongs to another CODEX_HOME/OPENCODEX_HOME: it would respawn
|
|
493
|
+
// this proxy immediately, and its shared config is not ours to tear down. Refuse the
|
|
494
|
+
// stop instead of half-performing it. 409, not 500 — the request is well-formed.
|
|
495
|
+
return jsonResponse({ success: false, message: err.message }, 409, req, config);
|
|
496
|
+
}
|
|
497
|
+
throw err;
|
|
523
498
|
}
|
|
524
|
-
//
|
|
525
|
-
//
|
|
526
|
-
// still
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
499
|
+
// The boolean helper collapses "failed" into the same false as "no service installed",
|
|
500
|
+
// so this route used to tear down shared config and exit while a manager that refused
|
|
501
|
+
// to stop was still there to respawn the proxy (#3008).
|
|
502
|
+
if (serviceStop === "failed") {
|
|
503
|
+
return jsonResponse({
|
|
504
|
+
success: false,
|
|
505
|
+
message: "The installed service manager did not stop; it may respawn the proxy. Shared client config was left alone. Run `ocx stop` from the home that owns the service.",
|
|
506
|
+
}, 409, req, config);
|
|
507
|
+
}
|
|
508
|
+
if (serviceStop === "state-unknown") {
|
|
509
|
+
// Same case, same remedy as the pre-check: the query is what needs fixing.
|
|
510
|
+
return jsonResponse({
|
|
511
|
+
success: false,
|
|
512
|
+
code: "service_state_unknown",
|
|
513
|
+
message: "The Windows Task Scheduler state could not be read, so this proxy cannot tell whether a wrapper would respawn it. Shared client config was left alone. Run `ocx service status` to see the query error, repair Task Scheduler access, then retry.",
|
|
514
|
+
}, 409, req, config);
|
|
515
|
+
}
|
|
516
|
+
// The pre-check above already refused the respawnable case without a receipt, so
|
|
517
|
+
// reaching here with one means the parent owns the verification.
|
|
518
|
+
// Both managed configs come down together on an explicit teardown. The daemon's own
|
|
519
|
+
// syncCleanup skips this when OCX_SERVICE is set (so a crash/respawn keeps the fence),
|
|
520
|
+
// which is exactly why an intentional stop has to do it here — unless the caller is
|
|
521
|
+
// `ocx stop`, which does it itself once the proxy is proven down.
|
|
522
|
+
const teardown = await performStopTeardown(url, { ownsReceipt: deferralMatchesReceipt });
|
|
523
|
+
if (teardown.sharedTeardown === "refused") return jsonResponse(teardown, 409, req, config);
|
|
524
|
+
noteExplicitShutdownRequested(); // Accepted stops and signals remain irreversible.
|
|
525
|
+
setTimeout(async () => {
|
|
526
|
+
let shutdownSucceeded = false;
|
|
527
|
+
try {
|
|
528
|
+
shutdownSucceeded = await drainAndShutdown(undefined, config.shutdownTimeoutMs ?? 5000);
|
|
529
|
+
} catch {
|
|
530
|
+
console.warn("[opencodex] shutdown drain failed");
|
|
531
|
+
}
|
|
532
|
+
// A drained proxy whose shared teardown failed did not finish the job. Exiting 0
|
|
533
|
+
// told a supervisor the stop was clean while native Codex or the Grok fence was
|
|
534
|
+
// still pointed at this process (#3008).
|
|
535
|
+
process.exit(shutdownSucceeded && teardown.success ? 0 : 1);
|
|
536
|
+
}, 200);
|
|
537
|
+
return jsonResponse(teardown);
|
|
538
|
+
} finally { releaseStopIntent(); }
|
|
530
539
|
}
|
|
531
540
|
|
|
532
541
|
if (url.pathname.startsWith("/api/native-main-profiles")) {
|
|
@@ -546,7 +555,8 @@ export async function handleManagementAPI(
|
|
|
546
555
|
const { ConfigMutationLockError } = await import("../config");
|
|
547
556
|
const { CodexCredentialRefreshLockTimeoutError } = await import("../codex/account-store");
|
|
548
557
|
try {
|
|
549
|
-
|
|
558
|
+
// Remembered sessions retain admin-token consent authority for account refresh.
|
|
559
|
+
return await handleCodexAuthAPI(req, url, config, convergeCodexCatalog, ctx.guiSessionIssuance === "remembered-admin" ? "admin-token" : principal);
|
|
550
560
|
} catch (error) {
|
|
551
561
|
// Credential writers remap ConfigMutationLockError to CodexCredentialRefreshLockTimeoutError;
|
|
552
562
|
// treat both as the same retryable busy response.
|
|
@@ -72,6 +72,7 @@ import {
|
|
|
72
72
|
type GuiSessionRequestContext,
|
|
73
73
|
} from "./gui-session";
|
|
74
74
|
import { hasLocalDesktopSnapshotCapability } from "./local-desktop-snapshot-auth";
|
|
75
|
+
import { forgetGuiDevice, rememberGuiDevice, rememberedGuiSessionIsCurrent, resumeGuiDevice } from "./persistent-gui-session";
|
|
75
76
|
import { hasLocalAccountSwitchCapability } from "./local-account-switch-auth";
|
|
76
77
|
import { authorizationCredential } from "../lib/authorization-scheme";
|
|
77
78
|
export type { GuiSessionBootstrap, GuiSessionRequestContext } from "./gui-session";
|
|
@@ -260,7 +261,7 @@ export function issueGuiSession(
|
|
|
260
261
|
context?: GuiSessionRequestContext,
|
|
261
262
|
): GuiSessionBootstrap | null {
|
|
262
263
|
if (!state.available) return null;
|
|
263
|
-
return issueGuiSessionFromState(req, config, state, context);
|
|
264
|
+
return resumeGuiDevice(req, config, state, context?.now) ?? issueGuiSessionFromState(req, config, state, context);
|
|
264
265
|
}
|
|
265
266
|
|
|
266
267
|
/** Returns the recorded issuance for the session that authorized this request. */
|
|
@@ -275,6 +276,8 @@ export function managementSessionIssuance(
|
|
|
275
276
|
}
|
|
276
277
|
|
|
277
278
|
export interface ManagementSessionControl {
|
|
279
|
+
rememberDevice?(req: Request, config: OcxConfig): ReturnType<typeof rememberGuiDevice>;
|
|
280
|
+
forgetDevice?(req: Request, config: OcxConfig): string | null;
|
|
278
281
|
revokeCurrent(req: Request): boolean;
|
|
279
282
|
/** Revalidate a long-lived request against current authority, without cached admission or renewal. */
|
|
280
283
|
isCurrent(req: Request, config: OcxConfig): boolean;
|
|
@@ -291,7 +294,7 @@ export function createManagementSessionControl(state: ManagementAuthState): Mana
|
|
|
291
294
|
const credential = requestManagementCredential(req);
|
|
292
295
|
if (!credential || equalSecret(credential, adminToken)) return null;
|
|
293
296
|
const session = state.sessions.get(credential);
|
|
294
|
-
if (!session) return null;
|
|
297
|
+
if (!session || !rememberedGuiSessionIsCurrent(req, config, state, session)) return null;
|
|
295
298
|
// Reuse the full origin/expiry/CSRF predicate against the current record, but
|
|
296
299
|
// isolate its sliding-expiry mutation: authority checks are not browser activity.
|
|
297
300
|
return authorizeGuiSessionRequest(req, config, {
|
|
@@ -300,6 +303,8 @@ export function createManagementSessionControl(state: ManagementAuthState): Mana
|
|
|
300
303
|
}).ok ? session : null;
|
|
301
304
|
}
|
|
302
305
|
return {
|
|
306
|
+
rememberDevice(req, config) { return state.available ? rememberGuiDevice(req, config, state) : null; },
|
|
307
|
+
forgetDevice(req, config) { return state.available ? forgetGuiDevice(req, config, state) : null; },
|
|
303
308
|
isCurrent(req: Request, config: OcxConfig): boolean {
|
|
304
309
|
if (!state.available) return false;
|
|
305
310
|
const credential = requestManagementCredential(req);
|
|
@@ -582,7 +587,10 @@ function resolveManagementAdmission(
|
|
|
582
587
|
else if (actual && isOpencodeCatalogRequest(req) && equalSecret(actual, opencodeCatalogToken(state.token))) {
|
|
583
588
|
principal = "opencode-catalog-token";
|
|
584
589
|
}
|
|
585
|
-
else if (config
|
|
590
|
+
else if (config) {
|
|
591
|
+
const admission = authorizeGuiSessionRequest(req, config, state);
|
|
592
|
+
if (admission.ok && rememberedGuiSessionIsCurrent(req, config, state, admission.session, "logout")) principal = "gui-session";
|
|
593
|
+
}
|
|
586
594
|
}
|
|
587
595
|
if (principal) admittedManagementRequests.set(req, principal);
|
|
588
596
|
return principal;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Whether a settled Messages route may take the managed native Messages lane (PF-08).
|
|
3
3
|
*
|
|
4
4
|
* PURE: reads the route, the body's structure and config, and nothing else. The Messages ingress,
|
|
5
|
-
* `count_tokens` and the protocol planner (`src/protocols/plan-snapshot.ts`) all ask here
|
|
6
|
-
*
|
|
5
|
+
* `count_tokens` and the protocol planner (`src/protocols/plan-snapshot.ts`) all ask here;
|
|
6
|
+
* previews and counts remain conservative when runtime availability is unknown.
|
|
7
7
|
*/
|
|
8
8
|
import { anthropicBodyElidesBlockedSkill } from "../claude/inbound";
|
|
9
9
|
import { isClaudeWebSearchToolName } from "../claude/outbound";
|
|
@@ -48,6 +48,8 @@ export interface NativeMessagesSelector {
|
|
|
48
48
|
* and judges OAuth from config alone.
|
|
49
49
|
*/
|
|
50
50
|
oauthFailoverQuorum?: boolean;
|
|
51
|
+
/** Runtime sidecar plan availability; absent for config-only callers. */
|
|
52
|
+
webSearchBackendAvailable?: boolean;
|
|
51
53
|
}
|
|
52
54
|
|
|
53
55
|
type Rec = Record<string, unknown>;
|
|
@@ -59,8 +61,7 @@ function isRec(value: unknown): value is Rec {
|
|
|
59
61
|
* Whether the bridge could hand this request to the web-search sidecar: a `web_search*` server
|
|
60
62
|
* tool the tool choice does not exclude, with the sidecar not disabled in the Claude replay config
|
|
61
63
|
* (`buildClaudeReplayConfig` merges `claudeCode.webSearchSidecar` over the global block). Whether
|
|
62
|
-
* a backend credential
|
|
63
|
-
* toward the bridge, which is today's behavior for every such request.
|
|
64
|
+
* a backend credential exists is supplied separately by the sending ingress.
|
|
64
65
|
*/
|
|
65
66
|
function webSearchSidecarMayEngage(body: Readonly<Rec>, config: OcxConfig): boolean {
|
|
66
67
|
const sidecar = { ...config.webSearchSidecar, ...config.claudeCode?.webSearchSidecar };
|
|
@@ -89,7 +90,7 @@ function bridgeOnlyPolicyApplies(
|
|
|
89
90
|
): boolean {
|
|
90
91
|
if (resolvePinnedEffort(route, selector.routeSelector, config) !== undefined) return true;
|
|
91
92
|
if (anthropicBodyElidesBlockedSkill(body, selector.claudeCode ?? config.claudeCode)) return true;
|
|
92
|
-
return webSearchSidecarMayEngage(body, config);
|
|
93
|
+
return selector.webSearchBackendAvailable !== false && webSearchSidecarMayEngage(body, config);
|
|
93
94
|
}
|
|
94
95
|
|
|
95
96
|
/**
|
|
@@ -13,7 +13,12 @@ export function nativeMessagesToolScopeDenial(
|
|
|
13
13
|
requestedModel: string,
|
|
14
14
|
body: Readonly<Rec>,
|
|
15
15
|
): AdmissionModelDeniedError | undefined {
|
|
16
|
-
if (!scope
|
|
16
|
+
if (!scope) return undefined;
|
|
17
|
+
for (const part of scope.allOf ?? []) {
|
|
18
|
+
const denial = nativeMessagesToolScopeDenial(part, providerName, requestedModel, body);
|
|
19
|
+
if (denial) return denial;
|
|
20
|
+
}
|
|
21
|
+
if (scope.models.length === 0) return undefined;
|
|
17
22
|
const definitions = new Map<string, Rec[]>();
|
|
18
23
|
const withdrawn = new Set<string>();
|
|
19
24
|
const anonymous: Rec[] = [];
|