@mastra/core 0.2.0-alpha.84 → 0.2.0-alpha.86

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 (83) hide show
  1. package/README.md +1 -1
  2. package/dist/action/index.d.ts +2 -2
  3. package/dist/agent/index.d.ts +6 -6
  4. package/dist/agent/index.js +1 -1
  5. package/dist/chunk-2ISN3AA7.js +392 -0
  6. package/dist/chunk-2J5OHBUG.js +24 -0
  7. package/dist/{chunk-Y7TKCKRI.js → chunk-5NQ3MEZM.js} +8 -8
  8. package/dist/{chunk-SAXFXAKK.js → chunk-73XDWPXJ.js} +41 -24
  9. package/dist/{chunk-3IV6WDJY.js → chunk-D66E7L7R.js} +1 -1
  10. package/dist/{chunk-3THCTISX.js → chunk-EVYBUFXB.js} +12 -8
  11. package/dist/{chunk-PRYZIZXD.js → chunk-I3MJB67Z.js} +8 -8
  12. package/dist/{chunk-42THOFKJ.js → chunk-RCS7AVH6.js} +1 -1
  13. package/dist/chunk-RLPH6TDJ.js +30 -0
  14. package/dist/embeddings/index.d.ts +2 -2
  15. package/dist/embeddings/index.js +1 -1
  16. package/dist/eval/index.d.ts +2 -2
  17. package/dist/filter/index.d.ts +6 -6
  18. package/dist/{index-62DyKJRU.d.ts → index-Duqv1Yom.d.ts} +340 -322
  19. package/dist/index.d.ts +6 -6
  20. package/dist/index.js +10 -10
  21. package/dist/integration/index.d.ts +7 -7
  22. package/dist/llm/index.d.ts +3 -3
  23. package/dist/llm/model/providers/anthropic-vertex.d.ts +31 -0
  24. package/dist/llm/model/providers/anthropic-vertex.js +23 -0
  25. package/dist/llm/model/providers/anthropic.d.ts +29 -0
  26. package/dist/llm/model/providers/anthropic.js +21 -0
  27. package/dist/llm/model/providers/azure.d.ts +48 -0
  28. package/dist/llm/model/providers/azure.js +50 -0
  29. package/dist/llm/model/providers/baseten.d.ts +33 -0
  30. package/dist/llm/model/providers/baseten.js +29 -0
  31. package/dist/llm/model/providers/bedrock.d.ts +32 -0
  32. package/dist/llm/model/providers/bedrock.js +24 -0
  33. package/dist/llm/model/providers/cerebras.d.ts +30 -0
  34. package/dist/llm/model/providers/cerebras.js +22 -0
  35. package/dist/llm/model/providers/cohere.d.ts +30 -0
  36. package/dist/llm/model/providers/cohere.js +22 -0
  37. package/dist/llm/model/providers/deepinfra.d.ts +30 -0
  38. package/dist/llm/model/providers/deepinfra.js +22 -0
  39. package/dist/llm/model/providers/deepseek.d.ts +30 -0
  40. package/dist/llm/model/providers/deepseek.js +22 -0
  41. package/dist/llm/model/providers/fireworks.d.ts +35 -0
  42. package/dist/llm/model/providers/fireworks.js +40 -0
  43. package/dist/llm/model/providers/google-vertex.d.ts +48 -0
  44. package/dist/llm/model/providers/google-vertex.js +22 -0
  45. package/dist/llm/model/providers/google.d.ts +54 -0
  46. package/dist/llm/model/providers/google.js +23 -0
  47. package/dist/llm/model/providers/grok.d.ts +32 -0
  48. package/dist/llm/model/providers/grok.js +22 -0
  49. package/dist/llm/model/providers/groq.d.ts +37 -0
  50. package/dist/llm/model/providers/groq.js +42 -0
  51. package/dist/llm/model/providers/lmstudio.d.ts +29 -0
  52. package/dist/llm/model/providers/lmstudio.js +22 -0
  53. package/dist/llm/model/providers/mistral.d.ts +30 -0
  54. package/dist/llm/model/providers/mistral.js +22 -0
  55. package/dist/llm/model/providers/mock.d.ts +30 -0
  56. package/dist/llm/model/providers/mock.js +83 -0
  57. package/dist/llm/model/providers/ollama.d.ts +31 -0
  58. package/dist/llm/model/providers/ollama.js +23 -0
  59. package/dist/llm/model/providers/openai-compat.d.ts +39 -0
  60. package/dist/llm/model/providers/openai-compat.js +6 -0
  61. package/dist/llm/model/providers/openai.d.ts +34 -0
  62. package/dist/llm/model/providers/openai.js +6 -0
  63. package/dist/llm/model/providers/openai.test.d.ts +2 -0
  64. package/dist/llm/model/providers/openai.test.js +220 -0
  65. package/dist/llm/model/providers/perplexity.d.ts +30 -0
  66. package/dist/llm/model/providers/perplexity.js +22 -0
  67. package/dist/llm/model/providers/portkey.d.ts +34 -0
  68. package/dist/llm/model/providers/portkey.js +22 -0
  69. package/dist/llm/model/providers/togetherai.d.ts +30 -0
  70. package/dist/llm/model/providers/togetherai.js +22 -0
  71. package/dist/mastra/index.d.ts +3 -3
  72. package/dist/memory/index.d.ts +1 -1
  73. package/dist/memory/index.js +1 -1
  74. package/dist/model-QGWIMOSx.d.ts +31 -0
  75. package/dist/relevance/index.d.ts +2 -2
  76. package/dist/relevance/index.js +2 -2
  77. package/dist/storage/index.d.ts +3 -3
  78. package/dist/storage/index.js +1 -1
  79. package/dist/tools/index.d.ts +3 -3
  80. package/dist/vector/index.js +2 -2
  81. package/dist/{workflow-DGktrYAL.d.ts → workflow-DQ8CtzzU.d.ts} +1 -1
  82. package/dist/workflows/index.d.ts +4 -4
  83. package/package.json +30 -14
@@ -1,13 +1,13 @@
1
1
  import * as ai from 'ai';
2
- import { Message, UserContent, AssistantContent, ToolContent, CoreMessage as CoreMessage$1, CoreSystemMessage as CoreSystemMessage$1, CoreAssistantMessage as CoreAssistantMessage$1, CoreUserMessage as CoreUserMessage$1, CoreToolMessage as CoreToolMessage$1, EmbedResult as EmbedResult$1, EmbedManyResult as EmbedManyResult$1, LanguageModelV1, GenerateTextResult, GenerateObjectResult, StreamTextResult, StreamObjectResult, CoreTool as CoreTool$1 } from 'ai';
2
+ import { CoreMessage as CoreMessage$1, CoreSystemMessage as CoreSystemMessage$1, CoreAssistantMessage as CoreAssistantMessage$1, CoreUserMessage as CoreUserMessage$1, CoreToolMessage as CoreToolMessage$1, EmbedResult as EmbedResult$1, EmbedManyResult as EmbedManyResult$1, LanguageModelV1, GenerateTextResult, GenerateObjectResult, StreamTextResult, StreamObjectResult, DeepPartial, Message, UserContent, AssistantContent, ToolContent, CoreTool as CoreTool$1 } from 'ai';
3
3
  import { JSONSchema7 } from 'json-schema';
4
4
  import { z, ZodSchema } from 'zod';
5
5
  import { MastraBase } from './base.js';
6
6
  import { M as Metric } from './metric-D2V4CR8D.js';
7
- import { E as EmbeddingOptions } from './types-M16hSruO.js';
8
7
  import { T as Telemetry } from './telemetry-oCUM52DG.js';
9
- import { Query } from 'sift';
10
8
  import { B as BaseLogMessage, R as RegisteredLogger, b as Run, L as Logger } from './index-B0-NXUYv.js';
9
+ import { Query } from 'sift';
10
+ import { E as EmbeddingOptions } from './types-M16hSruO.js';
11
11
  import { MastraVector } from './vector/index.js';
