@mastra/core 0.2.0-alpha.88 → 0.2.0-alpha.89

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 (106) hide show
  1. package/dist/action/index.d.ts +2 -2
  2. package/dist/agent/index.d.ts +2 -2
  3. package/dist/agent/index.js +5 -5
  4. package/dist/base.d.ts +1 -1
  5. package/dist/base.js +2 -2
  6. package/dist/bundler/index.d.ts +1 -1
  7. package/dist/bundler/index.js +3 -3
  8. package/dist/{chunk-GTSK3JW4.js → chunk-654VMNVR.js} +3 -3
  9. package/dist/{chunk-SLWM3SEH.js → chunk-ADU6ZLCT.js} +1 -1
  10. package/dist/{chunk-XD5IQZRB.js → chunk-BCNHUSA6.js} +1 -1
  11. package/dist/{chunk-OOZGW5CY.js → chunk-FFZKACHZ.js} +1 -1
  12. package/dist/{chunk-SDLVJT2J.js → chunk-GTJIVA2D.js} +1 -1
  13. package/dist/{chunk-I3MJB67Z.js → chunk-HILJW64N.js} +14 -7
  14. package/dist/{chunk-TJK6TGSR.js → chunk-IO3KMCXV.js} +2 -1
  15. package/dist/{chunk-RCS7AVH6.js → chunk-J556NL2S.js} +1 -1
  16. package/dist/{chunk-OU2SP3L7.js → chunk-KHPTZCPA.js} +2 -2
  17. package/dist/{chunk-LUULSM4U.js → chunk-KNPBNSJ7.js} +65 -1
  18. package/dist/{chunk-U25DBVJZ.js → chunk-NIYVERVP.js} +1 -1
  19. package/dist/{chunk-CQYUMNLZ.js → chunk-RIATJJC3.js} +1 -1
  20. package/dist/{chunk-ELN2OU4M.js → chunk-SKEBFXFK.js} +29 -5
  21. package/dist/{chunk-JNVLA435.js → chunk-SMVXLIV7.js} +1 -1
  22. package/dist/{chunk-RH2Q6WKD.js → chunk-T5ZUXYWC.js} +1 -1
  23. package/dist/{chunk-JCRGAEY6.js → chunk-WLG2YHOZ.js} +1 -1
  24. package/dist/{chunk-747HUVPF.js → chunk-Y7YCQUOD.js} +3 -3
  25. package/dist/{chunk-EVYBUFXB.js → chunk-Z2KRB7Z4.js} +1 -1
  26. package/dist/deployer/index.d.ts +1 -1
  27. package/dist/deployer/index.js +4 -4
  28. package/dist/engine/index.d.ts +1 -1
  29. package/dist/engine/index.js +3 -3
  30. package/dist/eval/index.d.ts +2 -2
  31. package/dist/{index-B0-NXUYv.d.ts → index-Cktbxvxx.d.ts} +1 -0
  32. package/dist/{index-Duqv1Yom.d.ts → index-D-mqcYwN.d.ts} +20 -5
  33. package/dist/index.d.ts +7 -7
  34. package/dist/index.js +19 -19
  35. package/dist/integration/index.d.ts +3 -3
  36. package/dist/llm/index.d.ts +2 -2
  37. package/dist/llm/index.js +4 -4
  38. package/dist/llm/model/providers/anthropic-vertex.d.ts +3 -3
  39. package/dist/llm/model/providers/anthropic-vertex.js +4 -4
  40. package/dist/llm/model/providers/anthropic.d.ts +3 -3
  41. package/dist/llm/model/providers/anthropic.js +4 -4
  42. package/dist/llm/model/providers/azure.d.ts +3 -3
  43. package/dist/llm/model/providers/azure.js +4 -4
  44. package/dist/llm/model/providers/baseten.d.ts +3 -3
  45. package/dist/llm/model/providers/baseten.js +5 -5
  46. package/dist/llm/model/providers/bedrock.d.ts +3 -3
  47. package/dist/llm/model/providers/bedrock.js +4 -4
  48. package/dist/llm/model/providers/cerebras.d.ts +3 -3
  49. package/dist/llm/model/providers/cerebras.js +4 -4
  50. package/dist/llm/model/providers/cohere.d.ts +3 -3
  51. package/dist/llm/model/providers/cohere.js +4 -4
  52. package/dist/llm/model/providers/deepinfra.d.ts +3 -3
  53. package/dist/llm/model/providers/deepinfra.js +4 -4
  54. package/dist/llm/model/providers/deepseek.d.ts +3 -3
  55. package/dist/llm/model/providers/deepseek.js +4 -4
  56. package/dist/llm/model/providers/fireworks.d.ts +3 -3
  57. package/dist/llm/model/providers/fireworks.js +4 -4
  58. package/dist/llm/model/providers/google-vertex.d.ts +3 -3
  59. package/dist/llm/model/providers/google-vertex.js +4 -4
  60. package/dist/llm/model/providers/google.d.ts +3 -3
  61. package/dist/llm/model/providers/google.js +4 -4
  62. package/dist/llm/model/providers/grok.d.ts +3 -3
  63. package/dist/llm/model/providers/grok.js +4 -4
  64. package/dist/llm/model/providers/groq.d.ts +3 -3
  65. package/dist/llm/model/providers/groq.js +4 -4
  66. package/dist/llm/model/providers/lmstudio.d.ts +3 -3
  67. package/dist/llm/model/providers/lmstudio.js +5 -5
  68. package/dist/llm/model/providers/mistral.d.ts +3 -3
  69. package/dist/llm/model/providers/mistral.js +4 -4
  70. package/dist/llm/model/providers/mock.d.ts +3 -3
  71. package/dist/llm/model/providers/mock.js +4 -4
  72. package/dist/llm/model/providers/ollama.d.ts +3 -3
  73. package/dist/llm/model/providers/ollama.js +4 -4
  74. package/dist/llm/model/providers/openai-compat.d.ts +3 -3
  75. package/dist/llm/model/providers/openai-compat.js +5 -5
  76. package/dist/llm/model/providers/openai.d.ts +3 -3
  77. package/dist/llm/model/providers/openai.js +5 -5
  78. package/dist/llm/model/providers/openai.test.js +5 -5
  79. package/dist/llm/model/providers/perplexity.d.ts +3 -3
  80. package/dist/llm/model/providers/perplexity.js +4 -4
  81. package/dist/llm/model/providers/portkey.d.ts +3 -3
  82. package/dist/llm/model/providers/portkey.js +4 -4
  83. package/dist/llm/model/providers/togetherai.d.ts +3 -3
  84. package/dist/llm/model/providers/togetherai.js +4 -4
  85. package/dist/logger/index.d.ts +1 -1
  86. package/dist/logger/index.js +1 -1
  87. package/dist/mastra/index.d.ts +3 -3
  88. package/dist/mastra/index.js +5 -5
  89. package/dist/memory/index.d.ts +2 -2
  90. package/dist/memory/index.js +4 -3
  91. package/dist/{model-QGWIMOSx.d.ts → model-CD0nIpJn.d.ts} +1 -1
  92. package/dist/relevance/index.d.ts +2 -2
  93. package/dist/relevance/index.js +6 -6
  94. package/dist/storage/index.d.ts +3 -3
  95. package/dist/storage/index.js +3 -3
  96. package/dist/tools/index.d.ts +3 -3
  97. package/dist/tts/index.d.ts +1 -1
  98. package/dist/tts/index.js +3 -3
  99. package/dist/utils.d.ts +20 -1
  100. package/dist/utils.js +1 -1
  101. package/dist/vector/index.d.ts +1 -1
  102. package/dist/vector/index.js +3 -3
  103. package/dist/{workflow-DQ8CtzzU.d.ts → workflow-4u4hE9mG.d.ts} +1 -1
  104. package/dist/workflows/index.d.ts +4 -4
  105. package/dist/workflows/index.js +3 -3
  106. package/package.json +9 -2
