@juspay/neurolink
Version:
Universal AI Development Platform with working MCP integration, multi-provider support, voice (TTS/STT/realtime), and professional CLI. 58+ external MCP servers discoverable, multimodal file processing, RAG pipelines. Build, test, and deploy AI applicatio
35 lines • 1.64 kB
JavaScript
/**
* Circuit Breaker Error Classes
* Shared error types for circuit breaker implementations across the codebase.
* Lives in types/ to avoid circular dependencies between utils/ and mcp/.
*/
/**
* Typed error thrown when a circuit breaker is open or half-open call limit is reached.
* Contains structured metadata so callers can build actionable error messages
* for AI models and downstream consumers.
*/
export class CircuitBreakerOpenError extends Error {
/** The circuit breaker name (e.g., "tool-execution-bitbucket-server-add_comment") */
breakerName;
/** ISO timestamp when the circuit breaker will transition to half-open and allow a retry */
retryAfter;
/** Milliseconds until the circuit breaker will allow a retry */
retryAfterMs;
/** Current circuit breaker state ("open" or "half-open") */
breakerState;
/** Number of failures that caused the circuit to open */
failureCount;
constructor(options) {
const retryAfterStr = options.retryAfter.toISOString();
super(`Circuit breaker '${options.breakerName}' is ${options.breakerState}. ` +
`Tool temporarily unavailable after ${options.failureCount} failures. ` +
`Retry after: ${retryAfterStr} (${Math.ceil(options.retryAfterMs / 1000)}s).`);
this.name = "CircuitBreakerOpenError";
this.breakerName = options.breakerName;
this.retryAfter = retryAfterStr;
this.retryAfterMs = options.retryAfterMs;
this.breakerState = options.breakerState;
this.failureCount = options.failureCount;
}
}
//# sourceMappingURL=circuitBreakerErrors.js.map