/** * Telegram Bot API Client * * Handles all HTTP requests to the Telegram API with: * - Configuration-based token management * - Structured logging * - Rate limiting (global + per-chat) * - Circuit breaker for cascading failure protection * - Automatic retries with exponential backoff * - Proper error handling */ /** * Error categories for classification and monitoring */ export declare enum ErrorCategory { VALIDATION = "VALIDATION",// Bad input (missing/invalid params) CLIENT = "CLIENT",// 4xx errors (bad request, forbidden, not found) SERVER = "SERVER",// 5xx errors (Telegram server issues) NETWORK = "NETWORK",// Connection failures RATE_LIMITED = "RATE_LIMITED",// 429 Too Many Requests TIMEOUT = "TIMEOUT",// Request timeout CIRCUIT_OPEN = "CIRCUIT_OPEN" } /** * Categorize an error based on response */ export declare function categorizeError(response: TelegramResponse): ErrorCategory; /** * Telegram API response structure */ export interface TelegramResponse { ok: boolean; result?: T; description?: string; error_code?: number; parameters?: { migrate_to_chat_id?: number; retry_after?: number; }; } /** * API call options */ interface ApiCallOptions { /** Request timeout in ms (uses config default if not specified) */ timeout?: number; /** Number of retries (uses config default if not specified) */ maxRetries?: number; /** Skip rate limiting check */ skipRateLimit?: boolean; } /** * Call the Telegram Bot API * * @param method - API method name (e.g., "sendMessage") * @param params - Method parameters * @param options - Call options (timeout, retries) * @returns API response */ export declare function callTelegramAPI(method: string, params?: Record, options?: ApiCallOptions): Promise>; /** * Format API response for MCP tool output */ export declare function formatResponse(response: TelegramResponse): string; /** * Create MCP tool result content */ export declare function createToolResult(response: TelegramResponse): { content: { type: "text"; text: string; }[]; isError: boolean; }; /** * Get circuit breaker status for health checks */ export declare function getCircuitBreakerStatus(): { state: "closed" | "open" | "half-open"; consecutiveFailures: number; }; /** * Get rate limiter status for health checks */ export declare function getRateLimiterStatus(): { requestsInWindow: number; limited: boolean; perChatTracked: number; }; export {}; //# sourceMappingURL=telegram-api.d.ts.map