@mastra/core 0.10.6-alpha.2 → 0.10.6-alpha.4

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 (101) hide show
  1. package/dist/agent/index.cjs +4 -4
  2. package/dist/agent/index.d.cts +1 -1
  3. package/dist/agent/index.d.ts +1 -1
  4. package/dist/agent/index.js +2 -2
  5. package/dist/{base-BP-zf-hZ.d.cts → base-BhFLW4wh.d.cts} +57 -9
  6. package/dist/{base-BGLE5ewf.d.ts → base-D2r9PD_M.d.ts} +57 -9
  7. package/dist/{chunk-LDNCERLU.js → chunk-4MPQAHTP.js} +1 -0
  8. package/dist/{chunk-TGK6JO2D.cjs → chunk-6NCAW2KJ.cjs} +3 -3
  9. package/dist/{chunk-CEM46IBM.cjs → chunk-7DACNI2G.cjs} +4 -4
  10. package/dist/{chunk-2XKJ7TUK.js → chunk-7PJSQZ2G.js} +1 -1
  11. package/dist/{chunk-6U377XOJ.cjs → chunk-B56DSVPS.cjs} +17 -17
  12. package/dist/{chunk-X2JO3IZM.cjs → chunk-BXKMEIPZ.cjs} +2 -2
  13. package/dist/{chunk-YDGX5LRI.js → chunk-CYVJMK5L.js} +2 -2
  14. package/dist/{chunk-CMEK3A3W.js → chunk-DVZMAHQO.js} +17 -3
  15. package/dist/{chunk-WZRMRYK5.cjs → chunk-ED3FH4QV.cjs} +2 -2
  16. package/dist/{chunk-6ACH5N7Q.js → chunk-ESHFQMPC.js} +2 -2
  17. package/dist/{chunk-WC7XENI5.cjs → chunk-EXYYTCHF.cjs} +7 -7
  18. package/dist/{chunk-DPKEVI6Q.js → chunk-GTG6JWTV.js} +1 -1
  19. package/dist/{chunk-AQRPDE2V.cjs → chunk-HHQZ3NUR.cjs} +78 -52
  20. package/dist/{chunk-3SY7GRSA.js → chunk-HJQYQAIJ.js} +1 -1
  21. package/dist/{chunk-6EMFDXAQ.cjs → chunk-HUZTNNHH.cjs} +18 -4
  22. package/dist/{chunk-CD2WGTW5.js → chunk-HWV3U4ZK.js} +1 -1
  23. package/dist/{chunk-BE2B3X5T.js → chunk-IFQGBW42.js} +1 -1
  24. package/dist/{chunk-UCKXM3N7.cjs → chunk-KKCGZKNC.cjs} +21 -21
  25. package/dist/{chunk-JDOKE3OQ.cjs → chunk-L5FURQXC.cjs} +4 -4
  26. package/dist/{chunk-WQYP3JIQ.js → chunk-L6BR3ILD.js} +1 -1
  27. package/dist/{chunk-PYJKBUWB.js → chunk-NTTH3J2D.js} +2 -2
  28. package/dist/{chunk-Q65UGFQK.cjs → chunk-PDK2ZFRX.cjs} +4 -4
  29. package/dist/{chunk-HVI3SKIH.cjs → chunk-PK4TS7JL.cjs} +16 -16
  30. package/dist/{chunk-OLSQRA2V.cjs → chunk-U3XRKJNN.cjs} +1 -0
  31. package/dist/{chunk-J7MLMW6O.cjs → chunk-UOKJ7SQO.cjs} +2 -2
  32. package/dist/{chunk-ODKQT6IG.js → chunk-UQ3K5POQ.js} +36 -10
  33. package/dist/{chunk-K5SVOEUZ.js → chunk-WK7AF32G.js} +1 -1
  34. package/dist/{chunk-2RZXEVWT.js → chunk-WWKY4EQ7.js} +1 -1
  35. package/dist/error/index.cjs +5 -5
  36. package/dist/error/index.d.cts +2 -1
  37. package/dist/error/index.d.ts +2 -1
  38. package/dist/error/index.js +1 -1
  39. package/dist/eval/index.d.cts +1 -1
  40. package/dist/eval/index.d.ts +1 -1
  41. package/dist/index.cjs +48 -48
  42. package/dist/index.d.cts +2 -2
  43. package/dist/index.d.ts +2 -2
  44. package/dist/index.js +12 -12
  45. package/dist/integration/index.d.cts +1 -1
  46. package/dist/integration/index.d.ts +1 -1
  47. package/dist/llm/index.d.cts +1 -1
  48. package/dist/llm/index.d.ts +1 -1
  49. package/dist/mastra/index.cjs +2 -2
  50. package/dist/mastra/index.d.cts +1 -1
  51. package/dist/mastra/index.d.ts +1 -1
  52. package/dist/mastra/index.js +1 -1
  53. package/dist/mcp/index.d.cts +1 -1
  54. package/dist/mcp/index.d.ts +1 -1
  55. package/dist/memory/index.cjs +4 -4
  56. package/dist/memory/index.d.cts +1 -1
  57. package/dist/memory/index.d.ts +1 -1
  58. package/dist/memory/index.js +1 -1
  59. package/dist/network/index.cjs +4 -4
  60. package/dist/network/index.d.cts +1 -1
  61. package/dist/network/index.d.ts +1 -1
  62. package/dist/network/index.js +2 -2
  63. package/dist/relevance/index.cjs +4 -4
  64. package/dist/relevance/index.d.cts +1 -1
  65. package/dist/relevance/index.d.ts +1 -1
  66. package/dist/relevance/index.js +1 -1
  67. package/dist/server/index.cjs +4 -4
  68. package/dist/server/index.d.cts +2 -2
  69. package/dist/server/index.d.ts +2 -2
  70. package/dist/server/index.js +2 -2
  71. package/dist/storage/index.cjs +12 -12
  72. package/dist/storage/index.d.cts +2 -2
  73. package/dist/storage/index.d.ts +2 -2
  74. package/dist/storage/index.js +4 -4
  75. package/dist/telemetry/index.cjs +7 -7
  76. package/dist/telemetry/index.d.cts +1 -1
  77. package/dist/telemetry/index.d.ts +1 -1
  78. package/dist/telemetry/index.js +1 -1
  79. package/dist/tools/index.d.cts +2 -2
  80. package/dist/tools/index.d.ts +2 -2
  81. package/dist/tts/index.cjs +2 -2
  82. package/dist/tts/index.js +1 -1
  83. package/dist/utils.cjs +14 -14
  84. package/dist/utils.d.cts +1 -1
  85. package/dist/utils.d.ts +1 -1
  86. package/dist/utils.js +1 -1
  87. package/dist/vector/index.cjs +2 -2
  88. package/dist/vector/index.js +1 -1
  89. package/dist/voice/index.cjs +4 -4
  90. package/dist/voice/index.d.cts +1 -1
  91. package/dist/voice/index.d.ts +1 -1
  92. package/dist/voice/index.js +1 -1
  93. package/dist/workflows/index.cjs +9 -9
  94. package/dist/workflows/index.d.cts +2 -2
  95. package/dist/workflows/index.d.ts +2 -2
  96. package/dist/workflows/index.js +1 -1
  97. package/dist/workflows/legacy/index.cjs +22 -22
  98. package/dist/workflows/legacy/index.d.cts +2 -2
  99. package/dist/workflows/legacy/index.d.ts +2 -2
  100. package/dist/workflows/legacy/index.js +1 -1
  101. package/package.json +1 -1
@@ -1,15 +1,15 @@
1
1
  'use strict';
2
2
 
3
- var chunkAQRPDE2V_cjs = require('../chunk-AQRPDE2V.cjs');
4
- var chunkTGK6JO2D_cjs = require('../chunk-TGK6JO2D.cjs');
3
+ var chunkHHQZ3NUR_cjs = require('../chunk-HHQZ3NUR.cjs');
4
+ var chunk6NCAW2KJ_cjs = require('../chunk-6NCAW2KJ.cjs');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, "Agent", {
9
9
  enumerable: true,
10
- get: function () { return chunkAQRPDE2V_cjs.Agent; }
10
+ get: function () { return chunkHHQZ3NUR_cjs.Agent; }
11
11
  });
