@mastra/playground-ui 5.1.1-alpha.1 → 5.1.1-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/dist/index.cjs.js CHANGED
@@ -18,6 +18,8 @@ const langJson = require('@codemirror/lang-json');
18
18
  const highlight$1 = require('@lezer/highlight');
19
19
  const codemirrorThemeDracula = require('@uiw/codemirror-theme-dracula');
20
20
  const CodeMirror = require('@uiw/react-codemirror');
21
+ const DialogPrimitive = require('@radix-ui/react-dialog');
22
+ const shallow = require('zustand/shallow');
21
23
  const di = require('@mastra/core/di');
22
24
  const clientJs = require('@mastra/client-js');
23
25
  const zustand = require('zustand');
@@ -35,7 +37,6 @@ require('@xyflow/react/dist/style.css');
35
37
  const Dagre = require('@dagrejs/dagre');
36
38
  const prismReactRenderer = require('prism-react-renderer');
37
39
  const CollapsiblePrimitive = require('@radix-ui/react-collapsible');
38
- const DialogPrimitive = require('@radix-ui/react-dialog');
39
40
  const ScrollAreaPrimitive = require('@radix-ui/react-scroll-area');
40
41
  const jsonSchemaToZod = require('json-schema-to-zod');
41
42
  const superjson = require('superjson');
@@ -71,9 +72,9 @@ function _interopNamespaceDefault(e) {
71
72
  const React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
72
73
  const TooltipPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(TooltipPrimitive);
73
74
  const AvatarPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(AvatarPrimitive);
75
+ const DialogPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(DialogPrimitive);
74
76
  const TabsPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(TabsPrimitive);
75
77
  const CollapsiblePrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(CollapsiblePrimitive);
76
- const DialogPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(DialogPrimitive);
77
78
  const ScrollAreaPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(ScrollAreaPrimitive);
78
79
  const CheckboxPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(CheckboxPrimitive);
79
80
  const PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(PopoverPrimitive);
@@ -3925,6 +3926,83 @@ const McpCoinIcon = (props) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "
3925
3926
  )
3926
3927
  ] });
3927
3928
 
