import { createOpenAI } from '@ai-sdk/openai'; import { LanguageModel } from 'ai'; import { C as CustomProvider, L as LLMProvider } from './index-fZyfLCHE.js'; import './public-types-CX8stXC3.js'; import './types-HXAijHji.js'; import './types-CI0Xyszt.js'; import '@modelcontextprotocol/client'; import '@modelcontextprotocol/client/stdio'; import 'zod'; /** * Model factory for creating AI SDK language models from provider/model strings. * Supports both built-in providers and user-defined custom providers. * * Also exports buildOrgModelFromResolvedConfig / assertOrgModelAllowed for * building models from org-resolved provider configs (local BYOK runtime). */ /** * Custom base URLs for built-in providers that support them. */ interface BaseUrls { ollama?: string; azure?: string; anthropic?: string; openai?: string; /** * Amazon Bedrock regional runtime endpoint, e.g. * https://bedrock-runtime.us-east-1.amazonaws.com. * When omitted, the provider derives it from the AWS_REGION env var. */ bedrock?: string; } /** * Options for creating a model. */ interface CreateModelOptions { apiKey: string; baseUrls?: BaseUrls; /** Custom providers registry (name -> config) */ customProviders?: Map | Record; } /** * Result of parsing an LLM string */ type ParsedLLMString = { type: "builtin"; provider: LLMProvider; model: string; } | { type: "custom"; providerName: string; model: string; }; /** * Parse an LLM string into provider and model components. * Supports both built-in providers and custom provider names. * * @param llmString - String in format "provider/model" (e.g., "openai/gpt-4o" or "my-litellm/gpt-4") * @param customProviderNames - Optional set of registered custom provider names for validation * @returns Parsed result with type discriminator */ declare function parseLLMString(llmString: string, customProviderNames?: Set): ParsedLLMString; /** * Model type returned by provider factories. */ type ProviderLanguageModel = ReturnType>; /** * Create a language model from an LLM string. * @param llmString - String in format "provider/model" (e.g., "openai/gpt-4o" or "my-provider/model") * @param options - API key, optional base URLs, and custom providers registry * @returns AI SDK language model instance */ declare function createModelFromString(llmString: string, options: CreateModelOptions): ProviderLanguageModel; /** * Parse a comma-separated string of model IDs into an array. * Handles whitespace and empty entries. */ declare function parseModelIds(modelIdsString: string): string[]; /** * Create a CustomProvider configuration from user input. * This is a helper for building the configuration from form inputs. */ declare function createCustomProvider(config: { name: string; protocol: "openai-compatible" | "anthropic-compatible"; baseUrl: string; modelIds: string | string[]; apiKey?: string; apiKeyEnvVar?: string; useChatCompletions?: boolean; }): CustomProvider; /** * Preset configurations for common OpenAI-compatible providers. * Users can use these as starting points and customize as needed. */ declare const PROVIDER_PRESETS: { /** LiteLLM proxy - requires useChatCompletions */ readonly litellm: (baseUrl: string | undefined, modelIds: string[]) => CustomProvider; }; /** * Resolved provider config as returned by /stream/org/resolve for local providers. * Cloud providers do not send apiKey — only local providers include credentials. */ interface OrgProviderResolvedConfig { providerKey: string; /** Present only for local-runtime providers. */ apiKey?: string; baseUrl?: string; protocol?: "openai-compatible" | "anthropic-compatible"; modelIds?: string[]; displayName?: string; selectedModels?: string[]; } declare class OrgProviderConfigError extends Error { readonly code: string; constructor(code: string, message: string); } /** * Build an AI SDK LanguageModel from an org-resolved provider config. * * Mirrors convex/stream/buildOrgModel.ts — kept in sync so local and cloud * execution use the same provider dispatch logic. * * Throws OrgProviderConfigError('provider_not_configured', ...) when a * required apiKey or baseUrl is missing. */ declare function buildOrgModelFromResolvedConfig(config: OrgProviderResolvedConfig, modelId: string): LanguageModel; /** * Validate that the requested model is in the org's allowlist for the provider. * For OpenRouter and Amazon Bedrock this is selectedModels; for custom * providers it is modelIds. Built-in providers are pass-through (the upstream * provider rejects unknown ids). * * Throws OrgProviderConfigError('model_not_allowed', ...) on rejection. */ declare function assertOrgModelAllowed(config: OrgProviderResolvedConfig, modelId: string): void; export { type BaseUrls, type CreateModelOptions, OrgProviderConfigError, type OrgProviderResolvedConfig, PROVIDER_PRESETS, type ParsedLLMString, type ProviderLanguageModel, assertOrgModelAllowed, buildOrgModelFromResolvedConfig, createCustomProvider, createModelFromString, parseLLMString, parseModelIds };