@prometheus-ai/ai 0.5.4 → 0.5.8

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 (377) hide show
  1. package/dist/types/auth-broker/remote-store.d.ts +2 -1
  2. package/dist/types/auth-broker/wire-schemas.d.ts +4 -1
  3. package/dist/types/auth-gateway/server.d.ts +19 -0
  4. package/dist/types/auth-gateway/types.d.ts +9 -3
  5. package/dist/types/auth-retry.d.ts +119 -0
  6. package/dist/types/auth-storage.d.ts +217 -8
  7. package/dist/types/errors.d.ts +24 -0
  8. package/dist/types/index.d.ts +5 -9
  9. package/dist/types/provider-details.d.ts +1 -1
  10. package/dist/types/providers/amazon-bedrock.d.ts +12 -6
  11. package/dist/types/providers/anthropic-client.d.ts +10 -3
  12. package/dist/types/providers/anthropic-messages-server-schema.d.ts +2 -2
  13. package/dist/types/providers/anthropic-messages-server.d.ts +3 -3
  14. package/dist/types/providers/anthropic-wire.d.ts +3 -3
  15. package/dist/types/providers/anthropic.d.ts +41 -34
  16. package/dist/types/providers/aws-credentials.d.ts +8 -0
  17. package/dist/types/providers/azure-openai-responses.d.ts +1 -0
  18. package/dist/types/providers/google-gemini-cli.d.ts +22 -1
  19. package/dist/types/providers/google-shared.d.ts +22 -0
  20. package/dist/types/providers/google-types.d.ts +13 -1
  21. package/dist/types/providers/mock.d.ts +8 -3
  22. package/dist/types/providers/ollama.d.ts +6 -0
  23. package/dist/types/providers/openai-chat-server-schema.d.ts +6 -3
  24. package/dist/types/providers/openai-chat-server.d.ts +3 -3
  25. package/dist/types/providers/openai-chat-wire.d.ts +644 -0
  26. package/dist/types/providers/openai-codex/request-transformer.d.ts +8 -0
  27. package/dist/types/providers/openai-codex/response-handler.d.ts +9 -0
  28. package/dist/types/providers/openai-codex-responses.d.ts +31 -2
  29. package/dist/types/providers/openai-completions-compat.d.ts +2 -25
  30. package/dist/types/providers/openai-completions.d.ts +2 -10
  31. package/dist/types/providers/openai-responses-server-schema.d.ts +4 -4
  32. package/dist/types/providers/openai-responses-server.d.ts +2 -2
  33. package/dist/types/providers/openai-responses-shared.d.ts +49 -9
  34. package/dist/types/providers/openai-responses-wire.d.ts +6065 -0
  35. package/dist/types/providers/openai-responses.d.ts +13 -4
  36. package/dist/types/providers/prometheus-native-client.d.ts +9 -0
  37. package/dist/types/providers/prometheus-native-server.d.ts +4 -3
  38. package/dist/types/providers/transform-messages.d.ts +1 -2
  39. package/dist/types/rate-limit-utils.d.ts +3 -2
  40. package/dist/types/registry/aimlapi.d.ts +4 -0
  41. package/dist/types/registry/alibaba-coding-plan.d.ts +7 -0
  42. package/dist/types/registry/amazon-bedrock.d.ts +5 -0
  43. package/dist/types/registry/anthropic.d.ts +10 -0
  44. package/dist/types/{utils/oauth → registry}/api-key-login.d.ts +8 -2
  45. package/dist/types/{utils/oauth → registry}/api-key-validation.d.ts +15 -0
  46. package/dist/types/registry/cerebras.d.ts +7 -0
  47. package/dist/types/registry/cloudflare-ai-gateway.d.ts +13 -0
  48. package/dist/types/registry/cursor.d.ts +7 -0
  49. package/dist/types/registry/deepseek.d.ts +8 -0
  50. package/dist/types/registry/derived.d.ts +5 -0
  51. package/dist/types/registry/firepass.d.ts +16 -0
  52. package/dist/types/registry/fireworks.d.ts +7 -0
  53. package/dist/types/registry/github-copilot.d.ts +7 -0
  54. package/dist/types/registry/gitlab-duo.d.ts +9 -0
  55. package/dist/types/registry/google-antigravity.d.ts +9 -0
  56. package/dist/types/registry/google-gemini-cli.d.ts +9 -0
  57. package/dist/types/registry/google-vertex.d.ts +5 -0
  58. package/dist/types/registry/google.d.ts +4 -0
  59. package/dist/types/registry/groq.d.ts +4 -0
  60. package/dist/types/registry/huggingface.d.ts +7 -0
  61. package/dist/types/registry/index.d.ts +4 -0
  62. package/dist/types/registry/kagi.d.ts +14 -0
  63. package/dist/types/registry/kilo.d.ts +7 -0
  64. package/dist/types/registry/kimi-code.d.ts +7 -0
  65. package/dist/types/registry/litellm.d.ts +13 -0
  66. package/dist/types/registry/lm-studio.d.ts +8 -0
  67. package/dist/types/registry/minimax-code-cn.d.ts +6 -0
  68. package/dist/types/registry/minimax-code.d.ts +6 -0
  69. package/dist/types/registry/minimax.d.ts +4 -0
  70. package/dist/types/registry/mistral.d.ts +4 -0
  71. package/dist/types/registry/moonshot.d.ts +7 -0
  72. package/dist/types/registry/nanogpt.d.ts +7 -0
  73. package/dist/types/registry/nvidia.d.ts +7 -0
  74. package/dist/types/registry/oauth/__tests__/xai-oauth.test.d.ts +1 -0
  75. package/dist/types/{utils → registry}/oauth/anthropic.d.ts +2 -1
  76. package/dist/types/{utils → registry}/oauth/github-copilot.d.ts +15 -23
  77. package/dist/types/{utils → registry}/oauth/index.d.ts +1 -0
  78. package/dist/types/{utils → registry}/oauth/minimax-code.d.ts +5 -5
  79. package/dist/types/{utils → registry}/oauth/types.d.ts +6 -1
  80. package/dist/types/{utils → registry}/oauth/xai-oauth.d.ts +2 -1
  81. package/dist/types/registry/ollama-cloud.d.ts +7 -0
  82. package/dist/types/registry/ollama.d.ts +12 -0
  83. package/dist/types/registry/openai-codex-device.d.ts +8 -0
  84. package/dist/types/registry/openai-codex.d.ts +9 -0
  85. package/dist/types/registry/openai.d.ts +4 -0
  86. package/dist/types/registry/opencode-go.d.ts +6 -0
  87. package/dist/types/registry/opencode-zen.d.ts +6 -0
  88. package/dist/types/registry/openrouter.d.ts +13 -0
  89. package/dist/types/registry/parallel.d.ts +14 -0
  90. package/dist/types/registry/perplexity.d.ts +7 -0
  91. package/dist/types/registry/qianfan.d.ts +7 -0
  92. package/dist/types/registry/qwen-portal.d.ts +7 -0
  93. package/dist/types/registry/registry.d.ts +272 -0
  94. package/dist/types/registry/synthetic.d.ts +6 -0
  95. package/dist/types/registry/tavily.d.ts +14 -0
  96. package/dist/types/registry/together.d.ts +6 -0
  97. package/dist/types/registry/types.d.ts +51 -0
  98. package/dist/types/registry/venice.d.ts +13 -0
  99. package/dist/types/registry/vercel-ai-gateway.d.ts +7 -0
  100. package/dist/types/registry/vllm.d.ts +7 -0
  101. package/dist/types/registry/wafer-pass.d.ts +6 -0
  102. package/dist/types/registry/wafer-serverless.d.ts +6 -0
  103. package/dist/types/registry/xai-oauth.d.ts +7 -0
  104. package/dist/types/registry/xai.d.ts +4 -0
  105. package/dist/types/registry/xiaomi-token-plan-ams.d.ts +6 -0
  106. package/dist/types/registry/xiaomi-token-plan-cn.d.ts +6 -0
  107. package/dist/types/registry/xiaomi-token-plan-sgp.d.ts +6 -0
  108. package/dist/types/registry/xiaomi.d.ts +6 -0
  109. package/dist/types/registry/zai.d.ts +7 -0
  110. package/dist/types/registry/zenmux.d.ts +7 -0
  111. package/dist/types/registry/zhipu-coding-plan.d.ts +7 -0
  112. package/dist/types/stream.d.ts +9 -1
  113. package/dist/types/types.d.ts +56 -295
  114. package/dist/types/usage/google-antigravity.d.ts +15 -1
  115. package/dist/types/usage/openai-codex-reset.d.ts +79 -0
  116. package/dist/types/usage/openai-codex.d.ts +1 -0
  117. package/dist/types/usage.d.ts +77 -4
  118. package/dist/types/utils/abort.d.ts +6 -0
  119. package/dist/types/utils/event-stream.d.ts +2 -0
  120. package/dist/types/utils/http-inspector.d.ts +0 -1
  121. package/dist/types/utils/idle-iterator.d.ts +35 -0
  122. package/dist/types/utils/openai-http.d.ts +58 -0
  123. package/dist/types/utils/request-debug.d.ts +3 -0
  124. package/dist/types/utils/retry-after.d.ts +1 -0
  125. package/dist/types/utils/schema/fields.d.ts +5 -0
  126. package/dist/types/utils/schema/json-schema-validator.d.ts +8 -0
  127. package/dist/types/utils/schema/stamps.d.ts +7 -15
  128. package/dist/types/utils/sse-debug.d.ts +0 -5
  129. package/dist/types/utils/stream-markup-healing.d.ts +2 -0
  130. package/dist/types/utils.d.ts +1 -5
  131. package/package.json +17 -29
  132. package/src/auth-broker/remote-store.ts +10 -1
  133. package/src/auth-broker/snapshot-cache.ts +1 -1
  134. package/src/auth-broker/wire-schemas.ts +1 -1
  135. package/src/auth-gateway/http.ts +1 -1
  136. package/src/auth-gateway/server.ts +95 -30
  137. package/src/auth-gateway/types.ts +10 -2
  138. package/src/auth-retry.ts +238 -0
  139. package/src/auth-storage.ts +935 -430
  140. package/src/errors.ts +32 -0
  141. package/src/index.ts +9 -14
  142. package/src/provider-details.ts +1 -1
  143. package/src/providers/__tests__/google-auth.test.ts +144 -0
  144. package/src/providers/amazon-bedrock.ts +70 -40
  145. package/src/providers/anthropic-client.ts +15 -13
  146. package/src/providers/anthropic-messages-server-schema.ts +17 -7
  147. package/src/providers/anthropic-messages-server.ts +88 -20
  148. package/src/providers/anthropic-wire.ts +4 -3
  149. package/src/providers/anthropic.ts +1234 -621
  150. package/src/providers/aws-credentials.ts +47 -5
  151. package/src/providers/aws-eventstream.ts +5 -0
  152. package/src/providers/azure-openai-responses.ts +117 -67
  153. package/src/providers/cursor.ts +30 -30
  154. package/src/providers/github-copilot-headers.ts +1 -1
  155. package/src/providers/gitlab-duo.ts +36 -29
  156. package/src/providers/google-auth.ts +71 -8
  157. package/src/providers/google-gemini-cli.ts +118 -22
  158. package/src/providers/google-shared.ts +163 -43
  159. package/src/providers/google-types.ts +10 -1
  160. package/src/providers/kimi.ts +1 -1
  161. package/src/providers/mock.ts +11 -3
  162. package/src/providers/ollama.ts +64 -7
  163. package/src/providers/openai-anthropic-shim.ts +17 -8
  164. package/src/providers/openai-chat-server-schema.ts +9 -3
  165. package/src/providers/openai-chat-server.ts +82 -16
  166. package/src/providers/openai-chat-wire.ts +847 -0
  167. package/src/providers/openai-codex/request-transformer.ts +129 -34
  168. package/src/providers/openai-codex/response-handler.ts +22 -1
  169. package/src/providers/openai-codex-responses.ts +699 -247
  170. package/src/providers/openai-completions-compat.ts +8 -308
  171. package/src/providers/openai-completions.ts +416 -267
  172. package/src/providers/openai-responses-server-schema.ts +15 -9
  173. package/src/providers/openai-responses-server.ts +162 -114
  174. package/src/providers/openai-responses-shared.ts +320 -82
  175. package/src/providers/openai-responses-wire.ts +6391 -0
  176. package/src/providers/openai-responses.ts +382 -176
  177. package/src/providers/prometheus-native-client.ts +27 -11
  178. package/src/providers/prometheus-native-server.ts +44 -17
  179. package/src/providers/transform-messages.ts +311 -120
  180. package/src/providers/vision-guard.ts +5 -3
  181. package/src/rate-limit-utils.ts +13 -3
  182. package/src/registry/aimlapi.ts +6 -0
  183. package/src/{utils/oauth → registry}/alibaba-coding-plan.ts +8 -18
  184. package/src/registry/amazon-bedrock.ts +22 -0
  185. package/src/registry/anthropic.ts +26 -0
  186. package/src/{utils/oauth → registry}/api-key-login.ts +25 -3
  187. package/src/{utils/oauth → registry}/api-key-validation.ts +62 -2
  188. package/src/{utils/oauth → registry}/cerebras.ts +8 -1
  189. package/src/{utils/oauth → registry}/cloudflare-ai-gateway.ts +8 -12
  190. package/src/registry/cursor.ts +20 -0
  191. package/src/{utils/oauth → registry}/deepseek.ts +9 -17
  192. package/src/registry/derived.ts +9 -0
  193. package/src/{utils/oauth → registry}/firepass.ts +10 -2
  194. package/src/{utils/oauth → registry}/fireworks.ts +8 -1
  195. package/src/registry/github-copilot.ts +22 -0
  196. package/src/registry/gitlab-duo.ts +19 -0
  197. package/src/registry/google-antigravity.ts +21 -0
  198. package/src/registry/google-gemini-cli.ts +21 -0
  199. package/src/registry/google-vertex.ts +38 -0
  200. package/src/registry/google.ts +6 -0
  201. package/src/registry/groq.ts +6 -0
  202. package/src/{utils/oauth → registry}/huggingface.ts +8 -19
  203. package/src/registry/index.ts +4 -0
  204. package/src/{utils/oauth → registry}/kagi.ts +9 -11
  205. package/src/{utils/oauth → registry}/kilo.ts +11 -6
  206. package/src/registry/kimi-code.ts +17 -0
  207. package/src/{utils/oauth → registry}/litellm.ts +8 -12
  208. package/src/{utils/oauth → registry}/lm-studio.ts +9 -17
  209. package/src/registry/minimax-code-cn.ts +12 -0
  210. package/src/registry/minimax-code.ts +12 -0
  211. package/src/registry/minimax.ts +6 -0
  212. package/src/registry/mistral.ts +6 -0
  213. package/src/{utils/oauth → registry}/moonshot.ts +8 -9
  214. package/src/{utils/oauth → registry}/nanogpt.ts +8 -1
  215. package/src/{utils/oauth → registry}/nvidia.ts +8 -18
  216. package/src/{utils → registry}/oauth/__tests__/xai-oauth.test.ts +4 -7
  217. package/src/{utils → registry}/oauth/anthropic.ts +38 -17
  218. package/src/{utils → registry}/oauth/github-copilot.ts +79 -115
  219. package/src/registry/oauth/gitlab-duo.ts +198 -0
  220. package/src/{utils → registry}/oauth/google-antigravity.ts +1 -4
  221. package/src/{utils → registry}/oauth/google-gemini-cli.ts +1 -4
  222. package/src/registry/oauth/index.ts +164 -0
  223. package/src/{utils → registry}/oauth/minimax-code.ts +16 -14
  224. package/src/{utils → registry}/oauth/types.ts +7 -51
  225. package/src/{utils → registry}/oauth/wafer.ts +1 -1
  226. package/src/{utils → registry}/oauth/xai-oauth.ts +16 -8
  227. package/src/{utils → registry}/oauth/xiaomi.ts +9 -4
  228. package/src/{utils/oauth → registry}/ollama-cloud.ts +8 -1
  229. package/src/{utils/oauth → registry}/ollama.ts +8 -13
  230. package/src/registry/openai-codex-device.ts +18 -0
  231. package/src/registry/openai-codex.ts +19 -0
  232. package/src/registry/openai.ts +6 -0
  233. package/src/registry/opencode-go.ts +12 -0
  234. package/src/registry/opencode-zen.ts +12 -0
  235. package/src/{utils/oauth → registry}/openrouter.ts +10 -2
  236. package/src/{utils/oauth → registry}/parallel.ts +9 -11
  237. package/src/registry/perplexity.ts +13 -0
  238. package/src/{utils/oauth → registry}/qianfan.ts +8 -17
  239. package/src/{utils/oauth → registry}/qwen-portal.ts +8 -19
  240. package/src/registry/registry.ts +149 -0
  241. package/src/{utils/oauth → registry}/synthetic.ts +7 -1
  242. package/src/{utils/oauth → registry}/tavily.ts +10 -12
  243. package/src/{utils/oauth → registry}/together.ts +7 -1
  244. package/src/registry/types.ts +56 -0
  245. package/src/{utils/oauth → registry}/venice.ts +8 -12
  246. package/src/{utils/oauth → registry}/vercel-ai-gateway.ts +8 -18
  247. package/src/{utils/oauth → registry}/vllm.ts +9 -16
  248. package/src/registry/wafer-pass.ts +12 -0
  249. package/src/registry/wafer-serverless.ts +12 -0
  250. package/src/registry/xai-oauth.ts +17 -0
  251. package/src/registry/xai.ts +6 -0
  252. package/src/registry/xiaomi-token-plan-ams.ts +12 -0
  253. package/src/registry/xiaomi-token-plan-cn.ts +12 -0
  254. package/src/registry/xiaomi-token-plan-sgp.ts +12 -0
  255. package/src/registry/xiaomi.ts +12 -0
  256. package/src/{utils/oauth → registry}/zai.ts +10 -22
  257. package/src/{utils/oauth → registry}/zenmux.ts +8 -1
  258. package/src/{utils/oauth/zhipu.ts → registry/zhipu-coding-plan.ts} +9 -21
  259. package/src/stream.ts +229 -199
  260. package/src/types.ts +63 -384
  261. package/src/usage/claude.ts +4 -2
  262. package/src/usage/github-copilot.ts +4 -2
  263. package/src/usage/google-antigravity.ts +196 -28
  264. package/src/usage/kimi.ts +1 -1
  265. package/src/usage/minimax-code.ts +5 -6
  266. package/src/usage/openai-codex-reset.ts +174 -0
  267. package/src/usage/openai-codex.ts +19 -2
  268. package/src/usage/zai.ts +2 -1
  269. package/src/usage.ts +93 -4
  270. package/src/utils/abort.ts +14 -0
  271. package/src/utils/event-stream.ts +17 -0
  272. package/src/utils/http-inspector.ts +4 -12
  273. package/src/utils/idle-iterator.ts +250 -79
  274. package/src/utils/openai-http.ts +157 -0
  275. package/src/utils/request-debug.ts +67 -19
  276. package/src/utils/retry-after.ts +1 -1
  277. package/src/utils/retry.ts +23 -2
  278. package/src/utils/schema/CONSTRAINTS.md +4 -2
  279. package/src/utils/schema/fields.ts +16 -0
  280. package/src/utils/schema/json-schema-validator.ts +19 -1
  281. package/src/utils/schema/normalize.ts +80 -8
  282. package/src/utils/schema/stamps.ts +22 -10
  283. package/src/utils/schema/wire.ts +2 -2
  284. package/src/utils/sse-debug.ts +0 -271
  285. package/src/utils/stream-markup-healing.ts +50 -8
  286. package/src/utils/validation.ts +49 -13
  287. package/src/utils.ts +2 -26
  288. package/dist/types/model-cache.d.ts +0 -17
  289. package/dist/types/model-manager.d.ts +0 -64
  290. package/dist/types/model-thinking.d.ts +0 -100
  291. package/dist/types/models.d.ts +0 -12
  292. package/dist/types/provider-models/bundled-references.d.ts +0 -4
  293. package/dist/types/provider-models/descriptors.d.ts +0 -50
  294. package/dist/types/provider-models/google.d.ts +0 -24
  295. package/dist/types/provider-models/index.d.ts +0 -5
  296. package/dist/types/provider-models/ollama.d.ts +0 -7
  297. package/dist/types/provider-models/openai-compat.d.ts +0 -323
  298. package/dist/types/provider-models/special.d.ts +0 -16
  299. package/dist/types/utils/discovery/antigravity.d.ts +0 -61
  300. package/dist/types/utils/discovery/codex.d.ts +0 -38
  301. package/dist/types/utils/discovery/cursor.d.ts +0 -23
  302. package/dist/types/utils/discovery/gemini.d.ts +0 -25
  303. package/dist/types/utils/discovery/index.d.ts +0 -4
  304. package/dist/types/utils/discovery/openai-compatible.d.ts +0 -72
  305. package/dist/types/utils/oauth/alibaba-coding-plan.d.ts +0 -18
  306. package/dist/types/utils/oauth/cerebras.d.ts +0 -1
  307. package/dist/types/utils/oauth/cloudflare-ai-gateway.d.ts +0 -18
  308. package/dist/types/utils/oauth/deepseek.d.ts +0 -10
  309. package/dist/types/utils/oauth/firepass.d.ts +0 -1
  310. package/dist/types/utils/oauth/fireworks.d.ts +0 -1
  311. package/dist/types/utils/oauth/huggingface.d.ts +0 -19
  312. package/dist/types/utils/oauth/kagi.d.ts +0 -17
  313. package/dist/types/utils/oauth/kilo.d.ts +0 -5
  314. package/dist/types/utils/oauth/litellm.d.ts +0 -18
  315. package/dist/types/utils/oauth/lm-studio.d.ts +0 -17
  316. package/dist/types/utils/oauth/moonshot.d.ts +0 -1
  317. package/dist/types/utils/oauth/nanogpt.d.ts +0 -1
  318. package/dist/types/utils/oauth/nvidia.d.ts +0 -18
  319. package/dist/types/utils/oauth/ollama-cloud.d.ts +0 -2
  320. package/dist/types/utils/oauth/ollama.d.ts +0 -18
  321. package/dist/types/utils/oauth/openrouter.d.ts +0 -1
  322. package/dist/types/utils/oauth/parallel.d.ts +0 -17
  323. package/dist/types/utils/oauth/qianfan.d.ts +0 -17
  324. package/dist/types/utils/oauth/qwen-portal.d.ts +0 -19
  325. package/dist/types/utils/oauth/synthetic.d.ts +0 -1
  326. package/dist/types/utils/oauth/tavily.d.ts +0 -17
  327. package/dist/types/utils/oauth/together.d.ts +0 -1
  328. package/dist/types/utils/oauth/venice.d.ts +0 -18
  329. package/dist/types/utils/oauth/vercel-ai-gateway.d.ts +0 -18
  330. package/dist/types/utils/oauth/vllm.d.ts +0 -16
  331. package/dist/types/utils/oauth/zai.d.ts +0 -18
  332. package/dist/types/utils/oauth/zenmux.d.ts +0 -1
  333. package/dist/types/utils/oauth/zhipu.d.ts +0 -18
  334. package/src/model-cache.ts +0 -129
  335. package/src/model-manager.ts +0 -469
  336. package/src/model-thinking.ts +0 -756
  337. package/src/models.json +0 -60287
  338. package/src/models.json.d.ts +0 -9
  339. package/src/models.ts +0 -56
  340. package/src/provider-models/bundled-references.ts +0 -38
  341. package/src/provider-models/descriptors.ts +0 -364
  342. package/src/provider-models/google.ts +0 -88
  343. package/src/provider-models/index.ts +0 -5
  344. package/src/provider-models/ollama.ts +0 -153
  345. package/src/provider-models/openai-compat.ts +0 -2904
  346. package/src/provider-models/special.ts +0 -67
  347. package/src/utils/discovery/antigravity.ts +0 -261
  348. package/src/utils/discovery/codex.ts +0 -371
  349. package/src/utils/discovery/cursor.ts +0 -306
  350. package/src/utils/discovery/gemini.ts +0 -248
  351. package/src/utils/discovery/index.ts +0 -4
  352. package/src/utils/discovery/openai-compatible.ts +0 -224
  353. package/src/utils/oauth/gitlab-duo.ts +0 -123
  354. package/src/utils/oauth/index.ts +0 -502
  355. /package/dist/types/{utils/oauth/__tests__/xai-oauth.test.d.ts → providers/__tests__/google-auth.test.d.ts} +0 -0
  356. /package/dist/types/{utils → registry}/oauth/callback-server.d.ts +0 -0
  357. /package/dist/types/{utils → registry}/oauth/cursor.d.ts +0 -0
  358. /package/dist/types/{utils → registry}/oauth/gitlab-duo.d.ts +0 -0
  359. /package/dist/types/{utils → registry}/oauth/google-antigravity.d.ts +0 -0
  360. /package/dist/types/{utils → registry}/oauth/google-gemini-cli.d.ts +0 -0
  361. /package/dist/types/{utils → registry}/oauth/google-oauth-shared.d.ts +0 -0
  362. /package/dist/types/{utils → registry}/oauth/kimi.d.ts +0 -0
  363. /package/dist/types/{utils → registry}/oauth/openai-codex.d.ts +0 -0
  364. /package/dist/types/{utils → registry}/oauth/opencode.d.ts +0 -0
  365. /package/dist/types/{utils → registry}/oauth/perplexity.d.ts +0 -0
  366. /package/dist/types/{utils → registry}/oauth/pkce.d.ts +0 -0
  367. /package/dist/types/{utils → registry}/oauth/wafer.d.ts +0 -0
  368. /package/dist/types/{utils → registry}/oauth/xiaomi.d.ts +0 -0
  369. /package/src/{utils → registry}/oauth/callback-server.ts +0 -0
  370. /package/src/{utils → registry}/oauth/cursor.ts +0 -0
  371. /package/src/{utils → registry}/oauth/google-oauth-shared.ts +0 -0
  372. /package/src/{utils → registry}/oauth/kimi.ts +0 -0
  373. /package/src/{utils → registry}/oauth/oauth.html +0 -0
  374. /package/src/{utils → registry}/oauth/openai-codex.ts +0 -0
  375. /package/src/{utils → registry}/oauth/opencode.ts +0 -0
  376. /package/src/{utils → registry}/oauth/perplexity.ts +0 -0
  377. /package/src/{utils → registry}/oauth/pkce.ts +0 -0