3929
+ const ToolCoinIcon = (props) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "126", height: "85", viewBox: "0 0 126 85", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: [
3930
+ /* @__PURE__ */ jsxRuntime.jsx(
3931
+ "path",
3932
+ {
3933
+ d: "M119.322 35.1641C119.322 50.36 94.1055 62.6787 62.9998 62.6787C31.894 62.6787 6.67773 50.36 6.67773 35.1641V49.8368C6.67773 65.0327 31.894 77.3514 62.9998 77.3514C94.1055 77.3514 119.322 65.0327 119.322 49.8368V35.1641Z",
3934
+ fill: "#2E2E2E",
3935
+ fillOpacity: "0.9"
3936
+ }
3937
+ ),
3938
+ /* @__PURE__ */ jsxRuntime.jsx(
3939
+ "path",
3940
+ {
3941
+ d: "M119.322 35.1641C119.322 50.36 94.1055 62.6787 62.9998 62.6787C31.894 62.6787 6.67773 50.36 6.67773 35.1641M119.322 35.1641C119.322 19.9681 94.1055 7.64941 62.9998 7.64941C31.894 7.64941 6.67773 19.9681 6.67773 35.1641M119.322 35.1641V49.8368C119.322 65.0327 94.1055 77.3514 62.9998 77.3514C31.894 77.3514 6.67773 65.0327 6.67773 49.8368V35.1641",
3942
+ stroke: "#424242"
3943
+ }
3944
+ ),
3945
+ /* @__PURE__ */ jsxRuntime.jsx(
3946
+ "path",
3947
+ {
3948
+ d: "M63.0002 0.96875C28.5152 0.96875 0.55957 15.6489 0.55957 33.7578V51.2433C0.55957 69.3522 28.5152 84.0323 63.0002 84.0323C97.4853 84.0323 125.441 69.3522 125.441 51.2433V33.7578C125.441 15.6489 97.4853 0.96875 63.0002 0.96875Z",
3949
+ stroke: "#707070"
3950
+ }
3951
+ ),
3952
+ /* @__PURE__ */ jsxRuntime.jsx(
3953
+ "path",
3954
+ {
3955
+ fillRule: "evenodd",
3956
+ clipRule: "evenodd",
3957
+ d: "M95.8997 32.6647C98.4806 33.9355 98.4744 36.0012 95.8997 37.2689L89.6657 40.3384C87.0848 41.6091 82.8892 41.6061 80.3146 40.3384L74.0805 37.2689C71.4996 35.9981 71.5059 33.9324 74.0805 32.6647L80.3146 29.5952C82.8955 28.3244 87.091 28.3275 89.6657 29.5952L95.8997 32.6647ZM74.0805 21.9215C76.6614 23.1923 76.6552 25.258 74.0805 26.5257L67.8465 29.5952C65.2656 30.866 61.0701 30.8629 58.4954 29.5952L52.2613 26.5257C49.6804 25.255 49.6867 23.1892 52.2613 21.9215L58.4954 18.852C61.0763 17.5813 65.2718 17.5843 67.8465 18.852L74.0805 21.9215ZM74.0805 43.4079C76.6614 44.6786 76.6552 46.7444 74.0805 48.0121L67.8465 51.0816C65.2656 52.3523 61.0701 52.3493 58.4954 51.0816L52.2613 48.0121C49.6804 46.7413 49.6867 44.6756 52.2613 43.4079L58.4954 40.3384C61.0763 39.0676 65.2718 39.0707 67.8465 40.3384L74.0805 43.4079ZM52.2613 32.6647C54.8422 33.9355 54.836 36.0012 52.2613 37.2689L46.0273 40.3384C43.4464 41.6091 39.2509 41.6061 36.6762 40.3384L30.4422 37.2689C27.8613 35.9981 27.8675 33.9324 30.4422 32.6647L36.6762 29.5952C39.2571 28.3244 43.4526 28.3275 46.0273 29.5952L52.2613 32.6647Z",
3958
+ fill: "#A9A9A9"
3959
+ }
3960
+ )
3961
+ ] });
3962
+
3963
+ const AgentNetworkCoinIcon = (props) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "126", height: "85", viewBox: "0 0 126 85", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: [
3964
+ /* @__PURE__ */ jsxRuntime.jsx(
3965
+ "path",
3966
+ {
3967
+ d: "M119.322 35.1641C119.322 50.36 94.1055 62.6787 62.9998 62.6787C31.894 62.6787 6.67773 50.36 6.67773 35.1641V49.8368C6.67773 65.0327 31.894 77.3514 62.9998 77.3514C94.1055 77.3514 119.322 65.0327 119.322 49.8368V35.1641Z",
3968
+ fill: "#2E2E2E",
3969
+ fillOpacity: "0.9"
3970
+ }
3971
+ ),
3972
+ /* @__PURE__ */ jsxRuntime.jsx(
3973
+ "path",
3974
+ {
3975
+ d: "M119.322 35.1641C119.322 50.36 94.1055 62.6787 62.9998 62.6787C31.894 62.6787 6.67773 50.36 6.67773 35.1641M119.322 35.1641C119.322 19.9681 94.1055 7.64941 62.9998 7.64941C31.894 7.64941 6.67773 19.9681 6.67773 35.1641M119.322 35.1641V49.8368C119.322 65.0327 94.1055 77.3514 62.9998 77.3514C31.894 77.3514 6.67773 65.0327 6.67773 49.8368V35.1641",
3976
+ stroke: "#424242"
3977
+ }
3978
+ ),
3979
+ /* @__PURE__ */ jsxRuntime.jsx(
3980
+ "path",
3981
+ {
3982
+ d: "M63.0002 0.96875C28.5152 0.96875 0.55957 15.6489 0.55957 33.7578V51.2433C0.55957 69.3522 28.5152 84.0323 63.0002 84.0323C97.4853 84.0323 125.441 69.3522 125.441 51.2433V33.7578C125.441 15.6489 97.4853 0.96875 63.0002 0.96875Z",
3983
+ stroke: "#707070"
3984
+ }
3985
+ ),
3986
+ /* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip0_23333_14744)", children: /* @__PURE__ */ jsxRuntime.jsx(
3987
+ "path",
3988
+ {
3989
+ fillRule: "evenodd",
3990
+ clipRule: "evenodd",
3991
+ d: "M79.2946 17.9539C83.0143 19.7854 83.016 22.7559 79.2979 24.5879C77.0214 25.7087 73.8794 26.1385 70.9301 25.8878L67.5296 30.2202C68.0944 30.3987 68.6321 30.6075 69.1262 30.8507C71.0847 31.815 72.0009 33.0948 71.8979 34.3581L77.2504 35.1977C77.6452 34.8727 78.1174 34.5635 78.6856 34.2835C82.4066 32.4514 88.4403 32.4485 92.1623 34.2803C95.8842 36.1128 95.8805 39.0851 92.159 40.9175C88.4373 42.7488 82.4002 42.7513 78.679 40.9191C76.7415 39.9647 75.8248 38.7009 75.9073 37.4506L70.5219 36.6045C70.1354 36.9168 69.6777 37.2145 69.1295 37.4846C68.345 37.8708 67.4527 38.1705 66.5059 38.3939L67.9312 41.984C70.1507 42.0573 72.3276 42.5087 74.0244 43.3438C77.7444 45.1754 77.7467 48.1458 74.0277 49.9778C70.3071 51.8092 64.2712 51.8095 60.551 49.9778C56.8323 48.1459 56.8351 45.1755 60.5543 43.3438C61.3581 42.9482 62.2741 42.6414 63.247 42.4167L61.8282 38.8428C59.5803 38.7777 57.3696 38.3299 55.6527 37.4846C54.1264 36.7327 53.2395 35.7882 52.9666 34.8103L43.924 34.0469C43.4596 34.6259 42.7547 35.1702 41.8041 35.6385C38.0834 37.4696 32.0473 37.4701 28.3273 35.6385C24.6089 33.8068 24.6123 30.8363 28.3306 29.0046C32.0508 27.1737 38.0806 27.1737 41.8008 29.0046C43.3459 29.7653 44.2412 30.7224 44.5033 31.7129L53.5098 32.4747C53.9742 31.8832 54.6868 31.3279 55.656 30.8507C57.6687 29.8601 60.357 29.4079 62.9902 29.4892L66.5783 24.9218C66.3174 24.8179 66.0637 24.7073 65.8212 24.5879C62.1022 22.7559 62.1045 19.7856 65.8245 17.9539C69.5447 16.1235 75.5747 16.1232 79.2946 17.9539ZM38.4299 30.6643C36.5715 29.75 33.5599 29.75 31.7015 30.6643C29.8447 31.5793 29.8414 33.0638 31.6982 33.9788C33.5565 34.8938 36.5742 34.8933 38.4332 33.9788C40.2906 33.0635 40.2883 31.5793 38.4299 30.6643ZM70.6536 45.0035C68.7951 44.0893 65.7836 44.0893 63.9251 45.0035C62.0676 45.9185 62.0647 47.4029 63.9218 48.318C65.7804 49.2332 68.7979 49.2329 70.6569 48.3181C72.5142 47.4027 72.5119 45.9185 70.6536 45.0035ZM65.7553 32.5104C63.8969 31.5961 60.8853 31.5961 59.0269 32.5104C57.1685 33.4254 57.1662 34.9096 59.0236 35.8249C60.8824 36.7402 63.8998 36.7402 65.7586 35.8249C67.616 34.9096 67.6137 33.4254 65.7553 32.5104ZM88.7915 35.94C86.9338 35.0261 83.9184 35.0264 82.0564 35.9432C80.1965 36.8601 80.1945 38.3451 82.0498 39.2594C83.9067 40.1736 86.9255 40.1738 88.7882 39.2578C90.6507 38.3407 90.649 36.8546 88.7915 35.94ZM75.9238 19.6136C74.0656 18.6995 71.0538 18.6998 69.1953 19.6136C67.3369 20.5286 67.3347 22.0129 69.192 22.9282C71.0509 23.8434 74.0682 23.8434 75.9271 22.9282C77.7836 22.0128 77.7818 20.5285 75.9238 19.6136Z",
3992
+ fill: "#A9A9A9"
3993
+ }
3994
+ ) }),
3995
+ /* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip0_23333_14744", children: /* @__PURE__ */ jsxRuntime.jsx(
3996
+ "rect",
3997
+ {
3998
+ width: "59.3185",
3999
+ height: "59.3185",
4000
+ fill: "white",
4001
+ transform: "matrix(0.897148 0.441731 -0.897148 0.441731 65.3042 6.51953)"
4002
+ }
4003
+ ) }) })
4004
+ ] });
4005
+
3928
4006
  const useCodemirrorTheme$1 = () => {
3929
4007
  return React.useMemo(
3930
4008
  () => codemirrorThemeDracula.draculaInit({
@@ -4021,8 +4099,156 @@ const AssistantActionBar = () => {
4021
4099
  );
4022
4100
  };
4023
4101
 
4102
+ const Dialog = DialogPrimitive__namespace.Root;
4103
+ const DialogTrigger = DialogPrimitive__namespace.Trigger;
4104
+ const DialogPortal = DialogPrimitive__namespace.Portal;
4105
+ const DialogOverlay = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
4106
+ DialogPrimitive__namespace.Overlay,
4107
+ {
4108
+ ref,
4109
+ className: cn(
4110
+ "fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
4111
+ className
4112
+ ),
4113
+ ...props
4114
+ }
4115
+ ));
4116
+ DialogOverlay.displayName = DialogPrimitive__namespace.Overlay.displayName;
4117
+ const DialogContent = React__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(DialogPortal, { children: [
4118
+ /* @__PURE__ */ jsxRuntime.jsx(DialogOverlay, {}),
4119
+ /* @__PURE__ */ jsxRuntime.jsxs(
4120
+ DialogPrimitive__namespace.Content,
4121
+ {
4122
+ ref,
4123
+ className: cn(
4124
+ "fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
4125
+ className
4126
+ ),
4127
+ ...props,
4128
+ children: [
4129
+ children,
4130
+ /* @__PURE__ */ jsxRuntime.jsxs(DialogPrimitive__namespace.Close, { className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground", children: [
4131
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "h-4 w-4" }),
4132
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Close" })
4133
+ ] })
4134
+ ]
4135
+ }
4136
+ )
4137
+ ] }));
4138
+ DialogContent.displayName = DialogPrimitive__namespace.Content.displayName;
4139
+ const DialogTitle = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
4140
+ DialogPrimitive__namespace.Title,
4141
+ {
4142
+ ref,
4143
+ className: cn("text-lg font-semibold leading-none tracking-tight", className),
4144
+ ...props
4145
+ }
4146
+ ));
4147
+ DialogTitle.displayName = DialogPrimitive__namespace.Title.displayName;
4148
+ const DialogDescription = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Description, { ref, className: cn("text-sm text-muted-foreground", className), ...props }));
4149
+ DialogDescription.displayName = DialogPrimitive__namespace.Description.displayName;
4150
+
4151
+ const useHasAttachments = () => {
4152
+ const composer = react.useComposerRuntime();
4153
+ const [hasAttachments, setHasAttachments] = React.useState(false);
4154
+ React.useEffect(() => {
4155
+ composer.subscribe(() => {
4156
+ const attachments = composer.getState().attachments;
4157
+ setHasAttachments(attachments.length > 0);
4158
+ });
4159
+ }, [composer]);
4160
+ return hasAttachments;
4161
+ };
4162
+
4163
+ const useFileSrc = (file) => {
4164
+ const [src, setSrc] = React.useState(void 0);
4165
+ React.useEffect(() => {
4166
+ if (!file) {
4167
+ setSrc(void 0);
4168
+ return;
4169
+ }
4170
+ const objectUrl = URL.createObjectURL(file);
4171
+ setSrc(objectUrl);
4172
+ return () => {
4173
+ URL.revokeObjectURL(objectUrl);
4174
+ };
4175
+ }, [file]);
4176
+ return src;
4177
+ };
4178
+ const useAttachmentSrc = () => {
4179
+ const { file, src } = react.useAttachment(
4180
+ shallow.useShallow((a) => {
4181
+ if (a.type !== "image") return {};
4182
+ if (a.file) return { file: a.file };
4183
+ const src2 = a.content?.filter((c) => c.type === "image")[0]?.image;
4184
+ if (!src2) return {};
4185
+ return { src: src2 };
4186
+ })
4187
+ );
4188
+ return useFileSrc(file) ?? src;
4189
+ };
4190
+ const AttachmentPreview = ({ src }) => {
4191
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-hidden w-full", children: /* @__PURE__ */ jsxRuntime.jsx("img", { src, className: "object-contain aspect-ratio h-full w-full", alt: "Preview" }) });
4192
+ };
4193
+ const AttachmentPreviewDialog = ({ children }) => {
4194
+ const src = useAttachmentSrc();
4195
+ if (!src) return children;
4196
+ return /* @__PURE__ */ jsxRuntime.jsxs(Dialog, { children: [
4197
+ /* @__PURE__ */ jsxRuntime.jsx(DialogTrigger, { className: "hover:bg-accent/50 cursor-pointer transition-colors", asChild: true, children }),
4198
+ /* @__PURE__ */ jsxRuntime.jsxs(DialogPortal, { children: [
4199
+ /* @__PURE__ */ jsxRuntime.jsx(DialogOverlay, {}),
4200
+ /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: "max-w-5xl w-full max-h-[80%]", children: [
4201
+ /* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { className: "aui-sr-only", children: "Image Attachment Preview" }),
4202
+ /* @__PURE__ */ jsxRuntime.jsx(AttachmentPreview, { src })
4203
+ ] })
4204
+ ] })
4205
+ ] });
4206
+ };
4207
+ const AttachmentThumbnail = () => {
4208
+ const isImage = react.useAttachment((a) => a.type === "image");
4209
+ const src = useAttachmentSrc();
4210
+ const canRemove = react.useAttachment((a) => a.source !== "message");
4211
+ return /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive.TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
4212
+ /* @__PURE__ */ jsxRuntime.jsxs(react.AttachmentPrimitive.Root, { className: "relative", children: [
4213
+ /* @__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" }) }) }) }) }),
4214
+ canRemove && /* @__PURE__ */ jsxRuntime.jsx(AttachmentRemove, {})
4215
+ ] }),
4216
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { side: "top", children: /* @__PURE__ */ jsxRuntime.jsx(react.AttachmentPrimitive.Name, {}) })
4217
+ ] }) });
4218
+ };
4219
+ const AttachmentRemove = () => {
4220
+ return /* @__PURE__ */ jsxRuntime.jsx(react.AttachmentPrimitive.Remove, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
4221
+ TooltipIconButton,
4222
+ {
4223
+ tooltip: "Remove file",
4224
+ className: "absolute -right-3 -top-3 hover:bg-transparent rounded-full bg-surface1 rounded-full p-1",
4225
+ side: "top",
4226
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleXIcon, {}) })
4227
+ }
4228
+ ) });
4229
+ };
4230
+ const UserMessageAttachments = () => {
4231
+ return /* @__PURE__ */ jsxRuntime.jsx(react.MessagePrimitive.Attachments, { components: { Attachment: InMessageAttachment } });
4232
+ };
4233
+ const InMessageAttachment = () => {
4234
+ const isImage = react.useAttachment((a) => a.type === "image");
4235
+ const src = useAttachmentSrc();
4236
+ return /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive.TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
4237
+ /* @__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" }) }) }) }) }) }),
4238
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { side: "top", children: /* @__PURE__ */ jsxRuntime.jsx(react.AttachmentPrimitive.Name, {}) })
4239
+ ] }) });
4240
+ };
4241
+ const ComposerAttachments = () => {
4242
+ const hasAttachments = useHasAttachments();
4243
+ if (!hasAttachments) return null;
4244
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex w-full flex-row items-center gap-4 h-24", children: /* @__PURE__ */ jsxRuntime.jsx(react.ComposerPrimitive.Attachments, { components: { Attachment: AttachmentThumbnail } }) });
4245
+ };
4246
+
4024
4247
  const UserMessage = () => {
4025
- return /* @__PURE__ */ jsxRuntime.jsx(react.MessagePrimitive.Root, { className: "w-full flex justify-end pb-4", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "max-w-[366px] px-5 py-3 text-icon6 text-ui-lg leading-ui-lg rounded-lg bg-surface3", children: /* @__PURE__ */ jsxRuntime.jsx(react.MessagePrimitive.Content, {}) }) });
4248
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.MessagePrimitive.Root, { className: "w-full flex items-end pb-4 flex-col", children: [
4249
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "max-w-[366px] px-5 py-3 text-icon6 text-ui-lg leading-ui-lg rounded-lg bg-surface3", children: /* @__PURE__ */ jsxRuntime.jsx(react.MessagePrimitive.Content, {}) }),
4250
+ /* @__PURE__ */ jsxRuntime.jsx(UserMessageAttachments, {})
4251
+ ] });
4026
4252
  };
