@mastra/core 0.5.0-alpha.9 → 0.5.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.
Files changed (91) hide show
  1. package/dist/agent/index.cjs +3 -2140
  2. package/dist/agent/index.d.cts +1 -1
  3. package/dist/agent/index.d.ts +1 -1
  4. package/dist/agent/index.js +1 -1
  5. package/dist/{base-CMEKtEnE.d.cts → base-CIPKleAU.d.cts} +97 -60
  6. package/dist/{base-B78F6w8S.d.ts → base-C_Oq53qk.d.ts} +97 -60
  7. package/dist/base.cjs +5 -140
  8. package/dist/bundler/index.cjs +5 -160
  9. package/dist/chunk-2W2GYEYQ.cjs +25 -0
  10. package/dist/chunk-3ASEZT7U.cjs +1586 -0
  11. package/dist/chunk-43Y7WG5W.cjs +335 -0
  12. package/dist/{chunk-IM7CM3DU.js → chunk-4Y74D74B.js} +1 -1
  13. package/dist/chunk-ENT7U27Y.cjs +37 -0
  14. package/dist/chunk-F5UYWPV4.cjs +14 -0
  15. package/dist/chunk-FL3GQXQ2.cjs +218 -0
  16. package/dist/chunk-FRQFWZDN.cjs +2 -0
  17. package/dist/chunk-GXQRMKSN.cjs +367 -0
  18. package/dist/chunk-HJPMYDWO.cjs +37 -0
  19. package/dist/chunk-IIWRJFLQ.cjs +51 -0
  20. package/dist/chunk-KFQ7Z3PO.cjs +347 -0
  21. package/dist/{chunk-TWAIC2XA.js → chunk-KP5UAFLN.js} +1 -1
  22. package/dist/chunk-KPKFLQFR.cjs +12 -0
  23. package/dist/{chunk-NR5T72G7.js → chunk-MLFXOST6.js} +1 -1
  24. package/dist/{chunk-6V737PR2.js → chunk-OD7ZMKHY.js} +166 -58
  25. package/dist/chunk-OTFLHXHZ.cjs +65 -0
  26. package/dist/chunk-RWTSGWWL.cjs +81 -0
  27. package/dist/chunk-ST5RMVLG.cjs +87 -0
  28. package/dist/chunk-SYQ7NK2E.cjs +24 -0
  29. package/dist/chunk-UZNQG7QO.cjs +1868 -0
  30. package/dist/chunk-V5ORZPFW.cjs +38 -0
  31. package/dist/chunk-VA4P7QJT.cjs +443 -0
  32. package/dist/chunk-WB2HREXE.cjs +166 -0
  33. package/dist/chunk-WOMOGDGR.cjs +691 -0
  34. package/dist/chunk-XB2TJ7LX.cjs +408 -0
  35. package/dist/{chunk-4AQBRUR2.js → chunk-XF2FMJYK.js} +1 -1
  36. package/dist/chunk-XLSROQ26.cjs +91 -0
  37. package/dist/chunk-YK3XJ52U.cjs +192 -0
  38. package/dist/{chunk-EWB556GS.js → chunk-YPD6BQIM.js} +29 -1
  39. package/dist/deployer/index.cjs +5 -167
  40. package/dist/eval/index.cjs +9 -105
  41. package/dist/eval/index.d.cts +1 -1
  42. package/dist/eval/index.d.ts +1 -1
  43. package/dist/hooks/index.cjs +14 -83
  44. package/dist/index.cjs +253 -7516
  45. package/dist/index.d.cts +3 -3
  46. package/dist/index.d.ts +3 -3
  47. package/dist/index.js +7 -7
  48. package/dist/integration/index.cjs +9 -108
  49. package/dist/integration/index.d.cts +1 -1
  50. package/dist/integration/index.d.ts +1 -1
  51. package/dist/llm/index.d.cts +1 -1
  52. package/dist/llm/index.d.ts +1 -1
  53. package/dist/logger/index.cjs +33 -161
  54. package/dist/mastra/index.cjs +3 -1755
  55. package/dist/mastra/index.d.cts +1 -1
  56. package/dist/mastra/index.d.ts +1 -1
  57. package/dist/mastra/index.js +1 -1
  58. package/dist/memory/index.cjs +4 -2050
  59. package/dist/memory/index.d.cts +1 -1
  60. package/dist/memory/index.d.ts +1 -1
  61. package/dist/memory/index.js +1 -1
  62. package/dist/relevance/index.cjs +10 -2201
  63. package/dist/relevance/index.d.cts +19 -2
  64. package/dist/relevance/index.d.ts +19 -2
  65. package/dist/relevance/index.js +1 -1
  66. package/dist/storage/index.cjs +29 -367
  67. package/dist/storage/index.d.cts +1 -1
  68. package/dist/storage/index.d.ts +1 -1
  69. package/dist/storage/libsql/index.cjs +9 -798
  70. package/dist/storage/libsql/index.d.cts +1 -1
  71. package/dist/storage/libsql/index.d.ts +1 -1
  72. package/dist/telemetry/index.cjs +21 -408
  73. package/dist/telemetry/index.d.cts +1 -1
  74. package/dist/telemetry/index.d.ts +1 -1
  75. package/dist/tools/index.cjs +11 -22
  76. package/dist/tools/index.d.cts +3 -3
  77. package/dist/tools/index.d.ts +3 -3
  78. package/dist/tts/index.cjs +3 -328
  79. package/dist/utils.cjs +41 -350
  80. package/dist/utils.d.cts +3 -3
  81. package/dist/utils.d.ts +3 -3
  82. package/dist/utils.js +1 -1
  83. package/dist/vector/filter/index.cjs +7 -189
  84. package/dist/vector/index.cjs +5 -172
  85. package/dist/vector/libsql/index.cjs +9 -1047
  86. package/dist/voice/index.cjs +8 -306
  87. package/dist/workflows/index.cjs +65 -1936
  88. package/dist/workflows/index.d.cts +4 -3
  89. package/dist/workflows/index.d.ts +4 -3
  90. package/dist/workflows/index.js +1 -1
  91. package/package.json +27 -27
