/** * Model-runtime resolver + request-pipeline middleware. * * Maps the shared `Config.modelRuntime` settings into the per-request * `Request.reasoning` and `Request.cache` fields, gated by the active model's * `reasoningConfig` capabilities so unsupported values are omitted (and * surfaced as warnings) instead of triggering provider 400s. * * Wired once at boot (REPL/TUI/WebUI all go through the same `request` * pipeline) — see `installModelRuntimeMiddleware()`. UIs only need to mutate * `Config.modelRuntime` (and persist) for the change to take effect on the next * request. */ import type { Capabilities, ReasoningConfig, Request } from '../types/provider.js'; import type { ModelRuntimeConfig, ModelRuntimeParametersConfig } from '../types/config.js'; export interface ResolvedModelRuntime { reasoning: Request['reasoning']; cache: Request['cache']; /** Resolved generation parameters (topK, frequencyPenalty, etc.). */ parameters: Partial | undefined; /** Human-readable warnings for settings that were ignored for this model. */ warnings: string[]; } /** * Overlay a scoped runtime override (for example a subagent role matrix entry) * on top of the session-wide runtime settings. Nested objects merge so a role * can set only `reasoning.effort` without losing the leader's cache TTL or * other gated parameters. */ export declare function mergeModelRuntime(base: ModelRuntimeConfig | undefined, override: ModelRuntimeConfig | undefined): ModelRuntimeConfig | undefined; /** * Resolve user-facing runtime settings into request fields for a specific * model capability profile. Pure function — safe to unit-test without a * provider or event bus. * * @param settings `Config.modelRuntime` (may be undefined → no-op) * @param reasoning The model's `reasoningConfig`, or undefined when unknown. * When undefined the resolver is conservative: explicit * on/off is suppressed (provider default wins) and effort is * dropped, because we cannot tell whether the model will * accept the fields. */ export declare function resolveModelRuntime(settings: ModelRuntimeConfig | undefined, reasoning: ReasoningConfig | undefined, capabilities?: Capabilities | undefined): ResolvedModelRuntime; export declare function resolveReasoningForRequest(settings: ModelRuntimeConfig, rc: ReasoningConfig | undefined, warnings: string[]): Request['reasoning']; export declare function resolveCacheForRequest(settings: ModelRuntimeConfig, _warnings: string[]): Request['cache']; /** * Map the user-facing `ModelRuntimeParametersConfig` onto `Request` fields, * gated by the active model's `Capabilities`. Parameters whose capability * flag is false (or unknown) are silently omitted so unsupported models * never receive fields they'd reject. */ export declare function resolveParametersForRequest(params: ModelRuntimeParametersConfig | undefined, caps: Capabilities | undefined, _warnings: string[]): Partial | undefined; export interface ModelRuntimeMiddlewareOptions { /** Provider id of the active model, for logging/diagnostics only. */ providerId?: string | undefined; /** Model id of the active model, for logging/diagnostics only. */ modelId?: string | undefined; /** Current runtime settings. Called per-request so live changes apply. */ getSettings(): ModelRuntimeConfig | undefined; /** Current model capability profile. Called per-request. */ getReasoningConfig(): ReasoningConfig | undefined; /** Current model capabilities for parameter gating. Called per-request. */ getCapabilities?(): Capabilities | undefined; /** Optional sink for suppressed-setting warnings (e.g. emit to event bus). */ onWarning?: ((message: string) => void) | undefined; } /** * Build a `request`-pipeline middleware that applies runtime settings. The * returned function mutates the outgoing request by overlaying resolved * `reasoning` / `cache` fields and generic parameters. Existing fields on * the request are preserved only when the resolver produces nothing for * that field. */ export declare function applyModelRuntime(req: Request, opts: ModelRuntimeMiddlewareOptions): Request; //# sourceMappingURL=model-runtime.d.ts.map