@mastra/inngest 0.0.0-fix-zod4-schema-validation-20251212180638 → 0.0.0-fix-11329-windows-path-20251222155941

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
@@ -136,6 +136,18 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
136
136
  getEngineContext() {
137
137
  return { step: this.inngestStep };
138
138
  }
139
+ /**
140
+ * For Inngest, lifecycle callbacks are invoked in the workflow's finalize step
141
+ * (wrapped in step.run for durability), not in execute(). Override to skip.
142
+ */
143
+ async invokeLifecycleCallbacks(_result) {
144
+ }
145
+ /**
146
+ * Actually invoke the lifecycle callbacks. Called from workflow.ts finalize step.
147
+ */
148
+ async invokeLifecycleCallbacksInternal(result) {
149
+ return super.invokeLifecycleCallbacks(result);
150
+ }
139
151
  /**
140
152
  * Execute nested InngestWorkflow using inngestStep.invoke() for durability.
141
153
  * This MUST be called directly (not inside step.run()) due to Inngest constraints.
@@ -144,7 +156,18 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
144
156
  if (!(params.step instanceof InngestWorkflow)) {
145
157
  return null;
146
158
  }
147
- const { step, stepResults, executionContext, resume, timeTravel, prevOutput, inputData, pubsub, startedAt } = params;
159
+ const {
160
+ step,
161
+ stepResults,
162
+ executionContext,
163
+ resume,
164
+ timeTravel,
165
+ prevOutput,
166
+ inputData,
167
+ pubsub,
168
+ startedAt,
169
+ perStep
170
+ } = params;
148
171
  const isResume = !!resume?.steps?.length;
149
172
  let result;
150
173
  let runId;
@@ -169,7 +192,8 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
169
192
  resumePayload: resume.resumePayload,
170
193
  resumePath: resume.steps?.[1] ? snapshot?.suspendedPaths?.[resume.steps?.[1]] : void 0
171
194
  },
172
- outputOptions: { includeState: true }
195
+ outputOptions: { includeState: true },
196
+ perStep
173
197
  }
174
198
  });
175
199
  result = invokeResp.result;
@@ -195,7 +219,8 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
195
219
  timeTravel: timeTravelParams,
196
220
  initialState: executionContext.state ?? {},
197
221
  runId: executionContext.runId,
198
- outputOptions: { includeState: true }
222
+ outputOptions: { includeState: true },
223
+ perStep
199
224
  }
200
225
  });
201
226
  result = invokeResp.result;
@@ -207,7 +232,8 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
207
232
  data: {
208
233
  inputData,
209
234
  initialState: executionContext.state ?? {},
210
- outputOptions: { includeState: true }
235
+ outputOptions: { includeState: true },
236
+ perStep
211
237
  }
212
238
  });
213
239
  result = invokeResp.result;
@@ -246,7 +272,7 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
246
272
  }
247
273
  }
248
274
  });
249
- return { executionContext, result: { status: "failed", error: result?.error } };
275
+ return { executionContext, result: { status: "failed", error: result?.error, endedAt: Date.now() } };
250
276
  } else if (result.status === "suspended") {
251
277
  const suspendedSteps = Object.entries(result.steps).filter(([_stepName, stepResult]) => {
252
278
  const stepRes = stepResult;
@@ -270,6 +296,7 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
270
296
  executionContext,
271
297
  result: {
272
298
  status: "suspended",
299
+ suspendedAt: Date.now(),
273
300
  payload: stepResult.payload,
274
301
  suspendPayload: {
275
302
  ...stepResult?.suspendPayload,
@@ -282,6 +309,7 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
282
309
  executionContext,
283
310
  result: {
284
311
  status: "suspended",
312
+ suspendedAt: Date.now(),
285
313
  payload: {}
286
314
  }
287
315
  };
@@ -303,9 +331,34 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
303
331
  executionContext,
304
332
  result: {
305
333
  status: "tripwire",
306
- tripwire: result?.tripwire
334
+ tripwire: result?.tripwire,
335
+ endedAt: Date.now()
307
336
  }
308
337
  };
338
+ } else if (perStep || result.status === "paused") {
339
+ await pubsub.publish(`workflow.events.v2.${executionContext.runId}`, {
340
+ type: "watch",
341
+ runId: executionContext.runId,
342
+ data: {
343
+ type: "workflow-step-result",
344
+ payload: {
345
+ id: step.id,
346
+ status: "paused"
347
+ }
348
+ }
349
+ });
350
+ await pubsub.publish(`workflow.events.v2.${executionContext.runId}`, {
351
+ type: "watch",
352
+ runId: executionContext.runId,
353
+ data: {
354
+ type: "workflow-step-finish",
355
+ payload: {
356
+ id: step.id,
357
+ metadata: {}
358
+ }
359
+ }
360
+ });
361
+ return { executionContext, result: { status: "paused" } };
309
362
  }
310
363
  await pubsub.publish(`workflow.events.v2.${executionContext.runId}`, {
311
364
  type: "watch",
@@ -330,14 +383,13 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
330
383
  }
331
384
  }
332
385
  });
333
- return { executionContext, result: { status: "success", output: result?.result } };
386
+ return { executionContext, result: { status: "success", output: result?.result, endedAt: Date.now() } };
334
387
  }
335
388
  );
336
389
  Object.assign(executionContext, res.executionContext);
337
390
  return {
338
391
  ...res.result,
339
392
  startedAt,
340
- endedAt: Date.now(),
341
393
  payload: inputData,
342
394
  resumedAt: resume?.steps[0] === step.id ? startedAt : void 0,
343
395
  resumePayload: resume?.steps[0] === step.id ? resume?.resumePayload : void 0
@@ -615,7 +667,8 @@ var InngestRun = class extends Run {
615
667
  resourceId: this.resourceId,
616
668
  outputOptions: params.outputOptions,
617
669
  tracingOptions: params.tracingOptions,
618
- requestContext: params.requestContext ? Object.fromEntries(params.requestContext.entries()) : {}
670
+ requestContext: params.requestContext ? Object.fromEntries(params.requestContext.entries()) : {},
671
+ perStep: params.perStep
619
672
  }
620
673
  });
621
674
  const eventId = eventOutput.ids[0];
@@ -630,7 +683,8 @@ var InngestRun = class extends Run {
630
683
  outputOptions,
631
684
  tracingOptions,
632
685
  format,
633
- requestContext
686
+ requestContext,
687
+ perStep
634
688
  }) {
635
689
  await this.#mastra.getStorage()?.persistWorkflowSnapshot({
636
690
  workflowName: this.workflowId,
@@ -662,7 +716,8 @@ var InngestRun = class extends Run {
662
716
  outputOptions,
663
717
  tracingOptions,
664
718
  format,
665
- requestContext: requestContext ? Object.fromEntries(requestContext.entries()) : {}
719
+ requestContext: requestContext ? Object.fromEntries(requestContext.entries()) : {},
720
+ perStep
666
721
  }
667
722
  });
668
723
  const eventId = eventOutput.ids[0];
@@ -721,7 +776,8 @@ var InngestRun = class extends Run {
721
776
  resumePayload: resumeDataToUse,
722
777
  resumePath: steps?.[0] ? snapshot?.suspendedPaths?.[steps?.[0]] : void 0
723
778
  },
724
- requestContext: mergedRequestContext
779
+ requestContext: mergedRequestContext,
780
+ perStep: params.perStep
725
781
  }
726
782
  });
727
783
  const eventId = eventOutput.ids[0];
@@ -811,7 +867,8 @@ var InngestRun = class extends Run {
811
867
  timeTravel: timeTravelData,
812
868
  tracingOptions: params.tracingOptions,
813
869
  outputOptions: params.outputOptions,
814
- requestContext: params.requestContext ? Object.fromEntries(params.requestContext.entries()) : {}
870
+ requestContext: params.requestContext ? Object.fromEntries(params.requestContext.entries()) : {},
871
+ perStep: params.perStep
815
872
  }
816
873
  });
817
874
  const eventId = eventOutput.ids[0];
@@ -902,7 +959,8 @@ var InngestRun = class extends Run {
902
959
  tracingOptions,
903
960
  closeOnSuspend = true,
904
961
  initialState,
905
- outputOptions
962
+ outputOptions,
963
+ perStep
906
964
  } = {}) {
907
965
  if (this.closeStreamAction && this.streamOutput) {
908
966
  return this.streamOutput;
@@ -938,7 +996,8 @@ var InngestRun = class extends Run {
938
996
  initialState,
939
997
  tracingOptions,
940
998
  outputOptions,
941
- format: "vnext"
999
+ format: "vnext",
1000
+ perStep
942
1001
  });
943
1002
  let executionResults;
944
1003
  try {
@@ -981,7 +1040,8 @@ var InngestRun = class extends Run {
981
1040
  nestedStepsContext,
982
1041
  requestContext,
983
1042
  tracingOptions,
984
- outputOptions
1043
+ outputOptions,
1044
+ perStep
985
1045
  }) {
986
1046
  this.closeStreamAction = async () => {
987
1047
  };
@@ -1016,7 +1076,8 @@ var InngestRun = class extends Run {
1016
1076
  initialState,
1017
1077
  requestContext,
1018
1078
  tracingOptions,
1019
- outputOptions
1079
+ outputOptions,
1080
+ perStep
1020
1081
  });
1021
1082
  self.executionResults = executionResultsPromise;
1022
1083
  let executionResults;
@@ -1132,7 +1193,9 @@ var InngestWorkflow = class _InngestWorkflow extends Workflow {
1132
1193
  workflowStatus: run.workflowRunStatus,
1133
1194
  stepResults: {}
1134
1195
  });
1135
- const workflowSnapshotInStorage = await this.getWorkflowRunExecutionResult(runIdToUse, false);
1196
+ const workflowSnapshotInStorage = await this.getWorkflowRunExecutionResult(runIdToUse, {
1197
+ withNestedWorkflows: false
1198
+ });
1136
1199
  if (!workflowSnapshotInStorage && shouldPersistSnapshot) {
1137
1200
  await this.mastra?.getStorage()?.persistWorkflowSnapshot({
1138
1201
  workflowName: this.id,
@@ -1171,7 +1234,7 @@ var InngestWorkflow = class _InngestWorkflow extends Workflow {
1171
1234
  },
1172
1235
  { event: `workflow.${this.id}` },
1173
1236
  async ({ event, step, attempt, publish }) => {
1174
- let { inputData, initialState, runId, resourceId, resume, outputOptions, format, timeTravel } = event.data;
1237
+ let { inputData, initialState, runId, resourceId, resume, outputOptions, format, timeTravel, perStep } = event.data;
1175
1238
  if (!runId) {
1176
1239
  runId = await step.run(`workflow.${this.id}.runIdGen`, async () => {
1177
1240
  return randomUUID();
@@ -1192,6 +1255,7 @@ var InngestWorkflow = class _InngestWorkflow extends Workflow {
1192
1255
  requestContext: new RequestContext(Object.entries(event.data.requestContext ?? {})),
1193
1256
  resume,
1194
1257
  timeTravel,
1258
+ perStep,
1195
1259
  format,
1196
1260
  abortController: new AbortController(),
1197
1261
  // currentSpan: undefined, // TODO: Pass actual parent Span from workflow execution context
@@ -1209,6 +1273,9 @@ var InngestWorkflow = class _InngestWorkflow extends Workflow {
1209
1273
  }
1210
1274
  });
1211
1275
  await step.run(`workflow.${this.id}.finalize`, async () => {
1276
+ if (result.status !== "paused") {
1277
+ await engine.invokeLifecycleCallbacksInternal(result);
1278
+ }
1212
1279
  if (result.status === "failed") {
1213
1280
  throw new NonRetriableError(`Workflow failed`, {
1214
1281
  cause: result