@mastra/inngest 0.0.0-add-runtime-context-to-openai-realtime-20250516201052 → 0.0.0-ai-v5-20250625173645

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.cjs CHANGED
@@ -3,12 +3,15 @@
3
3
  var crypto = require('crypto');
4
4
  var realtime = require('@inngest/realtime');
5
5
  var di = require('@mastra/core/di');
6
- var vNext = require('@mastra/core/workflows/vNext');
6
+ var tools = require('@mastra/core/tools');
7
+ var workflows = require('@mastra/core/workflows');
8
+ var _constants = require('@mastra/core/workflows/_constants');
7
9
  var hono = require('inngest/hono');
10
+ var zod = require('zod');
8
11
 
9
12
  // src/index.ts
10
13
  function serve({ mastra, inngest }) {
11
- const wfs = mastra.vnext_getWorkflows();
14
+ const wfs = mastra.getWorkflows();
12
15
  const functions = Object.values(wfs).flatMap((wf) => {
13
16
  if (wf instanceof InngestWorkflow) {
14
17
  wf.__registerMastra(mastra);
@@ -21,16 +24,18 @@ function serve({ mastra, inngest }) {
21
24
  functions
22
25
  });
23
26
  }
24
- var InngestRun = class extends vNext.Run {
27
+ var InngestRun = class extends workflows.Run {
25
28
  inngest;
29
+ serializedStepGraph;
26
30
  #mastra;
27
31
  constructor(params, inngest) {
28
32
  super(params);
29
33
  this.inngest = inngest;
34
+ this.serializedStepGraph = params.serializedStepGraph;
30
35
  this.#mastra = params.mastra;
31
36
  }
32
37
  async getRuns(eventId) {
33
- const response = await fetch(`${this.inngest.apiBaseUrl}/v1/events/${eventId}/runs`, {
38
+ const response = await fetch(`${this.inngest.apiBaseUrl ?? "https://api.inngest.com"}/v1/events/${eventId}/runs`, {
34
39
  headers: {
35
40
  Authorization: `Bearer ${process.env.INNGEST_SIGNING_KEY}`
36
41
  }
@@ -40,7 +45,7 @@ var InngestRun = class extends vNext.Run {
40
45
  }
41
46
  async getRunOutput(eventId) {
42
47
  let runs = await this.getRuns(eventId);
43
- while (runs?.[0]?.status !== "Completed") {
48
+ while (runs?.[0]?.status !== "Completed" || runs?.[0]?.event_id !== eventId) {
44
49
  await new Promise((resolve) => setTimeout(resolve, 1e3));
45
50
  runs = await this.getRuns(eventId);
46
51
  if (runs?.[0]?.status === "Failed" || runs?.[0]?.status === "Cancelled") {
@@ -49,6 +54,12 @@ var InngestRun = class extends vNext.Run {
49
54
  }
50
55
  return runs?.[0];
51
56
  }
57
+ async sendEvent(event, data) {
58
+ await this.inngest.send({
59
+ name: `user-event-${event}`,
60
+ data
61
+ });
62
+ }
52
63
  async start({
53
64
  inputData
54
65
  }) {
@@ -57,11 +68,13 @@ var InngestRun = class extends vNext.Run {
57
68
  runId: this.runId,
58
69
  snapshot: {
59
70
  runId: this.runId,
71
+ serializedStepGraph: this.serializedStepGraph,
60
72
  value: {},
61
73
  context: {},
62
74
  activePaths: [],
63
75
  suspendedPaths: {},
64
- timestamp: Date.now()
76
+ timestamp: Date.now(),
77
+ status: "running"
65
78
  }
66
79
  });
67
80
  const eventOutput = await this.inngest.send({
@@ -84,6 +97,17 @@ var InngestRun = class extends vNext.Run {
84
97
  return result;
85
98
  }
86
99
  async resume(params) {
100
+ const p = this._resume(params).then((result) => {
101
+ if (result.status !== "suspended") {
102
+ this.closeStreamAction?.().catch(() => {
103
+ });
104
+ }
105
+ return result;
106
+ });
107
+ this.executionResults = p;
108
+ return p;
109
+ }
110
+ async _resume(params) {
87
111
  const steps = (Array.isArray(params.step) ? params.step : [params.step]).map(
88
112
  (step) => typeof step === "string" ? step : step?.id
89
113
  );
@@ -117,27 +141,62 @@ var InngestRun = class extends vNext.Run {
117
141
  }
118
142
  return result;
119
143
  }
120
- watch(cb) {
144
+ watch(cb, type = "watch") {
145
+ let active = true;
121
146
  const streamPromise = realtime.subscribe(
122
147
  {
123
148
  channel: `workflow:${this.workflowId}:${this.runId}`,
124
- topics: ["watch"],
149
+ topics: [type],
125
150
  app: this.inngest
126
151
  },
127
152
  (message) => {
128
- cb(message.data);
153
+ if (active) {
154
+ cb(message.data);
155
+ }
129
156
  }
130
157
  );
131
158
  return () => {
132
- streamPromise.then((stream) => {
133
- stream.cancel();
159
+ active = false;
160
+ streamPromise.then(async (stream) => {
161
+ return stream.cancel();
134
162
  }).catch((err) => {
135
163
  console.error(err);
136
164
  });
137
165
  };
138
166
  }
167
+ stream({ inputData, runtimeContext } = {}) {
168
+ const { readable, writable } = new TransformStream();
169
+ const writer = writable.getWriter();
170
+ const unwatch = this.watch(async (event) => {
171
+ try {
172
+ await writer.write(event);
173
+ } catch {
174
+ }
175
+ }, "watch-v2");
176
+ this.closeStreamAction = async () => {
177
+ unwatch();
178
+ try {
179
+ await writer.close();
180
+ } catch (err) {
181
+ console.error("Error closing stream:", err);
182
+ } finally {
183
+ writer.releaseLock();
184
+ }
185
+ };
186
+ this.executionResults = this.start({ inputData, runtimeContext }).then((result) => {
187
+ if (result.status !== "suspended") {
188
+ this.closeStreamAction?.().catch(() => {
189
+ });
190
+ }
191
+ return result;
192
+ });
193
+ return {
194
+ stream: readable,
195
+ getWorkflowState: () => this.executionResults
196
+ };
197
+ }
139
198
  };
140
- var InngestWorkflow = class _InngestWorkflow extends vNext.NewWorkflow {
199
+ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
141
200
  #mastra;
142
201
  inngest;
143
202
  function;
@@ -158,11 +217,32 @@ var InngestWorkflow = class _InngestWorkflow extends vNext.NewWorkflow {
158
217
  const storage = this.#mastra?.getStorage();
159
218
  if (!storage) {
160
219
  this.logger.debug("Cannot get workflow runs. Mastra engine is not initialized");
161
- return null;
220
+ return this.runs.get(runId) ? { ...this.runs.get(runId), workflowName: this.id } : null;
162
221
  }
163
222
  const run = await storage.getWorkflowRunById({ runId, workflowName: this.id });
164
223
  return run ?? (this.runs.get(runId) ? { ...this.runs.get(runId), workflowName: this.id } : null);
165
224
  }
225
+ async getWorkflowRunExecutionResult(runId) {
226
+ const storage = this.#mastra?.getStorage();
227
+ if (!storage) {
228
+ this.logger.debug("Cannot get workflow run execution result. Mastra storage is not initialized");
229
+ return null;
230
+ }
231
+ const run = await storage.getWorkflowRunById({ runId, workflowName: this.id });
232
+ if (!run?.snapshot) {
233
+ return null;
234
+ }
235
+ if (typeof run.snapshot === "string") {
236
+ return null;
237
+ }
238
+ return {
239
+ status: run.snapshot.status,
240
+ result: run.snapshot.result,
241
+ error: run.snapshot.error,
242
+ payload: run.snapshot.context?.input,
243
+ steps: run.snapshot.context
244
+ };
245
+ }
166
246
  __registerMastra(mastra) {
167
247
  this.#mastra = mastra;
168
248
  this.executionEngine.__registerMastra(mastra);
@@ -189,6 +269,7 @@ var InngestWorkflow = class _InngestWorkflow extends vNext.NewWorkflow {
189
269
  runId: runIdToUse,
190
270
  executionEngine: this.executionEngine,
191
271
  executionGraph: this.executionGraph,
272
+ serializedStepGraph: this.serializedStepGraph,
192
273
  mastra: this.#mastra,
193
274
  retryConfig: this.retryConfig,
194
275
  cleanup: () => this.runs.delete(runIdToUse)
@@ -221,12 +302,18 @@ var InngestWorkflow = class _InngestWorkflow extends vNext.NewWorkflow {
221
302
  try {
222
303
  await publish({
223
304
  channel: `workflow:${this.id}:${runId}`,
224
- topic: "watch",
305
+ topic: event2,
225
306
  data
226
307
  });
227
308
  } catch (err) {
228
309
  this.logger.error("Error emitting event: " + (err?.stack ?? err?.message ?? err));
229
310
  }
311
+ },
312
+ on: (_event, _callback) => {
313
+ },
314
+ off: (_event, _callback) => {
315
+ },
316
+ once: (_event, _callback) => {
230
317
  }
231
318
  };
232
319
  const engine = new InngestExecutionEngine(this.#mastra, step, attempt);
@@ -234,6 +321,7 @@ var InngestWorkflow = class _InngestWorkflow extends vNext.NewWorkflow {
234
321
  workflowId: this.id,
235
322
  runId,
236
323
  graph: this.executionGraph,
324
+ serializedStepGraph: this.serializedStepGraph,
237
325
  input: inputData,
238
326
  emitter,
239
327
  retryConfig: this.retryConfig,
@@ -263,32 +351,137 @@ var InngestWorkflow = class _InngestWorkflow extends vNext.NewWorkflow {
263
351
  return [this.getFunction(), ...this.getNestedFunctions(this.executionGraph.steps)];
264
352
  }
265
353
  };
266
- function cloneWorkflow(workflow, opts) {
267
- const wf = new InngestWorkflow(
268
- {
269
- id: opts.id,
270
- inputSchema: workflow.inputSchema,
271
- outputSchema: workflow.outputSchema,
272
- steps: workflow.stepDefs,
273
- mastra: workflow.mastra
274
- },
275
- workflow.inngest
276
- );
277
- wf.setStepFlow(workflow.stepGraph);
278
- wf.commit();
279
- return wf;
354
+ function isAgent(params) {
355
+ return params?.component === "AGENT";
356
+ }
357
+ function isTool(params) {
358
+ return params instanceof tools.Tool;
359
+ }
360
+ function createStep(params) {
361
+ if (isAgent(params)) {
362
+ return {
363
+ id: params.name,
364
+ // @ts-ignore
365
+ inputSchema: zod.z.object({
366
+ prompt: zod.z.string()
367
+ // resourceId: z.string().optional(),
368
+ // threadId: z.string().optional(),
369
+ }),
370
+ // @ts-ignore
371
+ outputSchema: zod.z.object({
372
+ text: zod.z.string()
373
+ }),
374
+ execute: async ({ inputData, [_constants.EMITTER_SYMBOL]: emitter, runtimeContext }) => {
375
+ let streamPromise = {};
376
+ streamPromise.promise = new Promise((resolve, reject) => {
377
+ streamPromise.resolve = resolve;
378
+ streamPromise.reject = reject;
379
+ });
380
+ const toolData = {
381
+ name: params.name,
382
+ args: inputData
383
+ };
384
+ await emitter.emit("watch-v2", {
385
+ type: "tool-call-streaming-start",
386
+ ...toolData
387
+ });
388
+ const { fullStream } = await params.stream(inputData.prompt, {
389
+ // resourceId: inputData.resourceId,
390
+ // threadId: inputData.threadId,
391
+ runtimeContext,
392
+ onFinish: (result) => {
393
+ streamPromise.resolve(result.text);
394
+ }
395
+ });
396
+ for await (const chunk of fullStream) {
397
+ switch (chunk.type) {
398
+ case "text":
399
+ await emitter.emit("watch-v2", {
400
+ type: "tool-call-delta",
401
+ ...toolData,
402
+ argsTextDelta: chunk.text
403
+ });
404
+ break;
405
+ case "start-step":
406
+ case "finish-step":
407
+ case "finish":
408
+ break;
409
+ case "tool-call":
410
+ case "tool-result":
411
+ case "tool-input-start":
412
+ case "tool-input-delta":
413
+ case "source":
414
+ case "file":
415
+ default:
416
+ await emitter.emit("watch-v2", chunk);
417
+ break;
418
+ }
419
+ }
420
+ return {
421
+ text: await streamPromise.promise
422
+ };
423
+ }
424
+ };
425
+ }
426
+ if (isTool(params)) {
427
+ if (!params.inputSchema || !params.outputSchema) {
428
+ throw new Error("Tool must have input and output schemas defined");
429
+ }
430
+ return {
431
+ // TODO: tool probably should have strong id type
432
+ // @ts-ignore
433
+ id: params.id,
434
+ inputSchema: params.inputSchema,
435
+ outputSchema: params.outputSchema,
436
+ execute: async ({ inputData, mastra, runtimeContext }) => {
437
+ return params.execute({
438
+ context: inputData,
439
+ mastra,
440
+ runtimeContext
441
+ });
442
+ }
443
+ };
444
+ }
445
+ return {
446
+ id: params.id,
447
+ description: params.description,
448
+ inputSchema: params.inputSchema,
449
+ outputSchema: params.outputSchema,
450
+ resumeSchema: params.resumeSchema,
451
+ suspendSchema: params.suspendSchema,
452
+ execute: params.execute
453
+ };
280
454
  }
281
455
  function init(inngest) {
282
456
  return {
283
457
  createWorkflow(params) {
284
458
  return new InngestWorkflow(params, inngest);
285
459
  },
286
- createStep: vNext.createStep,
287
- cloneStep: vNext.cloneStep,
288
- cloneWorkflow
460
+ createStep,
461
+ cloneStep(step, opts) {
462
+ return {
463
+ id: opts.id,
464
+ description: step.description,
465
+ inputSchema: step.inputSchema,
466
+ outputSchema: step.outputSchema,
467
+ execute: step.execute
468
+ };
469
+ },
470
+ cloneWorkflow(workflow, opts) {
471
+ const wf = new workflows.Workflow({
472
+ id: opts.id,
473
+ inputSchema: workflow.inputSchema,
474
+ outputSchema: workflow.outputSchema,
475
+ steps: workflow.stepDefs,
476
+ mastra: workflow.mastra
477
+ });
478
+ wf.setStepFlow(workflow.stepGraph);
479
+ wf.commit();
480
+ return wf;
481
+ }
289
482
  };
290
483
  }
291
- var InngestExecutionEngine = class extends vNext.DefaultExecutionEngine {
484
+ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
292
485
  inngestStep;
293
486
  inngestAttempts;
294
487
  constructor(mastra, inngestStep, inngestAttempts = 0) {
@@ -296,6 +489,18 @@ var InngestExecutionEngine = class extends vNext.DefaultExecutionEngine {
296
489
  this.inngestStep = inngestStep;
297
490
  this.inngestAttempts = inngestAttempts;
298
491
  }
492
+ async execute(params) {
493
+ await params.emitter.emit("watch-v2", {
494
+ type: "start",
495
+ payload: { runId: params.runId }
496
+ });
497
+ const result = await super.execute(params);
498
+ await params.emitter.emit("watch-v2", {
499
+ type: "finish",
500
+ payload: { runId: params.runId }
501
+ });
502
+ return result;
503
+ }
299
504
  async fmtReturnValue(executionSpan, emitter, stepResults, lastOutput, error) {
300
505
  const base = {
301
506
  status: lastOutput.status,
@@ -376,6 +581,19 @@ var InngestExecutionEngine = class extends vNext.DefaultExecutionEngine {
376
581
  runtimeContext
377
582
  });
378
583
  }
584
+ async executeSleep({ id, duration }) {
585
+ await this.inngestStep.sleep(id, duration);
586
+ }
587
+ async executeWaitForEvent({ event, timeout }) {
588
+ const eventData = await this.inngestStep.waitForEvent(`user-event-${event}`, {
589
+ event: `user-event-${event}`,
590
+ timeout: timeout ?? 5e3
591
+ });
592
+ if (eventData === null) {
593
+ throw "Timeout waiting for event";
594
+ }
595
+ return eventData?.data;
596
+ }
379
597
  async executeStep({
380
598
  step,
381
599
  stepResults,
@@ -385,9 +603,10 @@ var InngestExecutionEngine = class extends vNext.DefaultExecutionEngine {
385
603
  emitter,
386
604
  runtimeContext
387
605
  }) {
388
- await this.inngestStep.run(
606
+ const startedAt = await this.inngestStep.run(
389
607
  `workflow.${executionContext.workflowId}.run.${executionContext.runId}.step.${step.id}.running_ev`,
390
608
  async () => {
609
+ const startedAt2 = Date.now();
391
610
  await emitter.emit("watch", {
392
611
  type: "watch",
393
612
  payload: {
@@ -409,6 +628,13 @@ var InngestExecutionEngine = class extends vNext.DefaultExecutionEngine {
409
628
  },
410
629
  eventTimestamp: Date.now()
411
630
  });
631
+ await emitter.emit("watch-v2", {
632
+ type: "step-start",
633
+ payload: {
634
+ id: step.id
635
+ }
636
+ });
637
+ return startedAt2;
412
638
  }
413
639
  );
414
640
  if (step instanceof InngestWorkflow) {
@@ -469,6 +695,13 @@ var InngestExecutionEngine = class extends vNext.DefaultExecutionEngine {
469
695
  },
470
696
  eventTimestamp: Date.now()
471
697
  });
698
+ await emitter.emit("watch-v2", {
699
+ type: "step-result",
700
+ payload: {
701
+ id: step.id,
702
+ status: "failed"
703
+ }
704
+ });
472
705
  return { executionContext, result: { status: "failed", error: result?.error } };
473
706
  } else if (result.status === "suspended") {
474
707
  const suspendedSteps = Object.entries(result.steps).filter(([_stepName, stepResult]) => {
@@ -495,6 +728,12 @@ var InngestExecutionEngine = class extends vNext.DefaultExecutionEngine {
495
728
  },
496
729
  eventTimestamp: Date.now()
497
730
  });
731
+ await emitter.emit("watch-v2", {
732
+ type: "step-suspended",
733
+ payload: {
734
+ id: step.id
735
+ }
736
+ });
498
737
  return {
499
738
  executionContext,
500
739
  result: {
@@ -545,6 +784,13 @@ var InngestExecutionEngine = class extends vNext.DefaultExecutionEngine {
545
784
  },
546
785
  eventTimestamp: Date.now()
547
786
  });
787
+ await emitter.emit("watch-v2", {
788
+ type: "step-finish",
789
+ payload: {
790
+ id: step.id,
791
+ metadata: {}
792
+ }
793
+ });
548
794
  return { executionContext, result: { status: "success", output: result?.result } };
549
795
  }
550
796
  );
@@ -556,6 +802,7 @@ var InngestExecutionEngine = class extends vNext.DefaultExecutionEngine {
556
802
  let suspended;
557
803
  try {
558
804
  const result = await step.execute({
805
+ runId: executionContext.runId,
559
806
  mastra: this.mastra,
560
807
  runtimeContext,
561
808
  inputData: prevOutput,
@@ -578,14 +825,42 @@ var InngestExecutionEngine = class extends vNext.DefaultExecutionEngine {
578
825
  // @ts-ignore
579
826
  runId: stepResults[step.id]?.payload?.__workflow_meta?.runId
580
827
  },
581
- emitter
828
+ [_constants.EMITTER_SYMBOL]: emitter,
829
+ engine: {
830
+ step: this.inngestStep
831
+ }
582
832
  });
583
- execResults = { status: "success", output: result };
833
+ const endedAt = Date.now();
834
+ execResults = {
835
+ status: "success",
836
+ output: result,
837
+ startedAt,
838
+ endedAt,
839
+ payload: prevOutput,
840
+ resumedAt: resume?.steps[0] === step.id ? startedAt : void 0,
841
+ resumePayload: resume?.steps[0] === step.id ? resume?.resumePayload : void 0
842
+ };
584
843
  } catch (e) {
585
- execResults = { status: "failed", error: e instanceof Error ? e.message : String(e) };
844
+ execResults = {
845
+ status: "failed",
846
+ payload: prevOutput,
847
+ error: e instanceof Error ? e.message : String(e),
848
+ endedAt: Date.now(),
849
+ startedAt,
850
+ resumedAt: resume?.steps[0] === step.id ? startedAt : void 0,
851
+ resumePayload: resume?.steps[0] === step.id ? resume?.resumePayload : void 0
852
+ };
586
853
  }
587
854
  if (suspended) {
588
- execResults = { status: "suspended", payload: suspended.payload };
855
+ execResults = {
856
+ status: "suspended",
857
+ suspendedPayload: suspended.payload,
858
+ payload: prevOutput,
859
+ suspendedAt: Date.now(),
860
+ startedAt,
861
+ resumedAt: resume?.steps[0] === step.id ? startedAt : void 0,
862
+ resumePayload: resume?.steps[0] === step.id ? resume?.resumePayload : void 0
863
+ };
589
864
  }
590
865
  if (execResults.status === "failed") {
591
866
  if (executionContext.retryConfig.attempts > 0 && this.inngestAttempts < executionContext.retryConfig.attempts) {
@@ -597,18 +872,43 @@ var InngestExecutionEngine = class extends vNext.DefaultExecutionEngine {
597
872
  payload: {
598
873
  currentStep: {
599
874
  id: step.id,
600
- status: execResults.status,
601
- output: execResults.output
875
+ ...execResults
602
876
  },
603
877
  workflowState: {
604
878
  status: "running",
605
- steps: stepResults,
879
+ steps: { ...stepResults, [step.id]: execResults },
606
880
  result: null,
607
881
  error: null
608
882
  }
609
883
  },
610
884
  eventTimestamp: Date.now()
611
885
  });
886
+ if (execResults.status === "suspended") {
887
+ await emitter.emit("watch-v2", {
888
+ type: "step-suspended",
889
+ payload: {
890
+ id: step.id,
891
+ status: execResults.status,
892
+ output: execResults.status === "success" ? execResults?.output : void 0
893
+ }
894
+ });
895
+ } else {
896
+ await emitter.emit("watch-v2", {
897
+ type: "step-result",
898
+ payload: {
899
+ id: step.id,
900
+ status: execResults.status,
901
+ output: execResults.status === "success" ? execResults?.output : void 0
902
+ }
903
+ });
904
+ await emitter.emit("watch-v2", {
905
+ type: "step-finish",
906
+ payload: {
907
+ id: step.id,
908
+ metadata: {}
909
+ }
910
+ });
911
+ }
612
912
  return { result: execResults, executionContext, stepResults };
613
913
  });
614
914
  Object.assign(executionContext.suspendedPaths, stepRes.executionContext.suspendedPaths);
@@ -619,7 +919,11 @@ var InngestExecutionEngine = class extends vNext.DefaultExecutionEngine {
619
919
  workflowId,
620
920
  runId,
621
921
  stepResults,
622
- executionContext
922
+ executionContext,
923
+ serializedStepGraph,
924
+ workflowStatus,
925
+ result,
926
+ error
623
927
  }) {
624
928
  await this.inngestStep.run(
625
929
  `workflow.${workflowId}.run.${runId}.path.${JSON.stringify(executionContext.executionPath)}.stepUpdate`,
@@ -633,6 +937,10 @@ var InngestExecutionEngine = class extends vNext.DefaultExecutionEngine {
633
937
  context: stepResults,
634
938
  activePaths: [],
635
939
  suspendedPaths: executionContext.suspendedPaths,
940
+ serializedStepGraph,
941
+ status: workflowStatus,
942
+ result,
943
+ error,
636
944
  // @ts-ignore
637
945
  timestamp: Date.now()
638
946
  }
@@ -647,6 +955,7 @@ var InngestExecutionEngine = class extends vNext.DefaultExecutionEngine {
647
955
  prevOutput,
648
956
  prevStep,
649
957
  stepResults,
958
+ serializedStepGraph,
650
959
  resume,
651
960
  executionContext,
652
961
  emitter,
@@ -658,6 +967,7 @@ var InngestExecutionEngine = class extends vNext.DefaultExecutionEngine {
658
967
  (cond, index) => this.inngestStep.run(`workflow.${workflowId}.conditional.${index}`, async () => {
659
968
  try {
660
969
  const result = await cond({
970
+ runId,
661
971
  mastra: this.mastra,
662
972
  runtimeContext,
663
973
  inputData: prevOutput,
@@ -675,7 +985,10 @@ var InngestExecutionEngine = class extends vNext.DefaultExecutionEngine {
675
985
  // TODO: this function shouldn't have suspend probably?
676
986
  suspend: async (_suspendPayload) => {
677
987
  },
678
- emitter
988
+ [_constants.EMITTER_SYMBOL]: emitter,
989
+ engine: {
990
+ step: this.inngestStep
991
+ }
679
992
  });
680
993
  return result ? index : null;
681
994
  } catch (e) {
@@ -694,6 +1007,7 @@ var InngestExecutionEngine = class extends vNext.DefaultExecutionEngine {
694
1007
  prevStep,
695
1008
  stepResults,
696
1009
  resume,
1010
+ serializedStepGraph,
697
1011
  executionContext: {
698
1012
  workflowId,
699
1013
  runId,
@@ -707,17 +1021,17 @@ var InngestExecutionEngine = class extends vNext.DefaultExecutionEngine {
707
1021
  })
708
1022
  )
709
1023
  );
710
- const hasFailed = results.find((result) => result.status === "failed");
711
- const hasSuspended = results.find((result) => result.status === "suspended");
1024
+ const hasFailed = results.find((result) => result.result.status === "failed");
1025
+ const hasSuspended = results.find((result) => result.result.status === "suspended");
712
1026
  if (hasFailed) {
713
- execResults = { status: "failed", error: hasFailed.error };
1027
+ execResults = { status: "failed", error: hasFailed.result.error };
714
1028
  } else if (hasSuspended) {
715
- execResults = { status: "suspended", payload: hasSuspended.payload };
1029
+ execResults = { status: "suspended", payload: hasSuspended.result.suspendPayload };
716
1030
  } else {
717
1031
  execResults = {
718
1032
  status: "success",
719
1033
  output: results.reduce((acc, result, index) => {
720
- if (result.status === "success") {
1034
+ if (result.result.status === "success") {
721
1035
  acc[stepsToRun[index].step.id] = result.output;
722
1036
  }
723
1037
  return acc;
@@ -731,5 +1045,6 @@ var InngestExecutionEngine = class extends vNext.DefaultExecutionEngine {
731
1045
  exports.InngestExecutionEngine = InngestExecutionEngine;
732
1046
  exports.InngestRun = InngestRun;
733
1047
  exports.InngestWorkflow = InngestWorkflow;
1048
+ exports.createStep = createStep;
734
1049
  exports.init = init;
735
1050
  exports.serve = serve;
package/dist/index.d.cts CHANGED
@@ -1,5 +1,7 @@
1
1
  export { serve } from './_tsup-dts-rollup.cjs';
2
+ export { createStep } from './_tsup-dts-rollup.cjs';
2
3
  export { init } from './_tsup-dts-rollup.cjs';
4
+ export { InngestEngineType } from './_tsup-dts-rollup.cjs';
3
5
  export { InngestRun } from './_tsup-dts-rollup.cjs';
4
6
  export { InngestWorkflow } from './_tsup-dts-rollup.cjs';
5
7
  export { InngestExecutionEngine } from './_tsup-dts-rollup.cjs';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  export { serve } from './_tsup-dts-rollup.js';
2
+ export { createStep } from './_tsup-dts-rollup.js';
2
3
  export { init } from './_tsup-dts-rollup.js';
4
+ export { InngestEngineType } from './_tsup-dts-rollup.js';
3
5
  export { InngestRun } from './_tsup-dts-rollup.js';
4
6
  export { InngestWorkflow } from './_tsup-dts-rollup.js';
5
7
  export { InngestExecutionEngine } from './_tsup-dts-rollup.js';