"use strict";
/**
 * LLM Provider Adapter SDK -- public interface surface
 *
 * Defines the abstract interface that every LLM provider adapter must
 * implement. This is the contract between the governance runtime (which
 * is provider-agnostic) and the provider-specific transport layers.
 *
 * The governance runtime dispatches PreTool / PostTool hooks, approval-
 * queue routing, audit-chain emission, and circuit-breaker state through
 * this interface. No provider-specific branching is permitted in the
 * runtime layer -- all provider logic lives here.
 *
 * Spec: P3-SUB-01 (LLM Provider Adapter SDK)
 * AC:   1-3, 22-27 (interface, base, error hierarchy, version pinning)
 *
 * @connexum/ai-governance
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.LlmToolUseError = exports.LlmModelNotFoundError = exports.LlmContentFilterError = exports.LlmRateLimitError = exports.LlmAuthError = exports.LlmProviderError = void 0;
// ---------------------------------------------------------------------------
// Error hierarchy (AC 22, Section 3.3)
// ---------------------------------------------------------------------------
/**
 * Base error for all LLM provider errors.
 * Every error path in every adapter throws a typed subclass.
 * No adapter swallows an error and returns a fallback value.
 */
class LlmProviderError extends Error {
    code;
    providerId;
    adapterId;
    httpStatus;
    /** When the caller may retry (milliseconds) */
    retryAfterMs;
    /** Raw provider response (first 500 chars max) */
    raw;
    constructor(opts) {
        super(opts.message);
        this.name = 'LlmProviderError';
        this.code = opts.code;
        this.providerId = opts.providerId;
        this.adapterId = opts.adapterId;
        this.httpStatus = opts.httpStatus;
        this.retryAfterMs = opts.retryAfterMs;
        this.raw = opts.raw;
    }
}
exports.LlmProviderError = LlmProviderError;
/** Authentication / credential failure */
class LlmAuthError extends LlmProviderError {
    constructor(opts) {
        super({ ...opts, code: 'AUTH_FAILURE' });
        this.name = 'LlmAuthError';
    }
}
exports.LlmAuthError = LlmAuthError;
/** Rate limit exceeded -- retryAfterMs is required */
class LlmRateLimitError extends LlmProviderError {
    constructor(opts) {
        super({ ...opts, code: 'RATE_LIMIT' });
        this.name = 'LlmRateLimitError';
    }
}
exports.LlmRateLimitError = LlmRateLimitError;
/** Content blocked by provider content filter */
class LlmContentFilterError extends LlmProviderError {
    filterCategory;
    constructor(opts) {
        super({ ...opts, code: 'CONTENT_FILTERED' });
        this.name = 'LlmContentFilterError';
        this.filterCategory = opts.filterCategory;
    }
}
exports.LlmContentFilterError = LlmContentFilterError;
/** Requested model not found or not available on this adapter */
class LlmModelNotFoundError extends LlmProviderError {
    requestedModelId;
    constructor(opts) {
        super({ ...opts, code: 'MODEL_NOT_FOUND' });
        this.name = 'LlmModelNotFoundError';
        this.requestedModelId = opts.requestedModelId;
    }
}
exports.LlmModelNotFoundError = LlmModelNotFoundError;
/** Tool / function calling failure or unsupported operation */
class LlmToolUseError extends LlmProviderError {
    toolName;
    constructor(opts) {
        super({ ...opts, code: 'TOOL_USE_FAILURE' });
        this.name = 'LlmToolUseError';
        this.toolName = opts.toolName;
    }
}
exports.LlmToolUseError = LlmToolUseError;
//# sourceMappingURL=index.js.map