@llumiverse/common 1.1.0 → 1.2.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 (56) hide show
  1. package/lib/cjs/index.js +1 -0
  2. package/lib/cjs/index.js.map +1 -1
  3. package/lib/cjs/options/bedrock.js +32 -76
  4. package/lib/cjs/options/bedrock.js.map +1 -1
  5. package/lib/cjs/options/context-windows.js +2 -0
  6. package/lib/cjs/options/context-windows.js.map +1 -1
  7. package/lib/cjs/options/openai.js +22 -3
  8. package/lib/cjs/options/openai.js.map +1 -1
  9. package/lib/cjs/options/shared-parsing.js +144 -0
  10. package/lib/cjs/options/shared-parsing.js.map +1 -0
  11. package/lib/cjs/options/version-parsing.js +326 -0
  12. package/lib/cjs/options/version-parsing.js.map +1 -0
  13. package/lib/cjs/options/vertexai.js +35 -199
  14. package/lib/cjs/options/vertexai.js.map +1 -1
  15. package/lib/cjs/types.js +2 -1
  16. package/lib/cjs/types.js.map +1 -1
  17. package/lib/esm/index.js +1 -0
  18. package/lib/esm/index.js.map +1 -1
  19. package/lib/esm/options/bedrock.js +32 -76
  20. package/lib/esm/options/bedrock.js.map +1 -1
  21. package/lib/esm/options/context-windows.js +2 -0
  22. package/lib/esm/options/context-windows.js.map +1 -1
  23. package/lib/esm/options/openai.js +22 -3
  24. package/lib/esm/options/openai.js.map +1 -1
  25. package/lib/esm/options/shared-parsing.js +135 -0
  26. package/lib/esm/options/shared-parsing.js.map +1 -0
  27. package/lib/esm/options/version-parsing.js +310 -0
  28. package/lib/esm/options/version-parsing.js.map +1 -0
  29. package/lib/esm/options/vertexai.js +28 -190
  30. package/lib/esm/options/vertexai.js.map +1 -1
  31. package/lib/esm/types.js +2 -1
  32. package/lib/esm/types.js.map +1 -1
  33. package/lib/types/index.d.ts +1 -0
  34. package/lib/types/index.d.ts.map +1 -1
  35. package/lib/types/options/bedrock.d.ts +2 -2
  36. package/lib/types/options/bedrock.d.ts.map +1 -1
  37. package/lib/types/options/context-windows.d.ts.map +1 -1
  38. package/lib/types/options/openai.d.ts +3 -2
  39. package/lib/types/options/openai.d.ts.map +1 -1
  40. package/lib/types/options/shared-parsing.d.ts +50 -0
  41. package/lib/types/options/shared-parsing.d.ts.map +1 -0
  42. package/lib/types/options/version-parsing.d.ts +184 -0
  43. package/lib/types/options/version-parsing.d.ts.map +1 -0
  44. package/lib/types/options/vertexai.d.ts +3 -11
  45. package/lib/types/options/vertexai.d.ts.map +1 -1
  46. package/lib/types/types.d.ts +2 -0
  47. package/lib/types/types.d.ts.map +1 -1
  48. package/package.json +2 -2
  49. package/src/index.ts +2 -1
  50. package/src/options/bedrock.ts +46 -80
  51. package/src/options/context-windows.ts +1 -0
  52. package/src/options/openai.ts +28 -6
  53. package/src/options/shared-parsing.ts +144 -0
  54. package/src/options/version-parsing.ts +360 -0
  55. package/src/options/vertexai.ts +46 -211
  56. package/src/types.ts +4 -1
