@mastra/inngest 0.0.0-fix-zod4-schema-validation-20251212180638 → 0.0.0-fix-local-pkg-cwd-20251224015404
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 +533 -14
- package/dist/execution-engine.d.ts +22 -0
- package/dist/execution-engine.d.ts.map +1 -1
- package/dist/index.cjs +119 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +119 -34
- 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
|
@@ -65,6 +65,27 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
65
65
|
* Provide Inngest step primitive in engine context
|
|
66
66
|
*/
|
|
67
67
|
getEngineContext(): Record<string, any>;
|
|
68
|
+
/**
|
|
69
|
+
* For Inngest, lifecycle callbacks are invoked in the workflow's finalize step
|
|
70
|
+
* (wrapped in step.run for durability), not in execute(). Override to skip.
|
|
71
|
+
*/
|
|
72
|
+
invokeLifecycleCallbacks(_result: {
|
|
73
|
+
status: any;
|
|
74
|
+
result?: any;
|
|
75
|
+
error?: any;
|
|
76
|
+
steps: Record<string, any>;
|
|
77
|
+
tripwire?: any;
|
|
78
|
+
}): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Actually invoke the lifecycle callbacks. Called from workflow.ts finalize step.
|
|
81
|
+
*/
|
|
82
|
+
invokeLifecycleCallbacksInternal(result: {
|
|
83
|
+
status: any;
|
|
84
|
+
result?: any;
|
|
85
|
+
error?: any;
|
|
86
|
+
steps: Record<string, any>;
|
|
87
|
+
tripwire?: any;
|
|
88
|
+
}): Promise<void>;
|
|
68
89
|
/**
|
|
69
90
|
* Execute nested InngestWorkflow using inngestStep.invoke() for durability.
|
|
70
91
|
* This MUST be called directly (not inside step.run()) due to Inngest constraints.
|
|
@@ -83,6 +104,7 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
83
104
|
inputData: any;
|
|
84
105
|
pubsub: PubSub;
|
|
85
106
|
startedAt: number;
|
|
107
|
+
perStep?: boolean;
|
|
86
108
|
}): Promise<StepResult<any, any, any, any> | null>;
|
|
87
109
|
}
|
|
88
110
|
//# sourceMappingURL=execution-engine.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution-engine.d.ts","sourceRoot":"","sources":["../src/execution-engine.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,sBAAsB,EAAmC,MAAM,wBAAwB,CAAC;AACjG,OAAO,KAAK,EACV,gBAAgB,EAChB,IAAI,EACJ,UAAU,EAEV,sBAAsB,EACtB,yBAAyB,EAE1B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGpD,qBAAa,sBAAuB,SAAQ,sBAAsB;IAChE,OAAO,CAAC,WAAW,CAA+B;IAClD,OAAO,CAAC,eAAe,CAAS;gBAG9B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,EACzC,eAAe,EAAE,MAAM,YAAI,EAC3B,OAAO,EAAE,sBAAsB;IAWjC;;;OAGG;IACH,SAAS,CAAC,iBAAiB,CACzB,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,SAAS,EACjC,UAAU,EAAE,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GACzC,eAAe;IAUlB;;OAEG;IACH,oBAAoB,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC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U,CAAC,EAAE,yBAAyB,CAAC;QACvC,UAAU,EAAE,GAAG,CAAC;QAChB,SAAS,EAAE,GAAG,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;CA6QnD"}
|
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;
|
|
@@ -154,7 +177,8 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
154
177
|
try {
|
|
155
178
|
if (isResume) {
|
|
156
179
|
runId = stepResults[resume?.steps?.[0] ?? ""]?.suspendPayload?.__workflow_meta?.runId ?? crypto$1.randomUUID();
|
|
157
|
-
const
|
|
180
|
+
const workflowsStore = await this.mastra?.getStorage()?.getStore("workflows");
|
|
181
|
+
const snapshot = await workflowsStore?.loadWorkflowSnapshot({
|
|
158
182
|
workflowName: step.id,
|
|
159
183
|
runId
|
|
160
184
|
});
|
|
@@ -171,14 +195,16 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
171
195
|
resumePayload: resume.resumePayload,
|
|
172
196
|
resumePath: resume.steps?.[1] ? snapshot?.suspendedPaths?.[resume.steps?.[1]] : void 0
|
|
173
197
|
},
|
|
174
|
-
outputOptions: { includeState: true }
|
|
198
|
+
outputOptions: { includeState: true },
|
|
199
|
+
perStep
|
|
175
200
|
}
|
|
176
201
|
});
|
|
177
202
|
result = invokeResp.result;
|
|
178
203
|
runId = invokeResp.runId;
|
|
179
204
|
executionContext.state = invokeResp.result.state;
|
|
180
205
|
} else if (isTimeTravel) {
|
|
181
|
-
const
|
|
206
|
+
const workflowsStoreForTimeTravel = await this.mastra?.getStorage()?.getStore("workflows");
|
|
207
|
+
const snapshot = await workflowsStoreForTimeTravel?.loadWorkflowSnapshot({
|
|
182
208
|
workflowName: step.id,
|
|
183
209
|
runId: executionContext.runId
|
|
184
210
|
}) ?? { context: {} };
|
|
@@ -197,7 +223,8 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
197
223
|
timeTravel: timeTravelParams,
|
|
198
224
|
initialState: executionContext.state ?? {},
|
|
199
225
|
runId: executionContext.runId,
|
|
200
|
-
outputOptions: { includeState: true }
|
|
226
|
+
outputOptions: { includeState: true },
|
|
227
|
+
perStep
|
|
201
228
|
}
|
|
202
229
|
});
|
|
203
230
|
result = invokeResp.result;
|
|
@@ -209,7 +236,8 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
209
236
|
data: {
|
|
210
237
|
inputData,
|
|
211
238
|
initialState: executionContext.state ?? {},
|
|
212
|
-
outputOptions: { includeState: true }
|
|
239
|
+
outputOptions: { includeState: true },
|
|
240
|
+
perStep
|
|
213
241
|
}
|
|
214
242
|
});
|
|
215
243
|
result = invokeResp.result;
|
|
@@ -248,7 +276,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
248
276
|
}
|
|
249
277
|
}
|
|
250
278
|
});
|
|
251
|
-
return { executionContext, result: { status: "failed", error: result?.error } };
|
|
279
|
+
return { executionContext, result: { status: "failed", error: result?.error, endedAt: Date.now() } };
|
|
252
280
|
} else if (result.status === "suspended") {
|
|
253
281
|
const suspendedSteps = Object.entries(result.steps).filter(([_stepName, stepResult]) => {
|
|
254
282
|
const stepRes = stepResult;
|
|
@@ -272,6 +300,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
272
300
|
executionContext,
|
|
273
301
|
result: {
|
|
274
302
|
status: "suspended",
|
|
303
|
+
suspendedAt: Date.now(),
|
|
275
304
|
payload: stepResult.payload,
|
|
276
305
|
suspendPayload: {
|
|
277
306
|
...stepResult?.suspendPayload,
|
|
@@ -284,6 +313,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
284
313
|
executionContext,
|
|
285
314
|
result: {
|
|
286
315
|
status: "suspended",
|
|
316
|
+
suspendedAt: Date.now(),
|
|
287
317
|
payload: {}
|
|
288
318
|
}
|
|
289
319
|
};
|
|
@@ -305,9 +335,34 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
305
335
|
executionContext,
|
|
306
336
|
result: {
|
|
307
337
|
status: "tripwire",
|
|
308
|
-
tripwire: result?.tripwire
|
|
338
|
+
tripwire: result?.tripwire,
|
|
339
|
+
endedAt: Date.now()
|
|
309
340
|
}
|
|
310
341
|
};
|
|
342
|
+
} else if (perStep || result.status === "paused") {
|
|
343
|
+
await pubsub.publish(`workflow.events.v2.${executionContext.runId}`, {
|
|
344
|
+
type: "watch",
|
|
345
|
+
runId: executionContext.runId,
|
|
346
|
+
data: {
|
|
347
|
+
type: "workflow-step-result",
|
|
348
|
+
payload: {
|
|
349
|
+
id: step.id,
|
|
350
|
+
status: "paused"
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
await pubsub.publish(`workflow.events.v2.${executionContext.runId}`, {
|
|
355
|
+
type: "watch",
|
|
356
|
+
runId: executionContext.runId,
|
|
357
|
+
data: {
|
|
358
|
+
type: "workflow-step-finish",
|
|
359
|
+
payload: {
|
|
360
|
+
id: step.id,
|
|
361
|
+
metadata: {}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
return { executionContext, result: { status: "paused" } };
|
|
311
366
|
}
|
|
312
367
|
await pubsub.publish(`workflow.events.v2.${executionContext.runId}`, {
|
|
313
368
|
type: "watch",
|
|
@@ -332,14 +387,13 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
332
387
|
}
|
|
333
388
|
}
|
|
334
389
|
});
|
|
335
|
-
return { executionContext, result: { status: "success", output: result?.result } };
|
|
390
|
+
return { executionContext, result: { status: "success", output: result?.result, endedAt: Date.now() } };
|
|
336
391
|
}
|
|
337
392
|
);
|
|
338
393
|
Object.assign(executionContext, res.executionContext);
|
|
339
394
|
return {
|
|
340
395
|
...res.result,
|
|
341
396
|
startedAt,
|
|
342
|
-
endedAt: Date.now(),
|
|
343
397
|
payload: inputData,
|
|
344
398
|
resumedAt: resume?.steps[0] === step.id ? startedAt : void 0,
|
|
345
399
|
resumePayload: resume?.steps[0] === step.id ? resume?.resumePayload : void 0
|
|
@@ -508,6 +562,7 @@ var InngestRun = class extends workflows.Run {
|
|
|
508
562
|
async getRunOutput(eventId, maxWaitMs = 3e5) {
|
|
509
563
|
const startTime = Date.now();
|
|
510
564
|
const storage = this.#mastra?.getStorage();
|
|
565
|
+
const workflowsStore = await storage?.getStore("workflows");
|
|
511
566
|
while (Date.now() - startTime < maxWaitMs) {
|
|
512
567
|
let runs;
|
|
513
568
|
try {
|
|
@@ -524,7 +579,7 @@ var InngestRun = class extends workflows.Run {
|
|
|
524
579
|
return runs[0];
|
|
525
580
|
}
|
|
526
581
|
if (runs?.[0]?.status === "Failed") {
|
|
527
|
-
const snapshot = await
|
|
582
|
+
const snapshot = await workflowsStore?.loadWorkflowSnapshot({
|
|
528
583
|
workflowName: this.workflowId,
|
|
529
584
|
runId: this.runId
|
|
530
585
|
});
|
|
@@ -543,7 +598,7 @@ var InngestRun = class extends workflows.Run {
|
|
|
543
598
|
};
|
|
544
599
|
}
|
|
545
600
|
if (runs?.[0]?.status === "Cancelled") {
|
|
546
|
-
const snapshot = await
|
|
601
|
+
const snapshot = await workflowsStore?.loadWorkflowSnapshot({
|
|
547
602
|
workflowName: this.workflowId,
|
|
548
603
|
runId: this.runId
|
|
549
604
|
});
|
|
@@ -561,12 +616,13 @@ var InngestRun = class extends workflows.Run {
|
|
|
561
616
|
runId: this.runId
|
|
562
617
|
}
|
|
563
618
|
});
|
|
564
|
-
const
|
|
619
|
+
const workflowsStore = await storage?.getStore("workflows");
|
|
620
|
+
const snapshot = await workflowsStore?.loadWorkflowSnapshot({
|
|
565
621
|
workflowName: this.workflowId,
|
|
566
622
|
runId: this.runId
|
|
567
623
|
});
|
|
568
624
|
if (snapshot) {
|
|
569
|
-
await
|
|
625
|
+
await workflowsStore?.persistWorkflowSnapshot({
|
|
570
626
|
workflowName: this.workflowId,
|
|
571
627
|
runId: this.runId,
|
|
572
628
|
resourceId: this.resourceId,
|
|
@@ -588,7 +644,8 @@ var InngestRun = class extends workflows.Run {
|
|
|
588
644
|
* Use this when you don't need to wait for the result or want to avoid polling failures.
|
|
589
645
|
*/
|
|
590
646
|
async startAsync(params) {
|
|
591
|
-
await this.#mastra.getStorage()?.
|
|
647
|
+
const workflowsStore = await this.#mastra.getStorage()?.getStore("workflows");
|
|
648
|
+
await workflowsStore?.persistWorkflowSnapshot({
|
|
592
649
|
workflowName: this.workflowId,
|
|
593
650
|
runId: this.runId,
|
|
594
651
|
resourceId: this.resourceId,
|
|
@@ -617,7 +674,8 @@ var InngestRun = class extends workflows.Run {
|
|
|
617
674
|
resourceId: this.resourceId,
|
|
618
675
|
outputOptions: params.outputOptions,
|
|
619
676
|
tracingOptions: params.tracingOptions,
|
|
620
|
-
requestContext: params.requestContext ? Object.fromEntries(params.requestContext.entries()) : {}
|
|
677
|
+
requestContext: params.requestContext ? Object.fromEntries(params.requestContext.entries()) : {},
|
|
678
|
+
perStep: params.perStep
|
|
621
679
|
}
|
|
622
680
|
});
|
|
623
681
|
const eventId = eventOutput.ids[0];
|
|
@@ -632,9 +690,11 @@ var InngestRun = class extends workflows.Run {
|
|
|
632
690
|
outputOptions,
|
|
633
691
|
tracingOptions,
|
|
634
692
|
format,
|
|
635
|
-
requestContext
|
|
693
|
+
requestContext,
|
|
694
|
+
perStep
|
|
636
695
|
}) {
|
|
637
|
-
await this.#mastra.getStorage()?.
|
|
696
|
+
const workflowsStore = await this.#mastra.getStorage()?.getStore("workflows");
|
|
697
|
+
await workflowsStore?.persistWorkflowSnapshot({
|
|
638
698
|
workflowName: this.workflowId,
|
|
639
699
|
runId: this.runId,
|
|
640
700
|
resourceId: this.resourceId,
|
|
@@ -664,7 +724,8 @@ var InngestRun = class extends workflows.Run {
|
|
|
664
724
|
outputOptions,
|
|
665
725
|
tracingOptions,
|
|
666
726
|
format,
|
|
667
|
-
requestContext: requestContext ? Object.fromEntries(requestContext.entries()) : {}
|
|
727
|
+
requestContext: requestContext ? Object.fromEntries(requestContext.entries()) : {},
|
|
728
|
+
perStep
|
|
668
729
|
}
|
|
669
730
|
});
|
|
670
731
|
const eventId = eventOutput.ids[0];
|
|
@@ -700,7 +761,8 @@ var InngestRun = class extends workflows.Run {
|
|
|
700
761
|
(step) => typeof step === "string" ? step : step?.id
|
|
701
762
|
);
|
|
702
763
|
}
|
|
703
|
-
const
|
|
764
|
+
const workflowsStore = await storage?.getStore("workflows");
|
|
765
|
+
const snapshot = await workflowsStore?.loadWorkflowSnapshot({
|
|
704
766
|
workflowName: this.workflowId,
|
|
705
767
|
runId: this.runId
|
|
706
768
|
});
|
|
@@ -723,7 +785,8 @@ var InngestRun = class extends workflows.Run {
|
|
|
723
785
|
resumePayload: resumeDataToUse,
|
|
724
786
|
resumePath: steps?.[0] ? snapshot?.suspendedPaths?.[steps?.[0]] : void 0
|
|
725
787
|
},
|
|
726
|
-
requestContext: mergedRequestContext
|
|
788
|
+
requestContext: mergedRequestContext,
|
|
789
|
+
perStep: params.perStep
|
|
727
790
|
}
|
|
728
791
|
});
|
|
729
792
|
const eventId = eventOutput.ids[0];
|
|
@@ -762,12 +825,13 @@ var InngestRun = class extends workflows.Run {
|
|
|
762
825
|
throw new Error("No steps provided to timeTravel");
|
|
763
826
|
}
|
|
764
827
|
const storage = this.#mastra?.getStorage();
|
|
765
|
-
const
|
|
828
|
+
const workflowsStore = await storage?.getStore("workflows");
|
|
829
|
+
const snapshot = await workflowsStore?.loadWorkflowSnapshot({
|
|
766
830
|
workflowName: this.workflowId,
|
|
767
831
|
runId: this.runId
|
|
768
832
|
});
|
|
769
833
|
if (!snapshot) {
|
|
770
|
-
await
|
|
834
|
+
await workflowsStore?.persistWorkflowSnapshot({
|
|
771
835
|
workflowName: this.workflowId,
|
|
772
836
|
runId: this.runId,
|
|
773
837
|
resourceId: this.resourceId,
|
|
@@ -801,7 +865,8 @@ var InngestRun = class extends workflows.Run {
|
|
|
801
865
|
nestedStepsContext: params.nestedStepsContext,
|
|
802
866
|
snapshot: snapshot ?? { context: {} },
|
|
803
867
|
graph: this.executionGraph,
|
|
804
|
-
initialState: params.initialState
|
|
868
|
+
initialState: params.initialState,
|
|
869
|
+
perStep: params.perStep
|
|
805
870
|
});
|
|
806
871
|
const eventOutput = await this.inngest.send({
|
|
807
872
|
name: `workflow.${this.workflowId}`,
|
|
@@ -813,7 +878,8 @@ var InngestRun = class extends workflows.Run {
|
|
|
813
878
|
timeTravel: timeTravelData,
|
|
814
879
|
tracingOptions: params.tracingOptions,
|
|
815
880
|
outputOptions: params.outputOptions,
|
|
816
|
-
requestContext: params.requestContext ? Object.fromEntries(params.requestContext.entries()) : {}
|
|
881
|
+
requestContext: params.requestContext ? Object.fromEntries(params.requestContext.entries()) : {},
|
|
882
|
+
perStep: params.perStep
|
|
817
883
|
}
|
|
818
884
|
});
|
|
819
885
|
const eventId = eventOutput.ids[0];
|
|
@@ -904,7 +970,8 @@ var InngestRun = class extends workflows.Run {
|
|
|
904
970
|
tracingOptions,
|
|
905
971
|
closeOnSuspend = true,
|
|
906
972
|
initialState,
|
|
907
|
-
outputOptions
|
|
973
|
+
outputOptions,
|
|
974
|
+
perStep
|
|
908
975
|
} = {}) {
|
|
909
976
|
if (this.closeStreamAction && this.streamOutput) {
|
|
910
977
|
return this.streamOutput;
|
|
@@ -940,7 +1007,8 @@ var InngestRun = class extends workflows.Run {
|
|
|
940
1007
|
initialState,
|
|
941
1008
|
tracingOptions,
|
|
942
1009
|
outputOptions,
|
|
943
|
-
format: "vnext"
|
|
1010
|
+
format: "vnext",
|
|
1011
|
+
perStep
|
|
944
1012
|
});
|
|
945
1013
|
let executionResults;
|
|
946
1014
|
try {
|
|
@@ -983,7 +1051,8 @@ var InngestRun = class extends workflows.Run {
|
|
|
983
1051
|
nestedStepsContext,
|
|
984
1052
|
requestContext,
|
|
985
1053
|
tracingOptions,
|
|
986
|
-
outputOptions
|
|
1054
|
+
outputOptions,
|
|
1055
|
+
perStep
|
|
987
1056
|
}) {
|
|
988
1057
|
this.closeStreamAction = async () => {
|
|
989
1058
|
};
|
|
@@ -1018,7 +1087,8 @@ var InngestRun = class extends workflows.Run {
|
|
|
1018
1087
|
initialState,
|
|
1019
1088
|
requestContext,
|
|
1020
1089
|
tracingOptions,
|
|
1021
|
-
outputOptions
|
|
1090
|
+
outputOptions,
|
|
1091
|
+
perStep
|
|
1022
1092
|
});
|
|
1023
1093
|
self.executionResults = executionResultsPromise;
|
|
1024
1094
|
let executionResults;
|
|
@@ -1080,7 +1150,11 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
|
|
|
1080
1150
|
this.logger.debug("Cannot get workflow runs. Mastra engine is not initialized");
|
|
1081
1151
|
return { runs: [], total: 0 };
|
|
1082
1152
|
}
|
|
1083
|
-
|
|
1153
|
+
const workflowsStore = await storage.getStore("workflows");
|
|
1154
|
+
if (!workflowsStore) {
|
|
1155
|
+
return { runs: [], total: 0 };
|
|
1156
|
+
}
|
|
1157
|
+
return workflowsStore.listWorkflowRuns({ workflowName: this.id, ...args ?? {} });
|
|
1084
1158
|
}
|
|
1085
1159
|
async getWorkflowRunById(runId) {
|
|
1086
1160
|
const storage = this.#mastra?.getStorage();
|
|
@@ -1088,7 +1162,11 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
|
|
|
1088
1162
|
this.logger.debug("Cannot get workflow runs. Mastra engine is not initialized");
|
|
1089
1163
|
return this.runs.get(runId) ? { ...this.runs.get(runId), workflowName: this.id } : null;
|
|
1090
1164
|
}
|
|
1091
|
-
const
|
|
1165
|
+
const workflowsStore = await storage.getStore("workflows");
|
|
1166
|
+
if (!workflowsStore) {
|
|
1167
|
+
return this.runs.get(runId) ? { ...this.runs.get(runId), workflowName: this.id } : null;
|
|
1168
|
+
}
|
|
1169
|
+
const run = await workflowsStore.getWorkflowRunById({ runId, workflowName: this.id });
|
|
1092
1170
|
return run ?? (this.runs.get(runId) ? { ...this.runs.get(runId), workflowName: this.id } : null);
|
|
1093
1171
|
}
|
|
1094
1172
|
__registerMastra(mastra) {
|
|
@@ -1134,9 +1212,12 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
|
|
|
1134
1212
|
workflowStatus: run.workflowRunStatus,
|
|
1135
1213
|
stepResults: {}
|
|
1136
1214
|
});
|
|
1137
|
-
const workflowSnapshotInStorage = await this.getWorkflowRunExecutionResult(runIdToUse,
|
|
1215
|
+
const workflowSnapshotInStorage = await this.getWorkflowRunExecutionResult(runIdToUse, {
|
|
1216
|
+
withNestedWorkflows: false
|
|
1217
|
+
});
|
|
1138
1218
|
if (!workflowSnapshotInStorage && shouldPersistSnapshot) {
|
|
1139
|
-
await this.mastra?.getStorage()?.
|
|
1219
|
+
const workflowsStore = await this.mastra?.getStorage()?.getStore("workflows");
|
|
1220
|
+
await workflowsStore?.persistWorkflowSnapshot({
|
|
1140
1221
|
workflowName: this.id,
|
|
1141
1222
|
runId: runIdToUse,
|
|
1142
1223
|
resourceId: options?.resourceId,
|
|
@@ -1173,7 +1254,7 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
|
|
|
1173
1254
|
},
|
|
1174
1255
|
{ event: `workflow.${this.id}` },
|
|
1175
1256
|
async ({ event, step, attempt, publish }) => {
|
|
1176
|
-
let { inputData, initialState, runId, resourceId, resume, outputOptions, format, timeTravel } = event.data;
|
|
1257
|
+
let { inputData, initialState, runId, resourceId, resume, outputOptions, format, timeTravel, perStep } = event.data;
|
|
1177
1258
|
if (!runId) {
|
|
1178
1259
|
runId = await step.run(`workflow.${this.id}.runIdGen`, async () => {
|
|
1179
1260
|
return crypto$1.randomUUID();
|
|
@@ -1194,6 +1275,7 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
|
|
|
1194
1275
|
requestContext: new di.RequestContext(Object.entries(event.data.requestContext ?? {})),
|
|
1195
1276
|
resume,
|
|
1196
1277
|
timeTravel,
|
|
1278
|
+
perStep,
|
|
1197
1279
|
format,
|
|
1198
1280
|
abortController: new AbortController(),
|
|
1199
1281
|
// currentSpan: undefined, // TODO: Pass actual parent Span from workflow execution context
|
|
@@ -1211,6 +1293,9 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
|
|
|
1211
1293
|
}
|
|
1212
1294
|
});
|
|
1213
1295
|
await step.run(`workflow.${this.id}.finalize`, async () => {
|
|
1296
|
+
if (result.status !== "paused") {
|
|
1297
|
+
await engine.invokeLifecycleCallbacksInternal(result);
|
|
1298
|
+
}
|
|
1214
1299
|
if (result.status === "failed") {
|
|
1215
1300
|
throw new inngest.NonRetriableError(`Workflow failed`, {
|
|
1216
1301
|
cause: result
|