package/src/types.ts CHANGED
@@ -1,8 +1,6 @@
1
- import type { ZodType, z } from "zod/v4";
2
- import type { BedrockOptions } from "./providers/amazon-bedrock";
3
- import type { AnthropicOptions } from "./providers/anthropic";
4
- import type { AzureOpenAIResponsesOptions } from "./providers/azure-openai-responses";
5
- import type { CursorOptions } from "./providers/cursor";
1
+ export * from "@prometheus-ai/catalog/effort";
2
+ export * from "@prometheus-ai/catalog/types";
3
+
6
4
  import type {
7
5
  DeleteArgs,
8
6
  DeleteResult,
@@ -19,7 +17,16 @@ import type {
19
17
  ShellResult,
20
18
  WriteArgs,
21
19
  WriteResult,
22
- } from "./providers/cursor/gen/agent_pb";
20
+ } from "@prometheus-ai/catalog/discovery/cursor-gen/agent_pb";
21
+ import type { Effort } from "@prometheus-ai/catalog/effort";
22
+ import type { Api, FetchImpl, KnownApi, Model, Provider, ThinkingBudgets, Usage } from "@prometheus-ai/catalog/types";
23
+ import type { ZodType, z } from "zod/v4";
24
+ import type { ApiKey } from "./auth-retry";
25
+ import type { BedrockOptions } from "./providers/amazon-bedrock";
26
+ import type { AnthropicOptions } from "./providers/anthropic";
27
+ import type { StopDetails } from "./providers/anthropic-wire";
28
+ import type { AzureOpenAIResponsesOptions } from "./providers/azure-openai-responses";
29
+ import type { CursorOptions } from "./providers/cursor";
23
30
  import type { GoogleOptions } from "./providers/google";
