import { useState, type ComponentType } from "react"; import { useQuery } from "@tanstack/react-query"; import { useNavigate } from "@/lib/router"; import { useDialog } from "../context/DialogContext"; import { useCompany } from "../context/CompanyContext"; import { agentsApi } from "../api/agents"; import { queryKeys } from "../lib/queryKeys"; import { Dialog, DialogContent, } from "@/components/ui/dialog"; import { Button } from "@/components/ui/button"; import { ArrowLeft, Bot, Code, Gem, MousePointer2, Sparkles, Terminal, } from "lucide-react"; import { cn } from "@/lib/utils"; import { OpenCodeLogoIcon } from "./OpenCodeLogoIcon"; type AdvancedAdapterType = | "claude_local" | "codex_local" | "gemini_local" | "opencode_local" | "pi_local" | "cursor" | "openclaw_gateway"; const ADVANCED_ADAPTER_OPTIONS: Array<{ value: AdvancedAdapterType; label: string; desc: string; icon: ComponentType<{ className?: string }>; recommended?: boolean; }> = [ { value: "claude_local", label: "Claude Code", icon: Sparkles, desc: "Local Claude agent", recommended: true, }, { value: "codex_local", label: "Codex", icon: Code, desc: "Local Codex agent", recommended: true, }, { value: "gemini_local", label: "Gemini CLI", icon: Gem, desc: "Local Gemini agent", }, { value: "opencode_local", label: "OpenCode", icon: OpenCodeLogoIcon, desc: "Local multi-provider agent", }, { value: "pi_local", label: "Pi", icon: Terminal, desc: "Local Pi agent", }, { value: "cursor", label: "Cursor", icon: MousePointer2, desc: "Local Cursor agent", }, { value: "openclaw_gateway", label: "OpenClaw Gateway", icon: Bot, desc: "Invoke OpenClaw via gateway protocol", }, ]; export function NewAgentDialog() { const { newAgentOpen, closeNewAgent, openNewIssue } = useDialog(); const { selectedCompanyId } = useCompany(); const navigate = useNavigate(); const [showAdvancedCards, setShowAdvancedCards] = useState(false); const { data: agents } = useQuery({ queryKey: queryKeys.agents.list(selectedCompanyId!), queryFn: () => agentsApi.list(selectedCompanyId!), enabled: !!selectedCompanyId && newAgentOpen, }); const ceoAgent = (agents ?? []).find((a) => a.role === "ceo"); function handleAskCeo() { closeNewAgent(); openNewIssue({ assigneeAgentId: ceoAgent?.id, title: "Create a new agent", description: "(type in what kind of agent you want here)", }); } function handleAdvancedConfig() { setShowAdvancedCards(true); } function handleAdvancedAdapterPick(adapterType: AdvancedAdapterType) { closeNewAgent(); setShowAdvancedCards(false); navigate(`/agents/new?adapterType=${encodeURIComponent(adapterType)}`); } return ( { if (!open) { setShowAdvancedCards(false); closeNewAgent(); } }} > {/* Header */}
Add a new agent
{!showAdvancedCards ? ( <> {/* Recommendation */}

We recommend letting your CEO handle agent setup — they know the org structure and can configure reporting, permissions, and adapters.

{/* Advanced link */}
) : ( <>

Choose your adapter type for advanced setup.

{ADVANCED_ADAPTER_OPTIONS.map((opt) => ( ))}
)}
); }