@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,344 +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/workflows.ts
8
- var workflows_exports = {};
9
- __export(workflows_exports, {
10
- createWorkflowRunHandler: () => createWorkflowRunHandler,
11
- getWorkflowByIdHandler: () => getWorkflowByIdHandler,
12
- getWorkflowRunByIdHandler: () => getWorkflowRunByIdHandler,
13
- getWorkflowRunsHandler: () => getWorkflowRunsHandler,
14
- getWorkflowsHandler: () => getWorkflowsHandler,
15
- resumeAsyncWorkflowHandler: () => resumeAsyncWorkflowHandler,
16
- resumeWorkflowHandler: () => resumeWorkflowHandler,
17
- startAsyncWorkflowHandler: () => startAsyncWorkflowHandler,
18
- startWorkflowRunHandler: () => startWorkflowRunHandler,
19
- streamWorkflowHandler: () => streamWorkflowHandler,
20
- watchWorkflowHandler: () => watchWorkflowHandler
21
- });
22
- async function getWorkflowsHandler({ mastra }) {
23
- try {
24
- const workflows = mastra.getWorkflows({ serialized: false });
25
- const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
26
- acc[key] = {
27
- name: workflow.name,
28
- description: workflow.description,
29
- steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
30
- acc2[key2] = {
31
- id: step.id,
32
- description: step.description,
33
- inputSchema: step.inputSchema ? stringify(esm_default(step.inputSchema)) : void 0,
34
- outputSchema: step.outputSchema ? stringify(esm_default(step.outputSchema)) : void 0,
35
- resumeSchema: step.resumeSchema ? stringify(esm_default(step.resumeSchema)) : void 0,
36
- suspendSchema: step.suspendSchema ? stringify(esm_default(step.suspendSchema)) : void 0
37
- };
38
- return acc2;
39
- }, {}),
40
- stepGraph: workflow.serializedStepGraph,
41
- inputSchema: workflow.inputSchema ? stringify(esm_default(workflow.inputSchema)) : void 0,
42
- outputSchema: workflow.outputSchema ? stringify(esm_default(workflow.outputSchema)) : void 0
43
- };
44
- return acc;
45
- }, {});
46
- return _workflows;
47
- } catch (error) {
48
- throw new HTTPException(500, { message: error?.message || "Error getting workflows" });
49
- }
50
- }
51
- async function getWorkflowByIdHandler({ mastra, workflowId }) {
52
- try {
53
- if (!workflowId) {
54
- throw new HTTPException(400, { message: "Workflow ID is required" });
55
- }
56
- const workflow = mastra.getWorkflow(workflowId);
57
- if (!workflow) {
58
- throw new HTTPException(404, { message: "Workflow not found" });
59
- }
60
- return {
61
- steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
62
- acc[key] = {
63
- id: step.id,
64
- description: step.description,
65
- inputSchema: step.inputSchema ? stringify(esm_default(step.inputSchema)) : void 0,
66
- outputSchema: step.outputSchema ? stringify(esm_default(step.outputSchema)) : void 0,
67
- resumeSchema: step.resumeSchema ? stringify(esm_default(step.resumeSchema)) : void 0,
68
- suspendSchema: step.suspendSchema ? stringify(esm_default(step.suspendSchema)) : void 0
69
- };
70
- return acc;
71
- }, {}),
72
- name: workflow.name,
73
- description: workflow.description,
74
- stepGraph: workflow.serializedStepGraph,
75
- inputSchema: workflow.inputSchema ? stringify(esm_default(workflow.inputSchema)) : void 0,
76
- outputSchema: workflow.outputSchema ? stringify(esm_default(workflow.outputSchema)) : void 0
77
- };
78
- } catch (error) {
79
- throw new HTTPException(500, { message: error?.message || "Error getting workflow" });
80
- }
81
- }
82
- async function getWorkflowRunByIdHandler({
83
- mastra,
84
- workflowId,
85
- runId
86
- }) {
87
- try {
88
- if (!workflowId) {
89
- throw new HTTPException(400, { message: "Workflow ID is required" });
90
- }
91
- if (!runId) {
92
- throw new HTTPException(400, { message: "Run ID is required" });
93
- }
94
- const workflow = mastra.getWorkflow(workflowId);
95
- if (!workflow) {
96
- throw new HTTPException(404, { message: "Workflow not found" });
97
- }
98
- const run = await workflow.getWorkflowRunById(runId);
99
- if (!run) {
100
- throw new HTTPException(404, { message: "Workflow run not found" });
101
- }
102
- return run;
103
- } catch (error) {
104
- throw new HTTPException(500, { message: error?.message || "Error getting workflow run" });
105
- }
106
- }
107
- async function createWorkflowRunHandler({
108
- mastra,
109
- workflowId,
110
- runId: prevRunId
111
- }) {
112
- try {
113
- if (!workflowId) {
114
- throw new HTTPException(400, { message: "Workflow ID is required" });
115
- }
116
- const workflow = mastra.getWorkflow(workflowId);
117
- if (!workflow) {
118
- throw new 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 HTTPException(500, { message: error?.message || "Error creating workflow run" });
124
- }
125
- }
126
- async function startAsyncWorkflowHandler({
127
- mastra,
128
- runtimeContext,
129
- workflowId,
130
- runId,
131
- inputData
132
- }) {
133
- try {
134
- if (!workflowId) {
135
- throw new HTTPException(400, { message: "Workflow ID is required" });
136
- }
137
- const workflow = mastra.getWorkflow(workflowId);
138
- if (!workflow) {
139
- throw new HTTPException(404, { message: "Workflow not found" });
140
- }
141
- const _run = workflow.createRun({ runId });
142
- const result = await _run.start({
143
- inputData,
144
- runtimeContext
145
- });
146
- return result;
147
- } catch (error) {
148
- throw new HTTPException(500, { message: error?.message || "Error executing workflow" });
149
- }
150
- }
151
- async function startWorkflowRunHandler({
152
- mastra,
153
- runtimeContext,
154
- workflowId,
155
- runId,
156
- inputData
157
- }) {
158
- try {
159
- if (!workflowId) {
160
- throw new HTTPException(400, { message: "Workflow ID is required" });
161
- }
162
- if (!runId) {
163
- throw new HTTPException(400, { message: "runId required to start run" });
164
- }
165
- const workflow = mastra.getWorkflow(workflowId);
166
- const run = await workflow.getWorkflowRunById(runId);
167
- if (!run) {
168
- throw new HTTPException(404, { message: "Workflow run not found" });
169
- }
170
- const _run = workflow.createRun({ runId });
171
- void _run.start({
172
- inputData,
173
- runtimeContext
174
- });
175
- return { message: "Workflow run started" };
176
- } catch (e) {
177
- return handleError(e, "Error starting workflow run");
178
- }
179
- }
180
- async function watchWorkflowHandler({
181
- mastra,
182
- workflowId,
183
- runId
184
- }) {
185
- try {
186
- if (!workflowId) {
187
- throw new HTTPException(400, { message: "Workflow ID is required" });
188
- }
189
- if (!runId) {
190
- throw new HTTPException(400, { message: "runId required to watch workflow" });
191
- }
192
- const workflow = mastra.getWorkflow(workflowId);
193
- const run = await workflow.getWorkflowRunById(runId);
194
- if (!run) {
195
- throw new HTTPException(404, { message: "Workflow run not found" });
196
- }
197
- const _run = workflow.createRun({ runId });
198
- let unwatch;
199
- let asyncRef = null;
200
- const stream = new ReadableStream({
201
- start(controller) {
202
- unwatch = _run.watch(({ type, payload, eventTimestamp }) => {
203
- controller.enqueue(JSON.stringify({ type, payload, eventTimestamp, runId }));
204
- if (asyncRef) {
205
- clearImmediate(asyncRef);
206
- asyncRef = null;
207
- }
208
- asyncRef = setImmediate(async () => {
209
- const runDone = payload.workflowState.status !== "running";
210
- if (runDone) {
211
- controller.close();
212
- unwatch?.();
213
- }
214
- });
215
- });
216
- },
217
- cancel() {
218
- unwatch?.();
219
- }
220
- });
221
- return stream;
222
- } catch (error) {
223
- return handleError(error, "Error watching workflow");
224
- }
225
- }
226
- function streamWorkflowHandler({
227
- mastra,
228
- runtimeContext,
229
- workflowId,
230
- runId,
231
- inputData
232
- }) {
233
- try {
234
- if (!workflowId) {
235
- throw new HTTPException(400, { message: "Workflow ID is required" });
236
- }
237
- if (!runId) {
238
- throw new HTTPException(400, { message: "runId required to resume workflow" });
239
- }
240
- const workflow = mastra.getWorkflow(workflowId);
241
- if (!workflow) {
242
- throw new HTTPException(404, { message: "Workflow not found" });
243
- }
244
- const run = workflow.createRun({ runId });
245
- const result = run.stream({
246
- inputData,
247
- runtimeContext
248
- });
249
- return result;
250
- } catch (error) {
251
- return handleError(error, "Error executing workflow");
252
- }
253
- }
254
- async function resumeAsyncWorkflowHandler({
255
- mastra,
256
- workflowId,
257
- runId,
258
- body,
259
- runtimeContext
260
- }) {
261
- try {
262
- if (!workflowId) {
263
- throw new HTTPException(400, { message: "Workflow ID is required" });
264
- }
265
- if (!runId) {
266
- throw new HTTPException(400, { message: "runId required to resume workflow" });
267
- }
268
- if (!body.step) {
269
- throw new HTTPException(400, { message: "step required to resume workflow" });
270
- }
271
- const workflow = mastra.getWorkflow(workflowId);
272
- const run = await workflow.getWorkflowRunById(runId);
273
- if (!run) {
274
- throw new HTTPException(404, { message: "Workflow run not found" });
275
- }
276
- const _run = workflow.createRun({ runId });
277
- const result = await _run.resume({
278
- step: body.step,
279
- resumeData: body.resumeData,
280
- runtimeContext
281
- });
282
- return result;
283
- } catch (error) {
284
- return handleError(error, "Error resuming workflow step");
285
- }
286
- }
287
- async function resumeWorkflowHandler({
288
- mastra,
289
- workflowId,
290
- runId,
291
- body,
292
- runtimeContext
293
- }) {
294
- try {
295
- if (!workflowId) {
296
- throw new HTTPException(400, { message: "Workflow ID is required" });
297
- }
298
- if (!runId) {
299
- throw new HTTPException(400, { message: "runId required to resume workflow" });
300
- }
301
- if (!body.step) {
302
- throw new HTTPException(400, { message: "step required to resume workflow" });
303
- }
304
- const workflow = mastra.getWorkflow(workflowId);
305
- const run = await workflow.getWorkflowRunById(runId);
306
- if (!run) {
307
- throw new HTTPException(404, { message: "Workflow run not found" });
308
- }
309
- const _run = workflow.createRun({ runId });
310
- void _run.resume({
311
- step: body.step,
312
- resumeData: body.resumeData,
313
- runtimeContext
314
- });
315
- return { message: "Workflow run resumed" };
316
- } catch (error) {
317
- return handleError(error, "Error resuming workflow");
318
- }
319
- }
320
- async function getWorkflowRunsHandler({
321
- mastra,
322
- workflowId,
323
- fromDate,
324
- toDate,
325
- limit,
326
- offset,
327
- resourceId
328
- }) {
329
- try {
330
- if (!workflowId) {
331
- throw new HTTPException(400, { message: "Workflow ID is required" });
332
- }
333
- const workflow = mastra.getWorkflow(workflowId);
334
- const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
335
- runs: [],
336
- total: 0
337
- };
338
- return workflowRuns;
339
- } catch (error) {
340
- return handleError(error, "Error getting workflow runs");
341
- }
342
- }
343
-
344
- export { createWorkflowRunHandler, getWorkflowByIdHandler, getWorkflowRunByIdHandler, getWorkflowRunsHandler, getWorkflowsHandler, resumeAsyncWorkflowHandler, resumeWorkflowHandler, startAsyncWorkflowHandler, startWorkflowRunHandler, streamWorkflowHandler, watchWorkflowHandler, workflows_exports };
@@ -1,145 +0,0 @@
1
- 'use strict';
2
-
3
- var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
4
- var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
5
- var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
6
-
7
- // src/server/handlers/telemetry.ts
8
- var telemetry_exports = {};
9
- chunk75ZPJI57_cjs.__export(telemetry_exports, {
10
- getTelemetryHandler: () => getTelemetryHandler,
11
- storeTelemetryHandler: () => storeTelemetryHandler
12
- });
13
- async function getTelemetryHandler({ mastra, body }) {
14
- try {
15
- const telemetry = mastra.getTelemetry();
16
- const storage = mastra.getStorage();
17
- if (!telemetry) {
18
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Telemetry is not initialized" });
19
- }
20
- if (!storage) {
21
- return [];
22
- }
23
- if (!body) {
24
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Body is required" });
25
- }
26
- const { name, scope, page, perPage, attribute, fromDate, toDate } = body;
27
- const attributes = attribute ? Object.fromEntries(
28
- (Array.isArray(attribute) ? attribute : [attribute]).map((attr) => {
29
- const [key, value] = attr.split(":");
30
- return [key, value];
31
- })
32
- ) : void 0;
33
- const traces = await storage.getTraces({
34
- name,
35
- scope,
36
- page: Number(page ?? 0),
37
- perPage: Number(perPage ?? 100),
38
- attributes,
39
- fromDate: fromDate ? new Date(fromDate) : void 0,
40
- toDate: toDate ? new Date(toDate) : void 0
41
- });
42
- return traces;
43
- } catch (error2) {
44
- return chunk64U3UDTH_cjs.handleError(error2, "Error getting telemetry");
45
- }
46
- }
47
- async function storeTelemetryHandler({ mastra, body }) {
48
- try {
49
- const storage = mastra.getStorage();
50
- const logger = mastra.getLogger();
51
- if (!storage) {
52
- return {
53
- status: "error",
54
- message: "Storage is not initialized"
55
- };
56
- }
57
- const now = /* @__PURE__ */ new Date();
58
- const items = body?.resourceSpans?.[0]?.scopeSpans;
59
- logger.debug("[Telemetry Handler] Received spans:", {
60
- totalSpans: items?.reduce((acc, scope) => acc + scope.spans.length, 0) || 0,
61
- timestamp: now.toISOString()
62
- });
63
- if (!items?.length) {
64
- return {
65
- status: "success",
66
- message: "No spans to process",
67
- traceCount: 0
68
- };
69
- }
70
- const allSpans = items.reduce((acc, scopedSpans) => {
71
- const { scope, spans } = scopedSpans;
72
- for (const span of spans) {
73
- const {
74
- spanId,
75
- parentSpanId,
76
- traceId,
77
- name,
78
- kind,
79
- attributes,
80
- status,
81
- events,
82
- links,
83
- startTimeUnixNano,
84
- endTimeUnixNano,
85
- ...rest
86
- } = span;
87
- const startTime = Number(BigInt(startTimeUnixNano) / 1000n);
88
- const endTime = Number(BigInt(endTimeUnixNano) / 1000n);
89
- acc.push({
90
- id: spanId,
91
- parentSpanId,
92
- traceId,
93
- name,
94
- scope: scope.name,
95
- kind,
96
- status: JSON.stringify(status),
97
- events: JSON.stringify(events),
98
- links: JSON.stringify(links),
99
- attributes: JSON.stringify(
100
- attributes.reduce((acc2, attr) => {
101
- const valueKey = Object.keys(attr.value)[0];
102
- if (valueKey) {
103
- acc2[attr.key] = attr.value[valueKey];
104
- }
105
- return acc2;
106
- }, {})
107
- ),
108
- startTime,
109
- endTime,
110
- other: JSON.stringify(rest),
111
- createdAt: now
112
- });
113
- }
114
- return acc;
115
- }, []);
116
- return storage.batchTraceInsert({
117
- records: allSpans
118
- }).then(() => {
119
- return {
120
- status: "success",
121
- message: "Traces received and processed successfully",
122
- traceCount: body.resourceSpans?.length || 0
123
- };
124
- }).catch(() => {
125
- return {
126
- status: "error",
127
- message: "Failed to process traces",
128
- // @ts-ignore
129
- error: error.message
130
- };
131
- });
132
- } catch (error2) {
133
- console.error("Error processing traces:", error2);
134
- return {
135
- status: "error",
136
- message: "Failed to process traces",
137
- // @ts-ignore
138
- error: error2.message
139
- };
140
- }
141
- }
142
-
143
- exports.getTelemetryHandler = getTelemetryHandler;
144
- exports.storeTelemetryHandler = storeTelemetryHandler;
145
- exports.telemetry_exports = telemetry_exports;
@@ -1,141 +0,0 @@
1
- import { handleError } from './chunk-M5ABIP7D.js';
2
- import { HTTPException } from './chunk-NYN7KFXL.js';
3
- import { __export } from './chunk-MLKGABMK.js';
4
-
5
- // src/server/handlers/telemetry.ts
6
- var telemetry_exports = {};
7
- __export(telemetry_exports, {
8
- getTelemetryHandler: () => getTelemetryHandler,
9
- storeTelemetryHandler: () => storeTelemetryHandler
10
- });
11
- async function getTelemetryHandler({ mastra, body }) {
12
- try {
13
- const telemetry = mastra.getTelemetry();
14
- const storage = mastra.getStorage();
15
- if (!telemetry) {
16
- throw new HTTPException(400, { message: "Telemetry is not initialized" });
17
- }
18
- if (!storage) {
19
- return [];
20
- }
21
- if (!body) {
22
- throw new HTTPException(400, { message: "Body is required" });
23
- }
24
- const { name, scope, page, perPage, attribute, fromDate, toDate } = body;
25
- const attributes = attribute ? Object.fromEntries(
26
- (Array.isArray(attribute) ? attribute : [attribute]).map((attr) => {
27
- const [key, value] = attr.split(":");
28
- return [key, value];
29
- })
30
- ) : void 0;
31
- const traces = await storage.getTraces({
32
- name,
33
- scope,
34
- page: Number(page ?? 0),
35
- perPage: Number(perPage ?? 100),
36
- attributes,
37
- fromDate: fromDate ? new Date(fromDate) : void 0,
38
- toDate: toDate ? new Date(toDate) : void 0
39
- });
40
- return traces;
41
- } catch (error2) {
42
- return handleError(error2, "Error getting telemetry");
43
- }
44
- }
45
- async function storeTelemetryHandler({ mastra, body }) {
46
- try {
47
- const storage = mastra.getStorage();
48
- const logger = mastra.getLogger();
49
- if (!storage) {
50
- return {
51
- status: "error",
52
- message: "Storage is not initialized"
53
- };
54
- }
55
- const now = /* @__PURE__ */ new Date();
56
- const items = body?.resourceSpans?.[0]?.scopeSpans;
57
- logger.debug("[Telemetry Handler] Received spans:", {
58
- totalSpans: items?.reduce((acc, scope) => acc + scope.spans.length, 0) || 0,
59
- timestamp: now.toISOString()
60
- });
61
- if (!items?.length) {
62
- return {
63
- status: "success",
64
- message: "No spans to process",
65
- traceCount: 0
66
- };
67
- }
68
- const allSpans = items.reduce((acc, scopedSpans) => {
69
- const { scope, spans } = scopedSpans;
70
- for (const span of spans) {
71
- const {
72
- spanId,
73
- parentSpanId,
74
- traceId,
75
- name,
76
- kind,
77
- attributes,
78
- status,
79
- events,
80
- links,
81
- startTimeUnixNano,
82
- endTimeUnixNano,
83
- ...rest
84
- } = span;
85
- const startTime = Number(BigInt(startTimeUnixNano) / 1000n);
86
- const endTime = Number(BigInt(endTimeUnixNano) / 1000n);
87
- acc.push({
88
- id: spanId,
89
- parentSpanId,
90
- traceId,
91
- name,
92
- scope: scope.name,
93
- kind,
94
- status: JSON.stringify(status),
95
- events: JSON.stringify(events),
96
- links: JSON.stringify(links),
97
- attributes: JSON.stringify(
98
- attributes.reduce((acc2, attr) => {
99
- const valueKey = Object.keys(attr.value)[0];
100
- if (valueKey) {
101
- acc2[attr.key] = attr.value[valueKey];
102
- }
103
- return acc2;
104
- }, {})
105
- ),
106
- startTime,
107
- endTime,
108
- other: JSON.stringify(rest),
109
- createdAt: now
110
- });
111
- }
112
- return acc;
113
- }, []);
114
- return storage.batchTraceInsert({
115
- records: allSpans
116
- }).then(() => {
117
- return {
118
- status: "success",
119
- message: "Traces received and processed successfully",
120
- traceCount: body.resourceSpans?.length || 0
121
- };
122
- }).catch(() => {
123
- return {
124
- status: "error",
125
- message: "Failed to process traces",
126
- // @ts-ignore
127
- error: error.message
128
- };
129
- });
130
- } catch (error2) {
131
- console.error("Error processing traces:", error2);
132
- return {
133
- status: "error",
134
- message: "Failed to process traces",
135
- // @ts-ignore
136
- error: error2.message
137
- };
138
- }
139
- }
140
-
141
- export { getTelemetryHandler, storeTelemetryHandler, telemetry_exports };