@mastra/server 0.0.0-cli-debug-20250611094457 → 0.0.0-client-js-listmessages-agentid-fix-20251119175531

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 (270) hide show
  1. package/CHANGELOG.md +4889 -0
  2. package/LICENSE.md +11 -42
  3. package/README.md +1 -6
  4. package/dist/chunk-2PLXW4ZX.cjs +2777 -0
  5. package/dist/chunk-2PLXW4ZX.cjs.map +1 -0
  6. package/dist/chunk-2YZH5PH6.cjs +200 -0
  7. package/dist/chunk-2YZH5PH6.cjs.map +1 -0
  8. package/dist/chunk-3AMNUUZF.js +124 -0
  9. package/dist/chunk-3AMNUUZF.js.map +1 -0
  10. package/dist/chunk-3F52QCI4.js +192 -0
  11. package/dist/chunk-3F52QCI4.js.map +1 -0
  12. package/dist/{chunk-OCWPVYNI.cjs → chunk-64ITUOXI.cjs} +3 -0
  13. package/dist/chunk-64ITUOXI.cjs.map +1 -0
  14. package/dist/{chunk-NYN7KFXL.js → chunk-6QWQZI4Q.js} +3 -0
  15. package/dist/chunk-6QWQZI4Q.js.map +1 -0
  16. package/dist/{chunk-QLG2PFHE.js → chunk-73PAWDM5.js} +14 -12
  17. package/dist/chunk-73PAWDM5.js.map +1 -0
  18. package/dist/chunk-7HVY3D64.cjs +22955 -0
  19. package/dist/chunk-7HVY3D64.cjs.map +1 -0
  20. package/dist/chunk-A24TSVEZ.cjs +130 -0
  21. package/dist/chunk-A24TSVEZ.cjs.map +1 -0
  22. package/dist/{chunk-CP55EVBK.js → chunk-B3Z6J745.js} +34 -20
  23. package/dist/chunk-B3Z6J745.js.map +1 -0
  24. package/dist/chunk-BTWIR2B7.cjs +28 -0
  25. package/dist/chunk-BTWIR2B7.cjs.map +1 -0
  26. package/dist/chunk-D7T74TVR.js +129 -0
  27. package/dist/chunk-D7T74TVR.js.map +1 -0
  28. package/dist/chunk-EHACNWDL.cjs +681 -0
  29. package/dist/chunk-EHACNWDL.cjs.map +1 -0
  30. package/dist/{chunk-GHC4YV6R.js → chunk-FPBYKMIS.js} +119 -146
  31. package/dist/chunk-FPBYKMIS.js.map +1 -0
  32. package/dist/chunk-GLAZTMX3.cjs +128 -0
  33. package/dist/chunk-GLAZTMX3.cjs.map +1 -0
  34. package/dist/chunk-GU4EWMZB.cjs +769 -0
  35. package/dist/chunk-GU4EWMZB.cjs.map +1 -0
  36. package/dist/chunk-KF3RI45U.cjs +172 -0
  37. package/dist/chunk-KF3RI45U.cjs.map +1 -0
  38. package/dist/{chunk-SDPGVWQJ.cjs → chunk-KJIDZQRA.cjs} +120 -147
  39. package/dist/chunk-KJIDZQRA.cjs.map +1 -0
  40. package/dist/{chunk-55DOQLP6.js → chunk-KWH5QBXP.js} +5 -3
  41. package/dist/chunk-KWH5QBXP.js.map +1 -0
  42. package/dist/chunk-LF2ZLOFP.js +767 -0
  43. package/dist/chunk-LF2ZLOFP.js.map +1 -0
  44. package/dist/chunk-LPM6BBAX.cjs +1043 -0
  45. package/dist/chunk-LPM6BBAX.cjs.map +1 -0
  46. package/dist/chunk-ND5OKOMT.js +165 -0
  47. package/dist/chunk-ND5OKOMT.js.map +1 -0
  48. package/dist/chunk-O7I5CWRX.cjs +44 -0
  49. package/dist/chunk-O7I5CWRX.cjs.map +1 -0
  50. package/dist/{chunk-IMBY5XUG.cjs → chunk-PPMIB3FQ.cjs} +22 -20
  51. package/dist/chunk-PPMIB3FQ.cjs.map +1 -0
  52. package/dist/chunk-PR4QN5HX.js +39 -0
  53. package/dist/chunk-PR4QN5HX.js.map +1 -0
  54. package/dist/chunk-QU6N55W6.cjs +256 -0
  55. package/dist/chunk-QU6N55W6.cjs.map +1 -0
  56. package/dist/chunk-RQK4FQUD.js +1012 -0
  57. package/dist/chunk-RQK4FQUD.js.map +1 -0
  58. package/dist/{chunk-BNEY4P4P.cjs → chunk-S54HNARD.cjs} +20 -18
  59. package/dist/chunk-S54HNARD.cjs.map +1 -0
  60. package/dist/chunk-SHWNNZBL.js +254 -0
  61. package/dist/chunk-SHWNNZBL.js.map +1 -0
  62. package/dist/{chunk-H5PTF3Y4.js → chunk-SZIFSF4T.js} +11 -2
  63. package/dist/chunk-SZIFSF4T.js.map +1 -0
  64. package/dist/chunk-TOCYBDP2.js +46 -0
  65. package/dist/chunk-TOCYBDP2.js.map +1 -0
  66. package/dist/chunk-U7GLIXYO.cjs +534 -0
  67. package/dist/chunk-U7GLIXYO.cjs.map +1 -0
  68. package/dist/chunk-UXGQZUYZ.js +16 -0
  69. package/dist/chunk-UXGQZUYZ.js.map +1 -0
  70. package/dist/chunk-V5WWQN7P.cjs +18 -0
  71. package/dist/chunk-V5WWQN7P.cjs.map +1 -0
  72. package/dist/chunk-V6JYJS7O.js +518 -0
  73. package/dist/chunk-V6JYJS7O.js.map +1 -0
  74. package/dist/chunk-VEVU6EUO.js +22916 -0
  75. package/dist/chunk-VEVU6EUO.js.map +1 -0
  76. package/dist/chunk-W2KMU354.cjs +133 -0
  77. package/dist/chunk-W2KMU354.cjs.map +1 -0
  78. package/dist/chunk-X3MICMI2.cjs +620 -0
  79. package/dist/chunk-X3MICMI2.cjs.map +1 -0
  80. package/dist/chunk-X6C7BUWN.cjs +48 -0
  81. package/dist/chunk-X6C7BUWN.cjs.map +1 -0
  82. package/dist/chunk-Z2O5YVHY.js +661 -0
  83. package/dist/chunk-Z2O5YVHY.js.map +1 -0
  84. package/dist/chunk-ZJ6KEY6H.js +600 -0
  85. package/dist/chunk-ZJ6KEY6H.js.map +1 -0
  86. package/dist/chunk-ZULZ2752.js +2774 -0
  87. package/dist/chunk-ZULZ2752.js.map +1 -0
  88. package/dist/dist-4MVGNSRL.cjs +1150 -0
  89. package/dist/dist-4MVGNSRL.cjs.map +1 -0
  90. package/dist/dist-FZYCV3VB.cjs +940 -0
  91. package/dist/dist-FZYCV3VB.cjs.map +1 -0
  92. package/dist/dist-G2BYZJOC.cjs +928 -0
  93. package/dist/dist-G2BYZJOC.cjs.map +1 -0
  94. package/dist/dist-P4MXBQ3U.cjs +16 -0
  95. package/dist/dist-P4MXBQ3U.cjs.map +1 -0
  96. package/dist/dist-PQZUVLPC.js +937 -0
  97. package/dist/dist-PQZUVLPC.js.map +1 -0
  98. package/dist/dist-R7WYX6LC.js +925 -0
  99. package/dist/dist-R7WYX6LC.js.map +1 -0
  100. package/dist/dist-RFMYFILX.cjs +764 -0
  101. package/dist/dist-RFMYFILX.cjs.map +1 -0
  102. package/dist/dist-X7XR3M3Z.js +1147 -0
  103. package/dist/dist-X7XR3M3Z.js.map +1 -0
  104. package/dist/dist-XVBSOGFK.js +761 -0
  105. package/dist/dist-XVBSOGFK.js.map +1 -0
  106. package/dist/dist-YREX2TJT.js +3 -0
  107. package/dist/dist-YREX2TJT.js.map +1 -0
  108. package/dist/index.cjs +6 -0
  109. package/dist/index.cjs.map +1 -0
  110. package/dist/index.d.ts +1 -0
  111. package/dist/index.d.ts.map +1 -0
  112. package/dist/index.js +5 -0
  113. package/dist/index.js.map +1 -0
  114. package/dist/server/a2a/protocol.d.ts +8 -0
  115. package/dist/server/a2a/protocol.d.ts.map +1 -0
  116. package/dist/server/a2a/store.cjs +25 -0
  117. package/dist/server/a2a/store.cjs.map +1 -0
  118. package/dist/server/a2a/store.d.ts +14 -0
  119. package/dist/server/a2a/store.d.ts.map +1 -0
  120. package/dist/server/a2a/store.js +23 -0
  121. package/dist/server/a2a/store.js.map +1 -0
  122. package/dist/server/a2a/tasks.d.ts +20 -0
  123. package/dist/server/a2a/tasks.d.ts.map +1 -0
  124. package/dist/server/handlers/a2a.cjs +13 -11
  125. package/dist/server/handlers/a2a.cjs.map +1 -0
  126. package/dist/server/handlers/a2a.d.ts +68 -6
  127. package/dist/server/handlers/a2a.d.ts.map +1 -0
  128. package/dist/server/handlers/a2a.js +3 -1
  129. package/dist/server/handlers/a2a.js.map +1 -0
  130. package/dist/server/handlers/agent-builder.cjs +80 -0
  131. package/dist/server/handlers/agent-builder.cjs.map +1 -0
  132. package/dist/server/handlers/agent-builder.d.ts +85 -0
  133. package/dist/server/handlers/agent-builder.d.ts.map +1 -0
  134. package/dist/server/handlers/agent-builder.js +3 -0
  135. package/dist/server/handlers/agent-builder.js.map +1 -0
  136. package/dist/server/handlers/agents.cjs +60 -10
  137. package/dist/server/handlers/agents.cjs.map +1 -0
  138. package/dist/server/handlers/agents.d.ts +194 -6
  139. package/dist/server/handlers/agents.d.ts.map +1 -0
  140. package/dist/server/handlers/agents.js +3 -1
  141. package/dist/server/handlers/agents.js.map +1 -0
  142. package/dist/server/handlers/error.cjs +4 -2
  143. package/dist/server/handlers/error.cjs.map +1 -0
  144. package/dist/server/handlers/error.d.ts +2 -1
  145. package/dist/server/handlers/error.d.ts.map +1 -0
  146. package/dist/server/handlers/error.js +3 -1
  147. package/dist/server/handlers/error.js.map +1 -0
  148. package/dist/server/handlers/logs.cjs +9 -7
  149. package/dist/server/handlers/logs.cjs.map +1 -0
  150. package/dist/server/handlers/logs.d.ts +34 -3
  151. package/dist/server/handlers/logs.d.ts.map +1 -0
  152. package/dist/server/handlers/logs.js +3 -1
  153. package/dist/server/handlers/logs.js.map +1 -0
  154. package/dist/server/handlers/memory.cjs +37 -11
  155. package/dist/server/handlers/memory.cjs.map +1 -0
  156. package/dist/server/handlers/memory.d.ts +113 -8
  157. package/dist/server/handlers/memory.d.ts.map +1 -0
  158. package/dist/server/handlers/memory.js +3 -1
  159. package/dist/server/handlers/memory.js.map +1 -0
  160. package/dist/server/handlers/observability.cjs +24 -0
  161. package/dist/server/handlers/observability.cjs.map +1 -0
  162. package/dist/server/handlers/observability.d.ts +49 -0
  163. package/dist/server/handlers/observability.d.ts.map +1 -0
  164. package/dist/server/handlers/observability.js +3 -0
  165. package/dist/server/handlers/observability.js.map +1 -0
  166. package/dist/server/handlers/scores.cjs +32 -0
  167. package/dist/server/handlers/scores.cjs.map +1 -0
  168. package/dist/server/handlers/scores.d.ts +152 -0
  169. package/dist/server/handlers/scores.d.ts.map +1 -0
  170. package/dist/server/handlers/scores.js +3 -0
  171. package/dist/server/handlers/scores.js.map +1 -0
  172. package/dist/server/handlers/tools.cjs +12 -6
  173. package/dist/server/handlers/tools.cjs.map +1 -0
  174. package/dist/server/handlers/tools.d.ts +25 -4
  175. package/dist/server/handlers/tools.d.ts.map +1 -0
  176. package/dist/server/handlers/tools.js +3 -1
  177. package/dist/server/handlers/tools.js.map +1 -0
  178. package/dist/server/handlers/utils.cjs +8 -2
  179. package/dist/server/handlers/utils.cjs.map +1 -0
  180. package/dist/server/handlers/utils.d.ts +8 -1
  181. package/dist/server/handlers/utils.d.ts.map +1 -0
  182. package/dist/server/handlers/utils.js +3 -1
  183. package/dist/server/handlers/utils.js.map +1 -0
  184. package/dist/server/handlers/vector.cjs +9 -7
  185. package/dist/server/handlers/vector.cjs.map +1 -0
  186. package/dist/server/handlers/vector.d.ts +51 -6
  187. package/dist/server/handlers/vector.d.ts.map +1 -0
  188. package/dist/server/handlers/vector.js +3 -1
  189. package/dist/server/handlers/vector.js.map +1 -0
  190. package/dist/server/handlers/voice.cjs +7 -5
  191. package/dist/server/handlers/voice.cjs.map +1 -0
  192. package/dist/server/handlers/voice.d.ts +41 -4
  193. package/dist/server/handlers/voice.d.ts.map +1 -0
  194. package/dist/server/handlers/voice.js +3 -1
  195. package/dist/server/handlers/voice.js.map +1 -0
  196. package/dist/server/handlers/workflows.cjs +46 -16
  197. package/dist/server/handlers/workflows.cjs.map +1 -0
  198. package/dist/server/handlers/workflows.d.ts +88 -11
  199. package/dist/server/handlers/workflows.d.ts.map +1 -0
  200. package/dist/server/handlers/workflows.js +3 -1
  201. package/dist/server/handlers/workflows.js.map +1 -0
  202. package/dist/server/handlers.cjs +33 -31
  203. package/dist/server/handlers.cjs.map +1 -0
  204. package/dist/server/handlers.d.ts +12 -11
  205. package/dist/server/handlers.d.ts.map +1 -0
  206. package/dist/server/handlers.js +13 -11
  207. package/dist/server/handlers.js.map +1 -0
  208. package/dist/server/http-exception.d.ts +82 -0
  209. package/dist/server/http-exception.d.ts.map +1 -0
  210. package/dist/server/types.d.ts +10 -0
  211. package/dist/server/types.d.ts.map +1 -0
  212. package/dist/server/utils.d.ts +45 -0
  213. package/dist/server/utils.d.ts.map +1 -0
  214. package/dist/token-375W3LEI.cjs +64 -0
  215. package/dist/token-375W3LEI.cjs.map +1 -0
  216. package/dist/token-C3IMNCC4.js +62 -0
  217. package/dist/token-C3IMNCC4.js.map +1 -0
  218. package/dist/token-util-CV3RRG6K.cjs +9 -0
  219. package/dist/token-util-CV3RRG6K.cjs.map +1 -0
  220. package/dist/token-util-E5QO2RCL.js +7 -0
  221. package/dist/token-util-E5QO2RCL.js.map +1 -0
  222. package/package.json +46 -19
  223. package/dist/_tsup-dts-rollup.d.cts +0 -860
  224. package/dist/_tsup-dts-rollup.d.ts +0 -860
  225. package/dist/chunk-57CJTIPW.cjs +0 -18
  226. package/dist/chunk-64U3UDTH.cjs +0 -13
  227. package/dist/chunk-6F2H7Y45.js +0 -255
  228. package/dist/chunk-6TJSHFCJ.cjs +0 -221
  229. package/dist/chunk-75ZPJI57.cjs +0 -9
  230. package/dist/chunk-7IBZ4L35.js +0 -344
  231. package/dist/chunk-B4MQFJ7G.cjs +0 -145
  232. package/dist/chunk-BFOA2QQY.js +0 -141
  233. package/dist/chunk-C7564HUT.js +0 -142
  234. package/dist/chunk-CMMOIUFC.cjs +0 -114
  235. package/dist/chunk-HYP7B2TL.js +0 -122
  236. package/dist/chunk-I7KJZNX5.js +0 -211
  237. package/dist/chunk-JEWNMAYQ.cjs +0 -263
  238. package/dist/chunk-JKF6PRPU.cjs +0 -357
  239. package/dist/chunk-M5ABIP7D.js +0 -11
  240. package/dist/chunk-MLKGABMK.js +0 -7
  241. package/dist/chunk-TEZOEGR4.js +0 -320
  242. package/dist/chunk-TJO277H7.cjs +0 -128
  243. package/dist/chunk-UZ7FJ66C.cjs +0 -332
  244. package/dist/chunk-VPNDC2DI.cjs +0 -148
  245. package/dist/chunk-WKWHYFX4.js +0 -2001
  246. package/dist/chunk-XUGQSVZ4.cjs +0 -2004
  247. package/dist/index.d.cts +0 -1
  248. package/dist/server/handlers/a2a.d.cts +0 -6
  249. package/dist/server/handlers/agents.d.cts +0 -6
  250. package/dist/server/handlers/error.d.cts +0 -1
  251. package/dist/server/handlers/legacyWorkflows.cjs +0 -46
  252. package/dist/server/handlers/legacyWorkflows.d.cts +0 -10
  253. package/dist/server/handlers/legacyWorkflows.d.ts +0 -10
  254. package/dist/server/handlers/legacyWorkflows.js +0 -1
  255. package/dist/server/handlers/logs.d.cts +0 -3
  256. package/dist/server/handlers/memory.d.cts +0 -8
  257. package/dist/server/handlers/network.cjs +0 -22
  258. package/dist/server/handlers/network.d.cts +0 -4
  259. package/dist/server/handlers/network.d.ts +0 -4
  260. package/dist/server/handlers/network.js +0 -1
  261. package/dist/server/handlers/telemetry.cjs +0 -14
  262. package/dist/server/handlers/telemetry.d.cts +0 -2
  263. package/dist/server/handlers/telemetry.d.ts +0 -2
  264. package/dist/server/handlers/telemetry.js +0 -1
  265. package/dist/server/handlers/tools.d.cts +0 -4
  266. package/dist/server/handlers/utils.d.cts +0 -1
  267. package/dist/server/handlers/vector.d.cts +0 -6
  268. package/dist/server/handlers/voice.d.cts +0 -4
  269. package/dist/server/handlers/workflows.d.cts +0 -11
  270. package/dist/server/handlers.d.cts +0 -11
