@bitkyc08/opencodex 2.99.0 → 2.100.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (276) hide show
  1. package/AGENTS_INSTALL.md +19 -1
  2. package/README.md +37 -33
  3. package/SPONSORS.md +5 -1
  4. package/bin/ocx.mjs +1 -1
  5. package/gui/dist/assets/{App-C1hGwaN1.css → App-COo8Yopd.css} +1 -1
  6. package/gui/dist/assets/App-g3Cm2xhZ.js +59 -0
  7. package/gui/dist/assets/Tray-BMDkAiXy.js +1 -0
  8. package/gui/dist/assets/brand-mark-nr3ziR-T.js +1 -0
  9. package/gui/dist/assets/index-Bziu8gTy.css +2 -0
  10. package/gui/dist/assets/index-OYzhQUNP.js +94 -0
  11. package/gui/dist/assets/{segment-thumb-features-fYEMxBaW.js → segment-thumb-features-DKCVUUTi.js} +1 -1
  12. package/gui/dist/classic/assets/App-CgPBKUP-.js +58 -0
  13. package/gui/dist/classic/assets/{Tray-BqZueZOx.js → Tray-BedmOsE7.js} +1 -1
  14. package/gui/dist/classic/assets/index-BR-HhNrp.js +94 -0
  15. package/gui/dist/classic/assets/quota-summary-CXKhvSmQ.js +1 -0
  16. package/gui/dist/classic/index.html +1 -1
  17. package/gui/dist/index.html +2 -2
  18. package/native/ocx-child/Cargo.lock +215 -0
  19. package/native/ocx-child/Cargo.toml +31 -0
  20. package/native/ocx-child/src/cli.rs +1901 -0
  21. package/native/ocx-child/src/codex_home.rs +429 -0
  22. package/native/ocx-child/src/codex_settings.rs +231 -0
  23. package/native/ocx-child/src/daemon.rs +363 -0
  24. package/native/ocx-child/src/http_wire.rs +619 -0
  25. package/native/ocx-child/src/journal.rs +977 -0
  26. package/native/ocx-child/src/lib.rs +22 -0
  27. package/native/ocx-child/src/main.rs +9 -0
  28. package/native/ocx-child/src/parity.rs +102 -0
  29. package/native/ocx-child/src/platform.rs +1487 -0
  30. package/native/ocx-child/src/relay.rs +1288 -0
  31. package/native/ocx-child/src/relay_auth.rs +166 -0
  32. package/native/ocx-child/src/routes.rs +236 -0
  33. package/native/ocx-child/src/state.rs +190 -0
  34. package/native/ocx-child/src/test_hooks.rs +58 -0
  35. package/native/ocx-child/src/toml_surgeon.rs +1156 -0
  36. package/package.json +8 -2
  37. package/src/adapters/anthropic-image-normalize.ts +1 -1
  38. package/src/adapters/anthropic.ts +28 -2
  39. package/src/adapters/claude-cli/adapter.ts +5 -25
  40. package/src/adapters/claude-cli/instruction-images.ts +31 -0
  41. package/src/adapters/claude-cli/stable-replay.ts +42 -14
  42. package/src/adapters/claude-cli/usage-admission.ts +53 -64
  43. package/src/adapters/client-fingerprint.ts +1 -1
  44. package/src/adapters/coding-agent/protocol.ts +1 -1
  45. package/src/adapters/devin/live-models.ts +3 -0
  46. package/src/adapters/google-http.ts +3 -0
  47. package/src/adapters/google-vertex-key-project.ts +10 -2
  48. package/src/adapters/google.ts +40 -8
  49. package/src/adapters/kiro/usage.ts +3 -13
  50. package/src/adapters/openai-chat/mistral-image-limit.ts +28 -15
  51. package/src/adapters/openai-chat-images.ts +100 -0
  52. package/src/adapters/openai-chat.ts +6 -9
  53. package/src/adapters/openai-responses/passthrough.ts +5 -2
  54. package/src/adapters/openai-responses/request-strips.ts +32 -0
  55. package/src/adapters/openai-responses/tool-schema.ts +9 -4
  56. package/src/chat/inbound.ts +1 -1
  57. package/src/claude/auth-detect.ts +26 -8
  58. package/src/claude/inbound-content-options.ts +18 -3
  59. package/src/claude/inbound.ts +5 -2
  60. package/src/cli/bundled-bun-diagnostic.ts +91 -0
  61. package/src/cli/capabilities-agents-routing.ts +2 -2
  62. package/src/cli/capabilities-observe-system.ts +60 -0
  63. package/src/cli/combo-input.ts +6 -0
  64. package/src/cli/combo-result.ts +1 -1
  65. package/src/cli/combo.ts +4 -0
  66. package/src/cli/config-command.ts +16 -2
  67. package/src/cli/connect.ts +12 -10
  68. package/src/cli/dispatch.ts +4 -0
  69. package/src/cli/doctor.ts +11 -0
  70. package/src/cli/help.ts +1 -0
  71. package/src/cli/init.ts +4 -0
  72. package/src/cli/link-enrollment.ts +152 -25
  73. package/src/cli/link-local-control.ts +49 -0
  74. package/src/cli/link.ts +37 -10
  75. package/src/cli/provider-lifecycle-runtime.ts +4 -2
  76. package/src/cli/registry.ts +13 -0
  77. package/src/cli/star-prompt.ts +2 -0
  78. package/src/cli/status.ts +1 -1
  79. package/src/cli/telemetry-profile.ts +206 -0
  80. package/src/cli/telemetry.ts +260 -0
  81. package/src/client/hub-relay.ts +26 -0
  82. package/src/client/machine-api.ts +3 -0
  83. package/src/clients/config-export/t3code.ts +44 -5
  84. package/src/clients/omo-role-models.ts +1 -1
  85. package/src/codex/catalog/bundled.ts +44 -2
  86. package/src/codex/runtime.ts +12 -0
  87. package/src/codex/shim-restore-lock.ts +67 -30
  88. package/src/combos/types.ts +21 -1
  89. package/src/config/atomic-write.ts +24 -1
  90. package/src/config/diagnostics.ts +15 -0
  91. package/src/config/live-reconcile.ts +17 -0
  92. package/src/config/load-degrade.ts +16 -0
  93. package/src/config/provider-validation.ts +29 -0
  94. package/src/config/schema/config-schema.ts +24 -0
  95. package/src/config/schema/leaf-validators.ts +17 -0
  96. package/src/config/telemetry-carry.ts +30 -0
  97. package/src/config.ts +13 -1
  98. package/src/generated/compatibility-version.json +422 -170
  99. package/src/generated/model-metadata.ts +3 -3
  100. package/src/integrations/aside-profiles.ts +7 -1
  101. package/src/integrations/owned-refresh.ts +9 -2
  102. package/src/lab/artifacts/secure-fs.ts +12 -11
  103. package/src/lab/fabric/scratch.ts +11 -9
  104. package/src/lab/public/community.ts +2 -3
  105. package/src/lab/public/file-safety.ts +18 -20
  106. package/src/lab/public/mutation-lock.ts +109 -337
  107. package/src/lab/public/private-file.ts +4 -3
  108. package/src/lib/bun-runtime-preflight.ts +1 -1
  109. package/src/lib/codex-catalog-read-only.ts +122 -0
  110. package/src/lib/config-ownership.ts +56 -18
  111. package/src/lib/errors.ts +11 -0
  112. package/src/lib/gcp-adc.ts +167 -48
  113. package/src/lib/jsonc.ts +4 -2
  114. package/src/lib/local-control-socket.ts +88 -0
  115. package/src/lib/privacy.ts +15 -0
  116. package/src/lib/provider-client-headers.ts +3 -0
  117. package/src/lib/token-estimate.ts +13 -2
  118. package/src/link/child-binary-source.ts +228 -0
  119. package/src/link/ephemeral-child.ts +45 -0
  120. package/src/link/remote-plant.ts +306 -0
  121. package/src/link/remote-windows.ts +59 -5
  122. package/src/link/ssh-argv.ts +71 -8
  123. package/src/link/status-projection.ts +2 -0
  124. package/src/link/store.ts +5 -1
  125. package/src/oauth/anthropic-model-quota.ts +12 -0
  126. package/src/oauth/anthropic-routing.ts +11 -4
  127. package/src/oauth/claude-keychain-read.ts +165 -0
  128. package/src/oauth/kiro-iam-identity-center.ts +4 -1
  129. package/src/oauth/local-token-detect.ts +14 -17
  130. package/src/protocols/envelope.ts +20 -2
  131. package/src/providers/api-key-selection.ts +8 -2
  132. package/src/providers/claude-cli-identity.ts +9 -3
  133. package/src/providers/claude-cli-usage-state.ts +93 -0
  134. package/src/providers/claude-cli-usage.ts +3 -2
  135. package/src/providers/github-copilot-auto.ts +25 -5
  136. package/src/providers/meta-muse-plan-refusal.ts +94 -0
  137. package/src/providers/model-rename-fields.ts +3 -0
  138. package/src/providers/quota/anthropic-family-headers.ts +8 -1
  139. package/src/providers/quota/anthropic-usage-windows.ts +49 -2
  140. package/src/providers/quota/vendor-probes-key.ts +23 -4
  141. package/src/providers/quota/vendor-probes-oauth.ts +59 -0
  142. package/src/providers/quota/workbuddy.ts +2 -2
  143. package/src/providers/quota-types.ts +7 -0
  144. package/src/providers/quota.ts +25 -18
  145. package/src/providers/registry/entries-core.ts +7 -4
  146. package/src/providers/registry/entries-extended.ts +42 -8
  147. package/src/providers/registry/model-ids.ts +1 -0
  148. package/src/providers/registry/model-seeds.ts +10 -2
  149. package/src/providers/registry/types.ts +6 -0
  150. package/src/providers/resolved-model-policy.ts +4 -0
  151. package/src/providers/routed-config.ts +30 -3
  152. package/src/providers/stale-no-vision-seed-migration.ts +7 -0
  153. package/src/providers/vertex-environment-authority.ts +50 -0
  154. package/src/providers/workbuddy-credit-balance.ts +38 -6
  155. package/src/quota-pool/assemble.ts +14 -6
  156. package/src/responses/retained-compaction.ts +31 -5
  157. package/src/router.ts +1 -0
  158. package/src/server/adapter-resolve.ts +11 -6
  159. package/src/server/audio-dictation.ts +21 -7
  160. package/src/server/auth-cors.ts +19 -0
  161. package/src/server/background-lifecycle.ts +71 -0
  162. package/src/server/chat-completions.ts +2 -0
  163. package/src/server/claude-messages.ts +30 -3
  164. package/src/server/index/live-sideband.ts +15 -1
  165. package/src/server/index/local-control-listener.ts +515 -0
  166. package/src/server/index/optional-listeners.ts +21 -1
  167. package/src/server/index/serve-options.ts +4 -3
  168. package/src/server/index/websocket-handler.ts +2 -0
  169. package/src/server/index.ts +3 -0
  170. package/src/server/management/combo-routes.ts +6 -1
  171. package/src/server/management/context.ts +1 -0
  172. package/src/server/management/link-child-preflight.ts +74 -0
  173. package/src/server/management/link-enrollment.ts +190 -25
  174. package/src/server/management/link-route-state.ts +6 -1
  175. package/src/server/management/link-routes.ts +27 -9
  176. package/src/server/management/model-rows.ts +4 -0
  177. package/src/server/management/oauth-account-routes.ts +9 -4
  178. package/src/server/management/provider-overwrite-carry.ts +9 -2
  179. package/src/server/management/provider-routes.ts +14 -0
  180. package/src/server/management/provider-thinking-display-patch.ts +54 -0
  181. package/src/server/management/route-registry.ts +7 -0
  182. package/src/server/management/session-routes.ts +4 -1
  183. package/src/server/management/telemetry-routes.ts +37 -0
  184. package/src/server/management/usage-aggregate-cache.ts +290 -67
  185. package/src/server/management-api.ts +11 -2
  186. package/src/server/messages-native-preflight.ts +166 -0
  187. package/src/server/messages-native.ts +143 -43
  188. package/src/server/messages-shared.ts +14 -0
  189. package/src/server/proxy-liveness.ts +99 -6
  190. package/src/server/request-log-conversation.ts +18 -2
  191. package/src/server/request-log.ts +7 -2
  192. package/src/server/responses/adapter-continuation.ts +1 -0
  193. package/src/server/responses/adapter-dispatch.ts +11 -28
  194. package/src/server/responses/adapter-failure-message.ts +68 -0
  195. package/src/server/responses/combo-stream-preflight.ts +14 -2
  196. package/src/server/responses/compact.ts +13 -1
  197. package/src/server/responses/core-auth.ts +26 -5
  198. package/src/server/responses/core-codex-account.ts +8 -1
  199. package/src/server/responses/core-combo-failure.ts +6 -1
  200. package/src/server/responses/core-combo-native.ts +150 -37
  201. package/src/server/responses/core-combo.ts +15 -9
  202. package/src/server/responses/core-normalize.ts +1 -0
  203. package/src/server/responses/core-options.ts +7 -1
  204. package/src/server/responses/core-pipeline.ts +21 -1
  205. package/src/server/responses/fetch-helpers.ts +5 -0
  206. package/src/server/responses/opengateway-completion-guard.ts +7 -3
  207. package/src/server/responses/passthrough-delivery.ts +8 -1
  208. package/src/server/responses/passthrough-error.ts +22 -0
  209. package/src/server/responses/request-prepare.ts +7 -1
  210. package/src/server/responses/request-transport.ts +28 -5
  211. package/src/server/responses/run-turn-execution.ts +13 -0
  212. package/src/server/sse-frame-buffer.ts +5 -0
  213. package/src/server/ws-bridge.ts +10 -0
  214. package/src/service/launchd.ts +78 -4
  215. package/src/telemetry/aggregate.ts +348 -0
  216. package/src/telemetry/consent.ts +128 -0
  217. package/src/telemetry/contract.ts +403 -0
  218. package/src/telemetry/disclosure.ts +19 -0
  219. package/src/telemetry/install-id.ts +226 -0
  220. package/src/telemetry/payload.ts +129 -0
  221. package/src/telemetry/profile/client.ts +150 -0
  222. package/src/telemetry/profile/contract.ts +288 -0
  223. package/src/telemetry/profile/disclosure.ts +14 -0
  224. package/src/telemetry/profile/paths.ts +13 -0
  225. package/src/telemetry/profile/routes.ts +99 -0
  226. package/src/telemetry/profile/service.ts +234 -0
  227. package/src/telemetry/profile/state.ts +189 -0
  228. package/src/telemetry/profile/sync.ts +276 -0
  229. package/src/telemetry/routes.ts +183 -0
  230. package/src/telemetry/scheduler.ts +386 -0
  231. package/src/telemetry/sender.ts +97 -0
  232. package/src/telemetry/state.ts +334 -0
  233. package/src/types/combo-jev-effort-mode.ts +11 -0
  234. package/src/types/config.ts +3 -0
  235. package/src/types/provider.ts +11 -1
  236. package/src/types/request.ts +2 -0
  237. package/src/types/telemetry.ts +15 -0
  238. package/src/types/wire.ts +10 -0
  239. package/src/types.ts +5 -0
  240. package/src/update/index.ts +7 -1
  241. package/src/update/minisign.d.mts +17 -0
  242. package/src/update/minisign.mjs +88 -0
  243. package/src/update/signed-supply.d.mts +59 -0
  244. package/src/update/signed-supply.mjs +289 -0
  245. package/src/update/trust-root.json +38 -0
  246. package/src/update/update-bounded-json.d.mts +4 -0
  247. package/src/update/update-bounded-json.mjs +113 -0
  248. package/src/update/update-bytes.d.mts +2 -0
  249. package/src/update/update-bytes.mjs +23 -0
  250. package/src/update/update-candidate-id.d.mts +2 -0
  251. package/src/update/update-candidate-id.mjs +23 -0
  252. package/src/update/update-checkpoint-codec.d.mts +33 -0
  253. package/src/update/update-checkpoint-codec.mjs +217 -0
  254. package/src/update/update-contracts.d.mts +24 -0
  255. package/src/update/update-contracts.mjs +207 -0
  256. package/src/update/update-signature-threshold.d.mts +12 -0
  257. package/src/update/update-signature-threshold.mjs +47 -0
  258. package/src/update/update-signed-version.d.mts +5 -0
  259. package/src/update/update-signed-version.mjs +25 -0
  260. package/src/update/update-trust-anchor.d.mts +2 -0
  261. package/src/update/update-trust-anchor.mjs +2 -0
  262. package/src/usage/cache-diagnostic.ts +195 -50
  263. package/src/usage/expected-prices.ts +20 -2
  264. package/src/usage/filter-index.ts +1469 -0
  265. package/src/usage/ledger-scanner.ts +245 -4
  266. package/src/usage/source-filter.ts +10 -2
  267. package/src/usage/summary.ts +16 -0
  268. package/src/web-search/parse.ts +265 -38
  269. package/gui/dist/assets/App-BepstgEN.js +0 -59
  270. package/gui/dist/assets/Tray-BinxbEZo.js +0 -1
  271. package/gui/dist/assets/brand-mark-wzPe3R-J.js +0 -1
  272. package/gui/dist/assets/index-C-9X2yaI.js +0 -94
  273. package/gui/dist/assets/index-bnUWypyz.css +0 -2
  274. package/gui/dist/classic/assets/App-DX88_GCW.js +0 -58
  275. package/gui/dist/classic/assets/index-fSP71pLB.js +0 -94
  276. package/gui/dist/classic/assets/quota-summary-y2fl0WBv.js +0 -1
