@mastra/react 1.4.2-alpha.0 → 1.4.2-alpha.12
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/index.cjs +28 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +28 -4
- 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
|
@@ -737,6 +737,27 @@ const accumulateChunk = ({ chunk, conversation, metadata }) => {
|
|
|
737
737
|
};
|
|
738
738
|
return replaceAt(result, messageIndex, withParts(targetMessage, parts));
|
|
739
739
|
}
|
|
740
|
+
case "tool-output-denied": {
|
|
741
|
+
const location = locateToolPart(result, chunk.payload.toolCallId, false);
|
|
742
|
+
if (!location || location.toolPartIndex < 0) return result;
|
|
743
|
+
const { messageIndex, toolPartIndex } = location;
|
|
744
|
+
const targetMessage = result[messageIndex];
|
|
745
|
+
if (!targetMessage || targetMessage.role !== "assistant") return result;
|
|
746
|
+
const parts = [...targetMessage.content.parts];
|
|
747
|
+
const toolPart = parts[toolPartIndex];
|
|
748
|
+
if (!isToolPart(toolPart)) return result;
|
|
749
|
+
parts[toolPartIndex] = {
|
|
750
|
+
...toolPart,
|
|
751
|
+
toolInvocation: {
|
|
752
|
+
...toolPart.toolInvocation,
|
|
753
|
+
state: "output-denied",
|
|
754
|
+
toolName: chunk.payload.toolName,
|
|
755
|
+
args: chunk.payload.args ?? toolPart.toolInvocation.args,
|
|
756
|
+
approval: chunk.payload.approval
|
|
757
|
+
}
|
|
758
|
+
};
|
|
759
|
+
return replaceAt(result, messageIndex, withParts(targetMessage, parts));
|
|
760
|
+
}
|
|
740
761
|
case "tool-error":
|
|
741
762
|
case "tool-result":
|
|
742
763
|
case "background-task-completed":
|
|
@@ -1107,7 +1128,8 @@ const accumulateChunk = ({ chunk, conversation, metadata }) => {
|
|
|
1107
1128
|
case "network-validation-start":
|
|
1108
1129
|
case "network-validation-end":
|
|
1109
1130
|
case "network-object":
|
|
1110
|
-
case "network-object-result":
|
|
1131
|
+
case "network-object-result":
|
|
1132
|
+
case "tool-output-denied": return result;
|
|
1111
1133
|
default: return assertExhaustive(chunk, result);
|
|
1112
1134
|
}
|
|
1113
1135
|
};
|
|
@@ -3212,6 +3234,7 @@ const useMastraSpeechToText = ({ agent, language }) => {
|
|
|
3212
3234
|
const start = () => {
|
|
3213
3235
|
if (!agent || startInFlightRef.current || recorderRef.current) return;
|
|
3214
3236
|
startInFlightRef.current = true;
|
|
3237
|
+
sessionRef.current += 1;
|
|
3215
3238
|
const session = sessionRef.current;
|
|
3216
3239
|
recordMicrophoneToFile(handleFinish(session)).then((recorder) => {
|
|
3217
3240
|
startInFlightRef.current = false;
|
|
@@ -3240,10 +3263,11 @@ const useMastraSpeechToText = ({ agent, language }) => {
|
|
|
3240
3263
|
});
|
|
3241
3264
|
};
|
|
3242
3265
|
const stop = () => {
|
|
3243
|
-
|
|
3266
|
+
if (recorderRef.current) {
|
|
3267
|
+
recorderRef.current.stop();
|
|
3268
|
+
recorderRef.current = null;
|
|
3269
|
+
} else if (startInFlightRef.current) sessionRef.current += 1;
|
|
3244
3270
|
startInFlightRef.current = false;
|
|
3245
|
-
recorderRef.current?.stop();
|
|
3246
|
-
recorderRef.current = null;
|
|
3247
3271
|
setState((prev) => ({
|
|
3248
3272
|
...prev,
|
|
3249
3273
|
isListening: false
|