@mastra/playground-ui 5.0.4 → 5.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +635 -385
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.css +2 -2
- package/dist/index.es.js +630 -385
- package/dist/index.es.js.map +1 -1
- package/dist/src/components/assistant-ui/image-with-fallback.d.ts +3 -0
- package/dist/src/components/assistant-ui/thread.d.ts +2 -1
- package/dist/src/components/ui/data-table.d.ts +2 -1
- package/dist/src/domains/agents/agent/context/agent-context.d.ts +4 -3
- package/dist/src/domains/traces/types.d.ts +9 -4
- package/dist/src/domains/traces/utils/createSpanTree.d.ts +3 -0
- package/dist/src/domains/workflows/context/legacy-workflow-nested-graph-context.d.ts +13 -0
- package/dist/src/domains/workflows/context/workflow-nested-graph-context.d.ts +4 -3
- package/dist/src/domains/workflows/context/workflow-run-context.d.ts +4 -4
- package/dist/src/domains/workflows/index.d.ts +3 -3
- package/dist/src/domains/workflows/workflow/legacy-workflow-graph-inner.d.ts +5 -0
- package/dist/src/domains/workflows/workflow/{v-next-workflow-graph.d.ts → legacy-workflow-graph.d.ts} +1 -1
- package/dist/src/domains/workflows/workflow/legacy-workflow-nested-graph.d.ts +6 -0
- package/dist/src/domains/workflows/workflow/legacy-workflow-nested-node.d.ts +12 -0
- package/dist/src/domains/workflows/workflow/legacy-workflow-status.d.ts +6 -0
- package/dist/src/domains/workflows/workflow/{v-next-workflow-trigger.d.ts → legacy-workflow-trigger.d.ts} +1 -1
- package/dist/src/domains/workflows/workflow/utils.d.ts +5 -5
- package/dist/src/domains/workflows/workflow/workflow-card.d.ts +6 -0
- package/dist/src/domains/workflows/workflow/workflow-graph-inner.d.ts +2 -2
- package/dist/src/domains/workflows/workflow/workflow-nested-graph.d.ts +3 -3
- package/dist/src/domains/workflows/workflow/workflow-nested-node.d.ts +2 -2
- package/dist/src/domains/workflows/workflow/workflow-result.d.ts +5 -0
- package/dist/src/domains/workflows/workflow/workflow-status.d.ts +5 -0
- package/dist/src/ds/components/Entity/Entity.d.ts +10 -0
- package/dist/src/ds/components/Entity/index.d.ts +1 -0
- package/dist/src/ds/components/TraceTree/Span.d.ts +3 -1
- package/dist/src/ds/components/TraceTree/Time.d.ts +2 -1
- package/dist/src/ds/components/TraceTree/Trace.d.ts +2 -1
- package/dist/src/ds/icons/Icon.d.ts +1 -1
- package/dist/src/ds/tokens/sizes.d.ts +1 -0
- package/dist/src/hooks/use-workflows.d.ts +24 -24
- package/dist/src/index.d.ts +1 -0
- package/dist/src/store/agent-store.d.ts +20 -0
- package/dist/src/types.d.ts +1 -4
- package/dist/tokens.cjs.js +1 -0
- package/dist/tokens.cjs.js.map +1 -1
- package/dist/tokens.es.js +1 -0
- package/dist/tokens.es.js.map +1 -1
- package/package.json +6 -5
- package/dist/src/domains/workflows/context/v-next-workflow-nested-graph-context.d.ts +0 -14
- package/dist/src/domains/workflows/workflow/v-next-workflow-graph-inner.d.ts +0 -5
- package/dist/src/domains/workflows/workflow/v-next-workflow-nested-graph.d.ts +0 -6
- package/dist/src/domains/workflows/workflow/v-next-workflow-nested-node.d.ts +0 -11
- package/dist/src/ds/components/TraceTree/Trace.context.d.ts +0 -9
package/dist/index.es.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { useMessage, MessagePrimitive, ActionBarPrimitive, ThreadPrimitive, ComposerPrimitive, useExternalStoreRuntime, AssistantRuntimeProvider } from '@assistant-ui/react';
|
|
3
|
-
import { CheckIcon as CheckIcon$1, CopyIcon, ChevronUpIcon, ArrowUp, Copy, Search, RefreshCcwIcon, ChevronRight, SortAsc, SortDesc, X, Check, ChevronUp, ChevronDown, LoaderCircle, ChevronDownIcon, ExternalLinkIcon, Footprints, CircleCheck, CircleX, Workflow, AlertCircleIcon, AlertCircle, CalendarIcon, PlusIcon, TrashIcon, Plus, Loader2 } from 'lucide-react';
|
|
3
|
+
import { CheckIcon as CheckIcon$1, CopyIcon, ChevronUpIcon, ArrowUp, Copy, Search, RefreshCcwIcon, ChevronRight, SortAsc, SortDesc, X, Check, ChevronUp, ChevronDown, LoaderCircle, ChevronDownIcon, ExternalLinkIcon, Footprints, CircleCheck, CircleX, Workflow, AlertCircleIcon, AlertCircle, CalendarIcon, Braces, Brackets, PlusIcon, TrashIcon, Plus, Loader2, CirclePause } from 'lucide-react';
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
import React__default, { forwardRef,
|
|
5
|
+
import React__default, { forwardRef, useState, useEffect, memo, useMemo, useRef, createContext, useContext, useCallback, Suspense, Fragment as Fragment$1 } from 'react';
|
|
6
6
|
import { Slot } from '@radix-ui/react-slot';
|
|
7
7
|
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
8
8
|
import * as AvatarPrimitive from '@radix-ui/react-avatar';
|
|
@@ -38,13 +38,13 @@ import jsonSchemaToZod from 'json-schema-to-zod';
|
|
|
38
38
|
import { parse } from 'superjson';
|
|
39
39
|
import z$1, { z, ZodObject } from 'zod';
|
|
40
40
|
import { AutoForm as AutoForm$1, buildZodFieldConfig } from '@autoform/react';
|
|
41
|
-
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
42
41
|
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
43
42
|
import { DayPicker } from 'react-day-picker';
|
|
44
43
|
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
45
44
|
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
46
45
|
import { v4 } from '@lukeed/uuid';
|
|
47
46
|
import { ZodProvider, getFieldConfigInZodStack, getDefaultValueInZodStack } from '@autoform/zod';
|
|
47
|
+
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
48
48
|
import { CodeBlock as CodeBlock$1 } from 'react-code-block';
|
|
49
49
|
import { useReactTable, getCoreRowModel, flexRender } from '@tanstack/react-table';
|
|
50
50
|
|
|
@@ -2890,6 +2890,46 @@ const AvatarFallback = React.forwardRef(({ className, ...props }, ref) => /* @__
|
|
|
2890
2890
|
));
|
|
2891
2891
|
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
|
|
2892
2892
|
|
|
2893
|
+
const ImageWithFallback = ({ alt, src, ...rest }) => {
|
|
2894
|
+
const [error, setError] = useState(false);
|
|
2895
|
+
useEffect(() => {
|
|
2896
|
+
setError(false);
|
|
2897
|
+
}, [src]);
|
|
2898
|
+
return error || !src ? /* @__PURE__ */ jsxs("div", { children: [
|
|
2899
|
+
/* @__PURE__ */ jsx(
|
|
2900
|
+
"svg",
|
|
2901
|
+
{
|
|
2902
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2903
|
+
fill: "none",
|
|
2904
|
+
viewBox: "0 0 24 24",
|
|
2905
|
+
strokeWidth: "1.5",
|
|
2906
|
+
stroke: "currentColor",
|
|
2907
|
+
width: "150",
|
|
2908
|
+
height: "150",
|
|
2909
|
+
children: /* @__PURE__ */ jsx(
|
|
2910
|
+
"path",
|
|
2911
|
+
{
|
|
2912
|
+
strokeLinecap: "round",
|
|
2913
|
+
strokeLinejoin: "round",
|
|
2914
|
+
d: "m2.25 15.75 5.159-5.159a2.25 2.25 0 0 1 3.182 0l5.159 5.159m-1.5-1.5 1.409-1.409a2.25 2.25 0 0 1 3.182 0l2.909 2.909m-18 3.75h16.5a1.5 1.5 0 0 0 1.5-1.5V6a1.5 1.5 0 0 0-1.5-1.5H3.75A1.5 1.5 0 0 0 2.25 6v12a1.5 1.5 0 0 0 1.5 1.5Zm10.5-11.25h.008v.008h-.008V8.25Zm.375 0a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0Z"
|
|
2915
|
+
}
|
|
2916
|
+
)
|
|
2917
|
+
}
|
|
2918
|
+
),
|
|
2919
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs italic text-muted-foreground -mt-[0.625rem] mb-[0.625rem]", children: "Image link is broken" })
|
|
2920
|
+
] }) : /* @__PURE__ */ jsx(
|
|
2921
|
+
"img",
|
|
2922
|
+
{
|
|
2923
|
+
src,
|
|
2924
|
+
alt,
|
|
2925
|
+
...rest,
|
|
2926
|
+
onError: () => {
|
|
2927
|
+
setError(true);
|
|
2928
|
+
}
|
|
2929
|
+
}
|
|
2930
|
+
);
|
|
2931
|
+
};
|
|
2932
|
+
|
|
2893
2933
|
const SyntaxHighlighter$2 = makePrismAsyncSyntaxHighlighter({
|
|
2894
2934
|
style: coldarkDark,
|
|
2895
2935
|
customStyle: {
|
|
@@ -3109,10 +3149,12 @@ const defaultComponents = unstable_memoizeMarkdownComponents({
|
|
|
3109
3149
|
);
|
|
3110
3150
|
},
|
|
3111
3151
|
CodeHeader,
|
|
3112
|
-
SyntaxHighlighter: SyntaxHighlighter$2
|
|
3152
|
+
SyntaxHighlighter: SyntaxHighlighter$2,
|
|
3153
|
+
img: ImageWithFallback
|
|
3113
3154
|
});
|
|
3114
3155
|
|
|
3115
3156
|
const sizes = {
|
|
3157
|
+
sm: "[&>svg]:h-icon-sm [&>svg]:w-icon-sm",
|
|
3116
3158
|
default: "[&>svg]:h-icon-default [&>svg]:w-icon-default",
|
|
3117
3159
|
lg: "[&>svg]:h-icon-lg [&>svg]:w-icon-lg"
|
|
3118
3160
|
};
|
|
@@ -3491,10 +3533,10 @@ const GithubIcon = (props) => /* @__PURE__ */ jsxs("svg", { width: "15", height:
|
|
|
3491
3533
|
"path",
|
|
3492
3534
|
{
|
|
3493
3535
|
d: "M7.5 0.75C3.6325 0.75 0.5 3.8825 0.5 7.75C0.5 10.8475 2.50375 13.4637 5.28625 14.3912C5.63625 14.4525 5.7675 14.2425 5.7675 14.0587C5.7675 13.8925 5.75875 13.3412 5.75875 12.755C4 13.0787 3.545 12.3262 3.405 11.9325C3.32625 11.7312 2.985 11.11 2.6875 10.9437C2.4425 10.8125 2.0925 10.4887 2.67875 10.48C3.23 10.4712 3.62375 10.9875 3.755 11.1975C4.385 12.2562 5.39125 11.9587 5.79375 11.775C5.855 11.32 6.03875 11.0137 6.24 10.8387C4.6825 10.6637 3.055 10.06 3.055 7.3825C3.055 6.62125 3.32625 5.99125 3.7725 5.50125C3.7025 5.32625 3.4575 4.60875 3.8425 3.64625C3.8425 3.64625 4.42875 3.4625 5.7675 4.36375C6.3275 4.20625 6.9225 4.1275 7.5175 4.1275C8.1125 4.1275 8.7075 4.20625 9.2675 4.36375C10.6062 3.45375 11.1925 3.64625 11.1925 3.64625C11.5775 4.60875 11.3325 5.32625 11.2625 5.50125C11.7087 5.99125 11.98 6.6125 11.98 7.3825C11.98 10.0687 10.3438 10.6637 8.78625 10.8387C9.04 11.0575 9.25875 11.4775 9.25875 12.1337C9.25875 13.07 9.25 13.8225 9.25 14.0587C9.25 14.2425 9.38125 14.4612 9.73125 14.3912C11.1209 13.9221 12.3284 13.029 13.1839 11.8377C14.0393 10.6463 14.4996 9.21668 14.5 7.75C14.5 3.8825 11.3675 0.75 7.5 0.75Z",
|
|
3494
|
-
fill: "
|
|
3536
|
+
fill: "currentColor"
|
|
3495
3537
|
}
|
|
3496
3538
|
) }),
|
|
3497
|
-
/* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx("clipPath", { id: "clip0_21999_22095", children: /* @__PURE__ */ jsx("rect", { width: "14", height: "14", fill: "
|
|
3539
|
+
/* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx("clipPath", { id: "clip0_21999_22095", children: /* @__PURE__ */ jsx("rect", { width: "14", height: "14", fill: "currentColor", transform: "translate(0.5 0.75)" }) }) })
|
|
3498
3540
|
] });
|
|
3499
3541
|
|
|
3500
3542
|
const GoogleIcon = (props) => /* @__PURE__ */ jsxs("svg", { width: "15", height: "15", viewBox: "0 0 15 15", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: [
|
|
@@ -3723,7 +3765,7 @@ const WorkflowIcon = (props) => /* @__PURE__ */ jsx("svg", { width: "17", height
|
|
|
3723
3765
|
fillRule: "evenodd",
|
|
3724
3766
|
clipRule: "evenodd",
|
|
3725
3767
|
d: "M6.24388 2.4018C6.24388 2.0394 6.53767 1.74561 6.90008 1.74561H10.0991C10.4614 1.74561 10.7553 2.0394 10.7553 2.4018V4.57546C10.7553 4.93787 10.4614 5.23166 10.0991 5.23166H9.31982V7.35469L10.0033 9.22664C9.90442 9.20146 9.80035 9.1761 9.6915 9.14986L9.62652 9.13422C9.30473 9.05687 8.92256 8.96501 8.61993 8.84491C8.5819 8.82981 8.54147 8.81292 8.49957 8.79391C8.45767 8.81292 8.41724 8.82981 8.3792 8.84491C8.07657 8.96501 7.6944 9.05687 7.37261 9.13422L7.30763 9.14986C7.19879 9.1761 7.09471 9.20146 6.99577 9.22664L7.67932 7.35469V5.23166H6.90008C6.53767 5.23166 6.24388 4.93787 6.24388 4.57546V2.4018ZM6.99577 9.22664C6.99577 9.22664 6.99578 9.22664 6.99577 9.22664L6.43283 10.7683H6.81806C7.18047 10.7683 7.47426 11.0622 7.47426 11.4245V13.5982C7.47426 13.9606 7.18047 14.2544 6.81806 14.2544H3.61909C3.25668 14.2544 2.96289 13.9606 2.96289 13.5982V11.4245C2.96289 11.0622 3.25668 10.7683 3.61909 10.7683H4.26617C4.2921 10.4663 4.32783 10.1494 4.37744 9.85171C4.43762 9.49063 4.52982 9.08135 4.68998 8.76102C4.93975 8.2615 5.44743 8.01751 5.7771 7.88788C6.14684 7.74249 6.57537 7.63889 6.92317 7.55505C7.24707 7.47696 7.49576 7.41679 7.67932 7.35469L6.99577 9.22664ZM6.43283 10.7683L6.99577 9.22664C6.75846 9.28705 6.55067 9.34646 6.37745 9.41458C6.22784 9.47341 6.1623 9.51712 6.14023 9.53254C6.09752 9.63631 6.04409 9.83055 5.99562 10.1214C5.96201 10.3231 5.93498 10.5439 5.91341 10.7683H6.43283ZM10.0033 9.22664L9.31982 7.35469C9.50338 7.41679 9.75206 7.47696 10.076 7.55505C10.4238 7.63889 10.8523 7.74249 11.2221 7.88788C11.5517 8.01751 12.0594 8.2615 12.3091 8.76102C12.4693 9.08135 12.5615 9.49063 12.6217 9.85171C12.6713 10.1494 12.707 10.4663 12.733 10.7683H13.38C13.7424 10.7683 14.0362 11.0622 14.0362 11.4245V13.5982C14.0362 13.9606 13.7424 14.2544 13.38 14.2544H10.1811C9.81867 14.2544 9.52488 13.9606 9.52488 13.5982V11.4245C9.52488 11.0622 9.81867 10.7683 10.1811 10.7683H10.5663L10.0033 9.22664ZM10.0033 9.22664L10.5663 10.7683H11.0857C11.0642 10.5439 11.0372 10.3231 11.0035 10.1214C10.9551 9.83055 10.9016 9.63631 10.8589 9.53254C10.8369 9.51712 10.7713 9.47341 10.6217 9.41458C10.4485 9.34646 10.2407 9.28705 10.0033 9.22664Z",
|
|
3726
|
-
fill: "
|
|
3768
|
+
fill: "currentColor"
|
|
3727
3769
|
}
|
|
3728
3770
|
) });
|
|
3729
3771
|
|
|
@@ -3856,7 +3898,10 @@ const AssistantMessage = ({
|
|
|
3856
3898
|
/* @__PURE__ */ jsx("div", { className: "text-icon6 text-ui-lg leading-ui-lg", children: /* @__PURE__ */ jsx(
|
|
3857
3899
|
MessagePrimitive.Content,
|
|
3858
3900
|
{
|
|
3859
|
-
components: {
|
|
3901
|
+
components: {
|
|
3902
|
+
Text: MarkdownText,
|
|
3903
|
+
tools: { Fallback: ToolFallbackCustom || ToolFallback$1 }
|
|
3904
|
+
}
|
|
3860
3905
|
}
|
|
3861
3906
|
) }),
|
|
3862
3907
|
/* @__PURE__ */ jsx("div", { className: "h-6 pt-1", children: !isSolelyToolCall && /* @__PURE__ */ jsx(AssistantActionBar, {}) })
|
|
@@ -3920,13 +3965,27 @@ const useAutoscroll = (ref, { enabled = true }) => {
|
|
|
3920
3965
|
}, [enabled, ref]);
|
|
3921
3966
|
};
|
|
3922
3967
|
|
|
3923
|
-
const
|
|
3968
|
+
const variants = {
|
|
3969
|
+
"header-md": "text-header-md leading-header-md",
|
|
3970
|
+
"ui-lg": "text-ui-lg leading-ui-lg",
|
|
3971
|
+
"ui-md": "text-ui-md leading-ui-md",
|
|
3972
|
+
"ui-sm": "text-ui-sm leading-ui-sm",
|
|
3973
|
+
"ui-xs": "text-ui-xs leading-ui-xs"
|
|
3974
|
+
};
|
|
3975
|
+
const fonts = {
|
|
3976
|
+
mono: "font-mono"
|
|
3977
|
+
};
|
|
3978
|
+
const Txt = ({ as: Root = "p", className, variant = "ui-md", font, ...props }) => {
|
|
3979
|
+
return /* @__PURE__ */ jsx(Root, { className: clsx(variants[variant], font && fonts[font], className), ...props });
|
|
3980
|
+
};
|
|
3981
|
+
|
|
3982
|
+
const Thread = ({ ToolFallback, agentName, hasMemory }) => {
|
|
3924
3983
|
const areaRef = useRef(null);
|
|
3925
3984
|
useAutoscroll(areaRef, { enabled: true });
|
|
3926
3985
|
const WrappedAssistantMessage = (props) => {
|
|
3927
3986
|
return /* @__PURE__ */ jsx(AssistantMessage, { ...props, ToolFallback });
|
|
3928
3987
|
};
|
|
3929
|
-
return /* @__PURE__ */ jsxs(ThreadPrimitive.Root, { className: "max-w-[568px] w-full mx-auto h-[calc(100%-
|
|
3988
|
+
return /* @__PURE__ */ jsxs(ThreadPrimitive.Root, { className: "max-w-[568px] w-full mx-auto h-[calc(100%-110px)] px-4", children: [
|
|
3930
3989
|
/* @__PURE__ */ jsxs(ThreadPrimitive.Viewport, { className: "py-10 overflow-y-auto scroll-smooth h-full", ref: areaRef, autoScroll: false, children: [
|
|
3931
3990
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
3932
3991
|
/* @__PURE__ */ jsx(ThreadWelcome, { agentName }),
|
|
@@ -3943,7 +4002,7 @@ const Thread = ({ ToolFallback, agentName }) => {
|
|
|
3943
4002
|
] }),
|
|
3944
4003
|
/* @__PURE__ */ jsx(ThreadPrimitive.If, { empty: false, children: /* @__PURE__ */ jsx("div", {}) })
|
|
3945
4004
|
] }),
|
|
3946
|
-
/* @__PURE__ */ jsx(Composer, {})
|
|
4005
|
+
/* @__PURE__ */ jsx(Composer, { hasMemory })
|
|
3947
4006
|
] });
|
|
3948
4007
|
};
|
|
3949
4008
|
const ThreadWelcome = ({ agentName }) => {
|
|
@@ -3962,19 +4021,25 @@ const ThreadWelcome = ({ agentName }) => {
|
|
|
3962
4021
|
/* @__PURE__ */ jsx("p", { className: "mt-4 font-medium", children: "How can I help you today?" })
|
|
3963
4022
|
] }) });
|
|
3964
4023
|
};
|
|
3965
|
-
const Composer = () => {
|
|
3966
|
-
return /* @__PURE__ */ jsxs(
|
|
3967
|
-
/* @__PURE__ */
|
|
3968
|
-
"
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
4024
|
+
const Composer = ({ hasMemory }) => {
|
|
4025
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
4026
|
+
/* @__PURE__ */ jsxs(ComposerPrimitive.Root, { className: "w-full bg-surface3 rounded-lg border-sm border-border1 px-3 py-4 mt-auto h-[100px]", children: [
|
|
4027
|
+
/* @__PURE__ */ jsx(ComposerPrimitive.Input, { asChild: true, className: "w-full", children: /* @__PURE__ */ jsx(
|
|
4028
|
+
"textarea",
|
|
4029
|
+
{
|
|
4030
|
+
className: "text-ui-lg leading-ui-lg placeholder:text-icon3 text-icon6 bg-transparent focus:outline-none resize-none",
|
|
4031
|
+
autoFocus: true,
|
|
4032
|
+
placeholder: "Enter your message...",
|
|
4033
|
+
name: "",
|
|
4034
|
+
id: ""
|
|
4035
|
+
}
|
|
4036
|
+
) }),
|
|
4037
|
+
/* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx(ComposerAction, {}) })
|
|
4038
|
+
] }),
|
|
4039
|
+
!hasMemory && /* @__PURE__ */ jsxs(Txt, { variant: "ui-sm", className: "text-icon3 flex items-center gap-2 pt-0.5", children: [
|
|
4040
|
+
/* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(InfoIcon, {}) }),
|
|
4041
|
+
"Memory is not enabled. The conversation will not be persisted."
|
|
4042
|
+
] })
|
|
3978
4043
|
] });
|
|
3979
4044
|
};
|
|
3980
4045
|
const ComposerAction = () => {
|
|
@@ -4316,6 +4381,20 @@ function MastraRuntimeProvider({
|
|
|
4316
4381
|
] });
|
|
4317
4382
|
}
|
|
4318
4383
|
|
|
4384
|
+
const useAgentStore = create()(
|
|
4385
|
+
persist(
|
|
4386
|
+
(set) => ({
|
|
4387
|
+
modelSettings: {},
|
|
4388
|
+
setModelSettings: (modelSettings) => set((state) => ({ modelSettings: { ...state.modelSettings, ...modelSettings } })),
|
|
4389
|
+
chatWithGenerate: {},
|
|
4390
|
+
setChatWithGenerate: (chatWithGenerate) => set((state) => ({ chatWithGenerate: { ...state.chatWithGenerate, ...chatWithGenerate } }))
|
|
4391
|
+
}),
|
|
4392
|
+
{
|
|
4393
|
+
name: "mastra-agent-store"
|
|
4394
|
+
}
|
|
4395
|
+
)
|
|
4396
|
+
);
|
|
4397
|
+
|
|
4319
4398
|
const defaultModelSettings$1 = {
|
|
4320
4399
|
maxRetries: 2,
|
|
4321
4400
|
maxSteps: 5,
|
|
@@ -4323,12 +4402,24 @@ const defaultModelSettings$1 = {
|
|
|
4323
4402
|
topP: 1
|
|
4324
4403
|
};
|
|
4325
4404
|
const AgentContext = createContext({});
|
|
4326
|
-
function AgentProvider({ children }) {
|
|
4327
|
-
const
|
|
4328
|
-
|
|
4405
|
+
function AgentProvider({ agentId, children }) {
|
|
4406
|
+
const {
|
|
4407
|
+
modelSettings: modelSettingsStore,
|
|
4408
|
+
setModelSettings: setModelSettingsStore,
|
|
4409
|
+
chatWithGenerate: chatWithGenerateStore,
|
|
4410
|
+
setChatWithGenerate: setChatWithGenerateStore
|
|
4411
|
+
} = useAgentStore();
|
|
4412
|
+
const modelSettings = modelSettingsStore[agentId] || defaultModelSettings$1;
|
|
4413
|
+
const setModelSettings = (modelSettings2) => {
|
|
4414
|
+
setModelSettingsStore({ [agentId]: modelSettings2 });
|
|
4415
|
+
};
|
|
4329
4416
|
const resetModelSettings = () => {
|
|
4330
4417
|
setModelSettings(defaultModelSettings$1);
|
|
4331
4418
|
};
|
|
4419
|
+
const chatWithGenerate = chatWithGenerateStore[agentId] || false;
|
|
4420
|
+
const setChatWithGenerate = (chatWithGenerate2) => {
|
|
4421
|
+
setChatWithGenerateStore({ [agentId]: chatWithGenerate2 });
|
|
4422
|
+
};
|
|
4332
4423
|
return /* @__PURE__ */ jsx(
|
|
4333
4424
|
AgentContext.Provider,
|
|
4334
4425
|
{
|
|
@@ -4380,7 +4471,7 @@ const AgentChat = ({
|
|
|
4380
4471
|
modelSettings,
|
|
4381
4472
|
chatWithGenerate,
|
|
4382
4473
|
runtimeContext,
|
|
4383
|
-
children: /* @__PURE__ */ jsx("div", { className: "h-full pb-4", children: /* @__PURE__ */ jsx(Thread, { agentName: agentName ?? "" }) })
|
|
4474
|
+
children: /* @__PURE__ */ jsx("div", { className: "h-full pb-4 bg-surface1", children: /* @__PURE__ */ jsx(Thread, { agentName: agentName ?? "", hasMemory: memory }) })
|
|
4384
4475
|
}
|
|
4385
4476
|
);
|
|
4386
4477
|
};
|
|
@@ -4440,18 +4531,18 @@ function FormattedDate({ date }) {
|
|
|
4440
4531
|
}
|
|
4441
4532
|
|
|
4442
4533
|
const inputVariants = cva(
|
|
4443
|
-
"flex w-full text-
|
|
4534
|
+
"flex w-full text-icon6 rounded-lg border bg-transparent shadow-sm focus-visible:ring-ring transition-colors focus-visible:outline-none focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50",
|
|
4444
4535
|
{
|
|
4445
4536
|
variants: {
|
|
4446
4537
|
variant: {
|
|
4447
|
-
default: "border-
|
|
4448
|
-
filled: "bg-inputFill border-
|
|
4449
|
-
unstyled: "border-0 bg-transparent placeholder:text-
|
|
4538
|
+
default: "border-sm border-border1 placeholder:text-icon3",
|
|
4539
|
+
filled: "border-sm bg-inputFill border-border1 placeholder:text-icon3",
|
|
4540
|
+
unstyled: "border-0 bg-transparent placeholder:text-icon3 focus-visible:ring-transparent focus-visible:outline-none"
|
|
4450
4541
|
},
|
|
4451
4542
|
customSize: {
|
|
4452
|
-
default: "px-[13px] text-[calc(13_/_16_*_1rem)] h-
|
|
4543
|
+
default: "px-[13px] text-[calc(13_/_16_*_1rem)] h-8",
|
|
4453
4544
|
sm: "h-[30px] px-[13px] text-xs",
|
|
4454
|
-
lg: "h-10 px-[17px]
|
|
4545
|
+
lg: "h-10 px-[17px] text-[calc(13_/_16_*_1rem)]"
|
|
4455
4546
|
}
|
|
4456
4547
|
},
|
|
4457
4548
|
defaultVariants: {
|
|
@@ -4930,20 +5021,6 @@ const Row = ({ className, children, selected = false, onClick }) => {
|
|
|
4930
5021
|
);
|
|
4931
5022
|
};
|
|
4932
5023
|
|
|
4933
|
-
const variants = {
|
|
4934
|
-
"header-md": "text-header-md leading-header-md",
|
|
4935
|
-
"ui-lg": "text-ui-lg leading-ui-lg",
|
|
4936
|
-
"ui-md": "text-ui-md leading-ui-md",
|
|
4937
|
-
"ui-sm": "text-ui-sm leading-ui-sm",
|
|
4938
|
-
"ui-xs": "text-ui-xs leading-ui-xs"
|
|
4939
|
-
};
|
|
4940
|
-
const fonts = {
|
|
4941
|
-
mono: "font-mono"
|
|
4942
|
-
};
|
|
4943
|
-
const Txt = ({ as: Root = "p", className, variant = "ui-md", font, ...props }) => {
|
|
4944
|
-
return /* @__PURE__ */ jsx(Root, { className: clsx(variants[variant], font && fonts[font], className), ...props });
|
|
4945
|
-
};
|
|
4946
|
-
|
|
4947
5024
|
const formatDateCell = (date) => {
|
|
4948
5025
|
const month = new Intl.DateTimeFormat("en-US", { month: "short" }).format(date).toUpperCase();
|
|
4949
5026
|
const day = date.getDate();
|
|
@@ -5166,11 +5243,17 @@ const TraceTree = ({ children }) => {
|
|
|
5166
5243
|
const variantClasses = {
|
|
5167
5244
|
agent: "bg-accent1"
|
|
5168
5245
|
};
|
|
5169
|
-
const Time = ({ durationMs, tokenCount, variant, progressPercent }) => {
|
|
5246
|
+
const Time = ({ durationMs, tokenCount, variant, progressPercent, offsetPercent }) => {
|
|
5170
5247
|
const variantClass = variant ? variantClasses[variant] : "bg-accent3";
|
|
5171
5248
|
const percent = Math.min(100, progressPercent);
|
|
5172
5249
|
return /* @__PURE__ */ jsxs("div", { className: "w-[80px] xl:w-[166px] shrink-0", children: [
|
|
5173
|
-
/* @__PURE__ */ jsx("div", { className: "bg-surface4 relative h-[6px] w-full rounded-full p-px overflow-hidden", children: /* @__PURE__ */ jsx(
|
|
5250
|
+
/* @__PURE__ */ jsx("div", { className: "bg-surface4 relative h-[6px] w-full rounded-full p-px overflow-hidden", children: /* @__PURE__ */ jsx(
|
|
5251
|
+
"div",
|
|
5252
|
+
{
|
|
5253
|
+
className: clsx("absolute h-1 rounded-full", variantClass),
|
|
5254
|
+
style: { width: `${percent}%`, left: `${offsetPercent}%` }
|
|
5255
|
+
}
|
|
5256
|
+
) }),
|
|
5174
5257
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4 pt-0.5", children: [
|
|
5175
5258
|
/* @__PURE__ */ jsxs(Txt, { variant: "ui-sm", className: "text-icon2 font-medium", children: [
|
|
5176
5259
|
toSigFigs(durationMs, 3),
|
|
@@ -5184,14 +5267,6 @@ const Time = ({ durationMs, tokenCount, variant, progressPercent }) => {
|
|
|
5184
5267
|
] });
|
|
5185
5268
|
};
|
|
5186
5269
|
|
|
5187
|
-
const TraceDurationContext = createContext(0);
|
|
5188
|
-
const useTraceDuration = () => {
|
|
5189
|
-
return useContext(TraceDurationContext);
|
|
5190
|
-
};
|
|
5191
|
-
const TraceDurationProvider = ({ children, durationMs }) => {
|
|
5192
|
-
return /* @__PURE__ */ jsx(TraceDurationContext.Provider, { value: durationMs, children });
|
|
5193
|
-
};
|
|
5194
|
-
|
|
5195
5270
|
const spanIconMap = {
|
|
5196
5271
|
tool: ToolsIcon,
|
|
5197
5272
|
agent: AgentIcon,
|
|
@@ -5212,14 +5287,25 @@ const spanVariantClasses = {
|
|
|
5212
5287
|
eval: "text-accent4",
|
|
5213
5288
|
other: "text-icon6"
|
|
5214
5289
|
};
|
|
5215
|
-
const Span = ({
|
|
5290
|
+
const Span = ({
|
|
5291
|
+
children,
|
|
5292
|
+
durationMs,
|
|
5293
|
+
variant,
|
|
5294
|
+
tokenCount,
|
|
5295
|
+
spans,
|
|
5296
|
+
isRoot,
|
|
5297
|
+
onClick,
|
|
5298
|
+
isActive,
|
|
5299
|
+
offsetMs,
|
|
5300
|
+
totalDurationMs
|
|
5301
|
+
}) => {
|
|
5216
5302
|
const [isExpanded, setIsExpanded] = useState(true);
|
|
5217
|
-
const traceDuration = useTraceDuration();
|
|
5218
5303
|
const VariantIcon = spanIconMap[variant];
|
|
5219
5304
|
const variantClass = spanVariantClasses[variant];
|
|
5220
|
-
const progressPercent = durationMs /
|
|
5305
|
+
const progressPercent = durationMs / totalDurationMs * 100;
|
|
5306
|
+
const offsetPercent = offsetMs / totalDurationMs * 100;
|
|
5221
5307
|
const TextEl = onClick ? "button" : "div";
|
|
5222
|
-
return /* @__PURE__ */
|
|
5308
|
+
return /* @__PURE__ */ jsxs("li", { children: [
|
|
5223
5309
|
/* @__PURE__ */ jsxs("div", { className: clsx("flex justify-between items-center gap-2 rounded-md pl-2", isActive && "bg-surface4"), children: [
|
|
5224
5310
|
/* @__PURE__ */ jsxs("div", { className: "flex h-8 items-center gap-1 min-w-0", children: [
|
|
5225
5311
|
spans ? /* @__PURE__ */ jsx(
|
|
@@ -5244,20 +5330,30 @@ const Span = ({ children, durationMs, variant, tokenCount, spans, isRoot, onClic
|
|
|
5244
5330
|
durationMs,
|
|
5245
5331
|
tokenCount,
|
|
5246
5332
|
variant: variant === "agent" ? "agent" : void 0,
|
|
5247
|
-
progressPercent
|
|
5333
|
+
progressPercent,
|
|
5334
|
+
offsetPercent
|
|
5248
5335
|
}
|
|
5249
5336
|
)
|
|
5250
5337
|
] }),
|
|
5251
5338
|
isExpanded && spans && /* @__PURE__ */ jsx("div", { className: "ml-4", children: spans })
|
|
5252
|
-
] })
|
|
5339
|
+
] });
|
|
5253
5340
|
};
|
|
5254
5341
|
|
|
5255
5342
|
const Spans = ({ children }) => {
|
|
5256
5343
|
return /* @__PURE__ */ jsx("ol", { children });
|
|
5257
5344
|
};
|
|
5258
5345
|
|
|
5259
|
-
const Trace = ({
|
|
5260
|
-
|
|
5346
|
+
const Trace = ({
|
|
5347
|
+
name,
|
|
5348
|
+
spans,
|
|
5349
|
+
durationMs,
|
|
5350
|
+
tokenCount,
|
|
5351
|
+
onClick,
|
|
5352
|
+
variant,
|
|
5353
|
+
isActive,
|
|
5354
|
+
totalDurationMs
|
|
5355
|
+
}) => {
|
|
5356
|
+
return /* @__PURE__ */ jsx(
|
|
5261
5357
|
Span,
|
|
5262
5358
|
{
|
|
5263
5359
|
isRoot: true,
|
|
@@ -5266,9 +5362,11 @@ const Trace = ({ name, spans, durationMs, tokenCount, onClick, variant, isActive
|
|
|
5266
5362
|
spans: /* @__PURE__ */ jsx(Spans, { children: spans }),
|
|
5267
5363
|
onClick,
|
|
5268
5364
|
isActive,
|
|
5365
|
+
offsetMs: 0,
|
|
5366
|
+
totalDurationMs,
|
|
5269
5367
|
children: name
|
|
5270
5368
|
}
|
|
5271
|
-
)
|
|
5369
|
+
);
|
|
5272
5370
|
};
|
|
5273
5371
|
|
|
5274
5372
|
const getSpanVariant = (span) => {
|
|
@@ -5293,40 +5391,71 @@ const getSpanVariant = (span) => {
|
|
|
5293
5391
|
return "other";
|
|
5294
5392
|
};
|
|
5295
5393
|
|
|
5296
|
-
function buildTree(
|
|
5297
|
-
return
|
|
5298
|
-
|
|
5299
|
-
|
|
5300
|
-
|
|
5394
|
+
function buildTree(spans, minStartTime, totalDurationMs, parentSpanId = null) {
|
|
5395
|
+
return spans.filter((span) => span.parentSpanId === parentSpanId).map((span) => {
|
|
5396
|
+
return {
|
|
5397
|
+
...span,
|
|
5398
|
+
children: buildTree(spans, minStartTime, totalDurationMs, span.id),
|
|
5399
|
+
offset: (span.startTime - minStartTime) / 1e3,
|
|
5400
|
+
// ns to ms
|
|
5401
|
+
duration: span.duration / 1e3,
|
|
5402
|
+
totalDurationMs
|
|
5403
|
+
};
|
|
5404
|
+
});
|
|
5301
5405
|
}
|
|
5302
|
-
const
|
|
5406
|
+
const createSpanTree = (spans) => {
|
|
5407
|
+
if (spans.length === 0) return [];
|
|
5408
|
+
let minStartTime;
|
|
5409
|
+
let maxEndTime;
|
|
5410
|
+
const orderedTree = [];
|
|
5411
|
+
const listSize = spans.length;
|
|
5412
|
+
for (let i = listSize - 1; i >= 0; i--) {
|
|
5413
|
+
const span = spans[i];
|
|
5414
|
+
if (!minStartTime || span.startTime < minStartTime) {
|
|
5415
|
+
minStartTime = span.startTime;
|
|
5416
|
+
}
|
|
5417
|
+
if (!maxEndTime || span.endTime > maxEndTime) {
|
|
5418
|
+
maxEndTime = span.endTime;
|
|
5419
|
+
}
|
|
5420
|
+
if (span.name !== ".insert" && span.name !== "mastra.getStorage") {
|
|
5421
|
+
orderedTree.push(span);
|
|
5422
|
+
}
|
|
5423
|
+
}
|
|
5424
|
+
if (!minStartTime || !maxEndTime) return [];
|
|
5425
|
+
const totalDurationMs = (maxEndTime - minStartTime) / 1e3;
|
|
5426
|
+
return buildTree(orderedTree, minStartTime, totalDurationMs);
|
|
5427
|
+
};
|
|
5428
|
+
|
|
5429
|
+
const NestedSpans = ({ spanNodes }) => {
|
|
5303
5430
|
const { span: activeSpan, setSpan } = useContext(TraceContext);
|
|
5304
|
-
return /* @__PURE__ */ jsx(Spans, { children:
|
|
5305
|
-
const isActive =
|
|
5431
|
+
return /* @__PURE__ */ jsx(Spans, { children: spanNodes.map((spanNode) => {
|
|
5432
|
+
const isActive = spanNode.id === activeSpan?.id;
|
|
5306
5433
|
return /* @__PURE__ */ jsx(
|
|
5307
5434
|
Span,
|
|
5308
5435
|
{
|
|
5309
|
-
spans:
|
|
5310
|
-
durationMs:
|
|
5311
|
-
|
|
5436
|
+
spans: spanNode.children.length > 0 && /* @__PURE__ */ jsx(NestedSpans, { spanNodes: spanNode.children }),
|
|
5437
|
+
durationMs: spanNode.duration,
|
|
5438
|
+
offsetMs: spanNode.offset,
|
|
5439
|
+
variant: getSpanVariant(spanNode),
|
|
5312
5440
|
isActive,
|
|
5313
|
-
onClick: () => setSpan(
|
|
5314
|
-
|
|
5441
|
+
onClick: () => setSpan(spanNode),
|
|
5442
|
+
totalDurationMs: spanNode.totalDurationMs,
|
|
5443
|
+
children: spanNode.name
|
|
5315
5444
|
},
|
|
5316
|
-
|
|
5445
|
+
spanNode.id
|
|
5317
5446
|
);
|
|
5318
5447
|
}) });
|
|
5319
5448
|
};
|
|
5320
5449
|
function SpanView({ trace }) {
|
|
5321
|
-
const shallowCopy = [...trace];
|
|
5322
|
-
const tree = buildTree(shallowCopy.reverse());
|
|
5323
5450
|
const { span: activeSpan, setSpan } = useContext(TraceContext);
|
|
5451
|
+
const tree = createSpanTree(trace);
|
|
5324
5452
|
return /* @__PURE__ */ jsx(TraceTree, { children: tree.map((node) => /* @__PURE__ */ jsx(
|
|
5325
5453
|
Trace,
|
|
5326
5454
|
{
|
|
5327
5455
|
name: node.name,
|
|
5328
|
-
durationMs: node.duration
|
|
5329
|
-
|
|
5456
|
+
durationMs: node.duration,
|
|
5457
|
+
totalDurationMs: node.totalDurationMs,
|
|
5458
|
+
spans: /* @__PURE__ */ jsx(NestedSpans, { spanNodes: node.children }),
|
|
5330
5459
|
variant: getSpanVariant(node),
|
|
5331
5460
|
isActive: node.id === activeSpan?.id,
|
|
5332
5461
|
onClick: () => setSpan(node)
|
|
@@ -5462,8 +5591,7 @@ const refineTraces = (traces, isWorkflow = false) => {
|
|
|
5462
5591
|
const parentSpan = value.find((span) => !span.parentSpanId || !listOfSpanIds.has(span.parentSpanId));
|
|
5463
5592
|
const enrichedSpans = value.map((span) => ({
|
|
5464
5593
|
...span,
|
|
5465
|
-
parentSpanId: parentSpan?.id === span.id ? null : span?.parentSpanId
|
|
5466
|
-
relativePercentage: parentSpan ? span.duration / parentSpan.duration : 0
|
|
5594
|
+
parentSpanId: parentSpan?.id === span.id ? null : span?.parentSpanId
|
|
5467
5595
|
}));
|
|
5468
5596
|
const failedStatus = value.find((span) => span.status.code !== 0)?.status;
|
|
5469
5597
|
return {
|
|
@@ -6074,7 +6202,7 @@ function WorkflowTracesInner({ traces, isLoading, error }) {
|
|
|
6074
6202
|
] });
|
|
6075
6203
|
}
|
|
6076
6204
|
|
|
6077
|
-
const
|
|
6205
|
+
const sanitizeWorkflowWatchResult = (record) => {
|
|
6078
6206
|
const formattedResults = Object.entries(record.payload.workflowState.steps || {}).reduce(
|
|
6079
6207
|
(acc, [key, value]) => {
|
|
6080
6208
|
let output = value.status === "success" ? value.output : void 0;
|
|
@@ -6109,8 +6237,8 @@ const sanitizeVNexWorkflowWatchResult = (record) => {
|
|
|
6109
6237
|
};
|
|
6110
6238
|
return sanitizedRecord;
|
|
6111
6239
|
};
|
|
6112
|
-
const
|
|
6113
|
-
const [
|
|
6240
|
+
const useLegacyWorkflow = (workflowId, baseUrl) => {
|
|
6241
|
+
const [legacyWorkflow, setLegacyWorkflow] = useState(null);
|
|
6114
6242
|
const [isLoading, setIsLoading] = useState(true);
|
|
6115
6243
|
const client = createMastraClient(baseUrl);
|
|
6116
6244
|
useEffect(() => {
|
|
@@ -6118,22 +6246,22 @@ const useWorkflow = (workflowId, baseUrl) => {
|
|
|
6118
6246
|
setIsLoading(true);
|
|
6119
6247
|
try {
|
|
6120
6248
|
if (!workflowId) {
|
|
6121
|
-
|
|
6249
|
+
setLegacyWorkflow(null);
|
|
6122
6250
|
setIsLoading(false);
|
|
6123
6251
|
return;
|
|
6124
6252
|
}
|
|
6125
|
-
const res = await client.
|
|
6253
|
+
const res = await client.getLegacyWorkflow(workflowId).details();
|
|
6126
6254
|
if (!res) {
|
|
6127
|
-
|
|
6128
|
-
console.error("Error fetching workflow");
|
|
6129
|
-
toast.error("Error fetching workflow");
|
|
6255
|
+
setLegacyWorkflow(null);
|
|
6256
|
+
console.error("Error fetching legacy workflow");
|
|
6257
|
+
toast.error("Error fetching legacy workflow");
|
|
6130
6258
|
return;
|
|
6131
6259
|
}
|
|
6132
6260
|
const steps = res.steps;
|
|
6133
6261
|
const stepsWithWorkflow = await Promise.all(
|
|
6134
6262
|
Object.values(steps)?.map(async (step) => {
|
|
6135
6263
|
if (!step.workflowId) return step;
|
|
6136
|
-
const wFlow = await client.
|
|
6264
|
+
const wFlow = await client.getLegacyWorkflow(step.workflowId).details();
|
|
6137
6265
|
if (!wFlow) return step;
|
|
6138
6266
|
return { ...step, stepGraph: wFlow.stepGraph, stepSubscriberGraph: wFlow.stepSubscriberGraph };
|
|
6139
6267
|
})
|
|
@@ -6141,21 +6269,21 @@ const useWorkflow = (workflowId, baseUrl) => {
|
|
|
6141
6269
|
const _steps = stepsWithWorkflow.reduce((acc, b) => {
|
|
6142
6270
|
return { ...acc, [b.id]: b };
|
|
6143
6271
|
}, {});
|
|
6144
|
-
|
|
6272
|
+
setLegacyWorkflow({ ...res, steps: _steps });
|
|
6145
6273
|
} catch (error) {
|
|
6146
|
-
|
|
6147
|
-
console.error("Error fetching workflow", error);
|
|
6148
|
-
toast.error("Error fetching workflow");
|
|
6274
|
+
setLegacyWorkflow(null);
|
|
6275
|
+
console.error("Error fetching legacy workflow", error);
|
|
6276
|
+
toast.error("Error fetching legacy workflow");
|
|
6149
6277
|
} finally {
|
|
6150
6278
|
setIsLoading(false);
|
|
6151
6279
|
}
|
|
6152
6280
|
};
|
|
6153
6281
|
fetchWorkflow();
|
|
6154
6282
|
}, [workflowId]);
|
|
6155
|
-
return {
|
|
6283
|
+
return { legacyWorkflow, isLoading };
|
|
6156
6284
|
};
|
|
6157
|
-
const
|
|
6158
|
-
const [
|
|
6285
|
+
const useWorkflow = (workflowId, baseUrl) => {
|
|
6286
|
+
const [workflow, setWorkflow] = useState(null);
|
|
6159
6287
|
const [isLoading, setIsLoading] = useState(true);
|
|
6160
6288
|
const client = createMastraClient(baseUrl);
|
|
6161
6289
|
useEffect(() => {
|
|
@@ -6163,14 +6291,14 @@ const useVNextWorkflow = (workflowId, baseUrl) => {
|
|
|
6163
6291
|
setIsLoading(true);
|
|
6164
6292
|
try {
|
|
6165
6293
|
if (!workflowId) {
|
|
6166
|
-
|
|
6294
|
+
setWorkflow(null);
|
|
6167
6295
|
setIsLoading(false);
|
|
6168
6296
|
return;
|
|
6169
6297
|
}
|
|
6170
|
-
const res = await client.
|
|
6171
|
-
|
|
6298
|
+
const res = await client.getWorkflow(workflowId).details();
|
|
6299
|
+
setWorkflow(res);
|
|
6172
6300
|
} catch (error) {
|
|
6173
|
-
|
|
6301
|
+
setWorkflow(null);
|
|
6174
6302
|
console.error("Error fetching workflow", error);
|
|
6175
6303
|
toast.error("Error fetching workflow");
|
|
6176
6304
|
} finally {
|
|
@@ -6179,13 +6307,13 @@ const useVNextWorkflow = (workflowId, baseUrl) => {
|
|
|
6179
6307
|
};
|
|
6180
6308
|
fetchWorkflow();
|
|
6181
6309
|
}, [workflowId]);
|
|
6182
|
-
return {
|
|
6310
|
+
return { workflow, isLoading };
|
|
6183
6311
|
};
|
|
6184
6312
|
const useExecuteWorkflow = (baseUrl) => {
|
|
6185
6313
|
const client = createMastraClient(baseUrl);
|
|
6186
|
-
const
|
|
6314
|
+
const createLegacyWorkflowRun = async ({ workflowId, prevRunId }) => {
|
|
6187
6315
|
try {
|
|
6188
|
-
const workflow = client.
|
|
6316
|
+
const workflow = client.getLegacyWorkflow(workflowId);
|
|
6189
6317
|
const { runId: newRunId } = await workflow.createRun({ runId: prevRunId });
|
|
6190
6318
|
return { runId: newRunId };
|
|
6191
6319
|
} catch (error) {
|
|
@@ -6193,9 +6321,9 @@ const useExecuteWorkflow = (baseUrl) => {
|
|
|
6193
6321
|
throw error;
|
|
6194
6322
|
}
|
|
6195
6323
|
};
|
|
6196
|
-
const
|
|
6324
|
+
const createWorkflowRun = async ({ workflowId, prevRunId }) => {
|
|
6197
6325
|
try {
|
|
6198
|
-
const workflow = client.
|
|
6326
|
+
const workflow = client.getWorkflow(workflowId);
|
|
6199
6327
|
const { runId: newRunId } = await workflow.createRun({ runId: prevRunId });
|
|
6200
6328
|
return { runId: newRunId };
|
|
6201
6329
|
} catch (error) {
|
|
@@ -6203,16 +6331,20 @@ const useExecuteWorkflow = (baseUrl) => {
|
|
|
6203
6331
|
throw error;
|
|
6204
6332
|
}
|
|
6205
6333
|
};
|
|
6206
|
-
const
|
|
6334
|
+
const startLegacyWorkflowRun = async ({
|
|
6335
|
+
workflowId,
|
|
6336
|
+
runId,
|
|
6337
|
+
input
|
|
6338
|
+
}) => {
|
|
6207
6339
|
try {
|
|
6208
|
-
const workflow = client.
|
|
6340
|
+
const workflow = client.getLegacyWorkflow(workflowId);
|
|
6209
6341
|
await workflow.start({ runId, triggerData: input || {} });
|
|
6210
6342
|
} catch (error) {
|
|
6211
6343
|
console.error("Error starting workflow run:", error);
|
|
6212
6344
|
throw error;
|
|
6213
6345
|
}
|
|
6214
6346
|
};
|
|
6215
|
-
const
|
|
6347
|
+
const startWorkflowRun = async ({
|
|
6216
6348
|
workflowId,
|
|
6217
6349
|
runId,
|
|
6218
6350
|
input,
|
|
@@ -6223,14 +6355,14 @@ const useExecuteWorkflow = (baseUrl) => {
|
|
|
6223
6355
|
Object.entries(playgroundRuntimeContext).forEach(([key, value]) => {
|
|
6224
6356
|
runtimeContext.set(key, value);
|
|
6225
6357
|
});
|
|
6226
|
-
const workflow = client.
|
|
6358
|
+
const workflow = client.getWorkflow(workflowId);
|
|
6227
6359
|
await workflow.start({ runId, inputData: input || {}, runtimeContext });
|
|
6228
6360
|
} catch (error) {
|
|
6229
6361
|
console.error("Error starting workflow run:", error);
|
|
6230
6362
|
throw error;
|
|
6231
6363
|
}
|
|
6232
6364
|
};
|
|
6233
|
-
const
|
|
6365
|
+
const startAsyncWorkflowRun = async ({
|
|
6234
6366
|
workflowId,
|
|
6235
6367
|
runId,
|
|
6236
6368
|
input,
|
|
@@ -6241,7 +6373,7 @@ const useExecuteWorkflow = (baseUrl) => {
|
|
|
6241
6373
|
Object.entries(playgroundRuntimeContext).forEach(([key, value]) => {
|
|
6242
6374
|
runtimeContext.set(key, value);
|
|
6243
6375
|
});
|
|
6244
|
-
const workflow = client.
|
|
6376
|
+
const workflow = client.getWorkflow(workflowId);
|
|
6245
6377
|
const result = await workflow.startAsync({ runId, inputData: input || {}, runtimeContext });
|
|
6246
6378
|
return result;
|
|
6247
6379
|
} catch (error) {
|
|
@@ -6252,17 +6384,17 @@ const useExecuteWorkflow = (baseUrl) => {
|
|
|
6252
6384
|
return {
|
|
6253
6385
|
startWorkflowRun,
|
|
6254
6386
|
createWorkflowRun,
|
|
6255
|
-
|
|
6256
|
-
|
|
6257
|
-
|
|
6387
|
+
startLegacyWorkflowRun,
|
|
6388
|
+
createLegacyWorkflowRun,
|
|
6389
|
+
startAsyncWorkflowRun
|
|
6258
6390
|
};
|
|
6259
6391
|
};
|
|
6260
6392
|
const useWatchWorkflow = (baseUrl) => {
|
|
6393
|
+
const [isWatchingLegacyWorkflow, setIsWatchingLegacyWorkflow] = useState(false);
|
|
6261
6394
|
const [isWatchingWorkflow, setIsWatchingWorkflow] = useState(false);
|
|
6262
|
-
const [
|
|
6395
|
+
const [legacyWatchResult, setLegacyWatchResult] = useState(null);
|
|
6263
6396
|
const [watchResult, setWatchResult] = useState(null);
|
|
6264
|
-
const
|
|
6265
|
-
const debouncedSetWatchResult = useDebouncedCallback((record) => {
|
|
6397
|
+
const debouncedSetLegacyWorkflowWatchResult = useDebouncedCallback((record) => {
|
|
6266
6398
|
const formattedResults = Object.entries(record.results || {}).reduce(
|
|
6267
6399
|
(acc, [key, value]) => {
|
|
6268
6400
|
let output = value.status === "success" ? value.output : void 0;
|
|
@@ -6285,19 +6417,19 @@ const useWatchWorkflow = (baseUrl) => {
|
|
|
6285
6417
|
...record,
|
|
6286
6418
|
sanitizedOutput: record ? JSON.stringify({ ...record, results: formattedResults }, null, 2).slice(0, 5e4) : null
|
|
6287
6419
|
};
|
|
6288
|
-
|
|
6420
|
+
setLegacyWatchResult(sanitizedRecord);
|
|
6289
6421
|
}, 100);
|
|
6290
|
-
const
|
|
6422
|
+
const watchLegacyWorkflow = async ({ workflowId, runId }) => {
|
|
6291
6423
|
try {
|
|
6292
|
-
|
|
6424
|
+
setIsWatchingLegacyWorkflow(true);
|
|
6293
6425
|
const client = createMastraClient(baseUrl);
|
|
6294
|
-
const workflow = client.
|
|
6426
|
+
const workflow = client.getLegacyWorkflow(workflowId);
|
|
6295
6427
|
await workflow.watch({ runId }, (record) => {
|
|
6296
6428
|
try {
|
|
6297
|
-
|
|
6429
|
+
debouncedSetLegacyWorkflowWatchResult(record);
|
|
6298
6430
|
} catch (err) {
|
|
6299
6431
|
console.error("Error processing workflow record:", err);
|
|
6300
|
-
|
|
6432
|
+
setLegacyWatchResult({
|
|
6301
6433
|
...record
|
|
6302
6434
|
});
|
|
6303
6435
|
}
|
|
@@ -6306,24 +6438,24 @@ const useWatchWorkflow = (baseUrl) => {
|
|
|
6306
6438
|
console.error("Error watching workflow:", error);
|
|
6307
6439
|
throw error;
|
|
6308
6440
|
} finally {
|
|
6309
|
-
|
|
6441
|
+
setIsWatchingLegacyWorkflow(false);
|
|
6310
6442
|
}
|
|
6311
6443
|
};
|
|
6312
|
-
const
|
|
6313
|
-
const sanitizedRecord =
|
|
6314
|
-
|
|
6444
|
+
const debouncedSetWorkflowWatchResult = useDebouncedCallback((record) => {
|
|
6445
|
+
const sanitizedRecord = sanitizeWorkflowWatchResult(record);
|
|
6446
|
+
setWatchResult(sanitizedRecord);
|
|
6315
6447
|
}, 100);
|
|
6316
|
-
const
|
|
6448
|
+
const watchWorkflow = async ({ workflowId, runId }) => {
|
|
6317
6449
|
try {
|
|
6318
|
-
|
|
6450
|
+
setIsWatchingWorkflow(true);
|
|
6319
6451
|
const client = createMastraClient(baseUrl);
|
|
6320
|
-
const workflow = client.
|
|
6452
|
+
const workflow = client.getWorkflow(workflowId);
|
|
6321
6453
|
await workflow.watch({ runId }, (record) => {
|
|
6322
6454
|
try {
|
|
6323
|
-
|
|
6455
|
+
debouncedSetWorkflowWatchResult(record);
|
|
6324
6456
|
} catch (err) {
|
|
6325
6457
|
console.error("Error processing workflow record:", err);
|
|
6326
|
-
|
|
6458
|
+
setWatchResult({
|
|
6327
6459
|
...record
|
|
6328
6460
|
});
|
|
6329
6461
|
}
|
|
@@ -6332,40 +6464,40 @@ const useWatchWorkflow = (baseUrl) => {
|
|
|
6332
6464
|
console.error("Error watching workflow:", error);
|
|
6333
6465
|
throw error;
|
|
6334
6466
|
} finally {
|
|
6335
|
-
|
|
6467
|
+
setIsWatchingWorkflow(false);
|
|
6336
6468
|
}
|
|
6337
6469
|
};
|
|
6338
6470
|
return {
|
|
6471
|
+
watchLegacyWorkflow,
|
|
6472
|
+
isWatchingLegacyWorkflow,
|
|
6473
|
+
legacyWatchResult,
|
|
6339
6474
|
watchWorkflow,
|
|
6340
6475
|
isWatchingWorkflow,
|
|
6341
|
-
watchResult
|
|
6342
|
-
watchVNextWorkflow,
|
|
6343
|
-
isWatchingVNextWorkflow,
|
|
6344
|
-
watchVNextResult
|
|
6476
|
+
watchResult
|
|
6345
6477
|
};
|
|
6346
6478
|
};
|
|
6347
6479
|
const useResumeWorkflow = (baseUrl) => {
|
|
6480
|
+
const [isResumingLegacyWorkflow, setIsResumingLegacyWorkflow] = useState(false);
|
|
6348
6481
|
const [isResumingWorkflow, setIsResumingWorkflow] = useState(false);
|
|
6349
|
-
const
|
|
6350
|
-
const resumeWorkflow = async ({
|
|
6482
|
+
const resumeLegacyWorkflow = async ({
|
|
6351
6483
|
workflowId,
|
|
6352
6484
|
stepId,
|
|
6353
6485
|
runId,
|
|
6354
6486
|
context
|
|
6355
6487
|
}) => {
|
|
6356
6488
|
try {
|
|
6357
|
-
|
|
6489
|
+
setIsResumingLegacyWorkflow(true);
|
|
6358
6490
|
const client = createMastraClient(baseUrl);
|
|
6359
|
-
const response = await client.
|
|
6491
|
+
const response = await client.getLegacyWorkflow(workflowId).resume({ stepId, runId, context });
|
|
6360
6492
|
return response;
|
|
6361
6493
|
} catch (error) {
|
|
6362
6494
|
console.error("Error resuming workflow:", error);
|
|
6363
6495
|
throw error;
|
|
6364
6496
|
} finally {
|
|
6365
|
-
|
|
6497
|
+
setIsResumingLegacyWorkflow(false);
|
|
6366
6498
|
}
|
|
6367
6499
|
};
|
|
6368
|
-
const
|
|
6500
|
+
const resumeWorkflow = async ({
|
|
6369
6501
|
workflowId,
|
|
6370
6502
|
step,
|
|
6371
6503
|
runId,
|
|
@@ -6373,26 +6505,26 @@ const useResumeWorkflow = (baseUrl) => {
|
|
|
6373
6505
|
runtimeContext: playgroundRuntimeContext
|
|
6374
6506
|
}) => {
|
|
6375
6507
|
try {
|
|
6376
|
-
|
|
6508
|
+
setIsResumingWorkflow(true);
|
|
6377
6509
|
const client = createMastraClient(baseUrl);
|
|
6378
6510
|
const runtimeContext = new RuntimeContext$1();
|
|
6379
6511
|
Object.entries(playgroundRuntimeContext).forEach(([key, value]) => {
|
|
6380
6512
|
runtimeContext.set(key, value);
|
|
6381
6513
|
});
|
|
6382
|
-
const response = await client.
|
|
6514
|
+
const response = await client.getWorkflow(workflowId).resume({ step, runId, resumeData, runtimeContext });
|
|
6383
6515
|
return response;
|
|
6384
6516
|
} catch (error) {
|
|
6385
6517
|
console.error("Error resuming workflow:", error);
|
|
6386
6518
|
throw error;
|
|
6387
6519
|
} finally {
|
|
6388
|
-
|
|
6520
|
+
setIsResumingWorkflow(false);
|
|
6389
6521
|
}
|
|
6390
6522
|
};
|
|
6391
6523
|
return {
|
|
6524
|
+
resumeLegacyWorkflow,
|
|
6525
|
+
isResumingLegacyWorkflow,
|
|
6392
6526
|
resumeWorkflow,
|
|
6393
|
-
isResumingWorkflow
|
|
6394
|
-
resumeVNextWorkflow,
|
|
6395
|
-
isResumingVNextWorkflow
|
|
6527
|
+
isResumingWorkflow
|
|
6396
6528
|
};
|
|
6397
6529
|
};
|
|
6398
6530
|
|
|
@@ -6479,7 +6611,7 @@ const defaultEdgeOptions = {
|
|
|
6479
6611
|
color: "#8e8e8e"
|
|
6480
6612
|
}
|
|
6481
6613
|
};
|
|
6482
|
-
const
|
|
6614
|
+
const contructLegacyNodesAndEdges = ({
|
|
6483
6615
|
stepGraph,
|
|
6484
6616
|
stepSubscriberGraph,
|
|
6485
6617
|
steps: mainSteps = {}
|
|
@@ -6930,7 +7062,7 @@ const getStepNodeAndEdge = ({
|
|
|
6930
7062
|
}
|
|
6931
7063
|
return { nodes: [], edges: [], nextPrevNodeIds: [] };
|
|
6932
7064
|
};
|
|
6933
|
-
const
|
|
7065
|
+
const constructNodesAndEdges = ({
|
|
6934
7066
|
stepGraph
|
|
6935
7067
|
}) => {
|
|
6936
7068
|
if (!stepGraph) {
|
|
@@ -7269,12 +7401,12 @@ function Spinner({ color = "#fff", className }) {
|
|
|
7269
7401
|
);
|
|
7270
7402
|
}
|
|
7271
7403
|
|
|
7272
|
-
function
|
|
7404
|
+
function LegacyWorkflowNestedGraph({
|
|
7273
7405
|
stepGraph,
|
|
7274
7406
|
stepSubscriberGraph,
|
|
7275
7407
|
open
|
|
7276
7408
|
}) {
|
|
7277
|
-
const { nodes: initialNodes, edges: initialEdges } =
|
|
7409
|
+
const { nodes: initialNodes, edges: initialEdges } = contructLegacyNodesAndEdges({
|
|
7278
7410
|
stepGraph,
|
|
7279
7411
|
stepSubscriberGraph
|
|
7280
7412
|
});
|
|
@@ -7312,10 +7444,10 @@ function WorkflowNestedGraph({
|
|
|
7312
7444
|
) : /* @__PURE__ */ jsx("div", { className: "w-full h-full flex items-center justify-center", children: /* @__PURE__ */ jsx(Spinner, {}) }) });
|
|
7313
7445
|
}
|
|
7314
7446
|
|
|
7315
|
-
const
|
|
7447
|
+
const LegacyWorkflowNestedGraphContext = createContext(
|
|
7316
7448
|
{}
|
|
7317
7449
|
);
|
|
7318
|
-
function
|
|
7450
|
+
function LegacyWorkflowNestedGraphProvider({ children }) {
|
|
7319
7451
|
const [stepGraph, setStepGraph] = useState(null);
|
|
7320
7452
|
const [stepSubscriberGraph, setStepSubscriberGraph] = useState(null);
|
|
7321
7453
|
const [openDialog, setOpenDialog] = useState(false);
|
|
@@ -7337,7 +7469,7 @@ function WorkflowNestedGraphProvider({ children }) {
|
|
|
7337
7469
|
setOpenDialog(true);
|
|
7338
7470
|
};
|
|
7339
7471
|
return /* @__PURE__ */ jsxs(
|
|
7340
|
-
|
|
7472
|
+
LegacyWorkflowNestedGraphContext.Provider,
|
|
7341
7473
|
{
|
|
7342
7474
|
value: {
|
|
7343
7475
|
showNestedGraph,
|
|
@@ -7353,16 +7485,23 @@ function WorkflowNestedGraphProvider({ children }) {
|
|
|
7353
7485
|
" workflow"
|
|
7354
7486
|
] })
|
|
7355
7487
|
] }),
|
|
7356
|
-
/* @__PURE__ */ jsx(ReactFlowProvider, { children: /* @__PURE__ */ jsx(
|
|
7488
|
+
/* @__PURE__ */ jsx(ReactFlowProvider, { children: /* @__PURE__ */ jsx(
|
|
7489
|
+
LegacyWorkflowNestedGraph,
|
|
7490
|
+
{
|
|
7491
|
+
stepGraph,
|
|
7492
|
+
open: openDialog,
|
|
7493
|
+
stepSubscriberGraph
|
|
7494
|
+
}
|
|
7495
|
+
) })
|
|
7357
7496
|
] }) }) })
|
|
7358
7497
|
]
|
|
7359
7498
|
}
|
|
7360
7499
|
);
|
|
7361
7500
|
}
|
|
7362
7501
|
|
|
7363
|
-
function
|
|
7502
|
+
function LegacyWorkflowNestedNode({ data }) {
|
|
7364
7503
|
const { label, withoutTopHandle, withoutBottomHandle, stepGraph, stepSubscriberGraph } = data;
|
|
7365
|
-
const { showNestedGraph } = useContext(
|
|
7504
|
+
const { showNestedGraph } = useContext(LegacyWorkflowNestedGraphContext);
|
|
7366
7505
|
return /* @__PURE__ */ jsxs("div", { className: cn("bg-[rgba(29,29,29,0.5)] rounded-md h-full overflow-scroll w-[274px]"), children: [
|
|
7367
7506
|
!withoutTopHandle && /* @__PURE__ */ jsx(Handle, { type: "target", position: Position.Top, style: { visibility: "hidden" } }),
|
|
7368
7507
|
/* @__PURE__ */ jsx("div", { className: "p-2 cursor-pointer", onClick: () => showNestedGraph({ label, stepGraph, stepSubscriberGraph }), children: /* @__PURE__ */ jsxs("div", { className: "text-sm bg-mastra-bg-9 flex items-center gap-1.5 rounded-sm p-2 cursor-pointer", children: [
|
|
@@ -7373,8 +7512,8 @@ function WorkflowNestedNode({ data }) {
|
|
|
7373
7512
|
] });
|
|
7374
7513
|
}
|
|
7375
7514
|
|
|
7376
|
-
function
|
|
7377
|
-
const { nodes: initialNodes, edges: initialEdges } =
|
|
7515
|
+
function LegacyWorkflowGraphInner({ workflow }) {
|
|
7516
|
+
const { nodes: initialNodes, edges: initialEdges } = contructLegacyNodesAndEdges({
|
|
7378
7517
|
stepGraph: workflow.serializedStepGraph || workflow.stepGraph,
|
|
7379
7518
|
stepSubscriberGraph: workflow.serializedStepSubscriberGraph || workflow.stepSubscriberGraph,
|
|
7380
7519
|
steps: workflow.steps
|
|
@@ -7386,7 +7525,7 @@ function WorkflowGraphInner({ workflow }) {
|
|
|
7386
7525
|
"condition-node": WorkflowConditionNode,
|
|
7387
7526
|
"after-node": WorkflowAfterNode,
|
|
7388
7527
|
"loop-result-node": WorkflowLoopResultNode,
|
|
7389
|
-
"nested-node":
|
|
7528
|
+
"nested-node": LegacyWorkflowNestedNode
|
|
7390
7529
|
};
|
|
7391
7530
|
return /* @__PURE__ */ jsx("div", { className: "w-full h-full", children: /* @__PURE__ */ jsxs(
|
|
7392
7531
|
ReactFlow,
|
|
@@ -7413,12 +7552,12 @@ const lodashTitleCase = (str) => {
|
|
|
7413
7552
|
return camelCased.replace(/([A-Z])/g, " $1").replace(/^./, (str2) => str2.toUpperCase()).trim();
|
|
7414
7553
|
};
|
|
7415
7554
|
|
|
7416
|
-
function
|
|
7417
|
-
const {
|
|
7555
|
+
function LegacyWorkflowGraph({ workflowId, baseUrl }) {
|
|
7556
|
+
const { legacyWorkflow, isLoading } = useLegacyWorkflow(workflowId, baseUrl);
|
|
7418
7557
|
if (isLoading) {
|
|
7419
7558
|
return /* @__PURE__ */ jsx("div", { className: "p-4", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-[600px]" }) });
|
|
7420
7559
|
}
|
|
7421
|
-
if (!
|
|
7560
|
+
if (!legacyWorkflow) {
|
|
7422
7561
|
return /* @__PURE__ */ jsx("div", { className: "grid h-full place-items-center", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-2", children: [
|
|
7423
7562
|
/* @__PURE__ */ jsx(AlertCircleIcon, {}),
|
|
7424
7563
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
@@ -7428,28 +7567,24 @@ function WorkflowGraph({ workflowId, baseUrl }) {
|
|
|
7428
7567
|
] })
|
|
7429
7568
|
] }) });
|
|
7430
7569
|
}
|
|
7431
|
-
return /* @__PURE__ */ jsx(
|
|
7570
|
+
return /* @__PURE__ */ jsx(LegacyWorkflowNestedGraphProvider, { children: /* @__PURE__ */ jsx(ReactFlowProvider, { children: /* @__PURE__ */ jsx(LegacyWorkflowGraphInner, { workflow: legacyWorkflow }) }) });
|
|
7432
7571
|
}
|
|
7433
7572
|
|
|
7434
7573
|
const Form = React__default.forwardRef(({ children, ...props }, ref) => {
|
|
7435
7574
|
return /* @__PURE__ */ jsx("form", { ref, className: "space-y-4", ...props, children });
|
|
7436
7575
|
});
|
|
7437
7576
|
|
|
7438
|
-
const labelVariants = cva("text-sm leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70");
|
|
7439
|
-
const Label = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(LabelPrimitive.Root, { ref, className: cn(labelVariants(), className), ...props }));
|
|
7440
|
-
Label.displayName = LabelPrimitive.Root.displayName;
|
|
7441
|
-
|
|
7442
7577
|
const DISABLED_LABELS = ["boolean", "object", "array"];
|
|
7443
7578
|
const FieldWrapper = ({ label, children, id, field, error }) => {
|
|
7444
7579
|
const isDisabled = DISABLED_LABELS.includes(field.type);
|
|
7445
|
-
return /* @__PURE__ */ jsxs("div", { className: "
|
|
7446
|
-
!isDisabled && /* @__PURE__ */ jsxs(
|
|
7580
|
+
return /* @__PURE__ */ jsxs("div", { className: "pb-4 last:pb-0", children: [
|
|
7581
|
+
!isDisabled && /* @__PURE__ */ jsxs(Txt, { as: "label", variant: "ui-sm", className: "text-icon3 pb-1 block", htmlFor: id, children: [
|
|
7447
7582
|
label,
|
|
7448
|
-
field.required && /* @__PURE__ */ jsx("span", { className: "text-
|
|
7583
|
+
field.required && /* @__PURE__ */ jsx("span", { className: "text-accent2", children: " *" })
|
|
7449
7584
|
] }),
|
|
7450
7585
|
children,
|
|
7451
|
-
field.fieldConfig?.description && /* @__PURE__ */ jsx("p",
|
|
7452
|
-
error && /* @__PURE__ */ jsx("p",
|
|
7586
|
+
field.fieldConfig?.description && /* @__PURE__ */ jsx(Txt, { as: "p", variant: "ui-sm", className: "text-icon6", children: field.fieldConfig.description }),
|
|
7587
|
+
error && /* @__PURE__ */ jsx(Txt, { as: "p", variant: "ui-sm", className: "text-accent2", children: error })
|
|
7453
7588
|
] });
|
|
7454
7589
|
};
|
|
7455
7590
|
|
|
@@ -7558,9 +7693,9 @@ const BooleanField = ({ field, label, id, inputProps, value }) => /* @__PURE__ *
|
|
|
7558
7693
|
defaultChecked: field.default
|
|
7559
7694
|
}
|
|
7560
7695
|
),
|
|
7561
|
-
/* @__PURE__ */ jsxs(
|
|
7696
|
+
/* @__PURE__ */ jsxs(Txt, { as: "label", variant: "ui-sm", className: "text-icon3", htmlFor: id, children: [
|
|
7562
7697
|
label,
|
|
7563
|
-
field.required && /* @__PURE__ */ jsx("span", { className: "text-
|
|
7698
|
+
field.required && /* @__PURE__ */ jsx("span", { className: "text-accent2", children: " *" })
|
|
7564
7699
|
] })
|
|
7565
7700
|
] });
|
|
7566
7701
|
|
|
@@ -7907,34 +8042,53 @@ const SelectField = ({ field, inputProps, error, id, value }) => {
|
|
|
7907
8042
|
};
|
|
7908
8043
|
|
|
7909
8044
|
const ObjectWrapper = ({ label, children }) => {
|
|
7910
|
-
|
|
7911
|
-
|
|
7912
|
-
children
|
|
7913
|
-
|
|
7914
|
-
|
|
7915
|
-
|
|
7916
|
-
const ArrayWrapper = ({ label, children, onAddItem }) => {
|
|
7917
|
-
return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
7918
|
-
/* @__PURE__ */ jsx("h3", { className: "text-sm font-medium", children: label }),
|
|
7919
|
-
children,
|
|
8045
|
+
const hasLabel = label !== "" && label !== "";
|
|
8046
|
+
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
8047
|
+
hasLabel && /* @__PURE__ */ jsxs(Txt, { as: "h3", variant: "ui-sm", className: "text-icon3 flex items-center gap-1 pb-2", children: [
|
|
8048
|
+
/* @__PURE__ */ jsx(Icon, { size: "sm", children: /* @__PURE__ */ jsx(Braces, {}) }),
|
|
8049
|
+
label
|
|
8050
|
+
] }),
|
|
7920
8051
|
/* @__PURE__ */ jsx(
|
|
7921
|
-
|
|
8052
|
+
"div",
|
|
7922
8053
|
{
|
|
7923
|
-
className: "
|
|
7924
|
-
|
|
7925
|
-
variant: "outline",
|
|
7926
|
-
size: "sm",
|
|
7927
|
-
type: "button",
|
|
7928
|
-
children: /* @__PURE__ */ jsx(PlusIcon, { className: "h-4 w-4" })
|
|
8054
|
+
className: hasLabel ? "flex flex-col gap-1 [&>*]:border-dashed [&>*]:border-l [&>*]:border-l-border1 [&>*]:pl-4" : "",
|
|
8055
|
+
children
|
|
7929
8056
|
}
|
|
7930
8057
|
)
|
|
7931
8058
|
] });
|
|
7932
8059
|
};
|
|
7933
8060
|
|
|
8061
|
+
const ArrayWrapper = ({ label, children, onAddItem }) => {
|
|
8062
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
8063
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-2 justify-between", children: [
|
|
8064
|
+
/* @__PURE__ */ jsxs(Txt, { as: "h3", variant: "ui-sm", className: "text-icon3 pb-2 flex items-center gap-1", children: [
|
|
8065
|
+
/* @__PURE__ */ jsx(Icon, { size: "sm", children: /* @__PURE__ */ jsx(Brackets, {}) }),
|
|
8066
|
+
label
|
|
8067
|
+
] }),
|
|
8068
|
+
/* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 0, children: [
|
|
8069
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
8070
|
+
"button",
|
|
8071
|
+
{
|
|
8072
|
+
onClick: onAddItem,
|
|
8073
|
+
type: "button",
|
|
8074
|
+
className: "text-icon3 bg-surface3 rounded-md p-1 hover:bg-surface4 hover:text-icon6 h-icon-sm w-icon-sm",
|
|
8075
|
+
children: /* @__PURE__ */ jsx(Icon, { size: "sm", children: /* @__PURE__ */ jsx(PlusIcon, {}) })
|
|
8076
|
+
}
|
|
8077
|
+
) }),
|
|
8078
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: "Add item" })
|
|
8079
|
+
] }) })
|
|
8080
|
+
] }),
|
|
8081
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children })
|
|
8082
|
+
] });
|
|
8083
|
+
};
|
|
8084
|
+
|
|
7934
8085
|
const ArrayElementWrapper = ({ children, onRemove }) => {
|
|
7935
|
-
return /* @__PURE__ */ jsxs("div", { className: "
|
|
7936
|
-
|
|
7937
|
-
children
|
|
8086
|
+
return /* @__PURE__ */ jsxs("div", { className: "pl-4 border-l border-border1", children: [
|
|
8087
|
+
children,
|
|
8088
|
+
/* @__PURE__ */ jsxs(Button, { onClick: onRemove, type: "button", children: [
|
|
8089
|
+
/* @__PURE__ */ jsx(Icon, { size: "sm", children: /* @__PURE__ */ jsx(TrashIcon, {}) }),
|
|
8090
|
+
"Delete"
|
|
8091
|
+
] })
|
|
7938
8092
|
] });
|
|
7939
8093
|
};
|
|
7940
8094
|
|
|
@@ -8133,6 +8287,10 @@ class CustomZodProvider extends ZodProvider {
|
|
|
8133
8287
|
}
|
|
8134
8288
|
}
|
|
8135
8289
|
|
|
8290
|
+
const labelVariants = cva("text-sm leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70");
|
|
8291
|
+
const Label = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(LabelPrimitive.Root, { ref, className: cn(labelVariants(), className), ...props }));
|
|
8292
|
+
Label.displayName = LabelPrimitive.Root.displayName;
|
|
8293
|
+
|
|
8136
8294
|
function isEmptyZodObject(schema) {
|
|
8137
8295
|
if (schema instanceof ZodObject) {
|
|
8138
8296
|
return Object.keys(schema.shape).length === 0;
|
|
@@ -8144,7 +8302,7 @@ function DynamicForm({
|
|
|
8144
8302
|
onSubmit,
|
|
8145
8303
|
defaultValues,
|
|
8146
8304
|
isSubmitLoading,
|
|
8147
|
-
submitButtonLabel
|
|
8305
|
+
submitButtonLabel
|
|
8148
8306
|
}) {
|
|
8149
8307
|
if (!schema) {
|
|
8150
8308
|
console.error("no form schema found");
|
|
@@ -8166,17 +8324,17 @@ function DynamicForm({
|
|
|
8166
8324
|
},
|
|
8167
8325
|
defaultValues: defaultValues ? { "": defaultValues } : void 0,
|
|
8168
8326
|
formProps: {
|
|
8169
|
-
className: "
|
|
8327
|
+
className: ""
|
|
8170
8328
|
},
|
|
8171
8329
|
uiComponents: {
|
|
8172
|
-
SubmitButton: ({ children }) => /* @__PURE__ */ jsx(Button
|
|
8330
|
+
SubmitButton: ({ children }) => /* @__PURE__ */ jsx(Button, { variant: "light", className: "w-full", size: "lg", disabled: isSubmitLoading, children: isSubmitLoading ? /* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(Loader2, { className: "animate-spin" }) }) : submitButtonLabel || children })
|
|
8173
8331
|
},
|
|
8174
8332
|
formComponents: {
|
|
8175
8333
|
Label: ({ value }) => /* @__PURE__ */ jsx(Label, { className: "text-sm font-normal", children: value })
|
|
8176
8334
|
},
|
|
8177
8335
|
withSubmit: true
|
|
8178
8336
|
};
|
|
8179
|
-
return /* @__PURE__ */ jsx(
|
|
8337
|
+
return /* @__PURE__ */ jsx("div", { className: "h-full w-full", children: /* @__PURE__ */ jsx(AutoForm, { ...formProps }) });
|
|
8180
8338
|
}
|
|
8181
8339
|
|
|
8182
8340
|
function resolveSerializedZodOutput(obj) {
|
|
@@ -8206,22 +8364,22 @@ function CodeBlockDemo({
|
|
|
8206
8364
|
|
|
8207
8365
|
const WorkflowRunContext = createContext({});
|
|
8208
8366
|
function WorkflowRunProvider({ children }) {
|
|
8367
|
+
const [legacyResult, setLegacyResult] = useState(null);
|
|
8209
8368
|
const [result, setResult] = useState(null);
|
|
8210
|
-
const [vNextResult, setVNextResult] = useState(null);
|
|
8211
8369
|
const [payload, setPayload] = useState(null);
|
|
8212
8370
|
const clearData = () => {
|
|
8371
|
+
setLegacyResult(null);
|
|
8213
8372
|
setResult(null);
|
|
8214
|
-
setVNextResult(null);
|
|
8215
8373
|
setPayload(null);
|
|
8216
8374
|
};
|
|
8217
8375
|
return /* @__PURE__ */ jsx(
|
|
8218
8376
|
WorkflowRunContext.Provider,
|
|
8219
8377
|
{
|
|
8220
8378
|
value: {
|
|
8379
|
+
legacyResult,
|
|
8380
|
+
setLegacyResult,
|
|
8221
8381
|
result,
|
|
8222
8382
|
setResult,
|
|
8223
|
-
vNextResult,
|
|
8224
|
-
setVNextResult,
|
|
8225
8383
|
payload,
|
|
8226
8384
|
setPayload,
|
|
8227
8385
|
clearData
|
|
@@ -8231,16 +8389,81 @@ function WorkflowRunProvider({ children }) {
|
|
|
8231
8389
|
);
|
|
8232
8390
|
}
|
|
8233
8391
|
|
|
8234
|
-
|
|
8392
|
+
const WorkflowCard = ({ header, children, footer }) => {
|
|
8393
|
+
return /* @__PURE__ */ jsxs("div", { className: "rounded-lg border-sm border-border1 bg-surface4", children: [
|
|
8394
|
+
/* @__PURE__ */ jsx("div", { className: "py-1 px-2 flex items-center gap-3", children: header }),
|
|
8395
|
+
children && /* @__PURE__ */ jsx("div", { className: "border-t-sm border-border1", children }),
|
|
8396
|
+
footer && /* @__PURE__ */ jsx("div", { className: "py-1 px-2 border-t-sm border-border1", children: footer })
|
|
8397
|
+
] });
|
|
8398
|
+
};
|
|
8399
|
+
|
|
8400
|
+
const LegacyWorkflowStatus = ({ stepId, pathStatus, path }) => {
|
|
8401
|
+
const status = pathStatus === "completed" ? "Completed" : stepId === path ? pathStatus.charAt(0).toUpperCase() + pathStatus.slice(1) : pathStatus === "executing" ? "Executing" : "Completed";
|
|
8402
|
+
return /* @__PURE__ */ jsx(
|
|
8403
|
+
WorkflowCard,
|
|
8404
|
+
{
|
|
8405
|
+
header: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
8406
|
+
/* @__PURE__ */ jsxs(Icon, { children: [
|
|
8407
|
+
status === "Completed" && /* @__PURE__ */ jsx(CheckIcon, { className: "text-accent1" }),
|
|
8408
|
+
status === "Failed" && /* @__PURE__ */ jsx(CrossIcon, { className: "text-accent2" }),
|
|
8409
|
+
status === "Executing" && /* @__PURE__ */ jsx(Loader2, { className: "text-icon3 animate-spin" })
|
|
8410
|
+
] }),
|
|
8411
|
+
/* @__PURE__ */ jsx(Txt, { as: "span", variant: "ui-lg", className: "text-icon6 font-medium", children: path })
|
|
8412
|
+
] })
|
|
8413
|
+
}
|
|
8414
|
+
);
|
|
8415
|
+
};
|
|
8416
|
+
|
|
8417
|
+
const WorkflowResult = ({ jsonResult, sanitizedJsonResult }) => {
|
|
8418
|
+
const { handleCopy } = useCopyToClipboard({ text: jsonResult });
|
|
8419
|
+
const [expanded, setExpanded] = useState(false);
|
|
8420
|
+
return /* @__PURE__ */ jsx(
|
|
8421
|
+
WorkflowCard,
|
|
8422
|
+
{
|
|
8423
|
+
header: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 justify-between w-full", children: [
|
|
8424
|
+
/* @__PURE__ */ jsxs(Txt, { variant: "ui-lg", className: "text-icon6 flex items-center gap-3 font-medium", children: [
|
|
8425
|
+
/* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(DeploymentIcon, {}) }),
|
|
8426
|
+
"Results"
|
|
8427
|
+
] }),
|
|
8428
|
+
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
8429
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
8430
|
+
"button",
|
|
8431
|
+
{
|
|
8432
|
+
className: "p-2 rounded-lg hover:bg-surface5 transition-colors duration-150 ease-in-out text-icon3 hover:text-icon6",
|
|
8433
|
+
onClick: () => handleCopy(),
|
|
8434
|
+
children: /* @__PURE__ */ jsx(Icon, { size: "sm", children: /* @__PURE__ */ jsx(CopyIcon, {}) })
|
|
8435
|
+
}
|
|
8436
|
+
) }),
|
|
8437
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: "Copy result" })
|
|
8438
|
+
] })
|
|
8439
|
+
] }),
|
|
8440
|
+
footer: /* @__PURE__ */ jsx(
|
|
8441
|
+
"button",
|
|
8442
|
+
{
|
|
8443
|
+
className: "w-full h-full text-center text-icon2 hover:text-icon6 text-ui-md",
|
|
8444
|
+
onClick: () => setExpanded((s) => !s),
|
|
8445
|
+
children: expanded ? "collapse" : "expand"
|
|
8446
|
+
}
|
|
8447
|
+
),
|
|
8448
|
+
children: expanded ? /* @__PURE__ */ jsx(CodeBlockDemo, { className: "w-full overflow-x-auto", code: sanitizedJsonResult || jsonResult, language: "json" }) : null
|
|
8449
|
+
}
|
|
8450
|
+
);
|
|
8451
|
+
};
|
|
8452
|
+
|
|
8453
|
+
function LegacyWorkflowTrigger({
|
|
8235
8454
|
workflowId,
|
|
8236
8455
|
baseUrl,
|
|
8237
8456
|
setRunId
|
|
8238
8457
|
}) {
|
|
8239
|
-
const { result, setResult, payload, setPayload } = useContext(WorkflowRunContext);
|
|
8240
|
-
const { isLoading, workflow } =
|
|
8241
|
-
const { createWorkflowRun, startWorkflowRun } = useExecuteWorkflow(baseUrl);
|
|
8242
|
-
const {
|
|
8243
|
-
|
|
8458
|
+
const { legacyResult: result, setLegacyResult: setResult, payload, setPayload } = useContext(WorkflowRunContext);
|
|
8459
|
+
const { isLoading, legacyWorkflow: workflow } = useLegacyWorkflow(workflowId, baseUrl);
|
|
8460
|
+
const { createLegacyWorkflowRun: createWorkflowRun, startLegacyWorkflowRun: startWorkflowRun } = useExecuteWorkflow(baseUrl);
|
|
8461
|
+
const {
|
|
8462
|
+
watchLegacyWorkflow: watchWorkflow,
|
|
8463
|
+
legacyWatchResult: watchResult,
|
|
8464
|
+
isWatchingLegacyWorkflow: isWatchingWorkflow
|
|
8465
|
+
} = useWatchWorkflow(baseUrl);
|
|
8466
|
+
const { resumeLegacyWorkflow: resumeWorkflow, isResumingLegacyWorkflow: isResumingWorkflow } = useResumeWorkflow(baseUrl);
|
|
8244
8467
|
const [suspendedSteps, setSuspendedSteps] = useState([]);
|
|
8245
8468
|
const [isRunning, setIsRunning] = useState(false);
|
|
8246
8469
|
const triggerSchema = workflow?.triggerSchema;
|
|
@@ -8271,7 +8494,7 @@ function WorkflowTrigger({
|
|
|
8271
8494
|
});
|
|
8272
8495
|
};
|
|
8273
8496
|
const watchResultToUse = result ?? watchResult;
|
|
8274
|
-
const workflowActivePaths = watchResultToUse?.activePaths ??
|
|
8497
|
+
const workflowActivePaths = watchResultToUse?.activePaths ?? {};
|
|
8275
8498
|
useEffect(() => {
|
|
8276
8499
|
setIsRunning(isWatchingWorkflow);
|
|
8277
8500
|
}, [isWatchingWorkflow]);
|
|
@@ -8299,50 +8522,34 @@ function WorkflowTrigger({
|
|
|
8299
8522
|
const isSuspendedSteps = suspendedSteps.length > 0;
|
|
8300
8523
|
const zodInputSchema = triggerSchema ? resolveSerializedZodOutput(jsonSchemaToZod(parse(triggerSchema))) : null;
|
|
8301
8524
|
const { sanitizedOutput, ...restResult } = result ?? {};
|
|
8302
|
-
|
|
8303
|
-
|
|
8304
|
-
|
|
8305
|
-
|
|
8306
|
-
|
|
8307
|
-
/* @__PURE__ */ jsx(Loader2, { className: "w-3 h-3 animate-spin text-mastra-el-accent" }),
|
|
8308
|
-
" Resuming workflow"
|
|
8309
|
-
] }) : /* @__PURE__ */ jsx(Fragment, {})
|
|
8310
|
-
] }),
|
|
8311
|
-
/* @__PURE__ */ jsx(
|
|
8312
|
-
DynamicForm,
|
|
8313
|
-
{
|
|
8314
|
-
schema: zodInputSchema,
|
|
8315
|
-
defaultValues: payload,
|
|
8316
|
-
isSubmitLoading: isWatchingWorkflow,
|
|
8317
|
-
onSubmit: (data) => {
|
|
8318
|
-
setPayload(data);
|
|
8319
|
-
handleExecuteWorkflow(data);
|
|
8320
|
-
}
|
|
8321
|
-
}
|
|
8322
|
-
)
|
|
8323
|
-
] }) : /* @__PURE__ */ jsxs("div", { className: "px-4 space-y-4", children: [
|
|
8324
|
-
isResumingWorkflow ? /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1", children: [
|
|
8325
|
-
/* @__PURE__ */ jsx(Loader2, { className: "w-3 h-3 animate-spin text-mastra-el-accent" }),
|
|
8326
|
-
" Resuming workflow"
|
|
8327
|
-
] }) : /* @__PURE__ */ jsx(Fragment, {}),
|
|
8328
|
-
/* @__PURE__ */ jsx(Button$1, { className: "w-full", disabled: isRunning, onClick: () => handleExecuteWorkflow(null), children: isRunning ? /* @__PURE__ */ jsx(Loader2, { className: "w-4 h-4 animate-spin" }) : "Trigger" })
|
|
8329
|
-
] }) }),
|
|
8330
|
-
Object.values(workflowActivePaths).length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
8331
|
-
/* @__PURE__ */ jsx(Text, { variant: "secondary", className: "px-4 text-mastra-el-3", size: "xs", children: "Status" }),
|
|
8332
|
-
/* @__PURE__ */ jsx("div", { className: "px-4 flex flex-col gap-4", children: Object.entries(workflowActivePaths)?.map(([stepId, { status: pathStatus, stepPath }]) => {
|
|
8333
|
-
return /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: stepPath?.map((path, idx) => {
|
|
8334
|
-
const status = pathStatus === "completed" ? "Completed" : stepId === path ? pathStatus.charAt(0).toUpperCase() + pathStatus.slice(1) : "Completed";
|
|
8335
|
-
const statusIcon = status === "Completed" ? /* @__PURE__ */ jsx("div", { className: "w-2 h-2 bg-green-500 rounded-full" }) : status === "Failed" ? /* @__PURE__ */ jsx("div", { className: "w-2 h-2 bg-red-500 rounded-full" }) : /* @__PURE__ */ jsx("div", { className: "w-2 h-2 bg-yellow-500 rounded-full animate-pulse" });
|
|
8336
|
-
return /* @__PURE__ */ jsx("div", { className: "flex flex-col overflow-hidden rounded-md border", children: /* @__PURE__ */ jsxs("div", { className: `flex items-center justify-between p-3`, children: [
|
|
8337
|
-
/* @__PURE__ */ jsx(Text, { variant: "secondary", className: "text-mastra-el-3", size: "xs", children: path.charAt(0).toUpperCase() + path.slice(1) }),
|
|
8338
|
-
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
|
|
8339
|
-
/* @__PURE__ */ jsx(Text, { variant: "secondary", className: "text-mastra-el-3", size: "xs", children: statusIcon }),
|
|
8340
|
-
status
|
|
8341
|
-
] })
|
|
8342
|
-
] }) }, idx);
|
|
8343
|
-
}) });
|
|
8344
|
-
}) })
|
|
8525
|
+
const hasWorkflowActivePaths = Object.values(workflowActivePaths).length > 0;
|
|
8526
|
+
return /* @__PURE__ */ jsx("div", { className: "h-full px-5 pt-3 pb-12", children: /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
8527
|
+
isResumingWorkflow && /* @__PURE__ */ jsxs("div", { className: "py-2 px-5 flex items-center gap-2 bg-surface5 -mx-5 -mt-5 border-b-sm border-border1", children: [
|
|
8528
|
+
/* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(Loader2, { className: "animate-spin text-icon6" }) }),
|
|
8529
|
+
/* @__PURE__ */ jsx(Txt, { children: "Resuming workflow" })
|
|
8345
8530
|
] }),
|
|
8531
|
+
!isSuspendedSteps && /* @__PURE__ */ jsx(Fragment, { children: zodInputSchema ? /* @__PURE__ */ jsx(
|
|
8532
|
+
DynamicForm,
|
|
8533
|
+
{
|
|
8534
|
+
schema: zodInputSchema,
|
|
8535
|
+
defaultValues: payload,
|
|
8536
|
+
isSubmitLoading: isWatchingWorkflow,
|
|
8537
|
+
submitButtonLabel: "Run",
|
|
8538
|
+
onSubmit: (data) => {
|
|
8539
|
+
setPayload(data);
|
|
8540
|
+
handleExecuteWorkflow(data);
|
|
8541
|
+
}
|
|
8542
|
+
}
|
|
8543
|
+
) : /* @__PURE__ */ jsx(
|
|
8544
|
+
Button,
|
|
8545
|
+
{
|
|
8546
|
+
className: "w-full",
|
|
8547
|
+
variant: "light",
|
|
8548
|
+
disabled: isRunning,
|
|
8549
|
+
onClick: () => handleExecuteWorkflow(null),
|
|
8550
|
+
children: isRunning ? /* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(Loader2, { className: "animate-spin" }) }) : "Trigger"
|
|
8551
|
+
}
|
|
8552
|
+
) }),
|
|
8346
8553
|
isSuspendedSteps && suspendedSteps?.map((step) => {
|
|
8347
8554
|
const stepDefinition = workflow.steps[step.stepId];
|
|
8348
8555
|
const stepSchema = stepDefinition?.inputSchema ? resolveSerializedZodOutput(jsonSchemaToZod(parse(stepDefinition.inputSchema))) : z.record(z.string(), z.any());
|
|
@@ -8374,29 +8581,23 @@ function WorkflowTrigger({
|
|
|
8374
8581
|
)
|
|
8375
8582
|
] });
|
|
8376
8583
|
}),
|
|
8377
|
-
|
|
8378
|
-
/* @__PURE__ */ jsx(
|
|
8379
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-
|
|
8380
|
-
|
|
8381
|
-
|
|
8382
|
-
|
|
8383
|
-
|
|
8384
|
-
|
|
8385
|
-
|
|
8386
|
-
/* @__PURE__ */ jsx(
|
|
8387
|
-
|
|
8388
|
-
{
|
|
8389
|
-
className: "w-full overflow-x-auto",
|
|
8390
|
-
code: sanitizedOutput || JSON.stringify(restResult, null, 2),
|
|
8391
|
-
language: "json"
|
|
8392
|
-
}
|
|
8393
|
-
)
|
|
8584
|
+
hasWorkflowActivePaths && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
8585
|
+
/* @__PURE__ */ jsx("hr", { className: "border-border1 border-sm my-5" }),
|
|
8586
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-4", children: Object.entries(workflowActivePaths)?.map(([stepId, { status: pathStatus, stepPath }]) => {
|
|
8587
|
+
return /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: stepPath?.map((path, idx) => {
|
|
8588
|
+
return /* @__PURE__ */ jsx(LegacyWorkflowStatus, { stepId, pathStatus, path }, idx);
|
|
8589
|
+
}) }, stepId);
|
|
8590
|
+
}) })
|
|
8591
|
+
] }),
|
|
8592
|
+
result && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
8593
|
+
/* @__PURE__ */ jsx("hr", { className: "border-border1 border-sm my-5" }),
|
|
8594
|
+
/* @__PURE__ */ jsx(WorkflowResult, { sanitizedJsonResult: sanitizedOutput, jsonResult: JSON.stringify(restResult, null, 2) })
|
|
8394
8595
|
] })
|
|
8395
8596
|
] }) });
|
|
8396
8597
|
}
|
|
8397
8598
|
|
|
8398
|
-
function
|
|
8399
|
-
const { nodes: initialNodes, edges: initialEdges } =
|
|
8599
|
+
function WorkflowNestedGraph({ stepGraph, open }) {
|
|
8600
|
+
const { nodes: initialNodes, edges: initialEdges } = constructNodesAndEdges({
|
|
8400
8601
|
stepGraph
|
|
8401
8602
|
});
|
|
8402
8603
|
const [isMounted, setIsMounted] = useState(false);
|
|
@@ -8407,7 +8608,7 @@ function VNextWorkflowNestedGraph({ stepGraph, open }) {
|
|
|
8407
8608
|
"condition-node": WorkflowConditionNode,
|
|
8408
8609
|
"after-node": WorkflowAfterNode,
|
|
8409
8610
|
"loop-result-node": WorkflowLoopResultNode,
|
|
8410
|
-
"nested-node":
|
|
8611
|
+
"nested-node": WorkflowNestedNode
|
|
8411
8612
|
};
|
|
8412
8613
|
useEffect(() => {
|
|
8413
8614
|
if (open) {
|
|
@@ -8434,10 +8635,10 @@ function VNextWorkflowNestedGraph({ stepGraph, open }) {
|
|
|
8434
8635
|
) : /* @__PURE__ */ jsx("div", { className: "w-full h-full flex items-center justify-center", children: /* @__PURE__ */ jsx(Spinner, {}) }) });
|
|
8435
8636
|
}
|
|
8436
8637
|
|
|
8437
|
-
const
|
|
8638
|
+
const WorkflowNestedGraphContext = createContext(
|
|
8438
8639
|
{}
|
|
8439
8640
|
);
|
|
8440
|
-
function
|
|
8641
|
+
function WorkflowNestedGraphProvider({ children }) {
|
|
8441
8642
|
const [stepGraph, setStepGraph] = useState(null);
|
|
8442
8643
|
const [parentStepGraphList, setParentStepGraphList] = useState([]);
|
|
8443
8644
|
const [openDialog, setOpenDialog] = useState(false);
|
|
@@ -8475,7 +8676,7 @@ function VNextWorkflowNestedGraphProvider({ children }) {
|
|
|
8475
8676
|
}, 500);
|
|
8476
8677
|
};
|
|
8477
8678
|
return /* @__PURE__ */ jsxs(
|
|
8478
|
-
|
|
8679
|
+
WorkflowNestedGraphContext.Provider,
|
|
8479
8680
|
{
|
|
8480
8681
|
value: {
|
|
8481
8682
|
showNestedGraph,
|
|
@@ -8491,16 +8692,16 @@ function VNextWorkflowNestedGraphProvider({ children }) {
|
|
|
8491
8692
|
" workflow"
|
|
8492
8693
|
] })
|
|
8493
8694
|
] }),
|
|
8494
|
-
switching ? /* @__PURE__ */ jsx("div", { className: "w-full h-full flex items-center justify-center", children: /* @__PURE__ */ jsx(Spinner, {}) }) : /* @__PURE__ */ jsx(ReactFlowProvider, { children: /* @__PURE__ */ jsx(
|
|
8695
|
+
switching ? /* @__PURE__ */ jsx("div", { className: "w-full h-full flex items-center justify-center", children: /* @__PURE__ */ jsx(Spinner, {}) }) : /* @__PURE__ */ jsx(ReactFlowProvider, { children: /* @__PURE__ */ jsx(WorkflowNestedGraph, { stepGraph, open: openDialog }) })
|
|
8495
8696
|
] }) }) })
|
|
8496
8697
|
]
|
|
8497
8698
|
}
|
|
8498
8699
|
);
|
|
8499
8700
|
}
|
|
8500
8701
|
|
|
8501
|
-
function
|
|
8702
|
+
function WorkflowNestedNode({ data }) {
|
|
8502
8703
|
const { label, withoutTopHandle, withoutBottomHandle, stepGraph } = data;
|
|
8503
|
-
const { showNestedGraph } = useContext(
|
|
8704
|
+
const { showNestedGraph } = useContext(WorkflowNestedGraphContext);
|
|
8504
8705
|
return /* @__PURE__ */ jsxs("div", { className: cn("bg-[rgba(29,29,29,0.5)] rounded-md h-full overflow-scroll w-[274px]"), children: [
|
|
8505
8706
|
!withoutTopHandle && /* @__PURE__ */ jsx(Handle, { type: "target", position: Position.Top, style: { visibility: "hidden" } }),
|
|
8506
8707
|
/* @__PURE__ */ jsx("div", { className: "p-2 cursor-pointer", onClick: () => showNestedGraph({ label, stepGraph }), children: /* @__PURE__ */ jsxs("div", { className: "text-sm bg-mastra-bg-9 flex items-center gap-1.5 rounded-sm p-2 cursor-pointer", children: [
|
|
@@ -8511,8 +8712,8 @@ function VNextWorkflowNestedNode({ data }) {
|
|
|
8511
8712
|
] });
|
|
8512
8713
|
}
|
|
8513
8714
|
|
|
8514
|
-
function
|
|
8515
|
-
const { nodes: initialNodes, edges: initialEdges } =
|
|
8715
|
+
function WorkflowGraphInner({ workflow }) {
|
|
8716
|
+
const { nodes: initialNodes, edges: initialEdges } = constructNodesAndEdges(workflow);
|
|
8516
8717
|
const [nodes, _, onNodesChange] = useNodesState(initialNodes);
|
|
8517
8718
|
const [edges] = useEdgesState(initialEdges);
|
|
8518
8719
|
const nodeTypes = {
|
|
@@ -8520,7 +8721,7 @@ function VNextWorkflowGraphInner({ workflow }) {
|
|
|
8520
8721
|
"condition-node": WorkflowConditionNode,
|
|
8521
8722
|
"after-node": WorkflowAfterNode,
|
|
8522
8723
|
"loop-result-node": WorkflowLoopResultNode,
|
|
8523
|
-
"nested-node":
|
|
8724
|
+
"nested-node": WorkflowNestedNode
|
|
8524
8725
|
};
|
|
8525
8726
|
return /* @__PURE__ */ jsx("div", { className: "w-full h-full", children: /* @__PURE__ */ jsxs(
|
|
8526
8727
|
ReactFlow,
|
|
@@ -8542,12 +8743,12 @@ function VNextWorkflowGraphInner({ workflow }) {
|
|
|
8542
8743
|
) });
|
|
8543
8744
|
}
|
|
8544
8745
|
|
|
8545
|
-
function
|
|
8546
|
-
const {
|
|
8746
|
+
function WorkflowGraph({ workflowId, baseUrl }) {
|
|
8747
|
+
const { workflow, isLoading } = useWorkflow(workflowId, baseUrl);
|
|
8547
8748
|
if (isLoading) {
|
|
8548
8749
|
return /* @__PURE__ */ jsx("div", { className: "p-4", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-[600px]" }) });
|
|
8549
8750
|
}
|
|
8550
|
-
if (!
|
|
8751
|
+
if (!workflow) {
|
|
8551
8752
|
return /* @__PURE__ */ jsx("div", { className: "grid h-full place-items-center", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-2", children: [
|
|
8552
8753
|
/* @__PURE__ */ jsx(AlertCircleIcon, {}),
|
|
8553
8754
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
@@ -8557,43 +8758,60 @@ function VNextWorkflowGraph({ workflowId, baseUrl }) {
|
|
|
8557
8758
|
] })
|
|
8558
8759
|
] }) });
|
|
8559
8760
|
}
|
|
8560
|
-
return /* @__PURE__ */ jsx(
|
|
8761
|
+
return /* @__PURE__ */ jsx(WorkflowNestedGraphProvider, { children: /* @__PURE__ */ jsx(ReactFlowProvider, { children: /* @__PURE__ */ jsx(WorkflowGraphInner, { workflow }) }) });
|
|
8561
8762
|
}
|
|
8562
8763
|
|
|
8563
|
-
|
|
8764
|
+
const WorkflowStatus = ({ stepId, status }) => {
|
|
8765
|
+
return /* @__PURE__ */ jsx(
|
|
8766
|
+
WorkflowCard,
|
|
8767
|
+
{
|
|
8768
|
+
header: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
8769
|
+
/* @__PURE__ */ jsxs(Icon, { children: [
|
|
8770
|
+
status === "success" && /* @__PURE__ */ jsx(CheckIcon, { className: "text-accent1" }),
|
|
8771
|
+
status === "failed" && /* @__PURE__ */ jsx(CrossIcon, { className: "text-accent2" }),
|
|
8772
|
+
status === "suspended" && /* @__PURE__ */ jsx(CirclePause, { className: "text-icon3" }),
|
|
8773
|
+
status === "running" && /* @__PURE__ */ jsx(Loader2, { className: "text-icon3 animate-spin" })
|
|
8774
|
+
] }),
|
|
8775
|
+
/* @__PURE__ */ jsx(Txt, { as: "span", variant: "ui-lg", className: "text-icon6 font-medium", children: stepId.charAt(0).toUpperCase() + stepId.slice(1) })
|
|
8776
|
+
] })
|
|
8777
|
+
}
|
|
8778
|
+
);
|
|
8779
|
+
};
|
|
8780
|
+
|
|
8781
|
+
function WorkflowTrigger({
|
|
8564
8782
|
workflowId,
|
|
8565
8783
|
baseUrl,
|
|
8566
8784
|
setRunId
|
|
8567
8785
|
}) {
|
|
8568
8786
|
const { runtimeContext } = usePlaygroundStore();
|
|
8569
|
-
const {
|
|
8570
|
-
const { isLoading,
|
|
8571
|
-
const {
|
|
8572
|
-
const {
|
|
8573
|
-
const {
|
|
8787
|
+
const { result, setResult, payload, setPayload } = useContext(WorkflowRunContext);
|
|
8788
|
+
const { isLoading, workflow } = useWorkflow(workflowId, baseUrl);
|
|
8789
|
+
const { createWorkflowRun, startWorkflowRun } = useExecuteWorkflow(baseUrl);
|
|
8790
|
+
const { watchWorkflow, watchResult, isWatchingWorkflow } = useWatchWorkflow(baseUrl);
|
|
8791
|
+
const { resumeWorkflow, isResumingWorkflow } = useResumeWorkflow(baseUrl);
|
|
8574
8792
|
const [suspendedSteps, setSuspendedSteps] = useState([]);
|
|
8575
8793
|
const [isRunning, setIsRunning] = useState(false);
|
|
8576
|
-
const triggerSchema =
|
|
8794
|
+
const triggerSchema = workflow?.inputSchema;
|
|
8577
8795
|
const handleExecuteWorkflow = async (data) => {
|
|
8578
8796
|
try {
|
|
8579
|
-
if (!
|
|
8797
|
+
if (!workflow) return;
|
|
8580
8798
|
setIsRunning(true);
|
|
8581
|
-
|
|
8582
|
-
const { runId } = await
|
|
8799
|
+
setResult(null);
|
|
8800
|
+
const { runId } = await createWorkflowRun({ workflowId });
|
|
8583
8801
|
setRunId?.(runId);
|
|
8584
|
-
|
|
8585
|
-
|
|
8802
|
+
watchWorkflow({ workflowId, runId });
|
|
8803
|
+
startWorkflowRun({ workflowId, runId, input: data, runtimeContext });
|
|
8586
8804
|
} catch (err) {
|
|
8587
8805
|
setIsRunning(false);
|
|
8588
8806
|
toast.error("Error executing workflow");
|
|
8589
8807
|
}
|
|
8590
8808
|
};
|
|
8591
8809
|
const handleResumeWorkflow = async (step) => {
|
|
8592
|
-
if (!
|
|
8810
|
+
if (!workflow) return;
|
|
8593
8811
|
const { stepId, runId: prevRunId, resumeData } = step;
|
|
8594
|
-
const { runId } = await
|
|
8595
|
-
|
|
8596
|
-
await
|
|
8812
|
+
const { runId } = await createWorkflowRun({ workflowId, prevRunId });
|
|
8813
|
+
watchWorkflow({ workflowId, runId });
|
|
8814
|
+
await resumeWorkflow({
|
|
8597
8815
|
step: stepId,
|
|
8598
8816
|
runId,
|
|
8599
8817
|
resumeData,
|
|
@@ -8601,78 +8819,65 @@ function VNextWorkflowTrigger({
|
|
|
8601
8819
|
runtimeContext
|
|
8602
8820
|
});
|
|
8603
8821
|
};
|
|
8604
|
-
const watchResultToUse =
|
|
8822
|
+
const watchResultToUse = result ?? watchResult;
|
|
8605
8823
|
const workflowActivePaths = watchResultToUse?.payload?.workflowState?.steps ?? {};
|
|
8606
8824
|
useEffect(() => {
|
|
8607
|
-
setIsRunning(
|
|
8608
|
-
}, [
|
|
8825
|
+
setIsRunning(isWatchingWorkflow);
|
|
8826
|
+
}, [isWatchingWorkflow]);
|
|
8609
8827
|
useEffect(() => {
|
|
8610
|
-
if (!watchResultToUse?.payload?.workflowState?.steps || !
|
|
8828
|
+
if (!watchResultToUse?.payload?.workflowState?.steps || !result?.runId) return;
|
|
8611
8829
|
const suspended = Object.entries(watchResultToUse.payload.workflowState.steps).filter(([_, { status }]) => status === "suspended").map(([stepId, { payload: payload2 }]) => ({
|
|
8612
8830
|
stepId,
|
|
8613
|
-
runId:
|
|
8831
|
+
runId: result.runId,
|
|
8614
8832
|
suspendPayload: payload2
|
|
8615
8833
|
}));
|
|
8616
8834
|
setSuspendedSteps(suspended);
|
|
8617
|
-
}, [watchResultToUse,
|
|
8835
|
+
}, [watchResultToUse, result]);
|
|
8618
8836
|
useEffect(() => {
|
|
8619
|
-
if (
|
|
8620
|
-
|
|
8837
|
+
if (watchResult) {
|
|
8838
|
+
setResult(watchResult);
|
|
8621
8839
|
}
|
|
8622
|
-
}, [
|
|
8840
|
+
}, [watchResult]);
|
|
8623
8841
|
if (isLoading) {
|
|
8624
8842
|
return /* @__PURE__ */ jsx(ScrollArea, { className: "h-[calc(100vh-126px)] pt-2 px-4 pb-4 text-xs", children: /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
8625
8843
|
/* @__PURE__ */ jsx(Skeleton, { className: "h-10" }),
|
|
8626
8844
|
/* @__PURE__ */ jsx(Skeleton, { className: "h-10" })
|
|
8627
8845
|
] }) });
|
|
8628
8846
|
}
|
|
8629
|
-
if (!
|
|
8847
|
+
if (!workflow) return null;
|
|
8630
8848
|
const isSuspendedSteps = suspendedSteps.length > 0;
|
|
8631
8849
|
const zodInputSchema = triggerSchema ? resolveSerializedZodOutput(jsonSchemaToZod(parse(triggerSchema))) : null;
|
|
8632
|
-
const { sanitizedOutput, ...restResult } =
|
|
8633
|
-
|
|
8634
|
-
|
|
8635
|
-
|
|
8636
|
-
|
|
8637
|
-
|
|
8638
|
-
/* @__PURE__ */ jsx(Loader2, { className: "w-3 h-3 animate-spin text-mastra-el-accent" }),
|
|
8639
|
-
" Resuming workflow"
|
|
8640
|
-
] }) : /* @__PURE__ */ jsx(Fragment, {})
|
|
8641
|
-
] }),
|
|
8642
|
-
/* @__PURE__ */ jsx(
|
|
8643
|
-
DynamicForm,
|
|
8644
|
-
{
|
|
8645
|
-
schema: zodInputSchema,
|
|
8646
|
-
defaultValues: payload,
|
|
8647
|
-
isSubmitLoading: isWatchingVNextWorkflow,
|
|
8648
|
-
onSubmit: (data) => {
|
|
8649
|
-
setPayload(data);
|
|
8650
|
-
handleExecuteWorkflow(data);
|
|
8651
|
-
}
|
|
8652
|
-
}
|
|
8653
|
-
)
|
|
8654
|
-
] }) : /* @__PURE__ */ jsxs("div", { className: "px-4 space-y-4", children: [
|
|
8655
|
-
isResumingVNextWorkflow ? /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1", children: [
|
|
8656
|
-
/* @__PURE__ */ jsx(Loader2, { className: "w-3 h-3 animate-spin text-mastra-el-accent" }),
|
|
8657
|
-
" Resuming workflow"
|
|
8658
|
-
] }) : /* @__PURE__ */ jsx(Fragment, {}),
|
|
8659
|
-
/* @__PURE__ */ jsx(Button$1, { className: "w-full", disabled: isRunning, onClick: () => handleExecuteWorkflow(null), children: isRunning ? /* @__PURE__ */ jsx(Loader2, { className: "w-4 h-4 animate-spin" }) : "Trigger" })
|
|
8660
|
-
] }) }),
|
|
8661
|
-
Object.values(workflowActivePaths).length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
8662
|
-
/* @__PURE__ */ jsx(Text, { variant: "secondary", className: "px-4 text-mastra-el-3", size: "xs", children: "Status" }),
|
|
8663
|
-
/* @__PURE__ */ jsx("div", { className: "px-4 flex flex-col gap-4", children: Object.entries(workflowActivePaths)?.filter(([key, _]) => key !== "input" && !key.endsWith(".input"))?.map(([stepId, { status }]) => {
|
|
8664
|
-
const statusIcon = status === "success" ? /* @__PURE__ */ jsx("div", { className: "w-2 h-2 bg-green-500 rounded-full" }) : status === "failed" ? /* @__PURE__ */ jsx("div", { className: "w-2 h-2 bg-red-500 rounded-full" }) : /* @__PURE__ */ jsx("div", { className: "w-2 h-2 bg-yellow-500 rounded-full animate-pulse" });
|
|
8665
|
-
return /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: /* @__PURE__ */ jsx("div", { className: "flex flex-col overflow-hidden rounded-md border", children: /* @__PURE__ */ jsxs("div", { className: `flex items-center justify-between p-3`, children: [
|
|
8666
|
-
/* @__PURE__ */ jsx(Text, { variant: "secondary", className: "text-mastra-el-3", size: "xs", children: stepId.charAt(0).toUpperCase() + stepId.slice(1) }),
|
|
8667
|
-
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2 capitalize", children: [
|
|
8668
|
-
/* @__PURE__ */ jsx(Text, { variant: "secondary", className: "text-mastra-el-3", size: "xs", children: statusIcon }),
|
|
8669
|
-
status
|
|
8670
|
-
] })
|
|
8671
|
-
] }) }, stepId) });
|
|
8672
|
-
}) })
|
|
8850
|
+
const { sanitizedOutput, ...restResult } = result ?? {};
|
|
8851
|
+
const hasWorkflowActivePaths = Object.values(workflowActivePaths).length > 0;
|
|
8852
|
+
return /* @__PURE__ */ jsx("div", { className: "h-full px-5 pt-3 pb-12", children: /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
8853
|
+
isResumingWorkflow && /* @__PURE__ */ jsxs("div", { className: "py-2 px-5 flex items-center gap-2 bg-surface5 -mx-5 -mt-5 border-b-sm border-border1", children: [
|
|
8854
|
+
/* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(Loader2, { className: "animate-spin text-icon6" }) }),
|
|
8855
|
+
/* @__PURE__ */ jsx(Txt, { children: "Resuming workflow" })
|
|
8673
8856
|
] }),
|
|
8674
|
-
!
|
|
8675
|
-
|
|
8857
|
+
!isSuspendedSteps && /* @__PURE__ */ jsx(Fragment, { children: zodInputSchema ? /* @__PURE__ */ jsx(
|
|
8858
|
+
DynamicForm,
|
|
8859
|
+
{
|
|
8860
|
+
schema: zodInputSchema,
|
|
8861
|
+
defaultValues: payload,
|
|
8862
|
+
isSubmitLoading: isWatchingWorkflow,
|
|
8863
|
+
submitButtonLabel: "Run",
|
|
8864
|
+
onSubmit: (data) => {
|
|
8865
|
+
setPayload(data);
|
|
8866
|
+
handleExecuteWorkflow(data);
|
|
8867
|
+
}
|
|
8868
|
+
}
|
|
8869
|
+
) : /* @__PURE__ */ jsx(
|
|
8870
|
+
Button,
|
|
8871
|
+
{
|
|
8872
|
+
className: "w-full",
|
|
8873
|
+
variant: "light",
|
|
8874
|
+
disabled: isRunning,
|
|
8875
|
+
onClick: () => handleExecuteWorkflow(null),
|
|
8876
|
+
children: isRunning ? /* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(Loader2, { className: "animate-spin" }) }) : "Trigger"
|
|
8877
|
+
}
|
|
8878
|
+
) }),
|
|
8879
|
+
!isWatchingWorkflow && isSuspendedSteps && suspendedSteps?.map((step) => {
|
|
8880
|
+
const stepDefinition = workflow.steps[step.stepId];
|
|
8676
8881
|
const stepSchema = stepDefinition?.resumeSchema ? resolveSerializedZodOutput(jsonSchemaToZod(parse(stepDefinition.resumeSchema))) : z.record(z.string(), z.any());
|
|
8677
8882
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col px-4", children: [
|
|
8678
8883
|
/* @__PURE__ */ jsx(Text, { variant: "secondary", className: "text-mastra-el-3", size: "xs", children: step.stepId }),
|
|
@@ -8688,7 +8893,7 @@ function VNextWorkflowTrigger({
|
|
|
8688
8893
|
DynamicForm,
|
|
8689
8894
|
{
|
|
8690
8895
|
schema: stepSchema,
|
|
8691
|
-
isSubmitLoading:
|
|
8896
|
+
isSubmitLoading: isResumingWorkflow,
|
|
8692
8897
|
submitButtonLabel: "Resume",
|
|
8693
8898
|
onSubmit: (data) => {
|
|
8694
8899
|
handleResumeWorkflow({
|
|
@@ -8702,23 +8907,18 @@ function VNextWorkflowTrigger({
|
|
|
8702
8907
|
)
|
|
8703
8908
|
] });
|
|
8704
8909
|
}),
|
|
8705
|
-
|
|
8706
|
-
/* @__PURE__ */ jsx(
|
|
8707
|
-
/* @__PURE__ */
|
|
8708
|
-
|
|
8709
|
-
{
|
|
8710
|
-
|
|
8711
|
-
|
|
8712
|
-
|
|
8713
|
-
|
|
8714
|
-
|
|
8715
|
-
|
|
8716
|
-
|
|
8717
|
-
className: "w-full overflow-x-auto",
|
|
8718
|
-
code: sanitizedOutput || JSON.stringify(restResult, null, 2),
|
|
8719
|
-
language: "json"
|
|
8720
|
-
}
|
|
8721
|
-
)
|
|
8910
|
+
hasWorkflowActivePaths && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
8911
|
+
/* @__PURE__ */ jsx("hr", { className: "border-border1 border-sm my-5" }),
|
|
8912
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
8913
|
+
/* @__PURE__ */ jsx(Text, { variant: "secondary", className: "px-4 text-mastra-el-3", size: "xs", children: "Status" }),
|
|
8914
|
+
/* @__PURE__ */ jsx("div", { className: "px-4 flex flex-col gap-4", children: Object.entries(workflowActivePaths)?.filter(([key, _]) => key !== "input" && !key.endsWith(".input"))?.map(([stepId, { status }]) => {
|
|
8915
|
+
return /* @__PURE__ */ jsx(WorkflowStatus, { stepId, status });
|
|
8916
|
+
}) })
|
|
8917
|
+
] })
|
|
8918
|
+
] }),
|
|
8919
|
+
result && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
8920
|
+
/* @__PURE__ */ jsx("hr", { className: "border-border1 border-sm my-5" }),
|
|
8921
|
+
/* @__PURE__ */ jsx(WorkflowResult, { sanitizedJsonResult: sanitizedOutput, jsonResult: JSON.stringify(restResult, null, 2) })
|
|
8722
8922
|
] })
|
|
8723
8923
|
] }) });
|
|
8724
8924
|
}
|
|
@@ -8732,7 +8932,8 @@ const DataTable = ({
|
|
|
8732
8932
|
getRowId,
|
|
8733
8933
|
selectedRowId,
|
|
8734
8934
|
isLoading,
|
|
8735
|
-
emptyText
|
|
8935
|
+
emptyText,
|
|
8936
|
+
onClick
|
|
8736
8937
|
}) => {
|
|
8737
8938
|
const [sorting, setSorting] = useState([]);
|
|
8738
8939
|
const [{ pageIndex, pageSize }, setPagination] = useState({
|
|
@@ -8774,7 +8975,16 @@ const DataTable = ({
|
|
|
8774
8975
|
const meta = header.column.columnDef.meta;
|
|
8775
8976
|
return /* @__PURE__ */ jsx(Th, { style: { width: meta?.width || size || "auto" }, children: header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext()) }, header.id);
|
|
8776
8977
|
}) }),
|
|
8777
|
-
/* @__PURE__ */ jsx(Tbody, { children: isLoading ? /* @__PURE__ */ jsx(Fragment, { children: Array.from({ length: 3 }).map((_, rowIndex) => /* @__PURE__ */ jsx(Row, {
|
|
8978
|
+
/* @__PURE__ */ jsx(Tbody, { children: isLoading ? /* @__PURE__ */ jsx(Fragment, { children: Array.from({ length: 3 }).map((_, rowIndex) => /* @__PURE__ */ jsx(Row, { onClick: () => {
|
|
8979
|
+
}, children: Array.from({ length: columns.length }).map((_2, cellIndex) => /* @__PURE__ */ jsx(Cell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-1/2" }) }, `row-${rowIndex}-cell-${cellIndex}`)) }, rowIndex)) }) : rows?.length > 0 ? rows.map((row) => /* @__PURE__ */ jsx(
|
|
8980
|
+
Row,
|
|
8981
|
+
{
|
|
8982
|
+
"data-state": (row.getIsSelected() || row.id === selectedRowId) && "selected",
|
|
8983
|
+
onClick: () => onClick?.(row.original),
|
|
8984
|
+
children: row.getVisibleCells().map((cell) => flexRender(cell.column.columnDef.cell, cell.getContext()))
|
|
8985
|
+
},
|
|
8986
|
+
row.id
|
|
8987
|
+
)) : emptyNode })
|
|
8778
8988
|
] }),
|
|
8779
8989
|
pagination && /* @__PURE__ */ jsxs("div", { className: "mt-4 flex items-center justify-between px-2", children: [
|
|
8780
8990
|
/* @__PURE__ */ jsxs("div", { className: "text-muted-foreground text-sm", children: [
|
|
@@ -8911,6 +9121,41 @@ const DarkLogo = (props) => /* @__PURE__ */ jsxs("svg", { width: "100", height:
|
|
|
8911
9121
|
)
|
|
8912
9122
|
] });
|
|
8913
9123
|
|
|
9124
|
+
const Entity = ({ children, className, onClick }) => {
|
|
9125
|
+
return /* @__PURE__ */ jsx(
|
|
9126
|
+
"div",
|
|
9127
|
+
{
|
|
9128
|
+
tabIndex: onClick ? 0 : void 0,
|
|
9129
|
+
onKeyDown: (e) => {
|
|
9130
|
+
if (!onClick) return;
|
|
9131
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
9132
|
+
e.preventDefault();
|
|
9133
|
+
onClick?.();
|
|
9134
|
+
}
|
|
9135
|
+
},
|
|
9136
|
+
className: clsx(
|
|
9137
|
+
"flex gap-3 group/entity bg-surface3 rounded-lg border-sm border-border1 py-3 px-4",
|
|
9138
|
+
onClick && "cursor-pointer hover:bg-surface4 transition-all",
|
|
9139
|
+
className
|
|
9140
|
+
),
|
|
9141
|
+
onClick,
|
|
9142
|
+
children
|
|
9143
|
+
}
|
|
9144
|
+
);
|
|
9145
|
+
};
|
|
9146
|
+
const EntityIcon = ({ children, className }) => {
|
|
9147
|
+
return /* @__PURE__ */ jsx(Icon, { size: "lg", className: clsx("text-icon3 mt-1", className), children });
|
|
9148
|
+
};
|
|
9149
|
+
const EntityName = ({ children, className }) => {
|
|
9150
|
+
return /* @__PURE__ */ jsx(Txt, { as: "p", variant: "ui-lg", className: clsx("text-icon6 font-medium", className), children });
|
|
9151
|
+
};
|
|
9152
|
+
const EntityDescription = ({ children, className }) => {
|
|
9153
|
+
return /* @__PURE__ */ jsx(Txt, { as: "p", variant: "ui-sm", className: clsx("text-icon3", className), children });
|
|
9154
|
+
};
|
|
9155
|
+
const EntityContent = ({ children, className }) => {
|
|
9156
|
+
return /* @__PURE__ */ jsx("div", { className, children });
|
|
9157
|
+
};
|
|
9158
|
+
|
|
8914
9159
|
function usePolling({
|
|
8915
9160
|
fetchFn,
|
|
8916
9161
|
interval = 3e3,
|
|
@@ -9065,5 +9310,5 @@ const useTraces = (componentName, baseUrl, isWorkflow = false) => {
|
|
|
9065
9310
|
return { traces, firstCallLoading, error };
|
|
9066
9311
|
};
|
|
9067
9312
|
|
|
9068
|
-
export { AgentChat, AgentCoinIcon, AgentContext, AgentEvals, AgentIcon, AgentProvider, AgentTraces, AiIcon, ApiIcon, Badge$1 as Badge, BranchIcon, Breadcrumb, Button, Cell, CheckIcon, ChevronIcon, CommitIcon, CrossIcon, Crumb, DarkLogo, DataTable, DateTimeCell, DbIcon, DebugIcon, DeploymentIcon, DividerIcon, DocsIcon, DynamicForm, EntryCell, EnvIcon, EvaluatorCoinIcon, FiltersIcon, GithubCoinIcon, GithubIcon, GoogleIcon, Header, HeaderAction, HeaderGroup, HeaderTitle, HomeIcon, Icon, InfoIcon, JudgeIcon, LatencyIcon, LogsIcon, MastraResizablePanel, MemoryIcon, NetworkChat, NetworkContext, NetworkProvider, OpenAIIcon, PromptIcon, RepoIcon, Row, ScoreIcon, SettingsIcon, SlashIcon, Table, Tbody, Th, Thead, ThreadDeleteButton, ThreadItem, ThreadLink, ThreadList, Threads, ToolsIcon, TraceContext, TraceIcon, TraceProvider, TsIcon, Txt, TxtCell, UnitCell,
|
|
9313
|
+
export { AgentChat, AgentCoinIcon, AgentContext, AgentEvals, AgentIcon, AgentProvider, AgentTraces, AiIcon, ApiIcon, Badge$1 as Badge, BranchIcon, Breadcrumb, Button, Cell, CheckIcon, ChevronIcon, CommitIcon, CrossIcon, Crumb, DarkLogo, DataTable, DateTimeCell, DbIcon, DebugIcon, DeploymentIcon, DividerIcon, DocsIcon, DynamicForm, Entity, EntityContent, EntityDescription, EntityIcon, EntityName, EntryCell, EnvIcon, EvaluatorCoinIcon, FiltersIcon, GithubCoinIcon, GithubIcon, GoogleIcon, Header, HeaderAction, HeaderGroup, HeaderTitle, HomeIcon, Icon, InfoIcon, JudgeIcon, LatencyIcon, LegacyWorkflowGraph, LegacyWorkflowTrigger, LogsIcon, MastraResizablePanel, MemoryIcon, NetworkChat, NetworkContext, NetworkProvider, OpenAIIcon, PromptIcon, RepoIcon, Row, ScoreIcon, SettingsIcon, SlashIcon, Table, Tbody, Th, Thead, ThreadDeleteButton, ThreadItem, ThreadLink, ThreadList, Threads, ToolsIcon, TraceContext, TraceIcon, TraceProvider, TsIcon, Txt, TxtCell, UnitCell, VariablesIcon, WorkflowCoinIcon, WorkflowGraph, WorkflowIcon, WorkflowRunContext, WorkflowRunProvider, WorkflowTraces, WorkflowTrigger, refineTraces, usePlaygroundStore, usePolling, useTraces };
|
|
9069
9314
|
//# sourceMappingURL=index.es.js.map
|