@mastra/inngest 0.11.7 → 0.11.8

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,316 +0,0 @@
1
- import type { Agent } from '@mastra/core';
2
- import type { BaseContext } from 'inngest';
3
- import type { ChunkType } from '@mastra/core/workflows';
4
- import { ClientOptions } from 'inngest';
5
- import { DefaultExecutionEngine } from '@mastra/core/workflows';
6
- import type { Emitter } from '@mastra/core/workflows';
7
- import type { ExecuteFunction } from '@mastra/core/workflows';
8
- import type { ExecutionContext } from '@mastra/core/workflows';
9
- import type { ExecutionEngine } from '@mastra/core/workflows';
10
- import type { ExecutionGraph } from '@mastra/core/workflows';
11
- import { Handler } from 'inngest';
12
- import type { Inngest } from 'inngest';
13
- import { InngestFunction } from 'inngest';
14
- import { InngestMiddleware } from 'inngest';
15
- import type { Mastra } from '@mastra/core';
16
- import type { ReadableStream as ReadableStream_2 } from 'node:stream/web';
17
- import { Run } from '@mastra/core/workflows';
18
- import { RuntimeContext } from '@mastra/core/di';
19
- import type { SerializedStepFlowEntry } from '@mastra/core/workflows';
20
- import { serve as serve_2 } from 'inngest/hono';
21
- import type { Span } from '@opentelemetry/api';
22
- import type { Step } from '@mastra/core/workflows';
23
- import type { StepFlowEntry } from '@mastra/core/workflows';
24
- import type { StepResult } from '@mastra/core/workflows';
25
- import type { StreamEvent } from '@mastra/core/workflows';
26
- import { Tool } from '@mastra/core/tools';
27
- import type { ToolExecutionContext } from '@mastra/core';
28
- import type { WatchEvent } from '@mastra/core/workflows';
29
- import { Workflow } from '@mastra/core/workflows';
30
- import type { WorkflowConfig } from '@mastra/core/workflows';
31
- import type { WorkflowResult } from '@mastra/core/workflows';
32
- import type { WorkflowRun } from '@mastra/core';
33
- import type { WorkflowRuns } from '@mastra/core';
34
- import { z } from 'zod';
35
-
36
- 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: {
37
- id: TStepId;
38
- description?: string;
39
- inputSchema: TStepInput;
40
- outputSchema: TStepOutput;
41
- resumeSchema?: TResumeSchema;
42
- suspendSchema?: TSuspendSchema;
43
- execute: ExecuteFunction<z.infer<TStepInput>, z.infer<TStepOutput>, z.infer<TResumeSchema>, z.infer<TSuspendSchema>, InngestEngineType>;
44
- }): Step<TStepId, TStepInput, TStepOutput, TResumeSchema, TSuspendSchema, InngestEngineType>;
45
-
46
- export declare function createStep<TStepId extends string, TStepInput extends z.ZodObject<{
47
- prompt: z.ZodString;
48
- }>, TStepOutput extends z.ZodObject<{
49
- text: z.ZodString;
50
- }>, TResumeSchema extends z.ZodType<any>, TSuspendSchema extends z.ZodType<any>>(agent: Agent<TStepId, any, any>): Step<TStepId, TStepInput, TStepOutput, TResumeSchema, TSuspendSchema, InngestEngineType>;
51
-
52
- export declare function createStep<TSchemaIn extends z.ZodType<any>, TSchemaOut extends z.ZodType<any>, TContext extends ToolExecutionContext<TSchemaIn>>(tool: Tool<TSchemaIn, TSchemaOut, TContext> & {
53
- inputSchema: TSchemaIn;
54
- outputSchema: TSchemaOut;
55
- execute: (context: TContext) => Promise<any>;
56
- }): Step<string, TSchemaIn, TSchemaOut, z.ZodType<any>, z.ZodType<any>, InngestEngineType>;
57
-
58
- export declare function init(inngest: Inngest): {
59
- 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>;
60
- createStep: typeof createStep;
61
- cloneStep<TStepId extends string>(step: Step<string, any, any, any, any, InngestEngineType>, opts: {
62
- id: TStepId;
63
- }): Step<TStepId, any, any, any, any, InngestEngineType>;
64
- 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: {
65
- id: TWorkflowId;
66
- }): Workflow<InngestEngineType, TSteps, TWorkflowId, TInput, TOutput, TPrevSchema>;
67
- };
68
-
69
- export declare type InngestEngineType = {
70
- step: any;
71
- };
72
-
73
- export declare class InngestExecutionEngine extends DefaultExecutionEngine {
74
- private inngestStep;
75
- private inngestAttempts;
76
- constructor(mastra: Mastra, inngestStep: BaseContext<Inngest>['step'], inngestAttempts?: number);
77
- execute<TInput, TOutput>(params: {
78
- workflowId: string;
79
- runId: string;
80
- graph: ExecutionGraph;
81
- serializedStepGraph: SerializedStepFlowEntry[];
82
- input?: TInput;
83
- resume?: {
84
- steps: string[];
85
- stepResults: Record<string, StepResult<any, any, any, any>>;
86
- resumePayload: any;
87
- resumePath: number[];
88
- };
89
- emitter: Emitter;
90
- retryConfig?: {
91
- attempts?: number;
92
- delay?: number;
93
- };
94
- runtimeContext: RuntimeContext;
95
- abortController: AbortController;
96
- }): Promise<TOutput>;
97
- protected fmtReturnValue<TOutput>(executionSpan: Span | undefined, emitter: Emitter, stepResults: Record<string, StepResult<any, any, any, any>>, lastOutput: StepResult<any, any, any, any>, error?: Error | string): Promise<TOutput>;
98
- superExecuteStep({ workflowId, runId, step, stepResults, executionContext, resume, prevOutput, emitter, abortController, runtimeContext, writableStream, }: {
99
- workflowId: string;
100
- runId: string;
101
- step: Step<string, any, any>;
102
- stepResults: Record<string, StepResult<any, any, any, any>>;
103
- executionContext: ExecutionContext;
104
- resume?: {
105
- steps: string[];
106
- resumePayload: any;
107
- };
108
- prevOutput: any;
109
- emitter: Emitter;
110
- abortController: AbortController;
111
- runtimeContext: RuntimeContext;
112
- writableStream?: WritableStream<ChunkType>;
113
- }): Promise<StepResult<any, any, any, any>>;
114
- executeSleep({ workflowId, runId, entry, prevOutput, stepResults, emitter, abortController, runtimeContext, writableStream, }: {
115
- workflowId: string;
116
- runId: string;
117
- serializedStepGraph: SerializedStepFlowEntry[];
118
- entry: {
119
- type: 'sleep';
120
- id: string;
121
- duration?: number;
122
- fn?: ExecuteFunction<any, any, any, any, InngestEngineType>;
123
- };
124
- prevStep: StepFlowEntry;
125
- prevOutput: any;
126
- stepResults: Record<string, StepResult<any, any, any, any>>;
127
- resume?: {
128
- steps: string[];
129
- stepResults: Record<string, StepResult<any, any, any, any>>;
130
- resumePayload: any;
131
- resumePath: number[];
132
- };
133
- executionContext: ExecutionContext;
134
- emitter: Emitter;
135
- abortController: AbortController;
136
- runtimeContext: RuntimeContext;
137
- writableStream?: WritableStream<ChunkType>;
138
- }): Promise<void>;
139
- executeSleepUntil({ workflowId, runId, entry, prevOutput, stepResults, emitter, abortController, runtimeContext, writableStream, }: {
140
- workflowId: string;
141
- runId: string;
142
- serializedStepGraph: SerializedStepFlowEntry[];
143
- entry: {
144
- type: 'sleepUntil';
145
- id: string;
146
- date?: Date;
147
- fn?: ExecuteFunction<any, any, any, any, InngestEngineType>;
148
- };
149
- prevStep: StepFlowEntry;
150
- prevOutput: any;
151
- stepResults: Record<string, StepResult<any, any, any, any>>;
152
- resume?: {
153
- steps: string[];
154
- stepResults: Record<string, StepResult<any, any, any, any>>;
155
- resumePayload: any;
156
- resumePath: number[];
157
- };
158
- executionContext: ExecutionContext;
159
- emitter: Emitter;
160
- abortController: AbortController;
161
- runtimeContext: RuntimeContext;
162
- writableStream?: WritableStream<ChunkType>;
163
- }): Promise<void>;
164
- executeWaitForEvent({ event, timeout }: {
165
- event: string;
166
- timeout?: number;
167
- }): Promise<any>;
168
- executeStep({ step, stepResults, executionContext, resume, prevOutput, emitter, abortController, runtimeContext, writableStream, }: {
169
- step: Step<string, any, any>;
170
- stepResults: Record<string, StepResult<any, any, any, any>>;
171
- executionContext: ExecutionContext;
172
- resume?: {
173
- steps: string[];
174
- resumePayload: any;
175
- runId?: string;
176
- };
177
- prevOutput: any;
178
- emitter: Emitter;
179
- abortController: AbortController;
180
- runtimeContext: RuntimeContext;
181
- writableStream?: WritableStream<ChunkType>;
182
- }): Promise<StepResult<any, any, any, any>>;
183
- persistStepUpdate({ workflowId, runId, stepResults, executionContext, serializedStepGraph, workflowStatus, result, error, }: {
184
- workflowId: string;
185
- runId: string;
186
- stepResults: Record<string, StepResult<any, any, any, any>>;
187
- serializedStepGraph: SerializedStepFlowEntry[];
188
- executionContext: ExecutionContext;
189
- workflowStatus: 'success' | 'failed' | 'suspended' | 'running';
190
- result?: Record<string, any>;
191
- error?: string | Error;
192
- runtimeContext: RuntimeContext;
193
- }): Promise<void>;
194
- executeConditional({ workflowId, runId, entry, prevOutput, prevStep, stepResults, serializedStepGraph, resume, executionContext, emitter, abortController, runtimeContext, writableStream, }: {
195
- workflowId: string;
196
- runId: string;
197
- entry: {
198
- type: 'conditional';
199
- steps: StepFlowEntry[];
200
- conditions: ExecuteFunction<any, any, any, any, InngestEngineType>[];
201
- };
202
- prevStep: StepFlowEntry;
203
- serializedStepGraph: SerializedStepFlowEntry[];
204
- prevOutput: any;
205
- stepResults: Record<string, StepResult<any, any, any, any>>;
206
- resume?: {
207
- steps: string[];
208
- stepResults: Record<string, StepResult<any, any, any, any>>;
209
- resumePayload: any;
210
- resumePath: number[];
211
- };
212
- executionContext: ExecutionContext;
213
- emitter: Emitter;
214
- abortController: AbortController;
215
- runtimeContext: RuntimeContext;
216
- writableStream?: WritableStream<ChunkType>;
217
- }): Promise<StepResult<any, any, any, any>>;
218
- }
219
-
220
- 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> {
221
- #private;
222
- private inngest;
223
- serializedStepGraph: SerializedStepFlowEntry[];
224
- constructor(params: {
225
- workflowId: string;
226
- runId: string;
227
- executionEngine: ExecutionEngine;
228
- executionGraph: ExecutionGraph;
229
- serializedStepGraph: SerializedStepFlowEntry[];
230
- mastra?: Mastra;
231
- retryConfig?: {
232
- attempts?: number;
233
- delay?: number;
234
- };
235
- cleanup?: () => void;
236
- }, inngest: Inngest);
237
- getRuns(eventId: string): Promise<any>;
238
- getRunOutput(eventId: string): Promise<any>;
239
- sendEvent(event: string, data: any): Promise<void>;
240
- cancel(): Promise<void>;
241
- start({ inputData, }: {
242
- inputData?: z.infer<TInput>;
243
- runtimeContext?: RuntimeContext;
244
- }): Promise<WorkflowResult<TOutput, TSteps>>;
245
- resume<TResumeSchema extends z.ZodType<any>>(params: {
246
- resumeData?: z.infer<TResumeSchema>;
247
- step: Step<string, any, any, TResumeSchema, any> | [...Step<string, any, any, any, any>[], Step<string, any, any, TResumeSchema, any>] | string | string[];
248
- runtimeContext?: RuntimeContext;
249
- }): Promise<WorkflowResult<TOutput, TSteps>>;
250
- _resume<TResumeSchema extends z.ZodType<any>>(params: {
251
- resumeData?: z.infer<TResumeSchema>;
252
- step: Step<string, any, any, TResumeSchema, any> | [...Step<string, any, any, any, any>[], Step<string, any, any, TResumeSchema, any>] | string | string[];
253
- runtimeContext?: RuntimeContext;
254
- }): Promise<WorkflowResult<TOutput, TSteps>>;
255
- watch(cb: (event: WatchEvent) => void, type?: 'watch' | 'watch-v2'): () => void;
256
- stream({ inputData, runtimeContext }?: {
257
- inputData?: z.infer<TInput>;
258
- runtimeContext?: RuntimeContext;
259
- }): {
260
- stream: ReadableStream_2<StreamEvent>;
261
- getWorkflowState: () => Promise<WorkflowResult<TOutput, TSteps>>;
262
- };
263
- }
264
-
265
- 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> {
266
- #private;
267
- inngest: Inngest;
268
- private function;
269
- constructor(params: WorkflowConfig<TWorkflowId, TInput, TOutput, TSteps>, inngest: Inngest);
270
- getWorkflowRuns(args?: {
271
- fromDate?: Date;
272
- toDate?: Date;
273
- limit?: number;
274
- offset?: number;
275
- resourceId?: string;
276
- }): Promise<WorkflowRuns>;
277
- getWorkflowRunById(runId: string): Promise<WorkflowRun | null>;
278
- getWorkflowRunExecutionResult(runId: string): Promise<WatchEvent['payload']['workflowState'] | null>;
279
- __registerMastra(mastra: Mastra): void;
280
- createRun(options?: {
281
- runId?: string;
282
- }): Run<TEngineType, TSteps, TInput, TOutput>;
283
- createRunAsync(options?: {
284
- runId?: string;
285
- }): Promise<Run<TEngineType, TSteps, TInput, TOutput>>;
286
- getFunction(): InngestFunction<Omit<InngestFunction.Options<Inngest<ClientOptions>, InngestMiddleware.Stack, InngestFunction.Trigger<string>[] | [{
287
- cron: string;
288
- } & Partial<Record<"event" | "if", never>>] | [{
289
- event: string;
290
- if?: string;
291
- } & Partial<Record<"cron", never>>], Handler.Any>, "triggers">, Handler.Any, Handler.Any, Inngest<ClientOptions>, InngestMiddleware.Stack, InngestFunction.Trigger<string>[] | [{
292
- cron: string;
293
- } & Partial<Record<"event" | "if", never>>] | [{
294
- event: string;
295
- if?: string;
296
- } & Partial<Record<"cron", never>>]>;
297
- getNestedFunctions(steps: StepFlowEntry[]): ReturnType<Inngest['createFunction']>[];
298
- getFunctions(): InngestFunction<Omit<InngestFunction.Options<Inngest<ClientOptions>, InngestMiddleware.Stack, InngestFunction.Trigger<string>[] | [{
299
- cron: string;
300
- } & Partial<Record<"event" | "if", never>>] | [{
301
- event: string;
302
- if?: string;
303
- } & Partial<Record<"cron", never>>], Handler.Any>, "triggers">, Handler.Any, Handler.Any, Inngest<ClientOptions>, InngestMiddleware.Stack, InngestFunction.Trigger<string>[] | [{
304
- cron: string;
305
- } & Partial<Record<"event" | "if", never>>] | [{
306
- event: string;
307
- if?: string;
308
- } & Partial<Record<"cron", never>>]>[];
309
- }
310
-
311
- export declare function serve({ mastra, inngest }: {
312
- mastra: Mastra;
313
- inngest: Inngest;
314
- }): ReturnType<typeof serve_2>;
315
-
316
- export { }
package/dist/index.d.cts DELETED
@@ -1,7 +0,0 @@
1
- export { serve } from './_tsup-dts-rollup.cjs';
2
- export { createStep } from './_tsup-dts-rollup.cjs';
3
- export { init } from './_tsup-dts-rollup.cjs';
4
- export { InngestEngineType } from './_tsup-dts-rollup.cjs';
5
- export { InngestRun } from './_tsup-dts-rollup.cjs';
6
- export { InngestWorkflow } from './_tsup-dts-rollup.cjs';
7
- export { InngestExecutionEngine } from './_tsup-dts-rollup.cjs';