@mastra/core 0.9.0 → 0.9.1-alpha.1

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.
Files changed (94) hide show
  1. package/dist/agent/index.cjs +2 -2
  2. package/dist/agent/index.d.cts +4 -2
  3. package/dist/agent/index.d.ts +4 -2
  4. package/dist/agent/index.js +1 -1
  5. package/dist/{base-oP3DoUrm.d.cts → base-CZmT-p10.d.cts} +524 -53
  6. package/dist/{base-Bk5V1doj.d.ts → base-DDoWFpFc.d.ts} +524 -53
  7. package/dist/{chunk-NTHHPNOW.js → chunk-34622N67.js} +1 -1
  8. package/dist/{chunk-ATXF6TIO.cjs → chunk-422BXQRT.cjs} +24 -677
  9. package/dist/{chunk-HARYMLZH.js → chunk-4K4DHXRF.js} +6 -658
  10. package/dist/{chunk-N2ONCUUS.js → chunk-6AHC67YY.js} +132 -12
  11. package/dist/chunk-7AGAXO6B.cjs +588 -0
  12. package/dist/{chunk-GEIPVIW4.js → chunk-BFF2O6RO.js} +1 -1
  13. package/dist/{chunk-RASVJ3TR.js → chunk-BU45BMXY.js} +55 -1
  14. package/dist/{chunk-DIZZQ3E5.cjs → chunk-CEXM6WP5.cjs} +2 -2
  15. package/dist/chunk-HNEE7IF4.js +60 -0
  16. package/dist/{chunk-NZDXKMDP.cjs → chunk-LABUWBKX.cjs} +1 -1
  17. package/dist/chunk-MUNFCOMB.cjs +62 -0
  18. package/dist/{chunk-GJWCFDFN.js → chunk-PS2ZF6MA.js} +1 -1
  19. package/dist/{chunk-M472GIT6.js → chunk-SGGPJWRQ.js} +1 -1
  20. package/dist/{chunk-7CSNWYGJ.cjs → chunk-U5DGGGS2.cjs} +2 -2
  21. package/dist/{chunk-W5IA5OGL.cjs → chunk-V7IE36YV.cjs} +58 -4
  22. package/dist/chunk-VMVXIPGW.js +586 -0
  23. package/dist/{chunk-53P5ZBJE.cjs → chunk-YTTBFAQJ.cjs} +2 -2
  24. package/dist/{chunk-KZWBYRXW.cjs → chunk-YZFNMXY4.cjs} +135 -14
  25. package/dist/di/index.cjs +2 -2
  26. package/dist/di/index.d.cts +1 -52
  27. package/dist/di/index.d.ts +1 -52
  28. package/dist/di/index.js +1 -1
  29. package/dist/eval/index.d.cts +4 -2
  30. package/dist/eval/index.d.ts +4 -2
  31. package/dist/index.cjs +60 -55
  32. package/dist/index.d.cts +5 -3
  33. package/dist/index.d.ts +5 -3
  34. package/dist/index.js +10 -9
  35. package/dist/integration/index.cjs +3 -3
  36. package/dist/integration/index.d.cts +4 -2
  37. package/dist/integration/index.d.ts +4 -2
  38. package/dist/integration/index.js +1 -1
  39. package/dist/llm/index.cjs +8 -0
  40. package/dist/llm/index.d.cts +4 -2
  41. package/dist/llm/index.d.ts +4 -2
  42. package/dist/llm/index.js +1 -1
  43. package/dist/mastra/index.cjs +2 -2
  44. package/dist/mastra/index.d.cts +4 -2
  45. package/dist/mastra/index.d.ts +4 -2
  46. package/dist/mastra/index.js +1 -1
  47. package/dist/memory/index.cjs +7 -3
  48. package/dist/memory/index.d.cts +4 -2
  49. package/dist/memory/index.d.ts +4 -2
  50. package/dist/memory/index.js +1 -1
  51. package/dist/network/index.cjs +4 -4
  52. package/dist/network/index.d.cts +4 -2
  53. package/dist/network/index.d.ts +4 -2
  54. package/dist/network/index.js +2 -2
  55. package/dist/relevance/index.cjs +4 -4
  56. package/dist/relevance/index.d.cts +4 -2
  57. package/dist/relevance/index.d.ts +4 -2
  58. package/dist/relevance/index.js +1 -1
  59. package/dist/runtime-context/index.cjs +7 -68
  60. package/dist/runtime-context/index.js +1 -69
  61. package/dist/server/index.d.cts +4 -2
  62. package/dist/server/index.d.ts +4 -2
  63. package/dist/storage/index.d.cts +4 -2
  64. package/dist/storage/index.d.ts +4 -2
  65. package/dist/storage/libsql/index.cjs +19 -0
  66. package/dist/storage/libsql/index.d.cts +7 -8
  67. package/dist/storage/libsql/index.d.ts +7 -8
  68. package/dist/storage/libsql/index.js +19 -0
  69. package/dist/telemetry/index.d.cts +4 -2
  70. package/dist/telemetry/index.d.ts +4 -2
  71. package/dist/tools/index.cjs +4 -4
  72. package/dist/tools/index.d.cts +4 -2
  73. package/dist/tools/index.d.ts +4 -2
  74. package/dist/tools/index.js +1 -1
  75. package/dist/utils.cjs +14 -14
  76. package/dist/utils.d.cts +6 -4
  77. package/dist/utils.d.ts +6 -4
  78. package/dist/utils.js +1 -1
  79. package/dist/voice/index.d.cts +5 -3
  80. package/dist/voice/index.d.ts +5 -3
  81. package/dist/workflows/index.cjs +22 -26
  82. package/dist/workflows/index.d.cts +5 -3
  83. package/dist/workflows/index.d.ts +5 -3
  84. package/dist/workflows/index.js +1 -1
  85. package/dist/workflows/vNext/index.cjs +1058 -0
  86. package/dist/workflows/vNext/index.d.cts +180 -0
  87. package/dist/workflows/vNext/index.d.ts +180 -0
  88. package/dist/workflows/vNext/index.js +1046 -0
  89. package/package.json +11 -1
  90. package/workflows/vNext.d.ts +1 -0
  91. /package/dist/{chunk-WEYWYKLG.cjs → chunk-27PAET7X.cjs} +0 -0
  92. /package/dist/{chunk-FRQFWZDN.cjs → chunk-HSVOEWAM.cjs} +0 -0
  93. /package/dist/{chunk-ZDWFBE5L.js → chunk-NH5WJNNS.js} +0 -0
  94. /package/dist/{chunk-LANFNMEE.js → chunk-SGTFVHOZ.js} +0 -0
@@ -1,22 +1,24 @@
1
1
  import * as ai from 'ai';
2
- import { Tool as Tool$1, ToolExecutionOptions, LanguageModelV1, CoreMessage as CoreMessage$1, GenerateTextResult, GenerateObjectResult, StreamTextResult, StreamObjectResult, EmbeddingModel, Message, UserContent, AssistantContent, TelemetrySettings, generateText, generateObject, streamText, streamObject, CoreSystemMessage as CoreSystemMessage$1, CoreAssistantMessage as CoreAssistantMessage$1, CoreUserMessage as CoreUserMessage$1, CoreToolMessage as CoreToolMessage$1, EmbedResult as EmbedResult$1, EmbedManyResult as EmbedManyResult$1, GenerateTextOnStepFinishCallback, StreamTextOnFinishCallback, StreamObjectOnFinishCallback, StreamTextOnStepFinishCallback, LanguageModel as LanguageModel$1, DeepPartial, ToolContent } from 'ai';
2
+ import { Tool as Tool$1, ToolExecutionOptions, LanguageModelV1, CoreMessage as CoreMessage$1, GenerateTextResult, GenerateObjectResult, StreamTextResult, StreamObjectResult, EmbeddingModel, Message, UserContent, AssistantContent, LanguageModel as LanguageModel$1, DeepPartial, TelemetrySettings, generateText, generateObject, streamText, streamObject, CoreSystemMessage as CoreSystemMessage$1, CoreAssistantMessage as CoreAssistantMessage$1, CoreUserMessage as CoreUserMessage$1, CoreToolMessage as CoreToolMessage$1, EmbedResult as EmbedResult$1, EmbedManyResult as EmbedManyResult$1, GenerateTextOnStepFinishCallback, StreamTextOnFinishCallback, StreamObjectOnFinishCallback, StreamTextOnStepFinishCallback, ToolContent } from 'ai';
3
3
  import { M as MastraBase, T as Telemetry, O as OtelConfig } from './base-DT2poiVK.js';
4
4
  import { a as Metric, M as MetricResult, T as TestInfo } from './types-BtMyV38I.js';
5
5
  import { Query } from 'sift';
6
6
  import { z, ZodSchema } from 'zod';
7
7
  import { JSONSchema7 } from 'json-schema';
