UNPKG

automagik-cli

Version:

Automagik CLI - A powerful command-line interface for interacting with Automagik Hive multi-agent AI systems

37 lines (36 loc) 2.17 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { useState } from 'react'; import { Box, Text } from 'ink'; import TextInput from 'ink-text-input'; import { Colors } from '../colors.js'; export const ServerConfigDialog = ({ currentUrl = 'http://localhost:8886', onSubmit, onCancel, }) => { const [url, setUrl] = useState(currentUrl); const [isSubmitting, setIsSubmitting] = useState(false); const handleSubmit = async () => { if (!url.trim()) { return; } // Validate URL format try { new URL(url); } catch { // If URL is invalid, try adding http:// prefix if (!url.startsWith('http://') && !url.startsWith('https://')) { try { new URL(`http://${url}`); setUrl(`http://${url}`); } catch { return; // Invalid URL format } } else { return; // Invalid URL format } } setIsSubmitting(true); onSubmit(url); }; return (_jsxs(Box, { flexDirection: "column", padding: 1, children: [_jsx(Box, { marginBottom: 1, children: _jsx(Text, { color: Colors.AccentBlue, children: "\uD83D\uDD27 Server Configuration" }) }), _jsx(Box, { marginBottom: 1, children: _jsx(Text, { children: "Unable to connect to the API server. Please enter the server URL:" }) }), _jsx(Box, { marginBottom: 1, children: _jsx(Text, { color: Colors.Comment, children: "Examples: http://localhost:8886, https://api.example.com, 192.168.1.100:8080" }) }), _jsxs(Box, { marginBottom: 1, children: [_jsx(Text, { color: Colors.AccentCyan, children: "Server URL: " }), _jsx(TextInput, { value: url, onChange: setUrl, onSubmit: handleSubmit, placeholder: "Enter server URL..." })] }), _jsx(Box, { marginBottom: 1, children: _jsx(Text, { color: Colors.Comment, children: "Press Enter to save and continue, or Ctrl+C to cancel" }) }), isSubmitting && (_jsx(Box, { children: _jsx(Text, { color: Colors.AccentGreen, children: "\uD83D\uDCBE Saving configuration..." }) }))] })); };