@bitkyc08/opencodex 2.99.0-preview.20261108 → 2.100.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (258) hide show
  1. package/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-CitvEefy.js +59 -0
  7. package/gui/dist/assets/Tray-CeKVWQyB.js +1 -0
  8. package/gui/dist/assets/{brand-mark-DpiBmFGI.js → brand-mark-M92UnxX2.js} +1 -1
  9. package/gui/dist/assets/index-BP47do6-.js +94 -0
  10. package/gui/dist/assets/index-DmDooSAG.css +2 -0
  11. package/gui/dist/assets/{segment-thumb-features-JcszQ18T.js → segment-thumb-features-CcxZBnxv.js} +1 -1
  12. package/gui/dist/classic/assets/App-aYgIQMxI.js +58 -0
  13. package/gui/dist/classic/assets/{Tray-5v86r9Az.js → Tray-D8jfUXpQ.js} +1 -1
  14. package/gui/dist/classic/assets/index-CfGqHooN.js +94 -0
  15. package/gui/dist/classic/assets/quota-summary-R-ih7OlS.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.ts +28 -2
  38. package/src/adapters/claude-cli/adapter.ts +5 -25
  39. package/src/adapters/claude-cli/instruction-images.ts +31 -0
  40. package/src/adapters/claude-cli/stable-replay.ts +42 -14
  41. package/src/adapters/claude-cli/usage-admission.ts +53 -64
  42. package/src/adapters/coding-agent/protocol.ts +1 -1
  43. package/src/adapters/devin/live-models.ts +3 -0
  44. package/src/adapters/google-http.ts +3 -0
  45. package/src/adapters/google-vertex-key-project.ts +10 -2
  46. package/src/adapters/google.ts +40 -8
  47. package/src/adapters/kiro/usage.ts +3 -13
  48. package/src/adapters/openai-responses/passthrough.ts +5 -2
  49. package/src/adapters/openai-responses/request-strips.ts +32 -0
  50. package/src/adapters/openai-responses/tool-schema.ts +9 -4
  51. package/src/chat/inbound.ts +1 -1
  52. package/src/claude/auth-detect.ts +26 -8
  53. package/src/claude/inbound-content-options.ts +18 -3
  54. package/src/claude/inbound.ts +5 -2
  55. package/src/cli/bundled-bun-diagnostic.ts +91 -0
  56. package/src/cli/capabilities-agents-routing.ts +2 -2
  57. package/src/cli/capabilities-observe-system.ts +60 -0
  58. package/src/cli/combo-input.ts +6 -0
  59. package/src/cli/combo-result.ts +1 -1
  60. package/src/cli/combo.ts +4 -0
  61. package/src/cli/config-command.ts +16 -2
  62. package/src/cli/connect.ts +12 -10
  63. package/src/cli/dispatch.ts +4 -0
  64. package/src/cli/doctor.ts +11 -0
  65. package/src/cli/help.ts +1 -0
  66. package/src/cli/init.ts +4 -0
  67. package/src/cli/link-enrollment.ts +152 -25
  68. package/src/cli/link-local-control.ts +49 -0
  69. package/src/cli/link.ts +37 -10
  70. package/src/cli/provider-lifecycle-runtime.ts +4 -2
  71. package/src/cli/registry.ts +13 -0
  72. package/src/cli/star-prompt.ts +2 -0
  73. package/src/cli/status.ts +1 -1
  74. package/src/cli/telemetry-profile.ts +206 -0
  75. package/src/cli/telemetry.ts +260 -0
  76. package/src/client/hub-relay.ts +26 -0
  77. package/src/client/machine-api.ts +3 -0
  78. package/src/clients/config-export/t3code.ts +44 -5
  79. package/src/clients/omo-role-models.ts +1 -1
  80. package/src/codex/catalog/bundled.ts +44 -2
  81. package/src/codex/runtime.ts +12 -0
  82. package/src/codex/shim-restore-lock.ts +67 -30
  83. package/src/combos/types.ts +21 -1
  84. package/src/config/atomic-write.ts +24 -1
  85. package/src/config/diagnostics.ts +15 -0
  86. package/src/config/live-reconcile.ts +17 -0
  87. package/src/config/load-degrade.ts +16 -0
  88. package/src/config/provider-validation.ts +29 -0
  89. package/src/config/schema/config-schema.ts +24 -0
  90. package/src/config/schema/leaf-validators.ts +17 -0
  91. package/src/config/telemetry-carry.ts +30 -0
  92. package/src/config.ts +13 -1
  93. package/src/generated/compatibility-version.json +405 -153
  94. package/src/generated/model-metadata.ts +3 -3
  95. package/src/integrations/aside-profiles.ts +7 -1
  96. package/src/integrations/owned-refresh.ts +9 -2
  97. package/src/lab/artifacts/secure-fs.ts +12 -11
  98. package/src/lab/fabric/scratch.ts +11 -9
  99. package/src/lab/public/community.ts +2 -3
  100. package/src/lab/public/file-safety.ts +18 -20
  101. package/src/lab/public/mutation-lock.ts +109 -337
  102. package/src/lab/public/private-file.ts +4 -3
  103. package/src/lib/bun-runtime-preflight.ts +1 -1
  104. package/src/lib/codex-catalog-read-only.ts +122 -0
  105. package/src/lib/config-ownership.ts +49 -18
  106. package/src/lib/errors.ts +11 -0
  107. package/src/lib/gcp-adc.ts +167 -48
  108. package/src/lib/jsonc.ts +4 -2
  109. package/src/lib/local-control-socket.ts +88 -0
  110. package/src/lib/privacy.ts +15 -0
  111. package/src/lib/provider-client-headers.ts +3 -0
  112. package/src/lib/token-estimate.ts +13 -2
  113. package/src/link/child-binary-source.ts +228 -0
  114. package/src/link/ephemeral-child.ts +45 -0
  115. package/src/link/remote-plant.ts +306 -0
  116. package/src/link/remote-windows.ts +59 -5
  117. package/src/link/ssh-argv.ts +71 -8
  118. package/src/link/status-projection.ts +2 -0
  119. package/src/link/store.ts +5 -1
  120. package/src/oauth/claude-keychain-read.ts +165 -0
  121. package/src/oauth/local-token-detect.ts +14 -17
  122. package/src/protocols/envelope.ts +20 -2
  123. package/src/providers/api-key-selection.ts +8 -2
  124. package/src/providers/claude-cli-usage-state.ts +93 -0
  125. package/src/providers/github-copilot-auto.ts +25 -5
  126. package/src/providers/meta-muse-plan-refusal.ts +94 -0
  127. package/src/providers/model-rename-fields.ts +3 -0
  128. package/src/providers/quota/vendor-probes-key.ts +23 -4
  129. package/src/providers/quota/vendor-probes-oauth.ts +59 -0
  130. package/src/providers/quota/workbuddy.ts +2 -2
  131. package/src/providers/quota.ts +25 -18
  132. package/src/providers/registry/entries-core.ts +7 -4
  133. package/src/providers/registry/entries-extended.ts +39 -7
  134. package/src/providers/registry/model-seeds.ts +10 -2
  135. package/src/providers/resolved-model-policy.ts +4 -0
  136. package/src/providers/routed-config.ts +30 -3
  137. package/src/providers/stale-no-vision-seed-migration.ts +7 -0
  138. package/src/providers/vertex-environment-authority.ts +50 -0
  139. package/src/providers/workbuddy-credit-balance.ts +38 -6
  140. package/src/quota-pool/assemble.ts +14 -6
  141. package/src/router.ts +1 -0
  142. package/src/server/adapter-resolve.ts +11 -6
  143. package/src/server/audio-dictation.ts +21 -7
  144. package/src/server/auth-cors.ts +19 -0
  145. package/src/server/background-lifecycle.ts +71 -0
  146. package/src/server/chat-completions.ts +2 -0
  147. package/src/server/claude-messages.ts +30 -3
  148. package/src/server/index/live-sideband.ts +15 -1
  149. package/src/server/index/local-control-listener.ts +515 -0
  150. package/src/server/index/optional-listeners.ts +21 -1
  151. package/src/server/index/serve-options.ts +4 -3
  152. package/src/server/index/websocket-handler.ts +2 -0
  153. package/src/server/index.ts +3 -0
  154. package/src/server/management/combo-routes.ts +6 -1
  155. package/src/server/management/context.ts +1 -0
  156. package/src/server/management/link-child-preflight.ts +74 -0
  157. package/src/server/management/link-enrollment.ts +190 -25
  158. package/src/server/management/link-route-state.ts +6 -1
  159. package/src/server/management/link-routes.ts +27 -9
  160. package/src/server/management/model-rows.ts +4 -0
  161. package/src/server/management/oauth-account-routes.ts +9 -4
  162. package/src/server/management/provider-overwrite-carry.ts +9 -2
  163. package/src/server/management/provider-routes.ts +14 -0
  164. package/src/server/management/provider-thinking-display-patch.ts +54 -0
  165. package/src/server/management/route-registry.ts +7 -0
  166. package/src/server/management/session-routes.ts +4 -1
  167. package/src/server/management/telemetry-routes.ts +37 -0
  168. package/src/server/management/usage-aggregate-cache.ts +290 -67
  169. package/src/server/management-api.ts +11 -2
  170. package/src/server/messages-native-preflight.ts +166 -0
  171. package/src/server/messages-native.ts +143 -43
  172. package/src/server/messages-shared.ts +14 -0
  173. package/src/server/proxy-liveness.ts +99 -6
  174. package/src/server/request-log-conversation.ts +18 -2
  175. package/src/server/request-log.ts +7 -2
  176. package/src/server/responses/adapter-continuation.ts +1 -0
  177. package/src/server/responses/adapter-dispatch.ts +11 -28
  178. package/src/server/responses/adapter-failure-message.ts +68 -0
  179. package/src/server/responses/combo-stream-preflight.ts +14 -2
  180. package/src/server/responses/core-auth.ts +26 -5
  181. package/src/server/responses/core-codex-account.ts +8 -1
  182. package/src/server/responses/core-combo-failure.ts +6 -1
  183. package/src/server/responses/core-combo-native.ts +150 -37
  184. package/src/server/responses/core-combo.ts +15 -9
  185. package/src/server/responses/core-normalize.ts +1 -0
  186. package/src/server/responses/core-options.ts +7 -1
  187. package/src/server/responses/core-pipeline.ts +21 -1
  188. package/src/server/responses/fetch-helpers.ts +5 -0
  189. package/src/server/responses/opengateway-completion-guard.ts +7 -3
  190. package/src/server/responses/passthrough-delivery.ts +8 -1
  191. package/src/server/responses/passthrough-error.ts +22 -0
  192. package/src/server/responses/request-prepare.ts +7 -1
  193. package/src/server/responses/request-transport.ts +28 -5
  194. package/src/server/responses/run-turn-execution.ts +13 -0
  195. package/src/server/sse-frame-buffer.ts +5 -0
  196. package/src/server/ws-bridge.ts +10 -0
  197. package/src/service/launchd.ts +78 -4
  198. package/src/telemetry/aggregate.ts +348 -0
  199. package/src/telemetry/consent.ts +128 -0
  200. package/src/telemetry/contract.ts +403 -0
  201. package/src/telemetry/disclosure.ts +19 -0
  202. package/src/telemetry/install-id.ts +226 -0
  203. package/src/telemetry/payload.ts +129 -0
  204. package/src/telemetry/profile/client.ts +150 -0
  205. package/src/telemetry/profile/contract.ts +288 -0
  206. package/src/telemetry/profile/disclosure.ts +14 -0
  207. package/src/telemetry/profile/paths.ts +13 -0
  208. package/src/telemetry/profile/routes.ts +99 -0
  209. package/src/telemetry/profile/service.ts +234 -0
  210. package/src/telemetry/profile/state.ts +189 -0
  211. package/src/telemetry/profile/sync.ts +276 -0
  212. package/src/telemetry/routes.ts +183 -0
  213. package/src/telemetry/scheduler.ts +386 -0
  214. package/src/telemetry/sender.ts +97 -0
  215. package/src/telemetry/state.ts +334 -0
  216. package/src/types/combo-jev-effort-mode.ts +11 -0
  217. package/src/types/config.ts +3 -0
  218. package/src/types/provider.ts +11 -1
  219. package/src/types/request.ts +2 -0
  220. package/src/types/telemetry.ts +15 -0
  221. package/src/types/wire.ts +10 -0
  222. package/src/types.ts +5 -0
  223. package/src/update/index.ts +7 -1
  224. package/src/update/minisign.d.mts +17 -0
  225. package/src/update/minisign.mjs +88 -0
  226. package/src/update/signed-supply.d.mts +59 -0
  227. package/src/update/signed-supply.mjs +289 -0
  228. package/src/update/trust-root.json +38 -0
  229. package/src/update/update-bounded-json.d.mts +4 -0
  230. package/src/update/update-bounded-json.mjs +113 -0
  231. package/src/update/update-bytes.d.mts +2 -0
  232. package/src/update/update-bytes.mjs +23 -0
  233. package/src/update/update-candidate-id.d.mts +2 -0
  234. package/src/update/update-candidate-id.mjs +23 -0
  235. package/src/update/update-checkpoint-codec.d.mts +33 -0
  236. package/src/update/update-checkpoint-codec.mjs +217 -0
  237. package/src/update/update-contracts.d.mts +24 -0
  238. package/src/update/update-contracts.mjs +207 -0
  239. package/src/update/update-signature-threshold.d.mts +12 -0
  240. package/src/update/update-signature-threshold.mjs +47 -0
  241. package/src/update/update-signed-version.d.mts +5 -0
  242. package/src/update/update-signed-version.mjs +25 -0
  243. package/src/update/update-trust-anchor.d.mts +2 -0
  244. package/src/update/update-trust-anchor.mjs +2 -0
  245. package/src/usage/cache-diagnostic.ts +195 -50
  246. package/src/usage/expected-prices.ts +20 -2
  247. package/src/usage/filter-index.ts +1469 -0
  248. package/src/usage/ledger-scanner.ts +245 -4
  249. package/src/usage/source-filter.ts +10 -2
  250. package/src/usage/summary.ts +16 -0
  251. package/src/web-search/parse.ts +244 -38
  252. package/gui/dist/assets/App-CWz0areF.js +0 -59
  253. package/gui/dist/assets/Tray-BosDoskm.js +0 -1
  254. package/gui/dist/assets/index-CAxjGWkm.js +0 -94
  255. package/gui/dist/assets/index-bnUWypyz.css +0 -2
  256. package/gui/dist/classic/assets/App-BOEsFmiN.js +0 -58
  257. package/gui/dist/classic/assets/index-ClZ_zZ77.js +0 -94
  258. package/gui/dist/classic/assets/quota-summary-xwvDtvu7.js +0 -1
