import type { RuntimeModelReference } from "./types.js"; export type LocalProviderType = "ollama" | "lmstudio" | "openai_compat"; export interface LocalProviderCapabilities { readonly tool_use?: boolean; readonly reasoning?: boolean; readonly reasoning_mode?: "none" | "toggle" | "effort" | string; readonly reasoning_levels?: readonly string[]; readonly reasoning_disable_supported?: boolean; readonly vision?: boolean; readonly json_mode?: boolean; readonly context_window?: number; readonly num_ctx?: number; readonly max_tokens?: number; readonly family?: string; readonly advertised_capabilities?: readonly string[]; readonly [key: string]: unknown; } export interface LocalProviderPricing { readonly input_per_million?: number; readonly cached_input_per_million?: number; readonly cache_write_per_million?: number; readonly output_per_million?: number; readonly [key: string]: unknown; } export interface LocalProviderModelDefinition { readonly name: string; readonly alias?: string; readonly displayName?: string; readonly enabled?: boolean; readonly capabilities?: LocalProviderCapabilities; readonly pricing?: LocalProviderPricing; } /** One provider selected into an agent's model catalog. */ export interface ProviderDefinition { readonly id: string; /** Present only for a self-hosted/OpenAI-compatible endpoint. */ readonly type?: LocalProviderType; readonly baseUrl?: string; readonly enabled?: boolean; readonly trustPublicUrl?: boolean; readonly apiKey?: string; readonly apiKeyEnv?: string; readonly models?: readonly LocalProviderModelDefinition[]; /** Bound the provider's contribution to operator-facing model catalogs. */ readonly maxAdvertisedModels?: number; } /** Backward-compatible narrowed shape for callers that require a local endpoint. */ export interface LocalProviderDefinition extends ProviderDefinition { readonly type: LocalProviderType; } export interface AgentRuntimeCustomProvider { readonly id: string; readonly provider_type: LocalProviderType; readonly base_url: string; readonly enabled: boolean; readonly trust_public_url: boolean; readonly api_key?: string; } export interface AgentRuntimeCustomModel { readonly provider_id: string; readonly model_name: string; readonly alias?: string; readonly display_name: string; readonly capabilities: LocalProviderCapabilities; readonly pricing: LocalProviderPricing; readonly enabled: boolean; } export interface LocalProviderRuntimeOptions { readonly customProvider?: AgentRuntimeCustomProvider; readonly customModel?: AgentRuntimeCustomModel; readonly modelCapabilities?: LocalProviderCapabilities; readonly isPrivateProvider?: boolean; readonly [key: string]: unknown; } /** One model discovered live from a local provider's OpenAI-compatible `/v1/models` endpoint. */ export interface DiscoveredLocalModel { readonly ref: string; readonly label: string; readonly providerId: string; /** Confirmed by native provider metadata, never inferred from the name. */ readonly embeddingOnly?: boolean; } export interface DiscoverLocalProviderModelsOptions { readonly fetch?: typeof fetch; readonly timeoutMs?: number; } /** * Live-discovers the models each ENABLED local provider currently serves, by * GETting its OpenAI-compatible `/v1/models` endpoint. Resilient by design: a * down/erroring/non-JSON/malformed-shape endpoint is skipped, never thrown — * this is called on the `/v1/info` request path and must never fail it. Only * enabled providers are probed; a disabled provider is skipped without a * network call. */ export declare function discoverLocalProviderModels(providers: readonly LocalProviderDefinition[] | undefined, opts?: DiscoverLocalProviderModelsOptions): Promise; /** * Advisory native metadata for chat catalogs. Unknown models remain usable. * One shared deadline and four workers bound Ollama's per-model requests. */ export declare function discoverEmbeddingOnlyModelIds(provider: LocalProviderDefinition, ids: readonly string[], fetchImpl: typeof fetch, signal: AbortSignal): Promise>; /** * Mirrors `openAiCompatBaseUrl` in agent-runtime's pi-models.js: ollama's * OpenAI-compat surface always lives at `/v1` (stripping any existing * `/api` or `/v1` suffix first); other local provider types get `/v1` * appended unless the configured baseUrl already ends in a version segment * (e.g. a gateway pre-configured with `.../v1`). */ export declare function modelsEndpointForProvider(provider: LocalProviderDefinition): string; /** The effort-related facts the TUI needs to render a per-model reasoning/effort picker. */ export interface ModelEffortLevels { readonly reasoning: boolean; /** * How this model exposes reasoning: `"effort"` (graded levels, see * `effortLevels`), `"toggle"` (binary thinking on/off — the client renders * on/off, NOT graded levels), or `"none"` (no adjustable thinking). Absent * for cloud/unconfigured refs, where the client falls back to the global * effort enum. */ readonly reasoningMode?: "none" | "toggle" | "effort" | string; readonly effortLevels?: readonly string[]; } /** * Resolves the reasoning support + effort levels for a parsed model reference. * Models whose provider matches a configured local provider get precise levels * via the same capability resolution `runtimeOptionsForLocalProvider` * uses for execution. Everything else (a cloud provider, or a local ref whose * provider isn't configured here) deliberately degrades to * `{ reasoning: true }` with `effortLevels` left undefined — resolving cloud * reasoning levels precisely would require reaching into the pi-ai model * registry from this package, which would cycle back through config; the TUI * falls back to the global effort enum for those. Never throws. */ export declare function resolveModelEffortLevels(ref: RuntimeModelReference, providers: readonly LocalProviderDefinition[] | undefined): ModelEffortLevels; export declare function runtimeOptionsForLocalProvider(model: RuntimeModelReference, providers: readonly LocalProviderDefinition[] | undefined): LocalProviderRuntimeOptions; export declare function validateLocalProviderDefinition(provider: LocalProviderDefinition): LocalProviderDefinition; /** * Validate the shared provider shape without doing network I/O. Entries with * no `type` declare or narrow a Pi built-in; the two local autodiscovery ids * may also omit it because their endpoint kind is intrinsic to the id. */ export declare function validateProviderDefinition(provider: ProviderDefinition): ProviderDefinition; /** True when Pi's version-pinned, in-process catalog owns the provider id. */ export declare function isPiBuiltinProvider(providerId: string): boolean; /** Local ids whose default endpoints can be checked without configuration. */ export declare function isAutodiscoverableProviderId(providerId: string): boolean; /** Resolve an endpoint-bearing definition for one autodiscoverable/configured local provider. */ export declare function localProviderDefinitionFor(provider: ProviderDefinition): LocalProviderDefinition | undefined; export declare function isPrivateBaseUrl(value: string): boolean; export declare function validateProviderBaseUrl(baseUrl: string, options: { readonly trustPublicUrl: boolean; }): void; //# sourceMappingURL=local-providers.d.ts.map