@mastra/server 0.10.8 → 0.10.9-alpha.0

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 (55) hide show
  1. package/dist/_tsup-dts-rollup.d.cts +18 -3
  2. package/dist/_tsup-dts-rollup.d.ts +18 -3
  3. package/dist/{chunk-RQ2Z56EC.cjs → chunk-3DKDT264.cjs} +9 -9
  4. package/dist/{chunk-PMUATKV2.js → chunk-4QBIUKVY.js} +3 -3
  5. package/dist/{chunk-TO5U6HW3.cjs → chunk-7524QH7G.cjs} +76 -28
  6. package/dist/{chunk-N2YBMSO2.js → chunk-7GQJAMTA.js} +7 -7
  7. package/dist/{chunk-QLG2PFHE.js → chunk-BOXE6WSV.js} +1 -1
  8. package/dist/{chunk-BFOA2QQY.js → chunk-BP24Z4WG.js} +1 -1
  9. package/dist/{chunk-GKM45O24.cjs → chunk-BWHGBV3K.cjs} +12 -12
  10. package/dist/{chunk-IMBY5XUG.cjs → chunk-CNVDCLSY.cjs} +4 -4
  11. package/dist/{chunk-XR7VJOOP.js → chunk-DFJUGWNU.js} +2 -2
  12. package/dist/{chunk-VPNDC2DI.cjs → chunk-DPRB3R7Y.cjs} +5 -5
  13. package/dist/{chunk-CPPYMJX5.cjs → chunk-FGGMQCPP.cjs} +10 -10
  14. package/dist/{chunk-55DOQLP6.js → chunk-FVMGZKFD.js} +1 -1
  15. package/dist/{chunk-R5VGYBV6.js → chunk-G37NVEDX.js} +1 -1
  16. package/dist/{chunk-WJY57THV.cjs → chunk-L3N7ST2Z.cjs} +5 -5
  17. package/dist/{chunk-MN6F4D5A.cjs → chunk-LI436ITD.cjs} +107 -69
  18. package/dist/{chunk-XUIJ7WRT.js → chunk-LTJNMM2Y.js} +1 -1
  19. package/dist/{chunk-OSZM4EAY.js → chunk-MEGCYGBU.js} +108 -70
  20. package/dist/{chunk-64U3UDTH.cjs → chunk-MTR2B27E.cjs} +2 -1
  21. package/dist/{chunk-M5ABIP7D.js → chunk-QDOJJCS4.js} +2 -1
  22. package/dist/{chunk-4DTDPTQC.cjs → chunk-TGZIR6AK.cjs} +18 -18
  23. package/dist/{chunk-BNEY4P4P.cjs → chunk-TVBPFPTN.cjs} +7 -7
  24. package/dist/{chunk-B4MQFJ7G.cjs → chunk-ULFULEW4.cjs} +2 -2
  25. package/dist/{chunk-C7564HUT.js → chunk-VMXLEF54.js} +1 -1
  26. package/dist/{chunk-SOBBILUG.js → chunk-Z5TH5F35.js} +58 -11
  27. package/dist/server/handlers/agents.cjs +7 -7
  28. package/dist/server/handlers/agents.js +1 -1
  29. package/dist/server/handlers/error.cjs +2 -2
  30. package/dist/server/handlers/error.js +1 -1
  31. package/dist/server/handlers/legacyWorkflows.cjs +11 -11
  32. package/dist/server/handlers/legacyWorkflows.js +1 -1
  33. package/dist/server/handlers/logs.cjs +4 -4
  34. package/dist/server/handlers/logs.js +1 -1
  35. package/dist/server/handlers/memory.cjs +9 -9
  36. package/dist/server/handlers/memory.js +1 -1
  37. package/dist/server/handlers/network.cjs +5 -5
  38. package/dist/server/handlers/network.js +1 -1
  39. package/dist/server/handlers/telemetry.cjs +3 -3
  40. package/dist/server/handlers/telemetry.js +1 -1
  41. package/dist/server/handlers/tools.cjs +5 -5
  42. package/dist/server/handlers/tools.js +1 -1
  43. package/dist/server/handlers/vNextNetwork.cjs +30 -12
  44. package/dist/server/handlers/vNextNetwork.js +20 -2
  45. package/dist/server/handlers/vector.cjs +7 -7
  46. package/dist/server/handlers/vector.js +1 -1
  47. package/dist/server/handlers/voice.cjs +5 -5
  48. package/dist/server/handlers/voice.js +1 -1
  49. package/dist/server/handlers/workflows.cjs +17 -13
  50. package/dist/server/handlers/workflows.d.cts +1 -0
  51. package/dist/server/handlers/workflows.d.ts +1 -0
  52. package/dist/server/handlers/workflows.js +1 -1
  53. package/dist/server/handlers.cjs +20 -20
  54. package/dist/server/handlers.js +10 -10
  55. package/package.json +4 -4