@@ -0,0 +1,360 @@
1
+ /**
2
+ * Version parsing utilities for Claude and Gemini models.
3
+ *
4
+ * Provides version detection helpers that are forward-compatible with future
5
+ * model releases (e.g., Haiku 4.7, Sonnet 4.7, Opus 4.8, Opus 5).
6
+ *
7
+ * These helpers are used to:
8
+ * - Control option visibility in the UI
9
+ * - Construct appropriate API payloads for each model version
10
+ *
11
+ * Note: llumiverse does NOT validate options here. Errors from invalid
12
+ * parameters propagate to the provider side.
13
+ */
14
+
15
+ // ============================================================================
16
+ // Claude Version Parsing
17
+ // ============================================================================
18
+
19
+ /**
20
+ * Parsed Claude model version information.
21
+ */
22
+ export interface ClaudeVersion {
23
+ /** Major version number (e.g., 3, 4, 5) */
24
+ major: number;
25
+ /** Minor version number (e.g., 5, 6, 7) */
26
+ minor: number;
27
+ /** Model variant: opus, sonnet, or haiku */
28
+ variant: 'opus' | 'sonnet' | 'haiku';
29
+ }
30
+
31
+ /**
32
+ * Parse Claude model version from a model string.
33
+ *
34
+ * Examples:
35
+ * - "claude-opus-4-7" -> { major: 4, minor: 7, variant: 'opus' }
36
+ * - "claude-sonnet-4-6" -> { major: 4, minor: 6, variant: 'sonnet' }
37
+ * - "claude-3-7-sonnet-20250219" -> { major: 3, minor: 7, variant: 'sonnet' }
38
+ * - "claude-opus-4-6" -> { major: 4, minor: 6, variant: 'opus' }
39
+ *
40
+ * @param modelString - The model identifier string
41
+ * @returns Parsed version info, or null if not parseable
42
+ */
43
+ export function parseClaudeVersion(modelString: string): ClaudeVersion | null {
44
+ // Match pattern: claude-[variant-]-{major}-[optional minor]
45
+ // The minor version is limited to 1-2 digits to avoid matching dates (YYYYMMDD format)
46
+ const match = modelString.match(/claude-(opus|sonnet|haiku)-?(\d+)(?:-(\d{1,2}))?(?:-|\b)/i);
47
+ if (match) {
48
+ const variant = match[1].toLowerCase() as 'opus' | 'sonnet' | 'haiku';
49
+ const major = parseInt(match[2], 10);
50
+ const minor = match[3] ? parseInt(match[3], 10) : 0;
51
+ return { major, minor, variant };
52
+ }
53
+
54
+ // Fallback for older format: claude-3-7-sonnet-20250219
55
+ const fallbackMatch = modelString.match(/claude-(\d+)-(\d+)-(\w+)/i);
56
+ if (fallbackMatch) {
57
+ const major = parseInt(fallbackMatch[1], 10);
58
+ const minor = parseInt(fallbackMatch[2], 10);
59
+ const variant = fallbackMatch[3].toLowerCase() as 'opus' | 'sonnet' | 'haiku';
60
+ return { major, minor, variant };
61
+ }
62
+
63
+ return null;
64
+ }
65
+
66
+ /**
67
+ * Check if a Claude model version is greater than or equal to a target version.
68
+ *
69
+ * @param modelString - The model identifier string
70
+ * @param targetMajor - Target major version
71
+ * @param targetMinor - Target minor version
72
+ * @returns true if the model version is >= target version, false otherwise
73
+ */
74
+ export function isClaudeVersionGTE(modelString: string, targetMajor: number, targetMinor: number): boolean {
75
+ const version = parseClaudeVersion(modelString);
76
+ if (!version) {
77
+ return false;
78
+ }
79
+ if (version.major > targetMajor) {
80
+ return true;
81
+ }
82
+ if (version.major === targetMajor && version.minor >= targetMinor) {
83
+ return true;
84
+ }
85
+ return false;
86
+ }
87
+
88
+ /**
89
+ * Check if a Claude variant model version is greater than or equal to a target version.
90
+ *
91
+ * @param modelString - The model identifier string
92
+ * @param variant - Model variant: "opus" or "sonnet"
93
+ * @param targetMajor - Target major version
94
+ * @param targetMinor - Target minor version
95
+ * @returns true if the model matches the variant and version >= target
96
+ */
97
+ function isClaudeVariantVersionGTE(
98
+ modelString: string,
99
+ variant: "opus" | "sonnet",
100
+ targetMajor: number,
101
+ targetMinor: number
102
+ ): boolean {
103
+ const version = parseClaudeVersion(modelString);
104
+ if (!version) return false;
105
+ if (version.variant.toLowerCase() !== variant) return false;
106
+ return version.major > targetMajor || (version.major === targetMajor && version.minor >= targetMinor);
107
+ }
108
+
109
+ /**
110
+ * Check if a model requires sampling parameter removal (behavior: sampling params removed on Opus 4.7+).
111
+ *
112
+ * This includes:
113
+ * - claude-opus-4-7
114
+ * - Future Opus 4.x with minor >= 7
115
+ * - Future Opus 5.x+
116
+ *
117
+ * @param modelString - The model identifier string
118
+ * @returns true if Opus 4.7+ or equivalent future model
119
+ */
120
+ export function hasSamplingParameterRemoval(modelString: string): boolean {
121
+ return isClaudeVariantVersionGTE(modelString, "opus", 4, 7);
122
+ }
123
+
124
+ /**
125
+ * Check if a model requires adaptive thinking (behavior: adaptive thinking required on Opus 4.6+).
126
+ *
127
+ * This includes:
128
+ * - claude-opus-4-6
129
+ * - claude-opus-4-7
130
+ * - Future Opus 4.x with minor >= 6
131
+ * - Future Opus 5.x+
132
+ *
133
+ * @param modelString - The model identifier string
134
+ * @returns true if Opus 4.6+ or equivalent future model
135
+ */
136
+ export function requiresAdaptiveThinking(modelString: string): boolean {
137
+ return isClaudeVariantVersionGTE(modelString, "opus", 4, 6);
138
+ }
139
+
140
+ /**
141
+ * Check if a model supports adaptive thinking.
142
+ *
143
+ * Adaptive thinking was introduced in:
144
+ * - Claude Opus 4.6
145
+ * - Claude Sonnet 4.6
146
+ *
147
+ * @param modelString - The model identifier string
148
+ * @returns true if the model supports adaptive thinking
149
+ */
150
+ export function supportsAdaptiveThinking(modelString: string): boolean {
151
+ return requiresAdaptiveThinking(modelString) || isClaudeVariantVersionGTE(modelString, "sonnet", 4, 6);
152
+ }
153
+
154
+ /**
155
+ * Check if extended thinking is deprecated for this model.
156
+ *
157
+ * Extended thinking (thinking.type: "enabled" with budget_tokens) is deprecated
158
+ * but still functional on:
159
+ * - Claude Opus 4.6+
160
+ * - Claude Sonnet 4.6+
161
+ *
162
+ * @param modelString - The model identifier string
163
+ * @returns true if extended thinking is deprecated (adaptive thinking recommended)
164
+ */
165
+ export function isExtendedThinkingDeprecated(modelString: string): boolean {
166
+ return supportsAdaptiveThinking(modelString);
167
+ }
168
+
169
+ /**
170
+ * Check if a model requires adaptive thinking ONLY (extended thinking removed).
171
+ *
172
+ * On Opus 4.7+, extended thinking returns a 400 error. Only adaptive thinking is supported.
173
+ * Future models (Sonnet 4.7+, Haiku 4.7+, any 5.0+) follow the same pattern.
174
+ *
175
+ * @param modelString - The model identifier string
176
+ * @returns true if extended thinking is removed (returns 400 error)
177
+ */
178
+ export function requiresAdaptiveThinkingOnly(modelString: string): boolean {
179
+ return hasSamplingParameterRestriction(modelString);
180
+ }
181
+
182
+ /**
183
+ * Check if a model has sampling parameter restrictions.
184
+ *
185
+ * On Opus 4.7+, setting temperature, top_p, or top_k to any non-default value
186
+ * returns a 400 error. Future models following the same pattern will also match:
187
+ * - Opus 4.7+ (current restriction)
188
+ * - Sonnet 4.7+, Haiku 4.7+ (future minor versions >= 7)
189
+ * - Sonnet 5.0+, Haiku 5.0+, Opus 5.0+ (future major versions)
190
+ *
191
+ * @param modelString - The model identifier string
192
+ * @returns true if sampling parameters are restricted
193
+ */
194
+ export function hasSamplingParameterRestriction(modelString: string): boolean {
195
+ const version = parseClaudeVersion(modelString);
196
+ if (!version) {
197
+ return false;
198
+ }
199
+
200
+ // Future major versions (5.0+) follow the same pattern as 4.7
201
+ if (version.major > 4) {
202
+ return true;
203
+ }
204
+
205
+ // Version 4.7+ (Opus 4.7, Sonnet 4.7, Haiku 4.7, etc.)
206
+ if (version.major === 4 && version.minor >= 7) {
207
+ return true;
208
+ }
209
+
210
+ return false;
211
+ }
212
+
213
+ // ============================================================================
214
+ // Claude Effort Parameter Support
215
+ // ============================================================================
216
+
217
+ /** Available effort levels for Claude models. */
218
+ export type ClaudeEffortLevel = 'low' | 'medium' | 'high' | 'xhigh' | 'max';
219
+
220
+ /**
221
+ * Check if a model supports the effort parameter.
222
+ *
223
+ * Effort is supported on:
224
+ * - Claude Opus 4.5+
225
+ * - Claude Opus 4.6+
226
+ * - Claude Sonnet 4.6+
227
+ * - All variants at 4.7+ (Opus, Sonnet, Haiku)
228
+ * - All variants at 5.0+
229
+ *
230
+ * @param modelString - The model identifier string
231
+ * @returns true if the model supports the effort parameter
232
+ */
233
+ export function supportsEffort(modelString: string): boolean {
234
+ // All 4.7+ variants support effort (covers future Sonnet 4.7, Haiku 4.7, etc.)
235
+ if (hasSamplingParameterRestriction(modelString)) {
236
+ return true;
237
+ }
238
+ // Opus 4.5+ supports effort
239
+ if (isClaudeVariantVersionGTE(modelString, "opus", 4, 5)) {
240
+ return true;
241
+ }
242
+ // Sonnet 4.6+ supports effort
243
+ if (isClaudeVariantVersionGTE(modelString, "sonnet", 4, 6)) {
244
+ return true;
245
+ }
246
+ return false;
247
+ }
248
+
249
+ /**
250
+ * Check if a model supports the xhigh effort level.
251
+ *
252
+ * xhigh is only available on Opus 4.7+.
253
+ *
254
+ * @param modelString - The model identifier string
255
+ * @returns true if the model supports xhigh effort
256
+ */
257
+ export function supportsXHighEffort(modelString: string): boolean {
258
+ return isClaudeVariantVersionGTE(modelString, "opus", 4, 7);
259
+ }
260
+
261
+ /**
262
+ * Get the available effort levels for a given Claude model.
263
+ *
264
+ * - Opus 4.7+: low, medium, high, xhigh, max
265
+ * - Opus 4.5+, Opus 4.6+, Sonnet 4.6+: low, medium, high, max
266
+ * - Other models: empty (effort not supported)
267
+ *
268
+ * @param modelString - The model identifier string
269
+ * @returns Record of display label to effort level value, or null if not supported
270
+ */
271
+ export function getAvailableEffortLevels(modelString: string): Record<string, ClaudeEffortLevel> | null {
272
+ if (!supportsEffort(modelString)) {
273
+ return null;
274
+ }
275
+ const levels: Record<string, ClaudeEffortLevel> = {
276
+ "Low": "low",
277
+ "Medium": "medium",
278
+ "High (default)": "high",
279
+ "Max": "max",
280
+ };
281
+ if (supportsXHighEffort(modelString)) {
282
+ // Insert xhigh between high and max
283
+ return {
284
+ "Low": "low",
285
+ "Medium": "medium",
286
+ "High (default)": "high",
287
+ "Extra High": "xhigh",
288
+ "Max": "max",
289
+ };
290
+ }
291
+ return levels;
292
+ }
293
+
294
+ // ============================================================================
295
+ // Gemini Version Parsing
296
+ // ============================================================================
297
+
298
+ /**
299
+ * Extract Gemini version from a model ID.
300
+ *
301
+ * Examples:
302
+ * - "locations/global/publishers/google/models/gemini-2.5-flash" -> "2.5"
303
+ * - "publishers/google/models/gemini-3-pro-image-preview" -> "3"
304
+ * - "gemini-3.1-flash-lite-preview" -> "3.1"
305
+ *
306
+ * @param modelId - The model identifier string
307
+ * @returns Version string (e.g., "2.5", "3", "3.1"), or undefined if not parseable
308
+ */
309
+ export function getGeminiModelVersion(modelId: string): string | undefined {
310
+ const modelName = modelId.split('/').pop() ?? modelId;
311
+ const match = modelName.match(/^gemini-(\d+(?:\.\d+)?)/i);
312
+ return match?.[1];
313
+ }
314
+
315
+ /**
316
+ * Parse a version string into major.minor components.
317
+ *
318
+ * @param version - Version string (e.g., "2.5", "3", "3.1")
319
+ * @returns Parsed version, or undefined if not parseable
320
+ */
321
+ export function parseGeminiVersion(version: string): { major: number; minor: number } | undefined {
322
+ const match = version.match(/^(\d+)(?:\.(\d+))?$/);
323
+ if (!match) {
324
+ return undefined;
325
+ }
326
+
327
+ return {
328
+ major: Number(match[1]),
329
+ minor: Number(match[2] ?? '0'),
330
+ };
331
+ }
332
+
333
+ /**
334
+ * Check if a Gemini model version is greater than or equal to a minimum version.
335
+ *
336
+ * @param modelId - The model identifier string
337
+ * @param minVersion - Minimum version string (e.g., "2.5", "3.0")
338
+ * @returns true if model version >= min version
339
+ */
340
+ export function isGeminiModelVersionGte(modelId: string, minVersion: string): boolean {
341
+ const modelVersion = getGeminiModelVersion(modelId);
342
+ if (!modelVersion) {
343
+ return false;
344
+ }
345
+
346
+ const current = parseGeminiVersion(modelVersion);
347
+ const target = parseGeminiVersion(minVersion);
348
+ if (!current || !target) {
349
+ return false;
350
+ }
351
+
352
+ if (current.major > target.major) {
353
+ return true;
354
+ }
355
+ if (current.major < target.major) {
356
+ return false;
357
+ }
358
+
359
+ return current.minor >= target.minor;
360
+ }
@@ -1,6 +1,17 @@
1
- import { ModelOptionInfoItem, ModelOptions, ModelOptionsInfo, OptionType, SharedOptions } from "../types.js";
2
- import { getMaxOutputTokens } from "./context-windows.js";
1
+ import { type ModelOptionInfoItem, type ModelOptions, type ModelOptionsInfo, OptionType, SharedOptions } from "../types.js";
3
2
  import { textOptionsFallback } from "./fallback.js";
