@mastra/inngest 0.10.3 → 0.10.5-alpha.0

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,23 +1,23 @@
1
1
 
2
- > @mastra/inngest@0.10.3-alpha.0 build /home/runner/work/mastra/mastra/workflows/inngest
2
+ > @mastra/inngest@0.10.5-alpha.0 build /home/runner/work/mastra/mastra/workflows/inngest
3
3
  > tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting
4
4
 
5
5
  CLI Building entry: src/index.ts
6
6
  CLI Using tsconfig: tsconfig.json
7
7
  CLI tsup v8.5.0
8
8
  TSC Build start
9
- TSC ⚡️ Build success in 8132ms
9
+ TSC ⚡️ Build success in 8463ms
10
10
  DTS Build start
11
11
  CLI Target: es2022
12
12
  Analysis will use the bundled TypeScript version 5.8.3
13
13
  Writing package typings: /home/runner/work/mastra/mastra/workflows/inngest/dist/_tsup-dts-rollup.d.ts
14
14
  Analysis will use the bundled TypeScript version 5.8.3
15
15
  Writing package typings: /home/runner/work/mastra/mastra/workflows/inngest/dist/_tsup-dts-rollup.d.cts
16
- DTS ⚡️ Build success in 7089ms
16
+ DTS ⚡️ Build success in 6163ms
17
17
  CLI Cleaning output folder
18
18
  ESM Build start
19
19
  CJS Build start
20
- ESM dist/index.js 22.54 KB
21
- ESM ⚡️ Build success in 343ms
22
- CJS dist/index.cjs 22.68 KB
23
- CJS ⚡️ Build success in 344ms
20
+ ESM dist/index.js 25.94 KB
21
+ ESM ⚡️ Build success in 270ms
22
+ CJS dist/index.cjs 26.13 KB
23
+ CJS ⚡️ Build success in 271ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @mastra/inngest
2
2
 
3
+ ## 0.10.5-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 63f6b7d: dependencies updates:
8
+ - Updated dependency [`inngest@^3.39.1` ↗︎](https://www.npmjs.com/package/inngest/v/3.39.1) (from `^3.35.1`, in `dependencies`)
9
+ - Updated dependency [`zod@^3.25.57` ↗︎](https://www.npmjs.com/package/zod/v/3.25.57) (from `^3.25.56`, in `dependencies`)
10
+ - Updated dependencies [63f6b7d]
11
+ - Updated dependencies [36f1c36]
12
+ - Updated dependencies [10d352e]
13
+ - Updated dependencies [53d3c37]
14
+ - @mastra/core@0.10.6-alpha.0
15
+
16
+ ## 0.10.4
17
+
18
+ ### Patch Changes
19
+
20
+ - 13c97f9: Save run status, result and error in storage snapshot
21
+ - Updated dependencies [13c97f9]
22
+ - @mastra/core@0.10.5
23
+
3
24
  ## 0.10.3
4
25
 
5
26
  ### Patch Changes
@@ -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';
@@ -20,22 +19,50 @@ import type { Span } from '@opentelemetry/api';
20
19
  import type { Step } from '@mastra/core/workflows';
21
20
  import type { StepFlowEntry } from '@mastra/core/workflows';
22
21
  import type { StepResult } from '@mastra/core/workflows';
22
+ import { Tool } from '@mastra/core';
23
+ import type { ToolExecutionContext } from '@mastra/core';
23
24
  import { Workflow } from '@mastra/core/workflows';
24
25
  import type { WorkflowConfig } from '@mastra/core/workflows';
25
26
  import type { WorkflowResult } from '@mastra/core/workflows';
26
27
  import type { WorkflowRun } from '@mastra/core';
27
28
  import type { WorkflowRuns } from '@mastra/core';
28
- import type { z } from 'zod';
29
+ import { z } from 'zod';
29
30
 
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>;
31
+ 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: {
32
+ id: TStepId;
33
+ description?: string;
34
+ inputSchema: TStepInput;
35
+ outputSchema: TStepOutput;
36
+ resumeSchema?: TResumeSchema;
37
+ suspendSchema?: TSuspendSchema;
38
+ execute: ExecuteFunction<z.infer<TStepInput>, z.infer<TStepOutput>, z.infer<TResumeSchema>, z.infer<TSuspendSchema>, InngestEngineType>;
39
+ }): Step<TStepId, TStepInput, TStepOutput, TResumeSchema, TSuspendSchema, InngestEngineType>;
40
+
41
+ export declare function createStep<TStepId extends string, TStepInput extends z.ZodObject<{
42
+ prompt: z.ZodString;
43
+ }>, TStepOutput extends z.ZodObject<{
44
+ text: z.ZodString;
45
+ }>, TResumeSchema extends z.ZodType<any>, TSuspendSchema extends z.ZodType<any>>(agent: Agent<TStepId, any, any>): Step<TStepId, TStepInput, TStepOutput, TResumeSchema, TSuspendSchema, InngestEngineType>;
46
+
47
+ export declare function createStep<TSchemaIn extends z.ZodType<any>, TSchemaOut extends z.ZodType<any>, TContext extends ToolExecutionContext<TSchemaIn>>(tool: Tool<TSchemaIn, TSchemaOut, TContext> & {
48
+ inputSchema: TSchemaIn;
49
+ outputSchema: TSchemaOut;
50
+ execute: (context: TContext) => Promise<any>;
51
+ }): Step<string, TSchemaIn, TSchemaOut, z.ZodType<any>, z.ZodType<any>, InngestEngineType>;
33
52
 
34
53
  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>;
54
+ 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
55
  createStep: typeof createStep;
37
- cloneStep: typeof cloneStep;
38
- cloneWorkflow: typeof cloneWorkflow;
56
+ cloneStep<TStepId extends string>(step: Step<string, any, any, any, any, InngestEngineType>, opts: {
57
+ id: TStepId;
58
+ }): Step<TStepId, any, any, any, any, InngestEngineType>;
59
+ 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: {
60
+ id: TWorkflowId;
61
+ }): Workflow<InngestEngineType, TSteps, TWorkflowId, TInput, TOutput, TInput>;
62
+ };
63
+
64
+ export declare type InngestEngineType = {
65
+ step: any;
39
66
  };
