@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/CHANGELOG.md +312 -14
- package/dist/execution-engine.d.ts +22 -0
- package/dist/execution-engine.d.ts.map +1 -1
- package/dist/index.cjs +86 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +86 -19
- package/dist/index.js.map +1 -1
- package/dist/run.d.ts +13 -3
- package/dist/run.d.ts.map +1 -1
- package/dist/workflow.d.ts.map +1 -1
- package/package.json +7 -8
package/dist/index.cjs
CHANGED
|
@@ -138,6 +138,18 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
138
138
|
getEngineContext() {
|
|
139
139
|
return { step: this.inngestStep };
|
|
140
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* For Inngest, lifecycle callbacks are invoked in the workflow's finalize step
|
|
143
|
+
* (wrapped in step.run for durability), not in execute(). Override to skip.
|
|
144
|
+
*/
|
|
145
|
+
async invokeLifecycleCallbacks(_result) {
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Actually invoke the lifecycle callbacks. Called from workflow.ts finalize step.
|
|
149
|
+
*/
|
|
150
|
+
async invokeLifecycleCallbacksInternal(result) {
|
|
151
|
+
return super.invokeLifecycleCallbacks(result);
|
|
152
|
+
}
|
|
141
153
|
/**
|
|
142
154
|
* Execute nested InngestWorkflow using inngestStep.invoke() for durability.
|
|
143
155
|
* This MUST be called directly (not inside step.run()) due to Inngest constraints.
|
|
@@ -146,7 +158,18 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
146
158
|
if (!(params.step instanceof InngestWorkflow)) {
|
|
147
159
|
return null;
|
|
148
160
|
}
|
|
149
|
-
const {
|
|
161
|
+
const {
|
|
162
|
+
step,
|
|
163
|
+
stepResults,
|
|
164
|
+
executionContext,
|
|
165
|
+
resume,
|
|
166
|
+
timeTravel,
|
|
167
|
+
prevOutput,
|
|
168
|
+
inputData,
|
|
169
|
+
pubsub,
|
|
170
|
+
startedAt,
|
|
171
|
+
perStep
|
|
172
|
+
} = params;
|
|
150
173
|
const isResume = !!resume?.steps?.length;
|
|
151
174
|
let result;
|
|
152
175
|
let runId;
|
|
@@ -171,7 +194,8 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
171
194
|
resumePayload: resume.resumePayload,
|
|
172
195
|
resumePath: resume.steps?.[1] ? snapshot?.suspendedPaths?.[resume.steps?.[1]] : void 0
|
|
173
196
|
},
|
|
174
|
-
outputOptions: { includeState: true }
|
|
197
|
+
outputOptions: { includeState: true },
|
|
198
|
+
perStep
|
|
175
199
|
}
|
|
176
200
|
});
|
|
177
201
|
result = invokeResp.result;
|
|
@@ -197,7 +221,8 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
197
221
|
timeTravel: timeTravelParams,
|
|
198
222
|
initialState: executionContext.state ?? {},
|
|
199
223
|
runId: executionContext.runId,
|
|
200
|
-
outputOptions: { includeState: true }
|
|
224
|
+
outputOptions: { includeState: true },
|
|
225
|
+
perStep
|
|
201
226
|
}
|
|
202
227
|
});
|
|
203
228
|
result = invokeResp.result;
|
|
@@ -209,7 +234,8 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
209
234
|
data: {
|
|
210
235
|
inputData,
|
|
211
236
|
initialState: executionContext.state ?? {},
|
|
212
|
-
outputOptions: { includeState: true }
|
|
237
|
+
outputOptions: { includeState: true },
|
|
238
|
+
perStep
|
|
213
239
|
}
|
|
214
240
|
});
|
|
215
241
|
result = invokeResp.result;
|
|
@@ -248,7 +274,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
248
274
|
}
|
|
249
275
|
}
|
|
250
276
|
});
|
|
251
|
-
return { executionContext, result: { status: "failed", error: result?.error } };
|
|
277
|
+
return { executionContext, result: { status: "failed", error: result?.error, endedAt: Date.now() } };
|
|
252
278
|
} else if (result.status === "suspended") {
|
|
253
279
|
const suspendedSteps = Object.entries(result.steps).filter(([_stepName, stepResult]) => {
|
|
254
280
|
const stepRes = stepResult;
|
|
@@ -272,6 +298,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
272
298
|
executionContext,
|
|
273
299
|
result: {
|
|
274
300
|
status: "suspended",
|
|
301
|
+
suspendedAt: Date.now(),
|
|
275
302
|
payload: stepResult.payload,
|
|
276
303
|
suspendPayload: {
|
|
277
304
|
...stepResult?.suspendPayload,
|
|
@@ -284,6 +311,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
284
311
|
executionContext,
|
|
285
312
|
result: {
|
|
286
313
|
status: "suspended",
|
|
314
|
+
suspendedAt: Date.now(),
|
|
287
315
|
payload: {}
|
|
288
316
|
}
|
|
289
317
|
};
|
|
@@ -305,9 +333,34 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
305
333
|
executionContext,
|
|
306
334
|
result: {
|
|
307
335
|
status: "tripwire",
|
|
308
|
-
tripwire: result?.tripwire
|
|
336
|
+
tripwire: result?.tripwire,
|
|
337
|
+
endedAt: Date.now()
|
|
309
338
|
}
|
|
310
339
|
};
|
|
340
|
+
} else if (perStep || result.status === "paused") {
|
|
341
|
+
await pubsub.publish(`workflow.events.v2.${executionContext.runId}`, {
|
|
342
|
+
type: "watch",
|
|
343
|
+
runId: executionContext.runId,
|
|
344
|
+
data: {
|
|
345
|
+
type: "workflow-step-result",
|
|
346
|
+
payload: {
|
|
347
|
+
id: step.id,
|
|
348
|
+
status: "paused"
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
await pubsub.publish(`workflow.events.v2.${executionContext.runId}`, {
|
|
353
|
+
type: "watch",
|
|
354
|
+
runId: executionContext.runId,
|
|
355
|
+
data: {
|
|
356
|
+
type: "workflow-step-finish",
|
|
357
|
+
payload: {
|
|
358
|
+
id: step.id,
|
|
359
|
+
metadata: {}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
return { executionContext, result: { status: "paused" } };
|
|
311
364
|
}
|
|
312
365
|
await pubsub.publish(`workflow.events.v2.${executionContext.runId}`, {
|
|
313
366
|
type: "watch",
|
|
@@ -332,14 +385,13 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
332
385
|
}
|
|
333
386
|
}
|
|
334
387
|
});
|
|
335
|
-
return { executionContext, result: { status: "success", output: result?.result } };
|
|
388
|
+
return { executionContext, result: { status: "success", output: result?.result, endedAt: Date.now() } };
|
|
336
389
|
}
|
|
337
390
|
);
|
|
338
391
|
Object.assign(executionContext, res.executionContext);
|
|
339
392
|
return {
|
|
340
393
|
...res.result,
|
|
341
394
|
startedAt,
|
|
342
|
-
endedAt: Date.now(),
|
|
343
395
|
payload: inputData,
|
|
344
396
|
resumedAt: resume?.steps[0] === step.id ? startedAt : void 0,
|
|
345
397
|
resumePayload: resume?.steps[0] === step.id ? resume?.resumePayload : void 0
|
|
@@ -617,7 +669,8 @@ var InngestRun = class extends workflows.Run {
|
|
|
617
669
|
resourceId: this.resourceId,
|
|
618
670
|
outputOptions: params.outputOptions,
|
|
619
671
|
tracingOptions: params.tracingOptions,
|
|
620
|
-
requestContext: params.requestContext ? Object.fromEntries(params.requestContext.entries()) : {}
|
|
672
|
+
requestContext: params.requestContext ? Object.fromEntries(params.requestContext.entries()) : {},
|
|
673
|
+
perStep: params.perStep
|
|
621
674
|
}
|
|
622
675
|
});
|
|
623
676
|
const eventId = eventOutput.ids[0];
|
|
@@ -632,7 +685,8 @@ var InngestRun = class extends workflows.Run {
|
|
|
632
685
|
outputOptions,
|
|
633
686
|
tracingOptions,
|
|
634
687
|
format,
|
|
635
|
-
requestContext
|
|
688
|
+
requestContext,
|
|
689
|
+
perStep
|
|
636
690
|
}) {
|
|
637
691
|
await this.#mastra.getStorage()?.persistWorkflowSnapshot({
|
|
638
692
|
workflowName: this.workflowId,
|
|
@@ -664,7 +718,8 @@ var InngestRun = class extends workflows.Run {
|
|
|
664
718
|
outputOptions,
|
|
665
719
|
tracingOptions,
|
|
666
720
|
format,
|
|
667
|
-
requestContext: requestContext ? Object.fromEntries(requestContext.entries()) : {}
|
|
721
|
+
requestContext: requestContext ? Object.fromEntries(requestContext.entries()) : {},
|
|
722
|
+
perStep
|
|
668
723
|
}
|
|
669
724
|
});
|
|
670
725
|
const eventId = eventOutput.ids[0];
|
|
@@ -723,7 +778,8 @@ var InngestRun = class extends workflows.Run {
|
|
|
723
778
|
resumePayload: resumeDataToUse,
|
|
724
779
|
resumePath: steps?.[0] ? snapshot?.suspendedPaths?.[steps?.[0]] : void 0
|
|
725
780
|
},
|
|
726
|
-
requestContext: mergedRequestContext
|
|
781
|
+
requestContext: mergedRequestContext,
|
|
782
|
+
perStep: params.perStep
|
|
727
783
|
}
|
|
728
784
|
});
|
|
729
785
|
const eventId = eventOutput.ids[0];
|
|
@@ -813,7 +869,8 @@ var InngestRun = class extends workflows.Run {
|
|
|
813
869
|
timeTravel: timeTravelData,
|
|
814
870
|
tracingOptions: params.tracingOptions,
|
|
815
871
|
outputOptions: params.outputOptions,
|
|
816
|
-
requestContext: params.requestContext ? Object.fromEntries(params.requestContext.entries()) : {}
|
|
872
|
+
requestContext: params.requestContext ? Object.fromEntries(params.requestContext.entries()) : {},
|
|
873
|
+
perStep: params.perStep
|
|
817
874
|
}
|
|
818
875
|
});
|
|
819
876
|
const eventId = eventOutput.ids[0];
|
|
@@ -904,7 +961,8 @@ var InngestRun = class extends workflows.Run {
|
|
|
904
961
|
tracingOptions,
|
|
905
962
|
closeOnSuspend = true,
|
|
906
963
|
initialState,
|
|
907
|
-
outputOptions
|
|
964
|
+
outputOptions,
|
|
965
|
+
perStep
|
|
908
966
|
} = {}) {
|
|
909
967
|
if (this.closeStreamAction && this.streamOutput) {
|
|
910
968
|
return this.streamOutput;
|
|
@@ -940,7 +998,8 @@ var InngestRun = class extends workflows.Run {
|
|
|
940
998
|
initialState,
|
|
941
999
|
tracingOptions,
|
|
942
1000
|
outputOptions,
|
|
943
|
-
format: "vnext"
|
|
1001
|
+
format: "vnext",
|
|
1002
|
+
perStep
|
|
944
1003
|
});
|
|
945
1004
|
let executionResults;
|
|
946
1005
|
try {
|
|
@@ -983,7 +1042,8 @@ var InngestRun = class extends workflows.Run {
|
|
|
983
1042
|
nestedStepsContext,
|
|
984
1043
|
requestContext,
|
|
985
1044
|
tracingOptions,
|
|
986
|
-
outputOptions
|
|
1045
|
+
outputOptions,
|
|
1046
|
+
perStep
|
|
987
1047
|
}) {
|
|
988
1048
|
this.closeStreamAction = async () => {
|
|
989
1049
|
};
|
|
@@ -1018,7 +1078,8 @@ var InngestRun = class extends workflows.Run {
|
|
|
1018
1078
|
initialState,
|
|
1019
1079
|
requestContext,
|
|
1020
1080
|
tracingOptions,
|
|
1021
|
-
outputOptions
|
|
1081
|
+
outputOptions,
|
|
1082
|
+
perStep
|
|
1022
1083
|
});
|
|
1023
1084
|
self.executionResults = executionResultsPromise;
|
|
1024
1085
|
let executionResults;
|
|
@@ -1134,7 +1195,9 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
|
|
|
1134
1195
|
workflowStatus: run.workflowRunStatus,
|
|
1135
1196
|
stepResults: {}
|
|
1136
1197
|
});
|
|
1137
|
-
const workflowSnapshotInStorage = await this.getWorkflowRunExecutionResult(runIdToUse,
|
|
1198
|
+
const workflowSnapshotInStorage = await this.getWorkflowRunExecutionResult(runIdToUse, {
|
|
1199
|
+
withNestedWorkflows: false
|
|
1200
|
+
});
|
|
1138
1201
|
if (!workflowSnapshotInStorage && shouldPersistSnapshot) {
|
|
1139
1202
|
await this.mastra?.getStorage()?.persistWorkflowSnapshot({
|
|
1140
1203
|
workflowName: this.id,
|
|
@@ -1173,7 +1236,7 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
|
|
|
1173
1236
|
},
|
|
1174
1237
|
{ event: `workflow.${this.id}` },
|
|
1175
1238
|
async ({ event, step, attempt, publish }) => {
|
|
1176
|
-
let { inputData, initialState, runId, resourceId, resume, outputOptions, format, timeTravel } = event.data;
|
|
1239
|
+
let { inputData, initialState, runId, resourceId, resume, outputOptions, format, timeTravel, perStep } = event.data;
|
|
1177
1240
|
if (!runId) {
|
|
1178
1241
|
runId = await step.run(`workflow.${this.id}.runIdGen`, async () => {
|
|
1179
1242
|
return crypto$1.randomUUID();
|
|
@@ -1194,6 +1257,7 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
|
|
|
1194
1257
|
requestContext: new di.RequestContext(Object.entries(event.data.requestContext ?? {})),
|
|
1195
1258
|
resume,
|
|
1196
1259
|
timeTravel,
|
|
1260
|
+
perStep,
|
|
1197
1261
|
format,
|
|
1198
1262
|
abortController: new AbortController(),
|
|
1199
1263
|
// currentSpan: undefined, // TODO: Pass actual parent Span from workflow execution context
|
|
@@ -1211,6 +1275,9 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
|
|
|
1211
1275
|
}
|
|
1212
1276
|
});
|
|
1213
1277
|
await step.run(`workflow.${this.id}.finalize`, async () => {
|
|
1278
|
+
if (result.status !== "paused") {
|
|
1279
|
+
await engine.invokeLifecycleCallbacksInternal(result);
|
|
1280
|
+
}
|
|
1214
1281
|
if (result.status === "failed") {
|
|
1215
1282
|
throw new inngest.NonRetriableError(`Workflow failed`, {
|
|
1216
1283
|
cause: result
|