@@ -18,6 +18,7 @@ import { LegacyWorkflowRunResult } from '@mastra/core/workflows/legacy';
18
18
  import type { LegacyWorkflowRuns } from '@mastra/core/storage';
19
19
  import type { LogLevel } from '@mastra/core/logger';
20
20
  import type { Mastra } from '@mastra/core/mastra';
21
+ import type { MastraError } from '@mastra/core/error';
21
22
  import type { MastraMemory } from '@mastra/core/memory';
22
23
  import { MastraMessageV1 } from '@mastra/core/memory';
23
24
  import type { Message } from '@mastra/core/a2a';
@@ -80,13 +81,17 @@ export declare namespace agents {
80
81
  }
81
82
  }
82
83
 
83
- export declare interface ApiError extends Error {
84
+ export declare interface ApiError extends MastraError {
84
85
  message: string;
85
86
  status?: number;
86
87
  }
87
88
 
88
89
  export declare function applyUpdateToTaskAndHistory(current: TaskAndHistory, update: Omit<TaskStatus, 'timestamp'> | Artifact): TaskAndHistory;
89
90
 
91
+ export declare function cancelWorkflowRunHandler({ mastra, workflowId, runId, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'>): Promise<{
92
+ message: string;
93
+ }>;
94
+
90
95
  declare type ClientErrorStatusCode = 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451;
91
96
 
92
97
  export declare interface Context {
@@ -402,6 +407,10 @@ export declare function getVNextNetworkByIdHandler({ mastra, networkId, runtimeC
402
407
  inputSchema: string | undefined;
403
408
  outputSchema: string | undefined;
404
409
  }[];
410
+ tools: {
411
+ id: string;
412
+ description: string;
413
+ }[];
405
414
  routingModel: {
406
415
  provider: string;
407
416
  modelId: string;
@@ -412,6 +421,10 @@ export declare function getVNextNetworksHandler({ mastra, runtimeContext, }: Pic
412
421
  id: string;
413
422
  name: string;
414
423
  instructions: string;
424
+ tools: {
425
+ id: string;
426
+ description: string;
427
+ }[];
415
428
  agents: {
416
429
  name: string;
417
430
  provider: string;
@@ -430,7 +443,8 @@ export declare function getVNextNetworksHandler({ mastra, runtimeContext, }: Pic
430
443
  }[]>;
431
444
 
432
445
  export declare function getWorkflowByIdHandler({ mastra, workflowId }: WorkflowContext_3): Promise<{
433
- steps: SerializedStep[];
446
+ steps: Record<string, SerializedStep>;
447
+ allSteps: Record<string, SerializedStep>;
434
448
  name: string | undefined;
435
449
  description: string | undefined;
436
450
  stepGraph: SerializedStepFlowEntry[];
@@ -1046,7 +1060,8 @@ export declare namespace workflows {
1046
1060
  streamWorkflowHandler,
1047
1061
  resumeAsyncWorkflowHandler,
1048
1062
  resumeWorkflowHandler,
1049
- getWorkflowRunsHandler
1063
+ getWorkflowRunsHandler,
1064
+ cancelWorkflowRunHandler
1050
1065
  }
1051
1066
  }
1052
1067
 
@@ -18,6 +18,7 @@ import { LegacyWorkflowRunResult } from '@mastra/core/workflows/legacy';
18
18
  import type { LegacyWorkflowRuns } from '@mastra/core/storage';
19
19
  import type { LogLevel } from '@mastra/core/logger';
20
20
  import type { Mastra } from '@mastra/core/mastra';
21
+ import type { MastraError } from '@mastra/core/error';
21
22
  import type { MastraMemory } from '@mastra/core/memory';
22
23
  import { MastraMessageV1 } from '@mastra/core/memory';
23
24
  import type { Message } from '@mastra/core/a2a';
@@ -80,13 +81,17 @@ export declare namespace agents {
80
81
  }
81
82
  }
82
83
 
83
- export declare interface ApiError extends Error {
84
+ export declare interface ApiError extends MastraError {
84
85
  message: string;
85
86
  status?: number;
86
87
  }
87
88
 
88
89
  export declare function applyUpdateToTaskAndHistory(current: TaskAndHistory, update: Omit<TaskStatus, 'timestamp'> | Artifact): TaskAndHistory;
89
90
 
91
+ export declare function cancelWorkflowRunHandler({ mastra, workflowId, runId, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'>): Promise<{
92
+ message: string;
93
+ }>;
94
+
90
95
  declare type ClientErrorStatusCode = 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451;
91
96
 
92
97
  export declare interface Context {
@@ -402,6 +407,10 @@ export declare function getVNextNetworkByIdHandler({ mastra, networkId, runtimeC
402
407
  inputSchema: string | undefined;
403
408
  outputSchema: string | undefined;
404
409
  }[];
410
+ tools: {
411
+ id: string;
412
+ description: string;
413
+ }[];
405
414
  routingModel: {
406
415
  provider: string;
407
416
  modelId: string;
@@ -412,6 +421,10 @@ export declare function getVNextNetworksHandler({ mastra, runtimeContext, }: Pic
412
421
  id: string;
413
422
  name: string;
414
423
  instructions: string;
424
+ tools: {
425
+ id: string;
426
+ description: string;
427
+ }[];
415
428
  agents: {
416
429
  name: string;
417
430
  provider: string;
@@ -430,7 +443,8 @@ export declare function getVNextNetworksHandler({ mastra, runtimeContext, }: Pic
430
443
  }[]>;
431
444
 
432
445
  export declare function getWorkflowByIdHandler({ mastra, workflowId }: WorkflowContext_3): Promise<{
433
- steps: SerializedStep[];
446
+ steps: Record<string, SerializedStep>;
447
+ allSteps: Record<string, SerializedStep>;
434
448
  name: string | undefined;
435
449
  description: string | undefined;
436
450
  stepGraph: SerializedStepFlowEntry[];
@@ -1046,7 +1060,8 @@ export declare namespace workflows {
1046
1060
  streamWorkflowHandler,
1047
1061
  resumeAsyncWorkflowHandler,
1048
1062
  resumeWorkflowHandler,
1049
- getWorkflowRunsHandler
1063
+ getWorkflowRunsHandler,
1064
+ cancelWorkflowRunHandler
1050
1065
  }
1051
1066
  }
1052
1067
 
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var chunk57CJTIPW_cjs = require('./chunk-57CJTIPW.cjs');
4
- var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
4
+ var chunkMTR2B27E_cjs = require('./chunk-MTR2B27E.cjs');
5
5
  var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
6
6
  var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
7
7
 
@@ -52,7 +52,7 @@ async function getMemoryStatusHandler({
52
52
  }
53
53
  return { result: true };
54
54
  } catch (error) {
55
- return chunk64U3UDTH_cjs.handleError(error, "Error getting memory status");
55
+ return chunkMTR2B27E_cjs.handleError(error, "Error getting memory status");
56
56
  }
57
57
  }
58
58
  async function getThreadsHandler({
@@ -71,7 +71,7 @@ async function getThreadsHandler({
71
71
  const threads = await memory.getThreadsByResourceId({ resourceId });
72
72
  return threads;
73
73
  } catch (error) {
74
- return chunk64U3UDTH_cjs.handleError(error, "Error getting threads");
74
+ return chunkMTR2B27E_cjs.handleError(error, "Error getting threads");
75
75
  }
76
76
  }
77
77
  async function getThreadByIdHandler({
@@ -93,7 +93,7 @@ async function getThreadByIdHandler({
93
93
  }
94
94
  return thread;
95
95
  } catch (error) {
96
- return chunk64U3UDTH_cjs.handleError(error, "Error getting thread");
96
+ return chunkMTR2B27E_cjs.handleError(error, "Error getting thread");
97
97
  }
98
98
  }
99
99
  async function saveMessagesHandler({
@@ -122,7 +122,7 @@ async function saveMessagesHandler({
122
122
  const result = await memory.saveMessages({ messages: processedMessages, memoryConfig: {} });
123
123
  return result;
124
124
  } catch (error) {
125
- return chunk64U3UDTH_cjs.handleError(error, "Error saving messages");
125
+ return chunkMTR2B27E_cjs.handleError(error, "Error saving messages");
126
126
  }
127
127
  }
128
128
  async function createThreadHandler({
@@ -146,7 +146,7 @@ async function createThreadHandler({
146
146
  });
147
147
  return result;
148
148
  } catch (error) {
149
- return chunk64U3UDTH_cjs.handleError(error, "Error saving thread to memory");
149
+ return chunkMTR2B27E_cjs.handleError(error, "Error saving thread to memory");
150
150
  }
151
151
  }
152
152
  async function updateThreadHandler({
@@ -183,7 +183,7 @@ async function updateThreadHandler({
183
183
  const result = await memory.saveThread({ thread: updatedThread });
184
184
  return result;
185
185
  } catch (error) {
186
- return chunk64U3UDTH_cjs.handleError(error, "Error updating thread");
186
+ return chunkMTR2B27E_cjs.handleError(error, "Error updating thread");
187
187
  }
188
188
  }
189
189
  async function deleteThreadHandler({
@@ -206,7 +206,7 @@ async function deleteThreadHandler({
206
206
  await memory.deleteThread(threadId);
207
207
  return { result: "Thread deleted" };
208
208
  } catch (error) {
209
- return chunk64U3UDTH_cjs.handleError(error, "Error deleting thread");
209
+ return chunkMTR2B27E_cjs.handleError(error, "Error deleting thread");
210
210
  }
211
211
  }
212
212
  async function getMessagesHandler({
@@ -236,7 +236,7 @@ async function getMessagesHandler({
236
236
  });
237
237
  return { messages: result.messages, uiMessages: result.uiMessages };
238
238
  } catch (error) {
239
- return chunk64U3UDTH_cjs.handleError(error, "Error getting messages");
239
+ return chunkMTR2B27E_cjs.handleError(error, "Error getting messages");
240
240
  }
241
241
  }
242
242
 
@@ -1,6 +1,6 @@
1
- import { stringify, esm_default } from './chunk-OSZM4EAY.js';
1
+ import { stringify, esm_default } from './chunk-MEGCYGBU.js';
2
2
  import { validateBody } from './chunk-H5PTF3Y4.js';
3
- import { handleError } from './chunk-M5ABIP7D.js';
3
+ import { handleError } from './chunk-QDOJJCS4.js';
4
4
  import { HTTPException } from './chunk-NYN7KFXL.js';
5
5
  import { __export } from './chunk-MLKGABMK.js';
6
6
  import { RuntimeContext } from '@mastra/core/runtime-context';
@@ -263,7 +263,7 @@ async function streamGenerateHandler({
263
263
  });
264
264
  return streamResponse;
265
265
  } catch (error) {
266
- throw new HTTPException(error?.status ?? 500, { message: error?.message ?? "Error streaming from agent" });
266
+ return handleError(error, "error streaming agent response");
267
267
  }
268
268
  }
269
269
 
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkMN6F4D5A_cjs = require('./chunk-MN6F4D5A.cjs');
4
- var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
3
+ var chunkLI436ITD_cjs = require('./chunk-LI436ITD.cjs');
4
+ var chunkMTR2B27E_cjs = require('./chunk-MTR2B27E.cjs');
5
5
  var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
6
6
  var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
7
7
  var web = require('stream/web');
@@ -9,6 +9,7 @@ var web = require('stream/web');
9
9
  // src/server/handlers/workflows.ts
10
10
  var workflows_exports = {};
11
11
  chunk75ZPJI57_cjs.__export(workflows_exports, {
12
+ cancelWorkflowRunHandler: () => cancelWorkflowRunHandler,
12
13
  createWorkflowRunHandler: () => createWorkflowRunHandler,
13
14
  getWorkflowByIdHandler: () => getWorkflowByIdHandler,
14
15
  getWorkflowRunByIdHandler: () => getWorkflowRunByIdHandler,
@@ -22,6 +23,25 @@ chunk75ZPJI57_cjs.__export(workflows_exports, {
22
23
  streamWorkflowHandler: () => streamWorkflowHandler,
23
24
  watchWorkflowHandler: () => watchWorkflowHandler
24
25
  });
26
+ function getSteps(steps, path) {
27
+ return Object.entries(steps).reduce((acc, [key, step]) => {
28
+ const fullKey = path ? `${path}.${key}` : key;
29
+ acc[fullKey] = {
30
+ id: step.id,
31
+ description: step.description,
32
+ inputSchema: step.inputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(step.inputSchema)) : void 0,
33
+ outputSchema: step.outputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(step.outputSchema)) : void 0,
34
+ resumeSchema: step.resumeSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(step.resumeSchema)) : void 0,
35
+ suspendSchema: step.suspendSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(step.suspendSchema)) : void 0,
36
+ isWorkflow: step.component === "WORKFLOW"
37
+ };
38
+ if (step.component === "WORKFLOW" && step.steps) {
39
+ const nestedSteps = getSteps(step.steps, fullKey) || {};
40
+ acc = { ...acc, ...nestedSteps };
41
+ }
42
+ return acc;
43
+ }, {});
44
+ }
25
45
  async function getWorkflowsHandler({ mastra }) {
26
46
  try {
27
47
  const workflows = mastra.getWorkflows({ serialized: false });
@@ -33,22 +53,23 @@ async function getWorkflowsHandler({ mastra }) {
33
53
  acc2[key2] = {
34
54
  id: step.id,
35
55
  description: step.description,
36
- inputSchema: step.inputSchema ? chunkMN6F4D5A_cjs.stringify(chunkMN6F4D5A_cjs.esm_default(step.inputSchema)) : void 0,
37
- outputSchema: step.outputSchema ? chunkMN6F4D5A_cjs.stringify(chunkMN6F4D5A_cjs.esm_default(step.outputSchema)) : void 0,
38
- resumeSchema: step.resumeSchema ? chunkMN6F4D5A_cjs.stringify(chunkMN6F4D5A_cjs.esm_default(step.resumeSchema)) : void 0,
39
- suspendSchema: step.suspendSchema ? chunkMN6F4D5A_cjs.stringify(chunkMN6F4D5A_cjs.esm_default(step.suspendSchema)) : void 0
56
+ inputSchema: step.inputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(step.inputSchema)) : void 0,
57
+ outputSchema: step.outputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(step.outputSchema)) : void 0,
58
+ resumeSchema: step.resumeSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(step.resumeSchema)) : void 0,
59
+ suspendSchema: step.suspendSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(step.suspendSchema)) : void 0
40
60
  };
41
61
  return acc2;
42
62
  }, {}),
63
+ allSteps: getSteps(workflow.steps) || {},
43
64
  stepGraph: workflow.serializedStepGraph,
44
- inputSchema: workflow.inputSchema ? chunkMN6F4D5A_cjs.stringify(chunkMN6F4D5A_cjs.esm_default(workflow.inputSchema)) : void 0,
45
- outputSchema: workflow.outputSchema ? chunkMN6F4D5A_cjs.stringify(chunkMN6F4D5A_cjs.esm_default(workflow.outputSchema)) : void 0
65
+ inputSchema: workflow.inputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(workflow.inputSchema)) : void 0,
66
+ outputSchema: workflow.outputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(workflow.outputSchema)) : void 0
46
67
  };
47
68
  return acc;
48
69
  }, {});
49
70
  return _workflows;
50
71
  } catch (error) {
51
- throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflows" });
72
+ return chunkMTR2B27E_cjs.handleError(error, "Error getting workflows");
52
73
  }
53
74
  }
54
75
  async function getWorkflowsFromSystem({ mastra, workflowId }) {
@@ -99,21 +120,22 @@ async function getWorkflowByIdHandler({ mastra, workflowId }) {
99
120
  acc[key] = {
100
121
  id: step.id,
101
122
  description: step.description,
102
- inputSchema: step.inputSchema ? chunkMN6F4D5A_cjs.stringify(chunkMN6F4D5A_cjs.esm_default(step.inputSchema)) : void 0,
103
- outputSchema: step.outputSchema ? chunkMN6F4D5A_cjs.stringify(chunkMN6F4D5A_cjs.esm_default(step.outputSchema)) : void 0,
104
- resumeSchema: step.resumeSchema ? chunkMN6F4D5A_cjs.stringify(chunkMN6F4D5A_cjs.esm_default(step.resumeSchema)) : void 0,
105
- suspendSchema: step.suspendSchema ? chunkMN6F4D5A_cjs.stringify(chunkMN6F4D5A_cjs.esm_default(step.suspendSchema)) : void 0
123
+ inputSchema: step.inputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(step.inputSchema)) : void 0,
124
+ outputSchema: step.outputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(step.outputSchema)) : void 0,
125
+ resumeSchema: step.resumeSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(step.resumeSchema)) : void 0,
126
+ suspendSchema: step.suspendSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(step.suspendSchema)) : void 0
106
127
  };
107
128
  return acc;
108
129
  }, {}),
130
+ allSteps: getSteps(workflow.steps) || {},
109
131
  name: workflow.name,
110
132
  description: workflow.description,
111
133
  stepGraph: workflow.serializedStepGraph,
112
- inputSchema: workflow.inputSchema ? chunkMN6F4D5A_cjs.stringify(chunkMN6F4D5A_cjs.esm_default(workflow.inputSchema)) : void 0,
113
- outputSchema: workflow.outputSchema ? chunkMN6F4D5A_cjs.stringify(chunkMN6F4D5A_cjs.esm_default(workflow.outputSchema)) : void 0
134
+ inputSchema: workflow.inputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(workflow.inputSchema)) : void 0,
135
+ outputSchema: workflow.outputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(workflow.outputSchema)) : void 0
114
136
  };
