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 */}
{/* Allowed Tools */}
{t('permissions.allowedTools.title')}
{t('permissions.allowedTools.description')}
{/* 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')}
{disallowedTools.map(tool => (
{tool}
))}
{disallowedTools.length === 0 && (
{t('permissions.blockedTools.empty')}
)}
{/* Help Section */}
{t('permissions.toolExamples.title')}
"Bash(git log:*)" {t('permissions.toolExamples.bashGitLog')}
"Bash(git diff:*)" {t('permissions.toolExamples.bashGitDiff')}
"Write" {t('permissions.toolExamples.write')}
"Bash(rm:*)" {t('permissions.toolExamples.bashRm')}
);
}
// 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 */}
{/* Allowed Commands */}
{t('permissions.allowedCommands.title')}
{t('permissions.allowedCommands.description')}
{/* 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')}
{disallowedCommands.map(cmd => (
{cmd}
))}
{disallowedCommands.length === 0 && (
{t('permissions.blockedCommands.empty')}
)}
{/* Help Section */}
{t('permissions.shellExamples.title')}
"Shell(ls)" {t('permissions.shellExamples.ls')}
"Shell(git status)" {t('permissions.shellExamples.gitStatus')}
"Shell(npm install)" {t('permissions.shellExamples.npmInstall')}
"Shell(rm -rf)" {t('permissions.shellExamples.rmRf')}
);
}
// 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;
}