@mastra/core 0.4.0-alpha.0 → 0.4.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.
@@ -1 +1 @@
1
- export { Agent } from '../chunk-4DNSLET5.js';
1
+ export { Agent } from '../chunk-63KLSI2Y.js';
@@ -1,8 +1,8 @@
1
1
  import { InstrumentClass } from './chunk-4ZRHVG25.js';
2
- import { delay } from './chunk-55GTEVHJ.js';
2
+ import { delay } from './chunk-WIBGG4X6.js';
3
+ import { executeHook } from './chunk-BB4KXGBU.js';
3
4
  import { MastraBase } from './chunk-SYZAQCKZ.js';
4
5
  import { RegisteredLogger, LogLevel } from './chunk-XS2VY7YW.js';
5
- import { executeHook } from './chunk-BB4KXGBU.js';
6
6
  import { __decoratorStart, __decorateElement, __runInitializers } from './chunk-C6A6W6XS.js';
7
7
  import { randomUUID } from 'crypto';
8
8
  import { z } from 'zod';
@@ -1,4 +1,4 @@
1
- import { Agent } from './chunk-4DNSLET5.js';
1
+ import { Agent } from './chunk-63KLSI2Y.js';
2
2
  import { CohereClient } from 'cohere-ai';
3
3
 
4
4
  var CohereRelevanceScorer = class {
@@ -1,7 +1,7 @@
1
1
  import { DefaultStorage } from './chunk-6CWY2XAM.js';
2
2
  import { DefaultVectorDB } from './chunk-KDUL7NPA.js';
3
3
  import { defaultEmbedder } from './chunk-VIJVUFTB.js';
4
- import { deepMerge } from './chunk-55GTEVHJ.js';
4
+ import { deepMerge } from './chunk-WIBGG4X6.js';
5
5
  import { MastraBase } from './chunk-SYZAQCKZ.js';
6
6
 
7
7
  // src/memory/memory.ts
@@ -104,15 +104,35 @@ async function* maskStreamTags(stream, tag, options = {}) {
104
104
  let fullContent = "";
105
105
  let isMasking = false;
106
106
  let isBuffering = false;
107
- const startsWith = (text, pattern) => text.trim().startsWith(pattern.trim());
107
+ const trimOutsideDelimiter = (text, delimiter, trim) => {
108
+ if (!text.includes(delimiter)) {
109
+ return text;
110
+ }
111
+ const parts = text.split(delimiter);
112
+ if (trim === `before-start`) {
113
+ return `${delimiter}${parts[1]}`;
114
+ }
115
+ return `${parts[0]}${delimiter}`;
116
+ };
117
+ const startsWith = (text, pattern) => {
118
+ if (pattern.includes(openTag.substring(0, 3))) {
119
+ pattern = trimOutsideDelimiter(pattern, `<`, `before-start`);
120
+ }
121
+ return text.trim().startsWith(pattern.trim());
122
+ };
108
123
  for await (const chunk of stream) {
109
124
  fullContent += chunk;
110
125
  if (isBuffering) buffer += chunk;
111
126
  const chunkHasTag = startsWith(chunk, openTag);
112
127
  const bufferHasTag = !chunkHasTag && isBuffering && startsWith(openTag, buffer);
128
+ let toYieldBeforeMaskedStartTag = ``;
113
129
  if (!isMasking && (chunkHasTag || bufferHasTag)) {
114
130
  isMasking = true;
115
131
  isBuffering = false;
132
+ const taggedTextToMask = trimOutsideDelimiter(buffer, `<`, `before-start`);
133
+ if (taggedTextToMask !== buffer.trim()) {
134
+ toYieldBeforeMaskedStartTag = buffer.replace(taggedTextToMask, ``);
135
+ }
116
136
  buffer = "";
117
137
  onStart?.();
118
138
  }
@@ -127,14 +147,23 @@ async function* maskStreamTags(stream, tag, options = {}) {
127
147
  isBuffering = false;
128
148
  continue;
129
149
  }
130
- if (isMasking && fullContent.trim().includes(closeTag)) {
150
+ if (isMasking && fullContent.includes(closeTag)) {
131
151
  onMask?.(chunk);
132
152
  onEnd?.();
133
153
  isMasking = false;
154
+ const lastFullContent = fullContent;
155
+ fullContent = ``;
156
+ const textUntilEndTag = trimOutsideDelimiter(lastFullContent, closeTag, "after-end");
157
+ if (textUntilEndTag !== lastFullContent) {
158
+ yield lastFullContent.replace(textUntilEndTag, ``);
159
+ }
134
160
  continue;
135
161
  }
136
162
  if (isMasking) {
137
163
  onMask?.(chunk);
164
+ if (toYieldBeforeMaskedStartTag) {
165
+ yield toYieldBeforeMaskedStartTag;
166
+ }
138
167
  continue;
139
168
  }
140
169
  yield chunk;
package/dist/index.js CHANGED
@@ -5,22 +5,22 @@ import { Integration, OpenAPIToolset } from './chunk-PNZK456O.js';
5
5
  import { Tool } from './chunk-ZINPRHAN.js';
6
6
  export { createTool } from './chunk-ZINPRHAN.js';
7
7
  export { Mastra } from './chunk-DAWQ5R4C.js';
8
- import { MastraMemory } from './chunk-NMB3HO5N.js';
9
- export { CohereRelevanceScorer, MastraAgentRelevanceScorer, createSimilarityPrompt } from './chunk-E3DDYOSO.js';
8
+ import { MastraMemory } from './chunk-KMVLZUIO.js';
9
+ export { CohereRelevanceScorer, MastraAgentRelevanceScorer, createSimilarityPrompt } from './chunk-ILKS57KK.js';
10
10
  import { MastraStorage, DefaultStorage } from './chunk-6CWY2XAM.js';
11
11
  export { DefaultStorage } from './chunk-6CWY2XAM.js';
12
12
  export { DefaultVectorDB, DefaultVectorDB as LibSQLVector } from './chunk-KDUL7NPA.js';
13
13
  import { MastraVector } from './chunk-VIJVUFTB.js';
14
14
  export { defaultEmbedder } from './chunk-VIJVUFTB.js';
15
- import { Agent } from './chunk-4DNSLET5.js';
15
+ import { Agent } from './chunk-63KLSI2Y.js';
16
16
  export { InstrumentClass, OTLPTraceExporter as OTLPStorageExporter, Telemetry, hasActiveTelemetry, withSpan } from './chunk-4ZRHVG25.js';
17
- export { deepMerge, delay, jsonSchemaPropertiesToTSTypes, jsonSchemaToModel, maskStreamTags } from './chunk-55GTEVHJ.js';
17
+ export { deepMerge, delay, jsonSchemaPropertiesToTSTypes, jsonSchemaToModel, maskStreamTags } from './chunk-WIBGG4X6.js';
18
18
  import { MastraDeployer } from './chunk-COG5YSSN.js';
19
+ export { Metric, evaluate } from './chunk-NUDAZEOG.js';
20
+ export { AvailableHooks, executeHook, registerHook } from './chunk-BB4KXGBU.js';
19
21
  import { MastraBase } from './chunk-SYZAQCKZ.js';
20
22
  import { createLogger } from './chunk-XS2VY7YW.js';
21
23
  export { LogLevel, Logger, LoggerTransport, MultiLogger, RegisteredLogger, combineLoggers, noopLogger } from './chunk-XS2VY7YW.js';
22
- export { Metric, evaluate } from './chunk-NUDAZEOG.js';
23
- export { AvailableHooks, executeHook, registerHook } from './chunk-BB4KXGBU.js';
24
24
  export { BaseFilterTranslator } from './chunk-SIFBBGY6.js';
25
25
 
26
26
  // src/agent/index.warning.ts
@@ -1 +1 @@
1
- export { MastraMemory } from '../chunk-NMB3HO5N.js';
1
+ export { MastraMemory } from '../chunk-KMVLZUIO.js';
@@ -1 +1 @@
1
- export { CohereRelevanceScorer, MastraAgentRelevanceScorer, createSimilarityPrompt } from '../chunk-E3DDYOSO.js';
1
+ export { CohereRelevanceScorer, MastraAgentRelevanceScorer, createSimilarityPrompt } from '../chunk-ILKS57KK.js';
package/dist/utils.js CHANGED
@@ -1 +1 @@
1
- export { deepMerge, delay, jsonSchemaPropertiesToTSTypes, jsonSchemaToModel, maskStreamTags } from './chunk-55GTEVHJ.js';
1
+ export { deepMerge, delay, jsonSchemaPropertiesToTSTypes, jsonSchemaToModel, maskStreamTags } from './chunk-WIBGG4X6.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/core",
3
- "version": "0.4.0-alpha.0",
3
+ "version": "0.4.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/core.esm.js",