import { Context, Effect, type JsonSchema, Layer, Schema, Scope, Stream } from "effect"; import { AiError, LanguageModel, Model, Tool } from "effect/unstable/ai"; /** @experimental */ export type Metadata = Readonly>; /** @experimental */ export interface GovernanceOptions { readonly maxConcurrentModelCalls?: number; } /** @experimental */ export interface ModelSelection { readonly provider: string; readonly model: string; readonly registrationKey?: string; } /** @experimental Immutable identity of one candidate within an ordered provider route. */ export interface CandidateIdentity extends ModelSelection { readonly candidate: number; } /** @experimental Disposition chosen for a failed provider attempt. */ export type FailureDisposition = "retry" | "fallback" | "terminal"; /** @experimental Instrumentation boundary supplied to a provider-owned candidate route. */ export interface CandidateRouteInstrumentation { readonly instrument: (model: LanguageModel.Service, identity: CandidateIdentity) => LanguageModel.Service; readonly settleFailure: (disposition: FailureDisposition) => Effect.Effect; readonly fallbackScheduled: (input: { readonly from: CandidateIdentity; readonly to: CandidateIdentity; readonly error: unknown; }) => Effect.Effect; } /** @experimental Provider-owned ordered candidate routing implementation. */ export type CandidateRoute = (instrumentation: CandidateRouteInstrumentation) => LanguageModel.Service; /** @experimental Semantic classification of a model failure. */ export type FailureClassification = "context-overflow" | "other"; /** @experimental Provider-owned semantic model-failure classifier. */ export type FailureClassifier = (error: unknown) => FailureClassification; /** @experimental Provider-owned decision that a failed invocation may advance an ordered candidate route. */ export type AvailabilityFailureClassifier = (error: unknown) => boolean; /** @experimental Provider-owned compilation of a tool's exact request JSON Schema. */ export type ToolJsonSchemaCompiler = (tool: Tool.Any) => Effect.Effect; /** @experimental Classify a failure using semantics attached to the active registered model, falling back to provider-agnostic context-overflow evidence. */ export declare const classifyFailure: { (error: unknown): (model: LanguageModel.Service) => FailureClassification; (model: LanguageModel.Service, error: unknown): FailureClassification; }; /** @experimental Read the compiler attached to the active registered or explicitly wrapped model. */ export declare const toolJsonSchemaCompiler: (model: LanguageModel.Service) => ToolJsonSchemaCompiler | undefined; /** @experimental Attach a provider-exact tool JSON Schema compiler to a direct language model. */ export declare const withToolJsonSchemaCompiler: { (compiler: ToolJsonSchemaCompiler): (model: LanguageModel.Service) => LanguageModel.Service; (model: LanguageModel.Service, compiler: ToolJsonSchemaCompiler): LanguageModel.Service; }; /** @experimental Attach a provider-owned candidate route at the raw model-attempt boundary. */ export declare const withCandidateRoute: { (route: CandidateRoute): (model: LanguageModel.Service) => LanguageModel.Service; (model: LanguageModel.Service, route: CandidateRoute): LanguageModel.Service; }; /** @internal */ export declare const candidateRoute: (model: LanguageModel.Service) => CandidateRoute | undefined; /** @internal */ export declare const registrationIdentity: (model: LanguageModel.Service) => ModelSelection | undefined; declare const LanguageModelNotRegistered_base: Schema.Class; }>, import("effect/Cause").YieldableError>; /** @experimental */ export declare class LanguageModelNotRegistered extends LanguageModelNotRegistered_base { } /** @experimental */ export interface Registration { readonly provider: string; readonly model: string; readonly registrationKey?: string; readonly layer: Layer.Layer; readonly metadata?: Metadata; readonly classifyFailure?: FailureClassifier; readonly toolJsonSchemaCompiler?: ToolJsonSchemaCompiler; readonly isAvailabilityFailure?: AvailabilityFailureClassifier; } /** @experimental */ export interface RegisterInput { readonly registration: Registration; } /** @experimental */ export interface Interface { readonly register: (input: RegisterInput) => Effect.Effect; readonly registrations: Effect.Effect>; readonly operate: (selection: ModelSelection, effect: Effect.Effect) => Effect.Effect>; readonly stream: (selection: ModelSelection, stream: Stream.Stream) => Stream.Stream>; } declare const ModelRegistry_base: Context.ServiceClass; /** @experimental */ export declare class ModelRegistry extends ModelRegistry_base { } /** @experimental */ export type ModelEnvironment = LanguageModel.LanguageModel | Model.ProviderName | Model.ModelName; /** @experimental */ export declare const registration: (input: { readonly provider: string; readonly model: string; readonly registrationKey?: string; readonly layer: Layer.Layer; readonly metadata?: Metadata; readonly classifyFailure?: FailureClassifier; readonly toolJsonSchemaCompiler?: ToolJsonSchemaCompiler; readonly isAvailabilityFailure?: AvailabilityFailureClassifier; }) => Effect.Effect; /** @experimental */ export declare const layer: { (): Layer.Layer; (options?: GovernanceOptions): (registrations?: ReadonlyArray>) => Layer.Layer>; (registrations?: ReadonlyArray>, options?: GovernanceOptions): Layer.Layer>; }; /** @experimental */ export declare const layerCombined: { (options?: GovernanceOptions): (registries: ReadonlyArray>) => Layer.Layer; (registries: ReadonlyArray>, options?: GovernanceOptions): Layer.Layer; }; /** @experimental In-memory model registry. */ /** @experimental */ export declare const layerTest: (implementation: Interface) => Layer.Layer; /** @experimental */ export declare const register: (input: RegisterInput) => Effect.Effect; /** @experimental */ export declare const registrations: () => Effect.Effect; /** @experimental */ export declare const operate: { (effect: Effect.Effect): (selection: ModelSelection) => Effect.Effect>; (selection: ModelSelection, effect: Effect.Effect): Effect.Effect>; }; /** @experimental */ export declare const stream: { (operation: Stream.Stream): (selection: ModelSelection) => Stream.Stream>; (selection: ModelSelection, operation: Stream.Stream): Stream.Stream>; }; export {};