@mastra/server 0.0.0-llamaindex-extract-20250416163822 → 0.0.0-main-test-20251105183450

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 (263) hide show
  1. package/CHANGELOG.md +4494 -0
  2. package/LICENSE.md +11 -42
  3. package/README.md +45 -137
  4. package/dist/chunk-2PLXW4ZX.cjs +2777 -0
  5. package/dist/chunk-2PLXW4ZX.cjs.map +1 -0
  6. package/dist/chunk-46Z2KDQL.js +124 -0
  7. package/dist/chunk-46Z2KDQL.js.map +1 -0
  8. package/dist/{chunk-FV45V6WC.cjs → chunk-64ITUOXI.cjs} +3 -7
  9. package/dist/chunk-64ITUOXI.cjs.map +1 -0
  10. package/dist/{chunk-TRDNDNGQ.js → chunk-6QWQZI4Q.js} +4 -7
  11. package/dist/chunk-6QWQZI4Q.js.map +1 -0
  12. package/dist/chunk-73PAWDM5.js +83 -0
  13. package/dist/chunk-73PAWDM5.js.map +1 -0
  14. package/dist/chunk-A5SOZY5R.js +502 -0
  15. package/dist/chunk-A5SOZY5R.js.map +1 -0
  16. package/dist/chunk-AEVI2HIU.cjs +651 -0
  17. package/dist/chunk-AEVI2HIU.cjs.map +1 -0
  18. package/dist/chunk-ALOLTNSO.js +477 -0
  19. package/dist/chunk-ALOLTNSO.js.map +1 -0
  20. package/dist/chunk-B6NK4KI5.cjs +128 -0
  21. package/dist/chunk-B6NK4KI5.cjs.map +1 -0
  22. package/dist/chunk-BANGX6SC.cjs +200 -0
  23. package/dist/chunk-BANGX6SC.cjs.map +1 -0
  24. package/dist/chunk-BHQH5QXD.cjs +172 -0
  25. package/dist/chunk-BHQH5QXD.cjs.map +1 -0
  26. package/dist/chunk-BTWIR2B7.cjs +28 -0
  27. package/dist/chunk-BTWIR2B7.cjs.map +1 -0
  28. package/dist/chunk-DNUO33HF.js +129 -0
  29. package/dist/chunk-DNUO33HF.js.map +1 -0
  30. package/dist/chunk-GTZOYEAU.cjs +130 -0
  31. package/dist/chunk-GTZOYEAU.cjs.map +1 -0
  32. package/dist/chunk-GU4EWMZB.cjs +769 -0
  33. package/dist/chunk-GU4EWMZB.cjs.map +1 -0
  34. package/dist/chunk-IGOWG5V5.js +192 -0
  35. package/dist/chunk-IGOWG5V5.js.map +1 -0
  36. package/dist/chunk-JO2AZFJN.js +165 -0
  37. package/dist/chunk-JO2AZFJN.js.map +1 -0
  38. package/dist/chunk-JZ65BJ6H.cjs +678 -0
  39. package/dist/chunk-JZ65BJ6H.cjs.map +1 -0
  40. package/dist/{chunk-4JINXASC.js → chunk-KWH5QBXP.js} +7 -4
  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-3RVHWGWO.js → chunk-LPCK5MAF.js} +49 -22
  45. package/dist/chunk-LPCK5MAF.js.map +1 -0
  46. package/dist/chunk-LPM6BBAX.cjs +1043 -0
  47. package/dist/chunk-LPM6BBAX.cjs.map +1 -0
  48. package/dist/chunk-LWLSQ2W4.cjs +133 -0
  49. package/dist/chunk-LWLSQ2W4.cjs.map +1 -0
  50. package/dist/chunk-MMQIJZ2Q.cjs +23079 -0
  51. package/dist/chunk-MMQIJZ2Q.cjs.map +1 -0
  52. package/dist/chunk-O7I5CWRX.cjs +44 -0
  53. package/dist/chunk-O7I5CWRX.cjs.map +1 -0
  54. package/dist/chunk-PPMIB3FQ.cjs +88 -0
  55. package/dist/chunk-PPMIB3FQ.cjs.map +1 -0
  56. package/dist/chunk-PR4QN5HX.js +39 -0
  57. package/dist/chunk-PR4QN5HX.js.map +1 -0
  58. package/dist/chunk-QU6N55W6.cjs +256 -0
  59. package/dist/chunk-QU6N55W6.cjs.map +1 -0
  60. package/dist/chunk-R6OQFR47.js +630 -0
  61. package/dist/chunk-R6OQFR47.js.map +1 -0
  62. package/dist/chunk-RQK4FQUD.js +1012 -0
  63. package/dist/chunk-RQK4FQUD.js.map +1 -0
  64. package/dist/{chunk-M56ECCHK.cjs → chunk-S54HNARD.cjs} +22 -19
  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-SIPNICB3.cjs +517 -0
  69. package/dist/chunk-SIPNICB3.cjs.map +1 -0
  70. package/dist/{chunk-L7XE5QTW.js → chunk-SZIFSF4T.js} +11 -2
  71. package/dist/chunk-SZIFSF4T.js.map +1 -0
  72. package/dist/chunk-TOCYBDP2.js +46 -0
  73. package/dist/chunk-TOCYBDP2.js.map +1 -0
  74. package/dist/chunk-UU7MMOP5.js +23039 -0
  75. package/dist/chunk-UU7MMOP5.js.map +1 -0
  76. package/dist/chunk-UXGQZUYZ.js +16 -0
  77. package/dist/chunk-UXGQZUYZ.js.map +1 -0
  78. package/dist/chunk-V5WWQN7P.cjs +18 -0
  79. package/dist/chunk-V5WWQN7P.cjs.map +1 -0
  80. package/dist/chunk-VYR3SAFM.js +658 -0
  81. package/dist/chunk-VYR3SAFM.js.map +1 -0
  82. package/dist/chunk-X6C7BUWN.cjs +48 -0
  83. package/dist/chunk-X6C7BUWN.cjs.map +1 -0
  84. package/dist/chunk-XXGID4PQ.cjs +485 -0
  85. package/dist/chunk-XXGID4PQ.cjs.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 +32 -0
  125. package/dist/server/handlers/a2a.cjs.map +1 -0
  126. package/dist/server/handlers/a2a.d.ts +68 -0
  127. package/dist/server/handlers/a2a.d.ts.map +1 -0
  128. package/dist/server/handlers/a2a.js +3 -0
  129. package/dist/server/handlers/a2a.js.map +1 -0
  130. package/dist/server/handlers/agent-builder.cjs +84 -0
  131. package/dist/server/handlers/agent-builder.cjs.map +1 -0
  132. package/dist/server/handlers/agent-builder.d.ts +91 -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 +54 -16
  197. package/dist/server/handlers/workflows.cjs.map +1 -0
  198. package/dist/server/handlers/workflows.d.ts +94 -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 +38 -26
  203. package/dist/server/handlers.cjs.map +1 -0
  204. package/dist/server/handlers.d.ts +12 -9
  205. package/dist/server/handlers.d.ts.map +1 -0
  206. package/dist/server/handlers.js +13 -9
  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 +44 -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 -573
  224. package/dist/_tsup-dts-rollup.d.ts +0 -573
  225. package/dist/chunk-2FJURXCL.cjs +0 -213
  226. package/dist/chunk-3AHQ5RGN.js +0 -11
  227. package/dist/chunk-3EJZQ6TQ.js +0 -49
  228. package/dist/chunk-67WTHYAV.js +0 -156
  229. package/dist/chunk-A7DF4ETD.cjs +0 -100
  230. package/dist/chunk-B64YROKU.cjs +0 -317
  231. package/dist/chunk-CWSDZEZG.cjs +0 -139
  232. package/dist/chunk-DVPP5S6I.js +0 -135
  233. package/dist/chunk-JLDXUWK7.cjs +0 -126
  234. package/dist/chunk-OPP7H5TW.js +0 -305
  235. package/dist/chunk-PDC4ZBQW.cjs +0 -126
  236. package/dist/chunk-QH6XWSXP.cjs +0 -5579
  237. package/dist/chunk-QN4KF3BH.cjs +0 -18
  238. package/dist/chunk-RBQASTUP.js +0 -203
  239. package/dist/chunk-SKBVVI24.cjs +0 -54
  240. package/dist/chunk-UV4WTEH4.js +0 -120
  241. package/dist/chunk-VK6FX47H.js +0 -5576
  242. package/dist/chunk-YANVFOYA.js +0 -120
  243. package/dist/chunk-Z46X3YCB.cjs +0 -164
  244. package/dist/chunk-ZLBRQFDD.cjs +0 -13
  245. package/dist/index.d.cts +0 -1
  246. package/dist/server/handlers/agents.d.cts +0 -6
  247. package/dist/server/handlers/error.d.cts +0 -1
  248. package/dist/server/handlers/logs.d.cts +0 -3
  249. package/dist/server/handlers/memory.d.cts +0 -8
  250. package/dist/server/handlers/network.cjs +0 -22
  251. package/dist/server/handlers/network.d.cts +0 -4
  252. package/dist/server/handlers/network.d.ts +0 -4
  253. package/dist/server/handlers/network.js +0 -1
  254. package/dist/server/handlers/telemetry.cjs +0 -14
  255. package/dist/server/handlers/telemetry.d.cts +0 -2
  256. package/dist/server/handlers/telemetry.d.ts +0 -2
  257. package/dist/server/handlers/telemetry.js +0 -1
  258. package/dist/server/handlers/tools.d.cts +0 -4
  259. package/dist/server/handlers/utils.d.cts +0 -1
  260. package/dist/server/handlers/vector.d.cts +0 -6
  261. package/dist/server/handlers/voice.d.cts +0 -3
  262. package/dist/server/handlers/workflows.d.cts +0 -10
  263. package/dist/server/handlers.d.cts +0 -9
