diff --git a/src/renderer/components/organization/AgentCreator.tsx b/src/renderer/components/organization/AgentCreator.tsx index 05dddc3f..15f4b3b4 100644 --- a/src/renderer/components/organization/AgentCreator.tsx +++ b/src/renderer/components/organization/AgentCreator.tsx @@ -1,12 +1,5 @@ -import { useEffect, useMemo, useState } from "react"; -import { AnimatePresence, motion } from "framer-motion"; -import { Robot } from "@phosphor-icons/react"; -import { DEPARTMENT_OPTIONS } from "@shared/constants"; -import type { AgentRecord, ConnectorRecord, DepartmentId, WorkspaceRecord } from "@shared/types"; -import { isConnectorExecutionReady } from "@shared/connector-policy"; -import { unwrap } from "../../lib/desktop"; -import { ActionButton, Input, Select, TextArea } from "../ui"; -import { useT } from "../../i18n"; +import type { AgentRecord, ConnectorRecord, WorkspaceRecord } from "@shared/types"; +import { AgentForm } from "./agent-form"; export function AgentCreator({ companyId, @@ -21,188 +14,14 @@ export function AgentCreator({ agents: AgentRecord[]; onSaved: () => Promise; }) { - const executionReadyConnectors = useMemo( - () => connectors.filter((connector) => isConnectorExecutionReady(connector)), - [connectors], - ); - const [name, setName] = useState(""); - const [role, setRole] = useState(""); - const [title, setTitle] = useState(""); - const [department, setDepartment] = useState(""); - const [connectorId, setConnectorId] = useState(executionReadyConnectors[0]?.id ?? ""); - const [model, setModel] = useState(""); - const [availableModels, setAvailableModels] = useState>([]); - const [workspaceId, setWorkspaceId] = useState(workspaces[0]?.id ?? ""); - const [budget, setBudget] = useState("120"); - const [capabilities, setCapabilities] = useState(""); - const [reportsTo, setReportsTo] = useState(""); - const [thinkingEffort, setThinkingEffort] = useState(""); - const [requestError, setRequestError] = useState(null); - const supportsEffort = connectorId === "claude_local" || connectorId === "codex_local"; - const selectedConnector = executionReadyConnectors.find((connector) => connector.id === connectorId) ?? null; - - useEffect(() => { - if (!connectorId) { - setAvailableModels([]); - setModel(""); - return; - } - void (async () => { - const result = await window.agentCompany.listConnectorModels(connectorId); - if (result.ok) { - setAvailableModels(result.data); - setModel(result.data[0]?.id ?? ""); - } - })(); - if (connectorId !== "claude_local" && connectorId !== "codex_local") { - setThinkingEffort(""); - } - }, [connectorId]); - - useEffect(() => { - if (!connectorId && executionReadyConnectors[0]) { - setConnectorId(executionReadyConnectors[0].id); - return; - } - if (connectorId && !executionReadyConnectors.some((connector) => connector.id === connectorId)) { - setConnectorId(executionReadyConnectors[0]?.id ?? ""); - } - }, [executionReadyConnectors, connectorId]); - - const t = useT(); - const [showAdvanced, setShowAdvanced] = useState(false); - const selectedDepartment: DepartmentId | null = department === "" ? null : department; - return ( -
- - - - ({ value: m.id, label: m.label }))} - /> - ) : null} - {supportsEffort ? ( - setDepartment(value as DepartmentId | "")} - options={DEPARTMENT_OPTIONS.map((option) => ({ - value: option.value, - label: option.value === "" ? t("comm.selectDepartment") : option.label, - }))} - /> - ({ value: a.id, label: a.name })), - ]} - /> - -