@mastra/core 0.15.3-alpha.2 → 0.15.3-alpha.4
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/agent.types.d.ts +9 -4
- package/dist/agent/agent.types.d.ts.map +1 -1
- package/dist/agent/index.cjs +11 -11
- package/dist/agent/index.d.ts +33 -5
- package/dist/agent/index.d.ts.map +1 -1
- 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/agent/types.d.ts +11 -6
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/ai-tracing/context.d.ts.map +1 -1
- package/dist/ai-tracing/default.d.ts.map +1 -1
- package/dist/ai-tracing/index.cjs +43 -31
- package/dist/ai-tracing/index.js +1 -1
- package/dist/ai-tracing/no-op.d.ts +0 -1
- package/dist/ai-tracing/no-op.d.ts.map +1 -1
- package/dist/ai-tracing/types.d.ts +0 -2
- package/dist/ai-tracing/types.d.ts.map +1 -1
- package/dist/ai-tracing/utils.d.ts +44 -8
- package/dist/ai-tracing/utils.d.ts.map +1 -1
- package/dist/{chunk-QA2TWVUS.cjs → chunk-5CJDO3UO.cjs} +292 -9
- package/dist/chunk-5CJDO3UO.cjs.map +1 -0
- package/dist/chunk-ABRPHTOG.cjs +108 -0
- package/dist/chunk-ABRPHTOG.cjs.map +1 -0
- package/dist/chunk-BJGHUKKM.js +103 -0
- package/dist/chunk-BJGHUKKM.js.map +1 -0
- package/dist/{chunk-BRNBKCHE.js → chunk-CKM2ESZF.js} +51 -26
- package/dist/chunk-CKM2ESZF.js.map +1 -0
- package/dist/{chunk-HHLPYCQG.cjs → chunk-DZADAEAF.cjs} +68 -22
- package/dist/chunk-DZADAEAF.cjs.map +1 -0
- package/dist/{chunk-VBAWR62U.cjs → chunk-F2CAC2R2.cjs} +54 -29
- package/dist/chunk-F2CAC2R2.cjs.map +1 -0
- package/dist/{chunk-C5C4PN54.js → chunk-F4SQXAXR.js} +292 -9
- package/dist/chunk-F4SQXAXR.js.map +1 -0
- package/dist/{chunk-UG3KS3XV.cjs → chunk-F6XWBVVG.cjs} +4 -4
- package/dist/{chunk-UG3KS3XV.cjs.map → chunk-F6XWBVVG.cjs.map} +1 -1
- package/dist/{chunk-WHEH32QU.cjs → chunk-FQRDHVZC.cjs} +4 -4
- package/dist/{chunk-WHEH32QU.cjs.map → chunk-FQRDHVZC.cjs.map} +1 -1
- package/dist/{chunk-4DKPMUAC.cjs → chunk-I7OAONIW.cjs} +259 -177
- package/dist/chunk-I7OAONIW.cjs.map +1 -0
- package/dist/{chunk-XOZ737RO.js → chunk-IODUKRQP.js} +3 -3
- package/dist/{chunk-XOZ737RO.js.map → chunk-IODUKRQP.js.map} +1 -1
- package/dist/{chunk-7OSUKFNG.cjs → chunk-KUNWELBC.cjs} +692 -507
- package/dist/chunk-KUNWELBC.cjs.map +1 -0
- package/dist/{chunk-WOTBMZCN.js → chunk-LOYT3WUA.js} +255 -176
- package/dist/chunk-LOYT3WUA.js.map +1 -0
- package/dist/{chunk-6VROHRAR.cjs → chunk-LVGGMWSE.cjs} +31 -8
- package/dist/chunk-LVGGMWSE.cjs.map +1 -0
- package/dist/{chunk-T64BA34G.js → chunk-OFPVAPUH.js} +4 -4
- package/dist/{chunk-T64BA34G.js.map → chunk-OFPVAPUH.js.map} +1 -1
- package/dist/{chunk-5NGEKEU7.js → chunk-P2IJ74UW.js} +661 -476
- package/dist/chunk-P2IJ74UW.js.map +1 -0
- package/dist/{chunk-QBNRMJAN.cjs → chunk-VVTB47UG.cjs} +6 -6
- package/dist/{chunk-QBNRMJAN.cjs.map → chunk-VVTB47UG.cjs.map} +1 -1
- package/dist/{chunk-HXYE4EJA.cjs → chunk-W5CF7DLB.cjs} +9 -9
- package/dist/{chunk-HXYE4EJA.cjs.map → chunk-W5CF7DLB.cjs.map} +1 -1
- package/dist/{chunk-FLXWZUIG.js → chunk-WWQ3QRPF.js} +27 -5
- package/dist/chunk-WWQ3QRPF.js.map +1 -0
- package/dist/{chunk-E3LAPNKY.js → chunk-XPFWOBV4.js} +4 -4
- package/dist/{chunk-E3LAPNKY.js.map → chunk-XPFWOBV4.js.map} +1 -1
- package/dist/{chunk-IYCG5OVT.js → chunk-YAWYQH3N.js} +3 -3
- package/dist/{chunk-IYCG5OVT.js.map → chunk-YAWYQH3N.js.map} +1 -1
- package/dist/{chunk-UT6KEZRF.js → chunk-YVIYEC6R.js} +62 -16
- package/dist/chunk-YVIYEC6R.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/index.d.ts +2 -2
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/model/base.types.d.ts +2 -2
- package/dist/llm/model/base.types.d.ts.map +1 -1
- package/dist/llm/model/model.d.ts +4 -4
- 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/llm/model/model.loop.types.d.ts +2 -0
- package/dist/llm/model/model.loop.types.d.ts.map +1 -1
- package/dist/loop/index.cjs +2 -2
- package/dist/loop/index.js +1 -1
- package/dist/loop/loop.d.ts +1 -1
- package/dist/loop/loop.d.ts.map +1 -1
- package/dist/loop/types.d.ts +4 -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/loop/workflow/stream.d.ts +1 -1
- package/dist/loop/workflow/stream.d.ts.map +1 -1
- package/dist/mastra/hooks.d.ts.map +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.d.ts +8 -3
- package/dist/mastra/index.d.ts.map +1 -1
- 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 +13 -11
- package/dist/processors/index.cjs.map +1 -1
- package/dist/processors/index.d.ts +4 -0
- package/dist/processors/index.d.ts.map +1 -1
- package/dist/processors/index.js +7 -5
- package/dist/processors/index.js.map +1 -1
- package/dist/processors/processors/moderation.d.ts +4 -0
- package/dist/processors/processors/moderation.d.ts.map +1 -1
- package/dist/processors/processors/pii-detector.d.ts +3 -0
- package/dist/processors/processors/pii-detector.d.ts.map +1 -1
- package/dist/processors/processors/prompt-injection-detector.d.ts +2 -0
- package/dist/processors/processors/prompt-injection-detector.d.ts.map +1 -1
- package/dist/processors/processors/system-prompt-scrubber.d.ts +2 -0
- package/dist/processors/processors/system-prompt-scrubber.d.ts.map +1 -1
- package/dist/processors/runner.d.ts +5 -4
- package/dist/processors/runner.d.ts.map +1 -1
- package/dist/relevance/index.cjs +4 -4
- package/dist/relevance/index.js +1 -1
- package/dist/scores/base.d.ts +2 -0
- package/dist/scores/base.d.ts.map +1 -1
- package/dist/scores/hooks.d.ts +3 -1
- package/dist/scores/hooks.d.ts.map +1 -1
- package/dist/scores/index.cjs +27 -18
- package/dist/scores/index.cjs.map +1 -1
- package/dist/scores/index.js +23 -14
- package/dist/scores/index.js.map +1 -1
- package/dist/scores/run-experiment/index.d.ts +2 -0
- package/dist/scores/run-experiment/index.d.ts.map +1 -1
- package/dist/scores/types.d.ts +3 -0
- package/dist/scores/types.d.ts.map +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/tool.d.ts +3 -1
- package/dist/tools/tool.d.ts.map +1 -1
- package/dist/tools/validation.d.ts.map +1 -1
- package/dist/utils.cjs +20 -16
- package/dist/utils.d.ts +12 -3
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/workflows/default.d.ts +13 -3
- package/dist/workflows/default.d.ts.map +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/execution-engine.d.ts +2 -2
- package/dist/workflows/execution-engine.d.ts.map +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/dist/workflows/workflow.d.ts +8 -8
- package/dist/workflows/workflow.d.ts.map +1 -1
- package/package.json +6 -6
- package/dist/chunk-4DKPMUAC.cjs.map +0 -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-HHLPYCQG.cjs.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-UT6KEZRF.js.map +0 -1
- package/dist/chunk-VBAWR62U.cjs.map +0 -1
- package/dist/chunk-WOTBMZCN.js.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,14 +3,14 @@
|
|
|
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 chunkF2CAC2R2_cjs = require('./chunk-F2CAC2R2.cjs');
|
|
7
|
+
var chunk5CJDO3UO_cjs = require('./chunk-5CJDO3UO.cjs');
|
|
8
8
|
var chunkTSNDVBUU_cjs = require('./chunk-TSNDVBUU.cjs');
|
|
9
|
-
var
|
|
9
|
+
var chunkLVGGMWSE_cjs = require('./chunk-LVGGMWSE.cjs');
|
|
10
10
|
var chunkGPWMM745_cjs = require('./chunk-GPWMM745.cjs');
|
|
11
11
|
var chunkS6MAHT7F_cjs = require('./chunk-S6MAHT7F.cjs');
|
|
12
|
-
var
|
|
13
|
-
var
|
|
12
|
+
var chunkABRPHTOG_cjs = require('./chunk-ABRPHTOG.cjs');
|
|
13
|
+
var chunkI7OAONIW_cjs = require('./chunk-I7OAONIW.cjs');
|
|
14
14
|
var chunkC73WLCY3_cjs = require('./chunk-C73WLCY3.cjs');
|
|
15
15
|
var chunkKXCUCBEI_cjs = require('./chunk-KXCUCBEI.cjs');
|
|
16
16
|
var chunkV5WKCX3G_cjs = require('./chunk-V5WKCX3G.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
|
|
@@ -608,6 +385,49 @@ async function safeValidateTypes({
|
|
|
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,234 @@ 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
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
520
|
+
this.streamParts.push(part);
|
|
521
|
+
}
|
|
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, tracingContext, telemetry) {
|
|
540
|
+
const responseMessages = messageList.clear.response.v2();
|
|
541
|
+
let processableMessages = [...responseMessages];
|
|
542
|
+
const ctx = {
|
|
543
|
+
abort: () => {
|
|
544
|
+
throw new TripWire("Tripwire triggered");
|
|
545
|
+
}
|
|
546
|
+
};
|
|
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
|
+
tracingContext
|
|
561
|
+
});
|
|
562
|
+
} else {
|
|
563
|
+
await telemetry.traceMethod(async () => {
|
|
564
|
+
processableMessages = await processMethod({
|
|
565
|
+
messages: processableMessages,
|
|
566
|
+
abort: ctx.abort,
|
|
567
|
+
tracingContext
|
|
568
|
+
});
|
|
569
|
+
return processableMessages;
|
|
570
|
+
}, {
|
|
571
|
+
spanName: `agent.outputProcessor.${processor.name}`,
|
|
572
|
+
attributes: {
|
|
573
|
+
"processor.name": processor.name,
|
|
574
|
+
"processor.index": index.toString(),
|
|
575
|
+
"processor.total": this.outputProcessors.length.toString()
|
|
576
|
+
}
|
|
577
|
+
})();
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
if (processableMessages.length > 0) {
|
|
581
|
+
messageList.add(processableMessages, "response");
|
|
582
|
+
}
|
|
583
|
+
return messageList;
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* Process a stream part through all output processors with state management
|
|
587
|
+
*/
|
|
588
|
+
async processPart(part, processorStates, tracingContext) {
|
|
589
|
+
if (!this.outputProcessors.length) {
|
|
590
|
+
return {
|
|
591
|
+
part,
|
|
592
|
+
blocked: false
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
try {
|
|
596
|
+
let processedPart = part;
|
|
597
|
+
for (const processor of this.outputProcessors) {
|
|
598
|
+
try {
|
|
599
|
+
if (processor.processOutputStream && processedPart) {
|
|
600
|
+
let state = processorStates.get(processor.name);
|
|
601
|
+
if (!state) {
|
|
602
|
+
state = new ProcessorState(processor.name);
|
|
603
|
+
processorStates.set(processor.name, state);
|
|
604
|
+
}
|
|
605
|
+
state.addPart(processedPart);
|
|
606
|
+
const result = await processor.processOutputStream({
|
|
607
|
+
part: processedPart,
|
|
608
|
+
streamParts: state.streamParts,
|
|
609
|
+
state: state.customState,
|
|
610
|
+
abort: reason => {
|
|
611
|
+
throw new TripWire(reason || `Stream part blocked by ${processor.name}`);
|
|
612
|
+
},
|
|
613
|
+
tracingContext
|
|
614
|
+
});
|
|
615
|
+
processedPart = result;
|
|
616
|
+
}
|
|
617
|
+
} catch (error) {
|
|
618
|
+
if (error instanceof TripWire) {
|
|
619
|
+
return {
|
|
620
|
+
part: null,
|
|
621
|
+
blocked: true,
|
|
622
|
+
reason: error.message
|
|
623
|
+
};
|
|
624
|
+
}
|
|
625
|
+
this.logger.error(`[Agent:${this.agentName}] - Output processor ${processor.name} failed:`, error);
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
return {
|
|
629
|
+
part: processedPart,
|
|
630
|
+
blocked: false
|
|
631
|
+
};
|
|
632
|
+
} catch (error) {
|
|
633
|
+
this.logger.error(`[Agent:${this.agentName}] - Stream part processing failed:`, error);
|
|
634
|
+
return {
|
|
635
|
+
part,
|
|
636
|
+
blocked: false
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
async runOutputProcessorsForStream(streamResult, tracingContext) {
|
|
641
|
+
return new ReadableStream({
|
|
642
|
+
start: async controller => {
|
|
643
|
+
const reader = streamResult.fullStream.getReader();
|
|
644
|
+
const processorStates = /* @__PURE__ */new Map();
|
|
645
|
+
try {
|
|
646
|
+
while (true) {
|
|
647
|
+
const {
|
|
648
|
+
done,
|
|
649
|
+
value
|
|
650
|
+
} = await reader.read();
|
|
651
|
+
if (done) {
|
|
652
|
+
controller.close();
|
|
653
|
+
break;
|
|
654
|
+
}
|
|
655
|
+
const {
|
|
656
|
+
part: processedPart,
|
|
657
|
+
blocked,
|
|
658
|
+
reason
|
|
659
|
+
} = await this.processPart(value, processorStates, tracingContext);
|
|
660
|
+
if (blocked) {
|
|
661
|
+
void this.logger.debug(`[Agent:${this.agentName}] - Stream part blocked by output processor`, {
|
|
662
|
+
reason,
|
|
663
|
+
originalPart: value
|
|
664
|
+
});
|
|
665
|
+
controller.enqueue({
|
|
666
|
+
type: "tripwire",
|
|
667
|
+
tripwireReason: reason || "Output processor blocked content"
|
|
668
|
+
});
|
|
669
|
+
controller.close();
|
|
670
|
+
break;
|
|
671
|
+
} else if (processedPart !== null) {
|
|
672
|
+
controller.enqueue(processedPart);
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
} catch (error) {
|
|
676
|
+
controller.error(error);
|
|
677
|
+
}
|
|
694
678
|
}
|
|
695
|
-
this._resolve = resolve;
|
|
696
|
-
this._reject = reject;
|
|
697
679
|
});
|
|
698
|
-
return this._promise;
|
|
699
680
|
}
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
681
|
+
async runInputProcessors(messageList, tracingContext, telemetry) {
|
|
682
|
+
const userMessages = messageList.clear.input.v2();
|
|
683
|
+
let processableMessages = [...userMessages];
|
|
684
|
+
const ctx = {
|
|
685
|
+
abort: () => {
|
|
686
|
+
throw new TripWire("Tripwire triggered");
|
|
687
|
+
}
|
|
704
688
|
};
|
|
705
|
-
|
|
706
|
-
|
|
689
|
+
for (const [index, processor] of this.inputProcessors.entries()) {
|
|
690
|
+
const abort = reason => {
|
|
691
|
+
throw new TripWire(reason || `Tripwire triggered by ${processor.name}`);
|
|
692
|
+
};
|
|
693
|
+
ctx.abort = abort;
|
|
694
|
+
const processMethod = processor.processInput?.bind(processor);
|
|
695
|
+
if (!processMethod) {
|
|
696
|
+
continue;
|
|
697
|
+
}
|
|
698
|
+
if (!telemetry) {
|
|
699
|
+
processableMessages = await processMethod({
|
|
700
|
+
messages: processableMessages,
|
|
701
|
+
abort: ctx.abort,
|
|
702
|
+
tracingContext
|
|
703
|
+
});
|
|
704
|
+
} else {
|
|
705
|
+
await telemetry.traceMethod(async () => {
|
|
706
|
+
processableMessages = await processMethod({
|
|
707
|
+
messages: processableMessages,
|
|
708
|
+
abort: ctx.abort,
|
|
709
|
+
tracingContext
|
|
710
|
+
});
|
|
711
|
+
return processableMessages;
|
|
712
|
+
}, {
|
|
713
|
+
spanName: `agent.inputProcessor.${processor.name}`,
|
|
714
|
+
attributes: {
|
|
715
|
+
"processor.name": processor.name,
|
|
716
|
+
"processor.index": index.toString(),
|
|
717
|
+
"processor.total": this.inputProcessors.length.toString()
|
|
718
|
+
}
|
|
719
|
+
})();
|
|
720
|
+
}
|
|
707
721
|
}
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
this.status = {
|
|
711
|
-
type: "rejected",
|
|
712
|
-
error
|
|
713
|
-
};
|
|
714
|
-
if (this._promise) {
|
|
715
|
-
this._reject?.(error);
|
|
722
|
+
if (processableMessages.length > 0) {
|
|
723
|
+
messageList.add(processableMessages, "user");
|
|
716
724
|
}
|
|
725
|
+
return messageList;
|
|
717
726
|
}
|
|
718
727
|
};
|
|
719
728
|
function getTransformedSchema(schema) {
|
|
@@ -1164,7 +1173,7 @@ function convertMastraChunkToAISDKv5({
|
|
|
1164
1173
|
if (mode === "generate") {
|
|
1165
1174
|
return {
|
|
1166
1175
|
type: "file",
|
|
1167
|
-
file: new
|
|
1176
|
+
file: new chunk5CJDO3UO_cjs.DefaultGeneratedFile({
|
|
1168
1177
|
data: chunk.payload.data,
|
|
1169
1178
|
mediaType: chunk.payload.mimeType
|
|
1170
1179
|
})
|
|
@@ -1172,7 +1181,7 @@ function convertMastraChunkToAISDKv5({
|
|
|
1172
1181
|
}
|
|
1173
1182
|
return {
|
|
1174
1183
|
type: "file",
|
|
1175
|
-
file: new
|
|
1184
|
+
file: new chunk5CJDO3UO_cjs.DefaultGeneratedFileWithType({
|
|
1176
1185
|
data: chunk.payload.data,
|
|
1177
1186
|
mediaType: chunk.payload.mimeType
|
|
1178
1187
|
})
|
|
@@ -2216,7 +2225,7 @@ var MastraModelOutput = class extends chunkKXCUCBEI_cjs.MastraBase {
|
|
|
2216
2225
|
try {
|
|
2217
2226
|
if (self.processorRunner) {
|
|
2218
2227
|
await self.processorRunner.runOutputProcessors(self.messageList);
|
|
2219
|
-
const outputText = self.messageList.get.response.aiV4.core().map(m =>
|
|
2228
|
+
const outputText = self.messageList.get.response.aiV4.core().map(m => chunk5CJDO3UO_cjs.MessageList.coreContentToString(m.content)).join("\n");
|
|
2220
2229
|
const messages = self.messageList.get.response.v2();
|
|
2221
2230
|
const messagesWithStructuredData = messages.filter(msg => msg.content.metadata && msg.content.metadata.structuredOutput);
|
|
2222
2231
|
if (messagesWithStructuredData[0] && messagesWithStructuredData[0].content.metadata?.structuredOutput) {
|
|
@@ -3311,7 +3320,9 @@ function createLLMExecutionStep({
|
|
|
3311
3320
|
toolCallStreaming,
|
|
3312
3321
|
controller,
|
|
3313
3322
|
output,
|
|
3314
|
-
headers
|
|
3323
|
+
headers,
|
|
3324
|
+
downloadRetries,
|
|
3325
|
+
downloadConcurrency
|
|
3315
3326
|
}) {
|
|
3316
3327
|
return createStep({
|
|
3317
3328
|
id: "llm-execution",
|
|
@@ -3332,11 +3343,16 @@ function createLLMExecutionStep({
|
|
|
3332
3343
|
switch (model.specificationVersion) {
|
|
3333
3344
|
case "v2":
|
|
3334
3345
|
{
|
|
3346
|
+
const inputMessages = await messageList.get.all.aiV5.llmPrompt({
|
|
3347
|
+
downloadRetries,
|
|
3348
|
+
downloadConcurrency,
|
|
3349
|
+
supportedUrls: model?.supportedUrls
|
|
3350
|
+
});
|
|
3335
3351
|
modelResult = execute({
|
|
3336
3352
|
runId,
|
|
3337
3353
|
model,
|
|
3338
3354
|
providerOptions,
|
|
3339
|
-
inputMessages
|
|
3355
|
+
inputMessages,
|
|
3340
3356
|
tools,
|
|
3341
3357
|
toolChoice,
|
|
3342
3358
|
options,
|
|
@@ -3753,12 +3769,23 @@ function workflowLoopStream({
|
|
|
3753
3769
|
modelSettings,
|
|
3754
3770
|
_internal,
|
|
3755
3771
|
modelStreamSpan,
|
|
3772
|
+
llmAISpan,
|
|
3756
3773
|
...rest
|
|
3757
3774
|
}) {
|
|
3758
3775
|
return new web.ReadableStream({
|
|
3759
3776
|
start: async controller => {
|
|
3760
3777
|
const writer = new WritableStream({
|
|
3761
3778
|
write: chunk => {
|
|
3779
|
+
if (llmAISpan && chunk.type === "text-delta") {
|
|
3780
|
+
llmAISpan.createEventSpan({
|
|
3781
|
+
type: "llm_chunk" /* LLM_CHUNK */,
|
|
3782
|
+
name: `llm chunk: ${chunk.type}`,
|
|
3783
|
+
output: chunk.payload.text,
|
|
3784
|
+
attributes: {
|
|
3785
|
+
chunkType: chunk.type
|
|
3786
|
+
}
|
|
3787
|
+
});
|
|
3788
|
+
}
|
|
3762
3789
|
controller.enqueue(chunk);
|
|
3763
3790
|
}
|
|
3764
3791
|
});
|
|
@@ -3859,6 +3886,9 @@ function workflowLoopStream({
|
|
|
3859
3886
|
user: rest.messageList.get.input.aiV5.model(),
|
|
3860
3887
|
nonUser: []
|
|
3861
3888
|
}
|
|
3889
|
+
},
|
|
3890
|
+
tracingContext: {
|
|
3891
|
+
currentSpan: llmAISpan
|
|
3862
3892
|
}
|
|
3863
3893
|
});
|
|
3864
3894
|
if (executionResult.status !== "success") {
|
|
@@ -3901,6 +3931,7 @@ function loop({
|
|
|
3901
3931
|
_internal,
|
|
3902
3932
|
mode = "stream",
|
|
3903
3933
|
outputProcessors,
|
|
3934
|
+
llmAISpan,
|
|
3904
3935
|
...rest
|
|
3905
3936
|
}) {
|
|
3906
3937
|
let loggerToUse = logger || new chunkV5WKCX3G_cjs.ConsoleLogger({
|
|
@@ -3958,6 +3989,7 @@ function loop({
|
|
|
3958
3989
|
telemetry_settings,
|
|
3959
3990
|
modelSettings,
|
|
3960
3991
|
outputProcessors,
|
|
3992
|
+
llmAISpan,
|
|
3961
3993
|
...rest
|
|
3962
3994
|
};
|
|
3963
3995
|
const streamFn = workflowLoopStream(workflowLoopProps);
|
|
@@ -4069,7 +4101,9 @@ var MastraLLMVNext = class extends chunkKXCUCBEI_cjs.MastraBase {
|
|
|
4069
4101
|
resourceId,
|
|
4070
4102
|
output,
|
|
4071
4103
|
options,
|
|
4072
|
-
outputProcessors
|
|
4104
|
+
outputProcessors,
|
|
4105
|
+
providerOptions,
|
|
4106
|
+
tracingContext
|
|
4073
4107
|
// ...rest
|
|
4074
4108
|
}) {
|
|
4075
4109
|
let stopWhenToUse;
|
|
@@ -4089,8 +4123,22 @@ var MastraLLMVNext = class extends chunkKXCUCBEI_cjs.MastraBase {
|
|
|
4089
4123
|
if (output) {
|
|
4090
4124
|
output = this._applySchemaCompat(output);
|
|
4091
4125
|
}
|
|
4126
|
+
const llmAISpan = tracingContext?.currentSpan?.createChildSpan({
|
|
4127
|
+
name: `llm stream: '${model.modelId}'`,
|
|
4128
|
+
type: "llm_generation" /* LLM_GENERATION */,
|
|
4129
|
+
input: messages,
|
|
4130
|
+
attributes: {
|
|
4131
|
+
model: model.modelId,
|
|
4132
|
+
provider: model.provider,
|
|
4133
|
+
streaming: true
|
|
4134
|
+
},
|
|
4135
|
+
metadata: {
|
|
4136
|
+
threadId,
|
|
4137
|
+
resourceId
|
|
4138
|
+
}
|
|
4139
|
+
});
|
|
4092
4140
|
try {
|
|
4093
|
-
const messageList = new
|
|
4141
|
+
const messageList = new chunk5CJDO3UO_cjs.MessageList({
|
|
4094
4142
|
threadId,
|
|
4095
4143
|
resourceId
|
|
4096
4144
|
});
|
|
@@ -4102,12 +4150,14 @@ var MastraLLMVNext = class extends chunkKXCUCBEI_cjs.MastraBase {
|
|
|
4102
4150
|
stopWhen: stopWhenToUse,
|
|
4103
4151
|
toolChoice,
|
|
4104
4152
|
modelSettings,
|
|
4153
|
+
providerOptions,
|
|
4105
4154
|
telemetry_settings: {
|
|
4106
4155
|
...this.experimental_telemetry,
|
|
4107
4156
|
...telemetry_settings
|
|
4108
4157
|
},
|
|
4109
4158
|
output,
|
|
4110
4159
|
outputProcessors,
|
|
4160
|
+
llmAISpan,
|
|
4111
4161
|
options: {
|
|
4112
4162
|
...options,
|
|
4113
4163
|
onStepFinish: async props => {
|
|
@@ -4148,7 +4198,7 @@ var MastraLLMVNext = class extends chunkKXCUCBEI_cjs.MastraBase {
|
|
|
4148
4198
|
this.logger.warn("Rate limit approaching, waiting 10 seconds", {
|
|
4149
4199
|
runId
|
|
4150
4200
|
});
|
|
4151
|
-
await
|
|
4201
|
+
await chunkLVGGMWSE_cjs.delay(10 * 1e3);
|
|
4152
4202
|
}
|
|
4153
4203
|
},
|
|
4154
4204
|
onFinish: async props => {
|
|
@@ -4190,7 +4240,11 @@ var MastraLLMVNext = class extends chunkKXCUCBEI_cjs.MastraBase {
|
|
|
4190
4240
|
}
|
|
4191
4241
|
}
|
|
4192
4242
|
};
|
|
4193
|
-
|
|
4243
|
+
const result = loop(loopOptions);
|
|
4244
|
+
llmAISpan?.end({
|
|
4245
|
+
output: result
|
|
4246
|
+
});
|
|
4247
|
+
return result;
|
|
4194
4248
|
} catch (e) {
|
|
4195
4249
|
const mastraError = new chunkC73WLCY3_cjs.MastraError({
|
|
4196
4250
|
id: "LLM_STREAM_TEXT_AI_SDK_EXECUTION_FAILED",
|
|
@@ -4204,6 +4258,9 @@ var MastraLLMVNext = class extends chunkKXCUCBEI_cjs.MastraBase {
|
|
|
4204
4258
|
resourceId: resourceId ?? "unknown"
|
|
4205
4259
|
}
|
|
4206
4260
|
}, e);
|
|
4261
|
+
llmAISpan?.error({
|
|
4262
|
+
error: mastraError
|
|
4263
|
+
});
|
|
4207
4264
|
throw mastraError;
|
|
4208
4265
|
}
|
|
4209
4266
|
}
|
|
@@ -4367,6 +4424,7 @@ function runScorer({
|
|
|
4367
4424
|
input,
|
|
4368
4425
|
output,
|
|
4369
4426
|
runtimeContext,
|
|
4427
|
+
tracingContext,
|
|
4370
4428
|
entity,
|
|
4371
4429
|
structuredOutput,
|
|
4372
4430
|
source,
|
|
@@ -4399,6 +4457,7 @@ function runScorer({
|
|
|
4399
4457
|
input,
|
|
4400
4458
|
output,
|
|
4401
4459
|
runtimeContext: Object.fromEntries(runtimeContext.entries()),
|
|
4460
|
+
tracingContext,
|
|
4402
4461
|
runId,
|
|
4403
4462
|
source,
|
|
4404
4463
|
entity,
|
|
@@ -5034,7 +5093,7 @@ var Machine = class extends EventEmitter__default.default {
|
|
|
5034
5093
|
const logger = this.logger;
|
|
5035
5094
|
let mastraProxy = void 0;
|
|
5036
5095
|
if (this.#mastra) {
|
|
5037
|
-
mastraProxy =
|
|
5096
|
+
mastraProxy = chunkLVGGMWSE_cjs.createMastraProxy({
|
|
5038
5097
|
mastra: this.#mastra,
|
|
5039
5098
|
logger
|
|
5040
5099
|
});
|
|
@@ -7612,7 +7671,8 @@ var ModerationProcessor = class _ModerationProcessor {
|
|
|
7612
7671
|
try {
|
|
7613
7672
|
const {
|
|
7614
7673
|
messages,
|
|
7615
|
-
abort
|
|
7674
|
+
abort,
|
|
7675
|
+
tracingContext
|
|
7616
7676
|
} = args;
|
|
7617
7677
|
if (messages.length === 0) {
|
|
7618
7678
|
return messages;
|
|
@@ -7624,7 +7684,7 @@ var ModerationProcessor = class _ModerationProcessor {
|
|
|
7624
7684
|
passedMessages.push(message);
|
|
7625
7685
|
continue;
|
|
7626
7686
|
}
|
|
7627
|
-
const moderationResult = await this.moderateContent(textContent);
|
|
7687
|
+
const moderationResult = await this.moderateContent(textContent, false, tracingContext);
|
|
7628
7688
|
if (this.isModerationFlagged(moderationResult)) {
|
|
7629
7689
|
this.handleFlaggedContent(moderationResult, this.strategy, abort);
|
|
7630
7690
|
if (this.strategy === "filter") {
|
|
@@ -7649,13 +7709,14 @@ var ModerationProcessor = class _ModerationProcessor {
|
|
|
7649
7709
|
const {
|
|
7650
7710
|
part,
|
|
7651
7711
|
streamParts,
|
|
7652
|
-
abort
|
|
7712
|
+
abort,
|
|
7713
|
+
tracingContext
|
|
7653
7714
|
} = args;
|
|
7654
7715
|
if (part.type !== "text-delta") {
|
|
7655
7716
|
return part;
|
|
7656
7717
|
}
|
|
7657
7718
|
const contentToModerate = this.buildContextFromChunks(streamParts);
|
|
7658
|
-
const moderationResult = await this.moderateContent(contentToModerate, true);
|
|
7719
|
+
const moderationResult = await this.moderateContent(contentToModerate, true, tracingContext);
|
|
7659
7720
|
if (this.isModerationFlagged(moderationResult)) {
|
|
7660
7721
|
this.handleFlaggedContent(moderationResult, this.strategy, abort);
|
|
7661
7722
|
if (this.strategy === "filter") {
|
|
@@ -7674,7 +7735,7 @@ var ModerationProcessor = class _ModerationProcessor {
|
|
|
7674
7735
|
/**
|
|
7675
7736
|
* Moderate content using the internal agent
|
|
7676
7737
|
*/
|
|
7677
|
-
async moderateContent(content, isStream = false) {
|
|
7738
|
+
async moderateContent(content, isStream = false, tracingContext) {
|
|
7678
7739
|
const prompt = this.createModerationPrompt(content, isStream);
|
|
7679
7740
|
try {
|
|
7680
7741
|
const model = await this.moderationAgent.getModel();
|
|
@@ -7691,12 +7752,14 @@ var ModerationProcessor = class _ModerationProcessor {
|
|
|
7691
7752
|
output: schema,
|
|
7692
7753
|
modelSettings: {
|
|
7693
7754
|
temperature: 0
|
|
7694
|
-
}
|
|
7755
|
+
},
|
|
7756
|
+
tracingContext
|
|
7695
7757
|
});
|
|
7696
7758
|
} else {
|
|
7697
7759
|
response = await this.moderationAgent.generate(prompt, {
|
|
7698
7760
|
output: schema,
|
|
7699
|
-
temperature: 0
|
|
7761
|
+
temperature: 0,
|
|
7762
|
+
tracingContext
|
|
7700
7763
|
});
|
|
7701
7764
|
}
|
|
7702
7765
|
const result = response.object;
|
|
@@ -7849,7 +7912,8 @@ var PromptInjectionDetector = class _PromptInjectionDetector {
|
|
|
7849
7912
|
try {
|
|
7850
7913
|
const {
|
|
7851
7914
|
messages,
|
|
7852
|
-
abort
|
|
7915
|
+
abort,
|
|
7916
|
+
tracingContext
|
|
7853
7917
|
} = args;
|
|
7854
7918
|
if (messages.length === 0) {
|
|
7855
7919
|
return messages;
|
|
@@ -7861,7 +7925,7 @@ var PromptInjectionDetector = class _PromptInjectionDetector {
|
|
|
7861
7925
|
processedMessages.push(message);
|
|
7862
7926
|
continue;
|
|
7863
7927
|
}
|
|
7864
|
-
const detectionResult = await this.detectPromptInjection(textContent);
|
|
7928
|
+
const detectionResult = await this.detectPromptInjection(textContent, tracingContext);
|
|
7865
7929
|
if (this.isInjectionFlagged(detectionResult)) {
|
|
7866
7930
|
const processedMessage = this.handleDetectedInjection(message, detectionResult, this.strategy, abort);
|
|
7867
7931
|
if (this.strategy === "filter") {
|
|
@@ -7886,7 +7950,7 @@ var PromptInjectionDetector = class _PromptInjectionDetector {
|
|
|
7886
7950
|
/**
|
|
7887
7951
|
* Detect prompt injection using the internal agent
|
|
7888
7952
|
*/
|
|
7889
|
-
async detectPromptInjection(content) {
|
|
7953
|
+
async detectPromptInjection(content, tracingContext) {
|
|
7890
7954
|
const prompt = this.createDetectionPrompt(content);
|
|
7891
7955
|
try {
|
|
7892
7956
|
const model = await this.detectionAgent.getModel();
|
|
@@ -7904,12 +7968,14 @@ var PromptInjectionDetector = class _PromptInjectionDetector {
|
|
|
7904
7968
|
output: schema,
|
|
7905
7969
|
modelSettings: {
|
|
7906
7970
|
temperature: 0
|
|
7907
|
-
}
|
|
7971
|
+
},
|
|
7972
|
+
tracingContext
|
|
7908
7973
|
});
|
|
7909
7974
|
} else {
|
|
7910
7975
|
response = await this.detectionAgent.generate(prompt, {
|
|
7911
7976
|
output: schema,
|
|
7912
|
-
temperature: 0
|
|
7977
|
+
temperature: 0,
|
|
7978
|
+
tracingContext
|
|
7913
7979
|
});
|
|
7914
7980
|
}
|
|
7915
7981
|
const result = response.object;
|
|
@@ -8080,7 +8146,8 @@ var PIIDetector = class _PIIDetector {
|
|
|
8080
8146
|
try {
|
|
8081
8147
|
const {
|
|
8082
8148
|
messages,
|
|
8083
|
-
abort
|
|
8149
|
+
abort,
|
|
8150
|
+
tracingContext
|
|
8084
8151
|
} = args;
|
|
8085
8152
|
if (messages.length === 0) {
|
|
8086
8153
|
return messages;
|
|
@@ -8092,7 +8159,7 @@ var PIIDetector = class _PIIDetector {
|
|
|
8092
8159
|
processedMessages.push(message);
|
|
8093
8160
|
continue;
|
|
8094
8161
|
}
|
|
8095
|
-
const detectionResult = await this.detectPII(textContent);
|
|
8162
|
+
const detectionResult = await this.detectPII(textContent, tracingContext);
|
|
8096
8163
|
if (this.isPIIFlagged(detectionResult)) {
|
|
8097
8164
|
const processedMessage = this.handleDetectedPII(message, detectionResult, this.strategy, abort);
|
|
8098
8165
|
if (this.strategy === "filter") {
|
|
@@ -8119,7 +8186,7 @@ var PIIDetector = class _PIIDetector {
|
|
|
8119
8186
|
/**
|
|
8120
8187
|
* Detect PII using the internal agent
|
|
8121
8188
|
*/
|
|
8122
|
-
async detectPII(content) {
|
|
8189
|
+
async detectPII(content, tracingContext) {
|
|
8123
8190
|
const prompt = this.createDetectionPrompt(content);
|
|
8124
8191
|
const schema = z__default.default.object({
|
|
8125
8192
|
categories: z__default.default.object(this.detectionTypes.reduce((props, type) => {
|
|
@@ -8144,12 +8211,14 @@ var PIIDetector = class _PIIDetector {
|
|
|
8144
8211
|
output: schema,
|
|
8145
8212
|
modelSettings: {
|
|
8146
8213
|
temperature: 0
|
|
8147
|
-
}
|
|
8214
|
+
},
|
|
8215
|
+
tracingContext
|
|
8148
8216
|
});
|
|
8149
8217
|
} else {
|
|
8150
8218
|
response = await this.detectionAgent.generate(prompt, {
|
|
8151
8219
|
output: schema,
|
|
8152
|
-
temperature: 0
|
|
8220
|
+
temperature: 0,
|
|
8221
|
+
tracingContext
|
|
8153
8222
|
});
|
|
8154
8223
|
}
|
|
8155
8224
|
const result = response.object;
|
|
@@ -8343,7 +8412,8 @@ IMPORTANT: IF NO PII IS DETECTED, RETURN AN EMPTY OBJECT, DO NOT INCLUDE ANYTHIN
|
|
|
8343
8412
|
async processOutputStream(args) {
|
|
8344
8413
|
const {
|
|
8345
8414
|
part,
|
|
8346
|
-
abort
|
|
8415
|
+
abort,
|
|
8416
|
+
tracingContext
|
|
8347
8417
|
} = args;
|
|
8348
8418
|
try {
|
|
8349
8419
|
if (part.type !== "text-delta") {
|
|
@@ -8353,7 +8423,7 @@ IMPORTANT: IF NO PII IS DETECTED, RETURN AN EMPTY OBJECT, DO NOT INCLUDE ANYTHIN
|
|
|
8353
8423
|
if (!textContent.trim()) {
|
|
8354
8424
|
return part;
|
|
8355
8425
|
}
|
|
8356
|
-
const detectionResult = await this.detectPII(textContent);
|
|
8426
|
+
const detectionResult = await this.detectPII(textContent, tracingContext);
|
|
8357
8427
|
if (this.isPIIFlagged(detectionResult)) {
|
|
8358
8428
|
switch (this.strategy) {
|
|
8359
8429
|
case "block":
|
|
@@ -9192,13 +9262,13 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9192
9262
|
this.logger.error(mastraError.toString());
|
|
9193
9263
|
throw mastraError;
|
|
9194
9264
|
}
|
|
9195
|
-
return
|
|
9265
|
+
return chunkLVGGMWSE_cjs.ensureToolProperties(this.#tools);
|
|
9196
9266
|
}
|
|
9197
9267
|
getTools({
|
|
9198
9268
|
runtimeContext = new chunkGPWMM745_cjs.RuntimeContext()
|
|
9199
9269
|
} = {}) {
|
|
9200
9270
|
if (typeof this.#tools !== "function") {
|
|
9201
|
-
return
|
|
9271
|
+
return chunkLVGGMWSE_cjs.ensureToolProperties(this.#tools);
|
|
9202
9272
|
}
|
|
9203
9273
|
const result = this.#tools({
|
|
9204
9274
|
runtimeContext,
|
|
@@ -9219,7 +9289,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9219
9289
|
this.logger.error(mastraError.toString());
|
|
9220
9290
|
throw mastraError;
|
|
9221
9291
|
}
|
|
9222
|
-
return
|
|
9292
|
+
return chunkLVGGMWSE_cjs.ensureToolProperties(tools);
|
|
9223
9293
|
});
|
|
9224
9294
|
}
|
|
9225
9295
|
get llm() {
|
|
@@ -9263,7 +9333,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9263
9333
|
mastra: this.#mastra
|
|
9264
9334
|
});
|
|
9265
9335
|
} else {
|
|
9266
|
-
llm = new
|
|
9336
|
+
llm = new chunkF2CAC2R2_cjs.MastraLLMV1({
|
|
9267
9337
|
model: resolvedModel,
|
|
9268
9338
|
mastra: this.#mastra
|
|
9269
9339
|
});
|
|
@@ -9371,6 +9441,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9371
9441
|
async generateTitleFromUserMessage({
|
|
9372
9442
|
message,
|
|
9373
9443
|
runtimeContext = new chunkGPWMM745_cjs.RuntimeContext(),
|
|
9444
|
+
tracingContext,
|
|
9374
9445
|
model,
|
|
9375
9446
|
instructions
|
|
9376
9447
|
}) {
|
|
@@ -9378,7 +9449,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9378
9449
|
runtimeContext,
|
|
9379
9450
|
model
|
|
9380
9451
|
});
|
|
9381
|
-
const normMessage = new
|
|
9452
|
+
const normMessage = new chunk5CJDO3UO_cjs.MessageList().add(message, "user").get.all.ui().at(-1);
|
|
9382
9453
|
if (!normMessage) {
|
|
9383
9454
|
throw new Error(`Could not generate title from input ${JSON.stringify(message)}`);
|
|
9384
9455
|
}
|
|
@@ -9403,6 +9474,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9403
9474
|
if (llm.getModel().specificationVersion === "v2") {
|
|
9404
9475
|
const result = llm.stream({
|
|
9405
9476
|
runtimeContext,
|
|
9477
|
+
tracingContext,
|
|
9406
9478
|
messages: [{
|
|
9407
9479
|
role: "system",
|
|
9408
9480
|
content: systemInstructions
|
|
@@ -9415,6 +9487,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9415
9487
|
} else {
|
|
9416
9488
|
const result = await llm.__text({
|
|
9417
9489
|
runtimeContext,
|
|
9490
|
+
tracingContext,
|
|
9418
9491
|
messages: [{
|
|
9419
9492
|
role: "system",
|
|
9420
9493
|
content: systemInstructions
|
|
@@ -9432,14 +9505,15 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9432
9505
|
const userMessages = messages.filter(message => message.role === "user");
|
|
9433
9506
|
return userMessages.at(-1);
|
|
9434
9507
|
}
|
|
9435
|
-
async genTitle(userMessage, runtimeContext, model, instructions) {
|
|
9508
|
+
async genTitle(userMessage, runtimeContext, tracingContext, model, instructions) {
|
|
9436
9509
|
try {
|
|
9437
9510
|
if (userMessage) {
|
|
9438
|
-
const normMessage = new
|
|
9511
|
+
const normMessage = new chunk5CJDO3UO_cjs.MessageList().add(userMessage, "user").get.all.ui().at(-1);
|
|
9439
9512
|
if (normMessage) {
|
|
9440
9513
|
return await this.generateTitleFromUserMessage({
|
|
9441
9514
|
message: normMessage,
|
|
9442
9515
|
runtimeContext,
|
|
9516
|
+
tracingContext,
|
|
9443
9517
|
model,
|
|
9444
9518
|
instructions
|
|
9445
9519
|
});
|
|
@@ -9460,7 +9534,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9460
9534
|
runId,
|
|
9461
9535
|
userMessages,
|
|
9462
9536
|
systemMessage,
|
|
9463
|
-
messageList = new
|
|
9537
|
+
messageList = new chunk5CJDO3UO_cjs.MessageList({
|
|
9464
9538
|
threadId,
|
|
9465
9539
|
resourceId
|
|
9466
9540
|
}),
|
|
@@ -9515,7 +9589,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9515
9589
|
systemMessage: systemMessages,
|
|
9516
9590
|
memorySystemMessage: memorySystemMessage || void 0
|
|
9517
9591
|
});
|
|
9518
|
-
const returnList = new
|
|
9592
|
+
const returnList = new chunk5CJDO3UO_cjs.MessageList().addSystem(systemMessages).add(processedMemoryMessages, "memory").add(newMessages, "user");
|
|
9519
9593
|
return {
|
|
9520
9594
|
threadId: thread.id,
|
|
9521
9595
|
messages: returnList.get.all.prompt()
|
|
@@ -9531,8 +9605,8 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9531
9605
|
resourceId,
|
|
9532
9606
|
threadId,
|
|
9533
9607
|
runtimeContext,
|
|
9534
|
-
|
|
9535
|
-
|
|
9608
|
+
tracingContext,
|
|
9609
|
+
mastraProxy
|
|
9536
9610
|
}) {
|
|
9537
9611
|
let convertedMemoryTools = {};
|
|
9538
9612
|
const memory = await this.getMemory({
|
|
@@ -9555,12 +9629,12 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9555
9629
|
memory,
|
|
9556
9630
|
agentName: this.name,
|
|
9557
9631
|
runtimeContext,
|
|
9632
|
+
tracingContext,
|
|
9558
9633
|
model: typeof this.model === "function" ? await this.getModel({
|
|
9559
9634
|
runtimeContext
|
|
9560
|
-
}) : this.model
|
|
9561
|
-
agentAISpan
|
|
9635
|
+
}) : this.model
|
|
9562
9636
|
};
|
|
9563
|
-
const convertedToCoreTool =
|
|
9637
|
+
const convertedToCoreTool = chunkLVGGMWSE_cjs.makeCoreTool(toolObj, options);
|
|
9564
9638
|
convertedMemoryTools[toolName] = convertedToCoreTool;
|
|
9565
9639
|
}
|
|
9566
9640
|
}
|
|
@@ -9568,6 +9642,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9568
9642
|
}
|
|
9569
9643
|
async __runInputProcessors({
|
|
9570
9644
|
runtimeContext,
|
|
9645
|
+
tracingContext,
|
|
9571
9646
|
messageList,
|
|
9572
9647
|
inputProcessorOverrides
|
|
9573
9648
|
}) {
|
|
@@ -9578,13 +9653,13 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9578
9653
|
runtimeContext,
|
|
9579
9654
|
inputProcessorOverrides
|
|
9580
9655
|
});
|
|
9581
|
-
const tracedRunInputProcessors = messageList2 => {
|
|
9656
|
+
const tracedRunInputProcessors = (messageList2, tracingContext2) => {
|
|
9582
9657
|
const telemetry = this.#mastra?.getTelemetry();
|
|
9583
9658
|
if (!telemetry) {
|
|
9584
|
-
return runner.runInputProcessors(messageList2, void 0);
|
|
9659
|
+
return runner.runInputProcessors(messageList2, tracingContext2, void 0);
|
|
9585
9660
|
}
|
|
9586
9661
|
return telemetry.traceMethod(async data => {
|
|
9587
|
-
return runner.runInputProcessors(data.messageList, telemetry);
|
|
9662
|
+
return runner.runInputProcessors(data.messageList, tracingContext2, telemetry);
|
|
9588
9663
|
}, {
|
|
9589
9664
|
spanName: `agent.${this.name}.inputProcessors`,
|
|
9590
9665
|
attributes: {
|
|
@@ -9597,7 +9672,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9597
9672
|
});
|
|
9598
9673
|
};
|
|
9599
9674
|
try {
|
|
9600
|
-
messageList = await tracedRunInputProcessors(messageList);
|
|
9675
|
+
messageList = await tracedRunInputProcessors(messageList, tracingContext);
|
|
9601
9676
|
} catch (error) {
|
|
9602
9677
|
if (error instanceof TripWire) {
|
|
9603
9678
|
tripwireTriggered = true;
|
|
@@ -9620,6 +9695,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9620
9695
|
}
|
|
9621
9696
|
async __runOutputProcessors({
|
|
9622
9697
|
runtimeContext,
|
|
9698
|
+
tracingContext,
|
|
9623
9699
|
messageList,
|
|
9624
9700
|
outputProcessorOverrides
|
|
9625
9701
|
}) {
|
|
@@ -9630,13 +9706,13 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9630
9706
|
runtimeContext,
|
|
9631
9707
|
outputProcessorOverrides
|
|
9632
9708
|
});
|
|
9633
|
-
const tracedRunOutputProcessors = messageList2 => {
|
|
9709
|
+
const tracedRunOutputProcessors = (messageList2, tracingContext2) => {
|
|
9634
9710
|
const telemetry = this.#mastra?.getTelemetry();
|
|
9635
9711
|
if (!telemetry) {
|
|
9636
|
-
return runner.runOutputProcessors(messageList2, void 0);
|
|
9712
|
+
return runner.runOutputProcessors(messageList2, tracingContext2, void 0);
|
|
9637
9713
|
}
|
|
9638
9714
|
return telemetry.traceMethod(async data => {
|
|
9639
|
-
return runner.runOutputProcessors(data.messageList, telemetry);
|
|
9715
|
+
return runner.runOutputProcessors(data.messageList, tracingContext2, telemetry);
|
|
9640
9716
|
}, {
|
|
9641
9717
|
spanName: `agent.${this.name}.outputProcessors`,
|
|
9642
9718
|
attributes: {
|
|
@@ -9649,7 +9725,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9649
9725
|
});
|
|
9650
9726
|
};
|
|
9651
9727
|
try {
|
|
9652
|
-
messageList = await tracedRunOutputProcessors(messageList);
|
|
9728
|
+
messageList = await tracedRunOutputProcessors(messageList, tracingContext);
|
|
9653
9729
|
} catch (e) {
|
|
9654
9730
|
if (e instanceof TripWire) {
|
|
9655
9731
|
tripwireTriggered = true;
|
|
@@ -9688,13 +9764,13 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9688
9764
|
}).then(r => r.messagesV2);
|
|
9689
9765
|
}
|
|
9690
9766
|
async getAssignedTools({
|
|
9691
|
-
runtimeContext,
|
|
9692
9767
|
runId,
|
|
9693
9768
|
resourceId,
|
|
9694
9769
|
threadId,
|
|
9770
|
+
runtimeContext,
|
|
9771
|
+
tracingContext,
|
|
9695
9772
|
mastraProxy,
|
|
9696
|
-
writableStream
|
|
9697
|
-
agentAISpan
|
|
9773
|
+
writableStream
|
|
9698
9774
|
}) {
|
|
9699
9775
|
let toolsForRequest = {};
|
|
9700
9776
|
this.logger.debug(`[Agents:${this.name}] - Assembling assigned tools`, {
|
|
@@ -9723,13 +9799,13 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9723
9799
|
memory,
|
|
9724
9800
|
agentName: this.name,
|
|
9725
9801
|
runtimeContext,
|
|
9802
|
+
tracingContext,
|
|
9726
9803
|
model: typeof this.model === "function" ? await this.getModel({
|
|
9727
9804
|
runtimeContext
|
|
9728
9805
|
}) : this.model,
|
|
9729
|
-
writableStream
|
|
9730
|
-
agentAISpan
|
|
9806
|
+
writableStream
|
|
9731
9807
|
};
|
|
9732
|
-
return [k,
|
|
9808
|
+
return [k, chunkLVGGMWSE_cjs.makeCoreTool(tool, options)];
|
|
9733
9809
|
}));
|
|
9734
9810
|
const assignedToolEntriesConverted = Object.fromEntries(assignedCoreToolEntries.filter(entry => Boolean(entry)));
|
|
9735
9811
|
toolsForRequest = {
|
|
@@ -9743,8 +9819,8 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9743
9819
|
resourceId,
|
|
9744
9820
|
toolsets,
|
|
9745
9821
|
runtimeContext,
|
|
9746
|
-
|
|
9747
|
-
|
|
9822
|
+
tracingContext,
|
|
9823
|
+
mastraProxy
|
|
9748
9824
|
}) {
|
|
9749
9825
|
let toolsForRequest = {};
|
|
9750
9826
|
const memory = await this.getMemory({
|
|
@@ -9768,12 +9844,12 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9768
9844
|
memory,
|
|
9769
9845
|
agentName: this.name,
|
|
9770
9846
|
runtimeContext,
|
|
9847
|
+
tracingContext,
|
|
9771
9848
|
model: typeof this.model === "function" ? await this.getModel({
|
|
9772
9849
|
runtimeContext
|
|
9773
|
-
}) : this.model
|
|
9774
|
-
agentAISpan
|
|
9850
|
+
}) : this.model
|
|
9775
9851
|
};
|
|
9776
|
-
const convertedToCoreTool =
|
|
9852
|
+
const convertedToCoreTool = chunkLVGGMWSE_cjs.makeCoreTool(toolObj, options, "toolset");
|
|
9777
9853
|
toolsForRequest[toolName] = convertedToCoreTool;
|
|
9778
9854
|
}
|
|
9779
9855
|
}
|
|
@@ -9785,9 +9861,9 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9785
9861
|
threadId,
|
|
9786
9862
|
resourceId,
|
|
9787
9863
|
runtimeContext,
|
|
9864
|
+
tracingContext,
|
|
9788
9865
|
mastraProxy,
|
|
9789
|
-
clientTools
|
|
9790
|
-
agentAISpan
|
|
9866
|
+
clientTools
|
|
9791
9867
|
}) {
|
|
9792
9868
|
let toolsForRequest = {};
|
|
9793
9869
|
const memory = await this.getMemory({
|
|
@@ -9813,12 +9889,12 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9813
9889
|
memory,
|
|
9814
9890
|
agentName: this.name,
|
|
9815
9891
|
runtimeContext,
|
|
9892
|
+
tracingContext,
|
|
9816
9893
|
model: typeof this.model === "function" ? await this.getModel({
|
|
9817
9894
|
runtimeContext
|
|
9818
|
-
}) : this.model
|
|
9819
|
-
agentAISpan
|
|
9895
|
+
}) : this.model
|
|
9820
9896
|
};
|
|
9821
|
-
const convertedToCoreTool =
|
|
9897
|
+
const convertedToCoreTool = chunkLVGGMWSE_cjs.makeCoreTool(rest, options, "client-tool");
|
|
9822
9898
|
toolsForRequest[toolName] = convertedToCoreTool;
|
|
9823
9899
|
}
|
|
9824
9900
|
}
|
|
@@ -9829,7 +9905,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9829
9905
|
threadId,
|
|
9830
9906
|
resourceId,
|
|
9831
9907
|
runtimeContext,
|
|
9832
|
-
|
|
9908
|
+
tracingContext
|
|
9833
9909
|
}) {
|
|
9834
9910
|
let convertedWorkflowTools = {};
|
|
9835
9911
|
const workflows = await this.getWorkflows({
|
|
@@ -9846,7 +9922,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9846
9922
|
// manually wrap workflow tools with ai tracing, so that we can pass the
|
|
9847
9923
|
// current tool span onto the workflow to maintain continuity of the trace
|
|
9848
9924
|
execute: async args => {
|
|
9849
|
-
const toolAISpan =
|
|
9925
|
+
const toolAISpan = tracingContext.currentSpan?.createChildSpan({
|
|
9850
9926
|
type: "tool_call" /* TOOL_CALL */,
|
|
9851
9927
|
name: `tool: '${workflowName}'`,
|
|
9852
9928
|
input: args,
|
|
@@ -9868,7 +9944,9 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9868
9944
|
const result = await run.start({
|
|
9869
9945
|
inputData: args,
|
|
9870
9946
|
runtimeContext,
|
|
9871
|
-
|
|
9947
|
+
tracingContext: {
|
|
9948
|
+
currentSpan: toolAISpan
|
|
9949
|
+
}
|
|
9872
9950
|
});
|
|
9873
9951
|
toolAISpan?.end({
|
|
9874
9952
|
output: result
|
|
@@ -9908,13 +9986,13 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9908
9986
|
resourceId,
|
|
9909
9987
|
runId,
|
|
9910
9988
|
runtimeContext,
|
|
9911
|
-
|
|
9912
|
-
|
|
9989
|
+
tracingContext,
|
|
9990
|
+
writableStream
|
|
9913
9991
|
}) {
|
|
9914
9992
|
let mastraProxy = void 0;
|
|
9915
9993
|
const logger = this.logger;
|
|
9916
9994
|
if (this.#mastra) {
|
|
9917
|
-
mastraProxy =
|
|
9995
|
+
mastraProxy = chunkLVGGMWSE_cjs.createMastraProxy({
|
|
9918
9996
|
mastra: this.#mastra,
|
|
9919
9997
|
logger
|
|
9920
9998
|
});
|
|
@@ -9924,42 +10002,42 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
9924
10002
|
resourceId,
|
|
9925
10003
|
threadId,
|
|
9926
10004
|
runtimeContext,
|
|
10005
|
+
tracingContext,
|
|
9927
10006
|
mastraProxy,
|
|
9928
|
-
writableStream
|
|
9929
|
-
agentAISpan
|
|
10007
|
+
writableStream
|
|
9930
10008
|
});
|
|
9931
10009
|
const memoryTools = await this.getMemoryTools({
|
|
9932
10010
|
runId,
|
|
9933
10011
|
resourceId,
|
|
9934
10012
|
threadId,
|
|
9935
10013
|
runtimeContext,
|
|
9936
|
-
|
|
9937
|
-
|
|
10014
|
+
tracingContext,
|
|
10015
|
+
mastraProxy
|
|
9938
10016
|
});
|
|
9939
10017
|
const toolsetTools = await this.getToolsets({
|
|
9940
10018
|
runId,
|
|
9941
10019
|
resourceId,
|
|
9942
10020
|
threadId,
|
|
9943
10021
|
runtimeContext,
|
|
10022
|
+
tracingContext,
|
|
9944
10023
|
mastraProxy,
|
|
9945
|
-
toolsets
|
|
9946
|
-
agentAISpan
|
|
10024
|
+
toolsets
|
|
9947
10025
|
});
|
|
9948
10026
|
const clientSideTools = await this.getClientTools({
|
|
9949
10027
|
runId,
|
|
9950
10028
|
resourceId,
|
|
9951
10029
|
threadId,
|
|
9952
10030
|
runtimeContext,
|
|
10031
|
+
tracingContext,
|
|
9953
10032
|
mastraProxy,
|
|
9954
|
-
clientTools
|
|
9955
|
-
agentAISpan
|
|
10033
|
+
clientTools
|
|
9956
10034
|
});
|
|
9957
10035
|
const workflowTools = await this.getWorkflowTools({
|
|
9958
10036
|
runId,
|
|
9959
10037
|
resourceId,
|
|
9960
10038
|
threadId,
|
|
9961
10039
|
runtimeContext,
|
|
9962
|
-
|
|
10040
|
+
tracingContext
|
|
9963
10041
|
});
|
|
9964
10042
|
return this.formatTools({
|
|
9965
10043
|
...assignedTools,
|
|
@@ -10044,7 +10122,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
10044
10122
|
runtimeContext,
|
|
10045
10123
|
saveQueueManager,
|
|
10046
10124
|
writableStream,
|
|
10047
|
-
|
|
10125
|
+
tracingContext
|
|
10048
10126
|
}) {
|
|
10049
10127
|
return {
|
|
10050
10128
|
before: async () => {
|
|
@@ -10053,8 +10131,10 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
10053
10131
|
runId
|
|
10054
10132
|
});
|
|
10055
10133
|
}
|
|
10056
|
-
const
|
|
10134
|
+
const agentAISpan = chunkI7OAONIW_cjs.getOrCreateSpan({
|
|
10135
|
+
type: "agent_run" /* AGENT_RUN */,
|
|
10057
10136
|
name: `agent run: '${this.id}'`,
|
|
10137
|
+
input: messages,
|
|
10058
10138
|
attributes: {
|
|
10059
10139
|
agentId: this.id,
|
|
10060
10140
|
instructions,
|
|
@@ -10064,28 +10144,13 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
10064
10144
|
runId,
|
|
10065
10145
|
resourceId,
|
|
10066
10146
|
threadId: thread ? thread.id : void 0
|
|
10067
|
-
}
|
|
10147
|
+
},
|
|
10148
|
+
tracingContext,
|
|
10149
|
+
runtimeContext
|
|
10150
|
+
});
|
|
10151
|
+
const innerTracingContext = {
|
|
10152
|
+
currentSpan: agentAISpan
|
|
10068
10153
|
};
|
|
10069
|
-
let agentAISpan;
|
|
10070
|
-
if (currentSpan) {
|
|
10071
|
-
agentAISpan = currentSpan.createChildSpan({
|
|
10072
|
-
type: "agent_run" /* AGENT_RUN */,
|
|
10073
|
-
...spanArgs
|
|
10074
|
-
});
|
|
10075
|
-
} else {
|
|
10076
|
-
const aiTracing = chunk4DKPMUAC_cjs.getSelectedAITracing({
|
|
10077
|
-
runtimeContext
|
|
10078
|
-
});
|
|
10079
|
-
if (aiTracing) {
|
|
10080
|
-
agentAISpan = aiTracing.startSpan({
|
|
10081
|
-
type: "agent_run" /* AGENT_RUN */,
|
|
10082
|
-
...spanArgs,
|
|
10083
|
-
startOptions: {
|
|
10084
|
-
runtimeContext
|
|
10085
|
-
}
|
|
10086
|
-
});
|
|
10087
|
-
}
|
|
10088
|
-
}
|
|
10089
10154
|
const memory = await this.getMemory({
|
|
10090
10155
|
runtimeContext
|
|
10091
10156
|
});
|
|
@@ -10109,10 +10174,10 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
10109
10174
|
resourceId,
|
|
10110
10175
|
runId,
|
|
10111
10176
|
runtimeContext,
|
|
10112
|
-
|
|
10113
|
-
|
|
10177
|
+
tracingContext: innerTracingContext,
|
|
10178
|
+
writableStream
|
|
10114
10179
|
});
|
|
10115
|
-
const messageList = new
|
|
10180
|
+
const messageList = new chunk5CJDO3UO_cjs.MessageList({
|
|
10116
10181
|
threadId,
|
|
10117
10182
|
resourceId,
|
|
10118
10183
|
generateMessageId: this.#mastra?.generateId?.bind(this.#mastra),
|
|
@@ -10129,6 +10194,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
10129
10194
|
tripwireReason: tripwireReason2
|
|
10130
10195
|
} = await this.__runInputProcessors({
|
|
10131
10196
|
runtimeContext,
|
|
10197
|
+
tracingContext: innerTracingContext,
|
|
10132
10198
|
messageList
|
|
10133
10199
|
});
|
|
10134
10200
|
return {
|
|
@@ -10199,7 +10265,7 @@ exports.Agent = class Agent extends (_a = chunkKXCUCBEI_cjs.MastraBase) {
|
|
|
10199
10265
|
let [memoryMessages, memorySystemMessage] = await Promise.all([existingThread ? this.getMemoryMessages({
|
|
10200
10266
|
resourceId,
|
|
10201
10267
|
threadId: threadObject.id,
|
|
10202
|
-
vectorMessageSearch: new
|
|
10268
|
+
vectorMessageSearch: new chunk5CJDO3UO_cjs.MessageList().add(messages, `user`).getLatestUserContent() || "",
|
|
10203
10269
|
memoryConfig,
|
|
10204
10270
|
runtimeContext
|
|
10205
10271
|
}) : [], memory.getSystemMessage({
|
|
@@ -10222,7 +10288,7 @@ The following messages were remembered from a different conversation:
|
|
|
10222
10288
|
<remembered_from_other_conversation>
|
|
10223
10289
|
${(() => {
|
|
10224
10290
|
let result = ``;
|
|
10225
|
-
const messages2 = new
|
|
10291
|
+
const messages2 = new chunk5CJDO3UO_cjs.MessageList().add(resultsFromOtherThreads, "memory").get.all.v1();
|
|
10226
10292
|
let lastYmd = null;
|
|
10227
10293
|
for (const msg of messages2) {
|
|
10228
10294
|
const date = msg.createdAt;
|
|
@@ -10261,6 +10327,7 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10261
10327
|
tripwireReason
|
|
10262
10328
|
} = await this.__runInputProcessors({
|
|
10263
10329
|
runtimeContext,
|
|
10330
|
+
tracingContext: innerTracingContext,
|
|
10264
10331
|
messageList
|
|
10265
10332
|
});
|
|
10266
10333
|
const systemMessage = [...messageList.getSystemMessages(), ...messageList.getSystemMessages("memory")]?.map(m => m.content)?.join(`
|
|
@@ -10274,7 +10341,7 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10274
10341
|
systemMessage,
|
|
10275
10342
|
memorySystemMessage: memorySystemMessage || void 0
|
|
10276
10343
|
});
|
|
10277
|
-
const processedList = new
|
|
10344
|
+
const processedList = new chunk5CJDO3UO_cjs.MessageList({
|
|
10278
10345
|
threadId: threadObject.id,
|
|
10279
10346
|
resourceId,
|
|
10280
10347
|
generateMessageId: this.#mastra?.generateId?.bind(this.#mastra),
|
|
@@ -10325,23 +10392,12 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10325
10392
|
};
|
|
10326
10393
|
})
|
|
10327
10394
|
};
|
|
10328
|
-
agentAISpan?.end({
|
|
10329
|
-
output: {
|
|
10330
|
-
text: result?.text,
|
|
10331
|
-
object: result?.object
|
|
10332
|
-
},
|
|
10333
|
-
metadata: {
|
|
10334
|
-
usage: result?.usage,
|
|
10335
|
-
toolResults: result?.toolResults,
|
|
10336
|
-
toolCalls: result?.toolCalls
|
|
10337
|
-
}
|
|
10338
|
-
});
|
|
10339
10395
|
this.logger.debug(`[Agent:${this.name}] - Post processing LLM response`, {
|
|
10340
10396
|
runId: runId2,
|
|
10341
10397
|
result: resToLog,
|
|
10342
10398
|
threadId
|
|
10343
10399
|
});
|
|
10344
|
-
const messageListResponses = new
|
|
10400
|
+
const messageListResponses = new chunk5CJDO3UO_cjs.MessageList({
|
|
10345
10401
|
threadId,
|
|
10346
10402
|
resourceId,
|
|
10347
10403
|
generateMessageId: this.#mastra?.generateId?.bind(this.#mastra),
|
|
@@ -10397,7 +10453,9 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10397
10453
|
instructions: titleInstructions
|
|
10398
10454
|
} = this.resolveTitleGenerationConfig(config?.threads?.generateTitle);
|
|
10399
10455
|
if (shouldGenerate && userMessage) {
|
|
10400
|
-
promises.push(this.genTitle(userMessage, runtimeContext,
|
|
10456
|
+
promises.push(this.genTitle(userMessage, runtimeContext, {
|
|
10457
|
+
currentSpan: agentAISpan
|
|
10458
|
+
}, titleModel, titleInstructions).then(title => {
|
|
10401
10459
|
if (title) {
|
|
10402
10460
|
return memory.createThread({
|
|
10403
10461
|
threadId: thread2.id,
|
|
@@ -10414,6 +10472,9 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10414
10472
|
} catch (e) {
|
|
10415
10473
|
await saveQueueManager.flushMessages(messageList, threadId, memoryConfig2);
|
|
10416
10474
|
if (e instanceof chunkC73WLCY3_cjs.MastraError) {
|
|
10475
|
+
agentAISpan?.error({
|
|
10476
|
+
error: e
|
|
10477
|
+
});
|
|
10417
10478
|
throw e;
|
|
10418
10479
|
}
|
|
10419
10480
|
const mastraError = new chunkC73WLCY3_cjs.MastraError({
|
|
@@ -10429,6 +10490,9 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10429
10490
|
}, e);
|
|
10430
10491
|
this.logger.trackException(mastraError);
|
|
10431
10492
|
this.logger.error(mastraError.toString());
|
|
10493
|
+
agentAISpan?.error({
|
|
10494
|
+
error: mastraError
|
|
10495
|
+
});
|
|
10432
10496
|
throw mastraError;
|
|
10433
10497
|
}
|
|
10434
10498
|
} else {
|
|
@@ -10453,6 +10517,9 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10453
10517
|
outputText,
|
|
10454
10518
|
instructions,
|
|
10455
10519
|
runtimeContext,
|
|
10520
|
+
tracingContext: {
|
|
10521
|
+
currentSpan: agentAISpan
|
|
10522
|
+
},
|
|
10456
10523
|
structuredOutput,
|
|
10457
10524
|
overrideScorers,
|
|
10458
10525
|
threadId,
|
|
@@ -10467,6 +10534,17 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10467
10534
|
},
|
|
10468
10535
|
output: messageList.getPersisted.response.ui()
|
|
10469
10536
|
};
|
|
10537
|
+
agentAISpan?.end({
|
|
10538
|
+
output: {
|
|
10539
|
+
text: result?.text,
|
|
10540
|
+
object: result?.object
|
|
10541
|
+
},
|
|
10542
|
+
metadata: {
|
|
10543
|
+
usage: result?.usage,
|
|
10544
|
+
toolResults: result?.toolResults,
|
|
10545
|
+
toolCalls: result?.toolCalls
|
|
10546
|
+
}
|
|
10547
|
+
});
|
|
10470
10548
|
return {
|
|
10471
10549
|
scoringData
|
|
10472
10550
|
};
|
|
@@ -10479,6 +10557,7 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10479
10557
|
outputText,
|
|
10480
10558
|
instructions,
|
|
10481
10559
|
runtimeContext,
|
|
10560
|
+
tracingContext,
|
|
10482
10561
|
structuredOutput,
|
|
10483
10562
|
overrideScorers,
|
|
10484
10563
|
threadId,
|
|
@@ -10500,9 +10579,15 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10500
10579
|
});
|
|
10501
10580
|
}
|
|
10502
10581
|
}
|
|
10503
|
-
|
|
10504
|
-
|
|
10505
|
-
|
|
10582
|
+
let scorers = {};
|
|
10583
|
+
try {
|
|
10584
|
+
scorers = overrideScorers ? this.resolveOverrideScorerReferences(overrideScorers) : await this.getScorers({
|
|
10585
|
+
runtimeContext
|
|
10586
|
+
});
|
|
10587
|
+
} catch (e) {
|
|
10588
|
+
this.logger.warn(`[Agent:${this.name}] - Failed to get scorers: ${e}`);
|
|
10589
|
+
return;
|
|
10590
|
+
}
|
|
10506
10591
|
const scorerInput = {
|
|
10507
10592
|
inputMessages: messageList.getPersisted.input.ui(),
|
|
10508
10593
|
rememberedMessages: messageList.getPersisted.remembered.ui(),
|
|
@@ -10513,12 +10598,13 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10513
10598
|
if (Object.keys(scorers || {}).length > 0) {
|
|
10514
10599
|
for (const [id, scorerObject] of Object.entries(scorers)) {
|
|
10515
10600
|
runScorer({
|
|
10516
|
-
scorerId: id,
|
|
10601
|
+
scorerId: overrideScorers ? scorerObject.scorer.name : id,
|
|
10517
10602
|
scorerObject,
|
|
10518
10603
|
runId,
|
|
10519
10604
|
input: scorerInput,
|
|
10520
10605
|
output: scorerOutput,
|
|
10521
10606
|
runtimeContext,
|
|
10607
|
+
tracingContext,
|
|
10522
10608
|
entity: {
|
|
10523
10609
|
id: this.id,
|
|
10524
10610
|
name: this.name
|
|
@@ -10532,6 +10618,41 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10532
10618
|
}
|
|
10533
10619
|
}
|
|
10534
10620
|
}
|
|
10621
|
+
resolveOverrideScorerReferences(overrideScorers) {
|
|
10622
|
+
const result = {};
|
|
10623
|
+
for (const [id, scorerObject] of Object.entries(overrideScorers)) {
|
|
10624
|
+
if (typeof scorerObject.scorer === "string") {
|
|
10625
|
+
try {
|
|
10626
|
+
if (!this.#mastra) {
|
|
10627
|
+
throw new chunkC73WLCY3_cjs.MastraError({
|
|
10628
|
+
id: "AGENT_GENEREATE_SCORER_NOT_FOUND",
|
|
10629
|
+
domain: "AGENT" /* AGENT */,
|
|
10630
|
+
category: "USER" /* USER */,
|
|
10631
|
+
text: `Mastra not found when fetching scorer. Make sure to fetch agent from mastra.getAgent()`
|
|
10632
|
+
});
|
|
10633
|
+
}
|
|
10634
|
+
const scorer = this.#mastra.getScorerByName(scorerObject.scorer);
|
|
10635
|
+
result[id] = {
|
|
10636
|
+
scorer,
|
|
10637
|
+
sampling: scorerObject.sampling
|
|
10638
|
+
};
|
|
10639
|
+
} catch (error) {
|
|
10640
|
+
this.logger.warn(`[Agent:${this.name}] - Failed to get scorer ${scorerObject.scorer}: ${error}`);
|
|
10641
|
+
}
|
|
10642
|
+
} else {
|
|
10643
|
+
result[id] = scorerObject;
|
|
10644
|
+
}
|
|
10645
|
+
}
|
|
10646
|
+
if (Object.keys(result).length === 0) {
|
|
10647
|
+
throw new chunkC73WLCY3_cjs.MastraError({
|
|
10648
|
+
id: "AGENT_GENEREATE_SCORER_NOT_FOUND",
|
|
10649
|
+
domain: "AGENT" /* AGENT */,
|
|
10650
|
+
category: "USER" /* USER */,
|
|
10651
|
+
text: `No scorers found in overrideScorers`
|
|
10652
|
+
});
|
|
10653
|
+
}
|
|
10654
|
+
return result;
|
|
10655
|
+
}
|
|
10535
10656
|
async prepareLLMOptions(messages, options) {
|
|
10536
10657
|
const {
|
|
10537
10658
|
context,
|
|
@@ -10544,6 +10665,7 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10544
10665
|
temperature,
|
|
10545
10666
|
toolChoice = "auto",
|
|
10546
10667
|
runtimeContext = new chunkGPWMM745_cjs.RuntimeContext(),
|
|
10668
|
+
tracingContext,
|
|
10547
10669
|
savePerStep,
|
|
10548
10670
|
writableStream,
|
|
10549
10671
|
...args
|
|
@@ -10608,7 +10730,7 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10608
10730
|
runtimeContext,
|
|
10609
10731
|
saveQueueManager,
|
|
10610
10732
|
writableStream,
|
|
10611
|
-
|
|
10733
|
+
tracingContext
|
|
10612
10734
|
});
|
|
10613
10735
|
let messageList;
|
|
10614
10736
|
let thread;
|
|
@@ -10675,7 +10797,8 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10675
10797
|
result,
|
|
10676
10798
|
outputText,
|
|
10677
10799
|
structuredOutput = false,
|
|
10678
|
-
agentAISpan
|
|
10800
|
+
agentAISpan,
|
|
10801
|
+
overrideScorers
|
|
10679
10802
|
}) => {
|
|
10680
10803
|
const afterResult = await after({
|
|
10681
10804
|
result,
|
|
@@ -10687,7 +10810,8 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10687
10810
|
messageList,
|
|
10688
10811
|
structuredOutput,
|
|
10689
10812
|
threadExists,
|
|
10690
|
-
agentAISpan
|
|
10813
|
+
agentAISpan,
|
|
10814
|
+
overrideScorers
|
|
10691
10815
|
});
|
|
10692
10816
|
return afterResult;
|
|
10693
10817
|
}
|
|
@@ -10711,6 +10835,22 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10711
10835
|
const instructions = options.instructions || (await this.getInstructions({
|
|
10712
10836
|
runtimeContext
|
|
10713
10837
|
}));
|
|
10838
|
+
const agentAISpan = chunkI7OAONIW_cjs.getOrCreateSpan({
|
|
10839
|
+
type: "agent_run" /* AGENT_RUN */,
|
|
10840
|
+
name: `agent run: '${this.id}'`,
|
|
10841
|
+
input: options.messages,
|
|
10842
|
+
attributes: {
|
|
10843
|
+
agentId: this.id,
|
|
10844
|
+
instructions
|
|
10845
|
+
},
|
|
10846
|
+
metadata: {
|
|
10847
|
+
runId,
|
|
10848
|
+
resourceId,
|
|
10849
|
+
threadId: threadFromArgs ? threadFromArgs.id : void 0
|
|
10850
|
+
},
|
|
10851
|
+
tracingContext: options.tracingContext,
|
|
10852
|
+
runtimeContext
|
|
10853
|
+
});
|
|
10714
10854
|
const activeSpan = chunkZOU4K5MI_cjs.Telemetry.getActiveSpan();
|
|
10715
10855
|
const baggageEntries = {};
|
|
10716
10856
|
if (threadFromArgs?.id) {
|
|
@@ -10771,7 +10911,10 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10771
10911
|
resourceId,
|
|
10772
10912
|
runId,
|
|
10773
10913
|
runtimeContext,
|
|
10774
|
-
writableStream: options.writableStream
|
|
10914
|
+
writableStream: options.writableStream,
|
|
10915
|
+
tracingContext: {
|
|
10916
|
+
currentSpan: agentAISpan
|
|
10917
|
+
}
|
|
10775
10918
|
});
|
|
10776
10919
|
return {
|
|
10777
10920
|
convertedTools
|
|
@@ -10789,9 +10932,11 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10789
10932
|
tripwire: z.z.boolean().optional(),
|
|
10790
10933
|
tripwireReason: z.z.string().optional()
|
|
10791
10934
|
}),
|
|
10792
|
-
execute: async (
|
|
10935
|
+
execute: async ({
|
|
10936
|
+
tracingContext
|
|
10937
|
+
}) => {
|
|
10793
10938
|
const thread = threadFromArgs;
|
|
10794
|
-
const messageList = new
|
|
10939
|
+
const messageList = new chunk5CJDO3UO_cjs.MessageList({
|
|
10795
10940
|
threadId: thread?.id,
|
|
10796
10941
|
resourceId,
|
|
10797
10942
|
generateMessageId: this.#mastra?.generateId?.bind(this.#mastra),
|
|
@@ -10808,6 +10953,7 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10808
10953
|
tripwireReason: tripwireReason2
|
|
10809
10954
|
} = await this.__runInputProcessors({
|
|
10810
10955
|
runtimeContext,
|
|
10956
|
+
tracingContext,
|
|
10811
10957
|
messageList
|
|
10812
10958
|
});
|
|
10813
10959
|
return {
|
|
@@ -10873,7 +11019,7 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10873
11019
|
let [memoryMessages, memorySystemMessage] = await Promise.all([existingThread ? this.getMemoryMessages({
|
|
10874
11020
|
resourceId,
|
|
10875
11021
|
threadId: threadObject.id,
|
|
10876
|
-
vectorMessageSearch: new
|
|
11022
|
+
vectorMessageSearch: new chunk5CJDO3UO_cjs.MessageList().add(options.messages, `user`).getLatestUserContent() || "",
|
|
10877
11023
|
memoryConfig,
|
|
10878
11024
|
runtimeContext
|
|
10879
11025
|
}) : [], memory.getSystemMessage({
|
|
@@ -10895,8 +11041,8 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10895
11041
|
The following messages were remembered from a different conversation:
|
|
10896
11042
|
<remembered_from_other_conversation>
|
|
10897
11043
|
${(() => {
|
|
10898
|
-
let
|
|
10899
|
-
const messages = new
|
|
11044
|
+
let result2 = ``;
|
|
11045
|
+
const messages = new chunk5CJDO3UO_cjs.MessageList().add(resultsFromOtherThreads, "memory").get.all.v1();
|
|
10900
11046
|
let lastYmd = null;
|
|
10901
11047
|
for (const msg of messages) {
|
|
10902
11048
|
const date = msg.createdAt;
|
|
@@ -10912,15 +11058,14 @@ ${(() => {
|
|
|
10912
11058
|
const ampm = utcHour < 12 ? "AM" : "PM";
|
|
10913
11059
|
const timeofday = `${hour12}:${utcMinute < 10 ? "0" : ""}${utcMinute} ${ampm}`;
|
|
10914
11060
|
if (!lastYmd || lastYmd !== ymd) {
|
|
10915
|
-
|
|
11061
|
+
result2 += `
|
|
10916
11062
|
the following messages are from ${ymd}
|
|
10917
11063
|
`;
|
|
10918
11064
|
}
|
|
10919
|
-
|
|
10920
|
-
Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conversation" : ""} at ${timeofday}: ${JSON.stringify(msg)}`;
|
|
11065
|
+
result2 += `Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conversation" : ""} at ${timeofday}: ${JSON.stringify(msg)}`;
|
|
10921
11066
|
lastYmd = ymd;
|
|
10922
11067
|
}
|
|
10923
|
-
return
|
|
11068
|
+
return result2;
|
|
10924
11069
|
})()}
|
|
10925
11070
|
<end_remembered_from_other_conversation>`;
|
|
10926
11071
|
}
|
|
@@ -10935,6 +11080,7 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10935
11080
|
tripwireReason
|
|
10936
11081
|
} = await this.__runInputProcessors({
|
|
10937
11082
|
runtimeContext,
|
|
11083
|
+
tracingContext,
|
|
10938
11084
|
messageList
|
|
10939
11085
|
});
|
|
10940
11086
|
const systemMessage = [...messageList.getSystemMessages(), ...messageList.getSystemMessages("memory")]?.map(m => m.content)?.join(`
|
|
@@ -10948,7 +11094,7 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10948
11094
|
systemMessage,
|
|
10949
11095
|
memorySystemMessage: memorySystemMessage || void 0
|
|
10950
11096
|
});
|
|
10951
|
-
const processedList = new
|
|
11097
|
+
const processedList = new chunk5CJDO3UO_cjs.MessageList({
|
|
10952
11098
|
threadId: threadObject.id,
|
|
10953
11099
|
resourceId,
|
|
10954
11100
|
generateMessageId: this.#mastra?.generateId?.bind(this.#mastra),
|
|
@@ -10973,7 +11119,8 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10973
11119
|
inputSchema: z.z.any(),
|
|
10974
11120
|
outputSchema: z.z.any(),
|
|
10975
11121
|
execute: async ({
|
|
10976
|
-
inputData
|
|
11122
|
+
inputData,
|
|
11123
|
+
tracingContext
|
|
10977
11124
|
}) => {
|
|
10978
11125
|
this.logger.debug(`Starting agent ${this.name} llm stream call`, {
|
|
10979
11126
|
runId
|
|
@@ -10983,7 +11130,8 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10983
11130
|
}) : this.#outputProcessors : []);
|
|
10984
11131
|
const streamResult = llm.stream({
|
|
10985
11132
|
...inputData,
|
|
10986
|
-
outputProcessors
|
|
11133
|
+
outputProcessors,
|
|
11134
|
+
tracingContext
|
|
10987
11135
|
});
|
|
10988
11136
|
if (options.format === "aisdk") {
|
|
10989
11137
|
return streamResult.aisdk.v5;
|
|
@@ -10998,9 +11146,10 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10998
11146
|
steps: [prepareToolsStep, prepareMemory]
|
|
10999
11147
|
}).parallel([prepareToolsStep, prepareMemory]).map(async ({
|
|
11000
11148
|
inputData,
|
|
11001
|
-
bail
|
|
11149
|
+
bail,
|
|
11150
|
+
tracingContext
|
|
11002
11151
|
}) => {
|
|
11003
|
-
const
|
|
11152
|
+
const result2 = {
|
|
11004
11153
|
...options,
|
|
11005
11154
|
messages: inputData["prepare-memory-step"].messageObjects,
|
|
11006
11155
|
tools: inputData["prepare-tools-step"].convertedTools,
|
|
@@ -11042,7 +11191,7 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
11042
11191
|
tripwireReason: inputData["prepare-memory-step"].tripwireReason
|
|
11043
11192
|
})
|
|
11044
11193
|
};
|
|
11045
|
-
if (
|
|
11194
|
+
if (result2.tripwire) {
|
|
11046
11195
|
const emptyResult = {
|
|
11047
11196
|
textStream: async function* () {}(),
|
|
11048
11197
|
fullStream: new globalThis.ReadableStream({
|
|
@@ -11063,7 +11212,7 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
11063
11212
|
}),
|
|
11064
11213
|
finishReason: Promise.resolve("other"),
|
|
11065
11214
|
tripwire: true,
|
|
11066
|
-
tripwireReason:
|
|
11215
|
+
tripwireReason: result2.tripwireReason,
|
|
11067
11216
|
response: {
|
|
11068
11217
|
id: crypto2.randomUUID(),
|
|
11069
11218
|
timestamp: /* @__PURE__ */new Date(),
|
|
@@ -11086,23 +11235,27 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
11086
11235
|
return bail(emptyResult);
|
|
11087
11236
|
}
|
|
11088
11237
|
let effectiveOutputProcessors = options.outputProcessors || (this.#outputProcessors ? typeof this.#outputProcessors === "function" ? await this.#outputProcessors({
|
|
11089
|
-
runtimeContext:
|
|
11238
|
+
runtimeContext: result2.runtimeContext
|
|
11090
11239
|
}) : this.#outputProcessors : []);
|
|
11091
11240
|
if (options.structuredOutput) {
|
|
11092
11241
|
const structuredProcessor = new StructuredOutputProcessor(options.structuredOutput);
|
|
11093
11242
|
effectiveOutputProcessors = effectiveOutputProcessors ? [...effectiveOutputProcessors, structuredProcessor] : [structuredProcessor];
|
|
11094
11243
|
}
|
|
11095
11244
|
const loopOptions = {
|
|
11096
|
-
messages:
|
|
11097
|
-
runtimeContext:
|
|
11245
|
+
messages: result2.messages,
|
|
11246
|
+
runtimeContext: result2.runtimeContext,
|
|
11247
|
+
tracingContext: {
|
|
11248
|
+
currentSpan: agentAISpan
|
|
11249
|
+
},
|
|
11098
11250
|
runId,
|
|
11099
|
-
toolChoice:
|
|
11100
|
-
tools:
|
|
11101
|
-
resourceId:
|
|
11102
|
-
threadId:
|
|
11103
|
-
structuredOutput:
|
|
11104
|
-
stopWhen:
|
|
11105
|
-
maxSteps:
|
|
11251
|
+
toolChoice: result2.toolChoice,
|
|
11252
|
+
tools: result2.tools,
|
|
11253
|
+
resourceId: result2.resourceId,
|
|
11254
|
+
threadId: result2.threadId,
|
|
11255
|
+
structuredOutput: result2.structuredOutput,
|
|
11256
|
+
stopWhen: result2.stopWhen,
|
|
11257
|
+
maxSteps: result2.maxSteps,
|
|
11258
|
+
providerOptions: result2.providerOptions,
|
|
11106
11259
|
options: {
|
|
11107
11260
|
onFinish: async payload => {
|
|
11108
11261
|
if (payload.finishReason === "error") {
|
|
@@ -11120,16 +11273,18 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
11120
11273
|
result: payload,
|
|
11121
11274
|
outputText,
|
|
11122
11275
|
instructions,
|
|
11123
|
-
thread:
|
|
11124
|
-
threadId:
|
|
11276
|
+
thread: result2.thread,
|
|
11277
|
+
threadId: result2.threadId,
|
|
11125
11278
|
resourceId,
|
|
11126
11279
|
memoryConfig,
|
|
11127
11280
|
runtimeContext,
|
|
11281
|
+
tracingContext,
|
|
11128
11282
|
runId,
|
|
11129
11283
|
messageList,
|
|
11130
11284
|
threadExists: inputData["prepare-memory-step"].threadExists,
|
|
11131
11285
|
structuredOutput: !!options.output,
|
|
11132
|
-
saveQueueManager
|
|
11286
|
+
saveQueueManager,
|
|
11287
|
+
overrideScorers: options.scorers
|
|
11133
11288
|
});
|
|
11134
11289
|
} catch (e) {
|
|
11135
11290
|
this.logger.error("Error saving memory on finish", {
|
|
@@ -11138,11 +11293,12 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
11138
11293
|
});
|
|
11139
11294
|
}
|
|
11140
11295
|
await options?.onFinish?.({
|
|
11141
|
-
...
|
|
11142
|
-
runId
|
|
11296
|
+
...result2,
|
|
11297
|
+
runId,
|
|
11298
|
+
messages: messageList.get.response.aiV5.model()
|
|
11143
11299
|
});
|
|
11144
11300
|
},
|
|
11145
|
-
onStepFinish:
|
|
11301
|
+
onStepFinish: result2.onStepFinish
|
|
11146
11302
|
},
|
|
11147
11303
|
output: options.output,
|
|
11148
11304
|
outputProcessors: effectiveOutputProcessors,
|
|
@@ -11154,7 +11310,15 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
11154
11310
|
return loopOptions;
|
|
11155
11311
|
}).then(streamStep).commit();
|
|
11156
11312
|
const run = await executionWorkflow.createRunAsync();
|
|
11157
|
-
|
|
11313
|
+
const result = await run.start({
|
|
11314
|
+
tracingContext: {
|
|
11315
|
+
currentSpan: agentAISpan
|
|
11316
|
+
}
|
|
11317
|
+
});
|
|
11318
|
+
agentAISpan?.end({
|
|
11319
|
+
output: result
|
|
11320
|
+
});
|
|
11321
|
+
return result;
|
|
11158
11322
|
}
|
|
11159
11323
|
async #executeOnFinish({
|
|
11160
11324
|
result,
|
|
@@ -11165,11 +11329,13 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
11165
11329
|
memoryConfig,
|
|
11166
11330
|
outputText,
|
|
11167
11331
|
runtimeContext,
|
|
11332
|
+
tracingContext,
|
|
11168
11333
|
runId,
|
|
11169
11334
|
messageList,
|
|
11170
11335
|
threadExists,
|
|
11171
11336
|
structuredOutput = false,
|
|
11172
|
-
saveQueueManager
|
|
11337
|
+
saveQueueManager,
|
|
11338
|
+
overrideScorers
|
|
11173
11339
|
}) {
|
|
11174
11340
|
const resToLog = {
|
|
11175
11341
|
text: result?.text,
|
|
@@ -11244,7 +11410,7 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
11244
11410
|
instructions: titleInstructions
|
|
11245
11411
|
} = this.resolveTitleGenerationConfig(config?.threads?.generateTitle);
|
|
11246
11412
|
if (shouldGenerate && userMessage) {
|
|
11247
|
-
promises.push(this.genTitle(userMessage, runtimeContext, titleModel, titleInstructions).then(title => {
|
|
11413
|
+
promises.push(this.genTitle(userMessage, runtimeContext, tracingContext, titleModel, titleInstructions).then(title => {
|
|
11248
11414
|
if (title) {
|
|
11249
11415
|
return memory.createThread({
|
|
11250
11416
|
threadId: thread.id,
|
|
@@ -11300,7 +11466,9 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
11300
11466
|
outputText,
|
|
11301
11467
|
instructions,
|
|
11302
11468
|
runtimeContext,
|
|
11303
|
-
|
|
11469
|
+
tracingContext,
|
|
11470
|
+
structuredOutput,
|
|
11471
|
+
overrideScorers
|
|
11304
11472
|
});
|
|
11305
11473
|
}
|
|
11306
11474
|
async generateVNext(messages, options) {
|
|
@@ -11360,6 +11528,10 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
11360
11528
|
return result.result;
|
|
11361
11529
|
}
|
|
11362
11530
|
async generate(messages, generateOptions = {}) {
|
|
11531
|
+
this.logger.warn("Deprecation NOTICE:\nGenerate method will switch to use generateVNext implementation September 16th. Please use generateLegacy if you don't want to upgrade just yet.");
|
|
11532
|
+
return this.generateLegacy(messages, generateOptions);
|
|
11533
|
+
}
|
|
11534
|
+
async generateLegacy(messages, generateOptions = {}) {
|
|
11363
11535
|
const defaultGenerateOptions = await this.getDefaultGenerateOptions({
|
|
11364
11536
|
runtimeContext: generateOptions.runtimeContext
|
|
11365
11537
|
});
|
|
@@ -11427,6 +11599,9 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
11427
11599
|
agentAISpan,
|
|
11428
11600
|
...llmOptions
|
|
11429
11601
|
} = beforeResult;
|
|
11602
|
+
const tracingContext = {
|
|
11603
|
+
currentSpan: agentAISpan
|
|
11604
|
+
};
|
|
11430
11605
|
let finalOutputProcessors = mergedGenerateOptions.outputProcessors;
|
|
11431
11606
|
if (mergedGenerateOptions.structuredOutput) {
|
|
11432
11607
|
const structuredProcessor = new StructuredOutputProcessor(mergedGenerateOptions.structuredOutput);
|
|
@@ -11435,13 +11610,14 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
11435
11610
|
if (!output || experimental_output) {
|
|
11436
11611
|
const result2 = await llmToUse.__text({
|
|
11437
11612
|
...llmOptions,
|
|
11438
|
-
|
|
11613
|
+
tracingContext,
|
|
11439
11614
|
experimental_output
|
|
11440
11615
|
});
|
|
11441
11616
|
const outputProcessorResult2 = await this.__runOutputProcessors({
|
|
11442
11617
|
runtimeContext: mergedGenerateOptions.runtimeContext || new chunkGPWMM745_cjs.RuntimeContext(),
|
|
11618
|
+
tracingContext,
|
|
11443
11619
|
outputProcessorOverrides: finalOutputProcessors,
|
|
11444
|
-
messageList: new
|
|
11620
|
+
messageList: new chunk5CJDO3UO_cjs.MessageList({
|
|
11445
11621
|
threadId: llmOptions.threadId || "",
|
|
11446
11622
|
resourceId: llmOptions.resourceId || ""
|
|
11447
11623
|
}).add({
|
|
@@ -11511,12 +11687,13 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
11511
11687
|
}
|
|
11512
11688
|
}
|
|
11513
11689
|
}
|
|
11690
|
+
const overrideScorers = mergedGenerateOptions.scorers;
|
|
11514
11691
|
const afterResult2 = await after({
|
|
11515
11692
|
result: result2,
|
|
11516
11693
|
outputText: newText2,
|
|
11517
11694
|
agentAISpan,
|
|
11518
|
-
...(
|
|
11519
|
-
overrideScorers
|
|
11695
|
+
...(overrideScorers ? {
|
|
11696
|
+
overrideScorers
|
|
11520
11697
|
} : {})
|
|
11521
11698
|
});
|
|
11522
11699
|
if (generateOptions.returnScorerData) {
|
|
@@ -11526,13 +11703,14 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
11526
11703
|
}
|
|
11527
11704
|
const result = await llmToUse.__textObject({
|
|
11528
11705
|
...llmOptions,
|
|
11529
|
-
|
|
11706
|
+
tracingContext,
|
|
11530
11707
|
structuredOutput: output
|
|
11531
11708
|
});
|
|
11532
11709
|
const outputText = JSON.stringify(result.object);
|
|
11533
11710
|
const outputProcessorResult = await this.__runOutputProcessors({
|
|
11534
11711
|
runtimeContext: mergedGenerateOptions.runtimeContext || new chunkGPWMM745_cjs.RuntimeContext(),
|
|
11535
|
-
|
|
11712
|
+
tracingContext,
|
|
11713
|
+
messageList: new chunk5CJDO3UO_cjs.MessageList({
|
|
11536
11714
|
threadId: llmOptions.threadId || "",
|
|
11537
11715
|
resourceId: llmOptions.resourceId || ""
|
|
11538
11716
|
}).add({
|
|
@@ -11600,6 +11778,10 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
11600
11778
|
return result;
|
|
11601
11779
|
}
|
|
11602
11780
|
async stream(messages, streamOptions = {}) {
|
|
11781
|
+
this.logger.warn("Deprecation NOTICE:\nStream method will switch to use streamVNext implementation September 16th. Please use streamLegacy if you don't want to upgrade just yet.");
|
|
11782
|
+
return this.streamLegacy(messages, streamOptions);
|
|
11783
|
+
}
|
|
11784
|
+
async streamLegacy(messages, streamOptions = {}) {
|
|
11603
11785
|
const defaultStreamOptions = await this.getDefaultStreamOptions({
|
|
11604
11786
|
runtimeContext: streamOptions.runtimeContext
|
|
11605
11787
|
});
|
|
@@ -11700,6 +11882,10 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
11700
11882
|
agentAISpan,
|
|
11701
11883
|
...llmOptions
|
|
11702
11884
|
} = beforeResult;
|
|
11885
|
+
const overrideScorers = mergedStreamOptions.scorers;
|
|
11886
|
+
const tracingContext = {
|
|
11887
|
+
currentSpan: agentAISpan
|
|
11888
|
+
};
|
|
11703
11889
|
if (!output || experimental_output) {
|
|
11704
11890
|
this.logger.debug(`Starting agent ${this.name} llm stream call`, {
|
|
11705
11891
|
runId
|
|
@@ -11707,14 +11893,17 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
11707
11893
|
const streamResult = llm.__stream({
|
|
11708
11894
|
...llmOptions,
|
|
11709
11895
|
experimental_output,
|
|
11710
|
-
|
|
11896
|
+
tracingContext,
|
|
11711
11897
|
onFinish: async result => {
|
|
11712
11898
|
try {
|
|
11713
11899
|
const outputText = result.text;
|
|
11714
11900
|
await after({
|
|
11715
11901
|
result,
|
|
11716
11902
|
outputText,
|
|
11717
|
-
agentAISpan
|
|
11903
|
+
agentAISpan,
|
|
11904
|
+
...(overrideScorers ? {
|
|
11905
|
+
overrideScorers
|
|
11906
|
+
} : {})
|
|
11718
11907
|
});
|
|
11719
11908
|
} catch (e) {
|
|
11720
11909
|
this.logger.error("Error saving memory on finish", {
|
|
@@ -11736,7 +11925,7 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
11736
11925
|
});
|
|
11737
11926
|
return llm.__streamObject({
|
|
11738
11927
|
...llmOptions,
|
|
11739
|
-
|
|
11928
|
+
tracingContext,
|
|
11740
11929
|
onFinish: async result => {
|
|
11741
11930
|
try {
|
|
11742
11931
|
const outputText = JSON.stringify(result.object);
|
|
@@ -11744,7 +11933,10 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
11744
11933
|
result,
|
|
11745
11934
|
outputText,
|
|
11746
11935
|
structuredOutput: true,
|
|
11747
|
-
agentAISpan
|
|
11936
|
+
agentAISpan,
|
|
11937
|
+
...(overrideScorers ? {
|
|
11938
|
+
overrideScorers
|
|
11939
|
+
} : {})
|
|
11748
11940
|
});
|
|
11749
11941
|
} catch (e) {
|
|
11750
11942
|
this.logger.error("Error saving memory on finish", {
|
|
@@ -12062,6 +12254,21 @@ var ExecutionEngine = class extends chunkKXCUCBEI_cjs.MastraBase {
|
|
|
12062
12254
|
|
|
12063
12255
|
// src/workflows/default.ts
|
|
12064
12256
|
var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
12257
|
+
/**
|
|
12258
|
+
* Preprocesses an error caught during workflow execution.
|
|
12259
|
+
*
|
|
12260
|
+
* - Wraps a non-MastraError exception
|
|
12261
|
+
* - Logs error details
|
|
12262
|
+
*/
|
|
12263
|
+
preprocessExecutionError(e, errorDefinition, logPrefix) {
|
|
12264
|
+
const error = e instanceof chunkC73WLCY3_cjs.MastraError ? e : new chunkC73WLCY3_cjs.MastraError(errorDefinition, e);
|
|
12265
|
+
if (!(e instanceof chunkC73WLCY3_cjs.MastraError) && e instanceof Error && e.stack) {
|
|
12266
|
+
error.stack = e.stack;
|
|
12267
|
+
}
|
|
12268
|
+
this.logger?.trackException(error);
|
|
12269
|
+
this.logger?.error(logPrefix + error?.stack);
|
|
12270
|
+
return error;
|
|
12271
|
+
}
|
|
12065
12272
|
/**
|
|
12066
12273
|
* The runCounts map is used to keep track of the run count for each step.
|
|
12067
12274
|
* The step id is used as the key and the run count is the value.
|
|
@@ -12158,7 +12365,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
12158
12365
|
resume,
|
|
12159
12366
|
retryConfig,
|
|
12160
12367
|
runtimeContext,
|
|
12161
|
-
|
|
12368
|
+
tracingContext,
|
|
12162
12369
|
disableScorers
|
|
12163
12370
|
} = params;
|
|
12164
12371
|
const {
|
|
@@ -12167,33 +12374,16 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
12167
12374
|
} = retryConfig ?? {};
|
|
12168
12375
|
const steps = graph.steps;
|
|
12169
12376
|
this.runCounts.clear();
|
|
12170
|
-
const
|
|
12377
|
+
const workflowAISpan = chunkI7OAONIW_cjs.getOrCreateSpan({
|
|
12378
|
+
type: "workflow_run" /* WORKFLOW_RUN */,
|
|
12171
12379
|
name: `workflow run: '${workflowId}'`,
|
|
12172
12380
|
input,
|
|
12173
12381
|
attributes: {
|
|
12174
12382
|
workflowId
|
|
12175
|
-
}
|
|
12176
|
-
|
|
12177
|
-
|
|
12178
|
-
|
|
12179
|
-
workflowAISpan = currentSpan.createChildSpan({
|
|
12180
|
-
type: "workflow_run" /* WORKFLOW_RUN */,
|
|
12181
|
-
...spanArgs
|
|
12182
|
-
});
|
|
12183
|
-
} else {
|
|
12184
|
-
const aiTracing = chunk4DKPMUAC_cjs.getSelectedAITracing({
|
|
12185
|
-
runtimeContext
|
|
12186
|
-
});
|
|
12187
|
-
if (aiTracing) {
|
|
12188
|
-
workflowAISpan = aiTracing.startSpan({
|
|
12189
|
-
type: "workflow_run" /* WORKFLOW_RUN */,
|
|
12190
|
-
...spanArgs,
|
|
12191
|
-
startOptions: {
|
|
12192
|
-
runtimeContext
|
|
12193
|
-
}
|
|
12194
|
-
});
|
|
12195
|
-
}
|
|
12196
|
-
}
|
|
12383
|
+
},
|
|
12384
|
+
tracingContext,
|
|
12385
|
+
runtimeContext
|
|
12386
|
+
});
|
|
12197
12387
|
if (steps.length === 0) {
|
|
12198
12388
|
const empty_graph_error = new chunkC73WLCY3_cjs.MastraError({
|
|
12199
12389
|
id: "WORKFLOW_EXECUTE_EMPTY_GRAPH",
|
|
@@ -12286,7 +12476,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
12286
12476
|
return result2;
|
|
12287
12477
|
}
|
|
12288
12478
|
} catch (e) {
|
|
12289
|
-
const error =
|
|
12479
|
+
const error = this.preprocessExecutionError(e, {
|
|
12290
12480
|
id: "WORKFLOW_ENGINE_STEP_EXECUTION_FAILED",
|
|
12291
12481
|
domain: "MASTRA_WORKFLOW" /* MASTRA_WORKFLOW */,
|
|
12292
12482
|
category: "USER" /* USER */,
|
|
@@ -12294,9 +12484,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
12294
12484
|
workflowId,
|
|
12295
12485
|
runId
|
|
12296
12486
|
}
|
|
12297
|
-
},
|
|
12298
|
-
this.logger?.trackException(error);
|
|
12299
|
-
this.logger?.error(`Error executing step: ${error?.stack}`);
|
|
12487
|
+
}, "Error executing step: ");
|
|
12300
12488
|
const result2 = await this.fmtReturnValue(executionSpan, params.emitter, stepResults, lastOutput.result, e);
|
|
12301
12489
|
await this.persistStepUpdate({
|
|
12302
12490
|
workflowId,
|
|
@@ -12610,11 +12798,15 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
12610
12798
|
const stepAISpan = tracingContext.currentSpan?.createChildSpan({
|
|
12611
12799
|
name: `workflow step: '${step.id}'`,
|
|
12612
12800
|
type: "workflow_step" /* WORKFLOW_STEP */,
|
|
12613
|
-
|
|
12801
|
+
|
|
12802
|
+
//input: prevOutput,
|
|
12614
12803
|
attributes: {
|
|
12615
12804
|
stepId: step.id
|
|
12616
12805
|
}
|
|
12617
12806
|
});
|
|
12807
|
+
const innerTracingContext = {
|
|
12808
|
+
currentSpan: stepAISpan
|
|
12809
|
+
};
|
|
12618
12810
|
if (!skipEmits) {
|
|
12619
12811
|
await emitter.emit("watch", {
|
|
12620
12812
|
type: "watch",
|
|
@@ -12690,16 +12882,12 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
12690
12882
|
const result = await runStep({
|
|
12691
12883
|
runId,
|
|
12692
12884
|
workflowId,
|
|
12693
|
-
mastra: this.mastra ?
|
|
12694
|
-
currentSpan: stepAISpan
|
|
12695
|
-
}) : void 0,
|
|
12885
|
+
mastra: this.mastra ? chunkI7OAONIW_cjs.wrapMastra(this.mastra, innerTracingContext) : void 0,
|
|
12696
12886
|
runtimeContext,
|
|
12697
12887
|
inputData: prevOutput,
|
|
12698
12888
|
runCount: this.getOrGenerateRunCount(step.id),
|
|
12699
12889
|
resumeData: resume?.steps[0] === step.id ? resume?.resumePayload : void 0,
|
|
12700
|
-
tracingContext:
|
|
12701
|
-
currentSpan: stepAISpan
|
|
12702
|
-
},
|
|
12890
|
+
tracingContext: innerTracingContext,
|
|
12703
12891
|
getInitData: () => stepResults?.input,
|
|
12704
12892
|
getStepResult: step2 => {
|
|
12705
12893
|
if (!step2?.id) {
|
|
@@ -12754,6 +12942,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
12754
12942
|
workflowId,
|
|
12755
12943
|
stepId: step.id,
|
|
12756
12944
|
runtimeContext,
|
|
12945
|
+
tracingContext: innerTracingContext,
|
|
12757
12946
|
disableScorers
|
|
12758
12947
|
});
|
|
12759
12948
|
}
|
|
@@ -12778,7 +12967,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
12778
12967
|
}
|
|
12779
12968
|
break;
|
|
12780
12969
|
} catch (e) {
|
|
12781
|
-
const error =
|
|
12970
|
+
const error = this.preprocessExecutionError(e, {
|
|
12782
12971
|
id: "WORKFLOW_STEP_INVOKE_FAILED",
|
|
12783
12972
|
domain: "MASTRA_WORKFLOW" /* MASTRA_WORKFLOW */,
|
|
12784
12973
|
category: "USER" /* USER */,
|
|
@@ -12787,9 +12976,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
12787
12976
|
runId,
|
|
12788
12977
|
stepId: step.id
|
|
12789
12978
|
}
|
|
12790
|
-
},
|
|
12791
|
-
this.logger.trackException(error);
|
|
12792
|
-
this.logger.error(`Error executing step ${step.id}: ` + error?.stack);
|
|
12979
|
+
}, `Error executing step ${step.id}: `);
|
|
12793
12980
|
stepAISpan?.error({
|
|
12794
12981
|
error,
|
|
12795
12982
|
attributes: {
|
|
@@ -12876,6 +13063,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
12876
13063
|
workflowId,
|
|
12877
13064
|
stepId,
|
|
12878
13065
|
runtimeContext,
|
|
13066
|
+
tracingContext,
|
|
12879
13067
|
disableScorers
|
|
12880
13068
|
}) {
|
|
12881
13069
|
let scorersToUse = scorers;
|
|
@@ -12885,18 +13073,16 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
12885
13073
|
runtimeContext
|
|
12886
13074
|
});
|
|
12887
13075
|
} catch (error) {
|
|
12888
|
-
|
|
13076
|
+
this.preprocessExecutionError(error, {
|
|
12889
13077
|
id: "WORKFLOW_FAILED_TO_FETCH_SCORERS",
|
|
12890
|
-
domain: "MASTRA_WORKFLOW"
|
|
13078
|
+
domain: "MASTRA_WORKFLOW" /* MASTRA_WORKFLOW */,
|
|
12891
13079
|
category: "USER" /* USER */,
|
|
12892
13080
|
details: {
|
|
12893
13081
|
runId,
|
|
12894
13082
|
workflowId,
|
|
12895
13083
|
stepId
|
|
12896
13084
|
}
|
|
12897
|
-
},
|
|
12898
|
-
this.logger.trackException(mastraError);
|
|
12899
|
-
this.logger.error(mastraError.toString(), error);
|
|
13085
|
+
}, "Error fetching scorers: ");
|
|
12900
13086
|
}
|
|
12901
13087
|
}
|
|
12902
13088
|
if (!disableScorers && scorersToUse && Object.keys(scorersToUse || {}).length > 0) {
|
|
@@ -12908,6 +13094,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
12908
13094
|
input: [input],
|
|
12909
13095
|
output,
|
|
12910
13096
|
runtimeContext,
|
|
13097
|
+
tracingContext,
|
|
12911
13098
|
entity: {
|
|
12912
13099
|
id: workflowId,
|
|
12913
13100
|
stepId
|
|
@@ -13089,7 +13276,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
13089
13276
|
});
|
|
13090
13277
|
return result ? index : null;
|
|
13091
13278
|
} catch (e) {
|
|
13092
|
-
const error =
|
|
13279
|
+
const error = this.preprocessExecutionError(e, {
|
|
13093
13280
|
id: "WORKFLOW_CONDITION_EVALUATION_FAILED",
|
|
13094
13281
|
domain: "MASTRA_WORKFLOW" /* MASTRA_WORKFLOW */,
|
|
13095
13282
|
category: "USER" /* USER */,
|
|
@@ -13097,9 +13284,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
13097
13284
|
workflowId,
|
|
13098
13285
|
runId
|
|
13099
13286
|
}
|
|
13100
|
-
},
|
|
13101
|
-
this.logger.trackException(error);
|
|
13102
|
-
this.logger.error("Error evaluating condition: " + error?.stack);
|
|
13287
|
+
}, "Error evaluating condition: ");
|
|
13103
13288
|
evalSpan?.error({
|
|
13104
13289
|
error,
|
|
13105
13290
|
attributes: {
|
|
@@ -13279,7 +13464,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
13279
13464
|
const evalSpan = loopSpan?.createChildSpan({
|
|
13280
13465
|
type: "workflow_conditional_eval" /* WORKFLOW_CONDITIONAL_EVAL */,
|
|
13281
13466
|
name: `condition: ${entry.loopType}`,
|
|
13282
|
-
input: result.output,
|
|
13467
|
+
input: chunkI7OAONIW_cjs.selectFields(result.output, ["stepResult", "output.text", "output.object", "messages"]),
|
|
13283
13468
|
attributes: {
|
|
13284
13469
|
conditionIndex: iteration
|
|
13285
13470
|
}
|
|
@@ -14236,7 +14421,7 @@ function createStep(params) {
|
|
|
14236
14421
|
}
|
|
14237
14422
|
};
|
|
14238
14423
|
}
|
|
14239
|
-
if (params instanceof
|
|
14424
|
+
if (params instanceof chunkABRPHTOG_cjs.Tool) {
|
|
14240
14425
|
if (!params.inputSchema || !params.outputSchema) {
|
|
14241
14426
|
throw new Error("Tool must have input and output schemas defined");
|
|
14242
14427
|
}
|
|
@@ -14777,7 +14962,7 @@ var Workflow = class extends chunkKXCUCBEI_cjs.MastraBase {
|
|
|
14777
14962
|
cleanup: () => this.#runs.delete(runIdToUse)
|
|
14778
14963
|
});
|
|
14779
14964
|
this.#runs.set(runIdToUse, run);
|
|
14780
|
-
this.mastra?.getLogger().warn("createRun()
|
|
14965
|
+
this.mastra?.getLogger().warn("createRun() will be removed on September 16th. Use createRunAsync() instead.");
|
|
14781
14966
|
return run;
|
|
14782
14967
|
}
|
|
14783
14968
|
/**
|
|
@@ -14862,7 +15047,7 @@ var Workflow = class extends chunkKXCUCBEI_cjs.MastraBase {
|
|
|
14862
15047
|
abort,
|
|
14863
15048
|
abortSignal,
|
|
14864
15049
|
runCount,
|
|
14865
|
-
|
|
15050
|
+
tracingContext
|
|
14866
15051
|
}) {
|
|
14867
15052
|
this.__registerMastra(mastra);
|
|
14868
15053
|
const isResume = !!(resume?.steps && resume.steps.length > 0);
|
|
@@ -14898,11 +15083,11 @@ var Workflow = class extends chunkKXCUCBEI_cjs.MastraBase {
|
|
|
14898
15083
|
resumeData,
|
|
14899
15084
|
step: resume.steps,
|
|
14900
15085
|
runtimeContext,
|
|
14901
|
-
|
|
15086
|
+
tracingContext
|
|
14902
15087
|
}) : await run.start({
|
|
14903
15088
|
inputData,
|
|
14904
15089
|
runtimeContext,
|
|
14905
|
-
|
|
15090
|
+
tracingContext
|
|
14906
15091
|
});
|
|
14907
15092
|
unwatch();
|
|
14908
15093
|
unwatchV2();
|
|
@@ -15068,7 +15253,7 @@ var Run = class {
|
|
|
15068
15253
|
inputData,
|
|
15069
15254
|
runtimeContext,
|
|
15070
15255
|
writableStream,
|
|
15071
|
-
|
|
15256
|
+
tracingContext
|
|
15072
15257
|
}) {
|
|
15073
15258
|
const result = await this.executionEngine.execute({
|
|
15074
15259
|
workflowId: this.workflowId,
|
|
@@ -15095,7 +15280,7 @@ var Run = class {
|
|
|
15095
15280
|
runtimeContext: runtimeContext ?? new chunkGPWMM745_cjs.RuntimeContext(),
|
|
15096
15281
|
abortController: this.abortController,
|
|
15097
15282
|
writableStream,
|
|
15098
|
-
|
|
15283
|
+
tracingContext
|
|
15099
15284
|
});
|
|
15100
15285
|
if (result.status !== "suspended") {
|
|
15101
15286
|
this.cleanup?.();
|
|
@@ -15432,7 +15617,7 @@ var Run = class {
|
|
|
15432
15617
|
},
|
|
15433
15618
|
runtimeContext: runtimeContextToUse,
|
|
15434
15619
|
abortController: this.abortController,
|
|
15435
|
-
|
|
15620
|
+
tracingContext: params.tracingContext
|
|
15436
15621
|
}).then(result => {
|
|
15437
15622
|
if (result.status !== "suspended") {
|
|
15438
15623
|
this.closeStreamAction?.().catch(() => {});
|
|
@@ -15537,5 +15722,5 @@ exports.recursivelyCheckForFinalState = recursivelyCheckForFinalState;
|
|
|
15537
15722
|
exports.resolveVariables = resolveVariables;
|
|
15538
15723
|
exports.updateStepInHierarchy = updateStepInHierarchy;
|
|
15539
15724
|
exports.workflowToStep = workflowToStep;
|
|
15540
|
-
//# sourceMappingURL=chunk-
|
|
15541
|
-
//# sourceMappingURL=chunk-
|
|
15725
|
+
//# sourceMappingURL=chunk-KUNWELBC.cjs.map
|
|
15726
|
+
//# sourceMappingURL=chunk-KUNWELBC.cjs.map
|