@mastra/server 0.0.0-separate-trace-data-from-component-20250501141108 → 0.0.0-support-d1-client-20250701191943

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 (91) hide show
  1. package/README.md +48 -135
  2. package/dist/_tsup-dts-rollup.d.cts +517 -103
  3. package/dist/_tsup-dts-rollup.d.ts +517 -103
  4. package/dist/{chunk-2FJURXCL.cjs → chunk-3DKDT264.cjs} +93 -55
  5. package/dist/{chunk-Y3SV5XK4.js → chunk-4QBIUKVY.js} +105 -16
  6. package/dist/{chunk-QN4KF3BH.cjs → chunk-57CJTIPW.cjs} +2 -2
  7. package/dist/chunk-7524QH7G.cjs +483 -0
  8. package/dist/chunk-75ZPJI57.cjs +9 -0
  9. package/dist/{chunk-M3YJLWTU.js → chunk-7GQJAMTA.js} +68 -57
  10. package/dist/chunk-BOXE6WSV.js +81 -0
  11. package/dist/{chunk-WTHDCRMY.js → chunk-BP24Z4WG.js} +12 -6
  12. package/dist/chunk-BWHGBV3K.cjs +278 -0
  13. package/dist/chunk-CNVDCLSY.cjs +86 -0
  14. package/dist/{chunk-5JNVY6DU.js → chunk-DFJUGWNU.js} +7 -5
  15. package/dist/{chunk-5YGDYMRB.cjs → chunk-DPRB3R7Y.cjs} +14 -13
  16. package/dist/{chunk-D3G23FP3.cjs → chunk-FGGMQCPP.cjs} +24 -22
  17. package/dist/{chunk-4JINXASC.js → chunk-FVMGZKFD.js} +5 -4
  18. package/dist/{chunk-Q6SHQECN.js → chunk-G37NVEDX.js} +34 -10
  19. package/dist/chunk-GHC4YV6R.js +504 -0
  20. package/dist/{chunk-L7XE5QTW.js → chunk-H5PTF3Y4.js} +1 -1
  21. package/dist/chunk-L3N7ST2Z.cjs +118 -0
  22. package/dist/chunk-LI436ITD.cjs +2042 -0
  23. package/dist/{chunk-RBQASTUP.js → chunk-LTJNMM2Y.js} +63 -25
  24. package/dist/chunk-MEGCYGBU.js +2039 -0
  25. package/dist/chunk-MLKGABMK.js +7 -0
  26. package/dist/{chunk-ZLBRQFDD.cjs → chunk-MTR2B27E.cjs} +3 -2
  27. package/dist/{chunk-TRDNDNGQ.js → chunk-NYN7KFXL.js} +1 -7
  28. package/dist/{chunk-FV45V6WC.cjs → chunk-OCWPVYNI.cjs} +0 -7
  29. package/dist/{chunk-3AHQ5RGN.js → chunk-QDOJJCS4.js} +3 -2
  30. package/dist/chunk-SDPGVWQJ.cjs +512 -0
  31. package/dist/chunk-TGZIR6AK.cjs +332 -0
  32. package/dist/{chunk-M56ECCHK.cjs → chunk-TVBPFPTN.cjs} +20 -19
  33. package/dist/{chunk-7IWQE76Z.cjs → chunk-ULFULEW4.cjs} +16 -10
  34. package/dist/{chunk-QJ3AHN64.js → chunk-VMXLEF54.js} +4 -3
  35. package/dist/chunk-Z5TH5F35.js +468 -0
  36. package/dist/server/handlers/a2a.cjs +30 -0
  37. package/dist/server/handlers/a2a.d.cts +6 -0
  38. package/dist/server/handlers/a2a.d.ts +6 -0
  39. package/dist/server/handlers/a2a.js +1 -0
  40. package/dist/server/handlers/agents.cjs +7 -7
  41. package/dist/server/handlers/agents.js +1 -1
  42. package/dist/server/handlers/error.cjs +2 -2
  43. package/dist/server/handlers/error.js +1 -1
  44. package/dist/server/handlers/legacyWorkflows.cjs +46 -0
  45. package/dist/server/handlers/legacyWorkflows.d.cts +10 -0
  46. package/dist/server/handlers/legacyWorkflows.d.ts +10 -0
  47. package/dist/server/handlers/legacyWorkflows.js +1 -0
  48. package/dist/server/handlers/logs.cjs +4 -4
  49. package/dist/server/handlers/logs.js +1 -1
  50. package/dist/server/handlers/memory.cjs +9 -9
  51. package/dist/server/handlers/memory.js +1 -1
  52. package/dist/server/handlers/network.cjs +5 -5
  53. package/dist/server/handlers/network.js +1 -1
  54. package/dist/server/handlers/telemetry.cjs +3 -3
  55. package/dist/server/handlers/telemetry.js +1 -1
  56. package/dist/server/handlers/tools.cjs +5 -5
  57. package/dist/server/handlers/tools.js +1 -1
  58. package/dist/server/handlers/utils.cjs +2 -2
  59. package/dist/server/handlers/utils.js +1 -1
  60. package/dist/server/handlers/vNextNetwork.cjs +218 -0
  61. package/dist/server/handlers/vNextNetwork.d.cts +6 -0
  62. package/dist/server/handlers/vNextNetwork.d.ts +6 -0
  63. package/dist/server/handlers/vNextNetwork.js +211 -0
  64. package/dist/server/handlers/vector.cjs +7 -7
  65. package/dist/server/handlers/vector.js +1 -1
  66. package/dist/server/handlers/voice.cjs +8 -4
  67. package/dist/server/handlers/voice.d.cts +1 -0
  68. package/dist/server/handlers/voice.d.ts +1 -0
  69. package/dist/server/handlers/voice.js +1 -1
  70. package/dist/server/handlers/workflows.cjs +25 -13
  71. package/dist/server/handlers/workflows.d.cts +5 -2
  72. package/dist/server/handlers/workflows.d.ts +5 -2
  73. package/dist/server/handlers/workflows.js +1 -1
  74. package/dist/server/handlers.cjs +32 -27
  75. package/dist/server/handlers.d.cts +2 -1
  76. package/dist/server/handlers.d.ts +2 -1
  77. package/dist/server/handlers.js +11 -10
  78. package/package.json +14 -13
  79. package/dist/chunk-3EJZQ6TQ.js +0 -49
  80. package/dist/chunk-4BIX6GMY.cjs +0 -189
  81. package/dist/chunk-55HTWX4C.cjs +0 -93
  82. package/dist/chunk-5SWCVTNL.cjs +0 -5579
  83. package/dist/chunk-AELYAUEE.cjs +0 -316
  84. package/dist/chunk-EVCC233P.cjs +0 -321
  85. package/dist/chunk-JPB6RPGB.js +0 -304
  86. package/dist/chunk-OMN3UI6X.js +0 -5576
  87. package/dist/chunk-SKBVVI24.cjs +0 -54
  88. package/dist/server/handlers/vNextWorkflows.cjs +0 -46
  89. package/dist/server/handlers/vNextWorkflows.d.cts +0 -10
  90. package/dist/server/handlers/vNextWorkflows.d.ts +0 -10
  91. package/dist/server/handlers/vNextWorkflows.js +0 -1
