Skip to content

Commit

Permalink
🔄 synced local 'skyvern-frontend/src/' with remote 'skyvern-frontend/…
Browse files Browse the repository at this point in the history
…src/'

<!-- ELLIPSIS_HIDDEN -->

> [!IMPORTANT]
> Add Task v2 Block to Skyvern workflow editor with new node type, UI components, and YAML conversion logic.
>
>   - **Behavior**:
>     - Introduces `Taskv2Node` in `Taskv2Node.tsx` with properties like `prompt`, `url`, `maxIterations`, `totpVerificationUrl`, and `totpIdentifier`.
>     - Adds `taskv2` to `helpTooltips` and `placeholders` in `helpContent.ts` with specific content for `maxIterations` and `prompt`.
>     - Updates `WorkflowNodeLibraryPanel.tsx` to include `Task v2 Block` in the node library.
>   - **Models**:
>     - Defines `Taskv2NodeData` and `Taskv2Node` types in `types.ts` with default values.
>     - Adds `Taskv2Block` type to `workflowTypes.ts` and `Taskv2BlockYAML` to `workflowYamlTypes.ts`.
>   - **UI Components**:
>     - Updates `WorkflowBlockIcon.tsx` to use `ListBulletIcon` for `task_v2`.
>     - Adds `Taskv2NodeComponent` to `index.ts` for node registration.
>   - **YAML Conversion**:
>     - Updates `workflowEditorUtils.ts` to handle `task_v2` in `convertToNode`, `createNode`, `getWorkflowBlock`, and `convertBlocksToBlockYAML`.
>
> <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=Skyvern-AI%2Fskyvern-cloud&utm_source=github&utm_medium=referral)<sup> for c84b962e0c7b079036cc5ea9d84ae1744f3ff1fe. It will automatically update as commits are pushed.</sup>

<!-- ELLIPSIS_HIDDEN -->
  • Loading branch information
wintonzheng committed Jan 30, 2025
1 parent 331969a commit 2650f61
Show file tree
Hide file tree
Showing 12 changed files with 310 additions and 8 deletions.
1 change: 0 additions & 1 deletion skyvern-frontend/src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export const ProxyLocation = {
ResidentialJP: "RESIDENTIAL_JP",
ResidentialGB: "RESIDENTIAL_GB",
ResidentialFR: "RESIDENTIAL_FR",
ResidentialDE: "RESIDENTIAL_DE",
None: "NONE",
} as const;