115
137
  } catch (error) {
116
- throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflow" });
138
+ return chunkMTR2B27E_cjs.handleError(error, "Error getting workflow");
117
139
  }
118
140
  }
119
141
  async function getWorkflowRunByIdHandler({
@@ -138,7 +160,7 @@ async function getWorkflowRunByIdHandler({
138
160
  }
139
161
  return run;
140
162
  } catch (error) {
141
- throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflow run" });
163
+ return chunkMTR2B27E_cjs.handleError(error, "Error getting workflow run");
142
164
  }
143
165
  }
144
166
  async function getWorkflowRunExecutionResultHandler({
@@ -163,9 +185,7 @@ async function getWorkflowRunExecutionResultHandler({
163
185
  }
164
186
  return executionResult;
165
187
  } catch (error) {
166
- throw new chunkOCWPVYNI_cjs.HTTPException(500, {
167
- message: error?.message || "Error getting workflow run execution result"
168
- });
188
+ return chunkMTR2B27E_cjs.handleError(error, "Error getting workflow run execution result");
169
189
  }
170
190
  }
171
191
  async function createWorkflowRunHandler({
@@ -184,7 +204,7 @@ async function createWorkflowRunHandler({
184
204
  const run = await workflow.createRunAsync({ runId: prevRunId });
185
205
  return { runId: run.runId };
186
206
  } catch (error) {
187
- throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error creating workflow run" });
207
+ return chunkMTR2B27E_cjs.handleError(error, "Error creating workflow run");
188
208
  }
189
209
  }
190
210
  async function startAsyncWorkflowHandler({
@@ -209,7 +229,7 @@ async function startAsyncWorkflowHandler({
209
229
  });
210
230
  return result;
211
231
  } catch (error) {
212
- throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error executing workflow" });
232
+ return chunkMTR2B27E_cjs.handleError(error, "Error starting async workflow");
213
233
  }
214
234
  }
215
235
  async function startWorkflowRunHandler({
@@ -241,7 +261,7 @@ async function startWorkflowRunHandler({
241
261
  });
242
262
  return { message: "Workflow run started" };
243
263
  } catch (e) {
244
- return chunk64U3UDTH_cjs.handleError(e, "Error starting workflow run");
264
+ return chunkMTR2B27E_cjs.handleError(e, "Error starting workflow run");
245
265
  }
246
266
  }
247
267
  async function watchWorkflowHandler({
@@ -290,7 +310,7 @@ async function watchWorkflowHandler({
290
310
  });
291
311
  return stream;
292
312
  } catch (error) {
293
- return chunk64U3UDTH_cjs.handleError(error, "Error watching workflow");
313
+ return chunkMTR2B27E_cjs.handleError(error, "Error watching workflow");
294
314
  }
295
315
  }
296
316
  async function streamWorkflowHandler({
@@ -318,7 +338,7 @@ async function streamWorkflowHandler({
318
338
  });
319
339
  return result;
320
340
  } catch (error) {
321
- return chunk64U3UDTH_cjs.handleError(error, "Error executing workflow");
341
+ return chunkMTR2B27E_cjs.handleError(error, "Error executing workflow");
322
342
  }
323
343
  }
324
344
  async function resumeAsyncWorkflowHandler({
@@ -354,7 +374,7 @@ async function resumeAsyncWorkflowHandler({
354
374
  });
355
375
  return result;
356
376
  } catch (error) {
357
- return chunk64U3UDTH_cjs.handleError(error, "Error resuming workflow step");
377
+ return chunkMTR2B27E_cjs.handleError(error, "Error resuming workflow step");
358
378
  }
359
379
  }
360
380
  async function resumeWorkflowHandler({
@@ -390,7 +410,7 @@ async function resumeWorkflowHandler({
390
410
  });
391
411
  return { message: "Workflow run resumed" };
392
412
  } catch (error) {
393
- return chunk64U3UDTH_cjs.handleError(error, "Error resuming workflow");
413
+ return chunkMTR2B27E_cjs.handleError(error, "Error resuming workflow");
394
414
  }
395
415
  }
396
416
  async function getWorkflowRunsHandler({
@@ -416,10 +436,38 @@ async function getWorkflowRunsHandler({
416
436
  };
417
437
  return workflowRuns;
418
438
  } catch (error) {
419
- return chunk64U3UDTH_cjs.handleError(error, "Error getting workflow runs");
439
+ return chunkMTR2B27E_cjs.handleError(error, "Error getting workflow runs");
440
+ }
441
+ }
442
+ async function cancelWorkflowRunHandler({
443
+ mastra,
444
+ workflowId,
445
+ runId
446
+ }) {
447
+ try {
448
+ if (!workflowId) {
449
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
450
+ }
451
+ if (!runId) {
452
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to cancel workflow run" });
453
+ }
454
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
455
+ if (!workflow) {
456
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
457
+ }
458
+ const run = await workflow.getWorkflowRunById(runId);
459
+ if (!run) {
460
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
461
+ }
462
+ const _run = await workflow.createRunAsync({ runId });
463
+ await _run.cancel();
464
+ return { message: "Workflow run cancelled" };
465
+ } catch (error) {
466
+ return chunkMTR2B27E_cjs.handleError(error, "Error canceling workflow run");
420
467
  }
421
468
  }
422
469
 
470
+ exports.cancelWorkflowRunHandler = cancelWorkflowRunHandler;
423
471
  exports.createWorkflowRunHandler = createWorkflowRunHandler;
424
472
  exports.getWorkflowByIdHandler = getWorkflowByIdHandler;
425
473
  exports.getWorkflowRunByIdHandler = getWorkflowRunByIdHandler;
@@ -1,5 +1,5 @@
1
- import { stringify, esm_default } from './chunk-OSZM4EAY.js';
2
- import { handleError } from './chunk-M5ABIP7D.js';
1
+ import { stringify, esm_default } from './chunk-MEGCYGBU.js';
2
+ import { handleError } from './chunk-QDOJJCS4.js';
3
3
  import { HTTPException } from './chunk-NYN7KFXL.js';
4
4
  import { __export } from './chunk-MLKGABMK.js';
5
5
  import { ReadableStream } from 'stream/web';
@@ -46,7 +46,7 @@ async function getLegacyWorkflowsHandler({ mastra }) {
46
46
  }, {});
47
47
  return _workflows;
48
48
  } catch (error) {
49
- throw new HTTPException(500, { message: error?.message || "Error getting workflows" });
49
+ return handleError(error, "error getting workflows");
50
50
  }
51
51
  }
52
52
  async function getLegacyWorkflowByIdHandler({ mastra, workflowId }) {
@@ -78,7 +78,7 @@ async function getLegacyWorkflowByIdHandler({ mastra, workflowId }) {
78
78
  }, {})
79
79
  };
80
80
  } catch (error) {
81
- throw new HTTPException(500, { message: error?.message || "Error getting workflow" });
81
+ return handleError(error, "error getting workflow by id");
82
82
  }
