@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
|
@@ -221,11 +221,19 @@ function inspectionDeps(commandDeps: CodexCliUpdateCommandDeps): CodexCliInstall
|
|
|
221
221
|
return {
|
|
222
222
|
env: {
|
|
223
223
|
...trusted.managerRoots,
|
|
224
|
+
...trusted.transportEnv,
|
|
224
225
|
CODEX_CLI_PATH: trusted.codexCliPath ?? undefined,
|
|
225
226
|
PATH: trusted.path ?? undefined,
|
|
226
227
|
PATHEXT: trusted.pathExt ?? undefined,
|
|
228
|
+
// The lookup seeds the inspection models against the launch-time
|
|
229
|
+
// capture; ambient values are never consulted.
|
|
230
|
+
HOME: trusted.home ?? undefined,
|
|
231
|
+
NODE_PATH: trusted.nodePath ?? undefined,
|
|
227
232
|
},
|
|
228
233
|
configDir: trusted.configDir,
|
|
234
|
+
// Content observation picks the platform backing by the Node launcher's
|
|
235
|
+
// arch, which can differ from this Bun process's under Rosetta.
|
|
236
|
+
arch: trusted.arch ?? undefined,
|
|
229
237
|
// The snapshot is proof-bound to the launcher, but the report may only attest
|
|
230
238
|
// the environment candidate when the resolver picks the same canonical path —
|
|
231
239
|
// managed requires both.
|
|
@@ -34,6 +34,10 @@ export function skipsCodexShimAutoRestore(command: string | undefined, args: str
|
|
|
34
34
|
// The desktop's approval-bound stop must validate its snapshot before any unrelated
|
|
35
35
|
// CLI repair changes the installation it was approved against.
|
|
36
36
|
if (command === "stop" && args.some(arg => arg.startsWith("--expect-"))) return true;
|
|
37
|
+
// A pinned sync (#7694) must change nothing when its expected Home or hub key does not hold,
|
|
38
|
+
// so the root preflight may not repair the shim first; the sync runner repairs it only after
|
|
39
|
+
// the locked identity check passed (runCodexShimAutoRestore in src/cli/dispatch.ts).
|
|
40
|
+
if (command === "sync" && args.some(arg => /^--expect-(link|hub-key)(=|$)/.test(arg))) return true;
|
|
37
41
|
// The entire updater-inspection namespace is zero-effect, including malformed
|
|
38
42
|
// or future actions. A later `apply` implementation must own its preflight.
|
|
39
43
|
if (command === "system" && args[1] === "codex-cli-update") return true;
|
|
@@ -47,6 +51,11 @@ export function maybeAutoRestoreCodexShim(
|
|
|
47
51
|
deps: CodexShimAutoRestoreCliDeps = DEFAULT_DEPS,
|
|
48
52
|
): void {
|
|
49
53
|
if (skipsCodexShimAutoRestore(command, args)) return;
|
|
54
|
+
runCodexShimAutoRestore(deps);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** The repair itself, without the command gate: for a caller that deferred it past its own check. */
|
|
58
|
+
export function runCodexShimAutoRestore(deps: CodexShimAutoRestoreCliDeps = DEFAULT_DEPS): void {
|
|
50
59
|
try {
|
|
51
60
|
const result = deps.restore({
|
|
52
61
|
enabled: () => codexShimAutoRestoreEnabled(deps.readConfig().config, deps.env),
|
package/src/cli/combo-result.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { normalizeJevQuotaTiers } from "../combos/jev-quota-config";
|
|
2
|
+
import { normalizeJevSessionPin } from "../combos/jev-session-pin-config";
|
|
2
3
|
import { parseComboTargets } from "./combo-input";
|
|
3
4
|
import { printCatalogResult } from "./catalog-command-result";
|
|
4
5
|
|
|
@@ -39,6 +40,18 @@ function publicCombo(value: unknown): Record<string, unknown> {
|
|
|
39
40
|
if (!tiers) invalid();
|
|
40
41
|
result[key] = tiers;
|
|
41
42
|
continue;
|
|
43
|
+
} else if (key === "cooldownReprobe") {
|
|
44
|
+
if (!record(child) || typeof child.enabled !== "boolean"
|
|
45
|
+
|| Object.keys(child).some(field => field !== "enabled" && field !== "intervalMs")) invalid();
|
|
46
|
+
if (child.intervalMs !== undefined && (typeof child.intervalMs !== "number"
|
|
47
|
+
|| !Number.isSafeInteger(child.intervalMs) || child.intervalMs < 1000 || child.intervalMs > 86_400_000)) invalid();
|
|
48
|
+
result[key] = { enabled: child.enabled, ...(child.intervalMs !== undefined ? { intervalMs: child.intervalMs } : {}) };
|
|
49
|
+
continue;
|
|
50
|
+
} else if (key === "sessionPin") {
|
|
51
|
+
const pin = normalizeJevSessionPin(child);
|
|
52
|
+
if (!pin) invalid();
|
|
53
|
+
result[key] = pin;
|
|
54
|
+
continue;
|
|
42
55
|
} else if (key === "nativeAlias" || key === "allowMeteredTargets" || key === "decisionQuotaSignals") {
|
|
43
56
|
if (typeof child !== "boolean") invalid();
|
|
44
57
|
} else invalid();
|
package/src/cli/combo-stats.ts
CHANGED
|
@@ -53,6 +53,8 @@ function projectStats(value: unknown, id: string, range: string) {
|
|
|
53
53
|
const rawSummary = record(dto.summary);
|
|
54
54
|
const summary = {
|
|
55
55
|
...counts(rawSummary, SUMMARY_COUNTS),
|
|
56
|
+
// Absent means zero: a proxy started before session pins (#7525) does not report the field.
|
|
57
|
+
pinnedRequests: Object.hasOwn(rawSummary, "pinnedRequests") ? number(rawSummary.pinnedRequests) : 0,
|
|
56
58
|
averageLatencyMs: nullable(rawSummary.averageLatencyMs),
|
|
57
59
|
averageConfidence: nullable(rawSummary.averageConfidence, 1),
|
|
58
60
|
averageChosenProbability: nullable(rawSummary.averageChosenProbability, 1),
|
|
@@ -111,6 +113,7 @@ export async function handleComboStatsCommand(argv: string[], deps: RuntimeApiDe
|
|
|
111
113
|
`Combo ${id} — JEV observations (${range})`,
|
|
112
114
|
...(summary.decisions === 0 ? ["No recorded JEV decisions in this window."] : []),
|
|
113
115
|
`Decisions: ${summary.decisions}; applied: ${summary.appliedDecisions}; fail-open: ${summary.failOpenDecisions}`,
|
|
116
|
+
...(summary.pinnedRequests > 0 ? [`Session-pinned requests (no decision call): ${summary.pinnedRequests}`] : []),
|
|
114
117
|
`Successful requests: ${summary.successfulRequests}; requests with model fallback: ${summary.requestsWithModelFallback}`,
|
|
115
118
|
`Model tokens: ${summary.modelTotalTokens}; measured attempts: ${summary.measuredModelAttempts}/${summary.modelAttempts}`,
|
|
116
119
|
`Decision tokens: ${summary.decisionTotalTokens}; decisions reporting usage: ${summary.decisionUsageReported}/${summary.decisions}`,
|
package/src/cli/combo.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { normalizeJevQuotaTiers } from "../combos/jev-quota-config";
|
|
2
|
+
import { parseJevSessionPinDuration } from "../combos/jev-session-pin-config";
|
|
2
3
|
import { JEV_DECISION_TIMEOUT_MAX_MS, JEV_DECISION_TIMEOUT_MIN_MS } from "../combos/types";
|
|
3
4
|
import {
|
|
4
5
|
CliUsageError,
|
|
5
6
|
printData,
|
|
6
7
|
rejectArgs,
|
|
8
|
+
RuntimeApiError,
|
|
7
9
|
runCliAction,
|
|
8
10
|
runtimeRequest,
|
|
9
11
|
runtimeBaseUrl,
|
|
@@ -22,6 +24,7 @@ const USAGE = `Usage:
|
|
|
22
24
|
ocx combo show <id> [--json]
|
|
23
25
|
ocx combo set <id> [--targets <provider/model[:weight],...> | --targets-file <FILE|->]
|
|
24
26
|
[--strategy <failover|round-robin|random|least-used|reset-window|jev>] [--sticky <1-100|->]
|
|
27
|
+
[--cooldown-reprobe <on|off>] [--cooldown-reprobe-interval <ms>]
|
|
25
28
|
[--effort <low|medium|high|xhigh|max|ultra|->] [--effort-mode <fallback|force|->]
|
|
26
29
|
(force overrides valid client effort and can increase cost/latency) [--alias <name|->]
|
|
27
30
|
[--native-alias [on|off]] [--allow-metered-targets <on|off>] [--display-name <label|->]
|
|
@@ -29,6 +32,7 @@ const USAGE = `Usage:
|
|
|
29
32
|
[--image-input <auto|disabled>] [--reasoning-effort-mode <strict|adaptive>]
|
|
30
33
|
[--decision-provider <provider|-> | --decision-model <route|->] [--decision-timeout <ms|->]
|
|
31
34
|
[--decision-quota-signals <on|off|->] [--decision-quota-tiers <JSON|->]
|
|
35
|
+
[--session-pin <duration|->] (e.g. 20m; keeps a session on JEV's target while active)
|
|
32
36
|
(jev only; the provider must be a configured jev-decision row)
|
|
33
37
|
[--rename-from <id>] [--json]
|
|
34
38
|
ocx combo stats <id> [--range <7d|30d|all>] [--json]
|
|
@@ -39,6 +43,15 @@ const USAGE = `Usage:
|
|
|
39
43
|
ocx combo discover [--query <text>] [--json]`;
|
|
40
44
|
|
|
41
45
|
type ComboRow = Record<string, unknown> & { id?: string; model?: string; strategy?: string };
|
|
46
|
+
const STRATEGIES = ["failover", "round-robin", "random", "least-used", "reset-window", "jev"] as const;
|
|
47
|
+
const isComboStrategy = (value: string): value is typeof STRATEGIES[number] => (STRATEGIES as readonly string[]).includes(value);
|
|
48
|
+
// Combo writes print fixed messages instead of server text. When --targets kept a stored JEV
|
|
49
|
+
// strategy the user did not name, a refusal of the targets or a JEV setting says so (#7579).
|
|
50
|
+
const KEPT_JEV_REJECTED = "combo_targets_rejected_by_kept_jev";
|
|
51
|
+
const KEPT_JEV_FIELDS = new Set(["targets", "decisionProvider", "decisionModel", "decisionTimeoutMs", "decisionQuotaSignals", "decisionQuotaTiers", "sessionPin"]);
|
|
52
|
+
const SET_ERRORS = {
|
|
53
|
+
[KEPT_JEV_REJECTED]: "The selected target rejected the new targets or the kept jev settings. Without --strategy, --targets keeps the stored jev strategy with its decision method, quota policy and session pin, and the save checks the new targets together with them. Inspect the combo with ocx combo show <id> --json, then fix the targets or those settings, or pass --strategy to change the strategy.",
|
|
54
|
+
};
|
|
42
55
|
|
|
43
56
|
function parseTargets(value: string): Array<{ provider: string; model: string; weight?: number }> {
|
|
44
57
|
const targets = value.split(",").map(part => part.trim()).filter(Boolean).map(part => {
|
|
@@ -91,28 +104,26 @@ async function set(argv: string[], deps: RuntimeApiDeps): Promise<number> {
|
|
|
91
104
|
if (!id) throw new CliUsageError("combo id is required", USAGE);
|
|
92
105
|
const additional = await prepareComboInput(args, deps);
|
|
93
106
|
const targetsRaw = takeOption(args, "--targets");
|
|
107
|
+
const parsedTargets = targetsRaw === undefined ? undefined : parseTargets(targetsRaw);
|
|
94
108
|
const renameFrom = takeOption(args, "--rename-from");
|
|
95
|
-
const replacingTargets =
|
|
96
|
-
deps = { ...deps, baseUrl: await runtimeBaseUrl(deps) };
|
|
97
|
-
// A structured target file replaces the target list, not unrelated combo settings.
|
|
98
|
-
const partialCurrent = targetsRaw === undefined
|
|
99
|
-
? await runtimeRequest<{ combos?: ComboRow[] }>("/api/combos", { redirect: "error" }, deps)
|
|
100
|
-
: undefined;
|
|
101
|
-
const partialExisting = partialCurrent?.combos?.find(row => row.id === (renameFrom ?? id));
|
|
102
|
-
if (!replacingTargets && !partialExisting) {
|
|
103
|
-
throw new CliUsageError("--targets is required when creating a combo", USAGE);
|
|
104
|
-
}
|
|
109
|
+
const replacingTargets = parsedTargets !== undefined || additional.targets !== undefined;
|
|
105
110
|
const strategyRaw = takeOption(args, "--strategy");
|
|
106
|
-
|
|
107
|
-
if (strategy !== "failover" && strategy !== "round-robin" && strategy !== "random" && strategy !== "least-used" && strategy !== "reset-window" && strategy !== "jev") throw new CliUsageError("--strategy must be failover, round-robin, random, least-used, reset-window, or jev", USAGE);
|
|
111
|
+
if (strategyRaw !== undefined && !isComboStrategy(strategyRaw)) throw new CliUsageError("--strategy must be failover, round-robin, random, least-used, reset-window, or jev", USAGE);
|
|
108
112
|
const stickyRaw = takeOption(args, "--sticky");
|
|
109
113
|
const stickyLimit = stickyRaw === undefined ? undefined : stickyRaw === "-" ? 1 : Number(stickyRaw);
|
|
110
114
|
if (stickyLimit !== undefined && (!Number.isInteger(stickyLimit) || stickyLimit < 1)) {
|
|
111
115
|
throw new CliUsageError("--sticky must be an integer from 1 to 100, or -", USAGE);
|
|
112
116
|
}
|
|
113
|
-
if (stickyLimit !== undefined)
|
|
114
|
-
|
|
115
|
-
|
|
117
|
+
if (stickyLimit !== undefined && stickyLimit > 100) throw new CliUsageError("--sticky must be <= 100", USAGE);
|
|
118
|
+
const reprobe = takeOption(args, "--cooldown-reprobe");
|
|
119
|
+
const reprobeInterval = takeOption(args, "--cooldown-reprobe-interval");
|
|
120
|
+
if (reprobe !== undefined && reprobe !== "on" && reprobe !== "off") {
|
|
121
|
+
throw new CliUsageError("--cooldown-reprobe must be on or off", USAGE);
|
|
122
|
+
}
|
|
123
|
+
const reprobeIntervalMs = reprobeInterval === undefined ? undefined : Number(reprobeInterval);
|
|
124
|
+
if (reprobeIntervalMs !== undefined && (!Number.isSafeInteger(reprobeIntervalMs)
|
|
125
|
+
|| reprobeIntervalMs < 1000 || reprobeIntervalMs > 86_400_000)) {
|
|
126
|
+
throw new CliUsageError("--cooldown-reprobe-interval must be an integer from 1000 to 86400000 ms", USAGE);
|
|
116
127
|
}
|
|
117
128
|
const effort = takeOption(args, "--effort");
|
|
118
129
|
const effortMode = takeOption(args, "--effort-mode");
|
|
@@ -128,19 +139,17 @@ async function set(argv: string[], deps: RuntimeApiDeps): Promise<number> {
|
|
|
128
139
|
if (decisionModel !== undefined && decisionModel !== "-" && decisionProvider !== undefined && decisionProvider !== "-") {
|
|
129
140
|
throw new CliUsageError("--decision-model cannot be combined with --decision-provider", USAGE);
|
|
130
141
|
}
|
|
131
|
-
if (decisionModel !== undefined && decisionModel !== "-" && strategy !== "jev") {
|
|
132
|
-
throw new CliUsageError("--decision-model applies only to the jev strategy", USAGE);
|
|
133
|
-
}
|
|
134
|
-
if (decisionProvider !== undefined && decisionProvider !== "-" && strategy !== "jev") {
|
|
135
|
-
throw new CliUsageError("--decision-provider applies only to the jev strategy", USAGE);
|
|
136
|
-
}
|
|
137
142
|
const quotaSignals = takeOption(args, "--decision-quota-signals");
|
|
138
143
|
const quotaTiers = takeOption(args, "--decision-quota-tiers");
|
|
139
144
|
if (quotaSignals !== undefined && !["on", "off", "-"].includes(quotaSignals)) throw new CliUsageError("--decision-quota-signals must be on, off or -", USAGE);
|
|
140
145
|
let parsedQuotaTiers: ReturnType<typeof normalizeJevQuotaTiers> | null;
|
|
141
146
|
try { parsedQuotaTiers = quotaTiers === undefined || quotaTiers === "-" ? null : normalizeJevQuotaTiers(JSON.parse(quotaTiers)); } catch { throw new CliUsageError("invalid --decision-quota-tiers JSON", USAGE); }
|
|
142
147
|
if (quotaTiers !== undefined && quotaTiers !== "-" && !parsedQuotaTiers) throw new CliUsageError("quota tiers must be finite 0..100 and strictly ascending", USAGE);
|
|
143
|
-
|
|
148
|
+
const sessionPinRaw = takeOption(args, "--session-pin");
|
|
149
|
+
const sessionPinMs = sessionPinRaw === undefined || sessionPinRaw === "-" ? undefined : parseJevSessionPinDuration(sessionPinRaw);
|
|
150
|
+
if (sessionPinRaw !== undefined && sessionPinRaw !== "-" && sessionPinMs === undefined) {
|
|
151
|
+
throw new CliUsageError("--session-pin must be a duration from 1m to 24h (for example 90s, 20m, 1h, or milliseconds), or -", USAGE);
|
|
152
|
+
}
|
|
144
153
|
const decisionTimeout = takeOption(args, "--decision-timeout");
|
|
145
154
|
let decisionTimeoutMs: number | null | undefined;
|
|
146
155
|
if (decisionTimeout !== undefined) {
|
|
@@ -154,19 +163,45 @@ async function set(argv: string[], deps: RuntimeApiDeps): Promise<number> {
|
|
|
154
163
|
USAGE,
|
|
155
164
|
);
|
|
156
165
|
}
|
|
157
|
-
if (decisionTimeoutMs !== null && strategy !== "jev") {
|
|
158
|
-
throw new CliUsageError("--decision-timeout applies only to the jev strategy", USAGE);
|
|
159
|
-
}
|
|
160
166
|
}
|
|
161
167
|
rejectArgs(args, USAGE);
|
|
168
|
+
// Flags that belong to one strategy. An explicit --strategy is checked before any request; an
|
|
169
|
+
// omitted one is the stored strategy, so it is checked once the row has been read.
|
|
170
|
+
const requireStrategyFlags = (strategy: string): void => {
|
|
171
|
+
if (stickyLimit !== undefined && strategy !== "round-robin") throw new CliUsageError("--sticky applies only to round-robin", USAGE);
|
|
172
|
+
if (strategy === "jev") return;
|
|
173
|
+
if (decisionModel !== undefined && decisionModel !== "-") throw new CliUsageError("--decision-model applies only to the jev strategy", USAGE);
|
|
174
|
+
if (decisionProvider !== undefined && decisionProvider !== "-") throw new CliUsageError("--decision-provider applies only to the jev strategy", USAGE);
|
|
175
|
+
if (quotaSignals !== undefined && quotaSignals !== "-" || quotaTiers !== undefined && quotaTiers !== "-") throw new CliUsageError("quota settings apply only to jev", USAGE);
|
|
176
|
+
if (sessionPinMs !== undefined) throw new CliUsageError("--session-pin applies only to the jev strategy", USAGE);
|
|
177
|
+
if (decisionTimeoutMs != null) throw new CliUsageError("--decision-timeout applies only to the jev strategy", USAGE);
|
|
178
|
+
};
|
|
179
|
+
if (strategyRaw !== undefined) requireStrategyFlags(strategyRaw);
|
|
180
|
+
deps = { ...deps, baseUrl: await runtimeBaseUrl(deps) };
|
|
181
|
+
// Replacing targets keeps every other stored setting, including the strategy and its policy (#7579).
|
|
182
|
+
const current = await runtimeRequest<{ combos?: ComboRow[] }>("/api/combos", { redirect: "error" }, deps);
|
|
183
|
+
const existing = current.combos?.find(row => row.id === (renameFrom ?? id));
|
|
184
|
+
if (!replacingTargets && !existing) {
|
|
185
|
+
throw new CliUsageError("--targets is required when creating a combo", USAGE);
|
|
186
|
+
}
|
|
187
|
+
const strategy = strategyRaw ?? existing?.strategy ?? "failover";
|
|
188
|
+
if (!isComboStrategy(strategy)) throw new CliUsageError(`combo ${renameFrom ?? id} has an unsupported stored strategy; pass --strategy`, USAGE);
|
|
189
|
+
if (strategyRaw === undefined) requireStrategyFlags(strategy);
|
|
162
190
|
// Listing-only nulls must not be resent as explicit clears (alias rejects null).
|
|
163
|
-
const combo: Record<string, unknown> =
|
|
164
|
-
? Object.fromEntries(Object.entries(
|
|
165
|
-
: { strategy, stickyLimit: stickyLimit ?? 1
|
|
191
|
+
const combo: Record<string, unknown> = existing
|
|
192
|
+
? Object.fromEntries(Object.entries(existing).filter(([, value]) => value !== null))
|
|
193
|
+
: { strategy, stickyLimit: stickyLimit ?? 1 };
|
|
194
|
+
if (reprobe !== undefined || reprobeIntervalMs !== undefined) {
|
|
195
|
+
const previous = (combo.cooldownReprobe ?? {}) as { enabled?: boolean; intervalMs?: number };
|
|
196
|
+
combo.cooldownReprobe = { ...previous,
|
|
197
|
+
enabled: reprobe === undefined ? previous.enabled === true : reprobe === "on",
|
|
198
|
+
...(reprobeIntervalMs !== undefined ? { intervalMs: reprobeIntervalMs } : {}),
|
|
199
|
+
};
|
|
200
|
+
}
|
|
166
201
|
delete combo.id;
|
|
167
202
|
delete combo.model;
|
|
168
|
-
if (
|
|
169
|
-
|
|
203
|
+
if (replacingTargets) combo.targets = additional.targets ?? parsedTargets;
|
|
204
|
+
combo.strategy = strategy;
|
|
170
205
|
if (stickyLimit !== undefined) combo.stickyLimit = stickyLimit;
|
|
171
206
|
if (effort !== undefined) combo.defaultEffort = effort === "-" ? null : effort;
|
|
172
207
|
if (effortMode !== undefined) combo.defaultEffortMode = effortMode === "-" ? "fallback" : effortMode;
|
|
@@ -184,26 +219,33 @@ async function set(argv: string[], deps: RuntimeApiDeps): Promise<number> {
|
|
|
184
219
|
if (decisionTimeoutMs !== undefined) combo.decisionTimeoutMs = decisionTimeoutMs;
|
|
185
220
|
if (quotaSignals !== undefined) combo.decisionQuotaSignals = quotaSignals === "-" ? null : quotaSignals === "on";
|
|
186
221
|
if (quotaTiers !== undefined) combo.decisionQuotaTiers = parsedQuotaTiers;
|
|
222
|
+
if (sessionPinRaw !== undefined) combo.sessionPin = sessionPinMs === undefined ? null : { ttlMs: sessionPinMs };
|
|
187
223
|
if (strategy !== "jev") {
|
|
188
224
|
delete combo.decisionProvider;
|
|
189
225
|
delete combo.decisionModel;
|
|
190
226
|
delete combo.decisionTimeoutMs;
|
|
191
227
|
delete combo.decisionQuotaSignals;
|
|
192
228
|
delete combo.decisionQuotaTiers;
|
|
193
|
-
|
|
194
|
-
const current = partialCurrent ?? await runtimeRequest<{ combos?: ComboRow[] }>("/api/combos", { redirect: "error" }, deps);
|
|
195
|
-
const existing = (current.combos ?? []).find(row => row.id === (renameFrom ?? id));
|
|
196
|
-
if (additional.imageInput === undefined && existing?.imageInput === "disabled") combo.imageInput = "disabled";
|
|
197
|
-
if (effort === undefined && existing?.defaultEffort != null && combo.defaultEffort === undefined) {
|
|
198
|
-
combo.defaultEffort = existing.defaultEffort;
|
|
229
|
+
delete combo.sessionPin;
|
|
199
230
|
}
|
|
200
231
|
if (effortMode === undefined && existing?.defaultEffortMode === "force") {
|
|
201
232
|
combo.defaultEffortMode = effort === "-" ? "fallback" : "force";
|
|
202
233
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
234
|
+
let result: unknown;
|
|
235
|
+
try {
|
|
236
|
+
result = await runtimeRequest("/api/combos", {
|
|
237
|
+
method: "PUT", redirect: "error",
|
|
238
|
+
body: serializeManagementJson({ id, combo, ...(renameFrom ? { renameFrom } : {}) }),
|
|
239
|
+
}, deps);
|
|
240
|
+
} catch (error) {
|
|
241
|
+
const field = error instanceof RuntimeApiError && error.body !== null && typeof error.body === "object"
|
|
242
|
+
? (error.body as Record<string, unknown>).field : undefined;
|
|
243
|
+
if (error instanceof RuntimeApiError && error.status === 400 && typeof field === "string" && KEPT_JEV_FIELDS.has(field)
|
|
244
|
+
&& replacingTargets && strategyRaw === undefined && strategy === "jev") {
|
|
245
|
+
throw new RuntimeApiError(error.message, error.status, { code: KEPT_JEV_REJECTED });
|
|
246
|
+
}
|
|
247
|
+
throw error;
|
|
248
|
+
}
|
|
207
249
|
return printComboWriteResult(result, id, wantsJson);
|
|
208
250
|
}
|
|
209
251
|
|
|
@@ -286,7 +328,7 @@ async function discover(argv: string[], deps: RuntimeApiDeps): Promise<void> {
|
|
|
286
328
|
|
|
287
329
|
export async function handleComboCommand(argv: string[], deps: RuntimeApiDeps = {}): Promise<number> {
|
|
288
330
|
const [subcommand, ...writeArgs] = argv;
|
|
289
|
-
if (subcommand === "set" || subcommand === "create" || subcommand === "update") return runCatalogAction(() => set(writeArgs, deps));
|
|
331
|
+
if (subcommand === "set" || subcommand === "create" || subcommand === "update") return runCatalogAction(() => set(writeArgs, deps), SET_ERRORS);
|
|
290
332
|
if (subcommand === "stats") {
|
|
291
333
|
const { handleComboStatsCommand } = await import("./combo-stats");
|
|
292
334
|
return handleComboStatsCommand(writeArgs, deps);
|
|
@@ -9,6 +9,9 @@ import { detectCodexRoutingDrift } from "../codex/routing-drift";
|
|
|
9
9
|
import { readBoundedCodexConfig } from "../codex/inject/bounded-config-reader";
|
|
10
10
|
import { currentExternalCodexModelProvider } from "../codex/inject";
|
|
11
11
|
import { reconcileJournal } from "../codex/journal";
|
|
12
|
+
import { shouldSyncCodexOnStart } from "../codex/desired-state";
|
|
13
|
+
import { loadConfig } from "../config";
|
|
14
|
+
import { updateTeardownHandoverPending } from "../update/teardown-handover";
|
|
12
15
|
import { markSiblingStart, siblingOfLivePort } from "../codex/sibling-start";
|
|
13
16
|
import { readClientConnectionState } from "../client/state";
|
|
14
17
|
import { findManagedRegion, resolveGrokHome } from "../grok/inject";
|
|
@@ -350,5 +353,14 @@ export function reconcileStartupJournal(): void {
|
|
|
350
353
|
const clientState = readClientConnectionState();
|
|
351
354
|
reconcileJournal(clientState.kind === "connected"
|
|
352
355
|
? { activeClientApiKeyId: clientState.value.apiKeyId }
|
|
353
|
-
:
|
|
356
|
+
: { adoptUpdateHandover: updateTeardownHandoverPending() && startupSyncEnabled() });
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* #7423: adoption keeps routing only for a startup that will re-publish it. A user who has
|
|
361
|
+
* since turned the Codex integration off gets the ordinary recovery, even with a stale
|
|
362
|
+
* handover receipt on disk; an unreadable config is treated the same way.
|
|
363
|
+
*/
|
|
364
|
+
function startupSyncEnabled(): boolean {
|
|
365
|
+
try { return shouldSyncCodexOnStart(loadConfig()); } catch { return false; }
|
|
354
366
|
}
|
package/src/cli/dispatch.ts
CHANGED
|
@@ -404,6 +404,14 @@ const commandRunners: Record<string, CommandRunner> = {
|
|
|
404
404
|
},
|
|
405
405
|
sync: async deps => {
|
|
406
406
|
const syncArgs = deps.args.slice(1);
|
|
407
|
+
// #7694: parse the expected identity before anything else reads or writes state.
|
|
408
|
+
const { parseSyncExpectation, reportSyncExpectationMismatch, SYNC_EXPECTATION_USAGE_EXIT } = await import("./sync-expectation");
|
|
409
|
+
const parsedExpectation = parseSyncExpectation(syncArgs);
|
|
410
|
+
if (!parsedExpectation.ok) {
|
|
411
|
+
console.error(parsedExpectation.message);
|
|
412
|
+
return SYNC_EXPECTATION_USAGE_EXIT;
|
|
413
|
+
}
|
|
414
|
+
const expectation = parsedExpectation.expectation;
|
|
407
415
|
const restartScope = readRestartScope(syncArgs, console);
|
|
408
416
|
// The wire field keeps APP-SERVER-ONLY meaning and is deliberately not widened. A
|
|
409
417
|
// remote hub must not end a local user's conversations because a field name acquired
|
|
@@ -412,15 +420,24 @@ const commandRunners: Record<string, CommandRunner> = {
|
|
|
412
420
|
const restartCodex = restartScope.appServers;
|
|
413
421
|
const { readClientConnectionState } = await import("../client/state");
|
|
414
422
|
const clientState = readClientConnectionState();
|
|
415
|
-
|
|
423
|
+
// With an expectation the unlocked read decides nothing: the connected sync re-reads under its
|
|
424
|
+
// lock and refuses there, so a state that changes in between can never reach the local path.
|
|
425
|
+
if (!expectation && (clientState.kind === "invalid" || clientState.kind === "mismatched")) {
|
|
416
426
|
console.error(`Client state is ${clientState.kind}: ${clientState.reason}`);
|
|
417
427
|
return 1;
|
|
418
428
|
}
|
|
419
|
-
if (clientState.kind === "connected") {
|
|
429
|
+
if (expectation || clientState.kind === "connected") {
|
|
420
430
|
try {
|
|
421
431
|
const { syncConnectedClient } = await import("../client/connect");
|
|
422
|
-
const result = await syncConnectedClient({ restartCodex });
|
|
423
|
-
|
|
432
|
+
const result = await syncConnectedClient(expectation ? { restartCodex, expect: expectation } : { restartCodex });
|
|
433
|
+
if (expectation) {
|
|
434
|
+
// The root preflight skipped the shim repair for a pinned sync; the identity held, so
|
|
435
|
+
// run it now, as an unpinned sync would have.
|
|
436
|
+
const { runCodexShimAutoRestore } = await import("./codex-shim-autorestore");
|
|
437
|
+
runCodexShimAutoRestore();
|
|
438
|
+
}
|
|
439
|
+
// The connection the sync ran under, read inside its lock; the read above may be stale.
|
|
440
|
+
const link = result.connection.transport === "link";
|
|
424
441
|
console.log(result.stale
|
|
425
442
|
? `${link ? "Home" : "Hub"} unavailable; retained and applied the last-known-good remote catalog (stale).`
|
|
426
443
|
: link ? "Remote Link Home catalog synchronized." : "Remote hub catalog synchronized.");
|
|
@@ -445,7 +462,7 @@ const commandRunners: Record<string, CommandRunner> = {
|
|
|
445
462
|
if (link && result.appliedRecord) {
|
|
446
463
|
const { applyRestartMessage, restartRuntimeAfterApply } = await import("./link-apply-restart");
|
|
447
464
|
const { sameClientConnectionOwner } = await import("../client/state");
|
|
448
|
-
const applied =
|
|
465
|
+
const applied = result.connection;
|
|
449
466
|
const outcome = await restartRuntimeAfterApply(result.appliedRecord, {
|
|
450
467
|
restart: startWhenStopped => deps.handleProxyRestart(startWhenStopped),
|
|
451
468
|
recoveryStart: recovering => deps.handleRestartStartWhenStopped(recovering),
|
|
@@ -470,6 +487,8 @@ const commandRunners: Record<string, CommandRunner> = {
|
|
|
470
487
|
// types it as `number | string`; only a numeric code means anything here.
|
|
471
488
|
return typeof process.exitCode === "number" ? process.exitCode : 0;
|
|
472
489
|
} catch (error) {
|
|
490
|
+
const { ClientSyncExpectationError } = await import("../client/sync-expectation");
|
|
491
|
+
if (error instanceof ClientSyncExpectationError) return reportSyncExpectationMismatch(error, console);
|
|
473
492
|
// The refresh path reaches the same hub catalog `ocx connect` validates, so a rejected
|
|
474
493
|
// reasoning level arrives here as hub-supplied text. Rendering it through the shared
|
|
475
494
|
// terminal boundary is what keeps the routine refresh from forging output; the domain
|
|
@@ -527,7 +546,7 @@ const commandRunners: Record<string, CommandRunner> = {
|
|
|
527
546
|
},
|
|
528
547
|
config,
|
|
529
548
|
port: live.port,
|
|
530
|
-
}, ["mcode", "pi", "raycast", "omo", "cline", "commandcode", "droid", "opencode", "kilo", "qoder"]));
|
|
549
|
+
}, ["mcode", "pi", "raycast", "omo", "cline", "commandcode", "droid", "opencode", "kilo", "qoder", "qoder-cn", "workbuddy", "workbuddy-ai"]));
|
|
531
550
|
} catch (error) {
|
|
532
551
|
console.warn(`Client integrations were not refreshed: ${error instanceof Error ? error.message : String(error)}`);
|
|
533
552
|
}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { loadConfig } from "../config";
|
|
12
12
|
import { cliFirstPartyDesired, firstPartyDesired, reconcileClaudeFirstPartySettings } from "../claude/first-party-settings";
|
|
13
|
+
import { getConfigDir } from "../config/paths";
|
|
13
14
|
import { claudeInterceptEnabled } from "../claude/intercept/runtime";
|
|
14
15
|
import { removeDesktopPickerArtifacts } from "../claude/desktop-picker";
|
|
15
16
|
import { findLiveProxy } from "../server/proxy-liveness";
|
|
@@ -17,10 +18,10 @@ import { runtimeRequest } from "./runtime-api";
|
|
|
17
18
|
import { stripGrokConfig, type GrokInjectResult } from "../grok/inject";
|
|
18
19
|
import { inspectDesktop3pConfigLibrary, removeDesktop3pStandardPivot } from "../claude/desktop-3p";
|
|
19
20
|
import {
|
|
20
|
-
applyDesktopFirstParty,
|
|
21
|
+
applyDesktopFirstParty, withFirstPartySecretsSettled,
|
|
21
22
|
inspectDesktopFirstParty,
|
|
22
23
|
observeClaudeDesktopMode,
|
|
23
|
-
removeDesktopFirstParty,
|
|
24
|
+
removeDesktopFirstParty, removeDesktopFirstPartySettled,
|
|
24
25
|
resolveClaudeDesktopMode,
|
|
25
26
|
} from "../claude/desktop-first-party";
|
|
26
27
|
import {
|
|
@@ -154,8 +155,9 @@ export async function ensureClaudeDesktopMatchesDesired(
|
|
|
154
155
|
if (cliFirstPartyDesired(config)) {
|
|
155
156
|
const seen = (deps.inspectDesktopFirstParty ?? inspectDesktopFirstParty)(config);
|
|
156
157
|
if (seen.settings.kind === "absent" || seen.stale || !claudeInterceptEnabled(config)) {
|
|
157
|
-
const result = (
|
|
158
|
-
|
|
158
|
+
const result = await withFirstPartySecretsSettled(getConfigDir(), () =>
|
|
159
|
+
(deps.reconcileClaudeFirstPartySettings ?? reconcileClaudeFirstPartySettings)(config,
|
|
160
|
+
firstPartyDesired(config, (deps.observeClaudeDesktopMode ?? observeClaudeDesktopMode)(config))));
|
|
159
161
|
if (result.ok && result.changed) log(` + Claude CLI first-party env refreshed (${result.path})`);
|
|
160
162
|
else if (!result.ok) error(`⚠️ Claude CLI first-party env refresh skipped: ${result.reason}.`);
|
|
161
163
|
}
|
|
@@ -173,7 +175,7 @@ export async function ensureClaudeDesktopMatchesDesired(
|
|
|
173
175
|
}
|
|
174
176
|
const seen = (deps.inspectDesktopFirstParty ?? inspectDesktopFirstParty)(config);
|
|
175
177
|
if (!seen.stale) return;
|
|
176
|
-
const applied = (deps.applyDesktopFirstParty ?? applyDesktopFirstParty)(config);
|
|
178
|
+
const applied = await withFirstPartySecretsSettled(getConfigDir(), () => (deps.applyDesktopFirstParty ?? applyDesktopFirstParty)(config));
|
|
177
179
|
if (applied.ok && applied.changed) log(` + Claude Desktop first-party env refreshed (${applied.path})`);
|
|
178
180
|
else if (!applied.ok) error(`⚠️ Claude Desktop first-party env refresh skipped: ${applied.reason}.`);
|
|
179
181
|
return;
|
|
@@ -196,7 +198,7 @@ export async function ensureClaudeDesktopMatchesDesired(
|
|
|
196
198
|
error(`⚠️ Claude Desktop picker cleanup skipped: ${detail}.`);
|
|
197
199
|
}
|
|
198
200
|
try {
|
|
199
|
-
const env = (deps.removeDesktopFirstParty ?? removeDesktopFirstParty)
|
|
201
|
+
const env = await removeDesktopFirstPartySettled(deps.loadConfig, {}, deps.removeDesktopFirstParty ?? removeDesktopFirstParty);
|
|
200
202
|
if (env.ok && env.changed) log(" ↩️ Claude Desktop first-party env removed.");
|
|
201
203
|
else if (env.ok && env.retainedFor === "cli") log(" = Shared first-party env retained for Claude Code CLI.");
|
|
202
204
|
else if (!env.ok) error(`⚠️ Claude Desktop first-party env cleanup skipped: ${env.reason} (${env.path}).`);
|
|
@@ -94,6 +94,9 @@ export function exportModelsFromProxyRows(
|
|
|
94
94
|
if (entry.maxTokens !== undefined) model.maxTokens = entry.maxTokens;
|
|
95
95
|
if (entry.maxInputTokens !== undefined) model.maxInputTokens = entry.maxInputTokens;
|
|
96
96
|
if (entry.reasoningEfforts !== undefined) model.reasoningEfforts = [...entry.reasoningEfforts];
|
|
97
|
+
if (entry.supportsThinkingToggle !== undefined) model.supportsThinkingToggle = entry.supportsThinkingToggle;
|
|
98
|
+
if (entry.supportsReasoningEffort !== undefined) model.supportsReasoningEffort = entry.supportsReasoningEffort;
|
|
99
|
+
if (entry.defaultThinkingEnabled !== undefined) model.defaultThinkingEnabled = entry.defaultThinkingEnabled;
|
|
97
100
|
if (entry.defaultReasoningEffort) model.defaultReasoningEffort = entry.defaultReasoningEffort;
|
|
98
101
|
if (entry.inputModalities && entry.inputModalities.length > 0) {
|
|
99
102
|
model.inputModalities = [...entry.inputModalities];
|
|
@@ -169,7 +172,7 @@ export async function handleExportCommand(argv: string[], deps: ExportCommandDep
|
|
|
169
172
|
const spec = EXPORT_CLIENTS[client];
|
|
170
173
|
const root = await runtimeBaseUrl(deps);
|
|
171
174
|
let built: { document: unknown; text: string };
|
|
172
|
-
if (client === "raycast" || client === "droid" || client === "qoder") {
|
|
175
|
+
if (client === "raycast" || client === "droid" || client === "qoder" || client === "qoder-cn" || client === "workbuddy" || client === "workbuddy-ai") {
|
|
173
176
|
// The dial address alone cannot distinguish a wildcard authenticated bind
|
|
174
177
|
// from loopback. Let the live server resolve its admission/listener policy;
|
|
175
178
|
// saved config can differ from the process serving this request.
|
package/src/cli/help.ts
CHANGED
|
@@ -49,6 +49,7 @@ Usage:
|
|
|
49
49
|
ocx remote-workspace <sub> Pair/run an OCX-only remote execution computer
|
|
50
50
|
ocx disconnect Restore local state and clear the hub connection
|
|
51
51
|
ocx sync [--restart-codex] Fetch models from providers and inject into Codex config
|
|
52
|
+
--expect-link <id> | --expect-hub-key <id>: only from that Home/hub key (exit 5 otherwise)
|
|
52
53
|
ocx sync-cache [--restart-codex]
|
|
53
54
|
Refresh Codex's model cache from the active catalog
|
|
54
55
|
ocx catalog pull <https-url> Install a validated remote catalog and refresh the Codex cache
|
|
@@ -93,7 +94,7 @@ Usage:
|
|
|
93
94
|
ocx api-key <sub> Alias of ocx access key
|
|
94
95
|
ocx access <sub> External API keys and endpoint information
|
|
95
96
|
ocx api <sub> Protocol paths: vocabulary, request-path preview, and policy
|
|
96
|
-
ocx export --client <id> Print a client config wired to the running proxy (
|
|
97
|
+
ocx export --client <id> Print a client config wired to the running proxy (23 clients)
|
|
97
98
|
ocx integration client <sub> Enable, disable, inspect or roll back a client integration
|
|
98
99
|
ocx grok <sub> Grok Build model selection and apply
|
|
99
100
|
ocx system <sub> Runtime settings, startup, sync, OpenCodex updates, and Codex CLI inspection
|