@bitkyc08/opencodex 2.95.0 → 2.97.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (276) hide show
  1. package/bin/ocx.mjs +214 -19
  2. package/gui/dist/assets/{App-8yedBkhm.js → App-DuNhggE1.js} +18 -18
  3. package/gui/dist/assets/{Tray-erSMzxPG.js → Tray-CEw0y0jR.js} +1 -1
  4. package/gui/dist/assets/index-CynE_Rue.js +94 -0
  5. package/gui/dist/assets/{quota-summary-BK4VuQNc.js → quota-summary-VHFSlUuM.js} +1 -1
  6. package/gui/dist/index.html +1 -1
  7. package/package.json +1 -1
  8. package/src/adapters/command-code.ts +15 -16
  9. package/src/adapters/cursor/transport-retry.ts +2 -2
  10. package/src/adapters/devin/cloud-direct/chat.ts +15 -6
  11. package/src/adapters/kiro/stream.ts +63 -4
  12. package/src/adapters/kiro-constants.ts +15 -1
  13. package/src/adapters/kiro-events.ts +31 -1
  14. package/src/adapters/kiro-retry.ts +3 -3
  15. package/src/adapters/ollama-native.ts +21 -7
  16. package/src/adapters/openai-responses/canonical-forward.ts +50 -13
  17. package/src/adapters/openai-responses/empty-assistant.ts +15 -3
  18. package/src/adapters/openai-responses/passthrough.ts +8 -8
  19. package/src/adapters/openai-responses/reasoning.ts +9 -4
  20. package/src/adapters/openai-responses/request-strips.ts +1 -1
  21. package/src/adapters/openai-responses/transport.ts +17 -26
  22. package/src/adapters/physical-send.ts +3 -3
  23. package/src/adapters/qoder/adapter.ts +1 -1
  24. package/src/adapters/qoder/image-input.ts +5 -2
  25. package/src/adapters/zed-openai-stream.ts +2 -1
  26. package/src/bridge/errors.ts +11 -2
  27. package/src/bridge/response-json.ts +2 -1
  28. package/src/bridge/sse.ts +14 -6
  29. package/src/chat/failure-verdict.ts +21 -0
  30. package/src/chat/outbound.ts +139 -21
  31. package/src/claude/outbound.ts +49 -2
  32. package/src/cli/agent.ts +44 -15
  33. package/src/cli/capabilities-agents-routing.ts +9 -0
  34. package/src/cli/capabilities-base.ts +25 -3
  35. package/src/cli/capabilities-command.ts +12 -3
  36. package/src/cli/capability-contracts.ts +2 -0
  37. package/src/cli/codex-launch-auth.ts +30 -1
  38. package/src/cli/codex-launcher.ts +12 -5
  39. package/src/cli/codex-shim-autorestore.ts +5 -4
  40. package/src/cli/dispatch.ts +11 -176
  41. package/src/cli/ensure-desired-integrations.ts +4 -3
  42. package/src/cli/help.ts +2 -2
  43. package/src/cli/index.ts +9 -2
  44. package/src/cli/link.ts +1 -1
  45. package/src/cli/message-command.ts +2 -1
  46. package/src/cli/message-mcp-command.ts +29 -0
  47. package/src/cli/registry.ts +12 -4
  48. package/src/cli/root.ts +8 -0
  49. package/src/cli/sync-command.ts +243 -0
  50. package/src/cli/sync-fanout-process.ts +92 -0
  51. package/src/cli/sync-fanout.ts +150 -0
  52. package/src/cli/sync-flags.ts +10 -0
  53. package/src/cli/sync-link-status.ts +39 -0
  54. package/src/cli/sync-update-guard.ts +18 -0
  55. package/src/client/connect.ts +31 -14
  56. package/src/client/link-home.ts +3 -2
  57. package/src/client/machine-listener.ts +3 -0
  58. package/src/client/restore-ownership.ts +19 -1
  59. package/src/client/runtime-restart.ts +12 -4
  60. package/src/client/runtime.ts +40 -11
  61. package/src/client/stop-routing.ts +62 -0
  62. package/src/client/sync-runtime.ts +65 -0
  63. package/src/clients/config-export.ts +32 -3
  64. package/src/codex/account-store.ts +1 -0
  65. package/src/codex/auth-context-provider.ts +15 -0
  66. package/src/codex/auth-context.ts +59 -122
  67. package/src/codex/catalog/antigravity-discovery.ts +16 -5
  68. package/src/codex/catalog/provider-models.ts +6 -8
  69. package/src/codex/forward-transport-headers.ts +65 -36
  70. package/src/codex/inject/config-toml.ts +88 -0
  71. package/src/codex/inject/multi-agent-v2.ts +30 -4
  72. package/src/codex/inject/plan.ts +34 -7
  73. package/src/codex/inject-coordination.ts +11 -0
  74. package/src/codex/inject.ts +18 -7
  75. package/src/codex/installation-id.ts +72 -0
  76. package/src/codex/lineage.ts +13 -7
  77. package/src/codex/quota.ts +22 -6
  78. package/src/codex/request-owned-affinity-key.ts +11 -0
  79. package/src/codex/request-owned-affinity.ts +118 -0
  80. package/src/codex/request-owned-main-pin.ts +86 -0
  81. package/src/codex/role-capability.ts +52 -41
  82. package/src/codex/routing/active-account.ts +13 -5
  83. package/src/codex/routing/selection.ts +40 -1
  84. package/src/codex/routing/thread-affinity-store.ts +916 -0
  85. package/src/codex/routing/thread-affinity.ts +90 -12
  86. package/src/codex/toml-source-lines.ts +72 -13
  87. package/src/combos/failover.ts +6 -109
  88. package/src/combos/request.ts +2 -2
  89. package/src/combos/resolve.ts +29 -11
  90. package/src/config/process-state.ts +5 -0
  91. package/src/config/schema/leaf-validators.ts +1 -0
  92. package/src/generated/compatibility-version.json +496 -192
  93. package/src/grok/sync.ts +10 -1
  94. package/src/images/loop.ts +2 -1
  95. package/src/lib/client-error-body.ts +184 -0
  96. package/src/lib/client-retry-after.ts +66 -0
  97. package/src/lib/config-ownership.ts +4 -0
  98. package/src/lib/context-overflow-verdict.ts +113 -0
  99. package/src/lib/desktop-cli-handoff.d.mts +1 -1
  100. package/src/lib/desktop-cli-handoff.mjs +11 -1
  101. package/src/lib/empty-tool-catalog.ts +25 -3
  102. package/src/lib/error-destination.ts +47 -0
  103. package/src/lib/failure-detail.ts +66 -0
  104. package/src/lib/model-identity.ts +44 -0
  105. package/src/lib/private-sqlite-path.ts +124 -0
  106. package/src/lib/response-service-tier.ts +17 -0
  107. package/src/lib/retry-after.ts +3 -0
  108. package/src/lib/spend-ledger-owner.ts +43 -4
  109. package/src/lib/upstream-condition.ts +142 -0
  110. package/src/lib/upstream-retry.ts +14 -11
  111. package/src/lib/windows-owner-acl.ts +13 -6
  112. package/src/lib/windows-secret-acl.ts +2 -2
  113. package/src/link/remote-platform.ts +14 -0
  114. package/src/link/remote-windows.ts +51 -9
  115. package/src/link/ssh-argv.ts +63 -10
  116. package/src/messaging/mcp-queue-rpc.ts +102 -0
  117. package/src/messaging/mcp-queue-server.ts +42 -0
  118. package/src/messaging/mcp-queue-tools.ts +39 -0
  119. package/src/oauth/anthropic-identity.ts +2 -6
  120. package/src/oauth/generic-account-failover.ts +13 -11
  121. package/src/oauth/index.ts +41 -74
  122. package/src/oauth/oauth-errors.ts +67 -0
  123. package/src/oauth/store.ts +1 -1
  124. package/src/protocols/codecs/ollama.ts +197 -0
  125. package/src/protocols/encoders/adapter-events.ts +4 -0
  126. package/src/protocols/encoders/chat.ts +18 -10
  127. package/src/protocols/trace.ts +18 -0
  128. package/src/providers/anthropic-subscription.ts +25 -0
  129. package/src/providers/claude-cli-usage.ts +15 -67
  130. package/src/providers/fastwire.ts +3 -2
  131. package/src/providers/quota/anthropic-decision-windows.ts +5 -19
  132. package/src/providers/quota/anthropic-usage-windows.ts +65 -0
  133. package/src/providers/quota/vendor-probes-key.ts +60 -24
  134. package/src/providers/request-pacing.ts +3 -2
  135. package/src/responses/apply-patch-envelope.ts +45 -19
  136. package/src/responses/compaction-history-framing.ts +5 -1
  137. package/src/responses/freeform-wrapper-scan.ts +5 -3
  138. package/src/responses/parser-tools.ts +1 -0
  139. package/src/responses/progressive-freeform-input.ts +354 -45
  140. package/src/responses/schema.ts +5 -2
  141. package/src/routing/fallback-policy.ts +3 -1
  142. package/src/server/admission-model-scope.ts +17 -6
  143. package/src/server/admitted-http-turn.ts +56 -0
  144. package/src/server/audio-dictation.ts +3 -0
  145. package/src/server/audio-live.ts +8 -2
  146. package/src/server/audio-upstream.ts +2 -0
  147. package/src/server/auth-cors.ts +5 -0
  148. package/src/server/chat-completions.ts +45 -20
  149. package/src/server/chat-native-sse.ts +52 -7
  150. package/src/server/chat-native.ts +60 -35
  151. package/src/server/claude-bridge-pool-session.ts +59 -0
  152. package/src/server/claude-messages.ts +57 -27
  153. package/src/server/context-history.ts +14 -7
  154. package/src/server/images.ts +14 -5
  155. package/src/server/inbound-body-admission.ts +11 -4
  156. package/src/server/index/live-sideband.ts +16 -2
  157. package/src/server/index/ollama-routes.ts +89 -0
  158. package/src/server/index/serve-options.ts +22 -4
  159. package/src/server/index/websocket-handler.ts +5 -3
  160. package/src/server/index.ts +6 -36
  161. package/src/server/inference/client-encoder-delivery.ts +4 -2
  162. package/src/server/json-serialized-bytes.ts +44 -0
  163. package/src/server/live.ts +30 -5
  164. package/src/server/management/agent-settings-routes.ts +24 -21
  165. package/src/server/management/codex-cli-update-routes.ts +2 -1
  166. package/src/server/management/route-registry.ts +1 -1
  167. package/src/server/messages-native-scope.ts +2 -1
  168. package/src/server/messages-native-tool-guard.ts +1 -1
  169. package/src/server/messages-native.ts +12 -7
  170. package/src/server/messages-shared.ts +6 -2
  171. package/src/server/native-final-log.ts +93 -0
  172. package/src/server/ollama-inbound.ts +349 -0
  173. package/src/server/ollama-native-paths.ts +21 -0
  174. package/src/server/ollama-route-policy.ts +73 -0
  175. package/src/server/relay.ts +22 -3
  176. package/src/server/request-decompress.ts +4 -2
  177. package/src/server/request-log-failure-attribution.ts +22 -0
  178. package/src/server/request-log-failure-detail.ts +80 -0
  179. package/src/server/request-log-terminal-status.ts +4 -2
  180. package/src/server/request-log.ts +79 -42
  181. package/src/server/response-log-body.ts +6 -1
  182. package/src/server/responses/account-change-state.ts +17 -6
  183. package/src/server/responses/adapter-continuation.ts +9 -4
  184. package/src/server/responses/adapter-delivery.ts +5 -4
  185. package/src/server/responses/adapter-dispatch.ts +36 -30
  186. package/src/server/responses/anthropic-thinking-recovery.ts +3 -0
  187. package/src/server/responses/codex-auth-error.ts +22 -17
  188. package/src/server/responses/codex-ws-exchange.ts +11 -8
  189. package/src/server/responses/codex-ws-metadata.ts +94 -21
  190. package/src/server/responses/codex-ws-request.ts +3 -1
  191. package/src/server/responses/combo-required-tool-contract.ts +24 -12
  192. package/src/server/responses/compact.ts +89 -41
  193. package/src/server/responses/compaction-recovery.ts +4 -2
  194. package/src/server/responses/compaction-routing.ts +9 -4
  195. package/src/server/responses/core-auth.ts +32 -14
  196. package/src/server/responses/core-codex-account.ts +34 -12
  197. package/src/server/responses/core-combo-failure.ts +5 -1
  198. package/src/server/responses/core-combo-native.ts +2 -1
  199. package/src/server/responses/core-combo.ts +51 -33
  200. package/src/server/responses/core-errors.ts +22 -20
  201. package/src/server/responses/core-lifetime.ts +6 -3
  202. package/src/server/responses/core-normalize.ts +8 -1
  203. package/src/server/responses/core-options.ts +7 -0
  204. package/src/server/responses/core-pipeline.ts +4 -3
  205. package/src/server/responses/fetch-helpers.ts +7 -1
  206. package/src/server/responses/input-admission.ts +28 -2
  207. package/src/server/responses/native-injection.ts +1 -1
  208. package/src/server/responses/native-response-json.ts +13 -4
  209. package/src/server/responses/native-response-output.ts +1 -2
  210. package/src/server/responses/non-replayable-error.ts +2 -1
  211. package/src/server/responses/pacing-overload.ts +3 -2
  212. package/src/server/responses/passthrough-build-error.ts +36 -0
  213. package/src/server/responses/passthrough-delivery.ts +55 -14
  214. package/src/server/responses/passthrough-dispatch.ts +26 -39
  215. package/src/server/responses/passthrough-error.ts +9 -9
  216. package/src/server/responses/policy-fallback.ts +2 -1
  217. package/src/server/responses/request-prepare.ts +67 -48
  218. package/src/server/responses/request-sidecar-auth.ts +3 -1
  219. package/src/server/responses/request-transport.ts +35 -31
  220. package/src/server/responses/run-turn-execution.ts +6 -6
  221. package/src/server/responses/sidecar-execution.ts +16 -12
  222. package/src/server/responses/spend-storage-error.ts +2 -1
  223. package/src/server/responses/ws-upstream.ts +9 -0
  224. package/src/server/responses-custom-tool-repair.ts +14 -3
  225. package/src/server/responses-terminal-repair.ts +5 -2
  226. package/src/server/responses-undeclared-tool-guard.ts +39 -16
  227. package/src/server/safe-response-headers.ts +162 -13
  228. package/src/server/search.ts +13 -4
  229. package/src/server/turn-state-handles.ts +164 -0
  230. package/src/server/workflow-refusal.ts +2 -1
  231. package/src/server/ws-bridge.ts +5 -2
  232. package/src/service/ownership-mutation-lease.d.mts +11 -2
  233. package/src/service/ownership-mutation-lease.mjs +53 -11
  234. package/src/types/config.ts +2 -0
  235. package/src/update/index.ts +133 -25
  236. package/src/update/npm-install.d.mts +8 -0
  237. package/src/update/npm-install.mjs +20 -1
  238. package/src/update/orchestrated-admission.d.mts +4 -0
  239. package/src/update/orchestrated-admission.mjs +12 -0
  240. package/src/update/orchestrated-arguments.d.mts +12 -0
  241. package/src/update/orchestrated-arguments.mjs +64 -0
  242. package/src/update/orchestrated-child.d.mts +12 -0
  243. package/src/update/orchestrated-child.mjs +70 -0
  244. package/src/update/orchestrated-entry.ts +234 -0
  245. package/src/update/orchestrated-identity-probe-entry.ts +20 -0
  246. package/src/update/orchestrated-identity.ts +53 -0
  247. package/src/update/orchestrated-live-identity.ts +48 -0
  248. package/src/update/orchestrated-node-driver.mjs +99 -0
  249. package/src/update/orchestrated-outcome.d.mts +21 -0
  250. package/src/update/orchestrated-outcome.mjs +40 -0
  251. package/src/update/orchestrated-plan.ts +49 -0
  252. package/src/update/orchestrated-pnpm.d.mts +8 -0
  253. package/src/update/orchestrated-pnpm.mjs +33 -0
  254. package/src/update/orchestrated-session.d.mts +37 -0
  255. package/src/update/orchestrated-session.mjs +264 -0
  256. package/src/update/orchestrated-token.d.mts +10 -0
  257. package/src/update/orchestrated-token.mjs +21 -0
  258. package/src/update/orchestrated-token.ts +3 -0
  259. package/src/update/orchestrated-tree.d.mts +1 -0
  260. package/src/update/orchestrated-tree.mjs +14 -0
  261. package/src/update/pnpm-global-install.d.mts +6 -0
  262. package/src/update/pnpm-global-install.mjs +9 -2
  263. package/src/update/posix-install-supervisor-entry.mjs +6 -0
  264. package/src/update/posix-install-supervisor.d.mts +10 -0
  265. package/src/update/posix-install-supervisor.mjs +88 -0
  266. package/src/update/sync-update-mutex.d.mts +10 -0
  267. package/src/update/sync-update-mutex.mjs +164 -0
  268. package/src/update/sync-update-mutex.ts +1 -0
  269. package/src/update/test-home-guard.mjs +33 -0
  270. package/src/update/transactional-install.mjs +2 -2
  271. package/src/usage/error-detail.ts +225 -0
  272. package/src/usage/log.ts +60 -27
  273. package/src/vision/describe.ts +4 -7
  274. package/src/web-search/executor.ts +4 -7
  275. package/src/web-search/loop.ts +31 -5
  276. package/gui/dist/assets/index-D7DCm5eQ.js +0 -94