@@ -0,0 +1,468 @@
1
+ import { stringify, esm_default } from './chunk-MEGCYGBU.js';
2
+ import { handleError } from './chunk-QDOJJCS4.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
+ cancelWorkflowRunHandler: () => cancelWorkflowRunHandler,
11
+ createWorkflowRunHandler: () => createWorkflowRunHandler,
12
+ getWorkflowByIdHandler: () => getWorkflowByIdHandler,
13
+ getWorkflowRunByIdHandler: () => getWorkflowRunByIdHandler,
14
+ getWorkflowRunExecutionResultHandler: () => getWorkflowRunExecutionResultHandler,
15
+ getWorkflowRunsHandler: () => getWorkflowRunsHandler,
16
+ getWorkflowsHandler: () => getWorkflowsHandler,
17
+ resumeAsyncWorkflowHandler: () => resumeAsyncWorkflowHandler,
18
+ resumeWorkflowHandler: () => resumeWorkflowHandler,
19
+ startAsyncWorkflowHandler: () => startAsyncWorkflowHandler,
20
+ startWorkflowRunHandler: () => startWorkflowRunHandler,
21
+ streamWorkflowHandler: () => streamWorkflowHandler,
22
+ watchWorkflowHandler: () => watchWorkflowHandler
23
+ });
24
+ function getSteps(steps, path) {
25
+ return Object.entries(steps).reduce((acc, [key, step]) => {
26
+ const fullKey = path ? `${path}.${key}` : key;
27
+ acc[fullKey] = {
28
+ id: step.id,
29
+ description: step.description,
30
+ inputSchema: step.inputSchema ? stringify(esm_default(step.inputSchema)) : void 0,
31
+ outputSchema: step.outputSchema ? stringify(esm_default(step.outputSchema)) : void 0,
32
+ resumeSchema: step.resumeSchema ? stringify(esm_default(step.resumeSchema)) : void 0,
33
+ suspendSchema: step.suspendSchema ? stringify(esm_default(step.suspendSchema)) : void 0,
34
+ isWorkflow: step.component === "WORKFLOW"
35
+ };
36
+ if (step.component === "WORKFLOW" && step.steps) {
37
+ const nestedSteps = getSteps(step.steps, fullKey) || {};
38
+ acc = { ...acc, ...nestedSteps };
39
+ }
40
+ return acc;
41
+ }, {});
42
+ }
43
+ async function getWorkflowsHandler({ mastra }) {
44
+ try {
45
+ const workflows = mastra.getWorkflows({ serialized: false });
46
+ const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
47
+ acc[key] = {
48
+ name: workflow.name,
49
+ description: workflow.description,
50
+ steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
51
+ acc2[key2] = {
52
+ id: step.id,
53
+ description: step.description,
54
+ inputSchema: step.inputSchema ? stringify(esm_default(step.inputSchema)) : void 0,
55
+ outputSchema: step.outputSchema ? stringify(esm_default(step.outputSchema)) : void 0,
56
+ resumeSchema: step.resumeSchema ? stringify(esm_default(step.resumeSchema)) : void 0,
57
+ suspendSchema: step.suspendSchema ? stringify(esm_default(step.suspendSchema)) : void 0
58
+ };
59
+ return acc2;
60
+ }, {}),
61
+ allSteps: getSteps(workflow.steps) || {},
62
+ stepGraph: workflow.serializedStepGraph,
63
+ inputSchema: workflow.inputSchema ? stringify(esm_default(workflow.inputSchema)) : void 0,
64
+ outputSchema: workflow.outputSchema ? stringify(esm_default(workflow.outputSchema)) : void 0
65
+ };
66
+ return acc;
67
+ }, {});
68
+ return _workflows;
69
+ } catch (error) {
70
+ return handleError(error, "Error getting workflows");
71
+ }
72
+ }
73
+ async function getWorkflowsFromSystem({ mastra, workflowId }) {
74
+ const logger = mastra.getLogger();
75
+ if (!workflowId) {
76
+ throw new HTTPException(400, { message: "Workflow ID is required" });
77
+ }
78
+ let workflow;
79
+ try {
80
+ workflow = mastra.getWorkflow(workflowId);
81
+ } catch (error) {
82
+ logger.debug("Error getting workflow, searching agents for workflow", error);
83
+ }
84
+ if (!workflow) {
85
+ logger.debug("Workflow not found, searching agents for workflow", { workflowId });
86
+ const agents = mastra.getAgents();
87
+ if (Object.keys(agents || {}).length) {
88
+ for (const [_, agent] of Object.entries(agents)) {
89
+ try {
90
+ const workflows = await agent.getWorkflows();
91
+ if (workflows[workflowId]) {
92
+ workflow = workflows[workflowId];
93
+ break;
94
+ }
95
+ break;
96
+ } catch (error) {
97
+ logger.debug("Error getting workflow from agent", error);
98
+ }
99
+ }
100
+ }
101
+ }
102
+ if (!workflow) {
103
+ throw new HTTPException(404, { message: "Workflow not found" });
104
+ }
105
+ return { workflow };
106
+ }
107
+ async function getWorkflowByIdHandler({ mastra, workflowId }) {
108
+ try {
109
+ if (!workflowId) {
110
+ throw new HTTPException(400, { message: "Workflow ID is required" });
111
+ }
112
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
113
+ if (!workflow) {
114
+ throw new HTTPException(404, { message: "Workflow not found" });
115
+ }
116
+ return {
117
+ steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
118
+ acc[key] = {
119
+ id: step.id,
120
+ description: step.description,
121
+ inputSchema: step.inputSchema ? stringify(esm_default(step.inputSchema)) : void 0,
122
+ outputSchema: step.outputSchema ? stringify(esm_default(step.outputSchema)) : void 0,
123
+ resumeSchema: step.resumeSchema ? stringify(esm_default(step.resumeSchema)) : void 0,
124
+ suspendSchema: step.suspendSchema ? stringify(esm_default(step.suspendSchema)) : void 0
125
+ };
126
+ return acc;
127
+ }, {}),
128
+ allSteps: getSteps(workflow.steps) || {},
129
+ name: workflow.name,
130
+ description: workflow.description,
131
+ stepGraph: workflow.serializedStepGraph,
132
+ inputSchema: workflow.inputSchema ? stringify(esm_default(workflow.inputSchema)) : void 0,
133
+ outputSchema: workflow.outputSchema ? stringify(esm_default(workflow.outputSchema)) : void 0
134
+ };
135
+ } catch (error) {
136
+ return handleError(error, "Error getting workflow");
137
+ }
138
+ }
139
+ async function getWorkflowRunByIdHandler({
140
+ mastra,
141
+ workflowId,
142
+ runId
143
+ }) {
144
+ try {
145
+ if (!workflowId) {
146
+ throw new HTTPException(400, { message: "Workflow ID is required" });
147
+ }
148
+ if (!runId) {
149
+ throw new HTTPException(400, { message: "Run ID is required" });
150
+ }
151
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
152
+ if (!workflow) {
153
+ throw new HTTPException(404, { message: "Workflow not found" });
154
+ }
155
+ const run = await workflow.getWorkflowRunById(runId);
156
+ if (!run) {
157
+ throw new HTTPException(404, { message: "Workflow run not found" });
158
+ }
159
+ return run;
160
+ } catch (error) {
161
+ return handleError(error, "Error getting workflow run");
162
+ }
163
+ }
164
+ async function getWorkflowRunExecutionResultHandler({
165
+ mastra,
166
+ workflowId,
167
+ runId
168
+ }) {
169
+ try {
170
+ if (!workflowId) {
171
+ throw new HTTPException(400, { message: "Workflow ID is required" });
172
+ }
173
+ if (!runId) {
174
+ throw new HTTPException(400, { message: "Run ID is required" });
175
+ }
176
+ const workflow = mastra.getWorkflow(workflowId);
177
+ if (!workflow) {
178
+ throw new HTTPException(404, { message: "Workflow not found" });
179
+ }
180
+ const executionResult = await workflow.getWorkflowRunExecutionResult(runId);
181
+ if (!executionResult) {
182
+ throw new HTTPException(404, { message: "Workflow run execution result not found" });
183
+ }
184
+ return executionResult;
185
+ } catch (error) {
186
+ return handleError(error, "Error getting workflow run execution result");
187
+ }
188
+ }
189
+ async function createWorkflowRunHandler({
190
+ mastra,
191
+ workflowId,
192
+ runId: prevRunId
193
+ }) {
194
+ try {
195
+ if (!workflowId) {
196
+ throw new HTTPException(400, { message: "Workflow ID is required" });
197
+ }
198
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
199
+ if (!workflow) {
200
+ throw new HTTPException(404, { message: "Workflow not found" });
201
+ }
202
+ const run = await workflow.createRunAsync({ runId: prevRunId });
203
+ return { runId: run.runId };
204
+ } catch (error) {
205
+ return handleError(error, "Error creating workflow run");
206
+ }
207
+ }
208
+ async function startAsyncWorkflowHandler({
209
+ mastra,
210
+ runtimeContext,
211
+ workflowId,
212
+ runId,
213
+ inputData
214
+ }) {
215
+ try {
216
+ if (!workflowId) {
217
+ throw new HTTPException(400, { message: "Workflow ID is required" });
218
+ }
219
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
220
+ if (!workflow) {
221
+ throw new HTTPException(404, { message: "Workflow not found" });
222
+ }
223
+ const _run = await workflow.createRunAsync({ runId });
224
+ const result = await _run.start({
225
+ inputData,
226
+ runtimeContext
227
+ });
228
+ return result;
229
+ } catch (error) {
230
+ return handleError(error, "Error starting async workflow");
231
+ }
232
+ }
233
+ async function startWorkflowRunHandler({
234
+ mastra,
235
+ runtimeContext,
236
+ workflowId,
237
+ runId,
238
+ inputData
239
+ }) {
240
+ try {
241
+ if (!workflowId) {
242
+ throw new HTTPException(400, { message: "Workflow ID is required" });
243
+ }
244
+ if (!runId) {
245
+ throw new HTTPException(400, { message: "runId required to start run" });
246
+ }
247
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
248
+ if (!workflow) {
249
+ throw new HTTPException(404, { message: "Workflow not found" });
250
+ }
251
+ const run = await workflow.getWorkflowRunById(runId);
252
+ if (!run) {
253
+ throw new HTTPException(404, { message: "Workflow run not found" });
254
+ }
255
+ const _run = await workflow.createRunAsync({ runId });
256
+ void _run.start({
257
+ inputData,
258
+ runtimeContext
259
+ });
260
+ return { message: "Workflow run started" };
261
+ } catch (e) {
262
+ return handleError(e, "Error starting workflow run");
263
+ }
264
+ }
265
+ async function watchWorkflowHandler({
266
+ mastra,
267
+ workflowId,
268
+ runId
269
+ }) {
270
+ try {
271
+ if (!workflowId) {
272
+ throw new HTTPException(400, { message: "Workflow ID is required" });
273
+ }
274
+ if (!runId) {
275
+ throw new HTTPException(400, { message: "runId required to watch workflow" });
276
+ }
277
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
278
+ if (!workflow) {
279
+ throw new HTTPException(404, { message: "Workflow not found" });
280
+ }
281
+ const run = await workflow.getWorkflowRunById(runId);
282
+ if (!run) {
283
+ throw new HTTPException(404, { message: "Workflow run not found" });
284
+ }
285
+ const _run = await workflow.createRunAsync({ runId });
286
+ let unwatch;
287
+ let asyncRef = null;
288
+ const stream = new ReadableStream({
289
+ start(controller) {
290
+ unwatch = _run.watch(({ type, payload, eventTimestamp }) => {
291
+ controller.enqueue(JSON.stringify({ type, payload, eventTimestamp, runId }));
292
+ if (asyncRef) {
293
+ clearImmediate(asyncRef);
294
+ asyncRef = null;
295
+ }
296
+ asyncRef = setImmediate(async () => {
297
+ const runDone = payload.workflowState.status !== "running";
298
+ if (runDone) {
299
+ controller.close();
300
+ unwatch?.();
301
+ }
302
+ });
303
+ });
304
+ },
305
+ cancel() {
306
+ unwatch?.();
307
+ }
308
+ });
309
+ return stream;
310
+ } catch (error) {
311
+ return handleError(error, "Error watching workflow");
312
+ }
313
+ }
314
+ async function streamWorkflowHandler({
315
+ mastra,
316
+ runtimeContext,
317
+ workflowId,
318
+ runId,
319
+ inputData
320
+ }) {
321
+ try {
322
+ if (!workflowId) {
323
+ throw new HTTPException(400, { message: "Workflow ID is required" });
324
+ }
325
+ if (!runId) {
326
+ throw new HTTPException(400, { message: "runId required to resume workflow" });
327
+ }
328
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
329
+ if (!workflow) {
330
+ throw new HTTPException(404, { message: "Workflow not found" });
331
+ }
332
+ const run = await workflow.createRunAsync({ runId });
333
+ const result = run.stream({
334
+ inputData,
335
+ runtimeContext
336
+ });
337
+ return result;
338
+ } catch (error) {
339
+ return handleError(error, "Error executing workflow");
340
+ }
341
+ }
342
+ async function resumeAsyncWorkflowHandler({
343
+ mastra,
344
+ workflowId,
345
+ runId,
346
+ body,
347
+ runtimeContext
348
+ }) {
349
+ try {
350
+ if (!workflowId) {
351
+ throw new HTTPException(400, { message: "Workflow ID is required" });
352
+ }
353
+ if (!runId) {
354
+ throw new HTTPException(400, { message: "runId required to resume workflow" });
355
+ }
356
+ if (!body.step) {
357
+ throw new HTTPException(400, { message: "step required to resume workflow" });
358
+ }
359
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
360
+ if (!workflow) {
361
+ throw new HTTPException(404, { message: "Workflow not found" });
362
+ }
363
+ const run = await workflow.getWorkflowRunById(runId);
364
+ if (!run) {
365
+ throw new HTTPException(404, { message: "Workflow run not found" });
366
+ }
367
+ const _run = await workflow.createRunAsync({ runId });
368
+ const result = await _run.resume({
369
+ step: body.step,
370
+ resumeData: body.resumeData,
371
+ runtimeContext
372
+ });
373
+ return result;
374
+ } catch (error) {
375
+ return handleError(error, "Error resuming workflow step");
376
+ }
377
+ }
378
+ async function resumeWorkflowHandler({
379
+ mastra,
380
+ workflowId,
381
+ runId,
382
+ body,
383
+ runtimeContext
384
+ }) {
385
+ try {
386
+ if (!workflowId) {
387
+ throw new HTTPException(400, { message: "Workflow ID is required" });
388
+ }
389
+ if (!runId) {
390
+ throw new HTTPException(400, { message: "runId required to resume workflow" });
391
+ }
392
+ if (!body.step) {
393
+ throw new HTTPException(400, { message: "step required to resume workflow" });
394
+ }
395
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
396
+ if (!workflow) {
397
+ throw new HTTPException(404, { message: "Workflow not found" });
398
+ }
399
+ const run = await workflow.getWorkflowRunById(runId);
400
+ if (!run) {
401
+ throw new HTTPException(404, { message: "Workflow run not found" });
402
+ }
403
+ const _run = await workflow.createRunAsync({ runId });
404
+ void _run.resume({
405
+ step: body.step,
406
+ resumeData: body.resumeData,
407
+ runtimeContext
408
+ });
409
+ return { message: "Workflow run resumed" };
410
+ } catch (error) {
411
+ return handleError(error, "Error resuming workflow");
412
+ }
413
+ }
414
+ async function getWorkflowRunsHandler({
415
+ mastra,
416
+ workflowId,
417
+ fromDate,
418
+ toDate,
419
+ limit,
420
+ offset,
421
+ resourceId
422
+ }) {
423
+ try {
424
+ if (!workflowId) {
425
+ throw new HTTPException(400, { message: "Workflow ID is required" });
426
+ }
427
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
428
+ if (!workflow) {
429
+ throw new HTTPException(404, { message: "Workflow not found" });
430
+ }
431
+ const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
432
+ runs: [],
433
+ total: 0
434
+ };
435
+ return workflowRuns;
436
+ } catch (error) {
437
+ return handleError(error, "Error getting workflow runs");
438
+ }
439
+ }
440
+ async function cancelWorkflowRunHandler({
441
+ mastra,
442
+ workflowId,
443
+ runId
444
+ }) {
445
+ try {
446
+ if (!workflowId) {
447
+ throw new HTTPException(400, { message: "Workflow ID is required" });
448
+ }
449
+ if (!runId) {
450
+ throw new HTTPException(400, { message: "runId required to cancel workflow run" });
451
+ }
452
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
453
+ if (!workflow) {
454
+ throw new HTTPException(404, { message: "Workflow not found" });
455
+ }
456
+ const run = await workflow.getWorkflowRunById(runId);
457
+ if (!run) {
458
+ throw new HTTPException(404, { message: "Workflow run not found" });
459
+ }
460
+ const _run = await workflow.createRunAsync({ runId });
461
+ await _run.cancel();
462
+ return { message: "Workflow run cancelled" };
463
+ } catch (error) {
464
+ return handleError(error, "Error canceling workflow run");
465
+ }
466
+ }
467
+
468
+ export { cancelWorkflowRunHandler, createWorkflowRunHandler, getWorkflowByIdHandler, getWorkflowRunByIdHandler, getWorkflowRunExecutionResultHandler, getWorkflowRunsHandler, getWorkflowsHandler, resumeAsyncWorkflowHandler, resumeWorkflowHandler, startAsyncWorkflowHandler, startWorkflowRunHandler, streamWorkflowHandler, watchWorkflowHandler, workflows_exports };
@@ -0,0 +1,30 @@
1
+ 'use strict';
2
+
3
+ var chunkSDPGVWQJ_cjs = require('../../chunk-SDPGVWQJ.cjs');
4
+
5
+
6
+
7
+ Object.defineProperty(exports, "getAgentCardByIdHandler", {
8
+ enumerable: true,
9
+ get: function () { return chunkSDPGVWQJ_cjs.getAgentCardByIdHandler; }
10
+ });
11
+ Object.defineProperty(exports, "getAgentExecutionHandler", {
12
+ enumerable: true,
13
+ get: function () { return chunkSDPGVWQJ_cjs.getAgentExecutionHandler; }
14
+ });
15
+ Object.defineProperty(exports, "handleTaskCancel", {
16
+ enumerable: true,
17
+ get: function () { return chunkSDPGVWQJ_cjs.handleTaskCancel; }
18
+ });
19
+ Object.defineProperty(exports, "handleTaskGet", {
20
+ enumerable: true,
21
+ get: function () { return chunkSDPGVWQJ_cjs.handleTaskGet; }
22
+ });
23
+ Object.defineProperty(exports, "handleTaskSend", {
24
+ enumerable: true,
25
+ get: function () { return chunkSDPGVWQJ_cjs.handleTaskSend; }
26
+ });
27
+ Object.defineProperty(exports, "handleTaskSendSubscribe", {
28
+ enumerable: true,
29
+ get: function () { return chunkSDPGVWQJ_cjs.handleTaskSendSubscribe; }
30
+ });
@@ -0,0 +1,6 @@
1
+ export { getAgentCardByIdHandler } from '../../_tsup-dts-rollup.cjs';
2
+ export { handleTaskSend } from '../../_tsup-dts-rollup.cjs';
3
+ export { handleTaskGet } from '../../_tsup-dts-rollup.cjs';
4
+ export { handleTaskSendSubscribe } from '../../_tsup-dts-rollup.cjs';
5
+ export { handleTaskCancel } from '../../_tsup-dts-rollup.cjs';
6
+ export { getAgentExecutionHandler } from '../../_tsup-dts-rollup.cjs';
@@ -0,0 +1,6 @@
1
+ export { getAgentCardByIdHandler } from '../../_tsup-dts-rollup.js';
2
+ export { handleTaskSend } from '../../_tsup-dts-rollup.js';
3
+ export { handleTaskGet } from '../../_tsup-dts-rollup.js';
4
+ export { handleTaskSendSubscribe } from '../../_tsup-dts-rollup.js';
5
+ export { handleTaskCancel } from '../../_tsup-dts-rollup.js';
6
+ export { getAgentExecutionHandler } from '../../_tsup-dts-rollup.js';
@@ -0,0 +1 @@
1
+ export { getAgentCardByIdHandler, getAgentExecutionHandler, handleTaskCancel, handleTaskGet, handleTaskSend, handleTaskSendSubscribe } from '../../chunk-GHC4YV6R.js';
@@ -1,30 +1,30 @@
1
1
  'use strict';
