@mastra/playground-ui 5.1.1-alpha.2 → 5.1.1-alpha.4

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.
@@ -0,0 +1,26 @@
1
+ const Colors = {
2
+ surface1: "#000000",
3
+ surface2: "#0F0F0F",
4
+ surface3: "#141414",
5
+ surface4: "#1A1A1A",
6
+ surface5: "rgba(46, 46, 46, 0.9)",
7
+ accent1: "#1AFB6F",
8
+ accent2: "#FF4931",
9
+ accent3: "#267AD2",
10
+ accent4: "#9E57B3"
11
+ };
12
+ const BorderColors = {
13
+ border1: "rgba(48, 48, 48, 1)",
14
+ border2: "rgba(66, 66, 66, 1)"
15
+ };
16
+ const IconColors = {
17
+ icon1: "#5C5C5C",
18
+ icon2: "#707070",
19
+ icon3: "#939393",
20
+ icon4: "#A9A9A9",
21
+ icon5: "#E6E6E6",
22
+ icon6: "#FFFFFF"
23
+ };
24
+
25
+ export { BorderColors as B, Colors as C, IconColors as I };
26
+ //# sourceMappingURL=colors-CBG_Mm7P.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colors-CBG_Mm7P.js","sources":["../src/ds/tokens/colors.ts"],"sourcesContent":["export const Colors = {\n surface1: '#000000',\n surface2: '#0F0F0F',\n surface3: '#141414',\n surface4: '#1A1A1A',\n surface5: 'rgba(46, 46, 46, 0.9)',\n accent1: '#1AFB6F',\n accent2: '#FF4931',\n accent3: '#267AD2',\n accent4: '#9E57B3',\n};\n\nexport const BorderColors = {\n border1: 'rgba(48, 48, 48, 1)',\n border2: 'rgba(66, 66, 66, 1)',\n};\n\nexport const IconColors = {\n icon1: '#5C5C5C',\n icon2: '#707070',\n icon3: '#939393',\n icon4: '#A9A9A9',\n icon5: '#E6E6E6',\n icon6: '#FFFFFF',\n};\n"],"names":[],"mappings":"AAAO,MAAM,MAAS,GAAA;AAAA,EACpB,QAAU,EAAA,SAAA;AAAA,EACV,QAAU,EAAA,SAAA;AAAA,EACV,QAAU,EAAA,SAAA;AAAA,EACV,QAAU,EAAA,SAAA;AAAA,EACV,QAAU,EAAA,uBAAA;AAAA,EACV,OAAS,EAAA,SAAA;AAAA,EACT,OAAS,EAAA,SAAA;AAAA,EACT,OAAS,EAAA,SAAA;AAAA,EACT,OAAS,EAAA;AACX;AAEO,MAAM,YAAe,GAAA;AAAA,EAC1B,OAAS,EAAA,qBAAA;AAAA,EACT,OAAS,EAAA;AACX;AAEO,MAAM,UAAa,GAAA;AAAA,EACxB,KAAO,EAAA,SAAA;AAAA,EACP,KAAO,EAAA,SAAA;AAAA,EACP,KAAO,EAAA,SAAA;AAAA,EACP,KAAO,EAAA,SAAA;AAAA,EACP,KAAO,EAAA,SAAA;AAAA,EACP,KAAO,EAAA;AACT;;;;"}
@@ -0,0 +1,30 @@
1
+ 'use strict';
2
+
3
+ const Colors = {
4
+ surface1: "#000000",
5
+ surface2: "#0F0F0F",
6
+ surface3: "#141414",
7
+ surface4: "#1A1A1A",
8
+ surface5: "rgba(46, 46, 46, 0.9)",
9
+ accent1: "#1AFB6F",
10
+ accent2: "#FF4931",
11
+ accent3: "#267AD2",
12
+ accent4: "#9E57B3"
13
+ };
14
+ const BorderColors = {
15
+ border1: "rgba(48, 48, 48, 1)",
16
+ border2: "rgba(66, 66, 66, 1)"
17
+ };
18
+ const IconColors = {
19
+ icon1: "#5C5C5C",
20
+ icon2: "#707070",
21
+ icon3: "#939393",
22
+ icon4: "#A9A9A9",
23
+ icon5: "#E6E6E6",
24
+ icon6: "#FFFFFF"
25
+ };
26
+
27
+ exports.BorderColors = BorderColors;
28
+ exports.Colors = Colors;
29
+ exports.IconColors = IconColors;
30
+ //# sourceMappingURL=colors-Du4i-E0i.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colors-Du4i-E0i.cjs","sources":["../src/ds/tokens/colors.ts"],"sourcesContent":["export const Colors = {\n surface1: '#000000',\n surface2: '#0F0F0F',\n surface3: '#141414',\n surface4: '#1A1A1A',\n surface5: 'rgba(46, 46, 46, 0.9)',\n accent1: '#1AFB6F',\n accent2: '#FF4931',\n accent3: '#267AD2',\n accent4: '#9E57B3',\n};\n\nexport const BorderColors = {\n border1: 'rgba(48, 48, 48, 1)',\n border2: 'rgba(66, 66, 66, 1)',\n};\n\nexport const IconColors = {\n icon1: '#5C5C5C',\n icon2: '#707070',\n icon3: '#939393',\n icon4: '#A9A9A9',\n icon5: '#E6E6E6',\n icon6: '#FFFFFF',\n};\n"],"names":[],"mappings":";;AAAO,MAAM,MAAS,GAAA;AAAA,EACpB,QAAU,EAAA,SAAA;AAAA,EACV,QAAU,EAAA,SAAA;AAAA,EACV,QAAU,EAAA,SAAA;AAAA,EACV,QAAU,EAAA,SAAA;AAAA,EACV,QAAU,EAAA,uBAAA;AAAA,EACV,OAAS,EAAA,SAAA;AAAA,EACT,OAAS,EAAA,SAAA;AAAA,EACT,OAAS,EAAA,SAAA;AAAA,EACT,OAAS,EAAA;AACX;AAEO,MAAM,YAAe,GAAA;AAAA,EAC1B,OAAS,EAAA,qBAAA;AAAA,EACT,OAAS,EAAA;AACX;AAEO,MAAM,UAAa,GAAA;AAAA,EACxB,KAAO,EAAA,SAAA;AAAA,EACP,KAAO,EAAA,SAAA;AAAA,EACP,KAAO,EAAA,SAAA;AAAA,EACP,KAAO,EAAA,SAAA;AAAA,EACP,KAAO,EAAA,SAAA;AAAA,EACP,KAAO,EAAA;AACT;;;;;;"}
package/dist/index.cjs.js CHANGED
@@ -28,6 +28,7 @@ const dateFns = require('date-fns');
28
28
  const TabsPrimitive = require('@radix-ui/react-tabs');
