import { EventEmitter } from "node:events";
import { ToolPermissionLevel, type ResolvedToolPermission } from "./governance.js";
/** User's consent decision */
export declare enum ConsentDecision {
    /** Allow this single invocation */
    ALLOW_ONCE = "allow_once",
    /** Deny this single invocation */
    DENY_ONCE = "deny_once",
    /** Allow always for this tool pattern (session-scoped) */
    ALLOW_ALWAYS = "allow_always",
    /** Deny always for this tool pattern (session-scoped) */
    DENY_ALWAYS = "deny_always"
}
/** Scope for persistent decisions */
export declare enum ConsentScope {
    /** Only for this session */
    SESSION = "session",
    /** Persist across sessions (stored in config) */
    PERMANENT = "permanent"
}
/** A pending consent request presented to the user */
export interface ConsentRequest {
    /** Unique request ID */
    id: string;
    /** ISO 8601 timestamp */
    timestamp: string;
    /** Tool name being invoked */
    toolName: string;
    /** MCP server providing the tool */
    serverName: string;
    /** Arguments passed to the tool (sanitized) */
    args: Record<string, unknown>;
    /** Resolved permission that triggered this request */
    permission: ResolvedToolPermission;
    /** Matched rule reason (if any) */
    reason?: string;
    /** Rule severity */
    severity?: string;
    /** Rule category */
    category?: string;
}
/** Result of a consent flow */
export interface ConsentResult {
    /** The decision made */
    decision: ConsentDecision;
    /** The original request */
    request: ConsentRequest;
    /** ISO 8601 timestamp of decision */
    decidedAt: string;
    /** Scope of the decision */
    scope: ConsentScope;
}
/** Stored consent decision for future reference */
export interface StoredConsent {
    /** Tool name pattern */
    toolPattern: string;
    /** Server name (null = any server) */
    serverName: string | null;
    /** Decision (allow or deny) */
    permission: ToolPermissionLevel.ALLOW | ToolPermissionLevel.DENY;
    /** Scope */
    scope: ConsentScope;
    /** ISO 8601 timestamp when stored */
    storedAt: string;
    /** Optional reason */
    reason?: string;
}
export interface ConsentFlowOptions {
    /** Auto-deny if no response within timeout (ms, 0 = no timeout) */
    timeoutMs?: number;
    /** Default scope for decisions */
    defaultScope?: ConsentScope;
    /** Whether to emit events for UI integration */
    emitEvents?: boolean;
}
export declare class ConsentFlowManager extends EventEmitter {
    private decisions;
    private pendingRequests;
    private options;
    constructor(options?: ConsentFlowOptions);
    /**
     * Check if a tool invocation needs consent.
     * Returns null if already decided, or a ConsentRequest if user input is needed.
     */
    checkConsent(toolName: string, serverName: string, args: Record<string, unknown>, resolved: ResolvedToolPermission): ConsentRequest | null;
    /**
     * Record a user's consent decision.
     */
    recordDecision(requestId: string, decision: ConsentDecision, scope?: ConsentScope): ConsentResult;
    /**
     * Resolve permission considering stored consent decisions.
     * Returns the effective permission (ALLOW/DENY) or null if still ASK.
     */
    resolveConsent(toolName: string, serverName: string): ToolPermissionLevel.ALLOW | ToolPermissionLevel.DENY | null;
    /**
     * Get all stored decisions.
     */
    getStoredDecisions(): StoredConsent[];
    /**
     * Remove a stored decision by tool pattern.
     */
    removeDecision(toolPattern: string, serverName?: string): boolean;
    /**
     * Clear all stored decisions.
     */
    clearDecisions(): void;
    /**
     * Get pending consent requests.
     */
    getPendingRequests(): ConsentRequest[];
    /**
     * Cancel a pending consent request.
     */
    cancelRequest(requestId: string): boolean;
    /**
     * Format a consent request for terminal display.
     */
    static formatRequest(request: ConsentRequest): string;
    /**
     * Format a consent result for terminal display.
     */
    static formatResult(result: ConsentResult): string;
    private static getSeverityIcon;
    private getStoredDecision;
    private makeKey;
}
/**
 * Interactive CLI consent prompt using readline.
 * Returns the user's decision.
 */
export declare function promptConsent(request: ConsentRequest, inputStream?: NodeJS.ReadableStream, outputStream?: NodeJS.WritableStream): Promise<ConsentDecision>;
/**
 * Wraps a PermissionMatcher with consent flow.
 * When permission resolves to ASK, triggers consent flow.
 */
export declare class ConsentAwareResolver {
    private consentManager;
    constructor(consentManager?: ConsentFlowManager);
    /**
     * Get the underlying consent manager.
     */
    getConsentManager(): ConsentFlowManager;
    /**
     * Resolve permission with consent flow.
     * Returns ALLOW or DENY (never ASK — consent is resolved before returning).
     */
    resolveWithConsent(toolName: string, serverName: string, args: Record<string, unknown>, resolved: ResolvedToolPermission): {
        permission: ToolPermissionLevel.ALLOW | ToolPermissionLevel.DENY;
        consentRequest?: ConsentRequest;
        consentResult?: ConsentResult;
    };
}
