@humain/humain-code 0.4.14 → 0.4.17

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 (315) hide show
  1. package/CHANGELOG.md +93 -0
  2. package/README.md +1 -1
  3. package/dist/bundle/agent-monitor.js +1 -1
  4. package/dist/bundle/chunks/anthropic-messages-TSNY5MWH.js +67 -0
  5. package/dist/bundle/chunks/azure-openai-responses-Z4DCXO2G.js +15 -0
  6. package/dist/bundle/chunks/bedrock-converse-stream.js +59 -42
  7. package/dist/bundle/chunks/{chunk-HDA2IGKA.js → chunk-4NFYTS4C.js} +8 -8
  8. package/dist/bundle/chunks/{chunk-MF2NEHP4.js → chunk-4XU7TDAL.js} +939 -560
  9. package/dist/bundle/chunks/{chunk-LUL775V7.js → chunk-5K5RFXXO.js} +4 -4
  10. package/dist/bundle/chunks/chunk-65U7MPF4.js +1790 -0
  11. package/dist/bundle/chunks/{chunk-AIXI6RIE.js → chunk-7PRU6YW3.js} +114 -82
  12. package/dist/bundle/chunks/{chunk-KA7K6ECX.js → chunk-AOL6QG6L.js} +2254 -2416
  13. package/dist/bundle/chunks/chunk-AWCJWXGD.js +212 -0
  14. package/dist/bundle/chunks/{chunk-NNKA2PAP.js → chunk-FHVNUUBF.js} +1 -1
  15. package/dist/bundle/chunks/chunk-FZUJXM6D.js +816 -0
  16. package/dist/bundle/chunks/chunk-IJYVMOB4.js +6 -0
  17. package/dist/bundle/chunks/chunk-LG2PJ6JN.js +131 -0
  18. package/dist/bundle/chunks/chunk-NCQ6WAQK.js +125 -0
  19. package/dist/bundle/chunks/{chunk-Z74ZYQPX.js → chunk-OKALNPTJ.js} +80 -210
  20. package/dist/bundle/chunks/{chunk-OX2IBCCA.js → chunk-PTP2ZHFQ.js} +88 -82
  21. package/dist/bundle/chunks/chunk-PY7SOXCA.js +10 -0
  22. package/dist/bundle/chunks/chunk-Q7VXYXY3.js +7 -0
  23. package/dist/bundle/chunks/{chunk-COF5P635.js → chunk-QEF72EIZ.js} +13 -13
  24. package/dist/bundle/chunks/{chunk-EYIYBQAR.js → chunk-RXOCQRBG.js} +1 -1
  25. package/dist/bundle/chunks/{chunk-BVHXWQLD.js → chunk-SCBU5WOP.js} +1 -1
  26. package/dist/bundle/chunks/{chunk-UDVC7A5S.js → chunk-TIFFHHW6.js} +16 -14
  27. package/dist/bundle/chunks/{chunk-L3J4P5JR.js → chunk-UGJAAWNC.js} +1 -1
  28. package/dist/bundle/chunks/chunk-V76YPIMT.js +48 -0
  29. package/dist/bundle/chunks/{chunk-Y3RFGBG2.js → chunk-X3O5MCKJ.js} +1 -1
  30. package/dist/bundle/chunks/{chunk-KK3KUUMM.js → chunk-X6OTEVGA.js} +71 -66
  31. package/dist/bundle/chunks/chunk-Y26OS23T.js +80 -0
  32. package/dist/bundle/chunks/chunk-YDBNMIA3.js +34 -0
  33. package/dist/bundle/chunks/{chunk-UHLW4KJ7.js → chunk-ZRGFX6T6.js} +92 -89
  34. package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-JGN7NZCV.js → cloudflare-workers-ai-system-one-MUJQ6LT2.js} +1 -1
  35. package/dist/bundle/chunks/{compat-OQMUE3QD.js → compat-ARQPWKBQ.js} +8 -8
  36. package/dist/bundle/chunks/{dist-65YQEF26.js → dist-D7M52E3X.js} +1733 -1053
  37. package/dist/bundle/chunks/dist-LKDZAEUQ.js +7 -0
  38. package/dist/bundle/chunks/{dist-JXEXN6S2.js → dist-XVXV2CL4.js} +1 -1
  39. package/dist/bundle/chunks/dist-cjs-AXBW3N4F.js +182 -0
  40. package/dist/bundle/chunks/{easter-egg-3d-ZJ2JUFOA.js → easter-egg-3d-4SUPLBUF.js} +1 -1
  41. package/dist/bundle/chunks/{execute-LRTXH4YJ.js → execute-NTO3U76E.js} +10 -9
  42. package/dist/bundle/chunks/{extract-OZW5JHG6.js → extract-BKBHK4AK.js} +14 -13
  43. package/dist/bundle/chunks/github-copilot.js +34 -47
  44. package/dist/bundle/chunks/{google-generative-ai-YXXFSTX7.js → google-generative-ai-SJ4JO2MY.js} +2 -2
  45. package/dist/bundle/chunks/{google-vertex-3IVWLYJ5.js → google-vertex-KNLNNDET.js} +2 -2
  46. package/dist/bundle/chunks/host-63SNKK5Y.js +2 -0
  47. package/dist/bundle/chunks/jiti-static-loader-7OZNBOCI.js +2 -0
  48. package/dist/bundle/chunks/{mistral-conversations-Y7GWO3QB.js → mistral-conversations-G3GN6CMT.js} +20 -20
  49. package/dist/bundle/chunks/{node-SPBTZUUS.js → node-DZCAT4Q6.js} +1 -1
  50. package/dist/bundle/chunks/{openai-codex-responses-NSXWHIDT.js → openai-codex-responses-FJFDAWHI.js} +17 -17
  51. package/dist/bundle/chunks/openai-completions-IC7WRLTI.js +82 -0
  52. package/dist/bundle/chunks/{openai-decisions-QWEISDVO.js → openai-decisions-HESOHYZB.js} +1 -1
  53. package/dist/bundle/chunks/openai-responses-XXCYDFSM.js +24 -0
  54. package/dist/bundle/chunks/{openrouter-images-BMVMAROU.js → openrouter-images-DT2HMZNO.js} +1 -1
  55. package/dist/bundle/chunks/pdfjs-EK6K7CXX.js +3593 -0
  56. package/dist/bundle/chunks/{pi-messages-XNEG23NU.js → pi-messages-SAOV3JNW.js} +1 -1
  57. package/dist/bundle/chunks/{typesafe-system-one-62YHYXZV.js → typesafe-system-one-HCMGHK6A.js} +1 -1
  58. package/dist/bundle/chunks/{undici-7EW63V4X.js → undici-N4LWJ3S3.js} +1 -1
  59. package/dist/bundle/chunks/virtual-modules-LP2ULVLW.js +5 -0
  60. package/dist/bundle/cli-runtime.js +3 -3
  61. package/dist/bundle/cli.js +2 -2
  62. package/dist/bundle/flow/package.json +6 -5
  63. package/dist/bundle/index.js +8 -8
  64. package/dist/bundle/rpc-entry.js +3 -3
  65. package/dist/cli/credential-print.d.ts.map +1 -1
  66. package/dist/cli/credential-print.js +4 -4
  67. package/dist/cli/credential-print.js.map +1 -1
  68. package/dist/coordination/adapter/index.d.ts.map +1 -1
  69. package/dist/coordination/adapter/index.js +1 -1
  70. package/dist/coordination/adapter/index.js.map +1 -1
  71. package/dist/coordination/adapter/integration-notices.d.ts +1 -1
  72. package/dist/coordination/adapter/integration-notices.d.ts.map +1 -1
  73. package/dist/coordination/adapter/integration-notices.js +5 -2
  74. package/dist/coordination/adapter/integration-notices.js.map +1 -1
  75. package/dist/coordination/broker/extension-state.js +3 -3
  76. package/dist/coordination/broker/extension-state.js.map +1 -1
  77. package/dist/coordination/transport/framing.d.ts.map +1 -1
  78. package/dist/coordination/transport/framing.js +2 -1
  79. package/dist/coordination/transport/framing.js.map +1 -1
  80. package/dist/core/account-reporting.d.ts +3 -1
  81. package/dist/core/account-reporting.d.ts.map +1 -1
  82. package/dist/core/account-reporting.js +12 -2
  83. package/dist/core/account-reporting.js.map +1 -1
  84. package/dist/core/agent-session-services.d.ts.map +1 -1
  85. package/dist/core/agent-session-services.js +39 -36
  86. package/dist/core/agent-session-services.js.map +1 -1
  87. package/dist/core/agent-session.d.ts +4 -2
  88. package/dist/core/agent-session.d.ts.map +1 -1
  89. package/dist/core/agent-session.js +5 -4
  90. package/dist/core/agent-session.js.map +1 -1
  91. package/dist/core/codex-usage.d.ts +11 -2
  92. package/dist/core/codex-usage.d.ts.map +1 -1
  93. package/dist/core/codex-usage.js +74 -2
  94. package/dist/core/codex-usage.js.map +1 -1
  95. package/dist/core/export-html/template.js +21 -16
  96. package/dist/core/model-config.d.ts +33 -8
  97. package/dist/core/model-config.d.ts.map +1 -1
  98. package/dist/core/model-config.js +22 -4
  99. package/dist/core/model-config.js.map +1 -1
  100. package/dist/core/model-resolver.d.ts +56 -43
  101. package/dist/core/model-resolver.d.ts.map +1 -1
  102. package/dist/core/model-resolver.js +256 -361
  103. package/dist/core/model-resolver.js.map +1 -1
  104. package/dist/core/model-runtime.d.ts +6 -3
  105. package/dist/core/model-runtime.d.ts.map +1 -1
  106. package/dist/core/model-runtime.js +19 -5
  107. package/dist/core/model-runtime.js.map +1 -1
  108. package/dist/core/models-store.d.ts.map +1 -1
  109. package/dist/core/models-store.js +7 -2
  110. package/dist/core/models-store.js.map +1 -1
  111. package/dist/core/oauth-account-pool.d.ts +9 -1
  112. package/dist/core/oauth-account-pool.d.ts.map +1 -1
  113. package/dist/core/oauth-account-pool.js +63 -12
  114. package/dist/core/oauth-account-pool.js.map +1 -1
  115. package/dist/core/prompt-templates.d.ts.map +1 -1
  116. package/dist/core/prompt-templates.js +7 -2
  117. package/dist/core/prompt-templates.js.map +1 -1
  118. package/dist/core/settings-defaults.d.ts +2 -0
  119. package/dist/core/settings-defaults.d.ts.map +1 -1
  120. package/dist/core/settings-defaults.js +2 -0
  121. package/dist/core/settings-defaults.js.map +1 -1
  122. package/dist/core/settings-manager.d.ts +4 -2
  123. package/dist/core/settings-manager.d.ts.map +1 -1
  124. package/dist/core/settings-manager.js +11 -0
  125. package/dist/core/settings-manager.js.map +1 -1
  126. package/dist/core/settings-schema.d.ts +4 -0
  127. package/dist/core/settings-schema.d.ts.map +1 -1
  128. package/dist/core/settings-schema.js +8 -0
  129. package/dist/core/settings-schema.js.map +1 -1
  130. package/dist/core/slash-commands.js +1 -1
  131. package/dist/core/slash-commands.js.map +1 -1
  132. package/dist/core/tools/render-utils.d.ts +2 -0
  133. package/dist/core/tools/render-utils.d.ts.map +1 -1
  134. package/dist/core/tools/render-utils.js +21 -0
  135. package/dist/core/tools/render-utils.js.map +1 -1
  136. package/dist/core/tools/renderers/read.d.ts.map +1 -1
  137. package/dist/core/tools/renderers/read.js +7 -10
  138. package/dist/core/tools/renderers/read.js.map +1 -1
  139. package/dist/core/tools/subagent.d.ts.map +1 -1
  140. package/dist/core/tools/subagent.js +4 -7
  141. package/dist/core/tools/subagent.js.map +1 -1
  142. package/dist/core/trace/redaction.d.ts.map +1 -1
  143. package/dist/core/trace/redaction.js +3 -1
  144. package/dist/core/trace/redaction.js.map +1 -1
  145. package/dist/extensions/codemode/execute.d.ts.map +1 -1
  146. package/dist/extensions/codemode/execute.js +12 -0
  147. package/dist/extensions/codemode/execute.js.map +1 -1
  148. package/dist/extensions/codemode/index.d.ts.map +1 -1
  149. package/dist/extensions/codemode/index.js +5 -0
  150. package/dist/extensions/codemode/index.js.map +1 -1
  151. package/dist/humain/bedrock-provider/vendor/index.bundle.mjs +74 -20
  152. package/dist/humain/flow-accounts-host.d.ts.map +1 -1
  153. package/dist/humain/flow-accounts-host.js +3 -0
  154. package/dist/humain/flow-accounts-host.js.map +1 -1
  155. package/dist/humain/flow-command.d.ts +1 -1
  156. package/dist/humain/flow-command.d.ts.map +1 -1
  157. package/dist/humain/flow-command.js +8 -1
  158. package/dist/humain/flow-command.js.map +1 -1
  159. package/dist/humain/flow-loader.js +1 -1
  160. package/dist/humain/flow-loader.js.map +1 -1
  161. package/dist/humain/node-provider.d.ts.map +1 -1
  162. package/dist/humain/node-provider.js +2 -0
  163. package/dist/humain/node-provider.js.map +1 -1
  164. package/dist/humain/trace-capture/index.js +3 -3
  165. package/dist/humain/trace-capture/index.js.map +1 -1
  166. package/dist/humain/web-access/vendor/credential-source.d.ts +2 -0
  167. package/dist/humain/web-access/vendor/credential-source.d.ts.map +1 -1
  168. package/dist/humain/web-access/vendor/credential-source.js +50 -4
  169. package/dist/humain/web-access/vendor/credential-source.js.map +1 -1
  170. package/dist/humain/web-access/vendor/curator-page.d.ts.map +1 -1
  171. package/dist/humain/web-access/vendor/curator-page.js +3 -1
  172. package/dist/humain/web-access/vendor/curator-page.js.map +1 -1
  173. package/dist/humain/web-access/vendor/curator-server.d.ts.map +1 -1
  174. package/dist/humain/web-access/vendor/curator-server.js +2 -0
  175. package/dist/humain/web-access/vendor/curator-server.js.map +1 -1
  176. package/dist/humain/web-access/vendor/deepseek.d.ts +4 -0
  177. package/dist/humain/web-access/vendor/deepseek.d.ts.map +1 -0
  178. package/dist/humain/web-access/vendor/deepseek.js +201 -0
  179. package/dist/humain/web-access/vendor/deepseek.js.map +1 -0
  180. package/dist/humain/web-access/vendor/extract.d.ts.map +1 -1
  181. package/dist/humain/web-access/vendor/extract.js +4 -2
  182. package/dist/humain/web-access/vendor/extract.js.map +1 -1
  183. package/dist/humain/web-access/vendor/gemini-adc.d.ts.map +1 -1
  184. package/dist/humain/web-access/vendor/gemini-adc.js +49 -5
  185. package/dist/humain/web-access/vendor/gemini-adc.js.map +1 -1
  186. package/dist/humain/web-access/vendor/gemini-search.d.ts +3 -3
  187. package/dist/humain/web-access/vendor/gemini-search.d.ts.map +1 -1
  188. package/dist/humain/web-access/vendor/gemini-search.js +11 -4
  189. package/dist/humain/web-access/vendor/gemini-search.js.map +1 -1
  190. package/dist/humain/web-access/vendor/index.d.ts.map +1 -1
  191. package/dist/humain/web-access/vendor/index.js +16 -1
  192. package/dist/humain/web-access/vendor/index.js.map +1 -1
  193. package/dist/humain/web-access/vendor/page-query.d.ts.map +1 -1
  194. package/dist/humain/web-access/vendor/page-query.js +12 -6
  195. package/dist/humain/web-access/vendor/page-query.js.map +1 -1
  196. package/dist/humain/web-access/vendor/query-rewrite.d.ts.map +1 -1
  197. package/dist/humain/web-access/vendor/query-rewrite.js +11 -4
  198. package/dist/humain/web-access/vendor/query-rewrite.js.map +1 -1
  199. package/dist/humain/web-access/vendor/searxng.d.ts.map +1 -1
  200. package/dist/humain/web-access/vendor/searxng.js +2 -1
  201. package/dist/humain/web-access/vendor/searxng.js.map +1 -1
  202. package/dist/humain/web-access/vendor/ssrf-protection.d.ts +1 -0
  203. package/dist/humain/web-access/vendor/ssrf-protection.d.ts.map +1 -1
  204. package/dist/humain/web-access/vendor/ssrf-protection.js +10 -0
  205. package/dist/humain/web-access/vendor/ssrf-protection.js.map +1 -1
  206. package/dist/humain/web-access/vendor/summary-review.d.ts.map +1 -1
  207. package/dist/humain/web-access/vendor/summary-review.js +17 -6
  208. package/dist/humain/web-access/vendor/summary-review.js.map +1 -1
  209. package/dist/humain/web-access/vendor/utils.d.ts +2 -0
  210. package/dist/humain/web-access/vendor/utils.d.ts.map +1 -1
  211. package/dist/humain/web-access/vendor/utils.js +18 -0
  212. package/dist/humain/web-access/vendor/utils.js.map +1 -1
  213. package/dist/humain/web-access/vendor/web-tool-core.d.ts +2 -0
  214. package/dist/humain/web-access/vendor/web-tool-core.d.ts.map +1 -1
  215. package/dist/humain/web-access/vendor/web-tool-core.js.map +1 -1
  216. package/dist/index.d.ts +1 -0
  217. package/dist/index.d.ts.map +1 -1
  218. package/dist/index.js.map +1 -1
  219. package/dist/main.d.ts.map +1 -1
  220. package/dist/main.js +1 -0
  221. package/dist/main.js.map +1 -1
  222. package/dist/modes/interactive/components/settings-selector.d.ts +3 -1
  223. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  224. package/dist/modes/interactive/components/settings-selector.js +10 -0
  225. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  226. package/dist/modes/interactive/components/status-indicator.d.ts +5 -0
  227. package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
  228. package/dist/modes/interactive/components/status-indicator.js +27 -2
  229. package/dist/modes/interactive/components/status-indicator.js.map +1 -1
  230. package/dist/modes/interactive/components/tool-execution.d.ts +2 -1
  231. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  232. package/dist/modes/interactive/components/tool-execution.js +4 -2
  233. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  234. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  235. package/dist/modes/interactive/components/tree-selector.js +2 -9
  236. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  237. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  238. package/dist/modes/interactive/interactive-mode.js +28 -14
  239. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  240. package/dist/modes/interactive/oauth-account-format.d.ts +4 -4
  241. package/dist/modes/interactive/oauth-account-format.d.ts.map +1 -1
  242. package/dist/modes/interactive/oauth-account-format.js +5 -2
  243. package/dist/modes/interactive/oauth-account-format.js.map +1 -1
  244. package/dist/modes/interactive/session-share.d.ts.map +1 -1
  245. package/dist/modes/interactive/session-share.js +9 -2
  246. package/dist/modes/interactive/session-share.js.map +1 -1
  247. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  248. package/dist/modes/rpc/rpc-mode.js +16 -4
  249. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  250. package/dist/utils/tools-manager.d.ts.map +1 -1
  251. package/dist/utils/tools-manager.js +2 -1
  252. package/dist/utils/tools-manager.js.map +1 -1
  253. package/docs/cli.md +3 -3
  254. package/docs/codemode.md +3 -1
  255. package/docs/coordination.md +6 -0
  256. package/docs/docs.json +4 -0
  257. package/docs/environment-variables.md +4 -0
  258. package/docs/flow.md +20 -2
  259. package/docs/humain-code-forge-flow-walkthrough.md +1 -1
  260. package/docs/humain-code.md +2 -4
  261. package/docs/json.md +2 -2
  262. package/docs/llama-cpp.md +1 -1
  263. package/docs/nvidia-rtx-llama-cpp.md +96 -0
  264. package/docs/rpc-commands.md +1 -1
  265. package/docs/rpc.md +9 -1
  266. package/docs/sessions.md +1 -1
  267. package/docs/settings.md +2 -0
  268. package/docs/trace.md +4 -0
  269. package/docs/usage.md +1 -1
  270. package/examples/extensions/custom-provider-anthropic/package-lock.json +16 -6
  271. package/examples/extensions/custom-provider-anthropic/package.json +2 -2
  272. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  273. package/examples/extensions/gondolin/package-lock.json +16 -16
  274. package/examples/extensions/gondolin/package.json +1 -1
  275. package/examples/extensions/minimal-mode.ts +4 -4
  276. package/examples/extensions/sandbox/package-lock.json +6 -6
  277. package/examples/extensions/sandbox/package.json +2 -2
  278. package/examples/extensions/with-deps/package-lock.json +2 -2
  279. package/examples/extensions/with-deps/package.json +1 -1
  280. package/examples/plugins/pi-example-plugin/package.json +2 -2
  281. package/examples/rpc-subagent-progress-host.ts +6 -2
  282. package/npm-shrinkwrap.json +129 -171
  283. package/package.json +19 -19
  284. package/schemas/models.schema.json +9 -5
  285. package/schemas/settings.schema.json +32 -0
  286. package/src/coordination/UPSTREAM.md +31 -1
  287. package/src/coordination/upstream.json +3 -3
  288. package/src/humain/adhd/UPSTREAM.md +8 -0
  289. package/src/humain/caveman/UPSTREAM.md +19 -3
  290. package/src/humain/caveman/upstream.json +2 -2
  291. package/src/humain/ponytail/UPSTREAM.md +23 -2
  292. package/src/humain/ponytail/upstream.json +8 -8
  293. package/src/humain/ponytail/vendor/skills/ponytail/SKILL.md +1 -1
  294. package/src/humain/ponytail/vendor/skills/ponytail-debt/SKILL.md +1 -2
  295. package/src/humain/ponytail/vendor/skills/ponytail-gain/SKILL.md +0 -1
  296. package/src/humain/web-access/UPSTREAM.md +45 -1
  297. package/src/humain/web-access/upstream.json +4 -4
  298. package/dist/bundle/chunks/anthropic-messages-YSAHA7QM.js +0 -67
  299. package/dist/bundle/chunks/azure-openai-responses-Z5XYDPHS.js +0 -15
  300. package/dist/bundle/chunks/chunk-2TTB6GIB.js +0 -47
  301. package/dist/bundle/chunks/chunk-4DXXZHY2.js +0 -540
  302. package/dist/bundle/chunks/chunk-A7QKOI62.js +0 -572
  303. package/dist/bundle/chunks/chunk-FRUFMISJ.js +0 -505
  304. package/dist/bundle/chunks/chunk-IUKCPYKD.js +0 -1786
  305. package/dist/bundle/chunks/chunk-MG5PX4KU.js +0 -31
  306. package/dist/bundle/chunks/chunk-RYC5BYVE.js +0 -5
  307. package/dist/bundle/chunks/chunk-YJ3NQWES.js +0 -9
  308. package/dist/bundle/chunks/dist-MNSGVI4C.js +0 -7
  309. package/dist/bundle/chunks/dist-cjs-4BMVQ74V.js +0 -179
  310. package/dist/bundle/chunks/host-2RMBOGA7.js +0 -2
  311. package/dist/bundle/chunks/jiti-static-loader-2RCDI6B4.js +0 -2
  312. package/dist/bundle/chunks/openai-completions-WGBQHTYA.js +0 -79
  313. package/dist/bundle/chunks/openai-responses-OKGCSIEY.js +0 -23
  314. package/dist/bundle/chunks/pdfjs-6UVU6XFX.js +0 -3564
  315. package/dist/bundle/chunks/virtual-modules-5KW36RPG.js +0 -5