83
83
  }
84
84
  async function startAsyncLegacyWorkflowHandler({
@@ -114,7 +114,7 @@ async function startAsyncLegacyWorkflowHandler({
114
114
  });
115
115
  return result;
116
116
  } catch (error) {
117
- throw new HTTPException(500, { message: error?.message || "Error executing workflow" });
117
+ return handleError(error, "error starting workflow");
118
118
  }
119
119
  }
120
120
  async function getLegacyWorkflowRunHandler({
@@ -139,7 +139,7 @@ async function getLegacyWorkflowRunHandler({
139
139
  }
140
140
  return run;
141
141
  } catch (error) {
142
- throw new HTTPException(500, { message: error?.message || "Error getting workflow run" });
142
+ return handleError(error, "error getting workflow run");
143
143
  }
144
144
  }
145
145
  async function createLegacyWorkflowRunHandler({
@@ -158,7 +158,7 @@ async function createLegacyWorkflowRunHandler({
158
158
  const newRun = workflow.createRun({ runId: prevRunId });
159
159
  return { runId: newRun.runId };
160
160
  } catch (error) {
161
- throw new HTTPException(500, { message: error?.message || "Error creating workflow run" });
161
+ return handleError(error, "error creating workflow run");
162
162
  }
163
163
  }
164
164
  async function startLegacyWorkflowRunHandler({
@@ -1,5 +1,5 @@
1
1
  import { validateBody } from './chunk-H5PTF3Y4.js';
2
- import { handleError } from './chunk-M5ABIP7D.js';
2
+ import { handleError } from './chunk-QDOJJCS4.js';
3
3
  import { __export } from './chunk-MLKGABMK.js';
4
4
 
5
5
  // src/server/handlers/logs.ts
@@ -1,4 +1,4 @@
1
- import { handleError } from './chunk-M5ABIP7D.js';
1
+ import { handleError } from './chunk-QDOJJCS4.js';
2
2
  import { HTTPException } from './chunk-NYN7KFXL.js';
3
3
  import { __export } from './chunk-MLKGABMK.js';
4
4
 
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunkMN6F4D5A_cjs = require('./chunk-MN6F4D5A.cjs');
3
+ var chunkLI436ITD_cjs = require('./chunk-LI436ITD.cjs');
4
4
  var chunk57CJTIPW_cjs = require('./chunk-57CJTIPW.cjs');
5
- var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
5
+ var chunkMTR2B27E_cjs = require('./chunk-MTR2B27E.cjs');
6
6
  var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
7
7
  var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
8
8
  var runtimeContext = require('@mastra/core/runtime-context');
@@ -31,8 +31,8 @@ async function getAgentsHandler({ mastra, runtimeContext }) {
31
31
  const _tool = tool;
32
32
  acc[key] = {
33
33
  ..._tool,
34
- inputSchema: _tool.inputSchema ? chunkMN6F4D5A_cjs.stringify(chunkMN6F4D5A_cjs.esm_default(_tool.inputSchema)) : void 0,
35
- outputSchema: _tool.outputSchema ? chunkMN6F4D5A_cjs.stringify(chunkMN6F4D5A_cjs.esm_default(_tool.outputSchema)) : void 0
34
+ inputSchema: _tool.inputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(_tool.inputSchema)) : void 0,
35
+ outputSchema: _tool.outputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(_tool.outputSchema)) : void 0
36
36
  };
37
37
  return acc;
38
38
  }, {});
@@ -72,7 +72,7 @@ async function getAgentsHandler({ mastra, runtimeContext }) {
72
72
  }, {});
73
73
  return serializedAgents;
74
74
  } catch (error) {
75
- return chunk64U3UDTH_cjs.handleError(error, "Error getting agents");
75
+ return chunkMTR2B27E_cjs.handleError(error, "Error getting agents");
76
76
  }
