@mastra/inngest 0.0.0-redis-cloud-transporter-20250508203756 → 0.0.0-support-d1-client-20250701191943

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.
@@ -1,128 +1,181 @@
1
+ import type { Agent } from '@mastra/core';
1
2
  import type { BaseContext } from 'inngest';
2
3
  import { ClientOptions } from 'inngest';
3
- import { cloneStep } from '@mastra/core/workflows/vNext';
4
- import { createStep } from '@mastra/core/workflows/vNext';
5
- import { DefaultExecutionEngine } from '@mastra/core/workflows/vNext';
6
- import type { ExecuteFunction } from '@mastra/core/workflows/vNext';
7
- import type { ExecutionContext } from '@mastra/core/workflows/vNext';
8
- import type { ExecutionEngine } from '@mastra/core/workflows/vNext';
9
- import type { ExecutionGraph } from '@mastra/core/workflows/vNext';
4
+ import { DefaultExecutionEngine } from '@mastra/core/workflows';
5
+ import type { Emitter } from '@mastra/core/workflows';
6
+ import type { ExecuteFunction } from '@mastra/core/workflows';
7
+ import type { ExecutionContext } from '@mastra/core/workflows';
8
+ import type { ExecutionEngine } from '@mastra/core/workflows';
9
+ import type { ExecutionGraph } from '@mastra/core/workflows';
10
10
  import { Handler } from 'inngest';
11
11
  import type { Inngest } from 'inngest';
12
12
  import { InngestFunction } from 'inngest';
13
13
  import { InngestMiddleware } from 'inngest';
14
14
  import type { Mastra } from '@mastra/core';
15
- import type { NewStep } from '@mastra/core/workflows/vNext';
16
- import { NewWorkflow } from '@mastra/core/workflows/vNext';
17
- import type { NewWorkflowConfig } from '@mastra/core/workflows/vNext';
18
- import { Run } from '@mastra/core/workflows/vNext';
15
+ import type { ReadableStream as ReadableStream_2 } from 'node:stream/web';
16
+ import { Run } from '@mastra/core/workflows';
19
17
  import { RuntimeContext } from '@mastra/core/di';
18
+ import type { SerializedStepFlowEntry } from '@mastra/core/workflows';
20
19
  import { serve as serve_2 } from 'inngest/hono';
21
20
  import type { Span } from '@opentelemetry/api';
22
- import type { StepFlowEntry } from '@mastra/core/workflows/vNext';
23
- import type { StepResult } from '@mastra/core/workflows/vNext';
24
- import type { WorkflowResult } from '@mastra/core/workflows/vNext';
21
+ import type { Step } from '@mastra/core/workflows';
22
+ import type { StepFlowEntry } from '@mastra/core/workflows';
23
+ import type { StepResult } from '@mastra/core/workflows';
24
+ import type { StreamEvent } from '@mastra/core/workflows';
25
+ import { Tool } from '@mastra/core/tools';
26
+ import type { ToolExecutionContext } from '@mastra/core';
27
+ import type { WatchEvent } from '@mastra/core/workflows';
28
+ import { Workflow } from '@mastra/core/workflows';
29
+ import type { WorkflowConfig } from '@mastra/core/workflows';
30
+ import type { WorkflowResult } from '@mastra/core/workflows';
25
31
  import type { WorkflowRun } from '@mastra/core';
26
- import { WorkflowRuns } from '@mastra/core';
27
- import type { z } from 'zod';
32
+ import type { WorkflowRuns } from '@mastra/core';
33
+ import { z } from 'zod';
28
34
 