@@ -1,7 +1,7 @@
1
1
  export { Message as AiMessageType } from 'ai';
2
2
  import 'json-schema';
3
3
  import 'zod';
4
- export { A as Agent, i as AgentConfig, au as AgentGenerateOptions, av as AgentStreamOptions, a as ToolsInput, at as ToolsetsInput } from '../base-CMEKtEnE.cjs';
4
+ export { A as Agent, l as AgentConfig, ay as AgentGenerateOptions, az as AgentStreamOptions, aw as MastraLanguageModel, a as ToolsInput, ax as ToolsetsInput } from '../base-CIPKleAU.cjs';
5
5
  import '../base-DboIg_Cd.cjs';
6
6
  import '../types-CwTG2XyQ.cjs';
7
7
  import '../voice/index.cjs';
@@ -1,7 +1,7 @@
1
1
  export { Message as AiMessageType } from 'ai';
2
2
  import 'json-schema';
3
3
  import 'zod';
4
- export { A as Agent, i as AgentConfig, au as AgentGenerateOptions, av as AgentStreamOptions, a as ToolsInput, at as ToolsetsInput } from '../base-B78F6w8S.js';
4
+ export { A as Agent, l as AgentConfig, ay as AgentGenerateOptions, az as AgentStreamOptions, aw as MastraLanguageModel, a as ToolsInput, ax as ToolsetsInput } from '../base-C_Oq53qk.js';
5
5
  import '../base-BZViaFTt.js';
6
6
  import '../types-CwTG2XyQ.js';
7
7
  import '../voice/index.js';
@@ -1 +1 @@
1
- export { Agent } from '../chunk-TWAIC2XA.js';
1
+ export { Agent } from '../chunk-KP5UAFLN.js';
@@ -1,6 +1,6 @@
1
1
  import * as ai from 'ai';
2
2
  import { Tool, ToolExecutionOptions, EmbeddingModel, CoreMessage as CoreMessage$1, Message, UserContent, AssistantContent, LanguageModelV1, TelemetrySettings, generateText, generateObject, streamText, GenerateTextResult, GenerateObjectResult, streamObject, StreamTextResult, StreamObjectResult, CoreSystemMessage as CoreSystemMessage$1, CoreAssistantMessage as CoreAssistantMessage$1, CoreUserMessage as CoreUserMessage$1, CoreToolMessage as CoreToolMessage$1, EmbedResult as EmbedResult$1, EmbedManyResult as EmbedManyResult$1, LanguageModel as LanguageModel$1, DeepPartial, ToolContent } from 'ai';
