@mastra/server 1.82.0-alpha.1 → 1.82.0-alpha.2

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 (337) hide show
  1. package/dist/_types/{@internal_voice/dist/_types/@internal_core → @internal_voice@0.0.43/dist/_types/@internal_core@0.1.4}/dist/routes/index.d.ts +1 -1
  2. package/dist/_types/{@internal_voice → @internal_voice@0.0.43}/dist/routes/index.d.ts +15 -15
  3. package/dist/_types/{@mastra_schema-compat/dist/_types/@internal_ai-sdk-v4 → @mastra_schema-compat@1.3.17/dist/_types/@internal_ai-sdk-v4@0.0.94}/dist/index.d.ts +1 -1
  4. package/dist/_types/{@mastra_schema-compat/dist/_types/@internal_ai-sdk-v5 → @mastra_schema-compat@1.3.17/dist/_types/@internal_ai-sdk-v5@0.0.94}/dist/index.d.ts +1 -1
  5. package/dist/_types/{@mastra_schema-compat/dist/_types/@internal_ai-v6 → @mastra_schema-compat@1.3.17/dist/_types/@internal_ai-v6@0.0.94}/dist/index.d.ts +1 -1
  6. package/dist/_types/{@mastra_schema-compat → @mastra_schema-compat@1.3.17}/dist/provider-compats/anthropic.d.ts +2 -2
  7. package/dist/_types/{@mastra_schema-compat → @mastra_schema-compat@1.3.17}/dist/provider-compats/deepseek.d.ts +2 -2
  8. package/dist/_types/{@mastra_schema-compat → @mastra_schema-compat@1.3.17}/dist/provider-compats/google.d.ts +1 -1
  9. package/dist/_types/{@mastra_schema-compat → @mastra_schema-compat@1.3.17}/dist/provider-compats/meta.d.ts +2 -2
  10. package/dist/_types/{@mastra_schema-compat → @mastra_schema-compat@1.3.17}/dist/provider-compats/openai.d.ts +1 -1
  11. package/dist/_types/{@mastra_schema-compat → @mastra_schema-compat@1.3.17}/dist/schema.types.d.ts +4 -4
  12. package/dist/_types/{@mastra_schema-compat → @mastra_schema-compat@1.3.17}/dist/standard-schema/standard-schema.d.ts +2 -2
  13. package/dist/_types/{@mastra_schema-compat → @mastra_schema-compat@1.3.17}/dist/standard-schema/standard-schema.types.d.ts +1 -1
  14. package/dist/_types/{@mastra_schema-compat → @mastra_schema-compat@1.3.17}/dist/zod-to-json.d.ts +1 -1
  15. package/dist/{a2a-CIq9dtbC.cjs → a2a-CNfj0wRr.cjs} +2 -2
  16. package/dist/{a2a-CIq9dtbC.cjs.map → a2a-CNfj0wRr.cjs.map} +1 -1
  17. package/dist/{a2a-DULF2hBd.js → a2a-C_2w6OWn.js} +2 -2
  18. package/dist/{a2a-DULF2hBd.js.map → a2a-C_2w6OWn.js.map} +1 -1
  19. package/dist/{agent-builder-C1SGph1p.cjs → agent-builder-B7B1DSP9.cjs} +4 -4
  20. package/dist/{agent-builder-C1SGph1p.cjs.map → agent-builder-B7B1DSP9.cjs.map} +1 -1
  21. package/dist/{agent-builder-Cq-jo2FP.js → agent-builder-CrFZJ1mg.js} +4 -4
  22. package/dist/{agent-builder-Cq-jo2FP.js.map → agent-builder-CrFZJ1mg.js.map} +1 -1
  23. package/dist/{agent-versions-DX2rd6j_.cjs → agent-versions-BccL4mEW.cjs} +2 -2
  24. package/dist/{agent-versions-DX2rd6j_.cjs.map → agent-versions-BccL4mEW.cjs.map} +1 -1
  25. package/dist/{agent-versions-TUl6ky5W.js → agent-versions-DFJyxWY1.js} +2 -2
  26. package/dist/{agent-versions-TUl6ky5W.js.map → agent-versions-DFJyxWY1.js.map} +1 -1
  27. package/dist/{agents-B5kq2QEV.js → agents-BXqMKoOz.js} +3 -2
  28. package/dist/agents-BXqMKoOz.js.map +1 -0
  29. package/dist/{agents-SvkxJW48.cjs → agents-Cp4FBxQB.cjs} +107 -15
  30. package/dist/agents-Cp4FBxQB.cjs.map +1 -0
  31. package/dist/{agents-NRBk4JAs.js → agents-DPvMjiDf.js} +109 -17
  32. package/dist/agents-DPvMjiDf.js.map +1 -0
  33. package/dist/{agents-Cel1sffU.cjs → agents-DbnPZXIN.cjs} +3 -2
  34. package/dist/agents-DbnPZXIN.cjs.map +1 -0
  35. package/dist/{api-schema-manifest-C8E9EB-q.js → api-schema-manifest-BTfM-0md.js} +2 -2
  36. package/dist/{api-schema-manifest-C8E9EB-q.js.map → api-schema-manifest-BTfM-0md.js.map} +1 -1
  37. package/dist/{api-schema-manifest-CNjDZrQ8.cjs → api-schema-manifest-C55f0tmn.cjs} +2 -2
  38. package/dist/{api-schema-manifest-CNjDZrQ8.cjs.map → api-schema-manifest-C55f0tmn.cjs.map} +1 -1
  39. package/dist/{background-tasks-DhQ6upHK.js → background-tasks-BHhn4YZA.js} +42 -3
  40. package/dist/background-tasks-BHhn4YZA.js.map +1 -0
  41. package/dist/{background-tasks-Kcx2YtW0.cjs → background-tasks-Ci2tlxJC.cjs} +47 -2
  42. package/dist/background-tasks-Ci2tlxJC.cjs.map +1 -0
  43. package/dist/{conversations-Ds6aiCMU.cjs → conversations-6DxLemUg.cjs} +2 -2
  44. package/dist/{conversations-Ds6aiCMU.cjs.map → conversations-6DxLemUg.cjs.map} +1 -1
  45. package/dist/{conversations-CVvZOu1K.js → conversations-DDMCe7th.js} +2 -2
  46. package/dist/{conversations-CVvZOu1K.js.map → conversations-DDMCe7th.js.map} +1 -1
  47. package/dist/{dist-Ch5YGldj.cjs → dist-CjEJaGGe.cjs} +1 -1
  48. package/dist/{dist-CPj7ZQaO.cjs → dist-CzWU4AmA.cjs} +9 -8
  49. package/dist/dist-CzWU4AmA.cjs.map +1 -0
  50. package/dist/{dist-DC2mND12.js → dist-DDo4vt34.js} +9 -8
  51. package/dist/dist-DDo4vt34.js.map +1 -0
  52. package/dist/dist-FafoYsHK.js +1 -0
  53. package/dist/docs/SKILL.md +1 -1
  54. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  55. package/dist/docs/references/reference-observability-tracing-advanced-queries.md +31 -11
  56. package/dist/{editor-builder-CcSeAW18.cjs → editor-builder-BO0Pebws.cjs} +3 -3
  57. package/dist/{editor-builder-CcSeAW18.cjs.map → editor-builder-BO0Pebws.cjs.map} +1 -1
  58. package/dist/{editor-builder-B8Mf4kJo.cjs → editor-builder-BaI8pttR.cjs} +2 -2
  59. package/dist/{editor-builder-B8Mf4kJo.cjs.map → editor-builder-BaI8pttR.cjs.map} +1 -1
  60. package/dist/{editor-builder-PKGDfYNc.js → editor-builder-Bln4Pg1U.js} +2 -2
  61. package/dist/{editor-builder-PKGDfYNc.js.map → editor-builder-Bln4Pg1U.js.map} +1 -1
  62. package/dist/{editor-builder-BG38irXi.js → editor-builder-CuT_ltBK.js} +3 -3
  63. package/dist/{editor-builder-BG38irXi.js.map → editor-builder-CuT_ltBK.js.map} +1 -1
  64. package/dist/{observability-dUv60Mzz.cjs → observability-BtdW6mjq.cjs} +2 -2
  65. package/dist/{observability-dUv60Mzz.cjs.map → observability-BtdW6mjq.cjs.map} +1 -1
  66. package/dist/{observability-BS5rmyEH.js → observability-DBtyAJnb.js} +2 -2
  67. package/dist/{observability-BS5rmyEH.js.map → observability-DBtyAJnb.js.map} +1 -1
  68. package/dist/{observability-new-endpoints-BORkWc9f.js → observability-new-endpoints-Di7m_-xc.js} +9 -9
  69. package/dist/observability-new-endpoints-Di7m_-xc.js.map +1 -0
  70. package/dist/{observability-new-endpoints-KJCQZLZr.cjs → observability-new-endpoints-jjCgXuTF.cjs} +8 -8
  71. package/dist/observability-new-endpoints-jjCgXuTF.cjs.map +1 -0
  72. package/dist/{plans-Cq23qQ48.cjs → plans-UPUTbvxx.cjs} +3 -3
  73. package/dist/{plans-Cq23qQ48.cjs.map → plans-UPUTbvxx.cjs.map} +1 -1
  74. package/dist/{plans-BRf1-Sch.js → plans-k4FuteiT.js} +3 -3
  75. package/dist/{plans-BRf1-Sch.js.map → plans-k4FuteiT.js.map} +1 -1
  76. package/dist/{probe-image-size-CSrQj2gm.cjs → probe-image-size-BRHrC0Va.cjs} +2 -2
  77. package/dist/{probe-image-size-CSrQj2gm.cjs.map → probe-image-size-BRHrC0Va.cjs.map} +1 -1
  78. package/dist/{probe-image-size-ssYltjkF.js → probe-image-size-BmIt3CH4.js} +2 -2
  79. package/dist/{probe-image-size-ssYltjkF.js.map → probe-image-size-BmIt3CH4.js.map} +1 -1
  80. package/dist/{responses-CGy87E_N.js → responses-C8HCkptA.js} +2 -2
  81. package/dist/{responses-CGy87E_N.js.map → responses-C8HCkptA.js.map} +1 -1
  82. package/dist/{responses-CPTdr5VE.cjs → responses-opDOcZYI.cjs} +2 -2
  83. package/dist/{responses-CPTdr5VE.cjs.map → responses-opDOcZYI.cjs.map} +1 -1
  84. package/dist/{routes-X0Gh3f3T.js → routes-BCoCimCB.js} +17 -16
  85. package/dist/routes-BCoCimCB.js.map +1 -0
  86. package/dist/{routes-DSBYmGyo.cjs → routes-FKc6a2N0.cjs} +17 -16
  87. package/dist/routes-FKc6a2N0.cjs.map +1 -0
  88. package/dist/{scorer-versions-DIcWTIgC.js → scorer-versions-BZ58s09W.js} +2 -2
  89. package/dist/{scorer-versions-DIcWTIgC.js.map → scorer-versions-BZ58s09W.js.map} +1 -1
  90. package/dist/{scorer-versions-BOjrlIcM.cjs → scorer-versions-vQVWyYWA.cjs} +2 -2
  91. package/dist/{scorer-versions-BOjrlIcM.cjs.map → scorer-versions-vQVWyYWA.cjs.map} +1 -1
  92. package/dist/{scores-BZ0Iz_0O.cjs → scores-CNMXAquK.cjs} +2 -2
  93. package/dist/{scores-BZ0Iz_0O.cjs.map → scores-CNMXAquK.cjs.map} +1 -1
  94. package/dist/{scores-DqSDYRs0.js → scores-CrpJomkR.js} +2 -2
  95. package/dist/{scores-DqSDYRs0.js.map → scores-CrpJomkR.js.map} +1 -1
  96. package/dist/server/handlers/a2a.cjs +1 -1
  97. package/dist/server/handlers/a2a.js +1 -1
  98. package/dist/server/handlers/agent-builder.cjs +1 -1
  99. package/dist/server/handlers/agent-builder.js +1 -1
  100. package/dist/server/handlers/agent-versions.cjs +1 -1
  101. package/dist/server/handlers/agent-versions.js +1 -1
  102. package/dist/server/handlers/agents.cjs +1 -1
  103. package/dist/server/handlers/agents.d.ts +18 -0
  104. package/dist/server/handlers/agents.d.ts.map +1 -1
  105. package/dist/server/handlers/agents.js +1 -1
  106. package/dist/server/handlers/background-tasks.cjs +2 -1
  107. package/dist/server/handlers/background-tasks.d.ts +89 -0
  108. package/dist/server/handlers/background-tasks.d.ts.map +1 -1
  109. package/dist/server/handlers/background-tasks.js +1 -1
  110. package/dist/server/handlers/conversations.cjs +1 -1
  111. package/dist/server/handlers/conversations.js +1 -1
  112. package/dist/server/handlers/editor-builder.cjs +1 -1
  113. package/dist/server/handlers/editor-builder.js +1 -1
  114. package/dist/server/handlers/favorites-enrichment.cjs +1 -1
  115. package/dist/server/handlers/favorites-enrichment.js +1 -1
  116. package/dist/server/handlers/observability-new-endpoints.cjs +1 -1
  117. package/dist/server/handlers/observability-new-endpoints.d.ts +248 -244
  118. package/dist/server/handlers/observability-new-endpoints.d.ts.map +1 -1
  119. package/dist/server/handlers/observability-new-endpoints.js +1 -1
  120. package/dist/server/handlers/observability-shared.cjs +19 -16
  121. package/dist/server/handlers/observability-shared.cjs.map +1 -1
  122. package/dist/server/handlers/observability-shared.d.ts +3 -3
  123. package/dist/server/handlers/observability-shared.d.ts.map +1 -1
  124. package/dist/server/handlers/observability-shared.js +18 -14
  125. package/dist/server/handlers/observability-shared.js.map +1 -1
  126. package/dist/server/handlers/observability.cjs +2 -2
  127. package/dist/server/handlers/observability.js +2 -2
  128. package/dist/server/handlers/plans.cjs +1 -1
  129. package/dist/server/handlers/plans.js +1 -1
  130. package/dist/server/handlers/responses.cjs +1 -1
  131. package/dist/server/handlers/responses.js +1 -1
  132. package/dist/server/handlers/scorer-versions.cjs +1 -1
  133. package/dist/server/handlers/scorer-versions.js +1 -1
  134. package/dist/server/handlers/scores.cjs +1 -1
  135. package/dist/server/handlers/scores.js +1 -1
  136. package/dist/server/handlers/stored-agent-favorites.cjs +2 -2
  137. package/dist/server/handlers/stored-agent-favorites.js +2 -2
  138. package/dist/server/handlers/stored-agents.cjs +29 -10
  139. package/dist/server/handlers/stored-agents.cjs.map +1 -1
  140. package/dist/server/handlers/stored-agents.d.ts +56 -0
  141. package/dist/server/handlers/stored-agents.d.ts.map +1 -1
  142. package/dist/server/handlers/stored-agents.js +29 -10
  143. package/dist/server/handlers/stored-agents.js.map +1 -1
  144. package/dist/server/handlers/stored-scorers.cjs +1 -1
  145. package/dist/server/handlers/stored-scorers.js +1 -1
  146. package/dist/server/handlers/stored-skill-favorites.cjs +1 -1
  147. package/dist/server/handlers/stored-skill-favorites.js +1 -1
  148. package/dist/server/handlers/stored-skills.cjs +1 -1
  149. package/dist/server/handlers/stored-skills.js +1 -1
  150. package/dist/server/handlers/system.cjs +2 -2
  151. package/dist/server/handlers/system.d.ts +2 -0
  152. package/dist/server/handlers/system.d.ts.map +1 -1
  153. package/dist/server/handlers/system.js +2 -2
  154. package/dist/server/handlers/tools.cjs +1 -1
  155. package/dist/server/handlers/tools.js +1 -1
  156. package/dist/server/handlers/workflow-builder.cjs +1 -1
  157. package/dist/server/handlers/workflow-builder.js +1 -1
  158. package/dist/server/handlers/workflows.cjs +1 -1
  159. package/dist/server/handlers/workflows.js +1 -1
  160. package/dist/server/handlers.cjs +10 -10
  161. package/dist/server/handlers.js +10 -10
  162. package/dist/server/schemas/agents.d.ts +4 -1
  163. package/dist/server/schemas/agents.d.ts.map +1 -1
  164. package/dist/server/schemas/background-tasks.d.ts +6 -0
  165. package/dist/server/schemas/background-tasks.d.ts.map +1 -1
  166. package/dist/server/schemas/feedback.d.ts +3 -3
  167. package/dist/server/schemas/index.cjs +7 -7
  168. package/dist/server/schemas/index.js +7 -7
  169. package/dist/server/schemas/stored-agents.d.ts +70 -0
  170. package/dist/server/schemas/stored-agents.d.ts.map +1 -1
  171. package/dist/server/schemas/system.d.ts +2 -0
  172. package/dist/server/schemas/system.d.ts.map +1 -1
  173. package/dist/server/server-adapter/api-schema-manifest.d.ts +1 -1
  174. package/dist/server/server-adapter/index.cjs +1 -1
  175. package/dist/server/server-adapter/index.js +1 -1
  176. package/dist/server/server-adapter/openapi-utils.d.ts +1 -1
  177. package/dist/server/server-adapter/routes/background-tasks.d.ts.map +1 -1
  178. package/dist/server/server-adapter/routes/observability.d.ts +124 -122
  179. package/dist/server/server-adapter/routes/observability.d.ts.map +1 -1
  180. package/dist/server/server-adapter/routes/system.d.ts +2 -0
  181. package/dist/server/server-adapter/routes/system.d.ts.map +1 -1
  182. package/dist/{stored-agents-C9zCintA.js → stored-agents-DA8Zx6o9.js} +10 -1
  183. package/dist/stored-agents-DA8Zx6o9.js.map +1 -0
  184. package/dist/{stored-agents-LCHZldYH.cjs → stored-agents-TQ2lIFbx.cjs} +10 -1
  185. package/dist/stored-agents-TQ2lIFbx.cjs.map +1 -0
  186. package/dist/{stored-scorers-Dz9vAQcr.js → stored-scorers-DhOq8ZQC.js} +2 -2
  187. package/dist/{stored-scorers-Dz9vAQcr.js.map → stored-scorers-DhOq8ZQC.js.map} +1 -1
  188. package/dist/{stored-scorers-DxQds4_y.cjs → stored-scorers-FJOs5774.cjs} +2 -2
  189. package/dist/{stored-scorers-DxQds4_y.cjs.map → stored-scorers-FJOs5774.cjs.map} +1 -1
  190. package/dist/{system-B0_hRqFE.js → system-DT0pqJSk.js} +2 -1
  191. package/dist/system-DT0pqJSk.js.map +1 -0
  192. package/dist/{system-iruN6xnj.cjs → system-eeBLPCu1.cjs} +2 -1
  193. package/dist/system-eeBLPCu1.cjs.map +1 -0
  194. package/dist/{tools-DtRHH9Hr.cjs → tools-C6TLcPmD.cjs} +3 -3
  195. package/dist/{tools-DtRHH9Hr.cjs.map → tools-C6TLcPmD.cjs.map} +1 -1
  196. package/dist/{tools-CtELrYsA.js → tools-DP3yJsX7.js} +3 -3
  197. package/dist/{tools-CtELrYsA.js.map → tools-DP3yJsX7.js.map} +1 -1
  198. package/dist/{workflow-builder-6I2HiKcF.js → workflow-builder-CaSfD6oL.js} +3 -3
  199. package/dist/{workflow-builder-6I2HiKcF.js.map → workflow-builder-CaSfD6oL.js.map} +1 -1
  200. package/dist/{workflow-builder-CQzvZvwC.cjs → workflow-builder-tr_D_ZDN.cjs} +3 -3
  201. package/dist/{workflow-builder-CQzvZvwC.cjs.map → workflow-builder-tr_D_ZDN.cjs.map} +1 -1
  202. package/dist/{workflows-DgSo-eBG.cjs → workflows-CJxQkruy.cjs} +2 -2
  203. package/dist/{workflows-DgSo-eBG.cjs.map → workflows-CJxQkruy.cjs.map} +1 -1
  204. package/dist/{workflows-ClfVyB1p.js → workflows-DrDssVnE.js} +2 -2
  205. package/dist/{workflows-ClfVyB1p.js.map → workflows-DrDssVnE.js.map} +1 -1
  206. package/package.json +5 -5
  207. package/dist/agents-B5kq2QEV.js.map +0 -1
  208. package/dist/agents-Cel1sffU.cjs.map +0 -1
  209. package/dist/agents-NRBk4JAs.js.map +0 -1
  210. package/dist/agents-SvkxJW48.cjs.map +0 -1
  211. package/dist/background-tasks-DhQ6upHK.js.map +0 -1
  212. package/dist/background-tasks-Kcx2YtW0.cjs.map +0 -1
  213. package/dist/dist-CPj7ZQaO.cjs.map +0 -1
  214. package/dist/dist-DC2mND12.js.map +0 -1
  215. package/dist/dist-DDpKEjMk.js +0 -1
  216. package/dist/observability-new-endpoints-BORkWc9f.js.map +0 -1
  217. package/dist/observability-new-endpoints-KJCQZLZr.cjs.map +0 -1
  218. package/dist/routes-DSBYmGyo.cjs.map +0 -1
  219. package/dist/routes-X0Gh3f3T.js.map +0 -1
  220. package/dist/stored-agents-C9zCintA.js.map +0 -1
  221. package/dist/stored-agents-LCHZldYH.cjs.map +0 -1
  222. package/dist/system-B0_hRqFE.js.map +0 -1
  223. package/dist/system-iruN6xnj.cjs.map +0 -1
  224. /package/dist/_types/{@internal_core → @internal_core@0.1.4}/dist/storage/index.d.ts +0 -0
  225. /package/dist/_types/{@internal_core → @internal_core@0.1.4}/package.json +0 -0
  226. /package/dist/_types/{@internal_voice/dist/_types/@internal_core → @internal_voice@0.0.43/dist/_types/@internal_core@0.1.4}/dist/request-context/index.d.ts +0 -0
  227. /package/dist/_types/{@internal_voice/dist/_types/@internal_core → @internal_voice@0.0.43/dist/_types/@internal_core@0.1.4}/dist/types/index.d.ts +0 -0
  228. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/classic/checks.d.ts +0 -0
  229. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/classic/coerce.d.ts +0 -0
  230. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/classic/compat.d.ts +0 -0
  231. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/classic/deep-partial.d.ts +0 -0
  232. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/classic/errors.d.ts +0 -0
  233. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/classic/external.d.ts +0 -0
  234. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/classic/from-json-schema.d.ts +0 -0
  235. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/classic/in-out.d.ts +0 -0
  236. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/classic/index.d.ts +0 -0
  237. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/classic/iso.d.ts +0 -0
  238. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/classic/parse.d.ts +0 -0
  239. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/classic/schemas.d.ts +0 -0
  240. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/core/api.d.ts +0 -0
  241. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/core/checks.d.ts +0 -0
  242. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/core/compile.d.ts +0 -0
  243. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/core/core.d.ts +0 -0
  244. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/core/doc.d.ts +0 -0
  245. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/core/errors.d.ts +0 -0
  246. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/core/index.d.ts +0 -0
  247. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/core/json-schema-generator.d.ts +0 -0
  248. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/core/json-schema-processors.d.ts +0 -0
  249. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/core/json-schema.d.ts +0 -0
  250. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/core/memoizer.d.ts +0 -0
  251. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/core/parse.d.ts +0 -0
  252. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/core/regexes.d.ts +0 -0
  253. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/core/registries.d.ts +0 -0
  254. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/core/schemas.d.ts +0 -0
  255. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/core/standard-schema.d.ts +0 -0
  256. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/core/to-json-schema.d.ts +0 -0
  257. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/core/util.d.ts +0 -0
  258. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/core/versions.d.ts +0 -0
  259. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/index.d.cts +0 -0
  260. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/ar.d.ts +0 -0
  261. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/az.d.ts +0 -0
  262. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/be.d.ts +0 -0
  263. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/bg.d.ts +0 -0
  264. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/bn.d.ts +0 -0
  265. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/ca.d.ts +0 -0
  266. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/ckb.d.ts +0 -0
  267. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/cs.d.ts +0 -0
  268. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/da.d.ts +0 -0
  269. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/de.d.ts +0 -0
  270. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/el.d.ts +0 -0
  271. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/en.d.ts +0 -0
  272. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/eo.d.ts +0 -0
  273. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/es.d.ts +0 -0
  274. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/fa.d.ts +0 -0
  275. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/fi.d.ts +0 -0
  276. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/fr-CA.d.ts +0 -0
  277. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/fr.d.ts +0 -0
  278. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/gu.d.ts +0 -0
  279. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/he.d.ts +0 -0
  280. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/hi.d.ts +0 -0
  281. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/hr.d.ts +0 -0
  282. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/hu.d.ts +0 -0
  283. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/hy.d.ts +0 -0
  284. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/id.d.ts +0 -0
  285. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/index.d.ts +0 -0
  286. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/is.d.ts +0 -0
  287. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/it.d.ts +0 -0
  288. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/ja.d.ts +0 -0
  289. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/ka.d.ts +0 -0
  290. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/kh.d.ts +0 -0
  291. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/km.d.ts +0 -0
  292. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/kn.d.ts +0 -0
  293. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/ko.d.ts +0 -0
  294. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/lt.d.ts +0 -0
  295. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/mk.d.ts +0 -0
  296. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/ms.d.ts +0 -0
  297. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/ne.d.ts +0 -0
  298. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/nl.d.ts +0 -0
  299. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/nn.d.ts +0 -0
  300. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/no.d.ts +0 -0
  301. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/ota.d.ts +0 -0
  302. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/pl.d.ts +0 -0
  303. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/ps.d.ts +0 -0
  304. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/pt-BR.d.ts +0 -0
  305. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/pt.d.ts +0 -0
  306. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/ro.d.ts +0 -0
  307. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/ru.d.ts +0 -0
  308. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/sk.d.ts +0 -0
  309. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/sl.d.ts +0 -0
  310. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/sv.d.ts +0 -0
  311. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/ta.d.ts +0 -0
  312. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/tg.d.ts +0 -0
  313. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/th.d.ts +0 -0
  314. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/tk.d.ts +0 -0
  315. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/tr.d.ts +0 -0
  316. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/ua.d.ts +0 -0
  317. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/uk.d.ts +0 -0
  318. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/ur.d.ts +0 -0
  319. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/uz.d.ts +0 -0
  320. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/vi.d.ts +0 -0
  321. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/yo.d.ts +0 -0
  322. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/zh-CN.d.ts +0 -0
  323. /package/dist/_types/{@internal_voice/dist/_types/zod → @internal_voice@0.0.43/dist/_types/zod@4.6.7}/v4/locales/zh-TW.d.ts +0 -0
  324. /package/dist/_types/{@internal_voice → @internal_voice@0.0.43}/package.json +0 -0
  325. /package/dist/_types/{@mastra_schema-compat/dist/_types/@standard-schema_spec → @mastra_schema-compat@1.3.17/dist/_types/@standard-schema_spec@1.1.0}/dist/index.d.ts +0 -0
  326. /package/dist/_types/{@mastra_schema-compat/dist/_types/@types_json-schema → @mastra_schema-compat@1.3.17/dist/_types/@types_json-schema@7.0.15}/index.d.ts +0 -0
  327. /package/dist/_types/{@mastra_schema-compat → @mastra_schema-compat@1.3.17}/dist/index.d.ts +0 -0
  328. /package/dist/_types/{@mastra_schema-compat → @mastra_schema-compat@1.3.17}/dist/null-to-undefined.d.ts +0 -0
  329. /package/dist/_types/{@mastra_schema-compat → @mastra_schema-compat@1.3.17}/dist/provider-compats/openai-reasoning.d.ts +0 -0
  330. /package/dist/_types/{@mastra_schema-compat → @mastra_schema-compat@1.3.17}/dist/schema-compatibility-v3.d.ts +0 -0
  331. /package/dist/_types/{@mastra_schema-compat → @mastra_schema-compat@1.3.17}/dist/schema-compatibility-v4.d.ts +0 -0
  332. /package/dist/_types/{@mastra_schema-compat → @mastra_schema-compat@1.3.17}/dist/schema-compatibility.d.ts +0 -0
  333. /package/dist/_types/{@mastra_schema-compat → @mastra_schema-compat@1.3.17}/dist/schema.d.ts +0 -0
  334. /package/dist/_types/{@mastra_schema-compat → @mastra_schema-compat@1.3.17}/dist/standard-schema-compat.d.ts +0 -0
  335. /package/dist/_types/{@mastra_schema-compat → @mastra_schema-compat@1.3.17}/dist/types.d.ts +0 -0
  336. /package/dist/_types/{@mastra_schema-compat → @mastra_schema-compat@1.3.17}/dist/utils.d.ts +0 -0
  337. /package/dist/_types/{@mastra_schema-compat → @mastra_schema-compat@1.3.17}/package.json +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"workflows-ClfVyB1p.js","names":[],"sources":["../src/server/handlers/workflows.ts"],"sourcesContent":["import type { Mastra } from '@mastra/core';\nimport type { MastraServerCache } from '@mastra/core/cache';\nimport type { RequestContext } from '@mastra/core/di';\nimport type { Event } from '@mastra/core/events';\nimport { createReplayStream } from '@mastra/core/stream';\nimport type {\n WorkflowInfo,\n ChunkType,\n StreamEvent,\n WorkflowStateField,\n WorkflowRunStatus,\n WorkflowRunState,\n} from '@mastra/core/workflows';\nimport { z } from 'zod/v4';\nimport { MastraFGAPermissions } from '../fga-permissions';\nimport { HTTPException } from '../http-exception';\nimport { streamResponseSchema } from '../schemas/agents';\nimport { optionalRunIdSchema, runIdSchema } from '../schemas/common';\nimport {\n createWorkflowRunBodySchema,\n createWorkflowRunResponseSchema,\n listWorkflowRunsQuerySchema,\n listWorkflowsResponseSchema,\n workflowRunCountsResponseSchema,\n restartBodySchema,\n timeTravelBodySchema,\n resumeBodySchema,\n startAsyncWorkflowBodySchema,\n streamWorkflowBodySchema,\n workflowControlResponseSchema,\n workflowExecutionResultSchema,\n workflowIdPathParams,\n workflowInfoSchema,\n workflowRunPathParams,\n workflowRunsResponseSchema,\n workflowRunResultQuerySchema,\n workflowRunResultSchema,\n observeWorkflowQuerySchema,\n} from '../schemas/workflows';\nimport { createRoute } from '../server-adapter/routes/route-builder';\nimport type { Context } from '../types';\nimport { getWorkflowInfo, WorkflowRegistry } from '../utils';\nimport { handleError } from './error';\nimport { getEffectiveResourceId, getHandlerFGAProvider, getPublicWorkflowById, validateRunOwnership } from './utils';\n\n/**\n * Statuses a run cannot come back from. Streaming one of these runIds again would\n * start a fresh execution under the same runId and overwrite its stored snapshot —\n * the in-memory de-dupe that protects concurrent streams only covers runs still held\n * in the workflow's run map, and a finished run has already been dropped from it.\n */\nconst TERMINAL_RUN_STATUSES: WorkflowRunStatus[] = ['success', 'failed', 'canceled', 'tripwire'];\n\n/**\n * Runs whose chunks are already being written to the cache in this process,\n * keyed by runId. A run has exactly one writer: without this, two concurrent\n * requests for the same runId each cache every chunk and the replayed history\n * comes back duplicated.\n */\nconst activeRunStreamCachers = new Set<string>();\n\n/**\n * Cache a run's chunks for later replay and return the stream to hand the client.\n *\n * The cached history belongs to the run, not to whoever happens to be watching,\n * so the caching side is driven by its own reader rather than by the client's\n * consumption. If the client disconnects mid-run its branch is cancelled while\n * this reader keeps draining, so `/observe` still replays a complete history —\n * the failure that makes reconnection necessary is exactly the one the cache has\n * to survive. Chunks buffer in the tee while a client lags, bounded by the run's\n * own length.\n */\nfunction cacheRunStream({\n cache,\n runId,\n source,\n}: {\n cache: MastraServerCache;\n runId: string;\n source: ReadableStream<ChunkType>;\n}): ReadableStream<ChunkType> {\n if (activeRunStreamCachers.has(runId)) {\n return source;\n }\n\n const [toCache, toClient] = source.tee();\n activeRunStreamCachers.add(runId);\n\n void (async () => {\n const reader = toCache.getReader();\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n // Cache failures must not take down the run being streamed.\n await cache.listPush(runId, value).catch(() => {});\n }\n } catch {\n // The source errored; the client's branch surfaces it.\n } finally {\n reader.releaseLock();\n activeRunStreamCachers.delete(runId);\n }\n })();\n\n return toClient;\n}\n\nexport interface WorkflowContext extends Context {\n workflowId?: string;\n runId?: string;\n requestContext?: RequestContext;\n}\n\nasync function listWorkflowsFromSystem({ mastra, workflowId }: WorkflowContext) {\n const logger = mastra.getLogger();\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n let workflow;\n\n // First check registry for temporary workflows\n workflow = WorkflowRegistry.getWorkflow(workflowId);\n\n if (!workflow) {\n workflow = getPublicWorkflowById(mastra, workflowId);\n }\n\n if (!workflow) {\n logger.debug('Workflow not found, searching agents for workflow', { workflowId });\n const agents = mastra.listAgents();\n\n if (Object.keys(agents || {}).length) {\n for (const [_, agent] of Object.entries(agents)) {\n try {\n const workflows = await agent.listWorkflows();\n\n if (workflows[workflowId]) {\n workflow = workflows[workflowId];\n break;\n }\n } catch (error) {\n logger.debug('Error getting workflow from agent', error);\n }\n }\n }\n }\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n return { workflow };\n}\n\n// ============================================================================\n// Route Definitions (new pattern - handlers defined inline with createRoute)\n// ============================================================================\n\nexport const LIST_WORKFLOWS_ROUTE = createRoute({\n method: 'GET',\n path: '/workflows',\n responseType: 'json',\n queryParamSchema: z.object({\n partial: z.string().optional(),\n }),\n responseSchema: listWorkflowsResponseSchema,\n summary: 'List all workflows',\n description: 'Returns a list of all available workflows in the system',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: (async ({ mastra, partial, requestContext }: any) => {\n try {\n const workflows = mastra.listWorkflows({ serialized: false });\n const isPartial = partial === 'true';\n const _workflows = Object.entries(workflows).reduce<Record<string, WorkflowInfo>>((acc, [key, workflow]) => {\n acc[key] = getWorkflowInfo(workflow as any, isPartial);\n return acc;\n }, {});\n\n // Filter workflows by FGA if configured\n const fgaProvider = getHandlerFGAProvider(mastra, requestContext);\n const user = requestContext?.get('user');\n if (fgaProvider) {\n if (!user) {\n return {};\n }\n const workflowList = Object.entries(_workflows).map(([id, w]) => ({ id, ...w }));\n const accessible = await fgaProvider.filterAccessible(\n user,\n workflowList,\n 'workflow',\n MastraFGAPermissions.WORKFLOWS_READ,\n );\n const accessibleSet = new Set(accessible.map((w: any) => w.id));\n for (const id of Object.keys(_workflows)) {\n if (!accessibleSet.has(id)) {\n delete _workflows[id];\n }\n }\n }\n\n return _workflows;\n } catch (error) {\n return handleError(error, 'Error getting workflows');\n }\n }) as any,\n});\n\ntype WorkflowRunCounts = { running: number; suspended: number };\n\nconst RUN_COUNTS_CACHE_TTL_MS = 5_000;\n// Keyed by Mastra instance so multiple apps in one process never share counts.\nconst runCountsCache = new WeakMap<object, { at: number; value: Record<string, WorkflowRunCounts> }>();\nlet runCountsNow: () => number = () => Date.now();\n\n/** Test seam — lets TTL expiry be tested without wall-clock waits. */\nexport function __setWorkflowRunCountsNow(now?: () => number) {\n runCountsNow = now ?? (() => Date.now());\n}\n\nexport const LIST_WORKFLOW_RUN_COUNTS_ROUTE = createRoute({\n method: 'GET',\n path: '/workflows/run-counts',\n responseType: 'json',\n responseSchema: workflowRunCountsResponseSchema,\n summary: 'List workflow run counts',\n description:\n 'Returns per-workflow counts of currently running and suspended (awaiting resume) runs, keyed by the workflow registry key used in the Mastra config',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: (async ({ mastra, requestContext }: any) => {\n try {\n const fgaProvider = getHandlerFGAProvider(mastra, requestContext);\n const user = requestContext?.get('user');\n // FGA with no user can never see anything — answer before touching storage.\n if (fgaProvider && !user) {\n return {};\n }\n\n const workflows = mastra.listWorkflows({ serialized: false });\n\n const counts: Record<string, WorkflowRunCounts> = {};\n const workflowIdToRegistryKey = new Map<string, string>();\n for (const [registryKey, workflow] of Object.entries(workflows)) {\n counts[registryKey] = { running: 0, suspended: 0 };\n workflowIdToRegistryKey.set((workflow as any).id, registryKey);\n }\n\n // Runs are scoped to the caller like the runs-listing endpoint: the\n // reserved request-context resource id takes precedence for security.\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n // The shared cache holds the unscoped, unfiltered map — usable only when\n // neither per-user FGA filtering nor a resource scope applies.\n const cacheable = !fgaProvider && !effectiveResourceId;\n if (cacheable) {\n const cached = runCountsCache.get(mastra);\n if (cached && runCountsNow() - cached.at < RUN_COUNTS_CACHE_TTL_MS) {\n return cached.value;\n }\n }\n\n const storage = mastra.getStorage();\n const workflowsStore = storage ? await storage.getStore('workflows') : undefined;\n if (workflowsStore) {\n // Cross-workflow, engine-agnostic: both execution engines persist run\n // status into the same store. Deliberately not listActiveWorkflowRuns,\n // which means running+waiting and covers the default engine only.\n const [running, suspended] = await Promise.all([\n workflowsStore.listWorkflowRuns({ status: 'running', resourceId: effectiveResourceId }),\n workflowsStore.listWorkflowRuns({ status: 'suspended', resourceId: effectiveResourceId }),\n ]);\n for (const run of running.runs) {\n const registryKey = workflowIdToRegistryKey.get(run.workflowName);\n const entry = registryKey ? counts[registryKey] : undefined;\n if (entry) entry.running++;\n }\n for (const run of suspended.runs) {\n const registryKey = workflowIdToRegistryKey.get(run.workflowName);\n const entry = registryKey ? counts[registryKey] : undefined;\n if (entry) entry.suspended++;\n }\n }\n\n if (fgaProvider) {\n const workflowList = Object.keys(counts).map(id => ({ id }));\n const accessible = await fgaProvider.filterAccessible(\n user,\n workflowList,\n 'workflow',\n MastraFGAPermissions.WORKFLOWS_READ,\n );\n const accessibleSet = new Set(accessible.map((w: any) => w.id));\n for (const id of Object.keys(counts)) {\n if (!accessibleSet.has(id)) {\n delete counts[id];\n }\n }\n return counts;\n }\n\n if (cacheable) {\n runCountsCache.set(mastra, { at: runCountsNow(), value: counts });\n }\n return counts;\n } catch (error) {\n return handleError(error, 'Error getting workflow run counts');\n }\n }) as any,\n});\n\nexport const GET_WORKFLOW_BY_ID_ROUTE = createRoute({\n method: 'GET',\n path: '/workflows/:workflowId',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n responseSchema: workflowInfoSchema,\n summary: 'Get workflow by ID',\n description: 'Returns details for a specific workflow',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: (async ({ mastra, workflowId }: any) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n return getWorkflowInfo(workflow, false);\n } catch (error) {\n return handleError(error, 'Error getting workflow');\n }\n }) as any,\n});\n\nexport const LIST_WORKFLOW_RUNS_ROUTE = createRoute({\n method: 'GET',\n path: '/workflows/:workflowId/runs',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: listWorkflowRunsQuerySchema,\n responseSchema: workflowRunsResponseSchema,\n summary: 'List workflow runs',\n description: 'Returns a paginated list of execution runs for the specified workflow',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({\n mastra,\n workflowId,\n fromDate,\n toDate,\n page,\n perPage,\n limit,\n offset,\n resourceId,\n status,\n summary,\n requestContext,\n }) => {\n try {\n // Use effective resourceId (context key takes precedence over client-provided value)\n const effectiveResourceId = getEffectiveResourceId(requestContext, resourceId);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n // Support both page/perPage and limit/offset for backwards compatibility\n // If page/perPage provided, use directly; otherwise convert from limit/offset\n let finalPage = page;\n let finalPerPage = perPage;\n\n if (finalPerPage === undefined && limit !== undefined) {\n finalPerPage = limit;\n }\n if (finalPage === undefined && offset !== undefined && finalPerPage !== undefined && finalPerPage > 0) {\n finalPage = Math.floor(offset / finalPerPage);\n }\n\n if (\n finalPerPage !== undefined &&\n (typeof finalPerPage !== 'number' || !Number.isInteger(finalPerPage) || finalPerPage <= 0)\n ) {\n throw new HTTPException(400, { message: 'perPage must be a positive integer' });\n }\n if (finalPage !== undefined && (!Number.isInteger(finalPage) || finalPage < 0)) {\n throw new HTTPException(400, { message: 'page must be a non-negative integer' });\n }\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n const workflowRuns = (await workflow.listWorkflowRuns({\n fromDate: fromDate ? (typeof fromDate === 'string' ? new Date(fromDate) : fromDate) : undefined,\n toDate: toDate ? (typeof toDate === 'string' ? new Date(toDate) : toDate) : undefined,\n perPage: finalPerPage,\n page: finalPage,\n resourceId: effectiveResourceId,\n status,\n ...(summary ? { summary: true } : {}),\n })) || {\n runs: [],\n total: 0,\n };\n if (summary) {\n // Adapters may ignore `summary`, so always trim here to keep the response small.\n return {\n ...workflowRuns,\n runs: workflowRuns.runs.map(run => ({ ...run, snapshot: toSummarySnapshot(run.snapshot) })),\n };\n }\n return workflowRuns;\n } catch (error) {\n return handleError(error, 'Error getting workflow runs');\n }\n },\n});\n\nfunction toSummarySnapshot(\n snapshot: WorkflowRunState | string,\n): Pick<WorkflowRunState, 'status' | 'timestamp'> | string {\n let parsed: unknown;\n if (typeof snapshot === 'string') {\n try {\n parsed = JSON.parse(snapshot);\n } catch {\n // Never echo an unparseable (possibly huge) snapshot back in summary mode.\n return '';\n }\n } else {\n parsed = snapshot;\n }\n if (!parsed || typeof parsed !== 'object') return '';\n const { status, timestamp } = parsed as WorkflowRunState;\n return { status, timestamp };\n}\n\nexport const GET_WORKFLOW_RUN_BY_ID_ROUTE = createRoute({\n method: 'GET',\n path: '/workflows/:workflowId/runs/:runId',\n responseType: 'json',\n pathParamSchema: workflowRunPathParams,\n queryParamSchema: workflowRunResultQuerySchema,\n responseSchema: workflowRunResultSchema,\n summary: 'Get workflow run by ID',\n description:\n 'Returns a workflow run with metadata and processed execution state. Use the fields query parameter to reduce payload size by requesting only specific fields (e.g., ?fields=result,steps). Available fields: result, error, payload, steps, activeStepsPath, serializedStepGraph. Metadata fields (runId, workflowName, resourceId, createdAt, updatedAt) and status are always included.',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, fields, withNestedWorkflows, requestContext }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'Run ID is required' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n // Parse fields parameter (comma-separated string)\n const fieldList = fields ? (fields.split(',').map((f: string) => f.trim()) as WorkflowStateField[]) : undefined;\n\n const run = await workflow.getWorkflowRunById(runId, {\n withNestedWorkflows: withNestedWorkflows !== 'false', // Default to true unless explicitly 'false'\n fields: fieldList,\n });\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\n\n return run;\n } catch (error) {\n return handleError(error, 'Error getting workflow run');\n }\n },\n});\n\nexport const DELETE_WORKFLOW_RUN_BY_ID_ROUTE = createRoute({\n method: 'DELETE',\n path: '/workflows/:workflowId/runs/:runId',\n responseType: 'json',\n pathParamSchema: workflowRunPathParams,\n responseSchema: workflowControlResponseSchema,\n summary: 'Delete workflow run by ID',\n description: 'Deletes a specific workflow run by ID',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'Run ID is required' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n // Validate ownership before deletion\n const run = await workflow.getWorkflowRunById(runId);\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\n\n await workflow.deleteWorkflowRunById(runId);\n\n return { message: 'Workflow run deleted' };\n } catch (error) {\n return handleError(error, 'Error deleting workflow run');\n }\n },\n});\n\nexport const CREATE_WORKFLOW_RUN_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/create-run',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: optionalRunIdSchema,\n bodySchema: createWorkflowRunBodySchema,\n responseSchema: createWorkflowRunResponseSchema,\n summary: 'Create workflow run',\n description: 'Creates a new workflow execution instance with an optional custom run ID',\n tags: ['Workflows'],\n requiresAuth: true,\n // Creating a run is part of the execute flow (Studio/UI calls this before\n // starting/streaming a workflow), so allow either permission. `write` is kept\n // for back-compat with roles that already grant it.\n requiresPermission: ['workflows:write', 'workflows:execute'],\n handler: async ({ mastra, workflowId, runId, resourceId, disableScorers, requestContext }) => {\n try {\n // Use effective resourceId (context key takes precedence over client-provided value)\n const effectiveResourceId = getEffectiveResourceId(requestContext, resourceId);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n if (runId) {\n const existingRun = await workflow.getWorkflowRunById(runId, { withNestedWorkflows: false });\n await validateRunOwnership(\n existingRun,\n getEffectiveResourceId(requestContext, undefined),\n mastra,\n requestContext,\n );\n }\n const run = await workflow.createRun({ runId, resourceId: effectiveResourceId, disableScorers });\n\n return { runId: run.runId };\n } catch (error) {\n return handleError(error, 'Error creating workflow run');\n }\n },\n});\n\nexport const STREAM_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/stream',\n responseType: 'stream',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: streamWorkflowBodySchema,\n summary: 'Stream workflow execution',\n description: 'Executes a workflow and streams the results in real-time',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, resourceId, requestContext, ...params }) => {\n try {\n // Use effective resourceId (context key takes precedence over client-provided value)\n const effectiveResourceId = getEffectiveResourceId(requestContext, resourceId);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to stream workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const existingRun = await workflow.getWorkflowRunById(runId, { withNestedWorkflows: false });\n await validateRunOwnership(\n existingRun,\n getEffectiveResourceId(requestContext, undefined),\n mastra,\n requestContext,\n );\n\n if (existingRun && TERMINAL_RUN_STATUSES.includes(existingRun.status)) {\n throw new HTTPException(409, {\n message:\n `Workflow run ${runId} already finished with status \"${existingRun.status}\". ` +\n `Use /observe to read its stream back, or stream a new runId.`,\n });\n }\n\n const serverCache = mastra.getServerCache();\n\n const run = await workflow.createRun({ runId, resourceId: effectiveResourceId });\n const result = run.stream({ ...params, requestContext });\n\n if (serverCache) {\n return cacheRunStream({ cache: serverCache, runId, source: result.fullStream });\n }\n\n return result.fullStream;\n } catch (error) {\n return handleError(error, 'Error streaming workflow');\n }\n },\n});\n\nexport const RESUME_STREAM_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/resume-stream',\n responseType: 'stream',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: resumeBodySchema,\n responseSchema: streamResponseSchema,\n summary: 'Resume workflow stream',\n description: 'Resumes a suspended workflow execution and continues streaming results',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n const serverCache = mastra.getServerCache();\n\n const resumeResult = _run.resumeStream({ ...params, requestContext });\n\n if (serverCache) {\n return cacheRunStream({ cache: serverCache, runId, source: resumeResult.fullStream });\n }\n\n return resumeResult.fullStream;\n } catch (error) {\n return handleError(error, 'Error resuming workflow');\n }\n },\n});\n\nexport const START_ASYNC_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/start-async',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: optionalRunIdSchema,\n bodySchema: startAsyncWorkflowBodySchema,\n responseSchema: workflowExecutionResultSchema,\n summary: 'Start workflow asynchronously',\n description: 'Starts a workflow execution asynchronously without streaming results',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, resourceId, requestContext, ...params }) => {\n try {\n // Use effective resourceId (context key takes precedence over client-provided value)\n const effectiveResourceId = getEffectiveResourceId(requestContext, resourceId);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n if (runId) {\n const existingRun = await workflow.getWorkflowRunById(runId, { withNestedWorkflows: false });\n await validateRunOwnership(\n existingRun,\n getEffectiveResourceId(requestContext, undefined),\n mastra,\n requestContext,\n );\n }\n const _run = await workflow.createRun({ runId, resourceId: effectiveResourceId });\n const result = await _run.start({ ...params, requestContext });\n return result;\n } catch (error) {\n return handleError(error, 'Error starting async workflow');\n }\n },\n});\n\nexport const START_WORKFLOW_RUN_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/start',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: startAsyncWorkflowBodySchema,\n responseSchema: workflowControlResponseSchema,\n summary: 'Start specific workflow run',\n description: 'Starts execution of a specific workflow run by ID',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to start run' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n // Fire-and-forget: attach .catch so a rejected start (e.g. invalid input\n // schema) cannot become an unhandledRejection and tear down the process.\n void _run\n .start({\n ...params,\n requestContext,\n })\n .catch(error => {\n mastra.getLogger().error('Failed to start workflow run', { error, workflowId, runId });\n });\n\n return { message: 'Workflow run started' };\n } catch (e) {\n return handleError(e, 'Error starting workflow run');\n }\n },\n});\n\nexport const OBSERVE_STREAM_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/observe',\n responseType: 'stream',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: observeWorkflowQuerySchema,\n responseSchema: streamResponseSchema,\n summary: 'Observe workflow stream',\n description:\n 'Observes and streams updates from an already running workflow execution. Supports position-based resume with offset for efficient reconnection.',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, offset, requestContext }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to observe workflow stream' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n const serverCache = mastra.getServerCache();\n if (!serverCache) {\n throw new HTTPException(500, { message: 'Server cache not found' });\n }\n\n // Get cached chunks from the specified index (or 0 if not specified)\n const startIndex = offset ?? 0;\n const cachedRunChunks = (await serverCache.listFromTo(runId, startIndex)) as ChunkType[];\n const liveStream = _run.observeStream();\n\n return createReplayStream<ChunkType>({\n history: cachedRunChunks,\n liveSource: liveStream,\n });\n } catch (error) {\n return handleError(error, 'Error observing workflow stream');\n }\n },\n});\n\nexport const RESUME_ASYNC_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/resume-async',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: resumeBodySchema,\n responseSchema: workflowExecutionResultSchema,\n summary: 'Resume workflow asynchronously',\n description: 'Resumes a suspended workflow execution asynchronously without streaming',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n const result = await _run.resume({ ...params, requestContext });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error resuming workflow step');\n }\n },\n});\n\n/**\n * Fire-and-forget resume: dispatches the resume and returns immediately with the runId,\n * without waiting for the workflow to complete. For Inngest-backed workflows this avoids\n * the `getRunOutput()` polling race that the awaiting `resume-async` route can hit.\n *\n * TODO(v2): in Mastra v2 this fire-and-forget behavior should become the behavior of the\n * `resume-async` route (and `Run.resumeAsync()`), and this route should be removed. It is\n * kept separate in v1 to avoid a breaking change to the existing `resume-async` response\n * contract (which returns the full workflow result).\n */\nexport const RESUME_NO_WAIT_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/resume-no-wait',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: resumeBodySchema,\n responseSchema: createWorkflowRunResponseSchema,\n summary: 'Resume workflow without waiting',\n description:\n 'Resumes a suspended workflow execution without waiting (fire-and-forget) and returns immediately with the runId. The workflow continues executing in the background.',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n const result = await _run.resumeAsync({ ...params, requestContext });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error resuming workflow step');\n }\n },\n});\n\nexport const RESUME_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/resume',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: resumeBodySchema,\n responseSchema: workflowControlResponseSchema,\n summary: 'Resume workflow',\n description: 'Resumes a suspended workflow execution from a specific step',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n\n // Fire-and-forget: attach .catch so a rejected resume cannot become an\n // unhandledRejection and tear down the process.\n void _run.resume({ ...params, requestContext }).catch(error => {\n mastra.getLogger().error('Failed to resume workflow run', { error, workflowId, runId });\n });\n\n return { message: 'Workflow run resumed' };\n } catch (error) {\n return handleError(error, 'Error resuming workflow');\n }\n },\n});\n\nexport const RESTART_ASYNC_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/restart-async',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: restartBodySchema,\n responseSchema: workflowExecutionResultSchema,\n summary: 'Restart workflow asynchronously',\n description: 'Restarts an active workflow execution asynchronously',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to restart workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n const result = await _run.restart({ ...params, requestContext });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error restarting workflow');\n }\n },\n});\n\nexport const RESTART_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/restart',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: restartBodySchema,\n responseSchema: workflowControlResponseSchema,\n summary: 'Restart workflow',\n description: 'Restarts an active workflow execution',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to restart workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n\n void _run.restart({ ...params, requestContext }).catch(error => {\n mastra.getLogger().error('Failed to restart workflow run in background', { error, workflowId, runId });\n });\n\n return { message: 'Workflow run restarted' };\n } catch (error) {\n return handleError(error, 'Error restarting workflow');\n }\n },\n});\n\nexport const RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ASYNC_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/restart-all-active-workflow-runs-async',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n responseSchema: workflowControlResponseSchema,\n summary: 'Restart all active workflow runs asynchronously',\n description: 'Restarts all active workflow runs asynchronously',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, requestContext }) => {\n try {\n // Restarting every active run spans all owners, so only a privileged caller may do it:\n // checked as access to a run with no owner.\n await validateRunOwnership(\n { resourceId: null },\n getEffectiveResourceId(requestContext, undefined),\n mastra,\n requestContext,\n );\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n await workflow.restartAllActiveWorkflowRuns();\n\n return { message: 'All active workflow runs restarted' };\n } catch (error) {\n return handleError(error, 'Error restarting workflow');\n }\n },\n});\n\nexport const RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/restart-all-active-workflow-runs',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n responseSchema: workflowControlResponseSchema,\n summary: 'Restart all active workflow runs',\n description: 'Restarts all active workflow runs',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, requestContext }) => {\n try {\n // Restarting every active run spans all owners, so only a privileged caller may do it:\n // checked as access to a run with no owner.\n await validateRunOwnership(\n { resourceId: null },\n getEffectiveResourceId(requestContext, undefined),\n mastra,\n requestContext,\n );\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n void workflow.restartAllActiveWorkflowRuns().catch(error => {\n mastra.getLogger().error('Failed to restart active workflow runs', { error, workflowId });\n });\n\n return { message: 'All active workflow runs restarted' };\n } catch (error) {\n return handleError(error, 'Error restarting workflow');\n }\n },\n});\n\nexport const TIME_TRAVEL_ASYNC_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/time-travel-async',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: timeTravelBodySchema,\n responseSchema: workflowExecutionResultSchema,\n summary: 'Time travel workflow asynchronously',\n description: 'Time travels a workflow run asynchronously without streaming',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to time travel workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n const result = await _run.timeTravel({ ...params, requestContext });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error time traveling workflow');\n }\n },\n});\n\nexport const TIME_TRAVEL_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/time-travel',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: timeTravelBodySchema,\n responseSchema: workflowControlResponseSchema,\n summary: 'Time travel workflow',\n description: 'Time travels a workflow run, starting from a specific step',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to time travel workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n\n // Fire-and-forget: attach .catch so a rejected time travel cannot become\n // an unhandledRejection and tear down the process.\n void _run.timeTravel({ ...params, requestContext }).catch(error => {\n mastra.getLogger().error('Failed to time travel workflow run', { error, workflowId, runId });\n });\n\n return { message: 'Workflow run time travel started' };\n } catch (error) {\n return handleError(error, 'Error time traveling workflow');\n }\n },\n});\n\nexport const TIME_TRAVEL_STREAM_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/time-travel-stream',\n responseType: 'stream',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: timeTravelBodySchema,\n summary: 'Time travel workflow stream',\n description: 'Time travels a workflow run, starting from a specific step, and streams the results in real-time',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to time travel workflow stream' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n // Validate ownership of existing run before time traveling\n const existingRun = await workflow.getWorkflowRunById(runId);\n if (!existingRun) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n await validateRunOwnership(existingRun, effectiveResourceId, mastra, requestContext);\n\n const serverCache = mastra.getServerCache();\n\n const run = await workflow.createRun({ runId, resourceId: existingRun.resourceId });\n const result = run.timeTravelStream({ ...params, requestContext });\n\n if (serverCache) {\n return cacheRunStream({ cache: serverCache, runId, source: result.fullStream });\n }\n\n return result.fullStream;\n } catch (error) {\n return handleError(error, 'Error time traveling workflow stream');\n }\n },\n});\n\nexport const CANCEL_WORKFLOW_RUN_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/runs/:runId/cancel',\n responseType: 'json',\n pathParamSchema: workflowRunPathParams,\n responseSchema: workflowControlResponseSchema,\n summary: 'Cancel workflow run',\n description: 'Cancels an in-progress workflow execution',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to cancel workflow run' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n\n await _run.cancel();\n\n return { message: 'Workflow run cancelled' };\n } catch (error) {\n return handleError(error, 'Error canceling workflow run');\n }\n },\n});\n\n// Legacy routes (deprecated)\nexport const STREAM_LEGACY_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/stream-legacy',\n responseType: 'stream',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: streamWorkflowBodySchema,\n responseSchema: streamResponseSchema,\n summary: '[DEPRECATED] Stream workflow with legacy format',\n description: 'Legacy endpoint for streaming workflow execution. Use /workflows/:workflowId/stream instead.',\n tags: ['Workflows', 'Legacy'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, resourceId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, resourceId);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const serverCache = mastra.getServerCache();\n\n if (runId) {\n const existingRun = await workflow.getWorkflowRunById(runId, { withNestedWorkflows: false });\n await validateRunOwnership(\n existingRun,\n getEffectiveResourceId(requestContext, undefined),\n mastra,\n requestContext,\n );\n }\n const run = await workflow.createRun({ runId, resourceId: effectiveResourceId });\n const result = run.streamLegacy({\n ...params,\n requestContext,\n onChunk: async chunk => {\n if (serverCache) {\n const cacheKey = runId;\n await serverCache.listPush(cacheKey, chunk);\n }\n },\n });\n\n return result.stream;\n } catch (error) {\n return handleError(error, 'Error executing workflow');\n }\n },\n});\n\nexport const OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/observe-stream-legacy',\n responseType: 'stream',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n responseSchema: streamResponseSchema,\n summary: '[DEPRECATED] Observe workflow stream with legacy format',\n description: 'Legacy endpoint for observing workflow stream. Use /workflows/:workflowId/observe instead.',\n tags: ['Workflows', 'Legacy'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to observe workflow stream' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n const serverCache = mastra.getServerCache();\n if (!serverCache) {\n throw new HTTPException(500, { message: 'Server cache not found' });\n }\n\n // Get cached chunks and create replay stream\n const cachedRunChunks = (await serverCache.listFromTo(runId, 0)) as StreamEvent[];\n const result = _run.observeStreamLegacy();\n\n if (!result.stream) {\n throw new HTTPException(500, { message: 'Failed to create observe stream' });\n }\n\n return createReplayStream<StreamEvent>({\n history: cachedRunChunks,\n liveSource: result.stream,\n });\n } catch (error) {\n return handleError(error, 'Error observing workflow stream');\n }\n },\n});\n\n// ============================================================================\n// Worker Step Execution Endpoint\n// Used by standalone OrchestrationWorker instances with HttpRemoteStrategy.\n// ============================================================================\n\n// Identifies the workflow a nested step runs under, up to the top-level run.\n// Nested workflows are usually reachable only from their parent's step graph.\nexport type StepExecutionParentWorkflow = {\n workflowId: string;\n runId: string;\n executionPath: number[];\n parentWorkflow?: StepExecutionParentWorkflow;\n};\n\nconst stepExecutionParentWorkflowSchema: z.ZodType<StepExecutionParentWorkflow> = z.lazy(() =>\n z.object({\n workflowId: z.string(),\n runId: z.string(),\n executionPath: z.array(z.number().int().nonnegative()),\n parentWorkflow: stepExecutionParentWorkflowSchema.optional(),\n }),\n);\n\n// `workflowId` and `runId` are taken from path params (single source of\n// truth); they are intentionally omitted from the request body schema.\nconst stepExecutionBodySchema = z.object({\n stepId: z.string(),\n executionPath: z.array(z.number().int().nonnegative()),\n parentWorkflow: stepExecutionParentWorkflowSchema.optional(),\n stepResults: z.record(z.string(), z.unknown()),\n state: z.record(z.string(), z.unknown()),\n requestContext: z.record(z.string(), z.unknown()),\n input: z.unknown().optional(),\n resumeData: z.unknown().optional(),\n retryCount: z.number().int().nonnegative().optional(),\n foreachIdx: z.number().int().nonnegative().optional(),\n format: z.enum(['legacy', 'vnext']).optional(),\n perStep: z.boolean().optional(),\n validateInputs: z.boolean().optional(),\n});\n\ntype StepExecutionBody = z.infer<typeof stepExecutionBodySchema>;\n\ninterface StepExecutionHandlerArgs extends StepExecutionBody {\n mastra: Mastra;\n workflowId: string;\n runId: string;\n}\n\n// Reuse the InProcessStrategy across requests for a given Mastra instance.\n// The strategy is stateless beyond its mastra reference, but allocating it\n// per request triggers a dynamic import on the hot path.\n//\n// The dynamic import is required by `pnpm --filter ./packages/server\n// check:core-imports`: `@mastra/core/worker` is a new subpath that older\n// peer-dep floors don't expose, so a static import would fail the check.\n// Once the floor is bumped, this can become a static import.\ntype StepStrategy = { executeStep: (p: unknown) => Promise<unknown> };\nconst strategyByMastra = new WeakMap<Mastra, StepStrategy>();\n\nasync function getStepStrategy(mastra: Mastra): Promise<StepStrategy> {\n let cached = strategyByMastra.get(mastra);\n if (!cached) {\n const { InProcessStrategy } = await import('@mastra/core/worker');\n cached = new InProcessStrategy({ mastra }) as unknown as StepStrategy;\n strategyByMastra.set(mastra, cached);\n }\n return cached;\n}\n\n// Step execution returns the worker's StepResult. Its shape is dynamic\n// and depends on the step's output schema.\nconst stepExecutionResponseSchema = z.unknown();\n\nexport const EXECUTE_WORKFLOW_STEP_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/runs/:runId/steps/execute',\n responseType: 'json',\n pathParamSchema: workflowRunPathParams,\n bodySchema: stepExecutionBodySchema,\n responseSchema: stepExecutionResponseSchema,\n summary: 'Execute a workflow step',\n description:\n 'Internal endpoint used by standalone OrchestrationWorker instances to execute workflow steps remotely via HttpRemoteStrategy.',\n tags: ['Workflows', 'Worker'],\n requiresAuth: true,\n handler: (async ({ mastra, workflowId, runId, ...body }: StepExecutionHandlerArgs) => {\n try {\n // The adapter replaces the body's requestContext with the server-built context.\n const candidate = body.requestContext as unknown as RequestContext | undefined;\n const serverRequestContext = typeof candidate?.get === 'function' ? candidate : undefined;\n const workflowsStore = await mastra.getStorage()?.getStore('workflows');\n const existingRun = await workflowsStore?.getWorkflowRunById({ runId, workflowName: workflowId });\n await validateRunOwnership(\n existingRun,\n getEffectiveResourceId(serverRequestContext, undefined),\n mastra,\n serverRequestContext,\n );\n // Auth is enforced by the framework via `requiresAuth: true` and the\n // deployer's `authenticateToken` provider. Note that when NO auth\n // provider is configured, the framework currently treats the route\n // as public (see ServerAdapter.checkRouteAuth). Operators deploying\n // standalone workers must configure an auth provider to gate this\n // endpoint — there is no implicit fail-closed.\n const strategy = await getStepStrategy(mastra);\n const result = await strategy.executeStep({\n workflowId,\n runId,\n stepId: body.stepId,\n executionPath: body.executionPath,\n parentWorkflow: body.parentWorkflow,\n stepResults: body.stepResults,\n state: body.state,\n requestContext: body.requestContext,\n input: body.input,\n resumeData: body.resumeData,\n retryCount: body.retryCount,\n foreachIdx: body.foreachIdx,\n format: body.format,\n perStep: body.perStep,\n validateInputs: body.validateInputs,\n });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error executing workflow step');\n }\n }) as any,\n});\n\n// Wire shape of an Event delivered through a push-mode broker. Validates the\n// fields `WorkflowEventProcessor` depends on; broker envelopes routinely carry\n// extra metadata that isn't part of `Event` itself, so we passthrough the rest.\n// `createdAt` is an ISO timestamp on the wire — the handler converts it to a\n// `Date` before forwarding to `Mastra.handleWorkflowEvent`.\nconst workflowEventSchema = z.object({\n id: z.string(),\n type: z.string(),\n data: z.unknown(),\n runId: z.string(),\n createdAt: z.string(),\n index: z.number().optional(),\n deliveryAttempt: z.number().optional(),\n});\n\nconst receiveWorkflowEventBodySchema = z.object({\n event: workflowEventSchema.passthrough(),\n});\n\nconst receiveWorkflowEventResponseSchema = z.object({\n ok: z.boolean(),\n retry: z.boolean().optional(),\n});\n\ninterface ReceiveWorkflowEventHandlerArgs {\n mastra: Mastra;\n event: Event;\n requestContext?: RequestContext;\n}\n\n/**\n * Generic push receive endpoint for workflow events. A push-mode broker\n * (GCP Pub/Sub push subscription, SNS, EventBridge) — or a per-broker adapter\n * that decodes the broker's envelope first — POSTs each event here and the\n * response code tells the broker whether to retry:\n *\n * - 200/204 → ack\n * - 5xx → transient, retry with backoff\n * - 4xx → poison, drop / send to DLQ\n *\n * Auth is enforced through the framework's standard `requiresAuth` flow.\n * Operators MUST configure an `authenticateToken` provider that recognizes\n * whatever credential the broker attaches (e.g. a Google-signed OIDC token\n * for GCP Pub/Sub push). Without an auth provider the endpoint is effectively\n * public — same caveat as `EXECUTE_WORKFLOW_STEP_ROUTE`.\n */\nexport const RECEIVE_WORKFLOW_EVENT_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/events',\n responseType: 'json',\n bodySchema: receiveWorkflowEventBodySchema,\n responseSchema: receiveWorkflowEventResponseSchema,\n summary: 'Receive a workflow event from a push-mode broker',\n description:\n 'Push-mode entry point for workflow events. Brokers (GCP Pub/Sub push, SNS, EventBridge) POST each event here; Mastra processes it through the same pipeline as pull-mode workers.',\n tags: ['Workflows', 'Worker'],\n requiresAuth: true,\n // Broker push endpoint: it advances runtime state rather than editing\n // definitions, so `workflows:execute` is the more accurate fit. `write` is\n // kept for back-compat with service principals that already grant it.\n requiresPermission: ['workflows:write', 'workflows:execute'],\n handler: (async ({ mastra, event, requestContext }: ReceiveWorkflowEventHandlerArgs) => {\n try {\n const workflowName = (event.data as { workflowId?: unknown } | undefined)?.workflowId;\n const workflowsStore = await mastra.getStorage()?.getStore('workflows');\n const existingRun = await workflowsStore?.getWorkflowRunById({\n runId: event.runId,\n ...(typeof workflowName === 'string' ? { workflowName } : {}),\n });\n await validateRunOwnership(\n existingRun,\n getEffectiveResourceId(requestContext, undefined),\n mastra,\n requestContext,\n );\n // The wire schema carries `createdAt` as a string; coerce to Date here\n // before handing off to the in-process pipeline, which expects an `Event`.\n const rawCreatedAt = (event as unknown as { createdAt: unknown }).createdAt;\n const createdAt = rawCreatedAt instanceof Date ? rawCreatedAt : new Date(rawCreatedAt as string);\n if (Number.isNaN(createdAt.getTime())) {\n throw new HTTPException(400, { message: 'Invalid createdAt' });\n }\n return await mastra.handleWorkflowEvent({ ...event, createdAt });\n } catch (error) {\n return handleError(error, 'Error receiving workflow event');\n }\n }) as any,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,MAAM,wBAA6C;CAAC;CAAW;CAAU;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jE,SAAS,OAAO;GACd,OAAO,YAAY,OAAO,gCAAgC;EAC5D;CACF;AACF,CAAC"}
