@mastra/playground-ui 5.1.11-alpha.0 → 5.1.11-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.es.js CHANGED
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  import React__default, { createContext, useContext, forwardRef, useState, useEffect, memo, useRef, useCallback, useMemo, Suspense, Fragment as Fragment$1 } from 'react';
4
4
  import { MastraClient } from '@mastra/client-js';
5
5
  import { useMessage, MessagePrimitive, ActionBarPrimitive, useComposerRuntime, ComposerPrimitive, useAttachment, AttachmentPrimitive, ThreadPrimitive, useExternalStoreRuntime, CompositeAttachmentAdapter, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, AssistantRuntimeProvider } from '@assistant-ui/react';
6
- import { CheckIcon as CheckIcon$1, CopyIcon, Check, Copy, ChevronUpIcon, X, FileText, FileIcon, CircleXIcon, Mic, PlusIcon, ArrowUp, Search, RefreshCcwIcon, ChevronRight, SortAsc, SortDesc, ChevronUp, ChevronDown, Circle, RefreshCw, LoaderCircle, ChevronDownIcon, ExternalLinkIcon, Braces, Loader2, Network, PauseIcon, HourglassIcon, CircleDashed, Footprints, CircleCheck, CircleX, Minus, Plus, Maximize, Workflow, AlertCircleIcon, AlertCircle, CalendarIcon, Brackets, TrashIcon, CirclePause } from 'lucide-react';
6
+ import { CheckIcon as CheckIcon$1, CopyIcon, Check, Copy, ChevronUpIcon, X, FileText, FileIcon, CircleXIcon, Mic, PlusIcon, ArrowUp, Search, RefreshCcwIcon, ChevronRight, SortAsc, SortDesc, ChevronUp, ChevronDown, Circle, RefreshCw, LoaderCircle, ChevronDownIcon, ExternalLinkIcon, Braces, Loader2, Network, PauseIcon, HourglassIcon, CircleDashed, Footprints, CircleCheck, CircleX, Minus, Plus, Maximize, Workflow, AlertCircleIcon, AlertCircle, CalendarIcon, Brackets, TrashIcon, CirclePause, StopCircle } from 'lucide-react';
7
7
  import { Slot } from '@radix-ui/react-slot';
8
8
  import * as TooltipPrimitive from '@radix-ui/react-tooltip';
9
9
  import { TooltipProvider as TooltipProvider$1 } from '@radix-ui/react-tooltip';
@@ -3206,7 +3206,7 @@ const ImageWithFallback = ({ alt, src, ...rest }) => {
3206
3206
  );
3207
3207
  };
3208
3208
 
