import { evaluate, merge, toRuleset } from "./evaluate.js";
export { evaluate, merge, toRuleset };
export const KNOWN_PERMISSIONS = [
    "read",
    "edit",
    "write",
    "glob",
    "grep",
    "list",
    "bash",
    "task",
    "external_directory",
    "todowrite",
    "question",
    "webfetch",
    "websearch",
    "repo_clone",
    "repo_overview",
    "lsp",
    "doom_loop",
    "skill",
];
export function disabled(permission, ruleset) {
    return evaluate(permission, "*", ruleset).action === "deny";
}
export class PermissionManager {
    ruleset = [];
    constructor(config) {
        if (config) {
            this.ruleset = toRuleset(config);
        }
    }
    getRuleset() {
        return [...this.ruleset];
    }
    update(config) {
        this.ruleset = toRuleset(config);
    }
    merge(other) {
        this.ruleset = merge(this.ruleset, other);
    }
    check(permission, pattern = "*") {
        return evaluate(permission, pattern, this.ruleset).action;
    }
    isDenied(permission, pattern = "*") {
        return this.check(permission, pattern) === "deny";
    }
    isAllowed(permission, pattern = "*") {
        return this.check(permission, pattern) === "allow";
    }
    needsAsk(permission, pattern = "*") {
        return this.check(permission, pattern) === "ask";
    }
    findMatchingRule(permission, pattern = "*") {
        return evaluate(permission, pattern, this.ruleset);
    }
}
//# sourceMappingURL=index.js.map