@mastra/core 0.8.3-alpha.0 → 0.8.3-alpha.2

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 (72) hide show
  1. package/{LICENSE → LICENSE.md} +3 -1
  2. package/dist/agent/index.cjs +2 -2
  3. package/dist/agent/index.d.cts +2 -1
  4. package/dist/agent/index.d.ts +2 -1
  5. package/dist/agent/index.js +1 -1
  6. package/dist/{base-VLg7uRIB.d.cts → base-Ca8Hlcj4.d.cts} +31 -13
  7. package/dist/{base-BZEw2nXJ.d.ts → base-Cb5pwtMe.d.ts} +31 -13
  8. package/dist/chunk-3PBEAM6M.js +69 -0
  9. package/dist/{chunk-OSY64FYD.cjs → chunk-B23KFOTM.cjs} +2 -2
  10. package/dist/{chunk-4RMSGSQN.js → chunk-EO7KZJF6.js} +1 -1
  11. package/dist/{chunk-7I7AKQH3.cjs → chunk-IPQW4HAT.cjs} +2 -2
  12. package/dist/{chunk-BC5B4EGI.js → chunk-K5TZKHR7.js} +4 -2
  13. package/dist/{chunk-FFOLLSHP.js → chunk-KB4JVOEB.js} +102 -87
  14. package/dist/{chunk-MP3UIX44.cjs → chunk-LRDD5WDF.cjs} +115 -100
  15. package/dist/chunk-LZQIMLJV.cjs +71 -0
  16. package/dist/{chunk-Z7SWEXRF.js → chunk-MUM4UGX3.js} +1 -1
  17. package/dist/{chunk-6BT5XRRD.cjs → chunk-OMXQLDP7.cjs} +2 -2
  18. package/dist/{chunk-64VPB7ZD.cjs → chunk-PY3DCT4A.cjs} +4 -2
  19. package/dist/{chunk-26NMSLXS.js → chunk-QVY6JUDZ.js} +1 -1
  20. package/dist/di/index.cjs +10 -0
  21. package/dist/di/index.d.cts +52 -0
  22. package/dist/di/index.d.ts +52 -0
  23. package/dist/di/index.js +1 -0
  24. package/dist/eval/index.d.cts +2 -1
  25. package/dist/eval/index.d.ts +2 -1
  26. package/dist/index.cjs +49 -49
  27. package/dist/index.d.cts +3 -2
  28. package/dist/index.d.ts +3 -2
  29. package/dist/index.js +8 -8
  30. package/dist/integration/index.cjs +3 -3
  31. package/dist/integration/index.d.cts +2 -1
  32. package/dist/integration/index.d.ts +2 -1
  33. package/dist/integration/index.js +1 -1
  34. package/dist/llm/index.d.cts +2 -1
  35. package/dist/llm/index.d.ts +2 -1
  36. package/dist/mastra/index.d.cts +2 -1
  37. package/dist/mastra/index.d.ts +2 -1
  38. package/dist/memory/index.cjs +3 -3
  39. package/dist/memory/index.d.cts +2 -1
  40. package/dist/memory/index.d.ts +2 -1
  41. package/dist/memory/index.js +1 -1
  42. package/dist/network/index.cjs +4 -4
  43. package/dist/network/index.d.cts +2 -1
  44. package/dist/network/index.d.ts +2 -1
  45. package/dist/network/index.js +2 -2
  46. package/dist/relevance/index.cjs +4 -4
  47. package/dist/relevance/index.d.cts +2 -1
  48. package/dist/relevance/index.d.ts +2 -1
  49. package/dist/relevance/index.js +1 -1
  50. package/dist/server/index.d.cts +2 -1
  51. package/dist/server/index.d.ts +2 -1
  52. package/dist/storage/index.d.cts +2 -1
  53. package/dist/storage/index.d.ts +2 -1
  54. package/dist/storage/libsql/index.d.cts +2 -1
  55. package/dist/storage/libsql/index.d.ts +2 -1
  56. package/dist/telemetry/index.d.cts +2 -1
  57. package/dist/telemetry/index.d.ts +2 -1
  58. package/dist/tools/index.cjs +4 -4
  59. package/dist/tools/index.d.cts +2 -1
  60. package/dist/tools/index.d.ts +2 -1
  61. package/dist/tools/index.js +1 -1
  62. package/dist/utils.cjs +13 -13
  63. package/dist/utils.d.cts +3 -1
  64. package/dist/utils.d.ts +3 -1
  65. package/dist/utils.js +1 -1
  66. package/dist/voice/index.d.cts +3 -2
  67. package/dist/voice/index.d.ts +3 -2
  68. package/dist/workflows/index.cjs +23 -23
  69. package/dist/workflows/index.d.cts +3 -2
  70. package/dist/workflows/index.d.ts +3 -2
  71. package/dist/workflows/index.js +1 -1
  72. package/package.json +3 -3
