codex-multi-auth 2.15.0 → 2.17.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 (272) hide show
  1. package/.codex-plugin/plugin.json +1 -1
  2. package/README.md +22 -1
  3. package/config/README.md +2 -2
  4. package/config/codex-legacy.json +109 -184
  5. package/config/codex-modern.json +44 -114
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +10 -4
  8. package/dist/lib/account-policy.d.ts +4 -0
  9. package/dist/lib/account-policy.d.ts.map +1 -1
  10. package/dist/lib/account-policy.js +8 -0
  11. package/dist/lib/accounts/rate-limits.d.ts.map +1 -1
  12. package/dist/lib/accounts/rate-limits.js +2 -0
  13. package/dist/lib/accounts.d.ts +21 -3
  14. package/dist/lib/accounts.d.ts.map +1 -1
  15. package/dist/lib/accounts.js +229 -17
  16. package/dist/lib/api-route-store.d.ts +24 -0
  17. package/dist/lib/api-route-store.d.ts.map +1 -0
  18. package/dist/lib/api-route-store.js +145 -0
  19. package/dist/lib/auth/account-access.d.ts +115 -0
  20. package/dist/lib/auth/account-access.d.ts.map +1 -0
  21. package/dist/lib/auth/account-access.js +214 -0
  22. package/dist/lib/auth/token-utils.d.ts +54 -1
  23. package/dist/lib/auth/token-utils.d.ts.map +1 -1
  24. package/dist/lib/auth/token-utils.js +92 -7
  25. package/dist/lib/cli.d.ts +1 -1
  26. package/dist/lib/cli.d.ts.map +1 -1
  27. package/dist/lib/cli.js +4 -0
  28. package/dist/lib/codex-cli/state.d.ts +7 -0
  29. package/dist/lib/codex-cli/state.d.ts.map +1 -1
  30. package/dist/lib/codex-cli/state.js +18 -0
  31. package/dist/lib/codex-cli/writer.d.ts.map +1 -1
  32. package/dist/lib/codex-cli/writer.js +60 -8
  33. package/dist/lib/codex-manager/account-manager-commands.d.ts.map +1 -1
  34. package/dist/lib/codex-manager/account-manager-commands.js +1 -0
  35. package/dist/lib/codex-manager/account-pool-write.d.ts +3 -1
  36. package/dist/lib/codex-manager/account-pool-write.d.ts.map +1 -1
  37. package/dist/lib/codex-manager/account-pool-write.js +4 -0
  38. package/dist/lib/codex-manager/api-login-menu.d.ts +14 -0
  39. package/dist/lib/codex-manager/api-login-menu.d.ts.map +1 -0
  40. package/dist/lib/codex-manager/api-login-menu.js +224 -0
  41. package/dist/lib/codex-manager/commands/account.d.ts.map +1 -1
  42. package/dist/lib/codex-manager/commands/account.js +27 -0
  43. package/dist/lib/codex-manager/commands/best.d.ts.map +1 -1
  44. package/dist/lib/codex-manager/commands/best.js +6 -2
  45. package/dist/lib/codex-manager/commands/check.d.ts +7 -1
  46. package/dist/lib/codex-manager/commands/check.d.ts.map +1 -1
  47. package/dist/lib/codex-manager/commands/check.js +24 -3
  48. package/dist/lib/codex-manager/commands/forecast.d.ts.map +1 -1
  49. package/dist/lib/codex-manager/commands/forecast.js +5 -1
  50. package/dist/lib/codex-manager/commands/report.d.ts.map +1 -1
  51. package/dist/lib/codex-manager/commands/report.js +5 -1
  52. package/dist/lib/codex-manager/commands/resets.d.ts +2 -0
  53. package/dist/lib/codex-manager/commands/resets.d.ts.map +1 -0
  54. package/dist/lib/codex-manager/commands/resets.js +67 -0
  55. package/dist/lib/codex-manager/commands/rotation.d.ts +2 -2
  56. package/dist/lib/codex-manager/commands/rotation.d.ts.map +1 -1
  57. package/dist/lib/codex-manager/commands/rotation.js +63 -12
  58. package/dist/lib/codex-manager/commands/status.d.ts +12 -1
  59. package/dist/lib/codex-manager/commands/status.d.ts.map +1 -1
  60. package/dist/lib/codex-manager/commands/status.js +166 -22
  61. package/dist/lib/codex-manager/commands/uninstall.js +1 -1
  62. package/dist/lib/codex-manager/formatters/quota-formatters.d.ts.map +1 -1
  63. package/dist/lib/codex-manager/formatters/quota-formatters.js +3 -2
  64. package/dist/lib/codex-manager/health-check.d.ts +3 -0
  65. package/dist/lib/codex-manager/health-check.d.ts.map +1 -1
  66. package/dist/lib/codex-manager/health-check.js +56 -6
  67. package/dist/lib/codex-manager/help.d.ts.map +1 -1
  68. package/dist/lib/codex-manager/help.js +4 -2
  69. package/dist/lib/codex-manager/login-flow.d.ts.map +1 -1
  70. package/dist/lib/codex-manager/login-flow.js +69 -7
  71. package/dist/lib/codex-manager/login-menu-data.d.ts.map +1 -1
  72. package/dist/lib/codex-manager/login-menu-data.js +14 -5
  73. package/dist/lib/codex-manager/login-oauth.d.ts +3 -0
  74. package/dist/lib/codex-manager/login-oauth.d.ts.map +1 -1
  75. package/dist/lib/codex-manager/login-oauth.js +6 -1
  76. package/dist/lib/codex-manager/login-workspace-choice.d.ts +11 -0
  77. package/dist/lib/codex-manager/login-workspace-choice.d.ts.map +1 -0
  78. package/dist/lib/codex-manager/login-workspace-choice.js +37 -0
  79. package/dist/lib/codex-manager/persist-selected-account.d.ts.map +1 -1
  80. package/dist/lib/codex-manager/persist-selected-account.js +2 -1
  81. package/dist/lib/codex-manager/repair-commands.d.ts +13 -0
  82. package/dist/lib/codex-manager/repair-commands.d.ts.map +1 -1
  83. package/dist/lib/codex-manager/repair-commands.js +143 -8
  84. package/dist/lib/codex-manager.d.ts.map +1 -1
  85. package/dist/lib/codex-manager.js +25 -6
  86. package/dist/lib/concurrency.d.ts +3 -0
  87. package/dist/lib/concurrency.d.ts.map +1 -0
  88. package/dist/lib/concurrency.js +31 -0
  89. package/dist/lib/context-budget/model-context-windows.d.ts +1 -1
  90. package/dist/lib/context-budget/model-context-windows.d.ts.map +1 -1
  91. package/dist/lib/context-budget/model-context-windows.js +9 -10
  92. package/dist/lib/model-route-policy.d.ts +52 -0
  93. package/dist/lib/model-route-policy.d.ts.map +1 -0
  94. package/dist/lib/model-route-policy.js +159 -0
  95. package/dist/lib/policy/runtime-policy.d.ts +1 -0
  96. package/dist/lib/policy/runtime-policy.d.ts.map +1 -1
  97. package/dist/lib/policy/runtime-policy.js +3 -0
  98. package/dist/lib/preemptive-quota-scheduler.d.ts +2 -0
  99. package/dist/lib/preemptive-quota-scheduler.d.ts.map +1 -1
  100. package/dist/lib/preemptive-quota-scheduler.js +4 -0
  101. package/dist/lib/prompts/codex.d.ts.map +1 -1
  102. package/dist/lib/prompts/codex.js +3 -1
  103. package/dist/lib/quota-probe.d.ts +5 -0
  104. package/dist/lib/quota-probe.d.ts.map +1 -1
  105. package/dist/lib/quota-probe.js +26 -2
  106. package/dist/lib/request/client-cancellation.d.ts +5 -0
  107. package/dist/lib/request/client-cancellation.d.ts.map +1 -0
  108. package/dist/lib/request/client-cancellation.js +7 -0
  109. package/dist/lib/request/error-classification.d.ts.map +1 -1
  110. package/dist/lib/request/error-classification.js +39 -25
  111. package/dist/lib/request/fetch-helpers.js +1 -1
  112. package/dist/lib/request/helpers/model-map.d.ts +12 -2
  113. package/dist/lib/request/helpers/model-map.d.ts.map +1 -1
  114. package/dist/lib/request/helpers/model-map.js +174 -147
  115. package/dist/lib/request/response-outcome.d.ts +25 -0
  116. package/dist/lib/request/response-outcome.d.ts.map +1 -0
  117. package/dist/lib/request/response-outcome.js +49 -0
  118. package/dist/lib/request/stream-failover-runtime.d.ts +2 -1
  119. package/dist/lib/request/stream-failover-runtime.d.ts.map +1 -1
  120. package/dist/lib/request/stream-failover-runtime.js +29 -10
  121. package/dist/lib/runtime/account-check.d.ts.map +1 -1
  122. package/dist/lib/runtime/account-check.js +2 -8
  123. package/dist/lib/runtime/account-model-catalog.d.ts +64 -0
  124. package/dist/lib/runtime/account-model-catalog.d.ts.map +1 -0
  125. package/dist/lib/runtime/account-model-catalog.js +154 -0
  126. package/dist/lib/runtime/account-pool.d.ts +3 -1
  127. package/dist/lib/runtime/account-pool.d.ts.map +1 -1
  128. package/dist/lib/runtime/account-pool.js +4 -0
  129. package/dist/lib/runtime/account-reset-credits.d.ts +42 -0
  130. package/dist/lib/runtime/account-reset-credits.d.ts.map +1 -0
  131. package/dist/lib/runtime/account-reset-credits.js +82 -0
  132. package/dist/lib/runtime/api-model-capabilities.d.ts +30 -0
  133. package/dist/lib/runtime/api-model-capabilities.d.ts.map +1 -0
  134. package/dist/lib/runtime/api-model-capabilities.js +434 -0
  135. package/dist/lib/runtime/api-model-runtime.d.ts +42 -0
  136. package/dist/lib/runtime/api-model-runtime.d.ts.map +1 -0
  137. package/dist/lib/runtime/api-model-runtime.js +358 -0
  138. package/dist/lib/runtime/app-bind.d.ts +19 -1
  139. package/dist/lib/runtime/app-bind.d.ts.map +1 -1
  140. package/dist/lib/runtime/app-bind.js +79 -9
  141. package/dist/lib/runtime/automatic-account-checks.d.ts +31 -0
  142. package/dist/lib/runtime/automatic-account-checks.d.ts.map +1 -0
  143. package/dist/lib/runtime/automatic-account-checks.js +113 -0
  144. package/dist/lib/runtime/automatic-subscription-checks.d.ts +7 -0
  145. package/dist/lib/runtime/automatic-subscription-checks.d.ts.map +1 -0
  146. package/dist/lib/runtime/automatic-subscription-checks.js +57 -0
  147. package/dist/lib/runtime/catalog-capabilities.d.ts +8 -0
  148. package/dist/lib/runtime/catalog-capabilities.d.ts.map +1 -0
  149. package/dist/lib/runtime/catalog-capabilities.js +61 -0
  150. package/dist/lib/runtime/inference-activity.d.ts +15 -0
  151. package/dist/lib/runtime/inference-activity.d.ts.map +1 -0
  152. package/dist/lib/runtime/inference-activity.js +95 -0
  153. package/dist/lib/runtime/model-discovery-status.d.ts +100 -0
  154. package/dist/lib/runtime/model-discovery-status.d.ts.map +1 -0
  155. package/dist/lib/runtime/model-discovery-status.js +387 -0
  156. package/dist/lib/runtime/native-account-storage.d.ts +11 -0
  157. package/dist/lib/runtime/native-account-storage.d.ts.map +1 -0
  158. package/dist/lib/runtime/native-account-storage.js +50 -0
  159. package/dist/lib/runtime/native-account-sync.d.ts +19 -0
  160. package/dist/lib/runtime/native-account-sync.d.ts.map +1 -0
  161. package/dist/lib/runtime/native-account-sync.js +62 -0
  162. package/dist/lib/runtime/native-binding-lock.d.ts +3 -0
  163. package/dist/lib/runtime/native-binding-lock.d.ts.map +1 -0
  164. package/dist/lib/runtime/native-binding-lock.js +5 -0
  165. package/dist/lib/runtime/native-client-auth.d.ts +3 -0
  166. package/dist/lib/runtime/native-client-auth.d.ts.map +1 -0
  167. package/dist/lib/runtime/native-client-auth.js +42 -0
  168. package/dist/lib/runtime/native-provider-config.d.ts +4 -0
  169. package/dist/lib/runtime/native-provider-config.d.ts.map +1 -0
  170. package/dist/lib/runtime/native-provider-config.js +52 -0
  171. package/dist/lib/runtime/native-rate-limits.d.ts +18 -0
  172. package/dist/lib/runtime/native-rate-limits.d.ts.map +1 -0
  173. package/dist/lib/runtime/native-rate-limits.js +135 -0
  174. package/dist/lib/runtime/reset-credit-routing.d.ts +41 -0
  175. package/dist/lib/runtime/reset-credit-routing.d.ts.map +1 -0
  176. package/dist/lib/runtime/reset-credit-routing.js +66 -0
  177. package/dist/lib/runtime/reset-credits.d.ts +101 -0
  178. package/dist/lib/runtime/reset-credits.d.ts.map +1 -0
  179. package/dist/lib/runtime/reset-credits.js +162 -0
  180. package/dist/lib/runtime/response-output-history.d.ts +17 -0
  181. package/dist/lib/runtime/response-output-history.d.ts.map +1 -0
  182. package/dist/lib/runtime/response-output-history.js +85 -0
  183. package/dist/lib/runtime/responses-websocket.d.ts +31 -0
  184. package/dist/lib/runtime/responses-websocket.d.ts.map +1 -0
  185. package/dist/lib/runtime/responses-websocket.js +636 -0
  186. package/dist/lib/runtime/resume-picker.d.ts +41 -0
  187. package/dist/lib/runtime/resume-picker.d.ts.map +1 -0
  188. package/dist/lib/runtime/resume-picker.js +169 -0
  189. package/dist/lib/runtime/rotation-account-selection.d.ts +6 -0
  190. package/dist/lib/runtime/rotation-account-selection.d.ts.map +1 -1
  191. package/dist/lib/runtime/rotation-account-selection.js +63 -0
  192. package/dist/lib/runtime/rotation-proxy-state.d.ts +33 -0
  193. package/dist/lib/runtime/rotation-proxy-state.d.ts.map +1 -1
  194. package/dist/lib/runtime/rotation-server-types.d.ts +18 -0
  195. package/dist/lib/runtime/rotation-server-types.d.ts.map +1 -1
  196. package/dist/lib/runtime/runtime-capability-failures.d.ts +14 -0
  197. package/dist/lib/runtime/runtime-capability-failures.d.ts.map +1 -0
  198. package/dist/lib/runtime/runtime-capability-failures.js +76 -0
  199. package/dist/lib/runtime/runtime-observability.d.ts +7 -0
  200. package/dist/lib/runtime/runtime-observability.d.ts.map +1 -1
  201. package/dist/lib/runtime/runtime-observability.js +42 -2
  202. package/dist/lib/runtime/subscription-first-use.d.ts +10 -0
  203. package/dist/lib/runtime/subscription-first-use.d.ts.map +1 -0
  204. package/dist/lib/runtime/subscription-first-use.js +64 -0
  205. package/dist/lib/runtime/subscription-quota-event.d.ts +6 -0
  206. package/dist/lib/runtime/subscription-quota-event.d.ts.map +1 -0
  207. package/dist/lib/runtime/subscription-quota-event.js +31 -0
  208. package/dist/lib/runtime/subscription-quota-order.d.ts +17 -0
  209. package/dist/lib/runtime/subscription-quota-order.d.ts.map +1 -0
  210. package/dist/lib/runtime/subscription-quota-order.js +31 -0
  211. package/dist/lib/runtime/workspace-model-scopes.d.ts +15 -0
  212. package/dist/lib/runtime/workspace-model-scopes.d.ts.map +1 -0
  213. package/dist/lib/runtime/workspace-model-scopes.js +34 -0
  214. package/dist/lib/runtime-constants.d.ts +3 -0
  215. package/dist/lib/runtime-constants.d.ts.map +1 -1
  216. package/dist/lib/runtime-constants.js +5 -0
  217. package/dist/lib/runtime-paths.d.ts.map +1 -1
  218. package/dist/lib/runtime-paths.js +4 -1
  219. package/dist/lib/runtime-rotation-proxy.d.ts.map +1 -1
  220. package/dist/lib/runtime-rotation-proxy.js +855 -46
  221. package/dist/lib/schemas.d.ts +20 -0
  222. package/dist/lib/schemas.d.ts.map +1 -1
  223. package/dist/lib/schemas.js +3 -0
  224. package/dist/lib/storage/credential-sidecars.d.ts +13 -0
  225. package/dist/lib/storage/credential-sidecars.d.ts.map +1 -0
  226. package/dist/lib/storage/credential-sidecars.js +52 -0
  227. package/dist/lib/storage/file-lock.d.ts +9 -0
  228. package/dist/lib/storage/file-lock.d.ts.map +1 -0
  229. package/dist/lib/storage/file-lock.js +186 -0
  230. package/dist/lib/storage/flagged-storage.d.ts.map +1 -1
  231. package/dist/lib/storage/flagged-storage.js +12 -0
  232. package/dist/lib/storage/path-state.d.ts +2 -0
  233. package/dist/lib/storage/path-state.d.ts.map +1 -1
  234. package/dist/lib/storage/path-state.js +9 -0
  235. package/dist/lib/storage/paths.js +4 -4
  236. package/dist/lib/storage/pending-auth.d.ts +17 -0
  237. package/dist/lib/storage/pending-auth.d.ts.map +1 -0
  238. package/dist/lib/storage/pending-auth.js +153 -0
  239. package/dist/lib/storage/public-types.d.ts +13 -0
  240. package/dist/lib/storage/public-types.d.ts.map +1 -1
  241. package/dist/lib/storage/snapshot-merge.d.ts +16 -0
  242. package/dist/lib/storage/snapshot-merge.d.ts.map +1 -0
  243. package/dist/lib/storage/snapshot-merge.js +206 -0
  244. package/dist/lib/storage/transactions.d.ts.map +1 -1
  245. package/dist/lib/storage/transactions.js +5 -4
  246. package/dist/lib/storage.d.ts +6 -0
  247. package/dist/lib/storage.d.ts.map +1 -1
  248. package/dist/lib/storage.js +77 -7
  249. package/dist/lib/ui/auth-menu-builder.d.ts +2 -0
  250. package/dist/lib/ui/auth-menu-builder.d.ts.map +1 -1
  251. package/dist/lib/ui/auth-menu-builder.js +1 -0
  252. package/dist/lib/ui/auth-menu.d.ts.map +1 -1
  253. package/dist/lib/ui/auth-menu.js +1 -0
  254. package/dist/lib/ui/check-progress.d.ts +8 -0
  255. package/dist/lib/ui/check-progress.d.ts.map +1 -0
  256. package/dist/lib/ui/check-progress.js +30 -0
  257. package/dist/lib/ui/format.d.ts +3 -1
  258. package/dist/lib/ui/format.d.ts.map +1 -1
  259. package/dist/lib/ui/format.js +8 -0
  260. package/dist/lib/ui/ui-copy.d.ts +2 -2
  261. package/dist/lib/ui/ui-copy.js +2 -2
  262. package/dist/lib/usage/pricing.d.ts +19 -2
  263. package/dist/lib/usage/pricing.d.ts.map +1 -1
  264. package/dist/lib/usage/pricing.js +101 -40
  265. package/dist/lib/usage/usage-extraction.d.ts +3 -1
  266. package/dist/lib/usage/usage-extraction.d.ts.map +1 -1
  267. package/dist/lib/usage/usage-extraction.js +46 -9
  268. package/package.json +7 -4
  269. package/scripts/codex-app-router.js +7 -0
  270. package/scripts/codex-bin-resolver.js +40 -8
  271. package/scripts/codex-routing.js +1 -0
  272. package/scripts/codex.js +209 -126
