@iislee/opencodex 2.31.0 → 2.35.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 (261) hide show
  1. package/README.md +3 -3
  2. package/bin/ocx.mjs +99 -70
  3. package/gui/dist/assets/index-Be1sDpWw.css +1 -0
  4. package/gui/dist/assets/index-D4OKgUV4.js +114 -0
  5. package/gui/dist/index.html +2 -2
  6. package/package.json +3 -1
  7. package/src/adapters/anthropic.ts +104 -15
  8. package/src/adapters/base.ts +29 -1
  9. package/src/adapters/command-code.ts +42 -6
  10. package/src/adapters/cursor/call-id.ts +44 -0
  11. package/src/adapters/cursor/catalog.ts +541 -0
  12. package/src/adapters/cursor/checkpoint-store.ts +15 -10
  13. package/src/adapters/cursor/cursor-errors.ts +15 -0
  14. package/src/adapters/cursor/discovery.ts +69 -18
  15. package/src/adapters/cursor/effort-map.ts +79 -1
  16. package/src/adapters/cursor/envelope-echo.ts +290 -0
  17. package/src/adapters/cursor/live-models.ts +7 -2
  18. package/src/adapters/cursor/live-transport.ts +14 -0
  19. package/src/adapters/cursor/message-mapper.ts +4 -1
  20. package/src/adapters/cursor/native-exec-desktop.ts +23 -0
  21. package/src/adapters/cursor/native-exec-fs.ts +2 -2
  22. package/src/adapters/cursor/native-exec-network.ts +1 -1
  23. package/src/adapters/cursor/native-exec-shell.ts +5 -2
  24. package/src/adapters/cursor/native-exec.ts +20 -0
  25. package/src/adapters/cursor/protobuf-request.ts +68 -14
  26. package/src/adapters/cursor/request-builder.ts +40 -10
  27. package/src/adapters/cursor/tool-definitions.ts +14 -4
  28. package/src/adapters/cursor/tool-result-normalize.ts +28 -5
  29. package/src/adapters/cursor/types.ts +20 -0
  30. package/src/adapters/cursor.ts +209 -38
  31. package/src/adapters/exec-tool-result-normalize.ts +99 -0
  32. package/src/adapters/google-antigravity-replay.ts +173 -25
  33. package/src/adapters/google-antigravity-wire.ts +5 -0
  34. package/src/adapters/google-errors.ts +44 -12
  35. package/src/adapters/google.ts +136 -24
  36. package/src/adapters/image.ts +1 -1
  37. package/src/adapters/kiro-constants.ts +27 -0
  38. package/src/adapters/kiro-tools.ts +55 -16
  39. package/src/adapters/kiro.ts +182 -23
  40. package/src/adapters/openai-chat.ts +300 -242
  41. package/src/adapters/openai-responses.ts +353 -27
  42. package/src/adapters/run-turn-queue.ts +36 -1
  43. package/src/adapters/tool-catalog-nudge.ts +4 -3
  44. package/src/adapters/xai-tool-schema.ts +436 -0
  45. package/src/adapters/xai-web-search.ts +17 -16
  46. package/src/bridge.ts +90 -37
  47. package/src/chat/inbound.ts +14 -1
  48. package/src/chat/outbound.ts +15 -7
  49. package/src/claude/agents-inject.ts +8 -1
  50. package/src/claude/context-windows.ts +16 -9
  51. package/src/claude/outbound.ts +24 -11
  52. package/src/cli/access.ts +46 -3
  53. package/src/cli/account-api.ts +116 -19
  54. package/src/cli/account-extended.ts +262 -29
  55. package/src/cli/account-main.ts +12 -12
  56. package/src/cli/account.ts +69 -15
  57. package/src/cli/agent.ts +8 -1
  58. package/src/cli/alias.ts +66 -0
  59. package/src/cli/capabilities-command.ts +94 -0
  60. package/src/cli/capabilities.ts +496 -0
  61. package/src/cli/claude-desktop.ts +31 -11
  62. package/src/cli/claude.ts +26 -1
  63. package/src/cli/dispatch.ts +256 -28
  64. package/src/cli/doctor.ts +126 -14
  65. package/src/cli/help.ts +17 -6
  66. package/src/cli/index.ts +39 -9
  67. package/src/cli/init.ts +1 -0
  68. package/src/cli/inspect.ts +230 -0
  69. package/src/cli/models-runtime.ts +95 -0
  70. package/src/cli/models.ts +26 -10
  71. package/src/cli/observe.ts +31 -8
  72. package/src/cli/provider-runtime.ts +16 -2
  73. package/src/cli/provider.ts +2 -1
  74. package/src/cli/registry.ts +49 -10
  75. package/src/cli/runtime-api.ts +51 -7
  76. package/src/cli/status.ts +41 -1
  77. package/src/cli/storage.ts +234 -0
  78. package/src/cli/system-command.ts +16 -0
  79. package/src/cli/system-restart-client.ts +1 -1
  80. package/src/cli/usage-report.ts +184 -0
  81. package/src/cli/v2.ts +34 -10
  82. package/src/cli/version-skew.ts +46 -0
  83. package/src/clients/config-export.ts +85 -3
  84. package/src/clients/effective-status.ts +30 -2
  85. package/src/clients/probes/cline.ts +81 -0
  86. package/src/codex/account-label.ts +21 -0
  87. package/src/codex/account-pause.ts +2 -1
  88. package/src/codex/account-priority.ts +3 -2
  89. package/src/codex/app-server-processes.ts +83 -7
  90. package/src/codex/auth-api.ts +50 -10
  91. package/src/codex/auth-context.ts +21 -18
  92. package/src/codex/autostart-health.ts +16 -0
  93. package/src/codex/catalog/aggregation.ts +18 -0
  94. package/src/codex/catalog/effort.ts +18 -3
  95. package/src/codex/catalog/metadata.ts +27 -1
  96. package/src/codex/catalog/native-models.ts +5 -2
  97. package/src/codex/catalog/parsing.ts +72 -27
  98. package/src/codex/catalog/provider-fetch.ts +187 -31
  99. package/src/codex/catalog/sync.ts +131 -5
  100. package/src/codex/catalog.ts +1 -1
  101. package/src/codex/codex-write-lock.ts +3 -1
  102. package/src/codex/convergence-types.ts +1 -1
  103. package/src/codex/convergence.ts +27 -2
  104. package/src/codex/desired-state.ts +2 -2
  105. package/src/codex/desktop-app-restart.ts +355 -0
  106. package/src/codex/history-job.ts +32 -3
  107. package/src/codex/history-manifest.ts +112 -0
  108. package/src/codex/history-migration-guardian.ts +5 -5
  109. package/src/codex/history-provider.ts +825 -247
  110. package/src/codex/history-worker.ts +8 -5
  111. package/src/codex/inject-coordination.ts +83 -0
  112. package/src/codex/inject.ts +63 -22
  113. package/src/codex/injected-marker.ts +1 -1
  114. package/src/codex/internal/history-writer.ts +4 -3
  115. package/src/codex/log-guard/inspect.ts +22 -4
  116. package/src/codex/model-entitlements.ts +9 -2
  117. package/src/codex/native-profile-startup.ts +157 -27
  118. package/src/codex/native-residue.ts +26 -33
  119. package/src/codex/prompt-layers.ts +371 -25
  120. package/src/codex/prompt-text-probe.ts +238 -0
  121. package/src/codex/quota.ts +91 -10
  122. package/src/codex/routing.ts +9 -0
  123. package/src/codex/shim.ts +56 -3
  124. package/src/codex/subagent-model-fallback.ts +104 -25
  125. package/src/codex/transition-state.ts +116 -8
  126. package/src/combos/failover.ts +27 -0
  127. package/src/combos/types.ts +10 -0
  128. package/src/compatibility/index.ts +26 -0
  129. package/src/compatibility/manifest.ts +253 -0
  130. package/src/compatibility/openai-responses.ts +121 -0
  131. package/src/config/atomic-write.ts +219 -0
  132. package/src/config/paths.ts +40 -0
  133. package/src/config/process-state.ts +309 -0
  134. package/src/config/provider-validation.ts +177 -0
  135. package/src/config/rebase-provenance.ts +68 -0
  136. package/src/config.ts +206 -824
  137. package/src/generated/compatibility-version.json +373 -213
  138. package/src/images/loop.ts +5 -4
  139. package/src/images/plan.ts +5 -4
  140. package/src/integrations/ownership-policy.ts +160 -0
  141. package/src/integrations/ownership.ts +46 -2
  142. package/src/integrations/registry.ts +7 -0
  143. package/src/integrations/state.ts +79 -7
  144. package/src/integrations/writer.ts +26 -2
  145. package/src/lab/conformance/fixtures/protocol-v1-cases.json +1 -1
  146. package/src/lab/fabric/producer-child.ts +1 -1
  147. package/src/lib/admin-secrets.ts +24 -0
  148. package/src/lib/bounded-body.ts +14 -2
  149. package/src/lib/config-ownership.ts +20 -0
  150. package/src/lib/errors.ts +36 -3
  151. package/src/lib/package-tree-integrity.ts +101 -0
  152. package/src/lib/process-control.ts +2 -1
  153. package/src/lib/service-secrets.ts +15 -0
  154. package/src/lib/tool-argument-integers.ts +56 -5
  155. package/src/oauth/callback-server.ts +22 -2
  156. package/src/oauth/cline.ts +203 -0
  157. package/src/oauth/generic-account-failover.ts +231 -0
  158. package/src/oauth/health.ts +1 -1
  159. package/src/oauth/index.ts +65 -6
  160. package/src/oauth/key-providers.ts +10 -1
  161. package/src/oauth/kimi.ts +9 -1
  162. package/src/oauth/kiro.ts +45 -0
  163. package/src/oauth/local-token-detect.ts +2 -0
  164. package/src/oauth/open-browser-choice.ts +26 -0
  165. package/src/oauth/store.ts +14 -5
  166. package/src/oauth/types.ts +15 -0
  167. package/src/providers/auto-compact-budget.ts +65 -0
  168. package/src/providers/command-code-efforts.ts +38 -6
  169. package/src/providers/context-cap.ts +4 -3
  170. package/src/providers/default-aliases.ts +65 -0
  171. package/src/providers/derive.ts +28 -0
  172. package/src/providers/fastwire.ts +7 -1
  173. package/src/providers/label.ts +34 -1
  174. package/src/providers/model-presets.ts +119 -0
  175. package/src/providers/new-model-policy.ts +146 -0
  176. package/src/providers/provider-id-rewrite.ts +2 -1
  177. package/src/providers/quota.ts +65 -7
  178. package/src/providers/registry.ts +184 -69
  179. package/src/providers/slug-codec.ts +52 -0
  180. package/src/providers/xai-transport.ts +21 -0
  181. package/src/reasoning-effort.ts +19 -2
  182. package/src/responses/apply-patch-envelope.ts +63 -0
  183. package/src/responses/code-mode-helper-compat.ts +50 -0
  184. package/src/responses/custom-tool-compat.ts +157 -39
  185. package/src/responses/namespace-tool-compat.ts +84 -4
  186. package/src/responses/parser.ts +7 -2
  187. package/src/responses/reasoning-replay-cache.ts +81 -3
  188. package/src/responses/schema.ts +5 -1
  189. package/src/responses/state.ts +94 -4
  190. package/src/responses/thought-signature-replay.ts +17 -0
  191. package/src/responses/turn-termination.ts +107 -0
  192. package/src/router.ts +40 -2
  193. package/src/routing/analytics.ts +1 -0
  194. package/src/routing/quota.ts +10 -0
  195. package/src/server/auth-cors.ts +27 -7
  196. package/src/server/chat-completions.ts +24 -16
  197. package/src/server/chat-native-sse.ts +3 -3
  198. package/src/server/chat-native.ts +30 -11
  199. package/src/server/claude-messages.ts +1 -1
  200. package/src/server/index.ts +179 -32
  201. package/src/server/lifecycle.ts +52 -1
  202. package/src/server/local-management-read-client.ts +1 -1
  203. package/src/server/local-provider-reload-client.ts +1 -1
  204. package/src/server/management/agent-settings-routes.ts +45 -23
  205. package/src/server/management/codex-prompt-routes.ts +570 -0
  206. package/src/server/management/combo-routes.ts +2 -1
  207. package/src/server/management/config-routes.ts +59 -12
  208. package/src/server/management/context.ts +10 -1
  209. package/src/server/management/logs-usage-routes.ts +30 -24
  210. package/src/server/management/model-routes.ts +274 -4
  211. package/src/server/management/model-rows.ts +4 -0
  212. package/src/server/management/native-integration-routes.ts +2 -1
  213. package/src/server/management/oauth-account-routes.ts +10 -4
  214. package/src/server/management/provider-capability-config.ts +1 -1
  215. package/src/server/management/provider-routes.ts +81 -11
  216. package/src/server/management/route-registry.ts +332 -0
  217. package/src/server/management/routing-profile-routes.ts +2 -2
  218. package/src/server/management/system-restart.ts +1 -1
  219. package/src/server/management-api.ts +18 -16
  220. package/src/server/port-reclaim.ts +1 -1
  221. package/src/server/proxy-liveness.ts +29 -5
  222. package/src/server/relay-eager.ts +147 -20
  223. package/src/server/relay.ts +251 -19
  224. package/src/server/request-log-conversation.ts +51 -0
  225. package/src/server/request-log.ts +70 -16
  226. package/src/server/responses/codex-auth-error.ts +55 -0
  227. package/src/server/responses/collaboration.ts +37 -3
  228. package/src/server/responses/combo-stream-preflight.ts +178 -0
  229. package/src/server/responses/compact.ts +6 -21
  230. package/src/server/responses/core.ts +810 -208
  231. package/src/server/responses/empty-completion-guard.ts +63 -6
  232. package/src/server/responses/fetch-helpers.ts +17 -102
  233. package/src/server/responses/input-admission.ts +3 -1
  234. package/src/server/responses/passthrough-error.ts +33 -9
  235. package/src/server/responses/responses-field-backfill.ts +105 -13
  236. package/src/server/responses/ws-upstream.ts +75 -2
  237. package/src/server/responses-custom-tool-repair.ts +87 -6
  238. package/src/server/responses-terminal-repair.ts +25 -4
  239. package/src/server/responses-undeclared-tool-guard.ts +241 -18
  240. package/src/server/sse-frame-buffer.ts +31 -4
  241. package/src/server/ws-bridge.ts +14 -2
  242. package/src/service.ts +42 -4
  243. package/src/storage/policy-job.ts +14 -4
  244. package/src/storage/policy.ts +88 -23
  245. package/src/types/config.ts +66 -0
  246. package/src/types/provider.ts +69 -0
  247. package/src/types/request.ts +17 -4
  248. package/src/types/tools.ts +116 -11
  249. package/src/types.ts +3 -1
  250. package/src/update/index.ts +5 -4
  251. package/src/update/job.ts +3 -1
  252. package/src/update/transactional-install.mjs +8 -1
  253. package/src/usage/expected-prices.ts +43 -24
  254. package/src/usage/log.ts +63 -12
  255. package/src/usage/summary.ts +211 -8
  256. package/src/vision/describe.ts +18 -13
  257. package/src/web-search/exa-executor.ts +40 -9
  258. package/src/web-search/executor.ts +10 -3
  259. package/src/web-search/loop.ts +5 -4
  260. package/gui/dist/assets/index-BF38heuV.js +0 -104
  261. package/gui/dist/assets/index-DMiI18Kv.css +0 -1