3209
- const SyntaxHighlighter$2 = makePrismAsyncSyntaxHighlighter({
3209
+ const SyntaxHighlighter$3 = makePrismAsyncSyntaxHighlighter({
3210
3210
  style: coldarkDark,
3211
3211
  customStyle: {
3212
3212
  margin: 0,
@@ -3425,7 +3425,7 @@ const defaultComponents = unstable_memoizeMarkdownComponents({
3425
3425
  );
3426
3426
  },
3427
3427
  CodeHeader,
3428
- SyntaxHighlighter: SyntaxHighlighter$2,
3428
+ SyntaxHighlighter: SyntaxHighlighter$3,
3429
3429
  img: ImageWithFallback
3430
3430
  });
3431
3431
 
@@ -4304,7 +4304,7 @@ const useCodemirrorTheme$1 = () => {
4304
4304
  []
4305
4305
  );
4306
4306
  };
4307
- const SyntaxHighlighter$1 = ({ data, className }) => {
4307
+ const SyntaxHighlighter$2 = ({ data, className }) => {
4308
4308
  const formattedCode = JSON.stringify(data, null, 2);
4309
4309
  const theme = useCodemirrorTheme$1();
4310
4310
  return /* @__PURE__ */ jsxs("div", { className: clsx("rounded-md bg-surface4 p-1 font-mono relative", className), children: [
@@ -4331,7 +4331,7 @@ const ToolFallback$1 = ({ toolName, argsText, result }) => {
4331
4331
  let argSlot;
4332
4332
  try {
4333
4333
  const parsedArgs = JSON.parse(argsText);
4334
- argSlot = /* @__PURE__ */ jsx(SyntaxHighlighter$1, { data: parsedArgs });
4334
+ argSlot = /* @__PURE__ */ jsx(SyntaxHighlighter$2, { data: parsedArgs });
4335
4335
  } catch {
4336
4336
  argSlot = /* @__PURE__ */ jsx("pre", { className: "whitespace-pre-wrap", children: argsText });
4337
4337
  }
@@ -4347,7 +4347,7 @@ const ToolFallback$1 = ({ toolName, argsText, result }) => {
4347
4347
  ] }),
4348
4348
  result !== void 0 && /* @__PURE__ */ jsxs("div", { className: "px-4 py-2", children: [
4349
4349
  /* @__PURE__ */ jsx("p", { className: "font-medium pb-2", children: "Tool result" }),
4350
- typeof result === "string" ? /* @__PURE__ */ jsx("pre", { className: "whitespace-pre-wrap", children: result }) : /* @__PURE__ */ jsx(SyntaxHighlighter$1, { data: result })
4350
+ typeof result === "string" ? /* @__PURE__ */ jsx("pre", { className: "whitespace-pre-wrap", children: result }) : /* @__PURE__ */ jsx(SyntaxHighlighter$2, { data: result })
4351
4351
  ] })
4352
4352
  ] }) })
4353
4353
  ] });
@@ -4728,7 +4728,7 @@ const SpeechInput$1 = () => {
4728
4728
  variant: "ghost",
4729
4729
  className: "rounded-full",
4730
4730
  onClick: () => isListening ? stop() : start(),
4731
- children: isListening ? /* @__PURE__ */ jsx(CircleStopIcon$2, {}) : /* @__PURE__ */ jsx(Mic, { className: "h-6 w-6 text-[#898989] hover:text-[#fff]" })
4731
+ children: isListening ? /* @__PURE__ */ jsx(CircleStopIcon$1, {}) : /* @__PURE__ */ jsx(Mic, { className: "h-6 w-6 text-[#898989] hover:text-[#fff]" })
4732
4732
  }
4733
4733
  );
4734
4734
  };
@@ -4744,7 +4744,7 @@ const ComposerAction$1 = ({ showFileSupport }) => {
4744
4744
  children: /* @__PURE__ */ jsx(ArrowUp, { className: "h-6 w-6 text-[#898989] hover:text-[#fff]" })
4745
4745
  }
4746
4746
  ) }) }),
4747
- /* @__PURE__ */ jsx(ThreadPrimitive.If, { running: true, children: /* @__PURE__ */ jsx(ComposerPrimitive.Cancel, { asChild: true, children: /* @__PURE__ */ jsx(TooltipIconButton, { tooltip: "Cancel", variant: "default", children: /* @__PURE__ */ jsx(CircleStopIcon$2, {}) }) }) })
4747
+ /* @__PURE__ */ jsx(ThreadPrimitive.If, { running: true, children: /* @__PURE__ */ jsx(ComposerPrimitive.Cancel, { asChild: true, children: /* @__PURE__ */ jsx(TooltipIconButton, { tooltip: "Cancel", variant: "default", children: /* @__PURE__ */ jsx(CircleStopIcon$1, {}) }) }) })
4748
4748
  ] });
4749
4749
  };
4750
4750
  const EditComposer$1 = () => {
@@ -4756,7 +4756,7 @@ const EditComposer$1 = () => {
4756
4756
  ] })
4757
4757
  ] });
4758
4758
  };
4759
- const CircleStopIcon$2 = () => {
4759
+ const CircleStopIcon$1 = () => {
4760
4760
  return /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", fill: "currentColor", width: "16", height: "16", children: /* @__PURE__ */ jsx("rect", { width: "10", height: "10", x: "3", y: "3", rx: "2" }) });
4761
4761
  };
4762
4762
 
@@ -6317,7 +6317,7 @@ const useCodemirrorTheme = () => {
6317
6317
  []
6318
6318
  );
6319
6319
  };