77
77
  }
78
78
  async function getAgentByIdHandler({
@@ -91,8 +91,8 @@ async function getAgentByIdHandler({
91
91
  const _tool = tool;
92
92
  acc[key] = {
93
93
  ..._tool,
94
- inputSchema: _tool.inputSchema ? chunkMN6F4D5A_cjs.stringify(chunkMN6F4D5A_cjs.esm_default(_tool.inputSchema)) : void 0,
95
- outputSchema: _tool.outputSchema ? chunkMN6F4D5A_cjs.stringify(chunkMN6F4D5A_cjs.esm_default(_tool.outputSchema)) : void 0
94
+ inputSchema: _tool.inputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(_tool.inputSchema)) : void 0,
95
+ outputSchema: _tool.outputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(_tool.outputSchema)) : void 0
96
96
  };
97
97
  return acc;
98
98
  }, {});
@@ -151,7 +151,7 @@ async function getAgentByIdHandler({
151
151
  defaultStreamOptions
152
152
  };
153
153
  } catch (error) {
154
- return chunk64U3UDTH_cjs.handleError(error, "Error getting agent");
154
+ return chunkMTR2B27E_cjs.handleError(error, "Error getting agent");
155
155
  }
156
156
  }
157
157
  async function getEvalsByAgentIdHandler({
@@ -170,7 +170,7 @@ async function getEvalsByAgentIdHandler({
170
170
  evals
171
171
  };
172
172
  } catch (error) {
173
- return chunk64U3UDTH_cjs.handleError(error, "Error getting test evals");
173
+ return chunkMTR2B27E_cjs.handleError(error, "Error getting test evals");
174
174
  }
175
175
  }
176
176
  async function getLiveEvalsByAgentIdHandler({
@@ -189,7 +189,7 @@ async function getLiveEvalsByAgentIdHandler({
189
189
  evals
190
190
  };
191
191
  } catch (error) {
192
- return chunk64U3UDTH_cjs.handleError(error, "Error getting live evals");
192
+ return chunkMTR2B27E_cjs.handleError(error, "Error getting live evals");
193
193
  }
194
194
  }
195
195
  async function generateHandler({
@@ -220,7 +220,7 @@ async function generateHandler({
220
220
  });
221
221
  return result;
222
222
  } catch (error) {
223
- return chunk64U3UDTH_cjs.handleError(error, "Error generating from agent");
223
+ return chunkMTR2B27E_cjs.handleError(error, "Error generating from agent");
224
224
  }
225
225
  }
226
226
  async function streamGenerateHandler({
@@ -265,7 +265,7 @@ async function streamGenerateHandler({
265
265
  });
266
266
  return streamResponse;
267
267
  } catch (error) {
268
- throw new chunkOCWPVYNI_cjs.HTTPException(error?.status ?? 500, { message: error?.message ?? "Error streaming from agent" });
268
+ return chunkMTR2B27E_cjs.handleError(error, "error streaming agent response");
269
269
  }
270
270
  }
271
271
 
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var chunk57CJTIPW_cjs = require('./chunk-57CJTIPW.cjs');
4
- var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
4
+ var chunkMTR2B27E_cjs = require('./chunk-MTR2B27E.cjs');
5
5
  var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
6
6
 
7
7
  // src/server/handlers/logs.ts
@@ -35,7 +35,7 @@ async function getLogsHandler({
35
35
  });
36
36
  return logs;
37
37
  } catch (error) {
38
- return chunk64U3UDTH_cjs.handleError(error, "Error getting logs");
38
+ return chunkMTR2B27E_cjs.handleError(error, "Error getting logs");
39
39
  }
40
40
  }