@@ -0,0 +1,159 @@
1
+ import { mergeCatalogModel, mergeCatalogModels } from "./runtime/catalog-capabilities.js";
2
+ import { isRecord } from "./utils.js";
3
+ export function parseModelRoute(model) {
4
+ if (!model || model.length > 256 || /[\u0000-\u0020\u007f]/.test(model))
5
+ throw new Error("Invalid route model");
6
+ let kind = "oauth";
7
+ for (const candidate of ["api", "zdr"])
8
+ if (model.startsWith(`${candidate}/`)) {
9
+ kind = candidate;
10
+ model = model.slice(candidate.length + 1);
11
+ break;
12
+ }
13
+ let serviceTier;
14
+ if (model.startsWith("speed/")) {
15
+ const match = /^speed\/([A-Za-z0-9._-]{1,64})\/(.+)$/.exec(model);
16
+ if (!match?.[1] || !match[2])
17
+ throw new Error("Invalid speed route");
18
+ serviceTier = match[1];
19
+ model = match[2];
20
+ }
21
+ if (!model || /^(api|zdr|speed)\//.test(model))
22
+ throw new Error("Invalid route model");
23
+ return {
24
+ kind,
25
+ upstreamModel: model,
26
+ ...(serviceTier ? { serviceTier } : {}),
27
+ };
28
+ }
29
+ export function modelServiceTiers(model) {
30
+ if (!Array.isArray(model.service_tiers))
31
+ return [];
32
+ return model.service_tiers.filter((tier) => isRecord(tier) &&
33
+ typeof tier.id === "string" &&
34
+ /^[A-Za-z0-9._-]{1,64}$/.test(tier.id) &&
35
+ typeof tier.name === "string" &&
36
+ tier.name.length <= 100 &&
37
+ !/[\x00-\x1f\x7f]/.test(tier.name) &&
38
+ typeof tier.description === "string");
39
+ }
40
+ export function canonicalServiceTier(tier) {
41
+ return tier === "priority" ? "fast" : tier;
42
+ }
43
+ export function supportsModelSettings(model, reasoningEffort, serviceTier) {
44
+ return ((!reasoningEffort ||
45
+ Array.isArray(model.supported_reasoning_levels) &&
46
+ model.supported_reasoning_levels.some((l) => isRecord(l) && l.effort === reasoningEffort)) &&
47
+ (!serviceTier ||
48
+ serviceTier === "default" ||
49
+ serviceTier === "auto" ||
50
+ modelServiceTiers(model).some((t) => canonicalServiceTier(t.id) === canonicalServiceTier(serviceTier))));
51
+ }
52
+ function visible(catalog, model) {
53
+ if ((isRecord(model.capability_probe_status) &&
54
+ model.capability_probe_status.responses === "unsupported") ||
55
+ !catalog.enabled ||
56
+ !model.slug ||
57
+ /^(api|zdr|speed)\//.test(model.slug))
58
+ return false;
59
+ return (catalog.kind === "oauth" ||
60
+ catalog.visibleModels?.includes(model.slug) === true);
61
+ }
62
+ export function resolveModelRoute(model, catalogs, settings = {}) {
63
+ const parsed = parseModelRoute(model);
64
+ if (parsed.serviceTier &&
65
+ settings.serviceTier &&
66
+ canonicalServiceTier(parsed.serviceTier) !==
67
+ canonicalServiceTier(settings.serviceTier))
68
+ throw new Error("Conflicting speed selection");
69
+ const serviceTier = parsed.serviceTier ?? settings.serviceTier;
70
+ const candidates = catalogs
71
+ .filter((c) => c.kind === parsed.kind &&
72
+ c.models.some((m) => m.slug === parsed.upstreamModel &&
73
+ visible(c, m) &&
74
+ supportsModelSettings(m, settings.reasoningEffort, serviceTier)))
75
+ .sort((a, b) => a.priority - b.priority || a.id.localeCompare(b.id));
76
+ return { ...parsed, ...(serviceTier ? { serviceTier } : {}), candidates };
77
+ }
78
+ export function buildVisibleModelUnion(catalogs) {
79
+ const models = new Map();
80
+ const sources = new Map();
81
+ for (const catalog of [...catalogs].sort((a, b) => a.priority - b.priority)) {
82
+ for (const model of catalog.models) {
83
+ if (!visible(catalog, model))
84
+ continue;
85
+ const prefix = catalog.kind === "oauth" ? "" : `${catalog.kind}/`;
86
+ const name = `${catalog.kind === "oauth" ? "" : `${catalog.kind.toUpperCase()} · `}${typeof model.display_name === "string" ? model.display_name : model.slug}`;
87
+ const slug = prefix + model.slug;
88
+ const group = sources.get(slug) ?? [];
89
+ group.push({ ...model, ...(Array.isArray(model.service_tiers) ? { service_tiers: modelServiceTiers(model) } : {}) });
90
+ sources.set(slug, group);
91
+ const existing = models.get(slug);
92
+ const entry = (existing ? mergeCatalogModel(existing, model) : undefined) ??
93
+ (catalog.kind === "oauth"
94
+ ? { ...model }
95
+ : { ...model, slug, display_name: name });
96
+ models.set(slug, entry);
97
+ const programs = new Map();
98
+ for (const source of [entry.available_access_programs, model.available_access_programs]) {
99
+ if (!isRecord(source))
100
+ continue;
101
+ for (const [category, values] of Object.entries(source)) {
102
+ if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,79}$/.test(category) || !Array.isArray(values))
103
+ continue;
104
+ const merged = programs.get(category) ?? new Set();
105
+ for (const value of values)
106
+ if (typeof value === "string" && /^[A-Za-z0-9][A-Za-z0-9._-]{0,79}$/.test(value))
107
+ merged.add(value);
108
+ programs.set(category, merged);
109
+ }
110
+ }
111
+ if (programs.size)
112
+ entry.available_access_programs = Object.fromEntries([...programs].map(([category, values]) => [category, [...values]]));
113
+ }
114
+ }
115
+ for (const [slug, group] of sources) {
116
+ const entry = models.get(slug), merged = mergeCatalogModels(group);
117
+ if (!entry || !merged)
118
+ continue;
119
+ entry.supported_reasoning_levels = merged.supported_reasoning_levels;
120
+ if (merged.default_service_tier !== undefined)
121
+ entry.default_service_tier = merged.default_service_tier === "fast" ? "priority" : merged.default_service_tier;
122
+ if (Array.isArray(merged.service_tiers))
123
+ entry.service_tiers = modelServiceTiers(merged).map(tier => ({ ...tier, id: canonicalServiceTier(tier.id) === "fast" ? "priority" : tier.id }));
124
+ }
125
+ return [...models.values()];
126
+ }
127
+ /** Whitelist capability metadata; never persist model instructions or arbitrary fields. */
128
+ export function modelEntitlements(model) {
129
+ const safe = (v) => typeof v === "string" && /^[A-Za-z0-9._-]{1,80}$/.test(v);
130
+ return {
131
+ model: model.slug,
132
+ ...(typeof model.capability_checked_at === "number"
133
+ ? { checkedAt: model.capability_checked_at }
134
+ : {}),
135
+ ...(isRecord(model.capability_probe_status)
136
+ ? {
137
+ probes: Object.fromEntries(Object.entries(model.capability_probe_status).filter((entry) => /^(responses|fast|ultrafast|effort:(none|minimal|low|medium|high|xhigh|max|ultra))$/.test(entry[0]) &&
138
+ [
139
+ "verified",
140
+ "unsupported",
141
+ "unverified",
142
+ "downgraded",
143
+ ].includes(String(entry[1])))),
144
+ }
145
+ : {}),
146
+ serviceTiers: modelServiceTiers(model).map((t) => ({
147
+ id: t.id,
148
+ name: t.name,
149
+ })),
150
+ reasoningLevels: Array.isArray(model.supported_reasoning_levels)
151
+ ? model.supported_reasoning_levels.flatMap((v) => isRecord(v) && safe(v.effort) ? [v.effort] : [])
152
+ : [],
153
+ accessPrograms: isRecord(model.available_access_programs)
154
+ ? Object.entries(model.available_access_programs).flatMap(([category, values]) => safe(category) && Array.isArray(values)
155
+ ? values.filter(safe).map((v) => `${category}:${v}`)
156
+ : [])
157
+ : [],
158
+ };
159
+ }
@@ -24,6 +24,7 @@ export interface RuntimePolicyDecision {
24
24
  blockedAccountIndexes: Set<number>;
25
25
  blockedAccountReasons?: Record<number, string>;
26
26
  scoreBoostByAccount: Record<number, number>;
27
+ priorityByAccount?: Record<number, number>;
27
28
  budgetEvaluations: BudgetGuardEvaluation[];
28
29
  }
