@mastra/inngest 0.0.0-just-snapshot-20251014192224 → 0.0.0-main-test-05-11-2025-2-20251105214713

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.
package/dist/index.js CHANGED
@@ -1,9 +1,11 @@
1
1
  import { randomUUID } from 'crypto';
2
+ import { ReadableStream } from 'stream/web';
2
3
  import { subscribe } from '@inngest/realtime';
3
- import { wrapMastra, AISpanType } from '@mastra/core/ai-tracing';
4
- import { RuntimeContext } from '@mastra/core/di';
4
+ import { RequestContext } from '@mastra/core/di';
5
+ import { wrapMastra, SpanType } from '@mastra/core/observability';
6
+ import { ChunkFrom, WorkflowRunOutput } from '@mastra/core/stream';
5
7
  import { ToolStream, Tool } from '@mastra/core/tools';
6
- import { Run, Workflow, DefaultExecutionEngine, getStepResult, validateStepInput } from '@mastra/core/workflows';
8
+ import { Run, Workflow, DefaultExecutionEngine, createDeprecationProxy, getStepResult, runCountDeprecationMessage, validateStepInput } from '@mastra/core/workflows';
7
9
  import { EMITTER_SYMBOL, STREAM_FORMAT_SYMBOL } from '@mastra/core/workflows/_constants';
8
10
  import { NonRetriableError, RetryAfterError } from 'inngest';
9
11
  import { serve as serve$1 } from 'inngest/hono';