@@ -1,4 +1,6 @@
1
- Elastic License 2.0 (ELv2)
1
+ # Elastic License 2.0 (ELv2)
2
+
3
+ Copyright (c) 2025 Mastra AI, Inc.
2
4
 
3
5
  **Acceptance**
4
6
  By using the software, you agree to all of the terms and conditions below.
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var chunkMP3UIX44_cjs = require('../chunk-MP3UIX44.cjs');
3
+ var chunkLRDD5WDF_cjs = require('../chunk-LRDD5WDF.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "Agent", {
8
8
  enumerable: true,
9
- get: function () { return chunkMP3UIX44_cjs.Agent; }
9
+ get: function () { return chunkLRDD5WDF_cjs.Agent; }
10
10
  });
@@ -1,8 +1,9 @@
1
1
  export { Message as AiMessageType } from 'ai';
2
2
  import 'json-schema';
3
3
  import 'zod';
4
- export { j as Agent, k as AgentConfig, aM as AgentGenerateOptions, aN as AgentStreamOptions, aG as MastraLanguageModel, aH as ToolsInput, aL as ToolsetsInput } from '../base-VLg7uRIB.cjs';
4
+ export { j as Agent, k as AgentConfig, aM as AgentGenerateOptions, aN as AgentStreamOptions, aG as MastraLanguageModel, aH as ToolsInput, aL as ToolsetsInput } from '../base-Ca8Hlcj4.cjs';
5
5
  import '../base-BihKcqDY.cjs';
6
+ import '../di/index.cjs';
6
7
  import '../types-BtMyV38I.cjs';
7
8
  import 'sift';
8
9
  import '../index-CquI0inB.cjs';
@@ -1,8 +1,9 @@
1
1
  export { Message as AiMessageType } from 'ai';
2
2
  import 'json-schema';
3
3
  import 'zod';
4
- export { j as Agent, k as AgentConfig, aM as AgentGenerateOptions, aN as AgentStreamOptions, aG as MastraLanguageModel, aH as ToolsInput, aL as ToolsetsInput } from '../base-BZEw2nXJ.js';
4
+ export { j as Agent, k as AgentConfig, aM as AgentGenerateOptions, aN as AgentStreamOptions, aG as MastraLanguageModel, aH as ToolsInput, aL as ToolsetsInput } from '../base-Cb5pwtMe.js';
5
5
  import '../base-DT2poiVK.js';
6
+ import '../di/index.js';
6
7
  import '../types-BtMyV38I.js';
7
8
  import 'sift';
8
9
  import '../index-CquI0inB.js';
@@ -1 +1 @@
1
- export { Agent } from '../chunk-FFOLLSHP.js';
1
+ export { Agent } from '../chunk-KB4JVOEB.js';
@@ -5,6 +5,7 @@ import { a as Metric, M as MetricResult, T as TestInfo } from './types-BtMyV38I.
5
5
  import { Query } from 'sift';
6
6
  import { z, ZodSchema } from 'zod';
7
7
  import { JSONSchema7 } from 'json-schema';
8
+ import { Container } from './di/index.cjs';
8
9
  import { B as BaseLogMessage, R as RegisteredLogger, L as Logger, d as Run } from './index-CquI0inB.cjs';
9
10
  import { Span } from '@opentelemetry/api';
10
11
  import * as xstate from 'xstate';
@@ -33,6 +34,7 @@ type CoreTool = {
33
34
  });
34
35
  interface ToolExecutionContext<TSchemaIn extends z.ZodSchema | undefined = undefined> extends IExecutionContext<TSchemaIn> {
35
36
  mastra?: MastraUnion;
37
+ container: Container;
36
38
  }
37
39
  interface ToolAction<TSchemaIn extends z.ZodSchema | undefined = undefined, TSchemaOut extends z.ZodSchema | undefined = undefined, TContext extends ToolExecutionContext<TSchemaIn> = ToolExecutionContext<TSchemaIn>> extends IAction<string, TSchemaIn, TSchemaOut, TContext, ToolExecutionOptions> {
38
40
  description: string;
@@ -191,6 +193,7 @@ interface StepExecutionContext<TSchemaIn extends z.ZodSchema | undefined = undef
191
193
  runId: string;
192
194
  emit: (event: string, data: any) => void;
193
195
  mastra?: MastraUnion;
196
+ container: Container;
194
197
  }