2
2
 
3
- var chunk4BIX6GMY_cjs = require('../../chunk-4BIX6GMY.cjs');
3
+ var chunkBWHGBV3K_cjs = require('../../chunk-BWHGBV3K.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "generateHandler", {
8
8
  enumerable: true,
9
- get: function () { return chunk4BIX6GMY_cjs.generateHandler; }
9
+ get: function () { return chunkBWHGBV3K_cjs.generateHandler; }
10
10
  });
11
11
  Object.defineProperty(exports, "getAgentByIdHandler", {
12
12
  enumerable: true,
13
- get: function () { return chunk4BIX6GMY_cjs.getAgentByIdHandler; }
13
+ get: function () { return chunkBWHGBV3K_cjs.getAgentByIdHandler; }
14
14
  });
15
15
  Object.defineProperty(exports, "getAgentsHandler", {
16
16
  enumerable: true,
17
- get: function () { return chunk4BIX6GMY_cjs.getAgentsHandler; }
17
+ get: function () { return chunkBWHGBV3K_cjs.getAgentsHandler; }
18
18
  });
19
19
  Object.defineProperty(exports, "getEvalsByAgentIdHandler", {
20
20
  enumerable: true,
21
- get: function () { return chunk4BIX6GMY_cjs.getEvalsByAgentIdHandler; }
21
+ get: function () { return chunkBWHGBV3K_cjs.getEvalsByAgentIdHandler; }
22
22
  });
