@mastra/playground-ui 5.1.7-alpha.0 → 5.1.7-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/colors-CBG_Mm7P.js.map +1 -1
- package/dist/colors-Du4i-E0i.cjs.map +1 -1
- package/dist/index.cjs.js +2169 -1511
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +2170 -1513
- package/dist/index.es.js.map +1 -1
- package/dist/src/components/assistant-ui/network-threads.d.ts +12 -0
- package/dist/src/domains/networks/index.d.ts +1 -0
- package/dist/src/domains/networks/v-next/network-chat.d.ts +10 -0
- package/dist/src/domains/networks/v-next/step-dropdown.d.ts +1 -0
- package/dist/src/domains/networks/v-next/wrapped-assistant-message.d.ts +6 -0
- package/dist/src/domains/workflows/workflow/workflow-graph-inner.d.ts +1 -1
- package/dist/src/domains/workflows/workflow/workflow-graph.d.ts +1 -1
- package/dist/src/hooks/use-workflow-runs.d.ts +4 -0
- package/dist/src/hooks/use-workflows.d.ts +5 -1
- package/dist/src/lib/formatting.d.ts +1 -0
- package/dist/src/services/vnext-message-provider.d.ts +11 -0
- package/dist/src/services/vnext-network-chat-provider.d.ts +19 -0
- package/dist/src/services/vnext-network-runtime-provider.d.ts +10 -0
- package/dist/src/types.d.ts +4 -0
- package/dist/tokens.cjs.js.map +1 -1
- package/dist/tokens.es.js.map +1 -1
- package/package.json +8 -8
package/dist/index.cjs.js
CHANGED
|
@@ -31,13 +31,18 @@ const react$1 = require('motion/react');
|
|
|
31
31
|
const colors = require('./colors-Du4i-E0i.cjs');
|
|
32
32
|
const uiUtils = require('@ai-sdk/ui-utils');
|
|
33
33
|
const Markdown = require('react-markdown');
|
|
34
|
-
const useDebounce = require('use-debounce');
|
|
35
34
|
const react$2 = require('@xyflow/react');
|
|
36
35
|
require('@xyflow/react/dist/style.css');
|
|
37
36
|
const Dagre = require('@dagrejs/dagre');
|
|
38
37
|
const prismReactRenderer = require('prism-react-renderer');
|
|
39
38
|
const CollapsiblePrimitive = require('@radix-ui/react-collapsible');
|
|
40
39
|
const ScrollAreaPrimitive = require('@radix-ui/react-scroll-area');
|
|
40
|
+
const SliderPrimitive = require('@radix-ui/react-slider');
|
|
41
|
+
const useDebounce = require('use-debounce');
|
|
42
|
+
const uuid = require('@lukeed/uuid');
|
|
43
|
+
const prettier = require('prettier');
|
|
44
|
+
const prettierPluginBabel = require('prettier/plugins/babel');
|
|
45
|
+
const prettierPluginEstree = require('prettier/plugins/estree');
|
|
41
46
|
const jsonSchemaToZod = require('json-schema-to-zod');
|
|
42
47
|
const superjson = require('superjson');
|
|
43
48
|
const z = require('zod');
|
|
@@ -46,11 +51,9 @@ const CheckboxPrimitive = require('@radix-ui/react-checkbox');
|
|
|
46
51
|
const reactDayPicker = require('react-day-picker');
|
|
47
52
|
const PopoverPrimitive = require('@radix-ui/react-popover');
|
|
48
53
|
const SelectPrimitive = require('@radix-ui/react-select');
|
|
49
|
-
const uuid = require('@lukeed/uuid');
|
|
50
54
|
const zod = require('@autoform/zod');
|
|
51
55
|
const LabelPrimitive = require('@radix-ui/react-label');
|
|
52
56
|
const reactCodeBlock = require('react-code-block');
|
|
53
|
-
const SliderPrimitive = require('@radix-ui/react-slider');
|
|
54
57
|
const reactTable = require('@tanstack/react-table');
|
|
55
58
|
|
|
56
59
|
function _interopNamespaceDefault(e) {
|
|
@@ -77,11 +80,11 @@ const DialogPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(DialogP
|
|
|
77
80
|
const TabsPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(TabsPrimitive);
|
|
78
81
|
const CollapsiblePrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(CollapsiblePrimitive);
|
|
79
82
|
const ScrollAreaPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(ScrollAreaPrimitive);
|
|
83
|
+
const SliderPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(SliderPrimitive);
|
|
80
84
|
const CheckboxPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(CheckboxPrimitive);
|
|
81
85
|
const PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(PopoverPrimitive);
|
|
82
86
|
const SelectPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(SelectPrimitive);
|
|
83
87
|
const LabelPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(LabelPrimitive);
|
|
84
|
-
const SliderPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(SliderPrimitive);
|
|
85
88
|
|
|
86
89
|
const createMastraClient = (baseUrl, mastraClientHeaders = {}) => {
|
|
87
90
|
return new clientJs.MastraClient({
|
|
@@ -4396,10 +4399,10 @@ const AssistantMessage = ({
|
|
|
4396
4399
|
}
|
|
4397
4400
|
}
|
|
4398
4401
|
) }),
|
|
4399
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-6 pt-1", children: !isSolelyToolCall && /* @__PURE__ */ jsxRuntime.jsx(AssistantActionBar, {}) })
|
|
4402
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-6 pt-1", children: !isSolelyToolCall && /* @__PURE__ */ jsxRuntime.jsx(AssistantActionBar$1, {}) })
|
|
4400
4403
|
] });
|
|
4401
4404
|
};
|
|
4402
|
-
const AssistantActionBar = () => {
|
|
4405
|
+
const AssistantActionBar$1 = () => {
|
|
4403
4406
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4404
4407
|
react.ActionBarPrimitive.Root,
|
|
4405
4408
|
{
|
|
@@ -4677,28 +4680,28 @@ const Thread = ({ ToolFallback, agentName, hasMemory, showFileSupport }) => {
|
|
|
4677
4680
|
const WrappedAssistantMessage = (props) => {
|
|
4678
4681
|
return /* @__PURE__ */ jsxRuntime.jsx(AssistantMessage, { ...props, ToolFallback });
|
|
4679
4682
|
};
|
|
4680
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(ThreadWrapper, { children: [
|
|
4683
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ThreadWrapper$1, { children: [
|
|
4681
4684
|
/* @__PURE__ */ jsxRuntime.jsxs(react.ThreadPrimitive.Viewport, { ref: areaRef, autoScroll: false, className: "overflow-y-scroll scroll-smooth h-full", children: [
|
|
4682
|
-
/* @__PURE__ */ jsxRuntime.jsx(ThreadWelcome, { agentName }),
|
|
4685
|
+
/* @__PURE__ */ jsxRuntime.jsx(ThreadWelcome$1, { agentName }),
|
|
4683
4686
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "max-w-[568px] w-full mx-auto px-4 pb-7", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4684
4687
|
react.ThreadPrimitive.Messages,
|
|
4685
4688
|
{
|
|
4686
4689
|
components: {
|
|
4687
4690
|
UserMessage,
|
|
4688
|
-
EditComposer,
|
|
4691
|
+
EditComposer: EditComposer$1,
|
|
4689
4692
|
AssistantMessage: WrappedAssistantMessage
|
|
4690
4693
|
}
|
|
4691
4694
|
}
|
|
4692
4695
|
) }),
|
|
4693
4696
|
/* @__PURE__ */ jsxRuntime.jsx(react.ThreadPrimitive.If, { empty: false, children: /* @__PURE__ */ jsxRuntime.jsx("div", {}) })
|
|
4694
4697
|
] }),
|
|
4695
|
-
/* @__PURE__ */ jsxRuntime.jsx(Composer, { hasMemory, showFileSupport })
|
|
4698
|
+
/* @__PURE__ */ jsxRuntime.jsx(Composer$1, { hasMemory, showFileSupport })
|
|
4696
4699
|
] });
|
|
4697
4700
|
};
|
|
4698
|
-
const ThreadWrapper = ({ children }) => {
|
|
4701
|
+
const ThreadWrapper$1 = ({ children }) => {
|
|
4699
4702
|
return /* @__PURE__ */ jsxRuntime.jsx(react.ThreadPrimitive.Root, { className: "grid grid-rows-[1fr_auto] h-full overflow-y-auto", children });
|
|
4700
4703
|
};
|
|
4701
|
-
const ThreadWelcome = ({ agentName }) => {
|
|
4704
|
+
const ThreadWelcome$1 = ({ agentName }) => {
|
|
4702
4705
|
const safeAgentName = agentName ?? "";
|
|
4703
4706
|
const words = safeAgentName.split(" ") ?? [];
|
|
4704
4707
|
let initials = "A";
|
|
@@ -4714,7 +4717,7 @@ const ThreadWelcome = ({ agentName }) => {
|
|
|
4714
4717
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-4 font-medium", children: "How can I help you today?" })
|
|
4715
4718
|
] }) });
|
|
4716
4719
|
};
|
|
4717
|
-
const Composer = ({ hasMemory, showFileSupport }) => {
|
|
4720
|
+
const Composer$1 = ({ hasMemory, showFileSupport }) => {
|
|
4718
4721
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mx-4", children: [
|
|
4719
4722
|
/* @__PURE__ */ jsxRuntime.jsxs(react.ComposerPrimitive.Root, { children: [
|
|
4720
4723
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "max-w-[568px] w-full mx-auto px-2 py-3", children: /* @__PURE__ */ jsxRuntime.jsx(ComposerAttachments, {}) }),
|
|
@@ -4730,8 +4733,8 @@ const Composer = ({ hasMemory, showFileSupport }) => {
|
|
|
4730
4733
|
}
|
|
4731
4734
|
) }),
|
|
4732
4735
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
4733
|
-
/* @__PURE__ */ jsxRuntime.jsx(SpeechInput, {}),
|
|
4734
|
-
/* @__PURE__ */ jsxRuntime.jsx(ComposerAction, { showFileSupport })
|
|
4736
|
+
/* @__PURE__ */ jsxRuntime.jsx(SpeechInput$1, {}),
|
|
4737
|
+
/* @__PURE__ */ jsxRuntime.jsx(ComposerAction$1, { showFileSupport })
|
|
4735
4738
|
] })
|
|
4736
4739
|
] })
|
|
4737
4740
|
] }),
|
|
@@ -4741,7 +4744,7 @@ const Composer = ({ hasMemory, showFileSupport }) => {
|
|
|
4741
4744
|
] })
|
|
4742
4745
|
] });
|
|
4743
4746
|
};
|
|
4744
|
-
const SpeechInput = () => {
|
|
4747
|
+
const SpeechInput$1 = () => {
|
|
4745
4748
|
const composerRuntime = react.useComposerRuntime();
|
|
4746
4749
|
const { start, stop, isListening, transcript } = useSpeechRecognition();
|
|
4747
4750
|
React.useEffect(() => {
|
|
@@ -4756,11 +4759,11 @@ const SpeechInput = () => {
|
|
|
4756
4759
|
variant: "ghost",
|
|
4757
4760
|
className: "rounded-full",
|
|
4758
4761
|
onClick: () => isListening ? stop() : start(),
|
|
4759
|
-
children: isListening ? /* @__PURE__ */ jsxRuntime.jsx(CircleStopIcon, {}) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Mic, { className: "h-6 w-6 text-[#898989] hover:text-[#fff]" })
|
|
4762
|
+
children: isListening ? /* @__PURE__ */ jsxRuntime.jsx(CircleStopIcon$1, {}) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Mic, { className: "h-6 w-6 text-[#898989] hover:text-[#fff]" })
|
|
4760
4763
|
}
|
|
4761
4764
|
);
|
|
4762
4765
|
};
|
|
4763
|
-
const ComposerAction = ({ showFileSupport }) => {
|
|
4766
|
+
const ComposerAction$1 = ({ showFileSupport }) => {
|
|
4764
4767
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4765
4768
|
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]" }) }) }),
|
|
4766
4769
|
/* @__PURE__ */ jsxRuntime.jsx(react.ThreadPrimitive.If, { running: false, children: /* @__PURE__ */ jsxRuntime.jsx(react.ComposerPrimitive.Send, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4772,10 +4775,10 @@ const ComposerAction = ({ showFileSupport }) => {
|
|
|
4772
4775
|
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowUp, { className: "h-6 w-6 text-[#898989] hover:text-[#fff]" })
|
|
4773
4776
|
}
|
|
4774
4777
|
) }) }),
|
|
4775
|
-
/* @__PURE__ */ jsxRuntime.jsx(react.ThreadPrimitive.If, { running: true, children: /* @__PURE__ */ jsxRuntime.jsx(react.ComposerPrimitive.Cancel, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(TooltipIconButton, { tooltip: "Cancel", variant: "default", children: /* @__PURE__ */ jsxRuntime.jsx(CircleStopIcon, {}) }) }) })
|
|
4778
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.ThreadPrimitive.If, { running: true, children: /* @__PURE__ */ jsxRuntime.jsx(react.ComposerPrimitive.Cancel, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(TooltipIconButton, { tooltip: "Cancel", variant: "default", children: /* @__PURE__ */ jsxRuntime.jsx(CircleStopIcon$1, {}) }) }) })
|
|
4776
4779
|
] });
|
|
4777
4780
|
};
|
|
4778
|
-
const EditComposer = () => {
|
|
4781
|
+
const EditComposer$1 = () => {
|
|
4779
4782
|
return /* @__PURE__ */ jsxRuntime.jsxs(react.ComposerPrimitive.Root, { children: [
|
|
4780
4783
|
/* @__PURE__ */ jsxRuntime.jsx(react.ComposerPrimitive.Input, {}),
|
|
4781
4784
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
@@ -4784,7 +4787,7 @@ const EditComposer = () => {
|
|
|
4784
4787
|
] })
|
|
4785
4788
|
] });
|
|
4786
4789
|
};
|
|
4787
|
-
const CircleStopIcon = () => {
|
|
4790
|
+
const CircleStopIcon$1 = () => {
|
|
4788
4791
|
return /* @__PURE__ */ jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", fill: "currentColor", width: "16", height: "16", children: /* @__PURE__ */ jsxRuntime.jsx("rect", { width: "10", height: "10", x: "3", y: "3", rx: "2" }) });
|
|
4789
4792
|
};
|
|
4790
4793
|
|
|
@@ -4859,7 +4862,7 @@ class PDFAttachmentAdapter {
|
|
|
4859
4862
|
}
|
|
4860
4863
|
}
|
|
4861
4864
|
|
|
4862
|
-
const convertMessage$
|
|
4865
|
+
const convertMessage$2 = (message) => {
|
|
4863
4866
|
return message;
|
|
4864
4867
|
};
|
|
4865
4868
|
const convertToAIAttachments = async (attachments) => {
|
|
@@ -5198,7 +5201,7 @@ function MastraRuntimeProvider({
|
|
|
5198
5201
|
const runtime = react.useExternalStoreRuntime({
|
|
5199
5202
|
isRunning,
|
|
5200
5203
|
messages,
|
|
5201
|
-
convertMessage: convertMessage$
|
|
5204
|
+
convertMessage: convertMessage$2,
|
|
5202
5205
|
onNew,
|
|
5203
5206
|
adapters: {
|
|
5204
5207
|
attachments: new react.CompositeAttachmentAdapter([
|
|
@@ -6507,7 +6510,7 @@ function AgentTracesInner({ className, traces, error }) {
|
|
|
6507
6510
|
] });
|
|
6508
6511
|
}
|
|
6509
6512
|
|
|
6510
|
-
const convertMessage = (message) => {
|
|
6513
|
+
const convertMessage$1 = (message) => {
|
|
6511
6514
|
return message;
|
|
6512
6515
|
};
|
|
6513
6516
|
function MastraNetworkRuntimeProvider({
|
|
@@ -6672,7 +6675,7 @@ function MastraNetworkRuntimeProvider({
|
|
|
6672
6675
|
const runtime = react.useExternalStoreRuntime({
|
|
6673
6676
|
isRunning,
|
|
6674
6677
|
messages,
|
|
6675
|
-
convertMessage,
|
|
6678
|
+
convertMessage: convertMessage$1,
|
|
6676
6679
|
onNew
|
|
6677
6680
|
});
|
|
6678
6681
|
return /* @__PURE__ */ jsxRuntime.jsxs(react.AssistantRuntimeProvider, { runtime, children: [
|
|
@@ -6911,190 +6914,95 @@ const NetworkChat = ({ agentId, memory }) => {
|
|
|
6911
6914
|
return /* @__PURE__ */ jsxRuntime.jsx(MastraNetworkRuntimeProvider, { agentId, memory, modelSettings, children: /* @__PURE__ */ jsxRuntime.jsx(Thread, { ToolFallback }) });
|
|
6912
6915
|
};
|
|
6913
6916
|
|
|
6914
|
-
|
|
6915
|
-
|
|
6917
|
+
const VNextNetworkChatContext = React.createContext(void 0);
|
|
6918
|
+
const VNextNetworkChatProvider = ({ children, networkId }) => {
|
|
6919
|
+
const [state, setState] = React.useState({});
|
|
6920
|
+
const handleStep = (uuid, record) => {
|
|
6921
|
+
const id = record?.type === "finish" ? "finish" : record.type === "start" ? "start" : record.payload?.id;
|
|
6922
|
+
if (id.includes("mapping_")) return;
|
|
6923
|
+
setState((prevState) => {
|
|
6924
|
+
const current = prevState[uuid];
|
|
6925
|
+
const currentMetadata = current?.steps?.[id]?.metadata;
|
|
6926
|
+
let startTime = currentMetadata?.startTime;
|
|
6927
|
+
let endTime = currentMetadata?.endTime;
|
|
6928
|
+
if (record.type === "step-start") {
|
|
6929
|
+
startTime = Date.now();
|
|
6930
|
+
}
|
|
6931
|
+
if (record.type === "step-finish") {
|
|
6932
|
+
endTime = Date.now();
|
|
6933
|
+
}
|
|
6934
|
+
return {
|
|
6935
|
+
...prevState,
|
|
6936
|
+
[uuid]: {
|
|
6937
|
+
...current,
|
|
6938
|
+
runId: current?.runId || record?.payload?.runId,
|
|
6939
|
+
executionSteps: current?.steps?.[id] ? current?.executionSteps : [...current?.executionSteps || [], id],
|
|
6940
|
+
steps: {
|
|
6941
|
+
...current?.steps,
|
|
6942
|
+
[id]: {
|
|
6943
|
+
...current?.steps?.[id] || {},
|
|
6944
|
+
[record.type]: record.payload,
|
|
6945
|
+
metadata: {
|
|
6946
|
+
startTime,
|
|
6947
|
+
endTime
|
|
6948
|
+
}
|
|
6949
|
+
}
|
|
6950
|
+
}
|
|
6951
|
+
}
|
|
6952
|
+
};
|
|
6953
|
+
});
|
|
6954
|
+
};
|
|
6955
|
+
return /* @__PURE__ */ jsxRuntime.jsx(VNextNetworkChatContext.Provider, { value: { state, handleStep, setState }, children });
|
|
6956
|
+
};
|
|
6957
|
+
const useVNextNetworkChat = () => {
|
|
6958
|
+
const context = React.useContext(VNextNetworkChatContext);
|
|
6959
|
+
if (context === void 0) {
|
|
6960
|
+
throw new Error("useVNextNetworkChat must be used within a VNextNetworkChatProvider");
|
|
6961
|
+
}
|
|
6962
|
+
return context;
|
|
6963
|
+
};
|
|
6964
|
+
|
|
6965
|
+
function Spinner({ color = "#fff", className }) {
|
|
6966
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6967
|
+
"svg",
|
|
6968
|
+
{
|
|
6969
|
+
className: cn("animate-spin duration-700", className),
|
|
6970
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
6971
|
+
width: "24",
|
|
6972
|
+
height: "24",
|
|
6973
|
+
viewBox: "0 0 24 24",
|
|
6974
|
+
fill: "none",
|
|
6975
|
+
stroke: "currentColor",
|
|
6976
|
+
strokeWidth: "2",
|
|
6977
|
+
strokeLinecap: "round",
|
|
6978
|
+
strokeLinejoin: "round",
|
|
6979
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M21 12a9 9 0 1 1-6.219-8.56", stroke: color })
|
|
6980
|
+
}
|
|
6981
|
+
);
|
|
6916
6982
|
}
|
|
6917
|
-
|
|
6918
|
-
|
|
6919
|
-
const [
|
|
6920
|
-
const { isOpen: open, setTrace, setIsOpen, setSpan } = React.useContext(TraceContext);
|
|
6983
|
+
|
|
6984
|
+
const Clock = ({ startedAt, endedAt }) => {
|
|
6985
|
+
const [time, setTime] = React.useState(startedAt);
|
|
6921
6986
|
React.useEffect(() => {
|
|
6922
|
-
|
|
6923
|
-
|
|
6924
|
-
|
|
6925
|
-
|
|
6926
|
-
|
|
6927
|
-
|
|
6928
|
-
|
|
6929
|
-
|
|
6930
|
-
|
|
6931
|
-
hasRunRef.current = true;
|
|
6932
|
-
}, [runId, traces, setTrace]);
|
|
6933
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("main", { className: "h-full relative overflow-hidden flex", children: [
|
|
6934
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full overflow-y-scroll w-full", children: /* @__PURE__ */ jsxRuntime.jsx(TracesTable, { traces, error }) }),
|
|
6935
|
-
open && /* @__PURE__ */ jsxRuntime.jsx(TracesSidebar, { width: sidebarWidth, onResize: setSidebarWidth })
|
|
6987
|
+
const interval = setInterval(() => {
|
|
6988
|
+
setTime(Date.now());
|
|
6989
|
+
}, 100);
|
|
6990
|
+
return () => clearInterval(interval);
|
|
6991
|
+
}, [startedAt]);
|
|
6992
|
+
const timeDiff = endedAt ? endedAt - startedAt : time - startedAt;
|
|
6993
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs text-icon3", children: [
|
|
6994
|
+
toSigFigs(timeDiff, 3),
|
|
6995
|
+
"ms"
|
|
6936
6996
|
] });
|
|
6937
|
-
}
|
|
6997
|
+
};
|
|
6938
6998
|
|
|
6939
6999
|
function Skeleton({ className, ...props }) {
|
|
6940
7000
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("animate-pulse rounded-md bg-muted/50", className), ...props });
|
|
6941
7001
|
}
|
|
6942
7002
|
|
|
6943
|
-
const
|
|
6944
|
-
const [
|
|
6945
|
-
|
|
6946
|
-
const client = useMastraClient();
|
|
6947
|
-
React.useEffect(() => {
|
|
6948
|
-
const fetchWorkflow = async () => {
|
|
6949
|
-
setIsLoading(true);
|
|
6950
|
-
try {
|
|
6951
|
-
if (!workflowId) {
|
|
6952
|
-
setLegacyWorkflow(null);
|
|
6953
|
-
setIsLoading(false);
|
|
6954
|
-
return;
|
|
6955
|
-
}
|
|
6956
|
-
const res = await client.getLegacyWorkflow(workflowId).details();
|
|
6957
|
-
if (!res) {
|
|
6958
|
-
setLegacyWorkflow(null);
|
|
6959
|
-
console.error("Error fetching legacy workflow");
|
|
6960
|
-
sonner.toast.error("Error fetching legacy workflow");
|
|
6961
|
-
return;
|
|
6962
|
-
}
|
|
6963
|
-
const steps = res.steps;
|
|
6964
|
-
const stepsWithWorkflow = await Promise.all(
|
|
6965
|
-
Object.values(steps)?.map(async (step) => {
|
|
6966
|
-
if (!step.workflowId) return step;
|
|
6967
|
-
const wFlow = await client.getLegacyWorkflow(step.workflowId).details();
|
|
6968
|
-
if (!wFlow) return step;
|
|
6969
|
-
return { ...step, stepGraph: wFlow.stepGraph, stepSubscriberGraph: wFlow.stepSubscriberGraph };
|
|
6970
|
-
})
|
|
6971
|
-
);
|
|
6972
|
-
const _steps = stepsWithWorkflow.reduce((acc, b) => {
|
|
6973
|
-
return { ...acc, [b.id]: b };
|
|
6974
|
-
}, {});
|
|
6975
|
-
setLegacyWorkflow({ ...res, steps: _steps });
|
|
6976
|
-
} catch (error) {
|
|
6977
|
-
setLegacyWorkflow(null);
|
|
6978
|
-
console.error("Error fetching legacy workflow", error);
|
|
6979
|
-
sonner.toast.error("Error fetching legacy workflow");
|
|
6980
|
-
} finally {
|
|
6981
|
-
setIsLoading(false);
|
|
6982
|
-
}
|
|
6983
|
-
};
|
|
6984
|
-
fetchWorkflow();
|
|
6985
|
-
}, [workflowId]);
|
|
6986
|
-
return { legacyWorkflow, isLoading };
|
|
6987
|
-
};
|
|
6988
|
-
const useExecuteWorkflow = () => {
|
|
6989
|
-
const client = useMastraClient();
|
|
6990
|
-
const createLegacyWorkflowRun = async ({ workflowId, prevRunId }) => {
|
|
6991
|
-
try {
|
|
6992
|
-
const workflow = client.getLegacyWorkflow(workflowId);
|
|
6993
|
-
const { runId: newRunId } = await workflow.createRun({ runId: prevRunId });
|
|
6994
|
-
return { runId: newRunId };
|
|
6995
|
-
} catch (error) {
|
|
6996
|
-
console.error("Error creating workflow run:", error);
|
|
6997
|
-
throw error;
|
|
6998
|
-
}
|
|
6999
|
-
};
|
|
7000
|
-
const startLegacyWorkflowRun = async ({
|
|
7001
|
-
workflowId,
|
|
7002
|
-
runId,
|
|
7003
|
-
input
|
|
7004
|
-
}) => {
|
|
7005
|
-
try {
|
|
7006
|
-
const workflow = client.getLegacyWorkflow(workflowId);
|
|
7007
|
-
await workflow.start({ runId, triggerData: input || {} });
|
|
7008
|
-
} catch (error) {
|
|
7009
|
-
console.error("Error starting workflow run:", error);
|
|
7010
|
-
throw error;
|
|
7011
|
-
}
|
|
7012
|
-
};
|
|
7013
|
-
return {
|
|
7014
|
-
startLegacyWorkflowRun,
|
|
7015
|
-
createLegacyWorkflowRun
|
|
7016
|
-
};
|
|
7017
|
-
};
|
|
7018
|
-
const useWatchWorkflow = () => {
|
|
7019
|
-
const [isWatchingLegacyWorkflow, setIsWatchingLegacyWorkflow] = React.useState(false);
|
|
7020
|
-
const [legacyWatchResult, setLegacyWatchResult] = React.useState(null);
|
|
7021
|
-
const client = useMastraClient();
|
|
7022
|
-
const debouncedSetLegacyWorkflowWatchResult = useDebounce.useDebouncedCallback((record) => {
|
|
7023
|
-
const formattedResults = Object.entries(record.results || {}).reduce(
|
|
7024
|
-
(acc, [key, value]) => {
|
|
7025
|
-
let output = value.status === "success" ? value.output : void 0;
|
|
7026
|
-
if (output) {
|
|
7027
|
-
output = Object.entries(output).reduce(
|
|
7028
|
-
(_acc, [_key, _value]) => {
|
|
7029
|
-
const val = _value;
|
|
7030
|
-
_acc[_key] = val.type?.toLowerCase() === "buffer" ? { type: "Buffer", data: `[...buffered data]` } : val;
|
|
7031
|
-
return _acc;
|
|
7032
|
-
},
|
|
7033
|
-
{}
|
|
7034
|
-
);
|
|
7035
|
-
}
|
|
7036
|
-
acc[key] = { ...value, output };
|
|
7037
|
-
return acc;
|
|
7038
|
-
},
|
|
7039
|
-
{}
|
|
7040
|
-
);
|
|
7041
|
-
const sanitizedRecord = {
|
|
7042
|
-
...record,
|
|
7043
|
-
sanitizedOutput: record ? JSON.stringify({ ...record, results: formattedResults }, null, 2).slice(0, 5e4) : null
|
|
7044
|
-
};
|
|
7045
|
-
setLegacyWatchResult(sanitizedRecord);
|
|
7046
|
-
}, 100);
|
|
7047
|
-
const watchLegacyWorkflow = async ({ workflowId, runId }) => {
|
|
7048
|
-
try {
|
|
7049
|
-
setIsWatchingLegacyWorkflow(true);
|
|
7050
|
-
const workflow = client.getLegacyWorkflow(workflowId);
|
|
7051
|
-
await workflow.watch({ runId }, (record) => {
|
|
7052
|
-
try {
|
|
7053
|
-
debouncedSetLegacyWorkflowWatchResult(record);
|
|
7054
|
-
} catch (err) {
|
|
7055
|
-
console.error("Error processing workflow record:", err);
|
|
7056
|
-
setLegacyWatchResult({
|
|
7057
|
-
...record
|
|
7058
|
-
});
|
|
7059
|
-
}
|
|
7060
|
-
});
|
|
7061
|
-
} catch (error) {
|
|
7062
|
-
console.error("Error watching workflow:", error);
|
|
7063
|
-
throw error;
|
|
7064
|
-
} finally {
|
|
7065
|
-
setIsWatchingLegacyWorkflow(false);
|
|
7066
|
-
}
|
|
7067
|
-
};
|
|
7068
|
-
return {
|
|
7069
|
-
watchLegacyWorkflow,
|
|
7070
|
-
isWatchingLegacyWorkflow,
|
|
7071
|
-
legacyWatchResult
|
|
7072
|
-
};
|
|
7073
|
-
};
|
|
7074
|
-
const useResumeWorkflow = () => {
|
|
7075
|
-
const [isResumingLegacyWorkflow, setIsResumingLegacyWorkflow] = React.useState(false);
|
|
7076
|
-
const client = useMastraClient();
|
|
7077
|
-
const resumeLegacyWorkflow = async ({
|
|
7078
|
-
workflowId,
|
|
7079
|
-
stepId,
|
|
7080
|
-
runId,
|
|
7081
|
-
context
|
|
7082
|
-
}) => {
|
|
7083
|
-
try {
|
|
7084
|
-
setIsResumingLegacyWorkflow(true);
|
|
7085
|
-
const response = await client.getLegacyWorkflow(workflowId).resume({ stepId, runId, context });
|
|
7086
|
-
return response;
|
|
7087
|
-
} catch (error) {
|
|
7088
|
-
console.error("Error resuming workflow:", error);
|
|
7089
|
-
throw error;
|
|
7090
|
-
} finally {
|
|
7091
|
-
setIsResumingLegacyWorkflow(false);
|
|
7092
|
-
}
|
|
7093
|
-
};
|
|
7094
|
-
return {
|
|
7095
|
-
resumeLegacyWorkflow,
|
|
7096
|
-
isResumingLegacyWorkflow
|
|
7097
|
-
};
|
|
7003
|
+
const lodashTitleCase = (str) => {
|
|
7004
|
+
const camelCased = str.replace(/[-_\s]+(.)?/g, (_, char) => char ? char.toUpperCase() : "").replace(/^(.)/, (char) => char.toLowerCase());
|
|
7005
|
+
return camelCased.replace(/([A-Z])/g, " $1").replace(/^./, (str2) => str2.toUpperCase()).trim();
|
|
7098
7006
|
};
|
|
7099
7007
|
|
|
7100
7008
|
function extractConditions(group, type) {
|
|
@@ -8069,21 +7977,6 @@ function WorkflowConditionNode({ data }) {
|
|
|
8069
7977
|
] });
|
|
8070
7978
|
}
|
|
8071
7979
|
|
|
8072
|
-
const Clock = ({ startedAt, endedAt }) => {
|
|
8073
|
-
const [time, setTime] = React.useState(startedAt);
|
|
8074
|
-
React.useEffect(() => {
|
|
8075
|
-
const interval = setInterval(() => {
|
|
8076
|
-
setTime(Date.now());
|
|
8077
|
-
}, 100);
|
|
8078
|
-
return () => clearInterval(interval);
|
|
8079
|
-
}, [startedAt]);
|
|
8080
|
-
const timeDiff = endedAt ? endedAt - startedAt : time - startedAt;
|
|
8081
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs text-icon3", children: [
|
|
8082
|
-
toSigFigs(timeDiff, 3),
|
|
8083
|
-
"ms"
|
|
8084
|
-
] });
|
|
8085
|
-
};
|
|
8086
|
-
|
|
8087
7980
|
function WorkflowDefaultNode({
|
|
8088
7981
|
data,
|
|
8089
7982
|
onShowTrace,
|
|
@@ -8127,7 +8020,7 @@ function WorkflowDefaultNode({
|
|
|
8127
8020
|
output: step?.output,
|
|
8128
8021
|
error: step?.error,
|
|
8129
8022
|
mapConfig: data.mapConfig,
|
|
8130
|
-
onShowTrace: runId ? () => onShowTrace?.({ runId, stepName: fullLabel }) : void 0
|
|
8023
|
+
onShowTrace: runId && onShowTrace ? () => onShowTrace?.({ runId, stepName: fullLabel }) : void 0
|
|
8131
8024
|
}
|
|
8132
8025
|
)
|
|
8133
8026
|
]
|
|
@@ -8189,42 +8082,62 @@ function WorkflowLoopResultNode({ data }) {
|
|
|
8189
8082
|
] });
|
|
8190
8083
|
}
|
|
8191
8084
|
|
|
8192
|
-
|
|
8193
|
-
|
|
8194
|
-
|
|
8195
|
-
|
|
8196
|
-
|
|
8197
|
-
|
|
8198
|
-
|
|
8199
|
-
|
|
8200
|
-
|
|
8201
|
-
|
|
8202
|
-
|
|
8203
|
-
|
|
8204
|
-
|
|
8205
|
-
strokeLinejoin: "round",
|
|
8206
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M21 12a9 9 0 1 1-6.219-8.56", stroke: color })
|
|
8207
|
-
}
|
|
8208
|
-
);
|
|
8209
|
-
}
|
|
8085
|
+
const Slider = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8086
|
+
SliderPrimitive__namespace.Root,
|
|
8087
|
+
{
|
|
8088
|
+
ref,
|
|
8089
|
+
className: cn("relative flex w-full touch-none select-none items-center", className),
|
|
8090
|
+
...props,
|
|
8091
|
+
children: [
|
|
8092
|
+
/* @__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" }) }),
|
|
8093
|
+
/* @__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" })
|
|
8094
|
+
]
|
|
8095
|
+
}
|
|
8096
|
+
));
|
|
8097
|
+
Slider.displayName = SliderPrimitive__namespace.Root.displayName;
|
|
8210
8098
|
|
|
8211
|
-
|
|
8212
|
-
|
|
8213
|
-
|
|
8214
|
-
|
|
8215
|
-
}) {
|
|
8216
|
-
|
|
8217
|
-
|
|
8218
|
-
|
|
8099
|
+
const ZoomSlider = React.forwardRef(({ className, ...props }) => {
|
|
8100
|
+
const { zoom } = react$2.useViewport();
|
|
8101
|
+
const { zoomTo, zoomIn, zoomOut, fitView } = react$2.useReactFlow();
|
|
8102
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(react$2.Panel, { className: cn("flex gap-1 rounded-md bg-primary-foreground p-1 text-foreground", className), ...props, children: [
|
|
8103
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button$1, { variant: "ghost", size: "icon", onClick: () => zoomOut({ duration: 300 }), children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Minus, { className: "h-4 w-4" }) }),
|
|
8104
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8105
|
+
Slider,
|
|
8106
|
+
{
|
|
8107
|
+
className: "w-[140px]",
|
|
8108
|
+
value: [zoom],
|
|
8109
|
+
min: 0.01,
|
|
8110
|
+
max: 1,
|
|
8111
|
+
step: 0.01,
|
|
8112
|
+
onValueChange: (values) => {
|
|
8113
|
+
zoomTo(values[0]);
|
|
8114
|
+
}
|
|
8115
|
+
}
|
|
8116
|
+
),
|
|
8117
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button$1, { variant: "ghost", size: "icon", onClick: () => zoomIn({ duration: 300 }), children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "h-4 w-4" }) }),
|
|
8118
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Button$1, { className: "min-w-20 tabular-nums", variant: "ghost", onClick: () => zoomTo(1, { duration: 300 }), children: [
|
|
8119
|
+
(100 * zoom).toFixed(0),
|
|
8120
|
+
"%"
|
|
8121
|
+
] }),
|
|
8122
|
+
/* @__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" }) })
|
|
8123
|
+
] });
|
|
8124
|
+
});
|
|
8125
|
+
ZoomSlider.displayName = "ZoomSlider";
|
|
8126
|
+
|
|
8127
|
+
function WorkflowNestedGraph({ stepGraph, open, workflowName }) {
|
|
8128
|
+
const { nodes: initialNodes, edges: initialEdges } = constructNodesAndEdges({
|
|
8129
|
+
stepGraph
|
|
8219
8130
|
});
|
|
8220
8131
|
const [isMounted, setIsMounted] = React.useState(false);
|
|
8221
8132
|
const [nodes, _, onNodesChange] = react$2.useNodesState(initialNodes);
|
|
8222
8133
|
const [edges] = react$2.useEdgesState(initialEdges);
|
|
8134
|
+
const { steps } = useCurrentRun();
|
|
8223
8135
|
const nodeTypes = {
|
|
8224
|
-
"default-node": WorkflowDefaultNode,
|
|
8136
|
+
"default-node": (props) => /* @__PURE__ */ jsxRuntime.jsx(WorkflowDefaultNode, { parentWorkflowName: workflowName, ...props }),
|
|
8225
8137
|
"condition-node": WorkflowConditionNode,
|
|
8226
8138
|
"after-node": WorkflowAfterNode,
|
|
8227
|
-
"loop-result-node": WorkflowLoopResultNode
|
|
8139
|
+
"loop-result-node": WorkflowLoopResultNode,
|
|
8140
|
+
"nested-node": (props) => /* @__PURE__ */ jsxRuntime.jsx(WorkflowNestedNode, { parentWorkflowName: workflowName, ...props })
|
|
8228
8141
|
};
|
|
8229
8142
|
React.useEffect(() => {
|
|
8230
8143
|
if (open) {
|
|
@@ -8233,17 +8146,27 @@ function LegacyWorkflowNestedGraph({
|
|
|
8233
8146
|
}, 500);
|
|
8234
8147
|
}
|
|
8235
8148
|
}, [open]);
|
|
8236
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full h-full relative", children: isMounted ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8149
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full h-full relative bg-surface1", children: isMounted ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8237
8150
|
react$2.ReactFlow,
|
|
8238
8151
|
{
|
|
8239
8152
|
nodes,
|
|
8240
|
-
edges
|
|
8153
|
+
edges: edges.map((e) => ({
|
|
8154
|
+
...e,
|
|
8155
|
+
style: {
|
|
8156
|
+
...e.style,
|
|
8157
|
+
stroke: steps[`${workflowName}.${e.data?.previousStepId}`]?.status === "success" && steps[`${workflowName}.${e.data?.nextStepId}`] ? "#22c55e" : void 0
|
|
8158
|
+
}
|
|
8159
|
+
})),
|
|
8241
8160
|
fitView: true,
|
|
8242
|
-
fitViewOptions: {
|
|
8161
|
+
fitViewOptions: {
|
|
8162
|
+
maxZoom: 1
|
|
8163
|
+
},
|
|
8164
|
+
minZoom: 0.01,
|
|
8165
|
+
maxZoom: 1,
|
|
8243
8166
|
nodeTypes,
|
|
8244
8167
|
onNodesChange,
|
|
8245
8168
|
children: [
|
|
8246
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8169
|
+
/* @__PURE__ */ jsxRuntime.jsx(ZoomSlider, { position: "bottom-left" }),
|
|
8247
8170
|
/* @__PURE__ */ jsxRuntime.jsx(react$2.MiniMap, { pannable: true, zoomable: true, maskColor: "#121212", bgColor: "#171717", nodeColor: "#2c2c2c" }),
|
|
8248
8171
|
/* @__PURE__ */ jsxRuntime.jsx(react$2.Background, { variant: react$2.BackgroundVariant.Lines, gap: 12, size: 0.5 })
|
|
8249
8172
|
]
|
|
@@ -8251,32 +8174,53 @@ function LegacyWorkflowNestedGraph({
|
|
|
8251
8174
|
) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full h-full flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(Spinner, {}) }) });
|
|
8252
8175
|
}
|
|
8253
8176
|
|
|
8254
|
-
const
|
|
8177
|
+
const WorkflowNestedGraphContext = React.createContext(
|
|
8255
8178
|
{}
|
|
8256
8179
|
);
|
|
8257
|
-
function
|
|
8180
|
+
function WorkflowNestedGraphProvider({ children }) {
|
|
8258
8181
|
const [stepGraph, setStepGraph] = React.useState(null);
|
|
8259
|
-
const [
|
|
8182
|
+
const [parentStepGraphList, setParentStepGraphList] = React.useState([]);
|
|
8260
8183
|
const [openDialog, setOpenDialog] = React.useState(false);
|
|
8261
8184
|
const [label, setLabel] = React.useState("");
|
|
8185
|
+
const [fullStep, setFullStep] = React.useState("");
|
|
8186
|
+
const [switching, setSwitching] = React.useState(false);
|
|
8262
8187
|
const closeNestedGraph = () => {
|
|
8263
|
-
|
|
8264
|
-
|
|
8265
|
-
|
|
8266
|
-
|
|
8188
|
+
if (parentStepGraphList.length) {
|
|
8189
|
+
setSwitching(true);
|
|
8190
|
+
const lastStepGraph = parentStepGraphList[parentStepGraphList.length - 1];
|
|
8191
|
+
setStepGraph(lastStepGraph.stepGraph);
|
|
8192
|
+
setLabel(lastStepGraph.label);
|
|
8193
|
+
setFullStep(lastStepGraph.fullStep);
|
|
8194
|
+
setParentStepGraphList(parentStepGraphList.slice(0, -1));
|
|
8195
|
+
setTimeout(() => {
|
|
8196
|
+
setSwitching(false);
|
|
8197
|
+
}, 500);
|
|
8198
|
+
} else {
|
|
8199
|
+
setOpenDialog(false);
|
|
8200
|
+
setStepGraph(null);
|
|
8201
|
+
setLabel("");
|
|
8202
|
+
setFullStep("");
|
|
8203
|
+
}
|
|
8267
8204
|
};
|
|
8268
8205
|
const showNestedGraph = ({
|
|
8269
|
-
label:
|
|
8270
|
-
stepGraph:
|
|
8271
|
-
|
|
8206
|
+
label: newLabel,
|
|
8207
|
+
stepGraph: newStepGraph,
|
|
8208
|
+
fullStep: newFullStep
|
|
8272
8209
|
}) => {
|
|
8273
|
-
|
|
8274
|
-
|
|
8275
|
-
|
|
8210
|
+
if (stepGraph) {
|
|
8211
|
+
setSwitching(true);
|
|
8212
|
+
setParentStepGraphList([...parentStepGraphList, { stepGraph, label, fullStep }]);
|
|
8213
|
+
}
|
|
8214
|
+
setLabel(newLabel);
|
|
8215
|
+
setFullStep(newFullStep);
|
|
8216
|
+
setStepGraph(newStepGraph);
|
|
8276
8217
|
setOpenDialog(true);
|
|
8218
|
+
setTimeout(() => {
|
|
8219
|
+
setSwitching(false);
|
|
8220
|
+
}, 500);
|
|
8277
8221
|
};
|
|
8278
8222
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8279
|
-
|
|
8223
|
+
WorkflowNestedGraphContext.Provider,
|
|
8280
8224
|
{
|
|
8281
8225
|
value: {
|
|
8282
8226
|
showNestedGraph,
|
|
@@ -8284,7 +8228,7 @@ function LegacyWorkflowNestedGraphProvider({ children }) {
|
|
|
8284
8228
|
},
|
|
8285
8229
|
children: [
|
|
8286
8230
|
children,
|
|
8287
|
-
/* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: openDialog, onOpenChange: closeNestedGraph, children: /* @__PURE__ */ jsxRuntime.jsx(DialogPortal, { children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: "w-[
|
|
8231
|
+
/* @__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: [
|
|
8288
8232
|
/* @__PURE__ */ jsxRuntime.jsxs(DialogTitle, { className: "flex items-center gap-1.5 absolute top-2.5 left-2.5", children: [
|
|
8289
8233
|
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Workflow, { className: "text-current w-4 h-4" }),
|
|
8290
8234
|
/* @__PURE__ */ jsxRuntime.jsxs(Text, { size: "xs", weight: "medium", className: "text-mastra-el-6 capitalize", children: [
|
|
@@ -8292,1411 +8236,2124 @@ function LegacyWorkflowNestedGraphProvider({ children }) {
|
|
|
8292
8236
|
" workflow"
|
|
8293
8237
|
] })
|
|
8294
8238
|
] }),
|
|
8295
|
-
/* @__PURE__ */ jsxRuntime.jsx(react$2.ReactFlowProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8296
|
-
LegacyWorkflowNestedGraph,
|
|
8297
|
-
{
|
|
8298
|
-
stepGraph,
|
|
8299
|
-
open: openDialog,
|
|
8300
|
-
stepSubscriberGraph
|
|
8301
|
-
}
|
|
8302
|
-
) })
|
|
8239
|
+
switching ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full h-full flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(Spinner, {}) }) : /* @__PURE__ */ jsxRuntime.jsx(react$2.ReactFlowProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(WorkflowNestedGraph, { stepGraph, open: openDialog, workflowName: fullStep }) })
|
|
8303
8240
|
] }) }) })
|
|
8304
8241
|
]
|
|
8305
8242
|
}
|
|
8306
8243
|
);
|
|
8307
8244
|
}
|
|
8308
8245
|
|
|
8309
|
-
function
|
|
8310
|
-
|
|
8311
|
-
|
|
8312
|
-
|
|
8246
|
+
function WorkflowNestedNode({
|
|
8247
|
+
data,
|
|
8248
|
+
parentWorkflowName
|
|
8249
|
+
}) {
|
|
8250
|
+
const [isInputOpen, setIsInputOpen] = React.useState(false);
|
|
8251
|
+
const [isOutputOpen, setIsOutputOpen] = React.useState(false);
|
|
8252
|
+
const [isErrorOpen, setIsErrorOpen] = React.useState(false);
|
|
8253
|
+
const [isMapConfigOpen, setIsMapConfigOpen] = React.useState(false);
|
|
8254
|
+
const { steps, isRunning } = useCurrentRun();
|
|
8255
|
+
const { showNestedGraph } = React.useContext(WorkflowNestedGraphContext);
|
|
8256
|
+
const { label, description, withoutTopHandle, withoutBottomHandle, stepGraph, mapConfig } = data;
|
|
8257
|
+
const fullLabel = parentWorkflowName ? `${parentWorkflowName}.${label}` : label;
|
|
8258
|
+
const step = steps[fullLabel];
|
|
8259
|
+
const dialogContentClass = "bg-surface2 rounded-lg border-sm border-border1 max-w-4xl w-full px-0";
|
|
8260
|
+
const dialogTitleClass = "border-b-sm border-border1 pb-4 px-6";
|
|
8261
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
8313
8262
|
!withoutTopHandle && /* @__PURE__ */ jsxRuntime.jsx(react$2.Handle, { type: "target", position: react$2.Position.Top, style: { visibility: "hidden" } }),
|
|
8314
|
-
/* @__PURE__ */ jsxRuntime.
|
|
8315
|
-
|
|
8316
|
-
|
|
8317
|
-
|
|
8318
|
-
|
|
8319
|
-
|
|
8320
|
-
|
|
8321
|
-
|
|
8322
|
-
|
|
8323
|
-
|
|
8324
|
-
|
|
8325
|
-
|
|
8326
|
-
|
|
8327
|
-
|
|
8328
|
-
|
|
8329
|
-
|
|
8330
|
-
|
|
8331
|
-
|
|
8332
|
-
|
|
8333
|
-
|
|
8334
|
-
|
|
8335
|
-
|
|
8336
|
-
|
|
8337
|
-
|
|
8338
|
-
|
|
8339
|
-
|
|
8340
|
-
|
|
8341
|
-
|
|
8342
|
-
|
|
8343
|
-
|
|
8344
|
-
|
|
8345
|
-
|
|
8346
|
-
|
|
8347
|
-
|
|
8348
|
-
|
|
8349
|
-
|
|
8350
|
-
|
|
8351
|
-
|
|
8352
|
-
|
|
8353
|
-
|
|
8354
|
-
|
|
8355
|
-
|
|
8356
|
-
|
|
8357
|
-
|
|
8358
|
-
|
|
8359
|
-
|
|
8360
|
-
|
|
8361
|
-
|
|
8362
|
-
|
|
8363
|
-
|
|
8364
|
-
|
|
8365
|
-
|
|
8366
|
-
|
|
8367
|
-
|
|
8368
|
-
|
|
8369
|
-
|
|
8370
|
-
|
|
8371
|
-
|
|
8372
|
-
|
|
8373
|
-
|
|
8374
|
-
|
|
8375
|
-
|
|
8376
|
-
|
|
8377
|
-
|
|
8378
|
-
}
|
|
8379
|
-
|
|
8380
|
-
|
|
8381
|
-
|
|
8382
|
-
}
|
|
8383
|
-
|
|
8384
|
-
|
|
8385
|
-
const FieldWrapper = ({ label, children, id, field, error }) => {
|
|
8386
|
-
const isDisabled = DISABLED_LABELS.includes(field.type);
|
|
8387
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pb-4 last:pb-0", children: [
|
|
8388
|
-
!isDisabled && /* @__PURE__ */ jsxRuntime.jsxs(Txt, { as: "label", variant: "ui-sm", className: "text-icon3 pb-1 block", htmlFor: id, children: [
|
|
8389
|
-
label,
|
|
8390
|
-
field.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-accent2", children: " *" })
|
|
8391
|
-
] }),
|
|
8392
|
-
children,
|
|
8393
|
-
field.fieldConfig?.description && /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "p", variant: "ui-sm", className: "text-icon6", children: field.fieldConfig.description }),
|
|
8394
|
-
error && /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "p", variant: "ui-sm", className: "text-accent2", children: error })
|
|
8263
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
8264
|
+
"div",
|
|
8265
|
+
{
|
|
8266
|
+
className: cn(
|
|
8267
|
+
"bg-surface3 rounded-lg w-[274px] border-sm border-border1 pt-2",
|
|
8268
|
+
step?.status === "success" && "ring-2 ring-accent1",
|
|
8269
|
+
step?.status === "failed" && "ring-2 ring-accent2"
|
|
8270
|
+
),
|
|
8271
|
+
children: [
|
|
8272
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex items-center gap-2 px-3", !description && "pb-2"), children: [
|
|
8273
|
+
isRunning && /* @__PURE__ */ jsxRuntime.jsxs(Icon, { children: [
|
|
8274
|
+
step?.status === "failed" && /* @__PURE__ */ jsxRuntime.jsx(CrossIcon, { className: "text-accent2" }),
|
|
8275
|
+
step?.status === "success" && /* @__PURE__ */ jsxRuntime.jsx(CheckIcon, { className: "text-accent1" }),
|
|
8276
|
+
step?.status === "suspended" && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.PauseIcon, { className: "text-icon3" }),
|
|
8277
|
+
step?.status === "running" && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "text-icon6 animate-spin" }),
|
|
8278
|
+
!step && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleDashed, { className: "text-icon2" })
|
|
8279
|
+
] }),
|
|
8280
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Txt, { variant: "ui-lg", className: "text-icon6 font-medium inline-flex items-center gap-1 justify-between w-full", children: [
|
|
8281
|
+
label,
|
|
8282
|
+
" ",
|
|
8283
|
+
step?.startedAt && /* @__PURE__ */ jsxRuntime.jsx(Clock, { startedAt: step.startedAt, endedAt: step.endedAt })
|
|
8284
|
+
] })
|
|
8285
|
+
] }),
|
|
8286
|
+
description && /* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-sm", className: "text-icon3 px-3 pb-2", children: description }),
|
|
8287
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center bg-surface4 border-t-sm border-border1 px-2 py-1 gap-2 rounded-b-lg", children: [
|
|
8288
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: () => showNestedGraph({ label, fullStep: fullLabel, stepGraph }), children: "View workflow" }),
|
|
8289
|
+
mapConfig && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
8290
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: () => setIsMapConfigOpen(true), children: "Map config" }),
|
|
8291
|
+
/* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: isMapConfigOpen, onOpenChange: setIsMapConfigOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: dialogContentClass, children: [
|
|
8292
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DialogTitle, { className: dialogTitleClass, children: [
|
|
8293
|
+
label,
|
|
8294
|
+
" map config"
|
|
8295
|
+
] }),
|
|
8296
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(CodeDialogContent, { data: mapConfig }) })
|
|
8297
|
+
] }) })
|
|
8298
|
+
] }),
|
|
8299
|
+
step?.input && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
8300
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: () => setIsInputOpen(true), children: "Input" }),
|
|
8301
|
+
/* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: isInputOpen, onOpenChange: setIsInputOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: dialogContentClass, children: [
|
|
8302
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DialogTitle, { className: dialogTitleClass, children: [
|
|
8303
|
+
label,
|
|
8304
|
+
" input"
|
|
8305
|
+
] }),
|
|
8306
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(CodeDialogContent, { data: step.input }) })
|
|
8307
|
+
] }) })
|
|
8308
|
+
] }),
|
|
8309
|
+
step?.output && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
8310
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: () => setIsOutputOpen(true), children: "Output" }),
|
|
8311
|
+
/* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: isOutputOpen, onOpenChange: setIsOutputOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: dialogContentClass, children: [
|
|
8312
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DialogTitle, { className: dialogTitleClass, children: [
|
|
8313
|
+
label,
|
|
8314
|
+
" output"
|
|
8315
|
+
] }),
|
|
8316
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(CodeDialogContent, { data: step.output }) })
|
|
8317
|
+
] }) })
|
|
8318
|
+
] }),
|
|
8319
|
+
step?.error && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
8320
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: () => setIsErrorOpen(true), children: "Error" }),
|
|
8321
|
+
/* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: isErrorOpen, onOpenChange: setIsErrorOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: dialogContentClass, children: [
|
|
8322
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DialogTitle, { className: dialogTitleClass, children: [
|
|
8323
|
+
label,
|
|
8324
|
+
" error"
|
|
8325
|
+
] }),
|
|
8326
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(CodeDialogContent, { data: step?.error }) })
|
|
8327
|
+
] }) })
|
|
8328
|
+
] })
|
|
8329
|
+
] })
|
|
8330
|
+
]
|
|
8331
|
+
}
|
|
8332
|
+
),
|
|
8333
|
+
!withoutBottomHandle && /* @__PURE__ */ jsxRuntime.jsx(react$2.Handle, { type: "source", position: react$2.Position.Bottom, style: { visibility: "hidden" } })
|
|
8395
8334
|
] });
|
|
8396
|
-
}
|
|
8335
|
+
}
|
|
8397
8336
|
|
|
8398
|
-
|
|
8399
|
-
|
|
8400
|
-
|
|
8401
|
-
|
|
8402
|
-
|
|
8403
|
-
|
|
8404
|
-
|
|
8405
|
-
|
|
8406
|
-
|
|
8407
|
-
|
|
8408
|
-
|
|
8337
|
+
function WorkflowGraphInner({ workflow, onShowTrace }) {
|
|
8338
|
+
const { nodes: initialNodes, edges: initialEdges } = constructNodesAndEdges(workflow);
|
|
8339
|
+
const [nodes, _, onNodesChange] = react$2.useNodesState(initialNodes);
|
|
8340
|
+
const [edges] = react$2.useEdgesState(initialEdges);
|
|
8341
|
+
const { steps, runId } = useCurrentRun();
|
|
8342
|
+
const nodeTypes = {
|
|
8343
|
+
"default-node": (props) => /* @__PURE__ */ jsxRuntime.jsx(WorkflowDefaultNode, { onShowTrace, ...props }),
|
|
8344
|
+
"condition-node": WorkflowConditionNode,
|
|
8345
|
+
"after-node": WorkflowAfterNode,
|
|
8346
|
+
"loop-result-node": WorkflowLoopResultNode,
|
|
8347
|
+
"nested-node": WorkflowNestedNode
|
|
8348
|
+
};
|
|
8349
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full h-full bg-surface1", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8350
|
+
react$2.ReactFlow,
|
|
8351
|
+
{
|
|
8352
|
+
nodes,
|
|
8353
|
+
edges: edges.map((e) => ({
|
|
8354
|
+
...e,
|
|
8355
|
+
style: {
|
|
8356
|
+
...e.style,
|
|
8357
|
+
stroke: steps[e.data?.previousStepId]?.status === "success" && steps[e.data?.nextStepId] ? "#22c55e" : void 0
|
|
8358
|
+
}
|
|
8359
|
+
})),
|
|
8360
|
+
nodeTypes,
|
|
8361
|
+
onNodesChange,
|
|
8362
|
+
fitView: true,
|
|
8363
|
+
fitViewOptions: {
|
|
8364
|
+
maxZoom: 1
|
|
8365
|
+
},
|
|
8366
|
+
minZoom: 0.01,
|
|
8367
|
+
maxZoom: 1,
|
|
8368
|
+
children: [
|
|
8369
|
+
/* @__PURE__ */ jsxRuntime.jsx(ZoomSlider, { position: "bottom-left" }),
|
|
8370
|
+
/* @__PURE__ */ jsxRuntime.jsx(react$2.MiniMap, { pannable: true, zoomable: true, maskColor: "#121212", bgColor: "#171717", nodeColor: "#2c2c2c" }),
|
|
8371
|
+
/* @__PURE__ */ jsxRuntime.jsx(react$2.Background, { variant: react$2.BackgroundVariant.Dots, gap: 12, size: 0.5 })
|
|
8372
|
+
]
|
|
8409
8373
|
}
|
|
8410
|
-
}
|
|
8411
|
-
|
|
8412
|
-
const Alert = React__namespace.forwardRef(({ className, variant, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, role: "alert", className: cn(alertVariants({ variant }), className), ...props }));
|
|
8413
|
-
Alert.displayName = "Alert";
|
|
8414
|
-
const AlertTitle = React__namespace.forwardRef(
|
|
8415
|
-
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("h5", { ref, className: cn("mb-1 font-medium leading-none tracking-tight", className), ...props })
|
|
8416
|
-
);
|
|
8417
|
-
AlertTitle.displayName = "AlertTitle";
|
|
8418
|
-
const AlertDescription = React__namespace.forwardRef(
|
|
8419
|
-
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("text-sm [&_p]:leading-relaxed", className), ...props })
|
|
8420
|
-
);
|
|
8421
|
-
AlertDescription.displayName = "AlertDescription";
|
|
8422
|
-
|
|
8423
|
-
const ErrorMessage = ({ error }) => /* @__PURE__ */ jsxRuntime.jsxs(Alert, { variant: "destructive", children: [
|
|
8424
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircle, { className: "h-4 w-4" }),
|
|
8425
|
-
/* @__PURE__ */ jsxRuntime.jsx(AlertTitle, { children: error })
|
|
8426
|
-
] });
|
|
8374
|
+
) });
|
|
8375
|
+
}
|
|
8427
8376
|
|
|
8428
|
-
|
|
8377
|
+
function WorkflowGraph({ workflowId, onShowTrace, workflow, isLoading }) {
|
|
8378
|
+
const { snapshot } = React.useContext(WorkflowRunContext);
|
|
8379
|
+
if (isLoading) {
|
|
8380
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4", children: /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-full" }) });
|
|
8381
|
+
}
|
|
8382
|
+
if (!workflow) {
|
|
8383
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid h-full place-items-center", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-2", children: [
|
|
8384
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircleIcon, {}),
|
|
8385
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
8386
|
+
"We couldn't find ",
|
|
8387
|
+
lodashTitleCase(workflowId),
|
|
8388
|
+
" workflow."
|
|
8389
|
+
] })
|
|
8390
|
+
] }) });
|
|
8391
|
+
}
|
|
8392
|
+
return /* @__PURE__ */ jsxRuntime.jsx(WorkflowNestedGraphProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(react$2.ReactFlowProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8393
|
+
WorkflowGraphInner,
|
|
8394
|
+
{
|
|
8395
|
+
workflow: snapshot?.serializedStepGraph ? { stepGraph: snapshot?.serializedStepGraph } : workflow,
|
|
8396
|
+
onShowTrace
|
|
8397
|
+
}
|
|
8398
|
+
) }) }, snapshot?.runId ?? workflowId);
|
|
8399
|
+
}
|
|
8429
8400
|
|
|
8430
|
-
const
|
|
8431
|
-
const
|
|
8432
|
-
|
|
8401
|
+
const useWorkflowRuns = (workflowId) => {
|
|
8402
|
+
const [runs, setRuns] = React.useState(null);
|
|
8403
|
+
const [isLoading, setIsLoading] = React.useState(true);
|
|
8404
|
+
const client = useMastraClient();
|
|
8405
|
+
React.useEffect(() => {
|
|
8406
|
+
const fetchWorkflow = async () => {
|
|
8407
|
+
setIsLoading(true);
|
|
8408
|
+
try {
|
|
8409
|
+
if (!workflowId) {
|
|
8410
|
+
setRuns(null);
|
|
8411
|
+
setIsLoading(false);
|
|
8412
|
+
return;
|
|
8413
|
+
}
|
|
8414
|
+
const res = await client.getWorkflow(workflowId).runs({ limit: 50 });
|
|
8415
|
+
setRuns(res);
|
|
8416
|
+
} catch (error) {
|
|
8417
|
+
setRuns(null);
|
|
8418
|
+
console.error("Error fetching workflow", error);
|
|
8419
|
+
sonner.toast.error("Error fetching workflow");
|
|
8420
|
+
} finally {
|
|
8421
|
+
setIsLoading(false);
|
|
8422
|
+
}
|
|
8423
|
+
};
|
|
8424
|
+
fetchWorkflow();
|
|
8425
|
+
}, [workflowId]);
|
|
8426
|
+
return { runs, isLoading };
|
|
8433
8427
|
};
|
|
8434
8428
|
|
|
8435
|
-
const
|
|
8436
|
-
const
|
|
8429
|
+
const useWorkflow = (workflowId) => {
|
|
8430
|
+
const [workflow, setWorkflow] = React.useState(null);
|
|
8431
|
+
const [isLoading, setIsLoading] = React.useState(true);
|
|
8432
|
+
const client = useMastraClient();
|
|
8437
8433
|
React.useEffect(() => {
|
|
8438
|
-
|
|
8439
|
-
|
|
8440
|
-
|
|
8441
|
-
|
|
8442
|
-
|
|
8443
|
-
|
|
8444
|
-
|
|
8445
|
-
Input,
|
|
8446
|
-
{
|
|
8447
|
-
id,
|
|
8448
|
-
type: "number",
|
|
8449
|
-
className: error ? "border-destructive" : "",
|
|
8450
|
-
...props,
|
|
8451
|
-
defaultValue: field.default !== void 0 ? Number(field.default) : void 0,
|
|
8452
|
-
onChange: (e) => {
|
|
8453
|
-
const value = e.target.value;
|
|
8454
|
-
if (value !== "" && !isNaN(Number(value))) {
|
|
8455
|
-
props.onChange({
|
|
8456
|
-
target: { value, name: inputProps.name }
|
|
8457
|
-
});
|
|
8434
|
+
const fetchWorkflow = async () => {
|
|
8435
|
+
setIsLoading(true);
|
|
8436
|
+
try {
|
|
8437
|
+
if (!workflowId) {
|
|
8438
|
+
setWorkflow(null);
|
|
8439
|
+
setIsLoading(false);
|
|
8440
|
+
return;
|
|
8458
8441
|
}
|
|
8459
|
-
|
|
8460
|
-
|
|
8461
|
-
|
|
8462
|
-
|
|
8463
|
-
|
|
8464
|
-
|
|
8465
|
-
});
|
|
8442
|
+
const res = await client.getWorkflow(workflowId).details();
|
|
8443
|
+
if (!res) {
|
|
8444
|
+
setWorkflow(null);
|
|
8445
|
+
console.error("Error fetching workflow");
|
|
8446
|
+
sonner.toast.error("Error fetching workflow");
|
|
8447
|
+
return;
|
|
8466
8448
|
}
|
|
8449
|
+
setWorkflow(res);
|
|
8450
|
+
} catch (error) {
|
|
8451
|
+
setWorkflow(null);
|
|
8452
|
+
console.error("Error fetching workflow", error);
|
|
8453
|
+
sonner.toast.error("Error fetching workflow");
|
|
8454
|
+
} finally {
|
|
8455
|
+
setIsLoading(false);
|
|
8467
8456
|
}
|
|
8468
|
-
}
|
|
8469
|
-
|
|
8457
|
+
};
|
|
8458
|
+
fetchWorkflow();
|
|
8459
|
+
}, [workflowId]);
|
|
8460
|
+
return { workflow, isLoading };
|
|
8470
8461
|
};
|
|
8471
|
-
|
|
8472
|
-
const
|
|
8473
|
-
|
|
8474
|
-
|
|
8475
|
-
|
|
8476
|
-
|
|
8477
|
-
|
|
8478
|
-
|
|
8479
|
-
|
|
8480
|
-
|
|
8481
|
-
|
|
8482
|
-
|
|
8483
|
-
|
|
8484
|
-
|
|
8485
|
-
|
|
8486
|
-
|
|
8487
|
-
|
|
8488
|
-
|
|
8462
|
+
const useLegacyWorkflow = (workflowId) => {
|
|
8463
|
+
const [legacyWorkflow, setLegacyWorkflow] = React.useState(null);
|
|
8464
|
+
const [isLoading, setIsLoading] = React.useState(true);
|
|
8465
|
+
const client = useMastraClient();
|
|
8466
|
+
React.useEffect(() => {
|
|
8467
|
+
const fetchWorkflow = async () => {
|
|
8468
|
+
setIsLoading(true);
|
|
8469
|
+
try {
|
|
8470
|
+
if (!workflowId) {
|
|
8471
|
+
setLegacyWorkflow(null);
|
|
8472
|
+
setIsLoading(false);
|
|
8473
|
+
return;
|
|
8474
|
+
}
|
|
8475
|
+
const res = await client.getLegacyWorkflow(workflowId).details();
|
|
8476
|
+
if (!res) {
|
|
8477
|
+
setLegacyWorkflow(null);
|
|
8478
|
+
console.error("Error fetching legacy workflow");
|
|
8479
|
+
sonner.toast.error("Error fetching legacy workflow");
|
|
8480
|
+
return;
|
|
8481
|
+
}
|
|
8482
|
+
const steps = res.steps;
|
|
8483
|
+
const stepsWithWorkflow = await Promise.all(
|
|
8484
|
+
Object.values(steps)?.map(async (step) => {
|
|
8485
|
+
if (!step.workflowId) return step;
|
|
8486
|
+
const wFlow = await client.getLegacyWorkflow(step.workflowId).details();
|
|
8487
|
+
if (!wFlow) return step;
|
|
8488
|
+
return { ...step, stepGraph: wFlow.stepGraph, stepSubscriberGraph: wFlow.stepSubscriberGraph };
|
|
8489
|
+
})
|
|
8490
|
+
);
|
|
8491
|
+
const _steps = stepsWithWorkflow.reduce((acc, b) => {
|
|
8492
|
+
return { ...acc, [b.id]: b };
|
|
8493
|
+
}, {});
|
|
8494
|
+
setLegacyWorkflow({ ...res, steps: _steps });
|
|
8495
|
+
} catch (error) {
|
|
8496
|
+
setLegacyWorkflow(null);
|
|
8497
|
+
console.error("Error fetching legacy workflow", error);
|
|
8498
|
+
sonner.toast.error("Error fetching legacy workflow");
|
|
8499
|
+
} finally {
|
|
8500
|
+
setIsLoading(false);
|
|
8501
|
+
}
|
|
8502
|
+
};
|
|
8503
|
+
fetchWorkflow();
|
|
8504
|
+
}, [workflowId]);
|
|
8505
|
+
return { legacyWorkflow, isLoading };
|
|
8506
|
+
};
|
|
8507
|
+
const useExecuteWorkflow = () => {
|
|
8508
|
+
const client = useMastraClient();
|
|
8509
|
+
const createLegacyWorkflowRun = async ({ workflowId, prevRunId }) => {
|
|
8510
|
+
try {
|
|
8511
|
+
const workflow = client.getLegacyWorkflow(workflowId);
|
|
8512
|
+
const { runId: newRunId } = await workflow.createRun({ runId: prevRunId });
|
|
8513
|
+
return { runId: newRunId };
|
|
8514
|
+
} catch (error) {
|
|
8515
|
+
console.error("Error creating workflow run:", error);
|
|
8516
|
+
throw error;
|
|
8517
|
+
}
|
|
8518
|
+
};
|
|
8519
|
+
const startLegacyWorkflowRun = async ({
|
|
8520
|
+
workflowId,
|
|
8521
|
+
runId,
|
|
8522
|
+
input
|
|
8523
|
+
}) => {
|
|
8524
|
+
try {
|
|
8525
|
+
const workflow = client.getLegacyWorkflow(workflowId);
|
|
8526
|
+
await workflow.start({ runId, triggerData: input || {} });
|
|
8527
|
+
} catch (error) {
|
|
8528
|
+
console.error("Error starting workflow run:", error);
|
|
8529
|
+
throw error;
|
|
8530
|
+
}
|
|
8531
|
+
};
|
|
8532
|
+
return {
|
|
8533
|
+
startLegacyWorkflowRun,
|
|
8534
|
+
createLegacyWorkflowRun
|
|
8535
|
+
};
|
|
8536
|
+
};
|
|
8537
|
+
const useWatchWorkflow = () => {
|
|
8538
|
+
const [isWatchingLegacyWorkflow, setIsWatchingLegacyWorkflow] = React.useState(false);
|
|
8539
|
+
const [legacyWatchResult, setLegacyWatchResult] = React.useState(null);
|
|
8540
|
+
const client = useMastraClient();
|
|
8541
|
+
const debouncedSetLegacyWorkflowWatchResult = useDebounce.useDebouncedCallback((record) => {
|
|
8542
|
+
const formattedResults = Object.entries(record.results || {}).reduce(
|
|
8543
|
+
(acc, [key, value]) => {
|
|
8544
|
+
let output = value.status === "success" ? value.output : void 0;
|
|
8545
|
+
if (output) {
|
|
8546
|
+
output = Object.entries(output).reduce(
|
|
8547
|
+
(_acc, [_key, _value]) => {
|
|
8548
|
+
const val = _value;
|
|
8549
|
+
_acc[_key] = val.type?.toLowerCase() === "buffer" ? { type: "Buffer", data: `[...buffered data]` } : val;
|
|
8550
|
+
return _acc;
|
|
8551
|
+
},
|
|
8552
|
+
{}
|
|
8553
|
+
);
|
|
8554
|
+
}
|
|
8555
|
+
acc[key] = { ...value, output };
|
|
8556
|
+
return acc;
|
|
8557
|
+
},
|
|
8558
|
+
{}
|
|
8559
|
+
);
|
|
8560
|
+
const sanitizedRecord = {
|
|
8561
|
+
...record,
|
|
8562
|
+
sanitizedOutput: record ? JSON.stringify({ ...record, results: formattedResults }, null, 2).slice(0, 5e4) : null
|
|
8563
|
+
};
|
|
8564
|
+
setLegacyWatchResult(sanitizedRecord);
|
|
8565
|
+
}, 100);
|
|
8566
|
+
const watchLegacyWorkflow = async ({ workflowId, runId }) => {
|
|
8567
|
+
try {
|
|
8568
|
+
setIsWatchingLegacyWorkflow(true);
|
|
8569
|
+
const workflow = client.getLegacyWorkflow(workflowId);
|
|
8570
|
+
await workflow.watch({ runId }, (record) => {
|
|
8571
|
+
try {
|
|
8572
|
+
debouncedSetLegacyWorkflowWatchResult(record);
|
|
8573
|
+
} catch (err) {
|
|
8574
|
+
console.error("Error processing workflow record:", err);
|
|
8575
|
+
setLegacyWatchResult({
|
|
8576
|
+
...record
|
|
8577
|
+
});
|
|
8578
|
+
}
|
|
8579
|
+
});
|
|
8580
|
+
} catch (error) {
|
|
8581
|
+
console.error("Error watching workflow:", error);
|
|
8582
|
+
throw error;
|
|
8583
|
+
} finally {
|
|
8584
|
+
setIsWatchingLegacyWorkflow(false);
|
|
8585
|
+
}
|
|
8586
|
+
};
|
|
8587
|
+
return {
|
|
8588
|
+
watchLegacyWorkflow,
|
|
8589
|
+
isWatchingLegacyWorkflow,
|
|
8590
|
+
legacyWatchResult
|
|
8591
|
+
};
|
|
8592
|
+
};
|
|
8593
|
+
const useResumeWorkflow = () => {
|
|
8594
|
+
const [isResumingLegacyWorkflow, setIsResumingLegacyWorkflow] = React.useState(false);
|
|
8595
|
+
const client = useMastraClient();
|
|
8596
|
+
const resumeLegacyWorkflow = async ({
|
|
8597
|
+
workflowId,
|
|
8598
|
+
stepId,
|
|
8599
|
+
runId,
|
|
8600
|
+
context
|
|
8601
|
+
}) => {
|
|
8602
|
+
try {
|
|
8603
|
+
setIsResumingLegacyWorkflow(true);
|
|
8604
|
+
const response = await client.getLegacyWorkflow(workflowId).resume({ stepId, runId, context });
|
|
8605
|
+
return response;
|
|
8606
|
+
} catch (error) {
|
|
8607
|
+
console.error("Error resuming workflow:", error);
|
|
8608
|
+
throw error;
|
|
8609
|
+
} finally {
|
|
8610
|
+
setIsResumingLegacyWorkflow(false);
|
|
8611
|
+
}
|
|
8612
|
+
};
|
|
8613
|
+
return {
|
|
8614
|
+
resumeLegacyWorkflow,
|
|
8615
|
+
isResumingLegacyWorkflow
|
|
8616
|
+
};
|
|
8617
|
+
};
|
|
8618
|
+
|
|
8619
|
+
const LabelMappings = {
|
|
8620
|
+
"routing-step": "Decision making process",
|
|
8621
|
+
"agent-step": "Agent execution",
|
|
8622
|
+
"workflow-step": "Workflow execution"
|
|
8623
|
+
};
|
|
8624
|
+
const StepDropdown = () => {
|
|
8625
|
+
const [isExpanded, setIsExpanded] = React.useState(false);
|
|
8626
|
+
const { state } = useVNextNetworkChat();
|
|
8627
|
+
const message = react.useMessage();
|
|
8628
|
+
const id = message?.metadata?.custom?.id;
|
|
8629
|
+
if (!id) return /* @__PURE__ */ jsxRuntime.jsx("div", { children: "Something is wrong" });
|
|
8630
|
+
const currentState = state[id];
|
|
8631
|
+
const latestStepId = currentState.executionSteps[currentState.executionSteps.length - 1];
|
|
8632
|
+
const hasFinished = latestStepId === "finish";
|
|
8633
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
8634
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Button, { onClick: () => setIsExpanded(!isExpanded), children: [
|
|
8635
|
+
hasFinished ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
8636
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(CheckIcon, { className: "text-accent1" }) }),
|
|
8637
|
+
"Done"
|
|
8638
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
8639
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(Spinner, { className: "animate-spin" }) }),
|
|
8640
|
+
"Thinking..."
|
|
8641
|
+
] }),
|
|
8642
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "ml-2", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: clsx("transition-transform -rotate-90", isExpanded && "rotate-0") }) })
|
|
8643
|
+
] }),
|
|
8644
|
+
isExpanded ? /* @__PURE__ */ jsxRuntime.jsx(Steps, { id }) : null
|
|
8645
|
+
] });
|
|
8646
|
+
};
|
|
8647
|
+
const Steps = ({ id }) => {
|
|
8648
|
+
const { state } = useVNextNetworkChat();
|
|
8649
|
+
const currentState = state[id];
|
|
8650
|
+
return /* @__PURE__ */ jsxRuntime.jsx("ol", { className: "flex flex-col gap-px rounded-lg overflow-hidden", children: currentState.executionSteps.filter((stepId) => stepId !== "start").map((stepId, index) => /* @__PURE__ */ jsxRuntime.jsx(StepEntry, { stepId, step: currentState.steps[stepId], runId: currentState.runId }, index)) });
|
|
8651
|
+
};
|
|
8652
|
+
const StepEntry = ({ stepId, step, runId }) => {
|
|
8653
|
+
const [expanded, setExpanded] = React.useState(false);
|
|
8654
|
+
const stepResult = step["step-result"];
|
|
8655
|
+
if (stepId === "finish") {
|
|
8656
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-surface4 py-2 px-3 text-icon6 flex items-center gap-4 justify-between", children: /* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-sm", className: "text-icon6", children: "Process completed" }) });
|
|
8657
|
+
}
|
|
8658
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
|
|
8659
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
8660
|
+
"button",
|
|
8661
|
+
{
|
|
8662
|
+
className: "bg-surface4 py-2 px-3 text-icon6 flex items-center gap-4 justify-between w-full text-left",
|
|
8663
|
+
onClick: () => setExpanded((s) => !s),
|
|
8664
|
+
children: [
|
|
8665
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
8666
|
+
/* @__PURE__ */ jsxRuntime.jsx(StatusIcon, { status: stepResult ? stepResult?.status : "loading" }),
|
|
8667
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-sm", className: "text-icon6", children: LabelMappings[stepId] || stepId })
|
|
8668
|
+
] }),
|
|
8669
|
+
step.metadata?.startTime && /* @__PURE__ */ jsxRuntime.jsx(StepClock, { step })
|
|
8670
|
+
]
|
|
8671
|
+
}
|
|
8672
|
+
),
|
|
8673
|
+
stepId === "routing-step" && expanded && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-surface1 p-3 space-y-4", children: [
|
|
8674
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
8675
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-sm", className: "text-icon3 font-medium", children: "Selection reason:" }),
|
|
8676
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-sm", className: "text-icon6", children: stepResult?.output?.selectionReason || "N/A" })
|
|
8677
|
+
] }),
|
|
8678
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
8679
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-sm", className: "text-icon3 font-medium", children: "Resource ID" }),
|
|
8680
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-sm", className: "text-icon6", children: stepResult?.output?.resourceId || "N/A" })
|
|
8681
|
+
] })
|
|
8682
|
+
] }),
|
|
8683
|
+
stepId === "workflow-step" && stepResult?.output?.resourceId ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
8684
|
+
WorkflowStepResultDialog,
|
|
8685
|
+
{
|
|
8686
|
+
open: expanded,
|
|
8687
|
+
onOpenChange: setExpanded,
|
|
8688
|
+
workflowId: stepResult?.output?.resourceId,
|
|
8689
|
+
runId
|
|
8690
|
+
}
|
|
8691
|
+
) : null
|
|
8692
|
+
] });
|
|
8693
|
+
};
|
|
8694
|
+
const WorkflowStepResultDialog = ({ open, onOpenChange, workflowId, runId }) => {
|
|
8695
|
+
const { runs } = useWorkflowRuns(workflowId);
|
|
8696
|
+
const { workflow, isLoading } = useWorkflow(workflowId);
|
|
8697
|
+
const run = runs?.runs.find((run2) => run2.runId === runId);
|
|
8698
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxRuntime.jsx(DialogPortal, { children: /* @__PURE__ */ jsxRuntime.jsx(DialogContent, { className: "h-[90vh] w-[90%] max-w-[unset]", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 h-full", children: [
|
|
8699
|
+
/* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { children: "Workflow details" }),
|
|
8700
|
+
/* @__PURE__ */ jsxRuntime.jsx(WorkflowRunProvider, { snapshot: typeof run?.snapshot === "object" ? run.snapshot : void 0, children: /* @__PURE__ */ jsxRuntime.jsx(WorkflowGraph, { workflowId, workflow, isLoading }) })
|
|
8701
|
+
] }) }) }) });
|
|
8702
|
+
};
|
|
8703
|
+
const StatusIcon = ({ status }) => {
|
|
8704
|
+
if (status === "error") {
|
|
8705
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(CrossIcon, { className: "text-accent2" }) });
|
|
8706
|
+
}
|
|
8707
|
+
if (status === "success") {
|
|
8708
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(CheckIcon, { className: "text-accent1" }) });
|
|
8709
|
+
}
|
|
8710
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(Spinner, { className: "animate-spin" }) });
|
|
8711
|
+
};
|
|
8712
|
+
const StepClock = ({ step }) => {
|
|
8713
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Badge$1, { children: /* @__PURE__ */ jsxRuntime.jsx(Clock, { startedAt: step.metadata.startTime, endedAt: step.metadata?.endTime }) });
|
|
8714
|
+
};
|
|
8715
|
+
|
|
8716
|
+
const NextAssistantMessage = ({
|
|
8717
|
+
ToolFallback: ToolFallbackCustom
|
|
8718
|
+
}) => {
|
|
8719
|
+
const data = react.useMessage();
|
|
8720
|
+
const isSolelyToolCall = data.content.length === 1 && data.content[0].type === "tool-call";
|
|
8721
|
+
const content = data.content[0];
|
|
8722
|
+
if (!content) {
|
|
8723
|
+
return null;
|
|
8724
|
+
}
|
|
8725
|
+
const textContent = content.text;
|
|
8726
|
+
if (textContent === "start") {
|
|
8727
|
+
return /* @__PURE__ */ jsxRuntime.jsx(StepDropdown, {});
|
|
8728
|
+
}
|
|
8729
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(react.MessagePrimitive.Root, { className: "max-w-full", children: [
|
|
8730
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-icon6 text-ui-lg leading-ui-lg", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8731
|
+
react.MessagePrimitive.Content,
|
|
8732
|
+
{
|
|
8733
|
+
components: {
|
|
8734
|
+
Text: MarkdownText,
|
|
8735
|
+
tools: { Fallback: ToolFallbackCustom || ToolFallback$1 }
|
|
8736
|
+
}
|
|
8737
|
+
}
|
|
8738
|
+
) }),
|
|
8739
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-6 pt-1", children: !isSolelyToolCall && /* @__PURE__ */ jsxRuntime.jsx(AssistantActionBar, {}) })
|
|
8740
|
+
] });
|
|
8741
|
+
};
|
|
8742
|
+
const AssistantActionBar = () => {
|
|
8743
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
8744
|
+
react.ActionBarPrimitive.Root,
|
|
8489
8745
|
{
|
|
8490
|
-
|
|
8491
|
-
|
|
8492
|
-
|
|
8493
|
-
|
|
8494
|
-
|
|
8495
|
-
|
|
8746
|
+
hideWhenRunning: true,
|
|
8747
|
+
autohide: "always",
|
|
8748
|
+
autohideFloat: "single-branch",
|
|
8749
|
+
className: "flex gap-1 items-center transition-all",
|
|
8750
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(react.ActionBarPrimitive.Copy, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(TooltipIconButton, { tooltip: "Copy", className: "bg-transparent text-icon3 hover:text-icon6", children: [
|
|
8751
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.MessagePrimitive.If, { copied: true, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CheckIcon, {}) }),
|
|
8752
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.MessagePrimitive.If, { copied: false, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CopyIcon, {}) })
|
|
8753
|
+
] }) })
|
|
8754
|
+
}
|
|
8755
|
+
);
|
|
8756
|
+
};
|
|
8757
|
+
|
|
8758
|
+
const NetworkThread = ({ ToolFallback, networkName, hasMemory, showFileSupport }) => {
|
|
8759
|
+
const areaRef = React.useRef(null);
|
|
8760
|
+
useAutoscroll(areaRef, { enabled: true });
|
|
8761
|
+
const WrappedAssistantMessage = (props) => {
|
|
8762
|
+
return /* @__PURE__ */ jsxRuntime.jsx(NextAssistantMessage, { ...props, ToolFallback });
|
|
8763
|
+
};
|
|
8764
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ThreadWrapper, { children: [
|
|
8765
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react.ThreadPrimitive.Viewport, { className: "py-10 overflow-y-auto scroll-smooth h-full", ref: areaRef, autoScroll: false, children: [
|
|
8766
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
8767
|
+
/* @__PURE__ */ jsxRuntime.jsx(ThreadWelcome, { networkName }),
|
|
8768
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8769
|
+
react.ThreadPrimitive.Messages,
|
|
8770
|
+
{
|
|
8771
|
+
components: {
|
|
8772
|
+
UserMessage,
|
|
8773
|
+
EditComposer,
|
|
8774
|
+
AssistantMessage: WrappedAssistantMessage
|
|
8775
|
+
}
|
|
8776
|
+
}
|
|
8777
|
+
)
|
|
8778
|
+
] }),
|
|
8779
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.ThreadPrimitive.If, { empty: false, children: /* @__PURE__ */ jsxRuntime.jsx("div", {}) })
|
|
8780
|
+
] }),
|
|
8781
|
+
/* @__PURE__ */ jsxRuntime.jsx(Composer, { hasMemory, showFileSupport })
|
|
8782
|
+
] });
|
|
8783
|
+
};
|
|
8784
|
+
const ThreadWrapper = ({ children }) => {
|
|
8785
|
+
const hasAttachments = useHasAttachments();
|
|
8786
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
8787
|
+
react.ThreadPrimitive.Root,
|
|
8788
|
+
{
|
|
8789
|
+
className: clsx(
|
|
8790
|
+
"max-w-[568px] w-full mx-auto px-4",
|
|
8791
|
+
hasAttachments ? "h-[calc(100%-208px)]" : "h-[calc(100%-112px)]"
|
|
8792
|
+
),
|
|
8793
|
+
children
|
|
8794
|
+
}
|
|
8795
|
+
);
|
|
8796
|
+
};
|
|
8797
|
+
const ThreadWelcome = ({ networkName }) => {
|
|
8798
|
+
const safeNetworkName = networkName ?? "";
|
|
8799
|
+
const words = safeNetworkName.split(" ") ?? [];
|
|
8800
|
+
let initials = "A";
|
|
8801
|
+
if (words.length === 2) {
|
|
8802
|
+
initials = `${words[0][0]}${words[1][0]}`;
|
|
8803
|
+
} else if (safeNetworkName.length > 0) {
|
|
8804
|
+
initials = `${safeNetworkName[0]}`;
|
|
8805
|
+
} else {
|
|
8806
|
+
initials = "A";
|
|
8807
|
+
}
|
|
8808
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.ThreadPrimitive.Empty, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full flex-grow flex-col items-center justify-center", children: [
|
|
8809
|
+
/* @__PURE__ */ jsxRuntime.jsx(Avatar, { children: /* @__PURE__ */ jsxRuntime.jsx(AvatarFallback, { children: initials }) }),
|
|
8810
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-4 font-medium", children: "How can I help you today?" })
|
|
8811
|
+
] }) });
|
|
8812
|
+
};
|
|
8813
|
+
const Composer = ({ hasMemory, showFileSupport }) => {
|
|
8814
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
8815
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react.ComposerPrimitive.Root, { children: [
|
|
8816
|
+
/* @__PURE__ */ jsxRuntime.jsx(ComposerAttachments, {}),
|
|
8817
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full bg-surface3 rounded-lg border-sm border-border1 px-3 py-4 mt-auto h-[100px]", children: [
|
|
8818
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.ComposerPrimitive.Input, { asChild: true, className: "w-full", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8819
|
+
"textarea",
|
|
8820
|
+
{
|
|
8821
|
+
className: "text-ui-lg leading-ui-lg placeholder:text-icon3 text-icon6 bg-transparent focus:outline-none resize-none",
|
|
8822
|
+
autoFocus: true,
|
|
8823
|
+
placeholder: "Enter your message...",
|
|
8824
|
+
name: "",
|
|
8825
|
+
id: ""
|
|
8496
8826
|
}
|
|
8497
|
-
}
|
|
8498
|
-
|
|
8499
|
-
|
|
8500
|
-
|
|
8501
|
-
|
|
8502
|
-
|
|
8503
|
-
|
|
8504
|
-
|
|
8505
|
-
|
|
8506
|
-
|
|
8507
|
-
|
|
8508
|
-
] });
|
|
8509
|
-
|
|
8510
|
-
|
|
8827
|
+
) }),
|
|
8828
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
8829
|
+
/* @__PURE__ */ jsxRuntime.jsx(SpeechInput, {}),
|
|
8830
|
+
/* @__PURE__ */ jsxRuntime.jsx(ComposerAction, { showFileSupport })
|
|
8831
|
+
] })
|
|
8832
|
+
] })
|
|
8833
|
+
] }),
|
|
8834
|
+
!hasMemory && /* @__PURE__ */ jsxRuntime.jsxs(Txt, { variant: "ui-sm", className: "text-icon3 flex items-center gap-2 pt-0.5", children: [
|
|
8835
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(InfoIcon, {}) }),
|
|
8836
|
+
"Memory is not enabled. The conversation will not be persisted."
|
|
8837
|
+
] })
|
|
8838
|
+
] });
|
|
8839
|
+
};
|
|
8840
|
+
const SpeechInput = () => {
|
|
8841
|
+
const composerRuntime = react.useComposerRuntime();
|
|
8842
|
+
const { start, stop, isListening, transcript } = useSpeechRecognition();
|
|
8843
|
+
React.useEffect(() => {
|
|
8844
|
+
if (!transcript) return;
|
|
8845
|
+
composerRuntime.setText(transcript);
|
|
8846
|
+
}, [composerRuntime, transcript]);
|
|
8511
8847
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
8512
|
-
|
|
8848
|
+
TooltipIconButton,
|
|
8513
8849
|
{
|
|
8514
|
-
|
|
8515
|
-
|
|
8516
|
-
|
|
8517
|
-
|
|
8518
|
-
|
|
8519
|
-
|
|
8520
|
-
caption_label: "text-sm text-text font-medium",
|
|
8521
|
-
nav: "space-x-1 flex items-center",
|
|
8522
|
-
nav_button_previous: cn(
|
|
8523
|
-
buttonVariants({ variant: "outline" }),
|
|
8524
|
-
"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100",
|
|
8525
|
-
"absolute left-4 top-[56px] z-10"
|
|
8526
|
-
),
|
|
8527
|
-
nav_button_next: cn(
|
|
8528
|
-
buttonVariants({ variant: "outline" }),
|
|
8529
|
-
"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100",
|
|
8530
|
-
"absolute right-4 top-[56px] z-10"
|
|
8531
|
-
),
|
|
8532
|
-
dropdown_month: "w-full border-collapse space-y-1",
|
|
8533
|
-
weeknumber: "flex",
|
|
8534
|
-
day: cn(
|
|
8535
|
-
buttonVariants({ variant: "ghost" }),
|
|
8536
|
-
"relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected].day-range-end)]:rounded-r-md",
|
|
8537
|
-
props.mode === "range" ? "[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md" : "[&:has([aria-selected])]:rounded-md",
|
|
8538
|
-
"h-8 w-8 p-0 hover:bg-lightGray-7/50 font-normal aria-selected:opacity-100"
|
|
8539
|
-
),
|
|
8540
|
-
day_range_start: "day-range-start",
|
|
8541
|
-
day_range_end: "day-range-end",
|
|
8542
|
-
day_selected: "!bg-primary !text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",
|
|
8543
|
-
day_today: "bg-lightGray-7/50 text-accent-foreground",
|
|
8544
|
-
day_outside: "day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",
|
|
8545
|
-
day_disabled: "text-muted-foreground opacity-50",
|
|
8546
|
-
day_range_middle: "aria-selected:bg-accent aria-selected:text-accent-foreground",
|
|
8547
|
-
day_hidden: "invisible",
|
|
8548
|
-
...classNames
|
|
8549
|
-
},
|
|
8550
|
-
components: {
|
|
8551
|
-
// IconDropdown: ({ }) => (
|
|
8552
|
-
// <CalendarIcon
|
|
8553
|
-
// className={cn('h-4 w-4', {
|
|
8554
|
-
// 'rotate-180': orientation === 'up',
|
|
8555
|
-
// 'rotate-90': orientation === 'left',
|
|
8556
|
-
// '-rotate-90': orientation === 'right',
|
|
8557
|
-
// })}
|
|
8558
|
-
// />
|
|
8559
|
-
// ),
|
|
8560
|
-
},
|
|
8561
|
-
...props
|
|
8850
|
+
type: "button",
|
|
8851
|
+
tooltip: isListening ? "Stop dictation" : "Start dictation",
|
|
8852
|
+
variant: "ghost",
|
|
8853
|
+
className: "rounded-full",
|
|
8854
|
+
onClick: () => isListening ? stop() : start(),
|
|
8855
|
+
children: isListening ? /* @__PURE__ */ jsxRuntime.jsx(CircleStopIcon, {}) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Mic, { className: "h-6 w-6 text-[#898989] hover:text-[#fff]" })
|
|
8562
8856
|
}
|
|
8563
8857
|
);
|
|
8564
|
-
}
|
|
8565
|
-
|
|
8858
|
+
};
|
|
8859
|
+
const ComposerAction = ({ showFileSupport }) => {
|
|
8860
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
8861
|
+
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]" }) }) }),
|
|
8862
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.ThreadPrimitive.If, { running: false, children: /* @__PURE__ */ jsxRuntime.jsx(react.ComposerPrimitive.Send, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8863
|
+
TooltipIconButton,
|
|
8864
|
+
{
|
|
8865
|
+
tooltip: "Send",
|
|
8866
|
+
variant: "default",
|
|
8867
|
+
className: "rounded-full border-sm border-[#363636] bg-[#292929]",
|
|
8868
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowUp, { className: "h-6 w-6 text-[#898989] hover:text-[#fff]" })
|
|
8869
|
+
}
|
|
8870
|
+
) }) }),
|
|
8871
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.ThreadPrimitive.If, { running: true, children: /* @__PURE__ */ jsxRuntime.jsx(react.ComposerPrimitive.Cancel, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(TooltipIconButton, { tooltip: "Cancel", variant: "default", children: /* @__PURE__ */ jsxRuntime.jsx(CircleStopIcon, {}) }) }) })
|
|
8872
|
+
] });
|
|
8873
|
+
};
|
|
8874
|
+
const EditComposer = () => {
|
|
8875
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(react.ComposerPrimitive.Root, { children: [
|
|
8876
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.ComposerPrimitive.Input, {}),
|
|
8877
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
8878
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.ComposerPrimitive.Cancel, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(Button$1, { variant: "ghost", children: "Cancel" }) }),
|
|
8879
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.ComposerPrimitive.Send, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(Button$1, { children: "Send" }) })
|
|
8880
|
+
] })
|
|
8881
|
+
] });
|
|
8882
|
+
};
|
|
8883
|
+
const CircleStopIcon = () => {
|
|
8884
|
+
return /* @__PURE__ */ jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", fill: "currentColor", width: "16", height: "16", children: /* @__PURE__ */ jsxRuntime.jsx("rect", { width: "10", height: "10", x: "3", y: "3", rx: "2" }) });
|
|
8885
|
+
};
|
|
8566
8886
|
|
|
8567
|
-
const
|
|
8568
|
-
|
|
8569
|
-
|
|
8570
|
-
|
|
8571
|
-
{
|
|
8572
|
-
ref,
|
|
8573
|
-
align,
|
|
8574
|
-
sideOffset,
|
|
8575
|
-
className: cn(
|
|
8576
|
-
"z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none 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-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
8577
|
-
className
|
|
8578
|
-
),
|
|
8579
|
-
...props
|
|
8887
|
+
const MessagesContext = React.createContext({
|
|
8888
|
+
messages: [],
|
|
8889
|
+
setMessages: () => {
|
|
8890
|
+
},
|
|
8891
|
+
appendToLastMessage: () => {
|
|
8580
8892
|
}
|
|
8581
|
-
|
|
8582
|
-
|
|
8893
|
+
});
|
|
8894
|
+
const MessagesProvider = ({ children }) => {
|
|
8895
|
+
const [messages, setMessages] = React.useState([]);
|
|
8896
|
+
const appendToLastMessage = (partial) => setMessages((msgs) => {
|
|
8897
|
+
const lastMsg = msgs[msgs.length - 1];
|
|
8898
|
+
const content = typeof lastMsg.content === "string" ? lastMsg.content : (lastMsg.content?.[0]).text;
|
|
8899
|
+
return [
|
|
8900
|
+
...msgs.slice(0, -1),
|
|
8901
|
+
{
|
|
8902
|
+
...lastMsg,
|
|
8903
|
+
content: [{ type: "text", text: content + partial }]
|
|
8904
|
+
}
|
|
8905
|
+
];
|
|
8906
|
+
});
|
|
8907
|
+
return /* @__PURE__ */ jsxRuntime.jsx(MessagesContext.Provider, { value: { messages, setMessages, appendToLastMessage }, children });
|
|
8908
|
+
};
|
|
8909
|
+
const useMessages = () => React.useContext(MessagesContext);
|
|
8583
8910
|
|
|
8584
|
-
const
|
|
8585
|
-
|
|
8586
|
-
|
|
8911
|
+
const formatJSON = async (code) => {
|
|
8912
|
+
const formatted = await prettier.format(code, {
|
|
8913
|
+
semi: false,
|
|
8914
|
+
parser: "json",
|
|
8915
|
+
printWidth: 80,
|
|
8916
|
+
tabWidth: 2,
|
|
8917
|
+
plugins: [prettierPluginBabel, prettierPluginEstree]
|
|
8918
|
+
});
|
|
8919
|
+
return formatted;
|
|
8920
|
+
};
|
|
8921
|
+
|
|
8922
|
+
const convertMessage = (message) => {
|
|
8923
|
+
return message;
|
|
8924
|
+
};
|
|
8925
|
+
function VNextMastraNetworkRuntimeProvider({
|
|
8587
8926
|
children,
|
|
8588
|
-
|
|
8589
|
-
|
|
8590
|
-
|
|
8591
|
-
|
|
8592
|
-
|
|
8593
|
-
|
|
8594
|
-
|
|
8595
|
-
|
|
8596
|
-
|
|
8597
|
-
|
|
8598
|
-
|
|
8599
|
-
|
|
8600
|
-
|
|
8927
|
+
networkId,
|
|
8928
|
+
memory,
|
|
8929
|
+
threadId,
|
|
8930
|
+
refreshThreadList,
|
|
8931
|
+
initialMessages
|
|
8932
|
+
}) {
|
|
8933
|
+
const runIdRef = React.useRef(void 0);
|
|
8934
|
+
const [isRunning, setIsRunning] = React.useState(false);
|
|
8935
|
+
const { messages, setMessages, appendToLastMessage } = useMessages();
|
|
8936
|
+
const [currentThreadId, setCurrentThreadId] = React.useState(threadId);
|
|
8937
|
+
const { handleStep, state, setState } = useVNextNetworkChat();
|
|
8938
|
+
const id = runIdRef.current;
|
|
8939
|
+
const currentState = id ? state[id] : void 0;
|
|
8940
|
+
React.useEffect(() => {
|
|
8941
|
+
if (!currentState) return;
|
|
8942
|
+
const hasFinished = Boolean(currentState?.steps?.["finish"]);
|
|
8943
|
+
if (!hasFinished) return;
|
|
8944
|
+
const workflowStep = currentState?.steps?.["workflow-step"];
|
|
8945
|
+
if (!workflowStep) return;
|
|
8946
|
+
const workflowStepResult = workflowStep?.["step-result"];
|
|
8947
|
+
if (!workflowStepResult) return;
|
|
8948
|
+
const workflowStepResultOutput = workflowStepResult?.output;
|
|
8949
|
+
if (!workflowStepResultOutput) return;
|
|
8950
|
+
const run = async () => {
|
|
8951
|
+
const parsedResult = JSON.parse(workflowStepResult?.output?.result ?? "{}") ?? {};
|
|
8952
|
+
const runResult = parsedResult?.runResult ?? {};
|
|
8953
|
+
const formatted = await formatJSON(JSON.stringify(runResult));
|
|
8954
|
+
setMessages((msgs) => [
|
|
8955
|
+
...msgs,
|
|
8956
|
+
{ role: "assistant", content: [{ type: "text", text: `\`\`\`json
|
|
8957
|
+
${formatted}\`\`\`` }] }
|
|
8958
|
+
]);
|
|
8959
|
+
};
|
|
8960
|
+
run();
|
|
8961
|
+
}, [currentState]);
|
|
8962
|
+
React.useEffect(() => {
|
|
8963
|
+
const hasNewInitialMessages = initialMessages && initialMessages?.length > messages?.length;
|
|
8964
|
+
if (messages.length === 0 || currentThreadId !== threadId || hasNewInitialMessages && currentThreadId === threadId) {
|
|
8965
|
+
const run = async (result, messageId) => {
|
|
8966
|
+
const formatted = await formatJSON(result);
|
|
8967
|
+
const finalResponse = `\`\`\`json
|
|
8968
|
+
${formatted}\`\`\``;
|
|
8969
|
+
setMessages((currentConversation) => {
|
|
8970
|
+
return currentConversation.map((message) => {
|
|
8971
|
+
if (message.metadata?.custom?.id === messageId) {
|
|
8972
|
+
return { ...message, content: [{ type: "text", text: finalResponse }] };
|
|
8973
|
+
}
|
|
8974
|
+
return message;
|
|
8975
|
+
});
|
|
8976
|
+
});
|
|
8977
|
+
};
|
|
8978
|
+
if (initialMessages && threadId && memory) {
|
|
8979
|
+
for (const message of initialMessages) {
|
|
8980
|
+
if (message.role === "user") {
|
|
8981
|
+
setMessages((currentConversation) => [...currentConversation, message]);
|
|
8982
|
+
}
|
|
8983
|
+
if (message.role === "assistant") {
|
|
8984
|
+
const id2 = uuid.v4();
|
|
8985
|
+
const formattedMessageId = uuid.v4();
|
|
8986
|
+
const parts = message.parts;
|
|
8987
|
+
const routingStep = parts?.[2];
|
|
8988
|
+
const responseStep = parts?.[3];
|
|
8989
|
+
const routingDecision = JSON.parse(routingStep?.text ?? "{}");
|
|
8990
|
+
const resourceStepId = routingDecision?.resourceType === "agent" ? "agent-step" : "workflow-step";
|
|
8991
|
+
let finalResponse = responseStep?.text ?? "";
|
|
8992
|
+
let runId = "";
|
|
8993
|
+
let runResult = {};
|
|
8994
|
+
if (resourceStepId === "workflow-step") {
|
|
8995
|
+
const parsedResult = JSON.parse(responseStep?.text ?? "{}") ?? {};
|
|
8996
|
+
runResult = parsedResult?.runResult ?? {};
|
|
8997
|
+
runId = parsedResult?.runId ?? "";
|
|
8998
|
+
}
|
|
8999
|
+
setState((currentState2) => {
|
|
9000
|
+
return {
|
|
9001
|
+
...currentState2,
|
|
9002
|
+
[id2]: {
|
|
9003
|
+
executionSteps: ["start", "routing-step", resourceStepId, "finish"],
|
|
9004
|
+
runId,
|
|
9005
|
+
steps: {
|
|
9006
|
+
start: {},
|
|
9007
|
+
"routing-step": {
|
|
9008
|
+
"step-result": {
|
|
9009
|
+
output: routingDecision,
|
|
9010
|
+
status: "success"
|
|
9011
|
+
}
|
|
9012
|
+
},
|
|
9013
|
+
[resourceStepId]: {
|
|
9014
|
+
"step-result": {
|
|
9015
|
+
output: {
|
|
9016
|
+
resourceId: routingDecision?.resourceId
|
|
9017
|
+
},
|
|
9018
|
+
status: "success"
|
|
9019
|
+
}
|
|
9020
|
+
},
|
|
9021
|
+
finish: {}
|
|
9022
|
+
}
|
|
9023
|
+
}
|
|
9024
|
+
};
|
|
9025
|
+
});
|
|
9026
|
+
setMessages((currentConversation) => {
|
|
9027
|
+
return [
|
|
9028
|
+
...currentConversation,
|
|
9029
|
+
{
|
|
9030
|
+
role: "assistant",
|
|
9031
|
+
metadata: {
|
|
9032
|
+
custom: {
|
|
9033
|
+
id: id2
|
|
9034
|
+
}
|
|
9035
|
+
},
|
|
9036
|
+
content: [
|
|
9037
|
+
{
|
|
9038
|
+
type: "text",
|
|
9039
|
+
text: "start"
|
|
9040
|
+
}
|
|
9041
|
+
]
|
|
9042
|
+
},
|
|
9043
|
+
{
|
|
9044
|
+
role: "assistant",
|
|
9045
|
+
content: [{ type: "text", text: resourceStepId === "workflow-step" ? "" : finalResponse }],
|
|
9046
|
+
metadata: {
|
|
9047
|
+
custom: {
|
|
9048
|
+
id: formattedMessageId
|
|
9049
|
+
}
|
|
9050
|
+
}
|
|
9051
|
+
}
|
|
9052
|
+
];
|
|
9053
|
+
});
|
|
9054
|
+
if (resourceStepId === "workflow-step") {
|
|
9055
|
+
run(JSON.stringify(runResult), formattedMessageId);
|
|
9056
|
+
}
|
|
9057
|
+
}
|
|
9058
|
+
}
|
|
9059
|
+
setCurrentThreadId(threadId);
|
|
8601
9060
|
}
|
|
8602
|
-
|
|
8603
|
-
|
|
8604
|
-
|
|
8605
|
-
|
|
8606
|
-
|
|
8607
|
-
|
|
8608
|
-
|
|
8609
|
-
|
|
8610
|
-
|
|
8611
|
-
|
|
8612
|
-
|
|
8613
|
-
|
|
8614
|
-
|
|
8615
|
-
|
|
8616
|
-
|
|
9061
|
+
}
|
|
9062
|
+
}, [initialMessages, threadId, memory, messages]);
|
|
9063
|
+
const mastra = useMastraClient();
|
|
9064
|
+
const network = mastra.getVNextNetwork(networkId);
|
|
9065
|
+
const onNew = async (message) => {
|
|
9066
|
+
runIdRef.current = void 0;
|
|
9067
|
+
if (message.content[0]?.type !== "text") throw new Error("Only text messages are supported");
|
|
9068
|
+
const input = message.content[0].text;
|
|
9069
|
+
setMessages((currentConversation) => [...currentConversation, { role: "user", content: input }]);
|
|
9070
|
+
setIsRunning(true);
|
|
9071
|
+
try {
|
|
9072
|
+
await network.stream(
|
|
9073
|
+
{
|
|
9074
|
+
message: input,
|
|
9075
|
+
threadId,
|
|
9076
|
+
resourceId: networkId
|
|
9077
|
+
},
|
|
9078
|
+
(record) => {
|
|
9079
|
+
if (runIdRef.current) {
|
|
9080
|
+
if (record.type === "tool-call-delta") {
|
|
9081
|
+
appendToLastMessage(record.argsTextDelta);
|
|
9082
|
+
} else if (record.type === "tool-call-streaming-start") {
|
|
9083
|
+
setMessages((msgs) => [...msgs, { role: "assistant", content: [{ type: "text", text: "" }] }]);
|
|
9084
|
+
setTimeout(() => {
|
|
9085
|
+
refreshThreadList?.();
|
|
9086
|
+
}, 500);
|
|
9087
|
+
return;
|
|
9088
|
+
} else {
|
|
9089
|
+
handleStep(runIdRef.current, record);
|
|
9090
|
+
}
|
|
9091
|
+
} else if (record.type === "start") {
|
|
9092
|
+
const id2 = uuid.v4();
|
|
9093
|
+
runIdRef.current = id2;
|
|
9094
|
+
setMessages((currentConversation) => {
|
|
9095
|
+
return [
|
|
9096
|
+
...currentConversation,
|
|
9097
|
+
{
|
|
9098
|
+
role: "assistant",
|
|
9099
|
+
metadata: {
|
|
9100
|
+
custom: {
|
|
9101
|
+
id: id2
|
|
9102
|
+
}
|
|
9103
|
+
},
|
|
9104
|
+
content: [
|
|
9105
|
+
{
|
|
9106
|
+
type: "text",
|
|
9107
|
+
text: "start"
|
|
9108
|
+
}
|
|
9109
|
+
]
|
|
9110
|
+
}
|
|
9111
|
+
];
|
|
9112
|
+
});
|
|
8617
9113
|
}
|
|
8618
|
-
|
|
8619
|
-
|
|
8620
|
-
|
|
9114
|
+
setTimeout(() => {
|
|
9115
|
+
refreshThreadList?.();
|
|
9116
|
+
}, 500);
|
|
9117
|
+
}
|
|
9118
|
+
);
|
|
9119
|
+
setIsRunning(false);
|
|
9120
|
+
} catch (error) {
|
|
9121
|
+
console.error("Error occurred in VNextMastraNetworkRuntimeProvider", error);
|
|
9122
|
+
setIsRunning(false);
|
|
9123
|
+
}
|
|
9124
|
+
};
|
|
9125
|
+
const runtime = react.useExternalStoreRuntime({
|
|
9126
|
+
isRunning,
|
|
9127
|
+
messages,
|
|
9128
|
+
convertMessage,
|
|
9129
|
+
onNew
|
|
9130
|
+
});
|
|
9131
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(react.AssistantRuntimeProvider, { runtime, children: [
|
|
9132
|
+
" ",
|
|
9133
|
+
children,
|
|
9134
|
+
" "
|
|
8621
9135
|
] });
|
|
8622
|
-
}
|
|
8623
|
-
|
|
8624
|
-
|
|
8625
|
-
|
|
8626
|
-
|
|
8627
|
-
|
|
8628
|
-
|
|
8629
|
-
|
|
8630
|
-
|
|
9136
|
+
}
|
|
9137
|
+
|
|
9138
|
+
const VNextNetworkChat = ({
|
|
9139
|
+
networkId,
|
|
9140
|
+
networkName,
|
|
9141
|
+
threadId,
|
|
9142
|
+
initialMessages,
|
|
9143
|
+
memory,
|
|
9144
|
+
refreshThreadList
|
|
8631
9145
|
}) => {
|
|
8632
|
-
|
|
8633
|
-
|
|
8634
|
-
|
|
8635
|
-
|
|
8636
|
-
|
|
8637
|
-
|
|
8638
|
-
|
|
8639
|
-
|
|
8640
|
-
|
|
8641
|
-
|
|
8642
|
-
|
|
8643
|
-
|
|
8644
|
-
|
|
9146
|
+
return /* @__PURE__ */ jsxRuntime.jsx(MessagesProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(VNextNetworkChatProvider, { networkId, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9147
|
+
VNextMastraNetworkRuntimeProvider,
|
|
9148
|
+
{
|
|
9149
|
+
networkId,
|
|
9150
|
+
initialMessages: initialMessages ?? [],
|
|
9151
|
+
threadId,
|
|
9152
|
+
memory,
|
|
9153
|
+
refreshThreadList,
|
|
9154
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full pb-4", children: /* @__PURE__ */ jsxRuntime.jsx(NetworkThread, { hasMemory: memory, networkName }) })
|
|
9155
|
+
},
|
|
9156
|
+
threadId
|
|
9157
|
+
) }, threadId) }, threadId);
|
|
9158
|
+
};
|
|
9159
|
+
|
|
9160
|
+
function WorkflowTraces({ traces, error, runId, stepName }) {
|
|
9161
|
+
return /* @__PURE__ */ jsxRuntime.jsx(TraceProvider, { initialTraces: traces || [], children: /* @__PURE__ */ jsxRuntime.jsx(WorkflowTracesInner, { traces, error, runId, stepName }) });
|
|
9162
|
+
}
|
|
9163
|
+
function WorkflowTracesInner({ traces, error, runId, stepName }) {
|
|
9164
|
+
const hasRunRef = React.useRef(false);
|
|
9165
|
+
const [sidebarWidth, setSidebarWidth] = React.useState(100);
|
|
9166
|
+
const { isOpen: open, setTrace, setIsOpen, setSpan } = React.useContext(TraceContext);
|
|
9167
|
+
React.useEffect(() => {
|
|
9168
|
+
if (hasRunRef.current) return;
|
|
9169
|
+
if (!runId || !stepName) return;
|
|
9170
|
+
const matchingTrace = traces.find((trace) => trace.runId === runId);
|
|
9171
|
+
if (!matchingTrace) return;
|
|
9172
|
+
const matchingSpan = matchingTrace.trace.find((span) => span.name.includes(stepName));
|
|
9173
|
+
if (!matchingSpan) return;
|
|
9174
|
+
setTrace(matchingTrace.trace);
|
|
9175
|
+
setSpan(matchingSpan);
|
|
9176
|
+
setIsOpen(true);
|
|
9177
|
+
hasRunRef.current = true;
|
|
9178
|
+
}, [runId, traces, setTrace]);
|
|
9179
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("main", { className: "h-full relative overflow-hidden flex", children: [
|
|
9180
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full overflow-y-scroll w-full", children: /* @__PURE__ */ jsxRuntime.jsx(TracesTable, { traces, error }) }),
|
|
9181
|
+
open && /* @__PURE__ */ jsxRuntime.jsx(TracesSidebar, { width: sidebarWidth, onResize: setSidebarWidth })
|
|
9182
|
+
] });
|
|
9183
|
+
}
|
|
9184
|
+
|
|
9185
|
+
function LegacyWorkflowNestedGraph({
|
|
9186
|
+
stepGraph,
|
|
9187
|
+
stepSubscriberGraph,
|
|
9188
|
+
open
|
|
9189
|
+
}) {
|
|
9190
|
+
const { nodes: initialNodes, edges: initialEdges } = contructLegacyNodesAndEdges({
|
|
9191
|
+
stepGraph,
|
|
9192
|
+
stepSubscriberGraph
|
|
9193
|
+
});
|
|
9194
|
+
const [isMounted, setIsMounted] = React.useState(false);
|
|
9195
|
+
const [nodes, _, onNodesChange] = react$2.useNodesState(initialNodes);
|
|
9196
|
+
const [edges] = react$2.useEdgesState(initialEdges);
|
|
9197
|
+
const nodeTypes = {
|
|
9198
|
+
"default-node": WorkflowDefaultNode,
|
|
9199
|
+
"condition-node": WorkflowConditionNode,
|
|
9200
|
+
"after-node": WorkflowAfterNode,
|
|
9201
|
+
"loop-result-node": WorkflowLoopResultNode
|
|
8645
9202
|
};
|
|
8646
|
-
|
|
8647
|
-
|
|
8648
|
-
|
|
8649
|
-
|
|
8650
|
-
|
|
8651
|
-
setInputValue(dateFns.format(date, "PP"));
|
|
8652
|
-
} else {
|
|
8653
|
-
setInputValue("");
|
|
9203
|
+
React.useEffect(() => {
|
|
9204
|
+
if (open) {
|
|
9205
|
+
setTimeout(() => {
|
|
9206
|
+
setIsMounted(true);
|
|
9207
|
+
}, 500);
|
|
8654
9208
|
}
|
|
8655
|
-
};
|
|
8656
|
-
|
|
8657
|
-
|
|
8658
|
-
|
|
8659
|
-
|
|
8660
|
-
|
|
8661
|
-
|
|
9209
|
+
}, [open]);
|
|
9210
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full h-full relative", children: isMounted ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9211
|
+
react$2.ReactFlow,
|
|
9212
|
+
{
|
|
9213
|
+
nodes,
|
|
9214
|
+
edges,
|
|
9215
|
+
fitView: true,
|
|
9216
|
+
fitViewOptions: { maxZoom: 0.85 },
|
|
9217
|
+
nodeTypes,
|
|
9218
|
+
onNodesChange,
|
|
9219
|
+
children: [
|
|
9220
|
+
/* @__PURE__ */ jsxRuntime.jsx(react$2.Controls, {}),
|
|
9221
|
+
/* @__PURE__ */ jsxRuntime.jsx(react$2.MiniMap, { pannable: true, zoomable: true, maskColor: "#121212", bgColor: "#171717", nodeColor: "#2c2c2c" }),
|
|
9222
|
+
/* @__PURE__ */ jsxRuntime.jsx(react$2.Background, { variant: react$2.BackgroundVariant.Lines, gap: 12, size: 0.5 })
|
|
9223
|
+
]
|
|
8662
9224
|
}
|
|
9225
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full h-full flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(Spinner, {}) }) });
|
|
9226
|
+
}
|
|
9227
|
+
|
|
9228
|
+
const LegacyWorkflowNestedGraphContext = React.createContext(
|
|
9229
|
+
{}
|
|
9230
|
+
);
|
|
9231
|
+
function LegacyWorkflowNestedGraphProvider({ children }) {
|
|
9232
|
+
const [stepGraph, setStepGraph] = React.useState(null);
|
|
9233
|
+
const [stepSubscriberGraph, setStepSubscriberGraph] = React.useState(null);
|
|
9234
|
+
const [openDialog, setOpenDialog] = React.useState(false);
|
|
9235
|
+
const [label, setLabel] = React.useState("");
|
|
9236
|
+
const closeNestedGraph = () => {
|
|
9237
|
+
setOpenDialog(false);
|
|
9238
|
+
setStepGraph(null);
|
|
9239
|
+
setStepSubscriberGraph(null);
|
|
9240
|
+
setLabel("");
|
|
9241
|
+
};
|
|
9242
|
+
const showNestedGraph = ({
|
|
9243
|
+
label: label2,
|
|
9244
|
+
stepGraph: stepGraph2,
|
|
9245
|
+
stepSubscriberGraph: stepSubscriberGraph2
|
|
9246
|
+
}) => {
|
|
9247
|
+
setLabel(label2);
|
|
9248
|
+
setStepGraph(stepGraph2);
|
|
9249
|
+
setStepSubscriberGraph(stepSubscriberGraph2);
|
|
9250
|
+
setOpenDialog(true);
|
|
8663
9251
|
};
|
|
8664
9252
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8665
|
-
|
|
9253
|
+
LegacyWorkflowNestedGraphContext.Provider,
|
|
8666
9254
|
{
|
|
8667
|
-
|
|
8668
|
-
|
|
8669
|
-
|
|
8670
|
-
e.stopPropagation();
|
|
8671
|
-
if (e.key === "Escape") {
|
|
8672
|
-
setOpenPopover?.(false);
|
|
8673
|
-
}
|
|
9255
|
+
value: {
|
|
9256
|
+
showNestedGraph,
|
|
9257
|
+
closeNestedGraph
|
|
8674
9258
|
},
|
|
8675
9259
|
children: [
|
|
8676
|
-
|
|
8677
|
-
|
|
8678
|
-
{
|
|
8679
|
-
|
|
8680
|
-
|
|
8681
|
-
|
|
8682
|
-
|
|
8683
|
-
|
|
8684
|
-
}
|
|
8685
|
-
|
|
8686
|
-
|
|
8687
|
-
|
|
8688
|
-
|
|
8689
|
-
|
|
8690
|
-
|
|
8691
|
-
|
|
8692
|
-
|
|
8693
|
-
|
|
8694
|
-
|
|
8695
|
-
|
|
8696
|
-
|
|
8697
|
-
|
|
8698
|
-
|
|
8699
|
-
|
|
8700
|
-
|
|
8701
|
-
|
|
8702
|
-
|
|
8703
|
-
|
|
8704
|
-
|
|
8705
|
-
|
|
8706
|
-
|
|
8707
|
-
|
|
8708
|
-
|
|
8709
|
-
|
|
8710
|
-
|
|
8711
|
-
|
|
9260
|
+
children,
|
|
9261
|
+
/* @__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: [
|
|
9262
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DialogTitle, { className: "flex items-center gap-1.5 absolute top-2.5 left-2.5", children: [
|
|
9263
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Workflow, { className: "text-current w-4 h-4" }),
|
|
9264
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Text, { size: "xs", weight: "medium", className: "text-mastra-el-6 capitalize", children: [
|
|
9265
|
+
label,
|
|
9266
|
+
" workflow"
|
|
9267
|
+
] })
|
|
9268
|
+
] }),
|
|
9269
|
+
/* @__PURE__ */ jsxRuntime.jsx(react$2.ReactFlowProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9270
|
+
LegacyWorkflowNestedGraph,
|
|
9271
|
+
{
|
|
9272
|
+
stepGraph,
|
|
9273
|
+
open: openDialog,
|
|
9274
|
+
stepSubscriberGraph
|
|
9275
|
+
}
|
|
9276
|
+
) })
|
|
9277
|
+
] }) }) })
|
|
9278
|
+
]
|
|
9279
|
+
}
|
|
9280
|
+
);
|
|
9281
|
+
}
|
|
9282
|
+
|
|
9283
|
+
function LegacyWorkflowNestedNode({ data }) {
|
|
9284
|
+
const { label, withoutTopHandle, withoutBottomHandle, stepGraph, stepSubscriberGraph } = data;
|
|
9285
|
+
const { showNestedGraph } = React.useContext(LegacyWorkflowNestedGraphContext);
|
|
9286
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("bg-[rgba(29,29,29,0.5)] rounded-md h-full overflow-scroll w-[274px]"), children: [
|
|
9287
|
+
!withoutTopHandle && /* @__PURE__ */ jsxRuntime.jsx(react$2.Handle, { type: "target", position: react$2.Position.Top, style: { visibility: "hidden" } }),
|
|
9288
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-2 cursor-pointer", onClick: () => showNestedGraph({ label, stepGraph, stepSubscriberGraph }), children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-sm bg-mastra-bg-9 flex items-center gap-1.5 rounded-sm p-2 cursor-pointer", children: [
|
|
9289
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Workflow, { className: "text-current w-4 h-4" }),
|
|
9290
|
+
/* @__PURE__ */ jsxRuntime.jsx(Text, { size: "xs", weight: "medium", className: "text-mastra-el-6 capitalize", children: label })
|
|
9291
|
+
] }) }),
|
|
9292
|
+
!withoutBottomHandle && /* @__PURE__ */ jsxRuntime.jsx(react$2.Handle, { type: "source", position: react$2.Position.Bottom, style: { visibility: "hidden" } })
|
|
9293
|
+
] });
|
|
9294
|
+
}
|
|
9295
|
+
|
|
9296
|
+
function LegacyWorkflowGraphInner({ workflow }) {
|
|
9297
|
+
const { nodes: initialNodes, edges: initialEdges } = contructLegacyNodesAndEdges({
|
|
9298
|
+
stepGraph: workflow.serializedStepGraph || workflow.stepGraph,
|
|
9299
|
+
stepSubscriberGraph: workflow.serializedStepSubscriberGraph || workflow.stepSubscriberGraph,
|
|
9300
|
+
steps: workflow.steps
|
|
9301
|
+
});
|
|
9302
|
+
const [nodes, _, onNodesChange] = react$2.useNodesState(initialNodes);
|
|
9303
|
+
const [edges] = react$2.useEdgesState(initialEdges);
|
|
9304
|
+
const nodeTypes = {
|
|
9305
|
+
"default-node": WorkflowDefaultNode,
|
|
9306
|
+
"condition-node": WorkflowConditionNode,
|
|
9307
|
+
"after-node": WorkflowAfterNode,
|
|
9308
|
+
"loop-result-node": WorkflowLoopResultNode,
|
|
9309
|
+
"nested-node": LegacyWorkflowNestedNode
|
|
9310
|
+
};
|
|
9311
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full h-full", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9312
|
+
react$2.ReactFlow,
|
|
9313
|
+
{
|
|
9314
|
+
nodes,
|
|
9315
|
+
edges,
|
|
9316
|
+
nodeTypes,
|
|
9317
|
+
onNodesChange,
|
|
9318
|
+
fitView: true,
|
|
9319
|
+
fitViewOptions: {
|
|
9320
|
+
maxZoom: 0.85
|
|
9321
|
+
},
|
|
9322
|
+
children: [
|
|
9323
|
+
/* @__PURE__ */ jsxRuntime.jsx(react$2.Controls, {}),
|
|
9324
|
+
/* @__PURE__ */ jsxRuntime.jsx(react$2.MiniMap, { pannable: true, zoomable: true, maskColor: "#121212", bgColor: "#171717", nodeColor: "#2c2c2c" }),
|
|
9325
|
+
/* @__PURE__ */ jsxRuntime.jsx(react$2.Background, { variant: react$2.BackgroundVariant.Dots, gap: 12, size: 0.5 })
|
|
8712
9326
|
]
|
|
8713
9327
|
}
|
|
8714
|
-
);
|
|
9328
|
+
) });
|
|
9329
|
+
}
|
|
9330
|
+
|
|
9331
|
+
function LegacyWorkflowGraph({ workflowId }) {
|
|
9332
|
+
const { legacyWorkflow, isLoading } = useLegacyWorkflow(workflowId);
|
|
9333
|
+
if (isLoading) {
|
|
9334
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4", children: /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-[600px]" }) });
|
|
9335
|
+
}
|
|
9336
|
+
if (!legacyWorkflow) {
|
|
9337
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid h-full place-items-center", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-2", children: [
|
|
9338
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircleIcon, {}),
|
|
9339
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
9340
|
+
"We couldn't find ",
|
|
9341
|
+
lodashTitleCase(workflowId),
|
|
9342
|
+
" workflow."
|
|
9343
|
+
] })
|
|
9344
|
+
] }) });
|
|
9345
|
+
}
|
|
9346
|
+
return /* @__PURE__ */ jsxRuntime.jsx(LegacyWorkflowNestedGraphProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(react$2.ReactFlowProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(LegacyWorkflowGraphInner, { workflow: legacyWorkflow }) }) });
|
|
9347
|
+
}
|
|
9348
|
+
|
|
9349
|
+
const Form = React.forwardRef(({ children, ...props }, ref) => {
|
|
9350
|
+
return /* @__PURE__ */ jsxRuntime.jsx("form", { ref, className: "space-y-4", ...props, children });
|
|
9351
|
+
});
|
|
9352
|
+
|
|
9353
|
+
const DISABLED_LABELS = ["boolean", "object", "array"];
|
|
9354
|
+
const FieldWrapper = ({ label, children, id, field, error }) => {
|
|
9355
|
+
const isDisabled = DISABLED_LABELS.includes(field.type);
|
|
9356
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pb-4 last:pb-0", children: [
|
|
9357
|
+
!isDisabled && /* @__PURE__ */ jsxRuntime.jsxs(Txt, { as: "label", variant: "ui-sm", className: "text-icon3 pb-1 block", htmlFor: id, children: [
|
|
9358
|
+
label,
|
|
9359
|
+
field.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-accent2", children: " *" })
|
|
9360
|
+
] }),
|
|
9361
|
+
children,
|
|
9362
|
+
field.fieldConfig?.description && /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "p", variant: "ui-sm", className: "text-icon6", children: field.fieldConfig.description }),
|
|
9363
|
+
error && /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "p", variant: "ui-sm", className: "text-accent2", children: error })
|
|
9364
|
+
] });
|
|
8715
9365
|
};
|
|
8716
|
-
|
|
8717
|
-
|
|
8718
|
-
|
|
8719
|
-
|
|
8720
|
-
|
|
8721
|
-
|
|
8722
|
-
|
|
8723
|
-
|
|
8724
|
-
"bg-neutral-825 border-neutral-775 w-full justify-start whitespace-nowrap rounded-md border px-2 py-0 text-left flex items-center gap-1",
|
|
8725
|
-
className
|
|
8726
|
-
),
|
|
8727
|
-
...props,
|
|
8728
|
-
children: [
|
|
8729
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.CalendarIcon, { className: "h-4 w-4" }),
|
|
8730
|
-
value ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-white", children: dateFns.format(value, "PPP") }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray", children: placeholder ?? "Pick a date" })
|
|
8731
|
-
]
|
|
9366
|
+
|
|
9367
|
+
const alertVariants = cva(
|
|
9368
|
+
"relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",
|
|
9369
|
+
{
|
|
9370
|
+
variants: {
|
|
9371
|
+
variant: {
|
|
9372
|
+
default: "bg-background text-foreground",
|
|
9373
|
+
destructive: "border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"
|
|
8732
9374
|
}
|
|
8733
|
-
|
|
9375
|
+
},
|
|
9376
|
+
defaultVariants: {
|
|
9377
|
+
variant: "default"
|
|
9378
|
+
}
|
|
8734
9379
|
}
|
|
8735
9380
|
);
|
|
8736
|
-
|
|
9381
|
+
const Alert = React__namespace.forwardRef(({ className, variant, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, role: "alert", className: cn(alertVariants({ variant }), className), ...props }));
|
|
9382
|
+
Alert.displayName = "Alert";
|
|
9383
|
+
const AlertTitle = React__namespace.forwardRef(
|
|
9384
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("h5", { ref, className: cn("mb-1 font-medium leading-none tracking-tight", className), ...props })
|
|
9385
|
+
);
|
|
9386
|
+
AlertTitle.displayName = "AlertTitle";
|
|
9387
|
+
const AlertDescription = React__namespace.forwardRef(
|
|
9388
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("text-sm [&_p]:leading-relaxed", className), ...props })
|
|
9389
|
+
);
|
|
9390
|
+
AlertDescription.displayName = "AlertDescription";
|
|
8737
9391
|
|
|
8738
|
-
const
|
|
9392
|
+
const ErrorMessage = ({ error }) => /* @__PURE__ */ jsxRuntime.jsxs(Alert, { variant: "destructive", children: [
|
|
9393
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircle, { className: "h-4 w-4" }),
|
|
9394
|
+
/* @__PURE__ */ jsxRuntime.jsx(AlertTitle, { children: error })
|
|
9395
|
+
] });
|
|
9396
|
+
|
|
9397
|
+
const SubmitButton = ({ children }) => /* @__PURE__ */ jsxRuntime.jsx(Button$1, { type: "submit", children });
|
|
9398
|
+
|
|
9399
|
+
const StringField = ({ inputProps, error, field, id }) => {
|
|
9400
|
+
const { key, ...props } = inputProps;
|
|
9401
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Input, { id, className: error ? "border-destructive" : "", ...props, defaultValue: field.default });
|
|
9402
|
+
};
|
|
9403
|
+
|
|
9404
|
+
const NumberField = ({ inputProps, error, field, id }) => {
|
|
8739
9405
|
const { key, ...props } = inputProps;
|
|
8740
|
-
const [value, setValue] = React.useState(null);
|
|
8741
9406
|
React.useEffect(() => {
|
|
8742
|
-
if (field.default) {
|
|
8743
|
-
|
|
8744
|
-
|
|
8745
|
-
|
|
8746
|
-
}
|
|
9407
|
+
if (field.default !== void 0) {
|
|
9408
|
+
props.onChange({
|
|
9409
|
+
target: { value: Number(field.default), name: inputProps.name }
|
|
9410
|
+
});
|
|
8747
9411
|
}
|
|
8748
|
-
}, [field]);
|
|
9412
|
+
}, [field.default]);
|
|
8749
9413
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
8750
|
-
|
|
9414
|
+
Input,
|
|
8751
9415
|
{
|
|
8752
9416
|
id,
|
|
9417
|
+
type: "number",
|
|
8753
9418
|
className: error ? "border-destructive" : "",
|
|
8754
|
-
|
|
8755
|
-
|
|
8756
|
-
|
|
8757
|
-
|
|
9419
|
+
...props,
|
|
9420
|
+
defaultValue: field.default !== void 0 ? Number(field.default) : void 0,
|
|
9421
|
+
onChange: (e) => {
|
|
9422
|
+
const value = e.target.value;
|
|
9423
|
+
if (value !== "" && !isNaN(Number(value))) {
|
|
8758
9424
|
props.onChange({
|
|
8759
|
-
target: { value
|
|
9425
|
+
target: { value, name: inputProps.name }
|
|
8760
9426
|
});
|
|
8761
|
-
setValue(new Date(newDate));
|
|
8762
9427
|
}
|
|
8763
9428
|
},
|
|
8764
|
-
|
|
9429
|
+
onBlur: (e) => {
|
|
9430
|
+
const value = e.target.value;
|
|
9431
|
+
if (value !== "" && !isNaN(Number(value))) {
|
|
9432
|
+
props.onChange({
|
|
9433
|
+
target: { value: Number(value), name: inputProps.name }
|
|
9434
|
+
});
|
|
9435
|
+
}
|
|
9436
|
+
}
|
|
8765
9437
|
}
|
|
8766
9438
|
);
|
|
8767
9439
|
};
|
|
8768
9440
|
|
|
8769
|
-
const
|
|
8770
|
-
|
|
8771
|
-
const SelectTrigger = React__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8772
|
-
SelectPrimitive__namespace.Trigger,
|
|
9441
|
+
const Checkbox = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
9442
|
+
CheckboxPrimitive__namespace.Root,
|
|
8773
9443
|
{
|
|
8774
9444
|
ref,
|
|
8775
9445
|
className: cn(
|
|
8776
|
-
"
|
|
9446
|
+
"peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
|
|
8777
9447
|
className
|
|
8778
9448
|
),
|
|
8779
9449
|
...props,
|
|
8780
|
-
children:
|
|
8781
|
-
children,
|
|
8782
|
-
/* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Icon, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "h-4 w-4 opacity-50" }) })
|
|
8783
|
-
]
|
|
9450
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(CheckboxPrimitive__namespace.Indicator, { className: cn("flex items-center justify-center text-current"), children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-4 w-4" }) })
|
|
8784
9451
|
}
|
|
8785
9452
|
));
|
|
8786
|
-
|
|
8787
|
-
|
|
8788
|
-
|
|
8789
|
-
|
|
8790
|
-
|
|
8791
|
-
|
|
8792
|
-
|
|
8793
|
-
|
|
8794
|
-
|
|
8795
|
-
|
|
8796
|
-
|
|
8797
|
-
|
|
8798
|
-
|
|
8799
|
-
|
|
8800
|
-
|
|
8801
|
-
|
|
8802
|
-
|
|
8803
|
-
|
|
9453
|
+
Checkbox.displayName = CheckboxPrimitive__namespace.Root.displayName;
|
|
9454
|
+
|
|
9455
|
+
const BooleanField = ({ field, label, id, inputProps, value }) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center space-x-2", children: [
|
|
9456
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9457
|
+
Checkbox,
|
|
9458
|
+
{
|
|
9459
|
+
id,
|
|
9460
|
+
onCheckedChange: (checked) => {
|
|
9461
|
+
const event = {
|
|
9462
|
+
target: {
|
|
9463
|
+
name: inputProps.name,
|
|
9464
|
+
value: checked
|
|
9465
|
+
}
|
|
9466
|
+
};
|
|
9467
|
+
inputProps.onChange(event);
|
|
9468
|
+
},
|
|
9469
|
+
defaultChecked: field.default,
|
|
9470
|
+
disabled: inputProps.disabled || inputProps.readOnly
|
|
9471
|
+
}
|
|
9472
|
+
),
|
|
9473
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Txt, { as: "label", variant: "ui-sm", className: "text-icon3", htmlFor: id, children: [
|
|
9474
|
+
label,
|
|
9475
|
+
field.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-accent2", children: " *" })
|
|
9476
|
+
] })
|
|
9477
|
+
] });
|
|
9478
|
+
|
|
9479
|
+
function Calendar({ className, classNames, showOutsideDays = true, ...props }) {
|
|
9480
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
9481
|
+
reactDayPicker.DayPicker,
|
|
9482
|
+
{
|
|
9483
|
+
showOutsideDays,
|
|
9484
|
+
className: cn("p-3", className),
|
|
9485
|
+
classNames: {
|
|
9486
|
+
months: "flex flex-col space-y-4 sm:space-y-0",
|
|
9487
|
+
month: "space-y-4",
|
|
9488
|
+
// month_caption: 'flex justify-center pt-1 relative items-center',
|
|
9489
|
+
caption_label: "text-sm text-text font-medium",
|
|
9490
|
+
nav: "space-x-1 flex items-center",
|
|
9491
|
+
nav_button_previous: cn(
|
|
9492
|
+
buttonVariants({ variant: "outline" }),
|
|
9493
|
+
"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100",
|
|
9494
|
+
"absolute left-4 top-[56px] z-10"
|
|
8804
9495
|
),
|
|
8805
|
-
|
|
8806
|
-
|
|
8807
|
-
|
|
8808
|
-
|
|
8809
|
-
)
|
|
8810
|
-
|
|
8811
|
-
|
|
8812
|
-
|
|
9496
|
+
nav_button_next: cn(
|
|
9497
|
+
buttonVariants({ variant: "outline" }),
|
|
9498
|
+
"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100",
|
|
9499
|
+
"absolute right-4 top-[56px] z-10"
|
|
9500
|
+
),
|
|
9501
|
+
dropdown_month: "w-full border-collapse space-y-1",
|
|
9502
|
+
weeknumber: "flex",
|
|
9503
|
+
day: cn(
|
|
9504
|
+
buttonVariants({ variant: "ghost" }),
|
|
9505
|
+
"relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected].day-range-end)]:rounded-r-md",
|
|
9506
|
+
props.mode === "range" ? "[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md" : "[&:has([aria-selected])]:rounded-md",
|
|
9507
|
+
"h-8 w-8 p-0 hover:bg-lightGray-7/50 font-normal aria-selected:opacity-100"
|
|
9508
|
+
),
|
|
9509
|
+
day_range_start: "day-range-start",
|
|
9510
|
+
day_range_end: "day-range-end",
|
|
9511
|
+
day_selected: "!bg-primary !text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",
|
|
9512
|
+
day_today: "bg-lightGray-7/50 text-accent-foreground",
|
|
9513
|
+
day_outside: "day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",
|
|
9514
|
+
day_disabled: "text-muted-foreground opacity-50",
|
|
9515
|
+
day_range_middle: "aria-selected:bg-accent aria-selected:text-accent-foreground",
|
|
9516
|
+
day_hidden: "invisible",
|
|
9517
|
+
...classNames
|
|
9518
|
+
},
|
|
9519
|
+
components: {
|
|
9520
|
+
// IconDropdown: ({ }) => (
|
|
9521
|
+
// <CalendarIcon
|
|
9522
|
+
// className={cn('h-4 w-4', {
|
|
9523
|
+
// 'rotate-180': orientation === 'up',
|
|
9524
|
+
// 'rotate-90': orientation === 'left',
|
|
9525
|
+
// '-rotate-90': orientation === 'right',
|
|
9526
|
+
// })}
|
|
9527
|
+
// />
|
|
9528
|
+
// ),
|
|
9529
|
+
},
|
|
9530
|
+
...props
|
|
9531
|
+
}
|
|
9532
|
+
);
|
|
9533
|
+
}
|
|
9534
|
+
Calendar.displayName = "Calendar";
|
|
9535
|
+
|
|
9536
|
+
const Popover = PopoverPrimitive__namespace.Root;
|
|
9537
|
+
const PopoverTrigger = PopoverPrimitive__namespace.Trigger;
|
|
9538
|
+
const PopoverContent = React__namespace.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(PopoverPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9539
|
+
PopoverPrimitive__namespace.Content,
|
|
8813
9540
|
{
|
|
8814
9541
|
ref,
|
|
9542
|
+
align,
|
|
9543
|
+
sideOffset,
|
|
8815
9544
|
className: cn(
|
|
8816
|
-
"
|
|
9545
|
+
"z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none 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-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
8817
9546
|
className
|
|
8818
9547
|
),
|
|
8819
|
-
...props
|
|
8820
|
-
children: [
|
|
8821
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute right-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.ItemIndicator, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-4 w-4" }) }) }),
|
|
8822
|
-
/* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.ItemText, { children })
|
|
8823
|
-
]
|
|
9548
|
+
...props
|
|
8824
9549
|
}
|
|
8825
|
-
));
|
|
8826
|
-
|
|
8827
|
-
|
|
8828
|
-
const SelectField = ({ field, inputProps, error, id, value }) => {
|
|
8829
|
-
const { key, ...props } = inputProps;
|
|
8830
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8831
|
-
Select,
|
|
8832
|
-
{
|
|
8833
|
-
...props,
|
|
8834
|
-
onValueChange: (value2) => {
|
|
8835
|
-
const syntheticEvent = {
|
|
8836
|
-
target: {
|
|
8837
|
-
value: value2,
|
|
8838
|
-
name: inputProps.name
|
|
8839
|
-
}
|
|
8840
|
-
};
|
|
8841
|
-
props.onChange(syntheticEvent);
|
|
8842
|
-
},
|
|
8843
|
-
defaultValue: field.default,
|
|
8844
|
-
children: [
|
|
8845
|
-
/* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { id, className: error ? "border-destructive" : "", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "Select an option" }) }),
|
|
8846
|
-
/* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: (field.options || []).map(([key2, label]) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: key2, children: label }, key2)) })
|
|
8847
|
-
]
|
|
8848
|
-
}
|
|
8849
|
-
);
|
|
8850
|
-
};
|
|
9550
|
+
) }));
|
|
9551
|
+
PopoverContent.displayName = PopoverPrimitive__namespace.Content.displayName;
|
|
8851
9552
|
|
|
8852
|
-
const
|
|
8853
|
-
|
|
8854
|
-
|
|
8855
|
-
|
|
8856
|
-
|
|
8857
|
-
|
|
8858
|
-
|
|
8859
|
-
|
|
8860
|
-
|
|
9553
|
+
const DatePicker = ({
|
|
9554
|
+
value,
|
|
9555
|
+
setValue,
|
|
9556
|
+
children,
|
|
9557
|
+
className,
|
|
9558
|
+
placeholder,
|
|
9559
|
+
...props
|
|
9560
|
+
}) => {
|
|
9561
|
+
const [openPopover, setOpenPopover] = React__namespace.useState(false);
|
|
9562
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Popover, { open: openPopover, onOpenChange: setOpenPopover, children: [
|
|
9563
|
+
/* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: children ? children : /* @__PURE__ */ jsxRuntime.jsx(
|
|
9564
|
+
DefaultButton,
|
|
8861
9565
|
{
|
|
8862
|
-
|
|
8863
|
-
|
|
9566
|
+
value,
|
|
9567
|
+
placeholder,
|
|
9568
|
+
className,
|
|
9569
|
+
"data-testid": "datepicker-button"
|
|
8864
9570
|
}
|
|
8865
|
-
)
|
|
8866
|
-
|
|
8867
|
-
|
|
8868
|
-
|
|
8869
|
-
|
|
8870
|
-
|
|
8871
|
-
|
|
8872
|
-
|
|
8873
|
-
|
|
8874
|
-
label
|
|
8875
|
-
] }),
|
|
8876
|
-
/* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { delayDuration: 0, children: [
|
|
8877
|
-
/* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8878
|
-
"button",
|
|
9571
|
+
) }),
|
|
9572
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9573
|
+
PopoverContent,
|
|
9574
|
+
{
|
|
9575
|
+
className: "backdrop-blur-4xl w-auto p-0 bg-[#171717]",
|
|
9576
|
+
align: "start",
|
|
9577
|
+
"data-testid": "datepicker-calendar",
|
|
9578
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9579
|
+
DatePickerOnly,
|
|
8879
9580
|
{
|
|
8880
|
-
|
|
8881
|
-
|
|
8882
|
-
|
|
8883
|
-
|
|
9581
|
+
value,
|
|
9582
|
+
setValue: (v) => setValue(v ? /* @__PURE__ */ new Date(`${v}z`) : null),
|
|
9583
|
+
clearable: props.clearable,
|
|
9584
|
+
setOpenPopover,
|
|
9585
|
+
...props
|
|
8884
9586
|
}
|
|
8885
|
-
)
|
|
8886
|
-
|
|
8887
|
-
|
|
8888
|
-
] }),
|
|
8889
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-1", children })
|
|
8890
|
-
] });
|
|
8891
|
-
};
|
|
8892
|
-
|
|
8893
|
-
const ArrayElementWrapper = ({ children, onRemove }) => {
|
|
8894
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pl-4 border-l border-border1", children: [
|
|
8895
|
-
children,
|
|
8896
|
-
/* @__PURE__ */ jsxRuntime.jsxs(Button, { onClick: onRemove, type: "button", children: [
|
|
8897
|
-
/* @__PURE__ */ jsxRuntime.jsx(Icon, { size: "sm", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.TrashIcon, {}) }),
|
|
8898
|
-
"Delete"
|
|
8899
|
-
] })
|
|
9587
|
+
)
|
|
9588
|
+
}
|
|
9589
|
+
)
|
|
8900
9590
|
] });
|
|
8901
9591
|
};
|
|
8902
|
-
|
|
8903
|
-
|
|
8904
|
-
|
|
8905
|
-
|
|
8906
|
-
|
|
8907
|
-
|
|
8908
|
-
|
|
8909
|
-
|
|
8910
|
-
|
|
8911
|
-
);
|
|
8912
|
-
React__namespace.
|
|
8913
|
-
|
|
8914
|
-
|
|
9592
|
+
const DatePickerOnly = ({
|
|
9593
|
+
value,
|
|
9594
|
+
setValue,
|
|
9595
|
+
setOpenPopover,
|
|
9596
|
+
clearable,
|
|
9597
|
+
placeholder,
|
|
9598
|
+
className,
|
|
9599
|
+
...props
|
|
9600
|
+
}) => {
|
|
9601
|
+
const [inputValue, setInputValue] = React__namespace.useState(value ? dateFns.format(value, "PP") : "");
|
|
9602
|
+
const [selected, setSelected] = React__namespace.useState(value ? new Date(value) : void 0);
|
|
9603
|
+
const debouncedDateUpdate = useDebounce.useDebouncedCallback((date) => {
|
|
9604
|
+
if (dateFns.isValid(date)) {
|
|
9605
|
+
setSelected(date);
|
|
9606
|
+
setValue?.(date);
|
|
9607
|
+
setOpenPopover?.(false);
|
|
8915
9608
|
}
|
|
8916
|
-
},
|
|
8917
|
-
const
|
|
8918
|
-
(
|
|
8919
|
-
|
|
8920
|
-
|
|
8921
|
-
if (pair.key) {
|
|
8922
|
-
acc[pair.key] = pair.value;
|
|
8923
|
-
}
|
|
8924
|
-
return acc;
|
|
8925
|
-
},
|
|
8926
|
-
{}
|
|
8927
|
-
);
|
|
8928
|
-
onChange?.({
|
|
8929
|
-
target: { value: newValue, name: inputProps.name }
|
|
8930
|
-
});
|
|
8931
|
-
},
|
|
8932
|
-
[onChange, inputProps.name]
|
|
8933
|
-
);
|
|
8934
|
-
const handleChange = (id2, field2, newValue) => {
|
|
8935
|
-
setPairs((prev) => prev.map((pair) => pair.id === id2 ? { ...pair, [field2]: newValue } : pair));
|
|
8936
|
-
};
|
|
8937
|
-
const handleBlur = () => {
|
|
8938
|
-
updateForm(pairs);
|
|
9609
|
+
}, 2e3);
|
|
9610
|
+
const handleInputChange = (e) => {
|
|
9611
|
+
setInputValue(e.currentTarget.value);
|
|
9612
|
+
const date = new Date(e.target.value);
|
|
9613
|
+
debouncedDateUpdate(date);
|
|
8939
9614
|
};
|
|
8940
|
-
const
|
|
8941
|
-
|
|
8942
|
-
|
|
8943
|
-
|
|
9615
|
+
const handleDaySelect = (date) => {
|
|
9616
|
+
setSelected(date);
|
|
9617
|
+
setValue?.(date);
|
|
9618
|
+
setOpenPopover?.(false);
|
|
9619
|
+
if (date) {
|
|
9620
|
+
setInputValue(dateFns.format(date, "PP"));
|
|
9621
|
+
} else {
|
|
9622
|
+
setInputValue("");
|
|
9623
|
+
}
|
|
8944
9624
|
};
|
|
8945
|
-
const
|
|
8946
|
-
|
|
8947
|
-
if (
|
|
8948
|
-
|
|
9625
|
+
const handleMonthSelect = (date) => {
|
|
9626
|
+
setSelected(date);
|
|
9627
|
+
if (date) {
|
|
9628
|
+
setInputValue(dateFns.format(date, "PP"));
|
|
9629
|
+
} else {
|
|
9630
|
+
setInputValue("");
|
|
8949
9631
|
}
|
|
8950
|
-
setPairs(newPairs);
|
|
8951
|
-
updateForm(newPairs);
|
|
8952
9632
|
};
|
|
8953
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8954
|
-
|
|
8955
|
-
|
|
8956
|
-
|
|
8957
|
-
|
|
8958
|
-
|
|
8959
|
-
|
|
8960
|
-
|
|
8961
|
-
|
|
8962
|
-
onClick: () => removePair(pair.id),
|
|
8963
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.TrashIcon, { className: "h-4 w-4" })
|
|
9633
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9634
|
+
"div",
|
|
9635
|
+
{
|
|
9636
|
+
"aria-label": "Choose date",
|
|
9637
|
+
className: "relative mt-2 flex flex-col gap-2",
|
|
9638
|
+
onKeyDown: (e) => {
|
|
9639
|
+
e.stopPropagation();
|
|
9640
|
+
if (e.key === "Escape") {
|
|
9641
|
+
setOpenPopover?.(false);
|
|
8964
9642
|
}
|
|
8965
|
-
|
|
8966
|
-
|
|
8967
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9643
|
+
},
|
|
9644
|
+
children: [
|
|
9645
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full px-3", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8968
9646
|
Input,
|
|
8969
9647
|
{
|
|
8970
|
-
|
|
8971
|
-
value:
|
|
8972
|
-
onChange:
|
|
8973
|
-
|
|
9648
|
+
type: "text",
|
|
9649
|
+
value: inputValue,
|
|
9650
|
+
onChange: handleInputChange,
|
|
9651
|
+
placeholder,
|
|
9652
|
+
className
|
|
9653
|
+
}
|
|
9654
|
+
) }),
|
|
9655
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9656
|
+
Calendar,
|
|
9657
|
+
{
|
|
9658
|
+
mode: "single",
|
|
9659
|
+
month: selected,
|
|
9660
|
+
selected,
|
|
9661
|
+
onMonthChange: handleMonthSelect,
|
|
9662
|
+
onSelect: handleDaySelect,
|
|
9663
|
+
...props
|
|
8974
9664
|
}
|
|
8975
9665
|
),
|
|
8976
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8977
|
-
|
|
9666
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-3 pb-2", children: clearable && /* @__PURE__ */ jsxRuntime.jsx(
|
|
9667
|
+
Button$1,
|
|
8978
9668
|
{
|
|
8979
|
-
|
|
8980
|
-
|
|
8981
|
-
|
|
8982
|
-
|
|
9669
|
+
variant: "outline",
|
|
9670
|
+
tabIndex: 0,
|
|
9671
|
+
className: "w-full !opacity-50 duration-200 hover:!opacity-100",
|
|
9672
|
+
onClick: () => {
|
|
9673
|
+
setValue(null);
|
|
9674
|
+
setSelected(void 0);
|
|
9675
|
+
setInputValue("");
|
|
9676
|
+
setOpenPopover?.(false);
|
|
9677
|
+
},
|
|
9678
|
+
children: "Clear"
|
|
8983
9679
|
}
|
|
8984
|
-
)
|
|
8985
|
-
]
|
|
8986
|
-
|
|
8987
|
-
|
|
8988
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "mr-2 h-4 w-4" }),
|
|
8989
|
-
"Add Key-Value Pair"
|
|
8990
|
-
] })
|
|
8991
|
-
] });
|
|
9680
|
+
) })
|
|
9681
|
+
]
|
|
9682
|
+
}
|
|
9683
|
+
);
|
|
8992
9684
|
};
|
|
9685
|
+
const DefaultButton = React__namespace.forwardRef(
|
|
9686
|
+
({ value, placeholder, className, ...props }, ref) => {
|
|
9687
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9688
|
+
Button$1,
|
|
9689
|
+
{
|
|
9690
|
+
ref,
|
|
9691
|
+
variant: "outline",
|
|
9692
|
+
className: cn(
|
|
9693
|
+
"bg-neutral-825 border-neutral-775 w-full justify-start whitespace-nowrap rounded-md border px-2 py-0 text-left flex items-center gap-1",
|
|
9694
|
+
className
|
|
9695
|
+
),
|
|
9696
|
+
...props,
|
|
9697
|
+
children: [
|
|
9698
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.CalendarIcon, { className: "h-4 w-4" }),
|
|
9699
|
+
value ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-white", children: dateFns.format(value, "PPP") }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray", children: placeholder ?? "Pick a date" })
|
|
9700
|
+
]
|
|
9701
|
+
}
|
|
9702
|
+
);
|
|
9703
|
+
}
|
|
9704
|
+
);
|
|
9705
|
+
DefaultButton.displayName = "DefaultButton";
|
|
8993
9706
|
|
|
8994
|
-
const
|
|
8995
|
-
|
|
8996
|
-
|
|
8997
|
-
|
|
8998
|
-
|
|
8999
|
-
|
|
9000
|
-
|
|
9001
|
-
|
|
9002
|
-
}
|
|
9003
|
-
|
|
9004
|
-
|
|
9005
|
-
formComponents,
|
|
9006
|
-
readOnly,
|
|
9007
|
-
...props
|
|
9008
|
-
}) {
|
|
9707
|
+
const DateField = ({ inputProps, field, error, id }) => {
|
|
9708
|
+
const { key, ...props } = inputProps;
|
|
9709
|
+
const [value, setValue] = React.useState(null);
|
|
9710
|
+
React.useEffect(() => {
|
|
9711
|
+
if (field.default) {
|
|
9712
|
+
const date = new Date(field.default);
|
|
9713
|
+
if (dateFns.isValid(date)) {
|
|
9714
|
+
setValue(date);
|
|
9715
|
+
}
|
|
9716
|
+
}
|
|
9717
|
+
}, [field]);
|
|
9009
9718
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
9010
|
-
|
|
9719
|
+
DatePicker,
|
|
9011
9720
|
{
|
|
9012
|
-
|
|
9013
|
-
|
|
9014
|
-
|
|
9015
|
-
|
|
9016
|
-
|
|
9017
|
-
|
|
9018
|
-
|
|
9019
|
-
|
|
9020
|
-
|
|
9021
|
-
|
|
9022
|
-
|
|
9721
|
+
id,
|
|
9722
|
+
className: error ? "border-destructive" : "",
|
|
9723
|
+
value,
|
|
9724
|
+
setValue: (date) => {
|
|
9725
|
+
const newDate = date ? new Date(date).toISOString() : date;
|
|
9726
|
+
if (newDate) {
|
|
9727
|
+
props.onChange({
|
|
9728
|
+
target: { value: newDate?.toString(), name: inputProps.name }
|
|
9729
|
+
});
|
|
9730
|
+
setValue(new Date(newDate));
|
|
9731
|
+
}
|
|
9732
|
+
},
|
|
9733
|
+
clearable: true
|
|
9023
9734
|
}
|
|
9024
9735
|
);
|
|
9025
|
-
}
|
|
9026
|
-
|
|
9027
|
-
react$3.buildZodFieldConfig();
|
|
9028
|
-
|
|
9029
|
-
function inferFieldType(schema, fieldConfig) {
|
|
9030
|
-
if (fieldConfig?.fieldType) {
|
|
9031
|
-
return fieldConfig.fieldType;
|
|
9032
|
-
}
|
|
9033
|
-
if (schema instanceof z.z.ZodObject) return "object";
|
|
9034
|
-
if (schema instanceof z.z.ZodNumber) return "number";
|
|
9035
|
-
if (schema instanceof z.z.ZodBoolean) return "boolean";
|
|
9036
|
-
if (schema instanceof z.z.ZodDate || schema?.isDatetime || schema?.isDate) return "date";
|
|
9037
|
-
if (schema instanceof z.z.ZodString) return "string";
|
|
9038
|
-
if (schema instanceof z.z.ZodEnum) return "select";
|
|
9039
|
-
if (schema instanceof z.z.ZodNativeEnum) return "select";
|
|
9040
|
-
if (schema instanceof z.z.ZodArray) return "array";
|
|
9041
|
-
if (schema instanceof z.z.ZodRecord) return "record";
|
|
9042
|
-
return "string";
|
|
9043
|
-
}
|
|
9736
|
+
};
|
|
9044
9737
|
|
|
9045
|
-
|
|
9046
|
-
|
|
9047
|
-
|
|
9048
|
-
|
|
9049
|
-
|
|
9050
|
-
|
|
9051
|
-
|
|
9052
|
-
|
|
9053
|
-
|
|
9054
|
-
|
|
9055
|
-
|
|
9056
|
-
|
|
9057
|
-
|
|
9058
|
-
|
|
9059
|
-
|
|
9060
|
-
if (baseSchema instanceof z.z.ZodObject) {
|
|
9061
|
-
subSchema = Object.entries(baseSchema.shape).map(([key2, field]) => parseField(key2, field));
|
|
9062
|
-
}
|
|
9063
|
-
if (baseSchema instanceof z.z.ZodArray) {
|
|
9064
|
-
subSchema = [parseField("0", baseSchema._def.type)];
|
|
9065
|
-
}
|
|
9066
|
-
return {
|
|
9067
|
-
key,
|
|
9068
|
-
type,
|
|
9069
|
-
required: !schema.isOptional(),
|
|
9070
|
-
default: defaultValue,
|
|
9071
|
-
description: baseSchema.description,
|
|
9072
|
-
fieldConfig,
|
|
9073
|
-
options: optionValues,
|
|
9074
|
-
schema: subSchema
|
|
9075
|
-
};
|
|
9076
|
-
}
|
|
9077
|
-
function getBaseSchema(schema) {
|
|
9078
|
-
if ("innerType" in schema._def) {
|
|
9079
|
-
return getBaseSchema(schema._def.innerType);
|
|
9080
|
-
}
|
|
9081
|
-
if ("schema" in schema._def) {
|
|
9082
|
-
return getBaseSchema(schema._def.schema);
|
|
9083
|
-
}
|
|
9084
|
-
return schema;
|
|
9085
|
-
}
|
|
9086
|
-
function parseSchema(schema) {
|
|
9087
|
-
const objectSchema = schema instanceof z.z.ZodEffects ? schema.innerType() : schema;
|
|
9088
|
-
const shape = objectSchema.shape;
|
|
9089
|
-
const fields = Object.entries(shape).map(([key, field]) => parseField(key, field));
|
|
9090
|
-
return { fields };
|
|
9091
|
-
}
|
|
9092
|
-
class CustomZodProvider extends zod.ZodProvider {
|
|
9093
|
-
_schema;
|
|
9094
|
-
constructor(schema) {
|
|
9095
|
-
super(schema);
|
|
9096
|
-
this._schema = schema;
|
|
9097
|
-
}
|
|
9098
|
-
parseSchema() {
|
|
9099
|
-
return parseSchema(this._schema);
|
|
9738
|
+
const Select = SelectPrimitive__namespace.Root;
|
|
9739
|
+
const SelectValue = SelectPrimitive__namespace.Value;
|
|
9740
|
+
const SelectTrigger = React__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9741
|
+
SelectPrimitive__namespace.Trigger,
|
|
9742
|
+
{
|
|
9743
|
+
ref,
|
|
9744
|
+
className: cn(
|
|
9745
|
+
"flex h-9 w-full items-center justify-between rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
|
|
9746
|
+
className
|
|
9747
|
+
),
|
|
9748
|
+
...props,
|
|
9749
|
+
children: [
|
|
9750
|
+
children,
|
|
9751
|
+
/* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Icon, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "h-4 w-4 opacity-50" }) })
|
|
9752
|
+
]
|
|
9100
9753
|
}
|
|
9101
|
-
|
|
9102
|
-
|
|
9103
|
-
const
|
|
9104
|
-
|
|
9105
|
-
|
|
9106
|
-
|
|
9107
|
-
|
|
9108
|
-
|
|
9109
|
-
|
|
9754
|
+
));
|
|
9755
|
+
SelectTrigger.displayName = SelectPrimitive__namespace.Trigger.displayName;
|
|
9756
|
+
const SelectContent = React__namespace.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9757
|
+
SelectPrimitive__namespace.Content,
|
|
9758
|
+
{
|
|
9759
|
+
ref,
|
|
9760
|
+
className: cn(
|
|
9761
|
+
"relative z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md 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-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
9762
|
+
position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
|
|
9763
|
+
className
|
|
9764
|
+
),
|
|
9765
|
+
position,
|
|
9766
|
+
...props,
|
|
9767
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9768
|
+
SelectPrimitive__namespace.Viewport,
|
|
9769
|
+
{
|
|
9770
|
+
className: cn(
|
|
9771
|
+
"p-1",
|
|
9772
|
+
position === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
|
|
9773
|
+
),
|
|
9774
|
+
children
|
|
9775
|
+
}
|
|
9776
|
+
)
|
|
9110
9777
|
}
|
|
9111
|
-
|
|
9112
|
-
|
|
9113
|
-
|
|
9114
|
-
|
|
9115
|
-
|
|
9116
|
-
|
|
9117
|
-
|
|
9118
|
-
|
|
9119
|
-
|
|
9120
|
-
|
|
9121
|
-
|
|
9122
|
-
|
|
9123
|
-
|
|
9124
|
-
|
|
9778
|
+
) }));
|
|
9779
|
+
SelectContent.displayName = SelectPrimitive__namespace.Content.displayName;
|
|
9780
|
+
const SelectItem = React__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9781
|
+
SelectPrimitive__namespace.Item,
|
|
9782
|
+
{
|
|
9783
|
+
ref,
|
|
9784
|
+
className: cn(
|
|
9785
|
+
"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-mastra-el-5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
9786
|
+
className
|
|
9787
|
+
),
|
|
9788
|
+
...props,
|
|
9789
|
+
children: [
|
|
9790
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute right-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.ItemIndicator, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-4 w-4" }) }) }),
|
|
9791
|
+
/* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.ItemText, { children })
|
|
9792
|
+
]
|
|
9125
9793
|
}
|
|
9126
|
-
|
|
9127
|
-
|
|
9128
|
-
return z.object({});
|
|
9129
|
-
}
|
|
9130
|
-
return z.object({
|
|
9131
|
-
"": schema2
|
|
9132
|
-
});
|
|
9133
|
-
};
|
|
9134
|
-
const schemaProvider = new CustomZodProvider(normalizedSchema(schema));
|
|
9135
|
-
const formProps = {
|
|
9136
|
-
schema: schemaProvider,
|
|
9137
|
-
onSubmit: async (values) => {
|
|
9138
|
-
await onSubmit?.(values?.[""] || {});
|
|
9139
|
-
},
|
|
9140
|
-
defaultValues: defaultValues ? { "": defaultValues } : void 0,
|
|
9141
|
-
formProps: {
|
|
9142
|
-
className: ""
|
|
9143
|
-
},
|
|
9144
|
-
uiComponents: {
|
|
9145
|
-
SubmitButton: ({ children }) => onSubmit ? /* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "light", className: "w-full", size: "lg", disabled: isSubmitLoading, children: isSubmitLoading ? /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "animate-spin" }) }) : submitButtonLabel || children }) : null
|
|
9146
|
-
},
|
|
9147
|
-
formComponents: {
|
|
9148
|
-
Label: ({ value }) => /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-sm font-normal", children: value })
|
|
9149
|
-
},
|
|
9150
|
-
withSubmit: true
|
|
9151
|
-
};
|
|
9152
|
-
return /* @__PURE__ */ jsxRuntime.jsx(AutoForm, { ...formProps, readOnly });
|
|
9153
|
-
}
|
|
9794
|
+
));
|
|
9795
|
+
SelectItem.displayName = SelectPrimitive__namespace.Item.displayName;
|
|
9154
9796
|
|
|
9155
|
-
|
|
9156
|
-
|
|
9157
|
-
|
|
9797
|
+
const SelectField = ({ field, inputProps, error, id, value }) => {
|
|
9798
|
+
const { key, ...props } = inputProps;
|
|
9799
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9800
|
+
Select,
|
|
9801
|
+
{
|
|
9802
|
+
...props,
|
|
9803
|
+
onValueChange: (value2) => {
|
|
9804
|
+
const syntheticEvent = {
|
|
9805
|
+
target: {
|
|
9806
|
+
value: value2,
|
|
9807
|
+
name: inputProps.name
|
|
9808
|
+
}
|
|
9809
|
+
};
|
|
9810
|
+
props.onChange(syntheticEvent);
|
|
9811
|
+
},
|
|
9812
|
+
defaultValue: field.default,
|
|
9813
|
+
children: [
|
|
9814
|
+
/* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { id, className: error ? "border-destructive" : "", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "Select an option" }) }),
|
|
9815
|
+
/* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: (field.options || []).map(([key2, label]) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: key2, children: label }, key2)) })
|
|
9816
|
+
]
|
|
9817
|
+
}
|
|
9818
|
+
);
|
|
9819
|
+
};
|
|
9158
9820
|
|
|
9159
|
-
|
|
9160
|
-
|
|
9161
|
-
|
|
9162
|
-
|
|
9163
|
-
|
|
9164
|
-
|
|
9165
|
-
|
|
9166
|
-
filename ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute w-full px-6 py-2 pl-4 text-sm rounded bg-mastra-bg-2 text-mastra-el-6/50", children: filename }) : null,
|
|
9821
|
+
const ObjectWrapper = ({ label, children }) => {
|
|
9822
|
+
const hasLabel = label !== "" && label !== "";
|
|
9823
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "", children: [
|
|
9824
|
+
hasLabel && /* @__PURE__ */ jsxRuntime.jsxs(Txt, { as: "h3", variant: "ui-sm", className: "text-icon3 flex items-center gap-1 pb-2", children: [
|
|
9825
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { size: "sm", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Braces, {}) }),
|
|
9826
|
+
label
|
|
9827
|
+
] }),
|
|
9167
9828
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9168
|
-
|
|
9829
|
+
"div",
|
|
9169
9830
|
{
|
|
9170
|
-
className:
|
|
9171
|
-
children
|
|
9172
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactCodeBlock.CodeBlock.LineNumber, { className: "table-cell pr-4 text-sm text-right select-none text-gray-500/50" }),
|
|
9173
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactCodeBlock.CodeBlock.LineContent, { className: "flex", children: /* @__PURE__ */ jsxRuntime.jsx(reactCodeBlock.CodeBlock.Token, { className: "font-mono text-sm mastra-token" }) })
|
|
9174
|
-
] }) })
|
|
9831
|
+
className: hasLabel ? "flex flex-col gap-1 [&>*]:border-dashed [&>*]:border-l [&>*]:border-l-border1 [&>*]:pl-4" : "",
|
|
9832
|
+
children
|
|
9175
9833
|
}
|
|
9176
9834
|
)
|
|
9177
9835
|
] });
|
|
9178
|
-
}
|
|
9836
|
+
};
|
|
9179
9837
|
|
|
9180
|
-
const
|
|
9181
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
9182
|
-
/* @__PURE__ */ jsxRuntime.
|
|
9183
|
-
|
|
9184
|
-
|
|
9838
|
+
const ArrayWrapper = ({ label, children, onAddItem }) => {
|
|
9839
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
9840
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2 justify-between", children: [
|
|
9841
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Txt, { as: "h3", variant: "ui-sm", className: "text-icon3 pb-2 flex items-center gap-1", children: [
|
|
9842
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { size: "sm", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Brackets, {}) }),
|
|
9843
|
+
label
|
|
9844
|
+
] }),
|
|
9845
|
+
/* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { delayDuration: 0, children: [
|
|
9846
|
+
/* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9847
|
+
"button",
|
|
9848
|
+
{
|
|
9849
|
+
onClick: onAddItem,
|
|
9850
|
+
type: "button",
|
|
9851
|
+
className: "text-icon3 bg-surface3 rounded-md p-1 hover:bg-surface4 hover:text-icon6 h-icon-sm w-icon-sm",
|
|
9852
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { size: "sm", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.PlusIcon, {}) })
|
|
9853
|
+
}
|
|
9854
|
+
) }),
|
|
9855
|
+
/* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { children: "Add item" })
|
|
9856
|
+
] }) })
|
|
9857
|
+
] }),
|
|
9858
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-1", children })
|
|
9185
9859
|
] });
|
|
9186
9860
|
};
|
|
9187
9861
|
|
|
9188
|
-
const
|
|
9189
|
-
|
|
9190
|
-
|
|
9191
|
-
|
|
9192
|
-
|
|
9193
|
-
|
|
9194
|
-
|
|
9195
|
-
|
|
9196
|
-
status === "Failed" && /* @__PURE__ */ jsxRuntime.jsx(CrossIcon, { className: "text-accent2" }),
|
|
9197
|
-
status === "Executing" && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "text-icon3 animate-spin" })
|
|
9198
|
-
] }),
|
|
9199
|
-
/* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "span", variant: "ui-lg", className: "text-icon6 font-medium", children: path })
|
|
9200
|
-
] })
|
|
9201
|
-
}
|
|
9202
|
-
);
|
|
9862
|
+
const ArrayElementWrapper = ({ children, onRemove }) => {
|
|
9863
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pl-4 border-l border-border1", children: [
|
|
9864
|
+
children,
|
|
9865
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Button, { onClick: onRemove, type: "button", children: [
|
|
9866
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { size: "sm", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.TrashIcon, {}) }),
|
|
9867
|
+
"Delete"
|
|
9868
|
+
] })
|
|
9869
|
+
] });
|
|
9203
9870
|
};
|
|
9204
9871
|
|
|
9205
|
-
const
|
|
9206
|
-
const {
|
|
9207
|
-
const [
|
|
9208
|
-
|
|
9209
|
-
|
|
9210
|
-
|
|
9211
|
-
|
|
9212
|
-
|
|
9213
|
-
/* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(DeploymentIcon, {}) }),
|
|
9214
|
-
"Workflow Execution (JSON)"
|
|
9215
|
-
] }),
|
|
9216
|
-
/* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
|
|
9217
|
-
/* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9218
|
-
"button",
|
|
9219
|
-
{
|
|
9220
|
-
className: "p-2 rounded-lg hover:bg-surface5 transition-colors duration-150 ease-in-out text-icon3 hover:text-icon6",
|
|
9221
|
-
onClick: () => handleCopy(),
|
|
9222
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { size: "sm", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CopyIcon, {}) })
|
|
9223
|
-
}
|
|
9224
|
-
) }),
|
|
9225
|
-
/* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { children: "Copy result" })
|
|
9226
|
-
] })
|
|
9227
|
-
] }),
|
|
9228
|
-
footer: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9229
|
-
"button",
|
|
9230
|
-
{
|
|
9231
|
-
className: "w-full h-full text-center text-icon2 hover:text-icon6 text-ui-md",
|
|
9232
|
-
onClick: () => setExpanded((s) => !s),
|
|
9233
|
-
children: expanded ? "collapse" : "expand"
|
|
9234
|
-
}
|
|
9235
|
-
),
|
|
9236
|
-
children: expanded ? /* @__PURE__ */ jsxRuntime.jsx(CodeBlockDemo, { className: "w-full overflow-x-auto", code: sanitizedJsonResult || jsonResult, language: "json" }) : null
|
|
9237
|
-
}
|
|
9872
|
+
const RecordField = ({ inputProps, field, error, id }) => {
|
|
9873
|
+
const { key, onChange, ...props } = inputProps;
|
|
9874
|
+
const [pairs, setPairs] = React__namespace.useState(
|
|
9875
|
+
() => Object.entries(field.default || {}).map(([key2, val]) => ({
|
|
9876
|
+
id: key2 || uuid.v4(),
|
|
9877
|
+
key: key2,
|
|
9878
|
+
value: val
|
|
9879
|
+
}))
|
|
9238
9880
|
);
|
|
9239
|
-
|
|
9240
|
-
|
|
9241
|
-
|
|
9242
|
-
workflowId,
|
|
9243
|
-
setRunId
|
|
9244
|
-
}) {
|
|
9245
|
-
const { legacyResult: result, setLegacyResult: setResult, payload, setPayload } = React.useContext(WorkflowRunContext);
|
|
9246
|
-
const { isLoading, legacyWorkflow: workflow } = useLegacyWorkflow(workflowId);
|
|
9247
|
-
const { createLegacyWorkflowRun: createWorkflowRun, startLegacyWorkflowRun: startWorkflowRun } = useExecuteWorkflow();
|
|
9248
|
-
const {
|
|
9249
|
-
watchLegacyWorkflow: watchWorkflow,
|
|
9250
|
-
legacyWatchResult: watchResult,
|
|
9251
|
-
isWatchingLegacyWorkflow: isWatchingWorkflow
|
|
9252
|
-
} = useWatchWorkflow();
|
|
9253
|
-
const { resumeLegacyWorkflow: resumeWorkflow, isResumingLegacyWorkflow: isResumingWorkflow } = useResumeWorkflow();
|
|
9254
|
-
const [suspendedSteps, setSuspendedSteps] = React.useState([]);
|
|
9255
|
-
const [isRunning, setIsRunning] = React.useState(false);
|
|
9256
|
-
const triggerSchema = workflow?.triggerSchema;
|
|
9257
|
-
const handleExecuteWorkflow = async (data) => {
|
|
9258
|
-
try {
|
|
9259
|
-
if (!workflow) return;
|
|
9260
|
-
setIsRunning(true);
|
|
9261
|
-
setResult(null);
|
|
9262
|
-
const { runId } = await createWorkflowRun({ workflowId });
|
|
9263
|
-
setRunId?.(runId);
|
|
9264
|
-
watchWorkflow({ workflowId, runId });
|
|
9265
|
-
startWorkflowRun({ workflowId, runId, input: data });
|
|
9266
|
-
} catch (err) {
|
|
9267
|
-
setIsRunning(false);
|
|
9268
|
-
sonner.toast.error("Error executing workflow");
|
|
9881
|
+
React__namespace.useEffect(() => {
|
|
9882
|
+
if (pairs.length === 0) {
|
|
9883
|
+
setPairs([{ id: uuid.v4(), key: "", value: "" }]);
|
|
9269
9884
|
}
|
|
9885
|
+
}, [pairs]);
|
|
9886
|
+
const updateForm = React__namespace.useCallback(
|
|
9887
|
+
(newPairs) => {
|
|
9888
|
+
const newValue = newPairs.reduce(
|
|
9889
|
+
(acc, pair) => {
|
|
9890
|
+
if (pair.key) {
|
|
9891
|
+
acc[pair.key] = pair.value;
|
|
9892
|
+
}
|
|
9893
|
+
return acc;
|
|
9894
|
+
},
|
|
9895
|
+
{}
|
|
9896
|
+
);
|
|
9897
|
+
onChange?.({
|
|
9898
|
+
target: { value: newValue, name: inputProps.name }
|
|
9899
|
+
});
|
|
9900
|
+
},
|
|
9901
|
+
[onChange, inputProps.name]
|
|
9902
|
+
);
|
|
9903
|
+
const handleChange = (id2, field2, newValue) => {
|
|
9904
|
+
setPairs((prev) => prev.map((pair) => pair.id === id2 ? { ...pair, [field2]: newValue } : pair));
|
|
9270
9905
|
};
|
|
9271
|
-
const
|
|
9272
|
-
|
|
9273
|
-
const { stepId, runId: prevRunId, context } = step;
|
|
9274
|
-
const { runId } = await createWorkflowRun({ workflowId, prevRunId });
|
|
9275
|
-
watchWorkflow({ workflowId, runId });
|
|
9276
|
-
await resumeWorkflow({
|
|
9277
|
-
stepId,
|
|
9278
|
-
runId,
|
|
9279
|
-
context,
|
|
9280
|
-
workflowId
|
|
9281
|
-
});
|
|
9906
|
+
const handleBlur = () => {
|
|
9907
|
+
updateForm(pairs);
|
|
9282
9908
|
};
|
|
9283
|
-
const
|
|
9284
|
-
|
|
9285
|
-
|
|
9286
|
-
|
|
9287
|
-
}
|
|
9288
|
-
|
|
9289
|
-
|
|
9290
|
-
|
|
9291
|
-
|
|
9292
|
-
runId: result.runId,
|
|
9293
|
-
suspendPayload
|
|
9294
|
-
}));
|
|
9295
|
-
setSuspendedSteps(suspended);
|
|
9296
|
-
}, [watchResultToUse, result]);
|
|
9297
|
-
React.useEffect(() => {
|
|
9298
|
-
if (watchResult) {
|
|
9299
|
-
setResult(watchResult);
|
|
9909
|
+
const addPair = () => {
|
|
9910
|
+
const newPairs = [...pairs, { id: uuid.v4(), key: "", value: "" }];
|
|
9911
|
+
setPairs(newPairs);
|
|
9912
|
+
updateForm(newPairs);
|
|
9913
|
+
};
|
|
9914
|
+
const removePair = (id2) => {
|
|
9915
|
+
const newPairs = pairs.filter((p) => p.id !== id2);
|
|
9916
|
+
if (newPairs.length === 0) {
|
|
9917
|
+
newPairs.push({ id: uuid.v4(), key: "", value: "" });
|
|
9300
9918
|
}
|
|
9301
|
-
|
|
9302
|
-
|
|
9303
|
-
|
|
9304
|
-
|
|
9305
|
-
|
|
9306
|
-
|
|
9307
|
-
|
|
9308
|
-
|
|
9309
|
-
|
|
9310
|
-
|
|
9311
|
-
|
|
9312
|
-
|
|
9313
|
-
|
|
9314
|
-
|
|
9315
|
-
/* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "animate-spin text-icon6" }) }),
|
|
9316
|
-
/* @__PURE__ */ jsxRuntime.jsx(Txt, { children: "Resuming workflow" })
|
|
9317
|
-
] }),
|
|
9318
|
-
!isSuspendedSteps && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: zodInputSchema ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
9319
|
-
DynamicForm,
|
|
9320
|
-
{
|
|
9321
|
-
schema: zodInputSchema,
|
|
9322
|
-
defaultValues: payload,
|
|
9323
|
-
isSubmitLoading: isWatchingWorkflow,
|
|
9324
|
-
submitButtonLabel: "Run",
|
|
9325
|
-
onSubmit: (data) => {
|
|
9326
|
-
setPayload(data);
|
|
9327
|
-
handleExecuteWorkflow(data);
|
|
9919
|
+
setPairs(newPairs);
|
|
9920
|
+
updateForm(newPairs);
|
|
9921
|
+
};
|
|
9922
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
|
|
9923
|
+
pairs.map((pair) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative space-y-2 rounded-lg border p-4", children: [
|
|
9924
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9925
|
+
Button$1,
|
|
9926
|
+
{
|
|
9927
|
+
type: "button",
|
|
9928
|
+
variant: "ghost",
|
|
9929
|
+
size: "icon",
|
|
9930
|
+
className: "absolute right-2 top-2",
|
|
9931
|
+
onClick: () => removePair(pair.id),
|
|
9932
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.TrashIcon, { className: "h-4 w-4" })
|
|
9328
9933
|
}
|
|
9329
|
-
|
|
9330
|
-
|
|
9331
|
-
|
|
9332
|
-
|
|
9333
|
-
className: "w-full",
|
|
9334
|
-
variant: "light",
|
|
9335
|
-
disabled: isRunning,
|
|
9336
|
-
onClick: () => handleExecuteWorkflow(null),
|
|
9337
|
-
children: isRunning ? /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "animate-spin" }) }) : "Trigger"
|
|
9338
|
-
}
|
|
9339
|
-
) }),
|
|
9340
|
-
isSuspendedSteps && suspendedSteps?.map((step) => {
|
|
9341
|
-
const stepDefinition = workflow.steps[step.stepId];
|
|
9342
|
-
const stepSchema = stepDefinition?.inputSchema ? resolveSerializedZodOutput(jsonSchemaToZod(superjson.parse(stepDefinition.inputSchema))) : z.z.record(z.z.string(), z.z.any());
|
|
9343
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col px-4", children: [
|
|
9344
|
-
/* @__PURE__ */ jsxRuntime.jsx(Text, { variant: "secondary", className: "text-mastra-el-3", size: "xs", children: step.stepId }),
|
|
9345
|
-
step.suspendPayload && /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9346
|
-
CodeBlockDemo,
|
|
9934
|
+
),
|
|
9935
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2 pt-6", children: [
|
|
9936
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9937
|
+
Input,
|
|
9347
9938
|
{
|
|
9348
|
-
|
|
9349
|
-
|
|
9350
|
-
|
|
9939
|
+
placeholder: "Key",
|
|
9940
|
+
value: pair.key,
|
|
9941
|
+
onChange: (e) => handleChange(pair.id, "key", e.target.value),
|
|
9942
|
+
onBlur: handleBlur
|
|
9351
9943
|
}
|
|
9352
|
-
)
|
|
9944
|
+
),
|
|
9353
9945
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9354
|
-
|
|
9946
|
+
Input,
|
|
9355
9947
|
{
|
|
9356
|
-
|
|
9357
|
-
|
|
9358
|
-
|
|
9359
|
-
|
|
9360
|
-
handleResumeWorkflow({
|
|
9361
|
-
stepId: step.stepId,
|
|
9362
|
-
runId: step.runId,
|
|
9363
|
-
suspendPayload: step.suspendPayload,
|
|
9364
|
-
context: data
|
|
9365
|
-
});
|
|
9366
|
-
}
|
|
9948
|
+
placeholder: "Value",
|
|
9949
|
+
value: pair.value,
|
|
9950
|
+
onChange: (e) => handleChange(pair.id, "value", e.target.value),
|
|
9951
|
+
onBlur: handleBlur
|
|
9367
9952
|
}
|
|
9368
9953
|
)
|
|
9369
|
-
] })
|
|
9370
|
-
}),
|
|
9371
|
-
|
|
9372
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9373
|
-
|
|
9374
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-1", children: stepPath?.map((path, idx) => {
|
|
9375
|
-
return /* @__PURE__ */ jsxRuntime.jsx(LegacyWorkflowStatus, { stepId, pathStatus, path }, idx);
|
|
9376
|
-
}) }, stepId);
|
|
9377
|
-
}) })
|
|
9378
|
-
] }),
|
|
9379
|
-
result && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
9380
|
-
/* @__PURE__ */ jsxRuntime.jsx("hr", { className: "border-border1 border-sm my-5" }),
|
|
9381
|
-
/* @__PURE__ */ jsxRuntime.jsx(WorkflowResult, { sanitizedJsonResult: sanitizedOutput, jsonResult: JSON.stringify(restResult, null, 2) })
|
|
9954
|
+
] })
|
|
9955
|
+
] }, pair.id)),
|
|
9956
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Button$1, { type: "button", variant: "outline", size: "sm", className: "w-full", onClick: addPair, children: [
|
|
9957
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "mr-2 h-4 w-4" }),
|
|
9958
|
+
"Add Key-Value Pair"
|
|
9382
9959
|
] })
|
|
9383
|
-
] })
|
|
9960
|
+
] });
|
|
9961
|
+
};
|
|
9962
|
+
|
|
9963
|
+
const ShadcnUIComponents = {
|
|
9964
|
+
Form,
|
|
9965
|
+
FieldWrapper,
|
|
9966
|
+
ErrorMessage,
|
|
9967
|
+
SubmitButton,
|
|
9968
|
+
ObjectWrapper,
|
|
9969
|
+
ArrayWrapper,
|
|
9970
|
+
ArrayElementWrapper
|
|
9971
|
+
};
|
|
9972
|
+
function AutoForm({
|
|
9973
|
+
uiComponents,
|
|
9974
|
+
formComponents,
|
|
9975
|
+
readOnly,
|
|
9976
|
+
...props
|
|
9977
|
+
}) {
|
|
9978
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
9979
|
+
react$3.AutoForm,
|
|
9980
|
+
{
|
|
9981
|
+
...props,
|
|
9982
|
+
uiComponents: { ...ShadcnUIComponents, ...uiComponents },
|
|
9983
|
+
formComponents: {
|
|
9984
|
+
string: (props2) => /* @__PURE__ */ jsxRuntime.jsx(StringField, { ...props2, inputProps: { ...props2.inputProps, readOnly } }),
|
|
9985
|
+
number: (props2) => /* @__PURE__ */ jsxRuntime.jsx(NumberField, { ...props2, inputProps: { ...props2.inputProps, readOnly } }),
|
|
9986
|
+
boolean: (props2) => /* @__PURE__ */ jsxRuntime.jsx(BooleanField, { ...props2, inputProps: { ...props2.inputProps, readOnly } }),
|
|
9987
|
+
date: (props2) => /* @__PURE__ */ jsxRuntime.jsx(DateField, { ...props2, inputProps: { ...props2.inputProps, readOnly } }),
|
|
9988
|
+
select: (props2) => /* @__PURE__ */ jsxRuntime.jsx(SelectField, { ...props2, inputProps: { ...props2.inputProps, readOnly } }),
|
|
9989
|
+
record: (props2) => /* @__PURE__ */ jsxRuntime.jsx(RecordField, { ...props2, inputProps: { ...props2.inputProps, readOnly } }),
|
|
9990
|
+
...formComponents
|
|
9991
|
+
}
|
|
9992
|
+
}
|
|
9993
|
+
);
|
|
9384
9994
|
}
|
|
9385
9995
|
|
|
9386
|
-
|
|
9387
|
-
SliderPrimitive__namespace.Root,
|
|
9388
|
-
{
|
|
9389
|
-
ref,
|
|
9390
|
-
className: cn("relative flex w-full touch-none select-none items-center", className),
|
|
9391
|
-
...props,
|
|
9392
|
-
children: [
|
|
9393
|
-
/* @__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" }) }),
|
|
9394
|
-
/* @__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" })
|
|
9395
|
-
]
|
|
9396
|
-
}
|
|
9397
|
-
));
|
|
9398
|
-
Slider.displayName = SliderPrimitive__namespace.Root.displayName;
|
|
9996
|
+
react$3.buildZodFieldConfig();
|
|
9399
9997
|
|
|
9400
|
-
|
|
9401
|
-
|
|
9402
|
-
|
|
9403
|
-
|
|
9404
|
-
|
|
9405
|
-
|
|
9406
|
-
|
|
9407
|
-
|
|
9408
|
-
|
|
9409
|
-
|
|
9410
|
-
|
|
9411
|
-
|
|
9412
|
-
|
|
9413
|
-
|
|
9414
|
-
|
|
9415
|
-
}
|
|
9416
|
-
}
|
|
9417
|
-
),
|
|
9418
|
-
/* @__PURE__ */ jsxRuntime.jsx(Button$1, { variant: "ghost", size: "icon", onClick: () => zoomIn({ duration: 300 }), children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "h-4 w-4" }) }),
|
|
9419
|
-
/* @__PURE__ */ jsxRuntime.jsxs(Button$1, { className: "min-w-20 tabular-nums", variant: "ghost", onClick: () => zoomTo(1, { duration: 300 }), children: [
|
|
9420
|
-
(100 * zoom).toFixed(0),
|
|
9421
|
-
"%"
|
|
9422
|
-
] }),
|
|
9423
|
-
/* @__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" }) })
|
|
9424
|
-
] });
|
|
9425
|
-
});
|
|
9426
|
-
ZoomSlider.displayName = "ZoomSlider";
|
|
9998
|
+
function inferFieldType(schema, fieldConfig) {
|
|
9999
|
+
if (fieldConfig?.fieldType) {
|
|
10000
|
+
return fieldConfig.fieldType;
|
|
10001
|
+
}
|
|
10002
|
+
if (schema instanceof z.z.ZodObject) return "object";
|
|
10003
|
+
if (schema instanceof z.z.ZodNumber) return "number";
|
|
10004
|
+
if (schema instanceof z.z.ZodBoolean) return "boolean";
|
|
10005
|
+
if (schema instanceof z.z.ZodDate || schema?.isDatetime || schema?.isDate) return "date";
|
|
10006
|
+
if (schema instanceof z.z.ZodString) return "string";
|
|
10007
|
+
if (schema instanceof z.z.ZodEnum) return "select";
|
|
10008
|
+
if (schema instanceof z.z.ZodNativeEnum) return "select";
|
|
10009
|
+
if (schema instanceof z.z.ZodArray) return "array";
|
|
10010
|
+
if (schema instanceof z.z.ZodRecord) return "record";
|
|
10011
|
+
return "string";
|
|
10012
|
+
}
|
|
9427
10013
|
|
|
9428
|
-
function
|
|
9429
|
-
const
|
|
9430
|
-
|
|
9431
|
-
|
|
9432
|
-
const
|
|
9433
|
-
const
|
|
9434
|
-
|
|
9435
|
-
|
|
9436
|
-
|
|
9437
|
-
|
|
9438
|
-
|
|
9439
|
-
|
|
9440
|
-
"loop-result-node": WorkflowLoopResultNode,
|
|
9441
|
-
"nested-node": (props) => /* @__PURE__ */ jsxRuntime.jsx(WorkflowNestedNode, { parentWorkflowName: workflowName, ...props })
|
|
9442
|
-
};
|
|
9443
|
-
React.useEffect(() => {
|
|
9444
|
-
if (open) {
|
|
9445
|
-
setTimeout(() => {
|
|
9446
|
-
setIsMounted(true);
|
|
9447
|
-
}, 500);
|
|
9448
|
-
}
|
|
9449
|
-
}, [open]);
|
|
9450
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full h-full relative bg-surface1", children: isMounted ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9451
|
-
react$2.ReactFlow,
|
|
9452
|
-
{
|
|
9453
|
-
nodes,
|
|
9454
|
-
edges: edges.map((e) => ({
|
|
9455
|
-
...e,
|
|
9456
|
-
style: {
|
|
9457
|
-
...e.style,
|
|
9458
|
-
stroke: steps[`${workflowName}.${e.data?.previousStepId}`]?.status === "success" && steps[`${workflowName}.${e.data?.nextStepId}`] ? "#22c55e" : void 0
|
|
9459
|
-
}
|
|
9460
|
-
})),
|
|
9461
|
-
fitView: true,
|
|
9462
|
-
fitViewOptions: {
|
|
9463
|
-
maxZoom: 1
|
|
9464
|
-
},
|
|
9465
|
-
minZoom: 0.01,
|
|
9466
|
-
maxZoom: 1,
|
|
9467
|
-
nodeTypes,
|
|
9468
|
-
onNodesChange,
|
|
9469
|
-
children: [
|
|
9470
|
-
/* @__PURE__ */ jsxRuntime.jsx(ZoomSlider, { position: "bottom-left" }),
|
|
9471
|
-
/* @__PURE__ */ jsxRuntime.jsx(react$2.MiniMap, { pannable: true, zoomable: true, maskColor: "#121212", bgColor: "#171717", nodeColor: "#2c2c2c" }),
|
|
9472
|
-
/* @__PURE__ */ jsxRuntime.jsx(react$2.Background, { variant: react$2.BackgroundVariant.Lines, gap: 12, size: 0.5 })
|
|
9473
|
-
]
|
|
10014
|
+
function parseField(key, schema) {
|
|
10015
|
+
const baseSchema = getBaseSchema(schema);
|
|
10016
|
+
const fieldConfig = zod.getFieldConfigInZodStack(schema);
|
|
10017
|
+
const type = inferFieldType(baseSchema, fieldConfig);
|
|
10018
|
+
const defaultValue = zod.getDefaultValueInZodStack(schema);
|
|
10019
|
+
const options = baseSchema._def?.values;
|
|
10020
|
+
let optionValues = [];
|
|
10021
|
+
if (options) {
|
|
10022
|
+
if (!Array.isArray(options)) {
|
|
10023
|
+
optionValues = Object.entries(options);
|
|
10024
|
+
} else {
|
|
10025
|
+
optionValues = options.map((value) => [value, value]);
|
|
9474
10026
|
}
|
|
9475
|
-
|
|
10027
|
+
}
|
|
10028
|
+
let subSchema = [];
|
|
10029
|
+
if (baseSchema instanceof z.z.ZodObject) {
|
|
10030
|
+
subSchema = Object.entries(baseSchema.shape).map(([key2, field]) => parseField(key2, field));
|
|
10031
|
+
}
|
|
10032
|
+
if (baseSchema instanceof z.z.ZodArray) {
|
|
10033
|
+
subSchema = [parseField("0", baseSchema._def.type)];
|
|
10034
|
+
}
|
|
10035
|
+
return {
|
|
10036
|
+
key,
|
|
10037
|
+
type,
|
|
10038
|
+
required: !schema.isOptional(),
|
|
10039
|
+
default: defaultValue,
|
|
10040
|
+
description: baseSchema.description,
|
|
10041
|
+
fieldConfig,
|
|
10042
|
+
options: optionValues,
|
|
10043
|
+
schema: subSchema
|
|
10044
|
+
};
|
|
10045
|
+
}
|
|
10046
|
+
function getBaseSchema(schema) {
|
|
10047
|
+
if ("innerType" in schema._def) {
|
|
10048
|
+
return getBaseSchema(schema._def.innerType);
|
|
10049
|
+
}
|
|
10050
|
+
if ("schema" in schema._def) {
|
|
10051
|
+
return getBaseSchema(schema._def.schema);
|
|
10052
|
+
}
|
|
10053
|
+
return schema;
|
|
10054
|
+
}
|
|
10055
|
+
function parseSchema(schema) {
|
|
10056
|
+
const objectSchema = schema instanceof z.z.ZodEffects ? schema.innerType() : schema;
|
|
10057
|
+
const shape = objectSchema.shape;
|
|
10058
|
+
const fields = Object.entries(shape).map(([key, field]) => parseField(key, field));
|
|
10059
|
+
return { fields };
|
|
10060
|
+
}
|
|
10061
|
+
class CustomZodProvider extends zod.ZodProvider {
|
|
10062
|
+
_schema;
|
|
10063
|
+
constructor(schema) {
|
|
10064
|
+
super(schema);
|
|
10065
|
+
this._schema = schema;
|
|
10066
|
+
}
|
|
10067
|
+
parseSchema() {
|
|
10068
|
+
return parseSchema(this._schema);
|
|
10069
|
+
}
|
|
9476
10070
|
}
|
|
9477
10071
|
|
|
9478
|
-
const
|
|
9479
|
-
|
|
9480
|
-
|
|
9481
|
-
|
|
9482
|
-
|
|
9483
|
-
|
|
9484
|
-
|
|
9485
|
-
|
|
9486
|
-
|
|
9487
|
-
|
|
9488
|
-
|
|
9489
|
-
|
|
9490
|
-
|
|
9491
|
-
|
|
9492
|
-
|
|
9493
|
-
|
|
9494
|
-
|
|
9495
|
-
|
|
9496
|
-
|
|
9497
|
-
|
|
9498
|
-
|
|
9499
|
-
|
|
9500
|
-
|
|
9501
|
-
|
|
9502
|
-
|
|
9503
|
-
|
|
10072
|
+
const labelVariants = cva("text-sm leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70");
|
|
10073
|
+
const Label = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(LabelPrimitive__namespace.Root, { ref, className: cn(labelVariants(), className), ...props }));
|
|
10074
|
+
Label.displayName = LabelPrimitive__namespace.Root.displayName;
|
|
10075
|
+
|
|
10076
|
+
function isEmptyZodObject(schema) {
|
|
10077
|
+
if (schema instanceof z.ZodObject) {
|
|
10078
|
+
return Object.keys(schema.shape).length === 0;
|
|
10079
|
+
}
|
|
10080
|
+
return false;
|
|
10081
|
+
}
|
|
10082
|
+
function DynamicForm({
|
|
10083
|
+
schema,
|
|
10084
|
+
onSubmit,
|
|
10085
|
+
defaultValues,
|
|
10086
|
+
isSubmitLoading,
|
|
10087
|
+
submitButtonLabel,
|
|
10088
|
+
className,
|
|
10089
|
+
readOnly
|
|
10090
|
+
}) {
|
|
10091
|
+
const isNotZodObject = !(schema instanceof z.ZodObject);
|
|
10092
|
+
if (!schema) {
|
|
10093
|
+
console.error("no form schema found");
|
|
10094
|
+
return null;
|
|
10095
|
+
}
|
|
10096
|
+
const normalizedSchema = (schema2) => {
|
|
10097
|
+
if (isEmptyZodObject(schema2)) {
|
|
10098
|
+
return z.object({});
|
|
9504
10099
|
}
|
|
9505
|
-
|
|
9506
|
-
|
|
9507
|
-
|
|
9508
|
-
|
|
9509
|
-
fullStep: newFullStep
|
|
9510
|
-
}) => {
|
|
9511
|
-
if (stepGraph) {
|
|
9512
|
-
setSwitching(true);
|
|
9513
|
-
setParentStepGraphList([...parentStepGraphList, { stepGraph, label, fullStep }]);
|
|
10100
|
+
if (isNotZodObject) {
|
|
10101
|
+
return z.object({
|
|
10102
|
+
"": schema2
|
|
10103
|
+
});
|
|
9514
10104
|
}
|
|
9515
|
-
|
|
9516
|
-
setFullStep(newFullStep);
|
|
9517
|
-
setStepGraph(newStepGraph);
|
|
9518
|
-
setOpenDialog(true);
|
|
9519
|
-
setTimeout(() => {
|
|
9520
|
-
setSwitching(false);
|
|
9521
|
-
}, 500);
|
|
10105
|
+
return schema2;
|
|
9522
10106
|
};
|
|
9523
|
-
|
|
9524
|
-
|
|
9525
|
-
|
|
9526
|
-
|
|
9527
|
-
|
|
9528
|
-
|
|
9529
|
-
|
|
9530
|
-
|
|
9531
|
-
|
|
9532
|
-
|
|
9533
|
-
|
|
9534
|
-
|
|
9535
|
-
|
|
9536
|
-
|
|
9537
|
-
|
|
9538
|
-
|
|
9539
|
-
|
|
9540
|
-
|
|
9541
|
-
|
|
9542
|
-
]
|
|
9543
|
-
}
|
|
9544
|
-
);
|
|
10107
|
+
const schemaProvider = new CustomZodProvider(normalizedSchema(schema));
|
|
10108
|
+
const formProps = {
|
|
10109
|
+
schema: schemaProvider,
|
|
10110
|
+
onSubmit: async (values) => {
|
|
10111
|
+
await onSubmit?.(isNotZodObject ? values[""] || {} : values);
|
|
10112
|
+
},
|
|
10113
|
+
defaultValues: isNotZodObject ? defaultValues ? { "": defaultValues } : void 0 : defaultValues,
|
|
10114
|
+
formProps: {
|
|
10115
|
+
className: ""
|
|
10116
|
+
},
|
|
10117
|
+
uiComponents: {
|
|
10118
|
+
SubmitButton: ({ children }) => onSubmit ? /* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "light", className: "w-full", size: "lg", disabled: isSubmitLoading, children: isSubmitLoading ? /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "animate-spin" }) }) : submitButtonLabel || children }) : null
|
|
10119
|
+
},
|
|
10120
|
+
formComponents: {
|
|
10121
|
+
Label: ({ value }) => /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-sm font-normal", children: value })
|
|
10122
|
+
},
|
|
10123
|
+
withSubmit: true
|
|
10124
|
+
};
|
|
10125
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AutoForm, { ...formProps, readOnly });
|
|
9545
10126
|
}
|
|
9546
10127
|
|
|
9547
|
-
function
|
|
9548
|
-
|
|
9549
|
-
|
|
10128
|
+
function resolveSerializedZodOutput(obj) {
|
|
10129
|
+
return Function("z", `"use strict";return (${obj});`)(z.z);
|
|
10130
|
+
}
|
|
10131
|
+
|
|
10132
|
+
function CodeBlockDemo({
|
|
10133
|
+
code = "",
|
|
10134
|
+
language = "ts",
|
|
10135
|
+
filename,
|
|
10136
|
+
className
|
|
9550
10137
|
}) {
|
|
9551
|
-
|
|
9552
|
-
|
|
9553
|
-
|
|
9554
|
-
|
|
9555
|
-
const { steps, isRunning } = useCurrentRun();
|
|
9556
|
-
const { showNestedGraph } = React.useContext(WorkflowNestedGraphContext);
|
|
9557
|
-
const { label, description, withoutTopHandle, withoutBottomHandle, stepGraph, mapConfig } = data;
|
|
9558
|
-
const fullLabel = parentWorkflowName ? `${parentWorkflowName}.${label}` : label;
|
|
9559
|
-
const step = steps[fullLabel];
|
|
9560
|
-
const dialogContentClass = "bg-surface2 rounded-lg border-sm border-border1 max-w-4xl w-full px-0";
|
|
9561
|
-
const dialogTitleClass = "border-b-sm border-border1 pb-4 px-6";
|
|
9562
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
9563
|
-
!withoutTopHandle && /* @__PURE__ */ jsxRuntime.jsx(react$2.Handle, { type: "target", position: react$2.Position.Top, style: { visibility: "hidden" } }),
|
|
9564
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
9565
|
-
"div",
|
|
10138
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactCodeBlock.CodeBlock, { code, language, theme: prismReactRenderer.themes.oneDark, children: [
|
|
10139
|
+
filename ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute w-full px-6 py-2 pl-4 text-sm rounded bg-mastra-bg-2 text-mastra-el-6/50", children: filename }) : null,
|
|
10140
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10141
|
+
reactCodeBlock.CodeBlock.Code,
|
|
9566
10142
|
{
|
|
9567
|
-
className: cn(
|
|
9568
|
-
|
|
9569
|
-
|
|
9570
|
-
|
|
9571
|
-
)
|
|
9572
|
-
children: [
|
|
9573
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex items-center gap-2 px-3", !description && "pb-2"), children: [
|
|
9574
|
-
isRunning && /* @__PURE__ */ jsxRuntime.jsxs(Icon, { children: [
|
|
9575
|
-
step?.status === "failed" && /* @__PURE__ */ jsxRuntime.jsx(CrossIcon, { className: "text-accent2" }),
|
|
9576
|
-
step?.status === "success" && /* @__PURE__ */ jsxRuntime.jsx(CheckIcon, { className: "text-accent1" }),
|
|
9577
|
-
step?.status === "suspended" && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.PauseIcon, { className: "text-icon3" }),
|
|
9578
|
-
step?.status === "running" && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "text-icon6 animate-spin" }),
|
|
9579
|
-
!step && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleDashed, { className: "text-icon2" })
|
|
9580
|
-
] }),
|
|
9581
|
-
/* @__PURE__ */ jsxRuntime.jsxs(Txt, { variant: "ui-lg", className: "text-icon6 font-medium inline-flex items-center gap-1 justify-between w-full", children: [
|
|
9582
|
-
label,
|
|
9583
|
-
" ",
|
|
9584
|
-
step?.startedAt && /* @__PURE__ */ jsxRuntime.jsx(Clock, { startedAt: step.startedAt, endedAt: step.endedAt })
|
|
9585
|
-
] })
|
|
9586
|
-
] }),
|
|
9587
|
-
description && /* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-sm", className: "text-icon3 px-3 pb-2", children: description }),
|
|
9588
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center bg-surface4 border-t-sm border-border1 px-2 py-1 gap-2 rounded-b-lg", children: [
|
|
9589
|
-
/* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: () => showNestedGraph({ label, fullStep: fullLabel, stepGraph }), children: "View workflow" }),
|
|
9590
|
-
mapConfig && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
9591
|
-
/* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: () => setIsMapConfigOpen(true), children: "Map config" }),
|
|
9592
|
-
/* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: isMapConfigOpen, onOpenChange: setIsMapConfigOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: dialogContentClass, children: [
|
|
9593
|
-
/* @__PURE__ */ jsxRuntime.jsxs(DialogTitle, { className: dialogTitleClass, children: [
|
|
9594
|
-
label,
|
|
9595
|
-
" map config"
|
|
9596
|
-
] }),
|
|
9597
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(CodeDialogContent, { data: mapConfig }) })
|
|
9598
|
-
] }) })
|
|
9599
|
-
] }),
|
|
9600
|
-
step?.input && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
9601
|
-
/* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: () => setIsInputOpen(true), children: "Input" }),
|
|
9602
|
-
/* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: isInputOpen, onOpenChange: setIsInputOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: dialogContentClass, children: [
|
|
9603
|
-
/* @__PURE__ */ jsxRuntime.jsxs(DialogTitle, { className: dialogTitleClass, children: [
|
|
9604
|
-
label,
|
|
9605
|
-
" input"
|
|
9606
|
-
] }),
|
|
9607
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(CodeDialogContent, { data: step.input }) })
|
|
9608
|
-
] }) })
|
|
9609
|
-
] }),
|
|
9610
|
-
step?.output && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
9611
|
-
/* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: () => setIsOutputOpen(true), children: "Output" }),
|
|
9612
|
-
/* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: isOutputOpen, onOpenChange: setIsOutputOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: dialogContentClass, children: [
|
|
9613
|
-
/* @__PURE__ */ jsxRuntime.jsxs(DialogTitle, { className: dialogTitleClass, children: [
|
|
9614
|
-
label,
|
|
9615
|
-
" output"
|
|
9616
|
-
] }),
|
|
9617
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(CodeDialogContent, { data: step.output }) })
|
|
9618
|
-
] }) })
|
|
9619
|
-
] }),
|
|
9620
|
-
step?.error && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
9621
|
-
/* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: () => setIsErrorOpen(true), children: "Error" }),
|
|
9622
|
-
/* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: isErrorOpen, onOpenChange: setIsErrorOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: dialogContentClass, children: [
|
|
9623
|
-
/* @__PURE__ */ jsxRuntime.jsxs(DialogTitle, { className: dialogTitleClass, children: [
|
|
9624
|
-
label,
|
|
9625
|
-
" error"
|
|
9626
|
-
] }),
|
|
9627
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(CodeDialogContent, { data: step?.error }) })
|
|
9628
|
-
] }) })
|
|
9629
|
-
] })
|
|
9630
|
-
] })
|
|
9631
|
-
]
|
|
10143
|
+
className: cn("bg-transparent h-full p-6 rounded-xl whitespace-pre-wrap", filename ? "pt-10" : "", className),
|
|
10144
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "table-row", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center", children: [
|
|
10145
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactCodeBlock.CodeBlock.LineNumber, { className: "table-cell pr-4 text-sm text-right select-none text-gray-500/50" }),
|
|
10146
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactCodeBlock.CodeBlock.LineContent, { className: "flex", children: /* @__PURE__ */ jsxRuntime.jsx(reactCodeBlock.CodeBlock.Token, { className: "font-mono text-sm mastra-token" }) })
|
|
10147
|
+
] }) })
|
|
9632
10148
|
}
|
|
9633
|
-
)
|
|
9634
|
-
!withoutBottomHandle && /* @__PURE__ */ jsxRuntime.jsx(react$2.Handle, { type: "source", position: react$2.Position.Bottom, style: { visibility: "hidden" } })
|
|
10149
|
+
)
|
|
9635
10150
|
] });
|
|
9636
10151
|
}
|
|
9637
10152
|
|
|
9638
|
-
|
|
9639
|
-
|
|
9640
|
-
|
|
9641
|
-
|
|
9642
|
-
|
|
9643
|
-
|
|
9644
|
-
|
|
9645
|
-
|
|
9646
|
-
|
|
9647
|
-
|
|
9648
|
-
|
|
9649
|
-
|
|
9650
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full h-full bg-surface1", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9651
|
-
react$2.ReactFlow,
|
|
10153
|
+
const WorkflowCard = ({ header, children, footer }) => {
|
|
10154
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border-sm border-border1 bg-surface4", children: [
|
|
10155
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "py-1 px-2 flex items-center gap-3", children: header }),
|
|
10156
|
+
children && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t-sm border-border1", children }),
|
|
10157
|
+
footer && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "py-1 px-2 border-t-sm border-border1", children: footer })
|
|
10158
|
+
] });
|
|
10159
|
+
};
|
|
10160
|
+
|
|
10161
|
+
const LegacyWorkflowStatus = ({ stepId, pathStatus, path }) => {
|
|
10162
|
+
const status = pathStatus === "completed" ? "Completed" : stepId === path ? pathStatus.charAt(0).toUpperCase() + pathStatus.slice(1) : pathStatus === "executing" ? "Executing" : "Completed";
|
|
10163
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
10164
|
+
WorkflowCard,
|
|
9652
10165
|
{
|
|
9653
|
-
|
|
9654
|
-
|
|
9655
|
-
|
|
9656
|
-
|
|
9657
|
-
|
|
9658
|
-
|
|
10166
|
+
header: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
10167
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Icon, { children: [
|
|
10168
|
+
status === "Completed" && /* @__PURE__ */ jsxRuntime.jsx(CheckIcon, { className: "text-accent1" }),
|
|
10169
|
+
status === "Failed" && /* @__PURE__ */ jsxRuntime.jsx(CrossIcon, { className: "text-accent2" }),
|
|
10170
|
+
status === "Executing" && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "text-icon3 animate-spin" })
|
|
10171
|
+
] }),
|
|
10172
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "span", variant: "ui-lg", className: "text-icon6 font-medium", children: path })
|
|
10173
|
+
] })
|
|
10174
|
+
}
|
|
10175
|
+
);
|
|
10176
|
+
};
|
|
10177
|
+
|
|
10178
|
+
const WorkflowResult = ({ jsonResult, sanitizedJsonResult }) => {
|
|
10179
|
+
const { handleCopy } = useCopyToClipboard({ text: jsonResult });
|
|
10180
|
+
const [expanded, setExpanded] = React.useState(false);
|
|
10181
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
10182
|
+
WorkflowCard,
|
|
10183
|
+
{
|
|
10184
|
+
header: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 justify-between w-full", children: [
|
|
10185
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Txt, { variant: "ui-lg", className: "text-icon6 flex items-center gap-3 font-medium", children: [
|
|
10186
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(DeploymentIcon, {}) }),
|
|
10187
|
+
"Workflow Execution (JSON)"
|
|
10188
|
+
] }),
|
|
10189
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
|
|
10190
|
+
/* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10191
|
+
"button",
|
|
10192
|
+
{
|
|
10193
|
+
className: "p-2 rounded-lg hover:bg-surface5 transition-colors duration-150 ease-in-out text-icon3 hover:text-icon6",
|
|
10194
|
+
onClick: () => handleCopy(),
|
|
10195
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { size: "sm", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CopyIcon, {}) })
|
|
10196
|
+
}
|
|
10197
|
+
) }),
|
|
10198
|
+
/* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { children: "Copy result" })
|
|
10199
|
+
] })
|
|
10200
|
+
] }),
|
|
10201
|
+
footer: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10202
|
+
"button",
|
|
10203
|
+
{
|
|
10204
|
+
className: "w-full h-full text-center text-icon2 hover:text-icon6 text-ui-md",
|
|
10205
|
+
onClick: () => setExpanded((s) => !s),
|
|
10206
|
+
children: expanded ? "collapse" : "expand"
|
|
9659
10207
|
}
|
|
9660
|
-
|
|
9661
|
-
|
|
9662
|
-
onNodesChange,
|
|
9663
|
-
fitView: true,
|
|
9664
|
-
fitViewOptions: {
|
|
9665
|
-
maxZoom: 1
|
|
9666
|
-
},
|
|
9667
|
-
minZoom: 0.01,
|
|
9668
|
-
maxZoom: 1,
|
|
9669
|
-
children: [
|
|
9670
|
-
/* @__PURE__ */ jsxRuntime.jsx(ZoomSlider, { position: "bottom-left" }),
|
|
9671
|
-
/* @__PURE__ */ jsxRuntime.jsx(react$2.MiniMap, { pannable: true, zoomable: true, maskColor: "#121212", bgColor: "#171717", nodeColor: "#2c2c2c" }),
|
|
9672
|
-
/* @__PURE__ */ jsxRuntime.jsx(react$2.Background, { variant: react$2.BackgroundVariant.Dots, gap: 12, size: 0.5 })
|
|
9673
|
-
]
|
|
10208
|
+
),
|
|
10209
|
+
children: expanded ? /* @__PURE__ */ jsxRuntime.jsx(CodeBlockDemo, { className: "w-full overflow-x-auto", code: sanitizedJsonResult || jsonResult, language: "json" }) : null
|
|
9674
10210
|
}
|
|
9675
|
-
)
|
|
9676
|
-
}
|
|
10211
|
+
);
|
|
10212
|
+
};
|
|
9677
10213
|
|
|
9678
|
-
function
|
|
9679
|
-
|
|
10214
|
+
function LegacyWorkflowTrigger({
|
|
10215
|
+
workflowId,
|
|
10216
|
+
setRunId
|
|
10217
|
+
}) {
|
|
10218
|
+
const { legacyResult: result, setLegacyResult: setResult, payload, setPayload } = React.useContext(WorkflowRunContext);
|
|
10219
|
+
const { isLoading, legacyWorkflow: workflow } = useLegacyWorkflow(workflowId);
|
|
10220
|
+
const { createLegacyWorkflowRun: createWorkflowRun, startLegacyWorkflowRun: startWorkflowRun } = useExecuteWorkflow();
|
|
10221
|
+
const {
|
|
10222
|
+
watchLegacyWorkflow: watchWorkflow,
|
|
10223
|
+
legacyWatchResult: watchResult,
|
|
10224
|
+
isWatchingLegacyWorkflow: isWatchingWorkflow
|
|
10225
|
+
} = useWatchWorkflow();
|
|
10226
|
+
const { resumeLegacyWorkflow: resumeWorkflow, isResumingLegacyWorkflow: isResumingWorkflow } = useResumeWorkflow();
|
|
10227
|
+
const [suspendedSteps, setSuspendedSteps] = React.useState([]);
|
|
10228
|
+
const [isRunning, setIsRunning] = React.useState(false);
|
|
10229
|
+
const triggerSchema = workflow?.triggerSchema;
|
|
10230
|
+
const handleExecuteWorkflow = async (data) => {
|
|
10231
|
+
try {
|
|
10232
|
+
if (!workflow) return;
|
|
10233
|
+
setIsRunning(true);
|
|
10234
|
+
setResult(null);
|
|
10235
|
+
const { runId } = await createWorkflowRun({ workflowId });
|
|
10236
|
+
setRunId?.(runId);
|
|
10237
|
+
watchWorkflow({ workflowId, runId });
|
|
10238
|
+
startWorkflowRun({ workflowId, runId, input: data });
|
|
10239
|
+
} catch (err) {
|
|
10240
|
+
setIsRunning(false);
|
|
10241
|
+
sonner.toast.error("Error executing workflow");
|
|
10242
|
+
}
|
|
10243
|
+
};
|
|
10244
|
+
const handleResumeWorkflow = async (step) => {
|
|
10245
|
+
if (!workflow) return;
|
|
10246
|
+
const { stepId, runId: prevRunId, context } = step;
|
|
10247
|
+
const { runId } = await createWorkflowRun({ workflowId, prevRunId });
|
|
10248
|
+
watchWorkflow({ workflowId, runId });
|
|
10249
|
+
await resumeWorkflow({
|
|
10250
|
+
stepId,
|
|
10251
|
+
runId,
|
|
10252
|
+
context,
|
|
10253
|
+
workflowId
|
|
10254
|
+
});
|
|
10255
|
+
};
|
|
10256
|
+
const watchResultToUse = result ?? watchResult;
|
|
10257
|
+
const workflowActivePaths = watchResultToUse?.activePaths ?? {};
|
|
10258
|
+
React.useEffect(() => {
|
|
10259
|
+
setIsRunning(isWatchingWorkflow);
|
|
10260
|
+
}, [isWatchingWorkflow]);
|
|
10261
|
+
React.useEffect(() => {
|
|
10262
|
+
if (!watchResultToUse?.activePaths || !result?.runId) return;
|
|
10263
|
+
const suspended = Object.entries(watchResultToUse.activePaths).filter(([_, { status }]) => status === "suspended").map(([stepId, { suspendPayload }]) => ({
|
|
10264
|
+
stepId,
|
|
10265
|
+
runId: result.runId,
|
|
10266
|
+
suspendPayload
|
|
10267
|
+
}));
|
|
10268
|
+
setSuspendedSteps(suspended);
|
|
10269
|
+
}, [watchResultToUse, result]);
|
|
10270
|
+
React.useEffect(() => {
|
|
10271
|
+
if (watchResult) {
|
|
10272
|
+
setResult(watchResult);
|
|
10273
|
+
}
|
|
10274
|
+
}, [watchResult]);
|
|
9680
10275
|
if (isLoading) {
|
|
9681
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
9682
|
-
|
|
9683
|
-
|
|
9684
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid h-full place-items-center", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-2", children: [
|
|
9685
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircleIcon, {}),
|
|
9686
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
9687
|
-
"We couldn't find ",
|
|
9688
|
-
lodashTitleCase(workflowId),
|
|
9689
|
-
" workflow."
|
|
9690
|
-
] })
|
|
10276
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ScrollArea, { className: "h-[calc(100vh-126px)] pt-2 px-4 pb-4 text-xs", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
|
|
10277
|
+
/* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-10" }),
|
|
10278
|
+
/* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-10" })
|
|
9691
10279
|
] }) });
|
|
9692
10280
|
}
|
|
9693
|
-
|
|
9694
|
-
|
|
9695
|
-
|
|
9696
|
-
|
|
9697
|
-
|
|
9698
|
-
|
|
9699
|
-
|
|
10281
|
+
if (!workflow) return null;
|
|
10282
|
+
const isSuspendedSteps = suspendedSteps.length > 0;
|
|
10283
|
+
const zodInputSchema = triggerSchema ? resolveSerializedZodOutput(jsonSchemaToZod(superjson.parse(triggerSchema))) : null;
|
|
10284
|
+
const { sanitizedOutput, ...restResult } = result ?? {};
|
|
10285
|
+
const hasWorkflowActivePaths = Object.values(workflowActivePaths).length > 0;
|
|
10286
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full px-5 pt-3 pb-12", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
|
|
10287
|
+
isResumingWorkflow && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "py-2 px-5 flex items-center gap-2 bg-surface5 -mx-5 -mt-5 border-b-sm border-border1", children: [
|
|
10288
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "animate-spin text-icon6" }) }),
|
|
10289
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { children: "Resuming workflow" })
|
|
10290
|
+
] }),
|
|
10291
|
+
!isSuspendedSteps && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: zodInputSchema ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
10292
|
+
DynamicForm,
|
|
10293
|
+
{
|
|
10294
|
+
schema: zodInputSchema,
|
|
10295
|
+
defaultValues: payload,
|
|
10296
|
+
isSubmitLoading: isWatchingWorkflow,
|
|
10297
|
+
submitButtonLabel: "Run",
|
|
10298
|
+
onSubmit: (data) => {
|
|
10299
|
+
setPayload(data);
|
|
10300
|
+
handleExecuteWorkflow(data);
|
|
10301
|
+
}
|
|
10302
|
+
}
|
|
10303
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
10304
|
+
Button,
|
|
10305
|
+
{
|
|
10306
|
+
className: "w-full",
|
|
10307
|
+
variant: "light",
|
|
10308
|
+
disabled: isRunning,
|
|
10309
|
+
onClick: () => handleExecuteWorkflow(null),
|
|
10310
|
+
children: isRunning ? /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "animate-spin" }) }) : "Trigger"
|
|
10311
|
+
}
|
|
10312
|
+
) }),
|
|
10313
|
+
isSuspendedSteps && suspendedSteps?.map((step) => {
|
|
10314
|
+
const stepDefinition = workflow.steps[step.stepId];
|
|
10315
|
+
const stepSchema = stepDefinition?.inputSchema ? resolveSerializedZodOutput(jsonSchemaToZod(superjson.parse(stepDefinition.inputSchema))) : z.z.record(z.z.string(), z.z.any());
|
|
10316
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col px-4", children: [
|
|
10317
|
+
/* @__PURE__ */ jsxRuntime.jsx(Text, { variant: "secondary", className: "text-mastra-el-3", size: "xs", children: step.stepId }),
|
|
10318
|
+
step.suspendPayload && /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10319
|
+
CodeBlockDemo,
|
|
10320
|
+
{
|
|
10321
|
+
className: "w-full overflow-x-auto p-2",
|
|
10322
|
+
code: JSON.stringify(step.suspendPayload, null, 2),
|
|
10323
|
+
language: "json"
|
|
10324
|
+
}
|
|
10325
|
+
) }),
|
|
10326
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10327
|
+
DynamicForm,
|
|
10328
|
+
{
|
|
10329
|
+
schema: stepSchema,
|
|
10330
|
+
isSubmitLoading: isResumingWorkflow,
|
|
10331
|
+
submitButtonLabel: "Resume",
|
|
10332
|
+
onSubmit: (data) => {
|
|
10333
|
+
handleResumeWorkflow({
|
|
10334
|
+
stepId: step.stepId,
|
|
10335
|
+
runId: step.runId,
|
|
10336
|
+
suspendPayload: step.suspendPayload,
|
|
10337
|
+
context: data
|
|
10338
|
+
});
|
|
10339
|
+
}
|
|
10340
|
+
}
|
|
10341
|
+
)
|
|
10342
|
+
] });
|
|
10343
|
+
}),
|
|
10344
|
+
hasWorkflowActivePaths && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
10345
|
+
/* @__PURE__ */ jsxRuntime.jsx("hr", { className: "border-border1 border-sm my-5" }),
|
|
10346
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-4", children: Object.entries(workflowActivePaths)?.map(([stepId, { status: pathStatus, stepPath }]) => {
|
|
10347
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-1", children: stepPath?.map((path, idx) => {
|
|
10348
|
+
return /* @__PURE__ */ jsxRuntime.jsx(LegacyWorkflowStatus, { stepId, pathStatus, path }, idx);
|
|
10349
|
+
}) }, stepId);
|
|
10350
|
+
}) })
|
|
10351
|
+
] }),
|
|
10352
|
+
result && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
10353
|
+
/* @__PURE__ */ jsxRuntime.jsx("hr", { className: "border-border1 border-sm my-5" }),
|
|
10354
|
+
/* @__PURE__ */ jsxRuntime.jsx(WorkflowResult, { sanitizedJsonResult: sanitizedOutput, jsonResult: JSON.stringify(restResult, null, 2) })
|
|
10355
|
+
] })
|
|
10356
|
+
] }) });
|
|
9700
10357
|
}
|
|
9701
10358
|
|
|
9702
10359
|
function WorkflowTrigger({
|
|
@@ -10424,6 +11081,7 @@ exports.TsIcon = TsIcon;
|
|
|
10424
11081
|
exports.Txt = Txt;
|
|
10425
11082
|
exports.TxtCell = TxtCell;
|
|
10426
11083
|
exports.UnitCell = UnitCell;
|
|
11084
|
+
exports.VNextNetworkChat = VNextNetworkChat;
|
|
10427
11085
|
exports.VariablesIcon = VariablesIcon;
|
|
10428
11086
|
exports.WorkflowCoinIcon = WorkflowCoinIcon;
|
|
10429
11087
|
exports.WorkflowGraph = WorkflowGraph;
|