UNPKG

@mastra/core

Version:

Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack.

44 lines 2.11 kB
import type { MastraModelConfig } from '../../llm/model/shared.types.js'; import type { StorageConditionalField, StorageConditionalVariant, StorageModelConfig } from '../../storage/types.js'; export type ModelCandidateOrigin = 'static' | 'conditional-variant' | 'conditional-default' | 'runtime' | 'list' | 'sdk-instance' | 'openai-compatible'; /** * A single normalized provider/model candidate extracted from one of the many * shapes a model can be expressed in across the codebase. * * `origin` records which dispatch branch produced the candidate, mainly for * error messages on conditional variants. * * `label` is a short human-friendly description (variant index / SDK provider id * / etc.) used by `enforceModelAllowlist` when reporting the offending entry. */ export interface ModelCandidate { provider: string; modelId: string; origin: ModelCandidateOrigin; label?: string; } /** * Anything we accept as input to {@link toModelCandidates}. Kept open so call * sites can pass arbitrary stored or runtime model values without manual coercion. */ export type ModelCandidateInput = string | MastraModelConfig | StorageModelConfig | StorageConditionalField<StorageModelConfig> | StorageConditionalVariant<string>[] | { provider?: unknown; modelId?: unknown; name?: unknown; id?: unknown; providerId?: unknown; } | ((...args: unknown[]) => unknown) | null | undefined; /** * Convert any supported model expression into a flat list of `{ provider, modelId }` * candidates. Empty array means "could not statically determine" — callers * should treat that as unenforced at this level (runtime defense in Phase 7 * picks it up). * * Dispatch order: * 1. `null` / `undefined` / `function` → `[]` (dynamic, defer to runtime) * 2. `string` → gateway-aware split * 3. Conditional variants array → walk each variant * 4. Object → openai-compatible / SDK instance / stored static, see {@link fromObject} */ export declare function toModelCandidates(input: ModelCandidateInput): ModelCandidate[]; //# sourceMappingURL=normalize-candidate.d.ts.map