/**
 * ApprovalQueue -- Manages APPROVAL_REQUIRED workflow for tool access.
 *
 * When a tool call requires human approval, it's queued here. Supports:
 *   - Timeout with configurable default action (deny)
 *   - Escalation to a designated escalation agent
 *   - Delegation (approved by another authorized agent)
 *   - Persistent queue (survives process restart)
 *
 * Required by:
 *   - SOC 2 CC6.1: Logical and physical access
 *   - HIPAA 164.312(a)(1): Access control
 *   - ISO 27001 A.9.2.3: Management of privileged access
 *
 * @connexum/ai-governance
 */
export interface ApprovalQueueConfig {
    /** Directory for persistent queue storage */
    queueDir: string;
    /** Default timeout in ms (default: 300000 = 5 min) */
    timeoutMs?: number;
    /** Action on timeout: 'deny' | 'escalate' (default: 'deny') */
    timeoutAction?: 'deny' | 'escalate';
    /** Agent to escalate to on timeout (required if timeoutAction is 'escalate') */
    escalationTarget?: string;
    /** Agents authorized to approve on behalf of a human */
    delegateApprovers?: string[];
    /** Maximum queue size (default: 100) */
    maxQueueSize?: number;
    /** HMAC secret for verifying human approval tokens */
    approvalSecret?: string;
    /**
     * DA-HIGH-5: when true, the constructor throws if `approvalSecret` is
     * missing or under 32 chars. The CLI and governance-server init set
     * this to true whenever a HITL-required compliance pack (HIPAA, PCI
     * DSS, SOC 2, etc.) is active -- without the secret, human approval
     * tokens cannot be HMAC-verified and the human-in-the-loop control
     * degrades to a rubber stamp.
     */
    requireSecret?: boolean;
    /**
     * P4-RET-01: Optional DataClassifier for stamping DataClassTag on every
     * approval-queue insert. When provided, submit() classifies the record at
     * the 'approval-queue:insert' write site using the supplied tenantId and
     * contractId. Writes are refused if classification throws.
     *
     * TODO(P4-RET-04 migration): once the Prisma ApprovalRequest model gains
     * packBinding/dataClass columns, make this required (not optional).
     */
    dataClassifier?: import('../retention/classifier').DataClassifier;
    /** Tenant ID used by the DataClassifier. Required when dataClassifier is set. */
    tenantId?: string;
    /** Contract ID used by the DataClassifier. Required when dataClassifier is set. */
    contractId?: string;
    /** Active pack IDs for the tenant. Required when dataClassifier is set. */
    activePackIds?: string[];
}
/**
 * DA-HIGH-5: returns true if any pack in the given list requires the
 * `approval-queue` module, i.e. enforces human-in-the-loop. Used by
 * higher-level init code (governance-server, CLI) to decide whether
 * to pass `requireSecret: true` into the ApprovalQueue constructor.
 *
 * The import of CompliancePack type is deferred via duck-typing so
 * this module stays at the bottom of the dependency graph.
 */
export declare function packsRequireApprovalQueue(packs: Array<{
    requiredModules?: Array<{
        name: string;
        required?: boolean;
    }>;
}>): boolean;
export type ApprovalStatus = 'pending' | 'approved' | 'denied' | 'expired' | 'escalated';
export interface ApprovalRequest {
    /** Unique request ID */
    id: string;
    /** Agent requesting the tool call */
    agent: string;
    /** Tool being requested */
    tool: string;
    /** Tool input summary (redacted of secrets) */
    inputSummary: string;
    /** Reason for the request */
    reason: string;
    /** Current status */
    status: ApprovalStatus;
    /** When the request was created */
    createdAt: string;
    /** When the request expires */
    expiresAt: string;
    /** Who approved/denied (human or delegate agent) */
    resolvedBy?: string;
    /** When it was resolved */
    resolvedAt?: string;
    /** Resolution note */
    note?: string;
    /**
     * P4-RET-01: Data classification tag stamped at ingestion time.
     * Present when the caller supplies a DataClassifier via ApprovalQueueConfig.
     *
     * TODO(P4-RET-04 migration): Prisma `ApprovalRequest` model needs a
     * `packBinding String[]` column and a `dataClass String` column. Do NOT
     * run this migration until P4-RET-04 cycle. When the DB model gains these
     * columns, remove this JSONL-embedded tag and rely on the DB columns instead.
     *
     * Prisma model diff (add to schema.prisma when P4-RET-04 lands):
     *   dataClass    String?
     *   packBinding  String[]   (Postgres array; SQLite: JSON column)
     *   sovereigntyZone String?
     *   classifiedAt DateTime?
     */
    dataClassTag?: import('../retention/data-class').DataClassTag;
}
export interface ApprovalDecision {
    requestId: string;
    status: 'approved' | 'denied';
    resolvedBy: string;
    note?: string;
    /** HMAC token proving human authorization: HMAC(approvalSecret, requestId + ':' + status) */
    approvalToken?: string;
}
export declare class ApprovalQueue {
    private config;
    private queue;
    private queueFile;
    constructor(config: ApprovalQueueConfig);
    /**
     * Submit a tool call for approval.
     * Returns the request ID for polling.
     */
    submit(agent: string, tool: string, inputSummary: string, reason: string): ApprovalRequest;
    /**
     * Resolve an approval request (approve or deny).
     * Only humans or authorized delegate agents can resolve.
     */
    resolve(decision: ApprovalDecision): ApprovalRequest;
    /**
     * Check the status of a request. Handles timeout/escalation.
     */
    check(requestId: string): ApprovalRequest | null;
    /**
     * Get all pending requests.
     */
    getPending(): ApprovalRequest[];
    /**
     * Get all requests for a specific agent.
     */
    getByAgent(agent: string): ApprovalRequest[];
    /**
     * Get all escalated requests that need attention.
     */
    getEscalated(): ApprovalRequest[];
    /**
     * Get queue statistics.
     */
    getStats(): {
        total: number;
        pending: number;
        approved: number;
        denied: number;
        expired: number;
        escalated: number;
    };
    /**
     * Clear resolved requests older than the given age in ms.
     */
    cleanup(maxAgeMs?: number): number;
    private pruneExpired;
    private saveToDisk;
    private loadFromDisk;
}
//# sourceMappingURL=approval-queue.d.ts.map