@@ -1,126 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkQN4KF3BH_cjs = require('./chunk-QN4KF3BH.cjs');
4
- var chunkZLBRQFDD_cjs = require('./chunk-ZLBRQFDD.cjs');
5
- var chunkFV45V6WC_cjs = require('./chunk-FV45V6WC.cjs');
6
-
7
- // src/server/handlers/network.ts
8
- var network_exports = {};
9
- chunkFV45V6WC_cjs.__export(network_exports, {
10
- generateHandler: () => generateHandler,
11
- getNetworkByIdHandler: () => getNetworkByIdHandler,
12
- getNetworksHandler: () => getNetworksHandler,
13
- streamGenerateHandler: () => streamGenerateHandler
14
- });
15
- async function getNetworksHandler({ mastra }) {
16
- try {
17
- const networks = mastra.getNetworks();
18
- const serializedNetworks = networks.map((network) => {
19
- const routingAgent = network.getRoutingAgent();
20
- const agents = network.getAgents();
21
- return {
22
- id: network.formatAgentId(routingAgent.name),
23
- name: routingAgent.name,
24
- instructions: routingAgent.instructions,
25
- agents: agents.map((agent) => ({
26
- name: agent.name,
27
- provider: agent.llm?.getProvider(),
28
- modelId: agent.llm?.getModelId()
29
- })),
30
- routingModel: {
31
- provider: routingAgent.llm?.getProvider(),
32
- modelId: routingAgent.llm?.getModelId()
33
- }
34
- };
35
- });
36
- return serializedNetworks;
37
- } catch (error) {
38
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting networks");
39
- }
40
- }
41
- async function getNetworkByIdHandler({ mastra, networkId }) {
42
- try {
43
- const networks = mastra.getNetworks();
44
- const network = networks.find((network2) => {
45
- const routingAgent2 = network2.getRoutingAgent();
46
- return network2.formatAgentId(routingAgent2.name) === networkId;
47
- });
48
- if (!network) {
49
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Network not found" });
50
- }
51
- const routingAgent = network.getRoutingAgent();
52
- const agents = network.getAgents();
53
- const serializedNetwork = {
54
- id: network.formatAgentId(routingAgent.name),
55
- name: routingAgent.name,
56
- instructions: routingAgent.instructions,
57
- agents: agents.map((agent) => ({
58
- name: agent.name,
59
- provider: agent.llm?.getProvider(),
60
- modelId: agent.llm?.getModelId()
61
- })),
62
- routingModel: {
63
- provider: routingAgent.llm?.getProvider(),
64
- modelId: routingAgent.llm?.getModelId()
65
- }
66
- };
67
- return serializedNetwork;
68
- } catch (error) {
69
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting network by ID");
70
- }
71
- }
72
- async function generateHandler({
73
- mastra,
74
- container,
75
- networkId,
76
- body
77
- }) {
78
- try {
79
- const network = mastra.getNetwork(networkId);
80
- if (!network) {
81
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Network not found" });
82
- }
83
- chunkQN4KF3BH_cjs.validateBody({ messages: body.messages });
84
- const { messages, ...rest } = body;
85
- const result = await network.generate(messages, { ...rest, container });
86
- return result;
87
- } catch (error) {
88
- return chunkZLBRQFDD_cjs.handleError(error, "Error generating from network");
89
- }
90
- }
91
- async function streamGenerateHandler({
92
- mastra,
93
- networkId,
94
- body,
95
- container
96
- }) {
97
- try {
98
- const network = mastra.getNetwork(networkId);
99
- if (!network) {
100
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Network not found" });
101
- }
102
- chunkQN4KF3BH_cjs.validateBody({ messages: body.messages });
103
- const { messages, output, ...rest } = body;
104
- const streamResult = await network.stream(messages, {
105
- output,
106
- ...rest,
107
- container
108
- });
109
- const streamResponse = output ? streamResult.toTextStreamResponse() : streamResult.toDataStreamResponse({
110
- sendUsage: true,
111
- sendReasoning: true,
112
- getErrorMessage: (error) => {
113
- return `An error occurred while processing your request. ${error instanceof Error ? error.message : JSON.stringify(error)}`;
114
- }
115
- });
116
- return streamResponse;
117
- } catch (error) {
118
- return chunkZLBRQFDD_cjs.handleError(error, "Error streaming from network");
119
- }
120
- }
121
-
122
- exports.generateHandler = generateHandler;
123
- exports.getNetworkByIdHandler = getNetworkByIdHandler;
124
- exports.getNetworksHandler = getNetworksHandler;
125
- exports.network_exports = network_exports;
126
- exports.streamGenerateHandler = streamGenerateHandler;
@@ -1,305 +0,0 @@
1
- import { stringify, esm_default } from './chunk-VK6FX47H.js';
2
- import { handleError } from './chunk-3AHQ5RGN.js';
3
- import { __export, HTTPException } from './chunk-TRDNDNGQ.js';
4
- import { ReadableStream } from 'node:stream/web';
5
-
6
- // src/server/handlers/workflows.ts
7
- var workflows_exports = {};
8
- __export(workflows_exports, {
9
- createRunHandler: () => createRunHandler,
10
- getWorkflowByIdHandler: () => getWorkflowByIdHandler,
11
- getWorkflowRunHandler: () => getWorkflowRunHandler,
12
- getWorkflowRunsHandler: () => getWorkflowRunsHandler,
13
- getWorkflowsHandler: () => getWorkflowsHandler,
14
- resumeAsyncWorkflowHandler: () => resumeAsyncWorkflowHandler,
15
- resumeWorkflowHandler: () => resumeWorkflowHandler,
16
- startAsyncWorkflowHandler: () => startAsyncWorkflowHandler,
17
- startWorkflowRunHandler: () => startWorkflowRunHandler,
18
- watchWorkflowHandler: () => watchWorkflowHandler
19
- });
20
- async function getWorkflowsHandler({ mastra }) {
21
- try {
22
- const workflows = mastra.getWorkflows({ serialized: false });
23
- const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
24
- if (workflow.isNested) return acc;
25
- acc[key] = {
26
- stepGraph: workflow.stepGraph,
27
- stepSubscriberGraph: workflow.stepSubscriberGraph,
28
- serializedStepGraph: workflow.serializedStepGraph,
29
- serializedStepSubscriberGraph: workflow.serializedStepSubscriberGraph,
30
- name: workflow.name,
31
- triggerSchema: workflow.triggerSchema ? stringify(esm_default(workflow.triggerSchema)) : void 0,
32
- steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
33
- const _step = step;
34
- acc2[key2] = {
35
- ..._step,
36
- inputSchema: _step.inputSchema ? stringify(esm_default(_step.inputSchema)) : void 0,
37
- outputSchema: _step.outputSchema ? stringify(esm_default(_step.outputSchema)) : void 0
38
- };
39
- return acc2;
40
- }, {})
41
- };
42
- return acc;
43
- }, {});
44
- return _workflows;
45
- } catch (error) {
46
- throw new HTTPException(500, { message: error?.message || "Error getting workflows" });
47
- }
48
- }
49
- async function getWorkflowByIdHandler({ mastra, workflowId }) {
50
- try {
51
- if (!workflowId) {
52
- throw new HTTPException(400, { message: "Workflow ID is required" });
53
- }
54
- const workflow = mastra.getWorkflow(workflowId);
55
- if (!workflow) {
56
- throw new HTTPException(404, { message: "Workflow not found" });
57
- }
58
- return {
59
- stepGraph: workflow.stepGraph,
60
- stepSubscriberGraph: workflow.stepSubscriberGraph,
61
- serializedStepGraph: workflow.serializedStepGraph,
62
- serializedStepSubscriberGraph: workflow.serializedStepSubscriberGraph,
63
- name: workflow.name,
64
- triggerSchema: workflow.triggerSchema ? stringify(esm_default(workflow.triggerSchema)) : void 0,
65
- steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
66
- const _step = step;
67
- acc[key] = {
68
- ..._step,
69
- inputSchema: _step.inputSchema ? stringify(esm_default(_step.inputSchema)) : void 0,
70
- outputSchema: _step.outputSchema ? stringify(esm_default(_step.outputSchema)) : void 0
71
- };
72
- return acc;
73
- }, {})
74
- };
75
- } catch (error) {
76
- throw new HTTPException(500, { message: error?.message || "Error getting workflow" });
77
- }
78
- }
79
- async function startAsyncWorkflowHandler({
80
- mastra,
81
- container,
82
- workflowId,
83
- runId,
84
- triggerData
85
- }) {
86
- try {
87
- if (!workflowId) {
88
- throw new HTTPException(400, { message: "Workflow ID is required" });
89
- }
90
- const workflow = mastra.getWorkflow(workflowId);
91
- if (!workflow) {
92
- throw new HTTPException(404, { message: "Workflow not found" });
93
- }
94
- if (!runId) {
95
- const { start } = workflow.createRun();
96
- const result2 = await start({
97
- triggerData,
98
- container
99
- });
100
- return result2;
101
- }
102
- const run = workflow.getRun(runId);
103
- if (!run) {
104
- throw new HTTPException(404, { message: "Workflow run not found" });
105
- }
106
- const result = await run.start({
107
- triggerData,
108
- container
109
- });
110
- return result;
111
- } catch (error) {
112
- throw new HTTPException(500, { message: error?.message || "Error executing workflow" });
113
- }
114
- }
115
- async function getWorkflowRunHandler({
116
- mastra,
117
- workflowId,
118
- runId
119
- }) {
120
- try {
121
- if (!workflowId) {
122
- throw new HTTPException(400, { message: "Workflow ID is required" });
123
- }
124
- if (!runId) {
125
- throw new HTTPException(400, { message: "Run ID is required" });
126
- }
127
- const workflow = mastra.getWorkflow(workflowId);
128
- if (!workflow) {
129
- throw new HTTPException(404, { message: "Workflow not found" });
130
- }
131
- const run = workflow.getRun(runId);
132
- if (!run) {
133
- throw new HTTPException(404, { message: "Workflow run not found" });
134
- }
135
- return run;
136
- } catch (error) {
137
- throw new HTTPException(500, { message: error?.message || "Error getting workflow run" });
138
- }
139
- }
140
- async function createRunHandler({
141
- mastra,
142
- workflowId,
143
- runId: prevRunId
144
- }) {
145
- try {
146
- if (!workflowId) {
147
- throw new HTTPException(400, { message: "Workflow ID is required" });
148
- }
149
- const workflow = mastra.getWorkflow(workflowId);
150
- if (!workflow) {
151
- throw new HTTPException(404, { message: "Workflow not found" });
152
- }
153
- const { runId } = workflow.createRun({ runId: prevRunId });
154
- return { runId };
155
- } catch (error) {
156
- throw new HTTPException(500, { message: error?.message || "Error creating workflow run" });
157
- }
158
- }
159
- async function startWorkflowRunHandler({
160
- mastra,
161
- container,
162
- workflowId,
163
- runId,
164
- triggerData
165
- }) {
166
- try {
167
- if (!workflowId) {
168
- throw new HTTPException(400, { message: "Workflow ID is required" });
169
- }
170
- if (!runId) {
171
- throw new HTTPException(400, { message: "runId required to start run" });
172
- }
173
- const workflow = mastra.getWorkflow(workflowId);
174
- const run = workflow.getRun(runId);
175
- if (!run) {
176
- throw new HTTPException(404, { message: "Workflow run not found" });
177
- }
178
- await run.start({
179
- triggerData,
180
- container
181
- });
182
- return { message: "Workflow run started" };
183
- } catch (e) {
184
- return handleError(e, "Error starting workflow run");
185
- }
186
- }
187
- async function watchWorkflowHandler({
188
- mastra,
189
- workflowId,
190
- runId
191
- }) {
192
- try {
193
- if (!workflowId) {
194
- throw new HTTPException(400, { message: "Workflow ID is required" });
195
- }
196
- if (!runId) {
197
- throw new HTTPException(400, { message: "runId required to watch workflow" });
198
- }
199
- const workflow = mastra.getWorkflow(workflowId);
200
- const run = workflow.getRun(runId);
201
- if (!run) {
202
- throw new HTTPException(404, { message: "Workflow run not found" });
203
- }
204
- let unwatch;
205
- let asyncRef = null;
206
- const stream = new ReadableStream({
207
- start(controller) {
208
- unwatch = run.watch(({ activePaths, runId: runId2, timestamp, results }) => {
209
- const activePathsObj = Object.fromEntries(activePaths);
210
- controller.enqueue(JSON.stringify({ activePaths: activePathsObj, runId: runId2, timestamp, results }));
211
- if (asyncRef) {
212
- clearImmediate(asyncRef);
213
- asyncRef = null;
214
- }
215
- asyncRef = setImmediate(() => {
216
- if (!workflow.getRun(runId2)) {
217
- controller.close();
218
- }
219
- });
220
- });
221
- },
222
- cancel() {
223
- unwatch?.();
224
- }
225
- });
226
- return stream;
227
- } catch (error) {
228
- return handleError(error, "Error watching workflow");
229
- }
230
- }
231
- async function resumeAsyncWorkflowHandler({
232
- mastra,
233
- workflowId,
234
- runId,
235
- body,
236
- container
237
- }) {
238
- try {
239
- if (!workflowId) {
240
- throw new HTTPException(400, { message: "Workflow ID is required" });
241
- }
242
- if (!runId) {
243
- throw new HTTPException(400, { message: "runId required to resume workflow" });
244
- }
245
- const workflow = mastra.getWorkflow(workflowId);
246
- const run = workflow.getRun(runId);
247
- if (!run) {
248
- throw new HTTPException(404, { message: "Workflow run not found" });
249
- }
250
- const result = await run.resume({
251
- stepId: body.stepId,
252
- context: body.context,
253
- container
254
- });
255
- return result;
256
- } catch (error) {
257
- return handleError(error, "Error resuming workflow step");
258
- }
259
- }
260
- async function resumeWorkflowHandler({
261
- mastra,
262
- workflowId,
263
- runId,
264
- body,
265
- container
266
- }) {
267
- try {
268
- if (!workflowId) {
269
- throw new HTTPException(400, { message: "Workflow ID is required" });
270
- }
271
- if (!runId) {
272
- throw new HTTPException(400, { message: "runId required to resume workflow" });
273
- }
274
- const workflow = mastra.getWorkflow(workflowId);
275
- const run = workflow.getRun(runId);
276
- if (!run) {
277
- throw new HTTPException(404, { message: "Workflow run not found" });
278
- }
279
- await run.resume({
280
- stepId: body.stepId,
281
- context: body.context,
282
- container
283
- });
284
- return { message: "Workflow run resumed" };
285
- } catch (error) {
286
- return handleError(error, "Error resuming workflow");
287
- }
288
- }
289
- async function getWorkflowRunsHandler({ mastra, workflowId }) {
290
- try {
291
- if (!workflowId) {
292
- throw new HTTPException(400, { message: "Workflow ID is required" });
293
- }
294
- const workflow = mastra.getWorkflow(workflowId);
295
- const workflowRuns = await workflow.getWorkflowRuns() || {
296
- runs: [],
297
- total: 0
298
- };
299
- return workflowRuns;
300
- } catch (error) {
301
- return handleError(error, "Error getting workflow runs");
302
- }
303
- }
304
-
305
- export { createRunHandler, getWorkflowByIdHandler, getWorkflowRunHandler, getWorkflowRunsHandler, getWorkflowsHandler, resumeAsyncWorkflowHandler, resumeWorkflowHandler, startAsyncWorkflowHandler, startWorkflowRunHandler, watchWorkflowHandler, workflows_exports };
@@ -1,126 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkQH6XWSXP_cjs = require('./chunk-QH6XWSXP.cjs');
4
- var chunkQN4KF3BH_cjs = require('./chunk-QN4KF3BH.cjs');
5
- var chunkZLBRQFDD_cjs = require('./chunk-ZLBRQFDD.cjs');
6
- var chunkFV45V6WC_cjs = require('./chunk-FV45V6WC.cjs');
7
- var tools = require('@mastra/core/tools');
8
-
9
- // src/server/handlers/tools.ts
10
- var tools_exports = {};
11
- chunkFV45V6WC_cjs.__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 ? chunkQH6XWSXP_cjs.stringify(chunkQH6XWSXP_cjs.esm_default(tool.inputSchema)) : void 0,
28
- outputSchema: tool.outputSchema ? chunkQH6XWSXP_cjs.stringify(chunkQH6XWSXP_cjs.esm_default(tool.outputSchema)) : void 0
29
- };
30
- return acc;
31
- },
32
- {}
33
- );
34
- return serializedTools;
35
- } catch (error) {
36
- return chunkZLBRQFDD_cjs.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 chunkFV45V6WC_cjs.HTTPException(404, { message: "Tool not found" });
44
- }
45
- const serializedTool = {
46
- ...tool,
47
- inputSchema: tool.inputSchema ? chunkQH6XWSXP_cjs.stringify(chunkQH6XWSXP_cjs.esm_default(tool.inputSchema)) : void 0,
48
- outputSchema: tool.outputSchema ? chunkQH6XWSXP_cjs.stringify(chunkQH6XWSXP_cjs.esm_default(tool.outputSchema)) : void 0
49
- };
50
- return serializedTool;
51
- } catch (error) {
52
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting tool");
53
- }
54
- }
55
- function executeToolHandler(tools$1) {
56
- return async ({
57
- mastra,
58
- runId,
59
- toolId,
60
- data,
61
- container
62
- }) => {
63
- try {
64
- if (!toolId) {
65
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Tool ID is required" });
66
- }
67
- const tool = Object.values(tools$1 || {}).find((tool2) => tool2.id === toolId);
68
- if (!tool) {
69
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Tool not found" });
70
- }
71
- if (!tool?.execute) {
72
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Tool is not executable" });
73
- }
74
- chunkQN4KF3BH_cjs.validateBody({ data });
75
- if (tools.isVercelTool(tool)) {
76
- const result2 = await tool.execute(data);
77
- return result2;
78
- }
79
- const result = await tool.execute({
80
- context: data,
81
- mastra,
82
- runId,
83
- container
84
- });
85
- return result;
86
- } catch (error) {
87
- return chunkZLBRQFDD_cjs.handleError(error, "Error executing tool");
88
- }
89
- };
90
- }
91
- async function executeAgentToolHandler({
92
- mastra,
93
- agentId,
94
- toolId,
95
- data,
96
- container
97
- }) {
98
- try {
99
- const agent = agentId ? mastra.getAgent(agentId) : null;
100
- if (!agent) {
101
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Tool not found" });
102
- }
103
- const tool = Object.values(agent?.tools || {}).find((tool2) => tool2.id === toolId);
104
- if (!tool) {
105
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Tool not found" });
106
- }
107
- if (!tool?.execute) {
108
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Tool is not executable" });
109
- }
110
- const result = await tool.execute({
111
- context: data,
112
- container,
113
- mastra,
114
- runId: agentId
115
- });
116
- return result;
117
- } catch (error) {
118
- return chunkZLBRQFDD_cjs.handleError(error, "Error executing tool");
119
- }
120
- }
121
-
122
- exports.executeAgentToolHandler = executeAgentToolHandler;
123
- exports.executeToolHandler = executeToolHandler;
124
- exports.getToolByIdHandler = getToolByIdHandler;
125
- exports.getToolsHandler = getToolsHandler;
126
- exports.tools_exports = tools_exports;