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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (326) hide show
  1. package/CHANGELOG.md +3812 -0
  2. package/LICENSE.md +11 -42
  3. package/README.md +0 -5
  4. package/dist/{chunk-H5PTF3Y4.js → chunk-4QCXUEAT.js} +11 -2
  5. package/dist/chunk-4QCXUEAT.js.map +1 -0
  6. package/dist/chunk-4RRMWXQ2.js +3522 -0
  7. package/dist/chunk-4RRMWXQ2.js.map +1 -0
  8. package/dist/chunk-52UP7DFT.cjs +130 -0
  9. package/dist/chunk-52UP7DFT.cjs.map +1 -0
  10. package/dist/chunk-5DP5XZH6.cjs +928 -0
  11. package/dist/chunk-5DP5XZH6.cjs.map +1 -0
  12. package/dist/chunk-66YYHFGF.js +761 -0
  13. package/dist/chunk-66YYHFGF.js.map +1 -0
  14. package/dist/chunk-6GMFZ5LK.js +2774 -0
  15. package/dist/chunk-6GMFZ5LK.js.map +1 -0
  16. package/dist/{chunk-GHC4YV6R.js → chunk-6IJWRJZE.js} +109 -136
  17. package/dist/chunk-6IJWRJZE.js.map +1 -0
  18. package/dist/chunk-743UIDHI.cjs +2013 -0
  19. package/dist/chunk-743UIDHI.cjs.map +1 -0
  20. package/dist/chunk-7ESQBAXS.cjs +18023 -0
  21. package/dist/chunk-7ESQBAXS.cjs.map +1 -0
  22. package/dist/{chunk-OCWPVYNI.cjs → chunk-7NADHFD2.cjs} +3 -0
  23. package/dist/chunk-7NADHFD2.cjs.map +1 -0
  24. package/dist/{chunk-BOXE6WSV.js → chunk-A3AL7EWJ.js} +5 -3
  25. package/dist/chunk-A3AL7EWJ.js.map +1 -0
  26. package/dist/chunk-AK2FXLLB.cjs +849 -0
  27. package/dist/chunk-AK2FXLLB.cjs.map +1 -0
  28. package/dist/chunk-BKCWZLEL.cjs +197 -0
  29. package/dist/chunk-BKCWZLEL.cjs.map +1 -0
  30. package/dist/chunk-BOVFMBXY.js +607 -0
  31. package/dist/chunk-BOVFMBXY.js.map +1 -0
  32. package/dist/{chunk-QDOJJCS4.js → chunk-CY4TP3FK.js} +6 -2
  33. package/dist/chunk-CY4TP3FK.js.map +1 -0
  34. package/dist/chunk-EMMSS5I5.cjs +37 -0
  35. package/dist/chunk-EMMSS5I5.cjs.map +1 -0
  36. package/dist/chunk-EMNGA4R4.js +845 -0
  37. package/dist/chunk-EMNGA4R4.js.map +1 -0
  38. package/dist/chunk-FALVL2VV.cjs +3525 -0
  39. package/dist/chunk-FALVL2VV.cjs.map +1 -0
  40. package/dist/chunk-FQNT7PI4.js +937 -0
  41. package/dist/chunk-FQNT7PI4.js.map +1 -0
  42. package/dist/chunk-G3PMV62Z.js +33 -0
  43. package/dist/chunk-G3PMV62Z.js.map +1 -0
  44. package/dist/chunk-G4PUALCE.cjs +28 -0
  45. package/dist/chunk-G4PUALCE.cjs.map +1 -0
  46. package/dist/chunk-GU4EWMZB.cjs +769 -0
  47. package/dist/chunk-GU4EWMZB.cjs.map +1 -0
  48. package/dist/chunk-HJQKWRKQ.cjs +764 -0
  49. package/dist/chunk-HJQKWRKQ.cjs.map +1 -0
  50. package/dist/{chunk-LI436ITD.cjs → chunk-HVBBFCDH.cjs} +1041 -762
  51. package/dist/chunk-HVBBFCDH.cjs.map +1 -0
  52. package/dist/chunk-HZJRQ5L3.cjs +1411 -0
  53. package/dist/chunk-HZJRQ5L3.cjs.map +1 -0
  54. package/dist/chunk-IGFMAZZ5.cjs +1150 -0
  55. package/dist/chunk-IGFMAZZ5.cjs.map +1 -0
  56. package/dist/chunk-IOQGI4ML.js +931 -0
  57. package/dist/chunk-IOQGI4ML.js.map +1 -0
  58. package/dist/chunk-JQ74G5IO.js +17987 -0
  59. package/dist/chunk-JQ74G5IO.js.map +1 -0
  60. package/dist/{chunk-G37NVEDX.js → chunk-JRDEOHAJ.js} +23 -13
  61. package/dist/chunk-JRDEOHAJ.js.map +1 -0
  62. package/dist/chunk-JSMP6GVP.cjs +595 -0
  63. package/dist/chunk-JSMP6GVP.cjs.map +1 -0
  64. package/dist/{chunk-DFJUGWNU.js → chunk-KM7EJKXV.js} +50 -12
  65. package/dist/chunk-KM7EJKXV.js.map +1 -0
  66. package/dist/{chunk-TGZIR6AK.cjs → chunk-KNGXRN26.cjs} +48 -45
  67. package/dist/chunk-KNGXRN26.cjs.map +1 -0
  68. package/dist/{chunk-BP24Z4WG.js → chunk-KV6VHX4V.js} +24 -5
  69. package/dist/chunk-KV6VHX4V.js.map +1 -0
  70. package/dist/chunk-LF2ZLOFP.js +767 -0
  71. package/dist/chunk-LF2ZLOFP.js.map +1 -0
  72. package/dist/chunk-LJFAAEU7.cjs +167 -0
  73. package/dist/chunk-LJFAAEU7.cjs.map +1 -0
  74. package/dist/chunk-LYPU75T6.js +1147 -0
  75. package/dist/chunk-LYPU75T6.js.map +1 -0
  76. package/dist/{chunk-NYN7KFXL.js → chunk-MMROOK5J.js} +3 -0
  77. package/dist/chunk-MMROOK5J.js.map +1 -0
  78. package/dist/{chunk-MEGCYGBU.js → chunk-N7F33WAD.js} +1013 -762
  79. package/dist/chunk-N7F33WAD.js.map +1 -0
  80. package/dist/chunk-NG5IVLEZ.js +1012 -0
  81. package/dist/chunk-NG5IVLEZ.js.map +1 -0
  82. package/dist/chunk-NLWACBE7.cjs +128 -0
  83. package/dist/chunk-NLWACBE7.cjs.map +1 -0
  84. package/dist/chunk-OGW6HHVI.js +1408 -0
  85. package/dist/chunk-OGW6HHVI.js.map +1 -0
  86. package/dist/{chunk-SDPGVWQJ.cjs → chunk-OPI3FZYH.cjs} +110 -137
  87. package/dist/chunk-OPI3FZYH.cjs.map +1 -0
  88. package/dist/chunk-OZLRIVC4.cjs +588 -0
  89. package/dist/chunk-OZLRIVC4.cjs.map +1 -0
  90. package/dist/chunk-P7CIEIJ3.js +925 -0
  91. package/dist/chunk-P7CIEIJ3.js.map +1 -0
  92. package/dist/chunk-P7RBMCBE.cjs +934 -0
  93. package/dist/chunk-P7RBMCBE.cjs.map +1 -0
  94. package/dist/chunk-PPYGWINI.cjs +2777 -0
  95. package/dist/chunk-PPYGWINI.cjs.map +1 -0
  96. package/dist/{chunk-ULFULEW4.cjs → chunk-PWTXZZTR.cjs} +28 -8
  97. package/dist/chunk-PWTXZZTR.cjs.map +1 -0
  98. package/dist/chunk-RCHEPTZZ.js +2006 -0
  99. package/dist/chunk-RCHEPTZZ.js.map +1 -0
  100. package/dist/chunk-RE4RPXT2.cjs +18 -0
  101. package/dist/chunk-RE4RPXT2.cjs.map +1 -0
  102. package/dist/chunk-SIGXR3JT.cjs +1043 -0
  103. package/dist/chunk-SIGXR3JT.cjs.map +1 -0
  104. package/dist/{chunk-CNVDCLSY.cjs → chunk-SPLSYTYW.cjs} +11 -9
  105. package/dist/chunk-SPLSYTYW.cjs.map +1 -0
  106. package/dist/chunk-SQY4T6EJ.js +571 -0
  107. package/dist/chunk-SQY4T6EJ.js.map +1 -0
  108. package/dist/chunk-SXENNNR7.cjs +625 -0
  109. package/dist/chunk-SXENNNR7.cjs.map +1 -0
  110. package/dist/{chunk-TVBPFPTN.cjs → chunk-T3TIA3O6.cjs} +20 -18
  111. package/dist/chunk-T3TIA3O6.cjs.map +1 -0
  112. package/dist/{chunk-7GQJAMTA.js → chunk-TTHEEIZ3.js} +13 -10
  113. package/dist/chunk-TTHEEIZ3.js.map +1 -0
  114. package/dist/chunk-TVSIG4JE.cjs +940 -0
  115. package/dist/chunk-TVSIG4JE.cjs.map +1 -0
  116. package/dist/chunk-VY4ENABS.cjs +135 -0
  117. package/dist/chunk-VY4ENABS.cjs.map +1 -0
  118. package/dist/{chunk-FVMGZKFD.js → chunk-WHN4VX55.js} +5 -3
  119. package/dist/chunk-WHN4VX55.js.map +1 -0
  120. package/dist/chunk-WUJLVNLU.js +124 -0
  121. package/dist/chunk-WUJLVNLU.js.map +1 -0
  122. package/dist/chunk-XJOYGRTN.js +189 -0
  123. package/dist/chunk-XJOYGRTN.js.map +1 -0
  124. package/dist/chunk-YWOK4F5A.js +131 -0
  125. package/dist/chunk-YWOK4F5A.js.map +1 -0
  126. package/dist/{chunk-Z5TH5F35.js → chunk-ZAYTLC6C.js} +188 -80
  127. package/dist/chunk-ZAYTLC6C.js.map +1 -0
  128. package/dist/dist-26HWEQY6.js +3 -0
  129. package/dist/dist-26HWEQY6.js.map +1 -0
  130. package/dist/dist-3A5DXB37.cjs +20 -0
  131. package/dist/dist-3A5DXB37.cjs.map +1 -0
  132. package/dist/dist-3SJKQJGY.cjs +16 -0
  133. package/dist/dist-3SJKQJGY.cjs.map +1 -0
  134. package/dist/dist-4ZQSPE5K.js +3 -0
  135. package/dist/dist-4ZQSPE5K.js.map +1 -0
  136. package/dist/dist-5W5QNRTD.js +3 -0
  137. package/dist/dist-5W5QNRTD.js.map +1 -0
  138. package/dist/dist-653SRMPL.js +3 -0
  139. package/dist/dist-653SRMPL.js.map +1 -0
  140. package/dist/dist-6U6EFC5C.cjs +16 -0
  141. package/dist/dist-6U6EFC5C.cjs.map +1 -0
  142. package/dist/dist-7IHNNYMF.cjs +16 -0
  143. package/dist/dist-7IHNNYMF.cjs.map +1 -0
  144. package/dist/dist-B5IPRF6W.js +3 -0
  145. package/dist/dist-B5IPRF6W.js.map +1 -0
  146. package/dist/dist-EOMYFT4Y.cjs +16 -0
  147. package/dist/dist-EOMYFT4Y.cjs.map +1 -0
  148. package/dist/dist-EZZMMMNT.cjs +16 -0
  149. package/dist/dist-EZZMMMNT.cjs.map +1 -0
  150. package/dist/dist-F2ET4MNO.cjs +16 -0
  151. package/dist/dist-F2ET4MNO.cjs.map +1 -0
  152. package/dist/dist-H64VX6DE.js +3 -0
  153. package/dist/dist-H64VX6DE.js.map +1 -0
  154. package/dist/dist-HY7RMLJQ.cjs +16 -0
  155. package/dist/dist-HY7RMLJQ.cjs.map +1 -0
  156. package/dist/dist-M6S4P3FJ.js +3 -0
  157. package/dist/dist-M6S4P3FJ.js.map +1 -0
  158. package/dist/dist-NR7QSCQT.js +3 -0
  159. package/dist/dist-NR7QSCQT.js.map +1 -0
  160. package/dist/dist-QLFMCMCX.js +3 -0
  161. package/dist/dist-QLFMCMCX.js.map +1 -0
  162. package/dist/dist-UY46BFRP.js +3 -0
  163. package/dist/dist-UY46BFRP.js.map +1 -0
  164. package/dist/dist-WCQDRTIV.cjs +16 -0
  165. package/dist/dist-WCQDRTIV.cjs.map +1 -0
  166. package/dist/dist-WKYB3LTJ.cjs +16 -0
  167. package/dist/dist-WKYB3LTJ.cjs.map +1 -0
  168. package/dist/index.cjs +6 -0
  169. package/dist/index.cjs.map +1 -0
  170. package/dist/index.d.ts +1 -0
  171. package/dist/index.d.ts.map +1 -0
  172. package/dist/index.js +5 -0
  173. package/dist/index.js.map +1 -0
  174. package/dist/server/a2a/protocol.d.ts +8 -0
  175. package/dist/server/a2a/protocol.d.ts.map +1 -0
  176. package/dist/server/a2a/store.cjs +25 -0
  177. package/dist/server/a2a/store.cjs.map +1 -0
  178. package/dist/server/a2a/store.d.ts +14 -0
  179. package/dist/server/a2a/store.d.ts.map +1 -0
  180. package/dist/server/a2a/store.js +23 -0
  181. package/dist/server/a2a/store.js.map +1 -0
  182. package/dist/server/a2a/tasks.d.ts +20 -0
  183. package/dist/server/a2a/tasks.d.ts.map +1 -0
  184. package/dist/server/handlers/a2a.cjs +13 -11
  185. package/dist/server/handlers/a2a.cjs.map +1 -0
  186. package/dist/server/handlers/a2a.d.ts +68 -6
  187. package/dist/server/handlers/a2a.d.ts.map +1 -0
  188. package/dist/server/handlers/a2a.js +3 -1
  189. package/dist/server/handlers/a2a.js.map +1 -0
  190. package/dist/server/handlers/agent-builder.cjs +68 -0
  191. package/dist/server/handlers/agent-builder.cjs.map +1 -0
  192. package/dist/server/handlers/agent-builder.d.ts +92 -0
  193. package/dist/server/handlers/agent-builder.d.ts.map +1 -0
  194. package/dist/server/handlers/agent-builder.js +3 -0
  195. package/dist/server/handlers/agent-builder.js.map +1 -0
  196. package/dist/server/handlers/agents.cjs +49 -7
  197. package/dist/server/handlers/agents.cjs.map +1 -0
  198. package/dist/server/handlers/agents.d.ts +185 -6
  199. package/dist/server/handlers/agents.d.ts.map +1 -0
  200. package/dist/server/handlers/agents.js +3 -1
  201. package/dist/server/handlers/agents.js.map +1 -0
  202. package/dist/server/handlers/error.cjs +4 -2
  203. package/dist/server/handlers/error.cjs.map +1 -0
  204. package/dist/server/handlers/error.d.ts +2 -1
  205. package/dist/server/handlers/error.d.ts.map +1 -0
  206. package/dist/server/handlers/error.js +3 -1
  207. package/dist/server/handlers/error.js.map +1 -0
  208. package/dist/server/handlers/legacyWorkflows.cjs +13 -11
  209. package/dist/server/handlers/legacyWorkflows.cjs.map +1 -0
  210. package/dist/server/handlers/legacyWorkflows.d.ts +59 -10
  211. package/dist/server/handlers/legacyWorkflows.d.ts.map +1 -0
  212. package/dist/server/handlers/legacyWorkflows.js +3 -1
  213. package/dist/server/handlers/legacyWorkflows.js.map +1 -0
  214. package/dist/server/handlers/logs.cjs +6 -4
  215. package/dist/server/handlers/logs.cjs.map +1 -0
  216. package/dist/server/handlers/logs.d.ts +34 -3
  217. package/dist/server/handlers/logs.d.ts.map +1 -0
  218. package/dist/server/handlers/logs.js +3 -1
  219. package/dist/server/handlers/logs.js.map +1 -0
  220. package/dist/server/handlers/memory.cjs +39 -9
  221. package/dist/server/handlers/memory.cjs.map +1 -0
  222. package/dist/server/handlers/memory.d.ts +118 -8
  223. package/dist/server/handlers/memory.d.ts.map +1 -0
  224. package/dist/server/handlers/memory.js +3 -1
  225. package/dist/server/handlers/memory.js.map +1 -0
  226. package/dist/server/handlers/observability.cjs +24 -0
  227. package/dist/server/handlers/observability.cjs.map +1 -0
  228. package/dist/server/handlers/observability.d.ts +49 -0
  229. package/dist/server/handlers/observability.d.ts.map +1 -0
  230. package/dist/server/handlers/observability.js +3 -0
  231. package/dist/server/handlers/observability.js.map +1 -0
  232. package/dist/server/handlers/scores.cjs +32 -0
  233. package/dist/server/handlers/scores.cjs.map +1 -0
  234. package/dist/server/handlers/scores.d.ts +251 -0
  235. package/dist/server/handlers/scores.d.ts.map +1 -0
  236. package/dist/server/handlers/scores.js +3 -0
  237. package/dist/server/handlers/scores.js.map +1 -0
  238. package/dist/server/handlers/telemetry.cjs +9 -3
  239. package/dist/server/handlers/telemetry.cjs.map +1 -0
  240. package/dist/server/handlers/telemetry.d.ts +33 -2
  241. package/dist/server/handlers/telemetry.d.ts.map +1 -0
  242. package/dist/server/handlers/telemetry.js +3 -1
  243. package/dist/server/handlers/telemetry.js.map +1 -0
  244. package/dist/server/handlers/tools.cjs +11 -5
  245. package/dist/server/handlers/tools.cjs.map +1 -0
  246. package/dist/server/handlers/tools.d.ts +25 -4
  247. package/dist/server/handlers/tools.d.ts.map +1 -0
  248. package/dist/server/handlers/tools.js +3 -1
  249. package/dist/server/handlers/tools.js.map +1 -0
  250. package/dist/server/handlers/utils.cjs +8 -2
  251. package/dist/server/handlers/utils.cjs.map +1 -0
  252. package/dist/server/handlers/utils.d.ts +8 -1
  253. package/dist/server/handlers/utils.d.ts.map +1 -0
  254. package/dist/server/handlers/utils.js +3 -1
  255. package/dist/server/handlers/utils.js.map +1 -0
  256. package/dist/server/handlers/vNextNetwork.cjs +26 -24
  257. package/dist/server/handlers/vNextNetwork.cjs.map +1 -0
  258. package/dist/server/handlers/vNextNetwork.d.ts +246 -6
  259. package/dist/server/handlers/vNextNetwork.d.ts.map +1 -0
  260. package/dist/server/handlers/vNextNetwork.js +11 -9
  261. package/dist/server/handlers/vNextNetwork.js.map +1 -0
  262. package/dist/server/handlers/vector.cjs +9 -7
  263. package/dist/server/handlers/vector.cjs.map +1 -0
  264. package/dist/server/handlers/vector.d.ts +51 -6
  265. package/dist/server/handlers/vector.d.ts.map +1 -0
  266. package/dist/server/handlers/vector.js +3 -1
  267. package/dist/server/handlers/vector.js.map +1 -0
  268. package/dist/server/handlers/voice.cjs +7 -5
  269. package/dist/server/handlers/voice.cjs.map +1 -0
  270. package/dist/server/handlers/voice.d.ts +41 -4
  271. package/dist/server/handlers/voice.d.ts.map +1 -0
  272. package/dist/server/handlers/voice.js +3 -1
  273. package/dist/server/handlers/voice.js.map +1 -0
  274. package/dist/server/handlers/workflows.cjs +32 -14
  275. package/dist/server/handlers/workflows.cjs.map +1 -0
  276. package/dist/server/handlers/workflows.d.ts +87 -13
  277. package/dist/server/handlers/workflows.d.ts.map +1 -0
  278. package/dist/server/handlers/workflows.js +3 -1
  279. package/dist/server/handlers/workflows.js.map +1 -0
  280. package/dist/server/handlers.cjs +44 -32
  281. package/dist/server/handlers.cjs.map +1 -0
  282. package/dist/server/handlers.d.ts +14 -11
  283. package/dist/server/handlers.d.ts.map +1 -0
  284. package/dist/server/handlers.js +15 -11
  285. package/dist/server/handlers.js.map +1 -0
  286. package/dist/server/http-exception.d.ts +87 -0
  287. package/dist/server/http-exception.d.ts.map +1 -0
  288. package/dist/server/types.d.ts +10 -0
  289. package/dist/server/types.d.ts.map +1 -0
  290. package/dist/server/utils.d.ts +44 -0
  291. package/dist/server/utils.d.ts.map +1 -0
  292. package/package.json +46 -15
  293. package/dist/_tsup-dts-rollup.d.cts +0 -1068
  294. package/dist/_tsup-dts-rollup.d.ts +0 -1068
  295. package/dist/chunk-3DKDT264.cjs +0 -251
  296. package/dist/chunk-4QBIUKVY.js +0 -270
  297. package/dist/chunk-57CJTIPW.cjs +0 -18
  298. package/dist/chunk-7524QH7G.cjs +0 -483
  299. package/dist/chunk-75ZPJI57.cjs +0 -9
  300. package/dist/chunk-BWHGBV3K.cjs +0 -278
  301. package/dist/chunk-DPRB3R7Y.cjs +0 -148
  302. package/dist/chunk-FGGMQCPP.cjs +0 -128
  303. package/dist/chunk-L3N7ST2Z.cjs +0 -118
  304. package/dist/chunk-LTJNMM2Y.js +0 -241
  305. package/dist/chunk-MLKGABMK.js +0 -7
  306. package/dist/chunk-MTR2B27E.cjs +0 -14
  307. package/dist/chunk-VMXLEF54.js +0 -142
  308. package/dist/index.d.cts +0 -1
  309. package/dist/server/handlers/a2a.d.cts +0 -6
  310. package/dist/server/handlers/agents.d.cts +0 -6
  311. package/dist/server/handlers/error.d.cts +0 -1
  312. package/dist/server/handlers/legacyWorkflows.d.cts +0 -10
  313. package/dist/server/handlers/logs.d.cts +0 -3
  314. package/dist/server/handlers/memory.d.cts +0 -8
  315. package/dist/server/handlers/network.cjs +0 -22
  316. package/dist/server/handlers/network.d.cts +0 -4
  317. package/dist/server/handlers/network.d.ts +0 -4
  318. package/dist/server/handlers/network.js +0 -1
  319. package/dist/server/handlers/telemetry.d.cts +0 -2
  320. package/dist/server/handlers/tools.d.cts +0 -4
  321. package/dist/server/handlers/utils.d.cts +0 -1
  322. package/dist/server/handlers/vNextNetwork.d.cts +0 -6
  323. package/dist/server/handlers/vector.d.cts +0 -6
  324. package/dist/server/handlers/voice.d.cts +0 -4
  325. package/dist/server/handlers/workflows.d.cts +0 -13
  326. package/dist/server/handlers.d.cts +0 -11