29
29
  const sonner = require('sonner');
30
30
  const react$1 = require('motion/react');
31
+ const colors = require('./colors-Du4i-E0i.cjs');
31
32
  const uiUtils = require('@ai-sdk/ui-utils');
32
33
  const Markdown = require('react-markdown');
33
34
  const useDebounce = require('use-debounce');
@@ -50,6 +51,7 @@ const uuid = require('@lukeed/uuid');
50
51
  const zod = require('@autoform/zod');
51
52
  const LabelPrimitive = require('@radix-ui/react-label');
52
53
  const reactCodeBlock = require('react-code-block');
54
+ const SliderPrimitive = require('@radix-ui/react-slider');
53
55
  const reactTable = require('@tanstack/react-table');
54
56
 
55
57
  function _interopNamespaceDefault(e) {
@@ -80,6 +82,7 @@ const CheckboxPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(Check
80
82
  const PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(PopoverPrimitive);
81
83
  const SelectPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(SelectPrimitive);
82
84
  const LabelPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(LabelPrimitive);
85
+ const SliderPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(SliderPrimitive);
83
86
 
84
87
  function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
85
88
 
@@ -4140,7 +4143,7 @@ const DialogTitle = React__namespace.forwardRef(({ className, ...props }, ref) =
4140
4143
  DialogPrimitive__namespace.Title,
4141
4144
  {
4142
4145
  ref,
4143
- className: cn("text-lg font-semibold leading-none tracking-tight", className),
4146
+ className: clsx("text-lg font-semibold leading-none tracking-tight", className),
4144
4147
  ...props
4145
4148
  }
4146
4149
  ));
@@ -4855,23 +4858,47 @@ const defaultModelSettings$1 = {
4855
4858
  topP: 1
4856
4859
  };
4857
4860
  const AgentContext = React.createContext({});
4858
- function AgentProvider({ agentId, children }) {
4861
+ function AgentProvider({
4862
+ agentId,
4863
+ defaultGenerateOptions,
4864
+ defaultStreamOptions,
4865
+ children
4866
+ }) {
4859
4867
  const {
4860
4868
  modelSettings: modelSettingsStore,
4861
4869
  setModelSettings: setModelSettingsStore,
4862
4870
  chatWithGenerate: chatWithGenerateStore,
4863
4871
  setChatWithGenerate: setChatWithGenerateStore
4864
4872
  } = useAgentStore();
4865
- const modelSettings = modelSettingsStore[agentId] || defaultModelSettings$1;
4873
+ const chatWithGenerate = chatWithGenerateStore[agentId] || false;
4874
+ const setChatWithGenerate = (chatWithGenerate2) => {
4875
+ setChatWithGenerateStore({ [agentId]: chatWithGenerate2 });
4876
+ };
4877
+ const modelSettings = React.useMemo(() => {
4878
+ if (modelSettingsStore[agentId]) return modelSettingsStore[agentId];
4879
+ if (chatWithGenerate) {
4880
+ return {
4881
+ maxRetries: defaultGenerateOptions?.maxRetries ?? defaultModelSettings$1.maxRetries,
4882
+ maxSteps: defaultGenerateOptions?.maxSteps ?? defaultModelSettings$1.maxSteps,
4883
+ temperature: defaultGenerateOptions?.temperature ?? defaultModelSettings$1.temperature,
4884
+ topP: defaultGenerateOptions?.topP ?? defaultModelSettings$1.topP,
4885
+ ...defaultGenerateOptions
4886
+ };
4887
+ } else {
4888
+ return {
4889
+ maxRetries: defaultStreamOptions?.maxRetries ?? defaultModelSettings$1.maxRetries,
4890
+ maxSteps: defaultStreamOptions?.maxSteps ?? defaultModelSettings$1.maxSteps,
4891
+ temperature: defaultStreamOptions?.temperature ?? defaultModelSettings$1.temperature,
4892
+ topP: defaultStreamOptions?.topP ?? defaultModelSettings$1.topP,
4893
+ ...defaultStreamOptions
4894
+ };
4895
+ }
4896
+ }, [agentId, defaultGenerateOptions, defaultStreamOptions, chatWithGenerate, modelSettingsStore]);
4866
4897
  const setModelSettings = (modelSettings2) => {
4867
4898
  setModelSettingsStore({ [agentId]: modelSettings2 });
4868
4899
  };
4869
4900
  const resetModelSettings = () => {
4870
- setModelSettings(defaultModelSettings$1);
4871
- };
4872
- const chatWithGenerate = chatWithGenerateStore[agentId] || false;
4873
- const setChatWithGenerate = (chatWithGenerate2) => {
4874
- setChatWithGenerateStore({ [agentId]: chatWithGenerate2 });
4901
+ setModelSettingsStore({ [agentId]: null });
4875
4902
  };
4876
4903
  return /* @__PURE__ */ jsxRuntime.jsx(
4877
4904
  AgentContext.Provider,
@@ -5977,7 +6004,7 @@ const useCodemirrorTheme = () => {
5977
6004
  fontSize: "0.8rem",
5978
6005
  lineHighlight: "transparent",
5979
6006
  gutterBackground: "transparent",
5980
- gutterForeground: "#939393",
6007
+ gutterForeground: colors.Colors.surface3,
5981
6008
  background: "transparent"
5982
6009
  },
5983
6010
  styles: [{ tag: [highlight$1.tags.className, highlight$1.tags.propertyName] }]
@@ -7723,18 +7750,222 @@ function WorkflowConditionNode({ data }) {
7723
7750
  );
7724
7751
  }
7725
7752
 
7753
+ function convertWorkflowRunStateToWatchResult(runState) {
7754
+ const runId = runState.runId;
7755
+ const steps = {};
7756
+ const context = runState.context || {};
7757
+ Object.entries(context).forEach(([stepId, stepResult]) => {
7758
+ if (stepId !== "input" && "status" in stepResult) {
7759
+ const result = stepResult;
7760
+ steps[stepId] = {
7761
+ status: result.status,
7762
+ output: "output" in result ? result.output : void 0,
7763
+ payload: "payload" in result ? result.payload : void 0,
7764
+ resumePayload: "resumePayload" in result ? result.resumePayload : void 0,
7765
+ error: "error" in result ? result.error : void 0,
7766
+ startedAt: "startedAt" in result ? result.startedAt : Date.now(),
7767
+ endedAt: "endedAt" in result ? result.endedAt : void 0,
7768
+ suspendedAt: "suspendedAt" in result ? result.suspendedAt : void 0,
7769
+ resumedAt: "resumedAt" in result ? result.resumedAt : void 0
7770
+ };
7771
+ }
7772
+ });
7773
+ const status = determineWorkflowStatus(steps);
7774
+ return {
7775
+ type: "watch",
7776
+ payload: {
7777
+ workflowState: {
7778
+ status,
7779
+ steps,
7780
+ output: runState.value,
7781
+ payload: context.input,
7782
+ error: void 0
7783
+ }
7784
+ },
7785
+ eventTimestamp: new Date(runState.timestamp),
7786
+ runId
7787
+ };
7788
+ }
7789
+ function determineWorkflowStatus(steps) {
7790
+ const stepStatuses = Object.values(steps).map((step) => step.status);
7791
+ if (stepStatuses.includes("failed")) {
7792
+ return "failed";
7793
+ }
7794
+ if (stepStatuses.includes("suspended")) {
7795
+ return "suspended";
7796
+ }
7797
+ if (stepStatuses.every((status) => status === "success")) {
7798
+ return "success";
7799
+ }
7800
+ return "running";
7801
+ }
7802
+
7803
+ const WorkflowRunContext = React.createContext({});
7804
+ function WorkflowRunProvider({
7805
+ children,
7806
+ snapshot
7807
+ }) {
7808
+ const [legacyResult, setLegacyResult] = React.useState(null);
7809
+ const [result, setResult] = React.useState(
7810
+ () => snapshot ? convertWorkflowRunStateToWatchResult(snapshot) : null
7811
+ );
7812
+ const [payload, setPayload] = React.useState(null);
7813
+ const clearData = () => {
7814
+ setLegacyResult(null);
7815
+ setResult(null);
7816
+ setPayload(null);
7817
+ };
7818
+ React.useEffect(() => {
7819
+ if (snapshot?.runId) {
7820
+ setResult(convertWorkflowRunStateToWatchResult(snapshot));
7821
+ } else {
7822
+ setResult(null);
7823
+ }
7824
+ }, [snapshot?.runId ?? ""]);
7825
+ return /* @__PURE__ */ jsxRuntime.jsx(
7826
+ WorkflowRunContext.Provider,
7827
+ {
7828
+ value: {
7829
+ legacyResult,
7830
+ setLegacyResult,
7831
+ result,
7832
+ setResult,
7833
+ payload,
7834
+ setPayload,
7835
+ clearData
7836
+ },
7837
+ children
7838
+ }
7839
+ );
7840
+ }
7841
+
7842
+ const useCurrentRun = () => {
7843
+ const context = React.useContext(WorkflowRunContext);
7844
+ const workflowCurrentSteps = context.result?.payload?.workflowState?.steps ?? {};
7845
+ const steps = Object.entries(workflowCurrentSteps).reduce((acc, [key, value]) => {
7846
+ return {
7847
+ ...acc,
7848
+ [key]: {
7849
+ error: value.error,
7850
+ startedAt: value.startedAt,
7851
+ endedAt: value.endedAt,
7852
+ status: value.status,
7853
+ output: value.output,
7854
+ input: value.payload
7855
+ }
7856
+ };
7857
+ }, {});
7858
+ return { steps, isRunning: Boolean(context.payload) };
7859
+ };
7860
+
7726
7861
  function WorkflowDefaultNode({ data }) {
7862
+ const [isInputOpen, setIsInputOpen] = React.useState(false);
7863
+ const [isOutputOpen, setIsOutputOpen] = React.useState(false);
7864
+ const [isErrorOpen, setIsErrorOpen] = React.useState(false);
7865
+ const { steps, isRunning } = useCurrentRun();
7727
7866
  const { label, description, withoutTopHandle, withoutBottomHandle } = data;
7728
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("bg-mastra-bg-8 rounded-md w-[274px]"), children: [
7867
+ const step = steps[label];
7868
+ const dialogContentClass = "bg-surface2 rounded-lg border-sm border-border1 max-w-4xl w-full px-0";
7869
+ const dialogTitleClass = "border-b-sm border-border1 pb-4 px-6";
7870
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
7729
7871
  !withoutTopHandle && /* @__PURE__ */ jsxRuntime.jsx(react$2.Handle, { type: "target", position: react$2.Position.Top, style: { visibility: "hidden" } }),
7730
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-2", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-sm bg-mastra-bg-9 flex items-center gap-[6px] rounded-sm p-2", children: [
7731
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Footprints, { className: "text-current w-4 h-4" }),
7732
- /* @__PURE__ */ jsxRuntime.jsx(Text, { size: "xs", weight: "medium", className: "text-mastra-el-6 capitalize", children: label })
7733
- ] }) }),
7734
- description && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-mastra-bg-4 rounded-b-md p-2 text-[10px] text-left text-mastra-el-4", children: description }),
7735
- !withoutBottomHandle && /* @__PURE__ */ jsxRuntime.jsx(react$2.Handle, { type: "source", position: react$2.Position.Bottom, style: { visibility: "hidden" } })
7872
+ /* @__PURE__ */ jsxRuntime.jsxs(
7873
+ "div",
7874
+ {
7875
+ className: clsx(
7876
+ "bg-surface3 rounded-lg w-[274px] border-sm border-border1 pt-2",
7877
+ step?.status === "success" && "ring-2 ring-accent1",
7878
+ step?.status === "failed" && "ring-2 ring-accent2"
7879
+ ),
7880
+ children: [
7881
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 px-3", children: [
7882
+ isRunning && /* @__PURE__ */ jsxRuntime.jsxs(Icon, { children: [
7883
+ step?.status === "failed" && /* @__PURE__ */ jsxRuntime.jsx(CrossIcon, { className: "text-accent2" }),
7884
+ step?.status === "success" && /* @__PURE__ */ jsxRuntime.jsx(CheckIcon, { className: "text-accent1" }),
7885
+ step?.status === "suspended" && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.PauseIcon, { className: "text-icon3" }),
7886
+ step?.status === "running" && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "text-icon6 animate-spin" }),
7887
+ !step && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleDashed, { className: "text-icon2" })
7888
+ ] }),
7889
+ /* @__PURE__ */ jsxRuntime.jsxs(Txt, { variant: "ui-lg", className: "text-icon6 font-medium inline-flex items-center gap-1 justify-between w-full", children: [
7890
+ label,
7891
+ " ",
7892
+ step?.startedAt && /* @__PURE__ */ jsxRuntime.jsx(Clock, { startedAt: step.startedAt, endedAt: step.endedAt })
7893
+ ] })
7894
+ ] }),
7895
+ description && /* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-sm", className: "text-icon3 px-3 pb-2", children: description }),
7896
+ (step?.input || step?.output) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center bg-surface4 border-t-sm border-border1 px-2 py-1 gap-2", children: [
7897
+ step?.input && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
7898
+ /* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: () => setIsInputOpen(true), children: "Input" }),
7899
+ /* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: isInputOpen, onOpenChange: setIsInputOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: dialogContentClass, children: [
7900
+ /* @__PURE__ */ jsxRuntime.jsxs(DialogTitle, { className: dialogTitleClass, children: [
7901
+ label,
7902
+ " input"
7903
+ ] }),
7904
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(CodeDialogContent, { data: step.input }) })
7905
+ ] }) })
7906
+ ] }),
7907
+ step?.output && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
7908
+ /* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: () => setIsOutputOpen(true), children: "Output" }),
7909
+ /* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: isOutputOpen, onOpenChange: setIsOutputOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: dialogContentClass, children: [
7910
+ /* @__PURE__ */ jsxRuntime.jsxs(DialogTitle, { className: dialogTitleClass, children: [
7911
+ label,
7912
+ " output"
7913
+ ] }),
7914
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(CodeDialogContent, { data: step.output }) })
7915
+ ] }) })
7916
+ ] }),
7917
+ step?.error && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
7918
+ /* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: () => setIsErrorOpen(true), children: "Error" }),
7919
+ /* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: isErrorOpen, onOpenChange: setIsErrorOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: dialogContentClass, children: [
7920
+ /* @__PURE__ */ jsxRuntime.jsxs(DialogTitle, { className: dialogTitleClass, children: [
7921
+ label,
7922
+ " error"
7923
+ ] }),
7924
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(CodeDialogContent, { data: step?.error }) })
7925
+ ] }) })
7926
+ ] })
7927
+ ] })
7928
+ ]
7929
+ }
7930
+ ),
7931
+ !withoutBottomHandle && /* @__PURE__ */ jsxRuntime.jsx(react$2.Handle, { type: "source", position: react$2.Position.Bottom, style: { visibility: "hidden", color: "red" } })
7736
7932
  ] });
