@mastra/playground-ui 6.2.2-alpha.0 → 6.2.2-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/CHANGELOG.md +29 -0
- package/dist/index.cjs.js +40 -4
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +40 -4
- package/dist/index.es.js.map +1 -1
- package/dist/src/components/assistant-ui/tools/badges/tool-badge.d.ts +4 -1
- package/dist/src/components/ui/syntax-highlighter.d.ts +2 -2
- package/package.json +8 -8
package/dist/index.es.js
CHANGED
|
@@ -4287,7 +4287,10 @@ const useCodemirrorTheme$2 = () => {
|
|
|
4287
4287
|
[]
|
|
4288
4288
|
);
|
|
4289
4289
|
};
|
|
4290
|
-
const SyntaxHighlighter$2 = ({
|
|
4290
|
+
const SyntaxHighlighter$2 = ({
|
|
4291
|
+
data,
|
|
4292
|
+
className
|
|
4293
|
+
}) => {
|
|
4291
4294
|
const formattedCode = JSON.stringify(data, null, 2);
|
|
4292
4295
|
const theme = useCodemirrorTheme$2();
|
|
4293
4296
|
return /* @__PURE__ */ jsxs("div", { className: clsx("rounded-md bg-surface4 p-1 font-mono relative", className), children: [
|
|
@@ -4460,7 +4463,7 @@ const NetworkChoiceMetadataDialogTrigger = ({
|
|
|
4460
4463
|
] });
|
|
4461
4464
|
};
|
|
4462
4465
|
|
|
4463
|
-
const ToolBadge = ({ toolName, args, result, networkMetadata }) => {
|
|
4466
|
+
const ToolBadge = ({ toolName, args, result, networkMetadata, toolOutput }) => {
|
|
4464
4467
|
let argSlot = null;
|
|
4465
4468
|
try {
|
|
4466
4469
|
const { __mastraMetadata: _, ...formattedArgs } = typeof args === "object" ? args : JSON.parse(args);
|
|
@@ -4468,7 +4471,7 @@ const ToolBadge = ({ toolName, args, result, networkMetadata }) => {
|
|
|
4468
4471
|
} catch {
|
|
4469
4472
|
argSlot = /* @__PURE__ */ jsx("pre", { className: "whitespace-pre-wrap", children: args });
|
|
4470
4473
|
}
|
|
4471
|
-
let resultSlot = typeof result === "string" ? /* @__PURE__ */ jsx("pre", { className: "whitespace-pre-wrap", children: result }) : /* @__PURE__ */ jsx(SyntaxHighlighter$2, { data: result });
|
|
4474
|
+
let resultSlot = typeof result === "string" ? /* @__PURE__ */ jsx("pre", { className: "whitespace-pre-wrap bg-surface4 p-4 rounded-md", children: result }) : /* @__PURE__ */ jsx(SyntaxHighlighter$2, { data: result });
|
|
4472
4475
|
return /* @__PURE__ */ jsx(
|
|
4473
4476
|
BadgeWrapper,
|
|
4474
4477
|
{
|
|
@@ -4486,9 +4489,13 @@ const ToolBadge = ({ toolName, args, result, networkMetadata }) => {
|
|
|
4486
4489
|
/* @__PURE__ */ jsx("p", { className: "font-medium pb-2", children: "Tool arguments" }),
|
|
4487
4490
|
argSlot
|
|
4488
4491
|
] }),
|
|
4489
|
-
|
|
4492
|
+
resultSlot !== void 0 && /* @__PURE__ */ jsxs("div", { children: [
|
|
4490
4493
|
/* @__PURE__ */ jsx("p", { className: "font-medium pb-2", children: "Tool result" }),
|
|
4491
4494
|
resultSlot
|
|
4495
|
+
] }),
|
|
4496
|
+
toolOutput.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
|
|
4497
|
+
/* @__PURE__ */ jsx("p", { className: "font-medium pb-2", children: "Tool output" }),
|
|
4498
|
+
/* @__PURE__ */ jsx("div", { className: "h-40 overflow-y-auto", children: /* @__PURE__ */ jsx(SyntaxHighlighter$2, { data: toolOutput }) })
|
|
4492
4499
|
] })
|
|
4493
4500
|
] })
|
|
4494
4501
|
}
|
|
@@ -8728,6 +8735,7 @@ const ToolFallbackInner = ({ toolName, result, args }) => {
|
|
|
8728
8735
|
toolName,
|
|
8729
8736
|
args,
|
|
8730
8737
|
result,
|
|
8738
|
+
toolOutput: args?.__mastraMetadata?.toolOutput || [],
|
|
8731
8739
|
networkMetadata: args?.__mastraMetadata?.networkMetadata
|
|
8732
8740
|
}
|
|
8733
8741
|
);
|
|
@@ -9876,6 +9884,34 @@ const handleStreamChunk = async ({
|
|
|
9876
9884
|
case "tool-output": {
|
|
9877
9885
|
if (chunk.payload.output?.type.startsWith("workflow-")) {
|
|
9878
9886
|
handleWorkflowChunk({ workflowChunk: chunk.payload.output, setMessages, entityName: chunk.payload.toolName });
|
|
9887
|
+
} else {
|
|
9888
|
+
setMessages((currentConversation) => {
|
|
9889
|
+
const lastMessage = currentConversation[currentConversation.length - 1];
|
|
9890
|
+
if (lastMessage && lastMessage.role === "assistant" && Array.isArray(lastMessage.content)) {
|
|
9891
|
+
const updatedContent = lastMessage.content.map((part) => {
|
|
9892
|
+
if (typeof part === "object" && part.type === "tool-call" && part.toolCallId === chunk.payload.toolCallId) {
|
|
9893
|
+
const existingToolOutput = part.args?.__mastraMetadata?.toolOutput || [];
|
|
9894
|
+
return {
|
|
9895
|
+
...part,
|
|
9896
|
+
args: {
|
|
9897
|
+
...part.args,
|
|
9898
|
+
__mastraMetadata: {
|
|
9899
|
+
...part.args?.__mastraMetadata,
|
|
9900
|
+
toolOutput: [...existingToolOutput, chunk?.payload?.output]
|
|
9901
|
+
}
|
|
9902
|
+
}
|
|
9903
|
+
};
|
|
9904
|
+
}
|
|
9905
|
+
return part;
|
|
9906
|
+
});
|
|
9907
|
+
const updatedMessage = {
|
|
9908
|
+
...lastMessage,
|
|
9909
|
+
content: updatedContent
|
|
9910
|
+
};
|
|
9911
|
+
return [...currentConversation.slice(0, -1), updatedMessage];
|
|
9912
|
+
}
|
|
9913
|
+
return currentConversation;
|
|
9914
|
+
});
|
|
9879
9915
|
}
|
|
9880
9916
|
break;
|
|
9881
9917
|
}
|