1
+ {"version":3,"file":"workflows-DrDssVnE.js","names":[],"sources":["../src/server/handlers/workflows.ts"],"sourcesContent":["import type { Mastra } from '@mastra/core';\nimport type { MastraServerCache } from '@mastra/core/cache';\nimport type { RequestContext } from '@mastra/core/di';\nimport type { Event } from '@mastra/core/events';\nimport { createReplayStream } from '@mastra/core/stream';\nimport type {\n WorkflowInfo,\n ChunkType,\n StreamEvent,\n WorkflowStateField,\n WorkflowRunStatus,\n WorkflowRunState,\n} from '@mastra/core/workflows';\nimport { z } from 'zod/v4';\nimport { MastraFGAPermissions } from '../fga-permissions';\nimport { HTTPException } from '../http-exception';\nimport { streamResponseSchema } from '../schemas/agents';\nimport { optionalRunIdSchema, runIdSchema } from '../schemas/common';\nimport {\n createWorkflowRunBodySchema,\n createWorkflowRunResponseSchema,\n listWorkflowRunsQuerySchema,\n listWorkflowsResponseSchema,\n workflowRunCountsResponseSchema,\n restartBodySchema,\n timeTravelBodySchema,\n resumeBodySchema,\n startAsyncWorkflowBodySchema,\n streamWorkflowBodySchema,\n workflowControlResponseSchema,\n workflowExecutionResultSchema,\n workflowIdPathParams,\n workflowInfoSchema,\n workflowRunPathParams,\n workflowRunsResponseSchema,\n workflowRunResultQuerySchema,\n workflowRunResultSchema,\n observeWorkflowQuerySchema,\n} from '../schemas/workflows';\nimport { createRoute } from '../server-adapter/routes/route-builder';\nimport type { Context } from '../types';\nimport { getWorkflowInfo, WorkflowRegistry } from '../utils';\nimport { handleError } from './error';\nimport { getEffectiveResourceId, getHandlerFGAProvider, getPublicWorkflowById, validateRunOwnership } from './utils';\n\n/**\n * Statuses a run cannot come back from. Streaming one of these runIds again would\n * start a fresh execution under the same runId and overwrite its stored snapshot —\n * the in-memory de-dupe that protects concurrent streams only covers runs still held\n * in the workflow's run map, and a finished run has already been dropped from it.\n */\nconst TERMINAL_RUN_STATUSES: WorkflowRunStatus[] = ['success', 'failed', 'canceled', 'tripwire'];\n\n/**\n * Runs whose chunks are already being written to the cache in this process,\n * keyed by runId. A run has exactly one writer: without this, two concurrent\n * requests for the same runId each cache every chunk and the replayed history\n * comes back duplicated.\n */\nconst activeRunStreamCachers = new Set<string>();\n\n/**\n * Cache a run's chunks for later replay and return the stream to hand the client.\n *\n * The cached history belongs to the run, not to whoever happens to be watching,\n * so the caching side is driven by its own reader rather than by the client's\n * consumption. If the client disconnects mid-run its branch is cancelled while\n * this reader keeps draining, so `/observe` still replays a complete history —\n * the failure that makes reconnection necessary is exactly the one the cache has\n * to survive. Chunks buffer in the tee while a client lags, bounded by the run's\n * own length.\n */\nfunction cacheRunStream({\n cache,\n runId,\n source,\n}: {\n cache: MastraServerCache;\n runId: string;\n source: ReadableStream<ChunkType>;\n}): ReadableStream<ChunkType> {\n if (activeRunStreamCachers.has(runId)) {\n return source;\n }\n\n const [toCache, toClient] = source.tee();\n activeRunStreamCachers.add(runId);\n\n void (async () => {\n const reader = toCache.getReader();\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n // Cache failures must not take down the run being streamed.\n await cache.listPush(runId, value).catch(() => {});\n }\n } catch {\n // The source errored; the client's branch surfaces it.\n } finally {\n reader.releaseLock();\n activeRunStreamCachers.delete(runId);\n }\n })();\n\n return toClient;\n}\n\nexport interface WorkflowContext extends Context {\n workflowId?: string;\n runId?: string;\n requestContext?: RequestContext;\n}\n\nasync function listWorkflowsFromSystem({ mastra, workflowId }: WorkflowContext) {\n const logger = mastra.getLogger();\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n let workflow;\n\n // First check registry for temporary workflows\n workflow = WorkflowRegistry.getWorkflow(workflowId);\n\n if (!workflow) {\n workflow = getPublicWorkflowById(mastra, workflowId);\n }\n\n if (!workflow) {\n logger.debug('Workflow not found, searching agents for workflow', { workflowId });\n const agents = mastra.listAgents();\n\n if (Object.keys(agents || {}).length) {\n for (const [_, agent] of Object.entries(agents)) {\n try {\n const workflows = await agent.listWorkflows();\n\n if (workflows[workflowId]) {\n workflow = workflows[workflowId];\n break;\n }\n } catch (error) {\n logger.debug('Error getting workflow from agent', error);\n }\n }\n }\n }\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n return { workflow };\n}\n\n// ============================================================================\n// Route Definitions (new pattern - handlers defined inline with createRoute)\n// ============================================================================\n\nexport const LIST_WORKFLOWS_ROUTE = createRoute({\n method: 'GET',\n path: '/workflows',\n responseType: 'json',\n queryParamSchema: z.object({\n partial: z.string().optional(),\n }),\n responseSchema: listWorkflowsResponseSchema,\n summary: 'List all workflows',\n description: 'Returns a list of all available workflows in the system',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: (async ({ mastra, partial, requestContext }: any) => {\n try {\n const workflows = mastra.listWorkflows({ serialized: false });\n const isPartial = partial === 'true';\n const _workflows = Object.entries(workflows).reduce<Record<string, WorkflowInfo>>((acc, [key, workflow]) => {\n acc[key] = getWorkflowInfo(workflow as any, isPartial);\n return acc;\n }, {});\n\n // Filter workflows by FGA if configured\n const fgaProvider = getHandlerFGAProvider(mastra, requestContext);\n const user = requestContext?.get('user');\n if (fgaProvider) {\n if (!user) {\n return {};\n }\n const workflowList = Object.entries(_workflows).map(([id, w]) => ({ id, ...w }));\n const accessible = await fgaProvider.filterAccessible(\n user,\n workflowList,\n 'workflow',\n MastraFGAPermissions.WORKFLOWS_READ,\n );\n const accessibleSet = new Set(accessible.map((w: any) => w.id));\n for (const id of Object.keys(_workflows)) {\n if (!accessibleSet.has(id)) {\n delete _workflows[id];\n }\n }\n }\n\n return _workflows;\n } catch (error) {\n return handleError(error, 'Error getting workflows');\n }\n }) as any,\n});\n\ntype WorkflowRunCounts = { running: number; suspended: number };\n\nconst RUN_COUNTS_CACHE_TTL_MS = 5_000;\n// Keyed by Mastra instance so multiple apps in one process never share counts.\nconst runCountsCache = new WeakMap<object, { at: number; value: Record<string, WorkflowRunCounts> }>();\nlet runCountsNow: () => number = () => Date.now();\n\n/** Test seam — lets TTL expiry be tested without wall-clock waits. */\nexport function __setWorkflowRunCountsNow(now?: () => number) {\n runCountsNow = now ?? (() => Date.now());\n}\n\nexport const LIST_WORKFLOW_RUN_COUNTS_ROUTE = createRoute({\n method: 'GET',\n path: '/workflows/run-counts',\n responseType: 'json',\n responseSchema: workflowRunCountsResponseSchema,\n summary: 'List workflow run counts',\n description:\n 'Returns per-workflow counts of currently running and suspended (awaiting resume) runs, keyed by the workflow registry key used in the Mastra config',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: (async ({ mastra, requestContext }: any) => {\n try {\n const fgaProvider = getHandlerFGAProvider(mastra, requestContext);\n const user = requestContext?.get('user');\n // FGA with no user can never see anything — answer before touching storage.\n if (fgaProvider && !user) {\n return {};\n }\n\n const workflows = mastra.listWorkflows({ serialized: false });\n\n const counts: Record<string, WorkflowRunCounts> = {};\n const workflowIdToRegistryKey = new Map<string, string>();\n for (const [registryKey, workflow] of Object.entries(workflows)) {\n counts[registryKey] = { running: 0, suspended: 0 };\n workflowIdToRegistryKey.set((workflow as any).id, registryKey);\n }\n\n // Runs are scoped to the caller like the runs-listing endpoint: the\n // reserved request-context resource id takes precedence for security.\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n // The shared cache holds the unscoped, unfiltered map — usable only when\n // neither per-user FGA filtering nor a resource scope applies.\n const cacheable = !fgaProvider && !effectiveResourceId;\n if (cacheable) {\n const cached = runCountsCache.get(mastra);\n if (cached && runCountsNow() - cached.at < RUN_COUNTS_CACHE_TTL_MS) {\n return cached.value;\n }\n }\n\n const storage = mastra.getStorage();\n const workflowsStore = storage ? await storage.getStore('workflows') : undefined;\n if (workflowsStore) {\n // Cross-workflow, engine-agnostic: both execution engines persist run\n // status into the same store. Deliberately not listActiveWorkflowRuns,\n // which means running+waiting and covers the default engine only.\n const [running, suspended] = await Promise.all([\n workflowsStore.listWorkflowRuns({ status: 'running', resourceId: effectiveResourceId }),\n workflowsStore.listWorkflowRuns({ status: 'suspended', resourceId: effectiveResourceId }),\n ]);\n for (const run of running.runs) {\n const registryKey = workflowIdToRegistryKey.get(run.workflowName);\n const entry = registryKey ? counts[registryKey] : undefined;\n if (entry) entry.running++;\n }\n for (const run of suspended.runs) {\n const registryKey = workflowIdToRegistryKey.get(run.workflowName);\n const entry = registryKey ? counts[registryKey] : undefined;\n if (entry) entry.suspended++;\n }\n }\n\n if (fgaProvider) {\n const workflowList = Object.keys(counts).map(id => ({ id }));\n const accessible = await fgaProvider.filterAccessible(\n user,\n workflowList,\n 'workflow',\n MastraFGAPermissions.WORKFLOWS_READ,\n );\n const accessibleSet = new Set(accessible.map((w: any) => w.id));\n for (const id of Object.keys(counts)) {\n if (!accessibleSet.has(id)) {\n delete counts[id];\n }\n }\n return counts;\n }\n\n if (cacheable) {\n runCountsCache.set(mastra, { at: runCountsNow(), value: counts });\n }\n return counts;\n } catch (error) {\n return handleError(error, 'Error getting workflow run counts');\n }\n }) as any,\n});\n\nexport const GET_WORKFLOW_BY_ID_ROUTE = createRoute({\n method: 'GET',\n path: '/workflows/:workflowId',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n responseSchema: workflowInfoSchema,\n summary: 'Get workflow by ID',\n description: 'Returns details for a specific workflow',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: (async ({ mastra, workflowId }: any) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n return getWorkflowInfo(workflow, false);\n } catch (error) {\n return handleError(error, 'Error getting workflow');\n }\n }) as any,\n});\n\nexport const LIST_WORKFLOW_RUNS_ROUTE = createRoute({\n method: 'GET',\n path: '/workflows/:workflowId/runs',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: listWorkflowRunsQuerySchema,\n responseSchema: workflowRunsResponseSchema,\n summary: 'List workflow runs',\n description: 'Returns a paginated list of execution runs for the specified workflow',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({\n mastra,\n workflowId,\n fromDate,\n toDate,\n page,\n perPage,\n limit,\n offset,\n resourceId,\n status,\n summary,\n requestContext,\n }) => {\n try {\n // Use effective resourceId (context key takes precedence over client-provided value)\n const effectiveResourceId = getEffectiveResourceId(requestContext, resourceId);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n // Support both page/perPage and limit/offset for backwards compatibility\n // If page/perPage provided, use directly; otherwise convert from limit/offset\n let finalPage = page;\n let finalPerPage = perPage;\n\n if (finalPerPage === undefined && limit !== undefined) {\n finalPerPage = limit;\n }\n if (finalPage === undefined && offset !== undefined && finalPerPage !== undefined && finalPerPage > 0) {\n finalPage = Math.floor(offset / finalPerPage);\n }\n\n if (\n finalPerPage !== undefined &&\n (typeof finalPerPage !== 'number' || !Number.isInteger(finalPerPage) || finalPerPage <= 0)\n ) {\n throw new HTTPException(400, { message: 'perPage must be a positive integer' });\n }\n if (finalPage !== undefined && (!Number.isInteger(finalPage) || finalPage < 0)) {\n throw new HTTPException(400, { message: 'page must be a non-negative integer' });\n }\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n const workflowRuns = (await workflow.listWorkflowRuns({\n fromDate: fromDate ? (typeof fromDate === 'string' ? new Date(fromDate) : fromDate) : undefined,\n toDate: toDate ? (typeof toDate === 'string' ? new Date(toDate) : toDate) : undefined,\n perPage: finalPerPage,\n page: finalPage,\n resourceId: effectiveResourceId,\n status,\n ...(summary ? { summary: true } : {}),\n })) || {\n runs: [],\n total: 0,\n };\n if (summary) {\n // Adapters may ignore `summary`, so always trim here to keep the response small.\n return {\n ...workflowRuns,\n runs: workflowRuns.runs.map(run => ({ ...run, snapshot: toSummarySnapshot(run.snapshot) })),\n };\n }\n return workflowRuns;\n } catch (error) {\n return handleError(error, 'Error getting workflow runs');\n }\n },\n});\n\nfunction toSummarySnapshot(\n snapshot: WorkflowRunState | string,\n): Pick<WorkflowRunState, 'status' | 'timestamp'> | string {\n let parsed: unknown;\n if (typeof snapshot === 'string') {\n try {\n parsed = JSON.parse(snapshot);\n } catch {\n // Never echo an unparseable (possibly huge) snapshot back in summary mode.\n return '';\n }\n } else {\n parsed = snapshot;\n }\n if (!parsed || typeof parsed !== 'object') return '';\n const { status, timestamp } = parsed as WorkflowRunState;\n return { status, timestamp };\n}\n\nexport const GET_WORKFLOW_RUN_BY_ID_ROUTE = createRoute({\n method: 'GET',\n path: '/workflows/:workflowId/runs/:runId',\n responseType: 'json',\n pathParamSchema: workflowRunPathParams,\n queryParamSchema: workflowRunResultQuerySchema,\n responseSchema: workflowRunResultSchema,\n summary: 'Get workflow run by ID',\n description:\n 'Returns a workflow run with metadata and processed execution state. Use the fields query parameter to reduce payload size by requesting only specific fields (e.g., ?fields=result,steps). Available fields: result, error, payload, steps, activeStepsPath, serializedStepGraph. Metadata fields (runId, workflowName, resourceId, createdAt, updatedAt) and status are always included.',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, fields, withNestedWorkflows, requestContext }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'Run ID is required' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n // Parse fields parameter (comma-separated string)\n const fieldList = fields ? (fields.split(',').map((f: string) => f.trim()) as WorkflowStateField[]) : undefined;\n\n const run = await workflow.getWorkflowRunById(runId, {\n withNestedWorkflows: withNestedWorkflows !== 'false', // Default to true unless explicitly 'false'\n fields: fieldList,\n });\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\n\n return run;\n } catch (error) {\n return handleError(error, 'Error getting workflow run');\n }\n },\n});\n\nexport const DELETE_WORKFLOW_RUN_BY_ID_ROUTE = createRoute({\n method: 'DELETE',\n path: '/workflows/:workflowId/runs/:runId',\n responseType: 'json',\n pathParamSchema: workflowRunPathParams,\n responseSchema: workflowControlResponseSchema,\n summary: 'Delete workflow run by ID',\n description: 'Deletes a specific workflow run by ID',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'Run ID is required' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n // Validate ownership before deletion\n const run = await workflow.getWorkflowRunById(runId);\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\n\n await workflow.deleteWorkflowRunById(runId);\n\n return { message: 'Workflow run deleted' };\n } catch (error) {\n return handleError(error, 'Error deleting workflow run');\n }\n },\n});\n\nexport const CREATE_WORKFLOW_RUN_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/create-run',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: optionalRunIdSchema,\n bodySchema: createWorkflowRunBodySchema,\n responseSchema: createWorkflowRunResponseSchema,\n summary: 'Create workflow run',\n description: 'Creates a new workflow execution instance with an optional custom run ID',\n tags: ['Workflows'],\n requiresAuth: true,\n // Creating a run is part of the execute flow (Studio/UI calls this before\n // starting/streaming a workflow), so allow either permission. `write` is kept\n // for back-compat with roles that already grant it.\n requiresPermission: ['workflows:write', 'workflows:execute'],\n handler: async ({ mastra, workflowId, runId, resourceId, disableScorers, requestContext }) => {\n try {\n // Use effective resourceId (context key takes precedence over client-provided value)\n const effectiveResourceId = getEffectiveResourceId(requestContext, resourceId);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n if (runId) {\n const existingRun = await workflow.getWorkflowRunById(runId, { withNestedWorkflows: false });\n await validateRunOwnership(\n existingRun,\n getEffectiveResourceId(requestContext, undefined),\n mastra,\n requestContext,\n );\n }\n const run = await workflow.createRun({ runId, resourceId: effectiveResourceId, disableScorers });\n\n return { runId: run.runId };\n } catch (error) {\n return handleError(error, 'Error creating workflow run');\n }\n },\n});\n\nexport const STREAM_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/stream',\n responseType: 'stream',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: streamWorkflowBodySchema,\n summary: 'Stream workflow execution',\n description: 'Executes a workflow and streams the results in real-time',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, resourceId, requestContext, ...params }) => {\n try {\n // Use effective resourceId (context key takes precedence over client-provided value)\n const effectiveResourceId = getEffectiveResourceId(requestContext, resourceId);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to stream workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const existingRun = await workflow.getWorkflowRunById(runId, { withNestedWorkflows: false });\n await validateRunOwnership(\n existingRun,\n getEffectiveResourceId(requestContext, undefined),\n mastra,\n requestContext,\n );\n\n if (existingRun && TERMINAL_RUN_STATUSES.includes(existingRun.status)) {\n throw new HTTPException(409, {\n message:\n `Workflow run ${runId} already finished with status \"${existingRun.status}\". ` +\n `Use /observe to read its stream back, or stream a new runId.`,\n });\n }\n\n const serverCache = mastra.getServerCache();\n\n const run = await workflow.createRun({ runId, resourceId: effectiveResourceId });\n const result = run.stream({ ...params, requestContext });\n\n if (serverCache) {\n return cacheRunStream({ cache: serverCache, runId, source: result.fullStream });\n }\n\n return result.fullStream;\n } catch (error) {\n return handleError(error, 'Error streaming workflow');\n }\n },\n});\n\nexport const RESUME_STREAM_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/resume-stream',\n responseType: 'stream',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: resumeBodySchema,\n responseSchema: streamResponseSchema,\n summary: 'Resume workflow stream',\n description: 'Resumes a suspended workflow execution and continues streaming results',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n const serverCache = mastra.getServerCache();\n\n const resumeResult = _run.resumeStream({ ...params, requestContext });\n\n if (serverCache) {\n return cacheRunStream({ cache: serverCache, runId, source: resumeResult.fullStream });\n }\n\n return resumeResult.fullStream;\n } catch (error) {\n return handleError(error, 'Error resuming workflow');\n }\n },\n});\n\nexport const START_ASYNC_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/start-async',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: optionalRunIdSchema,\n bodySchema: startAsyncWorkflowBodySchema,\n responseSchema: workflowExecutionResultSchema,\n summary: 'Start workflow asynchronously',\n description: 'Starts a workflow execution asynchronously without streaming results',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, resourceId, requestContext, ...params }) => {\n try {\n // Use effective resourceId (context key takes precedence over client-provided value)\n const effectiveResourceId = getEffectiveResourceId(requestContext, resourceId);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n if (runId) {\n const existingRun = await workflow.getWorkflowRunById(runId, { withNestedWorkflows: false });\n await validateRunOwnership(\n existingRun,\n getEffectiveResourceId(requestContext, undefined),\n mastra,\n requestContext,\n );\n }\n const _run = await workflow.createRun({ runId, resourceId: effectiveResourceId });\n const result = await _run.start({ ...params, requestContext });\n return result;\n } catch (error) {\n return handleError(error, 'Error starting async workflow');\n }\n },\n});\n\nexport const START_WORKFLOW_RUN_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/start',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: startAsyncWorkflowBodySchema,\n responseSchema: workflowControlResponseSchema,\n summary: 'Start specific workflow run',\n description: 'Starts execution of a specific workflow run by ID',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to start run' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n // Fire-and-forget: attach .catch so a rejected start (e.g. invalid input\n // schema) cannot become an unhandledRejection and tear down the process.\n void _run\n .start({\n ...params,\n requestContext,\n })\n .catch(error => {\n mastra.getLogger().error('Failed to start workflow run', { error, workflowId, runId });\n });\n\n return { message: 'Workflow run started' };\n } catch (e) {\n return handleError(e, 'Error starting workflow run');\n }\n },\n});\n\nexport const OBSERVE_STREAM_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/observe',\n responseType: 'stream',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: observeWorkflowQuerySchema,\n responseSchema: streamResponseSchema,\n summary: 'Observe workflow stream',\n description:\n 'Observes and streams updates from an already running workflow execution. Supports position-based resume with offset for efficient reconnection.',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, offset, requestContext }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to observe workflow stream' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n const serverCache = mastra.getServerCache();\n if (!serverCache) {\n throw new HTTPException(500, { message: 'Server cache not found' });\n }\n\n // Get cached chunks from the specified index (or 0 if not specified)\n const startIndex = offset ?? 0;\n const cachedRunChunks = (await serverCache.listFromTo(runId, startIndex)) as ChunkType[];\n const liveStream = _run.observeStream();\n\n return createReplayStream<ChunkType>({\n history: cachedRunChunks,\n liveSource: liveStream,\n });\n } catch (error) {\n return handleError(error, 'Error observing workflow stream');\n }\n },\n});\n\nexport const RESUME_ASYNC_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/resume-async',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: resumeBodySchema,\n responseSchema: workflowExecutionResultSchema,\n summary: 'Resume workflow asynchronously',\n description: 'Resumes a suspended workflow execution asynchronously without streaming',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n const result = await _run.resume({ ...params, requestContext });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error resuming workflow step');\n }\n },\n});\n\n/**\n * Fire-and-forget resume: dispatches the resume and returns immediately with the runId,\n * without waiting for the workflow to complete. For Inngest-backed workflows this avoids\n * the `getRunOutput()` polling race that the awaiting `resume-async` route can hit.\n *\n * TODO(v2): in Mastra v2 this fire-and-forget behavior should become the behavior of the\n * `resume-async` route (and `Run.resumeAsync()`), and this route should be removed. It is\n * kept separate in v1 to avoid a breaking change to the existing `resume-async` response\n * contract (which returns the full workflow result).\n */\nexport const RESUME_NO_WAIT_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/resume-no-wait',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: resumeBodySchema,\n responseSchema: createWorkflowRunResponseSchema,\n summary: 'Resume workflow without waiting',\n description:\n 'Resumes a suspended workflow execution without waiting (fire-and-forget) and returns immediately with the runId. The workflow continues executing in the background.',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n const result = await _run.resumeAsync({ ...params, requestContext });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error resuming workflow step');\n }\n },\n});\n\nexport const RESUME_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/resume',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: resumeBodySchema,\n responseSchema: workflowControlResponseSchema,\n summary: 'Resume workflow',\n description: 'Resumes a suspended workflow execution from a specific step',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n\n // Fire-and-forget: attach .catch so a rejected resume cannot become an\n // unhandledRejection and tear down the process.\n void _run.resume({ ...params, requestContext }).catch(error => {\n mastra.getLogger().error('Failed to resume workflow run', { error, workflowId, runId });\n });\n\n return { message: 'Workflow run resumed' };\n } catch (error) {\n return handleError(error, 'Error resuming workflow');\n }\n },\n});\n\nexport const RESTART_ASYNC_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/restart-async',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: restartBodySchema,\n responseSchema: workflowExecutionResultSchema,\n summary: 'Restart workflow asynchronously',\n description: 'Restarts an active workflow execution asynchronously',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to restart workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n const result = await _run.restart({ ...params, requestContext });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error restarting workflow');\n }\n },\n});\n\nexport const RESTART_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/restart',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: restartBodySchema,\n responseSchema: workflowControlResponseSchema,\n summary: 'Restart workflow',\n description: 'Restarts an active workflow execution',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to restart workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n\n void _run.restart({ ...params, requestContext }).catch(error => {\n mastra.getLogger().error('Failed to restart workflow run in background', { error, workflowId, runId });\n });\n\n return { message: 'Workflow run restarted' };\n } catch (error) {\n return handleError(error, 'Error restarting workflow');\n }\n },\n});\n\nexport const RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ASYNC_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/restart-all-active-workflow-runs-async',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n responseSchema: workflowControlResponseSchema,\n summary: 'Restart all active workflow runs asynchronously',\n description: 'Restarts all active workflow runs asynchronously',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, requestContext }) => {\n try {\n // Restarting every active run spans all owners, so only a privileged caller may do it:\n // checked as access to a run with no owner.\n await validateRunOwnership(\n { resourceId: null },\n getEffectiveResourceId(requestContext, undefined),\n mastra,\n requestContext,\n );\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n await workflow.restartAllActiveWorkflowRuns();\n\n return { message: 'All active workflow runs restarted' };\n } catch (error) {\n return handleError(error, 'Error restarting workflow');\n }\n },\n});\n\nexport const RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/restart-all-active-workflow-runs',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n responseSchema: workflowControlResponseSchema,\n summary: 'Restart all active workflow runs',\n description: 'Restarts all active workflow runs',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, requestContext }) => {\n try {\n // Restarting every active run spans all owners, so only a privileged caller may do it:\n // checked as access to a run with no owner.\n await validateRunOwnership(\n { resourceId: null },\n getEffectiveResourceId(requestContext, undefined),\n mastra,\n requestContext,\n );\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n void workflow.restartAllActiveWorkflowRuns().catch(error => {\n mastra.getLogger().error('Failed to restart active workflow runs', { error, workflowId });\n });\n\n return { message: 'All active workflow runs restarted' };\n } catch (error) {\n return handleError(error, 'Error restarting workflow');\n }\n },\n});\n\nexport const TIME_TRAVEL_ASYNC_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/time-travel-async',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: timeTravelBodySchema,\n responseSchema: workflowExecutionResultSchema,\n summary: 'Time travel workflow asynchronously',\n description: 'Time travels a workflow run asynchronously without streaming',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to time travel workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n const result = await _run.timeTravel({ ...params, requestContext });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error time traveling workflow');\n }\n },\n});\n\nexport const TIME_TRAVEL_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/time-travel',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: timeTravelBodySchema,\n responseSchema: workflowControlResponseSchema,\n summary: 'Time travel workflow',\n description: 'Time travels a workflow run, starting from a specific step',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to time travel workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n\n // Fire-and-forget: attach .catch so a rejected time travel cannot become\n // an unhandledRejection and tear down the process.\n void _run.timeTravel({ ...params, requestContext }).catch(error => {\n mastra.getLogger().error('Failed to time travel workflow run', { error, workflowId, runId });\n });\n\n return { message: 'Workflow run time travel started' };\n } catch (error) {\n return handleError(error, 'Error time traveling workflow');\n }\n },\n});\n\nexport const TIME_TRAVEL_STREAM_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/time-travel-stream',\n responseType: 'stream',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: timeTravelBodySchema,\n summary: 'Time travel workflow stream',\n description: 'Time travels a workflow run, starting from a specific step, and streams the results in real-time',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to time travel workflow stream' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n // Validate ownership of existing run before time traveling\n const existingRun = await workflow.getWorkflowRunById(runId);\n if (!existingRun) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n await validateRunOwnership(existingRun, effectiveResourceId, mastra, requestContext);\n\n const serverCache = mastra.getServerCache();\n\n const run = await workflow.createRun({ runId, resourceId: existingRun.resourceId });\n const result = run.timeTravelStream({ ...params, requestContext });\n\n if (serverCache) {\n return cacheRunStream({ cache: serverCache, runId, source: result.fullStream });\n }\n\n return result.fullStream;\n } catch (error) {\n return handleError(error, 'Error time traveling workflow stream');\n }\n },\n});\n\nexport const CANCEL_WORKFLOW_RUN_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/runs/:runId/cancel',\n responseType: 'json',\n pathParamSchema: workflowRunPathParams,\n responseSchema: workflowControlResponseSchema,\n summary: 'Cancel workflow run',\n description: 'Cancels an in-progress workflow execution',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to cancel workflow run' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n\n await _run.cancel();\n\n return { message: 'Workflow run cancelled' };\n } catch (error) {\n return handleError(error, 'Error canceling workflow run');\n }\n },\n});\n\n// Legacy routes (deprecated)\nexport const STREAM_LEGACY_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/stream-legacy',\n responseType: 'stream',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: streamWorkflowBodySchema,\n responseSchema: streamResponseSchema,\n summary: '[DEPRECATED] Stream workflow with legacy format',\n description: 'Legacy endpoint for streaming workflow execution. Use /workflows/:workflowId/stream instead.',\n tags: ['Workflows', 'Legacy'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, resourceId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, resourceId);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const serverCache = mastra.getServerCache();\n\n if (runId) {\n const existingRun = await workflow.getWorkflowRunById(runId, { withNestedWorkflows: false });\n await validateRunOwnership(\n existingRun,\n getEffectiveResourceId(requestContext, undefined),\n mastra,\n requestContext,\n );\n }\n const run = await workflow.createRun({ runId, resourceId: effectiveResourceId });\n const result = run.streamLegacy({\n ...params,\n requestContext,\n onChunk: async chunk => {\n if (serverCache) {\n const cacheKey = runId;\n await serverCache.listPush(cacheKey, chunk);\n }\n },\n });\n\n return result.stream;\n } catch (error) {\n return handleError(error, 'Error executing workflow');\n }\n },\n});\n\nexport const OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/observe-stream-legacy',\n responseType: 'stream',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n responseSchema: streamResponseSchema,\n summary: '[DEPRECATED] Observe workflow stream with legacy format',\n description: 'Legacy endpoint for observing workflow stream. Use /workflows/:workflowId/observe instead.',\n tags: ['Workflows', 'Legacy'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to observe workflow stream' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n const serverCache = mastra.getServerCache();\n if (!serverCache) {\n throw new HTTPException(500, { message: 'Server cache not found' });\n }\n\n // Get cached chunks and create replay stream\n const cachedRunChunks = (await serverCache.listFromTo(runId, 0)) as StreamEvent[];\n const result = _run.observeStreamLegacy();\n\n if (!result.stream) {\n throw new HTTPException(500, { message: 'Failed to create observe stream' });\n }\n\n return createReplayStream<StreamEvent>({\n history: cachedRunChunks,\n liveSource: result.stream,\n });\n } catch (error) {\n return handleError(error, 'Error observing workflow stream');\n }\n },\n});\n\n// ============================================================================\n// Worker Step Execution Endpoint\n// Used by standalone OrchestrationWorker instances with HttpRemoteStrategy.\n// ============================================================================\n\n// Identifies the workflow a nested step runs under, up to the top-level run.\n// Nested workflows are usually reachable only from their parent's step graph.\nexport type StepExecutionParentWorkflow = {\n workflowId: string;\n runId: string;\n executionPath: number[];\n parentWorkflow?: StepExecutionParentWorkflow;\n};\n\nconst stepExecutionParentWorkflowSchema: z.ZodType<StepExecutionParentWorkflow> = z.lazy(() =>\n z.object({\n workflowId: z.string(),\n runId: z.string(),\n executionPath: z.array(z.number().int().nonnegative()),\n parentWorkflow: stepExecutionParentWorkflowSchema.optional(),\n }),\n);\n\n// `workflowId` and `runId` are taken from path params (single source of\n// truth); they are intentionally omitted from the request body schema.\nconst stepExecutionBodySchema = z.object({\n stepId: z.string(),\n executionPath: z.array(z.number().int().nonnegative()),\n parentWorkflow: stepExecutionParentWorkflowSchema.optional(),\n stepResults: z.record(z.string(), z.unknown()),\n state: z.record(z.string(), z.unknown()),\n requestContext: z.record(z.string(), z.unknown()),\n input: z.unknown().optional(),\n resumeData: z.unknown().optional(),\n retryCount: z.number().int().nonnegative().optional(),\n foreachIdx: z.number().int().nonnegative().optional(),\n format: z.enum(['legacy', 'vnext']).optional(),\n perStep: z.boolean().optional(),\n validateInputs: z.boolean().optional(),\n});\n\ntype StepExecutionBody = z.infer<typeof stepExecutionBodySchema>;\n\ninterface StepExecutionHandlerArgs extends StepExecutionBody {\n mastra: Mastra;\n workflowId: string;\n runId: string;\n}\n\n// Reuse the InProcessStrategy across requests for a given Mastra instance.\n// The strategy is stateless beyond its mastra reference, but allocating it\n// per request triggers a dynamic import on the hot path.\n//\n// The dynamic import is required by `pnpm --filter ./packages/server\n// check:core-imports`: `@mastra/core/worker` is a new subpath that older\n// peer-dep floors don't expose, so a static import would fail the check.\n// Once the floor is bumped, this can become a static import.\ntype StepStrategy = { executeStep: (p: unknown) => Promise<unknown> };\nconst strategyByMastra = new WeakMap<Mastra, StepStrategy>();\n\nasync function getStepStrategy(mastra: Mastra): Promise<StepStrategy> {\n let cached = strategyByMastra.get(mastra);\n if (!cached) {\n const { InProcessStrategy } = await import('@mastra/core/worker');\n cached = new InProcessStrategy({ mastra }) as unknown as StepStrategy;\n strategyByMastra.set(mastra, cached);\n }\n return cached;\n}\n\n// Step execution returns the worker's StepResult. Its shape is dynamic\n// and depends on the step's output schema.\nconst stepExecutionResponseSchema = z.unknown();\n\nexport const EXECUTE_WORKFLOW_STEP_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/runs/:runId/steps/execute',\n responseType: 'json',\n pathParamSchema: workflowRunPathParams,\n bodySchema: stepExecutionBodySchema,\n responseSchema: stepExecutionResponseSchema,\n summary: 'Execute a workflow step',\n description:\n 'Internal endpoint used by standalone OrchestrationWorker instances to execute workflow steps remotely via HttpRemoteStrategy.',\n tags: ['Workflows', 'Worker'],\n requiresAuth: true,\n handler: (async ({ mastra, workflowId, runId, ...body }: StepExecutionHandlerArgs) => {\n try {\n // The adapter replaces the body's requestContext with the server-built context.\n const candidate = body.requestContext as unknown as RequestContext | undefined;\n const serverRequestContext = typeof candidate?.get === 'function' ? candidate : undefined;\n const workflowsStore = await mastra.getStorage()?.getStore('workflows');\n const existingRun = await workflowsStore?.getWorkflowRunById({ runId, workflowName: workflowId });\n await validateRunOwnership(\n existingRun,\n getEffectiveResourceId(serverRequestContext, undefined),\n mastra,\n serverRequestContext,\n );\n // Auth is enforced by the framework via `requiresAuth: true` and the\n // deployer's `authenticateToken` provider. Note that when NO auth\n // provider is configured, the framework currently treats the route\n // as public (see ServerAdapter.checkRouteAuth). Operators deploying\n // standalone workers must configure an auth provider to gate this\n // endpoint — there is no implicit fail-closed.\n const strategy = await getStepStrategy(mastra);\n const result = await strategy.executeStep({\n workflowId,\n runId,\n stepId: body.stepId,\n executionPath: body.executionPath,\n parentWorkflow: body.parentWorkflow,\n stepResults: body.stepResults,\n state: body.state,\n requestContext: body.requestContext,\n input: body.input,\n resumeData: body.resumeData,\n retryCount: body.retryCount,\n foreachIdx: body.foreachIdx,\n format: body.format,\n perStep: body.perStep,\n validateInputs: body.validateInputs,\n });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error executing workflow step');\n }\n }) as any,\n});\n\n// Wire shape of an Event delivered through a push-mode broker. Validates the\n// fields `WorkflowEventProcessor` depends on; broker envelopes routinely carry\n// extra metadata that isn't part of `Event` itself, so we passthrough the rest.\n// `createdAt` is an ISO timestamp on the wire — the handler converts it to a\n// `Date` before forwarding to `Mastra.handleWorkflowEvent`.\nconst workflowEventSchema = z.object({\n id: z.string(),\n type: z.string(),\n data: z.unknown(),\n runId: z.string(),\n createdAt: z.string(),\n index: z.number().optional(),\n deliveryAttempt: z.number().optional(),\n});\n\nconst receiveWorkflowEventBodySchema = z.object({\n event: workflowEventSchema.passthrough(),\n});\n\nconst receiveWorkflowEventResponseSchema = z.object({\n ok: z.boolean(),\n retry: z.boolean().optional(),\n});\n\ninterface ReceiveWorkflowEventHandlerArgs {\n mastra: Mastra;\n event: Event;\n requestContext?: RequestContext;\n}\n\n/**\n * Generic push receive endpoint for workflow events. A push-mode broker\n * (GCP Pub/Sub push subscription, SNS, EventBridge) — or a per-broker adapter\n * that decodes the broker's envelope first — POSTs each event here and the\n * response code tells the broker whether to retry:\n *\n * - 200/204 → ack\n * - 5xx → transient, retry with backoff\n * - 4xx → poison, drop / send to DLQ\n *\n * Auth is enforced through the framework's standard `requiresAuth` flow.\n * Operators MUST configure an `authenticateToken` provider that recognizes\n * whatever credential the broker attaches (e.g. a Google-signed OIDC token\n * for GCP Pub/Sub push). Without an auth provider the endpoint is effectively\n * public — same caveat as `EXECUTE_WORKFLOW_STEP_ROUTE`.\n */\nexport const RECEIVE_WORKFLOW_EVENT_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/events',\n responseType: 'json',\n bodySchema: receiveWorkflowEventBodySchema,\n responseSchema: receiveWorkflowEventResponseSchema,\n summary: 'Receive a workflow event from a push-mode broker',\n description:\n 'Push-mode entry point for workflow events. Brokers (GCP Pub/Sub push, SNS, EventBridge) POST each event here; Mastra processes it through the same pipeline as pull-mode workers.',\n tags: ['Workflows', 'Worker'],\n requiresAuth: true,\n // Broker push endpoint: it advances runtime state rather than editing\n // definitions, so `workflows:execute` is the more accurate fit. `write` is\n // kept for back-compat with service principals that already grant it.\n requiresPermission: ['workflows:write', 'workflows:execute'],\n handler: (async ({ mastra, event, requestContext }: ReceiveWorkflowEventHandlerArgs) => {\n try {\n const workflowName = (event.data as { workflowId?: unknown } | undefined)?.workflowId;\n const workflowsStore = await mastra.getStorage()?.getStore('workflows');\n const existingRun = await workflowsStore?.getWorkflowRunById({\n runId: event.runId,\n ...(typeof workflowName === 'string' ? { workflowName } : {}),\n });\n await validateRunOwnership(\n existingRun,\n getEffectiveResourceId(requestContext, undefined),\n mastra,\n requestContext,\n );\n // The wire schema carries `createdAt` as a string; coerce to Date here\n // before handing off to the in-process pipeline, which expects an `Event`.\n const rawCreatedAt = (event as unknown as { createdAt: unknown }).createdAt;\n const createdAt = rawCreatedAt instanceof Date ? rawCreatedAt : new Date(rawCreatedAt as string);\n if (Number.isNaN(createdAt.getTime())) {\n throw new HTTPException(400, { message: 'Invalid createdAt' });\n }\n return await mastra.handleWorkflowEvent({ ...event, createdAt });\n } catch (error) {\n return handleError(error, 'Error receiving workflow event');\n }\n }) as any,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,MAAM,wBAA6C;CAAC;CAAW;CAAU;CAAY;AAAU;;;;;;;AAQ/F,MAAM,yCAAyB,IAAI,IAAY;;;;;;;;;;;;AAa/C,SAAS,eAAe,EACtB,OACA,OACA,UAK4B;CAC5B,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
  "name": "@mastra/server",
3
- "version": "1.82.0-alpha.1",
3
+ "version": "1.82.0-alpha.2",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "files": [
@@ -116,14 +116,14 @@
116
116
  "zod": "^4.6.7",
117
117
  "zod-to-ts": "^2.1.0",
118
118
  "@internal/core": "0.1.4",
119
- "@internal/lint": "0.0.147",
120
119
  "@internal/storage-test-utils": "0.0.143",
121
- "@internal/types-builder": "0.0.122",
120
+ "@internal/lint": "0.0.147",
122
121
  "@internal/test-utils": "0.0.83",
122
+ "@internal/types-builder": "0.0.122",
123
123
  "@internal/voice": "0.0.43",
124
- "@mastra/agent-builder": "1.1.33-alpha.1",
125
124
  "@mastra/schema-compat": "1.3.17",
126
- "@mastra/core": "1.82.0-alpha.1"
125
+ "@mastra/agent-builder": "1.1.33-alpha.2",
126
+ "@mastra/core": "1.82.0-alpha.2"
127
127
  },
128
128
  "homepage": "https://mastra.ai",
129
129
  "repository": {
@@ -1 +0,0 @@
1
- {"version":3,"file":"agents-B5kq2QEV.js","names":[],"sources":["../src/server/schemas/agents.ts"],"sourcesContent":["import type {\n AgentExecutionOptions,\n PublicStructuredOutputOptions,\n ToolsetsInput,\n ToolsInput,\n} from '@mastra/core/agent';\nimport type { CoreMessageV4 } from '@mastra/core/agent/message-list';\nimport type { ScoringSamplingConfig } from '@mastra/core/evals';\nimport type { OutputType, SystemMessage } from '@mastra/core/llm';\nimport type { ReasoningLevel } from '@mastra/core/loop';\nimport { z } from 'zod/v4';\n\n/**\n * Structural mirror of LoopOptions['modelSettings'] (ai-sdk CallSettings minus\n * abortSignal, plus reasoning). CallSettings is not publicly exported from\n * @mastra/core, so its fields are restated here to keep declaration emit portable.\n */\n/**\n * Structural mirror of LoopOptions['stopWhen'] entries. The ai-sdk StopCondition\n * type is not publicly exported from @mastra/core, so an assignable function\n * shape is used to keep declaration emit portable.\n */\ntype StopConditionArg = (event: unknown) => boolean | PromiseLike<boolean>;\n\ntype ModelSettings = {\n maxOutputTokens?: number;\n temperature?: number;\n topP?: number;\n topK?: number;\n presencePenalty?: number;\n frequencyPenalty?: number;\n stopSequences?: string[];\n seed?: number;\n maxRetries?: number;\n headers?: Record<string, string | undefined>;\n reasoning?: ReasoningLevel;\n};\nimport { tracingOptionsSchema, coreMessageSchema, messageResponseSchema, typedPermissive } from './common';\nimport { defaultOptionsSchema } from './default-options';\n\nexport {\n generateSpeechBodySchema,\n getListenerResponseSchema,\n speakResponseSchema,\n transcribeSpeechBodySchema,\n transcribeSpeechResponseSchema,\n voiceSpeakersResponseSchema,\n} from '@internal/voice/routes';\n\ntype JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue };\n\nconst jsonValueSchema: z.ZodType<JsonValue> = z.lazy(() =>\n z.union([\n z.string(),\n z.number(),\n z.boolean(),\n z.null(),\n z.array(jsonValueSchema),\n z.record(z.string(), jsonValueSchema),\n ]),\n);\nconst jsonRecordSchema = z.record(z.string(), jsonValueSchema);\n\nconst signalAttributesSchema = z.record(\n z.string(),\n z.union([z.string(), z.number(), z.boolean(), z.null(), z.undefined()]),\n);\n\nconst baseSignalSchema = z.object({\n id: z.string().optional(),\n createdAt: z.union([z.string(), z.date()]).optional(),\n metadata: jsonRecordSchema.optional(),\n attributes: signalAttributesSchema.optional(),\n});\n\nconst partProviderOptionsSchema = z.record(z.string(), z.record(z.string(), jsonValueSchema)).optional();\n\nconst signalTextPartSchema = z.object({\n type: z.literal('text'),\n text: z.string(),\n providerOptions: partProviderOptionsSchema,\n});\n\nconst signalFilePartSchema = z.object({\n type: z.literal('file'),\n data: z.string(),\n mediaType: z.string(),\n filename: z.string().optional(),\n providerOptions: partProviderOptionsSchema,\n});\n\nconst userMessageSignalContentsSchema = z.union([\n z.string(),\n z.array(z.union([signalTextPartSchema, signalFilePartSchema])),\n]);\n\nconst agentMessageInputObjectSchema = z.object({\n contents: userMessageSignalContentsSchema,\n attributes: signalAttributesSchema.optional(),\n metadata: jsonRecordSchema.optional(),\n providerOptions: z.record(z.string(), z.record(z.string(), jsonValueSchema)).optional(),\n});\n\nconst agentMessageInputSchema = z.union([userMessageSignalContentsSchema, agentMessageInputObjectSchema]);\n\nconst agentSignalBaseSchema = baseSignalSchema.extend({\n tagName: z.string().optional(),\n contents: userMessageSignalContentsSchema,\n providerOptions: z.record(z.string(), z.record(z.string(), jsonValueSchema)).optional(),\n});\n\nconst agentSignalSchema = z.discriminatedUnion('type', [\n agentSignalBaseSchema.extend({\n type: z.literal('state'),\n transient: z.never().optional(),\n }),\n agentSignalBaseSchema.extend({\n type: z.enum(['user', 'reactive', 'notification', 'user-message', 'system-reminder']),\n transient: z.boolean().optional(),\n }),\n]);\n\n// Path parameter schemas\nexport const agentIdPathParams = z.object({\n agentId: z.string().describe('Unique identifier for the agent'),\n});\n\n/**\n * Query params for GET /agents/:agentId — controls which stored config version is used for overrides.\n * When `status` and `versionId` are both provided, `versionId` takes precedence.\n * - `status` — 'draft' (latest version) or 'published' (active published version, default).\n * - `versionId` — Resolve with a specific version ID.\n */\nexport const agentVersionQuerySchema = z.object({\n status: z\n .enum(['draft', 'published'])\n .optional()\n .describe(\n 'Which stored config version to resolve: draft (latest version) or published (active version, default). When both status and versionId are provided, versionId takes precedence.',\n ),\n versionId: z\n .string()\n .optional()\n .describe('Specific version ID to resolve. Takes precedence over status when both are provided.'),\n});\n\nexport const agentPlanQuerySchema = agentVersionQuerySchema.extend({\n path: z.string().describe('Relative path to a markdown plan under .mastracode/plans/'),\n});\n\nexport const agentPlanResponseSchema = z.object({\n path: z.string(),\n content: z.string(),\n});\n\nexport const toolIdPathParams = z.object({\n toolId: z.string().describe('Unique identifier for the tool'),\n});\n\nexport const agentRunPathParams = agentIdPathParams.extend({\n runId: z.string().min(1).describe('Unique identifier for the agent run'),\n});\n\nexport const agentToolPathParams = agentIdPathParams.extend({\n toolId: z.string().describe('Unique identifier for the tool'),\n});\n\nexport const agentSkillPathParams = agentIdPathParams.extend({\n skillName: z.string().describe('Name of the skill'),\n});\n\nexport const modelConfigIdPathParams = agentIdPathParams.extend({\n modelConfigId: z.string().describe('Unique identifier for the model configuration'),\n});\n\n/**\n * Schema for serialized processor metadata\n */\nexport const serializedProcessorSchema = z.object({\n id: z.string(),\n name: z.string().optional(),\n});\n\n/**\n * Schema for serialized tool with JSON schemas\n */\nexport const serializedToolSchema = z.object({\n id: z.string(),\n title: z.string().optional(),\n description: z.string().optional(),\n inputSchema: z.string().optional(),\n outputSchema: z.string().optional(),\n requestContextSchema: z.string().optional(),\n requireApproval: z.boolean().optional(),\n});\n\n/**\n * Schema for serialized workflow with steps\n */\nexport const serializedWorkflowSchema = z.object({\n name: z.string(),\n steps: z\n .record(\n z.string(),\n z.object({\n id: z.string(),\n description: z.string().optional(),\n }),\n )\n .optional(),\n});\n\n/**\n * Schema for serialized agent definition (referenced by other agents)\n */\nexport const serializedAgentDefinitionSchema = z.object({\n id: z.string(),\n name: z.string(),\n});\n\n/**\n * Schema for SystemMessage type\n * Can be string, string[], or various message objects\n */\nconst systemMessageSchema = typedPermissive<SystemMessage>(\n z.union([\n z.string(),\n z.array(z.string()),\n z.unknown(), // CoreSystemMessage or SystemModelMessage\n z.array(z.unknown()),\n ]),\n);\n\n/**\n * Schema for model configuration in model list\n */\nconst modelConfigSchema = z.object({\n id: z.string(),\n enabled: z.boolean(),\n maxRetries: z.number(),\n model: z.object({\n modelId: z.string(),\n provider: z.string(),\n modelVersion: z.string(),\n }),\n});\n\nconst serializedSkillSchema = z.object({\n name: z.string(),\n description: z.string(),\n license: z.string().optional(),\n path: z.string(),\n});\n\nconst agentEditorConfigSchema = z.union([\n z.literal(false),\n z.object({\n instructions: z.boolean().optional(),\n tools: z.union([z.boolean(), z.object({ description: z.boolean().optional() })]).optional(),\n }),\n]);\n\n/**\n * Main schema for serialized agent representation\n */\nexport const serializedAgentSchema = z.object({\n name: z.string(),\n description: z.string().optional(),\n metadata: z.record(z.string(), z.unknown()).optional(),\n instructions: systemMessageSchema.optional(),\n tools: z.record(z.string(), serializedToolSchema),\n agents: z.record(z.string(), serializedAgentDefinitionSchema),\n workflows: z.record(z.string(), serializedWorkflowSchema),\n skills: z.array(serializedSkillSchema),\n workspaceTools: z.array(z.string()),\n browserTools: z.array(z.string()),\n hasBrowser: z.boolean(),\n workspaceId: z.string().optional(),\n inputProcessors: z.array(serializedProcessorSchema),\n outputProcessors: z.array(serializedProcessorSchema),\n provider: z.string().optional(),\n modelId: z.string().optional(),\n modelVersion: z.string().optional(),\n supportsMemory: z.boolean().optional(),\n modelList: z.array(modelConfigSchema).optional(),\n modelListEditable: z\n .boolean()\n .optional()\n .describe('False when the model list comes from a function and cannot be reordered or edited'),\n defaultOptions: defaultOptionsSchema.optional(),\n defaultGenerateOptionsLegacy: z.record(z.string(), z.unknown()).optional(),\n defaultStreamOptionsLegacy: z.record(z.string(), z.unknown()).optional(),\n requestContextSchema: z.string().optional(),\n source: z.enum(['code', 'stored', 'fs']).optional(),\n status: z.enum(['draft', 'published', 'archived']).optional(),\n activeVersionId: z.string().optional(),\n hasDraft: z.boolean().optional(),\n editor: agentEditorConfigSchema.optional(),\n});\n\n/**\n * Schema for agent with ID\n */\nexport const serializedAgentWithIdSchema = serializedAgentSchema.extend({\n id: z.string(),\n});\n\n/**\n * Schema for individual provider information\n */\nexport const providerSchema = z.object({\n id: z.string(),\n name: z.string(),\n label: z.string().optional(),\n description: z.string().optional(),\n envVar: z.union([z.string(), z.array(z.string())]),\n connected: z.boolean(),\n docUrl: z.string().optional(),\n models: z.array(z.string()),\n modelReleaseDates: z.record(z.string(), z.string()).optional(),\n});\n\n/**\n * Schema for providers endpoint response\n */\nexport const providersResponseSchema = z.object({\n providers: z.array(providerSchema),\n});\n\nexport type ProviderListItem = z.infer<typeof providerSchema>;\n\n/**\n * Schema for list agents endpoint response\n * Returns a record of agent ID to serialized agent\n */\nexport const listAgentsResponseSchema = z.record(z.string(), serializedAgentSchema);\n\n/**\n * Schema for list tools endpoint response\n * Returns a record of tool ID to serialized tool\n */\nexport const listToolsResponseSchema = z.record(z.string(), serializedToolSchema);\n\n// ============================================================================\n// Agent Execution Body Schemas\n// ============================================================================\n\n/**\n * Schema for agent memory option\n */\nconst agentMemoryOptionSchema = z.object({\n thread: z.union([z.string(), z.object({ id: z.string() }).passthrough()]),\n /**\n * Optional so authenticated setups can rely on the server-derived resource ID\n * (`mapUserToResourceId` sets MASTRA_RESOURCE_ID_KEY in the request context, which\n * takes precedence over this value). Handlers return a 400 when neither the body\n * nor the request context provides a resource ID.\n */\n resource: z.string().optional(),\n options: z.record(z.string(), z.unknown()).optional(),\n readOnly: z.boolean().optional(),\n});\n\n/**\n * Schema for tool choice configuration\n */\nconst toolChoiceSchema = z.union([\n z.enum(['auto', 'none', 'required']),\n z.object({ type: z.literal('tool'), toolName: z.string() }),\n]);\n\n/**\n * Comprehensive body schema for agent generate and stream endpoints\n * Validates common fields while using passthrough for complex nested objects\n *\n * EXCLUDED FIELDS (not serializable):\n * - Callbacks: onStepFinish, onFinish, onChunk, onError, onAbort, prepareStep\n * - Class instances: inputProcessors, outputProcessors\n * - Non-serializable: abortSignal, tracingContext\n */\nexport const agentExecutionBodySchema = z\n .object({\n // REQUIRED\n messages: z.union([\n z.array(coreMessageSchema), // Array of messages\n z.string(), // Single user message shorthand\n ]),\n\n // Message Configuration\n instructions: systemMessageSchema.optional(),\n system: systemMessageSchema.optional(),\n // ModelMessage[] at runtime; handlers cast since the AI SDK ModelMessage\n // type is not portable for declaration emit.\n context: z.array(coreMessageSchema).optional(),\n\n // Memory & Persistence\n memory: agentMemoryOptionSchema.optional(),\n runId: z.string().optional(),\n savePerStep: z.boolean().optional(),\n\n // Request Context (handler-specific field - merged with server's requestContext)\n requestContext: z.record(z.string(), z.unknown()).optional(),\n\n // Version overrides for sub-agents (and future primitives)\n versions: z\n .object({\n agents: z\n .record(\n z.string(),\n z.union([z.object({ versionId: z.string() }), z.object({ status: z.enum(['draft', 'published']) })]),\n )\n .optional(),\n defaultStatus: z.enum(['draft', 'published']).optional(),\n })\n .optional(),\n\n // Execution Control\n maxSteps: z.number().optional(),\n // Stop conditions are functions and cannot be validated by zod.\n stopWhen: typedPermissive<StopConditionArg | StopConditionArg[]>(z.unknown()).optional(),\n\n // Model Configuration\n model: z.string().optional(),\n providerOptions: z.record(z.string(), z.record(z.string(), jsonValueSchema)).optional(),\n modelSettings: typedPermissive<ModelSettings>(z.unknown()).optional(),\n\n // Tool Configuration\n activeTools: z.array(z.string()).optional(),\n // Tool entries contain execute functions and cannot be validated by zod.\n toolsets: typedPermissive<ToolsetsInput>(z.record(z.string(), z.unknown())).optional(),\n clientTools: typedPermissive<ToolsInput>(z.record(z.string(), z.unknown())).optional(),\n toolChoice: toolChoiceSchema.optional(),\n requireToolApproval: z.boolean().optional(),\n\n // Evaluation\n scorers: typedPermissive<Record<string, { scorer: string; sampling?: ScoringSamplingConfig }>>(\n z.union([\n z.record(z.string(), z.unknown()),\n z.record(\n z.string(),\n z.object({\n scorer: z.string(),\n sampling: z.unknown().optional(),\n }),\n ),\n ]),\n ).optional(),\n returnScorerData: z.boolean().optional(),\n\n // Observability\n tracingOptions: tracingOptionsSchema.optional(),\n\n // Structured Output\n // Zod schema, JSON schema, or structured output object — cannot be validated by zod.\n output: typedPermissive<OutputType>(z.unknown()).optional(),\n // The concrete options type cannot be expressed field-by-field because of\n // the fallback discriminated union.\n structuredOutput: typedPermissive<PublicStructuredOutputOptions<Record<string, unknown>>>(\n z.object({\n schema: z.object({}).passthrough(),\n model: z.union([z.string(), z.unknown()]).optional(),\n instructions: z.string().optional(),\n jsonPromptInjection: z.boolean().optional(),\n errorStrategy: z.enum(['strict', 'warn', 'fallback']).optional(),\n fallbackValue: z.unknown().optional(),\n }),\n ).optional(),\n\n // Idle-loop streaming (collapses streamUntilIdle into stream)\n untilIdle: z.union([z.boolean(), z.object({ maxIdleMs: z.number().int().positive().optional() })]).optional(),\n })\n .passthrough(); // Allow additional fields for forward compatibility\n\n/**\n * Legacy body schema for deprecated endpoints that still use threadId/resourceId\n * Used by /agents/:agentId/generate-legacy and /agents/:agentId/stream-legacy\n */\nexport const agentExecutionLegacyBodySchema = agentExecutionBodySchema.extend({\n resourceId: z.string().optional(),\n resourceid: z.string().optional(), // lowercase variant\n threadId: z.string().optional(),\n // Legacy generate/stream expect AI SDK v4 CoreMessage context and a string system message.\n context: typedPermissive<CoreMessageV4[]>(z.array(coreMessageSchema)).optional(),\n system: typedPermissive<string>(systemMessageSchema).optional(),\n});\n\nexport const streamUntilIdleBodySchema = agentExecutionBodySchema.extend({\n maxIdleMs: z.number().int().positive().optional(),\n untilIdle: z.union([z.boolean(), z.object({ maxIdleMs: z.number().int().positive().optional() })]).optional(),\n});\n\nexport const resumeStreamUntilIdleBodySchema = agentExecutionBodySchema.omit({ messages: true }).extend({\n runId: z.string(),\n resumeData: z.unknown().refine(x => x !== undefined, { message: 'resumeData is required' }),\n toolCallId: z.string().optional(),\n maxIdleMs: z.number().int().positive().optional(),\n});\n/**\n * Body schema for tool execute endpoint\n * Simple schema - tool validates its own input data\n * Note: The .refine() ensures data is required\n * (bare z.unknown() is treated as optional by Zod)\n */\nconst executeToolDataBodySchema = z.object({\n data: z.unknown().refine(x => x !== undefined, { message: 'data is required' }),\n});\n\nexport const executeToolBodySchema = executeToolDataBodySchema.extend({\n requestContext: z.record(z.string(), z.unknown()).optional(),\n});\n\nexport const executeToolContextBodySchema = executeToolDataBodySchema.extend({\n requestContext: z.record(z.string(), z.unknown()).optional(),\n});\n\n// ============================================================================\n// Tool Approval Schemas\n// ============================================================================\n\n/**\n * Base schema for tool approval/decline operations\n * Both approve and decline use the same parameters\n */\nconst toolCallActionBodySchema = z.object({\n runId: z.string(),\n model: z.string().optional(),\n requestContext: z.record(z.string(), z.unknown()).optional(),\n toolCallId: z.string(),\n format: z.string().optional(),\n providerOptions: z.record(z.string(), z.record(z.string(), jsonValueSchema)).optional(),\n modelSettings: typedPermissive<ModelSettings>(z.unknown()).optional(),\n // Client tools must be re-sent on resume so the model can call them after the approval decision.\n clientTools: typedPermissive<ToolsInput>(z.record(z.string(), z.unknown())).optional(),\n});\nconst networkToolCallActionBodySchema = z.object({\n runId: z.string(),\n model: z.string().optional(),\n requestContext: z.record(z.string(), z.unknown()).optional(),\n format: z.string().optional(),\n});\n\n/**\n * Body schema for approving tool call\n */\nexport const approveToolCallBodySchema = toolCallActionBodySchema;\n\n/**\n * Body schema for declining tool call\n */\nexport const declineToolCallBodySchema = toolCallActionBodySchema.extend({\n /** Optional explanation surfaced to the model in place of the default decline message. */\n reason: z.string().optional(),\n});\n\n/**\n * Body schema for approving network tool call\n */\nexport const approveNetworkToolCallBodySchema = networkToolCallActionBodySchema;\n\n/**\n * Body schema for declining network tool call\n */\nexport const declineNetworkToolCallBodySchema = networkToolCallActionBodySchema.extend({\n /** Optional explanation surfaced in place of the default decline message. */\n reason: z.string().optional(),\n});\n\n/**\n * Response schema for tool approval/decline\n */\nexport const toolCallResponseSchema = z.object({\n fullStream: z.unknown(), // ReadableStream\n});\n\nexport const sendToolApprovalResponseSchema = z.object({\n accepted: z.literal(true),\n runId: z.string(),\n toolCallId: z.string().optional(),\n});\n\n/**\n * Query schema for listing suspended agent runs\n */\nexport const listSuspendedRunsQuerySchema = z\n .object({\n threadId: z.string().optional(),\n resourceId: z.string().optional(),\n fromDate: z.coerce.date().optional(),\n toDate: z.coerce.date().optional(),\n perPage: z.coerce.number().int().positive().optional(),\n // page is zero-indexed, so 0 is valid\n page: z.coerce.number().int().nonnegative().optional(),\n })\n .refine(data => !data.fromDate || !data.toDate || data.fromDate <= data.toDate, {\n message: 'fromDate must be less than or equal to toDate',\n path: ['fromDate'],\n });\n\n/**\n * Response schema for listing suspended agent runs\n */\nexport const listSuspendedRunsResponseSchema = z.object({\n runs: z.array(\n z.object({\n runId: z.string(),\n status: z.literal('suspended'),\n threadId: z.string().optional(),\n resourceId: z.string().optional(),\n suspendedAt: z.date(),\n toolCalls: z.array(\n z.object({\n toolCallId: z.string().optional(),\n toolName: z.string().optional(),\n args: z.unknown().optional(),\n requiresApproval: z.boolean(),\n suspendPayload: z.unknown().optional(),\n }),\n ),\n }),\n ),\n total: z.number().int().nonnegative(),\n});\n\n// ============================================================================\n// Resume Stream Schema\n// ============================================================================\n\n/**\n * Body schema for resuming a suspended agent stream with custom data.\n * Extends the agent execution body without messages, since resume\n * continues from a prior suspension point rather than starting fresh.\n */\nexport const resumeStreamBodySchema = agentExecutionBodySchema.omit({ messages: true }).extend({\n runId: z.string(),\n resumeData: z.unknown().refine(x => x !== undefined, { message: 'resumeData is required' }),\n toolCallId: z.string().optional(),\n});\n\n// ============================================================================\n// Recover Schema\n// ============================================================================\n\n/**\n * Body schema for recovering an orphaned RUNNING durable-agent run.\n * Thread and resource are read from the persisted snapshot, so we only accept\n * the runId plus request-context / version overrides needed for auth and\n * routing.\n */\nexport const recoverBodySchema = z.object({\n runId: z.string(),\n requestContext: z.record(z.string(), z.unknown()).optional(),\n versions: z\n .object({\n agents: z\n .record(\n z.string(),\n z.union([z.object({ versionId: z.string() }), z.object({ status: z.enum(['draft', 'published']) })]),\n )\n .optional(),\n defaultStatus: z.enum(['draft', 'published']).optional(),\n })\n .optional(),\n});\n\n// ============================================================================\n// Model Management Schemas\n// ============================================================================\n\n/**\n * Body schema for updating agent model\n */\nexport const updateAgentModelBodySchema = z.object({\n modelId: z.string(),\n provider: z.string(),\n});\n\n/**\n * Body schema for reordering agent model list\n */\nexport const reorderAgentModelListBodySchema = z.object({\n reorderedModelIds: z.array(z.string()),\n});\n\n/**\n * Body schema for updating model in model list\n */\nexport const updateAgentModelInModelListBodySchema = z.object({\n model: z\n .object({\n modelId: z.string(),\n provider: z.string(),\n })\n .optional(),\n maxRetries: z.number().optional(),\n enabled: z.boolean().optional(),\n});\n\n/**\n * Response schema for model management operations\n */\nexport const modelManagementResponseSchema = messageResponseSchema;\n\n// ============================================================================\n// Response schemas for agent generation endpoints\n// These return AI SDK types which have complex structures\n// ============================================================================\n\nexport const generateResponseSchema = z.unknown(); // AI SDK GenerateResult type\nexport const streamResponseSchema = z.unknown(); // AI SDK StreamResult type\nexport const executeToolResponseSchema = z.unknown(); // Tool execution result varies by tool\n\n// ============================================================================\n// Instruction Enhancement Schemas\n// ============================================================================\n\n/**\n * Body schema for enhancing agent instructions\n */\nexport const enhanceInstructionsBodySchema = z.object({\n instructions: z.string().describe('The current agent instructions to enhance'),\n comment: z.string().describe('User comment describing how to enhance the instructions'),\n});\n\n/**\n * Response schema for enhanced instructions\n */\nexport const enhanceInstructionsResponseSchema = z.object({\n explanation: z.string().describe('Explanation of the changes made'),\n new_prompt: z.string().describe('The enhanced instructions'),\n});\n\n// ============================================================================\n// Observe (Resumable Streams) Schemas\n// ============================================================================\n\n/**\n * Body schema for observing an agent stream\n * Used to reconnect to an existing stream and receive missed events\n */\nexport const observeAgentBodySchema = z.object({\n runId: z.string().describe('The run ID to observe/reconnect to'),\n offset: z.number().optional().describe('Resume from this event index (0-based). If omitted, replays all events.'),\n});\n\nconst signalActiveBehaviorSchema = z.enum(['deliver', 'persist', 'discard']);\nconst signalIdleBehaviorSchema = z.enum(['wake', 'persist', 'discard']);\n\nconst signalTargetBaseBodySchema = z.object({\n ifActive: z\n .object({\n behavior: signalActiveBehaviorSchema.optional(),\n attributes: signalAttributesSchema.optional(),\n })\n .optional(),\n});\n\nconst signalTargetBodySchema = z.union([\n signalTargetBaseBodySchema.extend({\n runId: z.string(),\n resourceId: z.string().optional(),\n threadId: z.string().optional(),\n ifIdle: z.undefined().optional(),\n }),\n signalTargetBaseBodySchema.extend({\n runId: z.undefined().optional(),\n resourceId: z.string(),\n threadId: z.string(),\n ifIdle: z\n .object({\n behavior: signalIdleBehaviorSchema.optional(),\n streamOptions: agentExecutionBodySchema.omit({ messages: true }).optional(),\n attributes: signalAttributesSchema.optional(),\n })\n .optional(),\n }),\n]);\n\nexport const sendAgentSignalBodySchema = z.union([\n signalTargetBodySchema.options[0].extend({ signal: agentSignalSchema }),\n signalTargetBodySchema.options[1].extend({ signal: agentSignalSchema }),\n]);\n\nexport const sendAgentMessageBodySchema = z.union([\n signalTargetBodySchema.options[0].extend({ message: agentMessageInputSchema }),\n signalTargetBodySchema.options[1].extend({ message: agentMessageInputSchema }),\n]);\n\nexport const queueAgentMessageBodySchema = sendAgentMessageBodySchema;\nexport const queueAgentSignalBodySchema = sendAgentSignalBodySchema;\n\nconst agentThreadBodySchema = z.object({\n resourceId: z.string().optional(),\n threadId: z.string(),\n});\n\nexport const subscribeAgentThreadBodySchema = agentThreadBodySchema.extend({\n withRunStatus: z.boolean().optional().describe('Emit thread-run-status chunks, including retained outcomes'),\n withInitialHistory: z\n .union([z.boolean(), z.object({ perPage: z.number().int().positive().optional() })])\n .optional()\n .describe('Emit one thread-history chunk with stored messages before live parts'),\n});\n\nexport const abortAgentThreadBodySchema = agentThreadBodySchema.extend({\n threadId: z.string().min(1),\n clearPendingSignals: z.boolean().optional(),\n expectedRunId: z.string().optional(),\n});\n\nexport const cancelPendingAgentSignalsBodySchema = agentThreadBodySchema.extend({\n threadId: z.string().min(1),\n signalIds: z.array(z.string().min(1)).min(1).max(1000),\n});\n\nexport const cancelPendingAgentSignalsResponseSchema = z.object({\n cancelledSignalIds: z.array(z.string()),\n});\n\nexport const sendToolApprovalBodySchema = z.object({\n resourceId: z.string(),\n threadId: z.string(),\n requestContext: z.record(z.string(), z.unknown()).optional(),\n toolCallId: z.string(),\n approved: z.boolean(),\n resumeData: z.unknown().optional(),\n format: z.string().optional(),\n messages: z.array(coreMessageSchema).optional(),\n streamOptions: typedPermissive<AgentExecutionOptions<undefined>>(z.unknown()).optional(),\n});\n\nexport const abortAgentThreadResponseSchema = z.object({\n aborted: z.boolean(),\n});\n\n/**\n * Response schema for observe endpoint (streaming response)\n */\nexport const observeAgentResponseSchema = z.unknown(); // Streaming response\n"],"mappings":";;;;;AAmDA,MAAM,kBAAwC,EAAE,WAC9C,EAAE,MAAM;CACN,EAAE,OAAO;CACT,EAAE,OAAO;CACT,EAAE,QAAQ;CACV,EAAE,KAAK;CACP,EAAE,MAAM,eAAe;CACv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