@bitkyc08/opencodex 2.91.0 → 2.93.0-preview.20261027

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 (360) hide show
  1. package/bin/ocx.mjs +47 -8
  2. package/gui/dist/assets/App-CJZoq-uF.js +58 -0
  3. package/gui/dist/assets/{Tray-BuLy7hL1.js → Tray-BWQPcgZn.js} +1 -1
  4. package/gui/dist/assets/index-DRe8Hhfz.css +1 -0
  5. package/gui/dist/assets/index-Xfct8owH.js +94 -0
  6. package/gui/dist/assets/quota-summary-DxToX1rV.js +1 -0
  7. package/gui/dist/index.html +2 -2
  8. package/gui/dist/provider-icons/workbuddy-color.svg +29 -0
  9. package/package.json +8 -7
  10. package/src/adapters/anthropic.ts +28 -5
  11. package/src/adapters/coding-agent/batch-dispatcher.ts +122 -0
  12. package/src/adapters/coding-agent/profile.ts +54 -16
  13. package/src/adapters/coding-agent/turn.ts +30 -2
  14. package/src/adapters/command-code.ts +114 -7
  15. package/src/adapters/cursor/native-exec-fs.ts +11 -9
  16. package/src/adapters/devin/live-models.ts +4 -0
  17. package/src/adapters/google-vertex-endpoint.ts +9 -1
  18. package/src/adapters/google-vertex-key-project.ts +223 -0
  19. package/src/adapters/google-wire-compiler.ts +1 -2
  20. package/src/adapters/google.ts +13 -3
  21. package/src/adapters/kiro/reasoning.ts +2 -0
  22. package/src/adapters/kiro-refusal.ts +6 -1
  23. package/src/adapters/kiro-wire.ts +1 -1
  24. package/src/adapters/openai-chat/messages.ts +8 -2
  25. package/src/adapters/openai-chat/passthrough.ts +35 -14
  26. package/src/adapters/openai-chat/reasoning-replay.ts +27 -16
  27. package/src/adapters/openai-chat/reasoning-wire.ts +117 -8
  28. package/src/adapters/openai-chat/required-tool-result.ts +64 -0
  29. package/src/adapters/openai-chat/tool-name-registry.ts +3 -1
  30. package/src/adapters/openai-chat.ts +9 -10
  31. package/src/adapters/openai-responses/passthrough.ts +7 -4
  32. package/src/adapters/openai-responses/reasoning.ts +13 -0
  33. package/src/adapters/openai-responses/request-strips.ts +60 -0
  34. package/src/adapters/qoder/adapter.ts +129 -8
  35. package/src/adapters/qoder/scaffold-guard.ts +5 -0
  36. package/src/adapters/reasoning-controls.ts +16 -0
  37. package/src/adapters/registry.ts +5 -0
  38. package/src/adapters/tool-call-id.ts +1 -3
  39. package/src/adapters/workbuddy-schema.ts +61 -0
  40. package/src/adapters/workbuddy.ts +68 -0
  41. package/src/bridge/errors.ts +27 -0
  42. package/src/bridge/response-json.ts +1 -1
  43. package/src/bridge/sse.ts +1 -1
  44. package/src/bridge.ts +1 -1
  45. package/src/chat/inbound.ts +4 -1
  46. package/src/chat/outbound.ts +20 -6
  47. package/src/chat/reasoning-details.ts +28 -5
  48. package/src/claude/desktop-first-party.ts +54 -4
  49. package/src/claude/desktop-picker.ts +11 -8
  50. package/src/claude/first-party-settings.ts +3 -1
  51. package/src/claude/inbound.ts +2 -1
  52. package/src/claude/intercept/local-ca.ts +2 -1
  53. package/src/claude/intercept/picker-ca-cleanup.ts +4 -2
  54. package/src/claude/intercept/picker-ca-startup.ts +3 -1
  55. package/src/claude/intercept/picker-models.ts +6 -3
  56. package/src/claude/intercept/picker-runtime.ts +3 -2
  57. package/src/claude/intercept/runtime.ts +6 -3
  58. package/src/claude/model-info.ts +31 -8
  59. package/src/cli/account-api.ts +11 -0
  60. package/src/cli/capabilities-agents-routing.ts +3 -3
  61. package/src/cli/capabilities-base.ts +7 -1
  62. package/src/cli/capabilities-observe-system.ts +10 -0
  63. package/src/cli/claude-desktop.ts +9 -8
  64. package/src/cli/claude.ts +3 -2
  65. package/src/cli/codex-cli-update.ts +8 -0
  66. package/src/cli/codex-shim-autorestore.ts +9 -0
  67. package/src/cli/combo-result.ts +13 -0
  68. package/src/cli/combo-stats.ts +3 -0
  69. package/src/cli/combo.ts +83 -41
  70. package/src/cli/cross-home-owner.ts +13 -1
  71. package/src/cli/dispatch.ts +25 -6
  72. package/src/cli/ensure-desired-integrations.ts +8 -6
  73. package/src/cli/export-command.ts +4 -1
  74. package/src/cli/help.ts +2 -1
  75. package/src/cli/index.ts +45 -45
  76. package/src/cli/integration-plan-dto.ts +4 -0
  77. package/src/cli/launcher-context.ts +49 -2
  78. package/src/cli/link.ts +45 -32
  79. package/src/cli/opencode.ts +20 -9
  80. package/src/cli/provider.ts +2 -1
  81. package/src/cli/registry.ts +6 -4
  82. package/src/cli/root.ts +9 -0
  83. package/src/cli/status.ts +59 -1
  84. package/src/cli/stop-restore.ts +113 -0
  85. package/src/cli/sync-expectation.ts +60 -0
  86. package/src/cli/uninstall-integrations.ts +41 -7
  87. package/src/cli/usage-compare.ts +68 -12
  88. package/src/client/connect.ts +40 -3
  89. package/src/client/link-home.ts +10 -1
  90. package/src/client/link-ingress.ts +1 -1
  91. package/src/client/link-readiness.ts +97 -0
  92. package/src/client/link-relay-transport.ts +79 -11
  93. package/src/client/link-relay.ts +74 -15
  94. package/src/client/link-tunnel.ts +45 -18
  95. package/src/client/machine-api.ts +3 -1
  96. package/src/client/machine-listener.ts +20 -2
  97. package/src/client/runtime.ts +20 -2
  98. package/src/client/sync-expectation.ts +118 -0
  99. package/src/clients/config-export/agent-clients.ts +96 -0
  100. package/src/clients/config-export/contracts.ts +25 -7
  101. package/src/clients/config-export/qoder.ts +38 -23
  102. package/src/clients/config-export/reasoning-metadata.ts +55 -8
  103. package/src/clients/config-export.ts +12 -0
  104. package/src/clients/lazycodex.ts +7 -2
  105. package/src/clients/reasoning-controls.ts +49 -0
  106. package/src/codex/account-store.ts +17 -3
  107. package/src/codex/app-server-restart-service.ts +6 -5
  108. package/src/codex/auth-api/account-identity.ts +14 -0
  109. package/src/codex/auth-api/account-list.ts +29 -2
  110. package/src/codex/auth-api/http.ts +13 -0
  111. package/src/codex/auth-api/main-account-probe.ts +2 -2
  112. package/src/codex/auth-api/pool-mode-gate.ts +16 -3
  113. package/src/codex/auth-api/pool-quota-probe.ts +15 -0
  114. package/src/codex/auth-context.ts +15 -12
  115. package/src/codex/catalog/build-entries.ts +22 -0
  116. package/src/codex/catalog/configured-tiers.ts +70 -0
  117. package/src/codex/catalog/effort.ts +52 -11
  118. package/src/codex/catalog/gather-capture.ts +5 -2
  119. package/src/codex/catalog/heal-observation.ts +155 -13
  120. package/src/codex/catalog/metadata.ts +6 -0
  121. package/src/codex/catalog/model-hints.ts +60 -11
  122. package/src/codex/catalog/model-visibility.ts +3 -2
  123. package/src/codex/catalog/native-models.ts +18 -3
  124. package/src/codex/catalog/parsing.ts +10 -8
  125. package/src/codex/catalog/pinned-models.ts +2 -1
  126. package/src/codex/catalog/provider-models.ts +18 -13
  127. package/src/codex/catalog/retained-sync.ts +2 -1
  128. package/src/codex/catalog/routed-gather.ts +19 -20
  129. package/src/codex/catalog/write-audit.ts +3 -2
  130. package/src/codex/catalog-self-heal.ts +43 -23
  131. package/src/codex/chatgpt-refresh-failure.ts +6 -2
  132. package/src/codex/cli-install-provenance.ts +418 -0
  133. package/src/codex/cli-installation-targets.ts +5 -1
  134. package/src/codex/cli-update-plan.ts +43 -16
  135. package/src/codex/collision-identity.ts +30 -5
  136. package/src/codex/convergence.ts +4 -3
  137. package/src/codex/data/roster-pinned-models.json +177 -1
  138. package/src/codex/desired-state.ts +6 -1
  139. package/src/codex/desktop-app/picker-freshness.ts +10 -8
  140. package/src/codex/desktop-compatibility/installed-build.ts +88 -12
  141. package/src/codex/desktop-compatibility/runtime.ts +29 -5
  142. package/src/codex/desktop-compatibility/usage-activation.ts +2 -1
  143. package/src/codex/desktop-compatibility/usage-controller.ts +9 -1
  144. package/src/codex/desktop-compatibility/windows-certificate-trust.ts +46 -12
  145. package/src/codex/inject/config-toml.ts +0 -18
  146. package/src/codex/inject/plan.ts +18 -3
  147. package/src/codex/inject/remove.ts +6 -2
  148. package/src/codex/inject.ts +1 -1
  149. package/src/codex/journal.ts +61 -1
  150. package/src/codex/model-entitlements.ts +1 -1
  151. package/src/codex/native-main-owner.ts +27 -1
  152. package/src/codex/native-profile-store.ts +2 -1
  153. package/src/codex/pool-credit-policy.ts +35 -1
  154. package/src/codex/pool-refresh-backoff.ts +3 -1
  155. package/src/codex/quota-types.ts +3 -0
  156. package/src/codex/quota.ts +24 -4
  157. package/src/codex/role-auto-assign.ts +6 -2
  158. package/src/codex/subagent-defaults.ts +49 -4
  159. package/src/codex/user-identity.ts +35 -6
  160. package/src/codex/windows-current-sid.ts +162 -0
  161. package/src/combos/failover.ts +17 -2
  162. package/src/combos/jev-decision-contract.ts +22 -1
  163. package/src/combos/jev-quota-activation.ts +5 -1
  164. package/src/combos/jev-quota-route.ts +1 -1
  165. package/src/combos/jev-quota.ts +9 -1
  166. package/src/combos/jev-service-exchange.ts +3 -1
  167. package/src/combos/jev-session-pin-config.ts +51 -0
  168. package/src/combos/jev.ts +101 -9
  169. package/src/combos/resolve.ts +45 -1
  170. package/src/combos/types.ts +43 -0
  171. package/src/config/load-degrade.ts +5 -0
  172. package/src/config/paths.ts +19 -3
  173. package/src/config/pending-teardown.ts +22 -1
  174. package/src/config/provider-validation.ts +22 -4
  175. package/src/config/removed-opencode-free.ts +11 -0
  176. package/src/config/schema/leaf-validators.ts +6 -0
  177. package/src/generated/compatibility-version.json +467 -311
  178. package/src/generated/model-metadata.ts +5 -5
  179. package/src/images/loop.ts +16 -2
  180. package/src/integrations/catalog-refresh.ts +1 -1
  181. package/src/integrations/hermes-profiles.ts +251 -0
  182. package/src/integrations/merge.ts +8 -0
  183. package/src/integrations/mutation-plan.ts +19 -4
  184. package/src/integrations/registry.ts +5 -0
  185. package/src/integrations/state.ts +36 -1
  186. package/src/integrations/writer.ts +18 -4
  187. package/src/lib/bun-path-runtime.mjs +2 -1
  188. package/src/lib/decision-quota-sink.ts +10 -0
  189. package/src/lib/errors.ts +62 -0
  190. package/src/lib/eventstream-decoder.ts +81 -37
  191. package/src/lib/opaque-proxy-tunnel.ts +32 -8
  192. package/src/lib/pinned-http.ts +35 -2
  193. package/src/lib/process-control.ts +13 -1
  194. package/src/lib/socks5-fetch.ts +59 -64
  195. package/src/lib/socks5-upload-waiter.ts +50 -0
  196. package/src/lib/sse-decoder.ts +7 -2
  197. package/src/lib/state-store-sweeper.ts +40 -14
  198. package/src/lib/translator-budget.ts +4 -4
  199. package/src/lib/upstream-retry.ts +4 -1
  200. package/src/lib/windows-native-principal-worker.ts +14 -0
  201. package/src/lib/windows-native-principal.ts +188 -0
  202. package/src/lib/windows-secret-acl.ts +39 -3
  203. package/src/lib/windows-user-principal.ts +62 -18
  204. package/src/link/diagnostics.ts +193 -0
  205. package/src/link/relay-auth.ts +6 -0
  206. package/src/link/ssh-config.ts +35 -3
  207. package/src/link/status-projection.ts +39 -0
  208. package/src/link/supervisor.ts +45 -12
  209. package/src/link/tunnel-history.ts +109 -0
  210. package/src/link/tunnel-state.ts +80 -17
  211. package/src/messaging/remote-files.ts +24 -1
  212. package/src/oauth/generic-account-failover.ts +91 -7
  213. package/src/oauth/index.ts +15 -0
  214. package/src/oauth/model-discovery-auth.ts +5 -0
  215. package/src/oauth/store.ts +4 -1
  216. package/src/oauth/token-guardian.ts +7 -0
  217. package/src/oauth/types.ts +9 -0
  218. package/src/oauth/workbuddy.ts +139 -0
  219. package/src/providers/account-quota-disk.ts +12 -4
  220. package/src/providers/antigravity-quota-identity.ts +37 -0
  221. package/src/providers/base-url-choices.ts +8 -5
  222. package/src/providers/codebuddy-models.ts +6 -0
  223. package/src/providers/codex-capacity.ts +3 -1
  224. package/src/providers/derive.ts +51 -3
  225. package/src/providers/kiro-models.ts +3 -0
  226. package/src/providers/mimo-thinking.ts +12 -0
  227. package/src/providers/model-discovery.ts +2 -0
  228. package/src/providers/model-rename-fields.ts +2 -0
  229. package/src/providers/model-rename-migration.ts +10 -0
  230. package/src/providers/openai-sidecar-credit.ts +2 -2
  231. package/src/providers/quota/account-cache.ts +3 -2
  232. package/src/providers/quota/antigravity.ts +25 -14
  233. package/src/providers/quota/report-cache.ts +13 -4
  234. package/src/providers/quota/vendor-probes-key.ts +60 -0
  235. package/src/providers/quota/workbuddy.ts +83 -0
  236. package/src/providers/quota-decision-antigravity.ts +64 -0
  237. package/src/providers/quota-decision-publication.ts +11 -0
  238. package/src/providers/quota-decision-snapshot.ts +21 -4
  239. package/src/providers/quota-types.ts +2 -0
  240. package/src/providers/quota.ts +3 -1
  241. package/src/providers/reasoning-capabilities.ts +76 -0
  242. package/src/providers/registry/entries-core.ts +23 -12
  243. package/src/providers/registry/entries-extended.ts +83 -27
  244. package/src/providers/registry/model-ids.ts +5 -0
  245. package/src/providers/registry/model-seeds.ts +120 -56
  246. package/src/providers/registry/types.ts +29 -2
  247. package/src/providers/resolved-model-policy.ts +30 -10
  248. package/src/providers/routed-config.ts +24 -1
  249. package/src/providers/stale-model-roster-migration.ts +123 -18
  250. package/src/providers/workbuddy-credit-balance.ts +81 -0
  251. package/src/providers/workbuddy-models.ts +37 -0
  252. package/src/providers/workbuddy.ts +60 -0
  253. package/src/remote-control/workspace-pi-runtime.ts +11 -6
  254. package/src/responses/compaction-summary.ts +45 -0
  255. package/src/responses/muse-tool-name-alias.ts +1 -2
  256. package/src/responses/parser.ts +3 -2
  257. package/src/responses/reasoning-replay-cache.ts +18 -14
  258. package/src/responses/schema.ts +1 -0
  259. package/src/responses/thought-signature-replay.ts +10 -2
  260. package/src/router.ts +2 -0
  261. package/src/routing/analytics.ts +2 -3
  262. package/src/routing/capability.ts +8 -2
  263. package/src/routing/fallback-policy.ts +3 -3
  264. package/src/routing/history/ingest.ts +28 -3
  265. package/src/server/auth-cors.ts +4 -2
  266. package/src/server/chat-completions.ts +21 -1
  267. package/src/server/chat-native-eligibility.ts +7 -0
  268. package/src/server/chat-native-reasoning.ts +24 -7
  269. package/src/server/chat-native.ts +13 -2
  270. package/src/server/claude-messages.ts +3 -0
  271. package/src/server/direct-local-http.ts +5 -2
  272. package/src/server/effort-policy.ts +5 -1
  273. package/src/server/index/link-relay-sessions.ts +9 -5
  274. package/src/server/index/live-sideband.ts +18 -15
  275. package/src/server/index/optional-listeners.ts +4 -0
  276. package/src/server/index/serve-options.ts +5 -4
  277. package/src/server/local-management-read-client.ts +3 -1
  278. package/src/server/management/agent-settings-routes.ts +27 -15
  279. package/src/server/management/combo-routes.ts +14 -4
  280. package/src/server/management/config-routes.ts +2 -2
  281. package/src/server/management/decision-discovery.ts +12 -2
  282. package/src/server/management/hermes-profile-routes.ts +156 -0
  283. package/src/server/management/integration-routes.ts +85 -24
  284. package/src/server/management/link-routes.ts +5 -2
  285. package/src/server/management/model-routes.ts +2 -2
  286. package/src/server/management/model-row-export-metadata.ts +25 -6
  287. package/src/server/management/model-rows.ts +15 -20
  288. package/src/server/management/native-integration-routes.ts +11 -8
  289. package/src/server/management/provider-routes.ts +1 -1
  290. package/src/server/management/route-registry.ts +4 -0
  291. package/src/server/management-api.ts +5 -0
  292. package/src/server/models-capabilities.ts +21 -3
  293. package/src/server/port-reclaim.ts +51 -9
  294. package/src/server/request-log-conversation.ts +49 -0
  295. package/src/server/request-log.ts +2 -0
  296. package/src/server/responses/adapter-delivery.ts +11 -1
  297. package/src/server/responses/adapter-dispatch.ts +2 -2
  298. package/src/server/responses/anthropic-thinking-recovery.ts +1 -0
  299. package/src/server/responses/codex-ws-exchange.ts +39 -9
  300. package/src/server/responses/codex-ws-session.ts +38 -4
  301. package/src/server/responses/codex-ws-wire.ts +6 -1
  302. package/src/server/responses/combo-required-tool-contract.ts +103 -0
  303. package/src/server/responses/combo-stream-preflight.ts +8 -1
  304. package/src/server/responses/compact.ts +14 -5
  305. package/src/server/responses/context-overflow.ts +8 -1
  306. package/src/server/responses/core-combo-failure.ts +10 -0
  307. package/src/server/responses/core-combo.ts +74 -44
  308. package/src/server/responses/core-lifetime.ts +5 -2
  309. package/src/server/responses/core-normalize.ts +17 -4
  310. package/src/server/responses/core-opaque-recovery.ts +1 -0
  311. package/src/server/responses/core-options.ts +7 -0
  312. package/src/server/responses/core-replay.ts +2 -1
  313. package/src/server/responses/jev-combo-choice.ts +39 -0
  314. package/src/server/responses/jev-session-pin.ts +203 -0
  315. package/src/server/responses/main-hard-lock-routing.ts +60 -44
  316. package/src/server/responses/passthrough-delivery.ts +44 -2
  317. package/src/server/responses/policy-fallback.ts +6 -1
  318. package/src/server/responses/request-compression.ts +12 -7
  319. package/src/server/responses/request-prepare.ts +32 -7
  320. package/src/server/responses/request-sidecar-auth.ts +2 -0
  321. package/src/server/responses/request-transport.ts +25 -6
  322. package/src/server/responses/response-effects.ts +22 -10
  323. package/src/server/responses/run-turn-execution.ts +2 -4
  324. package/src/server/responses/sidecar-execution.ts +13 -7
  325. package/src/server/responses-phase-inference.ts +267 -0
  326. package/src/server/sse-payload-rewrite.ts +14 -1
  327. package/src/server/stop-teardown.ts +36 -1
  328. package/src/server/ws-bridge.ts +1 -1
  329. package/src/service/definition.ts +20 -8
  330. package/src/service/desktop-supervision.d.mts +7 -4
  331. package/src/service/desktop-supervision.mjs +90 -13
  332. package/src/service/ownership-mutation-lease.mjs +21 -7
  333. package/src/types/config.ts +14 -2
  334. package/src/types/provider.ts +29 -7
  335. package/src/types/request.ts +11 -0
  336. package/src/types/wire.ts +1 -0
  337. package/src/types.ts +1 -0
  338. package/src/update/bind-probe.ts +29 -0
  339. package/src/update/codex-cli-update-launch-policy.d.mts +9 -0
  340. package/src/update/codex-cli-update-launch-policy.mjs +30 -0
  341. package/src/update/job.ts +10 -29
  342. package/src/update/npm-install-job.ps1 +173 -0
  343. package/src/update/npm-install.mjs +70 -0
  344. package/src/update/stop-contract.d.mts +1 -0
  345. package/src/update/stop-contract.mjs +14 -0
  346. package/src/update/stop-decision.d.mts +1 -1
  347. package/src/update/stop-decision.mjs +13 -3
  348. package/src/update/teardown-handover.ts +166 -0
  349. package/src/update/transactional-install.d.mts +14 -3
  350. package/src/update/transactional-install.mjs +33 -7
  351. package/src/usage/expected-prices.ts +64 -31
  352. package/src/usage/jev-stats.ts +54 -14
  353. package/src/usage/timeline.ts +19 -9
  354. package/src/vision/eligibility.ts +15 -5
  355. package/src/vision/plan.ts +2 -2
  356. package/src/web-search/loop.ts +16 -2
  357. package/gui/dist/assets/App-nZ34cR5G.js +0 -58
  358. package/gui/dist/assets/index-DGXS51sp.js +0 -94
  359. package/gui/dist/assets/index-DPeB9HpV.css +0 -1
  360. package/gui/dist/assets/quota-summary-DO1Sx5TM.js +0 -1