3
- import { M as MastraBase, O as OtelConfig, T as Telemetry } from './base-DboIg_Cd.cjs';
3
+ import { M as MastraBase, T as Telemetry, O as OtelConfig } from './base-DboIg_Cd.cjs';
4
4
  import { Query } from 'sift';
5
5
  import { z, ZodSchema } from 'zod';
6
6
  import { JSONSchema7 } from 'json-schema';
@@ -23,7 +23,7 @@ interface ToolExecutionContext<TSchemaIn extends z.ZodSchema | undefined = undef
23
23
  }
24
24
  interface ToolAction<TSchemaIn extends z.ZodSchema | undefined = undefined, TSchemaOut extends z.ZodSchema | undefined = undefined, TContext extends ToolExecutionContext<TSchemaIn> = ToolExecutionContext<TSchemaIn>, TOptions extends unknown = unknown> extends IAction<string, TSchemaIn, TSchemaOut, TContext, TOptions> {
25
25
  description: string;
26
- execute: (context: TContext, options?: TOptions) => Promise<TSchemaOut extends z.ZodSchema ? z.infer<TSchemaOut> : unknown>;
26
+ execute?: (context: TContext, options?: TOptions) => Promise<TSchemaOut extends z.ZodSchema ? z.infer<TSchemaOut> : unknown>;
27
27
  mastra?: Mastra;
28
28
  }
29
29
 
@@ -159,6 +159,19 @@ declare abstract class MastraMemory extends MastraBase {
159
159
  generateId(): string;
160
160
  }
161
161
 