@@ -16,7 +18,7 @@ function serve({
16
18
  functions: userFunctions = [],
17
19
  registerOptions
18
20
  }) {
19
- const wfs = mastra.getWorkflows();
21
+ const wfs = mastra.listWorkflows();
20
22
  const workflowFunctions = Array.from(
21
23
  new Set(
22
24
  Object.values(wfs).flatMap((wf) => {
@@ -55,11 +57,12 @@ var InngestRun = class extends Run {
55
57
  }
56
58
  async getRunOutput(eventId) {
57
59
  let runs = await this.getRuns(eventId);
60
+ const storage = this.#mastra?.getStorage();
58
61
  while (runs?.[0]?.status !== "Completed" || runs?.[0]?.event_id !== eventId) {
59
62
  await new Promise((resolve) => setTimeout(resolve, 1e3));
60
63
  runs = await this.getRuns(eventId);
61
64
  if (runs?.[0]?.status === "Failed") {
62
- const snapshot = await this.#mastra?.storage?.loadWorkflowSnapshot({
65
+ const snapshot = await storage?.loadWorkflowSnapshot({
63
66
  workflowName: this.workflowId,
64
67
  runId: this.runId
65
68
  });
@@ -68,7 +71,7 @@ var InngestRun = class extends Run {
68
71
  };
69
72
  }
70
73
  if (runs?.[0]?.status === "Cancelled") {
71
- const snapshot = await this.#mastra?.storage?.loadWorkflowSnapshot({
74
+ const snapshot = await storage?.loadWorkflowSnapshot({
72
75
  workflowName: this.workflowId,
73
76
  runId: this.runId
74
77
  });
@@ -77,25 +80,20 @@ var InngestRun = class extends Run {
77
80
  }
78
81
  return runs?.[0];
79
82
  }
80
- async sendEvent(event, data) {
81
- await this.inngest.send({
82
- name: `user-event-${event}`,
83
- data
84
- });
85
- }
86
83
  async cancel() {
84
+ const storage = this.#mastra?.getStorage();
87
85
  await this.inngest.send({
88
86
  name: `cancel.workflow.${this.workflowId}`,
89
87
  data: {
90
88
  runId: this.runId
91
89
  }
92
90
  });
93
- const snapshot = await this.#mastra?.storage?.loadWorkflowSnapshot({
91
+ const snapshot = await storage?.loadWorkflowSnapshot({
94
92
  workflowName: this.workflowId,
95
93
  runId: this.runId
96
94
  });
97
95
  if (snapshot) {
98
- await this.#mastra?.storage?.persistWorkflowSnapshot({
96
+ await storage?.persistWorkflowSnapshot({
99
97
  workflowName: this.workflowId,
100
98
  runId: this.runId,
101
99
  resourceId: this.resourceId,
@@ -106,9 +104,15 @@ var InngestRun = class extends Run {
106
104
  });
107
105
  }
108
106
  }
109
- async start({
107
+ async start(params) {
108
+ return this._start(params);
109
+ }
110
+ async _start({
110
111
  inputData,
111
- initialState
112
+ initialState,
113
+ outputOptions,
114
+ tracingOptions,
115
+ format
112
116
  }) {
113
117
  await this.#mastra.getStorage()?.persistWorkflowSnapshot({
114
118
  workflowName: this.workflowId,
@@ -121,6 +125,7 @@ var InngestRun = class extends Run {
121
125
  context: {},
122
126
  activePaths: [],
123
127
  suspendedPaths: {},
128
+ resumeLabels: {},
124
129
  waitingPaths: {},
125
130
  timestamp: Date.now(),
126
131
  status: "running"
@@ -134,7 +139,10 @@ var InngestRun = class extends Run {
134
139
  inputData: inputDataToUse,
135
140
  initialState: initialStateToUse,
136
141
  runId: this.runId,
137
- resourceId: this.resourceId
142
+ resourceId: this.resourceId,
143
+ outputOptions,
144
+ tracingOptions,
145
+ format
138
146
  }
139
147
  });
140
148
  const eventId = eventOutput.ids[0];
@@ -163,10 +171,11 @@ var InngestRun = class extends Run {
163
171
  return p;
164
172
  }
165
173
  async _resume(params) {
174
+ const storage = this.#mastra?.getStorage();
166
175
  const steps = (Array.isArray(params.step) ? params.step : [params.step]).map(
167
176
  (step) => typeof step === "string" ? step : step?.id
168
177
  );
169
- const snapshot = await this.#mastra?.storage?.loadWorkflowSnapshot({
178
+ const snapshot = await storage?.loadWorkflowSnapshot({
170
179
  workflowName: this.workflowId,
171
180
  runId: this.runId
172
181
  });
@@ -200,12 +209,12 @@ var InngestRun = class extends Run {
200
209
  }
201
210
  return result;
202
211
  }
203
- watch(cb, type = "watch") {
212
+ watch(cb) {
204
213
  let active = true;
205
214
  const streamPromise = subscribe(
206
215
  {
207
216
  channel: `workflow:${this.workflowId}:${this.runId}`,
208
- topics: [type],
217
+ topics: ["watch"],
209
218
  app: this.inngest
210
219
  },
211
220
  (message) => {
@@ -223,20 +232,35 @@ var InngestRun = class extends Run {
223
232
  });
224
233
  };
225
234
  }
226
- stream({ inputData, runtimeContext } = {}) {
235
+ streamLegacy({ inputData, requestContext } = {}) {
227
236
  const { readable, writable } = new TransformStream();
228
237
  const writer = writable.getWriter();
229
238
  const unwatch = this.watch(async (event) => {
230
239
  try {
240
+ await writer.write({
241
+ // @ts-ignore
242
+ type: "start",
243
+ // @ts-ignore
244
+ payload: { runId: this.runId }
245
+ });
231
246
  const e = {
232
247
  ...event,
233
248
  type: event.type.replace("workflow-", "")
234
249
  };
250
+ if (e.type === "step-output") {
251
+ e.type = e.payload.output.type;
252
+ e.payload = e.payload.output.payload;
253
+ }
235
254
  await writer.write(e);
236
255
  } catch {
237
256
  }
238
- }, "watch-v2");
257
+ });
239
258
  this.closeStreamAction = async () => {
259
+ await writer.write({
260
+ type: "finish",
261
+ // @ts-ignore
262
+ payload: { runId: this.runId }
263
+ });
240
264
  unwatch();
241
265
  try {
242
266
  await writer.close();
@@ -246,7 +270,7 @@ var InngestRun = class extends Run {
246
270
  writer.releaseLock();
247
271
  }
248
272
  };
249
- this.executionResults = this.start({ inputData, runtimeContext }).then((result) => {
273
+ this.executionResults = this._start({ inputData, requestContext, format: "legacy" }).then((result) => {
250
274
  if (result.status !== "suspended") {
251
275
  this.closeStreamAction?.().catch(() => {
252
276
  });
@@ -258,6 +282,82 @@ var InngestRun = class extends Run {
258
282
  getWorkflowState: () => this.executionResults
259
283
  };
260
284
  }
285
+ stream({
286
+ inputData,
287
+ requestContext,
288
+ tracingOptions,
289
+ closeOnSuspend = true,
290
+ initialState,
291
+ outputOptions
292
+ } = {}) {
293
+ if (this.closeStreamAction && this.streamOutput) {
294
+ return this.streamOutput;
295
+ }
296
+ this.closeStreamAction = async () => {
297
+ };
298
+ const self = this;
299
+ const stream = new ReadableStream({
300
+ async start(controller) {
301
+ const unwatch = self.watch(async ({ type, from = ChunkFrom.WORKFLOW, payload }) => {
302
+ controller.enqueue({
303
+ type,
304
+ runId: self.runId,
305
+ from,
306
+ payload: {
307
+ stepName: payload?.id,
308
+ ...payload
309
+ }
310
+ });
311
+ });
312
+ self.closeStreamAction = async () => {
313
+ unwatch();
314
+ try {
315
+ await controller.close();
316
+ } catch (err) {
317
+ console.error("Error closing stream:", err);
318
+ }
319
+ };
320
+ const executionResultsPromise = self._start({
321
+ inputData,
322
+ requestContext,
323
+ // tracingContext, // We are not able to pass a reference to a span here, what to do?
324
+ initialState,
325
+ tracingOptions,
326
+ outputOptions,
327
+ format: "vnext"
328
+ });
329
+ let executionResults;
330
+ try {
331
+ executionResults = await executionResultsPromise;
332
+ if (closeOnSuspend) {
333
+ self.closeStreamAction?.().catch(() => {
334
+ });
335
+ } else if (executionResults.status !== "suspended") {
336
+ self.closeStreamAction?.().catch(() => {
337
+ });
338
+ }
339
+ if (self.streamOutput) {
340
+ self.streamOutput.updateResults(
341
+ executionResults
342
+ );
343
+ }
344
+ } catch (err) {
345
+ self.streamOutput?.rejectResults(err);
346
+ self.closeStreamAction?.().catch(() => {
347
+ });
348
+ }
349
+ }
350
+ });
351
+ this.streamOutput = new WorkflowRunOutput({
352
+ runId: this.runId,
353
+ workflowId: this.workflowId,
354
+ stream
355
+ });
356
+ return this.streamOutput;
357
+ }
358
+ streamVNext(args = {}) {
359
+ return this.stream(args);
360
+ }
261
361
  };
262
362
  var InngestWorkflow = class _InngestWorkflow extends Workflow {
263
363
  #mastra;
@@ -274,13 +374,13 @@ var InngestWorkflow = class _InngestWorkflow extends Workflow {
274
374
  this.#mastra = params.mastra;
275
375
  this.inngest = inngest;
276
376
  }
277
- async getWorkflowRuns(args) {
377
+ async listWorkflowRuns(args) {
278
378
  const storage = this.#mastra?.getStorage();
279
379
  if (!storage) {
280
380
  this.logger.debug("Cannot get workflow runs. Mastra engine is not initialized");
281
381
  return { runs: [], total: 0 };
282
382
  }
283
- return storage.getWorkflowRuns({ workflowName: this.id, ...args ?? {} });
383
+ return storage.listWorkflowRuns({ workflowName: this.id, ...args ?? {} });
284
384
  }
285
385
  async getWorkflowRunById(runId) {
286
386
  const storage = this.#mastra?.getStorage();
@@ -309,16 +409,7 @@ var InngestWorkflow = class _InngestWorkflow extends Workflow {
309
409
  }
310
410
  }
311
411
  }
312
- /**
313
- * @deprecated Use createRunAsync() instead.
314
- * @throws {Error} Always throws an error directing users to use createRunAsync()
315
- */
316
- createRun(_options) {
317
- throw new Error(
318
- "createRun() has been deprecated. Please use createRunAsync() instead.\n\nMigration guide:\n Before: const run = workflow.createRun();\n After: const run = await workflow.createRunAsync();\n\nNote: createRunAsync() is an async method, so make sure your calling function is async."
319
- );
320
- }
321
- async createRunAsync(options) {
412
+ async createRun(options) {
322
413
  const runIdToUse = options?.runId || randomUUID();
323
414
  const run = this.runs.get(runIdToUse) ?? new InngestRun(
324
415
  {
@@ -355,6 +446,7 @@ var InngestWorkflow = class _InngestWorkflow extends Workflow {
355
446
  waitingPaths: {},
356
447
  serializedStepGraph: this.serializedStepGraph,
357
448
  suspendedPaths: {},
449
+ resumeLabels: {},
358
450
  result: void 0,
359
451
  error: void 0,
360
452
  // @ts-ignore
@@ -379,7 +471,7 @@ var InngestWorkflow = class _InngestWorkflow extends Workflow {
379
471
  },
380
472
  { event: `workflow.${this.id}` },
381
473
  async ({ event, step, attempt, publish }) => {
382
- let { inputData, initialState, runId, resourceId, resume, outputOptions } = event.data;
474
+ let { inputData, initialState, runId, resourceId, resume, outputOptions, format } = event.data;
383
475
  if (!runId) {
384
476
  runId = await step.run(`workflow.${this.id}.runIdGen`, async () => {
385
477
  return randomUUID();
@@ -418,13 +510,19 @@ var InngestWorkflow = class _InngestWorkflow extends Workflow {
418
510
  initialState,
419
511
  emitter,
420
512
  retryConfig: this.retryConfig,
421
- runtimeContext: new RuntimeContext(),
513
+ requestContext: new RequestContext(),
422
514
  // TODO
423
515
  resume,
516
+ format,
424
517
  abortController: new AbortController(),
425
- currentSpan: void 0,
426
- // TODO: Pass actual parent AI span from workflow execution context
427
- outputOptions
518
+ // currentSpan: undefined, // TODO: Pass actual parent Span from workflow execution context
519
+ outputOptions,
520
+ writableStream: new WritableStream({
521
+ write(chunk) {
522
+ void emitter.emit("watch", chunk).catch(() => {
523
+ });
524
+ }
525
+ })
428
526
  });
429
527
  await step.run(`workflow.${this.id}.finalize`, async () => {
430
528
  if (result.status === "failed") {
@@ -462,7 +560,7 @@ function isAgent(params) {
462
560
  function isTool(params) {
463
561
  return params instanceof Tool;
464
562
  }
465
- function createStep(params) {
563
+ function createStep(params, agentOptions) {
466
564
  if (isAgent(params)) {
467
565
  return {
468
566
  id: params.name,
@@ -470,12 +568,23 @@ function createStep(params) {
470
568
  // @ts-ignore
471
569
  inputSchema: z.object({
472
570
  prompt: z.string()
571
+ // resourceId: z.string().optional(),
572
+ // threadId: z.string().optional(),
473
573
  }),
474
574
  // @ts-ignore
475
575
  outputSchema: z.object({
476
576
  text: z.string()
477
577
  }),
478
- execute: async ({ inputData, [EMITTER_SYMBOL]: emitter, runtimeContext, abortSignal, abort, tracingContext }) => {
578
+ execute: async ({
579
+ inputData,
580
+ [EMITTER_SYMBOL]: emitter,
581
+ [STREAM_FORMAT_SYMBOL]: streamFormat,
582
+ requestContext,
583
+ tracingContext,
584
+ abortSignal,
585
+ abort,
586
+ writer
587
+ }) => {
479
588
  let streamPromise = {};
480
589
  streamPromise.promise = new Promise((resolve, reject) => {
481
590
  streamPromise.resolve = resolve;
@@ -485,61 +594,60 @@ function createStep(params) {
485
594
  name: params.name,
486
595
  args: inputData
487
596
  };
488
- if ((await params.getLLM()).getModel().specificationVersion === `v2`) {
489
- const { fullStream } = await params.stream(inputData.prompt, {
490
- runtimeContext,
597
+ let stream;
598
+ if ((await params.getModel()).specificationVersion === "v1") {
599
+ const { fullStream } = await params.streamLegacy(inputData.prompt, {
600
+ ...agentOptions ?? {},
601
+ // resourceId: inputData.resourceId,
602
+ // threadId: inputData.threadId,
603
+ requestContext,
491
604
  tracingContext,
492
605
  onFinish: (result) => {
493
606
  streamPromise.resolve(result.text);
607
+ void agentOptions?.onFinish?.(result);
494
608
  },
495
609
  abortSignal
496
610
  });
497
- if (abortSignal.aborted) {
498
- return abort();
499
- }
500
- await emitter.emit("watch-v2", {
501
- type: "tool-call-streaming-start",
502
- ...toolData ?? {}
503
- });
504
- for await (const chunk of fullStream) {
505
- if (chunk.type === "text-delta") {
506
- await emitter.emit("watch-v2", {
507
- type: "tool-call-delta",
508
- ...toolData ?? {},
509
- argsTextDelta: chunk.payload.text
510
- });
511
- }
512
- }
611
+ stream = fullStream;
513
612
  } else {
514
- const { fullStream } = await params.streamLegacy(inputData.prompt, {
515
- runtimeContext,
613
+ const modelOutput = await params.stream(inputData.prompt, {
614
+ ...agentOptions ?? {},
615
+ requestContext,
516
616
  tracingContext,
517
617
  onFinish: (result) => {
518
618
  streamPromise.resolve(result.text);
619
+ void agentOptions?.onFinish?.(result);
519
620
  },
520
621
  abortSignal
521
622
  });
522
- if (abortSignal.aborted) {
523
- return abort();
524
- }
525
- await emitter.emit("watch-v2", {
623
+ stream = modelOutput.fullStream;
624
+ }
625
+ if (streamFormat === "legacy") {
626
+ await emitter.emit("watch", {
526
627
  type: "tool-call-streaming-start",
527
628
  ...toolData ?? {}
528
629
  });
529
- for await (const chunk of fullStream) {
630
+ for await (const chunk of stream) {
530
631
  if (chunk.type === "text-delta") {
531
- await emitter.emit("watch-v2", {
632
+ await emitter.emit("watch", {
532
633
  type: "tool-call-delta",
533
634
  ...toolData ?? {},
534
635
  argsTextDelta: chunk.textDelta
535
636
  });
536
637
  }
537
638
  }
639
+ await emitter.emit("watch", {
640
+ type: "tool-call-streaming-finish",
641
+ ...toolData ?? {}
642
+ });
643
+ } else {
644
+ for await (const chunk of stream) {
645
+ await writer.write(chunk);
646
+ }
647
+ }
648
+ if (abortSignal.aborted) {
649
+ return abort();
538
650
  }
539
- await emitter.emit("watch-v2", {
540
- type: "tool-call-streaming-finish",
541
- ...toolData ?? {}
542
- });
543
651
  return {
544
652
  text: await streamPromise.promise
545
653
  };
@@ -558,11 +666,11 @@ function createStep(params) {
558
666
  description: params.description,
559
667
  inputSchema: params.inputSchema,
560
668
  outputSchema: params.outputSchema,
561
- execute: async ({ inputData, mastra, runtimeContext, tracingContext, suspend, resumeData }) => {
669
+ execute: async ({ inputData, mastra, requestContext, tracingContext, suspend, resumeData }) => {
562
670
  return params.execute({
563
671
  context: inputData,
564
672
  mastra: wrapMastra(mastra, tracingContext),
565
- runtimeContext,
673
+ requestContext,
566
674
  tracingContext,
567
675
  suspend,
568
676
  resumeData
@@ -625,63 +733,16 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
625
733
  this.inngestStep = inngestStep;
626
734
  this.inngestAttempts = inngestAttempts;
627
735
  }
628
- async execute(params) {
629
- await params.emitter.emit("watch-v2", {
630
- type: "workflow-start",
631
- payload: { runId: params.runId }
632
- });
633
- const result = await super.execute(params);
634
- await params.emitter.emit("watch-v2", {
635
- type: "workflow-finish",
636
- payload: { runId: params.runId }
637
- });
638
- return result;
639
- }
640
- async fmtReturnValue(executionSpan, emitter, stepResults, lastOutput, error) {
736
+ async fmtReturnValue(emitter, stepResults, lastOutput, error) {
641
737
  const base = {
642
738
  status: lastOutput.status,
643
739
  steps: stepResults
644
740
  };
645
741
  if (lastOutput.status === "success") {
646
- await emitter.emit("watch", {
647
- type: "watch",
648
- payload: {
649
- workflowState: {
650
- status: lastOutput.status,
651
- steps: stepResults,
652
- result: lastOutput.output
653
- }
654
- },
655
- eventTimestamp: Date.now()
656
- });
657
742
  base.result = lastOutput.output;
658
743
  } else if (lastOutput.status === "failed") {
659
744
  base.error = error instanceof Error ? error?.stack ?? error.message : lastOutput?.error instanceof Error ? lastOutput.error.message : lastOutput.error ?? error ?? "Unknown error";
660
- await emitter.emit("watch", {
661
- type: "watch",
662
- payload: {
663
- workflowState: {
664
- status: lastOutput.status,
665
- steps: stepResults,
666
- result: null,
667
- error: base.error
668
- }
669
- },
670
- eventTimestamp: Date.now()
671
- });
672
745
  } else if (lastOutput.status === "suspended") {
673
- await emitter.emit("watch", {
674
- type: "watch",
675
- payload: {
676
- workflowState: {
677
- status: lastOutput.status,
678
- steps: stepResults,
679
- result: null,
680
- error: null
681
- }
682
- },
683
- eventTimestamp: Date.now()
684
- });
685
746
  const suspendedStepIds = Object.entries(stepResults).flatMap(([stepId, stepResult]) => {
686
747
  if (stepResult?.status === "suspended") {
687
748
  const nestedPath = stepResult?.suspendPayload?.__workflow_meta?.path;
@@ -691,7 +752,6 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
691
752
  });
692
753
  base.suspended = suspendedStepIds;
693
754
  }
694
- executionSpan?.end();
695
755
  return base;
696
756
  }
697
757
  // async executeSleep({ id, duration }: { id: string; duration: number }): Promise<void> {
@@ -705,14 +765,14 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
705
765
  stepResults,
706
766
  emitter,
707
767
  abortController,
708
- runtimeContext,
768
+ requestContext,
709
769
  executionContext,
710
770
  writableStream,
711
771
  tracingContext
712
772
  }) {
713
773
  let { duration, fn } = entry;
714
774
  const sleepSpan = tracingContext?.currentSpan?.createChildSpan({
715
- type: AISpanType.WORKFLOW_SLEEP,
775
+ type: SpanType.WORKFLOW_SLEEP,
716
776
  name: `sleep: ${duration ? `${duration}ms` : "dynamic"}`,
717
777
  attributes: {
718
778
  durationMs: duration,
@@ -723,45 +783,53 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
723
783
  if (fn) {
724
784
  const stepCallId = randomUUID();
725
785
  duration = await this.inngestStep.run(`workflow.${workflowId}.sleep.${entry.id}`, async () => {
726
- return await fn({
727
- runId,
728
- workflowId,
729
- mastra: this.mastra,
730
- runtimeContext,
731
- inputData: prevOutput,
732
- state: executionContext.state,
733
- setState: (state) => {
734
- executionContext.state = state;
735
- },
736
- runCount: -1,
737
- tracingContext: {
738
- currentSpan: sleepSpan
739
- },
740
- getInitData: () => stepResults?.input,
741
- getStepResult: getStepResult.bind(this, stepResults),
742
- // TODO: this function shouldn't have suspend probably?
743
- suspend: async (_suspendPayload) => {
744
- },
745
- bail: () => {
746
- },
747
- abort: () => {
748
- abortController?.abort();
749
- },
750
- [EMITTER_SYMBOL]: emitter,
751
- // TODO: add streamVNext support
752
- [STREAM_FORMAT_SYMBOL]: executionContext.format,
753
- engine: { step: this.inngestStep },
754
- abortSignal: abortController?.signal,
755
- writer: new ToolStream(
786
+ return await fn(
787
+ createDeprecationProxy(
756
788
  {
757
- prefix: "workflow-step",
758
- callId: stepCallId,
759
- name: "sleep",
760
- runId
789
+ runId,
790
+ workflowId,
791
+ mastra: this.mastra,
792
+ requestContext,
793
+ inputData: prevOutput,
794
+ state: executionContext.state,
795
+ setState: (state) => {
796
+ executionContext.state = state;
797
+ },
798
+ retryCount: -1,
799
+ tracingContext: {
800
+ currentSpan: sleepSpan
801
+ },
802
+ getInitData: () => stepResults?.input,
803
+ getStepResult: getStepResult.bind(this, stepResults),
804
+ // TODO: this function shouldn't have suspend probably?
805
+ suspend: async (_suspendPayload) => {
806
+ },
807
+ bail: () => {
808
+ },
809
+ abort: () => {
810
+ abortController?.abort();
811
+ },
812
+ [EMITTER_SYMBOL]: emitter,
813
+ [STREAM_FORMAT_SYMBOL]: executionContext.format,
814
+ engine: { step: this.inngestStep },
815
+ abortSignal: abortController?.signal,
816
+ writer: new ToolStream(
817
+ {
818
+ prefix: "workflow-step",
819
+ callId: stepCallId,
820
+ name: "sleep",
821
+ runId
822
+ },
823
+ writableStream
824
+ )
761
825
  },
762
- writableStream
826
+ {
827
+ paramName: "runCount",
828
+ deprecationMessage: runCountDeprecationMessage,
829
+ logger: this.logger
830
+ }
763
831
  )
764
- });
832
+ );
765
833
  });
766
834
  sleepSpan?.update({
767
835
  attributes: {
@@ -785,14 +853,14 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
785
853
  stepResults,
786
854
  emitter,
787
855
  abortController,
788
- runtimeContext,
856
+ requestContext,
789
857
  executionContext,
790
858
  writableStream,
791
859
  tracingContext
792
860
  }) {
793
861
  let { date, fn } = entry;
794
862
  const sleepUntilSpan = tracingContext?.currentSpan?.createChildSpan({
795
- type: AISpanType.WORKFLOW_SLEEP,
863
+ type: SpanType.WORKFLOW_SLEEP,
796
864
  name: `sleepUntil: ${date ? date.toISOString() : "dynamic"}`,
797
865
  attributes: {
798
866
  untilDate: date,
@@ -804,45 +872,53 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
804
872
  if (fn) {
805
873
  date = await this.inngestStep.run(`workflow.${workflowId}.sleepUntil.${entry.id}`, async () => {
806
874
  const stepCallId = randomUUID();
807
- return await fn({
808
- runId,
809
- workflowId,
810
- mastra: this.mastra,
811
- runtimeContext,
812
- inputData: prevOutput,
813
- state: executionContext.state,
814
- setState: (state) => {
815
- executionContext.state = state;
816
- },
817
- runCount: -1,
818
- tracingContext: {
819
- currentSpan: sleepUntilSpan
820
- },
821
- getInitData: () => stepResults?.input,
822
- getStepResult: getStepResult.bind(this, stepResults),
823
- // TODO: this function shouldn't have suspend probably?
824
- suspend: async (_suspendPayload) => {
825
- },
826
- bail: () => {
827
- },
828
- abort: () => {
829
- abortController?.abort();
830
- },
831
- [EMITTER_SYMBOL]: emitter,
832
- [STREAM_FORMAT_SYMBOL]: executionContext.format,
833
- // TODO: add streamVNext support
834
- engine: { step: this.inngestStep },
835
- abortSignal: abortController?.signal,
836
- writer: new ToolStream(
875
+ return await fn(
876
+ createDeprecationProxy(
837
877
  {
838
- prefix: "workflow-step",
839
- callId: stepCallId,
840
- name: "sleep",
841
- runId
878
+ runId,
879
+ workflowId,
880
+ mastra: this.mastra,
881
+ requestContext,
882
+ inputData: prevOutput,
883
+ state: executionContext.state,
884
+ setState: (state) => {
885
+ executionContext.state = state;
886
+ },
887
+ retryCount: -1,
888
+ tracingContext: {
889
+ currentSpan: sleepUntilSpan
890
+ },
891
+ getInitData: () => stepResults?.input,
892
+ getStepResult: getStepResult.bind(this, stepResults),
893
+ // TODO: this function shouldn't have suspend probably?
894
+ suspend: async (_suspendPayload) => {
895
+ },
896
+ bail: () => {
897
+ },
898
+ abort: () => {
899
+ abortController?.abort();
900
+ },
901
+ [EMITTER_SYMBOL]: emitter,
902
+ [STREAM_FORMAT_SYMBOL]: executionContext.format,
903
+ engine: { step: this.inngestStep },
904
+ abortSignal: abortController?.signal,
905
+ writer: new ToolStream(
906
+ {
907
+ prefix: "workflow-step",
908
+ callId: stepCallId,
909
+ name: "sleep",
910
+ runId
911
+ },
912
+ writableStream
913
+ )
842
914
  },
843
- writableStream
915
+ {
916
+ paramName: "runCount",
917
+ deprecationMessage: runCountDeprecationMessage,
918
+ logger: this.logger
919
+ }
844
920
  )
845
- });
921
+ );
846
922
  });
847
923
  if (date && !(date instanceof Date)) {
848
924
  date = new Date(date);
@@ -866,16 +942,6 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
866
942
  throw e;
867
943
  }
868
944
  }
869
- async executeWaitForEvent({ event, timeout }) {
870
- const eventData = await this.inngestStep.waitForEvent(`user-event-${event}`, {
871
- event: `user-event-${event}`,
872
- timeout: timeout ?? 5e3
873
- });
874
- if (eventData === null) {
875
- throw "Timeout waiting for event";
876
- }
877
- return eventData?.data;
878
- }
879
945
  async executeStep({
880
946
  step,
881
947
  stepResults,
@@ -884,14 +950,14 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
884
950
  prevOutput,
885
951
  emitter,
886
952
  abortController,
887
- runtimeContext,
953
+ requestContext,
888
954
  tracingContext,
889
955
  writableStream,
890
956
  disableScorers
891
957
  }) {
892
- const stepAISpan = tracingContext?.currentSpan?.createChildSpan({
958
+ const stepSpan = tracingContext?.currentSpan?.createChildSpan({
893
959
  name: `workflow step: '${step.id}'`,
894
- type: AISpanType.WORKFLOW_STEP,
960
+ type: SpanType.WORKFLOW_STEP,
895
961
  input: prevOutput,
896
962
  attributes: {
897
963
  stepId: step.id
@@ -908,27 +974,6 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
908
974
  async () => {
909
975
  const startedAt2 = Date.now();
910
976
  await emitter.emit("watch", {
911
- type: "watch",
912
- payload: {
913
- currentStep: {
914
- id: step.id,
915
- status: "running"
916
- },
917
- workflowState: {
918
- status: "running",
919
- steps: {
920
- ...stepResults,
921
- [step.id]: {
922
- status: "running"
923
- }
924
- },
925
- result: null,
926
- error: null
927
- }
928
- },
929
- eventTimestamp: Date.now()
930
- });
931
- await emitter.emit("watch-v2", {
932
977
  type: "workflow-step-start",
933
978
  payload: {
934
979
  id: step.id,
@@ -1004,23 +1049,6 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
1004
1049
  async () => {
1005
1050
  if (result.status === "failed") {
1006
1051
  await emitter.emit("watch", {
1007
- type: "watch",
1008
- payload: {
1009
- currentStep: {
1010
- id: step.id,
1011
- status: "failed",
1012
- error: result?.error
1013
- },
1014
- workflowState: {
1015
- status: "running",
1016
- steps: stepResults,
1017
- result: null,
1018
- error: null
1019
- }
1020
- },
1021
- eventTimestamp: Date.now()
1022
- });
1023
- await emitter.emit("watch-v2", {
1024
1052
  type: "workflow-step-result",
1025
1053
  payload: {
1026
1054
  id: step.id,
@@ -1039,27 +1067,6 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
1039
1067
  const suspendPath = [stepName, ...stepResult?.suspendPayload?.__workflow_meta?.path ?? []];
1040
1068
  executionContext.suspendedPaths[step.id] = executionContext.executionPath;
1041
1069
  await emitter.emit("watch", {
1042
- type: "watch",
1043
- payload: {
1044
- currentStep: {
1045
- id: step.id,
1046
- status: "suspended",
1047
- payload: stepResult.payload,
1048
- suspendPayload: {
1049
- ...stepResult?.suspendPayload,
1050
- __workflow_meta: { runId, path: suspendPath }
1051
- }
1052
- },
1053
- workflowState: {
1054
- status: "running",
1055
- steps: stepResults,
1056
- result: null,
1057
- error: null
1058
- }
1059
- },
1060
- eventTimestamp: Date.now()
1061
- });
1062
- await emitter.emit("watch-v2", {
1063
1070
  type: "workflow-step-suspended",
1064
1071
  payload: {
1065
1072
  id: step.id,
@@ -1078,23 +1085,6 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
1078
1085
  }
1079
1086
  };
1080
1087
  }
1081
- await emitter.emit("watch", {
1082
- type: "watch",
1083
- payload: {
1084
- currentStep: {
1085
- id: step.id,
1086
- status: "suspended",
1087
- payload: {}
1088
- },
1089
- workflowState: {
1090
- status: "running",
1091
- steps: stepResults,
1092
- result: null,
1093
- error: null
1094
- }
1095
- },
1096
- eventTimestamp: Date.now()
1097
- });
1098
1088
  return {
1099
1089
  executionContext,
1100
1090
  result: {
@@ -1104,23 +1094,6 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
1104
1094
  };
1105
1095
  }
1106
1096
  await emitter.emit("watch", {
1107
- type: "watch",
1108
- payload: {
1109
- currentStep: {
1110
- id: step.id,
1111
- status: "success",
1112
- output: result?.result
1113
- },
1114
- workflowState: {
1115
- status: "running",
1116
- steps: stepResults,
1117
- result: null,
1118
- error: null
1119
- }
1120
- },
1121
- eventTimestamp: Date.now()
1122
- });
1123
- await emitter.emit("watch-v2", {
1124
1097
  type: "workflow-step-result",
1125
1098
  payload: {
1126
1099
  id: step.id,
@@ -1128,7 +1101,7 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
1128
1101
  output: result?.result
1129
1102
  }
1130
1103
  });
1131
- await emitter.emit("watch-v2", {
1104
+ await emitter.emit("watch", {
1132
1105
  type: "workflow-step-finish",
1133
1106
  payload: {
1134
1107
  id: step.id,
@@ -1148,6 +1121,7 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
1148
1121
  resumePayload: resume?.steps[0] === step.id ? resume?.resumePayload : void 0
1149
1122
  };
1150
1123
  }
1124
+ const stepCallId = randomUUID();
1151
1125
  let stepRes;
1152
1126
  try {
1153
1127
  stepRes = await this.inngestStep.run(`workflow.${executionContext.workflowId}.step.${step.id}`, async () => {
@@ -1161,8 +1135,16 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
1161
1135
  const result = await step.execute({
1162
1136
  runId: executionContext.runId,
1163
1137
  mastra: this.mastra,
1164
- runtimeContext,
1165
- writableStream,
1138
+ requestContext,
1139
+ writer: new ToolStream(
1140
+ {
1141
+ prefix: "workflow-step",
1142
+ callId: stepCallId,
1143
+ name: step.id,
1144
+ runId: executionContext.runId
1145
+ },
1146
+ writableStream
1147
+ ),
1166
1148
  state: executionContext?.state ?? {},
1167
1149
  setState: (state) => {
1168
1150
  executionContext.state = state;
@@ -1170,12 +1152,21 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
1170
1152
  inputData,
1171
1153
  resumeData: resume?.steps[0] === step.id ? resume?.resumePayload : void 0,
1172
1154
  tracingContext: {
1173
- currentSpan: stepAISpan
1155
+ currentSpan: stepSpan
1174
1156
  },
1175
1157
  getInitData: () => stepResults?.input,
1176
1158
  getStepResult: getStepResult.bind(this, stepResults),
1177
- suspend: async (suspendPayload) => {
1159
+ suspend: async (suspendPayload, suspendOptions) => {
1178
1160
  executionContext.suspendedPaths[step.id] = executionContext.executionPath;
1161
+ if (suspendOptions?.resumeLabel) {
1162
+ const resumeLabel = Array.isArray(suspendOptions.resumeLabel) ? suspendOptions.resumeLabel : [suspendOptions.resumeLabel];
1163
+ for (const label of resumeLabel) {
1164
+ executionContext.resumeLabels[label] = {
1165
+ stepId: step.id,
1166
+ foreachIndex: executionContext.foreachIndex
1167
+ };
1168
+ }
1169
+ }
1179
1170
  suspended = { payload: suspendPayload };
1180
1171
  },
1181
1172
  bail: (result2) => {
@@ -1188,6 +1179,7 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
1188
1179
  runId: stepResults[step.id]?.suspendPayload?.__workflow_meta?.runId
1189
1180
  },
1190
1181
  [EMITTER_SYMBOL]: emitter,
1182
+ [STREAM_FORMAT_SYMBOL]: executionContext.format,
1191
1183
  engine: {
1192
1184
  step: this.inngestStep
1193
1185
  },
@@ -1215,7 +1207,7 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
1215
1207
  };
1216
1208
  execResults = stepFailure;
1217
1209
  const fallbackErrorMessage = `Step ${step.id} failed`;
1218
- stepAISpan?.error({ error: new Error(execResults.error ?? fallbackErrorMessage) });
1210
+ stepSpan?.error({ error: new Error(execResults.error ?? fallbackErrorMessage) });
1219
1211
  throw new RetryAfterError(execResults.error ?? fallbackErrorMessage, executionContext.retryConfig.delay, {
1220
1212
  cause: execResults
1221
1213
  });
@@ -1239,24 +1231,8 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
1239
1231
  startedAt
1240
1232
  };
1241
1233
  }
1242
- await emitter.emit("watch", {
1243
- type: "watch",
1244
- payload: {
1245
- currentStep: {
1246
- id: step.id,
1247
- ...execResults
1248
- },
1249
- workflowState: {
1250
- status: "running",
1251
- steps: { ...stepResults, [step.id]: execResults },
1252
- result: null,
1253
- error: null
1254
- }
1255
- },
1256
- eventTimestamp: Date.now()
1257
- });
1258
1234
  if (execResults.status === "suspended") {
1259
- await emitter.emit("watch-v2", {
1235
+ await emitter.emit("watch", {
1260
1236
  type: "workflow-step-suspended",
1261
1237
  payload: {
1262
1238
  id: step.id,
@@ -1264,14 +1240,14 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
1264
1240
  }
1265
1241
  });
1266
1242
  } else {
1267
- await emitter.emit("watch-v2", {
1243
+ await emitter.emit("watch", {
1268
1244
  type: "workflow-step-result",
1269
1245
  payload: {
1270
1246
  id: step.id,
1271
1247
  ...execResults
1272
1248
  }
1273
1249
  });
1274
- await emitter.emit("watch-v2", {
1250
+ await emitter.emit("watch", {
1275
1251
  type: "workflow-step-finish",
1276
1252
  payload: {
1277
1253
  id: step.id,
@@ -1279,7 +1255,7 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
1279
1255
  }
1280
1256
  });
1281
1257
  }
1282
- stepAISpan?.end({ output: execResults });
1258
+ stepSpan?.end({ output: execResults });
1283
1259
  return { result: execResults, executionContext, stepResults };
1284
1260
  });
1285
1261
  } catch (e) {
@@ -1309,9 +1285,9 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
1309
1285
  output: stepRes.result,
1310
1286
  workflowId: executionContext.workflowId,
1311
1287
  stepId: step.id,
1312
- runtimeContext,
1288
+ requestContext,
1313
1289
  disableScorers,
1314
- tracingContext: { currentSpan: stepAISpan }
1290
+ tracingContext: { currentSpan: stepSpan }
1315
1291
  });
1316
1292
  }
1317
1293
  });
@@ -1349,6 +1325,7 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
1349
1325
  context: stepResults,
1350
1326
  activePaths: [],
1351
1327
  suspendedPaths: executionContext.suspendedPaths,
1328
+ resumeLabels: executionContext.resumeLabels,
1352
1329
  waitingPaths: {},
1353
1330
  serializedStepGraph,
1354
1331
  status: workflowStatus,
@@ -1366,20 +1343,18 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
1366
1343
  runId,
1367
1344
  entry,
1368
1345
  prevOutput,
1369
- prevStep,
1370
1346
  stepResults,
1371
- serializedStepGraph,
1372
1347
  resume,
1373
1348
  executionContext,
1374
1349
  emitter,
1375
1350
  abortController,
1376
- runtimeContext,
1351
+ requestContext,
1377
1352
  writableStream,
1378
1353
  disableScorers,
1379
1354
  tracingContext
1380
1355
  }) {
1381
1356
  const conditionalSpan = tracingContext?.currentSpan?.createChildSpan({
1382
- type: AISpanType.WORKFLOW_CONDITIONAL,
1357
+ type: SpanType.WORKFLOW_CONDITIONAL,
1383
1358
  name: `conditional: '${entry.conditions.length} conditions'`,
1384
1359
  input: prevOutput,
1385
1360
  attributes: {
@@ -1392,7 +1367,7 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
1392
1367
  entry.conditions.map(
1393
1368
  (cond, index) => this.inngestStep.run(`workflow.${workflowId}.conditional.${index}`, async () => {
1394
1369
  const evalSpan = conditionalSpan?.createChildSpan({
1395
- type: AISpanType.WORKFLOW_CONDITIONAL_EVAL,
1370
+ type: SpanType.WORKFLOW_CONDITIONAL_EVAL,
1396
1371
  name: `condition: '${index}'`,
1397
1372
  input: prevOutput,
1398
1373
  attributes: {
@@ -1401,47 +1376,55 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
1401
1376
  tracingPolicy: this.options?.tracingPolicy
1402
1377
  });
1403
1378
  try {
1404
- const result = await cond({
1405
- runId,
1406
- workflowId,
1407
- mastra: this.mastra,
1408
- runtimeContext,
1409
- runCount: -1,
1410
- inputData: prevOutput,
1411
- state: executionContext.state,
1412
- setState: (state) => {
1413
- executionContext.state = state;
1414
- },
1415
- tracingContext: {
1416
- currentSpan: evalSpan
1417
- },
1418
- getInitData: () => stepResults?.input,
1419
- getStepResult: getStepResult.bind(this, stepResults),
1420
- // TODO: this function shouldn't have suspend probably?
1421
- suspend: async (_suspendPayload) => {
1422
- },
1423
- bail: () => {
1424
- },
1425
- abort: () => {
1426
- abortController.abort();
1427
- },
1428
- [EMITTER_SYMBOL]: emitter,
1429
- [STREAM_FORMAT_SYMBOL]: executionContext.format,
1430
- // TODO: add streamVNext support
1431
- engine: {
1432
- step: this.inngestStep
1433
- },
1434
- abortSignal: abortController.signal,
1435
- writer: new ToolStream(
1379
+ const result = await cond(
1380
+ createDeprecationProxy(
1436
1381
  {
1437
- prefix: "workflow-step",
1438
- callId: randomUUID(),
1439
- name: "conditional",
1440
- runId
1382
+ runId,
1383
+ workflowId,
1384
+ mastra: this.mastra,
1385
+ requestContext,
1386
+ retryCount: -1,
1387
+ inputData: prevOutput,
1388
+ state: executionContext.state,
1389
+ setState: (state) => {
1390
+ executionContext.state = state;
1391
+ },
1392
+ tracingContext: {
1393
+ currentSpan: evalSpan
1394
+ },
1395
+ getInitData: () => stepResults?.input,
1396
+ getStepResult: getStepResult.bind(this, stepResults),
1397
+ // TODO: this function shouldn't have suspend probably?
1398
+ suspend: async (_suspendPayload) => {
1399
+ },
1400
+ bail: () => {
1401
+ },
1402
+ abort: () => {
1403
+ abortController.abort();
1404
+ },
1405
+ [EMITTER_SYMBOL]: emitter,
1406
+ [STREAM_FORMAT_SYMBOL]: executionContext.format,
1407
+ engine: {
1408
+ step: this.inngestStep
1409
+ },
1410
+ abortSignal: abortController.signal,
1411
+ writer: new ToolStream(
1412
+ {
1413
+ prefix: "workflow-step",
1414
+ callId: randomUUID(),
1415
+ name: "conditional",
1416
+ runId
1417
+ },
1418
+ writableStream
1419
+ )
1441
1420
  },
1442
- writableStream
1421
+ {
1422
+ paramName: "runCount",
1423
+ deprecationMessage: runCountDeprecationMessage,
1424
+ logger: this.logger
1425
+ }
1443
1426
  )
1444
- });
1427
+ );
1445
1428
  evalSpan?.end({
1446
1429
  output: result,
1447
1430
  attributes: {
@@ -1469,13 +1452,14 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
1469
1452
  }
1470
1453
  });
1471
1454
  const results = await Promise.all(
1472
- stepsToRun.map(
1473
- (step, index) => this.executeEntry({
1474
- workflowId,
1475
- runId,
1476
- entry: step,
1477
- serializedStepGraph,
1478
- prevStep,
1455
+ stepsToRun.map(async (step, index) => {
1456
+ const currStepResult = stepResults[step.step.id];
1457
+ if (currStepResult && currStepResult.status === "success") {
1458
+ return currStepResult;
1459
+ }
1460
+ const result = await this.executeStep({
1461
+ step: step.step,
1462
+ prevOutput,
1479
1463
  stepResults,
1480
1464
  resume,
1481
1465
  executionContext: {
@@ -1483,32 +1467,34 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
1483
1467
  runId,
1484
1468
  executionPath: [...executionContext.executionPath, index],
1485
1469
  suspendedPaths: executionContext.suspendedPaths,
1470
+ resumeLabels: executionContext.resumeLabels,
1486
1471
  retryConfig: executionContext.retryConfig,
1487
- executionSpan: executionContext.executionSpan,
1488
1472
  state: executionContext.state
1489
1473
  },
1490
1474
  emitter,
1491
1475
  abortController,
1492
- runtimeContext,
1476
+ requestContext,
1493
1477
  writableStream,
1494
1478
  disableScorers,
1495
1479
  tracingContext: {
1496
1480
  currentSpan: conditionalSpan
1497
1481
  }
1498
- })
1499
- )
1482
+ });
1483
+ stepResults[step.step.id] = result;
1484
+ return result;
1485
+ })
1500
1486
  );
1501
- const hasFailed = results.find((result) => result.result.status === "failed");
1502
- const hasSuspended = results.find((result) => result.result.status === "suspended");
1487
+ const hasFailed = results.find((result) => result.status === "failed");
1488
+ const hasSuspended = results.find((result) => result.status === "suspended");
1503
1489
  if (hasFailed) {
1504
- execResults = { status: "failed", error: hasFailed.result.error };
1490
+ execResults = { status: "failed", error: hasFailed.error };
1505
1491
  } else if (hasSuspended) {
1506
- execResults = { status: "suspended", suspendPayload: hasSuspended.result.suspendPayload };
1492
+ execResults = { status: "suspended", suspendPayload: hasSuspended.suspendPayload };
1507
1493
  } else {
1508
1494
  execResults = {
1509
1495
  status: "success",
1510
1496
  output: results.reduce((acc, result, index) => {
1511
- if (result.result.status === "success") {
1497
+ if (result.status === "success") {
1512
1498
  acc[stepsToRun[index].step.id] = result.output;
1513
1499
  }
1514
1500
  return acc;