12
12
  Object.defineProperty(exports, "MessageList", {
13
13
  enumerable: true,
14
- get: function () { return chunkTGK6JO2D_cjs.MessageList; }
14
+ get: function () { return chunk6NCAW2KJ_cjs.MessageList; }
15
15
  });
@@ -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, as as AgentConfig, bV as AgentGenerateOptions, bW as AgentStreamOptions, bU as DynamicArgument, bs as MastraLanguageModel, bX as MastraMessageContentV2, s as MastraMessageV2, bS as MessageList, T as ToolsInput, bT as ToolsetsInput } from '../base-BP-zf-hZ.cjs';
4
+ export { A as Agent, as as AgentConfig, bY as AgentGenerateOptions, bZ as AgentStreamOptions, bX as DynamicArgument, bv as MastraLanguageModel, b_ as MastraMessageContentV2, s as MastraMessageV2, bV as MessageList, T as ToolsInput, bW as ToolsetsInput } from '../base-BhFLW4wh.cjs';
5
5
  import '../base-DVVTzIQy.cjs';
6
6
  import '../types-Bo1uigWx.cjs';
7
7
  import '../runtime-context/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, as as AgentConfig, bV as AgentGenerateOptions, bW as AgentStreamOptions, bU as DynamicArgument, bs as MastraLanguageModel, bX as MastraMessageContentV2, s as MastraMessageV2, bS as MessageList, T as ToolsInput, bT as ToolsetsInput } from '../base-BGLE5ewf.js';
4
+ export { A as Agent, as as AgentConfig, bY as AgentGenerateOptions, bZ as AgentStreamOptions, bX as DynamicArgument, bv as MastraLanguageModel, b_ as MastraMessageContentV2, s as MastraMessageV2, bV as MessageList, T as ToolsInput, bW as ToolsetsInput } from '../base-D2r9PD_M.js';
5
5
  import '../base-BbdvunNJ.js';
6
6
  import '../types-Bo1uigWx.js';
7
7
  import '../runtime-context/index.js';
@@ -1,2 +1,2 @@
1
- export { Agent } from '../chunk-ODKQT6IG.js';
2
- export { MessageList } from '../chunk-DPKEVI6Q.js';
1
+ export { Agent } from '../chunk-UQ3K5POQ.js';
2
+ export { MessageList } from '../chunk-GTG6JWTV.js';
@@ -1,7 +1,7 @@
1
1
  import * as ai from 'ai';
2
2
  import { Tool as Tool$1, Schema, ToolExecutionOptions, TextStreamPart, UserContent, AssistantContent, ToolContent, EmbeddingModel, CoreMessage as CoreMessage$1, UIMessage, Message, IDGenerator as IDGenerator$1, CoreSystemMessage as CoreSystemMessage$1, LanguageModel as LanguageModel$1, GenerateTextResult, GenerateObjectResult, StreamTextResult, StreamObjectResult, DeepPartial, generateText, generateObject, streamText, streamObject, TelemetrySettings, CoreAssistantMessage as CoreAssistantMessage$1, CoreUserMessage as CoreUserMessage$1, CoreToolMessage as CoreToolMessage$1, EmbedResult as EmbedResult$1, EmbedManyResult as EmbedManyResult$1, LanguageModelV1, GenerateTextOnStepFinishCallback, StreamTextOnFinishCallback, StreamObjectOnFinishCallback, StreamTextOnStepFinishCallback } from 'ai';
3
3
  import { M as MastraBase, a as Telemetry, O as OtelConfig, T as Trace } from './base-DVVTzIQy.cjs';
4
- import { z, ZodSchema } from 'zod';
4
+ import { z, ZodSchema, ZodObject } from 'zod';
5
5
  import { B as BaseLogMessage, R as RegisteredLogger, I as IMastraLogger, a as LogLevel } from './logger-CpL0z5v_.cjs';
6
6
  import { JSONSchema7Type, JSONSchema7 } from 'json-schema';
7
7
  import { MastraTTS } from './tts/index.cjs';
@@ -1695,6 +1695,24 @@ type MessageResponse<T extends 'raw' | 'core_message'> = {
1695
1695
  raw: MastraMessageV1[];
1696
1696
  core_message: CoreMessage$1[];
1697
1697
  }[T];
1698
+ type BaseWorkingMemory = {
1699
+ enabled: boolean;
1700
+ /** @deprecated The `use` option has been removed. Working memory always uses tool-call mode. */
1701
+ use?: never;
1702
+ };
1703
+ type TemplateWorkingMemory = BaseWorkingMemory & {
1704
+ template: string;
1705
+ schema?: never;
1706
+ };
1707
+ type SchemaWorkingMemory = BaseWorkingMemory & {
1708
+ schema: ZodObject<any>;
1709
+ template?: never;
1710
+ };
1711
+ type WorkingMemoryNone = BaseWorkingMemory & {
1712
+ template?: never;
1713
+ schema?: never;
1714
+ };
1715
+ type WorkingMemory = TemplateWorkingMemory | SchemaWorkingMemory | WorkingMemoryNone;
1698
1716
  type MemoryConfig = {
1699
1717
  lastMessages?: number | false;
1700
1718
  semanticRecall?: boolean | {
@@ -1705,12 +1723,7 @@ type MemoryConfig = {
1705
1723
  };
1706
1724
  scope?: 'thread' | 'resource';
1707
1725
  };
1708
- workingMemory?: {
1709
- enabled: boolean;
1710
- template?: string;
1711
- /** @deprecated The `use` option has been removed. Working memory always uses tool-call mode. */
1712
- use?: never;
1713
- };
1726
+ workingMemory?: WorkingMemory;
1714
1727
  threads?: {
1715
1728
  generateTitle?: boolean;
1716
1729
  };
@@ -1738,6 +1751,11 @@ type TraceType = {
1738
1751
  endTime: number;
1739
1752
  createdAt: Date;
1740
1753
  };
1754
+ type WorkingMemoryFormat = 'json' | 'markdown';
1755
+ type WorkingMemoryTemplate = {
1756
+ format: WorkingMemoryFormat;
1757
+ content: string;
1758
+ };
1741
1759
 
1742
1760
  type MastraMessageContentV2 = {
1743
1761
  format: 2;
@@ -1892,6 +1910,14 @@ declare abstract class MastraMemory extends MastraBase {
1892
1910
  threadId: string;
1893
1911
  memoryConfig?: MemoryConfig;
1894
1912
  }): Promise<string | null>;
1913
+ /**
1914
+ * Get a user context message to inject into the conversation.
1915
+ * This will be called before each conversation turn.
1916
+ * Implementations can override this to inject custom system messages.
1917
+ */
1918
+ getUserContextMessage(_input: {
1919
+ threadId: string;
1920
+ }): Promise<string | null>;
1895
1921
  /**
1896
1922
  * Get tools that should be available to the agent.
1897
1923
  * This will be called when converting tools for the agent.
@@ -2017,6 +2043,22 @@ declare abstract class MastraMemory extends MastraBase {
2017
2043
  * @returns A unique string ID
2018
2044
  */
2019
2045
  generateId(): string;
2046
+ /**
2047
+ * Retrieves working memory for a specific thread
2048
+ * @param threadId - The unique identifier of the thread
2049
+ * @param format - Optional format for the returned data ('json' or 'markdown')
2050
+ * @returns Promise resolving to working memory data or null if not found
2051
+ */
2052
+ abstract getWorkingMemory({ threadId, }: {
2053
+ threadId: string;
2054
+ format?: 'json' | 'markdown';
2055
+ }): Promise<Record<string, any> | string | null>;
2056
+ /**
2057
+ * Retrieves working memory template for a specific thread
2058
+ * @param threadId - The unique identifier of the thread
2059
+ * @returns Promise resolving to working memory template or null if not found
2060
+ */
2061
+ abstract getWorkingMemoryTemplate(): Promise<WorkingMemoryTemplate | null>;
2020
2062
  }
2021
2063
 
2022
2064
  declare class MastraLLMBase extends MastraBase {
@@ -3309,15 +3351,21 @@ declare class Agent<TAgentId extends string = string, TTools extends ToolsInput
3309
3351
  }): Promise<string>;