@@ -9,12 +9,44 @@ const COMMAND_CODE_MODEL_EFFORTS = {
9
9
  efforts: ["high", "max"],
10
10
  profileUrl: "https://commandcode.ai/models/deepseek-v4-flash",
11
11
  },
12
- // Ox Alpha (stealth preview, added in Command Code v1.31.0): free 1M-context
13
- // reasoning model on every plan. The profile does not publish an effort ladder,
14
- // so mirror the OpenRouter contract (reasoning mandatory; max/high/low).
15
- "stealth/ox-alpha": {
16
- efforts: ["low", "high", "max"],
17
- profileUrl: "https://commandcode.ai/models/ox-alpha",
12
+ /*
13
+ * Three live routes that reached the catalog without an effort ladder (#2647).
14
+ * Without a row here the model advertises no efforts at all, so a client that
15
+ * sends one gets it stripped or rejected rather than honored.
16
+ *
17
+ * PROVENANCE, stated plainly: these three ladders are the reporter's
18
+ * (darwintree, #2647), recorded as reported and NOT independently verified.
19
+ * All three profileUrls return HTTP 200, but commandcode.ai renders these
20
+ * pages client-side and ships the ladder inside a serialized React payload
21
+ * whose `reasoningEfforts` array is EMPTY in the delivered HTML. There is no
22
+ * fetchable statement of these ladders to check them against.
23
+ *
24
+ * Do not assume the refresh path launders this. It does not:
25
+ * `parsedProfileEfforts` below matches prose of the form
26
+ * "Reasoning efforts ... are supported;", and `grep -c -i 'reasoning efforts'`
27
+ * against the live pages returns 0 — for these three AND for the older rows
28
+ * (deepseek-v4-pro, GLM-5.3, muse-spark-1.2 all measured 0 on 2026-08-27).
29
+ * So `refreshCommandCodeReasoningEfforts` returns undefined and the caller
30
+ * keeps whatever is written here, indefinitely. The self-correction mechanism
31
+ * is currently dead for EVERY row in this table, which is a pre-existing
32
+ * defect worth its own fix (teach the parser to read the embedded payload),
33
+ * not something these three rows introduced.
34
+ *
35
+ * The practical consequence: a wrong ladder here stays wrong until a human
36
+ * changes it. It degrades safely — an effort the upstream rejects surfaces as
37
+ * an error rather than silent corruption — but it does not self-heal.
38
+ */
39
+ "deepseek/deepseek-v4-flash-vision-exp": {
40
+ efforts: ["high", "max"],
41
+ profileUrl: "https://commandcode.ai/models/deepseek-v4-flash-vision-exp",
42
+ },
43
+ "gpt-5.6-luna": {
44
+ efforts: ["low", "medium", "high", "xhigh", "max"],
45
+ profileUrl: "https://commandcode.ai/models/gpt-5-6-luna",
46
+ },
47
+ "google/gemini-3.7-flash": {
48
+ efforts: ["low", "medium", "high"],
49
+ profileUrl: "https://commandcode.ai/models/gemini-3-7-flash",
18
50
  },
19
51
  // Keys must match the EXACT upstream /provider/v1/models ids (GLM ships as
20
52
  // `zai-org/GLM-5.3`, not `zai-org/glm-5.3`). The table doubles as the router's
@@ -1,4 +1,5 @@
1
1
  import type { OcxConfig } from "../types";
2
+ import { deleteConfigTopLevelKey } from "../config/rebase-provenance";
2
3
 
3
4
  export const DEFAULT_PROVIDER_CONTEXT_CAP = 350_000;
4
5
 
@@ -50,7 +51,7 @@ export function setProviderContextCap(config: OcxConfig, provider: string, enabl
50
51
  delete next[provider];
51
52
  }
52
53
  if (Object.keys(next).length > 0) config.providerContextCaps = next;
53
- else delete config.providerContextCaps;
54
+ else deleteConfigTopLevelKey(config, "providerContextCaps");
54
55
  }
