@bitkyc08/opencodex 2.92.0 → 2.93.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 (258) hide show
  1. package/bin/ocx.mjs +10 -5
  2. package/gui/dist/assets/{App-sUf_8afJ.js → App-CizjBqyk.js} +18 -18
  3. package/gui/dist/assets/{Tray-BSsxznDm.js → Tray-DamiMqcX.js} +1 -1
  4. package/gui/dist/assets/{index-BlFE_VB_.js → index-DQsht3vH.js} +12 -12
  5. package/gui/dist/assets/index-DRe8Hhfz.css +1 -0
  6. package/gui/dist/assets/{quota-summary-BRlbXgw0.js → quota-summary-BXu4zE8H.js} +1 -1
  7. package/gui/dist/index.html +2 -2
  8. package/package.json +5 -5
  9. package/src/adapters/anthropic.ts +28 -5
  10. package/src/adapters/coding-agent/batch-dispatcher.ts +122 -0
  11. package/src/adapters/coding-agent/profile.ts +54 -16
  12. package/src/adapters/coding-agent/turn.ts +30 -2
  13. package/src/adapters/command-code.ts +114 -7
  14. package/src/adapters/cursor/native-exec-fs.ts +11 -9
  15. package/src/adapters/devin/live-models.ts +4 -0
  16. package/src/adapters/google-wire-compiler.ts +1 -2
  17. package/src/adapters/kiro/reasoning.ts +2 -0
  18. package/src/adapters/kiro-refusal.ts +6 -1
  19. package/src/adapters/kiro-wire.ts +1 -1
  20. package/src/adapters/openai-chat/messages.ts +8 -2
  21. package/src/adapters/openai-chat/passthrough.ts +35 -14
  22. package/src/adapters/openai-chat/reasoning-replay.ts +27 -16
  23. package/src/adapters/openai-chat/reasoning-wire.ts +117 -8
  24. package/src/adapters/openai-chat/required-tool-result.ts +64 -0
  25. package/src/adapters/openai-chat.ts +7 -8
  26. package/src/adapters/openai-responses/passthrough.ts +7 -4
  27. package/src/adapters/openai-responses/reasoning.ts +13 -0
  28. package/src/adapters/openai-responses/request-strips.ts +1 -1
  29. package/src/adapters/qoder/adapter.ts +129 -8
  30. package/src/adapters/qoder/scaffold-guard.ts +5 -0
  31. package/src/adapters/reasoning-controls.ts +16 -0
  32. package/src/adapters/tool-call-id.ts +1 -3
  33. package/src/bridge/errors.ts +27 -0
  34. package/src/bridge.ts +1 -1
  35. package/src/chat/inbound.ts +4 -1
  36. package/src/chat/outbound.ts +9 -2
  37. package/src/chat/reasoning-details.ts +28 -5
  38. package/src/claude/desktop-first-party.ts +54 -4
  39. package/src/claude/desktop-picker.ts +11 -8
  40. package/src/claude/first-party-settings.ts +3 -1
  41. package/src/claude/inbound.ts +2 -1
  42. package/src/claude/intercept/local-ca.ts +2 -1
  43. package/src/claude/intercept/picker-ca-cleanup.ts +4 -2
  44. package/src/claude/intercept/picker-ca-startup.ts +3 -1
  45. package/src/claude/intercept/picker-models.ts +6 -3
  46. package/src/claude/intercept/picker-runtime.ts +3 -2
  47. package/src/claude/intercept/runtime.ts +6 -3
  48. package/src/claude/model-info.ts +31 -8
  49. package/src/cli/account-api.ts +11 -0
  50. package/src/cli/capabilities-agents-routing.ts +2 -2
  51. package/src/cli/capabilities-base.ts +7 -1
  52. package/src/cli/capabilities-observe-system.ts +10 -0
  53. package/src/cli/claude-desktop.ts +9 -8
  54. package/src/cli/claude.ts +3 -2
  55. package/src/cli/codex-shim-autorestore.ts +9 -0
  56. package/src/cli/combo-result.ts +7 -0
  57. package/src/cli/combo.ts +18 -0
  58. package/src/cli/cross-home-owner.ts +13 -1
  59. package/src/cli/dispatch.ts +25 -6
  60. package/src/cli/ensure-desired-integrations.ts +8 -6
  61. package/src/cli/export-command.ts +4 -1
  62. package/src/cli/help.ts +2 -1
  63. package/src/cli/index.ts +45 -45
  64. package/src/cli/integration-plan-dto.ts +4 -0
  65. package/src/cli/opencode.ts +20 -9
  66. package/src/cli/registry.ts +6 -4
  67. package/src/cli/root.ts +9 -0
  68. package/src/cli/status.ts +59 -1
  69. package/src/cli/stop-restore.ts +113 -0
  70. package/src/cli/sync-expectation.ts +60 -0
  71. package/src/cli/uninstall-integrations.ts +41 -7
  72. package/src/client/connect.ts +40 -3
  73. package/src/client/link-home.ts +10 -1
  74. package/src/client/machine-api.ts +3 -1
  75. package/src/client/sync-expectation.ts +118 -0
  76. package/src/clients/config-export/agent-clients.ts +96 -0
  77. package/src/clients/config-export/contracts.ts +25 -7
  78. package/src/clients/config-export/qoder.ts +38 -23
  79. package/src/clients/config-export/reasoning-metadata.ts +55 -8
  80. package/src/clients/config-export.ts +12 -0
  81. package/src/clients/lazycodex.ts +7 -2
  82. package/src/clients/reasoning-controls.ts +49 -0
  83. package/src/codex/auth-api/account-identity.ts +14 -0
  84. package/src/codex/auth-api/account-list.ts +29 -2
  85. package/src/codex/auth-api/http.ts +13 -0
  86. package/src/codex/auth-api/main-account-probe.ts +2 -2
  87. package/src/codex/auth-api/pool-mode-gate.ts +16 -3
  88. package/src/codex/auth-api/pool-quota-probe.ts +15 -0
  89. package/src/codex/auth-context.ts +15 -12
  90. package/src/codex/catalog/build-entries.ts +22 -0
  91. package/src/codex/catalog/configured-tiers.ts +70 -0
  92. package/src/codex/catalog/effort.ts +44 -10
  93. package/src/codex/catalog/gather-capture.ts +1 -0
  94. package/src/codex/catalog/heal-observation.ts +155 -13
  95. package/src/codex/catalog/metadata.ts +6 -0
  96. package/src/codex/catalog/model-hints.ts +60 -11
  97. package/src/codex/catalog/model-visibility.ts +3 -2
  98. package/src/codex/catalog/native-models.ts +18 -3
  99. package/src/codex/catalog/parsing.ts +10 -8
  100. package/src/codex/catalog/pinned-models.ts +2 -1
  101. package/src/codex/catalog/provider-models.ts +4 -5
  102. package/src/codex/catalog/retained-sync.ts +2 -1
  103. package/src/codex/catalog/routed-gather.ts +19 -20
  104. package/src/codex/catalog/write-audit.ts +3 -2
  105. package/src/codex/catalog-self-heal.ts +43 -23
  106. package/src/codex/collision-identity.ts +30 -5
  107. package/src/codex/convergence.ts +4 -3
  108. package/src/codex/data/roster-pinned-models.json +177 -1
  109. package/src/codex/desired-state.ts +6 -1
  110. package/src/codex/desktop-compatibility/installed-build.ts +88 -12
  111. package/src/codex/desktop-compatibility/runtime.ts +29 -5
  112. package/src/codex/desktop-compatibility/usage-controller.ts +2 -0
  113. package/src/codex/desktop-compatibility/windows-certificate-trust.ts +46 -12
  114. package/src/codex/inject/config-toml.ts +0 -18
  115. package/src/codex/inject/plan.ts +18 -3
  116. package/src/codex/inject/remove.ts +6 -2
  117. package/src/codex/inject.ts +1 -1
  118. package/src/codex/journal.ts +61 -1
  119. package/src/codex/model-entitlements.ts +1 -1
  120. package/src/codex/native-main-owner.ts +27 -1
  121. package/src/codex/native-profile-store.ts +2 -1
  122. package/src/codex/pool-credit-policy.ts +35 -1
  123. package/src/codex/quota-types.ts +3 -0
  124. package/src/codex/quota.ts +24 -4
  125. package/src/codex/role-auto-assign.ts +6 -2
  126. package/src/codex/subagent-defaults.ts +49 -4
  127. package/src/combos/failover.ts +17 -2
  128. package/src/combos/jev-decision-contract.ts +22 -1
  129. package/src/combos/jev-service-exchange.ts +3 -1
  130. package/src/combos/jev.ts +95 -9
  131. package/src/combos/resolve.ts +45 -1
  132. package/src/combos/types.ts +24 -0
  133. package/src/config/load-degrade.ts +5 -0
  134. package/src/config/paths.ts +19 -3
  135. package/src/config/pending-teardown.ts +22 -1
  136. package/src/config/provider-validation.ts +15 -4
  137. package/src/config/removed-opencode-free.ts +11 -0
  138. package/src/config/schema/leaf-validators.ts +5 -0
  139. package/src/generated/compatibility-version.json +314 -230
  140. package/src/generated/model-metadata.ts +5 -5
  141. package/src/images/loop.ts +16 -2
  142. package/src/integrations/catalog-refresh.ts +1 -1
  143. package/src/integrations/hermes-profiles.ts +251 -0
  144. package/src/integrations/merge.ts +8 -0
  145. package/src/integrations/mutation-plan.ts +19 -4
  146. package/src/integrations/registry.ts +5 -0
  147. package/src/integrations/state.ts +36 -1
  148. package/src/integrations/writer.ts +18 -4
  149. package/src/lib/bun-path-runtime.mjs +2 -1
  150. package/src/lib/errors.ts +62 -0
  151. package/src/lib/eventstream-decoder.ts +81 -37
  152. package/src/lib/opaque-proxy-tunnel.ts +32 -8
  153. package/src/lib/pinned-http.ts +35 -2
  154. package/src/lib/process-control.ts +13 -1
  155. package/src/lib/socks5-fetch.ts +59 -64
  156. package/src/lib/socks5-upload-waiter.ts +50 -0
  157. package/src/lib/sse-decoder.ts +7 -2
  158. package/src/lib/state-store-sweeper.ts +40 -14
  159. package/src/lib/windows-native-principal-worker.ts +14 -0
  160. package/src/lib/windows-native-principal.ts +188 -0
  161. package/src/lib/windows-secret-acl.ts +39 -3
  162. package/src/lib/windows-user-principal.ts +62 -18
  163. package/src/link/ssh-config.ts +35 -3
  164. package/src/providers/account-quota-disk.ts +12 -4
  165. package/src/providers/codebuddy-models.ts +6 -0
  166. package/src/providers/codex-capacity.ts +3 -1
  167. package/src/providers/derive.ts +28 -0
  168. package/src/providers/kiro-models.ts +3 -0
  169. package/src/providers/mimo-thinking.ts +12 -0
  170. package/src/providers/model-rename-fields.ts +1 -0
  171. package/src/providers/model-rename-migration.ts +10 -0
  172. package/src/providers/openai-sidecar-credit.ts +2 -2
  173. package/src/providers/reasoning-capabilities.ts +76 -0
  174. package/src/providers/registry/entries-core.ts +14 -12
  175. package/src/providers/registry/entries-extended.ts +63 -20
  176. package/src/providers/registry/model-ids.ts +2 -0
  177. package/src/providers/registry/model-seeds.ts +93 -28
  178. package/src/providers/registry/types.ts +10 -1
  179. package/src/providers/resolved-model-policy.ts +26 -6
  180. package/src/providers/routed-config.ts +9 -1
  181. package/src/providers/stale-model-roster-migration.ts +44 -7
  182. package/src/remote-control/workspace-pi-runtime.ts +11 -6
  183. package/src/responses/compaction-summary.ts +45 -0
  184. package/src/responses/muse-tool-name-alias.ts +1 -2
  185. package/src/responses/parser.ts +3 -2
  186. package/src/responses/schema.ts +1 -0
  187. package/src/responses/thought-signature-replay.ts +10 -2
  188. package/src/routing/capability.ts +8 -2
  189. package/src/routing/history/ingest.ts +28 -3
  190. package/src/server/auth-cors.ts +3 -2
  191. package/src/server/chat-completions.ts +7 -0
  192. package/src/server/chat-native-eligibility.ts +7 -0
  193. package/src/server/chat-native-reasoning.ts +14 -4
  194. package/src/server/direct-local-http.ts +5 -2
  195. package/src/server/effort-policy.ts +5 -1
  196. package/src/server/index/live-sideband.ts +18 -15
  197. package/src/server/index/serve-options.ts +5 -4
  198. package/src/server/management/agent-settings-routes.ts +27 -15
  199. package/src/server/management/combo-routes.ts +4 -0
  200. package/src/server/management/config-routes.ts +2 -2
  201. package/src/server/management/decision-discovery.ts +12 -2
  202. package/src/server/management/hermes-profile-routes.ts +156 -0
  203. package/src/server/management/integration-routes.ts +85 -24
  204. package/src/server/management/model-routes.ts +2 -2
  205. package/src/server/management/model-row-export-metadata.ts +25 -6
  206. package/src/server/management/model-rows.ts +15 -20
  207. package/src/server/management/native-integration-routes.ts +11 -8
  208. package/src/server/management/route-registry.ts +4 -0
  209. package/src/server/management-api.ts +5 -0
  210. package/src/server/models-capabilities.ts +21 -3
  211. package/src/server/responses/adapter-delivery.ts +11 -1
  212. package/src/server/responses/adapter-dispatch.ts +2 -2
  213. package/src/server/responses/codex-ws-exchange.ts +39 -9
  214. package/src/server/responses/codex-ws-session.ts +38 -4
  215. package/src/server/responses/codex-ws-wire.ts +6 -1
  216. package/src/server/responses/combo-required-tool-contract.ts +103 -0
  217. package/src/server/responses/combo-stream-preflight.ts +8 -1
  218. package/src/server/responses/compact.ts +4 -3
  219. package/src/server/responses/context-overflow.ts +8 -1
  220. package/src/server/responses/core-combo-failure.ts +10 -0
  221. package/src/server/responses/core-combo.ts +23 -15
  222. package/src/server/responses/core-lifetime.ts +3 -0
  223. package/src/server/responses/core-normalize.ts +11 -1
  224. package/src/server/responses/core-options.ts +2 -0
  225. package/src/server/responses/main-hard-lock-routing.ts +60 -44
  226. package/src/server/responses/passthrough-delivery.ts +40 -2
  227. package/src/server/responses/policy-fallback.ts +6 -1
  228. package/src/server/responses/request-compression.ts +12 -7
  229. package/src/server/responses/request-prepare.ts +22 -2
  230. package/src/server/responses/request-sidecar-auth.ts +2 -0
  231. package/src/server/responses/response-effects.ts +22 -10
  232. package/src/server/responses/sidecar-execution.ts +11 -3
  233. package/src/server/stop-teardown.ts +36 -1
  234. package/src/server/ws-bridge.ts +1 -1
  235. package/src/service/desktop-supervision.d.mts +7 -4
  236. package/src/service/desktop-supervision.mjs +90 -13
  237. package/src/service/ownership-mutation-lease.mjs +21 -7
  238. package/src/types/config.ts +8 -2
  239. package/src/types/provider.ts +20 -6
  240. package/src/types/request.ts +10 -0
  241. package/src/types.ts +1 -0
  242. package/src/update/bind-probe.ts +29 -0
  243. package/src/update/job.ts +10 -29
  244. package/src/update/npm-install-job.ps1 +173 -0
  245. package/src/update/npm-install.mjs +70 -0
  246. package/src/update/stop-contract.d.mts +1 -0
  247. package/src/update/stop-contract.mjs +14 -0
  248. package/src/update/stop-decision.d.mts +1 -1
  249. package/src/update/stop-decision.mjs +13 -3
  250. package/src/update/teardown-handover.ts +166 -0
  251. package/src/update/transactional-install.d.mts +14 -3
  252. package/src/update/transactional-install.mjs +33 -7
  253. package/src/usage/expected-prices.ts +64 -31
  254. package/src/usage/timeline.ts +19 -9
  255. package/src/vision/eligibility.ts +15 -5
  256. package/src/vision/plan.ts +2 -2
  257. package/src/web-search/loop.ts +16 -2
  258. package/gui/dist/assets/index-DPeB9HpV.css +0 -1
