UNPKG

@agentdao/core

Version:

Core functionality, skills, and ready-made UI components for AgentDAO - Web3 subscriptions, content generation, social media, help support, live chat, RSS fetching, web search, and agent pricing integration

69 lines (68 loc) 2.05 kB
export interface RetryConfig { maxRetries: number; baseDelay: number; maxDelay: number; backoffMultiplier: number; } export interface RateLimitConfig { maxRequests: number; timeWindow: number; } export declare class RobustUtils { private static readonly DEFAULT_RETRY_CONFIG; private static readonly DEFAULT_RATE_LIMIT_CONFIG; private static requestCounts; /** * Execute function with retry logic */ static withRetry<T>(fn: () => Promise<T>, config?: Partial<RetryConfig>): Promise<T>; /** * Execute function with rate limiting */ static withRateLimit<T>(key: string, fn: () => Promise<T>, config?: Partial<RateLimitConfig>): Promise<T>; /** * Execute function with both retry and rate limiting */ static withRetryAndRateLimit<T>(key: string, fn: () => Promise<T>, retryConfig?: Partial<RetryConfig>, rateLimitConfig?: Partial<RateLimitConfig>): Promise<T>; /** * Validate API response */ static validateApiResponse(response: any, expectedFields: string[]): void; /** * Sanitize user input */ static sanitizeInput(input: string): string; /** * Validate search query */ static validateSearchQuery(query: string): { isValid: boolean; errors: string[]; }; /** * Validate content generation parameters */ static validateContentParams(params: any): { isValid: boolean; errors: string[]; }; /** * Create a circuit breaker */ static createCircuitBreaker(failureThreshold?: number, resetTimeout?: number): { execute<T>(fn: () => Promise<T>): Promise<T>; getState(): "CLOSED" | "OPEN" | "HALF_OPEN"; getFailureCount(): number; }; /** * Cache with TTL */ static createCache<T>(ttl?: number): { get(key: string): T | null; set(key: string, value: T): void; clear(): void; size(): number; }; private static isNonRetryableError; private static sleep; }