@@ -34,7 +34,7 @@ import { selfLaunchArgv } from "../lib/self-launch-argv";
34
34
  import { loadServiceTokenFromFile, serviceApiTokenFilePath } from "../lib/service-secrets";
35
35
  import { findExecutableOnPath } from "../remote-control/workspace-executable";
36
36
  import { findLiveProxy, type LiveProxy } from "../server/proxy-liveness";
37
- import { codexCredentialDestinationIsTrusted, resolveCodexLaunchHome } from "./codex-launch-auth";
37
+ import { attestCodexRuntime, codexCredentialDestinationIsTrusted, resolveCodexLaunchHome, type CodexRuntimeAttestation } from "./codex-launch-auth";
38
38
  import { codexCommandCanBypass, CODEX_UNVERIFIED_SHIM } from "./codex-launch-command";
39
39
  import { codexTokenArgsAreSafe, codexTokenEnvironmentIsSafe } from "./codex-launch-policy";
40
40
  import { codexTokenWithheldDiagnostic, type CodexTokenRefusal, type CodexTokenRefusalReporter } from "./codex-launch-diagnostics";
@@ -158,7 +158,9 @@ export type CodexLaunchEnvDeps = {
158
158
  args?: readonly string[];
159
159
  /** Test seam; production reads the hardened service token file. */
160
160
  serviceToken?: (base: CodexLaunchEnv) => string | null;
161
- credentialDestination?: (home: string, report?: CodexTokenRefusalReporter) => boolean;
161
+ credentialDestination?: (home: string, report?: CodexTokenRefusalReporter, runtimeAttestation?: CodexRuntimeAttestation | null) => boolean;
162
+ /** Exact origin that proved this home's runtime-record secret. */
163
+ runtimeAttestation?: CodexRuntimeAttestation | null;
162
164
  };