29
- declare function cloneWorkflow<TWorkflowId extends string = string, TInput extends z.ZodType<any> = z.ZodType<any>, TOutput extends z.ZodType<any> = z.ZodType<any>, TSteps extends NewStep<string, any, any, any, any>[] = NewStep<string, any, any, any, any>[]>(workflow: InngestWorkflow<TSteps, string, TInput, TOutput>, opts: {
30
- id: TWorkflowId;
31
- }): InngestWorkflow<TSteps, TWorkflowId, TInput, TOutput>;
35
+ 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: {
36
+ id: TStepId;
37
+ description?: string;
38
+ inputSchema: TStepInput;
39
+ outputSchema: TStepOutput;
40
+ resumeSchema?: TResumeSchema;
41
+ suspendSchema?: TSuspendSchema;
42
+ execute: ExecuteFunction<z.infer<TStepInput>, z.infer<TStepOutput>, z.infer<TResumeSchema>, z.infer<TSuspendSchema>, InngestEngineType>;
43
+ }): Step<TStepId, TStepInput, TStepOutput, TResumeSchema, TSuspendSchema, InngestEngineType>;
44
+
45
+ export declare function createStep<TStepId extends string, TStepInput extends z.ZodObject<{
46
+ prompt: z.ZodString;
47
+ }>, TStepOutput extends z.ZodObject<{
48
+ text: z.ZodString;
49
+ }>, TResumeSchema extends z.ZodType<any>, TSuspendSchema extends z.ZodType<any>>(agent: Agent<TStepId, any, any>): Step<TStepId, TStepInput, TStepOutput, TResumeSchema, TSuspendSchema, InngestEngineType>;
50
+
51
+ export declare function createStep<TSchemaIn extends z.ZodType<any>, TSchemaOut extends z.ZodType<any>, TContext extends ToolExecutionContext<TSchemaIn>>(tool: Tool<TSchemaIn, TSchemaOut, TContext> & {
52
+ inputSchema: TSchemaIn;
53
+ outputSchema: TSchemaOut;
54
+ execute: (context: TContext) => Promise<any>;
55
+ }): Step<string, TSchemaIn, TSchemaOut, z.ZodType<any>, z.ZodType<any>, InngestEngineType>;
32
56
 
33
57
  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 NewStep<string, any, any>[] = NewStep<string, any, any, z.ZodType<any, z.ZodTypeDef, any>, z.ZodType<any, z.ZodTypeDef, any>>[]>(params: NewWorkflowConfig<TWorkflowId, TInput, TOutput, TSteps>): InngestWorkflow<TSteps, TWorkflowId, TInput, TOutput, TInput>;
58
+ 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
59
  createStep: typeof createStep;
36
- cloneStep: typeof cloneStep;
37
- cloneWorkflow: typeof cloneWorkflow;
60
+ cloneStep<TStepId extends string>(step: Step<string, any, any, any, any, InngestEngineType>, opts: {
61
+ id: TStepId;
62
+ }): Step<TStepId, any, any, any, any, InngestEngineType>;
63
+ 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>[], TPrevSchema extends z.ZodType<any> = TInput>(workflow: Workflow<InngestEngineType, TSteps, string, TInput, TOutput, TPrevSchema>, opts: {
64
+ id: TWorkflowId;
65
+ }): Workflow<InngestEngineType, TSteps, TWorkflowId, TInput, TOutput, TPrevSchema>;
66
+ };
67
+
68
+ export declare type InngestEngineType = {
69
+ step: any;
38
70
  };
39
71
 
