@mastra/server 1.33.0-alpha.5 → 1.33.0-alpha.7

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 (339) hide show
  1. package/CHANGELOG.md +159 -0
  2. package/dist/{api-schema-manifest-OBRC34LA.js → api-schema-manifest-JLJ555JD.js} +4 -4
  3. package/dist/{api-schema-manifest-OBRC34LA.js.map → api-schema-manifest-JLJ555JD.js.map} +1 -1
  4. package/dist/{api-schema-manifest-MWMQI6TE.cjs → api-schema-manifest-QMJFKSSQ.cjs} +6 -6
  5. package/dist/{api-schema-manifest-MWMQI6TE.cjs.map → api-schema-manifest-QMJFKSSQ.cjs.map} +1 -1
  6. package/dist/{chunk-EIJLTW5X.js → chunk-2S4WCY5N.js} +4 -4
  7. package/dist/{chunk-EIJLTW5X.js.map → chunk-2S4WCY5N.js.map} +1 -1
  8. package/dist/{chunk-3J5YIIAC.js → chunk-34UYZN53.js} +4 -4
  9. package/dist/{chunk-3J5YIIAC.js.map → chunk-34UYZN53.js.map} +1 -1
  10. package/dist/{chunk-2RX6OJBY.js → chunk-3EK2EVVE.js} +4 -4
  11. package/dist/{chunk-2RX6OJBY.js.map → chunk-3EK2EVVE.js.map} +1 -1
  12. package/dist/{chunk-XKGJU4H3.js → chunk-3OTCA7TP.js} +3 -3
  13. package/dist/{chunk-XKGJU4H3.js.map → chunk-3OTCA7TP.js.map} +1 -1
  14. package/dist/{chunk-LYDIFPB2.js → chunk-4NPFEKIP.js} +4 -4
  15. package/dist/{chunk-LYDIFPB2.js.map → chunk-4NPFEKIP.js.map} +1 -1
  16. package/dist/{chunk-XMHZ4DSE.js → chunk-5FHBVBU2.js} +3 -3
  17. package/dist/{chunk-XMHZ4DSE.js.map → chunk-5FHBVBU2.js.map} +1 -1
  18. package/dist/{chunk-EFW6MWXU.cjs → chunk-5XW4MKE6.cjs} +22 -2
  19. package/dist/chunk-5XW4MKE6.cjs.map +1 -0
  20. package/dist/{chunk-MW23D33F.cjs → chunk-6DAZZPVO.cjs} +38 -38
  21. package/dist/{chunk-MW23D33F.cjs.map → chunk-6DAZZPVO.cjs.map} +1 -1
  22. package/dist/{chunk-D3DCFLTS.js → chunk-6ECVA7WE.js} +3 -3
  23. package/dist/{chunk-D3DCFLTS.js.map → chunk-6ECVA7WE.js.map} +1 -1
  24. package/dist/{chunk-7BXQ2HFG.cjs → chunk-6ICH4PZY.cjs} +16 -16
  25. package/dist/{chunk-7BXQ2HFG.cjs.map → chunk-6ICH4PZY.cjs.map} +1 -1
  26. package/dist/{chunk-MLEUYQFZ.js → chunk-6IR53OXN.js} +4 -4
  27. package/dist/{chunk-MLEUYQFZ.js.map → chunk-6IR53OXN.js.map} +1 -1
  28. package/dist/{chunk-GG537BE6.cjs → chunk-6PJXFSA6.cjs} +77 -77
  29. package/dist/{chunk-GG537BE6.cjs.map → chunk-6PJXFSA6.cjs.map} +1 -1
  30. package/dist/{chunk-64YJOWH2.cjs → chunk-72W42JL4.cjs} +5 -5
  31. package/dist/{chunk-64YJOWH2.cjs.map → chunk-72W42JL4.cjs.map} +1 -1
  32. package/dist/{chunk-DBY645PQ.cjs → chunk-7MXANTMR.cjs} +12 -12
  33. package/dist/{chunk-DBY645PQ.cjs.map → chunk-7MXANTMR.cjs.map} +1 -1
  34. package/dist/{chunk-OMOR5OUN.js → chunk-7QLLMDX3.js} +5 -5
  35. package/dist/{chunk-OMOR5OUN.js.map → chunk-7QLLMDX3.js.map} +1 -1
  36. package/dist/{chunk-27MTROCI.js → chunk-7UMTLDZF.js} +108 -6
  37. package/dist/chunk-7UMTLDZF.js.map +1 -0
  38. package/dist/{chunk-3S77SMGK.js → chunk-7UYUFWJS.js} +44 -44
  39. package/dist/chunk-7UYUFWJS.js.map +1 -0
  40. package/dist/chunk-7Y6MST2S.cjs +636 -0
  41. package/dist/chunk-7Y6MST2S.cjs.map +1 -0
  42. package/dist/{chunk-GWLMGMHI.cjs → chunk-AHKXIRNB.cjs} +145 -117
  43. package/dist/chunk-AHKXIRNB.cjs.map +1 -0
  44. package/dist/{chunk-QICD4OAR.cjs → chunk-AMZMBCKG.cjs} +10 -10
  45. package/dist/{chunk-QICD4OAR.cjs.map → chunk-AMZMBCKG.cjs.map} +1 -1
  46. package/dist/{chunk-XCXGX26I.cjs → chunk-AWXCTLMK.cjs} +11 -11
  47. package/dist/{chunk-XCXGX26I.cjs.map → chunk-AWXCTLMK.cjs.map} +1 -1
  48. package/dist/chunk-B3CHYE7C.js +549 -0
  49. package/dist/chunk-B3CHYE7C.js.map +1 -0
  50. package/dist/{chunk-IQMLYFOO.cjs → chunk-BGRKLLHE.cjs} +6 -6
  51. package/dist/{chunk-IQMLYFOO.cjs.map → chunk-BGRKLLHE.cjs.map} +1 -1
  52. package/dist/{chunk-6ZSBLNO2.cjs → chunk-BLK2XYVU.cjs} +10 -10
  53. package/dist/{chunk-6ZSBLNO2.cjs.map → chunk-BLK2XYVU.cjs.map} +1 -1
  54. package/dist/{chunk-UVLQSMYF.js → chunk-C45QKFMT.js} +40 -38
  55. package/dist/chunk-C45QKFMT.js.map +1 -0
  56. package/dist/{chunk-GI74MHRA.js → chunk-C7Q5IMST.js} +3 -3
  57. package/dist/{chunk-GI74MHRA.js.map → chunk-C7Q5IMST.js.map} +1 -1
  58. package/dist/{chunk-WC3F3EA5.cjs → chunk-CXWOBZOJ.cjs} +18 -18
  59. package/dist/{chunk-WC3F3EA5.cjs.map → chunk-CXWOBZOJ.cjs.map} +1 -1
  60. package/dist/{chunk-UWN75FKT.js → chunk-DXZFPYNO.js} +4 -4
  61. package/dist/{chunk-UWN75FKT.js.map → chunk-DXZFPYNO.js.map} +1 -1
  62. package/dist/{chunk-4OJDWKDW.js → chunk-E55OUW7R.js} +45 -70
  63. package/dist/chunk-E55OUW7R.js.map +1 -0
  64. package/dist/{chunk-TRB4NGQ3.cjs → chunk-E74QCKFN.cjs} +6 -6
  65. package/dist/{chunk-TRB4NGQ3.cjs.map → chunk-E74QCKFN.cjs.map} +1 -1
  66. package/dist/{chunk-D4XVXXDX.js → chunk-EWN5J4RH.js} +7 -7
  67. package/dist/{chunk-D4XVXXDX.js.map → chunk-EWN5J4RH.js.map} +1 -1
  68. package/dist/chunk-F3HP5HM6.cjs +998 -0
  69. package/dist/chunk-F3HP5HM6.cjs.map +1 -0
  70. package/dist/{chunk-BBX7Q7UG.cjs → chunk-FST7LM2Z.cjs} +83 -32
  71. package/dist/chunk-FST7LM2Z.cjs.map +1 -0
  72. package/dist/{chunk-247ZCPZW.js → chunk-GCR6GN77.js} +6 -6
  73. package/dist/{chunk-247ZCPZW.js.map → chunk-GCR6GN77.js.map} +1 -1
  74. package/dist/{chunk-LVWQGVPZ.js → chunk-GKN4IFE7.js} +3 -3
  75. package/dist/{chunk-LVWQGVPZ.js.map → chunk-GKN4IFE7.js.map} +1 -1
  76. package/dist/{chunk-ZMQTGPEU.js → chunk-GP45BMSR.js} +3 -3
  77. package/dist/{chunk-ZMQTGPEU.js.map → chunk-GP45BMSR.js.map} +1 -1
  78. package/dist/{chunk-GDACR4PY.js → chunk-HCIKFLLE.js} +2 -2
  79. package/dist/{chunk-GDACR4PY.js.map → chunk-HCIKFLLE.js.map} +1 -1
  80. package/dist/{chunk-J4FVO25L.cjs → chunk-HFF6QRLL.cjs} +6 -6
  81. package/dist/{chunk-J4FVO25L.cjs.map → chunk-HFF6QRLL.cjs.map} +1 -1
  82. package/dist/{chunk-IUXM3WA2.js → chunk-HLDBO2H6.js} +3 -3
  83. package/dist/{chunk-IUXM3WA2.js.map → chunk-HLDBO2H6.js.map} +1 -1
  84. package/dist/{chunk-767P6IDT.cjs → chunk-HN23LS75.cjs} +147 -147
  85. package/dist/chunk-HN23LS75.cjs.map +1 -0
  86. package/dist/{chunk-HERDIEC2.cjs → chunk-HNV2E454.cjs} +3 -3
  87. package/dist/{chunk-HERDIEC2.cjs.map → chunk-HNV2E454.cjs.map} +1 -1
  88. package/dist/{chunk-7756JXUH.cjs → chunk-HYYXUP35.cjs} +2 -2
  89. package/dist/{chunk-7756JXUH.cjs.map → chunk-HYYXUP35.cjs.map} +1 -1
  90. package/dist/{chunk-P2QL4REX.cjs → chunk-ICJ2ZVI2.cjs} +13 -13
  91. package/dist/{chunk-P2QL4REX.cjs.map → chunk-ICJ2ZVI2.cjs.map} +1 -1
  92. package/dist/{chunk-OSXOHBCO.js → chunk-IJFWBMHN.js} +4 -4
  93. package/dist/{chunk-OSXOHBCO.js.map → chunk-IJFWBMHN.js.map} +1 -1
  94. package/dist/{chunk-UOC4K3RU.js → chunk-JOUPK2UV.js} +3 -3
  95. package/dist/{chunk-UOC4K3RU.js.map → chunk-JOUPK2UV.js.map} +1 -1
  96. package/dist/{chunk-MZFFAVXZ.cjs → chunk-KFEM2S5D.cjs} +10 -10
  97. package/dist/{chunk-MZFFAVXZ.cjs.map → chunk-KFEM2S5D.cjs.map} +1 -1
  98. package/dist/{chunk-6Y4L2O5X.cjs → chunk-KRMMYAXW.cjs} +10 -10
  99. package/dist/{chunk-6Y4L2O5X.cjs.map → chunk-KRMMYAXW.cjs.map} +1 -1
  100. package/dist/{chunk-V67XVMFK.cjs → chunk-KUBAQ732.cjs} +10 -10
  101. package/dist/{chunk-V67XVMFK.cjs.map → chunk-KUBAQ732.cjs.map} +1 -1
  102. package/dist/{chunk-MF6GSHTO.js → chunk-LRYHYARK.js} +4 -4
  103. package/dist/{chunk-MF6GSHTO.js.map → chunk-LRYHYARK.js.map} +1 -1
  104. package/dist/{chunk-IYEGDP3G.js → chunk-M7DF3D2M.js} +3 -3
  105. package/dist/{chunk-IYEGDP3G.js.map → chunk-M7DF3D2M.js.map} +1 -1
  106. package/dist/{chunk-32OIQVBN.cjs → chunk-MAG4W3GZ.cjs} +8 -8
  107. package/dist/{chunk-32OIQVBN.cjs.map → chunk-MAG4W3GZ.cjs.map} +1 -1
  108. package/dist/{chunk-AV3ZGKEA.cjs → chunk-MCS43WKI.cjs} +10 -10
  109. package/dist/{chunk-AV3ZGKEA.cjs.map → chunk-MCS43WKI.cjs.map} +1 -1
  110. package/dist/{chunk-MUMWXLVB.cjs → chunk-MWXGGCHD.cjs} +10 -10
  111. package/dist/{chunk-MUMWXLVB.cjs.map → chunk-MWXGGCHD.cjs.map} +1 -1
  112. package/dist/{chunk-A3SH6O3E.js → chunk-NB7LJMYF.js} +3 -3
  113. package/dist/{chunk-A3SH6O3E.js.map → chunk-NB7LJMYF.js.map} +1 -1
  114. package/dist/{chunk-TZFIX2NI.js → chunk-NWD2SPUH.js} +4 -4
  115. package/dist/{chunk-TZFIX2NI.js.map → chunk-NWD2SPUH.js.map} +1 -1
  116. package/dist/{chunk-RNRF4YCD.cjs → chunk-OAE7ZFYO.cjs} +24 -24
  117. package/dist/{chunk-RNRF4YCD.cjs.map → chunk-OAE7ZFYO.cjs.map} +1 -1
  118. package/dist/{chunk-DWQGAKMB.cjs → chunk-OAWMKZCM.cjs} +11 -11
  119. package/dist/{chunk-DWQGAKMB.cjs.map → chunk-OAWMKZCM.cjs.map} +1 -1
  120. package/dist/{chunk-PALNMAC6.js → chunk-P5H4ILLH.js} +3 -3
  121. package/dist/{chunk-PALNMAC6.js.map → chunk-P5H4ILLH.js.map} +1 -1
  122. package/dist/{chunk-2XNLZANZ.cjs → chunk-PM3UPQWH.cjs} +11 -11
  123. package/dist/{chunk-2XNLZANZ.cjs.map → chunk-PM3UPQWH.cjs.map} +1 -1
  124. package/dist/{chunk-NHQKZEVJ.js → chunk-PX7NE2KG.js} +6 -6
  125. package/dist/{chunk-NHQKZEVJ.js.map → chunk-PX7NE2KG.js.map} +1 -1
  126. package/dist/{chunk-OCFLDDPE.js → chunk-PYT4SLHO.js} +3 -3
  127. package/dist/{chunk-OCFLDDPE.js.map → chunk-PYT4SLHO.js.map} +1 -1
  128. package/dist/{chunk-UP6HQJYH.js → chunk-Q3JFNANT.js} +4 -4
  129. package/dist/{chunk-UP6HQJYH.js.map → chunk-Q3JFNANT.js.map} +1 -1
  130. package/dist/{chunk-S65AMBAF.js → chunk-QJD675UA.js} +83 -32
  131. package/dist/chunk-QJD675UA.js.map +1 -0
  132. package/dist/{chunk-IQAV36GV.js → chunk-RVAPXLP2.js} +3 -3
  133. package/dist/{chunk-IQAV36GV.js.map → chunk-RVAPXLP2.js.map} +1 -1
  134. package/dist/{chunk-I45VWZBS.js → chunk-S4L4CSQD.js} +3 -3
  135. package/dist/{chunk-I45VWZBS.js.map → chunk-S4L4CSQD.js.map} +1 -1
  136. package/dist/{chunk-YCL2MS5R.js → chunk-SOH5VORA.js} +3 -3
  137. package/dist/{chunk-YCL2MS5R.js.map → chunk-SOH5VORA.js.map} +1 -1
  138. package/dist/{chunk-R2ODPDKE.cjs → chunk-SOQKSSPB.cjs} +74 -74
  139. package/dist/{chunk-R2ODPDKE.cjs.map → chunk-SOQKSSPB.cjs.map} +1 -1
  140. package/dist/{chunk-JNIAMBSQ.js → chunk-STNEFHHA.js} +4 -4
  141. package/dist/{chunk-JNIAMBSQ.js.map → chunk-STNEFHHA.js.map} +1 -1
  142. package/dist/{chunk-BQDKIKTT.cjs → chunk-SX3C7B3A.cjs} +28 -28
  143. package/dist/{chunk-BQDKIKTT.cjs.map → chunk-SX3C7B3A.cjs.map} +1 -1
  144. package/dist/{chunk-76TPFVVB.js → chunk-SYDZFUZI.js} +3 -3
  145. package/dist/{chunk-76TPFVVB.js.map → chunk-SYDZFUZI.js.map} +1 -1
  146. package/dist/{chunk-D5H4LH6V.cjs → chunk-T3X7ZXVR.cjs} +168 -64
  147. package/dist/chunk-T3X7ZXVR.cjs.map +1 -0
  148. package/dist/{chunk-N2JR3ER7.cjs → chunk-TFJZGWXX.cjs} +18 -18
  149. package/dist/{chunk-N2JR3ER7.cjs.map → chunk-TFJZGWXX.cjs.map} +1 -1
  150. package/dist/chunk-TLLV2JP5.js +983 -0
  151. package/dist/chunk-TLLV2JP5.js.map +1 -0
  152. package/dist/chunk-TTJ3DYZH.cjs +557 -0
  153. package/dist/chunk-TTJ3DYZH.cjs.map +1 -0
  154. package/dist/{chunk-LWBJ5GUU.cjs → chunk-UMXIU6E3.cjs} +7 -7
  155. package/dist/{chunk-LWBJ5GUU.cjs.map → chunk-UMXIU6E3.cjs.map} +1 -1
  156. package/dist/{chunk-E5BDG6JI.js → chunk-VESPCO5X.js} +3 -3
  157. package/dist/{chunk-E5BDG6JI.js.map → chunk-VESPCO5X.js.map} +1 -1
  158. package/dist/{chunk-BMACQWOU.js → chunk-VGNQKFWM.js} +3 -3
  159. package/dist/{chunk-BMACQWOU.js.map → chunk-VGNQKFWM.js.map} +1 -1
  160. package/dist/{chunk-WYH3OM52.cjs → chunk-VWBVA272.cjs} +5 -5
  161. package/dist/{chunk-WYH3OM52.cjs.map → chunk-VWBVA272.cjs.map} +1 -1
  162. package/dist/{chunk-GTHHWVCO.cjs → chunk-VZV7DUW7.cjs} +13 -13
  163. package/dist/{chunk-GTHHWVCO.cjs.map → chunk-VZV7DUW7.cjs.map} +1 -1
  164. package/dist/{chunk-JX5CEUXO.js → chunk-WE5GUI23.js} +3 -3
  165. package/dist/{chunk-JX5CEUXO.js.map → chunk-WE5GUI23.js.map} +1 -1
  166. package/dist/{chunk-2X3CMUG3.cjs → chunk-WLDDOYXP.cjs} +11 -11
  167. package/dist/{chunk-2X3CMUG3.cjs.map → chunk-WLDDOYXP.cjs.map} +1 -1
  168. package/dist/{chunk-NPNRCLYK.js → chunk-WN62DURP.js} +49 -21
  169. package/dist/chunk-WN62DURP.js.map +1 -0
  170. package/dist/{chunk-AH7FPYBH.cjs → chunk-WYQDPZNZ.cjs} +7 -7
  171. package/dist/{chunk-AH7FPYBH.cjs.map → chunk-WYQDPZNZ.cjs.map} +1 -1
  172. package/dist/{chunk-MOH4DZJP.cjs → chunk-XUFBFMUU.cjs} +71 -96
  173. package/dist/chunk-XUFBFMUU.cjs.map +1 -0
  174. package/dist/{chunk-BK2PRWVJ.cjs → chunk-Y5LNMKEY.cjs} +5 -5
  175. package/dist/{chunk-BK2PRWVJ.cjs.map → chunk-Y5LNMKEY.cjs.map} +1 -1
  176. package/dist/{chunk-OJRAH5VV.js → chunk-YARY4I5U.js} +18 -3
  177. package/dist/chunk-YARY4I5U.js.map +1 -0
  178. package/dist/{chunk-AJV6ZSUS.cjs → chunk-YN57WYLS.cjs} +11 -11
  179. package/dist/{chunk-AJV6ZSUS.cjs.map → chunk-YN57WYLS.cjs.map} +1 -1
  180. package/dist/{chunk-VQMQBGDO.cjs → chunk-YQILRC5Y.cjs} +10 -10
  181. package/dist/{chunk-VQMQBGDO.cjs.map → chunk-YQILRC5Y.cjs.map} +1 -1
  182. package/dist/{chunk-SZOC7JGR.cjs → chunk-Z7FXNI2N.cjs} +52 -52
  183. package/dist/{chunk-SZOC7JGR.cjs.map → chunk-Z7FXNI2N.cjs.map} +1 -1
  184. package/dist/{chunk-ING7J2GB.js → chunk-ZO7SOILM.js} +4 -4
  185. package/dist/{chunk-ING7J2GB.js.map → chunk-ZO7SOILM.js.map} +1 -1
  186. package/dist/{chunk-XOQX6DBB.cjs → chunk-ZOILZWQD.cjs} +6 -6
  187. package/dist/{chunk-XOQX6DBB.cjs.map → chunk-ZOILZWQD.cjs.map} +1 -1
  188. package/dist/{chunk-AN5GEDCI.js → chunk-ZSGVBBC4.js} +3 -3
  189. package/dist/{chunk-AN5GEDCI.js.map → chunk-ZSGVBBC4.js.map} +1 -1
  190. package/dist/{dist-6SY6NNDU.cjs → dist-22O7FBGT.cjs} +30 -30
  191. package/dist/{dist-6SY6NNDU.cjs.map → dist-22O7FBGT.cjs.map} +1 -1
  192. package/dist/{dist-RVKG65AN.js → dist-2APID4CW.js} +3 -3
  193. package/dist/{dist-RVKG65AN.js.map → dist-2APID4CW.js.map} +1 -1
  194. package/dist/{dist-GKNLMW5G.js → dist-3GSFJQXK.js} +3 -3
  195. package/dist/{dist-GKNLMW5G.js.map → dist-3GSFJQXK.js.map} +1 -1
  196. package/dist/{dist-47C5ZLC7.js → dist-7Q7BE2C5.js} +3 -3
  197. package/dist/{dist-47C5ZLC7.js.map → dist-7Q7BE2C5.js.map} +1 -1
  198. package/dist/{dist-IAVEFOC6.cjs → dist-7X6EJANH.cjs} +26 -26
  199. package/dist/{dist-IAVEFOC6.cjs.map → dist-7X6EJANH.cjs.map} +1 -1
  200. package/dist/dist-CC743ARY.cjs +16 -0
  201. package/dist/{dist-S6SWOZKE.cjs.map → dist-CC743ARY.cjs.map} +1 -1
  202. package/dist/{dist-VHDOPJW6.cjs → dist-DGCZK6BK.cjs} +20 -20
  203. package/dist/{dist-VHDOPJW6.cjs.map → dist-DGCZK6BK.cjs.map} +1 -1
  204. package/dist/{dist-BSWYTOHE.js → dist-F77PFLNC.js} +3 -3
  205. package/dist/{dist-BSWYTOHE.js.map → dist-F77PFLNC.js.map} +1 -1
  206. package/dist/{dist-LTT5BP7F.cjs → dist-SPP3XCYT.cjs} +28 -28
  207. package/dist/{dist-LTT5BP7F.cjs.map → dist-SPP3XCYT.cjs.map} +1 -1
  208. package/dist/dist-SPTCWKCU.js +3 -0
  209. package/dist/{dist-KEJZY3UJ.js.map → dist-SPTCWKCU.js.map} +1 -1
  210. package/dist/docs/SKILL.md +1 -1
  211. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  212. package/dist/{observational-memory-KH7G7Y6B-Y3XQXW3K.cjs → observational-memory-IP2RVQQG-5IHDRYAB.cjs} +26 -26
  213. package/dist/{observational-memory-KH7G7Y6B-Y3XQXW3K.cjs.map → observational-memory-IP2RVQQG-5IHDRYAB.cjs.map} +1 -1
  214. package/dist/{observational-memory-KH7G7Y6B-QKEOJZME.js → observational-memory-IP2RVQQG-DIZILT73.js} +3 -3
  215. package/dist/{observational-memory-KH7G7Y6B-QKEOJZME.js.map → observational-memory-IP2RVQQG-DIZILT73.js.map} +1 -1
  216. package/dist/server/auth/index.cjs +15 -15
  217. package/dist/server/auth/index.js +1 -1
  218. package/dist/server/constants.d.ts +5 -0
  219. package/dist/server/constants.d.ts.map +1 -1
  220. package/dist/server/handlers/a2a.cjs +14 -14
  221. package/dist/server/handlers/a2a.js +1 -1
  222. package/dist/server/handlers/agent-builder.cjs +16 -16
  223. package/dist/server/handlers/agent-builder.js +1 -1
  224. package/dist/server/handlers/agent-versions.cjs +8 -8
  225. package/dist/server/handlers/agent-versions.js +1 -1
  226. package/dist/server/handlers/agents.cjs +39 -39
  227. package/dist/server/handlers/agents.d.ts.map +1 -1
  228. package/dist/server/handlers/agents.js +1 -1
  229. package/dist/server/handlers/auth.cjs +11 -11
  230. package/dist/server/handlers/auth.js +1 -1
  231. package/dist/server/handlers/background-tasks.cjs +4 -4
  232. package/dist/server/handlers/background-tasks.js +1 -1
  233. package/dist/server/handlers/channels.cjs +5 -5
  234. package/dist/server/handlers/channels.js +1 -1
  235. package/dist/server/handlers/conversations.cjs +5 -5
  236. package/dist/server/handlers/conversations.js +1 -1
  237. package/dist/server/handlers/datasets.cjs +26 -26
  238. package/dist/server/handlers/datasets.js +1 -1
  239. package/dist/server/handlers/logs.cjs +4 -4
  240. package/dist/server/handlers/logs.js +1 -1
  241. package/dist/server/handlers/mcp-client-versions.cjs +8 -8
  242. package/dist/server/handlers/mcp-client-versions.js +1 -1
  243. package/dist/server/handlers/mcp.cjs +11 -11
  244. package/dist/server/handlers/mcp.js +1 -1
  245. package/dist/server/handlers/memory.cjs +27 -27
  246. package/dist/server/handlers/memory.js +1 -1
  247. package/dist/server/handlers/observability-new-endpoints.cjs +28 -28
  248. package/dist/server/handlers/observability-new-endpoints.js +1 -1
  249. package/dist/server/handlers/observability.cjs +38 -38
  250. package/dist/server/handlers/observability.js +2 -2
  251. package/dist/server/handlers/processor-providers.cjs +3 -3
  252. package/dist/server/handlers/processor-providers.js +1 -1
  253. package/dist/server/handlers/processors.cjs +4 -4
  254. package/dist/server/handlers/processors.js +1 -1
  255. package/dist/server/handlers/prompt-block-versions.cjs +8 -8
  256. package/dist/server/handlers/prompt-block-versions.js +1 -1
  257. package/dist/server/handlers/responses.adapter.cjs +18 -14
  258. package/dist/server/handlers/responses.adapter.d.ts +96 -2
  259. package/dist/server/handlers/responses.adapter.d.ts.map +1 -1
  260. package/dist/server/handlers/responses.adapter.js +1 -1
  261. package/dist/server/handlers/responses.cjs +4 -4
  262. package/dist/server/handlers/responses.d.ts.map +1 -1
  263. package/dist/server/handlers/responses.js +1 -1
  264. package/dist/server/handlers/responses.storage.cjs +8 -8
  265. package/dist/server/handlers/responses.storage.d.ts +4 -2
  266. package/dist/server/handlers/responses.storage.d.ts.map +1 -1
  267. package/dist/server/handlers/responses.storage.js +1 -1
  268. package/dist/server/handlers/schedules.cjs +6 -6
  269. package/dist/server/handlers/schedules.js +1 -1
  270. package/dist/server/handlers/scorer-versions.cjs +8 -8
  271. package/dist/server/handlers/scorer-versions.js +1 -1
  272. package/dist/server/handlers/scores.cjs +7 -7
  273. package/dist/server/handlers/scores.js +1 -1
  274. package/dist/server/handlers/stored-agents.cjs +7 -7
  275. package/dist/server/handlers/stored-agents.js +1 -1
  276. package/dist/server/handlers/stored-mcp-clients.cjs +6 -6
  277. package/dist/server/handlers/stored-mcp-clients.js +1 -1
  278. package/dist/server/handlers/stored-prompt-blocks.cjs +6 -6
  279. package/dist/server/handlers/stored-prompt-blocks.js +1 -1
  280. package/dist/server/handlers/stored-scorers.cjs +6 -6
  281. package/dist/server/handlers/stored-scorers.js +1 -1
  282. package/dist/server/handlers/stored-skills.cjs +7 -7
  283. package/dist/server/handlers/stored-skills.js +1 -1
  284. package/dist/server/handlers/stored-workspaces.cjs +6 -6
  285. package/dist/server/handlers/stored-workspaces.js +1 -1
  286. package/dist/server/handlers/system.cjs +3 -3
  287. package/dist/server/handlers/system.js +1 -1
  288. package/dist/server/handlers/tool-providers.cjs +5 -5
  289. package/dist/server/handlers/tool-providers.js +1 -1
  290. package/dist/server/handlers/tools.cjs +6 -6
  291. package/dist/server/handlers/tools.js +1 -1
  292. package/dist/server/handlers/utils.cjs +10 -10
  293. package/dist/server/handlers/utils.js +1 -1
  294. package/dist/server/handlers/vector.cjs +16 -16
  295. package/dist/server/handlers/vector.js +1 -1
  296. package/dist/server/handlers/voice.cjs +8 -8
  297. package/dist/server/handlers/voice.js +1 -1
  298. package/dist/server/handlers/workflows.cjs +32 -24
  299. package/dist/server/handlers/workflows.d.ts +83 -0
  300. package/dist/server/handlers/workflows.d.ts.map +1 -1
  301. package/dist/server/handlers/workflows.js +1 -1
  302. package/dist/server/handlers/workspace.cjs +26 -26
  303. package/dist/server/handlers/workspace.js +1 -1
  304. package/dist/server/handlers.cjs +30 -30
  305. package/dist/server/handlers.js +15 -15
  306. package/dist/server/server-adapter/index.cjs +55 -28
  307. package/dist/server/server-adapter/index.cjs.map +1 -1
  308. package/dist/server/server-adapter/index.d.ts +5 -1
  309. package/dist/server/server-adapter/index.d.ts.map +1 -1
  310. package/dist/server/server-adapter/index.js +19 -11
  311. package/dist/server/server-adapter/index.js.map +1 -1
  312. package/dist/server/server-adapter/routes/workflows.d.ts +66 -1
  313. package/dist/server/server-adapter/routes/workflows.d.ts.map +1 -1
  314. package/package.json +6 -6
  315. package/dist/chunk-27MTROCI.js.map +0 -1
  316. package/dist/chunk-3S77SMGK.js.map +0 -1
  317. package/dist/chunk-4OJDWKDW.js.map +0 -1
  318. package/dist/chunk-767P6IDT.cjs.map +0 -1
  319. package/dist/chunk-AJYJ4H7P.js +0 -438
  320. package/dist/chunk-AJYJ4H7P.js.map +0 -1
  321. package/dist/chunk-BBX7Q7UG.cjs.map +0 -1
  322. package/dist/chunk-D5H4LH6V.cjs.map +0 -1
  323. package/dist/chunk-DFSUBEGE.js +0 -226
  324. package/dist/chunk-DFSUBEGE.js.map +0 -1
  325. package/dist/chunk-EFW6MWXU.cjs.map +0 -1
  326. package/dist/chunk-GWLMGMHI.cjs.map +0 -1
  327. package/dist/chunk-MOH4DZJP.cjs.map +0 -1
  328. package/dist/chunk-NPNRCLYK.js.map +0 -1
  329. package/dist/chunk-OJ72T77G.cjs +0 -452
  330. package/dist/chunk-OJ72T77G.cjs.map +0 -1
  331. package/dist/chunk-OJRAH5VV.js.map +0 -1
  332. package/dist/chunk-PJYQMPXT.cjs +0 -234
  333. package/dist/chunk-PJYQMPXT.cjs.map +0 -1
  334. package/dist/chunk-S65AMBAF.js.map +0 -1
  335. package/dist/chunk-UVLQSMYF.js.map +0 -1
  336. package/dist/chunk-Y5FNAVOR.cjs +0 -634
  337. package/dist/chunk-Y5FNAVOR.cjs.map +0 -1
  338. package/dist/dist-KEJZY3UJ.js +0 -3
  339. package/dist/dist-S6SWOZKE.cjs +0 -16
