/**
 * Execpolicy Framework
 *
 * Granular command authorization system inspired by Codex CLI.
 * Provides fine-grained control over which commands can be executed
 * and with what parameters.
 */
import { EventEmitter } from 'events';
export type PolicyAction = 'allow' | 'deny' | 'ask' | 'sandbox';
export interface PolicyRule {
    /** Unique rule ID */
    id: string;
    /** Rule name */
    name: string;
    /** Rule description */
    description?: string;
    /** Command pattern (glob or regex) */
    pattern: string;
    /** Whether pattern is regex */
    isRegex?: boolean;
    /** Action to take */
    action: PolicyAction;
    /** Additional constraints */
    constraints?: {
        /** Allowed arguments patterns */
        allowedArgs?: string[];
        /** Denied arguments patterns */
        deniedArgs?: string[];
        /** Allowed working directories */
        allowedDirs?: string[];
        /** Denied working directories */
        deniedDirs?: string[];
        /** Max execution time (ms) */
        maxTimeout?: number;
        /** Require sandbox */
        requireSandbox?: boolean;
        /** Allow network */
        allowNetwork?: boolean;
    };
    /** Priority (higher = evaluated first) */
    priority: number;
    /** Whether rule is enabled */
    enabled: boolean;
    /** Creation timestamp */
    createdAt: number;
    /** Tags for organization */
    tags?: string[];
}
export interface PolicyEvaluation {
    command: string;
    args: string[];
    workDir: string;
    matchedRule: PolicyRule | null;
    action: PolicyAction;
    reason: string;
    constraints: PolicyRule['constraints'];
    timestamp: number;
}
export interface ExecPolicyConfig {
    /** Default action when no rules match */
    defaultAction: PolicyAction;
    /** Enable audit logging */
    auditLog: boolean;
    /** Max audit log entries */
    maxAuditEntries: number;
    /** Rules file path */
    rulesPath?: string;
    /** Enable dangerous command detection */
    detectDangerous: boolean;
}
export declare class ExecPolicy extends EventEmitter {
    private config;
    private rules;
    private auditLog;
    private initialized;
    constructor(config?: Partial<ExecPolicyConfig>);
    /**
     * Initialize policy system
     */
    initialize(): Promise<void>;
    /**
     * Evaluate command against policy
     */
    evaluate(command: string, args?: string[], workDir?: string): PolicyEvaluation;
    /**
     * Quick check if command is allowed
     */
    isAllowed(command: string, args?: string[], workDir?: string): boolean;
    /**
     * Add custom rule
     */
    addRule(rule: Omit<PolicyRule, 'id' | 'createdAt'>): PolicyRule;
    /**
     * Remove rule by ID
     */
    removeRule(id: string): boolean;
    /**
     * Update rule
     */
    updateRule(id: string, updates: Partial<PolicyRule>): PolicyRule | null;
    /**
     * Get all rules
     */
    getRules(includeBuiltin?: boolean): PolicyRule[];
    /**
     * Get rule by ID
     */
    getRule(id: string): PolicyRule | null;
    /**
     * Get audit log
     */
    getAuditLog(limit?: number): PolicyEvaluation[];
    /**
     * Clear audit log
     */
    clearAuditLog(): void;
    /**
     * Export rules to JSON
     */
    exportRules(includeBuiltin?: boolean): string;
    /**
     * Import rules from JSON
     */
    importRules(json: string, replace?: boolean): number;
    /**
     * Save rules to file
     */
    saveRules(filePath?: string): Promise<void>;
    /**
     * Format policy dashboard
     */
    formatDashboard(): string;
    private matchesRule;
    private matchGlob;
    private detectDangerous;
    private recordAudit;
    private loadRulesFromFile;
}
export declare function getExecPolicy(config?: Partial<ExecPolicyConfig>): ExecPolicy;
export declare function initializeExecPolicy(config?: Partial<ExecPolicyConfig>): Promise<ExecPolicy>;
export declare function resetExecPolicy(): void;
