@bitkyc08/opencodex 2.91.0 → 2.93.0-preview.20261027
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/bin/ocx.mjs +47 -8
- package/gui/dist/assets/App-CJZoq-uF.js +58 -0
- package/gui/dist/assets/{Tray-BuLy7hL1.js → Tray-BWQPcgZn.js} +1 -1
- package/gui/dist/assets/index-DRe8Hhfz.css +1 -0
- package/gui/dist/assets/index-Xfct8owH.js +94 -0
- package/gui/dist/assets/quota-summary-DxToX1rV.js +1 -0
- package/gui/dist/index.html +2 -2
- package/gui/dist/provider-icons/workbuddy-color.svg +29 -0
- package/package.json +8 -7
- package/src/adapters/anthropic.ts +28 -5
- package/src/adapters/coding-agent/batch-dispatcher.ts +122 -0
- package/src/adapters/coding-agent/profile.ts +54 -16
- package/src/adapters/coding-agent/turn.ts +30 -2
- package/src/adapters/command-code.ts +114 -7
- package/src/adapters/cursor/native-exec-fs.ts +11 -9
- package/src/adapters/devin/live-models.ts +4 -0
- package/src/adapters/google-vertex-endpoint.ts +9 -1
- package/src/adapters/google-vertex-key-project.ts +223 -0
- package/src/adapters/google-wire-compiler.ts +1 -2
- package/src/adapters/google.ts +13 -3
- package/src/adapters/kiro/reasoning.ts +2 -0
- package/src/adapters/kiro-refusal.ts +6 -1
- package/src/adapters/kiro-wire.ts +1 -1
- package/src/adapters/openai-chat/messages.ts +8 -2
- package/src/adapters/openai-chat/passthrough.ts +35 -14
- package/src/adapters/openai-chat/reasoning-replay.ts +27 -16
- package/src/adapters/openai-chat/reasoning-wire.ts +117 -8
- package/src/adapters/openai-chat/required-tool-result.ts +64 -0
- package/src/adapters/openai-chat/tool-name-registry.ts +3 -1
- package/src/adapters/openai-chat.ts +9 -10
- package/src/adapters/openai-responses/passthrough.ts +7 -4
- package/src/adapters/openai-responses/reasoning.ts +13 -0
- package/src/adapters/openai-responses/request-strips.ts +60 -0
- package/src/adapters/qoder/adapter.ts +129 -8
- package/src/adapters/qoder/scaffold-guard.ts +5 -0
- package/src/adapters/reasoning-controls.ts +16 -0
- package/src/adapters/registry.ts +5 -0
- package/src/adapters/tool-call-id.ts +1 -3
- package/src/adapters/workbuddy-schema.ts +61 -0
- package/src/adapters/workbuddy.ts +68 -0
- package/src/bridge/errors.ts +27 -0
- package/src/bridge/response-json.ts +1 -1
- package/src/bridge/sse.ts +1 -1
- package/src/bridge.ts +1 -1
- package/src/chat/inbound.ts +4 -1
- package/src/chat/outbound.ts +20 -6
- package/src/chat/reasoning-details.ts +28 -5
- package/src/claude/desktop-first-party.ts +54 -4
- package/src/claude/desktop-picker.ts +11 -8
- package/src/claude/first-party-settings.ts +3 -1
- package/src/claude/inbound.ts +2 -1
- package/src/claude/intercept/local-ca.ts +2 -1
- package/src/claude/intercept/picker-ca-cleanup.ts +4 -2
- package/src/claude/intercept/picker-ca-startup.ts +3 -1
- package/src/claude/intercept/picker-models.ts +6 -3
- package/src/claude/intercept/picker-runtime.ts +3 -2
- package/src/claude/intercept/runtime.ts +6 -3
- package/src/claude/model-info.ts +31 -8
- package/src/cli/account-api.ts +11 -0
- package/src/cli/capabilities-agents-routing.ts +3 -3
- package/src/cli/capabilities-base.ts +7 -1
- package/src/cli/capabilities-observe-system.ts +10 -0
- package/src/cli/claude-desktop.ts +9 -8
- package/src/cli/claude.ts +3 -2
- package/src/cli/codex-cli-update.ts +8 -0
- package/src/cli/codex-shim-autorestore.ts +9 -0
- package/src/cli/combo-result.ts +13 -0
- package/src/cli/combo-stats.ts +3 -0
- package/src/cli/combo.ts +83 -41
- package/src/cli/cross-home-owner.ts +13 -1
- package/src/cli/dispatch.ts +25 -6
- package/src/cli/ensure-desired-integrations.ts +8 -6
- package/src/cli/export-command.ts +4 -1
- package/src/cli/help.ts +2 -1
- package/src/cli/index.ts +45 -45
- package/src/cli/integration-plan-dto.ts +4 -0
- package/src/cli/launcher-context.ts +49 -2
- package/src/cli/link.ts +45 -32
- package/src/cli/opencode.ts +20 -9
- package/src/cli/provider.ts +2 -1
- package/src/cli/registry.ts +6 -4
- package/src/cli/root.ts +9 -0
- package/src/cli/status.ts +59 -1
- package/src/cli/stop-restore.ts +113 -0
- package/src/cli/sync-expectation.ts +60 -0
- package/src/cli/uninstall-integrations.ts +41 -7
- package/src/cli/usage-compare.ts +68 -12
- package/src/client/connect.ts +40 -3
- package/src/client/link-home.ts +10 -1
- package/src/client/link-ingress.ts +1 -1
- package/src/client/link-readiness.ts +97 -0
- package/src/client/link-relay-transport.ts +79 -11
- package/src/client/link-relay.ts +74 -15
- package/src/client/link-tunnel.ts +45 -18
- package/src/client/machine-api.ts +3 -1
- package/src/client/machine-listener.ts +20 -2
- package/src/client/runtime.ts +20 -2
- package/src/client/sync-expectation.ts +118 -0
- package/src/clients/config-export/agent-clients.ts +96 -0
- package/src/clients/config-export/contracts.ts +25 -7
- package/src/clients/config-export/qoder.ts +38 -23
- package/src/clients/config-export/reasoning-metadata.ts +55 -8
- package/src/clients/config-export.ts +12 -0
- package/src/clients/lazycodex.ts +7 -2
- package/src/clients/reasoning-controls.ts +49 -0
- package/src/codex/account-store.ts +17 -3
- package/src/codex/app-server-restart-service.ts +6 -5
- package/src/codex/auth-api/account-identity.ts +14 -0
- package/src/codex/auth-api/account-list.ts +29 -2
- package/src/codex/auth-api/http.ts +13 -0
- package/src/codex/auth-api/main-account-probe.ts +2 -2
- package/src/codex/auth-api/pool-mode-gate.ts +16 -3
- package/src/codex/auth-api/pool-quota-probe.ts +15 -0
- package/src/codex/auth-context.ts +15 -12
- package/src/codex/catalog/build-entries.ts +22 -0
- package/src/codex/catalog/configured-tiers.ts +70 -0
- package/src/codex/catalog/effort.ts +52 -11
- package/src/codex/catalog/gather-capture.ts +5 -2
- package/src/codex/catalog/heal-observation.ts +155 -13
- package/src/codex/catalog/metadata.ts +6 -0
- package/src/codex/catalog/model-hints.ts +60 -11
- package/src/codex/catalog/model-visibility.ts +3 -2
- package/src/codex/catalog/native-models.ts +18 -3
- package/src/codex/catalog/parsing.ts +10 -8
- package/src/codex/catalog/pinned-models.ts +2 -1
- package/src/codex/catalog/provider-models.ts +18 -13
- package/src/codex/catalog/retained-sync.ts +2 -1
- package/src/codex/catalog/routed-gather.ts +19 -20
- package/src/codex/catalog/write-audit.ts +3 -2
- package/src/codex/catalog-self-heal.ts +43 -23
- package/src/codex/chatgpt-refresh-failure.ts +6 -2
- package/src/codex/cli-install-provenance.ts +418 -0
- package/src/codex/cli-installation-targets.ts +5 -1
- package/src/codex/cli-update-plan.ts +43 -16
- package/src/codex/collision-identity.ts +30 -5
- package/src/codex/convergence.ts +4 -3
- package/src/codex/data/roster-pinned-models.json +177 -1
- package/src/codex/desired-state.ts +6 -1
- package/src/codex/desktop-app/picker-freshness.ts +10 -8
- package/src/codex/desktop-compatibility/installed-build.ts +88 -12
- package/src/codex/desktop-compatibility/runtime.ts +29 -5
- package/src/codex/desktop-compatibility/usage-activation.ts +2 -1
- package/src/codex/desktop-compatibility/usage-controller.ts +9 -1
- package/src/codex/desktop-compatibility/windows-certificate-trust.ts +46 -12
- package/src/codex/inject/config-toml.ts +0 -18
- package/src/codex/inject/plan.ts +18 -3
- package/src/codex/inject/remove.ts +6 -2
- package/src/codex/inject.ts +1 -1
- package/src/codex/journal.ts +61 -1
- package/src/codex/model-entitlements.ts +1 -1
- package/src/codex/native-main-owner.ts +27 -1
- package/src/codex/native-profile-store.ts +2 -1
- package/src/codex/pool-credit-policy.ts +35 -1
- package/src/codex/pool-refresh-backoff.ts +3 -1
- package/src/codex/quota-types.ts +3 -0
- package/src/codex/quota.ts +24 -4
- package/src/codex/role-auto-assign.ts +6 -2
- package/src/codex/subagent-defaults.ts +49 -4
- package/src/codex/user-identity.ts +35 -6
- package/src/codex/windows-current-sid.ts +162 -0
- package/src/combos/failover.ts +17 -2
- package/src/combos/jev-decision-contract.ts +22 -1
- package/src/combos/jev-quota-activation.ts +5 -1
- package/src/combos/jev-quota-route.ts +1 -1
- package/src/combos/jev-quota.ts +9 -1
- package/src/combos/jev-service-exchange.ts +3 -1
- package/src/combos/jev-session-pin-config.ts +51 -0
- package/src/combos/jev.ts +101 -9
- package/src/combos/resolve.ts +45 -1
- package/src/combos/types.ts +43 -0
- package/src/config/load-degrade.ts +5 -0
- package/src/config/paths.ts +19 -3
- package/src/config/pending-teardown.ts +22 -1
- package/src/config/provider-validation.ts +22 -4
- package/src/config/removed-opencode-free.ts +11 -0
- package/src/config/schema/leaf-validators.ts +6 -0
- package/src/generated/compatibility-version.json +467 -311
- package/src/generated/model-metadata.ts +5 -5
- package/src/images/loop.ts +16 -2
- package/src/integrations/catalog-refresh.ts +1 -1
- package/src/integrations/hermes-profiles.ts +251 -0
- package/src/integrations/merge.ts +8 -0
- package/src/integrations/mutation-plan.ts +19 -4
- package/src/integrations/registry.ts +5 -0
- package/src/integrations/state.ts +36 -1
- package/src/integrations/writer.ts +18 -4
- package/src/lib/bun-path-runtime.mjs +2 -1
- package/src/lib/decision-quota-sink.ts +10 -0
- package/src/lib/errors.ts +62 -0
- package/src/lib/eventstream-decoder.ts +81 -37
- package/src/lib/opaque-proxy-tunnel.ts +32 -8
- package/src/lib/pinned-http.ts +35 -2
- package/src/lib/process-control.ts +13 -1
- package/src/lib/socks5-fetch.ts +59 -64
- package/src/lib/socks5-upload-waiter.ts +50 -0
- package/src/lib/sse-decoder.ts +7 -2
- package/src/lib/state-store-sweeper.ts +40 -14
- package/src/lib/translator-budget.ts +4 -4
- package/src/lib/upstream-retry.ts +4 -1
- package/src/lib/windows-native-principal-worker.ts +14 -0
- package/src/lib/windows-native-principal.ts +188 -0
- package/src/lib/windows-secret-acl.ts +39 -3
- package/src/lib/windows-user-principal.ts +62 -18
- package/src/link/diagnostics.ts +193 -0
- package/src/link/relay-auth.ts +6 -0
- package/src/link/ssh-config.ts +35 -3
- package/src/link/status-projection.ts +39 -0
- package/src/link/supervisor.ts +45 -12
- package/src/link/tunnel-history.ts +109 -0
- package/src/link/tunnel-state.ts +80 -17
- package/src/messaging/remote-files.ts +24 -1
- package/src/oauth/generic-account-failover.ts +91 -7
- package/src/oauth/index.ts +15 -0
- package/src/oauth/model-discovery-auth.ts +5 -0
- package/src/oauth/store.ts +4 -1
- package/src/oauth/token-guardian.ts +7 -0
- package/src/oauth/types.ts +9 -0
- package/src/oauth/workbuddy.ts +139 -0
- package/src/providers/account-quota-disk.ts +12 -4
- package/src/providers/antigravity-quota-identity.ts +37 -0
- package/src/providers/base-url-choices.ts +8 -5
- package/src/providers/codebuddy-models.ts +6 -0
- package/src/providers/codex-capacity.ts +3 -1
- package/src/providers/derive.ts +51 -3
- package/src/providers/kiro-models.ts +3 -0
- package/src/providers/mimo-thinking.ts +12 -0
- package/src/providers/model-discovery.ts +2 -0
- package/src/providers/model-rename-fields.ts +2 -0
- package/src/providers/model-rename-migration.ts +10 -0
- package/src/providers/openai-sidecar-credit.ts +2 -2
- package/src/providers/quota/account-cache.ts +3 -2
- package/src/providers/quota/antigravity.ts +25 -14
- package/src/providers/quota/report-cache.ts +13 -4
- package/src/providers/quota/vendor-probes-key.ts +60 -0
- package/src/providers/quota/workbuddy.ts +83 -0
- package/src/providers/quota-decision-antigravity.ts +64 -0
- package/src/providers/quota-decision-publication.ts +11 -0
- package/src/providers/quota-decision-snapshot.ts +21 -4
- package/src/providers/quota-types.ts +2 -0
- package/src/providers/quota.ts +3 -1
- package/src/providers/reasoning-capabilities.ts +76 -0
- package/src/providers/registry/entries-core.ts +23 -12
- package/src/providers/registry/entries-extended.ts +83 -27
- package/src/providers/registry/model-ids.ts +5 -0
- package/src/providers/registry/model-seeds.ts +120 -56
- package/src/providers/registry/types.ts +29 -2
- package/src/providers/resolved-model-policy.ts +30 -10
- package/src/providers/routed-config.ts +24 -1
- package/src/providers/stale-model-roster-migration.ts +123 -18
- package/src/providers/workbuddy-credit-balance.ts +81 -0
- package/src/providers/workbuddy-models.ts +37 -0
- package/src/providers/workbuddy.ts +60 -0
- package/src/remote-control/workspace-pi-runtime.ts +11 -6
- package/src/responses/compaction-summary.ts +45 -0
- package/src/responses/muse-tool-name-alias.ts +1 -2
- package/src/responses/parser.ts +3 -2
- package/src/responses/reasoning-replay-cache.ts +18 -14
- package/src/responses/schema.ts +1 -0
- package/src/responses/thought-signature-replay.ts +10 -2
- package/src/router.ts +2 -0
- package/src/routing/analytics.ts +2 -3
- package/src/routing/capability.ts +8 -2
- package/src/routing/fallback-policy.ts +3 -3
- package/src/routing/history/ingest.ts +28 -3
- package/src/server/auth-cors.ts +4 -2
- package/src/server/chat-completions.ts +21 -1
- package/src/server/chat-native-eligibility.ts +7 -0
- package/src/server/chat-native-reasoning.ts +24 -7
- package/src/server/chat-native.ts +13 -2
- package/src/server/claude-messages.ts +3 -0
- package/src/server/direct-local-http.ts +5 -2
- package/src/server/effort-policy.ts +5 -1
- package/src/server/index/link-relay-sessions.ts +9 -5
- package/src/server/index/live-sideband.ts +18 -15
- package/src/server/index/optional-listeners.ts +4 -0
- package/src/server/index/serve-options.ts +5 -4
- package/src/server/local-management-read-client.ts +3 -1
- package/src/server/management/agent-settings-routes.ts +27 -15
- package/src/server/management/combo-routes.ts +14 -4
- package/src/server/management/config-routes.ts +2 -2
- package/src/server/management/decision-discovery.ts +12 -2
- package/src/server/management/hermes-profile-routes.ts +156 -0
- package/src/server/management/integration-routes.ts +85 -24
- package/src/server/management/link-routes.ts +5 -2
- package/src/server/management/model-routes.ts +2 -2
- package/src/server/management/model-row-export-metadata.ts +25 -6
- package/src/server/management/model-rows.ts +15 -20
- package/src/server/management/native-integration-routes.ts +11 -8
- package/src/server/management/provider-routes.ts +1 -1
- package/src/server/management/route-registry.ts +4 -0
- package/src/server/management-api.ts +5 -0
- package/src/server/models-capabilities.ts +21 -3
- package/src/server/port-reclaim.ts +51 -9
- package/src/server/request-log-conversation.ts +49 -0
- package/src/server/request-log.ts +2 -0
- package/src/server/responses/adapter-delivery.ts +11 -1
- package/src/server/responses/adapter-dispatch.ts +2 -2
- package/src/server/responses/anthropic-thinking-recovery.ts +1 -0
- package/src/server/responses/codex-ws-exchange.ts +39 -9
- package/src/server/responses/codex-ws-session.ts +38 -4
- package/src/server/responses/codex-ws-wire.ts +6 -1
- package/src/server/responses/combo-required-tool-contract.ts +103 -0
- package/src/server/responses/combo-stream-preflight.ts +8 -1
- package/src/server/responses/compact.ts +14 -5
- package/src/server/responses/context-overflow.ts +8 -1
- package/src/server/responses/core-combo-failure.ts +10 -0
- package/src/server/responses/core-combo.ts +74 -44
- package/src/server/responses/core-lifetime.ts +5 -2
- package/src/server/responses/core-normalize.ts +17 -4
- package/src/server/responses/core-opaque-recovery.ts +1 -0
- package/src/server/responses/core-options.ts +7 -0
- package/src/server/responses/core-replay.ts +2 -1
- package/src/server/responses/jev-combo-choice.ts +39 -0
- package/src/server/responses/jev-session-pin.ts +203 -0
- package/src/server/responses/main-hard-lock-routing.ts +60 -44
- package/src/server/responses/passthrough-delivery.ts +44 -2
- package/src/server/responses/policy-fallback.ts +6 -1
- package/src/server/responses/request-compression.ts +12 -7
- package/src/server/responses/request-prepare.ts +32 -7
- package/src/server/responses/request-sidecar-auth.ts +2 -0
- package/src/server/responses/request-transport.ts +25 -6
- package/src/server/responses/response-effects.ts +22 -10
- package/src/server/responses/run-turn-execution.ts +2 -4
- package/src/server/responses/sidecar-execution.ts +13 -7
- package/src/server/responses-phase-inference.ts +267 -0
- package/src/server/sse-payload-rewrite.ts +14 -1
- package/src/server/stop-teardown.ts +36 -1
- package/src/server/ws-bridge.ts +1 -1
- package/src/service/definition.ts +20 -8
- package/src/service/desktop-supervision.d.mts +7 -4
- package/src/service/desktop-supervision.mjs +90 -13
- package/src/service/ownership-mutation-lease.mjs +21 -7
- package/src/types/config.ts +14 -2
- package/src/types/provider.ts +29 -7
- package/src/types/request.ts +11 -0
- package/src/types/wire.ts +1 -0
- package/src/types.ts +1 -0
- package/src/update/bind-probe.ts +29 -0
- package/src/update/codex-cli-update-launch-policy.d.mts +9 -0
- package/src/update/codex-cli-update-launch-policy.mjs +30 -0
- package/src/update/job.ts +10 -29
- package/src/update/npm-install-job.ps1 +173 -0
- package/src/update/npm-install.mjs +70 -0
- package/src/update/stop-contract.d.mts +1 -0
- package/src/update/stop-contract.mjs +14 -0
- package/src/update/stop-decision.d.mts +1 -1
- package/src/update/stop-decision.mjs +13 -3
- package/src/update/teardown-handover.ts +166 -0
- package/src/update/transactional-install.d.mts +14 -3
- package/src/update/transactional-install.mjs +33 -7
- package/src/usage/expected-prices.ts +64 -31
- package/src/usage/jev-stats.ts +54 -14
- package/src/usage/timeline.ts +19 -9
- package/src/vision/eligibility.ts +15 -5
- package/src/vision/plan.ts +2 -2
- package/src/web-search/loop.ts +16 -2
- package/gui/dist/assets/App-nZ34cR5G.js +0 -58
- package/gui/dist/assets/index-DGXS51sp.js +0 -94
- package/gui/dist/assets/index-DPeB9HpV.css +0 -1
- package/gui/dist/assets/quota-summary-DO1Sx5TM.js +0 -1
package/src/cli/index.ts
CHANGED
|
@@ -42,7 +42,8 @@ import {
|
|
|
42
42
|
type RetainedCodexProviderTable,
|
|
43
43
|
} from "../codex/inject/restore";
|
|
44
44
|
import { stripGrokConfig } from "../grok/inject";
|
|
45
|
-
import { STOP_HISTORY_DEFERRED_EXIT_CODE, STOP_HISTORY_INCOMPLETE_EXIT_CODE } from "../update/stop-contract.mjs";
|
|
45
|
+
import { STOP_HISTORY_DEFERRED_EXIT_CODE, STOP_HISTORY_INCOMPLETE_EXIT_CODE, STOP_TEARDOWN_HANDED_OVER_EXIT_CODE } from "../update/stop-contract.mjs";
|
|
46
|
+
import { announceStopHandover, completeUpdateTeardownHandover, forgetUpdateTeardownHandover, stopHandsTeardownOver, updateTeardownHandoverRequested } from "../update/teardown-handover";
|
|
46
47
|
import {
|
|
47
48
|
describeHistoryJobFailure,
|
|
48
49
|
resolveCodexHistoryJobTarget,
|
|
@@ -77,7 +78,7 @@ import {
|
|
|
77
78
|
pendingTeardownsAreExactly,
|
|
78
79
|
quarantinePendingTeardown,
|
|
79
80
|
} from "../config/pending-teardown";
|
|
80
|
-
import { collectStatus,
|
|
81
|
+
import { collectStatus, detectMissingCodexCatalogPath, hubStatusLines, missingCodexCatalogLines, remoteHubBannerLine, remoteHubStatusLines, runtimeSupervisorLine, statusDeadProxyLines, statusProxyUp, statusUnusedProxyLines } from "./status";
|
|
81
82
|
import { endpointsToProve, everyEndpointProvenDownAsync, sharedTeardownAuthorized, type UninstallObservation } from "./uninstall-plan";
|
|
82
83
|
import { takeFlag } from "./runtime-api";
|
|
83
84
|
import { parseStartOptions, StartArgsError } from "./start-args";
|
|
@@ -127,6 +128,7 @@ import { inspectGuardedManagerTarget, observeGuardedManagerStopped } from "../se
|
|
|
127
128
|
import { summarizeStopRun, type StopOutcome, type StopRunRecord } from "./stop-report";
|
|
128
129
|
import { runCli } from "./root";
|
|
129
130
|
import { isProcessAlive, ProxyOwnershipRefusedError, refusalNextStep, stopProxy } from "../lib/process-control";
|
|
131
|
+
import { directLocalHttpFetch } from "../server/direct-local-http";
|
|
130
132
|
import { startupDataPlaneToken } from "../lib/service-secrets";
|
|
131
133
|
import { assertNotAdminToken, diagnoseService, isServiceOwnershipError, proxyStillLiveAfterStop, serviceCommand, serviceEnvironmentOwnedHere, serviceStartableFromTray, serviceStatePaths, serviceStatusSummary, stopServiceIfInstalledDetailed, uninstallServiceIfInstalled, uninstallServiceDetailed } from "../service";
|
|
132
134
|
import { acquireOwnershipMutationLease } from "../service/ownership-mutation-lease.mjs";
|
|
@@ -142,7 +144,7 @@ import {
|
|
|
142
144
|
StartOwnershipRollbackUncertainError,
|
|
143
145
|
} from "./start-ownership-publication";
|
|
144
146
|
import { syncModelsToCodex } from "../codex/sync";
|
|
145
|
-
import { localClientSkipReason, shouldSyncGrokOnStart, syncCodexOnStartIfEnabled } from "../codex/desired-state";
|
|
147
|
+
import { localClientSkipReason, shouldSyncCodexOnStart, shouldSyncGrokOnStart, syncCodexOnStartIfEnabled } from "../codex/desired-state";
|
|
146
148
|
import { honorSiblingMarker, markSiblingStart, siblingOfLivePort, siblingRuntimeField, siblingStopFoundOwner, withoutSiblingMarker } from "../codex/sibling-start";
|
|
147
149
|
import { consumeSiblingHandoff } from "../codex/sibling-handoff";
|
|
148
150
|
import {
|
|
@@ -162,7 +164,7 @@ import { removeOwnedConfigAfterDesktopCleanup } from "./uninstall-client-state";
|
|
|
162
164
|
import { withProcessRuntimeProvenance } from "../lib/bun-runtime";
|
|
163
165
|
import { startArgv } from "../lib/self-launch-argv";
|
|
164
166
|
import { initializeNodeLauncherContext } from "./launcher-context";
|
|
165
|
-
import { restoreSharedClientStateAfterStop } from "./stop-restore";
|
|
167
|
+
import { assertConnectedClientStopSupported, connectedClientStopSkipLine, preflightConnectedClientStop, preserveConnectedClientRoutingOnExit, restoreSharedClientStateAfterStop } from "./stop-restore";
|
|
166
168
|
import { startClientRuntimeUnderOwnershipLease } from "./client-start-fence";
|
|
167
169
|
import { recoverStartStateUnderOwnershipLease } from "./start-owner-fence";
|
|
168
170
|
import { handledSignalExitCode } from "../lib/handled-signal-exit";
|
|
@@ -383,6 +385,7 @@ async function findProxyOwnerBeforeJournalRecovery(
|
|
|
383
385
|
}
|
|
384
386
|
|
|
385
387
|
async function handleStart(options: { block?: boolean } = {}) {
|
|
388
|
+
forgetUpdateTeardownHandover(); // #7423: a recovery start must not pass the marker to its update workers
|
|
386
389
|
updateRestartChild?.check();
|
|
387
390
|
// A supervised service child defers to a foreign recorded owner before doing
|
|
388
391
|
// anything else. 'ocx service start' refuses this activation path already, but
|
|
@@ -654,7 +657,7 @@ async function handleStart(options: { block?: boolean } = {}) {
|
|
|
654
657
|
try { healthSentinel?.stop(); } catch { /* best-effort */ }
|
|
655
658
|
// Dashboard drain-and-restart (#563) must not tear down injection: the replacement
|
|
656
659
|
// process expects Codex/Grok/env fences to still be in place. A sibling owns none of them.
|
|
657
|
-
const teardown = decideStartExitTeardown({ sibling: siblingStart, recycling: isRecyclingForExit(), ocxService: process.env.OCX_SERVICE });
|
|
660
|
+
const teardown = preserveConnectedClientRoutingOnExit(decideStartExitTeardown({ sibling: siblingStart, recycling: isRecyclingForExit(), ocxService: process.env.OCX_SERVICE }));
|
|
658
661
|
if (teardown.revertSystemEnv) {
|
|
659
662
|
try { revertSystemEnv(); } catch { /* best-effort */ }
|
|
660
663
|
}
|
|
@@ -751,6 +754,8 @@ async function handleStart(options: { block?: boolean } = {}) {
|
|
|
751
754
|
},
|
|
752
755
|
);
|
|
753
756
|
if (!startupSync.ran) console.log(startupLeftCodexNativeLine(localClientSkipReason(config), server.port ?? port));
|
|
757
|
+
// #7423: routing an update kept in place for this proxy is ours once the startup sync published.
|
|
758
|
+
if (!siblingStart && startupSync.published) completeUpdateTeardownHandover(pid => isProcessAlive(pid) && isLikelyOcxProcess(pid));
|
|
754
759
|
await refreshOwnedRaycastCatalog(config, port);
|
|
755
760
|
if (!cleaned && !shuttingDown) healthSentinel = startServiceHealthSentinel(config); // after startup reconciliation; never mid-boot or mid-drain
|
|
756
761
|
// #1046: one warning per startup, after BOTH writes. The server's cache
|
|
@@ -995,8 +1000,6 @@ async function handleRestartStartWhenStopped(recoveringLiveRestart = false): Pro
|
|
|
995
1000
|
return restartStartOutcome(false, child, error);
|
|
996
1001
|
}
|
|
997
1002
|
}
|
|
998
|
-
|
|
999
|
-
|
|
1000
1003
|
async function handleStop(approval?: StopApproval) {
|
|
1001
1004
|
const lease = acquireOwnershipMutationLease(serviceStatePaths());
|
|
1002
1005
|
try {
|
|
@@ -1088,6 +1091,13 @@ async function handleStopUnlocked(snapshot?: GuardedStopSnapshot) {
|
|
|
1088
1091
|
// the record; a record left behind by a hard-killed sibling still says so.
|
|
1089
1092
|
const siblingOfPort = readRuntimePort()?.siblingOfPort;
|
|
1090
1093
|
const stoppingSibling = siblingOfPort !== undefined;
|
|
1094
|
+
const connectedClientSkip = stoppingSibling ? null : connectedClientStopSkipLine(readClientConnectionState());
|
|
1095
|
+
let connectedClientAlreadyStopped = false;
|
|
1096
|
+
if (connectedClientSkip) {
|
|
1097
|
+
const preflight = await preflightConnectedClientStop(snapshot?.approval);
|
|
1098
|
+
if (preflight === "already-stopped") connectedClientAlreadyStopped = true;
|
|
1099
|
+
else if (preflight) return preflight;
|
|
1100
|
+
}
|
|
1091
1101
|
// Structured twin of the human lines below, for `ocx stop --json`: one document the
|
|
1092
1102
|
// desktop shell can read across the process boundary (D4). Every field is assigned
|
|
1093
1103
|
// where the corresponding boolean already flips — the summarizer never re-decides.
|
|
@@ -1124,10 +1134,14 @@ async function handleStopUnlocked(snapshot?: GuardedStopSnapshot) {
|
|
|
1124
1134
|
const inheritedTeardowns = listPendingTeardowns()
|
|
1125
1135
|
.filter(read => isPendingTeardownAbandoned(read, teardownOwnerStillRunning));
|
|
1126
1136
|
let teardownNonce: string | undefined;
|
|
1137
|
+
// #7423: an update that restarts the proxy asks this stop to leave Codex routing for the replacement.
|
|
1138
|
+
const handoverRequested = updateTeardownHandoverRequested(process.env, () => shouldSyncCodexOnStart(loadConfig())) && !stoppingSibling && !connectedClientSkip;
|
|
1139
|
+
let deferralHonoredByProxy = false;
|
|
1127
1140
|
const claimTeardown = (endpoint: { hostname: string; port: number }, endpointSource: "exact" | "guessed") => {
|
|
1128
1141
|
if (teardownNonce || stoppingSibling) return;
|
|
1142
|
+
if (connectedClientSkip) return;
|
|
1129
1143
|
try {
|
|
1130
|
-
teardownNonce = claimPendingTeardown(endpoint, endpointSource).nonce;
|
|
1144
|
+
teardownNonce = claimPendingTeardown(endpoint, endpointSource, process.pid, handoverRequested ? "update-restart" : undefined).nonce;
|
|
1131
1145
|
} catch (err) {
|
|
1132
1146
|
// Without a receipt the proxy performs its own teardown, which is the pre-#3008
|
|
1133
1147
|
// behaviour: correct for every backend that cannot respawn, and merely early for
|
|
@@ -1135,33 +1149,17 @@ async function handleStopUnlocked(snapshot?: GuardedStopSnapshot) {
|
|
|
1135
1149
|
console.warn(`⚠️ Could not record the deferred-teardown receipt: ${err instanceof Error ? err.message : String(err)}`);
|
|
1136
1150
|
}
|
|
1137
1151
|
};
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
* Deriving them separately meant the receipt could name a different endpoint than the
|
|
1142
|
-
* one actually contacted, and a proxy with no runtime record got no receipt at all —
|
|
1143
|
-
* silently reopening the parent-crash window on the path where the stop is a hard kill
|
|
1144
|
-
* and no child teardown runs at all.
|
|
1145
|
-
*
|
|
1146
|
-
* So the caller supplies the endpoint it discovered after the orphan listener proves
|
|
1147
|
-
* possession of this home's runtime record, even when the pid file is gone.
|
|
1148
|
-
*
|
|
1149
|
-
* When nothing resolves, the graceful request cannot be made at all — `stopProxy` goes
|
|
1150
|
-
* straight to the kill ladder, no child teardown runs, and there is no receipt to leave
|
|
1151
|
-
* behind. A warning does not make that durable, so the receipt is claimed FIRST against
|
|
1152
|
-
* the endpoint this process would restore anyway. It is the configured listen address,
|
|
1153
|
-
* which is the same address every recovery probe would ask about, and an obligation
|
|
1154
|
-
* recorded against it is strictly better than none: at worst the probe cannot confirm
|
|
1155
|
-
* A guessed endpoint is NOT evidence, so the receipt records which kind it holds: a
|
|
1156
|
-
* guessed one fails closed into manual recovery rather than letting a later probe read
|
|
1157
|
-
* "the configured port refuses" as proof that the right proxy is down.
|
|
1158
|
-
*/
|
|
1152
|
+
// Resolve one target for receipt and request. Only a discovered endpoint may direct POST;
|
|
1153
|
+
// a configured guess records an obligation but is never evidence for orphan recovery.
|
|
1154
|
+
// Claim before any kill fallback so a parent crash leaves a durable teardown obligation.
|
|
1159
1155
|
const stopWithDeferral = async (pid: number, discovered?: { hostname: string; port: number } | null): Promise<boolean> => {
|
|
1160
1156
|
// Resolve ONCE. Reading the runtime record twice let the receipt name the configured
|
|
1161
1157
|
// guess while the request went to a runtime endpoint that appeared in between.
|
|
1162
1158
|
const exact = discovered ?? endpointOf(readRuntimePort(pid));
|
|
1159
|
+
if (connectedClientSkip) await assertConnectedClientStopSupported(exact ? { ...exact, pid } : null);
|
|
1163
1160
|
claimTeardown(exact ?? configuredEndpoint(), exact ? "exact" : "guessed");
|
|
1164
1161
|
const graceful = await stopProxy(pid, {
|
|
1162
|
+
fetchFn: connectedClientSkip ? directLocalHttpFetch as typeof fetch : undefined,
|
|
1165
1163
|
deferSharedTeardownNonce: teardownNonce,
|
|
1166
1164
|
// Only an exact endpoint may direct the request; the configured fallback is a guess
|
|
1167
1165
|
// good enough to record an obligation against, not to POST a stop to.
|
|
@@ -1170,12 +1168,15 @@ async function handleStopUnlocked(snapshot?: GuardedStopSnapshot) {
|
|
|
1170
1168
|
// A valid receipt means the proxy deferred shared teardown to this process. If the
|
|
1171
1169
|
// receipt could not be written, the proxy restores it itself and the caller must not
|
|
1172
1170
|
// attempt a second restore after a graceful stop. A hard-kill always leaves restore
|
|
1173
|
-
// to this process.
|
|
1171
|
+
// to this process. #7423: only a confirmed deferral kept the proxy's own exit cleanup off.
|
|
1172
|
+
if (graceful && teardownNonce) deferralHonoredByProxy = true;
|
|
1174
1173
|
return graceful && !teardownNonce;
|
|
1175
1174
|
};
|
|
1176
1175
|
const approvedEndpoint = snapshot
|
|
1177
1176
|
? { hostname: probeHostname(snapshot.approval.hostname || undefined), port: snapshot.approval.port }
|
|
1178
1177
|
: null;
|
|
1178
|
+
// Only an exact runtime endpoint may back a handover; without one the ordinary restore runs.
|
|
1179
|
+
const claimHandoverBeforeManager = () => { const exact = handoverRequested ? endpointOf(readRuntimePort()) : null; if (exact) claimTeardown(exact, "exact"); };
|
|
1179
1180
|
let guardedStep: Awaited<ReturnType<typeof runGuardedManagerStep>> | null = null;
|
|
1180
1181
|
try {
|
|
1181
1182
|
const serviceStop = snapshot
|
|
@@ -1191,7 +1192,8 @@ async function handleStopUnlocked(snapshot?: GuardedStopSnapshot) {
|
|
|
1191
1192
|
})).service
|
|
1192
1193
|
// A sibling never runs under a service manager: an installed one belongs to the live owner,
|
|
1193
1194
|
// and its ownership check would fail this stop and skip the stale-record purge below.
|
|
1194
|
-
:
|
|
1195
|
+
// #7423: a manager stop takes the proxy down itself, so a handover claims its receipt first.
|
|
1196
|
+
: stoppingSibling || connectedClientAlreadyStopped ? "absent" : (claimHandoverBeforeManager(), stopServiceIfInstalledDetailed());
|
|
1195
1197
|
record.service = serviceStop;
|
|
1196
1198
|
stoppedService = serviceStop === "stopped" || serviceStop === "stopped-respawnable";
|
|
1197
1199
|
schedulerCanRespawn = serviceStop === "stopped-respawnable";
|
|
@@ -1430,10 +1432,14 @@ async function handleStopUnlocked(snapshot?: GuardedStopSnapshot) {
|
|
|
1430
1432
|
console.error(" The obligation is preserved; retry once the proxy is confirmed stopped.");
|
|
1431
1433
|
}
|
|
1432
1434
|
}
|
|
1433
|
-
if (nativeRestoreHandledByProxy && !stoppingSibling) record.sharedTeardown = "performed-by-proxy";
|
|
1435
|
+
if (nativeRestoreHandledByProxy && !stoppingSibling && !connectedClientSkip) record.sharedTeardown = "performed-by-proxy";
|
|
1434
1436
|
if (stoppingSibling) console.log(`↩️ Client routing stays on the proxy at port ${siblingOfPort}; this sibling had no shared teardown to run.`);
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
+
if (connectedClientSkip) console.log(connectedClientSkip);
|
|
1438
|
+
const restoreBlocked = ownershipBlocked || inheritedBlocks || nativeRestoreHandledByProxy || stoppingSibling || connectedClientSkip !== null;
|
|
1439
|
+
const handedOver = stopHandsTeardownOver({ requested: handoverRequested, restoreBlocked, nonce: teardownNonce,
|
|
1440
|
+
stopFailed, recoveredCount: recoveredNonces.length, proxy: record.proxy, service: record.service, deferralHonored: deferralHonoredByProxy });
|
|
1441
|
+
if (handedOver) announceStopHandover();
|
|
1442
|
+
else if (!restoreBlocked) {
|
|
1437
1443
|
if (recoveredNonces.length > 0) {
|
|
1438
1444
|
// A previous deferred stop died before restoring, and the probe says its endpoint is
|
|
1439
1445
|
// not answering. That is the whole point of leaving the receipt behind.
|
|
@@ -1511,6 +1517,7 @@ async function handleStopUnlocked(snapshot?: GuardedStopSnapshot) {
|
|
|
1511
1517
|
? STOP_HISTORY_DEFERRED_EXIT_CODE
|
|
1512
1518
|
: 1;
|
|
1513
1519
|
}
|
|
1520
|
+
else if (handedOver) process.exitCode = STOP_TEARDOWN_HANDED_OVER_EXIT_CODE;
|
|
1514
1521
|
const signals = {
|
|
1515
1522
|
failed: stopFailed,
|
|
1516
1523
|
historyOnly: historyOnlyFailure,
|
|
@@ -1735,7 +1742,7 @@ async function handleStatus() {
|
|
|
1735
1742
|
// `(local)` only while connected: on a standalone install every line is local, and tagging
|
|
1736
1743
|
// them all would be noise that trains the reader to skip the tag.
|
|
1737
1744
|
const local = status.json.remoteHub.connected ? " (local)" : "";
|
|
1738
|
-
if (status.json
|
|
1745
|
+
if (statusProxyUp(status.json)) {
|
|
1739
1746
|
console.log(`✅ Proxy: ${status.proxyLabel}${local}`);
|
|
1740
1747
|
} else {
|
|
1741
1748
|
console.log(`❌ Proxy: ${status.proxyLabel}${local}`);
|
|
@@ -1752,14 +1759,10 @@ async function handleStatus() {
|
|
|
1752
1759
|
if (status.json.versionSkew.warning) {
|
|
1753
1760
|
console.log(` ⚠️ ${status.json.versionSkew.warning}`);
|
|
1754
1761
|
}
|
|
1755
|
-
for (const line of
|
|
1756
|
-
proxyUp: Boolean(status.json.proxy.pid || status.json.proxy.health.ok),
|
|
1757
|
-
routingKind: status.json.startup.routingKind,
|
|
1758
|
-
})) {
|
|
1762
|
+
for (const line of statusUnusedProxyLines(status.json)) {
|
|
1759
1763
|
console.log(` ${line}`);
|
|
1760
1764
|
}
|
|
1761
|
-
if (!(status.json
|
|
1762
|
-
console.log(" ↳ Not running — Codex/Claude requests will fail with connection errors.");
|
|
1765
|
+
if (!statusProxyUp(status.json)) {
|
|
1763
1766
|
// The service summary a few lines below already tells a registered-but-not-serving
|
|
1764
1767
|
// user to repair. Printing "install the persistent service" unconditionally
|
|
1765
1768
|
// contradicted it in the same report, and install re-registers: UAC on Windows and a
|
|
@@ -1781,10 +1784,7 @@ async function handleStatus() {
|
|
|
1781
1784
|
: " Restart with 'ocx start', or install the persistent service: 'ocx service install'.");
|
|
1782
1785
|
// Restarting is only half the choice. A user who cannot sign in to Codex at all needs the
|
|
1783
1786
|
// way out that does not require this proxy to come back (#5261).
|
|
1784
|
-
for (const line of
|
|
1785
|
-
proxyUp: false,
|
|
1786
|
-
routingKind: status.json.startup.routingKind,
|
|
1787
|
-
})) {
|
|
1787
|
+
for (const line of statusDeadProxyLines(status.json)) {
|
|
1788
1788
|
console.log(` ${line}`);
|
|
1789
1789
|
}
|
|
1790
1790
|
}
|
|
@@ -27,6 +27,9 @@ export const FILE_INTEGRATION_CLIENTS = [
|
|
|
27
27
|
"kilo",
|
|
28
28
|
"droid",
|
|
29
29
|
"qoder",
|
|
30
|
+
"qoder-cn",
|
|
31
|
+
"workbuddy",
|
|
32
|
+
"workbuddy-ai",
|
|
30
33
|
"gentle-shell",
|
|
31
34
|
] as const;
|
|
32
35
|
|
|
@@ -57,6 +60,7 @@ const MISSING_STORE_DOCUMENT = /^[\x20-\x7e]{1,64}$/;
|
|
|
57
60
|
const PLAN_CHANGE_KEYS = new Set(["kind", "path"]);
|
|
58
61
|
const PLAN_PSEUDO_PATHS = new Set(["$snapshot", "$ownership", "$journal"]);
|
|
59
62
|
const PLAN_SCHEMA_PATHS = new Set([
|
|
63
|
+
"*", // A WorkBuddy legacy document is a top-level model array.
|
|
60
64
|
"provider.opencodex",
|
|
61
65
|
"providers.opencodex",
|
|
62
66
|
"models.providers.opencodex",
|
|
@@ -24,7 +24,11 @@ export type TrustedNodeLaunchContext = {
|
|
|
24
24
|
codexCliPath: string | null;
|
|
25
25
|
path: string | null;
|
|
26
26
|
pathExt: string | null;
|
|
27
|
+
home: string | null;
|
|
28
|
+
nodePath: string | null;
|
|
27
29
|
managerRoots: CodexCliVersionManagerRoots | null;
|
|
30
|
+
transportEnv: Readonly<Record<string, string>>;
|
|
31
|
+
arch: NodeJS.Architecture | null;
|
|
28
32
|
configDir: string;
|
|
29
33
|
}> | null;
|
|
30
34
|
};
|
|
@@ -50,6 +54,27 @@ function parseVersionManagerRoots(value: unknown): CodexCliVersionManagerRoots |
|
|
|
50
54
|
return Object.freeze(Object.fromEntries(entries)) as CodexCliVersionManagerRoots;
|
|
51
55
|
}
|
|
52
56
|
|
|
57
|
+
function parseTransportEnv(value: unknown): Readonly<Record<string, string>> | undefined {
|
|
58
|
+
// Older snapshots convey no transport settings. Never fill them from Bun's ambient env.
|
|
59
|
+
if (value === undefined) return Object.freeze({});
|
|
60
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return undefined;
|
|
61
|
+
const entries = Object.entries(value);
|
|
62
|
+
if (entries.some(([name, setting]) => !CODEX_CLI_TRANSPORT_ENV_KEYS.includes(name.toLowerCase())
|
|
63
|
+
|| typeof setting !== "string" || setting.length > 32 * 1024)) return undefined;
|
|
64
|
+
return Object.freeze(Object.fromEntries(entries));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const NODE_ARCHITECTURES: ReadonlySet<string> = new Set<NodeJS.Architecture>([
|
|
68
|
+
"arm", "arm64", "ia32", "loong64", "mips", "mipsel", "ppc64", "riscv64", "s390x", "x64",
|
|
69
|
+
]);
|
|
70
|
+
|
|
71
|
+
function parseLauncherArch(value: unknown): NodeJS.Architecture | null | undefined {
|
|
72
|
+
// Older snapshots predate the field; absent stays null (Bun's own arch is the
|
|
73
|
+
// pre-existing fallback). Any other non-architecture value is untrusted.
|
|
74
|
+
if (value === undefined || value === null) return null;
|
|
75
|
+
return typeof value === "string" && NODE_ARCHITECTURES.has(value) ? value as NodeJS.Architecture : undefined;
|
|
76
|
+
}
|
|
77
|
+
|
|
53
78
|
/** Consume the internal proof before normal CLI argument parsing. */
|
|
54
79
|
export function initializeNodeLauncherContext(
|
|
55
80
|
argv: string[] = process.argv,
|
|
@@ -70,7 +95,7 @@ export function initializeNodeLauncherContext(
|
|
|
70
95
|
delete env.OCX_PRE_BUN_ANTHROPIC_ENV;
|
|
71
96
|
trustedContext = null;
|
|
72
97
|
|
|
73
|
-
if (proofArgs.length !== 1 || !raw || raw.length >
|
|
98
|
+
if (proofArgs.length !== 1 || !raw || raw.length > NODE_LAUNCH_CONTEXT_MAX_CHARS) return null;
|
|
74
99
|
const proof = proofArgs[0]!;
|
|
75
100
|
if (!isLaunchProof(proof)) return null;
|
|
76
101
|
|
|
@@ -95,6 +120,12 @@ export function initializeNodeLauncherContext(
|
|
|
95
120
|
const managerRoots = inspection && typeof inspection === "object" && !Array.isArray(inspection)
|
|
96
121
|
? parseVersionManagerRoots((inspection as Record<string, unknown>).managerRoots)
|
|
97
122
|
: null;
|
|
123
|
+
const transportEnv = inspection && typeof inspection === "object" && !Array.isArray(inspection)
|
|
124
|
+
? parseTransportEnv((inspection as Record<string, unknown>).transportEnv)
|
|
125
|
+
: undefined;
|
|
126
|
+
const arch = inspection && typeof inspection === "object" && !Array.isArray(inspection)
|
|
127
|
+
? parseLauncherArch((inspection as Record<string, unknown>).arch)
|
|
128
|
+
: undefined;
|
|
98
129
|
const codexCliInspectionEnv = inspection === null || inspection === undefined
|
|
99
130
|
? null
|
|
100
131
|
: inspection && typeof inspection === "object" && !Array.isArray(inspection)
|
|
@@ -102,15 +133,27 @@ export function initializeNodeLauncherContext(
|
|
|
102
133
|
const value = (inspection as Record<string, unknown>)[key];
|
|
103
134
|
return value === null || typeof value === "string";
|
|
104
135
|
})
|
|
136
|
+
// Older launchers predate the lookup-seed slots; absent stays null so
|
|
137
|
+
// the fallback lane simply remains unverifiable rather than untrusted.
|
|
138
|
+
&& ["home", "nodePath"].every(key => {
|
|
139
|
+
const value = (inspection as Record<string, unknown>)[key];
|
|
140
|
+
return value === undefined || value === null || typeof value === "string";
|
|
141
|
+
})
|
|
105
142
|
&& typeof (inspection as Record<string, unknown>).configDir === "string"
|
|
106
143
|
&& (inspection as Record<string, string>).configDir.length > 0
|
|
107
144
|
&& (inspection as Record<string, string>).configDir.length <= 32 * 1024
|
|
108
145
|
&& managerRoots !== undefined
|
|
146
|
+
&& transportEnv !== undefined
|
|
147
|
+
&& arch !== undefined
|
|
109
148
|
? Object.freeze({
|
|
110
149
|
codexCliPath: (inspection as Record<string, string | null>).codexCliPath ?? null,
|
|
111
150
|
path: (inspection as Record<string, string | null>).path ?? null,
|
|
112
151
|
pathExt: (inspection as Record<string, string | null>).pathExt ?? null,
|
|
152
|
+
home: (inspection as Record<string, string | null>).home ?? null,
|
|
153
|
+
nodePath: (inspection as Record<string, string | null>).nodePath ?? null,
|
|
113
154
|
managerRoots,
|
|
155
|
+
transportEnv,
|
|
156
|
+
arch,
|
|
114
157
|
configDir: (inspection as Record<string, string>).configDir,
|
|
115
158
|
})
|
|
116
159
|
: undefined;
|
|
@@ -125,4 +168,8 @@ export function initializeNodeLauncherContext(
|
|
|
125
168
|
export function trustedNodeLauncherContext(): TrustedNodeLaunchContext | null {
|
|
126
169
|
return trustedContext;
|
|
127
170
|
}
|
|
128
|
-
import {
|
|
171
|
+
import {
|
|
172
|
+
CODEX_CLI_TRANSPORT_ENV_KEYS,
|
|
173
|
+
CODEX_CLI_VERSION_MANAGER_ROOT_ENV_SLOTS,
|
|
174
|
+
NODE_LAUNCH_CONTEXT_MAX_CHARS,
|
|
175
|
+
} from "../update/codex-cli-update-launch-policy.mjs";
|
package/src/cli/link.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { clientLinkStatusIdentity } from "../client/link-status";
|
|
2
2
|
import { clientLinkTunnelStatus } from "../client/link-tunnel";
|
|
3
3
|
import { loadConfig } from "../config";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
projectLinkStatus, type ClientLinkIdentity, type LinkStatusConfig, type LinkStatusDto, type LinkTunnelDiagnostics, type LinkWireState,
|
|
6
|
+
} from "../link/status-projection";
|
|
7
|
+
import { TUNNEL_CAUSES } from "../link/tunnel-history";
|
|
5
8
|
import { isEpochMs, type LinkChildParity } from "../link/child-parity";
|
|
6
9
|
import { CODEX_SETTINGS_DIGEST_PATTERN } from "../link/codex-settings";
|
|
7
10
|
import type { LinkLocalPeer, LinkPeerStatus } from "../link/compatibility";
|
|
@@ -40,30 +43,11 @@ export const LINK_USAGE = `Usage:
|
|
|
40
43
|
Forced revoke skips remote cleanup. Run ocx disconnect on the remote client.
|
|
41
44
|
Cleanup finds Windows Children and explains how to move them to Hub mode; it changes nothing.`;
|
|
42
45
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
listener: { state: ListenerState; port: number | null };
|
|
49
|
-
links: Array<LinkChildParity & {
|
|
50
|
-
id: string;
|
|
51
|
-
alias: string;
|
|
52
|
-
direction: LinkDirection;
|
|
53
|
-
state: LinkState;
|
|
54
|
-
since: string;
|
|
55
|
-
reason: string | null;
|
|
56
|
-
tunnelPort: number;
|
|
57
|
-
peer?: LinkPeerStatus;
|
|
58
|
-
}>;
|
|
59
|
-
child: null | {
|
|
60
|
-
alias: string;
|
|
61
|
-
state: LinkState;
|
|
62
|
-
since: string;
|
|
63
|
-
reason: string | null;
|
|
64
|
-
};
|
|
65
|
-
local?: LinkLocalPeer;
|
|
66
|
-
}
|
|
46
|
+
/**
|
|
47
|
+
* What `ocx link status` prints: the runtime's status DTO itself, so a field the server adds (like
|
|
48
|
+
* `peer` or the diagnostics `tunnel`) is part of this type the moment it is part of the wire.
|
|
49
|
+
*/
|
|
50
|
+
export type LinkStatusPayload = LinkStatusDto;
|
|
67
51
|
|
|
68
52
|
export interface LinkIssuePayload {
|
|
69
53
|
linkId: string;
|
|
@@ -165,11 +149,11 @@ function validateStatus(value: unknown): LinkStatusPayload {
|
|
|
165
149
|
throw new Error("invalid link API response: listener port");
|
|
166
150
|
}
|
|
167
151
|
if (!Array.isArray(value.links)) throw new Error("invalid link API response: links");
|
|
168
|
-
const links = value.links.map((candidate, index) => {
|
|
152
|
+
const links = value.links.map((candidate, index): LinkStatusPayload["links"][number] => {
|
|
169
153
|
if (!isRecord(candidate)) throw new Error(`invalid link API response: link ${index}`);
|
|
170
154
|
// The OCX-6 parity fields are optional on the wire (an older runtime omits them) and always
|
|
171
155
|
// present in this output, null when absent.
|
|
172
|
-
assertKeys(candidate, ["id", "alias", "direction", "state", "since", "reason", "tunnelPort"], [...PARITY_KEYS, "peer"], `link ${index}`);
|
|
156
|
+
assertKeys(candidate, ["id", "alias", "direction", "state", "since", "reason", "tunnelPort"], [...PARITY_KEYS, "peer", "tunnel"], `link ${index}`);
|
|
173
157
|
const parity = validateParity(candidate, index);
|
|
174
158
|
if (typeof candidate.id !== "string" || !LINK_ID.test(candidate.id)
|
|
175
159
|
|| !validString(candidate.alias) || (candidate.direction !== "hub-initiated" && candidate.direction !== "client-initiated")
|
|
@@ -180,14 +164,15 @@ function validateStatus(value: unknown): LinkStatusPayload {
|
|
|
180
164
|
return {
|
|
181
165
|
id: candidate.id,
|
|
182
166
|
alias: candidate.alias,
|
|
183
|
-
direction: candidate.direction,
|
|
184
|
-
state: candidate.state,
|
|
167
|
+
direction: candidate.direction as LinkDirection,
|
|
168
|
+
state: candidate.state as LinkWireState,
|
|
185
169
|
since: candidate.since,
|
|
186
170
|
reason: candidate.reason,
|
|
187
171
|
tunnelPort: candidate.tunnelPort,
|
|
188
172
|
...parity,
|
|
189
173
|
...(candidate.peer !== undefined ? { peer: validatePeer(candidate.peer, index) } : {}),
|
|
190
|
-
|
|
174
|
+
...(candidate.tunnel !== undefined ? { tunnel: validateTunnel(candidate.tunnel, index) } : {}),
|
|
175
|
+
};
|
|
191
176
|
});
|
|
192
177
|
let child: LinkStatusPayload["child"] = null;
|
|
193
178
|
if (value.child !== null) {
|
|
@@ -310,8 +295,9 @@ async function runStatus(args: string[], deps: LinkCliDeps): Promise<void> {
|
|
|
310
295
|
}
|
|
311
296
|
throw error;
|
|
312
297
|
}
|
|
313
|
-
// A proxy older than the compatibility report
|
|
314
|
-
|
|
298
|
+
// A proxy older than the compatibility report or the tunnel diagnostics ignores the query and
|
|
299
|
+
// answers without those fields.
|
|
300
|
+
const result = validateStatus(await linkRequest<unknown>("/api/link/status?compatibility=1&diagnostics=1", {}, { ...deps, baseUrl }));
|
|
315
301
|
console.log(JSON.stringify(result));
|
|
316
302
|
}
|
|
317
303
|
|
|
@@ -385,6 +371,33 @@ export async function runLinkCommand(rawArgs: string[], deps: LinkCliDeps = {}):
|
|
|
385
371
|
}
|
|
386
372
|
|
|
387
373
|
const PARITY_KEYS = ["lastApplyAt", "runtimeStartedAt", "appliedCodexSettingsDigest", "reportedAt"] as const;
|
|
374
|
+
const WIRE_STATES = new Set(["connecting", "connected", "reconnecting", "failed", "idle"]);
|
|
375
|
+
const CAUSES = new Set<string>(TUNNEL_CAUSES);
|
|
376
|
+
|
|
377
|
+
function validIso(value: unknown): value is string {
|
|
378
|
+
return typeof value === "string" && value.length <= 64 && Number.isFinite(Date.parse(value));
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
function validateTunnel(value: unknown, index: number): LinkTunnelDiagnostics {
|
|
382
|
+
const fail = (): never => { throw new Error(`invalid link API response: link ${index} tunnel`); };
|
|
383
|
+
if (!isRecord(value)) return fail();
|
|
384
|
+
assertExactKeys(value, ["attempt", "nextRetryAt", "lastTransition", "lastFailure"], `link ${index} tunnel`);
|
|
385
|
+
const { attempt, nextRetryAt, lastTransition, lastFailure } = value;
|
|
386
|
+
if (typeof attempt !== "number" || !Number.isSafeInteger(attempt) || attempt < 0) fail();
|
|
387
|
+
if (nextRetryAt !== null && !validIso(nextRetryAt)) fail();
|
|
388
|
+
if (lastTransition !== null) {
|
|
389
|
+
if (!isRecord(lastTransition)) return fail();
|
|
390
|
+
assertExactKeys(lastTransition, ["from", "to", "at", "cause"], `link ${index} tunnel transition`);
|
|
391
|
+
if (!WIRE_STATES.has(lastTransition.from as string) || !WIRE_STATES.has(lastTransition.to as string)
|
|
392
|
+
|| !validIso(lastTransition.at) || (lastTransition.cause !== null && !CAUSES.has(lastTransition.cause as string))) fail();
|
|
393
|
+
}
|
|
394
|
+
if (lastFailure !== null) {
|
|
395
|
+
if (!isRecord(lastFailure)) return fail();
|
|
396
|
+
assertExactKeys(lastFailure, ["cause", "at"], `link ${index} tunnel failure`);
|
|
397
|
+
if (!CAUSES.has(lastFailure.cause as string) || !validIso(lastFailure.at)) fail();
|
|
398
|
+
}
|
|
399
|
+
return value as unknown as LinkTunnelDiagnostics;
|
|
400
|
+
}
|
|
388
401
|
|
|
389
402
|
function validateParity(candidate: Record<string, unknown>, index: number): LinkChildParity {
|
|
390
403
|
const time = (key: "lastApplyAt" | "runtimeStartedAt" | "reportedAt"): number | null => {
|
package/src/cli/opencode.ts
CHANGED
|
@@ -40,6 +40,7 @@ import type {
|
|
|
40
40
|
OpencodeV2ProviderBlock,
|
|
41
41
|
} from "../clients/config-export";
|
|
42
42
|
import type { EffectiveModelExportMetadata } from "../clients/config-export/contracts";
|
|
43
|
+
import { resolveExportReasoningAxes } from "../clients/config-export/reasoning-metadata";
|
|
43
44
|
import { filterCatalogVisibleModels, visibleNativeSlugs } from "../codex/catalog";
|
|
44
45
|
import { commandInvocation } from "../lib/win-exec";
|
|
45
46
|
import { configuredAdminToken, opencodeCatalogToken } from "../lib/admin-secrets";
|
|
@@ -91,6 +92,11 @@ export interface OpencodeRoutedModel {
|
|
|
91
92
|
displayName?: string;
|
|
92
93
|
/** Declared effort ladder; exported as opencode model variants when present. */
|
|
93
94
|
reasoningEfforts?: readonly string[];
|
|
95
|
+
supportsReasoning?: boolean;
|
|
96
|
+
supportsThinkingToggle?: boolean;
|
|
97
|
+
supportsReasoningEffort?: boolean;
|
|
98
|
+
defaultThinkingEnabled?: boolean;
|
|
99
|
+
defaultReasoningEffort?: string;
|
|
94
100
|
}
|
|
95
101
|
|
|
96
102
|
/** Row shape from authenticated GET /api/models on the running proxy. */
|
|
@@ -120,6 +126,9 @@ export interface OpencodeProxyModelRow {
|
|
|
120
126
|
inputModalities?: string[];
|
|
121
127
|
/** Declared effort ladder from `/api/models`; carried into opencode model variants. */
|
|
122
128
|
reasoningEfforts?: string[];
|
|
129
|
+
supportsThinkingToggle?: boolean;
|
|
130
|
+
supportsReasoningEffort?: boolean;
|
|
131
|
+
defaultThinkingEnabled?: boolean;
|
|
123
132
|
/** Declared default effort from `/api/models`. */
|
|
124
133
|
defaultReasoningEffort?: string;
|
|
125
134
|
/**
|
|
@@ -180,9 +189,14 @@ function opencodeLaunchCatalog(
|
|
|
180
189
|
id: model.id,
|
|
181
190
|
contextWindow: model.contextWindow,
|
|
182
191
|
displayName: model.displayName,
|
|
183
|
-
...(model.reasoningEfforts
|
|
192
|
+
...(model.reasoningEfforts !== undefined
|
|
184
193
|
? { reasoningEfforts: [...model.reasoningEfforts] }
|
|
185
194
|
: {}),
|
|
195
|
+
...(model.supportsReasoning !== undefined ? { supportsReasoning: model.supportsReasoning } : {}),
|
|
196
|
+
...(model.supportsThinkingToggle !== undefined ? { supportsThinkingToggle: model.supportsThinkingToggle } : {}),
|
|
197
|
+
...(model.supportsReasoningEffort !== undefined ? { supportsReasoningEffort: model.supportsReasoningEffort } : {}),
|
|
198
|
+
...(model.defaultThinkingEnabled !== undefined ? { defaultThinkingEnabled: model.defaultThinkingEnabled } : {}),
|
|
199
|
+
...(model.defaultReasoningEffort !== undefined ? { defaultReasoningEffort: model.defaultReasoningEffort } : {}),
|
|
186
200
|
})),
|
|
187
201
|
];
|
|
188
202
|
}
|
|
@@ -372,14 +386,8 @@ export function opencodeCatalogFromProxyRows(
|
|
|
372
386
|
const maxTokens = effective?.maxTokens ?? row.maxOutputTokens;
|
|
373
387
|
const maxInputTokens = effective?.maxInputTokens ?? row.maxInputTokens;
|
|
374
388
|
const inputModalities = effective?.inputModalities ?? row.inputModalities;
|
|
375
|
-
const
|
|
376
|
-
|
|
377
|
-
// NO declared default, and falling back to the row would reintroduce the picker's
|
|
378
|
-
// synthetic medium/low value. Rows without one (older hubs, hand-built rows) keep the
|
|
379
|
-
// row's own value.
|
|
380
|
-
const defaultReasoningEffort = effective !== undefined
|
|
381
|
-
? effective.defaultReasoningEffort
|
|
382
|
-
: row.defaultReasoningEffort;
|
|
389
|
+
const { supportsThinkingToggle, supportsReasoningEffort, defaultThinkingEnabled,
|
|
390
|
+
reasoningEfforts, defaultReasoningEffort } = resolveExportReasoningAxes(effective, row);
|
|
383
391
|
const supportsTools = effective?.supportsTools ?? row.supportsTools;
|
|
384
392
|
const supportsReasoning = effective?.supportsReasoning ?? row.supportsReasoning;
|
|
385
393
|
const supportsReasoningSummaries = effective?.supportsReasoningSummaries ?? row.supportsReasoningSummaries;
|
|
@@ -398,6 +406,9 @@ export function opencodeCatalogFromProxyRows(
|
|
|
398
406
|
...(typeof row.fastRowAvailable === "boolean" ? { fastRowAvailable: row.fastRowAvailable } : {}),
|
|
399
407
|
// `[]` is a declaration, not an absence: an explicit no-rungs ladder stays empty here.
|
|
400
408
|
...(Array.isArray(reasoningEfforts) ? { reasoningEfforts: [...reasoningEfforts] } : {}),
|
|
409
|
+
...(typeof supportsThinkingToggle === "boolean" ? { supportsThinkingToggle } : {}),
|
|
410
|
+
...(typeof supportsReasoningEffort === "boolean" ? { supportsReasoningEffort } : {}),
|
|
411
|
+
...(typeof defaultThinkingEnabled === "boolean" ? { defaultThinkingEnabled } : {}),
|
|
401
412
|
...(typeof defaultReasoningEffort === "string" && defaultReasoningEffort.length > 0
|
|
402
413
|
? { defaultReasoningEffort }
|
|
403
414
|
: {}),
|
package/src/cli/provider.ts
CHANGED
|
@@ -191,7 +191,7 @@ function handleList(args: string[], active: boolean = localProvidersActive()): v
|
|
|
191
191
|
console.log(` ${name}${isDefault}${source} adapter=${prov.adapter}${model}`);
|
|
192
192
|
}
|
|
193
193
|
|
|
194
|
-
const available = PROVIDER_REGISTRY.filter(e => !configured.includes(e.id));
|
|
194
|
+
const available = PROVIDER_REGISTRY.filter(e => !e.deprecated && !configured.includes(e.id));
|
|
195
195
|
if (available.length > 0) {
|
|
196
196
|
console.log(`\nAvailable from registry (${available.length}):\n`);
|
|
197
197
|
for (const entry of available) {
|
|
@@ -265,6 +265,7 @@ async function handleAdd(args: string[], deps: ProviderCommandDeps): Promise<voi
|
|
|
265
265
|
const registryEntry = getProviderRegistryEntry(name);
|
|
266
266
|
|
|
267
267
|
if (registryEntry) {
|
|
268
|
+
if (registryEntry.deprecated) console.warn(`Warning: provider "${name}" is deprecated: ${registryEntry.deprecated}`);
|
|
268
269
|
provConfig = providerConfigSeed(registryEntry);
|
|
269
270
|
if (apiKey) {
|
|
270
271
|
const candidateError = providerCredentialInputError({ apiKey });
|
package/src/cli/registry.ts
CHANGED
|
@@ -50,7 +50,7 @@ export const CLI_COMMANDS: CliCommandEntry[] = [
|
|
|
50
50
|
{
|
|
51
51
|
name: "stop",
|
|
52
52
|
usage: "ocx stop [--json]",
|
|
53
|
-
summary: "Stop the proxy
|
|
53
|
+
summary: "Stop the proxy; preserve connected-client integrations, restore native Codex config for standalone owners.",
|
|
54
54
|
details: [
|
|
55
55
|
"--json keeps the stop path unchanged and prints one structured summary document on stdout; human output moves to stderr.",
|
|
56
56
|
"Exit codes are identical with and without --json: 0, 1, 79 (history cleanup incomplete), 80 (teardown deferred).",
|
|
@@ -181,13 +181,15 @@ export const CLI_COMMANDS: CliCommandEntry[] = [
|
|
|
181
181
|
},
|
|
182
182
|
{
|
|
183
183
|
name: "sync",
|
|
184
|
-
usage: "ocx sync [--restart-codex] [--restart-app-server-only]",
|
|
184
|
+
usage: "ocx sync [--expect-link <linkId> | --expect-hub-key <apiKeyId>] [--restart-codex] [--restart-app-server-only]",
|
|
185
185
|
summary: "Fetch provider models and inject them into Codex config.",
|
|
186
186
|
details: [
|
|
187
187
|
"After writing the catalog, warns if long-lived Codex app-server processes are still running.",
|
|
188
188
|
"--restart-codex restarts the app-servers AND fully quits and relaunches the Codex desktop app on macOS, Linux and Windows, after catalog/cache writes or a committed configuration change. It ends live conversations.",
|
|
189
189
|
"--restart-app-server-only keeps the narrow behaviour: SIGTERM to matching app-server / code-mode-host processes, desktop app left running. It wins over --restart-codex when both are given.",
|
|
190
190
|
"--restart-desktop-app is a deprecated alias of --restart-codex and prints a notice.",
|
|
191
|
+
"--expect-link <linkId> syncs only when this machine is a connected Remote Link Child of that link (ocx connect status --json reports link.linkId); --expect-hub-key <apiKeyId> does the same for a hub client's key. The check runs under the lock that chooses the sync path.",
|
|
192
|
+
"Any other state (disconnected, another link or key, the other client kind, a pending key rotation, connect or disconnect) changes nothing, never syncs local providers, exits 5, and prints {\"phase\":\"child_link_mismatch\"|\"hub_client_mismatch\",\"reason\":...} as the last stderr line. A malformed or repeated flag exits 2.",
|
|
191
193
|
],
|
|
192
194
|
},
|
|
193
195
|
{
|
|
@@ -516,8 +518,8 @@ export const CLI_COMMANDS: CliCommandEntry[] = [
|
|
|
516
518
|
},
|
|
517
519
|
{
|
|
518
520
|
name: "export",
|
|
519
|
-
usage: "ocx export --client <qoder|opencode|pi|omp|hermes|openclaw|kimi|gajae|dsh|mcode|zcode|commandcode|prime|aside|raycast|omo|cline|kilo|droid|gentle-shell> [--json] [--out <path>] [--force]",
|
|
520
|
-
summary: "Print a client config (OpenCode, Pi, OMP, Hermes, OpenClaw, Kimi Code, gjc, DeepSeek Harness, MiniMax Code, ZCode, Command Code, Prime Agent, Aside, Raycast, omo, Cline, Kilo, Factory Droid, Qoder, Gentle Shell) wired to the running proxy.",
|
|
521
|
+
usage: "ocx export --client <qoder|qoder-cn|workbuddy|workbuddy-ai|opencode|pi|omp|hermes|openclaw|kimi|gajae|dsh|mcode|zcode|commandcode|prime|aside|raycast|omo|cline|kilo|droid|gentle-shell> [--json] [--out <path>] [--force]",
|
|
522
|
+
summary: "Print a client config (OpenCode, Pi, OMP, Hermes, OpenClaw, Kimi Code, gjc, DeepSeek Harness, MiniMax Code, ZCode, Command Code, Prime Agent, Aside, Raycast, omo, Cline, Kilo, Factory Droid, Qoder, Qoder CN, WorkBuddy, WorkBuddy AI, Gentle Shell) wired to the running proxy.",
|
|
521
523
|
details: [
|
|
522
524
|
"--json prints the generated document as JSON on stdout; use --out for the client's native format.",
|
|
523
525
|
"--out <path> writes the native config there and refuses to replace an existing file without --force.",
|
package/src/cli/root.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { printFullUsage, printSubcommandUsage, printUsage, printVersion } from "
|
|
|
12
12
|
import { parseReadyArgs, type ReadyArgs } from "./ready";
|
|
13
13
|
import { parseResolveArgs, type ResolveArgs } from "./resolve";
|
|
14
14
|
import { parseStopApproval } from "./stop-approval";
|
|
15
|
+
import { parseSyncExpectation, SYNC_EXPECTATION_USAGE_EXIT } from "./sync-expectation";
|
|
15
16
|
import { maybeAutoRestoreCodexShim } from "./codex-shim-autorestore";
|
|
16
17
|
import { findCommand } from "./registry";
|
|
17
18
|
import { printUnknownCommand } from "./help-recovery";
|
|
@@ -142,6 +143,14 @@ export async function runCli(argv: string[]): Promise<CliHead> {
|
|
|
142
143
|
console.error(uninstallError);
|
|
143
144
|
process.exit(2);
|
|
144
145
|
}
|
|
146
|
+
// #7694: a malformed pinned sync is refused before any preflight reads or repairs anything.
|
|
147
|
+
if (head.command === "sync") {
|
|
148
|
+
const pinned = parseSyncExpectation(head.args.slice(1));
|
|
149
|
+
if (!pinned.ok) {
|
|
150
|
+
console.error(pinned.message);
|
|
151
|
+
process.exit(SYNC_EXPECTATION_USAGE_EXIT);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
145
154
|
await maybeNoticeVersionSkew(head.command, head.args);
|
|
146
155
|
maybeAutoRestoreCodexShim(head.command, head.args);
|
|
147
156
|
return head;
|