@mastra/inngest 0.0.0-fix-fetching-workflow-snapshots-20250625000954 → 0.0.0-http-transporter-20250702160118
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 +70 -2
- package/dist/_tsup-dts-rollup.d.cts +9 -13
- package/dist/_tsup-dts-rollup.d.ts +9 -13
- package/dist/index.cjs +109 -39
- package/dist/index.js +109 -39
- package/docker-compose.yaml +3 -3
- package/package.json +10 -9
- package/src/index.test.ts +501 -238
- package/src/index.ts +112 -39
- package/vitest.config.ts +6 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,74 @@
|
|
|
1
1
|
# @mastra/inngest
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
3
|
+
## 0.0.0-http-transporter-20250702160118
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 48d9738: Fix inngest sleep stream events
|
|
8
|
+
- Updated dependencies [4d3fbdf]
|
|
9
|
+
- @mastra/core@0.0.0-http-transporter-20250702160118
|
|
10
|
+
|
|
11
|
+
## 0.11.2-alpha.0
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 48d9738: Fix inngest sleep stream events
|
|
16
|
+
- Updated dependencies [4d3fbdf]
|
|
17
|
+
- @mastra/core@0.10.10-alpha.0
|
|
18
|
+
|
|
19
|
+
## 0.11.1
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- e423a31: Fix bug where nested workflows would cause Inngest duplicate key error
|
|
24
|
+
- 764f86a: Introduces the runCount property in the execution parameters for the steps execute function
|
|
25
|
+
- 1760a1c: Use workflow stream in playground instead of watch
|
|
26
|
+
- 038e5ae: Add cancel workflow run
|
|
27
|
+
- 81a1b3b: Update peerdeps
|
|
28
|
+
- Updated dependencies [9dda1ac]
|
|
29
|
+
- Updated dependencies [c984582]
|
|
30
|
+
- Updated dependencies [7e801dd]
|
|
31
|
+
- Updated dependencies [a606c75]
|
|
32
|
+
- Updated dependencies [7aa70a4]
|
|
33
|
+
- Updated dependencies [764f86a]
|
|
34
|
+
- Updated dependencies [1760a1c]
|
|
35
|
+
- Updated dependencies [038e5ae]
|
|
36
|
+
- Updated dependencies [7dda16a]
|
|
37
|
+
- Updated dependencies [5ebfcdd]
|
|
38
|
+
- Updated dependencies [b2d0c91]
|
|
39
|
+
- Updated dependencies [4e809ad]
|
|
40
|
+
- Updated dependencies [57929df]
|
|
41
|
+
- Updated dependencies [b7852ed]
|
|
42
|
+
- Updated dependencies [6320a61]
|
|
43
|
+
- @mastra/core@0.10.9
|
|
44
|
+
|
|
45
|
+
## 0.11.1-alpha.0
|
|
46
|
+
|
|
47
|
+
### Patch Changes
|
|
48
|
+
|
|
49
|
+
- e423a31: Fix bug where nested workflows would cause Inngest duplicate key error
|
|
50
|
+
- 764f86a: Introduces the runCount property in the execution parameters for the steps execute function
|
|
51
|
+
- 1760a1c: Use workflow stream in playground instead of watch
|
|
52
|
+
- 038e5ae: Add cancel workflow run
|
|
53
|
+
- 81a1b3b: Update peerdeps
|
|
54
|
+
- Updated dependencies [9dda1ac]
|
|
55
|
+
- Updated dependencies [c984582]
|
|
56
|
+
- Updated dependencies [7e801dd]
|
|
57
|
+
- Updated dependencies [a606c75]
|
|
58
|
+
- Updated dependencies [7aa70a4]
|
|
59
|
+
- Updated dependencies [764f86a]
|
|
60
|
+
- Updated dependencies [1760a1c]
|
|
61
|
+
- Updated dependencies [038e5ae]
|
|
62
|
+
- Updated dependencies [7dda16a]
|
|
63
|
+
- Updated dependencies [5ebfcdd]
|
|
64
|
+
- Updated dependencies [b2d0c91]
|
|
65
|
+
- Updated dependencies [4e809ad]
|
|
66
|
+
- Updated dependencies [57929df]
|
|
67
|
+
- Updated dependencies [b7852ed]
|
|
68
|
+
- Updated dependencies [6320a61]
|
|
69
|
+
- @mastra/core@0.10.9-alpha.0
|
|
70
|
+
|
|
71
|
+
## 0.11.0
|
|
4
72
|
|
|
5
73
|
### Minor Changes
|
|
6
74
|
|
|
@@ -31,7 +99,7 @@
|
|
|
31
99
|
- Updated dependencies [8ba1b51]
|
|
32
100
|
- Updated dependencies [4efcfa0]
|
|
33
101
|
- Updated dependencies [0e17048]
|
|
34
|
-
- @mastra/core@0.
|
|
102
|
+
- @mastra/core@0.10.7
|
|
35
103
|
|
|
36
104
|
## 0.11.0-alpha.3
|
|
37
105
|
|
|
@@ -91,9 +91,10 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
91
91
|
delay?: number;
|
|
92
92
|
};
|
|
93
93
|
runtimeContext: RuntimeContext;
|
|
94
|
+
abortController: AbortController;
|
|
94
95
|
}): Promise<TOutput>;
|
|
95
96
|
protected fmtReturnValue<TOutput>(executionSpan: Span | undefined, emitter: Emitter, stepResults: Record<string, StepResult<any, any, any, any>>, lastOutput: StepResult<any, any, any, any>, error?: Error | string): Promise<TOutput>;
|
|
96
|
-
superExecuteStep({ workflowId, runId, step, stepResults, executionContext, resume, prevOutput, emitter, runtimeContext, }: {
|
|
97
|
+
superExecuteStep({ workflowId, runId, step, stepResults, executionContext, resume, prevOutput, emitter, abortController, runtimeContext, }: {
|
|
97
98
|
workflowId: string;
|
|
98
99
|
runId: string;
|
|
99
100
|
step: Step<string, any, any>;
|
|
@@ -105,6 +106,7 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
105
106
|
};
|
|
106
107
|
prevOutput: any;
|
|
107
108
|
emitter: Emitter;
|
|
109
|
+
abortController: AbortController;
|
|
108
110
|
runtimeContext: RuntimeContext;
|
|
109
111
|
}): Promise<StepResult<any, any, any, any>>;
|
|
110
112
|
executeSleep({ id, duration }: {
|
|
@@ -115,19 +117,10 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
115
117
|
event: string;
|
|
116
118
|
timeout?: number;
|
|
117
119
|
}): Promise<any>;
|
|
118
|
-
executeStep({ step, stepResults, executionContext, resume, prevOutput, emitter, runtimeContext, }: {
|
|
120
|
+
executeStep({ step, stepResults, executionContext, resume, prevOutput, emitter, abortController, runtimeContext, }: {
|
|
119
121
|
step: Step<string, any, any>;
|
|
120
122
|
stepResults: Record<string, StepResult<any, any, any, any>>;
|
|
121
|
-
executionContext:
|
|
122
|
-
workflowId: string;
|
|
123
|
-
runId: string;
|
|
124
|
-
executionPath: number[];
|
|
125
|
-
suspendedPaths: Record<string, number[]>;
|
|
126
|
-
retryConfig: {
|
|
127
|
-
attempts: number;
|
|
128
|
-
delay: number;
|
|
129
|
-
};
|
|
130
|
-
};
|
|
123
|
+
executionContext: ExecutionContext;
|
|
131
124
|
resume?: {
|
|
132
125
|
steps: string[];
|
|
133
126
|
resumePayload: any;
|
|
@@ -135,6 +128,7 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
135
128
|
};
|
|
136
129
|
prevOutput: any;
|
|
137
130
|
emitter: Emitter;
|
|
131
|
+
abortController: AbortController;
|
|
138
132
|
runtimeContext: RuntimeContext;
|
|
139
133
|
}): Promise<StepResult<any, any, any, any>>;
|
|
140
134
|
persistStepUpdate({ workflowId, runId, stepResults, executionContext, serializedStepGraph, workflowStatus, result, error, }: {
|
|
@@ -147,7 +141,7 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
147
141
|
result?: Record<string, any>;
|
|
148
142
|
error?: string | Error;
|
|
149
143
|
}): Promise<void>;
|
|
150
|
-
executeConditional({ workflowId, runId, entry, prevOutput, prevStep, stepResults, serializedStepGraph, resume, executionContext, emitter, runtimeContext, }: {
|
|
144
|
+
executeConditional({ workflowId, runId, entry, prevOutput, prevStep, stepResults, serializedStepGraph, resume, executionContext, emitter, abortController, runtimeContext, }: {
|
|
151
145
|
workflowId: string;
|
|
152
146
|
runId: string;
|
|
153
147
|
entry: {
|
|
@@ -167,6 +161,7 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
167
161
|
};
|
|
168
162
|
executionContext: ExecutionContext;
|
|
169
163
|
emitter: Emitter;
|
|
164
|
+
abortController: AbortController;
|
|
170
165
|
runtimeContext: RuntimeContext;
|
|
171
166
|
}): Promise<StepResult<any, any, any, any>>;
|
|
172
167
|
}
|
|
@@ -191,6 +186,7 @@ export declare class InngestRun<TEngineType = InngestEngineType, TSteps extends
|
|
|
191
186
|
getRuns(eventId: string): Promise<any>;
|
|
192
187
|
getRunOutput(eventId: string): Promise<any>;
|
|
193
188
|
sendEvent(event: string, data: any): Promise<void>;
|
|
189
|
+
cancel(): Promise<void>;
|
|
194
190
|
start({ inputData, }: {
|
|
195
191
|
inputData?: z.infer<TInput>;
|
|
196
192
|
runtimeContext?: RuntimeContext;
|
|
@@ -91,9 +91,10 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
91
91
|
delay?: number;
|
|
92
92
|
};
|
|
93
93
|
runtimeContext: RuntimeContext;
|
|
94
|
+
abortController: AbortController;
|
|
94
95
|
}): Promise<TOutput>;
|
|
95
96
|
protected fmtReturnValue<TOutput>(executionSpan: Span | undefined, emitter: Emitter, stepResults: Record<string, StepResult<any, any, any, any>>, lastOutput: StepResult<any, any, any, any>, error?: Error | string): Promise<TOutput>;
|
|
96
|
-
superExecuteStep({ workflowId, runId, step, stepResults, executionContext, resume, prevOutput, emitter, runtimeContext, }: {
|
|
97
|
+
superExecuteStep({ workflowId, runId, step, stepResults, executionContext, resume, prevOutput, emitter, abortController, runtimeContext, }: {
|
|
97
98
|
workflowId: string;
|
|
98
99
|
runId: string;
|
|
99
100
|
step: Step<string, any, any>;
|
|
@@ -105,6 +106,7 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
105
106
|
};
|
|
106
107
|
prevOutput: any;
|
|
107
108
|
emitter: Emitter;
|
|
109
|
+
abortController: AbortController;
|
|
108
110
|
runtimeContext: RuntimeContext;
|
|
109
111
|
}): Promise<StepResult<any, any, any, any>>;
|
|
110
112
|
executeSleep({ id, duration }: {
|
|
@@ -115,19 +117,10 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
115
117
|
event: string;
|
|
116
118
|
timeout?: number;
|
|
117
119
|
}): Promise<any>;
|
|
118
|
-
executeStep({ step, stepResults, executionContext, resume, prevOutput, emitter, runtimeContext, }: {
|
|
120
|
+
executeStep({ step, stepResults, executionContext, resume, prevOutput, emitter, abortController, runtimeContext, }: {
|
|
119
121
|
step: Step<string, any, any>;
|
|
120
122
|
stepResults: Record<string, StepResult<any, any, any, any>>;
|
|
121
|
-
executionContext:
|
|
122
|
-
workflowId: string;
|
|
123
|
-
runId: string;
|
|
124
|
-
executionPath: number[];
|
|
125
|
-
suspendedPaths: Record<string, number[]>;
|
|
126
|
-
retryConfig: {
|
|
127
|
-
attempts: number;
|
|
128
|
-
delay: number;
|
|
129
|
-
};
|
|
130
|
-
};
|
|
123
|
+
executionContext: ExecutionContext;
|
|
131
124
|
resume?: {
|
|
132
125
|
steps: string[];
|
|
133
126
|
resumePayload: any;
|
|
@@ -135,6 +128,7 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
135
128
|
};
|
|
136
129
|
prevOutput: any;
|
|
137
130
|
emitter: Emitter;
|
|
131
|
+
abortController: AbortController;
|
|
138
132
|
runtimeContext: RuntimeContext;
|
|
139
133
|
}): Promise<StepResult<any, any, any, any>>;
|
|
140
134
|
persistStepUpdate({ workflowId, runId, stepResults, executionContext, serializedStepGraph, workflowStatus, result, error, }: {
|
|
@@ -147,7 +141,7 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
147
141
|
result?: Record<string, any>;
|
|
148
142
|
error?: string | Error;
|
|
149
143
|
}): Promise<void>;
|
|
150
|
-
executeConditional({ workflowId, runId, entry, prevOutput, prevStep, stepResults, serializedStepGraph, resume, executionContext, emitter, runtimeContext, }: {
|
|
144
|
+
executeConditional({ workflowId, runId, entry, prevOutput, prevStep, stepResults, serializedStepGraph, resume, executionContext, emitter, abortController, runtimeContext, }: {
|
|
151
145
|
workflowId: string;
|
|
152
146
|
runId: string;
|
|
153
147
|
entry: {
|
|
@@ -167,6 +161,7 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
167
161
|
};
|
|
168
162
|
executionContext: ExecutionContext;
|
|
169
163
|
emitter: Emitter;
|
|
164
|
+
abortController: AbortController;
|
|
170
165
|
runtimeContext: RuntimeContext;
|
|
171
166
|
}): Promise<StepResult<any, any, any, any>>;
|
|
172
167
|
}
|
|
@@ -191,6 +186,7 @@ export declare class InngestRun<TEngineType = InngestEngineType, TSteps extends
|
|
|
191
186
|
getRuns(eventId: string): Promise<any>;
|
|
192
187
|
getRunOutput(eventId: string): Promise<any>;
|
|
193
188
|
sendEvent(event: string, data: any): Promise<void>;
|
|
189
|
+
cancel(): Promise<void>;
|
|
194
190
|
start({ inputData, }: {
|
|
195
191
|
inputData?: z.infer<TInput>;
|
|
196
192
|
runtimeContext?: RuntimeContext;
|
package/dist/index.cjs
CHANGED
|
@@ -12,13 +12,17 @@ var zod = require('zod');
|
|
|
12
12
|
// src/index.ts
|
|
13
13
|
function serve({ mastra, inngest }) {
|
|
14
14
|
const wfs = mastra.getWorkflows();
|
|
15
|
-
const functions =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
const functions = Array.from(
|
|
16
|
+
new Set(
|
|
17
|
+
Object.values(wfs).flatMap((wf) => {
|
|
18
|
+
if (wf instanceof InngestWorkflow) {
|
|
19
|
+
wf.__registerMastra(mastra);
|
|
20
|
+
return wf.getFunctions();
|
|
21
|
+
}
|
|
22
|
+
return [];
|
|
23
|
+
})
|
|
24
|
+
)
|
|
25
|
+
);
|
|
22
26
|
return hono.serve({
|
|
23
27
|
client: inngest,
|
|
24
28
|
functions
|
|
@@ -48,8 +52,15 @@ var InngestRun = class extends workflows.Run {
|
|
|
48
52
|
while (runs?.[0]?.status !== "Completed" || runs?.[0]?.event_id !== eventId) {
|
|
49
53
|
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
50
54
|
runs = await this.getRuns(eventId);
|
|
51
|
-
if (runs?.[0]?.status === "Failed"
|
|
55
|
+
if (runs?.[0]?.status === "Failed") {
|
|
56
|
+
console.log("run", runs?.[0]);
|
|
52
57
|
throw new Error(`Function run ${runs?.[0]?.status}`);
|
|
58
|
+
} else if (runs?.[0]?.status === "Cancelled") {
|
|
59
|
+
const snapshot = await this.#mastra?.storage?.loadWorkflowSnapshot({
|
|
60
|
+
workflowName: this.workflowId,
|
|
61
|
+
runId: this.runId
|
|
62
|
+
});
|
|
63
|
+
return { output: { result: { steps: snapshot?.context, status: "canceled" } } };
|
|
53
64
|
}
|
|
54
65
|
}
|
|
55
66
|
return runs?.[0];
|
|
@@ -60,6 +71,28 @@ var InngestRun = class extends workflows.Run {
|
|
|
60
71
|
data
|
|
61
72
|
});
|
|
62
73
|
}
|
|
74
|
+
async cancel() {
|
|
75
|
+
await this.inngest.send({
|
|
76
|
+
name: `cancel.workflow.${this.workflowId}`,
|
|
77
|
+
data: {
|
|
78
|
+
runId: this.runId
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
const snapshot = await this.#mastra?.storage?.loadWorkflowSnapshot({
|
|
82
|
+
workflowName: this.workflowId,
|
|
83
|
+
runId: this.runId
|
|
84
|
+
});
|
|
85
|
+
if (snapshot) {
|
|
86
|
+
await this.#mastra?.storage?.persistWorkflowSnapshot({
|
|
87
|
+
workflowName: this.workflowId,
|
|
88
|
+
runId: this.runId,
|
|
89
|
+
snapshot: {
|
|
90
|
+
...snapshot,
|
|
91
|
+
status: "canceled"
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
63
96
|
async start({
|
|
64
97
|
inputData
|
|
65
98
|
}) {
|
|
@@ -93,7 +126,9 @@ var InngestRun = class extends workflows.Run {
|
|
|
93
126
|
if (result.status === "failed") {
|
|
94
127
|
result.error = new Error(result.error);
|
|
95
128
|
}
|
|
96
|
-
|
|
129
|
+
if (result.status !== "suspended") {
|
|
130
|
+
this.cleanup?.();
|
|
131
|
+
}
|
|
97
132
|
return result;
|
|
98
133
|
}
|
|
99
134
|
async resume(params) {
|
|
@@ -295,23 +330,26 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
|
|
|
295
330
|
this.inngest
|
|
296
331
|
);
|
|
297
332
|
this.runs.set(runIdToUse, run);
|
|
298
|
-
await this.
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
333
|
+
const workflowSnapshotInStorage = await this.getWorkflowRunExecutionResult(runIdToUse);
|
|
334
|
+
if (!workflowSnapshotInStorage) {
|
|
335
|
+
await this.mastra?.getStorage()?.persistWorkflowSnapshot({
|
|
336
|
+
workflowName: this.id,
|
|
302
337
|
runId: runIdToUse,
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
338
|
+
snapshot: {
|
|
339
|
+
runId: runIdToUse,
|
|
340
|
+
status: "pending",
|
|
341
|
+
value: {},
|
|
342
|
+
context: {},
|
|
343
|
+
activePaths: [],
|
|
344
|
+
serializedStepGraph: this.serializedStepGraph,
|
|
345
|
+
suspendedPaths: {},
|
|
346
|
+
result: void 0,
|
|
347
|
+
error: void 0,
|
|
348
|
+
// @ts-ignore
|
|
349
|
+
timestamp: Date.now()
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
}
|
|
315
353
|
return run;
|
|
316
354
|
}
|
|
317
355
|
getFunction() {
|
|
@@ -319,8 +357,12 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
|
|
|
319
357
|
return this.function;
|
|
320
358
|
}
|
|
321
359
|
this.function = this.inngest.createFunction(
|
|
322
|
-
|
|
323
|
-
|
|
360
|
+
{
|
|
361
|
+
id: `workflow.${this.id}`,
|
|
362
|
+
// @ts-ignore
|
|
363
|
+
retries: this.retryConfig?.attempts ?? 0,
|
|
364
|
+
cancelOn: [{ event: `cancel.workflow.${this.id}` }]
|
|
365
|
+
},
|
|
324
366
|
{ event: `workflow.${this.id}` },
|
|
325
367
|
async ({ event, step, attempt, publish }) => {
|
|
326
368
|
let { inputData, runId, resume } = event.data;
|
|
@@ -362,7 +404,8 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
|
|
|
362
404
|
retryConfig: this.retryConfig,
|
|
363
405
|
runtimeContext: new di.RuntimeContext(),
|
|
364
406
|
// TODO
|
|
365
|
-
resume
|
|
407
|
+
resume,
|
|
408
|
+
abortController: new AbortController()
|
|
366
409
|
});
|
|
367
410
|
return { result, runId };
|
|
368
411
|
}
|
|
@@ -406,7 +449,7 @@ function createStep(params) {
|
|
|
406
449
|
outputSchema: zod.z.object({
|
|
407
450
|
text: zod.z.string()
|
|
408
451
|
}),
|
|
409
|
-
execute: async ({ inputData, [_constants.EMITTER_SYMBOL]: emitter, runtimeContext }) => {
|
|
452
|
+
execute: async ({ inputData, [_constants.EMITTER_SYMBOL]: emitter, runtimeContext, abortSignal, abort }) => {
|
|
410
453
|
let streamPromise = {};
|
|
411
454
|
streamPromise.promise = new Promise((resolve, reject) => {
|
|
412
455
|
streamPromise.resolve = resolve;
|
|
@@ -426,8 +469,12 @@ function createStep(params) {
|
|
|
426
469
|
runtimeContext,
|
|
427
470
|
onFinish: (result) => {
|
|
428
471
|
streamPromise.resolve(result.text);
|
|
429
|
-
}
|
|
472
|
+
},
|
|
473
|
+
abortSignal
|
|
430
474
|
});
|
|
475
|
+
if (abortSignal.aborted) {
|
|
476
|
+
return abort();
|
|
477
|
+
}
|
|
431
478
|
for await (const chunk of fullStream) {
|
|
432
479
|
switch (chunk.type) {
|
|
433
480
|
case "text-delta":
|
|
@@ -602,6 +649,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
602
649
|
resume,
|
|
603
650
|
prevOutput,
|
|
604
651
|
emitter,
|
|
652
|
+
abortController,
|
|
605
653
|
runtimeContext
|
|
606
654
|
}) {
|
|
607
655
|
return super.executeStep({
|
|
@@ -613,6 +661,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
613
661
|
resume,
|
|
614
662
|
prevOutput,
|
|
615
663
|
emitter,
|
|
664
|
+
abortController,
|
|
616
665
|
runtimeContext
|
|
617
666
|
});
|
|
618
667
|
}
|
|
@@ -636,6 +685,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
636
685
|
resume,
|
|
637
686
|
prevOutput,
|
|
638
687
|
emitter,
|
|
688
|
+
abortController,
|
|
639
689
|
runtimeContext
|
|
640
690
|
}) {
|
|
641
691
|
const startedAt = await this.inngestStep.run(
|
|
@@ -666,7 +716,10 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
666
716
|
await emitter.emit("watch-v2", {
|
|
667
717
|
type: "step-start",
|
|
668
718
|
payload: {
|
|
669
|
-
id: step.id
|
|
719
|
+
id: step.id,
|
|
720
|
+
status: "running",
|
|
721
|
+
payload: prevOutput,
|
|
722
|
+
startedAt: startedAt2
|
|
670
723
|
}
|
|
671
724
|
});
|
|
672
725
|
return startedAt2;
|
|
@@ -734,7 +787,9 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
734
787
|
type: "step-result",
|
|
735
788
|
payload: {
|
|
736
789
|
id: step.id,
|
|
737
|
-
status: "failed"
|
|
790
|
+
status: "failed",
|
|
791
|
+
error: result?.error,
|
|
792
|
+
payload: prevOutput
|
|
738
793
|
}
|
|
739
794
|
});
|
|
740
795
|
return { executionContext, result: { status: "failed", error: result?.error } };
|
|
@@ -766,7 +821,8 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
766
821
|
await emitter.emit("watch-v2", {
|
|
767
822
|
type: "step-suspended",
|
|
768
823
|
payload: {
|
|
769
|
-
id: step.id
|
|
824
|
+
id: step.id,
|
|
825
|
+
status: "suspended"
|
|
770
826
|
}
|
|
771
827
|
});
|
|
772
828
|
return {
|
|
@@ -819,6 +875,14 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
819
875
|
},
|
|
820
876
|
eventTimestamp: Date.now()
|
|
821
877
|
});
|
|
878
|
+
await emitter.emit("watch-v2", {
|
|
879
|
+
type: "step-result",
|
|
880
|
+
payload: {
|
|
881
|
+
id: step.id,
|
|
882
|
+
status: "success",
|
|
883
|
+
output: result?.result
|
|
884
|
+
}
|
|
885
|
+
});
|
|
822
886
|
await emitter.emit("watch-v2", {
|
|
823
887
|
type: "step-finish",
|
|
824
888
|
payload: {
|
|
@@ -867,7 +931,8 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
867
931
|
[_constants.EMITTER_SYMBOL]: emitter,
|
|
868
932
|
engine: {
|
|
869
933
|
step: this.inngestStep
|
|
870
|
-
}
|
|
934
|
+
},
|
|
935
|
+
abortSignal: abortController.signal
|
|
871
936
|
});
|
|
872
937
|
const endedAt = Date.now();
|
|
873
938
|
execResults = {
|
|
@@ -929,8 +994,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
929
994
|
type: "step-suspended",
|
|
930
995
|
payload: {
|
|
931
996
|
id: step.id,
|
|
932
|
-
|
|
933
|
-
output: execResults.status === "success" ? execResults?.output : void 0
|
|
997
|
+
...execResults
|
|
934
998
|
}
|
|
935
999
|
});
|
|
936
1000
|
} else {
|
|
@@ -938,8 +1002,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
938
1002
|
type: "step-result",
|
|
939
1003
|
payload: {
|
|
940
1004
|
id: step.id,
|
|
941
|
-
|
|
942
|
-
output: execResults.status === "success" ? execResults?.output : void 0
|
|
1005
|
+
...execResults
|
|
943
1006
|
}
|
|
944
1007
|
});
|
|
945
1008
|
await emitter.emit("watch-v2", {
|
|
@@ -1000,6 +1063,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
1000
1063
|
resume,
|
|
1001
1064
|
executionContext,
|
|
1002
1065
|
emitter,
|
|
1066
|
+
abortController,
|
|
1003
1067
|
runtimeContext
|
|
1004
1068
|
}) {
|
|
1005
1069
|
let execResults;
|
|
@@ -1011,6 +1075,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
1011
1075
|
runId,
|
|
1012
1076
|
mastra: this.mastra,
|
|
1013
1077
|
runtimeContext,
|
|
1078
|
+
runCount: -1,
|
|
1014
1079
|
inputData: prevOutput,
|
|
1015
1080
|
getInitData: () => stepResults?.input,
|
|
1016
1081
|
getStepResult: (step) => {
|
|
@@ -1028,10 +1093,14 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
1028
1093
|
},
|
|
1029
1094
|
bail: () => {
|
|
1030
1095
|
},
|
|
1096
|
+
abort: () => {
|
|
1097
|
+
abortController.abort();
|
|
1098
|
+
},
|
|
1031
1099
|
[_constants.EMITTER_SYMBOL]: emitter,
|
|
1032
1100
|
engine: {
|
|
1033
1101
|
step: this.inngestStep
|
|
1034
|
-
}
|
|
1102
|
+
},
|
|
1103
|
+
abortSignal: abortController.signal
|
|
1035
1104
|
});
|
|
1036
1105
|
return result ? index : null;
|
|
1037
1106
|
} catch (e) {
|
|
@@ -1060,6 +1129,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
1060
1129
|
executionSpan: executionContext.executionSpan
|
|
1061
1130
|
},
|
|
1062
1131
|
emitter,
|
|
1132
|
+
abortController,
|
|
1063
1133
|
runtimeContext
|
|
1064
1134
|
})
|
|
1065
1135
|
)
|