/** * Curated model catalog (Phase D+): provider -> OpenAI-compatible base URL * resolution for `provider:model` specs stored in Agent.model. * * The authoritative copy + update process live in `docs/agent-models.md`. * This file mirrors the frontend catalog * (`frontend/src/lib/constants/models.ts`) and the docs table — keep all * three in sync (see the docs for the 3-step update process). */ export declare const MODEL_BASE_URLS: Record; /** Provider keys accepted by the catalog (for validation/docs). */ export declare const MODEL_PROVIDERS: string[]; /** Providers that are harness-native (only work via the harness CLI, not --self). */ export declare const HARNESS_NATIVE_PROVIDERS: Set; /** * Vision-call wire families for the browser auto-answer direct loop. * * OpenCode Zen/Go is NOT one endpoint: each model family has its own path * (see https://opencode.ai/docs/zen/ and https://opencode.ai/docs/go/). * `chat` is the OpenAI-compatible `chat/completions` shape every other * provider speaks. `unsupported` is for ids that can never carry a screenshot * (e.g. `jev-*`, a text-decision model). */ export type VisionFamily = 'chat' | 'responses' | 'messages' | 'gemini'; export declare const ZEN_ROOT = "https://opencode.ai/zen/v1"; export declare const GO_ROOT = "https://opencode.ai/zen/go/v1"; /** * Classify an OpenCode (Zen/Go) model id into its wire family. * Prefix rules cover `gpt-*`/`grok-*`/`muse-spark-*` (responses) and * `claude-*`/`gemini-*`; the Qwen ids that ride `messages` are exact-matched * above because sibling Qwen ids ride `chat/completions`. Unknown ids default * to `chat` — the gateway's most widely served shape. */ export declare function zenFamilyFor(modelId: string): VisionFamily | 'unsupported'; /** Full request URL for a resolved vision endpoint. */ export declare function visionRequestUrl(endpoint: { baseUrl: string; family: VisionFamily; }): string; /** Provider slug of a `provider:model` / `provider/model` spec. */ export declare function providerOf(spec: string): string; /** Provider slugs that draw from the same console key (one key, both entitlements). */ export declare const OPENCODE_KEY_FAMILY: Set; /** * Resolve a direct API key for a model spec using (in order): an explicit key, * the agent's per-provider BYOK map, the agent's single provider key, the * provider's dedicated env var, then the generic LLM_API_KEY / CHAT_LLM_API_KEY. */ export declare function resolveDirectApiKey(spec: string, providerKeys?: Record | null, providerKey?: string | null): string | null; /** * Resolve an API key for a `provider:model` spec. Precedence: the provider's * dedicated env var (e.g. OPENROUTER_API_KEY) > generic LLM_API_KEY / * CHAT_LLM_API_KEY. Returns null when none is set. */ export declare function resolveApiKeyForProvider(spec: string): string | null; /** Default OpenAI-compatible base when nothing else is configured. */ export declare const DEFAULT_LLM_BASE_URL = "https://api.openai.com/v1"; export interface ResolvedModel { /** Base URL for chat/completions (env LLM_BASE_URL always wins). */ baseUrl: string; /** Model id sent to the API. */ model: string; /** True when the spec was resolved via the catalog (vs raw env default). */ catalogued: boolean; /** True when the model is harness-native (opencode-go) and cannot be used with --self. */ harnessOnly: boolean; } /** * Resolves a model spec to (baseUrl, model): * - `provider:model` (e.g. "gemini:gemini-2.5-flash") -> catalog base URL. * - `provider/model` (e.g. "opencode/x-preview-f-free") -> same, slash form. * - `opencode-go:*` -> harness-only flag (caller must use opencode harness, not --self). * - Anything else (legacy "deepseek-chat") -> env LLM_BASE_URL default, * preserving the pre-catalog behavior. * The provider is whatever precedes the EARLIEST separator (`:` or `/`), so * catalogued ids that themselves contain slashes * ("openrouter:anthropic/claude-...") still resolve correctly. * Precedence for the base URL: LLM_BASE_URL env > catalog provider URL. */ export declare function resolveModel(spec: string, envBaseUrl?: string): ResolvedModel; export interface ResolvedBrowseModel { /** * FULL request URL — callers post to this verbatim (or via * `visionRequestUrl`, which appends `:generateContent` for gemini). * For `chat`/`responses`/`messages` this already includes the path; there * is deliberately no bare `https://opencode.ai/zen/v1` base anymore, since * no such single endpoint exists. */ baseUrl: string; /** Model id sent in the request body. */ model: string; /** Wire shape the caller must speak. */ family: VisionFamily; /** True when the model needs the CLI harness (never direct-callable). */ harnessOnly: boolean; /** Set when the id can never carry a vision loop (e.g. `jev-*`). */ unsupported?: string; } /** * Resolve a model spec for a DIRECT vision call (browser auto-answer). * `opencode/*` (Zen) and `opencode-go/*` (Go subscription) are both * direct-callable: each id is classified into its wire family and pointed at * that family's endpoint path. Only `anthropic:*` (native API) stays * harness-only. A custom `baseUrl` (from the run form) always wins and is * treated as OpenAI-compatible (`chat`). * * There is NO default model: callers must pass an explicit spec and fail with * "pick a vision model" when they have none. */ export declare function resolveBrowseModel(spec: string, envBaseUrl?: string, customBaseUrl?: string): ResolvedBrowseModel; /** * Get the fallback model for opencode-go providers. * When opencode-go is detected and --self cannot be used, * this returns the agent's configured model or the default harness model. */ export declare function getHarnessFallbackModel(agentModel?: string): string;