/**
 * Elevated Mode Module
 *
 * Permission management for elevated/privileged operations.
 */
import { EventEmitter } from 'events';
export type PermissionLevel = 'user' | 'elevated' | 'admin' | 'system';
export type PermissionCategory = 'file:read' | 'file:write' | 'file:delete' | 'file:execute' | 'process:spawn' | 'process:kill' | 'network:connect' | 'network:listen' | 'network:modify' | 'system:info' | 'system:modify' | 'system:shutdown' | 'credential:read' | 'credential:write';
export interface Permission {
    /** Permission category */
    category: PermissionCategory;
    /** Resource pattern (glob) */
    resource?: string;
    /** Required level */
    level: PermissionLevel;
    /** Description */
    description?: string;
}
export interface PermissionRequest {
    /** Unique request ID */
    id: string;
    /** Requested permission */
    permission: Permission;
    /** Requesting context */
    context: {
        /** Source (tool name, etc.) */
        source: string;
        /** Reason for request */
        reason?: string;
        /** Additional metadata */
        metadata?: Record<string, unknown>;
    };
    /** Request timestamp */
    timestamp: Date;
    /** Timeout in ms */
    timeoutMs?: number;
}
export interface PermissionGrant {
    /** Grant ID */
    id: string;
    /** Associated request ID */
    requestId: string;
    /** Granted permission */
    permission: Permission;
    /** Grant type */
    type: 'allow-once' | 'allow-session' | 'allow-always' | 'deny';
    /** Expiration timestamp */
    expiresAt?: Date;
    /** Grant timestamp */
    grantedAt: Date;
    /** Who granted (user, auto, etc.) */
    grantedBy: string;
}
export interface ElevatedSession {
    /** Session ID */
    id: string;
    /** Current permission level */
    level: PermissionLevel;
    /** Elevated since */
    elevatedAt?: Date;
    /** Elevation expires at */
    expiresAt?: Date;
    /** Granted permissions */
    grants: Map<string, PermissionGrant>;
    /** Request history */
    requestHistory: PermissionRequest[];
}
export interface ElevatedModeConfig {
    /** Default permission level */
    defaultLevel: PermissionLevel;
    /** Session elevation timeout (ms) */
    elevationTimeoutMs: number;
    /** Auto-grant safe permissions */
    autoGrantSafe: boolean;
    /** Request timeout (ms) */
    requestTimeoutMs: number;
    /** Require confirmation for elevated */
    requireConfirmation: boolean;
    /** Safe permission categories */
    safeCategories: PermissionCategory[];
    /** Dangerous permission categories */
    dangerousCategories: PermissionCategory[];
    /** Max grants per session */
    maxGrantsPerSession: number;
}
export declare const DEFAULT_ELEVATED_CONFIG: ElevatedModeConfig;
export interface ElevatedModeEvents {
    'permission-request': (request: PermissionRequest) => void;
    'permission-grant': (grant: PermissionGrant) => void;
    'permission-deny': (request: PermissionRequest, reason: string) => void;
    'level-change': (from: PermissionLevel, to: PermissionLevel) => void;
    'session-expire': (session: ElevatedSession) => void;
    'grant-expire': (grant: PermissionGrant) => void;
}
/**
 * Compare permission levels
 */
export declare function compareLevels(a: PermissionLevel, b: PermissionLevel): number;
/**
 * Check if level meets requirement
 */
export declare function meetsLevel(current: PermissionLevel, required: PermissionLevel): boolean;
/**
 * Check if permission matches a pattern
 */
export declare function matchesPattern(resource: string, pattern: string): boolean;
/**
 * Create a permission key
 */
export declare function permissionKey(permission: Permission): string;
export declare class ElevatedModeManager extends EventEmitter {
    private config;
    private session;
    private pendingRequests;
    private expirationTimer;
    constructor(config?: Partial<ElevatedModeConfig>);
    private createSession;
    /**
     * Check if permission is granted
     */
    hasPermission(permission: Permission): boolean;
    /**
     * Check if permission is safe (auto-grantable)
     */
    isSafePermission(permission: Permission): boolean;
    /**
     * Check if permission is dangerous
     */
    isDangerousPermission(permission: Permission): boolean;
    /**
     * Request a permission
     */
    requestPermission(category: PermissionCategory, options?: {
        resource?: string;
        reason?: string;
        source?: string;
        metadata?: Record<string, unknown>;
    }): Promise<PermissionGrant | null>;
    /**
     * Grant a pending request
     */
    grantRequest(requestId: string, type?: 'allow-once' | 'allow-session' | 'allow-always', grantedBy?: string): PermissionGrant | null;
    /**
     * Deny a pending request
     */
    denyRequest(requestId: string, reason?: string): void;
    /**
     * Create a grant
     */
    private createGrant;
    /**
     * Get required level for a category
     */
    private getRequiredLevel;
    /**
     * Get current permission level
     */
    getLevel(): PermissionLevel;
    /**
     * Elevate to a higher level
     */
    elevate(level: PermissionLevel, durationMs?: number): boolean;
    /**
     * Drop elevation back to default
     */
    dropElevation(): void;
    /**
     * Check if elevated
     */
    isElevated(): boolean;
    /**
     * Get time until elevation expires
     */
    getElevationTimeRemaining(): number;
    /**
     * Get all grants
     */
    getGrants(): PermissionGrant[];
    /**
     * Revoke a grant
     */
    revokeGrant(grantId: string): boolean;
    /**
     * Revoke all grants for a category
     */
    revokeCategory(category: PermissionCategory): number;
    /**
     * Clear all grants
     */
    clearGrants(): void;
    /**
     * Get session info
     */
    getSession(): {
        id: string;
        level: PermissionLevel;
        elevatedAt?: Date;
        expiresAt?: Date;
        grantCount: number;
        requestCount: number;
        pendingCount: number;
    };
    /**
     * Get request history
     */
    getRequestHistory(): PermissionRequest[];
    /**
     * Reset session
     */
    resetSession(): void;
    /**
     * Get configuration
     */
    getConfig(): ElevatedModeConfig;
    /**
     * Update configuration
     */
    updateConfig(config: Partial<ElevatedModeConfig>): void;
}
export declare function getElevatedMode(config?: Partial<ElevatedModeConfig>): ElevatedModeManager;
export declare function resetElevatedMode(): void;