23
23
  Object.defineProperty(exports, "getLiveEvalsByAgentIdHandler", {
24
24
  enumerable: true,
25
- get: function () { return chunk4BIX6GMY_cjs.getLiveEvalsByAgentIdHandler; }
25
+ get: function () { return chunkBWHGBV3K_cjs.getLiveEvalsByAgentIdHandler; }
26
26
  });
27
27
  Object.defineProperty(exports, "streamGenerateHandler", {
28
28
  enumerable: true,
29
- get: function () { return chunk4BIX6GMY_cjs.streamGenerateHandler; }
29
+ get: function () { return chunkBWHGBV3K_cjs.streamGenerateHandler; }
30
30
  });
@@ -1 +1 @@
1
- export { generateHandler, getAgentByIdHandler, getAgentsHandler, getEvalsByAgentIdHandler, getLiveEvalsByAgentIdHandler, streamGenerateHandler } from '../../chunk-Y3SV5XK4.js';
1
+ export { generateHandler, getAgentByIdHandler, getAgentsHandler, getEvalsByAgentIdHandler, getLiveEvalsByAgentIdHandler, streamGenerateHandler } from '../../chunk-4QBIUKVY.js';
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var chunkZLBRQFDD_cjs = require('../../chunk-ZLBRQFDD.cjs');
3
+ var chunkMTR2B27E_cjs = require('../../chunk-MTR2B27E.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "handleError", {
8
8
  enumerable: true,
9
- get: function () { return chunkZLBRQFDD_cjs.handleError; }
9
+ get: function () { return chunkMTR2B27E_cjs.handleError; }
10
10
  });