12
12
  import { M as MastraEngine } from './engine-EwEG-4Iv.js';
13
13
  import { MastraTTS } from './tts/index.js';
@@ -291,327 +291,65 @@ interface WorkflowRunState {
291
291
  timestamp: number;
292
292
  }
293
293
 
294
- interface StorageColumn {
295
- type: 'text' | 'timestamp' | 'uuid' | 'jsonb' | 'integer';
296
- primaryKey?: boolean;
297
- nullable?: boolean;
298
- references?: {
299
- table: string;
300
- column: string;
301
- };
302
- }
303
- interface WorkflowRow {
304
- workflow_name: string;
305
- run_id: string;
306
- snapshot: WorkflowRunState;
307
- created_at: Date;
308
- updated_at: Date;
309
- }
310
- type StorageGetMessagesArg = {
311
- threadId: string;
312
- selectBy?: {
313
- vectorSearchString?: string;
314
- last?: number | false;
315
- include?: {
316
- id: string;
317
- withPreviousMessages?: number;
318
- withNextMessages?: number;
319
- }[];
320
- };
321
- threadConfig?: MemoryConfig;
294
+ type CoreTool = {
295
+ description?: string;
296
+ parameters: ZodSchema;
297
+ execute: (params: any) => Promise<any>;
322
298
  };
323
-
324
- type TABLE_NAMES = typeof MastraStorage.TABLE_WORKFLOW_SNAPSHOT | typeof MastraStorage.TABLE_EVALS | typeof MastraStorage.TABLE_MESSAGES | typeof MastraStorage.TABLE_THREADS;
325
- declare abstract class MastraStorage extends MastraBase {
326
- static readonly TABLE_WORKFLOW_SNAPSHOT = "workflow_snapshot";
327
- static readonly TABLE_EVALS = "evals";
328
- static readonly TABLE_MESSAGES = "messages";
329
- static readonly TABLE_THREADS = "threads";
330
- hasInit: boolean;
331
- constructor({ name }: {
332
- name: string;
333
- });
334
- abstract createTable({ tableName }: {
335
- tableName: TABLE_NAMES;
336
- schema: Record<string, StorageColumn>;
337
- }): Promise<void>;
338
- abstract clearTable({ tableName }: {
339
- tableName: TABLE_NAMES;
340
- }): Promise<void>;
341
- abstract insert({ tableName, record }: {
342
- tableName: TABLE_NAMES;
343
- record: Record<string, any>;
344
- }): Promise<void>;
345
- abstract load<R>({ tableName, keys }: {
346
- tableName: TABLE_NAMES;
347
- keys: Record<string, string>;
348
- }): Promise<R | null>;
349
- abstract getThreadById({ threadId }: {
350
- threadId: string;
351
- }): Promise<StorageThreadType | null>;
352
- __getThreadById({ threadId }: {
353
- threadId: string;
354
- }): Promise<StorageThreadType | null>;
355
- abstract getThreadsByResourceId({ resourceId }: {
356
- resourceId: string;
357
- }): Promise<StorageThreadType[]>;
358
- __getThreadsByResourceId({ resourceId }: {
359
- resourceId: string;
360
- }): Promise<StorageThreadType[]>;
361
- abstract saveThread({ thread }: {
362
- thread: StorageThreadType;
363
- }): Promise<StorageThreadType>;
364
- __saveThread({ thread }: {
365
- thread: StorageThreadType;
366
- }): Promise<StorageThreadType>;
367
- abstract updateThread({ id, title, metadata, }: {
368
- id: string;
369
- title: string;
370
- metadata: Record<string, unknown>;
371
- }): Promise<StorageThreadType>;
372
- __updateThread({ id, title, metadata, }: {
373
- id: string;
374
- title: string;
375
- metadata: Record<string, unknown>;
376
- }): Promise<StorageThreadType>;
377
- abstract deleteThread({ threadId }: {
378
- threadId: string;
379
- }): Promise<void>;
380
- __deleteThread({ threadId }: {
381
- threadId: string;
382
- }): Promise<void>;
383
- abstract getMessages({ threadId, selectBy, threadConfig }: StorageGetMessagesArg): Promise<MessageType[]>;
384
- __getMessages({ threadId, selectBy, threadConfig }: StorageGetMessagesArg): Promise<MessageType[]>;
385
- abstract saveMessages({ messages }: {
386
- messages: MessageType[];
387
- }): Promise<MessageType[]>;
388
- __saveMessages({ messages }: {
389
- messages: MessageType[];
390
- }): Promise<MessageType[]>;
391
- init(): Promise<void>;
392
- persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
393
- workflowName: string;
394
- runId: string;
395
- snapshot: WorkflowRunState;
396
- }): Promise<void>;
397
- loadWorkflowSnapshot({ workflowName, runId, }: {
398
- workflowName: string;
399
- runId: string;
400
- }): Promise<WorkflowRunState | null>;
299
+ interface ToolExecutionContext<TSchemaIn extends z.ZodSchema | undefined = undefined, TContext extends WorkflowContext = WorkflowContext> extends IExecutionContext<TSchemaIn, TContext> {
300
+ }
301
+ interface ToolAction<TId extends string, TSchemaIn extends z.ZodSchema | undefined = undefined, TSchemaOut extends z.ZodSchema | undefined = undefined, TContext extends ToolExecutionContext<TSchemaIn> = ToolExecutionContext<TSchemaIn>> extends IAction<TId, TSchemaIn, TSchemaOut, TContext> {
401
302
  }
402
303
 
