@bitkyc08/opencodex 2.99.0 → 2.100.1

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/AGENTS_INSTALL.md +19 -1
  2. package/README.md +37 -33
  3. package/SPONSORS.md +5 -1
  4. package/bin/ocx.mjs +1 -1
  5. package/gui/dist/assets/{App-C1hGwaN1.css → App-COo8Yopd.css} +1 -1
  6. package/gui/dist/assets/App-g3Cm2xhZ.js +59 -0
  7. package/gui/dist/assets/Tray-BMDkAiXy.js +1 -0
  8. package/gui/dist/assets/brand-mark-nr3ziR-T.js +1 -0
  9. package/gui/dist/assets/index-Bziu8gTy.css +2 -0
  10. package/gui/dist/assets/index-OYzhQUNP.js +94 -0
  11. package/gui/dist/assets/{segment-thumb-features-fYEMxBaW.js → segment-thumb-features-DKCVUUTi.js} +1 -1
  12. package/gui/dist/classic/assets/App-CgPBKUP-.js +58 -0
  13. package/gui/dist/classic/assets/{Tray-BqZueZOx.js → Tray-BedmOsE7.js} +1 -1
  14. package/gui/dist/classic/assets/index-BR-HhNrp.js +94 -0
  15. package/gui/dist/classic/assets/quota-summary-CXKhvSmQ.js +1 -0
  16. package/gui/dist/classic/index.html +1 -1
  17. package/gui/dist/index.html +2 -2
  18. package/native/ocx-child/Cargo.lock +215 -0
  19. package/native/ocx-child/Cargo.toml +31 -0
  20. package/native/ocx-child/src/cli.rs +1901 -0
  21. package/native/ocx-child/src/codex_home.rs +429 -0
  22. package/native/ocx-child/src/codex_settings.rs +231 -0
  23. package/native/ocx-child/src/daemon.rs +363 -0
  24. package/native/ocx-child/src/http_wire.rs +619 -0
  25. package/native/ocx-child/src/journal.rs +977 -0
  26. package/native/ocx-child/src/lib.rs +22 -0
  27. package/native/ocx-child/src/main.rs +9 -0
  28. package/native/ocx-child/src/parity.rs +102 -0
  29. package/native/ocx-child/src/platform.rs +1487 -0
  30. package/native/ocx-child/src/relay.rs +1288 -0
  31. package/native/ocx-child/src/relay_auth.rs +166 -0
  32. package/native/ocx-child/src/routes.rs +236 -0
  33. package/native/ocx-child/src/state.rs +190 -0
  34. package/native/ocx-child/src/test_hooks.rs +58 -0
  35. package/native/ocx-child/src/toml_surgeon.rs +1156 -0
  36. package/package.json +8 -2
  37. package/src/adapters/anthropic-image-normalize.ts +1 -1
  38. package/src/adapters/anthropic.ts +28 -2
  39. package/src/adapters/claude-cli/adapter.ts +5 -25
  40. package/src/adapters/claude-cli/instruction-images.ts +31 -0
  41. package/src/adapters/claude-cli/stable-replay.ts +42 -14
  42. package/src/adapters/claude-cli/usage-admission.ts +53 -64
  43. package/src/adapters/client-fingerprint.ts +1 -1
  44. package/src/adapters/coding-agent/protocol.ts +1 -1
  45. package/src/adapters/devin/live-models.ts +3 -0
  46. package/src/adapters/google-http.ts +3 -0
  47. package/src/adapters/google-vertex-key-project.ts +10 -2
  48. package/src/adapters/google.ts +40 -8
  49. package/src/adapters/kiro/usage.ts +3 -13
  50. package/src/adapters/openai-chat/mistral-image-limit.ts +28 -15
  51. package/src/adapters/openai-chat-images.ts +100 -0
  52. package/src/adapters/openai-chat.ts +6 -9
  53. package/src/adapters/openai-responses/passthrough.ts +5 -2
  54. package/src/adapters/openai-responses/request-strips.ts +32 -0
  55. package/src/adapters/openai-responses/tool-schema.ts +9 -4
  56. package/src/chat/inbound.ts +1 -1
  57. package/src/claude/auth-detect.ts +26 -8
  58. package/src/claude/inbound-content-options.ts +18 -3
  59. package/src/claude/inbound.ts +5 -2
  60. package/src/cli/bundled-bun-diagnostic.ts +91 -0
  61. package/src/cli/capabilities-agents-routing.ts +2 -2
  62. package/src/cli/capabilities-observe-system.ts +60 -0
  63. package/src/cli/combo-input.ts +6 -0
  64. package/src/cli/combo-result.ts +1 -1
  65. package/src/cli/combo.ts +4 -0
  66. package/src/cli/config-command.ts +16 -2
  67. package/src/cli/connect.ts +12 -10
  68. package/src/cli/dispatch.ts +4 -0
  69. package/src/cli/doctor.ts +11 -0
  70. package/src/cli/help.ts +1 -0
  71. package/src/cli/init.ts +4 -0
  72. package/src/cli/link-enrollment.ts +152 -25
  73. package/src/cli/link-local-control.ts +49 -0
  74. package/src/cli/link.ts +37 -10
  75. package/src/cli/provider-lifecycle-runtime.ts +4 -2
  76. package/src/cli/registry.ts +13 -0
  77. package/src/cli/star-prompt.ts +2 -0
  78. package/src/cli/status.ts +1 -1
  79. package/src/cli/telemetry-profile.ts +206 -0
  80. package/src/cli/telemetry.ts +260 -0
  81. package/src/client/hub-relay.ts +26 -0
  82. package/src/client/machine-api.ts +3 -0
  83. package/src/clients/config-export/t3code.ts +44 -5
  84. package/src/clients/omo-role-models.ts +1 -1
  85. package/src/codex/catalog/bundled.ts +44 -2
  86. package/src/codex/runtime.ts +12 -0
  87. package/src/codex/shim-restore-lock.ts +67 -30
  88. package/src/combos/types.ts +21 -1
  89. package/src/config/atomic-write.ts +24 -1
  90. package/src/config/diagnostics.ts +15 -0
  91. package/src/config/live-reconcile.ts +17 -0
  92. package/src/config/load-degrade.ts +16 -0
  93. package/src/config/provider-validation.ts +29 -0
  94. package/src/config/schema/config-schema.ts +24 -0
  95. package/src/config/schema/leaf-validators.ts +17 -0
  96. package/src/config/telemetry-carry.ts +30 -0
  97. package/src/config.ts +13 -1
  98. package/src/generated/compatibility-version.json +422 -170
  99. package/src/generated/model-metadata.ts +3 -3
  100. package/src/integrations/aside-profiles.ts +7 -1
  101. package/src/integrations/owned-refresh.ts +9 -2
  102. package/src/lab/artifacts/secure-fs.ts +12 -11
  103. package/src/lab/fabric/scratch.ts +11 -9
  104. package/src/lab/public/community.ts +2 -3
  105. package/src/lab/public/file-safety.ts +18 -20
  106. package/src/lab/public/mutation-lock.ts +109 -337
  107. package/src/lab/public/private-file.ts +4 -3
  108. package/src/lib/bun-runtime-preflight.ts +1 -1
  109. package/src/lib/codex-catalog-read-only.ts +122 -0
  110. package/src/lib/config-ownership.ts +56 -18
  111. package/src/lib/errors.ts +11 -0
  112. package/src/lib/gcp-adc.ts +167 -48
  113. package/src/lib/jsonc.ts +4 -2
  114. package/src/lib/local-control-socket.ts +88 -0
  115. package/src/lib/privacy.ts +15 -0
  116. package/src/lib/provider-client-headers.ts +3 -0
  117. package/src/lib/token-estimate.ts +13 -2
  118. package/src/link/child-binary-source.ts +228 -0
  119. package/src/link/ephemeral-child.ts +45 -0
  120. package/src/link/remote-plant.ts +306 -0
  121. package/src/link/remote-windows.ts +59 -5
  122. package/src/link/ssh-argv.ts +71 -8
  123. package/src/link/status-projection.ts +2 -0
  124. package/src/link/store.ts +5 -1
  125. package/src/oauth/anthropic-model-quota.ts +12 -0
  126. package/src/oauth/anthropic-routing.ts +11 -4
  127. package/src/oauth/claude-keychain-read.ts +165 -0
  128. package/src/oauth/kiro-iam-identity-center.ts +4 -1
  129. package/src/oauth/local-token-detect.ts +14 -17
  130. package/src/protocols/envelope.ts +20 -2
  131. package/src/providers/api-key-selection.ts +8 -2
  132. package/src/providers/claude-cli-identity.ts +9 -3
  133. package/src/providers/claude-cli-usage-state.ts +93 -0
  134. package/src/providers/claude-cli-usage.ts +3 -2
  135. package/src/providers/github-copilot-auto.ts +25 -5
  136. package/src/providers/meta-muse-plan-refusal.ts +94 -0
  137. package/src/providers/model-rename-fields.ts +3 -0
  138. package/src/providers/quota/anthropic-family-headers.ts +8 -1
  139. package/src/providers/quota/anthropic-usage-windows.ts +49 -2
  140. package/src/providers/quota/vendor-probes-key.ts +23 -4
  141. package/src/providers/quota/vendor-probes-oauth.ts +59 -0
  142. package/src/providers/quota/workbuddy.ts +2 -2
  143. package/src/providers/quota-types.ts +7 -0
  144. package/src/providers/quota.ts +25 -18
  145. package/src/providers/registry/entries-core.ts +7 -4
  146. package/src/providers/registry/entries-extended.ts +42 -8
  147. package/src/providers/registry/model-ids.ts +1 -0
  148. package/src/providers/registry/model-seeds.ts +10 -2
  149. package/src/providers/registry/types.ts +6 -0
  150. package/src/providers/resolved-model-policy.ts +4 -0
  151. package/src/providers/routed-config.ts +30 -3
  152. package/src/providers/stale-no-vision-seed-migration.ts +7 -0
  153. package/src/providers/vertex-environment-authority.ts +50 -0
  154. package/src/providers/workbuddy-credit-balance.ts +38 -6
  155. package/src/quota-pool/assemble.ts +14 -6
  156. package/src/responses/retained-compaction.ts +31 -5
  157. package/src/router.ts +1 -0
  158. package/src/server/adapter-resolve.ts +11 -6
  159. package/src/server/audio-dictation.ts +21 -7
  160. package/src/server/auth-cors.ts +19 -0
  161. package/src/server/background-lifecycle.ts +71 -0
  162. package/src/server/chat-completions.ts +2 -0
  163. package/src/server/claude-messages.ts +30 -3
  164. package/src/server/index/live-sideband.ts +15 -1
  165. package/src/server/index/local-control-listener.ts +515 -0
  166. package/src/server/index/optional-listeners.ts +21 -1
  167. package/src/server/index/serve-options.ts +4 -3
  168. package/src/server/index/websocket-handler.ts +2 -0
  169. package/src/server/index.ts +3 -0
  170. package/src/server/management/combo-routes.ts +6 -1
  171. package/src/server/management/context.ts +1 -0
  172. package/src/server/management/link-child-preflight.ts +74 -0
  173. package/src/server/management/link-enrollment.ts +190 -25
  174. package/src/server/management/link-route-state.ts +6 -1
  175. package/src/server/management/link-routes.ts +27 -9
  176. package/src/server/management/model-rows.ts +4 -0
  177. package/src/server/management/oauth-account-routes.ts +9 -4
  178. package/src/server/management/provider-overwrite-carry.ts +9 -2
  179. package/src/server/management/provider-routes.ts +14 -0
  180. package/src/server/management/provider-thinking-display-patch.ts +54 -0
  181. package/src/server/management/route-registry.ts +7 -0
  182. package/src/server/management/session-routes.ts +4 -1
  183. package/src/server/management/telemetry-routes.ts +37 -0
  184. package/src/server/management/usage-aggregate-cache.ts +290 -67
  185. package/src/server/management-api.ts +11 -2
  186. package/src/server/messages-native-preflight.ts +166 -0
  187. package/src/server/messages-native.ts +143 -43
  188. package/src/server/messages-shared.ts +14 -0
  189. package/src/server/proxy-liveness.ts +99 -6
  190. package/src/server/request-log-conversation.ts +18 -2
  191. package/src/server/request-log.ts +7 -2
  192. package/src/server/responses/adapter-continuation.ts +1 -0
  193. package/src/server/responses/adapter-dispatch.ts +11 -28
  194. package/src/server/responses/adapter-failure-message.ts +68 -0
  195. package/src/server/responses/combo-stream-preflight.ts +14 -2
  196. package/src/server/responses/compact.ts +13 -1
  197. package/src/server/responses/core-auth.ts +26 -5
  198. package/src/server/responses/core-codex-account.ts +8 -1
  199. package/src/server/responses/core-combo-failure.ts +6 -1
  200. package/src/server/responses/core-combo-native.ts +150 -37
  201. package/src/server/responses/core-combo.ts +15 -9
  202. package/src/server/responses/core-normalize.ts +1 -0
  203. package/src/server/responses/core-options.ts +7 -1
  204. package/src/server/responses/core-pipeline.ts +21 -1
  205. package/src/server/responses/fetch-helpers.ts +5 -0
  206. package/src/server/responses/opengateway-completion-guard.ts +7 -3
  207. package/src/server/responses/passthrough-delivery.ts +8 -1
  208. package/src/server/responses/passthrough-error.ts +22 -0
  209. package/src/server/responses/request-prepare.ts +7 -1
  210. package/src/server/responses/request-transport.ts +28 -5
  211. package/src/server/responses/run-turn-execution.ts +13 -0
  212. package/src/server/sse-frame-buffer.ts +5 -0
  213. package/src/server/ws-bridge.ts +10 -0
  214. package/src/service/launchd.ts +78 -4
  215. package/src/telemetry/aggregate.ts +348 -0
  216. package/src/telemetry/consent.ts +128 -0
  217. package/src/telemetry/contract.ts +403 -0
  218. package/src/telemetry/disclosure.ts +19 -0
  219. package/src/telemetry/install-id.ts +226 -0
  220. package/src/telemetry/payload.ts +129 -0
  221. package/src/telemetry/profile/client.ts +150 -0
  222. package/src/telemetry/profile/contract.ts +288 -0
  223. package/src/telemetry/profile/disclosure.ts +14 -0
  224. package/src/telemetry/profile/paths.ts +13 -0
  225. package/src/telemetry/profile/routes.ts +99 -0
  226. package/src/telemetry/profile/service.ts +234 -0
  227. package/src/telemetry/profile/state.ts +189 -0
  228. package/src/telemetry/profile/sync.ts +276 -0
  229. package/src/telemetry/routes.ts +183 -0
  230. package/src/telemetry/scheduler.ts +386 -0
  231. package/src/telemetry/sender.ts +97 -0
  232. package/src/telemetry/state.ts +334 -0
  233. package/src/types/combo-jev-effort-mode.ts +11 -0
  234. package/src/types/config.ts +3 -0
  235. package/src/types/provider.ts +11 -1
  236. package/src/types/request.ts +2 -0
  237. package/src/types/telemetry.ts +15 -0
  238. package/src/types/wire.ts +10 -0
  239. package/src/types.ts +5 -0
  240. package/src/update/index.ts +7 -1
  241. package/src/update/minisign.d.mts +17 -0
  242. package/src/update/minisign.mjs +88 -0
  243. package/src/update/signed-supply.d.mts +59 -0
  244. package/src/update/signed-supply.mjs +289 -0
  245. package/src/update/trust-root.json +38 -0
  246. package/src/update/update-bounded-json.d.mts +4 -0
  247. package/src/update/update-bounded-json.mjs +113 -0
  248. package/src/update/update-bytes.d.mts +2 -0
  249. package/src/update/update-bytes.mjs +23 -0
  250. package/src/update/update-candidate-id.d.mts +2 -0
  251. package/src/update/update-candidate-id.mjs +23 -0
  252. package/src/update/update-checkpoint-codec.d.mts +33 -0
  253. package/src/update/update-checkpoint-codec.mjs +217 -0
  254. package/src/update/update-contracts.d.mts +24 -0
  255. package/src/update/update-contracts.mjs +207 -0
  256. package/src/update/update-signature-threshold.d.mts +12 -0
  257. package/src/update/update-signature-threshold.mjs +47 -0
  258. package/src/update/update-signed-version.d.mts +5 -0
  259. package/src/update/update-signed-version.mjs +25 -0
  260. package/src/update/update-trust-anchor.d.mts +2 -0
  261. package/src/update/update-trust-anchor.mjs +2 -0
  262. package/src/usage/cache-diagnostic.ts +195 -50
  263. package/src/usage/expected-prices.ts +20 -2
  264. package/src/usage/filter-index.ts +1469 -0
  265. package/src/usage/ledger-scanner.ts +245 -4
  266. package/src/usage/source-filter.ts +10 -2
  267. package/src/usage/summary.ts +16 -0
  268. package/src/web-search/parse.ts +265 -38
  269. package/gui/dist/assets/App-BepstgEN.js +0 -59
  270. package/gui/dist/assets/Tray-BinxbEZo.js +0 -1
  271. package/gui/dist/assets/brand-mark-wzPe3R-J.js +0 -1
  272. package/gui/dist/assets/index-C-9X2yaI.js +0 -94
  273. package/gui/dist/assets/index-bnUWypyz.css +0 -2
  274. package/gui/dist/classic/assets/App-DX88_GCW.js +0 -58
  275. package/gui/dist/classic/assets/index-fSP71pLB.js +0 -94
  276. package/gui/dist/classic/assets/quota-summary-y2fl0WBv.js +0 -1
