@mastra/ai-sdk 1.0.0-beta.2 → 1.0.0-beta.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/CHANGELOG.md +102 -0
- package/dist/__tests__/__fixtures__/network.stream.d.ts +2329 -0
- package/dist/__tests__/__fixtures__/network.stream.d.ts.map +1 -0
- package/dist/convert-streams.d.ts +15 -1
- package/dist/convert-streams.d.ts.map +1 -1
- package/dist/helpers.d.ts +1 -1
- package/dist/helpers.d.ts.map +1 -1
- package/dist/index.cjs +194 -45
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +194 -45
- package/dist/index.js.map +1 -1
- package/dist/network-route.d.ts.map +1 -1
- package/dist/transformers.d.ts +12 -3
- package/dist/transformers.d.ts.map +1 -1
- package/dist/workflow-route.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -138,6 +138,28 @@ function convertMastraChunkToAISDKv5({
|
|
|
138
138
|
toolName: chunk.payload.toolName,
|
|
139
139
|
input: chunk.payload.args
|
|
140
140
|
};
|
|
141
|
+
case "tool-call-approval":
|
|
142
|
+
return {
|
|
143
|
+
type: "data-tool-call-approval",
|
|
144
|
+
id: chunk.payload.toolCallId,
|
|
145
|
+
data: {
|
|
146
|
+
runId: chunk.runId,
|
|
147
|
+
toolCallId: chunk.payload.toolCallId,
|
|
148
|
+
toolName: chunk.payload.toolName,
|
|
149
|
+
args: chunk.payload.args
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
case "tool-call-suspended":
|
|
153
|
+
return {
|
|
154
|
+
type: "data-tool-call-suspended",
|
|
155
|
+
id: chunk.payload.toolCallId,
|
|
156
|
+
data: {
|
|
157
|
+
runId: chunk.runId,
|
|
158
|
+
toolCallId: chunk.payload.toolCallId,
|
|
159
|
+
toolName: chunk.payload.toolName,
|
|
160
|
+
suspendPayload: chunk.payload.suspendPayload
|
|
161
|
+
}
|
|
162
|
+
};
|
|
141
163
|
case "tool-call-input-streaming-start":
|
|
142
164
|
return {
|
|
143
165
|
type: "tool-input-start",
|
|
@@ -228,6 +250,13 @@ function convertMastraChunkToAISDKv5({
|
|
|
228
250
|
type: "object",
|
|
229
251
|
object: chunk.object
|
|
230
252
|
};
|
|
253
|
+
case "tripwire":
|
|
254
|
+
return {
|
|
255
|
+
type: "data-tripwire",
|
|
256
|
+
data: {
|
|
257
|
+
tripwireReason: chunk.payload.tripwireReason
|
|
258
|
+
}
|
|
259
|
+
};
|
|
231
260
|
default:
|
|
232
261
|
if (chunk.type && "payload" in chunk && chunk.payload) {
|
|
233
262
|
return {
|
|
@@ -460,6 +489,7 @@ function convertFullStreamChunkToUIMessageStream({
|
|
|
460
489
|
}
|
|
461
490
|
|
|
462
491
|
// src/transformers.ts
|
|
492
|
+
var PRIMITIVE_CACHE_SYMBOL = Symbol("primitive-cache");
|
|
463
493
|
function WorkflowStreamToAISDKTransformer() {
|
|
464
494
|
const bufferedWorkflows = /* @__PURE__ */ new Map();
|
|
465
495
|
return new TransformStream({
|
|
@@ -503,21 +533,32 @@ function AgentStreamToAISDKTransformer({
|
|
|
503
533
|
sendStart,
|
|
504
534
|
sendFinish,
|
|
505
535
|
sendReasoning,
|
|
506
|
-
sendSources
|
|
536
|
+
sendSources,
|
|
537
|
+
messageMetadata,
|
|
538
|
+
onError
|
|
507
539
|
}) {
|
|
508
540
|
let bufferedSteps = /* @__PURE__ */ new Map();
|
|
541
|
+
let tripwireOccurred = false;
|
|
542
|
+
let finishEventSent = false;
|
|
509
543
|
return new TransformStream({
|
|
510
544
|
transform(chunk, controller) {
|
|
545
|
+
if (chunk.type === "tripwire") {
|
|
546
|
+
tripwireOccurred = true;
|
|
547
|
+
}
|
|
548
|
+
if (chunk.type === "finish") {
|
|
549
|
+
finishEventSent = true;
|
|
550
|
+
}
|
|
511
551
|
const part = convertMastraChunkToAISDKv5({ chunk, mode: "stream" });
|
|
512
552
|
const transformedChunk = convertFullStreamChunkToUIMessageStream({
|
|
513
553
|
part,
|
|
514
554
|
sendReasoning,
|
|
515
555
|
sendSources,
|
|
556
|
+
messageMetadataValue: messageMetadata?.({ part }),
|
|
516
557
|
sendStart,
|
|
517
558
|
sendFinish,
|
|
518
559
|
responseMessageId: lastMessageId,
|
|
519
560
|
onError(error) {
|
|
520
|
-
return safeParseErrorObject(error);
|
|
561
|
+
return onError ? onError(error) : safeParseErrorObject(error);
|
|
521
562
|
}
|
|
522
563
|
});
|
|
523
564
|
if (transformedChunk) {
|
|
@@ -537,6 +578,14 @@ function AgentStreamToAISDKTransformer({
|
|
|
537
578
|
controller.enqueue(transformedChunk);
|
|
538
579
|
}
|
|
539
580
|
}
|
|
581
|
+
},
|
|
582
|
+
flush(controller) {
|
|
583
|
+
if (tripwireOccurred && !finishEventSent && sendFinish) {
|
|
584
|
+
controller.enqueue({
|
|
585
|
+
type: "finish",
|
|
586
|
+
finishReason: "other"
|
|
587
|
+
});
|
|
588
|
+
}
|
|
540
589
|
}
|
|
541
590
|
});
|
|
542
591
|
}
|
|
@@ -769,6 +818,19 @@ function transformWorkflow(payload, bufferedWorkflows, isNested) {
|
|
|
769
818
|
}
|
|
770
819
|
};
|
|
771
820
|
}
|
|
821
|
+
case "workflow-step-output": {
|
|
822
|
+
const output = payload.payload.output;
|
|
823
|
+
if (output && isDataChunkType(output)) {
|
|
824
|
+
if (!("data" in output)) {
|
|
825
|
+
throw new Error(
|
|
826
|
+
`UI Messages require a data property when using data- prefixed chunks
|
|
827
|
+
${JSON.stringify(output)}`
|
|
828
|
+
);
|
|
829
|
+
}
|
|
830
|
+
return output;
|
|
831
|
+
}
|
|
832
|
+
return null;
|
|
833
|
+
}
|
|
772
834
|
default: {
|
|
773
835
|
if (isDataChunkType(payload)) {
|
|
774
836
|
if (!("data" in payload)) {
|
|
@@ -788,12 +850,29 @@ function transformNetwork(payload, bufferedNetworks, isNested) {
|
|
|
788
850
|
case "routing-agent-start": {
|
|
789
851
|
if (!bufferedNetworks.has(payload.runId)) {
|
|
790
852
|
bufferedNetworks.set(payload.runId, {
|
|
791
|
-
name: payload.payload.
|
|
853
|
+
name: payload.payload.networkId,
|
|
792
854
|
steps: [],
|
|
793
855
|
usage: null,
|
|
794
856
|
output: null
|
|
795
857
|
});
|
|
796
858
|
}
|
|
859
|
+
const current = bufferedNetworks.get(payload.runId);
|
|
860
|
+
current.steps.push({
|
|
861
|
+
id: payload.payload.runId,
|
|
862
|
+
name: payload.payload.agentId,
|
|
863
|
+
status: "running",
|
|
864
|
+
iteration: payload.payload.inputData.iteration,
|
|
865
|
+
input: {
|
|
866
|
+
task: payload.payload.inputData.task,
|
|
867
|
+
threadId: payload.payload.inputData.threadId,
|
|
868
|
+
threadResourceId: payload.payload.inputData.threadResourceId
|
|
869
|
+
},
|
|
870
|
+
output: "",
|
|
871
|
+
task: null,
|
|
872
|
+
suspendPayload: null,
|
|
873
|
+
resumePayload: null,
|
|
874
|
+
[PRIMITIVE_CACHE_SYMBOL]: /* @__PURE__ */ new Map()
|
|
875
|
+
});
|
|
797
876
|
return {
|
|
798
877
|
type: isNested ? "data-tool-network" : "data-network",
|
|
799
878
|
id: payload.runId,
|
|
@@ -824,14 +903,19 @@ function transformNetwork(payload, bufferedNetworks, isNested) {
|
|
|
824
903
|
};
|
|
825
904
|
}
|
|
826
905
|
case "agent-execution-start": {
|
|
827
|
-
const current = bufferedNetworks.get(payload.runId)
|
|
906
|
+
const current = bufferedNetworks.get(payload.runId);
|
|
907
|
+
if (!current) return null;
|
|
828
908
|
current.steps.push({
|
|
909
|
+
id: payload.payload.runId,
|
|
829
910
|
name: payload.payload.agentId,
|
|
830
911
|
status: "running",
|
|
831
|
-
|
|
912
|
+
iteration: payload.payload.args?.iteration ?? 0,
|
|
913
|
+
input: { prompt: payload.payload.args?.prompt ?? "" },
|
|
832
914
|
output: null,
|
|
915
|
+
task: null,
|
|
833
916
|
suspendPayload: null,
|
|
834
|
-
resumePayload: null
|
|
917
|
+
resumePayload: null,
|
|
918
|
+
[PRIMITIVE_CACHE_SYMBOL]: /* @__PURE__ */ new Map()
|
|
835
919
|
});
|
|
836
920
|
bufferedNetworks.set(payload.runId, current);
|
|
837
921
|
return {
|
|
@@ -844,14 +928,19 @@ function transformNetwork(payload, bufferedNetworks, isNested) {
|
|
|
844
928
|
};
|
|
845
929
|
}
|
|
846
930
|
case "workflow-execution-start": {
|
|
847
|
-
const current = bufferedNetworks.get(payload.runId)
|
|
931
|
+
const current = bufferedNetworks.get(payload.runId);
|
|
932
|
+
if (!current) return null;
|
|
848
933
|
current.steps.push({
|
|
849
|
-
|
|
934
|
+
id: payload.payload.runId,
|
|
935
|
+
name: payload.payload.workflowId,
|
|
850
936
|
status: "running",
|
|
851
|
-
|
|
937
|
+
iteration: payload.payload.args?.iteration ?? 0,
|
|
938
|
+
input: { prompt: payload.payload.args?.prompt ?? "" },
|
|
852
939
|
output: null,
|
|
940
|
+
task: null,
|
|
853
941
|
suspendPayload: null,
|
|
854
|
-
resumePayload: null
|
|
942
|
+
resumePayload: null,
|
|
943
|
+
[PRIMITIVE_CACHE_SYMBOL]: /* @__PURE__ */ new Map()
|
|
855
944
|
});
|
|
856
945
|
bufferedNetworks.set(payload.runId, current);
|
|
857
946
|
return {
|
|
@@ -864,14 +953,21 @@ function transformNetwork(payload, bufferedNetworks, isNested) {
|
|
|
864
953
|
};
|
|
865
954
|
}
|
|
866
955
|
case "tool-execution-start": {
|
|
867
|
-
const current = bufferedNetworks.get(payload.runId)
|
|
956
|
+
const current = bufferedNetworks.get(payload.runId);
|
|
957
|
+
if (!current) return null;
|
|
868
958
|
current.steps.push({
|
|
959
|
+
id: payload.payload.args.toolCallId,
|
|
869
960
|
name: payload.payload.args?.toolName,
|
|
870
961
|
status: "running",
|
|
962
|
+
iteration: payload.payload.args?.iteration ? Number(payload.payload.args.iteration) : 0,
|
|
963
|
+
task: {
|
|
964
|
+
id: payload.payload.args?.toolName
|
|
965
|
+
},
|
|
871
966
|
input: payload.payload.args?.args || null,
|
|
872
967
|
output: null,
|
|
873
968
|
suspendPayload: null,
|
|
874
|
-
resumePayload: null
|
|
969
|
+
resumePayload: null,
|
|
970
|
+
[PRIMITIVE_CACHE_SYMBOL]: /* @__PURE__ */ new Map()
|
|
875
971
|
});
|
|
876
972
|
bufferedNetworks.set(payload.runId, current);
|
|
877
973
|
return {
|
|
@@ -886,14 +982,13 @@ function transformNetwork(payload, bufferedNetworks, isNested) {
|
|
|
886
982
|
case "agent-execution-end": {
|
|
887
983
|
const current = bufferedNetworks.get(payload.runId);
|
|
888
984
|
if (!current) return null;
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
});
|
|
985
|
+
const stepId = payload.payload.runId;
|
|
986
|
+
const step = current.steps.find((step2) => step2.id === stepId);
|
|
987
|
+
if (!step) {
|
|
988
|
+
return null;
|
|
989
|
+
}
|
|
990
|
+
step.status = "success";
|
|
991
|
+
step.output = payload.payload.result;
|
|
897
992
|
return {
|
|
898
993
|
type: isNested ? "data-tool-network" : "data-network",
|
|
899
994
|
id: payload.runId,
|
|
@@ -908,14 +1003,13 @@ function transformNetwork(payload, bufferedNetworks, isNested) {
|
|
|
908
1003
|
case "tool-execution-end": {
|
|
909
1004
|
const current = bufferedNetworks.get(payload.runId);
|
|
910
1005
|
if (!current) return null;
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
});
|
|
1006
|
+
const stepId = payload.payload.toolCallId;
|
|
1007
|
+
const step = current.steps.find((step2) => step2.id === stepId);
|
|
1008
|
+
if (!step) {
|
|
1009
|
+
return null;
|
|
1010
|
+
}
|
|
1011
|
+
step.status = "success";
|
|
1012
|
+
step.output = payload.payload.result;
|
|
919
1013
|
return {
|
|
920
1014
|
type: isNested ? "data-tool-network" : "data-network",
|
|
921
1015
|
id: payload.runId,
|
|
@@ -929,14 +1023,13 @@ function transformNetwork(payload, bufferedNetworks, isNested) {
|
|
|
929
1023
|
case "workflow-execution-end": {
|
|
930
1024
|
const current = bufferedNetworks.get(payload.runId);
|
|
931
1025
|
if (!current) return null;
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
});
|
|
1026
|
+
const stepId = payload.payload.runId;
|
|
1027
|
+
const step = current.steps.find((step2) => step2.id === stepId);
|
|
1028
|
+
if (!step) {
|
|
1029
|
+
return null;
|
|
1030
|
+
}
|
|
1031
|
+
step.status = "success";
|
|
1032
|
+
step.output = payload.payload.result;
|
|
940
1033
|
return {
|
|
941
1034
|
type: isNested ? "data-tool-network" : "data-network",
|
|
942
1035
|
id: payload.runId,
|
|
@@ -951,12 +1044,24 @@ function transformNetwork(payload, bufferedNetworks, isNested) {
|
|
|
951
1044
|
case "routing-agent-end": {
|
|
952
1045
|
const current = bufferedNetworks.get(payload.runId);
|
|
953
1046
|
if (!current) return null;
|
|
1047
|
+
const stepId = payload.payload.runId;
|
|
1048
|
+
const step = current.steps.find((step2) => step2.id === stepId);
|
|
1049
|
+
if (!step) {
|
|
1050
|
+
return null;
|
|
1051
|
+
}
|
|
1052
|
+
step.status = "success";
|
|
1053
|
+
step.task = {
|
|
1054
|
+
id: payload.payload.primitiveId,
|
|
1055
|
+
type: payload.payload.primitiveType,
|
|
1056
|
+
name: payload.payload.task,
|
|
1057
|
+
reason: payload.payload.selectionReason
|
|
1058
|
+
};
|
|
1059
|
+
step.output = payload.payload.result;
|
|
954
1060
|
return {
|
|
955
1061
|
type: isNested ? "data-tool-network" : "data-network",
|
|
956
1062
|
id: payload.runId,
|
|
957
1063
|
data: {
|
|
958
1064
|
...current,
|
|
959
|
-
status: "finished",
|
|
960
1065
|
usage: payload.payload?.usage ?? current.usage,
|
|
961
1066
|
output: payload.payload?.result ?? current.output
|
|
962
1067
|
}
|
|
@@ -990,6 +1095,39 @@ function transformNetwork(payload, bufferedNetworks, isNested) {
|
|
|
990
1095
|
};
|
|
991
1096
|
}
|
|
992
1097
|
default: {
|
|
1098
|
+
if (payload.type.startsWith("agent-execution-event-")) {
|
|
1099
|
+
const stepId = payload.payload.runId;
|
|
1100
|
+
const current = bufferedNetworks.get(payload.runId);
|
|
1101
|
+
if (!current) return null;
|
|
1102
|
+
const step = current.steps.find((step2) => step2.id === stepId);
|
|
1103
|
+
if (!step) {
|
|
1104
|
+
return null;
|
|
1105
|
+
}
|
|
1106
|
+
step[PRIMITIVE_CACHE_SYMBOL] = step[PRIMITIVE_CACHE_SYMBOL] || /* @__PURE__ */ new Map();
|
|
1107
|
+
const result = transformAgent(payload.payload, step[PRIMITIVE_CACHE_SYMBOL]);
|
|
1108
|
+
if (result) {
|
|
1109
|
+
const { request, response, ...data } = result.data;
|
|
1110
|
+
step.task = data;
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
if (payload.type.startsWith("workflow-execution-event-")) {
|
|
1114
|
+
const stepId = payload.payload.runId;
|
|
1115
|
+
const current = bufferedNetworks.get(payload.runId);
|
|
1116
|
+
if (!current) return null;
|
|
1117
|
+
const step = current.steps.find((step2) => step2.id === stepId);
|
|
1118
|
+
if (!step) {
|
|
1119
|
+
return null;
|
|
1120
|
+
}
|
|
1121
|
+
step[PRIMITIVE_CACHE_SYMBOL] = step[PRIMITIVE_CACHE_SYMBOL] || /* @__PURE__ */ new Map();
|
|
1122
|
+
const result = transformWorkflow(payload.payload, step[PRIMITIVE_CACHE_SYMBOL]);
|
|
1123
|
+
if (result) {
|
|
1124
|
+
const data = result.data;
|
|
1125
|
+
step.task = data;
|
|
1126
|
+
if (data.name && step.task) {
|
|
1127
|
+
step.task.id = data.name;
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
993
1131
|
if (isDataChunkType(payload)) {
|
|
994
1132
|
if (!("data" in payload)) {
|
|
995
1133
|
throw new Error(
|
|
@@ -997,7 +1135,8 @@ function transformNetwork(payload, bufferedNetworks, isNested) {
|
|
|
997
1135
|
${JSON.stringify(payload)}`
|
|
998
1136
|
);
|
|
999
1137
|
}
|
|
1000
|
-
|
|
1138
|
+
const { type, data } = payload;
|
|
1139
|
+
return { type, data };
|
|
1001
1140
|
}
|
|
1002
1141
|
if (isAgentExecutionDataChunkType(payload)) {
|
|
1003
1142
|
if (!("data" in payload.payload)) {
|
|
@@ -1006,7 +1145,8 @@ function transformNetwork(payload, bufferedNetworks, isNested) {
|
|
|
1006
1145
|
${JSON.stringify(payload)}`
|
|
1007
1146
|
);
|
|
1008
1147
|
}
|
|
1009
|
-
|
|
1148
|
+
const { type, data } = payload.payload;
|
|
1149
|
+
return { type, data };
|
|
1010
1150
|
}
|
|
1011
1151
|
if (isWorkflowExecutionDataChunkType(payload)) {
|
|
1012
1152
|
if (!("data" in payload.payload)) {
|
|
@@ -1015,7 +1155,8 @@ function transformNetwork(payload, bufferedNetworks, isNested) {
|
|
|
1015
1155
|
${JSON.stringify(payload)}`
|
|
1016
1156
|
);
|
|
1017
1157
|
}
|
|
1018
|
-
|
|
1158
|
+
const { type, data } = payload.payload;
|
|
1159
|
+
return { type, data };
|
|
1019
1160
|
}
|
|
1020
1161
|
return null;
|
|
1021
1162
|
}
|
|
@@ -1042,7 +1183,9 @@ function toAISdkV5Stream(stream, options = {
|
|
|
1042
1183
|
sendStart: options?.sendStart,
|
|
1043
1184
|
sendFinish: options?.sendFinish,
|
|
1044
1185
|
sendReasoning: options?.sendReasoning,
|
|
1045
|
-
sendSources: options?.sendSources
|
|
1186
|
+
sendSources: options?.sendSources,
|
|
1187
|
+
messageMetadata: options?.messageMetadata,
|
|
1188
|
+
onError: options?.onError
|
|
1046
1189
|
})
|
|
1047
1190
|
);
|
|
1048
1191
|
}
|
|
@@ -1173,7 +1316,7 @@ function chatRoute({
|
|
|
1173
1316
|
if (!agentToUse) {
|
|
1174
1317
|
throw new Error("Agent ID is required");
|
|
1175
1318
|
}
|
|
1176
|
-
const agentObj = mastra.
|
|
1319
|
+
const agentObj = mastra.getAgentById(agentToUse);
|
|
1177
1320
|
if (!agentObj) {
|
|
1178
1321
|
throw new Error(`Agent ${agentToUse} not found`);
|
|
1179
1322
|
}
|
|
@@ -1262,6 +1405,7 @@ function workflowRoute({
|
|
|
1262
1405
|
handler: async (c) => {
|
|
1263
1406
|
const { runId, resourceId, inputData, resumeData, ...rest } = await c.req.json();
|
|
1264
1407
|
const mastra = c.get("mastra");
|
|
1408
|
+
const requestContext = c.get("requestContext");
|
|
1265
1409
|
let workflowToUse = workflow;
|
|
1266
1410
|
if (!workflow) {
|
|
1267
1411
|
const workflowId = c.req.param("workflowId");
|
|
@@ -1275,12 +1419,17 @@ function workflowRoute({
|
|
|
1275
1419
|
if (!workflowToUse) {
|
|
1276
1420
|
throw new Error("Workflow ID is required");
|
|
1277
1421
|
}
|
|
1278
|
-
const workflowObj = mastra.
|
|
1422
|
+
const workflowObj = mastra.getWorkflowById(workflowToUse);
|
|
1279
1423
|
if (!workflowObj) {
|
|
1280
1424
|
throw new Error(`Workflow ${workflowToUse} not found`);
|
|
1281
1425
|
}
|
|
1426
|
+
if (requestContext && rest.requestContext) {
|
|
1427
|
+
mastra.getLogger()?.warn(
|
|
1428
|
+
`"requestContext" from the request body will be ignored because "requestContext" is already set in the route options.`
|
|
1429
|
+
);
|
|
1430
|
+
}
|
|
1282
1431
|
const run = await workflowObj.createRun({ runId, resourceId, ...rest });
|
|
1283
|
-
const stream = resumeData ? run.resumeStream({ resumeData, ...rest }) : run.stream({ inputData, ...rest });
|
|
1432
|
+
const stream = resumeData ? run.resumeStream({ resumeData, ...rest, requestContext: requestContext || rest.requestContext }) : run.stream({ inputData, ...rest, requestContext: requestContext || rest.requestContext });
|
|
1284
1433
|
const uiMessageStream = createUIMessageStream({
|
|
1285
1434
|
execute: async ({ writer }) => {
|
|
1286
1435
|
for await (const part of toAISdkV5Stream(stream, { from: "workflow" })) {
|
|
@@ -1367,7 +1516,7 @@ function networkRoute({
|
|
|
1367
1516
|
if (!agentToUse) {
|
|
1368
1517
|
throw new Error("Agent ID is required");
|
|
1369
1518
|
}
|
|
1370
|
-
const agentObj = mastra.
|
|
1519
|
+
const agentObj = mastra.getAgentById(agentToUse);
|
|
1371
1520
|
if (!agentObj) {
|
|
1372
1521
|
throw new Error(`Agent ${agentToUse} not found`);
|
|
1373
1522
|
}
|