Expand Down
3 changes: 0 additions & 3 deletions skyvern-frontend/src/components/ProxySelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ function ProxySelector({ value, onChange, className }: Props) {
<SelectItem value={ProxyLocation.ResidentialFR}>
Residential (France)
</SelectItem>
<SelectItem value={ProxyLocation.ResidentialDE}>
Residential (Germany)
</SelectItem>
</SelectContent>
</Select>
);
Expand Down
9 changes: 9 additions & 0 deletions skyvern-frontend/src/routes/workflows/editor/helpContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ export const basePlaceholderContent = {

export const helpTooltips = {
task: baseHelpTooltipContent,
taskv2: {
...baseHelpTooltipContent,
maxIterations:
"The maximum number of iterations this task will take to achieve its goal.",
},
navigation: baseHelpTooltipContent,
extraction: {
...baseHelpTooltipContent,
Expand Down Expand Up @@ -100,6 +105,10 @@ export const helpTooltips = {

export const placeholders = {
task: basePlaceholderContent,
taskv2: {
...basePlaceholderContent,
prompt: "Tell Skyvern what to do",
},
navigation: {
...basePlaceholderContent,
navigationGoal:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
import { HelpTooltip } from "@/components/HelpTooltip";
import { WorkflowBlockInputTextarea } from "@/components/WorkflowBlockInputTextarea";
import {
Accordion,
AccordionContent,
AccordionItem,
AccordionTrigger,
} from "@/components/ui/accordion";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { Separator } from "@/components/ui/separator";
import { useDeleteNodeCallback } from "@/routes/workflows/hooks/useDeleteNodeCallback";
import { useNodeLabelChangeHandler } from "@/routes/workflows/hooks/useLabelChangeHandler";
import { WorkflowBlockTypes } from "@/routes/workflows/types/workflowTypes";
import { Handle, NodeProps, Position, useReactFlow } from "@xyflow/react";
import { useState } from "react";
import { helpTooltips, placeholders } from "../../helpContent";
import { useIsFirstBlockInWorkflow } from "../../hooks/useIsFirstNodeInWorkflow";
import { NodeActionMenu } from "../NodeActionMenu";
import { WorkflowBlockIcon } from "../WorkflowBlockIcon";
import { EditableNodeTitle } from "../components/EditableNodeTitle";
import { MAX_ITERATIONS_DEFAULT, type Taskv2Node } from "./types";

function Taskv2Node({ id, data, type }: NodeProps<Taskv2Node>) {
const { updateNodeData } = useReactFlow();
const { editable } = data;
const deleteNodeCallback = useDeleteNodeCallback();
const [label, setLabel] = useNodeLabelChangeHandler({
id,
initialValue: data.label,
});

const isFirstWorkflowBlock = useIsFirstBlockInWorkflow({ id });

const [inputs, setInputs] = useState({
prompt: data.prompt,
url: data.url,
totpVerificationUrl: data.totpVerificationUrl,
totpIdentifier: data.totpIdentifier,
maxIterations: data.maxIterations,
});

function handleChange(key: string, value: unknown) {
if (!editable) {
return;
}
setInputs({ ...inputs, [key]: value });
updateNodeData(id, { [key]: value });
}

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="w-[30rem] space-y-4 rounded-lg bg-slate-elevation3 px-6 py-4">
<div className="flex h-[2.75rem] justify-between">
<div className="flex gap-2">
<div className="flex h-[2.75rem] w-[2.75rem] items-center justify-center rounded border border-slate-600">
<WorkflowBlockIcon
workflowBlockType={WorkflowBlockTypes.Taskv2}
className="size-6"
/>
</div>
<div className="flex flex-col gap-1">
<EditableNodeTitle
value={label}
editable={editable}
onChange={setLabel}
titleClassName="text-base"
inputClassName="text-base"
/>
<span className="text-xs text-slate-400">Task v2 Block</span>
</div>
</div>
<NodeActionMenu
onDelete={() => {
deleteNodeCallback(id);
}}
/>
</div>
<div className="space-y-4">
<div className="space-y-2">
<div className="flex justify-between">
<Label className="text-xs text-slate-300">Prompt</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("prompt", value);
}}
value={inputs.prompt}
placeholder={placeholders[type]["prompt"]}
className="nopan text-xs"
/>
</div>
<div className="space-y-2">
<Label className="text-xs text-slate-300">URL</Label>
<WorkflowBlockInputTextarea
nodeId={id}
onChange={(value) => {
handleChange("url", value);
}}
value={inputs.url}
placeholder={placeholders[type]["url"]}
className="nopan text-xs"
/>
</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-4">
<div className="space-y-4">
<div className="space-y-2">
<div className="flex gap-2">
<Label className="text-xs text-slate-300">
Max Iterations
</Label>
<HelpTooltip
content={helpTooltips[type]["maxIterations"]}
/>
</div>
<Input
type="number"
placeholder="10"
className="nopan text-xs"
value={data.maxIterations ?? MAX_ITERATIONS_DEFAULT}
onChange={(event) => {
handleChange("maxIterations", Number(event.target.value));
}}
/>
</div>
<div className="space-y-2">
<div className="flex gap-2">
<Label className="text-xs text-slate-300">
2FA Identifier
</Label>
<HelpTooltip
content={helpTooltips[type]["totpIdentifier"]}
/>
</div>
<WorkflowBlockInputTextarea
nodeId={id}
onChange={(value) => {
handleChange("totpIdentifier", value);
}}
value={inputs.totpIdentifier ?? ""}
placeholder={placeholders["navigation"]["totpIdentifier"]}
className="nopan text-xs"
/>
</div>
</div>
</AccordionContent>
</AccordionItem>
</Accordion>
</div>
</div>
);
}

export { Taskv2Node };
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Node } from "@xyflow/react";
import { NodeBaseData } from "../types";

export const MAX_ITERATIONS_DEFAULT = 10;

export type Taskv2NodeData = NodeBaseData & {
prompt: string;
url: string;
totpVerificationUrl: string | null;
totpIdentifier: string | null;
maxIterations: number | null;
};

export type Taskv2Node = Node<Taskv2NodeData, "taskv2">;

export const taskv2NodeDefaultData: Taskv2NodeData = {
label: "",
continueOnFailure: false,
editable: true,
prompt: "",
url: "",
totpIdentifier: null,
totpVerificationUrl: null,
maxIterations: 10,
};

export function isTaskV2Node(node: Node): node is Taskv2Node {
return node.type === "taskv2";
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ function WorkflowBlockIcon({ workflowBlockType, className }: Props) {
case "send_email": {
return <EnvelopeClosedIcon className={className} />;
}
case "task": {
case "task":
case "task_v2": {
return <ListBulletIcon className={className} />;
}
case "text_prompt": {
Expand Down
6 changes: 5 additions & 1 deletion skyvern-frontend/src/routes/workflows/editor/nodes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import { FileDownloadNode } from "./FileDownloadNode/types";
import { FileDownloadNode as FileDownloadNodeComponent } from "./FileDownloadNode/FileDownloadNode";
import { PDFParserNode } from "./PDFParserNode/types";
import { PDFParserNode as PDFParserNodeComponent } from "./PDFParserNode/PDFParserNode";
import { Taskv2Node } from "./Taskv2Node/types";
import { Taskv2Node as Taskv2NodeComponent } from "./Taskv2Node/Taskv2Node";

export type UtilityNode = StartNode | NodeAdderNode;

Expand All @@ -54,7 +56,8 @@ export type WorkflowBlockNode =
| LoginNode
| WaitNode
| FileDownloadNode
| PDFParserNode;
| PDFParserNode
| Taskv2Node;

export function isUtilityNode(node: AppNode): node is UtilityNode {
return node.type === "nodeAdder" || node.type === "start";
Expand Down Expand Up @@ -85,4 +88,5 @@ export const nodeTypes = {
wait: memo(WaitNodeComponent),
fileDownload: memo(FileDownloadNodeComponent),
pdfParser: memo(PDFParserNodeComponent),
taskv2: memo(Taskv2NodeComponent),
} as const;
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,5 @@ export const workflowBlockTitle: {
validation: "Validation",
wait: "Wait",
pdf_parser: "PDF Parser",
task_v2: "Task v2",
};
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ const nodeLibraryItems: Array<{
title: "Task Block",
description: "Takes actions or extracts information",
},
{
nodeType: "taskv2",
icon: (
<WorkflowBlockIcon
workflowBlockType={WorkflowBlockTypes.Taskv2}
className="size-6"
/>
),
title: "Task v2 Block",
description: "Runs a Skyvern v2 Task",
},
{
nodeType: "textPrompt",
icon: (
Expand Down
Loading

0 comments on commit 2650f61

Please sign in to comment.