@mastra/core 0.15.3-alpha.5 → 0.15.3-alpha.7
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/CHANGELOG.md +33 -0
- package/dist/agent/agent.types.d.ts +1 -0
- package/dist/agent/agent.types.d.ts.map +1 -1
- package/dist/agent/index.cjs +11 -11
- package/dist/agent/index.d.ts +2 -1
- 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/prompt/convert-to-mastra-v1.d.ts.map +1 -1
- package/dist/ai-tracing/exporters/default.d.ts.map +1 -1
- package/dist/ai-tracing/index.cjs +30 -30
- package/dist/ai-tracing/index.js +1 -1
- package/dist/{chunk-XM2ASGWH.js → chunk-4VU6A5XE.js} +3 -3
- package/dist/{chunk-XM2ASGWH.js.map → chunk-4VU6A5XE.js.map} +1 -1
- package/dist/{chunk-VVTB47UG.cjs → chunk-626FLQPT.cjs} +4 -4
- package/dist/{chunk-VVTB47UG.cjs.map → chunk-626FLQPT.cjs.map} +1 -1
- package/dist/{chunk-E264YNL3.cjs → chunk-7IIXZ5HS.cjs} +14 -14
- package/dist/{chunk-E264YNL3.cjs.map → chunk-7IIXZ5HS.cjs.map} +1 -1
- package/dist/{chunk-5CJDO3UO.cjs → chunk-AAJF7WLJ.cjs} +3 -4
- package/dist/chunk-AAJF7WLJ.cjs.map +1 -0
- package/dist/{chunk-OBKBA6CO.cjs → chunk-AB2X2OLU.cjs} +4 -4
- package/dist/{chunk-OBKBA6CO.cjs.map → chunk-AB2X2OLU.cjs.map} +1 -1
- package/dist/{chunk-NMDRUT3Q.cjs → chunk-AWES6LTC.cjs} +4 -4
- package/dist/{chunk-NMDRUT3Q.cjs.map → chunk-AWES6LTC.cjs.map} +1 -1
- package/dist/{chunk-PQ3VP6NG.js → chunk-AYPDYPRS.js} +82 -42
- package/dist/chunk-AYPDYPRS.js.map +1 -0
- package/dist/{chunk-F4SQXAXR.js → chunk-BGE27UEX.js} +3 -4
- package/dist/chunk-BGE27UEX.js.map +1 -0
- package/dist/{chunk-A5NC3XK2.js → chunk-EUZ3OA6Y.js} +5 -5
- package/dist/{chunk-A5NC3XK2.js.map → chunk-EUZ3OA6Y.js.map} +1 -1
- package/dist/{chunk-JQKPRJCJ.cjs → chunk-GJD2BTI5.cjs} +252 -157
- package/dist/chunk-GJD2BTI5.cjs.map +1 -0
- package/dist/chunk-GXSERFAG.js +3 -0
- package/dist/{chunk-ZPQQN52E.js.map → chunk-GXSERFAG.js.map} +1 -1
- package/dist/{chunk-CKM2ESZF.js → chunk-HGYL2SSF.js} +14 -24
- package/dist/chunk-HGYL2SSF.js.map +1 -0
- package/dist/{chunk-F2CAC2R2.cjs → chunk-MNDKBEEQ.cjs} +14 -24
- package/dist/chunk-MNDKBEEQ.cjs.map +1 -0
- package/dist/{chunk-MVEPSGWQ.cjs → chunk-NVB2F66X.cjs} +86 -46
- package/dist/chunk-NVB2F66X.cjs.map +1 -0
- package/dist/{chunk-23NO6AMW.js → chunk-P24PB73W.js} +221 -126
- package/dist/chunk-P24PB73W.js.map +1 -0
- package/dist/{chunk-XPFWOBV4.js → chunk-POFCBVHG.js} +3 -3
- package/dist/{chunk-XPFWOBV4.js.map → chunk-POFCBVHG.js.map} +1 -1
- package/dist/{chunk-76MWMAR7.js → chunk-R7K2QO7M.js} +3 -2
- package/dist/chunk-R7K2QO7M.js.map +1 -0
- package/dist/{chunk-I7OAONIW.cjs → chunk-UFCYMOYH.cjs} +12 -2
- package/dist/chunk-UFCYMOYH.cjs.map +1 -0
- package/dist/{chunk-J35ULAQT.js → chunk-VZS4UVKF.js} +3 -3
- package/dist/{chunk-J35ULAQT.js.map → chunk-VZS4UVKF.js.map} +1 -1
- package/dist/{chunk-FBBP67MQ.cjs → chunk-VZYIKGJ6.cjs} +4 -4
- package/dist/{chunk-FBBP67MQ.cjs.map → chunk-VZYIKGJ6.cjs.map} +1 -1
- package/dist/{chunk-LOYT3WUA.js → chunk-WEPWZHE4.js} +12 -2
- package/dist/chunk-WEPWZHE4.js.map +1 -0
- package/dist/chunk-X4RMXTXF.cjs +4 -0
- package/dist/{chunk-F37IQKBQ.cjs.map → chunk-X4RMXTXF.cjs.map} +1 -1
- package/dist/{chunk-2L6PFHHU.js → chunk-XJO6WBIW.js} +3 -3
- package/dist/{chunk-2L6PFHHU.js.map → chunk-XJO6WBIW.js.map} +1 -1
- package/dist/{chunk-ZOU4K5MI.cjs → chunk-Z637KSJF.cjs} +3 -2
- package/dist/chunk-Z637KSJF.cjs.map +1 -0
- package/dist/index.cjs +30 -30
- package/dist/index.js +8 -8
- 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 +1 -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 +2 -0
- package/dist/loop/types.d.ts.map +1 -1
- package/dist/loop/workflow/llm-execution.d.ts.map +1 -1
- package/dist/loop/workflow/stream.d.ts.map +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +4 -4
- package/dist/memory/index.js +1 -1
- package/dist/network/index.cjs +2 -2
- package/dist/network/index.js +1 -1
- package/dist/network/vNext/index.cjs +17 -17
- package/dist/network/vNext/index.cjs.map +1 -1
- package/dist/network/vNext/index.d.ts.map +1 -1
- package/dist/network/vNext/index.js +3 -3
- package/dist/network/vNext/index.js.map +1 -1
- package/dist/processors/index.cjs +8 -8
- package/dist/processors/index.js +2 -2
- package/dist/relevance/index.cjs +4 -4
- package/dist/relevance/index.js +1 -1
- package/dist/scores/index.cjs +5 -5
- package/dist/scores/index.js +1 -1
- package/dist/server/index.cjs +2 -2
- package/dist/server/index.js +1 -1
- package/dist/storage/index.cjs +3 -3
- package/dist/storage/index.js +1 -1
- package/dist/stream/MastraWorkflowStream.d.ts.map +1 -1
- package/dist/stream/base/output.d.ts +6 -0
- package/dist/stream/base/output.d.ts.map +1 -1
- package/dist/stream/index.cjs +3 -3
- package/dist/stream/index.js +1 -1
- package/dist/stream/types.d.ts +2 -1
- package/dist/stream/types.d.ts.map +1 -1
- package/dist/telemetry/index.cjs +7 -7
- package/dist/telemetry/index.js +1 -1
- package/dist/telemetry/telemetry.decorators.d.ts.map +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 -0
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tts/index.cjs +2 -2
- package/dist/tts/index.js +1 -1
- package/dist/voice/index.cjs +4 -4
- package/dist/voice/index.js +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/evented/workflow.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/types.d.ts +64 -9
- package/dist/workflows/types.d.ts.map +1 -1
- package/dist/workflows/workflow.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-23NO6AMW.js.map +0 -1
- package/dist/chunk-5CJDO3UO.cjs.map +0 -1
- package/dist/chunk-76MWMAR7.js.map +0 -1
- package/dist/chunk-CKM2ESZF.js.map +0 -1
- package/dist/chunk-F2CAC2R2.cjs.map +0 -1
- package/dist/chunk-F37IQKBQ.cjs +0 -4
- package/dist/chunk-F4SQXAXR.js.map +0 -1
- package/dist/chunk-I7OAONIW.cjs.map +0 -1
- package/dist/chunk-JQKPRJCJ.cjs.map +0 -1
- package/dist/chunk-LOYT3WUA.js.map +0 -1
- package/dist/chunk-MVEPSGWQ.cjs.map +0 -1
- package/dist/chunk-PQ3VP6NG.js.map +0 -1
- package/dist/chunk-ZOU4K5MI.cjs.map +0 -1
- package/dist/chunk-ZPQQN52E.js +0 -3
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { DefaultVoice } from './chunk-
|
|
1
|
+
import { DefaultVoice } from './chunk-4VU6A5XE.js';
|
|
2
2
|
import { EMITTER_SYMBOL } from './chunk-GK5V7YTQ.js';
|
|
3
|
-
import { InstrumentClass, Telemetry } from './chunk-
|
|
4
|
-
import { MastraLLMV1 } from './chunk-
|
|
5
|
-
import { MessageList, DefaultGeneratedFile, DefaultGeneratedFileWithType } from './chunk-
|
|
3
|
+
import { InstrumentClass, Telemetry } from './chunk-R7K2QO7M.js';
|
|
4
|
+
import { MastraLLMV1 } from './chunk-HGYL2SSF.js';
|
|
5
|
+
import { MessageList, DefaultGeneratedFile, DefaultGeneratedFileWithType } from './chunk-BGE27UEX.js';
|
|
6
6
|
import { executeHook } from './chunk-TTELJD4F.js';
|
|
7
7
|
import { ensureToolProperties, makeCoreTool, createMastraProxy, delay } from './chunk-WWQ3QRPF.js';
|
|
8
8
|
import { RuntimeContext } from './chunk-HLRWYUFN.js';
|
|
9
9
|
import { ToolStream } from './chunk-YW7UILPE.js';
|
|
10
|
-
import { Tool } from './chunk-BJGHUKKM.js';
|
|
11
|
-
import { getOrCreateSpan, wrapMastra, selectFields } from './chunk-
|
|
10
|
+
import { createTool, Tool } from './chunk-BJGHUKKM.js';
|
|
11
|
+
import { getOrCreateSpan, wrapMastra, selectFields } from './chunk-WEPWZHE4.js';
|
|
12
12
|
import { MastraError } from './chunk-MCOVMKIS.js';
|
|
13
13
|
import { MastraBase } from './chunk-6GF5M4GX.js';
|
|
14
14
|
import { ConsoleLogger, RegisteredLogger } from './chunk-X3GXU6TZ.js';
|
|
@@ -2023,6 +2023,7 @@ var MastraModelOutput = class extends MastraBase {
|
|
|
2023
2023
|
reasoningDetails: new DelayedPromise()
|
|
2024
2024
|
};
|
|
2025
2025
|
#streamConsumed = false;
|
|
2026
|
+
#returnScorerData = false;
|
|
2026
2027
|
/**
|
|
2027
2028
|
* Unique identifier for this execution run.
|
|
2028
2029
|
*/
|
|
@@ -2047,6 +2048,7 @@ var MastraModelOutput = class extends MastraBase {
|
|
|
2047
2048
|
name: "MastraModelOutput"
|
|
2048
2049
|
});
|
|
2049
2050
|
this.#options = options;
|
|
2051
|
+
this.#returnScorerData = !!options.returnScorerData;
|
|
2050
2052
|
this.runId = options.runId;
|
|
2051
2053
|
if (options.outputProcessors?.length) {
|
|
2052
2054
|
this.processorRunner = new ProcessorRunner({
|
|
@@ -2526,6 +2528,18 @@ var MastraModelOutput = class extends MastraBase {
|
|
|
2526
2528
|
throw error;
|
|
2527
2529
|
}
|
|
2528
2530
|
});
|
|
2531
|
+
let scoringData;
|
|
2532
|
+
if (this.#returnScorerData) {
|
|
2533
|
+
scoringData = {
|
|
2534
|
+
input: {
|
|
2535
|
+
inputMessages: this.messageList.getPersisted.input.ui(),
|
|
2536
|
+
rememberedMessages: this.messageList.getPersisted.remembered.ui(),
|
|
2537
|
+
systemMessages: this.messageList.getSystemMessages(),
|
|
2538
|
+
taggedSystemMessages: this.messageList.getPersisted.taggedSystemMessages
|
|
2539
|
+
},
|
|
2540
|
+
output: this.messageList.getPersisted.response.ui()
|
|
2541
|
+
};
|
|
2542
|
+
}
|
|
2529
2543
|
const fullOutput = {
|
|
2530
2544
|
text: await this.text,
|
|
2531
2545
|
usage: await this.usage,
|
|
@@ -2545,7 +2559,10 @@ var MastraModelOutput = class extends MastraBase {
|
|
|
2545
2559
|
object: await this.object,
|
|
2546
2560
|
error: this.error,
|
|
2547
2561
|
tripwire: this.#tripwire,
|
|
2548
|
-
tripwireReason: this.#tripwireReason
|
|
2562
|
+
tripwireReason: this.#tripwireReason,
|
|
2563
|
+
...(scoringData ? {
|
|
2564
|
+
scoringData
|
|
2565
|
+
} : {})
|
|
2549
2566
|
};
|
|
2550
2567
|
fullOutput.response.messages = this.messageList.get.response.aiV5.model();
|
|
2551
2568
|
return fullOutput;
|
|
@@ -3069,7 +3086,16 @@ async function processOutputStream({
|
|
|
3069
3086
|
reasoningDeltas: []
|
|
3070
3087
|
});
|
|
3071
3088
|
}
|
|
3072
|
-
if (chunk.type !== "text-delta" && chunk.type !== "tool-call" &&
|
|
3089
|
+
if (chunk.type !== "text-delta" && chunk.type !== "tool-call" &&
|
|
3090
|
+
// not 100% sure about this being the right fix.
|
|
3091
|
+
// basically for some llm providers they add response-metadata after each text-delta
|
|
3092
|
+
// we then flush the chunks by calling messageList.add (a few lines down)
|
|
3093
|
+
// this results in a bunch of weird separated text chunks on the message instead of combined chunks
|
|
3094
|
+
// easiest solution here is to just not flush for response-metadata
|
|
3095
|
+
// BUT does this cause other issues?
|
|
3096
|
+
// Alternative solution: in message list allow combining text deltas together when the message source is "response" and the text parts are directly next to each other
|
|
3097
|
+
// simple solution for now is to not flush text deltas on response-metadata
|
|
3098
|
+
chunk.type !== "response-metadata" && runState.state.isStreaming) {
|
|
3073
3099
|
if (runState.state.textDeltas.length) {
|
|
3074
3100
|
const textStartPayload = chunk.payload;
|
|
3075
3101
|
const providerMetadata = textStartPayload.providerMetadata ?? runState.state.providerOptions;
|
|
@@ -3750,16 +3776,6 @@ function workflowLoopStream({
|
|
|
3750
3776
|
start: async controller => {
|
|
3751
3777
|
const writer = new WritableStream({
|
|
3752
3778
|
write: chunk => {
|
|
3753
|
-
if (llmAISpan && chunk.type === "text-delta") {
|
|
3754
|
-
llmAISpan.createEventSpan({
|
|
3755
|
-
type: "llm_chunk" /* LLM_CHUNK */,
|
|
3756
|
-
name: `llm chunk: ${chunk.type}`,
|
|
3757
|
-
output: chunk.payload.text,
|
|
3758
|
-
attributes: {
|
|
3759
|
-
chunkType: chunk.type
|
|
3760
|
-
}
|
|
3761
|
-
});
|
|
3762
|
-
}
|
|
3763
3779
|
controller.enqueue(chunk);
|
|
3764
3780
|
}
|
|
3765
3781
|
});
|
|
@@ -3905,6 +3921,7 @@ function loop({
|
|
|
3905
3921
|
_internal,
|
|
3906
3922
|
mode = "stream",
|
|
3907
3923
|
outputProcessors,
|
|
3924
|
+
returnScorerData,
|
|
3908
3925
|
llmAISpan,
|
|
3909
3926
|
...rest
|
|
3910
3927
|
}) {
|
|
@@ -3984,7 +4001,8 @@ function loop({
|
|
|
3984
4001
|
onStepFinish: rest.options?.onStepFinish,
|
|
3985
4002
|
includeRawChunks: !!includeRawChunks,
|
|
3986
4003
|
output: rest.output,
|
|
3987
|
-
outputProcessors
|
|
4004
|
+
outputProcessors,
|
|
4005
|
+
returnScorerData
|
|
3988
4006
|
}
|
|
3989
4007
|
});
|
|
3990
4008
|
}
|
|
@@ -4076,6 +4094,7 @@ var MastraLLMVNext = class extends MastraBase {
|
|
|
4076
4094
|
output,
|
|
4077
4095
|
options,
|
|
4078
4096
|
outputProcessors,
|
|
4097
|
+
returnScorerData,
|
|
4079
4098
|
providerOptions,
|
|
4080
4099
|
tracingContext
|
|
4081
4100
|
// ...rest
|
|
@@ -4131,6 +4150,7 @@ var MastraLLMVNext = class extends MastraBase {
|
|
|
4131
4150
|
},
|
|
4132
4151
|
output,
|
|
4133
4152
|
outputProcessors,
|
|
4153
|
+
returnScorerData,
|
|
4134
4154
|
llmAISpan,
|
|
4135
4155
|
options: {
|
|
4136
4156
|
...options,
|
|
@@ -9879,27 +9899,31 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
9879
9899
|
threadId,
|
|
9880
9900
|
resourceId,
|
|
9881
9901
|
runtimeContext,
|
|
9902
|
+
methodType,
|
|
9882
9903
|
tracingContext
|
|
9883
9904
|
}) {
|
|
9884
|
-
|
|
9905
|
+
const convertedWorkflowTools = {};
|
|
9885
9906
|
const workflows = await this.getWorkflows({
|
|
9886
9907
|
runtimeContext
|
|
9887
9908
|
});
|
|
9888
9909
|
if (Object.keys(workflows).length > 0) {
|
|
9889
|
-
|
|
9890
|
-
|
|
9910
|
+
for (const [workflowName, workflow] of Object.entries(workflows)) {
|
|
9911
|
+
const toolObj = createTool({
|
|
9912
|
+
id: workflowName,
|
|
9891
9913
|
description: workflow.description || `Workflow: ${workflowName}`,
|
|
9892
|
-
|
|
9893
|
-
|
|
9894
|
-
|
|
9895
|
-
},
|
|
9914
|
+
inputSchema: workflow.inputSchema,
|
|
9915
|
+
outputSchema: workflow.outputSchema,
|
|
9916
|
+
mastra: this.#mastra,
|
|
9896
9917
|
// manually wrap workflow tools with ai tracing, so that we can pass the
|
|
9897
9918
|
// current tool span onto the workflow to maintain continuity of the trace
|
|
9898
|
-
execute: async
|
|
9919
|
+
execute: async ({
|
|
9920
|
+
context,
|
|
9921
|
+
writer
|
|
9922
|
+
}) => {
|
|
9899
9923
|
const toolAISpan = tracingContext.currentSpan?.createChildSpan({
|
|
9900
9924
|
type: "tool_call" /* TOOL_CALL */,
|
|
9901
9925
|
name: `tool: '${workflowName}'`,
|
|
9902
|
-
input:
|
|
9926
|
+
input: context,
|
|
9903
9927
|
attributes: {
|
|
9904
9928
|
toolId: workflowName,
|
|
9905
9929
|
toolType: "workflow"
|
|
@@ -9909,19 +9933,45 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
9909
9933
|
this.logger.debug(`[Agent:${this.name}] - Executing workflow as tool ${workflowName}`, {
|
|
9910
9934
|
name: workflowName,
|
|
9911
9935
|
description: workflow.description,
|
|
9912
|
-
args,
|
|
9936
|
+
args: context,
|
|
9913
9937
|
runId,
|
|
9914
9938
|
threadId,
|
|
9915
9939
|
resourceId
|
|
9916
9940
|
});
|
|
9917
9941
|
const run = workflow.createRun();
|
|
9918
|
-
|
|
9919
|
-
|
|
9920
|
-
|
|
9921
|
-
|
|
9922
|
-
|
|
9942
|
+
let result;
|
|
9943
|
+
if (methodType === "generate") {
|
|
9944
|
+
result = await run.start({
|
|
9945
|
+
inputData: context,
|
|
9946
|
+
runtimeContext,
|
|
9947
|
+
tracingContext: {
|
|
9948
|
+
currentSpan: toolAISpan
|
|
9949
|
+
}
|
|
9950
|
+
});
|
|
9951
|
+
} else if (methodType === "stream") {
|
|
9952
|
+
const streamResult = await run.stream({
|
|
9953
|
+
inputData: context,
|
|
9954
|
+
runtimeContext
|
|
9955
|
+
// TODO: is this forgottn?
|
|
9956
|
+
//currentSpan: toolAISpan,
|
|
9957
|
+
});
|
|
9958
|
+
if (writer) {
|
|
9959
|
+
await streamResult.stream.pipeTo(writer);
|
|
9960
|
+
} else {
|
|
9961
|
+
for await (const _chunk of streamResult.stream) {}
|
|
9923
9962
|
}
|
|
9924
|
-
|
|
9963
|
+
result = await streamResult.getWorkflowState();
|
|
9964
|
+
} else if (methodType === "streamVNext") {
|
|
9965
|
+
const streamResult = run.streamVNext({
|
|
9966
|
+
inputData: context,
|
|
9967
|
+
runtimeContext
|
|
9968
|
+
//format,
|
|
9969
|
+
});
|
|
9970
|
+
if (writer) {
|
|
9971
|
+
await streamResult.pipeTo(writer);
|
|
9972
|
+
}
|
|
9973
|
+
result = await streamResult.result;
|
|
9974
|
+
}
|
|
9925
9975
|
toolAISpan?.end({
|
|
9926
9976
|
output: result
|
|
9927
9977
|
});
|
|
@@ -9947,9 +9997,26 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
9947
9997
|
throw mastraError;
|
|
9948
9998
|
}
|
|
9949
9999
|
}
|
|
10000
|
+
});
|
|
10001
|
+
const options = {
|
|
10002
|
+
name: workflowName,
|
|
10003
|
+
runId,
|
|
10004
|
+
threadId,
|
|
10005
|
+
resourceId,
|
|
10006
|
+
logger: this.logger,
|
|
10007
|
+
mastra: this.#mastra,
|
|
10008
|
+
memory: await this.getMemory({
|
|
10009
|
+
runtimeContext
|
|
10010
|
+
}),
|
|
10011
|
+
agentName: this.name,
|
|
10012
|
+
runtimeContext,
|
|
10013
|
+
model: typeof this.model === "function" ? await this.getModel({
|
|
10014
|
+
runtimeContext
|
|
10015
|
+
}) : this.model,
|
|
10016
|
+
tracingContext
|
|
9950
10017
|
};
|
|
9951
|
-
|
|
9952
|
-
}
|
|
10018
|
+
convertedWorkflowTools[workflowName] = makeCoreTool(toolObj, options);
|
|
10019
|
+
}
|
|
9953
10020
|
}
|
|
9954
10021
|
return convertedWorkflowTools;
|
|
9955
10022
|
}
|
|
@@ -9961,7 +10028,9 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
9961
10028
|
runId,
|
|
9962
10029
|
runtimeContext,
|
|
9963
10030
|
tracingContext,
|
|
9964
|
-
writableStream
|
|
10031
|
+
writableStream,
|
|
10032
|
+
methodType,
|
|
10033
|
+
format
|
|
9965
10034
|
}) {
|
|
9966
10035
|
let mastraProxy = void 0;
|
|
9967
10036
|
const logger = this.logger;
|
|
@@ -10011,6 +10080,8 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
10011
10080
|
resourceId,
|
|
10012
10081
|
threadId,
|
|
10013
10082
|
runtimeContext,
|
|
10083
|
+
methodType,
|
|
10084
|
+
format,
|
|
10014
10085
|
tracingContext
|
|
10015
10086
|
});
|
|
10016
10087
|
return this.formatTools({
|
|
@@ -10096,6 +10167,7 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
10096
10167
|
runtimeContext,
|
|
10097
10168
|
saveQueueManager,
|
|
10098
10169
|
writableStream,
|
|
10170
|
+
methodType,
|
|
10099
10171
|
tracingContext
|
|
10100
10172
|
}) {
|
|
10101
10173
|
return {
|
|
@@ -10149,7 +10221,8 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
10149
10221
|
runId,
|
|
10150
10222
|
runtimeContext,
|
|
10151
10223
|
tracingContext: innerTracingContext,
|
|
10152
|
-
writableStream
|
|
10224
|
+
writableStream,
|
|
10225
|
+
methodType
|
|
10153
10226
|
});
|
|
10154
10227
|
const messageList = new MessageList({
|
|
10155
10228
|
threadId,
|
|
@@ -10627,7 +10700,7 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10627
10700
|
}
|
|
10628
10701
|
return result;
|
|
10629
10702
|
}
|
|
10630
|
-
async prepareLLMOptions(messages, options) {
|
|
10703
|
+
async prepareLLMOptions(messages, options, methodType) {
|
|
10631
10704
|
const {
|
|
10632
10705
|
context,
|
|
10633
10706
|
memoryOptions: memoryConfigFromArgs,
|
|
@@ -10704,6 +10777,7 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10704
10777
|
runtimeContext,
|
|
10705
10778
|
saveQueueManager,
|
|
10706
10779
|
writableStream,
|
|
10780
|
+
methodType,
|
|
10707
10781
|
tracingContext
|
|
10708
10782
|
});
|
|
10709
10783
|
let messageList;
|
|
@@ -10791,7 +10865,26 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10791
10865
|
}
|
|
10792
10866
|
};
|
|
10793
10867
|
}
|
|
10794
|
-
|
|
10868
|
+
/**
|
|
10869
|
+
* Merges telemetry wrapper with default onFinish callback when needed
|
|
10870
|
+
*/
|
|
10871
|
+
#mergeOnFinishWithTelemetry(streamOptions, defaultStreamOptions) {
|
|
10872
|
+
let finalOnFinish = streamOptions?.onFinish || defaultStreamOptions.onFinish;
|
|
10873
|
+
if (streamOptions?.onFinish && streamOptions.onFinish.__hasOriginalOnFinish === false && defaultStreamOptions.onFinish) {
|
|
10874
|
+
const telemetryWrapper = streamOptions.onFinish;
|
|
10875
|
+
const defaultCallback = defaultStreamOptions.onFinish;
|
|
10876
|
+
finalOnFinish = async data => {
|
|
10877
|
+
await telemetryWrapper(data);
|
|
10878
|
+
await defaultCallback(data);
|
|
10879
|
+
};
|
|
10880
|
+
}
|
|
10881
|
+
return finalOnFinish;
|
|
10882
|
+
}
|
|
10883
|
+
async #execute({
|
|
10884
|
+
methodType,
|
|
10885
|
+
format = "mastra",
|
|
10886
|
+
...options
|
|
10887
|
+
}) {
|
|
10795
10888
|
const runtimeContext = options.runtimeContext || new RuntimeContext();
|
|
10796
10889
|
const threadFromArgs = resolveThreadIdFromArgs({
|
|
10797
10890
|
threadId: options.threadId,
|
|
@@ -10886,6 +10979,8 @@ Message ${msg.threadId && msg.threadId !== threadObject.id ? "from previous conv
|
|
|
10886
10979
|
runId,
|
|
10887
10980
|
runtimeContext,
|
|
10888
10981
|
writableStream: options.writableStream,
|
|
10982
|
+
methodType,
|
|
10983
|
+
format,
|
|
10889
10984
|
tracingContext: {
|
|
10890
10985
|
currentSpan: agentAISpan
|
|
10891
10986
|
}
|
|
@@ -11105,9 +11200,10 @@ the following messages are from ${ymd}
|
|
|
11105
11200
|
const streamResult = llm.stream({
|
|
11106
11201
|
...inputData,
|
|
11107
11202
|
outputProcessors,
|
|
11203
|
+
returnScorerData: options.returnScorerData,
|
|
11108
11204
|
tracingContext
|
|
11109
11205
|
});
|
|
11110
|
-
if (
|
|
11206
|
+
if (format === "aisdk") {
|
|
11111
11207
|
return streamResult.aisdk.v5;
|
|
11112
11208
|
}
|
|
11113
11209
|
return streamResult;
|
|
@@ -11170,6 +11266,14 @@ the following messages are from ${ymd}
|
|
|
11170
11266
|
textStream: async function* () {}(),
|
|
11171
11267
|
fullStream: new globalThis.ReadableStream({
|
|
11172
11268
|
start(controller) {
|
|
11269
|
+
controller.enqueue({
|
|
11270
|
+
type: "tripwire",
|
|
11271
|
+
runId: result2.runId,
|
|
11272
|
+
from: "AGENT" /* AGENT */,
|
|
11273
|
+
payload: {
|
|
11274
|
+
tripwireReason: result2.tripwireReason
|
|
11275
|
+
}
|
|
11276
|
+
});
|
|
11173
11277
|
controller.close();
|
|
11174
11278
|
}
|
|
11175
11279
|
}),
|
|
@@ -11463,7 +11567,8 @@ the following messages are from ${ymd}
|
|
|
11463
11567
|
});
|
|
11464
11568
|
const mergedStreamOptions = {
|
|
11465
11569
|
...defaultStreamOptions,
|
|
11466
|
-
...streamOptions
|
|
11570
|
+
...streamOptions,
|
|
11571
|
+
onFinish: this.#mergeOnFinishWithTelemetry(streamOptions, defaultStreamOptions)
|
|
11467
11572
|
};
|
|
11468
11573
|
const llm = await this.getLLM({
|
|
11469
11574
|
runtimeContext: mergedStreamOptions.runtimeContext
|
|
@@ -11478,7 +11583,8 @@ the following messages are from ${ymd}
|
|
|
11478
11583
|
}
|
|
11479
11584
|
const result = await this.#execute({
|
|
11480
11585
|
...mergedStreamOptions,
|
|
11481
|
-
messages
|
|
11586
|
+
messages,
|
|
11587
|
+
methodType: "streamVNext"
|
|
11482
11588
|
});
|
|
11483
11589
|
if (result.status !== "success") {
|
|
11484
11590
|
if (result.status === "failed") {
|
|
@@ -11517,7 +11623,7 @@ the following messages are from ${ymd}
|
|
|
11517
11623
|
llm,
|
|
11518
11624
|
before,
|
|
11519
11625
|
after
|
|
11520
|
-
} = await this.prepareLLMOptions(messages, mergedGenerateOptions);
|
|
11626
|
+
} = await this.prepareLLMOptions(messages, mergedGenerateOptions, "generate");
|
|
11521
11627
|
if (llm.getModel().specificationVersion !== "v1") {
|
|
11522
11628
|
this.logger.error("V2 models are not supported for the current version of generate. Please use generateVNext instead.", {
|
|
11523
11629
|
modelId: llm.getModel().modelId
|
|
@@ -11761,13 +11867,14 @@ the following messages are from ${ymd}
|
|
|
11761
11867
|
});
|
|
11762
11868
|
const mergedStreamOptions = {
|
|
11763
11869
|
...defaultStreamOptions,
|
|
11764
|
-
...streamOptions
|
|
11870
|
+
...streamOptions,
|
|
11871
|
+
onFinish: this.#mergeOnFinishWithTelemetry(streamOptions, defaultStreamOptions)
|
|
11765
11872
|
};
|
|
11766
11873
|
const {
|
|
11767
11874
|
llm,
|
|
11768
11875
|
before,
|
|
11769
11876
|
after
|
|
11770
|
-
} = await this.prepareLLMOptions(messages, mergedStreamOptions);
|
|
11877
|
+
} = await this.prepareLLMOptions(messages, mergedStreamOptions, "stream");
|
|
11771
11878
|
if (llm.getModel().specificationVersion !== "v1") {
|
|
11772
11879
|
this.logger.error("V2 models are not supported for stream. Please use streamVNext instead.", {
|
|
11773
11880
|
modelId: llm.getModel().modelId
|
|
@@ -12159,21 +12266,20 @@ var MastraWorkflowStream = class extends ReadableStream$1 {
|
|
|
12159
12266
|
}
|
|
12160
12267
|
});
|
|
12161
12268
|
controller.enqueue({
|
|
12162
|
-
type: "start",
|
|
12269
|
+
type: "workflow-start",
|
|
12163
12270
|
runId: run.runId,
|
|
12164
12271
|
from: "WORKFLOW" /* WORKFLOW */,
|
|
12165
12272
|
payload: {}
|
|
12166
12273
|
});
|
|
12167
12274
|
const stream = await createStream(writer);
|
|
12168
12275
|
for await (const chunk of stream) {
|
|
12169
|
-
if (chunk.type === "step-
|
|
12170
|
-
|
|
12171
|
-
updateUsageCount(finishPayload.usage);
|
|
12276
|
+
if (chunk.type === "step-finish") {
|
|
12277
|
+
updateUsageCount(chunk.payload.usage);
|
|
12172
12278
|
}
|
|
12173
12279
|
controller.enqueue(chunk);
|
|
12174
12280
|
}
|
|
12175
12281
|
controller.enqueue({
|
|
12176
|
-
type: "finish",
|
|
12282
|
+
type: "workflow-finish",
|
|
12177
12283
|
runId: run.runId,
|
|
12178
12284
|
from: "WORKFLOW" /* WORKFLOW */,
|
|
12179
12285
|
payload: {
|
|
@@ -12589,7 +12695,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
12589
12695
|
engine: {},
|
|
12590
12696
|
abortSignal: abortController?.signal,
|
|
12591
12697
|
writer: new ToolStream({
|
|
12592
|
-
prefix: "step",
|
|
12698
|
+
prefix: "workflow-step",
|
|
12593
12699
|
callId: stepCallId,
|
|
12594
12700
|
name: "sleep",
|
|
12595
12701
|
runId
|
|
@@ -12668,7 +12774,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
12668
12774
|
engine: {},
|
|
12669
12775
|
abortSignal: abortController?.signal,
|
|
12670
12776
|
writer: new ToolStream({
|
|
12671
|
-
prefix: "step",
|
|
12777
|
+
prefix: "workflow-step",
|
|
12672
12778
|
callId: stepCallId,
|
|
12673
12779
|
name: "sleepUntil",
|
|
12674
12780
|
runId
|
|
@@ -12804,7 +12910,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
12804
12910
|
eventTimestamp: Date.now()
|
|
12805
12911
|
});
|
|
12806
12912
|
await emitter.emit("watch-v2", {
|
|
12807
|
-
type: "step-start",
|
|
12913
|
+
type: "workflow-step-start",
|
|
12808
12914
|
payload: {
|
|
12809
12915
|
id: step.id,
|
|
12810
12916
|
stepCallId,
|
|
@@ -12899,7 +13005,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
12899
13005
|
engine: {},
|
|
12900
13006
|
abortSignal: abortController?.signal,
|
|
12901
13007
|
writer: new ToolStream({
|
|
12902
|
-
prefix: "step",
|
|
13008
|
+
prefix: "workflow-step",
|
|
12903
13009
|
callId: stepCallId,
|
|
12904
13010
|
name: step.id,
|
|
12905
13011
|
runId
|
|
@@ -12990,7 +13096,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
12990
13096
|
});
|
|
12991
13097
|
if (execResults.status === "suspended") {
|
|
12992
13098
|
await emitter.emit("watch-v2", {
|
|
12993
|
-
type: "step-suspended",
|
|
13099
|
+
type: "workflow-step-suspended",
|
|
12994
13100
|
payload: {
|
|
12995
13101
|
id: step.id,
|
|
12996
13102
|
stepCallId,
|
|
@@ -12999,7 +13105,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
12999
13105
|
});
|
|
13000
13106
|
} else {
|
|
13001
13107
|
await emitter.emit("watch-v2", {
|
|
13002
|
-
type: "step-result",
|
|
13108
|
+
type: "workflow-step-result",
|
|
13003
13109
|
payload: {
|
|
13004
13110
|
id: step.id,
|
|
13005
13111
|
stepCallId,
|
|
@@ -13007,7 +13113,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
13007
13113
|
}
|
|
13008
13114
|
});
|
|
13009
13115
|
await emitter.emit("watch-v2", {
|
|
13010
|
-
type: "step-finish",
|
|
13116
|
+
type: "workflow-step-finish",
|
|
13011
13117
|
payload: {
|
|
13012
13118
|
id: step.id,
|
|
13013
13119
|
stepCallId,
|
|
@@ -13236,7 +13342,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
13236
13342
|
engine: {},
|
|
13237
13343
|
abortSignal: abortController?.signal,
|
|
13238
13344
|
writer: new ToolStream({
|
|
13239
|
-
prefix: "step",
|
|
13345
|
+
prefix: "workflow-step",
|
|
13240
13346
|
callId: randomUUID(),
|
|
13241
13347
|
name: "conditional",
|
|
13242
13348
|
runId
|
|
@@ -13470,7 +13576,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
13470
13576
|
engine: {},
|
|
13471
13577
|
abortSignal: abortController?.signal,
|
|
13472
13578
|
writer: new ToolStream({
|
|
13473
|
-
prefix: "step",
|
|
13579
|
+
prefix: "workflow-step",
|
|
13474
13580
|
callId: randomUUID(),
|
|
13475
13581
|
name: "loop",
|
|
13476
13582
|
runId
|
|
@@ -13560,7 +13666,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
13560
13666
|
eventTimestamp: Date.now()
|
|
13561
13667
|
});
|
|
13562
13668
|
await emitter.emit("watch-v2", {
|
|
13563
|
-
type: "step-start",
|
|
13669
|
+
type: "workflow-step-start",
|
|
13564
13670
|
payload: {
|
|
13565
13671
|
id: step.id,
|
|
13566
13672
|
...stepInfo,
|
|
@@ -13631,7 +13737,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
13631
13737
|
});
|
|
13632
13738
|
if (execResults.status === "suspended") {
|
|
13633
13739
|
await emitter.emit("watch-v2", {
|
|
13634
|
-
type: "step-suspended",
|
|
13740
|
+
type: "workflow-step-suspended",
|
|
13635
13741
|
payload: {
|
|
13636
13742
|
id: step.id,
|
|
13637
13743
|
...execResults
|
|
@@ -13639,14 +13745,14 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
13639
13745
|
});
|
|
13640
13746
|
} else {
|
|
13641
13747
|
await emitter.emit("watch-v2", {
|
|
13642
|
-
type: "step-result",
|
|
13748
|
+
type: "workflow-step-result",
|
|
13643
13749
|
payload: {
|
|
13644
13750
|
id: step.id,
|
|
13645
13751
|
...execResults
|
|
13646
13752
|
}
|
|
13647
13753
|
});
|
|
13648
13754
|
await emitter.emit("watch-v2", {
|
|
13649
|
-
type: "step-finish",
|
|
13755
|
+
type: "workflow-step-finish",
|
|
13650
13756
|
payload: {
|
|
13651
13757
|
id: step.id,
|
|
13652
13758
|
metadata: {}
|
|
@@ -13695,7 +13801,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
13695
13801
|
eventTimestamp: Date.now()
|
|
13696
13802
|
});
|
|
13697
13803
|
await emitter.emit("watch-v2", {
|
|
13698
|
-
type: "step-result",
|
|
13804
|
+
type: "workflow-step-result",
|
|
13699
13805
|
payload: {
|
|
13700
13806
|
id: step.id,
|
|
13701
13807
|
status: "success",
|
|
@@ -13704,7 +13810,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
13704
13810
|
}
|
|
13705
13811
|
});
|
|
13706
13812
|
await emitter.emit("watch-v2", {
|
|
13707
|
-
type: "step-finish",
|
|
13813
|
+
type: "workflow-step-finish",
|
|
13708
13814
|
payload: {
|
|
13709
13815
|
id: step.id,
|
|
13710
13816
|
metadata: {}
|
|
@@ -13977,7 +14083,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
13977
14083
|
eventTimestamp: Date.now()
|
|
13978
14084
|
});
|
|
13979
14085
|
await emitter.emit("watch-v2", {
|
|
13980
|
-
type: "step-waiting",
|
|
14086
|
+
type: "workflow-step-waiting",
|
|
13981
14087
|
payload: {
|
|
13982
14088
|
id: entry.id,
|
|
13983
14089
|
payload: prevOutput,
|
|
@@ -14057,7 +14163,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
14057
14163
|
eventTimestamp: Date.now()
|
|
14058
14164
|
});
|
|
14059
14165
|
await emitter.emit("watch-v2", {
|
|
14060
|
-
type: "step-result",
|
|
14166
|
+
type: "workflow-step-result",
|
|
14061
14167
|
payload: {
|
|
14062
14168
|
id: entry.id,
|
|
14063
14169
|
endedAt,
|
|
@@ -14066,7 +14172,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
14066
14172
|
}
|
|
14067
14173
|
});
|
|
14068
14174
|
await emitter.emit("watch-v2", {
|
|
14069
|
-
type: "step-finish",
|
|
14175
|
+
type: "workflow-step-finish",
|
|
14070
14176
|
payload: {
|
|
14071
14177
|
id: entry.id,
|
|
14072
14178
|
metadata: {}
|
|
@@ -14100,7 +14206,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
14100
14206
|
eventTimestamp: Date.now()
|
|
14101
14207
|
});
|
|
14102
14208
|
await emitter.emit("watch-v2", {
|
|
14103
|
-
type: "step-waiting",
|
|
14209
|
+
type: "workflow-step-waiting",
|
|
14104
14210
|
payload: {
|
|
14105
14211
|
id: entry.id,
|
|
14106
14212
|
payload: prevOutput,
|
|
@@ -14180,7 +14286,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
14180
14286
|
eventTimestamp: Date.now()
|
|
14181
14287
|
});
|
|
14182
14288
|
await emitter.emit("watch-v2", {
|
|
14183
|
-
type: "step-result",
|
|
14289
|
+
type: "workflow-step-result",
|
|
14184
14290
|
payload: {
|
|
14185
14291
|
id: entry.id,
|
|
14186
14292
|
endedAt,
|
|
@@ -14189,7 +14295,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
14189
14295
|
}
|
|
14190
14296
|
});
|
|
14191
14297
|
await emitter.emit("watch-v2", {
|
|
14192
|
-
type: "step-finish",
|
|
14298
|
+
type: "workflow-step-finish",
|
|
14193
14299
|
payload: {
|
|
14194
14300
|
id: entry.id,
|
|
14195
14301
|
metadata: {}
|
|
@@ -14224,7 +14330,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
14224
14330
|
eventTimestamp: Date.now()
|
|
14225
14331
|
});
|
|
14226
14332
|
await emitter.emit("watch-v2", {
|
|
14227
|
-
type: "step-waiting",
|
|
14333
|
+
type: "workflow-step-waiting",
|
|
14228
14334
|
payload: {
|
|
14229
14335
|
id: entry.step.id,
|
|
14230
14336
|
payload: prevOutput,
|
|
@@ -14348,8 +14454,8 @@ function createStep(params) {
|
|
|
14348
14454
|
args: inputData
|
|
14349
14455
|
};
|
|
14350
14456
|
await emitter.emit("watch-v2", {
|
|
14351
|
-
type: "
|
|
14352
|
-
|
|
14457
|
+
type: "workflow-agent-call-start",
|
|
14458
|
+
payload: toolData
|
|
14353
14459
|
});
|
|
14354
14460
|
const {
|
|
14355
14461
|
fullStream
|
|
@@ -14366,29 +14472,12 @@ function createStep(params) {
|
|
|
14366
14472
|
return abort();
|
|
14367
14473
|
}
|
|
14368
14474
|
for await (const chunk of fullStream) {
|
|
14369
|
-
|
|
14370
|
-
case "text-delta":
|
|
14371
|
-
await emitter.emit("watch-v2", {
|
|
14372
|
-
type: "tool-call-delta",
|
|
14373
|
-
...toolData,
|
|
14374
|
-
argsTextDelta: chunk.textDelta
|
|
14375
|
-
});
|
|
14376
|
-
break;
|
|
14377
|
-
case "step-start":
|
|
14378
|
-
case "step-finish":
|
|
14379
|
-
case "finish":
|
|
14380
|
-
break;
|
|
14381
|
-
case "tool-call":
|
|
14382
|
-
case "tool-result":
|
|
14383
|
-
case "tool-call-streaming-start":
|
|
14384
|
-
case "tool-call-delta":
|
|
14385
|
-
case "source":
|
|
14386
|
-
case "file":
|
|
14387
|
-
default:
|
|
14388
|
-
await emitter.emit("watch-v2", chunk);
|
|
14389
|
-
break;
|
|
14390
|
-
}
|
|
14475
|
+
await emitter.emit("watch-v2", chunk);
|
|
14391
14476
|
}
|
|
14477
|
+
await emitter.emit("watch-v2", {
|
|
14478
|
+
type: "workflow-agent-call-finish",
|
|
14479
|
+
payload: toolData
|
|
14480
|
+
});
|
|
14392
14481
|
return {
|
|
14393
14482
|
text: await streamPromise.promise
|
|
14394
14483
|
};
|
|
@@ -15337,15 +15426,43 @@ var Run = class {
|
|
|
15337
15426
|
readable,
|
|
15338
15427
|
writable
|
|
15339
15428
|
} = new TransformStream();
|
|
15429
|
+
let currentToolData = void 0;
|
|
15340
15430
|
const writer = writable.getWriter();
|
|
15341
15431
|
const unwatch = this.watch(async event => {
|
|
15432
|
+
if (event.type === "workflow-agent-call-start") {
|
|
15433
|
+
currentToolData = {
|
|
15434
|
+
name: event.payload.name,
|
|
15435
|
+
args: event.payload.args
|
|
15436
|
+
};
|
|
15437
|
+
await writer.write({
|
|
15438
|
+
...event.payload,
|
|
15439
|
+
type: "tool-call-streaming-start"
|
|
15440
|
+
});
|
|
15441
|
+
return;
|
|
15442
|
+
}
|
|
15342
15443
|
try {
|
|
15343
|
-
|
|
15444
|
+
if (event.type === "workflow-agent-call-finish") {
|
|
15445
|
+
return;
|
|
15446
|
+
} else if (!event.type.startsWith("workflow-")) {
|
|
15447
|
+
if (event.type === "text-delta") {
|
|
15448
|
+
await writer.write({
|
|
15449
|
+
type: "tool-call-delta",
|
|
15450
|
+
...(currentToolData ?? {}),
|
|
15451
|
+
argsTextDelta: event.textDelta
|
|
15452
|
+
});
|
|
15453
|
+
}
|
|
15454
|
+
return;
|
|
15455
|
+
}
|
|
15456
|
+
const e = {
|
|
15457
|
+
...event,
|
|
15458
|
+
type: event.type.replace("workflow-", "")
|
|
15459
|
+
};
|
|
15460
|
+
await writer.write(e);
|
|
15344
15461
|
} catch {}
|
|
15345
15462
|
}, "watch-v2");
|
|
15346
15463
|
this.closeStreamAction = async () => {
|
|
15347
15464
|
this.emitter.emit("watch-v2", {
|
|
15348
|
-
type: "finish",
|
|
15465
|
+
type: "workflow-finish",
|
|
15349
15466
|
payload: {
|
|
15350
15467
|
runId: this.runId
|
|
15351
15468
|
}
|
|
@@ -15360,7 +15477,7 @@ var Run = class {
|
|
|
15360
15477
|
}
|
|
15361
15478
|
};
|
|
15362
15479
|
this.emitter.emit("watch-v2", {
|
|
15363
|
-
type: "start",
|
|
15480
|
+
type: "workflow-start",
|
|
15364
15481
|
payload: {
|
|
15365
15482
|
runId: this.runId
|
|
15366
15483
|
}
|
|
@@ -15433,35 +15550,13 @@ var Run = class {
|
|
|
15433
15550
|
type,
|
|
15434
15551
|
payload
|
|
15435
15552
|
}) => {
|
|
15436
|
-
let newPayload = payload;
|
|
15437
|
-
if (type === "step-start") {
|
|
15438
|
-
const {
|
|
15439
|
-
payload: args,
|
|
15440
|
-
id,
|
|
15441
|
-
...rest
|
|
15442
|
-
} = newPayload;
|
|
15443
|
-
newPayload = {
|
|
15444
|
-
args,
|
|
15445
|
-
...rest
|
|
15446
|
-
};
|
|
15447
|
-
} else if (type === "step-result") {
|
|
15448
|
-
const {
|
|
15449
|
-
output,
|
|
15450
|
-
id,
|
|
15451
|
-
...rest
|
|
15452
|
-
} = newPayload;
|
|
15453
|
-
newPayload = {
|
|
15454
|
-
result: output,
|
|
15455
|
-
...rest
|
|
15456
|
-
};
|
|
15457
|
-
}
|
|
15458
15553
|
buffer.push({
|
|
15459
15554
|
type,
|
|
15460
15555
|
runId: this.runId,
|
|
15461
15556
|
from: "WORKFLOW" /* WORKFLOW */,
|
|
15462
15557
|
payload: {
|
|
15463
15558
|
stepName: payload.id,
|
|
15464
|
-
...
|
|
15559
|
+
...payload
|
|
15465
15560
|
}
|
|
15466
15561
|
});
|
|
15467
15562
|
await tryWrite();
|
|
@@ -15715,5 +15810,5 @@ function deepMergeWorkflowState(a, b) {
|
|
|
15715
15810
|
}
|
|
15716
15811
|
|
|
15717
15812
|
export { AISDKV5OutputStream, Agent, DefaultExecutionEngine, ExecutionEngine, LanguageDetector, LanguageDetectorInputProcessor, LegacyStep, LegacyWorkflow, MastraModelOutput, ModerationInputProcessor, ModerationProcessor, PIIDetector, PIIDetectorInputProcessor, PromptInjectionDetector, PromptInjectionDetectorInputProcessor, Run, StructuredOutputProcessor, TripWire, UnicodeNormalizer, UnicodeNormalizerInputProcessor, WhenConditionReturnValue, Workflow, agentToStep, cloneStep, cloneWorkflow, createStep, createWorkflow, getActivePathsAndStatus, getResultActivePaths, getStepResult, getSuspendedPaths, isAgent, isConditionalKey, isErrorEvent, isFinalState, isLimboState, isTransitionEvent, isVariableReference, isWorkflow, loop, mapVariable, mergeChildValue, recursivelyCheckForFinalState, resolveVariables, updateStepInHierarchy, workflowToStep };
|
|
15718
|
-
//# sourceMappingURL=chunk-
|
|
15719
|
-
//# sourceMappingURL=chunk-
|
|
15813
|
+
//# sourceMappingURL=chunk-P24PB73W.js.map
|
|
15814
|
+
//# sourceMappingURL=chunk-P24PB73W.js.map
|