6320
- const SyntaxHighlighter = ({ data }) => {
6320
+ const SyntaxHighlighter$1 = ({ data }) => {
6321
6321
  const formattedCode = JSON.stringify(data, null, 2);
6322
6322
  const theme = useCodemirrorTheme();
6323
6323
  return /* @__PURE__ */ jsx("div", { className: "rounded-md bg-[#1a1a1a] p-1 font-mono", children: /* @__PURE__ */ jsx(CodeMirror, { value: formattedCode, theme, extensions: [jsonLanguage] }) });
@@ -6432,10 +6432,10 @@ const AttributeValue = ({ value }) => {
6432
6432
  return /* @__PURE__ */ jsx(Txt, { as: "p", variant: "ui-md", className: "text-icon6", children: String(value) });
6433
6433
  }
6434
6434
  if (typeof value === "object") {
6435
- return /* @__PURE__ */ jsx(SyntaxHighlighter, { data: value });
6435
+ return /* @__PURE__ */ jsx(SyntaxHighlighter$1, { data: value });
6436
6436
  }
6437
6437
  try {
6438
- return /* @__PURE__ */ jsx(SyntaxHighlighter, { data: JSON.parse(value) });
6438
+ return /* @__PURE__ */ jsx(SyntaxHighlighter$1, { data: JSON.parse(value) });
6439
6439
  } catch {
6440
6440
  return /* @__PURE__ */ jsx(Txt, { as: "p", variant: "ui-md", className: "text-icon6", children: String(value) });
6441
6441
  }
@@ -8147,7 +8147,7 @@ const WorkflowRunEventForm = ({ event, runId, onSendEvent }) => {
8147
8147
  const formatted = await formatJSON(eventData);
8148
8148
  setEventData(formatted);
8149
8149
  };
8150
- return /* @__PURE__ */ jsxs("div", { children: [
8150
+ return /* @__PURE__ */ jsxs(TooltipProvider, { children: [
8151
8151
  /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
8152
8152
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between pb-2", children: [
8153
8153
  /* @__PURE__ */ jsx(Txt, { as: "label", variant: "ui-md", className: "text-icon3", children: "Event data (JSON)" }),
@@ -8254,7 +8254,7 @@ const WorkflowStepActionBar = ({
8254
8254
  ] }),
8255
8255
  onShowTrace && /* @__PURE__ */ jsx(Button, { onClick: onShowTrace, children: "Show trace" }),
8256
8256
  showEventForm && /* @__PURE__ */ jsxs(Fragment, { children: [
8257
- /* @__PURE__ */ jsx(Button, { onClick: () => setIsEventFormOpen(true), children: "Send event" }),
8257
+ /* @__PURE__ */ jsx(Button, { className: "ring-1 ring-accent5 !text-accent5", onClick: () => setIsEventFormOpen(true), children: "Send event" }),
8258
8258
  /* @__PURE__ */ jsx(Dialog, { open: isEventFormOpen, onOpenChange: setIsEventFormOpen, children: /* @__PURE__ */ jsxs(DialogContent, { className: dialogContentClass, children: [
8259
8259
  /* @__PURE__ */ jsxs(DialogTitle, { className: dialogTitleClass, children: [
8260
8260
  "Send ",
@@ -9313,7 +9313,7 @@ const SpeechInput = () => {
9313
9313
  variant: "ghost",
9314
9314
  className: "rounded-full",
9315
9315
  onClick: () => isListening ? stop() : start(),
9316
- children: isListening ? /* @__PURE__ */ jsx(CircleStopIcon$1, {}) : /* @__PURE__ */ jsx(Mic, { className: "h-6 w-6 text-[#898989] hover:text-[#fff]" })
9316
+ children: isListening ? /* @__PURE__ */ jsx(CircleStopIcon, {}) : /* @__PURE__ */ jsx(Mic, { className: "h-6 w-6 text-[#898989] hover:text-[#fff]" })
9317
9317
  }
9318
9318
  );
9319
9319
  };
@@ -9329,7 +9329,7 @@ const ComposerAction = ({ showFileSupport }) => {
9329
9329
  children: /* @__PURE__ */ jsx(ArrowUp, { className: "h-6 w-6 text-[#898989] hover:text-[#fff]" })
9330
9330
  }
9331
9331
  ) }) }),
9332
- /* @__PURE__ */ jsx(ThreadPrimitive.If, { running: true, children: /* @__PURE__ */ jsx(ComposerPrimitive.Cancel, { asChild: true, children: /* @__PURE__ */ jsx(TooltipIconButton, { tooltip: "Cancel", variant: "default", children: /* @__PURE__ */ jsx(CircleStopIcon$1, {}) }) }) })
9332
+ /* @__PURE__ */ jsx(ThreadPrimitive.If, { running: true, children: /* @__PURE__ */ jsx(ComposerPrimitive.Cancel, { asChild: true, children: /* @__PURE__ */ jsx(TooltipIconButton, { tooltip: "Cancel", variant: "default", children: /* @__PURE__ */ jsx(CircleStopIcon, {}) }) }) })
9333
9333
  ] });
9334
9334
  };
9335
9335
  const EditComposer = () => {
@@ -9341,7 +9341,7 @@ const EditComposer = () => {
9341
9341
  ] })
9342
9342
  ] });
9343
9343
  };
9344
- const CircleStopIcon$1 = () => {
9344
+ const CircleStopIcon = () => {
9345
9345
  return /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", fill: "currentColor", width: "16", height: "16", children: /* @__PURE__ */ jsx("rect", { width: "10", height: "10", x: "3", y: "3", rx: "2" }) });
9346
9346
  };
9347
9347
 
@@ -11087,12 +11087,88 @@ const WorkflowStatus = ({ stepId, status, result }) => {
11087
11087
  ] }),
11088
11088
  children: /* @__PURE__ */ jsxs("div", { className: "rounded-md bg-surface4 p-1 font-mono relative", children: [
11089
11089
  /* @__PURE__ */ jsx(CopyButton, { content: JSON.stringify(result, null, 2), className: "absolute top-2 right-2 z-10" }),
11090
- /* @__PURE__ */ jsx(SyntaxHighlighter, { data: result })
11090
+ /* @__PURE__ */ jsx(SyntaxHighlighter$1, { data: result })
11091
11091
  ] })
11092
11092
  }