@@ -6,6 +6,8 @@ export interface AnthropicUsageBucket {
6
6
  window: UsageWindow;
7
7
  row: Record<string, unknown>;
8
8
  percentField: "percent" | "utilization";
9
+ /** Share of the weekly limit this scoped family may consume, from `weekly_scoped_shares`. */
10
+ weeklyAllowancePercent?: number;
9
11
  }
10
12
  const legacyFields = { "5h": "five_hour", weekly: "seven_day", fable: "seven_day_fable",
11
13
  opus: "seven_day_opus", sonnet: "seven_day_sonnet" } as const;
@@ -18,6 +20,47 @@ function scopedFamily(row: Record<string, unknown>): "fable" | "opus" | "sonnet"
18
20
  return (["fable", "opus", "sonnet"] as const).find(family => label.includes(family));
19
21
  }
20
22
 
23
+ /**
24
+ * A family window's usage restated on the shared weekly scale.
25
+ *
26
+ * A scoped percent is relative to the family's own allowance: Fable at 60% of an allowance
27
+ * that is 50% of the week has 20 weekly points left, not 40. Ranking that compares a family
28
+ * request across accounts must use this figure alongside the shared weekly percent; a window
29
+ * without a valid allowance keeps its own percent. 100 maps to 100, so exhaustion is unchanged.
30
+ */
31
+ export function familyWeeklyEquivalentPercent(window: { percent?: number; weeklyAllowancePercent?: number }): number | undefined {
32
+ const percent = window.percent;
33
+ if (typeof percent !== "number" || !Number.isFinite(percent)) return undefined;
34
+ const allowance = window.weeklyAllowancePercent;
35
+ if (typeof allowance !== "number" || !Number.isFinite(allowance) || allowance <= 0 || allowance > 100) return percent;
36
+ const used = Math.max(0, Math.min(100, percent));
37
+ return percent >= 100 ? percent : 100 - allowance * (100 - used) / 100;
38
+ }
39
+
40
+ /**
41
+ * `weekly_scoped_shares[]` names, by raw `limits` index, the share of the weekly limit a scoped
42
+ * row may consume (Fable: "up to 50% of your weekly limit"). Only a selected scoped row
43
+ * receives it; a malformed, out-of-range or conflicting share is ignored.
44
+ */
45
+ function applyWeeklyShares(body: Record<string, unknown>, scopedRows: Map<number, AnthropicUsageBucket>): void {
46
+ if (!Array.isArray(body.weekly_scoped_shares)) return;
47
+ const conflicted = new Set<AnthropicUsageBucket>();
48
+ for (const raw of body.weekly_scoped_shares) {
49
+ const share = asRecord(raw);
50
+ const index = share?.limit_index;
51
+ const allowance = toFiniteNumber(share?.allowance_percent_of_weekly);
52
+ if (typeof index !== "number" || !Number.isInteger(index) || allowance === undefined || allowance <= 0 || allowance > 100) continue;
53
+ const bucket = scopedRows.get(index);
54
+ if (!bucket || conflicted.has(bucket)) continue;
55
+ if (bucket.weeklyAllowancePercent !== undefined && bucket.weeklyAllowancePercent !== allowance) {
56
+ delete bucket.weeklyAllowancePercent;
57
+ conflicted.add(bucket);
58
+ continue;
59
+ }
60
+ bucket.weeklyAllowancePercent = allowance;
61
+ }
62
+ }
63
+
21
64
  /**
22
65
  * Recognized rows supersede legacy duplicates even when skipped or malformed; duplicates
23
66
  * and malformed shared measurements make family enumeration incomplete. Shared finite
@@ -30,9 +73,10 @@ export function anthropicUsageBuckets(body: Record<string, unknown>): {
30
73
  } {
31
74
  const selected = new Map<UsageWindow, AnthropicUsageBucket>();
32
75
  const represented = new Set<UsageWindow>();
76
+ const scopedRows = new Map<number, AnthropicUsageBucket>();
33
77
  const limits = Array.isArray(body.limits) ? body.limits : [];
34
78
  let familyEnumeration = Array.isArray(body.limits);
35
- for (const raw of limits) {
79
+ for (const [index, raw] of limits.entries()) {
36
80
  const row = asRecord(raw);
37
81
  const window = row?.kind === "session" ? "5h" : row?.kind === "weekly_all" ? "weekly"
38
82
  : row?.kind === "weekly_scoped" ? scopedFamily(row) : undefined;
@@ -50,8 +94,11 @@ export function anthropicUsageBuckets(body: Record<string, unknown>): {
50
94
  if (row.is_active === false) continue;
51
95
  if (row.is_active !== undefined && row.is_active !== true) { familyEnumeration = false; continue; }
52
96
  if (toFiniteNumber(row.percent) === undefined) familyEnumeration = false;
53
- selected.set(window, { window, row, percentField: "percent" });
97
+ const bucket: AnthropicUsageBucket = { window, row, percentField: "percent" };
98
+ selected.set(window, bucket);
99
+ scopedRows.set(index, bucket);
54
100
  }
101
+ applyWeeklyShares(body, scopedRows);
55
102
  for (const window of Object.keys(legacyFields) as UsageWindow[]) {
56
103
  if (represented.has(window)) continue;
57
104
  const row = asRecord(body[legacyFields[window]]);
@@ -24,7 +24,13 @@ async function quotaFetch(providerName: string, config: OcxProviderConfig, url:
24
24
  }
25
25
 
26
26
  const KIMI_CODE_BASE_URL = "https://api.kimi.com/coding/v1";
27
- const KIMI_CODE_USAGE_URL = `${KIMI_CODE_BASE_URL}/usages`;
27
+ /**
28
+ * Kimi's regional (kimi.ai) Coding API. Its `/usages` answers a Coding Plan API key the same way
29
+ * the kimi.com origin does (#8332). Only key auth may use it: the probe then calls the origin that
30
+ * already receives this key for inference, so it adds no credential destination. OAuth tokens
31
+ * stay on the kimi.com origin they were issued for.
32
+ */
33
+ const KIMI_CODE_REGIONAL_BASE_URL = "https://api.kimi.ai/coding/v1";
28
34
  const COMMAND_CODE_BASE_URL = "https://api.commandcode.ai";
