@mastra/inngest 0.0.0-vnextAgentNetwork-20250602084555 → 0.0.0-workflow-deno-20250616115451
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 +163 -2
- package/dist/_tsup-dts-rollup.d.cts +56 -15
- package/dist/_tsup-dts-rollup.d.ts +56 -15
- package/dist/index.cjs +179 -29
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +179 -30
- package/package.json +18 -17
- package/src/index.test.ts +280 -195
- package/src/index.ts +322 -42
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,157 @@
|
|
|
1
1
|
# @mastra/inngest
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
3
|
+
## 0.0.0-workflow-deno-20250616115451
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 3ca9a67: Make createRun async to support storage
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 63f6b7d: dependencies updates:
|
|
12
|
+
- Updated dependency [`inngest@^3.39.1` ↗︎](https://www.npmjs.com/package/inngest/v/3.39.1) (from `^3.35.1`, in `dependencies`)
|
|
13
|
+
- Updated dependency [`zod@^3.25.57` ↗︎](https://www.npmjs.com/package/zod/v/3.25.57) (from `^3.25.56`, in `dependencies`)
|
|
14
|
+
- ee9af57: Add api for polling run execution result and get run by id
|
|
15
|
+
- Updated dependencies [63f6b7d]
|
|
16
|
+
- Updated dependencies [ee9af57]
|
|
17
|
+
- Updated dependencies [36f1c36]
|
|
18
|
+
- Updated dependencies [10d352e]
|
|
19
|
+
- Updated dependencies [3ca9a67]
|
|
20
|
+
- Updated dependencies [53d3c37]
|
|
21
|
+
- Updated dependencies [577ce3a]
|
|
22
|
+
- Updated dependencies [9260b3a]
|
|
23
|
+
- @mastra/core@0.0.0-workflow-deno-20250616115451
|
|
24
|
+
|
|
25
|
+
## 0.10.5-alpha.0
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- 63f6b7d: dependencies updates:
|
|
30
|
+
- Updated dependency [`inngest@^3.39.1` ↗︎](https://www.npmjs.com/package/inngest/v/3.39.1) (from `^3.35.1`, in `dependencies`)
|
|
31
|
+
- Updated dependency [`zod@^3.25.57` ↗︎](https://www.npmjs.com/package/zod/v/3.25.57) (from `^3.25.56`, in `dependencies`)
|
|
32
|
+
- Updated dependencies [63f6b7d]
|
|
33
|
+
- Updated dependencies [36f1c36]
|
|
34
|
+
- Updated dependencies [10d352e]
|
|
35
|
+
- Updated dependencies [53d3c37]
|
|
36
|
+
- @mastra/core@0.10.6-alpha.0
|
|
37
|
+
|
|
38
|
+
## 0.10.4
|
|
39
|
+
|
|
40
|
+
### Patch Changes
|
|
41
|
+
|
|
42
|
+
- 13c97f9: Save run status, result and error in storage snapshot
|
|
43
|
+
- Updated dependencies [13c97f9]
|
|
44
|
+
- @mastra/core@0.10.5
|
|
45
|
+
|
|
46
|
+
## 0.10.3
|
|
47
|
+
|
|
48
|
+
### Patch Changes
|
|
49
|
+
|
|
50
|
+
- 1ccccff: dependencies updates:
|
|
51
|
+
- Updated dependency [`zod@^3.25.56` ↗︎](https://www.npmjs.com/package/zod/v/3.25.56) (from `^3.24.2`, in `dependencies`)
|
|
52
|
+
- 1ccccff: dependencies updates:
|
|
53
|
+
- Updated dependency [`zod@^3.25.56` ↗︎](https://www.npmjs.com/package/zod/v/3.25.56) (from `^3.24.2`, in `dependencies`)
|
|
54
|
+
- Updated dependencies [d1ed912]
|
|
55
|
+
- Updated dependencies [f6fd25f]
|
|
56
|
+
- Updated dependencies [dffb67b]
|
|
57
|
+
- Updated dependencies [f1f1f1b]
|
|
58
|
+
- Updated dependencies [925ab94]
|
|
59
|
+
- Updated dependencies [f9816ae]
|
|
60
|
+
- Updated dependencies [82090c1]
|
|
61
|
+
- Updated dependencies [1b443fd]
|
|
62
|
+
- Updated dependencies [ce97900]
|
|
63
|
+
- Updated dependencies [f1309d3]
|
|
64
|
+
- Updated dependencies [14a2566]
|
|
65
|
+
- Updated dependencies [f7f8293]
|
|
66
|
+
- Updated dependencies [48eddb9]
|
|
67
|
+
- @mastra/core@0.10.4
|
|
68
|
+
|
|
69
|
+
## 0.10.3-alpha.0
|
|
70
|
+
|
|
71
|
+
### Patch Changes
|
|
72
|
+
|
|
73
|
+
- 1ccccff: dependencies updates:
|
|
74
|
+
- Updated dependency [`zod@^3.25.56` ↗︎](https://www.npmjs.com/package/zod/v/3.25.56) (from `^3.24.2`, in `dependencies`)
|
|
75
|
+
- 1ccccff: dependencies updates:
|
|
76
|
+
- Updated dependency [`zod@^3.25.56` ↗︎](https://www.npmjs.com/package/zod/v/3.25.56) (from `^3.24.2`, in `dependencies`)
|
|
77
|
+
- Updated dependencies [f6fd25f]
|
|
78
|
+
- Updated dependencies [dffb67b]
|
|
79
|
+
- Updated dependencies [f1309d3]
|
|
80
|
+
- Updated dependencies [f7f8293]
|
|
81
|
+
- @mastra/core@0.10.4-alpha.1
|
|
82
|
+
|
|
83
|
+
## 0.10.2
|
|
84
|
+
|
|
85
|
+
### Patch Changes
|
|
86
|
+
|
|
87
|
+
- 195c428: Add runId to step execute fn
|
|
88
|
+
- 12b7002: Add serializedStepGraph to workflow run snapshot in storage
|
|
89
|
+
- f0d559f: Fix peerdeps for alpha channel
|
|
90
|
+
- 1ee6894: inngest production url fix
|
|
91
|
+
- Updated dependencies [ee77e78]
|
|
92
|
+
- Updated dependencies [592a2db]
|
|
93
|
+
- Updated dependencies [e5dc18d]
|
|
94
|
+
- Updated dependencies [ab5adbe]
|
|
95
|
+
- Updated dependencies [1e8bb40]
|
|
96
|
+
- Updated dependencies [1b5fc55]
|
|
97
|
+
- Updated dependencies [195c428]
|
|
98
|
+
- Updated dependencies [f73e11b]
|
|
99
|
+
- Updated dependencies [37643b8]
|
|
100
|
+
- Updated dependencies [99fd6cf]
|
|
101
|
+
- Updated dependencies [c5bf1ce]
|
|
102
|
+
- Updated dependencies [add596e]
|
|
103
|
+
- Updated dependencies [8dc94d8]
|
|
104
|
+
- Updated dependencies [ecebbeb]
|
|
105
|
+
- Updated dependencies [79d5145]
|
|
106
|
+
- Updated dependencies [12b7002]
|
|
107
|
+
- Updated dependencies [2901125]
|
|
108
|
+
- @mastra/core@0.10.2
|
|
109
|
+
|
|
110
|
+
## 0.10.2-alpha.3
|
|
111
|
+
|
|
112
|
+
### Patch Changes
|
|
113
|
+
|
|
114
|
+
- 1ee6894: inngest production url fix
|
|
115
|
+
- Updated dependencies [1b5fc55]
|
|
116
|
+
- Updated dependencies [add596e]
|
|
117
|
+
- Updated dependencies [ecebbeb]
|
|
118
|
+
- @mastra/core@0.10.2-alpha.5
|
|
119
|
+
|
|
120
|
+
## 0.10.2-alpha.2
|
|
121
|
+
|
|
122
|
+
### Patch Changes
|
|
123
|
+
|
|
124
|
+
- 12b7002: Add serializedStepGraph to workflow run snapshot in storage
|
|
125
|
+
- Updated dependencies [c5bf1ce]
|
|
126
|
+
- Updated dependencies [12b7002]
|
|
127
|
+
- @mastra/core@0.10.2-alpha.4
|
|
128
|
+
|
|
129
|
+
## 0.10.2-alpha.1
|
|
130
|
+
|
|
131
|
+
### Patch Changes
|
|
132
|
+
|
|
133
|
+
- 195c428: Add runId to step execute fn
|
|
134
|
+
- Updated dependencies [ab5adbe]
|
|
135
|
+
- Updated dependencies [195c428]
|
|
136
|
+
- Updated dependencies [f73e11b]
|
|
137
|
+
- @mastra/core@0.10.2-alpha.3
|
|
138
|
+
|
|
139
|
+
## 0.10.2-alpha.0
|
|
140
|
+
|
|
141
|
+
### Patch Changes
|
|
142
|
+
|
|
143
|
+
- f0d559f: Fix peerdeps for alpha channel
|
|
144
|
+
- Updated dependencies [1e8bb40]
|
|
145
|
+
- @mastra/core@0.10.2-alpha.2
|
|
146
|
+
|
|
147
|
+
## 0.10.1
|
|
4
148
|
|
|
5
149
|
### Patch Changes
|
|
6
150
|
|
|
7
151
|
- 200d0da: Return payload data, start time, end time, resume time and suspend time for each step in workflow state
|
|
8
152
|
Return error stack for failed workflow runs
|
|
9
153
|
- 5343f93: Move emitter to symbol to make private
|
|
154
|
+
- Updated dependencies [d70b807]
|
|
10
155
|
- Updated dependencies [6d16390]
|
|
11
156
|
- Updated dependencies [1e4a421]
|
|
12
157
|
- Updated dependencies [200d0da]
|
|
@@ -15,7 +160,23 @@
|
|
|
15
160
|
- Updated dependencies [38aee50]
|
|
16
161
|
- Updated dependencies [5c41100]
|
|
17
162
|
- Updated dependencies [d6a759b]
|
|
18
|
-
|
|
163
|
+
- Updated dependencies [6015bdf]
|
|
164
|
+
- @mastra/core@0.10.1
|
|
165
|
+
|
|
166
|
+
## 0.10.1-alpha.0
|
|
167
|
+
|
|
168
|
+
### Patch Changes
|
|
169
|
+
|
|
170
|
+
- 200d0da: Return payload data, start time, end time, resume time and suspend time for each step in workflow state
|
|
171
|
+
Return error stack for failed workflow runs
|
|
172
|
+
- 5343f93: Move emitter to symbol to make private
|
|
173
|
+
- Updated dependencies [200d0da]
|
|
174
|
+
- Updated dependencies [bf5f17b]
|
|
175
|
+
- Updated dependencies [5343f93]
|
|
176
|
+
- Updated dependencies [38aee50]
|
|
177
|
+
- Updated dependencies [5c41100]
|
|
178
|
+
- Updated dependencies [d6a759b]
|
|
179
|
+
- @mastra/core@0.10.1-alpha.1
|
|
19
180
|
|
|
20
181
|
## 0.10.0
|
|
21
182
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import { Agent } from '@mastra/core';
|
|
1
2
|
import type { BaseContext } from 'inngest';
|
|
2
3
|
import { ClientOptions } from 'inngest';
|
|
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';
|
|
@@ -14,27 +13,57 @@ import { InngestMiddleware } from 'inngest';
|
|
|
14
13
|
import type { Mastra } from '@mastra/core';
|
|
15
14
|
import { Run } from '@mastra/core/workflows';
|
|
16
15
|
import { RuntimeContext } from '@mastra/core/di';
|
|
16
|
+
import type { SerializedStepFlowEntry } from '@mastra/core/workflows';
|
|
17
17
|
import { serve as serve_2 } from 'inngest/hono';
|
|
18
18
|
import type { Span } from '@opentelemetry/api';
|
|
19
19
|
import type { Step } from '@mastra/core/workflows';
|
|
20
20
|
import type { StepFlowEntry } from '@mastra/core/workflows';
|
|
21
21
|
import type { StepResult } from '@mastra/core/workflows';
|
|
22
|
+
import { Tool } from '@mastra/core';
|
|
23
|
+
import type { ToolExecutionContext } from '@mastra/core';
|
|
24
|
+
import type { WatchEvent } from '@mastra/core/workflows';
|
|
22
25
|
import { Workflow } from '@mastra/core/workflows';
|
|
23
26
|
import type { WorkflowConfig } from '@mastra/core/workflows';
|
|
24
27
|
import type { WorkflowResult } from '@mastra/core/workflows';
|
|
25
28
|
import type { WorkflowRun } from '@mastra/core';
|
|
26
29
|
import type { WorkflowRuns } from '@mastra/core';
|
|
27
|
-
import
|
|
30
|
+
import { z } from 'zod';
|
|
28
31
|
|
|
29
|
-
declare function
|
|
30
|
-
id:
|
|
31
|
-
|
|
32
|
+
export declare function 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: {
|
|
33
|
+
id: TStepId;
|
|
34
|
+
description?: string;
|
|
35
|
+
inputSchema: TStepInput;
|
|
36
|
+
outputSchema: TStepOutput;
|
|
37
|
+
resumeSchema?: TResumeSchema;
|
|
38
|
+
suspendSchema?: TSuspendSchema;
|
|
39
|
+
execute: ExecuteFunction<z.infer<TStepInput>, z.infer<TStepOutput>, z.infer<TResumeSchema>, z.infer<TSuspendSchema>, InngestEngineType>;
|
|
40
|
+
}): Step<TStepId, TStepInput, TStepOutput, TResumeSchema, TSuspendSchema, InngestEngineType>;
|
|
41
|
+
|
|
42
|
+
export declare function createStep<TStepId extends string, TStepInput extends z.ZodObject<{
|
|
43
|
+
prompt: z.ZodString;
|
|
44
|
+
}>, TStepOutput extends z.ZodObject<{
|
|
45
|
+
text: z.ZodString;
|
|
46
|
+
}>, TResumeSchema extends z.ZodType<any>, TSuspendSchema extends z.ZodType<any>>(agent: Agent<TStepId, any, any>): Step<TStepId, TStepInput, TStepOutput, TResumeSchema, TSuspendSchema, InngestEngineType>;
|
|
47
|
+
|
|
48
|
+
export declare function createStep<TSchemaIn extends z.ZodType<any>, TSchemaOut extends z.ZodType<any>, TContext extends ToolExecutionContext<TSchemaIn>>(tool: Tool<TSchemaIn, TSchemaOut, TContext> & {
|
|
49
|
+
inputSchema: TSchemaIn;
|
|
50
|
+
outputSchema: TSchemaOut;
|
|
51
|
+
execute: (context: TContext) => Promise<any>;
|
|
52
|
+
}): Step<string, TSchemaIn, TSchemaOut, z.ZodType<any>, z.ZodType<any>, InngestEngineType>;
|
|
32
53
|
|
|
33
54
|
export declare function init(inngest: Inngest): {
|
|
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,
|
|
55
|
+
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, any, any, InngestEngineType>[] = Step<string, any, any, any, any, InngestEngineType>[]>(params: WorkflowConfig<TWorkflowId, TInput, TOutput, TSteps>): InngestWorkflow<InngestEngineType, TSteps, TWorkflowId, TInput, TOutput, TInput>;
|
|
35
56
|
createStep: typeof createStep;
|
|
36
|
-
cloneStep:
|
|
37
|
-
|
|
57
|
+
cloneStep<TStepId extends string>(step: Step<string, any, any, any, any, InngestEngineType>, opts: {
|
|
58
|
+
id: TStepId;
|
|
59
|
+
}): Step<TStepId, any, any, any, any, InngestEngineType>;
|
|
60
|
+
cloneWorkflow<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, any, any, InngestEngineType>[] = Step<string, any, any, any, any, InngestEngineType>[]>(workflow: Workflow<InngestEngineType, TSteps, string, TInput, TOutput, TInput>, opts: {
|
|
61
|
+
id: TWorkflowId;
|
|
62
|
+
}): Workflow<InngestEngineType, TSteps, TWorkflowId, TInput, TOutput, TInput>;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export declare type InngestEngineType = {
|
|
66
|
+
step: any;
|
|
38
67
|
};
|
|
39
68
|
|
|
40
69
|
export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
@@ -60,6 +89,10 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
60
89
|
};
|
|
61
90
|
runtimeContext: RuntimeContext;
|
|
62
91
|
}): Promise<StepResult<any, any, any, any>>;
|
|
92
|
+
executeSleep({ id, duration }: {
|
|
93
|
+
id: string;
|
|
94
|
+
duration: number;
|
|
95
|
+
}): Promise<void>;
|
|
63
96
|
executeStep({ step, stepResults, executionContext, resume, prevOutput, emitter, runtimeContext, }: {
|
|
64
97
|
step: Step<string, any, any>;
|
|
65
98
|
stepResults: Record<string, StepResult<any, any, any, any>>;
|
|
@@ -84,21 +117,26 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
84
117
|
};
|
|
85
118
|
runtimeContext: RuntimeContext;
|
|
86
119
|
}): Promise<StepResult<any, any, any, any>>;
|
|
87
|
-
persistStepUpdate({ workflowId, runId, stepResults, executionContext, }: {
|
|
120
|
+
persistStepUpdate({ workflowId, runId, stepResults, executionContext, serializedStepGraph, workflowStatus, result, error, }: {
|
|
88
121
|
workflowId: string;
|
|
89
122
|
runId: string;
|
|
90
123
|
stepResults: Record<string, StepResult<any, any, any, any>>;
|
|
124
|
+
serializedStepGraph: SerializedStepFlowEntry[];
|
|
91
125
|
executionContext: ExecutionContext;
|
|
126
|
+
workflowStatus: 'success' | 'failed' | 'suspended' | 'running';
|
|
127
|
+
result?: Record<string, any>;
|
|
128
|
+
error?: string | Error;
|
|
92
129
|
}): Promise<void>;
|
|
93
|
-
executeConditional({ workflowId, runId, entry, prevOutput, prevStep, stepResults, resume, executionContext, emitter, runtimeContext, }: {
|
|
130
|
+
executeConditional({ workflowId, runId, entry, prevOutput, prevStep, stepResults, serializedStepGraph, resume, executionContext, emitter, runtimeContext, }: {
|
|
94
131
|
workflowId: string;
|
|
95
132
|
runId: string;
|
|
96
133
|
entry: {
|
|
97
134
|
type: 'conditional';
|
|
98
135
|
steps: StepFlowEntry[];
|
|
99
|
-
conditions: ExecuteFunction<any, any, any, any>[];
|
|
136
|
+
conditions: ExecuteFunction<any, any, any, any, InngestEngineType>[];
|
|
100
137
|
};
|
|
101
138
|
prevStep: StepFlowEntry;
|
|
139
|
+
serializedStepGraph: SerializedStepFlowEntry[];
|
|
102
140
|
prevOutput: any;
|
|
103
141
|
stepResults: Record<string, StepResult<any, any, any, any>>;
|
|
104
142
|
resume?: {
|
|
@@ -115,14 +153,16 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
115
153
|
}): Promise<StepResult<any, any, any, any>>;
|
|
116
154
|
}
|
|
117
155
|
|
|
118
|
-
export declare class InngestRun<TSteps extends Step<string, any, any>[] = Step<string, any, any>[], TInput extends z.ZodType<any> = z.ZodType<any>, TOutput extends z.ZodType<any> = z.ZodType<any>> extends Run<TSteps, TInput, TOutput> {
|
|
156
|
+
export declare class InngestRun<TEngineType = InngestEngineType, TSteps extends Step<string, any, any>[] = Step<string, any, any>[], TInput extends z.ZodType<any> = z.ZodType<any>, TOutput extends z.ZodType<any> = z.ZodType<any>> extends Run<TEngineType, TSteps, TInput, TOutput> {
|
|
119
157
|
#private;
|
|
120
158
|
private inngest;
|
|
159
|
+
serializedStepGraph: SerializedStepFlowEntry[];
|
|
121
160
|
constructor(params: {
|
|
122
161
|
workflowId: string;
|
|
123
162
|
runId: string;
|
|
124
163
|
executionEngine: ExecutionEngine;
|
|
125
164
|
executionGraph: ExecutionGraph;
|
|
165
|
+
serializedStepGraph: SerializedStepFlowEntry[];
|
|
126
166
|
mastra?: Mastra;
|
|
127
167
|
retryConfig?: {
|
|
128
168
|
attempts?: number;
|
|
@@ -144,7 +184,7 @@ export declare class InngestRun<TSteps extends Step<string, any, any>[] = Step<s
|
|
|
144
184
|
watch(cb: (event: any) => void): () => void;
|
|
145
185
|
}
|
|
146
186
|
|
|
147
|
-
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> {
|
|
187
|
+
export declare class InngestWorkflow<TEngineType = InngestEngineType, 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<TEngineType, TSteps, TWorkflowId, TInput, TOutput, TPrevSchema> {
|
|
148
188
|
#private;
|
|
149
189
|
inngest: Inngest;
|
|
150
190
|
private function;
|
|
@@ -157,10 +197,11 @@ export declare class InngestWorkflow<TSteps extends Step<string, any, any>[] = S
|
|
|
157
197
|
resourceId?: string;
|
|
158
198
|
}): Promise<WorkflowRuns>;
|
|
159
199
|
getWorkflowRunById(runId: string): Promise<WorkflowRun | null>;
|
|
200
|
+
getWorkflowRunExecutionResult(runId: string): Promise<WatchEvent['payload']['workflowState'] | null>;
|
|
160
201
|
__registerMastra(mastra: Mastra): void;
|
|
161
202
|
createRun(options?: {
|
|
162
203
|
runId?: string;
|
|
163
|
-
}): Run<TSteps, TInput, TOutput
|
|
204
|
+
}): Promise<Run<TEngineType, TSteps, TInput, TOutput>>;
|
|
164
205
|
getFunction(): InngestFunction<Omit<InngestFunction.Options<Inngest<ClientOptions>, InngestMiddleware.Stack, InngestFunction.Trigger<string>[] | [{
|
|
165
206
|
cron: string;
|
|
166
207
|
} & Partial<Record<"event" | "if", never>>] | [{
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import { Agent } from '@mastra/core';
|
|
1
2
|
import type { BaseContext } from 'inngest';
|
|
2
3
|
import { ClientOptions } from 'inngest';
|
|
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';
|
|
@@ -14,27 +13,57 @@ import { InngestMiddleware } from 'inngest';
|
|
|
14
13
|
import type { Mastra } from '@mastra/core';
|
|
15
14
|
import { Run } from '@mastra/core/workflows';
|
|
16
15
|
import { RuntimeContext } from '@mastra/core/di';
|
|
16
|
+
import type { SerializedStepFlowEntry } from '@mastra/core/workflows';
|
|
17
17
|
import { serve as serve_2 } from 'inngest/hono';
|
|
18
18
|
import type { Span } from '@opentelemetry/api';
|
|
19
19
|
import type { Step } from '@mastra/core/workflows';
|
|
20
20
|
import type { StepFlowEntry } from '@mastra/core/workflows';
|
|
21
21
|
import type { StepResult } from '@mastra/core/workflows';
|
|
22
|
+
import { Tool } from '@mastra/core';
|
|
23
|
+
import type { ToolExecutionContext } from '@mastra/core';
|
|
24
|
+
import type { WatchEvent } from '@mastra/core/workflows';
|
|
22
25
|
import { Workflow } from '@mastra/core/workflows';
|
|
23
26
|
import type { WorkflowConfig } from '@mastra/core/workflows';
|
|
24
27
|
import type { WorkflowResult } from '@mastra/core/workflows';
|
|
25
28
|
import type { WorkflowRun } from '@mastra/core';
|
|
26
29
|
import type { WorkflowRuns } from '@mastra/core';
|
|
27
|
-
import
|
|
30
|
+
import { z } from 'zod';
|
|
28
31
|
|
|
29
|
-
declare function
|
|
30
|
-
id:
|
|
31
|
-
|
|
32
|
+
export declare function 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: {
|
|
33
|
+
id: TStepId;
|
|
34
|
+
description?: string;
|
|
35
|
+
inputSchema: TStepInput;
|
|
36
|
+
outputSchema: TStepOutput;
|
|
37
|
+
resumeSchema?: TResumeSchema;
|
|
38
|
+
suspendSchema?: TSuspendSchema;
|
|
39
|
+
execute: ExecuteFunction<z.infer<TStepInput>, z.infer<TStepOutput>, z.infer<TResumeSchema>, z.infer<TSuspendSchema>, InngestEngineType>;
|
|
40
|
+
}): Step<TStepId, TStepInput, TStepOutput, TResumeSchema, TSuspendSchema, InngestEngineType>;
|
|
41
|
+
|
|
42
|
+
export declare function createStep<TStepId extends string, TStepInput extends z.ZodObject<{
|
|
43
|
+
prompt: z.ZodString;
|
|
44
|
+
}>, TStepOutput extends z.ZodObject<{
|
|
45
|
+
text: z.ZodString;
|
|
46
|
+
}>, TResumeSchema extends z.ZodType<any>, TSuspendSchema extends z.ZodType<any>>(agent: Agent<TStepId, any, any>): Step<TStepId, TStepInput, TStepOutput, TResumeSchema, TSuspendSchema, InngestEngineType>;
|
|
47
|
+
|
|
48
|
+
export declare function createStep<TSchemaIn extends z.ZodType<any>, TSchemaOut extends z.ZodType<any>, TContext extends ToolExecutionContext<TSchemaIn>>(tool: Tool<TSchemaIn, TSchemaOut, TContext> & {
|
|
49
|
+
inputSchema: TSchemaIn;
|
|
50
|
+
outputSchema: TSchemaOut;
|
|
51
|
+
execute: (context: TContext) => Promise<any>;
|
|
52
|
+
}): Step<string, TSchemaIn, TSchemaOut, z.ZodType<any>, z.ZodType<any>, InngestEngineType>;
|
|
32
53
|
|
|
33
54
|
export declare function init(inngest: Inngest): {
|
|
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,
|
|
55
|
+
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, any, any, InngestEngineType>[] = Step<string, any, any, any, any, InngestEngineType>[]>(params: WorkflowConfig<TWorkflowId, TInput, TOutput, TSteps>): InngestWorkflow<InngestEngineType, TSteps, TWorkflowId, TInput, TOutput, TInput>;
|
|
35
56
|
createStep: typeof createStep;
|
|
36
|
-
cloneStep:
|
|
37
|
-
|
|
57
|
+
cloneStep<TStepId extends string>(step: Step<string, any, any, any, any, InngestEngineType>, opts: {
|
|
58
|
+
id: TStepId;
|
|
59
|
+
}): Step<TStepId, any, any, any, any, InngestEngineType>;
|
|
60
|
+
cloneWorkflow<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, any, any, InngestEngineType>[] = Step<string, any, any, any, any, InngestEngineType>[]>(workflow: Workflow<InngestEngineType, TSteps, string, TInput, TOutput, TInput>, opts: {
|
|
61
|
+
id: TWorkflowId;
|
|
62
|
+
}): Workflow<InngestEngineType, TSteps, TWorkflowId, TInput, TOutput, TInput>;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export declare type InngestEngineType = {
|
|
66
|
+
step: any;
|
|
38
67
|
};
|
|
39
68
|
|
|
40
69
|
export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
@@ -60,6 +89,10 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
60
89
|
};
|
|
61
90
|
runtimeContext: RuntimeContext;
|
|
62
91
|
}): Promise<StepResult<any, any, any, any>>;
|
|
92
|
+
executeSleep({ id, duration }: {
|
|
93
|
+
id: string;
|
|
94
|
+
duration: number;
|
|
95
|
+
}): Promise<void>;
|
|
63
96
|
executeStep({ step, stepResults, executionContext, resume, prevOutput, emitter, runtimeContext, }: {
|
|
64
97
|
step: Step<string, any, any>;
|
|
65
98
|
stepResults: Record<string, StepResult<any, any, any, any>>;
|
|
@@ -84,21 +117,26 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
84
117
|
};
|
|
85
118
|
runtimeContext: RuntimeContext;
|
|
86
119
|
}): Promise<StepResult<any, any, any, any>>;
|
|
87
|
-
persistStepUpdate({ workflowId, runId, stepResults, executionContext, }: {
|
|
120
|
+
persistStepUpdate({ workflowId, runId, stepResults, executionContext, serializedStepGraph, workflowStatus, result, error, }: {
|
|
88
121
|
workflowId: string;
|
|
89
122
|
runId: string;
|
|
90
123
|
stepResults: Record<string, StepResult<any, any, any, any>>;
|
|
124
|
+
serializedStepGraph: SerializedStepFlowEntry[];
|
|
91
125
|
executionContext: ExecutionContext;
|
|
126
|
+
workflowStatus: 'success' | 'failed' | 'suspended' | 'running';
|
|
127
|
+
result?: Record<string, any>;
|
|
128
|
+
error?: string | Error;
|
|
92
129
|
}): Promise<void>;
|
|
93
|
-
executeConditional({ workflowId, runId, entry, prevOutput, prevStep, stepResults, resume, executionContext, emitter, runtimeContext, }: {
|
|
130
|
+
executeConditional({ workflowId, runId, entry, prevOutput, prevStep, stepResults, serializedStepGraph, resume, executionContext, emitter, runtimeContext, }: {
|
|
94
131
|
workflowId: string;
|
|
95
132
|
runId: string;
|
|
96
133
|
entry: {
|
|
97
134
|
type: 'conditional';
|
|
98
135
|
steps: StepFlowEntry[];
|
|
99
|
-
conditions: ExecuteFunction<any, any, any, any>[];
|
|
136
|
+
conditions: ExecuteFunction<any, any, any, any, InngestEngineType>[];
|
|
100
137
|
};
|
|
101
138
|
prevStep: StepFlowEntry;
|
|
139
|
+
serializedStepGraph: SerializedStepFlowEntry[];
|
|
102
140
|
prevOutput: any;
|
|
103
141
|
stepResults: Record<string, StepResult<any, any, any, any>>;
|
|
104
142
|
resume?: {
|
|
@@ -115,14 +153,16 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
115
153
|
}): Promise<StepResult<any, any, any, any>>;
|
|
116
154
|
}
|
|
117
155
|
|
|
118
|
-
export declare class InngestRun<TSteps extends Step<string, any, any>[] = Step<string, any, any>[], TInput extends z.ZodType<any> = z.ZodType<any>, TOutput extends z.ZodType<any> = z.ZodType<any>> extends Run<TSteps, TInput, TOutput> {
|
|
156
|
+
export declare class InngestRun<TEngineType = InngestEngineType, TSteps extends Step<string, any, any>[] = Step<string, any, any>[], TInput extends z.ZodType<any> = z.ZodType<any>, TOutput extends z.ZodType<any> = z.ZodType<any>> extends Run<TEngineType, TSteps, TInput, TOutput> {
|
|
119
157
|
#private;
|
|
120
158
|
private inngest;
|
|
159
|
+
serializedStepGraph: SerializedStepFlowEntry[];
|
|
121
160
|
constructor(params: {
|
|
122
161
|
workflowId: string;
|
|
123
162
|
runId: string;
|
|
124
163
|
executionEngine: ExecutionEngine;
|
|
125
164
|
executionGraph: ExecutionGraph;
|
|
165
|
+
serializedStepGraph: SerializedStepFlowEntry[];
|
|
126
166
|
mastra?: Mastra;
|
|
127
167
|
retryConfig?: {
|
|
128
168
|
attempts?: number;
|
|
@@ -144,7 +184,7 @@ export declare class InngestRun<TSteps extends Step<string, any, any>[] = Step<s
|
|
|
144
184
|
watch(cb: (event: any) => void): () => void;
|
|
145
185
|
}
|
|
146
186
|
|
|
147
|
-
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> {
|
|
187
|
+
export declare class InngestWorkflow<TEngineType = InngestEngineType, 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<TEngineType, TSteps, TWorkflowId, TInput, TOutput, TPrevSchema> {
|
|
148
188
|
#private;
|
|
149
189
|
inngest: Inngest;
|
|
150
190
|
private function;
|
|
@@ -157,10 +197,11 @@ export declare class InngestWorkflow<TSteps extends Step<string, any, any>[] = S
|
|
|
157
197
|
resourceId?: string;
|
|
158
198
|
}): Promise<WorkflowRuns>;
|
|
159
199
|
getWorkflowRunById(runId: string): Promise<WorkflowRun | null>;
|
|
200
|
+
getWorkflowRunExecutionResult(runId: string): Promise<WatchEvent['payload']['workflowState'] | null>;
|
|
160
201
|
__registerMastra(mastra: Mastra): void;
|
|
161
202
|
createRun(options?: {
|
|
162
203
|
runId?: string;
|
|
163
|
-
}): Run<TSteps, TInput, TOutput
|
|
204
|
+
}): Promise<Run<TEngineType, TSteps, TInput, TOutput>>;
|
|
164
205
|
getFunction(): InngestFunction<Omit<InngestFunction.Options<Inngest<ClientOptions>, InngestMiddleware.Stack, InngestFunction.Trigger<string>[] | [{
|
|
165
206
|
cron: string;
|
|
166
207
|
} & Partial<Record<"event" | "if", never>>] | [{
|