@mastra/core 0.5.0-alpha.8 → 0.5.0-alpha.9

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 (48) hide show
  1. package/dist/agent/index.cjs +45 -5
  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-DIn_km7X.d.ts → base-B78F6w8S.d.ts} +7 -11
  6. package/dist/{base-CTdONy0_.d.cts → base-CMEKtEnE.d.cts} +7 -11
  7. package/dist/{chunk-QABMKXI3.js → chunk-4AQBRUR2.js} +1 -1
  8. package/dist/{chunk-KBSR2LLT.js → chunk-6V737PR2.js} +11 -6
  9. package/dist/{chunk-SF5GHHOQ.js → chunk-EWB556GS.js} +93 -93
  10. package/dist/{chunk-HBHPTMAC.js → chunk-IM7CM3DU.js} +45 -5
  11. package/dist/{chunk-RRJB4TCC.js → chunk-NR5T72G7.js} +1 -1
  12. package/dist/{chunk-SWDQYPJS.js → chunk-TWAIC2XA.js} +3 -2
  13. package/dist/eval/index.d.cts +1 -1
  14. package/dist/eval/index.d.ts +1 -1
  15. package/dist/index.cjs +149 -103
  16. package/dist/index.d.cts +3 -3
  17. package/dist/index.d.ts +3 -3
  18. package/dist/index.js +7 -7
  19. package/dist/integration/index.d.cts +1 -1
  20. package/dist/integration/index.d.ts +1 -1
  21. package/dist/llm/index.d.cts +1 -1
  22. package/dist/llm/index.d.ts +1 -1
  23. package/dist/mastra/index.cjs +93 -93
  24. package/dist/mastra/index.d.cts +1 -1
  25. package/dist/mastra/index.d.ts +1 -1
  26. package/dist/mastra/index.js +1 -1
  27. package/dist/memory/index.d.cts +1 -1
  28. package/dist/memory/index.d.ts +1 -1
  29. package/dist/memory/index.js +1 -1
  30. package/dist/relevance/index.cjs +45 -5
  31. package/dist/relevance/index.js +1 -1
  32. package/dist/storage/index.d.cts +1 -1
  33. package/dist/storage/index.d.ts +1 -1
  34. package/dist/storage/libsql/index.d.cts +1 -1
  35. package/dist/storage/libsql/index.d.ts +1 -1
  36. package/dist/telemetry/index.d.cts +1 -1
  37. package/dist/telemetry/index.d.ts +1 -1
  38. package/dist/tools/index.d.cts +2 -2
  39. package/dist/tools/index.d.ts +2 -2
  40. package/dist/utils.cjs +45 -4
  41. package/dist/utils.d.cts +8 -2
  42. package/dist/utils.d.ts +8 -2
  43. package/dist/utils.js +1 -1
  44. package/dist/workflows/index.cjs +18 -7
  45. package/dist/workflows/index.d.cts +2 -2
  46. package/dist/workflows/index.d.ts +2 -2
  47. package/dist/workflows/index.js +1 -1
  48. package/package.json +1 -1
@@ -454,12 +454,45 @@ function createExecute(tool, options, logType) {
454
454
  }
455
455
  };
456
456
  }
