@apteva/apteva-linux-arm64 0.4.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/apteva +0 -0
  2. package/dist/ActivityPage.41nbye4r.js +3 -0
  3. package/dist/ActivityPage.41nbye4r.js.map +9 -0
  4. package/dist/ApiDocsPage.4smnt8m3.js +4 -0
  5. package/dist/ApiDocsPage.4smnt8m3.js.map +10 -0
  6. package/dist/App.0sbax9et.js +4 -0
  7. package/dist/App.0sbax9et.js.map +10 -0
  8. package/dist/App.0ws427h8.js +4 -0
  9. package/dist/App.0ws427h8.js.map +10 -0
  10. package/dist/App.6q6bar8b.js +4 -0
  11. package/dist/App.6q6bar8b.js.map +10 -0
  12. package/dist/App.80301vdb.js +4 -0
  13. package/dist/App.80301vdb.js.map +10 -0
  14. package/dist/App.af2wg84v.js +267 -0
  15. package/dist/App.af2wg84v.js.map +35 -0
  16. package/dist/App.ca1rz1ph.js +4 -0
  17. package/dist/App.ca1rz1ph.js.map +14 -0
  18. package/dist/App.ensa6z0r.js +4 -0
  19. package/dist/App.ensa6z0r.js.map +10 -0
  20. package/dist/App.f8g7tych.js +13 -0
  21. package/dist/App.f8g7tych.js.map +10 -0
  22. package/dist/App.mvtqv6qc.js +20 -0
  23. package/dist/App.mvtqv6qc.js.map +14 -0
  24. package/dist/App.ncgc9cxy.js +4 -0
  25. package/dist/App.ncgc9cxy.js.map +10 -0
  26. package/dist/App.p02f4ret.js +1 -0
  27. package/dist/App.p0fb1pds.js +4 -0
  28. package/dist/App.p0fb1pds.js.map +10 -0
  29. package/dist/App.pmaq48sj.js +4 -0
  30. package/dist/App.pmaq48sj.js.map +10 -0
  31. package/dist/App.yv87t9m5.js +4 -0
  32. package/dist/App.yv87t9m5.js.map +10 -0
  33. package/dist/App.zjmfm8p6.js +4 -0
  34. package/dist/App.zjmfm8p6.js.map +10 -0
  35. package/dist/ConnectionsPage.anb3rv9a.js +3 -0
  36. package/dist/ConnectionsPage.anb3rv9a.js.map +9 -0
  37. package/dist/McpPage.y396h6fy.js +3 -0
  38. package/dist/McpPage.y396h6fy.js.map +9 -0
  39. package/dist/SettingsPage.p1hc60gk.js +3 -0
  40. package/dist/SettingsPage.p1hc60gk.js.map +9 -0
  41. package/dist/SkillsPage.yj3xdsay.js +3 -0
  42. package/dist/SkillsPage.yj3xdsay.js.map +9 -0
  43. package/dist/TasksPage.sjv0khtv.js +3 -0
  44. package/dist/TasksPage.sjv0khtv.js.map +9 -0
  45. package/dist/TelemetryPage.2qm4w16r.js +3 -0
  46. package/dist/TelemetryPage.2qm4w16r.js.map +9 -0
  47. package/dist/TestsPage.zzs4qfj8.js +3 -0
  48. package/dist/TestsPage.zzs4qfj8.js.map +9 -0
  49. package/dist/apteva-kit.css +1 -0
  50. package/dist/icon.png +0 -0
  51. package/dist/index.html +16 -0
  52. package/dist/styles.css +1 -0
  53. package/index.js +1 -0
  54. package/package.json +10 -0
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/web/components/tasks/TasksPage.tsx"],
4
+ "sourcesContent": [
5
+ "import React, { useState, useEffect, useCallback, useRef, useMemo } from \"react\";\nimport { TasksIcon, CloseIcon, RecurringIcon, ScheduledIcon, TaskOnceIcon } from \"../common/Icons\";\nimport { useAuth, useProjects } from \"../../context\";\nimport { useTelemetry } from \"../../context/TelemetryContext\";\nimport type { Task, TaskTrajectoryStep, ToolUseBlock, ToolResultBlock } from \"../../types\";\n\ninterface TasksPageProps {\n onSelectAgent?: (agentId: string) => void;\n}\n\nexport function TasksPage({ onSelectAgent }: TasksPageProps) {\n const { authFetch } = useAuth();\n const { currentProjectId } = useProjects();\n const [tasks, setTasks] = useState<Task[]>([]);\n const [loading, setLoading] = useState(true);\n const [filter, setFilter] = useState<string>(\"all\");\n const [selectedTask, setSelectedTask] = useState<Task | null>(null);\n const [loadingTask, setLoadingTask] = useState(false);\n const lastProcessedEventRef = useRef<string | null>(null);\n\n // Subscribe to task telemetry events for real-time updates\n const { events: taskEvents } = useTelemetry({ category: \"TASK\" });\n\n const fetchTasks = useCallback(async () => {\n try {\n let url = `/api/tasks?status=${filter}`;\n if (currentProjectId !== null) {\n url += `&project_id=${encodeURIComponent(currentProjectId)}`;\n }\n const res = await authFetch(url);\n const data = await res.json();\n setTasks(data.tasks || []);\n } catch (e) {\n console.error(\"Failed to fetch tasks:\", e);\n } finally {\n setLoading(false);\n }\n }, [authFetch, filter, currentProjectId]);\n\n // Initial fetch\n useEffect(() => {\n fetchTasks();\n }, [fetchTasks]);\n\n // Handle real-time task events from telemetry - use as trigger to refetch\n // since telemetry data is incomplete (missing id, agentId, status, etc.)\n useEffect(() => {\n if (!taskEvents.length) return;\n\n const latestEvent = taskEvents[0];\n if (!latestEvent || latestEvent.id === lastProcessedEventRef.current) return;\n\n // Only react to task mutation events\n const eventType = latestEvent.type;\n if (eventType === \"task_created\" || eventType === \"task_updated\" || eventType === \"task_deleted\") {\n lastProcessedEventRef.current = latestEvent.id;\n console.log(\"[TasksPage] Telemetry event:\", eventType);\n // Refetch to get complete task data\n fetchTasks();\n }\n }, [taskEvents, fetchTasks]);\n\n // Fetch full task details (including trajectory) when selecting a task\n const selectTask = useCallback(async (task: Task) => {\n // Set task immediately for quick feedback\n setSelectedTask(task);\n setLoadingTask(true);\n\n try {\n const res = await authFetch(`/api/tasks/${task.agentId}/${task.id}`);\n console.log(\"[TasksPage] Fetch task response status:\", res.status);\n if (res.ok) {\n const data = await res.json();\n console.log(\"[TasksPage] Task data:\", data);\n console.log(\"[TasksPage] Has trajectory:\", !!data.task?.trajectory, \"Length:\", data.task?.trajectory?.length);\n if (data.task) {\n // Merge with agentId/agentName since API might not include them\n setSelectedTask({ ...data.task, agentId: task.agentId, agentName: task.agentName });\n }\n } else {\n console.error(\"[TasksPage] Failed to fetch task:\", res.status, await res.text());\n }\n } catch (e) {\n console.error(\"Failed to fetch task details:\", e);\n } finally {\n setLoadingTask(false);\n }\n }, [authFetch]);\n\n // Sort tasks: running first, then pending by next execution (soonest first), then completed/failed by date\n const sortedTasks = useMemo(() => {\n return [...tasks].sort((a, b) => {\n // Running tasks first\n if (a.status === \"running\" && b.status !== \"running\") return -1;\n if (b.status === \"running\" && a.status !== \"running\") return 1;\n // Pending tasks next\n const aIsPending = a.status === \"pending\";\n const bIsPending = b.status === \"pending\";\n if (aIsPending && !bIsPending) return -1;\n if (bIsPending && !aIsPending) return 1;\n // For running/pending: sort by next execution time (soonest first)\n if (aIsPending && bIsPending || a.status === \"running\" && b.status === \"running\") {\n const aTime = a.next_run || a.execute_at || null;\n const bTime = b.next_run || b.execute_at || null;\n const aTs = aTime ? new Date(aTime).getTime() : Infinity;\n const bTs = bTime ? new Date(bTime).getTime() : Infinity;\n return aTs - bTs;\n }\n // For completed/failed: most recent first\n const aDate = a.completed_at || a.executed_at || a.created_at;\n const bDate = b.completed_at || b.executed_at || b.created_at;\n return new Date(bDate).getTime() - new Date(aDate).getTime();\n });\n }, [tasks]);\n\n const statusColors: Record<string, string> = {\n pending: \"bg-yellow-500/20 text-yellow-400\",\n running: \"bg-blue-500/20 text-blue-400\",\n completed: \"bg-green-500/20 text-green-400\",\n failed: \"bg-red-500/20 text-red-400\",\n cancelled: \"bg-gray-500/20 text-gray-400\",\n };\n\n const filterOptions = [\n { value: \"all\", label: \"All\" },\n { value: \"pending\", label: \"Pending\" },\n { value: \"running\", label: \"Running\" },\n { value: \"completed\", label: \"Completed\" },\n { value: \"failed\", label: \"Failed\" },\n ];\n\n return (\n <div className=\"flex-1 flex overflow-hidden\">\n {/* Task List */}\n <div className={`flex-1 p-4 md:p-6 overflow-auto ${selectedTask ? 'hidden md:block md:w-1/2 lg:w-2/3' : ''}`}>\n <div className=\"max-w-4xl\">\n <div className=\"mb-6\">\n <div className=\"mb-4\">\n <h1 className=\"text-xl md:text-2xl font-semibold mb-1\">Tasks</h1>\n <p className=\"text-sm text-[#666]\">\n View tasks from all running agents\n </p>\n </div>\n <div className=\"flex gap-2 overflow-x-auto scrollbar-hide pb-1\">\n {filterOptions.map(opt => (\n <button\n key={opt.value}\n onClick={() => setFilter(opt.value)}\n className={`px-3 py-1.5 rounded text-sm transition whitespace-nowrap ${\n filter === opt.value\n ? \"bg-[#f97316] text-black\"\n : \"bg-[#1a1a1a] hover:bg-[#222]\"\n }`}\n >\n {opt.label}\n </button>\n ))}\n </div>\n </div>\n\n {loading ? (\n <div className=\"text-center py-12 text-[#666]\">Loading tasks...</div>\n ) : sortedTasks.length === 0 ? (\n <div className=\"text-center py-12\">\n <TasksIcon className=\"w-12 h-12 mx-auto mb-4 text-[#333]\" />\n <p className=\"text-[#666]\">No tasks found</p>\n <p className=\"text-sm text-[#444] mt-1\">\n Tasks will appear here when agents create them\n </p>\n </div>\n ) : (\n <div className=\"space-y-3\">\n {sortedTasks.map(task => (\n <div\n key={`${task.agentId}-${task.id}`}\n onClick={() => selectTask(task)}\n className={`bg-[#111] border rounded-lg p-4 cursor-pointer transition ${\n selectedTask?.id === task.id && selectedTask?.agentId === task.agentId\n ? \"border-[#f97316]\"\n : \"border-[#1a1a1a] hover:border-[#333]\"\n }`}\n >\n <div className=\"flex items-start justify-between mb-2\">\n <div className=\"flex-1\">\n <h3 className=\"font-medium\">{task.title}</h3>\n <p className=\"text-sm text-[#666]\">{task.agentName}</p>\n </div>\n <span className={`px-2 py-1 rounded text-xs font-medium ${statusColors[task.status] || statusColors.pending}`}>\n {task.status}\n </span>\n </div>\n\n {task.description && (\n <p className=\"text-sm text-[#888] mb-2 line-clamp-2\">\n {task.description}\n </p>\n )}\n\n <div className=\"flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-[#555]\">\n <span className=\"flex items-center gap-1\">\n {task.type === \"recurring\"\n ? <RecurringIcon className=\"w-3.5 h-3.5\" />\n : task.execute_at\n ? <ScheduledIcon className=\"w-3.5 h-3.5\" />\n : <TaskOnceIcon className=\"w-3.5 h-3.5\" />\n }\n {task.type === \"recurring\" && task.recurrence ? formatCron(task.recurrence) : task.type}\n </span>\n <span>Priority: {task.priority}</span>\n {task.next_run && (\n <span className=\"text-[#f97316]\">{formatRelativeTime(task.next_run)}</span>\n )}\n {!task.next_run && task.execute_at && (\n <span className=\"text-[#f97316]\">{formatRelativeTime(task.execute_at)}</span>\n )}\n <span>Created: {new Date(task.created_at).toLocaleDateString()}</span>\n </div>\n </div>\n ))}\n </div>\n )}\n </div>\n </div>\n\n {/* Task Detail Panel */}\n {selectedTask && (\n <TaskDetailPanel\n task={selectedTask}\n statusColors={statusColors}\n onClose={() => setSelectedTask(null)}\n onSelectAgent={onSelectAgent}\n loading={loadingTask}\n />\n )}\n </div>\n );\n}\n\nexport interface TaskDetailPanelProps {\n task: Task;\n statusColors: Record<string, string>;\n onClose: () => void;\n onSelectAgent?: (agentId: string) => void;\n loading?: boolean;\n}\n\nexport function TaskDetailPanel({ task, statusColors, onClose, onSelectAgent, loading }: TaskDetailPanelProps) {\n return (\n <div className=\"w-full md:w-1/2 lg:w-1/3 border-l border-[#1a1a1a] bg-[#0a0a0a] flex flex-col overflow-hidden\">\n {/* Header */}\n <div className=\"flex items-center justify-between p-4 border-b border-[#1a1a1a]\">\n <h2 className=\"font-medium truncate pr-2\">Task Details</h2>\n <button onClick={onClose} className=\"text-[#666] hover:text-[#e0e0e0] transition\">\n <CloseIcon />\n </button>\n </div>\n\n {/* Content */}\n <div className=\"flex-1 overflow-auto p-4 space-y-4\">\n {/* Title & Status */}\n <div>\n <div className=\"flex items-start justify-between gap-2 mb-2\">\n <h3 className=\"text-lg font-medium\">{task.title}</h3>\n <span className={`px-2 py-1 rounded text-xs font-medium flex-shrink-0 ${statusColors[task.status]}`}>\n {task.status}\n </span>\n </div>\n <button\n onClick={() => onSelectAgent?.(task.agentId)}\n className=\"text-sm text-[#f97316] hover:underline\"\n >\n {task.agentName}\n </button>\n </div>\n\n {/* Description */}\n {task.description && (\n <div>\n <h4 className=\"text-xs text-[#666] uppercase tracking-wider mb-1\">Description</h4>\n <p className=\"text-sm text-[#888] whitespace-pre-wrap\">{task.description}</p>\n </div>\n )}\n\n {/* Metadata */}\n <div className=\"grid grid-cols-2 gap-3 text-sm\">\n <div>\n <span className=\"text-[#666]\">Type</span>\n <p className=\"capitalize\">{task.type}</p>\n </div>\n <div>\n <span className=\"text-[#666]\">Priority</span>\n <p>{task.priority}</p>\n </div>\n <div>\n <span className=\"text-[#666]\">Source</span>\n <p className=\"capitalize\">{task.source}</p>\n </div>\n {task.recurrence && (\n <div>\n <span className=\"text-[#666]\">Recurrence</span>\n <p>{formatCron(task.recurrence)}</p>\n <p className=\"text-xs text-[#444] mt-0.5 font-mono\">{task.recurrence}</p>\n </div>\n )}\n </div>\n\n {/* Timestamps */}\n <div className=\"space-y-2 text-sm\">\n <div className=\"flex justify-between\">\n <span className=\"text-[#666]\">Created</span>\n <span>{new Date(task.created_at).toLocaleString()}</span>\n </div>\n {task.execute_at && (\n <div className=\"flex justify-between\">\n <span className=\"text-[#666]\">Scheduled</span>\n <span className=\"text-[#f97316]\">{formatRelativeTime(task.execute_at)}</span>\n </div>\n )}\n {task.executed_at && (\n <div className=\"flex justify-between\">\n <span className=\"text-[#666]\">Started</span>\n <span>{new Date(task.executed_at).toLocaleString()}</span>\n </div>\n )}\n {task.completed_at && (\n <div className=\"flex justify-between\">\n <span className=\"text-[#666]\">Completed</span>\n <span>{new Date(task.completed_at).toLocaleString()}</span>\n </div>\n )}\n {task.next_run && (\n <div className=\"flex justify-between\">\n <span className=\"text-[#666]\">Next Run</span>\n <span className=\"text-[#f97316]\">{formatRelativeTime(task.next_run)}</span>\n </div>\n )}\n </div>\n\n {/* Error */}\n {task.status === \"failed\" && task.error && (\n <div className=\"min-w-0\">\n <h4 className=\"text-xs text-red-400 uppercase tracking-wider mb-1\">Error</h4>\n <div className=\"bg-red-500/10 border border-red-500/20 rounded p-3 overflow-x-auto\">\n <pre className=\"text-sm text-red-400 whitespace-pre-wrap break-words\">{task.error}</pre>\n </div>\n </div>\n )}\n\n {/* Result */}\n {task.status === \"completed\" && task.result && (\n <div className=\"min-w-0\">\n <h4 className=\"text-xs text-green-400 uppercase tracking-wider mb-1\">Result</h4>\n <div className=\"bg-green-500/10 border border-green-500/20 rounded p-3 overflow-x-auto\">\n <pre className=\"text-sm text-green-400 whitespace-pre-wrap break-words\">\n {typeof task.result === \"string\" ? task.result : JSON.stringify(task.result, null, 2)}\n </pre>\n </div>\n </div>\n )}\n\n {/* Trajectory */}\n {loading && !task.trajectory && (\n <div>\n <h4 className=\"text-xs text-[#666] uppercase tracking-wider mb-2\">Trajectory</h4>\n <div className=\"text-sm text-[#555]\">Loading trajectory...</div>\n </div>\n )}\n {task.trajectory && task.trajectory.length > 0 && (\n <div>\n <h4 className=\"text-xs text-[#666] uppercase tracking-wider mb-2\">\n Trajectory ({task.trajectory.length} steps)\n </h4>\n <TrajectoryView trajectory={task.trajectory} />\n </div>\n )}\n </div>\n </div>\n );\n}\n\nexport function TrajectoryView({ trajectory }: { trajectory: TaskTrajectoryStep[] }) {\n const [expanded, setExpanded] = useState<Set<string>>(new Set());\n\n const toggleStep = (id: string) => {\n setExpanded(prev => {\n const next = new Set(prev);\n if (next.has(id)) {\n next.delete(id);\n } else {\n next.add(id);\n }\n return next;\n });\n };\n\n const roleStyles = {\n user: { bg: \"bg-blue-500/10\", text: \"text-blue-400\", icon: \"๐Ÿ‘ค\", label: \"User\" },\n assistant: { bg: \"bg-purple-500/10\", text: \"text-purple-400\", icon: \"๐Ÿค–\", label: \"Assistant\" },\n };\n\n // Render content which can be string or array of blocks\n const renderContent = (step: TaskTrajectoryStep) => {\n const content = step.content;\n\n // String content (text message)\n if (typeof content === \"string\") {\n const isLong = content.length > 200;\n const isExpanded = expanded.has(step.id);\n\n return (\n <div>\n <p className={`text-sm text-[#ccc] whitespace-pre-wrap break-words ${!isExpanded && isLong ? 'line-clamp-4' : ''}`}>\n {content}\n </p>\n {isLong && (\n <button\n onClick={() => toggleStep(step.id)}\n className=\"text-xs text-[#666] hover:text-[#888] mt-1\"\n >\n {isExpanded ? \"Show less\" : \"Show more...\"}\n </button>\n )}\n </div>\n );\n }\n\n // Array content (tool_use or tool_result blocks)\n return (\n <div className=\"space-y-2\">\n {content.map((block, idx) => {\n if (block.type === \"tool_use\") {\n const inputStr = JSON.stringify(block.input, null, 2);\n const isLong = inputStr.length > 150;\n const blockId = `${step.id}-${idx}`;\n const isExpanded = expanded.has(blockId);\n\n return (\n <div key={idx} className=\"bg-orange-500/10 border border-orange-500/20 rounded p-2\">\n <div className=\"flex items-center gap-2 mb-1\">\n <span className=\"text-orange-400\">๐Ÿ”ง</span>\n <span className=\"text-xs font-medium text-orange-400\">Tool Call</span>\n <span className=\"text-xs text-[#888]\">{block.name}</span>\n </div>\n <pre className={`text-xs text-[#888] overflow-x-auto ${!isExpanded && isLong ? 'line-clamp-3' : ''}`}>\n {inputStr}\n </pre>\n {isLong && (\n <button\n onClick={() => toggleStep(blockId)}\n className=\"text-xs text-[#666] hover:text-[#888] mt-1\"\n >\n {isExpanded ? \"Show less\" : \"Show more...\"}\n </button>\n )}\n </div>\n );\n }\n\n if (block.type === \"tool_result\") {\n const isError = block.is_error;\n const blockId = `${step.id}-${idx}`;\n const isExpanded = expanded.has(blockId);\n const isLong = block.content.length > 150;\n\n return (\n <div\n key={idx}\n className={`${isError ? 'bg-red-500/10 border-red-500/20' : 'bg-teal-500/10 border-teal-500/20'} border rounded p-2`}\n >\n <div className=\"flex items-center gap-2 mb-1\">\n <span>{isError ? \"โŒ\" : \"๐Ÿ“‹\"}</span>\n <span className={`text-xs font-medium ${isError ? 'text-red-400' : 'text-teal-400'}`}>\n Tool Result\n </span>\n </div>\n <pre className={`text-xs text-[#888] overflow-x-auto whitespace-pre-wrap break-words ${!isExpanded && isLong ? 'line-clamp-3' : ''}`}>\n {block.content}\n </pre>\n {isLong && (\n <button\n onClick={() => toggleStep(blockId)}\n className=\"text-xs text-[#666] hover:text-[#888] mt-1\"\n >\n {isExpanded ? \"Show less\" : \"Show more...\"}\n </button>\n )}\n </div>\n );\n }\n\n return null;\n })}\n </div>\n );\n };\n\n return (\n <div className=\"space-y-2\">\n {trajectory.map((step) => {\n const style = roleStyles[step.role] || roleStyles.assistant;\n\n return (\n <div\n key={step.id}\n className={`${style.bg} border border-[#1a1a1a] rounded overflow-hidden p-3`}\n >\n <div className=\"flex items-center gap-2 mb-2\">\n <span>{style.icon}</span>\n <span className={`text-xs font-medium ${style.text}`}>{style.label}</span>\n {step.model && (\n <span className=\"text-xs text-[#555]\">ยท {step.model}</span>\n )}\n <span className=\"text-xs text-[#555]\">\n ยท {new Date(step.created_at).toLocaleTimeString()}\n </span>\n </div>\n {renderContent(step)}\n </div>\n );\n })}\n </div>\n );\n}\n\n// --- Schedule formatting helpers ---\n\nconst DAY_NAMES = [\"Sun\", \"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\"];\n\nexport function formatCron(cron: string): string {\n try {\n const parts = cron.trim().split(/\\s+/);\n if (parts.length !== 5) return cron;\n const [minute, hour, dayOfMonth, month, dayOfWeek] = parts;\n\n // Every N minutes: */N * * * *\n if (minute.startsWith(\"*/\") && hour === \"*\" && dayOfMonth === \"*\" && month === \"*\" && dayOfWeek === \"*\") {\n const n = parseInt(minute.slice(2));\n if (n === 1) return \"Every minute\";\n return `Every ${n} minutes`;\n }\n\n // Every hour: 0 * * * *\n if (minute !== \"*\" && !minute.includes(\"/\") && hour === \"*\" && dayOfMonth === \"*\" && month === \"*\" && dayOfWeek === \"*\") {\n return \"Every hour\";\n }\n\n // Every N hours: 0 */N * * *\n if (hour.startsWith(\"*/\") && dayOfMonth === \"*\" && month === \"*\" && dayOfWeek === \"*\") {\n const n = parseInt(hour.slice(2));\n if (n === 1) return \"Every hour\";\n return `Every ${n} hours`;\n }\n\n const formatTime = (h: string, m: string): string => {\n const hr = parseInt(h);\n const mn = parseInt(m);\n if (isNaN(hr)) return \"\";\n const ampm = hr >= 12 ? \"PM\" : \"AM\";\n const h12 = hr === 0 ? 12 : hr > 12 ? hr - 12 : hr;\n return `${h12}:${mn.toString().padStart(2, \"0\")} ${ampm}`;\n };\n\n if (hour !== \"*\" && !hour.includes(\"/\") && dayOfMonth === \"*\" && month === \"*\") {\n const timeStr = formatTime(hour, minute);\n\n if (dayOfWeek === \"*\") return `Daily at ${timeStr}`;\n\n const days = dayOfWeek.split(\",\").map(d => {\n const num = parseInt(d.trim());\n return DAY_NAMES[num] || d;\n });\n\n if (days.length === 7) return `Daily at ${timeStr}`;\n if (days.length === 5 && !days.includes(\"Sat\") && !days.includes(\"Sun\")) {\n return `Weekdays at ${timeStr}`;\n }\n if (days.length === 1) return `Weekly on ${days[0]} at ${timeStr}`;\n return `${days.join(\" & \")} at ${timeStr}`;\n }\n\n return cron;\n } catch {\n return cron;\n }\n}\n\nexport function formatRelativeTime(dateStr: string): string {\n const date = new Date(dateStr);\n const now = new Date();\n const diffMs = date.getTime() - now.getTime();\n const absDiffMs = Math.abs(diffMs);\n const isFuture = diffMs > 0;\n\n const minutes = Math.floor(absDiffMs / 60000);\n const hours = Math.floor(absDiffMs / 3600000);\n const days = Math.floor(absDiffMs / 86400000);\n\n const timeStr = date.toLocaleTimeString([], { hour: \"numeric\", minute: \"2-digit\" });\n\n const isToday = date.toDateString() === now.toDateString();\n const tomorrow = new Date(now);\n tomorrow.setDate(tomorrow.getDate() + 1);\n const isTomorrow = date.toDateString() === tomorrow.toDateString();\n const yesterday = new Date(now);\n yesterday.setDate(yesterday.getDate() - 1);\n const isYesterday = date.toDateString() === yesterday.toDateString();\n\n if (isToday) {\n if (minutes < 1) return isFuture ? \"now\" : \"just now\";\n if (minutes < 60) return isFuture ? `in ${minutes} min (${timeStr})` : `${minutes} min ago`;\n return isFuture ? `in ${hours}h (${timeStr})` : `${hours}h ago`;\n }\n\n if (isTomorrow) return `Tomorrow at ${timeStr}`;\n if (isYesterday) return `Yesterday at ${timeStr}`;\n\n if (days < 7) {\n const dayName = DAY_NAMES[date.getDay()];\n return `${dayName} at ${timeStr}`;\n }\n\n return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IAAI,KAAK,CAAG,EAC7B,EAAS,QAAQ,EAAS,QAAQ,EAAI,CAAC,EACvC,IAAM,EAAa,EAAK,aAAa,IAAM,EAAS,aAAa,EAC3D,EAAY,IAAI,KAAK,CAAG,EAC9B,EAAU,QAAQ,EAAU,QAAQ,EAAI,CAAC,EACzC,IAAM,EAAc,EAAK,aAAa,IAAM,EAAU,aAAa,EAEnE,GAAI,EAAS,CACX,GAAI,EAAU,EAAG,OAAO,EAAW,MAAQ,WAC3C,GAAI,EAAU,GAAI,OAAO,EAAW,MAAM,UAAgB,KAAa,GAAG,YAC1E,OAAO,EAAW,MAAM,OAAW,KAAa,GAAG,SAGrD,GAAI,EAAY,MAAO,eAAe,IACtC,GAAI,EAAa,MAAO,gBAAgB,IAExC,GAAI,EAAO,EAET,MAAO,GADS,EAAU,EAAK,OAAO,SACd,IAG1B,OAAO,EAAK,mBAAmB,CAAC,EAAG,CAAE,MAAO,QAAS,IAAK,SAAU,CAAC,EAAI,OAAO",
8
+ "debugId": "FC665D53F976429364756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,4 @@
1
+ import{S as L,V as P,W as N}from"./App.mvtqv6qc.js";var z=L(P(),1),w=L(N(),1);function U({children:q,onClose:y}){return w.jsxDEV("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:w.jsxDEV("div",{className:"bg-[#111] rounded p-6 w-full max-w-xl lg:max-w-2xl border border-[#1a1a1a] max-h-[90vh] overflow-y-auto",children:q},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function Q({title:q,message:y,confirmText:F="Confirm",cancelText:B="Cancel",confirmVariant:G="danger",onConfirm:I,onCancel:J}){return w.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:w.jsxDEV("div",{className:"bg-[#111] border border-[#333] rounded-lg p-6 w-full max-w-sm",children:[q&&w.jsxDEV("h3",{className:"font-medium mb-2",children:q},void 0,!1,void 0,this),w.jsxDEV("p",{className:"text-sm text-[#ccc] mb-4",children:y},void 0,!1,void 0,this),w.jsxDEV("div",{className:"flex gap-2",children:[w.jsxDEV("button",{onClick:J,className:"flex-1 text-sm bg-[#1a1a1a] hover:bg-[#222] border border-[#333] px-4 py-2 rounded transition",children:B},void 0,!1,void 0,this),w.jsxDEV("button",{onClick:I,className:`flex-1 text-sm text-white px-4 py-2 rounded transition ${G==="danger"?"bg-red-500 hover:bg-red-600":"bg-[#f97316] hover:bg-[#ea580c]"}`,children:F},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function R({title:q,message:y,buttonText:F="OK",variant:B="info",onClose:G}){let I={error:"bg-red-500/20 text-red-400",success:"bg-green-500/20 text-green-400",info:"bg-blue-500/20 text-blue-400"},J={error:"โœ•",success:"โœ“",info:"โ„น"};return w.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:w.jsxDEV("div",{className:"bg-[#111] border border-[#333] rounded-lg p-6 w-full max-w-sm text-center",children:[w.jsxDEV("div",{className:`w-12 h-12 rounded-full flex items-center justify-center mx-auto mb-3 ${I[B]}`,children:w.jsxDEV("span",{className:"text-xl",children:J[B]},void 0,!1,void 0,this)},void 0,!1,void 0,this),q&&w.jsxDEV("h3",{className:"font-medium mb-2",children:q},void 0,!1,void 0,this),w.jsxDEV("p",{className:"text-sm text-[#ccc] mb-4",children:y},void 0,!1,void 0,this),w.jsxDEV("button",{onClick:G,className:"w-full text-sm bg-[#1a1a1a] hover:bg-[#222] border border-[#333] px-4 py-2 rounded transition",children:F},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function W(){let[q,y]=z.useState(null),F=z.useCallback((J,K={})=>{return new Promise((O)=>{y({message:J,options:K,resolve:O})})},[]),B=z.useCallback(()=>{q?.resolve(!0),y(null)},[q]),G=z.useCallback(()=>{q?.resolve(!1),y(null)},[q]),I=q?w.jsxDEV(Q,{title:q.options.title,message:q.message,confirmText:q.options.confirmText,cancelText:q.options.cancelText,confirmVariant:q.options.confirmVariant,onConfirm:B,onCancel:G},void 0,!1,void 0,this):null;return{confirm:F,ConfirmDialog:I}}function X(){let[q,y]=z.useState(null),F=z.useCallback((I,J={})=>{return new Promise((K)=>{y({message:I,options:J,resolve:K})})},[]),B=z.useCallback(()=>{q?.resolve(),y(null)},[q]),G=q?w.jsxDEV(R,{title:q.options.title,message:q.message,buttonText:q.options.buttonText,variant:q.options.variant,onClose:B},void 0,!1,void 0,this):null;return{alert:F,AlertDialog:G}}
2
+ export{U as N,W as O,X as P};
3
+
4
+ //# debugId=4155431C35BEBAD964756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/web/components/common/Modal.tsx"],
4
+ "sourcesContent": [
5
+ "import React from \"react\";\n\ninterface ModalProps {\n children: React.ReactNode;\n onClose?: () => void;\n}\n\nexport function Modal({ children, onClose }: ModalProps) {\n return (\n <div className=\"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4\">\n <div className=\"bg-[#111] rounded p-6 w-full max-w-xl lg:max-w-2xl border border-[#1a1a1a] max-h-[90vh] overflow-y-auto\">\n {children}\n </div>\n </div>\n );\n}\n\n// Confirmation Modal - replaces browser confirm()\ninterface ConfirmModalProps {\n title?: string;\n message: string;\n confirmText?: string;\n cancelText?: string;\n confirmVariant?: \"danger\" | \"primary\";\n onConfirm: () => void;\n onCancel: () => void;\n}\n\nexport function ConfirmModal({\n title,\n message,\n confirmText = \"Confirm\",\n cancelText = \"Cancel\",\n confirmVariant = \"danger\",\n onConfirm,\n onCancel,\n}: ConfirmModalProps) {\n return (\n <div className=\"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4\">\n <div className=\"bg-[#111] border border-[#333] rounded-lg p-6 w-full max-w-sm\">\n {title && <h3 className=\"font-medium mb-2\">{title}</h3>}\n <p className=\"text-sm text-[#ccc] mb-4\">{message}</p>\n <div className=\"flex gap-2\">\n <button\n onClick={onCancel}\n className=\"flex-1 text-sm bg-[#1a1a1a] hover:bg-[#222] border border-[#333] px-4 py-2 rounded transition\"\n >\n {cancelText}\n </button>\n <button\n onClick={onConfirm}\n className={`flex-1 text-sm text-white px-4 py-2 rounded transition ${\n confirmVariant === \"danger\"\n ? \"bg-red-500 hover:bg-red-600\"\n : \"bg-[#f97316] hover:bg-[#ea580c]\"\n }`}\n >\n {confirmText}\n </button>\n </div>\n </div>\n </div>\n );\n}\n\n// Alert Modal - replaces browser alert()\ninterface AlertModalProps {\n title?: string;\n message: string;\n buttonText?: string;\n variant?: \"error\" | \"success\" | \"info\";\n onClose: () => void;\n}\n\nexport function AlertModal({\n title,\n message,\n buttonText = \"OK\",\n variant = \"info\",\n onClose,\n}: AlertModalProps) {\n const iconColors = {\n error: \"bg-red-500/20 text-red-400\",\n success: \"bg-green-500/20 text-green-400\",\n info: \"bg-blue-500/20 text-blue-400\",\n };\n\n const icons = {\n error: \"โœ•\",\n success: \"โœ“\",\n info: \"โ„น\",\n };\n\n return (\n <div className=\"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4\">\n <div className=\"bg-[#111] border border-[#333] rounded-lg p-6 w-full max-w-sm text-center\">\n <div\n className={`w-12 h-12 rounded-full flex items-center justify-center mx-auto mb-3 ${iconColors[variant]}`}\n >\n <span className=\"text-xl\">{icons[variant]}</span>\n </div>\n {title && <h3 className=\"font-medium mb-2\">{title}</h3>}\n <p className=\"text-sm text-[#ccc] mb-4\">{message}</p>\n <button\n onClick={onClose}\n className=\"w-full text-sm bg-[#1a1a1a] hover:bg-[#222] border border-[#333] px-4 py-2 rounded transition\"\n >\n {buttonText}\n </button>\n </div>\n </div>\n );\n}\n\n// Hook for using confirmation dialogs\nimport { useState, useCallback } from \"react\";\n\ninterface UseConfirmOptions {\n title?: string;\n confirmText?: string;\n cancelText?: string;\n confirmVariant?: \"danger\" | \"primary\";\n}\n\nexport function useConfirm() {\n const [state, setState] = useState<{\n message: string;\n options: UseConfirmOptions;\n resolve: (value: boolean) => void;\n } | null>(null);\n\n const confirm = useCallback((message: string, options: UseConfirmOptions = {}) => {\n return new Promise<boolean>((resolve) => {\n setState({ message, options, resolve });\n });\n }, []);\n\n const handleConfirm = useCallback(() => {\n state?.resolve(true);\n setState(null);\n }, [state]);\n\n const handleCancel = useCallback(() => {\n state?.resolve(false);\n setState(null);\n }, [state]);\n\n const ConfirmDialog = state ? (\n <ConfirmModal\n title={state.options.title}\n message={state.message}\n confirmText={state.options.confirmText}\n cancelText={state.options.cancelText}\n confirmVariant={state.options.confirmVariant}\n onConfirm={handleConfirm}\n onCancel={handleCancel}\n />\n ) : null;\n\n return { confirm, ConfirmDialog };\n}\n\n// Hook for using alert dialogs\ninterface UseAlertOptions {\n title?: string;\n buttonText?: string;\n variant?: \"error\" | \"success\" | \"info\";\n}\n\nexport function useAlert() {\n const [state, setState] = useState<{\n message: string;\n options: UseAlertOptions;\n resolve: () => void;\n } | null>(null);\n\n const alert = useCallback((message: string, options: UseAlertOptions = {}) => {\n return new Promise<void>((resolve) => {\n setState({ message, options, resolve });\n });\n }, []);\n\n const handleClose = useCallback(() => {\n state?.resolve();\n setState(null);\n }, [state]);\n\n const AlertDialog = state ? (\n <AlertModal\n title={state.options.title}\n message={state.message}\n buttonText={state.options.buttonText}\n variant={state.options.variant}\n onClose={handleClose}\n />\n ) : null;\n\n return { alert, AlertDialog };\n}\n"
6
+ ],
7
+ "mappings": "oDAmHA,0BA5GO,SAAS,CAAK,EAAG,WAAU,WAAuB,CACvD,OACE,SAIE,MAJF,CAAK,UAAU,sEAAf,SACE,SAEE,MAFF,CAAK,UAAU,0GAAf,SACG,GADH,qBAEE,GAHJ,qBAIE,EAeC,SAAS,CAAY,EAC1B,QACA,UACA,cAAc,UACd,aAAa,SACb,iBAAiB,SACjB,YACA,YACoB,CACpB,OACE,SAuBE,MAvBF,CAAK,UAAU,sEAAf,SACE,SAqBE,MArBF,CAAK,UAAU,gEAAf,SAqBE,CApBC,GAAS,SAA0C,KAA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EAAI,EACnB,EAAS,IAAI,GACZ,CAAC,CAAK,CAAC,EAEJ,EAAe,cAAY,IAAM,CACrC,GAAO,QAAQ,EAAK,EACpB,EAAS,IAAI,GACZ,CAAC,CAAK,CAAC,EAEJ,EAAgB,EACpB,SAAC,EAAD,CACE,MAAO,EAAM,QAAQ,MACrB,QAAS,EAAM,QACf,YAAa,EAAM,QAAQ,YAC3B,WAAY,EAAM,QAAQ,WAC1B,eAAgB,EAAM,QAAQ,eAC9B,UAAW,EACX,SAAU,GAPZ,qBAQA,EACE,KAEJ,MAAO,CAAE,UAAS,eAAc,EAU3B,SAAS,CAAQ,EAAG,CACzB,IAAO,EAAO,GAAY,WAIhB,IAAI,EAER,EAAQ,cAAY,CAAC,EAAiB,EAA2B,CAAC,IAAM,CAC5E,OAAO,IAAI,QAAc,CAAC,IAAY,CACpC,EAAS,CAAE,UAAS,UAAS,SAAQ,CAAC,EACvC,GACA,CAAC,CAAC,EAEC,EAAc,cAAY,IAAM,CACpC,GAAO,QAAQ,EACf,EAAS,IAAI,GACZ,CAAC,CAAK,CAAC,EAEJ,EAAc,EAClB,SAAC,EAAD,CACE,MAAO,EAAM,QAAQ,MACrB,QAAS,EAAM,QACf,WAAY,EAAM,QAAQ,WAC1B,QAAS,EAAM,QAAQ,QACvB,QAAS,GALX,qBAMA,EACE,KAEJ,MAAO,CAAE,QAAO,aAAY",
8
+ "debugId": "4155431C35BEBAD964756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,4 @@
1
+ import{k as r}from"./App.ensa6z0r.js";import{u as Oz}from"./App.ncgc9cxy.js";import{O as Jz,P as o}from"./App.yv87t9m5.js";import{R as t}from"./App.p0fb1pds.js";import{S as a,V as Qz,W as zz,ca as c,fa as Gz}from"./App.mvtqv6qc.js";var J=a(Qz(),1);var z=a(zz(),1);function Mz(){let{authFetch:G}=c(),{projects:$,currentProjectId:H}=Gz(),[K,w]=J.useState([]),[W,B]=J.useState(!0),[q,F]=J.useState(!1),[U,T]=J.useState(null),[M,L]=J.useState(null),[Q,k]=J.useState("servers"),{confirm:y,ConfirmDialog:f}=Jz(),X=$.length>0,A=async()=>{try{let b=await(await G("/api/mcp/servers")).json();w(b.servers||[])}catch(Z){console.error("Failed to fetch MCP servers:",Z)}B(!1)};J.useEffect(()=>{A()},[G]);let Y=K.filter((Z)=>{if(!H)return!0;if(H==="unassigned")return Z.project_id===null;return Z.project_id===null||Z.project_id===H}),S=async(Z)=>{try{await G(`/api/mcp/servers/${Z}/start`,{method:"POST"}),A()}catch(b){console.error("Failed to start server:",b)}},I=async(Z)=>{try{await G(`/api/mcp/servers/${Z}/stop`,{method:"POST"}),A()}catch(b){console.error("Failed to stop server:",b)}},p=async(Z)=>{if(!await y("Delete this MCP server?",{confirmText:"Delete",title:"Delete Server"}))return;try{if(await G(`/api/mcp/servers/${Z}`,{method:"DELETE"}),M?.id===Z)L(null);A()}catch(C){console.error("Failed to delete server:",C)}},u=async(Z,b)=>{try{await G(`/api/mcp/servers/${Z}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b})}),A()}catch(C){console.error("Failed to rename server:",C)}},i=async(Z,b)=>{try{await G(`/api/mcp/servers/${Z}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),A()}catch(C){throw console.error("Failed to update server:",C),C}};return z.jsxDEV(z.Fragment,{children:[f,z.jsxDEV("div",{className:"flex-1 overflow-auto p-6",children:[z.jsxDEV("div",{className:"max-w-6xl",children:[z.jsxDEV("div",{className:"flex items-center justify-between mb-6",children:[z.jsxDEV("div",{children:[z.jsxDEV("h1",{className:"text-2xl font-semibold mb-1",children:"MCP Servers"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-[#666]",children:"Manage Model Context Protocol servers for tool integrations."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Q==="servers"&&z.jsxDEV("button",{onClick:()=>F(!0),className:"bg-[#f97316] hover:bg-[#fb923c] text-black px-4 py-2 rounded font-medium transition",children:"+ Add Server"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex gap-1 mb-6 bg-[#111] border border-[#1a1a1a] rounded-lg p-1 w-fit",children:[z.jsxDEV("button",{onClick:()=>k("servers"),className:`px-4 py-2 rounded text-sm font-medium transition ${Q==="servers"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"My Servers"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>k("hosted"),className:`px-4 py-2 rounded text-sm font-medium transition ${Q==="hosted"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"Hosted Services"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>k("registry"),className:`px-4 py-2 rounded text-sm font-medium transition ${Q==="registry"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"Browse Registry"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Q==="servers"&&z.jsxDEV(z.Fragment,{children:[W&&z.jsxDEV("div",{className:"text-center py-8 text-[#666]",children:"Loading..."},void 0,!1,void 0,this),!W&&Y.length===0&&K.length===0&&z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-8 text-center",children:[z.jsxDEV(Oz,{className:"w-12 h-12 text-[#333] mx-auto mb-4"},void 0,!1,void 0,this),z.jsxDEV("h3",{className:"text-lg font-medium mb-2",children:"No MCP servers configured"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-[#666] mb-6 max-w-md mx-auto",children:"MCP servers extend your agents with tools like file access, web browsing, database connections, and more."},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex gap-3 justify-center",children:[z.jsxDEV("button",{onClick:()=>F(!0),className:"bg-[#f97316] hover:bg-[#fb923c] text-black px-4 py-2 rounded font-medium transition",children:"Add Manually"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>k("registry"),className:"border border-[#333] hover:border-[#666] px-4 py-2 rounded font-medium transition",children:"Browse Registry"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),!W&&Y.length===0&&K.length>0&&z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-6 text-center",children:z.jsxDEV("p",{className:"text-[#666]",children:"No servers match this filter."},void 0,!1,void 0,this)},void 0,!1,void 0,this),!W&&Y.length>0&&z.jsxDEV("div",{className:"flex gap-6",children:[z.jsxDEV("div",{className:`space-y-3 ${M?"w-1/2":"w-full"}`,children:Y.map((Z)=>{let C=Z.type==="http"&&Z.url||Z.status==="running",h=X&&Z.project_id?$.find((j)=>j.id===Z.project_id):null;return z.jsxDEV(Wz,{server:Z,project:h,selected:M?.id===Z.id,onSelect:()=>L(C?Z:null),onStart:()=>S(Z.id),onStop:()=>I(Z.id),onDelete:()=>p(Z.id),onEdit:()=>T(Z)},Z.id,!1,void 0,this)})},void 0,!1,void 0,this),M&&z.jsxDEV("div",{className:"w-1/2",children:z.jsxDEV(Xz,{server:M,onClose:()=>L(null)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Q==="hosted"&&z.jsxDEV(_z,{onServerAdded:A,projectId:H},void 0,!1,void 0,this),Q==="registry"&&z.jsxDEV(Zz,{onInstall:(Z)=>{A(),k("servers")}},void 0,!1,void 0,this),Q==="servers"&&z.jsxDEV("div",{className:"mt-8 p-4 bg-[#111] border border-[#1a1a1a] rounded-lg",children:[z.jsxDEV("h3",{className:"font-medium mb-2",children:"Quick Start"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-sm text-[#666] mb-3",children:"Add an MCP server by providing its npm package name. For example:"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex flex-wrap gap-2",children:[{name:"filesystem",pkg:"@modelcontextprotocol/server-filesystem"},{name:"fetch",pkg:"@modelcontextprotocol/server-fetch"},{name:"memory",pkg:"@modelcontextprotocol/server-memory"}].map((Z)=>z.jsxDEV("code",{className:"text-xs bg-[#0a0a0a] px-2 py-1 rounded",children:Z.pkg},Z.name,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q&&z.jsxDEV(Bz,{onClose:()=>F(!1),onAdded:()=>{F(!1),A()},projects:X?$:void 0,defaultProjectId:H&&H!=="unassigned"?H:null},void 0,!1,void 0,this),U&&z.jsxDEV(Uz,{server:U,projects:X?$:void 0,onClose:()=>T(null),onSaved:()=>{T(null),A()}},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Wz({server:G,project:$,selected:H,onSelect:K,onStart:w,onStop:W,onDelete:B,onEdit:q}){let F=G.type==="http"&&G.url,U=F||G.status==="running",T=()=>{if(F)return`${G.source||"remote"} โ€ข http`;return`${G.type} โ€ข ${G.package||G.command||"custom"}${G.status==="running"&&G.port?` โ€ข :${G.port}`:""}`},M=()=>{if($)return z.jsxDEV("span",{className:"text-xs px-1.5 py-0.5 rounded",style:{backgroundColor:`${$.color}20`,color:$.color},children:$.name},void 0,!1,void 0,this);if(G.project_id===null)return z.jsxDEV("span",{className:"text-xs text-[#666] bg-[#1a1a1a] px-1.5 py-0.5 rounded",children:"Global"},void 0,!1,void 0,this);return null};return z.jsxDEV("div",{className:`bg-[#111] border rounded-lg p-4 cursor-pointer transition ${H?"border-[#f97316]":"border-[#1a1a1a] hover:border-[#333]"}`,onClick:U?K:void 0,children:z.jsxDEV("div",{className:"flex items-center justify-between",children:[z.jsxDEV("div",{className:"flex items-center gap-3",children:[z.jsxDEV("div",{className:`w-2 h-2 rounded-full ${U?"bg-green-400":"bg-[#444]"}`},void 0,!1,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("div",{className:"flex items-center gap-2",children:[z.jsxDEV("h3",{className:"font-medium",children:G.name},void 0,!1,void 0,this),M()]},void 0,!0,void 0,this),z.jsxDEV("p",{className:"text-sm text-[#666]",children:T()},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex items-center gap-2",children:[z.jsxDEV("button",{onClick:(L)=>{L.stopPropagation(),q()},className:"text-sm text-[#666] hover:text-[#888] px-3 py-1 transition",title:"Edit server settings",children:"Edit"},void 0,!1,void 0,this),F?z.jsxDEV("button",{onClick:(L)=>{L.stopPropagation(),B()},className:"text-sm text-[#666] hover:text-red-400 px-3 py-1 transition",children:"Remove"},void 0,!1,void 0,this):G.status==="running"?z.jsxDEV(z.Fragment,{children:[z.jsxDEV("button",{onClick:(L)=>{L.stopPropagation(),K()},className:"text-sm text-[#f97316] hover:text-[#fb923c] px-3 py-1 transition",children:"Tools"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:(L)=>{L.stopPropagation(),W()},className:"text-sm text-[#666] hover:text-red-400 px-3 py-1 transition",children:"Stop"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:(L)=>{L.stopPropagation(),B()},className:"text-sm text-[#666] hover:text-red-400 px-3 py-1 transition",children:"Delete"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):z.jsxDEV(z.Fragment,{children:[z.jsxDEV("button",{onClick:(L)=>{L.stopPropagation(),w()},className:"text-sm text-[#666] hover:text-green-400 px-3 py-1 transition",children:"Start"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:(L)=>{L.stopPropagation(),B()},className:"text-sm text-[#666] hover:text-red-400 px-3 py-1 transition",children:"Delete"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function Xz({server:G,onClose:$}){let{authFetch:H}=c(),[K,w]=J.useState([]),[W,B]=J.useState(null),[q,F]=J.useState(!0),[U,T]=J.useState(null),[M,L]=J.useState(null);return J.useEffect(()=>{(async()=>{F(!0),T(null);try{let k=await H(`/api/mcp/servers/${G.id}/tools`),y=await k.json();if(!k.ok){T(y.error||"Failed to fetch tools");return}w(y.tools||[]),B(y.serverInfo||null)}catch(k){T(`Failed to fetch tools: ${k}`)}finally{F(!1)}})()},[G.id,H]),z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg overflow-hidden",children:[z.jsxDEV("div",{className:"p-4 border-b border-[#1a1a1a] flex items-center justify-between",children:[z.jsxDEV("div",{children:[z.jsxDEV("h3",{className:"font-medium",children:[G.name," Tools"]},void 0,!0,void 0,this),W&&z.jsxDEV("p",{className:"text-xs text-[#666]",children:[W.name," v",W.version]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("button",{onClick:$,className:"text-[#666] hover:text-[#888] text-xl leading-none",children:"ร—"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"p-4 max-h-[500px] overflow-auto",children:[q&&z.jsxDEV("p",{className:"text-[#666]",children:"Loading tools..."},void 0,!1,void 0,this),U&&z.jsxDEV("div",{className:"text-red-400 text-sm p-3 bg-red-500/10 rounded",children:U},void 0,!1,void 0,this),!q&&!U&&K.length===0&&z.jsxDEV("p",{className:"text-[#666]",children:"No tools available from this server."},void 0,!1,void 0,this),!q&&!U&&K.length>0&&!M&&z.jsxDEV("div",{className:"space-y-2",children:K.map((Q)=>z.jsxDEV("button",{onClick:()=>L(Q),className:"w-full text-left p-3 bg-[#0a0a0a] hover:bg-[#1a1a1a] border border-[#222] hover:border-[#333] rounded transition",children:[z.jsxDEV("div",{className:"font-medium text-sm",children:Q.name},void 0,!1,void 0,this),Q.description&&z.jsxDEV("div",{className:"text-xs text-[#666] mt-1",children:Q.description},void 0,!1,void 0,this)]},Q.name,!0,void 0,this))},void 0,!1,void 0,this),M&&z.jsxDEV(Yz,{serverId:G.id,tool:M,onBack:()=>L(null)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Yz({serverId:G,tool:$,onBack:H}){let{authFetch:K}=c(),[w,W]=J.useState("{}"),[B,q]=J.useState(null),[F,U]=J.useState(null),[T,M]=J.useState(!1);J.useEffect(()=>{let Q=$.inputSchema;if(Q&&typeof Q==="object"&&"properties"in Q){let k=Q.properties,y={};for(let[f,X]of Object.entries(k))if(X.default!==void 0)y[f]=X.default;else if(X.type==="string")y[f]="";else if(X.type==="number"||X.type==="integer")y[f]=0;else if(X.type==="boolean")y[f]=!1;else if(X.type==="array")y[f]=[];else if(X.type==="object")y[f]={};W(JSON.stringify(y,null,2))}},[$]);let L=async()=>{M(!0),U(null),q(null);try{let Q=JSON.parse(w),k=await K(`/api/mcp/servers/${G}/tools/${encodeURIComponent($.name)}/call`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({arguments:Q})}),y=await k.json();if(!k.ok){U(y.error||"Failed to call tool");return}q(y.result)}catch(Q){U(`Error: ${Q}`)}finally{M(!1)}};return z.jsxDEV("div",{className:"space-y-4",children:[z.jsxDEV("div",{className:"flex items-center gap-2",children:[z.jsxDEV("button",{onClick:H,className:"text-[#666] hover:text-[#888] text-sm",children:"โ† Back"},void 0,!1,void 0,this),z.jsxDEV("span",{className:"text-[#444]",children:"/"},void 0,!1,void 0,this),z.jsxDEV("span",{className:"font-medium",children:$.name},void 0,!1,void 0,this)]},void 0,!0,void 0,this),$.description&&z.jsxDEV("p",{className:"text-sm text-[#666]",children:$.description},void 0,!1,void 0,this),$.inputSchema&&z.jsxDEV("div",{className:"text-xs",children:z.jsxDEV("details",{className:"cursor-pointer",children:[z.jsxDEV("summary",{className:"text-[#666] hover:text-[#888]",children:"Input Schema"},void 0,!1,void 0,this),z.jsxDEV("pre",{className:"mt-2 p-2 bg-[#0a0a0a] rounded text-[#888] overflow-auto max-h-32",children:JSON.stringify($.inputSchema,null,2)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Arguments (JSON)"},void 0,!1,void 0,this),z.jsxDEV("textarea",{value:w,onChange:(Q)=>W(Q.target.value),className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 h-32 font-mono text-sm focus:outline-none focus:border-[#f97316] resize-none",placeholder:"{}"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("button",{onClick:L,disabled:T,className:"w-full bg-[#f97316] hover:bg-[#fb923c] disabled:opacity-50 text-black px-4 py-2 rounded font-medium transition",children:T?"Calling...":"Call Tool"},void 0,!1,void 0,this),F&&z.jsxDEV("div",{className:"text-red-400 text-sm p-3 bg-red-500/10 rounded",children:F},void 0,!1,void 0,this),B&&z.jsxDEV("div",{className:"space-y-2",children:[z.jsxDEV("div",{className:"text-sm text-[#666]",children:["Result ",B.isError&&z.jsxDEV("span",{className:"text-red-400",children:"(error)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:`p-3 rounded text-sm ${B.isError?"bg-red-500/10":"bg-green-500/10"}`,children:B.content.map((Q,k)=>z.jsxDEV("div",{className:"mb-2 last:mb-0",children:[Q.type==="text"&&z.jsxDEV("pre",{className:"whitespace-pre-wrap font-mono text-xs",children:Q.text},void 0,!1,void 0,this),Q.type==="image"&&Q.data&&z.jsxDEV("img",{src:`data:${Q.mimeType||"image/png"};base64,${Q.data}`,alt:"Tool result",className:"max-w-full rounded"},void 0,!1,void 0,this)]},k,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Zz({onInstall:G}){let{authFetch:$}=c(),[H,K]=J.useState(""),[w,W]=J.useState([]),[B,q]=J.useState(!1),[F,U]=J.useState(!1),[T,M]=J.useState(null),[L,Q]=J.useState(null),k=async(X)=>{q(!0),Q(null);try{let A=await $(`/api/mcp/registry?search=${encodeURIComponent(X)}&limit=20`),Y=await A.json();if(!A.ok)Q(Y.error||"Failed to search registry"),W([]);else W(Y.servers||[])}catch(A){Q(`Failed to search: ${A}`),W([])}finally{q(!1),U(!0)}},y=(X)=>{if(X.preventDefault(),H.trim())k(H.trim())};J.useEffect(()=>{k("")},[]);let f=async(X)=>{if(!X.npmPackage){Q("This server does not have an npm package");return}M(X.id),Q(null);try{let A=await $("/api/mcp/servers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:X.name,type:"npm",package:X.npmPackage})});if(!A.ok){let Y=await A.json();Q(Y.error||"Failed to add server");return}G(X)}catch(A){Q(`Failed to add server: ${A}`)}finally{M(null)}};return z.jsxDEV("div",{className:"space-y-6",children:[z.jsxDEV("form",{onSubmit:y,className:"flex gap-2",children:[z.jsxDEV("input",{type:"text",value:H,onChange:(X)=>K(X.target.value),placeholder:"Search MCP servers (e.g., filesystem, github, slack...)",className:"flex-1 bg-[#111] border border-[#333] rounded-lg px-4 py-3 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("button",{type:"submit",disabled:B,className:"bg-[#f97316] hover:bg-[#fb923c] disabled:opacity-50 text-black px-6 py-3 rounded-lg font-medium transition",children:B?"...":"Search"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),L&&z.jsxDEV("div",{className:"text-red-400 text-sm p-3 bg-red-500/10 border border-red-500/20 rounded-lg",children:L},void 0,!1,void 0,this),!B&&F&&w.length===0&&z.jsxDEV("div",{className:"text-center py-8 text-[#666]",children:"No servers found. Try a different search term."},void 0,!1,void 0,this),w.length>0&&z.jsxDEV("div",{className:"grid gap-4 md:grid-cols-2",children:w.map((X)=>z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4 hover:border-[#333] transition",children:z.jsxDEV("div",{className:"flex items-start justify-between gap-3",children:[z.jsxDEV("div",{className:"flex-1 min-w-0",children:[z.jsxDEV("h3",{className:"font-medium truncate",children:X.name},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-sm text-[#666] mt-1 line-clamp-2",children:X.description||"No description"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex items-center gap-2 mt-2 text-xs text-[#555]",children:[X.version&&z.jsxDEV("span",{children:["v",X.version]},void 0,!0,void 0,this),z.jsxDEV("span",{className:`px-1.5 py-0.5 rounded ${X.npmPackage?"bg-green-500/10 text-green-400":"bg-blue-500/10 text-blue-400"}`,children:X.npmPackage?"npm":"remote"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("code",{className:"text-xs text-[#555] bg-[#0a0a0a] px-2 py-0.5 rounded mt-2 inline-block truncate max-w-full",children:X.npmPackage||X.fullName},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex-shrink-0",children:X.npmPackage?z.jsxDEV("button",{onClick:()=>f(X),disabled:T===X.id,className:"text-sm bg-[#1a1a1a] hover:bg-[#222] border border-[#333] hover:border-[#f97316] px-3 py-1.5 rounded transition disabled:opacity-50",children:T===X.id?"Adding...":"Add"},void 0,!1,void 0,this):X.repository?z.jsxDEV("a",{href:X.repository,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[#666] hover:text-[#f97316] transition",children:"View โ†’"},void 0,!1,void 0,this):null},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},X.id,!1,void 0,this))},void 0,!1,void 0,this),B&&z.jsxDEV("div",{className:"text-center py-8 text-[#666]",children:"Searching registry..."},void 0,!1,void 0,this),z.jsxDEV("div",{className:"p-4 bg-[#111] border border-[#1a1a1a] rounded-lg text-sm text-[#666]",children:z.jsxDEV("p",{children:["Servers are sourced from the"," ",z.jsxDEV("a",{href:"https://github.com/modelcontextprotocol/servers",target:"_blank",rel:"noopener noreferrer",className:"text-[#f97316] hover:underline",children:"official MCP registry"},void 0,!1,void 0,this),". Not all servers have npm packages - some require manual setup."]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function _z({onServerAdded:G,projectId:$}){let{authFetch:H}=c(),[K,w]=J.useState("composio"),[W,B]=J.useState("configs"),[q,F]=J.useState(!1),[U,T]=J.useState(!1),[M,L]=J.useState(!1),[Q,k]=J.useState([]),[y,f]=J.useState(new Set),[X,A]=J.useState(!0),[Y,S]=J.useState(!1),[I,p]=J.useState(null),{alert:u,AlertDialog:i}=o(),Z=async()=>{try{let P=$&&$!=="unassigned"?`/api/mcp/servers?project=${encodeURIComponent($)}`:"/api/mcp/servers",[D,_]=await Promise.all([H("/api/providers"),H(P)]),R=await D.json(),g=await _.json(),x=R.providers||[],O=g.servers||[],N=new Set(O.filter((E)=>E.source==="composio"&&E.url).map((E)=>{let e=E.url.match(/\/v3\/mcp\/([^/]+)/);return e?e[1]:null}).filter(Boolean));f(N);let m=x.find((E)=>E.id==="composio"),l=x.find((E)=>E.id==="smithery"),n=x.find((E)=>E.id==="agentdojo"),d=m?.hasKey||!1,v=l?.hasKey||!1,s=n?.hasKey||!1;if(F(d),T(v),L(s),d)w("composio"),b();else if(v)w("smithery");else if(s)w("agentdojo")}catch(P){console.error("Failed to fetch providers:",P)}A(!1)},b=async()=>{S(!0);try{let P=$&&$!=="unassigned"?`?project_id=${$}`:"",_=await(await H(`/api/integrations/composio/configs${P}`)).json();k(_.configs||[])}catch(P){console.error("Failed to fetch Composio configs:",P)}S(!1)},C=async(P)=>{p(P);try{let D=$&&$!=="unassigned"?`?project_id=${$}`:"",_=await H(`/api/integrations/composio/configs/${P}/add${D}`,{method:"POST"});if(_.ok)f((R)=>new Set([...R,P])),G?.();else{let R=await _.json();await u(R.error||"Failed to add config",{title:"Error",variant:"error"})}}catch(D){console.error("Failed to add config:",D)}p(null)},h=(P)=>{return y.has(P)};if(J.useEffect(()=>{Z()},[H,$]),X)return z.jsxDEV("div",{className:"text-center py-8 text-[#666]",children:"Loading..."},void 0,!1,void 0,this);let j=q||U||M,V=[q,U,M].filter(Boolean).length;if(!j)return z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-8 text-center",children:[z.jsxDEV("p",{className:"text-[#888] mb-2",children:"No hosted MCP services connected"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-sm text-[#666] mb-4",children:"Connect Composio, Smithery, or AgentDojo in Settings to access cloud-based MCP servers."},void 0,!1,void 0,this),z.jsxDEV("a",{href:"/settings",className:"inline-block bg-[#1a1a1a] hover:bg-[#222] border border-[#333] hover:border-[#f97316] px-4 py-2 rounded text-sm font-medium transition",children:"Go to Settings โ†’"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return z.jsxDEV(z.Fragment,{children:[i,z.jsxDEV("div",{className:"space-y-6",children:[V>1&&z.jsxDEV("div",{className:"flex gap-1 bg-[#0a0a0a] border border-[#222] rounded-lg p-1 w-fit",children:[q&&z.jsxDEV("button",{onClick:()=>{w("composio"),B("configs")},className:`px-4 py-2 rounded text-sm font-medium transition flex items-center gap-2 ${K==="composio"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:[z.jsxDEV("span",{className:"w-2 h-2 rounded-full bg-purple-500"},void 0,!1,void 0,this),"Composio"]},void 0,!0,void 0,this),U&&z.jsxDEV("button",{onClick:()=>w("smithery"),className:`px-4 py-2 rounded text-sm font-medium transition flex items-center gap-2 ${K==="smithery"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:[z.jsxDEV("span",{className:"w-2 h-2 rounded-full bg-blue-500"},void 0,!1,void 0,this),"Smithery"]},void 0,!0,void 0,this),M&&z.jsxDEV("button",{onClick:()=>w("agentdojo"),className:`px-4 py-2 rounded text-sm font-medium transition flex items-center gap-2 ${K==="agentdojo"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:[z.jsxDEV("span",{className:"w-2 h-2 rounded-full bg-green-500"},void 0,!1,void 0,this),"AgentDojo"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q&&(V===1||K==="composio")&&z.jsxDEV(z.Fragment,{children:[z.jsxDEV("div",{className:"flex items-center justify-between",children:[z.jsxDEV("div",{className:"flex gap-1 bg-[#0a0a0a] border border-[#222] rounded-lg p-1",children:[z.jsxDEV("button",{onClick:()=>B("configs"),className:`px-4 py-2 rounded text-sm font-medium transition ${W==="configs"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"MCP Configs"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>B("connect"),className:`px-4 py-2 rounded text-sm font-medium transition ${W==="connect"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"Connect Apps"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),V===1&&z.jsxDEV("div",{className:"flex items-center gap-2 text-xs text-[#666]",children:[z.jsxDEV("span",{className:"w-2 h-2 rounded-full bg-purple-500"},void 0,!1,void 0,this),"Composio",z.jsxDEV("span",{className:"text-green-400",children:"Connected"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),W==="connect"&&z.jsxDEV("div",{children:[z.jsxDEV("p",{className:"text-sm text-[#666] mb-4",children:"Connect your accounts to enable tools in MCP configs"},void 0,!1,void 0,this),z.jsxDEV(r,{providerId:"composio",projectId:$,onConnectionComplete:()=>{b()}},void 0,!1,void 0,this)]},void 0,!0,void 0,this),W==="configs"&&z.jsxDEV("div",{children:[z.jsxDEV("div",{className:"flex items-center justify-between mb-3",children:[z.jsxDEV("p",{className:"text-sm text-[#666]",children:"Your MCP configs from Composio"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex items-center gap-3",children:[z.jsxDEV("button",{onClick:b,disabled:Y,className:"text-xs text-[#666] hover:text-[#888] transition",children:Y?"Loading...":"Refresh"},void 0,!1,void 0,this),z.jsxDEV("a",{href:"https://app.composio.dev/mcp_configs",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-[#666] hover:text-[#f97316] transition",children:"Create Config โ†’"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Y?z.jsxDEV("div",{className:"text-center py-6 text-[#666]",children:"Loading configs..."},void 0,!1,void 0,this):Q.length===0?z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4 text-center",children:[z.jsxDEV("p",{className:"text-sm text-[#666]",children:"No MCP configs found"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-2",children:["First ",z.jsxDEV("button",{onClick:()=>B("connect"),className:"text-[#f97316] hover:text-[#fb923c]",children:"connect some apps"},void 0,!1,void 0,this),", then create a config."]},void 0,!0,void 0,this),z.jsxDEV("a",{href:"https://app.composio.dev/mcp_configs",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-[#f97316] hover:text-[#fb923c] mt-2 inline-block",children:"Create in Composio โ†’"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):z.jsxDEV("div",{className:"space-y-2",children:Q.map((P)=>{let D=h(P.id),_=I===P.id;return z.jsxDEV("div",{className:`bg-[#111] border rounded-lg p-3 transition flex items-center justify-between ${D?"border-green-500/30":"border-[#1a1a1a] hover:border-[#333]"}`,children:[z.jsxDEV("div",{className:"flex-1 min-w-0",children:[z.jsxDEV("div",{className:"flex items-center gap-2",children:[z.jsxDEV("span",{className:"font-medium text-sm",children:P.name},void 0,!1,void 0,this),z.jsxDEV("span",{className:"text-xs text-[#555]",children:[P.toolsCount," tools"]},void 0,!0,void 0,this),D&&z.jsxDEV("span",{className:"text-xs text-green-400",children:"Added"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),P.toolkits.length>0&&z.jsxDEV("div",{className:"flex flex-wrap gap-1 mt-1",children:[P.toolkits.slice(0,4).map((R)=>z.jsxDEV("span",{className:"text-xs bg-[#1a1a1a] text-[#666] px-1.5 py-0.5 rounded",children:R},R,!1,void 0,this)),P.toolkits.length>4&&z.jsxDEV("span",{className:"text-xs text-[#555]",children:["+",P.toolkits.length-4]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex items-center gap-2 ml-3",children:[D?z.jsxDEV("span",{className:"text-xs text-[#555] px-2 py-1",children:"In Servers"},void 0,!1,void 0,this):z.jsxDEV("button",{onClick:()=>C(P.id),disabled:_,className:"text-xs bg-[#f97316] hover:bg-[#fb923c] text-black px-3 py-1 rounded font-medium transition disabled:opacity-50",children:_?"Adding...":"Add"},void 0,!1,void 0,this),z.jsxDEV("a",{href:`https://app.composio.dev/mcp_configs/${P.id}`,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-[#666] hover:text-[#888] transition",children:"Edit"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},P.id,!0,void 0,this)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),U&&(V===1||K==="smithery")&&z.jsxDEV("div",{children:[V===1&&z.jsxDEV("div",{className:"flex items-center gap-2 text-xs text-[#666] mb-4",children:[z.jsxDEV("span",{className:"w-2 h-2 rounded-full bg-blue-500"},void 0,!1,void 0,this),"Smithery",z.jsxDEV("span",{className:"text-green-400",children:"Connected"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex items-center justify-between mb-3",children:[z.jsxDEV("p",{className:"text-sm text-[#666]",children:"Add MCP servers from the Smithery registry"},void 0,!1,void 0,this),z.jsxDEV("a",{href:"https://smithery.ai/servers",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-[#666] hover:text-[#f97316] transition",children:"Browse Smithery โ†’"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4 text-center",children:[z.jsxDEV("p",{className:"text-sm text-[#666]",children:["Smithery servers can be added from the ",z.jsxDEV("strong",{children:"Browse Registry"},void 0,!1,void 0,this)," tab."]},void 0,!0,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-2",children:"Your API key will be used automatically when adding Smithery servers."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),M&&(V===1||K==="agentdojo")&&z.jsxDEV($z,{projectId:$,onServerAdded:G,showProviderBadge:V===1},void 0,!1,void 0,this),z.jsxDEV("div",{className:"p-3 bg-[#0a0a0a] border border-[#222] rounded text-xs text-[#666]",children:[z.jsxDEV("strong",{className:"text-[#888]",children:"Tip:"},void 0,!1,void 0,this)," Connect apps first, then add MCP configs to make tools available to your agents."," ยท ",z.jsxDEV("a",{href:"/settings",className:"text-[#f97316] hover:text-[#fb923c]",children:"Add more providers in Settings"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function $z({projectId:G,onServerAdded:$,showProviderBadge:H}){let{authFetch:K}=c(),[w,W]=J.useState("configs"),[B,q]=J.useState([]),[F,U]=J.useState(new Set),[T,M]=J.useState(!1),[L,Q]=J.useState(null),{alert:k,AlertDialog:y}=o(),f=async()=>{M(!0);try{let Y=G&&G!=="unassigned"?`?project_id=${G}`:"",S=G&&G!=="unassigned"?`/api/mcp/servers?project=${encodeURIComponent(G)}`:"/api/mcp/servers";console.log(`[AgentDojo:fetchConfigs] projectId=${G} serversUrl=${S}`);let[I,p]=await Promise.all([K(`/api/integrations/agentdojo/configs${Y}`),K(S)]),u=await I.json(),i=await p.json();console.log(`[AgentDojo:fetchConfigs] configs=${(u.configs||[]).length} servers=${(i.servers||[]).length}`),q(u.configs||[]);let Z=(i.servers||[]).filter((C)=>C.source==="agentdojo");console.log(`[AgentDojo:fetchConfigs] agentdojo servers found: ${Z.length}`);for(let C of Z){let h=C.url?.match(/\/mcp\/([^/?]+)/);console.log(`[AgentDojo:fetchConfigs] server: id=${C.id} name=${C.name} project_id=${C.project_id} url=${C.url?.substring(0,80)} extracted=${h?h[1]:C.name}`)}let b=new Set(Z.map((C)=>{let h=C.url?.match(/\/mcp\/([^/?]+)/);return h?h[1]:C.name}));console.log("[AgentDojo:fetchConfigs] addedServers set:",[...b]),U(b)}catch(Y){console.error("Failed to fetch AgentDojo configs:",Y)}M(!1)},X=async(Y)=>{Q(Y);try{let S=G&&G!=="unassigned"?`?project_id=${G}`:"";console.log(`[AgentDojo:addConfig] configId=${Y} projectParam=${S}`);let I=await K(`/api/integrations/agentdojo/configs/${Y}/add${S}`,{method:"POST"}),p=await I.json();if(console.log(`[AgentDojo:addConfig] response status=${I.status} ok=${I.ok} message=${p.message} server.id=${p.server?.id} server.project_id=${p.server?.project_id}`),I.ok){let u=B.find((Z)=>Z.id===Y),i=u?.slug||Y;console.log(`[AgentDojo:addConfig] marking as added: key=${i} config.slug=${u?.slug} config.id=${u?.id} config.name=${u?.name}`),U((Z)=>new Set([...Z,i])),$?.()}else await k(p.error||"Failed to add config",{title:"Error",variant:"error"})}catch(S){console.error("Failed to add config:",S)}Q(null)},A=(Y)=>{return F.has(Y.slug)||F.has(Y.id)||F.has(Y.name)};return J.useEffect(()=>{f()},[K,G]),z.jsxDEV(z.Fragment,{children:[y,z.jsxDEV("div",{children:[H&&z.jsxDEV("div",{className:"flex items-center gap-2 text-xs text-[#666] mb-4",children:[z.jsxDEV("span",{className:"w-2 h-2 rounded-full bg-green-500"},void 0,!1,void 0,this),"AgentDojo",z.jsxDEV("span",{className:"text-green-400",children:"Connected"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex items-center justify-between mb-4",children:z.jsxDEV("div",{className:"flex gap-1 bg-[#0a0a0a] border border-[#222] rounded-lg p-1",children:[z.jsxDEV("button",{onClick:()=>W("configs"),className:`px-4 py-2 rounded text-sm font-medium transition ${w==="configs"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"MCP Servers"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>W("toolkits"),className:`px-4 py-2 rounded text-sm font-medium transition ${w==="toolkits"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"Browse Toolkits"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),w==="configs"&&z.jsxDEV("div",{children:[z.jsxDEV("div",{className:"flex items-center justify-between mb-3",children:[z.jsxDEV("p",{className:"text-sm text-[#666]",children:"Your MCP servers from AgentDojo"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:f,disabled:T,className:"text-xs text-[#666] hover:text-[#888] transition",children:T?"Loading...":"Refresh"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),T?z.jsxDEV("div",{className:"text-center py-6 text-[#666]",children:"Loading servers..."},void 0,!1,void 0,this):B.length===0?z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4 text-center",children:[z.jsxDEV("p",{className:"text-sm text-[#666]",children:"No MCP servers found"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-2",children:[z.jsxDEV("button",{onClick:()=>W("toolkits"),className:"text-[#f97316] hover:text-[#fb923c]",children:"Browse toolkits"},void 0,!1,void 0,this)," ","to create a new MCP server."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):z.jsxDEV("div",{className:"space-y-2",children:B.map((Y)=>{let S=A(Y),I=L===Y.id;return z.jsxDEV("div",{className:`bg-[#111] border rounded-lg p-3 transition flex items-center justify-between ${S?"border-green-500/30":"border-[#1a1a1a] hover:border-[#333]"}`,children:[z.jsxDEV("div",{className:"flex-1 min-w-0",children:[z.jsxDEV("div",{className:"flex items-center gap-2",children:[z.jsxDEV("span",{className:"font-medium text-sm",children:Y.name},void 0,!1,void 0,this),z.jsxDEV("span",{className:"text-xs text-[#555]",children:[Y.toolsCount," tools"]},void 0,!0,void 0,this),S&&z.jsxDEV("span",{className:"text-xs text-green-400",children:"Added"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Y.mcpUrl&&z.jsxDEV("code",{className:"text-xs text-[#555] mt-1 block truncate",children:Y.mcpUrl},void 0,!1,void 0,this),!Y.mcpUrl&&Y.slug&&z.jsxDEV("code",{className:"text-xs text-[#555] mt-1 block truncate",children:Y.slug},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex items-center gap-2 ml-3",children:S?z.jsxDEV("span",{className:"text-xs text-[#555] px-2 py-1",children:"In Servers"},void 0,!1,void 0,this):z.jsxDEV("button",{onClick:()=>X(Y.id),disabled:I,className:"text-xs bg-[#f97316] hover:bg-[#fb923c] text-black px-3 py-1 rounded font-medium transition disabled:opacity-50",children:I?"Adding...":"Add"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},Y.id,!0,void 0,this)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w==="toolkits"&&z.jsxDEV("div",{children:[z.jsxDEV("p",{className:"text-sm text-[#666] mb-4",children:"Browse available toolkits and create MCP servers"},void 0,!1,void 0,this),z.jsxDEV(r,{providerId:"agentdojo",projectId:G,onConnectionComplete:()=>{f()}},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function qz(G){let $=[],H=G,K=null,w=G.match(/(?:npx\s+-y\s+)?(@?[\w-]+\/)?(@?[\w-]+)(?:@[\w.-]+)?/);if(w){let q=w[2]||w[1];if(q)K=q.replace(/^@/,"").replace(/-mcp$/,"").replace(/-server$/,"").replace(/^server-/,"").replace(/^mcp-/,"")}let W=/--(\w+[-\w]*)\s+(YOUR_\w+|<[\w_]+>|\{[\w_]+\}|\$[\w_]+|[\w_]*(?:TOKEN|KEY|SECRET|PASSWORD|USER|ID|APIKEY)[\w_]*)/gi,B;while((B=W.exec(G))!==null){let q=B[1],F=B[2],U=q.toUpperCase().replace(/-/g,"_"),T=K?`${K.toUpperCase().replace(/-/g,"_")}_${U}`:U;$.push({key:T,flag:q}),H=H.replace(new RegExp(`(--${q}\\s+)${F.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}`,"i"),`--${q} $${T}`)}return{cleanCommand:H,credentials:$,serverName:K}}function Bz({onClose:G,onAdded:$,projects:H,defaultProjectId:K}){let{authFetch:w}=c(),[W,B]=J.useState("npm"),[q,F]=J.useState(""),[U,T]=J.useState(""),[M,L]=J.useState(""),[Q,k]=J.useState(""),[y,f]=J.useState(""),[X,A]=J.useState(""),[Y,S]=J.useState(""),[I,p]=J.useState([]),[u,i]=J.useState(K||null),[Z,b]=J.useState(!1),[C,h]=J.useState(null),j=H&&H.length>0,V=()=>{p([...I,{key:"",value:""}])},P=(O,N,m)=>{let l=[...I];l[O][N]=m,p(l)},D=(O)=>{p(I.filter((N,m)=>m!==O))},_=(O)=>{if(k(O),O.includes("YOUR_")||O.includes("<")||O.includes("{")||/TOKEN|KEY|SECRET|PASSWORD/i.test(O)){let{cleanCommand:N,credentials:m,serverName:l}=qz(O);if(!q&&l)F(l);if(m.length>0){let n=new Set(I.map((v)=>v.key)),d=m.filter((v)=>!n.has(v.key)).map((v)=>({key:v.key,value:""}));if(d.length>0)p([...I,...d]),k(N)}}},R=(O)=>{if(O.startsWith("npx ")||O.includes(" --")||O.includes("YOUR_")||O.includes("<")||/\s+(TOKEN|KEY|SECRET|PASSWORD)/i.test(O))B("command"),_(O);else if(T(O),!q&&O){let m=O.replace(/^@[\w-]+\//,"").replace(/@[\w.-]+$/,"").replace(/^server-/,"").replace(/-server$/,"").replace(/^mcp-/,"").replace(/-mcp$/,"");if(m&&m!==O)F(m)}},g=async()=>{if(!q){h("Name is required");return}if(W==="npm"&&!U){h("npm package is required");return}if(W==="pip"&&!U){h("pip package is required");return}if(W==="command"&&!Q){h("Command is required");return}if(W==="http"&&!y){h("URL is required");return}b(!0),h(null);let O={};for(let{key:N,value:m}of I)if(N.trim())O[N.trim()]=m;try{let N={name:q};if(W==="npm")N.type="npm",N.package=U;else if(W==="pip"){if(N.type="pip",N.package=U,M)N.pip_module=M}else if(W==="http"){N.type="http",N.url=y;let l={"Content-Type":"application/json"};if(X&&Y){let n=btoa(`${X}:${Y}`);l.Authorization=`Basic ${n}`}N.headers=l}else{let l=Q.trim().split(/\s+/);N.type="custom",N.command=l[0],N.args=l.slice(1).join(" ")}if(Object.keys(O).length>0)N.env=O;if(u)N.project_id=u;let m=await w("/api/mcp/servers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(N)});if(!m.ok){let l=await m.json();h(l.error||"Failed to add server"),b(!1);return}$()}catch(N){h("Failed to add server"),b(!1)}},x=(O,N)=>{B("npm"),F(O),T(N)};return z.jsxDEV("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-[2px] z-50 flex items-center justify-center p-4",children:z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg w-full max-w-lg max-h-[90vh] overflow-y-auto",children:[z.jsxDEV("div",{className:"p-4 border-b border-[#1a1a1a] flex items-center justify-between sticky top-0 bg-[#111]",children:[z.jsxDEV("h2",{className:"text-lg font-semibold",children:"Add MCP Server"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:G,className:"text-[#666] hover:text-[#888]",children:"โœ•"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"p-4 space-y-4",children:[z.jsxDEV("div",{children:[z.jsxDEV("p",{className:"text-sm text-[#666] mb-2",children:"Quick add:"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex flex-wrap gap-2",children:[{name:"filesystem",pkg:"@modelcontextprotocol/server-filesystem",type:"npm"},{name:"fetch",pkg:"@modelcontextprotocol/server-fetch",type:"npm"},{name:"memory",pkg:"@modelcontextprotocol/server-memory",type:"npm"},{name:"github",pkg:"@modelcontextprotocol/server-github",type:"npm"},{name:"time",pkg:"mcp-server-time",module:"mcp_server_time",type:"pip"}].map((O)=>z.jsxDEV("button",{onClick:()=>{if(B(O.type),F(O.name),T(O.pkg),O.type==="pip"&&"module"in O)L(O.module||"");else L("")},className:"text-sm bg-[#1a1a1a] hover:bg-[#222] px-3 py-1 rounded transition",children:O.name},O.name,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex gap-1 bg-[#0a0a0a] border border-[#222] rounded p-1",children:[z.jsxDEV("button",{onClick:()=>B("npm"),className:`flex-1 px-2 py-1.5 rounded text-sm transition ${W==="npm"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"npm"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>B("pip"),className:`flex-1 px-2 py-1.5 rounded text-sm transition ${W==="pip"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"pip"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>B("command"),className:`flex-1 px-2 py-1.5 rounded text-sm transition ${W==="command"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"Command"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>B("http"),className:`flex-1 px-2 py-1.5 rounded text-sm transition ${W==="http"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"HTTP"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Name"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:q,onChange:(O)=>F(O.target.value),placeholder:"e.g., pushover",className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),j&&z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Scope"},void 0,!1,void 0,this),z.jsxDEV(t,{value:u||"",onChange:(O)=>i(O||null),options:[{value:"",label:"Global (all projects)"},...H.map((O)=>({value:O.id,label:O.name}))],placeholder:"Select scope..."},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-1",children:"Global servers are available to all agents. Project-scoped servers are only available to agents in that project."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),W==="npm"&&z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"npm Package"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:U,onChange:(O)=>R(O.target.value),placeholder:"e.g., @modelcontextprotocol/server-filesystem or paste full command",className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-1",children:"Package name or paste a full npx command with credentials"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),W==="pip"&&z.jsxDEV("div",{className:"space-y-4",children:[z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"pip Package"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:U,onChange:(O)=>{if(T(O.target.value),!M&&O.target.value){let N=O.target.value.split("[")[0].replace(/-/g,".");L(N)}},placeholder:"e.g., late-sdk[mcp]",className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-1",children:"Python package with extras, e.g., late-sdk[mcp] or mcp-server-time"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Module (optional)"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:M,onChange:(O)=>L(O.target.value),placeholder:"e.g., late.mcp",className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 font-mono text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-1",children:"Python module to run with -m. Auto-detected from package name if not specified."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),W==="command"&&z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Command"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:Q,onChange:(O)=>_(O.target.value),placeholder:"e.g., npx -y pushover-mcp@latest start --token YOUR_TOKEN",className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 font-mono text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-1",children:"Paste the full command - credentials like YOUR_TOKEN will be auto-extracted"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),W==="http"&&z.jsxDEV("div",{className:"space-y-4",children:[z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"URL"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:y,onChange:(O)=>f(O.target.value),placeholder:"e.g., https://example.com/wp-json/mcp/v1/messages",className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 font-mono text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"p-3 bg-[#0a0a0a] border border-[#222] rounded",children:[z.jsxDEV("p",{className:"text-xs text-[#666] mb-3",children:"Optional: Basic Auth credentials (will be encoded and stored securely)"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"grid grid-cols-2 gap-3",children:[z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-xs text-[#555] mb-1",children:"Username"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:X,onChange:(O)=>A(O.target.value),placeholder:"username",className:"w-full bg-[#111] border border-[#333] rounded px-3 py-2 text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-xs text-[#555] mb-1",children:"Password"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"password",value:Y,onChange:(O)=>S(O.target.value),placeholder:"password or app key",className:"w-full bg-[#111] border border-[#333] rounded px-3 py-2 text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("div",{className:"flex items-center justify-between mb-2",children:[z.jsxDEV("label",{className:"text-sm text-[#666]",children:"Environment Variables / Credentials"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:V,className:"text-xs text-[#f97316] hover:text-[#fb923c] transition",children:"+ Add Variable"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),I.length===0&&z.jsxDEV("p",{className:"text-xs text-[#555] bg-[#0a0a0a] border border-[#222] rounded p-3",children:"Add environment variables for API tokens and credentials. These are stored encrypted and passed to the server at startup."},void 0,!1,void 0,this),I.length>0&&z.jsxDEV("div",{className:"space-y-2",children:I.map((O,N)=>z.jsxDEV("div",{className:"flex gap-2",children:[z.jsxDEV("input",{type:"text",value:O.key,onChange:(m)=>P(N,"key",m.target.value),placeholder:"KEY",className:"w-1/3 bg-[#0a0a0a] border border-[#333] rounded px-2 py-1.5 text-sm font-mono focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"password",value:O.value,onChange:(m)=>P(N,"value",m.target.value),placeholder:"value",className:"flex-1 bg-[#0a0a0a] border border-[#333] rounded px-2 py-1.5 text-sm font-mono focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>D(N),className:"text-[#666] hover:text-red-400 px-2 transition",children:"โœ•"},void 0,!1,void 0,this)]},N,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),C&&z.jsxDEV("p",{className:"text-red-400 text-sm",children:C},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"p-4 border-t border-[#1a1a1a] flex justify-end gap-2 sticky bottom-0 bg-[#111]",children:[z.jsxDEV("button",{onClick:G,className:"px-4 py-2 border border-[#333] hover:border-[#666] rounded transition",children:"Cancel"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:g,disabled:Z||!q||(W==="npm"?!U:W==="pip"?!U:W==="http"?!y:!Q),className:"px-4 py-2 bg-[#f97316] hover:bg-[#fb923c] text-black rounded font-medium transition disabled:opacity-50",children:Z?"Adding...":"Add Server"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function Uz({server:G,projects:$,onClose:H,onSaved:K}){let{authFetch:w}=c(),[W,B]=J.useState(G.name),[q,F]=J.useState(G.package||""),[U,T]=J.useState(G.command||""),[M,L]=J.useState(G.args||""),[Q,k]=J.useState(G.url||""),[y,f]=J.useState(()=>{let _=G.headers?.Authorization||"";if(_.startsWith("Basic "))try{return atob(_.slice(6)).split(":")[0]||""}catch{return""}return""}),[X,A]=J.useState(()=>{let _=G.headers?.Authorization||"";if(_.startsWith("Basic "))try{return atob(_.slice(6)).split(":").slice(1).join(":")||""}catch{return""}return""}),[Y,S]=J.useState(()=>{return Object.entries(G.env||{}).map(([_,R])=>({key:_,value:R}))}),[I,p]=J.useState(G.project_id),[u,i]=J.useState(!1),[Z,b]=J.useState(null),C=$&&$.length>0,h=G.type==="http",j=()=>{S([...Y,{key:"",value:""}])},V=(_,R,g)=>{let x=[...Y];x[_][R]=g,S(x)},P=(_)=>{S(Y.filter((R,g)=>g!==_))},D=async()=>{if(!W.trim()){b("Name is required");return}i(!0),b(null);let _={};for(let{key:R,value:g}of Y)if(R.trim())_[R.trim()]=g;try{let R={name:W.trim(),env:_};if(h){if(Q.trim())R.url=Q.trim();let x={"Content-Type":"application/json"};if(y&&X){let O=btoa(`${y}:${X}`);x.Authorization=`Basic ${O}`}R.headers=x}else{if(G.type==="npm"&&q.trim())R.package=q.trim();if(G.type==="pip"&&q.trim())R.package=q.trim();if(G.type==="custom"){if(U.trim())R.command=U.trim();if(M.trim())R.args=M.trim()}}R.project_id=I;let g=await w(`/api/mcp/servers/${G.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(R)});if(!g.ok){let x=await g.json();b(x.error||"Failed to save changes"),i(!1);return}if(G.status==="running"&&!h)try{await w(`/api/mcp/servers/${G.id}/stop`,{method:"POST"}),await w(`/api/mcp/servers/${G.id}/start`,{method:"POST"})}catch(x){console.error("Failed to restart server:",x)}K()}catch(R){b("Failed to save changes"),i(!1)}};return z.jsxDEV("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-[2px] z-50 flex items-center justify-center p-4",children:z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg w-full max-w-lg max-h-[90vh] overflow-y-auto",children:[z.jsxDEV("div",{className:"p-4 border-b border-[#1a1a1a] flex items-center justify-between sticky top-0 bg-[#111]",children:[z.jsxDEV("h2",{className:"text-lg font-semibold",children:"Edit MCP Server"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:H,className:"text-[#666] hover:text-[#888]",children:"โœ•"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"p-4 space-y-4",children:[z.jsxDEV("div",{className:"text-sm text-[#666] bg-[#0a0a0a] border border-[#222] rounded p-3",children:["Type: ",z.jsxDEV("span",{className:"text-[#888]",children:G.type},void 0,!1,void 0,this),G.package&&z.jsxDEV(z.Fragment,{children:[" โ€ข Package: ",z.jsxDEV("span",{className:"text-[#888] font-mono",children:G.package},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G.command&&z.jsxDEV(z.Fragment,{children:[" โ€ข Command: ",z.jsxDEV("span",{className:"text-[#888] font-mono",children:G.command},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Name"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:W,onChange:(_)=>B(_.target.value),className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),C&&z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Scope"},void 0,!1,void 0,this),z.jsxDEV(t,{value:I||"",onChange:(_)=>p(_||null),options:[{value:"",label:"Global (all projects)"},...$.map((_)=>({value:_.id,label:_.name}))],placeholder:"Select scope..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G.type==="npm"&&z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"npm Package"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:q,onChange:(_)=>F(_.target.value),className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 font-mono text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G.type==="pip"&&z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"pip Package"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:q,onChange:(_)=>F(_.target.value),className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 font-mono text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),h&&z.jsxDEV(z.Fragment,{children:[z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Server URL"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:Q,onChange:(_)=>k(_.target.value),placeholder:"https://example.com/mcp",className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 font-mono text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Authentication (Basic Auth)"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex gap-2",children:[z.jsxDEV("input",{type:"text",value:y,onChange:(_)=>f(_.target.value),placeholder:"Username",className:"flex-1 bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"password",value:X,onChange:(_)=>A(_.target.value),placeholder:"Password / App Password",className:"flex-1 bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-1",children:"Leave empty if no authentication required"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),G.type==="custom"&&z.jsxDEV(z.Fragment,{children:[z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Command"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:U,onChange:(_)=>T(_.target.value),className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 font-mono text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Arguments"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:M,onChange:(_)=>L(_.target.value),placeholder:"e.g., --token $TOKEN --verbose",className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 font-mono text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),!h&&z.jsxDEV("div",{children:[z.jsxDEV("div",{className:"flex items-center justify-between mb-2",children:[z.jsxDEV("label",{className:"text-sm text-[#666]",children:"Environment Variables / Credentials"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:j,className:"text-xs text-[#f97316] hover:text-[#fb923c] transition",children:"+ Add Variable"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Y.length===0&&z.jsxDEV("p",{className:"text-xs text-[#555] bg-[#0a0a0a] border border-[#222] rounded p-3",children:"No environment variables configured."},void 0,!1,void 0,this),Y.length>0&&z.jsxDEV("div",{className:"space-y-2",children:Y.map((_,R)=>z.jsxDEV("div",{className:"flex gap-2",children:[z.jsxDEV("input",{type:"text",value:_.key,onChange:(g)=>V(R,"key",g.target.value),placeholder:"KEY",className:"w-1/3 bg-[#0a0a0a] border border-[#333] rounded px-2 py-1.5 text-sm font-mono focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"password",value:_.value,onChange:(g)=>V(R,"value",g.target.value),placeholder:"value",className:"flex-1 bg-[#0a0a0a] border border-[#333] rounded px-2 py-1.5 text-sm font-mono focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>P(R),className:"text-[#666] hover:text-red-400 px-2 transition",children:"โœ•"},void 0,!1,void 0,this)]},R,!0,void 0,this))},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-2",children:G.status==="running"?"Server will be automatically restarted to apply changes.":"Changes will take effect when the server is started."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Z&&z.jsxDEV("p",{className:"text-red-400 text-sm",children:Z},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"p-4 border-t border-[#1a1a1a] flex justify-end gap-2 sticky bottom-0 bg-[#111]",children:[z.jsxDEV("button",{onClick:H,className:"px-4 py-2 border border-[#333] hover:border-[#666] rounded transition",children:"Cancel"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:D,disabled:u||!W.trim(),className:"px-4 py-2 bg-[#f97316] hover:bg-[#fb923c] text-black rounded font-medium transition disabled:opacity-50",children:u?"Saving...":"Save Changes"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}
2
+ export{Mz as j};
3
+
4
+ //# debugId=99C261B73617894664756E2164756E21