@mastra/core 1.0.0-beta.11 → 1.0.0-beta.13

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 (394) hide show
  1. package/CHANGELOG.md +173 -0
  2. package/dist/_types/@internal_ai-sdk-v4/dist/index.d.ts +7549 -0
  3. package/dist/_types/@internal_ai-sdk-v4/dist/test.d.ts +65 -0
  4. package/dist/_types/@internal_ai-sdk-v5/dist/index.d.ts +8396 -0
  5. package/dist/_types/@internal_ai-sdk-v5/dist/test.d.ts +1708 -0
  6. package/dist/_types/@internal_external-types/dist/index.d.ts +858 -0
  7. package/dist/agent/agent-legacy.d.ts +1 -1
  8. package/dist/agent/agent.d.ts +1 -1
  9. package/dist/agent/agent.d.ts.map +1 -1
  10. package/dist/agent/agent.types.d.ts +5 -1
  11. package/dist/agent/agent.types.d.ts.map +1 -1
  12. package/dist/agent/index.cjs +9 -9
  13. package/dist/agent/index.js +2 -2
  14. package/dist/agent/message-list/index.cjs +3 -3
  15. package/dist/agent/message-list/index.d.ts +4 -3
  16. package/dist/agent/message-list/index.d.ts.map +1 -1
  17. package/dist/agent/message-list/index.js +1 -1
  18. package/dist/agent/message-list/prompt/attachments-to-parts.d.ts +1 -1
  19. package/dist/agent/message-list/prompt/invalid-content-error.d.ts +1 -1
  20. package/dist/agent/message-list/types.d.ts +3 -3
  21. package/dist/agent/message-list/types.d.ts.map +1 -1
  22. package/dist/agent/message-list/utils/ai-v4-v5/core-model-message.d.ts +1 -1
  23. package/dist/agent/message-list/utils/ai-v4-v5/ui-message.d.ts +1 -1
  24. package/dist/agent/message-list/utils/ai-v5/gemini-compatibility.d.ts +2 -2
  25. package/dist/agent/message-list/utils/ai-v5/gemini-compatibility.d.ts.map +1 -1
  26. package/dist/agent/message-list/utils/convert-messages.d.ts +2 -2
  27. package/dist/agent/message-list/utils/convert-messages.d.ts.map +1 -1
  28. package/dist/agent/types.d.ts +3 -3
  29. package/dist/agent/utils.d.ts +3 -3
  30. package/dist/agent/utils.d.ts.map +1 -1
  31. package/dist/agent/workflows/prepare-stream/index.d.ts +2 -1
  32. package/dist/agent/workflows/prepare-stream/index.d.ts.map +1 -1
  33. package/dist/agent/workflows/prepare-stream/prepare-tools-step.d.ts.map +1 -1
  34. package/dist/agent/workflows/prepare-stream/stream-step.d.ts +3 -1
  35. package/dist/agent/workflows/prepare-stream/stream-step.d.ts.map +1 -1
  36. package/dist/bundler/types.d.ts +14 -1
  37. package/dist/bundler/types.d.ts.map +1 -1
  38. package/dist/{chunk-U3XOLEPX.js → chunk-2IU4RGU5.js} +6 -32
  39. package/dist/chunk-2IU4RGU5.js.map +1 -0
  40. package/dist/chunk-2SQB3WBT.js +4574 -0
  41. package/dist/chunk-2SQB3WBT.js.map +1 -0
  42. package/dist/{chunk-THZTRBFS.js → chunk-373OC54J.js} +8 -8
  43. package/dist/chunk-373OC54J.js.map +1 -0
  44. package/dist/{chunk-F2GAJSBI.js → chunk-4BC5FUAO.js} +8 -6
  45. package/dist/{chunk-F2GAJSBI.js.map → chunk-4BC5FUAO.js.map} +1 -1
  46. package/dist/chunk-55VPMN3N.js +250 -0
  47. package/dist/chunk-55VPMN3N.js.map +1 -0
  48. package/dist/{chunk-QM5SRDJX.js → chunk-5PTZG26U.js} +66 -84
  49. package/dist/chunk-5PTZG26U.js.map +1 -0
  50. package/dist/chunk-5VZGJTPR.js +4837 -0
  51. package/dist/chunk-5VZGJTPR.js.map +1 -0
  52. package/dist/{chunk-C36YRTZ6.js → chunk-62Q7K656.js} +6 -7
  53. package/dist/chunk-62Q7K656.js.map +1 -0
  54. package/dist/chunk-6PMMP3FR.js +7 -0
  55. package/dist/chunk-6PMMP3FR.js.map +1 -0
  56. package/dist/{chunk-DZUJEN5N.cjs → chunk-6SZKM6EC.cjs} +10 -3
  57. package/dist/{chunk-DZUJEN5N.cjs.map → chunk-6SZKM6EC.cjs.map} +1 -1
  58. package/dist/{chunk-5WRI5ZAA.js → chunk-7D4SUZUM.js} +10 -4
  59. package/dist/{chunk-5WRI5ZAA.js.map → chunk-7D4SUZUM.js.map} +1 -1
  60. package/dist/{chunk-YWMMBIOM.cjs → chunk-7HEAVZRS.cjs} +15 -15
  61. package/dist/{chunk-YWMMBIOM.cjs.map → chunk-7HEAVZRS.cjs.map} +1 -1
  62. package/dist/{chunk-BUKY6CTR.cjs → chunk-AGHLXC4I.cjs} +106 -36
  63. package/dist/chunk-AGHLXC4I.cjs.map +1 -0
  64. package/dist/{chunk-PK2A5WBG.js → chunk-ARAQIW6E.js} +222 -604
  65. package/dist/chunk-ARAQIW6E.js.map +1 -0
  66. package/dist/{chunk-US2U7ECW.js → chunk-BQDZIQ3G.js} +156 -90
  67. package/dist/chunk-BQDZIQ3G.js.map +1 -0
  68. package/dist/chunk-D22XABFZ.js +79 -0
  69. package/dist/chunk-D22XABFZ.js.map +1 -0
  70. package/dist/{chunk-2ULLRN4Y.js → chunk-E5BQRAJK.js} +943 -626
  71. package/dist/chunk-E5BQRAJK.js.map +1 -0
  72. package/dist/chunk-FST2G2FQ.cjs +84 -0
  73. package/dist/chunk-FST2G2FQ.cjs.map +1 -0
  74. package/dist/chunk-FVQTJUBD.cjs +2120 -0
  75. package/dist/chunk-FVQTJUBD.cjs.map +1 -0
  76. package/dist/chunk-G6E6V2Z4.js +2070 -0
  77. package/dist/chunk-G6E6V2Z4.js.map +1 -0
  78. package/dist/{chunk-7P6BNIJH.js → chunk-GIWC35YQ.js} +105 -35
  79. package/dist/chunk-GIWC35YQ.js.map +1 -0
  80. package/dist/{chunk-4JKEUSCC.cjs → chunk-H4VUIOWU.cjs} +22 -20
  81. package/dist/chunk-H4VUIOWU.cjs.map +1 -0
  82. package/dist/{chunk-TWH4PTDG.cjs → chunk-HWMMIRIF.cjs} +32 -27
  83. package/dist/chunk-HWMMIRIF.cjs.map +1 -0
  84. package/dist/chunk-IXZ2T2QX.cjs +448 -0
  85. package/dist/chunk-IXZ2T2QX.cjs.map +1 -0
  86. package/dist/chunk-L3NKIMF5.cjs +10 -0
  87. package/dist/chunk-L3NKIMF5.cjs.map +1 -0
  88. package/dist/chunk-L4JCRWDY.cjs +252 -0
  89. package/dist/chunk-L4JCRWDY.cjs.map +1 -0
  90. package/dist/{chunk-BJXKH4LG.cjs → chunk-LGB4VNZI.cjs} +43 -78
  91. package/dist/chunk-LGB4VNZI.cjs.map +1 -0
  92. package/dist/{chunk-PG5H6QIO.cjs → chunk-MLKE7HRS.cjs} +41 -21
  93. package/dist/chunk-MLKE7HRS.cjs.map +1 -0
  94. package/dist/{chunk-OEIVMCWX.js → chunk-MRRFTNF4.js} +2537 -84
  95. package/dist/chunk-MRRFTNF4.js.map +1 -0
  96. package/dist/chunk-MXBVP7HX.cjs +4842 -0
  97. package/dist/chunk-MXBVP7HX.cjs.map +1 -0
  98. package/dist/chunk-NESKUIRE.cjs +4586 -0
  99. package/dist/chunk-NESKUIRE.cjs.map +1 -0
  100. package/dist/{chunk-SVLMF4UZ.cjs → chunk-NIOEY3N3.cjs} +66 -85
  101. package/dist/chunk-NIOEY3N3.cjs.map +1 -0
  102. package/dist/{chunk-CZEJQSWB.cjs → chunk-OWIEOL55.cjs} +295 -677
  103. package/dist/chunk-OWIEOL55.cjs.map +1 -0
  104. package/dist/{chunk-WTSZBHIZ.cjs → chunk-PJAK4U6R.cjs} +24 -24
  105. package/dist/{chunk-WTSZBHIZ.cjs.map → chunk-PJAK4U6R.cjs.map} +1 -1
  106. package/dist/{chunk-52RSUALV.cjs → chunk-R5AJGM55.cjs} +1314 -995
  107. package/dist/chunk-R5AJGM55.cjs.map +1 -0
  108. package/dist/{chunk-IVV5TOMD.js → chunk-RCJLMMTO.js} +32 -12
  109. package/dist/chunk-RCJLMMTO.js.map +1 -0
  110. package/dist/{chunk-S73Z3PBJ.cjs → chunk-SZYSDJTN.cjs} +27 -28
  111. package/dist/chunk-SZYSDJTN.cjs.map +1 -0
  112. package/dist/{chunk-YC6PJEPH.cjs → chunk-U4CSOY6T.cjs} +188 -122
  113. package/dist/chunk-U4CSOY6T.cjs.map +1 -0
  114. package/dist/chunk-UBSPZTQX.js +434 -0
  115. package/dist/chunk-UBSPZTQX.js.map +1 -0
  116. package/dist/{chunk-SCUWP4II.cjs → chunk-VEPP75C4.cjs} +47 -74
  117. package/dist/chunk-VEPP75C4.cjs.map +1 -0
  118. package/dist/{chunk-JIGDJK2O.js → chunk-VETAQUW3.js} +4 -39
  119. package/dist/chunk-VETAQUW3.js.map +1 -0
  120. package/dist/{chunk-Z57R5WS4.js → chunk-WPTTKULS.js} +4 -4
  121. package/dist/{chunk-Z57R5WS4.js.map → chunk-WPTTKULS.js.map} +1 -1
  122. package/dist/{chunk-O2BJW7YA.js → chunk-WYGUWVTF.js} +5 -5
  123. package/dist/{chunk-O2BJW7YA.js.map → chunk-WYGUWVTF.js.map} +1 -1
  124. package/dist/{chunk-SXNQRJQD.js → chunk-WYWRMIQC.js} +127 -22
  125. package/dist/chunk-WYWRMIQC.js.map +1 -0
  126. package/dist/{chunk-5Q6WAYEY.cjs → chunk-X6IBA7FP.cjs} +137 -50
  127. package/dist/chunk-X6IBA7FP.cjs.map +1 -0
  128. package/dist/{chunk-MRFUISXC.cjs → chunk-Y7MZ5LJT.cjs} +2632 -179
  129. package/dist/chunk-Y7MZ5LJT.cjs.map +1 -0
  130. package/dist/{chunk-JJ5O45LH.js → chunk-YPLZDWG7.js} +32 -27
  131. package/dist/chunk-YPLZDWG7.js.map +1 -0
  132. package/dist/{chunk-MGCGWPQJ.cjs → chunk-Z55SJVEC.cjs} +8 -8
  133. package/dist/chunk-Z55SJVEC.cjs.map +1 -0
  134. package/dist/error/index.cjs +6 -6
  135. package/dist/error/index.d.ts +26 -20
  136. package/dist/error/index.d.ts.map +1 -1
  137. package/dist/error/index.js +1 -1
  138. package/dist/error/utils.d.ts +19 -5
  139. package/dist/error/utils.d.ts.map +1 -1
  140. package/dist/evals/index.cjs +4 -4
  141. package/dist/evals/index.js +1 -1
  142. package/dist/evals/run/index.d.ts +1 -1
  143. package/dist/evals/scoreTraces/index.cjs +8 -8
  144. package/dist/evals/scoreTraces/index.js +2 -2
  145. package/dist/evals/types.d.ts +1 -1
  146. package/dist/events/event-emitter.d.ts +6 -1
  147. package/dist/events/event-emitter.d.ts.map +1 -1
  148. package/dist/index.cjs +2 -2
  149. package/dist/index.js +1 -1
  150. package/dist/integration/index.cjs +2 -2
  151. package/dist/integration/index.js +1 -1
  152. package/dist/llm/index.cjs +15 -15
  153. package/dist/llm/index.d.ts +2 -2
  154. package/dist/llm/index.d.ts.map +1 -1
  155. package/dist/llm/index.js +5 -5
  156. package/dist/llm/model/aisdk/v5/model.d.ts +1 -1
  157. package/dist/llm/model/base.types.d.ts +2 -2
  158. package/dist/llm/model/model.d.ts +1 -1
  159. package/dist/llm/model/model.d.ts.map +1 -1
  160. package/dist/llm/model/model.loop.d.ts +2 -2
  161. package/dist/llm/model/model.loop.d.ts.map +1 -1
  162. package/dist/llm/model/model.loop.types.d.ts +1 -1
  163. package/dist/llm/model/model.loop.types.d.ts.map +1 -1
  164. package/dist/llm/model/provider-types.generated.d.ts +51 -11
  165. package/dist/llm/model/shared.types.d.ts +1 -1
  166. package/dist/loop/index.cjs +2 -2
  167. package/dist/loop/index.js +1 -1
  168. package/dist/loop/loop.d.ts +2 -2
  169. package/dist/loop/loop.d.ts.map +1 -1
  170. package/dist/loop/test-utils/MastraLanguageModelV2Mock.d.ts +1 -1
  171. package/dist/loop/test-utils/MastraLanguageModelV2Mock.d.ts.map +1 -1
  172. package/dist/loop/test-utils/options.d.ts.map +1 -1
  173. package/dist/loop/test-utils/streamObject.d.ts +1 -1
  174. package/dist/loop/test-utils/streamObject.d.ts.map +1 -1
  175. package/dist/loop/test-utils/tools.d.ts.map +1 -1
  176. package/dist/loop/types.d.ts +3 -1
  177. package/dist/loop/types.d.ts.map +1 -1
  178. package/dist/loop/workflows/agentic-execution/index.d.ts +13 -13
  179. package/dist/loop/workflows/agentic-execution/index.d.ts.map +1 -1
  180. package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts +10 -10
  181. package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts.map +1 -1
  182. package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts +5 -5
  183. package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts.map +1 -1
  184. package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts +22 -21
  185. package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts.map +1 -1
  186. package/dist/loop/workflows/agentic-loop/index.d.ts +13 -13
  187. package/dist/loop/workflows/agentic-loop/index.d.ts.map +1 -1
  188. package/dist/loop/workflows/schema.d.ts +6 -6
  189. package/dist/loop/workflows/schema.d.ts.map +1 -1
  190. package/dist/loop/workflows/stream.d.ts +2 -2
  191. package/dist/loop/workflows/stream.d.ts.map +1 -1
  192. package/dist/mastra/index.cjs +2 -2
  193. package/dist/mastra/index.js +1 -1
  194. package/dist/mcp/index.cjs +4 -4
  195. package/dist/mcp/index.js +1 -1
  196. package/dist/memory/index.cjs +6 -6
  197. package/dist/memory/index.js +1 -1
  198. package/dist/memory/memory.d.ts +1 -1
  199. package/dist/memory/types.d.ts +3 -3
  200. package/dist/memory/types.d.ts.map +1 -1
  201. package/dist/models-dev-D3EKFGAO.cjs +12 -0
  202. package/dist/{models-dev-EO3SUIY2.cjs.map → models-dev-D3EKFGAO.cjs.map} +1 -1
  203. package/dist/models-dev-EO22XOXQ.js +3 -0
  204. package/dist/{models-dev-23RN2WHG.js.map → models-dev-EO22XOXQ.js.map} +1 -1
  205. package/dist/netlify-AE4LNCAI.js +3 -0
  206. package/dist/{netlify-GXJ5D5DD.js.map → netlify-AE4LNCAI.js.map} +1 -1
  207. package/dist/netlify-WE42TZIT.cjs +12 -0
  208. package/dist/{netlify-KJLY3GFS.cjs.map → netlify-WE42TZIT.cjs.map} +1 -1
  209. package/dist/processors/index.cjs +37 -37
  210. package/dist/processors/index.d.ts +2 -2
  211. package/dist/processors/index.d.ts.map +1 -1
  212. package/dist/processors/index.js +1 -1
  213. package/dist/processors/step-schema.d.ts +1267 -1267
  214. package/dist/processors/step-schema.d.ts.map +1 -1
  215. package/dist/provider-registry-6LF3NGC5.js +3 -0
  216. package/dist/{provider-registry-F67Y6OF2.js.map → provider-registry-6LF3NGC5.js.map} +1 -1
  217. package/dist/provider-registry-73FKMXJV.cjs +40 -0
  218. package/dist/{provider-registry-3TG2KUD2.cjs.map → provider-registry-73FKMXJV.cjs.map} +1 -1
  219. package/dist/provider-registry.json +100 -30
  220. package/dist/{registry-generator-UMTNPBJX.js → registry-generator-AVQXI3GX.js} +2 -2
  221. package/dist/{registry-generator-UMTNPBJX.js.map → registry-generator-AVQXI3GX.js.map} +1 -1
  222. package/dist/{registry-generator-34SC4TAU.cjs → registry-generator-KOFNIIWJ.cjs} +2 -2
  223. package/dist/{registry-generator-34SC4TAU.cjs.map → registry-generator-KOFNIIWJ.cjs.map} +1 -1
  224. package/dist/relevance/index.cjs +2 -2
  225. package/dist/relevance/index.js +1 -1
  226. package/dist/server/index.cjs +5 -5
  227. package/dist/server/index.js +1 -1
  228. package/dist/storage/base.d.ts +2 -10
  229. package/dist/storage/base.d.ts.map +1 -1
  230. package/dist/storage/domains/workflows/base.d.ts +2 -8
  231. package/dist/storage/domains/workflows/base.d.ts.map +1 -1
  232. package/dist/storage/domains/workflows/inmemory.d.ts +2 -8
  233. package/dist/storage/domains/workflows/inmemory.d.ts.map +1 -1
  234. package/dist/storage/index.cjs +38 -38
  235. package/dist/storage/index.js +1 -1
  236. package/dist/storage/mock.d.ts +2 -8
  237. package/dist/storage/mock.d.ts.map +1 -1
  238. package/dist/storage/types.d.ts +9 -1
  239. package/dist/storage/types.d.ts.map +1 -1
  240. package/dist/stream/RunOutput.d.ts +1 -1
  241. package/dist/stream/aisdk/v4/input.d.ts +1 -1
  242. package/dist/stream/aisdk/v5/compat/content.d.ts +1 -1
  243. package/dist/stream/aisdk/v5/compat/content.d.ts.map +1 -1
  244. package/dist/stream/aisdk/v5/compat/prepare-tools.d.ts +1 -1
  245. package/dist/stream/aisdk/v5/compat/prepare-tools.d.ts.map +1 -1
  246. package/dist/stream/aisdk/v5/compat/ui-message.d.ts +1 -1
  247. package/dist/stream/aisdk/v5/compat/ui-message.d.ts.map +1 -1
  248. package/dist/stream/aisdk/v5/compat/validation.d.ts +1 -1
  249. package/dist/stream/aisdk/v5/compat/validation.d.ts.map +1 -1
  250. package/dist/stream/aisdk/v5/execute.d.ts +2 -2
  251. package/dist/stream/aisdk/v5/execute.d.ts.map +1 -1
  252. package/dist/stream/aisdk/v5/input.d.ts +1 -1
  253. package/dist/stream/aisdk/v5/input.d.ts.map +1 -1
  254. package/dist/stream/aisdk/v5/output-helpers.d.ts +12 -27
  255. package/dist/stream/aisdk/v5/output-helpers.d.ts.map +1 -1
  256. package/dist/stream/aisdk/v5/output.d.ts +41 -91
  257. package/dist/stream/aisdk/v5/output.d.ts.map +1 -1
  258. package/dist/stream/aisdk/v5/transform.d.ts +1 -1
  259. package/dist/stream/aisdk/v5/transform.d.ts.map +1 -1
  260. package/dist/stream/base/input.d.ts +1 -1
  261. package/dist/stream/base/output.d.ts +9 -31
  262. package/dist/stream/base/output.d.ts.map +1 -1
  263. package/dist/stream/base/schema.d.ts +2 -2
  264. package/dist/stream/base/schema.d.ts.map +1 -1
  265. package/dist/stream/index.cjs +12 -12
  266. package/dist/stream/index.js +2 -2
  267. package/dist/stream/types.d.ts +3 -2
  268. package/dist/stream/types.d.ts.map +1 -1
  269. package/dist/test-utils/llm-mock.cjs +14587 -14
  270. package/dist/test-utils/llm-mock.cjs.map +1 -1
  271. package/dist/test-utils/llm-mock.d.ts +3 -3
  272. package/dist/test-utils/llm-mock.d.ts.map +1 -1
  273. package/dist/test-utils/llm-mock.js +14577 -4
  274. package/dist/test-utils/llm-mock.js.map +1 -1
  275. package/dist/token-6GSAFR2W-SGVIXFCP.cjs +63 -0
  276. package/dist/token-6GSAFR2W-SGVIXFCP.cjs.map +1 -0
  277. package/dist/token-6GSAFR2W-SPYPLMBM.js +61 -0
  278. package/dist/token-6GSAFR2W-SPYPLMBM.js.map +1 -0
  279. package/dist/token-util-NEHG7TUY-7GMW5FXI.cjs +10 -0
  280. package/dist/token-util-NEHG7TUY-7GMW5FXI.cjs.map +1 -0
  281. package/dist/token-util-NEHG7TUY-JRJTGTAB.js +8 -0
  282. package/dist/token-util-NEHG7TUY-JRJTGTAB.js.map +1 -0
  283. package/dist/tools/index.cjs +4 -4
  284. package/dist/tools/index.js +1 -1
  285. package/dist/tools/is-vercel-tool.cjs +2 -2
  286. package/dist/tools/is-vercel-tool.js +1 -1
  287. package/dist/tools/tool-builder/builder.d.ts +2 -1
  288. package/dist/tools/tool-builder/builder.d.ts.map +1 -1
  289. package/dist/tools/tool.d.ts.map +1 -1
  290. package/dist/tools/types.d.ts +5 -5
  291. package/dist/tools/types.d.ts.map +1 -1
  292. package/dist/utils.cjs +22 -22
  293. package/dist/utils.d.ts +3 -3
  294. package/dist/utils.d.ts.map +1 -1
  295. package/dist/utils.js +1 -1
  296. package/dist/vector/embed.d.ts +2 -2
  297. package/dist/vector/embed.d.ts.map +1 -1
  298. package/dist/vector/index.cjs +11 -11
  299. package/dist/vector/index.js +3 -3
  300. package/dist/vector/vector.d.ts +1 -1
  301. package/dist/voice/aisdk/speech.d.ts +1 -1
  302. package/dist/voice/aisdk/speech.d.ts.map +1 -1
  303. package/dist/voice/aisdk/transcription.d.ts +1 -1
  304. package/dist/voice/aisdk/transcription.d.ts.map +1 -1
  305. package/dist/voice/composite-voice.d.ts +1 -1
  306. package/dist/voice/composite-voice.d.ts.map +1 -1
  307. package/dist/voice/index.cjs +6 -6
  308. package/dist/voice/index.js +1 -1
  309. package/dist/workflows/constants.cjs +4 -4
  310. package/dist/workflows/constants.d.ts +1 -1
  311. package/dist/workflows/constants.d.ts.map +1 -1
  312. package/dist/workflows/constants.js +1 -1
  313. package/dist/workflows/default.d.ts +9 -16
  314. package/dist/workflows/default.d.ts.map +1 -1
  315. package/dist/workflows/evented/execution-engine.d.ts +3 -2
  316. package/dist/workflows/evented/execution-engine.d.ts.map +1 -1
  317. package/dist/workflows/evented/index.cjs +10 -10
  318. package/dist/workflows/evented/index.js +1 -1
  319. package/dist/workflows/evented/step-executor.d.ts +1 -1
  320. package/dist/workflows/evented/step-executor.d.ts.map +1 -1
  321. package/dist/workflows/evented/workflow-event-processor/index.d.ts +1 -1
  322. package/dist/workflows/evented/workflow-event-processor/index.d.ts.map +1 -1
  323. package/dist/workflows/evented/workflow.d.ts +15 -0
  324. package/dist/workflows/evented/workflow.d.ts.map +1 -1
  325. package/dist/workflows/execution-engine.d.ts +25 -2
  326. package/dist/workflows/execution-engine.d.ts.map +1 -1
  327. package/dist/workflows/handlers/control-flow.d.ts +6 -5
  328. package/dist/workflows/handlers/control-flow.d.ts.map +1 -1
  329. package/dist/workflows/handlers/entry.d.ts +5 -3
  330. package/dist/workflows/handlers/entry.d.ts.map +1 -1
  331. package/dist/workflows/handlers/sleep.d.ts +4 -3
  332. package/dist/workflows/handlers/sleep.d.ts.map +1 -1
  333. package/dist/workflows/handlers/step.d.ts +5 -3
  334. package/dist/workflows/handlers/step.d.ts.map +1 -1
  335. package/dist/workflows/index.cjs +26 -22
  336. package/dist/workflows/index.js +1 -1
  337. package/dist/workflows/step.d.ts +5 -4
  338. package/dist/workflows/step.d.ts.map +1 -1
  339. package/dist/workflows/types.d.ts +66 -14
  340. package/dist/workflows/types.d.ts.map +1 -1
  341. package/dist/workflows/utils.d.ts +11 -0
  342. package/dist/workflows/utils.d.ts.map +1 -1
  343. package/dist/workflows/workflow.d.ts +26 -8
  344. package/dist/workflows/workflow.d.ts.map +1 -1
  345. package/package.json +12 -11
  346. package/src/llm/model/provider-types.generated.d.ts +51 -11
  347. package/dist/agent/__tests__/mock-model.d.ts +0 -8
  348. package/dist/agent/__tests__/mock-model.d.ts.map +0 -1
  349. package/dist/agent/agent-types.test-d.d.ts +0 -2
  350. package/dist/agent/agent-types.test-d.d.ts.map +0 -1
  351. package/dist/ai-sdk.types.d.ts +0 -4705
  352. package/dist/chunk-2ULLRN4Y.js.map +0 -1
  353. package/dist/chunk-3E3ILV6T.cjs +0 -518
  354. package/dist/chunk-3E3ILV6T.cjs.map +0 -1
  355. package/dist/chunk-4JKEUSCC.cjs.map +0 -1
  356. package/dist/chunk-52RSUALV.cjs.map +0 -1
  357. package/dist/chunk-5PAEYE3Q.js +0 -513
  358. package/dist/chunk-5PAEYE3Q.js.map +0 -1
  359. package/dist/chunk-5Q6WAYEY.cjs.map +0 -1
  360. package/dist/chunk-7P6BNIJH.js.map +0 -1
  361. package/dist/chunk-ABJOUEVA.cjs +0 -10
  362. package/dist/chunk-ABJOUEVA.cjs.map +0 -1
  363. package/dist/chunk-BJXKH4LG.cjs.map +0 -1
  364. package/dist/chunk-BUKY6CTR.cjs.map +0 -1
  365. package/dist/chunk-C36YRTZ6.js.map +0 -1
  366. package/dist/chunk-CZEJQSWB.cjs.map +0 -1
  367. package/dist/chunk-IVV5TOMD.js.map +0 -1
  368. package/dist/chunk-JIGDJK2O.js.map +0 -1
  369. package/dist/chunk-JJ5O45LH.js.map +0 -1
  370. package/dist/chunk-MGCGWPQJ.cjs.map +0 -1
  371. package/dist/chunk-MRFUISXC.cjs.map +0 -1
  372. package/dist/chunk-NLNKQD2T.js +0 -7
  373. package/dist/chunk-NLNKQD2T.js.map +0 -1
  374. package/dist/chunk-OEIVMCWX.js.map +0 -1
  375. package/dist/chunk-PG5H6QIO.cjs.map +0 -1
  376. package/dist/chunk-PK2A5WBG.js.map +0 -1
  377. package/dist/chunk-QM5SRDJX.js.map +0 -1
  378. package/dist/chunk-S73Z3PBJ.cjs.map +0 -1
  379. package/dist/chunk-SCUWP4II.cjs.map +0 -1
  380. package/dist/chunk-SVLMF4UZ.cjs.map +0 -1
  381. package/dist/chunk-SXNQRJQD.js.map +0 -1
  382. package/dist/chunk-THZTRBFS.js.map +0 -1
  383. package/dist/chunk-TWH4PTDG.cjs.map +0 -1
  384. package/dist/chunk-U3XOLEPX.js.map +0 -1
  385. package/dist/chunk-US2U7ECW.js.map +0 -1
  386. package/dist/chunk-YC6PJEPH.cjs.map +0 -1
  387. package/dist/models-dev-23RN2WHG.js +0 -3
  388. package/dist/models-dev-EO3SUIY2.cjs +0 -12
  389. package/dist/netlify-GXJ5D5DD.js +0 -3
  390. package/dist/netlify-KJLY3GFS.cjs +0 -12
  391. package/dist/provider-registry-3TG2KUD2.cjs +0 -40
  392. package/dist/provider-registry-F67Y6OF2.js +0 -3
  393. package/dist/tools/tool-stream-types.test-d.d.ts +0 -2
  394. package/dist/tools/tool-stream-types.test-d.d.ts.map +0 -1
