import type { Intent, ControlAction, ID, Timestamp, TrustLevel, TrustScore, EscalationRequest } from '../common/types.js';
/**
 * Risk score thresholds
 */
export interface RiskThresholds {
    /** Low risk threshold */
    low: number;
    /** Medium risk threshold */
    medium: number;
    /** High risk threshold */
    high: number;
    /** Critical risk threshold */
    critical: number;
}
/**
 * Default risk thresholds
 */
export declare const DEFAULT_RISK_THRESHOLDS: RiskThresholds;
/**
 * Risk level classification
 */
export type EscalationRiskLevel = 'minimal' | 'low' | 'medium' | 'high' | 'critical';
/**
 * Resource sensitivity levels
 */
export type ResourceSensitivity = 'public' | 'internal' | 'confidential' | 'restricted' | 'top-secret';
/**
 * Escalation target definition
 */
export interface EscalationTarget {
    /** Target identifier (user, role, group, or channel) */
    id: ID;
    /** Target type */
    type: 'user' | 'role' | 'group' | 'channel' | 'webhook';
    /** Target name */
    name: string;
    /** Notification channels */
    channels: NotificationChannel[];
    /** Whether target can approve/reject */
    canDecide: boolean;
    /** Priority for notification order */
    priority: number;
    /** Availability schedule */
    availability?: AvailabilitySchedule;
}
/**
 * Notification channel definition
 */
export interface NotificationChannel {
    /** Channel type */
    type: 'email' | 'slack' | 'teams' | 'webhook' | 'pagerduty' | 'sms';
    /** Channel-specific address/endpoint */
    address: string;
    /** Whether to use for urgent notifications */
    urgent?: boolean;
}
/**
 * Availability schedule for escalation targets
 */
export interface AvailabilitySchedule {
    /** Timezone */
    timezone: string;
    /** Available hours (HH:MM format) */
    availableHours?: {
        start: string;
        end: string;
    };
    /** Available days (0 = Sunday) */
    availableDays?: number[];
    /** Out of office periods */
    outOfOffice?: Array<{
        start: Timestamp;
        end: Timestamp;
        reason?: string;
        delegate?: ID;
    }>;
}
/**
 * Escalation rule definition
 */
export interface EscalationRule {
    /** Unique rule identifier */
    id: ID;
    /** Rule name */
    name: string;
    /** Rule description */
    description?: string;
    /** Whether rule is enabled */
    enabled: boolean;
    /** Rule priority (lower = higher priority) */
    priority: number;
    /** Conditions that trigger this rule */
    conditions: EscalationConditions;
    /** Escalation configuration */
    escalation: EscalationConfig;
    /** Metadata */
    metadata?: Record<string, unknown>;
}
/**
 * Conditions that trigger escalation
 */
export interface EscalationConditions {
    /** Risk score threshold (escalate if above) */
    riskScoreThreshold?: number;
    /** Risk level (escalate if matches or higher) */
    riskLevel?: EscalationRiskLevel;
    /** Action types that trigger escalation */
    actionTypes?: string[];
    /** Resource patterns that trigger escalation */
    resourcePatterns?: string[];
    /** Resource sensitivity levels that trigger escalation */
    resourceSensitivity?: ResourceSensitivity[];
    /** Intent types that trigger escalation */
    intentTypes?: string[];
    /** Trust levels that trigger escalation (escalate if below) */
    trustLevelBelow?: TrustLevel;
    /** Entity types that trigger escalation */
    entityTypes?: string[];
    /** Custom condition expression */
    customExpression?: string;
}
/**
 * Escalation configuration
 */
export interface EscalationConfig {
    /** Primary escalation targets */
    targets: EscalationTarget[];
    /** Timeout before auto-action */
    timeout: string;
    /** Action to take on timeout */
    timeoutAction: 'deny' | 'allow' | 're-escalate';
    /** Whether justification is required */
    requireJustification: boolean;
    /** Required number of approvals */
    requiredApprovals: number;
    /** Maximum escalation chain depth */
    maxChainDepth: number;
    /** Reminder intervals */
    reminderIntervals?: string[];
    /** Re-escalation targets (if primary doesn't respond) */
    reEscalationTargets?: EscalationTarget[];
    /** Re-escalation delay */
    reEscalationDelay?: string;
}
/**
 * Escalation match result
 */
export interface EscalationMatchResult {
    /** Rule that matched */
    rule: EscalationRule;
    /** Whether rule matched */
    matched: boolean;
    /** Match reason */
    reason: string;
    /** Computed risk score */
    riskScore: number;
    /** Computed risk level */
    riskLevel: EscalationRiskLevel;
    /** Selected targets */
    selectedTargets: EscalationTarget[];
    /** Match details */
    details: Record<string, unknown>;
}
/**
 * Escalation request with full context
 */
export interface EscalationRequestFull extends EscalationRequest {
    /** Associated rule ID */
    ruleId: ID;
    /** Risk score */
    riskScore: number;
    /** Risk level */
    riskLevel: EscalationRiskLevel;
    /** Selected targets */
    targets: EscalationTarget[];
    /** Justification (if provided) */
    justification?: string;
    /** Approvals received */
    approvals: EscalationApproval[];
    /** Rejections received */
    rejections: EscalationRejection[];
    /** Reminder count */
    remindersSent: number;
    /** Chain depth */
    chainDepth: number;
}
/**
 * Escalation approval record
 */
export interface EscalationApproval {
    /** Approver ID */
    approverId: ID;
    /** Approver name */
    approverName: string;
    /** Approval timestamp */
    approvedAt: Timestamp;
    /** Comments */
    comments?: string;
    /** Any conditions on approval */
    conditions?: string[];
}
/**
 * Escalation rejection record
 */