163
165
 
164
166
  /** Read the client admission credential from this installation's service-token file. */
@@ -186,6 +188,7 @@ export function buildCodexLaunchEnv(
186
188
  };
187
189
  if (!codexTokenArgsAreSafe(deps.args ?? [])) return withhold("args");
188
190
  if (!codexTokenEnvironmentIsSafe(env)) return withhold("environment");
191
+ if (!deps.runtimeAttestation) return withhold("destination");
189
192
  // NO_PROXY parsing and precedence vary across native HTTP/WebSocket transports.
190
193
  // Without proving bypass, preserve the user's transport but never load a secret.
191
194
  const home = resolveCodexLaunchHome(env);
@@ -193,8 +196,8 @@ export function buildCodexLaunchEnv(
193
196
  let refusal: CodexTokenRefusal = "destination";
194
197
  const report: CodexTokenRefusalReporter = reason => { refusal = reason; };
195
198
  const trusted = deps.credentialDestination
196
- ? deps.credentialDestination(home, report)
197
- : codexCredentialDestinationIsTrusted(home, undefined, report);
199
+ ? deps.credentialDestination(home, report, deps.runtimeAttestation)
200
+ : codexCredentialDestinationIsTrusted(home, undefined, report, deps.runtimeAttestation);
198
201
  if (!trusted) return withhold(refusal);
199
202
  const token = (deps.serviceToken ?? defaultServiceToken)(env);
200
203
  if (!token) return withhold("credential");
@@ -318,5 +321,9 @@ export async function cmdCodex(args: string[]): Promise<number> {
318
321
  // what the session does next; `ocx doctor` names the autostart failure.
319
322
  console.error(CODEX_SHIM_ENSURE_FAILED_DIAGNOSTIC);
320
323
  }
321
- return spawnCodex(args, buildCodexLaunchEnv(process.env, { routingKind, args }));
324
+ // A public health marker proves liveness, not ownership of the listener. Never read the
325
+ // persisted service token until the exact runtime-record endpoint answers a fresh challenge.
326
+ const runtimeAttestation = plan.kind === "routed" && live !== null
327
+ ? await attestCodexRuntime(live) : null;
328
+ return spawnCodex(args, buildCodexLaunchEnv(process.env, { routingKind, args, runtimeAttestation }));
322
329
  }