@@ -1,320 +0,0 @@
1
- import { stringify, esm_default } from './chunk-WKWHYFX4.js';
2
- import { handleError } from './chunk-M5ABIP7D.js';
3
- import { HTTPException } from './chunk-NYN7KFXL.js';
4
- import { __export } from './chunk-MLKGABMK.js';
5
- import { ReadableStream } from 'stream/web';
6
-
7
- // src/server/handlers/legacyWorkflows.ts
8
- var legacyWorkflows_exports = {};
9
- __export(legacyWorkflows_exports, {
10
- createLegacyWorkflowRunHandler: () => createLegacyWorkflowRunHandler,
11
- getLegacyWorkflowByIdHandler: () => getLegacyWorkflowByIdHandler,
12
- getLegacyWorkflowRunHandler: () => getLegacyWorkflowRunHandler,
13
- getLegacyWorkflowRunsHandler: () => getLegacyWorkflowRunsHandler,
14
- getLegacyWorkflowsHandler: () => getLegacyWorkflowsHandler,
15
- resumeAsyncLegacyWorkflowHandler: () => resumeAsyncLegacyWorkflowHandler,
16
- resumeLegacyWorkflowHandler: () => resumeLegacyWorkflowHandler,
17
- startAsyncLegacyWorkflowHandler: () => startAsyncLegacyWorkflowHandler,
18
- startLegacyWorkflowRunHandler: () => startLegacyWorkflowRunHandler,
19
- watchLegacyWorkflowHandler: () => watchLegacyWorkflowHandler
20
- });
21
- async function getLegacyWorkflowsHandler({ mastra }) {
22
- try {
23
- const workflows = mastra.legacy_getWorkflows({ serialized: false });
24
- const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
25
- if (workflow.isNested) return acc;
26
- acc[key] = {
27
- stepGraph: workflow.stepGraph,
28
- stepSubscriberGraph: workflow.stepSubscriberGraph,
29
- serializedStepGraph: workflow.serializedStepGraph,
30
- serializedStepSubscriberGraph: workflow.serializedStepSubscriberGraph,
31
- name: workflow.name,
32
- triggerSchema: workflow.triggerSchema ? stringify(esm_default(workflow.triggerSchema)) : void 0,
33
- steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
34
- const _step = step;
35
- acc2[key2] = {
36
- id: _step.id,
37
- description: _step.description,
38
- workflowId: _step.workflowId,
39
- inputSchema: _step.inputSchema ? stringify(esm_default(_step.inputSchema)) : void 0,
40
- outputSchema: _step.outputSchema ? stringify(esm_default(_step.outputSchema)) : void 0
41
- };
42
- return acc2;
43
- }, {})
44
- };
45
- return acc;
46
- }, {});
47
- return _workflows;
48
- } catch (error) {
49
- throw new HTTPException(500, { message: error?.message || "Error getting workflows" });
50
- }
51
- }
52
- async function getLegacyWorkflowByIdHandler({ mastra, workflowId }) {
53
- try {
54
- if (!workflowId) {
55
- throw new HTTPException(400, { message: "Workflow ID is required" });
56
- }
57
- const workflow = mastra.legacy_getWorkflow(workflowId);
58
- if (!workflow) {
59
- throw new HTTPException(404, { message: "Workflow not found" });
60
- }
61
- return {
62
- stepGraph: workflow.stepGraph,
63
- stepSubscriberGraph: workflow.stepSubscriberGraph,
64
- serializedStepGraph: workflow.serializedStepGraph,
65
- serializedStepSubscriberGraph: workflow.serializedStepSubscriberGraph,
66
- name: workflow.name,
67
- triggerSchema: workflow.triggerSchema ? stringify(esm_default(workflow.triggerSchema)) : void 0,
68
- steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
69
- const _step = step;
70
- acc[key] = {
71
- id: _step.id,
72
- description: _step.description,
73
- workflowId: _step.workflowId,
74
- inputSchema: _step.inputSchema ? stringify(esm_default(_step.inputSchema)) : void 0,
75
- outputSchema: _step.outputSchema ? stringify(esm_default(_step.outputSchema)) : void 0
76
- };
77
- return acc;
78
- }, {})
79
- };
80
- } catch (error) {
81
- throw new HTTPException(500, { message: error?.message || "Error getting workflow" });
82
- }
83
- }
84
- async function startAsyncLegacyWorkflowHandler({
85
- mastra,
86
- runtimeContext,
87
- workflowId,
88
- runId,
89
- triggerData
90
- }) {
91
- try {
92
- if (!workflowId) {
93
- throw new HTTPException(400, { message: "Workflow ID is required" });
94
- }
95
- const workflow = mastra.legacy_getWorkflow(workflowId);
96
- if (!workflow) {
97
- throw new HTTPException(404, { message: "Workflow not found" });
98
- }
99
- if (!runId) {
100
- const newRun = workflow.createRun();
101
- const result2 = await newRun.start({
102
- triggerData,
103
- runtimeContext
104
- });
105
- return result2;
106
- }
107
- const run = workflow.getMemoryRun(runId);
108
- if (!run) {
109
- throw new HTTPException(404, { message: "Workflow run not found" });
110
- }
111
- const result = await run.start({
112
- triggerData,
113
- runtimeContext
114
- });
115
- return result;
116
- } catch (error) {
117
- throw new HTTPException(500, { message: error?.message || "Error executing workflow" });
118
- }
119
- }
120
- async function getLegacyWorkflowRunHandler({
121
- mastra,
122
- workflowId,
123
- runId
124
- }) {
125
- try {
126
- if (!workflowId) {
127
- throw new HTTPException(400, { message: "Workflow ID is required" });
128
- }
129
- if (!runId) {
130
- throw new HTTPException(400, { message: "Run ID is required" });
131
- }
132
- const workflow = mastra.legacy_getWorkflow(workflowId);
133
- if (!workflow) {
134
- throw new HTTPException(404, { message: "Workflow not found" });
135
- }
136
- const run = await workflow.getRun(runId);
137
- if (!run) {
138
- throw new HTTPException(404, { message: "Workflow run not found" });
139
- }
140
- return run;
141
- } catch (error) {
142
- throw new HTTPException(500, { message: error?.message || "Error getting workflow run" });
143
- }
144
- }
145
- async function createLegacyWorkflowRunHandler({
146
- mastra,
147
- workflowId,
148
- runId: prevRunId
149
- }) {
150
- try {
151
- if (!workflowId) {
152
- throw new HTTPException(400, { message: "Workflow ID is required" });
153
- }
154
- const workflow = mastra.legacy_getWorkflow(workflowId);
155
- if (!workflow) {
156
- throw new HTTPException(404, { message: "Workflow not found" });
157
- }
158
- const newRun = workflow.createRun({ runId: prevRunId });
159
- return { runId: newRun.runId };
160
- } catch (error) {
161
- throw new HTTPException(500, { message: error?.message || "Error creating workflow run" });
162
- }
163
- }
164
- async function startLegacyWorkflowRunHandler({
165
- mastra,
166
- runtimeContext,
167
- workflowId,
168
- runId,
169
- triggerData
170
- }) {
171
- try {
172
- if (!workflowId) {
173
- throw new HTTPException(400, { message: "Workflow ID is required" });
174
- }
175
- if (!runId) {
176
- throw new HTTPException(400, { message: "runId required to start run" });
177
- }
178
- const workflow = mastra.legacy_getWorkflow(workflowId);
179
- const run = workflow.getMemoryRun(runId);
180
- if (!run) {
181
- throw new HTTPException(404, { message: "Workflow run not found" });
182
- }
183
- void run.start({
184
- triggerData,
185
- runtimeContext
186
- });
187
- return { message: "Workflow run started" };
188
- } catch (e) {
189
- return handleError(e, "Error starting workflow run");
190
- }
191
- }
192
- async function watchLegacyWorkflowHandler({
193
- mastra,
194
- workflowId,
195
- runId
196
- }) {
197
- try {
198
- if (!workflowId) {
199
- throw new HTTPException(400, { message: "Workflow ID is required" });
200
- }
201
- if (!runId) {
202
- throw new HTTPException(400, { message: "runId required to watch workflow" });
203
- }
204
- const workflow = mastra.legacy_getWorkflow(workflowId);
205
- const run = workflow.getMemoryRun(runId);
206
- if (!run) {
207
- throw new HTTPException(404, { message: "Workflow run not found" });
208
- }
209
- let unwatch;
210
- let asyncRef = null;
211
- const stream = new ReadableStream({
212
- start(controller) {
213
- unwatch = run.watch(({ activePaths, runId: runId2, timestamp, results }) => {
214
- const activePathsObj = Object.fromEntries(activePaths);
215
- controller.enqueue(JSON.stringify({ activePaths: activePathsObj, runId: runId2, timestamp, results }));
216
- if (asyncRef) {
217
- clearImmediate(asyncRef);
218
- asyncRef = null;
219
- }
220
- asyncRef = setImmediate(() => {
221
- const runDone = Object.values(activePathsObj).every((value) => value.status !== "executing");
222
- if (runDone) {
223
- controller.close();
224
- unwatch?.();
225
- }
226
- });
227
- });
228
- },
229
- cancel() {
230
- unwatch?.();
231
- }
232
- });
233
- return stream;
234
- } catch (error) {
235
- return handleError(error, "Error watching workflow");
236
- }
237
- }
238
- async function resumeAsyncLegacyWorkflowHandler({
239
- mastra,
240
- workflowId,
241
- runId,
242
- body,
243
- runtimeContext
244
- }) {
245
- try {
246
- if (!workflowId) {
247
- throw new HTTPException(400, { message: "Workflow ID is required" });
248
- }
249
- if (!runId) {
250
- throw new HTTPException(400, { message: "runId required to resume workflow" });
251
- }
252
- const workflow = mastra.legacy_getWorkflow(workflowId);
253
- const run = workflow.getMemoryRun(runId);
254
- if (!run) {
255
- throw new HTTPException(404, { message: "Workflow run not found" });
256
- }
257
- const result = await run.resume({
258
- stepId: body.stepId,
259
- context: body.context,
260
- runtimeContext
261
- });
262
- return result;
263
- } catch (error) {
264
- return handleError(error, "Error resuming workflow step");
265
- }
266
- }
267
- async function resumeLegacyWorkflowHandler({
268
- mastra,
269
- workflowId,
270
- runId,
271
- body,
272
- runtimeContext
273
- }) {
274
- try {
275
- if (!workflowId) {
276
- throw new HTTPException(400, { message: "Workflow ID is required" });
277
- }
278
- if (!runId) {
279
- throw new HTTPException(400, { message: "runId required to resume workflow" });
280
- }
281
- const workflow = mastra.legacy_getWorkflow(workflowId);
282
- const run = workflow.getMemoryRun(runId);
283
- if (!run) {
284
- throw new HTTPException(404, { message: "Workflow run not found" });
285
- }
286
- void run.resume({
287
- stepId: body.stepId,
288
- context: body.context,
289
- runtimeContext
290
- });
291
- return { message: "Workflow run resumed" };
292
- } catch (error) {
293
- return handleError(error, "Error resuming workflow");
294
- }
295
- }
296
- async function getLegacyWorkflowRunsHandler({
297
- mastra,
298
- workflowId,
299
- fromDate,
300
- toDate,
301
- limit,
302
- offset,
303
- resourceId
304
- }) {
305
- try {
306
- if (!workflowId) {
307
- throw new HTTPException(400, { message: "Workflow ID is required" });
308
- }
309
- const workflow = mastra.legacy_getWorkflow(workflowId);
310
- const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
311
- runs: [],
312
- total: 0
313
- };
314
- return workflowRuns;
315
- } catch (error) {
316
- return handleError(error, "Error getting workflow runs");
317
- }
318
- }
319
-
320
- export { createLegacyWorkflowRunHandler, getLegacyWorkflowByIdHandler, getLegacyWorkflowRunHandler, getLegacyWorkflowRunsHandler, getLegacyWorkflowsHandler, legacyWorkflows_exports, resumeAsyncLegacyWorkflowHandler, resumeLegacyWorkflowHandler, startAsyncLegacyWorkflowHandler, startLegacyWorkflowRunHandler, watchLegacyWorkflowHandler };
@@ -1,128 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkXUGQSVZ4_cjs = require('./chunk-XUGQSVZ4.cjs');
4
- var chunk57CJTIPW_cjs = require('./chunk-57CJTIPW.cjs');
5
- var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
6
- var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
7
- var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
8
- var tools = require('@mastra/core/tools');
9
-
10
- // src/server/handlers/tools.ts
11
- var tools_exports = {};
12
- chunk75ZPJI57_cjs.__export(tools_exports, {
13
- executeAgentToolHandler: () => executeAgentToolHandler,
14
- executeToolHandler: () => executeToolHandler,
15
- getToolByIdHandler: () => getToolByIdHandler,
16
- getToolsHandler: () => getToolsHandler
17
- });
18
- async function getToolsHandler({ tools }) {
19
- try {
20
- if (!tools) {
21
- return {};
22
- }
23
- const serializedTools = Object.entries(tools).reduce(
24
- (acc, [id, _tool]) => {
25
- const tool = _tool;
26
- acc[id] = {
27
- ...tool,
28
- inputSchema: tool.inputSchema ? chunkXUGQSVZ4_cjs.stringify(chunkXUGQSVZ4_cjs.esm_default(tool.inputSchema)) : void 0,
29
- outputSchema: tool.outputSchema ? chunkXUGQSVZ4_cjs.stringify(chunkXUGQSVZ4_cjs.esm_default(tool.outputSchema)) : void 0
30
- };
31
- return acc;
32
- },
33
- {}
34
- );
35
- return serializedTools;
36
- } catch (error) {
37
- return chunk64U3UDTH_cjs.handleError(error, "Error getting tools");
38
- }
39
- }
40
- async function getToolByIdHandler({ tools, toolId }) {
41
- try {
42
- const tool = Object.values(tools || {}).find((tool2) => tool2.id === toolId);
43
- if (!tool) {
44
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Tool not found" });
45
- }
46
- const serializedTool = {
47
- ...tool,
48
- inputSchema: tool.inputSchema ? chunkXUGQSVZ4_cjs.stringify(chunkXUGQSVZ4_cjs.esm_default(tool.inputSchema)) : void 0,
49
- outputSchema: tool.outputSchema ? chunkXUGQSVZ4_cjs.stringify(chunkXUGQSVZ4_cjs.esm_default(tool.outputSchema)) : void 0
50
- };
51
- return serializedTool;
52
- } catch (error) {
53
- return chunk64U3UDTH_cjs.handleError(error, "Error getting tool");
54
- }
55
- }
56
- function executeToolHandler(tools$1) {
57
- return async ({
58
- mastra,
59
- runId,
60
- toolId,
61
- data,
62
- runtimeContext
63
- }) => {
64
- try {
65
- if (!toolId) {
66
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Tool ID is required" });
67
- }
68
- const tool = Object.values(tools$1 || {}).find((tool2) => tool2.id === toolId);
69
- if (!tool) {
70
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Tool not found" });
71
- }
72
- if (!tool?.execute) {
73
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Tool is not executable" });
74
- }
75
- chunk57CJTIPW_cjs.validateBody({ data });
76
- if (tools.isVercelTool(tool)) {
77
- const result2 = await tool.execute(data);
78
- return result2;
79
- }
80
- const result = await tool.execute({
81
- context: data,
82
- mastra,
83
- runId,
84
- runtimeContext
85
- });
86
- return result;
87
- } catch (error) {
88
- return chunk64U3UDTH_cjs.handleError(error, "Error executing tool");
89
- }
90
- };
91
- }
92
- async function executeAgentToolHandler({
93
- mastra,
94
- agentId,
95
- toolId,
96
- data,
97
- runtimeContext
98
- }) {
99
- try {
100
- const agent = agentId ? mastra.getAgent(agentId) : null;
101
- if (!agent) {
102
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Tool not found" });
103
- }
104
- const agentTools = await agent.getTools({ runtimeContext });
105
- const tool = Object.values(agentTools || {}).find((tool2) => tool2.id === toolId);
106
- if (!tool) {
107
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Tool not found" });
108
- }
109
- if (!tool?.execute) {
110
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Tool is not executable" });
111
- }
112
- const result = await tool.execute({
113
- context: data,
114
- runtimeContext,
115
- mastra,
116
- runId: agentId
117
- });
118
- return result;
119
- } catch (error) {
120
- return chunk64U3UDTH_cjs.handleError(error, "Error executing tool");
121
- }
122
- }
123
-
124
- exports.executeAgentToolHandler = executeAgentToolHandler;
125
- exports.executeToolHandler = executeToolHandler;
126
- exports.getToolByIdHandler = getToolByIdHandler;
127
- exports.getToolsHandler = getToolsHandler;
128
- exports.tools_exports = tools_exports;