import { Button } from '../ui/button'; import { Input } from '../ui/input'; import { Shield, AlertTriangle, Plus, X } from 'lucide-react'; import { useTranslation } from 'react-i18next'; // Common tool patterns for Claude const commonClaudeTools = [ 'Bash(git log:*)', 'Bash(git diff:*)', 'Bash(git status:*)', 'Write', 'Read', 'Edit', 'Glob', 'Grep', 'MultiEdit', 'Task', 'TodoWrite', 'TodoRead', 'WebFetch', 'WebSearch' ]; // Common shell commands for Cursor const commonCursorCommands = [ 'Shell(ls)', 'Shell(mkdir)', 'Shell(cd)', 'Shell(cat)', 'Shell(echo)', 'Shell(git status)', 'Shell(git diff)', 'Shell(git log)', 'Shell(npm install)', 'Shell(npm run)', 'Shell(python)', 'Shell(node)' ]; // Claude Permissions function ClaudePermissions({ skipPermissions, setSkipPermissions, allowedTools, setAllowedTools, disallowedTools, setDisallowedTools, newAllowedTool, setNewAllowedTool, newDisallowedTool, setNewDisallowedTool, }) { const { t } = useTranslation('settings'); const addAllowedTool = (tool) => { if (tool && !allowedTools.includes(tool)) { setAllowedTools([...allowedTools, tool]); setNewAllowedTool(''); } }; const removeAllowedTool = (tool) => { setAllowedTools(allowedTools.filter(t => t !== tool)); }; const addDisallowedTool = (tool) => { if (tool && !disallowedTools.includes(tool)) { setDisallowedTools([...disallowedTools, tool]); setNewDisallowedTool(''); } }; const removeDisallowedTool = (tool) => { setDisallowedTools(disallowedTools.filter(t => t !== tool)); }; return (
{/* Skip Permissions */}

{t('permissions.title')}

{/* Allowed Tools */}

{t('permissions.allowedTools.title')}

{t('permissions.allowedTools.description')}

setNewAllowedTool(e.target.value)} placeholder={t('permissions.allowedTools.placeholder')} onKeyPress={(e) => { if (e.key === 'Enter') { e.preventDefault(); addAllowedTool(newAllowedTool); } }} className="flex-1 h-10" />
{/* Quick add buttons */}

{t('permissions.allowedTools.quickAdd')}

{commonClaudeTools.map(tool => ( ))}
{allowedTools.map(tool => (
{tool}
))} {allowedTools.length === 0 && (
{t('permissions.allowedTools.empty')}
)}
{/* Disallowed Tools */}

{t('permissions.blockedTools.title')}

{t('permissions.blockedTools.description')}

setNewDisallowedTool(e.target.value)} placeholder={t('permissions.blockedTools.placeholder')} onKeyPress={(e) => { if (e.key === 'Enter') { e.preventDefault(); addDisallowedTool(newDisallowedTool); } }} className="flex-1 h-10" />
{disallowedTools.map(tool => (
{tool}
))} {disallowedTools.length === 0 && (
{t('permissions.blockedTools.empty')}
)}
{/* Help Section */}

{t('permissions.toolExamples.title')}

); } // Cursor Permissions function CursorPermissions({ skipPermissions, setSkipPermissions, allowedCommands, setAllowedCommands, disallowedCommands, setDisallowedCommands, newAllowedCommand, setNewAllowedCommand, newDisallowedCommand, setNewDisallowedCommand, }) { const { t } = useTranslation('settings'); const addAllowedCommand = (cmd) => { if (cmd && !allowedCommands.includes(cmd)) { setAllowedCommands([...allowedCommands, cmd]); setNewAllowedCommand(''); } }; const removeAllowedCommand = (cmd) => { setAllowedCommands(allowedCommands.filter(c => c !== cmd)); }; const addDisallowedCommand = (cmd) => { if (cmd && !disallowedCommands.includes(cmd)) { setDisallowedCommands([...disallowedCommands, cmd]); setNewDisallowedCommand(''); } }; const removeDisallowedCommand = (cmd) => { setDisallowedCommands(disallowedCommands.filter(c => c !== cmd)); }; return (
{/* Skip Permissions */}

{t('permissions.title')}

{/* Allowed Commands */}

{t('permissions.allowedCommands.title')}

{t('permissions.allowedCommands.description')}

setNewAllowedCommand(e.target.value)} placeholder={t('permissions.allowedCommands.placeholder')} onKeyPress={(e) => { if (e.key === 'Enter') { e.preventDefault(); addAllowedCommand(newAllowedCommand); } }} className="flex-1 h-10" />
{/* Quick add buttons */}

{t('permissions.allowedCommands.quickAdd')}

{commonCursorCommands.map(cmd => ( ))}
{allowedCommands.map(cmd => (
{cmd}
))} {allowedCommands.length === 0 && (
{t('permissions.allowedCommands.empty')}
)}
{/* Disallowed Commands */}

{t('permissions.blockedCommands.title')}

{t('permissions.blockedCommands.description')}

setNewDisallowedCommand(e.target.value)} placeholder={t('permissions.blockedCommands.placeholder')} onKeyPress={(e) => { if (e.key === 'Enter') { e.preventDefault(); addDisallowedCommand(newDisallowedCommand); } }} className="flex-1 h-10" />
{disallowedCommands.map(cmd => (
{cmd}
))} {disallowedCommands.length === 0 && (
{t('permissions.blockedCommands.empty')}
)}
{/* Help Section */}

{t('permissions.shellExamples.title')}

); } // Codex Permissions function CodexPermissions({ permissionMode, setPermissionMode }) { const { t } = useTranslation('settings'); return (

{t('permissions.codex.permissionMode')}

{t('permissions.codex.description')}

{/* Default Mode */}
setPermissionMode('default')} >
{/* Accept Edits Mode */}
setPermissionMode('acceptEdits')} >
{/* Bypass Permissions Mode */}
setPermissionMode('bypassPermissions')} >
{/* Technical Details */}
{t('permissions.codex.technicalDetails')}

{t('permissions.codex.modes.default.title')}: {t('permissions.codex.technicalInfo.default')}

{t('permissions.codex.modes.acceptEdits.title')}: {t('permissions.codex.technicalInfo.acceptEdits')}

{t('permissions.codex.modes.bypassPermissions.title')}: {t('permissions.codex.technicalInfo.bypassPermissions')}

{t('permissions.codex.technicalInfo.overrideNote')}

); } // Main component export default function PermissionsContent({ agent, ...props }) { if (agent === 'claude') { return ; } if (agent === 'cursor') { return ; } if (agent === 'codex') { return ; } return null; }