195
198
  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> {
196
199
  mastra?: Mastra;
@@ -565,9 +568,10 @@ declare class Machine<TSteps extends Step<any, any, any, any>[] = Step<any, any,
565
568
  #private;
566
569
  logger: Logger;
567
570
  name: string;
568
- constructor({ logger, mastra, workflowInstance, executionSpan, name, runId, steps, stepGraph, retryConfig, startStepId, }: {
571
+ constructor({ logger, mastra, container, workflowInstance, executionSpan, name, runId, steps, stepGraph, retryConfig, startStepId, }: {
569
572
  logger: Logger;
570
573
  mastra?: Mastra;
574
+ container: Container;
571
575
  workflowInstance: WorkflowInstance;
572
576
  executionSpan?: Span;
573
577
  name: string;
@@ -939,13 +943,15 @@ interface WorkflowResultReturn<TResult extends z.ZodObject<any>, T extends z.Zod
939
943
  runId: string;
940
944
  start: (props?: {
941
945
  triggerData?: z.infer<T>;
946
+ container?: Container;
942
947
  } | undefined) => Promise<WorkflowRunResult<T, TSteps, TResult>>;
943
948
  watch: (onTransition: (state: Pick<WorkflowRunResult<T, TSteps, TResult>, 'results' | 'activePaths' | 'runId'>) => void) => () => void;
944
949
  resume: (props: {
945
950
  stepId: string;
946
951
  context?: Record<string, any>;
952
+ container?: Container;
947
953
  }) => Promise<Omit<WorkflowRunResult<T, TSteps, TResult>, 'runId'> | undefined>;
948
- resumeWithEvent: (eventName: string, data: any) => Promise<Omit<WorkflowRunResult<T, TSteps, TResult>, 'runId'> | undefined>;
954
+ resumeWithEvent: (eventName: string, data: any, container?: Container) => Promise<Omit<WorkflowRunResult<T, TSteps, TResult>, 'runId'> | undefined>;
949
955
  }
950
956
  declare class WorkflowInstance<TSteps extends Step<any, any, any, any>[] = Step<any, any, any, any>[], TTriggerSchema extends z.ZodObject<any> = any, TResult extends z.ZodObject<any> = any> implements WorkflowResultReturn<TResult, TTriggerSchema, TSteps> {
951
957
  #private;
@@ -977,8 +983,9 @@ declare class WorkflowInstance<TSteps extends Step<any, any, any, any>[] = Step<
977
983
  get runId(): string;
978
984
  get executionSpan(): Span | undefined;
979
985
  watch(onTransition: (state: Pick<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, 'results' | 'activePaths' | 'runId' | 'timestamp'>) => void): () => void;
980
- start({ triggerData }?: {
986
+ start({ triggerData, container }?: {
981
987
  triggerData?: z.infer<TTriggerSchema>;
988
+ container?: Container;
982
989
  }): Promise<{
983
990
  runId: string;
984
991
  timestamp: number;
@@ -992,28 +999,31 @@ declare class WorkflowInstance<TSteps extends Step<any, any, any, any>[] = Step<
992
999
  }>;
993
1000
  }>;
994
1001
  private isCompoundDependencyMet;
995
- execute({ triggerData, snapshot, stepId, resumeData, }?: {
1002
+ execute({ triggerData, snapshot, stepId, resumeData, container, }?: {
996
1003
  stepId?: string;
997
1004
  triggerData?: z.infer<TTriggerSchema>;
998
1005
  snapshot?: Snapshot<any>;
999
1006
  resumeData?: any;
1007
+ container: Container;
1000
1008
  }): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, 'runId'>>;
1001
1009
  hasSubscribers(stepId: string): boolean;
1002
- runMachine(parentStepId: string, input: any): Promise<(Pick<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, "runId" | "timestamp" | "results" | "activePaths"> | undefined)[]>;
1010
+ runMachine(parentStepId: string, input: any, container?: Container): Promise<(Pick<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, "runId" | "timestamp" | "results" | "activePaths"> | undefined)[]>;
1003
1011
  suspend(stepId: string, machine: Machine<TSteps, TTriggerSchema>): Promise<void>;
1004
1012
  /**
1005
1013
  * Persists the workflow state to the database
1006
1014
  */
1007
1015
  persistWorkflowSnapshot(): Promise<void>;
1008
1016
  getState(): Promise<WorkflowRunState | null>;
1009
- resumeWithEvent(eventName: string, data: any): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, "runId"> | undefined>;
1010
- resume({ stepId, context: resumeContext }: {
1017
+ resumeWithEvent(eventName: string, data: any, container?: Container): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, "runId"> | undefined>;
1018
+ resume({ stepId, context: resumeContext, container, }: {
1011
1019
  stepId: string;
1012
1020
  context?: Record<string, any>;
1021
+ container?: Container;
1013
1022
  }): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, "runId"> | undefined>;
1014
- _resume({ stepId, context: resumeContext }: {
1023
+ _resume({ stepId, context: resumeContext, container, }: {
1015
1024
  stepId: string;
1016
1025
  context?: Record<string, any>;
1026
+ container: Container;
1017
1027
  }): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, "runId"> | undefined>;
1018
1028
  }
1019
1029
 
@@ -1082,10 +1092,11 @@ declare class Workflow<TSteps extends Step<string, any, any>[] = Step<string, an
1082
1092
  getWorkflowRuns(): Promise<WorkflowRuns>;
1083
1093
  getExecutionSpan(runId: string): Span | undefined;
1084
1094
  getState(runId: string): Promise<WorkflowRunState | null>;
1085
- resume({ runId, stepId, context: resumeContext, }: {
1095
+ resume({ runId, stepId, context: resumeContext, container, }: {
1086
1096
  runId: string;
1087
1097
  stepId: string;
1088
1098
  context?: Record<string, any>;
1099
+ container: Container;
1089
1100
  }): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps, any>, "runId"> | undefined>;
1090
1101
  watch(onTransition: (state: Pick<WorkflowRunResult<TTriggerSchema, TSteps, TResultSchema>, 'results' | 'activePaths' | 'runId' | 'timestamp'>) => void): () => void;
1091
1102
  resumeWithEvent(runId: string, eventName: string, data: any): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps, any>, "runId"> | undefined>;
@@ -1309,6 +1320,7 @@ type MastraCustomLLMOptions<Z extends ZodSchema | JSONSchema7 | undefined = unde
1309
1320
  telemetry?: TelemetrySettings;
1310
1321
  threadId?: string;
1311
1322
  resourceId?: string;
1323
+ container: Container;
1312
1324
  } & Run;
1313
1325
  type LLMTextOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = {
1314
1326
  messages: CoreMessage[];
@@ -1568,6 +1580,8 @@ type AgentGenerateOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefi
1568
1580
  };
1569
1581
  /** Telemetry settings */
1570
1582
  telemetry?: TelemetrySettings;
1583
+ /** Container for dependency injection */
1584
+ container?: Container;
1571
1585
  } & ({
1572
1586
  resourceId?: undefined;
1573
1587
  threadId?: undefined;
@@ -1609,6 +1623,8 @@ type AgentStreamOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefine
1609
1623
  experimental_output?: Z;
1610
1624
  /** Telemetry settings */
1611
1625
  telemetry?: TelemetrySettings;
1626
+ /** Container for dependency injection */
1627
+ container?: Container;
1612
1628
  } & ({
1613
1629
  resourceId?: undefined;
1614
1630
  threadId?: undefined;
@@ -1758,10 +1774,10 @@ declare class MastraLLMBase extends MastraBase {
1758
1774
  __registerMastra(p: Mastra): void;
1759
1775
  __text<Z extends ZodSchema | JSONSchema7 | undefined>(input: LLMTextOptions<Z>): Promise<GenerateTextResult<any, any>>;
1760
1776
  __textObject<T extends ZodSchema | JSONSchema7 | undefined>(input: LLMTextObjectOptions<T>): Promise<GenerateObjectResult<T>>;
1761
- generate<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], options?: LLMStreamOptions<Z>): Promise<GenerateReturn<Z>>;
1777
+ generate<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], options: LLMStreamOptions<Z>): Promise<GenerateReturn<Z>>;
1762
1778
  __stream<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(input: LLMInnerStreamOptions<Z>): Promise<StreamTextResult<any, any>>;
1763
1779
  __streamObject<T extends ZodSchema | JSONSchema7 | undefined>(input: LLMStreamObjectOptions<T>): Promise<StreamObjectResult<DeepPartial<T>, T, never>>;
1764
- stream<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], options?: LLMStreamOptions<Z>): Promise<StreamReturn<Z>>;
1780
+ stream<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], options: LLMStreamOptions<Z>): Promise<StreamReturn<Z>>;
1765
1781
  }
1766
1782
 
1767
1783
  declare class Agent<TAgentId extends string = string, TTools extends ToolsInput = ToolsInput, TMetrics extends Record<string, Metric> = Record<string, Metric>> extends MastraBase {
@@ -1807,11 +1823,12 @@ declare class Agent<TAgentId extends string = string, TTools extends ToolsInput
1807
1823
  }>;
1808
1824
  private getResponseMessages;
1809
1825
  sanitizeResponseMessages(messages: Array<CoreMessage$1>): Array<CoreMessage$1>;
1810
- convertTools({ toolsets, threadId, resourceId, runId, }: {
1826
+ convertTools({ toolsets, threadId, resourceId, runId, container, }: {
1811
1827
  toolsets?: ToolsetsInput;
1812
1828
  threadId?: string;
1813
1829
  resourceId?: string;
1814
1830
  runId?: string;
1831
+ container: Container;
1815
1832
  }): Record<string, CoreTool>;
1816
1833
  preExecute({ resourceId, runId, threadId, thread, memoryConfig, messages, systemMessage, }: {
1817
1834
  runId?: string;
@@ -1825,7 +1842,7 @@ declare class Agent<TAgentId extends string = string, TTools extends ToolsInput
1825
1842
  coreMessages: CoreMessage$1[];
1826
1843
  threadIdToUse: string;
1827
1844
  }>;
1828
- __primitive({ instructions, messages, context, threadId, memoryConfig, resourceId, runId, toolsets, }: {
1845
+ __primitive({ instructions, messages, context, threadId, memoryConfig, resourceId, runId, toolsets, container, }: {
1829
1846
  instructions?: string;
1830
1847
  toolsets?: ToolsetsInput;
1831
1848
  resourceId?: string;
@@ -1834,6 +1851,7 @@ declare class Agent<TAgentId extends string = string, TTools extends ToolsInput
1834
1851
  context?: CoreMessage$1[];
1835
1852
  runId?: string;
1836
1853
  messages: CoreMessage$1[];
1854
+ container: Container;
1837
1855
  }): {
1838
1856
  before: () => Promise<{
1839
1857
  messageObjects: CoreMessage$1[];
@@ -5,6 +5,7 @@ import { a as Metric, M as MetricResult, T as TestInfo } from './types-BtMyV38I.
5
5
  import { Query } from 'sift';
6
6
  import { z, ZodSchema } from 'zod';
7
7
  import { JSONSchema7 } from 'json-schema';
8
+ import { Container } from './di/index.js';
8
9
  import { B as BaseLogMessage, R as RegisteredLogger, L as Logger, d as Run } from './index-CquI0inB.js';
9
10
  import { Span } from '@opentelemetry/api';
10
11
  import * as xstate from 'xstate';
@@ -33,6 +34,7 @@ type CoreTool = {
33
34
  });
34
35
  interface ToolExecutionContext<TSchemaIn extends z.ZodSchema | undefined = undefined> extends IExecutionContext<TSchemaIn> {
35
36
  mastra?: MastraUnion;
37
+ container: Container;
36
38
  }
37
39
  interface ToolAction<TSchemaIn extends z.ZodSchema | undefined = undefined, TSchemaOut extends z.ZodSchema | undefined = undefined, TContext extends ToolExecutionContext<TSchemaIn> = ToolExecutionContext<TSchemaIn>> extends IAction<string, TSchemaIn, TSchemaOut, TContext, ToolExecutionOptions> {
38
40
  description: string;
@@ -191,6 +193,7 @@ interface StepExecutionContext<TSchemaIn extends z.ZodSchema | undefined = undef
191
193
  runId: string;
192
194
  emit: (event: string, data: any) => void;
193
195
  mastra?: MastraUnion;
196
+ container: Container;
194
197
  }
195
198
  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> {
196
199
  mastra?: Mastra;
@@ -565,9 +568,10 @@ declare class Machine<TSteps extends Step<any, any, any, any>[] = Step<any, any,
565
568
  #private;
566
569
  logger: Logger;
567
570
  name: string;
568
- constructor({ logger, mastra, workflowInstance, executionSpan, name, runId, steps, stepGraph, retryConfig, startStepId, }: {
571
+ constructor({ logger, mastra, container, workflowInstance, executionSpan, name, runId, steps, stepGraph, retryConfig, startStepId, }: {
569
572
  logger: Logger;
570
573
  mastra?: Mastra;
574
+ container: Container;
571
575
  workflowInstance: WorkflowInstance;
572
576
  executionSpan?: Span;
573
577
  name: string;
@@ -939,13 +943,15 @@ interface WorkflowResultReturn<TResult extends z.ZodObject<any>, T extends z.Zod
939
943
  runId: string;
940
944
  start: (props?: {
941
945
  triggerData?: z.infer<T>;
946
+ container?: Container;
942
947
  } | undefined) => Promise<WorkflowRunResult<T, TSteps, TResult>>;
943
948
  watch: (onTransition: (state: Pick<WorkflowRunResult<T, TSteps, TResult>, 'results' | 'activePaths' | 'runId'>) => void) => () => void;
944
949
  resume: (props: {
945
950
  stepId: string;
946
951
  context?: Record<string, any>;
952
+ container?: Container;
947
953
  }) => Promise<Omit<WorkflowRunResult<T, TSteps, TResult>, 'runId'> | undefined>;
948
- resumeWithEvent: (eventName: string, data: any) => Promise<Omit<WorkflowRunResult<T, TSteps, TResult>, 'runId'> | undefined>;
954
+ resumeWithEvent: (eventName: string, data: any, container?: Container) => Promise<Omit<WorkflowRunResult<T, TSteps, TResult>, 'runId'> | undefined>;
949
955
  }
950
956
  declare class WorkflowInstance<TSteps extends Step<any, any, any, any>[] = Step<any, any, any, any>[], TTriggerSchema extends z.ZodObject<any> = any, TResult extends z.ZodObject<any> = any> implements WorkflowResultReturn<TResult, TTriggerSchema, TSteps> {
951
957
  #private;
@@ -977,8 +983,9 @@ declare class WorkflowInstance<TSteps extends Step<any, any, any, any>[] = Step<
977
983
  get runId(): string;
978
984
  get executionSpan(): Span | undefined;
979
985
  watch(onTransition: (state: Pick<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, 'results' | 'activePaths' | 'runId' | 'timestamp'>) => void): () => void;
980
- start({ triggerData }?: {
986
+ start({ triggerData, container }?: {
981
987
  triggerData?: z.infer<TTriggerSchema>;
988
+ container?: Container;
982
989
  }): Promise<{
983
990
  runId: string;
984
991
  timestamp: number;
@@ -992,28 +999,31 @@ declare class WorkflowInstance<TSteps extends Step<any, any, any, any>[] = Step<
992
999
  }>;
993
1000
  }>;
994
1001
  private isCompoundDependencyMet;
995
- execute({ triggerData, snapshot, stepId, resumeData, }?: {
1002
+ execute({ triggerData, snapshot, stepId, resumeData, container, }?: {
996
1003
  stepId?: string;
997
1004
  triggerData?: z.infer<TTriggerSchema>;
998
1005
  snapshot?: Snapshot<any>;
999
1006
  resumeData?: any;
1007
+ container: Container;
1000
1008
  }): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, 'runId'>>;
1001
1009
  hasSubscribers(stepId: string): boolean;
1002
- runMachine(parentStepId: string, input: any): Promise<(Pick<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, "runId" | "timestamp" | "results" | "activePaths"> | undefined)[]>;
1010
+ runMachine(parentStepId: string, input: any, container?: Container): Promise<(Pick<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, "runId" | "timestamp" | "results" | "activePaths"> | undefined)[]>;
1003
1011
  suspend(stepId: string, machine: Machine<TSteps, TTriggerSchema>): Promise<void>;
1004
1012
  /**
1005
1013
  * Persists the workflow state to the database
1006
1014
  */
1007
1015
  persistWorkflowSnapshot(): Promise<void>;
1008
1016
  getState(): Promise<WorkflowRunState | null>;
1009
- resumeWithEvent(eventName: string, data: any): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, "runId"> | undefined>;
1010
- resume({ stepId, context: resumeContext }: {
1017
+ resumeWithEvent(eventName: string, data: any, container?: Container): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, "runId"> | undefined>;
1018
+ resume({ stepId, context: resumeContext, container, }: {
1011
1019
  stepId: string;
1012
1020
  context?: Record<string, any>;
1021
+ container?: Container;
1013
1022
  }): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, "runId"> | undefined>;
1014
- _resume({ stepId, context: resumeContext }: {
1023
+ _resume({ stepId, context: resumeContext, container, }: {
1015
1024
  stepId: string;
1016
1025
  context?: Record<string, any>;
1026
+ container: Container;
1017
1027
  }): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, "runId"> | undefined>;
1018
1028
  }
1019
1029
 
@@ -1082,10 +1092,11 @@ declare class Workflow<TSteps extends Step<string, any, any>[] = Step<string, an
1082
1092
  getWorkflowRuns(): Promise<WorkflowRuns>;
1083
1093
  getExecutionSpan(runId: string): Span | undefined;
1084
1094
  getState(runId: string): Promise<WorkflowRunState | null>;
1085
- resume({ runId, stepId, context: resumeContext, }: {
1095
+ resume({ runId, stepId, context: resumeContext, container, }: {
1086
1096
  runId: string;
1087
1097
  stepId: string;
1088
1098
  context?: Record<string, any>;
1099
+ container: Container;
1089
1100
  }): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps, any>, "runId"> | undefined>;
1090
1101
  watch(onTransition: (state: Pick<WorkflowRunResult<TTriggerSchema, TSteps, TResultSchema>, 'results' | 'activePaths' | 'runId' | 'timestamp'>) => void): () => void;
1091
1102
  resumeWithEvent(runId: string, eventName: string, data: any): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps, any>, "runId"> | undefined>;
@@ -1309,6 +1320,7 @@ type MastraCustomLLMOptions<Z extends ZodSchema | JSONSchema7 | undefined = unde
1309
1320
  telemetry?: TelemetrySettings;
1310
1321
  threadId?: string;
1311
1322
  resourceId?: string;
1323
+ container: Container;
1312
1324
  } & Run;
1313
1325
  type LLMTextOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = {
1314
1326
  messages: CoreMessage[];
@@ -1568,6 +1580,8 @@ type AgentGenerateOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefi
1568
1580
  };
1569
1581
  /** Telemetry settings */
1570
1582
  telemetry?: TelemetrySettings;
1583
+ /** Container for dependency injection */
1584
+ container?: Container;
1571
1585
  } & ({
1572
1586
  resourceId?: undefined;
1573
1587
  threadId?: undefined;
@@ -1609,6 +1623,8 @@ type AgentStreamOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefine
1609
1623
  experimental_output?: Z;
1610
1624
  /** Telemetry settings */
1611
1625
  telemetry?: TelemetrySettings;
1626
+ /** Container for dependency injection */
1627
+ container?: Container;
1612
1628
  } & ({
1613
1629
  resourceId?: undefined;
1614
1630
  threadId?: undefined;
@@ -1758,10 +1774,10 @@ declare class MastraLLMBase extends MastraBase {
1758
1774
  __registerMastra(p: Mastra): void;
1759
1775
  __text<Z extends ZodSchema | JSONSchema7 | undefined>(input: LLMTextOptions<Z>): Promise<GenerateTextResult<any, any>>;
1760
1776
  __textObject<T extends ZodSchema | JSONSchema7 | undefined>(input: LLMTextObjectOptions<T>): Promise<GenerateObjectResult<T>>;
1761
- generate<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], options?: LLMStreamOptions<Z>): Promise<GenerateReturn<Z>>;
1777
+ generate<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], options: LLMStreamOptions<Z>): Promise<GenerateReturn<Z>>;
1762
1778
  __stream<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(input: LLMInnerStreamOptions<Z>): Promise<StreamTextResult<any, any>>;
1763
1779
  __streamObject<T extends ZodSchema | JSONSchema7 | undefined>(input: LLMStreamObjectOptions<T>): Promise<StreamObjectResult<DeepPartial<T>, T, never>>;
1764
- stream<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], options?: LLMStreamOptions<Z>): Promise<StreamReturn<Z>>;
1780
+ stream<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], options: LLMStreamOptions<Z>): Promise<StreamReturn<Z>>;
1765
1781
  }
1766
1782
 
1767
1783
  declare class Agent<TAgentId extends string = string, TTools extends ToolsInput = ToolsInput, TMetrics extends Record<string, Metric> = Record<string, Metric>> extends MastraBase {
@@ -1807,11 +1823,12 @@ declare class Agent<TAgentId extends string = string, TTools extends ToolsInput
1807
1823
  }>;
1808
1824
  private getResponseMessages;
1809
1825
  sanitizeResponseMessages(messages: Array<CoreMessage$1>): Array<CoreMessage$1>;
1810
- convertTools({ toolsets, threadId, resourceId, runId, }: {
1826
+ convertTools({ toolsets, threadId, resourceId, runId, container, }: {
1811
1827
  toolsets?: ToolsetsInput;
1812
1828
  threadId?: string;
1813
1829
  resourceId?: string;
1814
1830
  runId?: string;
1831
+ container: Container;
1815
1832
  }): Record<string, CoreTool>;
1816
1833
  preExecute({ resourceId, runId, threadId, thread, memoryConfig, messages, systemMessage, }: {
1817
1834
  runId?: string;
@@ -1825,7 +1842,7 @@ declare class Agent<TAgentId extends string = string, TTools extends ToolsInput
1825
1842
  coreMessages: CoreMessage$1[];
1826
1843
  threadIdToUse: string;
1827
1844
  }>;
1828
- __primitive({ instructions, messages, context, threadId, memoryConfig, resourceId, runId, toolsets, }: {
1845
+ __primitive({ instructions, messages, context, threadId, memoryConfig, resourceId, runId, toolsets, container, }: {
1829
1846
  instructions?: string;
1830
1847
  toolsets?: ToolsetsInput;
1831
1848
  resourceId?: string;
@@ -1834,6 +1851,7 @@ declare class Agent<TAgentId extends string = string, TTools extends ToolsInput
1834
1851
  context?: CoreMessage$1[];
1835
1852
  runId?: string;
1836
1853
  messages: CoreMessage$1[];
1854
+ container: Container;
1837
1855
  }): {
1838
1856
  before: () => Promise<{
1839
1857
  messageObjects: CoreMessage$1[];
@@ -0,0 +1,69 @@
1
+ // src/di/index.ts
2
+ var Container = class {
3
+ registry = /* @__PURE__ */ new Map();
4
+ constructor(iterable) {
5
+ this.registry = new Map(iterable);
6
+ }
7
+ /**
8
+ * set a value with strict typing if `Values` is a Record and the key exists in it.
9
+ */
10
+ set(key, value) {
11
+ this.registry.set(key, value);
12
+ }
13
+ /**
14
+ * Get a value with its type
15
+ */
16
+ get(key) {
17
+ return this.registry.get(key);
18
+ }
19
+ /**
20
+ * Check if a key exists in the container
21
+ */
22
+ has(key) {
23
+ return this.registry.has(key);
24
+ }
25
+ /**
26
+ * Delete a value by key
27
+ */
28
+ delete(key) {
29
+ return this.registry.delete(key);
30
+ }
31
+ /**
32
+ * Clear all values from the container
33
+ */
34
+ clear() {
35
+ this.registry.clear();
36
+ }
37
+ /**
38
+ * Get all keys in the container
39
+ */
40
+ keys() {
41
+ return this.registry.keys();
42
+ }
43
+ /**
44
+ * Get all values in the container
45
+ */
46
+ values() {
47
+ return this.registry.values();
48
+ }
49
+ /**
50
+ * Get all entries in the container
51
+ */
52
+ entries() {
53
+ return this.registry.entries();
54
+ }
55
+ /**
56
+ * Get the size of the container
57
+ */
58
+ size() {
59
+ return this.registry.size;
60
+ }
61
+ /**
62
+ * Execute a function for each entry in the container
63
+ */
64
+ forEach(callbackfn) {
65
+ this.registry.forEach(callbackfn);
66
+ }
67
+ };
68
+
69
+ export { Container };
@@ -2,7 +2,7 @@
2
2
 
3
3
  var chunkAAMFAGE5_cjs = require('./chunk-AAMFAGE5.cjs');
4
4
  var chunk2LIFCMY6_cjs = require('./chunk-2LIFCMY6.cjs');
5
- var chunk64VPB7ZD_cjs = require('./chunk-64VPB7ZD.cjs');
5
+ var chunkPY3DCT4A_cjs = require('./chunk-PY3DCT4A.cjs');
6
6
  var chunkD63P5O4Q_cjs = require('./chunk-D63P5O4Q.cjs');
7
7
  var fs = require('fs');
8
8
  var path = require('path');
@@ -226,7 +226,7 @@ var MastraMemory = class extends chunkD63P5O4Q_cjs.MastraBase {
226
226
  return { indexName };
227
227
  }
228
228
  getMergedThreadConfig(config) {
229
- return chunk64VPB7ZD_cjs.deepMerge(this.threadConfig, config || {});
229
+ return chunkPY3DCT4A_cjs.deepMerge(this.threadConfig, config || {});
230
230
  }
231
231
  /**
232
232
  * Apply all configured message processors to a list of messages.
@@ -1,4 +1,4 @@
1
- import { createTool } from './chunk-BC5B4EGI.js';
1
+ import { createTool } from './chunk-K5TZKHR7.js';
2
2
  import { z } from 'zod';
3
3
 
4
4
  // src/integration/integration.ts
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunk64VPB7ZD_cjs = require('./chunk-64VPB7ZD.cjs');
3
+ var chunkPY3DCT4A_cjs = require('./chunk-PY3DCT4A.cjs');
4
4
  var zod = require('zod');
5
5
 
6
6
  // src/integration/integration.ts
@@ -68,7 +68,7 @@ var OpenAPIToolset = class {
68
68
  const tools = Object.keys(clientMethods).reduce((acc, key) => {
69
69
  const comment = documentations[key]?.comment;
70
70
  const fallbackComment = `Execute ${key}`;
71
- const tool = chunk64VPB7ZD_cjs.createTool({
71
+ const tool = chunkPY3DCT4A_cjs.createTool({
72
72
  id: key,
73
73
  inputSchema: schemas[key] || zod.z.object({}),
74
74
  description: comment || fallbackComment,
@@ -1,3 +1,4 @@
1
+ import { Container } from './chunk-3PBEAM6M.js';
1
2
  import { createHash } from 'crypto';
2
3
  import { convertToCoreMessages } from 'ai';
3
4
  import jsonSchemaToZod from 'json-schema-to-zod';
@@ -221,7 +222,7 @@ function createLogMessageOptions({ agentName, toolName, tool, type }) {
221
222
  };
222
223
  }
223
224
  function createExecute(tool, options, logType) {
224
- const { logger, mastra: _mastra, memory: _memory, ...rest } = options;
225
+ const { logger, mastra: _mastra, memory: _memory, container, ...rest } = options;
225
226
  const { start, error } = createLogMessageOptions({
226
227
  agentName: options.agentName,
227
228
  toolName: options.name,
@@ -239,7 +240,8 @@ function createExecute(tool, options, logType) {
239
240
  resourceId: options.resourceId,
240
241
  mastra: options.mastra,
241
242
  memory: options.memory,
242
- runId: options.runId
243
+ runId: options.runId,
244
+ container: container ?? new Container()
243
245
  },
244
246
  execOptions
245
247
  ) ?? void 0;