/**
 * Manage permissions for LLM usage.
 *
 * Main features:
 * - Manage user permissions
 * - Manage tool permissions
 *
 * Basic principle
 * - LLMs cannot use tools that are in the denylist
 * - LLMs can use tools that are in the allowlist
 * - LLMs cannot use tools that are not in the allowlist
 * - LLMs can ask the user to add a tool to the allow list
 * - LLMs can use tools in the confirmlist by asking the user to confirm each use
 *
 * This module manages the permissions part of the config file and is loaded into the agent context
 *
 * This module focused on the [permissions] section of the config file
 *
 */

pub struct ProgramPermissions {
    allowlist: Vec<String>,
    denylist: Vec<String>,
    confirmlist: Vec<String>,
}

pub enum PermissionStatus {
    Allowed,
    Denied,
    Confirmed,
}

impl ProgramPermissions {
    pub fn check_permission(&self, program: &str) -> PermissionStatus {
        if self.denylist.contains(&program.to_string()) {
            PermissionStatus::Denied
        } else if self.confirmlist.contains(&program.to_string()) {
            PermissionStatus::Confirmed
        } else {
            PermissionStatus::Allowed
        }
    }
}