162
+ 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> {
163
+ id: TStepId;
164
+ description?: string;
165
+ inputSchema?: TSchemaIn;
166
+ outputSchema?: TSchemaOut;
167
+ payload?: TSchemaIn extends z.ZodSchema ? Partial<z.infer<TSchemaIn>> : unknown;
168
+ execute: (context: TContext) => Promise<TSchemaOut extends z.ZodSchema ? z.infer<TSchemaOut> : unknown>;
169
+ retryConfig?: RetryConfig;
170
+ mastra?: Mastra;
171
+ constructor({ id, description, execute, payload, outputSchema, inputSchema, retryConfig, }: StepAction<TStepId, TSchemaIn, TSchemaOut, TContext>);
172
+ }
173
+ 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>;
174
+
162
175
  interface WorkflowOptions<TTriggerSchema extends z.ZodObject<any> = any> {
163
176
  name: string;
164
177
  triggerSchema?: TTriggerSchema;
@@ -174,6 +187,7 @@ interface StepExecutionContext<TSchemaIn extends z.ZodSchema | undefined = undef
174
187
  interface StepAction<TId extends string, TSchemaIn extends z.ZodSchema | undefined, TSchemaOut extends z.ZodSchema | undefined, TContext extends StepExecutionContext<TSchemaIn>> extends IAction<TId, TSchemaIn, TSchemaOut, TContext> {
175
188
  mastra?: Mastra;
176
189
  payload?: TSchemaIn extends z.ZodSchema ? Partial<z.infer<TSchemaIn>> : unknown;
190
+ execute: (context: TContext) => Promise<TSchemaOut extends z.ZodSchema ? z.infer<TSchemaOut> : unknown>;
177
191
  retryConfig?: RetryConfig;
178
192
  }
179
193
  interface SimpleConditionalType {
@@ -225,14 +239,15 @@ type ActionContext<TSchemaIn extends z.ZodType<any>> = StepExecutionContext<z.in
225
239
  declare enum WhenConditionReturnValue {
226
240
  CONTINUE = "continue",
227
241
  CONTINUE_FAILED = "continue_failed",
228
- ABORT = "abort"
242
+ ABORT = "abort",
243
+ LIMBO = "limbo"
229
244
  }
230
245
  type StepDef<TStepId extends TSteps[number]['id'], TSteps extends StepAction<any, any, any, any>[], TSchemaIn extends z.ZodType<any>, TSchemaOut extends z.ZodType<any>> = Record<TStepId, {
231
- snapshotOnTimeout?: boolean;
232
246
  when?: Condition<any, any> | ((args: {
233
247
  context: WorkflowContext;
234
248
  mastra?: Mastra;
235
249
  }) => Promise<boolean | WhenConditionReturnValue>);
250
+ serializedWhen?: Condition<any, any> | string;
236
251
  data: TSchemaIn;
237
252
  handler: (args: ActionContext<TSchemaIn>) => Promise<z.infer<TSchemaOut>>;
238
253
  }>;
@@ -250,10 +265,9 @@ type Condition<TStep extends StepVariableType<any, any, any, any>, TTriggerSchem
250
265
  } | {
251
266
  not: Condition<TStep, TTriggerSchema>;
252
267
  };
253
- interface StepConfig<TStep extends StepAction<any, any, any, any>, CondStep extends StepVariableType<any, any, any, any>, VarStep extends StepVariableType<any, any, any, any>, TTriggerSchema extends z.ZodObject<any>> {
254
- snapshotOnTimeout?: boolean;
268
+ interface StepConfig<TStep extends StepAction<any, any, any, any>, CondStep extends StepVariableType<any, any, any, any>, VarStep extends StepVariableType<any, any, any, any>, TTriggerSchema extends z.ZodObject<any>, TSteps extends Step<string, any, any, any>[] = Step<string, any, any, any>[]> {
255
269
  when?: Condition<CondStep, TTriggerSchema> | ((args: {
256
- context: WorkflowContext<TTriggerSchema>;
270
+ context: WorkflowContext<TTriggerSchema, TSteps>;
257
271
  mastra?: Mastra;
258
272
  }) => Promise<boolean | WhenConditionReturnValue>);
259
273
  variables?: StepInputType<TStep, 'inputSchema'> extends never ? Record<string, VariableReference<VarStep, TTriggerSchema>> : {
@@ -275,13 +289,35 @@ type StepFailure = {
275
289
  status: 'failed';
276
290
  error: string;
277
291
  };
278
- type StepResult<T> = StepSuccess<T> | StepFailure | StepSuspended | StepWaiting;
279
- interface WorkflowContext<TTrigger extends z.ZodObject<any> = any> {
292
+ type StepSkipped = {
293
+ status: 'skipped';
294
+ };
295
+ type StepResult<T> = StepSuccess<T> | StepFailure | StepSuspended | StepWaiting | StepSkipped;
296
+ type StepsRecord<T extends readonly Step<any, any, z.ZodType<any> | undefined>[]> = {
297
+ [K in T[number]['id']]: Extract<T[number], {
298
+ id: K;
299
+ }>;
300
+ };
301
+ interface WorkflowRunResult<T extends z.ZodType<any>, TSteps extends Step<string, any, z.ZodType<any> | undefined>[]> {
302
+ triggerData?: z.infer<T>;
303
+ results: {
304
+ [K in keyof StepsRecord<TSteps>]: StepsRecord<TSteps>[K]['outputSchema'] extends undefined ? StepResult<unknown> : StepResult<z.infer<NonNullable<StepsRecord<TSteps>[K]['outputSchema']>>>;
305
+ };
306
+ runId: string;
307
+ activePaths: Map<string, {
308
+ status: string;
309
+ suspendPayload?: any;
310
+ }>;
311
+ }
312
+ interface WorkflowContext<TTrigger extends z.ZodObject<any> = any, TSteps extends Step<string, any, any, any>[] = Step<string, any, any, any>[]> {
280
313
  mastra?: MastraUnion;
281
- steps: Record<string, StepResult<any>>;
314
+ steps: {
315
+ [K in keyof StepsRecord<TSteps>]: StepsRecord<TSteps>[K]['outputSchema'] extends undefined ? StepResult<unknown> : StepResult<z.infer<NonNullable<StepsRecord<TSteps>[K]['outputSchema']>>>;
316
+ };
282
317
  triggerData: z.infer<TTrigger>;
283
318
  attempts: Record<string, number>;
284
- getStepResult: <T = unknown>(stepId: string) => T | undefined;
319
+ 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;
320
+ getStepResult<T extends Step<any, any, any, any>>(stepId: T): T['outputSchema'] extends undefined ? unknown : z.infer<NonNullable<T['outputSchema']>>;
285
321
  }
286
322
  interface WorkflowLogMessage extends BaseLogMessage {
287
323
  type: typeof RegisteredLogger.WORKFLOW;
@@ -337,11 +373,22 @@ type DependencyCheckOutput = {
337
373
  type: 'SUSPENDED';
338
374
  } | {
339
375
  type: 'WAITING';
376
+ } | {
377
+ type: 'CONDITIONS_LIMBO';
378
+ };
379
+ type StepResolverOutput = {
380
+ type: 'STEP_SUCCESS';
381
+ output: unknown;
382
+ } | {
383
+ type: 'STEP_FAILED';
384
+ error: string;
385
+ } | {
386
+ type: 'STEP_WAITING';
340
387
  };
341
388
  type WorkflowActors = {
342
389
  resolverFunction: {
343
390
  input: ResolverFunctionInput;
344
- output: ResolverFunctionOutput;
391
+ output: StepResolverOutput;
345
392
  };
346
393
  conditionCheck: {
347
394
  input: {
@@ -443,7 +490,7 @@ interface WorkflowRunState {
443
490
  value: Record<string, string>;
444
491
  context: {
445
492
  steps: Record<string, {
446
- status: 'success' | 'failed' | 'suspended' | 'waiting';
493
+ status: 'success' | 'failed' | 'suspended' | 'waiting' | 'skipped';
447
494
  payload?: any;
448
495
  error?: string;
449
496
  }>;
@@ -465,35 +512,14 @@ type WorkflowResumeResult<TTriggerSchema extends z.ZodObject<any>> = {
465
512
  results: Record<string, StepResult<any>>;
466
513
  };
467
514
 
468
- 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> {
469
- id: TStepId;
470
- description?: string;
471
- inputSchema?: TSchemaIn;
472
- outputSchema?: TSchemaOut;
473
- payload?: TSchemaIn extends z.ZodSchema ? Partial<z.infer<TSchemaIn>> : unknown;
474
- execute: (context: TContext) => Promise<TSchemaOut extends z.ZodSchema ? z.infer<TSchemaOut> : unknown>;
475
- retryConfig?: RetryConfig;
476
- mastra?: Mastra;
477
- constructor({ id, description, execute, payload, outputSchema, inputSchema, retryConfig, }: StepAction<TStepId, TSchemaIn, TSchemaOut, TContext>);
478
- }
479
- 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>;
480
-
481
- interface WorkflowResultReturn<T extends z.ZodType<any>> {
515
+ interface WorkflowResultReturn<T extends z.ZodType<any>, TSteps extends Step<any, any, any>[]> {
482
516
  runId: string;
483
517
  start: (props?: {
484
518
  triggerData?: z.infer<T>;
485
- } | undefined) => Promise<{
486
- triggerData?: z.infer<T>;
487
- results: Record<string, StepResult<any>>;
488
- runId: string;
489
- activePaths: Map<string, {
490
- status: string;
491
- suspendPayload?: any;
492
- }>;
493
- }>;
519
+ } | undefined) => Promise<WorkflowRunResult<T, TSteps>>;
494
520
  }
495
521
 
496
- declare class Workflow<TSteps extends Step<any, any, any>[] = any, TTriggerSchema extends z.ZodObject<any> = any> extends MastraBase {
522
+ declare class Workflow<TSteps extends Step<string, any, any>[] = Step<string, any, any>[], TTriggerSchema extends z.ZodObject<any> = any> extends MastraBase {
497
523
  #private;
498
524
  name: string;
499
525
  triggerSchema?: TTriggerSchema;
@@ -507,7 +533,7 @@ declare class Workflow<TSteps extends Step<any, any, any>[] = any, TTriggerSchem
507
533
  then<TStep extends StepAction<any, any, any, any>, CondStep extends StepVariableType<any, any, any, any>, VarStep extends StepVariableType<any, any, any, any>>(step: TStep, config?: StepConfig<TStep, CondStep, VarStep, TTriggerSchema>): this;
508
534
  private loop;
509
535
  while<FallbackStep extends StepAction<any, any, any, any>, CondStep extends StepVariableType<any, any, any, any>, VarStep extends StepVariableType<any, any, any, any>>(condition: StepConfig<FallbackStep, CondStep, VarStep, TTriggerSchema>['when'], fallbackStep: FallbackStep): this;
510
- until<FallbackStep extends StepAction<any, any, any, any>, CondStep extends StepVariableType<any, any, any, any>, VarStep extends StepVariableType<any, any, any, any>>(condition: StepConfig<FallbackStep, CondStep, VarStep, TTriggerSchema>['when'], fallbackStep: FallbackStep): this;
536
+ until<FallbackStep extends StepAction<any, any, any, any>, CondStep extends StepVariableType<any, any, any, any>, VarStep extends StepVariableType<any, any, any, any>>(condition: StepConfig<FallbackStep, CondStep, VarStep, TTriggerSchema, TSteps>['when'], fallbackStep: FallbackStep): this;
511
537
  if<TStep extends StepAction<any, any, any, any>>(condition: StepConfig<TStep, any, any, TTriggerSchema>['when']): this;
512
538
  else(): this;
513
539
  after<TStep extends StepAction<any, any, any, any>>(steps: TStep | TStep[]): Omit<typeof this, "then" | "after">;
@@ -517,7 +543,7 @@ declare class Workflow<TSteps extends Step<any, any, any>[] = any, TTriggerSchem
517
543
  * @returns Promise resolving to workflow results or rejecting with error
518
544
  * @throws Error if trigger schema validation fails
519
545
  */
520
- createRun(): WorkflowResultReturn<TTriggerSchema>;
546
+ createRun(): WorkflowResultReturn<TTriggerSchema, TSteps>;
521
547
  /**
522
548
  * Rebuilds the machine with the current steps configuration and validates the workflow
523
549
  *
@@ -534,26 +560,12 @@ declare class Workflow<TSteps extends Step<any, any, any>[] = any, TTriggerSchem
534
560
  runId: string;
535
561
  stepId: string;
536
562
  context?: Record<string, any>;
537
- }): Promise<{
538
- triggerData?: z.TypeOf<TTriggerSchema> | undefined;
539
- results: Record<string, StepResult<any>>;
540
- activePaths: Map<string, {
541
- status: string;
542
- suspendPayload?: any;
543
- }>;
544
- } | undefined>;
563
+ }): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps>, "runId"> | undefined>;
545
564
  _resume({ runId, stepId, context: resumeContext, }: {
546
565
  runId: string;
547
566
  stepId: string;
548
567
  context?: Record<string, any>;
549
- }): Promise<{
550
- triggerData?: z.TypeOf<TTriggerSchema> | undefined;
551
- results: Record<string, StepResult<any>>;
552
- activePaths: Map<string, {
553
- status: string;
554
- suspendPayload?: any;
555
- }>;
556
- } | undefined>;
568
+ }): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps>, "runId"> | undefined>;
557
569
  __registerMastra(mastra: Mastra): void;
558
570
  __registerPrimitives(p: MastraPrimitives): void;
559
571
  get stepGraph(): StepGraph;
@@ -570,12 +582,30 @@ interface Config<TAgents extends Record<string, Agent<any>> = Record<string, Age
570
582
  tts?: TTTS;
571
583
  telemetry?: OtelConfig;
572
584
  deployer?: MastraDeployer;
585
+ /**
586
+ * Server middleware functions to be applied to API routes
587
+ * Each middleware can specify a path pattern (defaults to '/api/*')
588
+ */
589
+ serverMiddleware?: Array<{
590
+ handler: (c: any, next: () => Promise<void>) => Promise<Response | void>;
591
+ path?: string;
592
+ }>;
573
593
  memory?: MastraMemory;
574
594
  }
575
595
  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> {
576
596
  #private;
597
+ /**
598
+ * @deprecated use getStorage() instead
599
+ */
577
600
  storage?: MastraStorage;
601
+ /**
602
+ * @deprecated use getMemory() instead
603
+ */
578
604
  memory?: MastraMemory;
605
+ /**
606
+ * @deprecated use getTelemetry() instead
607
+ */
608
+ get telemetry(): Telemetry | undefined;
579
609
  constructor(config?: Config<TAgents, TWorkflows, TVectors, TTTS, TLogger>);
580
610
  getAgent<TAgentName extends keyof TAgents>(name: TAgentName): TAgents[TAgentName];
581
611
  getAgents(): TAgents;
@@ -596,6 +626,12 @@ declare class Mastra<TAgents extends Record<string, Agent<any>> = Record<string,
596
626
  getTTS(): TTTS | undefined;
597
627
  getLogger(): TLogger;
598
628
  getTelemetry(): Telemetry | undefined;
629
+ getMemory(): MastraMemory | undefined;
630
+ getStorage(): MastraStorage | undefined;
631
+ getServerMiddleware(): {
632
+ handler: (c: any, next: () => Promise<void>) => Promise<Response | void>;
633
+ path: string;
634
+ }[];
599
635
  getLogsByRunId({ runId, transportId }: {
600
636
  runId: string;
601
637
  transportId: string;
@@ -626,15 +662,16 @@ interface IAction<TId extends string, TSchemaIn extends z.ZodSchema | undefined,
626
662
  description?: string;
627
663
  inputSchema?: TSchemaIn;
628
664
  outputSchema?: TSchemaOut;
629
- execute: (context: TContext, options?: TOptions) => Promise<TSchemaOut extends z.ZodSchema ? z.infer<TSchemaOut> : unknown>;
665
+ execute?: (context: TContext, options?: TOptions) => Promise<TSchemaOut extends z.ZodSchema ? z.infer<TSchemaOut> : unknown>;
630
666
  }
631
667
 
632
668
  type ToolsInput = Record<string, ToolAction<any, any, any> | VercelTool>;
633
669
  type ToolsetsInput = Record<string, ToolsInput>;
670
+ type MastraLanguageModel = LanguageModelV1;
634
671
  interface AgentConfig<TTools extends ToolsInput = ToolsInput, TMetrics extends Record<string, Metric> = Record<string, Metric>> {
635
672
  name: string;
636
673
  instructions: string;
637
- model: LanguageModelV1;
674
+ model: MastraLanguageModel;
638
675
  tools?: TTools;
639
676
  mastra?: Mastra;
640
677
  /** @deprecated This property is deprecated. Use evals instead to add evaluation metrics. */
@@ -688,7 +725,7 @@ type AgentStreamOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefine
688
725
  threadId: string;
689
726
  }) & (Z extends undefined ? DefaultLLMStreamOptions : DefaultLLMStreamObjectOptions);
690
727
 
691
- type LanguageModel = LanguageModelV1;
728
+ type LanguageModel = MastraLanguageModel;
692
729
  type CoreMessage = CoreMessage$1;
693
730
  type CoreSystemMessage = CoreSystemMessage$1;
694
731
  type CoreAssistantMessage = CoreAssistantMessage$1;
@@ -778,7 +815,7 @@ declare class Agent<TTools extends ToolsInput = ToolsInput, TMetrics extends Rec
778
815
  name: string;
779
816
  readonly llm: MastraLLMBase;
780
817
  instructions: string;
781
- readonly model?: LanguageModelV1;
818
+ readonly model?: MastraLanguageModel;
782
819
  tools: TTools;
783
820
  /** @deprecated This property is deprecated. Use evals instead. */
784
821
  metrics: TMetrics;
@@ -1116,4 +1153,4 @@ declare abstract class MastraStorage extends MastraBase {
1116
1153
  __getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
1117
1154
  }
1118
1155
 
1119
- export { type StepGraph as $, Agent as A, type BaseStructuredOutputType as B, type CoreTool as C, type DefaultLLMTextOptions as D, type EvalRow as E, type DefaultLLMStreamObjectOptions as F, type GenerateReturn as G, type LLMTextOptions as H, type LLMTextObjectOptions as I, type LLMStreamOptions as J, type LLMInnerStreamOptions as K, type LanguageModel as L, Mastra as M, type LLMStreamObjectOptions as N, type OutputType as O, type Config as P, type MessageResponse as Q, type MemoryConfig as R, type StorageColumn as S, type ToolAction as T, type SharedMemoryConfig as U, type VercelTool as V, Workflow as W, type StepExecutionContext as X, type StepAction as Y, type StepVariableType as Z, type StepNode as _, type ToolsInput as a, type RetryConfig as a0, type VariableReference as a1, type BaseCondition as a2, type ActionContext as a3, WhenConditionReturnValue as a4, type StepDef as a5, type StepCondition as a6, type StepConfig as a7, type StepResult as a8, type WorkflowContext as a9, TABLE_TRACES as aA, type WorkflowLogMessage as aa, type WorkflowEvent as ab, type ResolverFunctionInput as ac, type ResolverFunctionOutput as ad, type SubscriberFunctionOutput as ae, type DependencyCheckOutput as af, type WorkflowActors as ag, type WorkflowActionParams as ah, type WorkflowActions as ai, type WorkflowState as aj, type StepId as ak, type ExtractSchemaFromStep as al, type ExtractStepResult as am, type StepInputType as an, type ExtractSchemaType as ao, type PathsToStringProps as ap, type WorkflowRunState as aq, type WorkflowResumeResult as ar, createStep as as, type ToolsetsInput as at, type AgentGenerateOptions as au, type AgentStreamOptions as av, TABLE_WORKFLOW_SNAPSHOT as aw, TABLE_EVALS as ax, TABLE_MESSAGES as ay, TABLE_THREADS as az, type MastraPrimitives as b, MastraMemory as c, MastraStorage as d, type TABLE_NAMES as e, type StorageThreadType as f, type MessageType as g, type StorageGetMessagesArg as h, type AgentConfig as i, type ToolExecutionContext as j, Step as k, type WorkflowOptions as l, type WorkflowRow as m, type CoreMessage as n, type CoreSystemMessage as o, type CoreAssistantMessage as p, type CoreUserMessage as q, type CoreToolMessage as r, type EmbedResult as s, type EmbedManyResult as t, type StructuredOutputType as u, type StructuredOutputArrayItem as v, type StructuredOutput as w, type StreamReturn as x, type DefaultLLMTextObjectOptions as y, type DefaultLLMStreamOptions as z };
1156
+ export { type StepNode as $, Agent as A, type BaseStructuredOutputType as B, type CoreTool as C, type DefaultLLMTextOptions as D, type EvalRow as E, type DefaultLLMTextObjectOptions as F, type GenerateReturn as G, type DefaultLLMStreamOptions as H, type DefaultLLMStreamObjectOptions as I, type LLMTextOptions as J, type LLMTextObjectOptions as K, type LanguageModel as L, Mastra as M, type LLMStreamOptions as N, type OutputType as O, type LLMInnerStreamOptions as P, type LLMStreamObjectOptions as Q, type Config as R, Step as S, type ToolAction as T, type MessageResponse as U, type VercelTool as V, Workflow as W, type MemoryConfig as X, type SharedMemoryConfig as Y, type StepAction as Z, type StepVariableType as _, type ToolsInput as a, type StepGraph as a0, type RetryConfig as a1, type VariableReference as a2, type BaseCondition as a3, type ActionContext as a4, WhenConditionReturnValue as a5, type StepDef as a6, type StepCondition as a7, type StepConfig as a8, type StepResult as a9, TABLE_WORKFLOW_SNAPSHOT as aA, TABLE_EVALS as aB, TABLE_MESSAGES as aC, TABLE_THREADS as aD, TABLE_TRACES as aE, type StepsRecord as aa, type WorkflowRunResult as ab, type WorkflowLogMessage as ac, type WorkflowEvent as ad, type ResolverFunctionInput as ae, type ResolverFunctionOutput as af, type SubscriberFunctionOutput as ag, type DependencyCheckOutput as ah, type StepResolverOutput as ai, type WorkflowActors as aj, type WorkflowActionParams as ak, type WorkflowActions as al, type WorkflowState as am, type StepId as an, type ExtractSchemaFromStep as ao, type ExtractStepResult as ap, type StepInputType as aq, type ExtractSchemaType as ar, type PathsToStringProps as as, type WorkflowRunState as at, type WorkflowResumeResult as au, createStep as av, type MastraLanguageModel as aw, type ToolsetsInput as ax, type AgentGenerateOptions as ay, type AgentStreamOptions as az, type MastraPrimitives as b, MastraMemory as c, type StepExecutionContext as d, type WorkflowContext as e, MastraStorage as f, type TABLE_NAMES as g, type StorageColumn as h, type StorageThreadType as i, type MessageType as j, type StorageGetMessagesArg as k, type AgentConfig as l, type ToolExecutionContext as m, type WorkflowOptions as n, type WorkflowRow as o, type CoreMessage as p, type CoreSystemMessage as q, type CoreAssistantMessage as r, type CoreUserMessage as s, type CoreToolMessage as t, type EmbedResult as u, type EmbedManyResult as v, type StructuredOutputType as w, type StructuredOutputArrayItem as x, type StructuredOutput as y, type StreamReturn as z };