"use client"; import { useState, useMemo } from "react"; import { useRouter } from "next/navigation"; import { IconPlus, IconTrash } from "@tabler/icons-react"; import { Badge } from "@kandev/ui/badge"; import { Button } from "@kandev/ui/button"; import { Card, CardContent } from "@kandev/ui/card"; import { Separator } from "@kandev/ui/separator"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "@kandev/ui/dialog"; import { useAppStore } from "@/components/state-provider"; import { deleteExecutorProfile } from "@/lib/api/domains/settings-api"; import { EXECUTOR_ICON_MAP, getExecutorLabel } from "@/lib/executor-icons"; import type { Executor, ExecutorProfile } from "@/lib/types/http"; type ProfileWithExecutor = ExecutorProfile & { executor_type: string; executor_name: string; parent_executor_id: string; }; function useAllProfiles(): ProfileWithExecutor[] { const executors = useAppStore((state) => state.executors.items); return useMemo( () => executors.flatMap((e: Executor) => (e.profiles ?? []).map((p) => ({ ...p, executor_type: e.type, executor_name: e.name, parent_executor_id: e.id, })), ), [executors], ); } const DefaultIcon = EXECUTOR_ICON_MAP.local; const EXECUTOR_TYPES = [ { type: "local", label: "Local", description: "Run agents directly in the repository folder." }, { type: "worktree", label: "Worktree", description: "Create git worktrees for isolated agent sessions.", }, { type: "local_docker", label: "Docker", description: "Run Docker containers on this machine." }, { type: "sprites", label: "Sprites.dev", description: "Run agents in Sprites.dev cloud sandboxes.", }, { type: "ssh", label: "SSH", description: "Connect to a remote host over SSH and run agentctl there.", }, ] as const; function ExecutorIconBadge({ type }: { type: string }) { const Icon = EXECUTOR_ICON_MAP[type] ?? DefaultIcon; return (
); } function ProfileCard({ profile, onDelete, }: { profile: ProfileWithExecutor; onDelete: (id: string) => void; }) { const router = useRouter(); return ( router.push(`/settings/executors/${profile.id}`)} >

{profile.name}

{getExecutorLabel(profile.executor_type)}
); } function CreateTypeCard({ execType, onClick, }: { execType: (typeof EXECUTOR_TYPES)[number]; onClick: () => void; }) { return (

{execType.label}

{execType.description}

); } function DeleteProfileDialog({ profileName, open, onOpenChange, onDelete, deleting, }: { profileName: string | undefined; open: boolean; onOpenChange: (v: boolean) => void; onDelete: () => void; deleting: boolean; }) { return ( Delete Profile Are you sure you want to delete "{profileName}"? This action cannot be undone. ); } export default function ExecutorsHubPage() { const router = useRouter(); const allProfiles = useAllProfiles(); const executors = useAppStore((state) => state.executors.items); const setExecutors = useAppStore((state) => state.setExecutors); const [deleteProfileId, setDeleteProfileId] = useState(null); const [deleting, setDeleting] = useState(false); const profileToDelete = deleteProfileId ? allProfiles.find((p) => p.id === deleteProfileId) : null; const handleDelete = async () => { if (!profileToDelete) return; setDeleting(true); try { await deleteExecutorProfile(profileToDelete.parent_executor_id, profileToDelete.id); setExecutors( executors.map((e: Executor) => e.id === profileToDelete.parent_executor_id ? { ...e, profiles: (e.profiles ?? []).filter((p) => p.id !== profileToDelete.id) } : e, ), ); setDeleteProfileId(null); } finally { setDeleting(false); } }; return (

Executors

Executor profiles define how and where agents run. Each profile configures an execution environment with scripts, environment variables, and MCP policies.

Create New Profile

{EXECUTOR_TYPES.map((execType) => ( router.push(`/settings/executors/new/${execType.type}`)} /> ))}
{allProfiles.length > 0 && (

Profiles

{allProfiles.map((profile) => ( ))}
)} setDeleteProfileId(null)} onDelete={handleDelete} deleting={deleting} />
); }