4027
4253
 
4028
4254
  const useAutoscroll = (ref, { enabled = true }) => {
@@ -4077,13 +4303,63 @@ const Txt = ({ as: Root = "p", className, variant = "ui-md", font, ...props }) =
4077
4303
  return /* @__PURE__ */ jsxRuntime.jsx(Root, { className: clsx(variants[variant], font && fonts[font], className), ...props });
4078
4304
  };
4079
4305
 
4080
- const Thread = ({ ToolFallback, agentName, hasMemory }) => {
4306
+ const useSpeechRecognition = ({ language = "en-US" } = {}) => {
4307
+ const speechRecognitionRef = React.useRef(null);
4308
+ const [state, setState] = React.useState({
4309
+ isListening: false,
4310
+ transcript: "",
4311
+ error: null
4312
+ });
4313
+ const start = () => {
4314
+ if (!speechRecognitionRef.current) return;
4315
+ speechRecognitionRef.current.start();
4316
+ };
4317
+ const stop = () => {
4318
+ if (!speechRecognitionRef.current) return;
4319
+ speechRecognitionRef.current.stop();
4320
+ };
4321
+ React.useEffect(() => {
4322
+ if (!("webkitSpeechRecognition" in window) && !("SpeechRecognition" in window)) {
4323
+ setState((prev) => ({ ...prev, error: "Speech Recognition not supported in this browser" }));
4324
+ return;
4325
+ }
4326
+ const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
4327
+ const recognition = new SpeechRecognition();
4328
+ speechRecognitionRef.current = recognition;
4329
+ recognition.continuous = true;
4330
+ recognition.lang = language;
4331
+ recognition.onstart = () => {
4332
+ setState((prev) => ({ ...prev, isListening: true }));
4333
+ };
4334
+ recognition.onresult = (event) => {
4335
+ let finalTranscript = "";
4336
+ for (let i = event.resultIndex; i < event.results.length; i++) {
4337
+ const transcript = event.results[i][0].transcript;
4338
+ if (event.results[i].isFinal) {
4339
+ finalTranscript += transcript + " ";
4340
+ }
4341
+ }
4342
+ setState((prev) => ({ ...prev, transcript: finalTranscript }));
4343
+ };
4344
+ recognition.onerror = (event) => {
4345
+ setState((prev) => ({ ...prev, error: `Error: ${event.error}` }));
4346
+ };
4347
+ recognition.onend = () => setState((prev) => ({ ...prev, isListening: false }));
4348
+ }, [language]);
4349
+ return {
4350
+ ...state,
4351
+ start,
4352
+ stop
4353
+ };
4354
+ };
4355
+
4356
+ const Thread = ({ ToolFallback, agentName, hasMemory, showFileSupport }) => {
4081
4357
  const areaRef = React.useRef(null);
4082
4358
  useAutoscroll(areaRef, { enabled: true });
4083
4359
  const WrappedAssistantMessage = (props) => {
4084
4360
  return /* @__PURE__ */ jsxRuntime.jsx(AssistantMessage, { ...props, ToolFallback });
4085
4361
  };
4086
- return /* @__PURE__ */ jsxRuntime.jsxs(react.ThreadPrimitive.Root, { className: "max-w-[568px] w-full mx-auto h-[calc(100%-110px)] px-4", children: [
4362
+ return /* @__PURE__ */ jsxRuntime.jsxs(ThreadWrapper, { children: [
4087
4363
  /* @__PURE__ */ jsxRuntime.jsxs(react.ThreadPrimitive.Viewport, { className: "py-10 overflow-y-auto scroll-smooth h-full", ref: areaRef, autoScroll: false, children: [
4088
4364
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4089
4365
  /* @__PURE__ */ jsxRuntime.jsx(ThreadWelcome, { agentName }),
@@ -4100,9 +4376,22 @@ const Thread = ({ ToolFallback, agentName, hasMemory }) => {
4100
4376
  ] }),
4101
4377
  /* @__PURE__ */ jsxRuntime.jsx(react.ThreadPrimitive.If, { empty: false, children: /* @__PURE__ */ jsxRuntime.jsx("div", {}) })
4102
4378
  ] }),
4103
- /* @__PURE__ */ jsxRuntime.jsx(Composer, { hasMemory })
4379
+ /* @__PURE__ */ jsxRuntime.jsx(Composer, { hasMemory, showFileSupport })
4104
4380
  ] });
4105
4381
  };
4382
+ const ThreadWrapper = ({ children }) => {
4383
+ const hasAttachments = useHasAttachments();
4384
+ return /* @__PURE__ */ jsxRuntime.jsx(
4385
+ react.ThreadPrimitive.Root,
4386
+ {
4387
+ className: clsx(
4388
+ "max-w-[568px] w-full mx-auto px-4",
4389
+ hasAttachments ? "h-[calc(100%-208px)]" : "h-[calc(100%-112px)]"
4390
+ ),
4391
+ children
4392
+ }
4393
+ );
4394
+ };
4106
4395
  const ThreadWelcome = ({ agentName }) => {
4107
4396
  const safeAgentName = agentName ?? "";
4108
4397
  const words = safeAgentName.split(" ") ?? [];
@@ -4119,20 +4408,26 @@ const ThreadWelcome = ({ agentName }) => {
4119
4408
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-4 font-medium", children: "How can I help you today?" })
4120
4409
  ] }) });