package/src/bridge.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { adapterFailureFromMessage } from "./lib/errors";
2
2
 
3
- export { formatErrorResponse, formatUsageLimitReachedResponse } from "./bridge/errors";
3
+ export { formatErrorResponse, formatUpstreamFailureResponse, formatUsageLimitReachedResponse } from "./bridge/errors";
4
4
  export { setOwnedBudgetAbandonedMsForTests } from "./bridge/internal";
5
5
  export { buildResponseJSON } from "./bridge/response-json";
6
6
  export { bridgeToResponsesSSE } from "./bridge/sse";
@@ -672,9 +672,12 @@ function applyChatSettings(raw: ChatCompletionsRoutingBody, body: Rec): void {
672
672
 
673
673
  const effort = resolveReasoningEffort(raw);
674
674
  const summary = resolveReasoningSummary(raw);
675
- if (effort || summary !== undefined) {
675
+ const enabled = isRec(raw.reasoning) && typeof raw.reasoning.enabled === "boolean" ? raw.reasoning.enabled
676
+ : isRec(raw.thinking) && ["enabled", "disabled"].includes(String(raw.thinking.type)) ? raw.thinking.type === "enabled" : undefined;
677
+ if (effort || summary !== undefined || enabled !== undefined) {
676
678
  body.reasoning = {
677
679
  ...(effort ? { effort } : {}),
680
+ ...(enabled !== undefined ? { enabled } : {}),
678
681
  summary: summary ?? "auto",
679
682
  };
680
683
  }
@@ -19,6 +19,7 @@ import {
19
19
  CYBER_POLICY_ERROR_CODE,
20
20
  isCyberPolicyCode,
21
21
  isCyberPolicyMessage,
22
+ isTerminalRefusalCode,
22
23
  UNDECLARED_TOOL_CALL_ERROR_CODE,
23
24
  } from "../lib/errors";
24
25
  import { redactSecretString } from "../lib/redact";
@@ -203,6 +204,10 @@ export function chatCompletionsStreamErrorPayload(
203
204
  // The guard's deterministic refusal keeps its wire identity past classifyError's
204
205
  // generic 5xx remap — same code the buffered Chat error and the SSE frame carry.
205
206
  classified.code = UNDECLARED_TOOL_CALL_ERROR_CODE;
207
+ } else if (isTerminalRefusalCode(details?.code)) {
208
+ // A terminal refusal (e.g. `invalid_prompt` for a plan refusal on a later sidecar iteration)
209
+ // is a client error; its code survives so the client sees the refusal, not a server fault.
210
+ classified.code = details!.code!;
206
211
  } else if (details?.code !== undefined && details.code !== null && !classified.code) {
207
212
  classified.code = details.code;
208
213
  }
@@ -230,7 +235,9 @@ export function chatCompletionsFailedResponse(error: Rec): { message: string; de
230
235
  code,
231
236
  ...(code === "translation_buffer_limit"
232
237
  ? { status: 502, type: "upstream_error" }
233
- : { type, ...(code === CYBER_POLICY_ERROR_CODE ? { status: 400 } : {}) }),
238
+ // A terminal refusal code is a 400-class verdict; inferring status from its wording
239
+ // turned a permanent refusal into a retryable 502.
240
+ : { type, ...(isTerminalRefusalCode(code) ? { status: 400 } : {}) }),
234
241
  },
235
242
  };