@@ -1,13 +1,19 @@
1
1
  import { createInterface } from "node:readline/promises";
2
+ import { plantUnavailableGuidance } from "../link/child-binary-source";
2
3
  import { assertSshAlias } from "../link/ssh-argv";
3
- import { CliUsageError, RuntimeApiError, runtimeBaseUrl, rejectArgs, takeJsonFlag, takeOption, printData } from "./runtime-api";
4
+ import { CliUsageError, RuntimeApiError, runtimeBaseUrl, rejectArgs, takeFlag, takeJsonFlag, takeOption, printData } from "./runtime-api";
4
5
  import type { LinkCliDeps } from "./link";
5
6
 
6
7
  const FINGERPRINT = /^SHA256:[A-Za-z0-9+/]{16,88}={0,2}$/;
8
+ const SEMVER = /^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.+-]{1,128})?$/;
7
9
  const ENROLLMENT_DEADLINE_MS = 360_000;
8
10
  const PHASES: Record<string, string> = {
9
11
  remote_port_failed: "remote port selection", remote_port_timeout: "remote port selection",
12
+ remote_plant_failed: "remote ocx-child planting", remote_plant_timeout: "remote ocx-child planting",
13
+ remote_plant_unavailable: "local ocx-child binary resolution",
10
14
  child_preflight_failed: "Child preflight", child_preflight_timeout: "Child preflight",
15
+ child_port_busy: "Child port availability preflight",
16
+ child_external_provider_conflict: "Child Codex config ownership check",
11
17
  child_restart_unsupported: "Child restart preflight", child_curl_missing: "Child curl preflight",
12
18
  home_setup_failed: "Home setup", home_setup_timeout: "Home setup",
13
19
  remote_connect_failed: "Child enrollment", remote_connect_timeout: "Child enrollment",
@@ -16,28 +22,110 @@ const PHASES: Record<string, string> = {
16
22
  child_runtime_not_client: "Child runtime role verification",
17
23
  remote_platform_unsupported: "remote platform verification", remote_ocx_missing: "remote OpenCodex discovery",
18
24
  };
19
- const RECOVERY = "Run ocx disconnect and ocx restart on the Child before retrying.";
25
+ const RECOVERY_FULL = "Run ocx disconnect and ocx restart on the Child before retrying.";
26
+ const RECOVERY_EPHEMERAL = "Run ~/.cache/opencodex/bin/ocx-child detach on the Child before retrying.";
20
27
  type LinkRequest = <T>(path: string, init: RequestInit, deps: LinkCliDeps) => Promise<T>;
21
28
 
22
- function record(value: unknown): value is Record<string, unknown> { return value !== null && typeof value === "object" && !Array.isArray(value); }
23
- function offered(value: unknown): { alias: string; fingerprint: string; keyType: string; ocxVersion: string } {
24
- if (!record(value) || Object.keys(value).sort().join(",") !== "alias,fingerprint,keyType,ocxVersion"
25
- || typeof value.alias !== "string" || typeof value.fingerprint !== "string" || !FINGERPRINT.test(value.fingerprint)
26
- || typeof value.keyType !== "string" || !/^[A-Za-z0-9@._+-]{1,64}$/.test(value.keyType)) throw new Error("Invalid host probe response");
27
- if (typeof value.ocxVersion !== "string" || !/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.+-]{1,128})?$/.test(value.ocxVersion)) throw new Error("Invalid host version response");
28
- return { alias: value.alias, fingerprint: value.fingerprint, keyType: value.keyType, ocxVersion: value.ocxVersion };
29
+ interface ParsedProbeOffer {
30
+ alias: string;
31
+ fingerprint: string;
32
+ keyType: string;
33
+ ocxVersion: string | null;
34
+ runtimeKind?: "full" | "ephemeral" | "missing";
35
+ targetTriple?: string | null;
36
+ plantable?: boolean;
37
+ binarySizeBytes?: number;
38
+ plantUnavailableReason?: string;
39
+ legacyExact: boolean;
40
+ }
41
+
42
+ function record(value: unknown): value is Record<string, unknown> {
43
+ return value !== null && typeof value === "object" && !Array.isArray(value);
44
+ }
45
+
46
+ const PROBE_ALLOWED_KEYS = new Set([
47
+ "alias", "fingerprint", "keyType", "ocxVersion",
48
+ "runtimeKind", "targetTriple", "plantable", "binarySizeBytes", "plantUnavailableReason",
49
+ ]);
50
+ const CONFIRM_ALLOWED_KEYS = new Set([
51
+ "alias", "fingerprint", "ocxVersion",
52
+ "runtimeKind", "targetTriple", "plantable", "binarySizeBytes", "plantUnavailableReason",
53
+ ]);
54
+
55
+ function parseOffered(value: unknown, allowMissing: boolean): ParsedProbeOffer {
56
+ if (!record(value)) throw new Error("Invalid host probe response");
57
+ const keys = Object.keys(value);
58
+ if (keys.some(k => !PROBE_ALLOWED_KEYS.has(k))) throw new Error("Invalid host probe response");
59
+ if (typeof value.alias !== "string" || typeof value.fingerprint !== "string" || !FINGERPRINT.test(value.fingerprint)
60
+ || typeof value.keyType !== "string" || !/^[A-Za-z0-9@._+-]{1,64}$/.test(value.keyType)) {
61
+ throw new Error("Invalid host probe response");
62
+ }
63
+ const legacyExact = keys.slice().sort().join(",") === "alias,fingerprint,keyType,ocxVersion";
64
+ if (!allowMissing && !legacyExact) throw new Error("Invalid host probe response");
65
+ if (value.ocxVersion === null) {
66
+ if (!allowMissing || value.runtimeKind !== "missing") throw new Error("Invalid host version response");
67
+ } else if (typeof value.ocxVersion !== "string" || !SEMVER.test(value.ocxVersion)) {
68
+ throw new Error("Invalid host version response");
69
+ }
70
+ if (value.runtimeKind !== undefined && value.runtimeKind !== "full" && value.runtimeKind !== "ephemeral" && value.runtimeKind !== "missing") {
71
+ throw new Error("Invalid host probe response");
72
+ }
73
+ if (value.targetTriple !== undefined && value.targetTriple !== null && (typeof value.targetTriple !== "string" || value.targetTriple.length > 64)) {
74
+ throw new Error("Invalid host probe response");
75
+ }
76
+ if (value.plantable !== undefined && typeof value.plantable !== "boolean") throw new Error("Invalid host probe response");
77
+ if (value.binarySizeBytes !== undefined && (typeof value.binarySizeBytes !== "number" || !Number.isSafeInteger(value.binarySizeBytes) || value.binarySizeBytes <= 0)) {
78
+ throw new Error("Invalid host probe response");
79
+ }
80
+ if (value.plantUnavailableReason !== undefined && typeof value.plantUnavailableReason !== "string") {
81
+ throw new Error("Invalid host probe response");
82
+ }
83
+ return {
84
+ alias: value.alias,
85
+ fingerprint: value.fingerprint,
86
+ keyType: value.keyType,
87
+ ocxVersion: value.ocxVersion,
88
+ ...(value.runtimeKind !== undefined ? { runtimeKind: value.runtimeKind } : {}),
89
+ ...(value.targetTriple !== undefined ? { targetTriple: value.targetTriple } : {}),
90
+ ...(value.plantable !== undefined ? { plantable: value.plantable } : {}),
91
+ ...(value.binarySizeBytes !== undefined ? { binarySizeBytes: value.binarySizeBytes } : {}),
92
+ ...(value.plantUnavailableReason !== undefined ? { plantUnavailableReason: value.plantUnavailableReason } : {}),
93
+ legacyExact,
94
+ };
95
+ }
96
+
97
+ function validateConfirmed(value: unknown, alias: string, fingerprint: string, allowMissing: boolean): void {
98
+ if (!record(value)) throw new Error("Invalid host confirmation response");
99
+ const keys = Object.keys(value);
100
+ if (keys.some(k => !CONFIRM_ALLOWED_KEYS.has(k))) throw new Error("Invalid host confirmation response");
101
+ if (value.alias !== alias || value.fingerprint !== fingerprint) throw new Error("Invalid host confirmation response");
102
+ const legacyExact = keys.slice().sort().join(",") === "alias,fingerprint,ocxVersion";
103
+ if (!allowMissing && !legacyExact) throw new Error("Invalid host confirmation response");
104
+ if (value.ocxVersion === null) {
105
+ if (!allowMissing || value.runtimeKind !== "missing") throw new Error("Invalid host confirmation response");
106
+ } else if (typeof value.ocxVersion !== "string" || !SEMVER.test(value.ocxVersion)) {
107
+ throw new Error("Invalid host confirmation response");
108
+ }
109
+ }
110
+
111
+ function formatSizeMb(bytes?: number): string {
112
+ if (!bytes || !Number.isFinite(bytes) || bytes <= 0) return "~0.9 MB";
113
+ return `~${Math.max(0.1, bytes / (1024 * 1024)).toFixed(1)} MB`;
29
114
  }