55
56
 
56
57
  /**
@@ -71,12 +72,12 @@ export function setGlobalContextCapValue(config: OcxConfig, value: number, apply
71
72
  /** Enable the cap for every named provider at the current value, or clear all caps. */
72
73
  export function setAllProviderContextCaps(config: OcxConfig, providerNames: string[], enabled: boolean): void {
73
74
  if (!enabled) {
74
- delete config.providerContextCaps;
75
+ deleteConfigTopLevelKey(config, "providerContextCaps");
75
76
  return;
76
77
  }
77
78
  const value = globalContextCapValue(config);
78
79
  const next: Record<string, number> = {};
79
80
  for (const name of providerNames) next[name] = value;
80
81
  if (Object.keys(next).length > 0) config.providerContextCaps = next;
81
- else delete config.providerContextCaps;
82
+ else deleteConfigTopLevelKey(config, "providerContextCaps");
82
83
  }
@@ -0,0 +1,65 @@
1
+ import type { OcxConfig, OcxProviderConfig } from "../types";
2
+
3
+ export const MODEL_ALIAS_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
4
+
5
+ /** Ordered, most-specific-first built-in aliases. Updated with the provider registry. */
6
+ export const DEFAULT_MODEL_ALIASES: ReadonlyArray<{ match: RegExp; alias: string }> = [
7
+ { match: /^claude-opus-5/, alias: "opus" },
8
+ { match: /^claude-sonnet-5/, alias: "sonnet" },
9
+ { match: /^claude-haiku/, alias: "haiku" },
10
+ { match: /^gemini-3(?:\.\d+)?-pro/, alias: "g3p" },
11
+ { match: /^gemini-3(?:\.\d+)?-flash/, alias: "g3f" },
12
+ { match: /^deepseek-v4/, alias: "ds4" },
13
+ { match: /^grok-4/, alias: "grok" },
14
+ ];
15
+
16
+ export interface EffectiveModelAlias { alias: string; source: "user" | "builtin" }
17
+
18
+ function builtinRule(id: string): { match: RegExp; alias: string } | undefined {
19
+ const tail = id.slice(id.lastIndexOf("/") + 1);
20
+ return DEFAULT_MODEL_ALIASES.find(rule => rule.match.test(id) || rule.match.test(tail));
21
+ }
22
+
23
+ export function defaultAliasesEnabled(config: Pick<OcxConfig, "defaultModelAliases">, provider: OcxProviderConfig): boolean {
24
+ return provider.defaultAliases ?? config.defaultModelAliases ?? false;
25
+ }
26
+
27
+ export function effectiveModelAliases(
28
+ config: Pick<OcxConfig, "defaultModelAliases">,
29
+ provider: OcxProviderConfig,
30
+ knownIds: Iterable<string>,
31
+ ): Map<string, EffectiveModelAlias> {
32
+ const result = new Map<string, EffectiveModelAlias>();
33
+ for (const [id, alias] of Object.entries(provider.modelAliases ?? {})) {
34
+ if (typeof alias === "string" && MODEL_ALIAS_PATTERN.test(alias)) result.set(id, { alias, source: "user" });
35
+ }
36
+ if (!defaultAliasesEnabled(config, provider)) return result;
37
+ const claims = new Map<string, string[]>();
38
+ for (const id of knownIds) {
39
+ if (result.has(id)) continue;
40
+ const rule = builtinRule(id);
41
+ if (!rule) continue;
42
+ const key = rule.alias.toLowerCase();
43
+ claims.set(key, [...(claims.get(key) ?? []), id]);
44
+ }
45
+ for (const [alias, ids] of claims) {
46
+ if (ids.length !== 1) continue;
47
+ const id = ids[0]!;
48
+ // Catalog drift must skip, never shadow, a native id or explicit user alias.
49
+ if ([...knownIds].some(candidate => candidate.toLowerCase() === alias)) continue;
50
+ if ([...result.values()].some(value => value.alias.toLowerCase() === alias)) continue;
51
+ result.set(id, { alias: builtinRule(id)!.alias, source: "builtin" });
52
+ }
53
+ return result;
54
+ }
55
+
56
+ export function resolveModelAlias(
57
+ config: Pick<OcxConfig, "defaultModelAliases">,
58
+ provider: OcxProviderConfig,
59
+ knownIds: Iterable<string>,
60
+ requested: string,
61
+ ): string | undefined {
62
+ const needle = requested.toLowerCase();
63
+ return [...effectiveModelAliases(config, provider, knownIds)]
64
+ .find(([, value]) => value.alias.toLowerCase() === needle)?.[0];
65
+ }
@@ -390,6 +390,32 @@ function serviceTierModelDefaultsFor(
390
390
  : undefined;
391
391
  }