8
- import { RuntimeContext } from './di/index.js';
9
- import { B as BaseLogMessage, R as RegisteredLogger, L as Logger, d as Run } from './index-CquI0inB.js';
8
+ import { B as BaseLogMessage, R as RegisteredLogger, L as Logger, d as Run$1 } from './index-CquI0inB.js';
9
+ import { RuntimeContext } from './runtime-context/index.js';
10
10
  import { Span } from '@opentelemetry/api';
11
11
  import * as xstate from 'xstate';
12
12
  import { Snapshot } from 'xstate';
13
13
  import EventEmitter from 'node:events';
14
14
  import { MastraVector } from './vector/index.js';
15
15
  import { MastraTTS } from './tts/index.js';
16
+ import EventEmitter$1 from 'events';
16
17
  import { MastraDeployer } from './deployer/index.js';
17
18
  import { Handler, MiddlewareHandler } from 'hono';
18
19
  import { cors } from 'hono/cors';
19
20
  import { DescribeRouteOptions } from 'hono-openapi';
21
+ import { MockLanguageModelV1 } from 'ai/test';
20
22
 
21
23
  type VercelTool = Tool$1;
22
24
  type CoreTool = {
@@ -51,7 +53,13 @@ declare class Tool<TSchemaIn extends z.ZodSchema | undefined = undefined, TSchem
51
53
  mastra?: Mastra;
52
54
  constructor(opts: ToolAction<TSchemaIn, TSchemaOut, TContext>);
53
55
  }
54
- declare function createTool<TSchemaIn extends z.ZodSchema | undefined = undefined, TSchemaOut extends z.ZodSchema | undefined = undefined, TContext extends ToolExecutionContext<TSchemaIn> = ToolExecutionContext<TSchemaIn>>(opts: ToolAction<TSchemaIn, TSchemaOut, TContext>): Tool<TSchemaIn, TSchemaOut, TContext>;
56
+ declare function createTool<TSchemaIn extends z.ZodSchema | undefined = undefined, TSchemaOut extends z.ZodSchema | undefined = undefined, TContext extends ToolExecutionContext<TSchemaIn> = ToolExecutionContext<TSchemaIn>, TExecute extends ToolAction<TSchemaIn, TSchemaOut, TContext>['execute'] = ToolAction<TSchemaIn, TSchemaOut, TContext>['execute']>(opts: ToolAction<TSchemaIn, TSchemaOut, TContext> & {
57
+ execute?: TExecute;
58
+ }): [TSchemaIn, TSchemaOut, TExecute] extends [z.ZodSchema, z.ZodSchema, Function] ? Tool<TSchemaIn, TSchemaOut, TContext> & {
59
+ inputSchema: TSchemaIn;
60
+ outputSchema: TSchemaOut;
61
+ execute: (context: TContext) => Promise<any>;
62
+ } : Tool<TSchemaIn, TSchemaOut, TContext>;
55
63
 
