/** * Trusted provider presets — vendor-maintained defaults for provider IDs * whose product-specific base URL, model allowlist, env vars, and * compatibility quirks cannot be derived from the models.dev catalog alone * (or would otherwise leak into the user-typed `provider.add` payload). * * Why a separate module: * - The user-facing setup flow only ships `id`/`family`/`apiKey`; without * a trusted resolver, an OpenAI-compatible provider pointing at * `https://api.kimi.com/coding/v1` would work in the wire but skip the * Kimi-specific reasoning toggle and overwrite the user's explicit base * URL. We persist the canonical product defaults server-side instead. * - Vendor endpoints and model IDs change rarely but matter for * correctness (e.g. the Kimi HighSpeed alias consumes ~3× subscription * quota). Centralising them here keeps the CLI, TUI auth-menu, and * WebUI setup cards aligned. * * Coverage is intentionally narrow: only providers that need product-aware * server-side hydration are listed. Generic OpenAI-compatible gateways * (omniroute, LiteLLM, etc.) still rely on user-supplied baseUrl/models. */ import type { ProviderConfig } from '@wrongstack/core/types'; import type { ProviderDefinition } from './provider-definition-types.js'; /** * One trusted preset. `id` is the canonical provider id used in * `providers.` and on the wire; `family` is the wire family the * factory must use; `baseUrl`/`envVars`/`models`/`customModels`/`quirks` * are merged into a fresh ProviderConfig so callers do not need to know * them. * * `docsUrl` and `usage` are UI hints surfaced by setup cards and the TUI * auth menu — they do not change runtime behaviour. */ export interface TrustedProviderPreset extends ProviderDefinition { /** Canonical provider id (also the user-visible alias in WrongStack). */ id: string; /** Display name for the setup card / auth-menu row. */ name: string; /** * Wire family — drives which factory builds the provider. Use * `'openai-compatible'` for vendors whose API is documented as * OpenAI-compatible (Bearer + Chat Completions shape). Use `'anthropic'` * for Anthropic-Messages-compatible proxies. */ family: ProviderDefinition['family']; /** Default base URL; required so users only ever paste the key. */ baseUrl: string; /** Env var names to probe for the API key. */ envVars: string[]; /** Canonical model id allowlist. */ models: string[]; /** * Per-model definitions (capability overrides). These ride alongside * `models` so the WebUI model list can render reasoning/maxContext * without consulting the network catalog. Optional. */ /** Human-facing usage class — guides future access controls. */ usage: Exclude; catalog: NonNullable; } /** * Canonical trusted presets. * * Sourced from each vendor's public API/CLI documentation current as of * 2026-07-15. Update only after re-verifying the URL, the model aliases, * and the usage-class contract. */ export declare const TRUSTED_PROVIDER_PRESETS: Readonly>; /** * Look up a trusted preset by provider id. Returns `undefined` for ids * that are not in the trusted table (the generic openai-compatible / * anthropic / google path still works for those — see * `buildProviderFactoriesFromRegistry`). */ export declare function getTrustedProviderPreset(id: string): TrustedProviderPreset | undefined; /** * List all trusted preset ids. Used by the WebUI `providers.json` and the * TUI auth menu to render curated cards in addition to the user-managed * providers. */ export declare function listTrustedProviderPresetIds(): string[]; /** * Build a fresh `ProviderConfig` from a trusted preset, optionally * layering an initial API key. The returned object owns its own * `customModels`/`models`/`envVars` arrays/maps — callers may mutate * freely without affecting the preset table. * * Notes: * - `type` is set to the preset id so the registry can resolve the * catalog entry by id. When the user picks a custom alias (e.g. * `my-kimi`), callers should set `cfg.type = preset.id` and `cfg.family` * explicitly (or use `buildProviderConfigForAlias`). * - `apiKey` / `apiKeys[]` are not initialised here — callers use the * normal key-write path so the vault encryption flow stays uniform. */ export declare function buildProviderConfigFromPreset(preset: TrustedProviderPreset): ProviderConfig; /** * Repair stale preset metadata on an existing exact-canonical provider. * Credentials and user-owned fields are preserved. A provider with a base URL * different from the preset is treated as an explicit custom gateway, so its * family/models/env vars/quirks are not rewritten. Aliases are also excluded. */ export declare function rehydrateCanonicalProviderConfig(providerId: string, dest: ProviderConfig): boolean; /** * Resolve a user-supplied alias against the trusted preset table. Returns * the preset when the alias matches a canonical id exactly or when the * alias follows the `-` convention (so a user can save * a second Kimi subscription key under `kimi-for-coding-work` without * losing the canonical defaults). Returns `undefined` for unknown aliases * so the generic registration path can take over. */ export declare function resolvePresetForAlias(alias: string): TrustedProviderPreset | undefined; /** * True when an id matches a trusted preset exactly. Used by the WebUI * setup-card UI to decide whether to send a trusted preset id (and rely * on server-side hydration) or a generic id. */ export declare function isTrustedProviderId(id: string): boolean; //# sourceMappingURL=trusted-presets.d.ts.map