40
72
  export declare class InngestExecutionEngine extends DefaultExecutionEngine {
41
73
  private inngestStep;
42
74
  private inngestAttempts;
43
75
  constructor(mastra: Mastra, inngestStep: BaseContext<Inngest>['step'], inngestAttempts?: number);
44
- protected fmtReturnValue<TOutput>(executionSpan: Span | undefined, emitter: {
45
- emit: (event: string, data: any) => Promise<void>;
46
- }, stepResults: Record<string, StepResult<any>>, lastOutput: StepResult<any>, error?: Error | string): Promise<TOutput>;
47
- superExecuteStep({ workflowId, runId, step, stepResults, executionContext, resume, prevOutput, emitter, runtimeContext, }: {
76
+ execute<TInput, TOutput>(params: {
48
77
  workflowId: string;
49
78
  runId: string;
50
- step: NewStep<string, any, any>;
51
- stepResults: Record<string, StepResult<any>>;
52
- executionContext: ExecutionContext;
79
+ graph: ExecutionGraph;
80
+ serializedStepGraph: SerializedStepFlowEntry[];
81
+ input?: TInput;
53
82
  resume?: {
54
83
  steps: string[];
84
+ stepResults: Record<string, StepResult<any, any, any, any>>;
55
85
  resumePayload: any;
86
+ resumePath: number[];
56
87
  };
57
- prevOutput: any;
58
- emitter: {
59
- emit: (event: string, data: any) => Promise<void>;
88
+ emitter: Emitter;
89
+ retryConfig?: {
90
+ attempts?: number;
91
+ delay?: number;
60
92
  };
61
93
  runtimeContext: RuntimeContext;
62
- }): Promise<StepResult<any>>;
63
- executeStep({ step, stepResults, executionContext, resume, prevOutput, emitter, runtimeContext, }: {
64
- step: NewStep<string, any, any>;
65
- stepResults: Record<string, StepResult<any>>;
66
- executionContext: {
67
- workflowId: string;
68
- runId: string;
69
- executionPath: number[];
70
- suspendedPaths: Record<string, number[]>;
71
- retryConfig: {
72
- attempts: number;
73
- delay: number;
74
- };
94
+ abortController: AbortController;
95
+ }): Promise<TOutput>;
96
+ protected fmtReturnValue<TOutput>(executionSpan: Span | undefined, emitter: Emitter, stepResults: Record<string, StepResult<any, any, any, any>>, lastOutput: StepResult<any, any, any, any>, error?: Error | string): Promise<TOutput>;
97
+ superExecuteStep({ workflowId, runId, step, stepResults, executionContext, resume, prevOutput, emitter, abortController, runtimeContext, }: {
98
+ workflowId: string;
99
+ runId: string;
100
+ step: Step<string, any, any>;
101
+ stepResults: Record<string, StepResult<any, any, any, any>>;
102
+ executionContext: ExecutionContext;
103
+ resume?: {
104
+ steps: string[];
105
+ resumePayload: any;
75
106
  };
107
+ prevOutput: any;
108
+ emitter: Emitter;
109
+ abortController: AbortController;
110
+ runtimeContext: RuntimeContext;
111
+ }): Promise<StepResult<any, any, any, any>>;
112
+ executeSleep({ id, duration }: {
113
+ id: string;
114
+ duration: number;
115
+ }): Promise<void>;
116
+ executeWaitForEvent({ event, timeout }: {
117
+ event: string;
118
+ timeout?: number;
119
+ }): Promise<any>;
120
+ executeStep({ step, stepResults, executionContext, resume, prevOutput, emitter, abortController, runtimeContext, }: {
121
+ step: Step<string, any, any>;
122
+ stepResults: Record<string, StepResult<any, any, any, any>>;
123
+ executionContext: ExecutionContext;
76
124
  resume?: {
77
125
  steps: string[];
78
126
  resumePayload: any;
79
127
  runId?: string;
80
128
  };
81
129
  prevOutput: any;
82
- emitter: {
83
- emit: (event: string, data: any) => Promise<void>;
84
- };
130
+ emitter: Emitter;
131
+ abortController: AbortController;
85
132
  runtimeContext: RuntimeContext;
86
- }): Promise<StepResult<any>>;
87
- persistStepUpdate({ workflowId, runId, stepResults, executionContext, }: {
133
+ }): Promise<StepResult<any, any, any, any>>;
134
+ persistStepUpdate({ workflowId, runId, stepResults, executionContext, serializedStepGraph, workflowStatus, result, error, }: {
88
135
  workflowId: string;
89
136
  runId: string;
90
- stepResults: Record<string, StepResult<any>>;
137
+ stepResults: Record<string, StepResult<any, any, any, any>>;
138
+ serializedStepGraph: SerializedStepFlowEntry[];
91
139
  executionContext: ExecutionContext;
140
+ workflowStatus: 'success' | 'failed' | 'suspended' | 'running';
141
+ result?: Record<string, any>;
142
+ error?: string | Error;
92
143
  }): Promise<void>;
93
- executeConditional({ workflowId, runId, entry, prevOutput, prevStep, stepResults, resume, executionContext, emitter, runtimeContext, }: {
144
+ executeConditional({ workflowId, runId, entry, prevOutput, prevStep, stepResults, serializedStepGraph, resume, executionContext, emitter, abortController, runtimeContext, }: {
94
145
  workflowId: string;
95
146
  runId: string;
96
147
  entry: {
97
148
  type: 'conditional';
98
149
  steps: StepFlowEntry[];
99
- conditions: ExecuteFunction<any, any, any, any>[];
150
+ conditions: ExecuteFunction<any, any, any, any, InngestEngineType>[];
100
151
  };
101
152
  prevStep: StepFlowEntry;
153
+ serializedStepGraph: SerializedStepFlowEntry[];
102
154
  prevOutput: any;
103
- stepResults: Record<string, StepResult<any>>;
155
+ stepResults: Record<string, StepResult<any, any, any, any>>;
104
156
  resume?: {
105
157
  steps: string[];
106
- stepResults: Record<string, StepResult<any>>;
158
+ stepResults: Record<string, StepResult<any, any, any, any>>;
107
159
  resumePayload: any;
108
160
  resumePath: number[];
109
161
  };
110
162
  executionContext: ExecutionContext;
111
- emitter: {
112
- emit: (event: string, data: any) => Promise<void>;
113
- };
163
+ emitter: Emitter;
164
+ abortController: AbortController;
114
165
  runtimeContext: RuntimeContext;
115
- }): Promise<StepResult<any>>;
166
+ }): Promise<StepResult<any, any, any, any>>;
116
167
  }
117
168
 
118
- export declare class InngestRun<TSteps extends NewStep<string, any, any>[] = NewStep<string, any, any>[], TInput extends z.ZodType<any> = z.ZodType<any>, TOutput extends z.ZodType<any> = z.ZodType<any>> extends Run<TSteps, TInput, TOutput> {
169
+ 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
170
  #private;
120
171
  private inngest;
172
+ serializedStepGraph: SerializedStepFlowEntry[];
121
173
  constructor(params: {
122
174
  workflowId: string;
123
175
  runId: string;
124
176
  executionEngine: ExecutionEngine;
125
177
  executionGraph: ExecutionGraph;
178
+ serializedStepGraph: SerializedStepFlowEntry[];
126
179
  mastra?: Mastra;
127
180
  retryConfig?: {
128
181
  attempts?: number;
@@ -132,23 +185,37 @@ export declare class InngestRun<TSteps extends NewStep<string, any, any>[] = New
132
185
  }, inngest: Inngest);
133
186
  getRuns(eventId: string): Promise<any>;
134
187
  getRunOutput(eventId: string): Promise<any>;
188
+ sendEvent(event: string, data: any): Promise<void>;
189
+ cancel(): Promise<void>;
135
190
  start({ inputData, }: {
136
191
  inputData?: z.infer<TInput>;
137
192
  runtimeContext?: RuntimeContext;
138
193
  }): Promise<WorkflowResult<TOutput, TSteps>>;
139
194
  resume<TResumeSchema extends z.ZodType<any>>(params: {
140
195
  resumeData?: z.infer<TResumeSchema>;
141
- step: NewStep<string, any, any, TResumeSchema, any> | [...NewStep<string, any, any, any, any>[], NewStep<string, any, any, TResumeSchema, any>] | string | string[];
196
+ step: Step<string, any, any, TResumeSchema, any> | [...Step<string, any, any, any, any>[], Step<string, any, any, TResumeSchema, any>] | string | string[];
197
+ runtimeContext?: RuntimeContext;
198
+ }): Promise<WorkflowResult<TOutput, TSteps>>;
199
+ _resume<TResumeSchema extends z.ZodType<any>>(params: {
200
+ resumeData?: z.infer<TResumeSchema>;
201
+ step: Step<string, any, any, TResumeSchema, any> | [...Step<string, any, any, any, any>[], Step<string, any, any, TResumeSchema, any>] | string | string[];
142
202
  runtimeContext?: RuntimeContext;
143
203
  }): Promise<WorkflowResult<TOutput, TSteps>>;
144
- watch(cb: (event: any) => void): () => void;
204
+ watch(cb: (event: WatchEvent) => void, type?: 'watch' | 'watch-v2'): () => void;
205
+ stream({ inputData, runtimeContext }?: {
206
+ inputData?: z.infer<TInput>;
207
+ runtimeContext?: RuntimeContext;
208
+ }): {
209
+ stream: ReadableStream_2<StreamEvent>;
210
+ getWorkflowState: () => Promise<WorkflowResult<TOutput, TSteps>>;
211
+ };
145
212
  }
146
213
 
147
- export declare class InngestWorkflow<TSteps extends NewStep<string, any, any>[] = NewStep<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 NewWorkflow<TSteps, TWorkflowId, TInput, TOutput, TPrevSchema> {
214
+ 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
215
  #private;
149
216
  inngest: Inngest;
150
217
  private function;
151
- constructor(params: NewWorkflowConfig<TWorkflowId, TInput, TOutput, TSteps>, inngest: Inngest);
218
+ constructor(params: WorkflowConfig<TWorkflowId, TInput, TOutput, TSteps>, inngest: Inngest);
152
219
  getWorkflowRuns(args?: {
153
220
  fromDate?: Date;
154
221
  toDate?: Date;
@@ -157,10 +224,14 @@ export declare class InngestWorkflow<TSteps extends NewStep<string, any, any>[]
157
224
  resourceId?: string;
158
225
  }): Promise<WorkflowRuns>;
159
226
  getWorkflowRunById(runId: string): Promise<WorkflowRun | null>;
227
+ getWorkflowRunExecutionResult(runId: string): Promise<WatchEvent['payload']['workflowState'] | null>;
160
228
  __registerMastra(mastra: Mastra): void;
161
229
  createRun(options?: {
162
230
  runId?: string;
163
- }): Run<TSteps, TInput, TOutput>;
231
+ }): Run<TEngineType, TSteps, TInput, TOutput>;
232
+ createRunAsync(options?: {
233
+ runId?: string;
234
+ }): Promise<Run<TEngineType, TSteps, TInput, TOutput>>;
164
235
  getFunction(): InngestFunction<Omit<InngestFunction.Options<Inngest<ClientOptions>, InngestMiddleware.Stack, InngestFunction.Trigger<string>[] | [{
165
236
  cron: string;
166
237
  } & Partial<Record<"event" | "if", never>>] | [{
@@ -1,128 +1,181 @@
1
+ import type { Agent } from '@mastra/core';
1
2
  import type { BaseContext } from 'inngest';
2
3
  import { ClientOptions } from 'inngest';
3
- import { cloneStep } from '@mastra/core/workflows/vNext';
4
- import { createStep } from '@mastra/core/workflows/vNext';
5
- import { DefaultExecutionEngine } from '@mastra/core/workflows/vNext';
6
- import type { ExecuteFunction } from '@mastra/core/workflows/vNext';
7
- import type { ExecutionContext } from '@mastra/core/workflows/vNext';
8
- import type { ExecutionEngine } from '@mastra/core/workflows/vNext';
9
- import type { ExecutionGraph } from '@mastra/core/workflows/vNext';
4
+ import { DefaultExecutionEngine } from '@mastra/core/workflows';
5
+ import type { Emitter } from '@mastra/core/workflows';
6
+ import type { ExecuteFunction } from '@mastra/core/workflows';
7
+ import type { ExecutionContext } from '@mastra/core/workflows';
8
+ import type { ExecutionEngine } from '@mastra/core/workflows';
9
+ import type { ExecutionGraph } from '@mastra/core/workflows';
10
10
  import { Handler } from 'inngest';
11
11
  import type { Inngest } from 'inngest';
12
12
  import { InngestFunction } from 'inngest';
13
13
  import { InngestMiddleware } from 'inngest';
14
14
  import type { Mastra } from '@mastra/core';
15
- import type { NewStep } from '@mastra/core/workflows/vNext';
16
- import { NewWorkflow } from '@mastra/core/workflows/vNext';
17
- import type { NewWorkflowConfig } from '@mastra/core/workflows/vNext';
18
- import { Run } from '@mastra/core/workflows/vNext';
15
+ import type { ReadableStream as ReadableStream_2 } from 'node:stream/web';
16
+ import { Run } from '@mastra/core/workflows';
19
17
  import { RuntimeContext } from '@mastra/core/di';
18
+ import type { SerializedStepFlowEntry } from '@mastra/core/workflows';
20
19
  import { serve as serve_2 } from 'inngest/hono';
21
20
  import type { Span } from '@opentelemetry/api';
22
- import type { StepFlowEntry } from '@mastra/core/workflows/vNext';
23
- import type { StepResult } from '@mastra/core/workflows/vNext';
24
- import type { WorkflowResult } from '@mastra/core/workflows/vNext';
21
+ import type { Step } from '@mastra/core/workflows';
22
+ import type { StepFlowEntry } from '@mastra/core/workflows';
23
+ import type { StepResult } from '@mastra/core/workflows';
24
+ import type { StreamEvent } from '@mastra/core/workflows';
25
+ import { Tool } from '@mastra/core/tools';
26
+ import type { ToolExecutionContext } from '@mastra/core';
27
+ import type { WatchEvent } from '@mastra/core/workflows';
28
+ import { Workflow } from '@mastra/core/workflows';
29
+ import type { WorkflowConfig } from '@mastra/core/workflows';
30
+ import type { WorkflowResult } from '@mastra/core/workflows';
25
31
  import type { WorkflowRun } from '@mastra/core';
26
- import { WorkflowRuns } from '@mastra/core';
27
- import type { z } from 'zod';
32
+ import type { WorkflowRuns } from '@mastra/core';
33
+ import { z } from 'zod';
28
34
 
29
- declare function cloneWorkflow<TWorkflowId extends string = string, TInput extends z.ZodType<any> = z.ZodType<any>, TOutput extends z.ZodType<any> = z.ZodType<any>, TSteps extends NewStep<string, any, any, any, any>[] = NewStep<string, any, any, any, any>[]>(workflow: InngestWorkflow<TSteps, string, TInput, TOutput>, opts: {
30
- id: TWorkflowId;
31
- }): InngestWorkflow<TSteps, TWorkflowId, TInput, TOutput>;
35
+ 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: {
36
+ id: TStepId;
37
+ description?: string;
38
+ inputSchema: TStepInput;
39
+ outputSchema: TStepOutput;
40
+ resumeSchema?: TResumeSchema;
41
+ suspendSchema?: TSuspendSchema;
42
+ execute: ExecuteFunction<z.infer<TStepInput>, z.infer<TStepOutput>, z.infer<TResumeSchema>, z.infer<TSuspendSchema>, InngestEngineType>;
43
+ }): Step<TStepId, TStepInput, TStepOutput, TResumeSchema, TSuspendSchema, InngestEngineType>;
44
+
45
+ export declare function createStep<TStepId extends string, TStepInput extends z.ZodObject<{
46
+ prompt: z.ZodString;
47
+ }>, TStepOutput extends z.ZodObject<{
48
+ text: z.ZodString;
49
+ }>, TResumeSchema extends z.ZodType<any>, TSuspendSchema extends z.ZodType<any>>(agent: Agent<TStepId, any, any>): Step<TStepId, TStepInput, TStepOutput, TResumeSchema, TSuspendSchema, InngestEngineType>;
50
+
51
+ export declare function createStep<TSchemaIn extends z.ZodType<any>, TSchemaOut extends z.ZodType<any>, TContext extends ToolExecutionContext<TSchemaIn>>(tool: Tool<TSchemaIn, TSchemaOut, TContext> & {
52
+ inputSchema: TSchemaIn;
53
+ outputSchema: TSchemaOut;
54
+ execute: (context: TContext) => Promise<any>;
55
+ }): Step<string, TSchemaIn, TSchemaOut, z.ZodType<any>, z.ZodType<any>, InngestEngineType>;
32
56
 
33
57
  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 NewStep<string, any, any>[] = NewStep<string, any, any, z.ZodType<any, z.ZodTypeDef, any>, z.ZodType<any, z.ZodTypeDef, any>>[]>(params: NewWorkflowConfig<TWorkflowId, TInput, TOutput, TSteps>): InngestWorkflow<TSteps, TWorkflowId, TInput, TOutput, TInput>;
58
+ 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
59
  createStep: typeof createStep;
36
- cloneStep: typeof cloneStep;
37
- cloneWorkflow: typeof cloneWorkflow;
60
+ cloneStep<TStepId extends string>(step: Step<string, any, any, any, any, InngestEngineType>, opts: {
61
+ id: TStepId;
62
+ }): Step<TStepId, any, any, any, any, InngestEngineType>;
63
+ 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>[], TPrevSchema extends z.ZodType<any> = TInput>(workflow: Workflow<InngestEngineType, TSteps, string, TInput, TOutput, TPrevSchema>, opts: {
64
+ id: TWorkflowId;
65
+ }): Workflow<InngestEngineType, TSteps, TWorkflowId, TInput, TOutput, TPrevSchema>;
66
+ };
67
+
68
+ export declare type InngestEngineType = {
69
+ step: any;
38
70
  };
39
71
 
40
72
  export declare class InngestExecutionEngine extends DefaultExecutionEngine {
41
73
  private inngestStep;
42
74
  private inngestAttempts;
43
75
  constructor(mastra: Mastra, inngestStep: BaseContext<Inngest>['step'], inngestAttempts?: number);
44
- protected fmtReturnValue<TOutput>(executionSpan: Span | undefined, emitter: {
45
- emit: (event: string, data: any) => Promise<void>;
46
- }, stepResults: Record<string, StepResult<any>>, lastOutput: StepResult<any>, error?: Error | string): Promise<TOutput>;
47
- superExecuteStep({ workflowId, runId, step, stepResults, executionContext, resume, prevOutput, emitter, runtimeContext, }: {
76
+ execute<TInput, TOutput>(params: {
48
77
  workflowId: string;
49
78
  runId: string;
50
- step: NewStep<string, any, any>;
51
- stepResults: Record<string, StepResult<any>>;
52
- executionContext: ExecutionContext;
79
+ graph: ExecutionGraph;
80
+ serializedStepGraph: SerializedStepFlowEntry[];
81
+ input?: TInput;
53
82
  resume?: {
54
83
  steps: string[];
84
+ stepResults: Record<string, StepResult<any, any, any, any>>;
55
85
  resumePayload: any;
86
+ resumePath: number[];
56
87
  };
57
- prevOutput: any;
58
- emitter: {
59
- emit: (event: string, data: any) => Promise<void>;
88
+ emitter: Emitter;
89
+ retryConfig?: {
90
+ attempts?: number;
91
+ delay?: number;
60
92
  };
61
93
  runtimeContext: RuntimeContext;
62
- }): Promise<StepResult<any>>;
63
- executeStep({ step, stepResults, executionContext, resume, prevOutput, emitter, runtimeContext, }: {
64
- step: NewStep<string, any, any>;
65
- stepResults: Record<string, StepResult<any>>;
66
- executionContext: {
67
- workflowId: string;
68
- runId: string;
69
- executionPath: number[];
70
- suspendedPaths: Record<string, number[]>;
71
- retryConfig: {
72
- attempts: number;
73
- delay: number;
74
- };
94
+ abortController: AbortController;
95
+ }): Promise<TOutput>;
96
+ protected fmtReturnValue<TOutput>(executionSpan: Span | undefined, emitter: Emitter, stepResults: Record<string, StepResult<any, any, any, any>>, lastOutput: StepResult<any, any, any, any>, error?: Error | string): Promise<TOutput>;
97
+ superExecuteStep({ workflowId, runId, step, stepResults, executionContext, resume, prevOutput, emitter, abortController, runtimeContext, }: {
98
+ workflowId: string;
99
+ runId: string;
100
+ step: Step<string, any, any>;
101
+ stepResults: Record<string, StepResult<any, any, any, any>>;
102
+ executionContext: ExecutionContext;
103
+ resume?: {
104
+ steps: string[];
105
+ resumePayload: any;
75
106
  };
107
+ prevOutput: any;
108
+ emitter: Emitter;
109
+ abortController: AbortController;
110
+ runtimeContext: RuntimeContext;
111
+ }): Promise<StepResult<any, any, any, any>>;
112
+ executeSleep({ id, duration }: {
113
+ id: string;
114
+ duration: number;
115
+ }): Promise<void>;
116
+ executeWaitForEvent({ event, timeout }: {
117
+ event: string;
118
+ timeout?: number;
119
+ }): Promise<any>;
120
+ executeStep({ step, stepResults, executionContext, resume, prevOutput, emitter, abortController, runtimeContext, }: {
121
+ step: Step<string, any, any>;
122
+ stepResults: Record<string, StepResult<any, any, any, any>>;
123
+ executionContext: ExecutionContext;
76
124
  resume?: {
77
125
  steps: string[];
78
126
  resumePayload: any;
79
127
  runId?: string;
80
128
  };
81
129
  prevOutput: any;
82
- emitter: {
83
- emit: (event: string, data: any) => Promise<void>;
84
- };
130
+ emitter: Emitter;
131
+ abortController: AbortController;
85
132
  runtimeContext: RuntimeContext;
86
- }): Promise<StepResult<any>>;
87
- persistStepUpdate({ workflowId, runId, stepResults, executionContext, }: {
133
+ }): Promise<StepResult<any, any, any, any>>;
134
+ persistStepUpdate({ workflowId, runId, stepResults, executionContext, serializedStepGraph, workflowStatus, result, error, }: {
88
135
  workflowId: string;
89
136
  runId: string;
90
- stepResults: Record<string, StepResult<any>>;
137
+ stepResults: Record<string, StepResult<any, any, any, any>>;
138
+ serializedStepGraph: SerializedStepFlowEntry[];
91
139
  executionContext: ExecutionContext;
140
+ workflowStatus: 'success' | 'failed' | 'suspended' | 'running';
141
+ result?: Record<string, any>;
142
+ error?: string | Error;
92
143
  }): Promise<void>;
93
- executeConditional({ workflowId, runId, entry, prevOutput, prevStep, stepResults, resume, executionContext, emitter, runtimeContext, }: {
144
+ executeConditional({ workflowId, runId, entry, prevOutput, prevStep, stepResults, serializedStepGraph, resume, executionContext, emitter, abortController, runtimeContext, }: {
94
145
  workflowId: string;
95
146
  runId: string;
96
147
  entry: {
97
148
  type: 'conditional';
98
149
  steps: StepFlowEntry[];
99
- conditions: ExecuteFunction<any, any, any, any>[];
150
+ conditions: ExecuteFunction<any, any, any, any, InngestEngineType>[];
100
151
  };
101
152
  prevStep: StepFlowEntry;
153
+ serializedStepGraph: SerializedStepFlowEntry[];
102
154
  prevOutput: any;
103
- stepResults: Record<string, StepResult<any>>;
155
+ stepResults: Record<string, StepResult<any, any, any, any>>;
104
156
  resume?: {
105
157
  steps: string[];
106
- stepResults: Record<string, StepResult<any>>;
158
+ stepResults: Record<string, StepResult<any, any, any, any>>;
107
159
  resumePayload: any;
108
160
  resumePath: number[];
109
161
  };
110
162
  executionContext: ExecutionContext;
111
- emitter: {
112
- emit: (event: string, data: any) => Promise<void>;
113
- };
163
+ emitter: Emitter;
164
+ abortController: AbortController;
114
165
  runtimeContext: RuntimeContext;
115
- }): Promise<StepResult<any>>;
166
+ }): Promise<StepResult<any, any, any, any>>;
116
167
  }
117
168
 
118
- export declare class InngestRun<TSteps extends NewStep<string, any, any>[] = NewStep<string, any, any>[], TInput extends z.ZodType<any> = z.ZodType<any>, TOutput extends z.ZodType<any> = z.ZodType<any>> extends Run<TSteps, TInput, TOutput> {
169
+ 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
170
  #private;
120
171
  private inngest;
172
+ serializedStepGraph: SerializedStepFlowEntry[];
121
173
  constructor(params: {
122
174
  workflowId: string;
123
175
  runId: string;
124
176
  executionEngine: ExecutionEngine;
125
177
  executionGraph: ExecutionGraph;
178
+ serializedStepGraph: SerializedStepFlowEntry[];
126
179
  mastra?: Mastra;
127
180
  retryConfig?: {
128
181
  attempts?: number;
@@ -132,23 +185,37 @@ export declare class InngestRun<TSteps extends NewStep<string, any, any>[] = New
132
185
  }, inngest: Inngest);
133
186
  getRuns(eventId: string): Promise<any>;
134
187
  getRunOutput(eventId: string): Promise<any>;
188
+ sendEvent(event: string, data: any): Promise<void>;
189
+ cancel(): Promise<void>;
135
190
  start({ inputData, }: {
136
191
  inputData?: z.infer<TInput>;
137
192
  runtimeContext?: RuntimeContext;
138
193
  }): Promise<WorkflowResult<TOutput, TSteps>>;
139
194
  resume<TResumeSchema extends z.ZodType<any>>(params: {
140
195
  resumeData?: z.infer<TResumeSchema>;
141
- step: NewStep<string, any, any, TResumeSchema, any> | [...NewStep<string, any, any, any, any>[], NewStep<string, any, any, TResumeSchema, any>] | string | string[];
196
+ step: Step<string, any, any, TResumeSchema, any> | [...Step<string, any, any, any, any>[], Step<string, any, any, TResumeSchema, any>] | string | string[];
197
+ runtimeContext?: RuntimeContext;
198
+ }): Promise<WorkflowResult<TOutput, TSteps>>;
199
+ _resume<TResumeSchema extends z.ZodType<any>>(params: {
200
+ resumeData?: z.infer<TResumeSchema>;
201
+ step: Step<string, any, any, TResumeSchema, any> | [...Step<string, any, any, any, any>[], Step<string, any, any, TResumeSchema, any>] | string | string[];
142
202
  runtimeContext?: RuntimeContext;
143
203
  }): Promise<WorkflowResult<TOutput, TSteps>>;
144
- watch(cb: (event: any) => void): () => void;
204
+ watch(cb: (event: WatchEvent) => void, type?: 'watch' | 'watch-v2'): () => void;
205
+ stream({ inputData, runtimeContext }?: {
206
+ inputData?: z.infer<TInput>;
207
+ runtimeContext?: RuntimeContext;
208
+ }): {
209
+ stream: ReadableStream_2<StreamEvent>;
210
+ getWorkflowState: () => Promise<WorkflowResult<TOutput, TSteps>>;
211
+ };
145
212
  }
146
213
 
147
- export declare class InngestWorkflow<TSteps extends NewStep<string, any, any>[] = NewStep<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 NewWorkflow<TSteps, TWorkflowId, TInput, TOutput, TPrevSchema> {
214
+ 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
215
  #private;
149
216
  inngest: Inngest;
150
217
  private function;
151
- constructor(params: NewWorkflowConfig<TWorkflowId, TInput, TOutput, TSteps>, inngest: Inngest);
218
+ constructor(params: WorkflowConfig<TWorkflowId, TInput, TOutput, TSteps>, inngest: Inngest);
152
219
  getWorkflowRuns(args?: {
153
220
  fromDate?: Date;
154
221
  toDate?: Date;
@@ -157,10 +224,14 @@ export declare class InngestWorkflow<TSteps extends NewStep<string, any, any>[]
157
224
  resourceId?: string;
158
225
  }): Promise<WorkflowRuns>;
159
226
  getWorkflowRunById(runId: string): Promise<WorkflowRun | null>;
227
+ getWorkflowRunExecutionResult(runId: string): Promise<WatchEvent['payload']['workflowState'] | null>;
160
228
  __registerMastra(mastra: Mastra): void;
161
229
  createRun(options?: {
162
230
  runId?: string;
163
- }): Run<TSteps, TInput, TOutput>;
231
+ }): Run<TEngineType, TSteps, TInput, TOutput>;
232
+ createRunAsync(options?: {
233
+ runId?: string;
234
+ }): Promise<Run<TEngineType, TSteps, TInput, TOutput>>;
164
235
  getFunction(): InngestFunction<Omit<InngestFunction.Options<Inngest<ClientOptions>, InngestMiddleware.Stack, InngestFunction.Trigger<string>[] | [{
165
236
  cron: string;
166
237
  } & Partial<Record<"event" | "if", never>>] | [{