24
31
  import type { GoogleGeminiCliOptions } from "./providers/google-gemini-cli";
25
32
  import type { GoogleVertexOptions } from "./providers/google-vertex";
@@ -29,21 +36,22 @@ import type { OpenAICompletionsOptions } from "./providers/openai-completions";
29
36
  import type { OpenAIResponsesOptions } from "./providers/openai-responses";
30
37
  import type { AssistantMessageEventStream } from "./utils/event-stream";
31
38
 
39
+ export type { StopDetails } from "./providers/anthropic-wire";
32
40
  export type { AssistantMessageEventStream } from "./utils/event-stream";
33
41
 
34
- export type KnownApi =
35
- | "openai-completions"
36
- | "openai-responses"
37
- | "openai-codex-responses"
38
- | "azure-openai-responses"
39
- | "anthropic-messages"
40
- | "bedrock-converse-stream"
41
- | "google-generative-ai"
42
- | "google-gemini-cli"
43
- | "google-vertex"
44
- | "ollama-chat"
45
- | "cursor-agent";
46
- export type Api = KnownApi | (string & {});
42
+ /**
43
+ * Ceiling on the output-token count prometheus requests from any OpenAI-family endpoint
44
+ * (openai-responses, azure/xai responses, and openai-completions). Mirrors
45
+ * Anthropic's {@link CLAUDE_CODE_MAX_OUTPUT_TOKENS}.
46
+ *
47
+ * Catalog `maxTokens` frequently reflects a model's context window rather than a
48
+ * given upstream's real per-request output cap. OpenRouter, for instance,
49
+ * advertises 131072 output tokens for `z-ai/glm-4.7`, but the Cerebras upstream
50
+ * only allows ~131072 tokens total — so requesting the full ceiling overflows
51
+ * with a 400. Requested output is clamped to this value (and to `model.maxTokens`).
52
+ */
53
+ export const OPENAI_MAX_OUTPUT_TOKENS = 64000;
54
+
47
55
  export interface ApiOptionsMap {
48
56
  "anthropic-messages": AnthropicOptions;
49
57
  "bedrock-converse-stream": BedrockOptions;
@@ -69,93 +77,6 @@ export type OptionsForApi<TApi extends Api> =
69
77
  | StreamOptions
70
78
  | (TApi extends keyof ApiOptionsMap ? ApiOptionsMap[TApi] : never);
71
79
 
72
- /** Canonical thinking transport used by a model. */
73
- export type ThinkingControlMode =
74
- | "effort"
75
- | "budget"
76
- | "google-level"
77
- | "anthropic-adaptive"
78
- | "anthropic-budget-effort";
79
-
80
- /** Per-model thinking capabilities used to clamp and map user-facing effort levels. */
81
- export interface ThinkingConfig {
82
- /** Least intensive supported user-facing effort level. */
83
- minLevel: Effort;
84
- /** Most intensive supported user-facing effort level. */
85
- maxLevel: Effort;
86
- /**
87
- * Optional explicit list of supported levels. When present, takes precedence over
88
- * the `minLevel`..`maxLevel` range — used to encode discrete sets with gaps
89
- * (e.g. Gemini 3 Pro supports `low` and `high` but not `medium`).
90
- */
91
- levels?: readonly Effort[];
92
- /** Optional default effort applied when this model is selected. Falls back to global default if absent. */
93
- defaultLevel?: Effort;
94
- /** Provider-specific transport used to encode the selected effort. */
95
- mode: ThinkingControlMode;
96
- }
97
-
98
- export type KnownProvider =
99
- | "alibaba-coding-plan"
100
- | "amazon-bedrock"
101
- | "anthropic"
102
- | "google"
103
- | "google-gemini-cli"
104
- | "google-antigravity"
105
- | "google-vertex"
106
- | "openai"
107
- | "openai-codex"
108
- | "kimi-code"
109
- | "minimax-code"
110
- | "minimax-code-cn"
111
- | "github-copilot"
112
- | "fireworks"
113
- | "firepass"
114
- | "gitlab-duo"
115
- | "cursor"
116
- | "deepseek"
117
- | "xai"
118
- | "xai-oauth"
119
- | "groq"
120
- | "cerebras"
121
- | "openrouter"
122
- | "kilo"
123
- | "vercel-ai-gateway"
124
- | "zai"
125
- | "zhipu-coding-plan"
126
- | "mistral"
127
- | "minimax"
128
- | "opencode-go"
129
- | "opencode-zen"
130
- | "synthetic"
131
- | "cloudflare-ai-gateway"
132
- | "huggingface"
133
- | "litellm"
134
- | "moonshot"
135
- | "nvidia"
136
- | "nanogpt"
137
- | "ollama"
138
- | "ollama-cloud"
139
- | "qianfan"
140
- | "qwen-portal"
141
- | "together"
142
- | "venice"
143
- | "vllm"
144
- | "xiaomi"
145
- | "xiaomi-token-plan-sgp"
146
- | "xiaomi-token-plan-ams"
147
- | "xiaomi-token-plan-cn"
148
- | "wafer-pass"
149
- | "wafer-serverless"
150
- | "zenmux"
151
- | "lm-studio";
152
- export type Provider = KnownProvider | string;
153
-
154
- import type { Effort } from "./model-thinking";
155
-
156
- /** Token budgets for each thinking level (token-based providers only) */
157
- export type ThinkingBudgets = { [key in Effort]?: number };
158
-
159
80
  export interface TokenTaskBudget {
160
81
  type: "tokens";
161
82
  total: number;
@@ -267,15 +188,6 @@ export interface RawSseEvent {
267
188
  raw: string[];
268
189
  }
269
190
 
270
- /**
271
- * `fetch`-compatible function. Accepts any callable matching the standard
272
- * fetch signature; `preconnect` is optional because non-Bun runtimes (browsers,
273
- * test mocks) won't expose it.
274
- */
275
- export type FetchImpl = ((input: string | URL | Request, init?: RequestInit) => Promise<Response>) & {
276
- preconnect?: typeof globalThis.fetch.preconnect;
277
- };
278
-
279
191
  export interface StreamOptions {
280
192
  temperature?: number;
281
193
  topP?: number;
@@ -298,12 +210,6 @@ export interface StreamOptions {
298
210
  maxTokens?: number;
299
211
  signal?: AbortSignal;
300
212
  apiKey?: string;
301
- /**
302
- * Called when a provider returns 401 before any replay-unsafe assistant
303
- * event has been emitted. Returning a different key retries the provider
304
- * request once.
305
- */
306
- onAuthError?: (provider: string, apiKey: string, error: unknown) => Promise<string | undefined>;
307
213
  cacheRetention?: CacheRetention;
308
214
  /**
309
215
  * Additional headers to include in provider requests.
@@ -415,7 +321,21 @@ export interface StreamOptions {
415
321
  }
416
322
 
417
323
  // Unified options with reasoning passed to streamSimple() and completeSimple()
418
- export interface SimpleStreamOptions extends StreamOptions {
324
+ export interface SimpleStreamOptions extends Omit<StreamOptions, "apiKey"> {
325
+ /**
326
+ * API key for the request: either a static bearer string, or an
327
+ * {@link ApiKeyResolver} that mints/rotates the key across the central
328
+ * a/b/c auth-retry policy. `streamSimple`/`completeSimple` resolve a
329
+ * resolver to a string before per-provider dispatch, so providers only
330
+ * ever see the resolved {@link StreamOptions.apiKey} string.
331
+ */
332
+ apiKey?: ApiKey;
333
+ /**
334
+ * Legacy static-key retry hook. New callers should pass an {@link ApiKeyResolver}
335
+ * as `apiKey`; `streamSimple` adapts this hook into that resolver shape for
336
+ * older Prometheus runtime paths.
337
+ */
338
+ onAuthError?: (provider: string, oldKey: string, error: unknown) => Promise<string | undefined> | string | undefined;
419
339
  reasoning?: Effort;
420
340
  /**
421
341
  * Force-disable reasoning for the request even when the model supports it.
@@ -497,6 +417,12 @@ export interface ImageContent {
497
417
  type: "image";
498
418
  data: string; // base64 encoded image data
499
419
  mimeType: string; // e.g., "image/jpeg", "image/png"
420
+ /**
421
+ * OpenAI-only resolution hint. `"original"` preserves native resolution
422
+ * (required for snapcompact frames, whose glyphs do not survive the
423
+ * default `auto` downscale). Providers without a detail knob ignore it.
424
+ */
425
+ detail?: "auto" | "low" | "high" | "original";
500
426
  }
501
427
 
502
428
  export interface ToolCall {
@@ -516,53 +442,6 @@ export interface ToolCall {
516
442
  customWireName?: string;
517
443
  }
518
444
 
519
- export interface Usage {
520
- /** Non-cached input tokens (matches the bucket the provider bills as new input). */
521
- input: number;
522
- /** Total output tokens for the turn, including thinking, assistant text, and tool-call argument tokens. */
523
- output: number;
524
- /** Tokens read from the prompt cache. */
525
- cacheRead: number;
526
- /** Tokens written to the prompt cache (cache creation). */
527
- cacheWrite: number;
528
- /** Sum of input + output + cacheRead + cacheWrite. */
529
- totalTokens: number;
530
- /** Copilot premium-request counter, when applicable. */
531
- premiumRequests?: number;
532
- /**
533
- * Reasoning/thinking tokens included in `output`, when the provider reports them
534
- * (OpenAI `output_tokens_details.reasoning_tokens`, Google `thoughtsTokenCount`).
535
- * Always a subset of `output` — non-reasoning output is `output - reasoningTokens`.
536
- *
537
- * Providers that don't expose this leave it undefined rather than guessing;
538
- * `undefined` means unknown, NOT zero.
539
- */
540
- reasoningTokens?: number;
541
- /**
542
- * Cache-write TTL breakdown (Anthropic only). When set, the components sum to
543
- * `cacheWrite`. Absent providers do not populate this.
544
- */
545
- cttl?: {
546
- ephemeral5m?: number;
547
- ephemeral1h?: number;
548
- };
549
- /**
550
- * Server-side tool invocations made during this turn (Anthropic web_search /
551
- * web_fetch, OpenAI built-in tools when reported). Counts requests, not tokens.
552
- */
553
- server?: {
554
- webSearch?: number;
555
- webFetch?: number;
556
- };
557
- cost: {
558
- input: number;
559
- output: number;
560
- cacheRead: number;
561
- cacheWrite: number;
562
- total: number;
563
- };
564
- }
565
-
566
445
  export type StopReason = "stop" | "length" | "toolUse" | "error" | "aborted";
567
446
 
568
447
  export interface OpenAIResponsesHistoryPayload {
@@ -605,8 +484,17 @@ export interface AssistantMessage {
605
484
  provider: Provider;
606
485
  model: string;
607
486
  responseId?: string; // Provider-specific response/message identifier when the upstream API exposes one
487
+ /**
488
+ * Name of the upstream provider an aggregator routed this request to, as
489
+ * reported in the response (e.g. OpenRouter's top-level `provider` field:
490
+ * `"OpenAI"`, `"Anthropic"`, `"Together"`). Distinct from `provider`, which
491
+ * is the configured gateway we called (`"openrouter"`). Undefined for direct
492
+ * providers that expose no such field.
493
+ */
494
+ upstreamProvider?: string;
608
495
  usage: Usage;
609
496
  stopReason: StopReason;
497
+ stopDetails?: StopDetails | null;
610
498
  errorMessage?: string;
611
499
  /** HTTP status surfaced by the provider when the request failed. Populated by every provider's catch block alongside `errorMessage` so consumers (auth retry, telemetry, UI) can branch without regex-scraping the message. */
612
500
  errorStatus?: number;
@@ -636,6 +524,12 @@ export interface ToolResultMessage<TDetails = any> {
636
524
  attribution?: MessageAttribution;
637
525
  /** Timestamp when output was pruned (ms since epoch). Undefined if unpruned. */
638
526
  prunedAt?: number;
527
+ /**
528
+ * Tool-declared: this result carried no information worth retaining once
529
+ * consumed (zero matches, elapsed wait). Compaction passes may elide it.
530
+ * Never set together with isError.
531
+ */
532
+ useless?: boolean;
639
533
  timestamp: number; // Unix timestamp in milliseconds
640
534
  }
641
535
 
@@ -748,218 +642,3 @@ export type AssistantMessageEvent =
748
642
  reason: Extract<StopReason, "aborted" | "error">;
749
643
  error: AssistantMessage;
750
644
  };
751
-
752
- /**
753
- * Compatibility settings for openai-completions API.
754
- * Use this to override URL-based auto-detection for custom providers.
755
- */
756
- export interface OpenAICompat {
757
- /** Whether the provider supports the `store` field. Default: auto-detected from URL. */
758
- supportsStore?: boolean;
759
- /** Whether the provider supports the `developer` role (vs `system`). Default: auto-detected from URL. */
760
- supportsDeveloperRole?: boolean;
761
- /**
762
- * Whether the provider's chat-completions endpoint accepts multiple
763
- * leading `system`/`developer` messages. When false, ordered system
764
- * prompts are coalesced into a single message joined by `\n\n` so
765
- * strict chat templates (e.g. Qwen-served via vLLM, MiniMax) accept
766
- * the request. Default: detected per provider/baseUrl. Canonical
767
- * OpenAI/Azure/OpenRouter/Cerebras/Together/Fireworks/Groq/DeepSeek/
768
- * Mistral/xAI/Z.ai/GitHub Copilot/Zenmux are treated as `true`;
769
- * unknown or strict-template hosts default to `false`. Setting this
770
- * to `true` preserves separate blocks, which is preferred for
771
- * KV-cache reuse when the trailing prompt changes between calls.
772
- */
773
- supportsMultipleSystemMessages?: boolean;
774
- /** Whether the provider supports `reasoning_effort`. Default: auto-detected from URL. */
775
- supportsReasoningEffort?: boolean;
776
- /** Optional mapping from Prometheus AI reasoning levels to provider/model-specific `reasoning_effort` values. */
777
- reasoningEffortMap?: Partial<Record<Effort, string>>;
778
- /** Whether the provider supports `stream_options: { include_usage: true }` for token usage in streaming responses. Default: true. */
779
- supportsUsageInStreaming?: boolean;
780
- /** Which field to use for max tokens. Default: auto-detected from URL. */
781
- maxTokensField?: "max_completion_tokens" | "max_tokens";
782
- /** Whether tool results require the `name` field. Default: auto-detected from URL. */
783
- requiresToolResultName?: boolean;
784
- /** Whether a user message after tool results requires an assistant message in between. Default: auto-detected from URL. */
785
- requiresAssistantAfterToolResult?: boolean;
786
- /** Whether thinking blocks must be converted to text blocks with <thinking> delimiters. Default: auto-detected from URL. */
787
- requiresThinkingAsText?: boolean;
788
- /** Whether tool call IDs must be normalized to Mistral format (exactly 9 alphanumeric chars). Default: auto-detected from URL. */
789
- requiresMistralToolIds?: boolean;
790
- /** Format for reasoning/thinking parameter. "openai" uses reasoning_effort, "openrouter" uses reasoning: { effort }, "zai" uses thinking: { type: "enabled" | "disabled" } (also used by Moonshot Kimi), "qwen" uses top-level enable_thinking, and "qwen-chat-template" uses chat_template_kwargs.enable_thinking. Default: "openai". */
791
- thinkingFormat?: "openai" | "openrouter" | "zai" | "qwen" | "qwen-chat-template";
792
- /** Optional `thinking.keep` value for Z.ai/Moonshot-style thinking params. Set false to suppress auto-detected keep. Default: auto-detected. */
793
- thinkingKeep?: "all" | false;
794
- /** Which reasoning content field to emit on assistant messages. Default: auto-detected. */
795
- reasoningContentField?: "reasoning_content" | "reasoning" | "reasoning_text";
796
- /** Whether assistant tool-call messages must include reasoning content. Default: false. */
797
- requiresReasoningContentForToolCalls?: boolean;
798
- /** Whether the provider accepts a synthetic placeholder (e.g. ".") for missing reasoning_content on tool-call turns. Default: true. Set to false for providers like DeepSeek that validate the exact reasoning_content value. */
799
- allowsSyntheticReasoningContentForToolCalls?: boolean;
800
- /** Whether assistant tool-call messages must include non-empty content. Default: false. */
801
- requiresAssistantContentForToolCalls?: boolean;
802
- /** Whether the provider supports the `tool_choice` parameter. Default: true. */
803
- supportsToolChoice?: boolean;
804
- /**
805
- * Drop reasoning fields (`reasoning_effort`, OpenRouter `reasoning`) for
806
- * the request when `tool_choice` forces a tool call. Mirrors the Anthropic
807
- * `disableThinkingIfToolChoiceForced` rule for backends like Kimi that
808
- * 400 with `tool_choice 'specified' is incompatible with thinking
809
- * enabled` whenever both are present. Default: auto-detected (Kimi).
810
- */
811
- disableReasoningOnForcedToolChoice?: boolean;
812
- /**
813
- * Drop reasoning fields (`reasoning_effort`, OpenRouter `reasoning`) for
814
- * any request that sends `tool_choice`. Use for providers/models that accept
815
- * tools and `tool_choice`, but reject `tool_choice` while thinking is enabled.
816
- * Default: auto-detected (DeepSeek reasoning models).
817
- */
818
- disableReasoningOnToolChoice?: boolean;
819
- /** OpenRouter-specific routing preferences. Only used when baseUrl points to OpenRouter. */
820
- openRouterRouting?: OpenRouterRouting;
821
- /** Vercel AI Gateway routing preferences. Only used when baseUrl points to Vercel AI Gateway. */
822
- vercelGatewayRouting?: VercelGatewayRouting;
823
- /** Extra fields to include in request body (e.g. gateway routing hints for OpenClaw-style proxies). */
824
- extraBody?: Record<string, unknown>;
825
- /** Whether chat-completions payloads should include provider-specific prompt-cache markers. */
826
- cacheControlFormat?: "anthropic" | undefined;
827
- /** Whether the provider supports the `strict` field in tool definitions. Default: auto-detected per provider/baseUrl (conservative for unknown providers). */
828
- supportsStrictMode?: boolean;
829
- /** Whether tool schemas must be sent either all strict or all non-strict. Undefined keeps the existing per-tool mixed behavior. */
830
- toolStrictMode?: "all_strict" | "none";
831
- }
832
-
833
- /**
834
- * Compatibility settings for anthropic-messages API.
835
- * Use this to disable features that strict-by-default Anthropic accepts but
836
- * that proxy gateways (Vertex AI, AWS Bedrock-style fronts, etc.) reject.
837
- */
838
- export interface AnthropicCompat {
839
- /**
840
- * Drop the top-level `strict: true` field on tool definitions. Vertex AI's
841
- * Anthropic-compatible endpoint rejects unknown tool fields with
842
- * `tools.<n>.custom.strict: Extra inputs are not permitted`.
843
- */
844
- disableStrictTools?: boolean;
845
- /**
846
- * Map adaptive thinking (`thinking: { type: "adaptive" }`) to
847
- * `{ type: "enabled", budget_tokens }`. Vertex AI rejects the `adaptive`
848
- * tag with `Input tag 'adaptive' ... does not match any of the expected
849
- * tags: 'disabled', 'enabled'`.
850
- */
851
- disableAdaptiveThinking?: boolean;
852
- /** Whether tools may include Anthropic's per-tool eager_input_streaming flag. Default: true. */
853
- supportsEagerToolInputStreaming?: boolean;
854
- /** Whether long prompt-cache retention (`ttl: "1h"`) is supported. Default: true for canonical Anthropic API. */
855
- supportsLongCacheRetention?: boolean;
856
- /**
857
- * Whether mid-conversation `role: "system"` messages are accepted in the
858
- * `messages` array (Claude Opus 4.8+ on the first-party Claude API and
859
- * Claude Platform on AWS). When unset, auto-detected from the model id and
860
- * base URL. Not available on Bedrock, Vertex AI, or Microsoft Foundry.
861
- */
862
- supportsMidConversationSystem?: boolean;
863
- }
864
-
865
- /**
866
- * OpenRouter provider routing preferences.
867
- * Controls which upstream providers OpenRouter routes requests to.
868
- * @see https://openrouter.ai/docs/provider-routing
869
- */
870
- export interface OpenRouterRouting {
871
- /** List of provider slugs to exclusively use for this request (e.g., ["amazon-bedrock", "anthropic"]). */
872
- only?: string[];
873
- /** List of provider slugs to try in order (e.g., ["anthropic", "openai"]). */
874
- order?: string[];
875
- }
876
-
877
- /**
878
- * Vercel AI Gateway routing preferences.
879
- * Controls which upstream providers the gateway routes requests to.
880
- * @see https://vercel.com/docs/ai-gateway/models-and-providers/provider-options
881
- */
882
- export interface VercelGatewayRouting {
883
- /** List of provider slugs to exclusively use for this request (e.g., ["bedrock", "anthropic"]). */
884
- only?: string[];
885
- /** List of provider slugs to try in order (e.g., ["anthropic", "openai"]). */
886
- order?: string[];
887
- }
888
-
889
- // Model interface for the unified model system
890
- export interface Model<TApi extends Api = any> {
891
- id: string;
892
- name: string;
893
- api: TApi;
894
- provider: Provider;
895
- baseUrl: string;
896
- reasoning: boolean;
897
- input: ("text" | "image")[];
898
- cost: {
899
- input: number; // $/million tokens
900
- output: number; // $/million tokens
901
- cacheRead: number; // $/million tokens
902
- cacheWrite: number; // $/million tokens
903
- };
904
- /** Premium Copilot requests charged per user-initiated request (defaults to 1). */
905
- premiumMultiplier?: number;
906
- contextWindow: number;
907
- maxTokens: number;
908
- /**
909
- * When `true`, providers MUST omit `max_output_tokens` (Responses) /
910
- * `max_tokens` / `max_completion_tokens` (Completions) from the outbound
911
- * request and let the upstream API decide the per-response cap. `maxTokens`
912
- * is still used locally for budgeting (compaction, context promotion); only
913
- * the wire field is suppressed.
914
- *
915
- * Use this for proxies (notably Ollama) that forward to a backend whose true
916
- * output limit Prometheus cannot discover — sending the wrong value triggers 400s
917
- * from the upstream provider.
918
- */
919
- omitMaxOutputTokens?: boolean;
920
- headers?: Record<string, string>;
921
- /**
922
- * Streaming transport override. When `"prometheus-native"`, `streamSimple` routes
923
- * the request to the model's `baseUrl` via the auth-gateway's
924
- * `POST /v1/prometheus/stream` endpoint instead of dispatching the per-API
925
- * provider client. The `baseUrl` must point at an `prometheus auth-gateway`
926
- * (or compatible) host; `headers.Authorization` (or `apiKey` resolved by
927
- * the registry) carries the gateway bearer.
928
- *
929
- * Used by containerized prometheus installs (e.g. roboprometheus slots) to route every
930
- * LLM call through a sidecar gateway that holds the real provider
931
- * credentials. The model's other metadata (pricing, context window,
932
- * thinking config, …) still resolves locally; only the streaming
933
- * dispatch is redirected.
934
- */
935
- transport?: "prometheus-native";
936
- /** Hint that websocket transport should be preferred when supported by the provider implementation. */
937
- preferWebsockets?: boolean;
938
- /** Preferred model to switch to when context promotion is triggered (model id or provider/id). */
939
- contextPromotionTarget?: string;
940
- /** Provider-assigned priority value (lower = higher priority). */
941
- priority?: number;
942
- /** Canonical thinking capability metadata for this model. */
943
- thinking?: ThinkingConfig;
944
- /** Compatibility overrides per API. If not set, auto-detected from baseUrl. */
945
- compat?: TApi extends "openai-completions" | "openai-responses"
946
- ? OpenAICompat
947
- : TApi extends "anthropic-messages"
948
- ? AnthropicCompat
949
- : never;
950
- /**
951
- * Which shape to use when exposing the Codex `apply_patch` tool to this model.
952
- * Generated catalog policy sets `"freeform"` for first-party GPT-5 Responses
953
- * models that support OpenAI custom tools with a Lark grammar. The freeform
954
- * variant sends a raw patch string with no JSON envelope.
955
- * - `"function"` or undefined: JSON function-tool with `{input: string}` (spec §1.2).
956
- */
957
- applyPatchToolType?: "freeform" | "function";
958
- /**
959
- * Force OAuth-style request shaping for providers whose API key prefix doesn't
960
- * match an OAuth token (e.g. routing Anthropic traffic through a proxy that
961
- * expects Claude Code framing). When true, the streaming layer sets
962
- * `options.isOAuth = true` for the underlying provider call.
963
- */
964
- isOAuth?: boolean;
965
- }
@@ -1,4 +1,6 @@
1
1
  import { scheduler } from "node:timers/promises";
2
+ import { toNumber } from "@prometheus-ai/catalog/utils";
3
+ import { claudeCodeVersion } from "../providers/anthropic";
2
4
  import type {
3
5
  CredentialRankingStrategy,
4
6
  UsageAmount,
@@ -10,7 +12,7 @@ import type {
10
12
  UsageStatus,
11
13
  UsageWindow,
12
14
  } from "../usage";
13
- import { isRecord, toNumber } from "../utils";
15
+ import { isRecord } from "../utils";
14
16
 
15
17
  const DEFAULT_ENDPOINT = "https://api.anthropic.com/api/oauth";
16
18
  const FIVE_HOURS_MS = 5 * 60 * 60 * 1000;
@@ -24,7 +26,7 @@ const CLAUDE_HEADERS = {
24
26
  "anthropic-beta":
25
27
  "claude-code-20250219,oauth-2025-04-20,interleaved-thinking-2025-05-14,redact-thinking-2026-02-12,context-management-2025-06-27,prompt-caching-scope-2026-01-05,mid-conversation-system-2026-04-07,advanced-tool-use-2025-11-20,effort-2025-11-24,extended-cache-ttl-2025-04-11",
26
28
  "content-type": "application/json",
27
- "user-agent": "claude-cli/2.1.160 (external, cli)",
29
+ "user-agent": `claude-cli/${claudeCodeVersion} (external, cli)`,
28
30
  connection: "keep-alive",
29
31
  } as const;
30
32
 
@@ -3,6 +3,9 @@
3
3
  *
4
4
  * Normalizes Copilot quota usage into the shared UsageReport schema.
5
5
  */
6
+
7
+ import { toBoolean, toNumber } from "@prometheus-ai/catalog/utils";
8
+ import { OPENCODE_HEADERS } from "@prometheus-ai/catalog/wire/github-copilot";
6
9
  import type {
7
10
  UsageAmount,
8
11
  UsageFetchContext,
@@ -13,8 +16,7 @@ import type {
13
16
  UsageStatus,
14
17
  UsageWindow,
15
18
  } from "../usage";
16
- import { isRecord, toBoolean, toNumber } from "../utils";
17
- import { OPENCODE_HEADERS } from "../utils/oauth/github-copilot";
19
+ import { isRecord } from "../utils";
18
20
 
19
21
  type CopilotQuotaDetail = {
20
22
  entitlement: number;