/**
 * @module batch-operations
 * Batch operations support for xBind - enhanced API efficiency
 *
 * Provides batch operations for:
 * - Send: Multiple messages in one call (reduces round-trips)
 * - Receive: Batch envelope processing
 * - Registry: Bulk registration/revocation/updates
 *
 * Features:
 * - Atomic semantics where possible (registry operations)
 * - Partial success handling (graceful degradation)
 * - Progress tracking for long-running batches
 * - Performance optimization (parallel processing)
 */
import type { Result } from '@private.me/shared';
import type { Agent, AgentSendOptions, AgentMessage, AgentError, AgentReceiveOptions } from './agent.js';
import type { TrustRegistry, RegistryEntry, RegistryError } from './trust-registry.js';
import type { AnyTransportEnvelope } from './envelope.js';
import type { ProgressCallback } from '@private.me/ux-helpers';
/**
 * Options for batch send operations.
 */
export interface BatchSendOptions {
    /**
     * Messages to send in batch.
     * Each entry contains standard AgentSendOptions.
     */
    readonly messages: ReadonlyArray<AgentSendOptions>;
    /**
     * Batch execution strategy.
     *
     * - 'parallel': Send all messages concurrently (default, fastest)
     * - 'sequential': Send one at a time (preserves ordering)
     * - 'failfast': Stop on first error (parallel mode only)
     */
    readonly strategy?: 'parallel' | 'sequential' | 'failfast';
    /**
     * Maximum concurrent operations (parallel mode only).
     * Default: 10
     */
    readonly concurrency?: number;
    /**
     * Continue on partial failures.
     * When true, returns all results (success + failures).
     * When false, stops on first error.
     * Default: true
     */
    readonly continueOnError?: boolean;
    /**
     * Progress callback for batch operations.
     */
    readonly onProgress?: ProgressCallback;
}
/**
 * Result of a single operation in a batch.
 */
export interface BatchOperationResult<T> {
    /** Index of operation in original batch. */
    readonly index: number;
    /** Operation result (success or error). */
    readonly result: Result<T, AgentError | RegistryError>;
    /** Processing time in milliseconds. */
    readonly durationMs: number;
}
/**
 * Summary of batch operation results.
 */
export interface BatchSummary<T> {
    /** Total operations attempted. */
    readonly total: number;
    /** Number of successful operations. */
    readonly succeeded: number;
    /** Number of failed operations. */
    readonly failed: number;
    /** Individual operation results. */
    readonly results: ReadonlyArray<BatchOperationResult<T>>;
    /** Total batch processing time in milliseconds. */
    readonly totalDurationMs: number;
    /** Average operation time in milliseconds. */
    readonly avgDurationMs: number;
}
/**
 * Options for batch receive operations.
 */
export interface BatchReceiveOptions {
    /**
     * Envelopes to process in batch.
     */
    readonly envelopes: ReadonlyArray<AnyTransportEnvelope>;
    /**
     * Receive options applied to all envelopes.
     */
    readonly receiveOptions?: AgentReceiveOptions;
    /**
     * Batch execution strategy.
     * Default: 'parallel'
     */
    readonly strategy?: 'parallel' | 'sequential';
    /**
     * Maximum concurrent operations (parallel mode only).
     * Default: 10
     */
    readonly concurrency?: number;
    /**
     * Continue on partial failures.
     * Default: true
     */
    readonly continueOnError?: boolean;
    /**
     * Progress callback for batch operations.
     */
    readonly onProgress?: ProgressCallback;
}
/**
 * Registry operation for batch processing.
 */
export interface RegistryOperation {
    /** Operation type. */
    readonly type: 'register' | 'revoke' | 'updateScopes';
    /** DID being operated on. */
    readonly did: string;
    /** Registration parameters (register only). */
    readonly params?: {
        readonly publicKey: Uint8Array;
        readonly name: string;
        readonly scopes?: string[];
        readonly x25519PublicKey?: Uint8Array;
        readonly mlKemPublicKey?: Uint8Array;
        readonly mlDsaPublicKey?: Uint8Array;
        readonly xchange?: boolean;
        readonly receiveScopes?: string[];
        readonly sdkVersion?: string;
        readonly minEnvelopeVersion?: number;
        readonly maxEnvelopeVersion?: number;
        readonly ttlMs?: number;
    };
    /** New scopes (updateScopes only). */
    readonly newScopes?: string[];
}
/**
 * Options for batch registry operations.
 */
