llm-strings 1.0.0 → 1.1.0

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.
Files changed (54) hide show
  1. package/README.md +87 -12
  2. package/dist/chunk-6P5GSSNW.js +176 -0
  3. package/dist/chunk-6P5GSSNW.js.map +1 -0
  4. package/dist/chunk-FCEV23OT.js +37 -0
  5. package/dist/chunk-FCEV23OT.js.map +1 -0
  6. package/dist/chunk-MGWGNZDJ.cjs +116 -0
  7. package/dist/chunk-MGWGNZDJ.cjs.map +1 -0
  8. package/dist/chunk-MPIHGH6L.js +116 -0
  9. package/dist/chunk-MPIHGH6L.js.map +1 -0
  10. package/dist/chunk-N6NVBE43.cjs +37 -0
  11. package/dist/chunk-N6NVBE43.cjs.map +1 -0
  12. package/dist/chunk-NSCBY4VD.cjs +370 -0
  13. package/dist/chunk-NSCBY4VD.cjs.map +1 -0
  14. package/dist/chunk-RR3VXIW2.cjs +176 -0
  15. package/dist/chunk-RR3VXIW2.cjs.map +1 -0
  16. package/dist/chunk-RSUXM42X.cjs +180 -0
  17. package/dist/chunk-RSUXM42X.cjs.map +1 -0
  18. package/dist/chunk-UYMVUTLV.js +180 -0
  19. package/dist/chunk-UYMVUTLV.js.map +1 -0
  20. package/dist/chunk-XID353H7.js +370 -0
  21. package/dist/chunk-XID353H7.js.map +1 -0
  22. package/dist/index.cjs +46 -811
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +5 -140
  25. package/dist/index.d.ts +5 -140
  26. package/dist/index.js +29 -753
  27. package/dist/index.js.map +1 -1
  28. package/dist/normalize.cjs +8 -0
  29. package/dist/normalize.cjs.map +1 -0
  30. package/dist/normalize.d.cts +33 -0
  31. package/dist/normalize.d.ts +33 -0
  32. package/dist/normalize.js +8 -0
  33. package/dist/normalize.js.map +1 -0
  34. package/dist/parse.cjs +9 -0
  35. package/dist/parse.cjs.map +1 -0
  36. package/dist/parse.d.cts +32 -0
  37. package/dist/parse.d.ts +32 -0
  38. package/dist/parse.js +9 -0
  39. package/dist/parse.js.map +1 -0
  40. package/dist/provider-core-BUaKKLpd.d.cts +53 -0
  41. package/dist/provider-core-BUaKKLpd.d.ts +53 -0
  42. package/dist/providers.cjs +41 -0
  43. package/dist/providers.cjs.map +1 -0
  44. package/dist/providers.d.cts +34 -0
  45. package/dist/providers.d.ts +34 -0
  46. package/dist/providers.js +41 -0
  47. package/dist/providers.js.map +1 -0
  48. package/dist/validate.cjs +10 -0
  49. package/dist/validate.cjs.map +1 -0
  50. package/dist/validate.d.cts +21 -0
  51. package/dist/validate.d.ts +21 -0
  52. package/dist/validate.js +10 -0
  53. package/dist/validate.js.map +1 -0
  54. package/package.json +33 -1
