@mastra/core 0.6.1 → 0.6.2-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/agent/index.cjs +2 -2
  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-BNtyxqTf.d.cts → base-BESiSy3v.d.cts} +6 -6
  6. package/dist/{base-C1_KzNZ3.d.ts → base-BwuLIP_x.d.ts} +6 -6
  7. package/dist/{chunk-MNGT2Y5R.cjs → chunk-2PTWBPQ6.cjs} +2 -2
  8. package/dist/{chunk-E56VUJSG.js → chunk-44N24GPK.js} +100 -85
  9. package/dist/{chunk-5BL23DUS.cjs → chunk-CMSZAZ3I.cjs} +100 -85
  10. package/dist/{chunk-HEF3AUCR.js → chunk-DGCOY6YF.js} +1 -1
  11. package/dist/eval/index.d.cts +1 -1
  12. package/dist/eval/index.d.ts +1 -1
  13. package/dist/index.cjs +6 -6
  14. package/dist/index.d.cts +2 -2
  15. package/dist/index.d.ts +2 -2
  16. package/dist/index.js +2 -2
  17. package/dist/integration/index.d.cts +1 -1
  18. package/dist/integration/index.d.ts +1 -1
  19. package/dist/llm/index.d.cts +1 -1
  20. package/dist/llm/index.d.ts +1 -1
  21. package/dist/mastra/index.d.cts +1 -1
  22. package/dist/mastra/index.d.ts +1 -1
  23. package/dist/memory/index.d.cts +1 -1
  24. package/dist/memory/index.d.ts +1 -1
  25. package/dist/relevance/index.cjs +4 -4
  26. package/dist/relevance/index.d.cts +1 -1
  27. package/dist/relevance/index.d.ts +1 -1
  28. package/dist/relevance/index.js +1 -1
  29. package/dist/storage/index.d.cts +1 -1
  30. package/dist/storage/index.d.ts +1 -1
  31. package/dist/storage/libsql/index.d.cts +1 -1
  32. package/dist/storage/libsql/index.d.ts +1 -1
  33. package/dist/telemetry/index.d.cts +1 -1
  34. package/dist/telemetry/index.d.ts +1 -1
  35. package/dist/tools/index.d.cts +5 -5
  36. package/dist/tools/index.d.ts +5 -5
  37. package/dist/utils.d.cts +2 -2
  38. package/dist/utils.d.ts +2 -2
  39. package/dist/voice/index.d.cts +1 -1
  40. package/dist/voice/index.d.ts +1 -1
  41. package/dist/workflows/index.d.cts +2 -2
  42. package/dist/workflows/index.d.ts +2 -2
  43. package/package.json +1 -1
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var chunk5BL23DUS_cjs = require('../chunk-5BL23DUS.cjs');
3
+ var chunkCMSZAZ3I_cjs = require('../chunk-CMSZAZ3I.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "Agent", {
8
8
  enumerable: true,
9
- get: function () { return chunk5BL23DUS_cjs.Agent; }
9
+ get: function () { return chunkCMSZAZ3I_cjs.Agent; }
10
10
  });
@@ -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, l as AgentConfig, aD as AgentGenerateOptions, aE as AgentStreamOptions, aw as MastraLanguageModel, a as ToolsInput, aC as ToolsetsInput } from '../base-BNtyxqTf.cjs';
4
+ export { A as Agent, l as AgentConfig, aD as AgentGenerateOptions, aE as AgentStreamOptions, aw as MastraLanguageModel, a as ToolsInput, aC as ToolsetsInput } from '../base-BESiSy3v.cjs';
5
5
  import '../base-DboIg_Cd.cjs';
6
6
  import '../types-CwTG2XyQ.cjs';
7
7
  import 'sift';
@@ -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, l as AgentConfig, aD as AgentGenerateOptions, aE as AgentStreamOptions, aw as MastraLanguageModel, a as ToolsInput, aC as ToolsetsInput } from '../base-C1_KzNZ3.js';
4
+ export { A as Agent, l as AgentConfig, aD as AgentGenerateOptions, aE as AgentStreamOptions, aw as MastraLanguageModel, a as ToolsInput, aC as ToolsetsInput } from '../base-BwuLIP_x.js';
5
5
  import '../base-BZViaFTt.js';
6
6
  import '../types-CwTG2XyQ.js';
7
7
  import 'sift';
@@ -1 +1 @@
1
- export { Agent } from '../chunk-E56VUJSG.js';
1
+ export { Agent } from '../chunk-44N24GPK.js';
@@ -31,9 +31,9 @@ type CoreTool = {
31
31
  interface ToolExecutionContext<TSchemaIn extends z.ZodSchema | undefined = undefined> extends IExecutionContext<TSchemaIn> {
32
32
  mastra?: MastraUnion;
33
33
  }
34
- interface ToolAction<TSchemaIn extends z.ZodSchema | undefined = undefined, TSchemaOut extends z.ZodSchema | undefined = undefined, TContext extends ToolExecutionContext<TSchemaIn> = ToolExecutionContext<TSchemaIn>, TOptions extends unknown = unknown> extends IAction<string, TSchemaIn, TSchemaOut, TContext, TOptions> {
34
+ 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> {
35
35
  description: string;
36
- execute?: (context: TContext, options?: TOptions) => Promise<TSchemaOut extends z.ZodSchema ? z.infer<TSchemaOut> : unknown>;
36
+ execute?: (context: TContext, options?: ToolExecutionOptions) => Promise<TSchemaOut extends z.ZodSchema ? z.infer<TSchemaOut> : unknown>;
37
37
  mastra?: Mastra;
38
38
  }
39
39
 
@@ -1487,9 +1487,9 @@ declare class Agent<TTools extends ToolsInput = ToolsInput, TMetrics extends Rec
1487
1487
  }): Promise<string>;
1488
1488
  getMostRecentUserMessage(messages: Array<CoreMessage$1>): CoreUserMessage$1 | undefined;
1489
1489
  genTitle(userMessage: CoreUserMessage$1 | undefined): Promise<string>;