29
35
  const COMMAND_CODE_WHOAMI_URL = `${COMMAND_CODE_BASE_URL}/alpha/whoami`;
30
36
  const COMMAND_CODE_CREDITS_URL = `${COMMAND_CODE_BASE_URL}/alpha/billing/credits`;
@@ -1119,6 +1125,18 @@ export function isCanonicalKimiCodeBaseUrl(baseUrl: string): boolean {
1119
1125
  return normalizedBaseUrl(baseUrl) === KIMI_CODE_BASE_URL;
1120
1126
  }
1121
1127
 
1128
+ /**
1129
+ * The Kimi Coding origin whose `/usages` a quota probe may call with this provider's bearer, or
1130
+ * null. It is always the configured inference origin, matched exactly against Kimi's own origins,
1131
+ * so a user-edited or lookalike host never receives the credential.
1132
+ */
1133
+ function kimiCodeQuotaBaseUrl(config: Pick<OcxProviderConfig, "baseUrl" | "authMode">): string | null {
1134
+ const normalized = normalizedBaseUrl(config.baseUrl);
1135
+ if (normalized === KIMI_CODE_BASE_URL) return normalized;
1136
+ if (normalized === KIMI_CODE_REGIONAL_BASE_URL && (config.authMode ?? "key") === "key") return normalized;
1137
+ return null;
1138
+ }
1139
+
1122
1140
  export function isCanonicalCommandCodeBaseUrl(baseUrl: string): boolean {
1123
1141
  const normalized = normalizedBaseUrl(baseUrl);
1124
1142
  // OAuth preset points at the API root; the Provider-API preset at /provider/v1.
@@ -1270,9 +1288,10 @@ async function resolveKimiQuotaBearer(config: OcxProviderConfig, accountId?: str
1270
1288
 
1271
1289
  export async function fetchKimiQuota(provider: string, config: OcxProviderConfig, accessToken: string): Promise<ProviderQuotaReport | null> {
1272
1290
  // Never release credentials to a user-edited or lookalike provider host.
1273
- if (!isCanonicalKimiCodeBaseUrl(config.baseUrl)) return null;
1291
+ const baseUrl = kimiCodeQuotaBaseUrl(config);
1292
+ if (!baseUrl) return null;
1274
1293
  if (!accessToken) return null;
1275
- const response = await quotaFetch(provider, config, KIMI_CODE_USAGE_URL, {
1294
+ const response = await quotaFetch(provider, config, `${baseUrl}/usages`, {
1276
1295
  headers: { Accept: "application/json", Authorization: `Bearer ${accessToken}` },
1277
1296
  redirect: "error",
1278
1297
  signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
@@ -1435,7 +1454,7 @@ type KeyQuotaReader = (name: string, provider: OcxProviderConfig) => Promise<Pro
1435
1454
  /** Same selector drives cheap capabilities and uncached reads; never resolves credentials. */
1436
1455
  export function keyQuotaReaderForProvider(name: string, provider: OcxProviderConfig): KeyQuotaReader | null {
1437
1456
  if (provider.disabled === true || (provider.authMode ?? "key") !== "key") return null;
1438
- if (isCanonicalKimiCodeBaseUrl(provider.baseUrl)) {
1457
+ if (kimiCodeQuotaBaseUrl(provider)) {
1439
1458
  return async (id, config) => {
1440
1459
  const bearer = await resolveKimiQuotaBearer(config);
1441
1460
  return bearer ? fetchKimiQuota(id, config, bearer) : null;
@@ -9,6 +9,7 @@ import { hydrateKiroAccountState, persistKiroAccountState } from "../kiro-accoun
9
9
  import { kiroProbeCurrent, kiroProbeIdentity } from "./kiro-account-probe";
10
10
  import { fetchMuseKeyQuotaSnapshot } from "../muse-key-quota";
11
11
  import { probeAnthropicUsageQuota, type AnthropicUsageProbe } from "../claude-cli-usage";
12
+ import { claudeSignedInIdentity, peekClaudeUsageObservation } from "../claude-cli-usage-state";
12
13
  import { XAI_GROK_CLIENT_VERSION, XAI_GROK_COMPATIBILITY } from "../xai-transport";
13
14
  import {
14
15
  commitKiroAccountUsageState,
@@ -22,6 +23,7 @@ import { asRecord, normalizePercent, normalizeResetAt, readQuotaJson, REQUEST_TI
22
23
  import { providerCodexAccountMode } from "../registry";
23
24
  import {
24
25
  accountReportCurrent,
26
+ AUTHORITATIVE_EMPTY_QUOTA,
25
27
  TERMINAL_QUOTA_FAILURE,
26
28
  providerLabel,
27
29
  providerQuotaFromCodexQuota,
@@ -426,6 +428,63 @@ export async function fetchPassiveProviderQuota(provider: string): Promise<Provi
426
428
  return built ? { ...built, observed: true } : null;
427
429
  }
428
430
 
431
+ /**
432
+ * Provider-level row for the Claude Code CLI subscription: the signed-in account's last usage the
433
+ * admission recorded, in the same shape `fetchPassiveProviderQuota` returns.
434
+ *
435
+ * Cache-only. OpenCodex stores no Claude credential and this path must never spawn the CLI or
436
+ * probe an endpoint on a dashboard load; the admission already reads Anthropic's usage endpoint
437
+ * before a launch. A forced quota refresh re-reads the local sign-in and this snapshot, not the
438
+ * upstream. `updatedAt` stays the observation time, which is the age the quota card renders.
439
+ *
440
+ * The row belongs to one account. Signed out, an unreadable sign-in, or a sign-in with no recorded
441
+ * snapshot is authoritative empty, which clears another account's cached row. A cached row stops
442
+ * being current as soon as any later sign-in read (a turn's admission included) names another account.
443
+ */
444
+ export async function fetchClaudeCliObservedQuota(provider: string, forceRefresh: boolean): Promise<ProviderQuotaProbeResult> {
445
+ // Lazy: the adapter's sign-in reader (Keychain, child process) stays off the core request path.
446
+ const { currentClaudeIdentityKey } = await import("../../adapters/claude-cli/usage-admission");
447
+ await currentClaudeIdentityKey(forceRefresh);
448
+ return heldClaudeCliObservedQuota(provider);
449
+ }
450
+
451
+ /** Resolve against the latest recorded identity without accessing credentials or probing. */
452
+ export function heldClaudeCliObservedQuota(provider: string): ProviderQuotaProbeResult {
453
+ const identity = claudeSignedInIdentity();
454
+ if (!identity) return AUTHORITATIVE_EMPTY_QUOTA;
455
+ const observation = peekClaudeUsageObservation({ identity });
456
+ if (!observation?.quota) return AUTHORITATIVE_EMPTY_QUOTA;
457
+ const built = report(provider, `${provider}:subscription-observation`, observation.quota);
458
+ if (!built) return AUTHORITATIVE_EMPTY_QUOTA;
459
+ // Tagged here rather than inside report(), which every probed path shares.
460
+ const row = { ...built, observed: true };
461
+ accountReportCurrent.set(row, () => claudeSignedInIdentity() === identity);
462
+ return row;
463
+ }
464
+
465
+ /** Refresh only Claude CLI rows in a held response; other providers keep their cached readings. */
466
+ export function refreshHeldClaudeCliReports(config: OcxConfig, reports: ProviderQuotaReport[]): ProviderQuotaReport[] {
467
+ const claude = Object.entries(config.providers).filter(([, provider]) => provider.adapter === "claude-cli" && provider.disabled !== true);
468
+ if (!claude.length) return reports;
469
+ const names = new Set(claude.map(([name]) => name));
470
+ const current = claude.map(([name]) => heldClaudeCliObservedQuota(name))
471
+ .filter((item): item is ProviderQuotaReport => item !== null && item !== TERMINAL_QUOTA_FAILURE && item !== AUTHORITATIVE_EMPTY_QUOTA);
472
+ return [...reports.filter(item => !names.has(item.provider)), ...current];
473
+ }
474
+
475
+ /**
476
+ * Before the provider-report cache fast path: re-read the Claude Code sign-in (the admission's
477
+ * one-minute identity cache bounds this to one Keychain read a minute), so a cached Claude CLI
478
+ * row stops being current within a minute of a sign-out or account switch. Returns undefined when
479
+ * no Claude CLI provider is enabled: awaiting even a resolved promise would add a tick to every
480
+ * other read and reorder its in-flight join.
481
+ */
482
+ export function refreshClaudeCliSignIn(config: OcxConfig): Promise<unknown> | undefined {
483
+ if (!Object.values(config.providers).some(provider => provider.adapter === "claude-cli" && provider.disabled !== true)) return undefined;
484
+ // Lazy: the adapter's sign-in reader (Keychain, child process) stays off the core request path.
485
+ return import("../../adapters/claude-cli/usage-admission").then(admission => admission.currentClaudeIdentityKey());
486
+ }
487
+
429
488
  // ---------------------------------------------------------------------------
430
489
  // Per-account quota (multiauth)
431
490
  // ---------------------------------------------------------------------------
@@ -1,7 +1,7 @@
1
1
  import type { OAuthCredentials } from "../../oauth/types";
2
2
  import { workBuddyApi, WorkBuddyApiError } from "../../oauth/workbuddy";
3
3
  import { workBuddyHeaders } from "../workbuddy";
4
- import { parseWorkBuddyCredits, workBuddyCapacity, workBuddyRecord, type WorkBuddyCreditBalance } from "../workbuddy-credit-balance";
4
+ import { parseWorkBuddyCredits, remainingWorkBuddyCredits, workBuddyCapacity, workBuddyRecord, type WorkBuddyCreditBalance } from "../workbuddy-credit-balance";
5
5
  import { REQUEST_TIMEOUT_MS } from "../quota-wire";
6
6
  import { TERMINAL_QUOTA_FAILURE, type ProviderQuotaProbeResult } from "./report-cache";
7
7
 
@@ -67,7 +67,7 @@ export async function fetchWorkBuddyQuota(provider: string, credential: OAuthCre
67
67
  const team = await workBuddyApi("/billing/meter/get-enterprise-user-usage", headers, signal, true);
68
68
  const total = workBuddyCapacity(team.limitNum), used = workBuddyCapacity(team.credit);
69
69
  if (total === undefined || used === undefined) return null;
70
- credits = { total, used, remaining: Math.max(0, total - used), frozen: 0, groups: [] };
70
+ credits = { total, used, remaining: remainingWorkBuddyCredits(total, used), frozen: 0, groups: [] };
71
71
  }
72
72
  if (!credits) return null;
73
73
  if (credits.remaining > 0) {
@@ -37,6 +37,13 @@ export interface ProviderQuotaWindow {
37
37
  * provider-wide group named "Opus" there would otherwise be mistaken for a per-model window.
38
38
  */
39
39
  scope?: "model";
40
+ /**
41
+ * Share of the provider-wide weekly limit a model-scoped window may consume, in percent:
42
+ * Anthropic's `weekly_scoped_shares[].allowance_percent_of_weekly` (Fable is "up to 50% of
43
+ * your weekly limit"). `percent` stays relative to this allowance. Read from upstream, never
44
+ * inferred from a plan; ranking restates family usage on the weekly scale with it.
45
+ */
46
+ weeklyAllowancePercent?: number;
40
47
  /** Passive family readings have their own freshness clock, independent of active probes. */
41
48
  passiveObservedAt?: number;
42
49
  /** Upstream refusal evidence, distinct from a measured utilization counter. */
@@ -62,6 +62,8 @@ import {
62
62
  import {
63
63
  fetchAnthropicQuota,
64
64
  fetchChatGptForwardQuota,
65
+ fetchClaudeCliObservedQuota, heldClaudeCliObservedQuota, refreshHeldClaudeCliReports,
66
+ refreshClaudeCliSignIn,
65
67
  fetchCursorQuota,
66
68
  fetchKiroQuota,
67
69
  fetchMuseKeyQuota,
@@ -120,6 +122,7 @@ async function maybeFetchProviderQuota(
120
122
  ): Promise<ProviderQuotaProbeResult> {
121
123
  if (provider.disabled === true) return null;
122
124
  try {
125
+ if (provider.adapter === "claude-cli") return await fetchClaudeCliObservedQuota(name, forceRefresh);
123
126
  if (isBuiltInChatGptForwardProvider(name, provider)) {
124
127
  return fetchChatGptForwardQuota(config, name, provider, forceRefresh, prefetchedCodexSnapshot);
125
128
  }
@@ -201,11 +204,13 @@ function notifyProviderQuotaSnapshot(
201
204
  if (reports.length === 0) return;
202
205
  // Resolved here, synchronously, while the identity is still the one that produced these
203
206
  // reports.
204
- const observations = reports.map(report => ({
207
+ // Claude CLI rows are display-only: one reset key would span every account that signs in.
208
+ const observations = reports.filter(report => config.providers[report.provider]?.adapter !== "claude-cli").map(report => ({
205
209
  scope: report.provider,
206
210
  accountKey: providerObservationAccountKey(report.provider, config),
207
211
  quota: report.quota,
208
212
  }));
213
+ if (observations.length === 0) return;
209
214
  pendingProviderObservation = pendingProviderObservation
210
215
  .then(async () => {
211
216
  const observer = await import("../quota/reset-observer");
@@ -233,7 +238,7 @@ export function flushProviderQuotaObservationsForTests(): Promise<void> {
233
238
  /** Collect provider quota reports, using the cache unless refresh is forced, and publish the secret-free decision evidence from the collected reports. */
234
239
  export async function fetchProviderQuotaReports(config: OcxConfig, forceRefresh = false): Promise<ProviderQuotaResponse> {
235
240
  // A passive read (a Remote Link Child's, #6959) shows the held reports and starts nothing.
236
- if (isPassiveRead()) return heldProviderQuotaReports(Object.keys(config.providers));
241
+ if (isPassiveRead()) { const held = heldProviderQuotaReports(Object.keys(config.providers)); return { ...held, reports: refreshHeldClaudeCliReports(config, held.reports) }; }
237
242
  // A Pool report's cache signature and provider fetch must share one account snapshot.
238
243
  // Preserve force semantics when deciding whether that snapshot refreshes upstream data.
239
244
  const prefetchedCodexSnapshot = hasCodexPoolProvider(config)
@@ -243,6 +248,8 @@ export async function fetchProviderQuotaReports(config: OcxConfig, forceRefresh
243
248
  const key = typeof keyCandidate === "string" ? keyCandidate : await keyCandidate;
244
249
  const writerGeneration = captureConfigGeneration();
245
250
  const providerEpochs = captureProviderReportEpochs();
251
+ const claudeSignIn = forceRefresh ? undefined : refreshClaudeCliSignIn(config);
252
+ if (claudeSignIn) await claudeSignIn;
246
253
  const now = Date.now();
247
254
  // The cache fast path must not extend a preserved last-good row past its 30-minute bound:
248
255
  // a row preserved at age 29:59 plus a full 5-minute TTL would otherwise serve until ~35min.
@@ -254,8 +261,11 @@ export async function fetchProviderQuotaReports(config: OcxConfig, forceRefresh
254
261
  const cacheFresh = currentCache && currentCache.key === key && now - currentCache.ts < CACHE_TTL_MS
255
262
  && currentCache.response.reports.every(item =>
256
263
  (item.observed === true || now - item.updatedAt < LAST_GOOD_MAX_AGE_MS)
257
- && isProviderQuotaReportCurrent(item));
258
- if (!forceRefresh && cacheFresh) return currentCache!.response;
264
+ && (config.providers[item.provider]?.adapter === "claude-cli" || isProviderQuotaReportCurrent(item)));
265
+ if (!forceRefresh && cacheFresh) {
266
+ const response = currentCache!.response, reports = refreshHeldClaudeCliReports(config, response.reports);
267
+ return reports === response.reports ? response : { ...response, reports };
268
+ }
259
269
  const joinable = inflight.get(key);
260
270
  if (!forceRefresh && joinable && joinable.epoch === invalidationEpoch) return joinable.promise;
261
271
  // A forced probe takes commit authority: older in-flight probes must not overwrite its result.
@@ -270,26 +280,23 @@ export async function fetchProviderQuotaReports(config: OcxConfig, forceRefresh
270
280
  maybeFetchProviderQuota(name, provider, config, forceRefresh, prefetchedCodexSnapshot)
271
281
  )),
272
282
  );
273
- const fresh = probeResults.filter((item): item is ProviderQuotaReport => (
274
- item !== null && item !== TERMINAL_QUOTA_FAILURE && item !== AUTHORITATIVE_EMPTY_QUOTA
275
- ));
276
- // Both sentinels suppress the previous row. A terminal failure means the response was
277
- // invalid; an authoritative empty means the response was valid and said there are no
278
- // model windows. Either way the old row is no longer true, which is what separates them
279
- // from `null` (told us nothing — keep the last-good row).
280
- const terminalFailures = new Set(
281
- Object.keys(config.providers).filter((_, index) => (
282
- probeResults[index] === TERMINAL_QUOTA_FAILURE
283
- || probeResults[index] === AUTHORITATIVE_EMPTY_QUOTA
284
- )),
285
- );
286
283
  await providerQuotaBeforePublishForTests?.();
287
284
  let commitKey: string | null = null;
288
285
  if (epoch === invalidationEpoch) {
289
286
  const commitKeyCandidate = cacheKeyWithAggregationState(config);
290
287
  commitKey = typeof commitKeyCandidate === "string" ? commitKeyCandidate : await commitKeyCandidate;
291
288
  }
292
-
289
+ // Reconcile both rows and empty results after all awaits against the last recorded sign-in.
290
+ Object.entries(config.providers).forEach(([name, provider], index) => {
291
+ if (provider.adapter === "claude-cli" && provider.disabled !== true) probeResults[index] = heldClaudeCliObservedQuota(name);
292
+ });
293
+ const fresh = probeResults.filter((item): item is ProviderQuotaReport => (
294
+ item !== null && item !== TERMINAL_QUOTA_FAILURE && item !== AUTHORITATIVE_EMPTY_QUOTA
295
+ ));
296
+ // Both sentinels suppress the previous row; null alone keeps the last-good row.
297
+ const terminalFailures = new Set(Object.keys(config.providers).filter((_, index) => (
298
+ probeResults[index] === TERMINAL_QUOTA_FAILURE || probeResults[index] === AUTHORITATIVE_EMPTY_QUOTA
299
+ )));
293
300
  // Keep bounded last-good rows when a probe fails transiently; terminal-invalid provider
294
301
  // responses explicitly suppress their old row. Never re-stamp preserved timestamps.
295
302
  // Note: the cache key encodes the provider set (name/adapter/authMode/disabled/baseUrl),
@@ -102,8 +102,8 @@ import {
102
102
  /**
103
103
  * Claude fast mode (`speed: "fast"` + beta), shared by the OAuth and API-key Anthropic entries.
104
104
  * Only the models Anthropic documents for the lane are classified; Opus 4.6 silently runs
105
- * standard and Opus 4.7, Sonnet, Haiku and Fable reject `speed`, so they and future ids stay
106
- * unclassified. Source: https://platform.claude.com/docs/en/build-with-claude/fast-mode
105
+ * standard and Opus 4.7, Sonnet, Haiku, Fable 5 and Fable 5.1 reject `speed`, so they and future
106
+ * ids stay unclassified. Source: https://platform.claude.com/docs/en/build-with-claude/fast-mode
107
107
  * (2026-09-23) and the live probe in devlog/_fin/260923_anthropic_fast_speed.
108
108
  */
109
109
  const ANTHROPIC_FAST_WIRE = Object.freeze({
@@ -113,6 +113,9 @@ const ANTHROPIC_FAST_WIRE = Object.freeze({
113
113
  betas: Object.freeze([ANTHROPIC_FAST_MODE_BETA]),
114
114
  });
115
115
  const ANTHROPIC_FAST_MODELS: Readonly<Record<string, boolean>> = Object.freeze({
116
+ // 261110: Fable 5.2 is the first Fable with Claude API fast mode (16 / 80, 2x); Fable 5 and 5.1
117
+ // still reject `speed`. Source: platform.claude.com pricing and fast-mode pages.
118
+ "claude-fable-5-2": true,
116
119
  "claude-opus-5-5": true,
117
120
  "claude-opus-5": true,
118
121
  "claude-opus-4-8": true,
@@ -252,7 +255,7 @@ export const PROVIDER_REGISTRY_CORE: readonly ProviderRegistryEntry[] = [
252
255
  // only the old devin entry carried. Degraded-mode seed only either way —
253
256
  // `liveModels` discovers the account's real roster.
254
257
  // 261027 preemptive: GPT-6.1 Terra (same degraded seed policy as GPT-6.1 Sol).
255
- models: ["swe-2", "swe-1-7", "gpt-5-6-sol", "gpt-6-astra", "gpt-6-1-sol", "gpt-6-1-terra", "gpt-6-sol", "gpt-6-luna", "claude-opus-5-5", "claude-opus-5", "claude-fable-5-1", "claude-sonnet-5-5", "claude-haiku-5-5", "claude-sonnet-5", "glm-5-3", "kimi-k3", "gemini-3-8-flash", "grok-4-6", "grok-4-7", "swe-1-7-lightning", "gpt-5-6-luna", "gpt-5-6-terra", "claude-opus-4-8", "glm-5-2", "kimi-k2-7", "grok-4-5"],
258
+ models: ["swe-2", "swe-1-7", "gpt-5-6-sol", "gpt-6-astra", "gpt-6-1-sol", "gpt-6-1-terra", "gpt-6-sol", "gpt-6-luna", "claude-opus-5-5", "claude-opus-5", "claude-fable-5-2", "claude-fable-5-1", "claude-sonnet-5-5", "claude-haiku-5-5", "claude-sonnet-5", "glm-5-3", "kimi-k3", "gemini-3-8-flash", "grok-4-6", "grok-4-7", "swe-1-7-lightning", "gpt-5-6-luna", "gpt-5-6-terra", "claude-opus-4-8", "glm-5-2", "kimi-k2-7", "grok-4-5"],
256
259
  liveModels: true,
257
260
  defaultModel: "swe-2",
258
261
  modelContextWindows: DEVIN_MODEL_CONTEXT_WINDOWS,
@@ -838,7 +841,7 @@ export const PROVIDER_REGISTRY_CORE: readonly ProviderRegistryEntry[] = [
838
841
  modelInputModalities: Object.fromEntries(META_MODEL_API_MODELS.map(id => [id, ["text", "image"] as ["text", "image"]])),
839
842
  modelReasoningEfforts: Object.fromEntries(META_MODEL_API_MODELS.map(id => [id, META_MUSE_CODE_REASONING_EFFORTS])),
840
843
  modelReasoningEffortMap: Object.fromEntries(META_MODEL_API_MODELS.map(id => [id, META_MUSE_CODE_REASONING_EFFORT_MAP])),
841
- note: "Signs in to Meta with a browser device code on any platform, then mints the Muse Code subscription key. That grant is reimplemented from the one the Muse Code CLI performs and has NOT been exercised against Meta from OpenCodex, so treat the first login as unverified. If the Muse Code CLI is already signed in on macOS, the existing key is imported instead of starting a new grant. A pasted key from https://dev.meta.ai still works as a fallback when a device login cannot complete, and faces the same format check and live validation. A device login authenticates as Meta own Muse Code client, which is a stronger claim than reusing a key the CLI already minted. Meta scopes that credential to the Muse Code CLI, so this is an UNSUPPORTED use: Meta does not authorize subscription coverage outside its own CLI, how these calls settle is not observable from the API, and you should treat every call as billable against your account. The key, imported or pasted, is copied into OpenCodex's auth store. For an account signed in with the device login, OpenCodex refreshes Meta's subscription windows on demand from the same key endpoint the login uses, at most once every five minutes. For an imported or pasted key there is no endpoint to query them on demand, so OpenCodex reads them from streaming responses and shows the last observed value with its age; refreshing one then requires another streaming turn, and translated (non-passthrough) turns report none. Rate limits apply per team, not per key. For a supported path use the meta-model provider with your own key (export it as META_MODEL_API_KEY).",
844
+ note: "Signs in to Meta with a browser device code on any platform, then mints the Muse Code subscription key. That grant is reimplemented from the one the Muse Code CLI performs and has NOT been exercised against Meta from OpenCodex, so treat the first login as unverified. If the Muse Code CLI is already signed in on macOS, the existing key is imported instead of starting a new grant. A pasted key from https://dev.meta.ai still works as a fallback when a device login cannot complete, and faces the same format check and live validation. A device login authenticates as Meta own Muse Code client, which is a stronger claim than reusing a key the CLI already minted. Meta scopes that credential to the Muse Code CLI, so this is an UNSUPPORTED use: Meta does not authorize subscription coverage outside its own CLI, how these calls settle is not observable from the API, and you should treat every call as billable against your account. Meta may refuse another client outright with HTTP 403 and \"This API key is billed to a Muse Code subscription\"; OpenCodex reports that as a plan restriction on a valid credential, not a rejected or expired one, because no re-login can lift it. The key, imported or pasted, is copied into OpenCodex's auth store. For an account signed in with the device login, OpenCodex refreshes Meta's subscription windows on demand from the same key endpoint the login uses, at most once every five minutes. For an imported or pasted key there is no endpoint to query them on demand, so OpenCodex reads them from streaming responses and shows the last observed value with its age; refreshing one then requires another streaming turn, and translated (non-passthrough) turns report none. Rate limits apply per team, not per key. For a supported path use the meta-model provider with your own key (export it as META_MODEL_API_KEY); for direct Meta access that pay-as-you-go Meta API key is the supported key, and a Muse Code subscription key cannot replace it.",
842
845
  },
843
846
  {
844
847
  id: "umans",
@@ -522,7 +522,9 @@ export const PROVIDER_REGISTRY_EXTENDED: readonly ProviderRegistryEntry[] = [
522
522
  preserveReasoningContentModels: NVIDIA_NIM_KIMI_THINKING_MODELS,
523
523
  note: "Free tier on NVIDIA NIM — API key still required (get a free key at build.nvidia.com).",
524
524
  },
525
- { id: "venice", label: "Venice", baseUrl: "https://api.venice.ai/api/v1", adapter: "openai-chat", authKind: "key", dashboardUrl: "https://venice.ai/settings/api" },
525
+ // Venice returns 400 for any image under 64x64, which a wide screenshot hits after
526
+ // the shared normalizer floors older images to a 320px long edge (320x25).
527
+ { id: "venice", label: "Venice", baseUrl: "https://api.venice.ai/api/v1", adapter: "openai-chat", authKind: "key", dashboardUrl: "https://venice.ai/settings/api", minImageEdge: 64 },
526
528
  // 260710 GLM-5.2 context and path-specific ids: Tier-2 evidence in
527
529
  // devlog/_plan/260710_provider_hardening/002_research_cn.md.
528
530
  // 260814: glm-5.3 / glm-5.3[1m] added per docs.z.ai/devpack/latest-model, which lists them as
@@ -1345,6 +1347,42 @@ export const PROVIDER_REGISTRY_EXTENDED: readonly ProviderRegistryEntry[] = [
1345
1347
  inputModalities: ["text"],
1346
1348
  note: "Smart Router that sends each request to a model chosen from AI Stupid Level's benchmarks, using the provider keys saved on your AI Stupid Level account (OpenAI, Anthropic, Google, DeepSeek, Kimi, GLM), so each provider bills you directly with no markup. Routing modes: auto-coding (the default), auto-tooling, auto-reasoning, auto-best, plus value and speed modes. A real model id from the live list, such as claude-opus-5-5, pins one model. The X-AISM-Model response header names the model that answered. Text only.",
1347
1349
  },
1350
+ {
1351
+ // cheapaimodel, operated by LINKOVA PTE. LTD. (Singapore). Contract checked 2026-10-28:
1352
+ // https://cheapaimodel.ai/docs/api/create-chat-completion and
1353
+ // https://cheapaimodel.ai/docs/api/list-models. GET /v1/models answers 401 without a valid key,
1354
+ // so the default discovery URL doubles as key validation. Chat Completions is the one interface
1355
+ // every catalog model supports, so every inbound stays on Chat and the preset does not use the
1356
+ // gateway's Responses or Anthropic Messages endpoints. Context windows and
1357
+ // input modalities are from the live catalog at https://cheapaimodel.ai/models. kimi-k3 rejects
1358
+ // any temperature other than 0.6 or 1 and rejects top_p 0.9 and 1.0, so both are dropped for it.
1359
+ // deepseek-v4-1-flash takes reasoning_effort none, low, high and max, and an omitted effort runs
1360
+ // at high (https://cheapaimodel.ai/blog/deepseek-v4-1-flash-reasoning-effort), so it keeps the
1361
+ // DeepSeek Flash ladder and sends an explicit none instead of dropping it.
1362
+ // The env reference derived from the id is ${CHEAPAIMODEL_API_KEY}.
1363
+ id: "cheapaimodel",
1364
+ label: "cheapaimodel",
1365
+ adapter: "openai-chat",
1366
+ baseUrl: "https://api.cheapaimodel.ai/v1",
1367
+ authKind: "key",
1368
+ dashboardUrl: "https://console.cheapaimodel.ai/keys",
1369
+ liveModels: true,
1370
+ preserveCustomDestination: true,
1371
+ defaultModel: "deepseek-v4-1-flash",
1372
+ models: ["deepseek-v4-1-flash", "glm-5.3", "glm-5.3-flash", "kimi-k3", "grok-4.7"],
1373
+ modelContextWindows: {
1374
+ "deepseek-v4-1-flash": 1_000_000, "glm-5.3": 1_000_000, "glm-5.3-flash": 1_000_000, "kimi-k3": 1_000_000, "grok-4.7": 500_000,
1375
+ },
1376
+ modelInputModalities: {
1377
+ "deepseek-v4-1-flash": ["text", "image"], "glm-5.3": ["text"], "glm-5.3-flash": ["text", "image"],
1378
+ "kimi-k3": ["text", "image"], "grok-4.7": ["text", "image"],
1379
+ },
1380
+ noTemperatureModels: ["kimi-k3"],
1381
+ noTopPModels: ["kimi-k3"],
1382
+ modelReasoningEfforts: { "deepseek-v4-1-flash": deepseekThinkingEffortsFor("deepseek-v4-1-flash") },
1383
+ modelReasoningEffortMap: { "deepseek-v4-1-flash": { ...deepseekReasoningMapFor("deepseek-v4-1-flash"), none: "none" } },
1384
+ note: "Pay-per-token API gateway for open-weight models (DeepSeek, GLM, Kimi) and Grok, billed from a prepaid USD balance. Create an API key at console.cheapaimodel.ai. Live discovery lists the models your key can call; deepseek-v4-1-flash is the default. Chat Completions only.",
1385
+ },
1348
1386
  // Xiaomi retires mimo-v2.5 and mimo-v2.5-pro on 2026-10-21 with no redirect
1349
1387
  // (https://mimo.mi.com/docs/en-US/updates/deprecate), so the first-party presets default to V2.6.
1350
1388
  // Saved defaults are not rewritten; V2.5 stays listed until it stops answering.
@@ -1664,15 +1702,11 @@ export const PROVIDER_REGISTRY_EXTENDED: readonly ProviderRegistryEntry[] = [
1664
1702
  // request entirely (src/codex/catalog/provider-models.ts).
1665
1703
  liveModels: false,
1666
1704
  modelContextWindows: { ...ANTHROPIC_MODEL_CONTEXT_WINDOWS },
1667
- // Text-only for v1, not the image modality the Messages API rows publish. The CLI parses an
1668
- // image frame (verified against 2.1.270), but a headless turn has no verified contract that the
1669
- // harness hands those bytes to the model, and advertising a modality the route cannot honour
1670
- // makes a route selection pick this row for a picture it then answers blind. The adapter refuses
1671
- // direct image input for the same reason; the vision sidecar still captions images into text.
1672
- noVisionModels: [...ANTHROPIC_MODELS],
1705
+ // The CLI receives native image blocks through Claude's stable conversation replay.
1706
+ modelInputModalities: { ...ANTHROPIC_MODEL_INPUT_MODALITIES },
1673
1707
  reasoningEfforts: ANTHROPIC_REASONING_EFFORTS,
1674
1708
  modelReasoningEfforts: { ...ANTHROPIC_MODEL_REASONING_EFFORTS },
1675
1709
  defaultMaxOutputTokens: ANTHROPIC_DEFAULT_MAX_OUTPUT_TOKENS,
1676
- note: "Runs Claude subscription traffic through Anthropic's own harness: the official Claude Code CLI headlessly (`claude -p`), one turn per request. OpenCodex stores no Claude token, reads none and injects none — the CLI signs in and bills the account itself, which is why this row is keyless and an API key saved here never reaches the harness (use `anthropic-apikey` for key billing). The sign-in is the one of the user this proxy runs as, so every request served through this row — by any client of this proxy — spends that same account; OpenCodex neither pools nor multiplexes Claude sign-ins. Requires the CLI (`npm i -g @anthropic-ai/claude-code`) and a signed-in session (`claude` -> /login). v1 disables CLI tools (--tools \"\", --strict-mcp-config) so the client retains tool ownership: text/reasoning only for now. Subscription routing authorization flagged for maintainer review.",
1710
+ note: "Runs Claude subscription traffic through Anthropic's own harness: the official Claude Code CLI headlessly (`claude -p`), one turn per request. OpenCodex stores no Claude token and injects none into CLI requests (quota admission only reads it in memory) — the CLI signs in and bills the account itself, which is why this row is keyless and an API key saved here never reaches the harness (use `anthropic-apikey` for key billing). The sign-in is the one of the user this proxy runs as, so every request served through this row — by any client of this proxy — spends that same account; OpenCodex neither pools nor multiplexes Claude sign-ins. Requires the CLI (`npm i -g @anthropic-ai/claude-code`) and a signed-in session (`claude` -> /login). v1 disables CLI tools (--tools \"\", --strict-mcp-config) so the client retains tool ownership; text, reasoning and native image input are supported. Subscription routing authorization flagged for maintainer review.",
1677
1711
  },
1678
1712
  ];
@@ -81,6 +81,7 @@ export const REGISTRY_FIELD_MODEL_ID_ROLES = {
81
81
  annotateEmptyToolOutputs: NONE,
82
82
  supportsServiceTier: NONE,
83
83
  supportsOpenAiWebSearchToolFields: NONE,
84
+ minImageEdge: NONE,
84
85
  supportsResponsesCustomTools: NONE,
85
86
  modelSupportsServiceTier: RECORD_KEYS,
86
87
  keyAuthServiceTier: KEY_AUTH_SERVICE_TIER,
@@ -14,8 +14,10 @@ import type { ProviderModelDiscoverySpec } from "./types";
14
14
  // overview, migration guide, effort and pricing pages (platform.claude.com).
15
15
  // 261008 Claude Haiku 5.5: 1M / 128K, adaptive thinking, effort low..max (default medium),
16
16
  // per platform.claude.com Haiku 5.5 overview, migration guide and pricing page.
17
- export const ANTHROPIC_MODELS = ["claude-fable-5-1", "claude-fable-5", "claude-sonnet-5-5", "claude-sonnet-5", "claude-opus-5-5", "claude-opus-5", "claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", "claude-sonnet-4-6", "claude-haiku-5-5", "claude-haiku-4-5"];
18
- export const ANTHROPIC_MODEL_CONTEXT_WINDOWS: Record<string, number> = { "claude-fable-5-1": 1_000_000, "claude-sonnet-5-5": 1_000_000, "claude-sonnet-5": 1_000_000, "claude-fable-5": 1_000_000, "claude-opus-5-5": 1_000_000, "claude-opus-5": 1_000_000, "claude-opus-4-8": 1_000_000, "claude-opus-4-7": 1_000_000, "claude-opus-4-6": 1_000_000, "claude-sonnet-4-6": 1_000_000, "claude-haiku-5-5": 1_000_000, "claude-haiku-4-5": 200_000 };
17
+ // 261110 Claude Fable 5.2 (`claude-fable-5-2`, released 2026-11-09): 1M / 128K, adaptive thinking
18
+ // always on, effort low..max (default high), per the Fable 5.2 overview, what's-new and pricing pages.
19
+ export const ANTHROPIC_MODELS = ["claude-fable-5-2", "claude-fable-5-1", "claude-fable-5", "claude-sonnet-5-5", "claude-sonnet-5", "claude-opus-5-5", "claude-opus-5", "claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", "claude-sonnet-4-6", "claude-haiku-5-5", "claude-haiku-4-5"];
20
+ export const ANTHROPIC_MODEL_CONTEXT_WINDOWS: Record<string, number> = { "claude-fable-5-2": 1_000_000, "claude-fable-5-1": 1_000_000, "claude-sonnet-5-5": 1_000_000, "claude-sonnet-5": 1_000_000, "claude-fable-5": 1_000_000, "claude-opus-5-5": 1_000_000, "claude-opus-5": 1_000_000, "claude-opus-4-8": 1_000_000, "claude-opus-4-7": 1_000_000, "claude-opus-4-6": 1_000_000, "claude-sonnet-4-6": 1_000_000, "claude-haiku-5-5": 1_000_000, "claude-haiku-4-5": 200_000 };
19
21
  // All seeded Claude models support vision: https://platform.claude.com/docs/en/models/overview
20
22
  export const ANTHROPIC_MODEL_INPUT_MODALITIES: Record<string, string[]> = Object.fromEntries(
21
23
  ANTHROPIC_MODELS.map(id => [id, ["text", "image"]]),
@@ -43,6 +45,7 @@ export const ANTHROPIC_DEFAULT_MAX_OUTPUT_TOKENS = 64_000;
43
45
  */
44
46
  export const ANTHROPIC_MODEL_MAX_OUTPUT_TOKENS: Record<string, number> = {
45
47
  "claude-haiku-5-5": 128_000,
48
+ "claude-fable-5-2": 128_000,
46
49
  "claude-fable-5-1": 128_000,
47
50
  "claude-fable-5": 128_000,
48
51
  "claude-sonnet-5-5": 128_000,
@@ -1168,8 +1171,11 @@ export const CLINE_PASS_MODEL_INPUT_MODALITIES: Record<string, string[]> = Objec
1168
1171
  // (anthropic/claude-sonnet-4-6) pin one route and stay valid, they are just not seeded.
1169
1172
  // 260923: `claude-opus-5-5` pool (anthropic, aws eu, vertex, vertex-eu members; all 1M / 128K,
1170
1173
  // vision) read from the same catalogue endpoint the day after Anthropic's release.
1174
+ // 261110: `claude-fable-5-2` pool (api.opper.ai/v3/models?q=claude-fable-5-2: pooled, Anthropic US route,
1175
+ // 1M / 128K).
1171
1176
  export const OPPER_MODELS = [
1172
1177
  "claude-sonnet-4-6",
1178
+ "claude-fable-5-2",
1173
1179
  "claude-opus-5-5",
1174
1180
  "claude-opus-5",
1175
1181
  "gpt-5.5",
@@ -1183,6 +1189,7 @@ export const OPPER_MODELS = [
1183
1189
  // (kimi-k3 output); live discovery owns which models exist.
1184
1190
  export const OPPER_MODEL_CONTEXT_WINDOWS: Record<string, number> = {
1185
1191
  "claude-sonnet-4-6": 1_000_000,
1192
+ "claude-fable-5-2": 1_000_000,
1186
1193
  "claude-opus-5-5": 1_000_000,
1187
1194
  "claude-opus-5": 1_000_000,
1188
1195
  "gpt-5.5": 1_050_000,
@@ -1194,6 +1201,7 @@ export const OPPER_MODEL_CONTEXT_WINDOWS: Record<string, number> = {
1194
1201
  };
1195
1202
  export const OPPER_MODEL_MAX_OUTPUT_TOKENS: Record<string, number> = {
1196
1203
  "claude-sonnet-4-6": 64_000,
1204
+ "claude-fable-5-2": 128_000,
1197
1205
  "claude-opus-5-5": 128_000,
1198
1206
  "claude-opus-5": 128_000,
1199
1207
  "gpt-5.5": 128_000,
@@ -260,6 +260,12 @@ export interface ProviderRegistryEntry {
260
260
  supportsServiceTier?: boolean;
261
261
  /** Registry default for OpenAI extended hosted web_search field support. */
262
262
  supportsOpenAiWebSearchToolFields?: boolean;
263
+ /**
264
+ * Registry-only smallest image edge, in pixels, that the upstream accepts on the
265
+ * `openai-chat` wire. Inline images below it are upscaled before sending, because the
266
+ * upstream rejects the whole request otherwise (Venice: "images must be at least 64x64").
267
+ */
268
+ minImageEdge?: number;
263
269
  /** Registry default for native Responses custom-tool support. */
264
270
  supportsResponsesCustomTools?: boolean;
265
271
  /** Registry default for exact model service-tier capability; explicit config keys win. */
@@ -43,6 +43,7 @@ export type StaticProviderPolicyField =
43
43
  | "reasoningDetailsModels" | "thinkingToggleModels" | "thinkingBudgetModels" | "showThinkingSummary"
44
44
  | "escapeBuiltinToolNames" | "googleMode" | "project" | "location" | "modelCapabilities"
45
45
  | "modelAutoCompactTokenLimits" | "modelSuppressSyntheticMax" | "modelReasoningSummaryDelivery"
46
+ | "thinkingDisplay" | "modelThinkingDisplay"
46
47
  | "codexToolMode" | "modelAdapters";
47
48
  type StaticProviderPolicyShape = Pick<OcxProviderConfig, StaticProviderPolicyField>;
48
49
  export type ResolvedProviderStaticPolicy = Readonly<Partial<StaticProviderPolicyShape>> & Readonly<{
@@ -182,6 +183,8 @@ export function resolveModelPolicy(input: ResolveModelPolicyInput): ResolvedMode
182
183
  "supportsVerbosity", "responsesItemIdRepair",
183
184
  "showThinkingSummary", "escapeBuiltinToolNames", "googleMode", "project", "location",
184
185
  ] as const) putScalar(key, entry?.[key] as StaticProviderPolicyShape[typeof key] | undefined);
186
+ // Operator-only display policy; no registry entry declares it (#8363).
187
+ put("thinkingDisplay", provider.thinkingDisplay, provider.thinkingDisplay !== undefined ? "operator" : "unknown");
185
188
  const legacyClinePassLadder = entry !== undefined && input.providerName === "cline-pass"
186
189
  && provider.reasoningWireFormat === "gateway-object"
187
190
  && sameStringArray(provider.reasoningEfforts, ["low"]);
@@ -218,6 +221,7 @@ export function resolveModelPolicy(input: ResolveModelPolicyInput): ResolvedMode
218
221
  for (const key of [
219
222
  "modelAutoCompactTokenLimits", "modelSuppressSyntheticMax",
220
223
  "modelReasoningSummaryDelivery", "codexToolMode", "modelAdapters",
224
+ "modelThinkingDisplay",
221
225
  ] as const) putScalar(key, undefined);
222
226
  put("modelCapabilities", mergeReasoningModelCapabilities(entry?.modelCapabilities, provider.modelCapabilities),
223
227
  provider.modelCapabilities !== undefined ? "operator-capability" : entry?.modelCapabilities !== undefined ? "registry" : "unknown");