@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
JavaScript
/**
* 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