@mastra/inngest 0.0.0-taofeeqInngest-20250603090617 → 0.0.0-transpile-packages-20250724123433

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,8 +1,8 @@
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';
4
- import { createStep } from '@mastra/core/workflows';
5
4
  import { DefaultExecutionEngine } from '@mastra/core/workflows';
5
+ import type { Emitter } from '@mastra/core/workflows';
6
6
  import type { ExecuteFunction } from '@mastra/core/workflows';
7
7
  import type { ExecutionContext } from '@mastra/core/workflows';
8
8
  import type { ExecutionEngine } from '@mastra/core/workflows';
@@ -12,6 +12,7 @@ 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 { ReadableStream as ReadableStream_2 } from 'node:stream/web';
15
16
  import { Run } from '@mastra/core/workflows';
16
17
  import { RuntimeContext } from '@mastra/core/di';
17
18
  import type { SerializedStepFlowEntry } from '@mastra/core/workflows';
@@ -20,32 +21,80 @@ import type { Span } from '@opentelemetry/api';
20
21
  import type { Step } from '@mastra/core/workflows';
21
22
  import type { StepFlowEntry } from '@mastra/core/workflows';
22
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';
23
28
  import { Workflow } from '@mastra/core/workflows';
24
29
  import type { WorkflowConfig } from '@mastra/core/workflows';
25
30
  import type { WorkflowResult } from '@mastra/core/workflows';
26
31
  import type { WorkflowRun } from '@mastra/core';
27
32
  import type { WorkflowRuns } from '@mastra/core';
28
- import type { z } from 'zod';
33
+ import { z } from 'zod';
29
34
 
30
- 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 Step<string, any, any, any, any>[] = Step<string, any, any, any, any>[]>(workflow: InngestWorkflow<TSteps, string, TInput, TOutput>, opts: {
31
- id: TWorkflowId;
32
- }): 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>;
33
56
 
34
57
  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>>[]>(params: WorkflowConfig<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>;
36
59
  createStep: typeof createStep;
37
- cloneStep: typeof cloneStep;
38
- 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;
39
70
  };
40
71
 
