automagik-cli
Version:
Automagik CLI - A powerful command-line interface for interacting with Automagik Hive multi-agent AI systems
20 lines (19 loc) • 2.13 kB
JavaScript
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 APIKeyConfigDialog = ({ currentApiKey = '', authError, onSubmit, onCancel, }) => {
const [apiKey, setApiKey] = useState(currentApiKey);
const [isSubmitting, setIsSubmitting] = useState(false);
const handleSubmit = async () => {
if (!apiKey.trim()) {
return;
}
setIsSubmitting(true);
onSubmit(apiKey.trim());
};
return (_jsxs(Box, { flexDirection: "column", padding: 1, children: [_jsx(Box, { marginBottom: 1, children: _jsx(Text, { color: Colors.AccentBlue, children: "\uD83D\uDD11 API Key Configuration" }) }), _jsx(Box, { marginBottom: 1, children: _jsx(Text, { children: authError === 'No API key configured'
? 'No API key is configured. Please enter your API key to continue:'
: 'Authentication failed. Please check and update your API key:' }) }), authError && authError !== 'No API key configured' && (_jsx(Box, { marginBottom: 1, children: _jsxs(Text, { color: Colors.AccentRed, children: ["\u274C Error: ", authError] }) })), _jsx(Box, { marginBottom: 1, children: _jsx(Text, { color: Colors.Comment, children: "Your API key should look like: hive_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }) }), _jsxs(Box, { marginBottom: 1, children: [_jsx(Text, { color: Colors.AccentCyan, children: "API Key: " }), _jsx(TextInput, { value: apiKey, onChange: setApiKey, onSubmit: handleSubmit, placeholder: "Enter your API key...", mask: "*" })] }), _jsx(Box, { marginBottom: 1, children: _jsx(Text, { color: Colors.Comment, children: "Press Enter to save and continue, or Ctrl+C to cancel" }) }), _jsx(Box, { marginBottom: 1, children: _jsx(Text, { color: Colors.Comment, children: "\uD83D\uDCA1 Your API key will be saved to the .env file for future use" }) }), isSubmitting && (_jsx(Box, { children: _jsx(Text, { color: Colors.AccentGreen, children: "\uD83D\uDD04 Validating API key..." }) }))] }));
};