@@ -1,5 +1,6 @@
1
1
  import { autoRestoreCodexShim, autoRestoreCodexShimAsync } from "../codex/shim";
2
2
  import { codexShimAutoRestoreEnabled, readConfigDiagnostics } from "../config";
3
+ import { isOrchestratedUpdateArgv } from "../update/orchestrated-arguments.mjs";
3
4
 
4
5
  export interface CodexShimAutoRestoreCliDeps {
5
6
  env: NodeJS.ProcessEnv;
@@ -18,6 +19,10 @@ const DEFAULT_DEPS: CodexShimAutoRestoreCliDeps = {
18
19
  /** Identify command namespaces whose execution must not trigger automatic shim repair. */
19
20
  export function skipsCodexShimAutoRestore(command: string | undefined, args: string[]): boolean {
20
21
  if (command === "uninstall" || command === "remove") return true;
22
+ // Contract discovery and orchestrated update must validate before any repair.
23
+ if (command === "capabilities") return true;
24
+ if (command === "update" && isOrchestratedUpdateArgv(args)) return true;
25
+ if (command === "sync") return true;
21
26
  if (command === "status" || command === "doctor") return true;
22
27
  // The launcher owns shim handoff after classifying routing, including native fast paths.
23
28
  if (command === "codex") return true;
@@ -38,10 +43,6 @@ export function skipsCodexShimAutoRestore(command: string | undefined, args: str
38
43
  // The desktop's approval-bound stop must validate its snapshot before any unrelated
39
44
  // CLI repair changes the installation it was approved against.
40
45
  if (command === "stop" && args.some(arg => arg.startsWith("--expect-"))) return true;
41
- // A pinned sync (#7694) must change nothing when its expected Home or hub key does not hold,
42
- // so the root preflight may not repair the shim first; the sync runner repairs it only after
43
- // the locked identity check passed (runCodexShimAutoRestore in src/cli/dispatch.ts).
44
- if (command === "sync" && args.some(arg => /^--expect-(link|hub-key)(=|$)/.test(arg))) return true;
45
46
  // The entire updater-inspection namespace is zero-effect, including malformed
46
47
  // or future actions. A later `apply` implementation must own its preflight.
47
48
  if (command === "system" && args[1] === "codex-cli-update") return true;
@@ -15,7 +15,6 @@ import { uninstallArgsError, type CliHead } from "./root";
15
15
  import type { ReadyArgs } from "./ready";
16
16
  import type { LivenessIo, LiveProxy } from "../server/proxy-liveness";
17
17
  import type { OcxConfig } from "../types";
18
- import type { OwnedIntegrationRefreshOutcome } from "../integrations/owned-refresh";
19
18
  import { hasHelpFlag, printSubcommandUsage, printUsage } from "./help";
20
19
  import { printUnknownCommand } from "./help-recovery";
21
20
  import {
@@ -30,9 +29,9 @@ import { syncModelsToCodex } from "../codex/sync";
30
29
  import { collectOrcaCodexHomeDiagnostic } from "../codex/home";
31
30
  import { restoreNativeCodexAsync, type CodexNativeRestoreResult } from "../codex/inject";
32
31
  import { stripGrokConfig } from "../grok/inject";
33
- import { handleRestartScopeAfterWrite, readRestartScope, type RestartScope } from "./restart-scope";
32
+ import { handleRestartScopeAfterWrite, readRestartScope } from "./restart-scope";
34
33
  import { normalizeUpdateChannel, runGuiUpdateWorker } from "../update/job";
35
- import { isJsonOption, takeFlag, terminalSafeError, terminalSafeText } from "./runtime-api";
34
+ import { isJsonOption, takeFlag } from "./runtime-api";
36
35
  import { printStopSummary, type StopOutcome } from "./stop-report";
37
36
  import { parseStopApproval, type StopApproval } from "./stop-approval";
38
37
  import type { ResolveArgs } from "./resolve";
@@ -404,171 +403,7 @@ const commandRunners: Record<string, CommandRunner> = {
404
403
  const { handleLogoutCommand } = await import("./logout-command");
405
404
  return handleLogoutCommand(deps.args.slice(1), { findLiveProxy: deps.findLiveProxy });
406
405
  },
407
- sync: async deps => {
408
- const syncArgs = deps.args.slice(1);
409
- // #7694: parse the expected identity before anything else reads or writes state.
410
- const { parseSyncExpectation, reportSyncExpectationMismatch, SYNC_EXPECTATION_USAGE_EXIT } = await import("./sync-expectation");
411
- const parsedExpectation = parseSyncExpectation(syncArgs);
412
- if (!parsedExpectation.ok) {
413
- console.error(parsedExpectation.message);
414
- return SYNC_EXPECTATION_USAGE_EXIT;
415
- }
416
- const expectation = parsedExpectation.expectation;
417
- const restartScope = readRestartScope(syncArgs, console);
418
- // The wire field keeps APP-SERVER-ONLY meaning and is deliberately not widened. A
419
- // remote hub must not end a local user's conversations because a field name acquired
420
- // a wider meaning underneath it; the maintainer decision widened a local CLI flag and
421
- // said nothing about remote callers. syncConnectedClient ignores it either way.
422
- const restartCodex = restartScope.appServers;
423
- const { readClientConnectionState } = await import("../client/state");
424
- const clientState = readClientConnectionState();
425
- // With an expectation the unlocked read decides nothing: the connected sync re-reads under its
426
- // lock and refuses there, so a state that changes in between can never reach the local path.
427
- if (!expectation && (clientState.kind === "invalid" || clientState.kind === "mismatched")) {
428
- console.error(`Client state is ${clientState.kind}: ${clientState.reason}`);
429
- return 1;
430
- }
431
- if (expectation || clientState.kind === "connected") {
432
- try {
433
- const { syncConnectedClient } = await import("../client/connect");
434
- const result = await syncConnectedClient(expectation ? { restartCodex, expect: expectation } : { restartCodex });
435
- if (expectation) {
436
- // The root preflight skipped the shim repair for a pinned sync; the identity held, so
437
- // run it now, as an unpinned sync would have.
438
- const { runCodexShimAutoRestoreAsync } = await import("./codex-shim-autorestore");
439
- await runCodexShimAutoRestoreAsync();
440
- }
441
- // The connection the sync ran under, read inside its lock; the read above may be stale.
442
- const link = result.connection.transport === "link";
443
- console.log(result.stale
444
- ? `${link ? "Home" : "Hub"} unavailable; retained and applied the last-known-good remote catalog (stale).`
445
- : link ? "Remote Link Home catalog synchronized." : "Remote hub catalog synchronized.");
446
- if (result.homeSettings) {
447
- const { describeHomeCodexSettings } = await import("../link/codex-settings");
448
- const settings = result.homeSettings;
449
- if (settings.source === "local") {
450
- console.log(`Codex settings: kept this machine's local values (${terminalSafeText(settings.reason)}).`);
451
- } else {
452
- console.log(settings.source === "home"
453
- ? `Codex settings applied from Home ${terminalSafeText(settings.document.home.name)}:`
454
- : `Codex settings applied from the last recorded Home read (${terminalSafeText(settings.reason)}):`);
455
- for (const line of describeHomeCodexSettings(settings.document.settings)) console.log(` ${terminalSafeText(line)}`);
456
- }
457
- }
458
- await handleConnectedSyncCatalogWrite(result, restartScope);
459
- if (result.applyRecordFailed) {
460
- console.error("The Home's Codex settings were applied, but the apply record could not be written; the client runtime was not restarted. Run 'ocx sync' again.");
461
- process.exitCode = 1;
462
- }
463
- // OCX-6: a link Child's runtime must have started after the apply it serves under.
464
- if (link && result.appliedRecord) {
465
- const { applyRestartMessage, restartRuntimeAfterApply } = await import("./link-apply-restart");
466
- const { sameClientConnectionOwner } = await import("../client/state");
467
- const applied = result.connection;
468
- const outcome = await restartRuntimeAfterApply(result.appliedRecord, {
469
- restart: startWhenStopped => deps.handleProxyRestart(startWhenStopped),
470
- recoveryStart: recovering => deps.handleRestartStartWhenStopped(recovering),
471
- connectionUnchanged: () => {
472
- const current = readClientConnectionState();
473
- return current.kind === "connected" && sameClientConnectionOwner(current.value, applied)
474
- && current.value.link?.linkId === applied.link?.linkId;
475
- },
476
- });
477
- const message = applyRestartMessage(outcome);
478
- if (outcome.kind === "failed" || outcome.kind === "connection-changed") {
479
- console.error(message);
480
- process.exitCode = 1;
481
- } else {
482
- console.log(message);
483
- }
484
- }
485
- // `process.exitCode` rather than a literal 0, for the same reason every other
486
- // runner does it (tests/cli/cli-transport-honesty.test.ts): the catalog-write helper
487
- // drives app-server restarts, and one of those recording a failure must not be
488
- // erased by the value this runner returns. It reads 0 on the ordinary path. Node
489
- // types it as `number | string`; only a numeric code means anything here.
490
- return typeof process.exitCode === "number" ? process.exitCode : 0;
491
- } catch (error) {
492
- const { ClientSyncExpectationError } = await import("../client/sync-expectation");
493
- if (error instanceof ClientSyncExpectationError) return reportSyncExpectationMismatch(error, console);
494
- // The refresh path reaches the same hub catalog `ocx connect` validates, so a rejected
495
- // reasoning level arrives here as hub-supplied text. Rendering it through the shared
496
- // terminal boundary is what keeps the routine refresh from forging output; the domain
497
- // error itself is left alone for callers that inspect it.
498
- console.error(`Connected sync failed without local fallback: ${terminalSafeError(error).message}`);
499
- return 1;
500
- }
501
- }
502
- const live = await deps.findLiveProxy();
503
- const synced = await syncModelsToCodex(
504
- live?.port,
505
- undefined,
506
- undefined,
507
- undefined,
508
- { catalogEvenWhenNotInjected: true },
509
- );
510
- let code = 0;
511
- if (synced.status === "skipped") {
512
- console.log(synced.skippedReason === "hub-gated"
513
- ? `${HUB_GATED_SKIP_MESSAGE} sync skipped and no Codex files changed.`
514
- : "Codex integration is OFF; sync skipped and no Codex files changed.");
515
- } else if (synced.status === "catalog-only") {
516
- // Explicit sync with the integration OFF still refreshes the catalog/cache
517
- // for side profiles that consume the proxy without injection.
518
- console.log(synced.message ?? "Codex integration is OFF; catalog refreshed, Codex config untouched.");
519
- if (!synced.ok) code = 1;
520
- } else if (!synced.ok) {
521
- code = 1;
522
- console.error("Codex sync did not complete. Fix the reported Codex config issue and retry.");
523
- }
524
- // Catalog/model-cache writes retain their warning/restart handling. This is
525
- // deliberately not an `else`: refreshCodexModelCatalog runs before injectCodexConfig,
526
- // so a sync can fail (`ok: false`) after the catalog was already rewritten — which is
527
- // exactly when a long-lived app-server is holding the stale list.
528
- // A configuration-only change also needs a reload, but only when explicitly
529
- // requested. A successful no-op or refused write is never restart authority.
530
- const requestedConfigRestart = (restartScope.appServers || restartScope.desktopApp)
531
- && synced.ok && synced.configChanged === true;
532
- if (synced.catalogWritten || synced.cacheSynced || requestedConfigRestart) {
533
- await handleRestartScopeAfterWrite(restartScope, console);
534
- }
535
- // `ocx sync` is a direct CLI path; it does not call the management
536
- // `/api/sync` route. Refresh already-connected file integrations here too,
537
- // after Codex has published the catalog that supplies its capabilities.
538
- if (synced.status !== "refused") {
539
- const results: OwnedIntegrationRefreshOutcome[] = [];
540
- if (live) {
541
- try {
542
- const config = deps.loadConfig();
543
- const { refreshOwnedCatalogIntegrations } = await import("../integrations/catalog-refresh");
544
- results.push(...await refreshOwnedCatalogIntegrations({
545
- models: async () => {
546
- const { loadExportModels } = await import("../server/management/model-rows");
547
- return loadExportModels(config);
548
- },
549
- config,
550
- port: live.port,
551
- }, ["mcode", "pi", "raycast", "omo", "cline", "commandcode", "droid", "opencode", "kilo", "qoder", "qoder-cn", "workbuddy", "workbuddy-ai", "hermes", "t3code"]));
552
- } catch (error) {
553
- console.warn(`Client integrations were not refreshed: ${error instanceof Error ? error.message : String(error)}`);
554
- }
555
- }
556
- // Even without a live proxy, report why Aside could not sync. Its server
557
- // owner is never bypassed, and another client's failure cannot hide it.
558
- try {
559
- const { refreshAsideProfilesThroughServer } = await import("./aside-profiles");
560
- results.push(...await refreshAsideProfilesThroughServer({ findLiveProxy: async () => live }));
561
- } catch (error) {
562
- console.warn(`Aside profiles were not refreshed: ${error instanceof Error ? error.message : String(error)}`);
563
- }
564
- for (const result of results) {
565
- const label = result.profileId === undefined ? result.client : `${result.client}:${result.profileId}`;
566
- if (result.changed) console.log(`${label} integration refreshed from the current catalog.`);
567
- else if (result.reason) console.warn(`${label} integration was not refreshed: ${result.reason}${result.residual ? " Recovery did not finish." : ""}${result.snapshotPath ? ` Backup: ${result.snapshotPath}` : ""}`);
568
- }
569
- }
570
- return code;
571
- },
406
+ sync: async deps => (await import("./sync-update-guard")).withSyncUpdateGuard(async () => (await import("./sync-command")).runSyncCommand(deps), deps.args),
572
407
  v2: async deps => {
573
408
  const { cmdV2 } = await import("./v2");
574
409
  return await cmdV2(deps.args.slice(1), { runtimeApi: { findLiveProxy: deps.findLiveProxy } }, async () => (await deps.findLiveProxy())?.port);
@@ -775,6 +610,14 @@ const commandRunners: Record<string, CommandRunner> = {
775
610
  return 0;
776
611
  },
777
612
  update: async deps => {
613
+ const { isOrchestratedUpdateArgv, parseOrchestratedChildArgs } = await import("../update/orchestrated-arguments.mjs");
614
+ if (process.env.OCX_UPDATE_ORCHESTRATED_CHILD === "1" && deps.args.slice(1).some(arg => /^--orchestrated-(expect|result)(?:=|$)/.test(arg))) {
615
+ const child = parseOrchestratedChildArgs(deps.args.slice(1), process.env);
616
+ if (!child.ok) return 64;
617
+ await (await import("../update")).runUpdate(child);
618
+ return Number(process.exitCode ?? 0);
619
+ }
620
+ if (isOrchestratedUpdateArgv(deps.args.slice(1))) return (await import("../update/orchestrated-entry")).runOrchestratedUpdate(deps.args.slice(1));
778
621
  // `ocx update --help` must print usage and exit WITHOUT side effects — running the
779
622
  // real self-update stops the proxy and drops in-flight routed streams (issue #168).
780
623
  if (hasHelpFlag(deps.args.slice(1))) {
@@ -1254,14 +1097,6 @@ export async function dispatchCommand(head: CliHead, deps: CliDispatchDeps): Pro
1254
1097
  return await runner(deps);
1255
1098
  }
1256
1099
 
1257
- async function handleConnectedSyncCatalogWrite(
1258
- result: { catalogWritten: boolean; cacheSynced: boolean },
1259
- scope: RestartScope,
1260
- ): Promise<void> {
1261
- if (!result.catalogWritten && !result.cacheSynced) return;
1262
- await handleRestartScopeAfterWrite(scope, console);
1263
- }
1264
-
1265
1100
  async function reconcileClientJournalBeforeLifecycle(
1266
1101
  state: ClientConnectionState,
1267
1102
  ): Promise<void> {
@@ -48,7 +48,7 @@ export interface EnsureDesiredIntegrationsDeps {
48
48
  syncGrokConfig: (
49
49
  port: number,
50
50
  config: OcxConfig,
51
- opts?: { hostname?: string; probeHostname?: string },
51
+ opts?: { hostname?: string; probeHostname?: string; admit?: () => boolean },
52
52
  ) => Promise<GrokInjectResult>;
53
53
  removeDesktop3pStandardPivot: typeof removeDesktop3pStandardPivot;
54
54
  removeDesktopFirstParty?: typeof removeDesktopFirstParty;
@@ -67,7 +67,7 @@ export interface EnsureDesiredIntegrationsDeps {
67
67
  async function defaultSyncGrokConfig(
68
68
  port: number,
69
69
  config: OcxConfig,
70
- opts: { hostname?: string; probeHostname?: string } = {},
70
+ opts: { hostname?: string; probeHostname?: string; admit?: () => boolean } = {},
71
71
  ): Promise<GrokInjectResult> {
72
72
  const { syncGrokConfig } = await import("../grok/sync");
73
73
  return syncGrokConfig(port, config, opts);
@@ -133,7 +133,8 @@ export async function ensureGrokFenceMatchesDesired(
133
133
  port,
134
134
  config,
135
135
  { ...(hostname !== undefined ? { hostname } : {}),
136
- ...(opts.probeHostname !== undefined ? { probeHostname: opts.probeHostname } : {}) },
136
+ ...(opts.probeHostname !== undefined ? { probeHostname: opts.probeHostname } : {}),
137
+ admit: () => shouldSyncGrokOnStart(deps.loadConfig()) },
137
138
  );
138
139
  if (g.changed) log(" + Grok Build config updated (~/.grok/config.toml)");
139
140
  else if (!g.ok) error(`⚠️ ${g.message}`);
package/src/cli/help.ts CHANGED
@@ -49,7 +49,7 @@ Usage:
49
49
  ocx connect <url> Connect this machine to a remote OpenCodex hub (credential via stdin)
50
50
  ocx remote-workspace <sub> Pair/run an OCX-only remote execution computer
51
51
  ocx disconnect Restore local state and clear the hub connection
52
- ocx sync [--restart-codex] Fetch models from providers and inject into Codex config
52
+ ocx sync [--local-only] [--json] [--restart-codex] Sync models and linked Children
53
53
  --expect-link <id> | --expect-hub-key <id>: only from that Home/hub key (exit 5 otherwise)
54
54
  ocx sync-cache [--restart-codex]
55
55
  Refresh Codex's model cache from the active catalog
@@ -72,7 +72,7 @@ Usage:
72
72
  ocx restart Stop and restart the proxy
73
73
  ocx v2 <sub> multi_agent_v2 surface (status|on|off|mode|keep-native-v1|threads|mode-hint)
74
74
  ocx health [--json] Check proxy health (exit 0=healthy, 1=not)
75
- ocx capabilities [--json] List declared capabilities and the API routes they drive
75
+ ocx capabilities [--json] [--contracts] List capabilities and contracts
76
76
  ocx ready [--json] [--wait [--timeout <s>]] Check post-sync readiness (exit 0 only when ready)
77
77
  ocx resolve [--json] Config home, effective port, and liveness (JSON for shells)
78
78
  ocx provider <sub> Providers, connectivity, quota, and selected models
package/src/cli/index.ts CHANGED
@@ -210,6 +210,7 @@ async function refreshOwnedRaycastCatalog(
210
210
  }
211
211
  }
212
212
 
213
+ if (process.argv[2] === "__update-orchestrated-identity") process.exit(await (await import("../update/orchestrated-identity-probe-entry")).runIdentityProbe(process.argv.slice(2)));
213
214
  if (process.argv[2] === "start" && process.env.OCX_SERVICE) startServiceLogging(join(getConfigDir(), "service.log"));
214
215
  const updateRestartChild = admitUpdateRestartChild(process.argv.slice(2));
215
216
  initializeNodeLauncherContext();
@@ -606,6 +607,7 @@ async function handleStart(options: { block?: boolean } = {}) {
606
607
  port: bound.port,
607
608
  hostname: bound.config.hostname,
608
609
  attestationSecret: bound.localAttestationSecret,
610
+ command: currentServingCommand(),
609
611
  ...siblingRuntimeField(),
610
612
  }); updateRestartChild?.complete(); },
611
613
  stopBound: bound => bound.server.stop(true),
@@ -781,7 +783,10 @@ async function handleStart(options: { block?: boolean } = {}) {
781
783
  // one restart, because the toggle removed the fence and start wrote it back.
782
784
  if (shouldSyncGrokOnStart(config)) try {
783
785
  const { syncGrokConfig } = await import("../grok/sync");
784
- const r = await syncGrokConfig(port, config, config.hostname ? { hostname: config.hostname } : {});
786
+ const r = await syncGrokConfig(port, config, {
787
+ ...(config.hostname ? { hostname: config.hostname } : {}),
788
+ admit: () => !shuttingDown && !cleaned && shouldSyncGrokOnStart(loadConfig()),
789
+ });
785
790
  if (r.changed) console.log(" + Grok Build config updated (~/.grok/config.toml)");
786
791
  else if (!r.ok) console.error(`⚠️ ${r.message}`);
787
792
  } catch (err) {
@@ -1134,7 +1139,9 @@ async function handleStopUnlocked(snapshot?: GuardedStopSnapshot) {
1134
1139
  .filter(read => isPendingTeardownAbandoned(read, teardownOwnerStillRunning));
1135
1140
  let teardownNonce: string | undefined;
1136
1141
  // #7423: an update that restarts the proxy asks this stop to leave Codex routing for the replacement.
1137
- const handoverRequested = updateTeardownHandoverRequested(process.env, () => shouldSyncCodexOnStart(loadConfig())) && !stoppingSibling && !connectedClientSkip;
1142
+ // Client start never discharges a standalone update-handover receipt or reapplies routing.
1143
+ const handoverRequested = updateTeardownHandoverRequested(process.env, () => shouldSyncCodexOnStart(loadConfig()))
1144
+ && !stoppingSibling && readClientConnectionState().kind !== "connected";
1138
1145
  let deferralHonoredByProxy = false;
1139
1146
  const claimTeardown = (endpoint: { hostname: string; port: number }, endpointSource: "exact" | "guessed") => {
1140
1147
  if (teardownNonce || stoppingSibling) return;
package/src/cli/link.ts CHANGED
@@ -134,7 +134,7 @@ function validatePeer(value: unknown, index: number): LinkPeerStatus {
134
134
  };
135
135
  }
136
136
 
137
- function validateStatus(value: unknown): LinkStatusPayload {
137
+ export function validateStatus(value: unknown): LinkStatusPayload {
138
138
  if (!isRecord(value)) throw new Error("invalid link API response: status object");
139
139
  assertKeys(value, ["role", "listener", "links", "child"], ["local"], "status");
140
140
  if (value.role !== "standalone" && value.role !== "home" && value.role !== "child") {
@@ -7,11 +7,12 @@ import { terminalSafeText } from "./runtime-api";
7
7
 
8
8
  /** Run one local messaging operation after pure syntax validation, then release owned resources. */
9
9
  export async function runMessageCommand(argv: readonly string[], env: NodeJS.ProcessEnv = process.env): Promise<number> {
10
+ if (argv[0] === "mcp") return (await import("./message-mcp-command")).runMessageMcpCommand(argv.slice(1));
10
11
  const remote = parseRemoteMessageArgs(argv);
11
12
  if (remote) return (await import("./message-remote-command")).runRemoteMessageCommand(remote, env);
12
13
  const args = parseMessageArgs(argv);
13
14
  if (!args) {
14
- console.error("Usage: ocx message sessions [--host <peer>] [--json] | send (--thread <uuid> | --name <exact-name>) --stdin [--host <peer>] [--kind request|response|notification] [--in-reply-to <uuid>] [--json] | enable [--port <port>] | disable | status | hosts <probe|add|list|remove|abandon|allow-inbound|deny-inbound> | serve [--host <peer>]...");
15
+ console.error("Usage: ocx message sessions [--host <peer>] [--json] | send (--thread <uuid> | --name <exact-name>) --stdin [--host <peer>] [--kind request|response|notification] [--in-reply-to <uuid>] [--json] | mcp --codex <absolute-cli-path> --codex-home <absolute-existing-home> | enable [--port <port>] | disable | status | hosts <probe|add|list|remove|abandon|allow-inbound|deny-inbound> | serve [--host <peer>]...");
15
16
  return 64;
16
17
  }
17
18
  const controller = new AbortController();
@@ -0,0 +1,29 @@
1
+ import { isAbsolute } from "node:path";
2
+ import type { QueueMcpOptions } from "../messaging/mcp-queue-rpc";
3
+
4
+ /** Validate all syntax before importing the MCP host or resolving any executable/home. */
5
+ export function parseQueueMcpArgs(argv: readonly string[]): QueueMcpOptions | null {
6
+ if (argv.length !== 4) return null;
7
+ const values: Record<string, string> = {};
8
+ for (let i = 0; i < argv.length; i += 2) {
9
+ const flag = argv[i]!, value = argv[i + 1]!;
10
+ if (!["--codex", "--codex-home"].includes(flag) || values[flag] !== undefined
11
+ || !value || !isAbsolute(value) || /[\x00-\x1f]/.test(value)) return null;
12
+ values[flag] = value;
13
+ }
14
+ return values["--codex"] && values["--codex-home"] ? { codex: values["--codex"], codexHome: values["--codex-home"] } : null;
15
+ }
16
+
17
+ export async function runMessageMcpCommand(argv: readonly string[]): Promise<number> {
18
+ const options = parseQueueMcpArgs(argv);
19
+ if (!options) {
20
+ console.error("Usage: ocx message mcp --codex <absolute-cli-path> --codex-home <absolute-existing-home>");
21
+ return 64;
22
+ }
23
+ if (process.platform === "win32") {
24
+ console.error("Queue MCP currently supports macOS and Linux only.");
25
+ return 1;
26
+ }
27
+ try { await (await import("../messaging/mcp-queue-server")).serveQueueMcp(options); return 0; }
28
+ catch { console.error("Queue MCP could not serve the stdio connection."); return 1; }
29
+ }
@@ -18,7 +18,7 @@ export const CLI_COMMANDS: CliCommandEntry[] = [
18
18
  },
19
19
  {
20
20
  name: "message",
21
- usage: "ocx message <sessions|send|enable|disable|status|hosts|serve> [options]",
21
+ usage: "ocx message <sessions|send|mcp|enable|disable|status|hosts|serve> [options]",
22
22
  summary: "Discover loaded Codex sessions and queue messages locally or through explicit SSH peers.",
23
23
  details: ["Remote listeners/tunnels require explicit foreground serve; no daemon start. queued is submission, not processing; never replay an unknown send."],
24
24
  },
@@ -183,10 +183,13 @@ export const CLI_COMMANDS: CliCommandEntry[] = [
183
183
  },
184
184
  {
185
185
  name: "sync",
186
- usage: "ocx sync [--expect-link <linkId> | --expect-hub-key <apiKeyId>] [--restart-codex] [--restart-app-server-only]",
186
+ usage: "ocx sync [--expect-link <linkId> | --expect-hub-key <apiKeyId>] [--local-only] [--json] [--restart-codex] [--restart-app-server-only]",
187
187
  summary: "Fetch provider models and inject them into Codex config.",
188
188
  details: [
189
+ "A current Home catalog fans out to linked Children; --local-only disables fan-out and --json emits the result. Partial fan-out exits 6.",
190
+ "Fan-out never requests a Codex app or app-server restart on a Child; use GOAT or ocx sync --restart-codex on the Child. The Child's pinned sync may restart its OpenCodex client runtime after applying changed Home settings.",
189
191
  "After writing the catalog, warns if long-lived Codex app-server processes are still running.",
192
+ "An update in flight or an unavailable update/sync mutex refuses without changes: update-in-flight, exit 7. Another sync reports sync-in-progress, exit 1.",
190
193
  "--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.",
191
194
  "--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.",
192
195
  "--restart-desktop-app is a deprecated alias of --restart-codex and prints a notice.",
@@ -290,8 +293,12 @@ export const CLI_COMMANDS: CliCommandEntry[] = [
290
293
  },
291
294
  {
292
295
  name: "update",
293
- usage: "ocx update [--tag latest|preview]",
296
+ usage: "ocx update [--tag latest|preview] | --plan --json [--tag latest|preview | --version <version>] | --yes --json [--tag latest|preview | --version <version>] [--expect-plan <token>] [--not-after <unix-ms>]",
294
297
  summary: "Update opencodex. Preview installs stay on the preview tag unless overridden.",
298
+ details: [
299
+ "--plan --json previews an orchestrated update; --yes --json applies it. --expect-plan binds apply to the returned planToken; --not-after sets a Unix millisecond mutation deadline.",
300
+ "Orchestrated exit codes: 0 verified or up-to-date; 10 refused; 11 failed with previous version verified; 12 unverified or still running; 64 invalid usage.",
301
+ ],
295
302
  },
296
303
  {
297
304
  name: "provider",
@@ -731,10 +738,11 @@ export const CLI_COMMANDS: CliCommandEntry[] = [
731
738
  },
732
739
  {
733
740
  name: "capabilities",
734
- usage: "ocx capabilities [--json] [--mutating-only] [--route <path>]",
741
+ usage: "ocx capabilities [--json] [--contracts] [--mutating-only] [--route <path>]",
735
742
  summary: "List the declared CLI capabilities and the management routes they drive.",
736
743
  details: [
737
744
  "The machine-readable surface index: start here when driving ocx programmatically instead of parsing help text.",
745
+ "--contracts lists supported versioned contracts; it cannot be combined with --route or --mutating-only.",
738
746
  "--route <path> answers the inverse question: which commands drive this management route.",
739
747
  ],
740
748
  },
package/src/cli/root.ts CHANGED
@@ -13,11 +13,13 @@ import { parseReadyArgs, type ReadyArgs } from "./ready";
13
13
  import { parseResolveArgs, type ResolveArgs } from "./resolve";
14
14
  import { parseStopApproval } from "./stop-approval";
15
15
  import { parseSyncExpectation, SYNC_EXPECTATION_USAGE_EXIT } from "./sync-expectation";
16
+ import { parseSyncFanoutFlags } from "./sync-flags";
16
17
  import { maybeAutoRestoreCodexShimAsync } from "./codex-shim-autorestore";
17
18
  import { findCommand } from "./registry";
18
19
  import { printUnknownCommand } from "./help-recovery";
19
20
  import { noteCredentialArgv, redactSecretArgs } from "./secret-args";
20
21
  import { maybeNoticeVersionSkew } from "./version-skew-notice";
22
+ import { isOrchestratedUpdateArgv } from "../update/orchestrated-arguments.mjs";
21
23
 
22
24
  export interface CliHead {
23
25
  kind: "version" | "help" | "ready" | "resolve" | "command";
@@ -40,6 +42,7 @@ export function parseCliHead(argv: string[]): CliHead {
40
42
  const args = argv;
41
43
  // Codex owns its forwarded grammar; wrapper documentation is `ocx help codex`.
42
44
  if (command === "codex") return { kind: "command", command, args };
45
+ if (command === "update" && isOrchestratedUpdateArgv(args.slice(1))) return { kind: "command", command, args };
43
46
  if (command === "--version" || command === "-v" || command === "version") {
44
47
  return { kind: "version", command, args };
45
48
  }
@@ -147,6 +150,11 @@ export async function runCli(argv: string[]): Promise<CliHead> {
147
150
  }
148
151
  // #7694: a malformed pinned sync is refused before any preflight reads or repairs anything.
149
152
  if (head.command === "sync") {
153
+ const flags = parseSyncFanoutFlags(head.args.slice(1));
154
+ if (!flags.ok) {
155
+ console.error(flags.message);
156
+ process.exit(SYNC_EXPECTATION_USAGE_EXIT);
157
+ }
150
158
  const pinned = parseSyncExpectation(head.args.slice(1));
151
159
  if (!pinned.ok) {
152
160
  console.error(pinned.message);