392
392
 
393
+ /**
394
+ * Materialize the registry's verbosity opt-out into the provider config at seed/enrich time.
395
+ *
396
+ * The catalog hint pass must not read PROVIDER_REGISTRY: a gather flight captures its registry
397
+ * authority up front and forbids any later read, so consulting the registry per model turned
398
+ * every hint pass into a post-lookup read and dropped a custom-destination flight's own
399
+ * discovery result (tests/codex-gather-authority.test.ts).
400
+ *
401
+ * Registry values go in first so an explicit user entry still wins, matching
402
+ * `applyReasoningSummaryDefaults`. `supportsVerbosity` is the provider-wide default, expanded
403
+ * across the seeded model list so an id discovered later still inherits it through the same
404
+ * Record the hint pass already reads.
405
+ */
406
+ function applyVerbosityDefaults(prov: OcxProviderConfig, entry: ProviderRegistryEntry | undefined): void {
407
+ if (!entry) return;
408
+ const perModel = entry.modelSupportsVerbosity;
409
+ if (!perModel && entry.supportsVerbosity === undefined) return;
410
+ prov.modelSupportsVerbosity = {
411
+ ...(perModel ?? {}),
412
+ ...(prov.modelSupportsVerbosity ?? {}),
413
+ };
414
+ if (entry.supportsVerbosity !== undefined) {
415
+ prov.supportsVerbosity ??= entry.supportsVerbosity;
416
+ }
417
+ }
418
+
393
419
  /**
394
420
  * Last-resort enrichment for a provider whose NAME matches no registry id.
395
421
  *
@@ -426,6 +452,7 @@ export function enrichProviderFromRegistry(name: string, prov: OcxProviderConfig
426
452
  // destinations, so a templated or overridable base URL cannot be claimed by it.
427
453
  enrichReasoningSummariesByDestination(prov);
428
454
  applyServiceTierModelDefaults(prov, serviceTierModelDefaultsFor(registryEntryForProviderDestination(prov), prov));
455
+ applyVerbosityDefaults(prov, registryEntryForProviderDestination(prov));
429
456
  return;
430
457
  }
431
458
  const explicitDirectReasoning: DirectReasoningEffortOverrides = {
@@ -489,6 +516,7 @@ export function enrichProviderFromRegistry(name: string, prov: OcxProviderConfig
489
516
  if (prov.preserveResponsesReasoningContent === undefined && entry.preserveResponsesReasoningContent !== undefined) prov.preserveResponsesReasoningContent = entry.preserveResponsesReasoningContent;
490
517
  applyReasoningSummaryDefaults(prov, entry.modelSupportsReasoningSummaries);
491
518
  applyServiceTierModelDefaults(prov, serviceTierModelDefaultsFor(entry, prov));
519
+ applyVerbosityDefaults(prov, entry);
492
520
  // Registry-only repair policy (#938): fill only when the runtime provider has
493
521
  // no explicit policy, and deep-clone so saved/user values never alias the
494
522
  // registry constant.
@@ -246,6 +246,7 @@ export function tierObservationContext(
246
246
  policy: ResolvedFastPolicy,
247
247
  fastMode: boolean | undefined,
248
248
  callerTier: string | undefined,
249
+ responseTierAuthoritative?: boolean,
249
250
  ): TierObservationContext {
250
251
  return {
251
252
  capability: policy.capability,
@@ -253,6 +254,7 @@ export function tierObservationContext(
253
254
  fastWire: policy.fastWire,
254
255
  demandDecision: fastMode === true ? "force-fast" : fastMode === false ? "force-default" : "inherit",
255
256
  ...(callerTier !== undefined ? { callerTier } : {}),
257
+ ...(responseTierAuthoritative !== undefined ? { responseTierAuthoritative } : {}),
256
258
  };
257
259
  }
258
260
 
@@ -344,7 +346,11 @@ export function createAdapterTierMetadata(
344
346
 
345
347
  const responseCanConfirmFast = effectiveFastRequested
346
348
  && context.eligibility === "eligible"
347
- && wireValue !== null;
349
+ && wireValue !== null
350
+ // A destination whose echo is not authoritative can neither confirm nor deny Fast. The
351
+ // ChatGPT-internal Codex backend echoes "default" on priority-scheduled turns, so believing
352
+ // it reported every Fast request as `response-declined` (#2558).
353
+ && context.responseTierAuthoritative !== false;
348
354
  return {
349
355
  outcome,
350
356
  observeResponseServiceTier(value: unknown) {
@@ -1,4 +1,5 @@
1
- import { CODEX_ACCOUNT_LOG_LABEL_RE } from "../codex/account-label";
1
+ import { CODEX_ACCOUNT_LOG_LABEL_RE, oauthAccountLogLabel } from "../codex/account-label";
2
+ import type { OcxProviderConfig } from "../types";
2
3
 
3
4
  export function canonicalUsageProviderLabel(provider: string): string {
4
5
  return provider === "chatgpt" || provider === "openai-multi" ? "openai" : provider;
@@ -17,3 +18,35 @@ export function baseProviderLabel(provider: string): string {
17
18
  if (suffix === "main") return canonicalUsageProviderLabel(provider.slice(0, cut));
18
19
  return CODEX_ACCOUNT_LOG_LABEL_RE.test(suffix) ? canonicalUsageProviderLabel(provider.slice(0, cut)) : provider;
19
20
  }
21
+
22
+ /**
23
+ * Stamp the per-account usage label for a non-Codex OAuth provider (#2699).
24
+ *
25
+ * Call this where the resolved credential is known and NOT inside a failover gate. The obvious
26
+ * place -- next to the `genericFailoverAccountId` assignment in `core.ts` -- sits inside
27
+ * `isGenericFailoverProvider`, and the rotation paths additionally require two or more stored
28
+ * accounts. Stamping there would leave the ordinary case (one xai account, failover off) with no
29
+ * label at all while every test still passed, which is the bug this fixes rather than a variant
30
+ * of it.
31
+ *
32
+ * Two providers are skipped because they already have attribution:
33
+ * - `openai` produces its own `p`-labels through `codexAuthContextLogLabel`.
34
+ * - `anthropic` folds the account into the provider label (`formatAnthropicProviderForLog`).
35
+ *
36
+ * It lives here rather than in `account-label.ts` because it needs `baseProviderLabel`, and this
37
+ * module already imports from that one -- the reverse direction would be an import cycle. This
38
+ * file stays Lab-clean, which matters because `core.ts` is one of the three files
39
+ * `tests/core-lab-boundary.test.ts` guards.
40
+ */
41
+ export function stampOAuthAccountLabel(
42
+ logCtx: { accountLogLabel?: string },
43
+ providerName: string,
44
+ provider: Pick<OcxProviderConfig, "authMode">,
45
+ accountId: string | undefined,
46
+ ): void {
47
+ if (!accountId) return;
48
+ if (provider.authMode !== "oauth") return;
49
+ const base = baseProviderLabel(providerName);
50
+ if (base === "openai" || base === "anthropic") return;
51
+ logCtx.accountLogLabel = oauthAccountLogLabel(accountId, base);
52
+ }
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Shipped per-provider "latest/core" model presets (#2465).
3
+ *
4
+ * Adding a high-volume provider exposes its entire catalog to the Codex picker on day one:
5
+ * openrouter ships 400+ rows, an Anthropic provider ships every historical snapshot. The useful
6
+ * set is a handful of current flagships, so a newly added provider seeds from a curated preset
7
+ * and "everything" stays one click away.
8
+ *
9
+ * Rules are ID PATTERNS rather than literal id lists so a vendor snapshot suffix does not stale
10
+ * the preset between releases: `claude-opus-5-20260814` and `claude-opus-5` both match one rule.
11
+ *
12
+ * The preset is a SEED, not a lock. Materialization evaluates these rules against the provider's
13
+ * current catalog and stores CONCRETE ids in `selectedModels`, so the visibility hot path
14
+ * (`filterCatalogVisibleModels`) never learns about patterns and an older binary still sees a
15
+ * plain allowlist. Design: devlog/_plan/260824_model_ux_aliases_and_defaults/030_default_preset.md
16
+ */
17
+
18
+ import type { OcxProviderConfig } from "../types";
19
+
20
+ export interface ModelPresetRule {
21
+ readonly pattern: RegExp;
22
+ }
23
+
24
+ export interface ModelPreset {
25
+ /** Bumped whenever this provider's rules change; drives upgrade reconciliation. */
26
+ readonly version: number;
27
+ readonly rules: readonly ModelPresetRule[];
28
+ }
29
+
30
+ /**
31
+ * Curated on the same release train as the provider registry. A provider WITHOUT an entry has no
32
+ * preset and behaves exactly as today (mode "all").
33
+ *
34
+ * Deliberately limited to high-volume catalogs. A provider that already ships a short curated
35
+ * list gains nothing from a preset and would only add a marker to reconcile.
36
+ */
37
+ export const MODEL_PRESETS: Readonly<Record<string, ModelPreset>> = Object.freeze({
38
+ openrouter: {
39
+ version: 1,
40
+ rules: [
41
+ { pattern: /^anthropic\/claude-(opus|sonnet|haiku)-[45]/ },
42
+ { pattern: /^google\/gemini-3(\.\d+)?-(pro|flash)/ },
43
+ { pattern: /^openai\/gpt-5(\.\d+)?/ },
44
+ { pattern: /^deepseek\/deepseek-(v4|r2)/ },
45
+ { pattern: /^x-ai\/grok-4(\.\d+)?/ },
46
+ { pattern: /^moonshotai\/kimi-k[23]/ },
47
+ { pattern: /^z-ai\/glm-[45]/ },
48
+ ],
49
+ },
50
+ anthropic: {
51
+ version: 1,
52
+ rules: [
53
+ { pattern: /^claude-opus-[45]/ },
54
+ { pattern: /^claude-sonnet-[45]/ },
55
+ { pattern: /^claude-haiku-[45]/ },
56
+ { pattern: /^claude-fable-5/ },
57
+ ],
58
+ },
59
+ "anthropic-apikey": {
60
+ version: 1,
61
+ rules: [
62
+ { pattern: /^claude-opus-[45]/ },
63
+ { pattern: /^claude-sonnet-[45]/ },
64
+ { pattern: /^claude-haiku-[45]/ },
65
+ { pattern: /^claude-fable-5/ },
66
+ ],
67
+ },
68
+ });
69
+
70
+ /** The preset for a provider, or undefined when none is shipped. */
71
+ export function modelPresetFor(providerName: string): ModelPreset | undefined {
72
+ return MODEL_PRESETS[providerName];
73
+ }
74
+
75
+ /** True when a provider has a shipped preset at all. */
76
+ export function hasModelPreset(providerName: string): boolean {
77
+ return modelPresetFor(providerName) !== undefined;
78
+ }
79
+
80
+ /**
81
+ * Evaluate a provider's rules against concrete catalog ids.
82
+ *
83
+ * Input order is preserved so a caller can show the preset in the same order the picker does.
84
+ * Duplicates are collapsed; a model matching several rules is selected once.
85
+ */
86
+ export function materializeModelPreset(
87
+ providerName: string,
88
+ catalogModelIds: Iterable<string>,
89
+ ): string[] {
90
+ const preset = modelPresetFor(providerName);
91
+ if (!preset) return [];
92
+ const seen = new Set<string>();
93
+ const out: string[] = [];
94
+ for (const id of catalogModelIds) {
95
+ if (seen.has(id)) continue;
96
+ // `RegExp.test` on a shared literal is safe here because no rule uses the `g` flag; a
97
+ // sticky/global pattern would carry lastIndex between calls and skip rows.
98
+ if (preset.rules.some(rule => rule.pattern.test(id))) {
99
+ seen.add(id);
100
+ out.push(id);
101
+ }
102
+ }
103
+ return out;
104
+ }
105
+
106
+
107
+ /**
108
+ * Flip a provider out of preset mode when the user edits its selection (#2465).
109
+ *
110
+ * No-op unless the provider is currently in preset mode: "all" has no marker to keep, and
111
+ * "custom" is already terminal. The applied version is retained so the GUI can still offer
112
+ * "a newer preset is available" without losing what the user chose.
113
+ */
114
+ export function markModelPresetDiverged(provider: OcxProviderConfig): void {
115
+ const marker = provider.modelPreset;
116
+ if (marker?.mode !== "preset") return;
117
+ provider.modelPreset = { ...marker, mode: "custom" };
118
+ }
119
+
@@ -0,0 +1,146 @@
1
+ import type { OcxConfig } from "../types";
2
+ import { routedSlug } from "./slug-codec";
3
+
4
+ export const MODEL_REMOVAL_GRACE_FETCHES = 3;
5
+ export const MAX_KNOWN_MODELS_PER_PROVIDER = 2_000;
6
+ export const MAX_RECENT_ARRIVALS_PER_PROVIDER = 50;
7
+
8
+ export type KnownModelBaseline = NonNullable<NonNullable<OcxConfig["modelDiscovery"]>["knownModels"]>[string];
9
+ export type NewModelPolicy = "on" | "off";
10
+
11
+ export interface NewModelPolicyResult {
12
+ newIds: string[];
13
+ nextBaseline: KnownModelBaseline;
14
+ slugsToDisable: string[];
15
+ arrivals: Array<{ id: string; at: string }>;
16
+ overflow: boolean;
17
+ }
18
+
19
+ /**
20
+ * Whether a transition actually changes persisted state.
21
+ *
22
+ * `updatedAt` moves on every successful fetch, so comparing whole baselines would report a
23
+ * change every time and rewrite config.json on every catalog convergence — a write amplification
24
+ * that also churns the config generation other writers revalidate against. Only the fields that
25
+ * carry meaning are compared.
26
+ */
27
+ function baselineDiffers(prior: KnownModelBaseline | undefined, next: KnownModelBaseline): boolean {
28
+ if (!prior) return true;
29
+ const sameList = (a: readonly string[], b: readonly string[]) =>
30
+ a.length === b.length && a.every((value, index) => value === b[index]);
31
+ if (!sameList(prior.ids, next.ids) || !sameList(prior.removed, next.removed)) return true;
32
+ const priorMissing = prior.missing ?? {};
33
+ const nextMissing = next.missing ?? {};
34
+ const keys = new Set([...Object.keys(priorMissing), ...Object.keys(nextMissing)]);
35
+ for (const key of keys) if (priorMissing[key] !== nextMissing[key]) return true;
36
+ return false;
37
+ }
38
+
39
+ /** Pure successful-discovery transition. An absent baseline bootstraps without hiding anything. */
40
+ export function applyNewModelPolicy(options: {
41
+ provider: string;
42
+ discoveredIds: Iterable<string>;
43
+ baseline?: KnownModelBaseline;
44
+ policy: NewModelPolicy;
45
+ hasSelectedModels?: boolean;
46
+ now: string;
47
+ }): NewModelPolicyResult {
48
+ const discovered = [...new Set(options.discoveredIds)].sort();
49
+ const prior = options.baseline;
50
+ if (!prior) {
51
+ return {
52
+ newIds: [],
53
+ nextBaseline: { ids: discovered, removed: [], updatedAt: options.now },
54
+ slugsToDisable: [], arrivals: [],
55
+ overflow: discovered.length > MAX_KNOWN_MODELS_PER_PROVIDER,
56
+ };
57
+ }
58
+ const active = new Set(prior.ids);
59
+ const removed = new Set(prior.removed);
60
+ const seen = new Set(discovered);
61
+ const newIds = discovered.filter(id => !active.has(id) && !removed.has(id));
62
+ const missing: Record<string, number> = {};
63
+ for (const id of active) {
64
+ if (seen.has(id)) continue;
65
+ const count = (prior.missing?.[id] ?? 0) + 1;
66
+ if (count >= MODEL_REMOVAL_GRACE_FETCHES) {
67
+ active.delete(id);
68
+ removed.add(id);
69
+ } else missing[id] = count;
70
+ }
71
+ for (const id of discovered) active.add(id);
72
+ const unionSize = active.size + removed.size;
73
+ const overflow = unionSize > MAX_KNOWN_MODELS_PER_PROVIDER;
74
+ const arrivals = newIds.map(id => ({ id, at: options.now }));
75
+ return {
76
+ newIds,
77
+ nextBaseline: {
78
+ ids: [...active].sort(), removed: [...removed].sort(), updatedAt: options.now,
79
+ ...(Object.keys(missing).length ? { missing } : {}),
80
+ },
81
+ // A non-empty preset/custom allowlist already excludes arrivals. This explicit no-op is
82
+ // deliberate: preset mode owns which matching flagships arrive on.
83
+ slugsToDisable: !overflow && options.policy === "off" && !options.hasSelectedModels
84
+ ? newIds.map(id => routedSlug(options.provider, id)) : [],
85
+ arrivals,
86
+ overflow,
87
+ };
88
+ }
89
+
90
+ export function effectiveNewModelPolicy(config: OcxConfig, provider: string): NewModelPolicy {
91
+ const local = config.providers[provider]?.newModelPolicy;
92
+ if (local === "on" || local === "off") return local;
93
+ return config.modelDiscovery?.newModelPolicy ?? "on";
94
+ }
95
+
96
+ /** Apply authoritative provider rows to a mutable convergence copy; degraded providers are omitted. */
97
+ export function reconcileSuccessfulModelDiscoveries(options: {
98
+ config: OcxConfig;
99
+ models: Iterable<{ provider: string; id: string; custom?: boolean }>;
100
+ authoritativeProviders: Iterable<string>;
101
+ now: string;
102
+ }): boolean {
103
+ const byProvider = new Map<string, string[]>();
104
+ for (const model of options.models) {
105
+ if (model.custom) continue;
106
+ const ids = byProvider.get(model.provider) ?? [];
107
+ ids.push(model.id); byProvider.set(model.provider, ids);
108
+ }
109
+ let changed = false;
110
+ for (const provider of options.authoritativeProviders) {
111
+ const configured = options.config.providers[provider];
112
+ if (!configured || configured.liveModels === false) continue;
113
+ const discoveredIds = byProvider.get(provider) ?? [];
114
+ const discovery = options.config.modelDiscovery ??= {};
115
+ const known = discovery.knownModels ??= {};
116
+ const result = applyNewModelPolicy({
117
+ provider, discoveredIds, baseline: known[provider],
118
+ policy: effectiveNewModelPolicy(options.config, provider),
119
+ hasSelectedModels: (configured.selectedModels?.length ?? 0) > 0,
120
+ now: options.now,
121
+ });
122
+ if (result.overflow) continue;
123
+ const priorBaseline = known[provider];
124
+ const baselineChanged = baselineDiffers(priorBaseline, result.nextBaseline);
125
+ known[provider] = result.nextBaseline;
126
+ // Keep the previous timestamp when nothing else moved, so a steady-state roster does not
127
+ // make the baseline look dirty on the next comparison either.
128
+ if (!baselineChanged && priorBaseline) known[provider] = priorBaseline;
129
+ if (result.slugsToDisable.length) {
130
+ const disabled = options.config.disabledModels ??= [];
131
+ for (const slug of result.slugsToDisable) {
132
+ if (disabled.includes(slug)) continue;
133
+ disabled.push(slug);
134
+ changed = true;
135
+ }
136
+ }
137
+ if (result.arrivals.length) {
138
+ const recent = discovery.recentArrivals ??= {};
139
+ recent[provider] = [...(recent[provider] ?? []), ...result.arrivals]
140
+ .slice(-MAX_RECENT_ARRIVALS_PER_PROVIDER);
141
+ changed = true;
142
+ }
143
+ if (baselineChanged) changed = true;
144
+ }
145
+ return changed;
146
+ }
@@ -1,4 +1,5 @@
1
1
  import type { OcxConfig } from "../types";
2
+ import { deleteConfigTopLevelKey } from "../config/rebase-provenance";
2
3
 
3
4
  export interface ProviderRewriteResult {
4
5
  /** Number of references re-pointed. */
@@ -174,6 +175,6 @@ export function dropProviderCustomModels(config: OcxConfig, provider: string): n
174
175
  // `[]`, so the `customModels` field is absent either way. Only that field —
175
176
  // the `customModelCatalogMigration` marker is deliberately left in place.
176
177
  if (kept.length > 0) config.customModels = kept;
177
- else delete config.customModels;
178
+ else deleteConfigTopLevelKey(config, "customModels");
178
179
  return existing.length - kept.length;
179
180
  }