4121
4410
  };
4122
- const Composer = ({ hasMemory }) => {
4411
+ const Composer = ({ hasMemory, showFileSupport }) => {
4123
4412
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4124
- /* @__PURE__ */ jsxRuntime.jsxs(react.ComposerPrimitive.Root, { className: "w-full bg-surface3 rounded-lg border-sm border-border1 px-3 py-4 mt-auto h-[100px]", children: [
4125
- /* @__PURE__ */ jsxRuntime.jsx(react.ComposerPrimitive.Input, { asChild: true, className: "w-full", children: /* @__PURE__ */ jsxRuntime.jsx(
4126
- "textarea",
4127
- {
4128
- className: "text-ui-lg leading-ui-lg placeholder:text-icon3 text-icon6 bg-transparent focus:outline-none resize-none",
4129
- autoFocus: true,
4130
- placeholder: "Enter your message...",
4131
- name: "",
4132
- id: ""
4133
- }
4134
- ) }),
4135
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsxRuntime.jsx(ComposerAction, {}) })
4413
+ /* @__PURE__ */ jsxRuntime.jsxs(react.ComposerPrimitive.Root, { children: [
4414
+ /* @__PURE__ */ jsxRuntime.jsx(ComposerAttachments, {}),
4415
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full bg-surface3 rounded-lg border-sm border-border1 px-3 py-4 mt-auto h-[100px]", children: [
4416
+ /* @__PURE__ */ jsxRuntime.jsx(react.ComposerPrimitive.Input, { asChild: true, className: "w-full", children: /* @__PURE__ */ jsxRuntime.jsx(
4417
+ "textarea",
4418
+ {
4419
+ className: "text-ui-lg leading-ui-lg placeholder:text-icon3 text-icon6 bg-transparent focus:outline-none resize-none",
4420
+ autoFocus: true,
4421
+ placeholder: "Enter your message...",
4422
+ name: "",
4423
+ id: ""
4424
+ }
4425
+ ) }),
4426
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
4427
+ /* @__PURE__ */ jsxRuntime.jsx(SpeechInput, {}),
4428
+ /* @__PURE__ */ jsxRuntime.jsx(ComposerAction, { showFileSupport })
4429
+ ] })
4430
+ ] })
4136
4431
  ] }),