7737
7933
  }
7934
+ const CodeDialogContent = ({ data }) => {
7935
+ const theme = useCodemirrorTheme();
7936
+ if (typeof data !== "string") {
7937
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "max-h-[500px] overflow-auto relative p-4", children: [
7938
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute right-2 top-2 bg-surface4 rounded-full z-10", children: /* @__PURE__ */ jsxRuntime.jsx(CopyButton, { content: JSON.stringify(data, null, 2) }) }),
7939
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-surface4 rounded-lg p-4", children: /* @__PURE__ */ jsxRuntime.jsx(CodeMirror, { value: JSON.stringify(data, null, 2), theme, extensions: [langJson.jsonLanguage] }) })
7940
+ ] });
7941
+ }
7942
+ try {
7943
+ const json = JSON.parse(data);
7944
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "max-h-[500px] overflow-auto relative p-4", children: [
7945
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute right-2 top-2 bg-surface4 rounded-full z-10", children: /* @__PURE__ */ jsxRuntime.jsx(CopyButton, { content: data }) }),
7946
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-surface4 rounded-lg p-4", children: /* @__PURE__ */ jsxRuntime.jsx(CodeMirror, { value: json, theme, extensions: [langJson.jsonLanguage] }) })
7947
+ ] });
7948
+ } catch (error) {
7949
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "max-h-[500px] overflow-auto relative p-4", children: [
7950
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute right-2 top-2 bg-surface4 rounded-full z-10", children: /* @__PURE__ */ jsxRuntime.jsx(CopyButton, { content: data }) }),
7951
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-surface4 rounded-lg p-4", children: /* @__PURE__ */ jsxRuntime.jsx(CodeMirror, { value: data, theme, extensions: [] }) })
7952
+ ] });
7953
+ }
7954
+ };
7955
+ const Clock = ({ startedAt, endedAt }) => {
7956
+ const [time, setTime] = React.useState(startedAt);
7957
+ React.useEffect(() => {
7958
+ const interval = setInterval(() => {
7959
+ setTime(Date.now());
7960
+ }, 100);
7961
+ return () => clearInterval(interval);
7962
+ }, [startedAt]);
7963
+ const timeDiff = endedAt ? endedAt - startedAt : time - startedAt;
7964
+ return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs text-icon3", children: [
7965
+ toSigFigs(timeDiff, 3),
7966
+ "ms"
7967
+ ] });
7968
+ };
7738
7969
 
