( input: z.infer<typeof BashTool.inputSchema>, toolPermissionContext: ToolPermissionContext, )
| 70 | * - 'passthrough' if no mode-specific handling applies |
| 71 | */ |
| 72 | export function checkPermissionMode( |
| 73 | input: z.infer<typeof BashTool.inputSchema>, |
| 74 | toolPermissionContext: ToolPermissionContext, |
| 75 | ): PermissionResult { |
| 76 | // Skip if in bypass mode (handled elsewhere) |
| 77 | if (toolPermissionContext.mode === 'bypassPermissions') { |
| 78 | return { |
| 79 | behavior: 'passthrough', |
| 80 | message: 'Bypass mode is handled in main permission flow', |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | // Skip if in dontAsk mode (handled in main permission flow) |
| 85 | if (toolPermissionContext.mode === 'dontAsk') { |
| 86 | return { |
| 87 | behavior: 'passthrough', |
| 88 | message: 'DontAsk mode is handled in main permission flow', |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | const commands = splitCommand_DEPRECATED(input.command) |
| 93 | |
| 94 | // Check each subcommand |
| 95 | for (const cmd of commands) { |
| 96 | const result = validateCommandForMode(cmd, toolPermissionContext) |
| 97 | |
| 98 | // If any command triggers mode-specific behavior, return that result |
| 99 | if (result.behavior !== 'passthrough') { |
| 100 | return result |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | // No mode-specific handling needed |
| 105 | return { |
| 106 | behavior: 'passthrough', |
| 107 | message: 'No mode-specific validation required', |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | export function getAutoAllowedCommands( |
| 112 | mode: ToolPermissionContext['mode'], |
no test coverage detected