@mastra/inngest 0.11.4 → 0.11.5
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 +6 -6
- package/CHANGELOG.md +53 -0
- package/dist/_tsup-dts-rollup.d.cts +11 -5
- package/dist/_tsup-dts-rollup.d.ts +11 -5
- package/dist/index.cjs +51 -10
- package/dist/index.js +52 -11
- package/package.json +5 -5
- package/src/index.test.ts +118 -0
- package/src/index.ts +48 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/inngest@0.11.
|
|
2
|
+
> @mastra/inngest@0.11.5-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 8285ms
|
|
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 6185ms
|
|
17
17
|
[34mCLI[39m Cleaning output folder
|
|
18
18
|
[34mESM[39m Build start
|
|
19
19
|
[34mCJS[39m Build start
|
|
20
|
-
[
|
|
20
|
+
[32mESM[39m [1mdist/index.js [22m[32m38.07 KB[39m
|
|
21
|
+
[32mESM[39m ⚡️ Build success in 363ms
|
|
22
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m38.32 KB[39m
|
|
21
23
|
[32mCJS[39m ⚡️ Build success in 364ms
|
|
22
|
-
[32mESM[39m [1mdist/index.js [22m[32m37.03 KB[39m
|
|
23
|
-
[32mESM[39m ⚡️ Build success in 364ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,58 @@
|
|
|
1
1
|
# @mastra/inngest
|
|
2
2
|
|
|
3
|
+
## 0.11.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- a723d69: Pass workflowId through
|
|
8
|
+
- Updated dependencies [f248d53]
|
|
9
|
+
- Updated dependencies [2affc57]
|
|
10
|
+
- Updated dependencies [66e13e3]
|
|
11
|
+
- Updated dependencies [edd9482]
|
|
12
|
+
- Updated dependencies [18344d7]
|
|
13
|
+
- Updated dependencies [9d372c2]
|
|
14
|
+
- Updated dependencies [40c2525]
|
|
15
|
+
- Updated dependencies [e473f27]
|
|
16
|
+
- Updated dependencies [032cb66]
|
|
17
|
+
- Updated dependencies [703ac71]
|
|
18
|
+
- Updated dependencies [a723d69]
|
|
19
|
+
- Updated dependencies [7827943]
|
|
20
|
+
- Updated dependencies [5889a31]
|
|
21
|
+
- Updated dependencies [bf1e7e7]
|
|
22
|
+
- Updated dependencies [65e3395]
|
|
23
|
+
- Updated dependencies [4933192]
|
|
24
|
+
- Updated dependencies [d1c77a4]
|
|
25
|
+
- Updated dependencies [bea9dd1]
|
|
26
|
+
- Updated dependencies [dcd4802]
|
|
27
|
+
- Updated dependencies [cbddd18]
|
|
28
|
+
- Updated dependencies [7ba91fa]
|
|
29
|
+
- @mastra/core@0.11.0
|
|
30
|
+
|
|
31
|
+
## 0.11.5-alpha.0
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- a723d69: Pass workflowId through
|
|
36
|
+
- Updated dependencies [f248d53]
|
|
37
|
+
- Updated dependencies [2affc57]
|
|
38
|
+
- Updated dependencies [66e13e3]
|
|
39
|
+
- Updated dependencies [edd9482]
|
|
40
|
+
- Updated dependencies [18344d7]
|
|
41
|
+
- Updated dependencies [9d372c2]
|
|
42
|
+
- Updated dependencies [40c2525]
|
|
43
|
+
- Updated dependencies [e473f27]
|
|
44
|
+
- Updated dependencies [032cb66]
|
|
45
|
+
- Updated dependencies [703ac71]
|
|
46
|
+
- Updated dependencies [a723d69]
|
|
47
|
+
- Updated dependencies [5889a31]
|
|
48
|
+
- Updated dependencies [65e3395]
|
|
49
|
+
- Updated dependencies [4933192]
|
|
50
|
+
- Updated dependencies [d1c77a4]
|
|
51
|
+
- Updated dependencies [bea9dd1]
|
|
52
|
+
- Updated dependencies [dcd4802]
|
|
53
|
+
- Updated dependencies [7ba91fa]
|
|
54
|
+
- @mastra/core@0.11.0-alpha.2
|
|
55
|
+
|
|
3
56
|
## 0.11.4
|
|
4
57
|
|
|
5
58
|
### Patch Changes
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Agent } from '@mastra/core';
|
|
2
2
|
import type { BaseContext } from 'inngest';
|
|
3
|
+
import type { ChunkType } from '@mastra/core/workflows';
|
|
3
4
|
import { ClientOptions } from 'inngest';
|
|
4
5
|
import { DefaultExecutionEngine } from '@mastra/core/workflows';
|
|
5
6
|
import type { Emitter } from '@mastra/core/workflows';
|
|
@@ -94,7 +95,7 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
94
95
|
abortController: AbortController;
|
|
95
96
|
}): Promise<TOutput>;
|
|
96
97
|
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, abortController, runtimeContext, }: {
|
|
98
|
+
superExecuteStep({ workflowId, runId, step, stepResults, executionContext, resume, prevOutput, emitter, abortController, runtimeContext, writableStream, }: {
|
|
98
99
|
workflowId: string;
|
|
99
100
|
runId: string;
|
|
100
101
|
step: Step<string, any, any>;
|
|
@@ -108,8 +109,9 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
108
109
|
emitter: Emitter;
|
|
109
110
|
abortController: AbortController;
|
|
110
111
|
runtimeContext: RuntimeContext;
|
|
112
|
+
writableStream?: WritableStream<ChunkType>;
|
|
111
113
|
}): Promise<StepResult<any, any, any, any>>;
|
|
112
|
-
executeSleep({ workflowId, runId, entry, prevOutput, stepResults, emitter, abortController, runtimeContext, }: {
|
|
114
|
+
executeSleep({ workflowId, runId, entry, prevOutput, stepResults, emitter, abortController, runtimeContext, writableStream, }: {
|
|
113
115
|
workflowId: string;
|
|
114
116
|
runId: string;
|
|
115
117
|
serializedStepGraph: SerializedStepFlowEntry[];
|
|
@@ -132,8 +134,9 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
132
134
|
emitter: Emitter;
|
|
133
135
|
abortController: AbortController;
|
|
134
136
|
runtimeContext: RuntimeContext;
|
|
137
|
+
writableStream?: WritableStream<ChunkType>;
|
|
135
138
|
}): Promise<void>;
|
|
136
|
-
executeSleepUntil({ workflowId, runId, entry, prevOutput, stepResults, emitter, abortController, runtimeContext, }: {
|
|
139
|
+
executeSleepUntil({ workflowId, runId, entry, prevOutput, stepResults, emitter, abortController, runtimeContext, writableStream, }: {
|
|
137
140
|
workflowId: string;
|
|
138
141
|
runId: string;
|
|
139
142
|
serializedStepGraph: SerializedStepFlowEntry[];
|
|
@@ -156,12 +159,13 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
156
159
|
emitter: Emitter;
|
|
157
160
|
abortController: AbortController;
|
|
158
161
|
runtimeContext: RuntimeContext;
|
|
162
|
+
writableStream?: WritableStream<ChunkType>;
|
|
159
163
|
}): Promise<void>;
|
|
160
164
|
executeWaitForEvent({ event, timeout }: {
|
|
161
165
|
event: string;
|
|
162
166
|
timeout?: number;
|
|
163
167
|
}): Promise<any>;
|
|
164
|
-
executeStep({ step, stepResults, executionContext, resume, prevOutput, emitter, abortController, runtimeContext, }: {
|
|
168
|
+
executeStep({ step, stepResults, executionContext, resume, prevOutput, emitter, abortController, runtimeContext, writableStream, }: {
|
|
165
169
|
step: Step<string, any, any>;
|
|
166
170
|
stepResults: Record<string, StepResult<any, any, any, any>>;
|
|
167
171
|
executionContext: ExecutionContext;
|
|
@@ -174,6 +178,7 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
174
178
|
emitter: Emitter;
|
|
175
179
|
abortController: AbortController;
|
|
176
180
|
runtimeContext: RuntimeContext;
|
|
181
|
+
writableStream?: WritableStream<ChunkType>;
|
|
177
182
|
}): Promise<StepResult<any, any, any, any>>;
|
|
178
183
|
persistStepUpdate({ workflowId, runId, stepResults, executionContext, serializedStepGraph, workflowStatus, result, error, }: {
|
|
179
184
|
workflowId: string;
|
|
@@ -186,7 +191,7 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
186
191
|
error?: string | Error;
|
|
187
192
|
runtimeContext: RuntimeContext;
|
|
188
193
|
}): Promise<void>;
|
|
189
|
-
executeConditional({ workflowId, runId, entry, prevOutput, prevStep, stepResults, serializedStepGraph, resume, executionContext, emitter, abortController, runtimeContext, }: {
|
|
194
|
+
executeConditional({ workflowId, runId, entry, prevOutput, prevStep, stepResults, serializedStepGraph, resume, executionContext, emitter, abortController, runtimeContext, writableStream, }: {
|
|
190
195
|
workflowId: string;
|
|
191
196
|
runId: string;
|
|
192
197
|
entry: {
|
|
@@ -208,6 +213,7 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
208
213
|
emitter: Emitter;
|
|
209
214
|
abortController: AbortController;
|
|
210
215
|
runtimeContext: RuntimeContext;
|
|
216
|
+
writableStream?: WritableStream<ChunkType>;
|
|
211
217
|
}): Promise<StepResult<any, any, any, any>>;
|
|
212
218
|
}
|
|
213
219
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Agent } from '@mastra/core';
|
|
2
2
|
import type { BaseContext } from 'inngest';
|
|
3
|
+
import type { ChunkType } from '@mastra/core/workflows';
|
|
3
4
|
import { ClientOptions } from 'inngest';
|
|
4
5
|
import { DefaultExecutionEngine } from '@mastra/core/workflows';
|
|
5
6
|
import type { Emitter } from '@mastra/core/workflows';
|
|
@@ -94,7 +95,7 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
94
95
|
abortController: AbortController;
|
|
95
96
|
}): Promise<TOutput>;
|
|
96
97
|
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, abortController, runtimeContext, }: {
|
|
98
|
+
superExecuteStep({ workflowId, runId, step, stepResults, executionContext, resume, prevOutput, emitter, abortController, runtimeContext, writableStream, }: {
|
|
98
99
|
workflowId: string;
|
|
99
100
|
runId: string;
|
|
100
101
|
step: Step<string, any, any>;
|
|
@@ -108,8 +109,9 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
108
109
|
emitter: Emitter;
|
|
109
110
|
abortController: AbortController;
|
|
110
111
|
runtimeContext: RuntimeContext;
|
|
112
|
+
writableStream?: WritableStream<ChunkType>;
|
|
111
113
|
}): Promise<StepResult<any, any, any, any>>;
|
|
112
|
-
executeSleep({ workflowId, runId, entry, prevOutput, stepResults, emitter, abortController, runtimeContext, }: {
|
|
114
|
+
executeSleep({ workflowId, runId, entry, prevOutput, stepResults, emitter, abortController, runtimeContext, writableStream, }: {
|
|
113
115
|
workflowId: string;
|
|
114
116
|
runId: string;
|
|
115
117
|
serializedStepGraph: SerializedStepFlowEntry[];
|
|
@@ -132,8 +134,9 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
132
134
|
emitter: Emitter;
|
|
133
135
|
abortController: AbortController;
|
|
134
136
|
runtimeContext: RuntimeContext;
|
|
137
|
+
writableStream?: WritableStream<ChunkType>;
|
|
135
138
|
}): Promise<void>;
|
|
136
|
-
executeSleepUntil({ workflowId, runId, entry, prevOutput, stepResults, emitter, abortController, runtimeContext, }: {
|
|
139
|
+
executeSleepUntil({ workflowId, runId, entry, prevOutput, stepResults, emitter, abortController, runtimeContext, writableStream, }: {
|
|
137
140
|
workflowId: string;
|
|
138
141
|
runId: string;
|
|
139
142
|
serializedStepGraph: SerializedStepFlowEntry[];
|
|
@@ -156,12 +159,13 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
156
159
|
emitter: Emitter;
|
|
157
160
|
abortController: AbortController;
|
|
158
161
|
runtimeContext: RuntimeContext;
|
|
162
|
+
writableStream?: WritableStream<ChunkType>;
|
|
159
163
|
}): Promise<void>;
|
|
160
164
|
executeWaitForEvent({ event, timeout }: {
|
|
161
165
|
event: string;
|
|
162
166
|
timeout?: number;
|
|
163
167
|
}): Promise<any>;
|
|
164
|
-
executeStep({ step, stepResults, executionContext, resume, prevOutput, emitter, abortController, runtimeContext, }: {
|
|
168
|
+
executeStep({ step, stepResults, executionContext, resume, prevOutput, emitter, abortController, runtimeContext, writableStream, }: {
|
|
165
169
|
step: Step<string, any, any>;
|
|
166
170
|
stepResults: Record<string, StepResult<any, any, any, any>>;
|
|
167
171
|
executionContext: ExecutionContext;
|
|
@@ -174,6 +178,7 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
174
178
|
emitter: Emitter;
|
|
175
179
|
abortController: AbortController;
|
|
176
180
|
runtimeContext: RuntimeContext;
|
|
181
|
+
writableStream?: WritableStream<ChunkType>;
|
|
177
182
|
}): Promise<StepResult<any, any, any, any>>;
|
|
178
183
|
persistStepUpdate({ workflowId, runId, stepResults, executionContext, serializedStepGraph, workflowStatus, result, error, }: {
|
|
179
184
|
workflowId: string;
|
|
@@ -186,7 +191,7 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
186
191
|
error?: string | Error;
|
|
187
192
|
runtimeContext: RuntimeContext;
|
|
188
193
|
}): Promise<void>;
|
|
189
|
-
executeConditional({ workflowId, runId, entry, prevOutput, prevStep, stepResults, serializedStepGraph, resume, executionContext, emitter, abortController, runtimeContext, }: {
|
|
194
|
+
executeConditional({ workflowId, runId, entry, prevOutput, prevStep, stepResults, serializedStepGraph, resume, executionContext, emitter, abortController, runtimeContext, writableStream, }: {
|
|
190
195
|
workflowId: string;
|
|
191
196
|
runId: string;
|
|
192
197
|
entry: {
|
|
@@ -208,6 +213,7 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
208
213
|
emitter: Emitter;
|
|
209
214
|
abortController: AbortController;
|
|
210
215
|
runtimeContext: RuntimeContext;
|
|
216
|
+
writableStream?: WritableStream<ChunkType>;
|
|
211
217
|
}): Promise<StepResult<any, any, any, any>>;
|
|
212
218
|
}
|
|
213
219
|
|
package/dist/index.cjs
CHANGED
|
@@ -155,6 +155,7 @@ var InngestRun = class extends workflows.Run {
|
|
|
155
155
|
data: {
|
|
156
156
|
inputData: params.resumeData,
|
|
157
157
|
runId: this.runId,
|
|
158
|
+
workflowId: this.workflowId,
|
|
158
159
|
stepResults: snapshot?.context,
|
|
159
160
|
resume: {
|
|
160
161
|
steps,
|
|
@@ -650,7 +651,8 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
650
651
|
prevOutput,
|
|
651
652
|
emitter,
|
|
652
653
|
abortController,
|
|
653
|
-
runtimeContext
|
|
654
|
+
runtimeContext,
|
|
655
|
+
writableStream
|
|
654
656
|
}) {
|
|
655
657
|
return super.executeStep({
|
|
656
658
|
workflowId,
|
|
@@ -662,7 +664,8 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
662
664
|
prevOutput,
|
|
663
665
|
emitter,
|
|
664
666
|
abortController,
|
|
665
|
-
runtimeContext
|
|
667
|
+
runtimeContext,
|
|
668
|
+
writableStream
|
|
666
669
|
});
|
|
667
670
|
}
|
|
668
671
|
// async executeSleep({ id, duration }: { id: string; duration: number }): Promise<void> {
|
|
@@ -676,13 +679,16 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
676
679
|
stepResults,
|
|
677
680
|
emitter,
|
|
678
681
|
abortController,
|
|
679
|
-
runtimeContext
|
|
682
|
+
runtimeContext,
|
|
683
|
+
writableStream
|
|
680
684
|
}) {
|
|
681
685
|
let { duration, fn } = entry;
|
|
682
686
|
if (fn) {
|
|
687
|
+
const stepCallId = crypto.randomUUID();
|
|
683
688
|
duration = await this.inngestStep.run(`workflow.${workflowId}.sleep.${entry.id}`, async () => {
|
|
684
689
|
return await fn({
|
|
685
690
|
runId,
|
|
691
|
+
workflowId,
|
|
686
692
|
mastra: this.mastra,
|
|
687
693
|
runtimeContext,
|
|
688
694
|
inputData: prevOutput,
|
|
@@ -708,7 +714,16 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
708
714
|
},
|
|
709
715
|
[_constants.EMITTER_SYMBOL]: emitter,
|
|
710
716
|
engine: { step: this.inngestStep },
|
|
711
|
-
abortSignal: abortController?.signal
|
|
717
|
+
abortSignal: abortController?.signal,
|
|
718
|
+
writer: new tools.ToolStream(
|
|
719
|
+
{
|
|
720
|
+
prefix: "step",
|
|
721
|
+
callId: stepCallId,
|
|
722
|
+
name: "sleep",
|
|
723
|
+
runId
|
|
724
|
+
},
|
|
725
|
+
writableStream
|
|
726
|
+
)
|
|
712
727
|
});
|
|
713
728
|
});
|
|
714
729
|
}
|
|
@@ -722,13 +737,16 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
722
737
|
stepResults,
|
|
723
738
|
emitter,
|
|
724
739
|
abortController,
|
|
725
|
-
runtimeContext
|
|
740
|
+
runtimeContext,
|
|
741
|
+
writableStream
|
|
726
742
|
}) {
|
|
727
743
|
let { date, fn } = entry;
|
|
728
744
|
if (fn) {
|
|
729
745
|
date = await this.inngestStep.run(`workflow.${workflowId}.sleepUntil.${entry.id}`, async () => {
|
|
746
|
+
const stepCallId = crypto.randomUUID();
|
|
730
747
|
return await fn({
|
|
731
748
|
runId,
|
|
749
|
+
workflowId,
|
|
732
750
|
mastra: this.mastra,
|
|
733
751
|
runtimeContext,
|
|
734
752
|
inputData: prevOutput,
|
|
@@ -754,7 +772,16 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
754
772
|
},
|
|
755
773
|
[_constants.EMITTER_SYMBOL]: emitter,
|
|
756
774
|
engine: { step: this.inngestStep },
|
|
757
|
-
abortSignal: abortController?.signal
|
|
775
|
+
abortSignal: abortController?.signal,
|
|
776
|
+
writer: new tools.ToolStream(
|
|
777
|
+
{
|
|
778
|
+
prefix: "step",
|
|
779
|
+
callId: stepCallId,
|
|
780
|
+
name: "sleep",
|
|
781
|
+
runId
|
|
782
|
+
},
|
|
783
|
+
writableStream
|
|
784
|
+
)
|
|
758
785
|
});
|
|
759
786
|
});
|
|
760
787
|
}
|
|
@@ -781,7 +808,8 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
781
808
|
prevOutput,
|
|
782
809
|
emitter,
|
|
783
810
|
abortController,
|
|
784
|
-
runtimeContext
|
|
811
|
+
runtimeContext,
|
|
812
|
+
writableStream
|
|
785
813
|
}) {
|
|
786
814
|
const startedAt = await this.inngestStep.run(
|
|
787
815
|
`workflow.${executionContext.workflowId}.run.${executionContext.runId}.step.${step.id}.running_ev`,
|
|
@@ -1000,6 +1028,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
1000
1028
|
runId: executionContext.runId,
|
|
1001
1029
|
mastra: this.mastra,
|
|
1002
1030
|
runtimeContext,
|
|
1031
|
+
writableStream,
|
|
1003
1032
|
inputData: prevOutput,
|
|
1004
1033
|
resumeData: resume?.steps[0] === step.id ? resume?.resumePayload : void 0,
|
|
1005
1034
|
getInitData: () => stepResults?.input,
|
|
@@ -1159,7 +1188,8 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
1159
1188
|
executionContext,
|
|
1160
1189
|
emitter,
|
|
1161
1190
|
abortController,
|
|
1162
|
-
runtimeContext
|
|
1191
|
+
runtimeContext,
|
|
1192
|
+
writableStream
|
|
1163
1193
|
}) {
|
|
1164
1194
|
let execResults;
|
|
1165
1195
|
const truthyIndexes = (await Promise.all(
|
|
@@ -1168,6 +1198,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
1168
1198
|
try {
|
|
1169
1199
|
const result = await cond({
|
|
1170
1200
|
runId,
|
|
1201
|
+
workflowId,
|
|
1171
1202
|
mastra: this.mastra,
|
|
1172
1203
|
runtimeContext,
|
|
1173
1204
|
runCount: -1,
|
|
@@ -1195,7 +1226,16 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
1195
1226
|
engine: {
|
|
1196
1227
|
step: this.inngestStep
|
|
1197
1228
|
},
|
|
1198
|
-
abortSignal: abortController.signal
|
|
1229
|
+
abortSignal: abortController.signal,
|
|
1230
|
+
writer: new tools.ToolStream(
|
|
1231
|
+
{
|
|
1232
|
+
prefix: "step",
|
|
1233
|
+
callId: crypto.randomUUID(),
|
|
1234
|
+
name: "conditional",
|
|
1235
|
+
runId
|
|
1236
|
+
},
|
|
1237
|
+
writableStream
|
|
1238
|
+
)
|
|
1199
1239
|
});
|
|
1200
1240
|
return result ? index : null;
|
|
1201
1241
|
} catch (e) {
|
|
@@ -1225,7 +1265,8 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
1225
1265
|
},
|
|
1226
1266
|
emitter,
|
|
1227
1267
|
abortController,
|
|
1228
|
-
runtimeContext
|
|
1268
|
+
runtimeContext,
|
|
1269
|
+
writableStream
|
|
1229
1270
|
})
|
|
1230
1271
|
)
|
|
1231
1272
|
);
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { randomUUID } from 'crypto';
|
|
2
2
|
import { subscribe } from '@inngest/realtime';
|
|
3
3
|
import { RuntimeContext } from '@mastra/core/di';
|
|
4
|
-
import { Tool } from '@mastra/core/tools';
|
|
4
|
+
import { ToolStream, Tool } from '@mastra/core/tools';
|
|
5
5
|
import { Run, Workflow, DefaultExecutionEngine } from '@mastra/core/workflows';
|
|
6
6
|
import { EMITTER_SYMBOL } from '@mastra/core/workflows/_constants';
|
|
7
7
|
import { serve as serve$1 } from 'inngest/hono';
|
|
@@ -153,6 +153,7 @@ var InngestRun = class extends Run {
|
|
|
153
153
|
data: {
|
|
154
154
|
inputData: params.resumeData,
|
|
155
155
|
runId: this.runId,
|
|
156
|
+
workflowId: this.workflowId,
|
|
156
157
|
stepResults: snapshot?.context,
|
|
157
158
|
resume: {
|
|
158
159
|
steps,
|
|
@@ -648,7 +649,8 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
|
|
|
648
649
|
prevOutput,
|
|
649
650
|
emitter,
|
|
650
651
|
abortController,
|
|
651
|
-
runtimeContext
|
|
652
|
+
runtimeContext,
|
|
653
|
+
writableStream
|
|
652
654
|
}) {
|
|
653
655
|
return super.executeStep({
|
|
654
656
|
workflowId,
|
|
@@ -660,7 +662,8 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
|
|
|
660
662
|
prevOutput,
|
|
661
663
|
emitter,
|
|
662
664
|
abortController,
|
|
663
|
-
runtimeContext
|
|
665
|
+
runtimeContext,
|
|
666
|
+
writableStream
|
|
664
667
|
});
|
|
665
668
|
}
|
|
666
669
|
// async executeSleep({ id, duration }: { id: string; duration: number }): Promise<void> {
|
|
@@ -674,13 +677,16 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
|
|
|
674
677
|
stepResults,
|
|
675
678
|
emitter,
|
|
676
679
|
abortController,
|
|
677
|
-
runtimeContext
|
|
680
|
+
runtimeContext,
|
|
681
|
+
writableStream
|
|
678
682
|
}) {
|
|
679
683
|
let { duration, fn } = entry;
|
|
680
684
|
if (fn) {
|
|
685
|
+
const stepCallId = randomUUID();
|
|
681
686
|
duration = await this.inngestStep.run(`workflow.${workflowId}.sleep.${entry.id}`, async () => {
|
|
682
687
|
return await fn({
|
|
683
688
|
runId,
|
|
689
|
+
workflowId,
|
|
684
690
|
mastra: this.mastra,
|
|
685
691
|
runtimeContext,
|
|
686
692
|
inputData: prevOutput,
|
|
@@ -706,7 +712,16 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
|
|
|
706
712
|
},
|
|
707
713
|
[EMITTER_SYMBOL]: emitter,
|
|
708
714
|
engine: { step: this.inngestStep },
|
|
709
|
-
abortSignal: abortController?.signal
|
|
715
|
+
abortSignal: abortController?.signal,
|
|
716
|
+
writer: new ToolStream(
|
|
717
|
+
{
|
|
718
|
+
prefix: "step",
|
|
719
|
+
callId: stepCallId,
|
|
720
|
+
name: "sleep",
|
|
721
|
+
runId
|
|
722
|
+
},
|
|
723
|
+
writableStream
|
|
724
|
+
)
|
|
710
725
|
});
|
|
711
726
|
});
|
|
712
727
|
}
|
|
@@ -720,13 +735,16 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
|
|
|
720
735
|
stepResults,
|
|
721
736
|
emitter,
|
|
722
737
|
abortController,
|
|
723
|
-
runtimeContext
|
|
738
|
+
runtimeContext,
|
|
739
|
+
writableStream
|
|
724
740
|
}) {
|
|
725
741
|
let { date, fn } = entry;
|
|
726
742
|
if (fn) {
|
|
727
743
|
date = await this.inngestStep.run(`workflow.${workflowId}.sleepUntil.${entry.id}`, async () => {
|
|
744
|
+
const stepCallId = randomUUID();
|
|
728
745
|
return await fn({
|
|
729
746
|
runId,
|
|
747
|
+
workflowId,
|
|
730
748
|
mastra: this.mastra,
|
|
731
749
|
runtimeContext,
|
|
732
750
|
inputData: prevOutput,
|
|
@@ -752,7 +770,16 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
|
|
|
752
770
|
},
|
|
753
771
|
[EMITTER_SYMBOL]: emitter,
|
|
754
772
|
engine: { step: this.inngestStep },
|
|
755
|
-
abortSignal: abortController?.signal
|
|
773
|
+
abortSignal: abortController?.signal,
|
|
774
|
+
writer: new ToolStream(
|
|
775
|
+
{
|
|
776
|
+
prefix: "step",
|
|
777
|
+
callId: stepCallId,
|
|
778
|
+
name: "sleep",
|
|
779
|
+
runId
|
|
780
|
+
},
|
|
781
|
+
writableStream
|
|
782
|
+
)
|
|
756
783
|
});
|
|
757
784
|
});
|
|
758
785
|
}
|
|
@@ -779,7 +806,8 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
|
|
|
779
806
|
prevOutput,
|
|
780
807
|
emitter,
|
|
781
808
|
abortController,
|
|
782
|
-
runtimeContext
|
|
809
|
+
runtimeContext,
|
|
810
|
+
writableStream
|
|
783
811
|
}) {
|
|
784
812
|
const startedAt = await this.inngestStep.run(
|
|
785
813
|
`workflow.${executionContext.workflowId}.run.${executionContext.runId}.step.${step.id}.running_ev`,
|
|
@@ -998,6 +1026,7 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
|
|
|
998
1026
|
runId: executionContext.runId,
|
|
999
1027
|
mastra: this.mastra,
|
|
1000
1028
|
runtimeContext,
|
|
1029
|
+
writableStream,
|
|
1001
1030
|
inputData: prevOutput,
|
|
1002
1031
|
resumeData: resume?.steps[0] === step.id ? resume?.resumePayload : void 0,
|
|
1003
1032
|
getInitData: () => stepResults?.input,
|
|
@@ -1157,7 +1186,8 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
|
|
|
1157
1186
|
executionContext,
|
|
1158
1187
|
emitter,
|
|
1159
1188
|
abortController,
|
|
1160
|
-
runtimeContext
|
|
1189
|
+
runtimeContext,
|
|
1190
|
+
writableStream
|
|
1161
1191
|
}) {
|
|
1162
1192
|
let execResults;
|
|
1163
1193
|
const truthyIndexes = (await Promise.all(
|
|
@@ -1166,6 +1196,7 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
|
|
|
1166
1196
|
try {
|
|
1167
1197
|
const result = await cond({
|
|
1168
1198
|
runId,
|
|
1199
|
+
workflowId,
|
|
1169
1200
|
mastra: this.mastra,
|
|
1170
1201
|
runtimeContext,
|
|
1171
1202
|
runCount: -1,
|
|
@@ -1193,7 +1224,16 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
|
|
|
1193
1224
|
engine: {
|
|
1194
1225
|
step: this.inngestStep
|
|
1195
1226
|
},
|
|
1196
|
-
abortSignal: abortController.signal
|
|
1227
|
+
abortSignal: abortController.signal,
|
|
1228
|
+
writer: new ToolStream(
|
|
1229
|
+
{
|
|
1230
|
+
prefix: "step",
|
|
1231
|
+
callId: randomUUID(),
|
|
1232
|
+
name: "conditional",
|
|
1233
|
+
runId
|
|
1234
|
+
},
|
|
1235
|
+
writableStream
|
|
1236
|
+
)
|
|
1197
1237
|
});
|
|
1198
1238
|
return result ? index : null;
|
|
1199
1239
|
} catch (e) {
|
|
@@ -1223,7 +1263,8 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
|
|
|
1223
1263
|
},
|
|
1224
1264
|
emitter,
|
|
1225
1265
|
abortController,
|
|
1226
|
-
runtimeContext
|
|
1266
|
+
runtimeContext,
|
|
1267
|
+
writableStream
|
|
1227
1268
|
})
|
|
1228
1269
|
)
|
|
1229
1270
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/inngest",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.5",
|
|
4
4
|
"description": "Mastra Inngest integration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"tsup": "^8.5.0",
|
|
39
39
|
"typescript": "^5.8.3",
|
|
40
40
|
"vitest": "^3.2.4",
|
|
41
|
-
"@internal/lint": "0.0.
|
|
42
|
-
"@mastra/libsql": "0.11.
|
|
43
|
-
"@mastra/
|
|
44
|
-
"@mastra/
|
|
41
|
+
"@internal/lint": "0.0.21",
|
|
42
|
+
"@mastra/libsql": "0.11.1",
|
|
43
|
+
"@mastra/core": "0.11.0",
|
|
44
|
+
"@mastra/deployer": "0.11.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@mastra/core": ">=0.10.11-0 <0.11.0-0"
|
package/src/index.test.ts
CHANGED
|
@@ -4258,6 +4258,124 @@ describe('MastraInngestWorkflow', () => {
|
|
|
4258
4258
|
|
|
4259
4259
|
expect(promptAgentAction).toHaveBeenCalledTimes(2);
|
|
4260
4260
|
});
|
|
4261
|
+
|
|
4262
|
+
it('should handle consecutive nested workflows with suspend/resume', async ctx => {
|
|
4263
|
+
const inngest = new Inngest({
|
|
4264
|
+
id: 'mastra',
|
|
4265
|
+
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
4266
|
+
middleware: [realtimeMiddleware()],
|
|
4267
|
+
});
|
|
4268
|
+
|
|
4269
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
4270
|
+
|
|
4271
|
+
const step1 = vi.fn().mockImplementation(async ({ resumeData, suspend }) => {
|
|
4272
|
+
if (!resumeData?.suspect) {
|
|
4273
|
+
return await suspend({ message: 'What is the suspect?' });
|
|
4274
|
+
}
|
|
4275
|
+
return { suspect: resumeData.suspect };
|
|
4276
|
+
});
|
|
4277
|
+
const step1Definition = createStep({
|
|
4278
|
+
id: 'step-1',
|
|
4279
|
+
inputSchema: z.object({ suspect: z.string() }),
|
|
4280
|
+
outputSchema: z.object({ suspect: z.string() }),
|
|
4281
|
+
suspendSchema: z.object({ message: z.string() }),
|
|
4282
|
+
resumeSchema: z.object({ suspect: z.string() }),
|
|
4283
|
+
execute: step1,
|
|
4284
|
+
});
|
|
4285
|
+
|
|
4286
|
+
const step2 = vi.fn().mockImplementation(async ({ resumeData, suspend }) => {
|
|
4287
|
+
if (!resumeData?.suspect) {
|
|
4288
|
+
return await suspend({ message: 'What is the second suspect?' });
|
|
4289
|
+
}
|
|
4290
|
+
return { suspect: resumeData.suspect };
|
|
4291
|
+
});
|
|
4292
|
+
const step2Definition = createStep({
|
|
4293
|
+
id: 'step-2',
|
|
4294
|
+
inputSchema: z.object({ suspect: z.string() }),
|
|
4295
|
+
outputSchema: z.object({ suspect: z.string() }),
|
|
4296
|
+
suspendSchema: z.object({ message: z.string() }),
|
|
4297
|
+
resumeSchema: z.object({ suspect: z.string() }),
|
|
4298
|
+
execute: step2,
|
|
4299
|
+
});
|
|
4300
|
+
|
|
4301
|
+
const subWorkflow1 = createWorkflow({
|
|
4302
|
+
id: 'sub-workflow-1',
|
|
4303
|
+
inputSchema: z.object({ suspect: z.string() }),
|
|
4304
|
+
outputSchema: z.object({ suspect: z.string() }),
|
|
4305
|
+
})
|
|
4306
|
+
.then(step1Definition)
|
|
4307
|
+
.commit();
|
|
4308
|
+
|
|
4309
|
+
const subWorkflow2 = createWorkflow({
|
|
4310
|
+
id: 'sub-workflow-2',
|
|
4311
|
+
inputSchema: z.object({ suspect: z.string() }),
|
|
4312
|
+
outputSchema: z.object({ suspect: z.string() }),
|
|
4313
|
+
})
|
|
4314
|
+
.then(step2Definition)
|
|
4315
|
+
.commit();
|
|
4316
|
+
|
|
4317
|
+
const mainWorkflow = createWorkflow({
|
|
4318
|
+
id: 'main-workflow',
|
|
4319
|
+
inputSchema: z.object({ suspect: z.string() }),
|
|
4320
|
+
outputSchema: z.object({ suspect: z.string() }),
|
|
4321
|
+
})
|
|
4322
|
+
.then(subWorkflow1)
|
|
4323
|
+
.then(subWorkflow2)
|
|
4324
|
+
.commit();
|
|
4325
|
+
|
|
4326
|
+
const mastra = new Mastra({
|
|
4327
|
+
logger: false,
|
|
4328
|
+
storage: new DefaultStorage({
|
|
4329
|
+
url: ':memory:',
|
|
4330
|
+
}),
|
|
4331
|
+
workflows: { mainWorkflow },
|
|
4332
|
+
server: {
|
|
4333
|
+
apiRoutes: [
|
|
4334
|
+
{
|
|
4335
|
+
path: '/inngest/api',
|
|
4336
|
+
method: 'ALL',
|
|
4337
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
4338
|
+
},
|
|
4339
|
+
],
|
|
4340
|
+
},
|
|
4341
|
+
});
|
|
4342
|
+
|
|
4343
|
+
const app = await createHonoServer(mastra);
|
|
4344
|
+
|
|
4345
|
+
const srv = (globServer = serve({
|
|
4346
|
+
fetch: app.fetch,
|
|
4347
|
+
port: (ctx as any).handlerPort,
|
|
4348
|
+
}));
|
|
4349
|
+
await resetInngest();
|
|
4350
|
+
|
|
4351
|
+
const run = await mainWorkflow.createRunAsync();
|
|
4352
|
+
|
|
4353
|
+
const initialResult = await run.start({ inputData: { suspect: 'initial-suspect' } });
|
|
4354
|
+
expect(initialResult.status).toBe('suspended');
|
|
4355
|
+
|
|
4356
|
+
const firstResumeResult = await run.resume({
|
|
4357
|
+
step: ['sub-workflow-1', 'step-1'],
|
|
4358
|
+
resumeData: { suspect: 'first-suspect' },
|
|
4359
|
+
});
|
|
4360
|
+
expect(firstResumeResult.status).toBe('suspended');
|
|
4361
|
+
|
|
4362
|
+
const secondResumeResult = await run.resume({
|
|
4363
|
+
step: ['sub-workflow-2', 'step-2'],
|
|
4364
|
+
resumeData: { suspect: 'second-suspect' },
|
|
4365
|
+
});
|
|
4366
|
+
|
|
4367
|
+
expect(step1).toHaveBeenCalledTimes(2);
|
|
4368
|
+
expect(step2).toHaveBeenCalledTimes(2);
|
|
4369
|
+
expect(secondResumeResult.status).toBe('success');
|
|
4370
|
+
expect(secondResumeResult.steps['sub-workflow-1']).toMatchObject({
|
|
4371
|
+
status: 'success',
|
|
4372
|
+
});
|
|
4373
|
+
expect(secondResumeResult.steps['sub-workflow-2']).toMatchObject({
|
|
4374
|
+
status: 'success',
|
|
4375
|
+
});
|
|
4376
|
+
|
|
4377
|
+
srv.close();
|
|
4378
|
+
});
|
|
4261
4379
|
});
|
|
4262
4380
|
|
|
4263
4381
|
describe('Accessing Mastra', () => {
|
package/src/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { ReadableStream } from 'node:stream/web';
|
|
|
3
3
|
import { subscribe } from '@inngest/realtime';
|
|
4
4
|
import type { Agent, Mastra, ToolExecutionContext, WorkflowRun, WorkflowRuns } from '@mastra/core';
|
|
5
5
|
import { RuntimeContext } from '@mastra/core/di';
|
|
6
|
-
import { Tool } from '@mastra/core/tools';
|
|
6
|
+
import { Tool, ToolStream } from '@mastra/core/tools';
|
|
7
7
|
import { Workflow, Run, DefaultExecutionEngine } from '@mastra/core/workflows';
|
|
8
8
|
import type {
|
|
9
9
|
ExecuteFunction,
|
|
@@ -20,6 +20,7 @@ import type {
|
|
|
20
20
|
Emitter,
|
|
21
21
|
WatchEvent,
|
|
22
22
|
StreamEvent,
|
|
23
|
+
ChunkType,
|
|
23
24
|
} from '@mastra/core/workflows';
|
|
24
25
|
import { EMITTER_SYMBOL } from '@mastra/core/workflows/_constants';
|
|
25
26
|
import type { Span } from '@opentelemetry/api';
|
|
@@ -231,6 +232,7 @@ export class InngestRun<
|
|
|
231
232
|
data: {
|
|
232
233
|
inputData: params.resumeData,
|
|
233
234
|
runId: this.runId,
|
|
235
|
+
workflowId: this.workflowId,
|
|
234
236
|
stepResults: snapshot?.context as any,
|
|
235
237
|
resume: {
|
|
236
238
|
steps,
|
|
@@ -968,6 +970,7 @@ export class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
968
970
|
emitter,
|
|
969
971
|
abortController,
|
|
970
972
|
runtimeContext,
|
|
973
|
+
writableStream,
|
|
971
974
|
}: {
|
|
972
975
|
workflowId: string;
|
|
973
976
|
runId: string;
|
|
@@ -982,6 +985,7 @@ export class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
982
985
|
emitter: Emitter;
|
|
983
986
|
abortController: AbortController;
|
|
984
987
|
runtimeContext: RuntimeContext;
|
|
988
|
+
writableStream?: WritableStream<ChunkType>;
|
|
985
989
|
}): Promise<StepResult<any, any, any, any>> {
|
|
986
990
|
return super.executeStep({
|
|
987
991
|
workflowId,
|
|
@@ -994,6 +998,7 @@ export class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
994
998
|
emitter,
|
|
995
999
|
abortController,
|
|
996
1000
|
runtimeContext,
|
|
1001
|
+
writableStream,
|
|
997
1002
|
});
|
|
998
1003
|
}
|
|
999
1004
|
|
|
@@ -1010,6 +1015,7 @@ export class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
1010
1015
|
emitter,
|
|
1011
1016
|
abortController,
|
|
1012
1017
|
runtimeContext,
|
|
1018
|
+
writableStream,
|
|
1013
1019
|
}: {
|
|
1014
1020
|
workflowId: string;
|
|
1015
1021
|
runId: string;
|
|
@@ -1033,13 +1039,16 @@ export class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
1033
1039
|
emitter: Emitter;
|
|
1034
1040
|
abortController: AbortController;
|
|
1035
1041
|
runtimeContext: RuntimeContext;
|
|
1042
|
+
writableStream?: WritableStream<ChunkType>;
|
|
1036
1043
|
}): Promise<void> {
|
|
1037
1044
|
let { duration, fn } = entry;
|
|
1038
1045
|
|
|
1039
1046
|
if (fn) {
|
|
1047
|
+
const stepCallId = randomUUID();
|
|
1040
1048
|
duration = await this.inngestStep.run(`workflow.${workflowId}.sleep.${entry.id}`, async () => {
|
|
1041
1049
|
return await fn({
|
|
1042
1050
|
runId,
|
|
1051
|
+
workflowId,
|
|
1043
1052
|
mastra: this.mastra!,
|
|
1044
1053
|
runtimeContext,
|
|
1045
1054
|
inputData: prevOutput,
|
|
@@ -1067,6 +1076,15 @@ export class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
1067
1076
|
[EMITTER_SYMBOL]: emitter,
|
|
1068
1077
|
engine: { step: this.inngestStep },
|
|
1069
1078
|
abortSignal: abortController?.signal,
|
|
1079
|
+
writer: new ToolStream(
|
|
1080
|
+
{
|
|
1081
|
+
prefix: 'step',
|
|
1082
|
+
callId: stepCallId,
|
|
1083
|
+
name: 'sleep',
|
|
1084
|
+
runId,
|
|
1085
|
+
},
|
|
1086
|
+
writableStream,
|
|
1087
|
+
),
|
|
1070
1088
|
});
|
|
1071
1089
|
});
|
|
1072
1090
|
}
|
|
@@ -1083,6 +1101,7 @@ export class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
1083
1101
|
emitter,
|
|
1084
1102
|
abortController,
|
|
1085
1103
|
runtimeContext,
|
|
1104
|
+
writableStream,
|
|
1086
1105
|
}: {
|
|
1087
1106
|
workflowId: string;
|
|
1088
1107
|
runId: string;
|
|
@@ -1106,13 +1125,16 @@ export class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
1106
1125
|
emitter: Emitter;
|
|
1107
1126
|
abortController: AbortController;
|
|
1108
1127
|
runtimeContext: RuntimeContext;
|
|
1128
|
+
writableStream?: WritableStream<ChunkType>;
|
|
1109
1129
|
}): Promise<void> {
|
|
1110
1130
|
let { date, fn } = entry;
|
|
1111
1131
|
|
|
1112
1132
|
if (fn) {
|
|
1113
1133
|
date = await this.inngestStep.run(`workflow.${workflowId}.sleepUntil.${entry.id}`, async () => {
|
|
1134
|
+
const stepCallId = randomUUID();
|
|
1114
1135
|
return await fn({
|
|
1115
1136
|
runId,
|
|
1137
|
+
workflowId,
|
|
1116
1138
|
mastra: this.mastra!,
|
|
1117
1139
|
runtimeContext,
|
|
1118
1140
|
inputData: prevOutput,
|
|
@@ -1140,6 +1162,15 @@ export class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
1140
1162
|
[EMITTER_SYMBOL]: emitter,
|
|
1141
1163
|
engine: { step: this.inngestStep },
|
|
1142
1164
|
abortSignal: abortController?.signal,
|
|
1165
|
+
writer: new ToolStream(
|
|
1166
|
+
{
|
|
1167
|
+
prefix: 'step',
|
|
1168
|
+
callId: stepCallId,
|
|
1169
|
+
name: 'sleep',
|
|
1170
|
+
runId,
|
|
1171
|
+
},
|
|
1172
|
+
writableStream,
|
|
1173
|
+
),
|
|
1143
1174
|
});
|
|
1144
1175
|
});
|
|
1145
1176
|
}
|
|
@@ -1173,6 +1204,7 @@ export class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
1173
1204
|
emitter,
|
|
1174
1205
|
abortController,
|
|
1175
1206
|
runtimeContext,
|
|
1207
|
+
writableStream,
|
|
1176
1208
|
}: {
|
|
1177
1209
|
step: Step<string, any, any>;
|
|
1178
1210
|
stepResults: Record<string, StepResult<any, any, any, any>>;
|
|
@@ -1186,6 +1218,7 @@ export class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
1186
1218
|
emitter: Emitter;
|
|
1187
1219
|
abortController: AbortController;
|
|
1188
1220
|
runtimeContext: RuntimeContext;
|
|
1221
|
+
writableStream?: WritableStream<ChunkType>;
|
|
1189
1222
|
}): Promise<StepResult<any, any, any, any>> {
|
|
1190
1223
|
const startedAt = await this.inngestStep.run(
|
|
1191
1224
|
`workflow.${executionContext.workflowId}.run.${executionContext.runId}.step.${step.id}.running_ev`,
|
|
@@ -1429,6 +1462,7 @@ export class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
1429
1462
|
runId: executionContext.runId,
|
|
1430
1463
|
mastra: this.mastra!,
|
|
1431
1464
|
runtimeContext,
|
|
1465
|
+
writableStream,
|
|
1432
1466
|
inputData: prevOutput,
|
|
1433
1467
|
resumeData: resume?.steps[0] === step.id ? resume?.resumePayload : undefined,
|
|
1434
1468
|
getInitData: () => stepResults?.input as any,
|
|
@@ -1614,6 +1648,7 @@ export class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
1614
1648
|
emitter,
|
|
1615
1649
|
abortController,
|
|
1616
1650
|
runtimeContext,
|
|
1651
|
+
writableStream,
|
|
1617
1652
|
}: {
|
|
1618
1653
|
workflowId: string;
|
|
1619
1654
|
runId: string;
|
|
@@ -1636,6 +1671,7 @@ export class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
1636
1671
|
emitter: Emitter;
|
|
1637
1672
|
abortController: AbortController;
|
|
1638
1673
|
runtimeContext: RuntimeContext;
|
|
1674
|
+
writableStream?: WritableStream<ChunkType>;
|
|
1639
1675
|
}): Promise<StepResult<any, any, any, any>> {
|
|
1640
1676
|
let execResults: any;
|
|
1641
1677
|
const truthyIndexes = (
|
|
@@ -1645,6 +1681,7 @@ export class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
1645
1681
|
try {
|
|
1646
1682
|
const result = await cond({
|
|
1647
1683
|
runId,
|
|
1684
|
+
workflowId,
|
|
1648
1685
|
mastra: this.mastra!,
|
|
1649
1686
|
runtimeContext,
|
|
1650
1687
|
runCount: -1,
|
|
@@ -1674,6 +1711,15 @@ export class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
1674
1711
|
step: this.inngestStep,
|
|
1675
1712
|
},
|
|
1676
1713
|
abortSignal: abortController.signal,
|
|
1714
|
+
writer: new ToolStream(
|
|
1715
|
+
{
|
|
1716
|
+
prefix: 'step',
|
|
1717
|
+
callId: randomUUID(),
|
|
1718
|
+
name: 'conditional',
|
|
1719
|
+
runId,
|
|
1720
|
+
},
|
|
1721
|
+
writableStream,
|
|
1722
|
+
),
|
|
1677
1723
|
});
|
|
1678
1724
|
return result ? index : null;
|
|
1679
1725
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -1707,6 +1753,7 @@ export class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
1707
1753
|
emitter,
|
|
1708
1754
|
abortController,
|
|
1709
1755
|
runtimeContext,
|
|
1756
|
+
writableStream,
|
|
1710
1757
|
}),
|
|
1711
1758
|
),
|
|
1712
1759
|
);
|