30
115
 
31
116
  export async function runLinkEnrollment(command: "probe" | "add", args: string[], deps: LinkCliDeps, request: LinkRequest, usage: string): Promise<void> {
32
117
  const wantsJson = takeJsonFlag(args);
118
+ const plantFlag = takeFlag(args, "--plant");
33
119
  const expected = takeOption(args, "--expect-fingerprint");
34
120
  const alias = args.shift();
35
121
  if (!alias) throw new CliUsageError(command + " requires an SSH alias", usage);
36
122
  try { assertSshAlias(alias); } catch { throw new CliUsageError("Invalid SSH alias", usage); }
37
123
  rejectArgs(args, usage);
38
124
  if (command === "probe" && expected !== undefined) throw new CliUsageError("--expect-fingerprint is only for link add", usage);
125
+ if (command === "probe" && plantFlag) throw new CliUsageError("--plant is only for link add", usage);
39
126
  if (expected !== undefined && !FINGERPRINT.test(expected)) throw new CliUsageError("Expected a SHA256 SSH fingerprint", usage);
40
- if (command === "add" && !expected && !(deps.stdinImpl ?? process.stdin).isTTY) {
127
+ const isTTY = Boolean((deps.stdinImpl ?? process.stdin).isTTY);
128
+ if (command === "add" && !expected && !isTTY) {
41
129
  throw new CliUsageError("Non-interactive link add requires --expect-fingerprint", usage);
42
130
  }
43
131
  const timeout = deps.enrollmentTimeoutMs ?? ENROLLMENT_DEADLINE_MS;
@@ -48,6 +136,7 @@ export async function runLinkEnrollment(command: "probe" | "add", args: string[]
48
136
  timer = setTimeout(() => { controller.abort(); reject(new Error("Link enrollment timed out; its outcome is uncertain. Run ocx link status on the Home and ocx connect status on the Child before retrying.")); }, timeout);
49
137
  });
50
138
  let boundDeps = deps;
139
+ let ephemeralFlow = false;
51
140
  const post = async <T>(path: string, body: unknown): Promise<T> => {
52
141
  controller.signal.throwIfAborted();
53
142
  const result = await request<T>(path, { method: "POST", redirect: "error", signal: controller.signal, headers: { "content-type": "application/json" }, body: JSON.stringify(body) }, boundDeps);
@@ -55,38 +144,75 @@ export async function runLinkEnrollment(command: "probe" | "add", args: string[]
55
144
  return result;
56
145
  };
57
146
  let rl: ReturnType<typeof createInterface> | undefined;
147
+ const askYes = async (promptText: string): Promise<boolean> => {
148
+ rl ??= createInterface({ input: deps.stdinImpl ?? process.stdin, output: process.stderr });
149
+ return (await rl.question(promptText, { signal: controller.signal })).trim() === "yes";
150
+ };
58
151
  const work = async () => {
59
152
  boundDeps = { ...deps, baseUrl: await runtimeBaseUrl(deps) };
60
153
  controller.signal.throwIfAborted();
61
- const probe = offered(await post<unknown>("/api/link/probe", { alias, includeVersion: true }));
154
+ const probeReq = command === "add" ? { alias, includeVersion: true, allowMissing: true } : { alias, includeVersion: true };
155
+ const probe = parseOffered(await post<unknown>("/api/link/probe", probeReq), command === "add");
62
156
  if (probe.alias !== alias) throw new Error("Host probe alias did not match");
63
- if (command === "probe") { printData(probe, wantsJson, [probe.alias + " " + probe.keyType + " " + probe.fingerprint + " opencodex " + probe.ocxVersion]); return; }
157
+ if (command === "probe") {
158
+ const payload = { alias: probe.alias, fingerprint: probe.fingerprint, keyType: probe.keyType, ocxVersion: probe.ocxVersion! };
159
+ printData(payload, wantsJson, [probe.alias + " " + probe.keyType + " " + probe.fingerprint + " opencodex " + probe.ocxVersion]);
160
+ return;
161
+ }
64
162
  if (expected && expected !== probe.fingerprint) throw new CliUsageError("The offered host fingerprint does not match --expect-fingerprint");
65
- if (!expected) {
66
- let approved: boolean;
67
- if (deps.confirmFingerprint) approved = await deps.confirmFingerprint(probe);
68
- else {
69
- rl = createInterface({ input: deps.stdinImpl ?? process.stdin, output: process.stderr });
70
- approved = (await rl.question("Confirm " + alias + " " + probe.keyType + " " + probe.fingerprint + " opencodex " + probe.ocxVersion + " (type yes): ", { signal: controller.signal })).trim() === "yes";
163
+ let shouldPlant = false;
164
+ ephemeralFlow = probe.runtimeKind === "ephemeral" || probe.runtimeKind === "missing";
165
+ if (probe.runtimeKind === "missing") {
166
+ if (probe.plantable !== true) {
167
+ throw new Error("ocx was not found on " + alias + ". " + plantUnavailableGuidance(probe.plantUnavailableReason, probe.targetTriple ?? null));
168
+ }
169
+ if (!isTTY && !plantFlag) {
170
+ throw new CliUsageError("Remote host has no OpenCodex runtime; pass --plant alongside --expect-fingerprint to plant lightweight ocx-child.", usage);
71
171
  }
172
+ const sizeLabel = formatSizeMb(probe.binarySizeBytes);
173
+ if (!expected) {
174
+ const approved = deps.confirmFingerprint
175
+ ? await deps.confirmFingerprint({ alias: probe.alias, fingerprint: probe.fingerprint, keyType: probe.keyType, ocxVersion: null, runtimeKind: "missing", binarySizeBytes: probe.binarySizeBytes })
176
+ : await askYes(`Confirm ${alias} ${probe.keyType} ${probe.fingerprint} — plant lightweight ocx-child (${sizeLabel}) and connect? (type yes): `);
177
+ controller.signal.throwIfAborted();
178
+ if (!approved) throw new CliUsageError("Host fingerprint and ocx-child plant were not confirmed");
179
+ } else if (!plantFlag) {
180
+ const approved = deps.confirmFingerprint
181
+ ? await deps.confirmFingerprint({ alias: probe.alias, fingerprint: probe.fingerprint, keyType: probe.keyType, ocxVersion: null, runtimeKind: "missing", binarySizeBytes: probe.binarySizeBytes })
182
+ : await askYes(`Plant lightweight ocx-child (${sizeLabel}) on ${alias} and connect? (type yes): `);
183
+ controller.signal.throwIfAborted();
184
+ if (!approved) throw new CliUsageError("Planting ocx-child was not confirmed");
185
+ }
186
+ shouldPlant = true;
187
+ } else if (!expected) {
188
+ const approved = deps.confirmFingerprint
189
+ ? await deps.confirmFingerprint({ alias: probe.alias, fingerprint: probe.fingerprint, keyType: probe.keyType, ...(probe.ocxVersion !== null ? { ocxVersion: probe.ocxVersion } : {}) })
190
+ : await askYes("Confirm " + alias + " " + probe.keyType + " " + probe.fingerprint + " opencodex " + probe.ocxVersion + " (type yes): ");
72
191
  controller.signal.throwIfAborted();
73
192
  if (!approved) throw new CliUsageError("Host fingerprint was not confirmed");
74
193
  }
75
- const confirm = await post<unknown>("/api/link/confirm-host", { alias, fingerprint: probe.fingerprint });
76
- if (!record(confirm) || Object.keys(confirm).sort().join(",") !== "alias,fingerprint,ocxVersion" || confirm.alias !== alias || confirm.fingerprint !== probe.fingerprint
77
- || typeof confirm.ocxVersion !== "string" || !/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.+-]{1,128})?$/.test(confirm.ocxVersion)) throw new Error("Invalid host confirmation response");
78
- const result = await post<unknown>("/api/link/apply", { alias, fingerprint: probe.fingerprint });
194
+ const sendAllowMissing = shouldPlant || probe.runtimeKind === "missing";
195
+ const confirm = await post<unknown>("/api/link/confirm-host", { alias, fingerprint: probe.fingerprint, ...(sendAllowMissing ? { allowMissing: true } : {}) });
196
+ validateConfirmed(confirm, alias, probe.fingerprint, sendAllowMissing);
197
+ const result = await post<unknown>("/api/link/apply", { alias, fingerprint: probe.fingerprint, ...(shouldPlant ? { plant: true } : {}) });
79
198
  if (!record(result) || Object.keys(result).join(",") !== "linkId" || typeof result.linkId !== "string" || !/^lnk_[0-9a-f]{16}$/.test(result.linkId)) throw new Error("Invalid link apply response");
80
- printData({ linkId: result.linkId, alias, state: "connected", childRole: "client" }, wantsJson, ["Connected " + alias + " as a Child (" + result.linkId + ")."]);
199
+ printData({ linkId: result.linkId, alias, state: "connected", childRole: "client", ...(shouldPlant ? { planted: true } : {}) }, wantsJson, ["Connected " + alias + " as a Child (" + result.linkId + ")."]);
81
200
  };
82
201
  try { await Promise.race([work(), expiry]); }
83
202
  catch (error) {
84
203
  if (error instanceof RuntimeApiError && record(error.body)) {
85
204
  const code = record(error.body.error) ? error.body.error.code : undefined;
86
205
  if (code === "remote_platform_unsupported" && error.body.residual !== true) throw new Error("The remote shell cannot run this Remote Link workflow. Update OpenCodex on Home and check PowerShell on the Child.");
206
+ if (code === "child_port_busy") throw new Error("The target port on the Child is already in use by another process; no Child files were modified.");
207
+ if (code === "child_preflight_output_limit") throw new Error("The Child's ocx config show --json output exceeded the Remote Link preflight limit; trim the Child's saved configuration and retry.");
208
+ if (code === "child_external_provider_conflict") throw new Error("The Child's ~/.codex/config.toml is already managed by another model provider or custom base URL; no Child files were modified.");
87
209
  const phase = typeof code === "string" && Object.hasOwn(PHASES, code) ? PHASES[code] : undefined;
88
- const message = phase ? "Remote Link failed during " + phase : error.message;
89
- if (phase || error.body.residual === true) throw new Error(message + (error.body.residual === true ? ". " + RECOVERY : ""));
210
+ // The server's hint is the Child's own bounded, redacted reason (#8357); a phase name
211
+ // alone left every failure to SSH reproduction and source reading.
212
+ const hint = record(error.body.error) && typeof error.body.error.hint === "string" ? error.body.error.hint : "";
213
+ const message = phase ? "Remote Link failed during " + phase + (hint ? ": " + hint : "") : error.message;
214
+ const recovery = ephemeralFlow ? RECOVERY_EPHEMERAL : RECOVERY_FULL;
215
+ if (phase || error.body.residual === true) throw new Error(message + (error.body.residual === true ? ". " + recovery : ""));
90
216
  }
91
217
  throw error;
92
218
  } finally {
@@ -95,3 +221,4 @@ export async function runLinkEnrollment(command: "probe" | "add", args: string[]
95
221
  rl?.close();
96
222
  }
97
223
  }
224
+
@@ -0,0 +1,49 @@
1
+ import { usableLocalControlSocket } from "../lib/local-control-socket";
2
+ import type { RuntimeApiDeps } from "./runtime-api";
3
+
4
+ export interface LocalControlDeps {
5
+ /** Test seam: the socket a live runtime on this port exposes, or null. */
6
+ localControlSocket?: (port: number) => string | null;
7
+ }
8
+
9
+ /**
10
+ * Send one `ocx link status` read over the runtime's local control socket when it has one (#8184).
11
+ * A hub whose public listener is not loopback refuses the admin token on its TCP listeners, and the
12
+ * socket is the ingress that may accept it. A runtime without the socket (Windows, a loopback bind,
13
+ * an older version), or one whose socket cannot be reached, is asked over TCP exactly as before.
14
+ */
15
+ export async function viaLocalControlSocket<T, D extends RuntimeApiDeps & LocalControlDeps>(
16
+ baseUrl: string,
17
+ deps: D,
18
+ request: (deps: D) => Promise<T>,
19
+ ): Promise<T> {
20
+ const tcp = { ...deps, baseUrl };
21
+ if (deps.baseUrl) return request(tcp);
22
+ let port: number;
23
+ try { port = Number(new URL(baseUrl).port); } catch { return request(tcp); }
24
+ const socket = (deps.localControlSocket ?? usableLocalControlSocket)(port);
25
+ if (!socket) return request(tcp);
26
+ const fetchImpl = deps.fetchImpl ?? fetch;
27
+ // The marker is set by the transport itself, never inferred from the answer. A runtime that
28
+ // answers 503 with an empty or non-JSON body is still answering, and replacing that answer with
29
+ // the TCP listener's 403 would be a worse report than the one the socket gave.
30
+ let unreachable = false;
31
+ try {
32
+ return await request({
33
+ ...deps,
34
+ baseUrl: "http://localhost",
35
+ fetchImpl: (async (url: string | URL | Request, init?: RequestInit) => {
36
+ try {
37
+ return await fetchImpl(url, { ...init, unix: socket } as RequestInit);
38
+ } catch (error) {
39
+ unreachable = true;
40
+ throw error;
41
+ }
42
+ }) as typeof fetch,
43
+ });
44
+ } catch (error) {
45
+ // Only a transport failure falls back: an answer from the socket is the runtime's answer.
46
+ if (unreachable) return request(tcp);
47
+ throw error;
48
+ }
49
+ }
package/src/cli/link.ts CHANGED
@@ -11,10 +11,13 @@ import type { LinkLocalPeer, LinkPeerStatus } from "../link/compatibility";
11
11
  import { runLinkEnrollment } from "./link-enrollment";
12
12
  import { runLinkCleanup, type LinkCleanupDeps } from "./link-cleanup";
13
13
  import { assertSshAlias } from "../link/ssh-argv";
14
+ import { boundHint } from "../link/ssh-runner";
14
15
  import { linkStorePath } from "../link/paths";
15
16
  import { isLinkPort } from "../link/ports";
16
17
  import { readLinkStore, type LinkDirection, type LinkStore } from "../link/store";
18
+ import type { LinkChildKind } from "../link/store";
17
19
  import { findAvailablePort } from "../server/ports";
20
+ import { viaLocalControlSocket, type LocalControlDeps } from "./link-local-control";
18
21
  import {
19
22
  CliUsageError,
20
23
  RuntimeApiError,
@@ -32,11 +35,11 @@ import {
32
35
 
33
36
  export const LINK_USAGE = `Usage:
34
37
  ocx link probe <alias> [--json]
35
- ocx link add <alias> [--expect-fingerprint SHA256:…] [--json]
38
+ ocx link add <alias> [--plant] [--expect-fingerprint SHA256:…] [--json]
36
39
  ocx link port [--json]
37
40
  ocx link issue --alias <alias> --tunnel-port <port> [--json]
38
41
  ocx link status [--json]
39
- ocx link revoke --link-id <id> [--force --yes] [--json]
42
+ ocx link revoke --link-id <id> [--purge] [--force --yes] [--json]
40
43
  ocx link reconnect --link-id <id> [--json]
41
44
  ocx link cleanup [--link-id <id>] [--json]
42
45
 
@@ -56,14 +59,14 @@ export interface LinkIssuePayload {
56
59
  listenerPort: number;
57
60
  }
58
61
 
59
- export interface LinkCliDeps extends RuntimeApiDeps, Omit<LinkCleanupDeps, "readStore"> {
62
+ export interface LinkCliDeps extends RuntimeApiDeps, LocalControlDeps, Omit<LinkCleanupDeps, "readStore"> {
60
63
  /** Test seam can shorten, never extend, the whole enrollment deadline. */
61
64
  enrollmentTimeoutMs?: number;
62
65
  choosePort?: () => Promise<number>;
63
66
  readConfig?: () => LinkStatusConfig;
64
67
  readClientLinkIdentity?: (linkId: string) => ClientLinkIdentity | null;
65
68
  readChildStatus?: () => LinkStatusDto["child"];
66
- confirmFingerprint?: (host: { alias: string; fingerprint: string; keyType: string }) => Promise<boolean>;
69
+ confirmFingerprint?: (host: { alias: string; fingerprint: string; keyType: string; ocxVersion?: string | null; runtimeKind?: "full" | "ephemeral" | "missing"; binarySizeBytes?: number }) => Promise<boolean>;
67
70
  readStore?: () => LinkStore;
68
71
  readAdminToken?: () => string | null;
69
72
  }
@@ -153,11 +156,12 @@ export function validateStatus(value: unknown): LinkStatusPayload {
153
156
  if (!isRecord(candidate)) throw new Error(`invalid link API response: link ${index}`);
154
157
  // The OCX-6 parity fields are optional on the wire (an older runtime omits them) and always
155
158
  // present in this output, null when absent.
156
- assertKeys(candidate, ["id", "alias", "direction", "state", "since", "reason", "tunnelPort"], [...PARITY_KEYS, "peer", "tunnel"], `link ${index}`);
159
+ assertKeys(candidate, ["id", "alias", "direction", "state", "since", "reason", "tunnelPort"], [...PARITY_KEYS, "peer", "tunnel", "childKind"], `link ${index}`);
157
160
  const parity = validateParity(candidate, index);
158
161
  if (typeof candidate.id !== "string" || !LINK_ID.test(candidate.id)
159
162
  || !validString(candidate.alias) || (candidate.direction !== "hub-initiated" && candidate.direction !== "client-initiated")
160
163
  || (candidate.state !== "connecting" && candidate.state !== "connected" && candidate.state !== "reconnecting" && candidate.state !== "failed" && candidate.state !== "idle")
164
+ || (candidate.childKind !== undefined && candidate.childKind !== "full" && candidate.childKind !== "ephemeral")
161
165
  || !validString(candidate.since) || !validNullableString(candidate.reason) || !isLinkPort(candidate.tunnelPort)) {
162
166
  throw new Error(`invalid link API response: link ${index} fields`);
163
167
  }
@@ -169,6 +173,7 @@ export function validateStatus(value: unknown): LinkStatusPayload {
169
173
  since: candidate.since,
170
174
  reason: candidate.reason,
171
175
  tunnelPort: candidate.tunnelPort,
176
+ ...(candidate.childKind !== undefined ? { childKind: candidate.childKind as LinkChildKind } : {}),
172
177
  ...parity,
173
178
  ...(candidate.peer !== undefined ? { peer: validatePeer(candidate.peer, index) } : {}),
174
179
  ...(candidate.tunnel !== undefined ? { tunnel: validateTunnel(candidate.tunnel, index) } : {}),
@@ -242,17 +247,22 @@ async function linkRequest<T>(path: string, init: RequestInit, deps: LinkCliDeps
242
247
  } catch (error) {
243
248
  if (error instanceof RuntimeApiError) {
244
249
  // Never echo an API error body: issue responses contain a one-time data key. Only the error
245
- // code survives, because callers branch on it and a code is never secret.
250
+ // code, the server's already-bounded hint and the residual flag survive (errorCodeBody).
246
251
  throw new RuntimeApiError(`Link management request failed (${error.status})`, error.status, errorCodeBody(error.body));
247
252
  }
248
253
  throw error;
249
254
  }
250
255
  }
251
256
 
252
- function errorCodeBody(body: unknown): { error: { code: string }; residual?: true } | null {
257
+ function errorCodeBody(body: unknown): { error: { code: string; hint?: string }; residual?: true } | null {
253
258
  if (!isRecord(body) || !isRecord(body.error)) return null;
254
259
  const code = body.error.code;
255
- return typeof code === "string" && /^[a-z_]{1,64}$/.test(code) ? { error: { code }, ...(body.residual === true ? { residual: true as const } : {}) } : null;
260
+ if (typeof code !== "string" || !/^[a-z_]{1,64}$/.test(code)) return null;
261
+ // The hint is the only other field kept (#8357): the server builds it from a Child's last stderr
262
+ // line, already bounded and redacted, and it is bounded and redacted again here. The rest of
263
+ // the body is still never echoed.
264
+ const hint = typeof body.error.hint === "string" ? boundHint(body.error.hint) : undefined;
265
+ return { error: { code, ...(hint ? { hint } : {}) }, ...(body.residual === true ? { residual: true as const } : {}) };
256
266
  }
257
267
 
258
268
  async function runPort(args: string[], deps: LinkCliDeps): Promise<void> {
@@ -297,19 +307,29 @@ async function runStatus(args: string[], deps: LinkCliDeps): Promise<void> {
297
307
  }
298
308
  // A proxy older than the compatibility report or the tunnel diagnostics ignores the query and
299
309
  // answers without those fields.
300
- const result = validateStatus(await linkRequest<unknown>("/api/link/status?compatibility=1&diagnostics=1", {}, { ...deps, baseUrl }));
310
+ const result = validateStatus(await viaLocalControlSocket(baseUrl, deps,
311
+ statusDeps => linkRequest<unknown>("/api/link/status?compatibility=1&diagnostics=1", {}, statusDeps)));
301
312
  console.log(JSON.stringify(result));
302
313
  }
303
314
 
304
315
  async function runRevoke(args: string[], deps: LinkCliDeps): Promise<void> {
305
316
  const wantsJson = takeJsonFlag(args);
317
+ const purge = takeFlag(args, "--purge");
306
318
  const force = takeFlag(args, "--force");
307
319
  const confirmed = takeFlag(args, "--yes");
308
320
  const linkId = takeOption(args, "--link-id");
309
321
  if (!linkId || !LINK_ID.test(linkId)) throw new CliUsageError("revoke requires a valid --link-id", LINK_USAGE);
310
322
  rejectArgs(args, LINK_USAGE);
323
+ if (purge && force) throw new CliUsageError("--purge cannot be combined with --force", LINK_USAGE);
311
324
  if (force && !confirmed) throw new CliUsageError("forced revoke skips remote cleanup; pass --yes to confirm", LINK_USAGE);
312
325
  if (confirmed && !force) throw new CliUsageError("--yes requires --force", LINK_USAGE);
326
+ let wasEphemeral = false;
327
+ if (force) {
328
+ try {
329
+ const store = (deps.readStore ?? (() => readLinkStore(linkStorePath())))();
330
+ wasEphemeral = store.links.find(l => l.id === linkId)?.childKind === "ephemeral";
331
+ } catch { /* fallback to standard recovery message when store is unavailable */ }
332
+ }
313
333
  let remoteCleanup: "skipped" | "unverified" = "skipped";
314
334
  try {
315
335
  const response = await linkRequest<unknown>(`/api/link/${encodeURIComponent(linkId)}`, force ? {
@@ -317,6 +337,11 @@ async function runRevoke(args: string[], deps: LinkCliDeps): Promise<void> {
317
337
  redirect: "error",
318
338
  headers: { "content-type": "application/json" },
319
339
  body: JSON.stringify({ force: true }),
340
+ } : purge ? {
341
+ method: "DELETE",
342
+ redirect: "error",
343
+ headers: { "content-type": "application/json" },
344
+ body: JSON.stringify({ purge: true }),
320
345
  } : { method: "DELETE" }, deps);
321
346
  // Legacy revoke accepts an empty response; a forced receipt needs observed identity.
322
347
  if (force && response === null) throw new Error("invalid link API response: revoke object");
@@ -333,7 +358,9 @@ async function runRevoke(args: string[], deps: LinkCliDeps): Promise<void> {
333
358
  remoteCleanup = "unverified";
334
359
  }
335
360
  if (force) {
336
- const recovery = "Run ocx disconnect on the remote client.";
361
+ const recovery = wasEphemeral
362
+ ? "Run ~/.cache/opencodex/bin/ocx-child detach on the remote client."
363
+ : "Run ocx disconnect on the remote client.";
337
364
  printData({ linkId, remoteCleanup, recovery }, wantsJson, [
338
365
  remoteCleanup === "skipped" ? `Revoked ${linkId}; remote cleanup was skipped.` : `Link ${linkId} is already absent; remote cleanup is unverified.`,
339
366
  recovery,
@@ -108,6 +108,7 @@ function presetSeed(name: string, payload: unknown): Record<string, unknown> | u
108
108
  return seed;
109
109
  }
110
110
 
111
+ /** Live add: an unoffered preset without --adapter/--base-url is a usage error (exit 2) before any write. */
111
112
  async function add(name: string, options: ReturnType<typeof parseAdd>, wantsJson: boolean, deps: RuntimeApiDeps): Promise<number> {
112
113
  const roster = await runtimeRequest<unknown>("/api/providers", { redirect: "error" }, deps);
113
114
  if (!Array.isArray(roster) || roster.some(row => !record(row) || typeof row.name !== "string" || !isValidProviderName(row.name))) {
@@ -119,8 +120,9 @@ async function add(name: string, options: ReturnType<typeof parseAdd>, wantsJson
119
120
  }
120
121
  const presets = await runtimeRequest("/api/provider-presets", { redirect: "error" }, deps);
121
122
  const seed = presetSeed(name, presets);
122
- if (!seed && (name === "openai" || !options.fields.adapter || !options.fields.baseUrl)) {
123
- throw new Error("Target preset unavailable. Custom providers require --adapter and --base-url.");
123
+ if (!seed && name === "openai") invalid("The selected target does not offer the canonical openai preset.");
124
+ if (!seed && (!options.fields.adapter || !options.fields.baseUrl)) {
125
+ invalid(`The selected target does not offer a "${name}" preset. Custom providers require --adapter and --base-url.`);
124
126
  }
125
127
  const provider = { ...seed, ...options.fields };
126
128
  if (provider.googleToolSchemaPolicy !== undefined && provider.adapter !== "google") {
@@ -834,6 +834,19 @@ export const CLI_COMMANDS: CliCommandEntry[] = [
834
834
  usage: "ocx __gui-update-worker <jobId> [channel] [restart]",
835
835
  summary: "Hidden internal: run the GUI update worker.",
836
836
  },
837
+ {
838
+ name: "telemetry",
839
+ usage: "ocx telemetry <status|enable|disable|profile> [--json]",
840
+ summary: "Inspect or change anonymous daily usage telemetry consent and preview the payload.",
841
+ details: [
842
+ "status [--json] Show effective state, reason, install channel, last sent day, and exact preview payload.",
843
+ "enable [--json] Confirm and opt in to anonymous telemetry in an interactive terminal (refused with agent_consent_required or tty_required otherwise).",
844
+ "disable [--json] Opt out of anonymous telemetry and delete telemetry-id.json.",
845
+ "profile [status] [--json] Show the opt-in public leaderboard profile, the next day it would send, and its ranks.",
846
+ "profile connect --handle <h> [--name <n>] [--avatar <colour>] [--json] Create a public profile in an interactive terminal (refused with agent_consent_required or tty_required otherwise).",
847
+ "profile disconnect [--json] Delete the public profile and all its data on the server; always permitted.",
848
+ ],
849
+ },
837
850
  ];
838
851
 
839
852
  export function findCommand(name: string): CliCommandEntry | undefined {
@@ -177,6 +177,8 @@ function printAgentDeferral(): void {
177
177
  */
178
178
  export async function maybeShowStarPrompt(): Promise<void> {
179
179
  try {
180
+ const { maybeShowTelemetryPrompt } = await import("./telemetry");
181
+ await maybeShowTelemetryPrompt();
180
182
  let isTty = false;
181
183
  try {
182
184
  isTty = depsForTests?.isTty ? depsForTests.isTty() : isatty(0) && isatty(1);
package/src/cli/status.ts CHANGED
@@ -912,7 +912,7 @@ export async function collectStatus(options: { mainAccountPolicy?: boolean } = {
912
912
  }
913
913
  })();
914
914
  const clientConnection = collectClientConnectionStatus(Date.now(), undefined, {
915
- selectedCodexCommand: resolvedRuntime.runtime.command,
915
+ selectedCodexRuntime: resolvedRuntime.runtime,
916
916
  });
917
917
  // Asked before the local probes below so a connected client's report is hub-sourced from its
918
918
  // first line. Bounded and failure-tolerant: an offline hub degrades the remoteHub block, it