export interface EscalationRejection {
    /** Rejecter ID */
    rejecterId: ID;
    /** Rejecter name */
    rejecterName: string;
    /** Rejection timestamp */
    rejectedAt: Timestamp;
    /** Reason for rejection */
    reason: string;
}
/**
 * Context for escalation evaluation
 */
export interface EscalationContext {
    /** The intent being evaluated */
    intent: Intent;
    /** Trust score */
    trustScore: TrustScore;
    /** Trust level */
    trustLevel: TrustLevel;
    /** Computed risk score */
    riskScore?: number;
    /** Resource sensitivity (if known) */
    resourceSensitivity?: ResourceSensitivity;
    /** Additional context */
    context?: Record<string, unknown>;
    /** Environment data */
    environment?: {
        timestamp: Timestamp;
        timezone: string;
    };
}
/**
 * Escalation engine options
 */
export interface EscalationEngineOptions {
    /** Enable OpenTelemetry tracing */
    enableTracing?: boolean;
    /** Risk thresholds */
    riskThresholds?: RiskThresholds;
    /** Default timeout */
    defaultTimeout?: string;
    /** Default timeout action */
    defaultTimeoutAction?: 'deny' | 'allow' | 're-escalate';
    /** Notification handler */
    notificationHandler?: NotificationHandler;
}
/**
 * Notification handler interface
 */
export interface NotificationHandler {
    /** Send notification to target */
    notify(target: EscalationTarget, request: EscalationRequestFull, type: 'initial' | 'reminder' | 're-escalation'): Promise<boolean>;
}
/**
 * Default notification handler (logs notifications)
 */
export declare class LoggingNotificationHandler implements NotificationHandler {
    notify(target: EscalationTarget, request: EscalationRequestFull, type: 'initial' | 'reminder' | 're-escalation'): Promise<boolean>;
}
/**
 * EscalationRuleEngine for automatic escalation management
 */
export declare class EscalationRuleEngine {
    private rules;
    private activeEscalations;
    private options;
    private notificationHandler;
    constructor(options?: EscalationEngineOptions);
    /**
     * Evaluate whether escalation is needed
     */
    evaluate(context: EscalationContext): EscalationMatchResult | null;
    /**
     * Evaluate with OpenTelemetry tracing
     */
    evaluateWithTracing(context: EscalationContext): Promise<EscalationMatchResult | null>;
    /**
     * Create an escalation request from match result
     */
    createEscalation(context: EscalationContext, matchResult: EscalationMatchResult): Promise<EscalationRequestFull>;
    /**
     * Process an approval
     */
    processApproval(escalationId: ID, approval: Omit<EscalationApproval, 'approvedAt'>): EscalationRequestFull | null;
    /**
     * Process a rejection
     */
    processRejection(escalationId: ID, rejection: Omit<EscalationRejection, 'rejectedAt'>): EscalationRequestFull | null;
    /**
     * Process timeout
     */
    processTimeout(escalationId: ID): {
        request: EscalationRequestFull;
        action: ControlAction;
    } | null;
    /**
     * Send reminder
     */
    sendReminder(escalationId: ID): Promise<boolean>;
    /**
     * Evaluate a single rule
     */
    private evaluateRule;
    /**
     * Compute risk score from context
     */
    private computeRiskScore;
    /**
     * Classify risk level from score
     */
    private classifyRiskLevel;
    /**
     * Select available targets based on schedule
     */
    private selectAvailableTargets;
    /**
     * Check if target is available
     */
    private isTargetAvailable;
    /**
     * Send notifications to all targets
     */
    private sendNotifications;
    /**
     * Match value against pattern
     */
    private matchPattern;
    /**
     * Evaluate simple expression
     */
    private evaluateExpression;
    /**
     * Resolve field path from context
     */
    private resolveFieldPath;
    /**
     * Parse value string
     */
    private parseValue;
    /**
     * Add an escalation rule
     */
    addRule(rule: EscalationRule): void;
    /**
     * Remove a rule
     */
    removeRule(ruleId: ID): boolean;
    /**
     * Get a rule by ID
     */
    getRule(ruleId: ID): EscalationRule | undefined;
    /**
     * Get all rules
     */
    getAllRules(): EscalationRule[];
    /**
     * Get enabled rules
     */
    getEnabledRules(): EscalationRule[];
    /**
     * Get active escalation by ID
     */
    getEscalation(escalationId: ID): EscalationRequestFull | undefined;
    /**
     * Get all active escalations
     */
    getActiveEscalations(): EscalationRequestFull[];
    /**
     * Set notification handler
     */
    setNotificationHandler(handler: NotificationHandler): void;
    /**
     * Clear all rules and escalations
     */
    clear(): void;
    /**
     * Get engine statistics
     */
    getStats(): {
        totalRules: number;
        enabledRules: number;
        activeEscalations: number;
        pendingEscalations: number;
    };
}
/**
 * Create a new escalation rule engine instance
 */
export declare function createEscalationRuleEngine(options?: EscalationEngineOptions): EscalationRuleEngine;
/**
 * Create an escalation rule with defaults
 */
export declare function createEscalationRule(partial: Partial<EscalationRule> & Pick<EscalationRule, 'id' | 'name' | 'conditions' | 'escalation'>): EscalationRule;
/**
 * Create an escalation target
 */
export declare function createEscalationTarget(partial: Partial<EscalationTarget> & Pick<EscalationTarget, 'id' | 'type' | 'name'>): EscalationTarget;
//# sourceMappingURL=escalation-rules.d.ts.map