@mastra/core 0.15.3-alpha.2 → 0.15.3-alpha.3
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/agent/index.cjs +11 -11
- package/dist/agent/index.js +2 -2
- package/dist/agent/input-processor/index.cjs +6 -6
- package/dist/agent/input-processor/index.js +1 -1
- package/dist/agent/message-list/index.d.ts +5 -1
- package/dist/agent/message-list/index.d.ts.map +1 -1
- package/dist/agent/message-list/prompt/convert-file.d.ts +7 -0
- package/dist/agent/message-list/prompt/convert-file.d.ts.map +1 -0
- package/dist/agent/message-list/prompt/download-assets.d.ts +15 -0
- package/dist/agent/message-list/prompt/download-assets.d.ts.map +1 -0
- package/dist/{chunk-6VROHRAR.cjs → chunk-24TFSB6Z.cjs} +30 -7
- package/dist/chunk-24TFSB6Z.cjs.map +1 -0
- package/dist/{chunk-BRNBKCHE.js → chunk-5TFCIXWE.js} +10 -8
- package/dist/chunk-5TFCIXWE.js.map +1 -0
- package/dist/{chunk-UT6KEZRF.js → chunk-APVV75XG.js} +3 -3
- package/dist/{chunk-UT6KEZRF.js.map → chunk-APVV75XG.js.map} +1 -1
- package/dist/{chunk-HHLPYCQG.cjs → chunk-AYFN43FB.cjs} +4 -4
- package/dist/{chunk-HHLPYCQG.cjs.map → chunk-AYFN43FB.cjs.map} +1 -1
- package/dist/{chunk-5NGEKEU7.js → chunk-BGOXFBFK.js} +288 -275
- package/dist/chunk-BGOXFBFK.js.map +1 -0
- package/dist/{chunk-HXYE4EJA.cjs → chunk-D2GH2HAK.cjs} +9 -9
- package/dist/{chunk-HXYE4EJA.cjs.map → chunk-D2GH2HAK.cjs.map} +1 -1
- package/dist/{chunk-7OSUKFNG.cjs → chunk-DJKIK6ZB.cjs} +319 -306
- package/dist/chunk-DJKIK6ZB.cjs.map +1 -0
- package/dist/{chunk-XOZ737RO.js → chunk-EMAAAVRA.js} +3 -3
- package/dist/{chunk-XOZ737RO.js.map → chunk-EMAAAVRA.js.map} +1 -1
- package/dist/chunk-GOG77M6R.js +103 -0
- package/dist/chunk-GOG77M6R.js.map +1 -0
- package/dist/{chunk-UG3KS3XV.cjs → chunk-HXEHQLBD.cjs} +4 -4
- package/dist/{chunk-UG3KS3XV.cjs.map → chunk-HXEHQLBD.cjs.map} +1 -1
- package/dist/{chunk-IYCG5OVT.js → chunk-MEROMP3Z.js} +3 -3
- package/dist/{chunk-IYCG5OVT.js.map → chunk-MEROMP3Z.js.map} +1 -1
- package/dist/{chunk-C5C4PN54.js → chunk-O7IQL4DX.js} +288 -5
- package/dist/chunk-O7IQL4DX.js.map +1 -0
- package/dist/{chunk-VBAWR62U.cjs → chunk-QHEB6ZLO.cjs} +13 -11
- package/dist/chunk-QHEB6ZLO.cjs.map +1 -0
- package/dist/{chunk-T64BA34G.js → chunk-TQRLZH64.js} +4 -4
- package/dist/{chunk-T64BA34G.js.map → chunk-TQRLZH64.js.map} +1 -1
- package/dist/{chunk-QA2TWVUS.cjs → chunk-TWNFR6MQ.cjs} +288 -5
- package/dist/chunk-TWNFR6MQ.cjs.map +1 -0
- package/dist/{chunk-WHEH32QU.cjs → chunk-UGN2UU3K.cjs} +4 -4
- package/dist/{chunk-WHEH32QU.cjs.map → chunk-UGN2UU3K.cjs.map} +1 -1
- package/dist/{chunk-E3LAPNKY.js → chunk-WUQSFK7W.js} +4 -4
- package/dist/{chunk-E3LAPNKY.js.map → chunk-WUQSFK7W.js.map} +1 -1
- package/dist/{chunk-QBNRMJAN.cjs → chunk-YTVX52NU.cjs} +6 -6
- package/dist/{chunk-QBNRMJAN.cjs.map → chunk-YTVX52NU.cjs.map} +1 -1
- package/dist/chunk-ZAJTIZZF.cjs +108 -0
- package/dist/chunk-ZAJTIZZF.cjs.map +1 -0
- package/dist/{chunk-FLXWZUIG.js → chunk-ZC64CG7J.js} +26 -4
- package/dist/chunk-ZC64CG7J.js.map +1 -0
- package/dist/index.cjs +47 -43
- package/dist/index.js +10 -10
- package/dist/integration/index.cjs +3 -3
- package/dist/integration/index.js +1 -1
- package/dist/llm/model/model.d.ts.map +1 -1
- package/dist/llm/model/model.loop.d.ts +1 -1
- package/dist/llm/model/model.loop.d.ts.map +1 -1
- package/dist/loop/index.cjs +2 -2
- package/dist/loop/index.js +1 -1
- package/dist/loop/types.d.ts +2 -0
- package/dist/loop/types.d.ts.map +1 -1
- package/dist/loop/workflow/llm-execution.d.ts +1 -1
- package/dist/loop/workflow/llm-execution.d.ts.map +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +4 -4
- package/dist/memory/index.js +1 -1
- package/dist/network/index.cjs +4 -4
- package/dist/network/index.js +2 -2
- package/dist/network/vNext/index.cjs +14 -14
- package/dist/network/vNext/index.js +2 -2
- package/dist/processors/index.cjs +8 -8
- package/dist/processors/index.js +2 -2
- package/dist/relevance/index.cjs +4 -4
- package/dist/relevance/index.js +1 -1
- package/dist/scores/index.cjs +5 -5
- package/dist/scores/index.js +1 -1
- package/dist/storage/index.cjs +3 -3
- package/dist/storage/index.js +1 -1
- package/dist/stream/aisdk/v5/compat/consume-stream.d.ts +8 -0
- package/dist/stream/aisdk/v5/compat/consume-stream.d.ts.map +1 -0
- package/dist/stream/aisdk/v5/compat/content.d.ts +7 -0
- package/dist/stream/aisdk/v5/compat/content.d.ts.map +1 -0
- package/dist/stream/aisdk/v5/compat/delayed-promise.d.ts +23 -0
- package/dist/stream/aisdk/v5/compat/delayed-promise.d.ts.map +1 -0
- package/dist/stream/aisdk/v5/compat/index.d.ts +8 -0
- package/dist/stream/aisdk/v5/compat/index.d.ts.map +1 -0
- package/dist/stream/aisdk/v5/compat/media.d.ts +91 -0
- package/dist/stream/aisdk/v5/compat/media.d.ts.map +1 -0
- package/dist/stream/aisdk/v5/compat/prepare-tools.d.ts +11 -0
- package/dist/stream/aisdk/v5/compat/prepare-tools.d.ts.map +1 -0
- package/dist/stream/aisdk/v5/compat/ui-message.d.ts +20 -0
- package/dist/stream/aisdk/v5/compat/ui-message.d.ts.map +1 -0
- package/dist/stream/aisdk/v5/compat/validation.d.ts +17 -0
- package/dist/stream/aisdk/v5/compat/validation.d.ts.map +1 -0
- package/dist/stream/aisdk/v5/output.d.ts +1 -1
- package/dist/stream/base/output.d.ts +1 -1
- package/dist/stream/index.cjs +3 -3
- package/dist/stream/index.js +1 -1
- package/dist/test-utils/llm-mock.cjs +2 -2
- package/dist/test-utils/llm-mock.js +1 -1
- package/dist/tools/index.cjs +4 -4
- package/dist/tools/index.js +1 -1
- package/dist/tools/is-vercel-tool.cjs +2 -2
- package/dist/tools/is-vercel-tool.js +1 -1
- package/dist/tools/validation.d.ts.map +1 -1
- package/dist/utils.cjs +20 -16
- package/dist/utils.d.ts +9 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/index.cjs +10 -10
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/legacy/index.cjs +22 -22
- package/dist/workflows/legacy/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-5NGEKEU7.js.map +0 -1
- package/dist/chunk-6VROHRAR.cjs.map +0 -1
- package/dist/chunk-7OSUKFNG.cjs.map +0 -1
- package/dist/chunk-BRNBKCHE.js.map +0 -1
- package/dist/chunk-C5C4PN54.js.map +0 -1
- package/dist/chunk-E4XQMNEI.cjs +0 -77
- package/dist/chunk-E4XQMNEI.cjs.map +0 -1
- package/dist/chunk-FLXWZUIG.js.map +0 -1
- package/dist/chunk-IVGAHFAJ.js +0 -72
- package/dist/chunk-IVGAHFAJ.js.map +0 -1
- package/dist/chunk-QA2TWVUS.cjs.map +0 -1
- package/dist/chunk-VBAWR62U.cjs.map +0 -1
- package/dist/stream/aisdk/v5/compat.d.ts +0 -73
- package/dist/stream/aisdk/v5/compat.d.ts.map +0 -1
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
var chunkFBBP67MQ_cjs = require('./chunk-FBBP67MQ.cjs');
|
|
4
4
|
var chunkNFXTYMWZ_cjs = require('./chunk-NFXTYMWZ.cjs');
|
|
5
5
|
var chunkZOU4K5MI_cjs = require('./chunk-ZOU4K5MI.cjs');
|
|
6
|
-
var
|
|
7
|
-
var
|
|
6
|
+
var chunkQHEB6ZLO_cjs = require('./chunk-QHEB6ZLO.cjs');
|
|
7
|
+
var chunkTWNFR6MQ_cjs = require('./chunk-TWNFR6MQ.cjs');
|
|
8
8
|
var chunkTSNDVBUU_cjs = require('./chunk-TSNDVBUU.cjs');
|
|
9
|
-
var
|
|
9
|
+
var chunk24TFSB6Z_cjs = require('./chunk-24TFSB6Z.cjs');
|
|
10
10
|
var chunkGPWMM745_cjs = require('./chunk-GPWMM745.cjs');
|
|
11
11
|
var chunkS6MAHT7F_cjs = require('./chunk-S6MAHT7F.cjs');
|
|
12
|
-
var
|
|
12
|
+
var chunkZAJTIZZF_cjs = require('./chunk-ZAJTIZZF.cjs');
|
|
13
13
|
var chunk4DKPMUAC_cjs = require('./chunk-4DKPMUAC.cjs');
|
|
14
14
|
var chunkC73WLCY3_cjs = require('./chunk-C73WLCY3.cjs');
|
|
15
15
|
var chunkKXCUCBEI_cjs = require('./chunk-KXCUCBEI.cjs');
|
|
@@ -90,230 +90,17 @@ var require_fast_deep_equal = chunkEBVYYC2Q_cjs.__commonJS({
|
|
|
90
90
|
// src/agent/index.ts
|
|
91
91
|
var import_fast_deep_equal = chunkEBVYYC2Q_cjs.__toESM(require_fast_deep_equal(), 1);
|
|
92
92
|
|
|
93
|
-
// src/
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
// src/processors/runner.ts
|
|
102
|
-
var ProcessorState = class {
|
|
103
|
-
constructor(processorName) {
|
|
104
|
-
this.processorName = processorName;
|
|
105
|
-
}
|
|
106
|
-
accumulatedText = "";
|
|
107
|
-
customState = {};
|
|
108
|
-
streamParts = [];
|
|
109
|
-
// Internal methods for the runner
|
|
110
|
-
addPart(part) {
|
|
111
|
-
if (part.type === "text-delta") {
|
|
112
|
-
this.accumulatedText += part.payload.text;
|
|
113
|
-
}
|
|
114
|
-
this.streamParts.push(part);
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
var ProcessorRunner = class {
|
|
118
|
-
inputProcessors;
|
|
119
|
-
outputProcessors;
|
|
120
|
-
logger;
|
|
121
|
-
agentName;
|
|
122
|
-
constructor({
|
|
123
|
-
inputProcessors,
|
|
124
|
-
outputProcessors,
|
|
125
|
-
logger,
|
|
126
|
-
agentName
|
|
127
|
-
}) {
|
|
128
|
-
this.inputProcessors = inputProcessors ?? [];
|
|
129
|
-
this.outputProcessors = outputProcessors ?? [];
|
|
130
|
-
this.logger = logger;
|
|
131
|
-
this.agentName = agentName;
|
|
132
|
-
}
|
|
133
|
-
async runOutputProcessors(messageList, telemetry) {
|
|
134
|
-
const responseMessages = messageList.clear.response.v2();
|
|
135
|
-
let processableMessages = [...responseMessages];
|
|
136
|
-
const ctx = {
|
|
137
|
-
abort: () => {
|
|
138
|
-
throw new TripWire("Tripwire triggered");
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
for (const [index, processor] of this.outputProcessors.entries()) {
|
|
142
|
-
const abort = reason => {
|
|
143
|
-
throw new TripWire(reason || `Tripwire triggered by ${processor.name}`);
|
|
144
|
-
};
|
|
145
|
-
ctx.abort = abort;
|
|
146
|
-
const processMethod = processor.processOutputResult?.bind(processor);
|
|
147
|
-
if (!processMethod) {
|
|
148
|
-
continue;
|
|
149
|
-
}
|
|
150
|
-
if (!telemetry) {
|
|
151
|
-
processableMessages = await processMethod({
|
|
152
|
-
messages: processableMessages,
|
|
153
|
-
abort: ctx.abort
|
|
154
|
-
});
|
|
155
|
-
} else {
|
|
156
|
-
await telemetry.traceMethod(async () => {
|
|
157
|
-
processableMessages = await processMethod({
|
|
158
|
-
messages: processableMessages,
|
|
159
|
-
abort: ctx.abort
|
|
160
|
-
});
|
|
161
|
-
return processableMessages;
|
|
162
|
-
}, {
|
|
163
|
-
spanName: `agent.outputProcessor.${processor.name}`,
|
|
164
|
-
attributes: {
|
|
165
|
-
"processor.name": processor.name,
|
|
166
|
-
"processor.index": index.toString(),
|
|
167
|
-
"processor.total": this.outputProcessors.length.toString()
|
|
168
|
-
}
|
|
169
|
-
})();
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
if (processableMessages.length > 0) {
|
|
173
|
-
messageList.add(processableMessages, "response");
|
|
174
|
-
}
|
|
175
|
-
return messageList;
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Process a stream part through all output processors with state management
|
|
179
|
-
*/
|
|
180
|
-
async processPart(part, processorStates) {
|
|
181
|
-
if (!this.outputProcessors.length) {
|
|
182
|
-
return {
|
|
183
|
-
part,
|
|
184
|
-
blocked: false
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
try {
|
|
188
|
-
let processedPart = part;
|
|
189
|
-
for (const processor of this.outputProcessors) {
|
|
190
|
-
try {
|
|
191
|
-
if (processor.processOutputStream && processedPart) {
|
|
192
|
-
let state = processorStates.get(processor.name);
|
|
193
|
-
if (!state) {
|
|
194
|
-
state = new ProcessorState(processor.name);
|
|
195
|
-
processorStates.set(processor.name, state);
|
|
196
|
-
}
|
|
197
|
-
state.addPart(processedPart);
|
|
198
|
-
const result = await processor.processOutputStream({
|
|
199
|
-
part: processedPart,
|
|
200
|
-
streamParts: state.streamParts,
|
|
201
|
-
state: state.customState,
|
|
202
|
-
abort: reason => {
|
|
203
|
-
throw new TripWire(reason || `Stream part blocked by ${processor.name}`);
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
processedPart = result;
|
|
207
|
-
}
|
|
208
|
-
} catch (error) {
|
|
209
|
-
if (error instanceof TripWire) {
|
|
210
|
-
return {
|
|
211
|
-
part: null,
|
|
212
|
-
blocked: true,
|
|
213
|
-
reason: error.message
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
this.logger.error(`[Agent:${this.agentName}] - Output processor ${processor.name} failed:`, error);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
return {
|
|
220
|
-
part: processedPart,
|
|
221
|
-
blocked: false
|
|
222
|
-
};
|
|
223
|
-
} catch (error) {
|
|
224
|
-
this.logger.error(`[Agent:${this.agentName}] - Stream part processing failed:`, error);
|
|
225
|
-
return {
|
|
226
|
-
part,
|
|
227
|
-
blocked: false
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
async runOutputProcessorsForStream(streamResult) {
|
|
232
|
-
return new ReadableStream({
|
|
233
|
-
start: async controller => {
|
|
234
|
-
const reader = streamResult.fullStream.getReader();
|
|
235
|
-
const processorStates = /* @__PURE__ */new Map();
|
|
236
|
-
try {
|
|
237
|
-
while (true) {
|
|
238
|
-
const {
|
|
239
|
-
done,
|
|
240
|
-
value
|
|
241
|
-
} = await reader.read();
|
|
242
|
-
if (done) {
|
|
243
|
-
controller.close();
|
|
244
|
-
break;
|
|
245
|
-
}
|
|
246
|
-
const {
|
|
247
|
-
part: processedPart,
|
|
248
|
-
blocked,
|
|
249
|
-
reason
|
|
250
|
-
} = await this.processPart(value, processorStates);
|
|
251
|
-
if (blocked) {
|
|
252
|
-
void this.logger.debug(`[Agent:${this.agentName}] - Stream part blocked by output processor`, {
|
|
253
|
-
reason,
|
|
254
|
-
originalPart: value
|
|
255
|
-
});
|
|
256
|
-
controller.enqueue({
|
|
257
|
-
type: "tripwire",
|
|
258
|
-
tripwireReason: reason || "Output processor blocked content"
|
|
259
|
-
});
|
|
260
|
-
controller.close();
|
|
261
|
-
break;
|
|
262
|
-
} else if (processedPart !== null) {
|
|
263
|
-
controller.enqueue(processedPart);
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
} catch (error) {
|
|
267
|
-
controller.error(error);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
async runInputProcessors(messageList, telemetry) {
|
|
273
|
-
const userMessages = messageList.clear.input.v2();
|
|
274
|
-
let processableMessages = [...userMessages];
|
|
275
|
-
const ctx = {
|
|
276
|
-
abort: () => {
|
|
277
|
-
throw new TripWire("Tripwire triggered");
|
|
278
|
-
}
|
|
279
|
-
};
|
|
280
|
-
for (const [index, processor] of this.inputProcessors.entries()) {
|
|
281
|
-
const abort = reason => {
|
|
282
|
-
throw new TripWire(reason || `Tripwire triggered by ${processor.name}`);
|
|
283
|
-
};
|
|
284
|
-
ctx.abort = abort;
|
|
285
|
-
const processMethod = processor.processInput?.bind(processor);
|
|
286
|
-
if (!processMethod) {
|
|
287
|
-
continue;
|
|
288
|
-
}
|
|
289
|
-
if (!telemetry) {
|
|
290
|
-
processableMessages = await processMethod({
|
|
291
|
-
messages: processableMessages,
|
|
292
|
-
abort: ctx.abort
|
|
293
|
-
});
|
|
294
|
-
} else {
|
|
295
|
-
await telemetry.traceMethod(async () => {
|
|
296
|
-
processableMessages = await processMethod({
|
|
297
|
-
messages: processableMessages,
|
|
298
|
-
abort: ctx.abort
|
|
299
|
-
});
|
|
300
|
-
return processableMessages;
|
|
301
|
-
}, {
|
|
302
|
-
spanName: `agent.inputProcessor.${processor.name}`,
|
|
303
|
-
attributes: {
|
|
304
|
-
"processor.name": processor.name,
|
|
305
|
-
"processor.index": index.toString(),
|
|
306
|
-
"processor.total": this.inputProcessors.length.toString()
|
|
307
|
-
}
|
|
308
|
-
})();
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
if (processableMessages.length > 0) {
|
|
312
|
-
messageList.add(processableMessages, "user");
|
|
313
|
-
}
|
|
314
|
-
return messageList;
|
|
93
|
+
// src/stream/aisdk/v5/compat/ui-message.ts
|
|
94
|
+
function getResponseUIMessageId({
|
|
95
|
+
originalMessages,
|
|
96
|
+
responseMessageId
|
|
97
|
+
}) {
|
|
98
|
+
if (originalMessages == null) {
|
|
99
|
+
return void 0;
|
|
315
100
|
}
|
|
316
|
-
|
|
101
|
+
const lastMessage = originalMessages[originalMessages.length - 1];
|
|
102
|
+
return lastMessage?.role === "assistant" ? lastMessage.id : typeof responseMessageId === "function" ? responseMessageId() : responseMessageId;
|
|
103
|
+
}
|
|
317
104
|
function convertFullStreamChunkToUIMessageStream({
|
|
318
105
|
part,
|
|
319
106
|
messageMetadataValue,
|
|
@@ -566,16 +353,6 @@ function convertFullStreamChunkToUIMessageStream({
|
|
|
566
353
|
}
|
|
567
354
|
}
|
|
568
355
|
}
|
|
569
|
-
function getResponseUIMessageId({
|
|
570
|
-
originalMessages,
|
|
571
|
-
responseMessageId
|
|
572
|
-
}) {
|
|
573
|
-
if (originalMessages == null) {
|
|
574
|
-
return void 0;
|
|
575
|
-
}
|
|
576
|
-
const lastMessage = originalMessages[originalMessages.length - 1];
|
|
577
|
-
return lastMessage?.role === "assistant" ? lastMessage.id : typeof responseMessageId === "function" ? responseMessageId() : responseMessageId;
|
|
578
|
-
}
|
|
579
356
|
async function safeValidateTypes({
|
|
580
357
|
value,
|
|
581
358
|
schema
|
|
@@ -607,7 +384,50 @@ async function safeValidateTypes({
|
|
|
607
384
|
error: error instanceof Error ? error : new Error(String(error))
|
|
608
385
|
};
|
|
609
386
|
}
|
|
610
|
-
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// src/stream/aisdk/v5/compat/delayed-promise.ts
|
|
390
|
+
var DelayedPromise = class {
|
|
391
|
+
status = {
|
|
392
|
+
type: "pending"
|
|
393
|
+
};
|
|
394
|
+
_promise;
|
|
395
|
+
_resolve = void 0;
|
|
396
|
+
_reject = void 0;
|
|
397
|
+
get promise() {
|
|
398
|
+
if (this._promise) {
|
|
399
|
+
return this._promise;
|
|
400
|
+
}
|
|
401
|
+
this._promise = new Promise((resolve, reject) => {
|
|
402
|
+
if (this.status.type === "resolved") {
|
|
403
|
+
resolve(this.status.value);
|
|
404
|
+
} else if (this.status.type === "rejected") {
|
|
405
|
+
reject(this.status.error);
|
|
406
|
+
}
|
|
407
|
+
this._resolve = resolve;
|
|
408
|
+
this._reject = reject;
|
|
409
|
+
});
|
|
410
|
+
return this._promise;
|
|
411
|
+
}
|
|
412
|
+
resolve(value) {
|
|
413
|
+
this.status = {
|
|
414
|
+
type: "resolved",
|
|
415
|
+
value
|
|
416
|
+
};
|
|
417
|
+
if (this._promise) {
|
|
418
|
+
this._resolve?.(value);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
reject(error) {
|
|
422
|
+
this.status = {
|
|
423
|
+
type: "rejected",
|
|
424
|
+
error
|
|
425
|
+
};
|
|
426
|
+
if (this._promise) {
|
|
427
|
+
this._reject?.(error);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
};
|
|
611
431
|
function prepareToolsAndToolChoice({
|
|
612
432
|
tools,
|
|
613
433
|
toolChoice,
|
|
@@ -675,45 +495,229 @@ function prepareToolsAndToolChoice({
|
|
|
675
495
|
}
|
|
676
496
|
};
|
|
677
497
|
}
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
498
|
+
|
|
499
|
+
// src/agent/trip-wire.ts
|
|
500
|
+
var TripWire = class extends Error {
|
|
501
|
+
constructor(reason) {
|
|
502
|
+
super(reason);
|
|
503
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
|
|
507
|
+
// src/processors/runner.ts
|
|
508
|
+
var ProcessorState = class {
|
|
509
|
+
constructor(processorName) {
|
|
510
|
+
this.processorName = processorName;
|
|
511
|
+
}
|
|
512
|
+
accumulatedText = "";
|
|
513
|
+
customState = {};
|
|
514
|
+
streamParts = [];
|
|
515
|
+
// Internal methods for the runner
|
|
516
|
+
addPart(part) {
|
|
517
|
+
if (part.type === "text-delta") {
|
|
518
|
+
this.accumulatedText += part.payload.text;
|
|
688
519
|
}
|
|
689
|
-
this.
|
|
690
|
-
if (this.status.type === "resolved") {
|
|
691
|
-
resolve(this.status.value);
|
|
692
|
-
} else if (this.status.type === "rejected") {
|
|
693
|
-
reject(this.status.error);
|
|
694
|
-
}
|
|
695
|
-
this._resolve = resolve;
|
|
696
|
-
this._reject = reject;
|
|
697
|
-
});
|
|
698
|
-
return this._promise;
|
|
520
|
+
this.streamParts.push(part);
|
|
699
521
|
}
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
522
|
+
};
|
|
523
|
+
var ProcessorRunner = class {
|
|
524
|
+
inputProcessors;
|
|
525
|
+
outputProcessors;
|
|
526
|
+
logger;
|
|
527
|
+
agentName;
|
|
528
|
+
constructor({
|
|
529
|
+
inputProcessors,
|
|
530
|
+
outputProcessors,
|
|
531
|
+
logger,
|
|
532
|
+
agentName
|
|
533
|
+
}) {
|
|
534
|
+
this.inputProcessors = inputProcessors ?? [];
|
|
535
|
+
this.outputProcessors = outputProcessors ?? [];
|
|
536
|
+
this.logger = logger;
|
|
537
|
+
this.agentName = agentName;
|
|
538
|
+
}
|
|
539
|
+
async runOutputProcessors(messageList, telemetry) {
|
|
540
|
+
const responseMessages = messageList.clear.response.v2();
|
|
541
|
+
let processableMessages = [...responseMessages];
|
|
542
|
+
const ctx = {
|
|
543
|
+
abort: () => {
|
|
544
|
+
throw new TripWire("Tripwire triggered");
|
|
545
|
+
}
|
|
704
546
|
};
|
|
705
|
-
|
|
706
|
-
|
|
547
|
+
for (const [index, processor] of this.outputProcessors.entries()) {
|
|
548
|
+
const abort = reason => {
|
|
549
|
+
throw new TripWire(reason || `Tripwire triggered by ${processor.name}`);
|
|
550
|
+
};
|
|
551
|
+
ctx.abort = abort;
|
|
552
|
+
const processMethod = processor.processOutputResult?.bind(processor);
|
|
553
|
+
if (!processMethod) {
|
|
554
|
+
continue;
|
|
555
|
+
}
|
|
556
|
+
if (!telemetry) {
|
|
557
|
+
processableMessages = await processMethod({
|
|
558
|
+
messages: processableMessages,
|
|
559
|
+
abort: ctx.abort
|
|
560
|
+
});
|
|
561
|
+
} else {
|
|
562
|
+
await telemetry.traceMethod(async () => {
|
|
563
|
+
processableMessages = await processMethod({
|
|
564
|
+
messages: processableMessages,
|
|
565
|
+
abort: ctx.abort
|
|
566
|
+
});
|
|
567
|
+
return processableMessages;
|
|
568
|
+
}, {
|
|
569
|
+
spanName: `agent.outputProcessor.${processor.name}`,
|
|
570
|
+
attributes: {
|
|
571
|
+
"processor.name": processor.name,
|
|
572
|
+
"processor.index": index.toString(),
|
|
573
|
+
"processor.total": this.outputProcessors.length.toString()
|
|
574
|
+
}
|
|
575
|
+
})();
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
if (processableMessages.length > 0) {
|
|
579
|
+
messageList.add(processableMessages, "response");
|
|
707
580
|
}
|
|
581
|
+
return messageList;
|
|
708
582
|
}
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
583
|
+
/**
|
|
584
|
+
* Process a stream part through all output processors with state management
|
|
585
|
+
*/
|
|
586
|
+
async processPart(part, processorStates) {
|
|
587
|
+
if (!this.outputProcessors.length) {
|
|
588
|
+
return {
|
|
589
|
+
part,
|
|
590
|
+
blocked: false
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
try {
|
|
594
|
+
let processedPart = part;
|
|
595
|
+
for (const processor of this.outputProcessors) {
|
|
596
|
+
try {
|
|
597
|
+
if (processor.processOutputStream && processedPart) {
|
|
598
|
+
let state = processorStates.get(processor.name);
|
|
599
|
+
if (!state) {
|
|
600
|
+
state = new ProcessorState(processor.name);
|
|
601
|
+
processorStates.set(processor.name, state);
|
|
602
|
+
}
|
|
603
|
+
state.addPart(processedPart);
|
|
604
|
+
const result = await processor.processOutputStream({
|
|
605
|
+
part: processedPart,
|
|
606
|
+
streamParts: state.streamParts,
|
|
607
|
+
state: state.customState,
|
|
608
|
+
abort: reason => {
|
|
609
|
+
throw new TripWire(reason || `Stream part blocked by ${processor.name}`);
|
|
610
|
+
}
|
|
611
|
+
});
|
|
612
|
+
processedPart = result;
|
|
613
|
+
}
|
|
614
|
+
} catch (error) {
|
|
615
|
+
if (error instanceof TripWire) {
|
|
616
|
+
return {
|
|
617
|
+
part: null,
|
|
618
|
+
blocked: true,
|
|
619
|
+
reason: error.message
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
this.logger.error(`[Agent:${this.agentName}] - Output processor ${processor.name} failed:`, error);
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
return {
|
|
626
|
+
part: processedPart,
|
|
627
|
+
blocked: false
|
|
628
|
+
};
|
|
629
|
+
} catch (error) {
|
|
630
|
+
this.logger.error(`[Agent:${this.agentName}] - Stream part processing failed:`, error);
|
|
631
|
+
return {
|
|
632
|
+
part,
|
|
633
|
+
blocked: false
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
async runOutputProcessorsForStream(streamResult) {
|
|
638
|
+
return new ReadableStream({
|
|
639
|
+
start: async controller => {
|
|
640
|
+
const reader = streamResult.fullStream.getReader();
|
|
641
|
+
const processorStates = /* @__PURE__ */new Map();
|
|
642
|
+
try {
|
|
643
|
+
while (true) {
|
|
644
|
+
const {
|
|
645
|
+
done,
|
|
646
|
+
value
|
|
647
|
+
} = await reader.read();
|
|
648
|
+
if (done) {
|
|
649
|
+
controller.close();
|
|
650
|
+
break;
|
|
651
|
+
}
|
|
652
|
+
const {
|
|
653
|
+
part: processedPart,
|
|
654
|
+
blocked,
|
|
655
|
+
reason
|
|
656
|
+
} = await this.processPart(value, processorStates);
|
|
657
|
+
if (blocked) {
|
|
658
|
+
void this.logger.debug(`[Agent:${this.agentName}] - Stream part blocked by output processor`, {
|
|
659
|
+
reason,
|
|
660
|
+
originalPart: value
|
|
661
|
+
});
|
|
662
|
+
controller.enqueue({
|
|
663
|
+
type: "tripwire",
|
|
664
|
+
tripwireReason: reason || "Output processor blocked content"
|
|
665
|
+
});
|
|
666
|
+
controller.close();
|
|
667
|
+
break;
|
|
668
|
+
} else if (processedPart !== null) {
|
|
669
|
+
controller.enqueue(processedPart);
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
} catch (error) {
|
|
673
|
+
controller.error(error);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
async runInputProcessors(messageList, telemetry) {
|
|
679
|
+
const userMessages = messageList.clear.input.v2();
|
|
680
|
+
let processableMessages = [...userMessages];
|
|
681
|
+
const ctx = {
|
|
682
|
+
abort: () => {
|
|
683
|
+
throw new TripWire("Tripwire triggered");
|
|
684
|
+
}
|
|
713
685
|
};
|
|
714
|
-
|
|
715
|
-
|
|
686
|
+
for (const [index, processor] of this.inputProcessors.entries()) {
|
|
687
|
+
const abort = reason => {
|
|
688
|
+
throw new TripWire(reason || `Tripwire triggered by ${processor.name}`);
|
|
689
|
+
};
|
|
690
|
+
ctx.abort = abort;
|
|
691
|
+
const processMethod = processor.processInput?.bind(processor);
|
|
692
|
+
if (!processMethod) {
|
|
693
|
+
continue;
|
|
694
|
+
}
|
|
695
|
+
if (!telemetry) {
|
|
696
|
+
processableMessages = await processMethod({
|
|
697
|
+
messages: processableMessages,
|
|
698
|
+
abort: ctx.abort
|
|
699
|
+
});
|
|
700
|
+
} else {
|
|
701
|
+
await telemetry.traceMethod(async () => {
|
|
702
|
+
processableMessages = await processMethod({
|
|
703
|
+
messages: processableMessages,
|
|
704
|
+
abort: ctx.abort
|
|
705
|
+
});
|
|
706
|
+
return processableMessages;
|
|
707
|
+
}, {
|
|
708
|
+
spanName: `agent.inputProcessor.${processor.name}`,
|
|
709
|
+
attributes: {
|
|
710
|
+
"processor.name": processor.name,
|
|
711
|
+
"processor.index": index.toString(),
|
|
712
|
+
"processor.total": this.inputProcessors.length.toString()
|
|
713
|
+
}
|
|
714
|
+
})();
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
if (processableMessages.length > 0) {
|
|
718
|
+
messageList.add(processableMessages, "user");
|
|
716
719
|
}
|
|
720
|
+
return messageList;
|
|
717
721
|
}
|
|
718
722
|
};
|
|
719
723
|
function getTransformedSchema(schema) {
|
|
@@ -1164,7 +1168,7 @@ function convertMastraChunkToAISDKv5({
|
|
|
1164
1168
|
if (mode === "generate") {
|
|
1165
1169
|
return {
|
|
1166
1170
|
type: "file",
|
|
1167
|
-
file: new
|
|
1171
|
+
file: new chunkTWNFR6MQ_cjs.DefaultGeneratedFile({
|
|
1168
1172
|
data: chunk.payload.data,
|
|
1169
1173
|
mediaType: chunk.payload.mimeType
|
|
1170
1174
|
})
|
|
@@ -1172,7 +1176,7 @@ function convertMastraChunkToAISDKv5({
|
|
|
1172
1176
|
}
|
|
1173
1177
|
return {
|
|
1174
1178
|
type: "file",
|
|
1175
|
-
file: new
|
|
1179
|
+
file: new chunkTWNFR6MQ_cjs.DefaultGeneratedFileWithType({
|
|
1176
1180
|
data: chunk.payload.data,
|
|
1177
1181
|
mediaType: chunk.payload.mimeType
|
|
1178
1182
|
})
|
|
@@ -2216,7 +2220,7 @@ var MastraModelOutput = class extends chunkKXCUCBEI_cjs.MastraBase {
|
|
|
2216
2220
|
try {
|
|
2217
2221
|
if (self.processorRunner) {
|
|
2218
2222
|
await self.processorRunner.runOutputProcessors(self.messageList);
|
|
2219
|
-
const outputText = self.messageList.get.response.aiV4.core().map(m =>
|
|
2223
|
+
const outputText = self.messageList.get.response.aiV4.core().map(m => chunkTWNFR6MQ_cjs.MessageList.coreContentToString(m.content)).join("\n");
|
|
2220
2224
|
const messages = self.messageList.get.response.v2();
|
|
2221
2225
|
const messagesWithStructuredData = messages.filter(msg => msg.content.metadata && msg.content.metadata.structuredOutput);
|
|
2222
2226
|
if (messagesWithStructuredData[0] && messagesWithStructuredData[0].content.metadata?.structuredOutput) {
|
|
@@ -3311,7 +3315,9 @@ function createLLMExecutionStep({
|
|
|
3311
3315
|
toolCallStreaming,
|
|
3312
3316
|
controller,
|
|
3313
3317
|
output,
|
|
3314
|
-
headers
|
|
3318
|
+
headers,
|
|
3319
|
+
downloadRetries,
|
|
3320
|
+
downloadConcurrency
|
|
3315
3321
|
}) {
|
|
3316
3322
|
return createStep({
|
|
3317
3323
|
id: "llm-execution",
|
|
@@ -3332,11 +3338,16 @@ function createLLMExecutionStep({
|
|
|
3332
3338
|
switch (model.specificationVersion) {
|
|
3333
3339
|
case "v2":
|
|
3334
3340
|
{
|
|
3341
|
+
const inputMessages = await messageList.get.all.aiV5.llmPrompt({
|
|
3342
|
+
downloadRetries,
|
|
3343
|
+
downloadConcurrency,
|
|
3344
|
+
supportedUrls: model?.supportedUrls
|
|
3345
|
+
});
|
|
3335
3346
|
modelResult = execute({
|
|
3336
3347
|
runId,
|
|
3337
3348
|
model,
|
|
3338
3349
|
providerOptions,
|
|
3339
|
-
inputMessages
|
|
3350
|
+
inputMessages,
|
|
3340
3351
|
tools,
|
|
3341
3352
|
toolChoice,
|
|
3342
3353
|
options,
|
|
@@ -4069,7 +4080,8 @@ var MastraLLMVNext = class extends chunkKXCUCBEI_cjs.MastraBase {
|
|
|
4069
4080
|
resourceId,
|
|
4070
4081
|
output,
|
|
4071
4082
|
options,
|
|
4072
|
-
outputProcessors
|
|
4083
|
+
outputProcessors,
|
|
4084
|
+
providerOptions
|
|
4073
4085
|
// ...rest
|
|
4074
4086
|
}) {
|
|
4075
4087
|
let stopWhenToUse;
|
|
@@ -4090,7 +4102,7 @@ var MastraLLMVNext = class extends chunkKXCUCBEI_cjs.MastraBase {
|
|
|
4090
4102
|
output = this._applySchemaCompat(output);
|
|
4091
4103
|
}
|
|
4092
4104
|
try {
|
|
4093
|
-
const messageList = new
|
|
4105
|
+
const messageList = new chunkTWNFR6MQ_cjs.MessageList({
|
|
4094
4106
|
threadId,
|
|
4095
4107
|
resourceId
|
|
4096
4108
|
});
|
|
@@ -4102,6 +4114,7 @@ var MastraLLMVNext = class extends chunkKXCUCBEI_cjs.MastraBase {
|
|
|
4102
4114
|
stopWhen: stopWhenToUse,
|
|
4103
4115
|
toolChoice,
|
|
4104
4116
|
modelSettings,
|
|
4117
|
+
providerOptions,
|
|
4105
4118
|
telemetry_settings: {
|
|
4106
4119
|
...this.experimental_telemetry,
|
|
4107
4120
|
...telemetry_settings
|
|
@@ -4148,7 +4161,7 @@ var MastraLLMVNext = class extends chunkKXCUCBEI_cjs.MastraBase {
|
|
|
4148
4161
|
this.logger.warn("Rate limit approaching, waiting 10 seconds", {
|
|
4149
4162
|
runId
|
|
4150
4163
|
});
|
|
4151
|
-
await
|
|
4164
|
+
await chunk24TFSB6Z_cjs.delay(10 * 1e3);
|
|
4152
4165
|
}
|
|
4153
4166
|
},
|
|
4154
4167
|
onFinish: async props => {
|
|
@@ -5034,7 +5047,7 @@ var Machine = class extends EventEmitter__default.default {
|
|
|
5034
5047
|
const logger = this.logger;
|
|
5035
5048
|
let mastraProxy = void 0;
|
|
5036
5049
|
if (this.#mastra) {
|
|
5037
|
-
mastraProxy =
|
|
5050
|
+
mastraProxy = chunk24TFSB6Z_cjs.createMastraProxy({
|
|
5038
5051
|
mastra: this.#mastra,
|
|
5039
5052
|
logger
|
|
5040
5053
|
});
|
|
@@ -9192,13 +9205,13 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9192
9205
|
this.logger.error(mastraError.toString());
|
|
9193
9206
|
throw mastraError;
|
|
9194
9207
|
}
|
|
9195
|
-
return
|
|
9208
|
+
return chunk24TFSB6Z_cjs.ensureToolProperties(this.#tools);
|
|
9196
9209
|
}
|
|
9197
9210
|
getTools({
|
|
9198
9211
|
runtimeContext = new chunkGPWMM745_cjs.RuntimeContext()
|
|
9199
9212
|
} = {}) {
|
|
9200
9213
|
if (typeof this.#tools !== "function") {
|
|
9201
|
-
return
|
|
9214
|
+
return chunk24TFSB6Z_cjs.ensureToolProperties(this.#tools);
|
|
9202
9215
|
}
|
|
9203
9216
|
const result = this.#tools({
|
|
9204
9217
|
runtimeContext,
|
|
@@ -9219,7 +9232,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9219
9232
|
this.logger.error(mastraError.toString());
|
|
9220
9233
|
throw mastraError;
|
|
9221
9234
|
}
|
|
9222
|
-
return
|
|
9235
|
+
return chunk24TFSB6Z_cjs.ensureToolProperties(tools);
|
|
9223
9236
|
});
|
|
9224
9237
|
}
|
|
9225
9238
|
get llm() {
|
|
@@ -9263,7 +9276,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9263
9276
|
mastra: this.#mastra
|
|
9264
9277
|
});
|
|
9265
9278
|
} else {
|
|
9266
|
-
llm = new
|
|
9279
|
+
llm = new chunkQHEB6ZLO_cjs.MastraLLMV1({
|
|
9267
9280
|
model: resolvedModel,
|
|
9268
9281
|
mastra: this.#mastra
|
|
9269
9282
|
});
|
|
@@ -9378,7 +9391,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9378
9391
|
runtimeContext,
|
|
9379
9392
|
model
|
|
9380
9393
|
});
|
|
9381
|
-
const normMessage = new
|
|
9394
|
+
const normMessage = new chunkTWNFR6MQ_cjs.MessageList().add(message, "user").get.all.ui().at(-1);
|
|
9382
9395
|
if (!normMessage) {
|
|
9383
9396
|
throw new Error(`Could not generate title from input ${JSON.stringify(message)}`);
|
|
9384
9397
|
}
|
|
@@ -9435,7 +9448,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9435
9448
|
async genTitle(userMessage, runtimeContext, model, instructions) {
|
|
9436
9449
|
try {
|
|
9437
9450
|
if (userMessage) {
|
|
9438
|
-
const normMessage = new
|
|
9451
|
+
const normMessage = new chunkTWNFR6MQ_cjs.MessageList().add(userMessage, "user").get.all.ui().at(-1);
|
|
9439
9452
|
if (normMessage) {
|
|
9440
9453
|
return await this.generateTitleFromUserMessage({
|
|
9441
9454
|
message: normMessage,
|
|
@@ -9460,7 +9473,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9460
9473
|
runId,
|
|
9461
9474
|
userMessages,
|
|
9462
9475
|
systemMessage,
|
|
9463
|
-
messageList = new
|
|
9476
|
+
messageList = new chunkTWNFR6MQ_cjs.MessageList({
|
|
9464
9477
|
threadId,
|
|
9465
9478
|
resourceId
|
|
9466
9479
|
}),
|
|
@@ -9515,7 +9528,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9515
9528
|
systemMessage: systemMessages,
|
|
9516
9529
|
memorySystemMessage: memorySystemMessage || void 0
|
|
9517
9530
|
});
|
|
9518
|
-
const returnList = new
|
|
9531
|
+
const returnList = new chunkTWNFR6MQ_cjs.MessageList().addSystem(systemMessages).add(processedMemoryMessages, "memory").add(newMessages, "user");
|
|
9519
9532
|
return {
|
|
9520
9533
|
threadId: thread.id,
|
|
9521
9534
|
messages: returnList.get.all.prompt()
|
|
@@ -9560,7 +9573,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9560
9573
|
}) : this.model,
|
|
9561
9574
|
agentAISpan
|
|
9562
9575
|
};
|
|
9563
|
-
const convertedToCoreTool =
|
|
9576
|
+
const convertedToCoreTool = chunk24TFSB6Z_cjs.makeCoreTool(toolObj, options);
|
|
9564
9577
|
convertedMemoryTools[toolName] = convertedToCoreTool;
|
|
9565
9578
|
}
|
|
9566
9579
|
}
|
|
@@ -9729,7 +9742,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9729
9742
|
writableStream,
|
|
9730
9743
|
agentAISpan
|
|
9731
9744
|
};
|
|
9732
|
-
return [k,
|
|
9745
|
+
return [k, chunk24TFSB6Z_cjs.makeCoreTool(tool, options)];
|
|
9733
9746
|
}));
|
|
9734
9747
|
const assignedToolEntriesConverted = Object.fromEntries(assignedCoreToolEntries.filter(entry => Boolean(entry)));
|
|
9735
9748
|
toolsForRequest = {
|
|
@@ -9773,7 +9786,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9773
9786
|
}) : this.model,
|
|
9774
9787
|
agentAISpan
|
|
9775
9788
|
};
|
|
9776
|
-
const convertedToCoreTool =
|
|
9789
|
+
const convertedToCoreTool = chunk24TFSB6Z_cjs.makeCoreTool(toolObj, options, "toolset");
|
|
9777
9790
|
toolsForRequest[toolName] = convertedToCoreTool;
|
|
9778
9791
|
}
|
|
9779
9792
|
}
|
|
@@ -9818,7 +9831,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9818
9831
|
}) : this.model,
|
|
9819
9832
|
agentAISpan
|
|
9820
9833
|
};
|
|
9821
|
-
const convertedToCoreTool =
|
|
9834
|
+
const convertedToCoreTool = chunk24TFSB6Z_cjs.makeCoreTool(rest, options, "client-tool");
|
|
9822
9835
|
toolsForRequest[toolName] = convertedToCoreTool;
|
|
9823
9836
|
}
|
|
9824
9837
|
}
|
|
@@ -9914,7 +9927,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9914
9927
|
let mastraProxy = void 0;
|
|
9915
9928
|
const logger = this.logger;
|
|
9916
9929
|
if (this.#mastra) {
|
|
9917
|
-
mastraProxy =
|
|
9930
|
+
mastraProxy = chunk24TFSB6Z_cjs.createMastraProxy({
|
|
9918
9931
|
mastra: this.#mastra,
|
|
9919
9932
|
logger
|
|
9920
9933
|
});
|
|
@@ -10112,7 +10125,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
10112
10125
|
writableStream,
|
|
10113
10126
|
agentAISpan
|
|
10114
10127
|
});
|
|
10115
|
-
const messageList = new
|
|
10128
|
+
const messageList = new chunkTWNFR6MQ_cjs.MessageList({
|
|
10116
10129
|
threadId,
|
|
10117
10130
|
resourceId,
|
|
10118
10131
|
generateMessageId: this.#mastra?.generateId?.bind(this.#mastra),
|
|
@@ -10199,7 +10212,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
10199
10212
|
let [memoryMessages, memorySystemMessage] = await Promise.all([existingThread ? this.getMemoryMessages({
|
|
10200
10213
|
resourceId,
|
|
10201
10214
|
threadId: threadObject.id,
|
|
10202
|
-
vectorMessageSearch: new
|
|
10215
|
+
vectorMessageSearch: new chunkTWNFR6MQ_cjs.MessageList().add(messages, `user`).getLatestUserContent() || "",
|
|
10203
10216
|
memoryConfig,
|
|
10204
10217
|
runtimeContext
|
|
10205
10218
|
}) : [], memory.getSystemMessage({
|
|
@@ -10222,7 +10235,7 @@ The following messages were remembered from a different conversation:
|
|
|
10222
10235
|
<remembered_from_other_conversation>
|
|
10223
10236
|
${(() => {
|
|
10224
10237
|
let result = ``;
|
|
10225
|
-
const messages2 = new
|
|
10238
|
+
const messages2 = new chunkTWNFR6MQ_cjs.MessageList().add(resultsFromOtherThreads, "memory").get.all.v1();
|
|
10226
10239
|
let lastYmd = null;
|
|
10227
10240
|
for (const msg of messages2) {
|
|
10228
10241
|
const date = msg.createdAt;
|
|
@@ -10274,7 +10287,7 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10274
10287
|
systemMessage,
|
|
10275
10288
|
memorySystemMessage: memorySystemMessage || void 0
|
|
10276
10289
|
});
|
|
10277
|
-
const processedList = new
|
|
10290
|
+
const processedList = new chunkTWNFR6MQ_cjs.MessageList({
|
|
10278
10291
|
threadId: threadObject.id,
|
|
10279
10292
|
resourceId,
|
|
10280
10293
|
generateMessageId: this.#mastra?.generateId?.bind(this.#mastra),
|
|
@@ -10341,7 +10354,7 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10341
10354
|
result: resToLog,
|
|
10342
10355
|
threadId
|
|
10343
10356
|
});
|
|
10344
|
-
const messageListResponses = new
|
|
10357
|
+
const messageListResponses = new chunkTWNFR6MQ_cjs.MessageList({
|
|
10345
10358
|
threadId,
|
|
10346
10359
|
resourceId,
|
|
10347
10360
|
generateMessageId: this.#mastra?.generateId?.bind(this.#mastra),
|
|
@@ -10791,7 +10804,7 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10791
10804
|
}),
|
|
10792
10805
|
execute: async () => {
|
|
10793
10806
|
const thread = threadFromArgs;
|
|
10794
|
-
const messageList = new
|
|
10807
|
+
const messageList = new chunkTWNFR6MQ_cjs.MessageList({
|
|
10795
10808
|
threadId: thread?.id,
|
|
10796
10809
|
resourceId,
|
|
10797
10810
|
generateMessageId: this.#mastra?.generateId?.bind(this.#mastra),
|
|
@@ -10873,7 +10886,7 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10873
10886
|
let [memoryMessages, memorySystemMessage] = await Promise.all([existingThread ? this.getMemoryMessages({
|
|
10874
10887
|
resourceId,
|
|
10875
10888
|
threadId: threadObject.id,
|
|
10876
|
-
vectorMessageSearch: new
|
|
10889
|
+
vectorMessageSearch: new chunkTWNFR6MQ_cjs.MessageList().add(options.messages, `user`).getLatestUserContent() || "",
|
|
10877
10890
|
memoryConfig,
|
|
10878
10891
|
runtimeContext
|
|
10879
10892
|
}) : [], memory.getSystemMessage({
|
|
@@ -10896,7 +10909,7 @@ The following messages were remembered from a different conversation:
|
|
|
10896
10909
|
<remembered_from_other_conversation>
|
|
10897
10910
|
${(() => {
|
|
10898
10911
|
let result = ``;
|
|
10899
|
-
const messages = new
|
|
10912
|
+
const messages = new chunkTWNFR6MQ_cjs.MessageList().add(resultsFromOtherThreads, "memory").get.all.v1();
|
|
10900
10913
|
let lastYmd = null;
|
|
10901
10914
|
for (const msg of messages) {
|
|
10902
10915
|
const date = msg.createdAt;
|
|
@@ -10948,7 +10961,7 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10948
10961
|
systemMessage,
|
|
10949
10962
|
memorySystemMessage: memorySystemMessage || void 0
|
|
10950
10963
|
});
|
|
10951
|
-
const processedList = new
|
|
10964
|
+
const processedList = new chunkTWNFR6MQ_cjs.MessageList({
|
|
10952
10965
|
threadId: threadObject.id,
|
|
10953
10966
|
resourceId,
|
|
10954
10967
|
generateMessageId: this.#mastra?.generateId?.bind(this.#mastra),
|
|
@@ -11441,7 +11454,7 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
11441
11454
|
const outputProcessorResult2 = await this.__runOutputProcessors({
|
|
11442
11455
|
runtimeContext: mergedGenerateOptions.runtimeContext || new chunkGPWMM745_cjs.RuntimeContext(),
|
|
11443
11456
|
outputProcessorOverrides: finalOutputProcessors,
|
|
11444
|
-
messageList: new
|
|
11457
|
+
messageList: new chunkTWNFR6MQ_cjs.MessageList({
|
|
11445
11458
|
threadId: llmOptions.threadId || "",
|
|
11446
11459
|
resourceId: llmOptions.resourceId || ""
|
|
11447
11460
|
}).add({
|
|
@@ -11532,7 +11545,7 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
11532
11545
|
const outputText = JSON.stringify(result.object);
|
|
11533
11546
|
const outputProcessorResult = await this.__runOutputProcessors({
|
|
11534
11547
|
runtimeContext: mergedGenerateOptions.runtimeContext || new chunkGPWMM745_cjs.RuntimeContext(),
|
|
11535
|
-
messageList: new
|
|
11548
|
+
messageList: new chunkTWNFR6MQ_cjs.MessageList({
|
|
11536
11549
|
threadId: llmOptions.threadId || "",
|
|
11537
11550
|
resourceId: llmOptions.resourceId || ""
|
|
11538
11551
|
}).add({
|
|
@@ -14236,7 +14249,7 @@ function createStep(params) {
|
|
|
14236
14249
|
}
|
|
14237
14250
|
};
|
|
14238
14251
|
}
|
|
14239
|
-
if (params instanceof
|
|
14252
|
+
if (params instanceof chunkZAJTIZZF_cjs.Tool) {
|
|
14240
14253
|
if (!params.inputSchema || !params.outputSchema) {
|
|
14241
14254
|
throw new Error("Tool must have input and output schemas defined");
|
|
14242
14255
|
}
|
|
@@ -15537,5 +15550,5 @@ exports.recursivelyCheckForFinalState = recursivelyCheckForFinalState;
|
|
|
15537
15550
|
exports.resolveVariables = resolveVariables;
|
|
15538
15551
|
exports.updateStepInHierarchy = updateStepInHierarchy;
|
|
15539
15552
|
exports.workflowToStep = workflowToStep;
|
|
15540
|
-
//# sourceMappingURL=chunk-
|
|
15541
|
-
//# sourceMappingURL=chunk-
|
|
15553
|
+
//# sourceMappingURL=chunk-DJKIK6ZB.cjs.map
|
|
15554
|
+
//# sourceMappingURL=chunk-DJKIK6ZB.cjs.map
|