41
72
  export declare class InngestExecutionEngine extends DefaultExecutionEngine {
42
73
  private inngestStep;
43
74
  private inngestAttempts;
44
75
  constructor(mastra: Mastra, inngestStep: BaseContext<Inngest>['step'], inngestAttempts?: number);
45
- protected fmtReturnValue<TOutput>(executionSpan: Span | undefined, emitter: {
46
- emit: (event: string, data: any) => Promise<void>;
47
- }, stepResults: Record<string, StepResult<any, any, any, any>>, lastOutput: StepResult<any, any, any, any>, error?: Error | string): Promise<TOutput>;
48
- superExecuteStep({ workflowId, runId, step, stepResults, executionContext, resume, prevOutput, emitter, runtimeContext, }: {
76
+ execute<TInput, TOutput>(params: {
77
+ workflowId: string;
78
+ runId: string;
79
+ graph: ExecutionGraph;
80
+ serializedStepGraph: SerializedStepFlowEntry[];
81
+ input?: TInput;
82
+ resume?: {
83
+ steps: string[];
84
+ stepResults: Record<string, StepResult<any, any, any, any>>;
85
+ resumePayload: any;
86
+ resumePath: number[];
87
+ };
88
+ emitter: Emitter;
89
+ retryConfig?: {
90
+ attempts?: number;
91
+ delay?: number;
92
+ };
93
+ runtimeContext: RuntimeContext;
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, }: {
49
98
  workflowId: string;
50
99
  runId: string;
51
100
  step: Step<string, any, any>;
@@ -56,49 +105,94 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
56
105
  resumePayload: any;
57
106
  };
58
107
  prevOutput: any;
59
- emitter: {
60
- emit: (event: string, data: any) => Promise<void>;
61
- };
108
+ emitter: Emitter;
109
+ abortController: AbortController;
62
110
  runtimeContext: RuntimeContext;
63
111
  }): Promise<StepResult<any, any, any, any>>;
64
- executeStep({ step, stepResults, executionContext, resume, prevOutput, emitter, runtimeContext, }: {
65
- step: Step<string, any, any>;
112
+ executeSleep({ workflowId, runId, entry, prevOutput, stepResults, emitter, abortController, runtimeContext, }: {
113
+ workflowId: string;
114
+ runId: string;
115
+ serializedStepGraph: SerializedStepFlowEntry[];
116
+ entry: {
117
+ type: 'sleep';
118
+ id: string;
119
+ duration?: number;
120
+ fn?: ExecuteFunction<any, any, any, any, InngestEngineType>;
121
+ };
122
+ prevStep: StepFlowEntry;
123
+ prevOutput: any;
66
124
  stepResults: Record<string, StepResult<any, any, any, any>>;
67
- executionContext: {
68
- workflowId: string;
69
- runId: string;
70
- executionPath: number[];
71
- suspendedPaths: Record<string, number[]>;
72
- retryConfig: {
73
- attempts: number;
74
- delay: number;
75
- };
125
+ resume?: {
126
+ steps: string[];
127
+ stepResults: Record<string, StepResult<any, any, any, any>>;
128
+ resumePayload: any;
129
+ resumePath: number[];
76
130
  };
131
+ executionContext: ExecutionContext;
132
+ emitter: Emitter;
133
+ abortController: AbortController;
134
+ runtimeContext: RuntimeContext;
135
+ }): Promise<void>;
136
+ executeSleepUntil({ workflowId, runId, entry, prevOutput, stepResults, emitter, abortController, runtimeContext, }: {
137
+ workflowId: string;
138
+ runId: string;
139
+ serializedStepGraph: SerializedStepFlowEntry[];
140
+ entry: {
141
+ type: 'sleepUntil';
142
+ id: string;
143
+ date?: Date;
144
+ fn?: ExecuteFunction<any, any, any, any, InngestEngineType>;
145
+ };
146
+ prevStep: StepFlowEntry;
147
+ prevOutput: any;
148
+ stepResults: Record<string, StepResult<any, any, any, any>>;
149
+ resume?: {
150
+ steps: string[];
151
+ stepResults: Record<string, StepResult<any, any, any, any>>;
152
+ resumePayload: any;
153
+ resumePath: number[];
154
+ };
155
+ executionContext: ExecutionContext;
156
+ emitter: Emitter;
157
+ abortController: AbortController;
158
+ runtimeContext: RuntimeContext;
159
+ }): Promise<void>;
160
+ executeWaitForEvent({ event, timeout }: {
161
+ event: string;
162
+ timeout?: number;
163
+ }): Promise<any>;
164
+ executeStep({ step, stepResults, executionContext, resume, prevOutput, emitter, abortController, runtimeContext, }: {
165
+ step: Step<string, any, any>;
166
+ stepResults: Record<string, StepResult<any, any, any, any>>;
167
+ executionContext: ExecutionContext;
77
168
  resume?: {
78
169
  steps: string[];
79
170
  resumePayload: any;
80
171
  runId?: string;
81
172
  };
82
173
  prevOutput: any;
83
- emitter: {
84
- emit: (event: string, data: any) => Promise<void>;
85
- };
174
+ emitter: Emitter;
175
+ abortController: AbortController;
86
176
  runtimeContext: RuntimeContext;
87
177
  }): Promise<StepResult<any, any, any, any>>;
88
- persistStepUpdate({ workflowId, runId, stepResults, executionContext, serializedStepGraph, }: {
178
+ persistStepUpdate({ workflowId, runId, stepResults, executionContext, serializedStepGraph, workflowStatus, result, error, }: {
89
179
  workflowId: string;
90
180
  runId: string;
91
181
  stepResults: Record<string, StepResult<any, any, any, any>>;
92
182
  serializedStepGraph: SerializedStepFlowEntry[];
93
183
  executionContext: ExecutionContext;
184
+ workflowStatus: 'success' | 'failed' | 'suspended' | 'running';
185
+ result?: Record<string, any>;
186
+ error?: string | Error;
187
+ runtimeContext: RuntimeContext;
94
188
  }): Promise<void>;
95
- executeConditional({ workflowId, runId, entry, prevOutput, prevStep, stepResults, serializedStepGraph, resume, executionContext, emitter, runtimeContext, }: {
189
+ executeConditional({ workflowId, runId, entry, prevOutput, prevStep, stepResults, serializedStepGraph, resume, executionContext, emitter, abortController, runtimeContext, }: {
96
190
  workflowId: string;
97
191
  runId: string;
98
192
  entry: {
99
193
  type: 'conditional';
100
194
  steps: StepFlowEntry[];
101
- conditions: ExecuteFunction<any, any, any, any>[];
195
+ conditions: ExecuteFunction<any, any, any, any, InngestEngineType>[];
102
196
  };
103
197
  prevStep: StepFlowEntry;
104
198
  serializedStepGraph: SerializedStepFlowEntry[];
@@ -111,14 +205,13 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
111
205
  resumePath: number[];
112
206
  };
113
207
  executionContext: ExecutionContext;
114
- emitter: {
115
- emit: (event: string, data: any) => Promise<void>;
116
- };
208
+ emitter: Emitter;
209
+ abortController: AbortController;
117
210
  runtimeContext: RuntimeContext;
118
211
  }): Promise<StepResult<any, any, any, any>>;
119
212
  }
120
213
 
121
- 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> {
214
+ 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> {
122
215
  #private;
123
216
  private inngest;
124
217
  serializedStepGraph: SerializedStepFlowEntry[];
@@ -137,6 +230,8 @@ export declare class InngestRun<TSteps extends Step<string, any, any>[] = Step<s
137
230
  }, inngest: Inngest);
138
231
  getRuns(eventId: string): Promise<any>;
139
232
  getRunOutput(eventId: string): Promise<any>;
233
+ sendEvent(event: string, data: any): Promise<void>;
234
+ cancel(): Promise<void>;
140
235
  start({ inputData, }: {
141
236
  inputData?: z.infer<TInput>;
142
237
  runtimeContext?: RuntimeContext;
@@ -146,10 +241,22 @@ export declare class InngestRun<TSteps extends Step<string, any, any>[] = Step<s
146
241
  step: Step<string, any, any, TResumeSchema, any> | [...Step<string, any, any, any, any>[], Step<string, any, any, TResumeSchema, any>] | string | string[];
147
242
  runtimeContext?: RuntimeContext;
148
243
  }): Promise<WorkflowResult<TOutput, TSteps>>;
149
- watch(cb: (event: any) => void): () => void;
244
+ _resume<TResumeSchema extends z.ZodType<any>>(params: {
245
+ resumeData?: z.infer<TResumeSchema>;
246
+ step: Step<string, any, any, TResumeSchema, any> | [...Step<string, any, any, any, any>[], Step<string, any, any, TResumeSchema, any>] | string | string[];
247
+ runtimeContext?: RuntimeContext;
248
+ }): Promise<WorkflowResult<TOutput, TSteps>>;
249
+ watch(cb: (event: WatchEvent) => void, type?: 'watch' | 'watch-v2'): () => void;
250
+ stream({ inputData, runtimeContext }?: {
251
+ inputData?: z.infer<TInput>;
252
+ runtimeContext?: RuntimeContext;
253
+ }): {
254
+ stream: ReadableStream_2<StreamEvent>;
255
+ getWorkflowState: () => Promise<WorkflowResult<TOutput, TSteps>>;
256
+ };
150
257
  }
151
258
 
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> {
259
+ 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> {
153
260
  #private;
154
261
  inngest: Inngest;
155
262
  private function;
@@ -162,10 +269,14 @@ export declare class InngestWorkflow<TSteps extends Step<string, any, any>[] = S
162
269
  resourceId?: string;
163
270
  }): Promise<WorkflowRuns>;
164
271
  getWorkflowRunById(runId: string): Promise<WorkflowRun | null>;
272
+ getWorkflowRunExecutionResult(runId: string): Promise<WatchEvent['payload']['workflowState'] | null>;
165
273
  __registerMastra(mastra: Mastra): void;
166
274
  createRun(options?: {
167
275
  runId?: string;
168
- }): Run<TSteps, TInput, TOutput>;
276
+ }): Run<TEngineType, TSteps, TInput, TOutput>;
277
+ createRunAsync(options?: {
278
+ runId?: string;
279
+ }): Promise<Run<TEngineType, TSteps, TInput, TOutput>>;
169
280
  getFunction(): InngestFunction<Omit<InngestFunction.Options<Inngest<ClientOptions>, InngestMiddleware.Stack, InngestFunction.Trigger<string>[] | [{
170
281
  cron: string;
171
282
  } & Partial<Record<"event" | "if", never>>] | [{
@@ -1,8 +1,8 @@
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';
4
- import { createStep } from '@mastra/core/workflows';
5
4
  import { DefaultExecutionEngine } from '@mastra/core/workflows';
5
+ import type { Emitter } from '@mastra/core/workflows';
6
6
  import type { ExecuteFunction } from '@mastra/core/workflows';
7
7
  import type { ExecutionContext } from '@mastra/core/workflows';
8
8
  import type { ExecutionEngine } from '@mastra/core/workflows';
@@ -12,6 +12,7 @@ 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 { ReadableStream as ReadableStream_2 } from 'node:stream/web';
15
16
  import { Run } from '@mastra/core/workflows';
16
17
  import { RuntimeContext } from '@mastra/core/di';
17
18
  import type { SerializedStepFlowEntry } from '@mastra/core/workflows';
@@ -20,32 +21,80 @@ import type { Span } from '@opentelemetry/api';
20
21
  import type { Step } from '@mastra/core/workflows';
21
22
  import type { StepFlowEntry } from '@mastra/core/workflows';
22
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';
23
28
  import { Workflow } from '@mastra/core/workflows';
24
29
  import type { WorkflowConfig } from '@mastra/core/workflows';
25
30
  import type { WorkflowResult } from '@mastra/core/workflows';
26
31
  import type { WorkflowRun } from '@mastra/core';
27
32
  import type { WorkflowRuns } from '@mastra/core';
28
- import type { z } from 'zod';
33
+ import { z } from 'zod';
29
34
 
30
- 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 Step<string, any, any, any, any>[] = Step<string, any, any, any, any>[]>(workflow: InngestWorkflow<TSteps, string, TInput, TOutput>, opts: {
31
- id: TWorkflowId;
32
- }): 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>;
33
56
 
34
57
  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>>[]>(params: WorkflowConfig<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>;
36
59
  createStep: typeof createStep;
37
- cloneStep: typeof cloneStep;
38
- 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;
39
70
  };
40
71
 
41
72
  export declare class InngestExecutionEngine extends DefaultExecutionEngine {
42
73
  private inngestStep;
43
74
  private inngestAttempts;
44
75
  constructor(mastra: Mastra, inngestStep: BaseContext<Inngest>['step'], inngestAttempts?: number);
45
- protected fmtReturnValue<TOutput>(executionSpan: Span | undefined, emitter: {
46
- emit: (event: string, data: any) => Promise<void>;
47
- }, stepResults: Record<string, StepResult<any, any, any, any>>, lastOutput: StepResult<any, any, any, any>, error?: Error | string): Promise<TOutput>;
48
- superExecuteStep({ workflowId, runId, step, stepResults, executionContext, resume, prevOutput, emitter, runtimeContext, }: {
76
+ execute<TInput, TOutput>(params: {
77
+ workflowId: string;
78
+ runId: string;
79
+ graph: ExecutionGraph;
80
+ serializedStepGraph: SerializedStepFlowEntry[];
81
+ input?: TInput;
82
+ resume?: {
83
+ steps: string[];
84
+ stepResults: Record<string, StepResult<any, any, any, any>>;
85
+ resumePayload: any;
86
+ resumePath: number[];
87
+ };
88
+ emitter: Emitter;
89
+ retryConfig?: {
90
+ attempts?: number;
91
+ delay?: number;
92
+ };
93
+ runtimeContext: RuntimeContext;
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, }: {
49
98
  workflowId: string;
50
99
  runId: string;
51
100
  step: Step<string, any, any>;
@@ -56,49 +105,94 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
56
105
  resumePayload: any;
57
106
  };
58
107
  prevOutput: any;
59
- emitter: {
60
- emit: (event: string, data: any) => Promise<void>;
61
- };
108
+ emitter: Emitter;
109
+ abortController: AbortController;
62
110
  runtimeContext: RuntimeContext;
63
111
  }): Promise<StepResult<any, any, any, any>>;
64
- executeStep({ step, stepResults, executionContext, resume, prevOutput, emitter, runtimeContext, }: {
65
- step: Step<string, any, any>;
112
+ executeSleep({ workflowId, runId, entry, prevOutput, stepResults, emitter, abortController, runtimeContext, }: {
113
+ workflowId: string;
114
+ runId: string;
115
+ serializedStepGraph: SerializedStepFlowEntry[];
116
+ entry: {
117
+ type: 'sleep';
118
+ id: string;
119
+ duration?: number;
120
+ fn?: ExecuteFunction<any, any, any, any, InngestEngineType>;
121
+ };
122
+ prevStep: StepFlowEntry;
123
+ prevOutput: any;
66
124
  stepResults: Record<string, StepResult<any, any, any, any>>;
67
- executionContext: {
68
- workflowId: string;
69
- runId: string;
70
- executionPath: number[];
71
- suspendedPaths: Record<string, number[]>;
72
- retryConfig: {
73
- attempts: number;
74
- delay: number;
75
- };
125
+ resume?: {
126
+ steps: string[];
127
+ stepResults: Record<string, StepResult<any, any, any, any>>;
128
+ resumePayload: any;
129
+ resumePath: number[];
76
130
  };
131
+ executionContext: ExecutionContext;
132
+ emitter: Emitter;
133
+ abortController: AbortController;
134
+ runtimeContext: RuntimeContext;
135
+ }): Promise<void>;
136
+ executeSleepUntil({ workflowId, runId, entry, prevOutput, stepResults, emitter, abortController, runtimeContext, }: {
137
+ workflowId: string;
138
+ runId: string;
139
+ serializedStepGraph: SerializedStepFlowEntry[];
140
+ entry: {
141
+ type: 'sleepUntil';
142
+ id: string;
143
+ date?: Date;
144
+ fn?: ExecuteFunction<any, any, any, any, InngestEngineType>;
145
+ };
146
+ prevStep: StepFlowEntry;
147
+ prevOutput: any;
148
+ stepResults: Record<string, StepResult<any, any, any, any>>;
149
+ resume?: {
150
+ steps: string[];
151
+ stepResults: Record<string, StepResult<any, any, any, any>>;
152
+ resumePayload: any;
153
+ resumePath: number[];
154
+ };
155
+ executionContext: ExecutionContext;
156
+ emitter: Emitter;
157
+ abortController: AbortController;
158
+ runtimeContext: RuntimeContext;
159
+ }): Promise<void>;
160
+ executeWaitForEvent({ event, timeout }: {
161
+ event: string;
162
+ timeout?: number;
163
+ }): Promise<any>;
164
+ executeStep({ step, stepResults, executionContext, resume, prevOutput, emitter, abortController, runtimeContext, }: {
165
+ step: Step<string, any, any>;
166
+ stepResults: Record<string, StepResult<any, any, any, any>>;
167
+ executionContext: ExecutionContext;
77
168
  resume?: {
78
169
  steps: string[];
79
170
  resumePayload: any;
80
171
  runId?: string;
81
172
  };
82
173
  prevOutput: any;
83
- emitter: {
84
- emit: (event: string, data: any) => Promise<void>;
85
- };
174
+ emitter: Emitter;
175
+ abortController: AbortController;
86
176
  runtimeContext: RuntimeContext;
87
177
  }): Promise<StepResult<any, any, any, any>>;
88
- persistStepUpdate({ workflowId, runId, stepResults, executionContext, serializedStepGraph, }: {
178
+ persistStepUpdate({ workflowId, runId, stepResults, executionContext, serializedStepGraph, workflowStatus, result, error, }: {
89
179
  workflowId: string;
90
180
  runId: string;
91
181
  stepResults: Record<string, StepResult<any, any, any, any>>;
92
182
  serializedStepGraph: SerializedStepFlowEntry[];
93
183
  executionContext: ExecutionContext;
184
+ workflowStatus: 'success' | 'failed' | 'suspended' | 'running';
185
+ result?: Record<string, any>;
186
+ error?: string | Error;
187
+ runtimeContext: RuntimeContext;
94
188
  }): Promise<void>;
95
- executeConditional({ workflowId, runId, entry, prevOutput, prevStep, stepResults, serializedStepGraph, resume, executionContext, emitter, runtimeContext, }: {
189
+ executeConditional({ workflowId, runId, entry, prevOutput, prevStep, stepResults, serializedStepGraph, resume, executionContext, emitter, abortController, runtimeContext, }: {
96
190
  workflowId: string;
97
191
  runId: string;
98
192
  entry: {
99
193
  type: 'conditional';
100
194
  steps: StepFlowEntry[];
101
- conditions: ExecuteFunction<any, any, any, any>[];
195
+ conditions: ExecuteFunction<any, any, any, any, InngestEngineType>[];
102
196
  };
103
197
  prevStep: StepFlowEntry;
104
198
  serializedStepGraph: SerializedStepFlowEntry[];
@@ -111,14 +205,13 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
111
205
  resumePath: number[];
112
206
  };
113
207
  executionContext: ExecutionContext;
114
- emitter: {
115
- emit: (event: string, data: any) => Promise<void>;
116
- };
208
+ emitter: Emitter;
209
+ abortController: AbortController;
117
210
  runtimeContext: RuntimeContext;
118
211
  }): Promise<StepResult<any, any, any, any>>;
119
212
  }
120
213
 
121
- 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> {
214
+ 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> {
122
215
  #private;
123
216
  private inngest;
124
217
  serializedStepGraph: SerializedStepFlowEntry[];
@@ -137,6 +230,8 @@ export declare class InngestRun<TSteps extends Step<string, any, any>[] = Step<s
137
230
  }, inngest: Inngest);
138
231
  getRuns(eventId: string): Promise<any>;
139
232
  getRunOutput(eventId: string): Promise<any>;
233
+ sendEvent(event: string, data: any): Promise<void>;
234
+ cancel(): Promise<void>;
140
235
  start({ inputData, }: {
141
236
  inputData?: z.infer<TInput>;
142
237
  runtimeContext?: RuntimeContext;
@@ -146,10 +241,22 @@ export declare class InngestRun<TSteps extends Step<string, any, any>[] = Step<s
146
241
  step: Step<string, any, any, TResumeSchema, any> | [...Step<string, any, any, any, any>[], Step<string, any, any, TResumeSchema, any>] | string | string[];
147
242
  runtimeContext?: RuntimeContext;
148
243
  }): Promise<WorkflowResult<TOutput, TSteps>>;
149
- watch(cb: (event: any) => void): () => void;
244
+ _resume<TResumeSchema extends z.ZodType<any>>(params: {
245
+ resumeData?: z.infer<TResumeSchema>;
246
+ step: Step<string, any, any, TResumeSchema, any> | [...Step<string, any, any, any, any>[], Step<string, any, any, TResumeSchema, any>] | string | string[];
247
+ runtimeContext?: RuntimeContext;
248
+ }): Promise<WorkflowResult<TOutput, TSteps>>;
249
+ watch(cb: (event: WatchEvent) => void, type?: 'watch' | 'watch-v2'): () => void;
250
+ stream({ inputData, runtimeContext }?: {
251
+ inputData?: z.infer<TInput>;
252
+ runtimeContext?: RuntimeContext;
253
+ }): {
254
+ stream: ReadableStream_2<StreamEvent>;
255
+ getWorkflowState: () => Promise<WorkflowResult<TOutput, TSteps>>;
256
+ };
150
257
  }
151
258
 
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> {
259
+ 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> {
153
260
  #private;
154
261
  inngest: Inngest;
155
262
  private function;
@@ -162,10 +269,14 @@ export declare class InngestWorkflow<TSteps extends Step<string, any, any>[] = S
162
269
  resourceId?: string;
163
270
  }): Promise<WorkflowRuns>;
164
271
  getWorkflowRunById(runId: string): Promise<WorkflowRun | null>;
272
+ getWorkflowRunExecutionResult(runId: string): Promise<WatchEvent['payload']['workflowState'] | null>;
165
273
  __registerMastra(mastra: Mastra): void;
166
274
  createRun(options?: {
167
275
  runId?: string;
168
- }): Run<TSteps, TInput, TOutput>;
276
+ }): Run<TEngineType, TSteps, TInput, TOutput>;
277
+ createRunAsync(options?: {
278
+ runId?: string;
279
+ }): Promise<Run<TEngineType, TSteps, TInput, TOutput>>;
169
280
  getFunction(): InngestFunction<Omit<InngestFunction.Options<Inngest<ClientOptions>, InngestMiddleware.Stack, InngestFunction.Trigger<string>[] | [{
170
281
  cron: string;
171
282
  } & Partial<Record<"event" | "if", never>>] | [{