UNPKG

@hivetechs/hive-ai

Version:

Real-time streaming AI consensus platform with HTTP+SSE MCP integration for Claude Code, VS Code, Cursor, and Windsurf - powered by OpenRouter's unified API

55 lines • 2.66 kB
/** * Circuit Breaker Reset Tool * * Allows manual reset of circuit breakers for specific provider/model combinations. * Useful when a temporary issue has been resolved and normal operation should resume. */ import { z } from "zod"; import { globalErrorHandler } from '../error-handling.js'; import { globalHealthMonitor } from '../health-monitor.js'; export const CircuitBreakerResetToolSchema = z.object({ provider: z.string().describe('Provider name (e.g., openai, anthropic, google)'), model: z.string().describe('Model name (e.g., gpt-4o, claude-3-5-sonnet)') }); export async function runCircuitBreakerResetTool(args) { try { const { provider, model } = args; // Reset the circuit breaker const resetSuccess = globalErrorHandler.resetCircuitBreaker(provider, model); if (!resetSuccess) { return { result: `āš ļø No circuit breaker found for ${provider}/${model}. It may not have been used yet or is already in normal state.` }; } // Force a health check to verify the reset await globalHealthMonitor.runHealthChecks(); // Check if the model is now available const isAvailable = globalHealthMonitor.isModelAvailable(provider, model); const modelHealth = globalHealthMonitor.getModelHealth(provider, model); let result = `āœ… Circuit breaker reset for ${provider}/${model}\n\n`; if (isAvailable) { result += `šŸ”„ Model is now available for use\n`; } else { result += `āš ļø Model may still be experiencing issues\n`; } if (modelHealth) { result += `šŸ“Š Current status:\n`; result += ` • Status: ${modelHealth.status}\n`; result += ` • Success Rate: ${modelHealth.successRate}%\n`; result += ` • Avg Response Time: ${modelHealth.avgResponseTime}ms\n`; result += ` • Error Count: ${modelHealth.errorCount}\n`; } result += `\nšŸ’” The model will be tested on the next consensus request.\n`; result += `šŸ“‹ Use 'hive-ai health --detailed' to see full circuit breaker status.`; return { result }; } catch (error) { return { result: `āŒ Error resetting circuit breaker: ${error instanceof Error ? error.message : 'Unknown error'}` }; } } export const circuitBreakerResetToolName = 'circuit_breaker_reset'; export const circuitBreakerResetToolDescription = 'Reset circuit breaker for a specific provider/model combination to resume normal operation'; //# sourceMappingURL=circuit-breaker-reset.js.map