@mastra/playground-ui 5.1.8 → 5.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{colors-CBG_Mm7P.js → colors-BauMYA7t.js} +3 -2
- package/dist/colors-BauMYA7t.js.map +1 -0
- package/dist/{colors-Du4i-E0i.cjs → colors-BjoU9dWU.cjs} +3 -2
- package/dist/colors-BjoU9dWU.cjs.map +1 -0
- package/dist/index.cjs.js +826 -298
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +818 -296
- package/dist/index.es.js.map +1 -1
- package/dist/src/components/ui/entry.d.ts +7 -0
- package/dist/src/components/ui/radio-group.d.ts +5 -0
- package/dist/src/domains/agents/components/agent-advanced-settings.d.ts +1 -0
- package/dist/src/domains/agents/components/agent-model-settings.d.ts +1 -0
- package/dist/src/domains/agents/context/agent-context.d.ts +18 -0
- package/dist/src/domains/agents/hooks/use-agent-model-settings-state.d.ts +15 -0
- package/dist/src/domains/agents/index.d.ts +5 -4
- package/dist/src/domains/workflows/context/use-current-run.d.ts +2 -1
- package/dist/src/domains/workflows/context/workflow-nested-graph-context.d.ts +5 -1
- package/dist/src/domains/workflows/context/workflow-run-context.d.ts +3 -2
- package/dist/src/domains/workflows/utils.d.ts +2 -2
- package/dist/src/domains/workflows/workflow/workflow-default-node.d.ts +3 -1
- package/dist/src/domains/workflows/workflow/workflow-nested-graph.d.ts +5 -1
- package/dist/src/domains/workflows/workflow/workflow-nested-node.d.ts +7 -2
- package/dist/src/domains/workflows/workflow/workflow-status.d.ts +2 -1
- package/dist/src/domains/workflows/workflow/workflow-step-action-bar.d.ts +3 -1
- package/dist/src/domains/workflows/workflow/workflow-trigger.d.ts +12 -10
- package/dist/src/ds/tokens/colors.d.ts +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/types.d.ts +17 -0
- package/dist/tokens.cjs.js +1 -1
- package/dist/tokens.es.js +1 -1
- package/package.json +6 -5
- package/dist/colors-CBG_Mm7P.js.map +0 -1
- package/dist/colors-Du4i-E0i.cjs.map +0 -1
- package/dist/src/domains/agents/agent/context/agent-context.d.ts +0 -19
- package/dist/src/store/agent-store.d.ts +0 -20
- /package/dist/src/domains/agents/{agent → components}/agent-chat.d.ts +0 -0
- /package/dist/src/domains/agents/{agent → components}/agent-evals.d.ts +0 -0
- /package/dist/src/domains/agents/{agent → components}/agent-traces.d.ts +0 -0
package/dist/index.cjs.js
CHANGED
|
@@ -28,16 +28,18 @@ const middleware = require('zustand/middleware');
|
|
|
28
28
|
const dateFns = require('date-fns');
|
|
29
29
|
const TabsPrimitive = require('@radix-ui/react-tabs');
|
|
30
30
|
const react$1 = require('motion/react');
|
|
31
|
-
const colors = require('./colors-
|
|
31
|
+
const colors = require('./colors-BjoU9dWU.cjs');
|
|
32
|
+
const SliderPrimitive = require('@radix-ui/react-slider');
|
|
33
|
+
const LabelPrimitive = require('@radix-ui/react-label');
|
|
34
|
+
const RadioGroupPrimitive = require('@radix-ui/react-radio-group');
|
|
35
|
+
const CollapsiblePrimitive = require('@radix-ui/react-collapsible');
|
|
32
36
|
const uiUtils = require('@ai-sdk/ui-utils');
|
|
33
37
|
const Markdown = require('react-markdown');
|
|
34
38
|
const react$2 = require('@xyflow/react');
|
|
35
39
|
require('@xyflow/react/dist/style.css');
|
|
36
40
|
const Dagre = require('@dagrejs/dagre');
|
|
37
41
|
const prismReactRenderer = require('prism-react-renderer');
|
|
38
|
-
const CollapsiblePrimitive = require('@radix-ui/react-collapsible');
|
|
39
42
|
const ScrollAreaPrimitive = require('@radix-ui/react-scroll-area');
|
|
40
|
-
const SliderPrimitive = require('@radix-ui/react-slider');
|
|
41
43
|
const useDebounce = require('use-debounce');
|
|
42
44
|
const uuid = require('@lukeed/uuid');
|
|
43
45
|
const prettier = require('prettier');
|
|
@@ -52,7 +54,6 @@ const reactDayPicker = require('react-day-picker');
|
|
|
52
54
|
const PopoverPrimitive = require('@radix-ui/react-popover');
|
|
53
55
|
const SelectPrimitive = require('@radix-ui/react-select');
|
|
54
56
|
const zod = require('@autoform/zod');
|
|
55
|
-
const LabelPrimitive = require('@radix-ui/react-label');
|
|
56
57
|
const reactCodeBlock = require('react-code-block');
|
|
57
58
|
const reactTable = require('@tanstack/react-table');
|
|
58
59
|
|
|
@@ -78,13 +79,14 @@ const TooltipPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(Toolti
|
|
|
78
79
|
const AvatarPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(AvatarPrimitive);
|
|
79
80
|
const DialogPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(DialogPrimitive);
|
|
80
81
|
const TabsPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(TabsPrimitive);
|
|
82
|
+
const SliderPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(SliderPrimitive);
|
|
83
|
+
const LabelPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(LabelPrimitive);
|
|
84
|
+
const RadioGroupPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(RadioGroupPrimitive);
|
|
81
85
|
const CollapsiblePrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(CollapsiblePrimitive);
|
|
82
86
|
const ScrollAreaPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(ScrollAreaPrimitive);
|
|
83
|
-
const SliderPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(SliderPrimitive);
|
|
84
87
|
const CheckboxPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(CheckboxPrimitive);
|
|
85
88
|
const PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(PopoverPrimitive);
|
|
86
89
|
const SelectPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(SelectPrimitive);
|
|
87
|
-
const LabelPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(LabelPrimitive);
|
|
88
90
|
|
|
89
91
|
const createMastraClient = (baseUrl, mastraClientHeaders = {}) => {
|
|
90
92
|
return new clientJs.MastraClient({
|
|
@@ -4759,7 +4761,7 @@ const SpeechInput$1 = () => {
|
|
|
4759
4761
|
variant: "ghost",
|
|
4760
4762
|
className: "rounded-full",
|
|
4761
4763
|
onClick: () => isListening ? stop() : start(),
|
|
4762
|
-
children: isListening ? /* @__PURE__ */ jsxRuntime.jsx(CircleStopIcon$
|
|
4764
|
+
children: isListening ? /* @__PURE__ */ jsxRuntime.jsx(CircleStopIcon$2, {}) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Mic, { className: "h-6 w-6 text-[#898989] hover:text-[#fff]" })
|
|
4763
4765
|
}
|
|
4764
4766
|
);
|
|
4765
4767
|
};
|
|
@@ -4775,7 +4777,7 @@ const ComposerAction$1 = ({ showFileSupport }) => {
|
|
|
4775
4777
|
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowUp, { className: "h-6 w-6 text-[#898989] hover:text-[#fff]" })
|
|
4776
4778
|
}
|
|
4777
4779
|
) }) }),
|
|
4778
|
-
/* @__PURE__ */ jsxRuntime.jsx(react.ThreadPrimitive.If, { running: true, children: /* @__PURE__ */ jsxRuntime.jsx(react.ComposerPrimitive.Cancel, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(TooltipIconButton, { tooltip: "Cancel", variant: "default", children: /* @__PURE__ */ jsxRuntime.jsx(CircleStopIcon$
|
|
4780
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.ThreadPrimitive.If, { running: true, children: /* @__PURE__ */ jsxRuntime.jsx(react.ComposerPrimitive.Cancel, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(TooltipIconButton, { tooltip: "Cancel", variant: "default", children: /* @__PURE__ */ jsxRuntime.jsx(CircleStopIcon$2, {}) }) }) })
|
|
4779
4781
|
] });
|
|
4780
4782
|
};
|
|
4781
4783
|
const EditComposer$1 = () => {
|
|
@@ -4787,7 +4789,7 @@ const EditComposer$1 = () => {
|
|
|
4787
4789
|
] })
|
|
4788
4790
|
] });
|
|
4789
4791
|
};
|
|
4790
|
-
const CircleStopIcon$
|
|
4792
|
+
const CircleStopIcon$2 = () => {
|
|
4791
4793
|
return /* @__PURE__ */ jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", fill: "currentColor", width: "16", height: "16", children: /* @__PURE__ */ jsxRuntime.jsx("rect", { width: "10", height: "10", x: "3", y: "3", rx: "2" }) });
|
|
4792
4794
|
};
|
|
4793
4795
|
|
|
@@ -5218,83 +5220,79 @@ function MastraRuntimeProvider({
|
|
|
5218
5220
|
] });
|
|
5219
5221
|
}
|
|
5220
5222
|
|
|
5221
|
-
const useAgentStore = zustand.create()(
|
|
5222
|
-
middleware.persist(
|
|
5223
|
-
(set) => ({
|
|
5224
|
-
modelSettings: {},
|
|
5225
|
-
setModelSettings: (modelSettings) => set((state) => ({ modelSettings: { ...state.modelSettings, ...modelSettings } })),
|
|
5226
|
-
chatWithGenerate: {},
|
|
5227
|
-
setChatWithGenerate: (chatWithGenerate) => set((state) => ({ chatWithGenerate: { ...state.chatWithGenerate, ...chatWithGenerate } }))
|
|
5228
|
-
}),
|
|
5229
|
-
{
|
|
5230
|
-
name: "mastra-agent-store"
|
|
5231
|
-
}
|
|
5232
|
-
)
|
|
5233
|
-
);
|
|
5234
|
-
|
|
5235
5223
|
const defaultModelSettings$1 = {
|
|
5236
5224
|
maxRetries: 2,
|
|
5237
5225
|
maxSteps: 5,
|
|
5238
5226
|
temperature: 0.5,
|
|
5239
5227
|
topP: 1
|
|
5240
5228
|
};
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
const setChatWithGenerate = (chatWithGenerate2) => {
|
|
5256
|
-
setChatWithGenerateStore({ [agentId]: chatWithGenerate2 });
|
|
5257
|
-
};
|
|
5258
|
-
const modelSettings = React.useMemo(() => {
|
|
5259
|
-
if (modelSettingsStore[agentId]) return modelSettingsStore[agentId];
|
|
5260
|
-
if (chatWithGenerate) {
|
|
5261
|
-
return {
|
|
5262
|
-
maxRetries: defaultGenerateOptions?.maxRetries ?? defaultModelSettings$1.maxRetries,
|
|
5263
|
-
maxSteps: defaultGenerateOptions?.maxSteps ?? defaultModelSettings$1.maxSteps,
|
|
5264
|
-
temperature: defaultGenerateOptions?.temperature ?? defaultModelSettings$1.temperature,
|
|
5265
|
-
topP: defaultGenerateOptions?.topP ?? defaultModelSettings$1.topP,
|
|
5266
|
-
...defaultGenerateOptions
|
|
5267
|
-
};
|
|
5268
|
-
} else {
|
|
5269
|
-
return {
|
|
5270
|
-
maxRetries: defaultStreamOptions?.maxRetries ?? defaultModelSettings$1.maxRetries,
|
|
5271
|
-
maxSteps: defaultStreamOptions?.maxSteps ?? defaultModelSettings$1.maxSteps,
|
|
5272
|
-
temperature: defaultStreamOptions?.temperature ?? defaultModelSettings$1.temperature,
|
|
5273
|
-
topP: defaultStreamOptions?.topP ?? defaultModelSettings$1.topP,
|
|
5274
|
-
...defaultStreamOptions
|
|
5275
|
-
};
|
|
5229
|
+
function useAgentModelSettingsState({ agentId }) {
|
|
5230
|
+
const [modelSettings, setModelSettingsState] = React.useState(void 0);
|
|
5231
|
+
const [chatWithGenerate, setChatWithGenerateState] = React.useState(false);
|
|
5232
|
+
const LOCAL_STORAGE_KEY = `mastra-agent-store-${agentId}`;
|
|
5233
|
+
React.useEffect(() => {
|
|
5234
|
+
try {
|
|
5235
|
+
const stored = localStorage.getItem(LOCAL_STORAGE_KEY);
|
|
5236
|
+
if (stored) {
|
|
5237
|
+
const parsed = JSON.parse(stored);
|
|
5238
|
+
setModelSettingsState(parsed.modelSettings ?? void 0);
|
|
5239
|
+
setChatWithGenerateState(parsed.chatWithGenerate ?? false);
|
|
5240
|
+
}
|
|
5241
|
+
} catch (e) {
|
|
5242
|
+
console.error(e);
|
|
5276
5243
|
}
|
|
5277
|
-
}, [
|
|
5278
|
-
|
|
5279
|
-
|
|
5244
|
+
}, [LOCAL_STORAGE_KEY]);
|
|
5245
|
+
React.useEffect(() => {
|
|
5246
|
+
if (modelSettings) {
|
|
5247
|
+
localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify({ modelSettings, chatWithGenerate, agentId }));
|
|
5248
|
+
}
|
|
5249
|
+
}, [modelSettings, chatWithGenerate, LOCAL_STORAGE_KEY]);
|
|
5250
|
+
const setModelSettings = (modelSettingsValue) => setModelSettingsState((prev) => ({ ...prev, ...modelSettingsValue }));
|
|
5251
|
+
const setChatWithGenerate = (chatWithGenerateValue) => setChatWithGenerateState(chatWithGenerateValue);
|
|
5252
|
+
const resetAll = () => {
|
|
5253
|
+
setModelSettingsState(defaultModelSettings$1);
|
|
5254
|
+
setChatWithGenerate(false);
|
|
5280
5255
|
};
|
|
5281
|
-
|
|
5282
|
-
|
|
5256
|
+
return {
|
|
5257
|
+
modelSettings,
|
|
5258
|
+
chatWithGenerate,
|
|
5259
|
+
setModelSettings,
|
|
5260
|
+
setChatWithGenerate,
|
|
5261
|
+
resetAll
|
|
5262
|
+
};
|
|
5263
|
+
}
|
|
5264
|
+
|
|
5265
|
+
const AgentSettingsContext = React.createContext({});
|
|
5266
|
+
function AgentSettingsProvider({ children, agentId }) {
|
|
5267
|
+
const { modelSettings, setModelSettings, chatWithGenerate, setChatWithGenerate, resetAll } = useAgentModelSettingsState({
|
|
5268
|
+
agentId
|
|
5269
|
+
});
|
|
5270
|
+
const onChangeModelSettings = (modelSettings2) => {
|
|
5271
|
+
setModelSettings(modelSettings2);
|
|
5272
|
+
};
|
|
5273
|
+
const onChangeChatWithGenerate = (chatWithGenerate2) => {
|
|
5274
|
+
setChatWithGenerate(chatWithGenerate2);
|
|
5275
|
+
};
|
|
5276
|
+
const onReset = () => {
|
|
5277
|
+
resetAll();
|
|
5283
5278
|
};
|
|
5284
5279
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5285
|
-
|
|
5280
|
+
AgentSettingsContext.Provider,
|
|
5286
5281
|
{
|
|
5287
5282
|
value: {
|
|
5288
|
-
modelSettings,
|
|
5289
|
-
setModelSettings,
|
|
5290
|
-
resetModelSettings,
|
|
5291
|
-
chatWithGenerate,
|
|
5292
|
-
setChatWithGenerate
|
|
5283
|
+
modelSettings: modelSettings ?? defaultModelSettings$1,
|
|
5284
|
+
setModelSettings: onChangeModelSettings,
|
|
5285
|
+
resetModelSettings: onReset,
|
|
5286
|
+
chatWithGenerate: chatWithGenerate ?? false,
|
|
5287
|
+
setChatWithGenerate: onChangeChatWithGenerate
|
|
5293
5288
|
},
|
|
5294
5289
|
children
|
|
5295
5290
|
}
|
|
5296
5291
|
);
|
|
5297
5292
|
}
|
|
5293
|
+
const useAgentSettings = () => {
|
|
5294
|
+
return React.useContext(AgentSettingsContext);
|
|
5295
|
+
};
|
|
5298
5296
|
|
|
5299
5297
|
const usePlaygroundStore = zustand.create()(
|
|
5300
5298
|
middleware.persist(
|
|
@@ -5317,7 +5315,7 @@ const AgentChat = ({
|
|
|
5317
5315
|
refreshThreadList,
|
|
5318
5316
|
showFileSupport
|
|
5319
5317
|
}) => {
|
|
5320
|
-
const { modelSettings, chatWithGenerate } =
|
|
5318
|
+
const { modelSettings, chatWithGenerate } = useAgentSettings();
|
|
5321
5319
|
const { runtimeContext } = usePlaygroundStore();
|
|
5322
5320
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5323
5321
|
MastraRuntimeProvider,
|
|
@@ -6030,7 +6028,10 @@ const Button = ({ className, as, size = "md", variant = "default", ...props }) =
|
|
|
6030
6028
|
"bg-surface2 border-sm border-border1 px-lg text-ui-md inline-flex items-center justify-center rounded-md border",
|
|
6031
6029
|
variantClasses$1[variant],
|
|
6032
6030
|
sizeClasses[size],
|
|
6033
|
-
className
|
|
6031
|
+
className,
|
|
6032
|
+
{
|
|
6033
|
+
"cursor-not-allowed": props.disabled
|
|
6034
|
+
}
|
|
6034
6035
|
),
|
|
6035
6036
|
...props
|
|
6036
6037
|
}
|
|
@@ -6408,11 +6409,11 @@ function SpanDetail() {
|
|
|
6408
6409
|
span.name
|
|
6409
6410
|
] }),
|
|
6410
6411
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-row gap-2 items-center", children: span.status.code === 0 ? /* @__PURE__ */ jsxRuntime.jsxs(Badge$1, { icon: /* @__PURE__ */ jsxRuntime.jsx(LatencyIcon, {}), variant: "success", children: [
|
|
6411
|
-
toSigFigs(span.duration
|
|
6412
|
+
toSigFigs(span.duration, 3),
|
|
6412
6413
|
"ms"
|
|
6413
6414
|
] }) : /* @__PURE__ */ jsxRuntime.jsxs(Badge$1, { variant: "error", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, {}), children: [
|
|
6414
6415
|
"Failed in ",
|
|
6415
|
-
toSigFigs(span.duration
|
|
6416
|
+
toSigFigs(span.duration, 3),
|
|
6416
6417
|
"ms"
|
|
6417
6418
|
] }) }),
|
|
6418
6419
|
/* @__PURE__ */ jsxRuntime.jsx("hr", { className: "border-border1 border-sm my-5" }),
|
|
@@ -6510,6 +6511,218 @@ function AgentTracesInner({ className, traces, error }) {
|
|
|
6510
6511
|
] });
|
|
6511
6512
|
}
|
|
6512
6513
|
|
|
6514
|
+
const Slider = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6515
|
+
SliderPrimitive__namespace.Root,
|
|
6516
|
+
{
|
|
6517
|
+
ref,
|
|
6518
|
+
className: cn("relative flex w-full touch-none select-none items-center", className),
|
|
6519
|
+
...props,
|
|
6520
|
+
children: [
|
|
6521
|
+
/* @__PURE__ */ jsxRuntime.jsx(SliderPrimitive__namespace.Track, { className: "relative h-1.5 w-full grow overflow-hidden rounded-full bg-primary/20", children: /* @__PURE__ */ jsxRuntime.jsx(SliderPrimitive__namespace.Range, { className: "absolute h-full bg-primary/50" }) }),
|
|
6522
|
+
/* @__PURE__ */ jsxRuntime.jsx(SliderPrimitive__namespace.Thumb, { className: "block h-4 w-4 rounded-full border border-primary/50 bg-white shadow transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50" })
|
|
6523
|
+
]
|
|
6524
|
+
}
|
|
6525
|
+
));
|
|
6526
|
+
Slider.displayName = SliderPrimitive__namespace.Root.displayName;
|
|
6527
|
+
|
|
6528
|
+
const labelVariants = cva("text-sm leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70");
|
|
6529
|
+
const Label = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(LabelPrimitive__namespace.Root, { ref, className: cn(labelVariants(), className), ...props }));
|
|
6530
|
+
Label.displayName = LabelPrimitive__namespace.Root.displayName;
|
|
6531
|
+
|
|
6532
|
+
const RadioGroup = React__namespace.forwardRef(({ className, ...props }, ref) => {
|
|
6533
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RadioGroupPrimitive__namespace.Root, { className: cn("grid gap-2", className), ...props, ref });
|
|
6534
|
+
});
|
|
6535
|
+
RadioGroup.displayName = RadioGroupPrimitive__namespace.Root.displayName;
|
|
6536
|
+
const RadioGroupItem = React__namespace.forwardRef(({ className, ...props }, ref) => {
|
|
6537
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6538
|
+
RadioGroupPrimitive__namespace.Item,
|
|
6539
|
+
{
|
|
6540
|
+
ref,
|
|
6541
|
+
className: cn(
|
|
6542
|
+
"aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
6543
|
+
className
|
|
6544
|
+
),
|
|
6545
|
+
...props,
|
|
6546
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(RadioGroupPrimitive__namespace.Indicator, { className: "flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Circle, { className: "h-2.5 w-2.5 fill-current text-current" }) })
|
|
6547
|
+
}
|
|
6548
|
+
);
|
|
6549
|
+
});
|
|
6550
|
+
RadioGroupItem.displayName = RadioGroupPrimitive__namespace.Item.displayName;
|
|
6551
|
+
|
|
6552
|
+
const Entry = ({ label, children }) => {
|
|
6553
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
6554
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "p", variant: "ui-md", className: "text-icon3", children: label }),
|
|
6555
|
+
children
|
|
6556
|
+
] });
|
|
6557
|
+
};
|
|
6558
|
+
|
|
6559
|
+
const Collapsible = CollapsiblePrimitive__namespace.Root;
|
|
6560
|
+
const CollapsibleTrigger = CollapsiblePrimitive__namespace.CollapsibleTrigger;
|
|
6561
|
+
const CollapsibleContent = CollapsiblePrimitive__namespace.CollapsibleContent;
|
|
6562
|
+
|
|
6563
|
+
const AgentAdvancedSettings = () => {
|
|
6564
|
+
const { modelSettings, setModelSettings } = useAgentSettings();
|
|
6565
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
6566
|
+
const collapsibleClassName = "rounded-lg border-sm border-border1 bg-surface3 overflow-clip";
|
|
6567
|
+
const collapsibleTriggerClassName = "text-icon3 text-ui-lg font-medium flex items-center gap-2 w-full p-[10px] justify-between";
|
|
6568
|
+
const collapsibleContentClassName = "bg-surface2 p-[10px] grid grid-cols-2 gap-[10px]";
|
|
6569
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Collapsible, { className: collapsibleClassName, open: isOpen, onOpenChange: setIsOpen, children: [
|
|
6570
|
+
/* @__PURE__ */ jsxRuntime.jsxs(CollapsibleTrigger, { className: collapsibleTriggerClassName, children: [
|
|
6571
|
+
"Advanced Settings",
|
|
6572
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { className: cn("transition-transform", isOpen ? "rotate-0" : "-rotate-90"), children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, {}) })
|
|
6573
|
+
] }),
|
|
6574
|
+
/* @__PURE__ */ jsxRuntime.jsxs(CollapsibleContent, { className: collapsibleContentClassName, children: [
|
|
6575
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
|
|
6576
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "label", className: "text-icon3", variant: "ui-sm", htmlFor: "top-k", children: "Top K" }),
|
|
6577
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6578
|
+
Input,
|
|
6579
|
+
{
|
|
6580
|
+
id: "top-k",
|
|
6581
|
+
type: "number",
|
|
6582
|
+
value: modelSettings?.topK || "",
|
|
6583
|
+
onChange: (e) => setModelSettings({ ...modelSettings, topK: e.target.value ? Number(e.target.value) : void 0 })
|
|
6584
|
+
}
|
|
6585
|
+
)
|
|
6586
|
+
] }),
|
|
6587
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
|
|
6588
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "label", className: "text-icon3", variant: "ui-sm", htmlFor: "frequency-penalty", children: "Frequency Penalty" }),
|
|
6589
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6590
|
+
Input,
|
|
6591
|
+
{
|
|
6592
|
+
id: "frequency-penalty",
|
|
6593
|
+
type: "number",
|
|
6594
|
+
value: modelSettings?.frequencyPenalty || "",
|
|
6595
|
+
onChange: (e) => setModelSettings({
|
|
6596
|
+
...modelSettings,
|
|
6597
|
+
frequencyPenalty: e.target.value ? Number(e.target.value) : void 0
|
|
6598
|
+
})
|
|
6599
|
+
}
|
|
6600
|
+
)
|
|
6601
|
+
] }),
|
|
6602
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
|
|
6603
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "label", className: "text-icon3", variant: "ui-sm", htmlFor: "presence-penalty", children: "Presence Penalty" }),
|
|
6604
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6605
|
+
Input,
|
|
6606
|
+
{
|
|
6607
|
+
id: "presence-penalty",
|
|
6608
|
+
type: "number",
|
|
6609
|
+
value: modelSettings?.presencePenalty || "",
|
|
6610
|
+
onChange: (e) => setModelSettings({
|
|
6611
|
+
...modelSettings,
|
|
6612
|
+
presencePenalty: e.target.value ? Number(e.target.value) : void 0
|
|
6613
|
+
})
|
|
6614
|
+
}
|
|
6615
|
+
)
|
|
6616
|
+
] }),
|
|
6617
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
|
|
6618
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "label", className: "text-icon3", variant: "ui-sm", htmlFor: "max-tokens", children: "Max Tokens" }),
|
|
6619
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6620
|
+
Input,
|
|
6621
|
+
{
|
|
6622
|
+
id: "max-tokens",
|
|
6623
|
+
type: "number",
|
|
6624
|
+
value: modelSettings?.maxTokens || "",
|
|
6625
|
+
onChange: (e) => setModelSettings({
|
|
6626
|
+
...modelSettings,
|
|
6627
|
+
maxTokens: e.target.value ? Number(e.target.value) : void 0
|
|
6628
|
+
})
|
|
6629
|
+
}
|
|
6630
|
+
)
|
|
6631
|
+
] }),
|
|
6632
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
|
|
6633
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "label", className: "text-icon3", variant: "ui-sm", htmlFor: "max-steps", children: "Max Steps" }),
|
|
6634
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6635
|
+
Input,
|
|
6636
|
+
{
|
|
6637
|
+
id: "max-steps",
|
|
6638
|
+
type: "number",
|
|
6639
|
+
value: modelSettings?.maxSteps || "",
|
|
6640
|
+
onChange: (e) => setModelSettings({
|
|
6641
|
+
...modelSettings,
|
|
6642
|
+
maxSteps: e.target.value ? Number(e.target.value) : void 0
|
|
6643
|
+
})
|
|
6644
|
+
}
|
|
6645
|
+
)
|
|
6646
|
+
] }),
|
|
6647
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
|
|
6648
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "label", className: "text-icon3", variant: "ui-sm", htmlFor: "max-retries", children: "Max Retries" }),
|
|
6649
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6650
|
+
Input,
|
|
6651
|
+
{
|
|
6652
|
+
id: "max-retries",
|
|
6653
|
+
type: "number",
|
|
6654
|
+
value: modelSettings?.maxRetries || "",
|
|
6655
|
+
onChange: (e) => setModelSettings({
|
|
6656
|
+
...modelSettings,
|
|
6657
|
+
maxRetries: e.target.value ? Number(e.target.value) : void 0
|
|
6658
|
+
})
|
|
6659
|
+
}
|
|
6660
|
+
)
|
|
6661
|
+
] })
|
|
6662
|
+
] })
|
|
6663
|
+
] });
|
|
6664
|
+
};
|
|
6665
|
+
|
|
6666
|
+
function AgentModelSettings() {
|
|
6667
|
+
const { modelSettings, setModelSettings, chatWithGenerate, setChatWithGenerate, resetModelSettings } = useAgentSettings();
|
|
6668
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-5 text-xs py-2 pb-4", children: [
|
|
6669
|
+
/* @__PURE__ */ jsxRuntime.jsxs("section", { className: "space-y-7", children: [
|
|
6670
|
+
/* @__PURE__ */ jsxRuntime.jsx(Entry, { label: "Chat Method", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6671
|
+
RadioGroup,
|
|
6672
|
+
{
|
|
6673
|
+
orientation: "horizontal",
|
|
6674
|
+
value: chatWithGenerate ? "generate" : "stream",
|
|
6675
|
+
onValueChange: (value) => setChatWithGenerate(value === "generate"),
|
|
6676
|
+
className: "flex flex-row gap-4",
|
|
6677
|
+
children: [
|
|
6678
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
6679
|
+
/* @__PURE__ */ jsxRuntime.jsx(RadioGroupItem, { value: "generate", id: "generate", className: "text-icon6" }),
|
|
6680
|
+
/* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-icon6 text-ui-md", htmlFor: "generate", children: "Generate" })
|
|
6681
|
+
] }),
|
|
6682
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
6683
|
+
/* @__PURE__ */ jsxRuntime.jsx(RadioGroupItem, { value: "stream", id: "stream", className: "text-icon6" }),
|
|
6684
|
+
/* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-icon6 text-ui-md", htmlFor: "stream", children: "Stream" })
|
|
6685
|
+
] })
|
|
6686
|
+
]
|
|
6687
|
+
}
|
|
6688
|
+
) }),
|
|
6689
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-8", children: [
|
|
6690
|
+
/* @__PURE__ */ jsxRuntime.jsx(Entry, { label: "Temperature", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-row justify-between items-center gap-2", children: [
|
|
6691
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6692
|
+
Slider,
|
|
6693
|
+
{
|
|
6694
|
+
value: [modelSettings?.temperature ?? -0.1],
|
|
6695
|
+
max: 1,
|
|
6696
|
+
min: -0.1,
|
|
6697
|
+
step: 0.1,
|
|
6698
|
+
onValueChange: (value) => setModelSettings({ ...modelSettings, temperature: value[0] < 0 ? void 0 : value[0] })
|
|
6699
|
+
}
|
|
6700
|
+
),
|
|
6701
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "p", variant: "ui-sm", className: "text-icon3", children: modelSettings?.temperature ?? "n/a" })
|
|
6702
|
+
] }) }),
|
|
6703
|
+
/* @__PURE__ */ jsxRuntime.jsx(Entry, { label: "Top P", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-row justify-between items-center gap-2", children: [
|
|
6704
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6705
|
+
Slider,
|
|
6706
|
+
{
|
|
6707
|
+
onValueChange: (value) => setModelSettings({ ...modelSettings, topP: value[0] < 0 ? void 0 : value[0] }),
|
|
6708
|
+
value: [modelSettings?.topP ?? -0.1],
|
|
6709
|
+
max: 1,
|
|
6710
|
+
min: -0.1,
|
|
6711
|
+
step: 0.1
|
|
6712
|
+
}
|
|
6713
|
+
),
|
|
6714
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "p", variant: "ui-sm", className: "text-icon3", children: modelSettings?.topP ?? "n/a" })
|
|
6715
|
+
] }) })
|
|
6716
|
+
] })
|
|
6717
|
+
] }),
|
|
6718
|
+
/* @__PURE__ */ jsxRuntime.jsx("section", { className: "py-7", children: /* @__PURE__ */ jsxRuntime.jsx(AgentAdvancedSettings, {}) }),
|
|
6719
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Button, { onClick: () => resetModelSettings(), variant: "light", className: "w-full", size: "lg", children: [
|
|
6720
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.RefreshCw, {}) }),
|
|
6721
|
+
"Reset"
|
|
6722
|
+
] })
|
|
6723
|
+
] });
|
|
6724
|
+
}
|
|
6725
|
+
|
|
6513
6726
|
const convertMessage$1 = (message) => {
|
|
6514
6727
|
return message;
|
|
6515
6728
|
};
|
|
@@ -6927,18 +7140,21 @@ const VNextNetworkChatProvider = ({ children }) => {
|
|
|
6927
7140
|
const [state, setState] = React.useState({});
|
|
6928
7141
|
const { chatWithLoop } = React.useContext(NetworkContext);
|
|
6929
7142
|
const handleStep = (uuid, record) => {
|
|
6930
|
-
const addFinishStep = chatWithLoop && record.type === "step-finish" && record.payload?.id === "final-step";
|
|
6931
|
-
|
|
6932
|
-
if (id
|
|
7143
|
+
const addFinishStep = chatWithLoop && record.type === "step-finish" && record.payload?.id === "final-step" || record.type === "error";
|
|
7144
|
+
let id = record?.type === "finish" ? "finish" : record.type === "start" ? "start" : record.payload?.id;
|
|
7145
|
+
if (id?.includes("mapping_")) return;
|
|
6933
7146
|
setState((prevState) => {
|
|
6934
7147
|
const current = prevState[uuid];
|
|
7148
|
+
if (record.type === "error") {
|
|
7149
|
+
id = current?.executionSteps?.[current?.executionSteps.length - 1];
|
|
7150
|
+
}
|
|
6935
7151
|
const currentMetadata = current?.steps?.[id]?.metadata;
|
|
6936
7152
|
let startTime = currentMetadata?.startTime;
|
|
6937
7153
|
let endTime = currentMetadata?.endTime;
|
|
6938
7154
|
if (record.type === "step-start") {
|
|
6939
7155
|
startTime = Date.now();
|
|
6940
7156
|
}
|
|
6941
|
-
if (record.type === "step-finish") {
|
|
7157
|
+
if (record.type === "step-finish" || record.type === "error") {
|
|
6942
7158
|
endTime = Date.now();
|
|
6943
7159
|
}
|
|
6944
7160
|
return {
|
|
@@ -6951,7 +7167,7 @@ const VNextNetworkChatProvider = ({ children }) => {
|
|
|
6951
7167
|
...current?.steps,
|
|
6952
7168
|
[id]: {
|
|
6953
7169
|
...current?.steps?.[id] || {},
|
|
6954
|
-
[record.type]: record.payload,
|
|
7170
|
+
[record.type]: record.payload || record?.error,
|
|
6955
7171
|
metadata: {
|
|
6956
7172
|
startTime,
|
|
6957
7173
|
endTime
|
|
@@ -7385,11 +7601,16 @@ const getStepNodeAndEdge = ({
|
|
|
7385
7601
|
}) => {
|
|
7386
7602
|
let nextNodeIds = [];
|
|
7387
7603
|
let nextStepIds = [];
|
|
7388
|
-
if (nextStepFlow?.type === "step" || nextStepFlow?.type === "foreach" || nextStepFlow?.type === "loop") {
|
|
7604
|
+
if (nextStepFlow?.type === "step" || nextStepFlow?.type === "foreach" || nextStepFlow?.type === "loop" || nextStepFlow?.type === "waitForEvent") {
|
|
7389
7605
|
const nextStepId = allPrevNodeIds?.includes(nextStepFlow.step.id) ? `${nextStepFlow.step.id}-${yIndex + 1}` : nextStepFlow.step.id;
|
|
7390
7606
|
nextNodeIds = [nextStepId];
|
|
7391
7607
|
nextStepIds = [nextStepFlow.step.id];
|
|
7392
7608
|
}
|
|
7609
|
+
if (nextStepFlow?.type === "sleep" || nextStepFlow?.type === "sleepUntil") {
|
|
7610
|
+
const nextStepId = allPrevNodeIds?.includes(nextStepFlow.id) ? `${nextStepFlow.id}-${yIndex + 1}` : nextStepFlow.id;
|
|
7611
|
+
nextNodeIds = [nextStepId];
|
|
7612
|
+
nextStepIds = [nextStepFlow.id];
|
|
7613
|
+
}
|
|
7393
7614
|
if (nextStepFlow?.type === "parallel") {
|
|
7394
7615
|
nextNodeIds = nextStepFlow?.steps.map((step) => {
|
|
7395
7616
|
const stepId = step.step.id;
|
|
@@ -7402,7 +7623,7 @@ const getStepNodeAndEdge = ({
|
|
|
7402
7623
|
nextNodeIds = nextStepFlow?.serializedConditions.map((cond) => cond.id) || [];
|
|
7403
7624
|
nextStepIds = nextStepFlow?.steps?.map((step) => step.step.id) || [];
|
|
7404
7625
|
}
|
|
7405
|
-
if (stepFlow.type === "step" || stepFlow.type === "foreach") {
|
|
7626
|
+
if (stepFlow.type === "step" || stepFlow.type === "foreach" || stepFlow.type === "waitForEvent") {
|
|
7406
7627
|
const hasGraph = stepFlow.step.component === "WORKFLOW";
|
|
7407
7628
|
const nodeId = allPrevNodeIds?.includes(stepFlow.step.id) ? `${stepFlow.step.id}-${yIndex}` : stepFlow.step.id;
|
|
7408
7629
|
const nodes = [
|
|
@@ -7432,7 +7653,8 @@ const getStepNodeAndEdge = ({
|
|
|
7432
7653
|
withoutTopHandle: condition ? false : !prevNodeIds.length,
|
|
7433
7654
|
withoutBottomHandle: !nextNodeIds.length,
|
|
7434
7655
|
stepGraph: hasGraph ? stepFlow.step.serializedStepFlow : void 0,
|
|
7435
|
-
mapConfig: stepFlow.step.mapConfig
|
|
7656
|
+
mapConfig: stepFlow.step.mapConfig,
|
|
7657
|
+
...stepFlow.type === "waitForEvent" ? { event: stepFlow.event } : {}
|
|
7436
7658
|
}
|
|
7437
7659
|
}
|
|
7438
7660
|
];
|
|
@@ -7469,6 +7691,70 @@ const getStepNodeAndEdge = ({
|
|
|
7469
7691
|
];
|
|
7470
7692
|
return { nodes, edges, nextPrevNodeIds: [nodeId], nextPrevStepIds: [stepFlow.step.id] };
|
|
7471
7693
|
}
|
|
7694
|
+
if (stepFlow.type === "sleep" || stepFlow.type === "sleepUntil") {
|
|
7695
|
+
const nodeId = allPrevNodeIds?.includes(stepFlow.id) ? `${stepFlow.id}-${yIndex}` : stepFlow.id;
|
|
7696
|
+
const nodes = [
|
|
7697
|
+
...condition ? [
|
|
7698
|
+
{
|
|
7699
|
+
id: condition.id,
|
|
7700
|
+
position: { x: xIndex * 300, y: yIndex * 100 },
|
|
7701
|
+
type: "condition-node",
|
|
7702
|
+
data: {
|
|
7703
|
+
label: condition.id,
|
|
7704
|
+
previousStepId: prevStepIds[prevStepIds.length - 1],
|
|
7705
|
+
nextStepId: stepFlow.id,
|
|
7706
|
+
withoutTopHandle: false,
|
|
7707
|
+
withoutBottomHandle: !nextNodeIds.length,
|
|
7708
|
+
isLarge: true,
|
|
7709
|
+
conditions: [{ type: "when", fnString: condition.fn }]
|
|
7710
|
+
}
|
|
7711
|
+
}
|
|
7712
|
+
] : [],
|
|
7713
|
+
{
|
|
7714
|
+
id: nodeId,
|
|
7715
|
+
position: { x: xIndex * 300, y: (yIndex + (condition ? 1 : 0)) * 100 },
|
|
7716
|
+
type: "default-node",
|
|
7717
|
+
data: {
|
|
7718
|
+
label: stepFlow.id,
|
|
7719
|
+
withoutTopHandle: condition ? false : !prevNodeIds.length,
|
|
7720
|
+
withoutBottomHandle: !nextNodeIds.length,
|
|
7721
|
+
...stepFlow.type === "sleepUntil" ? { date: stepFlow.date } : { duration: stepFlow.duration }
|
|
7722
|
+
}
|
|
7723
|
+
}
|
|
7724
|
+
];
|
|
7725
|
+
const edges = [
|
|
7726
|
+
...!prevNodeIds.length ? [] : condition ? [
|
|
7727
|
+
...prevNodeIds.map((prevNodeId, i) => ({
|
|
7728
|
+
id: `e${prevNodeId}-${condition.id}`,
|
|
7729
|
+
source: prevNodeId,
|
|
7730
|
+
data: { previousStepId: prevStepIds[i], nextStepId: stepFlow.id },
|
|
7731
|
+
target: condition.id,
|
|
7732
|
+
...defaultEdgeOptions
|
|
7733
|
+
})),
|
|
7734
|
+
{
|
|
7735
|
+
id: `e${condition.id}-${nodeId}`,
|
|
7736
|
+
source: condition.id,
|
|
7737
|
+
data: { previousStepId: prevStepIds[prevStepIds.length - 1], nextStepId: stepFlow.id },
|
|
7738
|
+
target: nodeId,
|
|
7739
|
+
...defaultEdgeOptions
|
|
7740
|
+
}
|
|
7741
|
+
] : prevNodeIds.map((prevNodeId, i) => ({
|
|
7742
|
+
id: `e${prevNodeId}-${nodeId}`,
|
|
7743
|
+
source: prevNodeId,
|
|
7744
|
+
data: { previousStepId: prevStepIds[i], nextStepId: stepFlow.id },
|
|
7745
|
+
target: nodeId,
|
|
7746
|
+
...defaultEdgeOptions
|
|
7747
|
+
})),
|
|
7748
|
+
...!nextNodeIds.length ? [] : nextNodeIds.map((nextNodeId, i) => ({
|
|
7749
|
+
id: `e${nodeId}-${nextNodeId}`,
|
|
7750
|
+
source: nodeId,
|
|
7751
|
+
data: { previousStepId: stepFlow.id, nextStepId: nextStepIds[i] },
|
|
7752
|
+
target: nextNodeId,
|
|
7753
|
+
...defaultEdgeOptions
|
|
7754
|
+
}))
|
|
7755
|
+
];
|
|
7756
|
+
return { nodes, edges, nextPrevNodeIds: [nodeId], nextPrevStepIds: [stepFlow.id] };
|
|
7757
|
+
}
|
|
7472
7758
|
if (stepFlow.type === "loop") {
|
|
7473
7759
|
const { step: _step, serializedCondition, loopType } = stepFlow;
|
|
7474
7760
|
const hasGraph = _step.component === "WORKFLOW";
|
|
@@ -7653,10 +7939,6 @@ const Text = ({ className, weight, variant, as: Tag = "span", size, ...props })
|
|
|
7653
7939
|
return /* @__PURE__ */ jsxRuntime.jsx(Tag, { className: cn(textVariants({ size, variant, weight, className })), ...props });
|
|
7654
7940
|
};
|
|
7655
7941
|
|
|
7656
|
-
const Collapsible = CollapsiblePrimitive__namespace.Root;
|
|
7657
|
-
const CollapsibleTrigger = CollapsiblePrimitive__namespace.CollapsibleTrigger;
|
|
7658
|
-
const CollapsibleContent = CollapsiblePrimitive__namespace.CollapsibleContent;
|
|
7659
|
-
|
|
7660
7942
|
const ScrollArea = React__namespace.forwardRef(
|
|
7661
7943
|
({ className, children, viewPortClassName, maxHeight, autoScroll = false, ...props }, ref) => {
|
|
7662
7944
|
const areaRef = React__namespace.useRef(null);
|
|
@@ -7796,7 +8078,8 @@ const useCurrentRun = () => {
|
|
|
7796
8078
|
endedAt: value.endedAt,
|
|
7797
8079
|
status: value.status,
|
|
7798
8080
|
output: value.output,
|
|
7799
|
-
input: value.payload
|
|
8081
|
+
input: value.payload,
|
|
8082
|
+
resumeData: value.resumePayload
|
|
7800
8083
|
}
|
|
7801
8084
|
};
|
|
7802
8085
|
}, {});
|
|
@@ -7828,18 +8111,22 @@ const CodeDialogContent = ({ data }) => {
|
|
|
7828
8111
|
const WorkflowStepActionBar = ({
|
|
7829
8112
|
input,
|
|
7830
8113
|
output,
|
|
8114
|
+
resumeData,
|
|
7831
8115
|
error,
|
|
7832
8116
|
mapConfig,
|
|
7833
8117
|
stepName,
|
|
7834
|
-
onShowTrace
|
|
8118
|
+
onShowTrace,
|
|
8119
|
+
onShowNestedGraph
|
|
7835
8120
|
}) => {
|
|
7836
8121
|
const [isInputOpen, setIsInputOpen] = React.useState(false);
|
|
7837
8122
|
const [isOutputOpen, setIsOutputOpen] = React.useState(false);
|
|
8123
|
+
const [isResumeDataOpen, setIsResumeDataOpen] = React.useState(false);
|
|
7838
8124
|
const [isErrorOpen, setIsErrorOpen] = React.useState(false);
|
|
7839
8125
|
const [isMapConfigOpen, setIsMapConfigOpen] = React.useState(false);
|
|
7840
8126
|
const dialogContentClass = "bg-surface2 rounded-lg border-sm border-border1 max-w-4xl w-full px-0";
|
|
7841
8127
|
const dialogTitleClass = "border-b-sm border-border1 pb-4 px-6";
|
|
7842
|
-
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: (input || output || error || mapConfig) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center bg-surface4 border-t-sm border-border1 px-2 py-1 gap-2 rounded-b-lg", children: [
|
|
8128
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: (input || output || error || mapConfig || resumeData || onShowNestedGraph) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center bg-surface4 border-t-sm border-border1 px-2 py-1 gap-2 rounded-b-lg", children: [
|
|
8129
|
+
onShowNestedGraph && /* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: onShowNestedGraph, children: "View nested graph" }),
|
|
7843
8130
|
mapConfig && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
7844
8131
|
/* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: () => setIsMapConfigOpen(true), children: "Map config" }),
|
|
7845
8132
|
/* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: isMapConfigOpen, onOpenChange: setIsMapConfigOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: dialogContentClass, children: [
|
|
@@ -7860,6 +8147,16 @@ const WorkflowStepActionBar = ({
|
|
|
7860
8147
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(CodeDialogContent, { data: input }) })
|
|
7861
8148
|
] }) })
|
|
7862
8149
|
] }),
|
|
8150
|
+
resumeData && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
8151
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: () => setIsResumeDataOpen(true), children: "Resume data" }),
|
|
8152
|
+
/* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: isResumeDataOpen, onOpenChange: setIsResumeDataOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: dialogContentClass, children: [
|
|
8153
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DialogTitle, { className: dialogTitleClass, children: [
|
|
8154
|
+
stepName,
|
|
8155
|
+
" resume data"
|
|
8156
|
+
] }),
|
|
8157
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(CodeDialogContent, { data: resumeData }) })
|
|
8158
|
+
] }) })
|
|
8159
|
+
] }),
|
|
7863
8160
|
output && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
7864
8161
|
/* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: () => setIsOutputOpen(true), children: "Output" }),
|
|
7865
8162
|
/* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: isOutputOpen, onOpenChange: setIsOutputOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: dialogContentClass, children: [
|
|
@@ -7993,7 +8290,7 @@ function WorkflowDefaultNode({
|
|
|
7993
8290
|
parentWorkflowName
|
|
7994
8291
|
}) {
|
|
7995
8292
|
const { steps, isRunning, runId } = useCurrentRun();
|
|
7996
|
-
const { label, description, withoutTopHandle, withoutBottomHandle } = data;
|
|
8293
|
+
const { label, description, withoutTopHandle, withoutBottomHandle, mapConfig, event, duration, date } = data;
|
|
7997
8294
|
const fullLabel = parentWorkflowName ? `${parentWorkflowName}.${label}` : label;
|
|
7998
8295
|
const step = steps[fullLabel];
|
|
7999
8296
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
@@ -8004,14 +8301,17 @@ function WorkflowDefaultNode({
|
|
|
8004
8301
|
className: cn(
|
|
8005
8302
|
"bg-surface3 rounded-lg w-[274px] border-sm border-border1 pt-2",
|
|
8006
8303
|
step?.status === "success" && "ring-2 ring-accent1",
|
|
8007
|
-
step?.status === "failed" && "ring-2 ring-accent2"
|
|
8304
|
+
step?.status === "failed" && "ring-2 ring-accent2",
|
|
8305
|
+
step?.status === "suspended" && "ring-2 ring-accent3",
|
|
8306
|
+
step?.status === "waiting" && "ring-2 ring-accent5"
|
|
8008
8307
|
),
|
|
8009
8308
|
children: [
|
|
8010
8309
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex items-center gap-2 px-3", !description && "pb-2"), children: [
|
|
8011
8310
|
isRunning && /* @__PURE__ */ jsxRuntime.jsxs(Icon, { children: [
|
|
8012
8311
|
step?.status === "failed" && /* @__PURE__ */ jsxRuntime.jsx(CrossIcon, { className: "text-accent2" }),
|
|
8013
8312
|
step?.status === "success" && /* @__PURE__ */ jsxRuntime.jsx(CheckIcon, { className: "text-accent1" }),
|
|
8014
|
-
step?.status === "suspended" && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.PauseIcon, { className: "text-
|
|
8313
|
+
step?.status === "suspended" && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.PauseIcon, { className: "text-accent3" }),
|
|
8314
|
+
step?.status === "waiting" && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.HourglassIcon, { className: "text-accent5" }),
|
|
8015
8315
|
step?.status === "running" && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "text-icon6 animate-spin" }),
|
|
8016
8316
|
!step && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleDashed, { className: "text-icon2" })
|
|
8017
8317
|
] }),
|
|
@@ -8022,14 +8322,30 @@ function WorkflowDefaultNode({
|
|
|
8022
8322
|
] })
|
|
8023
8323
|
] }),
|
|
8024
8324
|
description && /* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-sm", className: "text-icon3 px-3 pb-2", children: description }),
|
|
8325
|
+
event && /* @__PURE__ */ jsxRuntime.jsxs(Txt, { variant: "ui-sm", className: "text-icon3 px-3 pb-2", children: [
|
|
8326
|
+
"waits for event: ",
|
|
8327
|
+
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: event })
|
|
8328
|
+
] }),
|
|
8329
|
+
duration && /* @__PURE__ */ jsxRuntime.jsxs(Txt, { variant: "ui-sm", className: "text-icon3 px-3 pb-2", children: [
|
|
8330
|
+
"sleeps for ",
|
|
8331
|
+
/* @__PURE__ */ jsxRuntime.jsxs("strong", { children: [
|
|
8332
|
+
duration,
|
|
8333
|
+
"ms"
|
|
8334
|
+
] })
|
|
8335
|
+
] }),
|
|
8336
|
+
date && /* @__PURE__ */ jsxRuntime.jsxs(Txt, { variant: "ui-sm", className: "text-icon3 px-3 pb-2", children: [
|
|
8337
|
+
"sleeps until ",
|
|
8338
|
+
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: new Date(date).toLocaleString() })
|
|
8339
|
+
] }),
|
|
8025
8340
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8026
8341
|
WorkflowStepActionBar,
|
|
8027
8342
|
{
|
|
8028
8343
|
stepName: label,
|
|
8029
8344
|
input: step?.input,
|
|
8345
|
+
resumeData: step?.resumeData,
|
|
8030
8346
|
output: step?.output,
|
|
8031
8347
|
error: step?.error,
|
|
8032
|
-
mapConfig
|
|
8348
|
+
mapConfig,
|
|
8033
8349
|
onShowTrace: runId && onShowTrace ? () => onShowTrace?.({ runId, stepName: fullLabel }) : void 0
|
|
8034
8350
|
}
|
|
8035
8351
|
)
|
|
@@ -8092,20 +8408,6 @@ function WorkflowLoopResultNode({ data }) {
|
|
|
8092
8408
|
] });
|
|
8093
8409
|
}
|
|
8094
8410
|
|
|
8095
|
-
const Slider = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8096
|
-
SliderPrimitive__namespace.Root,
|
|
8097
|
-
{
|
|
8098
|
-
ref,
|
|
8099
|
-
className: cn("relative flex w-full touch-none select-none items-center", className),
|
|
8100
|
-
...props,
|
|
8101
|
-
children: [
|
|
8102
|
-
/* @__PURE__ */ jsxRuntime.jsx(SliderPrimitive__namespace.Track, { className: "relative h-1.5 w-full grow overflow-hidden rounded-full bg-primary/20", children: /* @__PURE__ */ jsxRuntime.jsx(SliderPrimitive__namespace.Range, { className: "absolute h-full bg-primary/50" }) }),
|
|
8103
|
-
/* @__PURE__ */ jsxRuntime.jsx(SliderPrimitive__namespace.Thumb, { className: "block h-4 w-4 rounded-full border border-primary/50 bg-white shadow transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50" })
|
|
8104
|
-
]
|
|
8105
|
-
}
|
|
8106
|
-
));
|
|
8107
|
-
Slider.displayName = SliderPrimitive__namespace.Root.displayName;
|
|
8108
|
-
|
|
8109
8411
|
const ZoomSlider = React.forwardRef(({ className, ...props }) => {
|
|
8110
8412
|
const { zoom } = react$2.useViewport();
|
|
8111
8413
|
const { zoomTo, zoomIn, zoomOut, fitView } = react$2.useReactFlow();
|
|
@@ -8134,7 +8436,7 @@ const ZoomSlider = React.forwardRef(({ className, ...props }) => {
|
|
|
8134
8436
|
});
|
|
8135
8437
|
ZoomSlider.displayName = "ZoomSlider";
|
|
8136
8438
|
|
|
8137
|
-
function WorkflowNestedGraph({ stepGraph, open, workflowName }) {
|
|
8439
|
+
function WorkflowNestedGraph({ stepGraph, open, workflowName, onShowTrace }) {
|
|
8138
8440
|
const { nodes: initialNodes, edges: initialEdges } = constructNodesAndEdges({
|
|
8139
8441
|
stepGraph
|
|
8140
8442
|
});
|
|
@@ -8143,11 +8445,11 @@ function WorkflowNestedGraph({ stepGraph, open, workflowName }) {
|
|
|
8143
8445
|
const [edges] = react$2.useEdgesState(initialEdges);
|
|
8144
8446
|
const { steps } = useCurrentRun();
|
|
8145
8447
|
const nodeTypes = {
|
|
8146
|
-
"default-node": (props) => /* @__PURE__ */ jsxRuntime.jsx(WorkflowDefaultNode, { parentWorkflowName: workflowName, ...props }),
|
|
8448
|
+
"default-node": (props) => /* @__PURE__ */ jsxRuntime.jsx(WorkflowDefaultNode, { parentWorkflowName: workflowName, onShowTrace, ...props }),
|
|
8147
8449
|
"condition-node": WorkflowConditionNode,
|
|
8148
8450
|
"after-node": WorkflowAfterNode,
|
|
8149
8451
|
"loop-result-node": WorkflowLoopResultNode,
|
|
8150
|
-
"nested-node": (props) => /* @__PURE__ */ jsxRuntime.jsx(WorkflowNestedNode, { parentWorkflowName: workflowName, ...props })
|
|
8452
|
+
"nested-node": (props) => /* @__PURE__ */ jsxRuntime.jsx(WorkflowNestedNode, { parentWorkflowName: workflowName, onShowTrace, ...props })
|
|
8151
8453
|
};
|
|
8152
8454
|
React.useEffect(() => {
|
|
8153
8455
|
if (open) {
|
|
@@ -8187,24 +8489,22 @@ function WorkflowNestedGraph({ stepGraph, open, workflowName }) {
|
|
|
8187
8489
|
const WorkflowNestedGraphContext = React.createContext(
|
|
8188
8490
|
{}
|
|
8189
8491
|
);
|
|
8190
|
-
function WorkflowNestedGraphProvider({
|
|
8492
|
+
function WorkflowNestedGraphProvider({
|
|
8493
|
+
children,
|
|
8494
|
+
onShowTrace
|
|
8495
|
+
}) {
|
|
8191
8496
|
const [stepGraph, setStepGraph] = React.useState(null);
|
|
8192
8497
|
const [parentStepGraphList, setParentStepGraphList] = React.useState([]);
|
|
8193
8498
|
const [openDialog, setOpenDialog] = React.useState(false);
|
|
8194
8499
|
const [label, setLabel] = React.useState("");
|
|
8195
8500
|
const [fullStep, setFullStep] = React.useState("");
|
|
8196
|
-
const [switching, setSwitching] = React.useState(false);
|
|
8197
8501
|
const closeNestedGraph = () => {
|
|
8198
8502
|
if (parentStepGraphList.length) {
|
|
8199
|
-
setSwitching(true);
|
|
8200
8503
|
const lastStepGraph = parentStepGraphList[parentStepGraphList.length - 1];
|
|
8201
8504
|
setStepGraph(lastStepGraph.stepGraph);
|
|
8202
8505
|
setLabel(lastStepGraph.label);
|
|
8203
8506
|
setFullStep(lastStepGraph.fullStep);
|
|
8204
8507
|
setParentStepGraphList(parentStepGraphList.slice(0, -1));
|
|
8205
|
-
setTimeout(() => {
|
|
8206
|
-
setSwitching(false);
|
|
8207
|
-
}, 500);
|
|
8208
8508
|
} else {
|
|
8209
8509
|
setOpenDialog(false);
|
|
8210
8510
|
setStepGraph(null);
|
|
@@ -8218,16 +8518,12 @@ function WorkflowNestedGraphProvider({ children }) {
|
|
|
8218
8518
|
fullStep: newFullStep
|
|
8219
8519
|
}) => {
|
|
8220
8520
|
if (stepGraph) {
|
|
8221
|
-
setSwitching(true);
|
|
8222
8521
|
setParentStepGraphList([...parentStepGraphList, { stepGraph, label, fullStep }]);
|
|
8223
8522
|
}
|
|
8224
8523
|
setLabel(newLabel);
|
|
8225
8524
|
setFullStep(newFullStep);
|
|
8226
8525
|
setStepGraph(newStepGraph);
|
|
8227
8526
|
setOpenDialog(true);
|
|
8228
|
-
setTimeout(() => {
|
|
8229
|
-
setSwitching(false);
|
|
8230
|
-
}, 500);
|
|
8231
8527
|
};
|
|
8232
8528
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8233
8529
|
WorkflowNestedGraphContext.Provider,
|
|
@@ -8239,15 +8535,23 @@ function WorkflowNestedGraphProvider({ children }) {
|
|
|
8239
8535
|
children: [
|
|
8240
8536
|
children,
|
|
8241
8537
|
/* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: openDialog, onOpenChange: closeNestedGraph, children: /* @__PURE__ */ jsxRuntime.jsx(DialogPortal, { children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: "w-[45rem] h-[45rem] max-w-[unset] bg-[#121212] p-[0.5rem]", children: [
|
|
8242
|
-
/* @__PURE__ */ jsxRuntime.jsxs(DialogTitle, { className: "flex items-center gap-1.5 absolute top-
|
|
8538
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DialogTitle, { className: "flex items-center gap-1.5 absolute top-3 left-3 z-50", children: [
|
|
8243
8539
|
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Workflow, { className: "text-current w-4 h-4" }),
|
|
8244
8540
|
/* @__PURE__ */ jsxRuntime.jsxs(Text, { size: "xs", weight: "medium", className: "text-mastra-el-6 capitalize", children: [
|
|
8245
8541
|
label,
|
|
8246
8542
|
" workflow"
|
|
8247
8543
|
] })
|
|
8248
8544
|
] }),
|
|
8249
|
-
|
|
8250
|
-
|
|
8545
|
+
/* @__PURE__ */ jsxRuntime.jsx(react$2.ReactFlowProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8546
|
+
WorkflowNestedGraph,
|
|
8547
|
+
{
|
|
8548
|
+
stepGraph,
|
|
8549
|
+
open: openDialog,
|
|
8550
|
+
workflowName: fullStep,
|
|
8551
|
+
onShowTrace
|
|
8552
|
+
}
|
|
8553
|
+
) })
|
|
8554
|
+
] }) }) }, `${label}-${fullStep}`)
|
|
8251
8555
|
]
|
|
8252
8556
|
}
|
|
8253
8557
|
);
|
|
@@ -8255,19 +8559,14 @@ function WorkflowNestedGraphProvider({ children }) {
|
|
|
8255
8559
|
|
|
8256
8560
|
function WorkflowNestedNode({
|
|
8257
8561
|
data,
|
|
8258
|
-
parentWorkflowName
|
|
8562
|
+
parentWorkflowName,
|
|
8563
|
+
onShowTrace
|
|
8259
8564
|
}) {
|
|
8260
|
-
const
|
|
8261
|
-
const [isOutputOpen, setIsOutputOpen] = React.useState(false);
|
|
8262
|
-
const [isErrorOpen, setIsErrorOpen] = React.useState(false);
|
|
8263
|
-
const [isMapConfigOpen, setIsMapConfigOpen] = React.useState(false);
|
|
8264
|
-
const { steps, isRunning } = useCurrentRun();
|
|
8565
|
+
const { steps, isRunning, runId } = useCurrentRun();
|
|
8265
8566
|
const { showNestedGraph } = React.useContext(WorkflowNestedGraphContext);
|
|
8266
8567
|
const { label, description, withoutTopHandle, withoutBottomHandle, stepGraph, mapConfig } = data;
|
|
8267
8568
|
const fullLabel = parentWorkflowName ? `${parentWorkflowName}.${label}` : label;
|
|
8268
8569
|
const step = steps[fullLabel];
|
|
8269
|
-
const dialogContentClass = "bg-surface2 rounded-lg border-sm border-border1 max-w-4xl w-full px-0";
|
|
8270
|
-
const dialogTitleClass = "border-b-sm border-border1 pb-4 px-6";
|
|
8271
8570
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
8272
8571
|
!withoutTopHandle && /* @__PURE__ */ jsxRuntime.jsx(react$2.Handle, { type: "target", position: react$2.Position.Top, style: { visibility: "hidden" } }),
|
|
8273
8572
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -8294,49 +8593,19 @@ function WorkflowNestedNode({
|
|
|
8294
8593
|
] })
|
|
8295
8594
|
] }),
|
|
8296
8595
|
description && /* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-sm", className: "text-icon3 px-3 pb-2", children: description }),
|
|
8297
|
-
/* @__PURE__ */ jsxRuntime.
|
|
8298
|
-
|
|
8299
|
-
|
|
8300
|
-
|
|
8301
|
-
|
|
8302
|
-
|
|
8303
|
-
|
|
8304
|
-
|
|
8305
|
-
|
|
8306
|
-
|
|
8307
|
-
|
|
8308
|
-
|
|
8309
|
-
|
|
8310
|
-
/* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: () => setIsInputOpen(true), children: "Input" }),
|
|
8311
|
-
/* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: isInputOpen, onOpenChange: setIsInputOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: dialogContentClass, children: [
|
|
8312
|
-
/* @__PURE__ */ jsxRuntime.jsxs(DialogTitle, { className: dialogTitleClass, children: [
|
|
8313
|
-
label,
|
|
8314
|
-
" input"
|
|
8315
|
-
] }),
|
|
8316
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(CodeDialogContent, { data: step.input }) })
|
|
8317
|
-
] }) })
|
|
8318
|
-
] }),
|
|
8319
|
-
step?.output && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
8320
|
-
/* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: () => setIsOutputOpen(true), children: "Output" }),
|
|
8321
|
-
/* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: isOutputOpen, onOpenChange: setIsOutputOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: dialogContentClass, children: [
|
|
8322
|
-
/* @__PURE__ */ jsxRuntime.jsxs(DialogTitle, { className: dialogTitleClass, children: [
|
|
8323
|
-
label,
|
|
8324
|
-
" output"
|
|
8325
|
-
] }),
|
|
8326
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(CodeDialogContent, { data: step.output }) })
|
|
8327
|
-
] }) })
|
|
8328
|
-
] }),
|
|
8329
|
-
step?.error && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
8330
|
-
/* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: () => setIsErrorOpen(true), children: "Error" }),
|
|
8331
|
-
/* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: isErrorOpen, onOpenChange: setIsErrorOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: dialogContentClass, children: [
|
|
8332
|
-
/* @__PURE__ */ jsxRuntime.jsxs(DialogTitle, { className: dialogTitleClass, children: [
|
|
8333
|
-
label,
|
|
8334
|
-
" error"
|
|
8335
|
-
] }),
|
|
8336
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(CodeDialogContent, { data: step?.error }) })
|
|
8337
|
-
] }) })
|
|
8338
|
-
] })
|
|
8339
|
-
] })
|
|
8596
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8597
|
+
WorkflowStepActionBar,
|
|
8598
|
+
{
|
|
8599
|
+
stepName: label,
|
|
8600
|
+
input: step?.input,
|
|
8601
|
+
resumeData: step?.resumeData,
|
|
8602
|
+
output: step?.output,
|
|
8603
|
+
error: step?.error,
|
|
8604
|
+
mapConfig,
|
|
8605
|
+
onShowTrace: runId && onShowTrace ? () => onShowTrace?.({ runId, stepName: fullLabel }) : void 0,
|
|
8606
|
+
onShowNestedGraph: () => showNestedGraph({ label, fullStep: fullLabel, stepGraph })
|
|
8607
|
+
}
|
|
8608
|
+
)
|
|
8340
8609
|
]
|
|
8341
8610
|
}
|
|
8342
8611
|
),
|
|
@@ -8354,7 +8623,7 @@ function WorkflowGraphInner({ workflow, onShowTrace }) {
|
|
|
8354
8623
|
"condition-node": WorkflowConditionNode,
|
|
8355
8624
|
"after-node": WorkflowAfterNode,
|
|
8356
8625
|
"loop-result-node": WorkflowLoopResultNode,
|
|
8357
|
-
"nested-node": WorkflowNestedNode
|
|
8626
|
+
"nested-node": (props) => /* @__PURE__ */ jsxRuntime.jsx(WorkflowNestedNode, { onShowTrace, ...props })
|
|
8358
8627
|
};
|
|
8359
8628
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full h-full bg-surface1", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8360
8629
|
react$2.ReactFlow,
|
|
@@ -8399,7 +8668,7 @@ function WorkflowGraph({ workflowId, onShowTrace, workflow, isLoading }) {
|
|
|
8399
8668
|
] })
|
|
8400
8669
|
] }) });
|
|
8401
8670
|
}
|
|
8402
|
-
return /* @__PURE__ */ jsxRuntime.jsx(WorkflowNestedGraphProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(react$2.ReactFlowProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8671
|
+
return /* @__PURE__ */ jsxRuntime.jsx(WorkflowNestedGraphProvider, { onShowTrace, children: /* @__PURE__ */ jsxRuntime.jsx(react$2.ReactFlowProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8403
8672
|
WorkflowGraphInner,
|
|
8404
8673
|
{
|
|
8405
8674
|
workflow: snapshot?.serializedStepGraph ? { stepGraph: snapshot?.serializedStepGraph } : workflow,
|
|
@@ -8627,9 +8896,14 @@ const useResumeWorkflow = () => {
|
|
|
8627
8896
|
};
|
|
8628
8897
|
|
|
8629
8898
|
const LabelMappings = {
|
|
8899
|
+
"Agent-Network-Outer-Workflow.routing-step": "Decision making process",
|
|
8630
8900
|
"routing-step": "Decision making process",
|
|
8631
8901
|
"agent-step": "Agent execution",
|
|
8902
|
+
"Agent-Network-Outer-Workflow.agent-step": "Agent execution",
|
|
8632
8903
|
"workflow-step": "Workflow execution",
|
|
8904
|
+
"Agent-Network-Outer-Workflow.workflow-step": "Workflow execution",
|
|
8905
|
+
toolStep: "Tool execution",
|
|
8906
|
+
"Agent-Network-Outer-Workflow.toolStep": "Tool execution",
|
|
8633
8907
|
"final-step": "Task completed"
|
|
8634
8908
|
};
|
|
8635
8909
|
const StepDropdown = () => {
|
|
@@ -8639,14 +8913,20 @@ const StepDropdown = () => {
|
|
|
8639
8913
|
const id = message?.metadata?.custom?.id;
|
|
8640
8914
|
if (!id) return /* @__PURE__ */ jsxRuntime.jsx("div", { children: "Something is wrong" });
|
|
8641
8915
|
const currentState = state[id];
|
|
8642
|
-
const latestStepId = currentState.executionSteps[currentState.executionSteps.length - 1];
|
|
8916
|
+
const latestStepId = currentState.executionSteps ? currentState.executionSteps?.[currentState.executionSteps.length - 1] : "";
|
|
8643
8917
|
const hasFinished = latestStepId === "finish";
|
|
8644
|
-
|
|
8918
|
+
const failed = Object.values(currentState?.steps || {}).some(
|
|
8919
|
+
(step) => step?.["error"] || step?.["step-result"]?.status === "failed"
|
|
8920
|
+
);
|
|
8921
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2 mb-2", children: [
|
|
8645
8922
|
/* @__PURE__ */ jsxRuntime.jsxs(Button, { onClick: () => setIsExpanded(!isExpanded), children: [
|
|
8646
|
-
hasFinished ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
8923
|
+
hasFinished ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: failed ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
8924
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(CrossIcon, { className: "text-accent2" }) }),
|
|
8925
|
+
"Failed"
|
|
8926
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
8647
8927
|
/* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(CheckIcon, { className: "text-accent1" }) }),
|
|
8648
8928
|
"Done"
|
|
8649
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
8929
|
+
] }) }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
8650
8930
|
/* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(Spinner, { className: "animate-spin" }) }),
|
|
8651
8931
|
"Thinking..."
|
|
8652
8932
|
] }),
|
|
@@ -8658,11 +8938,29 @@ const StepDropdown = () => {
|
|
|
8658
8938
|
const Steps = ({ id }) => {
|
|
8659
8939
|
const { state } = useVNextNetworkChat();
|
|
8660
8940
|
const currentState = state[id];
|
|
8661
|
-
return /* @__PURE__ */ jsxRuntime.jsx("ol", { className: "flex flex-col gap-px rounded-lg overflow-hidden", children: currentState.executionSteps
|
|
8941
|
+
return /* @__PURE__ */ jsxRuntime.jsx("ol", { className: "flex flex-col gap-px rounded-lg overflow-hidden", children: currentState.executionSteps?.filter((stepId) => stepId !== "start").map((stepId, index) => /* @__PURE__ */ jsxRuntime.jsx(StepEntry, { stepId, step: currentState.steps[stepId] || {}, runId: currentState.runId }, index)) });
|
|
8662
8942
|
};
|
|
8663
8943
|
const StepEntry = ({ stepId, step, runId }) => {
|
|
8664
8944
|
const [expanded, setExpanded] = React.useState(false);
|
|
8665
|
-
|
|
8945
|
+
let stepResult = step["step-result"];
|
|
8946
|
+
const stepError = step["error"];
|
|
8947
|
+
if (stepId === "workflow-step" || stepId === "Agent-Network-Outer-Workflow.workflow-step") {
|
|
8948
|
+
const parsedResult = JSON.parse(stepResult?.output?.result ?? "{}") ?? {};
|
|
8949
|
+
if (!parsedResult?.runResult && stepResult?.status === "success") {
|
|
8950
|
+
stepResult = {
|
|
8951
|
+
...stepResult,
|
|
8952
|
+
status: "failed",
|
|
8953
|
+
error: "Something went wrong"
|
|
8954
|
+
};
|
|
8955
|
+
}
|
|
8956
|
+
}
|
|
8957
|
+
if (stepError) {
|
|
8958
|
+
stepResult = {
|
|
8959
|
+
...stepResult,
|
|
8960
|
+
status: "failed",
|
|
8961
|
+
error: stepError?.data?.error?.message
|
|
8962
|
+
};
|
|
8963
|
+
}
|
|
8666
8964
|
if (stepId === "finish") {
|
|
8667
8965
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-surface4 py-2 px-3 text-icon6 flex items-center gap-4 justify-between", children: /* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-sm", className: "text-icon6", children: "Process completed" }) });
|
|
8668
8966
|
}
|
|
@@ -8681,7 +8979,7 @@ const StepEntry = ({ stepId, step, runId }) => {
|
|
|
8681
8979
|
]
|
|
8682
8980
|
}
|
|
8683
8981
|
),
|
|
8684
|
-
stepId === "routing-step" && expanded && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-surface1 p-3 space-y-4", children: [
|
|
8982
|
+
(stepId === "routing-step" || stepId === "Agent-Network-Outer-Workflow.routing-step") && expanded && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-surface1 p-3 space-y-4", children: [
|
|
8685
8983
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
8686
8984
|
/* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-sm", className: "text-icon3 font-medium", children: "Selection reason:" }),
|
|
8687
8985
|
/* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-sm", className: "text-icon6", children: stepResult?.output?.selectionReason || "N/A" })
|
|
@@ -8689,8 +8987,20 @@ const StepEntry = ({ stepId, step, runId }) => {
|
|
|
8689
8987
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
8690
8988
|
/* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-sm", className: "text-icon3 font-medium", children: "Resource ID" }),
|
|
8691
8989
|
/* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-sm", className: "text-icon6", children: stepResult?.output?.resourceId || "N/A" })
|
|
8692
|
-
] })
|
|
8990
|
+
] }),
|
|
8991
|
+
stepResult?.error ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
8992
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-sm", className: "text-icon3 font-medium", children: "Error" }),
|
|
8993
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-sm", className: "text-icon6", children: stepResult?.error || "N/A" })
|
|
8994
|
+
] }) : null
|
|
8693
8995
|
] }),
|
|
8996
|
+
(stepId === "agent-step" || stepId === "Agent-Network-Outer-Workflow.agent-step") && (stepError || stepResult?.error) && expanded && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-surface1 p-3 space-y-4", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
8997
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-sm", className: "text-icon3 font-medium", children: "Error" }),
|
|
8998
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-sm", className: "text-icon6", children: stepError?.message || stepError?.data?.error?.message || stepResult?.error || "N/A" })
|
|
8999
|
+
] }) }),
|
|
9000
|
+
(stepId === "toolStep" || stepId === "Agent-Network-Outer-Workflow.toolStep") && (stepError || stepResult?.error) && expanded && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-surface1 p-3 space-y-4", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
9001
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-sm", className: "text-icon3 font-medium", children: "Error" }),
|
|
9002
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-sm", className: "text-icon6", children: stepError?.message || stepError?.data?.error?.message || stepResult?.error || "N/A" })
|
|
9003
|
+
] }) }),
|
|
8694
9004
|
stepId === "final-step" && expanded && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-surface1 p-3 space-y-4", children: [
|
|
8695
9005
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
8696
9006
|
/* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-sm", className: "text-icon3 font-medium", children: "Task:" }),
|
|
@@ -8701,7 +9011,7 @@ const StepEntry = ({ stepId, step, runId }) => {
|
|
|
8701
9011
|
/* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-sm", className: "text-icon6", children: stepResult?.output?.iteration || "N/A" })
|
|
8702
9012
|
] })
|
|
8703
9013
|
] }),
|
|
8704
|
-
stepId === "workflow-step" && stepResult?.output?.resourceId ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
9014
|
+
(stepId === "workflow-step" || stepId === "Agent-Network-Outer-Workflow.workflow-step") && stepResult?.output?.resourceId ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
8705
9015
|
WorkflowStepResultDialog,
|
|
8706
9016
|
{
|
|
8707
9017
|
open: expanded,
|
|
@@ -8722,7 +9032,7 @@ const WorkflowStepResultDialog = ({ open, onOpenChange, workflowId, runId }) =>
|
|
|
8722
9032
|
] }) }) }) });
|
|
8723
9033
|
};
|
|
8724
9034
|
const StatusIcon = ({ status }) => {
|
|
8725
|
-
if (status === "
|
|
9035
|
+
if (status === "failed") {
|
|
8726
9036
|
return /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(CrossIcon, { className: "text-accent2" }) });
|
|
8727
9037
|
}
|
|
8728
9038
|
if (status === "success") {
|
|
@@ -8873,7 +9183,7 @@ const SpeechInput = () => {
|
|
|
8873
9183
|
variant: "ghost",
|
|
8874
9184
|
className: "rounded-full",
|
|
8875
9185
|
onClick: () => isListening ? stop() : start(),
|
|
8876
|
-
children: isListening ? /* @__PURE__ */ jsxRuntime.jsx(CircleStopIcon, {}) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Mic, { className: "h-6 w-6 text-[#898989] hover:text-[#fff]" })
|
|
9186
|
+
children: isListening ? /* @__PURE__ */ jsxRuntime.jsx(CircleStopIcon$1, {}) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Mic, { className: "h-6 w-6 text-[#898989] hover:text-[#fff]" })
|
|
8877
9187
|
}
|
|
8878
9188
|
);
|
|
8879
9189
|
};
|
|
@@ -8889,7 +9199,7 @@ const ComposerAction = ({ showFileSupport }) => {
|
|
|
8889
9199
|
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowUp, { className: "h-6 w-6 text-[#898989] hover:text-[#fff]" })
|
|
8890
9200
|
}
|
|
8891
9201
|
) }) }),
|
|
8892
|
-
/* @__PURE__ */ jsxRuntime.jsx(react.ThreadPrimitive.If, { running: true, children: /* @__PURE__ */ jsxRuntime.jsx(react.ComposerPrimitive.Cancel, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(TooltipIconButton, { tooltip: "Cancel", variant: "default", children: /* @__PURE__ */ jsxRuntime.jsx(CircleStopIcon, {}) }) }) })
|
|
9202
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.ThreadPrimitive.If, { running: true, children: /* @__PURE__ */ jsxRuntime.jsx(react.ComposerPrimitive.Cancel, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(TooltipIconButton, { tooltip: "Cancel", variant: "default", children: /* @__PURE__ */ jsxRuntime.jsx(CircleStopIcon$1, {}) }) }) })
|
|
8893
9203
|
] });
|
|
8894
9204
|
};
|
|
8895
9205
|
const EditComposer = () => {
|
|
@@ -8901,7 +9211,7 @@ const EditComposer = () => {
|
|
|
8901
9211
|
] })
|
|
8902
9212
|
] });
|
|
8903
9213
|
};
|
|
8904
|
-
const CircleStopIcon = () => {
|
|
9214
|
+
const CircleStopIcon$1 = () => {
|
|
8905
9215
|
return /* @__PURE__ */ jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", fill: "currentColor", width: "16", height: "16", children: /* @__PURE__ */ jsxRuntime.jsx("rect", { width: "10", height: "10", x: "3", y: "3", rx: "2" }) });
|
|
8906
9216
|
};
|
|
8907
9217
|
|
|
@@ -8964,26 +9274,30 @@ function VNextMastraNetworkRuntimeProvider({
|
|
|
8964
9274
|
const hasFinished = Boolean(currentState?.steps?.["finish"]);
|
|
8965
9275
|
if (!hasFinished) return;
|
|
8966
9276
|
const workflowStep = currentState?.steps?.["workflow-step"];
|
|
8967
|
-
|
|
9277
|
+
const toolStep = currentState?.steps?.["toolStep"];
|
|
9278
|
+
if (!workflowStep && !toolStep) return;
|
|
8968
9279
|
const workflowStepResult = workflowStep?.["step-result"];
|
|
8969
|
-
|
|
9280
|
+
const toolStepResult = toolStep?.["step-result"];
|
|
9281
|
+
if (!workflowStepResult && !toolStepResult) return;
|
|
8970
9282
|
const workflowStepResultOutput = workflowStepResult?.output;
|
|
8971
|
-
|
|
9283
|
+
const toolStepResultOutput = toolStepResult?.output;
|
|
9284
|
+
if (!workflowStepResultOutput && !toolStepResultOutput) return;
|
|
8972
9285
|
const run = async () => {
|
|
8973
|
-
const parsedResult = JSON.parse(workflowStepResult?.output?.result ?? "{}") ?? {};
|
|
8974
|
-
|
|
8975
|
-
|
|
8976
|
-
|
|
8977
|
-
|
|
8978
|
-
|
|
9286
|
+
const parsedResult = workflowStepResult ? JSON.parse(workflowStepResult?.output?.result ?? "{}") ?? {} : { runResult: toolStepResultOutput?.result ?? {} };
|
|
9287
|
+
if (parsedResult?.runResult) {
|
|
9288
|
+
const runResult = parsedResult?.runResult ?? {};
|
|
9289
|
+
const formatted = await formatJSON(JSON.stringify(runResult));
|
|
9290
|
+
setMessages((msgs) => [
|
|
9291
|
+
...msgs,
|
|
9292
|
+
{ role: "assistant", content: [{ type: "text", text: `\`\`\`json
|
|
8979
9293
|
${formatted}\`\`\`` }] }
|
|
8980
|
-
|
|
9294
|
+
]);
|
|
9295
|
+
}
|
|
8981
9296
|
};
|
|
8982
9297
|
run();
|
|
8983
9298
|
}, [currentState]);
|
|
8984
9299
|
React.useEffect(() => {
|
|
8985
|
-
|
|
8986
|
-
if (messages.length === 0 || currentThreadId !== threadId || hasNewInitialMessages && currentThreadId === threadId) {
|
|
9300
|
+
if (messages.length === 0 || currentThreadId !== threadId) {
|
|
8987
9301
|
const run = async (result, messageId) => {
|
|
8988
9302
|
const formatted = await formatJSON(result);
|
|
8989
9303
|
const finalResponse = `\`\`\`json
|
|
@@ -8998,84 +9312,219 @@ ${formatted}\`\`\``;
|
|
|
8998
9312
|
});
|
|
8999
9313
|
};
|
|
9000
9314
|
if (initialMessages && threadId && memory) {
|
|
9001
|
-
|
|
9315
|
+
let userMessage = "";
|
|
9316
|
+
let iteration = 1;
|
|
9317
|
+
const formattedMessages = [];
|
|
9318
|
+
let assistantStep = freshAssistantStep();
|
|
9319
|
+
for (let i = 0; i < initialMessages.length; i++) {
|
|
9320
|
+
const message = initialMessages[i];
|
|
9002
9321
|
if (message.role === "user") {
|
|
9003
|
-
|
|
9322
|
+
assistantStep = freshAssistantStep();
|
|
9323
|
+
userMessage = message.content;
|
|
9324
|
+
formattedMessages.push({
|
|
9325
|
+
role: "user",
|
|
9326
|
+
message
|
|
9327
|
+
});
|
|
9328
|
+
continue;
|
|
9004
9329
|
}
|
|
9005
9330
|
if (message.role === "assistant") {
|
|
9006
|
-
const
|
|
9007
|
-
|
|
9008
|
-
|
|
9009
|
-
|
|
9010
|
-
|
|
9011
|
-
const
|
|
9012
|
-
|
|
9013
|
-
|
|
9331
|
+
const responseArray = message.parts ?? [];
|
|
9332
|
+
let hasRoutingDecision = false;
|
|
9333
|
+
let hasTaskCompleteDecision = false;
|
|
9334
|
+
let directText = "";
|
|
9335
|
+
let jsonStringResponse = "";
|
|
9336
|
+
for (const part of responseArray) {
|
|
9337
|
+
if (part.type === "text" && part.text) {
|
|
9338
|
+
const parsed = safeParse(part.text);
|
|
9339
|
+
if (parsed?.resourceId && parsed?.resourceType) {
|
|
9340
|
+
hasRoutingDecision = true;
|
|
9341
|
+
assistantStep.routingDecision = parsed;
|
|
9342
|
+
}
|
|
9343
|
+
if (typeof parsed?.isComplete === "boolean") {
|
|
9344
|
+
hasTaskCompleteDecision = true;
|
|
9345
|
+
assistantStep.taskCompleteDecision = parsed;
|
|
9346
|
+
if (parsed?.isComplete) {
|
|
9347
|
+
assistantStep.finalResponse = parsed.finalResult;
|
|
9348
|
+
formattedMessages.push({ role: "assistant", message: assistantStep });
|
|
9349
|
+
assistantStep = freshAssistantStep();
|
|
9350
|
+
}
|
|
9351
|
+
}
|
|
9352
|
+
if (!parsed || !parsed.resourceId && !parsed.runResult && typeof parsed.isComplete !== "boolean") {
|
|
9353
|
+
directText = part.text;
|
|
9354
|
+
}
|
|
9355
|
+
if (parsed && !parsed.resourceId && typeof parsed.isComplete !== "boolean") {
|
|
9356
|
+
jsonStringResponse = part.text;
|
|
9357
|
+
}
|
|
9358
|
+
}
|
|
9359
|
+
}
|
|
9360
|
+
if (!hasRoutingDecision && !hasTaskCompleteDecision) {
|
|
9361
|
+
assistantStep.finalResponse = directText || jsonStringResponse;
|
|
9362
|
+
if (assistantStep.routingDecision || assistantStep.finalResponse) {
|
|
9363
|
+
formattedMessages.push({ role: "assistant", message: assistantStep });
|
|
9364
|
+
assistantStep = freshAssistantStep();
|
|
9365
|
+
}
|
|
9366
|
+
}
|
|
9367
|
+
}
|
|
9368
|
+
if (i === initialMessages.length - 1 && (assistantStep.routingDecision || assistantStep.finalResponse)) {
|
|
9369
|
+
formattedMessages.push({ role: "assistant", message: assistantStep });
|
|
9370
|
+
}
|
|
9371
|
+
}
|
|
9372
|
+
for (const formattedMessage of formattedMessages) {
|
|
9373
|
+
const { role, message } = formattedMessage;
|
|
9374
|
+
if (role === "user") {
|
|
9375
|
+
iteration = 1;
|
|
9376
|
+
userMessage = message.content;
|
|
9377
|
+
setMessages((currentConversation) => {
|
|
9378
|
+
if (currentConversation.some((m) => m.id === message.id)) {
|
|
9379
|
+
return currentConversation;
|
|
9380
|
+
}
|
|
9381
|
+
return [...currentConversation, message];
|
|
9382
|
+
});
|
|
9383
|
+
}
|
|
9384
|
+
if (role === "assistant") {
|
|
9385
|
+
const { id: id2, formattedMessageId, finalStepId, routingDecision, finalResponse, taskCompleteDecision } = message;
|
|
9386
|
+
let resourceStepId = "";
|
|
9387
|
+
if (routingDecision?.resourceType === "agent") resourceStepId = "agent-step";
|
|
9388
|
+
if (routingDecision?.resourceType === "tool") resourceStepId = "toolStep";
|
|
9389
|
+
if (routingDecision?.resourceType === "workflow") resourceStepId = "workflow-step";
|
|
9014
9390
|
let runId = "";
|
|
9015
9391
|
let runResult = {};
|
|
9016
|
-
|
|
9017
|
-
|
|
9018
|
-
|
|
9392
|
+
let finalStep = null;
|
|
9393
|
+
let finalResult = "";
|
|
9394
|
+
if (resourceStepId === "workflow-step" || resourceStepId === "toolStep") {
|
|
9395
|
+
const parsedResult = JSON.parse(finalResponse ?? "{}") ?? {};
|
|
9396
|
+
runResult = resourceStepId === "workflow-step" ? parsedResult?.runResult ?? {} : parsedResult ?? {};
|
|
9019
9397
|
runId = parsedResult?.runId ?? "";
|
|
9020
9398
|
}
|
|
9399
|
+
if (taskCompleteDecision?.isComplete) {
|
|
9400
|
+
finalStep = {
|
|
9401
|
+
executionSteps: ["start", "routing-step", "final-step", "finish"],
|
|
9402
|
+
runId: "",
|
|
9403
|
+
steps: {
|
|
9404
|
+
start: {},
|
|
9405
|
+
"routing-step": {
|
|
9406
|
+
"step-result": {
|
|
9407
|
+
output: {
|
|
9408
|
+
selectionReason: taskCompleteDecision?.completionReason ?? ""
|
|
9409
|
+
},
|
|
9410
|
+
status: "success"
|
|
9411
|
+
}
|
|
9412
|
+
},
|
|
9413
|
+
"final-step": {
|
|
9414
|
+
"step-result": {
|
|
9415
|
+
output: {
|
|
9416
|
+
iteration,
|
|
9417
|
+
task: userMessage
|
|
9418
|
+
},
|
|
9419
|
+
status: "success"
|
|
9420
|
+
}
|
|
9421
|
+
},
|
|
9422
|
+
finish: {}
|
|
9423
|
+
}
|
|
9424
|
+
};
|
|
9425
|
+
finalResult = taskCompleteDecision?.finalResult;
|
|
9426
|
+
}
|
|
9427
|
+
const routingStepFailed = resourceStepId === "workflow-step" || resourceStepId === "toolStep" ? Object.keys(runResult).length === 0 : !finalResponse;
|
|
9021
9428
|
setState((currentState2) => {
|
|
9022
9429
|
return {
|
|
9023
9430
|
...currentState2,
|
|
9024
|
-
[
|
|
9025
|
-
|
|
9026
|
-
|
|
9027
|
-
|
|
9028
|
-
|
|
9029
|
-
|
|
9030
|
-
"step
|
|
9031
|
-
|
|
9032
|
-
|
|
9033
|
-
|
|
9034
|
-
|
|
9035
|
-
|
|
9036
|
-
|
|
9037
|
-
|
|
9038
|
-
|
|
9039
|
-
|
|
9040
|
-
|
|
9041
|
-
|
|
9042
|
-
|
|
9043
|
-
|
|
9431
|
+
...finalStep ? { [finalStepId]: finalStep } : {
|
|
9432
|
+
[id2]: {
|
|
9433
|
+
executionSteps: ["start", "routing-step", resourceStepId, "finish"],
|
|
9434
|
+
runId,
|
|
9435
|
+
steps: {
|
|
9436
|
+
start: {},
|
|
9437
|
+
"routing-step": {
|
|
9438
|
+
"step-result": {
|
|
9439
|
+
output: routingDecision,
|
|
9440
|
+
status: routingDecision ? "success" : "failed",
|
|
9441
|
+
...routingDecision ? {} : { error: "Something went wrong" }
|
|
9442
|
+
}
|
|
9443
|
+
},
|
|
9444
|
+
[resourceStepId]: {
|
|
9445
|
+
"step-result": {
|
|
9446
|
+
output: {
|
|
9447
|
+
resourceId: routingDecision?.resourceId,
|
|
9448
|
+
result: finalResponse ?? ""
|
|
9449
|
+
},
|
|
9450
|
+
status: routingStepFailed ? "failed" : "success",
|
|
9451
|
+
...routingStepFailed ? { error: "Something went wrong" } : {}
|
|
9452
|
+
}
|
|
9453
|
+
},
|
|
9454
|
+
finish: {}
|
|
9455
|
+
}
|
|
9044
9456
|
}
|
|
9045
9457
|
}
|
|
9046
9458
|
};
|
|
9047
9459
|
});
|
|
9048
9460
|
setMessages((currentConversation) => {
|
|
9461
|
+
const assistantRoutingMessageExist = currentConversation.some(
|
|
9462
|
+
(message2) => message2.metadata?.custom?.id === id2
|
|
9463
|
+
);
|
|
9464
|
+
const assistantResponseMessageExist = currentConversation.some(
|
|
9465
|
+
(message2) => message2.metadata?.custom?.id === formattedMessageId
|
|
9466
|
+
);
|
|
9049
9467
|
return [
|
|
9050
9468
|
...currentConversation,
|
|
9051
|
-
|
|
9052
|
-
|
|
9053
|
-
|
|
9054
|
-
|
|
9055
|
-
|
|
9056
|
-
|
|
9469
|
+
...finalResult ? [
|
|
9470
|
+
{
|
|
9471
|
+
role: "assistant",
|
|
9472
|
+
metadata: {
|
|
9473
|
+
custom: {
|
|
9474
|
+
id: finalStepId
|
|
9475
|
+
}
|
|
9476
|
+
},
|
|
9477
|
+
content: [
|
|
9478
|
+
{
|
|
9479
|
+
type: "text",
|
|
9480
|
+
text: "start"
|
|
9481
|
+
}
|
|
9482
|
+
]
|
|
9057
9483
|
},
|
|
9058
|
-
|
|
9484
|
+
{
|
|
9485
|
+
role: "assistant",
|
|
9486
|
+
content: [{ type: "text", text: finalResult }]
|
|
9487
|
+
}
|
|
9488
|
+
] : [
|
|
9489
|
+
...assistantRoutingMessageExist ? [] : [
|
|
9059
9490
|
{
|
|
9060
|
-
|
|
9061
|
-
|
|
9491
|
+
role: "assistant",
|
|
9492
|
+
metadata: {
|
|
9493
|
+
custom: {
|
|
9494
|
+
id: id2
|
|
9495
|
+
}
|
|
9496
|
+
},
|
|
9497
|
+
content: [
|
|
9498
|
+
{
|
|
9499
|
+
type: "text",
|
|
9500
|
+
text: "start"
|
|
9501
|
+
}
|
|
9502
|
+
]
|
|
9062
9503
|
}
|
|
9063
|
-
]
|
|
9064
|
-
|
|
9065
|
-
|
|
9066
|
-
|
|
9067
|
-
|
|
9068
|
-
|
|
9069
|
-
|
|
9070
|
-
|
|
9504
|
+
],
|
|
9505
|
+
...assistantResponseMessageExist ? [] : [
|
|
9506
|
+
{
|
|
9507
|
+
role: "assistant",
|
|
9508
|
+
content: [
|
|
9509
|
+
{
|
|
9510
|
+
type: "text",
|
|
9511
|
+
text: resourceStepId === "workflow-step" || resourceStepId === "toolStep" ? "" : finalResponse
|
|
9512
|
+
}
|
|
9513
|
+
],
|
|
9514
|
+
metadata: {
|
|
9515
|
+
custom: {
|
|
9516
|
+
id: formattedMessageId
|
|
9517
|
+
}
|
|
9518
|
+
}
|
|
9071
9519
|
}
|
|
9072
|
-
|
|
9073
|
-
|
|
9520
|
+
]
|
|
9521
|
+
]
|
|
9074
9522
|
];
|
|
9075
9523
|
});
|
|
9076
|
-
if (resourceStepId === "workflow-step") {
|
|
9524
|
+
if ((resourceStepId === "workflow-step" || resourceStepId === "toolStep") && !routingStepFailed) {
|
|
9077
9525
|
run(JSON.stringify(runResult), formattedMessageId);
|
|
9078
9526
|
}
|
|
9527
|
+
iteration++;
|
|
9079
9528
|
}
|
|
9080
9529
|
}
|
|
9081
9530
|
setCurrentThreadId(threadId);
|
|
@@ -9151,9 +9600,10 @@ ${formatted}\`\`\``;
|
|
|
9151
9600
|
handleStep(runIdRef.current, { ...record, type: "finish" });
|
|
9152
9601
|
runIdRef.current = void 0;
|
|
9153
9602
|
}
|
|
9154
|
-
} else if (record.type === "step-result" && record.payload?.id === "workflow-step") {
|
|
9603
|
+
} else if (record.type === "step-result" && (record.payload?.id === "Agent-Network-Outer-Workflow.workflow-step" || record.payload?.id === "Agent-Network-Outer-Workflow.toolStep")) {
|
|
9155
9604
|
handleStep(runIdRef.current, record);
|
|
9156
|
-
const
|
|
9605
|
+
const result = record?.payload?.output?.result;
|
|
9606
|
+
const parsedResult = typeof result === "string" ? JSON.parse(record?.payload?.output?.result ?? "{}") ?? {} : { runResult: result };
|
|
9157
9607
|
const runResult = parsedResult?.runResult ?? {};
|
|
9158
9608
|
const formatedOutputId = uuid.v4();
|
|
9159
9609
|
setMessages((msgs) => [
|
|
@@ -9192,9 +9642,11 @@ ${formatted}\`\`\``;
|
|
|
9192
9642
|
if (record.type === "step-finish" && record.payload?.id === "final-step") {
|
|
9193
9643
|
runIdRef.current = void 0;
|
|
9194
9644
|
}
|
|
9195
|
-
|
|
9196
|
-
|
|
9197
|
-
|
|
9645
|
+
if (record.type === "start" || record.type === "step-start" || record.type === "finish") {
|
|
9646
|
+
setTimeout(() => {
|
|
9647
|
+
refreshThreadList?.();
|
|
9648
|
+
}, 500);
|
|
9649
|
+
}
|
|
9198
9650
|
}
|
|
9199
9651
|
);
|
|
9200
9652
|
} else {
|
|
@@ -9210,9 +9662,6 @@ ${formatted}\`\`\``;
|
|
|
9210
9662
|
appendToLastMessage(record.argsTextDelta);
|
|
9211
9663
|
} else if (record.type === "tool-call-streaming-start") {
|
|
9212
9664
|
setMessages((msgs) => [...msgs, { role: "assistant", content: [{ type: "text", text: "" }] }]);
|
|
9213
|
-
setTimeout(() => {
|
|
9214
|
-
refreshThreadList?.();
|
|
9215
|
-
}, 500);
|
|
9216
9665
|
return;
|
|
9217
9666
|
} else {
|
|
9218
9667
|
handleStep(runIdRef.current, record);
|
|
@@ -9240,9 +9689,11 @@ ${formatted}\`\`\``;
|
|
|
9240
9689
|
];
|
|
9241
9690
|
});
|
|
9242
9691
|
}
|
|
9243
|
-
|
|
9244
|
-
|
|
9245
|
-
|
|
9692
|
+
if (record.type === "start" || record.type === "step-start" || record.type === "finish") {
|
|
9693
|
+
setTimeout(() => {
|
|
9694
|
+
refreshThreadList?.();
|
|
9695
|
+
}, 500);
|
|
9696
|
+
}
|
|
9246
9697
|
}
|
|
9247
9698
|
);
|
|
9248
9699
|
}
|
|
@@ -9263,6 +9714,21 @@ ${formatted}\`\`\``;
|
|
|
9263
9714
|
children,
|
|
9264
9715
|
" "
|
|
9265
9716
|
] });
|
|
9717
|
+
function safeParse(str) {
|
|
9718
|
+
try {
|
|
9719
|
+
return JSON.parse(str);
|
|
9720
|
+
} catch {
|
|
9721
|
+
return void 0;
|
|
9722
|
+
}
|
|
9723
|
+
}
|
|
9724
|
+
function freshAssistantStep() {
|
|
9725
|
+
return {
|
|
9726
|
+
id: uuid.v4(),
|
|
9727
|
+
formattedMessageId: uuid.v4(),
|
|
9728
|
+
finalStepId: uuid.v4(),
|
|
9729
|
+
finalResponse: ""
|
|
9730
|
+
};
|
|
9731
|
+
}
|
|
9266
9732
|
}
|
|
9267
9733
|
|
|
9268
9734
|
const VNextNetworkChat = ({
|
|
@@ -10199,10 +10665,6 @@ class CustomZodProvider extends zod.ZodProvider {
|
|
|
10199
10665
|
}
|
|
10200
10666
|
}
|
|
10201
10667
|
|
|
10202
|
-
const labelVariants = cva("text-sm leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70");
|
|
10203
|
-
const Label = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(LabelPrimitive__namespace.Root, { ref, className: cn(labelVariants(), className), ...props }));
|
|
10204
|
-
Label.displayName = LabelPrimitive__namespace.Root.displayName;
|
|
10205
|
-
|
|
10206
10668
|
function isEmptyZodObject(schema) {
|
|
10207
10669
|
if (schema instanceof z.ZodObject) {
|
|
10208
10670
|
return Object.keys(schema.shape).length === 0;
|
|
@@ -10281,9 +10743,13 @@ function CodeBlockDemo({
|
|
|
10281
10743
|
}
|
|
10282
10744
|
|
|
10283
10745
|
const WorkflowCard = ({ header, children, footer }) => {
|
|
10746
|
+
const [expanded, setExpanded] = React.useState(false);
|
|
10284
10747
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border-sm border-border1 bg-surface4", children: [
|
|
10285
|
-
/* @__PURE__ */ jsxRuntime.
|
|
10286
|
-
|
|
10748
|
+
/* @__PURE__ */ jsxRuntime.jsxs("button", { className: "py-1 px-2 flex items-center gap-3 justify-between w-full", onClick: () => setExpanded((s) => !s), children: [
|
|
10749
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full", children: header }),
|
|
10750
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDownIcon, { className: cn("text-icon3 transition-transform -rotate-90", expanded && "rotate-0") }) })
|
|
10751
|
+
] }),
|
|
10752
|
+
children && expanded && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t-sm border-border1", children }),
|
|
10287
10753
|
footer && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "py-1 px-2 border-t-sm border-border1", children: footer })
|
|
10288
10754
|
] });
|
|
10289
10755
|
};
|
|
@@ -10486,33 +10952,59 @@ function LegacyWorkflowTrigger({
|
|
|
10486
10952
|
] }) });
|
|
10487
10953
|
}
|
|
10488
10954
|
|
|
10955
|
+
const WorkflowStatus = ({ stepId, status, result }) => {
|
|
10956
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
10957
|
+
WorkflowCard,
|
|
10958
|
+
{
|
|
10959
|
+
header: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
10960
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Icon, { children: [
|
|
10961
|
+
status === "success" && /* @__PURE__ */ jsxRuntime.jsx(CheckIcon, { className: "text-accent1" }),
|
|
10962
|
+
status === "failed" && /* @__PURE__ */ jsxRuntime.jsx(CrossIcon, { className: "text-accent2" }),
|
|
10963
|
+
status === "suspended" && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CirclePause, { className: "text-accent3" }),
|
|
10964
|
+
status === "waiting" && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.HourglassIcon, { className: "text-accent5" }),
|
|
10965
|
+
status === "running" && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "text-icon3 animate-spin" })
|
|
10966
|
+
] }),
|
|
10967
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "span", variant: "ui-lg", className: "text-icon6 font-medium", children: stepId.charAt(0).toUpperCase() + stepId.slice(1) })
|
|
10968
|
+
] }),
|
|
10969
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-md bg-surface4 p-1 font-mono relative", children: [
|
|
10970
|
+
/* @__PURE__ */ jsxRuntime.jsx(CopyButton, { content: JSON.stringify(result, null, 2), className: "absolute top-2 right-2 z-10" }),
|
|
10971
|
+
/* @__PURE__ */ jsxRuntime.jsx(SyntaxHighlighter, { data: result })
|
|
10972
|
+
] })
|
|
10973
|
+
}
|
|
10974
|
+
);
|
|
10975
|
+
};
|
|
10976
|
+
|
|
10489
10977
|
function WorkflowTrigger({
|
|
10490
10978
|
workflowId,
|
|
10491
10979
|
setRunId,
|
|
10492
10980
|
workflow,
|
|
10493
10981
|
isLoading,
|
|
10494
10982
|
createWorkflowRun,
|
|
10495
|
-
startWorkflowRun,
|
|
10496
10983
|
resumeWorkflow,
|
|
10497
|
-
|
|
10498
|
-
|
|
10499
|
-
|
|
10500
|
-
isResumingWorkflow
|
|
10984
|
+
streamWorkflow,
|
|
10985
|
+
isStreamingWorkflow,
|
|
10986
|
+
streamResult,
|
|
10987
|
+
isResumingWorkflow,
|
|
10988
|
+
isCancellingWorkflowRun,
|
|
10989
|
+
cancelWorkflowRun
|
|
10501
10990
|
}) {
|
|
10502
10991
|
const { runtimeContext } = usePlaygroundStore();
|
|
10503
10992
|
const { result, setResult, payload, setPayload } = React.useContext(WorkflowRunContext);
|
|
10504
10993
|
const [suspendedSteps, setSuspendedSteps] = React.useState([]);
|
|
10505
10994
|
const [isRunning, setIsRunning] = React.useState(false);
|
|
10995
|
+
const [innerRunId, setInnerRunId] = React.useState("");
|
|
10996
|
+
const [cancelResponse, setCancelResponse] = React.useState(null);
|
|
10506
10997
|
const triggerSchema = workflow?.inputSchema;
|
|
10507
10998
|
const handleExecuteWorkflow = async (data) => {
|
|
10508
10999
|
try {
|
|
10509
11000
|
if (!workflow) return;
|
|
10510
11001
|
setIsRunning(true);
|
|
11002
|
+
setCancelResponse(null);
|
|
10511
11003
|
setResult(null);
|
|
10512
11004
|
const { runId } = await createWorkflowRun({ workflowId });
|
|
10513
11005
|
setRunId?.(runId);
|
|
10514
|
-
|
|
10515
|
-
|
|
11006
|
+
setInnerRunId(runId);
|
|
11007
|
+
streamWorkflow({ workflowId, runId, inputData: data, runtimeContext });
|
|
10516
11008
|
} catch (err) {
|
|
10517
11009
|
setIsRunning(false);
|
|
10518
11010
|
sonner.toast.error("Error executing workflow");
|
|
@@ -10520,9 +11012,9 @@ function WorkflowTrigger({
|
|
|
10520
11012
|
};
|
|
10521
11013
|
const handleResumeWorkflow = async (step) => {
|
|
10522
11014
|
if (!workflow) return;
|
|
11015
|
+
setCancelResponse(null);
|
|
10523
11016
|
const { stepId, runId: prevRunId, resumeData } = step;
|
|
10524
11017
|
const { runId } = await createWorkflowRun({ workflowId, prevRunId });
|
|
10525
|
-
watchWorkflow({ workflowId, runId });
|
|
10526
11018
|
await resumeWorkflow({
|
|
10527
11019
|
step: stepId,
|
|
10528
11020
|
runId,
|
|
@@ -10531,25 +11023,29 @@ function WorkflowTrigger({
|
|
|
10531
11023
|
runtimeContext
|
|
10532
11024
|
});
|
|
10533
11025
|
};
|
|
10534
|
-
const
|
|
11026
|
+
const handleCancelWorkflowRun = async () => {
|
|
11027
|
+
const response = await cancelWorkflowRun({ workflowId, runId: innerRunId });
|
|
11028
|
+
setCancelResponse(response);
|
|
11029
|
+
};
|
|
11030
|
+
const streamResultToUse = result ?? streamResult;
|
|
10535
11031
|
React.useEffect(() => {
|
|
10536
|
-
setIsRunning(
|
|
10537
|
-
}, [
|
|
11032
|
+
setIsRunning(isStreamingWorkflow);
|
|
11033
|
+
}, [isStreamingWorkflow]);
|
|
10538
11034
|
React.useEffect(() => {
|
|
10539
|
-
if (!
|
|
10540
|
-
const suspended = Object.entries(
|
|
11035
|
+
if (!streamResultToUse?.payload?.workflowState?.steps || !result?.runId) return;
|
|
11036
|
+
const suspended = Object.entries(streamResultToUse.payload.workflowState.steps).filter(([_, { status }]) => status === "suspended").map(([stepId, { payload: payload2 }]) => ({
|
|
10541
11037
|
stepId,
|
|
10542
11038
|
runId: result.runId,
|
|
10543
11039
|
suspendPayload: payload2,
|
|
10544
11040
|
isLoading: false
|
|
10545
11041
|
}));
|
|
10546
11042
|
setSuspendedSteps(suspended);
|
|
10547
|
-
}, [
|
|
11043
|
+
}, [streamResultToUse, result]);
|
|
10548
11044
|
React.useEffect(() => {
|
|
10549
|
-
if (
|
|
10550
|
-
setResult(
|
|
11045
|
+
if (streamResult) {
|
|
11046
|
+
setResult(streamResult);
|
|
10551
11047
|
}
|
|
10552
|
-
}, [
|
|
11048
|
+
}, [streamResult]);
|
|
10553
11049
|
if (isLoading) {
|
|
10554
11050
|
return /* @__PURE__ */ jsxRuntime.jsx(ScrollArea, { className: "h-[calc(100vh-126px)] pt-2 px-4 pb-4 text-xs", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
|
|
10555
11051
|
/* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-10" }),
|
|
@@ -10559,10 +11055,23 @@ function WorkflowTrigger({
|
|
|
10559
11055
|
if (!workflow) return null;
|
|
10560
11056
|
const isSuspendedSteps = suspendedSteps.length > 0;
|
|
10561
11057
|
const zodInputSchema = triggerSchema ? resolveSerializedZodOutput(jsonSchemaToZod(superjson.parse(triggerSchema))) : null;
|
|
10562
|
-
const
|
|
11058
|
+
const workflowActivePaths = streamResultToUse?.payload?.workflowState?.steps ?? {};
|
|
11059
|
+
const hasWorkflowActivePaths = Object.values(workflowActivePaths).length > 0;
|
|
10563
11060
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "h-full pt-3 pb-12", children: [
|
|
10564
11061
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4 px-5 pb-5 border-b-sm border-border1", children: [
|
|
10565
|
-
|
|
11062
|
+
result?.runId && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11063
|
+
Button,
|
|
11064
|
+
{
|
|
11065
|
+
variant: "light",
|
|
11066
|
+
onClick: handleCancelWorkflowRun,
|
|
11067
|
+
disabled: !!cancelResponse?.message || isCancellingWorkflowRun,
|
|
11068
|
+
children: [
|
|
11069
|
+
isCancellingWorkflowRun ? /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "animate-spin" }) }) : /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(CircleStopIcon, {}) }),
|
|
11070
|
+
cancelResponse?.message || "Cancel Workflow Run"
|
|
11071
|
+
]
|
|
11072
|
+
}
|
|
11073
|
+
),
|
|
11074
|
+
(isResumingWorkflow || isSuspendedSteps && isStreamingWorkflow) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "py-2 px-5 flex items-center gap-2 bg-surface5 -mx-5 -mt-5 border-b-sm border-border1", children: [
|
|
10566
11075
|
/* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "animate-spin text-icon6" }) }),
|
|
10567
11076
|
/* @__PURE__ */ jsxRuntime.jsx(Txt, { children: "Resuming workflow" })
|
|
10568
11077
|
] }),
|
|
@@ -10571,7 +11080,7 @@ function WorkflowTrigger({
|
|
|
10571
11080
|
{
|
|
10572
11081
|
schema: zodInputSchema,
|
|
10573
11082
|
defaultValues: payload,
|
|
10574
|
-
isSubmitLoading:
|
|
11083
|
+
isSubmitLoading: isStreamingWorkflow,
|
|
10575
11084
|
submitButtonLabel: "Run",
|
|
10576
11085
|
onSubmit: (data) => {
|
|
10577
11086
|
setPayload(data);
|
|
@@ -10588,8 +11097,9 @@ function WorkflowTrigger({
|
|
|
10588
11097
|
children: isRunning ? /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "animate-spin" }) }) : "Trigger"
|
|
10589
11098
|
}
|
|
10590
11099
|
) }),
|
|
10591
|
-
!
|
|
10592
|
-
const stepDefinition = workflow.
|
|
11100
|
+
!isStreamingWorkflow && isSuspendedSteps && suspendedSteps?.map((step) => {
|
|
11101
|
+
const stepDefinition = workflow.allSteps[step.stepId];
|
|
11102
|
+
if (!stepDefinition || stepDefinition.isWorkflow) return null;
|
|
10593
11103
|
const stepSchema = stepDefinition?.resumeSchema ? resolveSerializedZodOutput(jsonSchemaToZod(superjson.parse(stepDefinition.resumeSchema))) : z.z.record(z.z.string(), z.z.any());
|
|
10594
11104
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col px-4", children: [
|
|
10595
11105
|
/* @__PURE__ */ jsxRuntime.jsx(Text, { variant: "secondary", className: "text-mastra-el-3", size: "xs", children: step.stepId }),
|
|
@@ -10608,18 +11118,28 @@ function WorkflowTrigger({
|
|
|
10608
11118
|
isSubmitLoading: isResumingWorkflow,
|
|
10609
11119
|
submitButtonLabel: "Resume",
|
|
10610
11120
|
onSubmit: (data) => {
|
|
11121
|
+
const stepIds = step.stepId?.split(".");
|
|
10611
11122
|
handleResumeWorkflow({
|
|
10612
|
-
stepId:
|
|
11123
|
+
stepId: stepIds,
|
|
10613
11124
|
runId: step.runId,
|
|
10614
11125
|
suspendPayload: step.suspendPayload,
|
|
10615
11126
|
resumeData: data});
|
|
10616
11127
|
}
|
|
10617
11128
|
}
|
|
10618
11129
|
)
|
|
10619
|
-
] });
|
|
10620
|
-
})
|
|
11130
|
+
] }, step.stepId);
|
|
11131
|
+
}),
|
|
11132
|
+
hasWorkflowActivePaths && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
11133
|
+
/* @__PURE__ */ jsxRuntime.jsx("hr", { className: "border-border1 border-sm my-5" }),
|
|
11134
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
11135
|
+
/* @__PURE__ */ jsxRuntime.jsx(Text, { variant: "secondary", className: "px-4 text-mastra-el-3", size: "xs", children: "Status" }),
|
|
11136
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 flex flex-col gap-4", children: Object.entries(workflowActivePaths).filter(([key, _]) => key !== "input" && !key.endsWith(".input")).map(([stepId, { status, output }]) => {
|
|
11137
|
+
return /* @__PURE__ */ jsxRuntime.jsx(WorkflowStatus, { stepId, status, result: output ?? {} }, stepId);
|
|
11138
|
+
}) })
|
|
11139
|
+
] })
|
|
11140
|
+
] })
|
|
10621
11141
|
] }),
|
|
10622
|
-
result && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-5 border-b-sm border-border1", children: /* @__PURE__ */ jsxRuntime.jsx(WorkflowJsonDialog, { result
|
|
11142
|
+
result && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-5 border-b-sm border-border1", children: /* @__PURE__ */ jsxRuntime.jsx(WorkflowJsonDialog, { result }) })
|
|
10623
11143
|
] });
|
|
10624
11144
|
}
|
|
10625
11145
|
const WorkflowJsonDialog = ({ result }) => {
|
|
@@ -10635,6 +11155,9 @@ const WorkflowJsonDialog = ({ result }) => {
|
|
|
10635
11155
|
] }) }) })
|
|
10636
11156
|
] });
|
|
10637
11157
|
};
|
|
11158
|
+
const CircleStopIcon = () => {
|
|
11159
|
+
return /* @__PURE__ */ jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", fill: "currentColor", width: "16", height: "16", children: /* @__PURE__ */ jsxRuntime.jsx("rect", { width: "10", height: "10", x: "3", y: "3", rx: "2" }) });
|
|
11160
|
+
};
|
|
10638
11161
|
|
|
10639
11162
|
const WorkflowRuns = ({ workflowId, runId, isLoading, runs, onPressRun }) => {
|
|
10640
11163
|
if (isLoading) {
|
|
@@ -11071,11 +11594,12 @@ function usePolling({
|
|
|
11071
11594
|
|
|
11072
11595
|
exports.AgentChat = AgentChat;
|
|
11073
11596
|
exports.AgentCoinIcon = AgentCoinIcon;
|
|
11074
|
-
exports.AgentContext = AgentContext;
|
|
11075
11597
|
exports.AgentEvals = AgentEvals;
|
|
11076
11598
|
exports.AgentIcon = AgentIcon;
|
|
11599
|
+
exports.AgentModelSettings = AgentModelSettings;
|
|
11077
11600
|
exports.AgentNetworkCoinIcon = AgentNetworkCoinIcon;
|
|
11078
|
-
exports.
|
|
11601
|
+
exports.AgentSettingsContext = AgentSettingsContext;
|
|
11602
|
+
exports.AgentSettingsProvider = AgentSettingsProvider;
|
|
11079
11603
|
exports.AgentTraces = AgentTraces;
|
|
11080
11604
|
exports.AiIcon = AiIcon;
|
|
11081
11605
|
exports.ApiIcon = ApiIcon;
|
|
@@ -11104,6 +11628,7 @@ exports.EntityContent = EntityContent;
|
|
|
11104
11628
|
exports.EntityDescription = EntityDescription;
|
|
11105
11629
|
exports.EntityIcon = EntityIcon;
|
|
11106
11630
|
exports.EntityName = EntityName;
|
|
11631
|
+
exports.Entry = Entry;
|
|
11107
11632
|
exports.EntryCell = EntryCell;
|
|
11108
11633
|
exports.EnvIcon = EnvIcon;
|
|
11109
11634
|
exports.EvaluatorCoinIcon = EvaluatorCoinIcon;
|
|
@@ -11136,6 +11661,8 @@ exports.NetworkContext = NetworkContext;
|
|
|
11136
11661
|
exports.NetworkProvider = NetworkProvider;
|
|
11137
11662
|
exports.OpenAIIcon = OpenAIIcon;
|
|
11138
11663
|
exports.PromptIcon = PromptIcon;
|
|
11664
|
+
exports.RadioGroup = RadioGroup;
|
|
11665
|
+
exports.RadioGroupItem = RadioGroupItem;
|
|
11139
11666
|
exports.RepoIcon = RepoIcon;
|
|
11140
11667
|
exports.Row = Row;
|
|
11141
11668
|
exports.ScoreIcon = ScoreIcon;
|
|
@@ -11167,6 +11694,7 @@ exports.WorkflowRunProvider = WorkflowRunProvider;
|
|
|
11167
11694
|
exports.WorkflowRuns = WorkflowRuns;
|
|
11168
11695
|
exports.WorkflowTraces = WorkflowTraces;
|
|
11169
11696
|
exports.WorkflowTrigger = WorkflowTrigger;
|
|
11697
|
+
exports.useAgentSettings = useAgentSettings;
|
|
11170
11698
|
exports.useCurrentRun = useCurrentRun;
|
|
11171
11699
|
exports.useMastraClient = useMastraClient;
|
|
11172
11700
|
exports.usePlaygroundStore = usePlaygroundStore;
|