@mastra/server 0.10.6-alpha.0 → 0.10.6-alpha.1

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.
@@ -40,6 +40,7 @@ import type { TaskStatus } from '@mastra/core/a2a';
40
40
  import type { ToolAction } from '@mastra/core/tools';
41
41
  import { UIMessage } from 'ai';
42
42
  import type { VercelTool } from '@mastra/core/tools';
43
+ import type { WatchEvent } from '@mastra/core/workflows';
43
44
  import type { Workflow } from '@mastra/core/workflows';
44
45
  import { WorkflowContext as WorkflowContext_2 } from '@mastra/core/workflows/legacy';
45
46
  import { WorkflowResult } from '@mastra/core/workflows';
@@ -159,7 +160,7 @@ export declare function generateHandler({ mastra, runtimeContext, agentId, body,
159
160
  resourceid?: string;
160
161
  runtimeContext?: Record<string, unknown>;
161
162
  };
162
- }): Promise<GenerateTextResult<any, any>>;
163
+ }): Promise<GenerateTextResult<any, unknown>>;
163
164
 
164
165
  export declare function generateHandler_alias_1({ mastra, runtimeContext, networkId, body, }: NetworkContext & {
165
166
  runtimeContext: RuntimeContext;
@@ -362,6 +363,8 @@ export declare function getWorkflowByIdHandler({ mastra, workflowId }: WorkflowC
362
363
 
363
364
  export declare function getWorkflowRunByIdHandler({ mastra, workflowId, runId, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'>): Promise<ReturnType<Workflow['getWorkflowRunById']>>;
364
365
 
366
+ export declare function getWorkflowRunExecutionResultHandler({ mastra, workflowId, runId, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'>): Promise<WatchEvent['payload']['workflowState']>;
367
+
365
368
  export declare function getWorkflowRunsHandler({ mastra, workflowId, fromDate, toDate, limit, offset, resourceId, }: WorkflowContext_3 & {
366
369
  fromDate?: Date;
367
370
  toDate?: Date;
@@ -598,12 +601,12 @@ export declare function resumeAsyncLegacyWorkflowHandler({ mastra, workflowId, r
598
601
  runtimeContext: RuntimeContext;
599
602
  }): Promise<Omit<LegacyWorkflowRunResult<any, LegacyStep<string, any, any, StepExecutionContext<any, WorkflowContext_2<any, LegacyStep<string, any, any, any>[], Record<string, any>>>>[], any>, "runId"> | undefined>;
600
603
 
601
- export declare function resumeAsyncWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, }: WorkflowContext_3 & {
604
+ export declare function resumeAsyncWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext: payloadRuntimeContext, }: WorkflowContext_3 & {
602
605
  body: {
603
606
  step: string | string[];
604
607
  resumeData?: unknown;
605
608
  };
606
- runtimeContext?: RuntimeContext_2;
609
+ runtimeContext?: Record<string, any>;
607
610
  }): Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any, any>[]>>;
608
611
 
609
612
  export declare function resumeLegacyWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, }: WorkflowContext & {
@@ -616,12 +619,12 @@ export declare function resumeLegacyWorkflowHandler({ mastra, workflowId, runId,
616
619
  message: string;
617
620
  }>;
618
621
 
619
- export declare function resumeWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, }: WorkflowContext_3 & {
622
+ export declare function resumeWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext: payloadRuntimeContext, }: WorkflowContext_3 & {
620
623
  body: {
621
624
  step: string | string[];
622
625
  resumeData?: unknown;
623
626
  };
624
- runtimeContext?: RuntimeContext_2;
627
+ runtimeContext?: Record<string, any>;
625
628
  }): Promise<{
626
629
  message: string;
627
630
  }>;
@@ -648,9 +651,9 @@ export declare function startAsyncLegacyWorkflowHandler({ mastra, runtimeContext
648
651
  runtimeContext: RuntimeContext;
649
652
  }): Promise<LegacyWorkflowRunResult<any, LegacyStep<string, any, any, StepExecutionContext<any, WorkflowContext_2<any, LegacyStep<string, any, any, any>[], Record<string, any>>>>[], any>>;
650
653
 
651
- export declare function startAsyncWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
654
+ export declare function startAsyncWorkflowHandler({ mastra, runtimeContext: payloadRuntimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
652
655
  inputData?: unknown;
653
- runtimeContext?: RuntimeContext_2;
656
+ runtimeContext?: Record<string, any>;
654
657
  }): Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any, any>[]>>;
655
658
 
656
659
  export declare function startLegacyWorkflowRunHandler({ mastra, runtimeContext, workflowId, runId, triggerData, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
@@ -660,9 +663,9 @@ export declare function startLegacyWorkflowRunHandler({ mastra, runtimeContext,
660
663
  message: string;
661
664
  }>;
662
665
 
663
- export declare function startWorkflowRunHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
666
+ export declare function startWorkflowRunHandler({ mastra, runtimeContext: payloadRuntimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
664
667
  inputData?: unknown;
665
- runtimeContext?: RuntimeContext_2;
668
+ runtimeContext?: Record<string, any>;
666
669
  }): Promise<{
667
670
  message: string;
668
671
  }>;
@@ -706,9 +709,9 @@ export declare function streamGenerateHandler_alias_1({ mastra, networkId, body,
706
709
  } & Parameters<AgentNetwork['stream']>[1];
707
710
  }): Promise<Response>;
708
711
 
709
- export declare function streamWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
712
+ export declare function streamWorkflowHandler({ mastra, runtimeContext: payloadRuntimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
710
713
  inputData?: unknown;
711
- runtimeContext?: RuntimeContext_2;
714
+ runtimeContext?: Record<string, any>;
712
715
  }): Promise<{
713
716
  stream: globalThis.ReadableStream<StreamEvent>;
714
717
  getWorkflowState: () => Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any, any>[]>>;
@@ -846,6 +849,7 @@ export declare namespace workflows {
846
849
  getWorkflowsHandler,
847
850
  getWorkflowByIdHandler,
848
851
  getWorkflowRunByIdHandler,
852
+ getWorkflowRunExecutionResultHandler,
849
853
  createWorkflowRunHandler,
850
854
  startAsyncWorkflowHandler,
851
855
  startWorkflowRunHandler,
@@ -40,6 +40,7 @@ import type { TaskStatus } from '@mastra/core/a2a';
40
40
  import type { ToolAction } from '@mastra/core/tools';
41
41
  import { UIMessage } from 'ai';
42
42
  import type { VercelTool } from '@mastra/core/tools';
43
+ import type { WatchEvent } from '@mastra/core/workflows';
43
44
  import type { Workflow } from '@mastra/core/workflows';
44
45
  import { WorkflowContext as WorkflowContext_2 } from '@mastra/core/workflows/legacy';
45
46
  import { WorkflowResult } from '@mastra/core/workflows';
@@ -159,7 +160,7 @@ export declare function generateHandler({ mastra, runtimeContext, agentId, body,
159
160
  resourceid?: string;
160
161
  runtimeContext?: Record<string, unknown>;
161
162
  };
162
- }): Promise<GenerateTextResult<any, any>>;
163
+ }): Promise<GenerateTextResult<any, unknown>>;
163
164
 
164
165
  export declare function generateHandler_alias_1({ mastra, runtimeContext, networkId, body, }: NetworkContext & {
165
166
  runtimeContext: RuntimeContext;
@@ -362,6 +363,8 @@ export declare function getWorkflowByIdHandler({ mastra, workflowId }: WorkflowC
362
363
 
363
364
  export declare function getWorkflowRunByIdHandler({ mastra, workflowId, runId, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'>): Promise<ReturnType<Workflow['getWorkflowRunById']>>;
364
365
 
366
+ export declare function getWorkflowRunExecutionResultHandler({ mastra, workflowId, runId, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'>): Promise<WatchEvent['payload']['workflowState']>;
367
+
365
368
  export declare function getWorkflowRunsHandler({ mastra, workflowId, fromDate, toDate, limit, offset, resourceId, }: WorkflowContext_3 & {
366
369
  fromDate?: Date;
367
370
  toDate?: Date;
@@ -598,12 +601,12 @@ export declare function resumeAsyncLegacyWorkflowHandler({ mastra, workflowId, r
598
601
  runtimeContext: RuntimeContext;
599
602
  }): Promise<Omit<LegacyWorkflowRunResult<any, LegacyStep<string, any, any, StepExecutionContext<any, WorkflowContext_2<any, LegacyStep<string, any, any, any>[], Record<string, any>>>>[], any>, "runId"> | undefined>;
600
603
 
601
- export declare function resumeAsyncWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, }: WorkflowContext_3 & {
604
+ export declare function resumeAsyncWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext: payloadRuntimeContext, }: WorkflowContext_3 & {
602
605
  body: {
603
606
  step: string | string[];
604
607
  resumeData?: unknown;
605
608
  };
606
- runtimeContext?: RuntimeContext_2;
609
+ runtimeContext?: Record<string, any>;
607
610
  }): Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any, any>[]>>;
608
611
 
609
612
  export declare function resumeLegacyWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, }: WorkflowContext & {
@@ -616,12 +619,12 @@ export declare function resumeLegacyWorkflowHandler({ mastra, workflowId, runId,
616
619
  message: string;
617
620
  }>;
618
621
 
619
- export declare function resumeWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, }: WorkflowContext_3 & {
622
+ export declare function resumeWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext: payloadRuntimeContext, }: WorkflowContext_3 & {
620
623
  body: {
621
624
  step: string | string[];
622
625
  resumeData?: unknown;
623
626
  };
624
- runtimeContext?: RuntimeContext_2;
627
+ runtimeContext?: Record<string, any>;
625
628
  }): Promise<{
626
629
  message: string;
627
630
  }>;
@@ -648,9 +651,9 @@ export declare function startAsyncLegacyWorkflowHandler({ mastra, runtimeContext
648
651
  runtimeContext: RuntimeContext;
649
652
  }): Promise<LegacyWorkflowRunResult<any, LegacyStep<string, any, any, StepExecutionContext<any, WorkflowContext_2<any, LegacyStep<string, any, any, any>[], Record<string, any>>>>[], any>>;
650
653
 
651
- export declare function startAsyncWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
654
+ export declare function startAsyncWorkflowHandler({ mastra, runtimeContext: payloadRuntimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
652
655
  inputData?: unknown;
653
- runtimeContext?: RuntimeContext_2;
656
+ runtimeContext?: Record<string, any>;
654
657
  }): Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any, any>[]>>;
655
658
 
656
659
  export declare function startLegacyWorkflowRunHandler({ mastra, runtimeContext, workflowId, runId, triggerData, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
@@ -660,9 +663,9 @@ export declare function startLegacyWorkflowRunHandler({ mastra, runtimeContext,
660
663
  message: string;
661
664
  }>;
662
665
 
663
- export declare function startWorkflowRunHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
666
+ export declare function startWorkflowRunHandler({ mastra, runtimeContext: payloadRuntimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
664
667
  inputData?: unknown;
665
- runtimeContext?: RuntimeContext_2;
668
+ runtimeContext?: Record<string, any>;
666
669
  }): Promise<{
667
670
  message: string;
668
671
  }>;
@@ -706,9 +709,9 @@ export declare function streamGenerateHandler_alias_1({ mastra, networkId, body,
706
709
  } & Parameters<AgentNetwork['stream']>[1];
707
710
  }): Promise<Response>;
708
711
 
709
- export declare function streamWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
712
+ export declare function streamWorkflowHandler({ mastra, runtimeContext: payloadRuntimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
710
713
  inputData?: unknown;
711
- runtimeContext?: RuntimeContext_2;
714
+ runtimeContext?: Record<string, any>;
712
715
  }): Promise<{
713
716
  stream: globalThis.ReadableStream<StreamEvent>;
714
717
  getWorkflowState: () => Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any, any>[]>>;
@@ -846,6 +849,7 @@ export declare namespace workflows {
846
849
  getWorkflowsHandler,
847
850
  getWorkflowByIdHandler,
848
851
  getWorkflowRunByIdHandler,
852
+ getWorkflowRunExecutionResultHandler,
849
853
  createWorkflowRunHandler,
850
854
  startAsyncWorkflowHandler,
851
855
  startWorkflowRunHandler,
@@ -5,6 +5,7 @@ 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');
8
9
 
9
10
  // src/server/handlers/workflows.ts
10
11
  var workflows_exports = {};
@@ -12,6 +13,7 @@ chunk75ZPJI57_cjs.__export(workflows_exports, {
12
13
  createWorkflowRunHandler: () => createWorkflowRunHandler,
13
14
  getWorkflowByIdHandler: () => getWorkflowByIdHandler,
14
15
  getWorkflowRunByIdHandler: () => getWorkflowRunByIdHandler,
16
+ getWorkflowRunExecutionResultHandler: () => getWorkflowRunExecutionResultHandler,
15
17
  getWorkflowRunsHandler: () => getWorkflowRunsHandler,
16
18
  getWorkflowsHandler: () => getWorkflowsHandler,
17
19
  resumeAsyncWorkflowHandler: () => resumeAsyncWorkflowHandler,
@@ -140,6 +142,33 @@ async function getWorkflowRunByIdHandler({
140
142
  throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflow run" });
141
143
  }
142
144
  }
145
+ async function getWorkflowRunExecutionResultHandler({
146
+ mastra,
147
+ workflowId,
148
+ runId
149
+ }) {
150
+ try {
151
+ if (!workflowId) {
152
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
153
+ }
154
+ if (!runId) {
155
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Run ID is required" });
156
+ }
157
+ const workflow = mastra.getWorkflow(workflowId);
158
+ if (!workflow) {
159
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
160
+ }
161
+ const executionResult = await workflow.getWorkflowRunExecutionResult(runId);
162
+ if (!executionResult) {
163
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run execution result not found" });
164
+ }
165
+ return executionResult;
166
+ } catch (error) {
167
+ throw new chunkOCWPVYNI_cjs.HTTPException(500, {
168
+ message: error?.message || "Error getting workflow run execution result"
169
+ });
170
+ }
171
+ }
143
172
  async function createWorkflowRunHandler({
144
173
  mastra,
145
174
  workflowId,
@@ -161,7 +190,7 @@ async function createWorkflowRunHandler({
161
190
  }
162
191
  async function startAsyncWorkflowHandler({
163
192
  mastra,
164
- runtimeContext,
193
+ runtimeContext: payloadRuntimeContext,
165
194
  workflowId,
166
195
  runId,
167
196
  inputData
@@ -174,6 +203,13 @@ async function startAsyncWorkflowHandler({
174
203
  if (!workflow) {
175
204
  throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
176
205
  }
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
+ }
177
213
  const _run = workflow.createRun({ runId });
178
214
  const result = await _run.start({
179
215
  inputData,
@@ -186,7 +222,7 @@ async function startAsyncWorkflowHandler({
186
222
  }
187
223
  async function startWorkflowRunHandler({
188
224
  mastra,
189
- runtimeContext,
225
+ runtimeContext: payloadRuntimeContext,
190
226
  workflowId,
191
227
  runId,
192
228
  inputData
@@ -206,6 +242,13 @@ async function startWorkflowRunHandler({
206
242
  if (!run) {
207
243
  throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
208
244
  }
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
+ }
209
252
  const _run = workflow.createRun({ runId });
210
253
  void _run.start({
211
254
  inputData,
@@ -267,7 +310,7 @@ async function watchWorkflowHandler({
267
310
  }
268
311
  async function streamWorkflowHandler({
269
312
  mastra,
270
- runtimeContext,
313
+ runtimeContext: payloadRuntimeContext,
271
314
  workflowId,
272
315
  runId,
273
316
  inputData
@@ -283,6 +326,13 @@ async function streamWorkflowHandler({
283
326
  if (!workflow) {
284
327
  throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
285
328
  }
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
+ }
286
336
  const run = workflow.createRun({ runId });
287
337
  const result = run.stream({
288
338
  inputData,
@@ -298,7 +348,7 @@ async function resumeAsyncWorkflowHandler({
298
348
  workflowId,
299
349
  runId,
300
350
  body,
301
- runtimeContext
351
+ runtimeContext: payloadRuntimeContext
302
352
  }) {
303
353
  try {
304
354
  if (!workflowId) {
@@ -318,6 +368,13 @@ async function resumeAsyncWorkflowHandler({
318
368
  if (!run) {
319
369
  throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
320
370
  }
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
+ }
321
378
  const _run = workflow.createRun({ runId });
322
379
  const result = await _run.resume({
323
380
  step: body.step,
@@ -334,7 +391,7 @@ async function resumeWorkflowHandler({
334
391
  workflowId,
335
392
  runId,
336
393
  body,
337
- runtimeContext
394
+ runtimeContext: payloadRuntimeContext
338
395
  }) {
339
396
  try {
340
397
  if (!workflowId) {
@@ -354,6 +411,13 @@ async function resumeWorkflowHandler({
354
411
  if (!run) {
355
412
  throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
356
413
  }
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
+ }
357
421
  const _run = workflow.createRun({ runId });
358
422
  void _run.resume({
359
423
  step: body.step,
@@ -395,6 +459,7 @@ async function getWorkflowRunsHandler({
395
459
  exports.createWorkflowRunHandler = createWorkflowRunHandler;
396
460
  exports.getWorkflowByIdHandler = getWorkflowByIdHandler;
397
461
  exports.getWorkflowRunByIdHandler = getWorkflowRunByIdHandler;
462
+ exports.getWorkflowRunExecutionResultHandler = getWorkflowRunExecutionResultHandler;
398
463
  exports.getWorkflowRunsHandler = getWorkflowRunsHandler;
399
464
  exports.getWorkflowsHandler = getWorkflowsHandler;
400
465
  exports.resumeAsyncWorkflowHandler = resumeAsyncWorkflowHandler;
@@ -3,6 +3,7 @@ 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';
6
7
 
7
8
  // src/server/handlers/workflows.ts
8
9
  var workflows_exports = {};
@@ -10,6 +11,7 @@ __export(workflows_exports, {
10
11
  createWorkflowRunHandler: () => createWorkflowRunHandler,
11
12
  getWorkflowByIdHandler: () => getWorkflowByIdHandler,
12
13
  getWorkflowRunByIdHandler: () => getWorkflowRunByIdHandler,
14
+ getWorkflowRunExecutionResultHandler: () => getWorkflowRunExecutionResultHandler,
13
15
  getWorkflowRunsHandler: () => getWorkflowRunsHandler,
14
16
  getWorkflowsHandler: () => getWorkflowsHandler,
15
17
  resumeAsyncWorkflowHandler: () => resumeAsyncWorkflowHandler,
@@ -138,6 +140,33 @@ async function getWorkflowRunByIdHandler({
138
140
  throw new HTTPException(500, { message: error?.message || "Error getting workflow run" });
139
141
  }
140
142
  }
143
+ async function getWorkflowRunExecutionResultHandler({
144
+ mastra,
145
+ workflowId,
146
+ runId
147
+ }) {
148
+ try {
149
+ if (!workflowId) {
150
+ throw new HTTPException(400, { message: "Workflow ID is required" });
151
+ }
152
+ if (!runId) {
153
+ throw new HTTPException(400, { message: "Run ID is required" });
154
+ }
155
+ const workflow = mastra.getWorkflow(workflowId);
156
+ if (!workflow) {
157
+ throw new HTTPException(404, { message: "Workflow not found" });
158
+ }
159
+ const executionResult = await workflow.getWorkflowRunExecutionResult(runId);
160
+ if (!executionResult) {
161
+ throw new HTTPException(404, { message: "Workflow run execution result not found" });
162
+ }
163
+ return executionResult;
164
+ } catch (error) {
165
+ throw new HTTPException(500, {
166
+ message: error?.message || "Error getting workflow run execution result"
167
+ });
168
+ }
169
+ }
141
170
  async function createWorkflowRunHandler({
142
171
  mastra,
143
172
  workflowId,
@@ -159,7 +188,7 @@ async function createWorkflowRunHandler({
159
188
  }
160
189
  async function startAsyncWorkflowHandler({
161
190
  mastra,
162
- runtimeContext,
191
+ runtimeContext: payloadRuntimeContext,
163
192
  workflowId,
164
193
  runId,
165
194
  inputData
@@ -172,6 +201,13 @@ async function startAsyncWorkflowHandler({
172
201
  if (!workflow) {
173
202
  throw new HTTPException(404, { message: "Workflow not found" });
174
203
  }
204
+ let runtimeContext;
205
+ if (payloadRuntimeContext) {
206
+ runtimeContext = new RuntimeContext();
207
+ Object.entries(payloadRuntimeContext || {}).forEach(([key, value]) => {
208
+ runtimeContext.set(key, value);
209
+ });
210
+ }
175
211
  const _run = workflow.createRun({ runId });
176
212
  const result = await _run.start({
177
213
  inputData,
@@ -184,7 +220,7 @@ async function startAsyncWorkflowHandler({
184
220
  }
185
221
  async function startWorkflowRunHandler({
186
222
  mastra,
187
- runtimeContext,
223
+ runtimeContext: payloadRuntimeContext,
188
224
  workflowId,
189
225
  runId,
190
226
  inputData
@@ -204,6 +240,13 @@ async function startWorkflowRunHandler({
204
240
  if (!run) {
205
241
  throw new HTTPException(404, { message: "Workflow run not found" });
206
242
  }
243
+ let runtimeContext;
244
+ if (payloadRuntimeContext) {
245
+ runtimeContext = new RuntimeContext();
246
+ Object.entries(payloadRuntimeContext || {}).forEach(([key, value]) => {
247
+ runtimeContext.set(key, value);
248
+ });
249
+ }
207
250
  const _run = workflow.createRun({ runId });
208
251
  void _run.start({
209
252
  inputData,
@@ -265,7 +308,7 @@ async function watchWorkflowHandler({
265
308
  }
266
309
  async function streamWorkflowHandler({
267
310
  mastra,
268
- runtimeContext,
311
+ runtimeContext: payloadRuntimeContext,
269
312
  workflowId,
270
313
  runId,
271
314
  inputData
@@ -281,6 +324,13 @@ async function streamWorkflowHandler({
281
324
  if (!workflow) {
282
325
  throw new HTTPException(404, { message: "Workflow not found" });
283
326
  }
327
+ let runtimeContext;
328
+ if (payloadRuntimeContext) {
329
+ runtimeContext = new RuntimeContext();
330
+ Object.entries(payloadRuntimeContext || {}).forEach(([key, value]) => {
331
+ runtimeContext.set(key, value);
332
+ });
333
+ }
284
334
  const run = workflow.createRun({ runId });
285
335
  const result = run.stream({
286
336
  inputData,
@@ -296,7 +346,7 @@ async function resumeAsyncWorkflowHandler({
296
346
  workflowId,
297
347
  runId,
298
348
  body,
299
- runtimeContext
349
+ runtimeContext: payloadRuntimeContext
300
350
  }) {
301
351
  try {
302
352
  if (!workflowId) {
@@ -316,6 +366,13 @@ async function resumeAsyncWorkflowHandler({
316
366
  if (!run) {
317
367
  throw new HTTPException(404, { message: "Workflow run not found" });
318
368
  }
369
+ let runtimeContext;
370
+ if (payloadRuntimeContext) {
371
+ runtimeContext = new RuntimeContext();
372
+ Object.entries(payloadRuntimeContext || {}).forEach(([key, value]) => {
373
+ runtimeContext.set(key, value);
374
+ });
375
+ }
319
376
  const _run = workflow.createRun({ runId });
320
377
  const result = await _run.resume({
321
378
  step: body.step,
@@ -332,7 +389,7 @@ async function resumeWorkflowHandler({
332
389
  workflowId,
333
390
  runId,
334
391
  body,
335
- runtimeContext
392
+ runtimeContext: payloadRuntimeContext
336
393
  }) {
337
394
  try {
338
395
  if (!workflowId) {
@@ -352,6 +409,13 @@ async function resumeWorkflowHandler({
352
409
  if (!run) {
353
410
  throw new HTTPException(404, { message: "Workflow run not found" });
354
411
  }
412
+ let runtimeContext;
413
+ if (payloadRuntimeContext) {
414
+ runtimeContext = new RuntimeContext();
415
+ Object.entries(payloadRuntimeContext || {}).forEach(([key, value]) => {
416
+ runtimeContext.set(key, value);
417
+ });
418
+ }
355
419
  const _run = workflow.createRun({ runId });
356
420
  void _run.resume({
357
421
  step: body.step,
@@ -390,4 +454,4 @@ async function getWorkflowRunsHandler({
390
454
  }
391
455
  }
392
456
 
393
- export { createWorkflowRunHandler, getWorkflowByIdHandler, getWorkflowRunByIdHandler, getWorkflowRunsHandler, getWorkflowsHandler, resumeAsyncWorkflowHandler, resumeWorkflowHandler, startAsyncWorkflowHandler, startWorkflowRunHandler, streamWorkflowHandler, watchWorkflowHandler, workflows_exports };
457
+ export { createWorkflowRunHandler, getWorkflowByIdHandler, getWorkflowRunByIdHandler, getWorkflowRunExecutionResultHandler, getWorkflowRunsHandler, getWorkflowsHandler, resumeAsyncWorkflowHandler, resumeWorkflowHandler, startAsyncWorkflowHandler, startWorkflowRunHandler, streamWorkflowHandler, watchWorkflowHandler, workflows_exports };
@@ -1,50 +1,54 @@
1
1
  'use strict';
2
2
 
3
- var chunkCDFOBFRS_cjs = require('../../chunk-CDFOBFRS.cjs');
3
+ var chunkFRXZL32L_cjs = require('../../chunk-FRXZL32L.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "createWorkflowRunHandler", {
8
8
  enumerable: true,
9
- get: function () { return chunkCDFOBFRS_cjs.createWorkflowRunHandler; }
9
+ get: function () { return chunkFRXZL32L_cjs.createWorkflowRunHandler; }
10
10
  });
11
11
  Object.defineProperty(exports, "getWorkflowByIdHandler", {
12
12
  enumerable: true,
13
- get: function () { return chunkCDFOBFRS_cjs.getWorkflowByIdHandler; }
13
+ get: function () { return chunkFRXZL32L_cjs.getWorkflowByIdHandler; }
14
14
  });
15
15
  Object.defineProperty(exports, "getWorkflowRunByIdHandler", {
16
16
  enumerable: true,
17
- get: function () { return chunkCDFOBFRS_cjs.getWorkflowRunByIdHandler; }
17
+ get: function () { return chunkFRXZL32L_cjs.getWorkflowRunByIdHandler; }
18
+ });
19
+ Object.defineProperty(exports, "getWorkflowRunExecutionResultHandler", {
20
+ enumerable: true,
21
+ get: function () { return chunkFRXZL32L_cjs.getWorkflowRunExecutionResultHandler; }
18
22
  });
19
23
  Object.defineProperty(exports, "getWorkflowRunsHandler", {
20
24
  enumerable: true,
21
- get: function () { return chunkCDFOBFRS_cjs.getWorkflowRunsHandler; }
25
+ get: function () { return chunkFRXZL32L_cjs.getWorkflowRunsHandler; }
22
26
  });
23
27
  Object.defineProperty(exports, "getWorkflowsHandler", {
24
28
  enumerable: true,
25
- get: function () { return chunkCDFOBFRS_cjs.getWorkflowsHandler; }
29
+ get: function () { return chunkFRXZL32L_cjs.getWorkflowsHandler; }
26
30
  });
27
31
  Object.defineProperty(exports, "resumeAsyncWorkflowHandler", {
28
32
  enumerable: true,
29
- get: function () { return chunkCDFOBFRS_cjs.resumeAsyncWorkflowHandler; }
33
+ get: function () { return chunkFRXZL32L_cjs.resumeAsyncWorkflowHandler; }
30
34
  });
31
35
  Object.defineProperty(exports, "resumeWorkflowHandler", {
32
36
  enumerable: true,
33
- get: function () { return chunkCDFOBFRS_cjs.resumeWorkflowHandler; }
37
+ get: function () { return chunkFRXZL32L_cjs.resumeWorkflowHandler; }
34
38
  });
35
39
  Object.defineProperty(exports, "startAsyncWorkflowHandler", {
36
40
  enumerable: true,
37
- get: function () { return chunkCDFOBFRS_cjs.startAsyncWorkflowHandler; }
41
+ get: function () { return chunkFRXZL32L_cjs.startAsyncWorkflowHandler; }
38
42
  });
39
43
  Object.defineProperty(exports, "startWorkflowRunHandler", {
40
44
  enumerable: true,
41
- get: function () { return chunkCDFOBFRS_cjs.startWorkflowRunHandler; }
45
+ get: function () { return chunkFRXZL32L_cjs.startWorkflowRunHandler; }
42
46
  });
43
47
  Object.defineProperty(exports, "streamWorkflowHandler", {
44
48
  enumerable: true,
45
- get: function () { return chunkCDFOBFRS_cjs.streamWorkflowHandler; }
49
+ get: function () { return chunkFRXZL32L_cjs.streamWorkflowHandler; }
46
50
  });
47
51
  Object.defineProperty(exports, "watchWorkflowHandler", {
48
52
  enumerable: true,
49
- get: function () { return chunkCDFOBFRS_cjs.watchWorkflowHandler; }
53
+ get: function () { return chunkFRXZL32L_cjs.watchWorkflowHandler; }
50
54
  });
@@ -1,6 +1,7 @@
1
1
  export { getWorkflowsHandler } from '../../_tsup-dts-rollup.cjs';
2
2
  export { getWorkflowByIdHandler } from '../../_tsup-dts-rollup.cjs';
3
3
  export { getWorkflowRunByIdHandler } from '../../_tsup-dts-rollup.cjs';
4
+ export { getWorkflowRunExecutionResultHandler } from '../../_tsup-dts-rollup.cjs';
4
5
  export { createWorkflowRunHandler } from '../../_tsup-dts-rollup.cjs';
5
6
  export { startAsyncWorkflowHandler } from '../../_tsup-dts-rollup.cjs';
6
7
  export { startWorkflowRunHandler } from '../../_tsup-dts-rollup.cjs';
@@ -1,6 +1,7 @@
1
1
  export { getWorkflowsHandler } from '../../_tsup-dts-rollup.js';
2
2
  export { getWorkflowByIdHandler } from '../../_tsup-dts-rollup.js';
3
3
  export { getWorkflowRunByIdHandler } from '../../_tsup-dts-rollup.js';
4
+ export { getWorkflowRunExecutionResultHandler } from '../../_tsup-dts-rollup.js';
4
5
  export { createWorkflowRunHandler } from '../../_tsup-dts-rollup.js';
5
6
  export { startAsyncWorkflowHandler } from '../../_tsup-dts-rollup.js';
6
7
  export { startWorkflowRunHandler } from '../../_tsup-dts-rollup.js';
@@ -1 +1 @@
1
- export { createWorkflowRunHandler, getWorkflowByIdHandler, getWorkflowRunByIdHandler, getWorkflowRunsHandler, getWorkflowsHandler, resumeAsyncWorkflowHandler, resumeWorkflowHandler, startAsyncWorkflowHandler, startWorkflowRunHandler, streamWorkflowHandler, watchWorkflowHandler } from '../../chunk-IO4OZY5S.js';
1
+ export { createWorkflowRunHandler, getWorkflowByIdHandler, getWorkflowRunByIdHandler, getWorkflowRunExecutionResultHandler, getWorkflowRunsHandler, getWorkflowsHandler, resumeAsyncWorkflowHandler, resumeWorkflowHandler, startAsyncWorkflowHandler, startWorkflowRunHandler, streamWorkflowHandler, watchWorkflowHandler } from '../../chunk-JKTNRUKY.js';
@@ -5,7 +5,7 @@ var chunkB4MQFJ7G_cjs = require('../chunk-B4MQFJ7G.cjs');
5
5
  var chunkNGURCFEJ_cjs = require('../chunk-NGURCFEJ.cjs');
6
6
  var chunkBNEY4P4P_cjs = require('../chunk-BNEY4P4P.cjs');
7
7
  var chunkCMMOIUFC_cjs = require('../chunk-CMMOIUFC.cjs');
8
- var chunkCDFOBFRS_cjs = require('../chunk-CDFOBFRS.cjs');
8
+ var chunkFRXZL32L_cjs = require('../chunk-FRXZL32L.cjs');
9
9
  var chunkSDPGVWQJ_cjs = require('../chunk-SDPGVWQJ.cjs');
10
10
  var chunk42YJ2YVD_cjs = require('../chunk-42YJ2YVD.cjs');
11
11
  var chunkWE32JG64_cjs = require('../chunk-WE32JG64.cjs');
@@ -36,7 +36,7 @@ Object.defineProperty(exports, "voice", {
36
36
  });
37
37
  Object.defineProperty(exports, "workflows", {
38
38
  enumerable: true,
39
- get: function () { return chunkCDFOBFRS_cjs.workflows_exports; }
39
+ get: function () { return chunkFRXZL32L_cjs.workflows_exports; }
40
40
  });
41
41
  Object.defineProperty(exports, "a2a", {
42
42
  enumerable: true,
@@ -3,7 +3,7 @@ export { telemetry_exports as telemetry } from '../chunk-BFOA2QQY.js';
3
3
  export { tools_exports as tools } from '../chunk-2HXKRRNS.js';
4
4
  export { vector_exports as vector } from '../chunk-55DOQLP6.js';
5
5
  export { voice_exports as voice } from '../chunk-CP55EVBK.js';
6
- export { workflows_exports as workflows } from '../chunk-IO4OZY5S.js';
6
+ export { workflows_exports as workflows } from '../chunk-JKTNRUKY.js';
7
7
  export { a2a_exports as a2a } from '../chunk-GHC4YV6R.js';
8
8
  export { agents_exports as agents } from '../chunk-O2YAAFY3.js';
9
9
  export { legacyWorkflows_exports as legacyWorkflows } from '../chunk-CLYX4KLH.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/server",
3
- "version": "0.10.6-alpha.0",
3
+ "version": "0.10.6-alpha.1",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "files": [
@@ -60,7 +60,7 @@
60
60
  "zod": "^3.25.57",
61
61
  "zod-to-json-schema": "^3.24.5",
62
62
  "@internal/lint": "0.0.12",
63
- "@mastra/core": "0.10.6-alpha.0"
63
+ "@mastra/core": "0.10.6-alpha.1"
64
64
  },
65
65
  "scripts": {
66
66
  "build": "tsup src/index.ts src/server/handlers.ts src/server/handlers/*.ts !src/server/handlers/*.test.ts --format esm,cjs --clean --experimental-dts --treeshake=smallest --splitting",