@@ -47,6 +47,8 @@ const VENICE_BASE_URL = "https://api.venice.ai/api/v1";
47
47
  const SYNTHETIC_BASE_URL = "https://api.synthetic.new/v2";
48
48
  const DEEPINFRA_BASE_URL = "https://api.deepinfra.com";
49
49
  const NEURALWATT_BASE_URL = "https://api.neuralwatt.com/v1";
50
+ const ABLITERATION_BASE_URL = "https://api.abliteration.ai";
51
+ const ABLITERATION_CREDITS_URL = `${ABLITERATION_BASE_URL}/v1/credits`;
50
52
 
51
53
 
52
54
  function isCanonicalA6apiBaseUrl(baseUrl: string): boolean {
@@ -132,6 +134,11 @@ function isCanonicalNeuralwattBaseUrl(baseUrl: string): boolean {
132
134
  return normalizedBaseUrl(baseUrl) === NEURALWATT_BASE_URL;
133
135
  }
134
136
 
137
+ function isCanonicalAbliterationBaseUrl(baseUrl: string): boolean {
138
+ const normalized = normalizedBaseUrl(baseUrl);
139
+ return normalized === ABLITERATION_BASE_URL || normalized === `${ABLITERATION_BASE_URL}/v1`;
140
+ }
141
+
135
142
  function a6apiPayload(value: unknown): Record<string, unknown> | null {
136
143
  const body = asRecord(value);
137
144
  return asRecord(body?.data) ?? body;
@@ -1043,6 +1050,56 @@ async function fetchNeuralwattQuota(provider: string, config: OcxProviderConfig)
1043
1050
  return windows > 0 ? report(provider, "neuralwatt:quota", quota) : null;
1044
1051
  }
1045
1052
 
1053
+ /**
1054
+ * Abliteration `GET /v1/credits` body: `{ data: { total_credits, total_usage } }`, both in USD.
1055
+ * `total_credits` is everything granted or purchased and `total_usage` is finalized spend, so the
1056
+ * balance is their difference. A well-formed reply with zero total credits is authoritative: it has
1057
+ * no ceiling to meter against, so it clears any previous row instead of fabricating a bar. A
1058
+ * malformed reply returns null and leaves the last-good row in place.
1059
+ */
1060
+ export function parseAbliterationCredits(
1061
+ body: Record<string, unknown> | null,
1062
+ ): ProviderQuota | typeof AUTHORITATIVE_EMPTY_QUOTA | null {
1063
+ const data = asRecord(body?.data);
1064
+ const total = toFiniteNumber(data?.total_credits);
1065
+ const used = toFiniteNumber(data?.total_usage);
1066
+ if (total === undefined || used === undefined || total < 0 || used < 0) return null;
1067
+ if (total === 0) return AUTHORITATIVE_EMPTY_QUOTA;
1068
+ const percent = normalizePercent((used / total) * 100);
1069
+ if (percent === undefined) return null;
1070
+ return {
1071
+ creditsUsd: { used, limit: total, remaining: Math.max(0, total - used), percent },
1072
+ updatedAt: Date.now(),
1073
+ };
1074
+ }
1075
+
1076
+ /**
1077
+ * Abliteration `GET /v1/credits` — the organization credit balance for the active project key.
1078
+ * The balance funds every inference request on this key, so display and routing scope agree.
1079
+ * `503 credit_balance_unavailable`, 408 and 429 are transient and keep the last-good row.
1080
+ */
1081
+ async function fetchAbliterationQuota(provider: string, config: OcxProviderConfig): Promise<ProviderQuotaProbeResult> {
1082
+ // Never send a configured API key to a lookalike host or through a redirect.
1083
+ if (!isCanonicalAbliterationBaseUrl(config.baseUrl)) return null;
1084
+ const apiKey = resolveProviderApiKey(config.apiKey)?.trim();
1085
+ if (!apiKey) return null;
1086
+ const response = await quotaFetch(provider, config, ABLITERATION_CREDITS_URL, {
1087
+ headers: { Accept: "application/json", Authorization: `Bearer ${apiKey}` },
1088
+ redirect: "error",
1089
+ signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
1090
+ });
1091
+ if (!response.ok) {
1092
+ return response.status >= 400 && response.status < 500 && response.status !== 408 && response.status !== 429
1093
+ ? TERMINAL_QUOTA_FAILURE
1094
+ : null;
1095
+ }
1096
+ const raw = await readQuotaJson(response);
1097
+ if (raw === QUOTA_JSON_READ_FAILURE) return null;
1098
+ const quota = parseAbliterationCredits(asRecord(raw));
1099
+ if (quota === null || quota === AUTHORITATIVE_EMPTY_QUOTA) return quota;
1100
+ return keyReport(provider, "abliteration:credits", quota, config, apiKey, quota);
1101
+ }
1102
+
1046
1103
 
1047
1104
  export function normalizedBaseUrl(value: string): string | null {
1048
1105
  try {
@@ -1371,6 +1428,9 @@ export function keyQuotaReaderForProvider(name: string, provider: OcxProviderCon
1371
1428
  if (name === "synthetic" && isCanonicalSyntheticBaseUrl(provider.baseUrl)) return fetchSyntheticQuota;
1372
1429
  if (name === "deepinfra" && isCanonicalDeepInfraBaseUrl(provider.baseUrl)) return fetchDeepInfraQuota;
1373
1430
  if (name === "neuralwatt" && isCanonicalNeuralwattBaseUrl(provider.baseUrl)) return fetchNeuralwattQuota;
1431
+ // Abliteration has no registry preset, so it is usually a custom provider under any name; the
1432
+ // canonical-URL guard alone decides eligibility and keeps the key off lookalike hosts.
1433
+ if (isCanonicalAbliterationBaseUrl(provider.baseUrl)) return fetchAbliterationQuota;
1374
1434
  return null;
1375
1435
  }
1376
1436
 
@@ -0,0 +1,83 @@
1
+ import type { OAuthCredentials } from "../../oauth/types";
2
+ import { workBuddyApi, WorkBuddyApiError } from "../../oauth/workbuddy";
3
+ import { workBuddyHeaders } from "../workbuddy";
4
+ import { parseWorkBuddyCredits, workBuddyCapacity, workBuddyRecord, type WorkBuddyCreditBalance } from "../workbuddy-credit-balance";
5
+ import { REQUEST_TIMEOUT_MS } from "../quota-wire";
6
+ import { TERMINAL_QUOTA_FAILURE, type ProviderQuotaProbeResult } from "./report-cache";
7
+
8
+ function packageEnd(row: Record<string, unknown>): number | undefined {
9
+ const deduction = workBuddyCapacity(row.DeductionEndTime);
10
+ if (deduction && Number.isFinite(new Date(deduction).getTime())) return deduction;
11
+ for (const value of [row.ExpiredTime, row.CycleEndTime]) {
12
+ if (typeof value !== "string") continue;
13
+ const date = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/.test(value)
14
+ ? `${value.replace(" ", "T")}+08:00` : value;
15
+ const parsed = Date.parse(date);
16
+ if (parsed > 0) return parsed;
17
+ }
18
+ return undefined;
19
+ }
20
+
21
+ export function workBuddyExpiringCredits(packages: unknown[], codes: ReadonlySet<string>, now: number): WorkBuddyCreditBalance["expiring"] {
22
+ let at = Infinity, amount = 0;
23
+ for (const raw of packages) {
24
+ const row = workBuddyRecord(raw);
25
+ if (typeof row.PackageCode !== "string" || !codes.has(row.PackageCode) || String(row.CapacityType) === "4") continue;
26
+ const remaining = workBuddyCapacity(row.CycleCapacityRemainPrecise || row.CycleCapacityRemain);
27
+ const end = packageEnd(row);
28
+ if (!remaining || !end || end <= now) continue;
29
+ if (end < at) { at = end; amount = remaining; }
30
+ else if (end === at) amount += remaining;
31
+ }
32
+ return Number.isFinite(at) && Number.isFinite(amount) ? { amount, at } : undefined;
33
+ }
34
+
35
+ async function expiringCredits(summary: Record<string, unknown>, headers: Record<string, string>, signal: AbortSignal, now: number) {
36
+ const packages = Array.isArray(summary.Packages) ? summary.Packages : [];
37
+ const codes = [...new Set(packages.map(raw => workBuddyRecord(raw).PackageCode)
38
+ .filter((code): code is string => typeof code === "string" && /^[A-Za-z0-9_-]{1,128}$/.test(code)))];
39
+ if (!codes.length) return undefined;
40
+ const day = new Date(now + 8 * 3600_000).toISOString().slice(0, 10);
41
+ const lists = await Promise.all(["paid", "free"].map(async kind => {
42
+ const accounts: unknown[] = [];
43
+ for (let page = 1; page <= 10; page++) {
44
+ const data = await workBuddyApi(`/billing/meter/get-user-resource-${kind}-packages`, headers, signal, true, {
45
+ PageNumber: page, PageSize: 200, Status: [0, 3], PackageCodes: codes,
46
+ ...(kind === "paid" ? { NeedRenewInfo: true }
47
+ : { SlicePeriodStartTime: `${day} 00:00:00`, SlicePeriodEndTime: `${day} 23:59:59` }),
48
+ });
49
+ if (!Array.isArray(data.Accounts) || data.Accounts.length > 200) throw new Error("Invalid WorkBuddy package list");
50
+ accounts.push(...data.Accounts);
51
+ const total = workBuddyCapacity(data.TotalCount);
52
+ if (data.Accounts.length < 200 || total !== undefined && accounts.length >= total) return accounts;
53
+ }
54
+ throw new Error("WorkBuddy package list exceeded page limit");
55
+ }));
56
+ return workBuddyExpiringCredits(lists.flat(), new Set(codes), now);
57
+ }
58
+
59
+ export async function fetchWorkBuddyQuota(provider: string, credential: OAuthCredentials): Promise<ProviderQuotaProbeResult> {
60
+ if (!credential.workbuddy) return null;
61
+ const signal = AbortSignal.timeout(REQUEST_TIMEOUT_MS), now = Date.now();
62
+ try {
63
+ const headers = workBuddyHeaders(credential.access, credential.workbuddy);
64
+ const summary = await workBuddyApi("/billing/meter/get-user-resource-summary", headers, signal, true);
65
+ let credits = parseWorkBuddyCredits(summary);
66
+ if (credential.workbuddy.enterpriseId && (!credits || credits.total === 0)) {
67
+ const team = await workBuddyApi("/billing/meter/get-enterprise-user-usage", headers, signal, true);
68
+ const total = workBuddyCapacity(team.limitNum), used = workBuddyCapacity(team.credit);
69
+ if (total === undefined || used === undefined) return null;
70
+ credits = { total, used, remaining: Math.max(0, total - used), frozen: 0, groups: [] };
71
+ }
72
+ if (!credits) return null;
73
+ if (credits.remaining > 0) {
74
+ // Optional expiry failures must not erase a successful balance reading.
75
+ credits.expiring = await expiringCredits(summary, headers, signal, now).catch(() => undefined);
76
+ }
77
+ const updatedAt = Date.now();
78
+ return { provider, label: "WorkBuddy AI", source: "WorkBuddy credits", updatedAt,
79
+ reverseEngineered: true, quota: { updatedAt, workbuddyCredits: credits } };
80
+ } catch (error) {
81
+ return error instanceof WorkBuddyApiError && error.status === 401 ? TERMINAL_QUOTA_FAILURE : null;
82
+ }
83
+ }
@@ -0,0 +1,64 @@
1
+ /** Optional snapshot owner. No store reads: roster input comes only from loaded-store notifications. */
2
+ import { getConfigDir } from "../config/paths";
3
+ import { captureConfigGeneration } from "../lib/state-store-sweeper";
4
+ import { ANTIGRAVITY_OAUTH_STORE_KEY, antigravityQuotaCredentialGeneration, antigravityQuotaEligible, antigravityQuotaPolicy } from "./antigravity-quota-identity";
5
+ import type { AuthStore } from "../oauth/store";
6
+ import type { OcxProviderConfig } from "../types";
7
+ import type { AntigravityQuotaObservation, AntigravityQuotaReceipt } from "../lib/decision-quota-sink";
8
+ import type { DecisionQuotaWindow } from "./quota-decision-snapshot";
9
+
10
+ type Owner = { root: string; id: string; generation: string; revision: string };
11
+ type Receipt = Owner & { owner: Owner; name: string; policy: string; configGeneration: number; epoch: number };
12
+ let owner: Owner | undefined;
13
+ let epoch = 0;
14
+ const receipts = new WeakMap<AntigravityQuotaReceipt, Receipt>();
15
+ let observations = new Map<string, { receipt: Receipt; windows: readonly DecisionQuotaWindow[] }>();
16
+
17
+ /** Any roster transition retires old receipts, including switching away and back. */
18
+ export function observeAntigravityQuotaStore(store: AuthStore): void {
19
+ const set = store[ANTIGRAVITY_OAUTH_STORE_KEY];
20
+ const account = set?.accounts.length === 1 ? set.accounts[0] : undefined;
21
+ const next = account && set?.activeAccountId === account.id && !account.paused && !account.needsReauth
22
+ && account.credential.access && account.credential.projectId
23
+ ? { root: getConfigDir(), id: account.id, generation: antigravityQuotaCredentialGeneration(account.credential), revision: JSON.stringify([account.loginId, account.pauseRevision, set.selectionRevision]) } : undefined;
24
+ if (owner?.root === next?.root && owner?.id === next?.id && owner?.generation === next?.generation && owner?.revision === next?.revision) return;
25
+ owner = next;
26
+ invalidateAntigravityQuota();
27
+ }
28
+
29
+ /** Epoch fences also retire outstanding probes on explicit cache/evidence invalidation. */
30
+ export function invalidateAntigravityQuota(): void { epoch++; observations.clear(); }
31
+
32
+ export function captureAntigravityReceipt(name: string, provider: OcxProviderConfig, id: string, generation: string): AntigravityQuotaReceipt | undefined {
33
+ if (!owner || owner.root !== getConfigDir() || owner.id !== id || owner.generation !== generation || !antigravityQuotaEligible(name, provider)) return undefined;
34
+ const token: AntigravityQuotaReceipt = Object.freeze({ kind: "antigravity" });
35
+ receipts.set(token, { ...owner, owner, name, policy: antigravityQuotaPolicy(name, provider), configGeneration: captureConfigGeneration(), epoch });
36
+ return token;
37
+ }
38
+
39
+ function current(receipt: Receipt): boolean {
40
+ return receipt.owner === owner && receipt.root === getConfigDir() && receipt.epoch === epoch && receipt.configGeneration === captureConfigGeneration();
41
+ }
42
+
43
+ /** Only accepted, live immutable receipts can retain omitted family rows; clocks never change. */
44
+ export function replaceAntigravityQuotas(rows: readonly AntigravityQuotaObservation[]): void {
45
+ const next = new Map<string, { receipt: Receipt; windows: readonly DecisionQuotaWindow[] }>();
46
+ for (const row of rows.slice(0, 256)) {
47
+ const receipt = receipts.get(row.receipt);
48
+ if (!receipt) continue;
49
+ if (!current(receipt) || receipt.name !== row.name || !antigravityQuotaEligible(row.name, row.provider)
50
+ || receipt.policy !== antigravityQuotaPolicy(row.name, row.provider)) { receipts.delete(row.receipt); continue; }
51
+ const previous = observations.get(receipt.name);
52
+ const fresh = row.windows.length > 64 ? [] : row.windows.filter(window => window.family === "gem" || window.family === "cla");
53
+ const retained = previous && current(previous.receipt) && previous.receipt.owner === receipt.owner && previous.receipt.policy === receipt.policy
54
+ ? previous.windows.filter(window => !fresh.some(value => value.family === window.family && value.window === window.window)) : [];
55
+ next.set(receipt.name, { receipt, windows: [...retained, ...fresh].map(window => ({ ...window })) });
56
+ }
57
+ observations = next;
58
+ }
59
+
60
+ export function readAntigravityQuota(name: string, provider: OcxProviderConfig): readonly DecisionQuotaWindow[] | undefined {
61
+ const row = observations.get(name);
62
+ if (!row || !current(row.receipt) || !antigravityQuotaEligible(name, provider) || row.receipt.policy !== antigravityQuotaPolicy(name, provider)) return undefined;
63
+ return row.windows.map(window => ({ ...window }));
64
+ }
@@ -35,6 +35,17 @@ export function providerDecisionWindows(quota: ProviderQuota): DecisionQuotaWind
35
35
  }
36
36
  return windows;
37
37
  }
38
+ /** Antigravity family buckets: Gem/Cla are 5h counters, "(Weekly)" their weekly pair; per-model rows and other groups are display-only. */
39
+ export function antigravityDecisionWindows(quota: ProviderQuota): DecisionQuotaWindow[] {
40
+ const windows: DecisionQuotaWindow[] = [];
41
+ for (const row of Array.isArray(quota.customWindows) ? quota.customWindows : []) {
42
+ const match = typeof row?.label === "string" && row.modelId === undefined ? /^(Gem|Cla)( \(Weekly\))?$/.exec(row.label) : null;
43
+ if (!match || !Number.isFinite(row.percent)) continue;
44
+ windows.push({ window: match[2] ? "weekly" : "5h", family: match[1] === "Gem" ? "gem" : "cla", percent: row.percent,
45
+ observedAt: quota.updatedAt, ...(row.resetAt !== undefined ? { resetAt: row.resetAt } : {}) });
46
+ }
47
+ return windows;
48
+ }
38
49
  /** Publish decision windows for one Anthropic pool account, bound to its credential generation; a null quota publishes no windows. */
39
50
  export function publishAnthropicDecisionQuota(id: string, generation: string, quota: ProviderQuota | null, partial = false): void {
40
51
  if (!decisionQuotaSinkActive()) return;
@@ -3,12 +3,23 @@ import { createHash } from "node:crypto";
3
3
  import { getConfigDir } from "../config/paths";
4
4
  import { captureConfigGeneration } from "../lib/state-store-sweeper";
5
5
  import type { OcxProviderConfig } from "../types";
6
+ import { invalidateAntigravityQuota, readAntigravityQuota } from "./quota-decision-antigravity";
7
+ import type { DecisionKeyObservation } from "../lib/decision-quota-sink";
6
8
 
7
9
  export interface DecisionQuotaWindow {
8
10
  window: "5h" | "weekly" | "monthly" | "fable" | "opus" | "sonnet";
9
11
  percent: number;
10
12
  observedAt: number;
11
13
  resetAt?: number;
14
+ /** Model family this window meters (Antigravity Gemini vs Claude/3P buckets); absent means every model of the provider. */
15
+ family?: DecisionQuotaFamily;
16
+ }
17
+ export type DecisionQuotaFamily = "gem" | "cla";
18
+ /** True when the provider row can carry sole-credential decision evidence under `name`. */
19
+ function keyEvidenceEligible(name: string, provider: OcxProviderConfig): boolean {
20
+ if (provider.disabled || (provider.apiKeyPool?.length ?? 0) > 1) return false;
21
+ const mode = provider.authMode ?? "key";
22
+ return mode === "key";
12
23
  }
13
24
  export interface DecisionQuotaAccount {
14
25
  id: string;
@@ -54,18 +65,24 @@ function keyPolicy(provider: OcxProviderConfig): string {
54
65
  ])).digest("hex");
55
66
  }
