capsule-ai-cli
Version:
The AI Model Orchestrator - Intelligent multi-model workflows with device-locked licensing
40 lines • 2.86 kB
JavaScript
import React, { useState } from 'react';
import { Box, Text } from 'ink';
import { useInput } from 'ink';
export const BashConfirmation = ({ command, workingDirectory, isDangerous, onConfirm, onCancel }) => {
const [selectedOption, setSelectedOption] = useState('approve');
useInput((_, key) => {
if (key.upArrow || key.downArrow) {
setSelectedOption(prev => prev === 'approve' ? 'reject' : 'approve');
}
else if (key.return) {
if (selectedOption === 'approve') {
onConfirm();
}
else {
onCancel();
}
}
});
return (React.createElement(Box, { flexDirection: "column", marginY: 1 },
React.createElement(Box, { borderStyle: "round", borderColor: isDangerous ? "red" : "yellow", paddingX: 1, paddingY: 1, flexDirection: "column", width: 80 },
React.createElement(Box, { justifyContent: "center", marginBottom: 1 },
React.createElement(Text, { bold: true, color: isDangerous ? "red" : "yellow" }, isDangerous ? '[!] Dangerous Command' : '[$] Bash Command')),
React.createElement(Box, { flexDirection: "column" },
React.createElement(Box, { flexDirection: "column", marginBottom: 1 },
React.createElement(Text, { dimColor: true }, "Command:"),
React.createElement(Text, { color: "cyan", wrap: "wrap" }, command)),
React.createElement(Box, { flexDirection: "column" },
React.createElement(Text, { dimColor: true }, "Directory:"),
React.createElement(Text, { color: "blue", wrap: "wrap" }, workingDirectory))),
isDangerous && (React.createElement(Box, { marginTop: 1 },
React.createElement(Text, { color: "red", wrap: "wrap" }, "[WARNING] This command appears potentially dangerous. Please review carefully.")))),
React.createElement(Box, { marginTop: 1, flexDirection: "row", justifyContent: "center", gap: 4 },
React.createElement(Box, { borderStyle: "round", borderColor: selectedOption === 'approve' ? 'green' : 'gray', paddingX: 2 },
React.createElement(Text, { color: selectedOption === 'approve' ? 'green' : 'gray', bold: selectedOption === 'approve' }, "\u2713 Execute")),
React.createElement(Box, { borderStyle: "round", borderColor: selectedOption === 'reject' ? 'red' : 'gray', paddingX: 2 },
React.createElement(Text, { color: selectedOption === 'reject' ? 'red' : 'gray', bold: selectedOption === 'reject' }, "\u2717 Cancel"))),
React.createElement(Box, { marginTop: 1, justifyContent: "center" },
React.createElement(Text, { dimColor: true }, "\u2191\u2193 to switch \u2022 Enter to confirm"))));
};
//# sourceMappingURL=BashConfirmation.js.map