@@ -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) {
@@ -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",
@@ -1345,6 +1345,42 @@ export const PROVIDER_REGISTRY_EXTENDED: readonly ProviderRegistryEntry[] = [
1345
1345
  inputModalities: ["text"],
1346
1346
  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
1347
  },
1348
+ {
1349
+ // cheapaimodel, operated by LINKOVA PTE. LTD. (Singapore). Contract checked 2026-10-28:
1350
+ // https://cheapaimodel.ai/docs/api/create-chat-completion and
1351
+ // https://cheapaimodel.ai/docs/api/list-models. GET /v1/models answers 401 without a valid key,
1352
+ // so the default discovery URL doubles as key validation. Chat Completions is the one interface
1353
+ // every catalog model supports, so every inbound stays on Chat and the preset does not use the
1354
+ // gateway's Responses or Anthropic Messages endpoints. Context windows and
1355
+ // input modalities are from the live catalog at https://cheapaimodel.ai/models. kimi-k3 rejects
1356
+ // any temperature other than 0.6 or 1 and rejects top_p 0.9 and 1.0, so both are dropped for it.
1357
+ // deepseek-v4-1-flash takes reasoning_effort none, low, high and max, and an omitted effort runs
1358
+ // at high (https://cheapaimodel.ai/blog/deepseek-v4-1-flash-reasoning-effort), so it keeps the
1359
+ // DeepSeek Flash ladder and sends an explicit none instead of dropping it.
1360
+ // The env reference derived from the id is ${CHEAPAIMODEL_API_KEY}.
1361
+ id: "cheapaimodel",
1362
+ label: "cheapaimodel",
1363
+ adapter: "openai-chat",
1364
+ baseUrl: "https://api.cheapaimodel.ai/v1",
1365
+ authKind: "key",
1366
+ dashboardUrl: "https://console.cheapaimodel.ai/keys",
1367
+ liveModels: true,
1368
+ preserveCustomDestination: true,
1369
+ defaultModel: "deepseek-v4-1-flash",
1370
+ models: ["deepseek-v4-1-flash", "glm-5.3", "glm-5.3-flash", "kimi-k3", "grok-4.7"],
1371
+ modelContextWindows: {
1372
+ "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,
1373
+ },
1374
+ modelInputModalities: {
1375
+ "deepseek-v4-1-flash": ["text", "image"], "glm-5.3": ["text"], "glm-5.3-flash": ["text", "image"],
1376
+ "kimi-k3": ["text", "image"], "grok-4.7": ["text", "image"],
1377
+ },
1378
+ noTemperatureModels: ["kimi-k3"],
1379
+ noTopPModels: ["kimi-k3"],
1380
+ modelReasoningEfforts: { "deepseek-v4-1-flash": deepseekThinkingEffortsFor("deepseek-v4-1-flash") },
1381
+ modelReasoningEffortMap: { "deepseek-v4-1-flash": { ...deepseekReasoningMapFor("deepseek-v4-1-flash"), none: "none" } },
1382
+ 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.",
1383
+ },
1348
1384
  // Xiaomi retires mimo-v2.5 and mimo-v2.5-pro on 2026-10-21 with no redirect
1349
1385
  // (https://mimo.mi.com/docs/en-US/updates/deprecate), so the first-party presets default to V2.6.
1350
1386
  // Saved defaults are not rewritten; V2.5 stays listed until it stops answering.
@@ -1664,15 +1700,11 @@ export const PROVIDER_REGISTRY_EXTENDED: readonly ProviderRegistryEntry[] = [
1664
1700
  // request entirely (src/codex/catalog/provider-models.ts).
1665
1701
  liveModels: false,
1666
1702
  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],
1703
+ // The CLI receives native image blocks through Claude's stable conversation replay.
1704
+ modelInputModalities: { ...ANTHROPIC_MODEL_INPUT_MODALITIES },
1673
1705
  reasoningEfforts: ANTHROPIC_REASONING_EFFORTS,
1674
1706
  modelReasoningEfforts: { ...ANTHROPIC_MODEL_REASONING_EFFORTS },
1675
1707
  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.",
1708
+ 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
1709
  },
