import { useState } from 'react';
import { Link } from '@tanstack/react-router';
import { Info, ChevronDown } from 'lucide-react';
import { APP_PATHS } from '@/routes';
import { AddToolDialog } from '@/components/ui/add-tool-dialog';
import { ConfigureMemoryDialog } from '@/components/ui/configure-memory-dialog';
import { ToolChip } from '@/components/ui/tool-chip';
import type { Tool } from '@/types';
/**
* Toggle Switch Component
* @description A toggle switch that visually represents on/off state
*/
function ToggleSwitch({ enabled }: { enabled: boolean }) {
return (
);
}
/**
* AgentCreatePage component
* @description Page for creating a new agent with configuration options
* @returns Agent creation form page
*/
export function AgentCreatePage() {
const [enableKb, setEnableKb] = useState(false);
const [enableMemory, setEnableMemory] = useState(true);
const [isToolDialogOpen, setIsToolDialogOpen] = useState(false);
const [isMemoryDialogOpen, setIsMemoryDialogOpen] = useState(false);
const [memoryValue, setMemoryValue] = useState(2);
const [editingTool, setEditingTool] = useState(null);
const [tools, setTools] = useState([
{ id: '1', name: 'Slack', type: 'API', color: '#ff0080' },
{ id: '2', name: 'GitHub', type: 'MCP', color: '#8fbc24' },
]);
const handleAddTool = (toolData: Omit) => {
const newTool: Tool = {
...toolData,
id: Date.now().toString(), // Simple ID generation
};
setTools((prev) => [...prev, newTool]);
};
const handleUpdateTool = (toolId: string, toolData: Omit) => {
setTools((prev) =>
prev.map((tool) => (tool.id === toolId ? { ...tool, ...toolData } : tool))
);
setEditingTool(null);
};
const handleDeleteTool = (id: string) => {
setTools((prev) => prev.filter((tool) => tool.id !== id));
};
const handleRedirectTool = (id: string) => {
// Find the tool and open configuration/update dialog
const tool = tools.find((t) => t.id === id);
if (tool) {
setEditingTool(tool);
setIsToolDialogOpen(true);
}
};
const handleDialogClose = (open: boolean) => {
setIsToolDialogOpen(open);
if (!open) {
setEditingTool(null);
}
};
return (
Add Agent
{/* Main Form Card */}
{/* Left Column */}
{/* Right Column */}
{/* Features Card */}
Features
{/* Knowledge Base */}
Knowledge Base
{enableKb && (
)}
{/* Memory */}
Memory
{enableMemory && (
{memoryValue} Messages
)}
{/* Tool Configuration */}
Tool Configuration
{/* Divider */}
{/* Tools Display Section */}
{tools.map((tool) => (
))}
{/* Action Buttons */}
Cancel
{/* Add Tool Dialog */}
{/* Configure Memory Dialog */}
);
}