@mastra/server 0.0.0-scorers-api-v2-20250801171841 → 0.0.0-scorers-ui-refactored-20250916094952

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