@mastra/react 1.5.1-alpha.0 → 1.5.1-alpha.2
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/index.cjs +16 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +16 -4
- package/dist/index.js.map +1 -1
- package/dist/lib/mastra-db/accumulator.d.ts.map +1 -1
- package/dist/ui/MessageFactory/types.d.ts +1 -0
- package/dist/ui/MessageFactory/types.d.ts.map +1 -1
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -129,6 +129,18 @@ const formatStreamCompletionFeedback = (result, maxIterationReached) => {
|
|
|
129
129
|
const CLIENT_MESSAGE_ID_KEY = "clientMessageId";
|
|
130
130
|
//#endregion
|
|
131
131
|
//#region src/lib/mastra-db/accumulator.ts
|
|
132
|
+
function toolErrorText(error) {
|
|
133
|
+
if (error && typeof error === "object") {
|
|
134
|
+
if ("message" in error && typeof error.message === "string") return error.message;
|
|
135
|
+
if ("cause" in error) {
|
|
136
|
+
const cause = error.cause;
|
|
137
|
+
if (cause && typeof cause === "object") {
|
|
138
|
+
if (("id" in cause ? cause.id : "code" in cause ? cause.code : void 0) === "AGENT_AGENT_TOOL_EXECUTION_FAILED" && "message" in cause && typeof cause.message === "string") return cause.message;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return String(error);
|
|
143
|
+
}
|
|
132
144
|
const cloneMetadata = (metadata) => metadata ? { ...metadata } : {};
|
|
133
145
|
const withParts = (message, parts) => ({
|
|
134
146
|
...message,
|
|
@@ -808,8 +820,7 @@ const accumulateChunk = ({ chunk, conversation, metadata }) => {
|
|
|
808
820
|
const { toolName, toolCallId, args } = toolPart.toolInvocation;
|
|
809
821
|
const providerMeta = payloadProviderMetadata ?? toolPart.providerMetadata;
|
|
810
822
|
if (chunk.type === "tool-error" || chunk.type === "background-task-failed" || payloadIsError) {
|
|
811
|
-
const
|
|
812
|
-
const errorText = typeof error === "string" ? error : error instanceof Error ? error.message : error?.message ?? String(error);
|
|
823
|
+
const errorText = toolErrorText(chunk.type === "tool-error" || chunk.type === "background-task-failed" ? payloadError : payloadResult);
|
|
813
824
|
parts[toolPartIndex] = {
|
|
814
825
|
...toolPart,
|
|
815
826
|
providerMetadata: providerMeta,
|
|
@@ -818,7 +829,8 @@ const accumulateChunk = ({ chunk, conversation, metadata }) => {
|
|
|
818
829
|
toolCallId,
|
|
819
830
|
toolName,
|
|
820
831
|
args,
|
|
821
|
-
errorText
|
|
832
|
+
errorText,
|
|
833
|
+
...toolName?.startsWith("agent-") ? { result: toolPart.toolInvocation.result } : {}
|
|
822
834
|
}
|
|
823
835
|
};
|
|
824
836
|
} else {
|
|
@@ -1007,7 +1019,7 @@ const accumulateChunk = ({ chunk, conversation, metadata }) => {
|
|
|
1007
1019
|
mode: "stream",
|
|
1008
1020
|
requireApprovalMetadata: {
|
|
1009
1021
|
...lastRequireApproval,
|
|
1010
|
-
[chunk.payload.
|
|
1022
|
+
[chunk.payload.toolCallId]: {
|
|
1011
1023
|
toolCallId: chunk.payload.toolCallId,
|
|
1012
1024
|
toolName: chunk.payload.toolName,
|
|
1013
1025
|
args: chunk.payload.args
|