3
+ import {
4
+ buildClaudeCacheOptions,
5
+ buildClaudeCacheTtlOptions,
6
+ buildClaudeEffortOptions,
7
+ buildClaudeIncludeThoughtsOption,
8
+ buildClaudeThinkingBudgetOption,
9
+ getClaudeMaxTokensLimit,
10
+ } from "./shared-parsing.js";
11
+ import {
12
+ hasSamplingParameterRestriction,
13
+ isGeminiModelVersionGte,
14
+ } from "./version-parsing.js";
4
15
 
5
16
  // Union type of all VertexAI options
6
17
  export type VertexAIOptions = ImagenOptions | VertexAIClaudeOptions | VertexAIGeminiOptions;
@@ -67,7 +78,7 @@ export interface VertexAIClaudeOptions {
67
78
  top_p?: number;
68
79
  top_k?: number;
69
80
  stop_sequence?: string[];
70
- thinking_mode?: boolean;
81
+ effort?: 'low' | 'medium' | 'high' | 'xhigh' | 'max';
71
82
  thinking_budget_tokens?: number;
72
83
  include_thoughts?: boolean;
73
84
  cache_enabled?: boolean;
@@ -84,6 +95,7 @@ export interface VertexAIGeminiOptions {
84
95
  presence_penalty?: number;
85
96
  frequency_penalty?: number;
86
97
  seed?: number;
98
+ effort?: 'low' | 'medium' | 'high';
87
99
  include_thoughts?: boolean;
88
100
  thinking_budget_tokens?: number;
89
101
  thinking_level?: ThinkingLevel;
@@ -124,142 +136,6 @@ export function getVertexAiOptions(model: string, option?: ModelOptions): ModelO
124
136
  return textOptionsFallback;
125
137
  }
126
138
 
127
- /**
128
- * Extract Gemini version from a model ID.
129
- *
130
- * Examples:
131
- * - locations/global/publishers/google/models/gemini-2.5-flash -> 2.5
132
- * - publishers/google/models/gemini-3-pro-image-preview -> 3
133
- */
134
- export function getGeminiModelVersion(modelId: string): string | undefined {
135
- const modelName = modelId.split('/').pop() ?? modelId;
136
- const match = modelName.match(/^gemini-(\d+(?:\.\d+)?)/i);
137
- return match?.[1];
138
- }
139
-
140
- function parseVersion(version: string): { major: number; minor: number } | undefined {
141
- const match = version.match(/^(\d+)(?:\.(\d+))?$/);
142
- if (!match) {
143
- return undefined;
144
- }
145
-
146
- return {
147
- major: Number(match[1]),
148
- minor: Number(match[2] ?? '0'),
149
- };
150
- }
151
-
152
- export function isGeminiModelVersionGte(modelId: string, minVersion: string): boolean {
153
- const modelVersion = getGeminiModelVersion(modelId);
154
- if (!modelVersion) {
155
- return false;
156
- }
157
-
158
- const current = parseVersion(modelVersion);
159
- const target = parseVersion(minVersion);
160
- if (!current || !target) {
161
- return false;
162
- }
163
-
164
- if (current.major > target.major) {
165
- return true;
166
- }
167
- if (current.major < target.major) {
168
- return false;
169
- }
170
-
171
- return current.minor >= target.minor;
172
- }
173
-
174
- function getGeminiThinkingLevels(model: string): {
175
- levels: Record<string, ThinkingLevel>;
176
- defaultLevel: ThinkingLevel;
177
- } {
178
- const normalized = model.toLowerCase();
179
- const isGemini3OrLater = isGeminiModelVersionGte(model, "3.0");
180
- const isGemini31OrLater = isGeminiModelVersionGte(model, "3.1");
181
- const isFlashLite = normalized.includes("flash-lite");
182
- const isFlash = normalized.includes("flash") && !isFlashLite;
183
- const isPro = normalized.includes("pro");
184
-
185
- // Gemini 3 / 3.1 thinking_level support summary:
186
- // - MINIMAL: Gemini 3 Flash and Gemini 3.1 Flash-Lite only.
187
- // Gemini 3.1 Flash-Lite defaults to MINIMAL.
188
- // - LOW: Supported by Gemini 3+ models.
189
- // - MEDIUM: Gemini 3 Flash, Gemini 3.1 Pro, Gemini 3.1 Flash-Lite.
190
- // - HIGH: Supported by Gemini 3+ models.
191
- // - Thinking cannot be turned off for Gemini 3 Pro and Gemini 3.1 Pro.
192
- if (isFlashLite && isGemini31OrLater) {
193
- return {
194
- levels: {
195
- "Minimal": ThinkingLevel.MINIMAL,
196
- "Low": ThinkingLevel.LOW,
197
- "Medium": ThinkingLevel.MEDIUM,
198
- "High": ThinkingLevel.HIGH,
199
- },
200
- defaultLevel: ThinkingLevel.MINIMAL,
201
- };
202
- }
203
-
204
- // Gemini 3+ Flash supports MINIMAL and MEDIUM in addition to LOW/HIGH.
205
- if (isFlash) {
206
- return {
207
- levels: {
208
- "Minimal": ThinkingLevel.MINIMAL,
209
- "Low": ThinkingLevel.LOW,
210
- "Medium": ThinkingLevel.MEDIUM,
211
- "High": ThinkingLevel.HIGH,
212
- },
213
- defaultLevel: ThinkingLevel.MINIMAL,
214
- };
215
- }
216
-
217
- // Gemini 3.1 Pro adds MEDIUM, but does not support turning thinking off.
218
- if (isPro && isGemini31OrLater) {
219
- return {
220
- levels: {
221
- "Low": ThinkingLevel.LOW,
222
- "Medium": ThinkingLevel.MEDIUM,
223
- "High": ThinkingLevel.HIGH,
224
- },
225
- defaultLevel: ThinkingLevel.LOW,
226
- };
227
- }
228
-
229
- // Gemini 3 Pro supports LOW/HIGH. Thinking cannot be turned off.
230
- if (isPro) {
231
- return {
232
- levels: {
233
- "Low": ThinkingLevel.LOW,
234
- "High": ThinkingLevel.HIGH,
235
- },
236
- defaultLevel: ThinkingLevel.LOW,
237
- };
238
- }
239
-
240
- // Fallback for unknown Gemini 3+/4+ families:
241
- // prefer future-safe propagation by enabling the guaranteed baseline levels.
242
- if (isGemini3OrLater) {
243
- return {
244
- levels: {
245
- "Low": ThinkingLevel.LOW,
246
- "Medium": ThinkingLevel.MEDIUM,
247
- "High": ThinkingLevel.HIGH,
248
- },
249
- defaultLevel: ThinkingLevel.LOW,
250
- };
251
- }
252
-
253
- // Non-3.x models should not reach this helper in normal flow.
254
- return {
255
- levels: {
256
- "Low": ThinkingLevel.LOW,
257
- "High": ThinkingLevel.HIGH,
258
- },
259
- defaultLevel: ThinkingLevel.LOW,
260
- };
261
- }
262
-
263
139
  function getImagenOptions(model: string, option?: ModelOptions): ModelOptionsInfo {
264
140
  const commonOptions: ModelOptionInfoItem[] = [
265
141
  {
@@ -414,8 +290,17 @@ function getImagenOptions(model: string, option?: ModelOptions): ModelOptionsInf
414
290
  return textOptionsFallback;
415
291
  }
416
292
 
293
+ function getGeminiEffortOptions(model: string): Record<string, string> {
294
+ if (model.includes("gemini-3-pro-image")) {
295
+ return { "High": "high" };
296
+ }
297
+ if (model.includes("gemini-3.1-flash-image")) {
298
+ return { "Low": "low", "High": "high" };
299
+ }
300
+ return { "Low": "low", "Medium": "medium", "High": "high" };
301
+ }
302
+
417
303
  function getGeminiThinkingOptionItems(model: string): ModelOptionInfoItem[] {
418
- const thinkingLevelConfig = getGeminiThinkingLevels(model);
419
304
  return [
420
305
  {
421
306
  name: "include_thoughts",
@@ -424,10 +309,9 @@ function getGeminiThinkingOptionItems(model: string): ModelOptionInfoItem[] {
424
309
  description: "Include the model's reasoning process in the response"
425
310
  },
426
311
  {
427
- name: "thinking_level",
312
+ name: SharedOptions.effort,
428
313
  type: OptionType.enum,
429
- enum: thinkingLevelConfig.levels,
430
- default: thinkingLevelConfig.defaultLevel,
314
+ enum: getGeminiEffortOptions(model),
431
315
  description: "Higher thinking levels may improve quality, but increase response times and token costs"
432
316
  }
433
317
  ];
@@ -669,77 +553,35 @@ function getGeminiOptions(model: string, option?: ModelOptions): ModelOptionsInf
669
553
  function getClaudeOptions(model: string, option?: ModelOptions): ModelOptionsInfo {
670
554
  const max_tokens_limit = getClaudeMaxTokensLimit(model);
671
555
  const excludeOptions = ["max_tokens", "presence_penalty", "frequency_penalty"];
672
- const commonOptions = textOptionsFallback.options.filter((option) => !excludeOptions.includes(option.name));
556
+ let commonOptions = textOptionsFallback.options.filter((option) => !excludeOptions.includes(option.name));
557
+
558
+ // Opus 4.7+ models no longer support temperature, top_p, top_k (returns 400 error)
559
+ // Opus 4.6 and Sonnet 4.6 still support these parameters
560
+ const hasSamplingRestriction = hasSamplingParameterRestriction(model);
561
+ if (hasSamplingRestriction) {
562
+ commonOptions = commonOptions.filter((option) =>
563
+ option.name !== SharedOptions.temperature &&
564
+ option.name !== SharedOptions.top_p &&
565
+ option.name !== "top_k"
566
+ );
567
+ }
568
+
673
569
  const max_tokens: ModelOptionInfoItem[] = [{
674
570
  name: SharedOptions.max_tokens, type: OptionType.numeric, min: 1, max: max_tokens_limit,
675
571
  integer: true, step: 200, description: "The maximum number of tokens to generate"
676
572
  }];
677
573
 
678
- const claudeCacheOptions: ModelOptionInfoItem[] = [
679
- {
680
- name: "cache_enabled",
681
- type: OptionType.boolean,
682
- default: false,
683
- description: "Enable prompt caching. Injects cache breakpoints at the system prompt, tools, and conversation pivot.",
684
- },
685
- ];
686
- const claudeCacheTtlOptions: ModelOptionInfoItem[] = (option as VertexAIClaudeOptions)?.cache_enabled ? [
687
- {
688
- name: "cache_ttl",
689
- type: OptionType.enum,
690
- enum: { "5 minutes (default)": "5m", "1 hour": "1h" },
691
- default: "5m",
692
- description: "TTL for cache breakpoints. '1h' requires extended caching to be enabled on your account.",
693
- }
694
- ] : [];
695
-
696
- if (model.includes("-3-7") || model.includes("-4")) {
697
- const claudeModeOptions: ModelOptionInfoItem[] = [
698
- {
699
- name: "thinking_mode",
700
- type: OptionType.boolean,
701
- default: false,
702
- description: "If true, use the extended reasoning mode"
703
- },
704
- ];
705
- const claudeThinkingOptions: ModelOptionInfoItem[] = (option as VertexAIClaudeOptions)?.thinking_mode ? [
706
- {
707
- name: "thinking_budget_tokens",
708
- type: OptionType.numeric,
709
- min: 1024,
710
- default: 1024,
711
- integer: true,
712
- step: 100,
713
- description: "The target number of tokens to use for reasoning, not a hard limit."
714
- },
715
- {
716
- name: "include_thoughts",
717
- type: OptionType.boolean,
718
- default: false,
719
- description: "Include the model's reasoning process in the response"
720
- }
721
- ] : [];
722
-
723
- return {
724
- _option_id: "vertexai-claude",
725
- options: [
726
- ...max_tokens,
727
- ...commonOptions,
728
- ...claudeModeOptions,
729
- ...claudeThinkingOptions,
730
- ...claudeCacheOptions,
731
- ...claudeCacheTtlOptions,
732
- ]
733
- };
734
- }
735
574
  return {
736
575
  _option_id: "vertexai-claude",
737
576
  options: [
738
577
  ...max_tokens,
739
578
  ...commonOptions,
740
- ...claudeCacheOptions,
741
- ...claudeCacheTtlOptions,
742
- ]
579
+ ...buildClaudeEffortOptions(model),
580
+ ...buildClaudeThinkingBudgetOption(model),
581
+ ...buildClaudeIncludeThoughtsOption(model),
582
+ ...buildClaudeCacheOptions(),
583
+ ...buildClaudeCacheTtlOptions((option as VertexAIClaudeOptions)?.cache_enabled),
584
+ ],
743
585
  };
744
586
  }
745
587
 
@@ -788,13 +630,6 @@ function getGeminiMaxTokensLimit(model: string): number {
788
630
  return 8192;
789
631
  }
790
632
 
791
- // Delegate to provider-agnostic limits,
792
- // override only where VertexAI supports extended output (128K for 3.7)
793
- function getClaudeMaxTokensLimit(model: string): number {
794
- if (model.includes('-3-7')) return 128000;
795
- return getMaxOutputTokens(model);
796
- }
797
-
798
633
  function getLlamaMaxTokensLimit(_model: string): number {
799
634
  return 8192;
800
635
  }
package/src/types.ts CHANGED
@@ -82,7 +82,7 @@ export const ProviderList: Record<Providers, ProviderParams> = {
82
82
  },
83
83
  vertexai: {
84
84
  id: Providers.vertexai,
85
- name: "Google Vertex AI",
85
+ name: "Google Agent Platform (Vertex AI)",
86
86
  requiresApiKey: false,
87
87
  requiresEndpointUrl: false,
88
88
  supportSearch: false,
@@ -559,6 +559,7 @@ export enum SharedOptions {
559
559
  presence_penalty = "presence_penalty",
560
560
  frequency_penalty = "frequency_penalty",
561
561
  stop_sequence = "stop_sequence",
562
+ effort = "effort",
562
563
 
563
564
  //Image
564
565
  seed = "seed",
@@ -572,6 +573,8 @@ export enum OptionType {
572
573
  string_list = "string_list"
573
574
  }
574
575
 
576
+ export type ReasoningEffort = "low" | "medium" | "high";
577
+
575
578
  // ============== Model Options ===============
576
579
 
577
580
  export type ModelOptions = TextFallbackOptions | VertexAIOptions | BedrockOptions | OpenAiOptions | GroqOptions;