56
67
  /** Drop all key-based decision evidence and advance the epoch so earlier publications cannot be read. */
57
- export function invalidateDecisionKeyQuotas(): void { keyEpoch++; keys.clear(); }
68
+ export function invalidateDecisionKeyQuotas(): void { keyEpoch++; keys.clear(); invalidateAntigravityQuota(); }
69
+ /** Collector replacement does not retire live OAuth producer receipts or their original clocks. */
70
+ export function replaceDecisionKeyQuotas(rows: readonly DecisionKeyObservation[]): void {
71
+ keyEpoch++; keys.clear();
72
+ for (const row of rows) publishDecisionKeyQuota(row.name, row.provider, row.windows);
73
+ }
58
74
  /** Publish decision windows for a single-key provider; pooled, disabled or non-key providers are never published, and the table is bounded. */
59
75
  export function publishDecisionKeyQuota(name: string, provider: OcxProviderConfig, windows: readonly DecisionQuotaWindow[]): void {
60
76
  writesForTests++;
61
- if (name.length > 1024 || provider.disabled || (provider.authMode ?? "key") !== "key" || (provider.apiKeyPool?.length ?? 0) > 1) return;
77
+ if (name.length > 1024 || !keyEvidenceEligible(name, provider)) return;
62
78
  if (keys.size >= 256 && !keys.has(name)) keys.delete(keys.keys().next().value!);
63
79
  keys.set(name, { root: getConfigDir(), epoch: keyEpoch, configGeneration: captureConfigGeneration(), policy: keyPolicy(provider), windows: copyWindows(windows) });
64
80
  }