@@ -1 +1 @@
1
- export { handleError } from '../../chunk-3AHQ5RGN.js';
1
+ export { handleError } from '../../chunk-QDOJJCS4.js';
@@ -0,0 +1,46 @@
1
+ 'use strict';
2
+
3
+ var chunkTGZIR6AK_cjs = require('../../chunk-TGZIR6AK.cjs');
4
+
5
+
6
+
7
+ Object.defineProperty(exports, "createLegacyWorkflowRunHandler", {
8
+ enumerable: true,
9
+ get: function () { return chunkTGZIR6AK_cjs.createLegacyWorkflowRunHandler; }
10
+ });
11
+ Object.defineProperty(exports, "getLegacyWorkflowByIdHandler", {
12
+ enumerable: true,
13
+ get: function () { return chunkTGZIR6AK_cjs.getLegacyWorkflowByIdHandler; }
14
+ });
15
+ Object.defineProperty(exports, "getLegacyWorkflowRunHandler", {
16
+ enumerable: true,
17
+ get: function () { return chunkTGZIR6AK_cjs.getLegacyWorkflowRunHandler; }
18
+ });
19
+ Object.defineProperty(exports, "getLegacyWorkflowRunsHandler", {
20
+ enumerable: true,
21
+ get: function () { return chunkTGZIR6AK_cjs.getLegacyWorkflowRunsHandler; }
22
+ });
23
+ Object.defineProperty(exports, "getLegacyWorkflowsHandler", {
24
+ enumerable: true,
25
+ get: function () { return chunkTGZIR6AK_cjs.getLegacyWorkflowsHandler; }
26
+ });
27
+ Object.defineProperty(exports, "resumeAsyncLegacyWorkflowHandler", {
28
+ enumerable: true,
29
+ get: function () { return chunkTGZIR6AK_cjs.resumeAsyncLegacyWorkflowHandler; }
30
+ });
31
+ Object.defineProperty(exports, "resumeLegacyWorkflowHandler", {
32
+ enumerable: true,
33
+ get: function () { return chunkTGZIR6AK_cjs.resumeLegacyWorkflowHandler; }
34
+ });
35
+ Object.defineProperty(exports, "startAsyncLegacyWorkflowHandler", {
36
+ enumerable: true,
37
+ get: function () { return chunkTGZIR6AK_cjs.startAsyncLegacyWorkflowHandler; }
38
+ });
39
+ Object.defineProperty(exports, "startLegacyWorkflowRunHandler", {
40
+ enumerable: true,
41
+ get: function () { return chunkTGZIR6AK_cjs.startLegacyWorkflowRunHandler; }
42
+ });
43
+ Object.defineProperty(exports, "watchLegacyWorkflowHandler", {
44
+ enumerable: true,
45
+ get: function () { return chunkTGZIR6AK_cjs.watchLegacyWorkflowHandler; }
46
+ });
@@ -0,0 +1,10 @@
1
+ export { getLegacyWorkflowsHandler } from '../../_tsup-dts-rollup.cjs';
2
+ export { getLegacyWorkflowByIdHandler } from '../../_tsup-dts-rollup.cjs';
3
+ export { startAsyncLegacyWorkflowHandler } from '../../_tsup-dts-rollup.cjs';
4
+ export { getLegacyWorkflowRunHandler } from '../../_tsup-dts-rollup.cjs';
5
+ export { createLegacyWorkflowRunHandler } from '../../_tsup-dts-rollup.cjs';
6
+ export { startLegacyWorkflowRunHandler } from '../../_tsup-dts-rollup.cjs';
7
+ export { watchLegacyWorkflowHandler } from '../../_tsup-dts-rollup.cjs';
8
+ export { resumeAsyncLegacyWorkflowHandler } from '../../_tsup-dts-rollup.cjs';
9
+ export { resumeLegacyWorkflowHandler } from '../../_tsup-dts-rollup.cjs';
10
+ export { getLegacyWorkflowRunsHandler } from '../../_tsup-dts-rollup.cjs';
@@ -0,0 +1,10 @@
1
+ export { getLegacyWorkflowsHandler } from '../../_tsup-dts-rollup.js';
2
+ export { getLegacyWorkflowByIdHandler } from '../../_tsup-dts-rollup.js';
3
+ export { startAsyncLegacyWorkflowHandler } from '../../_tsup-dts-rollup.js';
4
+ export { getLegacyWorkflowRunHandler } from '../../_tsup-dts-rollup.js';
5
+ export { createLegacyWorkflowRunHandler } from '../../_tsup-dts-rollup.js';
6
+ export { startLegacyWorkflowRunHandler } from '../../_tsup-dts-rollup.js';
7
+ export { watchLegacyWorkflowHandler } from '../../_tsup-dts-rollup.js';
8
+ export { resumeAsyncLegacyWorkflowHandler } from '../../_tsup-dts-rollup.js';
9
+ export { resumeLegacyWorkflowHandler } from '../../_tsup-dts-rollup.js';
10
+ export { getLegacyWorkflowRunsHandler } from '../../_tsup-dts-rollup.js';
@@ -0,0 +1 @@
1
+ export { createLegacyWorkflowRunHandler, getLegacyWorkflowByIdHandler, getLegacyWorkflowRunHandler, getLegacyWorkflowRunsHandler, getLegacyWorkflowsHandler, resumeAsyncLegacyWorkflowHandler, resumeLegacyWorkflowHandler, startAsyncLegacyWorkflowHandler, startLegacyWorkflowRunHandler, watchLegacyWorkflowHandler } from '../../chunk-7GQJAMTA.js';
@@ -1,18 +1,18 @@
1
1
  'use strict';