@@ -1,7 +1,7 @@
1
1
  import 'zod';
2
- export { I as IAction, aT as IExecutionContext, d as MastraPrimitives } from '../index-Duqv1Yom.js';
2
+ export { I as IAction, aT as IExecutionContext, d as MastraPrimitives } from '../index-D-mqcYwN.js';
3
3
  import '../engine-EwEG-4Iv.js';
4
- import '../index-B0-NXUYv.js';
4
+ import '../index-Cktbxvxx.js';
5
5
  import '../telemetry-oCUM52DG.js';
6
6
  import '../tts/index.js';
7
7
  import '../vector/index.js';
@@ -1,11 +1,11 @@
1
1
  import 'ai';
2
2
  import 'json-schema';
3
3
  import 'zod';
4
- export { A as Agent } from '../index-Duqv1Yom.js';
4
+ export { A as Agent } from '../index-D-mqcYwN.js';
5
5
  import '../base.js';
6
6
  import '../metric-D2V4CR8D.js';
7
7
  import '../telemetry-oCUM52DG.js';
8
- import '../index-B0-NXUYv.js';
8
+ import '../index-Cktbxvxx.js';
9
9
  import 'pino';
10
10
  import 'stream';
11
11
  import 'sift';
@@ -1,9 +1,9 @@
1
- export { Agent } from '../chunk-ELN2OU4M.js';
1
+ export { Agent } from '../chunk-SKEBFXFK.js';
2
2
  import '../chunk-HBTQNIAX.js';
3
3
  import '../chunk-SDKEPBBH.js';
4
- import '../chunk-747HUVPF.js';
4
+ import '../chunk-Y7YCQUOD.js';
5
5
  import '../chunk-6ZVFVYLE.js';
6
- import '../chunk-LUULSM4U.js';
7
- import '../chunk-JCRGAEY6.js';
8
- import '../chunk-TJK6TGSR.js';
6
+ import '../chunk-KNPBNSJ7.js';
7
+ import '../chunk-WLG2YHOZ.js';
8
+ import '../chunk-IO3KMCXV.js';
9
9
  import '../chunk-AJJZUHB4.js';
package/dist/base.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _opentelemetry_api from '@opentelemetry/api';
2
- import { R as RegisteredLogger, L as Logger, a as LogLevel } from './index-B0-NXUYv.js';
2
+ import { R as RegisteredLogger, L as Logger, a as LogLevel } from './index-Cktbxvxx.js';
3
3
  import { T as Telemetry } from './telemetry-oCUM52DG.js';
4
4
  import 'pino';
5
5
  import 'stream';
package/dist/base.js CHANGED
@@ -1,3 +1,3 @@
1
- export { MastraBase } from './chunk-JCRGAEY6.js';
2
- import './chunk-TJK6TGSR.js';
1
+ export { MastraBase } from './chunk-WLG2YHOZ.js';
2
+ import './chunk-IO3KMCXV.js';
3
3
  import './chunk-AJJZUHB4.js';
@@ -1,6 +1,6 @@
1
1
  import { MastraBase } from '../base.js';
2
2
  import '@opentelemetry/api';
3
- import '../index-B0-NXUYv.js';
3
+ import '../index-Cktbxvxx.js';
4
4
  import 'pino';
5
5
  import 'stream';
6
6
  import '../telemetry-oCUM52DG.js';
@@ -1,4 +1,4 @@
1
- export { MastraBundler } from '../chunk-CQYUMNLZ.js';
2
- import '../chunk-JCRGAEY6.js';
3
- import '../chunk-TJK6TGSR.js';
1
+ export { MastraBundler } from '../chunk-RIATJJC3.js';
2
+ import '../chunk-WLG2YHOZ.js';
3
+ import '../chunk-IO3KMCXV.js';
4
4
  import '../chunk-AJJZUHB4.js';
