@mastra/react 1.7.0 → 1.7.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/agent/hooks.d.ts.map +1 -1
- package/dist/index.cjs +32 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +32 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/mastra-db/accumulator.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -297,7 +297,7 @@ const mergeBgTaskMetadata = (existing, mode, args, otherMetadata) => {
|
|
|
297
297
|
* `mapWorkflowStreamChunkToWatchResult` from the previous accumulator.
|
|
298
298
|
*/
|
|
299
299
|
const mapWorkflowStreamChunkToWatchResult = (prev, chunk) => {
|
|
300
|
-
const previous = prev
|
|
300
|
+
const previous = prev && typeof prev === "object" && prev.steps && typeof prev.steps === "object" ? prev : {
|
|
301
301
|
status: "running",
|
|
302
302
|
input: void 0,
|
|
303
303
|
steps: {}
|
|
@@ -1124,6 +1124,29 @@ const accumulateChunk = ({ chunk, conversation, metadata }) => {
|
|
|
1124
1124
|
} });
|
|
1125
1125
|
return replaceAt(result, messageIndex, withMetadata(targetMessage, nextMetadata));
|
|
1126
1126
|
}
|
|
1127
|
+
case "tool-call-resumed": {
|
|
1128
|
+
const resumedToolCallId = chunk.payload.toolCallId;
|
|
1129
|
+
for (let i = result.length - 1; i >= 0; i--) {
|
|
1130
|
+
const message = result[i];
|
|
1131
|
+
if (!message || message.role !== "assistant") continue;
|
|
1132
|
+
const meta = message.content.metadata;
|
|
1133
|
+
const metadataKeys = chunk.payload.kind === "approval" ? ["pendingToolApprovals", "requireApprovalMetadata"] : ["suspendedTools"];
|
|
1134
|
+
let nextMeta;
|
|
1135
|
+
for (const metadataKey of metadataKeys) {
|
|
1136
|
+
const entries = meta?.[metadataKey];
|
|
1137
|
+
if (!entries) continue;
|
|
1138
|
+
const key = Object.keys(entries).find((k) => (entries[k]?.toolCallId ?? k) === resumedToolCallId);
|
|
1139
|
+
if (!key) continue;
|
|
1140
|
+
const { [key]: _removed, ...remaining } = entries;
|
|
1141
|
+
nextMeta = {
|
|
1142
|
+
...nextMeta ?? meta,
|
|
1143
|
+
[metadataKey]: remaining
|
|
1144
|
+
};
|
|
1145
|
+
}
|
|
1146
|
+
if (nextMeta) return replaceAt(result, i, withMetadata(message, nextMeta));
|
|
1147
|
+
}
|
|
1148
|
+
return result;
|
|
1149
|
+
}
|
|
1127
1150
|
case "finish":
|
|
1128
1151
|
case "abort": return finishStreamingAssistantMessage(result);
|
|
1129
1152
|
case "error": {
|
|
@@ -2217,6 +2240,14 @@ const useChat = ({ agentId, resourceId, threadId, initialMessages, requestContex
|
|
|
2217
2240
|
}
|
|
2218
2241
|
setIsRunning(false);
|
|
2219
2242
|
}
|
|
2243
|
+
if (chunk.type === "tool-call-resumed") {
|
|
2244
|
+
const toolCallId = chunk.payload?.toolCallId;
|
|
2245
|
+
if (typeof toolCallId === "string") {
|
|
2246
|
+
liveApprovalIds.current.add(toolCallId);
|
|
2247
|
+
pendingToolApprovalIdsRef.current.delete(toolCallId);
|
|
2248
|
+
setIsAwaitingToolApproval(pendingToolApprovalIdsRef.current.size > 0);
|
|
2249
|
+
}
|
|
2250
|
+
}
|
|
2220
2251
|
if (isTerminal) {
|
|
2221
2252
|
if (chunk.runId === liveRunId.current) liveRunFinished.current = true;
|
|
2222
2253
|
for (const toolCallId of pendingToolApprovalIdsRef.current) liveApprovalIds.current.add(toolCallId);
|