1678
1710
  ];
@@ -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,
@@ -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");
@@ -10,6 +10,7 @@ import type { OcxProviderConfig } from "../types";
10
10
  import { providerUsesKeyAuthOverride, resolveProviderApiKey } from "./key-store";
11
11
  import { GCP_CREDENTIAL_MARKER_PREFIX } from "../lib/gcp-adc";
12
12
  import { captureProviderApiKeySelection } from "./api-key-selection-capture";
13
+ import { captureVertexEnvironmentKey } from "./vertex-environment-authority";
13
14
  import { assertProviderDestinationAllowed } from "../lib/destination-policy";
14
15
  import { redactSecretString, redactUrlForLog } from "../lib/redact";
15
16
  import { PROVIDER_REGISTRY, registryEntryForProviderDestination } from "./registry";
@@ -110,9 +111,35 @@ function usableResolvedApiKey(apiKey: string | undefined): string | undefined {
110
111
  return typeof resolved === "string" && resolved.trim().length > 0 ? resolved : undefined;
111
112
  }
112
113
 
114
+ /** Bind the environment values used by Vertex to the routed request for send-time checks. */
115
+ function snapshotVertexEnvironment(provider: OcxProviderConfig): OcxProviderConfig {
116
+ if (provider.adapter !== "google" || provider.googleMode !== "vertex") return provider;
117
+ const reference = provider._apiKeyAttempt?.reference;
118
+ if (reference && (reference.startsWith("keychain:") || reference.startsWith("$"))
119
+ && (!provider.apiKey?.trim() || provider.apiKey === "N/A" || provider.apiKey.startsWith("<") || reference === "keychain:")) {
120
+ throw new Error("Vertex API key reference could not be resolved");
121
+ }
122
+ const marker = provider.apiKey?.startsWith(GCP_CREDENTIAL_MARKER_PREFIX) === true;
123
+ const configuredKey = provider.apiKey && !provider.apiKey.startsWith("<") && provider.apiKey !== "N/A" ? provider.apiKey : undefined;
124
+ captureVertexEnvironmentKey(provider._apiKeyAttempt, provider);
125
+ if (!marker && (configuredKey || process.env.GOOGLE_CLOUD_API_KEY)) return provider;
126
+ return {
127
+ ...provider,
128
+ project: provider.project?.trim() ? provider.project : process.env.GOOGLE_CLOUD_PROJECT || process.env.GCLOUD_PROJECT,
129
+ location: provider.location || process.env.GOOGLE_CLOUD_LOCATION,
130
+ };
131
+ }
132
+
113
133
  export function routedProviderConfig(providerName: string, provider: OcxProviderConfig): OcxProviderConfig {
114
134
  provider = { ...provider, _apiKeyAttempt: provider._apiKeyAttempt ?? captureProviderApiKeySelection(provider) };
115
135
  const registryEntry = PROVIDER_REGISTRY.find(entry => entry.id === providerName);
136
+ if (provider.authMode === "forward" && (
137
+ (provider.adapter === "google" && provider.googleMode === "vertex")
138
+ || (registryEntry?.adapter === "google" && (provider.googleMode ?? registryEntry.googleMode) === "vertex"
139
+ && providerMatchesRegistryTransportWithStaticGuards(providerName, provider))
140
+ )) {
141
+ throw new Error("Vertex does not support forward authentication");
142
+ }
116
143
  if (!registryEntry || !providerMatchesRegistryTransportWithStaticGuards(providerName, provider)) {
117
144
  assertProviderDestinationAllowed(providerName, provider);
118
145
  // A row whose adapter no longer matches its registry entry still reaches the Responses
@@ -124,7 +151,7 @@ export function routedProviderConfig(providerName: string, provider: OcxProvider
124
151
  const destination = registryEntryForProviderDestination(provider);
125
152
  const inputModalities = provider.inputModalities === undefined
126
153
  ? registryInputModalitiesForDestination(providerName, provider) : undefined;
127
- return {
154
+ return snapshotVertexEnvironment({
128
155
  ...provider,
129
156
  ...(inputModalities ? { inputModalities } : {}),
130
157
  apiKey: usableResolvedApiKey(provider.apiKey),
@@ -140,7 +167,7 @@ export function routedProviderConfig(providerName: string, provider: OcxProvider
140
167
  ...(provider.dropResponsesReasoningItems === undefined && destination?.dropResponsesReasoningItems !== undefined
141
168
  ? { dropResponsesReasoningItems: destination.dropResponsesReasoningItems }
142
169
  : {}),
143
- };
170
+ });
144
171
  }
145
172
  const resolvedApiKey = usableResolvedApiKey(provider.apiKey);
146
173
  const staticModelCatalog = !providerSupportsLiveModelDiscovery(providerName, provider);
@@ -360,5 +387,5 @@ export function routedProviderConfig(providerName: string, provider: OcxProvider
360
387
  ...(thinkingBudgetModels ? { thinkingBudgetModels } : {}),
361
388
  };
362
389
  applyDirectReasoningEffortContracts(registryEntry, resolved, provider);
363
- return resolved;
390
+ return snapshotVertexEnvironment(resolved);
364
391
  }
@@ -30,6 +30,13 @@ export interface StaleNoVisionSeedProjection {
30
30
  }
31
31
 
32
32
  export const STALE_NO_VISION_SEEDS: readonly StaleNoVisionSeed[] = [
33
+ {
34
+ provider: "claude-cli",
35
+ seeds: [
36
+ // Released v2.94.0's complete text-only roster; preserve operator-edited lists.
37
+ ["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"],
38
+ ],
39
+ },
33
40
  {
34
41
  provider: "qoder",
35
42
  seeds: [
@@ -0,0 +1,50 @@
1
+ import { createHmac, randomBytes } from "node:crypto";
2
+ import { GCP_CREDENTIAL_MARKER_PREFIX } from "./api-key-resolve";
3
+ import type { ProviderApiKeySelection } from "../types/provider";
4
+ import type { OcxProviderConfig } from "../types";
5
+
6
+ // Keep the ambient key out of generic provider config and any serializable selection.
7
+ const digestKey = randomBytes(32);
8
+ export type VertexAmbientKeyAuthority = { digest: string; generation: number };
9
+ const keySnapshots = new WeakMap<ProviderApiKeySelection, { ambient?: VertexAmbientKeyAuthority; adapter: string; modelAdapters: string }>();
10
+ let observedKey: VertexAmbientKeyAuthority | undefined;
11
+ let keyGeneration = 0;
12
+
13
+ function ambientKeyDigest(): string {
14
+ return createHmac("sha256", digestKey).update(process.env.GOOGLE_CLOUD_API_KEY || "").digest("hex");
15
+ }
16
+
17
+ function observeAmbientKey(): VertexAmbientKeyAuthority {
18
+ const digest = ambientKeyDigest();
19
+ if (observedKey?.digest !== digest) observedKey = { digest, generation: ++keyGeneration };
20
+ return observedKey;
21
+ }
22
+
23
+ export function captureVertexAmbientKey(key: string): VertexAmbientKeyAuthority {
24
+ const current = observeAmbientKey();
25
+ const digest = createHmac("sha256", digestKey).update(key).digest("hex");
26
+ return digest === current.digest ? current : { digest, generation: -1 };
27
+ }
28
+
29
+ export function vertexAmbientKeyIsCurrent(expected: VertexAmbientKeyAuthority): boolean {
30
+ const current = observeAmbientKey();
31
+ return expected.digest === current.digest && expected.generation === current.generation;
32
+ }
33
+
34
+ function modelAdapterSignature(provider: OcxProviderConfig): string {
35
+ return JSON.stringify(Object.entries(provider.modelAdapters ?? {}).sort(([a], [b]) => a.localeCompare(b)));
36
+ }
37
+
38
+ export function captureVertexEnvironmentKey(selection: ProviderApiKeySelection | undefined, provider: OcxProviderConfig): void {
39
+ if (!selection || keySnapshots.has(selection)) return;
40
+ const configuredKey = provider.apiKey;
41
+ const ambient = !configuredKey?.startsWith(GCP_CREDENTIAL_MARKER_PREFIX)
42
+ && (!configuredKey || configuredKey.startsWith("<") || configuredKey === "N/A") ? observeAmbientKey() : undefined;
43
+ keySnapshots.set(selection, { adapter: provider.adapter, modelAdapters: modelAdapterSignature(provider), ambient });
44
+ }
45
+
46
+ export function vertexEnvironmentKeyIsCurrent(selection: ProviderApiKeySelection, current: OcxProviderConfig): boolean {
47
+ const expected = keySnapshots.get(selection);
48
+ return expected === undefined || (expected.adapter === current.adapter && expected.modelAdapters === modelAdapterSignature(current)
49
+ && (!expected.ambient || vertexAmbientKeyIsCurrent(expected.ambient)));
50
+ }
@@ -24,6 +24,35 @@ export function workBuddyCapacity(value: unknown): number | undefined {
24
24
  return Number.isFinite(number) && number >= 0 && number <= Number.MAX_SAFE_INTEGER ? number : undefined;
25
25
  }
26
26
 
27
+ /** Sum bounded numeric capacities as decimals before converting the result back to a number. */
28
+ function sumCapacities(values: readonly number[]): number {
29
+ const parts = values.map(value => {
30
+ const [coefficient, exponent = "0"] = value.toString().split("e");
31
+ const [whole, fraction = ""] = coefficient!.split(".");
32
+ let digits = BigInt(`${whole}${fraction}`);
33
+ let scale = fraction.length - Number(exponent);
34
+ if (scale < 0) { digits *= 10n ** BigInt(-scale); scale = 0; }
35
+ return { digits, scale };
36
+ });
37
+ const scale = Math.max(0, ...parts.map(part => part.scale));
38
+ const digits = parts.reduce((sum, part) => sum + part.digits * 10n ** BigInt(scale - part.scale), 0n);
39
+ return Number(`${digits}e-${scale}`);
40
+ }
41
+
42
+ function sumAmounts(rows: readonly WorkBuddyCreditAmount[]): WorkBuddyCreditAmount {
43
+ return {
44
+ total: sumCapacities(rows.map(row => row.total)),
45
+ used: sumCapacities(rows.map(row => row.used)),
46
+ remaining: sumCapacities(rows.map(row => row.remaining)),
47
+ frozen: sumCapacities(rows.map(row => row.frozen)),
48
+ };
49
+ }
50
+
51
+ /** Remaining credits when the provider omits them, bounded below by zero. */
52
+ export function remainingWorkBuddyCredits(total: number, used: number, frozen = 0): number {
53
+ return Math.max(0, sumCapacities([total, -used, -frozen]));
54
+ }
55
+
27
56
  function amount(value: unknown): WorkBuddyCreditAmount | undefined {
28
57
  const row = workBuddyRecord(value);
29
58
  const total = workBuddyCapacity(row.total), used = workBuddyCapacity(row.used);
@@ -53,29 +82,32 @@ function packageAmount(row: Record<string, unknown>): WorkBuddyCreditAmount | un
53
82
  const total = workBuddyCapacity(row.CycleTotalCapacity), used = workBuddyCapacity(row.CycleUsedCapacity);
54
83
  const frozen = row.CycleFrozenCapacity === undefined ? 0 : workBuddyCapacity(row.CycleFrozenCapacity);
55
84
  if (total === undefined || used === undefined || frozen === undefined) return undefined;
56
- const remaining = row.CycleRemainCapacity === undefined ? Math.max(0, total - used - frozen) : workBuddyCapacity(row.CycleRemainCapacity);
85
+ const remaining = row.CycleRemainCapacity === undefined ? remainingWorkBuddyCredits(total, used, frozen) : workBuddyCapacity(row.CycleRemainCapacity);
57
86
  return remaining === undefined ? undefined : { total, used, remaining, frozen };
58
87
  }
59
88
 
60
89
  export function parseWorkBuddyCredits(value: unknown): WorkBuddyCreditBalance | undefined {
61
90
  const summary = workBuddyRecord(value);
62
91
  if (!Array.isArray(summary.Packages) || summary.Packages.length > 512) return undefined;
63
- const balance: WorkBuddyCreditBalance = { total: 0, used: 0, remaining: 0, frozen: 0, groups: [] };
92
+ const packages: WorkBuddyCreditAmount[] = [];
64
93
  for (const raw of summary.Packages) {
65
94
  const quantities = packageAmount(workBuddyRecord(raw));
66
95
  if (!quantities) return undefined;
67
- for (const key of ["total", "used", "remaining", "frozen"] as const) balance[key] += quantities[key];
96
+ packages.push(quantities);
68
97
  }
98
+ const balance: WorkBuddyCreditBalance = { ...sumAmounts(packages), groups: [] };
69
99
  // CreditGroups is a breakdown of Packages, not another balance to add to it.
70
100
  if (Array.isArray(summary.CreditGroups) && summary.CreditGroups.length <= 16) {
101
+ const grouped = new Map<WorkBuddyCreditKind, WorkBuddyCreditAmount[]>();
71
102
  for (const raw of summary.CreditGroups) {
72
103
  const row = workBuddyRecord(raw), quantities = packageAmount(row);
73
104
  if (!quantities) continue;
74
105
  const kind = WORKBUDDY_CREDIT_KINDS.find(kind => kind === row.Kind) ?? "other";
75
- const existing = balance.groups.find(group => group.kind === kind);
76
- if (existing) for (const key of ["total", "used", "remaining", "frozen"] as const) existing[key] += quantities[key];
77
- else balance.groups.push({ kind, ...quantities });
106
+ const rows = grouped.get(kind) ?? [];
107
+ rows.push(quantities);
108
+ grouped.set(kind, rows);
78
109
  }
110
+ balance.groups = [...grouped].map(([kind, rows]) => ({ kind, ...sumAmounts(rows) }));
79
111
  }
80
112
  return normalizeWorkBuddyCredits(balance);
81
113
  }