@mastra/temporal 0.5.0-alpha.3 → 0.6.0-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.
@@ -1,8 +1,26 @@
1
- import { executeChild, proxyActivities, log, sleep } from '@temporalio/workflow';
1
+ import {
2
+ condition,
3
+ defineQuery,
4
+ defineSignal,
5
+ executeChild,
6
+ proxyActivities,
7
+ log,
8
+ setHandler,
9
+ sleep,
10
+ } from '@temporalio/workflow';
11
+
12
+ const resumeSignal = defineSignal('mastra.resume');
13
+ const statusQuery = defineQuery('mastra.status');
2
14
 
3
15
  export class TemporalExecutionEngine {
4
16
  startToCloseTimeout;
5
17
  activityHandle;
18
+ resumePayloads = new Map();
19
+ suspendedSteps = new Set();
20
+ resumeLabels = new Map();
21
+ currentResult;
22
+ initData;
23
+ initialState;
6
24
 
7
25
  constructor(params) {
8
26
  this.startToCloseTimeout = params?.options?.startToCloseTimeout ?? '1 minute';
@@ -10,47 +28,129 @@ export class TemporalExecutionEngine {
10
28
  startToCloseTimeout: this.startToCloseTimeout,
11
29
  ...(params?.options?.retry !== undefined && { retry: params.options.retry }),
12
30
  });
31
+ setHandler(resumeSignal, payload => {
32
+ const id = this.resumeTarget(payload);
33
+ if (id !== undefined && !this.resumePayloads.has(id)) {
34
+ this.resumePayloads.set(id, payload);
35
+ }
36
+ });
37
+ setHandler(statusQuery, () => this.currentResult);
13
38
  }
14
39
 