4137
4432
  !hasMemory && /* @__PURE__ */ jsxRuntime.jsxs(Txt, { variant: "ui-sm", className: "text-icon3 flex items-center gap-2 pt-0.5", children: [
4138
4433
  /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(InfoIcon, {}) }),
@@ -4140,8 +4435,28 @@ const Composer = ({ hasMemory }) => {
4140
4435
  ] })
4141
4436
  ] });
4142
4437
  };
4143
- const ComposerAction = () => {
4438
+ const SpeechInput = () => {
4439
+ const composerRuntime = react.useComposerRuntime();
4440
+ const { start, stop, isListening, transcript } = useSpeechRecognition();
4441
+ React.useEffect(() => {
4442
+ if (!transcript) return;
4443
+ composerRuntime.setText(transcript);
4444
+ }, [composerRuntime, transcript]);
4445
+ return /* @__PURE__ */ jsxRuntime.jsx(
4446
+ TooltipIconButton,
4447
+ {
4448
+ type: "button",
4449
+ tooltip: isListening ? "Stop dictation" : "Start dictation",
4450
+ variant: "ghost",
4451
+ className: "rounded-full",
4452
+ onClick: () => isListening ? stop() : start(),
4453
+ children: isListening ? /* @__PURE__ */ jsxRuntime.jsx(CircleStopIcon, {}) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Mic, { className: "h-6 w-6 text-[#898989] hover:text-[#fff]" })
4454
+ }
4455
+ );
4456
+ };
4457
+ const ComposerAction = ({ showFileSupport }) => {
4144
4458
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4459
+ showFileSupport && /* @__PURE__ */ jsxRuntime.jsx(react.ComposerPrimitive.AddAttachment, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(TooltipIconButton, { tooltip: "Add attachment", variant: "ghost", className: "rounded-full", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.PlusIcon, { className: "h-6 w-6 text-[#898989] hover:text-[#fff]" }) }) }),
4145
4460
  /* @__PURE__ */ jsxRuntime.jsx(react.ThreadPrimitive.If, { running: false, children: /* @__PURE__ */ jsxRuntime.jsx(react.ComposerPrimitive.Send, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
4146
4461
  TooltipIconButton,
4147
4462
  {
@@ -4175,9 +4490,40 @@ const createMastraClient = (baseUrl) => {
4175
4490
  });
4176
4491
  };
4177
4492
 
4493
+ const fileToBase64 = async (file) => {
4494
+ return new Promise((resolve, reject) => {
4495
+ const reader = new FileReader();
4496
+ reader.onload = () => {
4497
+ const result = reader.result;
4498
+ if (typeof result === "string") {
4499
+ resolve(result);
4500
+ } else {
4501
+ reject(new Error("Failed to convert file to base64."));
4502
+ }
4503
+ };
4504
+ reader.onerror = (error) => {
4505
+ reject(error);
4506
+ };
4507
+ reader.readAsDataURL(file);
4508
+ });
4509
+ };
4510
+
4178
4511
  const convertMessage$1 = (message) => {
4179
4512
  return message;
4180
4513
  };
4514
+ const convertToAIAttachments = async (attachments) => {
4515
+ const promises = attachments.filter((attachment) => attachment.file).map(async (attachment) => ({
4516
+ role: "user",
4517
+ content: [
4518
+ {
4519
+ type: "image",
4520
+ image: await fileToBase64(attachment.file),
4521
+ mimeType: attachment.file.type
4522
+ }
4523
+ ]
4524
+ }));
4525
+ return Promise.all(promises);
4526
+ };
4181
4527
  function MastraRuntimeProvider({
4182
4528
  children,
4183
4529
  agentId,
@@ -4230,8 +4576,12 @@ function MastraRuntimeProvider({
4230
4576
  const agent = mastra.getAgent(agentId);
4231
4577
  const onNew = async (message) => {
4232
4578
  if (message.content[0]?.type !== "text") throw new Error("Only text messages are supported");
4579
+ const attachments = await convertToAIAttachments(message.attachments);
4233
4580
  const input = message.content[0].text;
4234
- setMessages((currentConversation) => [...currentConversation, { role: "user", content: input }]);
4581
+ setMessages((currentConversation) => [
4582
+ ...currentConversation,
4583
+ { role: "user", content: input, attachments: message.attachments }
4584
+ ]);
4235
4585
  setIsRunning(true);
4236
4586
  try {
4237
4587
  if (chatWithGenerate) {
@@ -4240,7 +4590,8 @@ function MastraRuntimeProvider({
4240
4590
  {
4241
4591
  role: "user",
4242
4592
  content: input
4243
- }
4593
+ },
4594
+ ...attachments
4244
4595
  ],
4245
4596
  runId: agentId,
4246
4597
  frequencyPenalty,
@@ -4349,7 +4700,8 @@ function MastraRuntimeProvider({
4349
4700
  {
4350
4701
  role: "user",
4351
4702
  content: input
4352
- }
4703
+ },
4704
+ ...attachments
4353
4705
  ],
4354
4706
  runId: agentId,
4355
4707
  frequencyPenalty,
@@ -4470,7 +4822,10 @@ function MastraRuntimeProvider({
4470
4822
  isRunning,
4471
4823
  messages,
4472
4824
  convertMessage: convertMessage$1,
4473
- onNew
4825
+ onNew,
4826
+ adapters: {
4827
+ attachments: new react.CompositeAttachmentAdapter([new react.SimpleImageAttachmentAdapter()])
4828
+ }
4474
4829
  });
4475
4830
  return /* @__PURE__ */ jsxRuntime.jsxs(react.AssistantRuntimeProvider, { runtime, children: [
4476
4831
  " ",
@@ -4552,7 +4907,8 @@ const AgentChat = ({
4552
4907
  initialMessages,
4553
4908
  memory,
4554
4909
  baseUrl,
4555
- refreshThreadList
4910
+ refreshThreadList,
4911
+ showFileSupport
4556
4912
  }) => {
4557
4913
  const { modelSettings, chatWithGenerate } = React.useContext(AgentContext);
4558
4914
  const { runtimeContext } = usePlaygroundStore();
@@ -4569,7 +4925,7 @@ const AgentChat = ({
4569
4925
  modelSettings,
4570
4926
  chatWithGenerate,
4571
4927
  runtimeContext,
4572
- children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full pb-4 bg-surface1", children: /* @__PURE__ */ jsxRuntime.jsx(Thread, { agentName: agentName ?? "", hasMemory: memory }) })
4928
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full pb-4 bg-surface1", children: /* @__PURE__ */ jsxRuntime.jsx(Thread, { agentName: agentName ?? "", hasMemory: memory, showFileSupport }) })
4573
4929
  }
4574
4930
  );
4575
4931
  };
@@ -7231,54 +7587,6 @@ const Collapsible = CollapsiblePrimitive__namespace.Root;
7231
7587
  const CollapsibleTrigger = CollapsiblePrimitive__namespace.CollapsibleTrigger;
7232
7588
  const CollapsibleContent = CollapsiblePrimitive__namespace.CollapsibleContent;
7233
7589
 
7234
- const Dialog = DialogPrimitive__namespace.Root;
7235
- const DialogPortal = DialogPrimitive__namespace.Portal;
7236
- const DialogOverlay = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
7237
- DialogPrimitive__namespace.Overlay,
7238
- {
7239
- ref,
7240
- className: cn(
7241
- "fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
7242
- className
7243
- ),
7244
- ...props
7245
- }
7246
- ));
7247
- DialogOverlay.displayName = DialogPrimitive__namespace.Overlay.displayName;
7248
- const DialogContent = React__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(DialogPortal, { children: [
7249
- /* @__PURE__ */ jsxRuntime.jsx(DialogOverlay, {}),
7250
- /* @__PURE__ */ jsxRuntime.jsxs(
7251
- DialogPrimitive__namespace.Content,
7252
- {
7253
- ref,
7254
- className: cn(
7255
- "fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
7256
- className
7257
- ),
7258
- ...props,
7259
- children: [
7260
- children,
7261
- /* @__PURE__ */ jsxRuntime.jsxs(DialogPrimitive__namespace.Close, { className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground", children: [
7262
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "h-4 w-4" }),
7263
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Close" })
7264
- ] })
7265
- ]
7266
- }
7267
- )
7268
- ] }));
7269
- DialogContent.displayName = DialogPrimitive__namespace.Content.displayName;
7270
- const DialogTitle = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
7271
- DialogPrimitive__namespace.Title,
7272
- {
7273
- ref,
7274
- className: cn("text-lg font-semibold leading-none tracking-tight", className),
7275
- ...props
7276
- }
7277
- ));
7278
- DialogTitle.displayName = DialogPrimitive__namespace.Title.displayName;
7279
- const DialogDescription = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Description, { ref, className: cn("text-sm text-muted-foreground", className), ...props }));
7280
- DialogDescription.displayName = DialogPrimitive__namespace.Description.displayName;
7281
-
7282
7590
  const ScrollArea = React__namespace.forwardRef(
7283
7591
  ({ className, children, viewPortClassName, maxHeight, autoScroll = false, ...props }, ref) => {
7284
7592
  const areaRef = React__namespace.useRef(null);
@@ -9428,6 +9736,7 @@ exports.AgentCoinIcon = AgentCoinIcon;
9428
9736
  exports.AgentContext = AgentContext;
9429
9737
  exports.AgentEvals = AgentEvals;
9430
9738
  exports.AgentIcon = AgentIcon;
9739
+ exports.AgentNetworkCoinIcon = AgentNetworkCoinIcon;
9431
9740
  exports.AgentProvider = AgentProvider;
9432
9741
  exports.AgentTraces = AgentTraces;
9433
9742
  exports.AiIcon = AiIcon;
@@ -9500,6 +9809,7 @@ exports.ThreadItem = ThreadItem;
9500
9809
  exports.ThreadLink = ThreadLink;
9501
9810
  exports.ThreadList = ThreadList;
9502
9811
  exports.Threads = Threads;
9812
+ exports.ToolCoinIcon = ToolCoinIcon;
9503
9813
  exports.ToolsIcon = ToolsIcon;
9504
9814
  exports.TraceContext = TraceContext;
9505
9815
  exports.TraceIcon = TraceIcon;
@@ -9519,5 +9829,6 @@ exports.WorkflowTrigger = WorkflowTrigger;
9519
9829
  exports.refineTraces = refineTraces;
9520
9830
  exports.usePlaygroundStore = usePlaygroundStore;
9521
9831
  exports.usePolling = usePolling;
9832
+ exports.useSpeechRecognition = useSpeechRecognition;
9522
9833
  exports.useTraces = useTraces;
9523
9834
  //# sourceMappingURL=index.cjs.js.map