@mastra/core 0.9.5-alpha.0 → 0.10.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.
- package/README.md +3 -2
- package/dist/agent/index.cjs +2 -2
- package/dist/agent/index.d.cts +12 -13
- package/dist/agent/index.d.ts +12 -13
- package/dist/agent/index.js +1 -1
- package/dist/{base-CI7Uz2GO.d.ts → base-DttB7sJD.d.ts} +1172 -1130
- package/dist/{base-BV8SNIdm.d.cts → base-aJ3etsh5.d.cts} +1172 -1130
- package/dist/{base-H7siSAfu.d.cts → base-aPYtPBT2.d.cts} +3 -3
- package/dist/{base-4Z34GQL8.d.ts → base-tc5kgDTD.d.ts} +3 -3
- package/dist/base.cjs +2 -2
- package/dist/base.d.cts +2 -3
- package/dist/base.d.ts +2 -3
- package/dist/base.js +1 -1
- package/dist/bundler/index.cjs +2 -2
- package/dist/bundler/index.d.cts +2 -3
- package/dist/bundler/index.d.ts +2 -3
- package/dist/bundler/index.js +1 -1
- package/dist/{chunk-W4BSLENO.js → chunk-2NTUAUGH.js} +1 -1
- package/dist/{chunk-MF5BUJO6.js → chunk-2PW6UJMW.js} +57 -9
- package/dist/{chunk-HKCSQI7G.cjs → chunk-2U7ZZUFO.cjs} +2 -2
- package/dist/{workflows/vNext/index.js → chunk-3SQ3G2EJ.js} +16 -15
- package/dist/chunk-5HULBQ2W.cjs +38 -0
- package/dist/{chunk-BATBI3D4.cjs → chunk-5JRD3NDP.cjs} +15 -15
- package/dist/{chunk-EYQLTWRJ.cjs → chunk-5W2G7S44.cjs} +33 -58
- package/dist/chunk-75Z4BZEE.js +36 -0
- package/dist/{chunk-S3Y7QBO7.cjs → chunk-AOGUTJUO.cjs} +57 -50
- package/dist/{chunk-BZUIFK6C.js → chunk-BPTSLJHA.js} +9 -9
- package/dist/{chunk-JBJ7KXN5.js → chunk-C3ICEF6E.js} +1 -1
- package/dist/{chunk-E4FAXBUV.cjs → chunk-CWSFP2HS.cjs} +2 -2
- package/dist/{chunk-RWWUZTAK.js → chunk-E7CLY6SK.js} +41 -34
- package/dist/{chunk-235X76GC.js → chunk-FI7R232B.js} +2 -2
- package/dist/chunk-GQ2XQ4UN.js +321 -0
- package/dist/{chunk-6EPEYXAE.js → chunk-J7GDGV6F.js} +1 -1
- package/dist/{chunk-NLBJOFNG.js → chunk-JW5TMK2L.js} +1 -1
- package/dist/{chunk-NOPY74PV.js → chunk-KJQFFEEQ.js} +1 -1
- package/dist/{chunk-V2Q2FEVO.cjs → chunk-KSPHQSZX.cjs} +2 -2
- package/dist/{chunk-SU4O2A72.js → chunk-LHRZV5VG.js} +1 -22
- package/dist/chunk-NMDM4IZN.cjs +78 -0
- package/dist/chunk-OBEALYTK.js +74 -0
- package/dist/{chunk-PU2TNRKO.js → chunk-OCT2762Q.js} +1 -1
- package/dist/{chunk-5DUFC7TV.cjs → chunk-P7BGXOQV.cjs} +2 -2
- package/dist/{chunk-NQE264UM.cjs → chunk-PIZM25KI.cjs} +2 -23
- package/dist/{chunk-S7J63JOG.cjs → chunk-RVS6OUJN.cjs} +2 -2
- package/dist/{chunk-LF5CE7LU.cjs → chunk-SKG2NIZW.cjs} +2 -2
- package/dist/chunk-SWW4EBUZ.cjs +96 -0
- package/dist/{chunk-RGE4UF6A.cjs → chunk-TMPFLJLG.cjs} +2 -2
- package/dist/{workflows/vNext/index.cjs → chunk-TTKQ37ZZ.cjs} +21 -20
- package/dist/{chunk-F7HNPG53.cjs → chunk-U3L3NEOM.cjs} +58 -10
- package/dist/chunk-VHLL4AZK.js +90 -0
- package/dist/{chunk-EG74VBSP.cjs → chunk-YEULQPUY.cjs} +6 -6
- package/dist/{chunk-RVKA5VUT.js → chunk-ZB3LEHL2.js} +31 -56
- package/dist/{chunk-TAFOICHR.js → chunk-ZKN6HYYQ.js} +1 -1
- package/dist/chunk-ZZDAC5KD.cjs +325 -0
- package/dist/deployer/index.cjs +2 -2
- package/dist/deployer/index.d.cts +2 -3
- package/dist/deployer/index.d.ts +2 -3
- package/dist/deployer/index.js +1 -1
- package/dist/eval/index.d.cts +12 -13
- package/dist/eval/index.d.ts +12 -13
- package/dist/hooks/index.d.cts +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/index.cjs +71 -158
- package/dist/index.d.cts +16 -24
- package/dist/index.d.ts +16 -24
- package/dist/index.js +16 -23
- package/dist/integration/index.cjs +3 -3
- package/dist/integration/index.d.cts +11 -12
- package/dist/integration/index.d.ts +11 -12
- package/dist/integration/index.js +1 -1
- package/dist/llm/index.d.cts +11 -12
- package/dist/llm/index.d.ts +11 -12
- package/dist/logger/index.cjs +18 -17
- package/dist/logger/index.d.cts +42 -2
- package/dist/logger/index.d.ts +42 -2
- package/dist/logger/index.js +2 -1
- package/dist/{index-QV27jkxQ.d.ts → logger-EhZkzZOr.d.cts} +38 -52
- package/dist/{index-QV27jkxQ.d.cts → logger-EhZkzZOr.d.ts} +38 -52
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.d.cts +10 -11
- package/dist/mastra/index.d.ts +10 -11
- package/dist/mastra/index.js +1 -1
- package/dist/mcp/index.cjs +4 -4
- package/dist/mcp/index.d.cts +13 -14
- package/dist/mcp/index.d.ts +13 -14
- package/dist/mcp/index.js +2 -2
- package/dist/memory/index.cjs +4 -4
- package/dist/memory/index.d.cts +11 -12
- package/dist/memory/index.d.ts +11 -12
- package/dist/memory/index.js +1 -1
- package/dist/network/index.cjs +8 -8
- package/dist/network/index.d.cts +11 -12
- package/dist/network/index.d.ts +11 -12
- package/dist/network/index.js +4 -4
- package/dist/relevance/index.cjs +4 -4
- package/dist/relevance/index.d.cts +14 -15
- package/dist/relevance/index.d.ts +14 -15
- package/dist/relevance/index.js +1 -1
- package/dist/server/index.cjs +4 -0
- package/dist/server/index.d.cts +14 -13
- package/dist/server/index.d.ts +14 -13
- package/dist/server/index.js +4 -1
- package/dist/storage/index.cjs +184 -3
- package/dist/storage/index.d.cts +82 -12
- package/dist/storage/index.d.ts +82 -12
- package/dist/storage/index.js +186 -1
- package/dist/telemetry/index.d.cts +13 -14
- package/dist/telemetry/index.d.ts +13 -14
- package/dist/telemetry/otel-vendor.cjs +2 -2
- package/dist/telemetry/otel-vendor.d.cts +1 -1
- package/dist/telemetry/otel-vendor.d.ts +1 -1
- package/dist/telemetry/otel-vendor.js +1 -1
- package/dist/tools/index.cjs +4 -4
- package/dist/tools/index.d.cts +11 -12
- package/dist/tools/index.d.ts +11 -12
- package/dist/tools/index.js +1 -1
- package/dist/tts/index.cjs +2 -2
- package/dist/tts/index.d.cts +2 -3
- package/dist/tts/index.d.ts +2 -3
- package/dist/tts/index.js +1 -1
- package/dist/{types-BtMyV38I.d.ts → types-Bo1uigWx.d.cts} +1 -1
- package/dist/{types-BtMyV38I.d.cts → types-Bo1uigWx.d.ts} +1 -1
- package/dist/utils.cjs +16 -16
- package/dist/utils.d.cts +14 -15
- package/dist/utils.d.ts +14 -15
- package/dist/utils.js +1 -1
- package/dist/vector/filter/index.cjs +189 -7
- package/dist/vector/filter/index.js +190 -1
- package/dist/vector/index.cjs +2 -2
- package/dist/vector/index.d.cts +10 -24
- package/dist/vector/index.d.ts +10 -24
- package/dist/vector/index.js +1 -1
- package/dist/voice/index.cjs +4 -4
- package/dist/voice/index.d.cts +11 -12
- package/dist/voice/index.d.ts +11 -12
- package/dist/voice/index.js +1 -1
- package/dist/workflows/index.cjs +17 -69
- package/dist/workflows/index.d.cts +195 -75
- package/dist/workflows/index.d.ts +195 -75
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/legacy/index.cjs +90 -0
- package/dist/workflows/legacy/index.d.cts +87 -0
- package/dist/workflows/legacy/index.d.ts +87 -0
- package/dist/workflows/legacy/index.js +1 -0
- package/package.json +19 -41
- package/workflows/legacy.d.ts +1 -0
- package/dist/chunk-CMPPXW4U.js +0 -154
- package/dist/chunk-GH6EMQSO.js +0 -131
- package/dist/chunk-JMJXBE7L.js +0 -843
- package/dist/chunk-LGERQTJM.js +0 -190
- package/dist/chunk-O44MSFMZ.cjs +0 -168
- package/dist/chunk-T6DN4C76.cjs +0 -134
- package/dist/chunk-UCZWRJRW.cjs +0 -667
- package/dist/chunk-YK3XJ52U.cjs +0 -192
- package/dist/chunk-YNOTY72R.cjs +0 -845
- package/dist/chunk-ZY2DW2VQ.js +0 -658
- package/dist/storage/libsql/index.cjs +0 -588
- package/dist/storage/libsql/index.d.cts +0 -104
- package/dist/storage/libsql/index.d.ts +0 -104
- package/dist/storage/libsql/index.js +0 -585
- package/dist/vector/libsql/index.cjs +0 -14
- package/dist/vector/libsql/index.d.cts +0 -86
- package/dist/vector/libsql/index.d.ts +0 -86
- package/dist/vector/libsql/index.js +0 -1
- package/dist/workflows/vNext/index.d.cts +0 -209
- package/dist/workflows/vNext/index.d.ts +0 -209
- package/storage/libsql.d.ts +0 -1
- package/vector/libsql.d.ts +0 -1
- package/workflows/vNext.d.ts +0 -1
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk5HULBQ2W_cjs = require('./chunk-5HULBQ2W.cjs');
|
|
4
|
+
var chunkU3L3NEOM_cjs = require('./chunk-U3L3NEOM.cjs');
|
|
5
|
+
var chunkYEULQPUY_cjs = require('./chunk-YEULQPUY.cjs');
|
|
6
|
+
|
|
7
|
+
// src/memory/memory.ts
|
|
8
|
+
var MemoryProcessor = class extends chunkYEULQPUY_cjs.MastraBase {
|
|
9
|
+
/**
|
|
10
|
+
* Process a list of messages and return a filtered or transformed list.
|
|
11
|
+
* @param messages The messages to process
|
|
12
|
+
* @returns The processed messages
|
|
13
|
+
*/
|
|
14
|
+
process(messages, _opts) {
|
|
15
|
+
return messages;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
var memoryDefaultOptions = {
|
|
19
|
+
lastMessages: 10,
|
|
20
|
+
semanticRecall: false,
|
|
21
|
+
threads: {
|
|
22
|
+
generateTitle: false
|
|
23
|
+
},
|
|
24
|
+
workingMemory: {
|
|
25
|
+
enabled: false,
|
|
26
|
+
template: `
|
|
27
|
+
# User Information
|
|
28
|
+
- **First Name**:
|
|
29
|
+
- **Last Name**:
|
|
30
|
+
- **Location**:
|
|
31
|
+
- **Occupation**:
|
|
32
|
+
- **Interests**:
|
|
33
|
+
- **Goals**:
|
|
34
|
+
- **Events**:
|
|
35
|
+
- **Facts**:
|
|
36
|
+
- **Projects**:
|
|
37
|
+
`
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
var MastraMemory = class extends chunkYEULQPUY_cjs.MastraBase {
|
|
41
|
+
MAX_CONTEXT_TOKENS;
|
|
42
|
+
_storage;
|
|
43
|
+
vector;
|
|
44
|
+
embedder;
|
|
45
|
+
processors = [];
|
|
46
|
+
threadConfig = { ...memoryDefaultOptions };
|
|
47
|
+
constructor(config) {
|
|
48
|
+
super({ component: "MEMORY", name: config.name });
|
|
49
|
+
if (config.options) this.threadConfig = this.getMergedThreadConfig(config.options);
|
|
50
|
+
if (config.processors) this.processors = config.processors;
|
|
51
|
+
if (config.storage) {
|
|
52
|
+
this._storage = chunk5HULBQ2W_cjs.augmentWithInit(config.storage);
|
|
53
|
+
this._hasOwnStorage = true;
|
|
54
|
+
}
|
|
55
|
+
if (this.threadConfig.semanticRecall) {
|
|
56
|
+
if (!config.vector) {
|
|
57
|
+
throw new Error(
|
|
58
|
+
`Semantic recall requires a vector store to be configured.
|
|
59
|
+
|
|
60
|
+
https://mastra.ai/en/docs/memory/semantic-recall`
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
this.vector = config.vector;
|
|
64
|
+
if (!config.embedder) {
|
|
65
|
+
throw new Error(
|
|
66
|
+
`Semantic recall requires an embedder to be configured.
|
|
67
|
+
|
|
68
|
+
https://mastra.ai/en/docs/memory/semantic-recall`
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
this.embedder = config.embedder;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
_hasOwnStorage = false;
|
|
75
|
+
get hasOwnStorage() {
|
|
76
|
+
return this._hasOwnStorage;
|
|
77
|
+
}
|
|
78
|
+
get storage() {
|
|
79
|
+
if (!this._storage) {
|
|
80
|
+
throw new Error(
|
|
81
|
+
`Memory requires a storage provider to function. Add a storage configuration to Memory or to your Mastra instance.
|
|
82
|
+
|
|
83
|
+
https://mastra.ai/en/docs/memory/overview`
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
return this._storage;
|
|
87
|
+
}
|
|
88
|
+
setStorage(storage) {
|
|
89
|
+
this._storage = storage;
|
|
90
|
+
}
|
|
91
|
+
setVector(vector) {
|
|
92
|
+
this.vector = vector;
|
|
93
|
+
}
|
|
94
|
+
setEmbedder(embedder) {
|
|
95
|
+
this.embedder = embedder;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Get a system message to inject into the conversation.
|
|
99
|
+
* This will be called before each conversation turn.
|
|
100
|
+
* Implementations can override this to inject custom system messages.
|
|
101
|
+
*/
|
|
102
|
+
async getSystemMessage(_input) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Get tools that should be available to the agent.
|
|
107
|
+
* This will be called when converting tools for the agent.
|
|
108
|
+
* Implementations can override this to provide additional tools.
|
|
109
|
+
*/
|
|
110
|
+
getTools(_config) {
|
|
111
|
+
return {};
|
|
112
|
+
}
|
|
113
|
+
async createEmbeddingIndex(dimensions) {
|
|
114
|
+
const defaultDimensions = 1536;
|
|
115
|
+
const isDefault = dimensions === defaultDimensions;
|
|
116
|
+
const usedDimensions = dimensions ?? defaultDimensions;
|
|
117
|
+
const separator = this.vector?.indexSeparator ?? "_";
|
|
118
|
+
const indexName = isDefault ? `memory${separator}messages` : `memory${separator}messages${separator}${usedDimensions}`;
|
|
119
|
+
if (typeof this.vector === `undefined`) {
|
|
120
|
+
throw new Error(`Tried to create embedding index but no vector db is attached to this Memory instance.`);
|
|
121
|
+
}
|
|
122
|
+
await this.vector.createIndex({
|
|
123
|
+
indexName,
|
|
124
|
+
dimension: usedDimensions
|
|
125
|
+
});
|
|
126
|
+
return { indexName };
|
|
127
|
+
}
|
|
128
|
+
getMergedThreadConfig(config) {
|
|
129
|
+
if (config?.workingMemory && "use" in config.workingMemory) {
|
|
130
|
+
throw new Error("The workingMemory.use option has been removed. Working memory always uses tool-call mode.");
|
|
131
|
+
}
|
|
132
|
+
return chunkU3L3NEOM_cjs.deepMerge(this.threadConfig, config || {});
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Apply all configured message processors to a list of messages.
|
|
136
|
+
* @param messages The messages to process
|
|
137
|
+
* @returns The processed messages
|
|
138
|
+
*/
|
|
139
|
+
applyProcessors(messages, opts) {
|
|
140
|
+
const processors = opts.processors || this.processors;
|
|
141
|
+
if (!processors || processors.length === 0) {
|
|
142
|
+
return messages;
|
|
143
|
+
}
|
|
144
|
+
let processedMessages = [...messages];
|
|
145
|
+
for (const processor of processors) {
|
|
146
|
+
processedMessages = processor.process(processedMessages, {
|
|
147
|
+
systemMessage: opts.systemMessage,
|
|
148
|
+
newMessages: opts.newMessages,
|
|
149
|
+
memorySystemMessage: opts.memorySystemMessage
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
return processedMessages;
|
|
153
|
+
}
|
|
154
|
+
processMessages({
|
|
155
|
+
messages,
|
|
156
|
+
processors,
|
|
157
|
+
...opts
|
|
158
|
+
}) {
|
|
159
|
+
return this.applyProcessors(messages, { processors: processors || this.processors, ...opts });
|
|
160
|
+
}
|
|
161
|
+
estimateTokens(text) {
|
|
162
|
+
return Math.ceil(text.split(" ").length * 1.3);
|
|
163
|
+
}
|
|
164
|
+
parseMessages(messages) {
|
|
165
|
+
return messages.map((msg) => {
|
|
166
|
+
let content = msg.content;
|
|
167
|
+
if (typeof content === "string" && (content.startsWith("[") || content.startsWith("{"))) {
|
|
168
|
+
try {
|
|
169
|
+
content = JSON.parse(content);
|
|
170
|
+
} catch {
|
|
171
|
+
}
|
|
172
|
+
} else if (typeof content === "number") {
|
|
173
|
+
content = String(content);
|
|
174
|
+
}
|
|
175
|
+
return {
|
|
176
|
+
...msg,
|
|
177
|
+
content
|
|
178
|
+
};
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
convertToUIMessages(messages) {
|
|
182
|
+
function addToolMessageToChat({
|
|
183
|
+
toolMessage,
|
|
184
|
+
messages: messages2,
|
|
185
|
+
toolResultContents
|
|
186
|
+
}) {
|
|
187
|
+
const chatMessages2 = messages2.map((message) => {
|
|
188
|
+
if (message.toolInvocations) {
|
|
189
|
+
return {
|
|
190
|
+
...message,
|
|
191
|
+
toolInvocations: message.toolInvocations.map((toolInvocation) => {
|
|
192
|
+
const toolResult = toolMessage.content.find((tool) => tool.toolCallId === toolInvocation.toolCallId);
|
|
193
|
+
if (toolResult) {
|
|
194
|
+
return {
|
|
195
|
+
...toolInvocation,
|
|
196
|
+
state: "result",
|
|
197
|
+
result: toolResult.result
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
return toolInvocation;
|
|
201
|
+
})
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
return message;
|
|
205
|
+
});
|
|
206
|
+
const resultContents = [...toolResultContents, ...toolMessage.content];
|
|
207
|
+
return { chatMessages: chatMessages2, toolResultContents: resultContents };
|
|
208
|
+
}
|
|
209
|
+
const { chatMessages } = messages.reduce(
|
|
210
|
+
(obj, message) => {
|
|
211
|
+
if (message.role === "tool") {
|
|
212
|
+
return addToolMessageToChat({
|
|
213
|
+
toolMessage: message,
|
|
214
|
+
messages: obj.chatMessages,
|
|
215
|
+
toolResultContents: obj.toolResultContents
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
let textContent = "";
|
|
219
|
+
let toolInvocations = [];
|
|
220
|
+
if (typeof message.content === "string") {
|
|
221
|
+
textContent = message.content;
|
|
222
|
+
} else if (typeof message.content === "number") {
|
|
223
|
+
textContent = String(message.content);
|
|
224
|
+
} else if (Array.isArray(message.content)) {
|
|
225
|
+
for (const content of message.content) {
|
|
226
|
+
if (content.type === "text") {
|
|
227
|
+
textContent += content.text;
|
|
228
|
+
} else if (content.type === "tool-call") {
|
|
229
|
+
const toolResult = obj.toolResultContents.find((tool) => tool.toolCallId === content.toolCallId);
|
|
230
|
+
toolInvocations.push({
|
|
231
|
+
state: toolResult ? "result" : "call",
|
|
232
|
+
toolCallId: content.toolCallId,
|
|
233
|
+
toolName: content.toolName,
|
|
234
|
+
args: content.args,
|
|
235
|
+
result: toolResult?.result
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
obj.chatMessages.push({
|
|
241
|
+
id: message.id,
|
|
242
|
+
role: message.role,
|
|
243
|
+
content: textContent,
|
|
244
|
+
toolInvocations,
|
|
245
|
+
createdAt: message.createdAt
|
|
246
|
+
});
|
|
247
|
+
return obj;
|
|
248
|
+
},
|
|
249
|
+
{ chatMessages: [], toolResultContents: [] }
|
|
250
|
+
);
|
|
251
|
+
return chatMessages;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Helper method to create a new thread
|
|
255
|
+
* @param title - Optional title for the thread
|
|
256
|
+
* @param metadata - Optional metadata for the thread
|
|
257
|
+
* @returns Promise resolving to the created thread
|
|
258
|
+
*/
|
|
259
|
+
async createThread({
|
|
260
|
+
threadId,
|
|
261
|
+
resourceId,
|
|
262
|
+
title,
|
|
263
|
+
metadata,
|
|
264
|
+
memoryConfig
|
|
265
|
+
}) {
|
|
266
|
+
await this.storage.init();
|
|
267
|
+
const thread = {
|
|
268
|
+
id: threadId || this.generateId(),
|
|
269
|
+
title: title || `New Thread ${(/* @__PURE__ */ new Date()).toISOString()}`,
|
|
270
|
+
resourceId,
|
|
271
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
272
|
+
updatedAt: /* @__PURE__ */ new Date(),
|
|
273
|
+
metadata
|
|
274
|
+
};
|
|
275
|
+
return this.saveThread({ thread, memoryConfig });
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Helper method to add a single message to a thread
|
|
279
|
+
* @param threadId - The thread to add the message to
|
|
280
|
+
* @param content - The message content
|
|
281
|
+
* @param role - The role of the message sender
|
|
282
|
+
* @param type - The type of the message
|
|
283
|
+
* @param toolNames - Optional array of tool names that were called
|
|
284
|
+
* @param toolCallArgs - Optional array of tool call arguments
|
|
285
|
+
* @param toolCallIds - Optional array of tool call ids
|
|
286
|
+
* @returns Promise resolving to the saved message
|
|
287
|
+
*/
|
|
288
|
+
async addMessage({
|
|
289
|
+
threadId,
|
|
290
|
+
resourceId,
|
|
291
|
+
config,
|
|
292
|
+
content,
|
|
293
|
+
role,
|
|
294
|
+
type,
|
|
295
|
+
toolNames,
|
|
296
|
+
toolCallArgs,
|
|
297
|
+
toolCallIds
|
|
298
|
+
}) {
|
|
299
|
+
const message = {
|
|
300
|
+
id: this.generateId(),
|
|
301
|
+
content,
|
|
302
|
+
role,
|
|
303
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
304
|
+
threadId,
|
|
305
|
+
resourceId,
|
|
306
|
+
type,
|
|
307
|
+
toolNames,
|
|
308
|
+
toolCallArgs,
|
|
309
|
+
toolCallIds
|
|
310
|
+
};
|
|
311
|
+
const savedMessages = await this.saveMessages({ messages: [message], memoryConfig: config });
|
|
312
|
+
return savedMessages[0];
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Generates a unique identifier
|
|
316
|
+
* @returns A unique string ID
|
|
317
|
+
*/
|
|
318
|
+
generateId() {
|
|
319
|
+
return crypto.randomUUID();
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
exports.MastraMemory = MastraMemory;
|
|
324
|
+
exports.MemoryProcessor = MemoryProcessor;
|
|
325
|
+
exports.memoryDefaultOptions = memoryDefaultOptions;
|
package/dist/deployer/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkCWSFP2HS_cjs = require('../chunk-CWSFP2HS.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "MastraDeployer", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunkCWSFP2HS_cjs.MastraDeployer; }
|
|
10
10
|
});
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { MastraBundler, IBundler } from '../bundler/index.cjs';
|
|
2
|
-
import '../base-
|
|
2
|
+
import '../base-aPYtPBT2.cjs';
|
|
3
3
|
import '@opentelemetry/api';
|
|
4
|
-
import '../
|
|
4
|
+
import '../logger-EhZkzZOr.cjs';
|
|
5
5
|
import 'stream';
|
|
6
|
-
import 'pino';
|
|
7
6
|
import '@opentelemetry/sdk-trace-base';
|
|
8
7
|
|
|
9
8
|
interface IDeployer extends IBundler {
|
package/dist/deployer/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { MastraBundler, IBundler } from '../bundler/index.js';
|
|
2
|
-
import '../base-
|
|
2
|
+
import '../base-tc5kgDTD.js';
|
|
3
3
|
import '@opentelemetry/api';
|
|
4
|
-
import '../
|
|
4
|
+
import '../logger-EhZkzZOr.js';
|
|
5
5
|
import 'stream';
|
|
6
|
-
import 'pino';
|
|
7
6
|
import '@opentelemetry/sdk-trace-base';
|
|
8
7
|
|
|
9
8
|
interface IDeployer extends IBundler {
|
package/dist/deployer/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { MastraDeployer } from '../chunk-
|
|
1
|
+
export { MastraDeployer } from '../chunk-2NTUAUGH.js';
|
package/dist/eval/index.d.cts
CHANGED
|
@@ -1,29 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
1
|
+
import { M as Metric, T as TestInfo, E as EvaluationResult } from '../types-Bo1uigWx.cjs';
|
|
2
|
+
export { a as MetricResult } from '../types-Bo1uigWx.cjs';
|
|
3
|
+
import { r as Agent } from '../base-aJ3etsh5.cjs';
|
|
4
4
|
import 'ai';
|
|
5
|
-
import '../base-
|
|
5
|
+
import '../base-aPYtPBT2.cjs';
|
|
6
6
|
import '@opentelemetry/api';
|
|
7
|
-
import '../
|
|
7
|
+
import '../logger-EhZkzZOr.cjs';
|
|
8
8
|
import 'stream';
|
|
9
|
-
import 'pino';
|
|
10
9
|
import '@opentelemetry/sdk-trace-base';
|
|
11
10
|
import 'sift';
|
|
12
11
|
import 'zod';
|
|
13
12
|
import 'json-schema';
|
|
14
|
-
import '../
|
|
15
|
-
import '
|
|
16
|
-
import 'node:events';
|
|
13
|
+
import '../deployer/index.cjs';
|
|
14
|
+
import '../bundler/index.cjs';
|
|
17
15
|
import 'node:http';
|
|
18
16
|
import 'hono';
|
|
19
|
-
import '../
|
|
17
|
+
import '../runtime-context/index.cjs';
|
|
20
18
|
import '../vector/index.cjs';
|
|
21
19
|
import '../vector/filter/index.cjs';
|
|
22
|
-
import 'events';
|
|
23
|
-
import '../deployer/index.cjs';
|
|
24
|
-
import '../bundler/index.cjs';
|
|
25
20
|
import 'hono/cors';
|
|
26
21
|
import 'hono-openapi';
|
|
22
|
+
import '../tts/index.cjs';
|
|
23
|
+
import 'xstate';
|
|
24
|
+
import 'node:events';
|
|
25
|
+
import 'events';
|
|
27
26
|
import 'ai/test';
|
|
28
27
|
|
|
29
28
|
declare function evaluate<T extends Agent>({ agentName, input, metric, output, runId, globalRunId, testInfo, instructions, }: {
|
package/dist/eval/index.d.ts
CHANGED
|
@@ -1,29 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
1
|
+
import { M as Metric, T as TestInfo, E as EvaluationResult } from '../types-Bo1uigWx.js';
|
|
2
|
+
export { a as MetricResult } from '../types-Bo1uigWx.js';
|
|
3
|
+
import { r as Agent } from '../base-DttB7sJD.js';
|
|
4
4
|
import 'ai';
|
|
5
|
-
import '../base-
|
|
5
|
+
import '../base-tc5kgDTD.js';
|
|
6
6
|
import '@opentelemetry/api';
|
|
7
|
-
import '../
|
|
7
|
+
import '../logger-EhZkzZOr.js';
|
|
8
8
|
import 'stream';
|
|
9
|
-
import 'pino';
|
|
10
9
|
import '@opentelemetry/sdk-trace-base';
|
|
11
10
|
import 'sift';
|
|
12
11
|
import 'zod';
|
|
13
12
|
import 'json-schema';
|
|
14
|
-
import '../
|
|
15
|
-
import '
|
|
16
|
-
import 'node:events';
|
|
13
|
+
import '../deployer/index.js';
|
|
14
|
+
import '../bundler/index.js';
|
|
17
15
|
import 'node:http';
|
|
18
16
|
import 'hono';
|
|
19
|
-
import '../
|
|
17
|
+
import '../runtime-context/index.js';
|
|
20
18
|
import '../vector/index.js';
|
|
21
19
|
import '../vector/filter/index.js';
|
|
22
|
-
import 'events';
|
|
23
|
-
import '../deployer/index.js';
|
|
24
|
-
import '../bundler/index.js';
|
|
25
20
|
import 'hono/cors';
|
|
26
21
|
import 'hono-openapi';
|
|
22
|
+
import '../tts/index.js';
|
|
23
|
+
import 'xstate';
|
|
24
|
+
import 'node:events';
|
|
25
|
+
import 'events';
|
|
27
26
|
import 'ai/test';
|
|
28
27
|
|
|
29
28
|
declare function evaluate<T extends Agent>({ agentName, input, metric, output, runId, globalRunId, testInfo, instructions, }: {
|
package/dist/hooks/index.d.cts
CHANGED
package/dist/hooks/index.d.ts
CHANGED