7739
7970
  function WorkflowAfterNode({ data }) {
7740
7971
  const { steps } = data;
@@ -8768,33 +8999,6 @@ function CodeBlockDemo({
8768
8999
  ] });
8769
9000
  }
8770
9001
 
8771
- const WorkflowRunContext = React.createContext({});
8772
- function WorkflowRunProvider({ children }) {
8773
- const [legacyResult, setLegacyResult] = React.useState(null);
8774
- const [result, setResult] = React.useState(null);
8775
- const [payload, setPayload] = React.useState(null);
8776
- const clearData = () => {
8777
- setLegacyResult(null);
8778
- setResult(null);
8779
- setPayload(null);
8780
- };
8781
- return /* @__PURE__ */ jsxRuntime.jsx(
8782
- WorkflowRunContext.Provider,
8783
- {
8784
- value: {
8785
- legacyResult,
8786
- setLegacyResult,
8787
- result,
8788
- setResult,
8789
- payload,
8790
- setPayload,
8791
- clearData
8792
- },
8793
- children
8794
- }
8795
- );
8796
- }
8797
-
8798
9002
  const WorkflowCard = ({ header, children, footer }) => {
8799
9003
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border-sm border-border1 bg-surface4", children: [
8800
9004
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "py-1 px-2 flex items-center gap-3", children: header }),
@@ -9002,6 +9206,48 @@ function LegacyWorkflowTrigger({
9002
9206
  ] }) });
