@mastra/inngest 0.10.3 → 0.10.4
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 +8 -0
- package/dist/_tsup-dts-rollup.d.cts +19 -6
- package/dist/_tsup-dts-rollup.d.ts +19 -6
- package/dist/index.cjs +25 -10
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +25 -10
- package/package.json +5 -4
- package/src/index.test.ts +48 -136
- package/src/index.ts +58 -10
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/inngest@0.10.3
|
|
2
|
+
> @mastra/inngest@0.10.3 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 7542ms
|
|
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 7133ms
|
|
17
17
|
[34mCLI[39m Cleaning output folder
|
|
18
18
|
[34mESM[39m Build start
|
|
19
19
|
[34mCJS[39m Build start
|
|
20
|
-
[32mESM[39m [1mdist/index.js [22m[32m22.
|
|
21
|
-
[32mESM[39m ⚡️ Build success in
|
|
22
|
-
[32mCJS[39m [1mdist/index.cjs [22m[
|
|
23
|
-
[32mCJS[39m ⚡️ Build success in
|
|
20
|
+
[32mESM[39m [1mdist/index.js [22m[32m22.93 KB[39m
|
|
21
|
+
[32mESM[39m ⚡️ Build success in 318ms
|
|
22
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m23.07 KB[39m
|
|
23
|
+
[32mCJS[39m ⚡️ Build success in 319ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { BaseContext } from 'inngest';
|
|
2
2
|
import { ClientOptions } from 'inngest';
|
|
3
3
|
import { cloneStep } from '@mastra/core/workflows';
|
|
4
|
-
import { createStep } from '@mastra/core/workflows';
|
|
5
4
|
import { DefaultExecutionEngine } from '@mastra/core/workflows';
|
|
6
5
|
import type { ExecuteFunction } from '@mastra/core/workflows';
|
|
7
6
|
import type { ExecutionContext } from '@mastra/core/workflows';
|
|
@@ -32,12 +31,23 @@ declare function cloneWorkflow<TWorkflowId extends string = string, TInput exten
|
|
|
32
31
|
}): InngestWorkflow<TSteps, TWorkflowId, TInput, TOutput>;
|
|
33
32
|
|
|
34
33
|
export declare function init(inngest: Inngest): {
|
|
35
|
-
createWorkflow<TWorkflowId extends string = string, TInput extends z.ZodType<any> = z.ZodType<any, z.ZodTypeDef, any>, TOutput extends z.ZodType<any> = z.ZodType<any, z.ZodTypeDef, any>, TSteps extends Step<string, any, any>[] = Step<string, any, any, z.ZodType<any, z.ZodTypeDef, any>, z.ZodType<any, z.ZodTypeDef, any
|
|
36
|
-
createStep:
|
|
34
|
+
createWorkflow<TWorkflowId extends string = string, TInput extends z.ZodType<any> = z.ZodType<any, z.ZodTypeDef, any>, TOutput extends z.ZodType<any> = z.ZodType<any, z.ZodTypeDef, any>, TSteps extends Step<string, any, any>[] = Step<string, any, any, z.ZodType<any, z.ZodTypeDef, any>, z.ZodType<any, z.ZodTypeDef, any>, any>[]>(params: WorkflowConfig<TWorkflowId, TInput, TOutput, TSteps>): InngestWorkflow<TSteps, TWorkflowId, TInput, TOutput, TInput>;
|
|
35
|
+
createStep<TStepId extends string, TStepInput extends z.ZodType<any>, TStepOutput extends z.ZodType<any>, TResumeSchema extends z.ZodType<any>, TSuspendSchema extends z.ZodType<any>>(params: {
|
|
36
|
+
id: TStepId;
|
|
37
|
+
inputSchema: TStepInput;
|
|
38
|
+
outputSchema: TStepOutput;
|
|
39
|
+
resumeSchema?: TResumeSchema;
|
|
40
|
+
suspendSchema?: TSuspendSchema;
|
|
41
|
+
execute: ExecuteFunction<z.infer<TStepInput>, z.infer<TStepOutput>, z.infer<TResumeSchema>, z.infer<TSuspendSchema>, InngestEngineType>;
|
|
42
|
+
}): Step<TStepId, TStepInput, TStepOutput, TResumeSchema, TSuspendSchema, InngestEngineType>;
|
|
37
43
|
cloneStep: typeof cloneStep;
|
|
38
44
|
cloneWorkflow: typeof cloneWorkflow;
|
|
39
45
|
};
|
|
40
46
|
|
|
47
|
+
export declare type InngestEngineType = {
|
|
48
|
+
step: any;
|
|
49
|
+
};
|
|
50
|
+
|
|
41
51
|
export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
42
52
|
private inngestStep;
|
|
43
53
|
private inngestAttempts;
|
|
@@ -85,12 +95,15 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
85
95
|
};
|
|
86
96
|
runtimeContext: RuntimeContext;
|
|
87
97
|
}): Promise<StepResult<any, any, any, any>>;
|
|
88
|
-
persistStepUpdate({ workflowId, runId, stepResults, executionContext, serializedStepGraph, }: {
|
|
98
|
+
persistStepUpdate({ workflowId, runId, stepResults, executionContext, serializedStepGraph, workflowStatus, result, error, }: {
|
|
89
99
|
workflowId: string;
|
|
90
100
|
runId: string;
|
|
91
101
|
stepResults: Record<string, StepResult<any, any, any, any>>;
|
|
92
102
|
serializedStepGraph: SerializedStepFlowEntry[];
|
|
93
103
|
executionContext: ExecutionContext;
|
|
104
|
+
workflowStatus: 'success' | 'failed' | 'suspended' | 'running';
|
|
105
|
+
result?: Record<string, any>;
|
|
106
|
+
error?: string | Error;
|
|
94
107
|
}): Promise<void>;
|
|
95
108
|
executeConditional({ workflowId, runId, entry, prevOutput, prevStep, stepResults, serializedStepGraph, resume, executionContext, emitter, runtimeContext, }: {
|
|
96
109
|
workflowId: string;
|
|
@@ -98,7 +111,7 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
98
111
|
entry: {
|
|
99
112
|
type: 'conditional';
|
|
100
113
|
steps: StepFlowEntry[];
|
|
101
|
-
conditions: ExecuteFunction<any, any, any, any>[];
|
|
114
|
+
conditions: ExecuteFunction<any, any, any, any, InngestEngineType>[];
|
|
102
115
|
};
|
|
103
116
|
prevStep: StepFlowEntry;
|
|
104
117
|
serializedStepGraph: SerializedStepFlowEntry[];
|
|
@@ -149,7 +162,7 @@ export declare class InngestRun<TSteps extends Step<string, any, any>[] = Step<s
|
|
|
149
162
|
watch(cb: (event: any) => void): () => void;
|
|
150
163
|
}
|
|
151
164
|
|
|
152
|
-
export declare class InngestWorkflow<TSteps extends Step<string, any, any>[] = Step<string, any, any>[], TWorkflowId extends string = string, TInput extends z.ZodType<any> = z.ZodType<any>, TOutput extends z.ZodType<any> = z.ZodType<any>, TPrevSchema extends z.ZodType<any> = TInput> extends Workflow<TSteps, TWorkflowId, TInput, TOutput, TPrevSchema> {
|
|
165
|
+
export declare class InngestWorkflow<TSteps extends Step<string, any, any>[] = Step<string, any, any>[], TWorkflowId extends string = string, TInput extends z.ZodType<any> = z.ZodType<any>, TOutput extends z.ZodType<any> = z.ZodType<any>, TPrevSchema extends z.ZodType<any> = TInput> extends Workflow<TSteps, TWorkflowId, TInput, TOutput, InngestEngineType, TPrevSchema> {
|
|
153
166
|
#private;
|
|
154
167
|
inngest: Inngest;
|
|
155
168
|
private function;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { BaseContext } from 'inngest';
|
|
2
2
|
import { ClientOptions } from 'inngest';
|
|
3
3
|
import { cloneStep } from '@mastra/core/workflows';
|
|
4
|
-
import { createStep } from '@mastra/core/workflows';
|
|
5
4
|
import { DefaultExecutionEngine } from '@mastra/core/workflows';
|
|
6
5
|
import type { ExecuteFunction } from '@mastra/core/workflows';
|
|
7
6
|
import type { ExecutionContext } from '@mastra/core/workflows';
|
|
@@ -32,12 +31,23 @@ declare function cloneWorkflow<TWorkflowId extends string = string, TInput exten
|
|
|
32
31
|
}): InngestWorkflow<TSteps, TWorkflowId, TInput, TOutput>;
|
|
33
32
|
|
|
34
33
|
export declare function init(inngest: Inngest): {
|
|
35
|
-
createWorkflow<TWorkflowId extends string = string, TInput extends z.ZodType<any> = z.ZodType<any, z.ZodTypeDef, any>, TOutput extends z.ZodType<any> = z.ZodType<any, z.ZodTypeDef, any>, TSteps extends Step<string, any, any>[] = Step<string, any, any, z.ZodType<any, z.ZodTypeDef, any>, z.ZodType<any, z.ZodTypeDef, any
|
|
36
|
-
createStep:
|
|
34
|
+
createWorkflow<TWorkflowId extends string = string, TInput extends z.ZodType<any> = z.ZodType<any, z.ZodTypeDef, any>, TOutput extends z.ZodType<any> = z.ZodType<any, z.ZodTypeDef, any>, TSteps extends Step<string, any, any>[] = Step<string, any, any, z.ZodType<any, z.ZodTypeDef, any>, z.ZodType<any, z.ZodTypeDef, any>, any>[]>(params: WorkflowConfig<TWorkflowId, TInput, TOutput, TSteps>): InngestWorkflow<TSteps, TWorkflowId, TInput, TOutput, TInput>;
|
|
35
|
+
createStep<TStepId extends string, TStepInput extends z.ZodType<any>, TStepOutput extends z.ZodType<any>, TResumeSchema extends z.ZodType<any>, TSuspendSchema extends z.ZodType<any>>(params: {
|
|
36
|
+
id: TStepId;
|
|
37
|
+
inputSchema: TStepInput;
|
|
38
|
+
outputSchema: TStepOutput;
|
|
39
|
+
resumeSchema?: TResumeSchema;
|
|
40
|
+
suspendSchema?: TSuspendSchema;
|
|
41
|
+
execute: ExecuteFunction<z.infer<TStepInput>, z.infer<TStepOutput>, z.infer<TResumeSchema>, z.infer<TSuspendSchema>, InngestEngineType>;
|
|
42
|
+
}): Step<TStepId, TStepInput, TStepOutput, TResumeSchema, TSuspendSchema, InngestEngineType>;
|
|
37
43
|
cloneStep: typeof cloneStep;
|
|
38
44
|
cloneWorkflow: typeof cloneWorkflow;
|
|
39
45
|
};
|
|
40
46
|
|
|
47
|
+
export declare type InngestEngineType = {
|
|
48
|
+
step: any;
|
|
49
|
+
};
|
|
50
|
+
|
|
41
51
|
export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
42
52
|
private inngestStep;
|
|
43
53
|
private inngestAttempts;
|
|
@@ -85,12 +95,15 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
85
95
|
};
|
|
86
96
|
runtimeContext: RuntimeContext;
|
|
87
97
|
}): Promise<StepResult<any, any, any, any>>;
|
|
88
|
-
persistStepUpdate({ workflowId, runId, stepResults, executionContext, serializedStepGraph, }: {
|
|
98
|
+
persistStepUpdate({ workflowId, runId, stepResults, executionContext, serializedStepGraph, workflowStatus, result, error, }: {
|
|
89
99
|
workflowId: string;
|
|
90
100
|
runId: string;
|
|
91
101
|
stepResults: Record<string, StepResult<any, any, any, any>>;
|
|
92
102
|
serializedStepGraph: SerializedStepFlowEntry[];
|
|
93
103
|
executionContext: ExecutionContext;
|
|
104
|
+
workflowStatus: 'success' | 'failed' | 'suspended' | 'running';
|
|
105
|
+
result?: Record<string, any>;
|
|
106
|
+
error?: string | Error;
|
|
94
107
|
}): Promise<void>;
|
|
95
108
|
executeConditional({ workflowId, runId, entry, prevOutput, prevStep, stepResults, serializedStepGraph, resume, executionContext, emitter, runtimeContext, }: {
|
|
96
109
|
workflowId: string;
|
|
@@ -98,7 +111,7 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
98
111
|
entry: {
|
|
99
112
|
type: 'conditional';
|
|
100
113
|
steps: StepFlowEntry[];
|
|
101
|
-
conditions: ExecuteFunction<any, any, any, any>[];
|
|
114
|
+
conditions: ExecuteFunction<any, any, any, any, InngestEngineType>[];
|
|
102
115
|
};
|
|
103
116
|
prevStep: StepFlowEntry;
|
|
104
117
|
serializedStepGraph: SerializedStepFlowEntry[];
|
|
@@ -149,7 +162,7 @@ export declare class InngestRun<TSteps extends Step<string, any, any>[] = Step<s
|
|
|
149
162
|
watch(cb: (event: any) => void): () => void;
|
|
150
163
|
}
|
|
151
164
|
|
|
152
|
-
export declare class InngestWorkflow<TSteps extends Step<string, any, any>[] = Step<string, any, any>[], TWorkflowId extends string = string, TInput extends z.ZodType<any> = z.ZodType<any>, TOutput extends z.ZodType<any> = z.ZodType<any>, TPrevSchema extends z.ZodType<any> = TInput> extends Workflow<TSteps, TWorkflowId, TInput, TOutput, TPrevSchema> {
|
|
165
|
+
export declare class InngestWorkflow<TSteps extends Step<string, any, any>[] = Step<string, any, any>[], TWorkflowId extends string = string, TInput extends z.ZodType<any> = z.ZodType<any>, TOutput extends z.ZodType<any> = z.ZodType<any>, TPrevSchema extends z.ZodType<any> = TInput> extends Workflow<TSteps, TWorkflowId, TInput, TOutput, InngestEngineType, TPrevSchema> {
|
|
153
166
|
#private;
|
|
154
167
|
inngest: Inngest;
|
|
155
168
|
private function;
|
package/dist/index.cjs
CHANGED
|
@@ -65,7 +65,8 @@ var InngestRun = class extends workflows.Run {
|
|
|
65
65
|
context: {},
|
|
66
66
|
activePaths: [],
|
|
67
67
|
suspendedPaths: {},
|
|
68
|
-
timestamp: Date.now()
|
|
68
|
+
timestamp: Date.now(),
|
|
69
|
+
status: "running"
|
|
69
70
|
}
|
|
70
71
|
});
|
|
71
72
|
const eventOutput = await this.inngest.send({
|
|
@@ -289,7 +290,9 @@ function init(inngest) {
|
|
|
289
290
|
createWorkflow(params) {
|
|
290
291
|
return new InngestWorkflow(params, inngest);
|
|
291
292
|
},
|
|
292
|
-
createStep
|
|
293
|
+
createStep(params) {
|
|
294
|
+
return workflows.createStep(params);
|
|
295
|
+
},
|
|
293
296
|
cloneStep: workflows.cloneStep,
|
|
294
297
|
cloneWorkflow
|
|
295
298
|
};
|
|
@@ -585,7 +588,10 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
585
588
|
// @ts-ignore
|
|
586
589
|
runId: stepResults[step.id]?.payload?.__workflow_meta?.runId
|
|
587
590
|
},
|
|
588
|
-
emitter
|
|
591
|
+
[_constants.EMITTER_SYMBOL]: emitter,
|
|
592
|
+
engine: {
|
|
593
|
+
step: this.inngestStep
|
|
594
|
+
}
|
|
589
595
|
});
|
|
590
596
|
execResults = { status: "success", output: result };
|
|
591
597
|
} catch (e) {
|
|
@@ -627,7 +633,10 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
627
633
|
runId,
|
|
628
634
|
stepResults,
|
|
629
635
|
executionContext,
|
|
630
|
-
serializedStepGraph
|
|
636
|
+
serializedStepGraph,
|
|
637
|
+
workflowStatus,
|
|
638
|
+
result,
|
|
639
|
+
error
|
|
631
640
|
}) {
|
|
632
641
|
await this.inngestStep.run(
|
|
633
642
|
`workflow.${workflowId}.run.${runId}.path.${JSON.stringify(executionContext.executionPath)}.stepUpdate`,
|
|
@@ -642,6 +651,9 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
642
651
|
activePaths: [],
|
|
643
652
|
suspendedPaths: executionContext.suspendedPaths,
|
|
644
653
|
serializedStepGraph,
|
|
654
|
+
status: workflowStatus,
|
|
655
|
+
result,
|
|
656
|
+
error,
|
|
645
657
|
// @ts-ignore
|
|
646
658
|
timestamp: Date.now()
|
|
647
659
|
}
|
|
@@ -686,7 +698,10 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
686
698
|
// TODO: this function shouldn't have suspend probably?
|
|
687
699
|
suspend: async (_suspendPayload) => {
|
|
688
700
|
},
|
|
689
|
-
[_constants.EMITTER_SYMBOL]: emitter
|
|
701
|
+
[_constants.EMITTER_SYMBOL]: emitter,
|
|
702
|
+
engine: {
|
|
703
|
+
step: this.inngestStep
|
|
704
|
+
}
|
|
690
705
|
});
|
|
691
706
|
return result ? index : null;
|
|
692
707
|
} catch (e) {
|
|
@@ -719,17 +734,17 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
719
734
|
})
|
|
720
735
|
)
|
|
721
736
|
);
|
|
722
|
-
const hasFailed = results.find((result) => result.status === "failed");
|
|
723
|
-
const hasSuspended = results.find((result) => result.status === "suspended");
|
|
737
|
+
const hasFailed = results.find((result) => result.result.status === "failed");
|
|
738
|
+
const hasSuspended = results.find((result) => result.result.status === "suspended");
|
|
724
739
|
if (hasFailed) {
|
|
725
|
-
execResults = { status: "failed", error: hasFailed.error };
|
|
740
|
+
execResults = { status: "failed", error: hasFailed.result.error };
|
|
726
741
|
} else if (hasSuspended) {
|
|
727
|
-
execResults = { status: "suspended", payload: hasSuspended.payload };
|
|
742
|
+
execResults = { status: "suspended", payload: hasSuspended.result.payload };
|
|
728
743
|
} else {
|
|
729
744
|
execResults = {
|
|
730
745
|
status: "success",
|
|
731
746
|
output: results.reduce((acc, result, index) => {
|
|
732
|
-
if (result.status === "success") {
|
|
747
|
+
if (result.result.status === "success") {
|
|
733
748
|
acc[stepsToRun[index].step.id] = result.output;
|
|
734
749
|
}
|
|
735
750
|
return acc;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { serve } from './_tsup-dts-rollup.cjs';
|
|
2
2
|
export { init } from './_tsup-dts-rollup.cjs';
|
|
3
|
+
export { InngestEngineType } from './_tsup-dts-rollup.cjs';
|
|
3
4
|
export { InngestRun } from './_tsup-dts-rollup.cjs';
|
|
4
5
|
export { InngestWorkflow } from './_tsup-dts-rollup.cjs';
|
|
5
6
|
export { InngestExecutionEngine } from './_tsup-dts-rollup.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { serve } from './_tsup-dts-rollup.js';
|
|
2
2
|
export { init } from './_tsup-dts-rollup.js';
|
|
3
|
+
export { InngestEngineType } from './_tsup-dts-rollup.js';
|
|
3
4
|
export { InngestRun } from './_tsup-dts-rollup.js';
|
|
4
5
|
export { InngestWorkflow } from './_tsup-dts-rollup.js';
|
|
5
6
|
export { InngestExecutionEngine } from './_tsup-dts-rollup.js';
|
package/dist/index.js
CHANGED
|
@@ -63,7 +63,8 @@ var InngestRun = class extends Run {
|
|
|
63
63
|
context: {},
|
|
64
64
|
activePaths: [],
|
|
65
65
|
suspendedPaths: {},
|
|
66
|
-
timestamp: Date.now()
|
|
66
|
+
timestamp: Date.now(),
|
|
67
|
+
status: "running"
|
|
67
68
|
}
|
|
68
69
|
});
|
|
69
70
|
const eventOutput = await this.inngest.send({
|
|
@@ -287,7 +288,9 @@ function init(inngest) {
|
|
|
287
288
|
createWorkflow(params) {
|
|
288
289
|
return new InngestWorkflow(params, inngest);
|
|
289
290
|
},
|
|
290
|
-
createStep
|
|
291
|
+
createStep(params) {
|
|
292
|
+
return createStep(params);
|
|
293
|
+
},
|
|
291
294
|
cloneStep,
|
|
292
295
|
cloneWorkflow
|
|
293
296
|
};
|
|
@@ -583,7 +586,10 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
|
|
|
583
586
|
// @ts-ignore
|
|
584
587
|
runId: stepResults[step.id]?.payload?.__workflow_meta?.runId
|
|
585
588
|
},
|
|
586
|
-
emitter
|
|
589
|
+
[EMITTER_SYMBOL]: emitter,
|
|
590
|
+
engine: {
|
|
591
|
+
step: this.inngestStep
|
|
592
|
+
}
|
|
587
593
|
});
|
|
588
594
|
execResults = { status: "success", output: result };
|
|
589
595
|
} catch (e) {
|
|
@@ -625,7 +631,10 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
|
|
|
625
631
|
runId,
|
|
626
632
|
stepResults,
|
|
627
633
|
executionContext,
|
|
628
|
-
serializedStepGraph
|
|
634
|
+
serializedStepGraph,
|
|
635
|
+
workflowStatus,
|
|
636
|
+
result,
|
|
637
|
+
error
|
|
629
638
|
}) {
|
|
630
639
|
await this.inngestStep.run(
|
|
631
640
|
`workflow.${workflowId}.run.${runId}.path.${JSON.stringify(executionContext.executionPath)}.stepUpdate`,
|
|
@@ -640,6 +649,9 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
|
|
|
640
649
|
activePaths: [],
|
|
641
650
|
suspendedPaths: executionContext.suspendedPaths,
|
|
642
651
|
serializedStepGraph,
|
|
652
|
+
status: workflowStatus,
|
|
653
|
+
result,
|
|
654
|
+
error,
|
|
643
655
|
// @ts-ignore
|
|
644
656
|
timestamp: Date.now()
|
|
645
657
|
}
|
|
@@ -684,7 +696,10 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
|
|
|
684
696
|
// TODO: this function shouldn't have suspend probably?
|
|
685
697
|
suspend: async (_suspendPayload) => {
|
|
686
698
|
},
|
|
687
|
-
[EMITTER_SYMBOL]: emitter
|
|
699
|
+
[EMITTER_SYMBOL]: emitter,
|
|
700
|
+
engine: {
|
|
701
|
+
step: this.inngestStep
|
|
702
|
+
}
|
|
688
703
|
});
|
|
689
704
|
return result ? index : null;
|
|
690
705
|
} catch (e) {
|
|
@@ -717,17 +732,17 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
|
|
|
717
732
|
})
|
|
718
733
|
)
|
|
719
734
|
);
|
|
720
|
-
const hasFailed = results.find((result) => result.status === "failed");
|
|
721
|
-
const hasSuspended = results.find((result) => result.status === "suspended");
|
|
735
|
+
const hasFailed = results.find((result) => result.result.status === "failed");
|
|
736
|
+
const hasSuspended = results.find((result) => result.result.status === "suspended");
|
|
722
737
|
if (hasFailed) {
|
|
723
|
-
execResults = { status: "failed", error: hasFailed.error };
|
|
738
|
+
execResults = { status: "failed", error: hasFailed.result.error };
|
|
724
739
|
} else if (hasSuspended) {
|
|
725
|
-
execResults = { status: "suspended", payload: hasSuspended.payload };
|
|
740
|
+
execResults = { status: "suspended", payload: hasSuspended.result.payload };
|
|
726
741
|
} else {
|
|
727
742
|
execResults = {
|
|
728
743
|
status: "success",
|
|
729
744
|
output: results.reduce((acc, result, index) => {
|
|
730
|
-
if (result.status === "success") {
|
|
745
|
+
if (result.result.status === "success") {
|
|
731
746
|
acc[stepsToRun[index].step.id] = result.output;
|
|
732
747
|
}
|
|
733
748
|
return acc;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/inngest",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.4",
|
|
4
4
|
"description": "Mastra Inngest integration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -37,9 +37,10 @@
|
|
|
37
37
|
"tsup": "^8.5.0",
|
|
38
38
|
"typescript": "^5.8.2",
|
|
39
39
|
"vitest": "^2.1.9",
|
|
40
|
-
"@internal/lint": "0.0.
|
|
41
|
-
"@mastra/
|
|
42
|
-
"@mastra/
|
|
40
|
+
"@internal/lint": "0.0.12",
|
|
41
|
+
"@mastra/deployer": "0.10.5",
|
|
42
|
+
"@mastra/core": "0.10.5",
|
|
43
|
+
"@mastra/libsql": "0.10.2"
|
|
43
44
|
},
|
|
44
45
|
"peerDependencies": {
|
|
45
46
|
"@mastra/core": "^0.10.2-alpha.0"
|
package/src/index.test.ts
CHANGED
|
@@ -7,8 +7,8 @@ import { realtimeMiddleware } from '@inngest/realtime';
|
|
|
7
7
|
import { createTool, Mastra, Telemetry } from '@mastra/core';
|
|
8
8
|
import { Agent } from '@mastra/core/agent';
|
|
9
9
|
import { RuntimeContext } from '@mastra/core/runtime-context';
|
|
10
|
-
import { DefaultStorage } from '@mastra/core/storage/libsql';
|
|
11
10
|
import { createHonoServer } from '@mastra/deployer/server';
|
|
11
|
+
import { DefaultStorage } from '@mastra/libsql';
|
|
12
12
|
import { $ } from 'execa';
|
|
13
13
|
import getPort from 'get-port';
|
|
14
14
|
import { Inngest } from 'inngest';
|
|
@@ -67,9 +67,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
67
67
|
|
|
68
68
|
const mastra = new Mastra({
|
|
69
69
|
storage: new DefaultStorage({
|
|
70
|
-
|
|
71
|
-
url: ':memory:',
|
|
72
|
-
},
|
|
70
|
+
url: ':memory:',
|
|
73
71
|
}),
|
|
74
72
|
workflows: {
|
|
75
73
|
'test-workflow': workflow,
|
|
@@ -144,9 +142,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
144
142
|
|
|
145
143
|
const mastra = new Mastra({
|
|
146
144
|
storage: new DefaultStorage({
|
|
147
|
-
|
|
148
|
-
url: ':memory:',
|
|
149
|
-
},
|
|
145
|
+
url: ':memory:',
|
|
150
146
|
}),
|
|
151
147
|
workflows: {
|
|
152
148
|
'test-workflow': workflow,
|
|
@@ -227,9 +223,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
227
223
|
|
|
228
224
|
const mastra = new Mastra({
|
|
229
225
|
storage: new DefaultStorage({
|
|
230
|
-
|
|
231
|
-
url: ':memory:',
|
|
232
|
-
},
|
|
226
|
+
url: ':memory:',
|
|
233
227
|
}),
|
|
234
228
|
workflows: {
|
|
235
229
|
'test-workflow': workflow,
|
|
@@ -301,9 +295,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
301
295
|
|
|
302
296
|
const mastra = new Mastra({
|
|
303
297
|
storage: new DefaultStorage({
|
|
304
|
-
|
|
305
|
-
url: ':memory:',
|
|
306
|
-
},
|
|
298
|
+
url: ':memory:',
|
|
307
299
|
}),
|
|
308
300
|
workflows: {
|
|
309
301
|
'test-workflow': workflow,
|
|
@@ -390,9 +382,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
390
382
|
|
|
391
383
|
const mastra = new Mastra({
|
|
392
384
|
storage: new DefaultStorage({
|
|
393
|
-
|
|
394
|
-
url: ':memory:',
|
|
395
|
-
},
|
|
385
|
+
url: ':memory:',
|
|
396
386
|
}),
|
|
397
387
|
workflows: {
|
|
398
388
|
'test-workflow': workflow,
|
|
@@ -459,9 +449,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
459
449
|
|
|
460
450
|
const mastra = new Mastra({
|
|
461
451
|
storage: new DefaultStorage({
|
|
462
|
-
|
|
463
|
-
url: ':memory:',
|
|
464
|
-
},
|
|
452
|
+
url: ':memory:',
|
|
465
453
|
}),
|
|
466
454
|
workflows: {
|
|
467
455
|
'test-workflow': workflow,
|
|
@@ -536,9 +524,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
536
524
|
|
|
537
525
|
const mastra = new Mastra({
|
|
538
526
|
storage: new DefaultStorage({
|
|
539
|
-
|
|
540
|
-
url: ':memory:',
|
|
541
|
-
},
|
|
527
|
+
url: ':memory:',
|
|
542
528
|
}),
|
|
543
529
|
workflows: {
|
|
544
530
|
'test-workflow': workflow,
|
|
@@ -620,9 +606,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
620
606
|
|
|
621
607
|
const mastra = new Mastra({
|
|
622
608
|
storage: new DefaultStorage({
|
|
623
|
-
|
|
624
|
-
url: ':memory:',
|
|
625
|
-
},
|
|
609
|
+
url: ':memory:',
|
|
626
610
|
}),
|
|
627
611
|
workflows: {
|
|
628
612
|
'test-workflow': workflow,
|
|
@@ -725,9 +709,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
725
709
|
|
|
726
710
|
const mastra = new Mastra({
|
|
727
711
|
storage: new DefaultStorage({
|
|
728
|
-
|
|
729
|
-
url: ':memory:',
|
|
730
|
-
},
|
|
712
|
+
url: ':memory:',
|
|
731
713
|
}),
|
|
732
714
|
workflows: {
|
|
733
715
|
'test-workflow': workflow,
|
|
@@ -803,9 +785,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
803
785
|
|
|
804
786
|
const mastra = new Mastra({
|
|
805
787
|
storage: new DefaultStorage({
|
|
806
|
-
|
|
807
|
-
url: ':memory:',
|
|
808
|
-
},
|
|
788
|
+
url: ':memory:',
|
|
809
789
|
}),
|
|
810
790
|
workflows: {
|
|
811
791
|
'test-workflow': workflow,
|
|
@@ -910,9 +890,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
910
890
|
|
|
911
891
|
const mastra = new Mastra({
|
|
912
892
|
storage: new DefaultStorage({
|
|
913
|
-
|
|
914
|
-
url: ':memory:',
|
|
915
|
-
},
|
|
893
|
+
url: ':memory:',
|
|
916
894
|
}),
|
|
917
895
|
workflows: {
|
|
918
896
|
'test-workflow': workflow,
|
|
@@ -995,9 +973,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
995
973
|
|
|
996
974
|
const mastra = new Mastra({
|
|
997
975
|
storage: new DefaultStorage({
|
|
998
|
-
|
|
999
|
-
url: ':memory:',
|
|
1000
|
-
},
|
|
976
|
+
url: ':memory:',
|
|
1001
977
|
}),
|
|
1002
978
|
workflows: {
|
|
1003
979
|
'test-workflow': workflow,
|
|
@@ -1065,9 +1041,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
1065
1041
|
|
|
1066
1042
|
const mastra = new Mastra({
|
|
1067
1043
|
storage: new DefaultStorage({
|
|
1068
|
-
|
|
1069
|
-
url: ':memory:',
|
|
1070
|
-
},
|
|
1044
|
+
url: ':memory:',
|
|
1071
1045
|
}),
|
|
1072
1046
|
workflows: {
|
|
1073
1047
|
'test-workflow': workflow,
|
|
@@ -1151,9 +1125,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
1151
1125
|
|
|
1152
1126
|
const mastra = new Mastra({
|
|
1153
1127
|
storage: new DefaultStorage({
|
|
1154
|
-
|
|
1155
|
-
url: ':memory:',
|
|
1156
|
-
},
|
|
1128
|
+
url: ':memory:',
|
|
1157
1129
|
}),
|
|
1158
1130
|
workflows: {
|
|
1159
1131
|
'test-workflow': workflow,
|
|
@@ -1247,9 +1219,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
1247
1219
|
|
|
1248
1220
|
const mastra = new Mastra({
|
|
1249
1221
|
storage: new DefaultStorage({
|
|
1250
|
-
|
|
1251
|
-
url: ':memory:',
|
|
1252
|
-
},
|
|
1222
|
+
url: ':memory:',
|
|
1253
1223
|
}),
|
|
1254
1224
|
workflows: {
|
|
1255
1225
|
'main-workflow': mainWorkflow,
|
|
@@ -1377,9 +1347,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
1377
1347
|
|
|
1378
1348
|
const mastra = new Mastra({
|
|
1379
1349
|
storage: new DefaultStorage({
|
|
1380
|
-
|
|
1381
|
-
url: ':memory:',
|
|
1382
|
-
},
|
|
1350
|
+
url: ':memory:',
|
|
1383
1351
|
}),
|
|
1384
1352
|
workflows: {
|
|
1385
1353
|
'test-workflow': workflow,
|
|
@@ -1481,9 +1449,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
1481
1449
|
|
|
1482
1450
|
const mastra = new Mastra({
|
|
1483
1451
|
storage: new DefaultStorage({
|
|
1484
|
-
|
|
1485
|
-
url: ':memory:',
|
|
1486
|
-
},
|
|
1452
|
+
url: ':memory:',
|
|
1487
1453
|
}),
|
|
1488
1454
|
workflows: {
|
|
1489
1455
|
'test-workflow': counterWorkflow,
|
|
@@ -1586,9 +1552,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
1586
1552
|
|
|
1587
1553
|
const mastra = new Mastra({
|
|
1588
1554
|
storage: new DefaultStorage({
|
|
1589
|
-
|
|
1590
|
-
url: ':memory:',
|
|
1591
|
-
},
|
|
1555
|
+
url: ':memory:',
|
|
1592
1556
|
}),
|
|
1593
1557
|
workflows: {
|
|
1594
1558
|
'test-workflow': counterWorkflow,
|
|
@@ -1677,9 +1641,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
1677
1641
|
|
|
1678
1642
|
const mastra = new Mastra({
|
|
1679
1643
|
storage: new DefaultStorage({
|
|
1680
|
-
|
|
1681
|
-
url: ':memory:',
|
|
1682
|
-
},
|
|
1644
|
+
url: ':memory:',
|
|
1683
1645
|
}),
|
|
1684
1646
|
workflows: {
|
|
1685
1647
|
'test-workflow': counterWorkflow,
|
|
@@ -1832,9 +1794,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
1832
1794
|
|
|
1833
1795
|
const mastra = new Mastra({
|
|
1834
1796
|
storage: new DefaultStorage({
|
|
1835
|
-
|
|
1836
|
-
url: ':memory:',
|
|
1837
|
-
},
|
|
1797
|
+
url: ':memory:',
|
|
1838
1798
|
}),
|
|
1839
1799
|
workflows: {
|
|
1840
1800
|
'test-workflow': counterWorkflow,
|
|
@@ -1983,9 +1943,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
1983
1943
|
|
|
1984
1944
|
const mastra = new Mastra({
|
|
1985
1945
|
storage: new DefaultStorage({
|
|
1986
|
-
|
|
1987
|
-
url: ':memory:',
|
|
1988
|
-
},
|
|
1946
|
+
url: ':memory:',
|
|
1989
1947
|
}),
|
|
1990
1948
|
workflows: {
|
|
1991
1949
|
'test-workflow': counterWorkflow,
|
|
@@ -2157,9 +2115,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
2157
2115
|
|
|
2158
2116
|
const mastra = new Mastra({
|
|
2159
2117
|
storage: new DefaultStorage({
|
|
2160
|
-
|
|
2161
|
-
url: ':memory:',
|
|
2162
|
-
},
|
|
2118
|
+
url: ':memory:',
|
|
2163
2119
|
}),
|
|
2164
2120
|
workflows: {
|
|
2165
2121
|
'test-workflow': workflow,
|
|
@@ -2225,9 +2181,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
2225
2181
|
|
|
2226
2182
|
const mastra = new Mastra({
|
|
2227
2183
|
storage: new DefaultStorage({
|
|
2228
|
-
|
|
2229
|
-
url: ':memory:',
|
|
2230
|
-
},
|
|
2184
|
+
url: ':memory:',
|
|
2231
2185
|
}),
|
|
2232
2186
|
workflows: {
|
|
2233
2187
|
'test-workflow': workflow,
|
|
@@ -2359,9 +2313,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
2359
2313
|
|
|
2360
2314
|
const mastra = new Mastra({
|
|
2361
2315
|
storage: new DefaultStorage({
|
|
2362
|
-
|
|
2363
|
-
url: ':memory:',
|
|
2364
|
-
},
|
|
2316
|
+
url: ':memory:',
|
|
2365
2317
|
}),
|
|
2366
2318
|
workflows: {
|
|
2367
2319
|
'test-workflow': workflow,
|
|
@@ -2432,9 +2384,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
2432
2384
|
|
|
2433
2385
|
const mastra = new Mastra({
|
|
2434
2386
|
storage: new DefaultStorage({
|
|
2435
|
-
|
|
2436
|
-
url: ':memory:',
|
|
2437
|
-
},
|
|
2387
|
+
url: ':memory:',
|
|
2438
2388
|
}),
|
|
2439
2389
|
workflows: {
|
|
2440
2390
|
'test-workflow': workflow,
|
|
@@ -2620,9 +2570,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
2620
2570
|
|
|
2621
2571
|
const mastra = new Mastra({
|
|
2622
2572
|
storage: new DefaultStorage({
|
|
2623
|
-
|
|
2624
|
-
url: ':memory:',
|
|
2625
|
-
},
|
|
2573
|
+
url: ':memory:',
|
|
2626
2574
|
}),
|
|
2627
2575
|
workflows: {
|
|
2628
2576
|
'test-workflow': workflow,
|
|
@@ -2792,9 +2740,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
2792
2740
|
|
|
2793
2741
|
// Create a new storage instance for initial run
|
|
2794
2742
|
const initialStorage = new DefaultStorage({
|
|
2795
|
-
|
|
2796
|
-
url: 'file::memory:',
|
|
2797
|
-
},
|
|
2743
|
+
url: 'file::memory:',
|
|
2798
2744
|
});
|
|
2799
2745
|
const mastra = new Mastra({
|
|
2800
2746
|
storage: initialStorage,
|
|
@@ -2946,9 +2892,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
2946
2892
|
|
|
2947
2893
|
const mastra = new Mastra({
|
|
2948
2894
|
storage: new DefaultStorage({
|
|
2949
|
-
|
|
2950
|
-
url: ':memory:',
|
|
2951
|
-
},
|
|
2895
|
+
url: ':memory:',
|
|
2952
2896
|
}),
|
|
2953
2897
|
workflows: {
|
|
2954
2898
|
'test-workflow': workflow,
|
|
@@ -3150,9 +3094,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
3150
3094
|
|
|
3151
3095
|
const mastra = new Mastra({
|
|
3152
3096
|
storage: new DefaultStorage({
|
|
3153
|
-
|
|
3154
|
-
url: ':memory:',
|
|
3155
|
-
},
|
|
3097
|
+
url: ':memory:',
|
|
3156
3098
|
}),
|
|
3157
3099
|
workflows: {
|
|
3158
3100
|
'test-workflow': workflow,
|
|
@@ -3346,9 +3288,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
3346
3288
|
|
|
3347
3289
|
const mastra = new Mastra({
|
|
3348
3290
|
storage: new DefaultStorage({
|
|
3349
|
-
|
|
3350
|
-
url: ':memory:',
|
|
3351
|
-
},
|
|
3291
|
+
url: ':memory:',
|
|
3352
3292
|
}),
|
|
3353
3293
|
workflows: {
|
|
3354
3294
|
'test-workflow': promptEvalWorkflow,
|
|
@@ -3472,9 +3412,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
3472
3412
|
|
|
3473
3413
|
const mastra = new Mastra({
|
|
3474
3414
|
storage: new DefaultStorage({
|
|
3475
|
-
|
|
3476
|
-
url: ':memory:',
|
|
3477
|
-
},
|
|
3415
|
+
url: ':memory:',
|
|
3478
3416
|
}),
|
|
3479
3417
|
workflows: {
|
|
3480
3418
|
'test-workflow': workflow,
|
|
@@ -3577,9 +3515,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
3577
3515
|
|
|
3578
3516
|
const mastra = new Mastra({
|
|
3579
3517
|
storage: new DefaultStorage({
|
|
3580
|
-
|
|
3581
|
-
url: ':memory:',
|
|
3582
|
-
},
|
|
3518
|
+
url: ':memory:',
|
|
3583
3519
|
}),
|
|
3584
3520
|
workflows: {
|
|
3585
3521
|
'test-workflow': workflow,
|
|
@@ -3715,9 +3651,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
3715
3651
|
|
|
3716
3652
|
const mastra = new Mastra({
|
|
3717
3653
|
storage: new DefaultStorage({
|
|
3718
|
-
|
|
3719
|
-
url: ':memory:',
|
|
3720
|
-
},
|
|
3654
|
+
url: ':memory:',
|
|
3721
3655
|
}),
|
|
3722
3656
|
workflows: {
|
|
3723
3657
|
'test-workflow': workflow,
|
|
@@ -3860,9 +3794,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
3860
3794
|
|
|
3861
3795
|
const mastra = new Mastra({
|
|
3862
3796
|
storage: new DefaultStorage({
|
|
3863
|
-
|
|
3864
|
-
url: ':memory:',
|
|
3865
|
-
},
|
|
3797
|
+
url: ':memory:',
|
|
3866
3798
|
}),
|
|
3867
3799
|
workflows: {
|
|
3868
3800
|
'test-workflow': counterWorkflow,
|
|
@@ -4014,9 +3946,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
4014
3946
|
|
|
4015
3947
|
const mastra = new Mastra({
|
|
4016
3948
|
storage: new DefaultStorage({
|
|
4017
|
-
|
|
4018
|
-
url: ':memory:',
|
|
4019
|
-
},
|
|
3949
|
+
url: ':memory:',
|
|
4020
3950
|
}),
|
|
4021
3951
|
workflows: {
|
|
4022
3952
|
'test-workflow': counterWorkflow,
|
|
@@ -4173,9 +4103,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
4173
4103
|
|
|
4174
4104
|
const mastra = new Mastra({
|
|
4175
4105
|
storage: new DefaultStorage({
|
|
4176
|
-
|
|
4177
|
-
url: ':memory:',
|
|
4178
|
-
},
|
|
4106
|
+
url: ':memory:',
|
|
4179
4107
|
}),
|
|
4180
4108
|
workflows: {
|
|
4181
4109
|
'test-workflow': counterWorkflow,
|
|
@@ -4334,9 +4262,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
4334
4262
|
|
|
4335
4263
|
const mastra = new Mastra({
|
|
4336
4264
|
storage: new DefaultStorage({
|
|
4337
|
-
|
|
4338
|
-
url: ':memory:',
|
|
4339
|
-
},
|
|
4265
|
+
url: ':memory:',
|
|
4340
4266
|
}),
|
|
4341
4267
|
workflows: {
|
|
4342
4268
|
'test-workflow': counterWorkflow,
|
|
@@ -4533,9 +4459,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
4533
4459
|
|
|
4534
4460
|
const mastra = new Mastra({
|
|
4535
4461
|
storage: new DefaultStorage({
|
|
4536
|
-
|
|
4537
|
-
url: ':memory:',
|
|
4538
|
-
},
|
|
4462
|
+
url: ':memory:',
|
|
4539
4463
|
}),
|
|
4540
4464
|
workflows: {
|
|
4541
4465
|
'test-workflow': counterWorkflow,
|
|
@@ -4691,9 +4615,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
4691
4615
|
|
|
4692
4616
|
const mastra = new Mastra({
|
|
4693
4617
|
storage: new DefaultStorage({
|
|
4694
|
-
|
|
4695
|
-
url: ':memory:',
|
|
4696
|
-
},
|
|
4618
|
+
url: ':memory:',
|
|
4697
4619
|
}),
|
|
4698
4620
|
workflows: {
|
|
4699
4621
|
'test-workflow': counterWorkflow,
|
|
@@ -4841,9 +4763,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
4841
4763
|
|
|
4842
4764
|
const mastra = new Mastra({
|
|
4843
4765
|
storage: new DefaultStorage({
|
|
4844
|
-
|
|
4845
|
-
url: ':memory:',
|
|
4846
|
-
},
|
|
4766
|
+
url: ':memory:',
|
|
4847
4767
|
}),
|
|
4848
4768
|
workflows: {
|
|
4849
4769
|
'test-workflow': counterWorkflow,
|
|
@@ -5028,9 +4948,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
5028
4948
|
|
|
5029
4949
|
const mastra = new Mastra({
|
|
5030
4950
|
storage: new DefaultStorage({
|
|
5031
|
-
|
|
5032
|
-
url: ':memory:',
|
|
5033
|
-
},
|
|
4951
|
+
url: ':memory:',
|
|
5034
4952
|
}),
|
|
5035
4953
|
workflows: {
|
|
5036
4954
|
'test-workflow': counterWorkflow,
|
|
@@ -5187,9 +5105,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
5187
5105
|
|
|
5188
5106
|
const mastra = new Mastra({
|
|
5189
5107
|
storage: new DefaultStorage({
|
|
5190
|
-
|
|
5191
|
-
url: ':memory:',
|
|
5192
|
-
},
|
|
5108
|
+
url: ':memory:',
|
|
5193
5109
|
}),
|
|
5194
5110
|
workflows: {
|
|
5195
5111
|
'test-workflow': counterWorkflow,
|
|
@@ -5264,9 +5180,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
5264
5180
|
|
|
5265
5181
|
const mastra = new Mastra({
|
|
5266
5182
|
storage: new DefaultStorage({
|
|
5267
|
-
|
|
5268
|
-
url: ':memory:',
|
|
5269
|
-
},
|
|
5183
|
+
url: ':memory:',
|
|
5270
5184
|
}),
|
|
5271
5185
|
workflows: {
|
|
5272
5186
|
'test-workflow': workflow,
|
|
@@ -5329,9 +5243,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
5329
5243
|
|
|
5330
5244
|
const mastra = new Mastra({
|
|
5331
5245
|
storage: new DefaultStorage({
|
|
5332
|
-
|
|
5333
|
-
url: ':memory:',
|
|
5334
|
-
},
|
|
5246
|
+
url: ':memory:',
|
|
5335
5247
|
}),
|
|
5336
5248
|
workflows: {
|
|
5337
5249
|
'test-workflow': workflow,
|
|
@@ -5372,9 +5284,7 @@ describe('MastraInngestWorkflow', () => {
|
|
|
5372
5284
|
const { createWorkflow, createStep } = init(inngest);
|
|
5373
5285
|
|
|
5374
5286
|
const initialStorage = new DefaultStorage({
|
|
5375
|
-
|
|
5376
|
-
url: 'file::memory:',
|
|
5377
|
-
},
|
|
5287
|
+
url: 'file::memory:',
|
|
5378
5288
|
});
|
|
5379
5289
|
|
|
5380
5290
|
const runtimeContext = new RuntimeContext();
|
|
@@ -5427,4 +5337,6 @@ describe('MastraInngestWorkflow', () => {
|
|
|
5427
5337
|
expect(result?.steps.step1.output.injectedValue).toBe(testValue + '2');
|
|
5428
5338
|
});
|
|
5429
5339
|
});
|
|
5340
|
+
|
|
5341
|
+
describe('Access to inngest step primitives', () => {});
|
|
5430
5342
|
}, 40e3);
|
package/src/index.ts
CHANGED
|
@@ -14,6 +14,7 @@ import type {
|
|
|
14
14
|
StepResult,
|
|
15
15
|
WorkflowResult,
|
|
16
16
|
SerializedStepFlowEntry,
|
|
17
|
+
StepFailure,
|
|
17
18
|
} from '@mastra/core/workflows';
|
|
18
19
|
import { EMITTER_SYMBOL } from '@mastra/core/workflows/_constants';
|
|
19
20
|
import type { Span } from '@opentelemetry/api';
|
|
@@ -21,6 +22,10 @@ import type { Inngest, BaseContext } from 'inngest';
|
|
|
21
22
|
import { serve as inngestServe } from 'inngest/hono';
|
|
22
23
|
import type { z } from 'zod';
|
|
23
24
|
|
|
25
|
+
export type InngestEngineType = {
|
|
26
|
+
step: any;
|
|
27
|
+
};
|
|
28
|
+
|
|
24
29
|
export function serve({ mastra, inngest }: { mastra: Mastra; inngest: Inngest }): ReturnType<typeof inngestServe> {
|
|
25
30
|
const wfs = mastra.getWorkflows();
|
|
26
31
|
const functions = Object.values(wfs).flatMap(wf => {
|
|
@@ -106,6 +111,7 @@ export class InngestRun<
|
|
|
106
111
|
activePaths: [],
|
|
107
112
|
suspendedPaths: {},
|
|
108
113
|
timestamp: Date.now(),
|
|
114
|
+
status: 'running',
|
|
109
115
|
},
|
|
110
116
|
});
|
|
111
117
|
|
|
@@ -206,7 +212,7 @@ export class InngestWorkflow<
|
|
|
206
212
|
TInput extends z.ZodType<any> = z.ZodType<any>,
|
|
207
213
|
TOutput extends z.ZodType<any> = z.ZodType<any>,
|
|
208
214
|
TPrevSchema extends z.ZodType<any> = TInput,
|
|
209
|
-
> extends Workflow<TSteps, TWorkflowId, TInput, TOutput, TPrevSchema> {
|
|
215
|
+
> extends Workflow<TSteps, TWorkflowId, TInput, TOutput, InngestEngineType, TPrevSchema> {
|
|
210
216
|
#mastra: Mastra;
|
|
211
217
|
public inngest: Inngest;
|
|
212
218
|
|
|
@@ -404,7 +410,28 @@ export function init(inngest: Inngest) {
|
|
|
404
410
|
>(params: WorkflowConfig<TWorkflowId, TInput, TOutput, TSteps>) {
|
|
405
411
|
return new InngestWorkflow(params, inngest);
|
|
406
412
|
},
|
|
407
|
-
createStep
|
|
413
|
+
createStep<
|
|
414
|
+
TStepId extends string,
|
|
415
|
+
TStepInput extends z.ZodType<any>,
|
|
416
|
+
TStepOutput extends z.ZodType<any>,
|
|
417
|
+
TResumeSchema extends z.ZodType<any>,
|
|
418
|
+
TSuspendSchema extends z.ZodType<any>,
|
|
419
|
+
>(params: {
|
|
420
|
+
id: TStepId;
|
|
421
|
+
inputSchema: TStepInput;
|
|
422
|
+
outputSchema: TStepOutput;
|
|
423
|
+
resumeSchema?: TResumeSchema;
|
|
424
|
+
suspendSchema?: TSuspendSchema;
|
|
425
|
+
execute: ExecuteFunction<
|
|
426
|
+
z.infer<TStepInput>,
|
|
427
|
+
z.infer<TStepOutput>,
|
|
428
|
+
z.infer<TResumeSchema>,
|
|
429
|
+
z.infer<TSuspendSchema>,
|
|
430
|
+
InngestEngineType
|
|
431
|
+
>;
|
|
432
|
+
}) {
|
|
433
|
+
return createStep<TStepId, TStepInput, TStepOutput, TResumeSchema, TSuspendSchema, InngestEngineType>(params);
|
|
434
|
+
},
|
|
408
435
|
cloneStep,
|
|
409
436
|
cloneWorkflow,
|
|
410
437
|
};
|
|
@@ -771,7 +798,10 @@ export class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
771
798
|
// @ts-ignore
|
|
772
799
|
runId: stepResults[step.id]?.payload?.__workflow_meta?.runId,
|
|
773
800
|
},
|
|
774
|
-
emitter,
|
|
801
|
+
[EMITTER_SYMBOL]: emitter,
|
|
802
|
+
engine: {
|
|
803
|
+
step: this.inngestStep,
|
|
804
|
+
},
|
|
775
805
|
});
|
|
776
806
|
|
|
777
807
|
execResults = { status: 'success', output: result };
|
|
@@ -825,12 +855,18 @@ export class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
825
855
|
stepResults,
|
|
826
856
|
executionContext,
|
|
827
857
|
serializedStepGraph,
|
|
858
|
+
workflowStatus,
|
|
859
|
+
result,
|
|
860
|
+
error,
|
|
828
861
|
}: {
|
|
829
862
|
workflowId: string;
|
|
830
863
|
runId: string;
|
|
831
864
|
stepResults: Record<string, StepResult<any, any, any, any>>;
|
|
832
865
|
serializedStepGraph: SerializedStepFlowEntry[];
|
|
833
866
|
executionContext: ExecutionContext;
|
|
867
|
+
workflowStatus: 'success' | 'failed' | 'suspended' | 'running';
|
|
868
|
+
result?: Record<string, any>;
|
|
869
|
+
error?: string | Error;
|
|
834
870
|
}) {
|
|
835
871
|
await this.inngestStep.run(
|
|
836
872
|
`workflow.${workflowId}.run.${runId}.path.${JSON.stringify(executionContext.executionPath)}.stepUpdate`,
|
|
@@ -845,6 +881,9 @@ export class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
845
881
|
activePaths: [],
|
|
846
882
|
suspendedPaths: executionContext.suspendedPaths,
|
|
847
883
|
serializedStepGraph,
|
|
884
|
+
status: workflowStatus,
|
|
885
|
+
result,
|
|
886
|
+
error,
|
|
848
887
|
// @ts-ignore
|
|
849
888
|
timestamp: Date.now(),
|
|
850
889
|
},
|
|
@@ -868,7 +907,11 @@ export class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
868
907
|
}: {
|
|
869
908
|
workflowId: string;
|
|
870
909
|
runId: string;
|
|
871
|
-
entry: {
|
|
910
|
+
entry: {
|
|
911
|
+
type: 'conditional';
|
|
912
|
+
steps: StepFlowEntry[];
|
|
913
|
+
conditions: ExecuteFunction<any, any, any, any, InngestEngineType>[];
|
|
914
|
+
};
|
|
872
915
|
prevStep: StepFlowEntry;
|
|
873
916
|
serializedStepGraph: SerializedStepFlowEntry[];
|
|
874
917
|
prevOutput: any;
|
|
@@ -911,6 +954,9 @@ export class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
911
954
|
// TODO: this function shouldn't have suspend probably?
|
|
912
955
|
suspend: async (_suspendPayload: any) => {},
|
|
913
956
|
[EMITTER_SYMBOL]: emitter,
|
|
957
|
+
engine: {
|
|
958
|
+
step: this.inngestStep,
|
|
959
|
+
},
|
|
914
960
|
});
|
|
915
961
|
return result ? index : null;
|
|
916
962
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -923,7 +969,7 @@ export class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
923
969
|
).filter((index: any): index is number => index !== null);
|
|
924
970
|
|
|
925
971
|
const stepsToRun = entry.steps.filter((_, index) => truthyIndexes.includes(index));
|
|
926
|
-
const results: StepResult<any, any, any, any>[] = await Promise.all(
|
|
972
|
+
const results: { result: StepResult<any, any, any, any> }[] = await Promise.all(
|
|
927
973
|
stepsToRun.map((step, index) =>
|
|
928
974
|
this.executeEntry({
|
|
929
975
|
workflowId,
|
|
@@ -946,17 +992,19 @@ export class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
946
992
|
}),
|
|
947
993
|
),
|
|
948
994
|
);
|
|
949
|
-
const hasFailed = results.find(result => result.status === 'failed')
|
|
950
|
-
|
|
995
|
+
const hasFailed = results.find(result => result.result.status === 'failed') as {
|
|
996
|
+
result: StepFailure<any, any, any>;
|
|
997
|
+
};
|
|
998
|
+
const hasSuspended = results.find(result => result.result.status === 'suspended');
|
|
951
999
|
if (hasFailed) {
|
|
952
|
-
execResults = { status: 'failed', error: hasFailed.error };
|
|
1000
|
+
execResults = { status: 'failed', error: hasFailed.result.error };
|
|
953
1001
|
} else if (hasSuspended) {
|
|
954
|
-
execResults = { status: 'suspended', payload: hasSuspended.payload };
|
|
1002
|
+
execResults = { status: 'suspended', payload: hasSuspended.result.payload };
|
|
955
1003
|
} else {
|
|
956
1004
|
execResults = {
|
|
957
1005
|
status: 'success',
|
|
958
1006
|
output: results.reduce((acc: Record<string, any>, result, index) => {
|
|
959
|
-
if (result.status === 'success') {
|
|
1007
|
+
if (result.result.status === 'success') {
|
|
960
1008
|
// @ts-ignore
|
|
961
1009
|
acc[stepsToRun[index]!.step.id] = result.output;
|
|
962
1010
|
}
|