@mastra/inngest 0.11.0 → 0.11.1
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/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +52 -0
- package/dist/_tsup-dts-rollup.d.cts +9 -13
- package/dist/_tsup-dts-rollup.d.ts +9 -13
- package/dist/index.cjs +106 -39
- package/dist/index.js +106 -39
- package/package.json +7 -7
- package/src/index.test.ts +257 -52
- package/src/index.ts +109 -39
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/inngest@0.11.
|
|
2
|
+
> @mastra/inngest@0.11.1-alpha.0 build /home/runner/work/mastra/mastra/workflows/inngest
|
|
3
3
|
> tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
6
6
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
7
|
[34mCLI[39m tsup v8.5.0
|
|
8
8
|
[34mTSC[39m Build start
|
|
9
|
-
[32mTSC[39m ⚡️ Build success in
|
|
9
|
+
[32mTSC[39m ⚡️ Build success in 11632ms
|
|
10
10
|
[34mDTS[39m Build start
|
|
11
11
|
[34mCLI[39m Target: es2022
|
|
12
12
|
Analysis will use the bundled TypeScript version 5.8.3
|
|
13
13
|
[36mWriting package typings: /home/runner/work/mastra/mastra/workflows/inngest/dist/_tsup-dts-rollup.d.ts[39m
|
|
14
14
|
Analysis will use the bundled TypeScript version 5.8.3
|
|
15
15
|
[36mWriting package typings: /home/runner/work/mastra/mastra/workflows/inngest/dist/_tsup-dts-rollup.d.cts[39m
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 6309ms
|
|
17
17
|
[34mCLI[39m Cleaning output folder
|
|
18
18
|
[34mESM[39m Build start
|
|
19
19
|
[34mCJS[39m Build start
|
|
20
|
-
[
|
|
21
|
-
[
|
|
22
|
-
[
|
|
23
|
-
[
|
|
20
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m34.53 KB[39m
|
|
21
|
+
[32mCJS[39m ⚡️ Build success in 341ms
|
|
22
|
+
[32mESM[39m [1mdist/index.js [22m[32m34.32 KB[39m
|
|
23
|
+
[32mESM[39m ⚡️ Build success in 341ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,57 @@
|
|
|
1
1
|
# @mastra/inngest
|
|
2
2
|
|
|
3
|
+
## 0.11.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e423a31: Fix bug where nested workflows would cause Inngest duplicate key error
|
|
8
|
+
- 764f86a: Introduces the runCount property in the execution parameters for the steps execute function
|
|
9
|
+
- 1760a1c: Use workflow stream in playground instead of watch
|
|
10
|
+
- 038e5ae: Add cancel workflow run
|
|
11
|
+
- 81a1b3b: Update peerdeps
|
|
12
|
+
- Updated dependencies [9dda1ac]
|
|
13
|
+
- Updated dependencies [c984582]
|
|
14
|
+
- Updated dependencies [7e801dd]
|
|
15
|
+
- Updated dependencies [a606c75]
|
|
16
|
+
- Updated dependencies [7aa70a4]
|
|
17
|
+
- Updated dependencies [764f86a]
|
|
18
|
+
- Updated dependencies [1760a1c]
|
|
19
|
+
- Updated dependencies [038e5ae]
|
|
20
|
+
- Updated dependencies [7dda16a]
|
|
21
|
+
- Updated dependencies [5ebfcdd]
|
|
22
|
+
- Updated dependencies [b2d0c91]
|
|
23
|
+
- Updated dependencies [4e809ad]
|
|
24
|
+
- Updated dependencies [57929df]
|
|
25
|
+
- Updated dependencies [b7852ed]
|
|
26
|
+
- Updated dependencies [6320a61]
|
|
27
|
+
- @mastra/core@0.10.9
|
|
28
|
+
|
|
29
|
+
## 0.11.1-alpha.0
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- e423a31: Fix bug where nested workflows would cause Inngest duplicate key error
|
|
34
|
+
- 764f86a: Introduces the runCount property in the execution parameters for the steps execute function
|
|
35
|
+
- 1760a1c: Use workflow stream in playground instead of watch
|
|
36
|
+
- 038e5ae: Add cancel workflow run
|
|
37
|
+
- 81a1b3b: Update peerdeps
|
|
38
|
+
- Updated dependencies [9dda1ac]
|
|
39
|
+
- Updated dependencies [c984582]
|
|
40
|
+
- Updated dependencies [7e801dd]
|
|
41
|
+
- Updated dependencies [a606c75]
|
|
42
|
+
- Updated dependencies [7aa70a4]
|
|
43
|
+
- Updated dependencies [764f86a]
|
|
44
|
+
- Updated dependencies [1760a1c]
|
|
45
|
+
- Updated dependencies [038e5ae]
|
|
46
|
+
- Updated dependencies [7dda16a]
|
|
47
|
+
- Updated dependencies [5ebfcdd]
|
|
48
|
+
- Updated dependencies [b2d0c91]
|
|
49
|
+
- Updated dependencies [4e809ad]
|
|
50
|
+
- Updated dependencies [57929df]
|
|
51
|
+
- Updated dependencies [b7852ed]
|
|
52
|
+
- Updated dependencies [6320a61]
|
|
53
|
+
- @mastra/core@0.10.9-alpha.0
|
|
54
|
+
|
|
3
55
|
## 0.11.0
|
|
4
56
|
|
|
5
57
|
### Minor Changes
|
|
@@ -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,14 @@ 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") {
|
|
52
56
|
throw new Error(`Function run ${runs?.[0]?.status}`);
|
|
57
|
+
} else if (runs?.[0]?.status === "Cancelled") {
|
|
58
|
+
const snapshot = await this.#mastra?.storage?.loadWorkflowSnapshot({
|
|
59
|
+
workflowName: this.workflowId,
|
|
60
|
+
runId: this.runId
|
|
61
|
+
});
|
|
62
|
+
return { output: { result: { steps: snapshot?.context, status: "canceled" } } };
|
|
53
63
|
}
|
|
54
64
|
}
|
|
55
65
|
return runs?.[0];
|
|
@@ -60,6 +70,28 @@ var InngestRun = class extends workflows.Run {
|
|
|
60
70
|
data
|
|
61
71
|
});
|
|
62
72
|
}
|
|
73
|
+
async cancel() {
|
|
74
|
+
await this.inngest.send({
|
|
75
|
+
name: `cancel.workflow.${this.workflowId}`,
|
|
76
|
+
data: {
|
|
77
|
+
runId: this.runId
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
const snapshot = await this.#mastra?.storage?.loadWorkflowSnapshot({
|
|
81
|
+
workflowName: this.workflowId,
|
|
82
|
+
runId: this.runId
|
|
83
|
+
});
|
|
84
|
+
if (snapshot) {
|
|
85
|
+
await this.#mastra?.storage?.persistWorkflowSnapshot({
|
|
86
|
+
workflowName: this.workflowId,
|
|
87
|
+
runId: this.runId,
|
|
88
|
+
snapshot: {
|
|
89
|
+
...snapshot,
|
|
90
|
+
status: "canceled"
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
63
95
|
async start({
|
|
64
96
|
inputData
|
|
65
97
|
}) {
|
|
@@ -93,7 +125,9 @@ var InngestRun = class extends workflows.Run {
|
|
|
93
125
|
if (result.status === "failed") {
|
|
94
126
|
result.error = new Error(result.error);
|
|
95
127
|
}
|
|
96
|
-
|
|
128
|
+
if (result.status !== "suspended") {
|
|
129
|
+
this.cleanup?.();
|
|
130
|
+
}
|
|
97
131
|
return result;
|
|
98
132
|
}
|
|
99
133
|
async resume(params) {
|
|
@@ -295,23 +329,26 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
|
|
|
295
329
|
this.inngest
|
|
296
330
|
);
|
|
297
331
|
this.runs.set(runIdToUse, run);
|
|
298
|
-
await this.
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
332
|
+
const workflowSnapshotInStorage = await this.getWorkflowRunExecutionResult(runIdToUse);
|
|
333
|
+
if (!workflowSnapshotInStorage) {
|
|
334
|
+
await this.mastra?.getStorage()?.persistWorkflowSnapshot({
|
|
335
|
+
workflowName: this.id,
|
|
302
336
|
runId: runIdToUse,
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
337
|
+
snapshot: {
|
|
338
|
+
runId: runIdToUse,
|
|
339
|
+
status: "pending",
|
|
340
|
+
value: {},
|
|
341
|
+
context: {},
|
|
342
|
+
activePaths: [],
|
|
343
|
+
serializedStepGraph: this.serializedStepGraph,
|
|
344
|
+
suspendedPaths: {},
|
|
345
|
+
result: void 0,
|
|
346
|
+
error: void 0,
|
|
347
|
+
// @ts-ignore
|
|
348
|
+
timestamp: Date.now()
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
}
|
|
315
352
|
return run;
|
|
316
353
|
}
|
|
317
354
|
getFunction() {
|
|
@@ -319,8 +356,12 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
|
|
|
319
356
|
return this.function;
|
|
320
357
|
}
|
|
321
358
|
this.function = this.inngest.createFunction(
|
|
322
|
-
|
|
323
|
-
|
|
359
|
+
{
|
|
360
|
+
id: `workflow.${this.id}`,
|
|
361
|
+
// @ts-ignore
|
|
362
|
+
retries: this.retryConfig?.attempts ?? 0,
|
|
363
|
+
cancelOn: [{ event: `cancel.workflow.${this.id}` }]
|
|
364
|
+
},
|
|
324
365
|
{ event: `workflow.${this.id}` },
|
|
325
366
|
async ({ event, step, attempt, publish }) => {
|
|
326
367
|
let { inputData, runId, resume } = event.data;
|
|
@@ -362,7 +403,8 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
|
|
|
362
403
|
retryConfig: this.retryConfig,
|
|
363
404
|
runtimeContext: new di.RuntimeContext(),
|
|
364
405
|
// TODO
|
|
365
|
-
resume
|
|
406
|
+
resume,
|
|
407
|
+
abortController: new AbortController()
|
|
366
408
|
});
|
|
367
409
|
return { result, runId };
|
|
368
410
|
}
|
|
@@ -406,7 +448,7 @@ function createStep(params) {
|
|
|
406
448
|
outputSchema: zod.z.object({
|
|
407
449
|
text: zod.z.string()
|
|
408
450
|
}),
|
|
409
|
-
execute: async ({ inputData, [_constants.EMITTER_SYMBOL]: emitter, runtimeContext }) => {
|
|
451
|
+
execute: async ({ inputData, [_constants.EMITTER_SYMBOL]: emitter, runtimeContext, abortSignal, abort }) => {
|
|
410
452
|
let streamPromise = {};
|
|
411
453
|
streamPromise.promise = new Promise((resolve, reject) => {
|
|
412
454
|
streamPromise.resolve = resolve;
|
|
@@ -426,8 +468,12 @@ function createStep(params) {
|
|
|
426
468
|
runtimeContext,
|
|
427
469
|
onFinish: (result) => {
|
|
428
470
|
streamPromise.resolve(result.text);
|
|
429
|
-
}
|
|
471
|
+
},
|
|
472
|
+
abortSignal
|
|
430
473
|
});
|
|
474
|
+
if (abortSignal.aborted) {
|
|
475
|
+
return abort();
|
|
476
|
+
}
|
|
431
477
|
for await (const chunk of fullStream) {
|
|
432
478
|
switch (chunk.type) {
|
|
433
479
|
case "text-delta":
|
|
@@ -602,6 +648,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
602
648
|
resume,
|
|
603
649
|
prevOutput,
|
|
604
650
|
emitter,
|
|
651
|
+
abortController,
|
|
605
652
|
runtimeContext
|
|
606
653
|
}) {
|
|
607
654
|
return super.executeStep({
|
|
@@ -613,6 +660,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
613
660
|
resume,
|
|
614
661
|
prevOutput,
|
|
615
662
|
emitter,
|
|
663
|
+
abortController,
|
|
616
664
|
runtimeContext
|
|
617
665
|
});
|
|
618
666
|
}
|
|
@@ -636,6 +684,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
636
684
|
resume,
|
|
637
685
|
prevOutput,
|
|
638
686
|
emitter,
|
|
687
|
+
abortController,
|
|
639
688
|
runtimeContext
|
|
640
689
|
}) {
|
|
641
690
|
const startedAt = await this.inngestStep.run(
|
|
@@ -666,7 +715,8 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
666
715
|
await emitter.emit("watch-v2", {
|
|
667
716
|
type: "step-start",
|
|
668
717
|
payload: {
|
|
669
|
-
id: step.id
|
|
718
|
+
id: step.id,
|
|
719
|
+
status: "running"
|
|
670
720
|
}
|
|
671
721
|
});
|
|
672
722
|
return startedAt2;
|
|
@@ -734,7 +784,9 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
734
784
|
type: "step-result",
|
|
735
785
|
payload: {
|
|
736
786
|
id: step.id,
|
|
737
|
-
status: "failed"
|
|
787
|
+
status: "failed",
|
|
788
|
+
error: result?.error,
|
|
789
|
+
payload: prevOutput
|
|
738
790
|
}
|
|
739
791
|
});
|
|
740
792
|
return { executionContext, result: { status: "failed", error: result?.error } };
|
|
@@ -766,7 +818,8 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
766
818
|
await emitter.emit("watch-v2", {
|
|
767
819
|
type: "step-suspended",
|
|
768
820
|
payload: {
|
|
769
|
-
id: step.id
|
|
821
|
+
id: step.id,
|
|
822
|
+
status: "suspended"
|
|
770
823
|
}
|
|
771
824
|
});
|
|
772
825
|
return {
|
|
@@ -819,6 +872,14 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
819
872
|
},
|
|
820
873
|
eventTimestamp: Date.now()
|
|
821
874
|
});
|
|
875
|
+
await emitter.emit("watch-v2", {
|
|
876
|
+
type: "step-result",
|
|
877
|
+
payload: {
|
|
878
|
+
id: step.id,
|
|
879
|
+
status: "success",
|
|
880
|
+
output: result?.result
|
|
881
|
+
}
|
|
882
|
+
});
|
|
822
883
|
await emitter.emit("watch-v2", {
|
|
823
884
|
type: "step-finish",
|
|
824
885
|
payload: {
|
|
@@ -867,7 +928,8 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
867
928
|
[_constants.EMITTER_SYMBOL]: emitter,
|
|
868
929
|
engine: {
|
|
869
930
|
step: this.inngestStep
|
|
870
|
-
}
|
|
931
|
+
},
|
|
932
|
+
abortSignal: abortController.signal
|
|
871
933
|
});
|
|
872
934
|
const endedAt = Date.now();
|
|
873
935
|
execResults = {
|
|
@@ -929,8 +991,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
929
991
|
type: "step-suspended",
|
|
930
992
|
payload: {
|
|
931
993
|
id: step.id,
|
|
932
|
-
|
|
933
|
-
output: execResults.status === "success" ? execResults?.output : void 0
|
|
994
|
+
...execResults
|
|
934
995
|
}
|
|
935
996
|
});
|
|
936
997
|
} else {
|
|
@@ -938,8 +999,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
938
999
|
type: "step-result",
|
|
939
1000
|
payload: {
|
|
940
1001
|
id: step.id,
|
|
941
|
-
|
|
942
|
-
output: execResults.status === "success" ? execResults?.output : void 0
|
|
1002
|
+
...execResults
|
|
943
1003
|
}
|
|
944
1004
|
});
|
|
945
1005
|
await emitter.emit("watch-v2", {
|
|
@@ -1000,6 +1060,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
1000
1060
|
resume,
|
|
1001
1061
|
executionContext,
|
|
1002
1062
|
emitter,
|
|
1063
|
+
abortController,
|
|
1003
1064
|
runtimeContext
|
|
1004
1065
|
}) {
|
|
1005
1066
|
let execResults;
|
|
@@ -1011,6 +1072,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
1011
1072
|
runId,
|
|
1012
1073
|
mastra: this.mastra,
|
|
1013
1074
|
runtimeContext,
|
|
1075
|
+
runCount: -1,
|
|
1014
1076
|
inputData: prevOutput,
|
|
1015
1077
|
getInitData: () => stepResults?.input,
|
|
1016
1078
|
getStepResult: (step) => {
|
|
@@ -1028,10 +1090,14 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
1028
1090
|
},
|
|
1029
1091
|
bail: () => {
|
|
1030
1092
|
},
|
|
1093
|
+
abort: () => {
|
|
1094
|
+
abortController.abort();
|
|
1095
|
+
},
|
|
1031
1096
|
[_constants.EMITTER_SYMBOL]: emitter,
|
|
1032
1097
|
engine: {
|
|
1033
1098
|
step: this.inngestStep
|
|
1034
|
-
}
|
|
1099
|
+
},
|
|
1100
|
+
abortSignal: abortController.signal
|
|
1035
1101
|
});
|
|
1036
1102
|
return result ? index : null;
|
|
1037
1103
|
} catch (e) {
|
|
@@ -1060,6 +1126,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
1060
1126
|
executionSpan: executionContext.executionSpan
|
|
1061
1127
|
},
|
|
1062
1128
|
emitter,
|
|
1129
|
+
abortController,
|
|
1063
1130
|
runtimeContext
|
|
1064
1131
|
})
|
|
1065
1132
|
)
|