@mastra/server 0.0.0-support-d1-client-20250701191943 → 0.0.0-suspendRuntimeContextTypeFix-20250930142630

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 (326) hide show
  1. package/CHANGELOG.md +3812 -0
  2. package/LICENSE.md +11 -42
  3. package/README.md +0 -5
  4. package/dist/{chunk-H5PTF3Y4.js → chunk-4QCXUEAT.js} +11 -2
  5. package/dist/chunk-4QCXUEAT.js.map +1 -0
  6. package/dist/chunk-4RRMWXQ2.js +3522 -0
  7. package/dist/chunk-4RRMWXQ2.js.map +1 -0
  8. package/dist/chunk-52UP7DFT.cjs +130 -0
  9. package/dist/chunk-52UP7DFT.cjs.map +1 -0
  10. package/dist/chunk-5DP5XZH6.cjs +928 -0
  11. package/dist/chunk-5DP5XZH6.cjs.map +1 -0
  12. package/dist/chunk-66YYHFGF.js +761 -0
  13. package/dist/chunk-66YYHFGF.js.map +1 -0
  14. package/dist/chunk-6GMFZ5LK.js +2774 -0
  15. package/dist/chunk-6GMFZ5LK.js.map +1 -0
  16. package/dist/{chunk-GHC4YV6R.js → chunk-6IJWRJZE.js} +109 -136
  17. package/dist/chunk-6IJWRJZE.js.map +1 -0
  18. package/dist/chunk-743UIDHI.cjs +2013 -0
  19. package/dist/chunk-743UIDHI.cjs.map +1 -0
  20. package/dist/chunk-7ESQBAXS.cjs +18023 -0
  21. package/dist/chunk-7ESQBAXS.cjs.map +1 -0
  22. package/dist/{chunk-OCWPVYNI.cjs → chunk-7NADHFD2.cjs} +3 -0
  23. package/dist/chunk-7NADHFD2.cjs.map +1 -0
  24. package/dist/{chunk-BOXE6WSV.js → chunk-A3AL7EWJ.js} +5 -3
  25. package/dist/chunk-A3AL7EWJ.js.map +1 -0
  26. package/dist/chunk-AK2FXLLB.cjs +849 -0
  27. package/dist/chunk-AK2FXLLB.cjs.map +1 -0
  28. package/dist/chunk-BKCWZLEL.cjs +197 -0
  29. package/dist/chunk-BKCWZLEL.cjs.map +1 -0
  30. package/dist/chunk-BOVFMBXY.js +607 -0
  31. package/dist/chunk-BOVFMBXY.js.map +1 -0
  32. package/dist/{chunk-QDOJJCS4.js → chunk-CY4TP3FK.js} +6 -2
  33. package/dist/chunk-CY4TP3FK.js.map +1 -0
  34. package/dist/chunk-EMMSS5I5.cjs +37 -0
  35. package/dist/chunk-EMMSS5I5.cjs.map +1 -0
  36. package/dist/chunk-EMNGA4R4.js +845 -0
  37. package/dist/chunk-EMNGA4R4.js.map +1 -0
  38. package/dist/chunk-FALVL2VV.cjs +3525 -0
  39. package/dist/chunk-FALVL2VV.cjs.map +1 -0
  40. package/dist/chunk-FQNT7PI4.js +937 -0
  41. package/dist/chunk-FQNT7PI4.js.map +1 -0
  42. package/dist/chunk-G3PMV62Z.js +33 -0
  43. package/dist/chunk-G3PMV62Z.js.map +1 -0
  44. package/dist/chunk-G4PUALCE.cjs +28 -0
  45. package/dist/chunk-G4PUALCE.cjs.map +1 -0
  46. package/dist/chunk-GU4EWMZB.cjs +769 -0
  47. package/dist/chunk-GU4EWMZB.cjs.map +1 -0
  48. package/dist/chunk-HJQKWRKQ.cjs +764 -0
  49. package/dist/chunk-HJQKWRKQ.cjs.map +1 -0
  50. package/dist/{chunk-LI436ITD.cjs → chunk-HVBBFCDH.cjs} +1041 -762
  51. package/dist/chunk-HVBBFCDH.cjs.map +1 -0
  52. package/dist/chunk-HZJRQ5L3.cjs +1411 -0
  53. package/dist/chunk-HZJRQ5L3.cjs.map +1 -0
  54. package/dist/chunk-IGFMAZZ5.cjs +1150 -0
  55. package/dist/chunk-IGFMAZZ5.cjs.map +1 -0
  56. package/dist/chunk-IOQGI4ML.js +931 -0
  57. package/dist/chunk-IOQGI4ML.js.map +1 -0
  58. package/dist/chunk-JQ74G5IO.js +17987 -0
  59. package/dist/chunk-JQ74G5IO.js.map +1 -0
  60. package/dist/{chunk-G37NVEDX.js → chunk-JRDEOHAJ.js} +23 -13
  61. package/dist/chunk-JRDEOHAJ.js.map +1 -0
  62. package/dist/chunk-JSMP6GVP.cjs +595 -0
  63. package/dist/chunk-JSMP6GVP.cjs.map +1 -0
  64. package/dist/{chunk-DFJUGWNU.js → chunk-KM7EJKXV.js} +50 -12
  65. package/dist/chunk-KM7EJKXV.js.map +1 -0
  66. package/dist/{chunk-TGZIR6AK.cjs → chunk-KNGXRN26.cjs} +48 -45
  67. package/dist/chunk-KNGXRN26.cjs.map +1 -0
  68. package/dist/{chunk-BP24Z4WG.js → chunk-KV6VHX4V.js} +24 -5
  69. package/dist/chunk-KV6VHX4V.js.map +1 -0
  70. package/dist/chunk-LF2ZLOFP.js +767 -0
  71. package/dist/chunk-LF2ZLOFP.js.map +1 -0
  72. package/dist/chunk-LJFAAEU7.cjs +167 -0
  73. package/dist/chunk-LJFAAEU7.cjs.map +1 -0
  74. package/dist/chunk-LYPU75T6.js +1147 -0
  75. package/dist/chunk-LYPU75T6.js.map +1 -0
  76. package/dist/{chunk-NYN7KFXL.js → chunk-MMROOK5J.js} +3 -0
  77. package/dist/chunk-MMROOK5J.js.map +1 -0
  78. package/dist/{chunk-MEGCYGBU.js → chunk-N7F33WAD.js} +1013 -762
  79. package/dist/chunk-N7F33WAD.js.map +1 -0
  80. package/dist/chunk-NG5IVLEZ.js +1012 -0
  81. package/dist/chunk-NG5IVLEZ.js.map +1 -0
  82. package/dist/chunk-NLWACBE7.cjs +128 -0
  83. package/dist/chunk-NLWACBE7.cjs.map +1 -0
  84. package/dist/chunk-OGW6HHVI.js +1408 -0
  85. package/dist/chunk-OGW6HHVI.js.map +1 -0
  86. package/dist/{chunk-SDPGVWQJ.cjs → chunk-OPI3FZYH.cjs} +110 -137
  87. package/dist/chunk-OPI3FZYH.cjs.map +1 -0
  88. package/dist/chunk-OZLRIVC4.cjs +588 -0
  89. package/dist/chunk-OZLRIVC4.cjs.map +1 -0
  90. package/dist/chunk-P7CIEIJ3.js +925 -0
  91. package/dist/chunk-P7CIEIJ3.js.map +1 -0
  92. package/dist/chunk-P7RBMCBE.cjs +934 -0
  93. package/dist/chunk-P7RBMCBE.cjs.map +1 -0
  94. package/dist/chunk-PPYGWINI.cjs +2777 -0
  95. package/dist/chunk-PPYGWINI.cjs.map +1 -0
  96. package/dist/{chunk-ULFULEW4.cjs → chunk-PWTXZZTR.cjs} +28 -8
  97. package/dist/chunk-PWTXZZTR.cjs.map +1 -0
  98. package/dist/chunk-RCHEPTZZ.js +2006 -0
  99. package/dist/chunk-RCHEPTZZ.js.map +1 -0
  100. package/dist/chunk-RE4RPXT2.cjs +18 -0
  101. package/dist/chunk-RE4RPXT2.cjs.map +1 -0
  102. package/dist/chunk-SIGXR3JT.cjs +1043 -0
  103. package/dist/chunk-SIGXR3JT.cjs.map +1 -0
  104. package/dist/{chunk-CNVDCLSY.cjs → chunk-SPLSYTYW.cjs} +11 -9
  105. package/dist/chunk-SPLSYTYW.cjs.map +1 -0
  106. package/dist/chunk-SQY4T6EJ.js +571 -0
  107. package/dist/chunk-SQY4T6EJ.js.map +1 -0
  108. package/dist/chunk-SXENNNR7.cjs +625 -0
  109. package/dist/chunk-SXENNNR7.cjs.map +1 -0
  110. package/dist/{chunk-TVBPFPTN.cjs → chunk-T3TIA3O6.cjs} +20 -18
  111. package/dist/chunk-T3TIA3O6.cjs.map +1 -0
  112. package/dist/{chunk-7GQJAMTA.js → chunk-TTHEEIZ3.js} +13 -10
  113. package/dist/chunk-TTHEEIZ3.js.map +1 -0
  114. package/dist/chunk-TVSIG4JE.cjs +940 -0
  115. package/dist/chunk-TVSIG4JE.cjs.map +1 -0
  116. package/dist/chunk-VY4ENABS.cjs +135 -0
  117. package/dist/chunk-VY4ENABS.cjs.map +1 -0
  118. package/dist/{chunk-FVMGZKFD.js → chunk-WHN4VX55.js} +5 -3
  119. package/dist/chunk-WHN4VX55.js.map +1 -0
  120. package/dist/chunk-WUJLVNLU.js +124 -0
  121. package/dist/chunk-WUJLVNLU.js.map +1 -0
  122. package/dist/chunk-XJOYGRTN.js +189 -0
  123. package/dist/chunk-XJOYGRTN.js.map +1 -0
  124. package/dist/chunk-YWOK4F5A.js +131 -0
  125. package/dist/chunk-YWOK4F5A.js.map +1 -0
  126. package/dist/{chunk-Z5TH5F35.js → chunk-ZAYTLC6C.js} +188 -80
  127. package/dist/chunk-ZAYTLC6C.js.map +1 -0
  128. package/dist/dist-26HWEQY6.js +3 -0
  129. package/dist/dist-26HWEQY6.js.map +1 -0
  130. package/dist/dist-3A5DXB37.cjs +20 -0
  131. package/dist/dist-3A5DXB37.cjs.map +1 -0
  132. package/dist/dist-3SJKQJGY.cjs +16 -0
  133. package/dist/dist-3SJKQJGY.cjs.map +1 -0
  134. package/dist/dist-4ZQSPE5K.js +3 -0
  135. package/dist/dist-4ZQSPE5K.js.map +1 -0
  136. package/dist/dist-5W5QNRTD.js +3 -0
  137. package/dist/dist-5W5QNRTD.js.map +1 -0
  138. package/dist/dist-653SRMPL.js +3 -0
  139. package/dist/dist-653SRMPL.js.map +1 -0
  140. package/dist/dist-6U6EFC5C.cjs +16 -0
  141. package/dist/dist-6U6EFC5C.cjs.map +1 -0
  142. package/dist/dist-7IHNNYMF.cjs +16 -0
  143. package/dist/dist-7IHNNYMF.cjs.map +1 -0
  144. package/dist/dist-B5IPRF6W.js +3 -0
  145. package/dist/dist-B5IPRF6W.js.map +1 -0
  146. package/dist/dist-EOMYFT4Y.cjs +16 -0
  147. package/dist/dist-EOMYFT4Y.cjs.map +1 -0
  148. package/dist/dist-EZZMMMNT.cjs +16 -0
  149. package/dist/dist-EZZMMMNT.cjs.map +1 -0
  150. package/dist/dist-F2ET4MNO.cjs +16 -0
  151. package/dist/dist-F2ET4MNO.cjs.map +1 -0
  152. package/dist/dist-H64VX6DE.js +3 -0
  153. package/dist/dist-H64VX6DE.js.map +1 -0
  154. package/dist/dist-HY7RMLJQ.cjs +16 -0
  155. package/dist/dist-HY7RMLJQ.cjs.map +1 -0
  156. package/dist/dist-M6S4P3FJ.js +3 -0
  157. package/dist/dist-M6S4P3FJ.js.map +1 -0
  158. package/dist/dist-NR7QSCQT.js +3 -0
  159. package/dist/dist-NR7QSCQT.js.map +1 -0
  160. package/dist/dist-QLFMCMCX.js +3 -0
  161. package/dist/dist-QLFMCMCX.js.map +1 -0
  162. package/dist/dist-UY46BFRP.js +3 -0
  163. package/dist/dist-UY46BFRP.js.map +1 -0
  164. package/dist/dist-WCQDRTIV.cjs +16 -0
  165. package/dist/dist-WCQDRTIV.cjs.map +1 -0
  166. package/dist/dist-WKYB3LTJ.cjs +16 -0
  167. package/dist/dist-WKYB3LTJ.cjs.map +1 -0
  168. package/dist/index.cjs +6 -0
  169. package/dist/index.cjs.map +1 -0
  170. package/dist/index.d.ts +1 -0
  171. package/dist/index.d.ts.map +1 -0
  172. package/dist/index.js +5 -0
  173. package/dist/index.js.map +1 -0
  174. package/dist/server/a2a/protocol.d.ts +8 -0
  175. package/dist/server/a2a/protocol.d.ts.map +1 -0
  176. package/dist/server/a2a/store.cjs +25 -0
  177. package/dist/server/a2a/store.cjs.map +1 -0
  178. package/dist/server/a2a/store.d.ts +14 -0
  179. package/dist/server/a2a/store.d.ts.map +1 -0
  180. package/dist/server/a2a/store.js +23 -0
  181. package/dist/server/a2a/store.js.map +1 -0
  182. package/dist/server/a2a/tasks.d.ts +20 -0
  183. package/dist/server/a2a/tasks.d.ts.map +1 -0
  184. package/dist/server/handlers/a2a.cjs +13 -11
  185. package/dist/server/handlers/a2a.cjs.map +1 -0
  186. package/dist/server/handlers/a2a.d.ts +68 -6
  187. package/dist/server/handlers/a2a.d.ts.map +1 -0
  188. package/dist/server/handlers/a2a.js +3 -1
  189. package/dist/server/handlers/a2a.js.map +1 -0
  190. package/dist/server/handlers/agent-builder.cjs +68 -0
  191. package/dist/server/handlers/agent-builder.cjs.map +1 -0
  192. package/dist/server/handlers/agent-builder.d.ts +92 -0
  193. package/dist/server/handlers/agent-builder.d.ts.map +1 -0
  194. package/dist/server/handlers/agent-builder.js +3 -0
  195. package/dist/server/handlers/agent-builder.js.map +1 -0
  196. package/dist/server/handlers/agents.cjs +49 -7
  197. package/dist/server/handlers/agents.cjs.map +1 -0
  198. package/dist/server/handlers/agents.d.ts +185 -6
  199. package/dist/server/handlers/agents.d.ts.map +1 -0
  200. package/dist/server/handlers/agents.js +3 -1
  201. package/dist/server/handlers/agents.js.map +1 -0
  202. package/dist/server/handlers/error.cjs +4 -2
  203. package/dist/server/handlers/error.cjs.map +1 -0
  204. package/dist/server/handlers/error.d.ts +2 -1
  205. package/dist/server/handlers/error.d.ts.map +1 -0
  206. package/dist/server/handlers/error.js +3 -1
  207. package/dist/server/handlers/error.js.map +1 -0
  208. package/dist/server/handlers/legacyWorkflows.cjs +13 -11
  209. package/dist/server/handlers/legacyWorkflows.cjs.map +1 -0
  210. package/dist/server/handlers/legacyWorkflows.d.ts +59 -10
  211. package/dist/server/handlers/legacyWorkflows.d.ts.map +1 -0
  212. package/dist/server/handlers/legacyWorkflows.js +3 -1
  213. package/dist/server/handlers/legacyWorkflows.js.map +1 -0
  214. package/dist/server/handlers/logs.cjs +6 -4
  215. package/dist/server/handlers/logs.cjs.map +1 -0
  216. package/dist/server/handlers/logs.d.ts +34 -3
  217. package/dist/server/handlers/logs.d.ts.map +1 -0
  218. package/dist/server/handlers/logs.js +3 -1
  219. package/dist/server/handlers/logs.js.map +1 -0
  220. package/dist/server/handlers/memory.cjs +39 -9
  221. package/dist/server/handlers/memory.cjs.map +1 -0
  222. package/dist/server/handlers/memory.d.ts +118 -8
  223. package/dist/server/handlers/memory.d.ts.map +1 -0
  224. package/dist/server/handlers/memory.js +3 -1
  225. package/dist/server/handlers/memory.js.map +1 -0
  226. package/dist/server/handlers/observability.cjs +24 -0
  227. package/dist/server/handlers/observability.cjs.map +1 -0
  228. package/dist/server/handlers/observability.d.ts +49 -0
  229. package/dist/server/handlers/observability.d.ts.map +1 -0
  230. package/dist/server/handlers/observability.js +3 -0
  231. package/dist/server/handlers/observability.js.map +1 -0
  232. package/dist/server/handlers/scores.cjs +32 -0
  233. package/dist/server/handlers/scores.cjs.map +1 -0
  234. package/dist/server/handlers/scores.d.ts +251 -0
  235. package/dist/server/handlers/scores.d.ts.map +1 -0
  236. package/dist/server/handlers/scores.js +3 -0
  237. package/dist/server/handlers/scores.js.map +1 -0
  238. package/dist/server/handlers/telemetry.cjs +9 -3
  239. package/dist/server/handlers/telemetry.cjs.map +1 -0
  240. package/dist/server/handlers/telemetry.d.ts +33 -2
  241. package/dist/server/handlers/telemetry.d.ts.map +1 -0
  242. package/dist/server/handlers/telemetry.js +3 -1
  243. package/dist/server/handlers/telemetry.js.map +1 -0
  244. package/dist/server/handlers/tools.cjs +11 -5
  245. package/dist/server/handlers/tools.cjs.map +1 -0
  246. package/dist/server/handlers/tools.d.ts +25 -4
  247. package/dist/server/handlers/tools.d.ts.map +1 -0
  248. package/dist/server/handlers/tools.js +3 -1
  249. package/dist/server/handlers/tools.js.map +1 -0
  250. package/dist/server/handlers/utils.cjs +8 -2
  251. package/dist/server/handlers/utils.cjs.map +1 -0
  252. package/dist/server/handlers/utils.d.ts +8 -1
  253. package/dist/server/handlers/utils.d.ts.map +1 -0
  254. package/dist/server/handlers/utils.js +3 -1
  255. package/dist/server/handlers/utils.js.map +1 -0
  256. package/dist/server/handlers/vNextNetwork.cjs +26 -24
  257. package/dist/server/handlers/vNextNetwork.cjs.map +1 -0
  258. package/dist/server/handlers/vNextNetwork.d.ts +246 -6
  259. package/dist/server/handlers/vNextNetwork.d.ts.map +1 -0
  260. package/dist/server/handlers/vNextNetwork.js +11 -9
  261. package/dist/server/handlers/vNextNetwork.js.map +1 -0
  262. package/dist/server/handlers/vector.cjs +9 -7
  263. package/dist/server/handlers/vector.cjs.map +1 -0
  264. package/dist/server/handlers/vector.d.ts +51 -6
  265. package/dist/server/handlers/vector.d.ts.map +1 -0
  266. package/dist/server/handlers/vector.js +3 -1
  267. package/dist/server/handlers/vector.js.map +1 -0
  268. package/dist/server/handlers/voice.cjs +7 -5
  269. package/dist/server/handlers/voice.cjs.map +1 -0
  270. package/dist/server/handlers/voice.d.ts +41 -4
  271. package/dist/server/handlers/voice.d.ts.map +1 -0
  272. package/dist/server/handlers/voice.js +3 -1
  273. package/dist/server/handlers/voice.js.map +1 -0
  274. package/dist/server/handlers/workflows.cjs +32 -14
  275. package/dist/server/handlers/workflows.cjs.map +1 -0
  276. package/dist/server/handlers/workflows.d.ts +87 -13
  277. package/dist/server/handlers/workflows.d.ts.map +1 -0
  278. package/dist/server/handlers/workflows.js +3 -1
  279. package/dist/server/handlers/workflows.js.map +1 -0
  280. package/dist/server/handlers.cjs +44 -32
  281. package/dist/server/handlers.cjs.map +1 -0
  282. package/dist/server/handlers.d.ts +14 -11
  283. package/dist/server/handlers.d.ts.map +1 -0
  284. package/dist/server/handlers.js +15 -11
  285. package/dist/server/handlers.js.map +1 -0
  286. package/dist/server/http-exception.d.ts +87 -0
  287. package/dist/server/http-exception.d.ts.map +1 -0
  288. package/dist/server/types.d.ts +10 -0
  289. package/dist/server/types.d.ts.map +1 -0
  290. package/dist/server/utils.d.ts +44 -0
  291. package/dist/server/utils.d.ts.map +1 -0
  292. package/package.json +46 -15
  293. package/dist/_tsup-dts-rollup.d.cts +0 -1068
  294. package/dist/_tsup-dts-rollup.d.ts +0 -1068
  295. package/dist/chunk-3DKDT264.cjs +0 -251
  296. package/dist/chunk-4QBIUKVY.js +0 -270
  297. package/dist/chunk-57CJTIPW.cjs +0 -18
  298. package/dist/chunk-7524QH7G.cjs +0 -483
  299. package/dist/chunk-75ZPJI57.cjs +0 -9
  300. package/dist/chunk-BWHGBV3K.cjs +0 -278
  301. package/dist/chunk-DPRB3R7Y.cjs +0 -148
  302. package/dist/chunk-FGGMQCPP.cjs +0 -128
  303. package/dist/chunk-L3N7ST2Z.cjs +0 -118
  304. package/dist/chunk-LTJNMM2Y.js +0 -241
  305. package/dist/chunk-MLKGABMK.js +0 -7
  306. package/dist/chunk-MTR2B27E.cjs +0 -14
  307. package/dist/chunk-VMXLEF54.js +0 -142
  308. package/dist/index.d.cts +0 -1
  309. package/dist/server/handlers/a2a.d.cts +0 -6
  310. package/dist/server/handlers/agents.d.cts +0 -6
  311. package/dist/server/handlers/error.d.cts +0 -1
  312. package/dist/server/handlers/legacyWorkflows.d.cts +0 -10
  313. package/dist/server/handlers/logs.d.cts +0 -3
  314. package/dist/server/handlers/memory.d.cts +0 -8
  315. package/dist/server/handlers/network.cjs +0 -22
  316. package/dist/server/handlers/network.d.cts +0 -4
  317. package/dist/server/handlers/network.d.ts +0 -4
  318. package/dist/server/handlers/network.js +0 -1
  319. package/dist/server/handlers/telemetry.d.cts +0 -2
  320. package/dist/server/handlers/tools.d.cts +0 -4
  321. package/dist/server/handlers/utils.d.cts +0 -1
  322. package/dist/server/handlers/vNextNetwork.d.cts +0 -6
  323. package/dist/server/handlers/vector.d.cts +0 -6
  324. package/dist/server/handlers/voice.d.cts +0 -4
  325. package/dist/server/handlers/workflows.d.cts +0 -13
  326. package/dist/server/handlers.d.cts +0 -11