2
2
 
3
- var chunkSKBVVI24_cjs = require('../../chunk-SKBVVI24.cjs');
3
+ var chunkCNVDCLSY_cjs = require('../../chunk-CNVDCLSY.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "getLogTransports", {
8
8
  enumerable: true,
9
- get: function () { return chunkSKBVVI24_cjs.getLogTransports; }
9
+ get: function () { return chunkCNVDCLSY_cjs.getLogTransports; }
10
10
  });
11
11
  Object.defineProperty(exports, "getLogsByRunIdHandler", {
12
12
  enumerable: true,
13
- get: function () { return chunkSKBVVI24_cjs.getLogsByRunIdHandler; }
13
+ get: function () { return chunkCNVDCLSY_cjs.getLogsByRunIdHandler; }
14
14
  });
15
15
  Object.defineProperty(exports, "getLogsHandler", {
16
16
  enumerable: true,
17
- get: function () { return chunkSKBVVI24_cjs.getLogsHandler; }
17
+ get: function () { return chunkCNVDCLSY_cjs.getLogsHandler; }
18
18
  });
@@ -1 +1 @@
1
- export { getLogTransports, getLogsByRunIdHandler, getLogsHandler } from '../../chunk-3EJZQ6TQ.js';
1
+ export { getLogTransports, getLogsByRunIdHandler, getLogsHandler } from '../../chunk-BOXE6WSV.js';