@mastra/inngest 0.0.0-support-d1-client-20250701191943 → 0.0.0-tool-call-parts-20250630193309
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 +3 -8
- package/dist/_tsup-dts-rollup.d.cts +13 -9
- package/dist/_tsup-dts-rollup.d.ts +13 -9
- package/dist/index.cjs +15 -66
- package/dist/index.js +15 -66
- package/package.json +7 -7
- package/src/index.test.ts +0 -197
- package/src/index.ts +18 -70
package/CHANGELOG.md
CHANGED
|
@@ -1,26 +1,21 @@
|
|
|
1
1
|
# @mastra/inngest
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
3
|
+
## 0.0.0-tool-call-parts-20250630193309
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
- e423a31: Fix bug where nested workflows would cause Inngest duplicate key error
|
|
8
7
|
- 764f86a: Introduces the runCount property in the execution parameters for the steps execute function
|
|
9
8
|
- 1760a1c: Use workflow stream in playground instead of watch
|
|
10
|
-
- 038e5ae: Add cancel workflow run
|
|
11
9
|
- Updated dependencies [9dda1ac]
|
|
12
10
|
- Updated dependencies [7e801dd]
|
|
13
|
-
- Updated dependencies [a606c75]
|
|
14
11
|
- Updated dependencies [7aa70a4]
|
|
15
12
|
- Updated dependencies [764f86a]
|
|
16
13
|
- Updated dependencies [1760a1c]
|
|
17
|
-
- Updated dependencies [038e5ae]
|
|
18
14
|
- Updated dependencies [7dda16a]
|
|
19
|
-
- Updated dependencies [
|
|
15
|
+
- Updated dependencies [d80069a]
|
|
20
16
|
- Updated dependencies [57929df]
|
|
21
|
-
- Updated dependencies [b7852ed]
|
|
22
17
|
- Updated dependencies [6320a61]
|
|
23
|
-
- @mastra/core@0.0.0-
|
|
18
|
+
- @mastra/core@0.0.0-tool-call-parts-20250630193309
|
|
24
19
|
|
|
25
20
|
## 0.11.0
|
|
26
21
|
|
|
@@ -91,10 +91,9 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
91
91
|
delay?: number;
|
|
92
92
|
};
|
|
93
93
|
runtimeContext: RuntimeContext;
|
|
94
|
-
abortController: AbortController;
|
|
95
94
|
}): Promise<TOutput>;
|
|
96
95
|
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>;
|
|
97
|
-
superExecuteStep({ workflowId, runId, step, stepResults, executionContext, resume, prevOutput, emitter,
|
|
96
|
+
superExecuteStep({ workflowId, runId, step, stepResults, executionContext, resume, prevOutput, emitter, runtimeContext, }: {
|
|
98
97
|
workflowId: string;
|
|
99
98
|
runId: string;
|
|
100
99
|
step: Step<string, any, any>;
|
|
@@ -106,7 +105,6 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
106
105
|
};
|
|
107
106
|
prevOutput: any;
|
|
108
107
|
emitter: Emitter;
|
|
109
|
-
abortController: AbortController;
|
|
110
108
|
runtimeContext: RuntimeContext;
|
|
111
109
|
}): Promise<StepResult<any, any, any, any>>;
|
|
112
110
|
executeSleep({ id, duration }: {
|
|
@@ -117,10 +115,19 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
117
115
|
event: string;
|
|
118
116
|
timeout?: number;
|
|
119
117
|
}): Promise<any>;
|
|
120
|
-
executeStep({ step, stepResults, executionContext, resume, prevOutput, emitter,
|
|
118
|
+
executeStep({ step, stepResults, executionContext, resume, prevOutput, emitter, runtimeContext, }: {
|
|
121
119
|
step: Step<string, any, any>;
|
|
122
120
|
stepResults: Record<string, StepResult<any, any, any, any>>;
|
|
123
|
-
executionContext:
|
|
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
|
+
};
|
|
124
131
|
resume?: {
|
|
125
132
|
steps: string[];
|
|
126
133
|
resumePayload: any;
|
|
@@ -128,7 +135,6 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
128
135
|
};
|
|
129
136
|
prevOutput: any;
|
|
130
137
|
emitter: Emitter;
|
|
131
|
-
abortController: AbortController;
|
|
132
138
|
runtimeContext: RuntimeContext;
|
|
133
139
|
}): Promise<StepResult<any, any, any, any>>;
|
|
134
140
|
persistStepUpdate({ workflowId, runId, stepResults, executionContext, serializedStepGraph, workflowStatus, result, error, }: {
|
|
@@ -141,7 +147,7 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
141
147
|
result?: Record<string, any>;
|
|
142
148
|
error?: string | Error;
|
|
143
149
|
}): Promise<void>;
|
|
144
|
-
executeConditional({ workflowId, runId, entry, prevOutput, prevStep, stepResults, serializedStepGraph, resume, executionContext, emitter,
|
|
150
|
+
executeConditional({ workflowId, runId, entry, prevOutput, prevStep, stepResults, serializedStepGraph, resume, executionContext, emitter, runtimeContext, }: {
|
|
145
151
|
workflowId: string;
|
|
146
152
|
runId: string;
|
|
147
153
|
entry: {
|
|
@@ -161,7 +167,6 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
161
167
|
};
|
|
162
168
|
executionContext: ExecutionContext;
|
|
163
169
|
emitter: Emitter;
|
|
164
|
-
abortController: AbortController;
|
|
165
170
|
runtimeContext: RuntimeContext;
|
|
166
171
|
}): Promise<StepResult<any, any, any, any>>;
|
|
167
172
|
}
|
|
@@ -186,7 +191,6 @@ export declare class InngestRun<TEngineType = InngestEngineType, TSteps extends
|
|
|
186
191
|
getRuns(eventId: string): Promise<any>;
|
|
187
192
|
getRunOutput(eventId: string): Promise<any>;
|
|
188
193
|
sendEvent(event: string, data: any): Promise<void>;
|
|
189
|
-
cancel(): Promise<void>;
|
|
190
194
|
start({ inputData, }: {
|
|
191
195
|
inputData?: z.infer<TInput>;
|
|
192
196
|
runtimeContext?: RuntimeContext;
|
|
@@ -91,10 +91,9 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
91
91
|
delay?: number;
|
|
92
92
|
};
|
|
93
93
|
runtimeContext: RuntimeContext;
|
|
94
|
-
abortController: AbortController;
|
|
95
94
|
}): Promise<TOutput>;
|
|
96
95
|
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>;
|
|
97
|
-
superExecuteStep({ workflowId, runId, step, stepResults, executionContext, resume, prevOutput, emitter,
|
|
96
|
+
superExecuteStep({ workflowId, runId, step, stepResults, executionContext, resume, prevOutput, emitter, runtimeContext, }: {
|
|
98
97
|
workflowId: string;
|
|
99
98
|
runId: string;
|
|
100
99
|
step: Step<string, any, any>;
|
|
@@ -106,7 +105,6 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
106
105
|
};
|
|
107
106
|
prevOutput: any;
|
|
108
107
|
emitter: Emitter;
|
|
109
|
-
abortController: AbortController;
|
|
110
108
|
runtimeContext: RuntimeContext;
|
|
111
109
|
}): Promise<StepResult<any, any, any, any>>;
|
|
112
110
|
executeSleep({ id, duration }: {
|
|
@@ -117,10 +115,19 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
117
115
|
event: string;
|
|
118
116
|
timeout?: number;
|
|
119
117
|
}): Promise<any>;
|
|
120
|
-
executeStep({ step, stepResults, executionContext, resume, prevOutput, emitter,
|
|
118
|
+
executeStep({ step, stepResults, executionContext, resume, prevOutput, emitter, runtimeContext, }: {
|
|
121
119
|
step: Step<string, any, any>;
|
|
122
120
|
stepResults: Record<string, StepResult<any, any, any, any>>;
|
|
123
|
-
executionContext:
|
|
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
|
+
};
|
|
124
131
|
resume?: {
|
|
125
132
|
steps: string[];
|
|
126
133
|
resumePayload: any;
|
|
@@ -128,7 +135,6 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
128
135
|
};
|
|
129
136
|
prevOutput: any;
|
|
130
137
|
emitter: Emitter;
|
|
131
|
-
abortController: AbortController;
|
|
132
138
|
runtimeContext: RuntimeContext;
|
|
133
139
|
}): Promise<StepResult<any, any, any, any>>;
|
|
134
140
|
persistStepUpdate({ workflowId, runId, stepResults, executionContext, serializedStepGraph, workflowStatus, result, error, }: {
|
|
@@ -141,7 +147,7 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
141
147
|
result?: Record<string, any>;
|
|
142
148
|
error?: string | Error;
|
|
143
149
|
}): Promise<void>;
|
|
144
|
-
executeConditional({ workflowId, runId, entry, prevOutput, prevStep, stepResults, serializedStepGraph, resume, executionContext, emitter,
|
|
150
|
+
executeConditional({ workflowId, runId, entry, prevOutput, prevStep, stepResults, serializedStepGraph, resume, executionContext, emitter, runtimeContext, }: {
|
|
145
151
|
workflowId: string;
|
|
146
152
|
runId: string;
|
|
147
153
|
entry: {
|
|
@@ -161,7 +167,6 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
161
167
|
};
|
|
162
168
|
executionContext: ExecutionContext;
|
|
163
169
|
emitter: Emitter;
|
|
164
|
-
abortController: AbortController;
|
|
165
170
|
runtimeContext: RuntimeContext;
|
|
166
171
|
}): Promise<StepResult<any, any, any, any>>;
|
|
167
172
|
}
|
|
@@ -186,7 +191,6 @@ export declare class InngestRun<TEngineType = InngestEngineType, TSteps extends
|
|
|
186
191
|
getRuns(eventId: string): Promise<any>;
|
|
187
192
|
getRunOutput(eventId: string): Promise<any>;
|
|
188
193
|
sendEvent(event: string, data: any): Promise<void>;
|
|
189
|
-
cancel(): Promise<void>;
|
|
190
194
|
start({ inputData, }: {
|
|
191
195
|
inputData?: z.infer<TInput>;
|
|
192
196
|
runtimeContext?: RuntimeContext;
|
package/dist/index.cjs
CHANGED
|
@@ -12,17 +12,13 @@ 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
|
-
|
|
22
|
-
return [];
|
|
23
|
-
})
|
|
24
|
-
)
|
|
25
|
-
);
|
|
15
|
+
const functions = Object.values(wfs).flatMap((wf) => {
|
|
16
|
+
if (wf instanceof InngestWorkflow) {
|
|
17
|
+
wf.__registerMastra(mastra);
|
|
18
|
+
return wf.getFunctions();
|
|
19
|
+
}
|
|
20
|
+
return [];
|
|
21
|
+
});
|
|
26
22
|
return hono.serve({
|
|
27
23
|
client: inngest,
|
|
28
24
|
functions
|
|
@@ -52,14 +48,8 @@ var InngestRun = class extends workflows.Run {
|
|
|
52
48
|
while (runs?.[0]?.status !== "Completed" || runs?.[0]?.event_id !== eventId) {
|
|
53
49
|
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
54
50
|
runs = await this.getRuns(eventId);
|
|
55
|
-
if (runs?.[0]?.status === "Failed") {
|
|
51
|
+
if (runs?.[0]?.status === "Failed" || runs?.[0]?.status === "Cancelled") {
|
|
56
52
|
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" } } };
|
|
63
53
|
}
|
|
64
54
|
}
|
|
65
55
|
return runs?.[0];
|
|
@@ -70,28 +60,6 @@ var InngestRun = class extends workflows.Run {
|
|
|
70
60
|
data
|
|
71
61
|
});
|
|
72
62
|
}
|
|
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
|
-
}
|
|
95
63
|
async start({
|
|
96
64
|
inputData
|
|
97
65
|
}) {
|
|
@@ -356,12 +324,8 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
|
|
|
356
324
|
return this.function;
|
|
357
325
|
}
|
|
358
326
|
this.function = this.inngest.createFunction(
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
// @ts-ignore
|
|
362
|
-
retries: this.retryConfig?.attempts ?? 0,
|
|
363
|
-
cancelOn: [{ event: `cancel.workflow.${this.id}` }]
|
|
364
|
-
},
|
|
327
|
+
// @ts-ignore
|
|
328
|
+
{ id: `workflow.${this.id}`, retries: this.retryConfig?.attempts ?? 0 },
|
|
365
329
|
{ event: `workflow.${this.id}` },
|
|
366
330
|
async ({ event, step, attempt, publish }) => {
|
|
367
331
|
let { inputData, runId, resume } = event.data;
|
|
@@ -403,8 +367,7 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
|
|
|
403
367
|
retryConfig: this.retryConfig,
|
|
404
368
|
runtimeContext: new di.RuntimeContext(),
|
|
405
369
|
// TODO
|
|
406
|
-
resume
|
|
407
|
-
abortController: new AbortController()
|
|
370
|
+
resume
|
|
408
371
|
});
|
|
409
372
|
return { result, runId };
|
|
410
373
|
}
|
|
@@ -448,7 +411,7 @@ function createStep(params) {
|
|
|
448
411
|
outputSchema: zod.z.object({
|
|
449
412
|
text: zod.z.string()
|
|
450
413
|
}),
|
|
451
|
-
execute: async ({ inputData, [_constants.EMITTER_SYMBOL]: emitter, runtimeContext
|
|
414
|
+
execute: async ({ inputData, [_constants.EMITTER_SYMBOL]: emitter, runtimeContext }) => {
|
|
452
415
|
let streamPromise = {};
|
|
453
416
|
streamPromise.promise = new Promise((resolve, reject) => {
|
|
454
417
|
streamPromise.resolve = resolve;
|
|
@@ -468,12 +431,8 @@ function createStep(params) {
|
|
|
468
431
|
runtimeContext,
|
|
469
432
|
onFinish: (result) => {
|
|
470
433
|
streamPromise.resolve(result.text);
|
|
471
|
-
}
|
|
472
|
-
abortSignal
|
|
434
|
+
}
|
|
473
435
|
});
|
|
474
|
-
if (abortSignal.aborted) {
|
|
475
|
-
return abort();
|
|
476
|
-
}
|
|
477
436
|
for await (const chunk of fullStream) {
|
|
478
437
|
switch (chunk.type) {
|
|
479
438
|
case "text-delta":
|
|
@@ -648,7 +607,6 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
648
607
|
resume,
|
|
649
608
|
prevOutput,
|
|
650
609
|
emitter,
|
|
651
|
-
abortController,
|
|
652
610
|
runtimeContext
|
|
653
611
|
}) {
|
|
654
612
|
return super.executeStep({
|
|
@@ -660,7 +618,6 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
660
618
|
resume,
|
|
661
619
|
prevOutput,
|
|
662
620
|
emitter,
|
|
663
|
-
abortController,
|
|
664
621
|
runtimeContext
|
|
665
622
|
});
|
|
666
623
|
}
|
|
@@ -684,7 +641,6 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
684
641
|
resume,
|
|
685
642
|
prevOutput,
|
|
686
643
|
emitter,
|
|
687
|
-
abortController,
|
|
688
644
|
runtimeContext
|
|
689
645
|
}) {
|
|
690
646
|
const startedAt = await this.inngestStep.run(
|
|
@@ -928,8 +884,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
928
884
|
[_constants.EMITTER_SYMBOL]: emitter,
|
|
929
885
|
engine: {
|
|
930
886
|
step: this.inngestStep
|
|
931
|
-
}
|
|
932
|
-
abortSignal: abortController.signal
|
|
887
|
+
}
|
|
933
888
|
});
|
|
934
889
|
const endedAt = Date.now();
|
|
935
890
|
execResults = {
|
|
@@ -1060,7 +1015,6 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
1060
1015
|
resume,
|
|
1061
1016
|
executionContext,
|
|
1062
1017
|
emitter,
|
|
1063
|
-
abortController,
|
|
1064
1018
|
runtimeContext
|
|
1065
1019
|
}) {
|
|
1066
1020
|
let execResults;
|
|
@@ -1090,14 +1044,10 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
1090
1044
|
},
|
|
1091
1045
|
bail: () => {
|
|
1092
1046
|
},
|
|
1093
|
-
abort: () => {
|
|
1094
|
-
abortController.abort();
|
|
1095
|
-
},
|
|
1096
1047
|
[_constants.EMITTER_SYMBOL]: emitter,
|
|
1097
1048
|
engine: {
|
|
1098
1049
|
step: this.inngestStep
|
|
1099
|
-
}
|
|
1100
|
-
abortSignal: abortController.signal
|
|
1050
|
+
}
|
|
1101
1051
|
});
|
|
1102
1052
|
return result ? index : null;
|
|
1103
1053
|
} catch (e) {
|
|
@@ -1126,7 +1076,6 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
1126
1076
|
executionSpan: executionContext.executionSpan
|
|
1127
1077
|
},
|
|
1128
1078
|
emitter,
|
|
1129
|
-
abortController,
|
|
1130
1079
|
runtimeContext
|
|
1131
1080
|
})
|
|
1132
1081
|
)
|
package/dist/index.js
CHANGED
|
@@ -10,17 +10,13 @@ import { z } from 'zod';
|
|
|
10
10
|
// src/index.ts
|
|
11
11
|
function serve({ mastra, inngest }) {
|
|
12
12
|
const wfs = mastra.getWorkflows();
|
|
13
|
-
const functions =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return [];
|
|
21
|
-
})
|
|
22
|
-
)
|
|
23
|
-
);
|
|
13
|
+
const functions = Object.values(wfs).flatMap((wf) => {
|
|
14
|
+
if (wf instanceof InngestWorkflow) {
|
|
15
|
+
wf.__registerMastra(mastra);
|
|
16
|
+
return wf.getFunctions();
|
|
17
|
+
}
|
|
18
|
+
return [];
|
|
19
|
+
});
|
|
24
20
|
return serve$1({
|
|
25
21
|
client: inngest,
|
|
26
22
|
functions
|
|
@@ -50,14 +46,8 @@ var InngestRun = class extends Run {
|
|
|
50
46
|
while (runs?.[0]?.status !== "Completed" || runs?.[0]?.event_id !== eventId) {
|
|
51
47
|
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
52
48
|
runs = await this.getRuns(eventId);
|
|
53
|
-
if (runs?.[0]?.status === "Failed") {
|
|
49
|
+
if (runs?.[0]?.status === "Failed" || runs?.[0]?.status === "Cancelled") {
|
|
54
50
|
throw new Error(`Function run ${runs?.[0]?.status}`);
|
|
55
|
-
} else if (runs?.[0]?.status === "Cancelled") {
|
|
56
|
-
const snapshot = await this.#mastra?.storage?.loadWorkflowSnapshot({
|
|
57
|
-
workflowName: this.workflowId,
|
|
58
|
-
runId: this.runId
|
|
59
|
-
});
|
|
60
|
-
return { output: { result: { steps: snapshot?.context, status: "canceled" } } };
|
|
61
51
|
}
|
|
62
52
|
}
|
|
63
53
|
return runs?.[0];
|
|
@@ -68,28 +58,6 @@ var InngestRun = class extends Run {
|
|
|
68
58
|
data
|
|
69
59
|
});
|
|
70
60
|
}
|
|
71
|
-
async cancel() {
|
|
72
|
-
await this.inngest.send({
|
|
73
|
-
name: `cancel.workflow.${this.workflowId}`,
|
|
74
|
-
data: {
|
|
75
|
-
runId: this.runId
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
const snapshot = await this.#mastra?.storage?.loadWorkflowSnapshot({
|
|
79
|
-
workflowName: this.workflowId,
|
|
80
|
-
runId: this.runId
|
|
81
|
-
});
|
|
82
|
-
if (snapshot) {
|
|
83
|
-
await this.#mastra?.storage?.persistWorkflowSnapshot({
|
|
84
|
-
workflowName: this.workflowId,
|
|
85
|
-
runId: this.runId,
|
|
86
|
-
snapshot: {
|
|
87
|
-
...snapshot,
|
|
88
|
-
status: "canceled"
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
61
|
async start({
|
|
94
62
|
inputData
|
|
95
63
|
}) {
|
|
@@ -354,12 +322,8 @@ var InngestWorkflow = class _InngestWorkflow extends Workflow {
|
|
|
354
322
|
return this.function;
|
|
355
323
|
}
|
|
356
324
|
this.function = this.inngest.createFunction(
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
// @ts-ignore
|
|
360
|
-
retries: this.retryConfig?.attempts ?? 0,
|
|
361
|
-
cancelOn: [{ event: `cancel.workflow.${this.id}` }]
|
|
362
|
-
},
|
|
325
|
+
// @ts-ignore
|
|
326
|
+
{ id: `workflow.${this.id}`, retries: this.retryConfig?.attempts ?? 0 },
|
|
363
327
|
{ event: `workflow.${this.id}` },
|
|
364
328
|
async ({ event, step, attempt, publish }) => {
|
|
365
329
|
let { inputData, runId, resume } = event.data;
|
|
@@ -401,8 +365,7 @@ var InngestWorkflow = class _InngestWorkflow extends Workflow {
|
|
|
401
365
|
retryConfig: this.retryConfig,
|
|
402
366
|
runtimeContext: new RuntimeContext(),
|
|
403
367
|
// TODO
|
|
404
|
-
resume
|
|
405
|
-
abortController: new AbortController()
|
|
368
|
+
resume
|
|
406
369
|
});
|
|
407
370
|
return { result, runId };
|
|
408
371
|
}
|
|
@@ -446,7 +409,7 @@ function createStep(params) {
|
|
|
446
409
|
outputSchema: z.object({
|
|
447
410
|
text: z.string()
|
|
448
411
|
}),
|
|
449
|
-
execute: async ({ inputData, [EMITTER_SYMBOL]: emitter, runtimeContext
|
|
412
|
+
execute: async ({ inputData, [EMITTER_SYMBOL]: emitter, runtimeContext }) => {
|
|
450
413
|
let streamPromise = {};
|
|
451
414
|
streamPromise.promise = new Promise((resolve, reject) => {
|
|
452
415
|
streamPromise.resolve = resolve;
|
|
@@ -466,12 +429,8 @@ function createStep(params) {
|
|
|
466
429
|
runtimeContext,
|
|
467
430
|
onFinish: (result) => {
|
|
468
431
|
streamPromise.resolve(result.text);
|
|
469
|
-
}
|
|
470
|
-
abortSignal
|
|
432
|
+
}
|
|
471
433
|
});
|
|
472
|
-
if (abortSignal.aborted) {
|
|
473
|
-
return abort();
|
|
474
|
-
}
|
|
475
434
|
for await (const chunk of fullStream) {
|
|
476
435
|
switch (chunk.type) {
|
|
477
436
|
case "text-delta":
|
|
@@ -646,7 +605,6 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
|
|
|
646
605
|
resume,
|
|
647
606
|
prevOutput,
|
|
648
607
|
emitter,
|
|
649
|
-
abortController,
|
|
650
608
|
runtimeContext
|
|
651
609
|
}) {
|
|
652
610
|
return super.executeStep({
|
|
@@ -658,7 +616,6 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
|
|
|
658
616
|
resume,
|
|
659
617
|
prevOutput,
|
|
660
618
|
emitter,
|
|
661
|
-
abortController,
|
|
662
619
|
runtimeContext
|
|
663
620
|
});
|
|
664
621
|
}
|
|
@@ -682,7 +639,6 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
|
|
|
682
639
|
resume,
|
|
683
640
|
prevOutput,
|
|
684
641
|
emitter,
|
|
685
|
-
abortController,
|
|
686
642
|
runtimeContext
|
|
687
643
|
}) {
|
|
688
644
|
const startedAt = await this.inngestStep.run(
|
|
@@ -926,8 +882,7 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
|
|
|
926
882
|
[EMITTER_SYMBOL]: emitter,
|
|
927
883
|
engine: {
|
|
928
884
|
step: this.inngestStep
|
|
929
|
-
}
|
|
930
|
-
abortSignal: abortController.signal
|
|
885
|
+
}
|
|
931
886
|
});
|
|
932
887
|
const endedAt = Date.now();
|
|
933
888
|
execResults = {
|
|
@@ -1058,7 +1013,6 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
|
|
|
1058
1013
|
resume,
|
|
1059
1014
|
executionContext,
|
|
1060
1015
|
emitter,
|
|
1061
|
-
abortController,
|
|
1062
1016
|
runtimeContext
|
|
1063
1017
|
}) {
|
|
1064
1018
|
let execResults;
|
|
@@ -1088,14 +1042,10 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
|
|
|
1088
1042
|
},
|
|
1089
1043
|
bail: () => {
|
|
1090
1044
|
},
|
|
1091
|
-
abort: () => {
|
|
1092
|
-
abortController.abort();
|
|
1093
|
-
},
|
|
1094
1045
|
[EMITTER_SYMBOL]: emitter,
|
|
1095
1046
|
engine: {
|
|
1096
1047
|
step: this.inngestStep
|
|
1097
|
-
}
|
|
1098
|
-
abortSignal: abortController.signal
|
|
1048
|
+
}
|
|
1099
1049
|
});
|
|
1100
1050
|
return result ? index : null;
|
|
1101
1051
|
} catch (e) {
|
|
@@ -1124,7 +1074,6 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
|
|
|
1124
1074
|
executionSpan: executionContext.executionSpan
|
|
1125
1075
|
},
|
|
1126
1076
|
emitter,
|
|
1127
|
-
abortController,
|
|
1128
1077
|
runtimeContext
|
|
1129
1078
|
})
|
|
1130
1079
|
)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/inngest",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-tool-call-parts-20250630193309",
|
|
4
4
|
"description": "Mastra Inngest integration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -36,14 +36,14 @@
|
|
|
36
36
|
"hono": "^4.8.3",
|
|
37
37
|
"tsup": "^8.5.0",
|
|
38
38
|
"typescript": "^5.8.3",
|
|
39
|
-
"vitest": "^
|
|
40
|
-
"@
|
|
41
|
-
"@mastra/libsql": "0.0.0-
|
|
42
|
-
"@
|
|
43
|
-
"@mastra/
|
|
39
|
+
"vitest": "^2.1.9",
|
|
40
|
+
"@mastra/core": "0.0.0-tool-call-parts-20250630193309",
|
|
41
|
+
"@mastra/libsql": "0.0.0-tool-call-parts-20250630193309",
|
|
42
|
+
"@internal/lint": "0.0.0-tool-call-parts-20250630193309",
|
|
43
|
+
"@mastra/deployer": "0.0.0-tool-call-parts-20250630193309"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"@mastra/core": "0.0.0-
|
|
46
|
+
"@mastra/core": "0.0.0-tool-call-parts-20250630193309"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
49
|
"build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
|
package/src/index.test.ts
CHANGED
|
@@ -732,203 +732,6 @@ describe('MastraInngestWorkflow', () => {
|
|
|
732
732
|
});
|
|
733
733
|
});
|
|
734
734
|
|
|
735
|
-
describe('abort', () => {
|
|
736
|
-
it('should be able to abort workflow execution in between steps', async ctx => {
|
|
737
|
-
const inngest = new Inngest({
|
|
738
|
-
id: 'mastra',
|
|
739
|
-
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
740
|
-
middleware: [realtimeMiddleware()],
|
|
741
|
-
});
|
|
742
|
-
|
|
743
|
-
const { createWorkflow, createStep } = init(inngest);
|
|
744
|
-
|
|
745
|
-
const step1 = createStep({
|
|
746
|
-
id: 'step1',
|
|
747
|
-
execute: async ({ inputData }) => {
|
|
748
|
-
return { result: 'step1: ' + inputData.value };
|
|
749
|
-
},
|
|
750
|
-
inputSchema: z.object({ value: z.string() }),
|
|
751
|
-
outputSchema: z.object({ result: z.string() }),
|
|
752
|
-
});
|
|
753
|
-
const step2 = createStep({
|
|
754
|
-
id: 'step2',
|
|
755
|
-
execute: async ({ inputData }) => {
|
|
756
|
-
return { result: 'step2: ' + inputData.result };
|
|
757
|
-
},
|
|
758
|
-
inputSchema: z.object({ result: z.string() }),
|
|
759
|
-
outputSchema: z.object({ result: z.string() }),
|
|
760
|
-
});
|
|
761
|
-
|
|
762
|
-
const workflow = createWorkflow({
|
|
763
|
-
id: 'test-workflow',
|
|
764
|
-
inputSchema: z.object({}),
|
|
765
|
-
outputSchema: z.object({
|
|
766
|
-
result: z.string(),
|
|
767
|
-
}),
|
|
768
|
-
steps: [step1, step2],
|
|
769
|
-
});
|
|
770
|
-
|
|
771
|
-
workflow.then(step1).sleep(2000).then(step2).commit();
|
|
772
|
-
|
|
773
|
-
const mastra = new Mastra({
|
|
774
|
-
storage: new DefaultStorage({
|
|
775
|
-
url: ':memory:',
|
|
776
|
-
}),
|
|
777
|
-
workflows: {
|
|
778
|
-
'test-workflow': workflow,
|
|
779
|
-
},
|
|
780
|
-
server: {
|
|
781
|
-
apiRoutes: [
|
|
782
|
-
{
|
|
783
|
-
path: '/inngest/api',
|
|
784
|
-
method: 'ALL',
|
|
785
|
-
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
786
|
-
},
|
|
787
|
-
],
|
|
788
|
-
},
|
|
789
|
-
});
|
|
790
|
-
|
|
791
|
-
const app = await createHonoServer(mastra);
|
|
792
|
-
|
|
793
|
-
const srv = serve({
|
|
794
|
-
fetch: app.fetch,
|
|
795
|
-
port: (ctx as any).handlerPort,
|
|
796
|
-
});
|
|
797
|
-
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
798
|
-
|
|
799
|
-
const run = await workflow.createRunAsync();
|
|
800
|
-
const p = run.start({ inputData: { value: 'test' } });
|
|
801
|
-
|
|
802
|
-
setTimeout(() => {
|
|
803
|
-
run.cancel();
|
|
804
|
-
}, 1000);
|
|
805
|
-
|
|
806
|
-
const result = await p;
|
|
807
|
-
|
|
808
|
-
srv.close();
|
|
809
|
-
|
|
810
|
-
expect(result.status).toBe('canceled');
|
|
811
|
-
expect(result.steps['step1']).toEqual({
|
|
812
|
-
status: 'success',
|
|
813
|
-
output: { result: 'step1: test' },
|
|
814
|
-
payload: { value: 'test' },
|
|
815
|
-
startedAt: expect.any(Number),
|
|
816
|
-
endedAt: expect.any(Number),
|
|
817
|
-
});
|
|
818
|
-
|
|
819
|
-
expect(result.steps['step2']).toBeUndefined();
|
|
820
|
-
});
|
|
821
|
-
|
|
822
|
-
it('should be able to abort workflow execution during a step', async ctx => {
|
|
823
|
-
const inngest = new Inngest({
|
|
824
|
-
id: 'mastra',
|
|
825
|
-
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
826
|
-
middleware: [realtimeMiddleware()],
|
|
827
|
-
});
|
|
828
|
-
|
|
829
|
-
const { createWorkflow, createStep } = init(inngest);
|
|
830
|
-
|
|
831
|
-
const step1 = createStep({
|
|
832
|
-
id: 'step1',
|
|
833
|
-
execute: async ({ inputData }) => {
|
|
834
|
-
return { result: 'step1: ' + inputData.value };
|
|
835
|
-
},
|
|
836
|
-
inputSchema: z.object({ value: z.string() }),
|
|
837
|
-
outputSchema: z.object({ result: z.string() }),
|
|
838
|
-
});
|
|
839
|
-
const step2 = createStep({
|
|
840
|
-
id: 'step2',
|
|
841
|
-
execute: async ({ inputData, abortSignal, abort }) => {
|
|
842
|
-
console.log('abort signal', abortSignal);
|
|
843
|
-
const timeout: Promise<string> = new Promise((resolve, _reject) => {
|
|
844
|
-
const ref = setTimeout(() => {
|
|
845
|
-
resolve('step2: ' + inputData.result);
|
|
846
|
-
}, 5000);
|
|
847
|
-
|
|
848
|
-
abortSignal.addEventListener('abort', () => {
|
|
849
|
-
resolve('');
|
|
850
|
-
clearTimeout(ref);
|
|
851
|
-
});
|
|
852
|
-
});
|
|
853
|
-
|
|
854
|
-
const result = await timeout;
|
|
855
|
-
if (abortSignal.aborted) {
|
|
856
|
-
return abort();
|
|
857
|
-
}
|
|
858
|
-
return { result };
|
|
859
|
-
},
|
|
860
|
-
inputSchema: z.object({ result: z.string() }),
|
|
861
|
-
outputSchema: z.object({ result: z.string() }),
|
|
862
|
-
});
|
|
863
|
-
|
|
864
|
-
const workflow = createWorkflow({
|
|
865
|
-
id: 'test-workflow',
|
|
866
|
-
inputSchema: z.object({}),
|
|
867
|
-
outputSchema: z.object({
|
|
868
|
-
result: z.string(),
|
|
869
|
-
}),
|
|
870
|
-
steps: [step1, step2],
|
|
871
|
-
});
|
|
872
|
-
|
|
873
|
-
workflow.then(step1).then(step2).commit();
|
|
874
|
-
|
|
875
|
-
const mastra = new Mastra({
|
|
876
|
-
storage: new DefaultStorage({
|
|
877
|
-
url: ':memory:',
|
|
878
|
-
}),
|
|
879
|
-
workflows: {
|
|
880
|
-
'test-workflow': workflow,
|
|
881
|
-
},
|
|
882
|
-
server: {
|
|
883
|
-
apiRoutes: [
|
|
884
|
-
{
|
|
885
|
-
path: '/inngest/api',
|
|
886
|
-
method: 'ALL',
|
|
887
|
-
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
888
|
-
},
|
|
889
|
-
],
|
|
890
|
-
},
|
|
891
|
-
});
|
|
892
|
-
|
|
893
|
-
const app = await createHonoServer(mastra);
|
|
894
|
-
|
|
895
|
-
const srv = serve({
|
|
896
|
-
fetch: app.fetch,
|
|
897
|
-
port: (ctx as any).handlerPort,
|
|
898
|
-
});
|
|
899
|
-
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
900
|
-
|
|
901
|
-
const run = await workflow.createRunAsync();
|
|
902
|
-
const p = run.start({ inputData: { value: 'test' } });
|
|
903
|
-
|
|
904
|
-
setTimeout(() => {
|
|
905
|
-
run.cancel();
|
|
906
|
-
}, 1000);
|
|
907
|
-
|
|
908
|
-
const result = await p;
|
|
909
|
-
console.log('result', result);
|
|
910
|
-
|
|
911
|
-
srv.close();
|
|
912
|
-
|
|
913
|
-
expect(result.status).toBe('canceled');
|
|
914
|
-
expect(result.steps['step1']).toEqual({
|
|
915
|
-
status: 'success',
|
|
916
|
-
output: { result: 'step1: test' },
|
|
917
|
-
payload: { value: 'test' },
|
|
918
|
-
startedAt: expect.any(Number),
|
|
919
|
-
endedAt: expect.any(Number),
|
|
920
|
-
});
|
|
921
|
-
|
|
922
|
-
// expect(result.steps['step2']).toEqual({
|
|
923
|
-
// status: 'canceled',
|
|
924
|
-
// payload: { result: 'step1: test' },
|
|
925
|
-
// output: undefined,
|
|
926
|
-
// startedAt: expect.any(Number),
|
|
927
|
-
// endedAt: expect.any(Number),
|
|
928
|
-
// });
|
|
929
|
-
});
|
|
930
|
-
});
|
|
931
|
-
|
|
932
735
|
describe('Variable Resolution', () => {
|
|
933
736
|
it('should resolve trigger data', async ctx => {
|
|
934
737
|
const inngest = new Inngest({
|
package/src/index.ts
CHANGED
|
@@ -33,17 +33,13 @@ export type InngestEngineType = {
|
|
|
33
33
|
|
|
34
34
|
export function serve({ mastra, inngest }: { mastra: Mastra; inngest: Inngest }): ReturnType<typeof inngestServe> {
|
|
35
35
|
const wfs = mastra.getWorkflows();
|
|
36
|
-
const functions =
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return [];
|
|
44
|
-
}),
|
|
45
|
-
),
|
|
46
|
-
);
|
|
36
|
+
const functions = Object.values(wfs).flatMap(wf => {
|
|
37
|
+
if (wf instanceof InngestWorkflow) {
|
|
38
|
+
wf.__registerMastra(mastra);
|
|
39
|
+
return wf.getFunctions();
|
|
40
|
+
}
|
|
41
|
+
return [];
|
|
42
|
+
});
|
|
47
43
|
return inngestServe({
|
|
48
44
|
client: inngest,
|
|
49
45
|
functions,
|
|
@@ -98,14 +94,8 @@ export class InngestRun<
|
|
|
98
94
|
while (runs?.[0]?.status !== 'Completed' || runs?.[0]?.event_id !== eventId) {
|
|
99
95
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
100
96
|
runs = await this.getRuns(eventId);
|
|
101
|
-
if (runs?.[0]?.status === 'Failed') {
|
|
97
|
+
if (runs?.[0]?.status === 'Failed' || runs?.[0]?.status === 'Cancelled') {
|
|
102
98
|
throw new Error(`Function run ${runs?.[0]?.status}`);
|
|
103
|
-
} else if (runs?.[0]?.status === 'Cancelled') {
|
|
104
|
-
const snapshot = await this.#mastra?.storage?.loadWorkflowSnapshot({
|
|
105
|
-
workflowName: this.workflowId,
|
|
106
|
-
runId: this.runId,
|
|
107
|
-
});
|
|
108
|
-
return { output: { result: { steps: snapshot?.context, status: 'canceled' } } };
|
|
109
99
|
}
|
|
110
100
|
}
|
|
111
101
|
return runs?.[0];
|
|
@@ -118,30 +108,6 @@ export class InngestRun<
|
|
|
118
108
|
});
|
|
119
109
|
}
|
|
120
110
|
|
|
121
|
-
async cancel() {
|
|
122
|
-
await this.inngest.send({
|
|
123
|
-
name: `cancel.workflow.${this.workflowId}`,
|
|
124
|
-
data: {
|
|
125
|
-
runId: this.runId,
|
|
126
|
-
},
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
const snapshot = await this.#mastra?.storage?.loadWorkflowSnapshot({
|
|
130
|
-
workflowName: this.workflowId,
|
|
131
|
-
runId: this.runId,
|
|
132
|
-
});
|
|
133
|
-
if (snapshot) {
|
|
134
|
-
await this.#mastra?.storage?.persistWorkflowSnapshot({
|
|
135
|
-
workflowName: this.workflowId,
|
|
136
|
-
runId: this.runId,
|
|
137
|
-
snapshot: {
|
|
138
|
-
...snapshot,
|
|
139
|
-
status: 'canceled' as any,
|
|
140
|
-
},
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
111
|
async start({
|
|
146
112
|
inputData,
|
|
147
113
|
}: {
|
|
@@ -498,12 +464,8 @@ export class InngestWorkflow<
|
|
|
498
464
|
return this.function;
|
|
499
465
|
}
|
|
500
466
|
this.function = this.inngest.createFunction(
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
// @ts-ignore
|
|
504
|
-
retries: this.retryConfig?.attempts ?? 0,
|
|
505
|
-
cancelOn: [{ event: `cancel.workflow.${this.id}` }],
|
|
506
|
-
},
|
|
467
|
+
// @ts-ignore
|
|
468
|
+
{ id: `workflow.${this.id}`, retries: this.retryConfig?.attempts ?? 0 },
|
|
507
469
|
{ event: `workflow.${this.id}` },
|
|
508
470
|
async ({ event, step, attempt, publish }) => {
|
|
509
471
|
let { inputData, runId, resume } = event.data;
|
|
@@ -552,7 +514,6 @@ export class InngestWorkflow<
|
|
|
552
514
|
retryConfig: this.retryConfig,
|
|
553
515
|
runtimeContext: new RuntimeContext(), // TODO
|
|
554
516
|
resume,
|
|
555
|
-
abortController: new AbortController(),
|
|
556
517
|
});
|
|
557
518
|
|
|
558
519
|
return { result, runId };
|
|
@@ -675,7 +636,7 @@ export function createStep<
|
|
|
675
636
|
outputSchema: z.object({
|
|
676
637
|
text: z.string(),
|
|
677
638
|
}),
|
|
678
|
-
execute: async ({ inputData, [EMITTER_SYMBOL]: emitter, runtimeContext
|
|
639
|
+
execute: async ({ inputData, [EMITTER_SYMBOL]: emitter, runtimeContext }) => {
|
|
679
640
|
let streamPromise = {} as {
|
|
680
641
|
promise: Promise<string>;
|
|
681
642
|
resolve: (value: string) => void;
|
|
@@ -701,13 +662,8 @@ export function createStep<
|
|
|
701
662
|
onFinish: result => {
|
|
702
663
|
streamPromise.resolve(result.text);
|
|
703
664
|
},
|
|
704
|
-
abortSignal,
|
|
705
665
|
});
|
|
706
666
|
|
|
707
|
-
if (abortSignal.aborted) {
|
|
708
|
-
return abort();
|
|
709
|
-
}
|
|
710
|
-
|
|
711
667
|
for await (const chunk of fullStream) {
|
|
712
668
|
switch (chunk.type) {
|
|
713
669
|
case 'text-delta':
|
|
@@ -865,7 +821,6 @@ export class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
865
821
|
delay?: number;
|
|
866
822
|
};
|
|
867
823
|
runtimeContext: RuntimeContext;
|
|
868
|
-
abortController: AbortController;
|
|
869
824
|
}): Promise<TOutput> {
|
|
870
825
|
await params.emitter.emit('watch-v2', {
|
|
871
826
|
type: 'start',
|
|
@@ -965,7 +920,6 @@ export class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
965
920
|
resume,
|
|
966
921
|
prevOutput,
|
|
967
922
|
emitter,
|
|
968
|
-
abortController,
|
|
969
923
|
runtimeContext,
|
|
970
924
|
}: {
|
|
971
925
|
workflowId: string;
|
|
@@ -979,7 +933,6 @@ export class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
979
933
|
};
|
|
980
934
|
prevOutput: any;
|
|
981
935
|
emitter: Emitter;
|
|
982
|
-
abortController: AbortController;
|
|
983
936
|
runtimeContext: RuntimeContext;
|
|
984
937
|
}): Promise<StepResult<any, any, any, any>> {
|
|
985
938
|
return super.executeStep({
|
|
@@ -991,7 +944,6 @@ export class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
991
944
|
resume,
|
|
992
945
|
prevOutput,
|
|
993
946
|
emitter,
|
|
994
|
-
abortController,
|
|
995
947
|
runtimeContext,
|
|
996
948
|
});
|
|
997
949
|
}
|
|
@@ -1020,12 +972,17 @@ export class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
1020
972
|
resume,
|
|
1021
973
|
prevOutput,
|
|
1022
974
|
emitter,
|
|
1023
|
-
abortController,
|
|
1024
975
|
runtimeContext,
|
|
1025
976
|
}: {
|
|
1026
977
|
step: Step<string, any, any>;
|
|
1027
978
|
stepResults: Record<string, StepResult<any, any, any, any>>;
|
|
1028
|
-
executionContext:
|
|
979
|
+
executionContext: {
|
|
980
|
+
workflowId: string;
|
|
981
|
+
runId: string;
|
|
982
|
+
executionPath: number[];
|
|
983
|
+
suspendedPaths: Record<string, number[]>;
|
|
984
|
+
retryConfig: { attempts: number; delay: number };
|
|
985
|
+
};
|
|
1029
986
|
resume?: {
|
|
1030
987
|
steps: string[];
|
|
1031
988
|
resumePayload: any;
|
|
@@ -1033,7 +990,6 @@ export class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
1033
990
|
};
|
|
1034
991
|
prevOutput: any;
|
|
1035
992
|
emitter: Emitter;
|
|
1036
|
-
abortController: AbortController;
|
|
1037
993
|
runtimeContext: RuntimeContext;
|
|
1038
994
|
}): Promise<StepResult<any, any, any, any>> {
|
|
1039
995
|
const startedAt = await this.inngestStep.run(
|
|
@@ -1304,7 +1260,6 @@ export class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
1304
1260
|
engine: {
|
|
1305
1261
|
step: this.inngestStep,
|
|
1306
1262
|
},
|
|
1307
|
-
abortSignal: abortController.signal,
|
|
1308
1263
|
});
|
|
1309
1264
|
const endedAt = Date.now();
|
|
1310
1265
|
|
|
@@ -1458,7 +1413,6 @@ export class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
1458
1413
|
resume,
|
|
1459
1414
|
executionContext,
|
|
1460
1415
|
emitter,
|
|
1461
|
-
abortController,
|
|
1462
1416
|
runtimeContext,
|
|
1463
1417
|
}: {
|
|
1464
1418
|
workflowId: string;
|
|
@@ -1480,7 +1434,6 @@ export class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
1480
1434
|
};
|
|
1481
1435
|
executionContext: ExecutionContext;
|
|
1482
1436
|
emitter: Emitter;
|
|
1483
|
-
abortController: AbortController;
|
|
1484
1437
|
runtimeContext: RuntimeContext;
|
|
1485
1438
|
}): Promise<StepResult<any, any, any, any>> {
|
|
1486
1439
|
let execResults: any;
|
|
@@ -1512,14 +1465,10 @@ export class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
1512
1465
|
// TODO: this function shouldn't have suspend probably?
|
|
1513
1466
|
suspend: async (_suspendPayload: any) => {},
|
|
1514
1467
|
bail: () => {},
|
|
1515
|
-
abort: () => {
|
|
1516
|
-
abortController.abort();
|
|
1517
|
-
},
|
|
1518
1468
|
[EMITTER_SYMBOL]: emitter,
|
|
1519
1469
|
engine: {
|
|
1520
1470
|
step: this.inngestStep,
|
|
1521
1471
|
},
|
|
1522
|
-
abortSignal: abortController.signal,
|
|
1523
1472
|
});
|
|
1524
1473
|
return result ? index : null;
|
|
1525
1474
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -1551,7 +1500,6 @@ export class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
1551
1500
|
executionSpan: executionContext.executionSpan,
|
|
1552
1501
|
},
|
|
1553
1502
|
emitter,
|
|
1554
|
-
abortController,
|
|
1555
1503
|
runtimeContext,
|
|
1556
1504
|
}),
|
|
1557
1505
|
),
|