@mastra/server 0.0.0-cloud-transporter-20250513033346 → 0.0.0-cloud-storage-adapter-20251106204059

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 (273) hide show
  1. package/CHANGELOG.md +4864 -0
  2. package/LICENSE.md +11 -42
  3. package/README.md +1 -6
  4. package/dist/chunk-2IS5WICF.js +23036 -0
  5. package/dist/chunk-2IS5WICF.js.map +1 -0
  6. package/dist/chunk-2PLXW4ZX.cjs +2777 -0
  7. package/dist/chunk-2PLXW4ZX.cjs.map +1 -0
  8. package/dist/chunk-2YZH5PH6.cjs +200 -0
  9. package/dist/chunk-2YZH5PH6.cjs.map +1 -0
  10. package/dist/chunk-3AMNUUZF.js +124 -0
  11. package/dist/chunk-3AMNUUZF.js.map +1 -0
  12. package/dist/chunk-3F52QCI4.js +192 -0
  13. package/dist/chunk-3F52QCI4.js.map +1 -0
  14. package/dist/chunk-4JF5WXPL.js +502 -0
  15. package/dist/chunk-4JF5WXPL.js.map +1 -0
  16. package/dist/{chunk-OCWPVYNI.cjs → chunk-64ITUOXI.cjs} +3 -0
  17. package/dist/chunk-64ITUOXI.cjs.map +1 -0
  18. package/dist/{chunk-NYN7KFXL.js → chunk-6QWQZI4Q.js} +3 -0
  19. package/dist/chunk-6QWQZI4Q.js.map +1 -0
  20. package/dist/chunk-73PAWDM5.js +83 -0
  21. package/dist/chunk-73PAWDM5.js.map +1 -0
  22. package/dist/chunk-A24TSVEZ.cjs +130 -0
  23. package/dist/chunk-A24TSVEZ.cjs.map +1 -0
  24. package/dist/chunk-A2NPD5N6.cjs +517 -0
  25. package/dist/chunk-A2NPD5N6.cjs.map +1 -0
  26. package/dist/chunk-B3Z6J745.js +122 -0
  27. package/dist/chunk-B3Z6J745.js.map +1 -0
  28. package/dist/chunk-BTWIR2B7.cjs +28 -0
  29. package/dist/chunk-BTWIR2B7.cjs.map +1 -0
  30. package/dist/chunk-D7T74TVR.js +129 -0
  31. package/dist/chunk-D7T74TVR.js.map +1 -0
  32. package/dist/chunk-EHACNWDL.cjs +681 -0
  33. package/dist/chunk-EHACNWDL.cjs.map +1 -0
  34. package/dist/{chunk-P6SCPDYW.js → chunk-FPBYKMIS.js} +124 -147
  35. package/dist/chunk-FPBYKMIS.js.map +1 -0
  36. package/dist/chunk-GLAZTMX3.cjs +128 -0
  37. package/dist/chunk-GLAZTMX3.cjs.map +1 -0
  38. package/dist/chunk-GU4EWMZB.cjs +769 -0
  39. package/dist/chunk-GU4EWMZB.cjs.map +1 -0
  40. package/dist/chunk-ID6JYDNL.cjs +23075 -0
  41. package/dist/chunk-ID6JYDNL.cjs.map +1 -0
  42. package/dist/chunk-KF3RI45U.cjs +172 -0
  43. package/dist/chunk-KF3RI45U.cjs.map +1 -0
  44. package/dist/{chunk-5SN4U5AC.cjs → chunk-KJIDZQRA.cjs} +125 -148
  45. package/dist/chunk-KJIDZQRA.cjs.map +1 -0
  46. package/dist/{chunk-IU5VO2I2.js → chunk-KWH5QBXP.js} +7 -5
  47. package/dist/chunk-KWH5QBXP.js.map +1 -0
  48. package/dist/chunk-LF2ZLOFP.js +767 -0
  49. package/dist/chunk-LF2ZLOFP.js.map +1 -0
  50. package/dist/chunk-LPM6BBAX.cjs +1043 -0
  51. package/dist/chunk-LPM6BBAX.cjs.map +1 -0
  52. package/dist/chunk-ND5OKOMT.js +165 -0
  53. package/dist/chunk-ND5OKOMT.js.map +1 -0
  54. package/dist/chunk-O7I5CWRX.cjs +44 -0
  55. package/dist/chunk-O7I5CWRX.cjs.map +1 -0
  56. package/dist/chunk-PPMIB3FQ.cjs +88 -0
  57. package/dist/chunk-PPMIB3FQ.cjs.map +1 -0
  58. package/dist/chunk-PR4QN5HX.js +39 -0
  59. package/dist/chunk-PR4QN5HX.js.map +1 -0
  60. package/dist/chunk-QU6N55W6.cjs +256 -0
  61. package/dist/chunk-QU6N55W6.cjs.map +1 -0
  62. package/dist/chunk-RQK4FQUD.js +1012 -0
  63. package/dist/chunk-RQK4FQUD.js.map +1 -0
  64. package/dist/{chunk-4YZ3U35L.cjs → chunk-S54HNARD.cjs} +22 -20
  65. package/dist/chunk-S54HNARD.cjs.map +1 -0
  66. package/dist/chunk-SHWNNZBL.js +254 -0
  67. package/dist/chunk-SHWNNZBL.js.map +1 -0
  68. package/dist/{chunk-H5PTF3Y4.js → chunk-SZIFSF4T.js} +11 -2
  69. package/dist/chunk-SZIFSF4T.js.map +1 -0
  70. package/dist/chunk-TOCYBDP2.js +46 -0
  71. package/dist/chunk-TOCYBDP2.js.map +1 -0
  72. package/dist/chunk-UXGQZUYZ.js +16 -0
  73. package/dist/chunk-UXGQZUYZ.js.map +1 -0
  74. package/dist/chunk-V5WWQN7P.cjs +18 -0
  75. package/dist/chunk-V5WWQN7P.cjs.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 +34 -12
  155. package/dist/server/handlers/memory.cjs.map +1 -0
  156. package/dist/server/handlers/memory.d.ts +112 -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 +10 -4
  191. package/dist/server/handlers/voice.cjs.map +1 -0
  192. package/dist/server/handlers/voice.d.ts +41 -3
  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 +50 -16
  197. package/dist/server/handlers/workflows.cjs.map +1 -0
  198. package/dist/server/handlers/workflows.d.ts +88 -10
  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 +34 -32
  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 -21
  223. package/dist/_tsup-dts-rollup.d.cts +0 -815
  224. package/dist/_tsup-dts-rollup.d.ts +0 -815
  225. package/dist/chunk-57CJTIPW.cjs +0 -18
  226. package/dist/chunk-64U3UDTH.cjs +0 -13
  227. package/dist/chunk-75ZPJI57.cjs +0 -9
  228. package/dist/chunk-C7564HUT.js +0 -142
  229. package/dist/chunk-D4IRYCUI.cjs +0 -235
  230. package/dist/chunk-DJJIUEL2.js +0 -211
  231. package/dist/chunk-EJO45KYT.js +0 -320
  232. package/dist/chunk-HFWCEP5S.js +0 -89
  233. package/dist/chunk-HWZVAG3H.js +0 -49
  234. package/dist/chunk-I2B73Y4I.cjs +0 -332
  235. package/dist/chunk-LIVAK2DM.js +0 -2001
  236. package/dist/chunk-M5ABIP7D.js +0 -11
  237. package/dist/chunk-MHKNLNAN.cjs +0 -142
  238. package/dist/chunk-MIQYDLLM.js +0 -329
  239. package/dist/chunk-MLKGABMK.js +0 -7
  240. package/dist/chunk-OGCNNUHF.cjs +0 -54
  241. package/dist/chunk-OR3CIE2H.js +0 -138
  242. package/dist/chunk-TJKLBTFB.js +0 -132
  243. package/dist/chunk-UCTEMO2Q.cjs +0 -341
  244. package/dist/chunk-VPNDC2DI.cjs +0 -148
  245. package/dist/chunk-WUC6LSTW.js +0 -227
  246. package/dist/chunk-Y7UWRW5X.cjs +0 -221
  247. package/dist/chunk-YBVOQN4M.cjs +0 -94
  248. package/dist/chunk-YWLUOY3D.cjs +0 -2004
  249. package/dist/chunk-ZE5AAC4I.cjs +0 -138
  250. package/dist/index.d.cts +0 -1
  251. package/dist/server/handlers/a2a.d.cts +0 -6
  252. package/dist/server/handlers/agents.d.cts +0 -6
  253. package/dist/server/handlers/error.d.cts +0 -1
  254. package/dist/server/handlers/logs.d.cts +0 -3
  255. package/dist/server/handlers/memory.d.cts +0 -8
  256. package/dist/server/handlers/network.cjs +0 -22
  257. package/dist/server/handlers/network.d.cts +0 -4
  258. package/dist/server/handlers/network.d.ts +0 -4
  259. package/dist/server/handlers/network.js +0 -1
  260. package/dist/server/handlers/telemetry.cjs +0 -14
  261. package/dist/server/handlers/telemetry.d.cts +0 -2
  262. package/dist/server/handlers/telemetry.d.ts +0 -2
  263. package/dist/server/handlers/telemetry.js +0 -1
  264. package/dist/server/handlers/tools.d.cts +0 -4
  265. package/dist/server/handlers/utils.d.cts +0 -1
  266. package/dist/server/handlers/vNextWorkflows.cjs +0 -46
  267. package/dist/server/handlers/vNextWorkflows.d.cts +0 -10
  268. package/dist/server/handlers/vNextWorkflows.d.ts +0 -10
  269. package/dist/server/handlers/vNextWorkflows.js +0 -1
  270. package/dist/server/handlers/vector.d.cts +0 -6
  271. package/dist/server/handlers/voice.d.cts +0 -3
  272. package/dist/server/handlers/workflows.d.cts +0 -10
  273. package/dist/server/handlers.d.cts +0 -11