29
30
  export interface RuntimePolicyState {
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-policy.d.ts","sourceRoot":"","sources":["../../../lib/policy/runtime-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAErE,OAAO,EAGN,KAAK,kBAAkB,EACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAKN,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EACrB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAEN,KAAK,4BAA4B,EACjC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,oBAAoB,EAGpB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,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C1B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,oBAAoB,CAAC;CACrC,GAAG,oBAAoB,CAiCvB"}
@@ -72,6 +72,7 @@ export async function evaluateRuntimePolicy(input) {
72
72
  const blockedAccountIndexes = new Set();
73
73
  const blockedAccountReasons = {};
74
74
  const scoreBoostByAccount = {};
75
+ const priorityByAccount = {};
75
76
  const profile = input.state.project.profile;
76
77
  if (profile?.modelDenylist.length && matchesModel(profile.modelDenylist, input.model)) {
77
78
  reasons.push("routing profile denies requested model");
@@ -101,6 +102,7 @@ export async function evaluateRuntimePolicy(input) {
101
102
  refreshToken: account.refreshToken ?? undefined,
102
103
  }, account.index);
103
104
  const accountPolicy = input.state.accountPolicies.accounts[accountKey];
105
+ priorityByAccount[account.index] = accountPolicy?.priority ?? 1;
104
106
  let boost = 0;
105
107
  if (accountPolicy?.paused) {
106
108
  blockedAccountIndexes.add(account.index);
@@ -155,6 +157,7 @@ export async function evaluateRuntimePolicy(input) {
155
157
  blockedAccountIndexes,
156
158
  blockedAccountReasons,
157
159
  scoreBoostByAccount,
160
+ priorityByAccount,
158
161
  budgetEvaluations,
159
162
  };
160
163
  }
@@ -58,6 +58,8 @@ export declare class PreemptiveQuotaScheduler {
58
58
  * silent clear-all; use `clearAll()` when that is the intent.
59
59
  */
60
60
  clearByPrefix(prefix: string): void;
61
+ /** Forget one verified recovered model; preserve sibling quota buckets. */
62
+ clear(key: string): void;
61
63
  /** Forget every cached quota observation. */
62
64
  clearAll(): void;
63
65
  prune(now?: number): number;
@@ -1 +1 @@
1
- {"version":3,"file":"preemptive-quota-scheduler.d.ts","sourceRoot":"","sources":["../../lib/preemptive-quota-scheduler.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,oBAAoB;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED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OAAO,CAAC,WAAW,CAAK;gBAEZ,OAAO,GAAE,qBAA0B;IAQ/C,SAAS,CAAC,OAAO,GAAE,qBAA0B,GAAG,IAAI;IA2CpD,OAAO,CAAC,UAAU;IAMlB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,sBAAsB,GAAG,IAAI;IAM3D,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,SAAa,GAAG,IAAI;IA8B1E,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,SAAa,GAAG,qBAAqB;IAkEjE;;;;;;;;OAQG;IACH,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAOnC,2EAA2E;IAC3E,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAIxB,6CAA6C;IAC7C,QAAQ,IAAI,IAAI;IAIhB,KAAK,CAAC,GAAG,SAAa,GAAG,MAAM;CAW/B"}
@@ -281,6 +281,10 @@ export class PreemptiveQuotaScheduler {
281
281
  this.snapshots.delete(key);
282
282
  }
283
283
  }
284
+ /** Forget one verified recovered model; preserve sibling quota buckets. */
285
+ clear(key) {
286
+ this.snapshots.delete(key);
287
+ }
284
288
  /** Forget every cached quota observation. */
285
289
  clearAll() {
286
290
  this.snapshots.clear();
@@ -1 +1 @@
1
- {"version":3,"file":"codex.d.ts","sourceRoot":"","sources":["../../../lib/prompts/codex.ts"],"names":[],"mappings":"AAOA,OAAO,EAAkC,KAAK,WAAW,EAAE,MAAM,iCAAiC,CAAC;AA4EnG;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAI7C;AAcD,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,YAAY,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAyBnE;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,eAAe,EAAE,MAAM,GAAG,WAAW,CAEnE;AA4ED;;;;;;;;;GASG;AACH,wBAAsB,oBAAoB,CACzC,eAAe,SAAgB,GAC7B,OAAO,CAAC,MAAM,CAAC,CAkHjB;AA6GD;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,GAAE,MAAM,EAAO,GAAG,IAAI,CAiBpE;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,ozGA+EV,CAAC"}
1
+ {"version":3,"file":"codex.d.ts","sourceRoot":"","sources":["../../../lib/prompts/codex.ts"],"names":[],"mappings":"AAOA,OAAO,EAAkC,KAAK,WAAW,EAAE,MAAM,iCAAiC,CAAC;AA4EnG;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAI7C;AAcD,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,YAAY,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAyBnE;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,eAAe,EAAE,MAAM,GAAG,WAAW,CAEnE;AA4ED;;;;;;;;;GASG;AACH,wBAAsB,oBAAoB,CACzC,eAAe,SAAgB,GAC7B,OAAO,CAAC,MAAM,CAAC,CAkHjB;AA6GD;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,GAAE,MAAM,EAAO,GAAG,IAAI,CAmBpE;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,ozGA+EV,CAAC"}
@@ -359,7 +359,9 @@ function refreshInstructionsInBackground(modelFamily, promptFile, cacheFile, cac
359
359
  * Prewarm instruction caches for the provided models/families.
360
360
  */
361
361
  export function prewarmCodexInstructions(models = []) {
362
- const candidates = models.length > 0 ? models : [DEFAULT_MODEL, "gpt-5.3-codex", "gpt-5.1"];
362
+ // Every live model is in the gpt-5.2 prompt family now that the codex and
363
+ // gpt-5.1 models are retired, so the default model alone covers the prewarm.
364
+ const candidates = models.length > 0 ? models : [DEFAULT_MODEL];
363
365
  const prewarmTargets = new Map();
364
366
  for (const model of candidates) {
365
367
  const promptFamily = getModelFamily(model);
@@ -1,3 +1,4 @@
1
+ import { FirstUseProbeError } from "./runtime/subscription-first-use.js";
1
2
  /**
2
3
  * Human-readable note shown when a live probe fails solely because the account
3
4
  * lacks Codex entitlement (see {@link CodexUnavailableError}). Centralized so
@@ -25,6 +26,8 @@ export interface CodexQuotaWindow {
25
26
  resetAtMs?: number;
26
27
  }
27
28
  export interface CodexQuotaSnapshot {
29
+ primingCompleted?: boolean;
30
+ primingFailure?: FirstUseProbeError["reason"];
28
31
  status: number;
29
32
  planType?: string;
30
33
  activeLimit?: number;
@@ -57,6 +60,8 @@ export declare function formatQuotaResetAt(resetAtMs: number | undefined, nowMs?
57
60
  */
58
61
  export declare function formatQuotaSnapshotLine(snapshot: CodexQuotaSnapshot): string;
59
62
  export interface ProbeCodexQuotaOptions {
63
+ signal?: AbortSignal;
64
+ primeUnusedSubscription?: boolean;
60
65
  accountId: string;
61
66
  accessToken: string;
62
67
  model?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"quota-probe.d.ts","sourceRoot":"","sources":["../../lib/quota-probe.ts"],"names":[],"mappings":"AAYA;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,yCAAyC,CAAC;AAEnF;;;;;;;;;;;;GAYG;AACH,wBAAgB,yBAAyB,CACxC,KAAK,EAAE,OAAO,EACd,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,GACrC,MAAM,CAMR;AAED,MAAM,WAAW,gBAAgB;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,kBAAkB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,gBAAgB,CAAC;IAC1B,SAAS,EAAE,gBAAgB,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;CACd;A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AW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,gBAAgB,CAAC;IAC1B,SAAS,EAAE,gBAAgB,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;CACd;AAiND;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CACjC,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,KAAK,SAAa,GAChB,MAAM,GAAG,SAAS,CAqBpB;AAwBD;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,kBAAkB,GAAG,MAAM,CAa5E;AAED,MAAM,WAAW,sBAAsB;IACtC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,uBAAuB,CAC5C,OAAO,EAAE,sBAAsB,GAC7B,OAAO,CAAC,kBAAkB,CAAC,CA0H7B"}
@@ -1,10 +1,11 @@
1
- import { CODEX_BASE_URL } from "./constants.js";
1
+ import { CODEX_BASE_URL, MAX_RATE_LIMIT_DELAY_MS } from "./constants.js";
2
2
  import { createCodexHeaders, getUnsupportedCodexModelInfo } from "./request/fetch-helpers.js";
3
3
  import { QUOTA_PROBE_MODEL_CHAIN, resolveProbeReasoningEffort, } from "./request/helpers/model-map.js";
4
4
  import { CodexUnavailableError, isCodexUnavailableError } from "./errors.js";
5
5
  import { getCodexInstructions } from "./prompts/codex.js";
6
6
  import { mutateRuntimeObservabilitySnapshot } from "./runtime/runtime-observability.js";
7
7
  import { isRecord } from "./utils.js";
8
+ import { FirstUseProbeError, finishSubscriptionFirstUse, needsSubscriptionFirstUse } from "./runtime/subscription-first-use.js";
8
9
  /**
9
10
  * Human-readable note shown when a live probe fails solely because the account
10
11
  * lacks Codex entitlement (see {@link CodexUnavailableError}). Centralized so
@@ -79,6 +80,12 @@ function parseFiniteIntHeader(headers, name) {
79
80
  * Security: does not emit or persist header values; callers must redact any sensitive tokens before storing or logging headers.
80
81
  */
81
82
  function parseResetAtMs(headers, prefix) {
83
+ const raw = parseUnboundedResetAtMs(headers, prefix);
84
+ // A bogus header (finite, but overflowing once scaled to ms) must not read as
85
+ // a window that never resets.
86
+ return raw === undefined || Number.isNaN(raw) ? undefined : Math.min(raw, Date.now() + MAX_RATE_LIMIT_DELAY_MS);
87
+ }
88
+ function parseUnboundedResetAtMs(headers, prefix) {
82
89
  const resetAfterSeconds = parseFiniteIntHeader(headers, `${prefix}-reset-after-seconds`);
83
90
  if (typeof resetAfterSeconds === "number" && resetAfterSeconds > 0) {
84
91
  return Date.now() + resetAfterSeconds * 1000;
@@ -324,9 +331,11 @@ export async function fetchCodexQuotaSnapshot(options) {
324
331
  let sawUnsupportedModel = false;
325
332
  let sawOtherFailure = false;
326
333
  for (const model of models) {
334
+ options.signal?.throwIfAborted();
327
335
  attemptedAnyModel = true;
328
336
  try {
329
337
  const instructions = await getCodexInstructions(model);
338
+ options.signal?.throwIfAborted();
330
339
  const probeBody = {
331
340
  model,
332
341
  stream: true,
@@ -362,7 +371,7 @@ export async function fetchCodexQuotaSnapshot(options) {
362
371
  method: "POST",
363
372
  headers,
364
373
  body: JSON.stringify(probeBody),
365
- signal: controller.signal,
374
+ signal: options.signal ? AbortSignal.any([controller.signal, options.signal]) : controller.signal,
366
375
  });
367
376
  }
368
377
  finally {
@@ -370,6 +379,18 @@ export async function fetchCodexQuotaSnapshot(options) {
370
379
  }
371
380
  const snapshotBase = parseQuotaSnapshotBase(response.headers, response.status);
372
381
  if (snapshotBase) {
382
+ if (options.primeUnusedSubscription && needsSubscriptionFirstUse(snapshotBase, Date.now())) {
383
+ try {
384
+ await finishSubscriptionFirstUse(response, timeoutMs);
385
+ return { ...snapshotBase, model, primingCompleted: true };
386
+ }
387
+ catch (error) {
388
+ // Keep valid quota data without retrying an accepted inference.
389
+ if (error instanceof FirstUseProbeError)
390
+ return { ...snapshotBase, model, primingFailure: error.reason };
391
+ throw error;
392
+ }
393
+ }
373
394
  try {
374
395
  await response.body?.cancel();
375
396
  }
@@ -406,6 +427,9 @@ export async function fetchCodexQuotaSnapshot(options) {
406
427
  lastError = new Error("Codex response did not include quota headers");
407
428
  }
408
429
  catch (error) {
430
+ options.signal?.throwIfAborted();
431
+ if (error instanceof FirstUseProbeError)
432
+ throw error;
409
433
  sawOtherFailure = true;
410
434
  lastError = error instanceof Error ? error : new Error(String(error));
411
435
  }
@@ -0,0 +1,5 @@
1
+ /** Internal transport marker: upstream timeouts may also use AbortError. */
2
+ export declare class ClientCancellationError extends Error {
3
+ constructor();
4
+ }
5
+ //# sourceMappingURL=client-cancellation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-cancellation.d.ts","sourceRoot":"","sources":["../../../lib/request/client-cancellation.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,qBAAa,uBAAwB,SAAQ,KAAK;;CAKjD"}
@@ -0,0 +1,7 @@
1
+ /** Internal transport marker: upstream timeouts may also use AbortError. */
2
+ export class ClientCancellationError extends Error {
3
+ constructor() {
4
+ super("Client cancelled request");
5
+ this.name = "AbortError";
6
+ }
7
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"error-classification.d.ts","sourceRoot":"","sources":["../../../lib/request/error-classification.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,MAAM,WAAW,gBAAgB;IACzB,aAAa,EAAE,IAAI,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACvB;AAED,sGAAsG;AACtG,eAAO,MAAM,oCAAoC,6CAA6C,CAAC;AAQ/F,eAAO,MAAM,wCAAwC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAoD7E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QAAQ,EAAE,MAAM,GACrB,OAAO,CAoDT;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,8BAA8B,CAAC,SAAS,EAAE,MAAM,GAAG,QAAQ,CAmB1E"}
1
+ {"version":3,"file":"error-classification.d.ts","sourceRoot":"","sources":["../../../lib/request/error-classification.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,MAAM,WAAW,gBAAgB;IACzB,aAAa,EAAE,IAAI,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACvB;AAED,sGAAsG;AACtG,eAAO,MAAM,oCAAoC,6CAA6C,CAAC;AAQ/F,eAAO,MAAM,wCAAwC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAmE7E,CAAC;AAEF,MAAM,WAAW,yBAAyB;IACzC,aAAa,EAAE,OAAO,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,sCAAsC;IACtD,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,SAAS,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IACnC,+BAA+B,EAAE,OAAO,CAAC;IACzC,iCAAiC,EAAE,OAAO,CAAC;IAC3C,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CACvC;AAiDD,wBAAgB,oCAAoC,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAgBzF;AAED,sGAAsG;AACtG,wBAAgB,iCAAiC,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAQ3F;AAED,wBAAgB,4BAA4B,CAC3C,SAAS,EAAE,OAAO,GAChB,yBAAyB,CAqD3B;AAED,wBAAgB,oCAAoC,CACnD,OAAO,EAAE,sCAAsC,GAC7C,MAAM,GAAG,SAAS,CAkCpB;AAED;;GAEG;AACH,wBAAgB,uCAAuC,CACtD,cAAc,EAAE,MAAM,GAAG,SAAS,EAClC,SAAS,EAAE,OAAO,GAChB,OAAO,CAgBT;AAqCD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CACrC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACd,OAAO,CAIT;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAK1E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAChC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,QAAQ,EAAE,MAAM,GACrB,OAAO,CAoDT;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,8BAA8B,CAAC,SAAS,EAAE,MAAM,GAAG,QAAQ,CAmB1E"}
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import { isRecord } from "../utils.js";
7
7
  import { HTTP_STATUS, stripModelEffortSuffix } from "../constants.js";
8
+ import { RETIRED_MODEL_REPLACEMENTS } from "./helpers/model-map.js";
8
9
  /** @internal Exported only for sibling lib/request modules; import via fetch-helpers.ts elsewhere. */
9
10
  export const CHATGPT_CODEX_UNSUPPORTED_MODEL_CODE = "model_not_supported_with_chatgpt_account";
10
11
  const CHATGPT_CODEX_UNSUPPORTED_MODEL_PATTERN = /model is not supported when using codex with a chatgpt account/i;
@@ -26,42 +27,55 @@ export const DEFAULT_UNSUPPORTED_CODEX_FALLBACK_CHAIN = {
26
27
  //
27
28
  // Depth is not free: every hop spends one of the shared per-request outbound
28
29
  // attempts (`tryConsumeOutboundRequestAttempt`). A single-account balanced
29
- // session gets a budget of 5, and the aeon walk needs exactly 5, so it fits
30
- // with nothing spare. Spend an attempt on a retry or a stream failover and
31
- // the tail hops become unreachable, ending as an attempt-budget-exhausted
32
- // 503 rather than `gpt-5.4`. Hops are ordered most-valuable-first so what is
33
- // lost first matters least. Do not add a hop to a GPT-6 row without
30
+ // session gets a budget of 5, and the aeon walk needs 4 (it needed all 5
31
+ // until `gpt-5.4` was retired as the floor), leaving one attempt for a retry
32
+ // or a stream failover. Spend two and the tail hop becomes unreachable,
33
+ // ending as an attempt-budget-exhausted 503 rather than `gpt-5.5`. Hops are
34
+ // ordered most-valuable-first so what is lost first matters least. Do not
35
+ // add a hop to a GPT-6 row without
34
36
  // re-checking that budget; `test/gpt6-astra-models.test.ts` asserts it.
35
37
  "gpt-6-astra": ["gpt-5.6-sol", "gpt-5.5"],
36
38
  // aeon steps to the flagship first: still GPT-6, still Astra, just without
37
39
  // the long-horizon behaviour.
38
40
  "gpt-6-astra-aeon": ["gpt-6-astra", "gpt-5.6-sol"],
41
+ // Sol and Luna step to the 5.6 tier they replace, never sideways into Astra:
42
+ // an account without the new tier is far likelier to lack Astra too, and
43
+ // Astra is the priciest hop available ($10/$50 per 1M against Luna's
44
+ // $0.10/$0.50). Every hop on these walks still costs more than Luna itself.
45
+ "gpt-6-sol": ["gpt-5.6-sol"],
46
+ "gpt-6-luna": ["gpt-5.6-luna"],
39
47
  // The hop that makes the Astra path reach a model every account has. GPT-5.6
40
48
  // shipped without a chain entry, so an unsupported 5.6 response ended the
41
49
  // walk; with Astra above it that would have stranded the fallback one rung
42
- // short of the floor it documents. Terra and Luna are deliberately still
43
- // absent: nothing steps into them, so giving them a hop would change 5.6
44
- // behaviour beyond completing this path.
50
+ // short of the floor it documents.
45
51
  "gpt-5.6-sol": ["gpt-5.5"],
52
+ // Luna gained its row once `gpt-6-luna` started stepping into it; without
53
+ // it the Luna walk would stop one rung short of `gpt-5.5`, the same
54
+ // stranding the Sol row fixed. It also applies to a direct `gpt-5.6-luna`
55
+ // request, which used to end its walk on an unsupported response and now
56
+ // retries on the pricier `gpt-5.5`.
57
+ "gpt-5.6-luna": ["gpt-5.5"],
58
+ // Terra gained its row once the retired codex minis and `gpt-5-mini` began
59
+ // stepping into it; without it those walks stopped at Terra instead of the
60
+ // `gpt-5.5` floor every other retired id reaches.
61
+ "gpt-5.6-terra": ["gpt-5.5"],
46
62
  "gpt-5": ["gpt-5.5"],
47
63
  "gpt-5-pro": ["gpt-5.5-pro"],
48
- "gpt-5-chat-latest": ["gpt-5.5"],
49
- "gpt-5.5": ["gpt-5.4"],
50
- "gpt-5.5-pro": ["gpt-5.4"],
51
- "gpt-5.5-2026-04-23": ["gpt-5.4"],
52
- "gpt-5.5-pro-2026-04-23": ["gpt-5.4"],
53
- "gpt-5.5-20260423": ["gpt-5.4"],
54
- "gpt-5.5-pro-20260423": ["gpt-5.4"],
55
- "gpt-5.3-codex-spark": ["gpt-5.3-codex", "gpt-5.2-codex"],
56
- "gpt-5.3-codex": ["gpt-5.2-codex"],
57
- "codex-max": ["gpt-5.3-codex"],
58
- "gpt-5.1-codex-max": ["gpt-5.3-codex"],
59
- "codex-mini-latest": ["gpt-5.3-codex"],
60
- "gpt-5-codex-mini": ["gpt-5.3-codex"],
61
- "gpt-5.1-codex-mini": ["gpt-5.3-codex"],
62
- "gpt-5-codex": ["gpt-5.3-codex", "gpt-5.2-codex"],
63
- "gpt-5.2-codex": ["gpt-5.3-codex"],
64
- "gpt-5.1-codex": ["gpt-5.3-codex"],
64
+ "gpt-5.5-2026-04-23": ["gpt-5.5"],
65
+ "gpt-5.5-20260423": ["gpt-5.5"],
66
+ "gpt-5.5-pro-2026-04-23": ["gpt-5.5-pro"],
67
+ "gpt-5.5-pro-20260423": ["gpt-5.5-pro"],
68
+ // `gpt-5.5` and `gpt-5.5-pro` are the floor: they used to step to `gpt-5.4`,
69
+ // which the Codex backend no longer serves (`retirement_at: 2026-08-31` in
70
+ // the upstream catalog), so that hop could only ever fail.
71
+ //
72
+ // A retired id still reaches the backend verbatim through the pass-through
73
+ // rotation proxy, and the backend rejects it as unsupported. One hop to the
74
+ // replacement OpenAI names for it turns that into a working request.
75
+ ...Object.fromEntries(Object.entries(RETIRED_MODEL_REPLACEMENTS).map(([retired, replacement]) => [
76
+ retired,
77
+ [replacement],
78
+ ])),
65
79
  };
66
80
  function canonicalizeModelName(model) {
67
81
  if (!model)
@@ -252,7 +252,7 @@ function normalizeErrorPayload(errorBody, bodyText, statusText, status, diagnost
252
252
  error: {
253
253
  message: `The model '${unsupportedModel}' is not currently available for this ChatGPT account when using Codex OAuth. ` +
254
254
  "This is an account/workspace entitlement gate, not a temporary rate limit. " +
255
- "Try 'gpt-5.3-codex' (current), or legacy aliases like 'gpt-5-codex'/'gpt-5.2-codex', or enable automatic fallback via " +
255
+ "Try 'gpt-5.6-sol' or 'gpt-5.5', or enable automatic fallback via " +
256
256
  'unsupportedCodexPolicy: "fallback" (or CODEX_AUTH_UNSUPPORTED_MODEL_POLICY=fallback). ' +
257
257
  "(Legacy: CODEX_AUTH_FALLBACK_UNSUPPORTED_MODEL=1 or fallbackOnUnsupportedCodexModel).",
258
258
  type: "entitlement_error",
@@ -31,10 +31,18 @@ export interface ModelProfile {
31
31
  supportedReasoningEfforts: readonly ModelReasoningEffort[];
32
32
  capabilities: ModelCapabilities;
33
33
  }
34
- export declare const CURRENT_CODEX_MODEL = "gpt-5.3-codex";
34
+ /**
35
+ * Where every codex-named id routes. No codex model is left: upstream Codex
36
+ * dropped `gpt-5.3-codex` from its catalog on 2026-07-08, and OpenAI's
37
+ * deprecations page names `gpt-5.6-sol` as the replacement for every retired
38
+ * codex id (`gpt-5-codex`, `gpt-5.1-codex*`, `gpt-5.2-codex`). The export
39
+ * keeps its name so callers that mean "the model a codex request runs on"
40
+ * still read naturally.
41
+ */
42
+ export declare const CURRENT_CODEX_MODEL = "gpt-5.6-sol";
35
43
  export declare const DEFAULT_MODEL = "gpt-5.5";
36
44
  export declare const DEFAULT_PROBE_MODEL = "gpt-5.6-sol";
37
- export declare const QUOTA_PROBE_MODEL_CHAIN: readonly ["gpt-5.6-sol", "gpt-5.5", "gpt-5.4", "gpt-5.3-codex", "gpt-5.2-codex", "gpt-5-codex"];
45
+ export declare const QUOTA_PROBE_MODEL_CHAIN: readonly ["gpt-5.6-sol", "gpt-5.5", "gpt-6-luna"];
38
46
  /**
39
47
  * Effective model profiles keyed by canonical model name.
40
48
  *
@@ -45,6 +53,8 @@ export declare const QUOTA_PROBE_MODEL_CHAIN: readonly ["gpt-5.6-sol", "gpt-5.5"
45
53
  */
46
54
  export declare const MODEL_PROFILES: Record<string, ModelProfile>;
47
55
  declare const MODEL_MAP: Record<string, string>;
56
+ /** Every retired id and its replacement, for diagnostics and tests. */
57
+ export declare const RETIRED_MODEL_REPLACEMENTS: Readonly<Record<string, string>>;
48
58
  export { MODEL_MAP };
49
59
  /**
50
60
  * Get normalized model name from a known config/runtime identifier.
@@ -1 +1 @@
1
- {"version":3,"file":"model-map.d.ts","sourceRoot":"","sources":["../../../../lib/request/helpers/model-map.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,KAAK,EACX,oBAAoB,EACpB,mBAAmB,EACnB,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,CAAC;AAE1D,MAAM,MAAM,iBAAiB,GAC1B,aAAa,GACb,WAAW,GACX,OAAO,GACP,SAAS,GACT,SAAS,CAAC;AAEb;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,iBAAiB,CAAC;AAE5C;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,SAAS,WAAW,EAMvC,CAAC;AAEX,MAAM,WAAW,iBAAiB;IACjC,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,iBAAiB,CAAC;IAChC,sBAAsB,EAAE,oBAAoB,CAAC;IAC7C,yBAAyB,EAAE,SAAS,oBAAoB,EAAE,CAAC;IAC3D,YAAY,EAAE,iB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