@mastra/react 1.5.1-alpha.0 → 1.5.1-alpha.1
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 +15 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -3
- 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.js
CHANGED
|
@@ -128,6 +128,18 @@ const formatStreamCompletionFeedback = (result, maxIterationReached) => {
|
|
|
128
128
|
const CLIENT_MESSAGE_ID_KEY = "clientMessageId";
|
|
129
129
|
//#endregion
|
|
130
130
|
//#region src/lib/mastra-db/accumulator.ts
|
|
131
|
+
function toolErrorText(error) {
|
|
132
|
+
if (error && typeof error === "object") {
|
|
133
|
+
if ("message" in error && typeof error.message === "string") return error.message;
|
|
134
|
+
if ("cause" in error) {
|
|
135
|
+
const cause = error.cause;
|
|
136
|
+
if (cause && typeof cause === "object") {
|
|
137
|
+
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;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return String(error);
|
|
142
|
+
}
|
|
131
143
|
const cloneMetadata = (metadata) => metadata ? { ...metadata } : {};
|
|
132
144
|
const withParts = (message, parts) => ({
|
|
133
145
|
...message,
|
|
@@ -807,8 +819,7 @@ const accumulateChunk = ({ chunk, conversation, metadata }) => {
|
|
|
807
819
|
const { toolName, toolCallId, args } = toolPart.toolInvocation;
|
|
808
820
|
const providerMeta = payloadProviderMetadata ?? toolPart.providerMetadata;
|
|
809
821
|
if (chunk.type === "tool-error" || chunk.type === "background-task-failed" || payloadIsError) {
|
|
810
|
-
const
|
|
811
|
-
const errorText = typeof error === "string" ? error : error instanceof Error ? error.message : error?.message ?? String(error);
|
|
822
|
+
const errorText = toolErrorText(chunk.type === "tool-error" || chunk.type === "background-task-failed" ? payloadError : payloadResult);
|
|
812
823
|
parts[toolPartIndex] = {
|
|
813
824
|
...toolPart,
|
|
814
825
|
providerMetadata: providerMeta,
|
|
@@ -817,7 +828,8 @@ const accumulateChunk = ({ chunk, conversation, metadata }) => {
|
|
|
817
828
|
toolCallId,
|
|
818
829
|
toolName,
|
|
819
830
|
args,
|
|
820
|
-
errorText
|
|
831
|
+
errorText,
|
|
832
|
+
...toolName?.startsWith("agent-") ? { result: toolPart.toolInvocation.result } : {}
|
|
821
833
|
}
|
|
822
834
|
};
|
|
823
835
|
} else {
|