export { M as ModelFailoverAttempt, a as ModelFailoverExhaustedError, b as ModelFailoverResult, R as RunWithModelFailoverInput, U as UPSTREAM_UNAVAILABLE_CODES, c as UPSTREAM_UNAVAILABLE_STATUSES, d as buildModelChain, i as isUpstreamUnavailable, r as readHttpStatusHint, e as runWithModelFailover } from '../failover-D-3UXXTb.js';

/**
 * Canonical chat-model resolution — identical across every agent app.
 *
 * The ONLY per-app inputs are DATA, never logic: the default model, the
 * allowlist, the env value the deployment set, and the catalog-fetch loader.
 * The logic is one precedence ladder + one fail-closed validator that every
 * product uses the same way — there is no per-product variant, no env-var name
 * baked in, and no backend dimension (router-vs-sandbox is the harness/dispatch
 * concern, not model resolution; a sandbox's provider default lives in the
 * sandbox subpath).
 *
 * - resolveChatModel: request > workspace > env > default. The product reads its
 *   own deploy env var and passes the VALUE as `envModel`; the shell knows no
 *   env-var names. Source is canonical: 'request' | 'workspace' | 'env' | 'default'.
 * - validateChatModelId: fail-closed. Admit an id that is in the allowlist, or
 *   equals the operator-set env model, or is served by the live router catalog
 *   (exact, or a bare id resolved to its canonical id when the suffix is unique).
 */
/** The router /v1/models entry shape this module reads. Minimal on purpose. */
interface ModelInfo {
    id: string;
    name?: string;
    _provider?: string;
    provider?: string;
}
/** Define possible origins for the chat model configuration values */
type ChatModelSource = 'request' | 'workspace' | 'env' | 'default';
/** Resolve a chat model with its identifier and source information */
interface ResolvedChatModel {
    model: string;
    source: ChatModelSource;
}
/** Represent successful chat model validation with a true status and a validated string value */
interface ChatModelValidationSuccess {
    succeeded: true;
    value: string;
}
/** Describe a failed chat model validation result with an error message */
interface ChatModelValidationFailure {
    succeeded: false;
    error: string;
}
/** Resolve the outcome of validating a chat model as either success or failure */
type ChatModelValidationResult = ChatModelValidationSuccess | ChatModelValidationFailure;
/** The catalog-fetch boundary: maps a router base URL to the raw model list. */
type LoadModels = (routerBaseUrl: string) => Promise<ModelInfo[]>;
/** Resolve the effective chat model input by prioritizing request, workspace, environment, and default models */
interface ResolveChatModelInput {
    /** Per-request override (highest precedence). */
    requestModel?: string;
    /** Persisted workspace-pinned model. */
    workspaceModel?: string;
    /** The value the deployment's model env var holds (the product reads its own
     *  var name and passes the value — the shell stays env-var-name agnostic). */
    envModel?: string;
    /** Final fallback (the product's default, typically profile.model.default). */
    defaultModel: string;
}
/** Resolve the chat-turn model by the one canonical precedence. Blank values are
 *  treated as absent. */
declare function resolveChatModel(input: ResolveChatModelInput): ResolvedChatModel;
/** Define input parameters for validating chat model IDs with optional allowlist and catalog access details */
interface ValidateChatModelIdInput {
    /** Ids accepted without a catalog round-trip (defaults + operator-trusted). */
    allowlist?: Iterable<string>;
    /** The operator-set env model value — always admitted (operator-trusted). */
    envModel?: string;
    /** Catalog loader; required to reach the catalog path. */
    loadModels?: LoadModels;
    /** Catalog endpoint base; required to reach the catalog path. */
    routerBaseUrl?: string;
}
/**
 * Fail-closed model-id validation. Accepts an id only when it is well-formed AND
 * (in the allowlist, or equals the operator-set env model, or served by the live
 * catalog). A bare id (no provider prefix) resolves to its canonical id only when
 * the suffix is unique across the catalog — an ambiguous suffix is rejected
 * rather than silently assigned a provider.
 */
declare function validateChatModelId(modelId: unknown, input: ValidateChatModelIdInput): Promise<ChatModelValidationResult>;
/** Resolve and return a trimmed string model ID or undefined for invalid or empty input */
declare function cleanModelId(value: unknown): string | undefined;
/** Validate if a model ID string conforms to length and character format requirements */
declare function isWellFormedModelId(modelId: string): boolean;
/** Resolve unique catalog IDs associated with a given model including its canonical form if applicable */
declare function catalogIdsForModel(model: ModelInfo): string[];

export { type ChatModelSource, type ChatModelValidationFailure, type ChatModelValidationResult, type ChatModelValidationSuccess, type LoadModels, type ModelInfo, type ResolveChatModelInput, type ResolvedChatModel, type ValidateChatModelIdInput, catalogIdsForModel, cleanModelId, isWellFormedModelId, resolveChatModel, validateChatModelId };