56
64
  type AgentNetworkConfig = {
57
65
  name: string;
@@ -222,12 +230,12 @@ type RetryConfig = {
222
230
  attempts?: number;
223
231
  delay?: number;
224
232
  };
225
- type VariableReference<TStep extends StepVariableType<any, any, any, any>, TTriggerSchema extends z.ZodObject<any>> = TStep extends StepAction<any, any, any, any> ? {
233
+ type VariableReference$1<TStep extends StepVariableType<any, any, any, any>, TTriggerSchema extends z.ZodObject<any>> = TStep extends StepAction<any, any, any, any> ? {
226
234
  step: TStep;
227
- path: PathsToStringProps<ExtractSchemaType<ExtractSchemaFromStep<TStep, 'outputSchema'>>> | '' | '.';
235
+ path: PathsToStringProps$1<ExtractSchemaType$1<ExtractSchemaFromStep$1<TStep, 'outputSchema'>>> | '' | '.';
228
236
  } : TStep extends 'trigger' ? {
229
237
  step: 'trigger';
230
- path: PathsToStringProps<ExtractSchemaType<TTriggerSchema>> | '.' | '';
238
+ path: PathsToStringProps$1<ExtractSchemaType$1<TTriggerSchema>> | '.' | '';
231
239
  } : {
232
240
  step: {
233
241
  id: string;
@@ -237,10 +245,10 @@ type VariableReference<TStep extends StepVariableType<any, any, any, any>, TTrig
237
245
  interface BaseCondition<TStep extends StepVariableType<any, any, any, any>, TTriggerSchema extends z.ZodObject<any>> {
238
246
  ref: TStep extends StepAction<any, any, any, any> ? {
239
247
  step: TStep;
240
- path: PathsToStringProps<ExtractSchemaType<ExtractSchemaFromStep<TStep, 'outputSchema'>>> | '' | '.' | 'status';
248
+ path: PathsToStringProps$1<ExtractSchemaType$1<ExtractSchemaFromStep$1<TStep, 'outputSchema'>>> | '' | '.' | 'status';
241
249
  } : TStep extends 'trigger' ? {
242
250
  step: 'trigger';
243
- path: PathsToStringProps<ExtractSchemaType<TTriggerSchema>> | '.' | '';
251
+ path: PathsToStringProps$1<ExtractSchemaType$1<TTriggerSchema>> | '.' | '';
244
252
  } : {
245
253
  step: {
246
254
  id: string;
@@ -287,8 +295,8 @@ interface StepConfig<TStep extends StepAction<any, any, any, any>, CondStep exte
287
295
  context: WorkflowContext<TTriggerSchema, TSteps>;
288
296
  mastra?: Mastra;
289
297
  }) => Promise<boolean | WhenConditionReturnValue>);
290
- variables?: StepInputType<TStep, 'inputSchema'> extends never ? Record<string, VariableReference<VarStep, TTriggerSchema>> : {
291
- [K in keyof StepInputType<TStep, 'inputSchema'>]?: VariableReference<VarStep, TTriggerSchema>;
298
+ variables?: StepInputType<TStep, 'inputSchema'> extends never ? Record<string, VariableReference$1<VarStep, TTriggerSchema>> : {
299
+ [K in keyof StepInputType<TStep, 'inputSchema'>]?: VariableReference$1<VarStep, TTriggerSchema>;
292
300
  };
293
301
  '#internal'?: {
294
302
  when?: Condition<CondStep, TTriggerSchema> | ((args: {
@@ -300,11 +308,11 @@ interface StepConfig<TStep extends StepAction<any, any, any, any>, CondStep exte
300
308
  };
301
309
  id?: string;
302
310
  }
303
- type StepSuccess<T> = {
311
+ type StepSuccess$1<T> = {
304
312
  status: 'success';
305
313
  output: T;
306
314
  };
307
- type StepSuspended<T> = {
315
+ type StepSuspended$1<T> = {
308
316
  status: 'suspended';
309
317
  suspendPayload?: any;
310
318
  output?: T;
@@ -312,15 +320,15 @@ type StepSuspended<T> = {
312
320
  type StepWaiting = {
313
321
  status: 'waiting';
314
322
  };
315
- type StepFailure = {
323
+ type StepFailure$1 = {
316
324
  status: 'failed';
317
325
  error: string;
318
326
  };
319
327
  type StepSkipped = {
320
328
  status: 'skipped';
321
329
  };
322
- type StepResult<T> = StepSuccess<T> | StepFailure | StepSuspended<T> | StepWaiting | StepSkipped;
323
- type StepsRecord<T extends readonly Step<any, any, z.ZodType<any> | undefined>[]> = {
330
+ type StepResult$1<T> = StepSuccess$1<T> | StepFailure$1 | StepSuspended$1<T> | StepWaiting | StepSkipped;
331
+ type StepsRecord$1<T extends readonly Step<any, any, z.ZodType<any> | undefined>[]> = {
324
332
  [K in T[number]['id']]: Extract<T[number], {
325
333
  id: K;
326
334
  }>;
@@ -329,11 +337,11 @@ interface WorkflowRunResult<T extends z.ZodObject<any>, TSteps extends Step<stri
329
337
  triggerData?: z.infer<T>;
330
338
  result?: z.infer<TResult>;
331
339
  results: {
332
- [K in keyof StepsRecord<TSteps>]: StepsRecord<TSteps>[K]['outputSchema'] extends undefined ? StepResult<unknown> : StepResult<z.infer<NonNullable<StepsRecord<TSteps>[K]['outputSchema']>>>;
340
+ [K in keyof StepsRecord$1<TSteps>]: StepsRecord$1<TSteps>[K]['outputSchema'] extends undefined ? StepResult$1<unknown> : StepResult$1<z.infer<NonNullable<StepsRecord$1<TSteps>[K]['outputSchema']>>>;
333
341
  };
334
342
  runId: string;
335
343
  timestamp: number;
336
- activePaths: Map<keyof StepsRecord<TSteps>, {
344
+ activePaths: Map<keyof StepsRecord$1<TSteps>, {
337
345
  status: string;
338
346
  suspendPayload?: any;
339
347
  stepPath: string[];
@@ -346,13 +354,13 @@ interface WorkflowContext<TTrigger extends z.ZodObject<any> = any, TSteps extend
346
354
  };
347
355
  mastra?: MastraUnion;
348
356
  steps: {
349
- [K in keyof StepsRecord<TSteps>]: StepsRecord<TSteps>[K]['outputSchema'] extends undefined ? StepResult<unknown> : StepResult<z.infer<NonNullable<StepsRecord<TSteps>[K]['outputSchema']>>>;
357
+ [K in keyof StepsRecord$1<TSteps>]: StepsRecord$1<TSteps>[K]['outputSchema'] extends undefined ? StepResult$1<unknown> : StepResult$1<z.infer<NonNullable<StepsRecord$1<TSteps>[K]['outputSchema']>>>;
350
358
  };
351
359
  triggerData: z.infer<TTrigger>;
352
360
  inputData: TInputData;
353
361
  attempts: Record<string, number>;
354
362
  getStepResult(stepId: 'trigger'): z.infer<TTrigger>;
355
- getStepResult<T extends keyof StepsRecord<TSteps> | unknown>(stepId: T extends keyof StepsRecord<TSteps> ? T : string): T extends keyof StepsRecord<TSteps> ? StepsRecord<TSteps>[T]['outputSchema'] extends undefined ? unknown : z.infer<NonNullable<StepsRecord<TSteps>[T]['outputSchema']>> : T;
363
+ getStepResult<T extends keyof StepsRecord$1<TSteps> | unknown>(stepId: T extends keyof StepsRecord$1<TSteps> ? T : string): T extends keyof StepsRecord$1<TSteps> ? StepsRecord$1<TSteps>[T]['outputSchema'] extends undefined ? unknown : z.infer<NonNullable<StepsRecord$1<TSteps>[T]['outputSchema']>> : T;
356
364
  getStepResult<T extends Step<any, any, any, any>>(stepId: T): T['outputSchema'] extends undefined ? unknown : z.infer<NonNullable<T['outputSchema']>>;
357
365
  }
358
366
  interface WorkflowLogMessage extends BaseLogMessage {
@@ -518,12 +526,12 @@ declare const StepIdBrand: unique symbol;
518
526
  type StepId = string & {
519
527
  readonly [StepIdBrand]: typeof StepIdBrand;
520
528
  };
521
- type ExtractSchemaFromStep<TStep extends StepAction<any, any, any, any>, TKey extends 'inputSchema' | 'outputSchema'> = TStep[TKey];
529
+ type ExtractSchemaFromStep$1<TStep extends StepAction<any, any, any, any>, TKey extends 'inputSchema' | 'outputSchema'> = TStep[TKey];
522
530
  type ExtractStepResult<T> = T extends (data: any) => Promise<infer R> ? R : never;
523
- type StepInputType<TStep extends StepAction<any, any, any, any>, TKey extends 'inputSchema' | 'outputSchema'> = ExtractSchemaFromStep<TStep, TKey> extends infer Schema ? Schema extends z.ZodType<any> ? z.infer<Schema> : never : never;
524
- type ExtractSchemaType<T extends z.ZodSchema> = T extends z.ZodSchema<infer V> ? V : never;
525
- type PathsToStringProps<T> = T extends object ? {
526
- [K in keyof T]: T[K] extends object ? K extends string ? K | `${K}.${PathsToStringProps<T[K]>}` : never : K extends string ? K : never;
531
+ type StepInputType<TStep extends StepAction<any, any, any, any>, TKey extends 'inputSchema' | 'outputSchema'> = ExtractSchemaFromStep$1<TStep, TKey> extends infer Schema ? Schema extends z.ZodType<any> ? z.infer<Schema> : never : never;
532
+ type ExtractSchemaType$1<T extends z.ZodSchema> = T extends z.ZodSchema<infer V> ? V : never;
533
+ type PathsToStringProps$1<T> = T extends object ? {
534
+ [K in keyof T]: T[K] extends object ? K extends string ? K | `${K}.${PathsToStringProps$1<T[K]>}` : never : K extends string ? K : never;
527
535
  }[keyof T] : never;
528
536
  interface WorkflowRunState {
529
537
  value: Record<string, string>;
@@ -541,6 +549,7 @@ interface WorkflowRunState {
541
549
  stepId: string;
542
550
  status: string;
543
551
  }>;
552
+ suspendedPaths: Record<string, number[]>;
544
553
  runId: string;
545
554
  timestamp: number;
546
555
  childStates?: Record<string, WorkflowRunState>;
@@ -548,7 +557,7 @@ interface WorkflowRunState {
548
557
  }
549
558
  type WorkflowResumeResult<TTriggerSchema extends z.ZodObject<any>> = {
550
559
  triggerData?: z.infer<TTriggerSchema>;
551
- results: Record<string, StepResult<any>>;
560
+ results: Record<string, StepResult$1<any>>;
552
561
  };
553
562
 
554
563
  declare class Step<TStepId extends string = any, TSchemaIn extends z.ZodSchema | undefined = undefined, TSchemaOut extends z.ZodSchema | undefined = undefined, TContext extends StepExecutionContext<TSchemaIn> = StepExecutionContext<TSchemaIn>> implements StepAction<TStepId, TSchemaIn, TSchemaOut, TContext> {
@@ -562,7 +571,6 @@ declare class Step<TStepId extends string = any, TSchemaIn extends z.ZodSchema |
562
571
  mastra?: Mastra;
563
572
  constructor({ id, description, execute, payload, outputSchema, inputSchema, retryConfig, }: StepAction<TStepId, TSchemaIn, TSchemaOut, TContext>);
564
573
  }
565
- declare function createStep<TId extends string, TSchemaIn extends z.ZodSchema | undefined, TSchemaOut extends z.ZodSchema | undefined, TContext extends StepExecutionContext<TSchemaIn>>(opts: StepAction<TId, TSchemaIn, TSchemaOut, TContext>): Step<TId, TSchemaIn, TSchemaOut, TContext>;
566
574
 
567
575
  declare class Machine<TSteps extends Step<any, any, any, any>[] = Step<any, any, any, any>[], TTriggerSchema extends z.ZodObject<any> = any, TResultSchema extends z.ZodObject<any> = any> extends EventEmitter {
568
576
  #private;
@@ -991,7 +999,7 @@ declare class WorkflowInstance<TSteps extends Step<any, any, any, any>[] = Step<
991
999
  timestamp: number;
992
1000
  result?: z.TypeOf<TResult> | undefined;
993
1001
  triggerData?: z.TypeOf<TTriggerSchema> | undefined;
994
- results: { [K in keyof StepsRecord<TSteps>]: StepsRecord<TSteps>[K]["outputSchema"] extends undefined ? StepResult<unknown> : StepResult<z.TypeOf<NonNullable<StepsRecord<TSteps>[K]["outputSchema"]>>>; };
1002
+ results: { [K in keyof StepsRecord$1<TSteps>]: StepsRecord$1<TSteps>[K]["outputSchema"] extends undefined ? StepResult$1<unknown> : StepResult$1<z.TypeOf<NonNullable<StepsRecord$1<TSteps>[K]["outputSchema"]>>>; };
995
1003
  activePaths: Map<TSteps[number]["id"], {
996
1004
  status: string;
997
1005
  suspendPayload?: any;
@@ -1111,6 +1119,439 @@ declare class Workflow<TSteps extends Step<string, any, any>[] = Step<string, an
1111
1119
  toStep(): Step<TStepId, TTriggerSchema, z.ZodType<WorkflowRunResult<TTriggerSchema, TSteps, TResultSchema>>, any>;
1112
1120
  }
1113
1121
 
1122
+ type ExecuteFunction<TStepInput, TStepOutput, TResumeSchema, TSuspendSchema> = (params: {
1123
+ mastra: Mastra;
1124
+ runtimeContext: RuntimeContext;
1125
+ inputData: TStepInput;
1126
+ resumeData?: TResumeSchema;
1127
+ getInitData<T extends NewWorkflow<any, any, any, any, any>>(): T extends undefined ? unknown : z.infer<NonNullable<T['inputSchema']>>;
1128
+ getStepResult<T extends NewStep<any, any, any>>(stepId: T): T['outputSchema'] extends undefined ? unknown : z.infer<NonNullable<T['outputSchema']>>;
1129
+ suspend(suspendPayload: TSuspendSchema): Promise<void>;
1130
+ resume?: {
1131
+ steps: string[];
1132
+ resumePayload: any;
1133
+ };
1134
+ emitter: EventEmitter$1;
1135
+ }) => Promise<TStepOutput>;
1136
+ interface NewStep<TStepId extends string = string, TSchemaIn extends z.ZodType<any> = z.ZodType<any>, TSchemaOut extends z.ZodType<any> = z.ZodType<any>, TResumeSchema extends z.ZodType<any> = z.ZodType<any>, TSuspendSchema extends z.ZodType<any> = z.ZodType<any>> {
1137
+ id: TStepId;
1138
+ description?: string;
1139
+ inputSchema: TSchemaIn;
1140
+ outputSchema: TSchemaOut;
1141
+ resumeSchema?: TResumeSchema;
1142
+ suspendSchema?: TSuspendSchema;
1143
+ execute: ExecuteFunction<z.infer<TSchemaIn>, z.infer<TSchemaOut>, z.infer<TResumeSchema>, z.infer<TSuspendSchema>>;
1144
+ retries?: number;
1145
+ }
1146
+
1147
+ type StepSuccess<T> = {
1148
+ status: 'success';
1149
+ output: T;
1150
+ };
1151
+ type StepFailure = {
1152
+ status: 'failed';
1153
+ error: string;
1154
+ };
1155
+ type StepSuspended<T> = {
1156
+ status: 'suspended';
1157
+ payload: T;
1158
+ };
1159
+ type StepResult<T> = StepSuccess<T> | StepFailure | StepSuspended<T>;
1160
+ type StepsRecord<T extends readonly NewStep<any, any, any>[]> = {
1161
+ [K in T[number]['id']]: Extract<T[number], {
1162
+ id: K;
1163
+ }>;
1164
+ };
1165
+ type PathsToStringProps<T> = T extends object ? {
1166
+ [K in keyof T]: T[K] extends object ? K extends string ? K | `${K}.${PathsToStringProps<T[K]>}` : never : K extends string ? K : never;
1167
+ }[keyof T] : never;
1168
+ type ExtractSchemaType<T extends z.ZodType<any>> = T extends z.ZodObject<infer V> ? V : never;
1169
+ type ExtractSchemaFromStep<TStep extends NewStep<any, any, any>, TKey extends 'inputSchema' | 'outputSchema'> = TStep[TKey];
1170
+ type VariableReference<TStep extends NewStep<string, any, any> = NewStep<string, any, any>, TVarPath extends PathsToStringProps<ExtractSchemaType<ExtractSchemaFromStep<TStep, 'outputSchema'>>> | '' | '.' = PathsToStringProps<ExtractSchemaType<ExtractSchemaFromStep<TStep, 'outputSchema'>>> | '' | '.'> = {
1171
+ step: TStep;
1172
+ path: TVarPath;
1173
+ } | {
1174
+ value: any;
1175
+ schema: z.ZodTypeAny;
1176
+ };
1177
+ type WatchEvent = {
1178
+ type: 'watch';
1179
+ payload: {
1180
+ currentStep: {
1181
+ id: string;
1182
+ status: 'running' | 'success' | 'failed' | 'suspended';
1183
+ output?: Record<string, any>;
1184
+ payload?: Record<string, any>;
1185
+ };
1186
+ workflowState: {
1187
+ status: 'running' | 'success' | 'failed' | 'suspended';
1188
+ steps: Record<string, {
1189
+ status: 'running' | 'success' | 'failed' | 'suspended';
1190
+ output?: Record<string, any>;
1191
+ payload?: Record<string, any>;
1192
+ }>;
1193
+ output?: Record<string, any>;
1194
+ payload?: Record<string, any>;
1195
+ };
1196
+ };
1197
+ eventTimestamp: Date;
1198
+ };
1199
+ type ZodPathType<T extends z.ZodTypeAny, P extends string> = T extends z.ZodObject<infer Shape> ? P extends `${infer Key}.${infer Rest}` ? Key extends keyof Shape ? Shape[Key] extends z.ZodTypeAny ? ZodPathType<Shape[Key], Rest> : never : never : P extends keyof Shape ? Shape[P] : never : never;
1200
+
1201
+ /**
1202
+ * Represents an execution graph for a workflow
1203
+ */
1204
+ interface ExecutionGraph {
1205
+ id: string;
1206
+ steps: StepFlowEntry[];
1207
+ }
1208
+ /**
1209
+ * Execution engine abstract class for building and executing workflow graphs
1210
+ * Providers will implement this class to provide their own execution logic
1211
+ */
1212
+ declare abstract class ExecutionEngine extends MastraBase {
1213
+ protected mastra?: Mastra;
1214
+ constructor({ mastra }: {
1215
+ mastra?: Mastra;
1216
+ });
1217
+ __registerMastra(mastra: Mastra): void;
1218
+ /**
1219
+ * Executes a workflow run with the provided execution graph and input
1220
+ * @param graph The execution graph to execute
1221
+ * @param input The input data for the workflow
1222
+ * @returns A promise that resolves to the workflow output
1223
+ */
1224
+ abstract execute<TInput, TOutput>(params: {
1225
+ workflowId: string;
1226
+ runId: string;
1227
+ graph: ExecutionGraph;
1228
+ input?: TInput;
1229
+ resume?: {
1230
+ steps: string[];
1231
+ stepResults: Record<string, StepResult<any>>;
1232
+ resumePayload: any;
1233
+ resumePath: number[];
1234
+ };
1235
+ emitter: EventEmitter$1;
1236
+ runtimeContext: RuntimeContext;
1237
+ retryConfig?: {
1238
+ attempts?: number;
1239
+ delay?: number;
1240
+ };
1241
+ }): Promise<TOutput>;
1242
+ }
1243
+
1244
+ type StepFlowEntry = {
1245
+ type: 'step';
1246
+ step: NewStep;
1247
+ } | {
1248
+ type: 'parallel';
1249
+ steps: StepFlowEntry[];
1250
+ } | {
1251
+ type: 'conditional';
1252
+ steps: StepFlowEntry[];
1253
+ conditions: ExecuteFunction<any, any, any, any>[];
1254
+ serializedConditions: {
1255
+ id: string;
1256
+ fn: string;
1257
+ }[];
1258
+ } | {
1259
+ type: 'loop';
1260
+ step: NewStep;
1261
+ condition: ExecuteFunction<any, any, any, any>;
1262
+ serializedCondition: {
1263
+ id: string;
1264
+ fn: string;
1265
+ };
1266
+ loopType: 'dowhile' | 'dountil';
1267
+ } | {
1268
+ type: 'foreach';
1269
+ step: NewStep;
1270
+ opts: {
1271
+ concurrency: number;
1272
+ };
1273
+ };
1274
+ /**
1275
+ * Creates a new workflow step
1276
+ * @param params Configuration parameters for the step
1277
+ * @param params.id Unique identifier for the step
1278
+ * @param params.description Optional description of what the step does
1279
+ * @param params.inputSchema Zod schema defining the input structure
1280
+ * @param params.outputSchema Zod schema defining the output structure
1281
+ * @param params.execute Function that performs the step's operations
1282
+ * @returns A Step object that can be added to the workflow
1283
+ */
1284
+ 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: {
1285
+ id: TStepId;
1286
+ description?: string;
1287
+ inputSchema: TStepInput;
1288
+ outputSchema: TStepOutput;
1289
+ resumeSchema?: TResumeSchema;
1290
+ suspendSchema?: TSuspendSchema;
1291
+ execute: ExecuteFunction<z.infer<TStepInput>, z.infer<TStepOutput>, z.infer<TResumeSchema>, z.infer<TSuspendSchema>>;
1292
+ }): NewStep<TStepId, TStepInput, TStepOutput, TResumeSchema, TSuspendSchema>;
1293
+ declare function createStep<TStepId extends string, TStepInput extends z.ZodObject<{
1294
+ prompt: z.ZodString;
1295
+ }>, TStepOutput extends z.ZodObject<{
1296
+ text: z.ZodString;
1297
+ }>, TResumeSchema extends z.ZodType<any>, TSuspendSchema extends z.ZodType<any>>(agent: Agent<TStepId, any, any>): NewStep<TStepId, TStepInput, TStepOutput, TResumeSchema, TSuspendSchema>;
1298
+ declare function createStep<TSchemaIn extends z.ZodType<any>, TSchemaOut extends z.ZodType<any>, TContext extends ToolExecutionContext<TSchemaIn>>(tool: Tool<TSchemaIn, TSchemaOut, TContext> & {
1299
+ inputSchema: TSchemaIn;
1300
+ outputSchema: TSchemaOut;
1301
+ execute: (context: TContext) => Promise<any>;
1302
+ }): NewStep<string, TSchemaIn, TSchemaOut, z.ZodType<any>, z.ZodType<any>>;
1303
+ declare function cloneStep<TStepId extends string>(step: NewStep<TStepId, any, any>, opts: {
1304
+ id: TStepId;
1305
+ }): NewStep<string, any, any>;
1306
+ declare function createWorkflow<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>[] = NewStep<string, any, any>[]>(params: NewWorkflowConfig<TWorkflowId, TInput, TOutput, TSteps>): NewWorkflow<TSteps, TWorkflowId, TInput, TOutput, TInput>;
1307
+ type WorkflowResult<TOutput extends z.ZodType<any>, TSteps extends NewStep<string, any, any>[]> = {
1308
+ status: 'success';
1309
+ result: z.infer<TOutput>;
1310
+ steps: {
1311
+ [K in keyof StepsRecord<TSteps>]: StepsRecord<TSteps>[K]['outputSchema'] extends undefined ? StepResult<unknown> : StepResult<z.infer<NonNullable<StepsRecord<TSteps>[K]['outputSchema']>>>;
1312
+ };
1313
+ } | {
1314
+ status: 'failed';
1315
+ steps: {
1316
+ [K in keyof StepsRecord<TSteps>]: StepsRecord<TSteps>[K]['outputSchema'] extends undefined ? StepResult<unknown> : StepResult<z.infer<NonNullable<StepsRecord<TSteps>[K]['outputSchema']>>>;
1317
+ };
1318
+ error: Error;
1319
+ } | {
1320
+ status: 'suspended';
1321
+ steps: {
1322
+ [K in keyof StepsRecord<TSteps>]: StepsRecord<TSteps>[K]['outputSchema'] extends undefined ? StepResult<unknown> : StepResult<z.infer<NonNullable<StepsRecord<TSteps>[K]['outputSchema']>>>;
1323
+ };
1324
+ suspended: [string[], ...string[][]];
1325
+ };
1326
+ type NewWorkflowConfig<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>[] = NewStep<string, any, any>[]> = {
1327
+ mastra?: Mastra;
1328
+ id: TWorkflowId;
1329
+ description?: string | undefined;
1330
+ inputSchema: TInput;
1331
+ outputSchema: TOutput;
1332
+ executionEngine?: ExecutionEngine;
1333
+ steps?: TSteps;
1334
+ retryConfig?: {
1335
+ attempts?: number;
1336
+ delay?: number;
1337
+ };
1338
+ };
1339
+ declare class NewWorkflow<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 MastraBase implements NewStep<TWorkflowId, TInput, TOutput> {
1340
+ #private;
1341
+ id: TWorkflowId;
1342
+ description?: string | undefined;
1343
+ inputSchema: TInput;
1344
+ outputSchema: TOutput;
1345
+ steps: Record<string, NewStep<string, any, any>>;
1346
+ protected stepFlow: StepFlowEntry[];
1347
+ protected executionEngine: ExecutionEngine;
1348
+ protected executionGraph: ExecutionGraph;
1349
+ protected retryConfig: {
1350
+ attempts?: number;
1351
+ delay?: number;
1352
+ };
1353
+ constructor({ mastra, id, inputSchema, outputSchema, description, executionEngine, retryConfig, }: NewWorkflowConfig<TWorkflowId, TInput, TOutput, TSteps>);
1354
+ __registerMastra(mastra: Mastra): void;
1355
+ __registerPrimitives(p: MastraPrimitives): void;
1356
+ /**
1357
+ * Adds a step to the workflow
1358
+ * @param step The step to add to the workflow
1359
+ * @returns The workflow instance for chaining
1360
+ */
1361
+ then<TStepInputSchema extends TPrevSchema, TStepId extends string, TSchemaOut extends z.ZodType<any>>(step: NewStep<TStepId, TStepInputSchema, TSchemaOut, any, any>): NewWorkflow<TSteps, TWorkflowId, TInput, TOutput, TSchemaOut>;
1362
+ map<TSteps extends NewStep<string, any, any>[], TMapping extends {
1363
+ [K in keyof TMapping]: {
1364
+ step: TSteps[number];
1365
+ path: PathsToStringProps<ExtractSchemaType<ExtractSchemaFromStep<TSteps[number], 'outputSchema'>>> | '.';
1366
+ } | {
1367
+ value: any;
1368
+ schema: z.ZodTypeAny;
1369
+ } | {
1370
+ initData: TSteps[number];
1371
+ path: PathsToStringProps<ExtractSchemaType<ExtractSchemaFromStep<TSteps[number], 'inputSchema'>>> | '.';
1372
+ } | {
1373
+ runtimeContextPath: string;
1374
+ schema: z.ZodTypeAny;
1375
+ };
1376
+ }>(mappingConfig: TMapping): NewWorkflow<TSteps, TWorkflowId, TInput, TOutput, z.ZodObject<{ [K in keyof TMapping]: TMapping[K] extends {
1377
+ step: TSteps[number];
1378
+ path: PathsToStringProps<ExtractSchemaType<ExtractSchemaFromStep<TSteps[number], "outputSchema">>>;
1379
+ } ? TMapping[K]["path"] extends "." ? TMapping[K]["step"]["outputSchema"] : ZodPathType<TMapping[K]["step"]["outputSchema"], TMapping[K]["path"]> : TMapping[K] extends {
1380
+ initData: TSteps[number];
1381
+ path: PathsToStringProps<ExtractSchemaType<ExtractSchemaFromStep<TSteps[number], "inputSchema">>>;
1382
+ } ? TMapping[K]["path"] extends "." ? TMapping[K]["initData"]["inputSchema"] : ZodPathType<TMapping[K]["initData"]["inputSchema"], TMapping[K]["path"]> : TMapping[K] extends {
1383
+ value: any;
1384
+ schema: z.ZodTypeAny;
1385
+ } ? TMapping[K]["schema"] : TMapping[K] extends {
1386
+ runtimeContextPath: string;
1387
+ schema: z.ZodTypeAny;
1388
+ } ? TMapping[K]["schema"] : never; }, any, z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{ [K in keyof TMapping]: TMapping[K] extends {
1389
+ step: TSteps[number];
1390
+ path: PathsToStringProps<ExtractSchemaType<ExtractSchemaFromStep<TSteps[number], "outputSchema">>>;
1391
+ } ? TMapping[K]["path"] extends "." ? TMapping[K]["step"]["outputSchema"] : ZodPathType<TMapping[K]["step"]["outputSchema"], TMapping[K]["path"]> : TMapping[K] extends {
1392
+ initData: TSteps[number];
1393
+ path: PathsToStringProps<ExtractSchemaType<ExtractSchemaFromStep<TSteps[number], "inputSchema">>>;
1394
+ } ? TMapping[K]["path"] extends "." ? TMapping[K]["initData"]["inputSchema"] : ZodPathType<TMapping[K]["initData"]["inputSchema"], TMapping[K]["path"]> : TMapping[K] extends {
1395
+ value: any;
1396
+ schema: z.ZodTypeAny;
1397
+ } ? TMapping[K]["schema"] : TMapping[K] extends {
1398
+ runtimeContextPath: string;
1399
+ schema: z.ZodTypeAny;
1400
+ } ? TMapping[K]["schema"] : never; }>, any> extends infer T ? { [k in keyof T]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{ [K in keyof TMapping]: TMapping[K] extends {
1401
+ step: TSteps[number];
1402
+ path: PathsToStringProps<ExtractSchemaType<ExtractSchemaFromStep<TSteps[number], "outputSchema">>>;
1403
+ } ? TMapping[K]["path"] extends "." ? TMapping[K]["step"]["outputSchema"] : ZodPathType<TMapping[K]["step"]["outputSchema"], TMapping[K]["path"]> : TMapping[K] extends {
1404
+ initData: TSteps[number];
1405
+ path: PathsToStringProps<ExtractSchemaType<ExtractSchemaFromStep<TSteps[number], "inputSchema">>>;
1406
+ } ? TMapping[K]["path"] extends "." ? TMapping[K]["initData"]["inputSchema"] : ZodPathType<TMapping[K]["initData"]["inputSchema"], TMapping[K]["path"]> : TMapping[K] extends {
1407
+ value: any;
1408
+ schema: z.ZodTypeAny;
1409
+ } ? TMapping[K]["schema"] : TMapping[K] extends {
1410
+ runtimeContextPath: string;
1411
+ schema: z.ZodTypeAny;
1412
+ } ? TMapping[K]["schema"] : never; }>, any>[k]; } : never, z.baseObjectInputType<{ [K in keyof TMapping]: TMapping[K] extends {
1413
+ step: TSteps[number];
1414
+ path: PathsToStringProps<ExtractSchemaType<ExtractSchemaFromStep<TSteps[number], "outputSchema">>>;
1415
+ } ? TMapping[K]["path"] extends "." ? TMapping[K]["step"]["outputSchema"] : ZodPathType<TMapping[K]["step"]["outputSchema"], TMapping[K]["path"]> : TMapping[K] extends {
1416
+ initData: TSteps[number];
1417
+ path: PathsToStringProps<ExtractSchemaType<ExtractSchemaFromStep<TSteps[number], "inputSchema">>>;
1418
+ } ? TMapping[K]["path"] extends "." ? TMapping[K]["initData"]["inputSchema"] : ZodPathType<TMapping[K]["initData"]["inputSchema"], TMapping[K]["path"]> : TMapping[K] extends {
1419
+ value: any;
1420
+ schema: z.ZodTypeAny;
1421
+ } ? TMapping[K]["schema"] : TMapping[K] extends {
1422
+ runtimeContextPath: string;
1423
+ schema: z.ZodTypeAny;
1424
+ } ? TMapping[K]["schema"] : never; }> extends infer T_1 ? { [k_1 in keyof T_1]: z.baseObjectInputType<{ [K in keyof TMapping]: TMapping[K] extends {
1425
+ step: TSteps[number];
1426
+ path: PathsToStringProps<ExtractSchemaType<ExtractSchemaFromStep<TSteps[number], "outputSchema">>>;
1427
+ } ? TMapping[K]["path"] extends "." ? TMapping[K]["step"]["outputSchema"] : ZodPathType<TMapping[K]["step"]["outputSchema"], TMapping[K]["path"]> : TMapping[K] extends {
1428
+ initData: TSteps[number];
1429
+ path: PathsToStringProps<ExtractSchemaType<ExtractSchemaFromStep<TSteps[number], "inputSchema">>>;
1430
+ } ? TMapping[K]["path"] extends "." ? TMapping[K]["initData"]["inputSchema"] : ZodPathType<TMapping[K]["initData"]["inputSchema"], TMapping[K]["path"]> : TMapping[K] extends {
1431
+ value: any;
1432
+ schema: z.ZodTypeAny;
1433
+ } ? TMapping[K]["schema"] : TMapping[K] extends {
1434
+ runtimeContextPath: string;
1435
+ schema: z.ZodTypeAny;
1436
+ } ? TMapping[K]["schema"] : never; }>[k_1]; } : never>>;
1437
+ parallel<TParallelSteps extends NewStep<string, TPrevSchema, any, any, any>[]>(steps: TParallelSteps): NewWorkflow<TSteps, TWorkflowId, TInput, TOutput, z.ZodObject<{ [K in keyof StepsRecord<TParallelSteps>]: StepsRecord<TParallelSteps>[K]["outputSchema"]["path"]; }, any, z.ZodTypeAny>>;
1438
+ branch<TBranchSteps extends Array<[
1439
+ ExecuteFunction<z.infer<TPrevSchema>, any, any, any>,
1440
+ NewStep<string, TPrevSchema, any, any, any>
1441
+ ]>>(steps: TBranchSteps): NewWorkflow<TSteps, TWorkflowId, TInput, TOutput, z.ZodObject<{ [K in keyof StepsRecord<{ [K_1 in keyof TBranchSteps]: TBranchSteps[K_1][1]; }[number][]>]: StepsRecord<{ [K_1 in keyof TBranchSteps]: TBranchSteps[K_1][1]; }[number][]>[K]["outputSchema"]; }, any, z.ZodTypeAny>>;
1442
+ dowhile<TStepInputSchema extends TPrevSchema, TStepId extends string, TSchemaOut extends z.ZodType<any>>(step: NewStep<TStepId, TStepInputSchema, TSchemaOut, any, any>, condition: ExecuteFunction<z.infer<TSchemaOut>, any, any, any>): NewWorkflow<TSteps, TWorkflowId, TInput, TOutput, TSchemaOut>;
1443
+ dountil<TStepInputSchema extends TPrevSchema, TStepId extends string, TSchemaOut extends z.ZodType<any>>(step: NewStep<TStepId, TStepInputSchema, TSchemaOut, any, any>, condition: ExecuteFunction<z.infer<TSchemaOut>, any, any, any>): NewWorkflow<TSteps, TWorkflowId, TInput, TOutput, TSchemaOut>;
1444
+ foreach<TPrevIsArray extends TPrevSchema extends z.ZodArray<any> ? true : false, TStepInputSchema extends TPrevSchema extends z.ZodArray<infer TElement> ? TElement : never, TStepId extends string, TSchemaOut extends z.ZodType<any>>(step: TPrevIsArray extends true ? NewStep<TStepId, TStepInputSchema, TSchemaOut, any, any> : 'Previous step must return an array type', opts?: {
1445
+ concurrency: number;
1446
+ }): NewWorkflow<TSteps, TWorkflowId, TInput, TOutput, z.ZodArray<TSchemaOut>>;
1447
+ /**
1448
+ * Builds the execution graph for this workflow
1449
+ * @returns The execution graph that can be used to execute the workflow
1450
+ */
1451
+ buildExecutionGraph(): ExecutionGraph;
1452
+ /**
1453
+ * Finalizes the workflow definition and prepares it for execution
1454
+ * This method should be called after all steps have been added to the workflow
1455
+ * @returns A built workflow instance ready for execution
1456
+ */
1457
+ commit(): NewWorkflow<TSteps, TWorkflowId, TInput, TOutput, TOutput>;
1458
+ get stepGraph(): StepFlowEntry[];
1459
+ /**
1460
+ * Creates a new workflow run instance
1461
+ * @param options Optional configuration for the run
1462
+ * @returns A Run instance that can be used to execute the workflow
1463
+ */
1464
+ createRun(options?: {
1465
+ runId?: string;
1466
+ }): Run<TSteps, TInput, TOutput>;
1467
+ execute({ inputData, resumeData, suspend, resume, emitter, mastra, }: {
1468
+ inputData: z.infer<TInput>;
1469
+ resumeData?: any;
1470
+ getStepResult<T extends NewStep<any, any, any>>(stepId: T): T['outputSchema'] extends undefined ? unknown : z.infer<NonNullable<T['outputSchema']>>;
1471
+ suspend: (suspendPayload: any) => Promise<void>;
1472
+ resume?: {
1473
+ steps: string[];
1474
+ resumePayload: any;
1475
+ runId?: string;
1476
+ };
1477
+ emitter: EventEmitter$1;
1478
+ mastra: Mastra;
1479
+ }): Promise<z.infer<TOutput>>;
1480
+ getWorkflowRuns(): Promise<WorkflowRuns>;
1481
+ getWorkflowRun(runId: string): Promise<{
1482
+ workflowName: string;
1483
+ runId: string;
1484
+ snapshot: WorkflowRunState | string;
1485
+ createdAt: Date;
1486
+ updatedAt: Date;
1487
+ } | Run<TSteps, TInput, TOutput> | undefined>;
1488
+ }
1489
+ /**
1490
+ * Represents a workflow run that can be executed
1491
+ */
1492
+ declare class Run<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>> {
1493
+ #private;
1494
+ protected emitter: EventEmitter$1;
1495
+ /**
1496
+ * Unique identifier for this workflow
1497
+ */
1498
+ readonly workflowId: string;
1499
+ /**
1500
+ * Unique identifier for this run
1501
+ */
1502
+ readonly runId: string;
1503
+ /**
1504
+ * Internal state of the workflow run
1505
+ */
1506
+ protected state: Record<string, any>;
1507
+ /**
1508
+ * The execution engine for this run
1509
+ */
1510
+ executionEngine: ExecutionEngine;
1511
+ /**
1512
+ * The execution graph for this run
1513
+ */
1514
+ executionGraph: ExecutionGraph;
1515
+ protected cleanup?: () => void;
1516
+ protected retryConfig?: {
1517
+ attempts?: number;
1518
+ delay?: number;
1519
+ };
1520
+ constructor(params: {
1521
+ workflowId: string;
1522
+ runId: string;
1523
+ executionEngine: ExecutionEngine;
1524
+ executionGraph: ExecutionGraph;
1525
+ mastra?: Mastra;
1526
+ retryConfig?: {
1527
+ attempts?: number;
1528
+ delay?: number;
1529
+ };
1530
+ cleanup?: () => void;
1531
+ });
1532
+ /**
1533
+ * Starts the workflow execution with the provided input
1534
+ * @param input The input data for the workflow
1535
+ * @returns A promise that resolves to the workflow output
1536
+ */
1537
+ start({ inputData, runtimeContext, }: {
1538
+ inputData?: z.infer<TInput>;
1539
+ runtimeContext?: RuntimeContext;
1540
+ }): Promise<WorkflowResult<TOutput, TSteps>>;
1541
+ watch(cb: (event: WatchEvent) => void): () => void;
1542
+ resume<TResumeSchema extends z.ZodType<any>>(params: {
1543
+ resumeData?: z.infer<TResumeSchema>;
1544
+ step: NewStep<string, any, any, TResumeSchema, any> | [...NewStep<string, any, any, any, any>[], NewStep<string, any, any, TResumeSchema, any>] | string | string[];
1545
+ runtimeContext?: RuntimeContext;
1546
+ }): Promise<WorkflowResult<TOutput, TSteps>>;
1547
+ /**
1548
+ * Returns the current state of the workflow run
1549
+ * @returns The current state of the workflow run
1550
+ */
1551
+ getState(): Record<string, any>;
1552
+ updateState(state: Record<string, any>): void;
1553
+ }
1554
+
1114
1555
  type MemoryProcessorOpts = {
1115
1556
  systemMessage?: string;
1116
1557
  memorySystemMessage?: string;
@@ -1128,6 +1569,19 @@ declare abstract class MemoryProcessor extends MastraBase {
1128
1569
  */
1129
1570
  process(messages: CoreMessage$1[], _opts: MemoryProcessorOpts): CoreMessage$1[];
1130
1571
  }
1572
+ declare const memoryDefaultOptions: {
1573
+ lastMessages: number;
1574
+ semanticRecall: {
1575
+ topK: number;
1576
+ messageRange: {
1577
+ before: number;
1578
+ after: number;
1579
+ };
1580
+ };
1581
+ threads: {
1582
+ generateTitle: true;
1583
+ };
1584
+ };
1131
1585
  /**
1132
1586
  * Abstract Memory class that defines the interface for storing and retrieving
1133
1587
  * conversation threads and messages.
@@ -1138,10 +1592,12 @@ declare abstract class MastraMemory extends MastraBase {
1138
1592
  vector?: MastraVector;
1139
1593
  embedder?: EmbeddingModel<string>;
1140
1594
  private processors;
1595
+ private deprecationWarnings;
1141
1596
  protected threadConfig: MemoryConfig;
1142
1597
  constructor(config: {
1143
1598
  name: string;
1144
1599
  } & SharedMemoryConfig);
1600
+ private addImplicitDefaultsWarning;
1145
1601
  setStorage(storage: MastraStorage): void;
1146
1602
  setVector(vector: MastraVector): void;
1147
1603
  setEmbedder(embedder: EmbeddingModel<string>): void;
@@ -1273,6 +1729,33 @@ declare abstract class MastraMemory extends MastraBase {
1273
1729
  generateId(): string;
1274
1730
  }
1275
1731
 
1732
+ declare class MastraLLMBase extends MastraBase {
1733
+ #private;
1734
+ constructor({ name, model }: {
1735
+ name: string;
1736
+ model: LanguageModel$1;
1737
+ });
1738
+ getProvider(): string;
1739
+ getModelId(): string;
1740
+ getModel(): ai.LanguageModelV1;
1741
+ convertToMessages(messages: string | string[] | CoreMessage$1[]): CoreMessage$1[];
1742
+ __registerPrimitives(p: MastraPrimitives): void;
1743
+ __registerMastra(p: Mastra): void;
1744
+ __text<Z extends ZodSchema | JSONSchema7 | undefined>(input: LLMTextOptions<Z>): Promise<GenerateTextResult<any, any>>;
1745
+ __textObject<T extends ZodSchema | JSONSchema7 | undefined>(input: LLMTextObjectOptions<T>): Promise<GenerateObjectResult<T>>;
1746
+ generate<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], options: LLMStreamOptions<Z>): Promise<GenerateReturn<Z>>;
1747
+ __stream<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(input: LLMInnerStreamOptions<Z>): Promise<StreamTextResult<any, any>>;
1748
+ __streamObject<T extends ZodSchema | JSONSchema7 | undefined>(input: LLMStreamObjectOptions<T>): Promise<StreamObjectResult<DeepPartial<T>, T, never>>;
1749
+ stream<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], options: LLMStreamOptions<Z>): Promise<StreamReturn<Z>>;
1750
+ }
1751
+
1752
+ declare function createMockModel({ objectGenerationMode, mockText, spyGenerate, spyStream, }: {
1753
+ objectGenerationMode?: 'json';
1754
+ mockText: string | Record<string, any>;
1755
+ spyGenerate?: (props: any) => void;
1756
+ spyStream?: (props: any) => void;
1757
+ }): MockLanguageModelV1;
1758
+
1276
1759
  type LanguageModel = MastraLanguageModel;
1277
1760
  type CoreMessage = CoreMessage$1;
1278
1761
  type CoreSystemMessage = CoreSystemMessage$1;
@@ -1321,7 +1804,7 @@ type MastraCustomLLMOptions<Z extends ZodSchema | JSONSchema7 | undefined = unde
1321
1804
  threadId?: string;
1322
1805
  resourceId?: string;
1323
1806
  runtimeContext: RuntimeContext;
1324
- } & Run;
1807
+ } & Run$1;
1325
1808
  type LLMTextOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = {
1326
1809
  messages: CoreMessage[];
1327
1810
  } & MastraCustomLLMOptions<Z> & DefaultLLMTextOptions;
@@ -1679,13 +2162,14 @@ type ServerConfig = {
1679
2162
  };
1680
2163
  };
1681
2164
 
1682
- interface Config<TAgents extends Record<string, Agent<any>> = Record<string, Agent<any>>, TWorkflows extends Record<string, Workflow> = Record<string, Workflow>, TVectors extends Record<string, MastraVector> = Record<string, MastraVector>, TTTS extends Record<string, MastraTTS> = Record<string, MastraTTS>, TLogger extends Logger = Logger, TNetworks extends Record<string, AgentNetwork> = Record<string, AgentNetwork>> {
2165
+ interface Config<TAgents extends Record<string, Agent<any>> = Record<string, Agent<any>>, TWorkflows extends Record<string, Workflow> = Record<string, Workflow>, TNewWorkflows extends Record<string, NewWorkflow> = Record<string, NewWorkflow>, TVectors extends Record<string, MastraVector> = Record<string, MastraVector>, TTTS extends Record<string, MastraTTS> = Record<string, MastraTTS>, TLogger extends Logger = Logger, TNetworks extends Record<string, AgentNetwork> = Record<string, AgentNetwork>> {
1683
2166
  agents?: TAgents;
1684
2167
  networks?: TNetworks;
1685
2168
  storage?: MastraStorage;
1686
2169
  vectors?: TVectors;
1687
2170
  logger?: TLogger | false;
1688
2171
  workflows?: TWorkflows;
2172
+ vnext_workflows?: TNewWorkflows;
1689
2173
  tts?: TTTS;
1690
2174
  telemetry?: OtelConfig;
1691
2175
  deployer?: MastraDeployer;
@@ -1701,7 +2185,7 @@ interface Config<TAgents extends Record<string, Agent<any>> = Record<string, Age
1701
2185
  }>;
1702
2186
  memory?: MastraMemory;
1703
2187
  }
1704
- declare class Mastra<TAgents extends Record<string, Agent<any>> = Record<string, Agent<any>>, TWorkflows extends Record<string, Workflow> = Record<string, Workflow>, TVectors extends Record<string, MastraVector> = Record<string, MastraVector>, TTTS extends Record<string, MastraTTS> = Record<string, MastraTTS>, TLogger extends Logger = Logger, TNetworks extends Record<string, AgentNetwork> = Record<string, AgentNetwork>> {
2188
+ declare class Mastra<TAgents extends Record<string, Agent<any>> = Record<string, Agent<any>>, TWorkflows extends Record<string, Workflow> = Record<string, Workflow>, TNewWorkflows extends Record<string, NewWorkflow> = Record<string, NewWorkflow>, TVectors extends Record<string, MastraVector> = Record<string, MastraVector>, TTTS extends Record<string, MastraTTS> = Record<string, MastraTTS>, TLogger extends Logger = Logger, TNetworks extends Record<string, AgentNetwork> = Record<string, AgentNetwork>> {
1705
2189
  #private;
1706
2190
  /**
1707
2191
  * @deprecated use getTelemetry() instead
@@ -1715,7 +2199,7 @@ declare class Mastra<TAgents extends Record<string, Agent<any>> = Record<string,
1715
2199
  * @deprecated use getMemory() instead
1716
2200
  */
1717
2201
  get memory(): MastraMemory | undefined;
1718
- constructor(config?: Config<TAgents, TWorkflows, TVectors, TTTS, TLogger>);
2202
+ constructor(config?: Config<TAgents, TWorkflows, TNewWorkflows, TVectors, TTTS, TLogger>);
1719
2203
  getAgent<TAgentName extends keyof TAgents>(name: TAgentName): TAgents[TAgentName];
1720
2204
  getAgents(): TAgents;
1721
2205
  getVector<TVectorName extends keyof TVectors>(name: TVectorName): TVectors[TVectorName];
@@ -1724,9 +2208,15 @@ declare class Mastra<TAgents extends Record<string, Agent<any>> = Record<string,
1724
2208
  getWorkflow<TWorkflowId extends keyof TWorkflows>(id: TWorkflowId, { serialized }?: {
1725
2209
  serialized?: boolean;
1726
2210
  }): TWorkflows[TWorkflowId];
2211
+ vnext_getWorkflow<TWorkflowId extends keyof TNewWorkflows>(id: TWorkflowId, { serialized }?: {
2212
+ serialized?: boolean;
2213
+ }): TNewWorkflows[TWorkflowId];
1727
2214
  getWorkflows(props?: {
1728
2215
  serialized?: boolean;
1729
2216
  }): Record<string, Workflow>;
2217
+ vnext_getWorkflows(props?: {
2218
+ serialized?: boolean;
2219
+ }): Record<string, NewWorkflow>;
1730
2220
  setStorage(storage: MastraStorage): void;
1731
2221
  setLogger({ logger }: {
1732
2222
  logger: TLogger;
@@ -1782,28 +2272,9 @@ interface IAction<TId extends string, TSchemaIn extends z.ZodSchema | undefined,
1782
2272
  execute?: (context: TContext, options?: TOptions) => Promise<TSchemaOut extends z.ZodSchema ? z.infer<TSchemaOut> : unknown>;
1783
2273
  }
1784
2274
 
1785
- declare class MastraLLMBase extends MastraBase {
1786
- #private;
1787
- constructor({ name, model }: {
1788
- name: string;
1789
- model: LanguageModel$1;
1790
- });
1791
- getProvider(): string;
1792
- getModelId(): string;
1793
- getModel(): ai.LanguageModelV1;
1794
- convertToMessages(messages: string | string[] | CoreMessage$1[]): CoreMessage$1[];
1795
- __registerPrimitives(p: MastraPrimitives): void;
1796
- __registerMastra(p: Mastra): void;
1797
- __text<Z extends ZodSchema | JSONSchema7 | undefined>(input: LLMTextOptions<Z>): Promise<GenerateTextResult<any, any>>;
1798
- __textObject<T extends ZodSchema | JSONSchema7 | undefined>(input: LLMTextObjectOptions<T>): Promise<GenerateObjectResult<T>>;
1799
- generate<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], options: LLMStreamOptions<Z>): Promise<GenerateReturn<Z>>;
1800
- __stream<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(input: LLMInnerStreamOptions<Z>): Promise<StreamTextResult<any, any>>;
1801
- __streamObject<T extends ZodSchema | JSONSchema7 | undefined>(input: LLMStreamObjectOptions<T>): Promise<StreamObjectResult<DeepPartial<T>, T, never>>;
1802
- stream<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], options: LLMStreamOptions<Z>): Promise<StreamReturn<Z>>;
1803
- }
1804
-
1805
2275
  declare class Agent<TAgentId extends string = string, TTools extends ToolsInput = ToolsInput, TMetrics extends Record<string, Metric> = Record<string, Metric>> extends MastraBase {
1806
2276
  #private;
2277
+ id: TAgentId;
1807
2278
  name: TAgentId;
1808
2279
  readonly llm: MastraLLMBase;
1809
2280
  instructions: string;
@@ -2156,4 +2627,4 @@ declare abstract class MastraStorage extends MastraBase {
2156
2627
  }): Promise<WorkflowRuns>;
2157
2628
  }
2158
2629
 
2159
- export { type MemoryConfig as $, type ApiRoute as A, type BaseStructuredOutputType as B, CompositeVoice as C, type StructuredOutputType as D, type EvalRow as E, type StructuredOutputArrayItem as F, type StructuredOutput as G, type GenerateReturn as H, type StreamReturn as I, type DefaultLLMTextOptions as J, type DefaultLLMTextObjectOptions as K, type LanguageModel as L, type Methods as M, type DefaultLLMStreamOptions as N, type OutputType as O, type DefaultLLMStreamObjectOptions as P, type LLMTextOptions as Q, type LLMTextObjectOptions as R, type StorageColumn as S, type TABLE_NAMES as T, type LLMStreamOptions as U, type VoiceEventType as V, type WorkflowRunState as W, type LLMInnerStreamOptions as X, type LLMStreamObjectOptions as Y, type Config as Z, type MessageResponse as _, Mastra as a, type SharedMemoryConfig as a0, type MemoryProcessorOpts as a1, MemoryProcessor as a2, createTool as a3, type VercelTool as a4, type CoreTool as a5, type StepExecutionContext as a6, type StepAction as a7, type StepVariableType as a8, type StepNode as a9, type ExtractStepResult as aA, type StepInputType as aB, type ExtractSchemaType as aC, type PathsToStringProps as aD, type WorkflowResumeResult as aE, createStep as aF, type MastraLanguageModel as aG, type ToolsInput as aH, type MastraPrimitives as aI, AgentNetwork as aJ, type AgentNetworkConfig as aK, type ToolsetsInput as aL, type AgentGenerateOptions as aM, type AgentStreamOptions as aN, TABLE_WORKFLOW_SNAPSHOT as aO, TABLE_EVALS as aP, TABLE_MESSAGES as aQ, TABLE_THREADS as aR, TABLE_TRACES as aS, TABLE_SCHEMAS as aT, type StepGraph as aa, type RetryConfig as ab, type VariableReference as ac, type BaseCondition as ad, type ActionContext as ae, WhenConditionReturnValue as af, type StepDef as ag, type StepCondition as ah, type StepConfig as ai, type StepResult as aj, type StepsRecord as ak, type WorkflowRunResult as al, type WorkflowContext as am, type WorkflowLogMessage as an, type WorkflowEvent as ao, type ResolverFunctionInput as ap, type ResolverFunctionOutput as aq, type SubscriberFunctionOutput as ar, type DependencyCheckOutput as as, type StepResolverOutput as at, type WorkflowActors as au, type WorkflowActionParams as av, type WorkflowActions as aw, type WorkflowState as ax, type StepId as ay, type ExtractSchemaFromStep as az, MastraVoice as b, type VoiceEventMap as c, type VoiceConfig as d, MastraStorage as e, type StorageThreadType as f, type MessageType as g, type StorageGetMessagesArg as h, type ToolAction as i, Agent as j, type AgentConfig as k, MastraMemory as l, type ToolExecutionContext as m, Tool as n, Step as o, Workflow as p, type WorkflowOptions as q, type WorkflowRow as r, type WorkflowRuns as s, type CoreMessage as t, type CoreSystemMessage as u, type CoreAssistantMessage as v, type CoreUserMessage as w, type CoreToolMessage as x, type EmbedResult as y, type EmbedManyResult as z };
2630
+ export { type CoreAssistantMessage as $, type ApiRoute as A, type WatchEvent as B, CompositeVoice as C, type ToolAction as D, type EvalRow as E, Agent as F, type AgentConfig as G, MastraMemory as H, type ToolExecutionContext as I, Tool as J, Step as K, Workflow as L, type Methods as M, type NewStep as N, type WorkflowOptions as O, type PathsToStringProps as P, type WorkflowRow as Q, Run as R, type StorageColumn as S, type TABLE_NAMES as T, type WorkflowRuns as U, type VoiceEventType as V, type WorkflowRunState as W, type LanguageModel as X, type CoreMessage as Y, type ZodPathType as Z, type CoreSystemMessage as _, Mastra as a, type ExtractSchemaType$1 as a$, type CoreUserMessage as a0, type CoreToolMessage as a1, type EmbedResult as a2, type EmbedManyResult as a3, type BaseStructuredOutputType as a4, type StructuredOutputType as a5, type StructuredOutputArrayItem as a6, type StructuredOutput as a7, type GenerateReturn as a8, type StreamReturn as a9, type RetryConfig as aA, type VariableReference$1 as aB, type BaseCondition as aC, type ActionContext as aD, WhenConditionReturnValue as aE, type StepDef as aF, type StepCondition as aG, type StepConfig as aH, type StepResult$1 as aI, type StepsRecord$1 as aJ, type WorkflowRunResult as aK, type WorkflowContext as aL, type WorkflowLogMessage as aM, type WorkflowEvent as aN, type ResolverFunctionInput as aO, type ResolverFunctionOutput as aP, type SubscriberFunctionOutput as aQ, type DependencyCheckOutput as aR, type StepResolverOutput as aS, type WorkflowActors as aT, type WorkflowActionParams as aU, type WorkflowActions as aV, type WorkflowState as aW, type StepId as aX, type ExtractSchemaFromStep$1 as aY, type ExtractStepResult as aZ, type StepInputType as a_, type OutputType as aa, type DefaultLLMTextOptions as ab, type DefaultLLMTextObjectOptions as ac, type DefaultLLMStreamOptions as ad, type DefaultLLMStreamObjectOptions as ae, type LLMTextOptions as af, type LLMTextObjectOptions as ag, type LLMStreamOptions as ah, type LLMInnerStreamOptions as ai, type LLMStreamObjectOptions as aj, createMockModel as ak, type Config as al, type MessageResponse as am, type MemoryConfig as an, type SharedMemoryConfig as ao, type MemoryProcessorOpts as ap, MemoryProcessor as aq, memoryDefaultOptions as ar, createTool as as, type VercelTool as at, type CoreTool as au, type StepExecutionContext as av, type StepAction as aw, type StepVariableType as ax, type StepNode as ay, type StepGraph as az, MastraVoice as b, type PathsToStringProps$1 as b0, type WorkflowResumeResult as b1, type MastraLanguageModel as b2, type ToolsInput as b3, type MastraPrimitives as b4, AgentNetwork as b5, type AgentNetworkConfig as b6, type ToolsetsInput as b7, type AgentGenerateOptions as b8, type AgentStreamOptions as b9, TABLE_WORKFLOW_SNAPSHOT as ba, TABLE_EVALS as bb, TABLE_MESSAGES as bc, TABLE_THREADS as bd, TABLE_TRACES as be, TABLE_SCHEMAS as bf, type VoiceEventMap as c, type VoiceConfig as d, MastraStorage as e, type StorageThreadType as f, type MessageType as g, type StorageGetMessagesArg as h, ExecutionEngine as i, type ExecutionGraph as j, type StepResult as k, type StepFlowEntry as l, type ExecuteFunction as m, createStep as n, cloneStep as o, createWorkflow as p, type WorkflowResult as q, type NewWorkflowConfig as r, NewWorkflow as s, type StepSuccess as t, type StepFailure as u, type StepSuspended as v, type StepsRecord as w, type ExtractSchemaType as x, type ExtractSchemaFromStep as y, type VariableReference as z };