@mastra/server 1.79.0-alpha.10 → 1.79.0-alpha.11

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 (381) hide show
  1. package/dist/{a2a-CHBSYHxu.js → a2a-BqLB3McP.js} +17 -16
  2. package/dist/a2a-BqLB3McP.js.map +1 -0
  3. package/dist/{a2a-B465DD1u.cjs → a2a-Uood_0DN.cjs} +19 -18
  4. package/dist/a2a-Uood_0DN.cjs.map +1 -0
  5. package/dist/agent-builder-CuBD1tpv.cjs +728 -0
  6. package/dist/agent-builder-CuBD1tpv.cjs.map +1 -0
  7. package/dist/agent-builder-VhM8ADW-.js +627 -0
  8. package/dist/agent-builder-VhM8ADW-.js.map +1 -0
  9. package/dist/{agents-X1E7fW3p.js → agents-BHLTMBff.js} +2 -2
  10. package/dist/{agents-X1E7fW3p.js.map → agents-BHLTMBff.js.map} +1 -1
  11. package/dist/agents-BOWEUKyV.cjs +3127 -0
  12. package/dist/agents-BOWEUKyV.cjs.map +1 -0
  13. package/dist/agents-DRQ3ScbX.js +2828 -0
  14. package/dist/agents-DRQ3ScbX.js.map +1 -0
  15. package/dist/{agents-DoNMSCMt.cjs → agents-T-OIM9IK.cjs} +2 -2
  16. package/dist/{agents-DoNMSCMt.cjs.map → agents-T-OIM9IK.cjs.map} +1 -1
  17. package/dist/{api-schema-manifest-DUseI2VG.cjs → api-schema-manifest-A2qfi54Y.cjs} +4 -4
  18. package/dist/{api-schema-manifest-DUseI2VG.cjs.map → api-schema-manifest-A2qfi54Y.cjs.map} +1 -1
  19. package/dist/{api-schema-manifest-CWRIJP-B.js → api-schema-manifest-Dun5VMRT.js} +3 -3
  20. package/dist/{api-schema-manifest-CWRIJP-B.js.map → api-schema-manifest-Dun5VMRT.js.map} +1 -1
  21. package/dist/{background-tasks-CabImVak.cjs → background-tasks-B3VAKTJh.cjs} +3 -3
  22. package/dist/{background-tasks-CabImVak.cjs.map → background-tasks-B3VAKTJh.cjs.map} +1 -1
  23. package/dist/{background-tasks-oBaLtnCn.js → background-tasks-Du2zYOPl.js} +2 -2
  24. package/dist/{background-tasks-oBaLtnCn.js.map → background-tasks-Du2zYOPl.js.map} +1 -1
  25. package/dist/{builder-registry-DOkLe8ES.js → builder-registry-DLdu9bWH.js} +3 -3
  26. package/dist/{builder-registry-DOkLe8ES.js.map → builder-registry-DLdu9bWH.js.map} +1 -1
  27. package/dist/{builder-registry-D0frV8lQ.cjs → builder-registry-DaFAaMTf.cjs} +3 -3
  28. package/dist/{builder-registry-D0frV8lQ.cjs.map → builder-registry-DaFAaMTf.cjs.map} +1 -1
  29. package/dist/{channels-CBIopVWd.cjs → channels-BnVRmnzK.cjs} +6 -3
  30. package/dist/{channels-CBIopVWd.cjs.map → channels-BnVRmnzK.cjs.map} +1 -1
  31. package/dist/{channels-BOxgHvzI.js → channels-Db-4pXVZ.js} +6 -3
  32. package/dist/{channels-BOxgHvzI.js.map → channels-Db-4pXVZ.js.map} +1 -1
  33. package/dist/conversations-8BWryNlF.js +165 -0
  34. package/dist/conversations-8BWryNlF.js.map +1 -0
  35. package/dist/conversations-C5MkQBB8.cjs +194 -0
  36. package/dist/conversations-C5MkQBB8.cjs.map +1 -0
  37. package/dist/{conversations-Bj5TLNqF.cjs → conversations-DasqEDCF.cjs} +3 -3
  38. package/dist/{conversations-Bj5TLNqF.cjs.map → conversations-DasqEDCF.cjs.map} +1 -1
  39. package/dist/{dist-9c3PXXpk.cjs → dist-B-bEVWlJ.cjs} +4733 -1251
  40. package/dist/dist-B-bEVWlJ.cjs.map +1 -0
  41. package/dist/dist-B3kC8Yd0.cjs +3 -0
  42. package/dist/{dist-CQ3FSKT-.cjs → dist-B9ery9Zw.cjs} +38 -35
  43. package/dist/{dist-CQ3FSKT-.cjs.map → dist-B9ery9Zw.cjs.map} +1 -1
  44. package/dist/{dist-BxMmGD3n.js → dist-BBOnrL_A.js} +10 -12
  45. package/dist/{dist-BxMmGD3n.js.map → dist-BBOnrL_A.js.map} +1 -1
  46. package/dist/{dist-DOWsEmo6.js → dist-BIrQLUV9.js} +20 -20
  47. package/dist/{dist-DOWsEmo6.js.map → dist-BIrQLUV9.js.map} +1 -1
  48. package/dist/dist-BM9J-PTK.js +1 -0
  49. package/dist/{dist-DC1Pewf5.cjs → dist-Bo3GdQwf.cjs} +21 -21
  50. package/dist/{dist-DC1Pewf5.cjs.map → dist-Bo3GdQwf.cjs.map} +1 -1
  51. package/dist/{dist-BwYL7Ykb.js → dist-CREG82cy.js} +37 -34
  52. package/dist/{dist-BwYL7Ykb.js.map → dist-CREG82cy.js.map} +1 -1
  53. package/dist/{dist-rDRetJVY.cjs → dist-CeTLA-e5.cjs} +2 -3
  54. package/dist/{dist-rDRetJVY.cjs.map → dist-CeTLA-e5.cjs.map} +1 -1
  55. package/dist/{dist-CBRJax5e.js → dist-DLld1qjf.js} +25 -31
  56. package/dist/{dist-CBRJax5e.js.map → dist-DLld1qjf.js.map} +1 -1
  57. package/dist/{dist-B_bet8uz.js → dist-DjkPkAzV.js} +2 -3
  58. package/dist/{dist-B_bet8uz.js.map → dist-DjkPkAzV.js.map} +1 -1
  59. package/dist/{dist-UKEksCGq.cjs → dist-DsrJXwic.cjs} +11 -13
  60. package/dist/{dist-UKEksCGq.cjs.map → dist-DsrJXwic.cjs.map} +1 -1
  61. package/dist/{dist-DGCnbhNe.js → dist-k77XQGUn.js} +4493 -1043
  62. package/dist/dist-k77XQGUn.js.map +1 -0
  63. package/dist/{dist-3FPW9nVj.cjs → dist-lT2rqyY9.cjs} +26 -32
  64. package/dist/{dist-3FPW9nVj.cjs.map → dist-lT2rqyY9.cjs.map} +1 -1
  65. package/dist/docs/SKILL.md +1 -1
  66. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  67. package/dist/{dynamic-workflows-Rr_6ac1y.js → dynamic-workflows-CTUO0SFu.js} +3 -3
  68. package/dist/{dynamic-workflows-Rr_6ac1y.js.map → dynamic-workflows-CTUO0SFu.js.map} +1 -1
  69. package/dist/{dynamic-workflows-DXlkr-jK.cjs → dynamic-workflows-HwPX3mcf.cjs} +3 -3
  70. package/dist/{dynamic-workflows-DXlkr-jK.cjs.map → dynamic-workflows-HwPX3mcf.cjs.map} +1 -1
  71. package/dist/{editor-builder-BclcHxN6.cjs → editor-builder-BDtiWw0f.cjs} +2 -2
  72. package/dist/{editor-builder-BclcHxN6.cjs.map → editor-builder-BDtiWw0f.cjs.map} +1 -1
  73. package/dist/{editor-builder-D16kc1P6.js → editor-builder-ClFlGXoX.js} +4 -4
  74. package/dist/{editor-builder-D16kc1P6.js.map → editor-builder-ClFlGXoX.js.map} +1 -1
  75. package/dist/{editor-builder-s9WqPJgA.js → editor-builder-DnLCfqnY.js} +2 -2
  76. package/dist/{editor-builder-s9WqPJgA.js.map → editor-builder-DnLCfqnY.js.map} +1 -1
  77. package/dist/{editor-builder-DXHiPX1A.cjs → editor-builder-DtpP1FtW.cjs} +5 -5
  78. package/dist/{editor-builder-DXHiPX1A.cjs.map → editor-builder-DtpP1FtW.cjs.map} +1 -1
  79. package/dist/{helpers-ElhPeCSK.cjs → helpers-CAcEhq38.cjs} +21 -17
  80. package/dist/{helpers-ElhPeCSK.cjs.map → helpers-CAcEhq38.cjs.map} +1 -1
  81. package/dist/{helpers-DLhX1fqc.js → helpers-vrqddDd5.js} +21 -17
  82. package/dist/{helpers-DLhX1fqc.js.map → helpers-vrqddDd5.js.map} +1 -1
  83. package/dist/index.cjs +1 -1
  84. package/dist/logs-CiSw7r0s.cjs +119 -0
  85. package/dist/logs-CiSw7r0s.cjs.map +1 -0
  86. package/dist/logs-CxfPk-iL.js +96 -0
  87. package/dist/logs-CxfPk-iL.js.map +1 -0
  88. package/dist/mcp-BTdLh6E_.js +274 -0
  89. package/dist/mcp-BTdLh6E_.js.map +1 -0
  90. package/dist/mcp-BYqFR5q-.cjs +339 -0
  91. package/dist/mcp-BYqFR5q-.cjs.map +1 -0
  92. package/dist/memory-BHtTSzvJ.js +1739 -0
  93. package/dist/memory-BHtTSzvJ.js.map +1 -0
  94. package/dist/memory-CwwkVDh1.cjs +1906 -0
  95. package/dist/memory-CwwkVDh1.cjs.map +1 -0
  96. package/dist/observability-BBMCMeT-.cjs +502 -0
  97. package/dist/observability-BBMCMeT-.cjs.map +1 -0
  98. package/dist/observability-ZRgRcvoX.js +431 -0
  99. package/dist/observability-ZRgRcvoX.js.map +1 -0
  100. package/dist/{observability-new-endpoints-BU8JYPfh.js → observability-new-endpoints-fjoZzEtk.js} +10 -9
  101. package/dist/{observability-new-endpoints-BU8JYPfh.js.map → observability-new-endpoints-fjoZzEtk.js.map} +1 -1
  102. package/dist/{observability-new-endpoints-AMp9bnMV.cjs → observability-new-endpoints-tG3-odLa.cjs} +11 -10
  103. package/dist/observability-new-endpoints-tG3-odLa.cjs.map +1 -0
  104. package/dist/plans-CiPgWBhO.cjs +68 -0
  105. package/dist/plans-CiPgWBhO.cjs.map +1 -0
  106. package/dist/plans-DCepEY7n.js +57 -0
  107. package/dist/plans-DCepEY7n.js.map +1 -0
  108. package/dist/{probe-image-size-DBGjhUtJ.cjs → probe-image-size-Alv3gwKl.cjs} +194 -184
  109. package/dist/probe-image-size-Alv3gwKl.cjs.map +1 -0
  110. package/dist/{probe-image-size-Dmoxv93t.js → probe-image-size-BdfbUHxx.js} +158 -148
  111. package/dist/probe-image-size-BdfbUHxx.js.map +1 -0
  112. package/dist/responses-4FwMNxoJ.js +628 -0
  113. package/dist/responses-4FwMNxoJ.js.map +1 -0
  114. package/dist/responses-CCRijwDF.cjs +651 -0
  115. package/dist/responses-CCRijwDF.cjs.map +1 -0
  116. package/dist/{responses-CKNdSRkS.cjs → responses-CfcIc53b.cjs} +2 -2
  117. package/dist/{responses-CKNdSRkS.cjs.map → responses-CfcIc53b.cjs.map} +1 -1
  118. package/dist/{rolldown-runtime-Bd6kNlEP.cjs → rolldown-runtime-BwC_XMyb.cjs} +2 -2
  119. package/dist/{rolldown-runtime-maW3aOIk.js → rolldown-runtime-D3Hj5m0v.js} +2 -2
  120. package/dist/{route-builder-BNZs643f.cjs → route-builder-B2Qhhd7C.cjs} +52 -66
  121. package/dist/route-builder-B2Qhhd7C.cjs.map +1 -0
  122. package/dist/{route-builder-BfQYtclb.js → route-builder-CjkWxv4E.js} +51 -65
  123. package/dist/route-builder-CjkWxv4E.js.map +1 -0
  124. package/dist/{routes-Dl6_kWm7.js → routes-CKfXiwRc.js} +5 -3
  125. package/dist/routes-CKfXiwRc.js.map +1 -0
  126. package/dist/{routes-rwufkyUe.js → routes-D1cP2OeF.js} +26 -26
  127. package/dist/{routes-rwufkyUe.js.map → routes-D1cP2OeF.js.map} +1 -1
  128. package/dist/{routes-DPojsNf1.cjs → routes-bxG4x1MV.cjs} +199 -199
  129. package/dist/{routes-DPojsNf1.cjs.map → routes-bxG4x1MV.cjs.map} +1 -1
  130. package/dist/{routes-BULZI-PU.cjs → routes-jXksmX9G.cjs} +5 -3
  131. package/dist/routes-jXksmX9G.cjs.map +1 -0
  132. package/dist/{schedules-Bj-giFbc.cjs → schedules-CTTTCgbk.cjs} +3 -3
  133. package/dist/{schedules-Bj-giFbc.cjs.map → schedules-CTTTCgbk.cjs.map} +1 -1
  134. package/dist/{schedules-BQYgaz66.js → schedules-DXh37n6-.js} +2 -2
  135. package/dist/{schedules-BQYgaz66.js.map → schedules-DXh37n6-.js.map} +1 -1
  136. package/dist/{schema-e0VHpMt0-C0452jOk.cjs → schema-CzbEIyhE-20gGIWkz.cjs} +83 -88
  137. package/dist/schema-CzbEIyhE-20gGIWkz.cjs.map +1 -0
  138. package/dist/{schema-e0VHpMt0-CVP5Hnxy.js → schema-CzbEIyhE-BsMcj9Ws.js} +82 -87
  139. package/dist/schema-CzbEIyhE-BsMcj9Ws.js.map +1 -0
  140. package/dist/scores-D9UgETt_.js +288 -0
  141. package/dist/scores-D9UgETt_.js.map +1 -0
  142. package/dist/scores-DRdtS7NT.cjs +329 -0
  143. package/dist/scores-DRdtS7NT.cjs.map +1 -0
  144. package/dist/server/a2a/store.cjs +1 -1
  145. package/dist/server/auth/index.cjs +2 -2
  146. package/dist/server/auth/index.js +1 -1
  147. package/dist/server/browser-stream/index.cjs +9 -11
  148. package/dist/server/browser-stream/index.cjs.map +1 -1
  149. package/dist/server/browser-stream/index.js +8 -10
  150. package/dist/server/browser-stream/index.js.map +1 -1
  151. package/dist/server/handlers/a2a.cjs +2 -2
  152. package/dist/server/handlers/a2a.js +1 -2
  153. package/dist/server/handlers/agent-builder.cjs +18 -648
  154. package/dist/server/handlers/agent-builder.js +1 -627
  155. package/dist/server/handlers/agent-controller.cjs +5 -5
  156. package/dist/server/handlers/agent-controller.cjs.map +1 -1
  157. package/dist/server/handlers/agent-controller.js +11 -9
  158. package/dist/server/handlers/agent-controller.js.map +1 -1
  159. package/dist/server/handlers/agent-versions.cjs +15 -8
  160. package/dist/server/handlers/agent-versions.cjs.map +1 -1
  161. package/dist/server/handlers/agent-versions.js +14 -7
  162. package/dist/server/handlers/agent-versions.js.map +1 -1
  163. package/dist/server/handlers/agents.cjs +51 -2860
  164. package/dist/server/handlers/agents.js +1 -2806
  165. package/dist/server/handlers/auth.cjs +14 -12
  166. package/dist/server/handlers/auth.cjs.map +1 -1
  167. package/dist/server/handlers/auth.js +20 -16
  168. package/dist/server/handlers/auth.js.map +1 -1
  169. package/dist/server/handlers/author-enrichment.cjs +1 -1
  170. package/dist/server/handlers/authorship.cjs +1 -1
  171. package/dist/server/handlers/authorship.cjs.map +1 -1
  172. package/dist/server/handlers/background-tasks.cjs +2 -2
  173. package/dist/server/handlers/background-tasks.js +1 -2
  174. package/dist/server/handlers/builder-registry.cjs +2 -2
  175. package/dist/server/handlers/builder-registry.js +1 -2
  176. package/dist/server/handlers/channels.cjs +2 -2
  177. package/dist/server/handlers/channels.js +1 -2
  178. package/dist/server/handlers/conversations.cjs +6 -171
  179. package/dist/server/handlers/conversations.js +1 -162
  180. package/dist/server/handlers/datasets.cjs +2 -2
  181. package/dist/server/handlers/datasets.cjs.map +1 -1
  182. package/dist/server/handlers/datasets.js +1 -1
  183. package/dist/server/handlers/dynamic-workflows.cjs +2 -2
  184. package/dist/server/handlers/dynamic-workflows.js +1 -2
  185. package/dist/server/handlers/editor-builder.cjs +2 -2
  186. package/dist/server/handlers/editor-builder.js +1 -2
  187. package/dist/server/handlers/error.cjs +18 -13
  188. package/dist/server/handlers/error.cjs.map +1 -1
  189. package/dist/server/handlers/error.js +17 -12
  190. package/dist/server/handlers/error.js.map +1 -1
  191. package/dist/server/handlers/favorites-enrichment.cjs +2 -2
  192. package/dist/server/handlers/favorites-enrichment.js +1 -1
  193. package/dist/server/handlers/gateway-memory-client.cjs +1 -1
  194. package/dist/server/handlers/logs.cjs +5 -104
  195. package/dist/server/handlers/logs.js +1 -96
  196. package/dist/server/handlers/mcp-client-versions.cjs +15 -8
  197. package/dist/server/handlers/mcp-client-versions.cjs.map +1 -1
  198. package/dist/server/handlers/mcp-client-versions.js +14 -7
  199. package/dist/server/handlers/mcp-client-versions.js.map +1 -1
  200. package/dist/server/handlers/mcp.cjs +12 -289
  201. package/dist/server/handlers/mcp.js +1 -274
  202. package/dist/server/handlers/memory.cjs +29 -1763
  203. package/dist/server/handlers/memory.js +1 -1731
  204. package/dist/server/handlers/observability-list-query-schemas.cjs +1 -1
  205. package/dist/server/handlers/observability-new-endpoints.cjs +2 -2
  206. package/dist/server/handlers/observability-new-endpoints.js +1 -2
  207. package/dist/server/handlers/observability-shared.cjs +2 -2
  208. package/dist/server/handlers/observability-shared.js +1 -1
  209. package/dist/server/handlers/observability-storage-schemas.cjs +1 -1
  210. package/dist/server/handlers/observability.cjs +14 -445
  211. package/dist/server/handlers/observability.js +3 -429
  212. package/dist/server/handlers/plans.cjs +3 -63
  213. package/dist/server/handlers/plans.js +1 -57
  214. package/dist/server/handlers/processor-providers.cjs +2 -2
  215. package/dist/server/handlers/processor-providers.cjs.map +1 -1
  216. package/dist/server/handlers/processor-providers.js +1 -1
  217. package/dist/server/handlers/processors.cjs +13 -15
  218. package/dist/server/handlers/processors.cjs.map +1 -1
  219. package/dist/server/handlers/processors.js +12 -14
  220. package/dist/server/handlers/processors.js.map +1 -1
  221. package/dist/server/handlers/prompt-block-versions.cjs +15 -8
  222. package/dist/server/handlers/prompt-block-versions.cjs.map +1 -1
  223. package/dist/server/handlers/prompt-block-versions.js +14 -7
  224. package/dist/server/handlers/prompt-block-versions.js.map +1 -1
  225. package/dist/server/handlers/responses.adapter.cjs +1 -1
  226. package/dist/server/handlers/responses.adapter.cjs.map +1 -1
  227. package/dist/server/handlers/responses.cjs +5 -632
  228. package/dist/server/handlers/responses.js +1 -624
  229. package/dist/server/handlers/responses.storage.cjs +2 -2
  230. package/dist/server/handlers/schedules-workflows-shim.cjs +1 -1
  231. package/dist/server/handlers/schedules.cjs +2 -2
  232. package/dist/server/handlers/schedules.js +1 -2
  233. package/dist/server/handlers/scorer-versions.cjs +15 -8
  234. package/dist/server/handlers/scorer-versions.cjs.map +1 -1
  235. package/dist/server/handlers/scorer-versions.js +14 -7
  236. package/dist/server/handlers/scorer-versions.js.map +1 -1
  237. package/dist/server/handlers/scores.cjs +8 -299
  238. package/dist/server/handlers/scores.js +1 -288
  239. package/dist/server/handlers/skills-sh-shared.cjs +1 -1
  240. package/dist/server/handlers/stored-agent-favorites.cjs +4 -4
  241. package/dist/server/handlers/stored-agent-favorites.js +3 -3
  242. package/dist/server/handlers/stored-agents.cjs +19 -13
  243. package/dist/server/handlers/stored-agents.cjs.map +1 -1
  244. package/dist/server/handlers/stored-agents.js +18 -12
  245. package/dist/server/handlers/stored-agents.js.map +1 -1
  246. package/dist/server/handlers/stored-mcp-clients.cjs +8 -6
  247. package/dist/server/handlers/stored-mcp-clients.cjs.map +1 -1
  248. package/dist/server/handlers/stored-mcp-clients.js +7 -5
  249. package/dist/server/handlers/stored-mcp-clients.js.map +1 -1
  250. package/dist/server/handlers/stored-prompt-blocks.cjs +3 -3
  251. package/dist/server/handlers/stored-prompt-blocks.js +2 -2
  252. package/dist/server/handlers/stored-scorers.cjs +3 -3
  253. package/dist/server/handlers/stored-scorers.js +2 -2
  254. package/dist/server/handlers/stored-skill-favorites.cjs +4 -4
  255. package/dist/server/handlers/stored-skill-favorites.js +3 -3
  256. package/dist/server/handlers/stored-skills.cjs +6 -5
  257. package/dist/server/handlers/stored-skills.cjs.map +1 -1
  258. package/dist/server/handlers/stored-skills.js +5 -4
  259. package/dist/server/handlers/stored-skills.js.map +1 -1
  260. package/dist/server/handlers/stored-workspaces.cjs +3 -3
  261. package/dist/server/handlers/stored-workspaces.js +2 -2
  262. package/dist/server/handlers/system.cjs +3 -3
  263. package/dist/server/handlers/system.cjs.map +1 -1
  264. package/dist/server/handlers/system.js +2 -2
  265. package/dist/server/handlers/test-utils.cjs +1 -1
  266. package/dist/server/handlers/tool-providers.cjs +2 -2
  267. package/dist/server/handlers/tool-providers.js +1 -1
  268. package/dist/server/handlers/tool-schema-overrides.cjs +1 -1
  269. package/dist/server/handlers/tools.cjs +7 -267
  270. package/dist/server/handlers/tools.js +1 -257
  271. package/dist/server/handlers/utils.cjs +2 -2
  272. package/dist/server/handlers/utils.js +1 -2
  273. package/dist/server/handlers/validate-agent-instructions.cjs +2 -2
  274. package/dist/server/handlers/validate-agent-instructions.js +1 -1
  275. package/dist/server/handlers/validate-avatar.cjs +2 -2
  276. package/dist/server/handlers/validate-avatar.cjs.map +1 -1
  277. package/dist/server/handlers/validate-avatar.js +1 -1
  278. package/dist/server/handlers/validate-avatar.js.map +1 -1
  279. package/dist/server/handlers/vector.cjs +17 -334
  280. package/dist/server/handlers/vector.js +1 -314
  281. package/dist/server/handlers/version-helpers.cjs +1 -1
  282. package/dist/server/handlers/voice.cjs +9 -35
  283. package/dist/server/handlers/voice.js +1 -23
  284. package/dist/server/handlers/workflow-builder.cjs +2 -2
  285. package/dist/server/handlers/workflow-builder.js +1 -2
  286. package/dist/server/handlers/workflows.cjs +30 -1293
  287. package/dist/server/handlers/workflows.js +1 -1257
  288. package/dist/server/handlers/workspace.cjs +27 -1176
  289. package/dist/server/handlers/workspace.js +1 -1146
  290. package/dist/server/handlers.cjs +33 -33
  291. package/dist/server/handlers.js +17 -17
  292. package/dist/server/schemas/index.cjs +6 -6
  293. package/dist/server/schemas/index.js +3 -3
  294. package/dist/server/server-adapter/index.cjs +5 -5
  295. package/dist/server/server-adapter/index.cjs.map +1 -1
  296. package/dist/server/server-adapter/index.js +4 -4
  297. package/dist/server/server-adapter/index.js.map +1 -1
  298. package/dist/tools-CmFSfDMn.js +256 -0
  299. package/dist/tools-CmFSfDMn.js.map +1 -0
  300. package/dist/tools-SPJtxG9N.cjs +291 -0
  301. package/dist/tools-SPJtxG9N.cjs.map +1 -0
  302. package/dist/{utils-DCgeTrq2.cjs → utils-CF76qzZR.cjs} +12 -17
  303. package/dist/{utils-DCgeTrq2.cjs.map → utils-CF76qzZR.cjs.map} +1 -1
  304. package/dist/{utils-DCAUeb6M.js → utils-aoLN3Wfi.js} +11 -16
  305. package/dist/{utils-DCAUeb6M.js.map → utils-aoLN3Wfi.js.map} +1 -1
  306. package/dist/{utils-Du-EpvDs.cjs → utils-dDLIDg8O.cjs} +2 -2
  307. package/dist/{utils-Du-EpvDs.cjs.map → utils-dDLIDg8O.cjs.map} +1 -1
  308. package/dist/vector-BKDD1kwc.cjs +409 -0
  309. package/dist/vector-BKDD1kwc.cjs.map +1 -0
  310. package/dist/vector-TWv4t-4g.js +314 -0
  311. package/dist/vector-TWv4t-4g.js.map +1 -0
  312. package/dist/voice-BnGwlZ75.cjs +70 -0
  313. package/dist/voice-BnGwlZ75.cjs.map +1 -0
  314. package/dist/voice-DjG8tBAD.js +23 -0
  315. package/dist/voice-DjG8tBAD.js.map +1 -0
  316. package/dist/{workflow-builder-Brj3IArM.cjs → workflow-builder-C9-8ZOWF.cjs} +5 -5
  317. package/dist/{workflow-builder-Brj3IArM.cjs.map → workflow-builder-C9-8ZOWF.cjs.map} +1 -1
  318. package/dist/{workflow-builder-DOa1Vx6w.js → workflow-builder-CjlLoQvo.js} +10 -8
  319. package/dist/{workflow-builder-DOa1Vx6w.js.map → workflow-builder-CjlLoQvo.js.map} +1 -1
  320. package/dist/workflows-DjqeJcdJ.cjs +1446 -0
  321. package/dist/workflows-DjqeJcdJ.cjs.map +1 -0
  322. package/dist/workflows-bb-otd2o.js +1273 -0
  323. package/dist/workflows-bb-otd2o.js.map +1 -0
  324. package/dist/workspace-B6kzp-bo.js +1154 -0
  325. package/dist/workspace-B6kzp-bo.js.map +1 -0
  326. package/dist/workspace-COKR1SxH.cjs +1309 -0
  327. package/dist/workspace-COKR1SxH.cjs.map +1 -0
  328. package/package.json +4 -4
  329. package/dist/a2a-B465DD1u.cjs.map +0 -1
  330. package/dist/a2a-CHBSYHxu.js.map +0 -1
  331. package/dist/dist-9c3PXXpk.cjs.map +0 -1
  332. package/dist/dist-B5OwHWTo.cjs +0 -2294
  333. package/dist/dist-B5OwHWTo.cjs.map +0 -1
  334. package/dist/dist-DGCnbhNe.js.map +0 -1
  335. package/dist/dist-DcoIg_tp.js +0 -2293
  336. package/dist/dist-DcoIg_tp.js.map +0 -1
  337. package/dist/observability-new-endpoints-AMp9bnMV.cjs.map +0 -1
  338. package/dist/probe-image-size-DBGjhUtJ.cjs.map +0 -1
  339. package/dist/probe-image-size-Dmoxv93t.js.map +0 -1
  340. package/dist/route-builder-BNZs643f.cjs.map +0 -1
  341. package/dist/route-builder-BfQYtclb.js.map +0 -1
  342. package/dist/routes-BULZI-PU.cjs.map +0 -1
  343. package/dist/routes-Dl6_kWm7.js.map +0 -1
  344. package/dist/schema-Drf2W04o.js +0 -2
  345. package/dist/schema-EQanefYq.cjs +0 -1
  346. package/dist/schema-e0VHpMt0-C0452jOk.cjs.map +0 -1
  347. package/dist/schema-e0VHpMt0-CVP5Hnxy.js.map +0 -1
  348. package/dist/server/handlers/agent-builder.cjs.map +0 -1
  349. package/dist/server/handlers/agent-builder.js.map +0 -1
  350. package/dist/server/handlers/agents.cjs.map +0 -1
  351. package/dist/server/handlers/agents.js.map +0 -1
  352. package/dist/server/handlers/conversations.cjs.map +0 -1
  353. package/dist/server/handlers/conversations.js.map +0 -1
  354. package/dist/server/handlers/logs.cjs.map +0 -1
  355. package/dist/server/handlers/logs.js.map +0 -1
  356. package/dist/server/handlers/mcp.cjs.map +0 -1
  357. package/dist/server/handlers/mcp.js.map +0 -1
  358. package/dist/server/handlers/memory.cjs.map +0 -1
  359. package/dist/server/handlers/memory.js.map +0 -1
  360. package/dist/server/handlers/observability.cjs.map +0 -1
  361. package/dist/server/handlers/observability.js.map +0 -1
  362. package/dist/server/handlers/plans.cjs.map +0 -1
  363. package/dist/server/handlers/plans.js.map +0 -1
  364. package/dist/server/handlers/responses.cjs.map +0 -1
  365. package/dist/server/handlers/responses.js.map +0 -1
  366. package/dist/server/handlers/scores.cjs.map +0 -1
  367. package/dist/server/handlers/scores.js.map +0 -1
  368. package/dist/server/handlers/tools.cjs.map +0 -1
  369. package/dist/server/handlers/tools.js.map +0 -1
  370. package/dist/server/handlers/vector.cjs.map +0 -1
  371. package/dist/server/handlers/vector.js.map +0 -1
  372. package/dist/server/handlers/voice.cjs.map +0 -1
  373. package/dist/server/handlers/voice.js.map +0 -1
  374. package/dist/server/handlers/workflows.cjs.map +0 -1
  375. package/dist/server/handlers/workflows.js.map +0 -1
  376. package/dist/server/handlers/workspace.cjs.map +0 -1
  377. package/dist/server/handlers/workspace.js.map +0 -1
  378. package/dist/sync-Ai_ZDz7U.js +0 -1700
  379. package/dist/sync-Ai_ZDz7U.js.map +0 -1
  380. package/dist/sync-BrO5MtSe.cjs +0 -1729
  381. package/dist/sync-BrO5MtSe.cjs.map +0 -1