3310
3352
  getMostRecentUserMessage(messages: Array<UIMessage>): UIMessage | undefined;
3311
3353
  genTitle(userMessage: string | MessageInput | undefined, runtimeContext: RuntimeContext): Promise<string>;
3312
- fetchMemory({ threadId, thread: passedThread, memoryConfig, resourceId, runId, messageList, }: {
3354
+ fetchMemory({ threadId, thread: passedThread, memoryConfig, resourceId, runId, userMessages, systemMessage, messageList, }: {
3313
3355
  resourceId: string;
3314
3356
  threadId: string;
3315
3357
  thread?: StorageThreadType;
3316
3358
  memoryConfig?: MemoryConfig;
3359
+ userMessages?: CoreMessage$1[];
3360
+ systemMessage?: CoreMessage$1;
3317
3361
  runId?: string;
3318
3362
  messageList: MessageList;
3319
3363
  }): Promise<{
3320
3364
  threadId: string;
3365
+ messages?: undefined;
3366
+ } | {
3367
+ threadId: string;
3368
+ messages: NonNullable<string | CoreMessage$1>[];
3321
3369
  }>;
3322
3370
  private getMemoryTools;
3323
3371
  private getAssignedTools;
@@ -3558,4 +3606,4 @@ declare abstract class MastraStorage extends MastraBase {
3558
3606
  }>;
3559
3607
  }
3560
3608
 
3561
- export { type ActionContext as $, Agent as A, type StorageGetTracesArg as B, type CoreTool as C, TABLE_WORKFLOW_SNAPSHOT as D, type EvalRow as E, TABLE_EVALS as F, TABLE_MESSAGES as G, TABLE_THREADS as H, TABLE_TRACES as I, TABLE_SCHEMAS as J, type VariableReference$1 as K, LegacyWorkflow as L, Mastra as M, type StepResult$1 as N, type StepAction as O, type PaginationInfo as P, type LegacyWorkflowRunResult as Q, type WorkflowOptions as R, type StepExecutionContext as S, type ToolsInput as T, type StepVariableType as U, type VercelTool as V, type WorkflowContext as W, type StepNode as X, type StepGraph as Y, type RetryConfig as Z, type BaseCondition as _, type MastraPrimitives as a, MemoryProcessor as a$, WhenConditionReturnValue as a0, type StepDef as a1, type StepCondition as a2, type StepConfig as a3, type StepsRecord$1 as a4, type WorkflowLogMessage as a5, type WorkflowEvent as a6, type ResolverFunctionInput as a7, type ResolverFunctionOutput as a8, type SubscriberFunctionOutput as a9, type CoreToolMessage as aA, type EmbedResult as aB, type EmbedManyResult as aC, type BaseStructuredOutputType as aD, type StructuredOutputType as aE, type StructuredOutputArrayItem as aF, type StructuredOutput as aG, type GenerateReturn as aH, type StreamReturn as aI, type OutputType as aJ, type DefaultLLMTextOptions as aK, type DefaultLLMTextObjectOptions as aL, type DefaultLLMStreamOptions as aM, type DefaultLLMStreamObjectOptions as aN, type LLMTextOptions as aO, type LLMTextObjectOptions as aP, type LLMStreamOptions as aQ, type LLMInnerStreamOptions as aR, type LLMStreamObjectOptions as aS, createMockModel as aT, type Config as aU, type MessageType as aV, type MessageResponse as aW, type MemoryConfig as aX, type SharedMemoryConfig as aY, type TraceType as aZ, type MemoryProcessorOpts as a_, type DependencyCheckOutput as aa, type StepResolverOutput as ab, type WorkflowActors as ac, type WorkflowActionParams as ad, type WorkflowActions as ae, type LegacyWorkflowState as af, type StepId as ag, type ExtractSchemaFromStep$1 as ah, type ExtractStepResult as ai, type StepInputType as aj, type ExtractSchemaType$1 as ak, type PathsToStringProps$1 as al, type LegacyWorkflowRunState as am, type WorkflowResumeResult as an, Tool as ao, createTool as ap, type InternalCoreTool as aq, type ToolExecutionContext as ar, type AgentConfig as as, type DefaultEngineType as at, type WorkflowConfig as au, type LanguageModel as av, type CoreMessage as aw, type CoreSystemMessage as ax, type CoreAssistantMessage as ay, type CoreUserMessage as az, MastraMemory as b, memoryDefaultOptions as b0, type StepFlowEntry as b1, type SerializedStep as b2, type SerializedStepFlowEntry as b3, createStep as b4, cloneStep as b5, createWorkflow as b6, cloneWorkflow as b7, type WorkflowResult as b8, Run as b9, type ConvertedTool as bA, type MCPServerSSEOptions as bB, type MCPServerHonoSSEOptions as bC, type MCPServerHTTPOptions as bD, type Repository as bE, type VersionDetail as bF, type ArgumentInfo as bG, type PositionalArgumentInfo as bH, type NamedArgumentInfo as bI, type SubcommandInfo as bJ, type CommandInfo as bK, type EnvironmentVariableInfo as bL, type PackageInfo as bM, type RemoteInfo as bN, type MCPServerConfig as bO, type ServerInfo as bP, type ServerDetailInfo as bQ, type MCPToolType as bR, MessageList as bS, type ToolsetsInput as bT, type DynamicArgument as bU, type AgentGenerateOptions as bV, type AgentStreamOptions as bW, type MastraMessageContentV2 as bX, type ExecutionGraph as ba, ExecutionEngine as bb, type ExecuteFunction as bc, type StepSuccess as bd, type StepFailure as be, type StepSuspended as bf, type StepRunning as bg, type StepResult as bh, type StepsRecord as bi, type DynamicMapping as bj, type PathsToStringProps as bk, type ExtractSchemaType as bl, type ExtractSchemaFromStep as bm, type VariableReference as bn, type StreamEvent as bo, type WatchEvent as bp, type ZodPathType as bq, type WorkflowRunState as br, type MastraLanguageModel as bs, type VoiceEventType as bt, type VoiceEventMap as bu, type VoiceConfig as bv, MastraVoice as bw, CompositeVoice as bx, DefaultVoice as by, type AgentNetworkConfig as bz, type ToolAction as c, LegacyStep as d, Workflow as e, type Step as f, AgentNetwork as g, MCPServerBase as h, type Methods as i, type ApiRoute as j, type MastraAuthConfig as k, type ContextWithMastra as l, MastraAuthProvider as m, type MastraAuthProviderOptions as n, MastraStorage as o, type TABLE_NAMES as p, type StorageColumn as q, type StorageThreadType as r, type MastraMessageV2 as s, type StorageGetMessagesArg as t, type MastraMessageV1 as u, type WorkflowRuns as v, type WorkflowRun as w, type LegacyWorkflowRuns as x, type LegacyWorkflowRun as y, type PaginationArgs as z };
3609
+ export { type ActionContext as $, Agent as A, type StorageGetTracesArg as B, type CoreTool as C, TABLE_WORKFLOW_SNAPSHOT as D, type EvalRow as E, TABLE_EVALS as F, TABLE_MESSAGES as G, TABLE_THREADS as H, TABLE_TRACES as I, TABLE_SCHEMAS as J, type VariableReference$1 as K, LegacyWorkflow as L, Mastra as M, type StepResult$1 as N, type StepAction as O, type PaginationInfo as P, type LegacyWorkflowRunResult as Q, type WorkflowOptions as R, type StepExecutionContext as S, type ToolsInput as T, type StepVariableType as U, type VercelTool as V, type WorkflowContext as W, type StepNode as X, type StepGraph as Y, type RetryConfig as Z, type BaseCondition as _, type MastraPrimitives as a, type WorkingMemoryFormat as a$, WhenConditionReturnValue as a0, type StepDef as a1, type StepCondition as a2, type StepConfig as a3, type StepsRecord$1 as a4, type WorkflowLogMessage as a5, type WorkflowEvent as a6, type ResolverFunctionInput as a7, type ResolverFunctionOutput as a8, type SubscriberFunctionOutput as a9, type CoreToolMessage as aA, type EmbedResult as aB, type EmbedManyResult as aC, type BaseStructuredOutputType as aD, type StructuredOutputType as aE, type StructuredOutputArrayItem as aF, type StructuredOutput as aG, type GenerateReturn as aH, type StreamReturn as aI, type OutputType as aJ, type DefaultLLMTextOptions as aK, type DefaultLLMTextObjectOptions as aL, type DefaultLLMStreamOptions as aM, type DefaultLLMStreamObjectOptions as aN, type LLMTextOptions as aO, type LLMTextObjectOptions as aP, type LLMStreamOptions as aQ, type LLMInnerStreamOptions as aR, type LLMStreamObjectOptions as aS, createMockModel as aT, type Config as aU, type MessageType as aV, type MessageResponse as aW, type WorkingMemory as aX, type MemoryConfig as aY, type SharedMemoryConfig as aZ, type TraceType as a_, type DependencyCheckOutput as aa, type StepResolverOutput as ab, type WorkflowActors as ac, type WorkflowActionParams as ad, type WorkflowActions as ae, type LegacyWorkflowState as af, type StepId as ag, type ExtractSchemaFromStep$1 as ah, type ExtractStepResult as ai, type StepInputType as aj, type ExtractSchemaType$1 as ak, type PathsToStringProps$1 as al, type LegacyWorkflowRunState as am, type WorkflowResumeResult as an, Tool as ao, createTool as ap, type InternalCoreTool as aq, type ToolExecutionContext as ar, type AgentConfig as as, type DefaultEngineType as at, type WorkflowConfig as au, type LanguageModel as av, type CoreMessage as aw, type CoreSystemMessage as ax, type CoreAssistantMessage as ay, type CoreUserMessage as az, MastraMemory as b, type WorkingMemoryTemplate as b0, type MemoryProcessorOpts as b1, MemoryProcessor as b2, memoryDefaultOptions as b3, type StepFlowEntry as b4, type SerializedStep as b5, type SerializedStepFlowEntry as b6, createStep as b7, cloneStep as b8, createWorkflow as b9, CompositeVoice as bA, DefaultVoice as bB, type AgentNetworkConfig as bC, type ConvertedTool as bD, type MCPServerSSEOptions as bE, type MCPServerHonoSSEOptions as bF, type MCPServerHTTPOptions as bG, type Repository as bH, type VersionDetail as bI, type ArgumentInfo as bJ, type PositionalArgumentInfo as bK, type NamedArgumentInfo as bL, type SubcommandInfo as bM, type CommandInfo as bN, type EnvironmentVariableInfo as bO, type PackageInfo as bP, type RemoteInfo as bQ, type MCPServerConfig as bR, type ServerInfo as bS, type ServerDetailInfo as bT, type MCPToolType as bU, MessageList as bV, type ToolsetsInput as bW, type DynamicArgument as bX, type AgentGenerateOptions as bY, type AgentStreamOptions as bZ, type MastraMessageContentV2 as b_, cloneWorkflow as ba, type WorkflowResult as bb, Run as bc, type ExecutionGraph as bd, ExecutionEngine as be, type ExecuteFunction as bf, type StepSuccess as bg, type StepFailure as bh, type StepSuspended as bi, type StepRunning as bj, type StepResult as bk, type StepsRecord as bl, type DynamicMapping as bm, type PathsToStringProps as bn, type ExtractSchemaType as bo, type ExtractSchemaFromStep as bp, type VariableReference as bq, type StreamEvent as br, type WatchEvent as bs, type ZodPathType as bt, type WorkflowRunState as bu, type MastraLanguageModel as bv, type VoiceEventType as bw, type VoiceEventMap as bx, type VoiceConfig as by, MastraVoice as bz, type ToolAction as c, LegacyStep as d, Workflow as e, type Step as f, AgentNetwork as g, MCPServerBase as h, type Methods as i, type ApiRoute as j, type MastraAuthConfig as k, type ContextWithMastra as l, MastraAuthProvider as m, type MastraAuthProviderOptions as n, MastraStorage as o, type TABLE_NAMES as p, type StorageColumn as q, type StorageThreadType as r, type MastraMessageV2 as s, type StorageGetMessagesArg as t, type MastraMessageV1 as u, type WorkflowRuns as v, type WorkflowRun as w, type LegacyWorkflowRuns as x, type LegacyWorkflowRun as y, type PaginationArgs as z };
@@ -1,7 +1,7 @@
1
1
  import * as ai from 'ai';
2
2
  import { Tool as Tool$1, Schema, ToolExecutionOptions, TextStreamPart, UserContent, AssistantContent, ToolContent, EmbeddingModel, CoreMessage as CoreMessage$1, UIMessage, Message, IDGenerator as IDGenerator$1, CoreSystemMessage as CoreSystemMessage$1, LanguageModel as LanguageModel$1, GenerateTextResult, GenerateObjectResult, StreamTextResult, StreamObjectResult, DeepPartial, generateText, generateObject, streamText, streamObject, TelemetrySettings, CoreAssistantMessage as CoreAssistantMessage$1, CoreUserMessage as CoreUserMessage$1, CoreToolMessage as CoreToolMessage$1, EmbedResult as EmbedResult$1, EmbedManyResult as EmbedManyResult$1, LanguageModelV1, GenerateTextOnStepFinishCallback, StreamTextOnFinishCallback, StreamObjectOnFinishCallback, StreamTextOnStepFinishCallback } from 'ai';
3
3
  import { M as MastraBase, a as Telemetry, O as OtelConfig, T as Trace } from './base-BbdvunNJ.js';
4
- import { z, ZodSchema } from 'zod';
4
+ import { z, ZodSchema, ZodObject } from 'zod';
5
5
  import { B as BaseLogMessage, R as RegisteredLogger, I as IMastraLogger, a as LogLevel } from './logger-DtVDdb81.js';
6
6
  import { JSONSchema7Type, JSONSchema7 } from 'json-schema';
7
7
  import { MastraTTS } from './tts/index.js';
@@ -1695,6 +1695,24 @@ type MessageResponse<T extends 'raw' | 'core_message'> = {
1695
1695
  raw: MastraMessageV1[];
1696
1696
  core_message: CoreMessage$1[];
1697
1697
  }[T];
1698
+ type BaseWorkingMemory = {
1699
+ enabled: boolean;
1700
+ /** @deprecated The `use` option has been removed. Working memory always uses tool-call mode. */
1701
+ use?: never;
1702
+ };
1703
+ type TemplateWorkingMemory = BaseWorkingMemory & {
1704
+ template: string;
1705
+ schema?: never;
1706
+ };
1707
+ type SchemaWorkingMemory = BaseWorkingMemory & {
1708
+ schema: ZodObject<any>;
1709
+ template?: never;
1710
+ };
1711
+ type WorkingMemoryNone = BaseWorkingMemory & {
1712
+ template?: never;
1713
+ schema?: never;
1714
+ };
1715
+ type WorkingMemory = TemplateWorkingMemory | SchemaWorkingMemory | WorkingMemoryNone;
1698
1716
  type MemoryConfig = {
1699
1717
  lastMessages?: number | false;
1700
1718
  semanticRecall?: boolean | {
@@ -1705,12 +1723,7 @@ type MemoryConfig = {
1705
1723
  };
1706
1724
  scope?: 'thread' | 'resource';
1707
1725
  };
1708
- workingMemory?: {
1709
- enabled: boolean;
1710
- template?: string;
1711
- /** @deprecated The `use` option has been removed. Working memory always uses tool-call mode. */
1712
- use?: never;
1713
- };
1726
+ workingMemory?: WorkingMemory;
1714
1727
  threads?: {
1715
1728
  generateTitle?: boolean;
1716
1729
  };
@@ -1738,6 +1751,11 @@ type TraceType = {
1738
1751
  endTime: number;
1739
1752
  createdAt: Date;
1740
1753
  };
1754
+ type WorkingMemoryFormat = 'json' | 'markdown';
1755
+ type WorkingMemoryTemplate = {
1756
+ format: WorkingMemoryFormat;
1757
+ content: string;
1758
+ };
1741
1759
 
1742
1760
  type MastraMessageContentV2 = {
1743
1761
  format: 2;
@@ -1892,6 +1910,14 @@ declare abstract class MastraMemory extends MastraBase {
1892
1910
  threadId: string;
1893
1911
  memoryConfig?: MemoryConfig;
1894
1912
  }): Promise<string | null>;
1913
+ /**
1914
+ * Get a user context message to inject into the conversation.
1915
+ * This will be called before each conversation turn.
1916
+ * Implementations can override this to inject custom system messages.
1917
+ */
1918
+ getUserContextMessage(_input: {
1919
+ threadId: string;
1920
+ }): Promise<string | null>;
1895
1921
  /**
1896
1922
  * Get tools that should be available to the agent.
1897
1923
  * This will be called when converting tools for the agent.
@@ -2017,6 +2043,22 @@ declare abstract class MastraMemory extends MastraBase {
2017
2043
  * @returns A unique string ID
2018
2044
  */
2019
2045
  generateId(): string;
2046
+ /**
2047
+ * Retrieves working memory for a specific thread
2048
+ * @param threadId - The unique identifier of the thread
2049
+ * @param format - Optional format for the returned data ('json' or 'markdown')
2050
+ * @returns Promise resolving to working memory data or null if not found
2051
+ */
2052
+ abstract getWorkingMemory({ threadId, }: {
2053
+ threadId: string;
2054
+ format?: 'json' | 'markdown';
2055
+ }): Promise<Record<string, any> | string | null>;
2056
+ /**
2057
+ * Retrieves working memory template for a specific thread
2058
+ * @param threadId - The unique identifier of the thread
2059
+ * @returns Promise resolving to working memory template or null if not found
2060
+ */
2061
+ abstract getWorkingMemoryTemplate(): Promise<WorkingMemoryTemplate | null>;
2020
2062
  }
2021
2063
 
2022
2064
  declare class MastraLLMBase extends MastraBase {
@@ -3309,15 +3351,21 @@ declare class Agent<TAgentId extends string = string, TTools extends ToolsInput
3309
3351
  }): Promise<string>;