export interface BatchRegistryOptions {
    /**
     * Registry operations to perform.
     */
    readonly operations: ReadonlyArray<RegistryOperation>;
    /**
     * Atomic execution mode.
     *
     * - 'atomic': All operations succeed or all fail (transactional)
     * - 'best-effort': Apply as many as possible (default)
     *
     * Note: Atomic mode only supported by registries implementing transactions.
     */
    readonly atomic?: boolean;
    /**
     * Batch execution strategy.
     * Default: 'parallel'
     */
    readonly strategy?: 'parallel' | 'sequential';
    /**
     * Maximum concurrent operations (parallel mode only).
     * Default: 5 (lower than send/receive to avoid registry overload)
     */
    readonly concurrency?: number;
    /**
     * Progress callback for batch operations.
     */
    readonly onProgress?: ProgressCallback;
}
/**
 * Error thrown when batch operation fails.
 */
export declare class BatchOperationError extends Error {
    readonly summary: BatchSummary<unknown>;
    constructor(message: string, summary: BatchSummary<unknown>);
}
/**
 * Batch send multiple messages.
 *
 * Performance optimization: Sends messages in parallel (default) or sequentially.
 * Reduces round-trips for bulk message delivery.
 *
 * @param agent - Agent instance
 * @param options - Batch send options
 * @returns Batch summary with individual results
 *
 * @example
 * ```typescript
 * const agent = await Agent.create({ name: 'sender', registry });
 * const summary = await batchSend(agent, {
 *   messages: [
 *     { to: 'did:key:abc', payload: { msg: 1 }, scope: 'chat' },
 *     { to: 'did:key:def', payload: { msg: 2 }, scope: 'chat' },
 *   ],
 *   strategy: 'parallel',
 * });
 * console.log(`Sent ${summary.succeeded}/${summary.total} messages`);
 * ```
 */
export declare function batchSend(agent: Agent, options: BatchSendOptions): Promise<BatchSummary<void>>;
/**
 * Batch receive multiple envelopes.
 *
 * Performance optimization: Processes envelopes in parallel (default).
 * Useful for bulk message ingestion from queues or webhooks.
 *
 * @param agent - Agent instance
 * @param options - Batch receive options
 * @returns Batch summary with individual results
 *
 * @example
 * ```typescript
 * const agent = await Agent.create({ name: 'receiver', registry });
 * const summary = await batchReceive(agent, {
 *   envelopes: incomingEnvelopes,
 *   strategy: 'parallel',
 * });
 * console.log(`Processed ${summary.succeeded}/${summary.total} envelopes`);
 * ```
 */
export declare function batchReceive(agent: Agent, options: BatchReceiveOptions): Promise<BatchSummary<AgentMessage>>;
/**
 * Batch registry operations (register, revoke, updateScopes).
 *
 * Performance optimization: Groups operations by type for efficient processing.
 * Atomic semantics: When atomic=true, all operations succeed or all fail.
 *
 * @param registry - Trust registry instance
 * @param options - Batch registry options
 * @returns Batch summary with individual results
 *
 * @example
 * ```typescript
 * const summary = await batchRegistryOps(registry, {
 *   operations: [
 *     { type: 'register', did: 'did:key:abc', params: { publicKey, name: 'Alice' } },
 *     { type: 'revoke', did: 'did:key:old' },
 *   ],
 *   atomic: false, // best-effort mode
 * });
 * console.log(`Completed ${summary.succeeded}/${summary.total} operations`);
 * ```
 */
export declare function batchRegistryOps(registry: TrustRegistry, options: BatchRegistryOptions): Promise<BatchSummary<void>>;
/**
 * Batch resolve multiple DIDs.
 *
 * Performance optimization: Resolves DIDs in parallel.
 * Useful for resolving recipient keys before bulk message sending.
 *
 * @param registry - Trust registry instance
 * @param dids - DIDs to resolve
 * @param options - Optional progress callback and concurrency
 * @returns Batch summary with resolution results
 *
 * @example
 * ```typescript
 * const summary = await batchResolve(registry, [
 *   'did:key:abc',
 *   'did:key:def',
 *   'did:key:ghi',
 * ]);
 * const keys = summary.results
 *   .filter(r => r.result.ok)
 *   .map(r => r.result.value);
 * ```
 */
export declare function batchResolve(registry: TrustRegistry, dids: ReadonlyArray<string>, options?: {
    readonly concurrency?: number;
    readonly onProgress?: ProgressCallback;
}): Promise<BatchSummary<Uint8Array>>;
/**
 * Batch get registry entries.
 *
 * Performance optimization: Fetches entries in parallel.
 * Returns full registry metadata for multiple DIDs.
 *
 * @param registry - Trust registry instance
 * @param dids - DIDs to fetch
 * @param options - Optional progress callback and concurrency
 * @returns Batch summary with entry results
 *
 * @example
 * ```typescript
 * const summary = await batchGetEntries(registry, dids);
 * const entries = summary.results
 *   .filter(r => r.result.ok)
 *   .map(r => r.result.value);
 * ```
 */
export declare function batchGetEntries(registry: TrustRegistry, dids: ReadonlyArray<string>, options?: {
    readonly concurrency?: number;
    readonly onProgress?: ProgressCallback;
}): Promise<BatchSummary<RegistryEntry>>;
