@mastra/playground-ui 5.1.9 → 5.1.10-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +184 -39
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +185 -40
- package/dist/index.es.js.map +1 -1
- package/dist/src/domains/workflows/context/workflow-nested-graph-context.d.ts +3 -1
- package/dist/src/domains/workflows/workflow/workflow-default-node.d.ts +3 -1
- package/dist/src/domains/workflows/workflow/workflow-graph-inner.d.ts +3 -1
- package/dist/src/domains/workflows/workflow/workflow-graph.d.ts +3 -1
- package/dist/src/domains/workflows/workflow/workflow-nested-graph.d.ts +3 -1
- package/dist/src/domains/workflows/workflow/workflow-nested-node.d.ts +4 -1
- package/dist/src/domains/workflows/workflow/workflow-run-event-form.d.ts +12 -0
- package/dist/src/domains/workflows/workflow/workflow-step-action-bar.d.ts +6 -1
- package/dist/src/lib/formatting.d.ts +1 -0
- package/package.json +3 -3
package/dist/index.es.js
CHANGED
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import React__default, { createContext, useContext, forwardRef, useState, useEffect, memo, useRef, useCallback, useMemo, Suspense, Fragment as Fragment$1 } from 'react';
|
|
4
4
|
import { MastraClient } from '@mastra/client-js';
|
|
5
5
|
import { useMessage, MessagePrimitive, ActionBarPrimitive, useComposerRuntime, ComposerPrimitive, useAttachment, AttachmentPrimitive, ThreadPrimitive, useExternalStoreRuntime, CompositeAttachmentAdapter, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, AssistantRuntimeProvider } from '@assistant-ui/react';
|
|
6
|
-
import { CheckIcon as CheckIcon$1, CopyIcon, Check, Copy, ChevronUpIcon, X, FileText, FileIcon, CircleXIcon, Mic, PlusIcon, ArrowUp, Search, RefreshCcwIcon, ChevronRight, SortAsc, SortDesc, ChevronUp, ChevronDown, Circle, RefreshCw, LoaderCircle, ChevronDownIcon, ExternalLinkIcon, Network, PauseIcon, HourglassIcon,
|
|
6
|
+
import { CheckIcon as CheckIcon$1, CopyIcon, Check, Copy, ChevronUpIcon, X, FileText, FileIcon, CircleXIcon, Mic, PlusIcon, ArrowUp, Search, RefreshCcwIcon, ChevronRight, SortAsc, SortDesc, ChevronUp, ChevronDown, Circle, RefreshCw, LoaderCircle, ChevronDownIcon, ExternalLinkIcon, Braces, Loader2, Network, PauseIcon, HourglassIcon, CircleDashed, Footprints, CircleCheck, CircleX, Minus, Plus, Maximize, Workflow, AlertCircleIcon, AlertCircle, CalendarIcon, Brackets, TrashIcon, CirclePause } from 'lucide-react';
|
|
7
7
|
import { Slot } from '@radix-ui/react-slot';
|
|
8
8
|
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
9
9
|
import { TooltipProvider as TooltipProvider$1 } from '@radix-ui/react-tooltip';
|
|
@@ -38,11 +38,11 @@ import '@xyflow/react/dist/style.css';
|
|
|
38
38
|
import Dagre from '@dagrejs/dagre';
|
|
39
39
|
import { Highlight, themes } from 'prism-react-renderer';
|
|
40
40
|
import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
|
|
41
|
-
import { useDebouncedCallback } from 'use-debounce';
|
|
42
|
-
import { v4 } from '@lukeed/uuid';
|
|
43
41
|
import prettier from 'prettier';
|
|
44
42
|
import prettierPluginBabel from 'prettier/plugins/babel';
|
|
45
43
|
import prettierPluginEstree from 'prettier/plugins/estree';
|
|
44
|
+
import { useDebouncedCallback } from 'use-debounce';
|
|
45
|
+
import { v4 } from '@lukeed/uuid';
|
|
46
46
|
import jsonSchemaToZod from 'json-schema-to-zod';
|
|
47
47
|
import { parse } from 'superjson';
|
|
48
48
|
import z$1, { z, ZodObject } from 'zod';
|
|
@@ -4834,6 +4834,12 @@ class PDFAttachmentAdapter {
|
|
|
4834
4834
|
const convertMessage$2 = (message) => {
|
|
4835
4835
|
return message;
|
|
4836
4836
|
};
|
|
4837
|
+
const handleFinishReason = (finishReason) => {
|
|
4838
|
+
switch (finishReason) {
|
|
4839
|
+
case "tool-calls":
|
|
4840
|
+
throw new Error("Stream finished with reason tool-calls, try increasing maxSteps");
|
|
4841
|
+
}
|
|
4842
|
+
};
|
|
4837
4843
|
const convertToAIAttachments = async (attachments) => {
|
|
4838
4844
|
const promises = attachments.filter((attachment) => attachment.type === "image" || attachment.type === "document").map(async (attachment) => {
|
|
4839
4845
|
if (attachment.type === "document") {
|
|
@@ -5022,6 +5028,7 @@ function MastraRuntimeProvider({
|
|
|
5022
5028
|
{ role: "assistant", content: [] }
|
|
5023
5029
|
);
|
|
5024
5030
|
setMessages((currentConversation) => [...currentConversation, latestMessage]);
|
|
5031
|
+
handleFinishReason(generateResponse.finishReason);
|
|
5025
5032
|
}
|
|
5026
5033
|
} else {
|
|
5027
5034
|
let updater = function() {
|
|
@@ -5151,6 +5158,9 @@ function MastraRuntimeProvider({
|
|
|
5151
5158
|
},
|
|
5152
5159
|
onErrorPart(error) {
|
|
5153
5160
|
throw new Error(error);
|
|
5161
|
+
},
|
|
5162
|
+
onFinishMessagePart({ finishReason }) {
|
|
5163
|
+
handleFinishReason(finishReason);
|
|
5154
5164
|
}
|
|
5155
5165
|
});
|
|
5156
5166
|
}
|
|
@@ -5163,7 +5173,7 @@ function MastraRuntimeProvider({
|
|
|
5163
5173
|
setIsRunning(false);
|
|
5164
5174
|
setMessages((currentConversation) => [
|
|
5165
5175
|
...currentConversation,
|
|
5166
|
-
{ role: "assistant", content: [{ type: "text", text:
|
|
5176
|
+
{ role: "assistant", content: [{ type: "text", text: `${error}` }] }
|
|
5167
5177
|
]);
|
|
5168
5178
|
}
|
|
5169
5179
|
};
|
|
@@ -8075,6 +8085,92 @@ const CodeDialogContent = ({ data }) => {
|
|
|
8075
8085
|
}
|
|
8076
8086
|
};
|
|
8077
8087
|
|
|
8088
|
+
const formatJSON = async (code) => {
|
|
8089
|
+
const formatted = await prettier.format(code, {
|
|
8090
|
+
semi: false,
|
|
8091
|
+
parser: "json",
|
|
8092
|
+
printWidth: 80,
|
|
8093
|
+
tabWidth: 2,
|
|
8094
|
+
plugins: [prettierPluginBabel, prettierPluginEstree]
|
|
8095
|
+
});
|
|
8096
|
+
return formatted;
|
|
8097
|
+
};
|
|
8098
|
+
const isValidJson = (str) => {
|
|
8099
|
+
try {
|
|
8100
|
+
const obj = JSON.parse(str);
|
|
8101
|
+
return !!obj && typeof obj === "object";
|
|
8102
|
+
} catch (e) {
|
|
8103
|
+
return false;
|
|
8104
|
+
}
|
|
8105
|
+
};
|
|
8106
|
+
|
|
8107
|
+
const WorkflowRunEventForm = ({ event, runId, onSendEvent }) => {
|
|
8108
|
+
const [eventData, setEventData] = useState("");
|
|
8109
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
8110
|
+
const [error, setError] = useState(null);
|
|
8111
|
+
const theme = useCodemirrorTheme();
|
|
8112
|
+
const { handleCopy } = useCopyToClipboard({ text: eventData });
|
|
8113
|
+
const handleSendEvent = async () => {
|
|
8114
|
+
let data;
|
|
8115
|
+
setIsLoading(true);
|
|
8116
|
+
setError(null);
|
|
8117
|
+
try {
|
|
8118
|
+
data = JSON.parse(eventData);
|
|
8119
|
+
} catch (error2) {
|
|
8120
|
+
setError("Invalid JSON");
|
|
8121
|
+
setIsLoading(false);
|
|
8122
|
+
return;
|
|
8123
|
+
}
|
|
8124
|
+
try {
|
|
8125
|
+
const result = await onSendEvent({ event, data, runId });
|
|
8126
|
+
toast.success(result.message);
|
|
8127
|
+
} catch (error2) {
|
|
8128
|
+
console.error("Error sending event", error2);
|
|
8129
|
+
setError("Error sending event");
|
|
8130
|
+
} finally {
|
|
8131
|
+
setIsLoading(false);
|
|
8132
|
+
}
|
|
8133
|
+
};
|
|
8134
|
+
const buttonClass = "text-icon3 hover:text-icon6";
|
|
8135
|
+
const formatEventData = async () => {
|
|
8136
|
+
if (!isValidJson(eventData)) {
|
|
8137
|
+
setError("Invalid JSON");
|
|
8138
|
+
return;
|
|
8139
|
+
}
|
|
8140
|
+
const formatted = await formatJSON(eventData);
|
|
8141
|
+
setEventData(formatted);
|
|
8142
|
+
};
|
|
8143
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
8144
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
8145
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between pb-2", children: [
|
|
8146
|
+
/* @__PURE__ */ jsx(Txt, { as: "label", variant: "ui-md", className: "text-icon3", children: "Event data (JSON)" }),
|
|
8147
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
8148
|
+
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
8149
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx("button", { onClick: formatEventData, className: buttonClass, children: /* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(Braces, {}) }) }) }),
|
|
8150
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: "Format the event data JSON" })
|
|
8151
|
+
] }),
|
|
8152
|
+
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
8153
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx("button", { onClick: handleCopy, className: buttonClass, children: /* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(CopyIcon, {}) }) }) }),
|
|
8154
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: "Copy event data" })
|
|
8155
|
+
] })
|
|
8156
|
+
] })
|
|
8157
|
+
] }),
|
|
8158
|
+
/* @__PURE__ */ jsx(
|
|
8159
|
+
CodeMirror,
|
|
8160
|
+
{
|
|
8161
|
+
value: eventData,
|
|
8162
|
+
onChange: setEventData,
|
|
8163
|
+
theme,
|
|
8164
|
+
extensions: [jsonLanguage],
|
|
8165
|
+
className: "h-[400px] overflow-y-scroll bg-surface3 rounded-lg overflow-hidden p-3"
|
|
8166
|
+
}
|
|
8167
|
+
),
|
|
8168
|
+
error && /* @__PURE__ */ jsx(Txt, { variant: "ui-md", className: "text-accent2", children: error })
|
|
8169
|
+
] }),
|
|
8170
|
+
/* @__PURE__ */ jsx("div", { className: "flex justify-end pt-4", children: /* @__PURE__ */ jsx(Button, { onClick: handleSendEvent, disabled: isLoading, children: isLoading ? /* @__PURE__ */ jsx(Loader2, { className: "w-4 h-4 animate-spin" }) : "Send" }) })
|
|
8171
|
+
] });
|
|
8172
|
+
};
|
|
8173
|
+
|
|
8078
8174
|
const WorkflowStepActionBar = ({
|
|
8079
8175
|
input,
|
|
8080
8176
|
output,
|
|
@@ -8082,17 +8178,22 @@ const WorkflowStepActionBar = ({
|
|
|
8082
8178
|
error,
|
|
8083
8179
|
mapConfig,
|
|
8084
8180
|
stepName,
|
|
8181
|
+
event,
|
|
8085
8182
|
onShowTrace,
|
|
8086
|
-
onShowNestedGraph
|
|
8183
|
+
onShowNestedGraph,
|
|
8184
|
+
onSendEvent,
|
|
8185
|
+
runId
|
|
8087
8186
|
}) => {
|
|
8088
8187
|
const [isInputOpen, setIsInputOpen] = useState(false);
|
|
8089
8188
|
const [isOutputOpen, setIsOutputOpen] = useState(false);
|
|
8090
8189
|
const [isResumeDataOpen, setIsResumeDataOpen] = useState(false);
|
|
8091
8190
|
const [isErrorOpen, setIsErrorOpen] = useState(false);
|
|
8092
8191
|
const [isMapConfigOpen, setIsMapConfigOpen] = useState(false);
|
|
8192
|
+
const [isEventFormOpen, setIsEventFormOpen] = useState(false);
|
|
8093
8193
|
const dialogContentClass = "bg-surface2 rounded-lg border-sm border-border1 max-w-4xl w-full px-0";
|
|
8094
8194
|
const dialogTitleClass = "border-b-sm border-border1 pb-4 px-6";
|
|
8095
|
-
|
|
8195
|
+
const showEventForm = event && onSendEvent && runId;
|
|
8196
|
+
return /* @__PURE__ */ jsx(Fragment, { children: (input || output || error || mapConfig || resumeData || onShowNestedGraph || showEventForm) && /* @__PURE__ */ 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: [
|
|
8096
8197
|
onShowNestedGraph && /* @__PURE__ */ jsx(Button, { onClick: onShowNestedGraph, children: "View nested graph" }),
|
|
8097
8198
|
mapConfig && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
8098
8199
|
/* @__PURE__ */ jsx(Button, { onClick: () => setIsMapConfigOpen(true), children: "Map config" }),
|
|
@@ -8144,7 +8245,18 @@ const WorkflowStepActionBar = ({
|
|
|
8144
8245
|
/* @__PURE__ */ jsx("div", { className: "px-4 overflow-hidden", children: /* @__PURE__ */ jsx(CodeDialogContent, { data: error }) })
|
|
8145
8246
|
] }) })
|
|
8146
8247
|
] }),
|
|
8147
|
-
onShowTrace && /* @__PURE__ */ jsx(Button, { onClick: onShowTrace, children: "Show trace" })
|
|
8248
|
+
onShowTrace && /* @__PURE__ */ jsx(Button, { onClick: onShowTrace, children: "Show trace" }),
|
|
8249
|
+
showEventForm && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
8250
|
+
/* @__PURE__ */ jsx(Button, { onClick: () => setIsEventFormOpen(true), children: "Send event" }),
|
|
8251
|
+
/* @__PURE__ */ jsx(Dialog, { open: isEventFormOpen, onOpenChange: setIsEventFormOpen, children: /* @__PURE__ */ jsxs(DialogContent, { className: dialogContentClass, children: [
|
|
8252
|
+
/* @__PURE__ */ jsxs(DialogTitle, { className: dialogTitleClass, children: [
|
|
8253
|
+
"Send ",
|
|
8254
|
+
event,
|
|
8255
|
+
" event"
|
|
8256
|
+
] }),
|
|
8257
|
+
/* @__PURE__ */ jsx("div", { className: "px-4 overflow-hidden", children: /* @__PURE__ */ jsx(WorkflowRunEventForm, { event, runId, onSendEvent }) })
|
|
8258
|
+
] }) })
|
|
8259
|
+
] })
|
|
8148
8260
|
] }) });
|
|
8149
8261
|
};
|
|
8150
8262
|
|
|
@@ -8254,7 +8366,8 @@ function WorkflowConditionNode({ data }) {
|
|
|
8254
8366
|
function WorkflowDefaultNode({
|
|
8255
8367
|
data,
|
|
8256
8368
|
onShowTrace,
|
|
8257
|
-
parentWorkflowName
|
|
8369
|
+
parentWorkflowName,
|
|
8370
|
+
onSendEvent
|
|
8258
8371
|
}) {
|
|
8259
8372
|
const { steps, isRunning, runId } = useCurrentRun();
|
|
8260
8373
|
const { label, description, withoutTopHandle, withoutBottomHandle, mapConfig, event, duration, date } = data;
|
|
@@ -8313,7 +8426,10 @@ function WorkflowDefaultNode({
|
|
|
8313
8426
|
output: step?.output,
|
|
8314
8427
|
error: step?.error,
|
|
8315
8428
|
mapConfig,
|
|
8316
|
-
|
|
8429
|
+
event: step?.status === "waiting" ? event : void 0,
|
|
8430
|
+
onShowTrace: runId && onShowTrace ? () => onShowTrace?.({ runId, stepName: fullLabel }) : void 0,
|
|
8431
|
+
runId,
|
|
8432
|
+
onSendEvent
|
|
8317
8433
|
}
|
|
8318
8434
|
)
|
|
8319
8435
|
]
|
|
@@ -8403,7 +8519,13 @@ const ZoomSlider = forwardRef(({ className, ...props }) => {
|
|
|
8403
8519
|
});
|
|
8404
8520
|
ZoomSlider.displayName = "ZoomSlider";
|
|
8405
8521
|
|
|
8406
|
-
function WorkflowNestedGraph({
|
|
8522
|
+
function WorkflowNestedGraph({
|
|
8523
|
+
stepGraph,
|
|
8524
|
+
open,
|
|
8525
|
+
workflowName,
|
|
8526
|
+
onShowTrace,
|
|
8527
|
+
onSendEvent
|
|
8528
|
+
}) {
|
|
8407
8529
|
const { nodes: initialNodes, edges: initialEdges } = constructNodesAndEdges({
|
|
8408
8530
|
stepGraph
|
|
8409
8531
|
});
|
|
@@ -8412,11 +8534,27 @@ function WorkflowNestedGraph({ stepGraph, open, workflowName, onShowTrace }) {
|
|
|
8412
8534
|
const [edges] = useEdgesState(initialEdges);
|
|
8413
8535
|
const { steps } = useCurrentRun();
|
|
8414
8536
|
const nodeTypes = {
|
|
8415
|
-
"default-node": (props) => /* @__PURE__ */ jsx(
|
|
8537
|
+
"default-node": (props) => /* @__PURE__ */ jsx(
|
|
8538
|
+
WorkflowDefaultNode,
|
|
8539
|
+
{
|
|
8540
|
+
parentWorkflowName: workflowName,
|
|
8541
|
+
onShowTrace,
|
|
8542
|
+
onSendEvent,
|
|
8543
|
+
...props
|
|
8544
|
+
}
|
|
8545
|
+
),
|
|
8416
8546
|
"condition-node": WorkflowConditionNode,
|
|
8417
8547
|
"after-node": WorkflowAfterNode,
|
|
8418
8548
|
"loop-result-node": WorkflowLoopResultNode,
|
|
8419
|
-
"nested-node": (props) => /* @__PURE__ */ jsx(
|
|
8549
|
+
"nested-node": (props) => /* @__PURE__ */ jsx(
|
|
8550
|
+
WorkflowNestedNode,
|
|
8551
|
+
{
|
|
8552
|
+
parentWorkflowName: workflowName,
|
|
8553
|
+
onShowTrace,
|
|
8554
|
+
onSendEvent,
|
|
8555
|
+
...props
|
|
8556
|
+
}
|
|
8557
|
+
)
|
|
8420
8558
|
};
|
|
8421
8559
|
useEffect(() => {
|
|
8422
8560
|
if (open) {
|
|
@@ -8458,7 +8596,8 @@ const WorkflowNestedGraphContext = createContext(
|
|
|
8458
8596
|
);
|
|
8459
8597
|
function WorkflowNestedGraphProvider({
|
|
8460
8598
|
children,
|
|
8461
|
-
onShowTrace
|
|
8599
|
+
onShowTrace,
|
|
8600
|
+
onSendEvent
|
|
8462
8601
|
}) {
|
|
8463
8602
|
const [stepGraph, setStepGraph] = useState(null);
|
|
8464
8603
|
const [parentStepGraphList, setParentStepGraphList] = useState([]);
|
|
@@ -8515,7 +8654,8 @@ function WorkflowNestedGraphProvider({
|
|
|
8515
8654
|
stepGraph,
|
|
8516
8655
|
open: openDialog,
|
|
8517
8656
|
workflowName: fullStep,
|
|
8518
|
-
onShowTrace
|
|
8657
|
+
onShowTrace,
|
|
8658
|
+
onSendEvent
|
|
8519
8659
|
}
|
|
8520
8660
|
) })
|
|
8521
8661
|
] }) }) }, `${label}-${fullStep}`)
|
|
@@ -8527,11 +8667,12 @@ function WorkflowNestedGraphProvider({
|
|
|
8527
8667
|
function WorkflowNestedNode({
|
|
8528
8668
|
data,
|
|
8529
8669
|
parentWorkflowName,
|
|
8530
|
-
onShowTrace
|
|
8670
|
+
onShowTrace,
|
|
8671
|
+
onSendEvent
|
|
8531
8672
|
}) {
|
|
8532
8673
|
const { steps, isRunning, runId } = useCurrentRun();
|
|
8533
8674
|
const { showNestedGraph } = useContext(WorkflowNestedGraphContext);
|
|
8534
|
-
const { label, description, withoutTopHandle, withoutBottomHandle, stepGraph, mapConfig } = data;
|
|
8675
|
+
const { label, description, withoutTopHandle, withoutBottomHandle, stepGraph, mapConfig, event } = data;
|
|
8535
8676
|
const fullLabel = parentWorkflowName ? `${parentWorkflowName}.${label}` : label;
|
|
8536
8677
|
const step = steps[fullLabel];
|
|
8537
8678
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -8542,14 +8683,17 @@ function WorkflowNestedNode({
|
|
|
8542
8683
|
className: cn(
|
|
8543
8684
|
"bg-surface3 rounded-lg w-[274px] border-sm border-border1 pt-2",
|
|
8544
8685
|
step?.status === "success" && "ring-2 ring-accent1",
|
|
8545
|
-
step?.status === "failed" && "ring-2 ring-accent2"
|
|
8686
|
+
step?.status === "failed" && "ring-2 ring-accent2",
|
|
8687
|
+
step?.status === "suspended" && "ring-2 ring-accent3",
|
|
8688
|
+
step?.status === "waiting" && "ring-2 ring-accent5"
|
|
8546
8689
|
),
|
|
8547
8690
|
children: [
|
|
8548
8691
|
/* @__PURE__ */ jsxs("div", { className: cn("flex items-center gap-2 px-3", !description && "pb-2"), children: [
|
|
8549
8692
|
isRunning && /* @__PURE__ */ jsxs(Icon, { children: [
|
|
8550
8693
|
step?.status === "failed" && /* @__PURE__ */ jsx(CrossIcon, { className: "text-accent2" }),
|
|
8551
8694
|
step?.status === "success" && /* @__PURE__ */ jsx(CheckIcon, { className: "text-accent1" }),
|
|
8552
|
-
step?.status === "suspended" && /* @__PURE__ */ jsx(PauseIcon, { className: "text-
|
|
8695
|
+
step?.status === "suspended" && /* @__PURE__ */ jsx(PauseIcon, { className: "text-accent3" }),
|
|
8696
|
+
step?.status === "waiting" && /* @__PURE__ */ jsx(HourglassIcon, { className: "text-accent5" }),
|
|
8553
8697
|
step?.status === "running" && /* @__PURE__ */ jsx(Loader2, { className: "text-icon6 animate-spin" }),
|
|
8554
8698
|
!step && /* @__PURE__ */ jsx(CircleDashed, { className: "text-icon2" })
|
|
8555
8699
|
] }),
|
|
@@ -8570,7 +8714,10 @@ function WorkflowNestedNode({
|
|
|
8570
8714
|
error: step?.error,
|
|
8571
8715
|
mapConfig,
|
|
8572
8716
|
onShowTrace: runId && onShowTrace ? () => onShowTrace?.({ runId, stepName: fullLabel }) : void 0,
|
|
8573
|
-
onShowNestedGraph: () => showNestedGraph({ label, fullStep: fullLabel, stepGraph })
|
|
8717
|
+
onShowNestedGraph: () => showNestedGraph({ label, fullStep: fullLabel, stepGraph }),
|
|
8718
|
+
onSendEvent,
|
|
8719
|
+
event: step?.status === "waiting" ? event : void 0,
|
|
8720
|
+
runId
|
|
8574
8721
|
}
|
|
8575
8722
|
)
|
|
8576
8723
|
]
|
|
@@ -8580,17 +8727,17 @@ function WorkflowNestedNode({
|
|
|
8580
8727
|
] });
|
|
8581
8728
|
}
|
|
8582
8729
|
|
|
8583
|
-
function WorkflowGraphInner({ workflow, onShowTrace }) {
|
|
8730
|
+
function WorkflowGraphInner({ workflow, onShowTrace, onSendEvent }) {
|
|
8584
8731
|
const { nodes: initialNodes, edges: initialEdges } = constructNodesAndEdges(workflow);
|
|
8585
8732
|
const [nodes, _, onNodesChange] = useNodesState(initialNodes);
|
|
8586
8733
|
const [edges] = useEdgesState(initialEdges);
|
|
8587
8734
|
const { steps, runId } = useCurrentRun();
|
|
8588
8735
|
const nodeTypes = {
|
|
8589
|
-
"default-node": (props) => /* @__PURE__ */ jsx(WorkflowDefaultNode, { onShowTrace, ...props }),
|
|
8736
|
+
"default-node": (props) => /* @__PURE__ */ jsx(WorkflowDefaultNode, { onShowTrace, onSendEvent, ...props }),
|
|
8590
8737
|
"condition-node": WorkflowConditionNode,
|
|
8591
8738
|
"after-node": WorkflowAfterNode,
|
|
8592
8739
|
"loop-result-node": WorkflowLoopResultNode,
|
|
8593
|
-
"nested-node": (props) => /* @__PURE__ */ jsx(WorkflowNestedNode, { onShowTrace, ...props })
|
|
8740
|
+
"nested-node": (props) => /* @__PURE__ */ jsx(WorkflowNestedNode, { onShowTrace, onSendEvent, ...props })
|
|
8594
8741
|
};
|
|
8595
8742
|
return /* @__PURE__ */ jsx("div", { className: "w-full h-full bg-surface1", children: /* @__PURE__ */ jsxs(
|
|
8596
8743
|
ReactFlow,
|
|
@@ -8620,7 +8767,7 @@ function WorkflowGraphInner({ workflow, onShowTrace }) {
|
|
|
8620
8767
|
) });
|
|
8621
8768
|
}
|
|
8622
8769
|
|
|
8623
|
-
function WorkflowGraph({ workflowId, onShowTrace, workflow, isLoading }) {
|
|
8770
|
+
function WorkflowGraph({ workflowId, onShowTrace, workflow, isLoading, onSendEvent }) {
|
|
8624
8771
|
const { snapshot } = useContext(WorkflowRunContext);
|
|
8625
8772
|
if (isLoading) {
|
|
8626
8773
|
return /* @__PURE__ */ jsx("div", { className: "p-4", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }) });
|
|
@@ -8635,13 +8782,22 @@ function WorkflowGraph({ workflowId, onShowTrace, workflow, isLoading }) {
|
|
|
8635
8782
|
] })
|
|
8636
8783
|
] }) });
|
|
8637
8784
|
}
|
|
8638
|
-
return /* @__PURE__ */ jsx(
|
|
8639
|
-
|
|
8785
|
+
return /* @__PURE__ */ jsx(
|
|
8786
|
+
WorkflowNestedGraphProvider,
|
|
8640
8787
|
{
|
|
8641
|
-
|
|
8642
|
-
|
|
8643
|
-
|
|
8644
|
-
|
|
8788
|
+
onShowTrace,
|
|
8789
|
+
onSendEvent,
|
|
8790
|
+
children: /* @__PURE__ */ jsx(ReactFlowProvider, { children: /* @__PURE__ */ jsx(
|
|
8791
|
+
WorkflowGraphInner,
|
|
8792
|
+
{
|
|
8793
|
+
workflow: snapshot?.serializedStepGraph ? { stepGraph: snapshot?.serializedStepGraph } : workflow,
|
|
8794
|
+
onShowTrace,
|
|
8795
|
+
onSendEvent
|
|
8796
|
+
}
|
|
8797
|
+
) })
|
|
8798
|
+
},
|
|
8799
|
+
snapshot?.runId ?? workflowId
|
|
8800
|
+
);
|
|
8645
8801
|
}
|
|
8646
8802
|
|
|
8647
8803
|
const useWorkflowRuns = (workflowId) => {
|
|
@@ -9206,17 +9362,6 @@ const MessagesProvider = ({ children }) => {
|
|
|
9206
9362
|
};
|
|
9207
9363
|
const useMessages = () => useContext(MessagesContext);
|
|
9208
9364
|
|
|
9209
|
-
const formatJSON = async (code) => {
|
|
9210
|
-
const formatted = await prettier.format(code, {
|
|
9211
|
-
semi: false,
|
|
9212
|
-
parser: "json",
|
|
9213
|
-
printWidth: 80,
|
|
9214
|
-
tabWidth: 2,
|
|
9215
|
-
plugins: [prettierPluginBabel, prettierPluginEstree]
|
|
9216
|
-
});
|
|
9217
|
-
return formatted;
|
|
9218
|
-
};
|
|
9219
|
-
|
|
9220
9365
|
const convertMessage = (message) => {
|
|
9221
9366
|
return message;
|
|
9222
9367
|
};
|