40
67
 
41
68
  export declare class InngestExecutionEngine extends DefaultExecutionEngine {
@@ -61,6 +88,10 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
61
88
  };
62
89
  runtimeContext: RuntimeContext;
63
90
  }): Promise<StepResult<any, any, any, any>>;
91
+ executeSleep({ id, duration }: {
92
+ id: string;
93
+ duration: number;
94
+ }): Promise<void>;
64
95
  executeStep({ step, stepResults, executionContext, resume, prevOutput, emitter, runtimeContext, }: {
65
96
  step: Step<string, any, any>;
66
97
  stepResults: Record<string, StepResult<any, any, any, any>>;
@@ -85,12 +116,15 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
85
116
  };
86
117
  runtimeContext: RuntimeContext;
87
118
  }): Promise<StepResult<any, any, any, any>>;
88
- persistStepUpdate({ workflowId, runId, stepResults, executionContext, serializedStepGraph, }: {
119
+ persistStepUpdate({ workflowId, runId, stepResults, executionContext, serializedStepGraph, workflowStatus, result, error, }: {
89
120
  workflowId: string;
90
121
  runId: string;
91
122
  stepResults: Record<string, StepResult<any, any, any, any>>;
92
123
  serializedStepGraph: SerializedStepFlowEntry[];
93
124
  executionContext: ExecutionContext;
125
+ workflowStatus: 'success' | 'failed' | 'suspended' | 'running';
126
+ result?: Record<string, any>;
127
+ error?: string | Error;
94
128
  }): Promise<void>;
95
129
  executeConditional({ workflowId, runId, entry, prevOutput, prevStep, stepResults, serializedStepGraph, resume, executionContext, emitter, runtimeContext, }: {
96
130
  workflowId: string;
@@ -98,7 +132,7 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
98
132
  entry: {
99
133
  type: 'conditional';
100
134
  steps: StepFlowEntry[];
101
- conditions: ExecuteFunction<any, any, any, any>[];
135
+ conditions: ExecuteFunction<any, any, any, any, InngestEngineType>[];
102
136
  };
103
137
  prevStep: StepFlowEntry;
104
138
  serializedStepGraph: SerializedStepFlowEntry[];
@@ -118,7 +152,7 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
118
152
  }): Promise<StepResult<any, any, any, any>>;
119
153
  }
120
154
 
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> {
155
+ 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
156
  #private;
123
157
  private inngest;
124
158
  serializedStepGraph: SerializedStepFlowEntry[];
@@ -149,7 +183,7 @@ export declare class InngestRun<TSteps extends Step<string, any, any>[] = Step<s
149
183
  watch(cb: (event: any) => void): () => void;
150
184
  }
151
185
 
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> {
186
+ 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
187
  #private;
154
188
  inngest: Inngest;
155
189
  private function;
@@ -165,7 +199,7 @@ export declare class InngestWorkflow<TSteps extends Step<string, any, any>[] = S
165
199
  __registerMastra(mastra: Mastra): void;
166
200
  createRun(options?: {
167
201
  runId?: string;
168
- }): Run<TSteps, TInput, TOutput>;
202
+ }): Run<TEngineType, TSteps, TInput, TOutput>;
169
203
  getFunction(): InngestFunction<Omit<InngestFunction.Options<Inngest<ClientOptions>, InngestMiddleware.Stack, InngestFunction.Trigger<string>[] | [{
170
204
  cron: string;
171
205
  } & 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';
@@ -20,22 +19,50 @@ import type { Span } from '@opentelemetry/api';
20
19
  import type { Step } from '@mastra/core/workflows';
21
20
  import type { StepFlowEntry } from '@mastra/core/workflows';
22
21
  import type { StepResult } from '@mastra/core/workflows';
22
+ import { Tool } from '@mastra/core';
23
+ import type { ToolExecutionContext } from '@mastra/core';
23
24
  import { Workflow } from '@mastra/core/workflows';
24
25
  import type { WorkflowConfig } from '@mastra/core/workflows';
25
26
  import type { WorkflowResult } from '@mastra/core/workflows';
26
27
  import type { WorkflowRun } from '@mastra/core';
27
28
  import type { WorkflowRuns } from '@mastra/core';
28
- import type { z } from 'zod';
29
+ import { z } from 'zod';
29
30
 
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>;
31
+ 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: {
32
+ id: TStepId;
33
+ description?: string;
34
+ inputSchema: TStepInput;
35
+ outputSchema: TStepOutput;
36
+ resumeSchema?: TResumeSchema;
37
+ suspendSchema?: TSuspendSchema;
38
+ execute: ExecuteFunction<z.infer<TStepInput>, z.infer<TStepOutput>, z.infer<TResumeSchema>, z.infer<TSuspendSchema>, InngestEngineType>;
39
+ }): Step<TStepId, TStepInput, TStepOutput, TResumeSchema, TSuspendSchema, InngestEngineType>;
40
+
41
+ export declare function createStep<TStepId extends string, TStepInput extends z.ZodObject<{
42
+ prompt: z.ZodString;
43
+ }>, TStepOutput extends z.ZodObject<{
44
+ text: z.ZodString;
45
+ }>, TResumeSchema extends z.ZodType<any>, TSuspendSchema extends z.ZodType<any>>(agent: Agent<TStepId, any, any>): Step<TStepId, TStepInput, TStepOutput, TResumeSchema, TSuspendSchema, InngestEngineType>;
46
+
47
+ export declare function createStep<TSchemaIn extends z.ZodType<any>, TSchemaOut extends z.ZodType<any>, TContext extends ToolExecutionContext<TSchemaIn>>(tool: Tool<TSchemaIn, TSchemaOut, TContext> & {
48
+ inputSchema: TSchemaIn;
49
+ outputSchema: TSchemaOut;
50
+ execute: (context: TContext) => Promise<any>;
51
+ }): Step<string, TSchemaIn, TSchemaOut, z.ZodType<any>, z.ZodType<any>, InngestEngineType>;
33
52
 