9003
9207
  }
9004
9208
 
9209
+ const Slider = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
9210
+ SliderPrimitive__namespace.Root,
9211
+ {
9212
+ ref,
9213
+ className: cn("relative flex w-full touch-none select-none items-center", className),
9214
+ ...props,
9215
+ children: [
9216
+ /* @__PURE__ */ jsxRuntime.jsx(SliderPrimitive__namespace.Track, { className: "relative h-1.5 w-full grow overflow-hidden rounded-full bg-primary/20", children: /* @__PURE__ */ jsxRuntime.jsx(SliderPrimitive__namespace.Range, { className: "absolute h-full bg-primary/50" }) }),
9217
+ /* @__PURE__ */ jsxRuntime.jsx(SliderPrimitive__namespace.Thumb, { className: "block h-4 w-4 rounded-full border border-primary/50 bg-white shadow transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50" })
9218
+ ]
9219
+ }
9220
+ ));
9221
+ Slider.displayName = SliderPrimitive__namespace.Root.displayName;
9222
+
9223
+ const ZoomSlider = React.forwardRef(({ className, ...props }) => {
9224
+ const { zoom } = react$2.useViewport();
9225
+ const { zoomTo, zoomIn, zoomOut, fitView } = react$2.useReactFlow();
9226
+ return /* @__PURE__ */ jsxRuntime.jsxs(react$2.Panel, { className: cn("flex gap-1 rounded-md bg-primary-foreground p-1 text-foreground", className), ...props, children: [
9227
+ /* @__PURE__ */ jsxRuntime.jsx(Button$1, { variant: "ghost", size: "icon", onClick: () => zoomOut({ duration: 300 }), children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Minus, { className: "h-4 w-4" }) }),
9228
+ /* @__PURE__ */ jsxRuntime.jsx(
9229
+ Slider,
9230
+ {
9231
+ className: "w-[140px]",
9232
+ value: [zoom],
9233
+ min: 0.01,
9234
+ max: 1,
9235
+ step: 0.01,
9236
+ onValueChange: (values) => {
9237
+ zoomTo(values[0]);
9238
+ }
9239
+ }
9240
+ ),
9241
+ /* @__PURE__ */ jsxRuntime.jsx(Button$1, { variant: "ghost", size: "icon", onClick: () => zoomIn({ duration: 300 }), children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "h-4 w-4" }) }),
9242
+ /* @__PURE__ */ jsxRuntime.jsxs(Button$1, { className: "min-w-20 tabular-nums", variant: "ghost", onClick: () => zoomTo(1, { duration: 300 }), children: [
9243
+ (100 * zoom).toFixed(0),
9244
+ "%"
9245
+ ] }),
9246
+ /* @__PURE__ */ jsxRuntime.jsx(Button$1, { variant: "ghost", size: "icon", onClick: () => fitView({ duration: 300, maxZoom: 1 }), children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Maximize, { className: "h-4 w-4" }) })
9247
+ ] });
9248
+ });
9249
+ ZoomSlider.displayName = "ZoomSlider";
9250
+
9005
9251
  function WorkflowNestedGraph({ stepGraph, open }) {
9006
9252
  const { nodes: initialNodes, edges: initialEdges } = constructNodesAndEdges({
9007
9253
  stepGraph
@@ -9029,11 +9275,15 @@ function WorkflowNestedGraph({ stepGraph, open }) {
9029
9275
  nodes,
9030
9276
  edges,
9031
9277
  fitView: true,
9032
- fitViewOptions: { maxZoom: 0.85 },
9278
+ fitViewOptions: {
9279
+ maxZoom: 1
9280
+ },
9281
+ minZoom: 0.01,
9282
+ maxZoom: 1,
9033
9283
  nodeTypes,
9034
9284
  onNodesChange,
9035
9285
  children: [
9036
- /* @__PURE__ */ jsxRuntime.jsx(react$2.Controls, {}),
9286
+ /* @__PURE__ */ jsxRuntime.jsx(ZoomSlider, { position: "bottom-left" }),
9037
9287
  /* @__PURE__ */ jsxRuntime.jsx(react$2.MiniMap, { pannable: true, zoomable: true, maskColor: "#121212", bgColor: "#171717", nodeColor: "#2c2c2c" }),
9038
9288
  /* @__PURE__ */ jsxRuntime.jsx(react$2.Background, { variant: react$2.BackgroundVariant.Lines, gap: 12, size: 0.5 })
9039
9289
  ]
@@ -9090,7 +9340,7 @@ function WorkflowNestedGraphProvider({ children }) {
9090
9340
  },
9091
9341
  children: [
9092
9342
  children,
9093
- /* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: openDialog, onOpenChange: closeNestedGraph, children: /* @__PURE__ */ jsxRuntime.jsx(DialogPortal, { children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: "w-[40rem] h-[40rem] bg-[#121212] p-[0.5rem]", children: [
9343
+ /* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: openDialog, onOpenChange: closeNestedGraph, children: /* @__PURE__ */ jsxRuntime.jsx(DialogPortal, { children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: "w-[45rem] h-[45rem] max-w-[unset] bg-[#121212] p-[0.5rem]", children: [
9094
9344
  /* @__PURE__ */ jsxRuntime.jsxs(DialogTitle, { className: "flex items-center gap-1.5 absolute top-2.5 left-2.5", children: [
9095
9345
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Workflow, { className: "text-current w-4 h-4" }),
9096
9346
  /* @__PURE__ */ jsxRuntime.jsxs(Text, { size: "xs", weight: "medium", className: "text-mastra-el-6 capitalize", children: [
@@ -9122,6 +9372,7 @@ function WorkflowGraphInner({ workflow }) {
9122
9372
  const { nodes: initialNodes, edges: initialEdges } = constructNodesAndEdges(workflow);
9123
9373
  const [nodes, _, onNodesChange] = react$2.useNodesState(initialNodes);
9124
9374
  const [edges] = react$2.useEdgesState(initialEdges);
9375
+ const { steps } = useCurrentRun();
9125
9376
  const nodeTypes = {
9126
9377
  "default-node": WorkflowDefaultNode,
9127
9378
  "condition-node": WorkflowConditionNode,
@@ -9129,19 +9380,27 @@ function WorkflowGraphInner({ workflow }) {
9129
9380
  "loop-result-node": WorkflowLoopResultNode,
9130
9381
  "nested-node": WorkflowNestedNode
9131
9382
  };
9132
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full h-full", children: /* @__PURE__ */ jsxRuntime.jsxs(
9383
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full h-full bg-surface1", children: /* @__PURE__ */ jsxRuntime.jsxs(
9133
9384
  react$2.ReactFlow,
9134
9385
  {
9135
9386
  nodes,
9136
- edges,
9387
+ edges: edges.map((e) => ({
9388
+ ...e,
9389
+ style: {
9390
+ ...e.style,
9391
+ stroke: steps[e.source]?.status === "success" ? "#22c55e" : void 0
9392
+ }
9393
+ })),
9137
9394
  nodeTypes,
9138
9395
  onNodesChange,
9139
9396
  fitView: true,
9140
9397
  fitViewOptions: {
9141
- maxZoom: 0.85
9398
+ maxZoom: 1
9142
9399
  },
9400
+ minZoom: 0.01,
9401
+ maxZoom: 1,
9143
9402
  children: [
9144
- /* @__PURE__ */ jsxRuntime.jsx(react$2.Controls, {}),
9403
+ /* @__PURE__ */ jsxRuntime.jsx(ZoomSlider, { position: "bottom-left" }),
9145
9404
  /* @__PURE__ */ jsxRuntime.jsx(react$2.MiniMap, { pannable: true, zoomable: true, maskColor: "#121212", bgColor: "#171717", nodeColor: "#2c2c2c" }),
9146
9405
  /* @__PURE__ */ jsxRuntime.jsx(react$2.Background, { variant: react$2.BackgroundVariant.Dots, gap: 12, size: 0.5 })
9147
9406
  ]
@@ -9827,6 +10086,7 @@ exports.WorkflowRunProvider = WorkflowRunProvider;
9827
10086
  exports.WorkflowTraces = WorkflowTraces;
9828
10087
  exports.WorkflowTrigger = WorkflowTrigger;
9829
10088
  exports.refineTraces = refineTraces;
10089
+ exports.useCurrentRun = useCurrentRun;
9830
10090
  exports.usePlaygroundStore = usePlaygroundStore;
9831
10091
  exports.usePolling = usePolling;
9832
10092
  exports.useSpeechRecognition = useSpeechRecognition;