@bitkyc08/opencodex 2.93.0 → 2.94.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-DmvwlhQq.js +58 -0
- package/gui/dist/assets/Tray-CZatQdoF.js +1 -0
- package/gui/dist/assets/index-3EPO_KbX.js +94 -0
- package/gui/dist/assets/index-CHWwDo9L.css +1 -0
- package/gui/dist/assets/{quota-summary-BXu4zE8H.js → quota-summary-BHvWg9mi.js} +1 -1
- 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 +17 -4
- 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.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 +3 -0
- package/src/adapters/kiro/stream.ts +18 -13
- package/src/adapters/openai-chat/completed-tool-blocks.ts +65 -0
- package/src/adapters/openai-chat/messages.ts +22 -10
- 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/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/passthrough.ts +11 -34
- package/src/adapters/openai-responses/transport.ts +20 -2
- package/src/adapters/openai-responses/usage.ts +34 -0
- package/src/adapters/qoder/adapter.ts +9 -15
- package/src/adapters/qoder/image-input.ts +52 -0
- package/src/adapters/unique-tool-call-ids.ts +2 -2
- 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 +53 -3
- package/src/advisor/consult.ts +22 -0
- package/src/advisor/runtime.ts +3 -0
- package/src/bridge/errors.ts +22 -1
- package/src/bridge/response-json.ts +4 -1
- package/src/bridge/sse.ts +21 -12
- 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 +83 -0
- package/src/chatgpt/app-server-shim/bundle-trust.ts +15 -72
- package/src/claude/desktop-first-party.ts +16 -5
- package/src/claude/desktop-gateway-state.ts +4 -0
- package/src/claude/inbound-tool-loading.ts +93 -0
- package/src/claude/intercept/picker-listener.ts +33 -1
- package/src/claude/model-info.ts +29 -4
- package/src/claude/outbound.ts +33 -13
- package/src/cli/account-main.ts +43 -5
- package/src/cli/capabilities-base.ts +22 -5
- package/src/cli/capabilities-integrations.ts +4 -4
- 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 +310 -0
- package/src/cli/codex-shim-autorestore.ts +2 -0
- package/src/cli/config-command.ts +9 -4
- package/src/cli/config-mutation.ts +13 -0
- package/src/cli/dispatch.ts +13 -7
- 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 +58 -64
- 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/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.ts +146 -139
- package/src/cli/registry.ts +34 -3
- package/src/cli/root.ts +2 -0
- 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-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 +17 -4
- 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-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 +51 -15
- package/src/clients/gentle-shell-path.ts +3 -3
- 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/auth-api/main-account-probe.ts +50 -11
- package/src/codex/auth-api/pool-mode-gate.ts +16 -8
- package/src/codex/auth-context.ts +45 -4
- package/src/codex/catalog/antigravity-discovery.ts +59 -0
- package/src/codex/catalog/build-entries.ts +12 -13
- package/src/codex/catalog/bundled.ts +59 -9
- package/src/codex/catalog/derive-entry.ts +2 -0
- package/src/codex/catalog/gather-capture.ts +3 -0
- package/src/codex/catalog/metadata.ts +6 -5
- package/src/codex/catalog/model-hints.ts +36 -4
- package/src/codex/catalog/native-priority.ts +63 -0
- package/src/codex/catalog/provider-models.ts +20 -4
- package/src/codex/catalog/retained-sync.ts +1 -1
- package/src/codex/chatgpt-refresh-failure.ts +2 -2
- package/src/codex/cli-install-provenance.ts +57 -29
- 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 +257 -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 +1010 -0
- package/src/codex/cli-update-job-worker.ts +393 -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 +236 -0
- package/src/codex/cli-update-selection-gate.ts +235 -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 +250 -0
- package/src/codex/desktop-app-restart.ts +22 -3
- package/src/codex/exec-boundary.ts +208 -0
- package/src/codex/forward-transport-headers.ts +80 -0
- package/src/codex/history-job.ts +7 -0
- package/src/codex/history-provider.ts +5 -2
- package/src/codex/history-worker.ts +20 -1
- 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 +161 -23
- package/src/codex/native-main-auth-temp.ts +3 -2
- 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/ocx-compaction-history.ts +3 -2
- package/src/codex/prompt-text-probe.ts +211 -69
- package/src/codex/quota.ts +9 -0
- package/src/codex/role-model-history.ts +253 -0
- package/src/codex/runtime.ts +120 -71
- package/src/codex/shim-overlay.ts +22 -3
- package/src/codex/shim-templates.ts +5 -2
- package/src/codex/shim-wrapper-write.ts +136 -0
- package/src/codex/shim.ts +24 -125
- 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 +84 -5
- package/src/combos/index.ts +1 -0
- package/src/combos/resolve.ts +60 -22
- package/src/config/atomic-write.ts +75 -22
- package/src/config/diagnostics.ts +18 -10
- package/src/config/live-reconcile.ts +11 -3
- 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 +9 -5
- package/src/config/removed-opencode-free-backup.ts +99 -0
- package/src/config/removed-opencode-free.ts +4 -8
- package/src/config/salvage.ts +1 -0
- package/src/config/schema/config-schema.ts +16 -1
- package/src/config/schema/leaf-validators.ts +15 -0
- package/src/config.ts +4 -4
- package/src/generated/compatibility-version.json +743 -315
- package/src/grok/inject.ts +2 -1
- package/src/grok/sync.ts +5 -2
- package/src/images/loop.ts +14 -5
- package/src/integrations/catalog-refresh.ts +1 -1
- 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/config-ownership.ts +4 -0
- package/src/lib/errors.ts +2 -0
- package/src/lib/eventstream-decoder.ts +3 -2
- 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-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/shadow-call.ts +55 -1
- 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 +310 -44
- package/src/lib/windows-service-wrappers.ts +10 -7
- package/src/lib/winsw.ts +8 -4
- 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 +238 -0
- package/src/local-credentials/inventory.ts +281 -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/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/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 +29 -5
- package/src/oauth/index.ts +1 -0
- package/src/oauth/store.ts +32 -4
- package/src/protocols/encoders/adapter-events.ts +7 -4
- package/src/protocols/encoders/messages.ts +1 -1
- 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/claude-cli-identity.ts +2 -0
- package/src/providers/codex-capacity.ts +3 -2
- package/src/providers/free-directory.ts +10 -2
- package/src/providers/key-store.ts +7 -2
- package/src/providers/provider-id-rewrite.ts +3 -0
- package/src/providers/quota/antigravity.ts +6 -4
- package/src/providers/quota/vendor-probes-oauth.ts +0 -1
- package/src/providers/stale-model-roster-migration.ts +3 -0
- 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/responses/apply-patch-envelope.ts +35 -0
- package/src/responses/compaction-history-framing.ts +15 -4
- package/src/responses/turn-membership.ts +111 -0
- package/src/server/advisor-admission-scope.ts +43 -0
- package/src/server/audio-upstream.ts +10 -2
- package/src/server/auth-cors.ts +23 -0
- package/src/server/bind-host.ts +5 -0
- package/src/server/chat-completions.ts +17 -2
- package/src/server/chat-native.ts +16 -11
- package/src/server/claude-messages.ts +9 -1
- package/src/server/codex-model-list.ts +46 -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 +9 -43
- package/src/server/index/websocket-handler.ts +7 -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 +424 -543
- 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 +79 -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/config-routes.ts +444 -380
- package/src/server/management/consent-session.ts +6 -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 +90 -38
- package/src/server/management/oauth-account-routes.ts +8 -7
- package/src/server/management/route-registry.ts +8 -3
- package/src/server/management/session-routes.ts +20 -2
- package/src/server/management/shadow-call-validation.ts +43 -2
- package/src/server/management/sidebar-routes.ts +2 -1
- package/src/server/management/system-restart.ts +47 -7
- package/src/server/management-api.ts +61 -51
- package/src/server/management-auth.ts +11 -3
- package/src/server/messages-native.ts +21 -7
- package/src/server/messages-shared.ts +110 -18
- 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/responses/account-change-state.ts +14 -2
- package/src/server/responses/adapter-continuation.ts +5 -4
- package/src/server/responses/adapter-delivery.ts +20 -5
- package/src/server/responses/adapter-dispatch.ts +39 -45
- package/src/server/responses/advisor-plan-slot.ts +3 -0
- package/src/server/responses/advisor-slot.ts +4 -2
- 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/combo-required-tool-contract.ts +2 -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 +14 -7
- 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 +11 -6
- package/src/server/responses/core-combo-native.ts +6 -5
- package/src/server/responses/core-combo.ts +93 -20
- package/src/server/responses/core-options.ts +7 -0
- package/src/server/responses/fetch-helpers.ts +5 -1
- package/src/server/responses/jev-model-invoke.ts +8 -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 +12 -12
- package/src/server/responses/request-prepare.ts +10 -1
- package/src/server/responses/request-transport.ts +41 -6
- package/src/server/responses/run-turn-execution.ts +11 -3
- package/src/server/responses/sidecar-execution.ts +5 -0
- 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/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/service/desktop-recovery-process.ts +341 -0
- package/src/service/desktop-recovery.ts +172 -0
- package/src/service/windows-ops.ts +6 -3
- package/src/service/windows-scheduler.ts +29 -6
- package/src/stall-timeout.ts +47 -0
- package/src/tray/windows.ts +6 -4
- package/src/types/config.ts +61 -10
- package/src/types/request.ts +1 -1
- package/src/types.ts +1 -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 +179 -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 +3 -3
- package/src/vision/anthropic-describe.ts +2 -1
- 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 +10 -4
- package/src/web-search/parse.ts +191 -38
- package/gui/dist/assets/App-CizjBqyk.js +0 -58
- 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
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ManagementContext } from "./context";
|
|
2
|
+
|
|
3
|
+
/** Remembered sessions derive from the admin token, so casual-path consent guards give them admin-token parity. */
|
|
4
|
+
export function hasHumanDashboardSession(ctx: Pick<ManagementContext, "principal" | "guiSessionIssuance">): boolean {
|
|
5
|
+
return ctx.principal === "gui-session" && ctx.guiSessionIssuance !== "remembered-admin";
|
|
6
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ManagementContext } from "./context";
|
|
2
|
+
import { hasHumanDashboardSession } from "./consent-session";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Desktop compatibility mutations require an operator-mediated browser session. A remembered
|
|
6
|
+
* device session derives from the admin token, so it does not count as that confirmation.
|
|
7
|
+
*/
|
|
8
|
+
export function isAuthorizedDesktopCompatibilityMutation(ctx: ManagementContext): boolean {
|
|
9
|
+
return hasHumanDashboardSession(ctx)
|
|
10
|
+
&& ctx.trustedLoopbackIngress
|
|
11
|
+
&& ctx.sessionControl?.isPaired(ctx.req, ctx.config) === true;
|
|
12
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsonResponse } from "../auth-cors";
|
|
2
2
|
import { readManagementJsonBody, rethrowManagementBodyTooLarge } from "./body";
|
|
3
3
|
import type { ManagementContext } from "./context";
|
|
4
|
+
import { isAuthorizedDesktopCompatibilityMutation } from "./desktop-compatibility-authorization";
|
|
4
5
|
import type { DesktopCertificateService } from "../../codex/desktop-compatibility/certificate-service";
|
|
5
6
|
|
|
6
7
|
const PATH = "/api/codex/desktop-compatibility/certificate";
|
|
@@ -11,7 +12,7 @@ export async function handleDesktopCompatibilityRoutes(ctx: ManagementContext):
|
|
|
11
12
|
if (ctx.req.method !== "GET" && ctx.req.method !== "POST") return jsonResponse({ error: "method_not_allowed" }, 405);
|
|
12
13
|
// A local dashboard confirmation precedes any persisted key or CurrentUser Root mutation.
|
|
13
14
|
// This is caller provenance, not protection against an arbitrary same-user process.
|
|
14
|
-
if (ctx.req.method === "POST" && (ctx
|
|
15
|
+
if (ctx.req.method === "POST" && !isAuthorizedDesktopCompatibilityMutation(ctx)) {
|
|
15
16
|
return jsonResponse({ error: "local_dashboard_confirmation_required" }, 403);
|
|
16
17
|
}
|
|
17
18
|
let action: "prepare" | "trust" | "remove-trust" | "renew" | undefined, fingerprint: string | undefined;
|
|
@@ -36,7 +37,7 @@ export async function handleDesktopCompatibilityRoutes(ctx: ManagementContext):
|
|
|
36
37
|
: action === "trust" ? await controller.trust(fingerprint!)
|
|
37
38
|
: action === "renew" ? await controller.renew(fingerprint!)
|
|
38
39
|
: action === "remove-trust" ? await controller.removeTrust(fingerprint!) : await controller.status();
|
|
39
|
-
return jsonResponse({ ok: true, certificate: status });
|
|
40
|
+
return jsonResponse({ ok: true, certificate: { ...status, mutationAuthorized: isAuthorizedDesktopCompatibilityMutation(ctx) } });
|
|
40
41
|
} catch (error) {
|
|
41
42
|
const code = error && typeof error === "object" && "code" in error ? String(error.code) : "operation_failed";
|
|
42
43
|
const allowed = new Set(["unsupported", "busy", "not_prepared", "fingerprint_changed", "app_running", "runtime_running", "app_state_unknown", "trust_unknown", "trust_not_applied",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsonResponse } from "../auth-cors";
|
|
2
2
|
import { readManagementJsonBody, rethrowManagementBodyTooLarge } from "./body";
|
|
3
3
|
import type { ManagementContext } from "./context";
|
|
4
|
+
import { isAuthorizedDesktopCompatibilityMutation } from "./desktop-compatibility-authorization";
|
|
4
5
|
import type { DesktopCompatibilityRuntime } from "../../codex/desktop-compatibility/runtime";
|
|
5
6
|
|
|
6
7
|
const PATH = "/api/codex/desktop-compatibility/runtime";
|
|
@@ -11,7 +12,7 @@ const ERROR_CODES = new Set(["busy", "unsupported", "test_environment", "stoppin
|
|
|
11
12
|
export async function handleDesktopCompatibilityRuntimeRoutes(ctx: ManagementContext): Promise<Response | null> {
|
|
12
13
|
if (ctx.url.pathname !== PATH) return null;
|
|
13
14
|
if (ctx.req.method !== "GET" && ctx.req.method !== "POST") return jsonResponse({ error: "method_not_allowed" }, 405);
|
|
14
|
-
if (ctx.req.method === "POST" && (ctx
|
|
15
|
+
if (ctx.req.method === "POST" && !isAuthorizedDesktopCompatibilityMutation(ctx)) return jsonResponse({ error: "local_dashboard_confirmation_required" }, 403);
|
|
15
16
|
let action: "start" | "stop" | "observe" | "apply" | "launch" | undefined;
|
|
16
17
|
if (ctx.req.method === "POST") {
|
|
17
18
|
let body: unknown;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { jsonResponse } from "../auth-cors";
|
|
2
2
|
import { readManagementJsonBody, rethrowManagementBodyTooLarge } from "./body";
|
|
3
3
|
import type { ManagementContext } from "./context";
|
|
4
|
+
import { isAuthorizedDesktopCompatibilityMutation } from "./desktop-compatibility-authorization";
|
|
4
5
|
|
|
5
6
|
const PATH = "/api/codex/desktop-compatibility/settings";
|
|
6
7
|
export async function handleDesktopCompatibilitySettingsRoutes(ctx: ManagementContext): Promise<Response | null> {
|
|
7
8
|
if (ctx.url.pathname !== PATH) return null;
|
|
8
9
|
if (ctx.req.method !== "GET" && ctx.req.method !== "POST") return jsonResponse({ error: "method_not_allowed" }, 405);
|
|
9
|
-
if (ctx.req.method === "POST" && (ctx
|
|
10
|
+
if (ctx.req.method === "POST" && !isAuthorizedDesktopCompatibilityMutation(ctx)) return jsonResponse({ error: "local_dashboard_confirmation_required" }, 403);
|
|
10
11
|
let update: { startOnProxyStart: boolean; revision: string } | undefined;
|
|
11
12
|
if (ctx.req.method === "POST") {
|
|
12
13
|
let body: unknown;
|
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
import { detectRaycast, type RaycastInstall } from "../../integrations/raycast-detect";
|
|
29
29
|
import { readIntegrationState, readOwnedDroidReasoningDefaults } from "../../integrations/state";
|
|
30
30
|
import { droidReasoningModels, validateDroidReasoningDefaults } from "../../clients/config-export";
|
|
31
|
+
import { isExportModelNames, supportsAliasModelNames, type ExportModelNames } from "../../clients/config-export/model-names";
|
|
31
32
|
import { createIntegrationStateStore, type IntegrationStateStore } from "../../integrations/store";
|
|
32
33
|
import {
|
|
33
34
|
applyIntegrationCoordinated,
|
|
@@ -123,6 +124,7 @@ export interface IntegrationJournalRow {
|
|
|
123
124
|
|
|
124
125
|
export interface IntegrationToggleBody {
|
|
125
126
|
enabled: boolean;
|
|
127
|
+
modelNames?: ExportModelNames;
|
|
126
128
|
/**
|
|
127
129
|
* Opt in to replacing a conflicted block with the one opencodex would write.
|
|
128
130
|
*
|
|
@@ -284,6 +286,7 @@ async function buildIntegrationWriteInput(
|
|
|
284
286
|
ctx: ManagementContext,
|
|
285
287
|
store: IntegrationStateStore,
|
|
286
288
|
droidReasoningDefaults?: Record<string, string>,
|
|
289
|
+
modelNames?: ExportModelNames,
|
|
287
290
|
): Promise<IntegrationWriteInput> {
|
|
288
291
|
return {
|
|
289
292
|
clientId,
|
|
@@ -291,6 +294,7 @@ async function buildIntegrationWriteInput(
|
|
|
291
294
|
config: ctx.config,
|
|
292
295
|
port: managementInferencePort(ctx),
|
|
293
296
|
...(droidReasoningDefaults === undefined ? {} : { droidReasoningDefaults: { ...droidReasoningDefaults } }),
|
|
297
|
+
...(modelNames === undefined ? {} : { modelNames }),
|
|
294
298
|
store,
|
|
295
299
|
io: integrationMutationTestHooks?.io,
|
|
296
300
|
...scopedPathOverrides(ctx, clientId),
|
|
@@ -310,6 +314,7 @@ async function buildIntegrationPreviewInput(
|
|
|
310
314
|
ctx: ManagementContext,
|
|
311
315
|
store: IntegrationStateStore,
|
|
312
316
|
droidReasoningDefaults?: Record<string, string>,
|
|
317
|
+
modelNames?: ExportModelNames,
|
|
313
318
|
): Promise<{ input: IntegrationWriteInput; identity: string } | null> {
|
|
314
319
|
const snapshot = previewExportSnapshot(ctx.config);
|
|
315
320
|
// No cached roster means no honest snapshot to plan against. Gathering one here would make a
|
|
@@ -323,6 +328,7 @@ async function buildIntegrationPreviewInput(
|
|
|
323
328
|
config: ctx.config,
|
|
324
329
|
port: managementInferencePort(ctx),
|
|
325
330
|
...(droidReasoningDefaults === undefined ? {} : { droidReasoningDefaults: { ...droidReasoningDefaults } }),
|
|
331
|
+
...(modelNames === undefined ? {} : { modelNames }),
|
|
326
332
|
store,
|
|
327
333
|
io: integrationMutationTestHooks?.io,
|
|
328
334
|
...scopedPathOverrides(ctx, clientId),
|
|
@@ -383,6 +389,15 @@ function invalidDroidDefaultsResponse(ctx: ManagementContext, message: string):
|
|
|
383
389
|
return jsonResponse({ error: message, code: "invalid_droid_reasoning_defaults" }, 400, ctx.req, ctx.config);
|
|
384
390
|
}
|
|
385
391
|
|
|
392
|
+
function readModelNames(ctx: ManagementContext, body: Record<string, unknown>, client: string, operation: string): ExportModelNames | Response | undefined {
|
|
393
|
+
if (!Object.hasOwn(body, "modelNames")) return undefined;
|
|
394
|
+
if (!isExportModelNames(body.modelNames) || !supportsAliasModelNames(client)
|
|
395
|
+
|| (operation !== "apply" && operation !== "overwrite")) {
|
|
396
|
+
return jsonResponse({ error: "modelNames must be alias or routed and requires Hermes or Command Code apply or overwrite", code: "invalid_model_names" }, 400, ctx.req, ctx.config);
|
|
397
|
+
}
|
|
398
|
+
return body.modelNames;
|
|
399
|
+
}
|
|
400
|
+
|
|
386
401
|
function readDroidReasoningDefaults(
|
|
387
402
|
ctx: ManagementContext,
|
|
388
403
|
body: Record<string, unknown>,
|
|
@@ -455,6 +470,7 @@ function stalePlanGuard(
|
|
|
455
470
|
fingerprint: string,
|
|
456
471
|
capturedIdentity: string | null,
|
|
457
472
|
droidReasoningDefaults?: Record<string, string>,
|
|
473
|
+
modelNames?: ExportModelNames,
|
|
458
474
|
): {
|
|
459
475
|
revalidate: NonNullable<CoordinatedIntegrationOptions["revalidate"]>;
|
|
460
476
|
response: () => Response | null;
|
|
@@ -470,7 +486,7 @@ function stalePlanGuard(
|
|
|
470
486
|
* without ever swapping the roster this mutation is about to use.
|
|
471
487
|
*/
|
|
472
488
|
if (exportSnapshotIdentity(ctx.config) !== capturedIdentity) {
|
|
473
|
-
const refreshed = await buildIntegrationPreviewInput(clientId, ctx, store, droidReasoningDefaults);
|
|
489
|
+
const refreshed = await buildIntegrationPreviewInput(clientId, ctx, store, droidReasoningDefaults, modelNames);
|
|
474
490
|
stale = refreshed === null ? "unavailable" : previewIntegration(refreshed.input, request);
|
|
475
491
|
return { ok: false, reason: "conflict", state: "conflict", clientId, message: "the model roster changed while confirming" };
|
|
476
492
|
}
|
|
@@ -668,6 +684,17 @@ async function handleJournalDelete(ctx: ManagementContext): Promise<Response> {
|
|
|
668
684
|
}
|
|
669
685
|
|
|
670
686
|
export async function handleIntegrationRoutes(ctx: ManagementContext): Promise<Response | null> {
|
|
687
|
+
// Aside delegates before the ordinary client handler. Reject unsupported intent before that
|
|
688
|
+
// delegation can enumerate profiles, load catalogs, or write a different preference.
|
|
689
|
+
if (/^\/api\/client-integrations\/aside\/profiles(?:\/|$)/.test(ctx.url.pathname)
|
|
690
|
+
&& (ctx.req.method === "PUT" || ctx.req.method === "POST")) {
|
|
691
|
+
const body = await readJsonBody({ ...ctx, req: ctx.req.clone() });
|
|
692
|
+
if (body instanceof Response) return body;
|
|
693
|
+
if (isPlainRecord(body)) {
|
|
694
|
+
const naming = readModelNames(ctx, body, "aside", "apply");
|
|
695
|
+
if (naming instanceof Response) return naming;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
671
698
|
const hermesBase = { store: integrationStore(), ...pathOverrides() };
|
|
672
699
|
const hermesProfiles = await hermesProfileListResponse(ctx, hermesBase, () => loadExportModels(ctx.config),
|
|
673
700
|
(scope, models) => readIntegrationState({
|
|
@@ -836,9 +863,11 @@ export async function handleIntegrationRoutes(ctx: ManagementContext): Promise<R
|
|
|
836
863
|
}
|
|
837
864
|
const droidDefaults = readDroidReasoningDefaults(ctx, parsed, previewClient, operation);
|
|
838
865
|
if (droidDefaults instanceof Response) return droidDefaults;
|
|
866
|
+
const modelNames = readModelNames(ctx, parsed, previewClient, operation);
|
|
867
|
+
if (modelNames instanceof Response) return modelNames;
|
|
839
868
|
try {
|
|
840
869
|
const captured = await buildIntegrationPreviewInput(
|
|
841
|
-
previewClient as IntegrationClientId, ctx, integrationStore(ctx), droidDefaults,
|
|
870
|
+
previewClient as IntegrationClientId, ctx, integrationStore(ctx), droidDefaults, modelNames,
|
|
842
871
|
);
|
|
843
872
|
if (!captured) return previewUnavailableResponse(ctx);
|
|
844
873
|
if (droidDefaults !== undefined) {
|
|
@@ -855,6 +884,10 @@ export async function handleIntegrationRoutes(ctx: ManagementContext): Promise<R
|
|
|
855
884
|
if (req.method !== "POST") return null;
|
|
856
885
|
const parsed = await readJsonBody(ctx);
|
|
857
886
|
if (parsed instanceof Response) return parsed;
|
|
887
|
+
if (isPlainRecord(parsed)) {
|
|
888
|
+
const naming = readModelNames(ctx, parsed, "", "restore");
|
|
889
|
+
if (naming instanceof Response) return naming;
|
|
890
|
+
}
|
|
858
891
|
if (!isPlainRecord(parsed) || typeof parsed.opId !== "string" || parsed.opId.trim().length === 0) {
|
|
859
892
|
return jsonResponse({ error: "opId must be a non-empty string", code: "invalid_op_id" }, 400, req, ctx.config);
|
|
860
893
|
}
|
|
@@ -901,6 +934,10 @@ export async function handleIntegrationRoutes(ctx: ManagementContext): Promise<R
|
|
|
901
934
|
if (req.method !== "POST") return null;
|
|
902
935
|
const parsed = await readJsonBody(ctx);
|
|
903
936
|
if (parsed instanceof Response) return parsed;
|
|
937
|
+
if (isPlainRecord(parsed)) {
|
|
938
|
+
const naming = readModelNames(ctx, parsed, "", "restore");
|
|
939
|
+
if (naming instanceof Response) return naming;
|
|
940
|
+
}
|
|
904
941
|
if (!isPlainRecord(parsed) || typeof parsed.opId !== "string" || parsed.opId.trim().length === 0) {
|
|
905
942
|
return jsonResponse({
|
|
906
943
|
error: "opId must be a non-empty string",
|
|
@@ -1080,6 +1117,8 @@ export async function handleIntegrationRoutes(ctx: ManagementContext): Promise<R
|
|
|
1080
1117
|
: "disable";
|
|
1081
1118
|
const droidDefaults = readDroidReasoningDefaults(ctx, parsed, requestedClient, requestedOperation);
|
|
1082
1119
|
if (droidDefaults instanceof Response) return droidDefaults;
|
|
1120
|
+
const modelNames = readModelNames(ctx, parsed, requestedClient, requestedOperation);
|
|
1121
|
+
if (modelNames instanceof Response) return modelNames;
|
|
1083
1122
|
const binding = planBindingOf(parsed);
|
|
1084
1123
|
if (binding === "half") return halfBoundResponse(ctx);
|
|
1085
1124
|
if (binding === "unknown-operation" || (binding !== "none" && binding.operation !== requestedOperation)) {
|
|
@@ -1100,11 +1139,11 @@ export async function handleIntegrationRoutes(ctx: ManagementContext): Promise<R
|
|
|
1100
1139
|
*/
|
|
1101
1140
|
const boundToggle = binding === "none"
|
|
1102
1141
|
? null
|
|
1103
|
-
: await buildIntegrationPreviewInput(requestedClient, ctx, integrationStore(ctx), droidDefaults);
|
|
1142
|
+
: await buildIntegrationPreviewInput(requestedClient, ctx, integrationStore(ctx), droidDefaults, modelNames);
|
|
1104
1143
|
if (binding !== "none" && boundToggle === null) return previewUnavailableResponse(ctx);
|
|
1105
1144
|
const input = boundToggle
|
|
1106
1145
|
? boundToggle.input
|
|
1107
|
-
: await buildIntegrationWriteInput(requestedClient, ctx, integrationStore(ctx), droidDefaults);
|
|
1146
|
+
: await buildIntegrationWriteInput(requestedClient, ctx, integrationStore(ctx), droidDefaults, modelNames);
|
|
1108
1147
|
if (droidDefaults !== undefined) {
|
|
1109
1148
|
const invalid = validateDroidReasoningDefaults(input.models, droidDefaults);
|
|
1110
1149
|
if (invalid) return invalidDroidDefaultsResponse(ctx, invalid);
|
|
@@ -1117,10 +1156,11 @@ export async function handleIntegrationRoutes(ctx: ManagementContext): Promise<R
|
|
|
1117
1156
|
binding.fingerprint,
|
|
1118
1157
|
boundToggle === null ? null : boundToggle.identity,
|
|
1119
1158
|
droidDefaults,
|
|
1159
|
+
modelNames,
|
|
1120
1160
|
);
|
|
1121
1161
|
const result = await runIntegrationMutationFlight(
|
|
1122
1162
|
requestedClient,
|
|
1123
|
-
scopedFlightKey(ctx,
|
|
1163
|
+
scopedFlightKey(ctx, `${requestedOperation}:modelNames:${modelNames ?? "omitted"}`),
|
|
1124
1164
|
input.io?.now ?? Date.now,
|
|
1125
1165
|
() => {
|
|
1126
1166
|
const options = {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { tmpdir } from "node:os";
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
-
import { assertSshAlias, buildExecArgv, buildFingerprintArgv, buildProbeArgv, REMOTE_COMMAND_NOT_FOUND,
|
|
4
|
+
import { assertSshAlias, buildExecArgv, buildFingerprintArgv, buildProbeArgv, REMOTE_COMMAND_NOT_FOUND, remoteOcxArgv } from "../../link/ssh-argv";
|
|
5
5
|
import { parseFingerprintLine } from "../../link/fingerprint";
|
|
6
|
-
import {
|
|
6
|
+
import { requireRemotePlatform } from "../../link/remote-platform";
|
|
7
7
|
import type { SshRunner } from "../../link/ssh-runner";
|
|
8
8
|
import { LINK_CATALOG_MAX_BYTES, LINK_RELAY_VERIFY_MS, isChildHealth, linkCommandBudget, linkRestartBudget, parseChildHttp, remoteChildHttpArgv, REMOTE_CURL_PREFLIGHT } from "../../link/remote-probe";
|
|
9
9
|
import { newLinkId, type LinkStore } from "../../link/store";
|
|
@@ -26,23 +26,10 @@ async function serialized(state: LinkRouteState, alias: string, action: () => Pr
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
function remoteFailure(result: SshRunResult, code: string, message: string): Response | null {
|
|
29
|
-
if (result.code === REMOTE_PLATFORM_UNSUPPORTED || (result.code !== 0 && isWindowsShellRefusal(result.stderr))) return windowsRefusal();
|
|
30
29
|
if (result.code === REMOTE_COMMAND_NOT_FOUND) return fail("remote_ocx_missing", "ocx was not found on the remote host.", 502, sshFailureHint(result.stderr));
|
|
31
30
|
return result.code === 0 ? null : fail(code, message, 502, sshFailureHint(result.stderr));
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
function windowsRefusal(): Response {
|
|
35
|
-
return fail("remote_platform_unsupported", WINDOWS_CHILD_REFUSAL, 409);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Pre-issuance Windows gate for a failed remote command: exit 125, the English cmd/PowerShell
|
|
40
|
-
* refusal, or (for localized shells) the fixed %OS% probe against the same host key.
|
|
41
|
-
*/
|
|
42
|
-
async function windowsChild(runner: SshRunner, alias: string, knownHostsFile: string, result: SshRunResult): Promise<boolean> {
|
|
43
|
-
return result.code !== 0 && await detectRemotePlatform(runner, alias, knownHostsFile, result) === "windows";
|
|
44
|
-
}
|
|
45
|
-
|
|
46
33
|
export async function probe(ctx: ManagementContext, state: LinkRouteState): Promise<Response> {
|
|
47
34
|
const value = await readManagementJsonBodyOr(ctx.req, null);
|
|
48
35
|
const body = exactBody(value, ["alias"]) ?? exactBody(value, ["alias", "includeVersion"]);
|
|
@@ -58,24 +45,23 @@ export async function probe(ctx: ManagementContext, state: LinkRouteState): Prom
|
|
|
58
45
|
const started = now();
|
|
59
46
|
const result = await runner.run(buildProbeArgv({ alias, tempKnownHostsFile: path }), { timeoutMs: 30_000 });
|
|
60
47
|
const latency = Math.max(0, now() - started);
|
|
61
|
-
|
|
62
|
-
if (result.code !== 0) return await windowsChild(runner, alias, path, result) ? windowsRefusal() : fail("probe_failed", "SSH host probing failed.", 502, sshFailureHint(result.stderr));
|
|
48
|
+
if (result.code !== 0 || result.stdout.trim() !== "ocx-link-probe") return fail("probe_failed", "SSH host probing failed.", 502, sshFailureHint(result.stderr));
|
|
63
49
|
const fp = await runner.run(buildFingerprintArgv(path), { timeoutMs: 10_000 });
|
|
64
50
|
if (fp.code !== 0) return fail("fingerprint_failed", "The SSH host fingerprint could not be read.", 502, sshFailureHint(fp.stderr));
|
|
65
51
|
const parsed = parseFingerprintLine(fp.stdout.trim());
|
|
66
52
|
const line = readFileSync(path, "utf8").trim().split(/\r?\n/).filter(Boolean).at(-1);
|
|
67
53
|
if (!line) return fail("fingerprint_failed", "The SSH probe did not record a host key.", 502);
|
|
54
|
+
const remotePlatform = await requireRemotePlatform(runner, alias, path);
|
|
68
55
|
let ocxVersion: string | undefined;
|
|
69
56
|
if (body.includeVersion === true) {
|
|
70
|
-
const versionResult = await runner.run(buildExecArgv({ alias, argv: remoteOcxArgv(["--version"]), knownHostsFile: path }), { timeoutMs: 30_000 });
|
|
71
|
-
if (await windowsChild(runner, alias, path, versionResult)) return windowsRefusal();
|
|
57
|
+
const versionResult = await runner.run(buildExecArgv({ alias, argv: remoteOcxArgv(["--version"], remotePlatform), knownHostsFile: path }), { timeoutMs: 30_000 });
|
|
72
58
|
const denied = remoteFailure(versionResult, "version_probe_failed", "The remote ocx version could not be read.");
|
|
73
59
|
if (denied) return denied;
|
|
74
60
|
const parsedVersion = parseVersion(versionResult.stdout);
|
|
75
61
|
if (!parsedVersion) return fail("remote_ocx_unrecognized", "The remote ocx did not report an OpenCodex version.", 502);
|
|
76
62
|
ocxVersion = parsedVersion.version;
|
|
77
63
|
}
|
|
78
|
-
state.pendingHosts.set(alias, { alias, fingerprint: parsed.fingerprint, keyType: parsed.keyType, knownHostLine: line, probedAt: now(), sshLatencyMs: latency });
|
|
64
|
+
state.pendingHosts.set(alias, { alias, fingerprint: parsed.fingerprint, keyType: parsed.keyType, knownHostLine: line, probedAt: now(), sshLatencyMs: latency, remotePlatform });
|
|
79
65
|
state.confirmedHosts?.delete(alias);
|
|
80
66
|
return Response.json({ alias, fingerprint: parsed.fingerprint, keyType: parsed.keyType, ...(ocxVersion === undefined ? {} : { ocxVersion }) });
|
|
81
67
|
} catch (error) { return fail("probe_failed", "SSH host probing failed.", 502, sshRunnerErrorHint(error)); }
|
|
@@ -101,8 +87,8 @@ export async function confirmHost(ctx: ManagementContext, state: LinkRouteState)
|
|
|
101
87
|
try {
|
|
102
88
|
const started = now();
|
|
103
89
|
const runner = runnerFor(ctx);
|
|
104
|
-
const
|
|
105
|
-
|
|
90
|
+
const remotePlatform = pending.remotePlatform ?? await requireRemotePlatform(runner, alias, path);
|
|
91
|
+
const result = await runner.run(buildExecArgv({ alias, argv: remoteOcxArgv(["--version"], remotePlatform), knownHostsFile: path }), { timeoutMs: 30_000 });
|
|
106
92
|
const denied = remoteFailure(result, "version_probe_failed", "The remote ocx version could not be confirmed.");
|
|
107
93
|
if (denied) return denied;
|
|
108
94
|
const version = parseVersion(result.stdout);
|
|
@@ -111,7 +97,7 @@ export async function confirmHost(ctx: ManagementContext, state: LinkRouteState)
|
|
|
111
97
|
if (cmp >= 0 && version.parts[cmp]! < MIN_REMOTE_OCX[cmp]!) return fail("remote_ocx_outdated", "The remote OpenCodex is older than 2.66.0.", 409, boundHint("opencodex " + version.version));
|
|
112
98
|
if (state.pendingHosts.get(alias) !== pending || now() - pending.probedAt > PROBE_TTL_MS) return fail("host_confirmation_expired", "The SSH host probe changed or expired.", 409);
|
|
113
99
|
withConfigMutationLockSync(() => putKnownHost(knownHostsFile(ctx), alias, pending.knownHostLine));
|
|
114
|
-
const confirmed = { ...pending, sshLatencyMs: Math.max(pending.sshLatencyMs ?? 0, now() - started), ocxVersion: version.version };
|
|
100
|
+
const confirmed = { ...pending, remotePlatform, sshLatencyMs: Math.max(pending.sshLatencyMs ?? 0, now() - started), ocxVersion: version.version };
|
|
115
101
|
(state.confirmedHosts ??= new Map()).set(alias, confirmed);
|
|
116
102
|
state.pendingHosts.delete(alias);
|
|
117
103
|
return Response.json({ alias, fingerprint: pending.fingerprint, ocxVersion: version.version });
|
|
@@ -140,6 +126,8 @@ export async function apply(ctx: ManagementContext, state: LinkRouteState): Prom
|
|
|
140
126
|
writeFileSync(knownHosts, confirmed.knownHostLine + "\n", { mode: 0o600 });
|
|
141
127
|
const runner = runnerFor(ctx), budget = linkCommandBudget(confirmed.sshLatencyMs);
|
|
142
128
|
const run = (argv: readonly string[], timeoutMs = budget, maxOutputBytes?: number) => runner.run(buildExecArgv({ alias, argv, knownHostsFile: knownHosts }), { timeoutMs, ...(maxOutputBytes === undefined ? {} : { maxOutputBytes }) });
|
|
129
|
+
let remotePlatform: "posix" | "windows";
|
|
130
|
+
const ocx = (args: readonly string[]) => remoteOcxArgv(args, remotePlatform);
|
|
143
131
|
let record: LinkStore["links"][number] | undefined, input: Uint8Array | undefined;
|
|
144
132
|
let remoteMayBeConnected = false, phase = "remote_port";
|
|
145
133
|
const failed = async (response: Response): Promise<Response> => {
|
|
@@ -150,26 +138,27 @@ export async function apply(ctx: ManagementContext, state: LinkRouteState): Prom
|
|
|
150
138
|
return Response.json({ ...payload, residual: true, recovery: "Run ocx disconnect and ocx restart on the Child before retrying." }, { status: outcome.status });
|
|
151
139
|
};
|
|
152
140
|
try {
|
|
153
|
-
|
|
141
|
+
remotePlatform = confirmed.remotePlatform ?? await requireRemotePlatform(runner, alias, knownHosts);
|
|
142
|
+
const chosen = await run(ocx(["link", "port"]));
|
|
154
143
|
const denied = remoteFailure(chosen, "remote_port_failed", "The remote link port could not be determined.");
|
|
155
144
|
if (denied) return denied;
|
|
156
145
|
const remotePort = parsePort(chosen.stdout);
|
|
157
146
|
if (!remotePort) return fail("remote_port_failed", "The remote link port could not be determined.", 502);
|
|
158
147
|
phase = "child_preflight";
|
|
159
|
-
const configured = await run(
|
|
148
|
+
const configured = await run(ocx(["config", "show", "--json"]));
|
|
160
149
|
let childConfig: unknown = null;
|
|
161
150
|
try { if (configured.code === 0) childConfig = JSON.parse(configured.stdout); } catch { /* fail closed */ }
|
|
162
151
|
if (!isRecord(childConfig) || !port(childConfig.port)) return fail("child_preflight_failed", "The Child effective configuration could not be read.", 502);
|
|
163
152
|
if ((childConfig.runtimeRole ?? "standalone") !== "standalone") return fail("child_restart_unsupported", "The Child must run standalone OpenCodex; an existing Hub or Child cannot be converted by Add Child.", 409);
|
|
164
153
|
const childPort = childConfig.port;
|
|
165
|
-
if ((await run(REMOTE_CURL_PREFLIGHT)).code !== 0) return fail("child_curl_missing", "Install curl on the Child before connecting a Remote Link.", 409);
|
|
166
|
-
const before = await run(remoteChildHttpArgv(childPort, "healthz"));
|
|
154
|
+
if (remotePlatform === "posix" && (await run(REMOTE_CURL_PREFLIGHT)).code !== 0) return fail("child_curl_missing", "Install curl on the Child before connecting a Remote Link.", 409);
|
|
155
|
+
const before = await run(remoteChildHttpArgv(childPort, "healthz", LINK_RELAY_VERIFY_MS, remotePlatform));
|
|
167
156
|
const beforeHealth = before.code === 0 ? parseChildHttp(before.stdout) : null;
|
|
168
157
|
if (!isChildHealth(beforeHealth, "standalone", childPort)) return fail("child_restart_unsupported", "The Child must run a standalone OpenCodex with bound restart support; update or disconnect it before linking.", 409);
|
|
169
158
|
state.confirmedHosts?.delete(alias);
|
|
170
159
|
phase = "home_setup";
|
|
171
160
|
const id = newLinkId(), issued = issueKey(ctx, "link:" + alias);
|
|
172
|
-
record = { id, alias, direction: "hub-initiated", hostKeyFingerprint: confirmed.fingerprint, tunnelPort: remotePort, apiKeyId: issued.id, createdAt: new Date(now()).toISOString() };
|
|
161
|
+
record = { id, alias, direction: "hub-initiated", hostKeyFingerprint: confirmed.fingerprint, tunnelPort: remotePort, apiKeyId: issued.id, createdAt: new Date(now()).toISOString(), remotePlatform };
|
|
173
162
|
withConfigMutationLockSync(() => {
|
|
174
163
|
const current = readStoreFor(ctx);
|
|
175
164
|
if (current.links.some(link => link.alias === alias && link.direction === "hub-initiated")) throw new Error("link exists");
|
|
@@ -182,22 +171,22 @@ export async function apply(ctx: ManagementContext, state: LinkRouteState): Prom
|
|
|
182
171
|
phase = "remote_connect";
|
|
183
172
|
input = new TextEncoder().encode(JSON.stringify({ apiKeyId: issued.id, key: issued.key }));
|
|
184
173
|
remoteMayBeConnected = true;
|
|
185
|
-
const connected = await runner.run(buildExecArgv({ alias, argv:
|
|
174
|
+
const connected = await runner.run(buildExecArgv({ alias, argv: ocx(["connect", "--link", "--key-stdin", "--tunnel-port", String(remotePort), "--link-id", id]), knownHostsFile: knownHosts }), { stdin: input, timeoutMs: budget });
|
|
186
175
|
const connectDenied = remoteFailure(connected, "remote_connect_failed", "The Child enrollment command failed.");
|
|
187
176
|
if (connectDenied) return await failed(connectDenied);
|
|
188
177
|
input.fill(0);
|
|
189
178
|
phase = "child_restart";
|
|
190
|
-
const restarted = await run(
|
|
179
|
+
const restarted = await run(ocx(["restart"]), linkRestartBudget(confirmed.sshLatencyMs));
|
|
191
180
|
if (restarted.code !== 0) return await failed(fail("child_restart_failed", "The Child restart could not be verified.", 502, sshFailureHint(restarted.stderr)));
|
|
192
181
|
phase = "child_relay";
|
|
193
182
|
const deadline = now() + LINK_RELAY_VERIFY_MS, remaining = () => Math.max(1, deadline - now());
|
|
194
|
-
const health = await run(remoteChildHttpArgv(childPort, "healthz", remaining()), remaining());
|
|
183
|
+
const health = await run(remoteChildHttpArgv(childPort, "healthz", remaining(), remotePlatform), remaining());
|
|
195
184
|
if (!isChildHealth(health.code === 0 ? parseChildHttp(health.stdout) : null, "client", childPort)) return await failed(fail("child_runtime_not_client", "The Child is not serving the client runtime after restart.", 502));
|
|
196
185
|
let admitted = false;
|
|
197
186
|
const unsubscribe = state.listener.onAuthenticatedCatalog(keyId => { if (keyId === issued.id) admitted = true; });
|
|
198
187
|
try {
|
|
199
188
|
if (now() >= deadline) return await failed(fail("child_relay_timeout", "The Child relay verification deadline expired.", 502));
|
|
200
|
-
const catalog = await run(remoteChildHttpArgv(childPort, "v1/catalog", remaining()), remaining(), LINK_CATALOG_MAX_BYTES);
|
|
189
|
+
const catalog = await run(remoteChildHttpArgv(childPort, "v1/catalog", remaining(), remotePlatform), remaining(), LINK_CATALOG_MAX_BYTES);
|
|
201
190
|
let data: unknown = null;
|
|
202
191
|
try { if (catalog.code === 0) data = parseChildHttp(catalog.stdout); } catch { /* malformed is not a completed catalog */ }
|
|
203
192
|
if (!isRecord(data) || !Array.isArray(data.models) || !admitted || now() > deadline) return await failed(fail("child_relay_failed", "The Child did not relay a complete authenticated catalog through this Home.", 502));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { probe, confirmHost, apply } from "./link-enrollment";
|
|
2
2
|
import { fail, pairedSession, auth, port, isRecord, exactBody, runnerFor, readStoreFor, writeStoreFor, knownHostsFile, issueKey, revokeKeyIdempotent, compensateNewLink, type LinkRouteState } from "./link-route-state";
|
|
3
3
|
export type { LinkRouteState, PendingLinkHost, ConfirmedLinkHost, LinkRouteListener } from "./link-route-state";
|
|
4
|
+
import { requireRemotePlatform } from "../../link/remote-platform";
|
|
4
5
|
import { assertSshAlias, buildExecArgv, remoteOcxArgv } from "../../link/ssh-argv";
|
|
5
6
|
import { clearCompensationFailed, compensationPath, readCompensation } from "../../link/compensation";
|
|
6
7
|
import { loadHostCandidates } from "../../link/ssh-config";
|
|
@@ -217,7 +218,9 @@ async function remove(ctx: ManagementContext, state: LinkRouteState, id: string)
|
|
|
217
218
|
};
|
|
218
219
|
if (!force && record.direction === "hub-initiated") {
|
|
219
220
|
try {
|
|
220
|
-
const
|
|
221
|
+
const runner = runnerFor(ctx);
|
|
222
|
+
const platform = record.remotePlatform ?? await requireRemotePlatform(runner, record.alias, knownHostsFile(ctx));
|
|
223
|
+
const result = await runner.run(buildExecArgv({ alias: record.alias, argv: remoteOcxArgv(["disconnect"], platform), knownHostsFile: knownHostsFile(ctx) }), { timeoutMs: 30_000 });
|
|
221
224
|
if (result.code !== 0) {
|
|
222
225
|
await restartTunnel();
|
|
223
226
|
return fail("remote_disconnect_failed", "The remote client could not be disconnected.", 502, sshFailureHint(result.stderr));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import { shouldInjectApiAuthHeader } from "../../codex/loopback-target";
|
|
4
|
+
import { isExportModelNames, supportsAliasModelNames } from "../../clients/config-export/model-names";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Codex parses a catalog entry's `input_modalities` as a closed enum, and one out-of-enum
|
|
@@ -150,8 +151,8 @@ import { estimateComboCost, estimateRequestCost, normalizeCostTokens, tokensPerS
|
|
|
150
151
|
import type { PersistedUsageAttempt } from "../../usage/log";
|
|
151
152
|
import { isAllowedRequestOrigin, jsonResponse, providerManagementConfigError, publicProviderBaseUrl, safeConfigDTO, corsHeaders } from "../auth-cors";
|
|
152
153
|
import { applySystemEnvToggle } from "../system-env";
|
|
154
|
+
import { ClientPathError } from "../../clients/client-path";
|
|
153
155
|
import {
|
|
154
|
-
ClientPathError,
|
|
155
156
|
EXPORT_CLIENTS,
|
|
156
157
|
EXPORT_CLIENT_IDS,
|
|
157
158
|
OPENCODE_PROVIDER_ID,
|
|
@@ -169,7 +170,7 @@ import type {
|
|
|
169
170
|
import { isPlainRecord, parseDebugLogQuery, tokPerSecondResult, unavailableCostReason, costResult, requestLogDto, stripRegistryOnlyStaticHeaders, fetchAllModels } from "./shared";
|
|
170
171
|
import type { MetricUnavailableReason, TokPerSecondResult, CostEstimateReason, CostResult, MetricSource } from "./shared";
|
|
171
172
|
import { managementInferencePort, type ManagementContext } from "./context";
|
|
172
|
-
import { effectiveModelReasoningEfforts, inheritedModelReasoningEfforts, listManagementModelRows, loadExportModels } from "./model-rows";
|
|
173
|
+
import { effectiveModelReasoningEfforts, inheritedModelReasoningEfforts, listManagementModelRows, loadExportModels, previewExportSnapshot } from "./model-rows";
|
|
173
174
|
import { initialModelSelectionPending } from "../../providers/initial-model-selection";
|
|
174
175
|
import { readManagementJsonBody, rethrowManagementBodyTooLarge } from "./body";
|
|
175
176
|
import {
|
|
@@ -539,6 +540,16 @@ export async function handleModelRoutes(ctx: ManagementContext): Promise<Respons
|
|
|
539
540
|
config,
|
|
540
541
|
);
|
|
541
542
|
}
|
|
543
|
+
const namingOptions = url.searchParams.getAll("modelNames");
|
|
544
|
+
const modelNames = namingOptions[0];
|
|
545
|
+
if (namingOptions.length > 1 || (modelNames !== undefined
|
|
546
|
+
&& (!isExportModelNames(modelNames) || !supportsAliasModelNames(requested)))) {
|
|
547
|
+
return jsonResponse({ error: "modelNames must be alias or routed and requires Hermes or Command Code", code: "invalid_model_names" }, 400, req, config);
|
|
548
|
+
}
|
|
549
|
+
const passive = url.searchParams.get("preview") === "1";
|
|
550
|
+
if (passive && !supportsAliasModelNames(requested)) {
|
|
551
|
+
return jsonResponse({ error: "passive export preview requires Hermes or Command Code", code: "invalid_export_preview" }, 400, req, config);
|
|
552
|
+
}
|
|
542
553
|
const spec = EXPORT_CLIENTS[requested];
|
|
543
554
|
// Resolved before the catalog load on purpose. A refused override is a
|
|
544
555
|
// property of the request, not of the catalog: validating it afterwards
|
|
@@ -561,19 +572,23 @@ export async function handleModelRoutes(ctx: ManagementContext): Promise<Respons
|
|
|
561
572
|
if (!(error instanceof ClientPathError)) throw error;
|
|
562
573
|
return jsonResponse({ error: error.message }, 400, req, config);
|
|
563
574
|
}
|
|
564
|
-
if ((requested === "raycast" || requested === "droid" || requested === "qoder" || requested === "qoder-cn" || requested === "workbuddy" || requested === "workbuddy-ai") && shouldInjectApiAuthHeader(config)) {
|
|
575
|
+
if ((requested === "t3code" || requested === "raycast" || requested === "droid" || requested === "qoder" || requested === "qoder-cn" || requested === "workbuddy" || requested === "workbuddy-ai") && shouldInjectApiAuthHeader(config)) {
|
|
565
576
|
return jsonResponse({
|
|
566
|
-
error: `${requested === "droid" ? "Factory Droid" : requested.startsWith("qoder") ? "Qoder" : requested.startsWith("workbuddy") ? "WorkBuddy" : "Raycast"} export requires an unauthenticated loopback destination; this listener requires an admission header the client cannot supply.`,
|
|
577
|
+
error: `${requested === "t3code" ? "T3 Code" : requested === "droid" ? "Factory Droid" : requested.startsWith("qoder") ? "Qoder" : requested.startsWith("workbuddy") ? "WorkBuddy" : "Raycast"} export requires an unauthenticated loopback destination; this listener requires an admission header the client cannot supply.`,
|
|
567
578
|
reason: "non_loopback",
|
|
568
579
|
}, 400, req, config);
|
|
569
580
|
}
|
|
570
581
|
const baseUrl = opencodeProxyBaseUrl(managementInferencePort(ctx), config.hostname, config);
|
|
571
|
-
let models: ExportModel[];
|
|
582
|
+
let models: readonly ExportModel[];
|
|
572
583
|
try {
|
|
573
584
|
// The ONE loader every export surface uses. It carries the visibility
|
|
574
585
|
// filter with it, so this route and the integration routes cannot end up
|
|
575
586
|
// telling a client about different models.
|
|
576
|
-
|
|
587
|
+
if (passive) {
|
|
588
|
+
const snapshot = previewExportSnapshot(config);
|
|
589
|
+
if (snapshot === null) return jsonResponse({ error: "no current model roster is cached", code: "integration_preview_unavailable" }, 409, req, config);
|
|
590
|
+
models = snapshot.models;
|
|
591
|
+
} else models = await loadExportModels(config);
|
|
577
592
|
} catch (error) {
|
|
578
593
|
// A partial or empty `models` block reads as a valid config while offering nothing,
|
|
579
594
|
// so a catalog failure is surfaced as unavailable rather than serialized. The
|
|
@@ -590,6 +605,7 @@ export async function handleModelRoutes(ctx: ManagementContext): Promise<Respons
|
|
|
590
605
|
baseUrl,
|
|
591
606
|
models,
|
|
592
607
|
config,
|
|
608
|
+
...(modelNames === undefined ? {} : { modelNames }),
|
|
593
609
|
});
|
|
594
610
|
const document = built.document;
|
|
595
611
|
return jsonResponse({
|
|
@@ -39,6 +39,7 @@ import {
|
|
|
39
39
|
type ExportModel,
|
|
40
40
|
} from "../../clients/config-export/contracts";
|
|
41
41
|
import { customRowExportMetadata } from "./model-row-export-metadata";
|
|
42
|
+
import { attachExportAliasSelectors } from "../../clients/config-export/alias-selectors";
|
|
42
43
|
import { resolveExportReasoningAxes } from "../../clients/config-export/reasoning-metadata";
|
|
43
44
|
import { providerContextCap } from "../../providers/context-cap";
|
|
44
45
|
import { isVisionReasoningEffort, modelRecordValue, sanitizeCodexReasoningEfforts } from "../../reasoning-effort";
|
|
@@ -671,7 +672,8 @@ export async function loadExportModels(
|
|
|
671
672
|
// Management deliberately lists the full roster so hidden models can be enabled.
|
|
672
673
|
// A client picker must also honor the provider selection, not just its blocklist.
|
|
673
674
|
const visibleRouted = new Set(filterCatalogVisibleModels(rows.filter(row => !row.native), admitted));
|
|
674
|
-
const
|
|
675
|
+
const projected = attachExportAliasSelectors(admitted, rows.map(toExportModel));
|
|
676
|
+
const exported = projected.filter((_, index) => !rows[index]!.disabled && (rows[index]!.native || visibleRouted.has(rows[index]!)));
|
|
675
677
|
// Retain the FINAL projection, not an input to it. A preview that rebuilt from raw provider
|
|
676
678
|
// caches would miss static and forward providers, which never populate one, and would skip the
|
|
677
679
|
// retention, metadata, combo and filtering this function applies afterwards.
|