/**
 * Error ring buffer for proxy diagnostics.
 * Stores the last N errors for /doctor to report.
 */
const MAX_ERRORS = 20;
const errors = [];
const startTime = Date.now();
export function recordError(endpoint, errorType, message, suggestion) {
    errors.push({
        timestamp: new Date().toISOString(),
        endpoint,
        errorType,
        message,
        suggestion,
    });
    if (errors.length > MAX_ERRORS) {
        errors.shift();
    }
}
export function getRecentErrors(count = 5) {
    return errors.slice(-count);
}
export function getErrorCount() {
    return errors.length;
}
export function getUptime() {
    return Math.round((Date.now() - startTime) / 1000);
}
export function clearErrors() {
    errors.length = 0;
}
export function suggestModelFix(requestedModel, availableModels) {
    if (availableModels.length === 0)
        return undefined;
    // Try partial match
    const lower = requestedModel.toLowerCase();
    const partial = availableModels.find(m => m.toLowerCase().includes(lower) || lower.includes(m.toLowerCase()));
    if (partial)
        return `Did you mean "${partial}"?`;
    // Suggest first available
    return `Available models: ${availableModels.slice(0, 3).join(', ')}${availableModels.length > 3 ? '...' : ''}`;
}
//# sourceMappingURL=diagnostics.js.map