@mastra/server 0.0.0-fix-generate-title-20250616171351 → 0.0.0-fix-fetch-workflow-runs-20250624231457

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 (35) hide show
  1. package/dist/_tsup-dts-rollup.d.cts +162 -22
  2. package/dist/_tsup-dts-rollup.d.ts +162 -22
  3. package/dist/{chunk-WE32JG64.cjs → chunk-4DTDPTQC.cjs} +7 -7
  4. package/dist/{chunk-NGURCFEJ.cjs → chunk-CPPYMJX5.cjs} +5 -5
  5. package/dist/{chunk-C75ZRJKD.cjs → chunk-GKM45O24.cjs} +21 -13
  6. package/dist/{chunk-ASKESBJW.cjs → chunk-MN6F4D5A.cjs} +35 -35
  7. package/dist/{chunk-CLYX4KLH.js → chunk-N2YBMSO2.js} +1 -1
  8. package/dist/{chunk-TGJMNUYJ.js → chunk-OSZM4EAY.js} +35 -35
  9. package/dist/{chunk-4O23XCE5.js → chunk-PMUATKV2.js} +17 -9
  10. package/dist/{chunk-CP55EVBK.js → chunk-R5VGYBV6.js} +12 -8
  11. package/dist/{chunk-6TJSHFCJ.cjs → chunk-RQ2Z56EC.cjs} +50 -20
  12. package/dist/{chunk-JKTNRUKY.js → chunk-SOBBILUG.js} +13 -49
  13. package/dist/{chunk-FRXZL32L.cjs → chunk-TO5U6HW3.cjs} +25 -61
  14. package/dist/{chunk-CMMOIUFC.cjs → chunk-WJY57THV.cjs} +12 -8
  15. package/dist/{chunk-2HXKRRNS.js → chunk-XR7VJOOP.js} +1 -1
  16. package/dist/{chunk-I7KJZNX5.js → chunk-XUIJ7WRT.js} +50 -20
  17. package/dist/server/handlers/agents.cjs +7 -7
  18. package/dist/server/handlers/agents.js +1 -1
  19. package/dist/server/handlers/legacyWorkflows.cjs +11 -11
  20. package/dist/server/handlers/legacyWorkflows.js +1 -1
  21. package/dist/server/handlers/memory.cjs +9 -9
  22. package/dist/server/handlers/memory.js +1 -1
  23. package/dist/server/handlers/tools.cjs +5 -5
  24. package/dist/server/handlers/tools.js +1 -1
  25. package/dist/server/handlers/vNextNetwork.cjs +175 -0
  26. package/dist/server/handlers/vNextNetwork.d.cts +5 -0
  27. package/dist/server/handlers/vNextNetwork.d.ts +5 -0
  28. package/dist/server/handlers/vNextNetwork.js +169 -0
  29. package/dist/server/handlers/voice.cjs +5 -5
  30. package/dist/server/handlers/voice.js +1 -1
  31. package/dist/server/handlers/workflows.cjs +13 -13
  32. package/dist/server/handlers/workflows.js +1 -1
  33. package/dist/server/handlers.cjs +12 -12
  34. package/dist/server/handlers.js +6 -6
  35. package/package.json +6 -6
@@ -1,4 +1,4 @@
1
- import { stringify, esm_default } from './chunk-TGJMNUYJ.js';
1
+ import { stringify, esm_default } from './chunk-OSZM4EAY.js';
2
2
  import { validateBody } from './chunk-H5PTF3Y4.js';
3
3
  import { handleError } from './chunk-M5ABIP7D.js';
4
4
  import { HTTPException } from './chunk-NYN7KFXL.js';