package/dist/index.cjs CHANGED
@@ -1,812 +1,47 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- ALIASES: () => ALIASES,
24
- CANONICAL_PARAM_SPECS: () => CANONICAL_PARAM_SPECS,
25
- MODELS: () => MODELS,
26
- PARAM_SPECS: () => PARAM_SPECS,
27
- PROVIDER_META: () => PROVIDER_META,
28
- PROVIDER_PARAMS: () => PROVIDER_PARAMS,
29
- REASONING_MODEL_UNSUPPORTED: () => REASONING_MODEL_UNSUPPORTED,
30
- build: () => build,
31
- canHostOpenAIModels: () => canHostOpenAIModels,
32
- detectBedrockModelFamily: () => detectBedrockModelFamily,
33
- detectProvider: () => detectProvider,
34
- isReasoningModel: () => isReasoningModel,
35
- normalize: () => normalize,
36
- parse: () => parse,
37
- validate: () => validate
38
- });
39
- module.exports = __toCommonJS(index_exports);
40
-
41
- // src/parse.ts
42
- function parse(connectionString) {
43
- const url = new URL(connectionString);
44
- if (url.protocol !== "llm:") {
45
- throw new Error(
46
- `Invalid scheme: expected "llm://", got "${url.protocol}//"`
47
- );
48
- }
49
- const host = url.hostname;
50
- const model = url.pathname.replace(/^\//, "");
51
- const label = url.username || void 0;
52
- const apiKey = url.password || void 0;
53
- const params = {};
54
- for (const [key, value] of url.searchParams) {
55
- params[key] = value;
56
- }
57
- return {
58
- raw: connectionString,
59
- host,
60
- model,
61
- label,
62
- apiKey,
63
- params
64
- };
65
- }
66
- function build(config) {
67
- const auth = config.label || config.apiKey ? `${config.label ?? ""}${config.apiKey ? `:${config.apiKey}` : ""}@` : "";
68
- const query = new URLSearchParams(config.params).toString();
69
- const qs = query ? `?${query}` : "";
70
- return `llm://${auth}${config.host}/${config.model}${qs}`;
71
- }
72
-
73
- // src/providers.ts
74
- function detectProvider(host) {
75
- if (host.includes("openrouter")) return "openrouter";
76
- if (host.includes("gateway.ai.vercel")) return "vercel";
77
- if (host.includes("amazonaws") || host.includes("bedrock")) return "bedrock";
78
- if (host.includes("openai")) return "openai";
79
- if (host.includes("anthropic") || host.includes("claude")) return "anthropic";
80
- if (host.includes("googleapis") || host.includes("google")) return "google";
81
- if (host.includes("mistral")) return "mistral";
82
- if (host.includes("cohere")) return "cohere";
83
- return void 0;
84
- }
85
- var ALIASES = {
86
- // temperature
87
- temp: "temperature",
88
- // max_tokens
89
- max: "max_tokens",
90
- max_out: "max_tokens",
91
- max_output: "max_tokens",
92
- max_output_tokens: "max_tokens",
93
- max_completion_tokens: "max_tokens",
94
- maxOutputTokens: "max_tokens",
95
- maxTokens: "max_tokens",
96
- // top_p
97
- topp: "top_p",
98
- topP: "top_p",
99
- nucleus: "top_p",
100
- // top_k
101
- topk: "top_k",
102
- topK: "top_k",
103
- // frequency_penalty
104
- freq: "frequency_penalty",
105
- freq_penalty: "frequency_penalty",
106
- frequencyPenalty: "frequency_penalty",
107
- repetition_penalty: "frequency_penalty",
108
- // presence_penalty
109
- pres: "presence_penalty",
110
- pres_penalty: "presence_penalty",
111
- presencePenalty: "presence_penalty",
112
- // stop
113
- stop_sequences: "stop",
114
- stopSequences: "stop",
115
- stop_sequence: "stop",
116
- // seed
117
- random_seed: "seed",
118
- randomSeed: "seed",
119
- // n (completions count)
120
- candidateCount: "n",
121
- candidate_count: "n",
122
- num_completions: "n",
123
- // effort / reasoning
124
- reasoning_effort: "effort",
125
- reasoning: "effort",
126
- // cache
127
- cache_control: "cache",
128
- cacheControl: "cache",
129
- cachePoint: "cache",
130
- cache_point: "cache"
131
- };
132
- var PROVIDER_PARAMS = {
133
- openai: {
134
- temperature: "temperature",
135
- max_tokens: "max_tokens",
136
- top_p: "top_p",
137
- frequency_penalty: "frequency_penalty",
138
- presence_penalty: "presence_penalty",
139
- stop: "stop",
140
- n: "n",
141
- seed: "seed",
142
- stream: "stream",
143
- effort: "reasoning_effort"
144
- },
145
- anthropic: {
146
- temperature: "temperature",
147
- max_tokens: "max_tokens",
148
- top_p: "top_p",
149
- top_k: "top_k",
150
- stop: "stop_sequences",
151
- stream: "stream",
152
- effort: "effort",
153
- cache: "cache_control",
154
- cache_ttl: "cache_ttl"
155
- },
156
- google: {
157
- temperature: "temperature",
158
- max_tokens: "maxOutputTokens",
159
- top_p: "topP",
160
- top_k: "topK",
161
- frequency_penalty: "frequencyPenalty",
162
- presence_penalty: "presencePenalty",
163
- stop: "stopSequences",
164
- n: "candidateCount",
165
- stream: "stream",
166
- seed: "seed",
167
- responseMimeType: "responseMimeType",
168
- responseSchema: "responseSchema"
169
- },
170
- mistral: {
171
- temperature: "temperature",
172
- max_tokens: "max_tokens",
173
- top_p: "top_p",
174
- frequency_penalty: "frequency_penalty",
175
- presence_penalty: "presence_penalty",
176
- stop: "stop",
177
- n: "n",
178
- seed: "random_seed",
179
- stream: "stream",
180
- safe_prompt: "safe_prompt",
181
- min_tokens: "min_tokens"
182
- },
183
- cohere: {
184
- temperature: "temperature",
185
- max_tokens: "max_tokens",
186
- top_p: "p",
187
- top_k: "k",
188
- frequency_penalty: "frequency_penalty",
189
- presence_penalty: "presence_penalty",
190
- stop: "stop_sequences",
191
- stream: "stream",
192
- seed: "seed"
193
- },
194
- bedrock: {
195
- // Bedrock Converse API uses camelCase
196
- temperature: "temperature",
197
- max_tokens: "maxTokens",
198
- top_p: "topP",
199
- top_k: "topK",
200
- // Claude models via additionalModelRequestFields
201
- stop: "stopSequences",
202
- stream: "stream",
203
- cache: "cache_control",
204
- cache_ttl: "cache_ttl"
205
- },
206
- openrouter: {
207
- // OpenAI-compatible API with extra routing params
208
- temperature: "temperature",
209
- max_tokens: "max_tokens",
210
- top_p: "top_p",
211
- top_k: "top_k",
212
- frequency_penalty: "frequency_penalty",
213
- presence_penalty: "presence_penalty",
214
- stop: "stop",
215
- n: "n",
216
- seed: "seed",
217
- stream: "stream",
218
- effort: "reasoning_effort"
219
- },
220
- vercel: {
221
- // OpenAI-compatible gateway
222
- temperature: "temperature",
223
- max_tokens: "max_tokens",
224
- top_p: "top_p",
225
- top_k: "top_k",
226
- frequency_penalty: "frequency_penalty",
227
- presence_penalty: "presence_penalty",
228
- stop: "stop",
229
- n: "n",
230
- seed: "seed",
231
- stream: "stream",
232
- effort: "reasoning_effort"
233
- }
234
- };
235
- var PARAM_SPECS = {
236
- openai: {
237
- temperature: { type: "number", min: 0, max: 2 },
238
- max_tokens: { type: "number", min: 1 },
239
- top_p: { type: "number", min: 0, max: 1 },
240
- frequency_penalty: { type: "number", min: -2, max: 2 },
241
- presence_penalty: { type: "number", min: -2, max: 2 },
242
- stop: { type: "string" },
243
- n: { type: "number", min: 1 },
244
- seed: { type: "number" },
245
- stream: { type: "boolean" },
246
- reasoning_effort: {
247
- type: "string",
248
- values: ["none", "minimal", "low", "medium", "high", "xhigh"]
249
- }
250
- },
251
- anthropic: {
252
- temperature: { type: "number", min: 0, max: 1 },
253
- max_tokens: { type: "number", min: 1 },
254
- top_p: { type: "number", min: 0, max: 1 },
255
- top_k: { type: "number", min: 0 },
256
- stop_sequences: { type: "string" },
257
- stream: { type: "boolean" },
258
- effort: { type: "string", values: ["low", "medium", "high", "max"] },
259
- cache_control: { type: "string", values: ["ephemeral"] },
260
- cache_ttl: { type: "string", values: ["5m", "1h"] }
261
- },
262
- google: {
263
- temperature: { type: "number", min: 0, max: 2 },
264
- maxOutputTokens: { type: "number", min: 1 },
265
- topP: { type: "number", min: 0, max: 1 },
266
- topK: { type: "number", min: 0 },
267
- frequencyPenalty: { type: "number", min: -2, max: 2 },
268
- presencePenalty: { type: "number", min: -2, max: 2 },
269
- stopSequences: { type: "string" },
270
- candidateCount: { type: "number", min: 1 },
271
- stream: { type: "boolean" },
272
- seed: { type: "number" },
273
- responseMimeType: { type: "string" },
274
- responseSchema: { type: "string" }
275
- },
276
- mistral: {
277
- temperature: { type: "number", min: 0, max: 1 },
278
- max_tokens: { type: "number", min: 1 },
279
- top_p: { type: "number", min: 0, max: 1 },
280
- frequency_penalty: { type: "number", min: -2, max: 2 },
281
- presence_penalty: { type: "number", min: -2, max: 2 },
282
- stop: { type: "string" },
283
- n: { type: "number", min: 1 },
284
- random_seed: { type: "number" },
285
- stream: { type: "boolean" },
286
- safe_prompt: { type: "boolean" },
287
- min_tokens: { type: "number", min: 0 }
288
- },
289
- cohere: {
290
- temperature: { type: "number", min: 0, max: 1 },
291
- max_tokens: { type: "number", min: 1 },
292
- p: { type: "number", min: 0, max: 1 },
293
- k: { type: "number", min: 0, max: 500 },
294
- frequency_penalty: { type: "number", min: 0, max: 1 },
295
- presence_penalty: { type: "number", min: 0, max: 1 },
296
- stop_sequences: { type: "string" },
297
- stream: { type: "boolean" },
298
- seed: { type: "number" }
299
- },
300
- bedrock: {
301
- // Converse API inferenceConfig params
302
- temperature: { type: "number", min: 0, max: 1 },
303
- maxTokens: { type: "number", min: 1 },
304
- topP: { type: "number", min: 0, max: 1 },
305
- topK: { type: "number", min: 0 },
306
- stopSequences: { type: "string" },
307
- stream: { type: "boolean" },
308
- cache_control: { type: "string", values: ["ephemeral"] },
309
- cache_ttl: { type: "string", values: ["5m", "1h"] }
310
- },
311
- openrouter: {
312
- // Loose validation — proxies to many providers with varying ranges
313
- temperature: { type: "number", min: 0, max: 2 },
314
- max_tokens: { type: "number", min: 1 },
315
- top_p: { type: "number", min: 0, max: 1 },
316
- top_k: { type: "number", min: 0 },
317
- frequency_penalty: { type: "number", min: -2, max: 2 },
318
- presence_penalty: { type: "number", min: -2, max: 2 },
319
- stop: { type: "string" },
320
- n: { type: "number", min: 1 },
321
- seed: { type: "number" },
322
- stream: { type: "boolean" },
323
- reasoning_effort: {
324
- type: "string",
325
- values: ["none", "minimal", "low", "medium", "high", "xhigh"]
326
- }
327
- },
328
- vercel: {
329
- // Loose validation — proxies to many providers with varying ranges
330
- temperature: { type: "number", min: 0, max: 2 },
331
- max_tokens: { type: "number", min: 1 },
332
- top_p: { type: "number", min: 0, max: 1 },
333
- top_k: { type: "number", min: 0 },
334
- frequency_penalty: { type: "number", min: -2, max: 2 },
335
- presence_penalty: { type: "number", min: -2, max: 2 },
336
- stop: { type: "string" },
337
- n: { type: "number", min: 1 },
338
- seed: { type: "number" },
339
- stream: { type: "boolean" },
340
- reasoning_effort: {
341
- type: "string",
342
- values: ["none", "minimal", "low", "medium", "high", "xhigh"]
343
- }
344
- }
345
- };
346
- function isReasoningModel(model) {
347
- const name = model.includes("/") ? model.split("/").pop() : model;
348
- return /^o[134]/.test(name);
349
- }
350
- function canHostOpenAIModels(provider) {
351
- return provider === "openai" || provider === "openrouter" || provider === "vercel";
352
- }
353
- var REASONING_MODEL_UNSUPPORTED = /* @__PURE__ */ new Set([
354
- "temperature",
355
- "top_p",
356
- "frequency_penalty",
357
- "presence_penalty",
358
- "n"
359
- ]);
360
- function detectBedrockModelFamily(model) {
361
- const parts = model.split(".");
362
- let prefix = parts[0];
363
- if (["us", "eu", "apac", "global"].includes(prefix) && parts.length > 1) {
364
- prefix = parts[1];
365
- }
366
- const families = [
367
- "anthropic",
368
- "meta",
369
- "amazon",
370
- "mistral",
371
- "cohere",
372
- "ai21"
373
- ];
374
- return families.find((f) => prefix === f);
375
- }
376
- function bedrockSupportsCaching(model) {
377
- const family = detectBedrockModelFamily(model);
378
- if (family === "anthropic") return true;
379
- if (family === "amazon" && model.includes("nova")) return true;
380
- return false;
381
- }
382
- var CACHE_VALUES = {
383
- openai: void 0,
384
- // OpenAI auto-caches; no explicit param
385
- anthropic: "ephemeral",
386
- google: void 0,
387
- // Google uses explicit caching API, not a param
388
- mistral: void 0,
389
- cohere: void 0,
390
- bedrock: "ephemeral",
391
- // Supported for Claude models on Bedrock
392
- openrouter: void 0,
393
- // Depends on underlying provider
394
- vercel: void 0
395
- // Depends on underlying provider
396
- };
397
- var CACHE_TTLS = {
398
- openai: void 0,
399
- anthropic: ["5m", "1h"],
400
- google: void 0,
401
- mistral: void 0,
402
- cohere: void 0,
403
- bedrock: ["5m", "1h"],
404
- // Claude on Bedrock uses same TTLs as direct Anthropic
405
- openrouter: void 0,
406
- vercel: void 0
407
- };
408
- var DURATION_RE = /^\d+[mh]$/;
409
- var PROVIDER_META = [
410
- { id: "openai", name: "OpenAI", host: "api.openai.com", color: "#10a37f" },
411
- { id: "anthropic", name: "Anthropic", host: "api.anthropic.com", color: "#e8956a" },
412
- { id: "google", name: "Google", host: "generativelanguage.googleapis.com", color: "#4285f4" },
413
- { id: "mistral", name: "Mistral", host: "api.mistral.ai", color: "#ff7000" },
414
- { id: "cohere", name: "Cohere", host: "api.cohere.com", color: "#39594d" },
415
- { id: "bedrock", name: "Bedrock", host: "bedrock-runtime.us-east-1.amazonaws.com", color: "#ff9900" },
416
- { id: "openrouter", name: "OpenRouter", host: "openrouter.ai", color: "#818cf8" },
417
- { id: "vercel", name: "Vercel", host: "gateway.ai.vercel.app", color: "#ededed" }
418
- ];
419
- var MODELS = {
420
- openai: [
421
- "gpt-5.2",
422
- "gpt-5.2-pro",
423
- "gpt-4.1",
424
- "gpt-4.1-mini",
425
- "gpt-4.1-nano",
426
- "o3",
427
- "o3-mini",
428
- "o4-mini",
429
- "o1-pro"
430
- ],
431
- anthropic: [
432
- "claude-opus-4-6",
433
- "claude-sonnet-4-6",
434
- "claude-sonnet-4-5",
435
- "claude-haiku-4-5"
436
- ],
437
- google: [
438
- "gemini-3-pro-preview",
439
- "gemini-3-flash-preview",
440
- "gemini-2.5-pro",
441
- "gemini-2.5-flash"
442
- ],
443
- mistral: [
444
- "mistral-large-latest",
445
- "mistral-medium-latest",
446
- "mistral-small-latest",
447
- "codestral-latest",
448
- "magistral-medium-latest"
449
- ],
450
- cohere: [
451
- "command-a-03-2025",
452
- "command-r-plus-08-2024",
453
- "command-r-08-2024",
454
- "command-r7b-12-2024"
455
- ],
456
- bedrock: [
457
- "anthropic.claude-opus-4-6-v1",
458
- "anthropic.claude-sonnet-4-6-v1",
459
- "anthropic.claude-haiku-4-5-v1",
460
- "amazon.nova-pro-v1",
461
- "amazon.nova-lite-v1",
462
- "meta.llama3-70b-instruct-v1:0"
463
- ],
464
- openrouter: [
465
- "openai/gpt-5.2",
466
- "anthropic/claude-opus-4-6",
467
- "google/gemini-2.5-pro",
468
- "mistral/mistral-large-latest"
469
- ],
470
- vercel: [
471
- "openai/gpt-5.2",
472
- "anthropic/claude-opus-4-6",
473
- "google/gemini-2.5-pro",
474
- "google/gemini-3-pro-preview",
475
- "google/gemini-3-flash-preview",
476
- "mistral/mistral-large-latest",
477
- "qwen/qwen2.5-pro"
478
- ]
479
- };
480
- var CANONICAL_PARAM_SPECS = {
481
- openai: {
482
- temperature: { type: "number", min: 0, max: 2, default: 0.7, description: "Controls randomness" },
483
- max_tokens: { type: "number", min: 1, default: 4096, description: "Maximum output tokens" },
484
- top_p: { type: "number", min: 0, max: 1, default: 1, description: "Nucleus sampling" },
485
- frequency_penalty: { type: "number", min: -2, max: 2, default: 0, description: "Penalize frequent tokens" },
486
- presence_penalty: { type: "number", min: -2, max: 2, default: 0, description: "Penalize repeated topics" },
487
- stop: { type: "string", default: "", description: "Stop sequences" },
488
- n: { type: "number", min: 1, default: 1, description: "Completions count" },
489
- seed: { type: "number", default: "", description: "Random seed" },
490
- stream: { type: "boolean", default: false, description: "Stream response" },
491
- effort: { type: "enum", values: ["none", "minimal", "low", "medium", "high", "xhigh"], default: "medium", description: "Reasoning effort" }
492
- },
493
- anthropic: {
494
- temperature: { type: "number", min: 0, max: 1, default: 0.7, description: "Controls randomness" },
495
- max_tokens: { type: "number", min: 1, default: 4096, description: "Maximum output tokens" },
496
- top_p: { type: "number", min: 0, max: 1, default: 1, description: "Nucleus sampling" },
497
- top_k: { type: "number", min: 0, default: 40, description: "Top-K sampling" },
498
- stop: { type: "string", default: "", description: "Stop sequences" },
499
- stream: { type: "boolean", default: false, description: "Stream response" },
500
- effort: { type: "enum", values: ["low", "medium", "high", "max"], default: "medium", description: "Thinking effort" },
501
- cache: { type: "enum", values: ["ephemeral"], default: "ephemeral", description: "Cache control" },
502
- cache_ttl: { type: "enum", values: ["5m", "1h"], default: "5m", description: "Cache TTL" }
503
- },
504
- google: {
505
- temperature: { type: "number", min: 0, max: 2, default: 0.7, description: "Controls randomness" },
506
- max_tokens: { type: "number", min: 1, default: 4096, description: "Maximum output tokens" },
507
- top_p: { type: "number", min: 0, max: 1, default: 1, description: "Nucleus sampling" },
508
- top_k: { type: "number", min: 0, default: 40, description: "Top-K sampling" },
509
- frequency_penalty: { type: "number", min: -2, max: 2, default: 0, description: "Penalize frequent tokens" },
510
- presence_penalty: { type: "number", min: -2, max: 2, default: 0, description: "Penalize repeated topics" },
511
- stop: { type: "string", default: "", description: "Stop sequences" },
512
- n: { type: "number", min: 1, default: 1, description: "Candidate count" },
513
- stream: { type: "boolean", default: false, description: "Stream response" },
514
- seed: { type: "number", default: "", description: "Random seed" }
515
- },
516
- mistral: {
517
- temperature: { type: "number", min: 0, max: 1, default: 0.7, description: "Controls randomness" },
518
- max_tokens: { type: "number", min: 1, default: 4096, description: "Maximum output tokens" },
519
- top_p: { type: "number", min: 0, max: 1, default: 1, description: "Nucleus sampling" },
520
- frequency_penalty: { type: "number", min: -2, max: 2, default: 0, description: "Penalize frequent tokens" },
521
- presence_penalty: { type: "number", min: -2, max: 2, default: 0, description: "Penalize repeated topics" },
522
- stop: { type: "string", default: "", description: "Stop sequences" },
523
- n: { type: "number", min: 1, default: 1, description: "Completions count" },
524
- seed: { type: "number", default: "", description: "Random seed" },
525
- stream: { type: "boolean", default: false, description: "Stream response" },
526
- safe_prompt: { type: "boolean", default: false, description: "Enable safe prompt" },
527
- min_tokens: { type: "number", min: 0, default: 0, description: "Minimum tokens" }
528
- },
529
- cohere: {
530
- temperature: { type: "number", min: 0, max: 1, default: 0.7, description: "Controls randomness" },
531
- max_tokens: { type: "number", min: 1, default: 4096, description: "Maximum output tokens" },
532
- top_p: { type: "number", min: 0, max: 1, default: 1, description: "Nucleus sampling (p)" },
533
- top_k: { type: "number", min: 0, max: 500, default: 40, description: "Top-K sampling (k)" },
534
- frequency_penalty: { type: "number", min: 0, max: 1, default: 0, description: "Penalize frequent tokens" },
535
- presence_penalty: { type: "number", min: 0, max: 1, default: 0, description: "Penalize repeated topics" },
536
- stop: { type: "string", default: "", description: "Stop sequences" },
537
- stream: { type: "boolean", default: false, description: "Stream response" },
538
- seed: { type: "number", default: "", description: "Random seed" }
539
- },
540
- bedrock: {
541
- temperature: { type: "number", min: 0, max: 1, default: 0.7, description: "Controls randomness" },
542
- max_tokens: { type: "number", min: 1, default: 4096, description: "Maximum output tokens" },
543
- top_p: { type: "number", min: 0, max: 1, default: 1, description: "Nucleus sampling" },
544
- top_k: { type: "number", min: 0, default: 40, description: "Top-K sampling" },
545
- stop: { type: "string", default: "", description: "Stop sequences" },
546
- stream: { type: "boolean", default: false, description: "Stream response" },
547
- cache: { type: "enum", values: ["ephemeral"], default: "ephemeral", description: "Cache control" },
548
- cache_ttl: { type: "enum", values: ["5m", "1h"], default: "5m", description: "Cache TTL" }
549
- },
550
- openrouter: {
551
- temperature: { type: "number", min: 0, max: 2, default: 0.7, description: "Controls randomness" },
552
- max_tokens: { type: "number", min: 1, default: 4096, description: "Maximum output tokens" },
553
- top_p: { type: "number", min: 0, max: 1, default: 1, description: "Nucleus sampling" },
554
- top_k: { type: "number", min: 0, default: 40, description: "Top-K sampling" },
555
- frequency_penalty: { type: "number", min: -2, max: 2, default: 0, description: "Penalize frequent tokens" },
556
- presence_penalty: { type: "number", min: -2, max: 2, default: 0, description: "Penalize repeated topics" },
557
- stop: { type: "string", default: "", description: "Stop sequences" },
558
- n: { type: "number", min: 1, default: 1, description: "Completions count" },
559
- seed: { type: "number", default: "", description: "Random seed" },
560
- stream: { type: "boolean", default: false, description: "Stream response" },
561
- effort: { type: "enum", values: ["none", "minimal", "low", "medium", "high", "xhigh"], default: "medium", description: "Reasoning effort" }
562
- },
563
- vercel: {
564
- temperature: { type: "number", min: 0, max: 2, default: 0.7, description: "Controls randomness" },
565
- max_tokens: { type: "number", min: 1, default: 4096, description: "Maximum output tokens" },
566
- top_p: { type: "number", min: 0, max: 1, default: 1, description: "Nucleus sampling" },
567
- top_k: { type: "number", min: 0, default: 40, description: "Top-K sampling" },
568
- frequency_penalty: { type: "number", min: -2, max: 2, default: 0, description: "Penalize frequent tokens" },
569
- presence_penalty: { type: "number", min: -2, max: 2, default: 0, description: "Penalize repeated topics" },
570
- stop: { type: "string", default: "", description: "Stop sequences" },
571
- n: { type: "number", min: 1, default: 1, description: "Completions count" },
572
- seed: { type: "number", default: "", description: "Random seed" },
573
- stream: { type: "boolean", default: false, description: "Stream response" },
574
- effort: { type: "enum", values: ["none", "minimal", "low", "medium", "high", "xhigh"], default: "medium", description: "Reasoning effort" }
575
- }
576
- };
577
-
578
- // src/normalize.ts
579
- function normalize(config, options = {}) {
580
- const provider = detectProvider(config.host);
581
- const changes = [];
582
- const params = {};
583
- for (const [rawKey, value] of Object.entries(config.params)) {
584
- let key = rawKey;
585
- if (ALIASES[key]) {
586
- const canonical = ALIASES[key];
587
- if (options.verbose) {
588
- changes.push({
589
- from: key,
590
- to: canonical,
591
- value,
592
- reason: `alias: "${key}" \u2192 "${canonical}"`
593
- });
594
- }
595
- key = canonical;
596
- }
597
- if (key === "cache" && provider) {
598
- let cacheValue = CACHE_VALUES[provider];
599
- if (provider === "bedrock" && !bedrockSupportsCaching(config.model)) {
600
- cacheValue = void 0;
601
- }
602
- if (!cacheValue) {
603
- if (options.verbose) {
604
- changes.push({
605
- from: "cache",
606
- to: "(dropped)",
607
- value,
608
- reason: `${provider} does not use a cache param for this model (caching is automatic or unsupported)`
609
- });
610
- }
611
- continue;
612
- }
613
- const isBool = value === "true" || value === "1" || value === "yes";
614
- const isDuration = DURATION_RE.test(value);
615
- if (isBool || isDuration) {
616
- const providerKey = PROVIDER_PARAMS[provider]?.["cache"] ?? "cache";
617
- if (options.verbose) {
618
- changes.push({
619
- from: "cache",
620
- to: providerKey,
621
- value: cacheValue,
622
- reason: `cache=${value} \u2192 ${providerKey}=${cacheValue} for ${provider}`
623
- });
624
- }
625
- params[providerKey] = cacheValue;
626
- if (isDuration && CACHE_TTLS[provider]) {
627
- if (options.verbose) {
628
- changes.push({
629
- from: "cache",
630
- to: "cache_ttl",
631
- value,
632
- reason: `cache=${value} \u2192 cache_ttl=${value} for ${provider}`
633
- });
634
- }
635
- params["cache_ttl"] = value;
636
- }
637
- continue;
638
- }
639
- }
640
- if (provider && PROVIDER_PARAMS[provider]) {
641
- const providerKey = PROVIDER_PARAMS[provider][key];
642
- if (providerKey && providerKey !== key) {
643
- if (options.verbose) {
644
- changes.push({
645
- from: key,
646
- to: providerKey,
647
- value,
648
- reason: `${provider} uses "${providerKey}" instead of "${key}"`
649
- });
650
- }
651
- key = providerKey;
652
- }
653
- }
654
- if (provider && canHostOpenAIModels(provider) && isReasoningModel(config.model) && key === "max_tokens") {
655
- if (options.verbose) {
656
- changes.push({
657
- from: "max_tokens",
658
- to: "max_completion_tokens",
659
- value,
660
- reason: "OpenAI reasoning models use max_completion_tokens instead of max_tokens"
661
- });
662
- }
663
- key = "max_completion_tokens";
664
- }
665
- params[key] = value;
666
- }
667
- return {
668
- config: { ...config, params },
669
- provider,
670
- changes
671
- };
672
- }
673
-
674
- // src/validate.ts
675
- function validate(connectionString, options = {}) {
676
- const parsed = parse(connectionString);
677
- const { config, provider } = normalize(parsed);
678
- const issues = [];
679
- if (!provider) {
680
- issues.push({
681
- param: "host",
682
- value: config.host,
683
- message: `Unknown provider for host "${config.host}". Validation skipped.`,
684
- severity: options.strict ? "error" : "warning"
685
- });
686
- return issues;
687
- }
688
- const specs = PARAM_SPECS[provider];
689
- const knownParams = new Set(Object.values(PROVIDER_PARAMS[provider]));
690
- for (const [key, value] of Object.entries(config.params)) {
691
- if (canHostOpenAIModels(provider) && isReasoningModel(config.model) && REASONING_MODEL_UNSUPPORTED.has(key)) {
692
- issues.push({
693
- param: key,
694
- value,
695
- message: `"${key}" is not supported by OpenAI reasoning model "${config.model}". Use "reasoning_effort" instead of temperature for controlling output.`,
696
- severity: "error"
697
- });
698
- continue;
699
- }
700
- if (provider === "bedrock") {
701
- const family = detectBedrockModelFamily(config.model);
702
- if (key === "topK" && family && family !== "anthropic" && family !== "cohere" && family !== "mistral") {
703
- issues.push({
704
- param: key,
705
- value,
706
- message: `"topK" is not supported by ${family} models on Bedrock.`,
707
- severity: "error"
708
- });
709
- continue;
710
- }
711
- if (key === "cache_control" && !bedrockSupportsCaching(config.model)) {
712
- issues.push({
713
- param: key,
714
- value,
715
- message: `Prompt caching is only supported for Anthropic Claude and Amazon Nova models on Bedrock, not ${family ?? "unknown"} models.`,
716
- severity: "error"
717
- });
718
- continue;
719
- }
720
- }
721
- if (!knownParams.has(key) && !specs[key]) {
722
- issues.push({
723
- param: key,
724
- value,
725
- message: `Unknown param "${key}" for ${provider}.`,
726
- severity: options.strict ? "error" : "warning"
727
- });
728
- continue;
729
- }
730
- const spec = specs[key];
731
- if (!spec) continue;
732
- if ((provider === "anthropic" || provider === "bedrock" && detectBedrockModelFamily(config.model) === "anthropic") && (key === "temperature" || key === "top_p" || key === "topP")) {
733
- const otherKey = key === "temperature" ? provider === "bedrock" ? "topP" : "top_p" : "temperature";
734
- if (key === "temperature" && config.params[otherKey] !== void 0) {
735
- issues.push({
736
- param: key,
737
- value,
738
- message: `Cannot specify both "temperature" and "${otherKey}" for Anthropic models.`,
739
- severity: "error"
740
- });
741
- }
742
- }
743
- if (spec.type === "number") {
744
- const num = Number(value);
745
- if (isNaN(num)) {
746
- issues.push({
747
- param: key,
748
- value,
749
- message: `"${key}" should be a number, got "${value}".`,
750
- severity: "error"
751
- });
752
- continue;
753
- }
754
- if (spec.min !== void 0 && num < spec.min) {
755
- issues.push({
756
- param: key,
757
- value,
758
- message: `"${key}" must be >= ${spec.min}, got ${num}.`,
759
- severity: "error"
760
- });
761
- }
762
- if (spec.max !== void 0 && num > spec.max) {
763
- issues.push({
764
- param: key,
765
- value,
766
- message: `"${key}" must be <= ${spec.max}, got ${num}.`,
767
- severity: "error"
768
- });
769
- }
770
- }
771
- if (spec.type === "boolean") {
772
- if (!["true", "false", "0", "1"].includes(value)) {
773
- issues.push({
774
- param: key,
775
- value,
776
- message: `"${key}" should be a boolean (true/false), got "${value}".`,
777
- severity: "error"
778
- });
779
- }
780
- }
781
- if (spec.type === "string" && spec.values) {
782
- if (!spec.values.includes(value)) {
783
- issues.push({
784
- param: key,
785
- value,
786
- message: `"${key}" must be one of [${spec.values.join(", ")}], got "${value}".`,
787
- severity: "error"
788
- });
789
- }
790
- }
791
- }
792
- return issues;
793
- }
794
- // Annotate the CommonJS export names for ESM import in node:
795
- 0 && (module.exports = {
796
- ALIASES,
797
- CANONICAL_PARAM_SPECS,
798
- MODELS,
799
- PARAM_SPECS,
800
- PROVIDER_META,
801
- PROVIDER_PARAMS,
802
- REASONING_MODEL_UNSUPPORTED,
803
- build,
804
- canHostOpenAIModels,
805
- detectBedrockModelFamily,
806
- detectProvider,
807
- isReasoningModel,
808
- normalize,
809
- parse,
810
- validate
811
- });
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+ var _chunkRR3VXIW2cjs = require('./chunk-RR3VXIW2.cjs');
6
+
7
+
8
+ var _chunkRSUXM42Xcjs = require('./chunk-RSUXM42X.cjs');
9
+
10
+
11
+ var _chunkMGWGNZDJcjs = require('./chunk-MGWGNZDJ.cjs');
12
+
13
+
14
+
15
+ var _chunkN6NVBE43cjs = require('./chunk-N6NVBE43.cjs');
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+ var _chunkNSCBY4VDcjs = require('./chunk-NSCBY4VD.cjs');
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+ exports.ALIASES = _chunkNSCBY4VDcjs.ALIASES; exports.CANONICAL_PARAM_SPECS = _chunkRR3VXIW2cjs.CANONICAL_PARAM_SPECS; exports.MODELS = _chunkRR3VXIW2cjs.MODELS; exports.PARAM_SPECS = _chunkNSCBY4VDcjs.PARAM_SPECS; exports.PROVIDER_META = _chunkRR3VXIW2cjs.PROVIDER_META; exports.PROVIDER_PARAMS = _chunkNSCBY4VDcjs.PROVIDER_PARAMS; exports.REASONING_MODEL_UNSUPPORTED = _chunkNSCBY4VDcjs.REASONING_MODEL_UNSUPPORTED; exports.build = _chunkN6NVBE43cjs.build; exports.canHostOpenAIModels = _chunkNSCBY4VDcjs.canHostOpenAIModels; exports.detectBedrockModelFamily = _chunkNSCBY4VDcjs.detectBedrockModelFamily; exports.detectGatewaySubProvider = _chunkNSCBY4VDcjs.detectGatewaySubProvider; exports.detectProvider = _chunkNSCBY4VDcjs.detectProvider; exports.isGatewayProvider = _chunkNSCBY4VDcjs.isGatewayProvider; exports.isReasoningModel = _chunkNSCBY4VDcjs.isReasoningModel; exports.normalize = _chunkMGWGNZDJcjs.normalize; exports.parse = _chunkN6NVBE43cjs.parse; exports.validate = _chunkRSUXM42Xcjs.validate;
812
47
  //# sourceMappingURL=index.cjs.map