34
53
  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>;
54
+ 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
55
  createStep: typeof createStep;
37
- cloneStep: typeof cloneStep;
38
- cloneWorkflow: typeof cloneWorkflow;
56
+ cloneStep<TStepId extends string>(step: Step<string, any, any, any, any, InngestEngineType>, opts: {
57
+ id: TStepId;
58
+ }): Step<TStepId, any, any, any, any, InngestEngineType>;
59
+ 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: {
60
+ id: TWorkflowId;
61
+ }): Workflow<InngestEngineType, TSteps, TWorkflowId, TInput, TOutput, TInput>;
62
+ };
63
+
64
+ export declare type InngestEngineType = {
65
+ step: any;
39
66
  };
40
67
 
41
68
  export declare class InngestExecutionEngine extends DefaultExecutionEngine {
@@ -61,6 +88,10 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
61
88
  };
62
89
  runtimeContext: RuntimeContext;
63
90
  }): Promise<StepResult<any, any, any, any>>;
91
+ executeSleep({ id, duration }: {
92
+ id: string;
93
+ duration: number;
94
+ }): Promise<void>;
64
95
  executeStep({ step, stepResults, executionContext, resume, prevOutput, emitter, runtimeContext, }: {
65
96
  step: Step<string, any, any>;
66
97
  stepResults: Record<string, StepResult<any, any, any, any>>;
@@ -85,12 +116,15 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
85
116
  };
86
117
  runtimeContext: RuntimeContext;
87
118
  }): Promise<StepResult<any, any, any, any>>;
