/**
 * @license
 * Copyright 2025 Vybestack LLC
 * SPDX-License-Identifier: Apache-2.0
 */
/**
 * Error thrown when authentication is required but not available
 */
export class AuthenticationRequiredError extends Error {
    authMode;
    requiredAuth;
    constructor(message, authMode, requiredAuth) {
        super(message);
        this.name = 'AuthenticationRequiredError';
        this.authMode = authMode;
        this.requiredAuth = requiredAuth;
    }
}
/**
 * @plan:PLAN-20251023-STATELESS-HARDENING.P03
 * @requirement:REQ-SP4-001
 * @pseudocode base-provider-runtime-guard.md lines 10-14
 */
export class MissingProviderRuntimeError extends Error {
    /**
     * Call-site provider identifier (e.g. `BaseProvider.openai`).
     */
    providerKey;
    /**
     * Required runtime properties that were not supplied.
     */
    missingFields;
    /**
     * Requirement tag to aid verification harnesses.
     */
    requirement;
    /**
     * Recommendations for callers to remediate the guard failure.
     */
    remediation;
    /**
     * Structured metadata attached to the error for diagnostics.
     */
    context;
    /**
     * @plan:PLAN-20251023-STATELESS-HARDENING.P05
     * @requirement:REQ-SP4-001
     * @pseudocode base-provider-fallback-removal.md lines 11-12
     */
    constructor({ providerKey, missingFields, requirement = 'REQ-SP4-001', remediation, stage, metadata, message, }) {
        const formattedMissing = missingFields.length > 0 ? missingFields.join(', ') : 'runtime data';
        super(message ??
            `Provider ${providerKey} invoked without required runtime context (${formattedMissing}).`);
        this.name = 'MissingProviderRuntimeError';
        this.providerKey = providerKey;
        this.missingFields = missingFields;
        this.requirement = requirement;
        this.remediation = remediation ?? [
            'Ensure ProviderManager injects settings/config before invoking providers.',
            'Verify CLI runtime wiring activates an isolated ProviderRuntimeContext per call.',
        ];
        this.context = {
            stage,
            metadata,
        };
    }
}
/**
 * @plan:PLAN-20251023-STATELESS-HARDENING.P08
 * @requirement:REQ-SP4-002
 * @pseudocode provider-runtime-handling.md lines 11-12
 */
export class ProviderRuntimeNormalizationError extends Error {
    providerKey;
    requirement;
    context;
    constructor({ providerKey, message, requirement = 'REQ-SP4-002', runtimeId, stage, metadata, }) {
        super(message);
        this.name = 'ProviderRuntimeNormalizationError';
        this.providerKey = providerKey;
        this.requirement = requirement;
        this.context = {
            runtimeId,
            stage,
            metadata,
        };
    }
}
/**
 * @plan:PLAN-20251023-STATELESS-HARDENING.P08
 * @requirement:REQ-SP4-004
 * @pseudocode logging-wrapper-adjustments.md lines 11, 15
 */
export class ProviderRuntimeScopeError extends Error {
    requirement;
    context;
    constructor({ message, requirement = 'REQ-SP4-004', callId, stage, metadata, }) {
        super(message);
        this.name = 'ProviderRuntimeScopeError';
        this.requirement = requirement;
        this.context = {
            callId,
            stage,
            metadata,
        };
    }
}
/**
 * Error thrown when all backends in a load balancer failover policy have failed
 * @plan PLAN-20251212issue488
 */
export class LoadBalancerFailoverError extends Error {
    profileName;
    failures;
    constructor(profileName, failures) {
        const profileNames = failures.map((f) => f.profile).join(', ');
        const errorSummary = failures.length === 1
            ? failures[0].error.message
            : `${failures.length} backends failed`;
        super(`Load balancer "${profileName}" failover exhausted: ${errorSummary} (tried: ${profileNames})`);
        this.name = 'LoadBalancerFailoverError';
        this.profileName = profileName;
        this.failures = failures;
    }
}
//# sourceMappingURL=errors.js.map