3310
3352
  getMostRecentUserMessage(messages: Array<UIMessage>): UIMessage | undefined;
3311
3353
  genTitle(userMessage: string | MessageInput | undefined, runtimeContext: RuntimeContext): Promise<string>;
3312
- fetchMemory({ threadId, thread: passedThread, memoryConfig, resourceId, runId, messageList, }: {
3354
+ fetchMemory({ threadId, thread: passedThread, memoryConfig, resourceId, runId, userMessages, systemMessage, messageList, }: {
3313
3355
  resourceId: string;
3314
3356
  threadId: string;
3315
3357
  thread?: StorageThreadType;
3316
3358
  memoryConfig?: MemoryConfig;
3359
+ userMessages?: CoreMessage$1[];
3360
+ systemMessage?: CoreMessage$1;
3317
3361
  runId?: string;
3318
3362
  messageList: MessageList;
3319
3363
  }): Promise<{
3320
3364
  threadId: string;
3365
+ messages?: undefined;
3366
+ } | {
3367
+ threadId: string;
3368
+ messages: NonNullable<string | CoreMessage$1>[];
3321
3369
  }>;
3322
3370
  private getMemoryTools;
3323
3371
  private getAssignedTools;
@@ -3558,4 +3606,4 @@ declare abstract class MastraStorage extends MastraBase {
3558
3606
  }>;
3559
3607
  }
3560
3608
 
3561
- export { type ActionContext as $, Agent as A, type StorageGetTracesArg as B, type CoreTool as C, TABLE_WORKFLOW_SNAPSHOT as D, type EvalRow as E, TABLE_EVALS as F, TABLE_MESSAGES as G, TABLE_THREADS as H, TABLE_TRACES as I, TABLE_SCHEMAS as J, type VariableReference$1 as K, LegacyWorkflow as L, Mastra as M, type StepResult$1 as N, type StepAction as O, type PaginationInfo as P, type LegacyWorkflowRunResult as Q, type WorkflowOptions as R, type StepExecutionContext as S, type ToolsInput as T, type StepVariableType as U, type VercelTool as V, type WorkflowContext as W, type StepNode as X, type StepGraph as Y, type RetryConfig as Z, type BaseCondition as _, type MastraPrimitives as a, MemoryProcessor as a$, WhenConditionReturnValue as a0, type StepDef as a1, type StepCondition as a2, type StepConfig as a3, type StepsRecord$1 as a4, type WorkflowLogMessage as a5, type WorkflowEvent as a6, type ResolverFunctionInput as a7, type ResolverFunctionOutput as a8, type SubscriberFunctionOutput as a9, type CoreToolMessage as aA, type EmbedResult as aB, type EmbedManyResult as aC, type BaseStructuredOutputType as aD, type StructuredOutputType as aE, type StructuredOutputArrayItem as aF, type StructuredOutput as aG, type GenerateReturn as aH, type StreamReturn as aI, type OutputType as aJ, type DefaultLLMTextOptions as aK, type DefaultLLMTextObjectOptions as aL, type DefaultLLMStreamOptions as aM, type DefaultLLMStreamObjectOptions as aN, type LLMTextOptions as aO, type LLMTextObjectOptions as aP, type LLMStreamOptions as aQ, type LLMInnerStreamOptions as aR, type LLMStreamObjectOptions as aS, createMockModel as aT, type Config as aU, type MessageType as aV, type MessageResponse as aW, type MemoryConfig as aX, type SharedMemoryConfig as aY, type TraceType as aZ, type MemoryProcessorOpts as a_, type DependencyCheckOutput as aa, type StepResolverOutput as ab, type WorkflowActors as ac, type WorkflowActionParams as ad, type WorkflowActions as ae, type LegacyWorkflowState as af, type StepId as ag, type ExtractSchemaFromStep$1 as ah, type ExtractStepResult as ai, type StepInputType as aj, type ExtractSchemaType$1 as ak, type PathsToStringProps$1 as al, type LegacyWorkflowRunState as am, type WorkflowResumeResult as an, Tool as ao, createTool as ap, type InternalCoreTool as aq, type ToolExecutionContext as ar, type AgentConfig as as, type DefaultEngineType as at, type WorkflowConfig as au, type LanguageModel as av, type CoreMessage as aw, type CoreSystemMessage as ax, type CoreAssistantMessage as ay, type CoreUserMessage as az, MastraMemory as b, memoryDefaultOptions as b0, type StepFlowEntry as b1, type SerializedStep as b2, type SerializedStepFlowEntry as b3, createStep as b4, cloneStep as b5, createWorkflow as b6, cloneWorkflow as b7, type WorkflowResult as b8, Run as b9, type ConvertedTool as bA, type MCPServerSSEOptions as bB, type MCPServerHonoSSEOptions as bC, type MCPServerHTTPOptions as bD, type Repository as bE, type VersionDetail as bF, type ArgumentInfo as bG, type PositionalArgumentInfo as bH, type NamedArgumentInfo as bI, type SubcommandInfo as bJ, type CommandInfo as bK, type EnvironmentVariableInfo as bL, type PackageInfo as bM, type RemoteInfo as bN, type MCPServerConfig as bO, type ServerInfo as bP, type ServerDetailInfo as bQ, type MCPToolType as bR, MessageList as bS, type ToolsetsInput as bT, type DynamicArgument as bU, type AgentGenerateOptions as bV, type AgentStreamOptions as bW, type MastraMessageContentV2 as bX, type ExecutionGraph as ba, ExecutionEngine as bb, type ExecuteFunction as bc, type StepSuccess as bd, type StepFailure as be, type StepSuspended as bf, type StepRunning as bg, type StepResult as bh, type StepsRecord as bi, type DynamicMapping as bj, type PathsToStringProps as bk, type ExtractSchemaType as bl, type ExtractSchemaFromStep as bm, type VariableReference as bn, type StreamEvent as bo, type WatchEvent as bp, type ZodPathType as bq, type WorkflowRunState as br, type MastraLanguageModel as bs, type VoiceEventType as bt, type VoiceEventMap as bu, type VoiceConfig as bv, MastraVoice as bw, CompositeVoice as bx, DefaultVoice as by, type AgentNetworkConfig as bz, type ToolAction as c, LegacyStep as d, Workflow as e, type Step as f, AgentNetwork as g, MCPServerBase as h, type Methods as i, type ApiRoute as j, type MastraAuthConfig as k, type ContextWithMastra as l, MastraAuthProvider as m, type MastraAuthProviderOptions as n, MastraStorage as o, type TABLE_NAMES as p, type StorageColumn as q, type StorageThreadType as r, type MastraMessageV2 as s, type StorageGetMessagesArg as t, type MastraMessageV1 as u, type WorkflowRuns as v, type WorkflowRun as w, type LegacyWorkflowRuns as x, type LegacyWorkflowRun as y, type PaginationArgs as z };
3609
+ export { type ActionContext as $, Agent as A, type StorageGetTracesArg as B, type CoreTool as C, TABLE_WORKFLOW_SNAPSHOT as D, type EvalRow as E, TABLE_EVALS as F, TABLE_MESSAGES as G, TABLE_THREADS as H, TABLE_TRACES as I, TABLE_SCHEMAS as J, type VariableReference$1 as K, LegacyWorkflow as L, Mastra as M, type StepResult$1 as N, type StepAction as O, type PaginationInfo as P, type LegacyWorkflowRunResult as Q, type WorkflowOptions as R, type StepExecutionContext as S, type ToolsInput as T, type StepVariableType as U, type VercelTool as V, type WorkflowContext as W, type StepNode as X, type StepGraph as Y, type RetryConfig as Z, type BaseCondition as _, type MastraPrimitives as a, type WorkingMemoryFormat as a$, WhenConditionReturnValue as a0, type StepDef as a1, type StepCondition as a2, type StepConfig as a3, type StepsRecord$1 as a4, type WorkflowLogMessage as a5, type WorkflowEvent as a6, type ResolverFunctionInput as a7, type ResolverFunctionOutput as a8, type SubscriberFunctionOutput as a9, type CoreToolMessage as aA, type EmbedResult as aB, type EmbedManyResult as aC, type BaseStructuredOutputType as aD, type StructuredOutputType as aE, type StructuredOutputArrayItem as aF, type StructuredOutput as aG, type GenerateReturn as aH, type StreamReturn as aI, type OutputType as aJ, type DefaultLLMTextOptions as aK, type DefaultLLMTextObjectOptions as aL, type DefaultLLMStreamOptions as aM, type DefaultLLMStreamObjectOptions as aN, type LLMTextOptions as aO, type LLMTextObjectOptions as aP, type LLMStreamOptions as aQ, type LLMInnerStreamOptions as aR, type LLMStreamObjectOptions as aS, createMockModel as aT, type Config as aU, type MessageType as aV, type MessageResponse as aW, type WorkingMemory as aX, type MemoryConfig as aY, type SharedMemoryConfig as aZ, type TraceType as a_, type DependencyCheckOutput as aa, type StepResolverOutput as ab, type WorkflowActors as ac, type WorkflowActionParams as ad, type WorkflowActions as ae, type LegacyWorkflowState as af, type StepId as ag, type ExtractSchemaFromStep$1 as ah, type ExtractStepResult as ai, type StepInputType as aj, type ExtractSchemaType$1 as ak, type PathsToStringProps$1 as al, type LegacyWorkflowRunState as am, type WorkflowResumeResult as an, Tool as ao, createTool as ap, type InternalCoreTool as aq, type ToolExecutionContext as ar, type AgentConfig as as, type DefaultEngineType as at, type WorkflowConfig as au, type LanguageModel as av, type CoreMessage as aw, type CoreSystemMessage as ax, type CoreAssistantMessage as ay, type CoreUserMessage as az, MastraMemory as b, type WorkingMemoryTemplate as b0, type MemoryProcessorOpts as b1, MemoryProcessor as b2, memoryDefaultOptions as b3, type StepFlowEntry as b4, type SerializedStep as b5, type SerializedStepFlowEntry as b6, createStep as b7, cloneStep as b8, createWorkflow as b9, CompositeVoice as bA, DefaultVoice as bB, type AgentNetworkConfig as bC, type ConvertedTool as bD, type MCPServerSSEOptions as bE, type MCPServerHonoSSEOptions as bF, type MCPServerHTTPOptions as bG, type Repository as bH, type VersionDetail as bI, type ArgumentInfo as bJ, type PositionalArgumentInfo as bK, type NamedArgumentInfo as bL, type SubcommandInfo as bM, type CommandInfo as bN, type EnvironmentVariableInfo as bO, type PackageInfo as bP, type RemoteInfo as bQ, type MCPServerConfig as bR, type ServerInfo as bS, type ServerDetailInfo as bT, type MCPToolType as bU, MessageList as bV, type ToolsetsInput as bW, type DynamicArgument as bX, type AgentGenerateOptions as bY, type AgentStreamOptions as bZ, type MastraMessageContentV2 as b_, cloneWorkflow as ba, type WorkflowResult as bb, Run as bc, type ExecutionGraph as bd, ExecutionEngine as be, type ExecuteFunction as bf, type StepSuccess as bg, type StepFailure as bh, type StepSuspended as bi, type StepRunning as bj, type StepResult as bk, type StepsRecord as bl, type DynamicMapping as bm, type PathsToStringProps as bn, type ExtractSchemaType as bo, type ExtractSchemaFromStep as bp, type VariableReference as bq, type StreamEvent as br, type WatchEvent as bs, type ZodPathType as bt, type WorkflowRunState as bu, type MastraLanguageModel as bv, type VoiceEventType as bw, type VoiceEventMap as bx, type VoiceConfig as by, MastraVoice as bz, type ToolAction as c, LegacyStep as d, Workflow as e, type Step as f, AgentNetwork as g, MCPServerBase as h, type Methods as i, type ApiRoute as j, type MastraAuthConfig as k, type ContextWithMastra as l, MastraAuthProvider as m, type MastraAuthProviderOptions as n, MastraStorage as o, type TABLE_NAMES as p, type StorageColumn as q, type StorageThreadType as r, type MastraMessageV2 as s, type StorageGetMessagesArg as t, type MastraMessageV1 as u, type WorkflowRuns as v, type WorkflowRun as w, type LegacyWorkflowRuns as x, type LegacyWorkflowRun as y, type PaginationArgs as z };
@@ -11,6 +11,7 @@ var ErrorDomain = /* @__PURE__ */ ((ErrorDomain2) => {
11
11
  ErrorDomain2["MASTRA_VECTOR"] = "MASTRA_VECTOR";
12
12
  ErrorDomain2["LLM"] = "LLM";
13
13
  ErrorDomain2["UNKNOWN"] = "UNKNOWN";
14
+ ErrorDomain2["DEPLOYER"] = "DEPLOYER";
14
15
  return ErrorDomain2;
15
16
  })(ErrorDomain || {});
16
17
  var ErrorCategory = /* @__PURE__ */ ((ErrorCategory2) => {
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkJ7MLMW6O_cjs = require('./chunk-J7MLMW6O.cjs');
3
+ var chunkUOKJ7SQO_cjs = require('./chunk-UOKJ7SQO.cjs');
4
4
  var crypto = require('crypto');
5
5
  var ai = require('ai');
6
6
  var providerUtils = require('@ai-sdk/provider-utils');
@@ -861,10 +861,10 @@ ${JSON.stringify(message, null, 2)}`
861
861
  };
862
862
  }
863
863
  static isVercelUIMessage(msg) {
864
- return !_MessageList.isMastraMessage(msg) && chunkJ7MLMW6O_cjs.isUiMessage(msg);
864
+ return !_MessageList.isMastraMessage(msg) && chunkUOKJ7SQO_cjs.isUiMessage(msg);
865
865
  }
866
866
  static isVercelCoreMessage(msg) {
867
- return !_MessageList.isMastraMessage(msg) && chunkJ7MLMW6O_cjs.isCoreMessage(msg);
867
+ return !_MessageList.isMastraMessage(msg) && chunkUOKJ7SQO_cjs.isCoreMessage(msg);
868
868
  }
869
869
  static isMastraMessage(msg) {
870
870
  return _MessageList.isMastraMessageV2(msg) || _MessageList.isMastraMessageV1(msg);
@@ -1,14 +1,14 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkLXFZUKP3_cjs = require('./chunk-LXFZUKP3.cjs');
4
- var chunkJDOKE3OQ_cjs = require('./chunk-JDOKE3OQ.cjs');
4
+ var chunkL5FURQXC_cjs = require('./chunk-L5FURQXC.cjs');
5
5
  var chunk2D7NOO7S_cjs = require('./chunk-2D7NOO7S.cjs');
6
6
  var chunkZIZ3CVHN_cjs = require('./chunk-ZIZ3CVHN.cjs');
7
7
  var chunkRWTSGWWL_cjs = require('./chunk-RWTSGWWL.cjs');
8
8
 
9
9
  // src/mastra/index.ts
10
10
  var _Mastra_decorators, _init;
11
- _Mastra_decorators = [chunkJDOKE3OQ_cjs.InstrumentClass({
11
+ _Mastra_decorators = [chunkL5FURQXC_cjs.InstrumentClass({
12
12
  prefix: "mastra",
13
13
  excludeMethods: ["getLogger", "getTelemetry"]
14
14
  })];
@@ -72,7 +72,7 @@ exports.Mastra = class Mastra {
72
72
  if (storage) {
73
73
  storage = chunkLXFZUKP3_cjs.augmentWithInit(storage);
74
74
  }
75
- this.#telemetry = chunkJDOKE3OQ_cjs.Telemetry.init(config?.telemetry);
75
+ this.#telemetry = chunkL5FURQXC_cjs.Telemetry.init(config?.telemetry);
76
76
  if (this.#telemetry && storage) {
77
77
  this.#storage = this.#telemetry.traceClass(storage, {
78
78
  excludeMethods: ["__setTelemetry", "__getTelemetry", "batchTraceInsert", "getTraces", "getEvalsByAgentName"]
@@ -323,7 +323,7 @@ do:
323
323
  }
324
324
  }
325
325
  setTelemetry(telemetry) {
326
- this.#telemetry = chunkJDOKE3OQ_cjs.Telemetry.init(telemetry);
326
+ this.#telemetry = chunkL5FURQXC_cjs.Telemetry.init(telemetry);
327
327
  if (this.#agents) {
328
328
  Object.keys(this.#agents).forEach(key => {
329
329
  if (this.#telemetry) {
@@ -1,4 +1,4 @@
1
- import { TABLE_WORKFLOW_SNAPSHOT, TABLE_EVALS, TABLE_MESSAGES, TABLE_THREADS, TABLE_TRACES, TABLE_SCHEMAS } from './chunk-BE2B3X5T.js';
1
+ import { TABLE_WORKFLOW_SNAPSHOT, TABLE_EVALS, TABLE_MESSAGES, TABLE_THREADS, TABLE_TRACES, TABLE_SCHEMAS } from './chunk-IFQGBW42.js';
2
2
  import { MastraBase } from './chunk-5IEKR756.js';
3
3
 
4
4
  // src/storage/base.ts
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var chunkJDOKE3OQ_cjs = require('./chunk-JDOKE3OQ.cjs');
4
- var chunkOLSQRA2V_cjs = require('./chunk-OLSQRA2V.cjs');
3
+ var chunkL5FURQXC_cjs = require('./chunk-L5FURQXC.cjs');
4
+ var chunkU3XRKJNN_cjs = require('./chunk-U3XRKJNN.cjs');
5
5
  var chunkP3Q73CAW_cjs = require('./chunk-P3Q73CAW.cjs');
6
6
  var chunkRWTSGWWL_cjs = require('./chunk-RWTSGWWL.cjs');
7
7
 
8
8
  // src/voice/voice.ts
9
9
  var _MastraVoice_decorators, _init, _a;
10
- _MastraVoice_decorators = [chunkJDOKE3OQ_cjs.InstrumentClass({
10
+ _MastraVoice_decorators = [chunkL5FURQXC_cjs.InstrumentClass({
11
11
  prefix: "voice",
12
12
  excludeMethods: ["__setTools", "__setLogger", "__setTelemetry", "#log"]
13
13
  })];
@@ -155,7 +155,7 @@ var CompositeVoice = class extends exports.MastraVoice {
155
155
  } else if (this.speakProvider) {
156
156
  return this.speakProvider.speak(input, options);
157
157
  }
158
- throw new chunkOLSQRA2V_cjs.MastraError({
158
+ throw new chunkU3XRKJNN_cjs.MastraError({
159
159
  id: "VOICE_COMPOSITE_NO_SPEAK_PROVIDER",
160
160
  text: "No speak provider or realtime provider configured",
161
161
  domain: "MASTRA_VOICE" /* MASTRA_VOICE */,
@@ -168,7 +168,7 @@ var CompositeVoice = class extends exports.MastraVoice {
168
168
  } else if (this.listenProvider) {
169
169
  return await this.listenProvider.listen(audioStream, options);
170
170
  }
171
- throw new chunkOLSQRA2V_cjs.MastraError({
171
+ throw new chunkU3XRKJNN_cjs.MastraError({
172
172
  id: "VOICE_COMPOSITE_NO_LISTEN_PROVIDER",
173
173
  text: "No listen provider or realtime provider configured",
174
174
  domain: "MASTRA_VOICE" /* MASTRA_VOICE */,
@@ -181,7 +181,7 @@ var CompositeVoice = class extends exports.MastraVoice {
181
181
  } else if (this.speakProvider) {
182
182
  return this.speakProvider.getSpeakers();
183
183
  }
184
- throw new chunkOLSQRA2V_cjs.MastraError({
184
+ throw new chunkU3XRKJNN_cjs.MastraError({
185
185
  id: "VOICE_COMPOSITE_NO_SPEAKERS_PROVIDER",
186
186
  text: "No speak provider or realtime provider configured",
187
187
  domain: "MASTRA_VOICE" /* MASTRA_VOICE */,
@@ -194,7 +194,7 @@ var CompositeVoice = class extends exports.MastraVoice {
194
194
  } else if (this.listenProvider) {
195
195
  return this.listenProvider.getListener();
196
196
  }
197
- throw new chunkOLSQRA2V_cjs.MastraError({
197
+ throw new chunkU3XRKJNN_cjs.MastraError({
198
198
  id: "VOICE_COMPOSITE_NO_LISTENER_PROVIDER",
199
199
  text: "No listener provider or realtime provider configured",
200
200
  domain: "MASTRA_VOICE" /* MASTRA_VOICE */,
@@ -213,7 +213,7 @@ var CompositeVoice = class extends exports.MastraVoice {
213
213
  */
214
214
  connect(options) {
215
215
  if (!this.realtimeProvider) {
216
- throw new chunkOLSQRA2V_cjs.MastraError({
216
+ throw new chunkU3XRKJNN_cjs.MastraError({
217
217
  id: "VOICE_COMPOSITE_NO_REALTIME_PROVIDER_CONNECT",
218
218
  text: "No realtime provider configured",
219
219
  domain: "MASTRA_VOICE" /* MASTRA_VOICE */,
@@ -228,7 +228,7 @@ var CompositeVoice = class extends exports.MastraVoice {
228
228
  */
229
229
  send(audioData) {
230
230
  if (!this.realtimeProvider) {
231
- throw new chunkOLSQRA2V_cjs.MastraError({
231
+ throw new chunkU3XRKJNN_cjs.MastraError({
232
232
  id: "VOICE_COMPOSITE_NO_REALTIME_PROVIDER_SEND",
233
233
  text: "No realtime provider configured",
234
234
  domain: "MASTRA_VOICE" /* MASTRA_VOICE */,
@@ -242,7 +242,7 @@ var CompositeVoice = class extends exports.MastraVoice {
242
242
  */
243
243
  answer(options) {
244
244
  if (!this.realtimeProvider) {
245
- throw new chunkOLSQRA2V_cjs.MastraError({
245
+ throw new chunkU3XRKJNN_cjs.MastraError({
246
246
  id: "VOICE_COMPOSITE_NO_REALTIME_PROVIDER_ANSWER",
247
247
  text: "No realtime provider configured",
248
248
  domain: "MASTRA_VOICE" /* MASTRA_VOICE */,
@@ -276,7 +276,7 @@ var CompositeVoice = class extends exports.MastraVoice {
276
276
  */
277
277
  close() {
278
278
  if (!this.realtimeProvider) {
279
- throw new chunkOLSQRA2V_cjs.MastraError({
279
+ throw new chunkU3XRKJNN_cjs.MastraError({
280
280
  id: "VOICE_COMPOSITE_NO_REALTIME_PROVIDER_CLOSE",
281
281
  text: "No realtime provider configured",
282
282
  domain: "MASTRA_VOICE" /* MASTRA_VOICE */,
@@ -292,7 +292,7 @@ var CompositeVoice = class extends exports.MastraVoice {
292
292
  */
293
293
  on(event, callback) {
294
294
  if (!this.realtimeProvider) {
295
- throw new chunkOLSQRA2V_cjs.MastraError({
295
+ throw new chunkU3XRKJNN_cjs.MastraError({
296
296
  id: "VOICE_COMPOSITE_NO_REALTIME_PROVIDER_ON",
297
297
  text: "No realtime provider configured",
298
298
  domain: "MASTRA_VOICE" /* MASTRA_VOICE */,
@@ -308,7 +308,7 @@ var CompositeVoice = class extends exports.MastraVoice {
308
308
  */
309
309
  off(event, callback) {
310
310
  if (!this.realtimeProvider) {
311
- throw new chunkOLSQRA2V_cjs.MastraError({
311
+ throw new chunkU3XRKJNN_cjs.MastraError({
312
312
  id: "VOICE_COMPOSITE_NO_REALTIME_PROVIDER_OFF",
313
313
  text: "No realtime provider configured",
314
314
  domain: "MASTRA_VOICE" /* MASTRA_VOICE */,
@@ -325,7 +325,7 @@ var DefaultVoice = class extends exports.MastraVoice {
325
325
  super();
326
326
  }
327
327
  async speak(_input) {
328
- throw new chunkOLSQRA2V_cjs.MastraError({
328
+ throw new chunkU3XRKJNN_cjs.MastraError({
329
329
  id: "VOICE_DEFAULT_NO_SPEAK_PROVIDER",
330
330
  text: "No voice provider configured",
331
331
  domain: "MASTRA_VOICE" /* MASTRA_VOICE */,
@@ -333,7 +333,7 @@ var DefaultVoice = class extends exports.MastraVoice {
333
333
  });
334
334
  }
335
335
  async listen(_input) {
336
- throw new chunkOLSQRA2V_cjs.MastraError({
336
+ throw new chunkU3XRKJNN_cjs.MastraError({
337
337
  id: "VOICE_DEFAULT_NO_LISTEN_PROVIDER",
338
338
  text: "No voice provider configured",
339
339
  domain: "MASTRA_VOICE" /* MASTRA_VOICE */,
@@ -341,7 +341,7 @@ var DefaultVoice = class extends exports.MastraVoice {
341
341
  });
342
342
  }
343
343
  async getSpeakers() {
344
- throw new chunkOLSQRA2V_cjs.MastraError({
344
+ throw new chunkU3XRKJNN_cjs.MastraError({
345
345
  id: "VOICE_DEFAULT_NO_SPEAKERS_PROVIDER",
346
346
  text: "No voice provider configured",
347
347
  domain: "MASTRA_VOICE" /* MASTRA_VOICE */,
@@ -349,7 +349,7 @@ var DefaultVoice = class extends exports.MastraVoice {
349
349
  });
350
350
  }
351
351
  async getListener() {
352
- throw new chunkOLSQRA2V_cjs.MastraError({
352
+ throw new chunkU3XRKJNN_cjs.MastraError({
353
353
  id: "VOICE_DEFAULT_NO_LISTENER_PROVIDER",
354
354
  text: "No voice provider configured",
355
355
  domain: "MASTRA_VOICE" /* MASTRA_VOICE */,
@@ -1,12 +1,12 @@
1
1
  'use strict';
2
2
 
3
- var chunkJDOKE3OQ_cjs = require('./chunk-JDOKE3OQ.cjs');
3
+ var chunkL5FURQXC_cjs = require('./chunk-L5FURQXC.cjs');
4
4
  var chunkP3Q73CAW_cjs = require('./chunk-P3Q73CAW.cjs');
5
5
  var chunkRWTSGWWL_cjs = require('./chunk-RWTSGWWL.cjs');
6
6
 
7
7
  // src/tts/index.ts
8
8
  var _MastraTTS_decorators, _init, _a;
9
- _MastraTTS_decorators = [chunkJDOKE3OQ_cjs.InstrumentClass({
9
+ _MastraTTS_decorators = [chunkL5FURQXC_cjs.InstrumentClass({
10
10
  prefix: "tts",
11
11
  excludeMethods: ["__setTools", "__setLogger", "__setTelemetry", "#log"]
12
12
  })];
@@ -1,5 +1,5 @@
1
- import { delay } from './chunk-3SY7GRSA.js';
2
- import { MastraError } from './chunk-LDNCERLU.js';
1
+ import { delay } from './chunk-HJQYQAIJ.js';
2
+ import { MastraError } from './chunk-4MPQAHTP.js';
3
3
  import { MastraBase } from './chunk-5IEKR756.js';
4
4
  import { RegisteredLogger } from './chunk-5YDTZN2X.js';
5
5
  import { OpenAIReasoningSchemaCompatLayer, OpenAISchemaCompatLayer, GoogleSchemaCompatLayer, AnthropicSchemaCompatLayer, DeepSeekSchemaCompatLayer, MetaSchemaCompatLayer, applyCompatLayer } from '@mastra/schema-compat';
@@ -1,6 +1,6 @@
1
1
  import { augmentWithInit } from './chunk-YOQP5T77.js';
2
- import { MessageList } from './chunk-DPKEVI6Q.js';
3
- import { deepMerge } from './chunk-3SY7GRSA.js';
2
+ import { MessageList } from './chunk-GTG6JWTV.js';
3
+ import { deepMerge } from './chunk-HJQYQAIJ.js';
4
4
  import { MastraBase } from './chunk-5IEKR756.js';
5
5
 
6
6
  // src/memory/memory.ts
@@ -101,6 +101,14 @@ https://mastra.ai/en/docs/memory/overview`
101
101
  async getSystemMessage(_input) {
102
102
  return null;
103
103
  }
104
+ /**
105
+ * Get a user context message to inject into the conversation.
106
+ * This will be called before each conversation turn.
107
+ * Implementations can override this to inject custom system messages.
108
+ */
109
+ async getUserContextMessage(_input) {
110
+ return null;
111
+ }
104
112
  /**
105
113
  * Get tools that should be available to the agent.
106
114
  * This will be called when converting tools for the agent.
@@ -128,7 +136,13 @@ https://mastra.ai/en/docs/memory/overview`
128
136
  if (config?.workingMemory && "use" in config.workingMemory) {
129
137
  throw new Error("The workingMemory.use option has been removed. Working memory always uses tool-call mode.");
130
138
  }
131
- return deepMerge(this.threadConfig, config || {});
139
+ const mergedConfig = deepMerge(this.threadConfig, config || {});
140
+ if (config?.workingMemory?.schema) {
141
+ if (mergedConfig.workingMemory) {
142
+ mergedConfig.workingMemory.schema = config.workingMemory.schema;
143
+ }
144
+ }
145
+ return mergedConfig;
132
146
  }
133
147
  /**
134
148
  * Apply all configured message processors to a list of messages.
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkAQRPDE2V_cjs = require('./chunk-AQRPDE2V.cjs');
3
+ var chunkHHQZ3NUR_cjs = require('./chunk-HHQZ3NUR.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 chunkAQRPDE2V_cjs.Agent({
41
+ this.agent = new chunkHHQZ3NUR_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.
@@ -1,7 +1,7 @@
1
1
  import { EMITTER_SYMBOL } from './chunk-Y7D2JLKS.js';
2
- import { Agent } from './chunk-ODKQT6IG.js';
2
+ import { Agent } from './chunk-UQ3K5POQ.js';
3
3
  import { Tool } from './chunk-C4LMN2IR.js';
4
- import { MastraError } from './chunk-LDNCERLU.js';
4
+ import { MastraError } from './chunk-4MPQAHTP.js';
5
5
  import { MastraBase } from './chunk-5IEKR756.js';
6
6
  import { RegisteredLogger } from './chunk-5YDTZN2X.js';
7
7
  import { RuntimeContext } from './chunk-SGGPJWRQ.js';