@@ -0,0 +1,983 @@
1
+ import { randomUUID } from 'crypto';
2
+ import { isProviderDefinedTool } from '@mastra/core/tools';
3
+ import { zodToJsonSchema } from '@mastra/core/utils/zod-to-json';
4
+
5
+ // src/server/handlers/responses.adapter.ts
6
+ function normalizeMessageContent(content) {
7
+ if (typeof content === "string") {
8
+ return content;
9
+ }
10
+ return content.map((part) => part.text).join("");
11
+ }
12
+ function getMessageText(message) {
13
+ const parts = Array.isArray(message.content?.parts) ? message.content.parts : [];
14
+ return parts.flatMap((part) => part.type === "text" ? [part.text] : []).filter((text) => typeof text === "string").join("");
15
+ }
16
+ function isRecord(value) {
17
+ return typeof value === "object" && value !== null && !Array.isArray(value);
18
+ }
19
+ function getMessageRole(message) {
20
+ return message.role ?? "";
21
+ }
22
+ function getToolKey(toolCallId, messageId, partIndex) {
23
+ return `${messageId}:${partIndex}`;
24
+ }
25
+ function getFunctionCallOutputItemId(toolCallId) {
26
+ return `${toolCallId}:output`;
27
+ }
28
+ function normalizeToolParameters(schema) {
29
+ if (!isRecord(schema)) {
30
+ return schema;
31
+ }
32
+ if (isRecord(schema.json) && Object.keys(schema).length === 1) {
33
+ return schema.json;
34
+ }
35
+ return schema;
36
+ }
37
+ function mapMastraToolsToResponseTools(tools) {
38
+ if (!tools) {
39
+ return [];
40
+ }
41
+ return Object.values(tools).flatMap((tool) => {
42
+ if (!isRecord(tool)) {
43
+ return [];
44
+ }
45
+ const name = typeof tool.id === "string" ? tool.id : typeof tool.name === "string" ? tool.name : null;
46
+ if (!name) {
47
+ return [];
48
+ }
49
+ const description = typeof tool.description === "string" ? tool.description : void 0;
50
+ let parameters;
51
+ if (isProviderDefinedTool(tool)) {
52
+ const resolvedSchema = typeof tool.inputSchema === "function" ? tool.inputSchema() : tool.inputSchema;
53
+ parameters = isRecord(resolvedSchema) && "jsonSchema" in resolvedSchema ? normalizeToolParameters(resolvedSchema.jsonSchema) : void 0;
54
+ } else if ("inputSchema" in tool && tool.inputSchema) {
55
+ parameters = normalizeToolParameters(zodToJsonSchema(tool.inputSchema));
56
+ }
57
+ return [
58
+ {
59
+ type: "function",
60
+ name,
61
+ ...description ? { description } : {},
62
+ ...parameters !== void 0 ? { parameters: JSON.parse(JSON.stringify(parameters)) } : {}
63
+ }
64
+ ];
65
+ });
66
+ }
67
+ function stringifyToolPayload(value) {
68
+ if (typeof value === "string") {
69
+ return value;
70
+ }
71
+ return JSON.stringify(value === void 0 ? {} : value);
72
+ }
73
+ function stringifyToolArguments(value) {
74
+ if (isRecord(value) && typeof value.__raw === "string") {
75
+ return value.__raw;
76
+ }
77
+ return stringifyToolPayload(value === null ? void 0 : value);
78
+ }
79
+ function createOutputMessage({
80
+ messageId,
81
+ status,
82
+ text
83
+ }) {
84
+ const responseStatus = status === "completed" ? "completed" : "incomplete";
85
+ return {
86
+ id: messageId,
87
+ type: "message",
88
+ role: "assistant",
89
+ status: responseStatus,
90
+ content: [createOutputTextPart(text)]
91
+ };
92
+ }
93
+ function createConversationMessage({
94
+ messageId,
95
+ role,
96
+ text
97
+ }) {
98
+ return {
99
+ id: messageId,
100
+ type: "message",
101
+ role,
102
+ status: "completed",
103
+ content: [
104
+ role === "assistant" ? createOutputTextPart(text) : {
105
+ type: "input_text",
106
+ text
107
+ }
108
+ ]
109
+ };
110
+ }
111
+ function createFunctionCallItem({
112
+ itemId,
113
+ callId,
114
+ name,
115
+ args
116
+ }) {
117
+ return {
118
+ id: itemId,
119
+ type: "function_call",
120
+ call_id: callId,
121
+ name,
122
+ arguments: stringifyToolArguments(args),
123
+ status: "completed"
124
+ };
125
+ }
126
+ function createFunctionCallOutputItem({ itemId, callId, output }) {
127
+ return {
128
+ id: itemId,
129
+ type: "function_call_output",
130
+ call_id: callId,
131
+ output: stringifyToolPayload(output)
132
+ };
133
+ }
134
+ function collectToolResultCallIds(messages) {
135
+ const toolResultCallIds = /* @__PURE__ */ new Set();
136
+ for (const message of messages) {
137
+ const parts = Array.isArray(message.content?.parts) ? message.content.parts : [];
138
+ for (const [partIndex, part] of parts.entries()) {
139
+ if (!isRecord(part) || part.type !== "tool-invocation" || !isRecord(part.toolInvocation)) {
140
+ continue;
141
+ }
142
+ const toolInvocation = part.toolInvocation;
143
+ const toolCallId = typeof toolInvocation.toolCallId === "string" ? toolInvocation.toolCallId : getToolKey(null, message.id, partIndex);
144
+ if (getMessageRole(message) === "tool" && toolInvocation.result !== void 0) {
145
+ toolResultCallIds.add(toolCallId);
146
+ }
147
+ }
148
+ }
149
+ return toolResultCallIds;
150
+ }
151
+ function mapMastraMessageToResponseToolItems({
152
+ message,
153
+ toolResultCallIds,
154
+ emittedCallIds,
155
+ emittedResultCallIds
156
+ }) {
157
+ const items = [];
158
+ const parts = Array.isArray(message.content?.parts) ? message.content.parts : [];
159
+ for (const [partIndex, part] of parts.entries()) {
160
+ if (!isRecord(part) || part.type !== "tool-invocation" || !isRecord(part.toolInvocation)) {
161
+ continue;
162
+ }
163
+ const toolInvocation = part.toolInvocation;
164
+ const toolName = typeof toolInvocation.toolName === "string" ? toolInvocation.toolName : null;
165
+ const toolCallId = typeof toolInvocation.toolCallId === "string" ? toolInvocation.toolCallId : getToolKey(null, message.id, partIndex);
166
+ if (getMessageRole(message) === "assistant" && toolName && !emittedCallIds.has(toolCallId)) {
167
+ items.push(
168
+ createFunctionCallItem({
169
+ itemId: toolCallId,
170
+ callId: toolCallId,
171
+ name: toolName,
172
+ args: toolInvocation.args
173
+ })
174
+ );
175
+ emittedCallIds.add(toolCallId);
176
+ }
177
+ if (toolInvocation.result !== void 0 && !emittedResultCallIds.has(toolCallId) && (getMessageRole(message) === "tool" || !toolResultCallIds.has(toolCallId))) {
178
+ items.push(
179
+ createFunctionCallOutputItem({
180
+ itemId: getFunctionCallOutputItemId(toolCallId),
181
+ callId: toolCallId,
182
+ output: toolInvocation.result
183
+ })
184
+ );
185
+ emittedResultCallIds.add(toolCallId);
186
+ }
187
+ }
188
+ return items;
189
+ }
190
+ function mapMastraMessagesToConversationItems(messages) {
191
+ if (!messages.length) {
192
+ return [];
193
+ }
194
+ const items = [];
195
+ const toolResultCallIds = collectToolResultCallIds(messages);
196
+ const emittedCallIds = /* @__PURE__ */ new Set();
197
+ const emittedResultCallIds = /* @__PURE__ */ new Set();
198
+ for (const message of messages) {
199
+ items.push(
200
+ ...mapMastraMessageToResponseToolItems({
201
+ message,
202
+ toolResultCallIds,
203
+ emittedCallIds,
204
+ emittedResultCallIds
205
+ })
206
+ );
207
+ const role = getMessageRole(message);
208
+ const text = getMessageText(message);
209
+ if ((role === "user" || role === "system" || role === "assistant") && text) {
210
+ items.push(
211
+ createConversationMessage({
212
+ messageId: message.id,
213
+ role,
214
+ text
215
+ })
216
+ );
217
+ continue;
218
+ }
219
+ if (role === "assistant" && !text) {
220
+ const parts = Array.isArray(message.content?.parts) ? message.content.parts : [];
221
+ const hasOnlyToolInvocations = parts.every(
222
+ (part) => isRecord(part) && part.type === "tool-invocation" && isRecord(part.toolInvocation)
223
+ );
224
+ if (hasOnlyToolInvocations) {
225
+ continue;
226
+ }
227
+ }
228
+ if (role === "tool") {
229
+ continue;
230
+ }
231
+ }
232
+ return items;
233
+ }
234
+ function mergeFallbackOutputItems({
235
+ output,
236
+ fallbackOutputItems
237
+ }) {
238
+ if (!fallbackOutputItems.length) {
239
+ return output;
240
+ }
241
+ const outputById = new Map(output.map((item) => [item.id, item]));
242
+ const fallbackIds = new Set(fallbackOutputItems.map((item) => item.id));
243
+ return [
244
+ ...fallbackOutputItems.map((item) => outputById.get(item.id) ?? item),
245
+ ...output.filter((item) => !fallbackIds.has(item.id))
246
+ ];
247
+ }
248
+ function getOutputMessageText(item) {
249
+ return item.content.map((part) => part.text).join("");
250
+ }
251
+ function mapMastraMessagesToResponseOutputItems({
252
+ messages,
253
+ outputMessageId,
254
+ status,
255
+ fallbackText,
256
+ fallbackOutputItems = []
257
+ }) {
258
+ if (!messages?.length) {
259
+ if (fallbackOutputItems.length) {
260
+ return fallbackOutputItems;
261
+ }
262
+ return [createOutputMessage({ messageId: outputMessageId, status, text: fallbackText })];
263
+ }
264
+ const output = [];
265
+ const lastAssistantIndex = [...messages].map((message) => message.role).lastIndexOf("assistant");
266
+ const outputMessageIndex = [...messages].map((message, index) => ({ index, message })).reverse().find(({ message }) => getMessageRole(message) === "assistant" && getMessageText(message))?.index ?? lastAssistantIndex;
267
+ const toolResultCallIds = collectToolResultCallIds(messages);
268
+ const emittedCallIds = /* @__PURE__ */ new Set();
269
+ const emittedResultCallIds = /* @__PURE__ */ new Set();
270
+ const fallbackMessageItems = fallbackOutputItems.filter(
271
+ (item) => item.type === "message"
272
+ );
273
+ const emittedFallbackMessageIds = /* @__PURE__ */ new Set();
274
+ const getOutputMessageId = ({
275
+ message,
276
+ text,
277
+ useOutputMessageId
278
+ }) => {
279
+ const directFallbackItem = fallbackMessageItems.find((item) => item.id === message.id);
280
+ if (directFallbackItem) {
281
+ emittedFallbackMessageIds.add(directFallbackItem.id);
282
+ return directFallbackItem.id;
283
+ }
284
+ if (useOutputMessageId) {
285
+ const matchingFallbackItem = fallbackMessageItems.find(
286
+ (item) => item.id !== outputMessageId && !emittedFallbackMessageIds.has(item.id) && getOutputMessageText(item) === text
287
+ );
288
+ if (matchingFallbackItem) {
289
+ emittedFallbackMessageIds.add(matchingFallbackItem.id);
290
+ return matchingFallbackItem.id;
291
+ }
292
+ }
293
+ return useOutputMessageId ? outputMessageId : message.id;
294
+ };
295
+ for (const [messageIndex, message] of messages.entries()) {
296
+ output.push(
297
+ ...mapMastraMessageToResponseToolItems({
298
+ message,
299
+ toolResultCallIds,
300
+ emittedCallIds,
301
+ emittedResultCallIds
302
+ })
303
+ );
304
+ const text = getMessageText(message);
305
+ if (getMessageRole(message) === "assistant" && text) {
306
+ const useOutputMessageId = messageIndex === outputMessageIndex;
307
+ output.push(
308
+ createOutputMessage({
309
+ messageId: getOutputMessageId({ message, text, useOutputMessageId }),
310
+ status,
311
+ text
312
+ })
313
+ );
314
+ }
315
+ }
316
+ if (!output.some((item) => item.type === "message") && fallbackText) {
317
+ output.push(createOutputMessage({ messageId: outputMessageId, status, text: fallbackText }));
318
+ }
319
+ return mergeFallbackOutputItems({ output, fallbackOutputItems });
320
+ }
321
+ function createMessageId() {
322
+ return `msg_${randomUUID()}`;
323
+ }
324
+ function mapResponseInputToExecutionMessages(input) {
325
+ if (typeof input === "string") {
326
+ return [{ role: "user", content: input }];
327
+ }
328
+ return input.map((message) => ({
329
+ role: message.role === "developer" ? "system" : message.role,
330
+ content: normalizeMessageContent(message.content)
331
+ }));
332
+ }
333
+ function toResponseUsage(usage) {
334
+ if (!usage) {
335
+ return null;
336
+ }
337
+ const inputTokens = usage.inputTokens ?? usage.promptTokens ?? 0;
338
+ const outputTokens = usage.outputTokens ?? usage.completionTokens ?? 0;
339
+ const totalTokens = usage.totalTokens ?? inputTokens + outputTokens;
340
+ return {
341
+ input_tokens: inputTokens,
342
+ output_tokens: outputTokens,
343
+ total_tokens: totalTokens,
344
+ input_tokens_details: {
345
+ cached_tokens: 0
346
+ },
347
+ output_tokens_details: {
348
+ reasoning_tokens: 0
349
+ }
350
+ };
351
+ }
352
+ function toResponseStatus(finishReason) {
353
+ if (finishReason === "suspended" || finishReason === "error") {
354
+ return "incomplete";
355
+ }
356
+ return "completed";
357
+ }
358
+ function createOutputTextPart(text) {
359
+ return {
360
+ type: "output_text",
361
+ text,
362
+ annotations: [],
363
+ logprobs: []
364
+ };
365
+ }
366
+ function buildCompletedResponse({
367
+ responseId,
368
+ outputMessageId,
369
+ model,
370
+ createdAt,
371
+ completedAt,
372
+ status,
373
+ text,
374
+ usage,
375
+ instructions,
376
+ textConfig,
377
+ previousResponseId,
378
+ conversationId,
379
+ providerOptions,
380
+ tools,
381
+ store,
382
+ messages,
383
+ fallbackOutputItems
384
+ }) {
385
+ return {
386
+ id: responseId,
387
+ object: "response",
388
+ created_at: createdAt,
389
+ completed_at: completedAt,
390
+ model,
391
+ status,
392
+ output: mapMastraMessagesToResponseOutputItems({
393
+ messages,
394
+ outputMessageId,
395
+ status,
396
+ fallbackText: text,
397
+ fallbackOutputItems
398
+ }),
399
+ usage: toResponseUsage(usage),
400
+ error: null,
401
+ incomplete_details: null,
402
+ instructions: instructions ?? null,
403
+ text: textConfig ?? null,
404
+ previous_response_id: previousResponseId ?? null,
405
+ conversation_id: conversationId ?? null,
406
+ providerOptions,
407
+ tools,
408
+ store
409
+ };
410
+ }
411
+ function buildInProgressResponse({
412
+ responseId,
413
+ model,
414
+ createdAt,
415
+ instructions,
416
+ textConfig,
417
+ previousResponseId,
418
+ conversationId,
419
+ tools,
420
+ store
421
+ }) {
422
+ return {
423
+ id: responseId,
424
+ object: "response",
425
+ created_at: createdAt,
426
+ completed_at: null,
427
+ model,
428
+ status: "in_progress",
429
+ output: [],
430
+ usage: null,
431
+ error: null,
432
+ incomplete_details: null,
433
+ instructions: instructions ?? null,
434
+ text: textConfig ?? null,
435
+ previous_response_id: previousResponseId ?? null,
436
+ conversation_id: conversationId ?? null,
437
+ tools: tools ?? [],
438
+ store
439
+ };
440
+ }
441
+ function mapResponseTurnRecordToResponse(match) {
442
+ return {
443
+ id: match.message.id,
444
+ object: "response",
445
+ created_at: match.metadata.createdAt,
446
+ completed_at: match.metadata.completedAt,
447
+ model: match.metadata.model,
448
+ status: match.metadata.status,
449
+ output: mapMastraMessagesToResponseOutputItems({
450
+ messages: match.messages,
451
+ outputMessageId: match.message.id,
452
+ status: match.metadata.status,
453
+ fallbackText: getMessageText(match.message),
454
+ fallbackOutputItems: match.metadata.outputItems
455
+ }),
456
+ usage: match.metadata.usage,
457
+ error: null,
458
+ incomplete_details: null,
459
+ instructions: match.metadata.instructions ?? null,
460
+ text: match.metadata.text ?? null,
461
+ previous_response_id: match.metadata.previousResponseId ?? null,
462
+ conversation_id: match.thread.id,
463
+ providerOptions: match.metadata.providerOptions,
464
+ tools: match.metadata.tools,
465
+ store: match.metadata.store
466
+ };
467
+ }
468
+ function formatSseEvent(event, data) {
469
+ return new TextEncoder().encode(`event: ${event}
470
+ data: ${JSON.stringify(data)}
471
+
472
+ `);
473
+ }
474
+ function extractTextDelta(value) {
475
+ if (typeof value !== "object" || value === null || !("type" in value)) {
476
+ return null;
477
+ }
478
+ const chunk = value;
479
+ switch (chunk.type) {
480
+ case "text-delta":
481
+ if (typeof chunk.payload?.text === "string") {
482
+ return chunk.payload.text;
483
+ }
484
+ if (typeof chunk.textDelta === "string") {
485
+ return chunk.textDelta;
486
+ }
487
+ if (typeof chunk.text === "string") {
488
+ return chunk.text;
489
+ }
490
+ return null;
491
+ default:
492
+ return null;
493
+ }
494
+ }
495
+ function createResponseSseEvent(payload) {
496
+ return { event: payload.type, payload };
497
+ }
498
+ function getChunkPayload(value) {
499
+ if (!isRecord(value)) {
500
+ return null;
501
+ }
502
+ return isRecord(value.payload) ? value.payload : value;
503
+ }
504
+ function stringifyResponsePayload(value) {
505
+ if (typeof value === "string") {
506
+ return value;
507
+ }
508
+ return JSON.stringify(value === void 0 ? {} : value);
509
+ }
510
+ function stringifyFunctionCallArguments(value, fallback = "") {
511
+ const serialized = value === void 0 || value === null ? fallback : stringifyResponsePayload(value);
512
+ return serialized || fallback || "{}";
513
+ }
514
+ function removeWhitespaceOutsideJsonStrings(value) {
515
+ let inString = false;
516
+ let escaped = false;
517
+ let result = "";
518
+ for (const char of value) {
519
+ if (escaped) {
520
+ escaped = false;
521
+ result += char;
522
+ continue;
523
+ }
524
+ if (char === "\\" && inString) {
525
+ escaped = true;
526
+ result += char;
527
+ continue;
528
+ }
529
+ if (char === '"') {
530
+ inString = !inString;
531
+ result += char;
532
+ continue;
533
+ }
534
+ if (!inString && /\s/.test(char)) {
535
+ continue;
536
+ }
537
+ result += char;
538
+ }
539
+ return result;
540
+ }
541
+ function getRemainingArgumentsDelta(current, canonical) {
542
+ if (!current) {
543
+ return canonical;
544
+ }
545
+ if (canonical.startsWith(current)) {
546
+ return canonical.slice(current.length);
547
+ }
548
+ const compactCurrent = removeWhitespaceOutsideJsonStrings(current);
549
+ const compactCanonical = removeWhitespaceOutsideJsonStrings(canonical);
550
+ if (compactCurrent && compactCanonical.startsWith(compactCurrent)) {
551
+ return compactCanonical.slice(compactCurrent.length);
552
+ }
553
+ return null;
554
+ }
555
+ function isCompleteJsonString(value) {
556
+ if (!value) {
557
+ return true;
558
+ }
559
+ try {
560
+ JSON.parse(value);
561
+ return true;
562
+ } catch {
563
+ return false;
564
+ }
565
+ }
566
+ function serializeToolError(error) {
567
+ if (error instanceof Error) {
568
+ return { error: error.message };
569
+ }
570
+ return { error };
571
+ }
572
+ function getToolCallStart(value) {
573
+ if (!isRecord(value) || value.type !== "tool-call-input-streaming-start") {
574
+ return null;
575
+ }
576
+ const payload = getChunkPayload(value);
577
+ const toolCallId = payload?.toolCallId;
578
+ const toolName = payload?.toolName;
579
+ if (typeof toolCallId !== "string" || typeof toolName !== "string") {
580
+ return null;
581
+ }
582
+ return { toolCallId, toolName };
583
+ }
584
+ function getToolCallDelta(value) {
585
+ if (!isRecord(value) || value.type !== "tool-call-delta") {
586
+ return null;
587
+ }
588
+ const payload = getChunkPayload(value);
589
+ const toolCallId = payload?.toolCallId;
590
+ const delta = payload?.argsTextDelta ?? payload?.inputTextDelta ?? payload?.argsDelta ?? payload?.delta;
591
+ if (!payload || typeof toolCallId !== "string" || typeof delta !== "string") {
592
+ return null;
593
+ }
594
+ return {
595
+ toolCallId,
596
+ toolName: typeof payload.toolName === "string" ? payload.toolName : void 0,
597
+ delta
598
+ };
599
+ }
600
+ function getToolCall(value) {
601
+ if (!isRecord(value) || value.type !== "tool-call") {
602
+ return null;
603
+ }
604
+ const payload = getChunkPayload(value);
605
+ const toolCallId = payload?.toolCallId;
606
+ const toolName = payload?.toolName;
607
+ const args = payload?.args ?? payload?.input;
608
+ if (typeof toolCallId !== "string" || typeof toolName !== "string") {
609
+ return null;
610
+ }
611
+ return { toolCallId, toolName, args };
612
+ }
613
+ function getToolCallEnd(value) {
614
+ if (!isRecord(value) || value.type !== "tool-call-input-streaming-end") {
615
+ return null;
616
+ }
617
+ const payload = getChunkPayload(value);
618
+ const toolCallId = payload?.toolCallId;
619
+ if (typeof toolCallId !== "string") {
620
+ return null;
621
+ }
622
+ return { toolCallId };
623
+ }
624
+ function getToolResult(value) {
625
+ if (!isRecord(value) || value.type !== "tool-result" && value.type !== "tool-error") {
626
+ return null;
627
+ }
628
+ const payload = getChunkPayload(value);
629
+ const toolCallId = payload?.toolCallId;
630
+ if (!payload || typeof toolCallId !== "string") {
631
+ return null;
632
+ }
633
+ const toolName = typeof payload.toolName === "string" ? payload.toolName : void 0;
634
+ const args = payload.args ?? payload.input;
635
+ if (value.type === "tool-error") {
636
+ return { toolCallId, toolName, args, result: serializeToolError(payload.error) };
637
+ }
638
+ const outputValue = payload.result !== void 0 ? payload.result : payload.output;
639
+ const result = payload.isError ? serializeToolError(outputValue) : outputValue;
640
+ return { toolCallId, toolName, args, result };
641
+ }
642
+ function createResponseStreamEventTranslator(responseId) {
643
+ let text = "";
644
+ let nextOutputIndex = 0;
645
+ let textOutputIndex = null;
646
+ const completedToolResultCallIds = /* @__PURE__ */ new Set();
647
+ const pendingToolResults = /* @__PURE__ */ new Map();
648
+ const toolCalls = /* @__PURE__ */ new Map();
649
+ const outputItems = /* @__PURE__ */ new Map();
650
+ const ensureTextOutputItem = () => {
651
+ if (textOutputIndex !== null) {
652
+ return { events: [], outputIndex: textOutputIndex };
653
+ }
654
+ textOutputIndex = nextOutputIndex++;
655
+ return {
656
+ outputIndex: textOutputIndex,
657
+ events: [
658
+ createResponseSseEvent({
659
+ type: "response.output_item.added",
660
+ output_index: textOutputIndex,
661
+ item: {
662
+ id: responseId,
663
+ type: "message",
664
+ role: "assistant",
665
+ status: "in_progress",
666
+ content: []
667
+ }
668
+ }),
669
+ createResponseSseEvent({
670
+ type: "response.content_part.added",
671
+ output_index: textOutputIndex,
672
+ content_index: 0,
673
+ item_id: responseId,
674
+ part: createOutputTextPart("")
675
+ })
676
+ ]
677
+ };
678
+ };
679
+ const ensureToolCallItem = ({
680
+ toolCallId,
681
+ toolName
682
+ }) => {
683
+ const existing = toolCalls.get(toolCallId);
684
+ if (existing) {
685
+ if (!existing.completed && toolName && existing.name !== toolName) {
686
+ existing.name = toolName;
687
+ }
688
+ return { events: [], state: existing };
689
+ }
690
+ const state = {
691
+ argumentsText: "",
692
+ completed: false,
693
+ itemId: toolCallId,
694
+ name: toolName,
695
+ outputIndex: nextOutputIndex++,
696
+ zeroArgumentInputEnded: false
697
+ };
698
+ toolCalls.set(toolCallId, state);
699
+ return {
700
+ state,
701
+ events: [
702
+ createResponseSseEvent({
703
+ type: "response.output_item.added",
704
+ output_index: state.outputIndex,
705
+ item: {
706
+ id: state.itemId,
707
+ type: "function_call",
708
+ call_id: toolCallId,
709
+ name: toolName,
710
+ arguments: "",
711
+ status: "in_progress"
712
+ }
713
+ })
714
+ ]
715
+ };
716
+ };
717
+ const completeToolCallItem = ({
718
+ events,
719
+ state,
720
+ toolCallId,
721
+ toolName,
722
+ args
723
+ }) => {
724
+ if (state.completed) {
725
+ return events;
726
+ }
727
+ const item = {
728
+ id: state.itemId,
729
+ type: "function_call",
730
+ call_id: toolCallId,
731
+ name: toolName,
732
+ arguments: args,
733
+ status: "completed"
734
+ };
735
+ state.argumentsText = args;
736
+ state.completed = true;
737
+ outputItems.set(state.outputIndex, item);
738
+ return [
739
+ ...events,
740
+ createResponseSseEvent({
741
+ type: "response.function_call_arguments.done",
742
+ item_id: state.itemId,
743
+ output_index: state.outputIndex,
744
+ name: toolName,
745
+ arguments: args
746
+ }),
747
+ createResponseSseEvent({
748
+ type: "response.output_item.done",
749
+ output_index: state.outputIndex,
750
+ item
751
+ })
752
+ ];
753
+ };
754
+ const completeToolResultItem = ({
755
+ events,
756
+ toolResult
757
+ }) => {
758
+ if (completedToolResultCallIds.has(toolResult.toolCallId)) {
759
+ return events;
760
+ }
761
+ completedToolResultCallIds.add(toolResult.toolCallId);
762
+ pendingToolResults.delete(toolResult.toolCallId);
763
+ const outputIndex = nextOutputIndex++;
764
+ const item = {
765
+ id: getFunctionCallOutputItemId(toolResult.toolCallId),
766
+ type: "function_call_output",
767
+ call_id: toolResult.toolCallId,
768
+ output: stringifyResponsePayload(toolResult.result)
769
+ };
770
+ outputItems.set(outputIndex, item);
771
+ return [
772
+ ...events,
773
+ createResponseSseEvent({
774
+ type: "response.output_item.added",
775
+ output_index: outputIndex,
776
+ item
777
+ }),
778
+ createResponseSseEvent({
779
+ type: "response.output_item.done",
780
+ output_index: outputIndex,
781
+ item
782
+ })
783
+ ];
784
+ };
785
+ return {
786
+ get text() {
787
+ return text;
788
+ },
789
+ getOutputItems({ text: text2, status }) {
790
+ const items = new Map(outputItems);
791
+ if (text2) {
792
+ const messageOutputIndex = textOutputIndex ?? nextOutputIndex;
793
+ items.set(messageOutputIndex, createOutputMessage({ messageId: responseId, status, text: text2 }));
794
+ }
795
+ return [...items.entries()].sort(([left], [right]) => left - right).map(([, item]) => item);
796
+ },
797
+ consume(value) {
798
+ const textDelta = extractTextDelta(value);
799
+ if (textDelta) {
800
+ const { events, outputIndex } = ensureTextOutputItem();
801
+ text += textDelta;
802
+ return [
803
+ ...events,
804
+ createResponseSseEvent({
805
+ type: "response.output_text.delta",
806
+ output_index: outputIndex,
807
+ content_index: 0,
808
+ item_id: responseId,
809
+ delta: textDelta
810
+ })
811
+ ];
812
+ }
813
+ const toolCallStart = getToolCallStart(value);
814
+ if (toolCallStart) {
815
+ return ensureToolCallItem(toolCallStart).events;
816
+ }
817
+ const toolCallDelta = getToolCallDelta(value);
818
+ if (toolCallDelta) {
819
+ const existing = toolCalls.get(toolCallDelta.toolCallId);
820
+ if (!existing && !toolCallDelta.toolName) {
821
+ return [];
822
+ }
823
+ if (existing?.completed) {
824
+ return [];
825
+ }
826
+ const ensured = ensureToolCallItem({
827
+ toolCallId: toolCallDelta.toolCallId,
828
+ toolName: toolCallDelta.toolName ?? existing.name
829
+ });
830
+ ensured.state.argumentsText += toolCallDelta.delta;
831
+ ensured.state.zeroArgumentInputEnded = false;
832
+ return [
833
+ ...ensured.events,
834
+ createResponseSseEvent({
835
+ type: "response.function_call_arguments.delta",
836
+ item_id: ensured.state.itemId,
837
+ output_index: ensured.state.outputIndex,
838
+ delta: toolCallDelta.delta
839
+ })
840
+ ];
841
+ }
842
+ const toolCallEnd = getToolCallEnd(value);
843
+ if (toolCallEnd) {
844
+ const state = toolCalls.get(toolCallEnd.toolCallId);
845
+ if (!state || state.completed) {
846
+ return [];
847
+ }
848
+ state.zeroArgumentInputEnded = !state.argumentsText;
849
+ return [];
850
+ }
851
+ const toolCall = getToolCall(value);
852
+ if (toolCall) {
853
+ const { events, state } = ensureToolCallItem(toolCall);
854
+ const canonicalArgs = stringifyFunctionCallArguments(toolCall.args, state.argumentsText);
855
+ if (state.completed) {
856
+ const nextEvents2 = completeToolCallItem({
857
+ events,
858
+ state,
859
+ toolCallId: toolCall.toolCallId,
860
+ toolName: toolCall.toolName,
861
+ args: canonicalArgs
862
+ });
863
+ const pendingToolResult2 = pendingToolResults.get(toolCall.toolCallId);
864
+ return pendingToolResult2 ? completeToolResultItem({ events: nextEvents2, toolResult: pendingToolResult2 }) : nextEvents2;
865
+ }
866
+ const remainingArgsDelta = getRemainingArgumentsDelta(state.argumentsText, canonicalArgs);
867
+ const args = remainingArgsDelta === null ? (
868
+ // If both strings are valid but disagree, keep the bytes already emitted
869
+ // as deltas so arguments.done and response.output stay consistent.
870
+ isCompleteJsonString(state.argumentsText) ? state.argumentsText : canonicalArgs
871
+ ) : state.argumentsText + remainingArgsDelta;
872
+ const nextEvents = remainingArgsDelta ? [
873
+ ...events,
874
+ createResponseSseEvent({
875
+ type: "response.function_call_arguments.delta",
876
+ item_id: state.itemId,
877
+ output_index: state.outputIndex,
878
+ delta: remainingArgsDelta
879
+ })
880
+ ] : events;
881
+ const completedEvents = completeToolCallItem({
882
+ events: nextEvents,
883
+ state,
884
+ toolCallId: toolCall.toolCallId,
885
+ toolName: toolCall.toolName,
886
+ args
887
+ });
888
+ const pendingToolResult = pendingToolResults.get(toolCall.toolCallId);
889
+ return pendingToolResult ? completeToolResultItem({ events: completedEvents, toolResult: pendingToolResult }) : completedEvents;
890
+ }
891
+ const toolResult = getToolResult(value);
892
+ if (toolResult) {
893
+ const existingToolCallState = toolCalls.get(toolResult.toolCallId);
894
+ if (!existingToolCallState && !toolResult.toolName) {
895
+ return [];
896
+ }
897
+ const { events: toolCallEvents, state: toolCallState } = ensureToolCallItem({
898
+ toolCallId: toolResult.toolCallId,
899
+ toolName: toolResult.toolName ?? existingToolCallState.name
900
+ });
901
+ if (completedToolResultCallIds.has(toolResult.toolCallId)) {
902
+ return [];
903
+ }
904
+ const events = [...toolCallEvents];
905
+ if (!toolCallState.completed) {
906
+ const args = stringifyFunctionCallArguments(toolResult.args, toolCallState.argumentsText || "{}");
907
+ const hasZeroArgumentHint = toolCallState.zeroArgumentInputEnded && !toolCallState.argumentsText;
908
+ if (toolResult.args === void 0 && !hasZeroArgumentHint && (!toolCallState.argumentsText || !isCompleteJsonString(toolCallState.argumentsText))) {
909
+ pendingToolResults.set(toolResult.toolCallId, toolResult);
910
+ return events;
911
+ }
912
+ events.push(
913
+ ...completeToolCallItem({
914
+ events: [],
915
+ state: toolCallState,
916
+ toolCallId: toolResult.toolCallId,
917
+ toolName: toolResult.toolName ?? toolCallState.name,
918
+ args
919
+ })
920
+ );
921
+ }
922
+ return completeToolResultItem({ events, toolResult });
923
+ }
924
+ return [];
925
+ },
926
+ flushPendingToolResults() {
927
+ const events = [];
928
+ for (const toolResult of pendingToolResults.values()) {
929
+ const toolCallState = toolCalls.get(toolResult.toolCallId);
930
+ if (!toolCallState) {
931
+ continue;
932
+ }
933
+ if (!toolCallState.completed) {
934
+ const safeFallbackArgs = isCompleteJsonString(toolCallState.argumentsText) ? toolCallState.argumentsText : "{}";
935
+ events.push(
936
+ ...completeToolCallItem({
937
+ events: [],
938
+ state: toolCallState,
939
+ toolCallId: toolResult.toolCallId,
940
+ toolName: toolResult.toolName ?? toolCallState.name,
941
+ args: stringifyFunctionCallArguments(toolResult.args, safeFallbackArgs)
942
+ })
943
+ );
944
+ }
945
+ events.push(...completeToolResultItem({ events: [], toolResult }));
946
+ }
947
+ return events;
948
+ },
949
+ completeText(text2, completedItem) {
950
+ const { events, outputIndex } = ensureTextOutputItem();
951
+ const completedTextItem = {
952
+ ...completedItem,
953
+ content: [createOutputTextPart(text2)]
954
+ };
955
+ return [
956
+ ...events,
957
+ createResponseSseEvent({
958
+ type: "response.output_text.done",
959
+ output_index: outputIndex,
960
+ content_index: 0,
961
+ item_id: responseId,
962
+ text: text2
963
+ }),
964
+ createResponseSseEvent({
965
+ type: "response.content_part.done",
966
+ output_index: outputIndex,
967
+ content_index: 0,
968
+ item_id: responseId,
969
+ part: createOutputTextPart(text2)
970
+ }),
971
+ createResponseSseEvent({
972
+ type: "response.output_item.done",
973
+ output_index: outputIndex,
974
+ item: completedTextItem
975
+ })
976
+ ];
977
+ }
978
+ };
979
+ }
980
+
981
+ export { buildCompletedResponse, buildInProgressResponse, createMessageId, createOutputTextPart, createResponseStreamEventTranslator, extractTextDelta, formatSseEvent, mapMastraMessagesToConversationItems, mapMastraMessagesToResponseOutputItems, mapMastraToolsToResponseTools, mapResponseInputToExecutionMessages, mapResponseTurnRecordToResponse, toResponseStatus, toResponseUsage };
982
+ //# sourceMappingURL=chunk-TLLV2JP5.js.map
983
+ //# sourceMappingURL=chunk-TLLV2JP5.js.map