@mastra/core 0.2.0-alpha.87 → 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.
- package/dist/action/index.d.ts +2 -2
- package/dist/agent/index.d.ts +2 -2
- package/dist/agent/index.js +5 -5
- package/dist/base.d.ts +1 -1
- package/dist/base.js +2 -2
- package/dist/bundler/index.d.ts +1 -1
- package/dist/bundler/index.js +3 -3
- package/dist/{chunk-2ISN3AA7.js → chunk-654VMNVR.js} +20 -11
- package/dist/{chunk-SLWM3SEH.js → chunk-ADU6ZLCT.js} +1 -1
- package/dist/{chunk-XD5IQZRB.js → chunk-BCNHUSA6.js} +1 -1
- package/dist/{chunk-RZYBOMIG.js → chunk-D6SEHWUL.js} +13 -1
- package/dist/{chunk-OOZGW5CY.js → chunk-FFZKACHZ.js} +1 -1
- package/dist/{chunk-2J5OHBUG.js → chunk-GTJIVA2D.js} +1 -1
- package/dist/{chunk-I3MJB67Z.js → chunk-HILJW64N.js} +14 -7
- package/dist/{chunk-TJK6TGSR.js → chunk-IO3KMCXV.js} +2 -1
- package/dist/{chunk-RCS7AVH6.js → chunk-J556NL2S.js} +1 -1
- package/dist/{chunk-EH2PG7Q6.js → chunk-KHPTZCPA.js} +2 -2
- package/dist/{chunk-LUULSM4U.js → chunk-KNPBNSJ7.js} +65 -1
- package/dist/{chunk-U25DBVJZ.js → chunk-NIYVERVP.js} +1 -1
- package/dist/{chunk-CQYUMNLZ.js → chunk-RIATJJC3.js} +1 -1
- package/dist/{chunk-73XDWPXJ.js → chunk-SKEBFXFK.js} +64 -14
- package/dist/{chunk-D66E7L7R.js → chunk-SMVXLIV7.js} +1 -1
- package/dist/{chunk-RLPH6TDJ.js → chunk-T5ZUXYWC.js} +1 -1
- package/dist/{chunk-JCRGAEY6.js → chunk-WLG2YHOZ.js} +1 -1
- package/dist/{chunk-6WJREZ5F.js → chunk-Y7YCQUOD.js} +20 -13
- package/dist/{chunk-EVYBUFXB.js → chunk-Z2KRB7Z4.js} +1 -1
- package/dist/deployer/index.d.ts +1 -1
- package/dist/deployer/index.js +4 -4
- package/dist/engine/index.d.ts +1 -1
- package/dist/engine/index.js +3 -3
- package/dist/eval/index.d.ts +2 -2
- package/dist/filter/index.d.ts +2 -0
- package/dist/filter/index.js +1 -1
- package/dist/{index-B0-NXUYv.d.ts → index-Cktbxvxx.d.ts} +1 -0
- package/dist/{index-Duqv1Yom.d.ts → index-D-mqcYwN.d.ts} +20 -5
- package/dist/index.d.ts +7 -7
- package/dist/index.js +19 -19
- package/dist/integration/index.d.ts +3 -3
- package/dist/llm/index.d.ts +2 -2
- package/dist/llm/index.js +4 -4
- package/dist/llm/model/providers/anthropic-vertex.d.ts +3 -3
- package/dist/llm/model/providers/anthropic-vertex.js +4 -4
- package/dist/llm/model/providers/anthropic.d.ts +3 -3
- package/dist/llm/model/providers/anthropic.js +4 -4
- package/dist/llm/model/providers/azure.d.ts +3 -3
- package/dist/llm/model/providers/azure.js +4 -4
- package/dist/llm/model/providers/baseten.d.ts +3 -3
- package/dist/llm/model/providers/baseten.js +5 -5
- package/dist/llm/model/providers/bedrock.d.ts +3 -3
- package/dist/llm/model/providers/bedrock.js +4 -4
- package/dist/llm/model/providers/cerebras.d.ts +3 -3
- package/dist/llm/model/providers/cerebras.js +4 -4
- package/dist/llm/model/providers/cohere.d.ts +3 -3
- package/dist/llm/model/providers/cohere.js +4 -4
- package/dist/llm/model/providers/deepinfra.d.ts +3 -3
- package/dist/llm/model/providers/deepinfra.js +4 -4
- package/dist/llm/model/providers/deepseek.d.ts +3 -3
- package/dist/llm/model/providers/deepseek.js +4 -4
- package/dist/llm/model/providers/fireworks.d.ts +3 -3
- package/dist/llm/model/providers/fireworks.js +4 -4
- package/dist/llm/model/providers/google-vertex.d.ts +3 -3
- package/dist/llm/model/providers/google-vertex.js +4 -4
- package/dist/llm/model/providers/google.d.ts +3 -3
- package/dist/llm/model/providers/google.js +4 -4
- package/dist/llm/model/providers/grok.d.ts +3 -3
- package/dist/llm/model/providers/grok.js +4 -4
- package/dist/llm/model/providers/groq.d.ts +3 -3
- package/dist/llm/model/providers/groq.js +4 -4
- package/dist/llm/model/providers/lmstudio.d.ts +3 -3
- package/dist/llm/model/providers/lmstudio.js +5 -5
- package/dist/llm/model/providers/mistral.d.ts +3 -3
- package/dist/llm/model/providers/mistral.js +4 -4
- package/dist/llm/model/providers/mock.d.ts +3 -3
- package/dist/llm/model/providers/mock.js +4 -4
- package/dist/llm/model/providers/ollama.d.ts +3 -3
- package/dist/llm/model/providers/ollama.js +4 -4
- package/dist/llm/model/providers/openai-compat.d.ts +3 -3
- package/dist/llm/model/providers/openai-compat.js +5 -5
- package/dist/llm/model/providers/openai.d.ts +3 -3
- package/dist/llm/model/providers/openai.js +5 -5
- package/dist/llm/model/providers/openai.test.js +5 -5
- package/dist/llm/model/providers/perplexity.d.ts +3 -3
- package/dist/llm/model/providers/perplexity.js +4 -4
- package/dist/llm/model/providers/portkey.d.ts +3 -3
- package/dist/llm/model/providers/portkey.js +4 -4
- package/dist/llm/model/providers/togetherai.d.ts +3 -3
- package/dist/llm/model/providers/togetherai.js +4 -4
- package/dist/logger/index.d.ts +1 -1
- package/dist/logger/index.js +1 -1
- package/dist/mastra/index.d.ts +3 -3
- package/dist/mastra/index.js +5 -5
- package/dist/memory/index.d.ts +2 -2
- package/dist/memory/index.js +4 -3
- package/dist/{model-QGWIMOSx.d.ts → model-CD0nIpJn.d.ts} +1 -1
- package/dist/relevance/index.d.ts +2 -2
- package/dist/relevance/index.js +6 -6
- package/dist/storage/index.d.ts +3 -3
- package/dist/storage/index.js +3 -3
- package/dist/tools/index.d.ts +3 -3
- package/dist/tts/index.d.ts +1 -1
- package/dist/tts/index.js +3 -3
- package/dist/utils.d.ts +20 -1
- package/dist/utils.js +1 -1
- package/dist/vector/index.d.ts +1 -1
- package/dist/vector/index.js +3 -3
- package/dist/{workflow-DQ8CtzzU.d.ts → workflow-4u4hE9mG.d.ts} +1 -1
- package/dist/workflows/index.d.ts +4 -4
- package/dist/workflows/index.js +3 -3
- package/package.json +9 -2
package/dist/action/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import 'zod';
|
|
2
|
-
export { I as IAction, aT as IExecutionContext, d as MastraPrimitives } from '../index-
|
|
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-
|
|
4
|
+
import '../index-Cktbxvxx.js';
|
|
5
5
|
import '../telemetry-oCUM52DG.js';
|
|
6
6
|
import '../tts/index.js';
|
|
7
7
|
import '../vector/index.js';
|
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import 'ai';
|
|
2
2
|
import 'json-schema';
|
|
3
3
|
import 'zod';
|
|
4
|
-
export { A as Agent } from '../index-
|
|
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-
|
|
8
|
+
import '../index-Cktbxvxx.js';
|
|
9
9
|
import 'pino';
|
|
10
10
|
import 'stream';
|
|
11
11
|
import 'sift';
|
package/dist/agent/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { Agent } from '../chunk-
|
|
1
|
+
export { Agent } from '../chunk-SKEBFXFK.js';
|
|
2
2
|
import '../chunk-HBTQNIAX.js';
|
|
3
3
|
import '../chunk-SDKEPBBH.js';
|
|
4
|
-
import '../chunk-
|
|
4
|
+
import '../chunk-Y7YCQUOD.js';
|
|
5
5
|
import '../chunk-6ZVFVYLE.js';
|
|
6
|
-
import '../chunk-
|
|
7
|
-
import '../chunk-
|
|
8
|
-
import '../chunk-
|
|
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-
|
|
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-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { MastraBase } from './chunk-WLG2YHOZ.js';
|
|
2
|
+
import './chunk-IO3KMCXV.js';
|
|
3
3
|
import './chunk-AJJZUHB4.js';
|
package/dist/bundler/index.d.ts
CHANGED
package/dist/bundler/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { MastraBundler } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
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-
|
|
2
|
-
import { MastraBase } from './chunk-
|
|
3
|
-
import { RegisteredLogger } from './chunk-
|
|
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';
|
|
@@ -114,14 +114,23 @@ var _MastraLLM = class _MastraLLM extends MastraLLMBase {
|
|
|
114
114
|
description: tool.description,
|
|
115
115
|
parameters: tool.inputSchema,
|
|
116
116
|
execute: /* @__PURE__ */ __name(async (props) => {
|
|
117
|
-
|
|
118
|
-
tool
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
117
|
+
try {
|
|
118
|
+
this.logger.debug("Executing tool", {
|
|
119
|
+
tool: k,
|
|
120
|
+
props
|
|
121
|
+
});
|
|
122
|
+
return tool.execute({
|
|
123
|
+
context: props,
|
|
124
|
+
mastra: __privateGet(this, _mastra2)
|
|
125
|
+
});
|
|
126
|
+
} catch (error) {
|
|
127
|
+
this.logger.error("Error executing tool", {
|
|
128
|
+
tool: k,
|
|
129
|
+
props,
|
|
130
|
+
error
|
|
131
|
+
});
|
|
132
|
+
throw error;
|
|
133
|
+
}
|
|
125
134
|
}, "execute")
|
|
126
135
|
};
|
|
127
136
|
}
|
|
@@ -123,6 +123,16 @@ var BaseFilterTranslator = (_a = class {
|
|
|
123
123
|
messages.push(_a.ErrorMessages.UNSUPPORTED_OPERATOR(key));
|
|
124
124
|
continue;
|
|
125
125
|
}
|
|
126
|
+
if (!path && !this.isLogicalOperator(key)) {
|
|
127
|
+
isSupported = false;
|
|
128
|
+
messages.push(_a.ErrorMessages.INVALID_TOP_LEVEL_OPERATOR(key));
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
if (key === "$elemMatch" && (typeof value !== "object" || Array.isArray(value))) {
|
|
132
|
+
isSupported = false;
|
|
133
|
+
messages.push(_a.ErrorMessages.ELEM_MATCH_REQUIRES_OBJECT);
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
126
136
|
if (this.isLogicalOperator(key)) {
|
|
127
137
|
if (key === "$not") {
|
|
128
138
|
if (Array.isArray(value) || typeof value !== "object") {
|
|
@@ -198,7 +208,9 @@ var BaseFilterTranslator = (_a = class {
|
|
|
198
208
|
INVALID_LOGICAL_OPERATOR_LOCATION: /* @__PURE__ */ __name((op, path) => `Logical operator ${op} cannot be used at field level: ${path}`, "INVALID_LOGICAL_OPERATOR_LOCATION"),
|
|
199
209
|
NOT_REQUIRES_OBJECT: `$not operator requires an object`,
|
|
200
210
|
NOT_CANNOT_BE_EMPTY: `$not operator cannot be empty`,
|
|
201
|
-
INVALID_LOGICAL_OPERATOR_CONTENT: /* @__PURE__ */ __name((path) => `Logical operators must contain field conditions, not direct operators: ${path}`, "INVALID_LOGICAL_OPERATOR_CONTENT")
|
|
211
|
+
INVALID_LOGICAL_OPERATOR_CONTENT: /* @__PURE__ */ __name((path) => `Logical operators must contain field conditions, not direct operators: ${path}`, "INVALID_LOGICAL_OPERATOR_CONTENT"),
|
|
212
|
+
INVALID_TOP_LEVEL_OPERATOR: /* @__PURE__ */ __name((op) => `Invalid top-level operator: ${op}`, "INVALID_TOP_LEVEL_OPERATOR"),
|
|
213
|
+
ELEM_MATCH_REQUIRES_OBJECT: `$elemMatch requires an object with conditions`
|
|
202
214
|
}), _a);
|
|
203
215
|
|
|
204
216
|
export { BaseFilterTranslator };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MastraBase } from './chunk-
|
|
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,5 @@
|
|
|
1
|
-
import {
|
|
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
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Telemetry } from './chunk-SDKEPBBH.js';
|
|
2
|
-
import { LLM } from './chunk-
|
|
2
|
+
import { LLM } from './chunk-Y7YCQUOD.js';
|
|
3
3
|
import { InstrumentClass } from './chunk-6ZVFVYLE.js';
|
|
4
|
-
import { LogLevel, createLogger, noopLogger } from './chunk-
|
|
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,8 +1,8 @@
|
|
|
1
1
|
import { executeHook, AvailableHooks } from './chunk-HBTQNIAX.js';
|
|
2
|
-
import { LLM } from './chunk-
|
|
2
|
+
import { LLM } from './chunk-Y7YCQUOD.js';
|
|
3
3
|
import { InstrumentClass } from './chunk-6ZVFVYLE.js';
|
|
4
|
-
import { MastraBase } from './chunk-
|
|
5
|
-
import { RegisteredLogger, LogLevel } from './chunk-
|
|
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
|
]
|
|
@@ -313,7 +337,7 @@ var _Agent = class _Agent extends MastraBase {
|
|
|
313
337
|
}
|
|
314
338
|
}
|
|
315
339
|
} catch (err) {
|
|
316
|
-
this.logger.error(
|
|
340
|
+
this.logger.error(`[Agent:${this.name}] - Failed to save assistant response`, {
|
|
317
341
|
error: err,
|
|
318
342
|
runId
|
|
319
343
|
});
|
|
@@ -357,10 +381,23 @@ var _Agent = class _Agent extends MastraBase {
|
|
|
357
381
|
description: tool.description,
|
|
358
382
|
parameters: tool.inputSchema,
|
|
359
383
|
execute: /* @__PURE__ */ __name(async (args) => {
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
384
|
+
try {
|
|
385
|
+
this.logger.debug(`[Agent:${this.name}] - Executing tool ${k}`, {
|
|
386
|
+
name: k,
|
|
387
|
+
description: tool.description,
|
|
388
|
+
args
|
|
389
|
+
});
|
|
390
|
+
return tool.execute({
|
|
391
|
+
context: args,
|
|
392
|
+
mastra: __privateGet(this, _mastra)
|
|
393
|
+
});
|
|
394
|
+
} catch (err) {
|
|
395
|
+
this.logger.error(`[Agent:${this.name}] - Failed execution`, {
|
|
396
|
+
error: err,
|
|
397
|
+
runId
|
|
398
|
+
});
|
|
399
|
+
throw err;
|
|
400
|
+
}
|
|
364
401
|
}, "execute")
|
|
365
402
|
};
|
|
366
403
|
}
|
|
@@ -371,7 +408,7 @@ var _Agent = class _Agent extends MastraBase {
|
|
|
371
408
|
};
|
|
372
409
|
const toolsFromToolsets = Object.values(toolsets || {});
|
|
373
410
|
if (toolsFromToolsets.length > 0) {
|
|
374
|
-
this.logger.debug(`Adding tools from toolsets ${Object.keys(toolsets || {}).join(", ")}`, {
|
|
411
|
+
this.logger.debug(`[Agent:${this.name}] - Adding tools from toolsets ${Object.keys(toolsets || {}).join(", ")}`, {
|
|
375
412
|
runId
|
|
376
413
|
});
|
|
377
414
|
toolsFromToolsets.forEach((toolset) => {
|
|
@@ -381,9 +418,22 @@ var _Agent = class _Agent extends MastraBase {
|
|
|
381
418
|
description: toolObj.description || "",
|
|
382
419
|
parameters: toolObj.inputSchema,
|
|
383
420
|
execute: /* @__PURE__ */ __name(async (args) => {
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
421
|
+
try {
|
|
422
|
+
this.logger.debug(`[Agent:${this.name}] - Executing tool ${toolName}`, {
|
|
423
|
+
name: toolName,
|
|
424
|
+
description: toolObj.description,
|
|
425
|
+
args
|
|
426
|
+
});
|
|
427
|
+
return toolObj.execute({
|
|
428
|
+
context: args
|
|
429
|
+
});
|
|
430
|
+
} catch (err) {
|
|
431
|
+
this.logger.error(`[Agent:${this.name}] - Failed toolset execution`, {
|
|
432
|
+
error: err,
|
|
433
|
+
runId
|
|
434
|
+
});
|
|
435
|
+
throw err;
|
|
436
|
+
}
|
|
387
437
|
}, "execute")
|
|
388
438
|
};
|
|
389
439
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { InstrumentClass } from './chunk-6ZVFVYLE.js';
|
|
2
|
-
import { delay } from './chunk-
|
|
3
|
-
import { MastraBase } from './chunk-
|
|
4
|
-
import { RegisteredLogger, LogLevel } from './chunk-
|
|
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';
|
|
@@ -262,7 +262,6 @@ var _LLM = class _LLM extends MastraBase {
|
|
|
262
262
|
};
|
|
263
263
|
}
|
|
264
264
|
convertTools(tools) {
|
|
265
|
-
this.log(LogLevel.DEBUG, "Starting tool conversion for LLM");
|
|
266
265
|
const converted = Object.entries(tools || {}).reduce((memo, value) => {
|
|
267
266
|
const k = value[0];
|
|
268
267
|
const tool2 = value[1];
|
|
@@ -271,20 +270,28 @@ var _LLM = class _LLM extends MastraBase {
|
|
|
271
270
|
description: tool2.description,
|
|
272
271
|
parameters: tool2.inputSchema,
|
|
273
272
|
execute: /* @__PURE__ */ __name(async (props) => {
|
|
274
|
-
|
|
275
|
-
tool
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
273
|
+
try {
|
|
274
|
+
this.logger.debug(`Executing tool ${k}`, {
|
|
275
|
+
tool: k,
|
|
276
|
+
props
|
|
277
|
+
});
|
|
278
|
+
return tool2.execute({
|
|
279
|
+
context: props,
|
|
280
|
+
mastra: __privateGet(this, _mastra)
|
|
281
|
+
});
|
|
282
|
+
} catch (error) {
|
|
283
|
+
this.logger.error(`Error executing tool ${k}`, {
|
|
284
|
+
tool: k,
|
|
285
|
+
props,
|
|
286
|
+
error
|
|
287
|
+
});
|
|
288
|
+
throw error;
|
|
289
|
+
}
|
|
282
290
|
}, "execute")
|
|
283
291
|
};
|
|
284
292
|
}
|
|
285
293
|
return memo;
|
|
286
294
|
}, {});
|
|
287
|
-
this.log(LogLevel.DEBUG, `Converted tools for LLM`);
|
|
288
295
|
return converted;
|
|
289
296
|
}
|
|
290
297
|
convertToMessages(messages) {
|
package/dist/deployer/index.d.ts
CHANGED
package/dist/deployer/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { MastraDeployer } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
4
|
-
import '../chunk-
|
|
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';
|
package/dist/engine/index.d.ts
CHANGED
|
@@ -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-
|
|
5
|
+
import '../index-Cktbxvxx.js';
|
|
6
6
|
import 'pino';
|
|
7
7
|
import 'stream';
|
|
8
8
|
import '../telemetry-oCUM52DG.js';
|
package/dist/engine/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { FilterOperators, MastraEngine, MockMastraEngine, PropertyType } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
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';
|
package/dist/eval/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { M as Metric, a as MetricResult } from '../metric-D2V4CR8D.js';
|
|
2
|
-
import { A as Agent } from '../index-
|
|
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-
|
|
8
|
+
import '../index-Cktbxvxx.js';
|
|
9
9
|
import 'pino';
|
|
10
10
|
import 'stream';
|
|
11
11
|
import '../telemetry-oCUM52DG.js';
|
package/dist/filter/index.d.ts
CHANGED
|
@@ -72,6 +72,8 @@ declare abstract class BaseFilterTranslator {
|
|
|
72
72
|
readonly NOT_REQUIRES_OBJECT: "$not operator requires an object";
|
|
73
73
|
readonly NOT_CANNOT_BE_EMPTY: "$not operator cannot be empty";
|
|
74
74
|
readonly INVALID_LOGICAL_OPERATOR_CONTENT: (path: string) => string;
|
|
75
|
+
readonly INVALID_TOP_LEVEL_OPERATOR: (op: string) => string;
|
|
76
|
+
readonly ELEM_MATCH_REQUIRES_OBJECT: "$elemMatch requires an object with conditions";
|
|
75
77
|
};
|
|
76
78
|
/**
|
|
77
79
|
* Helper to handle array value normalization consistently
|
package/dist/filter/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { BaseFilterTranslator } from '../chunk-
|
|
1
|
+
export { BaseFilterTranslator } from '../chunk-D6SEHWUL.js';
|
|
2
2
|
import '../chunk-AJJZUHB4.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: {
|