41
41
  async function getLogsByRunIdHandler({
@@ -65,7 +65,7 @@ async function getLogsByRunIdHandler({
65
65
  });
66
66
  return logs;
67
67
  } catch (error) {
68
- return chunk64U3UDTH_cjs.handleError(error, "Error getting logs by run ID");
68
+ return chunkMTR2B27E_cjs.handleError(error, "Error getting logs by run ID");
69
69
  }
70
70
  }
71
71
  async function getLogTransports({ mastra }) {
@@ -76,7 +76,7 @@ async function getLogTransports({ mastra }) {
76
76
  transports: transports ? [...transports.keys()] : []
77
77
  };
78
78
  } catch (error) {
79
- return chunk64U3UDTH_cjs.handleError(error, "Error getting log Transports");
79
+ return chunkMTR2B27E_cjs.handleError(error, "Error getting log Transports");
80
80
  }
81
81
  }
82
82
 
@@ -1,6 +1,6 @@
1
- import { stringify, esm_default } from './chunk-OSZM4EAY.js';
1
+ import { stringify, esm_default } from './chunk-MEGCYGBU.js';
2
2
  import { validateBody } from './chunk-H5PTF3Y4.js';
3
- import { handleError } from './chunk-M5ABIP7D.js';
3
+ import { handleError } from './chunk-QDOJJCS4.js';
4
4
  import { HTTPException } from './chunk-NYN7KFXL.js';
5
5
  import { __export } from './chunk-MLKGABMK.js';
6
6
  import { isVercelTool } from '@mastra/core/tools';