15
40
  async execute(params) {
16
41
  this.initData = params.input;
42
+ this.initialState = params.initialState;
17
43
  this.executionContext = {
18
44
  ...(params.requestContext !== undefined && { requestContext: params.requestContext }),
19
45
  ...(params.runId !== undefined && { runId: params.runId }),
20
46
  ...(params.resourceId !== undefined && { resourceId: params.resourceId }),
21
- validateInputs: params.validateInputs,
47
+ ...(params.validateInputs !== undefined && { validateInputs: params.validateInputs }),
22
48
  workflowId: params.workflowId,
23
49
  };
24
- // Step times let start() build Mastra step records. Only recorded on request so runs that
25
- // never read them (startAsync, runs started before the field existed) keep their result size.
26
- this.stepMeta = params.recordStepMeta ? {} : undefined;
27
50
  let result = params.input;
28
51
  const stepResults = {};
52
+ this.currentResult = {
53
+ status: 'running',
54
+ input: params.input,
55
+ state: params.initialState,
56
+ steps: stepResults,
57
+ };
29
58
 
30
59
  for (const entry of params.graph.steps) {
31
60
  result = await this.executeEntry(entry, result, stepResults);
32
61
  }
33
62
 
34
- return {
63
+ this.currentResult = {
35
64
  status: 'success',
36
65
  input: params.input,
37
66
  result,
38
67
  state: params.initialState,
39
68
  steps: stepResults,
40
- ...(this.stepMeta && { stepMeta: this.stepMeta }),
41
69
  };
70
+ return this.currentResult;
42
71
  }
43
72
 
44
- // Runs one timed entry and stores its output under `id`. Date.now() in Workflow code is the
45
- // Workflow Task time, which replay reads from history.
46
- async timed(stepResults, id, run) {
73
+ resumeTarget(payload) {
74
+ if (payload?.step !== undefined) {
75
+ return this.suspendedSteps.has(payload.step) ? payload.step : undefined;
76
+ }
77
+ if (payload?.label !== undefined) {
78
+ const labeledStep = this.resumeLabels.get(payload.label);
79
+ return labeledStep !== undefined && this.suspendedSteps.has(labeledStep) ? labeledStep : undefined;
80
+ }
81
+ return this.suspendedSteps.size === 1 ? [...this.suspendedSteps][0] : undefined;
82
+ }
83
+
84
+ // Record steps in the core StepResult shape ({ status, payload, output, startedAt, endedAt }).
85
+ async recordStep(stepResults, id, payload, run) {
47
86
  const startedAt = Date.now();
48
- const out = await run();
49
- stepResults[id] = out;
50
- if (this.stepMeta) {
51
- this.stepMeta[id] = { startedAt, endedAt: Date.now() };
87
+ let output = await run();
88
+ let suspendPayload;
89
+ let resumeData;
90
+
91
+ while (output?.__temporalSuspension === true) {
92
+ suspendPayload = output.suspendPayload;
93
+ stepResults[id] = {
94
+ __temporalStepResult: true,
95
+ status: 'suspended',
96
+ payload,
97
+ suspendPayload,
98
+ suspendedAt: Date.now(),
99
+ };
100
+ for (const [label, target] of Object.entries(output.resumeLabels ?? {})) {
101
+ if (target?.stepId === id) {
102
+ this.resumeLabels.set(label, id);
103
+ }
104
+ }
105
+ this.currentResult = {
106
+ status: 'suspended',
107
+ input: this.initData,
108
+ state: this.initialState,
109
+ steps: stepResults,
110
+ suspended: [[id]],
111
+ suspendPayload: { [id]: suspendPayload },
112
+ resumeLabels: Object.fromEntries([...this.resumeLabels].map(([label, stepId]) => [label, { stepId }])),
113
+ };
114
+
115
+ this.suspendedSteps.add(id);
116
+ try {
117
+ await condition(() => this.resumePayloads.has(id));
118
+ resumeData = this.resumePayloads.get(id)?.resumeData;
119
+ this.resumePayloads.delete(id);
120
+ } finally {
121
+ this.suspendedSteps.delete(id);
122
+ for (const [label, stepId] of this.resumeLabels.entries()) {
123
+ if (stepId === id) {
124
+ this.resumeLabels.delete(label);
125
+ }
126
+ }
127
+ }
128
+ this.currentResult = {
129
+ status: 'running',
130
+ input: this.initData,
131
+ state: this.initialState,
132
+ steps: stepResults,
133
+ };
134
+ output = await run(resumeData);
52
135
  }
53
- return out;
136
+
137
+ stepResults[id] = {
138
+ __temporalStepResult: true,
139
+ status: 'success',
140
+ payload,
141
+ output,
142
+ ...(suspendPayload !== undefined && { suspendPayload }),
143
+ ...(resumeData !== undefined && { resumeData }),
144
+ startedAt,
145
+ endedAt: Date.now(),
146
+ };
147
+ this.currentResult = {
148
+ status: 'running',
149
+ input: this.initData,
150
+ state: this.initialState,
151
+ steps: stepResults,
152
+ };
153
+ return output;
54
154
  }
55
155
 
56
156
  activityParams(inputData, extra = {}) {
@@ -61,14 +161,19 @@ export class TemporalExecutionEngine {
61
161
  switch (entry.type) {
62
162
  case 'step': {
63
163
  log.info('step', { stepId: entry.step.id });
64
- return this.timed(stepResults, entry.step.id, () =>
65
- this.activityHandle[entry.step.id](this.activityParams(inputData, { initData: this.initData })),
164
+ return this.recordStep(stepResults, entry.step.id, inputData, resumeData =>
165
+ this.activityHandle[entry.step.id](
166
+ this.activityParams(inputData, {
167
+ initData: this.initData,
168
+ ...(resumeData !== undefined && { resumeData }),
169
+ }),
170
+ ),
66
171
  );
67
172
  }
68
173
 
69
174
  case 'childWorkflow': {
70
175
  log.info('childWorkflow', { workflowType: entry.workflowType });
71
- return this.timed(stepResults, entry.id, async () => {
176
+ return this.recordStep(stepResults, entry.id ?? entry.workflowType, inputData, async () => {
72
177
  const childResult = await executeChild(entry.workflowType, {
73
178
  args: [{ inputData, ...this.executionContext }],
74
179
  });
@@ -78,7 +183,7 @@ export class TemporalExecutionEngine {
78
183
 
79
184
  case 'mapping': {
80
185
  log.info('mapping', { mappingId: entry.id });
81
- return this.timed(stepResults, entry.id, () =>
186
+ return this.recordStep(stepResults, entry.id, inputData, () =>
82
187
  this.activityHandle[entry.id](this.activityParams(inputData, { initData: this.initData })),
83
188
  );
84
189
  }
@@ -105,8 +210,6 @@ export class TemporalExecutionEngine {
105
210
  }
106
211
 
107
212
  case 'parallel': {
108
- // The next step keeps reading a nested workflow under its Temporal type name, as before.
109
- // Only the step records use the Mastra id.
110
213
  const entryId = parallelEntry =>
111
214
  parallelEntry.type === 'childWorkflow' ? parallelEntry.workflowType : parallelEntry.step.id;
112
215
  log.info('parallel', { steps: entry.steps.map(entryId) });
@@ -134,8 +237,13 @@ export class TemporalExecutionEngine {
134
237
  for (let i = 0; i < entry.steps.length; i++) {
135
238
  if (condResults[i]) {
136
239
  const stepId = entry.steps[i].step.id;
137
- out[stepId] = await this.timed(stepResults, stepId, () =>
138
- this.activityHandle[stepId](this.activityParams(inputData, { initData: this.initData })),
240
+ out[stepId] = await this.recordStep(stepResults, stepId, inputData, resumeData =>
241
+ this.activityHandle[stepId](
242
+ this.activityParams(inputData, {
243
+ initData: this.initData,
244
+ ...(resumeData !== undefined && { resumeData }),
245
+ }),
246
+ ),
139
247
  );
140
248
  }
141
249
  }
@@ -148,9 +256,14 @@ export class TemporalExecutionEngine {
148
256
  let current = inputData;
149
257
 
150
258
  while (true) {
151
- const stepInput = current;
152
- current = await this.timed(stepResults, entry.step.id, () =>
153
- this.activityHandle[entry.step.id](this.activityParams(stepInput, { initData: this.initData })),
259
+ const payload = current;
260
+ current = await this.recordStep(stepResults, entry.step.id, payload, resumeData =>
261
+ this.activityHandle[entry.step.id](
262
+ this.activityParams(payload, {
263
+ initData: this.initData,
264
+ ...(resumeData !== undefined && { resumeData }),
265
+ }),
266
+ ),
154
267
  );
155
268
  const shouldContinue = Boolean(
156
269
  await this.activityHandle[entry.serializedCondition.id](this.activityParams(current)),
@@ -173,24 +286,31 @@ export class TemporalExecutionEngine {
173
286
  : (entry.opts.concurrency ?? 1);
174
287
  const concurrency = Number.isFinite(configured) ? Math.max(1, Math.floor(configured)) : 1;
175
288
  log.info('foreach', { step: entry.step.id, concurrency });
176
- return this.timed(stepResults, entry.step.id, async () => {
177
- const results = new Array(items.length);
178
- let index = 0;
179
- const workers = Array.from({ length: Math.min(concurrency, items.length) }, async () => {
180
- while (true) {
181
- const i = index++;
182
- if (i >= items.length) {
183
- break;
184
- }
185
- results[i] = await this.activityHandle[entry.step.id](
186
- this.activityParams(items[i], { initData: this.initData }),
187
- );
289
+ const startedAt = Date.now();
290
+ const results = new Array(items.length);
291
+ let index = 0;
292
+ const workers = Array.from({ length: Math.min(concurrency, items.length) }, async () => {
293
+ while (true) {
294
+ const i = index++;
295
+ if (i >= items.length) {
296
+ break;
188
297
  }
189
- });
190
-
191
- await Promise.all(workers);
192
- return results;
298
+ results[i] = await this.activityHandle[entry.step.id](
299
+ this.activityParams(items[i], { initData: this.initData }),
300
+ );
301
+ }
193
302
  });
303
+
304
+ await Promise.all(workers);
305
+ stepResults[entry.step.id] = {
306
+ __temporalStepResult: true,
307
+ status: 'success',
308
+ payload: inputData,
309
+ output: results,
310
+ startedAt,
311
+ endedAt: Date.now(),
312
+ };
313
+ return results;
194
314
  }
195
315
 
196
316
  default:
@@ -220,7 +340,6 @@ export function createWorkflow(workflowId, options) {
220
340
  },
221
341
  input: startArgs?.inputData,
222
342
  initialState: startArgs?.initialState,
223
- recordStepMeta: startArgs?.recordStepMeta,
224
343
  });
225
344
  };
226
345
 
@@ -1 +1 @@
1
- {"version":3,"file":"activities.d.ts","sourceRoot":"","sources":["../../src/transforms/activities.ts"],"names":[],"mappings":"AA0BA,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,mCAAmC;IAClD,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,uBAAuB,EAAE,CAAC;CAC7C;AAED,wBAAgB,+BAA+B,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,uBAAuB,EAAE,CAmE/G;AAoSD,wBAAsB,6BAA6B,CACjD,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,EACvB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,mCAAmC,CAAC,CAoZ9C"}
1
+ {"version":3,"file":"activities.d.ts","sourceRoot":"","sources":["../../src/transforms/activities.ts"],"names":[],"mappings":"AA0BA,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,mCAAmC;IAClD,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,uBAAuB,EAAE,CAAC;CAC7C;AAED,wBAAgB,+BAA+B,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,uBAAuB,EAAE,CAmE/G;AAkUD,wBAAsB,6BAA6B,CACjD,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,EACvB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,mCAAmC,CAAC,CAoZ9C"}
@@ -1,25 +1,23 @@
1
1
  export declare class TemporalExecutionEngine {
2
- initData: any;
3
2
  executionContext: {
4
3
  requestContext?: any;
5
4
  runId?: any;
6
5
  resourceId?: any;
7
- validateInputs: any;
6
+ validateInputs?: any;
8
7
  workflowId: any;
9
8
  } | undefined;
10
- stepMeta: {} | undefined;
11
9
  startToCloseTimeout: any;
12
10
  activityHandle: import("@temporalio/workflow").ActivityInterfaceFor<import("@temporalio/workflow").UntypedActivities>;
11
+ resumePayloads: Map<any, any>;
12
+ suspendedSteps: Set<any>;
13
+ resumeLabels: Map<any, any>;
14
+ currentResult: any;
15
+ initData: any;
16
+ initialState: any;
13
17
  constructor(params: any);
14
- execute(params: any): Promise<{
15
- status: string;
16
- input: any;
17
- result: any;
18
- state: any;
19
- steps: {};
20
- stepMeta?: {} | undefined;
21
- }>;
22
- timed(stepResults: any, id: any, run: any): Promise<any>;
18
+ execute(params: any): Promise<any>;
19
+ resumeTarget(payload: any): any;
20
+ recordStep(stepResults: any, id: any, payload: any, run: any): Promise<any>;
23
21
  activityParams(inputData: any, extra?: {}): {
24
22
  requestContext?: any;
25
23
  runId?: any;
@@ -30,101 +28,17 @@ export declare class TemporalExecutionEngine {
30
28
  };
31
29
  executeEntry(entry: any, inputData: any, stepResults: any): Promise<any>;
32
30
  }
33
- export declare function createWorkflow(workflowId: any, options: any): ((startArgs: any) => Promise<{
34
- status: string;
35
- input: any;
36
- result: any;
37
- state: any;
38
- steps: {};
39
- stepMeta?: {} | undefined;
40
- }>) & {
41
- then(stepId: any): (startArgs: any) => Promise<{
42
- status: string;
43
- input: any;
44
- result: any;
45
- state: any;
46
- steps: {};
47
- stepMeta?: {} | undefined;
48
- }>;
49
- thenWorkflow(workflowType: any, id: any): (startArgs: any) => Promise<{
50
- status: string;
51
- input: any;
52
- result: any;
53
- state: any;
54
- steps: {};
55
- stepMeta?: {} | undefined;
56
- }>;
57
- map(mappingId: any): (startArgs: any) => Promise<{
58
- status: string;
59
- input: any;
60
- result: any;
61
- state: any;
62
- steps: {};
63
- stepMeta?: {} | undefined;
64
- }>;
65
- sleep(durationOrFnId: any): (startArgs: any) => Promise<{
66
- status: string;
67
- input: any;
68
- result: any;
69
- state: any;
70
- steps: {};
71
- stepMeta?: {} | undefined;
72
- }>;
73
- sleepUntil(dateOrFnId: any): (startArgs: any) => Promise<{
74
- status: string;
75
- input: any;
76
- result: any;
77
- state: any;
78
- steps: {};
79
- stepMeta?: {} | undefined;
80
- }>;
81
- parallel(entries: any): (startArgs: any) => Promise<{
82
- status: string;
83
- input: any;
84
- result: any;
85
- state: any;
86
- steps: {};
87
- stepMeta?: {} | undefined;
88
- }>;
89
- branch(pairs: any): (startArgs: any) => Promise<{
90
- status: string;
91
- input: any;
92
- result: any;
93
- state: any;
94
- steps: {};
95
- stepMeta?: {} | undefined;
96
- }>;
97
- dowhile(stepId: any, condId: any): (startArgs: any) => Promise<{
98
- status: string;
99
- input: any;
100
- result: any;
101
- state: any;
102
- steps: {};
103
- stepMeta?: {} | undefined;
104
- }>;
105
- dountil(stepId: any, condId: any): (startArgs: any) => Promise<{
106
- status: string;
107
- input: any;
108
- result: any;
109
- state: any;
110
- steps: {};
111
- stepMeta?: {} | undefined;
112
- }>;
113
- foreach(stepId: any, opts: any): (startArgs: any) => Promise<{
114
- status: string;
115
- input: any;
116
- result: any;
117
- state: any;
118
- steps: {};
119
- stepMeta?: {} | undefined;
120
- }>;
121
- commit(): (startArgs: any) => Promise<{
122
- status: string;
123
- input: any;
124
- result: any;
125
- state: any;
126
- steps: {};
127
- stepMeta?: {} | undefined;
128
- }>;
31
+ export declare function createWorkflow(workflowId: any, options: any): ((startArgs: any) => Promise<any>) & {
32
+ then(stepId: any): (startArgs: any) => Promise<any>;
33
+ thenWorkflow(workflowType: any, id: any): (startArgs: any) => Promise<any>;
34
+ map(mappingId: any): (startArgs: any) => Promise<any>;
35
+ sleep(durationOrFnId: any): (startArgs: any) => Promise<any>;
36
+ sleepUntil(dateOrFnId: any): (startArgs: any) => Promise<any>;
37
+ parallel(entries: any): (startArgs: any) => Promise<any>;
38
+ branch(pairs: any): (startArgs: any) => Promise<any>;
39
+ dowhile(stepId: any, condId: any): (startArgs: any) => Promise<any>;
40
+ dountil(stepId: any, condId: any): (startArgs: any) => Promise<any>;
41
+ foreach(stepId: any, opts: any): (startArgs: any) => Promise<any>;
42
+ commit(): (startArgs: any) => Promise<any>;
129
43
  };
130
44
  //# sourceMappingURL=temporal-workflow-runtime.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"temporal-workflow-runtime.d.mts","sourceRoot":"","sources":["../../src/transforms/temporal-workflow-runtime.mjs"],"names":[],"mappings":"AAEA,qBAAa,uBAAuB;IAa3B,QAAQ;IACR,gBAAgB;;;;;;;IAShB,QAAQ;IAtBf,mBAAmB,MAAC;IACpB,cAAc,wGAAC;IAEf,YAAY,MAAM,KAAA,EAMjB;IAEK,OAAO,CAAC,MAAM,KAAA;;;;;;;OA2BnB;IAIK,KAAK,CAAC,WAAW,KAAA,EAAE,EAAE,KAAA,EAAE,GAAG,KAAA,gBAQ/B;IAED,cAAc,CAAC,SAAS,KAAA,EAAE,KAAK,KAAK;;;;;;;MAEnC;IAEK,YAAY,CAAC,KAAK,KAAA,EAAE,SAAS,KAAA,EAAE,WAAW,KAAA,gBA2I/C;CACF;AAED,wBAAgB,cAAc,CAAC,UAAU,KAAA,EAAE,OAAO,KAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwJjD"}
1
+ {"version":3,"file":"temporal-workflow-runtime.d.mts","sourceRoot":"","sources":["../../src/transforms/temporal-workflow-runtime.mjs"],"names":[],"mappings":"AAcA,qBAAa,uBAAuB;IA4B3B,gBAAgB;;;;;;;IA3BvB,mBAAmB,MAAC;IACpB,cAAc,wGAAC;IACf,cAAc,gBAAa;IAC3B,cAAc,WAAa;IAC3B,YAAY,gBAAa;IACzB,aAAa,MAAC;IACd,QAAQ,MAAC;IACT,YAAY,MAAC;IAEb,YAAY,MAAM,KAAA,EAajB;IAEK,OAAO,CAAC,MAAM,KAAA,gBA+BnB;IAED,YAAY,CAAC,OAAO,KAAA,OASnB;IAGK,UAAU,CAAC,WAAW,KAAA,EAAE,EAAE,KAAA,EAAE,OAAO,KAAA,EAAE,GAAG,KAAA,gBAqE7C;IAED,cAAc,CAAC,SAAS,KAAA,EAAE,KAAK,KAAK;;;;;;;MAEnC;IAEK,YAAY,CAAC,KAAK,KAAA,EAAE,SAAS,KAAA,EAAE,WAAW,KAAA,gBA+J/C;CACF;AAED,wBAAgB,cAAc,CAAC,UAAU,KAAA,EAAE,OAAO,KAAA;;;;;;;;;;;;EAuJjD"}
package/dist/worker.cjs CHANGED
@@ -427,24 +427,55 @@ function hasLocalMastraBinding(ast) {
427
427
  }
428
428
  function createTemporalActivitiesHelperStatements(mastraImportPath, hasMastraBinding, requestContextClassName) {
429
429
  const helperSource = `
430
- function withRequestContext(params) {
430
+ function withRequestContext(params, args) {
431
431
  const { requestContext, initData, ...rest } = params;
432
+ let suspended;
432
433
  return {
433
434
  ...rest,
434
435
  requestContext: new ${requestContextClassName}(requestContext),
435
436
  getInitData: () => initData,
437
+ suspend: async (suspendPayload, options) => {
438
+ const parsedSuspendPayload = await parseWithSchema(args.suspendSchema, suspendPayload, 'Suspend payload');
439
+ suspended = {
440
+ __temporalSuspension: true,
441
+ suspendPayload: parsedSuspendPayload,
442
+ ...(options?.resumeLabel !== undefined && { resumeLabel: options.resumeLabel }),
443
+ };
444
+ },
445
+ __getTemporalSuspension: () => suspended,
436
446
  };
437
447
  }
438
448
 
449
+ async function parseWithSchema(schema, value, label) {
450
+ if (!schema) return value;
451
+ if (schema['~standard']?.validate) {
452
+ const result = await schema['~standard'].validate(value);
453
+ if ('issues' in result && result.issues?.length) {
454
+ throw new Error(label + ' validation failed: ' + result.issues.map(issue => issue.message).join(', '));
455
+ }
456
+ return result.value;
457
+ }
458
+ if (typeof schema.parseAsync === 'function') return schema.parseAsync(value);
459
+ if (typeof schema.parse === 'function') return schema.parse(value);
460
+ return value;
461
+ }
462
+
463
+ async function executeTemporalStep(args, context) {
464
+ const result = await args.execute(context);
465
+ return context.__getTemporalSuspension() ?? result;
466
+ }
467
+
439
468
  function createStep(args) {
440
469
  return {
441
470
  inputSchema: args.inputSchema,
442
471
  requestContextSchema: args.requestContextSchema,
472
+ suspendSchema: args.suspendSchema,
473
+ resumeSchema: args.resumeSchema,
443
474
  execute: async (params) => {
444
475
  ${mastraImportPath ? `
445
476
  const { mastra } = await import(${JSON.stringify(mastraImportPath)});
446
- return args.execute({ ...withRequestContext(params), mastra });
447
- ` : hasMastraBinding ? "return args.execute({ ...withRequestContext(params), mastra });" : "return args.execute(withRequestContext(params));"}
477
+ return executeTemporalStep(args, { ...withRequestContext(params, args), mastra });
478
+ ` : hasMastraBinding ? "return executeTemporalStep(args, { ...withRequestContext(params, args), mastra });" : "return executeTemporalStep(args, withRequestContext(params, args));"}
448
479
  },
449
480
  };
450
481
  }