236
243
  }
@@ -1059,7 +1066,7 @@ export async function collectChatCompletion(
1059
1066
  const code = typeof parsed.error.code === "string" ? parsed.error.code : null;
1060
1067
  const status = code === "translation_buffer_limit"
1061
1068
  ? 502
1062
- : code === CYBER_POLICY_ERROR_CODE || isCyberPolicyMessage(message)
1069
+ : isTerminalRefusalCode(code) || isCyberPolicyMessage(message)
1063
1070
  ? 400
1064
1071
  : streamErrorStatus(message);
1065
1072
  const streamError = new ChatCompletionsStreamError(message, {
@@ -32,6 +32,32 @@ function isRec(value: unknown): value is Rec {
32
32
  /** OpenRouter's `format` for Anthropic thinking entries. */
33
33
  export const ANTHROPIC_REASONING_DETAIL_FORMAT = "anthropic-claude-v1";
34
34
 
35
+ /**
36
+ * One `reasoning.text` detail the inbound replay accepts as Anthropic state: Anthropic's format
37
+ * marker or no format at all, a text the client saw, and a signature with Anthropic's spelling.
38
+ * A client spelling the same signed block without OpenRouter's marker carries the same opaque
39
+ * state, so the native passthrough boundary must see it too.
40
+ */
41
+ function isAnthropicSignedReasoningText(detail: Rec): detail is Rec & { text: string; signature: string } {
42
+ if (detail.type !== "reasoning.text") return false;
43
+ if (detail.format !== undefined && detail.format !== ANTHROPIC_REASONING_DETAIL_FORMAT) return false;
44
+ const signature = typeof detail.signature === "string" ? detail.signature : undefined;
45
+ return typeof detail.text === "string" && isLikelyRealAnthropicThinkingSignature(signature);
46
+ }
47
+
48
+ /**
49
+ * Whether a Chat body contains provider-issued Anthropic state that another provider must not
50
+ * see: a `reasoning_details` entry carrying Anthropic's format marker, or an unmarked signed
51
+ * `reasoning.text` entry the inbound replay would accept.
52
+ */
53
+ export function chatBodyCarriesAnthropicReasoningState(body: Rec): boolean {
54
+ if (!Array.isArray(body.messages)) return false;
55
+ return body.messages.some(message => isRec(message)
56
+ && Array.isArray(message.reasoning_details)
57
+ && message.reasoning_details.some(detail => isRec(detail)
58
+ && (detail.format === ANTHROPIC_REASONING_DETAIL_FORMAT || isAnthropicSignedReasoningText(detail))));
59
+ }
60
+
35
61
  /** One closed reasoning item, as either outbound path sees it. */
36
62
  export interface ReasoningDetailSource {
37
63
  /** The thinking text the client was shown for this item. */
@@ -125,11 +151,8 @@ export function signedReasoningInputItems(details: unknown): Rec[] | undefined {
125
151
  redacted.push(raw.data);
126
152
  continue;
127
153
  }
128
- if (raw.type !== "reasoning.text") return undefined;
129
- if (raw.format !== undefined && raw.format !== ANTHROPIC_REASONING_DETAIL_FORMAT) return undefined;
130
- const signature = typeof raw.signature === "string" ? raw.signature : undefined;
131
- if (typeof raw.text !== "string" || !isLikelyRealAnthropicThinkingSignature(signature)) return undefined;
132
- items.push(reasoningInputItem(raw.text, { sig: signature, ...(redacted.length > 0 ? { red: redacted } : {}) }));
154
+ if (!isAnthropicSignedReasoningText(raw)) return undefined;
155
+ items.push(reasoningInputItem(raw.text, { sig: raw.signature, ...(redacted.length > 0 ? { red: redacted } : {}) }));
133
156
  redacted = [];
134
157
  }
135
158
  if (redacted.length > 0) items.push(reasoningInputItem("", { red: redacted }));
@@ -19,7 +19,8 @@
19
19
  * into Claude Code's settings keeps `first-party` (observeClaudeDesktopMode), so moving the default
20
20
  * to gateway never flips a working Desktop under the operator.
21
21
  */
22
- import { getConfigDir } from "../config/paths";
22
+ import { getConfigDir, withConfigDirHardeningSettled } from "../config/paths";
23
+ import { WindowsSecretAclSettleTimeoutError } from "../lib/windows-secret-acl";
23
24
  import { join } from "node:path";
24
25
  import type { OcxConfig } from "../types";
25
26
  import { claudeConfigDir } from "./auth-detect";
@@ -211,9 +212,35 @@ export function observeClaudeDesktopMode(
211
212
  return observed;
212
213
  }
213
214
 
215
+ const SECRET_FAILURE_CAUSES = ["EACCES", "EPERM", "ENOENT", "EEXIST", "EIO", "EBUSY", "ETIMEDOUT",
216
+ "EICACLS", "EACLIDENTITY", "local_ca_path_unsafe", "client_lifecycle_busy", "client_lifecycle_lock_failed",
217
+ "claude_intercept_proxy_token_invalid", "Error", "TypeError", "RangeError", "unknown"] as const;
218
+ export interface InterceptSecretDiagnostic {
219
+ stage: "ca" | "token";
220
+ cause: typeof SECRET_FAILURE_CAUSES[number];
221
+ }
222
+ function secretFailureCause(error: unknown): InterceptSecretDiagnostic["cause"] {
223
+ const code = error instanceof Error && "code" in error ? error.code : undefined;
224
+ // Allowlist labels, never arbitrary messages, paths, ACL stdout, or error-supplied names.
225
+ for (const allowed of SECRET_FAILURE_CAUSES) if (code === allowed) return allowed;
226
+ for (const allowed of ["TypeError", "RangeError", "Error"] as const)
227
+ if (error instanceof Error && error.name === allowed) return allowed;
228
+ return "unknown";
229
+ }
214
230
  export type DesktopFirstPartyApplyResult =
215
231
  | { ok: true; changed: boolean; path: string; env: ClaudeInterceptEnv; proxyPort: number }
216
- | { ok: false; reason: "intercept_disabled" | "ca_unavailable" | "unreadable" | "foreign_env"; path: string };
232
+ | { ok: false; reason: "intercept_disabled" | "ca_unavailable" | "unreadable" | "foreign_env"; path: string; diagnostic?: InterceptSecretDiagnostic };
233
+
234
+ /** Async apply/reconcile boundaries translate admission timeout into the existing refusal. */
235
+ export async function withFirstPartySecretsSettled<T>(configDir: string, prepare: () => T):
236
+ Promise<T | Extract<DesktopFirstPartyApplyResult, { ok: false }>> {
237
+ try { return await withConfigDirHardeningSettled(configDir, prepare); }
238
+ catch (error) {
239
+ if (!(error instanceof WindowsSecretAclSettleTimeoutError)) throw error;
240
+ return { ok: false, reason: "ca_unavailable", path: claudeInterceptCaCertPath(configDir),
241
+ diagnostic: { stage: "ca", cause: "ETIMEDOUT" } };
242
+ }
243
+ }
217
244
 
218
245
  /**
219
246
  * Write the first-party env into Claude Code's settings. Creates the local CA first so the
@@ -226,11 +253,15 @@ export function applyDesktopFirstParty(
226
253
  const opencodexConfigDir = options.opencodexConfigDir ?? getConfigDir();
227
254
  if (!claudeInterceptEnabled(config)) return { ok: false, reason: "intercept_disabled", path: "" };
228
255
  let target: DesktopFirstPartyTarget;
256
+ let stage: InterceptSecretDiagnostic["stage"] = "ca";
229
257
  try {
230
258
  ensureLocalInterceptCa(opencodexConfigDir);
259
+ stage = "token";
231
260
  target = desktopFirstPartyTarget(config, opencodexConfigDir);
232
- } catch {
233
- return { ok: false, reason: "ca_unavailable", path: claudeInterceptCaCertPath(opencodexConfigDir) };
261
+ } catch (error) {
262
+ const diagnostic = { stage, cause: secretFailureCause(error) };
263
+ console.warn(`[claude-intercept] secret preparation failed: stage=${diagnostic.stage} cause=${diagnostic.cause}`);
264
+ return { ok: false, reason: "ca_unavailable", path: claudeInterceptCaCertPath(opencodexConfigDir), diagnostic };
234
265
  }
235
266
  const written = applyClaudeInterceptSettings(target.env, options.claudeConfigDir);
236
267
  if (!written.ok) return { ok: false, reason: written.reason, path: written.path };
@@ -248,3 +279,22 @@ export function removeDesktopFirstParty(
248
279
  const caCertPath = claudeInterceptCaCertPath(options.opencodexConfigDir ?? getConfigDir());
249
280
  return removeClaudeInterceptSettings(caCertPath, options.claudeConfigDir);
250
281
  }
282
+
283
+ /**
284
+ * Remove Desktop's first-party env once ACL work overlapping the Claude settings home settles.
285
+ * A `CLAUDE_CONFIG_DIR` nested in the opencodex home shares the config-root hardening flight, so
286
+ * the credential-bearing settings rewrite gets the same admission as other intercept secrets.
287
+ * The config is read inside the same synchronous turn. A settle timeout refuses without writing.
288
+ */
289
+ export async function removeDesktopFirstPartySettled(
290
+ readConfig: () => Pick<OcxConfig, "claudeCode" | "runtimeRole">,
291
+ options: DesktopFirstPartyOptions = {},
292
+ remove: typeof removeDesktopFirstParty = removeDesktopFirstParty,
293
+ ): Promise<ReturnType<typeof removeDesktopFirstParty>> {
294
+ const dir = options.claudeConfigDir ?? claudeConfigDir();
295
+ try { return await withConfigDirHardeningSettled(dir, () => remove(readConfig(), options)); }
296
+ catch (error) {
297
+ if (!(error instanceof WindowsSecretAclSettleTimeoutError)) throw error;
298
+ return { ok: false, reason: "unreadable", path: join(dir, "settings.json") };
299
+ }
300
+ }
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import type { OcxConfig } from "../types";
8
8
  import { claudeDesktopIntegrationEnabled } from "../codex/desired-state";
9
- import { getConfigDir } from "../config/paths";
9
+ import { getConfigDir, withConfigDirHardeningSettled } from "../config/paths";
10
10
  import { readFileSync, existsSync } from "node:fs";
11
11
  import { acceptsPickerAuthority, pickerCaCertPath, pickerCaFingerprints, ensurePickerCa, issuePickerLeaf, pickerLeafCertPath, publishedPickerCaSha256 } from "./intercept/picker-ca";
12
12
  import { inspectPickerTrust, trustPickerCa, untrustPickerCa } from "./intercept/picker-trust";
@@ -222,7 +222,7 @@ export function createDesktopPickerController(deps: DesktopPickerControllerDeps)
222
222
  if (first) return refuse(first);
223
223
  if (options.persist) {
224
224
  try {
225
- if (!deps.persistPreference(true)) return refuse("mode_not_committed");
225
+ if (!await withConfigDirHardeningSettled(deps.configDir, () => deps.persistPreference(true))) return refuse("mode_not_committed");
226
226
  } catch { return refuse("mode_not_committed"); }
227
227
  }
228
228
  const second = check(deps.readConfig(), true);
@@ -237,12 +237,12 @@ export function createDesktopPickerController(deps: DesktopPickerControllerDeps)
237
237
  try {
238
238
  const ca = deps.persistentAuthority
239
239
  ? await preparePersistentPickerAuthority({ configDir: deps.configDir, store: deps.persistentAuthority.store, security: deps.security, platform })
240
- : ensurePickerCa(deps.configDir);
240
+ : await withConfigDirHardeningSettled(deps.configDir, () => ensurePickerCa(deps.configDir));
241
241
  // The CLI path gates trust on the same profile check; a published root whose bytes do not
242
242
  // match the profile this process mints must not reach the keychain through the server
243
243
  // path either, even when a live peer published it.
244
244
  if (!acceptsPickerAuthority(ca.certPem)) return refuse("ca_unverified");
245
- issuePickerLeaf(ca, deps.configDir);
245
+ await withConfigDirHardeningSettled(deps.configDir, () => issuePickerLeaf(ca, deps.configDir));
246
246
  caPath = pickerCaCertPath(deps.configDir);
247
247
  caSha1 = pickerCaFingerprints(ca.certPem).sha1;
248
248
  let trust = await inspectPickerTrust(pickerLeafCertPath(deps.configDir), caSha1, deps.security, platform);
@@ -268,7 +268,10 @@ export function createDesktopPickerController(deps: DesktopPickerControllerDeps)
268
268
  const compensationFailed = (trustedByAttempt || options.callerAddedTrust === true) && !(await compensateTrust(true));
269
269
  return withTrustFailure({ ...runtimeStatus(trust), reason: "proxy_unavailable" }, compensationFailed);
270
270
  }
271
- const applied = applyProfile({ ...profileOptions(deps), proxyPort });
271
+ const applied = await withConfigDirHardeningSettled(deps.configDir, () =>
272
+ check(deps.readConfig(), true) || deps.proxyPort() !== proxyPort
273
+ ? { ok: false as const, reason: "write_failed" }
274
+ : applyProfile({ ...profileOptions(deps), proxyPort }));
272
275
  if (!applied.ok) {
273
276
  const compensationFailed = (trustedByAttempt || options.callerAddedTrust === true) && !(await compensateTrust(true));
274
277
  return withTrustFailure({ ...runtimeStatus(trust), reason: "profile_failed", residual: ["profile"] }, compensationFailed);
@@ -288,11 +291,11 @@ export function createDesktopPickerController(deps: DesktopPickerControllerDeps)
288
291
  const residual: string[] = [];
289
292
  try { deps.runtime.disarm(); } catch { residual.push("runtime"); }
290
293
  if (options.persist) {
291
- try { if (!deps.persistPreference(false)) residual.push("preference"); }
294
+ try { if (!await withConfigDirHardeningSettled(deps.configDir, () => deps.persistPreference(false))) residual.push("preference"); }
292
295
  catch { residual.push("preference"); }
293
296
  }
294
297
  try {
295
- const removed = removeProfile(profileOptions(deps));
298
+ const removed = await withConfigDirHardeningSettled(deps.configDir, () => removeProfile(profileOptions(deps)));
296
299
  if (!removed.ok) residual.push("profile");
297
300
  } catch { residual.push("profile"); }
298
301
  // Trust goes only once Desktop no longer selects the picker profile: a selected profile without
@@ -332,7 +335,7 @@ export async function removeDesktopPickerArtifacts(options: { configDir?: string
332
335
  const platform = options.platform ?? process.platform;
333
336
  const residual: string[] = [];
334
337
  try {
335
- const removed = removeDesktopPickerProfile({ configDir, ...(platform ? { platform } : {}) });
338
+ const removed = await withConfigDirHardeningSettled(configDir, () => removeDesktopPickerProfile({ configDir, ...(platform ? { platform } : {}) }));
336
339
  if (!removed.ok) residual.push("profile");
337
340
  } catch { residual.push("profile"); }
338
341
  let released = false;
@@ -9,6 +9,7 @@ import {
9
9
  resolveClaudeDesktopMode,
10
10
  type ClaudeDesktopModeObservation,
11
11
  type DesktopFirstPartyOptions,
12
+ type DesktopFirstPartyApplyResult,
12
13
  } from "./desktop-first-party";
13
14
  import { claudeInterceptCaCertPath } from "./intercept/local-ca";
14
15
  import { invalidateClaudeCodeServedCatalog } from "./intercept/cli-catalog";
@@ -39,8 +40,9 @@ export function firstPartyDesired(
39
40
 
40
41
  export type ClaudeFirstPartyReconcileResult =
41
42
  | { ok: true; action: "applied" | "removed" | "unchanged"; changed: boolean; path: string }
42
- | { ok: false; reason: "intercept_disabled" | "ca_unavailable" | "unreadable" | "foreign_env"; path: string };
43
+ | Extract<DesktopFirstPartyApplyResult, { ok: false }>;
43
44
 
45
+ // Synchronous leaf: async callers wrap reconciliation in withConfigDirHardeningSettled.
44
46
  export function reconcileClaudeFirstPartySettings(
45
47
  config: Pick<OcxConfig, "claudeCode" | "port" | "runtimeRole" | "clientIntegrations">,
46
48
  desired: ClaudeFirstPartyDesired,
@@ -631,9 +631,10 @@ function applyAnthropicSettings(
631
631
  // think by default, omission means thinking is ON, sharing the caller's max_tokens (#545).
632
632
  // `none` is the effort disable sentinel. It is not a valid OpenAI summary
633
633
  // value, so do not attach the similarly named internal catalog sentinel.
634
- body.reasoning = { effort: "none" };
634
+ body.reasoning = { effort: "none", enabled: false };
635
635
  } else if (isRec(thinking) || outputConfigEffort !== undefined) {
636
636
  const reasoning: Rec = { summary: isRec(thinking) && thinking.display === "omitted" ? "none" : "auto" };
637
+ if (isRec(thinking) && thinking.type === "enabled") reasoning.enabled = true;
637
638
  if (outputConfigEffort !== undefined) {
638
639
  // Adaptive wire: /effort arrives as output_config.effort (devlog 080).
639
640
  reasoning.effort = outputConfigEffort;
@@ -1,5 +1,6 @@
1
1
  import { createHash, generateKeyPairSync, createPrivateKey, createPublicKey, sign, X509Certificate, type KeyObject } from "node:crypto";
2
2
  import { join } from "node:path";
3
+ import { withConfigDirHardeningSettled } from "../../config/paths";
3
4
  import { withLocalCaPublication, type LocalCaFiles } from "./local-ca-files";
4
5
 
5
6
  /**
@@ -371,7 +372,7 @@ export function ensureLocalInterceptCa(configDir: string): LocalInterceptCa {
371
372
  * contention, before binding listeners, without blocking the main event loop. */
372
373
  export async function ensureLocalInterceptCaForStartup(configDir: string): Promise<LocalInterceptCa> {
373
374
  for (let attempt = 0; ; attempt += 1) {
374
- try { return ensureLocalInterceptCa(configDir); }
375
+ try { return await withConfigDirHardeningSettled(configDir, () => ensureLocalInterceptCa(configDir)); }
375
376
  catch (error) {
376
377
  if (attempt >= 49 || !(error instanceof Error)
377
378
  || !("code" in error) || error.code !== "client_lifecycle_busy") throw error;
@@ -1,6 +1,7 @@
1
1
  import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
2
2
  import { tmpdir } from "node:os";
3
3
  import { join } from "node:path";
4
+ import { withConfigDirHardeningSettled } from "../../config/paths";
4
5
  import {
5
6
  acknowledgePendingPickerCaUntrust,
6
7
  pendingPickerCaHasLivePublishedOwner,
@@ -16,7 +17,7 @@ export async function drainPendingPickerCaUntrust(
16
17
  ): Promise<boolean> {
17
18
  const pending = readPendingPickerCaUntrust(configDir);
18
19
  if (!pending) return true;
19
- if (pendingPickerCaHasLivePublishedOwner(configDir, pending)) return false;
20
+ if (await withConfigDirHardeningSettled(configDir, () => pendingPickerCaHasLivePublishedOwner(configDir, pending))) return false;
20
21
 
21
22
  const privateDir = mkdtempSync(join(tmpdir(), "ocx-picker-untrust-"));
22
23
  try {
@@ -24,7 +25,8 @@ export async function drainPendingPickerCaUntrust(
24
25
  writeFileSync(publicCopy, pending.certPem, { mode: 0o600 });
25
26
  const result = await untrustPickerCa(publicCopy, pending.sha1, security, platform);
26
27
  if (!result.ok) return false;
27
- return acknowledgePendingPickerCaUntrust(configDir, pending, result);
28
+ // OS untrust yielded: a new parent flight may have started since the owner inspection.
29
+ return await withConfigDirHardeningSettled(configDir, () => acknowledgePendingPickerCaUntrust(configDir, pending, result));
28
30
  } finally {
29
31
  rmSync(privateDir, { recursive: true, force: true });
30
32
  }
@@ -1,4 +1,5 @@
1
1
  import { ensurePickerCa, type PickerCa } from "./picker-ca";
2
+ import { withConfigDirHardeningSettled } from "../../config/paths";
2
3
  import { drainPendingPickerCaUntrust } from "./picker-ca-cleanup";
3
4
  import type { PickerCaStore } from "./picker-ca-store";
4
5
  import type { SecurityRunner } from "./picker-trust";
@@ -11,7 +12,8 @@ export async function preparePersistentPickerAuthority(options: {
11
12
  if (!supportsDesktopPicker(options.platform)) throw new Error("picker_ca_unsupported_platform");
12
13
  const drain = () => drainPendingPickerCaUntrust(options.configDir, options.security, options.platform);
13
14
  if (!await drain()) throw new Error("picker_ca_pending_untrust");
14
- const ca = ensurePickerCa(options.configDir, { rotation: "startup", persistent: true, store: options.store });
15
+ const ca = await withConfigDirHardeningSettled(options.configDir, () =>
16
+ ensurePickerCa(options.configDir, { rotation: "startup", persistent: true, store: options.store }));
15
17
  if (!await drain()) throw new Error("picker_ca_pending_untrust");
16
18
  return ca;
17
19
  }
@@ -4,6 +4,7 @@
4
4
  */
5
5
  import { chmodSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
6
6
  import { dirname } from "node:path";
7
+ import { withConfigDirHardeningSettled } from "../../config/paths";
7
8
  import { nativeOpenAiContextWindow, type NativeContextLimitsInput } from "../../codex/catalog";
8
9
  import type { OcxClaudeDesktopProfile } from "../../types";
9
10
  import { aliasForRoute, claudeCodeNativeAlias } from "../alias";
@@ -137,9 +138,11 @@ export function createPickerModelSnapshot(
137
138
  const models = build(await load());
138
139
  const next = { models, builtAt: Date.now() };
139
140
  if (persistPath) {
140
- mkdirSync(dirname(persistPath), { recursive: true, mode: 0o700 });
141
- writeFileSync(persistPath, JSON.stringify(next), { encoding: "utf8", mode: 0o600 });
142
- chmodSync(persistPath, 0o600);
141
+ await withConfigDirHardeningSettled(dirname(persistPath), () => {
142
+ mkdirSync(dirname(persistPath), { recursive: true, mode: 0o700 });
143
+ writeFileSync(persistPath, JSON.stringify(next), { encoding: "utf8", mode: 0o600 });
144
+ chmodSync(persistPath, 0o600);
145
+ });
143
146
  }
144
147
  snapshot = next;
145
148
  } catch { /* Keep the last good snapshot when discovery or persistence fails. */ }
@@ -15,6 +15,7 @@
15
15
  */
16
16
  import { join } from "node:path";
17
17
  import type { OcxConfig } from "../../types";
18
+ import { withConfigDirHardeningSettled } from "../../config/paths";
18
19
  import type { ClaudeDesktopMode } from "../desktop-first-party";
19
20
  import { supportsDesktopPicker } from "../desktop-picker-platform";
20
21
  import type { TunnelDecision } from "./connect-proxy";
@@ -170,8 +171,8 @@ export function createPickerRuntime(options: CreatePickerRuntimeOptions): Picker
170
171
  if (!ca || !leaf || !caSha1) {
171
172
  ca = options.persistentAuthority
172
173
  ? await preparePersistentPickerAuthority({ configDir: options.configDir, store: options.persistentAuthority.store, security: options.security, platform })
173
- : ensurePickerCa(options.configDir);
174
- leaf = issuePickerLeaf(ca, options.configDir);
174
+ : await withConfigDirHardeningSettled(options.configDir, () => ensurePickerCa(options.configDir));
175
+ leaf = await withConfigDirHardeningSettled(options.configDir, () => issuePickerLeaf(ca!, options.configDir));
175
176
  caSha1 = pickerCaFingerprints(ca.certPem).sha1;
176
177
  }
177
178
  return { ca, leaf, sha1: caSha1 };
@@ -1,7 +1,8 @@
1
1
  import type { Server } from "bun";
2
2
  import { supportsDesktopPicker } from "../desktop-picker-platform";
3
3
  import type { OcxConfig } from "../../types";
4
- import { getConfigDir } from "../../config/paths";
4
+ import { getConfigDir, withConfigDirHardeningSettled } from "../../config/paths";
5
+ import { claudeConfigDir } from "../auth-detect";
5
6
  import type { DesktopPickerController } from "../desktop-picker";
6
7
  import type { ClaudeFirstPartyDesired } from "../first-party-settings";
7
8
  import { classifyInterceptClient, interceptRouteFor } from "./client-class";
@@ -149,7 +150,7 @@ export async function startClaudeIntercept<T>(options: StartClaudeInterceptOptio
149
150
  const configDir = options.configDir ?? getConfigDir();
150
151
  const ca = await ensureLocalInterceptCaForStartup(configDir);
151
152
  const startProxy = options.startProxy ?? startConnectProxy;
152
- const authToken = ensureClaudeInterceptProxyToken(configDir);
153
+ const authToken = await withConfigDirHardeningSettled(configDir, () => ensureClaudeInterceptProxyToken(configDir));
153
154
  const leaf = issueLocalInterceptLeaf(ca, CLAUDE_INTERCEPT_HOSTS);
154
155
  const listener = startClaudeInterceptListener<T>({
155
156
  leaf,
@@ -179,7 +180,9 @@ export async function startClaudeIntercept<T>(options: StartClaudeInterceptOptio
179
180
  // fixed-port bind leaves settings untouched; an ephemeral test binder never publishes :0
180
181
  // or a probed port another process can steal. Only stale, owned env blocks are rewritten.
181
182
  try {
182
- migrateClaudeInterceptSettings(buildClaudeInterceptEnv(proxy.port, claudeInterceptCaCertPath(configDir), authToken));
183
+ // Fresh admission after the bind await: a nested CLAUDE_CONFIG_DIR shares the config-root flight.
184
+ await withConfigDirHardeningSettled(claudeConfigDir(), () =>
185
+ migrateClaudeInterceptSettings(buildClaudeInterceptEnv(proxy.port, claudeInterceptCaCertPath(configDir), authToken)));
183
186
  } catch (error) {
184
187
  // Ensure/apply retries a skipped migration; upgraded clients otherwise keep hitting 407.
185
188
  console.warn(`[claude-intercept] settings migration skipped: ${error instanceof Error ? error.message : String(error)}`);
@@ -45,8 +45,23 @@ function effortCapability(ladder: readonly string[]) {
45
45
  };
46
46
  }
47
47
 
48
- function modelCapabilities(ladder: readonly string[], imageInput: boolean) {
49
- const reasons = ladder.length > 0;
48
+ function modelCapabilities(
49
+ ladder: readonly string[],
50
+ imageInput: boolean,
51
+ thinkingCapabilities?: Pick<CatalogModel, "supportsReasoning" | "supportsThinkingToggle" | "supportsReasoningEffort">,
52
+ ) {
53
+ const reasoningSupported = thinkingCapabilities?.supportsReasoning !== false;
54
+ const discoveredEffort = effortCapability(ladder);
55
+ const effort = reasoningSupported && thinkingCapabilities?.supportsReasoningEffort !== false
56
+ ? discoveredEffort
57
+ : effortCapability([]);
58
+ // Keep the old ladder projection only while the relevant axis is unknown. An explicit
59
+ // toggle proves `enabled`; a usable effort rung proves `adaptive`; neither implies the other.
60
+ // This lets clients select MiMo's enabled-only switch without inventing effort.
61
+ const adaptive = effort.supported;
62
+ const enabled = reasoningSupported && (thinkingCapabilities?.supportsThinkingToggle === true
63
+ || (thinkingCapabilities?.supportsThinkingToggle === undefined && effort.supported));
64
+ const thinkingSupported = thinkingCapabilities?.supportsReasoning ?? (adaptive || enabled);
50
65
  return {
51
66
  batch: cap(false),
52
67
  citations: cap(false),
@@ -57,12 +72,12 @@ function modelCapabilities(ladder: readonly string[], imageInput: boolean) {
57
72
  clear_tool_uses_20250919: null,
58
73
  compact_20260112: null,
59
74
  },
60
- effort: effortCapability(ladder),
75
+ effort,
61
76
  image_input: cap(imageInput),
62
77
  pdf_input: cap(false),
63
78
  structured_outputs: cap(false),
64
- thinking: reasons
65
- ? { supported: true, types: { adaptive: cap(true), enabled: cap(true) } }
79
+ thinking: thinkingSupported
80
+ ? { supported: true, types: { adaptive: cap(adaptive), enabled: cap(enabled) } }
66
81
  : { supported: false, types: { adaptive: cap(false), enabled: cap(false) } },
67
82
  };
68
83
  }
@@ -88,13 +103,21 @@ export interface AnthropicModelInfo {
88
103
  description?: string;
89
104
  }
90
105
 
91
- function modelInfo(id: string, displayName: string, ladder: readonly string[], imageInput: boolean, contextWindow?: number, description?: string): AnthropicModelInfo {
106
+ function modelInfo(
107
+ id: string,
108
+ displayName: string,
109
+ ladder: readonly string[],
110
+ imageInput: boolean,
111
+ contextWindow?: number,
112
+ description?: string,
113
+ thinkingCapabilities?: Pick<CatalogModel, "supportsReasoning" | "supportsThinkingToggle" | "supportsReasoningEffort">,
114
+ ): AnthropicModelInfo {
92
115
  return {
93
116
  id,
94
117
  display_name: displayName,
95
118
  type: "model",
96
119
  created_at: MODEL_INFO_CREATED_AT,
97
- capabilities: modelCapabilities(ladder, imageInput),
120
+ capabilities: modelCapabilities(ladder, imageInput, thinkingCapabilities),
98
121
  max_input_tokens: typeof contextWindow === "number" && contextWindow > 0 ? contextWindow : null,
99
122
  max_tokens: null,
100
123
  ...(description === undefined ? {} : { description }),
@@ -242,7 +265,7 @@ export function buildAnthropicModelInfos(
242
265
  : m.maxInputTokens)
243
266
  : undefined;
244
267
  const description = idStyle === "readable" ? `Routed by OpenCodex to ${m.provider}/${listedModelId}` : undefined;
245
- const info = modelInfo(id, `${listedModelId} (${m.provider})`, ladder, imageInput, routedMaxInput ?? m.contextWindow, description);
268
+ const info = modelInfo(id, `${listedModelId} (${m.provider})`, ladder, imageInput, routedMaxInput ?? m.contextWindow, description, m);
246
269
  out.push(info);
247
270
  // Anthropic passthrough guard (audit 021 #3): never auto-widen canonical claude
248
271
  // routes — only a genuine >=1M window earns the variant row there.
@@ -23,6 +23,9 @@ export interface AccountRow {
23
23
  provider: string;
24
24
  type: AccountType;
25
25
  id: string;
26
+ slotId?: string;
27
+ slotKind?: "native-main" | "pool";
28
+ upstreamAccountKey?: string;
26
29
  label?: string;
27
30
  email?: string;
28
31
  /**
@@ -329,6 +332,9 @@ export interface ProviderQuotaReportDto {
329
332
 
330
333
  interface CodexAccountDto {
331
334
  id: string;
335
+ slotId?: string;
336
+ slotKind?: "native-main" | "pool";
337
+ upstreamAccountKey?: string;
332
338
  alias?: string;
333
339
  email?: string;
334
340
  plan?: string;
@@ -401,6 +407,11 @@ export async function fetchCodexRows(
401
407
  provider: "openai",
402
408
  type: "codex" as const,
403
409
  id: a.id,
410
+ slotId: a.id,
411
+ slotKind: a.id === "__main__" ? "native-main" as const : "pool" as const,
412
+ ...(a.slotId === a.id && typeof a.upstreamAccountKey === "string"
413
+ && /^uai1_[0-9a-f]{64}$/.test(a.upstreamAccountKey)
414
+ ? { upstreamAccountKey: a.upstreamAccountKey } : {}),
404
415
  label: a.alias ?? a.plan ?? a.email,
405
416
  email: a.email,
406
417
  plan: a.plan,
@@ -385,10 +385,10 @@ export const AGENT_ROUTING_CAPABILITIES: readonly Capability[] = [
385
385
  },
386
386
  {
387
387
  command: ["combo","set"],
388
- usage: "ocx combo set <id> [--targets <provider/model[:weight],...> | --targets-file <FILE|->] [--strategy <failover|round-robin|random|least-used|reset-window|jev>] [--sticky <1-100|->] [--effort <low|medium|high|xhigh|max|ultra|->] [--effort-mode <fallback|force|->] [--alias <name|->] [--native-alias [on|off]] [--allow-metered-targets <on|off>] [--display-name <label|->] [--description <text|->] [--decision-provider <provider|-> | --decision-model <route|->] [--decision-timeout <ms|->] [--decision-quota-signals <on|off|->] [--decision-quota-tiers <JSON|->] [--session-pin <duration|->] [--rename-from <id>] [--image-input <auto|disabled>] [--reasoning-effort-mode <strict|adaptive>] [--json]",
388
+ usage: "ocx combo set <id> [--targets <provider/model[:weight],...> | --targets-file <FILE|->] [--strategy <failover|round-robin|random|least-used|reset-window|jev>] [--sticky <1-100|->] [--cooldown-reprobe <on|off>] [--cooldown-reprobe-interval <ms>] [--effort <low|medium|high|xhigh|max|ultra|->] [--effort-mode <fallback|force|->] [--alias <name|->] [--native-alias [on|off]] [--allow-metered-targets <on|off>] [--display-name <label|->] [--description <text|->] [--decision-provider <provider|-> | --decision-model <route|->] [--decision-timeout <ms|->] [--decision-quota-signals <on|off|->] [--decision-quota-tiers <JSON|->] [--session-pin <duration|->] [--rename-from <id>] [--image-input <auto|disabled>] [--reasoning-effort-mode <strict|adaptive>] [--json]",
389
389
  summary: "Create, update or rename a combo.",
390
390
  routes: [{"method":"GET","path":"/api/combos"},{"method":"PUT","path":"/api/combos"}],
391
- flags: [{"name":"--allow-metered-targets","value":"string","summary":"on grants operator consent to metered targets only on a loopback-only proxy; off clears it."},{"name":"--targets","value":"string","summary":"Ordered provider/model[:weight] list; required for creation."},{"name":"--strategy","value":"string","summary":"Routing strategy."},{"name":"--sticky","value":"string","summary":"Round-robin limit 1-100; - resets."},{"name":"--effort","value":"string","summary":"Default effort; - clears."},{"name":"--effort-mode","value":"string","summary":"fallback or force; - resets to fallback."},{"name":"--alias","value":"string","summary":"Alias; - clears."},{"name":"--display-name","value":"string","summary":"Label; - clears."},{"name":"--description","value":"string","summary":"Catalog row description; - clears."},{"name":"--decision-provider","value":"string","summary":"JEV provider; - clears."},{"name":"--decision-model","value":"string","summary":"JEV route; - clears; exclusive with provider."},{"name":"--decision-timeout","value":"string","summary":"JEV deadline 1000-120000 ms; - clears."},{"name":"--decision-quota-signals","value":"string","summary":"JEV advisory quota on/off; - clears."},{"name":"--decision-quota-tiers","value":"string","summary":"Partial JSON thresholds; - clears."},{"name":"--session-pin","value":"string","summary":"JEV session pin idle window 1m-24h (90s, 20m, 1h); - clears."},{"name":"--rename-from","value":"string","summary":"Existing combo ID to rename."},{"name":"--json","value":"boolean","summary":"Emit structured JSON."},{"name":"--native-alias","value":"string","summary":"Bare legacy flag means on; explicit on/off preserves presence, including false."},{"name":"--targets-file","value":"string","summary":"Bounded ordered target JSON array, exclusive with --targets; preserves effort/profile/last-resort metadata."},{"name":"--image-input","value":"string","summary":"auto or disabled; explicit auto clears the previous disabled choice."},{"name":"--reasoning-effort-mode","value":"string","summary":"strict or adaptive, distinct from --effort-mode fallback/force."}],
391
+ flags: [{"name":"--allow-metered-targets","value":"string","summary":"on grants operator consent to metered targets only on a loopback-only proxy; off clears it."},{"name":"--targets","value":"string","summary":"Ordered provider/model[:weight] list; required for creation."},{"name":"--strategy","value":"string","summary":"Routing strategy."},{"name":"--sticky","value":"string","summary":"Round-robin limit 1-100; - resets."},{"name":"--cooldown-reprobe","value":"string","summary":"Opt into one recovery pass when all eligible targets cool; off by default."},{"name":"--cooldown-reprobe-interval","value":"string","summary":"Minimum interval between recovery passes in ms (1000..86400000); default 300000."},{"name":"--effort","value":"string","summary":"Default effort; - clears."},{"name":"--effort-mode","value":"string","summary":"fallback or force; - resets to fallback."},{"name":"--alias","value":"string","summary":"Alias; - clears."},{"name":"--display-name","value":"string","summary":"Label; - clears."},{"name":"--description","value":"string","summary":"Catalog row description; - clears."},{"name":"--decision-provider","value":"string","summary":"JEV provider; - clears."},{"name":"--decision-model","value":"string","summary":"JEV route; - clears; exclusive with provider."},{"name":"--decision-timeout","value":"string","summary":"JEV deadline 1000-120000 ms; - clears."},{"name":"--decision-quota-signals","value":"string","summary":"JEV advisory quota on/off; - clears."},{"name":"--decision-quota-tiers","value":"string","summary":"Partial JSON thresholds; - clears."},{"name":"--session-pin","value":"string","summary":"JEV session pin idle window 1m-24h (90s, 20m, 1h); - clears."},{"name":"--rename-from","value":"string","summary":"Existing combo ID to rename."},{"name":"--json","value":"boolean","summary":"Emit structured JSON."},{"name":"--native-alias","value":"string","summary":"Bare legacy flag means on; explicit on/off preserves presence, including false."},{"name":"--targets-file","value":"string","summary":"Bounded ordered target JSON array, exclusive with --targets; preserves effort/profile/last-resort metadata."},{"name":"--image-input","value":"string","summary":"auto or disabled; explicit auto clears the previous disabled choice."},{"name":"--reasoning-effort-mode","value":"string","summary":"strict or adaptive, distinct from --effort-mode fallback/force."}],
392
392
  mutates: true,
393
393
  json: "payload",
394
394
  details: ["create and update are aliases of set. Existing fields are read before writing; --targets replaces targets. Without --strategy an existing combo keeps its stored strategy and JEV policy; a new combo defaults to failover.","force overrides valid client effort and may increase cost and latency.","Only the implemented target grammar is supported; full GUI target metadata and routing-profile writes are separate tasks.","New file/flag conflicts refuse before transport. Partial edits preserve target metadata; explicit false/default values override server carry. Turning a native alias off may also require clearing its incompatible alias.","Read/merge/write uses one target and remains an upsert without revision CAS. Saved-but-incomplete catalog outcomes return nonzero with their receipt."],
@@ -738,10 +738,16 @@ export const CAPABILITIES: readonly Capability[] = [
738
738
  { name: "--restart-codex", value: "boolean", summary: "Restart the Codex app-servers and fully quit and relaunch the Codex desktop app after a catalog, cache, or changed configuration write, on macOS, Linux and Windows." },
739
739
  { name: "--restart-app-server-only", value: "boolean", summary: "Restart only the Codex app-servers and leave the desktop app running; wins over --restart-codex when both are given." },
740
740
  { name: "--restart-desktop-app", value: "boolean", summary: "Deprecated alias of --restart-codex." },
741
+ { name: "--expect-link", value: "string", summary: "Sync only when this machine is a connected Remote Link Child of this link id; otherwise exit 5 with nothing changed." },
742
+ { name: "--expect-hub-key", value: "string", summary: "Sync only when this machine is a hub client connected with this API key id; otherwise exit 5 with nothing changed." },
741
743
  ],
742
744
  mutates: true,
743
745
  json: "none",
744
- details: ["The Aside refresh uses the live server; other catalog synchronization also performs local work."],
746
+ details: [
747
+ "The Aside refresh uses the live server; other catalog synchronization also performs local work.",
748
+ "--expect-link/--expect-hub-key are checked under the lock that selects the sync path. A mismatch writes nothing, never falls back to local providers, exits 5, and ends stderr with {\"phase\":\"child_link_mismatch\"|\"hub_client_mismatch\",\"reason\":...}; reasons are disconnected, invalid_state, disconnect_pending, pending_operation, hub_client, link_client, other_link and other_key. Usage errors exit 2.",
749
+ ],
750
+ usage: "ocx sync [--expect-link <linkId> | --expect-hub-key <apiKeyId>] [--restart-codex] [--restart-app-server-only]",
745
751
  },
746
752
  {
747
753
  command: ["agent","subagents","force"],