@@ -1,2293 +0,0 @@
1
- import { _ as InvalidPromptError, a as createEventSourceResponseHandler, b as TooManyEmbeddingValuesForCallError, c as generateId, d as parseProviderOptions, f as postFormDataToApi, g as APICallError, h as withoutTrailingSlash, i as createBinaryResponseHandler, l as isParsableJson, n as convertBase64ToUint8Array, o as createJsonErrorResponseHandler, p as postJsonToApi, r as convertUint8ArrayToBase64, s as createJsonResponseHandler, t as combineHeaders, u as loadApiKey, v as InvalidResponseDataError, x as UnsupportedFunctionalityError } from "./dist-B_bet8uz.js";
2
- import { z as z$1 } from "zod";
3
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@ai-sdk/openai/1.3.24/9ea9437756f1191484449f4e611ce2befb4ff9a7be92f5dfa8b1970d80a87966/node_modules/@ai-sdk/openai/dist/index.mjs
4
- function convertToOpenAIChatMessages({ prompt, useLegacyFunctionCalling = false, systemMessageMode = "system" }) {
5
- const messages = [];
6
- const warnings = [];
7
- for (const { role, content } of prompt) switch (role) {
8
- case "system":
9
- switch (systemMessageMode) {
10
- case "system":
11
- messages.push({
12
- role: "system",
13
- content
14
- });
15
- break;
16
- case "developer":
17
- messages.push({
18
- role: "developer",
19
- content
20
- });
21
- break;
22
- case "remove":
23
- warnings.push({
24
- type: "other",
25
- message: "system messages are removed for this model"
26
- });
27
- break;
28
- default: throw new Error(`Unsupported system message mode: ${systemMessageMode}`);
29
- }
30
- break;
31
- case "user":
32
- if (content.length === 1 && content[0].type === "text") {
33
- messages.push({
34
- role: "user",
35
- content: content[0].text
36
- });
37
- break;
38
- }
39
- messages.push({
40
- role: "user",
41
- content: content.map((part, index) => {
42
- var _a, _b, _c, _d;
43
- switch (part.type) {
44
- case "text": return {
45
- type: "text",
46
- text: part.text
47
- };
48
- case "image": return {
49
- type: "image_url",
50
- image_url: {
51
- url: part.image instanceof URL ? part.image.toString() : `data:${(_a = part.mimeType) != null ? _a : "image/jpeg"};base64,${convertUint8ArrayToBase64(part.image)}`,
52
- detail: (_c = (_b = part.providerMetadata) == null ? void 0 : _b.openai) == null ? void 0 : _c.imageDetail
53
- }
54
- };
55
- case "file":
56
- if (part.data instanceof URL) throw new UnsupportedFunctionalityError({ functionality: "'File content parts with URL data' functionality not supported." });
57
- switch (part.mimeType) {
58
- case "audio/wav": return {
59
- type: "input_audio",
60
- input_audio: {
61
- data: part.data,
62
- format: "wav"
63
- }
64
- };
65
- case "audio/mp3":
66
- case "audio/mpeg": return {
67
- type: "input_audio",
68
- input_audio: {
69
- data: part.data,
70
- format: "mp3"
71
- }
72
- };
73
- case "application/pdf": return {
74
- type: "file",
75
- file: {
76
- filename: (_d = part.filename) != null ? _d : `part-${index}.pdf`,
77
- file_data: `data:application/pdf;base64,${part.data}`
78
- }
79
- };
80
- default: throw new UnsupportedFunctionalityError({ functionality: `File content part type ${part.mimeType} in user messages` });
81
- }
82
- }
83
- })
84
- });
85
- break;
86
- case "assistant": {
87
- let text = "";
88
- const toolCalls = [];
89
- for (const part of content) switch (part.type) {
90
- case "text":
91
- text += part.text;
92
- break;
93
- case "tool-call":
94
- toolCalls.push({
95
- id: part.toolCallId,
96
- type: "function",
97
- function: {
98
- name: part.toolName,
99
- arguments: JSON.stringify(part.args)
100
- }
101
- });
102
- break;
103
- }
104
- if (useLegacyFunctionCalling) {
105
- if (toolCalls.length > 1) throw new UnsupportedFunctionalityError({ functionality: "useLegacyFunctionCalling with multiple tool calls in one message" });
106
- messages.push({
107
- role: "assistant",
108
- content: text,
109
- function_call: toolCalls.length > 0 ? toolCalls[0].function : void 0
110
- });
111
- } else messages.push({
112
- role: "assistant",
113
- content: text,
114
- tool_calls: toolCalls.length > 0 ? toolCalls : void 0
115
- });
116
- break;
117
- }
118
- case "tool":
119
- for (const toolResponse of content) if (useLegacyFunctionCalling) messages.push({
120
- role: "function",
121
- name: toolResponse.toolName,
122
- content: JSON.stringify(toolResponse.result)
123
- });
124
- else messages.push({
125
- role: "tool",
126
- tool_call_id: toolResponse.toolCallId,
127
- content: JSON.stringify(toolResponse.result)
128
- });
129
- break;
130
- default: throw new Error(`Unsupported role: ${role}`);
131
- }
132
- return {
133
- messages,
134
- warnings
135
- };
136
- }
137
- function mapOpenAIChatLogProbsOutput(logprobs) {
138
- var _a, _b;
139
- return (_b = (_a = logprobs == null ? void 0 : logprobs.content) == null ? void 0 : _a.map(({ token, logprob, top_logprobs }) => ({
140
- token,
141
- logprob,
142
- topLogprobs: top_logprobs ? top_logprobs.map(({ token: token2, logprob: logprob2 }) => ({
143
- token: token2,
144
- logprob: logprob2
145
- })) : []
146
- }))) != null ? _b : void 0;
147
- }
148
- function mapOpenAIFinishReason(finishReason) {
149
- switch (finishReason) {
150
- case "stop": return "stop";
151
- case "length": return "length";
152
- case "content_filter": return "content-filter";
153
- case "function_call":
154
- case "tool_calls": return "tool-calls";
155
- default: return "unknown";
156
- }
157
- }
158
- var openaiErrorDataSchema = z$1.object({ error: z$1.object({
159
- message: z$1.string(),
160
- type: z$1.string().nullish(),
161
- param: z$1.any().nullish(),
162
- code: z$1.union([z$1.string(), z$1.number()]).nullish()
163
- }) });
164
- var openaiFailedResponseHandler = createJsonErrorResponseHandler({
165
- errorSchema: openaiErrorDataSchema,
166
- errorToMessage: (data) => data.error.message
167
- });
168
- function getResponseMetadata({ id, model, created }) {
169
- return {
170
- id: id != null ? id : void 0,
171
- modelId: model != null ? model : void 0,
172
- timestamp: created != null ? /* @__PURE__ */ new Date(created * 1e3) : void 0
173
- };
174
- }
175
- function prepareTools({ mode, useLegacyFunctionCalling = false, structuredOutputs }) {
176
- var _a;
177
- const tools = ((_a = mode.tools) == null ? void 0 : _a.length) ? mode.tools : void 0;
178
- const toolWarnings = [];
179
- if (tools == null) return {
180
- tools: void 0,
181
- tool_choice: void 0,
182
- toolWarnings
183
- };
184
- const toolChoice = mode.toolChoice;
185
- if (useLegacyFunctionCalling) {
186
- const openaiFunctions = [];
187
- for (const tool of tools) if (tool.type === "provider-defined") toolWarnings.push({
188
- type: "unsupported-tool",
189
- tool
190
- });
191
- else openaiFunctions.push({
192
- name: tool.name,
193
- description: tool.description,
194
- parameters: tool.parameters
195
- });
196
- if (toolChoice == null) return {
197
- functions: openaiFunctions,
198
- function_call: void 0,
199
- toolWarnings
200
- };
201
- switch (toolChoice.type) {
202
- case "auto":
203
- case "none":
204
- case void 0: return {
205
- functions: openaiFunctions,
206
- function_call: void 0,
207
- toolWarnings
208
- };
209
- case "required": throw new UnsupportedFunctionalityError({ functionality: "useLegacyFunctionCalling and toolChoice: required" });
210
- default: return {
211
- functions: openaiFunctions,
212
- function_call: { name: toolChoice.toolName },
213
- toolWarnings
214
- };
215
- }
216
- }
217
- const openaiTools2 = [];
218
- for (const tool of tools) if (tool.type === "provider-defined") toolWarnings.push({
219
- type: "unsupported-tool",
220
- tool
221
- });
222
- else openaiTools2.push({
223
- type: "function",
224
- function: {
225
- name: tool.name,
226
- description: tool.description,
227
- parameters: tool.parameters,
228
- strict: structuredOutputs ? true : void 0
229
- }
230
- });
231
- if (toolChoice == null) return {
232
- tools: openaiTools2,
233
- tool_choice: void 0,
234
- toolWarnings
235
- };
236
- const type = toolChoice.type;
237
- switch (type) {
238
- case "auto":
239
- case "none":
240
- case "required": return {
241
- tools: openaiTools2,
242
- tool_choice: type,
243
- toolWarnings
244
- };
245
- case "tool": return {
246
- tools: openaiTools2,
247
- tool_choice: {
248
- type: "function",
249
- function: { name: toolChoice.toolName }
250
- },
251
- toolWarnings
252
- };
253
- default: throw new UnsupportedFunctionalityError({ functionality: `Unsupported tool choice type: ${type}` });
254
- }
255
- }
256
- var OpenAIChatLanguageModel = class {
257
- constructor(modelId, settings, config) {
258
- this.specificationVersion = "v1";
259
- this.modelId = modelId;
260
- this.settings = settings;
261
- this.config = config;
262
- }
263
- get supportsStructuredOutputs() {
264
- var _a;
265
- return (_a = this.settings.structuredOutputs) != null ? _a : isReasoningModel(this.modelId);
266
- }
267
- get defaultObjectGenerationMode() {
268
- if (isAudioModel(this.modelId)) return "tool";
269
- return this.supportsStructuredOutputs ? "json" : "tool";
270
- }
271
- get provider() {
272
- return this.config.provider;
273
- }
274
- get supportsImageUrls() {
275
- return !this.settings.downloadImages;
276
- }
277
- getArgs({ mode, prompt, maxTokens, temperature, topP, topK, frequencyPenalty, presencePenalty, stopSequences, responseFormat, seed, providerMetadata }) {
278
- var _a, _b, _c, _d, _e, _f, _g, _h;
279
- const type = mode.type;
280
- const warnings = [];
281
- if (topK != null) warnings.push({
282
- type: "unsupported-setting",
283
- setting: "topK"
284
- });
285
- if ((responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !this.supportsStructuredOutputs) warnings.push({
286
- type: "unsupported-setting",
287
- setting: "responseFormat",
288
- details: "JSON response format schema is only supported with structuredOutputs"
289
- });
290
- const useLegacyFunctionCalling = this.settings.useLegacyFunctionCalling;
291
- if (useLegacyFunctionCalling && this.settings.parallelToolCalls === true) throw new UnsupportedFunctionalityError({ functionality: "useLegacyFunctionCalling with parallelToolCalls" });
292
- if (useLegacyFunctionCalling && this.supportsStructuredOutputs) throw new UnsupportedFunctionalityError({ functionality: "structuredOutputs with useLegacyFunctionCalling" });
293
- const { messages, warnings: messageWarnings } = convertToOpenAIChatMessages({
294
- prompt,
295
- useLegacyFunctionCalling,
296
- systemMessageMode: getSystemMessageMode(this.modelId)
297
- });
298
- warnings.push(...messageWarnings);
299
- const baseArgs = {
300
- model: this.modelId,
301
- logit_bias: this.settings.logitBias,
302
- logprobs: this.settings.logprobs === true || typeof this.settings.logprobs === "number" ? true : void 0,
303
- top_logprobs: typeof this.settings.logprobs === "number" ? this.settings.logprobs : typeof this.settings.logprobs === "boolean" ? this.settings.logprobs ? 0 : void 0 : void 0,
304
- user: this.settings.user,
305
- parallel_tool_calls: this.settings.parallelToolCalls,
306
- max_tokens: maxTokens,
307
- temperature,
308
- top_p: topP,
309
- frequency_penalty: frequencyPenalty,
310
- presence_penalty: presencePenalty,
311
- response_format: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? this.supportsStructuredOutputs && responseFormat.schema != null ? {
312
- type: "json_schema",
313
- json_schema: {
314
- schema: responseFormat.schema,
315
- strict: true,
316
- name: (_a = responseFormat.name) != null ? _a : "response",
317
- description: responseFormat.description
318
- }
319
- } : { type: "json_object" } : void 0,
320
- stop: stopSequences,
321
- seed,
322
- max_completion_tokens: (_b = providerMetadata == null ? void 0 : providerMetadata.openai) == null ? void 0 : _b.maxCompletionTokens,
323
- store: (_c = providerMetadata == null ? void 0 : providerMetadata.openai) == null ? void 0 : _c.store,
324
- metadata: (_d = providerMetadata == null ? void 0 : providerMetadata.openai) == null ? void 0 : _d.metadata,
325
- prediction: (_e = providerMetadata == null ? void 0 : providerMetadata.openai) == null ? void 0 : _e.prediction,
326
- reasoning_effort: (_g = (_f = providerMetadata == null ? void 0 : providerMetadata.openai) == null ? void 0 : _f.reasoningEffort) != null ? _g : this.settings.reasoningEffort,
327
- messages
328
- };
329
- if (isReasoningModel(this.modelId)) {
330
- if (baseArgs.temperature != null) {
331
- baseArgs.temperature = void 0;
332
- warnings.push({
333
- type: "unsupported-setting",
334
- setting: "temperature",
335
- details: "temperature is not supported for reasoning models"
336
- });
337
- }
338
- if (baseArgs.top_p != null) {
339
- baseArgs.top_p = void 0;
340
- warnings.push({
341
- type: "unsupported-setting",
342
- setting: "topP",
343
- details: "topP is not supported for reasoning models"
344
- });
345
- }
346
- if (baseArgs.frequency_penalty != null) {
347
- baseArgs.frequency_penalty = void 0;
348
- warnings.push({
349
- type: "unsupported-setting",
350
- setting: "frequencyPenalty",
351
- details: "frequencyPenalty is not supported for reasoning models"
352
- });
353
- }
354
- if (baseArgs.presence_penalty != null) {
355
- baseArgs.presence_penalty = void 0;
356
- warnings.push({
357
- type: "unsupported-setting",
358
- setting: "presencePenalty",
359
- details: "presencePenalty is not supported for reasoning models"
360
- });
361
- }
362
- if (baseArgs.logit_bias != null) {
363
- baseArgs.logit_bias = void 0;
364
- warnings.push({
365
- type: "other",
366
- message: "logitBias is not supported for reasoning models"
367
- });
368
- }
369
- if (baseArgs.logprobs != null) {
370
- baseArgs.logprobs = void 0;
371
- warnings.push({
372
- type: "other",
373
- message: "logprobs is not supported for reasoning models"
374
- });
375
- }
376
- if (baseArgs.top_logprobs != null) {
377
- baseArgs.top_logprobs = void 0;
378
- warnings.push({
379
- type: "other",
380
- message: "topLogprobs is not supported for reasoning models"
381
- });
382
- }
383
- if (baseArgs.max_tokens != null) {
384
- if (baseArgs.max_completion_tokens == null) baseArgs.max_completion_tokens = baseArgs.max_tokens;
385
- baseArgs.max_tokens = void 0;
386
- }
387
- } else if (this.modelId.startsWith("gpt-4o-search-preview") || this.modelId.startsWith("gpt-4o-mini-search-preview")) {
388
- if (baseArgs.temperature != null) {
389
- baseArgs.temperature = void 0;
390
- warnings.push({
391
- type: "unsupported-setting",
392
- setting: "temperature",
393
- details: "temperature is not supported for the search preview models and has been removed."
394
- });
395
- }
396
- }
397
- switch (type) {
398
- case "regular": {
399
- const { tools, tool_choice, functions, function_call, toolWarnings } = prepareTools({
400
- mode,
401
- useLegacyFunctionCalling,
402
- structuredOutputs: this.supportsStructuredOutputs
403
- });
404
- return {
405
- args: {
406
- ...baseArgs,
407
- tools,
408
- tool_choice,
409
- functions,
410
- function_call
411
- },
412
- warnings: [...warnings, ...toolWarnings]
413
- };
414
- }
415
- case "object-json": return {
416
- args: {
417
- ...baseArgs,
418
- response_format: this.supportsStructuredOutputs && mode.schema != null ? {
419
- type: "json_schema",
420
- json_schema: {
421
- schema: mode.schema,
422
- strict: true,
423
- name: (_h = mode.name) != null ? _h : "response",
424
- description: mode.description
425
- }
426
- } : { type: "json_object" }
427
- },
428
- warnings
429
- };
430
- case "object-tool": return {
431
- args: useLegacyFunctionCalling ? {
432
- ...baseArgs,
433
- function_call: { name: mode.tool.name },
434
- functions: [{
435
- name: mode.tool.name,
436
- description: mode.tool.description,
437
- parameters: mode.tool.parameters
438
- }]
439
- } : {
440
- ...baseArgs,
441
- tool_choice: {
442
- type: "function",
443
- function: { name: mode.tool.name }
444
- },
445
- tools: [{
446
- type: "function",
447
- function: {
448
- name: mode.tool.name,
449
- description: mode.tool.description,
450
- parameters: mode.tool.parameters,
451
- strict: this.supportsStructuredOutputs ? true : void 0
452
- }
453
- }]
454
- },
455
- warnings
456
- };
457
- default: throw new Error(`Unsupported type: ${type}`);
458
- }
459
- }
460
- async doGenerate(options) {
461
- var _a, _b, _c, _d, _e, _f, _g, _h;
462
- const { args: body, warnings } = this.getArgs(options);
463
- const { responseHeaders, value: response, rawValue: rawResponse } = await postJsonToApi({
464
- url: this.config.url({
465
- path: "/chat/completions",
466
- modelId: this.modelId
467
- }),
468
- headers: combineHeaders(this.config.headers(), options.headers),
469
- body,
470
- failedResponseHandler: openaiFailedResponseHandler,
471
- successfulResponseHandler: createJsonResponseHandler(openaiChatResponseSchema),
472
- abortSignal: options.abortSignal,
473
- fetch: this.config.fetch
474
- });
475
- const { messages: rawPrompt, ...rawSettings } = body;
476
- const choice = response.choices[0];
477
- const completionTokenDetails = (_a = response.usage) == null ? void 0 : _a.completion_tokens_details;
478
- const promptTokenDetails = (_b = response.usage) == null ? void 0 : _b.prompt_tokens_details;
479
- const providerMetadata = { openai: {} };
480
- if ((completionTokenDetails == null ? void 0 : completionTokenDetails.reasoning_tokens) != null) providerMetadata.openai.reasoningTokens = completionTokenDetails == null ? void 0 : completionTokenDetails.reasoning_tokens;
481
- if ((completionTokenDetails == null ? void 0 : completionTokenDetails.accepted_prediction_tokens) != null) providerMetadata.openai.acceptedPredictionTokens = completionTokenDetails == null ? void 0 : completionTokenDetails.accepted_prediction_tokens;
482
- if ((completionTokenDetails == null ? void 0 : completionTokenDetails.rejected_prediction_tokens) != null) providerMetadata.openai.rejectedPredictionTokens = completionTokenDetails == null ? void 0 : completionTokenDetails.rejected_prediction_tokens;
483
- if ((promptTokenDetails == null ? void 0 : promptTokenDetails.cached_tokens) != null) providerMetadata.openai.cachedPromptTokens = promptTokenDetails == null ? void 0 : promptTokenDetails.cached_tokens;
484
- return {
485
- text: (_c = choice.message.content) != null ? _c : void 0,
486
- toolCalls: this.settings.useLegacyFunctionCalling && choice.message.function_call ? [{
487
- toolCallType: "function",
488
- toolCallId: generateId(),
489
- toolName: choice.message.function_call.name,
490
- args: choice.message.function_call.arguments
491
- }] : (_d = choice.message.tool_calls) == null ? void 0 : _d.map((toolCall) => {
492
- var _a2;
493
- return {
494
- toolCallType: "function",
495
- toolCallId: (_a2 = toolCall.id) != null ? _a2 : generateId(),
496
- toolName: toolCall.function.name,
497
- args: toolCall.function.arguments
498
- };
499
- }),
500
- finishReason: mapOpenAIFinishReason(choice.finish_reason),
501
- usage: {
502
- promptTokens: (_f = (_e = response.usage) == null ? void 0 : _e.prompt_tokens) != null ? _f : NaN,
503
- completionTokens: (_h = (_g = response.usage) == null ? void 0 : _g.completion_tokens) != null ? _h : NaN
504
- },
505
- rawCall: {
506
- rawPrompt,
507
- rawSettings
508
- },
509
- rawResponse: {
510
- headers: responseHeaders,
511
- body: rawResponse
512
- },
513
- request: { body: JSON.stringify(body) },
514
- response: getResponseMetadata(response),
515
- warnings,
516
- logprobs: mapOpenAIChatLogProbsOutput(choice.logprobs),
517
- providerMetadata
518
- };
519
- }
520
- async doStream(options) {
521
- if (this.settings.simulateStreaming) {
522
- const result = await this.doGenerate(options);
523
- return {
524
- stream: new ReadableStream({ start(controller) {
525
- controller.enqueue({
526
- type: "response-metadata",
527
- ...result.response
528
- });
529
- if (result.text) controller.enqueue({
530
- type: "text-delta",
531
- textDelta: result.text
532
- });
533
- if (result.toolCalls) for (const toolCall of result.toolCalls) {
534
- controller.enqueue({
535
- type: "tool-call-delta",
536
- toolCallType: "function",
537
- toolCallId: toolCall.toolCallId,
538
- toolName: toolCall.toolName,
539
- argsTextDelta: toolCall.args
540
- });
541
- controller.enqueue({
542
- type: "tool-call",
543
- ...toolCall
544
- });
545
- }
546
- controller.enqueue({
547
- type: "finish",
548
- finishReason: result.finishReason,
549
- usage: result.usage,
550
- logprobs: result.logprobs,
551
- providerMetadata: result.providerMetadata
552
- });
553
- controller.close();
554
- } }),
555
- rawCall: result.rawCall,
556
- rawResponse: result.rawResponse,
557
- warnings: result.warnings
558
- };
559
- }
560
- const { args, warnings } = this.getArgs(options);
561
- const body = {
562
- ...args,
563
- stream: true,
564
- stream_options: this.config.compatibility === "strict" ? { include_usage: true } : void 0
565
- };
566
- const { responseHeaders, value: response } = await postJsonToApi({
567
- url: this.config.url({
568
- path: "/chat/completions",
569
- modelId: this.modelId
570
- }),
571
- headers: combineHeaders(this.config.headers(), options.headers),
572
- body,
573
- failedResponseHandler: openaiFailedResponseHandler,
574
- successfulResponseHandler: createEventSourceResponseHandler(openaiChatChunkSchema),
575
- abortSignal: options.abortSignal,
576
- fetch: this.config.fetch
577
- });
578
- const { messages: rawPrompt, ...rawSettings } = args;
579
- const toolCalls = [];
580
- let finishReason = "unknown";
581
- let usage = {
582
- promptTokens: void 0,
583
- completionTokens: void 0
584
- };
585
- let logprobs;
586
- let isFirstChunk = true;
587
- const { useLegacyFunctionCalling } = this.settings;
588
- const providerMetadata = { openai: {} };
589
- return {
590
- stream: response.pipeThrough(new TransformStream({
591
- transform(chunk, controller) {
592
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
593
- if (!chunk.success) {
594
- finishReason = "error";
595
- controller.enqueue({
596
- type: "error",
597
- error: chunk.error
598
- });
599
- return;
600
- }
601
- const value = chunk.value;
602
- if ("error" in value) {
603
- finishReason = "error";
604
- controller.enqueue({
605
- type: "error",
606
- error: value.error
607
- });
608
- return;
609
- }
610
- if (isFirstChunk) {
611
- isFirstChunk = false;
612
- controller.enqueue({
613
- type: "response-metadata",
614
- ...getResponseMetadata(value)
615
- });
616
- }
617
- if (value.usage != null) {
618
- const { prompt_tokens, completion_tokens, prompt_tokens_details, completion_tokens_details } = value.usage;
619
- usage = {
620
- promptTokens: prompt_tokens != null ? prompt_tokens : void 0,
621
- completionTokens: completion_tokens != null ? completion_tokens : void 0
622
- };
623
- if ((completion_tokens_details == null ? void 0 : completion_tokens_details.reasoning_tokens) != null) providerMetadata.openai.reasoningTokens = completion_tokens_details == null ? void 0 : completion_tokens_details.reasoning_tokens;
624
- if ((completion_tokens_details == null ? void 0 : completion_tokens_details.accepted_prediction_tokens) != null) providerMetadata.openai.acceptedPredictionTokens = completion_tokens_details == null ? void 0 : completion_tokens_details.accepted_prediction_tokens;
625
- if ((completion_tokens_details == null ? void 0 : completion_tokens_details.rejected_prediction_tokens) != null) providerMetadata.openai.rejectedPredictionTokens = completion_tokens_details == null ? void 0 : completion_tokens_details.rejected_prediction_tokens;
626
- if ((prompt_tokens_details == null ? void 0 : prompt_tokens_details.cached_tokens) != null) providerMetadata.openai.cachedPromptTokens = prompt_tokens_details == null ? void 0 : prompt_tokens_details.cached_tokens;
627
- }
628
- const choice = value.choices[0];
629
- if ((choice == null ? void 0 : choice.finish_reason) != null) finishReason = mapOpenAIFinishReason(choice.finish_reason);
630
- if ((choice == null ? void 0 : choice.delta) == null) return;
631
- const delta = choice.delta;
632
- if (delta.content != null) controller.enqueue({
633
- type: "text-delta",
634
- textDelta: delta.content
635
- });
636
- const mappedLogprobs = mapOpenAIChatLogProbsOutput(choice == null ? void 0 : choice.logprobs);
637
- if (mappedLogprobs == null ? void 0 : mappedLogprobs.length) {
638
- if (logprobs === void 0) logprobs = [];
639
- logprobs.push(...mappedLogprobs);
640
- }
641
- const mappedToolCalls = useLegacyFunctionCalling && delta.function_call != null ? [{
642
- type: "function",
643
- id: generateId(),
644
- function: delta.function_call,
645
- index: 0
646
- }] : delta.tool_calls;
647
- if (mappedToolCalls != null) for (const toolCallDelta of mappedToolCalls) {
648
- const index = toolCallDelta.index;
649
- if (toolCalls[index] == null) {
650
- if (toolCallDelta.type !== "function") throw new InvalidResponseDataError({
651
- data: toolCallDelta,
652
- message: `Expected 'function' type.`
653
- });
654
- if (toolCallDelta.id == null) throw new InvalidResponseDataError({
655
- data: toolCallDelta,
656
- message: `Expected 'id' to be a string.`
657
- });
658
- if (((_a = toolCallDelta.function) == null ? void 0 : _a.name) == null) throw new InvalidResponseDataError({
659
- data: toolCallDelta,
660
- message: `Expected 'function.name' to be a string.`
661
- });
662
- toolCalls[index] = {
663
- id: toolCallDelta.id,
664
- type: "function",
665
- function: {
666
- name: toolCallDelta.function.name,
667
- arguments: (_b = toolCallDelta.function.arguments) != null ? _b : ""
668
- },
669
- hasFinished: false
670
- };
671
- const toolCall2 = toolCalls[index];
672
- if (((_c = toolCall2.function) == null ? void 0 : _c.name) != null && ((_d = toolCall2.function) == null ? void 0 : _d.arguments) != null) {
673
- if (toolCall2.function.arguments.length > 0) controller.enqueue({
674
- type: "tool-call-delta",
675
- toolCallType: "function",
676
- toolCallId: toolCall2.id,
677
- toolName: toolCall2.function.name,
678
- argsTextDelta: toolCall2.function.arguments
679
- });
680
- if (isParsableJson(toolCall2.function.arguments)) {
681
- controller.enqueue({
682
- type: "tool-call",
683
- toolCallType: "function",
684
- toolCallId: (_e = toolCall2.id) != null ? _e : generateId(),
685
- toolName: toolCall2.function.name,
686
- args: toolCall2.function.arguments
687
- });
688
- toolCall2.hasFinished = true;
689
- }
690
- }
691
- continue;
692
- }
693
- const toolCall = toolCalls[index];
694
- if (toolCall.hasFinished) continue;
695
- if (((_f = toolCallDelta.function) == null ? void 0 : _f.arguments) != null) toolCall.function.arguments += (_h = (_g = toolCallDelta.function) == null ? void 0 : _g.arguments) != null ? _h : "";
696
- controller.enqueue({
697
- type: "tool-call-delta",
698
- toolCallType: "function",
699
- toolCallId: toolCall.id,
700
- toolName: toolCall.function.name,
701
- argsTextDelta: (_i = toolCallDelta.function.arguments) != null ? _i : ""
702
- });
703
- if (((_j = toolCall.function) == null ? void 0 : _j.name) != null && ((_k = toolCall.function) == null ? void 0 : _k.arguments) != null && isParsableJson(toolCall.function.arguments)) {
704
- controller.enqueue({
705
- type: "tool-call",
706
- toolCallType: "function",
707
- toolCallId: (_l = toolCall.id) != null ? _l : generateId(),
708
- toolName: toolCall.function.name,
709
- args: toolCall.function.arguments
710
- });
711
- toolCall.hasFinished = true;
712
- }
713
- }
714
- },
715
- flush(controller) {
716
- var _a, _b;
717
- controller.enqueue({
718
- type: "finish",
719
- finishReason,
720
- logprobs,
721
- usage: {
722
- promptTokens: (_a = usage.promptTokens) != null ? _a : NaN,
723
- completionTokens: (_b = usage.completionTokens) != null ? _b : NaN
724
- },
725
- ...providerMetadata != null ? { providerMetadata } : {}
726
- });
727
- }
728
- })),
729
- rawCall: {
730
- rawPrompt,
731
- rawSettings
732
- },
733
- rawResponse: { headers: responseHeaders },
734
- request: { body: JSON.stringify(body) },
735
- warnings
736
- };
737
- }
738
- };
739
- var openaiTokenUsageSchema = z$1.object({
740
- prompt_tokens: z$1.number().nullish(),
741
- completion_tokens: z$1.number().nullish(),
742
- prompt_tokens_details: z$1.object({ cached_tokens: z$1.number().nullish() }).nullish(),
743
- completion_tokens_details: z$1.object({
744
- reasoning_tokens: z$1.number().nullish(),
745
- accepted_prediction_tokens: z$1.number().nullish(),
746
- rejected_prediction_tokens: z$1.number().nullish()
747
- }).nullish()
748
- }).nullish();
749
- var openaiChatResponseSchema = z$1.object({
750
- id: z$1.string().nullish(),
751
- created: z$1.number().nullish(),
752
- model: z$1.string().nullish(),
753
- choices: z$1.array(z$1.object({
754
- message: z$1.object({
755
- role: z$1.literal("assistant").nullish(),
756
- content: z$1.string().nullish(),
757
- function_call: z$1.object({
758
- arguments: z$1.string(),
759
- name: z$1.string()
760
- }).nullish(),
761
- tool_calls: z$1.array(z$1.object({
762
- id: z$1.string().nullish(),
763
- type: z$1.literal("function"),
764
- function: z$1.object({
765
- name: z$1.string(),
766
- arguments: z$1.string()
767
- })
768
- })).nullish()
769
- }),
770
- index: z$1.number(),
771
- logprobs: z$1.object({ content: z$1.array(z$1.object({
772
- token: z$1.string(),
773
- logprob: z$1.number(),
774
- top_logprobs: z$1.array(z$1.object({
775
- token: z$1.string(),
776
- logprob: z$1.number()
777
- }))
778
- })).nullable() }).nullish(),
779
- finish_reason: z$1.string().nullish()
780
- })),
781
- usage: openaiTokenUsageSchema
782
- });
783
- var openaiChatChunkSchema = z$1.union([z$1.object({
784
- id: z$1.string().nullish(),
785
- created: z$1.number().nullish(),
786
- model: z$1.string().nullish(),
787
- choices: z$1.array(z$1.object({
788
- delta: z$1.object({
789
- role: z$1.enum(["assistant"]).nullish(),
790
- content: z$1.string().nullish(),
791
- function_call: z$1.object({
792
- name: z$1.string().optional(),
793
- arguments: z$1.string().optional()
794
- }).nullish(),
795
- tool_calls: z$1.array(z$1.object({
796
- index: z$1.number(),
797
- id: z$1.string().nullish(),
798
- type: z$1.literal("function").nullish(),
799
- function: z$1.object({
800
- name: z$1.string().nullish(),
801
- arguments: z$1.string().nullish()
802
- })
803
- })).nullish()
804
- }).nullish(),
805
- logprobs: z$1.object({ content: z$1.array(z$1.object({
806
- token: z$1.string(),
807
- logprob: z$1.number(),
808
- top_logprobs: z$1.array(z$1.object({
809
- token: z$1.string(),
810
- logprob: z$1.number()
811
- }))
812
- })).nullable() }).nullish(),
813
- finish_reason: z$1.string().nullish(),
814
- index: z$1.number()
815
- })),
816
- usage: openaiTokenUsageSchema
817
- }), openaiErrorDataSchema]);
818
- function isReasoningModel(modelId) {
819
- return modelId.startsWith("o") || modelId.startsWith("gpt-5");
820
- }
821
- function isAudioModel(modelId) {
822
- return modelId.startsWith("gpt-4o-audio-preview");
823
- }
824
- function getSystemMessageMode(modelId) {
825
- var _a, _b;
826
- if (!isReasoningModel(modelId)) return "system";
827
- return (_b = (_a = reasoningModels[modelId]) == null ? void 0 : _a.systemMessageMode) != null ? _b : "developer";
828
- }
829
- var reasoningModels = {
830
- "o1-mini": { systemMessageMode: "remove" },
831
- "o1-mini-2024-09-12": { systemMessageMode: "remove" },
832
- "o1-preview": { systemMessageMode: "remove" },
833
- "o1-preview-2024-09-12": { systemMessageMode: "remove" },
834
- o3: { systemMessageMode: "developer" },
835
- "o3-2025-04-16": { systemMessageMode: "developer" },
836
- "o3-mini": { systemMessageMode: "developer" },
837
- "o3-mini-2025-01-31": { systemMessageMode: "developer" },
838
- "o4-mini": { systemMessageMode: "developer" },
839
- "o4-mini-2025-04-16": { systemMessageMode: "developer" }
840
- };
841
- function convertToOpenAICompletionPrompt({ prompt, inputFormat, user = "user", assistant = "assistant" }) {
842
- if (inputFormat === "prompt" && prompt.length === 1 && prompt[0].role === "user" && prompt[0].content.length === 1 && prompt[0].content[0].type === "text") return { prompt: prompt[0].content[0].text };
843
- let text = "";
844
- if (prompt[0].role === "system") {
845
- text += `${prompt[0].content}
846
-
847
- `;
848
- prompt = prompt.slice(1);
849
- }
850
- for (const { role, content } of prompt) switch (role) {
851
- case "system": throw new InvalidPromptError({
852
- message: "Unexpected system message in prompt: ${content}",
853
- prompt
854
- });
855
- case "user": {
856
- const userMessage = content.map((part) => {
857
- switch (part.type) {
858
- case "text": return part.text;
859
- case "image": throw new UnsupportedFunctionalityError({ functionality: "images" });
860
- }
861
- }).join("");
862
- text += `${user}:
863
- ${userMessage}
864
-
865
- `;
866
- break;
867
- }
868
- case "assistant": {
869
- const assistantMessage = content.map((part) => {
870
- switch (part.type) {
871
- case "text": return part.text;
872
- case "tool-call": throw new UnsupportedFunctionalityError({ functionality: "tool-call messages" });
873
- }
874
- }).join("");
875
- text += `${assistant}:
876
- ${assistantMessage}
877
-
878
- `;
879
- break;
880
- }
881
- case "tool": throw new UnsupportedFunctionalityError({ functionality: "tool messages" });
882
- default: throw new Error(`Unsupported role: ${role}`);
883
- }
884
- text += `${assistant}:
885
- `;
886
- return {
887
- prompt: text,
888
- stopSequences: [`
889
- ${user}:`]
890
- };
891
- }
892
- function mapOpenAICompletionLogProbs(logprobs) {
893
- return logprobs == null ? void 0 : logprobs.tokens.map((token, index) => ({
894
- token,
895
- logprob: logprobs.token_logprobs[index],
896
- topLogprobs: logprobs.top_logprobs ? Object.entries(logprobs.top_logprobs[index]).map(([token2, logprob]) => ({
897
- token: token2,
898
- logprob
899
- })) : []
900
- }));
901
- }
902
- var OpenAICompletionLanguageModel = class {
903
- constructor(modelId, settings, config) {
904
- this.specificationVersion = "v1";
905
- this.defaultObjectGenerationMode = void 0;
906
- this.modelId = modelId;
907
- this.settings = settings;
908
- this.config = config;
909
- }
910
- get provider() {
911
- return this.config.provider;
912
- }
913
- getArgs({ mode, inputFormat, prompt, maxTokens, temperature, topP, topK, frequencyPenalty, presencePenalty, stopSequences: userStopSequences, responseFormat, seed }) {
914
- var _a;
915
- const type = mode.type;
916
- const warnings = [];
917
- if (topK != null) warnings.push({
918
- type: "unsupported-setting",
919
- setting: "topK"
920
- });
921
- if (responseFormat != null && responseFormat.type !== "text") warnings.push({
922
- type: "unsupported-setting",
923
- setting: "responseFormat",
924
- details: "JSON response format is not supported."
925
- });
926
- const { prompt: completionPrompt, stopSequences } = convertToOpenAICompletionPrompt({
927
- prompt,
928
- inputFormat
929
- });
930
- const stop = [...stopSequences != null ? stopSequences : [], ...userStopSequences != null ? userStopSequences : []];
931
- const baseArgs = {
932
- model: this.modelId,
933
- echo: this.settings.echo,
934
- logit_bias: this.settings.logitBias,
935
- logprobs: typeof this.settings.logprobs === "number" ? this.settings.logprobs : typeof this.settings.logprobs === "boolean" ? this.settings.logprobs ? 0 : void 0 : void 0,
936
- suffix: this.settings.suffix,
937
- user: this.settings.user,
938
- max_tokens: maxTokens,
939
- temperature,
940
- top_p: topP,
941
- frequency_penalty: frequencyPenalty,
942
- presence_penalty: presencePenalty,
943
- seed,
944
- prompt: completionPrompt,
945
- stop: stop.length > 0 ? stop : void 0
946
- };
947
- switch (type) {
948
- case "regular":
949
- if ((_a = mode.tools) == null ? void 0 : _a.length) throw new UnsupportedFunctionalityError({ functionality: "tools" });
950
- if (mode.toolChoice) throw new UnsupportedFunctionalityError({ functionality: "toolChoice" });
951
- return {
952
- args: baseArgs,
953
- warnings
954
- };
955
- case "object-json": throw new UnsupportedFunctionalityError({ functionality: "object-json mode" });
956
- case "object-tool": throw new UnsupportedFunctionalityError({ functionality: "object-tool mode" });
957
- default: throw new Error(`Unsupported type: ${type}`);
958
- }
959
- }
960
- async doGenerate(options) {
961
- const { args, warnings } = this.getArgs(options);
962
- const { responseHeaders, value: response, rawValue: rawResponse } = await postJsonToApi({
963
- url: this.config.url({
964
- path: "/completions",
965
- modelId: this.modelId
966
- }),
967
- headers: combineHeaders(this.config.headers(), options.headers),
968
- body: args,
969
- failedResponseHandler: openaiFailedResponseHandler,
970
- successfulResponseHandler: createJsonResponseHandler(openaiCompletionResponseSchema),
971
- abortSignal: options.abortSignal,
972
- fetch: this.config.fetch
973
- });
974
- const { prompt: rawPrompt, ...rawSettings } = args;
975
- const choice = response.choices[0];
976
- return {
977
- text: choice.text,
978
- usage: {
979
- promptTokens: response.usage.prompt_tokens,
980
- completionTokens: response.usage.completion_tokens
981
- },
982
- finishReason: mapOpenAIFinishReason(choice.finish_reason),
983
- logprobs: mapOpenAICompletionLogProbs(choice.logprobs),
984
- rawCall: {
985
- rawPrompt,
986
- rawSettings
987
- },
988
- rawResponse: {
989
- headers: responseHeaders,
990
- body: rawResponse
991
- },
992
- response: getResponseMetadata(response),
993
- warnings,
994
- request: { body: JSON.stringify(args) }
995
- };
996
- }
997
- async doStream(options) {
998
- const { args, warnings } = this.getArgs(options);
999
- const body = {
1000
- ...args,
1001
- stream: true,
1002
- stream_options: this.config.compatibility === "strict" ? { include_usage: true } : void 0
1003
- };
1004
- const { responseHeaders, value: response } = await postJsonToApi({
1005
- url: this.config.url({
1006
- path: "/completions",
1007
- modelId: this.modelId
1008
- }),
1009
- headers: combineHeaders(this.config.headers(), options.headers),
1010
- body,
1011
- failedResponseHandler: openaiFailedResponseHandler,
1012
- successfulResponseHandler: createEventSourceResponseHandler(openaiCompletionChunkSchema),
1013
- abortSignal: options.abortSignal,
1014
- fetch: this.config.fetch
1015
- });
1016
- const { prompt: rawPrompt, ...rawSettings } = args;
1017
- let finishReason = "unknown";
1018
- let usage = {
1019
- promptTokens: NaN,
1020
- completionTokens: NaN
1021
- };
1022
- let logprobs;
1023
- let isFirstChunk = true;
1024
- return {
1025
- stream: response.pipeThrough(new TransformStream({
1026
- transform(chunk, controller) {
1027
- if (!chunk.success) {
1028
- finishReason = "error";
1029
- controller.enqueue({
1030
- type: "error",
1031
- error: chunk.error
1032
- });
1033
- return;
1034
- }
1035
- const value = chunk.value;
1036
- if ("error" in value) {
1037
- finishReason = "error";
1038
- controller.enqueue({
1039
- type: "error",
1040
- error: value.error
1041
- });
1042
- return;
1043
- }
1044
- if (isFirstChunk) {
1045
- isFirstChunk = false;
1046
- controller.enqueue({
1047
- type: "response-metadata",
1048
- ...getResponseMetadata(value)
1049
- });
1050
- }
1051
- if (value.usage != null) usage = {
1052
- promptTokens: value.usage.prompt_tokens,
1053
- completionTokens: value.usage.completion_tokens
1054
- };
1055
- const choice = value.choices[0];
1056
- if ((choice == null ? void 0 : choice.finish_reason) != null) finishReason = mapOpenAIFinishReason(choice.finish_reason);
1057
- if ((choice == null ? void 0 : choice.text) != null) controller.enqueue({
1058
- type: "text-delta",
1059
- textDelta: choice.text
1060
- });
1061
- const mappedLogprobs = mapOpenAICompletionLogProbs(choice == null ? void 0 : choice.logprobs);
1062
- if (mappedLogprobs == null ? void 0 : mappedLogprobs.length) {
1063
- if (logprobs === void 0) logprobs = [];
1064
- logprobs.push(...mappedLogprobs);
1065
- }
1066
- },
1067
- flush(controller) {
1068
- controller.enqueue({
1069
- type: "finish",
1070
- finishReason,
1071
- logprobs,
1072
- usage
1073
- });
1074
- }
1075
- })),
1076
- rawCall: {
1077
- rawPrompt,
1078
- rawSettings
1079
- },
1080
- rawResponse: { headers: responseHeaders },
1081
- warnings,
1082
- request: { body: JSON.stringify(body) }
1083
- };
1084
- }
1085
- };
1086
- var openaiCompletionResponseSchema = z$1.object({
1087
- id: z$1.string().nullish(),
1088
- created: z$1.number().nullish(),
1089
- model: z$1.string().nullish(),
1090
- choices: z$1.array(z$1.object({
1091
- text: z$1.string(),
1092
- finish_reason: z$1.string(),
1093
- logprobs: z$1.object({
1094
- tokens: z$1.array(z$1.string()),
1095
- token_logprobs: z$1.array(z$1.number()),
1096
- top_logprobs: z$1.array(z$1.record(z$1.string(), z$1.number())).nullable()
1097
- }).nullish()
1098
- })),
1099
- usage: z$1.object({
1100
- prompt_tokens: z$1.number(),
1101
- completion_tokens: z$1.number()
1102
- })
1103
- });
1104
- var openaiCompletionChunkSchema = z$1.union([z$1.object({
1105
- id: z$1.string().nullish(),
1106
- created: z$1.number().nullish(),
1107
- model: z$1.string().nullish(),
1108
- choices: z$1.array(z$1.object({
1109
- text: z$1.string(),
1110
- finish_reason: z$1.string().nullish(),
1111
- index: z$1.number(),
1112
- logprobs: z$1.object({
1113
- tokens: z$1.array(z$1.string()),
1114
- token_logprobs: z$1.array(z$1.number()),
1115
- top_logprobs: z$1.array(z$1.record(z$1.string(), z$1.number())).nullable()
1116
- }).nullish()
1117
- })),
1118
- usage: z$1.object({
1119
- prompt_tokens: z$1.number(),
1120
- completion_tokens: z$1.number()
1121
- }).nullish()
1122
- }), openaiErrorDataSchema]);
1123
- var OpenAIEmbeddingModel = class {
1124
- constructor(modelId, settings, config) {
1125
- this.specificationVersion = "v1";
1126
- this.modelId = modelId;
1127
- this.settings = settings;
1128
- this.config = config;
1129
- }
1130
- get provider() {
1131
- return this.config.provider;
1132
- }
1133
- get maxEmbeddingsPerCall() {
1134
- var _a;
1135
- return (_a = this.settings.maxEmbeddingsPerCall) != null ? _a : 2048;
1136
- }
1137
- get supportsParallelCalls() {
1138
- var _a;
1139
- return (_a = this.settings.supportsParallelCalls) != null ? _a : true;
1140
- }
1141
- async doEmbed({ values, headers, abortSignal }) {
1142
- if (values.length > this.maxEmbeddingsPerCall) throw new TooManyEmbeddingValuesForCallError({
1143
- provider: this.provider,
1144
- modelId: this.modelId,
1145
- maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
1146
- values
1147
- });
1148
- const { responseHeaders, value: response } = await postJsonToApi({
1149
- url: this.config.url({
1150
- path: "/embeddings",
1151
- modelId: this.modelId
1152
- }),
1153
- headers: combineHeaders(this.config.headers(), headers),
1154
- body: {
1155
- model: this.modelId,
1156
- input: values,
1157
- encoding_format: "float",
1158
- dimensions: this.settings.dimensions,
1159
- user: this.settings.user
1160
- },
1161
- failedResponseHandler: openaiFailedResponseHandler,
1162
- successfulResponseHandler: createJsonResponseHandler(openaiTextEmbeddingResponseSchema),
1163
- abortSignal,
1164
- fetch: this.config.fetch
1165
- });
1166
- return {
1167
- embeddings: response.data.map((item) => item.embedding),
1168
- usage: response.usage ? { tokens: response.usage.prompt_tokens } : void 0,
1169
- rawResponse: { headers: responseHeaders }
1170
- };
1171
- }
1172
- };
1173
- var openaiTextEmbeddingResponseSchema = z$1.object({
1174
- data: z$1.array(z$1.object({ embedding: z$1.array(z$1.number()) })),
1175
- usage: z$1.object({ prompt_tokens: z$1.number() }).nullish()
1176
- });
1177
- var modelMaxImagesPerCall = {
1178
- "dall-e-3": 1,
1179
- "dall-e-2": 10,
1180
- "gpt-image-1": 10
1181
- };
1182
- var hasDefaultResponseFormat = /* @__PURE__ */ new Set(["gpt-image-1"]);
1183
- var OpenAIImageModel = class {
1184
- constructor(modelId, settings, config) {
1185
- this.modelId = modelId;
1186
- this.settings = settings;
1187
- this.config = config;
1188
- this.specificationVersion = "v1";
1189
- }
1190
- get maxImagesPerCall() {
1191
- var _a, _b;
1192
- return (_b = (_a = this.settings.maxImagesPerCall) != null ? _a : modelMaxImagesPerCall[this.modelId]) != null ? _b : 1;
1193
- }
1194
- get provider() {
1195
- return this.config.provider;
1196
- }
1197
- async doGenerate({ prompt, n, size, aspectRatio, seed, providerOptions, headers, abortSignal }) {
1198
- var _a, _b, _c, _d;
1199
- const warnings = [];
1200
- if (aspectRatio != null) warnings.push({
1201
- type: "unsupported-setting",
1202
- setting: "aspectRatio",
1203
- details: "This model does not support aspect ratio. Use `size` instead."
1204
- });
1205
- if (seed != null) warnings.push({
1206
- type: "unsupported-setting",
1207
- setting: "seed"
1208
- });
1209
- const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
1210
- const { value: response, responseHeaders } = await postJsonToApi({
1211
- url: this.config.url({
1212
- path: "/images/generations",
1213
- modelId: this.modelId
1214
- }),
1215
- headers: combineHeaders(this.config.headers(), headers),
1216
- body: {
1217
- model: this.modelId,
1218
- prompt,
1219
- n,
1220
- size,
1221
- ...(_d = providerOptions.openai) != null ? _d : {},
1222
- ...!hasDefaultResponseFormat.has(this.modelId) ? { response_format: "b64_json" } : {}
1223
- },
1224
- failedResponseHandler: openaiFailedResponseHandler,
1225
- successfulResponseHandler: createJsonResponseHandler(openaiImageResponseSchema),
1226
- abortSignal,
1227
- fetch: this.config.fetch
1228
- });
1229
- return {
1230
- images: response.data.map((item) => item.b64_json),
1231
- warnings,
1232
- response: {
1233
- timestamp: currentDate,
1234
- modelId: this.modelId,
1235
- headers: responseHeaders
1236
- }
1237
- };
1238
- }
1239
- };
1240
- var openaiImageResponseSchema = z$1.object({ data: z$1.array(z$1.object({ b64_json: z$1.string() })) });
1241
- var openAIProviderOptionsSchema = z$1.object({
1242
- include: z$1.array(z$1.string()).nullish(),
1243
- language: z$1.string().nullish(),
1244
- prompt: z$1.string().nullish(),
1245
- temperature: z$1.number().min(0).max(1).nullish().default(0),
1246
- timestampGranularities: z$1.array(z$1.enum(["word", "segment"])).nullish().default(["segment"])
1247
- });
1248
- var languageMap = {
1249
- afrikaans: "af",
1250
- arabic: "ar",
1251
- armenian: "hy",
1252
- azerbaijani: "az",
1253
- belarusian: "be",
1254
- bosnian: "bs",
1255
- bulgarian: "bg",
1256
- catalan: "ca",
1257
- chinese: "zh",
1258
- croatian: "hr",
1259
- czech: "cs",
1260
- danish: "da",
1261
- dutch: "nl",
1262
- english: "en",
1263
- estonian: "et",
1264
- finnish: "fi",
1265
- french: "fr",
1266
- galician: "gl",
1267
- german: "de",
1268
- greek: "el",
1269
- hebrew: "he",
1270
- hindi: "hi",
1271
- hungarian: "hu",
1272
- icelandic: "is",
1273
- indonesian: "id",
1274
- italian: "it",
1275
- japanese: "ja",
1276
- kannada: "kn",
1277
- kazakh: "kk",
1278
- korean: "ko",
1279
- latvian: "lv",
1280
- lithuanian: "lt",
1281
- macedonian: "mk",
1282
- malay: "ms",
1283
- marathi: "mr",
1284
- maori: "mi",
1285
- nepali: "ne",
1286
- norwegian: "no",
1287
- persian: "fa",
1288
- polish: "pl",
1289
- portuguese: "pt",
1290
- romanian: "ro",
1291
- russian: "ru",
1292
- serbian: "sr",
1293
- slovak: "sk",
1294
- slovenian: "sl",
1295
- spanish: "es",
1296
- swahili: "sw",
1297
- swedish: "sv",
1298
- tagalog: "tl",
1299
- tamil: "ta",
1300
- thai: "th",
1301
- turkish: "tr",
1302
- ukrainian: "uk",
1303
- urdu: "ur",
1304
- vietnamese: "vi",
1305
- welsh: "cy"
1306
- };
1307
- var OpenAITranscriptionModel = class {
1308
- constructor(modelId, config) {
1309
- this.modelId = modelId;
1310
- this.config = config;
1311
- this.specificationVersion = "v1";
1312
- }
1313
- get provider() {
1314
- return this.config.provider;
1315
- }
1316
- getArgs({ audio, mediaType, providerOptions }) {
1317
- var _a, _b, _c, _d, _e;
1318
- const warnings = [];
1319
- const openAIOptions = parseProviderOptions({
1320
- provider: "openai",
1321
- providerOptions,
1322
- schema: openAIProviderOptionsSchema
1323
- });
1324
- const formData = new FormData();
1325
- const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([convertBase64ToUint8Array(audio)]);
1326
- formData.append("model", this.modelId);
1327
- formData.append("file", new File([blob], "audio", { type: mediaType }));
1328
- if (openAIOptions) {
1329
- const transcriptionModelOptions = {
1330
- include: (_a = openAIOptions.include) != null ? _a : void 0,
1331
- language: (_b = openAIOptions.language) != null ? _b : void 0,
1332
- prompt: (_c = openAIOptions.prompt) != null ? _c : void 0,
1333
- temperature: (_d = openAIOptions.temperature) != null ? _d : void 0,
1334
- timestamp_granularities: (_e = openAIOptions.timestampGranularities) != null ? _e : void 0
1335
- };
1336
- for (const key in transcriptionModelOptions) {
1337
- const value = transcriptionModelOptions[key];
1338
- if (value !== void 0) formData.append(key, String(value));
1339
- }
1340
- }
1341
- return {
1342
- formData,
1343
- warnings
1344
- };
1345
- }
1346
- async doGenerate(options) {
1347
- var _a, _b, _c, _d, _e, _f;
1348
- const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
1349
- const { formData, warnings } = this.getArgs(options);
1350
- const { value: response, responseHeaders, rawValue: rawResponse } = await postFormDataToApi({
1351
- url: this.config.url({
1352
- path: "/audio/transcriptions",
1353
- modelId: this.modelId
1354
- }),
1355
- headers: combineHeaders(this.config.headers(), options.headers),
1356
- formData,
1357
- failedResponseHandler: openaiFailedResponseHandler,
1358
- successfulResponseHandler: createJsonResponseHandler(openaiTranscriptionResponseSchema),
1359
- abortSignal: options.abortSignal,
1360
- fetch: this.config.fetch
1361
- });
1362
- const language = response.language != null && response.language in languageMap ? languageMap[response.language] : void 0;
1363
- return {
1364
- text: response.text,
1365
- segments: (_e = (_d = response.words) == null ? void 0 : _d.map((word) => ({
1366
- text: word.word,
1367
- startSecond: word.start,
1368
- endSecond: word.end
1369
- }))) != null ? _e : [],
1370
- language,
1371
- durationInSeconds: (_f = response.duration) != null ? _f : void 0,
1372
- warnings,
1373
- response: {
1374
- timestamp: currentDate,
1375
- modelId: this.modelId,
1376
- headers: responseHeaders,
1377
- body: rawResponse
1378
- }
1379
- };
1380
- }
1381
- };
1382
- var openaiTranscriptionResponseSchema = z$1.object({
1383
- text: z$1.string(),
1384
- language: z$1.string().nullish(),
1385
- duration: z$1.number().nullish(),
1386
- words: z$1.array(z$1.object({
1387
- word: z$1.string(),
1388
- start: z$1.number(),
1389
- end: z$1.number()
1390
- })).nullish()
1391
- });
1392
- function convertToOpenAIResponsesMessages({ prompt, systemMessageMode }) {
1393
- const messages = [];
1394
- const warnings = [];
1395
- for (const { role, content } of prompt) switch (role) {
1396
- case "system":
1397
- switch (systemMessageMode) {
1398
- case "system":
1399
- messages.push({
1400
- role: "system",
1401
- content
1402
- });
1403
- break;
1404
- case "developer":
1405
- messages.push({
1406
- role: "developer",
1407
- content
1408
- });
1409
- break;
1410
- case "remove":
1411
- warnings.push({
1412
- type: "other",
1413
- message: "system messages are removed for this model"
1414
- });
1415
- break;
1416
- default: throw new Error(`Unsupported system message mode: ${systemMessageMode}`);
1417
- }
1418
- break;
1419
- case "user":
1420
- messages.push({
1421
- role: "user",
1422
- content: content.map((part, index) => {
1423
- var _a, _b, _c, _d;
1424
- switch (part.type) {
1425
- case "text": return {
1426
- type: "input_text",
1427
- text: part.text
1428
- };
1429
- case "image": return {
1430
- type: "input_image",
1431
- image_url: part.image instanceof URL ? part.image.toString() : `data:${(_a = part.mimeType) != null ? _a : "image/jpeg"};base64,${convertUint8ArrayToBase64(part.image)}`,
1432
- detail: (_c = (_b = part.providerMetadata) == null ? void 0 : _b.openai) == null ? void 0 : _c.imageDetail
1433
- };
1434
- case "file":
1435
- if (part.data instanceof URL) throw new UnsupportedFunctionalityError({ functionality: "File URLs in user messages" });
1436
- switch (part.mimeType) {
1437
- case "application/pdf": return {
1438
- type: "input_file",
1439
- filename: (_d = part.filename) != null ? _d : `part-${index}.pdf`,
1440
- file_data: `data:application/pdf;base64,${part.data}`
1441
- };
1442
- default: throw new UnsupportedFunctionalityError({ functionality: "Only PDF files are supported in user messages" });
1443
- }
1444
- }
1445
- })
1446
- });
1447
- break;
1448
- case "assistant":
1449
- for (const part of content) switch (part.type) {
1450
- case "text":
1451
- messages.push({
1452
- role: "assistant",
1453
- content: [{
1454
- type: "output_text",
1455
- text: part.text
1456
- }]
1457
- });
1458
- break;
1459
- case "tool-call":
1460
- messages.push({
1461
- type: "function_call",
1462
- call_id: part.toolCallId,
1463
- name: part.toolName,
1464
- arguments: JSON.stringify(part.args)
1465
- });
1466
- break;
1467
- }
1468
- break;
1469
- case "tool":
1470
- for (const part of content) messages.push({
1471
- type: "function_call_output",
1472
- call_id: part.toolCallId,
1473
- output: JSON.stringify(part.result)
1474
- });
1475
- break;
1476
- default: throw new Error(`Unsupported role: ${role}`);
1477
- }
1478
- return {
1479
- messages,
1480
- warnings
1481
- };
1482
- }
1483
- function mapOpenAIResponseFinishReason({ finishReason, hasToolCalls }) {
1484
- switch (finishReason) {
1485
- case void 0:
1486
- case null: return hasToolCalls ? "tool-calls" : "stop";
1487
- case "max_output_tokens": return "length";
1488
- case "content_filter": return "content-filter";
1489
- default: return hasToolCalls ? "tool-calls" : "unknown";
1490
- }
1491
- }
1492
- function prepareResponsesTools({ mode, strict }) {
1493
- var _a;
1494
- const tools = ((_a = mode.tools) == null ? void 0 : _a.length) ? mode.tools : void 0;
1495
- const toolWarnings = [];
1496
- if (tools == null) return {
1497
- tools: void 0,
1498
- tool_choice: void 0,
1499
- toolWarnings
1500
- };
1501
- const toolChoice = mode.toolChoice;
1502
- const openaiTools2 = [];
1503
- for (const tool of tools) switch (tool.type) {
1504
- case "function":
1505
- openaiTools2.push({
1506
- type: "function",
1507
- name: tool.name,
1508
- description: tool.description,
1509
- parameters: tool.parameters,
1510
- strict: strict ? true : void 0
1511
- });
1512
- break;
1513
- case "provider-defined":
1514
- switch (tool.id) {
1515
- case "openai.web_search_preview":
1516
- openaiTools2.push({
1517
- type: "web_search_preview",
1518
- search_context_size: tool.args.searchContextSize,
1519
- user_location: tool.args.userLocation
1520
- });
1521
- break;
1522
- default:
1523
- toolWarnings.push({
1524
- type: "unsupported-tool",
1525
- tool
1526
- });
1527
- break;
1528
- }
1529
- break;
1530
- default:
1531
- toolWarnings.push({
1532
- type: "unsupported-tool",
1533
- tool
1534
- });
1535
- break;
1536
- }
1537
- if (toolChoice == null) return {
1538
- tools: openaiTools2,
1539
- tool_choice: void 0,
1540
- toolWarnings
1541
- };
1542
- const type = toolChoice.type;
1543
- switch (type) {
1544
- case "auto":
1545
- case "none":
1546
- case "required": return {
1547
- tools: openaiTools2,
1548
- tool_choice: type,
1549
- toolWarnings
1550
- };
1551
- case "tool":
1552
- if (toolChoice.toolName === "web_search_preview") return {
1553
- tools: openaiTools2,
1554
- tool_choice: { type: "web_search_preview" },
1555
- toolWarnings
1556
- };
1557
- return {
1558
- tools: openaiTools2,
1559
- tool_choice: {
1560
- type: "function",
1561
- name: toolChoice.toolName
1562
- },
1563
- toolWarnings
1564
- };
1565
- default: throw new UnsupportedFunctionalityError({ functionality: `Unsupported tool choice type: ${type}` });
1566
- }
1567
- }
1568
- var OpenAIResponsesLanguageModel = class {
1569
- constructor(modelId, config) {
1570
- this.specificationVersion = "v1";
1571
- this.defaultObjectGenerationMode = "json";
1572
- this.supportsStructuredOutputs = true;
1573
- this.modelId = modelId;
1574
- this.config = config;
1575
- }
1576
- get provider() {
1577
- return this.config.provider;
1578
- }
1579
- getArgs({ mode, maxTokens, temperature, stopSequences, topP, topK, presencePenalty, frequencyPenalty, seed, prompt, providerMetadata, responseFormat }) {
1580
- var _a, _b, _c;
1581
- const warnings = [];
1582
- const modelConfig = getResponsesModelConfig(this.modelId);
1583
- const type = mode.type;
1584
- if (topK != null) warnings.push({
1585
- type: "unsupported-setting",
1586
- setting: "topK"
1587
- });
1588
- if (seed != null) warnings.push({
1589
- type: "unsupported-setting",
1590
- setting: "seed"
1591
- });
1592
- if (presencePenalty != null) warnings.push({
1593
- type: "unsupported-setting",
1594
- setting: "presencePenalty"
1595
- });
1596
- if (frequencyPenalty != null) warnings.push({
1597
- type: "unsupported-setting",
1598
- setting: "frequencyPenalty"
1599
- });
1600
- if (stopSequences != null) warnings.push({
1601
- type: "unsupported-setting",
1602
- setting: "stopSequences"
1603
- });
1604
- const { messages, warnings: messageWarnings } = convertToOpenAIResponsesMessages({
1605
- prompt,
1606
- systemMessageMode: modelConfig.systemMessageMode
1607
- });
1608
- warnings.push(...messageWarnings);
1609
- const openaiOptions = parseProviderOptions({
1610
- provider: "openai",
1611
- providerOptions: providerMetadata,
1612
- schema: openaiResponsesProviderOptionsSchema
1613
- });
1614
- const isStrict = (_a = openaiOptions == null ? void 0 : openaiOptions.strictSchemas) != null ? _a : true;
1615
- const baseArgs = {
1616
- model: this.modelId,
1617
- input: messages,
1618
- temperature,
1619
- top_p: topP,
1620
- max_output_tokens: maxTokens,
1621
- ...(responseFormat == null ? void 0 : responseFormat.type) === "json" && { text: { format: responseFormat.schema != null ? {
1622
- type: "json_schema",
1623
- strict: isStrict,
1624
- name: (_b = responseFormat.name) != null ? _b : "response",
1625
- description: responseFormat.description,
1626
- schema: responseFormat.schema
1627
- } : { type: "json_object" } } },
1628
- metadata: openaiOptions == null ? void 0 : openaiOptions.metadata,
1629
- parallel_tool_calls: openaiOptions == null ? void 0 : openaiOptions.parallelToolCalls,
1630
- previous_response_id: openaiOptions == null ? void 0 : openaiOptions.previousResponseId,
1631
- store: openaiOptions == null ? void 0 : openaiOptions.store,
1632
- user: openaiOptions == null ? void 0 : openaiOptions.user,
1633
- instructions: openaiOptions == null ? void 0 : openaiOptions.instructions,
1634
- ...modelConfig.isReasoningModel && ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) && { reasoning: {
1635
- ...(openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null && { effort: openaiOptions.reasoningEffort },
1636
- ...(openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null && { summary: openaiOptions.reasoningSummary }
1637
- } },
1638
- ...modelConfig.requiredAutoTruncation && { truncation: "auto" }
1639
- };
1640
- if (modelConfig.isReasoningModel) {
1641
- if (baseArgs.temperature != null) {
1642
- baseArgs.temperature = void 0;
1643
- warnings.push({
1644
- type: "unsupported-setting",
1645
- setting: "temperature",
1646
- details: "temperature is not supported for reasoning models"
1647
- });
1648
- }
1649
- if (baseArgs.top_p != null) {
1650
- baseArgs.top_p = void 0;
1651
- warnings.push({
1652
- type: "unsupported-setting",
1653
- setting: "topP",
1654
- details: "topP is not supported for reasoning models"
1655
- });
1656
- }
1657
- }
1658
- switch (type) {
1659
- case "regular": {
1660
- const { tools, tool_choice, toolWarnings } = prepareResponsesTools({
1661
- mode,
1662
- strict: isStrict
1663
- });
1664
- return {
1665
- args: {
1666
- ...baseArgs,
1667
- tools,
1668
- tool_choice
1669
- },
1670
- warnings: [...warnings, ...toolWarnings]
1671
- };
1672
- }
1673
- case "object-json": return {
1674
- args: {
1675
- ...baseArgs,
1676
- text: { format: mode.schema != null ? {
1677
- type: "json_schema",
1678
- strict: isStrict,
1679
- name: (_c = mode.name) != null ? _c : "response",
1680
- description: mode.description,
1681
- schema: mode.schema
1682
- } : { type: "json_object" } }
1683
- },
1684
- warnings
1685
- };
1686
- case "object-tool": return {
1687
- args: {
1688
- ...baseArgs,
1689
- tool_choice: {
1690
- type: "function",
1691
- name: mode.tool.name
1692
- },
1693
- tools: [{
1694
- type: "function",
1695
- name: mode.tool.name,
1696
- description: mode.tool.description,
1697
- parameters: mode.tool.parameters,
1698
- strict: isStrict
1699
- }]
1700
- },
1701
- warnings
1702
- };
1703
- default: throw new Error(`Unsupported type: ${type}`);
1704
- }
1705
- }
1706
- async doGenerate(options) {
1707
- var _a, _b, _c, _d, _e, _f, _g;
1708
- const { args: body, warnings } = this.getArgs(options);
1709
- const url = this.config.url({
1710
- path: "/responses",
1711
- modelId: this.modelId
1712
- });
1713
- const { responseHeaders, value: response, rawValue: rawResponse } = await postJsonToApi({
1714
- url,
1715
- headers: combineHeaders(this.config.headers(), options.headers),
1716
- body,
1717
- failedResponseHandler: openaiFailedResponseHandler,
1718
- successfulResponseHandler: createJsonResponseHandler(z$1.object({
1719
- id: z$1.string(),
1720
- created_at: z$1.number(),
1721
- error: z$1.object({
1722
- message: z$1.string(),
1723
- code: z$1.string()
1724
- }).nullish(),
1725
- model: z$1.string(),
1726
- output: z$1.array(z$1.discriminatedUnion("type", [
1727
- z$1.object({
1728
- type: z$1.literal("message"),
1729
- role: z$1.literal("assistant"),
1730
- content: z$1.array(z$1.object({
1731
- type: z$1.literal("output_text"),
1732
- text: z$1.string(),
1733
- annotations: z$1.array(z$1.object({
1734
- type: z$1.literal("url_citation"),
1735
- start_index: z$1.number(),
1736
- end_index: z$1.number(),
1737
- url: z$1.string(),
1738
- title: z$1.string()
1739
- }))
1740
- }))
1741
- }),
1742
- z$1.object({
1743
- type: z$1.literal("function_call"),
1744
- call_id: z$1.string(),
1745
- name: z$1.string(),
1746
- arguments: z$1.string()
1747
- }),
1748
- z$1.object({ type: z$1.literal("web_search_call") }),
1749
- z$1.object({ type: z$1.literal("computer_call") }),
1750
- z$1.object({
1751
- type: z$1.literal("reasoning"),
1752
- summary: z$1.array(z$1.object({
1753
- type: z$1.literal("summary_text"),
1754
- text: z$1.string()
1755
- }))
1756
- })
1757
- ])),
1758
- incomplete_details: z$1.object({ reason: z$1.string() }).nullable(),
1759
- usage: usageSchema
1760
- })),
1761
- abortSignal: options.abortSignal,
1762
- fetch: this.config.fetch
1763
- });
1764
- if (response.error) throw new APICallError({
1765
- message: response.error.message,
1766
- url,
1767
- requestBodyValues: body,
1768
- statusCode: 400,
1769
- responseHeaders,
1770
- responseBody: rawResponse,
1771
- isRetryable: false
1772
- });
1773
- const outputTextElements = response.output.filter((output) => output.type === "message").flatMap((output) => output.content).filter((content) => content.type === "output_text");
1774
- const toolCalls = response.output.filter((output) => output.type === "function_call").map((output) => ({
1775
- toolCallType: "function",
1776
- toolCallId: output.call_id,
1777
- toolName: output.name,
1778
- args: output.arguments
1779
- }));
1780
- const reasoningSummary = (_b = (_a = response.output.find((item) => item.type === "reasoning")) == null ? void 0 : _a.summary) != null ? _b : null;
1781
- return {
1782
- text: outputTextElements.map((content) => content.text).join("\n"),
1783
- sources: outputTextElements.flatMap((content) => content.annotations.map((annotation) => {
1784
- var _a2, _b2, _c2;
1785
- return {
1786
- sourceType: "url",
1787
- id: (_c2 = (_b2 = (_a2 = this.config).generateId) == null ? void 0 : _b2.call(_a2)) != null ? _c2 : generateId(),
1788
- url: annotation.url,
1789
- title: annotation.title
1790
- };
1791
- })),
1792
- finishReason: mapOpenAIResponseFinishReason({
1793
- finishReason: (_c = response.incomplete_details) == null ? void 0 : _c.reason,
1794
- hasToolCalls: toolCalls.length > 0
1795
- }),
1796
- toolCalls: toolCalls.length > 0 ? toolCalls : void 0,
1797
- reasoning: reasoningSummary ? reasoningSummary.map((summary) => ({
1798
- type: "text",
1799
- text: summary.text
1800
- })) : void 0,
1801
- usage: {
1802
- promptTokens: response.usage.input_tokens,
1803
- completionTokens: response.usage.output_tokens
1804
- },
1805
- rawCall: {
1806
- rawPrompt: void 0,
1807
- rawSettings: {}
1808
- },
1809
- rawResponse: {
1810
- headers: responseHeaders,
1811
- body: rawResponse
1812
- },
1813
- request: { body: JSON.stringify(body) },
1814
- response: {
1815
- id: response.id,
1816
- timestamp: /* @__PURE__ */ new Date(response.created_at * 1e3),
1817
- modelId: response.model
1818
- },
1819
- providerMetadata: { openai: {
1820
- responseId: response.id,
1821
- cachedPromptTokens: (_e = (_d = response.usage.input_tokens_details) == null ? void 0 : _d.cached_tokens) != null ? _e : null,
1822
- reasoningTokens: (_g = (_f = response.usage.output_tokens_details) == null ? void 0 : _f.reasoning_tokens) != null ? _g : null
1823
- } },
1824
- warnings
1825
- };
1826
- }
1827
- async doStream(options) {
1828
- const { args: body, warnings } = this.getArgs(options);
1829
- const { responseHeaders, value: response } = await postJsonToApi({
1830
- url: this.config.url({
1831
- path: "/responses",
1832
- modelId: this.modelId
1833
- }),
1834
- headers: combineHeaders(this.config.headers(), options.headers),
1835
- body: {
1836
- ...body,
1837
- stream: true
1838
- },
1839
- failedResponseHandler: openaiFailedResponseHandler,
1840
- successfulResponseHandler: createEventSourceResponseHandler(openaiResponsesChunkSchema),
1841
- abortSignal: options.abortSignal,
1842
- fetch: this.config.fetch
1843
- });
1844
- const self = this;
1845
- let finishReason = "unknown";
1846
- let promptTokens = NaN;
1847
- let completionTokens = NaN;
1848
- let cachedPromptTokens = null;
1849
- let reasoningTokens = null;
1850
- let responseId = null;
1851
- const ongoingToolCalls = {};
1852
- let hasToolCalls = false;
1853
- return {
1854
- stream: response.pipeThrough(new TransformStream({
1855
- transform(chunk, controller) {
1856
- var _a, _b, _c, _d, _e, _f, _g, _h;
1857
- if (!chunk.success) {
1858
- finishReason = "error";
1859
- controller.enqueue({
1860
- type: "error",
1861
- error: chunk.error
1862
- });
1863
- return;
1864
- }
1865
- const value = chunk.value;
1866
- if (isResponseOutputItemAddedChunk(value)) {
1867
- if (value.item.type === "function_call") {
1868
- ongoingToolCalls[value.output_index] = {
1869
- toolName: value.item.name,
1870
- toolCallId: value.item.call_id
1871
- };
1872
- controller.enqueue({
1873
- type: "tool-call-delta",
1874
- toolCallType: "function",
1875
- toolCallId: value.item.call_id,
1876
- toolName: value.item.name,
1877
- argsTextDelta: value.item.arguments
1878
- });
1879
- }
1880
- } else if (isResponseFunctionCallArgumentsDeltaChunk(value)) {
1881
- const toolCall = ongoingToolCalls[value.output_index];
1882
- if (toolCall != null) controller.enqueue({
1883
- type: "tool-call-delta",
1884
- toolCallType: "function",
1885
- toolCallId: toolCall.toolCallId,
1886
- toolName: toolCall.toolName,
1887
- argsTextDelta: value.delta
1888
- });
1889
- } else if (isResponseCreatedChunk(value)) {
1890
- responseId = value.response.id;
1891
- controller.enqueue({
1892
- type: "response-metadata",
1893
- id: value.response.id,
1894
- timestamp: /* @__PURE__ */ new Date(value.response.created_at * 1e3),
1895
- modelId: value.response.model
1896
- });
1897
- } else if (isTextDeltaChunk(value)) controller.enqueue({
1898
- type: "text-delta",
1899
- textDelta: value.delta
1900
- });
1901
- else if (isResponseReasoningSummaryTextDeltaChunk(value)) controller.enqueue({
1902
- type: "reasoning",
1903
- textDelta: value.delta
1904
- });
1905
- else if (isResponseOutputItemDoneChunk(value) && value.item.type === "function_call") {
1906
- ongoingToolCalls[value.output_index] = void 0;
1907
- hasToolCalls = true;
1908
- controller.enqueue({
1909
- type: "tool-call",
1910
- toolCallType: "function",
1911
- toolCallId: value.item.call_id,
1912
- toolName: value.item.name,
1913
- args: value.item.arguments
1914
- });
1915
- } else if (isResponseFinishedChunk(value)) {
1916
- finishReason = mapOpenAIResponseFinishReason({
1917
- finishReason: (_a = value.response.incomplete_details) == null ? void 0 : _a.reason,
1918
- hasToolCalls
1919
- });
1920
- promptTokens = value.response.usage.input_tokens;
1921
- completionTokens = value.response.usage.output_tokens;
1922
- cachedPromptTokens = (_c = (_b = value.response.usage.input_tokens_details) == null ? void 0 : _b.cached_tokens) != null ? _c : cachedPromptTokens;
1923
- reasoningTokens = (_e = (_d = value.response.usage.output_tokens_details) == null ? void 0 : _d.reasoning_tokens) != null ? _e : reasoningTokens;
1924
- } else if (isResponseAnnotationAddedChunk(value)) controller.enqueue({
1925
- type: "source",
1926
- source: {
1927
- sourceType: "url",
1928
- id: (_h = (_g = (_f = self.config).generateId) == null ? void 0 : _g.call(_f)) != null ? _h : generateId(),
1929
- url: value.annotation.url,
1930
- title: value.annotation.title
1931
- }
1932
- });
1933
- else if (isErrorChunk(value)) controller.enqueue({
1934
- type: "error",
1935
- error: value
1936
- });
1937
- },
1938
- flush(controller) {
1939
- controller.enqueue({
1940
- type: "finish",
1941
- finishReason,
1942
- usage: {
1943
- promptTokens,
1944
- completionTokens
1945
- },
1946
- ...(cachedPromptTokens != null || reasoningTokens != null) && { providerMetadata: { openai: {
1947
- responseId,
1948
- cachedPromptTokens,
1949
- reasoningTokens
1950
- } } }
1951
- });
1952
- }
1953
- })),
1954
- rawCall: {
1955
- rawPrompt: void 0,
1956
- rawSettings: {}
1957
- },
1958
- rawResponse: { headers: responseHeaders },
1959
- request: { body: JSON.stringify(body) },
1960
- warnings
1961
- };
1962
- }
1963
- };
1964
- var usageSchema = z$1.object({
1965
- input_tokens: z$1.number(),
1966
- input_tokens_details: z$1.object({ cached_tokens: z$1.number().nullish() }).nullish(),
1967
- output_tokens: z$1.number(),
1968
- output_tokens_details: z$1.object({ reasoning_tokens: z$1.number().nullish() }).nullish()
1969
- });
1970
- var textDeltaChunkSchema = z$1.object({
1971
- type: z$1.literal("response.output_text.delta"),
1972
- delta: z$1.string()
1973
- });
1974
- var responseFinishedChunkSchema = z$1.object({
1975
- type: z$1.enum(["response.completed", "response.incomplete"]),
1976
- response: z$1.object({
1977
- incomplete_details: z$1.object({ reason: z$1.string() }).nullish(),
1978
- usage: usageSchema
1979
- })
1980
- });
1981
- var responseCreatedChunkSchema = z$1.object({
1982
- type: z$1.literal("response.created"),
1983
- response: z$1.object({
1984
- id: z$1.string(),
1985
- created_at: z$1.number(),
1986
- model: z$1.string()
1987
- })
1988
- });
1989
- var responseOutputItemDoneSchema = z$1.object({
1990
- type: z$1.literal("response.output_item.done"),
1991
- output_index: z$1.number(),
1992
- item: z$1.discriminatedUnion("type", [z$1.object({ type: z$1.literal("message") }), z$1.object({
1993
- type: z$1.literal("function_call"),
1994
- id: z$1.string(),
1995
- call_id: z$1.string(),
1996
- name: z$1.string(),
1997
- arguments: z$1.string(),
1998
- status: z$1.literal("completed")
1999
- })])
2000
- });
2001
- var responseFunctionCallArgumentsDeltaSchema = z$1.object({
2002
- type: z$1.literal("response.function_call_arguments.delta"),
2003
- item_id: z$1.string(),
2004
- output_index: z$1.number(),
2005
- delta: z$1.string()
2006
- });
2007
- var responseOutputItemAddedSchema = z$1.object({
2008
- type: z$1.literal("response.output_item.added"),
2009
- output_index: z$1.number(),
2010
- item: z$1.discriminatedUnion("type", [z$1.object({ type: z$1.literal("message") }), z$1.object({
2011
- type: z$1.literal("function_call"),
2012
- id: z$1.string(),
2013
- call_id: z$1.string(),
2014
- name: z$1.string(),
2015
- arguments: z$1.string()
2016
- })])
2017
- });
2018
- var responseAnnotationAddedSchema = z$1.object({
2019
- type: z$1.literal("response.output_text.annotation.added"),
2020
- annotation: z$1.object({
2021
- type: z$1.literal("url_citation"),
2022
- url: z$1.string(),
2023
- title: z$1.string()
2024
- })
2025
- });
2026
- var responseReasoningSummaryTextDeltaSchema = z$1.object({
2027
- type: z$1.literal("response.reasoning_summary_text.delta"),
2028
- item_id: z$1.string(),
2029
- output_index: z$1.number(),
2030
- summary_index: z$1.number(),
2031
- delta: z$1.string()
2032
- });
2033
- var errorChunkSchema = z$1.object({
2034
- type: z$1.literal("error"),
2035
- code: z$1.string(),
2036
- message: z$1.string(),
2037
- param: z$1.string().nullish(),
2038
- sequence_number: z$1.number()
2039
- });
2040
- var openaiResponsesChunkSchema = z$1.union([
2041
- textDeltaChunkSchema,
2042
- responseFinishedChunkSchema,
2043
- responseCreatedChunkSchema,
2044
- responseOutputItemDoneSchema,
2045
- responseFunctionCallArgumentsDeltaSchema,
2046
- responseOutputItemAddedSchema,
2047
- responseAnnotationAddedSchema,
2048
- responseReasoningSummaryTextDeltaSchema,
2049
- errorChunkSchema,
2050
- z$1.object({ type: z$1.string() }).passthrough()
2051
- ]);
2052
- function isTextDeltaChunk(chunk) {
2053
- return chunk.type === "response.output_text.delta";
2054
- }
2055
- function isResponseOutputItemDoneChunk(chunk) {
2056
- return chunk.type === "response.output_item.done";
2057
- }
2058
- function isResponseFinishedChunk(chunk) {
2059
- return chunk.type === "response.completed" || chunk.type === "response.incomplete";
2060
- }
2061
- function isResponseCreatedChunk(chunk) {
2062
- return chunk.type === "response.created";
2063
- }
2064
- function isResponseFunctionCallArgumentsDeltaChunk(chunk) {
2065
- return chunk.type === "response.function_call_arguments.delta";
2066
- }
2067
- function isResponseOutputItemAddedChunk(chunk) {
2068
- return chunk.type === "response.output_item.added";
2069
- }
2070
- function isResponseAnnotationAddedChunk(chunk) {
2071
- return chunk.type === "response.output_text.annotation.added";
2072
- }
2073
- function isResponseReasoningSummaryTextDeltaChunk(chunk) {
2074
- return chunk.type === "response.reasoning_summary_text.delta";
2075
- }
2076
- function isErrorChunk(chunk) {
2077
- return chunk.type === "error";
2078
- }
2079
- function getResponsesModelConfig(modelId) {
2080
- if (modelId.startsWith("o") || modelId.startsWith("gpt-5")) {
2081
- if (modelId.startsWith("o1-mini") || modelId.startsWith("o1-preview")) return {
2082
- isReasoningModel: true,
2083
- systemMessageMode: "remove",
2084
- requiredAutoTruncation: false
2085
- };
2086
- return {
2087
- isReasoningModel: true,
2088
- systemMessageMode: "developer",
2089
- requiredAutoTruncation: false
2090
- };
2091
- }
2092
- return {
2093
- isReasoningModel: false,
2094
- systemMessageMode: "system",
2095
- requiredAutoTruncation: false
2096
- };
2097
- }
2098
- var openaiResponsesProviderOptionsSchema = z$1.object({
2099
- metadata: z$1.any().nullish(),
2100
- parallelToolCalls: z$1.boolean().nullish(),
2101
- previousResponseId: z$1.string().nullish(),
2102
- store: z$1.boolean().nullish(),
2103
- user: z$1.string().nullish(),
2104
- reasoningEffort: z$1.string().nullish(),
2105
- strictSchemas: z$1.boolean().nullish(),
2106
- instructions: z$1.string().nullish(),
2107
- reasoningSummary: z$1.string().nullish()
2108
- });
2109
- var WebSearchPreviewParameters = z$1.object({});
2110
- function webSearchPreviewTool({ searchContextSize, userLocation } = {}) {
2111
- return {
2112
- type: "provider-defined",
2113
- id: "openai.web_search_preview",
2114
- args: {
2115
- searchContextSize,
2116
- userLocation
2117
- },
2118
- parameters: WebSearchPreviewParameters
2119
- };
2120
- }
2121
- var openaiTools = { webSearchPreview: webSearchPreviewTool };
2122
- var OpenAIProviderOptionsSchema = z$1.object({
2123
- instructions: z$1.string().nullish(),
2124
- speed: z$1.number().min(.25).max(4).default(1).nullish()
2125
- });
2126
- var OpenAISpeechModel = class {
2127
- constructor(modelId, config) {
2128
- this.modelId = modelId;
2129
- this.config = config;
2130
- this.specificationVersion = "v1";
2131
- }
2132
- get provider() {
2133
- return this.config.provider;
2134
- }
2135
- getArgs({ text, voice = "alloy", outputFormat = "mp3", speed, instructions, providerOptions }) {
2136
- const warnings = [];
2137
- const openAIOptions = parseProviderOptions({
2138
- provider: "openai",
2139
- providerOptions,
2140
- schema: OpenAIProviderOptionsSchema
2141
- });
2142
- const requestBody = {
2143
- model: this.modelId,
2144
- input: text,
2145
- voice,
2146
- response_format: "mp3",
2147
- speed,
2148
- instructions
2149
- };
2150
- if (outputFormat) if ([
2151
- "mp3",
2152
- "opus",
2153
- "aac",
2154
- "flac",
2155
- "wav",
2156
- "pcm"
2157
- ].includes(outputFormat)) requestBody.response_format = outputFormat;
2158
- else warnings.push({
2159
- type: "unsupported-setting",
2160
- setting: "outputFormat",
2161
- details: `Unsupported output format: ${outputFormat}. Using mp3 instead.`
2162
- });
2163
- if (openAIOptions) {
2164
- const speechModelOptions = {};
2165
- for (const key in speechModelOptions) {
2166
- const value = speechModelOptions[key];
2167
- if (value !== void 0) requestBody[key] = value;
2168
- }
2169
- }
2170
- return {
2171
- requestBody,
2172
- warnings
2173
- };
2174
- }
2175
- async doGenerate(options) {
2176
- var _a, _b, _c;
2177
- const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
2178
- const { requestBody, warnings } = this.getArgs(options);
2179
- const { value: audio, responseHeaders, rawValue: rawResponse } = await postJsonToApi({
2180
- url: this.config.url({
2181
- path: "/audio/speech",
2182
- modelId: this.modelId
2183
- }),
2184
- headers: combineHeaders(this.config.headers(), options.headers),
2185
- body: requestBody,
2186
- failedResponseHandler: openaiFailedResponseHandler,
2187
- successfulResponseHandler: createBinaryResponseHandler(),
2188
- abortSignal: options.abortSignal,
2189
- fetch: this.config.fetch
2190
- });
2191
- return {
2192
- audio,
2193
- warnings,
2194
- request: { body: JSON.stringify(requestBody) },
2195
- response: {
2196
- timestamp: currentDate,
2197
- modelId: this.modelId,
2198
- headers: responseHeaders,
2199
- body: rawResponse
2200
- }
2201
- };
2202
- }
2203
- };
2204
- function createOpenAI(options = {}) {
2205
- var _a, _b, _c;
2206
- const baseURL = (_a = withoutTrailingSlash(options.baseURL)) != null ? _a : "https://api.openai.com/v1";
2207
- const compatibility = (_b = options.compatibility) != null ? _b : "compatible";
2208
- const providerName = (_c = options.name) != null ? _c : "openai";
2209
- const getHeaders = () => ({
2210
- Authorization: `Bearer ${loadApiKey({
2211
- apiKey: options.apiKey,
2212
- environmentVariableName: "OPENAI_API_KEY",
2213
- description: "OpenAI"
2214
- })}`,
2215
- "OpenAI-Organization": options.organization,
2216
- "OpenAI-Project": options.project,
2217
- ...options.headers
2218
- });
2219
- const createChatModel = (modelId, settings = {}) => new OpenAIChatLanguageModel(modelId, settings, {
2220
- provider: `${providerName}.chat`,
2221
- url: ({ path }) => `${baseURL}${path}`,
2222
- headers: getHeaders,
2223
- compatibility,
2224
- fetch: options.fetch
2225
- });
2226
- const createCompletionModel = (modelId, settings = {}) => new OpenAICompletionLanguageModel(modelId, settings, {
2227
- provider: `${providerName}.completion`,
2228
- url: ({ path }) => `${baseURL}${path}`,
2229
- headers: getHeaders,
2230
- compatibility,
2231
- fetch: options.fetch
2232
- });
2233
- const createEmbeddingModel = (modelId, settings = {}) => new OpenAIEmbeddingModel(modelId, settings, {
2234
- provider: `${providerName}.embedding`,
2235
- url: ({ path }) => `${baseURL}${path}`,
2236
- headers: getHeaders,
2237
- fetch: options.fetch
2238
- });
2239
- const createImageModel = (modelId, settings = {}) => new OpenAIImageModel(modelId, settings, {
2240
- provider: `${providerName}.image`,
2241
- url: ({ path }) => `${baseURL}${path}`,
2242
- headers: getHeaders,
2243
- fetch: options.fetch
2244
- });
2245
- const createTranscriptionModel = (modelId) => new OpenAITranscriptionModel(modelId, {
2246
- provider: `${providerName}.transcription`,
2247
- url: ({ path }) => `${baseURL}${path}`,
2248
- headers: getHeaders,
2249
- fetch: options.fetch
2250
- });
2251
- const createSpeechModel = (modelId) => new OpenAISpeechModel(modelId, {
2252
- provider: `${providerName}.speech`,
2253
- url: ({ path }) => `${baseURL}${path}`,
2254
- headers: getHeaders,
2255
- fetch: options.fetch
2256
- });
2257
- const createLanguageModel = (modelId, settings) => {
2258
- if (new.target) throw new Error("The OpenAI model function cannot be called with the new keyword.");
2259
- if (modelId === "gpt-3.5-turbo-instruct") return createCompletionModel(modelId, settings);
2260
- return createChatModel(modelId, settings);
2261
- };
2262
- const createResponsesModel = (modelId) => {
2263
- return new OpenAIResponsesLanguageModel(modelId, {
2264
- provider: `${providerName}.responses`,
2265
- url: ({ path }) => `${baseURL}${path}`,
2266
- headers: getHeaders,
2267
- fetch: options.fetch
2268
- });
2269
- };
2270
- const provider = function(modelId, settings) {
2271
- return createLanguageModel(modelId, settings);
2272
- };
2273
- provider.languageModel = createLanguageModel;
2274
- provider.chat = createChatModel;
2275
- provider.completion = createCompletionModel;
2276
- provider.responses = createResponsesModel;
2277
- provider.embedding = createEmbeddingModel;
2278
- provider.textEmbedding = createEmbeddingModel;
2279
- provider.textEmbeddingModel = createEmbeddingModel;
2280
- provider.image = createImageModel;
2281
- provider.imageModel = createImageModel;
2282
- provider.transcription = createTranscriptionModel;
2283
- provider.transcriptionModel = createTranscriptionModel;
2284
- provider.speech = createSpeechModel;
2285
- provider.speechModel = createSpeechModel;
2286
- provider.tools = openaiTools;
2287
- return provider;
2288
- }
2289
- var openai = createOpenAI({ compatibility: "strict" });
2290
- //#endregion
2291
- export { openai };
2292
-
2293
- //# sourceMappingURL=dist-DcoIg_tp.js.map