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

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 (166) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/dist/_types/@internal_core/dist/index.d.ts +9 -1
  3. package/dist/{api-schema-manifest-X5B3P6OC.cjs → api-schema-manifest-MWMQI6TE.cjs} +4 -4
  4. package/dist/{api-schema-manifest-X5B3P6OC.cjs.map → api-schema-manifest-MWMQI6TE.cjs.map} +1 -1
  5. package/dist/{api-schema-manifest-JJDOQRPI.js → api-schema-manifest-OBRC34LA.js} +3 -3
  6. package/dist/{api-schema-manifest-JJDOQRPI.js.map → api-schema-manifest-OBRC34LA.js.map} +1 -1
  7. package/dist/{chunk-U5G72POG.js → chunk-247ZCPZW.js} +4 -4
  8. package/dist/{chunk-U5G72POG.js.map → chunk-247ZCPZW.js.map} +1 -1
  9. package/dist/{chunk-HFNLYENA.js → chunk-27MTROCI.js} +3 -3
  10. package/dist/{chunk-HFNLYENA.js.map → chunk-27MTROCI.js.map} +1 -1
  11. package/dist/{chunk-BZBG3MLF.cjs → chunk-2XNLZANZ.cjs} +3 -3
  12. package/dist/{chunk-BZBG3MLF.cjs.map → chunk-2XNLZANZ.cjs.map} +1 -1
  13. package/dist/{chunk-XDPKDD6J.js → chunk-3J5YIIAC.js} +3 -3
  14. package/dist/{chunk-XDPKDD6J.js.map → chunk-3J5YIIAC.js.map} +1 -1
  15. package/dist/{chunk-J6LU7NDU.js → chunk-3S77SMGK.js} +95 -4
  16. package/dist/chunk-3S77SMGK.js.map +1 -0
  17. package/dist/{chunk-EEDVUS6P.js → chunk-4OJDWKDW.js} +3 -3
  18. package/dist/{chunk-EEDVUS6P.js.map → chunk-4OJDWKDW.js.map} +1 -1
  19. package/dist/{chunk-GUWIV3ZN.cjs → chunk-4QZCXU3A.cjs} +9 -2
  20. package/dist/chunk-4QZCXU3A.cjs.map +1 -0
  21. package/dist/{chunk-PXMVZCUO.cjs → chunk-6ZSBLNO2.cjs} +3 -3
  22. package/dist/{chunk-PXMVZCUO.cjs.map → chunk-6ZSBLNO2.cjs.map} +1 -1
  23. package/dist/{chunk-25CXKVSW.cjs → chunk-767P6IDT.cjs} +174 -82
  24. package/dist/chunk-767P6IDT.cjs.map +1 -0
  25. package/dist/{chunk-OSUAMRZD.cjs → chunk-7BXQ2HFG.cjs} +25 -25
  26. package/dist/{chunk-OSUAMRZD.cjs.map → chunk-7BXQ2HFG.cjs.map} +1 -1
  27. package/dist/{chunk-CNTWPG57.cjs → chunk-CXAJPAJ2.cjs} +9 -2
  28. package/dist/chunk-CXAJPAJ2.cjs.map +1 -0
  29. package/dist/{chunk-UKWW47HL.js → chunk-D4XVXXDX.js} +3 -3
  30. package/dist/{chunk-UKWW47HL.js.map → chunk-D4XVXXDX.js.map} +1 -1
  31. package/dist/{chunk-PTLWJUYU.cjs → chunk-D5H4LH6V.cjs} +7 -7
  32. package/dist/{chunk-PTLWJUYU.cjs.map → chunk-D5H4LH6V.cjs.map} +1 -1
  33. package/dist/{chunk-377XDZUV.cjs → chunk-DBY645PQ.cjs} +157 -12
  34. package/dist/chunk-DBY645PQ.cjs.map +1 -0
  35. package/dist/{chunk-OXSLQPWP.cjs → chunk-DWQGAKMB.cjs} +4 -4
  36. package/dist/{chunk-OXSLQPWP.cjs.map → chunk-DWQGAKMB.cjs.map} +1 -1
  37. package/dist/{chunk-NJ2L4CM6.js → chunk-EIJLTW5X.js} +3 -3
  38. package/dist/{chunk-NJ2L4CM6.js.map → chunk-EIJLTW5X.js.map} +1 -1
  39. package/dist/{chunk-FOZ7WC36.cjs → chunk-GWLMGMHI.cjs} +464 -278
  40. package/dist/chunk-GWLMGMHI.cjs.map +1 -0
  41. package/dist/{chunk-MAUNZ6BS.js → chunk-ING7J2GB.js} +3 -3
  42. package/dist/{chunk-MAUNZ6BS.js.map → chunk-ING7J2GB.js.map} +1 -1
  43. package/dist/{chunk-3TT3XABO.js → chunk-IUXM3WA2.js} +8 -4
  44. package/dist/chunk-IUXM3WA2.js.map +1 -0
  45. package/dist/{chunk-SLXPPVD3.cjs → chunk-J4FVO25L.cjs} +8 -4
  46. package/dist/chunk-J4FVO25L.cjs.map +1 -0
  47. package/dist/{chunk-WIUKDNAE.js → chunk-JNIAMBSQ.js} +3 -3
  48. package/dist/{chunk-WIUKDNAE.js.map → chunk-JNIAMBSQ.js.map} +1 -1
  49. package/dist/{chunk-43CWQ4M3.js → chunk-KCVOCZXG.js} +9 -3
  50. package/dist/chunk-KCVOCZXG.js.map +1 -0
  51. package/dist/{chunk-TJNZEYLA.js → chunk-KEE6UMGC.js} +9 -2
  52. package/dist/chunk-KEE6UMGC.js.map +1 -0
  53. package/dist/{chunk-624PVCHI.js → chunk-LYDIFPB2.js} +3 -3
  54. package/dist/{chunk-624PVCHI.js.map → chunk-LYDIFPB2.js.map} +1 -1
  55. package/dist/{chunk-LAUE43XU.cjs → chunk-MOH4DZJP.cjs} +4 -4
  56. package/dist/{chunk-LAUE43XU.cjs.map → chunk-MOH4DZJP.cjs.map} +1 -1
  57. package/dist/{chunk-WIXZRRJE.cjs → chunk-MW23D33F.cjs} +6 -4
  58. package/dist/chunk-MW23D33F.cjs.map +1 -0
  59. package/dist/{chunk-AY3L2K4Y.cjs → chunk-MZFFAVXZ.cjs} +3 -3
  60. package/dist/{chunk-AY3L2K4Y.cjs.map → chunk-MZFFAVXZ.cjs.map} +1 -1
  61. package/dist/{chunk-A6J3CYNX.cjs → chunk-N2JR3ER7.cjs} +17 -17
  62. package/dist/{chunk-A6J3CYNX.cjs.map → chunk-N2JR3ER7.cjs.map} +1 -1
  63. package/dist/{chunk-HRV2M5BX.js → chunk-NHQKZEVJ.js} +131 -6
  64. package/dist/chunk-NHQKZEVJ.js.map +1 -0
  65. package/dist/{chunk-MGSLTJZ3.js → chunk-NPNRCLYK.js} +444 -258
  66. package/dist/chunk-NPNRCLYK.js.map +1 -0
  67. package/dist/{chunk-TEUAEW3K.js → chunk-OCFLDDPE.js} +6 -4
  68. package/dist/chunk-OCFLDDPE.js.map +1 -0
  69. package/dist/{chunk-JOMZXGHK.js → chunk-OMOR5OUN.js} +4 -4
  70. package/dist/{chunk-JOMZXGHK.js.map → chunk-OMOR5OUN.js.map} +1 -1
  71. package/dist/{chunk-LTQAE2EZ.js → chunk-OSXOHBCO.js} +3 -3
  72. package/dist/{chunk-LTQAE2EZ.js.map → chunk-OSXOHBCO.js.map} +1 -1
  73. package/dist/{chunk-2LIWBIH2.cjs → chunk-SZOC7JGR.cjs} +30 -30
  74. package/dist/{chunk-2LIWBIH2.cjs.map → chunk-SZOC7JGR.cjs.map} +1 -1
  75. package/dist/{chunk-LBYV6CLG.cjs → chunk-TRB4NGQ3.cjs} +3 -3
  76. package/dist/{chunk-LBYV6CLG.cjs.map → chunk-TRB4NGQ3.cjs.map} +1 -1
  77. package/dist/{chunk-PQHGVAHX.js → chunk-TZFIX2NI.js} +3 -3
  78. package/dist/{chunk-PQHGVAHX.js.map → chunk-TZFIX2NI.js.map} +1 -1
  79. package/dist/{chunk-2EYHTORX.js → chunk-UVLQSMYF.js} +23 -22
  80. package/dist/{chunk-2EYHTORX.js.map → chunk-UVLQSMYF.js.map} +1 -1
  81. package/dist/{chunk-ZYIGNK6T.cjs → chunk-VQMQBGDO.cjs} +3 -3
  82. package/dist/{chunk-ZYIGNK6T.cjs.map → chunk-VQMQBGDO.cjs.map} +1 -1
  83. package/dist/{chunk-MFICYRVR.cjs → chunk-WC3F3EA5.cjs} +4 -4
  84. package/dist/{chunk-MFICYRVR.cjs.map → chunk-WC3F3EA5.cjs.map} +1 -1
  85. package/dist/{chunk-SUGHLGVF.cjs → chunk-Y5FNAVOR.cjs} +172 -171
  86. package/dist/chunk-Y5FNAVOR.cjs.map +1 -0
  87. package/dist/docs/SKILL.md +1 -1
  88. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  89. package/dist/server/a2a/agent-card-signing.d.ts +7 -0
  90. package/dist/server/a2a/agent-card-signing.d.ts.map +1 -0
  91. package/dist/server/handlers/a2a.cjs +14 -14
  92. package/dist/server/handlers/a2a.d.ts +10 -0
  93. package/dist/server/handlers/a2a.d.ts.map +1 -1
  94. package/dist/server/handlers/a2a.js +1 -1
  95. package/dist/server/handlers/agent-builder.cjs +16 -16
  96. package/dist/server/handlers/agent-builder.js +1 -1
  97. package/dist/server/handlers/agents.cjs +42 -38
  98. package/dist/server/handlers/agents.d.ts +157 -0
  99. package/dist/server/handlers/agents.d.ts.map +1 -1
  100. package/dist/server/handlers/agents.js +1 -1
  101. package/dist/server/handlers/background-tasks.cjs +4 -4
  102. package/dist/server/handlers/background-tasks.d.ts +18 -5
  103. package/dist/server/handlers/background-tasks.d.ts.map +1 -1
  104. package/dist/server/handlers/background-tasks.js +1 -1
  105. package/dist/server/handlers/conversations.cjs +5 -5
  106. package/dist/server/handlers/conversations.js +1 -1
  107. package/dist/server/handlers/observability-new-endpoints.cjs +28 -28
  108. package/dist/server/handlers/observability-new-endpoints.d.ts +18 -6
  109. package/dist/server/handlers/observability-new-endpoints.d.ts.map +1 -1
  110. package/dist/server/handlers/observability-new-endpoints.js +1 -1
  111. package/dist/server/handlers/observability.cjs +38 -38
  112. package/dist/server/handlers/observability.js +2 -2
  113. package/dist/server/handlers/responses.cjs +4 -4
  114. package/dist/server/handlers/responses.js +1 -1
  115. package/dist/server/handlers/scores.cjs +7 -7
  116. package/dist/server/handlers/scores.js +1 -1
  117. package/dist/server/handlers/stored-agents.cjs +7 -7
  118. package/dist/server/handlers/stored-agents.js +1 -1
  119. package/dist/server/handlers/stored-mcp-clients.cjs +6 -6
  120. package/dist/server/handlers/stored-mcp-clients.js +1 -1
  121. package/dist/server/handlers/stored-prompt-blocks.cjs +6 -6
  122. package/dist/server/handlers/stored-prompt-blocks.js +1 -1
  123. package/dist/server/handlers/stored-scorers.cjs +6 -6
  124. package/dist/server/handlers/stored-scorers.js +1 -1
  125. package/dist/server/handlers/system.cjs +3 -3
  126. package/dist/server/handlers/system.js +1 -1
  127. package/dist/server/handlers/tools.cjs +6 -6
  128. package/dist/server/handlers/tools.js +1 -1
  129. package/dist/server/handlers/voice.cjs +8 -8
  130. package/dist/server/handlers/voice.js +1 -1
  131. package/dist/server/handlers/workflows.cjs +24 -24
  132. package/dist/server/handlers/workflows.js +1 -1
  133. package/dist/server/handlers.cjs +27 -27
  134. package/dist/server/handlers.js +11 -11
  135. package/dist/server/schemas/a2a.d.ts +5 -0
  136. package/dist/server/schemas/a2a.d.ts.map +1 -1
  137. package/dist/server/schemas/agents.d.ts +77 -0
  138. package/dist/server/schemas/agents.d.ts.map +1 -1
  139. package/dist/server/schemas/background-tasks.d.ts +11 -0
  140. package/dist/server/schemas/background-tasks.d.ts.map +1 -1
  141. package/dist/server/schemas/index.cjs +289 -285
  142. package/dist/server/schemas/index.js +7 -7
  143. package/dist/server/server-adapter/index.cjs +10 -10
  144. package/dist/server/server-adapter/index.js +2 -2
  145. package/dist/server/server-adapter/routes/a2a.d.ts +10 -0
  146. package/dist/server/server-adapter/routes/a2a.d.ts.map +1 -1
  147. package/dist/server/server-adapter/routes/agents.d.ts +2 -1
  148. package/dist/server/server-adapter/routes/agents.d.ts.map +1 -1
  149. package/dist/server/server-adapter/routes/observability.d.ts +9 -3
  150. package/dist/server/server-adapter/routes/observability.d.ts.map +1 -1
  151. package/package.json +8 -7
  152. package/dist/chunk-25CXKVSW.cjs.map +0 -1
  153. package/dist/chunk-377XDZUV.cjs.map +0 -1
  154. package/dist/chunk-3TT3XABO.js.map +0 -1
  155. package/dist/chunk-43CWQ4M3.js.map +0 -1
  156. package/dist/chunk-CNTWPG57.cjs.map +0 -1
  157. package/dist/chunk-FOZ7WC36.cjs.map +0 -1
  158. package/dist/chunk-GUWIV3ZN.cjs.map +0 -1
  159. package/dist/chunk-HRV2M5BX.js.map +0 -1
  160. package/dist/chunk-J6LU7NDU.js.map +0 -1
  161. package/dist/chunk-MGSLTJZ3.js.map +0 -1
  162. package/dist/chunk-SLXPPVD3.cjs.map +0 -1
  163. package/dist/chunk-SUGHLGVF.cjs.map +0 -1
  164. package/dist/chunk-TEUAEW3K.js.map +0 -1
  165. package/dist/chunk-TJNZEYLA.js.map +0 -1
  166. package/dist/chunk-WIXZRRJE.cjs.map +0 -1