@@ -1,132 +0,0 @@
1
- import { stringify, esm_default } from './chunk-LIVAK2DM.js';
2
- import { validateBody } from './chunk-H5PTF3Y4.js';
3
- import { handleError } from './chunk-M5ABIP7D.js';
4
- import { HTTPException } from './chunk-NYN7KFXL.js';
5
- import { __export } from './chunk-MLKGABMK.js';
6
- import { RuntimeContext } from '@mastra/core/di';
7
- import { isVercelTool } from '@mastra/core/tools';
8
-
9
- // src/server/handlers/tools.ts
10
- var tools_exports = {};
11
- __export(tools_exports, {
12
- executeAgentToolHandler: () => executeAgentToolHandler,
13
- executeToolHandler: () => executeToolHandler,
14
- getToolByIdHandler: () => getToolByIdHandler,
15
- getToolsHandler: () => getToolsHandler
16
- });
17
- async function getToolsHandler({ tools }) {
18
- try {
19
- if (!tools) {
20
- return {};
21
- }
22
- const serializedTools = Object.entries(tools).reduce(
23
- (acc, [id, _tool]) => {
24
- const tool = _tool;
25
- acc[id] = {
26
- ...tool,
27
- inputSchema: tool.inputSchema ? stringify(esm_default(tool.inputSchema)) : void 0,
28
- outputSchema: tool.outputSchema ? stringify(esm_default(tool.outputSchema)) : void 0
29
- };
30
- return acc;
31
- },
32
- {}
33
- );
34
- return serializedTools;
35
- } catch (error) {
36
- return handleError(error, "Error getting tools");
37
- }
38
- }
39
- async function getToolByIdHandler({ tools, toolId }) {
40
- try {
41
- const tool = Object.values(tools || {}).find((tool2) => tool2.id === toolId);
42
- if (!tool) {
43
- throw new HTTPException(404, { message: "Tool not found" });
44
- }
45
- const serializedTool = {
46
- ...tool,
47
- inputSchema: tool.inputSchema ? stringify(esm_default(tool.inputSchema)) : void 0,
48
- outputSchema: tool.outputSchema ? stringify(esm_default(tool.outputSchema)) : void 0
49
- };
50
- return serializedTool;
51
- } catch (error) {
52
- return handleError(error, "Error getting tool");
53
- }
54
- }
55
- function executeToolHandler(tools) {
56
- return async ({
57
- mastra,
58
- runId,
59
- toolId,
60
- data,
61
- runtimeContext,
62
- runtimeContextFromRequest
63
- }) => {
64
- try {
65
- if (!toolId) {
66
- throw new HTTPException(400, { message: "Tool ID is required" });
67
- }
68
- const tool = Object.values(tools || {}).find((tool2) => tool2.id === toolId);
69
- if (!tool) {
70
- throw new HTTPException(404, { message: "Tool not found" });
71
- }
72
- if (!tool?.execute) {
73
- throw new HTTPException(400, { message: "Tool is not executable" });
74
- }
75
- validateBody({ data });
76
- if (isVercelTool(tool)) {
77
- const result2 = await tool.execute(data);
78
- return result2;
79
- }
80
- const finalRuntimeContext = new RuntimeContext([
81
- ...Array.from(runtimeContext.entries()),
82
- ...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
83
- ]);
84
- const result = await tool.execute({
85
- context: data,
86
- mastra,
87
- runId,
88
- runtimeContext: finalRuntimeContext
89
- });
90
- return result;
91
- } catch (error) {
92
- return handleError(error, "Error executing tool");
93
- }
94
- };
95
- }
96
- async function executeAgentToolHandler({
97
- mastra,
98
- agentId,
99
- toolId,
100
- data,
101
- runtimeContext,
102
- runtimeContextFromRequest
103
- }) {
104
- try {
105
- const agent = agentId ? mastra.getAgent(agentId) : null;
106
- if (!agent) {
107
- throw new HTTPException(404, { message: "Tool not found" });
108
- }
109
- const tool = Object.values(agent?.tools || {}).find((tool2) => tool2.id === toolId);
110
- if (!tool) {
111
- throw new HTTPException(404, { message: "Tool not found" });
112
- }
113
- if (!tool?.execute) {
114
- throw new HTTPException(400, { message: "Tool is not executable" });
115
- }
116
- const finalRuntimeContext = new RuntimeContext([
117
- ...Array.from(runtimeContext.entries()),
118
- ...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
119
- ]);
120
- const result = await tool.execute({
121
- context: data,
122
- runtimeContext: finalRuntimeContext,
123
- mastra,
124
- runId: agentId
125
- });
126
- return result;
127
- } catch (error) {
128
- return handleError(error, "Error executing tool");
129
- }
130
- }
131
-
132
- export { executeAgentToolHandler, executeToolHandler, getToolByIdHandler, getToolsHandler, tools_exports };
@@ -1,341 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkYWLUOY3D_cjs = require('./chunk-YWLUOY3D.cjs');
4
- var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
5
- var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
6
- var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
7
- var web = require('stream/web');
8
- var di = require('@mastra/core/di');
9
-
10
- // src/server/handlers/vNextWorkflows.ts
11
- var vNextWorkflows_exports = {};
12
- chunk75ZPJI57_cjs.__export(vNextWorkflows_exports, {
13
- createVNextWorkflowRunHandler: () => createVNextWorkflowRunHandler,
14
- getVNextWorkflowByIdHandler: () => getVNextWorkflowByIdHandler,
15
- getVNextWorkflowRunByIdHandler: () => getVNextWorkflowRunByIdHandler,
16
- getVNextWorkflowRunsHandler: () => getVNextWorkflowRunsHandler,
17
- getVNextWorkflowsHandler: () => getVNextWorkflowsHandler,
18
- resumeAsyncVNextWorkflowHandler: () => resumeAsyncVNextWorkflowHandler,
19
- resumeVNextWorkflowHandler: () => resumeVNextWorkflowHandler,
20
- startAsyncVNextWorkflowHandler: () => startAsyncVNextWorkflowHandler,
21
- startVNextWorkflowRunHandler: () => startVNextWorkflowRunHandler,
22
- watchVNextWorkflowHandler: () => watchVNextWorkflowHandler
23
- });
24
- async function getVNextWorkflowsHandler({ mastra }) {
25
- try {
26
- const workflows = mastra.vnext_getWorkflows({ serialized: false });
27
- const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
28
- acc[key] = {
29
- name: workflow.name,
30
- steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
31
- acc2[key2] = {
32
- id: step.id,
33
- description: step.description,
34
- inputSchema: step.inputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.inputSchema)) : void 0,
35
- outputSchema: step.outputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.outputSchema)) : void 0,
36
- resumeSchema: step.resumeSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.resumeSchema)) : void 0,
37
- suspendSchema: step.suspendSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.suspendSchema)) : void 0
38
- };
39
- return acc2;
40
- }, {}),
41
- stepGraph: workflow.serializedStepGraph,
42
- inputSchema: workflow.inputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(workflow.inputSchema)) : void 0,
43
- outputSchema: workflow.outputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(workflow.outputSchema)) : void 0
44
- };
45
- return acc;
46
- }, {});
47
- return _workflows;
48
- } catch (error) {
49
- throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflows" });
50
- }
51
- }
52
- async function getVNextWorkflowByIdHandler({ mastra, workflowId }) {
53
- try {
54
- if (!workflowId) {
55
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
56
- }
57
- const workflow = mastra.vnext_getWorkflow(workflowId);
58
- if (!workflow) {
59
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
60
- }
61
- return {
62
- steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
63
- acc[key] = {
64
- id: step.id,
65
- description: step.description,
66
- inputSchema: step.inputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.inputSchema)) : void 0,
67
- outputSchema: step.outputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.outputSchema)) : void 0,
68
- resumeSchema: step.resumeSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.resumeSchema)) : void 0,
69
- suspendSchema: step.suspendSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.suspendSchema)) : void 0
70
- };
71
- return acc;
72
- }, {}),
73
- name: workflow.name,
74
- stepGraph: workflow.serializedStepGraph,
75
- inputSchema: workflow.inputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(workflow.inputSchema)) : void 0,
76
- outputSchema: workflow.outputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(workflow.outputSchema)) : void 0
77
- };
78
- } catch (error) {
79
- throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflow" });
80
- }
81
- }
82
- async function getVNextWorkflowRunByIdHandler({
83
- mastra,
84
- workflowId,
85
- runId
86
- }) {
87
- try {
88
- if (!workflowId) {
89
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
90
- }
91
- if (!runId) {
92
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Run ID is required" });
93
- }
94
- const workflow = mastra.vnext_getWorkflow(workflowId);
95
- if (!workflow) {
96
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
97
- }
98
- const run = await workflow.getWorkflowRunById(runId);
99
- if (!run) {
100
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
101
- }
102
- return run;
103
- } catch (error) {
104
- throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflow run" });
105
- }
106
- }
107
- async function createVNextWorkflowRunHandler({
108
- mastra,
109
- workflowId,
110
- runId: prevRunId
111
- }) {
112
- try {
113
- if (!workflowId) {
114
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
115
- }
116
- const workflow = mastra.vnext_getWorkflow(workflowId);
117
- if (!workflow) {
118
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
119
- }
120
- const run = workflow.createRun({ runId: prevRunId });
121
- return { runId: run.runId };
122
- } catch (error) {
123
- throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error creating workflow run" });
124
- }
125
- }
126
- async function startAsyncVNextWorkflowHandler({
127
- mastra,
128
- runtimeContext,
129
- workflowId,
130
- runId,
131
- inputData,
132
- runtimeContextFromRequest
133
- }) {
134
- try {
135
- if (!workflowId) {
136
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
137
- }
138
- const workflow = mastra.vnext_getWorkflow(workflowId);
139
- if (!workflow) {
140
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
141
- }
142
- const finalRuntimeContext = new di.RuntimeContext([
143
- ...Array.from(runtimeContext?.entries() ?? []),
144
- ...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
145
- ]);
146
- const _run = workflow.createRun({ runId });
147
- const result = await _run.start({
148
- inputData,
149
- runtimeContext: finalRuntimeContext
150
- });
151
- return result;
152
- } catch (error) {
153
- throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error executing workflow" });
154
- }
155
- }
156
- async function startVNextWorkflowRunHandler({
157
- mastra,
158
- runtimeContext,
159
- workflowId,
160
- runId,
161
- inputData,
162
- runtimeContextFromRequest
163
- }) {
164
- try {
165
- if (!workflowId) {
166
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
167
- }
168
- if (!runId) {
169
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to start run" });
170
- }
171
- const workflow = mastra.vnext_getWorkflow(workflowId);
172
- const run = await workflow.getWorkflowRunById(runId);
173
- if (!run) {
174
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
175
- }
176
- const finalRuntimeContext = new di.RuntimeContext([
177
- ...Array.from(runtimeContext?.entries() ?? []),
178
- ...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
179
- ]);
180
- const _run = workflow.createRun({ runId });
181
- void _run.start({
182
- inputData,
183
- runtimeContext: finalRuntimeContext
184
- });
185
- return { message: "Workflow run started" };
186
- } catch (e) {
187
- return chunk64U3UDTH_cjs.handleError(e, "Error starting workflow run");
188
- }
189
- }
190
- async function watchVNextWorkflowHandler({
191
- mastra,
192
- workflowId,
193
- runId
194
- }) {
195
- try {
196
- if (!workflowId) {
197
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
198
- }
199
- if (!runId) {
200
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to watch workflow" });
201
- }
202
- const workflow = mastra.vnext_getWorkflow(workflowId);
203
- const run = await workflow.getWorkflowRunById(runId);
204
- if (!run) {
205
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
206
- }
207
- const _run = workflow.createRun({ runId });
208
- let unwatch;
209
- let asyncRef = null;
210
- const stream = new web.ReadableStream({
211
- start(controller) {
212
- unwatch = _run.watch(({ type, payload, eventTimestamp }) => {
213
- controller.enqueue(JSON.stringify({ type, payload, eventTimestamp, runId }));
214
- if (asyncRef) {
215
- clearImmediate(asyncRef);
216
- asyncRef = null;
217
- }
218
- asyncRef = setImmediate(async () => {
219
- const runDone = payload.workflowState.status !== "running";
220
- if (runDone) {
221
- controller.close();
222
- unwatch?.();
223
- }
224
- });
225
- });
226
- },
227
- cancel() {
228
- unwatch?.();
229
- }
230
- });
231
- return stream;
232
- } catch (error) {
233
- return chunk64U3UDTH_cjs.handleError(error, "Error watching workflow");
234
- }
235
- }
236
- async function resumeAsyncVNextWorkflowHandler({
237
- mastra,
238
- workflowId,
239
- runId,
240
- body,
241
- runtimeContext,
242
- runtimeContextFromRequest
243
- }) {
244
- try {
245
- if (!workflowId) {
246
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
247
- }
248
- if (!runId) {
249
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to resume workflow" });
250
- }
251
- if (!body.step) {
252
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "step required to resume workflow" });
253
- }
254
- const workflow = mastra.vnext_getWorkflow(workflowId);
255
- const run = await workflow.getWorkflowRunById(runId);
256
- if (!run) {
257
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
258
- }
259
- const finalRuntimeContext = new di.RuntimeContext([
260
- ...Array.from(runtimeContext?.entries() ?? []),
261
- ...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
262
- ]);
263
- const _run = workflow.createRun({ runId });
264
- const result = await _run.resume({
265
- step: body.step,
266
- resumeData: body.resumeData,
267
- runtimeContext: finalRuntimeContext
268
- });
269
- return result;
270
- } catch (error) {
271
- return chunk64U3UDTH_cjs.handleError(error, "Error resuming workflow step");
272
- }
273
- }
274
- async function resumeVNextWorkflowHandler({
275
- mastra,
276
- workflowId,
277
- runId,
278
- body,
279
- runtimeContext
280
- }) {
281
- try {
282
- if (!workflowId) {
283
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
284
- }
285
- if (!runId) {
286
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to resume workflow" });
287
- }
288
- if (!body.step) {
289
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "step required to resume workflow" });
290
- }
291
- const workflow = mastra.vnext_getWorkflow(workflowId);
292
- const run = await workflow.getWorkflowRunById(runId);
293
- if (!run) {
294
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
295
- }
296
- const _run = workflow.createRun({ runId });
297
- void _run.resume({
298
- step: body.step,
299
- resumeData: body.resumeData,
300
- runtimeContext
301
- });
302
- return { message: "Workflow run resumed" };
303
- } catch (error) {
304
- return chunk64U3UDTH_cjs.handleError(error, "Error resuming workflow");
305
- }
306
- }
307
- async function getVNextWorkflowRunsHandler({
308
- mastra,
309
- workflowId,
310
- fromDate,
311
- toDate,
312
- limit,
313
- offset,
314
- resourceId
315
- }) {
316
- try {
317
- if (!workflowId) {
318
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
319
- }
320
- const workflow = mastra.vnext_getWorkflow(workflowId);
321
- const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
322
- runs: [],
323
- total: 0
324
- };
325
- return workflowRuns;
326
- } catch (error) {
327
- return chunk64U3UDTH_cjs.handleError(error, "Error getting workflow runs");
328
- }
329
- }
330
-
331
- exports.createVNextWorkflowRunHandler = createVNextWorkflowRunHandler;
332
- exports.getVNextWorkflowByIdHandler = getVNextWorkflowByIdHandler;
333
- exports.getVNextWorkflowRunByIdHandler = getVNextWorkflowRunByIdHandler;
334
- exports.getVNextWorkflowRunsHandler = getVNextWorkflowRunsHandler;
335
- exports.getVNextWorkflowsHandler = getVNextWorkflowsHandler;
336
- exports.resumeAsyncVNextWorkflowHandler = resumeAsyncVNextWorkflowHandler;
337
- exports.resumeVNextWorkflowHandler = resumeVNextWorkflowHandler;
338
- exports.startAsyncVNextWorkflowHandler = startAsyncVNextWorkflowHandler;
339
- exports.startVNextWorkflowRunHandler = startVNextWorkflowRunHandler;
340
- exports.vNextWorkflows_exports = vNextWorkflows_exports;
341
- exports.watchVNextWorkflowHandler = watchVNextWorkflowHandler;
@@ -1,148 +0,0 @@
1
- 'use strict';
2
-
3
- var chunk57CJTIPW_cjs = require('./chunk-57CJTIPW.cjs');
4
- var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
5
- var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
6
- var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
7
-
8
- // src/server/handlers/network.ts
9
- var network_exports = {};
10
- chunk75ZPJI57_cjs.__export(network_exports, {
11
- generateHandler: () => generateHandler,
12
- getNetworkByIdHandler: () => getNetworkByIdHandler,
13
- getNetworksHandler: () => getNetworksHandler,
14
- streamGenerateHandler: () => streamGenerateHandler
15
- });
16
- async function getNetworksHandler({
17
- mastra,
18
- runtimeContext
19
- }) {
20
- try {
21
- const networks = mastra.getNetworks();
22
- const serializedNetworks = await Promise.all(
23
- networks.map(async (network) => {
24
- const routingAgent = network.getRoutingAgent();
25
- const routingLLM = await routingAgent.getLLM({ runtimeContext });
26
- const agents = network.getAgents();
27
- return {
28
- id: network.formatAgentId(routingAgent.name),
29
- name: routingAgent.name,
30
- instructions: routingAgent.instructions,
31
- agents: await Promise.all(
32
- agents.map(async (agent) => {
33
- const llm = await agent.getLLM({ runtimeContext });
34
- return {
35
- name: agent.name,
36
- provider: llm?.getProvider(),
37
- modelId: llm?.getModelId()
38
- };
39
- })
40
- ),
41
- routingModel: {
42
- provider: routingLLM?.getProvider(),
43
- modelId: routingLLM?.getModelId()
44
- }
45
- };
46
- })
47
- );
48
- return serializedNetworks;
49
- } catch (error) {
50
- return chunk64U3UDTH_cjs.handleError(error, "Error getting networks");
51
- }
52
- }
53
- async function getNetworkByIdHandler({
54
- mastra,
55
- networkId,
56
- runtimeContext
57
- }) {
58
- try {
59
- const networks = mastra.getNetworks();
60
- const network = networks.find((network2) => {
61
- const routingAgent2 = network2.getRoutingAgent();
62
- return network2.formatAgentId(routingAgent2.name) === networkId;
63
- });
64
- if (!network) {
65
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Network not found" });
66
- }
67
- const routingAgent = network.getRoutingAgent();
68
- const routingLLM = await routingAgent.getLLM({ runtimeContext });
69
- const agents = network.getAgents();
70
- const serializedNetwork = {
71
- id: network.formatAgentId(routingAgent.name),
72
- name: routingAgent.name,
73
- instructions: routingAgent.instructions,
74
- agents: await Promise.all(
75
- agents.map(async (agent) => {
76
- const llm = await agent.getLLM({ runtimeContext });
77
- return {
78
- name: agent.name,
79
- provider: llm?.getProvider(),
80
- modelId: llm?.getModelId()
81
- };
82
- })
83
- ),
84
- routingModel: {
85
- provider: routingLLM?.getProvider(),
86
- modelId: routingLLM?.getModelId()
87
- }
88
- };
89
- return serializedNetwork;
90
- } catch (error) {
91
- return chunk64U3UDTH_cjs.handleError(error, "Error getting network by ID");
92
- }
93
- }
94
- async function generateHandler({
95
- mastra,
96
- runtimeContext,
97
- networkId,
98
- body
99
- }) {
100
- try {
101
- const network = mastra.getNetwork(networkId);
102
- if (!network) {
103
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Network not found" });
104
- }
105
- chunk57CJTIPW_cjs.validateBody({ messages: body.messages });
106
- const { messages, ...rest } = body;
107
- const result = await network.generate(messages, { ...rest, runtimeContext });
108
- return result;
109
- } catch (error) {
110
- return chunk64U3UDTH_cjs.handleError(error, "Error generating from network");
111
- }
112
- }
113
- async function streamGenerateHandler({
114
- mastra,
115
- networkId,
116
- body,
117
- runtimeContext
118
- }) {
119
- try {
120
- const network = mastra.getNetwork(networkId);
121
- if (!network) {
122
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Network not found" });
123
- }
124
- chunk57CJTIPW_cjs.validateBody({ messages: body.messages });
125
- const { messages, output, ...rest } = body;
126
- const streamResult = await network.stream(messages, {
127
- output,
128
- ...rest,
129
- runtimeContext
130
- });
131
- const streamResponse = output ? streamResult.toTextStreamResponse() : streamResult.toDataStreamResponse({
132
- sendUsage: true,
133
- sendReasoning: true,
134
- getErrorMessage: (error) => {
135
- return `An error occurred while processing your request. ${error instanceof Error ? error.message : JSON.stringify(error)}`;
136
- }
137
- });
138
- return streamResponse;
139
- } catch (error) {
140
- return chunk64U3UDTH_cjs.handleError(error, "Error streaming from network");
141
- }
142
- }
143
-
144
- exports.generateHandler = generateHandler;
145
- exports.getNetworkByIdHandler = getNetworkByIdHandler;
146
- exports.getNetworksHandler = getNetworksHandler;
147
- exports.network_exports = network_exports;
148
- exports.streamGenerateHandler = streamGenerateHandler;