/**
 * Async Utilities Module
 *
 * Production-ready async patterns for rate limiting, throttling,
 * concurrency control, and caching with TTL.
 *
 * Principal Investigator: Bo Shang
 * Framework: agi-cli
 */
export interface RateLimiterConfig {
    maxRequests: number;
    windowMs: number;
}
export interface ThrottleConfig {
    intervalMs: number;
    leading?: boolean;
    trailing?: boolean;
}
export interface CacheEntry<T> {
    value: T;
    expiresAt: number;
}
export interface CacheConfig {
    ttlMs: number;
    maxSize?: number;
}
export interface ConcurrencyConfig {
    maxConcurrent: number;
    timeout?: number;
}
export declare class RateLimiter {
    private tokens;
    private lastRefill;
    private readonly maxTokens;
    private readonly refillRate;
    constructor(config: RateLimiterConfig);
    private refill;
    acquire(): Promise<void>;
    tryAcquire(): boolean;
    get availableTokens(): number;
}
export declare function throttle<T extends (...args: unknown[]) => unknown>(fn: T, config: ThrottleConfig): (...args: Parameters<T>) => ReturnType<T> | undefined;
export declare function debounce<T extends (...args: unknown[]) => unknown>(fn: T, delayMs: number): (...args: Parameters<T>) => void;
export declare class TTLCache<K, V> {
    private cache;
    private readonly ttlMs;
    private readonly maxSize;
    constructor(config: CacheConfig);
    get(key: K): V | undefined;
    set(key: K, value: V, ttlMs?: number): void;
    has(key: K): boolean;
    delete(key: K): boolean;
    clear(): void;
    get size(): number;
    private prune;
}
export declare function memoize<T extends (...args: unknown[]) => unknown>(fn: T, config: CacheConfig & {
    keyFn?: (...args: Parameters<T>) => string;
}): T;
export declare class ConcurrencyPool {
    private running;
    private queue;
    private readonly maxConcurrent;
    private readonly timeout;
    constructor(config: ConcurrencyConfig);
    run<T>(fn: () => Promise<T>): Promise<T>;
    private acquire;
    private release;
    get pending(): number;
    get active(): number;
}
export declare function parallelMap<T, R>(items: T[], fn: (item: T, index: number) => Promise<R>, concurrency?: number): Promise<R[]>;
export declare function sleep(ms: number): Promise<void>;
export declare function withTimeout<T>(promise: Promise<T>, timeoutMs: number, errorMessage?: string): Promise<T>;
export declare function retry<T>(fn: () => Promise<T>, config?: {
    maxRetries?: number;
    baseDelayMs?: number;
    maxDelayMs?: number;
    backoffMultiplier?: number;
    shouldRetry?: (error: unknown) => boolean;
}): Promise<T>;
declare const _default: {
    RateLimiter: typeof RateLimiter;
    TTLCache: typeof TTLCache;
    ConcurrencyPool: typeof ConcurrencyPool;
    throttle: typeof throttle;
    debounce: typeof debounce;
    memoize: typeof memoize;
    parallelMap: typeof parallelMap;
    sleep: typeof sleep;
    withTimeout: typeof withTimeout;
    retry: typeof retry;
};
export default _default;
//# sourceMappingURL=asyncUtils.d.ts.map