@@ -0,0 +1,607 @@
1
+ import { google as google$1 } from './chunk-FQNT7PI4.js';
2
+ import { anthropic } from './chunk-RCHEPTZZ.js';
3
+ import { groq } from './chunk-EMNGA4R4.js';
4
+ import { xai } from './chunk-IOQGI4ML.js';
5
+ import { google } from './chunk-OGW6HHVI.js';
6
+ import { anthropic as anthropic$1 } from './chunk-LYPU75T6.js';
7
+ import { groq as groq$1 } from './chunk-66YYHFGF.js';
8
+ import { xai as xai$1 } from './chunk-P7CIEIJ3.js';
9
+ import { sanitizeBody, validateBody } from './chunk-4QCXUEAT.js';
10
+ import { openai } from './chunk-4RRMWXQ2.js';
11
+ import { openai as openai$1 } from './chunk-6GMFZ5LK.js';
12
+ import { stringify } from './chunk-LF2ZLOFP.js';
13
+ import { handleError } from './chunk-CY4TP3FK.js';
14
+ import { HTTPException } from './chunk-MMROOK5J.js';
15
+ import { __export } from './chunk-G3PMV62Z.js';
16
+ import { RuntimeContext } from '@mastra/core/runtime-context';
17
+ import { zodToJsonSchema } from '@mastra/core/utils/zod-to-json';
18
+
19
+ // src/server/handlers/agents.ts
20
+ var agents_exports = {};
21
+ __export(agents_exports, {
22
+ generateHandler: () => generateHandler,
23
+ generateLegacyHandler: () => generateLegacyHandler,
24
+ generateVNextHandler: () => generateVNextHandler,
25
+ getAgentByIdHandler: () => getAgentByIdHandler,
26
+ getAgentsHandler: () => getAgentsHandler,
27
+ getEvalsByAgentIdHandler: () => getEvalsByAgentIdHandler,
28
+ getLiveEvalsByAgentIdHandler: () => getLiveEvalsByAgentIdHandler,
29
+ getSerializedAgentTools: () => getSerializedAgentTools,
30
+ reorderAgentModelListHandler: () => reorderAgentModelListHandler,
31
+ streamGenerateHandler: () => streamGenerateHandler,
32
+ streamGenerateLegacyHandler: () => streamGenerateLegacyHandler,
33
+ streamNetworkHandler: () => streamNetworkHandler,
34
+ streamVNextGenerateHandler: () => streamVNextGenerateHandler,
35
+ streamVNextUIMessageHandler: () => streamVNextUIMessageHandler,
36
+ updateAgentModelHandler: () => updateAgentModelHandler,
37
+ updateAgentModelInModelListHandler: () => updateAgentModelInModelListHandler
38
+ });
39
+ async function getSerializedAgentTools(tools) {
40
+ return Object.entries(tools || {}).reduce((acc, [key, tool]) => {
41
+ const _tool = tool;
42
+ const toolId = _tool.id ?? `tool-${key}`;
43
+ let inputSchemaForReturn = void 0;
44
+ if (_tool.inputSchema) {
45
+ if (_tool.inputSchema?.jsonSchema) {
46
+ inputSchemaForReturn = stringify(_tool.inputSchema.jsonSchema);
47
+ } else {
48
+ inputSchemaForReturn = stringify(zodToJsonSchema(_tool.inputSchema));
49
+ }
50
+ }
51
+ let outputSchemaForReturn = void 0;
52
+ if (_tool.outputSchema) {
53
+ if (_tool.outputSchema?.jsonSchema) {
54
+ outputSchemaForReturn = stringify(_tool.outputSchema.jsonSchema);
55
+ } else {
56
+ outputSchemaForReturn = stringify(zodToJsonSchema(_tool.outputSchema));
57
+ }
58
+ }
59
+ acc[key] = {
60
+ ..._tool,
61
+ id: toolId,
62
+ inputSchema: inputSchemaForReturn,
63
+ outputSchema: outputSchemaForReturn
64
+ };
65
+ return acc;
66
+ }, {});
67
+ }
68
+ async function getSerializedAgentDefinition({
69
+ agent,
70
+ runtimeContext
71
+ }) {
72
+ let serializedAgentAgents = {};
73
+ if ("listAgents" in agent) {
74
+ const agents = await agent.listAgents({ runtimeContext });
75
+ serializedAgentAgents = Object.entries(agents || {}).reduce((acc, [key, agent2]) => {
76
+ return {
77
+ ...acc,
78
+ [key]: { id: agent2.id, name: agent2.name }
79
+ };
80
+ }, {});
81
+ }
82
+ return serializedAgentAgents;
83
+ }
84
+ async function formatAgentList({
85
+ id,
86
+ mastra,
87
+ agent,
88
+ runtimeContext
89
+ }) {
90
+ const instructions = await agent.getInstructions({ runtimeContext });
91
+ const tools = await agent.getTools({ runtimeContext });
92
+ const llm = await agent.getLLM({ runtimeContext });
93
+ const defaultGenerateOptions = await agent.getDefaultGenerateOptions({ runtimeContext });
94
+ const defaultStreamOptions = await agent.getDefaultStreamOptions({ runtimeContext });
95
+ const serializedAgentTools = await getSerializedAgentTools(tools);
96
+ let serializedAgentWorkflows = {};
97
+ if ("getWorkflows" in agent) {
98
+ const logger = mastra.getLogger();
99
+ try {
100
+ const workflows = await agent.getWorkflows({ runtimeContext });
101
+ serializedAgentWorkflows = Object.entries(workflows || {}).reduce((acc, [key, workflow]) => {
102
+ return {
103
+ ...acc,
104
+ [key]: {
105
+ name: workflow.name
106
+ }
107
+ };
108
+ }, {});
109
+ } catch (error) {
110
+ logger.error("Error getting workflows for agent", { agentName: agent.name, error });
111
+ }
112
+ }
113
+ const serializedAgentAgents = await getSerializedAgentDefinition({ agent, runtimeContext });
114
+ const model = llm?.getModel();
115
+ const models = await agent.getModelList(runtimeContext);
116
+ const modelList = models?.map((md) => ({
117
+ ...md,
118
+ model: {
119
+ modelId: md.model.modelId,
120
+ provider: md.model.provider,
121
+ modelVersion: md.model.specificationVersion
122
+ }
123
+ }));
124
+ return {
125
+ id,
126
+ name: agent.name,
127
+ instructions,
128
+ agents: serializedAgentAgents,
129
+ tools: serializedAgentTools,
130
+ workflows: serializedAgentWorkflows,
131
+ provider: llm?.getProvider(),
132
+ modelId: llm?.getModelId(),
133
+ modelVersion: model?.specificationVersion,
134
+ defaultGenerateOptions,
135
+ defaultStreamOptions,
136
+ modelList
137
+ };
138
+ }
139
+ async function getAgentsHandler({ mastra, runtimeContext }) {
140
+ try {
141
+ const agents = mastra.getAgents();
142
+ const serializedAgentsMap = await Promise.all(
143
+ Object.entries(agents).map(async ([id, agent]) => {
144
+ return formatAgentList({ id, mastra, agent, runtimeContext });
145
+ })
146
+ );
147
+ const serializedAgents = serializedAgentsMap.reduce((acc, { id, ...rest }) => {
148
+ acc[id] = rest;
149
+ return acc;
150
+ }, {});
151
+ return serializedAgents;
152
+ } catch (error) {
153
+ return handleError(error, "Error getting agents");
154
+ }
155
+ }
156
+ async function formatAgent({
157
+ mastra,
158
+ agent,
159
+ runtimeContext,
160
+ isPlayground
161
+ }) {
162
+ const tools = await agent.getTools({ runtimeContext });
163
+ const serializedAgentTools = await getSerializedAgentTools(tools);
164
+ let serializedAgentWorkflows = {};
165
+ if ("getWorkflows" in agent) {
166
+ const logger = mastra.getLogger();
167
+ try {
168
+ const workflows = await agent.getWorkflows({ runtimeContext });
169
+ serializedAgentWorkflows = Object.entries(workflows || {}).reduce((acc, [key, workflow]) => {
170
+ return {
171
+ ...acc,
172
+ [key]: {
173
+ name: workflow.name,
174
+ steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
175
+ return {
176
+ ...acc2,
177
+ [key2]: {
178
+ id: step.id,
179
+ description: step.description
180
+ }
181
+ };
182
+ }, {})
183
+ }
184
+ };
185
+ }, {});
186
+ } catch (error) {
187
+ logger.error("Error getting workflows for agent", { agentName: agent.name, error });
188
+ }
189
+ let proxyRuntimeContext = runtimeContext;
190
+ if (isPlayground) {
191
+ proxyRuntimeContext = new Proxy(runtimeContext, {
192
+ get(target, prop) {
193
+ if (prop === "get") {
194
+ return function(key) {
195
+ const value = target.get(key);
196
+ return value ?? `<${key}>`;
197
+ };
198
+ }
199
+ return Reflect.get(target, prop);
200
+ }
201
+ });
202
+ }
203
+ const instructions = await agent.getInstructions({ runtimeContext: proxyRuntimeContext });
204
+ const llm = await agent.getLLM({ runtimeContext });
205
+ const defaultGenerateOptions = await agent.getDefaultGenerateOptions({ runtimeContext: proxyRuntimeContext });
206
+ const defaultStreamOptions = await agent.getDefaultStreamOptions({ runtimeContext: proxyRuntimeContext });
207
+ const model = llm?.getModel();
208
+ const models = await agent.getModelList(runtimeContext);
209
+ const modelList = models?.map((md) => ({
210
+ ...md,
211
+ model: {
212
+ modelId: md.model.modelId,
213
+ provider: md.model.provider,
214
+ modelVersion: md.model.specificationVersion
215
+ }
216
+ }));
217
+ const serializedAgentAgents = await getSerializedAgentDefinition({ agent, runtimeContext: proxyRuntimeContext });
218
+ return {
219
+ name: agent.name,
220
+ instructions,
221
+ tools: serializedAgentTools,
222
+ agents: serializedAgentAgents,
223
+ workflows: serializedAgentWorkflows,
224
+ provider: llm?.getProvider(),
225
+ modelId: llm?.getModelId(),
226
+ modelVersion: model?.specificationVersion,
227
+ modelList,
228
+ defaultGenerateOptions,
229
+ defaultStreamOptions
230
+ };
231
+ }
232
+ }
233
+ async function getAgentByIdHandler({
234
+ mastra,
235
+ runtimeContext,
236
+ agentId,
237
+ isPlayground = false
238
+ }) {
239
+ try {
240
+ const agent = mastra.getAgent(agentId);
241
+ if (!agent) {
242
+ throw new HTTPException(404, { message: "Agent not found" });
243
+ }
244
+ return formatAgent({ mastra, agent, runtimeContext, isPlayground });
245
+ } catch (error) {
246
+ return handleError(error, "Error getting agent");
247
+ }
248
+ }
249
+ async function getEvalsByAgentIdHandler({
250
+ mastra,
251
+ runtimeContext,
252
+ agentId
253
+ }) {
254
+ try {
255
+ const agent = mastra.getAgent(agentId);
256
+ const evals = await mastra.getStorage()?.getEvalsByAgentName?.(agent.name, "test") || [];
257
+ const instructions = await agent.getInstructions({ runtimeContext });
258
+ return {
259
+ id: agentId,
260
+ name: agent.name,
261
+ instructions,
262
+ evals
263
+ };
264
+ } catch (error) {
265
+ return handleError(error, "Error getting test evals");
266
+ }
267
+ }
268
+ async function getLiveEvalsByAgentIdHandler({
269
+ mastra,
270
+ runtimeContext,
271
+ agentId
272
+ }) {
273
+ try {
274
+ const agent = mastra.getAgent(agentId);
275
+ const evals = await mastra.getStorage()?.getEvalsByAgentName?.(agent.name, "live") || [];
276
+ const instructions = await agent.getInstructions({ runtimeContext });
277
+ return {
278
+ id: agentId,
279
+ name: agent.name,
280
+ instructions,
281
+ evals
282
+ };
283
+ } catch (error) {
284
+ return handleError(error, "Error getting live evals");
285
+ }
286
+ }
287
+ function generateHandler({
288
+ mastra,
289
+ ...args
290
+ }) {
291
+ const logger = mastra.getLogger();
292
+ logger?.warn(
293
+ "Deprecation NOTICE:\nGenerate method will switch to use generateVNext implementation September 30th, 2025. Please use generateLegacyHandler if you don't want to upgrade just yet."
294
+ );
295
+ return generateLegacyHandler({ mastra, ...args });
296
+ }
297
+ async function generateLegacyHandler({
298
+ mastra,
299
+ runtimeContext,
300
+ agentId,
301
+ body,
302
+ abortSignal
303
+ }) {
304
+ try {
305
+ const agent = mastra.getAgent(agentId);
306
+ if (!agent) {
307
+ throw new HTTPException(404, { message: "Agent not found" });
308
+ }
309
+ sanitizeBody(body, ["tools"]);
310
+ const { messages, resourceId, resourceid, runtimeContext: agentRuntimeContext, ...rest } = body;
311
+ const finalResourceId = resourceId ?? resourceid;
312
+ const finalRuntimeContext = new RuntimeContext([
313
+ ...Array.from(runtimeContext.entries()),
314
+ ...Array.from(Object.entries(agentRuntimeContext ?? {}))
315
+ ]);
316
+ validateBody({ messages });
317
+ const result = await agent.generate(messages, {
318
+ ...rest,
319
+ abortSignal,
320
+ // @ts-expect-error TODO fix types
321
+ resourceId: finalResourceId,
322
+ runtimeContext: finalRuntimeContext
323
+ });
324
+ return result;
325
+ } catch (error) {
326
+ return handleError(error, "Error generating from agent");
327
+ }
328
+ }
329
+ async function generateVNextHandler({
330
+ mastra,
331
+ runtimeContext,
332
+ agentId,
333
+ body,
334
+ abortSignal
335
+ }) {
336
+ try {
337
+ const agent = mastra.getAgent(agentId);
338
+ if (!agent) {
339
+ throw new HTTPException(404, { message: "Agent not found" });
340
+ }
341
+ sanitizeBody(body, ["tools"]);
342
+ const { messages, runtimeContext: agentRuntimeContext, ...rest } = body;
343
+ const finalRuntimeContext = new RuntimeContext([
344
+ ...Array.from(runtimeContext.entries()),
345
+ ...Array.from(Object.entries(agentRuntimeContext ?? {}))
346
+ ]);
347
+ validateBody({ messages });
348
+ const result = await agent.generateVNext(messages, {
349
+ ...rest,
350
+ runtimeContext: finalRuntimeContext,
351
+ format: rest.format || "mastra",
352
+ abortSignal
353
+ });
354
+ return result;
355
+ } catch (error) {
356
+ return handleError(error, "Error generating from agent");
357
+ }
358
+ }
359
+ async function streamGenerateHandler({
360
+ mastra,
361
+ ...args
362
+ }) {
363
+ const logger = mastra.getLogger();
364
+ logger?.warn(
365
+ "Deprecation NOTICE:\n Stream method will switch to use streamVNext implementation September 30th, 2025. Please use streamGenerateLegacyHandler if you don't want to upgrade just yet."
366
+ );
367
+ return streamGenerateLegacyHandler({ mastra, ...args });
368
+ }
369
+ async function streamGenerateLegacyHandler({
370
+ mastra,
371
+ runtimeContext,
372
+ agentId,
373
+ body,
374
+ abortSignal
375
+ }) {
376
+ try {
377
+ const agent = mastra.getAgent(agentId);
378
+ if (!agent) {
379
+ throw new HTTPException(404, { message: "Agent not found" });
380
+ }
381
+ const { messages, resourceId, resourceid, runtimeContext: agentRuntimeContext, ...rest } = body;
382
+ const finalResourceId = resourceId ?? resourceid;
383
+ const finalRuntimeContext = new RuntimeContext([
384
+ ...Array.from(runtimeContext.entries()),
385
+ ...Array.from(Object.entries(agentRuntimeContext ?? {}))
386
+ ]);
387
+ validateBody({ messages });
388
+ const streamResult = await agent.stream(messages, {
389
+ ...rest,
390
+ abortSignal,
391
+ // @ts-expect-error TODO fix types
392
+ resourceId: finalResourceId,
393
+ runtimeContext: finalRuntimeContext
394
+ });
395
+ const streamResponse = rest.output ? streamResult.toTextStreamResponse({
396
+ headers: {
397
+ "Transfer-Encoding": "chunked"
398
+ }
399
+ }) : streamResult.toDataStreamResponse({
400
+ sendUsage: true,
401
+ sendReasoning: true,
402
+ getErrorMessage: (error) => {
403
+ return `An error occurred while processing your request. ${error instanceof Error ? error.message : JSON.stringify(error)}`;
404
+ },
405
+ headers: {
406
+ "Transfer-Encoding": "chunked"
407
+ }
408
+ });
409
+ return streamResponse;
410
+ } catch (error) {
411
+ return handleError(error, "error streaming agent response");
412
+ }
413
+ }
414
+ function streamVNextGenerateHandler({
415
+ mastra,
416
+ runtimeContext,
417
+ agentId,
418
+ body,
419
+ abortSignal
420
+ }) {
421
+ try {
422
+ const agent = mastra.getAgent(agentId);
423
+ if (!agent) {
424
+ throw new HTTPException(404, { message: "Agent not found" });
425
+ }
426
+ sanitizeBody(body, ["tools"]);
427
+ const { messages, runtimeContext: agentRuntimeContext, ...rest } = body;
428
+ const finalRuntimeContext = new RuntimeContext([
429
+ ...Array.from(runtimeContext.entries()),
430
+ ...Array.from(Object.entries(agentRuntimeContext ?? {}))
431
+ ]);
432
+ validateBody({ messages });
433
+ const streamResult = agent.streamVNext(messages, {
434
+ ...rest,
435
+ runtimeContext: finalRuntimeContext,
436
+ abortSignal,
437
+ format: body.format ?? "mastra"
438
+ });
439
+ return streamResult;
440
+ } catch (error) {
441
+ return handleError(error, "error streaming agent response");
442
+ }
443
+ }
444
+ function streamNetworkHandler({
445
+ mastra,
446
+ runtimeContext,
447
+ agentId,
448
+ body
449
+ // abortSignal,
450
+ }) {
451
+ try {
452
+ const agent = mastra.getAgent(agentId);
453
+ if (!agent) {
454
+ throw new HTTPException(404, { message: "Agent not found" });
455
+ }
456
+ sanitizeBody(body, ["tools"]);
457
+ const { messages, runtimeContext: agentRuntimeContext, ...rest } = body;
458
+ const finalRuntimeContext = new RuntimeContext([
459
+ ...Array.from(runtimeContext.entries()),
460
+ ...Array.from(Object.entries(agentRuntimeContext ?? {}))
461
+ ]);
462
+ validateBody({ messages });
463
+ const streamResult = agent.network(messages, {
464
+ ...rest,
465
+ memory: {
466
+ thread: rest.thread ?? "",
467
+ resource: rest.resourceId ?? ""
468
+ },
469
+ runtimeContext: finalRuntimeContext
470
+ });
471
+ return streamResult;
472
+ } catch (error) {
473
+ return handleError(error, "error streaming agent loop response");
474
+ }
475
+ }
476
+ async function streamVNextUIMessageHandler({
477
+ mastra,
478
+ runtimeContext,
479
+ agentId,
480
+ body,
481
+ abortSignal
482
+ }) {
483
+ try {
484
+ const agent = mastra.getAgent(agentId);
485
+ if (!agent) {
486
+ throw new HTTPException(404, { message: "Agent not found" });
487
+ }
488
+ sanitizeBody(body, ["tools"]);
489
+ const { messages, runtimeContext: agentRuntimeContext, ...rest } = body;
490
+ const finalRuntimeContext = new RuntimeContext([
491
+ ...Array.from(runtimeContext.entries()),
492
+ ...Array.from(Object.entries(agentRuntimeContext ?? {}))
493
+ ]);
494
+ validateBody({ messages });
495
+ const streamResult = await agent.streamVNext(messages, {
496
+ ...rest,
497
+ runtimeContext: finalRuntimeContext,
498
+ abortSignal,
499
+ format: "aisdk"
500
+ });
501
+ return streamResult.toUIMessageStreamResponse();
502
+ } catch (error) {
503
+ return handleError(error, "error streaming agent response");
504
+ }
505
+ }
506
+ async function updateAgentModelHandler({
507
+ mastra,
508
+ agentId,
509
+ body
510
+ }) {
511
+ try {
512
+ const agent = mastra.getAgent(agentId);
513
+ if (!agent) {
514
+ throw new HTTPException(404, { message: "Agent not found" });
515
+ }
516
+ const agentModel = await agent.getModel();
517
+ const modelVersion = agentModel.specificationVersion;
518
+ const { modelId, provider } = body;
519
+ const providerMap = {
520
+ v1: {
521
+ openai: openai$1(modelId),
522
+ anthropic: anthropic$1(modelId),
523
+ groq: groq$1(modelId),
524
+ xai: xai$1(modelId),
525
+ google: google$1(modelId)
526
+ },
527
+ v2: {
528
+ openai: openai(modelId),
529
+ anthropic: anthropic(modelId),
530
+ groq: groq(modelId),
531
+ xai: xai(modelId),
532
+ google: google(modelId)
533
+ }
534
+ };
535
+ const modelVersionKey = modelVersion === "v2" ? "v2" : "v1";
536
+ const model = providerMap[modelVersionKey][provider];
537
+ agent.__updateModel({ model });
538
+ return { message: "Agent model updated" };
539
+ } catch (error) {
540
+ return handleError(error, "error updating agent model");
541
+ }
542
+ }
543
+ async function reorderAgentModelListHandler({
544
+ mastra,
545
+ agentId,
546
+ body
547
+ }) {
548
+ try {
549
+ const agent = mastra.getAgent(agentId);
550
+ if (!agent) {
551
+ throw new HTTPException(404, { message: "Agent not found" });
552
+ }
553
+ const modelList = await agent.getModelList();
554
+ if (!modelList || modelList.length === 0) {
555
+ throw new HTTPException(400, { message: "Agent model list is not found or empty" });
556
+ }
557
+ agent.reorderModels(body.reorderedModelIds);
558
+ return { message: "Model list reordered" };
559
+ } catch (error) {
560
+ return handleError(error, "error reordering model list");
561
+ }
562
+ }
563
+ async function updateAgentModelInModelListHandler({
564
+ mastra,
565
+ agentId,
566
+ modelConfigId,
567
+ body
568
+ }) {
569
+ try {
570
+ const agent = mastra.getAgent(agentId);
571
+ if (!agent) {
572
+ throw new HTTPException(404, { message: "Agent not found" });
573
+ }
574
+ const { model: bodyModel, maxRetries, enabled } = body;
575
+ if (!modelConfigId) {
576
+ throw new HTTPException(400, { message: "Model id is required" });
577
+ }
578
+ const modelList = await agent.getModelList();
579
+ if (!modelList || modelList.length === 0) {
580
+ throw new HTTPException(400, { message: "Agent model list is not found or empty" });
581
+ }
582
+ const modelToUpdate = modelList.find((m) => m.id === modelConfigId);
583
+ if (!modelToUpdate) {
584
+ throw new HTTPException(400, { message: "Model to update is not found in agent model list" });
585
+ }
586
+ let model;
587
+ if (bodyModel) {
588
+ const { modelId, provider } = bodyModel;
589
+ const providerMap = {
590
+ openai: openai(modelId),
591
+ anthropic: anthropic(modelId),
592
+ groq: groq(modelId),
593
+ xai: xai(modelId),
594
+ google: google(modelId)
595
+ };
596
+ model = providerMap[provider];
597
+ }
598
+ agent.updateModelInModelList({ id: modelConfigId, model, maxRetries, enabled });
599
+ return { message: "Model list updated" };
600
+ } catch (error) {
601
+ return handleError(error, "error updating model list");
602
+ }
603
+ }
604
+
605
+ export { agents_exports, generateHandler, generateLegacyHandler, generateVNextHandler, getAgentByIdHandler, getAgentsHandler, getEvalsByAgentIdHandler, getLiveEvalsByAgentIdHandler, getSerializedAgentTools, reorderAgentModelListHandler, streamGenerateHandler, streamGenerateLegacyHandler, streamNetworkHandler, streamVNextGenerateHandler, streamVNextUIMessageHandler, updateAgentModelHandler, updateAgentModelInModelListHandler };
606
+ //# sourceMappingURL=chunk-BOVFMBXY.js.map
607
+ //# sourceMappingURL=chunk-BOVFMBXY.js.map