@@ -1,6 +1,6 @@
1
- import { delay } from './chunk-LUULSM4U.js';
2
- import { MastraBase } from './chunk-JCRGAEY6.js';
3
- import { RegisteredLogger } from './chunk-TJK6TGSR.js';
1
+ import { delay } from './chunk-KNPBNSJ7.js';
2
+ import { MastraBase } from './chunk-WLG2YHOZ.js';
3
+ import { RegisteredLogger } from './chunk-IO3KMCXV.js';
4
4
  import { __name, __privateAdd, __privateSet, __privateGet } from './chunk-AJJZUHB4.js';
5
5
  import { generateText, jsonSchema, generateObject, streamText, streamObject } from 'ai';
6
6
  import { z } from 'zod';
@@ -1,5 +1,5 @@
1
1
  import { InstrumentClass } from './chunk-6ZVFVYLE.js';
2
- import { MastraBase } from './chunk-JCRGAEY6.js';
2
+ import { MastraBase } from './chunk-WLG2YHOZ.js';
3
3
  import { __name, __publicField } from './chunk-AJJZUHB4.js';
4
4
 
5
5
  // src/tts/index.ts
@@ -1,4 +1,4 @@
1
- import { MastraBundler } from './chunk-CQYUMNLZ.js';
1
+ import { MastraBundler } from './chunk-RIATJJC3.js';
2
2
  import { __name } from './chunk-AJJZUHB4.js';
3
3
 
4
4
  // src/deployer/index.ts
@@ -1,4 +1,4 @@
1
- import { MastraBase } from './chunk-JCRGAEY6.js';
1
+ import { MastraBase } from './chunk-WLG2YHOZ.js';
2
2
  import { __name, __publicField, __privateAdd, __privateSet, __privateGet, __privateMethod } from './chunk-AJJZUHB4.js';
3
3
  import { get } from 'radash';
4
4
  import sift from 'sift';
@@ -1,4 +1,4 @@
1
- import { MastraLLM } from './chunk-GTSK3JW4.js';
1
+ import { MastraLLM } from './chunk-654VMNVR.js';
2
2
  import { __name } from './chunk-AJJZUHB4.js';
3
3
  import { createOpenAI } from '@ai-sdk/openai';
4
4
 
@@ -1,4 +1,5 @@
1
- import { MastraBase } from './chunk-JCRGAEY6.js';
1
+ import { deepMerge } from './chunk-KNPBNSJ7.js';
2
+ import { MastraBase } from './chunk-WLG2YHOZ.js';
2
3
  import { __name, __publicField } from './chunk-AJJZUHB4.js';
3
4
 
4
5
  // src/memory/index.ts
@@ -28,6 +29,14 @@ var _MastraMemory = class _MastraMemory extends MastraBase {
28
29
  this.threadConfig = this.getMergedThreadConfig(config.options);
29
30
  }
30
31
  }