88
- persistStepUpdate({ workflowId, runId, stepResults, executionContext, serializedStepGraph, }: {
119
+ persistStepUpdate({ workflowId, runId, stepResults, executionContext, serializedStepGraph, workflowStatus, result, error, }: {
89
120
  workflowId: string;
90
121
  runId: string;
91
122
  stepResults: Record<string, StepResult<any, any, any, any>>;
92
123
  serializedStepGraph: SerializedStepFlowEntry[];
93
124
  executionContext: ExecutionContext;
125
+ workflowStatus: 'success' | 'failed' | 'suspended' | 'running';
126
+ result?: Record<string, any>;
127
+ error?: string | Error;
94
128
  }): Promise<void>;
95
129
  executeConditional({ workflowId, runId, entry, prevOutput, prevStep, stepResults, serializedStepGraph, resume, executionContext, emitter, runtimeContext, }: {
96
130
  workflowId: string;
@@ -98,7 +132,7 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
98
132
  entry: {
99
133
  type: 'conditional';
100
134
  steps: StepFlowEntry[];
101
- conditions: ExecuteFunction<any, any, any, any>[];
135
+ conditions: ExecuteFunction<any, any, any, any, InngestEngineType>[];
102
136
  };
103
137
  prevStep: StepFlowEntry;
104
138
  serializedStepGraph: SerializedStepFlowEntry[];
@@ -118,7 +152,7 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
118
152
  }): Promise<StepResult<any, any, any, any>>;
119
153
  }
120
154
 
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> {
155
+ 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
156
  #private;
123
157
  private inngest;
124
158
  serializedStepGraph: SerializedStepFlowEntry[];
@@ -149,7 +183,7 @@ export declare class InngestRun<TSteps extends Step<string, any, any>[] = Step<s
149
183
  watch(cb: (event: any) => void): () => void;
150
184
  }
151
185
 
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> {
186
+ 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
187
  #private;
154
188
  inngest: Inngest;
155
189
  private function;
@@ -165,7 +199,7 @@ export declare class InngestWorkflow<TSteps extends Step<string, any, any>[] = S
165
199
  __registerMastra(mastra: Mastra): void;
166
200
  createRun(options?: {
167
201
  runId?: string;
168
- }): Run<TSteps, TInput, TOutput>;
202
+ }): Run<TEngineType, TSteps, TInput, TOutput>;
169
203
  getFunction(): InngestFunction<Omit<InngestFunction.Options<Inngest<ClientOptions>, InngestMiddleware.Stack, InngestFunction.Trigger<string>[] | [{
170
204
  cron: string;
171
205
  } & Partial<Record<"event" | "if", never>>] | [{
package/dist/index.cjs CHANGED
@@ -2,10 +2,12 @@
2
2
 
3
3
  var crypto = require('crypto');
4
4
  var realtime = require('@inngest/realtime');
5
+ var core = require('@mastra/core');
5
6
  var di = require('@mastra/core/di');
6
7
  var workflows = require('@mastra/core/workflows');
7
8
  var _constants = require('@mastra/core/workflows/_constants');
8
9
  var hono = require('inngest/hono');
10
+ var zod = require('zod');
9
11
 
10
12
  // src/index.ts
11
13
  function serve({ mastra, inngest }) {
@@ -65,7 +67,8 @@ var InngestRun = class extends workflows.Run {
65
67
  context: {},
66
68
  activePaths: [],
67
69
  suspendedPaths: {},
68
- timestamp: Date.now()
70
+ timestamp: Date.now(),
71
+ status: "running"
69
72
  }
70
73
  });
71
74
  const eventOutput = await this.inngest.send({
@@ -269,29 +272,128 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
269
272
  return [this.getFunction(), ...this.getNestedFunctions(this.executionGraph.steps)];
270
273
  }
271
274
  };
272
- function cloneWorkflow(workflow, opts) {
273
- const wf = new InngestWorkflow(
274
- {
275
- id: opts.id,
276
- inputSchema: workflow.inputSchema,
277
- outputSchema: workflow.outputSchema,
278
- steps: workflow.stepDefs,
279
- mastra: workflow.mastra
280
- },
281
- workflow.inngest
282
- );
283
- wf.setStepFlow(workflow.stepGraph);
284
- wf.commit();
285
- return wf;
275
+ function createStep(params) {
276
+ if (params instanceof core.Agent) {
277
+ return {
278
+ id: params.name,
279
+ // @ts-ignore
280
+ inputSchema: zod.z.object({
281
+ prompt: zod.z.string()
282
+ // resourceId: z.string().optional(),
283
+ // threadId: z.string().optional(),
284
+ }),
285
+ // @ts-ignore
286
+ outputSchema: zod.z.object({
287
+ text: zod.z.string()
288
+ }),
289
+ execute: async ({ inputData, [_constants.EMITTER_SYMBOL]: emitter, runtimeContext }) => {
290
+ let streamPromise = {};
291
+ streamPromise.promise = new Promise((resolve, reject) => {
292
+ streamPromise.resolve = resolve;
293
+ streamPromise.reject = reject;
294
+ });
295
+ const toolData = {
296
+ name: params.name,
297
+ args: inputData
298
+ };
299
+ await emitter.emit("watch-v2", {
300
+ type: "tool-call-streaming-start",
301
+ ...toolData
302
+ });
303
+ const { fullStream } = await params.stream(inputData.prompt, {
304
+ // resourceId: inputData.resourceId,
305
+ // threadId: inputData.threadId,
306
+ runtimeContext,
307
+ onFinish: (result) => {
308
+ streamPromise.resolve(result.text);
309
+ }
310
+ });
311
+ for await (const chunk of fullStream) {
312
+ switch (chunk.type) {
313
+ case "text-delta":
314
+ await emitter.emit("watch-v2", {
315
+ type: "tool-call-delta",
316
+ ...toolData,
317
+ argsTextDelta: chunk.textDelta
318
+ });
319
+ break;
320
+ case "step-start":
321
+ case "step-finish":
322
+ case "finish":
323
+ break;
324
+ case "tool-call":
325
+ case "tool-result":
326
+ case "tool-call-streaming-start":
327
+ case "tool-call-delta":
328
+ case "source":
329
+ case "file":
330
+ default:
331
+ await emitter.emit("watch-v2", chunk);
332
+ break;
333
+ }
334
+ }
335
+ return {
336
+ text: await streamPromise.promise
337
+ };
338
+ }
339
+ };
340
+ }
341
+ if (params instanceof core.Tool) {
342
+ if (!params.inputSchema || !params.outputSchema) {
343
+ throw new Error("Tool must have input and output schemas defined");
344
+ }
345
+ return {
346
+ // TODO: tool probably should have strong id type
347
+ // @ts-ignore
348
+ id: params.id,
349
+ inputSchema: params.inputSchema,
350
+ outputSchema: params.outputSchema,
351
+ execute: async ({ inputData, mastra, runtimeContext }) => {
352
+ return params.execute({
353
+ context: inputData,
354
+ mastra,
355
+ runtimeContext
356
+ });
357
+ }
358
+ };
359
+ }
360
+ return {
361
+ id: params.id,
362
+ description: params.description,
363
+ inputSchema: params.inputSchema,
364
+ outputSchema: params.outputSchema,
365
+ resumeSchema: params.resumeSchema,
366
+ suspendSchema: params.suspendSchema,
367
+ execute: params.execute
368
+ };
286
369
  }
287
370
  function init(inngest) {
288
371
  return {
289
372
  createWorkflow(params) {
290
373
  return new InngestWorkflow(params, inngest);
291
374
  },
292
- createStep: workflows.createStep,
293
- cloneStep: workflows.cloneStep,
294
- cloneWorkflow
375
+ createStep,
376
+ cloneStep(step, opts) {
377
+ return {
378
+ id: opts.id,
379
+ description: step.description,
380
+ inputSchema: step.inputSchema,
381
+ outputSchema: step.outputSchema,
382
+ execute: step.execute
383
+ };
384
+ },
385
+ cloneWorkflow(workflow, opts) {
386
+ const wf = new workflows.Workflow({
387
+ id: opts.id,
388
+ inputSchema: workflow.inputSchema,
389
+ outputSchema: workflow.outputSchema,
390
+ steps: workflow.stepDefs,
391
+ mastra: workflow.mastra
392
+ });
393
+ wf.setStepFlow(workflow.stepGraph);
394
+ wf.commit();
395
+ return wf;
396
+ }
295
397
  };
296
398
  }
297
399
  var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
@@ -382,6 +484,9 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
382
484
  runtimeContext
383
485
  });