@@ -0,0 +1,2070 @@
1
+ import * as z4 from 'zod/v4';
2
+ import { ZodFirstPartyTypeKind } from 'zod/v3';
3
+
4
+ // ../_vendored/ai_v5/dist/chunk-USLS7XOK.js
5
+ var marker = "vercel.ai.error";
6
+ var symbol = Symbol.for(marker);
7
+ var _a;
8
+ var _AISDKError = class _AISDKError2 extends Error {
9
+ /**
10
+ * Creates an AI SDK Error.
11
+ *
12
+ * @param {Object} params - The parameters for creating the error.
13
+ * @param {string} params.name - The name of the error.
14
+ * @param {string} params.message - The error message.
15
+ * @param {unknown} [params.cause] - The underlying cause of the error.
16
+ */
17
+ constructor({
18
+ name: name14,
19
+ message,
20
+ cause
21
+ }) {
22
+ super(message);
23
+ this[_a] = true;
24
+ this.name = name14;
25
+ this.cause = cause;
26
+ }
27
+ /**
28
+ * Checks if the given error is an AI SDK Error.
29
+ * @param {unknown} error - The error to check.
30
+ * @returns {boolean} True if the error is an AI SDK Error, false otherwise.
31
+ */
32
+ static isInstance(error) {
33
+ return _AISDKError2.hasMarker(error, marker);
34
+ }
35
+ static hasMarker(error, marker15) {
36
+ const markerSymbol = Symbol.for(marker15);
37
+ return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
38
+ }
39
+ };
40
+ _a = symbol;
41
+ var AISDKError = _AISDKError;
42
+ var name = "AI_APICallError";
43
+ var marker2 = `vercel.ai.error.${name}`;
44
+ var symbol2 = Symbol.for(marker2);
45
+ var _a2;
46
+ var APICallError = class extends AISDKError {
47
+ constructor({
48
+ message,
49
+ url,
50
+ requestBodyValues,
51
+ statusCode,
52
+ responseHeaders,
53
+ responseBody,
54
+ cause,
55
+ isRetryable = statusCode != null && (statusCode === 408 || // request timeout
56
+ statusCode === 409 || // conflict
57
+ statusCode === 429 || // too many requests
58
+ statusCode >= 500),
59
+ // server error
60
+ data
61
+ }) {
62
+ super({ name, message, cause });
63
+ this[_a2] = true;
64
+ this.url = url;
65
+ this.requestBodyValues = requestBodyValues;
66
+ this.statusCode = statusCode;
67
+ this.responseHeaders = responseHeaders;
68
+ this.responseBody = responseBody;
69
+ this.isRetryable = isRetryable;
70
+ this.data = data;
71
+ }
72
+ static isInstance(error) {
73
+ return AISDKError.hasMarker(error, marker2);
74
+ }
75
+ };
76
+ _a2 = symbol2;
77
+ var name2 = "AI_EmptyResponseBodyError";
78
+ var marker3 = `vercel.ai.error.${name2}`;
79
+ var symbol3 = Symbol.for(marker3);
80
+ var _a3;
81
+ var EmptyResponseBodyError = class extends AISDKError {
82
+ // used in isInstance
83
+ constructor({ message = "Empty response body" } = {}) {
84
+ super({ name: name2, message });
85
+ this[_a3] = true;
86
+ }
87
+ static isInstance(error) {
88
+ return AISDKError.hasMarker(error, marker3);
89
+ }
90
+ };
91
+ _a3 = symbol3;
92
+ function getErrorMessage(error) {
93
+ if (error == null) {
94
+ return "unknown error";
95
+ }
96
+ if (typeof error === "string") {
97
+ return error;
98
+ }
99
+ if (error instanceof Error) {
100
+ return error.message;
101
+ }
102
+ return JSON.stringify(error);
103
+ }
104
+ var name3 = "AI_InvalidArgumentError";
105
+ var marker4 = `vercel.ai.error.${name3}`;
106
+ var symbol4 = Symbol.for(marker4);
107
+ var _a4;
108
+ var InvalidArgumentError = class extends AISDKError {
109
+ constructor({
110
+ message,
111
+ cause,
112
+ argument
113
+ }) {
114
+ super({ name: name3, message, cause });
115
+ this[_a4] = true;
116
+ this.argument = argument;
117
+ }
118
+ static isInstance(error) {
119
+ return AISDKError.hasMarker(error, marker4);
120
+ }
121
+ };
122
+ _a4 = symbol4;
123
+ var name6 = "AI_JSONParseError";
124
+ var marker7 = `vercel.ai.error.${name6}`;
125
+ var symbol7 = Symbol.for(marker7);
126
+ var _a7;
127
+ var JSONParseError = class extends AISDKError {
128
+ constructor({ text, cause }) {
129
+ super({
130
+ name: name6,
131
+ message: `JSON parsing failed: Text: ${text}.
132
+ Error message: ${getErrorMessage(cause)}`,
133
+ cause
134
+ });
135
+ this[_a7] = true;
136
+ this.text = text;
137
+ }
138
+ static isInstance(error) {
139
+ return AISDKError.hasMarker(error, marker7);
140
+ }
141
+ };
142
+ _a7 = symbol7;
143
+ var name12 = "AI_TypeValidationError";
144
+ var marker13 = `vercel.ai.error.${name12}`;
145
+ var symbol13 = Symbol.for(marker13);
146
+ var _a13;
147
+ var _TypeValidationError = class _TypeValidationError2 extends AISDKError {
148
+ constructor({ value, cause }) {
149
+ super({
150
+ name: name12,
151
+ message: `Type validation failed: Value: ${JSON.stringify(value)}.
152
+ Error message: ${getErrorMessage(cause)}`,
153
+ cause
154
+ });
155
+ this[_a13] = true;
156
+ this.value = value;
157
+ }
158
+ static isInstance(error) {
159
+ return AISDKError.hasMarker(error, marker13);
160
+ }
161
+ /**
162
+ * Wraps an error into a TypeValidationError.
163
+ * If the cause is already a TypeValidationError with the same value, it returns the cause.
164
+ * Otherwise, it creates a new TypeValidationError.
165
+ *
166
+ * @param {Object} params - The parameters for wrapping the error.
167
+ * @param {unknown} params.value - The value that failed validation.
168
+ * @param {unknown} params.cause - The original error or cause of the validation failure.
169
+ * @returns {TypeValidationError} A TypeValidationError instance.
170
+ */
171
+ static wrap({
172
+ value,
173
+ cause
174
+ }) {
175
+ return _TypeValidationError2.isInstance(cause) && cause.value === value ? cause : new _TypeValidationError2({ value, cause });
176
+ }
177
+ };
178
+ _a13 = symbol13;
179
+ var TypeValidationError = _TypeValidationError;
180
+ var ParseError = class extends Error {
181
+ constructor(message, options) {
182
+ super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
183
+ }
184
+ };
185
+ function noop(_arg) {
186
+ }
187
+ function createParser(callbacks) {
188
+ if (typeof callbacks == "function")
189
+ throw new TypeError(
190
+ "`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?"
191
+ );
192
+ const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks;
193
+ let incompleteLine = "", isFirstChunk = true, id, data = "", eventType = "";
194
+ function feed(newChunk) {
195
+ const chunk = isFirstChunk ? newChunk.replace(/^\xEF\xBB\xBF/, "") : newChunk, [complete, incomplete] = splitLines(`${incompleteLine}${chunk}`);
196
+ for (const line of complete)
197
+ parseLine(line);
198
+ incompleteLine = incomplete, isFirstChunk = false;
199
+ }
200
+ function parseLine(line) {
201
+ if (line === "") {
202
+ dispatchEvent();
203
+ return;
204
+ }
205
+ if (line.startsWith(":")) {
206
+ onComment && onComment(line.slice(line.startsWith(": ") ? 2 : 1));
207
+ return;
208
+ }
209
+ const fieldSeparatorIndex = line.indexOf(":");
210
+ if (fieldSeparatorIndex !== -1) {
211
+ const field = line.slice(0, fieldSeparatorIndex), offset = line[fieldSeparatorIndex + 1] === " " ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
212
+ processField(field, value, line);
213
+ return;
214
+ }
215
+ processField(line, "", line);
216
+ }
217
+ function processField(field, value, line) {
218
+ switch (field) {
219
+ case "event":
220
+ eventType = value;
221
+ break;
222
+ case "data":
223
+ data = `${data}${value}
224
+ `;
225
+ break;
226
+ case "id":
227
+ id = value.includes("\0") ? void 0 : value;
228
+ break;
229
+ case "retry":
230
+ /^\d+$/.test(value) ? onRetry(parseInt(value, 10)) : onError(
231
+ new ParseError(`Invalid \`retry\` value: "${value}"`, {
232
+ type: "invalid-retry",
233
+ value,
234
+ line
235
+ })
236
+ );
237
+ break;
238
+ default:
239
+ onError(
240
+ new ParseError(
241
+ `Unknown field "${field.length > 20 ? `${field.slice(0, 20)}\u2026` : field}"`,
242
+ { type: "unknown-field", field, value, line }
243
+ )
244
+ );
245
+ break;
246
+ }
247
+ }
248
+ function dispatchEvent() {
249
+ data.length > 0 && onEvent({
250
+ id,
251
+ event: eventType || void 0,
252
+ // If the data buffer's last character is a U+000A LINE FEED (LF) character,
253
+ // then remove the last character from the data buffer.
254
+ data: data.endsWith(`
255
+ `) ? data.slice(0, -1) : data
256
+ }), id = void 0, data = "", eventType = "";
257
+ }
258
+ function reset(options = {}) {
259
+ incompleteLine && options.consume && parseLine(incompleteLine), isFirstChunk = true, id = void 0, data = "", eventType = "", incompleteLine = "";
260
+ }
261
+ return { feed, reset };
262
+ }
263
+ function splitLines(chunk) {
264
+ const lines = [];
265
+ let incompleteLine = "", searchIndex = 0;
266
+ for (; searchIndex < chunk.length; ) {
267
+ const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
268
+ `, searchIndex);
269
+ let lineEnd = -1;
270
+ 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) {
271
+ incompleteLine = chunk.slice(searchIndex);
272
+ break;
273
+ } else {
274
+ const line = chunk.slice(searchIndex, lineEnd);
275
+ lines.push(line), searchIndex = lineEnd + 1, chunk[searchIndex - 1] === "\r" && chunk[searchIndex] === `
276
+ ` && searchIndex++;
277
+ }
278
+ }
279
+ return [lines, incompleteLine];
280
+ }
281
+ var EventSourceParserStream = class extends TransformStream {
282
+ constructor({ onError, onRetry, onComment } = {}) {
283
+ let parser;
284
+ super({
285
+ start(controller) {
286
+ parser = createParser({
287
+ onEvent: (event) => {
288
+ controller.enqueue(event);
289
+ },
290
+ onError(error) {
291
+ onError === "terminate" ? controller.error(error) : typeof onError == "function" && onError(error);
292
+ },
293
+ onRetry,
294
+ onComment
295
+ });
296
+ },
297
+ transform(chunk) {
298
+ parser.feed(chunk);
299
+ }
300
+ });
301
+ }
302
+ };
303
+ function combineHeaders(...headers) {
304
+ return headers.reduce(
305
+ (combinedHeaders, currentHeaders) => ({
306
+ ...combinedHeaders,
307
+ ...currentHeaders != null ? currentHeaders : {}
308
+ }),
309
+ {}
310
+ );
311
+ }
312
+ async function delay(delayInMs, options) {
313
+ if (delayInMs == null) {
314
+ return Promise.resolve();
315
+ }
316
+ const signal = options == null ? void 0 : options.abortSignal;
317
+ return new Promise((resolve2, reject) => {
318
+ if (signal == null ? void 0 : signal.aborted) {
319
+ reject(createAbortError());
320
+ return;
321
+ }
322
+ const timeoutId = setTimeout(() => {
323
+ cleanup();
324
+ resolve2();
325
+ }, delayInMs);
326
+ const cleanup = () => {
327
+ clearTimeout(timeoutId);
328
+ signal == null ? void 0 : signal.removeEventListener("abort", onAbort);
329
+ };
330
+ const onAbort = () => {
331
+ cleanup();
332
+ reject(createAbortError());
333
+ };
334
+ signal == null ? void 0 : signal.addEventListener("abort", onAbort);
335
+ });
336
+ }
337
+ function createAbortError() {
338
+ return new DOMException("Delay was aborted", "AbortError");
339
+ }
340
+ function extractResponseHeaders(response) {
341
+ return Object.fromEntries([...response.headers]);
342
+ }
343
+ var createIdGenerator = ({
344
+ prefix,
345
+ size = 16,
346
+ alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
347
+ separator = "-"
348
+ } = {}) => {
349
+ const generator = () => {
350
+ const alphabetLength = alphabet.length;
351
+ const chars = new Array(size);
352
+ for (let i = 0; i < size; i++) {
353
+ chars[i] = alphabet[Math.random() * alphabetLength | 0];
354
+ }
355
+ return chars.join("");
356
+ };
357
+ if (prefix == null) {
358
+ return generator;
359
+ }
360
+ if (alphabet.includes(separator)) {
361
+ throw new InvalidArgumentError({
362
+ argument: "separator",
363
+ message: `The separator "${separator}" must not be part of the alphabet "${alphabet}".`
364
+ });
365
+ }
366
+ return () => `${prefix}${separator}${generator()}`;
367
+ };
368
+ var generateId = createIdGenerator();
369
+ function getErrorMessage2(error) {
370
+ if (error == null) {
371
+ return "unknown error";
372
+ }
373
+ if (typeof error === "string") {
374
+ return error;
375
+ }
376
+ if (error instanceof Error) {
377
+ return error.message;
378
+ }
379
+ return JSON.stringify(error);
380
+ }
381
+ function isAbortError(error) {
382
+ return (error instanceof Error || error instanceof DOMException) && (error.name === "AbortError" || error.name === "ResponseAborted" || // Next.js
383
+ error.name === "TimeoutError");
384
+ }
385
+ var FETCH_FAILED_ERROR_MESSAGES = ["fetch failed", "failed to fetch"];
386
+ function handleFetchError({
387
+ error,
388
+ url,
389
+ requestBodyValues
390
+ }) {
391
+ if (isAbortError(error)) {
392
+ return error;
393
+ }
394
+ if (error instanceof TypeError && FETCH_FAILED_ERROR_MESSAGES.includes(error.message.toLowerCase())) {
395
+ const cause = error.cause;
396
+ if (cause != null) {
397
+ return new APICallError({
398
+ message: `Cannot connect to API: ${cause.message}`,
399
+ cause,
400
+ url,
401
+ requestBodyValues,
402
+ isRetryable: true
403
+ // retry when network error
404
+ });
405
+ }
406
+ }
407
+ return error;
408
+ }
409
+ function getRuntimeEnvironmentUserAgent(globalThisAny = globalThis) {
410
+ var _a15, _b, _c;
411
+ if (globalThisAny.window) {
412
+ return `runtime/browser`;
413
+ }
414
+ if ((_a15 = globalThisAny.navigator) == null ? void 0 : _a15.userAgent) {
415
+ return `runtime/${globalThisAny.navigator.userAgent.toLowerCase()}`;
416
+ }
417
+ if ((_c = (_b = globalThisAny.process) == null ? void 0 : _b.versions) == null ? void 0 : _c.node) {
418
+ return `runtime/node.js/${globalThisAny.process.version.substring(0)}`;
419
+ }
420
+ if (globalThisAny.EdgeRuntime) {
421
+ return `runtime/vercel-edge`;
422
+ }
423
+ return "runtime/unknown";
424
+ }
425
+ function normalizeHeaders(headers) {
426
+ if (headers == null) {
427
+ return {};
428
+ }
429
+ const normalized = {};
430
+ if (headers instanceof Headers) {
431
+ headers.forEach((value, key) => {
432
+ normalized[key.toLowerCase()] = value;
433
+ });
434
+ } else {
435
+ if (!Array.isArray(headers)) {
436
+ headers = Object.entries(headers);
437
+ }
438
+ for (const [key, value] of headers) {
439
+ if (value != null) {
440
+ normalized[key.toLowerCase()] = value;
441
+ }
442
+ }
443
+ }
444
+ return normalized;
445
+ }
446
+ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
447
+ const normalizedHeaders = new Headers(normalizeHeaders(headers));
448
+ const currentUserAgentHeader = normalizedHeaders.get("user-agent") || "";
449
+ normalizedHeaders.set(
450
+ "user-agent",
451
+ [currentUserAgentHeader, ...userAgentSuffixParts].filter(Boolean).join(" ")
452
+ );
453
+ return Object.fromEntries(normalizedHeaders.entries());
454
+ }
455
+ var VERSION = "3.0.17";
456
+ var getOriginalFetch = () => globalThis.fetch;
457
+ var getFromApi = async ({
458
+ url,
459
+ headers = {},
460
+ successfulResponseHandler,
461
+ failedResponseHandler,
462
+ abortSignal,
463
+ fetch = getOriginalFetch()
464
+ }) => {
465
+ try {
466
+ const response = await fetch(url, {
467
+ method: "GET",
468
+ headers: withUserAgentSuffix(
469
+ headers,
470
+ `ai-sdk/provider-utils/${VERSION}`,
471
+ getRuntimeEnvironmentUserAgent()
472
+ ),
473
+ signal: abortSignal
474
+ });
475
+ const responseHeaders = extractResponseHeaders(response);
476
+ if (!response.ok) {
477
+ let errorInformation;
478
+ try {
479
+ errorInformation = await failedResponseHandler({
480
+ response,
481
+ url,
482
+ requestBodyValues: {}
483
+ });
484
+ } catch (error) {
485
+ if (isAbortError(error) || APICallError.isInstance(error)) {
486
+ throw error;
487
+ }
488
+ throw new APICallError({
489
+ message: "Failed to process error response",
490
+ cause: error,
491
+ statusCode: response.status,
492
+ url,
493
+ responseHeaders,
494
+ requestBodyValues: {}
495
+ });
496
+ }
497
+ throw errorInformation.value;
498
+ }
499
+ try {
500
+ return await successfulResponseHandler({
501
+ response,
502
+ url,
503
+ requestBodyValues: {}
504
+ });
505
+ } catch (error) {
506
+ if (error instanceof Error) {
507
+ if (isAbortError(error) || APICallError.isInstance(error)) {
508
+ throw error;
509
+ }
510
+ }
511
+ throw new APICallError({
512
+ message: "Failed to process successful response",
513
+ cause: error,
514
+ statusCode: response.status,
515
+ url,
516
+ responseHeaders,
517
+ requestBodyValues: {}
518
+ });
519
+ }
520
+ } catch (error) {
521
+ throw handleFetchError({ error, url, requestBodyValues: {} });
522
+ }
523
+ };
524
+ function loadOptionalSetting({
525
+ settingValue,
526
+ environmentVariableName
527
+ }) {
528
+ if (typeof settingValue === "string") {
529
+ return settingValue;
530
+ }
531
+ if (settingValue != null || typeof process === "undefined") {
532
+ return void 0;
533
+ }
534
+ settingValue = process.env[environmentVariableName];
535
+ if (settingValue == null || typeof settingValue !== "string") {
536
+ return void 0;
537
+ }
538
+ return settingValue;
539
+ }
540
+ var suspectProtoRx = /"__proto__"\s*:/;
541
+ var suspectConstructorRx = /"constructor"\s*:/;
542
+ function _parse(text) {
543
+ const obj = JSON.parse(text);
544
+ if (obj === null || typeof obj !== "object") {
545
+ return obj;
546
+ }
547
+ if (suspectProtoRx.test(text) === false && suspectConstructorRx.test(text) === false) {
548
+ return obj;
549
+ }
550
+ return filter(obj);
551
+ }
552
+ function filter(obj) {
553
+ let next = [obj];
554
+ while (next.length) {
555
+ const nodes = next;
556
+ next = [];
557
+ for (const node of nodes) {
558
+ if (Object.prototype.hasOwnProperty.call(node, "__proto__")) {
559
+ throw new SyntaxError("Object contains forbidden prototype property");
560
+ }
561
+ if (Object.prototype.hasOwnProperty.call(node, "constructor") && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
562
+ throw new SyntaxError("Object contains forbidden prototype property");
563
+ }
564
+ for (const key in node) {
565
+ const value = node[key];
566
+ if (value && typeof value === "object") {
567
+ next.push(value);
568
+ }
569
+ }
570
+ }
571
+ }
572
+ return obj;
573
+ }
574
+ function secureJsonParse(text) {
575
+ const { stackTraceLimit } = Error;
576
+ try {
577
+ Error.stackTraceLimit = 0;
578
+ } catch (e) {
579
+ return _parse(text);
580
+ }
581
+ try {
582
+ return _parse(text);
583
+ } finally {
584
+ Error.stackTraceLimit = stackTraceLimit;
585
+ }
586
+ }
587
+ var validatorSymbol = Symbol.for("vercel.ai.validator");
588
+ function validator(validate) {
589
+ return { [validatorSymbol]: true, validate };
590
+ }
591
+ function isValidator(value) {
592
+ return typeof value === "object" && value !== null && validatorSymbol in value && value[validatorSymbol] === true && "validate" in value;
593
+ }
594
+ function lazyValidator(createValidator) {
595
+ let validator2;
596
+ return () => {
597
+ if (validator2 == null) {
598
+ validator2 = createValidator();
599
+ }
600
+ return validator2;
601
+ };
602
+ }
603
+ function asValidator(value) {
604
+ return isValidator(value) ? value : typeof value === "function" ? value() : standardSchemaValidator(value);
605
+ }
606
+ function standardSchemaValidator(standardSchema) {
607
+ return validator(async (value) => {
608
+ const result = await standardSchema["~standard"].validate(value);
609
+ return result.issues == null ? { success: true, value: result.value } : {
610
+ success: false,
611
+ error: new TypeValidationError({
612
+ value,
613
+ cause: result.issues
614
+ })
615
+ };
616
+ });
617
+ }
618
+ async function validateTypes({
619
+ value,
620
+ schema
621
+ }) {
622
+ const result = await safeValidateTypes({ value, schema });
623
+ if (!result.success) {
624
+ throw TypeValidationError.wrap({ value, cause: result.error });
625
+ }
626
+ return result.value;
627
+ }
628
+ async function safeValidateTypes({
629
+ value,
630
+ schema
631
+ }) {
632
+ const validator2 = asValidator(schema);
633
+ try {
634
+ if (validator2.validate == null) {
635
+ return { success: true, value, rawValue: value };
636
+ }
637
+ const result = await validator2.validate(value);
638
+ if (result.success) {
639
+ return { success: true, value: result.value, rawValue: value };
640
+ }
641
+ return {
642
+ success: false,
643
+ error: TypeValidationError.wrap({ value, cause: result.error }),
644
+ rawValue: value
645
+ };
646
+ } catch (error) {
647
+ return {
648
+ success: false,
649
+ error: TypeValidationError.wrap({ value, cause: error }),
650
+ rawValue: value
651
+ };
652
+ }
653
+ }
654
+ async function parseJSON({
655
+ text,
656
+ schema
657
+ }) {
658
+ try {
659
+ const value = secureJsonParse(text);
660
+ if (schema == null) {
661
+ return value;
662
+ }
663
+ return validateTypes({ value, schema });
664
+ } catch (error) {
665
+ if (JSONParseError.isInstance(error) || TypeValidationError.isInstance(error)) {
666
+ throw error;
667
+ }
668
+ throw new JSONParseError({ text, cause: error });
669
+ }
670
+ }
671
+ async function safeParseJSON({
672
+ text,
673
+ schema
674
+ }) {
675
+ try {
676
+ const value = secureJsonParse(text);
677
+ if (schema == null) {
678
+ return { success: true, value, rawValue: value };
679
+ }
680
+ return await safeValidateTypes({ value, schema });
681
+ } catch (error) {
682
+ return {
683
+ success: false,
684
+ error: JSONParseError.isInstance(error) ? error : new JSONParseError({ text, cause: error }),
685
+ rawValue: void 0
686
+ };
687
+ }
688
+ }
689
+ function parseJsonEventStream({
690
+ stream,
691
+ schema
692
+ }) {
693
+ return stream.pipeThrough(new TextDecoderStream()).pipeThrough(new EventSourceParserStream()).pipeThrough(
694
+ new TransformStream({
695
+ async transform({ data }, controller) {
696
+ if (data === "[DONE]") {
697
+ return;
698
+ }
699
+ controller.enqueue(await safeParseJSON({ text: data, schema }));
700
+ }
701
+ })
702
+ );
703
+ }
704
+ var getOriginalFetch2 = () => globalThis.fetch;
705
+ var postJsonToApi = async ({
706
+ url,
707
+ headers,
708
+ body,
709
+ failedResponseHandler,
710
+ successfulResponseHandler,
711
+ abortSignal,
712
+ fetch
713
+ }) => postToApi({
714
+ url,
715
+ headers: {
716
+ "Content-Type": "application/json",
717
+ ...headers
718
+ },
719
+ body: {
720
+ content: JSON.stringify(body),
721
+ values: body
722
+ },
723
+ failedResponseHandler,
724
+ successfulResponseHandler,
725
+ abortSignal,
726
+ fetch
727
+ });
728
+ var postToApi = async ({
729
+ url,
730
+ headers = {},
731
+ body,
732
+ successfulResponseHandler,
733
+ failedResponseHandler,
734
+ abortSignal,
735
+ fetch = getOriginalFetch2()
736
+ }) => {
737
+ try {
738
+ const response = await fetch(url, {
739
+ method: "POST",
740
+ headers: withUserAgentSuffix(
741
+ headers,
742
+ `ai-sdk/provider-utils/${VERSION}`,
743
+ getRuntimeEnvironmentUserAgent()
744
+ ),
745
+ body: body.content,
746
+ signal: abortSignal
747
+ });
748
+ const responseHeaders = extractResponseHeaders(response);
749
+ if (!response.ok) {
750
+ let errorInformation;
751
+ try {
752
+ errorInformation = await failedResponseHandler({
753
+ response,
754
+ url,
755
+ requestBodyValues: body.values
756
+ });
757
+ } catch (error) {
758
+ if (isAbortError(error) || APICallError.isInstance(error)) {
759
+ throw error;
760
+ }
761
+ throw new APICallError({
762
+ message: "Failed to process error response",
763
+ cause: error,
764
+ statusCode: response.status,
765
+ url,
766
+ responseHeaders,
767
+ requestBodyValues: body.values
768
+ });
769
+ }
770
+ throw errorInformation.value;
771
+ }
772
+ try {
773
+ return await successfulResponseHandler({
774
+ response,
775
+ url,
776
+ requestBodyValues: body.values
777
+ });
778
+ } catch (error) {
779
+ if (error instanceof Error) {
780
+ if (isAbortError(error) || APICallError.isInstance(error)) {
781
+ throw error;
782
+ }
783
+ }
784
+ throw new APICallError({
785
+ message: "Failed to process successful response",
786
+ cause: error,
787
+ statusCode: response.status,
788
+ url,
789
+ responseHeaders,
790
+ requestBodyValues: body.values
791
+ });
792
+ }
793
+ } catch (error) {
794
+ throw handleFetchError({ error, url, requestBodyValues: body.values });
795
+ }
796
+ };
797
+ function tool(tool2) {
798
+ return tool2;
799
+ }
800
+ async function resolve(value) {
801
+ if (typeof value === "function") {
802
+ value = value();
803
+ }
804
+ return Promise.resolve(value);
805
+ }
806
+ var createJsonErrorResponseHandler = ({
807
+ errorSchema,
808
+ errorToMessage,
809
+ isRetryable
810
+ }) => async ({ response, url, requestBodyValues }) => {
811
+ const responseBody = await response.text();
812
+ const responseHeaders = extractResponseHeaders(response);
813
+ if (responseBody.trim() === "") {
814
+ return {
815
+ responseHeaders,
816
+ value: new APICallError({
817
+ message: response.statusText,
818
+ url,
819
+ requestBodyValues,
820
+ statusCode: response.status,
821
+ responseHeaders,
822
+ responseBody,
823
+ isRetryable: isRetryable == null ? void 0 : isRetryable(response)
824
+ })
825
+ };
826
+ }
827
+ try {
828
+ const parsedError = await parseJSON({
829
+ text: responseBody,
830
+ schema: errorSchema
831
+ });
832
+ return {
833
+ responseHeaders,
834
+ value: new APICallError({
835
+ message: errorToMessage(parsedError),
836
+ url,
837
+ requestBodyValues,
838
+ statusCode: response.status,
839
+ responseHeaders,
840
+ responseBody,
841
+ data: parsedError,
842
+ isRetryable: isRetryable == null ? void 0 : isRetryable(response, parsedError)
843
+ })
844
+ };
845
+ } catch (parseError) {
846
+ return {
847
+ responseHeaders,
848
+ value: new APICallError({
849
+ message: response.statusText,
850
+ url,
851
+ requestBodyValues,
852
+ statusCode: response.status,
853
+ responseHeaders,
854
+ responseBody,
855
+ isRetryable: isRetryable == null ? void 0 : isRetryable(response)
856
+ })
857
+ };
858
+ }
859
+ };
860
+ var createEventSourceResponseHandler = (chunkSchema) => async ({ response }) => {
861
+ const responseHeaders = extractResponseHeaders(response);
862
+ if (response.body == null) {
863
+ throw new EmptyResponseBodyError({});
864
+ }
865
+ return {
866
+ responseHeaders,
867
+ value: parseJsonEventStream({
868
+ stream: response.body,
869
+ schema: chunkSchema
870
+ })
871
+ };
872
+ };
873
+ var createJsonResponseHandler = (responseSchema) => async ({ response, url, requestBodyValues }) => {
874
+ const responseBody = await response.text();
875
+ const parsedResult = await safeParseJSON({
876
+ text: responseBody,
877
+ schema: responseSchema
878
+ });
879
+ const responseHeaders = extractResponseHeaders(response);
880
+ if (!parsedResult.success) {
881
+ throw new APICallError({
882
+ message: "Invalid JSON response",
883
+ cause: parsedResult.error,
884
+ statusCode: response.status,
885
+ responseHeaders,
886
+ responseBody,
887
+ url,
888
+ requestBodyValues
889
+ });
890
+ }
891
+ return {
892
+ responseHeaders,
893
+ value: parsedResult.value,
894
+ rawValue: parsedResult.rawValue
895
+ };
896
+ };
897
+ var getRelativePath = (pathA, pathB) => {
898
+ let i = 0;
899
+ for (; i < pathA.length && i < pathB.length; i++) {
900
+ if (pathA[i] !== pathB[i]) break;
901
+ }
902
+ return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
903
+ };
904
+ var ignoreOverride = Symbol(
905
+ "Let zodToJsonSchema decide on which parser to use"
906
+ );
907
+ var defaultOptions = {
908
+ name: void 0,
909
+ $refStrategy: "root",
910
+ basePath: ["#"],
911
+ effectStrategy: "input",
912
+ pipeStrategy: "all",
913
+ dateStrategy: "format:date-time",
914
+ mapStrategy: "entries",
915
+ removeAdditionalStrategy: "passthrough",
916
+ allowedAdditionalProperties: true,
917
+ rejectedAdditionalProperties: false,
918
+ definitionPath: "definitions",
919
+ strictUnions: false,
920
+ definitions: {},
921
+ errorMessages: false,
922
+ patternStrategy: "escape",
923
+ applyRegexFlags: false,
924
+ emailStrategy: "format:email",
925
+ base64Strategy: "contentEncoding:base64",
926
+ nameStrategy: "ref"
927
+ };
928
+ var getDefaultOptions = (options) => typeof options === "string" ? {
929
+ ...defaultOptions,
930
+ name: options
931
+ } : {
932
+ ...defaultOptions,
933
+ ...options
934
+ };
935
+ function parseAnyDef() {
936
+ return {};
937
+ }
938
+ function parseArrayDef(def, refs) {
939
+ var _a15, _b, _c;
940
+ const res = {
941
+ type: "array"
942
+ };
943
+ if (((_a15 = def.type) == null ? void 0 : _a15._def) && ((_c = (_b = def.type) == null ? void 0 : _b._def) == null ? void 0 : _c.typeName) !== ZodFirstPartyTypeKind.ZodAny) {
944
+ res.items = parseDef(def.type._def, {
945
+ ...refs,
946
+ currentPath: [...refs.currentPath, "items"]
947
+ });
948
+ }
949
+ if (def.minLength) {
950
+ res.minItems = def.minLength.value;
951
+ }
952
+ if (def.maxLength) {
953
+ res.maxItems = def.maxLength.value;
954
+ }
955
+ if (def.exactLength) {
956
+ res.minItems = def.exactLength.value;
957
+ res.maxItems = def.exactLength.value;
958
+ }
959
+ return res;
960
+ }
961
+ function parseBigintDef(def) {
962
+ const res = {
963
+ type: "integer",
964
+ format: "int64"
965
+ };
966
+ if (!def.checks) return res;
967
+ for (const check of def.checks) {
968
+ switch (check.kind) {
969
+ case "min":
970
+ if (check.inclusive) {
971
+ res.minimum = check.value;
972
+ } else {
973
+ res.exclusiveMinimum = check.value;
974
+ }
975
+ break;
976
+ case "max":
977
+ if (check.inclusive) {
978
+ res.maximum = check.value;
979
+ } else {
980
+ res.exclusiveMaximum = check.value;
981
+ }
982
+ break;
983
+ case "multipleOf":
984
+ res.multipleOf = check.value;
985
+ break;
986
+ }
987
+ }
988
+ return res;
989
+ }
990
+ function parseBooleanDef() {
991
+ return { type: "boolean" };
992
+ }
993
+ function parseBrandedDef(_def, refs) {
994
+ return parseDef(_def.type._def, refs);
995
+ }
996
+ var parseCatchDef = (def, refs) => {
997
+ return parseDef(def.innerType._def, refs);
998
+ };
999
+ function parseDateDef(def, refs, overrideDateStrategy) {
1000
+ const strategy = overrideDateStrategy != null ? overrideDateStrategy : refs.dateStrategy;
1001
+ if (Array.isArray(strategy)) {
1002
+ return {
1003
+ anyOf: strategy.map((item, i) => parseDateDef(def, refs, item))
1004
+ };
1005
+ }
1006
+ switch (strategy) {
1007
+ case "string":
1008
+ case "format:date-time":
1009
+ return {
1010
+ type: "string",
1011
+ format: "date-time"
1012
+ };
1013
+ case "format:date":
1014
+ return {
1015
+ type: "string",
1016
+ format: "date"
1017
+ };
1018
+ case "integer":
1019
+ return integerDateParser(def);
1020
+ }
1021
+ }
1022
+ var integerDateParser = (def) => {
1023
+ const res = {
1024
+ type: "integer",
1025
+ format: "unix-time"
1026
+ };
1027
+ for (const check of def.checks) {
1028
+ switch (check.kind) {
1029
+ case "min":
1030
+ res.minimum = check.value;
1031
+ break;
1032
+ case "max":
1033
+ res.maximum = check.value;
1034
+ break;
1035
+ }
1036
+ }
1037
+ return res;
1038
+ };
1039
+ function parseDefaultDef(_def, refs) {
1040
+ return {
1041
+ ...parseDef(_def.innerType._def, refs),
1042
+ default: _def.defaultValue()
1043
+ };
1044
+ }
1045
+ function parseEffectsDef(_def, refs) {
1046
+ return refs.effectStrategy === "input" ? parseDef(_def.schema._def, refs) : parseAnyDef();
1047
+ }
1048
+ function parseEnumDef(def) {
1049
+ return {
1050
+ type: "string",
1051
+ enum: Array.from(def.values)
1052
+ };
1053
+ }
1054
+ var isJsonSchema7AllOfType = (type) => {
1055
+ if ("type" in type && type.type === "string") return false;
1056
+ return "allOf" in type;
1057
+ };
1058
+ function parseIntersectionDef(def, refs) {
1059
+ const allOf = [
1060
+ parseDef(def.left._def, {
1061
+ ...refs,
1062
+ currentPath: [...refs.currentPath, "allOf", "0"]
1063
+ }),
1064
+ parseDef(def.right._def, {
1065
+ ...refs,
1066
+ currentPath: [...refs.currentPath, "allOf", "1"]
1067
+ })
1068
+ ].filter((x) => !!x);
1069
+ const mergedAllOf = [];
1070
+ allOf.forEach((schema) => {
1071
+ if (isJsonSchema7AllOfType(schema)) {
1072
+ mergedAllOf.push(...schema.allOf);
1073
+ } else {
1074
+ let nestedSchema = schema;
1075
+ if ("additionalProperties" in schema && schema.additionalProperties === false) {
1076
+ const { additionalProperties, ...rest } = schema;
1077
+ nestedSchema = rest;
1078
+ }
1079
+ mergedAllOf.push(nestedSchema);
1080
+ }
1081
+ });
1082
+ return mergedAllOf.length ? { allOf: mergedAllOf } : void 0;
1083
+ }
1084
+ function parseLiteralDef(def) {
1085
+ const parsedType = typeof def.value;
1086
+ if (parsedType !== "bigint" && parsedType !== "number" && parsedType !== "boolean" && parsedType !== "string") {
1087
+ return {
1088
+ type: Array.isArray(def.value) ? "array" : "object"
1089
+ };
1090
+ }
1091
+ return {
1092
+ type: parsedType === "bigint" ? "integer" : parsedType,
1093
+ const: def.value
1094
+ };
1095
+ }
1096
+ var emojiRegex = void 0;
1097
+ var zodPatterns = {
1098
+ /**
1099
+ * `c` was changed to `[cC]` to replicate /i flag
1100
+ */
1101
+ cuid: /^[cC][^\s-]{8,}$/,
1102
+ cuid2: /^[0-9a-z]+$/,
1103
+ ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,
1104
+ /**
1105
+ * `a-z` was added to replicate /i flag
1106
+ */
1107
+ email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
1108
+ /**
1109
+ * Constructed a valid Unicode RegExp
1110
+ *
1111
+ * Lazily instantiate since this type of regex isn't supported
1112
+ * in all envs (e.g. React Native).
1113
+ *
1114
+ * See:
1115
+ * https://github.com/colinhacks/zod/issues/2433
1116
+ * Fix in Zod:
1117
+ * https://github.com/colinhacks/zod/commit/9340fd51e48576a75adc919bff65dbc4a5d4c99b
1118
+ */
1119
+ emoji: () => {
1120
+ if (emojiRegex === void 0) {
1121
+ emojiRegex = RegExp(
1122
+ "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",
1123
+ "u"
1124
+ );
1125
+ }
1126
+ return emojiRegex;
1127
+ },
1128
+ /**
1129
+ * Unused
1130
+ */
1131
+ uuid: /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,
1132
+ /**
1133
+ * Unused
1134
+ */
1135
+ ipv4: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,
1136
+ ipv4Cidr: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,
1137
+ /**
1138
+ * Unused
1139
+ */
1140
+ ipv6: /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,
1141
+ ipv6Cidr: /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,
1142
+ base64: /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,
1143
+ base64url: /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,
1144
+ nanoid: /^[a-zA-Z0-9_-]{21}$/,
1145
+ jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/
1146
+ };
1147
+ function parseStringDef(def, refs) {
1148
+ const res = {
1149
+ type: "string"
1150
+ };
1151
+ if (def.checks) {
1152
+ for (const check of def.checks) {
1153
+ switch (check.kind) {
1154
+ case "min":
1155
+ res.minLength = typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value;
1156
+ break;
1157
+ case "max":
1158
+ res.maxLength = typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value;
1159
+ break;
1160
+ case "email":
1161
+ switch (refs.emailStrategy) {
1162
+ case "format:email":
1163
+ addFormat(res, "email", check.message, refs);
1164
+ break;
1165
+ case "format:idn-email":
1166
+ addFormat(res, "idn-email", check.message, refs);
1167
+ break;
1168
+ case "pattern:zod":
1169
+ addPattern(res, zodPatterns.email, check.message, refs);
1170
+ break;
1171
+ }
1172
+ break;
1173
+ case "url":
1174
+ addFormat(res, "uri", check.message, refs);
1175
+ break;
1176
+ case "uuid":
1177
+ addFormat(res, "uuid", check.message, refs);
1178
+ break;
1179
+ case "regex":
1180
+ addPattern(res, check.regex, check.message, refs);
1181
+ break;
1182
+ case "cuid":
1183
+ addPattern(res, zodPatterns.cuid, check.message, refs);
1184
+ break;
1185
+ case "cuid2":
1186
+ addPattern(res, zodPatterns.cuid2, check.message, refs);
1187
+ break;
1188
+ case "startsWith":
1189
+ addPattern(
1190
+ res,
1191
+ RegExp(`^${escapeLiteralCheckValue(check.value, refs)}`),
1192
+ check.message,
1193
+ refs
1194
+ );
1195
+ break;
1196
+ case "endsWith":
1197
+ addPattern(
1198
+ res,
1199
+ RegExp(`${escapeLiteralCheckValue(check.value, refs)}$`),
1200
+ check.message,
1201
+ refs
1202
+ );
1203
+ break;
1204
+ case "datetime":
1205
+ addFormat(res, "date-time", check.message, refs);
1206
+ break;
1207
+ case "date":
1208
+ addFormat(res, "date", check.message, refs);
1209
+ break;
1210
+ case "time":
1211
+ addFormat(res, "time", check.message, refs);
1212
+ break;
1213
+ case "duration":
1214
+ addFormat(res, "duration", check.message, refs);
1215
+ break;
1216
+ case "length":
1217
+ res.minLength = typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value;
1218
+ res.maxLength = typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value;
1219
+ break;
1220
+ case "includes": {
1221
+ addPattern(
1222
+ res,
1223
+ RegExp(escapeLiteralCheckValue(check.value, refs)),
1224
+ check.message,
1225
+ refs
1226
+ );
1227
+ break;
1228
+ }
1229
+ case "ip": {
1230
+ if (check.version !== "v6") {
1231
+ addFormat(res, "ipv4", check.message, refs);
1232
+ }
1233
+ if (check.version !== "v4") {
1234
+ addFormat(res, "ipv6", check.message, refs);
1235
+ }
1236
+ break;
1237
+ }
1238
+ case "base64url":
1239
+ addPattern(res, zodPatterns.base64url, check.message, refs);
1240
+ break;
1241
+ case "jwt":
1242
+ addPattern(res, zodPatterns.jwt, check.message, refs);
1243
+ break;
1244
+ case "cidr": {
1245
+ if (check.version !== "v6") {
1246
+ addPattern(res, zodPatterns.ipv4Cidr, check.message, refs);
1247
+ }
1248
+ if (check.version !== "v4") {
1249
+ addPattern(res, zodPatterns.ipv6Cidr, check.message, refs);
1250
+ }
1251
+ break;
1252
+ }
1253
+ case "emoji":
1254
+ addPattern(res, zodPatterns.emoji(), check.message, refs);
1255
+ break;
1256
+ case "ulid": {
1257
+ addPattern(res, zodPatterns.ulid, check.message, refs);
1258
+ break;
1259
+ }
1260
+ case "base64": {
1261
+ switch (refs.base64Strategy) {
1262
+ case "format:binary": {
1263
+ addFormat(res, "binary", check.message, refs);
1264
+ break;
1265
+ }
1266
+ case "contentEncoding:base64": {
1267
+ res.contentEncoding = "base64";
1268
+ break;
1269
+ }
1270
+ case "pattern:zod": {
1271
+ addPattern(res, zodPatterns.base64, check.message, refs);
1272
+ break;
1273
+ }
1274
+ }
1275
+ break;
1276
+ }
1277
+ case "nanoid": {
1278
+ addPattern(res, zodPatterns.nanoid, check.message, refs);
1279
+ }
1280
+ }
1281
+ }
1282
+ }
1283
+ return res;
1284
+ }
1285
+ function escapeLiteralCheckValue(literal, refs) {
1286
+ return refs.patternStrategy === "escape" ? escapeNonAlphaNumeric(literal) : literal;
1287
+ }
1288
+ var ALPHA_NUMERIC = new Set(
1289
+ "ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789"
1290
+ );
1291
+ function escapeNonAlphaNumeric(source) {
1292
+ let result = "";
1293
+ for (let i = 0; i < source.length; i++) {
1294
+ if (!ALPHA_NUMERIC.has(source[i])) {
1295
+ result += "\\";
1296
+ }
1297
+ result += source[i];
1298
+ }
1299
+ return result;
1300
+ }
1301
+ function addFormat(schema, value, message, refs) {
1302
+ var _a15;
1303
+ if (schema.format || ((_a15 = schema.anyOf) == null ? void 0 : _a15.some((x) => x.format))) {
1304
+ if (!schema.anyOf) {
1305
+ schema.anyOf = [];
1306
+ }
1307
+ if (schema.format) {
1308
+ schema.anyOf.push({
1309
+ format: schema.format
1310
+ });
1311
+ delete schema.format;
1312
+ }
1313
+ schema.anyOf.push({
1314
+ format: value,
1315
+ ...message && refs.errorMessages && { errorMessage: { format: message } }
1316
+ });
1317
+ } else {
1318
+ schema.format = value;
1319
+ }
1320
+ }
1321
+ function addPattern(schema, regex, message, refs) {
1322
+ var _a15;
1323
+ if (schema.pattern || ((_a15 = schema.allOf) == null ? void 0 : _a15.some((x) => x.pattern))) {
1324
+ if (!schema.allOf) {
1325
+ schema.allOf = [];
1326
+ }
1327
+ if (schema.pattern) {
1328
+ schema.allOf.push({
1329
+ pattern: schema.pattern
1330
+ });
1331
+ delete schema.pattern;
1332
+ }
1333
+ schema.allOf.push({
1334
+ pattern: stringifyRegExpWithFlags(regex, refs),
1335
+ ...message && refs.errorMessages && { errorMessage: { pattern: message } }
1336
+ });
1337
+ } else {
1338
+ schema.pattern = stringifyRegExpWithFlags(regex, refs);
1339
+ }
1340
+ }
1341
+ function stringifyRegExpWithFlags(regex, refs) {
1342
+ var _a15;
1343
+ if (!refs.applyRegexFlags || !regex.flags) {
1344
+ return regex.source;
1345
+ }
1346
+ const flags = {
1347
+ i: regex.flags.includes("i"),
1348
+ // Case-insensitive
1349
+ m: regex.flags.includes("m"),
1350
+ // `^` and `$` matches adjacent to newline characters
1351
+ s: regex.flags.includes("s")
1352
+ // `.` matches newlines
1353
+ };
1354
+ const source = flags.i ? regex.source.toLowerCase() : regex.source;
1355
+ let pattern = "";
1356
+ let isEscaped = false;
1357
+ let inCharGroup = false;
1358
+ let inCharRange = false;
1359
+ for (let i = 0; i < source.length; i++) {
1360
+ if (isEscaped) {
1361
+ pattern += source[i];
1362
+ isEscaped = false;
1363
+ continue;
1364
+ }
1365
+ if (flags.i) {
1366
+ if (inCharGroup) {
1367
+ if (source[i].match(/[a-z]/)) {
1368
+ if (inCharRange) {
1369
+ pattern += source[i];
1370
+ pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
1371
+ inCharRange = false;
1372
+ } else if (source[i + 1] === "-" && ((_a15 = source[i + 2]) == null ? void 0 : _a15.match(/[a-z]/))) {
1373
+ pattern += source[i];
1374
+ inCharRange = true;
1375
+ } else {
1376
+ pattern += `${source[i]}${source[i].toUpperCase()}`;
1377
+ }
1378
+ continue;
1379
+ }
1380
+ } else if (source[i].match(/[a-z]/)) {
1381
+ pattern += `[${source[i]}${source[i].toUpperCase()}]`;
1382
+ continue;
1383
+ }
1384
+ }
1385
+ if (flags.m) {
1386
+ if (source[i] === "^") {
1387
+ pattern += `(^|(?<=[\r
1388
+ ]))`;
1389
+ continue;
1390
+ } else if (source[i] === "$") {
1391
+ pattern += `($|(?=[\r
1392
+ ]))`;
1393
+ continue;
1394
+ }
1395
+ }
1396
+ if (flags.s && source[i] === ".") {
1397
+ pattern += inCharGroup ? `${source[i]}\r
1398
+ ` : `[${source[i]}\r
1399
+ ]`;
1400
+ continue;
1401
+ }
1402
+ pattern += source[i];
1403
+ if (source[i] === "\\") {
1404
+ isEscaped = true;
1405
+ } else if (inCharGroup && source[i] === "]") {
1406
+ inCharGroup = false;
1407
+ } else if (!inCharGroup && source[i] === "[") {
1408
+ inCharGroup = true;
1409
+ }
1410
+ }
1411
+ return pattern;
1412
+ }
1413
+ function parseRecordDef(def, refs) {
1414
+ var _a15, _b, _c, _d, _e, _f;
1415
+ const schema = {
1416
+ type: "object",
1417
+ additionalProperties: (_a15 = parseDef(def.valueType._def, {
1418
+ ...refs,
1419
+ currentPath: [...refs.currentPath, "additionalProperties"]
1420
+ })) != null ? _a15 : refs.allowedAdditionalProperties
1421
+ };
1422
+ if (((_b = def.keyType) == null ? void 0 : _b._def.typeName) === ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {
1423
+ const { type, ...keyType } = parseStringDef(def.keyType._def, refs);
1424
+ return {
1425
+ ...schema,
1426
+ propertyNames: keyType
1427
+ };
1428
+ } else if (((_d = def.keyType) == null ? void 0 : _d._def.typeName) === ZodFirstPartyTypeKind.ZodEnum) {
1429
+ return {
1430
+ ...schema,
1431
+ propertyNames: {
1432
+ enum: def.keyType._def.values
1433
+ }
1434
+ };
1435
+ } else if (((_e = def.keyType) == null ? void 0 : _e._def.typeName) === ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === ZodFirstPartyTypeKind.ZodString && ((_f = def.keyType._def.type._def.checks) == null ? void 0 : _f.length)) {
1436
+ const { type, ...keyType } = parseBrandedDef(
1437
+ def.keyType._def,
1438
+ refs
1439
+ );
1440
+ return {
1441
+ ...schema,
1442
+ propertyNames: keyType
1443
+ };
1444
+ }
1445
+ return schema;
1446
+ }
1447
+ function parseMapDef(def, refs) {
1448
+ if (refs.mapStrategy === "record") {
1449
+ return parseRecordDef(def, refs);
1450
+ }
1451
+ const keys = parseDef(def.keyType._def, {
1452
+ ...refs,
1453
+ currentPath: [...refs.currentPath, "items", "items", "0"]
1454
+ }) || parseAnyDef();
1455
+ const values = parseDef(def.valueType._def, {
1456
+ ...refs,
1457
+ currentPath: [...refs.currentPath, "items", "items", "1"]
1458
+ }) || parseAnyDef();
1459
+ return {
1460
+ type: "array",
1461
+ maxItems: 125,
1462
+ items: {
1463
+ type: "array",
1464
+ items: [keys, values],
1465
+ minItems: 2,
1466
+ maxItems: 2
1467
+ }
1468
+ };
1469
+ }
1470
+ function parseNativeEnumDef(def) {
1471
+ const object = def.values;
1472
+ const actualKeys = Object.keys(def.values).filter((key) => {
1473
+ return typeof object[object[key]] !== "number";
1474
+ });
1475
+ const actualValues = actualKeys.map((key) => object[key]);
1476
+ const parsedTypes = Array.from(
1477
+ new Set(actualValues.map((values) => typeof values))
1478
+ );
1479
+ return {
1480
+ type: parsedTypes.length === 1 ? parsedTypes[0] === "string" ? "string" : "number" : ["string", "number"],
1481
+ enum: actualValues
1482
+ };
1483
+ }
1484
+ function parseNeverDef() {
1485
+ return { not: parseAnyDef() };
1486
+ }
1487
+ function parseNullDef() {
1488
+ return {
1489
+ type: "null"
1490
+ };
1491
+ }
1492
+ var primitiveMappings = {
1493
+ ZodString: "string",
1494
+ ZodNumber: "number",
1495
+ ZodBigInt: "integer",
1496
+ ZodBoolean: "boolean",
1497
+ ZodNull: "null"
1498
+ };
1499
+ function parseUnionDef(def, refs) {
1500
+ const options = def.options instanceof Map ? Array.from(def.options.values()) : def.options;
1501
+ if (options.every(
1502
+ (x) => x._def.typeName in primitiveMappings && (!x._def.checks || !x._def.checks.length)
1503
+ )) {
1504
+ const types = options.reduce((types2, x) => {
1505
+ const type = primitiveMappings[x._def.typeName];
1506
+ return type && !types2.includes(type) ? [...types2, type] : types2;
1507
+ }, []);
1508
+ return {
1509
+ type: types.length > 1 ? types : types[0]
1510
+ };
1511
+ } else if (options.every((x) => x._def.typeName === "ZodLiteral" && !x.description)) {
1512
+ const types = options.reduce(
1513
+ (acc, x) => {
1514
+ const type = typeof x._def.value;
1515
+ switch (type) {
1516
+ case "string":
1517
+ case "number":
1518
+ case "boolean":
1519
+ return [...acc, type];
1520
+ case "bigint":
1521
+ return [...acc, "integer"];
1522
+ case "object":
1523
+ if (x._def.value === null) return [...acc, "null"];
1524
+ case "symbol":
1525
+ case "undefined":
1526
+ case "function":
1527
+ default:
1528
+ return acc;
1529
+ }
1530
+ },
1531
+ []
1532
+ );
1533
+ if (types.length === options.length) {
1534
+ const uniqueTypes = types.filter((x, i, a) => a.indexOf(x) === i);
1535
+ return {
1536
+ type: uniqueTypes.length > 1 ? uniqueTypes : uniqueTypes[0],
1537
+ enum: options.reduce(
1538
+ (acc, x) => {
1539
+ return acc.includes(x._def.value) ? acc : [...acc, x._def.value];
1540
+ },
1541
+ []
1542
+ )
1543
+ };
1544
+ }
1545
+ } else if (options.every((x) => x._def.typeName === "ZodEnum")) {
1546
+ return {
1547
+ type: "string",
1548
+ enum: options.reduce(
1549
+ (acc, x) => [
1550
+ ...acc,
1551
+ ...x._def.values.filter((x2) => !acc.includes(x2))
1552
+ ],
1553
+ []
1554
+ )
1555
+ };
1556
+ }
1557
+ return asAnyOf(def, refs);
1558
+ }
1559
+ var asAnyOf = (def, refs) => {
1560
+ const anyOf = (def.options instanceof Map ? Array.from(def.options.values()) : def.options).map(
1561
+ (x, i) => parseDef(x._def, {
1562
+ ...refs,
1563
+ currentPath: [...refs.currentPath, "anyOf", `${i}`]
1564
+ })
1565
+ ).filter(
1566
+ (x) => !!x && (!refs.strictUnions || typeof x === "object" && Object.keys(x).length > 0)
1567
+ );
1568
+ return anyOf.length ? { anyOf } : void 0;
1569
+ };
1570
+ function parseNullableDef(def, refs) {
1571
+ if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(
1572
+ def.innerType._def.typeName
1573
+ ) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) {
1574
+ return {
1575
+ type: [
1576
+ primitiveMappings[def.innerType._def.typeName],
1577
+ "null"
1578
+ ]
1579
+ };
1580
+ }
1581
+ const base = parseDef(def.innerType._def, {
1582
+ ...refs,
1583
+ currentPath: [...refs.currentPath, "anyOf", "0"]
1584
+ });
1585
+ return base && { anyOf: [base, { type: "null" }] };
1586
+ }
1587
+ function parseNumberDef(def) {
1588
+ const res = {
1589
+ type: "number"
1590
+ };
1591
+ if (!def.checks) return res;
1592
+ for (const check of def.checks) {
1593
+ switch (check.kind) {
1594
+ case "int":
1595
+ res.type = "integer";
1596
+ break;
1597
+ case "min":
1598
+ if (check.inclusive) {
1599
+ res.minimum = check.value;
1600
+ } else {
1601
+ res.exclusiveMinimum = check.value;
1602
+ }
1603
+ break;
1604
+ case "max":
1605
+ if (check.inclusive) {
1606
+ res.maximum = check.value;
1607
+ } else {
1608
+ res.exclusiveMaximum = check.value;
1609
+ }
1610
+ break;
1611
+ case "multipleOf":
1612
+ res.multipleOf = check.value;
1613
+ break;
1614
+ }
1615
+ }
1616
+ return res;
1617
+ }
1618
+ function parseObjectDef(def, refs) {
1619
+ const result = {
1620
+ type: "object",
1621
+ properties: {}
1622
+ };
1623
+ const required = [];
1624
+ const shape = def.shape();
1625
+ for (const propName in shape) {
1626
+ let propDef = shape[propName];
1627
+ if (propDef === void 0 || propDef._def === void 0) {
1628
+ continue;
1629
+ }
1630
+ const propOptional = safeIsOptional(propDef);
1631
+ const parsedDef = parseDef(propDef._def, {
1632
+ ...refs,
1633
+ currentPath: [...refs.currentPath, "properties", propName],
1634
+ propertyPath: [...refs.currentPath, "properties", propName]
1635
+ });
1636
+ if (parsedDef === void 0) {
1637
+ continue;
1638
+ }
1639
+ result.properties[propName] = parsedDef;
1640
+ if (!propOptional) {
1641
+ required.push(propName);
1642
+ }
1643
+ }
1644
+ if (required.length) {
1645
+ result.required = required;
1646
+ }
1647
+ const additionalProperties = decideAdditionalProperties(def, refs);
1648
+ if (additionalProperties !== void 0) {
1649
+ result.additionalProperties = additionalProperties;
1650
+ }
1651
+ return result;
1652
+ }
1653
+ function decideAdditionalProperties(def, refs) {
1654
+ if (def.catchall._def.typeName !== "ZodNever") {
1655
+ return parseDef(def.catchall._def, {
1656
+ ...refs,
1657
+ currentPath: [...refs.currentPath, "additionalProperties"]
1658
+ });
1659
+ }
1660
+ switch (def.unknownKeys) {
1661
+ case "passthrough":
1662
+ return refs.allowedAdditionalProperties;
1663
+ case "strict":
1664
+ return refs.rejectedAdditionalProperties;
1665
+ case "strip":
1666
+ return refs.removeAdditionalStrategy === "strict" ? refs.allowedAdditionalProperties : refs.rejectedAdditionalProperties;
1667
+ }
1668
+ }
1669
+ function safeIsOptional(schema) {
1670
+ try {
1671
+ return schema.isOptional();
1672
+ } catch (e) {
1673
+ return true;
1674
+ }
1675
+ }
1676
+ var parseOptionalDef = (def, refs) => {
1677
+ var _a15;
1678
+ if (refs.currentPath.toString() === ((_a15 = refs.propertyPath) == null ? void 0 : _a15.toString())) {
1679
+ return parseDef(def.innerType._def, refs);
1680
+ }
1681
+ const innerSchema = parseDef(def.innerType._def, {
1682
+ ...refs,
1683
+ currentPath: [...refs.currentPath, "anyOf", "1"]
1684
+ });
1685
+ return innerSchema ? { anyOf: [{ not: parseAnyDef() }, innerSchema] } : parseAnyDef();
1686
+ };
1687
+ var parsePipelineDef = (def, refs) => {
1688
+ if (refs.pipeStrategy === "input") {
1689
+ return parseDef(def.in._def, refs);
1690
+ } else if (refs.pipeStrategy === "output") {
1691
+ return parseDef(def.out._def, refs);
1692
+ }
1693
+ const a = parseDef(def.in._def, {
1694
+ ...refs,
1695
+ currentPath: [...refs.currentPath, "allOf", "0"]
1696
+ });
1697
+ const b = parseDef(def.out._def, {
1698
+ ...refs,
1699
+ currentPath: [...refs.currentPath, "allOf", a ? "1" : "0"]
1700
+ });
1701
+ return {
1702
+ allOf: [a, b].filter((x) => x !== void 0)
1703
+ };
1704
+ };
1705
+ function parsePromiseDef(def, refs) {
1706
+ return parseDef(def.type._def, refs);
1707
+ }
1708
+ function parseSetDef(def, refs) {
1709
+ const items = parseDef(def.valueType._def, {
1710
+ ...refs,
1711
+ currentPath: [...refs.currentPath, "items"]
1712
+ });
1713
+ const schema = {
1714
+ type: "array",
1715
+ uniqueItems: true,
1716
+ items
1717
+ };
1718
+ if (def.minSize) {
1719
+ schema.minItems = def.minSize.value;
1720
+ }
1721
+ if (def.maxSize) {
1722
+ schema.maxItems = def.maxSize.value;
1723
+ }
1724
+ return schema;
1725
+ }
1726
+ function parseTupleDef(def, refs) {
1727
+ if (def.rest) {
1728
+ return {
1729
+ type: "array",
1730
+ minItems: def.items.length,
1731
+ items: def.items.map(
1732
+ (x, i) => parseDef(x._def, {
1733
+ ...refs,
1734
+ currentPath: [...refs.currentPath, "items", `${i}`]
1735
+ })
1736
+ ).reduce(
1737
+ (acc, x) => x === void 0 ? acc : [...acc, x],
1738
+ []
1739
+ ),
1740
+ additionalItems: parseDef(def.rest._def, {
1741
+ ...refs,
1742
+ currentPath: [...refs.currentPath, "additionalItems"]
1743
+ })
1744
+ };
1745
+ } else {
1746
+ return {
1747
+ type: "array",
1748
+ minItems: def.items.length,
1749
+ maxItems: def.items.length,
1750
+ items: def.items.map(
1751
+ (x, i) => parseDef(x._def, {
1752
+ ...refs,
1753
+ currentPath: [...refs.currentPath, "items", `${i}`]
1754
+ })
1755
+ ).reduce(
1756
+ (acc, x) => x === void 0 ? acc : [...acc, x],
1757
+ []
1758
+ )
1759
+ };
1760
+ }
1761
+ }
1762
+ function parseUndefinedDef() {
1763
+ return {
1764
+ not: parseAnyDef()
1765
+ };
1766
+ }
1767
+ function parseUnknownDef() {
1768
+ return parseAnyDef();
1769
+ }
1770
+ var parseReadonlyDef = (def, refs) => {
1771
+ return parseDef(def.innerType._def, refs);
1772
+ };
1773
+ var selectParser = (def, typeName, refs) => {
1774
+ switch (typeName) {
1775
+ case ZodFirstPartyTypeKind.ZodString:
1776
+ return parseStringDef(def, refs);
1777
+ case ZodFirstPartyTypeKind.ZodNumber:
1778
+ return parseNumberDef(def);
1779
+ case ZodFirstPartyTypeKind.ZodObject:
1780
+ return parseObjectDef(def, refs);
1781
+ case ZodFirstPartyTypeKind.ZodBigInt:
1782
+ return parseBigintDef(def);
1783
+ case ZodFirstPartyTypeKind.ZodBoolean:
1784
+ return parseBooleanDef();
1785
+ case ZodFirstPartyTypeKind.ZodDate:
1786
+ return parseDateDef(def, refs);
1787
+ case ZodFirstPartyTypeKind.ZodUndefined:
1788
+ return parseUndefinedDef();
1789
+ case ZodFirstPartyTypeKind.ZodNull:
1790
+ return parseNullDef();
1791
+ case ZodFirstPartyTypeKind.ZodArray:
1792
+ return parseArrayDef(def, refs);
1793
+ case ZodFirstPartyTypeKind.ZodUnion:
1794
+ case ZodFirstPartyTypeKind.ZodDiscriminatedUnion:
1795
+ return parseUnionDef(def, refs);
1796
+ case ZodFirstPartyTypeKind.ZodIntersection:
1797
+ return parseIntersectionDef(def, refs);
1798
+ case ZodFirstPartyTypeKind.ZodTuple:
1799
+ return parseTupleDef(def, refs);
1800
+ case ZodFirstPartyTypeKind.ZodRecord:
1801
+ return parseRecordDef(def, refs);
1802
+ case ZodFirstPartyTypeKind.ZodLiteral:
1803
+ return parseLiteralDef(def);
1804
+ case ZodFirstPartyTypeKind.ZodEnum:
1805
+ return parseEnumDef(def);
1806
+ case ZodFirstPartyTypeKind.ZodNativeEnum:
1807
+ return parseNativeEnumDef(def);
1808
+ case ZodFirstPartyTypeKind.ZodNullable:
1809
+ return parseNullableDef(def, refs);
1810
+ case ZodFirstPartyTypeKind.ZodOptional:
1811
+ return parseOptionalDef(def, refs);
1812
+ case ZodFirstPartyTypeKind.ZodMap:
1813
+ return parseMapDef(def, refs);
1814
+ case ZodFirstPartyTypeKind.ZodSet:
1815
+ return parseSetDef(def, refs);
1816
+ case ZodFirstPartyTypeKind.ZodLazy:
1817
+ return () => def.getter()._def;
1818
+ case ZodFirstPartyTypeKind.ZodPromise:
1819
+ return parsePromiseDef(def, refs);
1820
+ case ZodFirstPartyTypeKind.ZodNaN:
1821
+ case ZodFirstPartyTypeKind.ZodNever:
1822
+ return parseNeverDef();
1823
+ case ZodFirstPartyTypeKind.ZodEffects:
1824
+ return parseEffectsDef(def, refs);
1825
+ case ZodFirstPartyTypeKind.ZodAny:
1826
+ return parseAnyDef();
1827
+ case ZodFirstPartyTypeKind.ZodUnknown:
1828
+ return parseUnknownDef();
1829
+ case ZodFirstPartyTypeKind.ZodDefault:
1830
+ return parseDefaultDef(def, refs);
1831
+ case ZodFirstPartyTypeKind.ZodBranded:
1832
+ return parseBrandedDef(def, refs);
1833
+ case ZodFirstPartyTypeKind.ZodReadonly:
1834
+ return parseReadonlyDef(def, refs);
1835
+ case ZodFirstPartyTypeKind.ZodCatch:
1836
+ return parseCatchDef(def, refs);
1837
+ case ZodFirstPartyTypeKind.ZodPipeline:
1838
+ return parsePipelineDef(def, refs);
1839
+ case ZodFirstPartyTypeKind.ZodFunction:
1840
+ case ZodFirstPartyTypeKind.ZodVoid:
1841
+ case ZodFirstPartyTypeKind.ZodSymbol:
1842
+ return void 0;
1843
+ default:
1844
+ return /* @__PURE__ */ ((_) => void 0)();
1845
+ }
1846
+ };
1847
+ function parseDef(def, refs, forceResolution = false) {
1848
+ var _a15;
1849
+ const seenItem = refs.seen.get(def);
1850
+ if (refs.override) {
1851
+ const overrideResult = (_a15 = refs.override) == null ? void 0 : _a15.call(
1852
+ refs,
1853
+ def,
1854
+ refs,
1855
+ seenItem,
1856
+ forceResolution
1857
+ );
1858
+ if (overrideResult !== ignoreOverride) {
1859
+ return overrideResult;
1860
+ }
1861
+ }
1862
+ if (seenItem && !forceResolution) {
1863
+ const seenSchema = get$ref(seenItem, refs);
1864
+ if (seenSchema !== void 0) {
1865
+ return seenSchema;
1866
+ }
1867
+ }
1868
+ const newItem = { def, path: refs.currentPath, jsonSchema: void 0 };
1869
+ refs.seen.set(def, newItem);
1870
+ const jsonSchemaOrGetter = selectParser(def, def.typeName, refs);
1871
+ const jsonSchema2 = typeof jsonSchemaOrGetter === "function" ? parseDef(jsonSchemaOrGetter(), refs) : jsonSchemaOrGetter;
1872
+ if (jsonSchema2) {
1873
+ addMeta(def, refs, jsonSchema2);
1874
+ }
1875
+ if (refs.postProcess) {
1876
+ const postProcessResult = refs.postProcess(jsonSchema2, def, refs);
1877
+ newItem.jsonSchema = jsonSchema2;
1878
+ return postProcessResult;
1879
+ }
1880
+ newItem.jsonSchema = jsonSchema2;
1881
+ return jsonSchema2;
1882
+ }
1883
+ var get$ref = (item, refs) => {
1884
+ switch (refs.$refStrategy) {
1885
+ case "root":
1886
+ return { $ref: item.path.join("/") };
1887
+ case "relative":
1888
+ return { $ref: getRelativePath(refs.currentPath, item.path) };
1889
+ case "none":
1890
+ case "seen": {
1891
+ if (item.path.length < refs.currentPath.length && item.path.every((value, index) => refs.currentPath[index] === value)) {
1892
+ console.warn(
1893
+ `Recursive reference detected at ${refs.currentPath.join(
1894
+ "/"
1895
+ )}! Defaulting to any`
1896
+ );
1897
+ return parseAnyDef();
1898
+ }
1899
+ return refs.$refStrategy === "seen" ? parseAnyDef() : void 0;
1900
+ }
1901
+ }
1902
+ };
1903
+ var addMeta = (def, refs, jsonSchema2) => {
1904
+ if (def.description) {
1905
+ jsonSchema2.description = def.description;
1906
+ }
1907
+ return jsonSchema2;
1908
+ };
1909
+ var getRefs = (options) => {
1910
+ const _options = getDefaultOptions(options);
1911
+ const currentPath = _options.name !== void 0 ? [..._options.basePath, _options.definitionPath, _options.name] : _options.basePath;
1912
+ return {
1913
+ ..._options,
1914
+ currentPath,
1915
+ propertyPath: void 0,
1916
+ seen: new Map(
1917
+ Object.entries(_options.definitions).map(([name14, def]) => [
1918
+ def._def,
1919
+ {
1920
+ def: def._def,
1921
+ path: [..._options.basePath, _options.definitionPath, name14],
1922
+ // Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
1923
+ jsonSchema: void 0
1924
+ }
1925
+ ])
1926
+ )
1927
+ };
1928
+ };
1929
+ var zodToJsonSchema = (schema, options) => {
1930
+ var _a15;
1931
+ const refs = getRefs(options);
1932
+ let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce(
1933
+ (acc, [name22, schema2]) => {
1934
+ var _a22;
1935
+ return {
1936
+ ...acc,
1937
+ [name22]: (_a22 = parseDef(
1938
+ schema2._def,
1939
+ {
1940
+ ...refs,
1941
+ currentPath: [...refs.basePath, refs.definitionPath, name22]
1942
+ },
1943
+ true
1944
+ )) != null ? _a22 : parseAnyDef()
1945
+ };
1946
+ },
1947
+ {}
1948
+ ) : void 0;
1949
+ const name14 = typeof options === "string" ? options : (options == null ? void 0 : options.nameStrategy) === "title" ? void 0 : options == null ? void 0 : options.name;
1950
+ const main = (_a15 = parseDef(
1951
+ schema._def,
1952
+ name14 === void 0 ? refs : {
1953
+ ...refs,
1954
+ currentPath: [...refs.basePath, refs.definitionPath, name14]
1955
+ },
1956
+ false
1957
+ )) != null ? _a15 : parseAnyDef();
1958
+ const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
1959
+ if (title !== void 0) {
1960
+ main.title = title;
1961
+ }
1962
+ const combined = name14 === void 0 ? definitions ? {
1963
+ ...main,
1964
+ [refs.definitionPath]: definitions
1965
+ } : main : {
1966
+ $ref: [
1967
+ ...refs.$refStrategy === "relative" ? [] : refs.basePath,
1968
+ refs.definitionPath,
1969
+ name14
1970
+ ].join("/"),
1971
+ [refs.definitionPath]: {
1972
+ ...definitions,
1973
+ [name14]: main
1974
+ }
1975
+ };
1976
+ combined.$schema = "http://json-schema.org/draft-07/schema#";
1977
+ return combined;
1978
+ };
1979
+ var zod_to_json_schema_default = zodToJsonSchema;
1980
+ function zod3Schema(zodSchema2, options) {
1981
+ var _a15;
1982
+ const useReferences = (_a15 = options == null ? void 0 : options.useReferences) != null ? _a15 : false;
1983
+ return jsonSchema(
1984
+ // defer json schema creation to avoid unnecessary computation when only validation is needed
1985
+ () => zod_to_json_schema_default(zodSchema2, {
1986
+ $refStrategy: useReferences ? "root" : "none"
1987
+ }),
1988
+ {
1989
+ validate: async (value) => {
1990
+ const result = await zodSchema2.safeParseAsync(value);
1991
+ return result.success ? { success: true, value: result.data } : { success: false, error: result.error };
1992
+ }
1993
+ }
1994
+ );
1995
+ }
1996
+ function zod4Schema(zodSchema2, options) {
1997
+ var _a15;
1998
+ const useReferences = (_a15 = options == null ? void 0 : options.useReferences) != null ? _a15 : false;
1999
+ return jsonSchema(
2000
+ // defer json schema creation to avoid unnecessary computation when only validation is needed
2001
+ () => z4.toJSONSchema(zodSchema2, {
2002
+ target: "draft-7",
2003
+ io: "output",
2004
+ reused: useReferences ? "ref" : "inline"
2005
+ }),
2006
+ {
2007
+ validate: async (value) => {
2008
+ const result = await z4.safeParseAsync(zodSchema2, value);
2009
+ return result.success ? { success: true, value: result.data } : { success: false, error: result.error };
2010
+ }
2011
+ }
2012
+ );
2013
+ }
2014
+ function isZod4Schema(zodSchema2) {
2015
+ return "_zod" in zodSchema2;
2016
+ }
2017
+ function zodSchema(zodSchema2, options) {
2018
+ if (isZod4Schema(zodSchema2)) {
2019
+ return zod4Schema(zodSchema2, options);
2020
+ } else {
2021
+ return zod3Schema(zodSchema2, options);
2022
+ }
2023
+ }
2024
+ var schemaSymbol = Symbol.for("vercel.ai.schema");
2025
+ function jsonSchema(jsonSchema2, {
2026
+ validate
2027
+ } = {}) {
2028
+ return {
2029
+ [schemaSymbol]: true,
2030
+ _type: void 0,
2031
+ // should never be used directly
2032
+ [validatorSymbol]: true,
2033
+ get jsonSchema() {
2034
+ if (typeof jsonSchema2 === "function") {
2035
+ jsonSchema2 = jsonSchema2();
2036
+ }
2037
+ return jsonSchema2;
2038
+ },
2039
+ validate
2040
+ };
2041
+ }
2042
+ function isSchema(value) {
2043
+ return typeof value === "object" && value !== null && schemaSymbol in value && value[schemaSymbol] === true && "jsonSchema" in value && "validate" in value;
2044
+ }
2045
+ function asSchema(schema) {
2046
+ return schema == null ? jsonSchema({
2047
+ properties: {},
2048
+ additionalProperties: false
2049
+ }) : isSchema(schema) ? schema : typeof schema === "function" ? schema() : zodSchema(schema);
2050
+ }
2051
+ var { btoa, atob } = globalThis;
2052
+ function convertBase64ToUint8Array(base64String) {
2053
+ const base64Url = base64String.replace(/-/g, "+").replace(/_/g, "/");
2054
+ const latin1string = atob(base64Url);
2055
+ return Uint8Array.from(latin1string, (byte) => byte.codePointAt(0));
2056
+ }
2057
+ function convertUint8ArrayToBase64(array) {
2058
+ let latin1string = "";
2059
+ for (let i = 0; i < array.length; i++) {
2060
+ latin1string += String.fromCodePoint(array[i]);
2061
+ }
2062
+ return btoa(latin1string);
2063
+ }
2064
+ function withoutTrailingSlash(url) {
2065
+ return url == null ? void 0 : url.replace(/\/$/, "");
2066
+ }
2067
+
2068
+ export { AISDKError, APICallError, asSchema, combineHeaders, convertBase64ToUint8Array, convertUint8ArrayToBase64, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, delay, generateId, getErrorMessage, getErrorMessage2, getFromApi, getRuntimeEnvironmentUserAgent, isAbortError, jsonSchema, lazyValidator, loadOptionalSetting, postJsonToApi, resolve, safeParseJSON, safeValidateTypes, tool, validateTypes, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
2069
+ //# sourceMappingURL=chunk-G6E6V2Z4.js.map
2070
+ //# sourceMappingURL=chunk-G6E6V2Z4.js.map