llm-strings 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +354 -0
- package/dist/index.cjs +631 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +92 -0
- package/dist/index.d.ts +92 -0
- package/dist/index.js +597 -0
- package/dist/index.js.map +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/parse.ts","../src/providers.ts","../src/normalize.ts","../src/validate.ts"],"sourcesContent":["export { parse, build } from \"./parse.js\";\nexport type { LlmConnectionConfig } from \"./parse.js\";\n\nexport { normalize } from \"./normalize.js\";\nexport type { NormalizeChange, NormalizeOptions, NormalizeResult } from \"./normalize.js\";\n\nexport { validate } from \"./validate.js\";\nexport type { ValidationIssue } from \"./validate.js\";\n\nexport { detectProvider, detectBedrockModelFamily, ALIASES, PROVIDER_PARAMS } from \"./providers.js\";\nexport type { Provider, BedrockModelFamily } from \"./providers.js\";\n","export interface LlmConnectionConfig {\n /** The original connection string */\n raw: string;\n /** Provider's API base URL (e.g. \"api.openai.com\") */\n host: string;\n /** Model name (e.g. \"gpt-5.2\") */\n model: string;\n /** Optional label or app name */\n label?: string;\n /** Optional API key or password */\n apiKey?: string;\n /** Additional config parameters (temp, max_tokens, etc.) */\n params: Record<string, string>;\n}\n\n/**\n * Parse an LLM connection string into its component parts.\n *\n * Format: `llm://[label[:apiKey]@]host/model[?key=value&...]`\n *\n * @example\n * ```ts\n * parse(\"llm://api.openai.com/gpt-5.2?temp=0.7&max_tokens=1500\")\n * parse(\"llm://app-name:sk-proj-123456@api.openai.com/gpt-5.2?temp=0.7\")\n * ```\n */\nexport function parse(connectionString: string): LlmConnectionConfig {\n const url = new URL(connectionString);\n\n if (url.protocol !== \"llm:\") {\n throw new Error(\n `Invalid scheme: expected \"llm://\", got \"${url.protocol}//\"`,\n );\n }\n\n const host = url.hostname;\n const model = url.pathname.replace(/^\\//, \"\");\n const label = url.username || undefined;\n const apiKey = url.password || undefined;\n\n const params: Record<string, string> = {};\n for (const [key, value] of url.searchParams) {\n params[key] = value;\n }\n\n return {\n raw: connectionString,\n host,\n model,\n label,\n apiKey,\n params,\n };\n}\n\n/**\n * Build an LLM connection string from a config object.\n */\nexport function build(config: Omit<LlmConnectionConfig, \"raw\">): string {\n const auth =\n config.label || config.apiKey\n ? `${config.label ?? \"\"}${config.apiKey ? `:${config.apiKey}` : \"\"}@`\n : \"\";\n\n const query = new URLSearchParams(config.params).toString();\n const qs = query ? `?${query}` : \"\";\n\n return `llm://${auth}${config.host}/${config.model}${qs}`;\n}\n","export type Provider =\n | \"openai\"\n | \"anthropic\"\n | \"google\"\n | \"mistral\"\n | \"cohere\"\n | \"bedrock\"\n | \"openrouter\"\n | \"vercel\";\n\nexport function detectProvider(host: string): Provider | undefined {\n // Gateways and aggregators first — they proxy to other providers\n if (host.includes(\"openrouter\")) return \"openrouter\";\n if (host.includes(\"gateway.ai.vercel\")) return \"vercel\";\n // Bedrock before native providers since it hosts models from multiple vendors\n if (host.includes(\"amazonaws\") || host.includes(\"bedrock\")) return \"bedrock\";\n if (host.includes(\"openai\")) return \"openai\";\n if (host.includes(\"anthropic\") || host.includes(\"claude\")) return \"anthropic\";\n if (host.includes(\"googleapis\") || host.includes(\"google\")) return \"google\";\n if (host.includes(\"mistral\")) return \"mistral\";\n if (host.includes(\"cohere\")) return \"cohere\";\n return undefined;\n}\n\n/**\n * Shorthand aliases → canonical param name.\n * Canonical names use snake_case and follow OpenAI conventions where possible.\n */\nexport const ALIASES: Record<string, string> = {\n // temperature\n temp: \"temperature\",\n\n // max_tokens\n max: \"max_tokens\",\n max_out: \"max_tokens\",\n max_output: \"max_tokens\",\n max_output_tokens: \"max_tokens\",\n max_completion_tokens: \"max_tokens\",\n maxOutputTokens: \"max_tokens\",\n maxTokens: \"max_tokens\",\n\n // top_p\n topp: \"top_p\",\n topP: \"top_p\",\n nucleus: \"top_p\",\n\n // top_k\n topk: \"top_k\",\n topK: \"top_k\",\n\n // frequency_penalty\n freq: \"frequency_penalty\",\n freq_penalty: \"frequency_penalty\",\n frequencyPenalty: \"frequency_penalty\",\n repetition_penalty: \"frequency_penalty\",\n\n // presence_penalty\n pres: \"presence_penalty\",\n pres_penalty: \"presence_penalty\",\n presencePenalty: \"presence_penalty\",\n\n // stop\n stop_sequences: \"stop\",\n stopSequences: \"stop\",\n stop_sequence: \"stop\",\n\n // seed\n random_seed: \"seed\",\n randomSeed: \"seed\",\n\n // n (completions count)\n candidateCount: \"n\",\n candidate_count: \"n\",\n num_completions: \"n\",\n\n // effort / reasoning\n reasoning_effort: \"effort\",\n reasoning: \"effort\",\n\n // cache\n cache_control: \"cache\",\n cacheControl: \"cache\",\n cachePoint: \"cache\",\n cache_point: \"cache\",\n};\n\n/**\n * Canonical param name → provider-specific API param name.\n * Only includes params the provider actually supports.\n */\nexport const PROVIDER_PARAMS: Record<Provider, Record<string, string>> = {\n openai: {\n temperature: \"temperature\",\n max_tokens: \"max_tokens\",\n top_p: \"top_p\",\n frequency_penalty: \"frequency_penalty\",\n presence_penalty: \"presence_penalty\",\n stop: \"stop\",\n n: \"n\",\n seed: \"seed\",\n stream: \"stream\",\n effort: \"reasoning_effort\",\n },\n anthropic: {\n temperature: \"temperature\",\n max_tokens: \"max_tokens\",\n top_p: \"top_p\",\n top_k: \"top_k\",\n stop: \"stop_sequences\",\n stream: \"stream\",\n effort: \"effort\",\n cache: \"cache_control\",\n cache_ttl: \"cache_ttl\",\n },\n google: {\n temperature: \"temperature\",\n max_tokens: \"maxOutputTokens\",\n top_p: \"topP\",\n top_k: \"topK\",\n frequency_penalty: \"frequencyPenalty\",\n presence_penalty: \"presencePenalty\",\n stop: \"stopSequences\",\n n: \"candidateCount\",\n stream: \"stream\",\n seed: \"seed\",\n responseMimeType: \"responseMimeType\",\n responseSchema: \"responseSchema\",\n },\n mistral: {\n temperature: \"temperature\",\n max_tokens: \"max_tokens\",\n top_p: \"top_p\",\n frequency_penalty: \"frequency_penalty\",\n presence_penalty: \"presence_penalty\",\n stop: \"stop\",\n n: \"n\",\n seed: \"random_seed\",\n stream: \"stream\",\n safe_prompt: \"safe_prompt\",\n min_tokens: \"min_tokens\",\n },\n cohere: {\n temperature: \"temperature\",\n max_tokens: \"max_tokens\",\n top_p: \"p\",\n top_k: \"k\",\n frequency_penalty: \"frequency_penalty\",\n presence_penalty: \"presence_penalty\",\n stop: \"stop_sequences\",\n stream: \"stream\",\n seed: \"seed\",\n },\n bedrock: {\n // Bedrock Converse API uses camelCase\n temperature: \"temperature\",\n max_tokens: \"maxTokens\",\n top_p: \"topP\",\n top_k: \"topK\", // Claude models via additionalModelRequestFields\n stop: \"stopSequences\",\n stream: \"stream\",\n cache: \"cache_control\",\n cache_ttl: \"cache_ttl\",\n },\n openrouter: {\n // OpenAI-compatible API with extra routing params\n temperature: \"temperature\",\n max_tokens: \"max_tokens\",\n top_p: \"top_p\",\n top_k: \"top_k\",\n frequency_penalty: \"frequency_penalty\",\n presence_penalty: \"presence_penalty\",\n stop: \"stop\",\n n: \"n\",\n seed: \"seed\",\n stream: \"stream\",\n effort: \"reasoning_effort\",\n },\n vercel: {\n // OpenAI-compatible gateway\n temperature: \"temperature\",\n max_tokens: \"max_tokens\",\n top_p: \"top_p\",\n top_k: \"top_k\",\n frequency_penalty: \"frequency_penalty\",\n presence_penalty: \"presence_penalty\",\n stop: \"stop\",\n n: \"n\",\n seed: \"seed\",\n stream: \"stream\",\n effort: \"reasoning_effort\",\n },\n};\n\n/**\n * Validation specs per provider, keyed by provider-specific param name.\n */\nexport interface ParamSpec {\n type: \"number\" | \"string\" | \"boolean\";\n min?: number;\n max?: number;\n values?: string[];\n}\n\nexport const PARAM_SPECS: Record<Provider, Record<string, ParamSpec>> = {\n openai: {\n temperature: { type: \"number\", min: 0, max: 2 },\n max_tokens: { type: \"number\", min: 1 },\n top_p: { type: \"number\", min: 0, max: 1 },\n frequency_penalty: { type: \"number\", min: -2, max: 2 },\n presence_penalty: { type: \"number\", min: -2, max: 2 },\n stop: { type: \"string\" },\n n: { type: \"number\", min: 1 },\n seed: { type: \"number\" },\n stream: { type: \"boolean\" },\n reasoning_effort: {\n type: \"string\",\n values: [\"none\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\"],\n },\n },\n anthropic: {\n temperature: { type: \"number\", min: 0, max: 1 },\n max_tokens: { type: \"number\", min: 1 },\n top_p: { type: \"number\", min: 0, max: 1 },\n top_k: { type: \"number\", min: 0 },\n stop_sequences: { type: \"string\" },\n stream: { type: \"boolean\" },\n effort: { type: \"string\", values: [\"low\", \"medium\", \"high\", \"max\"] },\n cache_control: { type: \"string\", values: [\"ephemeral\"] },\n cache_ttl: { type: \"string\", values: [\"5m\", \"1h\"] },\n },\n google: {\n temperature: { type: \"number\", min: 0, max: 2 },\n maxOutputTokens: { type: \"number\", min: 1 },\n topP: { type: \"number\", min: 0, max: 1 },\n topK: { type: \"number\", min: 0 },\n frequencyPenalty: { type: \"number\", min: -2, max: 2 },\n presencePenalty: { type: \"number\", min: -2, max: 2 },\n stopSequences: { type: \"string\" },\n candidateCount: { type: \"number\", min: 1 },\n stream: { type: \"boolean\" },\n seed: { type: \"number\" },\n responseMimeType: { type: \"string\" },\n responseSchema: { type: \"string\" },\n },\n mistral: {\n temperature: { type: \"number\", min: 0, max: 1 },\n max_tokens: { type: \"number\", min: 1 },\n top_p: { type: \"number\", min: 0, max: 1 },\n frequency_penalty: { type: \"number\", min: -2, max: 2 },\n presence_penalty: { type: \"number\", min: -2, max: 2 },\n stop: { type: \"string\" },\n n: { type: \"number\", min: 1 },\n random_seed: { type: \"number\" },\n stream: { type: \"boolean\" },\n safe_prompt: { type: \"boolean\" },\n min_tokens: { type: \"number\", min: 0 },\n },\n cohere: {\n temperature: { type: \"number\", min: 0, max: 1 },\n max_tokens: { type: \"number\", min: 1 },\n p: { type: \"number\", min: 0, max: 1 },\n k: { type: \"number\", min: 0, max: 500 },\n frequency_penalty: { type: \"number\", min: 0, max: 1 },\n presence_penalty: { type: \"number\", min: 0, max: 1 },\n stop_sequences: { type: \"string\" },\n stream: { type: \"boolean\" },\n seed: { type: \"number\" },\n },\n bedrock: {\n // Converse API inferenceConfig params\n temperature: { type: \"number\", min: 0, max: 1 },\n maxTokens: { type: \"number\", min: 1 },\n topP: { type: \"number\", min: 0, max: 1 },\n topK: { type: \"number\", min: 0 },\n stopSequences: { type: \"string\" },\n stream: { type: \"boolean\" },\n cache_control: { type: \"string\", values: [\"ephemeral\"] },\n cache_ttl: { type: \"string\", values: [\"5m\", \"1h\"] },\n },\n openrouter: {\n // Loose validation — proxies to many providers with varying ranges\n temperature: { type: \"number\", min: 0, max: 2 },\n max_tokens: { type: \"number\", min: 1 },\n top_p: { type: \"number\", min: 0, max: 1 },\n top_k: { type: \"number\", min: 0 },\n frequency_penalty: { type: \"number\", min: -2, max: 2 },\n presence_penalty: { type: \"number\", min: -2, max: 2 },\n stop: { type: \"string\" },\n n: { type: \"number\", min: 1 },\n seed: { type: \"number\" },\n stream: { type: \"boolean\" },\n reasoning_effort: {\n type: \"string\",\n values: [\"none\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\"],\n },\n },\n vercel: {\n // Loose validation — proxies to many providers with varying ranges\n temperature: { type: \"number\", min: 0, max: 2 },\n max_tokens: { type: \"number\", min: 1 },\n top_p: { type: \"number\", min: 0, max: 1 },\n top_k: { type: \"number\", min: 0 },\n frequency_penalty: { type: \"number\", min: -2, max: 2 },\n presence_penalty: { type: \"number\", min: -2, max: 2 },\n stop: { type: \"string\" },\n n: { type: \"number\", min: 1 },\n seed: { type: \"number\" },\n stream: { type: \"boolean\" },\n reasoning_effort: {\n type: \"string\",\n values: [\"none\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\"],\n },\n },\n};\n\n/** OpenAI reasoning models don't support standard sampling params. */\nexport function isReasoningModel(model: string): boolean {\n // Strip gateway prefix: \"openai/o3\" → \"o3\"\n const name = model.includes(\"/\") ? model.split(\"/\").pop()! : model;\n return /^o[134]/.test(name);\n}\n\n/** Providers that can route to OpenAI models (and need reasoning-model checks). */\nexport function canHostOpenAIModels(provider: Provider): boolean {\n return provider === \"openai\" || provider === \"openrouter\" || provider === \"vercel\";\n}\n\nexport const REASONING_MODEL_UNSUPPORTED = new Set([\n \"temperature\",\n \"top_p\",\n \"frequency_penalty\",\n \"presence_penalty\",\n \"n\",\n]);\n\n/**\n * Bedrock model IDs are prefixed with the vendor name.\n * e.g. \"anthropic.claude-sonnet-4-5-20250929-v1:0\"\n */\nexport type BedrockModelFamily =\n | \"anthropic\"\n | \"meta\"\n | \"amazon\"\n | \"mistral\"\n | \"cohere\"\n | \"ai21\";\n\nexport function detectBedrockModelFamily(\n model: string,\n): BedrockModelFamily | undefined {\n // Handle cross-region inference profiles (e.g. \"us.anthropic.claude-sonnet-4-5...\")\n // and global inference profiles (e.g. \"global.anthropic.claude-sonnet-4-5...\")\n const parts = model.split(\".\");\n \n // If first part is a region prefix (us, eu, apac) or global, skip it\n let prefix = parts[0];\n if ([\"us\", \"eu\", \"apac\", \"global\"].includes(prefix) && parts.length > 1) {\n prefix = parts[1];\n }\n\n const families: BedrockModelFamily[] = [\n \"anthropic\",\n \"meta\",\n \"amazon\",\n \"mistral\",\n \"cohere\",\n \"ai21\",\n ];\n return families.find((f) => prefix === f);\n}\n\n/** Whether a Bedrock model supports prompt caching (Claude and Nova only). */\nexport function bedrockSupportsCaching(model: string): boolean {\n const family = detectBedrockModelFamily(model);\n if (family === \"anthropic\") return true;\n if (family === \"amazon\" && model.includes(\"nova\")) return true;\n return false;\n}\n\n/** Cache value normalization per provider. */\nexport const CACHE_VALUES: Record<Provider, string | undefined> = {\n openai: undefined, // OpenAI auto-caches; no explicit param\n anthropic: \"ephemeral\",\n google: undefined, // Google uses explicit caching API, not a param\n mistral: undefined,\n cohere: undefined,\n bedrock: \"ephemeral\", // Supported for Claude models on Bedrock\n openrouter: undefined, // Depends on underlying provider\n vercel: undefined, // Depends on underlying provider\n};\n\n/** Valid cache TTL values per provider. */\nexport const CACHE_TTLS: Record<Provider, string[] | undefined> = {\n openai: undefined,\n anthropic: [\"5m\", \"1h\"],\n google: undefined,\n mistral: undefined,\n cohere: undefined,\n bedrock: [\"5m\", \"1h\"], // Claude on Bedrock uses same TTLs as direct Anthropic\n openrouter: undefined,\n vercel: undefined,\n};\n\n/** Match a duration expression like \"5m\", \"1h\", \"30m\". */\nexport const DURATION_RE = /^\\d+[mh]$/;\n","import type { LlmConnectionConfig } from \"./parse.js\";\nimport {\n ALIASES,\n CACHE_TTLS,\n CACHE_VALUES,\n DURATION_RE,\n PROVIDER_PARAMS,\n bedrockSupportsCaching,\n canHostOpenAIModels,\n detectProvider,\n isReasoningModel,\n type Provider,\n} from \"./providers.js\";\n\nexport interface NormalizeChange {\n from: string;\n to: string;\n value: string;\n reason: string;\n}\n\nexport interface NormalizeResult {\n config: LlmConnectionConfig;\n provider: Provider | undefined;\n changes: NormalizeChange[];\n}\n\nexport interface NormalizeOptions {\n /** Include detailed change log in the result. */\n verbose?: boolean;\n}\n\n/**\n * Normalize an LLM connection config's params for its target provider.\n *\n * 1. Expands shorthand aliases (e.g. `temp` → `temperature`)\n * 2. Maps canonical param names to provider-specific names\n * (e.g. `max_tokens` → `maxOutputTokens` for Google)\n * 3. Normalizes special values (e.g. `cache=true` → `cache_control=ephemeral` for Anthropic)\n * 4. For OpenAI reasoning models, remaps `max_tokens` → `max_completion_tokens`\n * and warns about unsupported sampling params\n */\nexport function normalize(\n config: LlmConnectionConfig,\n options: NormalizeOptions = {},\n): NormalizeResult {\n const provider = detectProvider(config.host);\n const changes: NormalizeChange[] = [];\n const params: Record<string, string> = {};\n\n for (const [rawKey, value] of Object.entries(config.params)) {\n let key = rawKey;\n\n // Step 1: Expand aliases to canonical name\n if (ALIASES[key]) {\n const canonical = ALIASES[key];\n if (options.verbose) {\n changes.push({\n from: key,\n to: canonical,\n value,\n reason: `alias: \"${key}\" → \"${canonical}\"`,\n });\n }\n key = canonical;\n }\n\n // Step 2: Handle special \"cache\" param\n if (key === \"cache\" && provider) {\n let cacheValue = CACHE_VALUES[provider];\n\n // Bedrock supports cache for Anthropic Claude and Amazon Nova models\n if (provider === \"bedrock\" && !bedrockSupportsCaching(config.model)) {\n cacheValue = undefined;\n }\n\n // Provider/model doesn't support cache — drop it\n if (!cacheValue) {\n if (options.verbose) {\n changes.push({\n from: \"cache\",\n to: \"(dropped)\",\n value,\n reason: `${provider} does not use a cache param for this model (caching is automatic or unsupported)`,\n });\n }\n continue;\n }\n\n const isBool = value === \"true\" || value === \"1\" || value === \"yes\";\n const isDuration = DURATION_RE.test(value);\n\n if (isBool || isDuration) {\n const providerKey =\n PROVIDER_PARAMS[provider]?.[\"cache\"] ?? \"cache\";\n if (options.verbose) {\n changes.push({\n from: \"cache\",\n to: providerKey,\n value: cacheValue,\n reason: `cache=${value} → ${providerKey}=${cacheValue} for ${provider}`,\n });\n }\n params[providerKey] = cacheValue;\n\n // Emit cache_ttl when a duration is specified\n if (isDuration && CACHE_TTLS[provider]) {\n if (options.verbose) {\n changes.push({\n from: \"cache\",\n to: \"cache_ttl\",\n value,\n reason: `cache=${value} → cache_ttl=${value} for ${provider}`,\n });\n }\n params[\"cache_ttl\"] = value;\n }\n continue;\n }\n }\n\n // Step 3: Map canonical → provider-specific param name\n if (provider && PROVIDER_PARAMS[provider]) {\n const providerKey = PROVIDER_PARAMS[provider][key];\n if (providerKey && providerKey !== key) {\n if (options.verbose) {\n changes.push({\n from: key,\n to: providerKey,\n value,\n reason: `${provider} uses \"${providerKey}\" instead of \"${key}\"`,\n });\n }\n key = providerKey;\n }\n }\n\n // Step 4: OpenAI reasoning model adjustments (direct or via gateway)\n if (\n provider &&\n canHostOpenAIModels(provider) &&\n isReasoningModel(config.model) &&\n key === \"max_tokens\"\n ) {\n if (options.verbose) {\n changes.push({\n from: \"max_tokens\",\n to: \"max_completion_tokens\",\n value,\n reason:\n \"OpenAI reasoning models use max_completion_tokens instead of max_tokens\",\n });\n }\n key = \"max_completion_tokens\";\n }\n\n params[key] = value;\n }\n\n return {\n config: { ...config, params },\n provider,\n changes,\n };\n}\n","import { parse } from \"./parse.js\";\nimport { normalize } from \"./normalize.js\";\nimport {\n PARAM_SPECS,\n PROVIDER_PARAMS,\n REASONING_MODEL_UNSUPPORTED,\n bedrockSupportsCaching,\n canHostOpenAIModels,\n detectBedrockModelFamily,\n detectProvider,\n isReasoningModel,\n} from \"./providers.js\";\n\nexport interface ValidationIssue {\n param: string;\n value: string;\n message: string;\n severity: \"error\" | \"warning\";\n}\n\n/**\n * Validate an LLM connection string.\n *\n * Parses and normalizes the string, then checks params against provider specs.\n * Returns a list of issues found. An empty array means all params look valid.\n */\nexport function validate(connectionString: string): ValidationIssue[] {\n const parsed = parse(connectionString);\n const { config } = normalize(parsed);\n const provider = detectProvider(config.host);\n const issues: ValidationIssue[] = [];\n\n if (!provider) {\n issues.push({\n param: \"host\",\n value: config.host,\n message: `Unknown provider for host \"${config.host}\". Validation skipped.`,\n severity: \"warning\",\n });\n return issues;\n }\n\n const specs = PARAM_SPECS[provider];\n const knownParams = new Set(Object.values(PROVIDER_PARAMS[provider]));\n\n for (const [key, value] of Object.entries(config.params)) {\n // Check for OpenAI reasoning model restrictions (direct or via gateway)\n if (\n canHostOpenAIModels(provider) &&\n isReasoningModel(config.model) &&\n REASONING_MODEL_UNSUPPORTED.has(key)\n ) {\n issues.push({\n param: key,\n value,\n message: `\"${key}\" is not supported by OpenAI reasoning model \"${config.model}\". Use \"reasoning_effort\" instead of temperature for controlling output.`,\n severity: \"error\",\n });\n continue;\n }\n\n // Bedrock model-family-specific checks\n if (provider === \"bedrock\") {\n const family = detectBedrockModelFamily(config.model);\n\n // topK is only supported by Claude, Cohere, and Mistral on Bedrock\n if (\n key === \"topK\" &&\n family &&\n family !== \"anthropic\" &&\n family !== \"cohere\" &&\n family !== \"mistral\"\n ) {\n issues.push({\n param: key,\n value,\n message: `\"topK\" is not supported by ${family} models on Bedrock.`,\n severity: \"error\",\n });\n continue;\n }\n\n // cache_control is only supported by Claude and Nova on Bedrock\n if (key === \"cache_control\" && !bedrockSupportsCaching(config.model)) {\n issues.push({\n param: key,\n value,\n message: `Prompt caching is only supported for Anthropic Claude and Amazon Nova models on Bedrock, not ${family ?? \"unknown\"} models.`,\n severity: \"error\",\n });\n continue;\n }\n }\n\n // Check if param is known for this provider\n if (!knownParams.has(key) && !specs[key]) {\n issues.push({\n param: key,\n value,\n message: `Unknown param \"${key}\" for ${provider}.`,\n severity: \"warning\",\n });\n continue;\n }\n\n // Validate against spec\n const spec = specs[key];\n if (!spec) continue;\n\n // Anthropic (and Bedrock Claude) mutual exclusion for temperature/top_p\n if (\n (provider === \"anthropic\" ||\n (provider === \"bedrock\" &&\n detectBedrockModelFamily(config.model) === \"anthropic\")) &&\n (key === \"temperature\" || key === \"top_p\" || key === \"topP\")\n ) {\n const otherKey =\n key === \"temperature\"\n ? provider === \"bedrock\"\n ? \"topP\"\n : \"top_p\"\n : \"temperature\";\n // Only report error once (on the temperature param) to avoid duplicate errors\n if (key === \"temperature\" && config.params[otherKey] !== undefined) {\n issues.push({\n param: key,\n value,\n message: `Cannot specify both \"temperature\" and \"${otherKey}\" for Anthropic models.`,\n severity: \"error\",\n });\n }\n }\n\n if (spec.type === \"number\") {\n const num = Number(value);\n if (isNaN(num)) {\n issues.push({\n param: key,\n value,\n message: `\"${key}\" should be a number, got \"${value}\".`,\n severity: \"error\",\n });\n continue;\n }\n if (spec.min !== undefined && num < spec.min) {\n issues.push({\n param: key,\n value,\n message: `\"${key}\" must be >= ${spec.min}, got ${num}.`,\n severity: \"error\",\n });\n }\n if (spec.max !== undefined && num > spec.max) {\n issues.push({\n param: key,\n value,\n message: `\"${key}\" must be <= ${spec.max}, got ${num}.`,\n severity: \"error\",\n });\n }\n }\n\n if (spec.type === \"boolean\") {\n if (![\"true\", \"false\", \"0\", \"1\"].includes(value)) {\n issues.push({\n param: key,\n value,\n message: `\"${key}\" should be a boolean (true/false), got \"${value}\".`,\n severity: \"error\",\n });\n }\n }\n\n if (spec.type === \"string\" && spec.values) {\n if (!spec.values.includes(value)) {\n issues.push({\n param: key,\n value,\n message: `\"${key}\" must be one of [${spec.values.join(\", \")}], got \"${value}\".`,\n severity: \"error\",\n });\n }\n }\n }\n\n return issues;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC0BO,SAAS,MAAM,kBAA+C;AACnE,QAAM,MAAM,IAAI,IAAI,gBAAgB;AAEpC,MAAI,IAAI,aAAa,QAAQ;AAC3B,UAAM,IAAI;AAAA,MACR,2CAA2C,IAAI,QAAQ;AAAA,IACzD;AAAA,EACF;AAEA,QAAM,OAAO,IAAI;AACjB,QAAM,QAAQ,IAAI,SAAS,QAAQ,OAAO,EAAE;AAC5C,QAAM,QAAQ,IAAI,YAAY;AAC9B,QAAM,SAAS,IAAI,YAAY;AAE/B,QAAM,SAAiC,CAAC;AACxC,aAAW,CAAC,KAAK,KAAK,KAAK,IAAI,cAAc;AAC3C,WAAO,GAAG,IAAI;AAAA,EAChB;AAEA,SAAO;AAAA,IACL,KAAK;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAKO,SAAS,MAAM,QAAkD;AACtE,QAAM,OACJ,OAAO,SAAS,OAAO,SACnB,GAAG,OAAO,SAAS,EAAE,GAAG,OAAO,SAAS,IAAI,OAAO,MAAM,KAAK,EAAE,MAChE;AAEN,QAAM,QAAQ,IAAI,gBAAgB,OAAO,MAAM,EAAE,SAAS;AAC1D,QAAM,KAAK,QAAQ,IAAI,KAAK,KAAK;AAEjC,SAAO,SAAS,IAAI,GAAG,OAAO,IAAI,IAAI,OAAO,KAAK,GAAG,EAAE;AACzD;;;AC1DO,SAAS,eAAe,MAAoC;AAEjE,MAAI,KAAK,SAAS,YAAY,EAAG,Q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K;AAAA,UACjE,UAAU;AAAA,QACZ,CAAC;AAAA,MACH;AAAA,IACF;AAEA,QAAI,KAAK,SAAS,YAAY,KAAK,QAAQ;AACzC,UAAI,CAAC,KAAK,OAAO,SAAS,KAAK,GAAG;AAChC,eAAO,KAAK;AAAA,UACV,OAAO;AAAA,UACP;AAAA,UACA,SAAS,IAAI,GAAG,qBAAqB,KAAK,OAAO,KAAK,IAAI,CAAC,WAAW,KAAK;AAAA,UAC3E,UAAU;AAAA,QACZ,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
interface LlmConnectionConfig {
|
|
2
|
+
/** The original connection string */
|
|
3
|
+
raw: string;
|
|
4
|
+
/** Provider's API base URL (e.g. "api.openai.com") */
|
|
5
|
+
host: string;
|
|
6
|
+
/** Model name (e.g. "gpt-5.2") */
|
|
7
|
+
model: string;
|
|
8
|
+
/** Optional label or app name */
|
|
9
|
+
label?: string;
|
|
10
|
+
/** Optional API key or password */
|
|
11
|
+
apiKey?: string;
|
|
12
|
+
/** Additional config parameters (temp, max_tokens, etc.) */
|
|
13
|
+
params: Record<string, string>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Parse an LLM connection string into its component parts.
|
|
17
|
+
*
|
|
18
|
+
* Format: `llm://[label[:apiKey]@]host/model[?key=value&...]`
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* parse("llm://api.openai.com/gpt-5.2?temp=0.7&max_tokens=1500")
|
|
23
|
+
* parse("llm://app-name:sk-proj-123456@api.openai.com/gpt-5.2?temp=0.7")
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
declare function parse(connectionString: string): LlmConnectionConfig;
|
|
27
|
+
/**
|
|
28
|
+
* Build an LLM connection string from a config object.
|
|
29
|
+
*/
|
|
30
|
+
declare function build(config: Omit<LlmConnectionConfig, "raw">): string;
|
|
31
|
+
|
|
32
|
+
type Provider = "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openrouter" | "vercel";
|
|
33
|
+
declare function detectProvider(host: string): Provider | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Shorthand aliases → canonical param name.
|
|
36
|
+
* Canonical names use snake_case and follow OpenAI conventions where possible.
|
|
37
|
+
*/
|
|
38
|
+
declare const ALIASES: Record<string, string>;
|
|
39
|
+
/**
|
|
40
|
+
* Canonical param name → provider-specific API param name.
|
|
41
|
+
* Only includes params the provider actually supports.
|
|
42
|
+
*/
|
|
43
|
+
declare const PROVIDER_PARAMS: Record<Provider, Record<string, string>>;
|
|
44
|
+
/**
|
|
45
|
+
* Bedrock model IDs are prefixed with the vendor name.
|
|
46
|
+
* e.g. "anthropic.claude-sonnet-4-5-20250929-v1:0"
|
|
47
|
+
*/
|
|
48
|
+
type BedrockModelFamily = "anthropic" | "meta" | "amazon" | "mistral" | "cohere" | "ai21";
|
|
49
|
+
declare function detectBedrockModelFamily(model: string): BedrockModelFamily | undefined;
|
|
50
|
+
|
|
51
|
+
interface NormalizeChange {
|
|
52
|
+
from: string;
|
|
53
|
+
to: string;
|
|
54
|
+
value: string;
|
|
55
|
+
reason: string;
|
|
56
|
+
}
|
|
57
|
+
interface NormalizeResult {
|
|
58
|
+
config: LlmConnectionConfig;
|
|
59
|
+
provider: Provider | undefined;
|
|
60
|
+
changes: NormalizeChange[];
|
|
61
|
+
}
|
|
62
|
+
interface NormalizeOptions {
|
|
63
|
+
/** Include detailed change log in the result. */
|
|
64
|
+
verbose?: boolean;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Normalize an LLM connection config's params for its target provider.
|
|
68
|
+
*
|
|
69
|
+
* 1. Expands shorthand aliases (e.g. `temp` → `temperature`)
|
|
70
|
+
* 2. Maps canonical param names to provider-specific names
|
|
71
|
+
* (e.g. `max_tokens` → `maxOutputTokens` for Google)
|
|
72
|
+
* 3. Normalizes special values (e.g. `cache=true` → `cache_control=ephemeral` for Anthropic)
|
|
73
|
+
* 4. For OpenAI reasoning models, remaps `max_tokens` → `max_completion_tokens`
|
|
74
|
+
* and warns about unsupported sampling params
|
|
75
|
+
*/
|
|
76
|
+
declare function normalize(config: LlmConnectionConfig, options?: NormalizeOptions): NormalizeResult;
|
|
77
|
+
|
|
78
|
+
interface ValidationIssue {
|
|
79
|
+
param: string;
|
|
80
|
+
value: string;
|
|
81
|
+
message: string;
|
|
82
|
+
severity: "error" | "warning";
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Validate an LLM connection string.
|
|
86
|
+
*
|
|
87
|
+
* Parses and normalizes the string, then checks params against provider specs.
|
|
88
|
+
* Returns a list of issues found. An empty array means all params look valid.
|
|
89
|
+
*/
|
|
90
|
+
declare function validate(connectionString: string): ValidationIssue[];
|
|
91
|
+
|
|
92
|
+
export { ALIASES, type BedrockModelFamily, type LlmConnectionConfig, type NormalizeChange, type NormalizeOptions, type NormalizeResult, PROVIDER_PARAMS, type Provider, type ValidationIssue, build, detectBedrockModelFamily, detectProvider, normalize, parse, validate };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
interface LlmConnectionConfig {
|
|
2
|
+
/** The original connection string */
|
|
3
|
+
raw: string;
|
|
4
|
+
/** Provider's API base URL (e.g. "api.openai.com") */
|
|
5
|
+
host: string;
|
|
6
|
+
/** Model name (e.g. "gpt-5.2") */
|
|
7
|
+
model: string;
|
|
8
|
+
/** Optional label or app name */
|
|
9
|
+
label?: string;
|
|
10
|
+
/** Optional API key or password */
|
|
11
|
+
apiKey?: string;
|
|
12
|
+
/** Additional config parameters (temp, max_tokens, etc.) */
|
|
13
|
+
params: Record<string, string>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Parse an LLM connection string into its component parts.
|
|
17
|
+
*
|
|
18
|
+
* Format: `llm://[label[:apiKey]@]host/model[?key=value&...]`
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* parse("llm://api.openai.com/gpt-5.2?temp=0.7&max_tokens=1500")
|
|
23
|
+
* parse("llm://app-name:sk-proj-123456@api.openai.com/gpt-5.2?temp=0.7")
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
declare function parse(connectionString: string): LlmConnectionConfig;
|
|
27
|
+
/**
|
|
28
|
+
* Build an LLM connection string from a config object.
|
|
29
|
+
*/
|
|
30
|
+
declare function build(config: Omit<LlmConnectionConfig, "raw">): string;
|
|
31
|
+
|
|
32
|
+
type Provider = "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openrouter" | "vercel";
|
|
33
|
+
declare function detectProvider(host: string): Provider | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Shorthand aliases → canonical param name.
|
|
36
|
+
* Canonical names use snake_case and follow OpenAI conventions where possible.
|
|
37
|
+
*/
|
|
38
|
+
declare const ALIASES: Record<string, string>;
|
|
39
|
+
/**
|
|
40
|
+
* Canonical param name → provider-specific API param name.
|
|
41
|
+
* Only includes params the provider actually supports.
|
|
42
|
+
*/
|
|
43
|
+
declare const PROVIDER_PARAMS: Record<Provider, Record<string, string>>;
|
|
44
|
+
/**
|
|
45
|
+
* Bedrock model IDs are prefixed with the vendor name.
|
|
46
|
+
* e.g. "anthropic.claude-sonnet-4-5-20250929-v1:0"
|
|
47
|
+
*/
|
|
48
|
+
type BedrockModelFamily = "anthropic" | "meta" | "amazon" | "mistral" | "cohere" | "ai21";
|
|
49
|
+
declare function detectBedrockModelFamily(model: string): BedrockModelFamily | undefined;
|
|
50
|
+
|
|
51
|
+
interface NormalizeChange {
|
|
52
|
+
from: string;
|
|
53
|
+
to: string;
|
|
54
|
+
value: string;
|
|
55
|
+
reason: string;
|
|
56
|
+
}
|
|
57
|
+
interface NormalizeResult {
|
|
58
|
+
config: LlmConnectionConfig;
|
|
59
|
+
provider: Provider | undefined;
|
|
60
|
+
changes: NormalizeChange[];
|
|
61
|
+
}
|
|
62
|
+
interface NormalizeOptions {
|
|
63
|
+
/** Include detailed change log in the result. */
|
|
64
|
+
verbose?: boolean;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Normalize an LLM connection config's params for its target provider.
|
|
68
|
+
*
|
|
69
|
+
* 1. Expands shorthand aliases (e.g. `temp` → `temperature`)
|
|
70
|
+
* 2. Maps canonical param names to provider-specific names
|
|
71
|
+
* (e.g. `max_tokens` → `maxOutputTokens` for Google)
|
|
72
|
+
* 3. Normalizes special values (e.g. `cache=true` → `cache_control=ephemeral` for Anthropic)
|
|
73
|
+
* 4. For OpenAI reasoning models, remaps `max_tokens` → `max_completion_tokens`
|
|
74
|
+
* and warns about unsupported sampling params
|
|
75
|
+
*/
|
|
76
|
+
declare function normalize(config: LlmConnectionConfig, options?: NormalizeOptions): NormalizeResult;
|
|
77
|
+
|
|
78
|
+
interface ValidationIssue {
|
|
79
|
+
param: string;
|
|
80
|
+
value: string;
|
|
81
|
+
message: string;
|
|
82
|
+
severity: "error" | "warning";
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Validate an LLM connection string.
|
|
86
|
+
*
|
|
87
|
+
* Parses and normalizes the string, then checks params against provider specs.
|
|
88
|
+
* Returns a list of issues found. An empty array means all params look valid.
|
|
89
|
+
*/
|
|
90
|
+
declare function validate(connectionString: string): ValidationIssue[];
|
|
91
|
+
|
|
92
|
+
export { ALIASES, type BedrockModelFamily, type LlmConnectionConfig, type NormalizeChange, type NormalizeOptions, type NormalizeResult, PROVIDER_PARAMS, type Provider, type ValidationIssue, build, detectBedrockModelFamily, detectProvider, normalize, parse, validate };
|