403
- type AiMessageType = Message;
404
- type MessageType = {
405
- id: string;
406
- content: UserContent | AssistantContent | ToolContent;
407
- role: 'system' | 'user' | 'assistant' | 'tool';
408
- createdAt: Date;
409
- threadId: string;
410
- toolCallIds?: string[];
411
- toolCallArgs?: Record<string, unknown>[];
412
- toolNames?: string[];
413
- type: 'text' | 'tool-call' | 'tool-result';
414
- };
415
- type StorageThreadType = {
416
- id: string;
417
- title?: string;
418
- resourceId: string;
419
- createdAt: Date;
420
- updatedAt: Date;
421
- metadata?: Record<string, unknown>;
422
- };
423
- type MessageResponse<T extends 'raw' | 'core_message'> = {
424
- raw: MessageType[];
425
- core_message: CoreMessage$1[];
426
- }[T];
427
- type MemoryConfig = {
428
- lastMessages?: number | false;
429
- historySearch?: boolean | {
430
- topK: number;
431
- messageRange: number | {
432
- before: number;
433
- after: number;
434
- };
435
- };
304
+ type OpenAIModel = 'gpt-4' | 'gpt-4-turbo' | 'gpt-3.5-turbo' | 'gpt-4o' | 'gpt-4o-mini' | 'o1' | 'o1-mini' | 'o1-preview';
305
+ type CoreMessage = CoreMessage$1;
306
+ type CoreSystemMessage = CoreSystemMessage$1;
307
+ type CoreAssistantMessage = CoreAssistantMessage$1;
308
+ type CoreUserMessage = CoreUserMessage$1;
309
+ type CoreToolMessage = CoreToolMessage$1;
310
+ type EmbedResult<T> = EmbedResult$1<T>;
311
+ type EmbedManyResult<T> = EmbedManyResult$1<T>;
312
+ type OpenAIConfig = {
313
+ provider: 'OPEN_AI';
314
+ name: OpenAIModel | (string & {});
315
+ toolChoice?: 'auto' | 'required';
316
+ apiKey?: string;
317
+ baseURL?: string;
318
+ headers?: Record<string, string>;
319
+ fetch?: typeof globalThis.fetch;
436
320
  };
437
- type SharedMemoryConfig = {
438
- storage: MastraStorage;
439
- options?: MemoryConfig;
440
- vector?: MastraVector;
441
- embeddingOptions?: EmbeddingOptions;
442
- } | {
443
- storage: MastraStorage;
444
- options?: MemoryConfig;
445
- vector: MastraVector;
446
- embeddingOptions: EmbeddingOptions;
321
+ type GoogleModel = 'gemini-1.5-pro-latest' | 'gemini-1.5-pro' | 'gemini-1.5-flash-latest' | 'gemini-1.5-flash' | 'gemini-2.0-flash-exp-latest' | 'gemini-2.0-flash-thinking-exp-1219' | 'gemini-exp-1206';
322
+ type GoogleConfig = {
323
+ provider: 'GOOGLE';
324
+ name: GoogleModel | (string & {});
325
+ toolChoice?: 'auto' | 'required';
326
+ apiKey?: string;
327
+ baseURL?: string;
328
+ headers?: Record<string, string>;
329
+ fetch?: typeof globalThis.fetch;
447
330
  };
448
- /**
449
- * Abstract Memory class that defines the interface for storing and retrieving
450
- * conversation threads and messages.
451
- */
452
- declare abstract class MastraMemory extends MastraBase {
453
- MAX_CONTEXT_TOKENS?: number;
454
- storage: MastraStorage;
455
- vector?: MastraVector;
456
- embeddingOptions?: EmbeddingOptions;
457
- protected threadConfig: MemoryConfig;
458
- constructor(config: {
459
- name: string;
460
- } & SharedMemoryConfig);
461
- protected parseEmbeddingOptions(): EmbeddingOptions;
462
- protected getMergedThreadConfig(config: MemoryConfig): MemoryConfig;
463
- abstract rememberMessages({ threadId, vectorMessageSearch, config, }: {
464
- threadId: string;
465
- vectorMessageSearch?: string;
466
- config?: MemoryConfig;
467
- }): Promise<{
468
- messages: CoreMessage$1[];
469
- uiMessages: AiMessageType[];
470
- }>;
471
- estimateTokens(text: string): number;
472
- protected parseMessages(messages: MessageType[]): CoreMessage$1[];
473
- protected convertToUIMessages(messages: MessageType[]): AiMessageType[];
474
- /**
475
- * Retrieves a specific thread by its ID
476
- * @param threadId - The unique identifier of the thread
477
- * @returns Promise resolving to the thread or null if not found
478
- */
479
- abstract getThreadById({ threadId }: {
480
- threadId: string;
481
- }): Promise<StorageThreadType | null>;
482
- abstract getThreadsByResourceId({ resourceId }: {
483
- resourceId: string;
484
- }): Promise<StorageThreadType[]>;
331
+ interface GoogleGenerativeAISettings {
485
332
  /**
486
- * Saves or updates a thread
487
- * @param thread - The thread data to save
488
- * @returns Promise resolving to the saved thread
489
- */
490
- abstract saveThread({ thread }: {
491
- thread: StorageThreadType;
492
- }): Promise<StorageThreadType>;
333
+ Optional.
334
+ The name of the cached content used as context to serve the prediction.
335
+ Format: cachedContents/{cachedContent}
336
+ */
337
+ cachedContent?: string;
493
338
  /**
494
- * Saves messages to a thread
495
- * @param messages - Array of messages to save
496
- * @returns Promise resolving to the saved messages
339
+ * Optional. Enable structured output. Default is true.
340
+ *
341
+ * This is useful when the JSON Schema contains elements that are
342
+ * not supported by the OpenAPI schema version that
343
+ * Google Generative AI uses. You can use this to disable
344
+ * structured outputs if you need to.
497
345
  */
498
- abstract saveMessages({ messages, memoryConfig, }: {
499
- messages: MessageType[];
500
- memoryConfig: MemoryConfig | undefined;
501
- }): Promise<MessageType[]>;
346
+ structuredOutputs?: boolean;
502
347
  /**
503
- * Retrieves all messages for a specific thread
504
- * @param threadId - The unique identifier of the thread
505
- * @returns Promise resolving to array of messages and uiMessages
506
- */
507
- abstract getMessages({ threadId, selectBy, }: StorageGetMessagesArg): Promise<{
508
- messages: CoreMessage$1[];
509
- uiMessages: AiMessageType[];
510
- }>;
511
- /**
512
- * Helper method to create a new thread
513
- * @param title - Optional title for the thread
514
- * @param metadata - Optional metadata for the thread
515
- * @returns Promise resolving to the created thread
516
- */
517
- createThread({ threadId, resourceId, title, metadata, }: {
518
- resourceId: string;
519
- threadId?: string;
520
- title?: string;
521
- metadata?: Record<string, unknown>;
522
- }): Promise<StorageThreadType>;
523
- /**
524
- * Helper method to delete a thread
525
- * @param threadId - the id of the thread to delete
526
- */
527
- abstract deleteThread(threadId: string): Promise<void>;
528
- /**
529
- * Helper method to add a single message to a thread
530
- * @param threadId - The thread to add the message to
531
- * @param content - The message content
532
- * @param role - The role of the message sender
533
- * @param type - The type of the message
534
- * @param toolNames - Optional array of tool names that were called
535
- * @param toolCallArgs - Optional array of tool call arguments
536
- * @param toolCallIds - Optional array of tool call ids
537
- * @returns Promise resolving to the saved message
538
- */
539
- addMessage({ threadId, config, content, role, type, toolNames, toolCallArgs, toolCallIds, }: {
540
- threadId: string;
541
- config?: MemoryConfig;
542
- content: UserContent | AssistantContent;
543
- role: 'user' | 'assistant';
544
- type: 'text' | 'tool-call' | 'tool-result';
545
- toolNames?: string[];
546
- toolCallArgs?: Record<string, unknown>[];
547
- toolCallIds?: string[];
548
- }): Promise<MessageType>;
549
- /**
550
- * Generates a unique identifier
551
- * @returns A unique string ID
552
- */
553
- generateId(): string;
554
- }
555
-
556
- type CoreTool = {
557
- description?: string;
558
- parameters: ZodSchema;
559
- execute: (params: any) => Promise<any>;
560
- };
561
- interface ToolExecutionContext<TSchemaIn extends z.ZodSchema | undefined = undefined, TContext extends WorkflowContext = WorkflowContext> extends IExecutionContext<TSchemaIn, TContext> {
562
- }
563
- interface ToolAction<TId extends string, TSchemaIn extends z.ZodSchema | undefined = undefined, TSchemaOut extends z.ZodSchema | undefined = undefined, TContext extends ToolExecutionContext<TSchemaIn> = ToolExecutionContext<TSchemaIn>> extends IAction<TId, TSchemaIn, TSchemaOut, TContext> {
564
- }
565
-
566
- type OpenAIModel = 'gpt-4' | 'gpt-4-turbo' | 'gpt-3.5-turbo' | 'gpt-4o' | 'gpt-4o-mini' | 'o1' | 'o1-mini' | 'o1-preview';
567
- type CoreMessage = CoreMessage$1;
568
- type CoreSystemMessage = CoreSystemMessage$1;
569
- type CoreAssistantMessage = CoreAssistantMessage$1;
570
- type CoreUserMessage = CoreUserMessage$1;
571
- type CoreToolMessage = CoreToolMessage$1;
572
- type EmbedResult<T> = EmbedResult$1<T>;
573
- type EmbedManyResult<T> = EmbedManyResult$1<T>;
574
- type OpenAIConfig = {
575
- provider: 'OPEN_AI';
576
- name: OpenAIModel | (string & {});
577
- toolChoice?: 'auto' | 'required';
578
- apiKey?: string;
579
- baseURL?: string;
580
- headers?: Record<string, string>;
581
- fetch?: typeof globalThis.fetch;
582
- };
583
- type GoogleModel = 'gemini-1.5-pro-latest' | 'gemini-1.5-pro' | 'gemini-1.5-flash-latest' | 'gemini-1.5-flash' | 'gemini-2.0-flash-exp-latest' | 'gemini-2.0-flash-thinking-exp-1219' | 'gemini-exp-1206';
584
- type GoogleConfig = {
585
- provider: 'GOOGLE';
586
- name: GoogleModel | (string & {});
587
- toolChoice?: 'auto' | 'required';
588
- apiKey?: string;
589
- baseURL?: string;
590
- headers?: Record<string, string>;
591
- fetch?: typeof globalThis.fetch;
592
- };
593
- interface GoogleGenerativeAISettings {
594
- /**
595
- Optional.
596
- The name of the cached content used as context to serve the prediction.
597
- Format: cachedContents/{cachedContent}
598
- */
599
- cachedContent?: string;
600
- /**
601
- * Optional. Enable structured output. Default is true.
602
- *
603
- * This is useful when the JSON Schema contains elements that are
604
- * not supported by the OpenAPI schema version that
605
- * Google Generative AI uses. You can use this to disable
606
- * structured outputs if you need to.
607
- */
608
- structuredOutputs?: boolean;
609
- /**
610
- Optional. A list of unique safety settings for blocking unsafe content.
611
- */
612
- safetySettings?: Array<{
613
- category: 'HARM_CATEGORY_HATE_SPEECH' | 'HARM_CATEGORY_DANGEROUS_CONTENT' | 'HARM_CATEGORY_HARASSMENT' | 'HARM_CATEGORY_SEXUALLY_EXPLICIT';
614
- threshold: 'HARM_BLOCK_THRESHOLD_UNSPECIFIED' | 'BLOCK_LOW_AND_ABOVE' | 'BLOCK_MEDIUM_AND_ABOVE' | 'BLOCK_ONLY_HIGH' | 'BLOCK_NONE';
348
+ Optional. A list of unique safety settings for blocking unsafe content.
349
+ */
350
+ safetySettings?: Array<{
351
+ category: 'HARM_CATEGORY_HATE_SPEECH' | 'HARM_CATEGORY_DANGEROUS_CONTENT' | 'HARM_CATEGORY_HARASSMENT' | 'HARM_CATEGORY_SEXUALLY_EXPLICIT';
352
+ threshold: 'HARM_BLOCK_THRESHOLD_UNSPECIFIED' | 'BLOCK_LOW_AND_ABOVE' | 'BLOCK_MEDIUM_AND_ABOVE' | 'BLOCK_ONLY_HIGH' | 'BLOCK_NONE';
615
353
  }>;
616
354
  }
617
355
  type AnthropicModel = 'claude-3-5-sonnet-20241022' | 'claude-3-5-sonnet-20240620' | 'claude-3-5-haiku-20241022' | 'claude-3-opus-20240229' | 'claude-3-sonnet-20240229' | 'claude-3-haiku-20240307';
@@ -804,6 +542,7 @@ type LLMTextOptions = {
804
542
  convertedTools?: Record<string, CoreTool>;
805
543
  messages: CoreMessage[];
806
544
  onStepFinish?: (step: string) => void;
545
+ toolChoice?: 'auto' | 'required';
807
546
  maxSteps?: number;
808
547
  temperature?: number;
809
548
  } & Run;
@@ -823,12 +562,290 @@ type LLMStreamObjectOptions<T> = LLMInnerStreamOptions & {
823
562
  structuredOutput: JSONSchema7 | z.ZodType<T> | StructuredOutput;
824
563
  };
825
564
 
565
+ declare class MastraLLMBase extends MastraBase {
566
+ #private;
567
+ constructor({ name }: {
568
+ name: string;
569
+ });
570
+ convertToMessages(messages: string | string[] | CoreMessage$1[]): CoreMessage$1[];
571
+ __registerPrimitives(p: MastraPrimitives): void;
572
+ __text(input: LLMTextOptions): Promise<GenerateTextResult<any, any>>;
573
+ __textObject<T>(input: LLMTextObjectOptions<T>): Promise<GenerateObjectResult<T>>;
574
+ generate<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], options?: LLMStreamOptions<Z>): Promise<GenerateReturn<Z>>;
575
+ __stream(input: LLMInnerStreamOptions): Promise<StreamTextResult<any, any>>;
576
+ __streamObject<T>(input: LLMStreamObjectOptions<T>): Promise<StreamObjectResult<DeepPartial<T>, T, never>>;
577
+ stream<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], options?: LLMStreamOptions<Z>): Promise<StreamReturn<Z>>;
578
+ }
579
+
580
+ interface StorageColumn {
581
+ type: 'text' | 'timestamp' | 'uuid' | 'jsonb' | 'integer';
582
+ primaryKey?: boolean;
583
+ nullable?: boolean;
584
+ references?: {
585
+ table: string;
586
+ column: string;
587
+ };
588
+ }
589
+ interface WorkflowRow {
590
+ workflow_name: string;
591
+ run_id: string;
592
+ snapshot: WorkflowRunState;
593
+ created_at: Date;
594
+ updated_at: Date;
595
+ }
596
+ type StorageGetMessagesArg = {
597
+ threadId: string;
598
+ selectBy?: {
599
+ vectorSearchString?: string;
600
+ last?: number | false;
601
+ include?: {
602
+ id: string;
603
+ withPreviousMessages?: number;
604
+ withNextMessages?: number;
605
+ }[];
606
+ };
607
+ threadConfig?: MemoryConfig;
608
+ };
609
+
610
+ type TABLE_NAMES = typeof MastraStorage.TABLE_WORKFLOW_SNAPSHOT | typeof MastraStorage.TABLE_EVALS | typeof MastraStorage.TABLE_MESSAGES | typeof MastraStorage.TABLE_THREADS;
611
+ declare abstract class MastraStorage extends MastraBase {
612
+ static readonly TABLE_WORKFLOW_SNAPSHOT = "mastra_workflow_snapshot";
613
+ static readonly TABLE_EVALS = "mastra_evals";
614
+ static readonly TABLE_MESSAGES = "mastra_messages";
615
+ static readonly TABLE_THREADS = "mastra_threads";
616
+ hasInit: boolean;
617
+ constructor({ name }: {
618
+ name: string;
619
+ });
620
+ abstract createTable({ tableName }: {
621
+ tableName: TABLE_NAMES;
622
+ schema: Record<string, StorageColumn>;
623
+ }): Promise<void>;
624
+ abstract clearTable({ tableName }: {
625
+ tableName: TABLE_NAMES;
626
+ }): Promise<void>;
627
+ abstract insert({ tableName, record }: {
628
+ tableName: TABLE_NAMES;
629
+ record: Record<string, any>;
630
+ }): Promise<void>;
631
+ abstract load<R>({ tableName, keys }: {
632
+ tableName: TABLE_NAMES;
633
+ keys: Record<string, string>;
634
+ }): Promise<R | null>;
635
+ abstract getThreadById({ threadId }: {
636
+ threadId: string;
637
+ }): Promise<StorageThreadType | null>;
638
+ __getThreadById({ threadId }: {
639
+ threadId: string;
640
+ }): Promise<StorageThreadType | null>;
641
+ abstract getThreadsByResourceId({ resourceId }: {
642
+ resourceId: string;
643
+ }): Promise<StorageThreadType[]>;
644
+ __getThreadsByResourceId({ resourceId }: {
645
+ resourceId: string;
646
+ }): Promise<StorageThreadType[]>;
647
+ abstract saveThread({ thread }: {
648
+ thread: StorageThreadType;
649
+ }): Promise<StorageThreadType>;
650
+ __saveThread({ thread }: {
651
+ thread: StorageThreadType;
652
+ }): Promise<StorageThreadType>;
653
+ abstract updateThread({ id, title, metadata, }: {
654
+ id: string;
655
+ title: string;
656
+ metadata: Record<string, unknown>;
657
+ }): Promise<StorageThreadType>;
658
+ __updateThread({ id, title, metadata, }: {
659
+ id: string;
660
+ title: string;
661
+ metadata: Record<string, unknown>;
662
+ }): Promise<StorageThreadType>;
663
+ abstract deleteThread({ threadId }: {
664
+ threadId: string;
665
+ }): Promise<void>;
666
+ __deleteThread({ threadId }: {
667
+ threadId: string;
668
+ }): Promise<void>;
669
+ abstract getMessages({ threadId, selectBy, threadConfig }: StorageGetMessagesArg): Promise<MessageType[]>;
670
+ __getMessages({ threadId, selectBy, threadConfig }: StorageGetMessagesArg): Promise<MessageType[]>;
671
+ abstract saveMessages({ messages }: {
672
+ messages: MessageType[];
673
+ }): Promise<MessageType[]>;
674
+ __saveMessages({ messages }: {
675
+ messages: MessageType[];
676
+ }): Promise<MessageType[]>;
677
+ init(): Promise<void>;
678
+ persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
679
+ workflowName: string;
680
+ runId: string;
681
+ snapshot: WorkflowRunState;
682
+ }): Promise<void>;
683
+ loadWorkflowSnapshot({ workflowName, runId, }: {
684
+ workflowName: string;
685
+ runId: string;
686
+ }): Promise<WorkflowRunState | null>;
687
+ }
688
+
689
+ type AiMessageType = Message;
690
+ type MessageType = {
691
+ id: string;
692
+ content: UserContent | AssistantContent | ToolContent;
693
+ role: 'system' | 'user' | 'assistant' | 'tool';
694
+ createdAt: Date;
695
+ threadId: string;
696
+ toolCallIds?: string[];
697
+ toolCallArgs?: Record<string, unknown>[];
698
+ toolNames?: string[];
699
+ type: 'text' | 'tool-call' | 'tool-result';
700
+ };
701
+ type StorageThreadType = {
702
+ id: string;
703
+ title?: string;
704
+ resourceId: string;
705
+ createdAt: Date;
706
+ updatedAt: Date;
707
+ metadata?: Record<string, unknown>;
708
+ };
709
+ type MessageResponse<T extends 'raw' | 'core_message'> = {
710
+ raw: MessageType[];
711
+ core_message: CoreMessage$1[];
712
+ }[T];
713
+ type MemoryConfig = {
714
+ lastMessages?: number | false;
715
+ semanticRecall?: boolean | {
716
+ topK: number;
717
+ messageRange: number | {
718
+ before: number;
719
+ after: number;
720
+ };
721
+ };
722
+ };
723
+ type SharedMemoryConfig = {
724
+ storage: MastraStorage;
725
+ options?: MemoryConfig;
726
+ vector?: MastraVector;
727
+ embedding?: EmbeddingOptions;
728
+ } | {
729
+ storage: MastraStorage;
730
+ options?: MemoryConfig;
731
+ vector: MastraVector;
732
+ embedding: EmbeddingOptions;
733
+ };
734
+ /**
735
+ * Abstract Memory class that defines the interface for storing and retrieving
736
+ * conversation threads and messages.
737
+ */
738
+ declare abstract class MastraMemory extends MastraBase {
739
+ MAX_CONTEXT_TOKENS?: number;
740
+ storage: MastraStorage;
741
+ vector?: MastraVector;
742
+ embedding?: EmbeddingOptions;
743
+ protected threadConfig: MemoryConfig;
744
+ constructor(config: {
745
+ name: string;
746
+ } & SharedMemoryConfig);
747
+ protected parseEmbeddingOptions(): EmbeddingOptions;
748
+ protected getMergedThreadConfig(config: MemoryConfig): MemoryConfig;
749
+ abstract rememberMessages({ threadId, vectorMessageSearch, config, }: {
750
+ threadId: string;
751
+ vectorMessageSearch?: string;
752
+ config?: MemoryConfig;
753
+ }): Promise<{
754
+ messages: CoreMessage$1[];
755
+ uiMessages: AiMessageType[];
756
+ }>;
757
+ estimateTokens(text: string): number;
758
+ protected parseMessages(messages: MessageType[]): CoreMessage$1[];
759
+ protected convertToUIMessages(messages: MessageType[]): AiMessageType[];
760
+ /**
761
+ * Retrieves a specific thread by its ID
762
+ * @param threadId - The unique identifier of the thread
763
+ * @returns Promise resolving to the thread or null if not found
764
+ */
765
+ abstract getThreadById({ threadId }: {
766
+ threadId: string;
767
+ }): Promise<StorageThreadType | null>;
768
+ abstract getThreadsByResourceId({ resourceId }: {
769
+ resourceId: string;
770
+ }): Promise<StorageThreadType[]>;
771
+ /**
772
+ * Saves or updates a thread
773
+ * @param thread - The thread data to save
774
+ * @returns Promise resolving to the saved thread
775
+ */
776
+ abstract saveThread({ thread }: {
777
+ thread: StorageThreadType;
778
+ }): Promise<StorageThreadType>;
779
+ /**
780
+ * Saves messages to a thread
781
+ * @param messages - Array of messages to save
782
+ * @returns Promise resolving to the saved messages
783
+ */
784
+ abstract saveMessages({ messages, memoryConfig, }: {
785
+ messages: MessageType[];
786
+ memoryConfig: MemoryConfig | undefined;
787
+ }): Promise<MessageType[]>;
788
+ /**
789
+ * Retrieves all messages for a specific thread
790
+ * @param threadId - The unique identifier of the thread
791
+ * @returns Promise resolving to array of messages and uiMessages
792
+ */
793
+ abstract query({ threadId, selectBy, }: StorageGetMessagesArg): Promise<{
794
+ messages: CoreMessage$1[];
795
+ uiMessages: AiMessageType[];
796
+ }>;
797
+ /**
798
+ * Helper method to create a new thread
799
+ * @param title - Optional title for the thread
800
+ * @param metadata - Optional metadata for the thread
801
+ * @returns Promise resolving to the created thread
802
+ */
803
+ createThread({ threadId, resourceId, title, metadata, }: {
804
+ resourceId: string;
805
+ threadId?: string;
806
+ title?: string;
807
+ metadata?: Record<string, unknown>;
808
+ }): Promise<StorageThreadType>;
809
+ /**
810
+ * Helper method to delete a thread
811
+ * @param threadId - the id of the thread to delete
812
+ */
813
+ abstract deleteThread(threadId: string): Promise<void>;
814
+ /**
815
+ * Helper method to add a single message to a thread
816
+ * @param threadId - The thread to add the message to
817
+ * @param content - The message content
818
+ * @param role - The role of the message sender
819
+ * @param type - The type of the message
820
+ * @param toolNames - Optional array of tool names that were called
821
+ * @param toolCallArgs - Optional array of tool call arguments
822
+ * @param toolCallIds - Optional array of tool call ids
823
+ * @returns Promise resolving to the saved message
824
+ */
825
+ addMessage({ threadId, config, content, role, type, toolNames, toolCallArgs, toolCallIds, }: {
826
+ threadId: string;
827
+ config?: MemoryConfig;
828
+ content: UserContent | AssistantContent;
829
+ role: 'user' | 'assistant';
830
+ type: 'text' | 'tool-call' | 'tool-result';
831
+ toolNames?: string[];
832
+ toolCallArgs?: Record<string, unknown>[];
833
+ toolCallIds?: string[];
834
+ }): Promise<MessageType>;
835
+ /**
836
+ * Generates a unique identifier
837
+ * @returns A unique string ID
838
+ */
839
+ generateId(): string;
840
+ }
841
+
826
842
  type ToolsetsInput = Record<string, Record<string, ToolAction<any, any, any, any>>>;