384
486
  }
487
+ async executeSleep({ id, duration }) {
488
+ await this.inngestStep.sleep(id, duration);
489
+ }
385
490
  async executeStep({
386
491
  step,
387
492
  stepResults,
@@ -585,7 +690,10 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
585
690
  // @ts-ignore
586
691
  runId: stepResults[step.id]?.payload?.__workflow_meta?.runId
587
692
  },
588
- emitter
693
+ [_constants.EMITTER_SYMBOL]: emitter,
694
+ engine: {
695
+ step: this.inngestStep
696
+ }
589
697
  });
590
698
  execResults = { status: "success", output: result };
591
699
  } catch (e) {
@@ -627,7 +735,10 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
627
735
  runId,
628
736
  stepResults,
629
737
  executionContext,
630
- serializedStepGraph
738
+ serializedStepGraph,
739
+ workflowStatus,
740
+ result,
741
+ error
631
742
  }) {
632
743
  await this.inngestStep.run(
633
744
  `workflow.${workflowId}.run.${runId}.path.${JSON.stringify(executionContext.executionPath)}.stepUpdate`,
@@ -642,6 +753,9 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
642
753
  activePaths: [],
643
754
  suspendedPaths: executionContext.suspendedPaths,
644
755
  serializedStepGraph,
756
+ status: workflowStatus,
757
+ result,
758
+ error,
645
759
  // @ts-ignore
646
760
  timestamp: Date.now()
647
761
  }
@@ -686,7 +800,10 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
686
800
  // TODO: this function shouldn't have suspend probably?
687
801
  suspend: async (_suspendPayload) => {
688
802
  },
689
- [_constants.EMITTER_SYMBOL]: emitter
803
+ [_constants.EMITTER_SYMBOL]: emitter,
804
+ engine: {
805
+ step: this.inngestStep
806
+ }
690
807
  });