@@ -23,6 +23,8 @@ async function getAgentsHandler({ mastra, runtimeContext }) {
23
23
  const instructions = await agent.getInstructions({ runtimeContext });
24
24
  const tools = await agent.getTools({ runtimeContext });
25
25
  const llm = await agent.getLLM({ runtimeContext });
26
+ const defaultGenerateOptions = await agent.getDefaultGenerateOptions({ runtimeContext });
27
+ const defaultStreamOptions = await agent.getDefaultStreamOptions({ runtimeContext });
26
28
  const serializedAgentTools = Object.entries(tools || {}).reduce((acc, [key, tool]) => {
27
29
  const _tool = tool;
28
30
  acc[key] = {
@@ -57,8 +59,8 @@ async function getAgentsHandler({ mastra, runtimeContext }) {
57
59
  workflows: serializedAgentWorkflows,
58
60
  provider: llm?.getProvider(),
59
61
  modelId: llm?.getModelId(),
60
- defaultGenerateOptions: agent.getDefaultGenerateOptions(),
61
- defaultStreamOptions: agent.getDefaultStreamOptions()
62
+ defaultGenerateOptions,
63
+ defaultStreamOptions
62
64
  };
63
65
  })
64
66
  );
@@ -134,6 +136,8 @@ async function getAgentByIdHandler({
134
136
  }
135
137
  const instructions = await agent.getInstructions({ runtimeContext: proxyRuntimeContext });
136
138
  const llm = await agent.getLLM({ runtimeContext });
139
+ const defaultGenerateOptions = await agent.getDefaultGenerateOptions({ runtimeContext: proxyRuntimeContext });
140
+ const defaultStreamOptions = await agent.getDefaultStreamOptions({ runtimeContext: proxyRuntimeContext });
137
141
  return {
138
142
  name: agent.name,
139
143
  instructions,
@@ -141,8 +145,8 @@ async function getAgentByIdHandler({
141
145
  workflows: serializedAgentWorkflows,
142
146
  provider: llm?.getProvider(),
143
147
  modelId: llm?.getModelId(),
144
- defaultGenerateOptions: agent.getDefaultGenerateOptions(),
145
- defaultStreamOptions: agent.getDefaultStreamOptions()
148
+ defaultGenerateOptions,
149
+ defaultStreamOptions
146
150
  };
147
151
  } catch (error) {
148
152
  return handleError(error, "Error getting agent");
@@ -190,7 +194,8 @@ async function generateHandler({
190
194
  mastra,
191
195
  runtimeContext,
192
196
  agentId,
193
- body
197
+ body,
198
+ abortSignal
194
199
  }) {
195
200
  try {
196
201
  const agent = mastra.getAgent(agentId);
@@ -208,7 +213,8 @@ async function generateHandler({
208
213
  ...rest,
209
214
  // @ts-expect-error TODO fix types
210
215
  resourceId: finalResourceId,
211
- runtimeContext: finalRuntimeContext
216
+ runtimeContext: finalRuntimeContext,
217
+ signal: abortSignal
212
218
  });
213
219
  return result;
214
220
  } catch (error) {
@@ -219,7 +225,8 @@ async function streamGenerateHandler({
219
225
  mastra,
220
226
  runtimeContext,
221
227
  agentId,
222
- body
228
+ body,
229
+ abortSignal
223
230
  }) {
224
231
  try {
225
232
  const agent = mastra.getAgent(agentId);
@@ -237,7 +244,8 @@ async function streamGenerateHandler({
237
244
  ...rest,
238
245
  // @ts-expect-error TODO fix types
239
246
  resourceId: finalResourceId,
240
- runtimeContext: finalRuntimeContext
247
+ runtimeContext: finalRuntimeContext,
248
+ signal: abortSignal
241
249
  });
242
250
  const streamResponse = rest.output ? streamResult.toTextStreamResponse({
243
251
  headers: {
@@ -21,10 +21,11 @@ async function getSpeakersHandler({ mastra, agentId }) {
21
21
  if (!agent) {
22
22
  throw new HTTPException(404, { message: "Agent not found" });
23
23
  }
24
- if (!agent.voice) {
24
+ const voice = await agent.getVoice();
25
+ if (!voice) {
25
26
  throw new HTTPException(400, { message: "Agent does not have voice capabilities" });
26
27
  }
27
- const speakers = await agent.voice.getSpeakers();
28
+ const speakers = await voice.getSpeakers();
28
29
  return speakers;
29
30
  } catch (error) {
30
31
  return handleError(error, "Error getting speakers");
@@ -46,10 +47,11 @@ async function generateSpeechHandler({
46
47
  if (!agent) {
47
48
  throw new HTTPException(404, { message: "Agent not found" });
48
49
  }
49
- if (!agent.voice) {
50
+ const voice = await agent.getVoice();
51
+ if (!voice) {
50
52
  throw new HTTPException(400, { message: "Agent does not have voice capabilities" });
51
53
  }
52
- const audioStream = await agent.voice.speak(body.text, { speaker: body.speakerId });
54
+ const audioStream = await voice.speak(body.text, { speaker: body.speakerId });
53
55
  if (!audioStream) {
54
56
  throw new HTTPException(500, { message: "Failed to generate speech" });
55
57
  }
@@ -74,13 +76,14 @@ async function transcribeSpeechHandler({
74
76
  if (!agent) {
75
77
  throw new HTTPException(404, { message: "Agent not found" });
76
78
  }
77
- if (!agent.voice) {
79
+ const voice = await agent.getVoice();
80
+ if (!voice) {
78
81
  throw new HTTPException(400, { message: "Agent does not have voice capabilities" });
79
82
  }
80
83
  const audioStream = new Readable();
81
84
  audioStream.push(body.audioData);
82
85
  audioStream.push(null);
83
- const text = await agent.voice.listen(audioStream, body.options);
86
+ const text = await voice.listen(audioStream, body.options);
84
87
  return { text };
85
88
  } catch (error) {
86
89
  return handleError(error, "Error transcribing speech");
@@ -95,10 +98,11 @@ async function getListenerHandler({ mastra, agentId }) {
95
98
  if (!agent) {
96
99
  throw new HTTPException(404, { message: "Agent not found" });
97
100
  }
98
- if (!agent.voice) {
101
+ const voice = await agent.getVoice();
102
+ if (!voice) {
99
103
  throw new HTTPException(400, { message: "Agent does not have voice capabilities" });
100
104
  }
101
- const listeners = await agent.voice.getListener();
105
+ const listeners = await voice.getListener();
102
106
  return listeners;
103
107
  } catch (error) {
104
108
  return handleError(error, "Error getting listeners");
@@ -17,20 +17,36 @@ chunk75ZPJI57_cjs.__export(memory_exports, {
17
17
  saveMessagesHandler: () => saveMessagesHandler,
18
18
  updateThreadHandler: () => updateThreadHandler
19
19
  });
20
- function getMemoryFromContext({
20
+ async function getMemoryFromContext({
21
21
  mastra,
22
- agentId
22
+ agentId,
23
+ networkId,
24
+ runtimeContext
23
25
  }) {
24
26
  const agent = agentId ? mastra.getAgent(agentId) : null;
25
27
  if (agentId && !agent) {
26
28
  throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
27
29
  }
28
- const memory = agent?.getMemory?.() || mastra.getMemory();
29
- return memory;
30
+ const network = networkId ? mastra.vnext_getNetwork(networkId) : null;
31
+ if (networkId && !network) {
32
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Network not found" });
33
+ }
34
+ if (agent) {
35
+ return agent?.getMemory() || mastra.getMemory();
36
+ }
37
+ if (network) {
38
+ return await network?.getMemory({ runtimeContext }) || mastra.getMemory();
39
+ }
40
+ return mastra.getMemory();
30
41
  }
31
- async function getMemoryStatusHandler({ mastra, agentId }) {
42
+ async function getMemoryStatusHandler({
43
+ mastra,
44
+ agentId,
45
+ networkId,
46
+ runtimeContext
47
+ }) {
32
48
  try {
33
- const memory = getMemoryFromContext({ mastra, agentId });
49
+ const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
34
50
  if (!memory) {
35
51
  return { result: false };
36
52
  }
@@ -42,10 +58,12 @@ async function getMemoryStatusHandler({ mastra, agentId }) {
42
58
  async function getThreadsHandler({
43
59
  mastra,
44
60
  agentId,
45
- resourceId
61
+ resourceId,
62
+ networkId,
63
+ runtimeContext
46
64
  }) {
47
65
  try {
48
- const memory = getMemoryFromContext({ mastra, agentId });
66
+ const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
49
67
  if (!memory) {
50
68
  throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
51
69
  }
@@ -59,11 +77,13 @@ async function getThreadsHandler({
59
77
  async function getThreadByIdHandler({
60
78
  mastra,
61
79
  agentId,
62
- threadId
80
+ threadId,
81
+ networkId,
82
+ runtimeContext
63
83
  }) {
64
84
  try {
65
85
  chunk57CJTIPW_cjs.validateBody({ threadId });
66
- const memory = getMemoryFromContext({ mastra, agentId });
86
+ const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
67
87
  if (!memory) {
68
88
  throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
69
89
  }
@@ -79,10 +99,12 @@ async function getThreadByIdHandler({
79
99
  async function saveMessagesHandler({
80
100
  mastra,
81
101
  agentId,
82
- body
102
+ body,
103
+ networkId,
104
+ runtimeContext
83
105
  }) {
84
106
  try {
85
- const memory = getMemoryFromContext({ mastra, agentId });
107
+ const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
86
108
  if (!memory) {
87
109
  throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
88
110
  }
@@ -106,10 +128,12 @@ async function saveMessagesHandler({
106
128
  async function createThreadHandler({
107
129
  mastra,
108
130
  agentId,
109
- body
131
+ body,
132
+ networkId,
133
+ runtimeContext
110
134
  }) {
111
135
  try {
112
- const memory = getMemoryFromContext({ mastra, agentId });
136
+ const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
113
137
  if (!memory) {
114
138
  throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
115
139
  }
@@ -129,10 +153,12 @@ async function updateThreadHandler({
129
153
  mastra,
130
154
  agentId,
131
155
  threadId,
132
- body
156
+ body,
157
+ networkId,
158
+ runtimeContext
133
159
  }) {
134
160
  try {
135
- const memory = getMemoryFromContext({ mastra, agentId });
161
+ const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
136
162
  if (!body) {
137
163
  throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Body is required" });
138
164
  }
@@ -163,11 +189,13 @@ async function updateThreadHandler({
163
189
  async function deleteThreadHandler({
164
190
  mastra,
165
191
  agentId,
166
- threadId
192
+ threadId,
193
+ networkId,
194
+ runtimeContext
167
195
  }) {
168
196
  try {
169
197
  chunk57CJTIPW_cjs.validateBody({ threadId });
170
- const memory = getMemoryFromContext({ mastra, agentId });
198
+ const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
171
199
  if (!memory) {
172
200
  throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
173
201
  }
@@ -185,14 +213,16 @@ async function getMessagesHandler({
185
213
  mastra,
186
214
  agentId,
187
215
  threadId,
188
- limit
216
+ limit,
217
+ networkId,
218
+ runtimeContext
189
219
  }) {
190
220
  if (limit !== void 0 && (!Number.isInteger(limit) || limit <= 0)) {
191
221
  throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Invalid limit: must be a positive integer" });
192
222
  }
193
223
  try {
194
224
  chunk57CJTIPW_cjs.validateBody({ threadId });
195
- const memory = getMemoryFromContext({ mastra, agentId });
225
+ const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
196
226
  if (!memory) {
197
227
  throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
198
228
  }
@@ -1,9 +1,8 @@
1
- import { stringify, esm_default } from './chunk-TGJMNUYJ.js';
1
+ import { stringify, esm_default } from './chunk-OSZM4EAY.js';
2
2
  import { handleError } from './chunk-M5ABIP7D.js';
3
3
  import { HTTPException } from './chunk-NYN7KFXL.js';
4
4
  import { __export } from './chunk-MLKGABMK.js';
5
5
  import { ReadableStream } from 'stream/web';
6
- import { RuntimeContext } from '@mastra/core/di';
7
6
 
8
7
  // src/server/handlers/workflows.ts
9
8
  var workflows_exports = {};
@@ -180,7 +179,7 @@ async function createWorkflowRunHandler({
180
179
  if (!workflow) {
181
180
  throw new HTTPException(404, { message: "Workflow not found" });
182
181
  }
183
- const run = workflow.createRun({ runId: prevRunId });
182
+ const run = await workflow.createRunAsync({ runId: prevRunId });
184
183
  return { runId: run.runId };
185
184
  } catch (error) {
186
185
  throw new HTTPException(500, { message: error?.message || "Error creating workflow run" });
@@ -188,7 +187,7 @@ async function createWorkflowRunHandler({
188
187
  }
189
188
  async function startAsyncWorkflowHandler({
190
189
  mastra,
191
- runtimeContext: payloadRuntimeContext,
190
+ runtimeContext,
192
191
  workflowId,
193
192
  runId,
194
193
  inputData
@@ -201,14 +200,7 @@ async function startAsyncWorkflowHandler({
201
200
  if (!workflow) {
202
201
  throw new HTTPException(404, { message: "Workflow not found" });
203
202
  }
204
- let runtimeContext;
205
- if (payloadRuntimeContext) {
206
- runtimeContext = new RuntimeContext();
207
- Object.entries(payloadRuntimeContext || {}).forEach(([key, value]) => {
208
- runtimeContext.set(key, value);
209
- });
210
- }
211
- const _run = workflow.createRun({ runId });
203
+ const _run = await workflow.createRunAsync({ runId });
212
204
  const result = await _run.start({
213
205
  inputData,
214
206
  runtimeContext
@@ -220,7 +212,7 @@ async function startAsyncWorkflowHandler({
220
212
  }
221
213
  async function startWorkflowRunHandler({
222
214
  mastra,
223
- runtimeContext: payloadRuntimeContext,
215
+ runtimeContext,
224
216
  workflowId,
225
217
  runId,
226
218
  inputData
@@ -240,14 +232,7 @@ async function startWorkflowRunHandler({
240
232
  if (!run) {
241
233
  throw new HTTPException(404, { message: "Workflow run not found" });
242
234
  }
243
- let runtimeContext;
244
- if (payloadRuntimeContext) {
245
- runtimeContext = new RuntimeContext();
246
- Object.entries(payloadRuntimeContext || {}).forEach(([key, value]) => {
247
- runtimeContext.set(key, value);
248
- });
249
- }
250
- const _run = workflow.createRun({ runId });
235
+ const _run = await workflow.createRunAsync({ runId });
251
236
  void _run.start({
252
237
  inputData,
253
238
  runtimeContext
@@ -277,7 +262,7 @@ async function watchWorkflowHandler({
277
262
  if (!run) {
278
263
  throw new HTTPException(404, { message: "Workflow run not found" });
279
264
  }
280
- const _run = workflow.createRun({ runId });
265
+ const _run = await workflow.createRunAsync({ runId });
281
266
  let unwatch;
282
267
  let asyncRef = null;
283
268
  const stream = new ReadableStream({
@@ -308,7 +293,7 @@ async function watchWorkflowHandler({
308
293
  }
309
294
  async function streamWorkflowHandler({
310
295
  mastra,
311
- runtimeContext: payloadRuntimeContext,
296
+ runtimeContext,
312
297
  workflowId,
313
298
  runId,
314
299
  inputData
@@ -324,14 +309,7 @@ async function streamWorkflowHandler({
324
309
  if (!workflow) {
325
310
  throw new HTTPException(404, { message: "Workflow not found" });
326
311
  }
327
- let runtimeContext;
328
- if (payloadRuntimeContext) {
329
- runtimeContext = new RuntimeContext();
330
- Object.entries(payloadRuntimeContext || {}).forEach(([key, value]) => {
331
- runtimeContext.set(key, value);
332
- });
333
- }
334
- const run = workflow.createRun({ runId });
312
+ const run = await workflow.createRunAsync({ runId });
335
313
  const result = run.stream({
336
314
  inputData,
337
315
  runtimeContext
@@ -346,7 +324,7 @@ async function resumeAsyncWorkflowHandler({
346
324
  workflowId,
347
325
  runId,
348
326
  body,
349
- runtimeContext: payloadRuntimeContext
327
+ runtimeContext
350
328
  }) {
351
329
  try {
352
330
  if (!workflowId) {
@@ -366,14 +344,7 @@ async function resumeAsyncWorkflowHandler({
366
344
  if (!run) {
367
345
  throw new HTTPException(404, { message: "Workflow run not found" });
368
346
  }
369
- let runtimeContext;
370
- if (payloadRuntimeContext) {
371
- runtimeContext = new RuntimeContext();
372
- Object.entries(payloadRuntimeContext || {}).forEach(([key, value]) => {
373
- runtimeContext.set(key, value);
374
- });
375
- }
376
- const _run = workflow.createRun({ runId });
347
+ const _run = await workflow.createRunAsync({ runId });
377
348
  const result = await _run.resume({
378
349
  step: body.step,
379
350
  resumeData: body.resumeData,
@@ -389,7 +360,7 @@ async function resumeWorkflowHandler({
389
360
  workflowId,
390
361
  runId,
391
362
  body,
392
- runtimeContext: payloadRuntimeContext
363
+ runtimeContext
393
364
  }) {
394
365
  try {
395
366
  if (!workflowId) {
@@ -409,14 +380,7 @@ async function resumeWorkflowHandler({
409
380
  if (!run) {
410
381
  throw new HTTPException(404, { message: "Workflow run not found" });
411
382
  }
412
- let runtimeContext;
413
- if (payloadRuntimeContext) {
414
- runtimeContext = new RuntimeContext();
415
- Object.entries(payloadRuntimeContext || {}).forEach(([key, value]) => {
416
- runtimeContext.set(key, value);
417
- });
418
- }
419
- const _run = workflow.createRun({ runId });
383
+ const _run = await workflow.createRunAsync({ runId });
420
384
  void _run.resume({
421
385
  step: body.step,
422
386
  resumeData: body.resumeData,
@@ -1,11 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var chunkASKESBJW_cjs = require('./chunk-ASKESBJW.cjs');
3
+ var chunkMN6F4D5A_cjs = require('./chunk-MN6F4D5A.cjs');
4
4
  var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.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');
8
- var di = require('@mastra/core/di');
9
8
 
10
9
  // src/server/handlers/workflows.ts
11
10
  var workflows_exports = {};
@@ -34,16 +33,16 @@ async function getWorkflowsHandler({ mastra }) {
34
33
  acc2[key2] = {
35
34
  id: step.id,
36
35
  description: step.description,
37
- inputSchema: step.inputSchema ? chunkASKESBJW_cjs.stringify(chunkASKESBJW_cjs.esm_default(step.inputSchema)) : void 0,
38
- outputSchema: step.outputSchema ? chunkASKESBJW_cjs.stringify(chunkASKESBJW_cjs.esm_default(step.outputSchema)) : void 0,
39
- resumeSchema: step.resumeSchema ? chunkASKESBJW_cjs.stringify(chunkASKESBJW_cjs.esm_default(step.resumeSchema)) : void 0,
40
- suspendSchema: step.suspendSchema ? chunkASKESBJW_cjs.stringify(chunkASKESBJW_cjs.esm_default(step.suspendSchema)) : void 0
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
41
40
  };
42
41
  return acc2;
43
42
  }, {}),
44
43
  stepGraph: workflow.serializedStepGraph,
45
- inputSchema: workflow.inputSchema ? chunkASKESBJW_cjs.stringify(chunkASKESBJW_cjs.esm_default(workflow.inputSchema)) : void 0,
46
- outputSchema: workflow.outputSchema ? chunkASKESBJW_cjs.stringify(chunkASKESBJW_cjs.esm_default(workflow.outputSchema)) : void 0
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
47
46
  };
48
47
  return acc;
49
48
  }, {});
@@ -100,18 +99,18 @@ async function getWorkflowByIdHandler({ mastra, workflowId }) {
100
99
  acc[key] = {
101
100
  id: step.id,
102
101
  description: step.description,
103
- inputSchema: step.inputSchema ? chunkASKESBJW_cjs.stringify(chunkASKESBJW_cjs.esm_default(step.inputSchema)) : void 0,
104
- outputSchema: step.outputSchema ? chunkASKESBJW_cjs.stringify(chunkASKESBJW_cjs.esm_default(step.outputSchema)) : void 0,
105
- resumeSchema: step.resumeSchema ? chunkASKESBJW_cjs.stringify(chunkASKESBJW_cjs.esm_default(step.resumeSchema)) : void 0,
106
- suspendSchema: step.suspendSchema ? chunkASKESBJW_cjs.stringify(chunkASKESBJW_cjs.esm_default(step.suspendSchema)) : void 0
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
107
106
  };
108
107
  return acc;
109
108
  }, {}),
110
109
  name: workflow.name,
111
110
  description: workflow.description,
112
111
  stepGraph: workflow.serializedStepGraph,
113
- inputSchema: workflow.inputSchema ? chunkASKESBJW_cjs.stringify(chunkASKESBJW_cjs.esm_default(workflow.inputSchema)) : void 0,
114
- outputSchema: workflow.outputSchema ? chunkASKESBJW_cjs.stringify(chunkASKESBJW_cjs.esm_default(workflow.outputSchema)) : void 0
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
115
114
  };
116
115
  } catch (error) {
117
116
  throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflow" });
@@ -182,7 +181,7 @@ async function createWorkflowRunHandler({
182
181
  if (!workflow) {
183
182
  throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
184
183
  }
185
- const run = workflow.createRun({ runId: prevRunId });
184
+ const run = await workflow.createRunAsync({ runId: prevRunId });
186
185
  return { runId: run.runId };
187
186
  } catch (error) {
188
187
  throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error creating workflow run" });
@@ -190,7 +189,7 @@ async function createWorkflowRunHandler({
190
189
  }
191
190
  async function startAsyncWorkflowHandler({
192
191
  mastra,
193
- runtimeContext: payloadRuntimeContext,
192
+ runtimeContext,
194
193
  workflowId,
195
194
  runId,
196
195
  inputData
@@ -203,14 +202,7 @@ async function startAsyncWorkflowHandler({
203
202
  if (!workflow) {
204
203
  throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
205
204
  }
206
- let runtimeContext;
207
- if (payloadRuntimeContext) {
208
- runtimeContext = new di.RuntimeContext();
209
- Object.entries(payloadRuntimeContext || {}).forEach(([key, value]) => {
210
- runtimeContext.set(key, value);
211
- });
212
- }
213
- const _run = workflow.createRun({ runId });
205
+ const _run = await workflow.createRunAsync({ runId });
214
206
  const result = await _run.start({
215
207
  inputData,
216
208
  runtimeContext
@@ -222,7 +214,7 @@ async function startAsyncWorkflowHandler({
222
214
  }
223
215
  async function startWorkflowRunHandler({
224
216
  mastra,
225
- runtimeContext: payloadRuntimeContext,
217
+ runtimeContext,
226
218
  workflowId,
227
219
  runId,
228
220
  inputData
@@ -242,14 +234,7 @@ async function startWorkflowRunHandler({
242
234
  if (!run) {
243
235
  throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
244
236
  }
245
- let runtimeContext;
246
- if (payloadRuntimeContext) {
247
- runtimeContext = new di.RuntimeContext();
248
- Object.entries(payloadRuntimeContext || {}).forEach(([key, value]) => {
249
- runtimeContext.set(key, value);
250
- });
251
- }
252
- const _run = workflow.createRun({ runId });
237
+ const _run = await workflow.createRunAsync({ runId });
253
238
  void _run.start({
254
239
  inputData,
255
240
  runtimeContext
@@ -279,7 +264,7 @@ async function watchWorkflowHandler({
279
264
  if (!run) {
280
265
  throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
281
266
  }
282
- const _run = workflow.createRun({ runId });
267
+ const _run = await workflow.createRunAsync({ runId });
283
268
  let unwatch;
284
269
  let asyncRef = null;
285
270
  const stream = new web.ReadableStream({
@@ -310,7 +295,7 @@ async function watchWorkflowHandler({
310
295
  }
311
296
  async function streamWorkflowHandler({
312
297
  mastra,
313
- runtimeContext: payloadRuntimeContext,
298
+ runtimeContext,
314
299
  workflowId,
315
300
  runId,
316
301
  inputData
@@ -326,14 +311,7 @@ async function streamWorkflowHandler({
326
311
  if (!workflow) {
327
312
  throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
328
313
  }
329
- let runtimeContext;
330
- if (payloadRuntimeContext) {
331
- runtimeContext = new di.RuntimeContext();
332
- Object.entries(payloadRuntimeContext || {}).forEach(([key, value]) => {
333
- runtimeContext.set(key, value);
334
- });
335
- }
336
- const run = workflow.createRun({ runId });
314
+ const run = await workflow.createRunAsync({ runId });
337
315
  const result = run.stream({
338
316
  inputData,
339
317
  runtimeContext
@@ -348,7 +326,7 @@ async function resumeAsyncWorkflowHandler({
348
326
  workflowId,
349
327
  runId,
350
328
  body,
351
- runtimeContext: payloadRuntimeContext
329
+ runtimeContext
352
330
  }) {
353
331
  try {
354
332
  if (!workflowId) {
@@ -368,14 +346,7 @@ async function resumeAsyncWorkflowHandler({
368
346
  if (!run) {
369
347
  throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
370
348
  }
371
- let runtimeContext;
372
- if (payloadRuntimeContext) {
373
- runtimeContext = new di.RuntimeContext();
374
- Object.entries(payloadRuntimeContext || {}).forEach(([key, value]) => {
375
- runtimeContext.set(key, value);
376
- });
377
- }
378
- const _run = workflow.createRun({ runId });
349
+ const _run = await workflow.createRunAsync({ runId });
379
350
  const result = await _run.resume({
380
351
  step: body.step,
381
352
  resumeData: body.resumeData,
@@ -391,7 +362,7 @@ async function resumeWorkflowHandler({
391
362
  workflowId,
392
363
  runId,
393
364
  body,
394
- runtimeContext: payloadRuntimeContext
365
+ runtimeContext
395
366
  }) {
396
367
  try {
397
368
  if (!workflowId) {
@@ -411,14 +382,7 @@ async function resumeWorkflowHandler({
411
382
  if (!run) {
412
383
  throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
413
384
  }
414
- let runtimeContext;
415
- if (payloadRuntimeContext) {
416
- runtimeContext = new di.RuntimeContext();
417
- Object.entries(payloadRuntimeContext || {}).forEach(([key, value]) => {
418
- runtimeContext.set(key, value);
419
- });
420
- }
421
- const _run = workflow.createRun({ runId });
385
+ const _run = await workflow.createRunAsync({ runId });
422
386
  void _run.resume({
423
387
  step: body.step,
424
388
  resumeData: body.resumeData,