11093
11093
  );
11094
11094
  };
11095
11095
 
11096
+ const WorkflowInputData = ({
11097
+ schema,
11098
+ defaultValues,
11099
+ isSubmitLoading,
11100
+ submitButtonLabel,
11101
+ onSubmit
11102
+ }) => {
11103
+ const [type, setType] = useState("form");
11104
+ return /* @__PURE__ */ jsxs("div", { children: [
11105
+ /* @__PURE__ */ jsx(RadioGroup, { value: type, onValueChange: (value) => setType(value), className: "pb-4", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-row gap-4", children: [
11106
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
11107
+ /* @__PURE__ */ jsx(RadioGroupItem, { value: "form", id: "form" }),
11108
+ /* @__PURE__ */ jsx(Label, { htmlFor: "form", className: "!text-icon3 text-ui-sm", children: "Form" })
11109
+ ] }),
11110
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
11111
+ /* @__PURE__ */ jsx(RadioGroupItem, { value: "json", id: "json" }),
11112
+ /* @__PURE__ */ jsx(Label, { htmlFor: "json", className: "!text-icon3 text-ui-sm", children: "JSON" })
11113
+ ] })
11114
+ ] }) }),
11115
+ type === "form" ? /* @__PURE__ */ jsx(
11116
+ DynamicForm,
11117
+ {
11118
+ schema,
11119
+ defaultValues,
11120
+ isSubmitLoading,
11121
+ submitButtonLabel,
11122
+ onSubmit
11123
+ }
11124
+ ) : /* @__PURE__ */ jsx(
11125
+ JSONInput,
11126
+ {
11127
+ schema,
11128
+ defaultValues,
11129
+ isSubmitLoading,
11130
+ submitButtonLabel,
11131
+ onSubmit
11132
+ }
11133
+ )
11134
+ ] });
11135
+ };
11136
+ const JSONInput = ({ schema, defaultValues, isSubmitLoading, submitButtonLabel, onSubmit }) => {
11137
+ const [errors, setErrors] = useState([]);
11138
+ const [inputData, setInputData] = useState(JSON.stringify(defaultValues ?? {}, null, 2));
11139
+ const handleSubmit = () => {
11140
+ setErrors([]);
11141
+ try {
11142
+ const result = schema.safeParse(JSON.parse(inputData));
11143
+ if (!result.success) {
11144
+ setErrors(result.error.issues.map((e) => `[${e.path.join(".")}] ${e.message}`));
11145
+ } else {
11146
+ onSubmit(result.data);
11147
+ }
11148
+ } catch (e) {
11149
+ setErrors(["Invalid JSON provided"]);
11150
+ }
11151
+ };
11152
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4", children: [
11153
+ errors.length > 0 && /* @__PURE__ */ jsxs("div", { className: "border-sm border-accent2 rounded-lg p-2", children: [
11154
+ /* @__PURE__ */ jsxs(Txt, { as: "p", variant: "ui-md", className: "text-accent2 font-semibold", children: [
11155
+ errors.length,
11156
+ " errors found"
11157
+ ] }),
11158
+ /* @__PURE__ */ jsx("ul", { className: "list-disc list-inside", children: errors.map((error, idx) => /* @__PURE__ */ jsx("li", { className: "text-ui-sm text-accent2", children: error }, idx)) })
11159
+ ] }),
11160
+ /* @__PURE__ */ jsx(SyntaxHighlighter, { data: inputData, onChange: setInputData }),
11161
+ /* @__PURE__ */ jsx(Button, { variant: "light", onClick: handleSubmit, className: "w-full", size: "lg", children: isSubmitLoading ? /* @__PURE__ */ jsx(Loader2, { className: "animate-spin" }) : submitButtonLabel })
11162
+ ] });
11163
+ };
11164
+ const SyntaxHighlighter = ({ data, onChange }) => {
11165
+ const theme = useCodemirrorTheme$1();
11166
+ return /* @__PURE__ */ jsxs("div", { className: "rounded-md bg-[#1a1a1a] p-1 font-mono", children: [
11167
+ /* @__PURE__ */ jsx(CopyButton, { content: data, className: "absolute top-2 right-2 z-10" }),
11168
+ /* @__PURE__ */ jsx(CodeMirror, { value: data, theme, extensions: [jsonLanguage], onChange })
11169
+ ] });
11170
+ };
11171
+
11096
11172
  function WorkflowTrigger({
11097
11173
  workflowId,
11098
11174
  setRunId,
@@ -11178,24 +11254,12 @@ function WorkflowTrigger({
11178
11254
  const hasWorkflowActivePaths = Object.values(workflowActivePaths).length > 0;
11179
11255
  return /* @__PURE__ */ jsxs("div", { className: "h-full pt-3 pb-12", children: [
11180
11256
  /* @__PURE__ */ jsxs("div", { className: "space-y-4 px-5 pb-5 border-b-sm border-border1", children: [
11181
- result?.runId && /* @__PURE__ */ jsxs(
11182
- Button,
11183
- {
11184
- variant: "light",
11185
- onClick: handleCancelWorkflowRun,
11186
- disabled: !!cancelResponse?.message || isCancellingWorkflowRun,
11187
- children: [
11188
- isCancellingWorkflowRun ? /* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(Loader2, { className: "animate-spin" }) }) : /* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(CircleStopIcon, {}) }),
11189
- cancelResponse?.message || "Cancel Workflow Run"
11190
- ]
11191
- }
11192
- ),
11193
11257
  (isResumingWorkflow || isSuspendedSteps && isStreamingWorkflow) && /* @__PURE__ */ jsxs("div", { className: "py-2 px-5 flex items-center gap-2 bg-surface5 -mx-5 -mt-5 border-b-sm border-border1", children: [
11194
11258
  /* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(Loader2, { className: "animate-spin text-icon6" }) }),
11195
11259
  /* @__PURE__ */ jsx(Txt, { children: "Resuming workflow" })
11196
11260
  ] }),
11197
11261
  !isSuspendedSteps && /* @__PURE__ */ jsx(Fragment, { children: zodInputSchema ? /* @__PURE__ */ jsx(
11198
- DynamicForm,
11262
+ WorkflowInputData,
11199
11263
  {
11200
11264
  schema: zodInputSchema,
11201
11265
  defaultValues: payload,
@@ -11231,7 +11295,7 @@ function WorkflowTrigger({
11231
11295
  }
11232
11296
  ) }),
11233
11297
  /* @__PURE__ */ jsx(
11234
- DynamicForm,
11298
+ WorkflowInputData,
11235
11299
  {
11236
11300
  schema: stepSchema,
11237
11301
  isSubmitLoading: isResumingWorkflow,
@@ -11248,6 +11312,20 @@ function WorkflowTrigger({
11248
11312
  )
11249
11313
  ] }, step.stepId);
11250
11314
  }),
11315
+ result?.runId && /* @__PURE__ */ jsxs(
11316
+ Button,
11317
+ {
11318
+ variant: "light",
11319
+ className: "w-full",
11320
+ size: "lg",
11321
+ onClick: handleCancelWorkflowRun,
11322
+ disabled: !!cancelResponse?.message || isCancellingWorkflowRun,
11323
+ children: [
11324
+ isCancellingWorkflowRun ? /* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(Loader2, { className: "animate-spin" }) }) : /* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(StopCircle, {}) }),
11325
+ cancelResponse?.message || "Cancel Workflow Run"
11326
+ ]
11327
+ }
11328
+ ),
11251
11329
  hasWorkflowActivePaths && /* @__PURE__ */ jsxs(Fragment, { children: [
11252
11330
  /* @__PURE__ */ jsx("hr", { className: "border-border1 border-sm my-5" }),
11253
11331
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
@@ -11270,13 +11348,10 @@ const WorkflowJsonDialog = ({ result }) => {
11270
11348
  ] }),
11271
11349
  /* @__PURE__ */ jsx(Dialog, { open, onOpenChange: setOpen, children: /* @__PURE__ */ jsx(DialogPortal, { children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-w-6xl max-h-[90vh] overflow-y-auto overflow-x-hidden bg-surface2", children: [
11272
11350
  /* @__PURE__ */ jsx(DialogTitle, { children: "Workflow Execution (JSON)" }),
11273
- /* @__PURE__ */ jsx("div", { className: "w-full h-full overflow-x-scroll", children: /* @__PURE__ */ jsx(SyntaxHighlighter$1, { data: result, className: "p-4" }) })
11351
+ /* @__PURE__ */ jsx("div", { className: "w-full h-full overflow-x-scroll", children: /* @__PURE__ */ jsx(SyntaxHighlighter$2, { data: result, className: "p-4" }) })
11274
11352
  ] }) }) })
11275
11353
  ] });
11276
11354
  };
11277
- const CircleStopIcon = () => {
11278
- return /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", fill: "currentColor", width: "16", height: "16", children: /* @__PURE__ */ jsx("rect", { width: "10", height: "10", x: "3", y: "3", rx: "2" }) });
11279
- };
11280
11355
 
11281
11356
  const WorkflowRuns = ({ workflowId, runId, isLoading, runs, onPressRun }) => {
11282
11357
  if (isLoading) {