32
+ /**
33
+ * Get a system message to inject into the conversation.
34
+ * This will be called before each conversation turn.
35
+ * Implementations can override this to inject custom system messages.
36
+ */
37
+ async getSystemMessage(_input) {
38
+ return null;
39
+ }
31
40
  parseEmbeddingOptions() {
32
41
  if (!this.embedding) {
33
42
  throw new Error(`Cannot use vector features without setting new Memory({ embedding: { ... } })`);
@@ -35,10 +44,7 @@ var _MastraMemory = class _MastraMemory extends MastraBase {
35
44
  return this.embedding;
36
45
  }
37
46
  getMergedThreadConfig(config) {
38
- return {
39
- ...this.threadConfig,
40
- ...config
41
- };
47
+ return deepMerge(this.threadConfig, config || {});
42
48
  }
43
49
  estimateTokens(text) {
44
50
  return Math.ceil(text.split(" ").length * 1.3);
@@ -127,7 +133,7 @@ var _MastraMemory = class _MastraMemory extends MastraBase {
127
133
  * @param metadata - Optional metadata for the thread
128
134
  * @returns Promise resolving to the created thread
129
135
  */
130
- async createThread({ threadId, resourceId, title, metadata }) {
136
+ async createThread({ threadId, resourceId, title, metadata, memoryConfig }) {
131
137
  const thread = {
132
138
  id: threadId || this.generateId(),
133
139
  title,
@@ -137,7 +143,8 @@ var _MastraMemory = class _MastraMemory extends MastraBase {
137
143
  metadata
138
144
  };
139
145
  return this.saveThread({
140
- thread
146
+ thread,
147
+ memoryConfig
141
148
  });
142
149
  }
143
150
  /**
@@ -13,7 +13,8 @@ var RegisteredLogger = {
13
13
  DEPLOYER: "DEPLOYER",
14
14
  ENGINE: "ENGINE",
15
15
  MEMORY: "MEMORY",
16
- STORAGE: "STORAGE"
16
+ STORAGE: "STORAGE",
17
+ EMBEDDINGS: "EMBEDDINGS"
17
18
  };
18
19
  var LogLevel = {
19
20
  DEBUG: "debug",
@@ -1,5 +1,5 @@
1
- import { MastraBase } from './chunk-JCRGAEY6.js';
2
1
  import { embed, embedMany } from './chunk-5NQ3MEZM.js';
2
+ import { MastraBase } from './chunk-WLG2YHOZ.js';
3
3
  import { __name } from './chunk-AJJZUHB4.js';
4
4
 
5
5
  // src/vector/index.ts
@@ -1,7 +1,7 @@
1
1
  import { Telemetry } from './chunk-SDKEPBBH.js';
2
- import { LLM } from './chunk-747HUVPF.js';
2
+ import { LLM } from './chunk-Y7YCQUOD.js';
3
3
  import { InstrumentClass } from './chunk-6ZVFVYLE.js';
4
- import { LogLevel, createLogger, noopLogger } from './chunk-TJK6TGSR.js';
4
+ import { LogLevel, createLogger, noopLogger } from './chunk-IO3KMCXV.js';
5
5
  import { __name, __publicField } from './chunk-AJJZUHB4.js';
6
6
  import 'dotenv/config';
7
7
 
@@ -77,5 +77,69 @@ Examples: ${value.examples.join(", ")}` : ""));
77
77
  return z.object(zodSchema);
78
78
  }
79
79
  __name(jsonSchemaToModel, "jsonSchemaToModel");
80
+ function deepMerge(target, source) {
81
+ const output = {
82
+ ...target
83
+ };
84
+ if (!source) return output;
85
+ Object.keys(source).forEach((key) => {
86
+ const targetValue = output[key];
87
+ const sourceValue = source[key];
88
+ if (Array.isArray(targetValue) && Array.isArray(sourceValue)) {
89
+ output[key] = sourceValue;
90
+ } else if (sourceValue instanceof Object && targetValue instanceof Object && !Array.isArray(sourceValue) && !Array.isArray(targetValue)) {
91
+ output[key] = deepMerge(targetValue, sourceValue);
92
+ } else if (sourceValue !== undefined) {
93
+ output[key] = sourceValue;
94
+ }
95
+ });
96
+ return output;
97
+ }
98
+ __name(deepMerge, "deepMerge");
99
+ async function* maskStreamTags(stream, tag, options = {}) {
100
+ const { onStart, onEnd, onMask } = options;
101
+ const openTag = `<${tag}>`;
102
+ const closeTag = `</${tag}>`;
103
+ let buffer = "";
104
+ let fullContent = "";
105
+ let isMasking = false;
106
+ let isBuffering = false;
107
+ const startsWith = /* @__PURE__ */ __name((text, pattern) => text.trim().startsWith(pattern.trim()), "startsWith");
108
+ for await (const chunk of stream) {
109
+ fullContent += chunk;
110
+ if (isBuffering) buffer += chunk;
111
+ const chunkHasTag = startsWith(chunk, openTag);
112
+ const bufferHasTag = !chunkHasTag && isBuffering && startsWith(openTag, buffer);
113
+ if (!isMasking && (chunkHasTag || bufferHasTag)) {
114
+ isMasking = true;
115
+ isBuffering = false;
116
+ buffer = "";
117
+ onStart?.();
118
+ }
119
+ if (!isMasking && !isBuffering && startsWith(openTag, chunk) && chunk.trim() !== "") {
120
+ isBuffering = true;
121
+ buffer += chunk;
122
+ continue;
123
+ }
124
+ if (isBuffering && buffer && !startsWith(openTag, buffer)) {
125
+ yield buffer;
126
+ buffer = "";
127
+ isBuffering = false;
128
+ continue;
129
+ }
130
+ if (isMasking && fullContent.trim().includes(closeTag)) {
131
+ onMask?.(chunk);
132
+ onEnd?.();
133
+ isMasking = false;
134
+ continue;
135
+ }
136
+ if (isMasking) {
137
+ onMask?.(chunk);
138
+ continue;
139
+ }
140
+ yield chunk;
141
+ }
142
+ }
143
+ __name(maskStreamTags, "maskStreamTags");
80
144
 
81
- export { delay, jsonSchemaPropertiesToTSTypes, jsonSchemaToModel };
145
+ export { deepMerge, delay, jsonSchemaPropertiesToTSTypes, jsonSchemaToModel, maskStreamTags };
@@ -1,4 +1,4 @@
1
- import { MastraBase } from './chunk-JCRGAEY6.js';
1
+ import { MastraBase } from './chunk-WLG2YHOZ.js';
2
2
  import { __name, __publicField } from './chunk-AJJZUHB4.js';
3
3
 
4
4
  // src/engine/types.ts
@@ -1,4 +1,4 @@
1
- import { MastraBase } from './chunk-JCRGAEY6.js';
1
+ import { MastraBase } from './chunk-WLG2YHOZ.js';
2
2
  import { __name } from './chunk-AJJZUHB4.js';
3
3
  import dotenv from 'dotenv';
4
4
  import { readFile } from 'fs/promises';
@@ -1,8 +1,8 @@
1
1
  import { executeHook, AvailableHooks } from './chunk-HBTQNIAX.js';
2
- import { LLM } from './chunk-747HUVPF.js';
2
+ import { LLM } from './chunk-Y7YCQUOD.js';
3
3
  import { InstrumentClass } from './chunk-6ZVFVYLE.js';
4
- import { MastraBase } from './chunk-JCRGAEY6.js';
5
- import { RegisteredLogger, LogLevel } from './chunk-TJK6TGSR.js';
4
+ import { MastraBase } from './chunk-WLG2YHOZ.js';
5
+ import { RegisteredLogger, LogLevel } from './chunk-IO3KMCXV.js';
6
6
  import { __name, __publicField, __privateAdd, __privateSet, __privateGet } from './chunk-AJJZUHB4.js';
7
7
  import { randomUUID } from 'crypto';
8
8
  import { z } from 'zod';
@@ -146,7 +146,8 @@ var _Agent = class _Agent extends MastraBase {
146
146
  thread = await memory.createThread({
147
147
  threadId,
148
148
  resourceId,
149
- title
149
+ title,
150
+ memoryConfig
150
151
  });
151
152
  } else {
152
153
  thread = await memory.getThreadById({
@@ -160,7 +161,8 @@ var _Agent = class _Agent extends MastraBase {
160
161
  thread = await memory.createThread({
161
162
  threadId,
162
163
  resourceId,
163
- title
164
+ title,
165
+ memoryConfig
164
166
  });
165
167
  }
166
168
  }
@@ -234,9 +236,31 @@ var _Agent = class _Agent extends MastraBase {
234
236
  threadId: thread.id,
235
237
  runId
236
238
  });
239
+ const memorySystemMessage = memory && threadId ? await memory.getSystemMessage({
240
+ threadId,
241
+ memoryConfig
242
+ }) : null;
237
243
  return {
238
244
  threadId: thread.id,
239
245
  messages: [
246
+ {
247
+ role: "system",
248
+ content: `
249
+
250
+ Analyze this message to determine if the user is referring to a previous conversation with the LLM.
251
+ Specifically, identify if the user wants to reference specific information from that chat or if they want the LLM to use the previous chat messages as context for the current conversation.
252
+ Extract any date ranges mentioned in the user message that could help identify the previous chat.
253
+ Return dates in ISO format.
254
+ If no specific dates are mentioned but time periods are (like "last week" or "past month"), calculate the appropriate date range.
255
+ For the end date, return the date 1 day after the end of the time period.
256
+ Today's date is ${(/* @__PURE__ */ new Date()).toISOString()} and the time is ${(/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", {
257
+ hour: "numeric",
258
+ minute: "numeric",
259
+ hour12: true
260
+ })} ${memorySystemMessage ? `
261
+
262
+ ${memorySystemMessage}` : ""}`
263
+ },
240
264
  ...memoryMessages,
241
265
  ...newMessages
242
266
  ]
@@ -1,4 +1,4 @@
1
- import { Agent } from './chunk-ELN2OU4M.js';
1
+ import { Agent } from './chunk-SKEBFXFK.js';
2
2
  import { __name, __publicField } from './chunk-AJJZUHB4.js';
3
3
  import { CohereClient } from 'cohere-ai';
4
4
 
@@ -1,4 +1,4 @@
1
- import { MastraLLM } from './chunk-GTSK3JW4.js';
1
+ import { MastraLLM } from './chunk-654VMNVR.js';
2
2
  import { __name } from './chunk-AJJZUHB4.js';
3
3
  import { createOpenAI } from '@ai-sdk/openai';
4
4
 
@@ -1,4 +1,4 @@
1
- import { RegisteredLogger, createLogger } from './chunk-TJK6TGSR.js';
1
+ import { RegisteredLogger, createLogger } from './chunk-IO3KMCXV.js';
2
2
  import { __name, __publicField } from './chunk-AJJZUHB4.js';
3
3
 
4
4
  // src/base.ts
@@ -1,7 +1,7 @@
1
1
  import { InstrumentClass } from './chunk-6ZVFVYLE.js';
2
- import { delay } from './chunk-LUULSM4U.js';
3
- import { MastraBase } from './chunk-JCRGAEY6.js';
4
- import { RegisteredLogger, LogLevel } from './chunk-TJK6TGSR.js';
2
+ import { delay } from './chunk-KNPBNSJ7.js';
3
+ import { MastraBase } from './chunk-WLG2YHOZ.js';
4
+ import { RegisteredLogger, LogLevel } from './chunk-IO3KMCXV.js';
5
5
  import { __name, __privateAdd, __privateSet, __privateGet } from './chunk-AJJZUHB4.js';
6
6
  import { createAmazonBedrock } from '@ai-sdk/amazon-bedrock';
7
7
  import { createAnthropic } from '@ai-sdk/anthropic';
@@ -1,4 +1,4 @@
1
- import { MastraBase } from './chunk-JCRGAEY6.js';
1
+ import { MastraBase } from './chunk-WLG2YHOZ.js';
2
2
  import { __name, __publicField } from './chunk-AJJZUHB4.js';
3
3
  import { createClient } from '@libsql/client';
4
4
 
@@ -1,7 +1,7 @@
1
1
  import { MastraBundler } from '../bundler/index.js';
2
2
  import '../base.js';
3
3
  import '@opentelemetry/api';
4
- import '../index-B0-NXUYv.js';
4
+ import '../index-Cktbxvxx.js';
5
5
  import 'pino';
6
6
  import 'stream';
7
7
  import '../telemetry-oCUM52DG.js';
@@ -1,5 +1,5 @@
1
- export { MastraDeployer } from '../chunk-XD5IQZRB.js';
2
- import '../chunk-CQYUMNLZ.js';
3
- import '../chunk-JCRGAEY6.js';
4
- import '../chunk-TJK6TGSR.js';
1
+ export { MastraDeployer } from '../chunk-BCNHUSA6.js';
2
+ import '../chunk-RIATJJC3.js';
3
+ import '../chunk-WLG2YHOZ.js';
4
+ import '../chunk-IO3KMCXV.js';
5
5
  import '../chunk-AJJZUHB4.js';
@@ -2,7 +2,7 @@ import { M as MastraEngine, D as DatabaseConfig, B as BaseEntity, a as BaseRecor
2
2
  export { b as FilterCondition, F as FilterOperators, P as PropertyType, S as SortOrder } from '../engine-EwEG-4Iv.js';
3
3
  import '../base.js';
4
4
  import '@opentelemetry/api';
5
- import '../index-B0-NXUYv.js';
5
+ import '../index-Cktbxvxx.js';
6
6
  import 'pino';
7
7
  import 'stream';
8
8
  import '../telemetry-oCUM52DG.js';
@@ -1,4 +1,4 @@
1
- export { FilterOperators, MastraEngine, MockMastraEngine, PropertyType } from '../chunk-U25DBVJZ.js';
2
- import '../chunk-JCRGAEY6.js';
3
- import '../chunk-TJK6TGSR.js';
1
+ export { FilterOperators, MastraEngine, MockMastraEngine, PropertyType } from '../chunk-NIYVERVP.js';
2
+ import '../chunk-WLG2YHOZ.js';
3
+ import '../chunk-IO3KMCXV.js';
4
4
  import '../chunk-AJJZUHB4.js';
@@ -1,11 +1,11 @@
1
1
  import { M as Metric, a as MetricResult } from '../metric-D2V4CR8D.js';
2
- import { A as Agent } from '../index-Duqv1Yom.js';
2
+ import { A as Agent } from '../index-D-mqcYwN.js';
3
3
  import 'ai';
4
4
  import 'json-schema';
5
5
  import 'zod';
6
6
  import '../base.js';
7
7
  import '@opentelemetry/api';
8
- import '../index-B0-NXUYv.js';
8
+ import '../index-Cktbxvxx.js';
9
9
  import 'pino';
10
10
  import 'stream';
11
11
  import '../telemetry-oCUM52DG.js';
@@ -18,6 +18,7 @@ declare const RegisteredLogger: {
18
18
  readonly ENGINE: "ENGINE";
19
19
  readonly MEMORY: "MEMORY";
20
20
  readonly STORAGE: "STORAGE";
21
+ readonly EMBEDDINGS: "EMBEDDINGS";
21
22
  };
22
23
  type RegisteredLogger = (typeof RegisteredLogger)[keyof typeof RegisteredLogger];
23
24
  declare const LogLevel: {
@@ -5,7 +5,7 @@ import { z, ZodSchema } from 'zod';
5
5
  import { MastraBase } from './base.js';
6
6
  import { M as Metric } from './metric-D2V4CR8D.js';
7
7
  import { T as Telemetry } from './telemetry-oCUM52DG.js';
8
- import { B as BaseLogMessage, R as RegisteredLogger, b as Run, L as Logger } from './index-B0-NXUYv.js';
8
+ import { B as BaseLogMessage, R as RegisteredLogger, b as Run, L as Logger } from './index-Cktbxvxx.js';
9
9
  import { Query } from 'sift';
10
10
  import { E as EmbeddingOptions } from './types-M16hSruO.js';
11
11
  import { MastraVector } from './vector/index.js';
@@ -719,6 +719,10 @@ type MemoryConfig = {
719
719
  after: number;
720
720
  };
721
721
  };
722
+ workingMemory?: {
723
+ enabled: boolean;
724
+ template?: string;
725
+ };
722
726
  };
723
727
  type SharedMemoryConfig = {
724
728
  storage: MastraStorage;
@@ -744,8 +748,17 @@ declare abstract class MastraMemory extends MastraBase {
744
748
  constructor(config: {
745
749
  name: string;
746
750
  } & SharedMemoryConfig);
751
+ /**
752
+ * Get a system message to inject into the conversation.
753
+ * This will be called before each conversation turn.
754
+ * Implementations can override this to inject custom system messages.
755
+ */
756
+ getSystemMessage(_input: {
757
+ threadId: string;
758
+ memoryConfig?: MemoryConfig;
759
+ }): Promise<string | null>;
747
760
  protected parseEmbeddingOptions(): EmbeddingOptions;
748
- protected getMergedThreadConfig(config: MemoryConfig): MemoryConfig;
761
+ protected getMergedThreadConfig(config?: MemoryConfig): MemoryConfig;
749
762
  abstract rememberMessages({ threadId, vectorMessageSearch, config, }: {
750
763
  threadId: string;
751
764
  vectorMessageSearch?: string;
@@ -773,8 +786,9 @@ declare abstract class MastraMemory extends MastraBase {
773
786
  * @param thread - The thread data to save
774
787
  * @returns Promise resolving to the saved thread
775
788
  */
776
- abstract saveThread({ thread }: {
789
+ abstract saveThread({ thread, memoryConfig, }: {
777
790
  thread: StorageThreadType;
791
+ memoryConfig?: MemoryConfig;
778
792
  }): Promise<StorageThreadType>;
779
793
  /**
780
794
  * Saves messages to a thread
@@ -800,11 +814,12 @@ declare abstract class MastraMemory extends MastraBase {
800
814
  * @param metadata - Optional metadata for the thread
801
815
  * @returns Promise resolving to the created thread
802
816
  */
803
- createThread({ threadId, resourceId, title, metadata, }: {
817
+ createThread({ threadId, resourceId, title, metadata, memoryConfig, }: {
804
818
  resourceId: string;
805
819
  threadId?: string;
806
820
  title?: string;
807
821
  metadata?: Record<string, unknown>;
822
+ memoryConfig?: MemoryConfig;
808
823
  }): Promise<StorageThreadType>;
809
824
  /**
810
825
  * Helper method to delete a thread
@@ -1008,7 +1023,7 @@ declare class Agent<TTools extends Record<string, ToolAction<any, any, any, any>
1008
1023
  runId?: string;
1009
1024
  }): Promise<{
1010
1025
  threadId: string;
1011
- messages: CoreMessage$1[];
1026
+ messages: any[];
1012
1027
  }>;
1013
1028
  saveResponse({ result, threadId, resourceId, runId, memoryConfig, }: {
1014
1029
  runId: string;
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import { M as Metric } from './metric-D2V4CR8D.js';
2
2
  export { a as MetricResult } from './metric-D2V4CR8D.js';
3
- import { q as ToolAction, A as Agent$1, r as AgentConfig, M as MastraStorage$1, a as MastraMemory$1, s as ToolExecutionContext, W as WorkflowOptions } from './index-Duqv1Yom.js';
4
- export { az as ActionContext, aq as AiMessageType, ah as AmazonConfig, ag as AmazonModel, Q as AnthropicConfig, P as AnthropicModel, aj as AnthropicVertexConfig, ai as AnthropicVertexModel, ad as AzureConfig, ac as AzureModel, ay as BaseCondition, al as BaseStructuredOutputType, a2 as BaseTenConfig, a1 as BasetenModel, ab as CohereConfig, aa as CohereModel, z as CoreAssistantMessage, x as CoreMessage, y as CoreSystemMessage, C as CoreTool, D as CoreToolMessage, B as CoreUserMessage, a9 as CustomModelConfig, af as DeepseekConfig, ae as DeepseekModel, aI as DependencyCheckOutput, F as EmbedManyResult, E as EmbedResult, aO as ExtractSchemaFromStep, aR as ExtractSchemaType, aP as ExtractStepResult, a4 as FireworksConfig, a3 as FireworksModel, G as GenerateReturn, K as GoogleConfig, N as GoogleGenerativeAISettings, J as GoogleModel, V as GroqConfig, U as GroqModel, g as LLMInnerStreamOptions, ak as LLMProvider, h as LLMStreamObjectOptions, i as LLMStreamOptions, f as LLMTextObjectOptions, e as LLMTextOptions, a0 as LMStudioConfig, $ as LMStudioModel, au as MemoryConfig, at as MessageResponse, ar as MessageType, a6 as MistralConfig, a5 as MistralModel, b as ModelConfig, H as OpenAIConfig, O as OpenAIModel, ap as OutputType, aS as PathsToStringProps, Y as PerplexityConfig, X as PerplexityModel, aF as ResolverFunctionInput, aG as ResolverFunctionOutput, R as RetryConfig, av as SharedMemoryConfig, k as StepAction, aB as StepCondition, m as StepConfig, aA as StepDef, j as StepExecutionContext, p as StepGraph, aN as StepId, aQ as StepInputType, aw as StepNode, n as StepResult, l as StepVariableType, u as StorageColumn, w as StorageGetMessagesArg, as as StorageThreadType, S as StreamReturn, ao as StructuredOutput, an as StructuredOutputArrayItem, am as StructuredOutputType, aH as SubscriberFunctionOutput, t as TABLE_NAMES, _ as TogetherAiConfig, Z as TogetherAiModel, ax as VariableReference, aK as WorkflowActionParams, aL as WorkflowActions, aJ as WorkflowActors, aC as WorkflowContext, aE as WorkflowEvent, aD as WorkflowLogMessage, v as WorkflowRow, o as WorkflowRunState, aM as WorkflowState, a8 as XGrokConfig, a7 as XGrokModel } from './index-Duqv1Yom.js';
3
+ import { q as ToolAction, A as Agent$1, r as AgentConfig, M as MastraStorage$1, a as MastraMemory$1, s as ToolExecutionContext, W as WorkflowOptions } from './index-D-mqcYwN.js';
4
+ export { az as ActionContext, aq as AiMessageType, ah as AmazonConfig, ag as AmazonModel, Q as AnthropicConfig, P as AnthropicModel, aj as AnthropicVertexConfig, ai as AnthropicVertexModel, ad as AzureConfig, ac as AzureModel, ay as BaseCondition, al as BaseStructuredOutputType, a2 as BaseTenConfig, a1 as BasetenModel, ab as CohereConfig, aa as CohereModel, z as CoreAssistantMessage, x as CoreMessage, y as CoreSystemMessage, C as CoreTool, D as CoreToolMessage, B as CoreUserMessage, a9 as CustomModelConfig, af as DeepseekConfig, ae as DeepseekModel, aI as DependencyCheckOutput, F as EmbedManyResult, E as EmbedResult, aO as ExtractSchemaFromStep, aR as ExtractSchemaType, aP as ExtractStepResult, a4 as FireworksConfig, a3 as FireworksModel, G as GenerateReturn, K as GoogleConfig, N as GoogleGenerativeAISettings, J as GoogleModel, V as GroqConfig, U as GroqModel, g as LLMInnerStreamOptions, ak as LLMProvider, h as LLMStreamObjectOptions, i as LLMStreamOptions, f as LLMTextObjectOptions, e as LLMTextOptions, a0 as LMStudioConfig, $ as LMStudioModel, au as MemoryConfig, at as MessageResponse, ar as MessageType, a6 as MistralConfig, a5 as MistralModel, b as ModelConfig, H as OpenAIConfig, O as OpenAIModel, ap as OutputType, aS as PathsToStringProps, Y as PerplexityConfig, X as PerplexityModel, aF as ResolverFunctionInput, aG as ResolverFunctionOutput, R as RetryConfig, av as SharedMemoryConfig, k as StepAction, aB as StepCondition, m as StepConfig, aA as StepDef, j as StepExecutionContext, p as StepGraph, aN as StepId, aQ as StepInputType, aw as StepNode, n as StepResult, l as StepVariableType, u as StorageColumn, w as StorageGetMessagesArg, as as StorageThreadType, S as StreamReturn, ao as StructuredOutput, an as StructuredOutputArrayItem, am as StructuredOutputType, aH as SubscriberFunctionOutput, t as TABLE_NAMES, _ as TogetherAiConfig, Z as TogetherAiModel, ax as VariableReference, aK as WorkflowActionParams, aL as WorkflowActions, aJ as WorkflowActors, aC as WorkflowContext, aE as WorkflowEvent, aD as WorkflowLogMessage, v as WorkflowRow, o as WorkflowRunState, aM as WorkflowState, a8 as XGrokConfig, a7 as XGrokModel } from './index-D-mqcYwN.js';
5
5
  export { O as OtelConfig, S as SamplingStrategy, T as Telemetry } from './telemetry-oCUM52DG.js';
6
6
  import { MastraBase as MastraBase$1 } from './base.js';
7
- import { R as RegisteredLogger, a as LogLevel, T as TransportMap, L as Logger } from './index-B0-NXUYv.js';
8
- export { B as BaseLogMessage, c as LoggerTransport, M as MultiLogger, d as combineLoggers, n as noopLogger } from './index-B0-NXUYv.js';
7
+ import { R as RegisteredLogger, a as LogLevel, T as TransportMap, L as Logger } from './index-Cktbxvxx.js';
8
+ export { B as BaseLogMessage, c as LoggerTransport, M as MultiLogger, d as combineLoggers, n as noopLogger } from './index-Cktbxvxx.js';
9
9
  import { MastraDeployer as MastraDeployer$1 } from './deployer/index.js';
10
10
  import * as ai from 'ai';
11
11
  import { E as EmbeddingOptions } from './types-M16hSruO.js';
@@ -22,11 +22,11 @@ import { z } from 'zod';
22
22
  import { Tool as Tool$1 } from './tools/index.js';
23
23
  export { createTool } from './tools/index.js';
24
24
  import { MastraTTS as MastraTTS$1, TTSConfig } from './tts/index.js';
25
- export { delay, jsonSchemaPropertiesToTSTypes, jsonSchemaToModel } from './utils.js';
25
+ export { TagMaskOptions, deepMerge, delay, jsonSchemaPropertiesToTSTypes, jsonSchemaToModel, maskStreamTags } from './utils.js';
26
26
  import { MastraVector as MastraVector$1 } from './vector/index.js';
27
27
  export { IndexStats, QueryResult } from './vector/index.js';
28
- import { S as Step, W as Workflow$1 } from './workflow-DQ8CtzzU.js';
29
- export { c as createStep } from './workflow-DQ8CtzzU.js';
28
+ import { S as Step, W as Workflow$1 } from './workflow-4u4hE9mG.js';
29
+ export { c as createStep } from './workflow-4u4hE9mG.js';
30
30
  export { getStepResult, isErrorEvent, isTransitionEvent, isVariableReference } from './workflows/index.js';
31
31
  export { AvailableHooks, executeHook, registerHook } from './hooks/index.js';
32
32
  export { ArrayOperator, BaseFilterTranslator, BasicOperator, ElementOperator, FieldCondition, Filter, LogicalOperator, NumericOperator, OperatorCondition, OperatorSupport, QueryOperator, RegexOperator } from './filter/index.js';
package/dist/index.js CHANGED
@@ -1,29 +1,29 @@
1
- import { MastraMemory } from './chunk-I3MJB67Z.js';
2
- export { CohereRelevanceScorer, MastraAgentRelevanceScorer, createSimilarityPrompt } from './chunk-JNVLA435.js';
3
- import { MastraStorage, MastraStorageLibSql } from './chunk-EVYBUFXB.js';
4
- import { MastraTTS } from './chunk-SLWM3SEH.js';
5
- import { MastraVector } from './chunk-RCS7AVH6.js';
6
- import { Workflow } from './chunk-OOZGW5CY.js';
7
- export { Step, createStep, getStepResult, isErrorEvent, isTransitionEvent, isVariableReference } from './chunk-OOZGW5CY.js';
8
- export { FilterOperators, MastraEngine, MockMastraEngine, PropertyType } from './chunk-U25DBVJZ.js';
9
- export { Metric, evaluate } from './chunk-QLN26TPI.js';
1
+ export { CohereRelevanceScorer, MastraAgentRelevanceScorer, createSimilarityPrompt } from './chunk-SMVXLIV7.js';
2
+ import { MastraStorage, MastraStorageLibSql } from './chunk-Z2KRB7Z4.js';
3
+ import { MastraMemory } from './chunk-HILJW64N.js';
4
+ import { MastraTTS } from './chunk-ADU6ZLCT.js';
5
+ import { MastraVector } from './chunk-J556NL2S.js';
6
+ import { Workflow } from './chunk-FFZKACHZ.js';
7
+ export { Step, createStep, getStepResult, isErrorEvent, isTransitionEvent, isVariableReference } from './chunk-FFZKACHZ.js';
8
+ import { embed, embedMany } from './chunk-5NQ3MEZM.js';
10
9
  export { BaseFilterTranslator } from './chunk-D6SEHWUL.js';
10
+ export { Metric, evaluate } from './chunk-QLN26TPI.js';
11
11
  import { Integration, OpenAPIToolset } from './chunk-42DYOLDV.js';
12
12
  import { Tool } from './chunk-VOUPGVRD.js';
13
13
  export { createTool } from './chunk-VOUPGVRD.js';
14
- export { Mastra } from './chunk-OU2SP3L7.js';
15
- import { Agent } from './chunk-ELN2OU4M.js';
14
+ export { Mastra } from './chunk-KHPTZCPA.js';
15
+ import { Agent } from './chunk-SKEBFXFK.js';
16
16
  export { AvailableHooks, executeHook, registerHook } from './chunk-HBTQNIAX.js';
17
17
  export { Telemetry } from './chunk-SDKEPBBH.js';
18
- import './chunk-747HUVPF.js';
18
+ import './chunk-Y7YCQUOD.js';
19
19
  export { InstrumentClass, hasActiveTelemetry, withSpan } from './chunk-6ZVFVYLE.js';
20
- export { delay, jsonSchemaPropertiesToTSTypes, jsonSchemaToModel } from './chunk-LUULSM4U.js';
21
- import { MastraDeployer } from './chunk-XD5IQZRB.js';
22
- import './chunk-CQYUMNLZ.js';
23
- import { MastraBase } from './chunk-JCRGAEY6.js';
24
- import { createLogger } from './chunk-TJK6TGSR.js';
25
- export { LogLevel, Logger, LoggerTransport, MultiLogger, RegisteredLogger, combineLoggers, noopLogger } from './chunk-TJK6TGSR.js';
26
- import { embed, embedMany } from './chunk-5NQ3MEZM.js';
20
+ export { deepMerge, delay, jsonSchemaPropertiesToTSTypes, jsonSchemaToModel, maskStreamTags } from './chunk-KNPBNSJ7.js';
21
+ import { MastraDeployer } from './chunk-BCNHUSA6.js';
22
+ import './chunk-RIATJJC3.js';
23
+ export { FilterOperators, MastraEngine, MockMastraEngine, PropertyType } from './chunk-NIYVERVP.js';
24
+ import { MastraBase } from './chunk-WLG2YHOZ.js';
25
+ import { createLogger } from './chunk-IO3KMCXV.js';
26
+ export { LogLevel, Logger, LoggerTransport, MultiLogger, RegisteredLogger, combineLoggers, noopLogger } from './chunk-IO3KMCXV.js';
27
27
  import { __name } from './chunk-AJJZUHB4.js';
28
28
 
29
29
  // src/agent/index.warning.ts