1490
- saveMemory({ threadId, memoryConfig, resourceId, userMessages, runId, }: {
1490
+ fetchMemory({ threadId, memoryConfig, resourceId, userMessages, runId, }: {
1491
1491
  resourceId: string;
1492
- threadId?: string;
1492
+ threadId: string;
1493
1493
  memoryConfig?: MemoryConfig;
1494
1494
  userMessages: CoreMessage$1[];
1495
1495
  time?: Date;
@@ -1497,7 +1497,7 @@ declare class Agent<TTools extends ToolsInput = ToolsInput, TMetrics extends Rec
1497
1497
  runId?: string;
1498
1498
  }): Promise<{
1499
1499
  threadId: string;
1500
- messages: NonNullable<CoreMessage$1 | null>[];
1500
+ messages: CoreMessage$1[];
1501
1501
  }>;
1502
1502
  saveResponse({ result, threadId, resourceId, runId, memoryConfig, }: {
1503
1503
  runId: string;
@@ -1515,7 +1515,7 @@ declare class Agent<TTools extends ToolsInput = ToolsInput, TMetrics extends Rec
1515
1515
  }): Record<string, CoreTool>;
1516
1516
  preExecute({ resourceId, runId, threadId, memoryConfig, messages, }: {
1517
1517
  runId?: string;
1518
- threadId?: string;
1518
+ threadId: string;
1519
1519
  memoryConfig?: MemoryConfig;
1520
1520
  messages: CoreMessage$1[];
1521
1521
  resourceId: string;
@@ -31,9 +31,9 @@ type CoreTool = {
31
31
  interface ToolExecutionContext<TSchemaIn extends z.ZodSchema | undefined = undefined> extends IExecutionContext<TSchemaIn> {
32
32
  mastra?: MastraUnion;
33
33
  }
34
- interface ToolAction<TSchemaIn extends z.ZodSchema | undefined = undefined, TSchemaOut extends z.ZodSchema | undefined = undefined, TContext extends ToolExecutionContext<TSchemaIn> = ToolExecutionContext<TSchemaIn>, TOptions extends unknown = unknown> extends IAction<string, TSchemaIn, TSchemaOut, TContext, TOptions> {
34
+ 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> {
35
35
  description: string;
36
- execute?: (context: TContext, options?: TOptions) => Promise<TSchemaOut extends z.ZodSchema ? z.infer<TSchemaOut> : unknown>;
36
+ execute?: (context: TContext, options?: ToolExecutionOptions) => Promise<TSchemaOut extends z.ZodSchema ? z.infer<TSchemaOut> : unknown>;
37
37
  mastra?: Mastra;
38
38
  }
39
39
 
@@ -1487,9 +1487,9 @@ declare class Agent<TTools extends ToolsInput = ToolsInput, TMetrics extends Rec
1487
1487
  }): Promise<string>;
1488
1488
  getMostRecentUserMessage(messages: Array<CoreMessage$1>): CoreUserMessage$1 | undefined;
1489
1489
  genTitle(userMessage: CoreUserMessage$1 | undefined): Promise<string>;
1490
- saveMemory({ threadId, memoryConfig, resourceId, userMessages, runId, }: {
1490
+ fetchMemory({ threadId, memoryConfig, resourceId, userMessages, runId, }: {
1491
1491
  resourceId: string;
1492
- threadId?: string;
1492
+ threadId: string;
1493
1493
  memoryConfig?: MemoryConfig;
1494
1494
  userMessages: CoreMessage$1[];
1495
1495
  time?: Date;
@@ -1497,7 +1497,7 @@ declare class Agent<TTools extends ToolsInput = ToolsInput, TMetrics extends Rec
1497
1497
  runId?: string;
1498
1498
  }): Promise<{
1499
1499
  threadId: string;
1500
- messages: NonNullable<CoreMessage$1 | null>[];
1500
+ messages: CoreMessage$1[];
1501
1501
  }>;
1502
1502
  saveResponse({ result, threadId, resourceId, runId, memoryConfig, }: {
1503
1503
  runId: string;
@@ -1515,7 +1515,7 @@ declare class Agent<TTools extends ToolsInput = ToolsInput, TMetrics extends Rec
1515
1515
  }): Record<string, CoreTool>;
1516
1516
  preExecute({ resourceId, runId, threadId, memoryConfig, messages, }: {
1517
1517
  runId?: string;
1518
- threadId?: string;
1518
+ threadId: string;
1519
1519
  memoryConfig?: MemoryConfig;
1520
1520
  messages: CoreMessage$1[];
1521
1521
  resourceId: string;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunk5BL23DUS_cjs = require('./chunk-5BL23DUS.cjs');
3
+ var chunkCMSZAZ3I_cjs = require('./chunk-CMSZAZ3I.cjs');
4
4
  var cohereAi = require('cohere-ai');
5
5
 
6
6
  var CohereRelevanceScorer = class {
@@ -38,7 +38,7 @@ Relevance score (0-1):`;
38
38
  var MastraAgentRelevanceScorer = class {
39
39
  agent;
40
40
  constructor(name, model) {
41
- this.agent = new chunk5BL23DUS_cjs.Agent({
41
+ this.agent = new chunkCMSZAZ3I_cjs.Agent({
42
42
  name: `Relevance Scorer ${name}`,
43
43
  instructions: `You are a specialized agent for evaluating the relevance of text to queries.
44
44
  Your task is to rate how well a text passage answers a given query.
@@ -740,96 +740,62 @@ var Agent = class extends (_a = MastraBase) {
740
740
  }
741
741
  return title;
742
742
  }
743
- async saveMemory({
743
+ async fetchMemory({
744
744
  threadId,
745
745
  memoryConfig,
746
746
  resourceId,
747
747
  userMessages,
748
748
  runId
749
749
  }) {
750
- const userMessage = this.getMostRecentUserMessage(userMessages);
751
750
  const memory = this.getMemory();
752
751
  if (memory) {
753
- const config = memory.getMergedThreadConfig(memoryConfig);
754
- let thread;
755
- if (!threadId) {
756
- this.logger.debug(`No threadId, creating new thread for agent ${this.name}`, {
757
- runId: runId || this.name
758
- });
759
- const title = config?.threads?.generateTitle ? await this.genTitle(userMessage) : void 0;
760
- thread = await memory.createThread({
761
- threadId,
762
- resourceId,
763
- memoryConfig,
764
- title
765
- });
766
- } else {
767
- thread = await memory.getThreadById({
768
- threadId
769
- });
770
- if (!thread) {
771
- this.logger.debug(`Thread with id ${threadId} not found, creating new thread for agent ${this.name}`, {
772
- runId: runId || this.name
773
- });
774
- const title = config?.threads?.generateTitle ? await this.genTitle(userMessage) : void 0;
775
- thread = await memory.createThread({
776
- threadId,
777
- resourceId,
778
- title,
779
- memoryConfig
780
- });
781
- }
752
+ const thread = await memory.getThreadById({
753
+ threadId
754
+ });
755
+ if (!thread) {
756
+ return {
757
+ threadId: threadId || "",
758
+ messages: userMessages
759
+ };
782
760
  }
761
+ const userMessage = this.getMostRecentUserMessage(userMessages);
783
762
  const newMessages = userMessage ? [userMessage] : userMessages;
784
- if (thread) {
785
- const messages = newMessages.map(u => {
786
- return {
787
- id: this.getMemory()?.generateId(),
788
- createdAt: /* @__PURE__ */new Date(),
789
- threadId: thread.id,
790
- ...u,
791
- content: u.content,
792
- role: u.role,
793
- type: "text"
794
- };
795
- });
796
- const memoryMessages = threadId && memory ? (await memory.rememberMessages({
797
- threadId,
798
- resourceId,
799
- config: memoryConfig,
800
- vectorMessageSearch: messages.slice(-1).map(m => {
801
- if (typeof m === `string`) {
802
- return m;
803
- }
804
- return m?.content || ``;
805
- }).join(`
806
- `)
807
- })).messages : [];
808
- if (memory) {
809
- await memory.saveMessages({
810
- messages,
811
- memoryConfig
812
- });
813
- }
814
- this.logger.debug("Saved messages to memory", {
815
- threadId: thread.id,
816
- runId
817
- });
818
- const memorySystemMessage = memory && threadId ? await memory.getSystemMessage({
819
- threadId,
820
- memoryConfig
821
- }) : null;
763
+ const messages = newMessages.map(u => {
822
764
  return {
823
- threadId: thread.id,
824
- messages: [memorySystemMessage ? {
825
- role: "system",
826
- content: memorySystemMessage
827
- } : null, ...this.sanitizeResponseMessages(memoryMessages), ...newMessages].filter(message => Boolean(message))
765
+ id: this.getMemory()?.generateId(),
766
+ createdAt: /* @__PURE__ */new Date(),
767
+ threadId,
768
+ ...u,
769
+ content: u.content,
770
+ role: u.role,
771
+ type: "text"
828
772
  };
829
- }
773
+ });
774
+ const [memoryMessages, memorySystemMessage] = threadId && memory ? await Promise.all([memory.rememberMessages({
775
+ threadId,
776
+ resourceId,
777
+ config: memoryConfig,
778
+ vectorMessageSearch: messages.slice(-1).map(m => {
779
+ if (typeof m === `string`) {
780
+ return m;
781
+ }
782
+ return m?.content || ``;
783
+ }).join(`
784
+ `)
785
+ }).then(r => r.messages), memory.getSystemMessage({
786
+ threadId,
787
+ memoryConfig
788
+ })]) : [[], null];
789
+ this.logger.debug("Saved messages to memory", {
790
+ threadId,
791
+ runId
792
+ });
830
793
  return {
831
- threadId: thread?.id || threadId || "",
832
- messages: userMessages
794
+ threadId: thread.id,
795
+ messages: [memorySystemMessage ? {
796
+ role: "system",
797
+ content: memorySystemMessage
798
+ } : null, ...this.sanitizeResponseMessages(memoryMessages), ...newMessages].filter(message => Boolean(message))
833
799
  };
834
800
  }
835
801
  return {
@@ -1081,7 +1047,7 @@ var Agent = class extends (_a = MastraBase) {
1081
1047
  this.logger.debug(`Saving user messages in memory for agent ${this.name}`, {
1082
1048
  runId
1083
1049
  });
1084
- const saveMessageResponse = await this.saveMemory({
1050
+ const saveMessageResponse = await this.fetchMemory({
1085
1051
  threadId,
1086
1052
  resourceId,
1087
1053
  userMessages: messages,
@@ -1128,6 +1094,17 @@ var Agent = class extends (_a = MastraBase) {
1128
1094
  threadId: threadIdToUse,
1129
1095
  memoryStore: this.getMemory()?.constructor.name
1130
1096
  });
1097
+ let thread = threadIdToUse ? await memory.getThreadById({
1098
+ threadId: threadIdToUse
1099
+ }) : void 0;
1100
+ if (!thread) {
1101
+ thread = await memory.createThread({
1102
+ threadId: threadIdToUse,
1103
+ resourceId,
1104
+ memoryConfig
1105
+ });
1106
+ }
1107
+ threadIdToUse = thread.id;
1131
1108
  const preExecuteResult = await this.preExecute({
1132
1109
  resourceId,
1133
1110
  runId,
@@ -1196,15 +1173,53 @@ var Agent = class extends (_a = MastraBase) {
1196
1173
  result: resToLog,
1197
1174
  threadId: threadId2
1198
1175
  });
1199
- if (this.getMemory() && resourceId) {
1176
+ const memory = this.getMemory();
1177
+ const thread = await memory?.getThreadById({
1178
+ threadId: threadId2
1179
+ });
1180
+ if (memory && resourceId && thread) {
1200
1181
  try {
1201
- await this.saveResponse({
1202
- result,
1203
- threadId: threadId2,
1204
- resourceId,
1205
- memoryConfig: memoryConfig2,
1206
- runId: runId2
1182
+ const userMessage = this.getMostRecentUserMessage(messages);
1183
+ const newMessages = userMessage ? [userMessage] : messages;
1184
+ const threadMessages = newMessages.map(u => {
1185
+ return {
1186
+ id: this.getMemory()?.generateId(),
1187
+ createdAt: /* @__PURE__ */new Date(),
1188
+ threadId: thread.id,
1189
+ ...u,
1190
+ content: u.content,
1191
+ role: u.role,
1192
+ type: "text"
1193
+ };
1207
1194
  });
1195
+ await Promise.all([(async () => {
1196
+ await memory.saveMessages({
1197
+ messages: threadMessages,
1198
+ memoryConfig: memoryConfig2
1199
+ });
1200
+ await this.saveResponse({
1201
+ result,
1202
+ threadId: threadId2,
1203
+ resourceId,
1204
+ memoryConfig: memoryConfig2,
1205
+ runId: runId2
1206
+ });
1207
+ })(), (async () => {
1208
+ if (!thread.title?.startsWith("New Thread")) {
1209
+ return;
1210
+ }
1211
+ const config = memory.getMergedThreadConfig(memoryConfig2);
1212
+ const title = config?.threads?.generateTitle ? await this.genTitle(userMessage) : void 0;
1213
+ if (!title) {
1214
+ return;
1215
+ }
1216
+ return memory.createThread({
1217
+ threadId: thread.id,
1218
+ resourceId,
1219
+ memoryConfig: memoryConfig2,
1220
+ title
1221
+ });
1222
+ })()]);
1208
1223
  } catch (e) {
1209
1224
  this.logger.error("Error saving response", {
1210
1225
  error: e,
@@ -742,96 +742,62 @@ exports.Agent = class Agent extends (_a = chunkIIWRJFLQ_cjs.MastraBase) {
742
742
  }
743
743
  return title;
744
744
  }
745
- async saveMemory({
745
+ async fetchMemory({
746
746
  threadId,
747
747
  memoryConfig,
748
748
  resourceId,
749
749
  userMessages,
750
750
  runId
751
751
  }) {
752
- const userMessage = this.getMostRecentUserMessage(userMessages);
753
752
  const memory = this.getMemory();
754
753
  if (memory) {
755
- const config = memory.getMergedThreadConfig(memoryConfig);
756
- let thread;
757
- if (!threadId) {
758
- this.logger.debug(`No threadId, creating new thread for agent ${this.name}`, {
759
- runId: runId || this.name
760
- });
761
- const title = config?.threads?.generateTitle ? await this.genTitle(userMessage) : void 0;
762
- thread = await memory.createThread({
763
- threadId,
764
- resourceId,
765
- memoryConfig,
766
- title
767
- });
768
- } else {
769
- thread = await memory.getThreadById({
770
- threadId
771
- });
772
- if (!thread) {
773
- this.logger.debug(`Thread with id ${threadId} not found, creating new thread for agent ${this.name}`, {
774
- runId: runId || this.name
775
- });
776
- const title = config?.threads?.generateTitle ? await this.genTitle(userMessage) : void 0;
777
- thread = await memory.createThread({
778
- threadId,
779
- resourceId,
780
- title,
781
- memoryConfig
782
- });
783
- }
754
+ const thread = await memory.getThreadById({
755
+ threadId
756
+ });
757
+ if (!thread) {
758
+ return {
759
+ threadId: threadId || "",
760
+ messages: userMessages
761
+ };
784
762
  }
763
+ const userMessage = this.getMostRecentUserMessage(userMessages);
785
764
  const newMessages = userMessage ? [userMessage] : userMessages;
786
- if (thread) {
787
- const messages = newMessages.map(u => {
788
- return {
789
- id: this.getMemory()?.generateId(),
790
- createdAt: /* @__PURE__ */new Date(),
791
- threadId: thread.id,
792
- ...u,
793
- content: u.content,
794
- role: u.role,
795
- type: "text"
796
- };
797
- });
798
- const memoryMessages = threadId && memory ? (await memory.rememberMessages({
799
- threadId,
800
- resourceId,
801
- config: memoryConfig,
802
- vectorMessageSearch: messages.slice(-1).map(m => {
803
- if (typeof m === `string`) {
804
- return m;
805
- }
806
- return m?.content || ``;
807
- }).join(`
808
- `)
809
- })).messages : [];
810
- if (memory) {
811
- await memory.saveMessages({
812
- messages,
813
- memoryConfig
814
- });
815
- }
816
- this.logger.debug("Saved messages to memory", {
817
- threadId: thread.id,
818
- runId
819
- });
820
- const memorySystemMessage = memory && threadId ? await memory.getSystemMessage({
821
- threadId,
822
- memoryConfig
823
- }) : null;
765
+ const messages = newMessages.map(u => {
824
766
  return {
825
- threadId: thread.id,
826
- messages: [memorySystemMessage ? {
827
- role: "system",
828
- content: memorySystemMessage
829
- } : null, ...this.sanitizeResponseMessages(memoryMessages), ...newMessages].filter(message => Boolean(message))
767
+ id: this.getMemory()?.generateId(),
768
+ createdAt: /* @__PURE__ */new Date(),
769
+ threadId,
770
+ ...u,
771
+ content: u.content,
772
+ role: u.role,
773
+ type: "text"
830
774
  };
831
- }
775
+ });
776
+ const [memoryMessages, memorySystemMessage] = threadId && memory ? await Promise.all([memory.rememberMessages({
777
+ threadId,
778
+ resourceId,
779
+ config: memoryConfig,
780
+ vectorMessageSearch: messages.slice(-1).map(m => {
781
+ if (typeof m === `string`) {
782
+ return m;
783
+ }
784
+ return m?.content || ``;
785
+ }).join(`
786
+ `)
787
+ }).then(r => r.messages), memory.getSystemMessage({
788
+ threadId,
789
+ memoryConfig
790
+ })]) : [[], null];
791
+ this.logger.debug("Saved messages to memory", {
792
+ threadId,
793
+ runId
794
+ });
832
795
  return {
833
- threadId: thread?.id || threadId || "",
834
- messages: userMessages
796
+ threadId: thread.id,
797
+ messages: [memorySystemMessage ? {
798
+ role: "system",
799
+ content: memorySystemMessage
800
+ } : null, ...this.sanitizeResponseMessages(memoryMessages), ...newMessages].filter(message => Boolean(message))
835
801
  };
836
802
  }
837
803
  return {
@@ -1083,7 +1049,7 @@ exports.Agent = class Agent extends (_a = chunkIIWRJFLQ_cjs.MastraBase) {
1083
1049
  this.logger.debug(`Saving user messages in memory for agent ${this.name}`, {
1084
1050
  runId
1085
1051
  });
1086
- const saveMessageResponse = await this.saveMemory({
1052
+ const saveMessageResponse = await this.fetchMemory({
1087
1053
  threadId,
1088
1054
  resourceId,
1089
1055
  userMessages: messages,
@@ -1130,6 +1096,17 @@ exports.Agent = class Agent extends (_a = chunkIIWRJFLQ_cjs.MastraBase) {
1130
1096
  threadId: threadIdToUse,
1131
1097
  memoryStore: this.getMemory()?.constructor.name
1132
1098
  });
1099
+ let thread = threadIdToUse ? await memory.getThreadById({
1100
+ threadId: threadIdToUse
1101
+ }) : void 0;
1102
+ if (!thread) {
1103
+ thread = await memory.createThread({
1104
+ threadId: threadIdToUse,
1105
+ resourceId,
1106
+ memoryConfig
1107
+ });
1108
+ }
1109
+ threadIdToUse = thread.id;
1133
1110
  const preExecuteResult = await this.preExecute({
1134
1111
  resourceId,
1135
1112
  runId,
@@ -1198,15 +1175,53 @@ exports.Agent = class Agent extends (_a = chunkIIWRJFLQ_cjs.MastraBase) {
1198
1175
  result: resToLog,
1199
1176
  threadId: threadId2
1200
1177
  });
1201
- if (this.getMemory() && resourceId) {
1178
+ const memory = this.getMemory();
1179
+ const thread = await memory?.getThreadById({
1180
+ threadId: threadId2
1181
+ });
1182
+ if (memory && resourceId && thread) {
1202
1183
  try {
1203
- await this.saveResponse({
1204
- result,
1205
- threadId: threadId2,
1206
- resourceId,
1207
- memoryConfig: memoryConfig2,
1208
- runId: runId2
1184
+ const userMessage = this.getMostRecentUserMessage(messages);
1185
+ const newMessages = userMessage ? [userMessage] : messages;
1186
+ const threadMessages = newMessages.map(u => {
1187
+ return {
1188
+ id: this.getMemory()?.generateId(),
1189
+ createdAt: /* @__PURE__ */new Date(),
1190
+ threadId: thread.id,
1191
+ ...u,
1192
+ content: u.content,
1193
+ role: u.role,
1194
+ type: "text"
1195
+ };
1209
1196
  });
1197
+ await Promise.all([(async () => {
1198
+ await memory.saveMessages({
1199
+ messages: threadMessages,
1200
+ memoryConfig: memoryConfig2
1201
+ });
1202
+ await this.saveResponse({
1203
+ result,
1204
+ threadId: threadId2,
1205
+ resourceId,
1206
+ memoryConfig: memoryConfig2,
1207
+ runId: runId2
1208
+ });
1209
+ })(), (async () => {
1210
+ if (!thread.title?.startsWith("New Thread")) {
1211
+ return;
1212
+ }
1213
+ const config = memory.getMergedThreadConfig(memoryConfig2);
1214
+ const title = config?.threads?.generateTitle ? await this.genTitle(userMessage) : void 0;
1215
+ if (!title) {
1216
+ return;
1217
+ }
1218
+ return memory.createThread({
1219
+ threadId: thread.id,
1220
+ resourceId,
1221
+ memoryConfig: memoryConfig2,
1222
+ title
1223
+ });
1224
+ })()]);
1210
1225
  } catch (e) {
1211
1226
  this.logger.error("Error saving response", {
1212
1227
  error: e,
@@ -1,4 +1,4 @@
1
- import { Agent } from './chunk-E56VUJSG.js';
1
+ import { Agent } from './chunk-44N24GPK.js';
2
2
  import { CohereClient } from 'cohere-ai';
3
3
 
4
4
  var CohereRelevanceScorer = class {
@@ -1,5 +1,5 @@
1
1
  import { M as Metric, T as TestInfo, a as MetricResult } from '../types-CwTG2XyQ.cjs';
2
- import { A as Agent } from '../base-BNtyxqTf.cjs';
2
+ import { A as Agent } from '../base-BESiSy3v.cjs';
3
3
  import 'ai';
4
4
  import '../base-DboIg_Cd.cjs';
5
5
  import '@opentelemetry/api';
@@ -1,5 +1,5 @@
1
1
  import { M as Metric, T as TestInfo, a as MetricResult } from '../types-CwTG2XyQ.js';
2
- import { A as Agent } from '../base-C1_KzNZ3.js';
2
+ import { A as Agent } from '../base-BwuLIP_x.js';
3
3
  import 'ai';
4
4
  import '../base-BZViaFTt.js';
5
5
  import '@opentelemetry/api';
package/dist/index.cjs CHANGED
@@ -6,9 +6,9 @@ var chunkXLSROQ26_cjs = require('./chunk-XLSROQ26.cjs');
6
6
  var chunkXLZRGA3F_cjs = require('./chunk-XLZRGA3F.cjs');
7
7
  var chunkBPL5FORD_cjs = require('./chunk-BPL5FORD.cjs');
8
8
  var chunkENT7U27Y_cjs = require('./chunk-ENT7U27Y.cjs');
9
- var chunkMNGT2Y5R_cjs = require('./chunk-MNGT2Y5R.cjs');
9
+ var chunk2PTWBPQ6_cjs = require('./chunk-2PTWBPQ6.cjs');
10
10
  var chunkFL3GQXQ2_cjs = require('./chunk-FL3GQXQ2.cjs');
11
- var chunk5BL23DUS_cjs = require('./chunk-5BL23DUS.cjs');
11
+ var chunkCMSZAZ3I_cjs = require('./chunk-CMSZAZ3I.cjs');
12
12
  var chunkXB2TJ7LX_cjs = require('./chunk-XB2TJ7LX.cjs');
13
13
  var chunkWSMI66XC_cjs = require('./chunk-WSMI66XC.cjs');
14
14
  var chunk2W2GYEYQ_cjs = require('./chunk-2W2GYEYQ.cjs');
@@ -19,7 +19,7 @@ var chunkV5ORZPFW_cjs = require('./chunk-V5ORZPFW.cjs');
19
19
  var chunkST5RMVLG_cjs = require('./chunk-ST5RMVLG.cjs');
20
20
 
21
21
  // src/agent/index.warning.ts
22
- var Agent2 = class extends chunk5BL23DUS_cjs.Agent {
22
+ var Agent2 = class extends chunkCMSZAZ3I_cjs.Agent {
23
23
  constructor(config) {
24
24
  super(config);
25
25
  this.logger.warn('Please import "Agent from "@mastra/core/agent" instead of "@mastra/core"');
@@ -180,15 +180,15 @@ Object.defineProperty(exports, "Mastra", {
180
180
  });
181
181
  Object.defineProperty(exports, "CohereRelevanceScorer", {
182
182
  enumerable: true,
183
- get: function () { return chunkMNGT2Y5R_cjs.CohereRelevanceScorer; }
183
+ get: function () { return chunk2PTWBPQ6_cjs.CohereRelevanceScorer; }
184
184
  });
185
185
  Object.defineProperty(exports, "MastraAgentRelevanceScorer", {
186
186
  enumerable: true,
187
- get: function () { return chunkMNGT2Y5R_cjs.MastraAgentRelevanceScorer; }
187
+ get: function () { return chunk2PTWBPQ6_cjs.MastraAgentRelevanceScorer; }
188
188
  });
189
189
  Object.defineProperty(exports, "createSimilarityPrompt", {
190
190
  enumerable: true,
191
- get: function () { return chunkMNGT2Y5R_cjs.createSimilarityPrompt; }
191
+ get: function () { return chunk2PTWBPQ6_cjs.createSimilarityPrompt; }
192
192
  });
193
193
  Object.defineProperty(exports, "InstrumentClass", {
194
194
  enumerable: true,
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { M as Metric } from './types-CwTG2XyQ.cjs';
2
2
  export { a as MetricResult, T as TestInfo } from './types-CwTG2XyQ.cjs';
3
- import { T as ToolAction, A as Agent$1, l as AgentConfig, f as MastraStorage$1, c as MastraMemory$1, m as ToolExecutionContext, S as Step, W as Workflow$1, n as WorkflowOptions } from './base-BNtyxqTf.cjs';
4
- export { a4 as ActionContext, a3 as BaseCondition, B as BaseStructuredOutputType, R as Config, r as CoreAssistantMessage, p as CoreMessage, q as CoreSystemMessage, C as CoreTool, t as CoreToolMessage, s as CoreUserMessage, I as DefaultLLMStreamObjectOptions, H as DefaultLLMStreamOptions, F as DefaultLLMTextObjectOptions, D as DefaultLLMTextOptions, ah as DependencyCheckOutput, v as EmbedManyResult, u as EmbedResult, E as EvalRow, ao as ExtractSchemaFromStep, ar as ExtractSchemaType, ap as ExtractStepResult, G as GenerateReturn, P as LLMInnerStreamOptions, Q as LLMStreamObjectOptions, N as LLMStreamOptions, K as LLMTextObjectOptions, J as LLMTextOptions, L as LanguageModel, M as Mastra, X as MemoryConfig, U as MessageResponse, j as MessageType, O as OutputType, as as PathsToStringProps, ae as ResolverFunctionInput, af as ResolverFunctionOutput, a1 as RetryConfig, Y as SharedMemoryConfig, Z as StepAction, a7 as StepCondition, a8 as StepConfig, a6 as StepDef, d as StepExecutionContext, a0 as StepGraph, an as StepId, aq as StepInputType, $ as StepNode, ai as StepResolverOutput, a9 as StepResult, _ as StepVariableType, aa as StepsRecord, h as StorageColumn, k as StorageGetMessagesArg, i as StorageThreadType, z as StreamReturn, y as StructuredOutput, x as StructuredOutputArrayItem, w as StructuredOutputType, ag as SubscriberFunctionOutput, a2 as VariableReference, V as VercelTool, a5 as WhenConditionReturnValue, ak as WorkflowActionParams, al as WorkflowActions, aj as WorkflowActors, e as WorkflowContext, ad as WorkflowEvent, ac as WorkflowLogMessage, au as WorkflowResumeResult, o as WorkflowRow, ab as WorkflowRunResult, at as WorkflowRunState, am as WorkflowState, av as createStep } from './base-BNtyxqTf.cjs';
3
+ import { T as ToolAction, A as Agent$1, l as AgentConfig, f as MastraStorage$1, c as MastraMemory$1, m as ToolExecutionContext, S as Step, W as Workflow$1, n as WorkflowOptions } from './base-BESiSy3v.cjs';
4
+ export { a4 as ActionContext, a3 as BaseCondition, B as BaseStructuredOutputType, R as Config, r as CoreAssistantMessage, p as CoreMessage, q as CoreSystemMessage, C as CoreTool, t as CoreToolMessage, s as CoreUserMessage, I as DefaultLLMStreamObjectOptions, H as DefaultLLMStreamOptions, F as DefaultLLMTextObjectOptions, D as DefaultLLMTextOptions, ah as DependencyCheckOutput, v as EmbedManyResult, u as EmbedResult, E as EvalRow, ao as ExtractSchemaFromStep, ar as ExtractSchemaType, ap as ExtractStepResult, G as GenerateReturn, P as LLMInnerStreamOptions, Q as LLMStreamObjectOptions, N as LLMStreamOptions, K as LLMTextObjectOptions, J as LLMTextOptions, L as LanguageModel, M as Mastra, X as MemoryConfig, U as MessageResponse, j as MessageType, O as OutputType, as as PathsToStringProps, ae as ResolverFunctionInput, af as ResolverFunctionOutput, a1 as RetryConfig, Y as SharedMemoryConfig, Z as StepAction, a7 as StepCondition, a8 as StepConfig, a6 as StepDef, d as StepExecutionContext, a0 as StepGraph, an as StepId, aq as StepInputType, $ as StepNode, ai as StepResolverOutput, a9 as StepResult, _ as StepVariableType, aa as StepsRecord, h as StorageColumn, k as StorageGetMessagesArg, i as StorageThreadType, z as StreamReturn, y as StructuredOutput, x as StructuredOutputArrayItem, w as StructuredOutputType, ag as SubscriberFunctionOutput, a2 as VariableReference, V as VercelTool, a5 as WhenConditionReturnValue, ak as WorkflowActionParams, al as WorkflowActions, aj as WorkflowActors, e as WorkflowContext, ad as WorkflowEvent, ac as WorkflowLogMessage, au as WorkflowResumeResult, o as WorkflowRow, ab as WorkflowRunResult, at as WorkflowRunState, am as WorkflowState, av as createStep } from './base-BESiSy3v.cjs';
5
5
  import { M as MastraBase$1 } from './base-DboIg_Cd.cjs';
6
6
  export { O as OtelConfig, S as SamplingStrategy, T as Telemetry } from './base-DboIg_Cd.cjs';
7
7
  import { R as RegisteredLogger, a as LogLevel, T as TransportMap, L as Logger } from './index-mKY1XrpK.cjs';
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { M as Metric } from './types-CwTG2XyQ.js';
2
2
  export { a as MetricResult, T as TestInfo } from './types-CwTG2XyQ.js';
3
- import { T as ToolAction, A as Agent$1, l as AgentConfig, f as MastraStorage$1, c as MastraMemory$1, m as ToolExecutionContext, S as Step, W as Workflow$1, n as WorkflowOptions } from './base-C1_KzNZ3.js';
4
- export { a4 as ActionContext, a3 as BaseCondition, B as BaseStructuredOutputType, R as Config, r as CoreAssistantMessage, p as CoreMessage, q as CoreSystemMessage, C as CoreTool, t as CoreToolMessage, s as CoreUserMessage, I as DefaultLLMStreamObjectOptions, H as DefaultLLMStreamOptions, F as DefaultLLMTextObjectOptions, D as DefaultLLMTextOptions, ah as DependencyCheckOutput, v as EmbedManyResult, u as EmbedResult, E as EvalRow, ao as ExtractSchemaFromStep, ar as ExtractSchemaType, ap as ExtractStepResult, G as GenerateReturn, P as LLMInnerStreamOptions, Q as LLMStreamObjectOptions, N as LLMStreamOptions, K as LLMTextObjectOptions, J as LLMTextOptions, L as LanguageModel, M as Mastra, X as MemoryConfig, U as MessageResponse, j as MessageType, O as OutputType, as as PathsToStringProps, ae as ResolverFunctionInput, af as ResolverFunctionOutput, a1 as RetryConfig, Y as SharedMemoryConfig, Z as StepAction, a7 as StepCondition, a8 as StepConfig, a6 as StepDef, d as StepExecutionContext, a0 as StepGraph, an as StepId, aq as StepInputType, $ as StepNode, ai as StepResolverOutput, a9 as StepResult, _ as StepVariableType, aa as StepsRecord, h as StorageColumn, k as StorageGetMessagesArg, i as StorageThreadType, z as StreamReturn, y as StructuredOutput, x as StructuredOutputArrayItem, w as StructuredOutputType, ag as SubscriberFunctionOutput, a2 as VariableReference, V as VercelTool, a5 as WhenConditionReturnValue, ak as WorkflowActionParams, al as WorkflowActions, aj as WorkflowActors, e as WorkflowContext, ad as WorkflowEvent, ac as WorkflowLogMessage, au as WorkflowResumeResult, o as WorkflowRow, ab as WorkflowRunResult, at as WorkflowRunState, am as WorkflowState, av as createStep } from './base-C1_KzNZ3.js';
3
+ import { T as ToolAction, A as Agent$1, l as AgentConfig, f as MastraStorage$1, c as MastraMemory$1, m as ToolExecutionContext, S as Step, W as Workflow$1, n as WorkflowOptions } from './base-BwuLIP_x.js';
4
+ export { a4 as ActionContext, a3 as BaseCondition, B as BaseStructuredOutputType, R as Config, r as CoreAssistantMessage, p as CoreMessage, q as CoreSystemMessage, C as CoreTool, t as CoreToolMessage, s as CoreUserMessage, I as DefaultLLMStreamObjectOptions, H as DefaultLLMStreamOptions, F as DefaultLLMTextObjectOptions, D as DefaultLLMTextOptions, ah as DependencyCheckOutput, v as EmbedManyResult, u as EmbedResult, E as EvalRow, ao as ExtractSchemaFromStep, ar as ExtractSchemaType, ap as ExtractStepResult, G as GenerateReturn, P as LLMInnerStreamOptions, Q as LLMStreamObjectOptions, N as LLMStreamOptions, K as LLMTextObjectOptions, J as LLMTextOptions, L as LanguageModel, M as Mastra, X as MemoryConfig, U as MessageResponse, j as MessageType, O as OutputType, as as PathsToStringProps, ae as ResolverFunctionInput, af as ResolverFunctionOutput, a1 as RetryConfig, Y as SharedMemoryConfig, Z as StepAction, a7 as StepCondition, a8 as StepConfig, a6 as StepDef, d as StepExecutionContext, a0 as StepGraph, an as StepId, aq as StepInputType, $ as StepNode, ai as StepResolverOutput, a9 as StepResult, _ as StepVariableType, aa as StepsRecord, h as StorageColumn, k as StorageGetMessagesArg, i as StorageThreadType, z as StreamReturn, y as StructuredOutput, x as StructuredOutputArrayItem, w as StructuredOutputType, ag as SubscriberFunctionOutput, a2 as VariableReference, V as VercelTool, a5 as WhenConditionReturnValue, ak as WorkflowActionParams, al as WorkflowActions, aj as WorkflowActors, e as WorkflowContext, ad as WorkflowEvent, ac as WorkflowLogMessage, au as WorkflowResumeResult, o as WorkflowRow, ab as WorkflowRunResult, at as WorkflowRunState, am as WorkflowState, av as createStep } from './base-BwuLIP_x.js';
5
5
  import { M as MastraBase$1 } from './base-BZViaFTt.js';
6
6
  export { O as OtelConfig, S as SamplingStrategy, T as Telemetry } from './base-BZViaFTt.js';
7
7
  import { R as RegisteredLogger, a as LogLevel, T as TransportMap, L as Logger } from './index-mKY1XrpK.js';
package/dist/index.js CHANGED
@@ -5,9 +5,9 @@ import { Integration, OpenAPIToolset } from './chunk-PNZK456O.js';
5
5
  export { Mastra } from './chunk-22HQQDJZ.js';
6
6
  import { MastraMemory } from './chunk-GHONEERA.js';
7
7
  import { MastraVector } from './chunk-QLYZGX5Z.js';
8
- export { CohereRelevanceScorer, MastraAgentRelevanceScorer, createSimilarityPrompt } from './chunk-HEF3AUCR.js';
8
+ export { CohereRelevanceScorer, MastraAgentRelevanceScorer, createSimilarityPrompt } from './chunk-DGCOY6YF.js';
9
9
  import { MastraStorage } from './chunk-7TZAPEAT.js';
10
- import { Agent } from './chunk-E56VUJSG.js';
10
+ import { Agent } from './chunk-44N24GPK.js';
11
11
  export { InstrumentClass, OTLPTraceExporter as OTLPStorageExporter, Telemetry, hasActiveTelemetry, withSpan } from './chunk-W5HVJX45.js';
12
12
  export { createMastraProxy, deepMerge, delay, ensureToolProperties, isVercelTool, jsonSchemaPropertiesToTSTypes, jsonSchemaToModel, makeCoreTool, maskStreamTags, resolveSerializedZodOutput } from './chunk-64NEAPI4.js';
13
13
  import { Tool } from './chunk-ZINPRHAN.js';
@@ -1,5 +1,5 @@
1
1
  import '../base-DboIg_Cd.cjs';
2
- import { W as Workflow, T as ToolAction } from '../base-BNtyxqTf.cjs';
2
+ import { W as Workflow, T as ToolAction } from '../base-BESiSy3v.cjs';
3
3
  import '@opentelemetry/api';
4
4
  import '../index-mKY1XrpK.cjs';
5
5
  import 'stream';
@@ -1,5 +1,5 @@
1
1
  import '../base-BZViaFTt.js';
2
- import { W as Workflow, T as ToolAction } from '../base-C1_KzNZ3.js';
2
+ import { W as Workflow, T as ToolAction } from '../base-BwuLIP_x.js';
3
3
  import '@opentelemetry/api';
4
4
  import '../index-mKY1XrpK.js';
5
5
  import 'stream';
@@ -1,7 +1,7 @@
1
1
  import 'ai';
2
2
  import 'json-schema';
3
3
  import 'zod';
4
- export { B as BaseStructuredOutputType, r as CoreAssistantMessage, p as CoreMessage, q as CoreSystemMessage, t as CoreToolMessage, s as CoreUserMessage, I as DefaultLLMStreamObjectOptions, H as DefaultLLMStreamOptions, F as DefaultLLMTextObjectOptions, D as DefaultLLMTextOptions, v as EmbedManyResult, u as EmbedResult, G as GenerateReturn, P as LLMInnerStreamOptions, Q as LLMStreamObjectOptions, N as LLMStreamOptions, K as LLMTextObjectOptions, J as LLMTextOptions, L as LanguageModel, O as OutputType, z as StreamReturn, y as StructuredOutput, x as StructuredOutputArrayItem, w as StructuredOutputType } from '../base-BNtyxqTf.cjs';
4
+ export { B as BaseStructuredOutputType, r as CoreAssistantMessage, p as CoreMessage, q as CoreSystemMessage, t as CoreToolMessage, s as CoreUserMessage, I as DefaultLLMStreamObjectOptions, H as DefaultLLMStreamOptions, F as DefaultLLMTextObjectOptions, D as DefaultLLMTextOptions, v as EmbedManyResult, u as EmbedResult, G as GenerateReturn, P as LLMInnerStreamOptions, Q as LLMStreamObjectOptions, N as LLMStreamOptions, K as LLMTextObjectOptions, J as LLMTextOptions, L as LanguageModel, O as OutputType, z as StreamReturn, y as StructuredOutput, x as StructuredOutputArrayItem, w as StructuredOutputType } from '../base-BESiSy3v.cjs';
5
5
  import '../index-mKY1XrpK.cjs';
6
6
  import '../base-DboIg_Cd.cjs';
7
7
  import '@opentelemetry/api';
@@ -1,7 +1,7 @@
1
1
  import 'ai';
2
2
  import 'json-schema';
3
3
  import 'zod';
4
- export { B as BaseStructuredOutputType, r as CoreAssistantMessage, p as CoreMessage, q as CoreSystemMessage, t as CoreToolMessage, s as CoreUserMessage, I as DefaultLLMStreamObjectOptions, H as DefaultLLMStreamOptions, F as DefaultLLMTextObjectOptions, D as DefaultLLMTextOptions, v as EmbedManyResult, u as EmbedResult, G as GenerateReturn, P as LLMInnerStreamOptions, Q as LLMStreamObjectOptions, N as LLMStreamOptions, K as LLMTextObjectOptions, J as LLMTextOptions, L as LanguageModel, O as OutputType, z as StreamReturn, y as StructuredOutput, x as StructuredOutputArrayItem, w as StructuredOutputType } from '../base-C1_KzNZ3.js';
4
+ export { B as BaseStructuredOutputType, r as CoreAssistantMessage, p as CoreMessage, q as CoreSystemMessage, t as CoreToolMessage, s as CoreUserMessage, I as DefaultLLMStreamObjectOptions, H as DefaultLLMStreamOptions, F as DefaultLLMTextObjectOptions, D as DefaultLLMTextOptions, v as EmbedManyResult, u as EmbedResult, G as GenerateReturn, P as LLMInnerStreamOptions, Q as LLMStreamObjectOptions, N as LLMStreamOptions, K as LLMTextObjectOptions, J as LLMTextOptions, L as LanguageModel, O as OutputType, z as StreamReturn, y as StructuredOutput, x as StructuredOutputArrayItem, w as StructuredOutputType } from '../base-BwuLIP_x.js';
5
5
  import '../index-mKY1XrpK.js';
6
6
  import '../base-BZViaFTt.js';
7
7
  import '@opentelemetry/api';
@@ -1,5 +1,5 @@
1
1
  import '../index-mKY1XrpK.cjs';
2
- export { R as Config, M as Mastra } from '../base-BNtyxqTf.cjs';
2
+ export { R as Config, M as Mastra } from '../base-BESiSy3v.cjs';
3
3
  import '../deployer/index.cjs';
4
4
  import '../vector/index.cjs';
5
5
  import '../base-DboIg_Cd.cjs';
@@ -1,5 +1,5 @@
1
1
  import '../index-mKY1XrpK.js';
2
- export { R as Config, M as Mastra } from '../base-C1_KzNZ3.js';
2
+ export { R as Config, M as Mastra } from '../base-BwuLIP_x.js';
3
3
  import '../deployer/index.js';
4
4
  import '../vector/index.js';
5
5
  import '../base-BZViaFTt.js';
@@ -1,4 +1,4 @@
1
- export { c as MastraMemory, X as MemoryConfig, U as MessageResponse, j as MessageType, Y as SharedMemoryConfig, i as StorageThreadType } from '../base-BNtyxqTf.cjs';
1
+ export { c as MastraMemory, X as MemoryConfig, U as MessageResponse, j as MessageType, Y as SharedMemoryConfig, i as StorageThreadType } from '../base-BESiSy3v.cjs';
2
2
  export { Message as AiMessageType } from 'ai';
3
3
  import '../base-DboIg_Cd.cjs';
4
4
  import '@opentelemetry/api';
@@ -1,4 +1,4 @@
1
- export { c as MastraMemory, X as MemoryConfig, U as MessageResponse, j as MessageType, Y as SharedMemoryConfig, i as StorageThreadType } from '../base-C1_KzNZ3.js';
1
+ export { c as MastraMemory, X as MemoryConfig, U as MessageResponse, j as MessageType, Y as SharedMemoryConfig, i as StorageThreadType } from '../base-BwuLIP_x.js';
2
2
  export { Message as AiMessageType } from 'ai';
3
3
  import '../base-BZViaFTt.js';
4
4
  import '@opentelemetry/api';
@@ -1,18 +1,18 @@
1
1
  'use strict';
2
2
 
3
- var chunkMNGT2Y5R_cjs = require('../chunk-MNGT2Y5R.cjs');
3
+ var chunk2PTWBPQ6_cjs = require('../chunk-2PTWBPQ6.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "CohereRelevanceScorer", {
8
8
  enumerable: true,
9
- get: function () { return chunkMNGT2Y5R_cjs.CohereRelevanceScorer; }
9
+ get: function () { return chunk2PTWBPQ6_cjs.CohereRelevanceScorer; }
10
10
  });
11
11
  Object.defineProperty(exports, "MastraAgentRelevanceScorer", {
12
12
  enumerable: true,
13
- get: function () { return chunkMNGT2Y5R_cjs.MastraAgentRelevanceScorer; }
13
+ get: function () { return chunk2PTWBPQ6_cjs.MastraAgentRelevanceScorer; }
14
14
  });
15
15
  Object.defineProperty(exports, "createSimilarityPrompt", {
16
16
  enumerable: true,
17
- get: function () { return chunkMNGT2Y5R_cjs.createSimilarityPrompt; }
17
+ get: function () { return chunk2PTWBPQ6_cjs.createSimilarityPrompt; }
18
18
  });
@@ -1,5 +1,5 @@
1
1
  import '../base-DboIg_Cd.cjs';
2
- import { aw as MastraLanguageModel } from '../base-BNtyxqTf.cjs';
2
+ import { aw as MastraLanguageModel } from '../base-BESiSy3v.cjs';
3
3
  import '@opentelemetry/api';
4
4
  import '../index-mKY1XrpK.cjs';
5
5
  import 'stream';
@@ -1,5 +1,5 @@
1
1
  import '../base-BZViaFTt.js';
2
- import { aw as MastraLanguageModel } from '../base-C1_KzNZ3.js';
2
+ import { aw as MastraLanguageModel } from '../base-BwuLIP_x.js';
3
3
  import '@opentelemetry/api';
4
4
  import '../index-mKY1XrpK.js';
5
5
  import 'stream';
@@ -1 +1 @@
1
- export { CohereRelevanceScorer, MastraAgentRelevanceScorer, createSimilarityPrompt } from '../chunk-HEF3AUCR.js';
1
+ export { CohereRelevanceScorer, MastraAgentRelevanceScorer, createSimilarityPrompt } from '../chunk-DGCOY6YF.js';
@@ -1,4 +1,4 @@
1
- export { E as EvalRow, f as MastraStorage, h as StorageColumn, k as StorageGetMessagesArg, aG as TABLE_EVALS, aH as TABLE_MESSAGES, g as TABLE_NAMES, aI as TABLE_THREADS, aJ as TABLE_TRACES, aF as TABLE_WORKFLOW_SNAPSHOT, o as WorkflowRow } from '../base-BNtyxqTf.cjs';
1
+ export { E as EvalRow, f as MastraStorage, h as StorageColumn, k as StorageGetMessagesArg, aG as TABLE_EVALS, aH as TABLE_MESSAGES, g as TABLE_NAMES, aI as TABLE_THREADS, aJ as TABLE_TRACES, aF as TABLE_WORKFLOW_SNAPSHOT, o as WorkflowRow } from '../base-BESiSy3v.cjs';
2
2
  import 'ai';
3
3
  import '../base-DboIg_Cd.cjs';
4
4
  import '@opentelemetry/api';
@@ -1,4 +1,4 @@
1
- export { E as EvalRow, f as MastraStorage, h as StorageColumn, k as StorageGetMessagesArg, aG as TABLE_EVALS, aH as TABLE_MESSAGES, g as TABLE_NAMES, aI as TABLE_THREADS, aJ as TABLE_TRACES, aF as TABLE_WORKFLOW_SNAPSHOT, o as WorkflowRow } from '../base-C1_KzNZ3.js';
1
+ export { E as EvalRow, f as MastraStorage, h as StorageColumn, k as StorageGetMessagesArg, aG as TABLE_EVALS, aH as TABLE_MESSAGES, g as TABLE_NAMES, aI as TABLE_THREADS, aJ as TABLE_TRACES, aF as TABLE_WORKFLOW_SNAPSHOT, o as WorkflowRow } from '../base-BwuLIP_x.js';
2
2
  import 'ai';
3
3
  import '../base-BZViaFTt.js';
4
4
  import '@opentelemetry/api';
@@ -1,4 +1,4 @@
1
- import { f as MastraStorage, g as TABLE_NAMES, h as StorageColumn, i as StorageThreadType, j as MessageType, k as StorageGetMessagesArg, E as EvalRow } from '../../base-BNtyxqTf.cjs';
1
+ import { f as MastraStorage, g as TABLE_NAMES, h as StorageColumn, i as StorageThreadType, j as MessageType, k as StorageGetMessagesArg, E as EvalRow } from '../../base-BESiSy3v.cjs';
2
2
  import 'ai';
3
3
  import '../../base-DboIg_Cd.cjs';
4
4
  import '@opentelemetry/api';
@@ -1,4 +1,4 @@
1
- import { f as MastraStorage, g as TABLE_NAMES, h as StorageColumn, i as StorageThreadType, j as MessageType, k as StorageGetMessagesArg, E as EvalRow } from '../../base-C1_KzNZ3.js';
1
+ import { f as MastraStorage, g as TABLE_NAMES, h as StorageColumn, i as StorageThreadType, j as MessageType, k as StorageGetMessagesArg, E as EvalRow } from '../../base-BwuLIP_x.js';
2
2
  import 'ai';
3
3
  import '../../base-BZViaFTt.js';
4
4
  import '@opentelemetry/api';
@@ -3,7 +3,7 @@ import { SpanKind } from '@opentelemetry/api';
3
3
  import { ExportResult } from '@opentelemetry/core';
4
4
  import { SpanExporter, ReadableSpan } from '@opentelemetry/sdk-trace-base';
5
5
  import { L as Logger } from '../index-mKY1XrpK.cjs';
6
- import { f as MastraStorage } from '../base-BNtyxqTf.cjs';
6
+ import { f as MastraStorage } from '../base-BESiSy3v.cjs';
7
7
  import 'stream';
8
8
  import 'pino';
9
9
  import 'ai';
@@ -3,7 +3,7 @@ import { SpanKind } from '@opentelemetry/api';
3
3
  import { ExportResult } from '@opentelemetry/core';
4
4
  import { SpanExporter, ReadableSpan } from '@opentelemetry/sdk-trace-base';
5
5
  import { L as Logger } from '../index-mKY1XrpK.js';
6
- import { f as MastraStorage } from '../base-C1_KzNZ3.js';
6
+ import { f as MastraStorage } from '../base-BwuLIP_x.js';
7
7
  import 'stream';
8
8
  import 'pino';
9
9
  import 'ai';
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
- import { m as ToolExecutionContext, T as ToolAction, M as Mastra } from '../base-BNtyxqTf.cjs';
3
- export { C as CoreTool, V as VercelTool } from '../base-BNtyxqTf.cjs';
2
+ import { m as ToolExecutionContext, T as ToolAction, M as Mastra } from '../base-BESiSy3v.cjs';
3
+ export { C as CoreTool, V as VercelTool } from '../base-BESiSy3v.cjs';
4
4
  import 'ai';
5
5
  import '../base-DboIg_Cd.cjs';
6
6
  import '@opentelemetry/api';
@@ -19,15 +19,15 @@ import 'xstate';
19
19
  import 'node:events';
20
20
  import '../tts/index.cjs';
21
21
 
22
- declare class Tool<TSchemaIn extends z.ZodSchema | undefined = undefined, TSchemaOut extends z.ZodSchema | undefined = undefined, TContext extends ToolExecutionContext<TSchemaIn> = ToolExecutionContext<TSchemaIn>, TOptions extends unknown = unknown> implements ToolAction<TSchemaIn, TSchemaOut, TContext, TOptions> {
22
+ declare class Tool<TSchemaIn extends z.ZodSchema | undefined = undefined, TSchemaOut extends z.ZodSchema | undefined = undefined, TContext extends ToolExecutionContext<TSchemaIn> = ToolExecutionContext<TSchemaIn>> implements ToolAction<TSchemaIn, TSchemaOut, TContext> {
23
23
  id: string;
24
24
  description: string;
25
25
  inputSchema?: TSchemaIn;
26
26
  outputSchema?: TSchemaOut;
27
- execute?: (context: TContext, options?: TOptions) => Promise<TSchemaOut extends z.ZodSchema ? z.infer<TSchemaOut> : unknown>;
27
+ execute?: ToolAction<TSchemaIn, TSchemaOut, TContext>['execute'];
28
28
  mastra?: Mastra;
29
29
  constructor(opts: ToolAction<TSchemaIn, TSchemaOut, TContext>);
30
30
  }
31
- declare function createTool<TSchemaIn extends z.ZodSchema | undefined = undefined, TSchemaOut extends z.ZodSchema | undefined = undefined, TContext extends ToolExecutionContext<TSchemaIn> = ToolExecutionContext<TSchemaIn>>(opts: ToolAction<TSchemaIn, TSchemaOut, TContext>): Tool<TSchemaIn, TSchemaOut, TContext, unknown>;
31
+ declare function createTool<TSchemaIn extends z.ZodSchema | undefined = undefined, TSchemaOut extends z.ZodSchema | undefined = undefined, TContext extends ToolExecutionContext<TSchemaIn> = ToolExecutionContext<TSchemaIn>>(opts: ToolAction<TSchemaIn, TSchemaOut, TContext>): Tool<TSchemaIn, TSchemaOut, TContext>;
32
32
 
33
33
  export { Tool, ToolAction, ToolExecutionContext, createTool };
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
- import { m as ToolExecutionContext, T as ToolAction, M as Mastra } from '../base-C1_KzNZ3.js';
3
- export { C as CoreTool, V as VercelTool } from '../base-C1_KzNZ3.js';
2
+ import { m as ToolExecutionContext, T as ToolAction, M as Mastra } from '../base-BwuLIP_x.js';
3
+ export { C as CoreTool, V as VercelTool } from '../base-BwuLIP_x.js';
4
4
  import 'ai';
5
5
  import '../base-BZViaFTt.js';
6
6
  import '@opentelemetry/api';
@@ -19,15 +19,15 @@ import 'xstate';
19
19
  import 'node:events';
20
20
  import '../tts/index.js';
21
21
 
22
- declare class Tool<TSchemaIn extends z.ZodSchema | undefined = undefined, TSchemaOut extends z.ZodSchema | undefined = undefined, TContext extends ToolExecutionContext<TSchemaIn> = ToolExecutionContext<TSchemaIn>, TOptions extends unknown = unknown> implements ToolAction<TSchemaIn, TSchemaOut, TContext, TOptions> {
22
+ declare class Tool<TSchemaIn extends z.ZodSchema | undefined = undefined, TSchemaOut extends z.ZodSchema | undefined = undefined, TContext extends ToolExecutionContext<TSchemaIn> = ToolExecutionContext<TSchemaIn>> implements ToolAction<TSchemaIn, TSchemaOut, TContext> {
23
23
  id: string;
24
24
  description: string;
25
25
  inputSchema?: TSchemaIn;
26
26
  outputSchema?: TSchemaOut;
27
- execute?: (context: TContext, options?: TOptions) => Promise<TSchemaOut extends z.ZodSchema ? z.infer<TSchemaOut> : unknown>;
27
+ execute?: ToolAction<TSchemaIn, TSchemaOut, TContext>['execute'];
28
28
  mastra?: Mastra;
29
29
  constructor(opts: ToolAction<TSchemaIn, TSchemaOut, TContext>);
30
30
  }
31
- declare function createTool<TSchemaIn extends z.ZodSchema | undefined = undefined, TSchemaOut extends z.ZodSchema | undefined = undefined, TContext extends ToolExecutionContext<TSchemaIn> = ToolExecutionContext<TSchemaIn>>(opts: ToolAction<TSchemaIn, TSchemaOut, TContext>): Tool<TSchemaIn, TSchemaOut, TContext, unknown>;
31
+ declare function createTool<TSchemaIn extends z.ZodSchema | undefined = undefined, TSchemaOut extends z.ZodSchema | undefined = undefined, TContext extends ToolExecutionContext<TSchemaIn> = ToolExecutionContext<TSchemaIn>>(opts: ToolAction<TSchemaIn, TSchemaOut, TContext>): Tool<TSchemaIn, TSchemaOut, TContext>;
32
32
 
33
33
  export { Tool, ToolAction, ToolExecutionContext, createTool };
package/dist/utils.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { MastraTTS } from './tts/index.cjs';
2
2
  import { MastraVector } from './vector/index.cjs';
3
- import { V as VercelTool, T as ToolAction, a as ToolsInput, M as Mastra, b as MastraPrimitives, c as MastraMemory, C as CoreTool, A as Agent, W as Workflow, S as Step, d as StepExecutionContext, e as WorkflowContext } from './base-BNtyxqTf.cjs';
3
+ import { V as VercelTool, T as ToolAction, a as ToolsInput, M as Mastra, b as MastraPrimitives, c as MastraMemory, C as CoreTool, A as Agent, W as Workflow, S as Step, d as StepExecutionContext, e as WorkflowContext } from './base-BESiSy3v.cjs';
4
4
  import { M as Metric } from './types-CwTG2XyQ.cjs';
5
5
  import { z, ZodObject } from 'zod';
6
6
  import { L as Logger } from './index-mKY1XrpK.cjs';
@@ -65,7 +65,7 @@ interface ToolOptions {
65
65
  memory?: MastraMemory;
66
66
  agentName?: string;
67
67
  }
68
- type ToolToConvert = VercelTool | ToolAction<any, any, any, any>;
68
+ type ToolToConvert = VercelTool | ToolAction<any, any, any>;
69
69
  /**
70
70
  * Ensures a tool has an ID and inputSchema by generating one if not present
71
71
  * @param tool - The tool to ensure has an ID and inputSchema
package/dist/utils.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { MastraTTS } from './tts/index.js';
2
2
  import { MastraVector } from './vector/index.js';
3
- import { V as VercelTool, T as ToolAction, a as ToolsInput, M as Mastra, b as MastraPrimitives, c as MastraMemory, C as CoreTool, A as Agent, W as Workflow, S as Step, d as StepExecutionContext, e as WorkflowContext } from './base-C1_KzNZ3.js';
3
+ import { V as VercelTool, T as ToolAction, a as ToolsInput, M as Mastra, b as MastraPrimitives, c as MastraMemory, C as CoreTool, A as Agent, W as Workflow, S as Step, d as StepExecutionContext, e as WorkflowContext } from './base-BwuLIP_x.js';
4
4
  import { M as Metric } from './types-CwTG2XyQ.js';
5
5
  import { z, ZodObject } from 'zod';
6
6
  import { L as Logger } from './index-mKY1XrpK.js';
@@ -65,7 +65,7 @@ interface ToolOptions {
65
65
  memory?: MastraMemory;
66
66
  agentName?: string;
67
67
  }
68
- type ToolToConvert = VercelTool | ToolAction<any, any, any, any>;
68
+ type ToolToConvert = VercelTool | ToolAction<any, any, any>;
69
69
  /**
70
70
  * Ensures a tool has an ID and inputSchema by generating one if not present
71
71
  * @param tool - The tool to ensure has an ID and inputSchema
@@ -1,4 +1,4 @@
1
- export { aB as CompositeVoice, aA as MastraVoice, az as VoiceConfig, ay as VoiceEventMap, ax as VoiceEventType } from '../base-BNtyxqTf.cjs';
1
+ export { aB as CompositeVoice, aA as MastraVoice, az as VoiceConfig, ay as VoiceEventMap, ax as VoiceEventType } from '../base-BESiSy3v.cjs';
2
2
  import 'ai';
3
3
  import '../base-DboIg_Cd.cjs';
4
4
  import '@opentelemetry/api';
@@ -1,4 +1,4 @@
1
- export { aB as CompositeVoice, aA as MastraVoice, az as VoiceConfig, ay as VoiceEventMap, ax as VoiceEventType } from '../base-C1_KzNZ3.js';
1
+ export { aB as CompositeVoice, aA as MastraVoice, az as VoiceConfig, ay as VoiceEventMap, ax as VoiceEventType } from '../base-BwuLIP_x.js';
2
2
  import 'ai';
3
3
  import '../base-BZViaFTt.js';
4
4
  import '@opentelemetry/api';
@@ -1,5 +1,5 @@
1
- import { a2 as VariableReference, a9 as StepResult } from '../base-BNtyxqTf.cjs';
2
- export { a4 as ActionContext, a3 as BaseCondition, ah as DependencyCheckOutput, ao as ExtractSchemaFromStep, ar as ExtractSchemaType, ap as ExtractStepResult, as as PathsToStringProps, ae as ResolverFunctionInput, af as ResolverFunctionOutput, a1 as RetryConfig, S as Step, Z as StepAction, a7 as StepCondition, a8 as StepConfig, a6 as StepDef, d as StepExecutionContext, a0 as StepGraph, an as StepId, aq as StepInputType, $ as StepNode, ai as StepResolverOutput, _ as StepVariableType, aa as StepsRecord, ag as SubscriberFunctionOutput, a5 as WhenConditionReturnValue, W as Workflow, ak as WorkflowActionParams, al as WorkflowActions, aj as WorkflowActors, e as WorkflowContext, ad as WorkflowEvent, ac as WorkflowLogMessage, n as WorkflowOptions, au as WorkflowResumeResult, ab as WorkflowRunResult, at as WorkflowRunState, am as WorkflowState, av as createStep } from '../base-BNtyxqTf.cjs';
1
+ import { a2 as VariableReference, a9 as StepResult } from '../base-BESiSy3v.cjs';
2
+ export { a4 as ActionContext, a3 as BaseCondition, ah as DependencyCheckOutput, ao as ExtractSchemaFromStep, ar as ExtractSchemaType, ap as ExtractStepResult, as as PathsToStringProps, ae as ResolverFunctionInput, af as ResolverFunctionOutput, a1 as RetryConfig, S as Step, Z as StepAction, a7 as StepCondition, a8 as StepConfig, a6 as StepDef, d as StepExecutionContext, a0 as StepGraph, an as StepId, aq as StepInputType, $ as StepNode, ai as StepResolverOutput, _ as StepVariableType, aa as StepsRecord, ag as SubscriberFunctionOutput, a5 as WhenConditionReturnValue, W as Workflow, ak as WorkflowActionParams, al as WorkflowActions, aj as WorkflowActors, e as WorkflowContext, ad as WorkflowEvent, ac as WorkflowLogMessage, n as WorkflowOptions, au as WorkflowResumeResult, ab as WorkflowRunResult, at as WorkflowRunState, am as WorkflowState, av as createStep } from '../base-BESiSy3v.cjs';
3
3
  import 'ai';
4
4
  import '../base-DboIg_Cd.cjs';
5
5
  import '@opentelemetry/api';
@@ -1,5 +1,5 @@
1
- import { a2 as VariableReference, a9 as StepResult } from '../base-C1_KzNZ3.js';
2
- export { a4 as ActionContext, a3 as BaseCondition, ah as DependencyCheckOutput, ao as ExtractSchemaFromStep, ar as ExtractSchemaType, ap as ExtractStepResult, as as PathsToStringProps, ae as ResolverFunctionInput, af as ResolverFunctionOutput, a1 as RetryConfig, S as Step, Z as StepAction, a7 as StepCondition, a8 as StepConfig, a6 as StepDef, d as StepExecutionContext, a0 as StepGraph, an as StepId, aq as StepInputType, $ as StepNode, ai as StepResolverOutput, _ as StepVariableType, aa as StepsRecord, ag as SubscriberFunctionOutput, a5 as WhenConditionReturnValue, W as Workflow, ak as WorkflowActionParams, al as WorkflowActions, aj as WorkflowActors, e as WorkflowContext, ad as WorkflowEvent, ac as WorkflowLogMessage, n as WorkflowOptions, au as WorkflowResumeResult, ab as WorkflowRunResult, at as WorkflowRunState, am as WorkflowState, av as createStep } from '../base-C1_KzNZ3.js';
1
+ import { a2 as VariableReference, a9 as StepResult } from '../base-BwuLIP_x.js';
2
+ export { a4 as ActionContext, a3 as BaseCondition, ah as DependencyCheckOutput, ao as ExtractSchemaFromStep, ar as ExtractSchemaType, ap as ExtractStepResult, as as PathsToStringProps, ae as ResolverFunctionInput, af as ResolverFunctionOutput, a1 as RetryConfig, S as Step, Z as StepAction, a7 as StepCondition, a8 as StepConfig, a6 as StepDef, d as StepExecutionContext, a0 as StepGraph, an as StepId, aq as StepInputType, $ as StepNode, ai as StepResolverOutput, _ as StepVariableType, aa as StepsRecord, ag as SubscriberFunctionOutput, a5 as WhenConditionReturnValue, W as Workflow, ak as WorkflowActionParams, al as WorkflowActions, aj as WorkflowActors, e as WorkflowContext, ad as WorkflowEvent, ac as WorkflowLogMessage, n as WorkflowOptions, au as WorkflowResumeResult, ab as WorkflowRunResult, at as WorkflowRunState, am as WorkflowState, av as createStep } from '../base-BwuLIP_x.js';
3
3
  import 'ai';
4
4
  import '../base-BZViaFTt.js';
5
5
  import '@opentelemetry/api';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/core",
3
- "version": "0.6.1",
3
+ "version": "0.6.2-alpha.0",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",