import { type Api, type Model } from "@bastani/pi-ai"; import type { ModelRegistry } from "./model-registry.ts"; import { type ModelConstraints, type ModelRouterOutput } from "./model-routing-constraints.js"; import { type TaskNeeds } from "./model-routing-needs.js"; import type { ModelRoutingSettings } from "./settings-types.ts"; export interface ModelRoutingContext { readonly modelRegistry: Pick & Partial>; readonly model?: Model; getRouterModel(): string; /** Provider and model filters from settings.json `modelRouting`; absent means every model is a candidate. */ getModelRouting?(): ModelRoutingSettings; /** The `httpIdleTimeoutMs` setting; bounds each routing inference. Absent means the setting's default. */ getHttpIdleTimeoutMs?(): number; } export interface ModelRoute { readonly routerSelection: ModelRouterOutput; readonly modelOverride: string; readonly fallbackModels?: readonly string[]; assertCurrent(): void; allowsModel(model: Model, effort?: string): boolean; } /** * Total auto-routing inference failure: Jev and the chat structured-output * fallback both failed before any model was selected (#3206). Validation, * eligibility, and credential-screening errors are never marked. */ export declare class AutoRoutingInferenceError extends Error { /** * Route pinned to the current chat model, present only when that model is * available and satisfies every routing constraint. Consumers may degrade * to it; when it is absent the failure stays fatal. */ readonly currentModelRoute?: ModelRoute; constructor(message: string, currentModelRoute?: ModelRoute); } /** * Caller-owned bounds on routing inference, on top of the structured-decision * deadline that already limits each inference call. A caller that needs a * shorter wait, or a concurrency limit, supplies them. */ export interface RoutingInferenceBounds { /** * When it aborts, inference stops and routing ends like any total inference * failure, so a consumer may degrade to `AutoRoutingInferenceError.currentModelRoute`. * Cancellation still goes through `signal`. */ readonly deadline?: AbortSignal; /** Runs each inference under the caller's concurrency limit; the queue wait must end when `signal` aborts. */ readonly limit?: (run: () => Promise, signal: AbortSignal | undefined) => Promise; } export declare function routeExecutionModel(input: { ctx: ModelRoutingContext; task: string; agent: { name: string; description: string; }; constraints?: readonly ModelConstraints[]; signal?: AbortSignal; /** Restore a recorded decision without another inference call. */ selection?: ModelRouterOutput; /** What the caller already knows about the task; routing asks the router only for the rest. */ taskNeeds?: TaskNeeds; /** * True when this call's own constraints set a provider list because the user * asked. Only then are the settings.json provider lists replaced; provider * lists from agent definitions or inherited workflow constraints restrict * candidates on top of the settings and never lift a user's exclusion. */ overrideProviderSettings?: boolean; inference?: RoutingInferenceBounds; }): Promise; //# sourceMappingURL=execution-model-router.d.ts.map