@@ -1,4 +1,4 @@
1
- import { type OAuthAccount } from "./oauth-account-pool.ts";
1
+ import { type OAuthAccount, type OAuthAccountPool } from "./oauth-account-pool.ts";
2
2
  export declare const CODEX_USAGE_URL = "https://chatgpt.com/backend-api/wham/usage";
3
3
  export declare const CODEX_USAGE_PROVIDER_ID = "openai-codex";
4
4
  export interface CodexCreditsStatus {
@@ -6,12 +6,15 @@ export interface CodexCreditsStatus {
6
6
  unlimited: boolean;
7
7
  balance?: string;
8
8
  }
9
+ type CodexAvailability = "allowed" | "blocked" | "unknown";
9
10
  export interface CodexWeeklyUsage {
10
11
  /** Provider-reported remaining percentage in the weekly window, 0..100. */
11
12
  remainingPercent: number;
12
13
  /** Epoch ms when the weekly window resets, when the provider reports it. */
13
14
  resetsAt: number | undefined;
14
15
  limitReached?: boolean;
16
+ /** Conservative availability across all reported limits, not proof of access to every model. */
17
+ availability?: CodexAvailability;
15
18
  /** Provider `rate_limit.allowed`, when reported. */
16
19
  allowed?: boolean;
17
20
  /** True when any reported window (any duration) has used_percent >= 100. Omitted otherwise. */
@@ -23,12 +26,15 @@ export type CodexUsageUnavailableReason = "expired_credential" | "unauthorized"
23
26
  export type CodexUsageResult = {
24
27
  status: "ok";
25
28
  usage: CodexWeeklyUsage;
29
+ cooldownCleared?: boolean;
26
30
  } | {
27
31
  status: "unavailable";
28
32
  reason: CodexUsageUnavailableReason;
29
33
  };
30
34
  export interface FetchCodexWeeklyUsageOptions {
31
35
  signal?: AbortSignal;
36
+ /** Opt in to clearing an unchanged cached cooldown after explicit provider availability. Never switches accounts. */
37
+ accountPool?: OAuthAccountPool;
32
38
  /** Injected for tests. Defaults to globalThis.fetch. */
33
39
  fetch?: typeof fetch;
34
40
  /** Reference time in epoch ms. Defaults to Date.now(). */
@@ -36,6 +42,7 @@ export interface FetchCodexWeeklyUsageOptions {
36
42
  }
37
43
  export interface FetchCodexWeeklyUsageForAccountsOptions {
38
44
  signal?: AbortSignal;
45
+ accountPool?: OAuthAccountPool;
39
46
  fetch?: typeof fetch;
40
47
  /** Per-request timeout in ms. Default 10_000. */
41
48
  timeoutMs?: number;
@@ -47,8 +54,10 @@ export interface FetchCodexWeeklyUsageForAccountsOptions {
47
54
  export declare function parseCodexCredits(payload: unknown): CodexCreditsStatus | undefined;
48
55
  /** Pure parser, exported for tests. Returns undefined when no valid weekly window exists. */
49
56
  export declare function parseCodexWeeklyUsage(payload: unknown, nowMs: number): CodexWeeklyUsage | undefined;
50
- /** One read-only usage lookup for one pooled account. Never throws; never mutates the credential. */
57
+ export declare function getCodexAvailability(usage: CodexWeeklyUsage): CodexAvailability;
58
+ /** One usage lookup for one pooled account. Never throws; never mutates the credential. */
51
59
  export declare function fetchCodexWeeklyUsage(account: OAuthAccount, options?: FetchCodexWeeklyUsageOptions): Promise<CodexUsageResult>;
52
60
  /** Bounded-concurrency fan-out; one failure never affects other accounts. */
53
61
  export declare function fetchCodexWeeklyUsageForAccounts(accounts: readonly OAuthAccount[], options?: FetchCodexWeeklyUsageForAccountsOptions): Promise<Map<string, CodexUsageResult>>;
62
+ export {};
54
63
  //# sourceMappingURL=codex-usage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"codex-usage.d.ts","sourceRoot":"","sources":["../../src/core/codex-usage.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,YAAY,EAAqC,MAAM,yBAAyB,CAAC;AAE/F,eAAO,MAAM,eAAe,+CAA+C,CAAC;AAC5E,eAAO,MAAM,uBAAuB,iBAAiB,CAAC;AAUtD,MAAM,WAAW,kBAAkB;IAClC,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAChC,2EAA2E;IAC3E,gBAAgB,EAAE,MAAM,CAAC;IACzB,4EAA4E;IAC5E,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,oDAAoD;IACpD,OAAO,CAAC,EAA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Q,EAAE,SAAS,YAAY,EAAE,EACjC,OAAO,GAAE,uCAA4C,GACnD,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAoCxC"}
@@ -66,8 +66,10 @@ export function parseCodexWeeklyUsage(payload, nowMs) {
66
66
  const rateLimitReachedType = typeof payload.rate_limit_reached_type === "string" && REACHED_TYPE_PATTERN.test(payload.rate_limit_reached_type)
67
67
  ? payload.rate_limit_reached_type
68
68
  : undefined;
69
+ const availability = reportedAvailability(payload);
69
70
  return {
70
71
  ...weeklyUsage,
72
+ ...(availability !== "unknown" || allowed !== undefined || limitReached !== undefined ? { availability } : {}),
71
73
  ...(limitReached !== undefined ? { limitReached } : {}),
72
74
  ...(allowed !== undefined ? { allowed } : {}),
73
75
  ...(exhaustedWindow ? { exhaustedWindow } : {}),
@@ -75,13 +77,70 @@ export function parseCodexWeeklyUsage(payload, nowMs) {
75
77
  ...(rateLimitReachedType !== undefined ? { rateLimitReachedType } : {}),
76
78
  };
77
79
  }
80
+ export function getCodexAvailability(usage) {
81
+ if (usage.availability !== undefined)
82
+ return usage.availability;
83
+ if (usage.allowed === false || usage.limitReached === true || usage.exhaustedWindow === true)
84
+ return "blocked";
85
+ return usage.allowed === true && usage.limitReached === false ? "allowed" : "unknown";
86
+ }
78
87
  function unavailable(reason) {
79
88
  return { status: "unavailable", reason };
80
89
  }
81
90
  function isAbortError(error) {
82
91
  return isRecord(error) && (error.name === "AbortError" || error.name === "TimeoutError");
83
92
  }
84
- /** One read-only usage lookup for one pooled account. Never throws; never mutates the credential. */
93
+ /** Confirm every reported limit before overriding a cached denial; malformed or omitted availability stays unknown. */
94
+ function reportedAvailability(payload) {
95
+ let unknown = false;
96
+ if (payload.rate_limit_reached_type != null && payload.rate_limit_reached_type !== "") {
97
+ if (typeof payload.rate_limit_reached_type === "string" &&
98
+ REACHED_TYPE_PATTERN.test(payload.rate_limit_reached_type))
99
+ return "blocked";
100
+ unknown = true;
101
+ }
102
+ const limits = [payload.rate_limit];
103
+ if (payload.code_review_rate_limit != null)
104
+ limits.push(payload.code_review_rate_limit);
105
+ if (payload.additional_rate_limits != null) {
106
+ if (!Array.isArray(payload.additional_rate_limits))
107
+ unknown = true;
108
+ else
109
+ for (const entry of payload.additional_rate_limits)
110
+ limits.push(isRecord(entry) ? entry.rate_limit : undefined);
111
+ }
112
+ for (const limit of limits) {
113
+ if (!isRecord(limit)) {
114
+ unknown = true;
115
+ continue;
116
+ }
117
+ if (limit.allowed === false || limit.limit_reached === true)
118
+ return "blocked";
119
+ if (limit.allowed !== true || limit.limit_reached !== false)
120
+ unknown = true;
121
+ const windows = [limit.primary_window, limit.secondary_window].filter((window) => window != null);
122
+ if (windows.length === 0)
123
+ unknown = true;
124
+ for (const window of windows) {
125
+ if (!isRecord(window)) {
126
+ unknown = true;
127
+ continue;
128
+ }
129
+ if (typeof window.used_percent !== "number" ||
130
+ !Number.isFinite(window.used_percent) ||
131
+ window.used_percent < 0)
132
+ unknown = true;
133
+ else if (window.used_percent >= 100)
134
+ return "blocked";
135
+ if (typeof window.limit_window_seconds !== "number" ||
136
+ !Number.isFinite(window.limit_window_seconds) ||
137
+ window.limit_window_seconds <= 0)
138
+ unknown = true;
139
+ }
140
+ }
141
+ return unknown ? "unknown" : "allowed";
142
+ }
143
+ /** One usage lookup for one pooled account. Never throws; never mutates the credential. */
85
144
  export async function fetchCodexWeeklyUsage(account, options = {}) {
86
145
  const now = options.now ?? Date.now();
87
146
  if (account.credential.expires <= now)
@@ -127,7 +186,19 @@ export async function fetchCodexWeeklyUsage(account, options = {}) {
127
186
  if (!isRecord(payload))
128
187
  return unavailable("malformed");
129
188
  const usage = parseCodexWeeklyUsage(payload, now);
130
- return usage ? { status: "ok", usage } : unavailable("no_weekly_window");
189
+ if (!usage)
190
+ return unavailable("no_weekly_window");
191
+ if (options.accountPool && account.exhaustedUntil !== undefined && getCodexAvailability(usage) === "allowed") {
192
+ try {
193
+ if (await options.accountPool.clearExhaustion(CODEX_USAGE_PROVIDER_ID, account, { signal: options.signal })) {
194
+ return { status: "ok", usage, cooldownCleared: true };
195
+ }
196
+ }
197
+ catch {
198
+ // A cancelled or failed pool write must not hide real usage or claim the cached cooldown was cleared.
199
+ }
200
+ }
201
+ return { status: "ok", usage };
131
202
  }
132
203
  /** Bounded-concurrency fan-out; one failure never affects other accounts. */
133
204
  export async function fetchCodexWeeklyUsageForAccounts(accounts, options = {}) {
@@ -149,6 +220,7 @@ export async function fetchCodexWeeklyUsageForAccounts(accounts, options = {}) {
149
220
  const timeoutSignal = AbortSignal.timeout(timeoutMs);
150
221
  const signal = options.signal ? AbortSignal.any([options.signal, timeoutSignal]) : timeoutSignal;
151
222
  const result = await fetchCodexWeeklyUsage(account, {
223
+ accountPool: options.accountPool,
152
224
  fetch: options.fetch,
153
225
  signal,
154
226
  });
@@ -1 +1 @@
1
- {"version":3,"file":"codex-usage.js","sourceRoot":"","sources":["../../src/core/codex-usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAqB,iCAAiC,EAAE,MAAM,yBAAyB,CAAC;AAE/F,MAAM,CAAC,MAAM,eAAe,GAAG,4CAA4C,CAAC;AAC5E,MAAM,CAAC,MAAM,uBAAuB,GAAG,cAAc,CAAC;AAEtD,MAAM,gBAAgB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AAC1C,MAAM,gBAAgB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AAC1C,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAClC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAC9B,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AACnC,MAAM,eAAe,GAAG,0BAA0B,CAAC;AACnD,MAAM,oBAAoB,GAAG,mBAAmB,CAAC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CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YACrD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC;YACjG,MAAM,MAAM,GAAG,MAAM,qBAAqB,CAAC,OAAO,EAAE;gBACnD,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,MAAM;aACN,CAAC,CAAC;YACH,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YACjC,IAAI,CAAC;gBACJ,OAAO,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YACzC,CAAC;YAAC,MAAM,CAAC;gBACR,oEAAoE;YACrE,CAAC;QACF,CAAC;IACF,CAAC;IAED,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IACvE,OAAO,OAAO,CAAC;AAChB,CAAC","sourcesContent":["import { VERSION } from \"../config.ts\";\nimport { getPiUserAgent } from \"../utils/pi-user-agent.ts\";\nimport { type OAuthAccount, resolveOpenAICodexAccountIdentity } from \"./oauth-account-pool.ts\";\n\nexport const CODEX_USAGE_URL = \"https://chatgpt.com/backend-api/wham/usage\";\nexport const CODEX_USAGE_PROVIDER_ID = \"openai-codex\";\n\nconst MIN_WEEK_SECONDS = 6 * 24 * 60 * 60;\nconst MAX_WEEK_SECONDS = 8 * 24 * 60 * 60;\nconst DEFAULT_TIMEOUT_MS = 10_000;\nconst DEFAULT_CONCURRENCY = 3;\nconst MAX_TIMEOUT_MS = 2 ** 31 - 1;\nconst BALANCE_PATTERN = /^-?\\d{1,15}(\\.\\d{1,8})?$/;\nconst REACHED_TYPE_PATTERN = /^[a-z0-9_]{1,64}$/;\n\nexport interface CodexCreditsStatus {\n\thasCredits: boolean;\n\tunlimited: boolean;\n\tbalance?: string;\n}\n\nexport interface CodexWeeklyUsage {\n\t/** Provider-reported remaining percentage in the weekly window, 0..100. */\n\tremainingPercent: number;\n\t/** Epoch ms when the weekly window resets, when the provider reports it. */\n\tresetsAt: number | undefined;\n\tlimitReached?: boolean;\n\t/** Provider `rate_limit.allowed`, when reported. */\n\tallowed?: boolean;\n\t/** True when any reported window (any duration) has used_percent >= 100. Omitted otherwise. */\n\texhaustedWindow?: boolean;\n\tcredits?: CodexCreditsStatus;\n\trateLimitReachedType?: string;\n}\n\nexport type CodexUsageUnavailableReason =\n\t| \"expired_credential\"\n\t| \"unauthorized\"\n\t| \"rate_limited\"\n\t| \"http_error\"\n\t| \"timeout\"\n\t| \"network\"\n\t| \"malformed\"\n\t| \"no_weekly_window\";\n\nexport type CodexUsageResult =\n\t| { status: \"ok\"; usage: CodexWeeklyUsage }\n\t| { status: \"unavailable\"; reason: CodexUsageUnavailableReason };\n\nexport interface FetchCodexWeeklyUsageOptions {\n\tsignal?: AbortSignal;\n\t/** Injected for tests. Defaults to globalThis.fetch. */\n\tfetch?: typeof fetch;\n\t/** Reference time in epoch ms. Defaults to Date.now(). */\n\tnow?: number;\n}\n\nexport interface FetchCodexWeeklyUsageForAccountsOptions {\n\tsignal?: AbortSignal;\n\tfetch?: typeof fetch;\n\t/** Per-request timeout in ms. Default 10_000. */\n\ttimeoutMs?: number;\n\t/** Max in-flight requests. Default 3. */\n\tconcurrency?: number;\n\t/** Called as each account result arrives (for progressive UI updates). */\n\tonResult?: (accountKey: string, result: CodexUsageResult) => void;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction parseWeeklyWindow(value: unknown, nowMs: number): CodexWeeklyUsage | undefined {\n\tif (!isRecord(value)) return undefined;\n\tconst duration = value.limit_window_seconds;\n\tconst usedPercent = value.used_percent;\n\tif (\n\t\ttypeof duration !== \"number\" ||\n\t\t!Number.isFinite(duration) ||\n\t\tduration < MIN_WEEK_SECONDS ||\n\t\tduration > MAX_WEEK_SECONDS ||\n\t\ttypeof usedPercent !== \"number\" ||\n\t\t!Number.isFinite(usedPercent) ||\n\t\tusedPercent < 0 ||\n\t\tusedPercent > 100\n\t) {\n\t\treturn undefined;\n\t}\n\n\tconst resetAt = value.reset_at;\n\tconst resetAfterSeconds = value.reset_after_seconds;\n\tconst resetsAt =\n\t\ttypeof resetAt === \"number\" && Number.isFinite(resetAt) && resetAt > 0\n\t\t\t? resetAt * 1000\n\t\t\t: typeof resetAfterSeconds === \"number\" && Number.isFinite(resetAfterSeconds) && resetAfterSeconds >= 0\n\t\t\t\t? nowMs + resetAfterSeconds * 1000\n\t\t\t\t: undefined;\n\n\treturn { remainingPercent: Math.max(0, Math.min(100, 100 - usedPercent)), resetsAt };\n}\n\nexport function parseCodexCredits(payload: unknown): CodexCreditsStatus | undefined {\n\tif (!isRecord(payload) || !isRecord(payload.credits)) return undefined;\n\tconst { has_credits: hasCredits, unlimited } = payload.credits;\n\tif (typeof hasCredits !== \"boolean\" || typeof unlimited !== \"boolean\") return undefined;\n\tconst rawBalance = typeof payload.credits.balance === \"string\" ? payload.credits.balance.trim() : \"\";\n\tconst balance = BALANCE_PATTERN.test(rawBalance) ? rawBalance : \"\";\n\treturn { hasCredits, unlimited, ...(balance ? { balance } : {}) };\n}\n\n/** Pure parser, exported for tests. Returns undefined when no valid weekly window exists. */\nexport function parseCodexWeeklyUsage(payload: unknown, nowMs: number): CodexWeeklyUsage | undefined {\n\tif (!isRecord(payload) || !isRecord(payload.rate_limit)) return undefined;\n\tconst rateLimit = payload.rate_limit;\n\tconst weeklyUsage =\n\t\tparseWeeklyWindow(rateLimit.primary_window, nowMs) ?? parseWeeklyWindow(rateLimit.secondary_window, nowMs);\n\tif (!weeklyUsage) return undefined;\n\n\tconst allowed = typeof rateLimit.allowed === \"boolean\" ? rateLimit.allowed : undefined;\n\tconst exhaustedWindow = [rateLimit.primary_window, rateLimit.secondary_window].some(\n\t\t(window) =>\n\t\t\tisRecord(window) &&\n\t\t\ttypeof window.used_percent === \"number\" &&\n\t\t\tNumber.isFinite(window.used_percent) &&\n\t\t\twindow.used_percent >= 100,\n\t);\n\tconst limitReached =\n\t\trateLimit.allowed === false ||\n\t\t(typeof rateLimit.limit_reached === \"boolean\" ? rateLimit.limit_reached : undefined);\n\tconst credits = parseCodexCredits(payload);\n\tconst rateLimitReachedType =\n\t\ttypeof payload.rate_limit_reached_type === \"string\" && REACHED_TYPE_PATTERN.test(payload.rate_limit_reached_type)\n\t\t\t? payload.rate_limit_reached_type\n\t\t\t: undefined;\n\treturn {\n\t\t...weeklyUsage,\n\t\t...(limitReached !== undefined ? { limitReached } : {}),\n\t\t...(allowed !== undefined ? { allowed } : {}),\n\t\t...(exhaustedWindow ? { exhaustedWindow } : {}),\n\t\t...(credits ? { credits } : {}),\n\t\t...(rateLimitReachedType !== undefined ? { rateLimitReachedType } : {}),\n\t};\n}\n\nfunction unavailable(reason: CodexUsageUnavailableReason): CodexUsageResult {\n\treturn { status: \"unavailable\", reason };\n}\n\nfunction isAbortError(error: unknown): boolean {\n\treturn isRecord(error) && (error.name === \"AbortError\" || error.name === \"TimeoutError\");\n}\n\n/** One read-only usage lookup for one pooled account. Never throws; never mutates the credential. */\nexport async function fetchCodexWeeklyUsage(\n\taccount: OAuthAccount,\n\toptions: FetchCodexWeeklyUsageOptions = {},\n): Promise<CodexUsageResult> {\n\tconst now = options.now ?? Date.now();\n\tif (account.credential.expires <= now) return unavailable(\"expired_credential\");\n\tif (options.signal?.aborted) return unavailable(\"timeout\");\n\tconst accountId = resolveOpenAICodexAccountIdentity(account.credential)?.key ?? account.credential.accountId;\n\tif (typeof accountId !== \"string\" || !accountId.trim()) return unavailable(\"malformed\");\n\n\tlet response: Response;\n\ttry {\n\t\tconst fetcher = options.fetch ?? globalThis.fetch;\n\t\tresponse = await fetcher(CODEX_USAGE_URL, {\n\t\t\tmethod: \"GET\",\n\t\t\theaders: {\n\t\t\t\tAuthorization: `Bearer ${account.credential.access}`,\n\t\t\t\t\"chatgpt-account-id\": accountId,\n\t\t\t\tAccept: \"application/json\",\n\t\t\t\t\"User-Agent\": getPiUserAgent(VERSION),\n\t\t\t\toriginator: \"pi\",\n\t\t\t},\n\t\t\t// The usage route must never redirect; refusing keeps the bearer token and account id on this origin.\n\t\t\tredirect: \"error\",\n\t\t\tsignal: options.signal,\n\t\t});\n\t} catch (error) {\n\t\treturn unavailable(options.signal?.aborted || isAbortError(error) ? \"timeout\" : \"network\");\n\t}\n\n\tif (response.status === 401 || response.status === 403) return unavailable(\"unauthorized\");\n\tif (response.status === 429) return unavailable(\"rate_limited\");\n\tif (!response.ok) return unavailable(\"http_error\");\n\n\tlet payload: unknown;\n\ttry {\n\t\tpayload = await response.json();\n\t} catch (error) {\n\t\treturn unavailable(options.signal?.aborted || isAbortError(error) ? \"timeout\" : \"malformed\");\n\t}\n\tif (!isRecord(payload)) return unavailable(\"malformed\");\n\n\tconst usage = parseCodexWeeklyUsage(payload, now);\n\treturn usage ? { status: \"ok\", usage } : unavailable(\"no_weekly_window\");\n}\n\n/** Bounded-concurrency fan-out; one failure never affects other accounts. */\nexport async function fetchCodexWeeklyUsageForAccounts(\n\taccounts: readonly OAuthAccount[],\n\toptions: FetchCodexWeeklyUsageForAccountsOptions = {},\n): Promise<Map<string, CodexUsageResult>> {\n\tconst results = new Map<string, CodexUsageResult>();\n\tlet nextIndex = 0;\n\tconst requestedConcurrency = options.concurrency ?? DEFAULT_CONCURRENCY;\n\tconst concurrency =\n\t\tNumber.isFinite(requestedConcurrency) && requestedConcurrency >= 1\n\t\t\t? Math.min(accounts.length, Math.floor(requestedConcurrency))\n\t\t\t: Math.min(accounts.length, DEFAULT_CONCURRENCY);\n\tconst requestedTimeout = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n\tconst timeoutMs =\n\t\tNumber.isFinite(requestedTimeout) && requestedTimeout >= 0\n\t\t\t? Math.min(MAX_TIMEOUT_MS, Math.floor(requestedTimeout))\n\t\t\t: DEFAULT_TIMEOUT_MS;\n\n\tasync function worker(): Promise<void> {\n\t\twhile (nextIndex < accounts.length) {\n\t\t\tif (options.signal?.aborted) return;\n\t\t\tconst account = accounts[nextIndex++];\n\t\t\tconst timeoutSignal = AbortSignal.timeout(timeoutMs);\n\t\t\tconst signal = options.signal ? AbortSignal.any([options.signal, timeoutSignal]) : timeoutSignal;\n\t\t\tconst result = await fetchCodexWeeklyUsage(account, {\n\t\t\t\tfetch: options.fetch,\n\t\t\t\tsignal,\n\t\t\t});\n\t\t\tresults.set(account.key, result);\n\t\t\ttry {\n\t\t\t\toptions.onResult?.(account.key, result);\n\t\t\t} catch {\n\t\t\t\t// Consumer callbacks must not interrupt lookups for other accounts.\n\t\t\t}\n\t\t}\n\t}\n\n\tawait Promise.all(Array.from({ length: concurrency }, () => worker()));\n\treturn results;\n}\n"]}
1
+ {"version":3,"file":"codex-usage.js","sourceRoot":"","sources":["../../src/core/codex-usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAA4C,iCAAiC,EAAE,MAAM,yBAAyB,CAAC;AAEtH,MAAM,CAAC,MAAM,eAAe,GAAG,4CAA4C,CAAC;AAC5E,MAAM,CAAC,MAAM,uBAAuB,GAAG,cAAc,CAAC;AAEtD,MAAM,gBAAgB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AAC1C,MAAM,gBAAgB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AAC1C,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAClC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAC9B,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,GAA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,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YACjC,IAAI,CAAC;gBACJ,OAAO,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YACzC,CAAC;YAAC,MAAM,CAAC;gBACR,oEAAoE;YACrE,CAAC;QACF,CAAC;IACF,CAAC;IAED,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IACvE,OAAO,OAAO,CAAC;AAChB,CAAC","sourcesContent":["import { VERSION } from \"../config.ts\";\nimport { getPiUserAgent } from \"../utils/pi-user-agent.ts\";\nimport { type OAuthAccount, type OAuthAccountPool, resolveOpenAICodexAccountIdentity } from \"./oauth-account-pool.ts\";\n\nexport const CODEX_USAGE_URL = \"https://chatgpt.com/backend-api/wham/usage\";\nexport const CODEX_USAGE_PROVIDER_ID = \"openai-codex\";\n\nconst MIN_WEEK_SECONDS = 6 * 24 * 60 * 60;\nconst MAX_WEEK_SECONDS = 8 * 24 * 60 * 60;\nconst DEFAULT_TIMEOUT_MS = 10_000;\nconst DEFAULT_CONCURRENCY = 3;\nconst MAX_TIMEOUT_MS = 2 ** 31 - 1;\nconst BALANCE_PATTERN = /^-?\\d{1,15}(\\.\\d{1,8})?$/;\nconst REACHED_TYPE_PATTERN = /^[a-z0-9_]{1,64}$/;\n\nexport interface CodexCreditsStatus {\n\thasCredits: boolean;\n\tunlimited: boolean;\n\tbalance?: string;\n}\n\ntype CodexAvailability = \"allowed\" | \"blocked\" | \"unknown\";\n\nexport interface CodexWeeklyUsage {\n\t/** Provider-reported remaining percentage in the weekly window, 0..100. */\n\tremainingPercent: number;\n\t/** Epoch ms when the weekly window resets, when the provider reports it. */\n\tresetsAt: number | undefined;\n\tlimitReached?: boolean;\n\t/** Conservative availability across all reported limits, not proof of access to every model. */\n\tavailability?: CodexAvailability;\n\t/** Provider `rate_limit.allowed`, when reported. */\n\tallowed?: boolean;\n\t/** True when any reported window (any duration) has used_percent >= 100. Omitted otherwise. */\n\texhaustedWindow?: boolean;\n\tcredits?: CodexCreditsStatus;\n\trateLimitReachedType?: string;\n}\n\nexport type CodexUsageUnavailableReason =\n\t| \"expired_credential\"\n\t| \"unauthorized\"\n\t| \"rate_limited\"\n\t| \"http_error\"\n\t| \"timeout\"\n\t| \"network\"\n\t| \"malformed\"\n\t| \"no_weekly_window\";\n\nexport type CodexUsageResult =\n\t| { status: \"ok\"; usage: CodexWeeklyUsage; cooldownCleared?: boolean }\n\t| { status: \"unavailable\"; reason: CodexUsageUnavailableReason };\n\nexport interface FetchCodexWeeklyUsageOptions {\n\tsignal?: AbortSignal;\n\t/** Opt in to clearing an unchanged cached cooldown after explicit provider availability. Never switches accounts. */\n\taccountPool?: OAuthAccountPool;\n\t/** Injected for tests. Defaults to globalThis.fetch. */\n\tfetch?: typeof fetch;\n\t/** Reference time in epoch ms. Defaults to Date.now(). */\n\tnow?: number;\n}\n\nexport interface FetchCodexWeeklyUsageForAccountsOptions {\n\tsignal?: AbortSignal;\n\taccountPool?: OAuthAccountPool;\n\tfetch?: typeof fetch;\n\t/** Per-request timeout in ms. Default 10_000. */\n\ttimeoutMs?: number;\n\t/** Max in-flight requests. Default 3. */\n\tconcurrency?: number;\n\t/** Called as each account result arrives (for progressive UI updates). */\n\tonResult?: (accountKey: string, result: CodexUsageResult) => void;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction parseWeeklyWindow(value: unknown, nowMs: number): CodexWeeklyUsage | undefined {\n\tif (!isRecord(value)) return undefined;\n\tconst duration = value.limit_window_seconds;\n\tconst usedPercent = value.used_percent;\n\tif (\n\t\ttypeof duration !== \"number\" ||\n\t\t!Number.isFinite(duration) ||\n\t\tduration < MIN_WEEK_SECONDS ||\n\t\tduration > MAX_WEEK_SECONDS ||\n\t\ttypeof usedPercent !== \"number\" ||\n\t\t!Number.isFinite(usedPercent) ||\n\t\tusedPercent < 0 ||\n\t\tusedPercent > 100\n\t) {\n\t\treturn undefined;\n\t}\n\n\tconst resetAt = value.reset_at;\n\tconst resetAfterSeconds = value.reset_after_seconds;\n\tconst resetsAt =\n\t\ttypeof resetAt === \"number\" && Number.isFinite(resetAt) && resetAt > 0\n\t\t\t? resetAt * 1000\n\t\t\t: typeof resetAfterSeconds === \"number\" && Number.isFinite(resetAfterSeconds) && resetAfterSeconds >= 0\n\t\t\t\t? nowMs + resetAfterSeconds * 1000\n\t\t\t\t: undefined;\n\n\treturn { remainingPercent: Math.max(0, Math.min(100, 100 - usedPercent)), resetsAt };\n}\n\nexport function parseCodexCredits(payload: unknown): CodexCreditsStatus | undefined {\n\tif (!isRecord(payload) || !isRecord(payload.credits)) return undefined;\n\tconst { has_credits: hasCredits, unlimited } = payload.credits;\n\tif (typeof hasCredits !== \"boolean\" || typeof unlimited !== \"boolean\") return undefined;\n\tconst rawBalance = typeof payload.credits.balance === \"string\" ? payload.credits.balance.trim() : \"\";\n\tconst balance = BALANCE_PATTERN.test(rawBalance) ? rawBalance : \"\";\n\treturn { hasCredits, unlimited, ...(balance ? { balance } : {}) };\n}\n\n/** Pure parser, exported for tests. Returns undefined when no valid weekly window exists. */\nexport function parseCodexWeeklyUsage(payload: unknown, nowMs: number): CodexWeeklyUsage | undefined {\n\tif (!isRecord(payload) || !isRecord(payload.rate_limit)) return undefined;\n\tconst rateLimit = payload.rate_limit;\n\tconst weeklyUsage =\n\t\tparseWeeklyWindow(rateLimit.primary_window, nowMs) ?? parseWeeklyWindow(rateLimit.secondary_window, nowMs);\n\tif (!weeklyUsage) return undefined;\n\n\tconst allowed = typeof rateLimit.allowed === \"boolean\" ? rateLimit.allowed : undefined;\n\tconst exhaustedWindow = [rateLimit.primary_window, rateLimit.secondary_window].some(\n\t\t(window) =>\n\t\t\tisRecord(window) &&\n\t\t\ttypeof window.used_percent === \"number\" &&\n\t\t\tNumber.isFinite(window.used_percent) &&\n\t\t\twindow.used_percent >= 100,\n\t);\n\tconst limitReached =\n\t\trateLimit.allowed === false ||\n\t\t(typeof rateLimit.limit_reached === \"boolean\" ? rateLimit.limit_reached : undefined);\n\tconst credits = parseCodexCredits(payload);\n\tconst rateLimitReachedType =\n\t\ttypeof payload.rate_limit_reached_type === \"string\" && REACHED_TYPE_PATTERN.test(payload.rate_limit_reached_type)\n\t\t\t? payload.rate_limit_reached_type\n\t\t\t: undefined;\n\tconst availability = reportedAvailability(payload);\n\treturn {\n\t\t...weeklyUsage,\n\t\t...(availability !== \"unknown\" || allowed !== undefined || limitReached !== undefined ? { availability } : {}),\n\t\t...(limitReached !== undefined ? { limitReached } : {}),\n\t\t...(allowed !== undefined ? { allowed } : {}),\n\t\t...(exhaustedWindow ? { exhaustedWindow } : {}),\n\t\t...(credits ? { credits } : {}),\n\t\t...(rateLimitReachedType !== undefined ? { rateLimitReachedType } : {}),\n\t};\n}\n\nexport function getCodexAvailability(usage: CodexWeeklyUsage): CodexAvailability {\n\tif (usage.availability !== undefined) return usage.availability;\n\tif (usage.allowed === false || usage.limitReached === true || usage.exhaustedWindow === true) return \"blocked\";\n\treturn usage.allowed === true && usage.limitReached === false ? \"allowed\" : \"unknown\";\n}\n\nfunction unavailable(reason: CodexUsageUnavailableReason): CodexUsageResult {\n\treturn { status: \"unavailable\", reason };\n}\n\nfunction isAbortError(error: unknown): boolean {\n\treturn isRecord(error) && (error.name === \"AbortError\" || error.name === \"TimeoutError\");\n}\n\n/** Confirm every reported limit before overriding a cached denial; malformed or omitted availability stays unknown. */\nfunction reportedAvailability(payload: Record<string, unknown>): CodexAvailability {\n\tlet unknown = false;\n\tif (payload.rate_limit_reached_type != null && payload.rate_limit_reached_type !== \"\") {\n\t\tif (\n\t\t\ttypeof payload.rate_limit_reached_type === \"string\" &&\n\t\t\tREACHED_TYPE_PATTERN.test(payload.rate_limit_reached_type)\n\t\t)\n\t\t\treturn \"blocked\";\n\t\tunknown = true;\n\t}\n\tconst limits: unknown[] = [payload.rate_limit];\n\tif (payload.code_review_rate_limit != null) limits.push(payload.code_review_rate_limit);\n\tif (payload.additional_rate_limits != null) {\n\t\tif (!Array.isArray(payload.additional_rate_limits)) unknown = true;\n\t\telse\n\t\t\tfor (const entry of payload.additional_rate_limits)\n\t\t\t\tlimits.push(isRecord(entry) ? entry.rate_limit : undefined);\n\t}\n\tfor (const limit of limits) {\n\t\tif (!isRecord(limit)) {\n\t\t\tunknown = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (limit.allowed === false || limit.limit_reached === true) return \"blocked\";\n\t\tif (limit.allowed !== true || limit.limit_reached !== false) unknown = true;\n\t\tconst windows = [limit.primary_window, limit.secondary_window].filter((window) => window != null);\n\t\tif (windows.length === 0) unknown = true;\n\t\tfor (const window of windows) {\n\t\t\tif (!isRecord(window)) {\n\t\t\t\tunknown = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (\n\t\t\t\ttypeof window.used_percent !== \"number\" ||\n\t\t\t\t!Number.isFinite(window.used_percent) ||\n\t\t\t\twindow.used_percent < 0\n\t\t\t)\n\t\t\t\tunknown = true;\n\t\t\telse if (window.used_percent >= 100) return \"blocked\";\n\t\t\tif (\n\t\t\t\ttypeof window.limit_window_seconds !== \"number\" ||\n\t\t\t\t!Number.isFinite(window.limit_window_seconds) ||\n\t\t\t\twindow.limit_window_seconds <= 0\n\t\t\t)\n\t\t\t\tunknown = true;\n\t\t}\n\t}\n\treturn unknown ? \"unknown\" : \"allowed\";\n}\n\n/** One usage lookup for one pooled account. Never throws; never mutates the credential. */\nexport async function fetchCodexWeeklyUsage(\n\taccount: OAuthAccount,\n\toptions: FetchCodexWeeklyUsageOptions = {},\n): Promise<CodexUsageResult> {\n\tconst now = options.now ?? Date.now();\n\tif (account.credential.expires <= now) return unavailable(\"expired_credential\");\n\tif (options.signal?.aborted) return unavailable(\"timeout\");\n\tconst accountId = resolveOpenAICodexAccountIdentity(account.credential)?.key ?? account.credential.accountId;\n\tif (typeof accountId !== \"string\" || !accountId.trim()) return unavailable(\"malformed\");\n\n\tlet response: Response;\n\ttry {\n\t\tconst fetcher = options.fetch ?? globalThis.fetch;\n\t\tresponse = await fetcher(CODEX_USAGE_URL, {\n\t\t\tmethod: \"GET\",\n\t\t\theaders: {\n\t\t\t\tAuthorization: `Bearer ${account.credential.access}`,\n\t\t\t\t\"chatgpt-account-id\": accountId,\n\t\t\t\tAccept: \"application/json\",\n\t\t\t\t\"User-Agent\": getPiUserAgent(VERSION),\n\t\t\t\toriginator: \"pi\",\n\t\t\t},\n\t\t\t// The usage route must never redirect; refusing keeps the bearer token and account id on this origin.\n\t\t\tredirect: \"error\",\n\t\t\tsignal: options.signal,\n\t\t});\n\t} catch (error) {\n\t\treturn unavailable(options.signal?.aborted || isAbortError(error) ? \"timeout\" : \"network\");\n\t}\n\n\tif (response.status === 401 || response.status === 403) return unavailable(\"unauthorized\");\n\tif (response.status === 429) return unavailable(\"rate_limited\");\n\tif (!response.ok) return unavailable(\"http_error\");\n\n\tlet payload: unknown;\n\ttry {\n\t\tpayload = await response.json();\n\t} catch (error) {\n\t\treturn unavailable(options.signal?.aborted || isAbortError(error) ? \"timeout\" : \"malformed\");\n\t}\n\tif (!isRecord(payload)) return unavailable(\"malformed\");\n\n\tconst usage = parseCodexWeeklyUsage(payload, now);\n\tif (!usage) return unavailable(\"no_weekly_window\");\n\tif (options.accountPool && account.exhaustedUntil !== undefined && getCodexAvailability(usage) === \"allowed\") {\n\t\ttry {\n\t\t\tif (await options.accountPool.clearExhaustion(CODEX_USAGE_PROVIDER_ID, account, { signal: options.signal })) {\n\t\t\t\treturn { status: \"ok\", usage, cooldownCleared: true };\n\t\t\t}\n\t\t} catch {\n\t\t\t// A cancelled or failed pool write must not hide real usage or claim the cached cooldown was cleared.\n\t\t}\n\t}\n\treturn { status: \"ok\", usage };\n}\n\n/** Bounded-concurrency fan-out; one failure never affects other accounts. */\nexport async function fetchCodexWeeklyUsageForAccounts(\n\taccounts: readonly OAuthAccount[],\n\toptions: FetchCodexWeeklyUsageForAccountsOptions = {},\n): Promise<Map<string, CodexUsageResult>> {\n\tconst results = new Map<string, CodexUsageResult>();\n\tlet nextIndex = 0;\n\tconst requestedConcurrency = options.concurrency ?? DEFAULT_CONCURRENCY;\n\tconst concurrency =\n\t\tNumber.isFinite(requestedConcurrency) && requestedConcurrency >= 1\n\t\t\t? Math.min(accounts.length, Math.floor(requestedConcurrency))\n\t\t\t: Math.min(accounts.length, DEFAULT_CONCURRENCY);\n\tconst requestedTimeout = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n\tconst timeoutMs =\n\t\tNumber.isFinite(requestedTimeout) && requestedTimeout >= 0\n\t\t\t? Math.min(MAX_TIMEOUT_MS, Math.floor(requestedTimeout))\n\t\t\t: DEFAULT_TIMEOUT_MS;\n\n\tasync function worker(): Promise<void> {\n\t\twhile (nextIndex < accounts.length) {\n\t\t\tif (options.signal?.aborted) return;\n\t\t\tconst account = accounts[nextIndex++];\n\t\t\tconst timeoutSignal = AbortSignal.timeout(timeoutMs);\n\t\t\tconst signal = options.signal ? AbortSignal.any([options.signal, timeoutSignal]) : timeoutSignal;\n\t\t\tconst result = await fetchCodexWeeklyUsage(account, {\n\t\t\t\taccountPool: options.accountPool,\n\t\t\t\tfetch: options.fetch,\n\t\t\t\tsignal,\n\t\t\t});\n\t\t\tresults.set(account.key, result);\n\t\t\ttry {\n\t\t\t\toptions.onResult?.(account.key, result);\n\t\t\t} catch {\n\t\t\t\t// Consumer callbacks must not interrupt lookups for other accounts.\n\t\t\t}\n\t\t}\n\t}\n\n\tawait Promise.all(Array.from({ length: concurrency }, () => worker()));\n\treturn results;\n}\n"]}
@@ -575,15 +575,7 @@
575
575
  switch (name) {
576
576
  case 'read': {
577
577
  const path = shortenPath(String(args.path || args.file_path || ''));
578
- const offset = args.offset;
579
- const limit = args.limit;
580
- let display = path;
581
- if (offset !== undefined || limit !== undefined) {
582
- const start = offset ?? 1;
583
- const end = limit !== undefined ? start + limit - 1 : '';
584
- display += `:${start}${end ? `-${end}` : ''}`;
585
- }
586
- return `[read: ${display}]`;
578
+ return `[read: ${path}${formatReadLineRange(args.offset, args.limit)}]`;
587
579
  }
588
580
  case 'write':
589
581
  return `[write: ${shortenPath(String(args.path || args.file_path || ''))}]`;
@@ -825,6 +817,23 @@
825
817
  return null;
826
818
  }
827
819
 
820
+ // Mirrors ../tools/render-utils.ts.
821
+ function parseLineNumber(value) {
822
+ if (typeof value === 'string' && value.trim() !== '') value = Number(value);
823
+ return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
824
+ }
825
+
826
+ function formatReadLineRange(offset, limit) {
827
+ if (offset == null && limit == null) return '';
828
+ const start = offset == null ? 1 : parseLineNumber(offset);
829
+ if (start === undefined) return '';
830
+ if (limit == null) return `:${start}`;
831
+ const count = parseLineNumber(limit);
832
+ if (count === undefined) return '';
833
+ const end = start + count - 1;
834
+ return `:${start}${end ? `-${end}` : ''}`;
835
+ }
836
+
828
837
  function getLanguageFromPath(filePath) {
829
838
  const ext = filePath.split('.').pop()?.toLowerCase();
830
839
  const extToLang = {
@@ -965,14 +974,10 @@
965
974
  }
966
975
  case 'read': {
967
976
  const filePath = str(args.file_path ?? args.path);
968
- const offset = args.offset;
969
- const limit = args.limit;
970
-
977
+ const readLineRange = formatReadLineRange(args.offset, args.limit);
971
978
  let pathHtml = filePath === null ? invalidArg : escapeHtml(shortenPath(filePath || ''));
972
- if (filePath !== null && (offset !== undefined || limit !== undefined)) {
973
- const startLine = offset ?? 1;
974
- const endLine = limit !== undefined ? startLine + limit - 1 : '';
975
- pathHtml += `<span class="line-numbers">:${startLine}${endLine ? '-' + endLine : ''}</span>`;
979
+ if (filePath !== null && readLineRange) {
980
+ pathHtml += `<span class="line-numbers">${escapeHtml(readLineRange)}</span>`;
976
981
  }
977
982
 
978
983
  html += `<div class="tool-header"><span class="tool-name">read</span> <span class="tool-path">${pathHtml}</span></div>`;
@@ -70,6 +70,7 @@ declare const ModelDefinitionSchema: Type.TObject<{
70
70
  requiresAssistantAfterToolResult: Type.TOptional<Type.TBoolean>;
71
71
  requiresThinkingAsText: Type.TOptional<Type.TBoolean>;
72
72
  requiresReasoningContentOnAssistantMessages: Type.TOptional<Type.TBoolean>;
73
+ inlineThinkTags: Type.TOptional<Type.TBoolean>;
73
74
  thinkingFormat: Type.TOptional<Type.TUnion<[Type.TLiteral<"openai">, Type.TLiteral<"openrouter">, Type.TLiteral<"deepseek">, Type.TLiteral<"together">, Type.TLiteral<"baseten">, Type.TLiteral<"zai">, Type.TLiteral<"qwen">, Type.TLiteral<"chat-template">, Type.TLiteral<"qwen-chat-template">, Type.TLiteral<"string-thinking">, Type.TLiteral<"ant-ling">]>>;
74
75
  chatTemplateKwargs: Type.TOptional<Type.TRecord<"^.*$", Type.TUnion<[Type.TString, Type.TNumber, Type.TBoolean, Type.TNull, Type.TObject<{
75
76
  $var: Type.TUnion<[Type.TLiteral<"thinking.enabled">, Type.TLiteral<"thinking.effort">, Type.TLiteral<"thinking.budget">]>;
@@ -139,6 +140,7 @@ declare const ModelDefinitionSchema: Type.TObject<{
139
140
  supportsAdditionalTools: Type.TOptional<Type.TBoolean>;
140
141
  supportsToolSearch: Type.TOptional<Type.TBoolean>;
141
142
  supportsExplicitPromptCacheMode: Type.TOptional<Type.TBoolean>;
143
+ supportsMidConvoEffort: Type.TOptional<Type.TBoolean>;
142
144
  supportsMaxOutputTokens: Type.TOptional<Type.TBoolean>;
143
145
  } & {
144
146
  supportsEagerToolInputStreaming: Type.TOptional<Type.TBoolean>;
@@ -174,10 +176,11 @@ declare const ModelDefinitionSchema: Type.TObject<{
174
176
  supportsStrictMode: Type.TOptional<Type.TBoolean>;
175
177
  } & {
176
178
  supportsMidConvoSystemMessages: Type.TOptional<Type.TBoolean>;
177
- }, "sendSessionAffinityHeaders" | "sessionAffinityFormat" | "supportsDeveloperRole" | "supportsLongCacheRetention" | "supportsMidConvoSystemMessages" | "supportsOpenAIGrammarTools" | "supportsStrictMode"> & {
179
+ }, "sendSessionAffinityHeaders" | "sessionAffinityFormat" | "supportsDeveloperRole" | "supportsLongCacheRetention" | "supportsMidConvoEffort" | "supportsMidConvoSystemMessages" | "supportsOpenAIGrammarTools" | "supportsStrictMode"> & {
178
180
  supportsDeveloperRole: Type.TOptional<Type.TBoolean>;
179
181
  supportsMidConvoSystemMessages: Type.TOptional<Type.TBoolean>;
180
182
  sessionAffinityFormat: Type.TOptional<Type.TUnion<[Type.TLiteral<"openai">, Type.TLiteral<"openai-nosession">, Type.TLiteral<"openrouter">]>>;
183
+ supportsMidConvoEffort: Type.TOptional<Type.TBoolean>;
181
184
  supportsLongCacheRetention: Type.TOptional<Type.TBoolean>;
182
185
  supportsStrictMode: Type.TOptional<Type.TBoolean>;
183
186
  supportsOpenAIGrammarTools: Type.TOptional<Type.TBoolean>;
@@ -251,6 +254,7 @@ declare const ModelOverrideSchema: Type.TObject<{
251
254
  requiresAssistantAfterToolResult: Type.TOptional<Type.TBoolean>;
252
255
  requiresThinkingAsText: Type.TOptional<Type.TBoolean>;
253
256
  requiresReasoningContentOnAssistantMessages: Type.TOptional<Type.TBoolean>;
257
+ inlineThinkTags: Type.TOptional<Type.TBoolean>;
254
258
  thinkingFormat: Type.TOptional<Type.TUnion<[Type.TLiteral<"openai">, Type.TLiteral<"openrouter">, Type.TLiteral<"deepseek">, Type.TLiteral<"together">, Type.TLiteral<"baseten">, Type.TLiteral<"zai">, Type.TLiteral<"qwen">, Type.TLiteral<"chat-template">, Type.TLiteral<"qwen-chat-template">, Type.TLiteral<"string-thinking">, Type.TLiteral<"ant-ling">]>>;
255
259
  chatTemplateKwargs: Type.TOptional<Type.TRecord<"^.*$", Type.TUnion<[Type.TString, Type.TNumber, Type.TBoolean, Type.TNull, Type.TObject<{
256
260
  $var: Type.TUnion<[Type.TLiteral<"thinking.enabled">, Type.TLiteral<"thinking.effort">, Type.TLiteral<"thinking.budget">]>;
@@ -320,6 +324,7 @@ declare const ModelOverrideSchema: Type.TObject<{
320
324
  supportsAdditionalTools: Type.TOptional<Type.TBoolean>;
321
325
  supportsToolSearch: Type.TOptional<Type.TBoolean>;
322
326
  supportsExplicitPromptCacheMode: Type.TOptional<Type.TBoolean>;
327
+ supportsMidConvoEffort: Type.TOptional<Type.TBoolean>;
323
328
  supportsMaxOutputTokens: Type.TOptional<Type.TBoolean>;
324
329
  } & {
325
330
  supportsEagerToolInputStreaming: Type.TOptional<Type.TBoolean>;
@@ -355,10 +360,11 @@ declare const ModelOverrideSchema: Type.TObject<{
355
360
  supportsStrictMode: Type.TOptional<Type.TBoolean>;
356
361
  } & {
357
362
  supportsMidConvoSystemMessages: Type.TOptional<Type.TBoolean>;
358
- }, "sendSessionAffinityHeaders" | "sessionAffinityFormat" | "supportsDeveloperRole" | "supportsLongCacheRetention" | "supportsMidConvoSystemMessages" | "supportsOpenAIGrammarTools" | "supportsStrictMode"> & {
363
+ }, "sendSessionAffinityHeaders" | "sessionAffinityFormat" | "supportsDeveloperRole" | "supportsLongCacheRetention" | "supportsMidConvoEffort" | "supportsMidConvoSystemMessages" | "supportsOpenAIGrammarTools" | "supportsStrictMode"> & {
359
364
  supportsDeveloperRole: Type.TOptional<Type.TBoolean>;
360
365
  supportsMidConvoSystemMessages: Type.TOptional<Type.TBoolean>;
361
366
  sessionAffinityFormat: Type.TOptional<Type.TUnion<[Type.TLiteral<"openai">, Type.TLiteral<"openai-nosession">, Type.TLiteral<"openrouter">]>>;
367
+ supportsMidConvoEffort: Type.TOptional<Type.TBoolean>;
362
368
  supportsLongCacheRetention: Type.TOptional<Type.TBoolean>;
363
369
  supportsStrictMode: Type.TOptional<Type.TBoolean>;
364
370
  supportsOpenAIGrammarTools: Type.TOptional<Type.TBoolean>;
@@ -383,6 +389,7 @@ declare const ProviderConfigSchema: Type.TObject<{
383
389
  requiresAssistantAfterToolResult: Type.TOptional<Type.TBoolean>;
384
390
  requiresThinkingAsText: Type.TOptional<Type.TBoolean>;
385
391
  requiresReasoningContentOnAssistantMessages: Type.TOptional<Type.TBoolean>;
392
+ inlineThinkTags: Type.TOptional<Type.TBoolean>;
386
393
  thinkingFormat: Type.TOptional<Type.TUnion<[Type.TLiteral<"openai">, Type.TLiteral<"openrouter">, Type.TLiteral<"deepseek">, Type.TLiteral<"together">, Type.TLiteral<"baseten">, Type.TLiteral<"zai">, Type.TLiteral<"qwen">, Type.TLiteral<"chat-template">, Type.TLiteral<"qwen-chat-template">, Type.TLiteral<"string-thinking">, Type.TLiteral<"ant-ling">]>>;
387
394
  chatTemplateKwargs: Type.TOptional<Type.TRecord<"^.*$", Type.TUnion<[Type.TString, Type.TNumber, Type.TBoolean, Type.TNull, Type.TObject<{
388
395
  $var: Type.TUnion<[Type.TLiteral<"thinking.enabled">, Type.TLiteral<"thinking.effort">, Type.TLiteral<"thinking.budget">]>;
@@ -452,6 +459,7 @@ declare const ProviderConfigSchema: Type.TObject<{
452
459
  supportsAdditionalTools: Type.TOptional<Type.TBoolean>;
453
460
  supportsToolSearch: Type.TOptional<Type.TBoolean>;
454
461
  supportsExplicitPromptCacheMode: Type.TOptional<Type.TBoolean>;
462
+ supportsMidConvoEffort: Type.TOptional<Type.TBoolean>;
455
463
  supportsMaxOutputTokens: Type.TOptional<Type.TBoolean>;
456
464
  } & {
457
465
  supportsEagerToolInputStreaming: Type.TOptional<Type.TBoolean>;
@@ -487,10 +495,11 @@ declare const ProviderConfigSchema: Type.TObject<{
487
495
  supportsStrictMode: Type.TOptional<Type.TBoolean>;
488
496
  } & {
489
497
  supportsMidConvoSystemMessages: Type.TOptional<Type.TBoolean>;
490
- }, "sendSessionAffinityHeaders" | "sessionAffinityFormat" | "supportsDeveloperRole" | "supportsLongCacheRetention" | "supportsMidConvoSystemMessages" | "supportsOpenAIGrammarTools" | "supportsStrictMode"> & {
498
+ }, "sendSessionAffinityHeaders" | "sessionAffinityFormat" | "supportsDeveloperRole" | "supportsLongCacheRetention" | "supportsMidConvoEffort" | "supportsMidConvoSystemMessages" | "supportsOpenAIGrammarTools" | "supportsStrictMode"> & {
491
499
  supportsDeveloperRole: Type.TOptional<Type.TBoolean>;
492
500
  supportsMidConvoSystemMessages: Type.TOptional<Type.TBoolean>;
493
501
  sessionAffinityFormat: Type.TOptional<Type.TUnion<[Type.TLiteral<"openai">, Type.TLiteral<"openai-nosession">, Type.TLiteral<"openrouter">]>>;
502
+ supportsMidConvoEffort: Type.TOptional<Type.TBoolean>;
494
503
  supportsLongCacheRetention: Type.TOptional<Type.TBoolean>;
495
504
  supportsStrictMode: Type.TOptional<Type.TBoolean>;
496
505
  supportsOpenAIGrammarTools: Type.TOptional<Type.TBoolean>;
@@ -567,6 +576,7 @@ declare const ProviderConfigSchema: Type.TObject<{
567
576
  requiresAssistantAfterToolResult: Type.TOptional<Type.TBoolean>;
568
577
  requiresThinkingAsText: Type.TOptional<Type.TBoolean>;
569
578
  requiresReasoningContentOnAssistantMessages: Type.TOptional<Type.TBoolean>;
579
+ inlineThinkTags: Type.TOptional<Type.TBoolean>;
570
580
  thinkingFormat: Type.TOptional<Type.TUnion<[Type.TLiteral<"openai">, Type.TLiteral<"openrouter">, Type.TLiteral<"deepseek">, Type.TLiteral<"together">, Type.TLiteral<"baseten">, Type.TLiteral<"zai">, Type.TLiteral<"qwen">, Type.TLiteral<"chat-template">, Type.TLiteral<"qwen-chat-template">, Type.TLiteral<"string-thinking">, Type.TLiteral<"ant-ling">]>>;
571
581
  chatTemplateKwargs: Type.TOptional<Type.TRecord<"^.*$", Type.TUnion<[Type.TString, Type.TNumber, Type.TBoolean, Type.TNull, Type.TObject<{
572
582
  $var: Type.TUnion<[Type.TLiteral<"thinking.enabled">, Type.TLiteral<"thinking.effort">, Type.TLiteral<"thinking.budget">]>;
@@ -636,6 +646,7 @@ declare const ProviderConfigSchema: Type.TObject<{
636
646
  supportsAdditionalTools: Type.TOptional<Type.TBoolean>;
637
647
  supportsToolSearch: Type.TOptional<Type.TBoolean>;
638
648
  supportsExplicitPromptCacheMode: Type.TOptional<Type.TBoolean>;
649
+ supportsMidConvoEffort: Type.TOptional<Type.TBoolean>;
639
650
  supportsMaxOutputTokens: Type.TOptional<Type.TBoolean>;
640
651
  } & {
641
652
  supportsEagerToolInputStreaming: Type.TOptional<Type.TBoolean>;
@@ -671,10 +682,11 @@ declare const ProviderConfigSchema: Type.TObject<{
671
682
  supportsStrictMode: Type.TOptional<Type.TBoolean>;
672
683
  } & {
673
684
  supportsMidConvoSystemMessages: Type.TOptional<Type.TBoolean>;
674
- }, "sendSessionAffinityHeaders" | "sessionAffinityFormat" | "supportsDeveloperRole" | "supportsLongCacheRetention" | "supportsMidConvoSystemMessages" | "supportsOpenAIGrammarTools" | "supportsStrictMode"> & {
685
+ }, "sendSessionAffinityHeaders" | "sessionAffinityFormat" | "supportsDeveloperRole" | "supportsLongCacheRetention" | "supportsMidConvoEffort" | "supportsMidConvoSystemMessages" | "supportsOpenAIGrammarTools" | "supportsStrictMode"> & {
675
686
  supportsDeveloperRole: Type.TOptional<Type.TBoolean>;
676
687
  supportsMidConvoSystemMessages: Type.TOptional<Type.TBoolean>;
677
688
  sessionAffinityFormat: Type.TOptional<Type.TUnion<[Type.TLiteral<"openai">, Type.TLiteral<"openai-nosession">, Type.TLiteral<"openrouter">]>>;
689
+ supportsMidConvoEffort: Type.TOptional<Type.TBoolean>;
678
690
  supportsLongCacheRetention: Type.TOptional<Type.TBoolean>;
679
691
  supportsStrictMode: Type.TOptional<Type.TBoolean>;
680
692
  supportsOpenAIGrammarTools: Type.TOptional<Type.TBoolean>;
@@ -748,6 +760,7 @@ declare const ProviderConfigSchema: Type.TObject<{
748
760
  requiresAssistantAfterToolResult: Type.TOptional<Type.TBoolean>;
749
761
  requiresThinkingAsText: Type.TOptional<Type.TBoolean>;
750
762
  requiresReasoningContentOnAssistantMessages: Type.TOptional<Type.TBoolean>;
763
+ inlineThinkTags: Type.TOptional<Type.TBoolean>;
751
764
  thinkingFormat: Type.TOptional<Type.TUnion<[Type.TLiteral<"openai">, Type.TLiteral<"openrouter">, Type.TLiteral<"deepseek">, Type.TLiteral<"together">, Type.TLiteral<"baseten">, Type.TLiteral<"zai">, Type.TLiteral<"qwen">, Type.TLiteral<"chat-template">, Type.TLiteral<"qwen-chat-template">, Type.TLiteral<"string-thinking">, Type.TLiteral<"ant-ling">]>>;
752
765
  chatTemplateKwargs: Type.TOptional<Type.TRecord<"^.*$", Type.TUnion<[Type.TString, Type.TNumber, Type.TBoolean, Type.TNull, Type.TObject<{
753
766
  $var: Type.TUnion<[Type.TLiteral<"thinking.enabled">, Type.TLiteral<"thinking.effort">, Type.TLiteral<"thinking.budget">]>;
@@ -817,6 +830,7 @@ declare const ProviderConfigSchema: Type.TObject<{
817
830
  supportsAdditionalTools: Type.TOptional<Type.TBoolean>;
818
831
  supportsToolSearch: Type.TOptional<Type.TBoolean>;
819
832
  supportsExplicitPromptCacheMode: Type.TOptional<Type.TBoolean>;
833
+ supportsMidConvoEffort: Type.TOptional<Type.TBoolean>;
820
834
  supportsMaxOutputTokens: Type.TOptional<Type.TBoolean>;
821
835
  } & {
822
836
  supportsEagerToolInputStreaming: Type.TOptional<Type.TBoolean>;
@@ -852,10 +866,11 @@ declare const ProviderConfigSchema: Type.TObject<{
852
866
  supportsStrictMode: Type.TOptional<Type.TBoolean>;
853
867
  } & {
854
868
  supportsMidConvoSystemMessages: Type.TOptional<Type.TBoolean>;
855
- }, "sendSessionAffinityHeaders" | "sessionAffinityFormat" | "supportsDeveloperRole" | "supportsLongCacheRetention" | "supportsMidConvoSystemMessages" | "supportsOpenAIGrammarTools" | "supportsStrictMode"> & {
869
+ }, "sendSessionAffinityHeaders" | "sessionAffinityFormat" | "supportsDeveloperRole" | "supportsLongCacheRetention" | "supportsMidConvoEffort" | "supportsMidConvoSystemMessages" | "supportsOpenAIGrammarTools" | "supportsStrictMode"> & {
856
870
  supportsDeveloperRole: Type.TOptional<Type.TBoolean>;
857
871
  supportsMidConvoSystemMessages: Type.TOptional<Type.TBoolean>;
858
872
  sessionAffinityFormat: Type.TOptional<Type.TUnion<[Type.TLiteral<"openai">, Type.TLiteral<"openai-nosession">, Type.TLiteral<"openrouter">]>>;
873
+ supportsMidConvoEffort: Type.TOptional<Type.TBoolean>;
859
874
  supportsLongCacheRetention: Type.TOptional<Type.TBoolean>;
860
875
  supportsStrictMode: Type.TOptional<Type.TBoolean>;
861
876
  supportsOpenAIGrammarTools: Type.TOptional<Type.TBoolean>;
@@ -882,6 +897,7 @@ export declare const ModelsConfigSchema: Type.TObject<{
882
897
  requiresAssistantAfterToolResult: Type.TOptional<Type.TBoolean>;
883
898
  requiresThinkingAsText: Type.TOptional<Type.TBoolean>;
884
899
  requiresReasoningContentOnAssistantMessages: Type.TOptional<Type.TBoolean>;
900
+ inlineThinkTags: Type.TOptional<Type.TBoolean>;
885
901
  thinkingFormat: Type.TOptional<Type.TUnion<[Type.TLiteral<"openai">, Type.TLiteral<"openrouter">, Type.TLiteral<"deepseek">, Type.TLiteral<"together">, Type.TLiteral<"baseten">, Type.TLiteral<"zai">, Type.TLiteral<"qwen">, Type.TLiteral<"chat-template">, Type.TLiteral<"qwen-chat-template">, Type.TLiteral<"string-thinking">, Type.TLiteral<"ant-ling">]>>;
886
902
  chatTemplateKwargs: Type.TOptional<Type.TRecord<"^.*$", Type.TUnion<[Type.TString, Type.TNumber, Type.TBoolean, Type.TNull, Type.TObject<{
887
903
  $var: Type.TUnion<[Type.TLiteral<"thinking.enabled">, Type.TLiteral<"thinking.effort">, Type.TLiteral<"thinking.budget">]>;
@@ -951,6 +967,7 @@ export declare const ModelsConfigSchema: Type.TObject<{
951
967
  supportsAdditionalTools: Type.TOptional<Type.TBoolean>;
952
968
  supportsToolSearch: Type.TOptional<Type.TBoolean>;
953
969
  supportsExplicitPromptCacheMode: Type.TOptional<Type.TBoolean>;
970
+ supportsMidConvoEffort: Type.TOptional<Type.TBoolean>;
954
971
  supportsMaxOutputTokens: Type.TOptional<Type.TBoolean>;
955
972
  } & {
956
973
  supportsEagerToolInputStreaming: Type.TOptional<Type.TBoolean>;
@@ -986,10 +1003,11 @@ export declare const ModelsConfigSchema: Type.TObject<{
986
1003
  supportsStrictMode: Type.TOptional<Type.TBoolean>;
987
1004
  } & {
988
1005
  supportsMidConvoSystemMessages: Type.TOptional<Type.TBoolean>;
989
- }, "sendSessionAffinityHeaders" | "sessionAffinityFormat" | "supportsDeveloperRole" | "supportsLongCacheRetention" | "supportsMidConvoSystemMessages" | "supportsOpenAIGrammarTools" | "supportsStrictMode"> & {
1006
+ }, "sendSessionAffinityHeaders" | "sessionAffinityFormat" | "supportsDeveloperRole" | "supportsLongCacheRetention" | "supportsMidConvoEffort" | "supportsMidConvoSystemMessages" | "supportsOpenAIGrammarTools" | "supportsStrictMode"> & {
990
1007
  supportsDeveloperRole: Type.TOptional<Type.TBoolean>;
991
1008
  supportsMidConvoSystemMessages: Type.TOptional<Type.TBoolean>;
992
1009
  sessionAffinityFormat: Type.TOptional<Type.TUnion<[Type.TLiteral<"openai">, Type.TLiteral<"openai-nosession">, Type.TLiteral<"openrouter">]>>;
1010
+ supportsMidConvoEffort: Type.TOptional<Type.TBoolean>;
993
1011
  supportsLongCacheRetention: Type.TOptional<Type.TBoolean>;
994
1012
  supportsStrictMode: Type.TOptional<Type.TBoolean>;
995
1013
  supportsOpenAIGrammarTools: Type.TOptional<Type.TBoolean>;
@@ -1066,6 +1084,7 @@ export declare const ModelsConfigSchema: Type.TObject<{
1066
1084
  requiresAssistantAfterToolResult: Type.TOptional<Type.TBoolean>;
1067
1085
  requiresThinkingAsText: Type.TOptional<Type.TBoolean>;
1068
1086
  requiresReasoningContentOnAssistantMessages: Type.TOptional<Type.TBoolean>;
1087
+ inlineThinkTags: Type.TOptional<Type.TBoolean>;
1069
1088
  thinkingFormat: Type.TOptional<Type.TUnion<[Type.TLiteral<"openai">, Type.TLiteral<"openrouter">, Type.TLiteral<"deepseek">, Type.TLiteral<"together">, Type.TLiteral<"baseten">, Type.TLiteral<"zai">, Type.TLiteral<"qwen">, Type.TLiteral<"chat-template">, Type.TLiteral<"qwen-chat-template">, Type.TLiteral<"string-thinking">, Type.TLiteral<"ant-ling">]>>;
1070
1089
  chatTemplateKwargs: Type.TOptional<Type.TRecord<"^.*$", Type.TUnion<[Type.TString, Type.TNumber, Type.TBoolean, Type.TNull, Type.TObject<{
1071
1090
  $var: Type.TUnion<[Type.TLiteral<"thinking.enabled">, Type.TLiteral<"thinking.effort">, Type.TLiteral<"thinking.budget">]>;
@@ -1135,6 +1154,7 @@ export declare const ModelsConfigSchema: Type.TObject<{
1135
1154
  supportsAdditionalTools: Type.TOptional<Type.TBoolean>;
1136
1155
  supportsToolSearch: Type.TOptional<Type.TBoolean>;
1137
1156
  supportsExplicitPromptCacheMode: Type.TOptional<Type.TBoolean>;
1157
+ supportsMidConvoEffort: Type.TOptional<Type.TBoolean>;
1138
1158
  supportsMaxOutputTokens: Type.TOptional<Type.TBoolean>;
1139
1159
  } & {
1140
1160
  supportsEagerToolInputStreaming: Type.TOptional<Type.TBoolean>;
@@ -1170,10 +1190,11 @@ export declare const ModelsConfigSchema: Type.TObject<{
1170
1190
  supportsStrictMode: Type.TOptional<Type.TBoolean>;
1171
1191
  } & {
1172
1192
  supportsMidConvoSystemMessages: Type.TOptional<Type.TBoolean>;
1173
- }, "sendSessionAffinityHeaders" | "sessionAffinityFormat" | "supportsDeveloperRole" | "supportsLongCacheRetention" | "supportsMidConvoSystemMessages" | "supportsOpenAIGrammarTools" | "supportsStrictMode"> & {
1193
+ }, "sendSessionAffinityHeaders" | "sessionAffinityFormat" | "supportsDeveloperRole" | "supportsLongCacheRetention" | "supportsMidConvoEffort" | "supportsMidConvoSystemMessages" | "supportsOpenAIGrammarTools" | "supportsStrictMode"> & {
1174
1194
  supportsDeveloperRole: Type.TOptional<Type.TBoolean>;
1175
1195
  supportsMidConvoSystemMessages: Type.TOptional<Type.TBoolean>;
1176
1196
  sessionAffinityFormat: Type.TOptional<Type.TUnion<[Type.TLiteral<"openai">, Type.TLiteral<"openai-nosession">, Type.TLiteral<"openrouter">]>>;
1197
+ supportsMidConvoEffort: Type.TOptional<Type.TBoolean>;
1177
1198
  supportsLongCacheRetention: Type.TOptional<Type.TBoolean>;
1178
1199
  supportsStrictMode: Type.TOptional<Type.TBoolean>;
1179
1200
  supportsOpenAIGrammarTools: Type.TOptional<Type.TBoolean>;
@@ -1247,6 +1268,7 @@ export declare const ModelsConfigSchema: Type.TObject<{
1247
1268
  requiresAssistantAfterToolResult: Type.TOptional<Type.TBoolean>;
1248
1269
  requiresThinkingAsText: Type.TOptional<Type.TBoolean>;
1249
1270
  requiresReasoningContentOnAssistantMessages: Type.TOptional<Type.TBoolean>;
1271
+ inlineThinkTags: Type.TOptional<Type.TBoolean>;
1250
1272
  thinkingFormat: Type.TOptional<Type.TUnion<[Type.TLiteral<"openai">, Type.TLiteral<"openrouter">, Type.TLiteral<"deepseek">, Type.TLiteral<"together">, Type.TLiteral<"baseten">, Type.TLiteral<"zai">, Type.TLiteral<"qwen">, Type.TLiteral<"chat-template">, Type.TLiteral<"qwen-chat-template">, Type.TLiteral<"string-thinking">, Type.TLiteral<"ant-ling">]>>;
1251
1273
  chatTemplateKwargs: Type.TOptional<Type.TRecord<"^.*$", Type.TUnion<[Type.TString, Type.TNumber, Type.TBoolean, Type.TNull, Type.TObject<{
1252
1274
  $var: Type.TUnion<[Type.TLiteral<"thinking.enabled">, Type.TLiteral<"thinking.effort">, Type.TLiteral<"thinking.budget">]>;
@@ -1316,6 +1338,7 @@ export declare const ModelsConfigSchema: Type.TObject<{
1316
1338
  supportsAdditionalTools: Type.TOptional<Type.TBoolean>;
1317
1339
  supportsToolSearch: Type.TOptional<Type.TBoolean>;
1318
1340
  supportsExplicitPromptCacheMode: Type.TOptional<Type.TBoolean>;
1341
+ supportsMidConvoEffort: Type.TOptional<Type.TBoolean>;
1319
1342
  supportsMaxOutputTokens: Type.TOptional<Type.TBoolean>;
1320
1343
  } & {
1321
1344
  supportsEagerToolInputStreaming: Type.TOptional<Type.TBoolean>;
@@ -1351,10 +1374,11 @@ export declare const ModelsConfigSchema: Type.TObject<{
1351
1374
  supportsStrictMode: Type.TOptional<Type.TBoolean>;
1352
1375
  } & {
1353
1376
  supportsMidConvoSystemMessages: Type.TOptional<Type.TBoolean>;
1354
- }, "sendSessionAffinityHeaders" | "sessionAffinityFormat" | "supportsDeveloperRole" | "supportsLongCacheRetention" | "supportsMidConvoSystemMessages" | "supportsOpenAIGrammarTools" | "supportsStrictMode"> & {
1377
+ }, "sendSessionAffinityHeaders" | "sessionAffinityFormat" | "supportsDeveloperRole" | "supportsLongCacheRetention" | "supportsMidConvoEffort" | "supportsMidConvoSystemMessages" | "supportsOpenAIGrammarTools" | "supportsStrictMode"> & {
1355
1378
  supportsDeveloperRole: Type.TOptional<Type.TBoolean>;
1356
1379
  supportsMidConvoSystemMessages: Type.TOptional<Type.TBoolean>;
1357
1380
  sessionAffinityFormat: Type.TOptional<Type.TUnion<[Type.TLiteral<"openai">, Type.TLiteral<"openai-nosession">, Type.TLiteral<"openrouter">]>>;
1381
+ supportsMidConvoEffort: Type.TOptional<Type.TBoolean>;
1358
1382
  supportsLongCacheRetention: Type.TOptional<Type.TBoolean>;
1359
1383
  supportsStrictMode: Type.TOptional<Type.TBoolean>;
1360
1384
  supportsOpenAIGrammarTools: Type.TOptional<Type.TBoolean>;
@@ -1373,6 +1397,7 @@ export declare class ModelConfig {
1373
1397
  private readonly error;
1374
1398
  private constructor();
1375
1399
  static load(modelsJsonPath: string | undefined): Promise<ModelConfig>;
1400
+ private static loaded;
1376
1401
  getProvider(providerId: string): ModelsJsonProvider | undefined;
1377
1402
  getProviderIds(): readonly string[];
1378
1403
  getError(): string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"model-config.d.ts","sourceRoot":"","sources":["../../src/core/model-config.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAWxD,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC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