@@ -2,771 +2,423 @@
2
2
 
3
3
  var zod = require('zod');
4
4
 
5
- // ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/double-indexed-kv.js
6
- var DoubleIndexedKV = class {
7
- constructor() {
8
- this.keyToValue = /* @__PURE__ */ new Map();
9
- this.valueToKey = /* @__PURE__ */ new Map();
10
- }
11
- set(key, value) {
12
- this.keyToValue.set(key, value);
13
- this.valueToKey.set(value, key);
14
- }
15
- getByKey(key) {
16
- return this.keyToValue.get(key);
5
+ // ../../node_modules/.pnpm/@ai-sdk+provider@2.0.0/node_modules/@ai-sdk/provider/dist/index.mjs
6
+ var marker = "vercel.ai.error";
7
+ var symbol = Symbol.for(marker);
8
+ var _a;
9
+ var _AISDKError = class _AISDKError2 extends Error {
10
+ /**
11
+ * Creates an AI SDK Error.
12
+ *
13
+ * @param {Object} params - The parameters for creating the error.
14
+ * @param {string} params.name - The name of the error.
15
+ * @param {string} params.message - The error message.
16
+ * @param {unknown} [params.cause] - The underlying cause of the error.
17
+ */
18
+ constructor({
19
+ name: name14,
20
+ message,
21
+ cause
22
+ }) {
23
+ super(message);
24
+ this[_a] = true;
25
+ this.name = name14;
26
+ this.cause = cause;
17
27
  }
18
- getByValue(value) {
19
- return this.valueToKey.get(value);
28
+ /**
29
+ * Checks if the given error is an AI SDK Error.
30
+ * @param {unknown} error - The error to check.
31
+ * @returns {boolean} True if the error is an AI SDK Error, false otherwise.
32
+ */
33
+ static isInstance(error) {
34
+ return _AISDKError2.hasMarker(error, marker);
20
35
  }
21
- clear() {
22
- this.keyToValue.clear();
23
- this.valueToKey.clear();
36
+ static hasMarker(error, marker15) {
37
+ const markerSymbol = Symbol.for(marker15);
38
+ return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
24
39
  }
25
40
  };
26
-
27
- // ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/registry.js
28
- var Registry = class {
29
- constructor(generateIdentifier) {
30
- this.generateIdentifier = generateIdentifier;
31
- this.kv = new DoubleIndexedKV();
32
- }
33
- register(value, identifier) {
34
- if (this.kv.getByValue(value)) {
35
- return;
36
- }
37
- if (!identifier) {
38
- identifier = this.generateIdentifier(value);
39
- }
40
- this.kv.set(identifier, value);
41
- }
42
- clear() {
43
- this.kv.clear();
44
- }
45
- getIdentifier(value) {
46
- return this.kv.getByValue(value);
47
- }
48
- getValue(identifier) {
49
- return this.kv.getByKey(identifier);
41
+ _a = symbol;
42
+ var AISDKError = _AISDKError;
43
+ var name = "AI_APICallError";
44
+ var marker2 = `vercel.ai.error.${name}`;
45
+ var symbol2 = Symbol.for(marker2);
46
+ var _a2;
47
+ var APICallError = class extends AISDKError {
48
+ constructor({
49
+ message,
50
+ url,
51
+ requestBodyValues,
52
+ statusCode,
53
+ responseHeaders,
54
+ responseBody,
55
+ cause,
56
+ isRetryable = statusCode != null && (statusCode === 408 || // request timeout
57
+ statusCode === 409 || // conflict
58
+ statusCode === 429 || // too many requests
59
+ statusCode >= 500),
60
+ // server error
61
+ data
62
+ }) {
63
+ super({ name, message, cause });
64
+ this[_a2] = true;
65
+ this.url = url;
66
+ this.requestBodyValues = requestBodyValues;
67
+ this.statusCode = statusCode;
68
+ this.responseHeaders = responseHeaders;
69
+ this.responseBody = responseBody;
70
+ this.isRetryable = isRetryable;
71
+ this.data = data;
72
+ }
73
+ static isInstance(error) {
74
+ return AISDKError.hasMarker(error, marker2);
50
75
  }
51
76
  };
52
-
53
- // ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/class-registry.js
54
- var ClassRegistry = class extends Registry {
55
- constructor() {
56
- super((c) => c.name);
57
- this.classToAllowedProps = /* @__PURE__ */ new Map();
58
- }
59
- register(value, options) {
60
- if (typeof options === "object") {
61
- if (options.allowProps) {
62
- this.classToAllowedProps.set(value, options.allowProps);
63
- }
64
- super.register(value, options.identifier);
65
- } else {
66
- super.register(value, options);
67
- }
68
- }
69
- getAllowedProps(value) {
70
- return this.classToAllowedProps.get(value);
77
+ _a2 = symbol2;
78
+ var name2 = "AI_EmptyResponseBodyError";
79
+ var marker3 = `vercel.ai.error.${name2}`;
80
+ var symbol3 = Symbol.for(marker3);
81
+ var _a3;
82
+ var EmptyResponseBodyError = class extends AISDKError {
83
+ // used in isInstance
84
+ constructor({ message = "Empty response body" } = {}) {
85
+ super({ name: name2, message });
86
+ this[_a3] = true;
87
+ }
88
+ static isInstance(error) {
89
+ return AISDKError.hasMarker(error, marker3);
71
90
  }
72
91
  };
73
-
74
- // ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/util.js
75
- function valuesOfObj(record) {
76
- if ("values" in Object) {
77
- return Object.values(record);
78
- }
79
- const values = [];
80
- for (const key in record) {
81
- if (record.hasOwnProperty(key)) {
82
- values.push(record[key]);
83
- }
92
+ _a3 = symbol3;
93
+ function getErrorMessage(error) {
94
+ if (error == null) {
95
+ return "unknown error";
84
96
  }
85
- return values;
86
- }
87
- function find(record, predicate) {
88
- const values = valuesOfObj(record);
89
- if ("find" in values) {
90
- return values.find(predicate);
97
+ if (typeof error === "string") {
98
+ return error;
91
99
  }
92
- const valuesNotNever = values;
93
- for (let i = 0; i < valuesNotNever.length; i++) {
94
- const value = valuesNotNever[i];
95
- if (predicate(value)) {
96
- return value;
97
- }
98
- }
99
- return void 0;
100
- }
101
- function forEach(record, run) {
102
- Object.entries(record).forEach(([key, value]) => run(value, key));
103
- }
104
- function includes(arr, value) {
105
- return arr.indexOf(value) !== -1;
106
- }
107
- function findArr(record, predicate) {
108
- for (let i = 0; i < record.length; i++) {
109
- const value = record[i];
110
- if (predicate(value)) {
111
- return value;
112
- }
100
+ if (error instanceof Error) {
101
+ return error.message;
113
102
  }
114
- return void 0;
103
+ return JSON.stringify(error);
115
104
  }
116
-
117
- // ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/custom-transformer-registry.js
118
- var CustomTransformerRegistry = class {
119
- constructor() {
120
- this.transfomers = {};
121
- }
122
- register(transformer) {
123
- this.transfomers[transformer.name] = transformer;
124
- }
125
- findApplicable(v) {
126
- return find(this.transfomers, (transformer) => transformer.isApplicable(v));
127
- }
128
- findByName(name) {
129
- return this.transfomers[name];
105
+ var name3 = "AI_InvalidArgumentError";
106
+ var marker4 = `vercel.ai.error.${name3}`;
107
+ var symbol4 = Symbol.for(marker4);
108
+ var _a4;
109
+ var InvalidArgumentError = class extends AISDKError {
110
+ constructor({
111
+ message,
112
+ cause,
113
+ argument
114
+ }) {
115
+ super({ name: name3, message, cause });
116
+ this[_a4] = true;
117
+ this.argument = argument;
118
+ }
119
+ static isInstance(error) {
120
+ return AISDKError.hasMarker(error, marker4);
130
121
  }
131
122
  };
132
-
133
- // ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/is.js
134
- var getType = (payload) => Object.prototype.toString.call(payload).slice(8, -1);
135
- var isUndefined = (payload) => typeof payload === "undefined";
136
- var isNull = (payload) => payload === null;
137
- var isPlainObject = (payload) => {
138
- if (typeof payload !== "object" || payload === null)
139
- return false;
140
- if (payload === Object.prototype)
141
- return false;
142
- if (Object.getPrototypeOf(payload) === null)
143
- return true;
144
- return Object.getPrototypeOf(payload) === Object.prototype;
123
+ _a4 = symbol4;
124
+ var name4 = "AI_InvalidPromptError";
125
+ var marker5 = `vercel.ai.error.${name4}`;
126
+ var symbol5 = Symbol.for(marker5);
127
+ var _a5;
128
+ var InvalidPromptError = class extends AISDKError {
129
+ constructor({
130
+ prompt,
131
+ message,
132
+ cause
133
+ }) {
134
+ super({ name: name4, message: `Invalid prompt: ${message}`, cause });
135
+ this[_a5] = true;
136
+ this.prompt = prompt;
137
+ }
138
+ static isInstance(error) {
139
+ return AISDKError.hasMarker(error, marker5);
140
+ }
145
141
  };
146
- var isEmptyObject = (payload) => isPlainObject(payload) && Object.keys(payload).length === 0;
147
- var isArray = (payload) => Array.isArray(payload);
148
- var isString = (payload) => typeof payload === "string";
149
- var isNumber = (payload) => typeof payload === "number" && !isNaN(payload);
150
- var isBoolean = (payload) => typeof payload === "boolean";
151
- var isRegExp = (payload) => payload instanceof RegExp;
152
- var isMap = (payload) => payload instanceof Map;
153
- var isSet = (payload) => payload instanceof Set;
154
- var isSymbol = (payload) => getType(payload) === "Symbol";
155
- var isDate = (payload) => payload instanceof Date && !isNaN(payload.valueOf());
156
- var isError = (payload) => payload instanceof Error;
157
- var isNaNValue = (payload) => typeof payload === "number" && isNaN(payload);
158
- var isPrimitive = (payload) => isBoolean(payload) || isNull(payload) || isUndefined(payload) || isNumber(payload) || isString(payload) || isSymbol(payload);
159
- var isBigint = (payload) => typeof payload === "bigint";
160
- var isInfinite = (payload) => payload === Infinity || payload === -Infinity;
161
- var isTypedArray = (payload) => ArrayBuffer.isView(payload) && !(payload instanceof DataView);
162
- var isURL = (payload) => payload instanceof URL;
163
-
164
- // ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/pathstringifier.js
165
- var escapeKey = (key) => key.replace(/\./g, "\\.");
166
- var stringifyPath = (path) => path.map(String).map(escapeKey).join(".");
167
- var parsePath = (string) => {
168
- const result = [];
169
- let segment = "";
170
- for (let i = 0; i < string.length; i++) {
171
- let char = string.charAt(i);
172
- const isEscapedDot = char === "\\" && string.charAt(i + 1) === ".";
173
- if (isEscapedDot) {
174
- segment += ".";
175
- i++;
176
- continue;
177
- }
178
- const isEndOfSegment = char === ".";
179
- if (isEndOfSegment) {
180
- result.push(segment);
181
- segment = "";
182
- continue;
183
- }
184
- segment += char;
142
+ _a5 = symbol5;
143
+ var name5 = "AI_InvalidResponseDataError";
144
+ var marker6 = `vercel.ai.error.${name5}`;
145
+ var symbol6 = Symbol.for(marker6);
146
+ var _a6;
147
+ var InvalidResponseDataError = class extends AISDKError {
148
+ constructor({
149
+ data,
150
+ message = `Invalid response data: ${JSON.stringify(data)}.`
151
+ }) {
152
+ super({ name: name5, message });
153
+ this[_a6] = true;
154
+ this.data = data;
155
+ }
156
+ static isInstance(error) {
157
+ return AISDKError.hasMarker(error, marker6);
185
158
  }
186
- const lastSegment = segment;
187
- result.push(lastSegment);
188
- return result;
189
159
  };
190
-
191
- // ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/transformer.js
192
- function simpleTransformation(isApplicable, annotation, transform, untransform) {
193
- return {
194
- isApplicable,
195
- annotation,
196
- transform,
197
- untransform
198
- };
199
- }
200
- var simpleRules = [
201
- simpleTransformation(isUndefined, "undefined", () => null, () => void 0),
202
- simpleTransformation(isBigint, "bigint", (v) => v.toString(), (v) => {
203
- if (typeof BigInt !== "undefined") {
204
- return BigInt(v);
205
- }
206
- console.error("Please add a BigInt polyfill.");
207
- return v;
208
- }),
209
- simpleTransformation(isDate, "Date", (v) => v.toISOString(), (v) => new Date(v)),
210
- simpleTransformation(isError, "Error", (v, superJson) => {
211
- const baseError = {
212
- name: v.name,
213
- message: v.message
214
- };
215
- superJson.allowedErrorProps.forEach((prop) => {
216
- baseError[prop] = v[prop];
160
+ _a6 = symbol6;
161
+ var name6 = "AI_JSONParseError";
162
+ var marker7 = `vercel.ai.error.${name6}`;
163
+ var symbol7 = Symbol.for(marker7);
164
+ var _a7;
165
+ var JSONParseError = class extends AISDKError {
166
+ constructor({ text, cause }) {
167
+ super({
168
+ name: name6,
169
+ message: `JSON parsing failed: Text: ${text}.
170
+ Error message: ${getErrorMessage(cause)}`,
171
+ cause
217
172
  });
218
- return baseError;
219
- }, (v, superJson) => {
220
- const e = new Error(v.message);
221
- e.name = v.name;
222
- e.stack = v.stack;
223
- superJson.allowedErrorProps.forEach((prop) => {
224
- e[prop] = v[prop];
225
- });
226
- return e;
227
- }),
228
- simpleTransformation(isRegExp, "regexp", (v) => "" + v, (regex) => {
229
- const body = regex.slice(1, regex.lastIndexOf("/"));
230
- const flags = regex.slice(regex.lastIndexOf("/") + 1);
231
- return new RegExp(body, flags);
232
- }),
233
- simpleTransformation(
234
- isSet,
235
- "set",
236
- // (sets only exist in es6+)
237
- // eslint-disable-next-line es5/no-es6-methods
238
- (v) => [...v.values()],
239
- (v) => new Set(v)
240
- ),
241
- simpleTransformation(isMap, "map", (v) => [...v.entries()], (v) => new Map(v)),
242
- simpleTransformation((v) => isNaNValue(v) || isInfinite(v), "number", (v) => {
243
- if (isNaNValue(v)) {
244
- return "NaN";
245
- }
246
- if (v > 0) {
247
- return "Infinity";
248
- } else {
249
- return "-Infinity";
250
- }
251
- }, Number),
252
- simpleTransformation((v) => v === 0 && 1 / v === -Infinity, "number", () => {
253
- return "-0";
254
- }, Number),
255
- simpleTransformation(isURL, "URL", (v) => v.toString(), (v) => new URL(v))
256
- ];
257
- function compositeTransformation(isApplicable, annotation, transform, untransform) {
258
- return {
259
- isApplicable,
260
- annotation,
261
- transform,
262
- untransform
263
- };
264
- }
265
- var symbolRule = compositeTransformation((s, superJson) => {
266
- if (isSymbol(s)) {
267
- const isRegistered = !!superJson.symbolRegistry.getIdentifier(s);
268
- return isRegistered;
269
- }
270
- return false;
271
- }, (s, superJson) => {
272
- const identifier = superJson.symbolRegistry.getIdentifier(s);
273
- return ["symbol", identifier];
274
- }, (v) => v.description, (_, a, superJson) => {
275
- const value = superJson.symbolRegistry.getValue(a[1]);
276
- if (!value) {
277
- throw new Error("Trying to deserialize unknown symbol");
278
- }
279
- return value;
280
- });
281
- var constructorToName = [
282
- Int8Array,
283
- Uint8Array,
284
- Int16Array,
285
- Uint16Array,
286
- Int32Array,
287
- Uint32Array,
288
- Float32Array,
289
- Float64Array,
290
- Uint8ClampedArray
291
- ].reduce((obj, ctor) => {
292
- obj[ctor.name] = ctor;
293
- return obj;
294
- }, {});
295
- var typedArrayRule = compositeTransformation(isTypedArray, (v) => ["typed-array", v.constructor.name], (v) => [...v], (v, a) => {
296
- const ctor = constructorToName[a[1]];
297
- if (!ctor) {
298
- throw new Error("Trying to deserialize unknown typed array");
299
- }
300
- return new ctor(v);
301
- });
302
- function isInstanceOfRegisteredClass(potentialClass, superJson) {
303
- if (potentialClass?.constructor) {
304
- const isRegistered = !!superJson.classRegistry.getIdentifier(potentialClass.constructor);
305
- return isRegistered;
306
- }
307
- return false;
308
- }
309
- var classRule = compositeTransformation(isInstanceOfRegisteredClass, (clazz, superJson) => {
310
- const identifier = superJson.classRegistry.getIdentifier(clazz.constructor);
311
- return ["class", identifier];
312
- }, (clazz, superJson) => {
313
- const allowedProps = superJson.classRegistry.getAllowedProps(clazz.constructor);
314
- if (!allowedProps) {
315
- return { ...clazz };
316
- }
317
- const result = {};
318
- allowedProps.forEach((prop) => {
319
- result[prop] = clazz[prop];
320
- });
321
- return result;
322
- }, (v, a, superJson) => {
323
- const clazz = superJson.classRegistry.getValue(a[1]);
324
- if (!clazz) {
325
- throw new Error(`Trying to deserialize unknown class '${a[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);
326
- }
327
- return Object.assign(Object.create(clazz.prototype), v);
328
- });
329
- var customRule = compositeTransformation((value, superJson) => {
330
- return !!superJson.customTransformerRegistry.findApplicable(value);
331
- }, (value, superJson) => {
332
- const transformer = superJson.customTransformerRegistry.findApplicable(value);
333
- return ["custom", transformer.name];
334
- }, (value, superJson) => {
335
- const transformer = superJson.customTransformerRegistry.findApplicable(value);
336
- return transformer.serialize(value);
337
- }, (v, a, superJson) => {
338
- const transformer = superJson.customTransformerRegistry.findByName(a[1]);
339
- if (!transformer) {
340
- throw new Error("Trying to deserialize unknown custom value");
341
- }
342
- return transformer.deserialize(v);
343
- });
344
- var compositeRules = [classRule, symbolRule, customRule, typedArrayRule];
345
- var transformValue = (value, superJson) => {
346
- const applicableCompositeRule = findArr(compositeRules, (rule) => rule.isApplicable(value, superJson));
347
- if (applicableCompositeRule) {
348
- return {
349
- value: applicableCompositeRule.transform(value, superJson),
350
- type: applicableCompositeRule.annotation(value, superJson)
351
- };
173
+ this[_a7] = true;
174
+ this.text = text;
352
175
  }
353
- const applicableSimpleRule = findArr(simpleRules, (rule) => rule.isApplicable(value, superJson));
354
- if (applicableSimpleRule) {
355
- return {
356
- value: applicableSimpleRule.transform(value, superJson),
357
- type: applicableSimpleRule.annotation
358
- };
176
+ static isInstance(error) {
177
+ return AISDKError.hasMarker(error, marker7);
359
178
  }
360
- return void 0;
361
179
  };
362
- var simpleRulesByAnnotation = {};
363
- simpleRules.forEach((rule) => {
364
- simpleRulesByAnnotation[rule.annotation] = rule;
365
- });
366
- var untransformValue = (json, type, superJson) => {
367
- if (isArray(type)) {
368
- switch (type[0]) {
369
- case "symbol":
370
- return symbolRule.untransform(json, type, superJson);
371
- case "class":
372
- return classRule.untransform(json, type, superJson);
373
- case "custom":
374
- return customRule.untransform(json, type, superJson);
375
- case "typed-array":
376
- return typedArrayRule.untransform(json, type, superJson);
377
- default:
378
- throw new Error("Unknown transformation: " + type);
379
- }
380
- } else {
381
- const transformation = simpleRulesByAnnotation[type];
382
- if (!transformation) {
383
- throw new Error("Unknown transformation: " + type);
384
- }
385
- return transformation.untransform(json, superJson);
180
+ _a7 = symbol7;
181
+ var name7 = "AI_LoadAPIKeyError";
182
+ var marker8 = `vercel.ai.error.${name7}`;
183
+ var symbol8 = Symbol.for(marker8);
184
+ var _a8;
185
+ var LoadAPIKeyError = class extends AISDKError {
186
+ // used in isInstance
187
+ constructor({ message }) {
188
+ super({ name: name7, message });
189
+ this[_a8] = true;
190
+ }
191
+ static isInstance(error) {
192
+ return AISDKError.hasMarker(error, marker8);
386
193
  }
387
194
  };
388
-
389
- // ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/accessDeep.js
390
- var getNthKey = (value, n) => {
391
- if (n > value.size)
392
- throw new Error("index out of bounds");
393
- const keys = value.keys();
394
- while (n > 0) {
395
- keys.next();
396
- n--;
397
- }
398
- return keys.next().value;
399
- };
400
- function validatePath(path) {
401
- if (includes(path, "__proto__")) {
402
- throw new Error("__proto__ is not allowed as a property");
403
- }
404
- if (includes(path, "prototype")) {
405
- throw new Error("prototype is not allowed as a property");
406
- }
407
- if (includes(path, "constructor")) {
408
- throw new Error("constructor is not allowed as a property");
409
- }
410
- }
411
- var getDeep = (object, path) => {
412
- validatePath(path);
413
- for (let i = 0; i < path.length; i++) {
414
- const key = path[i];
415
- if (isSet(object)) {
416
- object = getNthKey(object, +key);
417
- } else if (isMap(object)) {
418
- const row = +key;
419
- const type = +path[++i] === 0 ? "key" : "value";
420
- const keyOfRow = getNthKey(object, row);
421
- switch (type) {
422
- case "key":
423
- object = keyOfRow;
424
- break;
425
- case "value":
426
- object = object.get(keyOfRow);
427
- break;
428
- }
429
- } else {
430
- object = object[key];
431
- }
195
+ _a8 = symbol8;
196
+ var name10 = "AI_NoSuchModelError";
197
+ var marker11 = `vercel.ai.error.${name10}`;
198
+ var symbol11 = Symbol.for(marker11);
199
+ var _a11;
200
+ var NoSuchModelError = class extends AISDKError {
201
+ constructor({
202
+ errorName = name10,
203
+ modelId,
204
+ modelType,
205
+ message = `No such ${modelType}: ${modelId}`
206
+ }) {
207
+ super({ name: errorName, message });
208
+ this[_a11] = true;
209
+ this.modelId = modelId;
210
+ this.modelType = modelType;
211
+ }
212
+ static isInstance(error) {
213
+ return AISDKError.hasMarker(error, marker11);
432
214
  }
433
- return object;
434
215
  };
435
- var setDeep = (object, path, mapper) => {
436
- validatePath(path);
437
- if (path.length === 0) {
438
- return mapper(object);
439
- }
440
- let parent = object;
441
- for (let i = 0; i < path.length - 1; i++) {
442
- const key = path[i];
443
- if (isArray(parent)) {
444
- const index = +key;
445
- parent = parent[index];
446
- } else if (isPlainObject(parent)) {
447
- parent = parent[key];
448
- } else if (isSet(parent)) {
449
- const row = +key;
450
- parent = getNthKey(parent, row);
451
- } else if (isMap(parent)) {
452
- const isEnd = i === path.length - 2;
453
- if (isEnd) {
454
- break;
455
- }
456
- const row = +key;
457
- const type = +path[++i] === 0 ? "key" : "value";
458
- const keyOfRow = getNthKey(parent, row);
459
- switch (type) {
460
- case "key":
461
- parent = keyOfRow;
462
- break;
463
- case "value":
464
- parent = parent.get(keyOfRow);
465
- break;
466
- }
467
- }
468
- }
469
- const lastKey = path[path.length - 1];
470
- if (isArray(parent)) {
471
- parent[+lastKey] = mapper(parent[+lastKey]);
472
- } else if (isPlainObject(parent)) {
473
- parent[lastKey] = mapper(parent[lastKey]);
474
- }
475
- if (isSet(parent)) {
476
- const oldValue = getNthKey(parent, +lastKey);
477
- const newValue = mapper(oldValue);
478
- if (oldValue !== newValue) {
479
- parent.delete(oldValue);
480
- parent.add(newValue);
481
- }
216
+ _a11 = symbol11;
217
+ var name11 = "AI_TooManyEmbeddingValuesForCallError";
218
+ var marker12 = `vercel.ai.error.${name11}`;
219
+ var symbol12 = Symbol.for(marker12);
220
+ var _a12;
221
+ var TooManyEmbeddingValuesForCallError = class extends AISDKError {
222
+ constructor(options) {
223
+ super({
224
+ name: name11,
225
+ message: `Too many values for a single embedding call. The ${options.provider} model "${options.modelId}" can only embed up to ${options.maxEmbeddingsPerCall} values per call, but ${options.values.length} values were provided.`
226
+ });
227
+ this[_a12] = true;
228
+ this.provider = options.provider;
229
+ this.modelId = options.modelId;
230
+ this.maxEmbeddingsPerCall = options.maxEmbeddingsPerCall;
231
+ this.values = options.values;
482
232
  }
483
- if (isMap(parent)) {
484
- const row = +path[path.length - 2];
485
- const keyToRow = getNthKey(parent, row);
486
- const type = +lastKey === 0 ? "key" : "value";
487
- switch (type) {
488
- case "key": {
489
- const newKey = mapper(keyToRow);
490
- parent.set(newKey, parent.get(keyToRow));
491
- if (newKey !== keyToRow) {
492
- parent.delete(keyToRow);
493
- }
494
- break;
495
- }
496
- case "value": {
497
- parent.set(keyToRow, mapper(parent.get(keyToRow)));
498
- break;
499
- }
500
- }
233
+ static isInstance(error) {
234
+ return AISDKError.hasMarker(error, marker12);
501
235
  }
502
- return object;
503
236
  };
504
-
505
- // ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/plainer.js
506
- function traverse(tree, walker2, origin = []) {
507
- if (!tree) {
508
- return;
509
- }
510
- if (!isArray(tree)) {
511
- forEach(tree, (subtree, key) => traverse(subtree, walker2, [...origin, ...parsePath(key)]));
512
- return;
513
- }
514
- const [nodeValue, children] = tree;
515
- if (children) {
516
- forEach(children, (child, key) => {
517
- traverse(child, walker2, [...origin, ...parsePath(key)]);
237
+ _a12 = symbol12;
238
+ var name12 = "AI_TypeValidationError";
239
+ var marker13 = `vercel.ai.error.${name12}`;
240
+ var symbol13 = Symbol.for(marker13);
241
+ var _a13;
242
+ var _TypeValidationError = class _TypeValidationError2 extends AISDKError {
243
+ constructor({ value, cause }) {
244
+ super({
245
+ name: name12,
246
+ message: `Type validation failed: Value: ${JSON.stringify(value)}.
247
+ Error message: ${getErrorMessage(cause)}`,
248
+ cause
518
249
  });
250
+ this[_a13] = true;
251
+ this.value = value;
519
252
  }
520
- walker2(nodeValue, origin);
521
- }
522
- function applyValueAnnotations(plain, annotations, superJson) {
523
- traverse(annotations, (type, path) => {
524
- plain = setDeep(plain, path, (v) => untransformValue(v, type, superJson));
525
- });
526
- return plain;
527
- }
528
- function applyReferentialEqualityAnnotations(plain, annotations) {
529
- function apply(identicalPaths, path) {
530
- const object = getDeep(plain, parsePath(path));
531
- identicalPaths.map(parsePath).forEach((identicalObjectPath) => {
532
- plain = setDeep(plain, identicalObjectPath, () => object);
533
- });
253
+ static isInstance(error) {
254
+ return AISDKError.hasMarker(error, marker13);
534
255
  }
535
- if (isArray(annotations)) {
536
- const [root, other] = annotations;
537
- root.forEach((identicalPath) => {
538
- plain = setDeep(plain, parsePath(identicalPath), () => plain);
539
- });
540
- if (other) {
541
- forEach(other, apply);
542
- }
543
- } else {
544
- forEach(annotations, apply);
256
+ /**
257
+ * Wraps an error into a TypeValidationError.
258
+ * If the cause is already a TypeValidationError with the same value, it returns the cause.
259
+ * Otherwise, it creates a new TypeValidationError.
260
+ *
261
+ * @param {Object} params - The parameters for wrapping the error.
262
+ * @param {unknown} params.value - The value that failed validation.
263
+ * @param {unknown} params.cause - The original error or cause of the validation failure.
264
+ * @returns {TypeValidationError} A TypeValidationError instance.
265
+ */
266
+ static wrap({
267
+ value,
268
+ cause
269
+ }) {
270
+ return _TypeValidationError2.isInstance(cause) && cause.value === value ? cause : new _TypeValidationError2({ value, cause });
545
271
  }
546
- return plain;
547
- }
548
- var isDeep = (object, superJson) => isPlainObject(object) || isArray(object) || isMap(object) || isSet(object) || isInstanceOfRegisteredClass(object, superJson);
549
- function addIdentity(object, path, identities) {
550
- const existingSet = identities.get(object);
551
- if (existingSet) {
552
- existingSet.push(path);
553
- } else {
554
- identities.set(object, [path]);
272
+ };
273
+ _a13 = symbol13;
274
+ var TypeValidationError = _TypeValidationError;
275
+ var name13 = "AI_UnsupportedFunctionalityError";
276
+ var marker14 = `vercel.ai.error.${name13}`;
277
+ var symbol14 = Symbol.for(marker14);
278
+ var _a14;
279
+ var UnsupportedFunctionalityError = class extends AISDKError {
280
+ constructor({
281
+ functionality,
282
+ message = `'${functionality}' functionality not supported.`
283
+ }) {
284
+ super({ name: name13, message });
285
+ this[_a14] = true;
286
+ this.functionality = functionality;
287
+ }
288
+ static isInstance(error) {
289
+ return AISDKError.hasMarker(error, marker14);
555
290
  }
291
+ };
292
+ _a14 = symbol14;
293
+
294
+ // ../../node_modules/.pnpm/eventsource-parser@3.0.6/node_modules/eventsource-parser/dist/index.js
295
+ var ParseError = class extends Error {
296
+ constructor(message, options) {
297
+ super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
298
+ }
299
+ };
300
+ function noop(_arg) {
556
301
  }
557
- function generateReferentialEqualityAnnotations(identitites, dedupe) {
558
- const result = {};
559
- let rootEqualityPaths = void 0;
560
- identitites.forEach((paths) => {
561
- if (paths.length <= 1) {
302
+ function createParser(callbacks) {
303
+ if (typeof callbacks == "function")
304
+ throw new TypeError(
305
+ "`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?"
306
+ );
307
+ const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks;
308
+ let incompleteLine = "", isFirstChunk = true, id, data = "", eventType = "";
309
+ function feed(newChunk) {
310
+ const chunk = isFirstChunk ? newChunk.replace(/^\xEF\xBB\xBF/, "") : newChunk, [complete, incomplete] = splitLines(`${incompleteLine}${chunk}`);
311
+ for (const line of complete)
312
+ parseLine(line);
313
+ incompleteLine = incomplete, isFirstChunk = false;
314
+ }
315
+ function parseLine(line) {
316
+ if (line === "") {
317
+ dispatchEvent();
562
318
  return;
563
319
  }
564
- if (!dedupe) {
565
- paths = paths.map((path) => path.map(String)).sort((a, b) => a.length - b.length);
566
- }
567
- const [representativePath, ...identicalPaths] = paths;
568
- if (representativePath.length === 0) {
569
- rootEqualityPaths = identicalPaths.map(stringifyPath);
570
- } else {
571
- result[stringifyPath(representativePath)] = identicalPaths.map(stringifyPath);
572
- }
573
- });
574
- if (rootEqualityPaths) {
575
- if (isEmptyObject(result)) {
576
- return [rootEqualityPaths];
577
- } else {
578
- return [rootEqualityPaths, result];
320
+ if (line.startsWith(":")) {
321
+ onComment && onComment(line.slice(line.startsWith(": ") ? 2 : 1));
322
+ return;
579
323
  }
580
- } else {
581
- return isEmptyObject(result) ? void 0 : result;
582
- }
583
- }
584
- var walker = (object, identities, superJson, dedupe, path = [], objectsInThisPath = [], seenObjects = /* @__PURE__ */ new Map()) => {
585
- const primitive = isPrimitive(object);
586
- if (!primitive) {
587
- addIdentity(object, path, identities);
588
- const seen = seenObjects.get(object);
589
- if (seen) {
590
- return dedupe ? {
591
- transformedValue: null
592
- } : seen;
324
+ const fieldSeparatorIndex = line.indexOf(":");
325
+ if (fieldSeparatorIndex !== -1) {
326
+ const field = line.slice(0, fieldSeparatorIndex), offset = line[fieldSeparatorIndex + 1] === " " ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
327
+ processField(field, value, line);
328
+ return;
593
329
  }
330
+ processField(line, "", line);
594
331
  }
595
- if (!isDeep(object, superJson)) {
596
- const transformed2 = transformValue(object, superJson);
597
- const result2 = transformed2 ? {
598
- transformedValue: transformed2.value,
599
- annotations: [transformed2.type]
600
- } : {
601
- transformedValue: object
602
- };
603
- if (!primitive) {
604
- seenObjects.set(object, result2);
332
+ function processField(field, value, line) {
333
+ switch (field) {
334
+ case "event":
335
+ eventType = value;
336
+ break;
337
+ case "data":
338
+ data = `${data}${value}
339
+ `;
340
+ break;
341
+ case "id":
342
+ id = value.includes("\0") ? void 0 : value;
343
+ break;
344
+ case "retry":
345
+ /^\d+$/.test(value) ? onRetry(parseInt(value, 10)) : onError(
346
+ new ParseError(`Invalid \`retry\` value: "${value}"`, {
347
+ type: "invalid-retry",
348
+ value,
349
+ line
350
+ })
351
+ );
352
+ break;
353
+ default:
354
+ onError(
355
+ new ParseError(
356
+ `Unknown field "${field.length > 20 ? `${field.slice(0, 20)}\u2026` : field}"`,
357
+ { type: "unknown-field", field, value, line }
358
+ )
359
+ );
360
+ break;
605
361
  }
606
- return result2;
607
- }
608
- if (includes(objectsInThisPath, object)) {
609
- return {
610
- transformedValue: null
611
- };
612
362
  }
613
- const transformationResult = transformValue(object, superJson);
614
- const transformed = transformationResult?.value ?? object;
615
- const transformedValue = isArray(transformed) ? [] : {};
616
- const innerAnnotations = {};
617
- forEach(transformed, (value, index) => {
618
- if (index === "__proto__" || index === "constructor" || index === "prototype") {
619
- throw new Error(`Detected property ${index}. This is a prototype pollution risk, please remove it from your object.`);
620
- }
621
- const recursiveResult = walker(value, identities, superJson, dedupe, [...path, index], [...objectsInThisPath, object], seenObjects);
622
- transformedValue[index] = recursiveResult.transformedValue;
623
- if (isArray(recursiveResult.annotations)) {
624
- innerAnnotations[index] = recursiveResult.annotations;
625
- } else if (isPlainObject(recursiveResult.annotations)) {
626
- forEach(recursiveResult.annotations, (tree, key) => {
627
- innerAnnotations[escapeKey(index) + "." + key] = tree;
628
- });
629
- }
630
- });
631
- const result = isEmptyObject(innerAnnotations) ? {
632
- transformedValue,
633
- annotations: !!transformationResult ? [transformationResult.type] : void 0
634
- } : {
635
- transformedValue,
636
- annotations: !!transformationResult ? [transformationResult.type, innerAnnotations] : innerAnnotations
637
- };
638
- if (!primitive) {
639
- seenObjects.set(object, result);
363
+ function dispatchEvent() {
364
+ data.length > 0 && onEvent({
365
+ id,
366
+ event: eventType || void 0,
367
+ // If the data buffer's last character is a U+000A LINE FEED (LF) character,
368
+ // then remove the last character from the data buffer.
369
+ data: data.endsWith(`
370
+ `) ? data.slice(0, -1) : data
371
+ }), id = void 0, data = "", eventType = "";
640
372
  }
641
- return result;
642
- };
643
-
644
- // ../../node_modules/.pnpm/is-what@4.1.16/node_modules/is-what/dist/index.js
645
- function getType2(payload) {
646
- return Object.prototype.toString.call(payload).slice(8, -1);
647
- }
648
- function isArray2(payload) {
649
- return getType2(payload) === "Array";
650
- }
651
- function isPlainObject2(payload) {
652
- if (getType2(payload) !== "Object")
653
- return false;
654
- const prototype = Object.getPrototypeOf(payload);
655
- return !!prototype && prototype.constructor === Object && prototype === Object.prototype;
656
- }
657
-
658
- // ../../node_modules/.pnpm/copy-anything@3.0.5/node_modules/copy-anything/dist/index.js
659
- function assignProp(carry, key, newVal, originalObject, includeNonenumerable) {
660
- const propType = {}.propertyIsEnumerable.call(originalObject, key) ? "enumerable" : "nonenumerable";
661
- if (propType === "enumerable")
662
- carry[key] = newVal;
663
- if (includeNonenumerable && propType === "nonenumerable") {
664
- Object.defineProperty(carry, key, {
665
- value: newVal,
666
- enumerable: false,
667
- writable: true,
668
- configurable: true
669
- });
373
+ function reset(options = {}) {
374
+ incompleteLine && options.consume && parseLine(incompleteLine), isFirstChunk = true, id = void 0, data = "", eventType = "", incompleteLine = "";
670
375
  }
376
+ return { feed, reset };
671
377
  }
672
- function copy(target, options = {}) {
673
- if (isArray2(target)) {
674
- return target.map((item) => copy(item, options));
675
- }
676
- if (!isPlainObject2(target)) {
677
- return target;
678
- }
679
- const props = Object.getOwnPropertyNames(target);
680
- const symbols = Object.getOwnPropertySymbols(target);
681
- return [...props, ...symbols].reduce((carry, key) => {
682
- if (isArray2(options.props) && !options.props.includes(key)) {
683
- return carry;
378
+ function splitLines(chunk) {
379
+ const lines = [];
380
+ let incompleteLine = "", searchIndex = 0;
381
+ for (; searchIndex < chunk.length; ) {
382
+ const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
383
+ `, searchIndex);
384
+ let lineEnd = -1;
385
+ if (crIndex !== -1 && lfIndex !== -1 ? lineEnd = Math.min(crIndex, lfIndex) : crIndex !== -1 ? crIndex === chunk.length - 1 ? lineEnd = -1 : lineEnd = crIndex : lfIndex !== -1 && (lineEnd = lfIndex), lineEnd === -1) {
386
+ incompleteLine = chunk.slice(searchIndex);
387
+ break;
388
+ } else {
389
+ const line = chunk.slice(searchIndex, lineEnd);
390
+ lines.push(line), searchIndex = lineEnd + 1, chunk[searchIndex - 1] === "\r" && chunk[searchIndex] === `
391
+ ` && searchIndex++;
684
392
  }
685
- const val = target[key];
686
- const newVal = copy(val, options);
687
- assignProp(carry, key, newVal, target, options.nonenumerable);
688
- return carry;
689
- }, {});
393
+ }
394
+ return [lines, incompleteLine];
690
395
  }
691
396
 
692
- // ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/index.js
693
- var SuperJSON = class {
694
- /**
695
- * @param dedupeReferentialEqualities If true, SuperJSON will make sure only one instance of referentially equal objects are serialized and the rest are replaced with `null`.
696
- */
697
- constructor({ dedupe = false } = {}) {
698
- this.classRegistry = new ClassRegistry();
699
- this.symbolRegistry = new Registry((s) => s.description ?? "");
700
- this.customTransformerRegistry = new CustomTransformerRegistry();
701
- this.allowedErrorProps = [];
702
- this.dedupe = dedupe;
703
- }
704
- serialize(object) {
705
- const identities = /* @__PURE__ */ new Map();
706
- const output = walker(object, identities, this, this.dedupe);
707
- const res = {
708
- json: output.transformedValue
709
- };
710
- if (output.annotations) {
711
- res.meta = {
712
- ...res.meta,
713
- values: output.annotations
714
- };
715
- }
716
- const equalityAnnotations = generateReferentialEqualityAnnotations(identities, this.dedupe);
717
- if (equalityAnnotations) {
718
- res.meta = {
719
- ...res.meta,
720
- referentialEqualities: equalityAnnotations
721
- };
722
- }
723
- return res;
724
- }
725
- deserialize(payload) {
726
- const { json, meta } = payload;
727
- let result = copy(json);
728
- if (meta?.values) {
729
- result = applyValueAnnotations(result, meta.values, this);
730
- }
731
- if (meta?.referentialEqualities) {
732
- result = applyReferentialEqualityAnnotations(result, meta.referentialEqualities);
733
- }
734
- return result;
735
- }
736
- stringify(object) {
737
- return JSON.stringify(this.serialize(object));
738
- }
739
- parse(string) {
740
- return this.deserialize(JSON.parse(string));
741
- }
742
- registerClass(v, options) {
743
- this.classRegistry.register(v, options);
744
- }
745
- registerSymbol(v, identifier) {
746
- this.symbolRegistry.register(v, identifier);
747
- }
748
- registerCustom(transformer, name) {
749
- this.customTransformerRegistry.register({
750
- name,
751
- ...transformer
397
+ // ../../node_modules/.pnpm/eventsource-parser@3.0.6/node_modules/eventsource-parser/dist/stream.js
398
+ var EventSourceParserStream = class extends TransformStream {
399
+ constructor({ onError, onRetry, onComment } = {}) {
400
+ let parser;
401
+ super({
402
+ start(controller) {
403
+ parser = createParser({
404
+ onEvent: (event) => {
405
+ controller.enqueue(event);
406
+ },
407
+ onError(error) {
408
+ onError === "terminate" ? controller.error(error) : typeof onError == "function" && onError(error);
409
+ },
410
+ onRetry,
411
+ onComment
412
+ });
413
+ },
414
+ transform(chunk) {
415
+ parser.feed(chunk);
416
+ }
752
417
  });
753
418
  }
754
- allowErrorProps(...props) {
755
- this.allowedErrorProps.push(...props);
756
- }
757
419
  };
758
- SuperJSON.defaultInstance = new SuperJSON();
759
- SuperJSON.serialize = SuperJSON.defaultInstance.serialize.bind(SuperJSON.defaultInstance);
760
- SuperJSON.deserialize = SuperJSON.defaultInstance.deserialize.bind(SuperJSON.defaultInstance);
761
- SuperJSON.stringify = SuperJSON.defaultInstance.stringify.bind(SuperJSON.defaultInstance);
762
- SuperJSON.parse = SuperJSON.defaultInstance.parse.bind(SuperJSON.defaultInstance);
763
- SuperJSON.registerClass = SuperJSON.defaultInstance.registerClass.bind(SuperJSON.defaultInstance);
764
- SuperJSON.registerSymbol = SuperJSON.defaultInstance.registerSymbol.bind(SuperJSON.defaultInstance);
765
- SuperJSON.registerCustom = SuperJSON.defaultInstance.registerCustom.bind(SuperJSON.defaultInstance);
766
- SuperJSON.allowErrorProps = SuperJSON.defaultInstance.allowErrorProps.bind(SuperJSON.defaultInstance);
767
- var stringify = SuperJSON.stringify;
768
420
 
769
- // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.67/node_modules/zod-to-json-schema/dist/esm/Options.js
421
+ // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/Options.js
770
422
  var ignoreOverride = Symbol("Let zodToJsonSchema decide on which parser to use");
771
423
  var defaultOptions = {
772
424
  name: void 0,
@@ -800,7 +452,7 @@ var getDefaultOptions = (options) => typeof options === "string" ? {
800
452
  ...options
801
453
  };
802
454
 
803
- // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.67/node_modules/zod-to-json-schema/dist/esm/Refs.js
455
+ // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/Refs.js
804
456
  var getRefs = (options) => {
805
457
  const _options = getDefaultOptions(options);
806
458
  const currentPath = _options.name !== void 0 ? [..._options.basePath, _options.definitionPath, _options.name] : _options.basePath;
@@ -809,11 +461,11 @@ var getRefs = (options) => {
809
461
  flags: { hasReferencedOpenAiAnyType: false },
810
462
  currentPath,
811
463
  propertyPath: void 0,
812
- seen: new Map(Object.entries(_options.definitions).map(([name, def]) => [
464
+ seen: new Map(Object.entries(_options.definitions).map(([name14, def]) => [
813
465
  def._def,
814
466
  {
815
467
  def: def._def,
816
- path: [..._options.basePath, _options.definitionPath, name],
468
+ path: [..._options.basePath, _options.definitionPath, name14],
817
469
  // Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
818
470
  jsonSchema: void 0
819
471
  }
@@ -821,7 +473,7 @@ var getRefs = (options) => {
821
473
  };
822
474
  };
823
475
 
824
- // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.67/node_modules/zod-to-json-schema/dist/esm/errorMessages.js
476
+ // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/errorMessages.js
825
477
  function addErrorMessage(res, key, errorMessage, refs) {
826
478
  if (!refs?.errorMessages)
827
479
  return;
@@ -837,7 +489,7 @@ function setResponseValueAndErrors(res, key, value, errorMessage, refs) {
837
489
  addErrorMessage(res, key, errorMessage, refs);
838
490
  }
839
491
 
840
- // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.67/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js
492
+ // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js
841
493
  var getRelativePath = (pathA, pathB) => {
842
494
  let i = 0;
843
495
  for (; i < pathA.length && i < pathB.length; i++) {
@@ -847,7 +499,7 @@ var getRelativePath = (pathA, pathB) => {
847
499
  return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
848
500
  };
849
501
 
850
- // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.67/node_modules/zod-to-json-schema/dist/esm/parsers/any.js
502
+ // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/any.js
851
503
  function parseAnyDef(refs) {
852
504
  if (refs.target !== "openAi") {
853
505
  return {};
@@ -885,7 +537,7 @@ function parseArrayDef(def, refs) {
885
537
  return res;
886
538
  }
887
539
 
888
- // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.67/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js
540
+ // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js
889
541
  function parseBigintDef(def, refs) {
890
542
  const res = {
891
543
  type: "integer",
@@ -931,24 +583,24 @@ function parseBigintDef(def, refs) {
931
583
  return res;
932
584
  }
933
585
 
934
- // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.67/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js
586
+ // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js
935
587
  function parseBooleanDef() {
936
588
  return {
937
589
  type: "boolean"
938
590
  };
939
591
  }
940
592
 
941
- // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.67/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js
593
+ // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js
942
594
  function parseBrandedDef(_def, refs) {
943
595
  return parseDef(_def.type._def, refs);
944
596
  }
945
597
 
946
- // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.67/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js
598
+ // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js
947
599
  var parseCatchDef = (def, refs) => {
948
600
  return parseDef(def.innerType._def, refs);
949
601
  };
950
602
 
951
- // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.67/node_modules/zod-to-json-schema/dist/esm/parsers/date.js
603
+ // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/date.js
952
604
  function parseDateDef(def, refs, overrideDateStrategy) {
953
605
  const strategy = overrideDateStrategy ?? refs.dateStrategy;
954
606
  if (Array.isArray(strategy)) {
@@ -1007,7 +659,7 @@ var integerDateParser = (def, refs) => {
1007
659
  return res;
1008
660
  };
1009
661
 
1010
- // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.67/node_modules/zod-to-json-schema/dist/esm/parsers/default.js
662
+ // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/default.js
1011
663
  function parseDefaultDef(_def, refs) {
1012
664
  return {
1013
665
  ...parseDef(_def.innerType._def, refs),
@@ -1015,12 +667,12 @@ function parseDefaultDef(_def, refs) {
1015
667
  };
1016
668
  }
1017
669
 
1018
- // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.67/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js
670
+ // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js
1019
671
  function parseEffectsDef(_def, refs) {
1020
672
  return refs.effectStrategy === "input" ? parseDef(_def.schema._def, refs) : parseAnyDef(refs);
1021
673
  }
1022
674
 
1023
- // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.67/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js
675
+ // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js
1024
676
  function parseEnumDef(def) {
1025
677
  return {
1026
678
  type: "string",
@@ -1028,7 +680,7 @@ function parseEnumDef(def) {
1028
680
  };
1029
681
  }
1030
682
 
1031
- // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.67/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js
683
+ // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js
1032
684
  var isJsonSchema7AllOfType = (type) => {
1033
685
  if ("type" in type && type.type === "string")
1034
686
  return false;
@@ -1070,7 +722,7 @@ function parseIntersectionDef(def, refs) {
1070
722
  } : void 0;
1071
723
  }
1072
724
 
1073
- // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.67/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js
725
+ // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js
1074
726
  function parseLiteralDef(def, refs) {
1075
727
  const parsedType = typeof def.value;
1076
728
  if (parsedType !== "bigint" && parsedType !== "number" && parsedType !== "boolean" && parsedType !== "string") {
@@ -1090,7 +742,7 @@ function parseLiteralDef(def, refs) {
1090
742
  };
1091
743
  }
1092
744
 
1093
- // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.67/node_modules/zod-to-json-schema/dist/esm/parsers/string.js
745
+ // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/string.js
1094
746
  var emojiRegex = void 0;
1095
747
  var zodPatterns = {
1096
748
  /**
@@ -1402,7 +1054,7 @@ function stringifyRegExpWithFlags(regex, refs) {
1402
1054
  return pattern;
1403
1055
  }
1404
1056
 
1405
- // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.67/node_modules/zod-to-json-schema/dist/esm/parsers/record.js
1057
+ // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/record.js
1406
1058
  function parseRecordDef(def, refs) {
1407
1059
  if (refs.target === "openAi") {
1408
1060
  console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");
@@ -1454,7 +1106,7 @@ function parseRecordDef(def, refs) {
1454
1106
  return schema;
1455
1107
  }
1456
1108
 
1457
- // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.67/node_modules/zod-to-json-schema/dist/esm/parsers/map.js
1109
+ // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/map.js
1458
1110
  function parseMapDef(def, refs) {
1459
1111
  if (refs.mapStrategy === "record") {
1460
1112
  return parseRecordDef(def, refs);
@@ -1479,7 +1131,7 @@ function parseMapDef(def, refs) {
1479
1131
  };
1480
1132
  }
1481
1133
 
1482
- // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.67/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js
1134
+ // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js
1483
1135
  function parseNativeEnumDef(def) {
1484
1136
  const object = def.values;
1485
1137
  const actualKeys = Object.keys(def.values).filter((key) => {
@@ -1493,7 +1145,7 @@ function parseNativeEnumDef(def) {
1493
1145
  };
1494
1146
  }
1495
1147
 
1496
- // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.67/node_modules/zod-to-json-schema/dist/esm/parsers/never.js
1148
+ // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/never.js
1497
1149
  function parseNeverDef(refs) {
1498
1150
  return refs.target === "openAi" ? void 0 : {
1499
1151
  not: parseAnyDef({
@@ -1503,7 +1155,7 @@ function parseNeverDef(refs) {
1503
1155
  };
1504
1156
  }
1505
1157
 
1506
- // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.67/node_modules/zod-to-json-schema/dist/esm/parsers/null.js
1158
+ // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/null.js
1507
1159
  function parseNullDef(refs) {
1508
1160
  return refs.target === "openApi3" ? {
1509
1161
  enum: ["null"],
@@ -1513,7 +1165,7 @@ function parseNullDef(refs) {
1513
1165
  };
1514
1166
  }
1515
1167
 
1516
- // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.67/node_modules/zod-to-json-schema/dist/esm/parsers/union.js
1168
+ // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/union.js
1517
1169
  var primitiveMappings = {
1518
1170
  ZodString: "string",
1519
1171
  ZodNumber: "number",
@@ -1581,7 +1233,7 @@ var asAnyOf = (def, refs) => {
1581
1233
  return anyOf.length ? { anyOf } : void 0;
1582
1234
  };
1583
1235
 
1584
- // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.67/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js
1236
+ // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js
1585
1237
  function parseNullableDef(def, refs) {
1586
1238
  if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(def.innerType._def.typeName) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) {
1587
1239
  if (refs.target === "openApi3") {
@@ -1613,7 +1265,7 @@ function parseNullableDef(def, refs) {
1613
1265
  return base && { anyOf: [base, { type: "null" }] };
1614
1266
  }
1615
1267
 
1616
- // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.67/node_modules/zod-to-json-schema/dist/esm/parsers/number.js
1268
+ // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/number.js
1617
1269
  function parseNumberDef(def, refs) {
1618
1270
  const res = {
1619
1271
  type: "number"
@@ -1662,7 +1314,7 @@ function parseNumberDef(def, refs) {
1662
1314
  return res;
1663
1315
  }
1664
1316
 
1665
- // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.67/node_modules/zod-to-json-schema/dist/esm/parsers/object.js
1317
+ // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/object.js
1666
1318
  function parseObjectDef(def, refs) {
1667
1319
  const forceOptionalIntoNullable = refs.target === "openAi";
1668
1320
  const result = {
@@ -1732,7 +1384,7 @@ function safeIsOptional(schema) {
1732
1384
  }
1733
1385
  }
1734
1386
 
1735
- // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.67/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js
1387
+ // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js
1736
1388
  var parseOptionalDef = (def, refs) => {
1737
1389
  if (refs.currentPath.toString() === refs.propertyPath?.toString()) {
1738
1390
  return parseDef(def.innerType._def, refs);
@@ -1751,7 +1403,7 @@ var parseOptionalDef = (def, refs) => {
1751
1403
  } : parseAnyDef(refs);
1752
1404
  };
1753
1405
 
1754
- // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.67/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js
1406
+ // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js
1755
1407
  var parsePipelineDef = (def, refs) => {
1756
1408
  if (refs.pipeStrategy === "input") {
1757
1409
  return parseDef(def.in._def, refs);
@@ -1771,12 +1423,12 @@ var parsePipelineDef = (def, refs) => {
1771
1423
  };
1772
1424
  };
1773
1425
 
1774
- // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.67/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js
1426
+ // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js
1775
1427
  function parsePromiseDef(def, refs) {
1776
1428
  return parseDef(def.type._def, refs);
1777
1429
  }
1778
1430
 
1779
- // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.67/node_modules/zod-to-json-schema/dist/esm/parsers/set.js
1431
+ // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/set.js
1780
1432
  function parseSetDef(def, refs) {
1781
1433
  const items = parseDef(def.valueType._def, {
1782
1434
  ...refs,
@@ -1796,7 +1448,7 @@ function parseSetDef(def, refs) {
1796
1448
  return schema;
1797
1449
  }
1798
1450
 
1799
- // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.67/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js
1451
+ // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js
1800
1452
  function parseTupleDef(def, refs) {
1801
1453
  if (def.rest) {
1802
1454
  return {
@@ -1824,24 +1476,24 @@ function parseTupleDef(def, refs) {
1824
1476
  }
1825
1477
  }
1826
1478
 
1827
- // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.67/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js
1479
+ // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js
1828
1480
  function parseUndefinedDef(refs) {
1829
1481
  return {
1830
1482
  not: parseAnyDef(refs)
1831
1483
  };
1832
1484
  }
1833
1485
 
1834
- // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.67/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js
1486
+ // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js
1835
1487
  function parseUnknownDef(refs) {
1836
1488
  return parseAnyDef(refs);
1837
1489
  }
1838
1490
 
1839
- // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.67/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js
1491
+ // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js
1840
1492
  var parseReadonlyDef = (def, refs) => {
1841
1493
  return parseDef(def.innerType._def, refs);
1842
1494
  };
1843
1495
 
1844
- // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.67/node_modules/zod-to-json-schema/dist/esm/selectParser.js
1496
+ // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/selectParser.js
1845
1497
  var selectParser = (def, typeName, refs) => {
1846
1498
  switch (typeName) {
1847
1499
  case zod.ZodFirstPartyTypeKind.ZodString:
@@ -1917,7 +1569,7 @@ var selectParser = (def, typeName, refs) => {
1917
1569
  }
1918
1570
  };
1919
1571
 
1920
- // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.67/node_modules/zod-to-json-schema/dist/esm/parseDef.js
1572
+ // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parseDef.js
1921
1573
  function parseDef(def, refs, forceResolution = false) {
1922
1574
  const seenItem = refs.seen.get(def);
1923
1575
  if (refs.override) {
@@ -1973,20 +1625,20 @@ var addMeta = (def, refs, jsonSchema) => {
1973
1625
  return jsonSchema;
1974
1626
  };
1975
1627
 
1976
- // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.67/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js
1628
+ // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js
1977
1629
  var zodToJsonSchema = (schema, options) => {
1978
1630
  const refs = getRefs(options);
1979
- let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name2, schema2]) => ({
1631
+ let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name15, schema2]) => ({
1980
1632
  ...acc,
1981
- [name2]: parseDef(schema2._def, {
1633
+ [name15]: parseDef(schema2._def, {
1982
1634
  ...refs,
1983
- currentPath: [...refs.basePath, refs.definitionPath, name2]
1635
+ currentPath: [...refs.basePath, refs.definitionPath, name15]
1984
1636
  }, true) ?? parseAnyDef(refs)
1985
1637
  }), {}) : void 0;
1986
- const name = typeof options === "string" ? options : options?.nameStrategy === "title" ? void 0 : options?.name;
1987
- const main = parseDef(schema._def, name === void 0 ? refs : {
1638
+ const name14 = typeof options === "string" ? options : options?.nameStrategy === "title" ? void 0 : options?.name;
1639
+ const main = parseDef(schema._def, name14 === void 0 ? refs : {
1988
1640
  ...refs,
1989
- currentPath: [...refs.basePath, refs.definitionPath, name]
1641
+ currentPath: [...refs.basePath, refs.definitionPath, name14]
1990
1642
  }, false) ?? parseAnyDef(refs);
1991
1643
  const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
1992
1644
  if (title !== void 0) {
@@ -2010,18 +1662,18 @@ var zodToJsonSchema = (schema, options) => {
2010
1662
  };
2011
1663
  }
2012
1664
  }
2013
- const combined = name === void 0 ? definitions ? {
1665
+ const combined = name14 === void 0 ? definitions ? {
2014
1666
  ...main,
2015
1667
  [refs.definitionPath]: definitions
2016
1668
  } : main : {
2017
1669
  $ref: [
2018
1670
  ...refs.$refStrategy === "relative" ? [] : refs.basePath,
2019
1671
  refs.definitionPath,
2020
- name
1672
+ name14
2021
1673
  ].join("/"),
2022
1674
  [refs.definitionPath]: {
2023
1675
  ...definitions,
2024
- [name]: main
1676
+ [name14]: main
2025
1677
  }
2026
1678
  };
2027
1679
  if (refs.target === "jsonSchema7") {
@@ -2035,8 +1687,635 @@ var zodToJsonSchema = (schema, options) => {
2035
1687
  return combined;
2036
1688
  };
2037
1689
 
2038
- // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.67/node_modules/zod-to-json-schema/dist/esm/index.js
1690
+ // ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/index.js
2039
1691
  var esm_default = zodToJsonSchema;
2040
1692
 
1693
+ // ../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.3_zod@3.25.76/node_modules/@ai-sdk/provider-utils/dist/index.mjs
1694
+ function combineHeaders(...headers) {
1695
+ return headers.reduce(
1696
+ (combinedHeaders, currentHeaders) => ({
1697
+ ...combinedHeaders,
1698
+ ...currentHeaders != null ? currentHeaders : {}
1699
+ }),
1700
+ {}
1701
+ );
1702
+ }
1703
+ function extractResponseHeaders(response) {
1704
+ return Object.fromEntries([...response.headers]);
1705
+ }
1706
+ var createIdGenerator = ({
1707
+ prefix,
1708
+ size = 16,
1709
+ alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
1710
+ separator = "-"
1711
+ } = {}) => {
1712
+ const generator = () => {
1713
+ const alphabetLength = alphabet.length;
1714
+ const chars = new Array(size);
1715
+ for (let i = 0; i < size; i++) {
1716
+ chars[i] = alphabet[Math.random() * alphabetLength | 0];
1717
+ }
1718
+ return chars.join("");
1719
+ };
1720
+ if (prefix == null) {
1721
+ return generator;
1722
+ }
1723
+ if (alphabet.includes(separator)) {
1724
+ throw new InvalidArgumentError({
1725
+ argument: "separator",
1726
+ message: `The separator "${separator}" must not be part of the alphabet "${alphabet}".`
1727
+ });
1728
+ }
1729
+ return () => `${prefix}${separator}${generator()}`;
1730
+ };
1731
+ var generateId = createIdGenerator();
1732
+ function isAbortError(error) {
1733
+ return (error instanceof Error || error instanceof DOMException) && (error.name === "AbortError" || error.name === "ResponseAborted" || // Next.js
1734
+ error.name === "TimeoutError");
1735
+ }
1736
+ var FETCH_FAILED_ERROR_MESSAGES = ["fetch failed", "failed to fetch"];
1737
+ function handleFetchError({
1738
+ error,
1739
+ url,
1740
+ requestBodyValues
1741
+ }) {
1742
+ if (isAbortError(error)) {
1743
+ return error;
1744
+ }
1745
+ if (error instanceof TypeError && FETCH_FAILED_ERROR_MESSAGES.includes(error.message.toLowerCase())) {
1746
+ const cause = error.cause;
1747
+ if (cause != null) {
1748
+ return new APICallError({
1749
+ message: `Cannot connect to API: ${cause.message}`,
1750
+ cause,
1751
+ url,
1752
+ requestBodyValues,
1753
+ isRetryable: true
1754
+ // retry when network error
1755
+ });
1756
+ }
1757
+ }
1758
+ return error;
1759
+ }
1760
+ function removeUndefinedEntries(record) {
1761
+ return Object.fromEntries(
1762
+ Object.entries(record).filter(([_key, value]) => value != null)
1763
+ );
1764
+ }
1765
+ function loadApiKey({
1766
+ apiKey,
1767
+ environmentVariableName,
1768
+ apiKeyParameterName = "apiKey",
1769
+ description
1770
+ }) {
1771
+ if (typeof apiKey === "string") {
1772
+ return apiKey;
1773
+ }
1774
+ if (apiKey != null) {
1775
+ throw new LoadAPIKeyError({
1776
+ message: `${description} API key must be a string.`
1777
+ });
1778
+ }
1779
+ if (typeof process === "undefined") {
1780
+ throw new LoadAPIKeyError({
1781
+ message: `${description} API key is missing. Pass it using the '${apiKeyParameterName}' parameter. Environment variables is not supported in this environment.`
1782
+ });
1783
+ }
1784
+ apiKey = process.env[environmentVariableName];
1785
+ if (apiKey == null) {
1786
+ throw new LoadAPIKeyError({
1787
+ message: `${description} API key is missing. Pass it using the '${apiKeyParameterName}' parameter or the ${environmentVariableName} environment variable.`
1788
+ });
1789
+ }
1790
+ if (typeof apiKey !== "string") {
1791
+ throw new LoadAPIKeyError({
1792
+ message: `${description} API key must be a string. The value of the ${environmentVariableName} environment variable is not a string.`
1793
+ });
1794
+ }
1795
+ return apiKey;
1796
+ }
1797
+ var suspectProtoRx = /"__proto__"\s*:/;
1798
+ var suspectConstructorRx = /"constructor"\s*:/;
1799
+ function _parse(text) {
1800
+ const obj = JSON.parse(text);
1801
+ if (obj === null || typeof obj !== "object") {
1802
+ return obj;
1803
+ }
1804
+ if (suspectProtoRx.test(text) === false && suspectConstructorRx.test(text) === false) {
1805
+ return obj;
1806
+ }
1807
+ return filter(obj);
1808
+ }
1809
+ function filter(obj) {
1810
+ let next = [obj];
1811
+ while (next.length) {
1812
+ const nodes = next;
1813
+ next = [];
1814
+ for (const node of nodes) {
1815
+ if (Object.prototype.hasOwnProperty.call(node, "__proto__")) {
1816
+ throw new SyntaxError("Object contains forbidden prototype property");
1817
+ }
1818
+ if (Object.prototype.hasOwnProperty.call(node, "constructor") && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
1819
+ throw new SyntaxError("Object contains forbidden prototype property");
1820
+ }
1821
+ for (const key in node) {
1822
+ const value = node[key];
1823
+ if (value && typeof value === "object") {
1824
+ next.push(value);
1825
+ }
1826
+ }
1827
+ }
1828
+ }
1829
+ return obj;
1830
+ }
1831
+ function secureJsonParse(text) {
1832
+ const { stackTraceLimit } = Error;
1833
+ Error.stackTraceLimit = 0;
1834
+ try {
1835
+ return _parse(text);
1836
+ } finally {
1837
+ Error.stackTraceLimit = stackTraceLimit;
1838
+ }
1839
+ }
1840
+ var validatorSymbol = Symbol.for("vercel.ai.validator");
1841
+ function validator(validate) {
1842
+ return { [validatorSymbol]: true, validate };
1843
+ }
1844
+ function isValidator(value) {
1845
+ return typeof value === "object" && value !== null && validatorSymbol in value && value[validatorSymbol] === true && "validate" in value;
1846
+ }
1847
+ function asValidator(value) {
1848
+ return isValidator(value) ? value : standardSchemaValidator(value);
1849
+ }
1850
+ function standardSchemaValidator(standardSchema) {
1851
+ return validator(async (value) => {
1852
+ const result = await standardSchema["~standard"].validate(value);
1853
+ return result.issues == null ? { success: true, value: result.value } : {
1854
+ success: false,
1855
+ error: new TypeValidationError({
1856
+ value,
1857
+ cause: result.issues
1858
+ })
1859
+ };
1860
+ });
1861
+ }
1862
+ async function validateTypes({
1863
+ value,
1864
+ schema
1865
+ }) {
1866
+ const result = await safeValidateTypes({ value, schema });
1867
+ if (!result.success) {
1868
+ throw TypeValidationError.wrap({ value, cause: result.error });
1869
+ }
1870
+ return result.value;
1871
+ }
1872
+ async function safeValidateTypes({
1873
+ value,
1874
+ schema
1875
+ }) {
1876
+ const validator2 = asValidator(schema);
1877
+ try {
1878
+ if (validator2.validate == null) {
1879
+ return { success: true, value, rawValue: value };
1880
+ }
1881
+ const result = await validator2.validate(value);
1882
+ if (result.success) {
1883
+ return { success: true, value: result.value, rawValue: value };
1884
+ }
1885
+ return {
1886
+ success: false,
1887
+ error: TypeValidationError.wrap({ value, cause: result.error }),
1888
+ rawValue: value
1889
+ };
1890
+ } catch (error) {
1891
+ return {
1892
+ success: false,
1893
+ error: TypeValidationError.wrap({ value, cause: error }),
1894
+ rawValue: value
1895
+ };
1896
+ }
1897
+ }
1898
+ async function parseJSON({
1899
+ text,
1900
+ schema
1901
+ }) {
1902
+ try {
1903
+ const value = secureJsonParse(text);
1904
+ if (schema == null) {
1905
+ return value;
1906
+ }
1907
+ return validateTypes({ value, schema });
1908
+ } catch (error) {
1909
+ if (JSONParseError.isInstance(error) || TypeValidationError.isInstance(error)) {
1910
+ throw error;
1911
+ }
1912
+ throw new JSONParseError({ text, cause: error });
1913
+ }
1914
+ }
1915
+ async function safeParseJSON({
1916
+ text,
1917
+ schema
1918
+ }) {
1919
+ try {
1920
+ const value = secureJsonParse(text);
1921
+ if (schema == null) {
1922
+ return { success: true, value, rawValue: value };
1923
+ }
1924
+ return await safeValidateTypes({ value, schema });
1925
+ } catch (error) {
1926
+ return {
1927
+ success: false,
1928
+ error: JSONParseError.isInstance(error) ? error : new JSONParseError({ text, cause: error }),
1929
+ rawValue: void 0
1930
+ };
1931
+ }
1932
+ }
1933
+ function isParsableJson(input) {
1934
+ try {
1935
+ secureJsonParse(input);
1936
+ return true;
1937
+ } catch (e) {
1938
+ return false;
1939
+ }
1940
+ }
1941
+ function parseJsonEventStream({
1942
+ stream,
1943
+ schema
1944
+ }) {
1945
+ return stream.pipeThrough(new TextDecoderStream()).pipeThrough(new EventSourceParserStream()).pipeThrough(
1946
+ new TransformStream({
1947
+ async transform({ data }, controller) {
1948
+ if (data === "[DONE]") {
1949
+ return;
1950
+ }
1951
+ controller.enqueue(await safeParseJSON({ text: data, schema }));
1952
+ }
1953
+ })
1954
+ );
1955
+ }
1956
+ async function parseProviderOptions({
1957
+ provider,
1958
+ providerOptions,
1959
+ schema
1960
+ }) {
1961
+ if ((providerOptions == null ? void 0 : providerOptions[provider]) == null) {
1962
+ return void 0;
1963
+ }
1964
+ const parsedProviderOptions = await safeValidateTypes({
1965
+ value: providerOptions[provider],
1966
+ schema
1967
+ });
1968
+ if (!parsedProviderOptions.success) {
1969
+ throw new InvalidArgumentError({
1970
+ argument: "providerOptions",
1971
+ message: `invalid ${provider} provider options`,
1972
+ cause: parsedProviderOptions.error
1973
+ });
1974
+ }
1975
+ return parsedProviderOptions.value;
1976
+ }
1977
+ var getOriginalFetch2 = () => globalThis.fetch;
1978
+ var postJsonToApi = async ({
1979
+ url,
1980
+ headers,
1981
+ body,
1982
+ failedResponseHandler,
1983
+ successfulResponseHandler,
1984
+ abortSignal,
1985
+ fetch
1986
+ }) => postToApi({
1987
+ url,
1988
+ headers: {
1989
+ "Content-Type": "application/json",
1990
+ ...headers
1991
+ },
1992
+ body: {
1993
+ content: JSON.stringify(body),
1994
+ values: body
1995
+ },
1996
+ failedResponseHandler,
1997
+ successfulResponseHandler,
1998
+ abortSignal,
1999
+ fetch
2000
+ });
2001
+ var postFormDataToApi = async ({
2002
+ url,
2003
+ headers,
2004
+ formData,
2005
+ failedResponseHandler,
2006
+ successfulResponseHandler,
2007
+ abortSignal,
2008
+ fetch
2009
+ }) => postToApi({
2010
+ url,
2011
+ headers,
2012
+ body: {
2013
+ content: formData,
2014
+ values: Object.fromEntries(formData.entries())
2015
+ },
2016
+ failedResponseHandler,
2017
+ successfulResponseHandler,
2018
+ abortSignal,
2019
+ fetch
2020
+ });
2021
+ var postToApi = async ({
2022
+ url,
2023
+ headers = {},
2024
+ body,
2025
+ successfulResponseHandler,
2026
+ failedResponseHandler,
2027
+ abortSignal,
2028
+ fetch = getOriginalFetch2()
2029
+ }) => {
2030
+ try {
2031
+ const response = await fetch(url, {
2032
+ method: "POST",
2033
+ headers: removeUndefinedEntries(headers),
2034
+ body: body.content,
2035
+ signal: abortSignal
2036
+ });
2037
+ const responseHeaders = extractResponseHeaders(response);
2038
+ if (!response.ok) {
2039
+ let errorInformation;
2040
+ try {
2041
+ errorInformation = await failedResponseHandler({
2042
+ response,
2043
+ url,
2044
+ requestBodyValues: body.values
2045
+ });
2046
+ } catch (error) {
2047
+ if (isAbortError(error) || APICallError.isInstance(error)) {
2048
+ throw error;
2049
+ }
2050
+ throw new APICallError({
2051
+ message: "Failed to process error response",
2052
+ cause: error,
2053
+ statusCode: response.status,
2054
+ url,
2055
+ responseHeaders,
2056
+ requestBodyValues: body.values
2057
+ });
2058
+ }
2059
+ throw errorInformation.value;
2060
+ }
2061
+ try {
2062
+ return await successfulResponseHandler({
2063
+ response,
2064
+ url,
2065
+ requestBodyValues: body.values
2066
+ });
2067
+ } catch (error) {
2068
+ if (error instanceof Error) {
2069
+ if (isAbortError(error) || APICallError.isInstance(error)) {
2070
+ throw error;
2071
+ }
2072
+ }
2073
+ throw new APICallError({
2074
+ message: "Failed to process successful response",
2075
+ cause: error,
2076
+ statusCode: response.status,
2077
+ url,
2078
+ responseHeaders,
2079
+ requestBodyValues: body.values
2080
+ });
2081
+ }
2082
+ } catch (error) {
2083
+ throw handleFetchError({ error, url, requestBodyValues: body.values });
2084
+ }
2085
+ };
2086
+ function tool(tool2) {
2087
+ return tool2;
2088
+ }
2089
+ function createProviderDefinedToolFactory({
2090
+ id,
2091
+ name: name14,
2092
+ inputSchema
2093
+ }) {
2094
+ return ({
2095
+ execute,
2096
+ outputSchema,
2097
+ toModelOutput,
2098
+ onInputStart,
2099
+ onInputDelta,
2100
+ onInputAvailable,
2101
+ ...args
2102
+ }) => tool({
2103
+ type: "provider-defined",
2104
+ id,
2105
+ name: name14,
2106
+ args,
2107
+ inputSchema,
2108
+ outputSchema,
2109
+ execute,
2110
+ toModelOutput,
2111
+ onInputStart,
2112
+ onInputDelta,
2113
+ onInputAvailable
2114
+ });
2115
+ }
2116
+ function createProviderDefinedToolFactoryWithOutputSchema({
2117
+ id,
2118
+ name: name14,
2119
+ inputSchema,
2120
+ outputSchema
2121
+ }) {
2122
+ return ({
2123
+ execute,
2124
+ toModelOutput,
2125
+ onInputStart,
2126
+ onInputDelta,
2127
+ onInputAvailable,
2128
+ ...args
2129
+ }) => tool({
2130
+ type: "provider-defined",
2131
+ id,
2132
+ name: name14,
2133
+ args,
2134
+ inputSchema,
2135
+ outputSchema,
2136
+ execute,
2137
+ toModelOutput,
2138
+ onInputStart,
2139
+ onInputDelta,
2140
+ onInputAvailable
2141
+ });
2142
+ }
2143
+ async function resolve(value) {
2144
+ if (typeof value === "function") {
2145
+ value = value();
2146
+ }
2147
+ return Promise.resolve(value);
2148
+ }
2149
+ var createJsonErrorResponseHandler = ({
2150
+ errorSchema,
2151
+ errorToMessage,
2152
+ isRetryable
2153
+ }) => async ({ response, url, requestBodyValues }) => {
2154
+ const responseBody = await response.text();
2155
+ const responseHeaders = extractResponseHeaders(response);
2156
+ if (responseBody.trim() === "") {
2157
+ return {
2158
+ responseHeaders,
2159
+ value: new APICallError({
2160
+ message: response.statusText,
2161
+ url,
2162
+ requestBodyValues,
2163
+ statusCode: response.status,
2164
+ responseHeaders,
2165
+ responseBody,
2166
+ isRetryable: isRetryable == null ? void 0 : isRetryable(response)
2167
+ })
2168
+ };
2169
+ }
2170
+ try {
2171
+ const parsedError = await parseJSON({
2172
+ text: responseBody,
2173
+ schema: errorSchema
2174
+ });
2175
+ return {
2176
+ responseHeaders,
2177
+ value: new APICallError({
2178
+ message: errorToMessage(parsedError),
2179
+ url,
2180
+ requestBodyValues,
2181
+ statusCode: response.status,
2182
+ responseHeaders,
2183
+ responseBody,
2184
+ data: parsedError,
2185
+ isRetryable: isRetryable == null ? void 0 : isRetryable(response, parsedError)
2186
+ })
2187
+ };
2188
+ } catch (parseError) {
2189
+ return {
2190
+ responseHeaders,
2191
+ value: new APICallError({
2192
+ message: response.statusText,
2193
+ url,
2194
+ requestBodyValues,
2195
+ statusCode: response.status,
2196
+ responseHeaders,
2197
+ responseBody,
2198
+ isRetryable: isRetryable == null ? void 0 : isRetryable(response)
2199
+ })
2200
+ };
2201
+ }
2202
+ };
2203
+ var createEventSourceResponseHandler = (chunkSchema) => async ({ response }) => {
2204
+ const responseHeaders = extractResponseHeaders(response);
2205
+ if (response.body == null) {
2206
+ throw new EmptyResponseBodyError({});
2207
+ }
2208
+ return {
2209
+ responseHeaders,
2210
+ value: parseJsonEventStream({
2211
+ stream: response.body,
2212
+ schema: chunkSchema
2213
+ })
2214
+ };
2215
+ };
2216
+ var createJsonResponseHandler = (responseSchema) => async ({ response, url, requestBodyValues }) => {
2217
+ const responseBody = await response.text();
2218
+ const parsedResult = await safeParseJSON({
2219
+ text: responseBody,
2220
+ schema: responseSchema
2221
+ });
2222
+ const responseHeaders = extractResponseHeaders(response);
2223
+ if (!parsedResult.success) {
2224
+ throw new APICallError({
2225
+ message: "Invalid JSON response",
2226
+ cause: parsedResult.error,
2227
+ statusCode: response.status,
2228
+ responseHeaders,
2229
+ responseBody,
2230
+ url,
2231
+ requestBodyValues
2232
+ });
2233
+ }
2234
+ return {
2235
+ responseHeaders,
2236
+ value: parsedResult.value,
2237
+ rawValue: parsedResult.rawValue
2238
+ };
2239
+ };
2240
+ var createBinaryResponseHandler = () => async ({ response, url, requestBodyValues }) => {
2241
+ const responseHeaders = extractResponseHeaders(response);
2242
+ if (!response.body) {
2243
+ throw new APICallError({
2244
+ message: "Response body is empty",
2245
+ url,
2246
+ requestBodyValues,
2247
+ statusCode: response.status,
2248
+ responseHeaders,
2249
+ responseBody: void 0
2250
+ });
2251
+ }
2252
+ try {
2253
+ const buffer = await response.arrayBuffer();
2254
+ return {
2255
+ responseHeaders,
2256
+ value: new Uint8Array(buffer)
2257
+ };
2258
+ } catch (error) {
2259
+ throw new APICallError({
2260
+ message: "Failed to read response as array buffer",
2261
+ url,
2262
+ requestBodyValues,
2263
+ statusCode: response.status,
2264
+ responseHeaders,
2265
+ responseBody: void 0,
2266
+ cause: error
2267
+ });
2268
+ }
2269
+ };
2270
+ var { btoa, atob } = globalThis;
2271
+ function convertBase64ToUint8Array(base64String) {
2272
+ const base64Url = base64String.replace(/-/g, "+").replace(/_/g, "/");
2273
+ const latin1string = atob(base64Url);
2274
+ return Uint8Array.from(latin1string, (byte) => byte.codePointAt(0));
2275
+ }
2276
+ function convertUint8ArrayToBase64(array) {
2277
+ let latin1string = "";
2278
+ for (let i = 0; i < array.length; i++) {
2279
+ latin1string += String.fromCodePoint(array[i]);
2280
+ }
2281
+ return btoa(latin1string);
2282
+ }
2283
+ function convertToBase64(value) {
2284
+ return value instanceof Uint8Array ? convertUint8ArrayToBase64(value) : value;
2285
+ }
2286
+ function withoutTrailingSlash(url) {
2287
+ return url == null ? void 0 : url.replace(/\/$/, "");
2288
+ }
2289
+
2290
+ exports.AISDKError = AISDKError;
2291
+ exports.APICallError = APICallError;
2292
+ exports.EmptyResponseBodyError = EmptyResponseBodyError;
2293
+ exports.EventSourceParserStream = EventSourceParserStream;
2294
+ exports.InvalidArgumentError = InvalidArgumentError;
2295
+ exports.InvalidPromptError = InvalidPromptError;
2296
+ exports.InvalidResponseDataError = InvalidResponseDataError;
2297
+ exports.JSONParseError = JSONParseError;
2298
+ exports.NoSuchModelError = NoSuchModelError;
2299
+ exports.TooManyEmbeddingValuesForCallError = TooManyEmbeddingValuesForCallError;
2300
+ exports.TypeValidationError = TypeValidationError;
2301
+ exports.UnsupportedFunctionalityError = UnsupportedFunctionalityError;
2302
+ exports.combineHeaders = combineHeaders;
2303
+ exports.convertBase64ToUint8Array = convertBase64ToUint8Array;
2304
+ exports.convertToBase64 = convertToBase64;
2305
+ exports.createBinaryResponseHandler = createBinaryResponseHandler;
2306
+ exports.createEventSourceResponseHandler = createEventSourceResponseHandler;
2307
+ exports.createJsonErrorResponseHandler = createJsonErrorResponseHandler;
2308
+ exports.createJsonResponseHandler = createJsonResponseHandler;
2309
+ exports.createProviderDefinedToolFactory = createProviderDefinedToolFactory;
2310
+ exports.createProviderDefinedToolFactoryWithOutputSchema = createProviderDefinedToolFactoryWithOutputSchema;
2041
2311
  exports.esm_default = esm_default;
2042
- exports.stringify = stringify;
2312
+ exports.generateId = generateId;
2313
+ exports.isParsableJson = isParsableJson;
2314
+ exports.loadApiKey = loadApiKey;
2315
+ exports.parseProviderOptions = parseProviderOptions;
2316
+ exports.postFormDataToApi = postFormDataToApi;
2317
+ exports.postJsonToApi = postJsonToApi;
2318
+ exports.resolve = resolve;
2319
+ exports.withoutTrailingSlash = withoutTrailingSlash;
2320
+ //# sourceMappingURL=chunk-HVBBFCDH.cjs.map
2321
+ //# sourceMappingURL=chunk-HVBBFCDH.cjs.map