Skip to content

Automate browser based workflows with AI

make other script enabled blocks flip-to-script; add type-checked lis… (#3179)

Jonathan Dobson399fd4ea74ae
diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/ActionNode/ActionNode.tsx b/skyvern-frontend/src/routes/workflows/editor/nodes/ActionNode/ActionNode.tsx
index e5a4ba737..21a24988b 100644
--- a/skyvern-frontend/src/routes/workflows/editor/nodes/ActionNode/ActionNode.tsx
+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/ActionNode/ActionNode.tsx
@@ -1,3 +1,5 @@
+import { useEffect } from "react";
+import { Flippable } from "@/components/Flippable";
import {
Accordion,
AccordionContent,
@@ -23,6 +25,7 @@ import { CodeEditor } from "@/routes/workflows/components/CodeEditor";
import { Switch } from "@/components/ui/switch";
import { placeholders, helpTooltips } from "../../helpContent";
import { WorkflowBlockInputTextarea } from "@/components/WorkflowBlockInputTextarea";
+import { BlockCodeEditor } from "@/routes/workflows/components/BlockCodeEditor";
import { WorkflowBlockInput } from "@/components/WorkflowBlockInput";
import { AppNode } from "..";
import { getAvailableOutputParameterKeys } from "../../workflowEditorUtils";
@@ -31,6 +34,7 @@ import { useIsFirstBlockInWorkflow } from "../../hooks/useIsFirstNodeInWorkflow"
import { RunEngineSelector } from "@/components/EngineSelector";
import { ModelSelector } from "@/components/ModelSelector";
import { useDebugStore } from "@/store/useDebugStore";
+import { useBlockScriptStore } from "@/store/BlockScriptStore";
import { cn } from "@/util/utils";
import { useParams } from "react-router-dom";
import { NodeHeader } from "../components/NodeHeader";
@@ -44,7 +48,10 @@ const navigationGoalPlaceholder = 'Input {{ name }} into "Name" field.';
function ActionNode({ id, data, type }: NodeProps<ActionNode>) {
const { updateNodeData } = useReactFlow();
+ const [facing, setFacing] = useState<"front" | "back">("front");
+ const blockScriptStore = useBlockScriptStore();
const { editable, debuggable, label } = data;
+ const script = blockScriptStore.scripts[label];
const [inputs, setInputs] = useState({
url: data.url,
navigationGoal: data.navigationGoal,
@@ -78,308 +85,319 @@ function ActionNode({ id, data, type }: NodeProps<ActionNode>) {
const isFirstWorkflowBlock = useIsFirstBlockInWorkflow({ id });
+ useEffect(() => {
+ setFacing(data.showCode ? "back" : "front");
+ }, [data.showCode]);
+
return (
- <div>
- <Handle
- type="source"
- position={Position.Bottom}
- id="a"
- className="opacity-0"
- />
- <Handle
- type="target"
- position={Position.Top}
- id="b"
- className="opacity-0"
- />
- <div
- className={cn(
- "transform-origin-center w-[30rem] space-y-4 rounded-lg bg-slate-elevation3 px-6 py-4 transition-all",
- {
- "pointer-events-none bg-slate-950 outline outline-2 outline-slate-300":
- thisBlockIsPlaying,
- },
- )}
- >
- <NodeHeader
- blockLabel={label}
- disabled={elideFromDebugging}
- editable={editable}
- nodeId={id}
- totpIdentifier={inputs.totpIdentifier}
- totpUrl={inputs.totpVerificationUrl}
- type={type}
+ <Flippable facing={facing} preserveFrontsideHeight={true}>
+ <div>
+ <Handle
+ type="source"
+ position={Position.Bottom}
+ id="a"
+ className="opacity-0"
+ />
+ <Handle
+ type="target"
+ position={Position.Top}
+ id="b"
+ className="opacity-0"
/>
<div
- className={cn("space-y-4", {
- "opacity-50": thisBlockIsPlaying,
- })}
+ className={cn(
+ "transform-origin-center w-[30rem] space-y-4 rounded-lg bg-slate-elevation3 px-6 py-4 transition-all",
+ {
+ "pointer-events-none bg-slate-950 outline outline-2 outline-slate-300":
+ thisBlockIsPlaying,
+ },
+ )}
>
- <div className="space-y-2">
- <div className="flex justify-between">
- <div className="flex gap-2">
- <Label className="text-xs text-slate-300">URL</Label>
- <HelpTooltip content={urlTooltip} />
- </div>
- {isFirstWorkflowBlock ? (
- <div className="flex justify-end text-xs text-slate-400">
- Tip: Use the {"+"} button to add parameters!
+ <NodeHeader
+ blockLabel={label}
+ disabled={elideFromDebugging}
+ editable={editable}
+ nodeId={id}
+ totpIdentifier={inputs.totpIdentifier}
+ totpUrl={inputs.totpVerificationUrl}
+ type={type}
+ />
+ <div
+ className={cn("space-y-4", {
+ "opacity-50": thisBlockIsPlaying,
+ })}
+ >
+ <div className="space-y-2">
+ <div className="flex justify-between">
+ <div className="flex gap-2">
+ <Label className="text-xs text-slate-300">URL</Label>
+ <HelpTooltip content={urlTooltip} />
</div>
- ) : null}
- </div>
+ {isFirstWorkflowBlock ? (
+ <div className="flex justify-end text-xs text-slate-400">
+ Tip: Use the {"+"} button to add parameters!
+ </div>
+ ) : null}
+ </div>
- <WorkflowBlockInputTextarea
- canWriteTitle={true}
- nodeId={id}
- onChange={(value) => {
- handleChange("url", value);
- }}
- value={inputs.url}
- placeholder={placeholders["action"]["url"]}
- className="nopan text-xs"
- />
- </div>
- <div className="space-y-2">
- <div className="flex gap-2">
- <Label className="text-xs text-slate-300">
- Action Instruction
- </Label>
- <HelpTooltip content={navigationGoalTooltip} />
+ <WorkflowBlockInputTextarea
+ canWriteTitle={true}
+ nodeId={id}
+ onChange={(value) => {
+ handleChange("url", value);
+ }}
+ value={inputs.url}
+ placeholder={placeholders["action"]["url"]}
+ className="nopan text-xs"
+ />
</div>
- <WorkflowBlockInputTextarea
- nodeId={id}
- onChange={(value) => {
- handleChange("navigationGoal", value);
- }}
- value={inputs.navigationGoal}
- placeholder={navigationGoalPlaceholder}
- className="nopan text-xs"
- />
- </div>
- <div className="rounded-md bg-slate-800 p-2">
- <div className="space-y-1 text-xs text-slate-400">
- Tip: While executing the action block, Skyvern will only take one
- action.
+ <div className="space-y-2">
+ <div className="flex gap-2">
+ <Label className="text-xs text-slate-300">
+ Action Instruction
+ </Label>
+ <HelpTooltip content={navigationGoalTooltip} />
+ </div>
+ <WorkflowBlockInputTextarea
+ nodeId={id}
+ onChange={(value) => {
+ handleChange("navigationGoal", value);
+ }}
+ value={inputs.navigationGoal}
+ placeholder={navigationGoalPlaceholder}
+ className="nopan text-xs"
+ />
+ </div>
+ <div className="rounded-md bg-slate-800 p-2">
+ <div className="space-y-1 text-xs text-slate-400">
+ Tip: While executing the action block, Skyvern will only take
+ one action.
+ </div>
</div>
</div>
- </div>
- <Separator />
- <Accordion
- className={cn({
- "pointer-events-none opacity-50": thisBlockIsPlaying,
- })}
- type="single"
- collapsible
- >
- <AccordionItem value="advanced" className="border-b-0">
- <AccordionTrigger className="py-0">
- Advanced Settings
- </AccordionTrigger>
- <AccordionContent className="pl-6 pr-1 pt-1">
- <div className="space-y-4">
- <div className="space-y-2">
- <ModelSelector
- className="nopan w-52 text-xs"
- value={inputs.model}
- onChange={(value) => {
- handleChange("model", value);
- }}
- />
- <ParametersMultiSelect
- availableOutputParameters={outputParameterKeys}
- parameters={data.parameterKeys}
- onParametersChange={(parameterKeys) => {
- updateNodeData(id, { parameterKeys });
- }}
- />
- </div>
- <div className="flex items-center justify-between">
- <div className="flex gap-2">
- <Label className="text-xs font-normal text-slate-300">
- Engine
- </Label>
+ <Separator />
+ <Accordion
+ className={cn({
+ "pointer-events-none opacity-50": thisBlockIsPlaying,
+ })}
+ type="single"
+ collapsible
+ >
+ <AccordionItem value="advanced" className="border-b-0">
+ <AccordionTrigger className="py-0">
+ Advanced Settings
+ </AccordionTrigger>
+ <AccordionContent className="pl-6 pr-1 pt-1">
+ <div className="space-y-4">
+ <div className="space-y-2">
+ <ModelSelector
+ className="nopan w-52 text-xs"
+ value={inputs.model}
+ onChange={(value) => {
+ handleChange("model", value);
+ }}
+ />
+ <ParametersMultiSelect
+ availableOutputParameters={outputParameterKeys}
+ parameters={data.parameterKeys}
+ onParametersChange={(parameterKeys) => {
+ updateNodeData(id, { parameterKeys });
+ }}
+ />
</div>
- <RunEngineSelector
- value={inputs.engine}
- onChange={(value) => {
- handleChange("engine", value);
- }}
- className="nopan w-52 text-xs"
- />
- </div>
- <div className="space-y-2">
- <div className="flex gap-4">
+ <div className="flex items-center justify-between">
<div className="flex gap-2">
<Label className="text-xs font-normal text-slate-300">
- Error Messages
+ Engine
</Label>
- <HelpTooltip
- content={helpTooltips["action"]["errorCodeMapping"]}
- />
</div>
- <Checkbox
- checked={inputs.errorCodeMapping !== "null"}
- disabled={!editable}
- onCheckedChange={(checked) => {
- if (!editable) {
- return;
- }
- handleChange(
- "errorCodeMapping",
- checked
- ? JSON.stringify(errorMappingExampleValue, null, 2)
- : "null",
- );
+ <RunEngineSelector
+ value={inputs.engine}
+ onChange={(value) => {
+ handleChange("engine", value);
}}
+ className="nopan w-52 text-xs"
/>
</div>
- {inputs.errorCodeMapping !== "null" && (
- <div>
- <CodeEditor
- language="json"
- value={inputs.errorCodeMapping}
- onChange={(value) => {
+ <div className="space-y-2">
+ <div className="flex gap-4">
+ <div className="flex gap-2">
+ <Label className="text-xs font-normal text-slate-300">
+ Error Messages
+ </Label>
+ <HelpTooltip
+ content={helpTooltips["action"]["errorCodeMapping"]}
+ />
+ </div>
+ <Checkbox
+ checked={inputs.errorCodeMapping !== "null"}
+ disabled={!editable}
+ onCheckedChange={(checked) => {
if (!editable) {
return;
}
- handleChange("errorCodeMapping", value);
+ handleChange(
+ "errorCodeMapping",
+ checked
+ ? JSON.stringify(
+ errorMappingExampleValue,
+ null,
+ 2,
+ )
+ : "null",
+ );
}}
- className="nowheel nopan"
- fontSize={8}
/>
</div>
- )}
- </div>
- <Separator />
- <div className="flex items-center justify-between">
- <div className="flex gap-2">
- <Label className="text-xs font-normal text-slate-300">
- Continue on Failure
- </Label>
- <HelpTooltip
- content={helpTooltips["action"]["continueOnFailure"]}
- />
- </div>
- <div className="w-52">
- <Switch
- checked={inputs.continueOnFailure}
- onCheckedChange={(checked) => {
- if (!editable) {
- return;
- }
- handleChange("continueOnFailure", checked);
- }}
- />
+ {inputs.errorCodeMapping !== "null" && (
+ <div>
+ <CodeEditor
+ language="json"
+ value={inputs.errorCodeMapping}
+ onChange={(value) => {
+ if (!editable) {
+ return;
+ }
+ handleChange("errorCodeMapping", value);
+ }}
+ className="nowheel nopan"
+ fontSize={8}
+ />
+ </div>
+ )}
</div>
- </div>
- <div className="flex items-center justify-between">
- <div className="flex gap-2">
- <Label className="text-xs font-normal text-slate-300">
- Cache Actions
- </Label>
- <HelpTooltip
- content={helpTooltips["action"]["cacheActions"]}
- />
+ <Separator />
+ <div className="flex items-center justify-between">
+ <div className="flex gap-2">
+ <Label className="text-xs font-normal text-slate-300">
+ Continue on Failure
+ </Label>
+ <HelpTooltip
+ content={helpTooltips["action"]["continueOnFailure"]}
+ />
+ </div>
+ <div className="w-52">
+ <Switch
+ checked={inputs.continueOnFailure}
+ onCheckedChange={(checked) => {
+ if (!editable) {
+ return;
+ }
+ handleChange("continueOnFailure", checked);
+ }}
+ />
+ </div>
</div>
- <div className="w-52">
- <Switch
- checked={inputs.cacheActions}
- onCheckedChange={(checked) => {
- if (!editable) {
- return;
- }
- handleChange("cacheActions", checked);
- }}
- />
+ <div className="flex items-center justify-between">
+ <div className="flex gap-2">
+ <Label className="text-xs font-normal text-slate-300">
+ Cache Actions
+ </Label>
+ <HelpTooltip
+ content={helpTooltips["action"]["cacheActions"]}
+ />
+ </div>
+ <div className="w-52">
+ <Switch
+ checked={inputs.cacheActions}
+ onCheckedChange={(checked) => {
+ if (!editable) {
+ return;
+ }
+ handleChange("cacheActions", checked);
+ }}
+ />
+ </div>
</div>
- </div>
- <Separator />
- <div className="flex items-center justify-between">
- <div className="flex gap-2">
- <Label className="text-xs font-normal text-slate-300">
- Complete on Download
- </Label>
- <HelpTooltip
- content={helpTooltips["action"]["completeOnDownload"]}
- />
+ <Separator />
+ <div className="flex items-center justify-between">
+ <div className="flex gap-2">
+ <Label className="text-xs font-normal text-slate-300">
+ Complete on Download
+ </Label>
+ <HelpTooltip
+ content={helpTooltips["action"]["completeOnDownload"]}
+ />
+ </div>
+ <div className="w-52">
+ <Switch
+ checked={inputs.allowDownloads}
+ onCheckedChange={(checked) => {
+ if (!editable) {
+ return;
+ }
+ handleChange("allowDownloads", checked);
+ }}
+ />
+ </div>
</div>
- <div className="w-52">
- <Switch
- checked={inputs.allowDownloads}
- onCheckedChange={(checked) => {
- if (!editable) {
- return;
- }
- handleChange("allowDownloads", checked);
+ <div className="flex items-center justify-between">
+ <div className="flex gap-2">
+ <Label className="text-xs font-normal text-slate-300">
+ File Suffix
+ </Label>
+ <HelpTooltip
+ content={helpTooltips["action"]["fileSuffix"]}
+ />
+ </div>
+ <WorkflowBlockInput
+ nodeId={id}
+ type="text"
+ placeholder={placeholders["action"]["downloadSuffix"]}
+ className="nopan w-52 text-xs"
+ value={inputs.downloadSuffix ?? ""}
+ onChange={(value) => {
+ handleChange("downloadSuffix", value);
}}
/>
</div>
- </div>
- <div className="flex items-center justify-between">
- <div className="flex gap-2">
- <Label className="text-xs font-normal text-slate-300">
- File Suffix
- </Label>
- <HelpTooltip
- content={helpTooltips["action"]["fileSuffix"]}
- />
- </div>
- <WorkflowBlockInput
- nodeId={id}
- type="text"
- placeholder={placeholders["action"]["downloadSuffix"]}
- className="nopan w-52 text-xs"
- value={inputs.downloadSuffix ?? ""}
- onChange={(value) => {
- handleChange("downloadSuffix", value);
- }}
- />
- </div>
- <Separator />
- <div className="space-y-2">
- <div className="flex gap-2">
- <Label className="text-xs text-slate-300">
- 2FA Identifier
- </Label>
- <HelpTooltip
- content={helpTooltips["action"]["totpIdentifier"]}
+ <Separator />
+ <div className="space-y-2">
+ <div className="flex gap-2">
+ <Label className="text-xs text-slate-300">
+ 2FA Identifier
+ </Label>
+ <HelpTooltip
+ content={helpTooltips["action"]["totpIdentifier"]}
+ />
+ </div>
+ <WorkflowBlockInputTextarea
+ nodeId={id}
+ onChange={(value) => {
+ handleChange("totpIdentifier", value);
+ }}
+ value={inputs.totpIdentifier ?? ""}
+ placeholder={placeholders["action"]["totpIdentifier"]}
+ className="nopan text-xs"
/>
</div>
- <WorkflowBlockInputTextarea
- nodeId={id}
- onChange={(value) => {
- handleChange("totpIdentifier", value);
- }}
- value={inputs.totpIdentifier ?? ""}
- placeholder={placeholders["action"]["totpIdentifier"]}
- className="nopan text-xs"
- />
- </div>
- <div className="space-y-2">
- <div className="flex gap-2">
- <Label className="text-xs text-slate-300">
- 2FA Verification URL
- </Label>
- <HelpTooltip
- content={helpTooltips["task"]["totpVerificationUrl"]}
+ <div className="space-y-2">
+ <div className="flex gap-2">
+ <Label className="text-xs text-slate-300">
+ 2FA Verification URL
+ </Label>
+ <HelpTooltip
+ content={helpTooltips["task"]["totpVerificationUrl"]}
+ />
+ </div>
+ <WorkflowBlockInputTextarea
+ nodeId={id}
+ onChange={(value) => {
+ handleChange("totpVerificationUrl", value);
+ }}
+ value={inputs.totpVerificationUrl ?? ""}
+ placeholder={placeholders["task"]["totpVerificationUrl"]}
+ className="nopan text-xs"
/>
</div>
- <WorkflowBlockInputTextarea
- nodeId={id}
- onChange={(value) => {
- handleChange("totpVerificationUrl", value);
- }}
- value={inputs.totpVerificationUrl ?? ""}
- placeholder={placeholders["task"]["totpVerificationUrl"]}
- className="nopan text-xs"
- />
</div>
- </div>
- </AccordionContent>
- </AccordionItem>
- </Accordion>
+ </AccordionContent>
+ </AccordionItem>
+ </Accordion>
+ </div>
</div>
- </div>
+ <BlockCodeEditor blockLabel={label} blockType={type} script={script} />
+ </Flippable>
);
}
diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/ExtractionNode/ExtractionNode.tsx b/skyvern-frontend/src/routes/workflows/editor/nodes/ExtractionNode/ExtractionNode.tsx
index d53f529ad..95c8aa85b 100644
--- a/skyvern-frontend/src/routes/workflows/editor/nodes/ExtractionNode/ExtractionNode.tsx
+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/ExtractionNode/ExtractionNode.tsx
@@ -1,3 +1,5 @@
+import { useEffect } from "react";
+import { Flippable } from "@/components/Flippable";
import { HelpTooltip } from "@/components/HelpTooltip";
import {
Accordion,
@@ -22,6 +24,7 @@ import { dataSchemaExampleValue } from "../types";
import type { ExtractionNode } from "./types";
import { WorkflowBlockInputTextarea } from "@/components/WorkflowBlockInputTextarea";
+import { BlockCodeEditor } from "@/routes/workflows/components/BlockCodeEditor";
import { helpTooltips, placeholders } from "../../helpContent";
import { AppNode } from "..";
import { getAvailableOutputParameterKeys } from "../../workflowEditorUtils";
@@ -31,13 +34,17 @@ import { useIsFirstBlockInWorkflow } from "../../hooks/useIsFirstNodeInWorkflow"
import { RunEngineSelector } from "@/components/EngineSelector";
import { ModelSelector } from "@/components/ModelSelector";
import { useDebugStore } from "@/store/useDebugStore";
+import { useBlockScriptStore } from "@/store/BlockScriptStore";
import { cn } from "@/util/utils";
import { NodeHeader } from "../components/NodeHeader";
import { useParams } from "react-router-dom";
function ExtractionNode({ id, data, type }: NodeProps<ExtractionNode>) {
const { updateNodeData } = useReactFlow();
+ const [facing, setFacing] = useState<"front" | "back">("front");
+ const blockScriptStore = useBlockScriptStore();
const { debuggable, editable, label } = data;
+ const script = blockScriptStore.scripts[label];
const debugStore = useDebugStore();
const elideFromDebugging = debugStore.isDebugMode && !debuggable;
const { blockLabel: urlBlockLabel } = useParams();
@@ -67,193 +74,204 @@ function ExtractionNode({ id, data, type }: NodeProps<ExtractionNode>) {
updateNodeData(id, { [key]: value });
}
+ useEffect(() => {
+ setFacing(data.showCode ? "back" : "front");
+ }, [data.showCode]);
+
return (
- <div>
- <Handle
- type="source"
- position={Position.Bottom}
- id="a"
- className="opacity-0"
- />
- <Handle
- type="target"
- position={Position.Top}
- id="b"
- className="opacity-0"
- />
- <div
- className={cn(
- "transform-origin-center w-[30rem] space-y-4 rounded-lg bg-slate-elevation3 px-6 py-4 transition-all",
- {
- "pointer-events-none bg-slate-950 outline outline-2 outline-slate-300":
- thisBlockIsPlaying,
- },
- )}
- >
- <NodeHeader
- blockLabel={label}
- disabled={elideFromDebugging}
- editable={editable}
- nodeId={id}
- totpIdentifier={null}
- totpUrl={null}
- type={type}
+ <Flippable facing={facing} preserveFrontsideHeight={true}>
+ <div>
+ <Handle
+ type="source"
+ position={Position.Bottom}
+ id="a"
+ className="opacity-0"
/>
- <div className="space-y-2">
- <div className="flex justify-between">
- <div className="flex gap-2">
- <Label className="text-xs text-slate-300">
- Data Extraction Goal
- </Label>
- <HelpTooltip
- content={helpTooltips["extraction"]["dataExtractionGoal"]}
- />
- </div>
- {isFirstWorkflowBlock ? (
- <div className="flex justify-end text-xs text-slate-400">
- Tip: Use the {"+"} button to add parameters!
+ <Handle
+ type="target"
+ position={Position.Top}
+ id="b"
+ className="opacity-0"
+ />
+ <div
+ className={cn(
+ "transform-origin-center w-[30rem] space-y-4 rounded-lg bg-slate-elevation3 px-6 py-4 transition-all",
+ {
+ "pointer-events-none bg-slate-950 outline outline-2 outline-slate-300":
+ thisBlockIsPlaying,
+ },
+ )}
+ >
+ <NodeHeader
+ blockLabel={label}
+ disabled={elideFromDebugging}
+ editable={editable}
+ nodeId={id}
+ totpIdentifier={null}
+ totpUrl={null}
+ type={type}
+ />
+ <div className="space-y-2">
+ <div className="flex justify-between">
+ <div className="flex gap-2">
+ <Label className="text-xs text-slate-300">
+ Data Extraction Goal
+ </Label>
+ <HelpTooltip
+ content={helpTooltips["extraction"]["dataExtractionGoal"]}
+ />
</div>
- ) : null}
- </div>
+ {isFirstWorkflowBlock ? (
+ <div className="flex justify-end text-xs text-slate-400">
+ Tip: Use the {"+"} button to add parameters!
+ </div>
+ ) : null}
+ </div>
- <WorkflowBlockInputTextarea
- nodeId={id}
+ <WorkflowBlockInputTextarea
+ nodeId={id}
+ onChange={(value) => {
+ if (!editable) {
+ return;
+ }
+ handleChange("dataExtractionGoal", value);
+ }}
+ value={inputs.dataExtractionGoal}
+ placeholder={placeholders["extraction"]["dataExtractionGoal"]}
+ className="nopan text-xs"
+ />
+ </div>
+ <WorkflowDataSchemaInputGroup
+ value={inputs.dataSchema}
onChange={(value) => {
- if (!editable) {
- return;
- }
- handleChange("dataExtractionGoal", value);
+ handleChange("dataSchema", value);
+ }}
+ exampleValue={dataSchemaExampleValue}
+ suggestionContext={{
+ data_extraction_goal: inputs.dataExtractionGoal,
+ current_schema: inputs.dataSchema,
}}
- value={inputs.dataExtractionGoal}
- placeholder={placeholders["extraction"]["dataExtractionGoal"]}
- className="nopan text-xs"
/>
- </div>
- <WorkflowDataSchemaInputGroup
- value={inputs.dataSchema}
- onChange={(value) => {
- handleChange("dataSchema", value);
- }}
- exampleValue={dataSchemaExampleValue}
- suggestionContext={{
- data_extraction_goal: inputs.dataExtractionGoal,
- current_schema: inputs.dataSchema,
- }}
- />
- <Separator />
- <Accordion type="single" collapsible>
- <AccordionItem value="advanced" className="border-b-0">
- <AccordionTrigger className="py-0">
- Advanced Settings
- </AccordionTrigger>
- <AccordionContent className="pl-6 pr-1 pt-1">
- <div className="space-y-4">
- <div className="space-y-2">
- <ModelSelector
- className="nopan w-52 text-xs"
- value={inputs.model}
- onChange={(value) => {
- handleChange("model", value);
- }}
- />
- <ParametersMultiSelect
- availableOutputParameters={outputParameterKeys}
- parameters={data.parameterKeys}
- onParametersChange={(parameterKeys) => {
- updateNodeData(id, { parameterKeys });
- }}
- />
- </div>
- <div className="flex items-center justify-between">
- <div className="flex gap-2">
- <Label className="text-xs font-normal text-slate-300">
- Engine
- </Label>
- </div>
- <RunEngineSelector
- value={inputs.engine}
- onChange={(value) => {
- handleChange("engine", value);
- }}
- className="nopan w-52 text-xs"
- />
- </div>
- <div className="flex items-center justify-between">
- <div className="flex gap-2">
- <Label className="text-xs font-normal text-slate-300">
- Max Steps Override
- </Label>
- <HelpTooltip
- content={helpTooltips["extraction"]["maxStepsOverride"]}
- />
- </div>
- <Input
- type="number"
- placeholder={placeholders["extraction"]["maxStepsOverride"]}
- className="nopan w-52 text-xs"
- min="0"
- value={inputs.maxStepsOverride ?? ""}
- onChange={(event) => {
- if (!editable) {
- return;
- }
- const value =
- event.target.value === ""
- ? null
- : Number(event.target.value);
- handleChange("maxStepsOverride", value);
- }}
- />
- </div>
- <Separator />
- <div className="flex items-center justify-between">
- <div className="flex gap-2">
- <Label className="text-xs font-normal text-slate-300">
- Continue on Failure
- </Label>
- <HelpTooltip
- content={helpTooltips["extraction"]["continueOnFailure"]}
+ <Separator />
+ <Accordion type="single" collapsible>
+ <AccordionItem value="advanced" className="border-b-0">
+ <AccordionTrigger className="py-0">
+ Advanced Settings
+ </AccordionTrigger>
+ <AccordionContent className="pl-6 pr-1 pt-1">
+ <div className="space-y-4">
+ <div className="space-y-2">
+ <ModelSelector
+ className="nopan w-52 text-xs"
+ value={inputs.model}
+ onChange={(value) => {
+ handleChange("model", value);
+ }}
/>
- </div>
- <div className="w-52">
- <Switch
- checked={inputs.continueOnFailure}
- onCheckedChange={(checked) => {
- if (!editable) {
- return;
- }
- handleChange("continueOnFailure", checked);
+ <ParametersMultiSelect
+ availableOutputParameters={outputParameterKeys}
+ parameters={data.parameterKeys}
+ onParametersChange={(parameterKeys) => {
+ updateNodeData(id, { parameterKeys });
}}
/>
</div>
- </div>
- <div className="flex items-center justify-between">
- <div className="flex gap-2">
- <Label className="text-xs font-normal text-slate-300">
- Cache Actions
- </Label>
- <HelpTooltip
- content={helpTooltips["extraction"]["cacheActions"]}
+ <div className="flex items-center justify-between">
+ <div className="flex gap-2">
+ <Label className="text-xs font-normal text-slate-300">
+ Engine
+ </Label>
+ </div>
+ <RunEngineSelector
+ value={inputs.engine}
+ onChange={(value) => {
+ handleChange("engine", value);
+ }}
+ className="nopan w-52 text-xs"
/>
</div>
- <div className="w-52">
- <Switch
- checked={inputs.cacheActions}
- onCheckedChange={(checked) => {
+ <div className="flex items-center justify-between">
+ <div className="flex gap-2">
+ <Label className="text-xs font-normal text-slate-300">
+ Max Steps Override
+ </Label>
+ <HelpTooltip
+ content={helpTooltips["extraction"]["maxStepsOverride"]}
+ />
+ </div>
+ <Input
+ type="number"
+ placeholder={
+ placeholders["extraction"]["maxStepsOverride"]
+ }
+ className="nopan w-52 text-xs"
+ min="0"
+ value={inputs.maxStepsOverride ?? ""}
+ onChange={(event) => {
if (!editable) {
return;
}
- handleChange("cacheActions", checked);
+ const value =
+ event.target.value === ""
+ ? null
+ : Number(event.target.value);
+ handleChange("maxStepsOverride", value);
}}
/>
</div>
+ <Separator />
+ <div className="flex items-center justify-between">
+ <div className="flex gap-2">
+ <Label className="text-xs font-normal text-slate-300">
+ Continue on Failure
+ </Label>
+ <HelpTooltip
+ content={
+ helpTooltips["extraction"]["continueOnFailure"]
+ }
+ />
+ </div>
+ <div className="w-52">
+ <Switch
+ checked={inputs.continueOnFailure}
+ onCheckedChange={(checked) => {
+ if (!editable) {
+ return;
+ }
+ handleChange("continueOnFailure", checked);
+ }}
+ />
+ </div>
+ </div>
+ <div className="flex items-center justify-between">
+ <div className="flex gap-2">
+ <Label className="text-xs font-normal text-slate-300">
+ Cache Actions
+ </Label>
+ <HelpTooltip
+ content={helpTooltips["extraction"]["cacheActions"]}
+ />
+ </div>
+ <div className="w-52">
+ <Switch
+ checked={inputs.cacheActions}
+ onCheckedChange={(checked) => {
+ if (!editable) {
+ return;
+ }
+ handleChange("cacheActions", checked);
+ }}
+ />
+ </div>
+ </div>
</div>
- </div>
- </AccordionContent>
- </AccordionItem>
- </Accordion>
+ </AccordionContent>
+ </AccordionItem>
+ </Accordion>
+ </div>
</div>
- </div>
+ <BlockCodeEditor blockLabel={label} blockType={type} script={script} />
+ </Flippable>
);
}
diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/FileDownloadNode/FileDownloadNode.tsx b/skyvern-frontend/src/routes/workflows/editor/nodes/FileDownloadNode/FileDownloadNode.tsx
index 73bc8e527..aad4a6bbd 100644
--- a/skyvern-frontend/src/routes/workflows/editor/nodes/FileDownloadNode/FileDownloadNode.tsx
+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/FileDownloadNode/FileDownloadNode.tsx
@@ -1,3 +1,5 @@
+import { useEffect } from "react";
+import { Flippable } from "@/components/Flippable";
import { HelpTooltip } from "@/components/HelpTooltip";
import {
Accordion,
@@ -11,7 +13,9 @@ import { Label } from "@/components/ui/label";
import { Separator } from "@/components/ui/separator";
import { Switch } from "@/components/ui/switch";
import { WorkflowBlockInputTextarea } from "@/components/WorkflowBlockInputTextarea";
+import { BlockCodeEditor } from "@/routes/workflows/components/BlockCodeEditor";
import { CodeEditor } from "@/routes/workflows/components/CodeEditor";
+import { useBlockScriptStore } from "@/store/BlockScriptStore";
import {
Handle,
NodeProps,
@@ -44,7 +48,10 @@ const navigationGoalPlaceholder = "Tell Skyvern which file to download.";
function FileDownloadNode({ id, data }: NodeProps<FileDownloadNode>) {
const { updateNodeData } = useReactFlow();
+ const [facing, setFacing] = useState<"front" | "back">("front");
+ const blockScriptStore = useBlockScriptStore();
const { debuggable, editable, label } = data;
+ const script = blockScriptStore.scripts[label];
const debugStore = useDebugStore();
const { blockLabel: urlBlockLabel } = useParams();
const thisBlockIsPlaying =
@@ -75,282 +82,297 @@ function FileDownloadNode({ id, data }: NodeProps<FileDownloadNode>) {
updateNodeData(id, { [key]: value });
}
+ useEffect(() => {
+ setFacing(data.showCode ? "back" : "front");
+ }, [data.showCode]);
+
return (
- <div>
- <Handle
- type="source"
- position={Position.Bottom}
- id="a"
- className="opacity-0"
- />
- <Handle
- type="target"
- position={Position.Top}
- id="b"
- className="opacity-0"
- />
- <div
- className={cn(
- "transform-origin-center w-[30rem] space-y-4 rounded-lg bg-slate-elevation3 px-6 py-4 transition-all",
- {
- "pointer-events-none bg-slate-950 outline outline-2 outline-slate-300":
- thisBlockIsPlaying,
- },
- )}
- >
- <NodeHeader
- blockLabel={label}
- disabled={elideFromDebugging}
- editable={editable}
- nodeId={id}
- totpIdentifier={inputs.totpIdentifier}
- totpUrl={inputs.totpVerificationUrl}
- type="file_download" // sic: the naming for this block is not consistent
+ <Flippable facing={facing} preserveFrontsideHeight={true}>
+ <div>
+ <Handle
+ type="source"
+ position={Position.Bottom}
+ id="a"
+ className="opacity-0"
/>
- <div className="space-y-4">
- <div className="space-y-2">
- <div className="flex justify-between">
+ <Handle
+ type="target"
+ position={Position.Top}
+ id="b"
+ className="opacity-0"
+ />
+ <div
+ className={cn(
+ "transform-origin-center w-[30rem] space-y-4 rounded-lg bg-slate-elevation3 px-6 py-4 transition-all",
+ {
+ "pointer-events-none bg-slate-950 outline outline-2 outline-slate-300":
+ thisBlockIsPlaying,
+ },
+ )}
+ >
+ <NodeHeader
+ blockLabel={label}
+ disabled={elideFromDebugging}
+ editable={editable}
+ nodeId={id}
+ totpIdentifier={inputs.totpIdentifier}
+ totpUrl={inputs.totpVerificationUrl}
+ type="file_download" // sic: the naming for this block is not consistent
+ />
+ <div className="space-y-4">
+ <div className="space-y-2">
+ <div className="flex justify-between">
+ <div className="flex gap-2">
+ <Label className="text-xs text-slate-300">URL</Label>
+ <HelpTooltip content={urlTooltip} />
+ </div>
+ {isFirstWorkflowBlock ? (
+ <div className="flex justify-end text-xs text-slate-400">
+ Tip: Use the {"+"} button to add parameters!
+ </div>
+ ) : null}
+ </div>
+ <WorkflowBlockInputTextarea
+ canWriteTitle={true}
+ nodeId={id}
+ onChange={(value) => {
+ handleChange("url", value);
+ }}
+ value={inputs.url}
+ placeholder={urlPlaceholder}
+ className="nopan text-xs"
+ />
+ </div>
+ <div className="space-y-2">
<div className="flex gap-2">
- <Label className="text-xs text-slate-300">URL</Label>
- <HelpTooltip content={urlTooltip} />
+ <Label className="text-xs text-slate-300">Download Goal</Label>
+ <HelpTooltip content={navigationGoalTooltip} />
</div>
- {isFirstWorkflowBlock ? (
- <div className="flex justify-end text-xs text-slate-400">
- Tip: Use the {"+"} button to add parameters!
- </div>
- ) : null}
+ <WorkflowBlockInputTextarea
+ nodeId={id}
+ onChange={(value) => {
+ handleChange("navigationGoal", value);
+ }}
+ value={inputs.navigationGoal}
+ placeholder={navigationGoalPlaceholder}
+ className="nopan text-xs"
+ />
</div>
- <WorkflowBlockInputTextarea
- canWriteTitle={true}
- nodeId={id}
- onChange={(value) => {
- handleChange("url", value);
- }}
- value={inputs.url}
- placeholder={urlPlaceholder}
- className="nopan text-xs"
- />
- </div>
- <div className="space-y-2">
- <div className="flex gap-2">
- <Label className="text-xs text-slate-300">Download Goal</Label>
- <HelpTooltip content={navigationGoalTooltip} />
+ <div className="rounded-md bg-slate-800 p-2 text-xs text-slate-400">
+ Once the file is downloaded, this block will complete.
</div>
- <WorkflowBlockInputTextarea
- nodeId={id}
- onChange={(value) => {
- handleChange("navigationGoal", value);
- }}
- value={inputs.navigationGoal}
- placeholder={navigationGoalPlaceholder}
- className="nopan text-xs"
- />
</div>
- <div className="rounded-md bg-slate-800 p-2 text-xs text-slate-400">
- Once the file is downloaded, this block will complete.
- </div>
- </div>
- <Separator />
- <Accordion type="single" collapsible>
- <AccordionItem value="advanced" className="border-b-0">
- <AccordionTrigger className="py-0">
- Advanced Settings
- </AccordionTrigger>
- <AccordionContent className="pl-6 pr-1 pt-1">
- <div className="space-y-4">
- <div className="space-y-2">
- <ModelSelector
- className="nopan w-52 text-xs"
- value={inputs.model}
- onChange={(value) => {
- handleChange("model", value);
- }}
- />
- <ParametersMultiSelect
- availableOutputParameters={outputParameterKeys}
- parameters={data.parameterKeys}
- onParametersChange={(parameterKeys) => {
- updateNodeData(id, { parameterKeys });
- }}
- />
- </div>
- <div className="flex items-center justify-between">
- <div className="flex gap-2">
- <Label className="text-xs font-normal text-slate-300">
- Engine
- </Label>
+ <Separator />
+ <Accordion type="single" collapsible>
+ <AccordionItem value="advanced" className="border-b-0">
+ <AccordionTrigger className="py-0">
+ Advanced Settings
+ </AccordionTrigger>
+ <AccordionContent className="pl-6 pr-1 pt-1">
+ <div className="space-y-4">
+ <div className="space-y-2">
+ <ModelSelector
+ className="nopan w-52 text-xs"
+ value={inputs.model}
+ onChange={(value) => {
+ handleChange("model", value);
+ }}
+ />
+ <ParametersMultiSelect
+ availableOutputParameters={outputParameterKeys}
+ parameters={data.parameterKeys}
+ onParametersChange={(parameterKeys) => {
+ updateNodeData(id, { parameterKeys });
+ }}
+ />
</div>
- <RunEngineSelector
- value={inputs.engine}
- onChange={(value) => {
- handleChange("engine", value);
- }}
- className="nopan w-52 text-xs"
- />
- </div>
- <div className="flex items-center justify-between">
- <div className="flex gap-2">
- <Label className="text-xs font-normal text-slate-300">
- Max Steps Override
- </Label>
- <HelpTooltip
- content={helpTooltips["download"]["maxStepsOverride"]}
+ <div className="flex items-center justify-between">
+ <div className="flex gap-2">
+ <Label className="text-xs font-normal text-slate-300">
+ Engine
+ </Label>
+ </div>
+ <RunEngineSelector
+ value={inputs.engine}
+ onChange={(value) => {
+ handleChange("engine", value);
+ }}
+ className="nopan w-52 text-xs"
/>
</div>
- <Input
- type="number"
- placeholder={placeholders["download"]["maxStepsOverride"]}
- className="nopan w-52 text-xs"
- min="0"
- value={inputs.maxStepsOverride ?? ""}
- onChange={(event) => {
- const value =
- event.target.value === ""
- ? null
- : Number(event.target.value);
- handleChange("maxStepsOverride", value);
- }}
- />
- </div>
- <div className="space-y-2">
- <div className="flex gap-4">
+ <div className="flex items-center justify-between">
<div className="flex gap-2">
<Label className="text-xs font-normal text-slate-300">
- Error Messages
+ Max Steps Override
</Label>
<HelpTooltip
- content={helpTooltips["download"]["errorCodeMapping"]}
+ content={helpTooltips["download"]["maxStepsOverride"]}
/>
</div>
- <Checkbox
- checked={inputs.errorCodeMapping !== "null"}
- disabled={!editable}
- onCheckedChange={(checked) => {
- handleChange(
- "errorCodeMapping",
- checked
- ? JSON.stringify(errorMappingExampleValue, null, 2)
- : "null",
- );
+ <Input
+ type="number"
+ placeholder={placeholders["download"]["maxStepsOverride"]}
+ className="nopan w-52 text-xs"
+ min="0"
+ value={inputs.maxStepsOverride ?? ""}
+ onChange={(event) => {
+ const value =
+ event.target.value === ""
+ ? null
+ : Number(event.target.value);
+ handleChange("maxStepsOverride", value);
}}
/>
</div>
- {inputs.errorCodeMapping !== "null" && (
- <div>
- <CodeEditor
- language="json"
- value={inputs.errorCodeMapping}
- onChange={(value) => {
- handleChange("errorCodeMapping", value);
+ <div className="space-y-2">
+ <div className="flex gap-4">
+ <div className="flex gap-2">
+ <Label className="text-xs font-normal text-slate-300">
+ Error Messages
+ </Label>
+ <HelpTooltip
+ content={helpTooltips["download"]["errorCodeMapping"]}
+ />
+ </div>
+ <Checkbox
+ checked={inputs.errorCodeMapping !== "null"}
+ disabled={!editable}
+ onCheckedChange={(checked) => {
+ handleChange(
+ "errorCodeMapping",
+ checked
+ ? JSON.stringify(
+ errorMappingExampleValue,
+ null,
+ 2,
+ )
+ : "null",
+ );
}}
- className="nowheel nopan"
- fontSize={8}
/>
</div>
- )}
- </div>
- <Separator />
- <div className="flex items-center justify-between">
- <div className="flex gap-2">
- <Label className="text-xs font-normal text-slate-300">
- Continue on Failure
- </Label>
- <HelpTooltip
- content={helpTooltips["download"]["continueOnFailure"]}
- />
+ {inputs.errorCodeMapping !== "null" && (
+ <div>
+ <CodeEditor
+ language="json"
+ value={inputs.errorCodeMapping}
+ onChange={(value) => {
+ handleChange("errorCodeMapping", value);
+ }}
+ className="nowheel nopan"
+ fontSize={8}
+ />
+ </div>
+ )}
</div>
- <div className="w-52">
- <Switch
- checked={inputs.continueOnFailure}
- onCheckedChange={(checked) => {
- handleChange("continueOnFailure", checked);
- }}
- />
+ <Separator />
+ <div className="flex items-center justify-between">
+ <div className="flex gap-2">
+ <Label className="text-xs font-normal text-slate-300">
+ Continue on Failure
+ </Label>
+ <HelpTooltip
+ content={helpTooltips["download"]["continueOnFailure"]}
+ />
+ </div>
+ <div className="w-52">
+ <Switch
+ checked={inputs.continueOnFailure}
+ onCheckedChange={(checked) => {
+ handleChange("continueOnFailure", checked);
+ }}
+ />
+ </div>
</div>
- </div>
- <div className="flex items-center justify-between">
- <div className="flex gap-2">
- <Label className="text-xs font-normal text-slate-300">
- Cache Actions
- </Label>
- <HelpTooltip
- content={helpTooltips["download"]["cacheActions"]}
- />
+ <div className="flex items-center justify-between">
+ <div className="flex gap-2">
+ <Label className="text-xs font-normal text-slate-300">
+ Cache Actions
+ </Label>
+ <HelpTooltip
+ content={helpTooltips["download"]["cacheActions"]}
+ />
+ </div>
+ <div className="w-52">
+ <Switch
+ checked={inputs.cacheActions}
+ onCheckedChange={(checked) => {
+ handleChange("cacheActions", checked);
+ }}
+ />
+ </div>
</div>
- <div className="w-52">
- <Switch
- checked={inputs.cacheActions}
- onCheckedChange={(checked) => {
- handleChange("cacheActions", checked);
+ <Separator />
+ <div className="flex items-center justify-between">
+ <div className="flex gap-2">
+ <Label className="text-xs font-normal text-slate-300">
+ File Suffix
+ </Label>
+ <HelpTooltip
+ content={helpTooltips["download"]["fileSuffix"]}
+ />
+ </div>
+ <Input
+ type="text"
+ placeholder={placeholders["download"]["downloadSuffix"]}
+ className="nopan w-52 text-xs"
+ value={inputs.downloadSuffix ?? ""}
+ onChange={(event) => {
+ handleChange("downloadSuffix", event.target.value);
}}
/>
</div>
- </div>
- <Separator />
- <div className="flex items-center justify-between">
- <div className="flex gap-2">
- <Label className="text-xs font-normal text-slate-300">
- File Suffix
- </Label>
- <HelpTooltip
- content={helpTooltips["download"]["fileSuffix"]}
- />
- </div>
- <Input
- type="text"
- placeholder={placeholders["download"]["downloadSuffix"]}
- className="nopan w-52 text-xs"
- value={inputs.downloadSuffix ?? ""}
- onChange={(event) => {
- handleChange("downloadSuffix", event.target.value);
- }}
- />
- </div>
- <Separator />
- <div className="space-y-2">
- <div className="flex gap-2">
- <Label className="text-xs text-slate-300">
- 2FA Identifier
- </Label>
- <HelpTooltip
- content={helpTooltips["download"]["totpIdentifier"]}
+ <Separator />
+ <div className="space-y-2">
+ <div className="flex gap-2">
+ <Label className="text-xs text-slate-300">
+ 2FA Identifier
+ </Label>
+ <HelpTooltip
+ content={helpTooltips["download"]["totpIdentifier"]}
+ />
+ </div>
+ <WorkflowBlockInputTextarea
+ nodeId={id}
+ onChange={(value) => {
+ handleChange("totpIdentifier", value);
+ }}
+ value={inputs.totpIdentifier ?? ""}
+ placeholder={placeholders["download"]["totpIdentifier"]}
+ className="nopan text-xs"
/>
</div>
- <WorkflowBlockInputTextarea
- nodeId={id}
- onChange={(value) => {
- handleChange("totpIdentifier", value);
- }}
- value={inputs.totpIdentifier ?? ""}
- placeholder={placeholders["download"]["totpIdentifier"]}
- className="nopan text-xs"
- />
- </div>
- <div className="space-y-2">
- <div className="flex gap-2">
- <Label className="text-xs text-slate-300">
- 2FA Verification URL
- </Label>
- <HelpTooltip
- content={helpTooltips["task"]["totpVerificationUrl"]}
+ <div className="space-y-2">
+ <div className="flex gap-2">
+ <Label className="text-xs text-slate-300">
+ 2FA Verification URL
+ </Label>
+ <HelpTooltip
+ content={helpTooltips["task"]["totpVerificationUrl"]}
+ />
+ </div>
+ <WorkflowBlockInputTextarea
+ nodeId={id}
+ onChange={(value) => {
+ handleChange("totpVerificationUrl", value);
+ }}
+ value={inputs.totpVerificationUrl ?? ""}
+ placeholder={placeholders["task"]["totpVerificationUrl"]}
+ className="nopan text-xs"
/>
</div>
- <WorkflowBlockInputTextarea
- nodeId={id}
- onChange={(value) => {
- handleChange("totpVerificationUrl", value);
- }}
- value={inputs.totpVerificationUrl ?? ""}
- placeholder={placeholders["task"]["totpVerificationUrl"]}
- className="nopan text-xs"
- />
</div>
- </div>
- </AccordionContent>
- </AccordionItem>
- </Accordion>
+ </AccordionContent>
+ </AccordionItem>
+ </Accordion>
+ </div>
</div>
- </div>
+ <BlockCodeEditor
+ blockLabel={label}
+ blockType="file_download" // sic: naming is not consistent
+ script={script}
+ />
+ </Flippable>
);
}
diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/LoginNode/LoginNode.tsx b/skyvern-frontend/src/routes/workflows/editor/nodes/LoginNode/LoginNode.tsx
index 055f626cd..7bdf15790 100644
--- a/skyvern-frontend/src/routes/workflows/editor/nodes/LoginNode/LoginNode.tsx
+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/LoginNode/LoginNode.tsx
@@ -1,3 +1,5 @@
+import { useEffect } from "react";
+import { Flippable } from "@/components/Flippable";
import { HelpTooltip } from "@/components/HelpTooltip";
import {
Accordion,
@@ -11,7 +13,9 @@ import { Label } from "@/components/ui/label";
import { Separator } from "@/components/ui/separator";
import { Switch } from "@/components/ui/switch";
import { WorkflowBlockInputTextarea } from "@/components/WorkflowBlockInputTextarea";
+import { BlockCodeEditor } from "@/routes/workflows/components/BlockCodeEditor";
import { CodeEditor } from "@/routes/workflows/components/CodeEditor";
+import { useBlockScriptStore } from "@/store/BlockScriptStore";
import {
Handle,
NodeProps,
@@ -38,7 +42,10 @@ import { useParams } from "react-router-dom";
function LoginNode({ id, data, type }: NodeProps<LoginNode>) {
const { updateNodeData } = useReactFlow();
+ const [facing, setFacing] = useState<"front" | "back">("front");
+ const blockScriptStore = useBlockScriptStore();
const { debuggable, editable, label } = data;
+ const script = blockScriptStore.scripts[label];
const debugStore = useDebugStore();
const elideFromDebugging = debugStore.isDebugMode && !debuggable;
const { blockLabel: urlBlockLabel } = useParams();
@@ -72,291 +79,304 @@ function LoginNode({ id, data, type }: NodeProps<LoginNode>) {
updateNodeData(id, { [key]: value });
}
+ useEffect(() => {
+ setFacing(data.showCode ? "back" : "front");
+ }, [data.showCode]);
+
return (
- <div>
- <Handle
- type="source"
- position={Position.Bottom}
- id="a"
- className="opacity-0"
- />
- <Handle
- type="target"
- position={Position.Top}
- id="b"
- className="opacity-0"
- />
- <div
- className={cn(
- "transform-origin-center w-[30rem] space-y-4 rounded-lg bg-slate-elevation3 px-6 py-4 transition-all",
- {
- "pointer-events-none bg-slate-950 outline outline-2 outline-slate-300":
- thisBlockIsPlaying,
- },
- )}
- >
- <NodeHeader
- blockLabel={label}
- disabled={elideFromDebugging}
- editable={editable}
- nodeId={id}
- totpIdentifier={inputs.totpIdentifier}
- totpUrl={inputs.totpVerificationUrl}
- type={type}
+ <Flippable facing={facing} preserveFrontsideHeight={true}>
+ <div>
+ <Handle
+ type="source"
+ position={Position.Bottom}
+ id="a"
+ className="opacity-0"
/>
- <div className="space-y-4">
- <div className="space-y-2">
- <div className="flex justify-between">
- <div className="flex gap-2">
- <Label className="text-xs text-slate-300">URL</Label>
- <HelpTooltip content={helpTooltips["login"]["url"]} />
- </div>
- {isFirstWorkflowBlock ? (
- <div className="flex justify-end text-xs text-slate-400">
- Tip: Use the {"+"} button to add parameters!
+ <Handle
+ type="target"
+ position={Position.Top}
+ id="b"
+ className="opacity-0"
+ />
+ <div
+ className={cn(
+ "transform-origin-center w-[30rem] space-y-4 rounded-lg bg-slate-elevation3 px-6 py-4 transition-all",
+ {
+ "pointer-events-none bg-slate-950 outline outline-2 outline-slate-300":
+ thisBlockIsPlaying,
+ },
+ )}
+ >
+ <NodeHeader
+ blockLabel={label}
+ disabled={elideFromDebugging}
+ editable={editable}
+ nodeId={id}
+ totpIdentifier={inputs.totpIdentifier}
+ totpUrl={inputs.totpVerificationUrl}
+ type={type}
+ />
+ <div className="space-y-4">
+ <div className="space-y-2">
+ <div className="flex justify-between">
+ <div className="flex gap-2">
+ <Label className="text-xs text-slate-300">URL</Label>
+ <HelpTooltip content={helpTooltips["login"]["url"]} />
</div>
- ) : null}
- </div>
+ {isFirstWorkflowBlock ? (
+ <div className="flex justify-end text-xs text-slate-400">
+ Tip: Use the {"+"} button to add parameters!
+ </div>
+ ) : null}
+ </div>
- <WorkflowBlockInputTextarea
- canWriteTitle={true}
- nodeId={id}
- onChange={(value) => {
- handleChange("url", value);
- }}
- value={inputs.url}
- placeholder={placeholders["login"]["url"]}
- className="nopan text-xs"
- />
- </div>
- <div className="space-y-2">
- <div className="flex gap-2">
- <Label className="text-xs text-slate-300">Login Goal</Label>
- <HelpTooltip content={helpTooltips["login"]["navigationGoal"]} />
+ <WorkflowBlockInputTextarea
+ canWriteTitle={true}
+ nodeId={id}
+ onChange={(value) => {
+ handleChange("url", value);
+ }}
+ value={inputs.url}
+ placeholder={placeholders["login"]["url"]}
+ className="nopan text-xs"
+ />
</div>
- <WorkflowBlockInputTextarea
- nodeId={id}
- onChange={(value) => {
- handleChange("navigationGoal", value);
- }}
- value={inputs.navigationGoal}
- placeholder={placeholders["login"]["navigationGoal"]}
- className="nopan text-xs"
- />
- </div>
- <div className="space-y-2">
- <Label className="text-xs text-slate-300">Credential</Label>
- <LoginBlockCredentialSelector
- nodeId={id}
- value={
- data.parameterKeys.length > 0
- ? data.parameterKeys[0]
- : undefined
- }
- onChange={(value) => {
- if (!editable) {
- return;
+ <div className="space-y-2">
+ <div className="flex gap-2">
+ <Label className="text-xs text-slate-300">Login Goal</Label>
+ <HelpTooltip
+ content={helpTooltips["login"]["navigationGoal"]}
+ />
+ </div>
+ <WorkflowBlockInputTextarea
+ nodeId={id}
+ onChange={(value) => {
+ handleChange("navigationGoal", value);
+ }}
+ value={inputs.navigationGoal}
+ placeholder={placeholders["login"]["navigationGoal"]}
+ className="nopan text-xs"
+ />
+ </div>
+ <div className="space-y-2">
+ <Label className="text-xs text-slate-300">Credential</Label>
+ <LoginBlockCredentialSelector
+ nodeId={id}
+ value={
+ data.parameterKeys.length > 0
+ ? data.parameterKeys[0]
+ : undefined
}
- updateNodeData(id, { parameterKeys: [value] });
- }}
- />
+ onChange={(value) => {
+ if (!editable) {
+ return;
+ }
+ updateNodeData(id, { parameterKeys: [value] });
+ }}
+ />
+ </div>
</div>
- </div>
- <Separator />
- <Accordion type="single" collapsible>
- <AccordionItem value="advanced" className="border-b-0">
- <AccordionTrigger className="py-0">
- Advanced Settings
- </AccordionTrigger>
- <AccordionContent className="pl-6 pr-1 pt-1">
- <div className="space-y-4">
- <div className="space-y-2">
- <ModelSelector
- className="nopan w-52 text-xs"
- value={inputs.model}
- onChange={(value) => {
- handleChange("model", value);
- }}
- />
- <ParametersMultiSelect
- availableOutputParameters={outputParameterKeys}
- parameters={data.parameterKeys}
- onParametersChange={(parameterKeys) => {
- updateNodeData(id, { parameterKeys });
- }}
- />
- </div>
- <div className="space-y-2">
- <Label className="text-xs text-slate-300">
- Complete if...
- </Label>
- <WorkflowBlockInputTextarea
- nodeId={id}
- onChange={(value) => {
- handleChange("completeCriterion", value);
- }}
- value={inputs.completeCriterion}
- className="nopan text-xs"
- />
- </div>
- <Separator />
- <div className="flex items-center justify-between">
- <div className="flex gap-2">
- <Label className="text-xs font-normal text-slate-300">
- Engine
- </Label>
+ <Separator />
+ <Accordion type="single" collapsible>
+ <AccordionItem value="advanced" className="border-b-0">
+ <AccordionTrigger className="py-0">
+ Advanced Settings
+ </AccordionTrigger>
+ <AccordionContent className="pl-6 pr-1 pt-1">
+ <div className="space-y-4">
+ <div className="space-y-2">
+ <ModelSelector
+ className="nopan w-52 text-xs"
+ value={inputs.model}
+ onChange={(value) => {
+ handleChange("model", value);
+ }}
+ />
+ <ParametersMultiSelect
+ availableOutputParameters={outputParameterKeys}
+ parameters={data.parameterKeys}
+ onParametersChange={(parameterKeys) => {
+ updateNodeData(id, { parameterKeys });
+ }}
+ />
</div>
- <RunEngineSelector
- value={inputs.engine}
- onChange={(value) => {
- handleChange("engine", value);
- }}
- className="nopan w-52 text-xs"
- />
- </div>
- <div className="flex items-center justify-between">
- <div className="flex gap-2">
- <Label className="text-xs font-normal text-slate-300">
- Max Steps Override
+ <div className="space-y-2">
+ <Label className="text-xs text-slate-300">
+ Complete if...
</Label>
- <HelpTooltip
- content={helpTooltips["login"]["maxStepsOverride"]}
+ <WorkflowBlockInputTextarea
+ nodeId={id}
+ onChange={(value) => {
+ handleChange("completeCriterion", value);
+ }}
+ value={inputs.completeCriterion}
+ className="nopan text-xs"
/>
</div>
- <Input
- type="number"
- placeholder={placeholders["login"]["maxStepsOverride"]}
- className="nopan w-52 text-xs"
- min="0"
- value={inputs.maxStepsOverride ?? ""}
- onChange={(event) => {
- const value =
- event.target.value === ""
- ? null
- : Number(event.target.value);
- handleChange("maxStepsOverride", value);
- }}
- />
- </div>
- <div className="space-y-2">
- <div className="flex gap-4">
+ <Separator />
+ <div className="flex items-center justify-between">
+ <div className="flex gap-2">
+ <Label className="text-xs font-normal text-slate-300">
+ Engine
+ </Label>
+ </div>
+ <RunEngineSelector
+ value={inputs.engine}
+ onChange={(value) => {
+ handleChange("engine", value);
+ }}
+ className="nopan w-52 text-xs"
+ />
+ </div>
+ <div className="flex items-center justify-between">
<div className="flex gap-2">
<Label className="text-xs font-normal text-slate-300">
- Error Messages
+ Max Steps Override
</Label>
<HelpTooltip
- content={helpTooltips["login"]["errorCodeMapping"]}
+ content={helpTooltips["login"]["maxStepsOverride"]}
/>
</div>
- <Checkbox
- checked={inputs.errorCodeMapping !== "null"}
- disabled={!editable}
- onCheckedChange={(checked) => {
- handleChange(
- "errorCodeMapping",
- checked
- ? JSON.stringify(errorMappingExampleValue, null, 2)
- : "null",
- );
+ <Input
+ type="number"
+ placeholder={placeholders["login"]["maxStepsOverride"]}
+ className="nopan w-52 text-xs"
+ min="0"
+ value={inputs.maxStepsOverride ?? ""}
+ onChange={(event) => {
+ const value =
+ event.target.value === ""
+ ? null
+ : Number(event.target.value);
+ handleChange("maxStepsOverride", value);
}}
/>
</div>
- {inputs.errorCodeMapping !== "null" && (
- <div>
- <CodeEditor
- language="json"
- value={inputs.errorCodeMapping}
- onChange={(value) => {
- handleChange("errorCodeMapping", value);
+ <div className="space-y-2">
+ <div className="flex gap-4">
+ <div className="flex gap-2">
+ <Label className="text-xs font-normal text-slate-300">
+ Error Messages
+ </Label>
+ <HelpTooltip
+ content={helpTooltips["login"]["errorCodeMapping"]}
+ />
+ </div>
+ <Checkbox
+ checked={inputs.errorCodeMapping !== "null"}
+ disabled={!editable}
+ onCheckedChange={(checked) => {
+ handleChange(
+ "errorCodeMapping",
+ checked
+ ? JSON.stringify(
+ errorMappingExampleValue,
+ null,
+ 2,
+ )
+ : "null",
+ );
}}
- className="nowheel nopan"
- fontSize={8}
/>
</div>
- )}
- </div>
- <Separator />
- <div className="flex items-center justify-between">
- <div className="flex gap-2">
- <Label className="text-xs font-normal text-slate-300">
- Continue on Failure
- </Label>
- <HelpTooltip
- content={helpTooltips["login"]["continueOnFailure"]}
- />
+ {inputs.errorCodeMapping !== "null" && (
+ <div>
+ <CodeEditor
+ language="json"
+ value={inputs.errorCodeMapping}
+ onChange={(value) => {
+ handleChange("errorCodeMapping", value);
+ }}
+ className="nowheel nopan"
+ fontSize={8}
+ />
+ </div>
+ )}
</div>
- <div className="w-52">
- <Switch
- checked={inputs.continueOnFailure}
- onCheckedChange={(checked) => {
- handleChange("continueOnFailure", checked);
- }}
- />
+ <Separator />
+ <div className="flex items-center justify-between">
+ <div className="flex gap-2">
+ <Label className="text-xs font-normal text-slate-300">
+ Continue on Failure
+ </Label>
+ <HelpTooltip
+ content={helpTooltips["login"]["continueOnFailure"]}
+ />
+ </div>
+ <div className="w-52">
+ <Switch
+ checked={inputs.continueOnFailure}
+ onCheckedChange={(checked) => {
+ handleChange("continueOnFailure", checked);
+ }}
+ />
+ </div>
</div>
- </div>
- <div className="flex items-center justify-between">
- <div className="flex gap-2">
- <Label className="text-xs font-normal text-slate-300">
- Cache Actions
- </Label>
- <HelpTooltip
- content={helpTooltips["login"]["cacheActions"]}
- />
+ <div className="flex items-center justify-between">
+ <div className="flex gap-2">
+ <Label className="text-xs font-normal text-slate-300">
+ Cache Actions
+ </Label>
+ <HelpTooltip
+ content={helpTooltips["login"]["cacheActions"]}
+ />
+ </div>
+ <div className="w-52">
+ <Switch
+ checked={inputs.cacheActions}
+ onCheckedChange={(checked) => {
+ handleChange("cacheActions", checked);
+ }}
+ />
+ </div>
</div>
- <div className="w-52">
- <Switch
- checked={inputs.cacheActions}
- onCheckedChange={(checked) => {
- handleChange("cacheActions", checked);
+ <Separator />
+ <div className="space-y-2">
+ <div className="flex gap-2">
+ <Label className="text-xs text-slate-300">
+ 2FA Identifier
+ </Label>
+ <HelpTooltip
+ content={helpTooltips["login"]["totpIdentifier"]}
+ />
+ </div>
+ <WorkflowBlockInputTextarea
+ nodeId={id}
+ onChange={(value) => {
+ handleChange("totpIdentifier", value);
}}
+ value={inputs.totpIdentifier ?? ""}
+ placeholder={placeholders["login"]["totpIdentifier"]}
+ className="nopan text-xs"
/>
</div>
- </div>
- <Separator />
- <div className="space-y-2">
- <div className="flex gap-2">
- <Label className="text-xs text-slate-300">
- 2FA Identifier
- </Label>
- <HelpTooltip
- content={helpTooltips["login"]["totpIdentifier"]}
- />
- </div>
- <WorkflowBlockInputTextarea
- nodeId={id}
- onChange={(value) => {
- handleChange("totpIdentifier", value);
- }}
- value={inputs.totpIdentifier ?? ""}
- placeholder={placeholders["login"]["totpIdentifier"]}
- className="nopan text-xs"
- />
- </div>
- <div className="space-y-2">
- <div className="flex gap-2">
- <Label className="text-xs text-slate-300">
- 2FA Verification URL
- </Label>
- <HelpTooltip
- content={helpTooltips["login"]["totpVerificationUrl"]}
+ <div className="space-y-2">
+ <div className="flex gap-2">
+ <Label className="text-xs text-slate-300">
+ 2FA Verification URL
+ </Label>
+ <HelpTooltip
+ content={helpTooltips["login"]["totpVerificationUrl"]}
+ />
+ </div>
+ <WorkflowBlockInputTextarea
+ nodeId={id}
+ onChange={(value) => {
+ handleChange("totpVerificationUrl", value);
+ }}
+ value={inputs.totpVerificationUrl ?? ""}
+ placeholder={placeholders["login"]["totpVerificationUrl"]}
+ className="nopan text-xs"
/>
</div>
- <WorkflowBlockInputTextarea
- nodeId={id}
- onChange={(value) => {
- handleChange("totpVerificationUrl", value);
- }}
- value={inputs.totpVerificationUrl ?? ""}
- placeholder={placeholders["login"]["totpVerificationUrl"]}
- className="nopan text-xs"
- />
</div>
- </div>
- </AccordionContent>
- </AccordionItem>
- </Accordion>
+ </AccordionContent>
+ </AccordionItem>
+ </Accordion>
+ </div>
</div>
- </div>
+ <BlockCodeEditor blockLabel={label} blockType={type} script={script} />
+ </Flippable>
);
}
diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/NodeActionMenu.tsx b/skyvern-frontend/src/routes/workflows/editor/nodes/NodeActionMenu.tsx
index b2df436da..3b0a119cf 100644
--- a/skyvern-frontend/src/routes/workflows/editor/nodes/NodeActionMenu.tsx
+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/NodeActionMenu.tsx
@@ -10,11 +10,16 @@ import { DotsHorizontalIcon } from "@radix-ui/react-icons";
import { OrgWalled } from "@/components/Orgwalled";
type Props = {
+ isScriptable?: boolean;
onDelete: () => void;
onShowScript?: () => void;
};
-function NodeActionMenu({ onDelete, onShowScript }: Props) {
+function NodeActionMenu({
+ isScriptable = false,
+ onDelete,
+ onShowScript,
+}: Props) {
return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
@@ -30,17 +35,19 @@ function NodeActionMenu({ onDelete, onShowScript }: Props) {
>
Delete Block
</DropdownMenuItem>
- <OrgWalled className="p-0">
- {onShowScript && (
- <DropdownMenuItem
- onSelect={() => {
- onShowScript();
- }}
- >
- Show Script
- </DropdownMenuItem>
- )}
- </OrgWalled>
+ {isScriptable && (
+ <OrgWalled className="p-0">
+ {onShowScript && (
+ <DropdownMenuItem
+ onSelect={() => {
+ onShowScript();
+ }}
+ >
+ Show Script
+ </DropdownMenuItem>
+ )}
+ </OrgWalled>
+ )}
</DropdownMenuContent>
</DropdownMenu>
);
diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/TaskNode/TaskNode.tsx b/skyvern-frontend/src/routes/workflows/editor/nodes/TaskNode/TaskNode.tsx
index 89a25e31e..a54ea1325 100644
--- a/skyvern-frontend/src/routes/workflows/editor/nodes/TaskNode/TaskNode.tsx
+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/TaskNode/TaskNode.tsx
@@ -1,3 +1,5 @@
+import { useEffect } from "react";
+import { Flippable } from "@/components/Flippable";
import { HelpTooltip } from "@/components/HelpTooltip";
import {
Accordion,
@@ -12,7 +14,9 @@ import { Separator } from "@/components/ui/separator";
import { Switch } from "@/components/ui/switch";
import { WorkflowBlockInput } from "@/components/WorkflowBlockInput";
import { WorkflowBlockInputTextarea } from "@/components/WorkflowBlockInputTextarea";
+import { BlockCodeEditor } from "@/routes/workflows/components/BlockCodeEditor";
import { CodeEditor } from "@/routes/workflows/components/CodeEditor";
+import { useBlockScriptStore } from "@/store/BlockScriptStore";
import {
Handle,
NodeProps,
@@ -39,7 +43,10 @@ import { useParams } from "react-router-dom";
function TaskNode({ id, data, type }: NodeProps<TaskNode>) {
const { updateNodeData } = useReactFlow();
+ const [facing, setFacing] = useState<"front" | "back">("front");
+ const blockScriptStore = useBlockScriptStore();
const { debuggable, editable, label } = data;
+ const script = blockScriptStore.scripts[label];
const debugStore = useDebugStore();
const elideFromDebugging = debugStore.isDebugMode && !debuggable;
const { blockLabel: urlBlockLabel } = useParams();
@@ -78,377 +85,390 @@ function TaskNode({ id, data, type }: NodeProps<TaskNode>) {
updateNodeData(id, { [key]: value });
}
+ useEffect(() => {
+ setFacing(data.showCode ? "back" : "front");
+ }, [data.showCode]);
+
return (
- <div>
- <Handle
- type="source"
- position={Position.Bottom}
- id="a"
- className="opacity-0"
- />
- <Handle
- type="target"
- position={Position.Top}
- id="b"
- className="opacity-0"
- />
- <div
- className={cn(
- "transform-origin-center w-[30rem] space-y-4 rounded-lg bg-slate-elevation3 px-6 py-4 transition-all",
- {
- "pointer-events-none bg-slate-950 outline outline-2 outline-slate-300":
- thisBlockIsPlaying,
- },
- )}
- >
- <NodeHeader
- blockLabel={label}
- disabled={elideFromDebugging}
- editable={editable}
- nodeId={id}
- totpIdentifier={inputs.totpIdentifier}
- totpUrl={inputs.totpVerificationUrl}
- type={type}
+ <Flippable facing={facing} preserveFrontsideHeight={true}>
+ <div>
+ <Handle
+ type="source"
+ position={Position.Bottom}
+ id="a"
+ className="opacity-0"
+ />
+ <Handle
+ type="target"
+ position={Position.Top}
+ id="b"
+ className="opacity-0"
/>
- <Accordion type="multiple" defaultValue={["content", "extraction"]}>
- <AccordionItem value="content">
- <AccordionTrigger>Content</AccordionTrigger>
- <AccordionContent className="pl-[1.5rem] pr-1">
- <div className="space-y-4">
- <div className="space-y-2">
- <div className="flex justify-between">
+ <div
+ className={cn(
+ "transform-origin-center w-[30rem] space-y-4 rounded-lg bg-slate-elevation3 px-6 py-4 transition-all",
+ {
+ "pointer-events-none bg-slate-950 outline outline-2 outline-slate-300":
+ thisBlockIsPlaying,
+ },
+ )}
+ >
+ <NodeHeader
+ blockLabel={label}
+ disabled={elideFromDebugging}
+ editable={editable}
+ nodeId={id}
+ totpIdentifier={inputs.totpIdentifier}
+ totpUrl={inputs.totpVerificationUrl}
+ type={type}
+ />
+ <Accordion type="multiple" defaultValue={["content", "extraction"]}>
+ <AccordionItem value="content">
+ <AccordionTrigger>Content</AccordionTrigger>
+ <AccordionContent className="pl-[1.5rem] pr-1">
+ <div className="space-y-4">
+ <div className="space-y-2">
+ <div className="flex justify-between">
+ <div className="flex gap-2">
+ <Label className="text-xs text-slate-300">URL</Label>
+ <HelpTooltip content={helpTooltips["task"]["url"]} />
+ </div>
+ {isFirstWorkflowBlock ? (
+ <div className="flex justify-end text-xs text-slate-400">
+ Tip: Use the {"+"} button to add parameters!
+ </div>
+ ) : null}
+ </div>
+ <WorkflowBlockInputTextarea
+ canWriteTitle={true}
+ nodeId={id}
+ onChange={(value) => {
+ handleChange("url", value);
+ }}
+ value={inputs.url}
+ placeholder={placeholders["task"]["url"]}
+ className="nopan text-xs"
+ />
+ </div>
+ <div className="space-y-2">
<div className="flex gap-2">
- <Label className="text-xs text-slate-300">URL</Label>
- <HelpTooltip content={helpTooltips["task"]["url"]} />
+ <Label className="text-xs text-slate-300">Goal</Label>
+ <HelpTooltip
+ content={helpTooltips["task"]["navigationGoal"]}
+ />
</div>
- {isFirstWorkflowBlock ? (
- <div className="flex justify-end text-xs text-slate-400">
- Tip: Use the {"+"} button to add parameters!
- </div>
- ) : null}
+ <WorkflowBlockInputTextarea
+ nodeId={id}
+ onChange={(value) => {
+ handleChange("navigationGoal", value);
+ }}
+ value={inputs.navigationGoal}
+ placeholder={placeholders["task"]["navigationGoal"]}
+ className="nopan text-xs"
+ />
</div>
- <WorkflowBlockInputTextarea
- canWriteTitle={true}
- nodeId={id}
- onChange={(value) => {
- handleChange("url", value);
- }}
- value={inputs.url}
- placeholder={placeholders["task"]["url"]}
- className="nopan text-xs"
- />
- </div>
- <div className="space-y-2">
- <div className="flex gap-2">
- <Label className="text-xs text-slate-300">Goal</Label>
- <HelpTooltip
- content={helpTooltips["task"]["navigationGoal"]}
+ <div className="space-y-2">
+ <ParametersMultiSelect
+ availableOutputParameters={outputParameterKeys}
+ parameters={data.parameterKeys}
+ onParametersChange={(parameterKeys) => {
+ updateNodeData(id, { parameterKeys });
+ }}
/>
</div>
- <WorkflowBlockInputTextarea
- nodeId={id}
- onChange={(value) => {
- handleChange("navigationGoal", value);
- }}
- value={inputs.navigationGoal}
- placeholder={placeholders["task"]["navigationGoal"]}
- className="nopan text-xs"
- />
- </div>
- <div className="space-y-2">
- <ParametersMultiSelect
- availableOutputParameters={outputParameterKeys}
- parameters={data.parameterKeys}
- onParametersChange={(parameterKeys) => {
- updateNodeData(id, { parameterKeys });
- }}
- />
</div>
- </div>
- </AccordionContent>
- </AccordionItem>
- <AccordionItem value="extraction">
- <AccordionTrigger>Extraction</AccordionTrigger>
- <AccordionContent className="pl-[1.5rem] pr-1">
- <div className="space-y-4">
- <div className="space-y-2">
- <div className="flex gap-2">
- <Label className="text-xs text-slate-300">
- Data Extraction Goal
- </Label>
- <HelpTooltip
- content={helpTooltips["task"]["dataExtractionGoal"]}
+ </AccordionContent>
+ </AccordionItem>
+ <AccordionItem value="extraction">
+ <AccordionTrigger>Extraction</AccordionTrigger>
+ <AccordionContent className="pl-[1.5rem] pr-1">
+ <div className="space-y-4">
+ <div className="space-y-2">
+ <div className="flex gap-2">
+ <Label className="text-xs text-slate-300">
+ Data Extraction Goal
+ </Label>
+ <HelpTooltip
+ content={helpTooltips["task"]["dataExtractionGoal"]}
+ />
+ </div>
+ <WorkflowBlockInputTextarea
+ nodeId={id}
+ onChange={(value) => {
+ handleChange("dataExtractionGoal", value);
+ }}
+ value={inputs.dataExtractionGoal}
+ placeholder={placeholders["task"]["dataExtractionGoal"]}
+ className="nopan text-xs"
/>
</div>
- <WorkflowBlockInputTextarea
- nodeId={id}
+ <WorkflowDataSchemaInputGroup
+ exampleValue={dataSchemaExampleValue}
onChange={(value) => {
- handleChange("dataExtractionGoal", value);
+ handleChange("dataSchema", value);
}}
- value={inputs.dataExtractionGoal}
- placeholder={placeholders["task"]["dataExtractionGoal"]}
- className="nopan text-xs"
- />
- </div>
- <WorkflowDataSchemaInputGroup
- exampleValue={dataSchemaExampleValue}
- onChange={(value) => {
- handleChange("dataSchema", value);
- }}
- value={inputs.dataSchema}
- suggestionContext={{
- data_extraction_goal: inputs.dataExtractionGoal,
- current_schema: inputs.dataSchema,
- navigation_goal: inputs.navigationGoal,
- }}
- />
- </div>
- </AccordionContent>
- </AccordionItem>
- <AccordionItem value="advanced" className="border-b-0">
- <AccordionTrigger>Advanced Settings</AccordionTrigger>
- <AccordionContent className="pl-6 pr-1 pt-1">
- <div className="space-y-4">
- <div className="space-y-2">
- <Label className="text-xs text-slate-300">
- Complete if...
- </Label>
- <WorkflowBlockInputTextarea
- nodeId={id}
- onChange={(value) => {
- handleChange("completeCriterion", value);
+ value={inputs.dataSchema}
+ suggestionContext={{
+ data_extraction_goal: inputs.dataExtractionGoal,
+ current_schema: inputs.dataSchema,
+ navigation_goal: inputs.navigationGoal,
}}
- value={inputs.completeCriterion}
- className="nopan text-xs"
/>
</div>
- <Separator />
- <ModelSelector
- className="nopan w-52 text-xs"
- value={inputs.model}
- onChange={(value) => {
- handleChange("model", value);
- }}
- />
- <div className="flex items-center justify-between">
- <div className="flex gap-2">
- <Label className="text-xs font-normal text-slate-300">
- Engine
+ </AccordionContent>
+ </AccordionItem>
+ <AccordionItem value="advanced" className="border-b-0">
+ <AccordionTrigger>Advanced Settings</AccordionTrigger>
+ <AccordionContent className="pl-6 pr-1 pt-1">
+ <div className="space-y-4">
+ <div className="space-y-2">
+ <Label className="text-xs text-slate-300">
+ Complete if...
</Label>
+ <WorkflowBlockInputTextarea
+ nodeId={id}
+ onChange={(value) => {
+ handleChange("completeCriterion", value);
+ }}
+ value={inputs.completeCriterion}
+ className="nopan text-xs"
+ />
</div>
- <RunEngineSelector
- value={inputs.engine}
+ <Separator />
+ <ModelSelector
+ className="nopan w-52 text-xs"
+ value={inputs.model}
onChange={(value) => {
- handleChange("engine", value);
+ handleChange("model", value);
}}
- className="nopan w-52 text-xs"
/>
- </div>
- <div className="flex items-center justify-between">
- <div className="flex gap-2">
- <Label className="text-xs font-normal text-slate-300">
- Max Steps Override
- </Label>
- <HelpTooltip
- content={helpTooltips["task"]["maxStepsOverride"]}
+ <div className="flex items-center justify-between">
+ <div className="flex gap-2">
+ <Label className="text-xs font-normal text-slate-300">
+ Engine
+ </Label>
+ </div>
+ <RunEngineSelector
+ value={inputs.engine}
+ onChange={(value) => {
+ handleChange("engine", value);
+ }}
+ className="nopan w-52 text-xs"
/>
</div>
- <Input
- type="number"
- placeholder={placeholders["task"]["maxStepsOverride"]}
- className="nopan w-52 text-xs"
- min="0"
- value={inputs.maxStepsOverride ?? ""}
- onChange={(event) => {
- const value =
- event.target.value === ""
- ? null
- : Number(event.target.value);
- handleChange("maxStepsOverride", value);
- }}
- />
- </div>
- <div className="space-y-2">
- <div className="flex gap-4">
+ <div className="flex items-center justify-between">
<div className="flex gap-2">
<Label className="text-xs font-normal text-slate-300">
- Error Messages
+ Max Steps Override
</Label>
<HelpTooltip
- content={helpTooltips["task"]["errorCodeMapping"]}
+ content={helpTooltips["task"]["maxStepsOverride"]}
/>
</div>
- <Checkbox
- checked={inputs.errorCodeMapping !== "null"}
- disabled={!editable}
- onCheckedChange={(checked) => {
- handleChange(
- "errorCodeMapping",
- checked
- ? JSON.stringify(errorMappingExampleValue, null, 2)
- : "null",
- );
+ <Input
+ type="number"
+ placeholder={placeholders["task"]["maxStepsOverride"]}
+ className="nopan w-52 text-xs"
+ min="0"
+ value={inputs.maxStepsOverride ?? ""}
+ onChange={(event) => {
+ const value =
+ event.target.value === ""
+ ? null
+ : Number(event.target.value);
+ handleChange("maxStepsOverride", value);
}}
/>
</div>
- {inputs.errorCodeMapping !== "null" && (
- <div>
- <CodeEditor
- language="json"
- value={inputs.errorCodeMapping}
- onChange={(value) => {
- handleChange("errorCodeMapping", value);
+ <div className="space-y-2">
+ <div className="flex gap-4">
+ <div className="flex gap-2">
+ <Label className="text-xs font-normal text-slate-300">
+ Error Messages
+ </Label>
+ <HelpTooltip
+ content={helpTooltips["task"]["errorCodeMapping"]}
+ />
+ </div>
+ <Checkbox
+ checked={inputs.errorCodeMapping !== "null"}
+ disabled={!editable}
+ onCheckedChange={(checked) => {
+ handleChange(
+ "errorCodeMapping",
+ checked
+ ? JSON.stringify(
+ errorMappingExampleValue,
+ null,
+ 2,
+ )
+ : "null",
+ );
}}
- className="nowheel nopan"
- fontSize={8}
/>
</div>
- )}
- </div>
- <Separator />
- <div className="flex items-center justify-between">
- <div className="flex gap-2">
- <Label className="text-xs font-normal text-slate-300">
- Include Action History
- </Label>
- <HelpTooltip
- content={
- helpTooltips["task"][
- "includeActionHistoryInVerification"
- ]
- }
- />
+ {inputs.errorCodeMapping !== "null" && (
+ <div>
+ <CodeEditor
+ language="json"
+ value={inputs.errorCodeMapping}
+ onChange={(value) => {
+ handleChange("errorCodeMapping", value);
+ }}
+ className="nowheel nopan"
+ fontSize={8}
+ />
+ </div>
+ )}
</div>
- <div className="w-52">
- <Switch
- checked={inputs.includeActionHistoryInVerification}
- onCheckedChange={(checked) => {
- handleChange(
- "includeActionHistoryInVerification",
- checked,
- );
- }}
- />
+ <Separator />
+ <div className="flex items-center justify-between">
+ <div className="flex gap-2">
+ <Label className="text-xs font-normal text-slate-300">
+ Include Action History
+ </Label>
+ <HelpTooltip
+ content={
+ helpTooltips["task"][
+ "includeActionHistoryInVerification"
+ ]
+ }
+ />
+ </div>
+ <div className="w-52">
+ <Switch
+ checked={inputs.includeActionHistoryInVerification}
+ onCheckedChange={(checked) => {
+ handleChange(
+ "includeActionHistoryInVerification",
+ checked,
+ );
+ }}
+ />
+ </div>
</div>
- </div>
- <div className="flex items-center justify-between">
- <div className="flex gap-2">
- <Label className="text-xs font-normal text-slate-300">
- Continue on Failure
- </Label>
- <HelpTooltip
- content={helpTooltips["task"]["continueOnFailure"]}
- />
+ <div className="flex items-center justify-between">
+ <div className="flex gap-2">
+ <Label className="text-xs font-normal text-slate-300">
+ Continue on Failure
+ </Label>
+ <HelpTooltip
+ content={helpTooltips["task"]["continueOnFailure"]}
+ />
+ </div>
+ <div className="w-52">
+ <Switch
+ checked={inputs.continueOnFailure}
+ onCheckedChange={(checked) => {
+ handleChange("continueOnFailure", checked);
+ }}
+ />
+ </div>
</div>
- <div className="w-52">
- <Switch
- checked={inputs.continueOnFailure}
- onCheckedChange={(checked) => {
- handleChange("continueOnFailure", checked);
- }}
- />
+ <div className="flex items-center justify-between">
+ <div className="flex gap-2">
+ <Label className="text-xs font-normal text-slate-300">
+ Cache Actions
+ </Label>
+ <HelpTooltip
+ content={helpTooltips["task"]["cacheActions"]}
+ />
+ </div>
+ <div className="w-52">
+ <Switch
+ checked={inputs.cacheActions}
+ onCheckedChange={(checked) => {
+ handleChange("cacheActions", checked);
+ }}
+ />
+ </div>
</div>
- </div>
- <div className="flex items-center justify-between">
- <div className="flex gap-2">
- <Label className="text-xs font-normal text-slate-300">
- Cache Actions
- </Label>
- <HelpTooltip
- content={helpTooltips["task"]["cacheActions"]}
- />
+ <Separator />
+ <div className="flex items-center justify-between">
+ <div className="flex gap-2">
+ <Label className="text-xs font-normal text-slate-300">
+ Complete on Download
+ </Label>
+ <HelpTooltip
+ content={helpTooltips["task"]["completeOnDownload"]}
+ />
+ </div>
+ <div className="w-52">
+ <Switch
+ checked={inputs.allowDownloads}
+ onCheckedChange={(checked) => {
+ handleChange("allowDownloads", checked);
+ }}
+ />
+ </div>
</div>
- <div className="w-52">
- <Switch
- checked={inputs.cacheActions}
- onCheckedChange={(checked) => {
- handleChange("cacheActions", checked);
+ <div className="flex items-center justify-between">
+ <div className="flex gap-2">
+ <Label className="text-xs font-normal text-slate-300">
+ File Suffix
+ </Label>
+ <HelpTooltip
+ content={helpTooltips["task"]["fileSuffix"]}
+ />
+ </div>
+ <WorkflowBlockInput
+ nodeId={id}
+ type="text"
+ placeholder={placeholders["task"]["downloadSuffix"]}
+ className="nopan w-52 text-xs"
+ value={inputs.downloadSuffix ?? ""}
+ onChange={(value) => {
+ handleChange("downloadSuffix", value);
}}
/>
</div>
- </div>
- <Separator />
- <div className="flex items-center justify-between">
- <div className="flex gap-2">
- <Label className="text-xs font-normal text-slate-300">
- Complete on Download
- </Label>
- <HelpTooltip
- content={helpTooltips["task"]["completeOnDownload"]}
- />
- </div>
- <div className="w-52">
- <Switch
- checked={inputs.allowDownloads}
- onCheckedChange={(checked) => {
- handleChange("allowDownloads", checked);
+ <Separator />
+ <div className="space-y-2">
+ <div className="flex gap-2">
+ <Label className="text-xs text-slate-300">
+ 2FA Identifier
+ </Label>
+ <HelpTooltip
+ content={helpTooltips["task"]["totpIdentifier"]}
+ />
+ </div>
+ <WorkflowBlockInputTextarea
+ nodeId={id}
+ onChange={(value) => {
+ handleChange("totpIdentifier", value);
}}
+ value={inputs.totpIdentifier ?? ""}
+ placeholder={placeholders["task"]["totpIdentifier"]}
+ className="nopan text-xs"
/>
</div>
- </div>
- <div className="flex items-center justify-between">
- <div className="flex gap-2">
- <Label className="text-xs font-normal text-slate-300">
- File Suffix
- </Label>
- <HelpTooltip content={helpTooltips["task"]["fileSuffix"]} />
- </div>
- <WorkflowBlockInput
- nodeId={id}
- type="text"
- placeholder={placeholders["task"]["downloadSuffix"]}
- className="nopan w-52 text-xs"
- value={inputs.downloadSuffix ?? ""}
- onChange={(value) => {
- handleChange("downloadSuffix", value);
- }}
- />
- </div>
- <Separator />
- <div className="space-y-2">
- <div className="flex gap-2">
- <Label className="text-xs text-slate-300">
- 2FA Identifier
- </Label>
- <HelpTooltip
- content={helpTooltips["task"]["totpIdentifier"]}
- />
- </div>
- <WorkflowBlockInputTextarea
- nodeId={id}
- onChange={(value) => {
- handleChange("totpIdentifier", value);
- }}
- value={inputs.totpIdentifier ?? ""}
- placeholder={placeholders["task"]["totpIdentifier"]}
- className="nopan text-xs"
- />
- </div>
- <div className="space-y-2">
- <div className="flex gap-2">
- <Label className="text-xs text-slate-300">
- 2FA Verification URL
- </Label>
- <HelpTooltip
- content={helpTooltips["task"]["totpVerificationUrl"]}
+ <div className="space-y-2">
+ <div className="flex gap-2">
+ <Label className="text-xs text-slate-300">
+ 2FA Verification URL
+ </Label>
+ <HelpTooltip
+ content={helpTooltips["task"]["totpVerificationUrl"]}
+ />
+ </div>
+ <WorkflowBlockInputTextarea
+ nodeId={id}
+ onChange={(value) => {
+ handleChange("totpVerificationUrl", value);
+ }}
+ value={inputs.totpVerificationUrl ?? ""}
+ placeholder={placeholders["task"]["totpVerificationUrl"]}
+ className="nopan text-xs"
/>
</div>
- <WorkflowBlockInputTextarea
- nodeId={id}
- onChange={(value) => {
- handleChange("totpVerificationUrl", value);
- }}
- value={inputs.totpVerificationUrl ?? ""}
- placeholder={placeholders["task"]["totpVerificationUrl"]}
- className="nopan text-xs"
- />
</div>
- </div>
- </AccordionContent>
- </AccordionItem>
- </Accordion>
+ </AccordionContent>
+ </AccordionItem>
+ </Accordion>
+ </div>
</div>
- </div>
+ <BlockCodeEditor blockLabel={label} blockType={type} script={script} />
+ </Flippable>
);
}
diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/URLNode/URLNode.tsx b/skyvern-frontend/src/routes/workflows/editor/nodes/URLNode/URLNode.tsx
index be057278f..848caed38 100644
--- a/skyvern-frontend/src/routes/workflows/editor/nodes/URLNode/URLNode.tsx
+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/URLNode/URLNode.tsx
@@ -1,10 +1,14 @@
+import { useEffect } from "react";
+import { Flippable } from "@/components/Flippable";
import { Handle, NodeProps, Position, useReactFlow } from "@xyflow/react";
import type { URLNode } from "./types";
import { useIsFirstBlockInWorkflow } from "../../hooks/useIsFirstNodeInWorkflow";
import { useState } from "react";
import { Label } from "@/components/ui/label";
import { WorkflowBlockInputTextarea } from "@/components/WorkflowBlockInputTextarea";
+import { BlockCodeEditor } from "@/routes/workflows/components/BlockCodeEditor";
import { placeholders } from "../../helpContent";
+import { useBlockScriptStore } from "@/store/BlockScriptStore";
import { useDebugStore } from "@/store/useDebugStore";
import { cn } from "@/util/utils";
import { NodeHeader } from "../components/NodeHeader";
@@ -12,7 +16,10 @@ import { useParams } from "react-router-dom";
function URLNode({ id, data, type }: NodeProps<URLNode>) {
const { updateNodeData } = useReactFlow();
+ const [facing, setFacing] = useState<"front" | "back">("front");
+ const blockScriptStore = useBlockScriptStore();
const { debuggable, editable, label } = data;
+ const script = blockScriptStore.scripts[label];
const debugStore = useDebugStore();
const elideFromDebugging = debugStore.isDebugMode && !debuggable;
const { blockLabel: urlBlockLabel } = useParams();
@@ -32,62 +39,73 @@ function URLNode({ id, data, type }: NodeProps<URLNode>) {
updateNodeData(id, { [key]: value });
}
+ useEffect(() => {
+ setFacing(data.showCode ? "back" : "front");
+ }, [data.showCode]);
+
return (
- <div>
- <Handle
- type="source"
- position={Position.Bottom}
- id="a"
- className="opacity-0"
- />
- <Handle
- type="target"
- position={Position.Top}
- id="b"
- className="opacity-0"
- />
- <div
- className={cn(
- "transform-origin-center w-[30rem] space-y-4 rounded-lg bg-slate-elevation3 px-6 py-4 transition-all",
- {
- "pointer-events-none bg-slate-950 outline outline-2 outline-slate-300":
- thisBlockIsPlaying,
- },
- )}
- >
- <NodeHeader
- blockLabel={label}
- disabled={elideFromDebugging}
- editable={editable}
- nodeId={id}
- totpIdentifier={null}
- totpUrl={null}
- type="goto_url"
+ <Flippable facing={facing} preserveFrontsideHeight={true}>
+ <div>
+ <Handle
+ type="source"
+ position={Position.Bottom}
+ id="a"
+ className="opacity-0"
/>
- <div className="space-y-4">
- <div className="space-y-2">
- <div className="flex justify-between">
- <Label className="text-xs text-slate-300">URL</Label>
- {isFirstWorkflowBlock ? (
- <div className="flex justify-end text-xs text-slate-400">
- Tip: Use the {"+"} button to add parameters!
- </div>
- ) : null}
+ <Handle
+ type="target"
+ position={Position.Top}
+ id="b"
+ className="opacity-0"
+ />
+ <div
+ className={cn(
+ "transform-origin-center w-[30rem] space-y-4 rounded-lg bg-slate-elevation3 px-6 py-4 transition-all",
+ {
+ "pointer-events-none bg-slate-950 outline outline-2 outline-slate-300":
+ thisBlockIsPlaying,
+ },
+ )}
+ >
+ <NodeHeader
+ blockLabel={label}
+ disabled={elideFromDebugging}
+ editable={editable}
+ nodeId={id}
+ totpIdentifier={null}
+ totpUrl={null}
+ type="goto_url"
+ />
+ <div className="space-y-4">
+ <div className="space-y-2">
+ <div className="flex justify-between">
+ <Label className="text-xs text-slate-300">URL</Label>
+ {isFirstWorkflowBlock ? (
+ <div className="flex justify-end text-xs text-slate-400">
+ Tip: Use the {"+"} button to add parameters!
+ </div>
+ ) : null}
+ </div>
+ <WorkflowBlockInputTextarea
+ canWriteTitle={true}
+ nodeId={id}
+ onChange={(value) => {
+ handleChange("url", value);
+ }}
+ value={inputs.url}
+ placeholder={placeholders[type]["url"]}
+ className="nopan text-xs"
+ />
</div>
- <WorkflowBlockInputTextarea
- canWriteTitle={true}
- nodeId={id}
- onChange={(value) => {
- handleChange("url", value);
- }}
- value={inputs.url}
- placeholder={placeholders[type]["url"]}
- className="nopan text-xs"
- />
</div>
</div>
</div>
- </div>
+ <BlockCodeEditor
+ blockLabel={label}
+ blockType="goto_url" // sic: the naming is inconsistent
+ script={script}
+ />
+ </Flippable>
);
}
diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/ValidationNode/ValidationNode.tsx b/skyvern-frontend/src/routes/workflows/editor/nodes/ValidationNode/ValidationNode.tsx
index c8ba95add..ead409c87 100644
--- a/skyvern-frontend/src/routes/workflows/editor/nodes/ValidationNode/ValidationNode.tsx
+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/ValidationNode/ValidationNode.tsx
@@ -1,3 +1,5 @@
+import { useEffect } from "react";
+import { Flippable } from "@/components/Flippable";
import { HelpTooltip } from "@/components/HelpTooltip";
import {
Accordion,
@@ -10,7 +12,9 @@ import { Label } from "@/components/ui/label";
import { Separator } from "@/components/ui/separator";
import { Switch } from "@/components/ui/switch";
import { WorkflowBlockInputTextarea } from "@/components/WorkflowBlockInputTextarea";
+import { BlockCodeEditor } from "@/routes/workflows/components/BlockCodeEditor";
import { CodeEditor } from "@/routes/workflows/components/CodeEditor";
+import { useBlockScriptStore } from "@/store/BlockScriptStore";
import {
Handle,
NodeProps,
@@ -35,7 +39,10 @@ import { useParams } from "react-router-dom";
function ValidationNode({ id, data, type }: NodeProps<ValidationNode>) {
const { updateNodeData } = useReactFlow();
+ const [facing, setFacing] = useState<"front" | "back">("front");
+ const blockScriptStore = useBlockScriptStore();
const { debuggable, editable, label } = data;
+ const script = blockScriptStore.scripts[label];
const debugStore = useDebugStore();
const elideFromDebugging = debugStore.isDebugMode && !debuggable;
const { blockLabel: urlBlockLabel } = useParams();
@@ -61,162 +68,177 @@ function ValidationNode({ id, data, type }: NodeProps<ValidationNode>) {
const isFirstWorkflowBlock = useIsFirstBlockInWorkflow({ id });
+ useEffect(() => {
+ setFacing(data.showCode ? "back" : "front");
+ }, [data.showCode]);
+
return (
- <div>
- <Handle
- type="source"
- position={Position.Bottom}
- id="a"
- className="opacity-0"
- />
- <Handle
- type="target"
- position={Position.Top}
- id="b"
- className="opacity-0"
- />
- <div
- className={cn(
- "transform-origin-center w-[30rem] space-y-4 rounded-lg bg-slate-elevation3 px-6 py-4 transition-all",
- {
- "pointer-events-none bg-slate-950 outline outline-2 outline-slate-300":
- thisBlockIsPlaying,
- },
- )}
- >
- <NodeHeader
- blockLabel={label}
- disabled={elideFromDebugging}
- editable={editable}
- nodeId={id}
- totpIdentifier={null}
- totpUrl={null}
- type={type}
+ <Flippable facing={facing} preserveFrontsideHeight={true}>
+ <div>
+ <Handle
+ type="source"
+ position={Position.Bottom}
+ id="a"
+ className="opacity-0"
/>
- <div className="space-y-2">
- <div className="flex justify-between">
- <Label className="text-xs text-slate-300">Complete if...</Label>
- {isFirstWorkflowBlock ? (
- <div className="flex justify-end text-xs text-slate-400">
- Tip: Use the {"+"} button to add parameters!
- </div>
- ) : null}
- </div>
- <WorkflowBlockInputTextarea
- nodeId={id}
- onChange={(value) => {
- handleChange("completeCriterion", value);
- }}
- value={inputs.completeCriterion}
- className="nopan text-xs"
- />
- </div>
- <div className="space-y-2">
- <Label className="text-xs text-slate-300">Terminate if...</Label>
- <WorkflowBlockInputTextarea
+ <Handle
+ type="target"
+ position={Position.Top}
+ id="b"
+ className="opacity-0"
+ />
+ <div
+ className={cn(
+ "transform-origin-center w-[30rem] space-y-4 rounded-lg bg-slate-elevation3 px-6 py-4 transition-all",
+ {
+ "pointer-events-none bg-slate-950 outline outline-2 outline-slate-300":
+ thisBlockIsPlaying,
+ },
+ )}
+ >
+ <NodeHeader
+ blockLabel={label}
+ disabled={elideFromDebugging}
+ editable={editable}
nodeId={id}
- onChange={(value) => {
- handleChange("terminateCriterion", value);
- }}
- value={inputs.terminateCriterion}
- className="nopan text-xs"
+ totpIdentifier={null}
+ totpUrl={null}
+ type={type}
/>
- </div>
- <Separator />
- <Accordion type="single" collapsible>
- <AccordionItem value="advanced" className="border-b-0">
- <AccordionTrigger className="py-0">
- Advanced Settings
- </AccordionTrigger>
- <AccordionContent>
- <div className="ml-6 mt-4 space-y-4">
- <div className="space-y-2">
- <ModelSelector
- className="nopan mr-[1px] w-52 text-xs"
- value={inputs.model}
- onChange={(value) => {
- handleChange("model", value);
- }}
- />
- <ParametersMultiSelect
- availableOutputParameters={outputParameterKeys}
- parameters={data.parameterKeys}
- onParametersChange={(parameterKeys) => {
- updateNodeData(id, { parameterKeys });
- }}
- />
+ <div className="space-y-2">
+ <div className="flex justify-between">
+ <Label className="text-xs text-slate-300">Complete if...</Label>
+ {isFirstWorkflowBlock ? (
+ <div className="flex justify-end text-xs text-slate-400">
+ Tip: Use the {"+"} button to add parameters!
</div>
- <div className="space-y-2">
- <div className="flex gap-4">
+ ) : null}
+ </div>
+ <WorkflowBlockInputTextarea
+ nodeId={id}
+ onChange={(value) => {
+ handleChange("completeCriterion", value);
+ }}
+ value={inputs.completeCriterion}
+ className="nopan text-xs"
+ />
+ </div>
+ <div className="space-y-2">
+ <Label className="text-xs text-slate-300">Terminate if...</Label>
+ <WorkflowBlockInputTextarea
+ nodeId={id}
+ onChange={(value) => {
+ handleChange("terminateCriterion", value);
+ }}
+ value={inputs.terminateCriterion}
+ className="nopan text-xs"
+ />
+ </div>
+ <Separator />
+ <Accordion type="single" collapsible>
+ <AccordionItem value="advanced" className="border-b-0">
+ <AccordionTrigger className="py-0">
+ Advanced Settings
+ </AccordionTrigger>
+ <AccordionContent>
+ <div className="ml-6 mt-4 space-y-4">
+ <div className="space-y-2">
+ <ModelSelector
+ className="nopan mr-[1px] w-52 text-xs"
+ value={inputs.model}
+ onChange={(value) => {
+ handleChange("model", value);
+ }}
+ />
+ <ParametersMultiSelect
+ availableOutputParameters={outputParameterKeys}
+ parameters={data.parameterKeys}
+ onParametersChange={(parameterKeys) => {
+ updateNodeData(id, { parameterKeys });
+ }}
+ />
+ </div>
+ <div className="space-y-2">
+ <div className="flex gap-4">
+ <div className="flex gap-2">
+ <Label className="text-xs font-normal text-slate-300">
+ Error Messages
+ </Label>
+ <HelpTooltip
+ content={
+ helpTooltips["validation"]["errorCodeMapping"]
+ }
+ />
+ </div>
+ <Checkbox
+ checked={inputs.errorCodeMapping !== "null"}
+ disabled={!editable}
+ onCheckedChange={(checked) => {
+ if (!editable) {
+ return;
+ }
+ handleChange(
+ "errorCodeMapping",
+ checked
+ ? JSON.stringify(
+ errorMappingExampleValue,
+ null,
+ 2,
+ )
+ : "null",
+ );
+ }}
+ />
+ </div>
+ {inputs.errorCodeMapping !== "null" && (
+ <div>
+ <CodeEditor
+ language="json"
+ value={inputs.errorCodeMapping}
+ onChange={(value) => {
+ if (!editable) {
+ return;
+ }
+ handleChange("errorCodeMapping", value);
+ }}
+ className="nowheel nopan"
+ fontSize={8}
+ />
+ </div>
+ )}
+ </div>
+ <Separator />
+ <div className="flex items-center justify-between">
<div className="flex gap-2">
<Label className="text-xs font-normal text-slate-300">
- Error Messages
+ Continue on Failure
</Label>
<HelpTooltip
- content={helpTooltips["validation"]["errorCodeMapping"]}
+ content={
+ helpTooltips["validation"]["continueOnFailure"]
+ }
/>
</div>
- <Checkbox
- checked={inputs.errorCodeMapping !== "null"}
- disabled={!editable}
- onCheckedChange={(checked) => {
- if (!editable) {
- return;
- }
- handleChange(
- "errorCodeMapping",
- checked
- ? JSON.stringify(errorMappingExampleValue, null, 2)
- : "null",
- );
- }}
- />
- </div>
- {inputs.errorCodeMapping !== "null" && (
- <div>
- <CodeEditor
- language="json"
- value={inputs.errorCodeMapping}
- onChange={(value) => {
+ <div className="w-52">
+ <Switch
+ checked={data.continueOnFailure}
+ onCheckedChange={(checked) => {
if (!editable) {
return;
}
- handleChange("errorCodeMapping", value);
+ updateNodeData(id, { continueOnFailure: checked });
}}
- className="nowheel nopan"
- fontSize={8}
/>
</div>
- )}
- </div>
- <Separator />
- <div className="flex items-center justify-between">
- <div className="flex gap-2">
- <Label className="text-xs font-normal text-slate-300">
- Continue on Failure
- </Label>
- <HelpTooltip
- content={helpTooltips["validation"]["continueOnFailure"]}
- />
- </div>
- <div className="w-52">
- <Switch
- checked={data.continueOnFailure}
- onCheckedChange={(checked) => {
- if (!editable) {
- return;
- }
- updateNodeData(id, { continueOnFailure: checked });
- }}
- />
</div>
</div>
- </div>
- </AccordionContent>
- </AccordionItem>
- </Accordion>
+ </AccordionContent>
+ </AccordionItem>
+ </Accordion>
+ </div>
</div>
- </div>
+ <BlockCodeEditor blockLabel={label} blockType={type} script={script} />
+ </Flippable>
);
}
diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/components/NodeHeader.tsx b/skyvern-frontend/src/routes/workflows/editor/nodes/components/NodeHeader.tsx
index dfbac5963..73b74ba8e 100644
--- a/skyvern-frontend/src/routes/workflows/editor/nodes/components/NodeHeader.tsx
+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/components/NodeHeader.tsx
@@ -17,6 +17,7 @@ import { useDebugSessionQuery } from "@/routes/workflows/hooks/useDebugSessionQu
import { useWorkflowRunQuery } from "@/routes/workflows/hooks/useWorkflowRunQuery";
import {
debuggableWorkflowBlockTypes,
+ scriptableWorkflowBlockTypes,
type WorkflowBlockType,
type WorkflowApiResponse,
} from "@/routes/workflows/types/workflowTypes";
@@ -154,6 +155,7 @@ function NodeHeader({
const queryClient = useQueryClient();
const location = useLocation();
const isDebuggable = debuggableWorkflowBlockTypes.has(type);
+ const isScriptable = scriptableWorkflowBlockTypes.has(type);
const { data: workflowRun } = useWorkflowRunQuery();
const workflowRunIsRunningOrQueued =
workflowRun && statusIsRunningOrQueued(workflowRun);
@@ -414,6 +416,7 @@ function NodeHeader({
})}
>
<NodeActionMenu
+ isScriptable={isScriptable}
onDelete={() => {
deleteNodeCallback(nodeId);
}}
diff --git a/skyvern-frontend/src/routes/workflows/types/workflowTypes.ts b/skyvern-frontend/src/routes/workflows/types/workflowTypes.ts
index ad04ba38d..667ccc8a3 100644
--- a/skyvern-frontend/src/routes/workflows/types/workflowTypes.ts
+++ b/skyvern-frontend/src/routes/workflows/types/workflowTypes.ts
@@ -228,6 +228,17 @@ export const debuggableWorkflowBlockTypes: Set<WorkflowBlockType> = new Set([
"validation",
]);
+export const scriptableWorkflowBlockTypes: Set<WorkflowBlockType> = new Set([
+ "action",
+ "extraction",
+ "file_download",
+ "goto_url",
+ "login",
+ "navigation",
+ "task",
+ "validation",
+]);
+
export function isTaskVariantBlock(item: {
block_type: WorkflowBlockType;
}): boolean {