@@ -172,6 +172,13 @@ var agentCardResponseSchema = v4.z.object({
172
172
  defaultInputModes: v4.z.array(v4.z.string()),
173
173
  defaultOutputModes: v4.z.array(v4.z.string()),
174
174
  supportsAuthenticatedExtendedCard: v4.z.boolean().optional(),
175
+ signatures: v4.z.array(
176
+ v4.z.object({
177
+ protected: v4.z.string(),
178
+ signature: v4.z.string(),
179
+ header: v4.z.record(v4.z.string(), v4.z.unknown()).optional()
180
+ })
181
+ ).optional(),
175
182
  skills: v4.z.array(
176
183
  v4.z.object({
177
184
  id: v4.z.string(),
@@ -192,5 +199,5 @@ exports.agentExecutionResponseSchema = agentExecutionResponseSchema;
192
199
  exports.messageSendBodySchema = messageSendBodySchema;
193
200
  exports.taskQueryBodySchema = taskQueryBodySchema;
194
201
  exports.taskResponseSchema = taskResponseSchema;
195
- //# sourceMappingURL=chunk-CNTWPG57.cjs.map
196
- //# sourceMappingURL=chunk-CNTWPG57.cjs.map
202
+ //# sourceMappingURL=chunk-CXAJPAJ2.cjs.map
203
+ //# sourceMappingURL=chunk-CXAJPAJ2.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/server/schemas/a2a.ts"],"names":["z"],"mappings":";;;;;AAGO,IAAM,oBAAA,GAAuBA,KAAE,MAAA,CAAO;AAAA,EAC3C,OAAA,EAASA,IAAA,CAAE,MAAA,EAAO,CAAE,SAAS,iCAAiC;AAChE,CAAC;AAEM,IAAM,iBAAA,GAAoB,qBAAqB,MAAA,CAAO;AAAA,EAC3D,MAAA,EAAQA,IAAA,CAAE,MAAA,EAAO,CAAE,SAAS,gCAAgC;AAC9D,CAAC;AAKD,IAAM,wCAAA,GAA2CA,KAAE,MAAA,CAAO;AAAA,EACxD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CAAE,KAAA,CAAMA,IAAA,CAAE,QAAQ,CAAA;AAAA,EACtC,iCAAA,EAAmCA,IAAA,CAAE,OAAA,EAAQ,CAAE,QAAA,EAAS;AAAA,EACxD,YAAYA,IAAA,CACT,KAAA;AAAA,IACCA,KAAE,MAAA,CAAO;AAAA,MACP,SAAA,EAAWA,KAAE,MAAA,EAAO;AAAA,MACpB,SAAA,EAAWA,KAAE,MAAA,EAAO;AAAA,MACpB,MAAA,EAAQA,IAAA,CAAE,MAAA,CAAOA,IAAA,CAAE,MAAA,IAAUA,IAAA,CAAE,OAAA,EAAS,CAAA,CAAE,QAAA;AAAS,KACpD;AAAA,IAEF,QAAA,EAAS;AAAA,EACZ,QAAQA,IAAA,CAAE,KAAA;AAAA,IACRA,KAAE,MAAA,CAAO;AAAA,MACP,EAAA,EAAIA,KAAE,MAAA,EAAO;AAAA,MACb,IAAA,EAAMA,KAAE,MAAA,EAAO;AAAA,MACf,WAAA,EAAaA,KAAE,MAAA,EAAO;AAAA,MACtB,MAAMA,IAAA,CAAE,KAAA,CAAMA,KAAE,MAAA,EAAQ,EAAE,QAAA;AAAS,KACpC;AAAA;AAEL,CAAC;AAEM,IAAM,kBAAA,GAAqBA,KAAE,OAAA;AAE7B,IAAM,4BAAA,GAA+BA,KAAE,OAAA","file":"chunk-CXAJPAJ2.cjs","sourcesContent":["import { z } from 'zod/v4';\n\n// Path parameter schemas\nexport const a2aAgentIdPathParams = z.object({\n agentId: z.string().describe('Unique identifier for the agent'),\n});\n\nexport const a2aTaskPathParams = a2aAgentIdPathParams.extend({\n taskId: z.string().describe('Unique identifier for the task'),\n});\n\n// Body schemas for A2A protocol\n\n// Push notification schemas\nconst pushNotificationAuthenticationInfoSchema = z.object({\n schemes: z.array(z.string()).describe('Supported authentication schemes - e.g. Basic, Bearer'),\n credentials: z.string().optional().describe('Optional credentials'),\n});\n\nconst pushNotificationConfigSchema = z.object({\n url: z.string().describe('URL for sending the push notifications'),\n id: z.string().optional().describe('Push Notification ID - created by server to support multiple callbacks'),\n token: z.string().optional().describe('Token unique to this task/session'),\n authentication: pushNotificationAuthenticationInfoSchema.optional(),\n});\n\nconst messageSendConfigurationSchema = z.object({\n acceptedOutputModes: z.array(z.string()).optional().describe('Accepted output modalities by the client'),\n blocking: z.boolean().optional().describe('If the server should treat the client as a blocking request'),\n historyLength: z.number().optional().describe('Number of recent messages to be retrieved'),\n pushNotificationConfig: pushNotificationConfigSchema.optional(),\n});\n\n// Part schemas\nconst textPartSchema = z.object({\n kind: z.literal('text').describe('Part type - text for TextParts'),\n text: z.string().describe('Text content'),\n metadata: z.record(z.string(), z.unknown()).optional().describe('Optional metadata associated with the part'),\n});\n\nconst fileWithBytesSchema = z.object({\n bytes: z.string().describe('base64 encoded content of the file'),\n mimeType: z.string().optional().describe('Optional mimeType for the file'),\n name: z.string().optional().describe('Optional name for the file'),\n});\n\nconst fileWithUriSchema = z.object({\n uri: z.string().describe('URL for the File content'),\n mimeType: z.string().optional().describe('Optional mimeType for the file'),\n name: z.string().optional().describe('Optional name for the file'),\n});\n\nconst filePartSchema = z.object({\n kind: z.literal('file').describe('Part type - file for FileParts'),\n file: z.union([fileWithBytesSchema, fileWithUriSchema]).describe('File content either as url or bytes'),\n metadata: z.record(z.string(), z.unknown()).optional().describe('Optional metadata associated with the part'),\n});\n\nconst dataPartSchema = z.object({\n kind: z.literal('data').describe('Part type - data for DataParts'),\n data: z.record(z.string(), z.unknown()).describe('Structured data content'),\n metadata: z.record(z.string(), z.unknown()).optional().describe('Optional metadata associated with the part'),\n});\n\nconst partSchema = z.union([textPartSchema, filePartSchema, dataPartSchema]);\n\n// Message schema\nconst messageSchema = z.object({\n kind: z.literal('message').describe('Event type'),\n messageId: z.string().describe('Identifier created by the message creator'),\n role: z.enum(['user', 'agent']).describe(\"Message sender's role\"),\n parts: z.array(partSchema).describe('Message content'),\n contextId: z.string().optional().describe('The context the message is associated with'),\n taskId: z.string().optional().describe('Identifier of task the message is related to'),\n referenceTaskIds: z.array(z.string()).optional().describe('List of tasks referenced as context by this message'),\n extensions: z\n .array(z.string())\n .optional()\n .describe('The URIs of extensions that are present or contributed to this Message'),\n metadata: z.record(z.string(), z.unknown()).optional().describe('Extension metadata'),\n});\n\n// MessageSendParams schema\nconst messageSendParamsSchema = z.object({\n message: messageSchema,\n configuration: messageSendConfigurationSchema.optional(),\n metadata: z.record(z.string(), z.unknown()).optional().describe('Extension metadata'),\n});\n\n// TaskQueryParams schema\nconst taskQueryParamsSchema = z.object({\n id: z.string().describe('Task id'),\n historyLength: z.number().optional().describe('Number of recent messages to be retrieved'),\n metadata: z.record(z.string(), z.unknown()).optional(),\n});\n\n// TaskIdParams schema\nconst taskIdParamsSchema = z.object({\n id: z.string().describe('Task id'),\n metadata: z.record(z.string(), z.unknown()).optional(),\n});\n\nexport const taskResubscribeParamsSchema = taskIdParamsSchema;\n\nexport const setPushNotificationConfigParamsSchema = z.object({\n taskId: z.string().describe('Task id'),\n pushNotificationConfig: pushNotificationConfigSchema,\n});\n\nconst getPushNotificationConfigParamsSchema = taskIdParamsSchema.extend({\n pushNotificationConfigId: z.string().optional().describe('Push notification config id'),\n});\n\nexport const listPushNotificationConfigParamsSchema = taskIdParamsSchema;\n\nexport const deletePushNotificationConfigParamsSchema = taskIdParamsSchema.extend({\n pushNotificationConfigId: z.string().describe('Push notification config id'),\n});\n\n// Legacy schema for backwards compatibility\nexport const messageSendBodySchema = z.object({\n message: messageSchema,\n metadata: z.record(z.string(), z.any()).optional(),\n});\n\nexport const taskQueryBodySchema = z.object({\n id: z.string(),\n});\n\nconst requestBaseSchema = {\n jsonrpc: z.literal('2.0'),\n id: z.union([z.string(), z.number()]),\n} as const;\n\nexport const agentExecutionBodySchema = z.discriminatedUnion('method', [\n z.object({\n ...requestBaseSchema,\n method: z.literal('message/send'),\n params: messageSendParamsSchema,\n }),\n z.object({\n ...requestBaseSchema,\n method: z.literal('message/stream'),\n params: messageSendParamsSchema,\n }),\n z.object({\n ...requestBaseSchema,\n method: z.literal('tasks/get'),\n params: taskQueryParamsSchema,\n }),\n z.object({\n ...requestBaseSchema,\n method: z.literal('tasks/cancel'),\n params: taskIdParamsSchema,\n }),\n z.object({\n ...requestBaseSchema,\n method: z.literal('tasks/resubscribe'),\n params: taskResubscribeParamsSchema,\n }),\n z.object({\n ...requestBaseSchema,\n method: z.literal('tasks/pushNotificationConfig/set'),\n params: setPushNotificationConfigParamsSchema,\n }),\n z.object({\n ...requestBaseSchema,\n method: z.literal('tasks/pushNotificationConfig/get'),\n params: getPushNotificationConfigParamsSchema,\n }),\n z.object({\n ...requestBaseSchema,\n method: z.literal('tasks/pushNotificationConfig/list'),\n params: listPushNotificationConfigParamsSchema,\n }),\n z.object({\n ...requestBaseSchema,\n method: z.literal('tasks/pushNotificationConfig/delete'),\n params: deletePushNotificationConfigParamsSchema,\n }),\n z.object({\n ...requestBaseSchema,\n method: z.literal('agent/getAuthenticatedExtendedCard'),\n }),\n]);\n\n// Response schemas\nexport const agentCardResponseSchema = z.object({\n additionalInterfaces: z.array(z.unknown()).optional(),\n name: z.string(),\n description: z.string(),\n url: z.string(),\n protocolVersion: z.string(),\n provider: z\n .object({\n organization: z.string(),\n url: z.string(),\n })\n .optional(),\n security: z.array(z.record(z.string(), z.array(z.string()))).optional(),\n securitySchemes: z.record(z.string(), z.unknown()).optional(),\n version: z.string(),\n capabilities: z.object({\n extensions: z.array(z.unknown()).optional(),\n streaming: z.boolean().optional(),\n pushNotifications: z.boolean().optional(),\n stateTransitionHistory: z.boolean().optional(),\n }),\n defaultInputModes: z.array(z.string()),\n defaultOutputModes: z.array(z.string()),\n supportsAuthenticatedExtendedCard: z.boolean().optional(),\n signatures: z\n .array(\n z.object({\n protected: z.string(),\n signature: z.string(),\n header: z.record(z.string(), z.unknown()).optional(),\n }),\n )\n .optional(),\n skills: z.array(\n z.object({\n id: z.string(),\n name: z.string(),\n description: z.string(),\n tags: z.array(z.string()).optional(),\n }),\n ),\n});\n\nexport const taskResponseSchema = z.unknown(); // Complex task state structure\n\nexport const agentExecutionResponseSchema = z.unknown(); // JSON-RPC response\n"]}
@@ -1,7 +1,7 @@
1
1
  import { conversationObjectSchema, createConversationBodySchema, conversationIdPathParams, conversationItemsListSchema, conversationDeletedSchema } from './chunk-HX5WL5ZF.js';
2
2
  import { mapMastraMessagesToConversationItems } from './chunk-AJYJ4H7P.js';
3
3
  import { getAgentMemoryStore, findConversationThreadAcrossAgents } from './chunk-DFSUBEGE.js';
4
- import { getAgentFromSystem } from './chunk-J6LU7NDU.js';
4
+ import { getAgentFromSystem } from './chunk-3S77SMGK.js';
5
5
  import { getEffectiveResourceId } from './chunk-UOC4K3RU.js';
6
6
  import { MastraFGAPermissions } from './chunk-6KDKASVR.js';
7
7
  import { createRoute } from './chunk-GDACR4PY.js';
@@ -156,5 +156,5 @@ var DELETE_CONVERSATION_ROUTE = createRoute({
156
156
  });
157
157
 
158
158
  export { CREATE_CONVERSATION_ROUTE, DELETE_CONVERSATION_ROUTE, GET_CONVERSATION_ITEMS_ROUTE, GET_CONVERSATION_ROUTE, conversations_exports };
159
- //# sourceMappingURL=chunk-UKWW47HL.js.map
160
- //# sourceMappingURL=chunk-UKWW47HL.js.map
159
+ //# sourceMappingURL=chunk-D4XVXXDX.js.map
160
+ //# sourceMappingURL=chunk-D4XVXXDX.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/server/handlers/conversations.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,IAAA,qBAAA,GAAA;AAAA,QAAA,CAAA,qBAAA,EAAA;AAAA,EAAA,yBAAA,EAAA,MAAA,yBAAA;AAAA,EAAA,yBAAA,EAAA,MAAA,yBAAA;AAAA,EAAA,4BAAA,EAAA,MAAA,4BAAA;AAAA,EAAA,sBAAA,EAAA,MAAA;AAAA,CAAA,CAAA;AAkBA,SAAS,uBAAA,CAAwB,EAAE,MAAA,EAAO,EAAiE;AACzG,EAAA,OAAO;AAAA,IACL,IAAI,MAAA,CAAO,EAAA;AAAA,IACX,MAAA,EAA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AA,EACF;AACF,CAAC","file":"chunk-UKWW47HL.js","sourcesContent":["import { randomUUID } from 'node:crypto';\nimport { MastraFGAPermissions } from '../fga-permissions';\nimport { HTTPException } from '../http-exception';\nimport {\n conversationDeletedSchema,\n conversationIdPathParams,\n conversationItemsListSchema,\n conversationObjectSchema,\n createConversationBodySchema,\n} from '../schemas/conversations';\nimport type { ConversationDeleted, ConversationItemsList, ConversationObject } from '../schemas/conversations';\nimport { createRoute } from '../server-adapter/routes/route-builder';\nimport { getAgentFromSystem } from './agents';\nimport { handleError } from './error';\nimport { mapMastraMessagesToConversationItems } from './responses.adapter';\nimport { findConversationThreadAcrossAgents, getAgentMemoryStore } from './responses.storage';\nimport { getEffectiveResourceId } from './utils';\n\nfunction buildConversationObject({ thread }: { thread: ConversationObject['thread'] }): ConversationObject {\n return {\n id: thread.id,\n object: 'conversation',\n thread,\n };\n}\n\nfunction buildConversationItemsList(items: ConversationItemsList['data']): ConversationItemsList {\n return {\n object: 'list',\n data: items,\n first_id: items[0]?.id ?? null,\n last_id: items.at(-1)?.id ?? null,\n has_more: false,\n };\n}\n\nfunction buildConversationDeleted(conversationId: string): ConversationDeleted {\n return {\n id: conversationId,\n object: 'conversation.deleted',\n deleted: true,\n };\n}\n\nexport const CREATE_CONVERSATION_ROUTE = createRoute({\n method: 'POST',\n path: '/v1/conversations',\n responseType: 'json',\n bodySchema: createConversationBodySchema,\n responseSchema: conversationObjectSchema,\n summary: 'Create a conversation',\n description: 'Creates a new thread-backed conversation for agent-backed Responses API requests',\n tags: ['Responses'],\n requiresAuth: true,\n requiresPermission: MastraFGAPermissions.AGENTS_CREATE,\n handler: async ({ mastra, requestContext, agent_id, conversation_id, resource_id, title, metadata }) => {\n try {\n if (!mastra) {\n throw new HTTPException(500, { message: 'Mastra instance is required for conversations' });\n }\n\n const agent = await getAgentFromSystem({ mastra, agentId: agent_id });\n const memory = await agent.getMemory({ requestContext });\n if (!memory) {\n throw new HTTPException(400, { message: `Agent \"${agent.id}\" does not have memory configured` });\n }\n if (!(await getAgentMemoryStore({ agent, requestContext }))) {\n throw new HTTPException(400, { message: `Memory storage is not configured for agent \"${agent.id}\"` });\n }\n\n const threadId = conversation_id ?? randomUUID();\n const resourceId = getEffectiveResourceId(requestContext, resource_id) ?? threadId;\n const thread = await memory.createThread({\n threadId,\n resourceId,\n title,\n metadata,\n });\n\n return buildConversationObject({ thread });\n } catch (error) {\n return handleError(error, 'Error creating conversation');\n }\n },\n});\n\nexport const GET_CONVERSATION_ROUTE = createRoute({\n method: 'GET',\n path: '/v1/conversations/:conversationId',\n responseType: 'json',\n pathParamSchema: conversationIdPathParams,\n responseSchema: conversationObjectSchema,\n summary: 'Retrieve a conversation',\n description: 'Returns a conversation object backed by a Mastra memory thread',\n tags: ['Responses'],\n requiresAuth: true,\n requiresPermission: MastraFGAPermissions.AGENTS_READ,\n handler: async ({ mastra, requestContext, conversationId }) => {\n try {\n const match = await findConversationThreadAcrossAgents({ mastra, conversationId, requestContext });\n if (!match) {\n throw new HTTPException(404, { message: `Conversation ${conversationId} was not found` });\n }\n\n return buildConversationObject({ thread: match.thread });\n } catch (error) {\n return handleError(error, 'Error retrieving conversation');\n }\n },\n});\n\nexport const GET_CONVERSATION_ITEMS_ROUTE = createRoute({\n method: 'GET',\n path: '/v1/conversations/:conversationId/items',\n responseType: 'json',\n pathParamSchema: conversationIdPathParams,\n responseSchema: conversationItemsListSchema,\n summary: 'List conversation items',\n description: 'Returns OpenAI-style conversation items derived from the stored thread messages',\n tags: ['Responses'],\n requiresAuth: true,\n requiresPermission: MastraFGAPermissions.AGENTS_READ,\n handler: async ({ mastra, requestContext, conversationId }) => {\n try {\n const match = await findConversationThreadAcrossAgents({ mastra, conversationId, requestContext });\n if (!match) {\n throw new HTTPException(404, { message: `Conversation ${conversationId} was not found` });\n }\n\n const { messages } = await match.memoryStore.listMessages({\n threadId: conversationId,\n page: 0,\n perPage: 1000,\n });\n\n return buildConversationItemsList(mapMastraMessagesToConversationItems(messages));\n } catch (error) {\n return handleError(error, 'Error retrieving conversation');\n }\n },\n});\n\nexport const DELETE_CONVERSATION_ROUTE = createRoute({\n method: 'DELETE',\n path: '/v1/conversations/:conversationId',\n responseType: 'json',\n pathParamSchema: conversationIdPathParams,\n responseSchema: conversationDeletedSchema,\n summary: 'Delete a conversation',\n description: 'Deletes a thread-backed conversation and its stored items',\n tags: ['Responses'],\n requiresAuth: true,\n requiresPermission: MastraFGAPermissions.AGENTS_DELETE,\n handler: async ({ mastra, requestContext, conversationId }) => {\n try {\n const match = await findConversationThreadAcrossAgents({ mastra, conversationId, requestContext });\n if (!match) {\n throw new HTTPException(404, { message: `Conversation ${conversationId} was not found` });\n }\n\n await match.memoryStore.deleteThread({ threadId: conversationId });\n\n return buildConversationDeleted(conversationId);\n } catch (error) {\n return handleError(error, 'Error deleting conversation');\n }\n },\n});\n"]}
1
+ {"version":3,"sources":["../src/server/handlers/conversations.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,IAAA,qBAAA,GAAA;AAAA,QAAA,CAAA,qBAAA,EAAA;AAAA,EAAA,yBAAA,EAAA,MAAA,yBAAA;AAAA,EAAA,yBAAA,EAAA,MAAA,yBAAA;AAAA,EAAA,4BAAA,EAAA,MAAA,4BAAA;AAAA,EAAA,sBAAA,EAAA,MAAA;AAAA,CAAA,CAAA;AAkBA,SAAS,uBAAA,CAAwB,EAAE,MAAA,EAAO,EAAiE;AACzG,EAAA,OAAO;AAAA,IACL,IAAI,MAAA,CAAO,EAAA;AAAA,IACX,MAAA,EAAQ,cAAA;AAAA,IACR;AAAA,GACF;AACF;AAEA,SAAS,2BAA2B,KAAA,EAA6D;AAC/F,EAAA,OAAO;AAAA,IACL,MAAA,EAAQ,MAAA;AAAA,IACR,IAAA,EAAM,KAAA;AAAA,IACN,QAAA,EAAU,KAAA,CAAM,CAAC,CAAA,EAAG,EAAA,IAAM,IAAA;AAAA,IAC1B,OAAA,EAAS,KAAA,CAAM,EAAA,CAAG,EAAE,GAAG,EAAA,I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+BAA+B,CAAA;AAAA,IAC3D;AAAA,EACF;AACF,CAAC;AAEM,IAAM,4BAA4B,WAAA,CAAY;AAAA,EACnD,MAAA,EAAQ,QAAA;AAAA,EACR,IAAA,EAAM,mCAAA;AAAA,EACN,YAAA,EAAc,MAAA;AAAA,EACd,eAAA,EAAiB,wBAAA;AAAA,EACjB,cAAA,EAAgB,yBAAA;AAAA,EAChB,OAAA,EAAS,uBAAA;AAAA,EACT,WAAA,EAAa,2DAAA;AAAA,EACb,IAAA,EAAM,CAAC,WAAW,CAAA;AAAA,EAClB,YAAA,EAAc,IAAA;AAAA,EACd,oBAAoB,oBAAA,CAAqB,aAAA;AAAA,EACzC,SAAS,OAAO,EAAE,MAAA,EAAQ,cAAA,EAAgB,gBAAe,KAAM;AAC7D,IAAA,IAAI;AACF,MAAA,MAAM,QAAQ,MAAM,kCAAA,CAAmC,EAAE,MAAA,EAAQ,cAAA,EAAgB,gBAAgB,CAAA;AACjG,MAAA,IAAI,CAAC,KAAA,EAAO;AACV,QAAA,MAAM,IAAI,cAAc,GAAA,EAAK,EAAE,SAAS,CAAA,aAAA,EAAgB,cAAc,kBAAkB,CAAA;AAAA,MAC1F;AAEA,MAAA,MAAM,MAAM,WAAA,CAAY,YAAA,CAAa,EAAE,QAAA,EAAU,gBAAgB,CAAA;AAEjE,MAAA,OAAO,yBAAyB,cAAc,CAAA;AAAA,IAChD,SAAS,KAAA,EAAO;AACd,MAAA,OAAO,WAAA,CAAY,OAAO,6BAA6B,CAAA;AAAA,IACzD;AAAA,EACF;AACF,CAAC","file":"chunk-D4XVXXDX.js","sourcesContent":["import { randomUUID } from 'node:crypto';\nimport { MastraFGAPermissions } from '../fga-permissions';\nimport { HTTPException } from '../http-exception';\nimport {\n conversationDeletedSchema,\n conversationIdPathParams,\n conversationItemsListSchema,\n conversationObjectSchema,\n createConversationBodySchema,\n} from '../schemas/conversations';\nimport type { ConversationDeleted, ConversationItemsList, ConversationObject } from '../schemas/conversations';\nimport { createRoute } from '../server-adapter/routes/route-builder';\nimport { getAgentFromSystem } from './agents';\nimport { handleError } from './error';\nimport { mapMastraMessagesToConversationItems } from './responses.adapter';\nimport { findConversationThreadAcrossAgents, getAgentMemoryStore } from './responses.storage';\nimport { getEffectiveResourceId } from './utils';\n\nfunction buildConversationObject({ thread }: { thread: ConversationObject['thread'] }): ConversationObject {\n return {\n id: thread.id,\n object: 'conversation',\n thread,\n };\n}\n\nfunction buildConversationItemsList(items: ConversationItemsList['data']): ConversationItemsList {\n return {\n object: 'list',\n data: items,\n first_id: items[0]?.id ?? null,\n last_id: items.at(-1)?.id ?? null,\n has_more: false,\n };\n}\n\nfunction buildConversationDeleted(conversationId: string): ConversationDeleted {\n return {\n id: conversationId,\n object: 'conversation.deleted',\n deleted: true,\n };\n}\n\nexport const CREATE_CONVERSATION_ROUTE = createRoute({\n method: 'POST',\n path: '/v1/conversations',\n responseType: 'json',\n bodySchema: createConversationBodySchema,\n responseSchema: conversationObjectSchema,\n summary: 'Create a conversation',\n description: 'Creates a new thread-backed conversation for agent-backed Responses API requests',\n tags: ['Responses'],\n requiresAuth: true,\n requiresPermission: MastraFGAPermissions.AGENTS_CREATE,\n handler: async ({ mastra, requestContext, agent_id, conversation_id, resource_id, title, metadata }) => {\n try {\n if (!mastra) {\n throw new HTTPException(500, { message: 'Mastra instance is required for conversations' });\n }\n\n const agent = await getAgentFromSystem({ mastra, agentId: agent_id });\n const memory = await agent.getMemory({ requestContext });\n if (!memory) {\n throw new HTTPException(400, { message: `Agent \"${agent.id}\" does not have memory configured` });\n }\n if (!(await getAgentMemoryStore({ agent, requestContext }))) {\n throw new HTTPException(400, { message: `Memory storage is not configured for agent \"${agent.id}\"` });\n }\n\n const threadId = conversation_id ?? randomUUID();\n const resourceId = getEffectiveResourceId(requestContext, resource_id) ?? threadId;\n const thread = await memory.createThread({\n threadId,\n resourceId,\n title,\n metadata,\n });\n\n return buildConversationObject({ thread });\n } catch (error) {\n return handleError(error, 'Error creating conversation');\n }\n },\n});\n\nexport const GET_CONVERSATION_ROUTE = createRoute({\n method: 'GET',\n path: '/v1/conversations/:conversationId',\n responseType: 'json',\n pathParamSchema: conversationIdPathParams,\n responseSchema: conversationObjectSchema,\n summary: 'Retrieve a conversation',\n description: 'Returns a conversation object backed by a Mastra memory thread',\n tags: ['Responses'],\n requiresAuth: true,\n requiresPermission: MastraFGAPermissions.AGENTS_READ,\n handler: async ({ mastra, requestContext, conversationId }) => {\n try {\n const match = await findConversationThreadAcrossAgents({ mastra, conversationId, requestContext });\n if (!match) {\n throw new HTTPException(404, { message: `Conversation ${conversationId} was not found` });\n }\n\n return buildConversationObject({ thread: match.thread });\n } catch (error) {\n return handleError(error, 'Error retrieving conversation');\n }\n },\n});\n\nexport const GET_CONVERSATION_ITEMS_ROUTE = createRoute({\n method: 'GET',\n path: '/v1/conversations/:conversationId/items',\n responseType: 'json',\n pathParamSchema: conversationIdPathParams,\n responseSchema: conversationItemsListSchema,\n summary: 'List conversation items',\n description: 'Returns OpenAI-style conversation items derived from the stored thread messages',\n tags: ['Responses'],\n requiresAuth: true,\n requiresPermission: MastraFGAPermissions.AGENTS_READ,\n handler: async ({ mastra, requestContext, conversationId }) => {\n try {\n const match = await findConversationThreadAcrossAgents({ mastra, conversationId, requestContext });\n if (!match) {\n throw new HTTPException(404, { message: `Conversation ${conversationId} was not found` });\n }\n\n const { messages } = await match.memoryStore.listMessages({\n threadId: conversationId,\n page: 0,\n perPage: 1000,\n });\n\n return buildConversationItemsList(mapMastraMessagesToConversationItems(messages));\n } catch (error) {\n return handleError(error, 'Error retrieving conversation');\n }\n },\n});\n\nexport const DELETE_CONVERSATION_ROUTE = createRoute({\n method: 'DELETE',\n path: '/v1/conversations/:conversationId',\n responseType: 'json',\n pathParamSchema: conversationIdPathParams,\n responseSchema: conversationDeletedSchema,\n summary: 'Delete a conversation',\n description: 'Deletes a thread-backed conversation and its stored items',\n tags: ['Responses'],\n requiresAuth: true,\n requiresPermission: MastraFGAPermissions.AGENTS_DELETE,\n handler: async ({ mastra, requestContext, conversationId }) => {\n try {\n const match = await findConversationThreadAcrossAgents({ mastra, conversationId, requestContext });\n if (!match) {\n throw new HTTPException(404, { message: `Conversation ${conversationId} was not found` });\n }\n\n await match.memoryStore.deleteThread({ threadId: conversationId });\n\n return buildConversationDeleted(conversationId);\n } catch (error) {\n return handleError(error, 'Error deleting conversation');\n }\n },\n});\n"]}
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkTF7NSMHW_cjs = require('./chunk-TF7NSMHW.cjs');
4
- var chunkGUWIV3ZN_cjs = require('./chunk-GUWIV3ZN.cjs');
4
+ var chunk4QZCXU3A_cjs = require('./chunk-4QZCXU3A.cjs');
5
5
  var chunkIQMLYFOO_cjs = require('./chunk-IQMLYFOO.cjs');
6
6
  var chunk64YJOWH2_cjs = require('./chunk-64YJOWH2.cjs');
7
7
  var chunkL4M23OMB_cjs = require('./chunk-L4M23OMB.cjs');
@@ -360,7 +360,7 @@ var RESUME_STREAM_WORKFLOW_ROUTE = chunk7756JXUH_cjs.createRoute({
360
360
  pathParamSchema: chunkTF7NSMHW_cjs.workflowIdPathParams,
361
361
  queryParamSchema: chunkDIG2K5CV_cjs.runIdSchema,
362
362
  bodySchema: chunkTF7NSMHW_cjs.resumeBodySchema,
363
- responseSchema: chunkGUWIV3ZN_cjs.streamResponseSchema,
363
+ responseSchema: chunk4QZCXU3A_cjs.streamResponseSchema,
364
364
  summary: "Resume workflow stream",
365
365
  description: "Resumes a suspended workflow execution and continues streaming results",
366
366
  tags: ["Workflows"],
@@ -476,7 +476,7 @@ var OBSERVE_STREAM_WORKFLOW_ROUTE = chunk7756JXUH_cjs.createRoute({
476
476
  responseType: "stream",
477
477
  pathParamSchema: chunkTF7NSMHW_cjs.workflowIdPathParams,
478
478
  queryParamSchema: chunkTF7NSMHW_cjs.observeWorkflowQuerySchema,
479
- responseSchema: chunkGUWIV3ZN_cjs.streamResponseSchema,
479
+ responseSchema: chunk4QZCXU3A_cjs.streamResponseSchema,
480
480
  summary: "Observe workflow stream",
481
481
  description: "Observes and streams updates from an already running workflow execution. Supports position-based resume with offset for efficient reconnection.",
482
482
  tags: ["Workflows"],
@@ -884,7 +884,7 @@ var STREAM_LEGACY_WORKFLOW_ROUTE = chunk7756JXUH_cjs.createRoute({
884
884
  pathParamSchema: chunkTF7NSMHW_cjs.workflowIdPathParams,
885
885
  queryParamSchema: chunkDIG2K5CV_cjs.runIdSchema,
886
886
  bodySchema: chunkTF7NSMHW_cjs.streamWorkflowBodySchema,
887
- responseSchema: chunkGUWIV3ZN_cjs.streamResponseSchema,
887
+ responseSchema: chunk4QZCXU3A_cjs.streamResponseSchema,
888
888
  summary: "[DEPRECATED] Stream workflow with legacy format",
889
889
  description: "Legacy endpoint for streaming workflow execution. Use /workflows/:workflowId/stream instead.",
890
890
  tags: ["Workflows", "Legacy"],
@@ -926,7 +926,7 @@ var OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE = chunk7756JXUH_cjs.createRoute({
926
926
  responseType: "stream",
927
927
  pathParamSchema: chunkTF7NSMHW_cjs.workflowIdPathParams,
928
928
  queryParamSchema: chunkDIG2K5CV_cjs.runIdSchema,
929
- responseSchema: chunkGUWIV3ZN_cjs.streamResponseSchema,
929
+ responseSchema: chunk4QZCXU3A_cjs.streamResponseSchema,
930
930
  summary: "[DEPRECATED] Observe workflow stream with legacy format",
931
931
  description: "Legacy endpoint for observing workflow stream. Use /workflows/:workflowId/observe instead.",
932
932
  tags: ["Workflows", "Legacy"],
@@ -993,5 +993,5 @@ exports.TIME_TRAVEL_ASYNC_WORKFLOW_ROUTE = TIME_TRAVEL_ASYNC_WORKFLOW_ROUTE;
993
993
  exports.TIME_TRAVEL_STREAM_WORKFLOW_ROUTE = TIME_TRAVEL_STREAM_WORKFLOW_ROUTE;
994
994
  exports.TIME_TRAVEL_WORKFLOW_ROUTE = TIME_TRAVEL_WORKFLOW_ROUTE;
995
995
  exports.workflows_exports = workflows_exports;
996
- //# sourceMappingURL=chunk-PTLWJUYU.cjs.map
997
- //# sourceMappingURL=chunk-PTLWJUYU.cjs.map
996
+ //# sourceMappingURL=chunk-D5H4LH6V.cjs.map
997
+ //# sourceMappingURL=chunk-D5H4LH6V.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/server/handlers/workflows.ts"],"names":["__export","HTTPException","WorkflowRegistry","createRoute","z","listWorkflowsResponseSchema","getWorkflowInfo","MastraFGAPermissions","handleError","workflowIdPathParams","workflowInfoSchema","listWorkflowRunsQuerySchema","workflowRunsResponseSchema","getEffectiveResourceId","workflowRunPathParams","workflowRunResultQuerySchema","workflowRunResultSchema","validateRunOwnership","workflowControlResponseSchema","optionalRunIdSchema","createWorkflowRunBodySchema","createWorkflowRunResponseSchema","runIdSchema","streamWorkflowBodySchema","createCachingTransformStream","resumeBodySchema","streamResponseSchema","startAsyncWorkflowBodySchema","workflowExecutionResultSchema","observeWorkflowQuerySchema","createReplayStream","restartBodySchema","timeTravelBodySchema"],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAA,iBAAA,GAAA;AAAAA,0BAAA,CAAA,iBAAA,EAAA;AAAA,EAAA,yBAAA,EAAA,MAAA,yBAAA;AAAA,EAAA,yBAAA,EAAA,MAAA,yBAAA;AAAA,EAAA,+BAAA,EAAA,MAAA,+BAAA;AAAA,EAAA,wBAAA,EAAA,MAAA,wBAAA;AAAA,EAAA,4BAAA,EAAA,MAAA,4BAAA;AAAA,EAAA,oBAAA,EAAA,MAAA,oBAAA;AAAA,EAAA,wBAAA,EAAA,MAAA,wBAAA;AAAA,EAAA,oCAAA,EAAA,MAAA,oCAAA;AAAA,EAAA,6BAAA,EAAA,MAAA,6BAAA;AAAA,EAAA,4CAAA,EAAA,MAAA,4CAAA;AAAA,EAAA,sCAAA,EAAA,MAAA,sCAAA;AAAA,EAAA,4BAAA,EAAA,MAAA,4BAAA;AAAA,EAAA,sBAAA,EAAA,MAAA,sBAAA;AAAA,EAAA,2BAAA,EAAA,MAAA,2BA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;AAEnD,MAAA,IAAI,CAAC,GAAA,EAAK;AACR,QAAA,MAAM,IAAIA,+BAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,0BAA0B,CAAA;AAAA,MACpE;AAEA,MAAA,MAAMgB,sCAAA,CAAqB,KAAK,mBAAmB,CAAA;AAEnD,MAAA,MAAM,IAAA,GAAO,MAAM,QAAA,CAAS,SAAA,CAAU,EAAE,KAAA,EAAO,UAAA,EAAY,GAAA,CAAI,UAAA,EAAY,CAAA;AAC3E,MAAA,MAAM,WAAA,GAAc,OAAO,cAAA,EAAe;AAC1C,MAAA,IAAI,CAAC,WAAA,EAAa;AAChB,QAAA,MAAM,IAAIhB,+BAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,0BAA0B,CAAA;AAAA,MACpE;AAGA,MAAA,MAAM,eAAA,GAAmB,MAAM,WAAA,CAAY,UAAA,CAAW,OAAO,CAAC,CAAA;AAC9D,MAAA,MAAM,MAAA,GAAS,KAAK,mBAAA,EAAoB;AAExC,MAAA,IAAI,CAAC,OAAO,MAAA,EAAQ;AAClB,QAAA,MAAM,IAAIA,+BAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,mCAAmC,CAAA;AAAA,MAC7E;AAEA,MAAA,OAAO6B,yBAAA,CAAgC;AAAA,QACrC,OAAA,EAAS,eAAA;AAAA,QACT,YAAY,MAAA,CAAO;AAAA,OACpB,CAAA;AAAA,IACH,SAAS,KAAA,EAAO;AACd,MAAA,OAAOtB,6BAAA,CAAY,OAAO,iCAAiC,CAAA;AAAA,IAC7D;AAAA,EACF;AACF,CAAC","file":"chunk-PTLWJUYU.cjs","sourcesContent":["import type { RequestContext } from '@mastra/core/di';\nimport { createCachingTransformStream, createReplayStream } from '@mastra/core/stream';\nimport type { WorkflowInfo, ChunkType, StreamEvent, WorkflowStateField } 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 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, validateRunOwnership } from './utils';\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 try {\n workflow = mastra.getWorkflowById(workflowId);\n } catch (error) {\n logger.debug('Error getting workflow, searching agents for workflow', error);\n }\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 = mastra.getServer?.()?.fga;\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\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 fga: { resourceType: 'workflow', resourceIdParam: 'workflowId', permission: MastraFGAPermissions.WORKFLOWS_READ },\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);\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 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 })) || {\n runs: [],\n total: 0,\n };\n return workflowRuns;\n } catch (error) {\n return handleError(error, 'Error getting workflow runs');\n }\n },\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=status,result,metadata)',\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);\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);\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 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 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 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 const { transform } = createCachingTransformStream<ChunkType>({\n cache: serverCache,\n cacheKey: runId,\n });\n return result.fullStream.pipeThrough(transform);\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);\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 const { transform } = createCachingTransformStream<ChunkType>({\n cache: serverCache,\n cacheKey: runId,\n });\n return resumeResult.fullStream.pipeThrough(transform);\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 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);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n void _run.start({\n ...params,\n requestContext,\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);\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);\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\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);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n\n void _run.resume({ ...params, requestContext });\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);\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);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n\n void _run.restart({ ...params, requestContext });\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 }) => {\n try {\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 }) => {\n try {\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();\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);\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);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n\n void _run.timeTravel({ ...params, requestContext });\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);\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 const { transform } = createCachingTransformStream<ChunkType>({\n cache: serverCache,\n cacheKey: runId,\n });\n return result.fullStream.pipeThrough(transform);\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);\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 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);\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"]}
1
+ {"version":3,"sources":["../src/server/handlers/workflows.ts"],"names":["__export","HTTPException","WorkflowRegistry","createRoute","z","listWorkflowsResponseSchema","getWorkflowInfo","MastraFGAPermissions","handleError","workflowIdPathParams","workflowInfoSchema","listWorkflowRunsQuerySchema","workflowRunsResponseSchema","getEffectiveResourceId","workflowRunPathParams","workflowRunResultQuerySchema","workflowRunResultSchema","validateRunOwnership","workflowControlResponseSchema","optionalRunIdSchema","createWorkflowRunBodySchema","createWorkflowRunResponseSchema","runIdSchema","streamWorkflowBodySchema","createCachingTransformStream","resumeBodySchema","streamResponseSchema","startAsyncWorkflowBodySchema","workflowExecutionResultSchema","observeWorkflowQuerySchema","createReplayStream","restartBodySchema","timeTravelBodySchema"],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAA,iBAAA,GAAA;AAAAA,0BAAA,CAAA,iBAAA,EAAA;AAAA,EAAA,yBAAA,EAAA,MAAA,yBAAA;AAAA,EAAA,yBAAA,EAAA,MAAA,yBAAA;AAAA,EAAA,+BAAA,EAAA,MAAA,+BAAA;AAAA,EAAA,wBAAA,EAAA,MAAA,wBAAA;AAAA,EAAA,4BAAA,EAAA,MAAA,4BAAA;AAAA,EAAA,oBAAA,EAAA,MAAA,oBAAA;AAAA,EAAA,wBAAA,EAAA,MAAA,wBAAA;AAAA,EAAA,oCAAA,EAAA,MAAA,oCAAA;AAAA,EAAA,6BAAA,EAAA,MAAA,6BAAA;AAAA,EAAA,4CAAA,EAAA,MAAA,4CAAA;AAAA,EAAA,sCAAA,EAAA,MAAA,sCAAA;AAAA,EAAA,4BAAA,EAAA,MAAA,4BAAA;AAAA,EAAA,sBAAA,EAAA,MAAA,sBAAA;AAAA,EAAA,2BAAA,EAAA,MAAA,2BAAA;AAAA,EAAA,4BAAA,EAAA,MAAA,4BAAA;AAAA,EAAA,qBAAA,EAAA,MAAA,qBAAA;AAAA,EAAA,0BAAA,EAAA,MAAA,0BAAA;AAAA,EAAA,wBAAA,EAAA,MAAA,wBAAA;AAAA,EAAA,4BAAA,EAAA,MAAA,4BAAA;AAAA,EAAA,qBAAA,EAAA,MAAA,qBAAA;AAAA,EAAA,gCAAA,EAAA,MAAA,gCAAA;AAAA,EAAA,iCAAA,EAAA,MAAA,iCAAA;AAAA,EAAA,0BAAA,EAAA,MAAA;AAAA,CAAA,CAAA;AAwCA,eAAe,uBAAA,CAAwB,EAAE,MAAA,EA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AAA,MAAM,IAAIhB,+BAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,0BAA0B,CAAA;AAAA,MACpE;AAGA,MAAA,MAAM,eAAA,GAAmB,MAAM,WAAA,CAAY,UAAA,CAAW,OAAO,CAAC,CAAA;AAC9D,MAAA,MAAM,MAAA,GAAS,KAAK,mBAAA,EAAoB;AAExC,MAAA,IAAI,CAAC,OAAO,MAAA,EAAQ;AAClB,QAAA,MAAM,IAAIA,+BAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,mCAAmC,CAAA;AAAA,MAC7E;AAEA,MAAA,OAAO6B,yBAAA,CAAgC;AAAA,QACrC,OAAA,EAAS,eAAA;AAAA,QACT,YAAY,MAAA,CAAO;AAAA,OACpB,CAAA;AAAA,IACH,SAAS,KAAA,EAAO;AACd,MAAA,OAAOtB,6BAAA,CAAY,OAAO,iCAAiC,CAAA;AAAA,IAC7D;AAAA,EACF;AACF,CAAC","file":"chunk-D5H4LH6V.cjs","sourcesContent":["import type { RequestContext } from '@mastra/core/di';\nimport { createCachingTransformStream, createReplayStream } from '@mastra/core/stream';\nimport type { WorkflowInfo, ChunkType, StreamEvent, WorkflowStateField } 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 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, validateRunOwnership } from './utils';\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 try {\n workflow = mastra.getWorkflowById(workflowId);\n } catch (error) {\n logger.debug('Error getting workflow, searching agents for workflow', error);\n }\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 = mastra.getServer?.()?.fga;\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\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 fga: { resourceType: 'workflow', resourceIdParam: 'workflowId', permission: MastraFGAPermissions.WORKFLOWS_READ },\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);\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 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 })) || {\n runs: [],\n total: 0,\n };\n return workflowRuns;\n } catch (error) {\n return handleError(error, 'Error getting workflow runs');\n }\n },\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=status,result,metadata)',\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);\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);\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 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 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 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 const { transform } = createCachingTransformStream<ChunkType>({\n cache: serverCache,\n cacheKey: runId,\n });\n return result.fullStream.pipeThrough(transform);\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);\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 const { transform } = createCachingTransformStream<ChunkType>({\n cache: serverCache,\n cacheKey: runId,\n });\n return resumeResult.fullStream.pipeThrough(transform);\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 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);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n void _run.start({\n ...params,\n requestContext,\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);\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);\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\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);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n\n void _run.resume({ ...params, requestContext });\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);\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);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n\n void _run.restart({ ...params, requestContext });\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 }) => {\n try {\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 }) => {\n try {\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();\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);\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);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n\n void _run.timeTravel({ ...params, requestContext });\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);\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 const { transform } = createCachingTransformStream<ChunkType>({\n cache: serverCache,\n cacheKey: runId,\n });\n return result.fullStream.pipeThrough(transform);\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);\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 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);\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"]}