@mastra/core 0.15.3-alpha.1 → 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-TINMY4WA.js → chunk-APVV75XG.js} +3 -3
- package/dist/{chunk-TINMY4WA.js.map → chunk-APVV75XG.js.map} +1 -1
- package/dist/{chunk-HRDADYVX.cjs → chunk-AYFN43FB.cjs} +4 -4
- package/dist/{chunk-HRDADYVX.cjs.map → chunk-AYFN43FB.cjs.map} +1 -1
- package/dist/{chunk-FGCA6CCM.js → chunk-BGOXFBFK.js} +295 -275
- package/dist/chunk-BGOXFBFK.js.map +1 -0
- package/dist/{chunk-XEY3CWQW.cjs → chunk-D2GH2HAK.cjs} +9 -9
- package/dist/{chunk-XEY3CWQW.cjs.map → chunk-D2GH2HAK.cjs.map} +1 -1
- package/dist/{chunk-6Z7D7CA3.cjs → chunk-DJKIK6ZB.cjs} +326 -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-MKWJKRSX.js → chunk-MEROMP3Z.js} +3 -3
- package/dist/{chunk-MKWJKRSX.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-5MCNXLGT.js → chunk-TQRLZH64.js} +4 -4
- package/dist/{chunk-5MCNXLGT.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-CDLIHAX2.cjs → chunk-UGN2UU3K.cjs} +4 -4
- package/dist/{chunk-CDLIHAX2.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 +3 -3
- package/dist/chunk-6VROHRAR.cjs.map +0 -1
- package/dist/chunk-6Z7D7CA3.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-FGCA6CCM.js.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 -182
- 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,
|
|
@@ -480,6 +267,13 @@ function convertFullStreamChunkToUIMessageStream({
|
|
|
480
267
|
} : {})
|
|
481
268
|
};
|
|
482
269
|
}
|
|
270
|
+
case "tool-output":
|
|
271
|
+
{
|
|
272
|
+
return {
|
|
273
|
+
id: part.toolCallId,
|
|
274
|
+
...part.output
|
|
275
|
+
};
|
|
276
|
+
}
|
|
483
277
|
case "tool-error":
|
|
484
278
|
{
|
|
485
279
|
return {
|
|
@@ -559,16 +353,6 @@ function convertFullStreamChunkToUIMessageStream({
|
|
|
559
353
|
}
|
|
560
354
|
}
|
|
561
355
|
}
|
|
562
|
-
function getResponseUIMessageId({
|
|
563
|
-
originalMessages,
|
|
564
|
-
responseMessageId
|
|
565
|
-
}) {
|
|
566
|
-
if (originalMessages == null) {
|
|
567
|
-
return void 0;
|
|
568
|
-
}
|
|
569
|
-
const lastMessage = originalMessages[originalMessages.length - 1];
|
|
570
|
-
return lastMessage?.role === "assistant" ? lastMessage.id : typeof responseMessageId === "function" ? responseMessageId() : responseMessageId;
|
|
571
|
-
}
|
|
572
356
|
async function safeValidateTypes({
|
|
573
357
|
value,
|
|
574
358
|
schema
|
|
@@ -600,7 +384,50 @@ async function safeValidateTypes({
|
|
|
600
384
|
error: error instanceof Error ? error : new Error(String(error))
|
|
601
385
|
};
|
|
602
386
|
}
|
|
603
|
-
}
|
|
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
|
+
};
|
|
604
431
|
function prepareToolsAndToolChoice({
|
|
605
432
|
tools,
|
|
606
433
|
toolChoice,
|
|
@@ -668,45 +495,229 @@ function prepareToolsAndToolChoice({
|
|
|
668
495
|
}
|
|
669
496
|
};
|
|
670
497
|
}
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
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;
|
|
681
519
|
}
|
|
682
|
-
this.
|
|
683
|
-
if (this.status.type === "resolved") {
|
|
684
|
-
resolve(this.status.value);
|
|
685
|
-
} else if (this.status.type === "rejected") {
|
|
686
|
-
reject(this.status.error);
|
|
687
|
-
}
|
|
688
|
-
this._resolve = resolve;
|
|
689
|
-
this._reject = reject;
|
|
690
|
-
});
|
|
691
|
-
return this._promise;
|
|
520
|
+
this.streamParts.push(part);
|
|
692
521
|
}
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
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
|
+
}
|
|
697
546
|
};
|
|
698
|
-
|
|
699
|
-
|
|
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");
|
|
700
580
|
}
|
|
581
|
+
return messageList;
|
|
701
582
|
}
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
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
|
+
}
|
|
706
685
|
};
|
|
707
|
-
|
|
708
|
-
|
|
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");
|
|
709
719
|
}
|
|
720
|
+
return messageList;
|
|
710
721
|
}
|
|
711
722
|
};
|
|
712
723
|
function getTransformedSchema(schema) {
|
|
@@ -1157,7 +1168,7 @@ function convertMastraChunkToAISDKv5({
|
|
|
1157
1168
|
if (mode === "generate") {
|
|
1158
1169
|
return {
|
|
1159
1170
|
type: "file",
|
|
1160
|
-
file: new
|
|
1171
|
+
file: new chunkTWNFR6MQ_cjs.DefaultGeneratedFile({
|
|
1161
1172
|
data: chunk.payload.data,
|
|
1162
1173
|
mediaType: chunk.payload.mimeType
|
|
1163
1174
|
})
|
|
@@ -1165,7 +1176,7 @@ function convertMastraChunkToAISDKv5({
|
|
|
1165
1176
|
}
|
|
1166
1177
|
return {
|
|
1167
1178
|
type: "file",
|
|
1168
|
-
file: new
|
|
1179
|
+
file: new chunkTWNFR6MQ_cjs.DefaultGeneratedFileWithType({
|
|
1169
1180
|
data: chunk.payload.data,
|
|
1170
1181
|
mediaType: chunk.payload.mimeType
|
|
1171
1182
|
})
|
|
@@ -2209,7 +2220,7 @@ var MastraModelOutput = class extends chunkKXCUCBEI_cjs.MastraBase {
|
|
|
2209
2220
|
try {
|
|
2210
2221
|
if (self.processorRunner) {
|
|
2211
2222
|
await self.processorRunner.runOutputProcessors(self.messageList);
|
|
2212
|
-
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");
|
|
2213
2224
|
const messages = self.messageList.get.response.v2();
|
|
2214
2225
|
const messagesWithStructuredData = messages.filter(msg => msg.content.metadata && msg.content.metadata.structuredOutput);
|
|
2215
2226
|
if (messagesWithStructuredData[0] && messagesWithStructuredData[0].content.metadata?.structuredOutput) {
|
|
@@ -3304,7 +3315,9 @@ function createLLMExecutionStep({
|
|
|
3304
3315
|
toolCallStreaming,
|
|
3305
3316
|
controller,
|
|
3306
3317
|
output,
|
|
3307
|
-
headers
|
|
3318
|
+
headers,
|
|
3319
|
+
downloadRetries,
|
|
3320
|
+
downloadConcurrency
|
|
3308
3321
|
}) {
|
|
3309
3322
|
return createStep({
|
|
3310
3323
|
id: "llm-execution",
|
|
@@ -3325,11 +3338,16 @@ function createLLMExecutionStep({
|
|
|
3325
3338
|
switch (model.specificationVersion) {
|
|
3326
3339
|
case "v2":
|
|
3327
3340
|
{
|
|
3341
|
+
const inputMessages = await messageList.get.all.aiV5.llmPrompt({
|
|
3342
|
+
downloadRetries,
|
|
3343
|
+
downloadConcurrency,
|
|
3344
|
+
supportedUrls: model?.supportedUrls
|
|
3345
|
+
});
|
|
3328
3346
|
modelResult = execute({
|
|
3329
3347
|
runId,
|
|
3330
3348
|
model,
|
|
3331
3349
|
providerOptions,
|
|
3332
|
-
inputMessages
|
|
3350
|
+
inputMessages,
|
|
3333
3351
|
tools,
|
|
3334
3352
|
toolChoice,
|
|
3335
3353
|
options,
|
|
@@ -4062,7 +4080,8 @@ var MastraLLMVNext = class extends chunkKXCUCBEI_cjs.MastraBase {
|
|
|
4062
4080
|
resourceId,
|
|
4063
4081
|
output,
|
|
4064
4082
|
options,
|
|
4065
|
-
outputProcessors
|
|
4083
|
+
outputProcessors,
|
|
4084
|
+
providerOptions
|
|
4066
4085
|
// ...rest
|
|
4067
4086
|
}) {
|
|
4068
4087
|
let stopWhenToUse;
|
|
@@ -4083,7 +4102,7 @@ var MastraLLMVNext = class extends chunkKXCUCBEI_cjs.MastraBase {
|
|
|
4083
4102
|
output = this._applySchemaCompat(output);
|
|
4084
4103
|
}
|
|
4085
4104
|
try {
|
|
4086
|
-
const messageList = new
|
|
4105
|
+
const messageList = new chunkTWNFR6MQ_cjs.MessageList({
|
|
4087
4106
|
threadId,
|
|
4088
4107
|
resourceId
|
|
4089
4108
|
});
|
|
@@ -4095,6 +4114,7 @@ var MastraLLMVNext = class extends chunkKXCUCBEI_cjs.MastraBase {
|
|
|
4095
4114
|
stopWhen: stopWhenToUse,
|
|
4096
4115
|
toolChoice,
|
|
4097
4116
|
modelSettings,
|
|
4117
|
+
providerOptions,
|
|
4098
4118
|
telemetry_settings: {
|
|
4099
4119
|
...this.experimental_telemetry,
|
|
4100
4120
|
...telemetry_settings
|
|
@@ -4141,7 +4161,7 @@ var MastraLLMVNext = class extends chunkKXCUCBEI_cjs.MastraBase {
|
|
|
4141
4161
|
this.logger.warn("Rate limit approaching, waiting 10 seconds", {
|
|
4142
4162
|
runId
|
|
4143
4163
|
});
|
|
4144
|
-
await
|
|
4164
|
+
await chunk24TFSB6Z_cjs.delay(10 * 1e3);
|
|
4145
4165
|
}
|
|
4146
4166
|
},
|
|
4147
4167
|
onFinish: async props => {
|
|
@@ -5027,7 +5047,7 @@ var Machine = class extends EventEmitter__default.default {
|
|
|
5027
5047
|
const logger = this.logger;
|
|
5028
5048
|
let mastraProxy = void 0;
|
|
5029
5049
|
if (this.#mastra) {
|
|
5030
|
-
mastraProxy =
|
|
5050
|
+
mastraProxy = chunk24TFSB6Z_cjs.createMastraProxy({
|
|
5031
5051
|
mastra: this.#mastra,
|
|
5032
5052
|
logger
|
|
5033
5053
|
});
|
|
@@ -9185,13 +9205,13 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9185
9205
|
this.logger.error(mastraError.toString());
|
|
9186
9206
|
throw mastraError;
|
|
9187
9207
|
}
|
|
9188
|
-
return
|
|
9208
|
+
return chunk24TFSB6Z_cjs.ensureToolProperties(this.#tools);
|
|
9189
9209
|
}
|
|
9190
9210
|
getTools({
|
|
9191
9211
|
runtimeContext = new chunkGPWMM745_cjs.RuntimeContext()
|
|
9192
9212
|
} = {}) {
|
|
9193
9213
|
if (typeof this.#tools !== "function") {
|
|
9194
|
-
return
|
|
9214
|
+
return chunk24TFSB6Z_cjs.ensureToolProperties(this.#tools);
|
|
9195
9215
|
}
|
|
9196
9216
|
const result = this.#tools({
|
|
9197
9217
|
runtimeContext,
|
|
@@ -9212,7 +9232,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9212
9232
|
this.logger.error(mastraError.toString());
|
|
9213
9233
|
throw mastraError;
|
|
9214
9234
|
}
|
|
9215
|
-
return
|
|
9235
|
+
return chunk24TFSB6Z_cjs.ensureToolProperties(tools);
|
|
9216
9236
|
});
|
|
9217
9237
|
}
|
|
9218
9238
|
get llm() {
|
|
@@ -9256,7 +9276,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9256
9276
|
mastra: this.#mastra
|
|
9257
9277
|
});
|
|
9258
9278
|
} else {
|
|
9259
|
-
llm = new
|
|
9279
|
+
llm = new chunkQHEB6ZLO_cjs.MastraLLMV1({
|
|
9260
9280
|
model: resolvedModel,
|
|
9261
9281
|
mastra: this.#mastra
|
|
9262
9282
|
});
|
|
@@ -9371,7 +9391,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9371
9391
|
runtimeContext,
|
|
9372
9392
|
model
|
|
9373
9393
|
});
|
|
9374
|
-
const normMessage = new
|
|
9394
|
+
const normMessage = new chunkTWNFR6MQ_cjs.MessageList().add(message, "user").get.all.ui().at(-1);
|
|
9375
9395
|
if (!normMessage) {
|
|
9376
9396
|
throw new Error(`Could not generate title from input ${JSON.stringify(message)}`);
|
|
9377
9397
|
}
|
|
@@ -9428,7 +9448,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9428
9448
|
async genTitle(userMessage, runtimeContext, model, instructions) {
|
|
9429
9449
|
try {
|
|
9430
9450
|
if (userMessage) {
|
|
9431
|
-
const normMessage = new
|
|
9451
|
+
const normMessage = new chunkTWNFR6MQ_cjs.MessageList().add(userMessage, "user").get.all.ui().at(-1);
|
|
9432
9452
|
if (normMessage) {
|
|
9433
9453
|
return await this.generateTitleFromUserMessage({
|
|
9434
9454
|
message: normMessage,
|
|
@@ -9453,7 +9473,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9453
9473
|
runId,
|
|
9454
9474
|
userMessages,
|
|
9455
9475
|
systemMessage,
|
|
9456
|
-
messageList = new
|
|
9476
|
+
messageList = new chunkTWNFR6MQ_cjs.MessageList({
|
|
9457
9477
|
threadId,
|
|
9458
9478
|
resourceId
|
|
9459
9479
|
}),
|
|
@@ -9508,7 +9528,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9508
9528
|
systemMessage: systemMessages,
|
|
9509
9529
|
memorySystemMessage: memorySystemMessage || void 0
|
|
9510
9530
|
});
|
|
9511
|
-
const returnList = new
|
|
9531
|
+
const returnList = new chunkTWNFR6MQ_cjs.MessageList().addSystem(systemMessages).add(processedMemoryMessages, "memory").add(newMessages, "user");
|
|
9512
9532
|
return {
|
|
9513
9533
|
threadId: thread.id,
|
|
9514
9534
|
messages: returnList.get.all.prompt()
|
|
@@ -9553,7 +9573,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9553
9573
|
}) : this.model,
|
|
9554
9574
|
agentAISpan
|
|
9555
9575
|
};
|
|
9556
|
-
const convertedToCoreTool =
|
|
9576
|
+
const convertedToCoreTool = chunk24TFSB6Z_cjs.makeCoreTool(toolObj, options);
|
|
9557
9577
|
convertedMemoryTools[toolName] = convertedToCoreTool;
|
|
9558
9578
|
}
|
|
9559
9579
|
}
|
|
@@ -9722,7 +9742,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9722
9742
|
writableStream,
|
|
9723
9743
|
agentAISpan
|
|
9724
9744
|
};
|
|
9725
|
-
return [k,
|
|
9745
|
+
return [k, chunk24TFSB6Z_cjs.makeCoreTool(tool, options)];
|
|
9726
9746
|
}));
|
|
9727
9747
|
const assignedToolEntriesConverted = Object.fromEntries(assignedCoreToolEntries.filter(entry => Boolean(entry)));
|
|
9728
9748
|
toolsForRequest = {
|
|
@@ -9766,7 +9786,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9766
9786
|
}) : this.model,
|
|
9767
9787
|
agentAISpan
|
|
9768
9788
|
};
|
|
9769
|
-
const convertedToCoreTool =
|
|
9789
|
+
const convertedToCoreTool = chunk24TFSB6Z_cjs.makeCoreTool(toolObj, options, "toolset");
|
|
9770
9790
|
toolsForRequest[toolName] = convertedToCoreTool;
|
|
9771
9791
|
}
|
|
9772
9792
|
}
|
|
@@ -9811,7 +9831,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9811
9831
|
}) : this.model,
|
|
9812
9832
|
agentAISpan
|
|
9813
9833
|
};
|
|
9814
|
-
const convertedToCoreTool =
|
|
9834
|
+
const convertedToCoreTool = chunk24TFSB6Z_cjs.makeCoreTool(rest, options, "client-tool");
|
|
9815
9835
|
toolsForRequest[toolName] = convertedToCoreTool;
|
|
9816
9836
|
}
|
|
9817
9837
|
}
|
|
@@ -9907,7 +9927,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9907
9927
|
let mastraProxy = void 0;
|
|
9908
9928
|
const logger = this.logger;
|
|
9909
9929
|
if (this.#mastra) {
|
|
9910
|
-
mastraProxy =
|
|
9930
|
+
mastraProxy = chunk24TFSB6Z_cjs.createMastraProxy({
|
|
9911
9931
|
mastra: this.#mastra,
|
|
9912
9932
|
logger
|
|
9913
9933
|
});
|
|
@@ -10105,7 +10125,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
10105
10125
|
writableStream,
|
|
10106
10126
|
agentAISpan
|
|
10107
10127
|
});
|
|
10108
|
-
const messageList = new
|
|
10128
|
+
const messageList = new chunkTWNFR6MQ_cjs.MessageList({
|
|
10109
10129
|
threadId,
|
|
10110
10130
|
resourceId,
|
|
10111
10131
|
generateMessageId: this.#mastra?.generateId?.bind(this.#mastra),
|
|
@@ -10192,7 +10212,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
10192
10212
|
let [memoryMessages, memorySystemMessage] = await Promise.all([existingThread ? this.getMemoryMessages({
|
|
10193
10213
|
resourceId,
|
|
10194
10214
|
threadId: threadObject.id,
|
|
10195
|
-
vectorMessageSearch: new
|
|
10215
|
+
vectorMessageSearch: new chunkTWNFR6MQ_cjs.MessageList().add(messages, `user`).getLatestUserContent() || "",
|
|
10196
10216
|
memoryConfig,
|
|
10197
10217
|
runtimeContext
|
|
10198
10218
|
}) : [], memory.getSystemMessage({
|
|
@@ -10215,7 +10235,7 @@ The following messages were remembered from a different conversation:
|
|
|
10215
10235
|
<remembered_from_other_conversation>
|
|
10216
10236
|
${(() => {
|
|
10217
10237
|
let result = ``;
|
|
10218
|
-
const messages2 = new
|
|
10238
|
+
const messages2 = new chunkTWNFR6MQ_cjs.MessageList().add(resultsFromOtherThreads, "memory").get.all.v1();
|
|
10219
10239
|
let lastYmd = null;
|
|
10220
10240
|
for (const msg of messages2) {
|
|
10221
10241
|
const date = msg.createdAt;
|
|
@@ -10267,7 +10287,7 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10267
10287
|
systemMessage,
|
|
10268
10288
|
memorySystemMessage: memorySystemMessage || void 0
|
|
10269
10289
|
});
|
|
10270
|
-
const processedList = new
|
|
10290
|
+
const processedList = new chunkTWNFR6MQ_cjs.MessageList({
|
|
10271
10291
|
threadId: threadObject.id,
|
|
10272
10292
|
resourceId,
|
|
10273
10293
|
generateMessageId: this.#mastra?.generateId?.bind(this.#mastra),
|
|
@@ -10334,7 +10354,7 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10334
10354
|
result: resToLog,
|
|
10335
10355
|
threadId
|
|
10336
10356
|
});
|
|
10337
|
-
const messageListResponses = new
|
|
10357
|
+
const messageListResponses = new chunkTWNFR6MQ_cjs.MessageList({
|
|
10338
10358
|
threadId,
|
|
10339
10359
|
resourceId,
|
|
10340
10360
|
generateMessageId: this.#mastra?.generateId?.bind(this.#mastra),
|
|
@@ -10784,7 +10804,7 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10784
10804
|
}),
|
|
10785
10805
|
execute: async () => {
|
|
10786
10806
|
const thread = threadFromArgs;
|
|
10787
|
-
const messageList = new
|
|
10807
|
+
const messageList = new chunkTWNFR6MQ_cjs.MessageList({
|
|
10788
10808
|
threadId: thread?.id,
|
|
10789
10809
|
resourceId,
|
|
10790
10810
|
generateMessageId: this.#mastra?.generateId?.bind(this.#mastra),
|
|
@@ -10866,7 +10886,7 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10866
10886
|
let [memoryMessages, memorySystemMessage] = await Promise.all([existingThread ? this.getMemoryMessages({
|
|
10867
10887
|
resourceId,
|
|
10868
10888
|
threadId: threadObject.id,
|
|
10869
|
-
vectorMessageSearch: new
|
|
10889
|
+
vectorMessageSearch: new chunkTWNFR6MQ_cjs.MessageList().add(options.messages, `user`).getLatestUserContent() || "",
|
|
10870
10890
|
memoryConfig,
|
|
10871
10891
|
runtimeContext
|
|
10872
10892
|
}) : [], memory.getSystemMessage({
|
|
@@ -10889,7 +10909,7 @@ The following messages were remembered from a different conversation:
|
|
|
10889
10909
|
<remembered_from_other_conversation>
|
|
10890
10910
|
${(() => {
|
|
10891
10911
|
let result = ``;
|
|
10892
|
-
const messages = new
|
|
10912
|
+
const messages = new chunkTWNFR6MQ_cjs.MessageList().add(resultsFromOtherThreads, "memory").get.all.v1();
|
|
10893
10913
|
let lastYmd = null;
|
|
10894
10914
|
for (const msg of messages) {
|
|
10895
10915
|
const date = msg.createdAt;
|
|
@@ -10941,7 +10961,7 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10941
10961
|
systemMessage,
|
|
10942
10962
|
memorySystemMessage: memorySystemMessage || void 0
|
|
10943
10963
|
});
|
|
10944
|
-
const processedList = new
|
|
10964
|
+
const processedList = new chunkTWNFR6MQ_cjs.MessageList({
|
|
10945
10965
|
threadId: threadObject.id,
|
|
10946
10966
|
resourceId,
|
|
10947
10967
|
generateMessageId: this.#mastra?.generateId?.bind(this.#mastra),
|
|
@@ -11434,7 +11454,7 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
11434
11454
|
const outputProcessorResult2 = await this.__runOutputProcessors({
|
|
11435
11455
|
runtimeContext: mergedGenerateOptions.runtimeContext || new chunkGPWMM745_cjs.RuntimeContext(),
|
|
11436
11456
|
outputProcessorOverrides: finalOutputProcessors,
|
|
11437
|
-
messageList: new
|
|
11457
|
+
messageList: new chunkTWNFR6MQ_cjs.MessageList({
|
|
11438
11458
|
threadId: llmOptions.threadId || "",
|
|
11439
11459
|
resourceId: llmOptions.resourceId || ""
|
|
11440
11460
|
}).add({
|
|
@@ -11525,7 +11545,7 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
11525
11545
|
const outputText = JSON.stringify(result.object);
|
|
11526
11546
|
const outputProcessorResult = await this.__runOutputProcessors({
|
|
11527
11547
|
runtimeContext: mergedGenerateOptions.runtimeContext || new chunkGPWMM745_cjs.RuntimeContext(),
|
|
11528
|
-
messageList: new
|
|
11548
|
+
messageList: new chunkTWNFR6MQ_cjs.MessageList({
|
|
11529
11549
|
threadId: llmOptions.threadId || "",
|
|
11530
11550
|
resourceId: llmOptions.resourceId || ""
|
|
11531
11551
|
}).add({
|
|
@@ -14229,7 +14249,7 @@ function createStep(params) {
|
|
|
14229
14249
|
}
|
|
14230
14250
|
};
|
|
14231
14251
|
}
|
|
14232
|
-
if (params instanceof
|
|
14252
|
+
if (params instanceof chunkZAJTIZZF_cjs.Tool) {
|
|
14233
14253
|
if (!params.inputSchema || !params.outputSchema) {
|
|
14234
14254
|
throw new Error("Tool must have input and output schemas defined");
|
|
14235
14255
|
}
|
|
@@ -15530,5 +15550,5 @@ exports.recursivelyCheckForFinalState = recursivelyCheckForFinalState;
|
|
|
15530
15550
|
exports.resolveVariables = resolveVariables;
|
|
15531
15551
|
exports.updateStepInHierarchy = updateStepInHierarchy;
|
|
15532
15552
|
exports.workflowToStep = workflowToStep;
|
|
15533
|
-
//# sourceMappingURL=chunk-
|
|
15534
|
-
//# sourceMappingURL=chunk-
|
|
15553
|
+
//# sourceMappingURL=chunk-DJKIK6ZB.cjs.map
|
|
15554
|
+
//# sourceMappingURL=chunk-DJKIK6ZB.cjs.map
|