AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
feat(builder): Rewrite & split up node inputs (#7722)
Reinier van der Leerd82e57719677
diff --git a/rnd/autogpt_builder/package.json b/rnd/autogpt_builder/package.jsonindex f10491256f..60d051f37a 100644--- a/rnd/autogpt_builder/package.json+++ b/rnd/autogpt_builder/package.json@@ -18,6 +18,7 @@"@radix-ui/react-icons": "^1.3.0","@radix-ui/react-label": "^2.1.0","@radix-ui/react-popover": "^1.1.1",+ "@radix-ui/react-select": "^2.1.1","@radix-ui/react-scroll-area": "^1.1.0","@radix-ui/react-separator": "^1.1.0","@radix-ui/react-slot": "^1.1.0",diff --git a/rnd/autogpt_builder/src/components/CustomEdge.tsx b/rnd/autogpt_builder/src/components/CustomEdge.tsxindex 25ac6c329f..137fdea8d4 100644--- a/rnd/autogpt_builder/src/components/CustomEdge.tsx+++ b/rnd/autogpt_builder/src/components/CustomEdge.tsx@@ -32,9 +32,8 @@ const CustomEdgeFC: FC<EdgeProps<CustomEdgeData>> = ({const [isHovered, setIsHovered] = useState(false);const { setEdges } = useReactFlow();- const onEdgeClick = () => {+ const onEdgeRemoveClick = () => {setEdges((edges) => edges.filter((edge) => edge.id !== id));- data.clearNodesStatusAndOutput();};const [path, labelX, labelY] = getBezierPath({@@ -105,7 +104,7 @@ const CustomEdgeFC: FC<EdgeProps<CustomEdgeData>> = ({onMouseEnter={() => setIsHovered(true)}onMouseLeave={() => setIsHovered(false)}className={`edge-label-button ${isHovered ? "visible" : ""}`}- onClick={onEdgeClick}+ onClick={onEdgeRemoveClick}><X className="size-4" /></button>diff --git a/rnd/autogpt_builder/src/components/CustomNode.tsx b/rnd/autogpt_builder/src/components/CustomNode.tsxindex 63aeb222a8..65b4550c21 100644--- a/rnd/autogpt_builder/src/components/CustomNode.tsx+++ b/rnd/autogpt_builder/src/components/CustomNode.tsx@@ -15,13 +15,15 @@ import {BlockIORootSchema,NodeExecutionResult,} from "@/lib/autogpt-server-api/types";-import { BlockSchema } from "@/lib/types";import { beautifyString, setNestedProperty } from "@/lib/utils";+import { Button } from "@/components/ui/button";import { Switch } from "@/components/ui/switch";-import NodeHandle from "./NodeHandle";-import NodeInputField from "./NodeInputField";import { Copy, Trash2 } from "lucide-react";import { history } from "./history";+import NodeHandle from "./NodeHandle";+import { NodeGenericInputField } from "./node-input-components";++type ParsedKey = { key: string; index?: number };export type CustomNodeData = {blockType: string;@@ -37,8 +39,8 @@ export type CustomNodeData = {targetHandle: string;}>;isOutputOpen: boolean;- status?: string;- output_data?: any;+ status?: NodeExecutionResult["status"];+ output_data?: NodeExecutionResult["output_data"];block_id: string;backend_id?: string;errors?: { [key: string]: string | null };@@ -110,16 +112,30 @@ const CustomNode: FC<NodeProps<CustomNodeData>> = ({ data, id }) => {));};- const handleInputChange = (key: string, value: any) => {- const keys = key.split(".");+ const handleInputChange = (path: string, value: any) => {+ const keys = parseKeys(path);const newValues = JSON.parse(JSON.stringify(data.hardcodedValues));let current = newValues;for (let i = 0; i < keys.length - 1; i++) {- if (!current[keys[i]]) current[keys[i]] = {};- current = current[keys[i]];+ const { key: currentKey, index } = keys[i];+ if (index !== undefined) {+ if (!current[currentKey]) current[currentKey] = [];+ if (!current[currentKey][index]) current[currentKey][index] = {};+ current = current[currentKey][index];+ } else {+ if (!current[currentKey]) current[currentKey] = {};+ current = current[currentKey];+ }+ }++ const lastKey = keys[keys.length - 1];+ if (lastKey.index !== undefined) {+ if (!current[lastKey.key]) current[lastKey.key] = [];+ current[lastKey.key][lastKey.index] = value;+ } else {+ current[lastKey.key] = value;}- current[keys[keys.length - 1]] = value;console.log(`Updating hardcoded values for node ${id}:`, newValues);@@ -135,16 +151,49 @@ const CustomNode: FC<NodeProps<CustomNodeData>> = ({ data, id }) => {data.setHardcodedValues(newValues);const errors = data.errors || {};// Remove error with the same key- setNestedProperty(errors, key, null);+ setNestedProperty(errors, path, null);data.setErrors({ ...errors });};+ // Helper function to parse keys with array indices+ const parseKeys = (key: string): ParsedKey[] => {+ const regex = /(\w+)|\[(\d+)\]/g;+ const keys: ParsedKey[] = [];+ let match;+ let currentKey: string | null = null;++ while ((match = regex.exec(key)) !== null) {+ if (match[1]) {+ if (currentKey !== null) {+ keys.push({ key: currentKey });+ }+ currentKey = match[1];+ } else if (match[2]) {+ if (currentKey !== null) {+ keys.push({ key: currentKey, index: parseInt(match[2], 10) });+ currentKey = null;+ } else {+ throw new Error("Invalid key format: array index without a key");+ }+ }+ }++ if (currentKey !== null) {+ keys.push({ key: currentKey });+ }++ return keys;+ };+const getValue = (key: string) => {- const keys = key.split(".");- return keys.reduce(- (acc, k) => (acc && acc[k] !== undefined ? acc[k] : ""),- data.hardcodedValues,- );+ const keys = parseKeys(key);+ return keys.reduce((acc, k) => {+ if (acc === undefined) return undefined;+ if (k.index !== undefined) {+ return Array.isArray(acc[k.key]) ? acc[k.key][k.index] : undefined;+ }+ return acc[k.key];+ }, data.hardcodedValues as any);};const isHandleConnected = (key: string) => {@@ -208,12 +257,10 @@ const CustomNode: FC<NodeProps<CustomNodeData>> = ({ data, id }) => {const handleHovered = () => {setIsHovered(true);- console.log("isHovered", isHovered);};const handleMouseLeave = () => {setIsHovered(false);- console.log("isHovered", isHovered);};const deleteNode = useCallback(() => {@@ -274,58 +321,66 @@ const CustomNode: FC<NodeProps<CustomNodeData>> = ({ data, id }) => {<div className="text-lg font-bold">{beautifyString(data.blockType?.replace(/Block$/, "") || data.title)}</div>- <div className="node-actions">+ <div className="flex gap-[5px]">{isHovered && (<>- <button- className="node-action-button"+ <Button+ variant="outline"+ size="icon"onClick={copyNode}title="Copy node"><Copy size={18} />- </button>- <button- className="node-action-button"+ </Button>+ <Button+ variant="outline"+ size="icon"onClick={deleteNode}title="Delete node"><Trash2 size={18} />- </button>+ </Button></>)}</div></div>- <div className="node-content">+ <div className="flex justify-between items-start gap-2"><div>{data.inputSchema &&- Object.entries(data.inputSchema.properties).map(([key, schema]) => {- const isRequired = data.inputSchema.required?.includes(key);- return (- (isRequired || isAdvancedOpen) && (- <div key={key} onMouseOver={() => {}}>- <NodeHandle- keyName={key}- isConnected={isHandleConnected(key)}- isRequired={isRequired}- schema={schema}- side="left"- />- {!isHandleConnected(key) && (- <NodeInputField- keyName={key}- schema={schema}- value={getValue(key)}- handleInputClick={handleInputClick}- handleInputChange={handleInputChange}- errors={data.errors?.[key]}+ Object.entries(data.inputSchema.properties).map(+ ([propKey, propSchema]) => {+ const isRequired = data.inputSchema.required?.includes(propKey);+ return (+ (isRequired || isAdvancedOpen) && (+ <div key={propKey} onMouseOver={() => {}}>+ <NodeHandle+ keyName={propKey}+ isConnected={isHandleConnected(propKey)}+ isRequired={isRequired}+ schema={propSchema}+ side="left"/>- )}- </div>- )- );- })}+ {!isHandleConnected(propKey) && (+ <NodeGenericInputField+ className="mt-1 mb-2"+ propKey={propKey}+ propSchema={propSchema}+ currentValue={getValue(propKey)}+ handleInputChange={handleInputChange}+ handleInputClick={handleInputClick}+ errors={data.errors ?? {}}+ displayName={+ propSchema.title || beautifyString(propKey)+ }+ />+ )}+ </div>+ )+ );+ },+ )}</div>- <div>+ <div className="flex-none">{data.outputSchema && generateOutputHandles(data.outputSchema)}</div></div>@@ -355,14 +410,11 @@ const CustomNode: FC<NodeProps<CustomNodeData>> = ({ data, id }) => {</div>)}<div className="flex items-center mt-2.5">- <Switch onCheckedChange={toggleOutput} className="custom-switch" />+ <Switch onCheckedChange={toggleOutput} /><span className="m-1 mr-4">Output</span>{hasOptionalFields() && (<>- <Switch- onCheckedChange={toggleAdvancedSettings}- className="custom-switch"- />+ <Switch onCheckedChange={toggleAdvancedSettings} /><span className="m-1">Advanced</span></>)}diff --git a/rnd/autogpt_builder/src/components/Flow.tsx b/rnd/autogpt_builder/src/components/Flow.tsxindex 9441960c7a..25c0bb0a0e 100644--- a/rnd/autogpt_builder/src/components/Flow.tsx+++ b/rnd/autogpt_builder/src/components/Flow.tsx@@ -23,7 +23,6 @@ import CustomNode, { CustomNodeData } from "./CustomNode";import "./flow.css";import AutoGPTServerAPI, {Block,- BlockIOSchema,Graph,NodeExecutionResult,} from "@/lib/autogpt-server-api";@@ -458,7 +457,6 @@ const FlowEditor: React.FC<{targetHandle: link.sink_name,})),isOutputOpen: false,- setIsAnyModalOpen: setIsAnyModalOpen, // Pass setIsAnyModalOpen functionsetErrors: (errors: { [key: string]: string | null }) => {setNodes((nds) =>nds.map((node) =>@@ -502,11 +500,7 @@ const FlowEditor: React.FC<{);}- const prepareNodeInputData = (- node: Node<CustomNodeData>,- allNodes: Node<CustomNodeData>[],- allEdges: Edge<CustomEdgeData>[],- ) => {+ const prepareNodeInputData = (node: Node<CustomNodeData>) => {console.log("Preparing input data for node:", node.id, node.data.blockType);const blockSchema = availableNodes.find(@@ -519,7 +513,7 @@ const FlowEditor: React.FC<{}const getNestedData = (- schema: BlockIOSchema,+ schema: BlockIOSubSchema,values: { [key: string]: any },): { [key: string]: any } => {let inputData: { [key: string]: any } = {};@@ -580,7 +574,7 @@ const FlowEditor: React.FC<{const key = `${node.data.block_id}_${node.position.x}_${node.position.y}`;blockIdToNodeIdMap[key] = node.id;});- const inputDefault = prepareNodeInputData(node, nodes, edges);+ const inputDefault = prepareNodeInputData(node);const inputNodes = edges.filter((edge) => edge.target === node.id).map((edge) => ({@@ -685,7 +679,10 @@ const FlowEditor: React.FC<{// Populate errors if validation failsvalidate.errors?.forEach((error) => {// Skip error if there's an edge connected- const path = error.instancePath || error.schemaPath;+ const path =+ "dataPath" in error+ ? (error.dataPath as string)+ : error.instancePath;const handle = path.split(/[\/.]/)[0];if (node.data.connections.some(@@ -845,17 +842,17 @@ const FlowEditor: React.FC<{const editorControls: Control[] = [{label: "Undo",- icon: <Undo2 />,+ icon: <Undo2 size={18} />,onClick: handleUndo,},{label: "Redo",- icon: <Redo2 />,+ icon: <Redo2 size={18} />,onClick: handleRedo,},{label: "Run",- icon: <Play />,+ icon: <Play size={18} />,onClick: runAgent,},];@@ -883,17 +880,15 @@ const FlowEditor: React.FC<{onNodeDragStart={onNodesChangeStart}onNodeDragStop={onNodesChangeEnd}>- <div className={"flex flex-row absolute z-10 gap-2"}>- <ControlPanel controls={editorControls}>- <BlocksControl blocks={availableNodes} addBlock={addNode} />- <SaveControl- agentMeta={savedAgent}- onSave={saveAgent}- onDescriptionChange={setAgentDescription}- onNameChange={setAgentName}- />- </ControlPanel>- </div>+ <ControlPanel className="absolute z-10" controls={editorControls}>+ <BlocksControl blocks={availableNodes} addBlock={addNode} />+ <SaveControl+ agentMeta={savedAgent}+ onSave={saveAgent}+ onDescriptionChange={setAgentDescription}+ onNameChange={setAgentName}+ />+ </ControlPanel></ReactFlow></div>);diff --git a/rnd/autogpt_builder/src/components/NodeHandle.tsx b/rnd/autogpt_builder/src/components/NodeHandle.tsxindex a61ac48777..b300929f88 100644--- a/rnd/autogpt_builder/src/components/NodeHandle.tsx+++ b/rnd/autogpt_builder/src/components/NodeHandle.tsx@@ -1,4 +1,4 @@-import { BlockIOSchema } from "@/lib/autogpt-server-api/types";+import { BlockIOSubSchema } from "@/lib/autogpt-server-api/types";import { beautifyString, getTypeBgColor, getTypeTextColor } from "@/lib/utils";import { FC } from "react";import { Handle, Position } from "reactflow";@@ -6,7 +6,7 @@ import SchemaTooltip from "./SchemaTooltip";type HandleProps = {keyName: string;- schema: BlockIOSchema;+ schema: BlockIOSubSchema;isConnected: boolean;isRequired?: boolean;side: "left" | "right";@@ -28,7 +28,7 @@ const NodeHandle: FC<HandleProps> = ({null: "null",};- const typeClass = `text-sm ${getTypeTextColor(schema.type)} ${side === "left" ? "text-left" : "text-right"}`;+ const typeClass = `text-sm ${getTypeTextColor(schema.type || "any")} ${side === "left" ? "text-left" : "text-right"}`;const label = (<div className="flex flex-col flex-grow">@@ -36,13 +36,13 @@ const NodeHandle: FC<HandleProps> = ({{schema.title || beautifyString(keyName)}{isRequired ? "*" : ""}</span>- <span className={typeClass}>{typeName[schema.type]}</span>+ <span className={typeClass}>{typeName[schema.type] || "any"}</span></div>);const dot = (<div- className={`w-4 h-4 m-1 ${isConnected ? getTypeBgColor(schema.type) : "bg-gray-600"} rounded-full transition-colors duration-100 group-hover:bg-gray-300`}+ className={`w-4 h-4 m-1 ${isConnected ? getTypeBgColor(schema.type || "any") : "bg-gray-600"} rounded-full transition-colors duration-100 group-hover:bg-gray-300`}/>);@@ -53,7 +53,7 @@ const NodeHandle: FC<HandleProps> = ({type="target"position={Position.Left}id={keyName}- className="group -ml-[29px]"+ className="group -ml-[26px]"><div className="pointer-events-none flex items-center">{dot}@@ -70,7 +70,7 @@ const NodeHandle: FC<HandleProps> = ({type="source"position={Position.Right}id={keyName}- className="group -mr-[29px]"+ className="group -mr-[26px]"><div className="pointer-events-none flex items-center">{label}diff --git a/rnd/autogpt_builder/src/components/NodeInputField.tsx b/rnd/autogpt_builder/src/components/NodeInputField.tsxdeleted file mode 100644index 566ccecc94..0000000000--- a/rnd/autogpt_builder/src/components/NodeInputField.tsx+++ /dev/null@@ -1,357 +0,0 @@-import { Cross2Icon, PlusIcon } from "@radix-ui/react-icons";-import { beautifyString } from "@/lib/utils";-import { BlockIOSchema } from "@/lib/autogpt-server-api/types";-import { FC, useState } from "react";-import { Button } from "./ui/button";-import { Input } from "./ui/input";--type BlockInputFieldProps = {- keyName: string;- schema: BlockIOSchema;- parentKey?: string;- value: string | Array<string> | { [key: string]: string };- handleInputClick: (key: string) => void;- handleInputChange: (key: string, value: any) => void;- errors?: { [key: string]: string } | string | null;-};--const NodeInputField: FC<BlockInputFieldProps> = ({- keyName: key,- schema,- parentKey = "",- value,- handleInputClick,- handleInputChange,- errors,-}) => {- const fullKey = parentKey ? `${parentKey}.${key}` : key;- const error = typeof errors === "string" ? errors : (errors?.[key] ?? "");- const displayKey = schema.title || beautifyString(key);-- const [keyValuePairs, _setKeyValuePairs] = useState<- { key: string; value: string }[]- >(- "additionalProperties" in schema && value- ? Object.entries(value).map(([key, value]) => ({- key: key,- value: value,- }))- : [],- );-- function setKeyValuePairs(newKVPairs: typeof keyValuePairs): void {- _setKeyValuePairs(newKVPairs);- handleInputChange(- fullKey,- newKVPairs.reduce(- (obj, { key, value }) => ({ ...obj, [key]: value }),- {},- ),- );- }-- const renderClickableInput = (- value: string | null = null,- placeholder: string = "",- secret: boolean = false,- ) => {- const className = `clickable-input ${error ? "border-error" : ""}`;-- return secret ? (- <div className={className} onClick={() => handleInputClick(fullKey)}>- {value ? (- <span>********</span>- ) : (- <i className="text-gray-500">{placeholder}</i>- )}- </div>- ) : (- <div className={className} onClick={() => handleInputClick(fullKey)}>- {value || <i className="text-gray-500">{placeholder}</i>}- </div>- );- };-- if ("properties" in schema) {- return (- <div key={fullKey} className="object-input">- <strong>{displayKey}:</strong>- {Object.entries(schema.properties).map(([propKey, propSchema]) => (- <div key={`${fullKey}.${propKey}`} className="nested-input">- <NodeInputField- keyName={propKey}- schema={propSchema}- parentKey={fullKey}- value={(value as { [key: string]: string })[propKey]}- handleInputClick={handleInputClick}- handleInputChange={handleInputChange}- errors={errors}- />- </div>- ))}- </div>- );- }-- if (schema.type === "object" && schema.additionalProperties) {- return (- <div key={fullKey}>- <div>- {keyValuePairs.map(({ key, value }, index) => (- <div- key={index}- className="flex items-center w-[325px] space-x-2 mb-2"- >- <Input- type="text"- placeholder="Key"- value={key}- onChange={(e) =>- setKeyValuePairs(- keyValuePairs.toSpliced(index, 1, {- key: e.target.value,- value: value,- }),- )- }- />- <Input- type="text"- placeholder="Value"- value={value}- onChange={(e) =>- setKeyValuePairs(- keyValuePairs.toSpliced(index, 1, {- key: key,- value: e.target.value,- }),- )- }- />- <Button- variant="ghost"- className="px-2"- onClick={() =>- setKeyValuePairs(keyValuePairs.toSpliced(index, 1))- }- >- <Cross2Icon />- </Button>- </div>- ))}- <Button- className="w-full"- onClick={() =>- setKeyValuePairs(keyValuePairs.concat({ key: "", value: "" }))- }- >- <PlusIcon className="mr-2" /> Add Property- </Button>- </div>- {error && <span className="error-message">{error}</span>}- </div>- );- }-- if ("anyOf" in schema) {- const types = schema.anyOf.map((s) => ("type" in s ? s.type : undefined));- if (types.includes("string") && types.includes("null")) {- return (- <div key={fullKey} className="input-container">- {renderClickableInput(- value as string,- schema.placeholder || `Enter ${displayKey} (optional)`,- )}- {error && <span className="error-message">{error}</span>}- </div>- );- }- }-- if ("allOf" in schema) {- return (- <div key={fullKey} className="object-input">- <strong>{displayKey}:</strong>- {"properties" in schema.allOf[0] &&- Object.entries(schema.allOf[0].properties).map(- ([propKey, propSchema]) => (- <div key={`${fullKey}.${propKey}`} className="nested-input">- <NodeInputField- keyName={propKey}- schema={propSchema}- parentKey={fullKey}- value={(value as { [key: string]: string })[propKey]}- handleInputClick={handleInputClick}- handleInputChange={handleInputChange}- errors={errors}- />- </div>- ),- )}- </div>- );- }-- if ("oneOf" in schema) {- return (- <div key={fullKey} className="object-input">- <strong>{displayKey}:</strong>- {"properties" in schema.oneOf[0] &&- Object.entries(schema.oneOf[0].properties).map(- ([propKey, propSchema]) => (- <div key={`${fullKey}.${propKey}`} className="nested-input">- <NodeInputField- keyName={propKey}- schema={propSchema}- parentKey={fullKey}- value={(value as { [key: string]: string })[propKey]}- handleInputClick={handleInputClick}- handleInputChange={handleInputChange}- errors={errors}- />- </div>- ),- )}- </div>- );- }-- if (!("type" in schema)) {- console.warn(`Schema for input ${key} does not specify a type:`, schema);- return (- <div key={fullKey} className="input-container">- {renderClickableInput(- value as string,- schema.placeholder || `Enter ${beautifyString(displayKey)} (Complex)`,- )}- {error && <span className="error-message">{error}</span>}- </div>- );- }-- switch (schema.type) {- case "string":- if (schema.enum) {- return (- <div key={fullKey} className="input-container">- <select- value={(value as string) || ""}- onChange={(e) => handleInputChange(fullKey, e.target.value)}- className="select-input"- >- <option value="">Select {displayKey}</option>- {schema.enum.map((option: string) => (- <option key={option} value={option}>- {beautifyString(option)}- </option>- ))}- </select>- {error && <span className="error-message">{error}</span>}- </div>- );- }-- if (schema.secret) {- return (- <div key={fullKey} className="input-container">- {renderClickableInput(- value as string,- schema.placeholder || `Enter ${displayKey}`,- true,- )}- {error && <span className="error-message">{error}</span>}- </div>- );- }-- return (- <div key={fullKey} className="input-container">- {renderClickableInput(- value as string,- schema.placeholder || `Enter ${displayKey}`,- )}- {error && <span className="error-message">{error}</span>}- </div>- );- case "boolean":- return (- <div key={fullKey} className="input-container">- <select- value={value === undefined ? "" : value.toString()}- onChange={(e) =>- handleInputChange(fullKey, e.target.value === "true")- }- className="select-input"- >- <option value="">Select {displayKey}</option>- <option value="true">True</option>- <option value="false">False</option>- </select>- {error && <span className="error-message">{error}</span>}- </div>- );- case "number":- case "integer":- return (- <div key={fullKey} className="input-container">- <Input- type="number"- value={(value as string) || ""}- onChange={(e) =>- handleInputChange(fullKey, parseFloat(e.target.value))- }- className={`number-input ${error ? "border-error" : ""}`}- />- {error && <span className="error-message">{error}</span>}- </div>- );- case "array":- if (schema.items && schema.items.type === "string") {- const arrayValues = (value as Array<string>) || [];- return (- <div key={fullKey} className="input-container">- {arrayValues.map((item: string, index: number) => (- <div key={`${fullKey}.${index}`} className="array-item-container">- <Input- type="text"- value={item}- onChange={(e) =>- handleInputChange(`${fullKey}.${index}`, e.target.value)- }- className="array-item-input"- />- <Button- onClick={() => handleInputChange(`${fullKey}.${index}`, "")}- className="array-item-remove"- >- ×- </Button>- </div>- ))}- <Button- onClick={() => handleInputChange(fullKey, [...arrayValues, ""])}- className="array-item-add"- >- Add Item- </Button>- {error && <span className="error-message ml-2">{error}</span>}- </div>- );- }- return null;- default:- console.warn(`Schema for input ${key} specifies unknown type:`, schema);- return (- <div key={fullKey} className="input-container">- {renderClickableInput(- value as string,- schema.placeholder ||- `Enter ${beautifyString(displayKey)} (Complex)`,- )}- {error && <span className="error-message">{error}</span>}- </div>- );- }-};--export default NodeInputField;diff --git a/rnd/autogpt_builder/src/components/SchemaTooltip.tsx b/rnd/autogpt_builder/src/components/SchemaTooltip.tsxindex aa2131a6a3..e16db7508a 100644--- a/rnd/autogpt_builder/src/components/SchemaTooltip.tsx+++ b/rnd/autogpt_builder/src/components/SchemaTooltip.tsx@@ -4,11 +4,11 @@ import {TooltipProvider,TooltipTrigger,} from "@/components/ui/tooltip";-import { BlockIOSchema } from "@/lib/autogpt-server-api/types";+import { BlockIOSubSchema } from "@/lib/autogpt-server-api/types";import { Info } from "lucide-react";import ReactMarkdown from "react-markdown";-const SchemaTooltip: React.FC<{ schema: BlockIOSchema }> = ({ schema }) => {+const SchemaTooltip: React.FC<{ schema: BlockIOSubSchema }> = ({ schema }) => {if (!schema.description) return null;return (diff --git a/rnd/autogpt_builder/src/components/customnode.css b/rnd/autogpt_builder/src/components/customnode.cssindex c6968fed73..1dcf75b789 100644--- a/rnd/autogpt_builder/src/components/customnode.css+++ b/rnd/autogpt_builder/src/components/customnode.css@@ -1,5 +1,5 @@.custom-node {- padding: 15px;+ @apply p-3;border: 3px solid #4b5563;border-radius: 12px;background: #ffffff;@@ -9,13 +9,6 @@transition: border-color 0.3s ease-in-out;}-.node-content {- display: flex;- justify-content: space-between;- align-items: flex-start;- gap: 1px;-}-.custom-node .mb-2 {display: flex;justify-content: space-between;@@ -30,45 +23,6 @@margin-right: 10px;}-.node-actions {- display: flex;- gap: 5px;-}--.node-action-button {- width: 32px;- /* Increased size */- height: 32px;- /* Increased size */- display: flex;- align-items: center;- justify-content: center;- background-color: #f3f4f6;- /* Light gray background */- border: 1px solid #d1d5db;- /* Light border */- border-radius: 6px;- color: #4b5563;- transition: all 0.2s ease-in-out;- cursor: pointer;-}--.node-action-button:hover {- background-color: #e5e7eb;- color: #1f2937;-}--.node-action-button:focus {- outline: none;- box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);-}--.node-action-button svg {- width: 18px;- /* Increased icon size */- height: 18px;- /* Increased icon size */-}/* Existing styles */.handle-container {display: flex;@@ -89,38 +43,10 @@transform: none;}-.input-container {- margin-bottom: 5px;-}--.clickable-input {- padding: 5px;- width: 325px;- border-radius: 4px;- background: #ffffff;- border: 1px solid #d1d1d1;- color: #000000;- cursor: pointer;- word-break: break-all;- white-space: nowrap;- overflow: hidden;- text-overflow: ellipsis;- position: relative;-}-.border-error {border: 1px solid #d9534f;}-.clickable-input span {- display: inline-block;- white-space: nowrap;- overflow: hidden;- text-overflow: ellipsis;- max-width: calc(100% - 100px);- vertical-align: middle;-}-.select-input {width: 100%;padding: 5px;@@ -191,29 +117,9 @@.error-message {color: #d9534f;- font-size: 12px;+ font-size: 13px;margin-top: 5px;-}--.object-input {- margin-left: 10px;- border-left: 1px solid #000; /* Border for nested inputs */- padding-left: 10px;-}--.nested-input {- margin-top: 5px;-}--.key-value-input {- display: flex;- gap: 5px;- align-items: center;- margin-bottom: 5px;-}--.key-value-input input {- flex-grow: 1;+ margin-left: 5px;}/* Styles for node states */@@ -240,3 +146,13 @@.custom-switch {padding-left: 2px;}++input[type="number"]::-webkit-outer-spin-button,+input[type="number"]::-webkit-inner-spin-button {+ -webkit-appearance: none;+ margin: 0;+}++input[type="number"] {+ -moz-appearance: textfield;+}diff --git a/rnd/autogpt_builder/src/components/edit/control/BlocksControl.tsx b/rnd/autogpt_builder/src/components/edit/control/BlocksControl.tsxindex 4a834a13c8..637923bc3a 100644--- a/rnd/autogpt_builder/src/components/edit/control/BlocksControl.tsx+++ b/rnd/autogpt_builder/src/components/edit/control/BlocksControl.tsx@@ -40,8 +40,10 @@ export const BlocksControl: React.FC<BlocksControlProps> = ({return (<Popover>- <PopoverTrigger className="hover:bg-gray-100 hover:text-gray-900 dark:hover:bg-gray-800 dark:hover:text-gray-50 dark:text-white">- <ToyBrick className="size-4" />+ <PopoverTrigger asChild>+ <Button size="icon" variant="ghost">+ <ToyBrick size={18} />+ </Button></PopoverTrigger><PopoverContentside="right"diff --git a/rnd/autogpt_builder/src/components/edit/control/ControlPanel.tsx b/rnd/autogpt_builder/src/components/edit/control/ControlPanel.tsxindex c129579385..b8d662c93f 100644--- a/rnd/autogpt_builder/src/components/edit/control/ControlPanel.tsx+++ b/rnd/autogpt_builder/src/components/edit/control/ControlPanel.tsx@@ -6,6 +6,7 @@ import {} from "@/components/ui/tooltip";import { Button } from "@/components/ui/button";import { Separator } from "@/components/ui/separator";+import { cn } from "@/lib/utils";import React from "react";/**@@ -24,6 +25,7 @@ export type Control = {interface ControlPanelProps {controls: Control[];children?: React.ReactNode;+ className?: string;}/**@@ -31,11 +33,16 @@ interface ControlPanelProps {* @param {Object} ControlPanelProps - The properties of the control panel component.* @param {Array} ControlPanelProps.controls - An array of control objects representing actions to be preformed.* @param {Array} ControlPanelProps.children - The child components of the control panel.+ * @param {string} ControlPanelProps.className - Additional CSS class names for the control panel.* @returns The rendered control panel component.*/-export const ControlPanel = ({ controls, children }: ControlPanelProps) => {+export const ControlPanel = ({+ controls,+ children,+ className,+}: ControlPanelProps) => {return (- <aside className="hidden w-14 flex-col sm:flex">+ <aside className={cn("hidden w-14 flex-col sm:flex", className)}><Card><CardContent className="p-0"><div className="flex flex-col items-center gap-4 px-2 sm:py-5 rounded-radius">diff --git a/rnd/autogpt_builder/src/components/edit/control/SaveControl.tsx b/rnd/autogpt_builder/src/components/edit/control/SaveControl.tsxindex 6b7789fb6e..14aa655683 100644--- a/rnd/autogpt_builder/src/components/edit/control/SaveControl.tsx+++ b/rnd/autogpt_builder/src/components/edit/control/SaveControl.tsx@@ -51,8 +51,10 @@ export const SaveControl = ({return (<Popover>- <PopoverTrigger className="hover:bg-gray-100 hover:text-gray-900 dark:hover:bg-gray-800 dark:hover:text-gray-50 dark:text-white">- <Save className="size-4" />+ <PopoverTrigger asChild>+ <Button variant="ghost" size="icon">+ <Save size={18} />+ </Button></PopoverTrigger><PopoverContent side="right" sideOffset={15} align="start"><Card className="border-none shadow-none">diff --git a/rnd/autogpt_builder/src/components/flow.css b/rnd/autogpt_builder/src/components/flow.cssindex d74b8ddeea..830099e750 100644--- a/rnd/autogpt_builder/src/components/flow.css+++ b/rnd/autogpt_builder/src/components/flow.css@@ -11,20 +11,6 @@ code {monospace;}-button {- background-color: #ffffff;- color: #000000;- padding: 10px;- border: none;- border-radius: 4px;- cursor: pointer;- transition: background-color 0.3s ease;-}--button:hover {- background-color: #666;-}-input,textarea {background-color: #ffffff;@@ -128,24 +114,3 @@ textarea::placeholder {width: 100%;height: 600px; /* Adjust this height as needed */}--.flow-wrapper {- height: 100%;- width: 100%;- display: flex;- justify-content: center;- align-items: center;-}--.flow-controls {- position: absolute;- left: -80px;- z-index: 1001;- display: flex;- gap: 10px;- transition: transform 0.3s ease;-}--.flow-controls.open {- transform: translateX(350px);-}diff --git a/rnd/autogpt_builder/src/components/node-input-components.tsx b/rnd/autogpt_builder/src/components/node-input-components.tsxnew file mode 100644index 0000000000..04143dae4a--- /dev/null+++ b/rnd/autogpt_builder/src/components/node-input-components.tsx@@ -0,0 +1,616 @@+import { Cross2Icon, Pencil2Icon, PlusIcon } from "@radix-ui/react-icons";+import { beautifyString, cn } from "@/lib/utils";+import {+ BlockIORootSchema,+ BlockIOSubSchema,+ BlockIOObjectSubSchema,+ BlockIOKVSubSchema,+ BlockIOArraySubSchema,+ BlockIOStringSubSchema,+ BlockIONumberSubSchema,+ BlockIOBooleanSubSchema,+} from "@/lib/autogpt-server-api/types";+import { FC, useState } from "react";+import { Button } from "./ui/button";+import { Switch } from "./ui/switch";+import {+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue,+} from "./ui/select";+import { Input } from "./ui/input";++type NodeObjectInputTreeProps = {+ selfKey?: string;+ schema: BlockIORootSchema | BlockIOObjectSubSchema;+ object?: { [key: string]: any };+ handleInputClick: (key: string) => void;+ handleInputChange: (key: string, value: any) => void;+ errors: { [key: string]: string | undefined };+ className?: string;+ displayName?: string;+};++const NodeObjectInputTree: FC<NodeObjectInputTreeProps> = ({+ selfKey = "",+ schema,+ object,+ handleInputClick,+ handleInputChange,+ errors,+ className,+ displayName,+}) => {+ object ??= ("default" in schema ? schema.default : null) ?? {};+ return (+ <div className={cn(className, "flex-col w-full")}>+ {displayName && <strong>{displayName}</strong>}+ {Object.entries(schema.properties).map(([propKey, propSchema]) => {+ const childKey = selfKey ? `${selfKey}.${propKey}` : propKey;++ return (+ <div+ key={propKey}+ className="flex flex-row justify-between space-y-2 w-full"+ >+ <span className="mr-2 mt-3">+ {propSchema.title || beautifyString(propKey)}+ </span>+ <NodeGenericInputField+ key={propKey}+ propKey={childKey}+ propSchema={propSchema}+ currentValue={object ? object[propKey] : undefined}+ errors={errors}+ handleInputChange={handleInputChange}+ handleInputClick={handleInputClick}+ displayName={propSchema.title || beautifyString(propKey)}+ />+ </div>+ );+ })}+ </div>+ );+};++export default NodeObjectInputTree;++export const NodeGenericInputField: FC<{+ propKey: string;+ propSchema: BlockIOSubSchema;+ currentValue?: any;+ errors: NodeObjectInputTreeProps["errors"];+ handleInputChange: NodeObjectInputTreeProps["handleInputChange"];+ handleInputClick: NodeObjectInputTreeProps["handleInputClick"];+ className?: string;+ displayName?: string;+}> = ({+ propKey,+ propSchema,+ currentValue,+ errors,+ handleInputChange,+ handleInputClick,+ className,+ displayName,+}) => {+ displayName ??= propSchema.title || beautifyString(propKey);++ if ("allOf" in propSchema) {+ // If this happens, that is because Pydantic wraps $refs in an allOf if the+ // $ref has sibling schema properties (which isn't technically allowed),+ // so there will only be one item in allOf[].+ // AFAIK this should NEVER happen though, as $refs are resolved server-side.+ propSchema = propSchema.allOf[0];+ console.warn(`Unsupported 'allOf' in schema for '${propKey}'!`, propSchema);+ }++ if ("properties" in propSchema) {+ return (+ <NodeObjectInputTree+ selfKey={propKey}+ schema={propSchema}+ object={currentValue}+ errors={errors}+ className={cn("border-l border-gray-500 pl-2", className)} // visual indent+ displayName={displayName}+ handleInputClick={handleInputClick}+ handleInputChange={handleInputChange}+ />+ );+ }++ if ("additionalProperties" in propSchema) {+ return (+ <NodeKeyValueInput+ selfKey={propKey}+ schema={propSchema}+ entries={currentValue}+ errors={errors}+ className={className}+ displayName={displayName}+ handleInputChange={handleInputChange}+ />+ );+ }++ if ("anyOf" in propSchema) {+ // optional items+ const types = propSchema.anyOf.map((s) =>+ "type" in s ? s.type : undefined,+ );+ if (types.includes("string") && types.includes("null")) {+ // optional string+ return (+ <NodeStringInput+ selfKey={propKey}+ schema={{ ...propSchema, type: "string" } as BlockIOStringSubSchema}+ value={currentValue}+ error={errors[propKey]}+ className={className}+ displayName={displayName}+ handleInputChange={handleInputChange}+ handleInputClick={handleInputClick}+ />+ );+ }+ }++ if ("oneOf" in propSchema) {+ // At the time of writing, this isn't used in the backend -> no impl. needed+ console.error(+ `Unsupported 'oneOf' in schema for '${propKey}'!`,+ propSchema,+ );+ return null;+ }++ if (!("type" in propSchema)) {+ return (+ <NodeFallbackInput+ selfKey={propKey}+ schema={propSchema}+ value={currentValue}+ error={errors[propKey]}+ className={className}+ displayName={displayName}+ handleInputChange={handleInputChange}+ handleInputClick={handleInputClick}+ />+ );+ }++ switch (propSchema.type) {+ case "string":+ return (+ <NodeStringInput+ selfKey={propKey}+ schema={propSchema}+ value={currentValue}+ error={errors[propKey]}+ className={className}+ displayName={displayName}+ handleInputChange={handleInputChange}+ handleInputClick={handleInputClick}+ />+ );+ case "boolean":+ return (+ <NodeBooleanInput+ selfKey={propKey}+ schema={propSchema}+ value={currentValue}+ error={errors[propKey]}+ className={className}+ displayName={displayName}+ handleInputChange={handleInputChange}+ />+ );+ case "number":+ case "integer":+ return (+ <NodeNumberInput+ selfKey={propKey}+ schema={propSchema}+ value={currentValue}+ error={errors[propKey]}+ className={className}+ displayName={displayName}+ handleInputChange={handleInputChange}+ />+ );+ case "array":+ return (+ <NodeArrayInput+ selfKey={propKey}+ schema={propSchema}+ entries={currentValue}+ errors={errors}+ className={className}+ displayName={displayName}+ handleInputChange={handleInputChange}+ handleInputClick={handleInputClick}+ />+ );+ default:+ console.warn(+ `Schema for '${propKey}' specifies unknown type:`,+ propSchema,+ );+ return (+ <NodeFallbackInput+ selfKey={propKey}+ schema={propSchema}+ value={currentValue}+ error={errors[propKey]}+ className={className}+ displayName={displayName}+ handleInputChange={handleInputChange}+ handleInputClick={handleInputClick}+ />+ );+ }+};++const NodeKeyValueInput: FC<{+ selfKey: string;+ schema: BlockIOKVSubSchema;+ entries?: { [key: string]: string } | { [key: string]: number };+ errors: { [key: string]: string | undefined };+ handleInputChange: NodeObjectInputTreeProps["handleInputChange"];+ className?: string;+ displayName?: string;+}> = ({+ selfKey,+ entries,+ schema,+ handleInputChange,+ errors,+ className,+ displayName,+}) => {+ const [keyValuePairs, setKeyValuePairs] = useState<+ {+ key: string;+ value: string | number | null;+ }[]+ >(+ Object.entries(entries ?? schema.default ?? {}).map(([key, value]) => ({+ key,+ value: value,+ })),+ );++ function updateKeyValuePairs(newPairs: typeof keyValuePairs) {+ setKeyValuePairs(newPairs);+ handleInputChange(+ selfKey,+ newPairs.reduce((obj, { key, value }) => ({ ...obj, [key]: value }), {}),+ );+ }++ function convertValueType(value: string): string | number | null {+ if (schema.additionalProperties.type == "string") return value;+ if (!value) return null;+ return Number(value);+ }++ return (+ <div className={cn(className, "flex flex-col")}>+ {displayName && <strong>{displayName}</strong>}+ <div>+ {keyValuePairs.map(({ key, value }, index) => (+ <div key={index}>+ <div className="flex items-center space-x-2 mb-2">+ <Input+ type="text"+ placeholder="Key"+ value={key}+ onChange={(e) =>+ updateKeyValuePairs(+ keyValuePairs.toSpliced(index, 1, {+ key: e.target.value,+ value: value,+ }),+ )+ }+ />+ <Input+ type="text"+ placeholder="Value"+ value={value ?? ""}+ onChange={(e) =>+ updateKeyValuePairs(+ keyValuePairs.toSpliced(index, 1, {+ key: key,+ value: convertValueType(e.target.value),+ }),+ )+ }+ />+ <Button+ variant="ghost"+ className="px-2"+ onClick={() =>+ updateKeyValuePairs(keyValuePairs.toSpliced(index, 1))+ }+ >+ <Cross2Icon />+ </Button>+ </div>+ {errors[`${selfKey}.${key}`] && (+ <span className="error-message">+ {errors[`${selfKey}.${key}`]}+ </span>+ )}+ </div>+ ))}+ <Button+ className="w-full"+ onClick={() =>+ updateKeyValuePairs(keyValuePairs.concat({ key: "", value: "" }))+ }+ >+ <PlusIcon className="mr-2" /> Add Property+ </Button>+ </div>+ {errors[selfKey] && (+ <span className="error-message">{errors[selfKey]}</span>+ )}+ </div>+ );+};++const NodeArrayInput: FC<{+ selfKey: string;+ schema: BlockIOArraySubSchema;+ entries?: string[];+ errors: { [key: string]: string | undefined };+ handleInputChange: NodeObjectInputTreeProps["handleInputChange"];+ handleInputClick: NodeObjectInputTreeProps["handleInputClick"];+ className?: string;+ displayName?: string;+}> = ({+ selfKey,+ schema,+ entries,+ errors,+ handleInputChange,+ handleInputClick,+ className,+ displayName,+}) => {+ entries ??= schema.default ?? [];+ const isItemObject = "items" in schema && "properties" in schema.items!;+ const error =+ typeof errors[selfKey] === "string" ? errors[selfKey] : undefined;+ return (+ <div className={cn(className, "flex flex-col")}>+ {displayName && <strong>{displayName}</strong>}+ {entries.map((entry: any, index: number) => {+ const entryKey = `${selfKey}[${index}]`;+ return (+ <div key={entryKey}>+ <div className="flex items-center space-x-2 mb-2">+ {schema.items ? (+ <NodeGenericInputField+ propKey={entryKey}+ propSchema={schema.items}+ currentValue={entry}+ errors={errors}+ handleInputChange={handleInputChange}+ handleInputClick={handleInputClick}+ />+ ) : (+ <NodeFallbackInput+ selfKey={entryKey}+ schema={schema.items}+ value={entry}+ error={errors[entryKey]}+ displayName={displayName || beautifyString(selfKey)}+ handleInputChange={handleInputChange}+ handleInputClick={handleInputClick}+ />+ )}+ <Button+ variant="ghost"+ size="icon"+ onClick={() =>+ handleInputChange(selfKey, entries.toSpliced(index, 1))+ }+ >+ <Cross2Icon />+ </Button>+ </div>+ {errors[entryKey] && typeof errors[entryKey] === "string" && (+ <span className="error-message">{errors[entryKey]}</span>+ )}+ </div>+ );+ })}+ <Button+ onClick={() =>+ handleInputChange(selfKey, [...entries, isItemObject ? {} : ""])+ }+ >+ <PlusIcon className="mr-2" /> Add Item+ </Button>+ {error && <span className="error-message">{error}</span>}+ </div>+ );+};++const NodeStringInput: FC<{+ selfKey: string;+ schema: BlockIOStringSubSchema;+ value?: string;+ error?: string;+ handleInputChange: NodeObjectInputTreeProps["handleInputChange"];+ handleInputClick: NodeObjectInputTreeProps["handleInputClick"];+ className?: string;+ displayName: string;+}> = ({+ selfKey,+ schema,+ value,+ error,+ handleInputChange,+ handleInputClick,+ className,+ displayName,+}) => {+ return (+ <div className={className}>+ {schema.enum ? (+ <Select+ defaultValue={value}+ onValueChange={(newValue) => handleInputChange(selfKey, newValue)}+ >+ <SelectTrigger>+ <SelectValue placeholder={schema.placeholder || displayName} />+ </SelectTrigger>+ <SelectContent className="nodrag">+ {schema.enum.map((option, index) => (+ <SelectItem key={index} value={option}>+ {beautifyString(option)}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ ) : (+ <div+ className="nodrag relative"+ onClick={schema.secret ? () => handleInputClick(selfKey) : undefined}+ >+ <Input+ type="text"+ id={selfKey}+ value={schema.secret && value ? "********" : value}+ readOnly={schema.secret}+ placeholder={+ schema?.placeholder || `Enter ${beautifyString(displayName)}`+ }+ onChange={(e) => handleInputChange(selfKey, e.target.value)}+ className="pr-8 read-only:cursor-pointer read-only:text-gray-500"+ />+ <Button+ variant="ghost"+ size="icon"+ className="absolute inset-1 left-auto h-7 w-7 rounded-[0.25rem]"+ onClick={() => handleInputClick(selfKey)}+ title="Open a larger textbox input"+ >+ <Pencil2Icon className="m-0 p-0" />+ </Button>+ </div>+ )}+ {error && <span className="error-message">{error}</span>}+ </div>+ );+};++const NodeNumberInput: FC<{+ selfKey: string;+ schema: BlockIONumberSubSchema;+ value?: number;+ error?: string;+ handleInputChange: NodeObjectInputTreeProps["handleInputChange"];+ className?: string;+ displayName?: string;+}> = ({+ selfKey,+ schema,+ value,+ error,+ handleInputChange,+ className,+ displayName,+}) => {+ value ??= schema.default;+ displayName ??= schema.title || beautifyString(selfKey);+ return (+ <div className={className}>+ <div className="flex items-center justify-between space-x-3 nodrag">+ <Input+ type="number"+ id={selfKey}+ value={value}+ onChange={(e) =>+ handleInputChange(selfKey, parseFloat(e.target.value))+ }+ placeholder={+ schema.placeholder || `Enter ${beautifyString(displayName)}`+ }+ />+ </div>+ {error && <span className="error-message">{error}</span>}+ </div>+ );+};++const NodeBooleanInput: FC<{+ selfKey: string;+ schema: BlockIOBooleanSubSchema;+ value?: boolean;+ error?: string;+ handleInputChange: NodeObjectInputTreeProps["handleInputChange"];+ className?: string;+ displayName: string;+}> = ({+ selfKey,+ schema,+ value,+ error,+ handleInputChange,+ className,+ displayName,+}) => {+ value ??= schema.default ?? false;+ return (+ <div className={className}>+ <div className="flex items-center nodrag">+ <Switch+ checked={value}+ onCheckedChange={(v) => handleInputChange(selfKey, v)}+ />+ <span className="ml-3">{displayName}</span>+ </div>+ {error && <span className="error-message">{error}</span>}+ </div>+ );+};++const NodeFallbackInput: FC<{+ selfKey: string;+ schema?: BlockIOSubSchema;+ value: any;+ error?: string;+ handleInputChange: NodeObjectInputTreeProps["handleInputChange"];+ handleInputClick: NodeObjectInputTreeProps["handleInputClick"];+ className?: string;+ displayName: string;+}> = ({+ selfKey,+ schema,+ value,+ error,+ handleInputChange,+ handleInputClick,+ className,+ displayName,+}) => {+ return (+ <NodeStringInput+ selfKey={selfKey}+ schema={{ type: "string", ...schema } as BlockIOStringSubSchema}+ value={value}+ error={error}+ handleInputChange={handleInputChange}+ handleInputClick={handleInputClick}+ className={className}+ displayName={displayName}+ />+ );+};diff --git a/rnd/autogpt_builder/src/components/ui/select.tsx b/rnd/autogpt_builder/src/components/ui/select.tsxnew file mode 100644index 0000000000..d002f0eb1c--- /dev/null+++ b/rnd/autogpt_builder/src/components/ui/select.tsx@@ -0,0 +1,167 @@+"use client";++import * as React from "react";+import {+ CaretSortIcon,+ CheckIcon,+ ChevronDownIcon,+ ChevronUpIcon,+} from "@radix-ui/react-icons";+import * as SelectPrimitive from "@radix-ui/react-select";++import { cn } from "@/lib/utils";++const Select = SelectPrimitive.Root;++const SelectGroup = SelectPrimitive.Group;++const SelectValue = SelectPrimitive.Value;++const SelectTrigger = React.forwardRef<+ React.ElementRef<typeof SelectPrimitive.Trigger>,+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>+>(({ className, children, ...props }, ref) => (+ <SelectPrimitive.Trigger+ ref={ref}+ className={cn(+ "flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-neutral-200 bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-white placeholder:text-neutral-500 focus:outline-none focus:ring-1 focus:ring-neutral-950 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1 dark:border-neutral-800 dark:ring-offset-neutral-950 dark:placeholder:text-neutral-400 dark:focus:ring-neutral-300",+ className,+ )}+ {...props}+ >+ {children}+ <SelectPrimitive.Icon asChild>+ <CaretSortIcon className="h-4 w-4 opacity-50" />+ </SelectPrimitive.Icon>+ </SelectPrimitive.Trigger>+));+SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;++const SelectScrollUpButton = React.forwardRef<+ React.ElementRef<typeof SelectPrimitive.ScrollUpButton>,+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>+>(({ className, ...props }, ref) => (+ <SelectPrimitive.ScrollUpButton+ ref={ref}+ className={cn(+ "flex cursor-default items-center justify-center py-1",+ className,+ )}+ {...props}+ >+ <ChevronUpIcon />+ </SelectPrimitive.ScrollUpButton>+));+SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;++const SelectScrollDownButton = React.forwardRef<+ React.ElementRef<typeof SelectPrimitive.ScrollDownButton>,+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>+>(({ className, ...props }, ref) => (+ <SelectPrimitive.ScrollDownButton+ ref={ref}+ className={cn(+ "flex cursor-default items-center justify-center py-1",+ className,+ )}+ {...props}+ >+ <ChevronDownIcon />+ </SelectPrimitive.ScrollDownButton>+));+SelectScrollDownButton.displayName =+ SelectPrimitive.ScrollDownButton.displayName;++const SelectContent = React.forwardRef<+ React.ElementRef<typeof SelectPrimitive.Content>,+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>+>(({ className, children, position = "popper", ...props }, ref) => (+ <SelectPrimitive.Portal>+ <SelectPrimitive.Content+ ref={ref}+ className={cn(+ "relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border border-neutral-200 bg-white text-neutral-950 shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50",+ position === "popper" &&+ "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",+ className,+ )}+ position={position}+ {...props}+ >+ <SelectScrollUpButton />+ <SelectPrimitive.Viewport+ className={cn(+ "p-1",+ position === "popper" &&+ "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]",+ )}+ >+ {children}+ </SelectPrimitive.Viewport>+ <SelectScrollDownButton />+ </SelectPrimitive.Content>+ </SelectPrimitive.Portal>+));+SelectContent.displayName = SelectPrimitive.Content.displayName;++const SelectLabel = React.forwardRef<+ React.ElementRef<typeof SelectPrimitive.Label>,+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>+>(({ className, ...props }, ref) => (+ <SelectPrimitive.Label+ ref={ref}+ className={cn("px-2 py-1.5 text-sm font-semibold", className)}+ {...props}+ />+));+SelectLabel.displayName = SelectPrimitive.Label.displayName;++const SelectItem = React.forwardRef<+ React.ElementRef<typeof SelectPrimitive.Item>,+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>+>(({ className, children, ...props }, ref) => (+ <SelectPrimitive.Item+ ref={ref}+ className={cn(+ "relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-neutral-100 focus:text-neutral-900 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 dark:focus:bg-neutral-800 dark:focus:text-neutral-50",+ className,+ )}+ {...props}+ >+ <span className="absolute right-2 flex h-3.5 w-3.5 items-center justify-center">+ <SelectPrimitive.ItemIndicator>+ <CheckIcon className="h-4 w-4" />+ </SelectPrimitive.ItemIndicator>+ </span>+ <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>+ </SelectPrimitive.Item>+));+SelectItem.displayName = SelectPrimitive.Item.displayName;++const SelectSeparator = React.forwardRef<+ React.ElementRef<typeof SelectPrimitive.Separator>,+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>+>(({ className, ...props }, ref) => (+ <SelectPrimitive.Separator+ ref={ref}+ className={cn(+ "-mx-1 my-1 h-px bg-neutral-100 dark:bg-neutral-800",+ className,+ )}+ {...props}+ />+));+SelectSeparator.displayName = SelectPrimitive.Separator.displayName;++export {+ Select,+ SelectGroup,+ SelectValue,+ SelectTrigger,+ SelectContent,+ SelectLabel,+ SelectItem,+ SelectSeparator,+ SelectScrollUpButton,+ SelectScrollDownButton,+};diff --git a/rnd/autogpt_builder/src/lib/autogpt-server-api/types.ts b/rnd/autogpt_builder/src/lib/autogpt-server-api/types.tsindex f4ad2dc39d..c79de13648 100644--- a/rnd/autogpt_builder/src/lib/autogpt-server-api/types.ts+++ b/rnd/autogpt_builder/src/lib/autogpt-server-api/types.ts@@ -9,60 +9,86 @@ export type Block = {export type BlockIORootSchema = {type: "object";- properties: { [key: string]: BlockIOSchema };+ properties: { [key: string]: BlockIOSubSchema };required?: string[];additionalProperties?: { type: string };};-export type BlockIOSchema = {+export type BlockIOSubSchema =+ | BlockIOSimpleTypeSubSchema+ | BlockIOCombinedTypeSubSchema;++type BlockIOSimpleTypeSubSchema =+ | BlockIOObjectSubSchema+ | BlockIOKVSubSchema+ | BlockIOArraySubSchema+ | BlockIOStringSubSchema+ | BlockIONumberSubSchema+ | BlockIOBooleanSubSchema+ | BlockIONullSubSchema;++type BlockIOSubSchemaMeta = {title?: string;description?: string;placeholder?: string;-} & (BlockIOSimpleTypeSchema | BlockIOCombinedTypeSchema);--type BlockIOSimpleTypeSchema =- | {- type: "object";- properties: { [key: string]: BlockIOSchema };- required?: string[];- additionalProperties?: { type: string };- }- | {- type: "array";- items?: BlockIOSimpleTypeSchema;- }- | {- type: "string";- enum?: string[];- secret?: true;- default?: string;- }- | {- type: "integer" | "number";- default?: number;- }- | {- type: "boolean";- default?: boolean;- }- | {- type: "null";- };+};++export type BlockIOObjectSubSchema = BlockIOSubSchemaMeta & {+ type: "object";+ properties: { [key: string]: BlockIOSubSchema };+ default?: { [key: keyof BlockIOObjectSubSchema["properties"]]: any };+ required?: keyof BlockIOObjectSubSchema["properties"][];+};++export type BlockIOKVSubSchema = BlockIOSubSchemaMeta & {+ type: "object";+ additionalProperties: { type: "string" | "number" | "integer" };+ default?: { [key: string]: string | number };+};++export type BlockIOArraySubSchema = BlockIOSubSchemaMeta & {+ type: "array";+ items?: BlockIOSimpleTypeSubSchema;+ default?: Array<string>;+};++export type BlockIOStringSubSchema = BlockIOSubSchemaMeta & {+ type: "string";+ enum?: string[];+ secret?: true;+ default?: string;+};++export type BlockIONumberSubSchema = BlockIOSubSchemaMeta & {+ type: "integer" | "number";+ default?: number;+};++export type BlockIOBooleanSubSchema = BlockIOSubSchemaMeta & {+ type: "boolean";+ default?: boolean;+};++export type BlockIONullSubSchema = BlockIOSubSchemaMeta & {+ type: "null";+};// At the time of writing, combined schemas only occur on the first nested level in a// block schema. It is typed this way to make the use of these objects less tedious.-type BlockIOCombinedTypeSchema =- | {- allOf: [BlockIOSimpleTypeSchema];- }- | {- anyOf: BlockIOSimpleTypeSchema[];- default?: string | number | boolean | null;- }- | {- oneOf: BlockIOSimpleTypeSchema[];- default?: string | number | boolean | null;- };+type BlockIOCombinedTypeSubSchema = BlockIOSubSchemaMeta &+ (+ | {+ allOf: [BlockIOSimpleTypeSubSchema];+ }+ | {+ anyOf: BlockIOSimpleTypeSubSchema[];+ default?: string | number | boolean | null;+ }+ | {+ oneOf: BlockIOSimpleTypeSubSchema[];+ default?: string | number | boolean | null;+ }+ );/* Mirror of autogpt_server/data/graph.py:Node */export type Node = {diff --git a/rnd/autogpt_builder/src/lib/utils.ts b/rnd/autogpt_builder/src/lib/utils.tsindex 6bf9c9c46c..7d7639c5b7 100644--- a/rnd/autogpt_builder/src/lib/utils.ts+++ b/rnd/autogpt_builder/src/lib/utils.ts@@ -45,6 +45,7 @@ export function getTypeTextColor(type: string | null): string {object: "text-purple-500",array: "text-indigo-500",null: "text-gray-500",+ any: "text-gray-500","": "text-gray-500",}[type] || "text-gray-500");@@ -61,6 +62,7 @@ export function getTypeBgColor(type: string | null): string {object: "bg-purple-500",array: "bg-indigo-500",null: "bg-gray-500",+ any: "bg-gray-500","": "bg-gray-500",}[type] || "bg-gray-500");@@ -76,6 +78,7 @@ export function getTypeColor(type: string | null): string {object: "#a855f7",array: "#6366f1",null: "#6b7280",+ any: "#6b7280","": "#6b7280",}[type] || "#6b7280");diff --git a/rnd/autogpt_builder/yarn.lock b/rnd/autogpt_builder/yarn.lockindex 78e24778e2..3aad91e49d 100644--- a/rnd/autogpt_builder/yarn.lock+++ b/rnd/autogpt_builder/yarn.lock@@ -466,6 +466,33 @@"@radix-ui/react-use-callback-ref" "1.1.0""@radix-ui/react-use-controllable-state" "1.1.0"+"@radix-ui/react-select@^2.1.1":+ version "2.1.1"+ resolved "https://registry.yarnpkg.com/@radix-ui/react-select/-/react-select-2.1.1.tgz#df05cb0b29d3deaef83b505917c4042e0e418a9f"+ integrity sha512-8iRDfyLtzxlprOo9IicnzvpsO1wNCkuwzzCM+Z5Rb5tNOpCdMvcc2AkzX0Fz+Tz9v6NJ5B/7EEgyZveo4FBRfQ==+ dependencies:+ "@radix-ui/number" "1.1.0"+ "@radix-ui/primitive" "1.1.0"+ "@radix-ui/react-collection" "1.1.0"+ "@radix-ui/react-compose-refs" "1.1.0"+ "@radix-ui/react-context" "1.1.0"+ "@radix-ui/react-direction" "1.1.0"+ "@radix-ui/react-dismissable-layer" "1.1.0"+ "@radix-ui/react-focus-guards" "1.1.0"+ "@radix-ui/react-focus-scope" "1.1.0"+ "@radix-ui/react-id" "1.1.0"+ "@radix-ui/react-popper" "1.2.0"+ "@radix-ui/react-portal" "1.1.1"+ "@radix-ui/react-primitive" "2.0.0"+ "@radix-ui/react-slot" "1.1.0"+ "@radix-ui/react-use-callback-ref" "1.1.0"+ "@radix-ui/react-use-controllable-state" "1.1.0"+ "@radix-ui/react-use-layout-effect" "1.1.0"+ "@radix-ui/react-use-previous" "1.1.0"+ "@radix-ui/react-visually-hidden" "1.1.0"+ aria-hidden "^1.1.1"+ react-remove-scroll "2.5.7"+"@radix-ui/react-scroll-area@^1.1.0":version "1.1.0"resolved "https://registry.yarnpkg.com/@radix-ui/react-scroll-area/-/react-scroll-area-1.1.0.tgz#50b24b0fc9ada151d176395bcf47b2ec68feada5"