65
81
  /** Read key-based evidence only when the config root, epoch, generation and provider policy still match what was published. */
66
82
  export function readLoadedDecisionKeyQuota(name: string, provider: OcxProviderConfig): readonly DecisionQuotaWindow[] | undefined {
83
+ if (provider.authMode === "oauth") return readAntigravityQuota(name, provider);
67
84
  const row = keys.get(name);
68
- if (!row || provider.disabled || (provider.authMode ?? "key") !== "key" || (provider.apiKeyPool?.length ?? 0) > 1
85
+ if (!row || !keyEvidenceEligible(name, provider)
69
86
  || row.root !== getConfigDir() || row.epoch !== keyEpoch || row.configGeneration !== captureConfigGeneration()
70
87
  || row.policy !== keyPolicy(provider)) return undefined;
71
88
  return row.windows.map(row => ({ ...row }));
@@ -141,5 +158,5 @@ export function clearDecisionAccountQuotas(provider?: string, id?: string): void
141
158
  /** Copy only known window kinds into the bounded evidence table, so callers cannot retain a mutable reference. */
142
159
  function copyWindows(windows: readonly DecisionQuotaWindow[]): DecisionQuotaWindow[] {
143
160
  if (windows.length > MAX_WINDOWS) return [];
144
- return windows.filter(row => ["5h", "weekly", "monthly", "fable", "opus", "sonnet"].includes(row.window)).map(row => ({ window: row.window, percent: row.percent, observedAt: row.observedAt, ...(row.resetAt !== undefined ? { resetAt: row.resetAt } : {}) }));
161
+ return windows.filter(row => ["5h", "weekly", "monthly", "fable", "opus", "sonnet"].includes(row.window)).map(row => ({ window: row.window, percent: row.percent, observedAt: row.observedAt, ...(row.resetAt !== undefined ? { resetAt: row.resetAt } : {}), ...(row.family === "gem" || row.family === "cla" ? { family: row.family } : {}) }));
145
162
  }
@@ -53,6 +53,8 @@ export interface ProviderQuotaCreditsUsd {
53
53
  }
54
54
 
55
55
  export interface ProviderQuota {
56
+ /** Display-only subscription credits; not a routing or exhaustion window. */
57
+ workbuddyCredits?: import("./workbuddy-credit-balance").WorkBuddyCreditBalance;
56
58
  fiveHourPercent?: number;
57
59
  fiveHourResetAt?: number;
58
60
  weeklyPercent?: number;
@@ -1,5 +1,6 @@
1
1
  import { listCodexAuthAccountsSnapshot } from "../codex/auth-api";
2
2
  import { isAnthropicInstanceId, configuredAnthropicInstance } from "./anthropic-instance";
3
+ import { ANTIGRAVITY_OAUTH_STORE_KEY } from "./antigravity-quota-identity";
3
4
  import { fetchAnthropicAccountQuota } from "./quota/anthropic-account-quota";
4
5
  import { thrownQuotaFailure } from "./quota/failure-codes";
5
6
  import { resolveEnvValue } from "../config";
@@ -124,7 +125,7 @@ async function maybeFetchProviderQuota(
124
125
  }
125
126
  if (provider.authMode === "oauth" && explicitAccountReader(name)) return await fetchExplicitCurrentQuota(name, provider, config);
126
127
  if (provider.authMode === "oauth" && configuredAnthropicInstance(config, name)) return fetchAnthropicQuota(name, config);
127
- if (provider.authMode === "oauth" && name === "google-antigravity") return await fetchAntigravityQuota(name);
128
+ if (provider.authMode === "oauth" && name === ANTIGRAVITY_OAUTH_STORE_KEY) return await fetchAntigravityQuota(name, { ...provider });
128
129
  if (provider.authMode === "oauth" && name === "kiro") return fetchKiroQuota(name);
129
130
  // meta-muse: a device-logged-in account can be probed at the key endpoint; an
130
131
  // imported or pasted one cannot, and falls back to its last in-band observation.
@@ -368,6 +369,7 @@ async function readExplicitAccountQuota(provider: string, accountId: string, con
368
369
  case "kimi": result = await fetchKimiQuota(provider, config, accessToken); break;
369
370
  case "command-code": result = await fetchCommandCodeQuota(provider, config, accessToken); break;
370
371
  case "devin": result = await (await import("./quota/devin")).fetchDevinQuota(provider, accessToken, credential.apiBaseUrl, config.baseUrl); break;
372
+ case "workbuddy-ai": result = await (await import("./quota/workbuddy")).fetchWorkBuddyQuota(provider, credential); break;
371
373
  case "dsh-account": result = await (await import("./quota/dsh-account")).fetchDshAccountQuota(provider, accessToken, { accountId, credential }); break;
372
374
  default: return null;
373
375
  }
@@ -0,0 +1,76 @@
1
+ import type { ModelCapabilities, OcxProviderConfig, ReasoningCapabilities } from "../types";
2
+ import { modelInList } from "../types";
3
+ import { registryEntryForProviderDestination } from "./registry";
4
+ import { legacyModelValue, mapFill, nestedMapFill } from "./resolved-model-policy-merge";
5
+
6
+ export const REASONING_CAPABILITY_FIELDS = [
7
+ "supportsReasoning", "supportsThinkingToggle", "supportsReasoningEffort", "defaultThinkingEnabled",
8
+ ] as const;
9
+
10
+ /** Case-equal model declarations merge per axis; unrelated axes retain registry defaults. */
11
+ export function mergeReasoningModelCapabilities(
12
+ registry: Record<string, ModelCapabilities> | undefined,
13
+ explicit: Record<string, ModelCapabilities> | undefined,
14
+ ): Record<string, ModelCapabilities> | undefined {
15
+ if (!registry && !explicit) return undefined;
16
+ const merged: Record<string, ModelCapabilities> = {};
17
+ const keys = new Map<string, string>();
18
+ for (const rows of [registry, explicit]) {
19
+ for (const [id, row] of Object.entries(rows ?? {})) {
20
+ const key = keys.get(id.toLowerCase()) ?? id;
21
+ keys.set(id.toLowerCase(), key);
22
+ merged[key] = { ...merged[key], ...structuredClone(row) };
23
+ }
24
+ }
25
+ return merged;
26
+ }
27
+
28
+ /** Match a declared model case-insensitively, without inheriting suffix or family aliases. */
29
+ export function declaredModelCapabilities(rows: Readonly<Record<string, ModelCapabilities>> | undefined, modelId: string): ModelCapabilities | undefined {
30
+ return rows?.[modelId] ?? Object.entries(rows ?? {}).find(([id]) => id.toLowerCase() === modelId.toLowerCase())?.[1];
31
+ }
32
+
33
+ /** Captured-policy variant: never reads the live registry after admission. */
34
+ export function reasoningCapabilitiesFromConfig(provider: Readonly<OcxProviderConfig>, modelId: string): ReasoningCapabilities {
35
+ if (modelInList(provider.noReasoningModels, modelId)) {
36
+ return { supportsReasoning: false, supportsThinkingToggle: false, supportsReasoningEffort: false, defaultThinkingEnabled: false };
37
+ }
38
+ const declared = declaredModelCapabilities(provider.modelCapabilities, modelId);
39
+ const result: ReasoningCapabilities = {};
40
+ for (const field of REASONING_CAPABILITY_FIELDS) {
41
+ if (typeof declared?.[field] === "boolean") result[field] = declared[field];
42
+ }
43
+ const efforts = legacyModelValue(provider.modelReasoningEfforts, modelId) ?? provider.reasoningEfforts;
44
+ const effortMap = legacyModelValue(provider.modelReasoningEffortMap, modelId) ?? provider.reasoningEffortMap;
45
+ const effectiveEfforts = efforts?.filter(effort => effort !== "none").map(effort => effortMap?.[effort] ?? effort);
46
+ const strengths = ["minimal", "low", "medium", "high", "xhigh", "max", "ultra"];
47
+ if (result.supportsReasoningEffort === undefined && effectiveEfforts?.some(effort => strengths.includes(effort))) {
48
+ result.supportsReasoningEffort = true;
49
+ }
50
+ if (result.supportsReasoning === undefined && (result.supportsThinkingToggle === true
51
+ || result.supportsReasoningEffort === true || effectiveEfforts?.some(effort => strengths.includes(effort) || effort === "enabled" || effort === "adaptive")
52
+ || modelInList(provider.thinkingBudgetModels, modelId))) {
53
+ result.supportsReasoning = true;
54
+ }
55
+ if (result.supportsReasoning === false) {
56
+ result.supportsThinkingToggle = false;
57
+ result.supportsReasoningEffort = false;
58
+ result.defaultThinkingEnabled = false;
59
+ }
60
+ return result;
61
+ }
62
+
63
+ /** Resolve fixed destination registry facts beneath exact operator capabilities. Unknown stays absent. */
64
+ export function resolveReasoningCapabilities(provider: OcxProviderConfig, modelId: string): ReasoningCapabilities {
65
+ const entry = registryEntryForProviderDestination(provider);
66
+ return reasoningCapabilitiesFromConfig({
67
+ ...provider,
68
+ modelCapabilities: mergeReasoningModelCapabilities(entry?.modelCapabilities, provider.modelCapabilities),
69
+ modelReasoningEfforts: mapFill(entry?.modelReasoningEfforts, provider.modelReasoningEfforts)[0],
70
+ reasoningEfforts: provider.reasoningEfforts ?? entry?.reasoningEfforts,
71
+ reasoningEffortMap: mapFill(entry?.reasoningEffortMap, provider.reasoningEffortMap)[0],
72
+ modelReasoningEffortMap: nestedMapFill(entry?.modelReasoningEffortMap, provider.modelReasoningEffortMap)[0],
73
+ thinkingBudgetModels: [...(entry?.thinkingBudgetModels ?? []), ...(provider.thinkingBudgetModels ?? [])],
74
+ noReasoningModels: [...(entry?.noReasoningModels ?? []), ...(provider.noReasoningModels ?? [])],
75
+ }, modelId);
76
+ }
@@ -251,7 +251,8 @@ export const PROVIDER_REGISTRY_CORE: readonly ProviderRegistryEntry[] = [
251
251
  // (it is the current catalog, so its default ordering wins), then the ids
252
252
  // only the old devin entry carried. Degraded-mode seed only either way —
253
253
  // `liveModels` discovers the account's real roster.
254
- models: ["swe-2", "swe-1-7", "gpt-5-6-sol", "gpt-6-astra", "gpt-6-1-sol", "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"],
254
+ // 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"],
255
256
  liveModels: true,
256
257
  defaultModel: "swe-2",
257
258
  modelContextWindows: DEVIN_MODEL_CONTEXT_WINDOWS,
@@ -516,6 +517,15 @@ export const PROVIDER_REGISTRY_CORE: readonly ProviderRegistryEntry[] = [
516
517
  // The proprietary generate wire has no verified per-request serialization flag.
517
518
  parallelToolCalls: false,
518
519
  },
520
+ {
521
+ id: "workbuddy-ai", label: "WorkBuddy AI", adapter: "workbuddy-ai",
522
+ baseUrl: "https://www.workbuddy.ai/v2", authKind: "oauth", oauthId: "workbuddy-ai",
523
+ featured: false, dashboardPreset: true, liveModels: true,
524
+ defaultModel: "default-model", models: ["default-model"],
525
+ modelDiscovery: { path: "/v3/config", format: "workbuddy" },
526
+ dashboardUrl: "https://www.workbuddy.ai",
527
+ note: "Use your WorkBuddy AI international subscription. Sign in in your browser; models follow your account catalog.",
528
+ },
519
529
  {
520
530
  id: "dsh-account",
521
531
  label: "DeepSeek Account (DSH)",
@@ -748,6 +758,8 @@ export const PROVIDER_REGISTRY_CORE: readonly ProviderRegistryEntry[] = [
748
758
  ...OPENAI_DAYBREAK_REASONING_EFFORTS,
749
759
  "gpt-6-astra": ["low", "medium", "high", "xhigh", "max"],
750
760
  ...Object.fromEntries(OPENAI_GPT6_MODELS.map(id => [id, ["low", "medium", "high", "xhigh", "max"]])),
761
+ // OpenAI API model page (2026-10-27): Terra also accepts none; Sol does not.
762
+ "gpt-6.1-terra": ["none", "low", "medium", "high", "xhigh", "max"],
751
763
  },
752
764
  virtualModels: OPENAI_API_GPT56_VIRTUAL_MODELS,
753
765
  },
@@ -1089,6 +1101,7 @@ export const PROVIDER_REGISTRY_CORE: readonly ProviderRegistryEntry[] = [
1089
1101
  "openai/gpt-6-luna": true,
1090
1102
  // Listed 2026-09-29 as an OpenAI-backed route like GPT-6 Sol.
1091
1103
  "openai/gpt-6.1-sol": true,
1104
+ "openai/gpt-6.1-terra": true,
1092
1105
  },
1093
1106
  // Deliberately no OpenRouter route pin: it bills the endpoint actually used and reports the
1094
1107
  // actual service_tier. B0 confirmation therefore owns downgrade safety. Forcing `only` plus
@@ -1247,17 +1260,18 @@ export const PROVIDER_REGISTRY_CORE: readonly ProviderRegistryEntry[] = [
1247
1260
  // the list only as compatibility aliases so existing saved configs and requests
1248
1261
  // keep validating and routing (they previously mapped to v4-flash; devlog
1249
1262
  // _fin/260710_provider_hardening/002_research_cn.md). The current offerings are
1250
- // V4.1-Flash — defaultModel and the model-specific wiring below use its live id.
1263
+ // V4.1-Flash and V4 Pro; Flash remains the default.
1251
1264
  // Keep the legacy vision-preview alias; see DEEPSEEK_VISION_PREVIEW_MODEL.
1252
1265
  models: ["deepseek-chat", "deepseek-reasoner", ...DEEPSEEK_NATIVE_THINKING_MODELS, DEEPSEEK_VISION_PREVIEW_MODEL],
1253
- // V4.1-Flash is the current first-party offering; `deepseek-v4-flash` now routes there
1266
+ // V4.1-Flash is the first-party default; `deepseek-v4-flash` now routes there
1254
1267
  // as a compatibility alias, so a new install should ask for the live id by name.
1255
1268
  defaultModel: "deepseek-flash",
1256
1269
  // Official DeepSeek Codex setup (codex-deepseek-setup.sh) advertises 1,048,576
1257
1270
  // for both V4 models; the older 1,000,000 figure was a rounded approximation.
1258
- modelContextWindows: { "deepseek-flash": 1_048_576, "deepseek-v4-flash": 1_048_576, [DEEPSEEK_VISION_PREVIEW_MODEL]: 1_048_576 },
1271
+ modelContextWindows: { "deepseek-flash": 1_048_576, "deepseek-v4-flash": 1_048_576, "deepseek-v4-pro": 1_048_576, [DEEPSEEK_VISION_PREVIEW_MODEL]: 1_048_576 },
1259
1272
  modelInputModalities: {
1260
1273
  "deepseek-flash": ["text", "image"],
1274
+ "deepseek-v4-pro": ["text"],
1261
1275
  [DEEPSEEK_VISION_PREVIEW_MODEL]: ["text", "image"],
1262
1276
  },
1263
1277
  // DeepSeek documents both V4 models as native Responses API models adapted for Codex
@@ -1272,6 +1286,7 @@ export const PROVIDER_REGISTRY_CORE: readonly ProviderRegistryEntry[] = [
1272
1286
  // translating them into Responses would add a hop onto our newest upstream path
1273
1287
  // for no gain.
1274
1288
  "deepseek-v4-flash": { wire: "openai-responses", inbound: ["responses"] },
1289
+ "deepseek-v4-pro": { wire: "openai-responses", inbound: ["responses"] },
1275
1290
  // Same Responses contract as the V4 ids it succeeds; without this row the new
1276
1291
  // default would fall back to the provider-wide Chat wire.
1277
1292
  "deepseek-flash": { wire: "openai-responses", inbound: ["responses"] },
@@ -1289,7 +1304,7 @@ export const PROVIDER_REGISTRY_CORE: readonly ProviderRegistryEntry[] = [
1289
1304
  // devlog/_fin/260807_deepseek_responses_streaming/000_plan.md.
1290
1305
  // Current official streams normally carry a real terminal; retain a narrow grace
1291
1306
  // repair for the historical shape that closes after a complete graph without one.
1292
- modelResponsesTerminalRepair: { "deepseek-flash": { graceMs: 5_000 }, "deepseek-v4-flash": { graceMs: 5_000 } },
1307
+ modelResponsesTerminalRepair: { "deepseek-flash": { graceMs: 5_000 }, "deepseek-v4-flash": { graceMs: 5_000 }, "deepseek-v4-pro": { graceMs: 5_000 } },
1293
1308
  // DeepSeek's Responses route emits bare UUID item ids, which leave Codex
1294
1309
  // clients stuck on an uncommitted turn (#938). Client-facing only — raw
1295
1310
  // continuation snapshots keep the upstream ids.
@@ -1328,16 +1343,12 @@ export const PROVIDER_REGISTRY_CORE: readonly ProviderRegistryEntry[] = [
1328
1343
  modelReasoningEfforts: Object.fromEntries(DEEPSEEK_NATIVE_THINKING_MODELS.map(id => [id, deepseekThinkingEffortsFor(id)])),
1329
1344
  modelReasoningEffortMap: Object.fromEntries(DEEPSEEK_NATIVE_THINKING_MODELS.map(id => [id, deepseekReasoningMapFor(id)])),
1330
1345
  modelSupportsReasoningSummaries: Object.fromEntries(DEEPSEEK_NATIVE_THINKING_MODELS.map(id => [id, true])),
1331
- // deepseek-v4-pro is absent from the live sets on purpose (retired upstream, requests
1332
- // route to V4.1-Flash — see model-seeds.ts), but it stays SELECTABLE in configs that
1333
- // already carry it, and what serves it is a thinking-mode model. A saved config with
1334
- // the alias selected would otherwise serialize a bare continuation the upstream 400s
1335
- // on (#5421). The preserve list governs replay, not advertisement.
1336
- preserveReasoningContentModels: [...DEEPSEEK_NATIVE_THINKING_MODELS, "deepseek-v4-pro"],
1346
+ // Native thinking models retain assistant reasoning on tool-call continuations (#5421).
1347
+ preserveReasoningContentModels: DEEPSEEK_NATIVE_THINKING_MODELS,
1337
1348
  // #4436: first-party deepseek-flash accepts native images on Chat and Responses.
1338
1349
  // Keep unprobed compatibility aliases on the #88 sidecar path. This must be fixed
1339
1350
  // here: router enrichment unions this list with saved config, so config cannot remove it.
1340
- noVisionModels: ["deepseek-chat", "deepseek-reasoner", "deepseek-v4-flash"],
1351
+ noVisionModels: ["deepseek-chat", "deepseek-reasoner", "deepseek-v4-flash", "deepseek-v4-pro"],
1341
1352
  },
1342
1353
  // llama-3.3-70b was deprecated by Cerebras on 2026-02-16. Evidence: devlog/_plan/260710_provider_hardening/003_research_aggregators.md.
1343
1354
  { id: "cerebras", label: "Cerebras", baseUrl: "https://api.cerebras.ai/v1", adapter: "openai-chat", authKind: "key", dashboardUrl: "https://cloud.cerebras.ai/platform/apikeys", defaultModel: "gpt-oss-120b" },