827
843
  type ToolsInput = Record<string, ToolAction<any, any, any, any>>;
828
844
  interface AgentConfig<TTools extends Record<string, ToolAction<any, any, any, any>> = Record<string, ToolAction<any, any, any, any>>, TMetrics extends Record<string, Metric> = Record<string, Metric>> {
829
845
  name: string;
830
846
  instructions: string;
831
- model: ModelConfig;
847
+ model?: ModelConfig;
848
+ llm?: MastraLLMBase;
832
849
  tools?: TTools;
833
850
  mastra?: MastraPrimitives;
834
851
  metrics?: TMetrics;
@@ -906,7 +923,7 @@ declare class LLM extends MastraBase {
906
923
  toolsConverted: Record<string, CoreTool$1>;
907
924
  modelDef: LanguageModelV1;
908
925
  answerTool: {};
909
- toolChoice: "required" | "auto";
926
+ toolChoice: "auto" | "required";
910
927
  }>;
911
928
  convertTools(tools?: ToolsInput): Record<string, CoreTool>;
912
929
  private convertToMessages;
@@ -916,7 +933,7 @@ declare class LLM extends MastraBase {
916
933
  __getNamedModel(): {
917
934
  type: string;
918
935
  name: (string & {}) | "gpt-4" | "gpt-4-turbo" | "gpt-3.5-turbo" | "gpt-4o" | "gpt-4o-mini" | "o1" | "o1-mini" | "o1-preview" | "gemini-1.5-pro-latest" | "gemini-1.5-pro" | "gemini-1.5-flash-latest" | "gemini-1.5-flash" | "gemini-2.0-flash-exp-latest" | "gemini-2.0-flash-thinking-exp-1219" | "gemini-exp-1206" | "claude-3-5-sonnet-20241022" | "claude-3-5-sonnet-20240620" | "claude-3-5-haiku-20241022" | "claude-3-opus-20240229" | "claude-3-sonnet-20240229" | "claude-3-haiku-20240307" | "llama3-groq-70b-8192-tool-use-preview" | "llama3-groq-8b-8192-tool-use-preview" | "gemma2-9b-it" | "gemma-7b-it" | "llama-3.1-sonar-small-128k-online" | "llama-3.1-sonar-large-128k-online" | "llama-3.1-sonar-huge-128k-online" | "llama-3.1-sonar-small-128k-chat" | "llama-3.1-sonar-large-128k-chat" | "llama-3.1-8b-instruct" | "llama-3.1-70b-instruct" | "sonar" | "sonar-pro" | "codellama/CodeLlama-34b-Instruct-hf" | "upstage/SOLAR-10.7B-Instruct-v1.0" | "mistralai/Mixtral-8x7B-v0.1" | "WhereIsAI/UAE-Large-V1" | "black-forest-labs/FLUX.1-depth" | "togethercomputer/m2-bert-80M-32k-retrieval" | "black-forest-labs/FLUX.1-canny" | "black-forest-labs/FLUX.1-dev" | "black-forest-labs/FLUX.1-redux" | "BAAI/bge-large-en-v1.5" | "meta-llama/Llama-3.2-90B-Vision-Instruct-Turbo" | "togethercomputer/Llama-3-8b-chat-hf-int4" | "stabilityai/stable-diffusion-xl-base-1.0" | "Gryphe/MythoMax-L2-13b" | "meta-llama/Meta-Llama-3-8B" | "mistralai/Mixtral-8x7B-Instruct-v0.1" | "deepseek-ai/deepseek-llm-67b-chat" | "togethercomputer/m2-bert-80M-8k-retrieval" | "llava-hf/llava-v1.6-mistral-7b-hf" | "Qwen/Qwen2.5-Coder-32B-Instruct" | "databricks/dbrx-instruct" | "meta-llama/Meta-Llama-3.1-405B-Instruct-Lite-Pro" | "meta-llama/Meta-Llama-3-8B-Instruct-Lite" | "scb10x/scb10x-llama3-typhoon-v1-5-8b-instruct" | "microsoft/WizardLM-2-8x22B" | "BAAI/bge-base-en-v1.5" | "togethercomputer/m2-bert-80M-2k-retrieval" | "google/gemma-2b-it" | "meta-llama/Llama-2-70b-hf" | "mistralai/Mistral-7B-Instruct-v0.2" | "meta-llama/LlamaGuard-2-8b" | "mistralai/Mistral-7B-Instruct-v0.1" | "mistralai/Mistral-7B-v0.1" | "black-forest-labs/FLUX.1-pro" | "black-forest-labs/FLUX.1-schnell" | "meta-llama/Meta-Llama-3.1-405B-Instruct-Turbo" | "nvidia/Llama-3.1-Nemotron-70B-Instruct-HF" | "mistralai/Mistral-7B-Instruct-v0.3" | "Meta-Llama/Llama-Guard-7b" | "meta-llama/Meta-Llama-3-70B-Instruct-Turbo" | "meta-llama/Meta-Llama-3-70B-Instruct-Lite" | "google/gemma-2-27b-it" | "meta-llama/Llama-3-8b-chat-hf" | "Qwen/Qwen2.5-72B-Instruct-Turbo" | "Salesforce/Llama-Rank-V1" | "meta-llama/Llama-Guard-3-11B-Vision-Turbo" | "google/gemma-2-9b-it" | "meta-llama/Llama-3.2-11B-Vision-Instruct-Turbo" | "NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO" | "meta-llama/Llama-3-70b-chat-hf" | "Qwen/Qwen2.5-7B-Instruct-Turbo" | "scb10x/scb10x-llama3-typhoon-v1-5x-4f316" | "meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo" | "Gryphe/MythoMax-L2-13b-Lite" | "black-forest-labs/FLUX.1-schnell-Free" | "meta-llama/Llama-2-7b-chat-hf" | "meta-llama/Meta-Llama-Guard-3-8B" | "togethercomputer/Llama-3-8b-chat-hf-int8" | "meta-llama/Llama-Vision-Free" | "Qwen/Qwen2-72B-Instruct" | "mistralai/Mixtral-8x22B-Instruct-v0.1" | "black-forest-labs/FLUX.1.1-pro" | "meta-llama/Llama-3.2-3B-Instruct-Turbo" | "meta-llama/Llama-2-13b-chat-hf" | "meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo" | "Nexusflow/NexusRaven-V2-13B" | "bert-base-uncased" | "WizardLM/WizardLM-13B-V1.2" | "google/gemma-7b" | "togethercomputer/Koala-7B" | "zero-one-ai/Yi-34B" | "togethercomputer/StripedHyena-Hessian-7B" | "teknium/OpenHermes-2-Mistral-7B" | "Qwen/Qwen2-7B-Instruct" | "togethercomputer/guanaco-65b" | "togethercomputer/llama-2-7b" | "hazyresearch/M2-BERT-2k-Retrieval-Encoder-V1" | "huggyllama/llama-7b" | "Undi95/ReMM-SLERP-L2-13B" | "NousResearch/Nous-Capybara-7B-V1p9" | "lmsys/vicuna-7b-v1.3" | "Undi95/Toppy-M-7B" | "Qwen/Qwen2-72B" | "NousResearch/Nous-Hermes-Llama2-70b" | "WizardLM/WizardLM-70B-V1.0" | "huggyllama/llama-65b" | "lmsys/vicuna-13b-v1.5-16k" | "openchat/openchat-3.5-1210" | "Qwen/Qwen1.5-0.5B" | "Qwen/Qwen1.5-4B" | "Qwen/Qwen1.5-7B" | "snorkelai/Snorkel-Mistral-PairRM-DPO" | "Qwen/Qwen1.5-14B-Chat" | "Qwen/Qwen1.5-1.8B-Chat" | "Snowflake/snowflake-arctic-instruct" | "togethercomputer/llama-2-13b" | "NousResearch/Nous-Hermes-2-Mixtral-8x7B-SFT" | "deepseek-ai/deepseek-coder-33b-instruct" | "togethercomputer/CodeLlama-7b-Instruct" | "NousResearch/Nous-Hermes-Llama2-13b" | "lmsys/vicuna-13b-v1.5" | "togethercomputer/guanaco-13b" | "togethercomputer/CodeLlama-34b-Instruct" | "togethercomputer/llama-2-70b" | "codellama/CodeLlama-13b-Instruct-hf" | "Qwen/Qwen2-7B" | "Qwen/Qwen2-1.5B" | "togethercomputer/CodeLlama-13b-Instruct" | "meta-llama/Llama-2-13b-hf" | "togethercomputer/llama-2-13b-chat" | "huggyllama/llama-30b" | "NousResearch/Nous-Hermes-2-Mistral-7B-DPO" | "togethercomputer/alpaca-7b" | "google/gemma-7b-it" | "allenai/OLMo-7B" | "togethercomputer/guanaco-33b" | "togethercomputer/llama-2-7b-chat" | "togethercomputer/SOLAR-10.7B-Instruct-v1.0-int4" | "togethercomputer/guanaco-7b" | "Open-Orca/Mistral-7B-OpenOrca" | "Qwen/Qwen1.5-32B" | "EleutherAI/llemma_7b" | "NousResearch/Nous-Hermes-llama-2-7b" | "Qwen/Qwen1.5-32B-Chat" | "meta-llama/Meta-Llama-3-70B" | "meta-llama/Llama-3-8b-hf" | "sentence-transformers/msmarco-bert-base-dot-v5" | "zero-one-ai/Yi-6B" | "meta-llama/Meta-Llama-3-8B-Instruct" | "teknium/OpenHermes-2p5-Mistral-7B" | "Qwen/Qwen1.5-4B-Chat" | "wavymulder/Analog-Diffusion" | "runwayml/stable-diffusion-v1-5" | "prompthero/openjourney" | "meta-llama/Llama-2-7b-hf" | "SG161222/Realistic_Vision_V3.0_VAE" | "Qwen/Qwen1.5-0.5B-Chat" | "codellama/CodeLlama-7b-Instruct-hf" | "google/gemma-2b" | "mistralai/Mixtral-8x22B" | "meta-llama/Llama-2-70b-chat-hf" | "zero-one-ai/Yi-34B-Chat" | "google/gemma-2-9b" | "meta-llama/Meta-Llama-3-70B-Instruct" | "togethercomputer/LLaMA-2-7B-32K" | "codellama/CodeLlama-70b-Instruct-hf" | "NousResearch/Hermes-2-Theta-Llama-3-70B" | "test/test11" | "stabilityai/stable-diffusion-2-1" | "microsoft/phi-2" | "Qwen/Qwen1.5-7B-Chat" | "cognitivecomputations/dolphin-2.5-mixtral-8x7b" | "togethercomputer/evo-1-131k-base" | "togethercomputer/evo-1-8k-base" | "togethercomputer/llama-2-70b-chat" | "Qwen/Qwen1.5-14B" | "carson/ml318br" | "meta-llama/Meta-Llama-3.1-8B-Instruct-Reference" | "meta-llama/Meta-Llama-3.1-8B-Reference" | "gradientai/Llama-3-70B-Instruct-Gradient-1048k" | "meta-llama/Meta-Llama-3.1-70B-Reference" | "meta-llama/Meta-Llama-3.1-70B-Instruct-Reference" | "meta-llama/Llama-3-70b-hf" | "Qwen/Qwen2-1.5B-Instruct" | "NousResearch/Nous-Hermes-13b" | "HuggingFaceH4/zephyr-7b-beta" | "Austism/chronos-hermes-13b" | "Qwen/Qwen1.5-1.8B" | "Qwen/Qwen1.5-72B" | "lmsys/vicuna-13b-v1.3" | "huggyllama/llama-13b" | "garage-bAInd/Platypus2-70B-instruct" | "allenai/OLMo-7B-Instruct" | "togethercomputer/Koala-13B" | "lmsys/vicuna-7b-v1.5" | "qwen2-7b-instruct-4bit" | "qwen2-math-1.5b" | "qwen2-0.5b" | "aya-23-8b" | "mistral-7b-v0.3" | "stablecode" | "cohere-command-r-v01-4bit" | "command-r" | "starcoder2-7b" | "deepseek-math-7b" | "qwen2.5-coder-14b" | "qwen2.5-coder-32b" | "qwen2.5-coder-3b" | "llama-3.2-3b-instruct-4bit" | "llama-3.2-1b" | "llama-3.2-3b" | "qwen2.5-coder-7b" | "qwen2.5-14b" | "yi-coder-9b" | "hermes-3-llama-3.1-8b" | "internlm-2.5-20b" | "llava-v1.5" | "llama-3.1-8b-instruct-4bit" | "meta-llama-3.1-8b" | "mistral-nemo-2407" | "mistral-nemo-instruct-2407-4bit" | "gemma-2-2b" | "mathstral-7b" | "gemma-2-9b" | "deepseek-coder-v2-lite-instruct-4bit" | "smollm-360m-v0.2" | "phi-3-mini-4k-instruct-4bit" | "gemma-2-27b" | "codestral-22b" | "phi-3.1-mini-128k" | "deepseek-coder-v2-lite" | "qwen2.5-7b-math-instruct" | "qwen2.5-14b-instruct" | "qwen2.5-32b-coder-instruct" | "llama-3.1-nemetron-70b" | "llama-3.2-90b-vision-instruct" | "llama-3.1-405b-instruct" | "ultravox-v0.4" | "llama-3.2-1b-vision-instruct" | "llama-3-70b-instruct" | "llama-3-8b-instruct" | "mistral-7b-instruct" | "qwen2.5-14b-coder-instruct" | "qwen2.5-7b-coder-instruct" | "qwen2.5-72b-math-instruct" | "qwen2.5-72b-instruct" | "qwen2.5-32b-instruct" | "qwen2.5-7b-instruct" | "qwen2.5-3b-instruct" | "pixtral-12b" | "phi-3.5-mini-instruct" | "phi-3-mini-128k-instruct" | "phi-3-mini-4k-instruct" | "zephyr-7b-alpha" | "mixtral-8x7b-instruct" | "mixtral-8x22b" | "llama-3.2-3b-instruct" | "pixtral-large-latest" | "mistral-large-latest" | "mistral-small-latest" | "ministral-3b-latest" | "ministral-8b-latest" | "pixtral-12b-2409" | "grok-beta" | "grok-vision-beta" | "command-r-plus" | "gpt-35-turbo-instruct" | "deepseek-chat" | "deepseek-reasoner" | "amazon-titan-tg1-large" | "amazon-titan-text-express-v1" | "anthropic-claude-3-5-sonnet-20241022-v2:0" | "anthropic-claude-3-5-sonnet-20240620-v1:0" | "anthropic-claude-3-5-haiku-20241022-v1:0" | "anthropic-claude-3-opus-20240229-v1:0" | "anthropic-claude-3-sonnet-20240229-v1:0" | "anthropic-claude-3-haiku-20240307-v1:0" | "anthropic-claude-v2:1" | "cohere-command-r-v1:0" | "cohere-command-r-plus-v1:0" | "meta-llama2-13b-chat-v1" | "meta-llama2-70b-chat-v1" | "meta-llama3-8b-instruct-v1:0" | "meta-llama3-70b-instruct-v1:0" | "meta-llama3-1-8b-instruct-v1:0" | "meta-llama3-1-70b-instruct-v1:0" | "meta-llama3-1-405b-instruct-v1:0" | "meta-llama3-2-1b-instruct-v1:0" | "meta-llama3-2-3b-instruct-v1:0" | "meta-llama3-2-11b-instruct-v1:0" | "meta-llama3-2-90b-instruct-v1:0" | "mistral-mistral-7b-instruct-v0:2" | "mistral-mixtral-8x7b-instruct-v0:1" | "mistral-mistral-large-2402-v1:0" | "mistral-mistral-small-2402-v1:0" | "claude-3-5-sonnet@20240620" | "claude-3-opus@20240229" | "claude-3-sonnet@20240229" | "claude-3-haiku@20240307";
919
- toolChoice: "required" | "auto" | undefined;
936
+ toolChoice: "auto" | "required" | undefined;
920
937
  apiKey: string | undefined;
921
938
  baseURL: string | undefined;
922
939
  headers: Record<string, string> | undefined;
@@ -962,9 +979,9 @@ interface IAction<TId extends string, TSchemaIn extends z.ZodSchema | undefined,
962
979
  declare class Agent<TTools extends Record<string, ToolAction<any, any, any, any>> = Record<string, ToolAction<any, any, any, any>>, TMetrics extends Record<string, Metric> = Record<string, Metric>> extends MastraBase {
963
980
  #private;
964
981
  name: string;
965
- readonly llm: LLM;
982
+ readonly llm: LLM | MastraLLMBase;
966
983
  readonly instructions: string;
967
- readonly model: ModelConfig;
984
+ readonly model?: ModelConfig;
968
985
  tools: TTools;
969
986
  metrics: TMetrics;
970
987
  constructor(config: AgentConfig<TTools, TMetrics>);
@@ -993,8 +1010,9 @@ declare class Agent<TTools extends Record<string, ToolAction<any, any, any, any>
993
1010
  threadId: string;
994
1011
  messages: CoreMessage$1[];
995
1012
  }>;
996
- saveResponse({ result, threadId, runId, memoryConfig, }: {
1013
+ saveResponse({ result, threadId, resourceId, runId, memoryConfig, }: {
997
1014
  runId: string;
1015
+ resourceId: string;
998
1016
  result: Record<string, any>;
999
1017
  threadId: string;
1000
1018
  memoryConfig: MemoryConfig | undefined;
@@ -1041,4 +1059,4 @@ declare class Agent<TTools extends Record<string, ToolAction<any, any, any, any>
1041
1059
  stream<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], { context, threadId: threadIdInFn, memoryOptions, resourceId, maxSteps, onFinish, onStepFinish, runId, toolsets, output, temperature, }?: AgentStreamOptions<Z>): Promise<StreamReturn<Z>>;
1042
1060
  }
1043
1061
 
1044
- export { type CustomModelConfig as $, Agent as A, type GroqConfig as B, type CoreMessage as C, type PerplexityConfig as D, type EmbedResult as E, type TogetherAiModel as F, type GoogleModel as G, type TogetherAiConfig as H, type IAction as I, type LMStudioModel as J, type LMStudioConfig as K, LLM as L, MastraStorage as M, type BasetenModel as N, type OpenAIModel as O, type PerplexityModel as P, type BaseTenConfig as Q, type RetryConfig as R, type StepExecutionContext as S, type ToolAction as T, type FireworksModel as U, type FireworksConfig as V, type WorkflowOptions as W, type MistralModel as X, type MistralConfig as Y, type XGrokModel as Z, type XGrokConfig as _, MastraMemory as a, type CohereModel as a0, type CohereConfig as a1, type AzureModel as a2, type AzureConfig as a3, type DeepseekModel as a4, type DeepseekConfig as a5, type AmazonModel as a6, type AmazonConfig as a7, type AnthropicVertexModel as a8, type AnthropicVertexConfig as a9, type WorkflowContext as aA, type WorkflowLogMessage as aB, type WorkflowEvent as aC, type ResolverFunctionInput as aD, type ResolverFunctionOutput as aE, type SubscriberFunctionOutput as aF, type DependencyCheckOutput as aG, type WorkflowActors as aH, type WorkflowActionParams as aI, type WorkflowActions as aJ, type WorkflowState as aK, type StepId as aL, type ExtractSchemaFromStep as aM, type ExtractStepResult as aN, type StepInputType as aO, type ExtractSchemaType as aP, type PathsToStringProps as aQ, type IExecutionContext as aR, type LLMProvider as aa, type BaseStructuredOutputType as ab, type StructuredOutputType as ac, type StructuredOutputArrayItem as ad, type StructuredOutput as ae, type GenerateReturn as af, type StreamReturn as ag, type OutputType as ah, type LLMStreamOptions as ai, type LLMTextOptions as aj, type LLMTextObjectOptions as ak, type LLMInnerStreamOptions as al, type LLMStreamObjectOptions as am, type AiMessageType as an, type MessageType as ao, type StorageThreadType as ap, type MessageResponse as aq, type MemoryConfig as ar, type SharedMemoryConfig as as, type CoreTool as at, type StepNode as au, type VariableReference as av, type BaseCondition as aw, type ActionContext as ax, type StepDef as ay, type StepCondition as az, type ModelConfig as b, type StepAction as c, type MastraPrimitives as d, type StepVariableType as e, type StepConfig as f, type StepResult as g, type WorkflowRunState as h, type StepGraph as i, type AgentConfig as j, type ToolExecutionContext as k, type TABLE_NAMES as l, type StorageColumn as m, type WorkflowRow as n, type StorageGetMessagesArg as o, type CoreSystemMessage as p, type CoreAssistantMessage as q, type CoreUserMessage as r, type CoreToolMessage as s, type EmbedManyResult as t, type OpenAIConfig as u, type GoogleConfig as v, type GoogleGenerativeAISettings as w, type AnthropicModel as x, type AnthropicConfig as y, type GroqModel as z };
1062
+ export { type LMStudioModel as $, Agent as A, type CoreUserMessage as B, type CoreTool as C, type CoreToolMessage as D, type EmbedResult as E, type EmbedManyResult as F, type GenerateReturn as G, type OpenAIConfig as H, type IAction as I, type GoogleModel as J, type GoogleConfig as K, LLM as L, MastraStorage as M, type GoogleGenerativeAISettings as N, type OpenAIModel as O, type AnthropicModel as P, type AnthropicConfig as Q, type RetryConfig as R, type StreamReturn as S, type ToolsInput as T, type GroqModel as U, type GroqConfig as V, type WorkflowOptions as W, type PerplexityModel as X, type PerplexityConfig as Y, type TogetherAiModel as Z, type TogetherAiConfig as _, MastraMemory as a, type LMStudioConfig as a0, type BasetenModel as a1, type BaseTenConfig as a2, type FireworksModel as a3, type FireworksConfig as a4, type MistralModel as a5, type MistralConfig as a6, type XGrokModel as a7, type XGrokConfig as a8, type CustomModelConfig as a9, type StepDef as aA, type StepCondition as aB, type WorkflowContext as aC, type WorkflowLogMessage as aD, type WorkflowEvent as aE, type ResolverFunctionInput as aF, type ResolverFunctionOutput as aG, type SubscriberFunctionOutput as aH, type DependencyCheckOutput 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 IExecutionContext as aT, type CohereModel as aa, type CohereConfig as ab, type AzureModel as ac, type AzureConfig as ad, type DeepseekModel as ae, type DeepseekConfig as af, type AmazonModel as ag, type AmazonConfig as ah, type AnthropicVertexModel as ai, type AnthropicVertexConfig as aj, type LLMProvider as ak, type BaseStructuredOutputType as al, type StructuredOutputType as am, type StructuredOutputArrayItem as an, type StructuredOutput as ao, type OutputType as ap, type AiMessageType as aq, type MessageType as ar, type StorageThreadType as as, type MessageResponse as at, type MemoryConfig as au, type SharedMemoryConfig as av, type StepNode as aw, type VariableReference as ax, type BaseCondition as ay, type ActionContext as az, type ModelConfig as b, MastraLLMBase as c, type MastraPrimitives as d, type LLMTextOptions as e, type LLMTextObjectOptions as f, type LLMInnerStreamOptions as g, type LLMStreamObjectOptions as h, type LLMStreamOptions as i, type StepExecutionContext as j, type StepAction as k, type StepVariableType as l, type StepConfig as m, type StepResult as n, type WorkflowRunState as o, type StepGraph as p, type ToolAction as q, type AgentConfig as r, type ToolExecutionContext as s, type TABLE_NAMES as t, type StorageColumn as u, type WorkflowRow as v, type StorageGetMessagesArg as w, type CoreMessage as x, type CoreSystemMessage as y, type CoreAssistantMessage as z };