457
+ function isZodType(value) {
458
+ return typeof value === "object" && value !== null && "_def" in value && "parse" in value && typeof value.parse === "function" && "safeParse" in value && typeof value.safeParse === "function";
459
+ }
460
+ function createDeterministicId(input) {
461
+ return crypto$1.createHash("sha256").update(input).digest("hex").slice(0, 8);
462
+ }
463
+ function setVercelToolProperties(tool) {
464
+ const inputSchema = convertVercelToolParameters(tool);
465
+ const toolId = !("id" in tool) ? tool.description ? `tool-${createDeterministicId(tool.description)}` : `tool-${Math.random().toString(36).substring(2, 9)}` : tool.id;
466
+ return {
467
+ ...tool,
468
+ id: toolId,
469
+ inputSchema
470
+ };
471
+ }
472
+ function ensureToolProperties(tools) {
473
+ const toolsWithProperties = Object.keys(tools).reduce((acc, key) => {
474
+ const tool = tools?.[key];
475
+ if (tool) {
476
+ if (isVercelTool(tool)) {
477
+ acc[key] = setVercelToolProperties(tool);
478
+ } else {
479
+ acc[key] = tool;
480
+ }
481
+ }
482
+ return acc;
483
+ }, {});
484
+ return toolsWithProperties;
485
+ }
486
+ function convertVercelToolParameters(tool) {
487
+ const schema = tool.parameters ?? zod.z.object({});
488
+ return isZodType(schema) ? schema : resolveSerializedZodOutput(jsonSchemaToZod__default.default(schema));
489
+ }
457
490
  function makeCoreTool(tool, options, logType) {
458
491
  const getParameters = () => {
459
492
  if (isVercelTool(tool)) {
460
- return tool.parameters instanceof zod.z.ZodType ? tool.parameters : resolveSerializedZodOutput(jsonSchemaToZod__default.default(tool.parameters));
493
+ return convertVercelToolParameters(tool);
461
494
  }
462
- return tool.inputSchema;
495
+ return tool.inputSchema ?? zod.z.object({});
463
496
  };
464
497
  return {
465
498
  description: tool.description,
@@ -476,8 +509,14 @@ function createMastraProxy({
476
509
  }) {
477
510
  return new Proxy(mastra, {
478
511
  get(target, prop) {
479
- if (Reflect.has(target, prop)) {
480
- return Reflect.get(target, prop);
512
+ const hasProp = Reflect.has(target, prop);
513
+ if (hasProp) {
514
+ const value = Reflect.get(target, prop);
515
+ const isFunction = typeof value === "function";
516
+ if (isFunction) {
517
+ return value.bind(target);
518
+ }
519
+ return value;
481
520
  }
482
521
  if (prop === "logger") {
483
522
  logger.warn(`Please use 'getLogger' instead, logger is deprecated`);
@@ -1157,7 +1196,7 @@ exports.Agent = class Agent extends (_a = MastraBase) {
1157
1196
  this.metrics = {};
1158
1197
  this.evals = {};
1159
1198
  if (config.tools) {
1160
- this.tools = config.tools;
1199
+ this.tools = ensureToolProperties(config.tools);
1161
1200
  }
1162
1201
  if (config.mastra) {
1163
1202
  this.__registerPrimitives({
@@ -1315,6 +1354,7 @@ exports.Agent = class Agent extends (_a = MastraBase) {
1315
1354
  });
1316
1355
  const memoryMessages = threadId && memory ? (await memory.rememberMessages({
1317
1356
  threadId,
1357
+ resourceId,
1318
1358
  config: memoryConfig,
1319
1359
  vectorMessageSearch: messages.slice(-1).map(m => {
1320
1360
  if (typeof m === `string`) {
@@ -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, h as AgentConfig, au as AgentGenerateOptions, av as AgentStreamOptions, as as ToolsInput, at as ToolsetsInput } from '../base-CTdONy0_.cjs';
4
+ export { A as Agent, i as AgentConfig, au as AgentGenerateOptions, av as AgentStreamOptions, a as ToolsInput, at as ToolsetsInput } from '../base-CMEKtEnE.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, h as AgentConfig, au as AgentGenerateOptions, av as AgentStreamOptions, as as ToolsInput, at as ToolsetsInput } from '../base-DIn_km7X.js';
4
+ export { A as Agent, i as AgentConfig, au as AgentGenerateOptions, av as AgentStreamOptions, a as ToolsInput, at as ToolsetsInput } from '../base-B78F6w8S.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-SWDQYPJS.js';
1
+ export { Agent } from '../chunk-TWAIC2XA.js';
@@ -62,8 +62,9 @@ declare abstract class MastraMemory extends MastraBase {
62
62
  indexName: string;
63
63
  }>;
64
64
  getMergedThreadConfig(config?: MemoryConfig): MemoryConfig;
65
- abstract rememberMessages({ threadId, vectorMessageSearch, config, }: {
65
+ abstract rememberMessages({ threadId, resourceId, vectorMessageSearch, config, }: {
66
66
  threadId: string;
67
+ resourceId?: string;
67
68
  vectorMessageSearch?: string;
68
69
  config?: MemoryConfig;
69
70
  }): Promise<{
@@ -108,7 +109,7 @@ declare abstract class MastraMemory extends MastraBase {
108
109
  * @param threadId - The unique identifier of the thread
109
110
  * @returns Promise resolving to array of messages and uiMessages
110
111
  */
111
- abstract query({ threadId, selectBy, }: StorageGetMessagesArg): Promise<{
112
+ abstract query({ threadId, resourceId, selectBy, }: StorageGetMessagesArg): Promise<{
112
113
  messages: CoreMessage$1[];
113
114
  uiMessages: Message[];
114
115
  }>;
@@ -166,7 +167,7 @@ interface WorkflowOptions<TTriggerSchema extends z.ZodObject<any> = any> {
166
167
  }
167
168
  interface StepExecutionContext<TSchemaIn extends z.ZodSchema | undefined = undefined, TContext extends WorkflowContext = WorkflowContext> extends IExecutionContext<TSchemaIn> {
168
169
  context: TSchemaIn extends z.ZodSchema ? z.infer<TSchemaIn> & TContext : TContext;
169
- suspend: () => Promise<void>;
170
+ suspend: (payload?: unknown) => Promise<void>;
170
171
  runId: string;
171
172
  mastra?: MastraUnion;
172
173
  }
@@ -572,13 +573,7 @@ interface Config<TAgents extends Record<string, Agent<any>> = Record<string, Age
572
573
  memory?: MastraMemory;
573
574
  }
574
575
  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> {
575
- private vectors?;
576
- private agents;
577
- private logger;
578
- private workflows;
579
- private telemetry?;
580
- private tts?;
581
- private deployer?;
576
+ #private;
582
577
  storage?: MastraStorage;
583
578
  memory?: MastraMemory;
584
579
  constructor(config?: Config<TAgents, TWorkflows, TVectors, TTTS, TLogger>);
@@ -933,6 +928,7 @@ interface WorkflowRow {
933
928
  }
934
929
  type StorageGetMessagesArg = {
935
930
  threadId: string;
931
+ resourceId?: string;
936
932
  selectBy?: {
937
933
  vectorSearchString?: string;
938
934
  last?: number | false;
@@ -1120,4 +1116,4 @@ declare abstract class MastraStorage extends MastraBase {
1120
1116
  __getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
1121
1117
  }
1122
1118
 
1123
- export { type RetryConfig as $, Agent as A, type BaseStructuredOutputType as B, type CoreTool as C, type DefaultLLMTextOptions as D, type EvalRow as E, type LLMTextOptions as F, type GenerateReturn as G, type LLMTextObjectOptions as H, type LLMStreamOptions as I, type LLMInnerStreamOptions as J, type LLMStreamObjectOptions as K, type LanguageModel as L, Mastra as M, type Config as N, type OutputType as O, type MessageResponse as P, type MemoryConfig as Q, type SharedMemoryConfig as R, type StorageColumn as S, type ToolAction as T, type StepExecutionContext as U, type VercelTool as V, Workflow as W, type StepAction as X, type StepVariableType as Y, type StepNode as Z, type StepGraph as _, type MastraPrimitives as a, type VariableReference as a0, type BaseCondition as a1, type ActionContext as a2, WhenConditionReturnValue as a3, type StepDef as a4, type StepCondition as a5, type StepConfig as a6, type StepResult as a7, type WorkflowContext as a8, type WorkflowLogMessage as a9, TABLE_TRACES as aA, type WorkflowEvent as aa, type ResolverFunctionInput as ab, type ResolverFunctionOutput as ac, type SubscriberFunctionOutput as ad, type DependencyCheckOutput as ae, type WorkflowActors as af, type WorkflowActionParams as ag, type WorkflowActions as ah, type WorkflowState as ai, type StepId as aj, type ExtractSchemaFromStep as ak, type ExtractStepResult as al, type StepInputType as am, type ExtractSchemaType as an, type PathsToStringProps as ao, type WorkflowRunState as ap, type WorkflowResumeResult as aq, createStep as ar, type ToolsInput 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, MastraMemory as b, MastraStorage as c, type TABLE_NAMES as d, type StorageThreadType as e, type MessageType as f, type StorageGetMessagesArg as g, type AgentConfig as h, type ToolExecutionContext as i, Step as j, type WorkflowOptions as k, type WorkflowRow as l, type CoreMessage as m, type CoreSystemMessage as n, type CoreAssistantMessage as o, type CoreUserMessage as p, type CoreToolMessage as q, type EmbedResult as r, type EmbedManyResult as s, type StructuredOutputType as t, type StructuredOutputArrayItem as u, type StructuredOutput as v, type StreamReturn as w, type DefaultLLMTextObjectOptions as x, type DefaultLLMStreamOptions as y, type DefaultLLMStreamObjectOptions as z };
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 };
@@ -62,8 +62,9 @@ declare abstract class MastraMemory extends MastraBase {
62
62
  indexName: string;
63
63
  }>;
64
64
  getMergedThreadConfig(config?: MemoryConfig): MemoryConfig;
65
- abstract rememberMessages({ threadId, vectorMessageSearch, config, }: {
65
+ abstract rememberMessages({ threadId, resourceId, vectorMessageSearch, config, }: {
66
66
  threadId: string;
67
+ resourceId?: string;
67
68
  vectorMessageSearch?: string;
68
69
  config?: MemoryConfig;
69
70
  }): Promise<{
@@ -108,7 +109,7 @@ declare abstract class MastraMemory extends MastraBase {
108
109
  * @param threadId - The unique identifier of the thread
109
110
  * @returns Promise resolving to array of messages and uiMessages
110
111
  */
111
- abstract query({ threadId, selectBy, }: StorageGetMessagesArg): Promise<{
112
+ abstract query({ threadId, resourceId, selectBy, }: StorageGetMessagesArg): Promise<{
112
113
  messages: CoreMessage$1[];
113
114
  uiMessages: Message[];
114
115
  }>;
@@ -166,7 +167,7 @@ interface WorkflowOptions<TTriggerSchema extends z.ZodObject<any> = any> {
166
167
  }
167
168
  interface StepExecutionContext<TSchemaIn extends z.ZodSchema | undefined = undefined, TContext extends WorkflowContext = WorkflowContext> extends IExecutionContext<TSchemaIn> {
168
169
  context: TSchemaIn extends z.ZodSchema ? z.infer<TSchemaIn> & TContext : TContext;
169
- suspend: () => Promise<void>;
170
+ suspend: (payload?: unknown) => Promise<void>;
170
171
  runId: string;
171
172
  mastra?: MastraUnion;
172
173
  }
@@ -572,13 +573,7 @@ interface Config<TAgents extends Record<string, Agent<any>> = Record<string, Age
572
573
  memory?: MastraMemory;
573
574
  }
574
575
  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> {
575
- private vectors?;
576
- private agents;
577
- private logger;
578
- private workflows;
579
- private telemetry?;
580
- private tts?;
581
- private deployer?;
576
+ #private;
582
577
  storage?: MastraStorage;
583
578
  memory?: MastraMemory;
584
579
  constructor(config?: Config<TAgents, TWorkflows, TVectors, TTTS, TLogger>);
@@ -933,6 +928,7 @@ interface WorkflowRow {
933
928
  }
934
929
  type StorageGetMessagesArg = {
935
930
  threadId: string;
931
+ resourceId?: string;
936
932
  selectBy?: {
937
933
  vectorSearchString?: string;
938
934
  last?: number | false;
@@ -1120,4 +1116,4 @@ declare abstract class MastraStorage extends MastraBase {
1120
1116
  __getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
1121
1117
  }
1122
1118
 
1123
- export { type RetryConfig as $, Agent as A, type BaseStructuredOutputType as B, type CoreTool as C, type DefaultLLMTextOptions as D, type EvalRow as E, type LLMTextOptions as F, type GenerateReturn as G, type LLMTextObjectOptions as H, type LLMStreamOptions as I, type LLMInnerStreamOptions as J, type LLMStreamObjectOptions as K, type LanguageModel as L, Mastra as M, type Config as N, type OutputType as O, type MessageResponse as P, type MemoryConfig as Q, type SharedMemoryConfig as R, type StorageColumn as S, type ToolAction as T, type StepExecutionContext as U, type VercelTool as V, Workflow as W, type StepAction as X, type StepVariableType as Y, type StepNode as Z, type StepGraph as _, type MastraPrimitives as a, type VariableReference as a0, type BaseCondition as a1, type ActionContext as a2, WhenConditionReturnValue as a3, type StepDef as a4, type StepCondition as a5, type StepConfig as a6, type StepResult as a7, type WorkflowContext as a8, type WorkflowLogMessage as a9, TABLE_TRACES as aA, type WorkflowEvent as aa, type ResolverFunctionInput as ab, type ResolverFunctionOutput as ac, type SubscriberFunctionOutput as ad, type DependencyCheckOutput as ae, type WorkflowActors as af, type WorkflowActionParams as ag, type WorkflowActions as ah, type WorkflowState as ai, type StepId as aj, type ExtractSchemaFromStep as ak, type ExtractStepResult as al, type StepInputType as am, type ExtractSchemaType as an, type PathsToStringProps as ao, type WorkflowRunState as ap, type WorkflowResumeResult as aq, createStep as ar, type ToolsInput 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, MastraMemory as b, MastraStorage as c, type TABLE_NAMES as d, type StorageThreadType as e, type MessageType as f, type StorageGetMessagesArg as g, type AgentConfig as h, type ToolExecutionContext as i, Step as j, type WorkflowOptions as k, type WorkflowRow as l, type CoreMessage as m, type CoreSystemMessage as n, type CoreAssistantMessage as o, type CoreUserMessage as p, type CoreToolMessage as q, type EmbedResult as r, type EmbedManyResult as s, type StructuredOutputType as t, type StructuredOutputArrayItem as u, type StructuredOutput as v, type StreamReturn as w, type DefaultLLMTextObjectOptions as x, type DefaultLLMStreamOptions as y, type DefaultLLMStreamObjectOptions as z };
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 };
@@ -1,4 +1,4 @@
1
- import { Agent } from './chunk-SWDQYPJS.js';
1
+ import { Agent } from './chunk-TWAIC2XA.js';
2
2
  import { CohereClient } from 'cohere-ai';
3
3
 
4
4
  var CohereRelevanceScorer = class {
@@ -1,4 +1,4 @@
1
- import { createMastraProxy } from './chunk-HBHPTMAC.js';
1
+ import { createMastraProxy } from './chunk-IM7CM3DU.js';
2
2
  import { MastraBase } from './chunk-4VHCCQ7P.js';
3
3
  import { setTimeout } from 'node:timers/promises';
4
4
  import { context, trace } from '@opentelemetry/api';
@@ -1207,6 +1207,7 @@ var Workflow = class extends MastraBase {
1207
1207
  telemetry: mastra.getTelemetry(),
1208
1208
  logger: mastra.getLogger()
1209
1209
  });
1210
+ this.#mastra = mastra;
1210
1211
  }
1211
1212
  }
1212
1213
  step(step, config) {
@@ -1508,10 +1509,14 @@ var Workflow = class extends MastraBase {
1508
1509
  return await context.with(
1509
1510
  trace.setSpan(context.active(), this.getExecutionSpan(attributes?.runId ?? data?.runId)),
1510
1511
  async () => {
1511
- return this.#mastra.telemetry.traceMethod(handler2, {
1512
- spanName,
1513
- attributes
1514
- })(data);
1512
+ if (this?.telemetry) {
1513
+ return this.telemetry.traceMethod(handler2, {
1514
+ spanName,
1515
+ attributes
1516
+ })(data);
1517
+ } else {
1518
+ return handler2(data);
1519
+ }
1515
1520
  }
1516
1521
  );
1517
1522
  };
@@ -1525,7 +1530,7 @@ var Workflow = class extends MastraBase {
1525
1530
  ...payload,
1526
1531
  ...context
1527
1532
  };
1528
- const finalAction = this.#mastra?.getTelemetry() ? executeStep(execute, `workflow.${this.name}.action.${stepId}`, {
1533
+ const finalAction = this.telemetry ? executeStep(execute, `workflow.${this.name}.action.${stepId}`, {
1529
1534
  componentName: this.name,
1530
1535
  runId: rest.runId
1531
1536
  }) : execute;
@@ -10,13 +10,13 @@ _Mastra_decorators = [InstrumentClass({
10
10
  excludeMethods: ["getLogger", "getTelemetry"]
11
11
  })];
12
12
  var Mastra = class {
13
- vectors;
14
- agents;
15
- logger;
16
- workflows;
17
- telemetry;
18
- tts;
19
- deployer;
13
+ #vectors;
14
+ #agents;
15
+ #logger;
16
+ #workflows;
17
+ #telemetry;
18
+ #tts;
19
+ #deployer;
20
20
  storage;
21
21
  memory;
22
22
  constructor(config) {
@@ -34,7 +34,7 @@ var Mastra = class {
34
34
  });
35
35
  }
36
36
  }
37
- this.logger = logger;
37
+ this.#logger = logger;
38
38
  let storage = config?.storage;
39
39
  if (!storage) {
40
40
  storage = new LibSQLStore({
@@ -54,55 +54,55 @@ var Mastra = class {
54
54
  })
55
55
  }
56
56
  };
57
- this.telemetry = Telemetry.init(newTelemetry);
57
+ this.#telemetry = Telemetry.init(newTelemetry);
58
58
  } else if (config?.telemetry) {
59
- this.telemetry = Telemetry.init(config?.telemetry);
59
+ this.#telemetry = Telemetry.init(config?.telemetry);
60
60
  }
61
61
  if (config?.deployer) {
62
- this.deployer = config.deployer;
63
- if (this.telemetry) {
64
- this.deployer = this.telemetry.traceClass(config.deployer, {
62
+ this.#deployer = config.deployer;
63
+ if (this.#telemetry) {
64
+ this.#deployer = this.#telemetry.traceClass(config.deployer, {
65
65
  excludeMethods: ["__setTelemetry", "__getTelemetry"]
66
66
  });
67
- this.deployer.__setTelemetry(this.telemetry);
67
+ this.#deployer.__setTelemetry(this.#telemetry);
68
68
  }
69
69
  }
70
- if (this.telemetry) {
71
- this.storage = this.telemetry.traceClass(storage, {
70
+ if (this.#telemetry) {
71
+ this.storage = this.#telemetry.traceClass(storage, {
72
72
  excludeMethods: ["__setTelemetry", "__getTelemetry"]
73
73
  });
74
- this.storage.__setTelemetry(this.telemetry);
74
+ this.storage.__setTelemetry(this.#telemetry);
75
75
  } else {
76
76
  this.storage = storage;
77
77
  }
78
78
  if (config?.vectors) {
79
79
  let vectors = {};
80
80
  Object.entries(config.vectors).forEach(([key, vector]) => {
81
- if (this.telemetry) {
82
- vectors[key] = this.telemetry.traceClass(vector, {
81
+ if (this.#telemetry) {
82
+ vectors[key] = this.#telemetry.traceClass(vector, {
83
83
  excludeMethods: ["__setTelemetry", "__getTelemetry"]
84
84
  });
85
- vectors[key].__setTelemetry(this.telemetry);
85
+ vectors[key].__setTelemetry(this.#telemetry);
86
86
  } else {
87
87
  vectors[key] = vector;
88
88
  }
89
89
  });
90
- this.vectors = vectors;
90
+ this.#vectors = vectors;
91
91
  }
92
92
  if (config?.vectors) {
93
- this.vectors = config.vectors;
93
+ this.#vectors = config.vectors;
94
94
  }
95
95
  if (config?.memory) {
96
96
  this.memory = config.memory;
97
- if (this.telemetry) {
98
- this.memory = this.telemetry.traceClass(config.memory, {
97
+ if (this.#telemetry) {
98
+ this.memory = this.#telemetry.traceClass(config.memory, {
99
99
  excludeMethods: ["__setTelemetry", "__getTelemetry"]
100
100
  });
101
- this.memory.__setTelemetry(this.telemetry);
101
+ this.memory.__setTelemetry(this.#telemetry);
102
102
  }
103
103
  }
104
104
  if (config && `memory` in config) {
105
- this.logger.warn(`
105
+ this.#logger.warn(`
106
106
  Memory should be added to Agents, not to Mastra.
107
107
 
108
108
  Instead of:
@@ -115,14 +115,14 @@ This is a warning for now, but will throw an error in the future
115
115
  `);
116
116
  }
117
117
  if (config?.tts) {
118
- this.tts = config.tts;
119
- Object.entries(this.tts).forEach(([key, ttsCl]) => {
120
- if (this.tts?.[key]) {
121
- if (this.telemetry) {
122
- this.tts[key] = this.telemetry.traceClass(ttsCl, {
118
+ this.#tts = config.tts;
119
+ Object.entries(this.#tts).forEach(([key, ttsCl]) => {
120
+ if (this.#tts?.[key]) {
121
+ if (this.#telemetry) {
122
+ this.#tts[key] = this.#telemetry.traceClass(ttsCl, {
123
123
  excludeMethods: ["__setTelemetry", "__getTelemetry"]
124
124
  });
125
- this.tts[key].__setTelemetry(this.telemetry);
125
+ this.#tts[key].__setTelemetry(this.#telemetry);
126
126
  }
127
127
  }
128
128
  });
@@ -135,32 +135,32 @@ This is a warning for now, but will throw an error in the future
135
135
  }
136
136
  agent.__registerPrimitives({
137
137
  logger: this.getLogger(),
138
- telemetry: this.telemetry,
138
+ telemetry: this.#telemetry,
139
139
  storage: this.storage,
140
140
  memory: this.memory,
141
141
  agents,
142
- tts: this.tts,
143
- vectors: this.vectors
142
+ tts: this.#tts,
143
+ vectors: this.#vectors
144
144
  });
145
145
  agent.__registerMastra(this);
146
146
  agents[key] = agent;
147
147
  });
148
148
  }
149
- this.agents = agents;
150
- this.workflows = {};
149
+ this.#agents = agents;
150
+ this.#workflows = {};
151
151
  if (config?.workflows) {
152
152
  Object.entries(config.workflows).forEach(([key, workflow]) => {
153
153
  workflow.__registerMastra(this);
154
154
  workflow.__registerPrimitives({
155
155
  logger: this.getLogger(),
156
- telemetry: this.telemetry,
156
+ telemetry: this.#telemetry,
157
157
  storage: this.storage,
158
158
  memory: this.memory,
159
159
  agents,
160
- tts: this.tts,
161
- vectors: this.vectors
160
+ tts: this.#tts,
161
+ vectors: this.#vectors
162
162
  });
163
- this.workflows[key] = workflow;
163
+ this.#workflows[key] = workflow;
164
164
  });
165
165
  }
166
166
  this.setLogger({
@@ -168,32 +168,32 @@ This is a warning for now, but will throw an error in the future
168
168
  });
169
169
  }
170
170
  getAgent(name) {
171
- const agent = this.agents?.[name];
171
+ const agent = this.#agents?.[name];
172
172
  if (!agent) {
173
173
  throw new Error(`Agent with name ${String(name)} not found`);
174
174
  }
175
- return this.agents[name];
175
+ return this.#agents[name];
176
176
  }
177
177
  getAgents() {
178
- return this.agents;
178
+ return this.#agents;
179
179
  }
180
180
  getVector(name) {
181
- const vector = this.vectors?.[name];
181
+ const vector = this.#vectors?.[name];
182
182
  if (!vector) {
183
183
  throw new Error(`Vector with name ${String(name)} not found`);
184
184
  }
185
185
  return vector;
186
186
  }
187
187
  getVectors() {
188
- return this.vectors;
188
+ return this.#vectors;
189
189
  }
190
190
  getDeployer() {
191
- return this.deployer;
191
+ return this.#deployer;
192
192
  }
193
193
  getWorkflow(id, {
194
194
  serialized
195
195
  } = {}) {
196
- const workflow = this.workflows?.[id];
196
+ const workflow = this.#workflows?.[id];
197
197
  if (!workflow) {
198
198
  throw new Error(`Workflow with ID ${String(id)} not found`);
199
199
  }
@@ -206,7 +206,7 @@ This is a warning for now, but will throw an error in the future
206
206
  }
207
207
  getWorkflows(props = {}) {
208
208
  if (props.serialized) {
209
- return Object.entries(this.workflows).reduce((acc, [k, v]) => {
209
+ return Object.entries(this.#workflows).reduce((acc, [k, v]) => {
210
210
  return {
211
211
  ...acc,
212
212
  [k]: {
@@ -215,7 +215,7 @@ This is a warning for now, but will throw an error in the future
215
215
  };
216
216
  }, {});
217
217
  }
218
- return this.workflows;
218
+ return this.#workflows;
219
219
  }
220
220
  setStorage(storage) {
221
221
  this.storage = storage;
@@ -223,92 +223,92 @@ This is a warning for now, but will throw an error in the future
223
223
  setLogger({
224
224
  logger
225
225
  }) {
226
- this.logger = logger;
227
- if (this.agents) {
228
- Object.keys(this.agents).forEach(key => {
229
- this.agents?.[key]?.__setLogger(this.logger);
226
+ this.#logger = logger;
227
+ if (this.#agents) {
228
+ Object.keys(this.#agents).forEach(key => {
229
+ this.#agents?.[key]?.__setLogger(this.#logger);
230
230
  });
231
231
  }
232
232
  if (this.memory) {
233
- this.memory.__setLogger(this.logger);
233
+ this.memory.__setLogger(this.#logger);
234
234
  }
235
- if (this.deployer) {
236
- this.deployer.__setLogger(this.logger);
235
+ if (this.#deployer) {
236
+ this.#deployer.__setLogger(this.#logger);
237
237
  }
238
- if (this.tts) {
239
- Object.keys(this.tts).forEach(key => {
240
- this.tts?.[key]?.__setLogger(this.logger);
238
+ if (this.#tts) {
239
+ Object.keys(this.#tts).forEach(key => {
240
+ this.#tts?.[key]?.__setLogger(this.#logger);
241
241
  });
242
242
  }
243
243
  if (this.storage) {
244
- this.storage.__setLogger(this.logger);
244
+ this.storage.__setLogger(this.#logger);
245
245
  }
246
- if (this.vectors) {
247
- Object.keys(this.vectors).forEach(key => {
248
- this.vectors?.[key]?.__setLogger(this.logger);
246
+ if (this.#vectors) {
247
+ Object.keys(this.#vectors).forEach(key => {
248
+ this.#vectors?.[key]?.__setLogger(this.#logger);
249
249
  });
250
250
  }
251
251
  }
252
252
  setTelemetry(telemetry) {
253
- this.telemetry = Telemetry.init(telemetry);
254
- if (this.agents) {
255
- Object.keys(this.agents).forEach(key => {
256
- if (this.telemetry) {
257
- this.agents?.[key]?.__setTelemetry(this.telemetry);
253
+ this.#telemetry = Telemetry.init(telemetry);
254
+ if (this.#agents) {
255
+ Object.keys(this.#agents).forEach(key => {
256
+ if (this.#telemetry) {
257
+ this.#agents?.[key]?.__setTelemetry(this.#telemetry);
258
258
  }
259
259
  });
260
260
  }
261
261
  if (this.memory) {
262
- this.memory = this.telemetry.traceClass(this.memory, {
262
+ this.memory = this.#telemetry.traceClass(this.memory, {
263
263
  excludeMethods: ["__setTelemetry", "__getTelemetry"]
264
264
  });
265
- this.memory.__setTelemetry(this.telemetry);
265
+ this.memory.__setTelemetry(this.#telemetry);
266
266
  }
267
- if (this.deployer) {
268
- this.deployer = this.telemetry.traceClass(this.deployer, {
267
+ if (this.#deployer) {
268
+ this.#deployer = this.#telemetry.traceClass(this.#deployer, {
269
269
  excludeMethods: ["__setTelemetry", "__getTelemetry"]
270
270
  });
271
- this.deployer.__setTelemetry(this.telemetry);
271
+ this.#deployer.__setTelemetry(this.#telemetry);
272
272
  }
273
- if (this.tts) {
273
+ if (this.#tts) {
274
274
  let tts = {};
275
- Object.entries(this.tts).forEach(([key, ttsCl]) => {
276
- if (this.telemetry) {
277
- tts[key] = this.telemetry.traceClass(ttsCl, {
275
+ Object.entries(this.#tts).forEach(([key, ttsCl]) => {
276
+ if (this.#telemetry) {
277
+ tts[key] = this.#telemetry.traceClass(ttsCl, {
278
278
  excludeMethods: ["__setTelemetry", "__getTelemetry"]
279
279
  });
280
- tts[key].__setTelemetry(this.telemetry);
280
+ tts[key].__setTelemetry(this.#telemetry);
281
281
  }
282
282
  });
283
- this.tts = tts;
283
+ this.#tts = tts;
284
284
  }
285
285
  if (this.storage) {
286
- this.storage = this.telemetry.traceClass(this.storage, {
286
+ this.storage = this.#telemetry.traceClass(this.storage, {
287
287
  excludeMethods: ["__setTelemetry", "__getTelemetry"]
288
288
  });
289
- this.storage.__setTelemetry(this.telemetry);
289
+ this.storage.__setTelemetry(this.#telemetry);
290
290
  }
291
- if (this.vectors) {
291
+ if (this.#vectors) {
292
292
  let vectors = {};
293
- Object.entries(this.vectors).forEach(([key, vector]) => {
294
- if (this.telemetry) {
295
- vectors[key] = this.telemetry.traceClass(vector, {
293
+ Object.entries(this.#vectors).forEach(([key, vector]) => {
294
+ if (this.#telemetry) {
295
+ vectors[key] = this.#telemetry.traceClass(vector, {
296
296
  excludeMethods: ["__setTelemetry", "__getTelemetry"]
297
297
  });
298
- vectors[key].__setTelemetry(this.telemetry);
298
+ vectors[key].__setTelemetry(this.#telemetry);
299
299
  }
300
300
  });
301
- this.vectors = vectors;
301
+ this.#vectors = vectors;
302
302
  }
303
303
  }
304
304
  getTTS() {
305
- return this.tts;
305
+ return this.#tts;
306
306
  }
307
307
  getLogger() {
308
- return this.logger;
308
+ return this.#logger;
309
309
  }
310
310
  getTelemetry() {
311
- return this.telemetry;
311
+ return this.#telemetry;
312
312
  }
313
313
  async getLogsByRunId({
314
314
  runId,
@@ -317,7 +317,7 @@ This is a warning for now, but will throw an error in the future
317
317
  if (!transportId) {
318
318
  throw new Error("Transport ID is required");
319
319
  }
320
- return await this.logger.getLogsByRunId({
320
+ return await this.#logger.getLogsByRunId({
321
321
  runId,
322
322
  transportId
323
323
  });
@@ -326,7 +326,7 @@ This is a warning for now, but will throw an error in the future
326
326
  if (!transportId) {
327
327
  throw new Error("Transport ID is required");
328
328
  }
329
- return await this.logger.getLogs(transportId);
329
+ return await this.#logger.getLogs(transportId);
330
330
  }
331
331
  };
332
332
  Mastra = /*@__PURE__*/(_ => {