@mastra/playground-ui 5.1.2-alpha.5 → 5.1.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.js +117 -12
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +120 -16
- package/dist/index.es.js.map +1 -1
- package/dist/src/components/assistant-ui/attachment-adapters/pdfs-adapter.d.ts +12 -0
- package/dist/src/domains/workflows/index.d.ts +1 -0
- package/dist/src/domains/workflows/runs/workflow-runs.d.ts +13 -0
- package/package.json +3 -3
package/dist/index.cjs.js
CHANGED
|
@@ -4234,11 +4234,12 @@ const AttachmentPreviewDialog = ({ children }) => {
|
|
|
4234
4234
|
};
|
|
4235
4235
|
const AttachmentThumbnail = () => {
|
|
4236
4236
|
const isImage = react.useAttachment((a) => a.type === "image");
|
|
4237
|
+
const document = react.useAttachment((a) => a.type === "document" ? a : void 0);
|
|
4237
4238
|
const src = useAttachmentSrc();
|
|
4238
4239
|
const canRemove = react.useAttachment((a) => a.source !== "message");
|
|
4239
4240
|
return /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive.TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
|
|
4240
4241
|
/* @__PURE__ */ jsxRuntime.jsxs(react.AttachmentPrimitive.Root, { className: "relative", children: [
|
|
4241
|
-
/* @__PURE__ */ jsxRuntime.jsx(AttachmentPreviewDialog, { children: /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full w-full aspect-ratio overflow-hidden rounded-lg", children: isImage ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg border-sm border-border1 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("img", { src, className: "object-cover aspect-ratio size-16", alt: "Preview", height: 64, width: 64 }) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg border-sm border-border1 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileIcon, { className: "text-icon3" }) }) }) }) }),
|
|
4242
|
+
/* @__PURE__ */ jsxRuntime.jsx(AttachmentPreviewDialog, { children: /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full w-full aspect-ratio overflow-hidden rounded-lg", children: isImage ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg border-sm border-border1 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("img", { src, className: "object-cover aspect-ratio size-16", alt: "Preview", height: 64, width: 64 }) }) : document?.contentType === "application/pdf" ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg border-sm border-border1 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileText, { className: "text-accent2" }) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg border-sm border-border1 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileIcon, { className: "text-icon3" }) }) }) }) }),
|
|
4242
4243
|
canRemove && /* @__PURE__ */ jsxRuntime.jsx(AttachmentRemove, {})
|
|
4243
4244
|
] }),
|
|
4244
4245
|
/* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { side: "top", children: /* @__PURE__ */ jsxRuntime.jsx(react.AttachmentPrimitive.Name, {}) })
|
|
@@ -4260,9 +4261,10 @@ const UserMessageAttachments = () => {
|
|
|
4260
4261
|
};
|
|
4261
4262
|
const InMessageAttachment = () => {
|
|
4262
4263
|
const isImage = react.useAttachment((a) => a.type === "image");
|
|
4264
|
+
const document = react.useAttachment((a) => a.type === "document" ? a : void 0);
|
|
4263
4265
|
const src = useAttachmentSrc();
|
|
4264
4266
|
return /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive.TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
|
|
4265
|
-
/* @__PURE__ */ jsxRuntime.jsx(react.AttachmentPrimitive.Root, { className: "relative pt-4", children: /* @__PURE__ */ jsxRuntime.jsx(AttachmentPreviewDialog, { children: /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full w-full aspect-ratio overflow-hidden rounded-lg", children: isImage ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg border-sm border-border1 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("img", { src, className: "object-cover aspect-ratio max-h-[140px] max-w-[320px]", alt: "Preview" }) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg border-sm border-border1 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileIcon, { className: "text-icon3" }) }) }) }) }) }),
|
|
4267
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.AttachmentPrimitive.Root, { className: "relative pt-4", children: /* @__PURE__ */ jsxRuntime.jsx(AttachmentPreviewDialog, { children: /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full w-full aspect-ratio overflow-hidden rounded-lg", children: isImage ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg border-sm border-border1 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("img", { src, className: "object-cover aspect-ratio max-h-[140px] max-w-[320px]", alt: "Preview" }) }) : document?.contentType === "application/pdf" ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg border-sm border-border1 flex items-center justify-center p-4", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileText, { className: "text-accent2" }) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg border-sm border-border1 flex items-center justify-center p-4", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileIcon, { className: "text-icon3" }) }) }) }) }) }),
|
|
4266
4268
|
/* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { side: "top", children: /* @__PURE__ */ jsxRuntime.jsx(react.AttachmentPrimitive.Name, {}) })
|
|
4267
4269
|
] }) });
|
|
4268
4270
|
};
|
|
@@ -4528,20 +4530,96 @@ const fileToBase64 = async (file) => {
|
|
|
4528
4530
|
});
|
|
4529
4531
|
};
|
|
4530
4532
|
|
|
4533
|
+
class PDFAttachmentAdapter {
|
|
4534
|
+
accept = "application/pdf";
|
|
4535
|
+
async add({ file }) {
|
|
4536
|
+
const maxSize = 20 * 1024 * 1024;
|
|
4537
|
+
if (file.size > maxSize) {
|
|
4538
|
+
throw new Error("PDF size exceeds 20MB limit");
|
|
4539
|
+
}
|
|
4540
|
+
return {
|
|
4541
|
+
id: crypto.randomUUID(),
|
|
4542
|
+
type: "document",
|
|
4543
|
+
name: file.name,
|
|
4544
|
+
file,
|
|
4545
|
+
status: {
|
|
4546
|
+
type: "running",
|
|
4547
|
+
reason: "uploading",
|
|
4548
|
+
progress: 0
|
|
4549
|
+
},
|
|
4550
|
+
contentType: "application/pdf"
|
|
4551
|
+
};
|
|
4552
|
+
}
|
|
4553
|
+
async send(attachment) {
|
|
4554
|
+
const base64Data = await this.fileToBase64(attachment.file);
|
|
4555
|
+
return {
|
|
4556
|
+
id: attachment.id,
|
|
4557
|
+
type: "document",
|
|
4558
|
+
name: attachment.name,
|
|
4559
|
+
content: [
|
|
4560
|
+
{
|
|
4561
|
+
type: "text",
|
|
4562
|
+
text: base64Data
|
|
4563
|
+
}
|
|
4564
|
+
],
|
|
4565
|
+
status: { type: "complete" },
|
|
4566
|
+
contentType: "application/pdf"
|
|
4567
|
+
};
|
|
4568
|
+
}
|
|
4569
|
+
async remove(attachment) {
|
|
4570
|
+
}
|
|
4571
|
+
async fileToBase64(file) {
|
|
4572
|
+
const arrayBuffer = await file.arrayBuffer();
|
|
4573
|
+
const bytes = new Uint8Array(arrayBuffer);
|
|
4574
|
+
let binary = "";
|
|
4575
|
+
bytes.forEach((byte) => {
|
|
4576
|
+
binary += String.fromCharCode(byte);
|
|
4577
|
+
});
|
|
4578
|
+
return btoa(binary);
|
|
4579
|
+
}
|
|
4580
|
+
// Optional: Extract text from PDF using a library like pdf.js
|
|
4581
|
+
async extractTextFromPDF(file) {
|
|
4582
|
+
return "Extracted PDF text content";
|
|
4583
|
+
}
|
|
4584
|
+
}
|
|
4585
|
+
|
|
4531
4586
|
const convertMessage$1 = (message) => {
|
|
4532
4587
|
return message;
|
|
4533
4588
|
};
|
|
4534
4589
|
const convertToAIAttachments = async (attachments) => {
|
|
4535
|
-
const promises = attachments.filter((attachment) => attachment.
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4590
|
+
const promises = attachments.filter((attachment) => attachment.type === "image" || attachment.type === "document").map(async (attachment) => {
|
|
4591
|
+
if (attachment.type === "document") {
|
|
4592
|
+
if (attachment.contentType === "application/pdf") {
|
|
4593
|
+
return {
|
|
4594
|
+
role: "user",
|
|
4595
|
+
content: [
|
|
4596
|
+
{
|
|
4597
|
+
type: "file",
|
|
4598
|
+
// @ts-expect-error - TODO: fix this type issue somehow
|
|
4599
|
+
data: attachment.content?.[0]?.text || "",
|
|
4600
|
+
mimeType: attachment.contentType,
|
|
4601
|
+
filename: attachment.name
|
|
4602
|
+
}
|
|
4603
|
+
]
|
|
4604
|
+
};
|
|
4542
4605
|
}
|
|
4543
|
-
|
|
4544
|
-
|
|
4606
|
+
return {
|
|
4607
|
+
role: "user",
|
|
4608
|
+
// @ts-expect-error - TODO: fix this type issue somehow
|
|
4609
|
+
content: attachment.content[0]?.text || ""
|
|
4610
|
+
};
|
|
4611
|
+
}
|
|
4612
|
+
return {
|
|
4613
|
+
role: "user",
|
|
4614
|
+
content: [
|
|
4615
|
+
{
|
|
4616
|
+
type: "image",
|
|
4617
|
+
image: await fileToBase64(attachment.file),
|
|
4618
|
+
mimeType: attachment.file.type
|
|
4619
|
+
}
|
|
4620
|
+
]
|
|
4621
|
+
};
|
|
4622
|
+
});
|
|
4545
4623
|
return Promise.all(promises);
|
|
4546
4624
|
};
|
|
4547
4625
|
function MastraRuntimeProvider({
|
|
@@ -4843,7 +4921,11 @@ function MastraRuntimeProvider({
|
|
|
4843
4921
|
convertMessage: convertMessage$1,
|
|
4844
4922
|
onNew,
|
|
4845
4923
|
adapters: {
|
|
4846
|
-
attachments: new react.CompositeAttachmentAdapter([
|
|
4924
|
+
attachments: new react.CompositeAttachmentAdapter([
|
|
4925
|
+
new react.SimpleImageAttachmentAdapter(),
|
|
4926
|
+
new react.SimpleTextAttachmentAdapter(),
|
|
4927
|
+
new PDFAttachmentAdapter()
|
|
4928
|
+
])
|
|
4847
4929
|
}
|
|
4848
4930
|
});
|
|
4849
4931
|
return /* @__PURE__ */ jsxRuntime.jsxs(react.AssistantRuntimeProvider, { runtime, children: [
|
|
@@ -9743,6 +9825,28 @@ function WorkflowTrigger({ workflowId, setRunId }) {
|
|
|
9743
9825
|
] }) });
|
|
9744
9826
|
}
|
|
9745
9827
|
|
|
9828
|
+
const WorkflowRuns = ({ workflowId, runId, isLoading, runs, onPressRun }) => {
|
|
9829
|
+
if (isLoading) {
|
|
9830
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4", children: /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-[600px]" }) });
|
|
9831
|
+
}
|
|
9832
|
+
if (runs.length === 0) {
|
|
9833
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4", children: /* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-md", className: "text-icon6 text-center", children: "No previous run" }) });
|
|
9834
|
+
}
|
|
9835
|
+
return /* @__PURE__ */ jsxRuntime.jsx("ol", { className: "pb-10", children: runs.map((run) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9836
|
+
"button",
|
|
9837
|
+
{
|
|
9838
|
+
onClick: () => onPressRun({ workflowId, runId: run.runId }),
|
|
9839
|
+
className: clsx("px-3 py-2 border-b-sm border-border1 block w-full hover:bg-surface4 text-left", {
|
|
9840
|
+
"bg-surface4": run.runId === runId
|
|
9841
|
+
}),
|
|
9842
|
+
children: [
|
|
9843
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-lg", className: "font-medium text-icon6 truncate", as: "p", children: run.runId }),
|
|
9844
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-sm", className: "font-medium text-icon3 truncate", as: "p", children: typeof run?.snapshot === "string" ? "" : run?.snapshot?.timestamp ? dateFns.formatDate(run?.snapshot?.timestamp, "MMM d, yyyy h:mm a") : "" })
|
|
9845
|
+
]
|
|
9846
|
+
}
|
|
9847
|
+
) }, run.runId)) });
|
|
9848
|
+
};
|
|
9849
|
+
|
|
9746
9850
|
const DataTable = ({
|
|
9747
9851
|
columns,
|
|
9748
9852
|
data,
|
|
@@ -10190,6 +10294,7 @@ exports.WorkflowGraph = WorkflowGraph;
|
|
|
10190
10294
|
exports.WorkflowIcon = WorkflowIcon;
|
|
10191
10295
|
exports.WorkflowRunContext = WorkflowRunContext;
|
|
10192
10296
|
exports.WorkflowRunProvider = WorkflowRunProvider;
|
|
10297
|
+
exports.WorkflowRuns = WorkflowRuns;
|
|
10193
10298
|
exports.WorkflowTraces = WorkflowTraces;
|
|
10194
10299
|
exports.WorkflowTrigger = WorkflowTrigger;
|
|
10195
10300
|
exports.useCurrentRun = useCurrentRun;
|