691
808
  return result ? index : null;
692
809
  } catch (e) {
@@ -719,17 +836,17 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
719
836
  })
720
837
  )
721
838
  );
722
- const hasFailed = results.find((result) => result.status === "failed");
723
- const hasSuspended = results.find((result) => result.status === "suspended");
839
+ const hasFailed = results.find((result) => result.result.status === "failed");
840
+ const hasSuspended = results.find((result) => result.result.status === "suspended");
724
841
  if (hasFailed) {
725
- execResults = { status: "failed", error: hasFailed.error };
842
+ execResults = { status: "failed", error: hasFailed.result.error };
726
843
  } else if (hasSuspended) {
727
- execResults = { status: "suspended", payload: hasSuspended.payload };
844
+ execResults = { status: "suspended", payload: hasSuspended.result.payload };
728
845
  } else {
729
846
  execResults = {
730
847
  status: "success",
731
848
  output: results.reduce((acc, result, index) => {
732
- if (result.status === "success") {
849
+ if (result.result.status === "success") {
733
850
  acc[stepsToRun[index].step.id] = result.output;
734
851
  }
735
852
  return acc;
@@ -743,5 +860,6 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
743
860
  exports.InngestExecutionEngine = InngestExecutionEngine;
744
861
  exports.InngestRun = InngestRun;
745
862
  exports.InngestWorkflow = InngestWorkflow;
863
+ exports.createStep = createStep;
746
864
  exports.init = init;
747
865
  exports.serve = serve;
package/dist/index.d.cts CHANGED
@@ -1,5 +1,7 @@
1
1
  export { serve } from './_tsup-dts-rollup.cjs';
2
+ export { createStep } from './_tsup-dts-rollup.cjs';
2
3
  export { init } from './_tsup-dts-rollup.cjs';
4
+ export { InngestEngineType } from './_tsup-dts-rollup.cjs';
3
5
  export { InngestRun } from './_tsup-dts-rollup.cjs';
4
6
  export { InngestWorkflow } from './_tsup-dts-rollup.cjs';
5
7
  export { InngestExecutionEngine } from './_tsup-dts-rollup.cjs';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  export { serve } from './_tsup-dts-rollup.js';
2
+ export { createStep } from './_tsup-dts-rollup.js';
2
3
  export { init } from './_tsup-dts-rollup.js';
4
+ export { InngestEngineType } from './_tsup-dts-rollup.js';
3
5
  export { InngestRun } from './_tsup-dts-rollup.js';
4
6
  export { InngestWorkflow } from './_tsup-dts-rollup.js';
5
7
  export { InngestExecutionEngine } from './_tsup-dts-rollup.js';