@llumiverse/common
Version:
Public types, enums and options used by Llumiverse API.
184 lines • 6.92 kB
TypeScript
/**
* Version parsing utilities for Claude and Gemini models.
*
* Provides version detection helpers that are forward-compatible with future
* model releases (e.g., Haiku 4.7, Sonnet 4.7, Opus 4.8, Opus 5).
*
* These helpers are used to:
* - Control option visibility in the UI
* - Construct appropriate API payloads for each model version
*
* Note: llumiverse does NOT validate options here. Errors from invalid
* parameters propagate to the provider side.
*/
/**
* Parsed Claude model version information.
*/
export interface ClaudeVersion {
/** Major version number (e.g., 3, 4, 5) */
major: number;
/** Minor version number (e.g., 5, 6, 7) */
minor: number;
/** Model variant: opus, sonnet, or haiku */
variant: 'opus' | 'sonnet' | 'haiku';
}
/**
* Parse Claude model version from a model string.
*
* Examples:
* - "claude-opus-4-7" -> { major: 4, minor: 7, variant: 'opus' }
* - "claude-sonnet-4-6" -> { major: 4, minor: 6, variant: 'sonnet' }
* - "claude-3-7-sonnet-20250219" -> { major: 3, minor: 7, variant: 'sonnet' }
* - "claude-opus-4-6" -> { major: 4, minor: 6, variant: 'opus' }
*
* @param modelString - The model identifier string
* @returns Parsed version info, or null if not parseable
*/
export declare function parseClaudeVersion(modelString: string): ClaudeVersion | null;
/**
* Check if a Claude model version is greater than or equal to a target version.
*
* @param modelString - The model identifier string
* @param targetMajor - Target major version
* @param targetMinor - Target minor version
* @returns true if the model version is >= target version, false otherwise
*/
export declare function isClaudeVersionGTE(modelString: string, targetMajor: number, targetMinor: number): boolean;
/**
* Check if a model requires sampling parameter removal (behavior: sampling params removed on Opus 4.7+).
*
* This includes:
* - claude-opus-4-7
* - Future Opus 4.x with minor >= 7
* - Future Opus 5.x+
*
* @param modelString - The model identifier string
* @returns true if Opus 4.7+ or equivalent future model
*/
export declare function hasSamplingParameterRemoval(modelString: string): boolean;
/**
* Check if a model requires adaptive thinking (behavior: adaptive thinking required on Opus 4.6+).
*
* This includes:
* - claude-opus-4-6
* - claude-opus-4-7
* - Future Opus 4.x with minor >= 6
* - Future Opus 5.x+
*
* @param modelString - The model identifier string
* @returns true if Opus 4.6+ or equivalent future model
*/
export declare function requiresAdaptiveThinking(modelString: string): boolean;
/**
* Check if a model supports adaptive thinking.
*
* Adaptive thinking was introduced in:
* - Claude Opus 4.6
* - Claude Sonnet 4.6
*
* @param modelString - The model identifier string
* @returns true if the model supports adaptive thinking
*/
export declare function supportsAdaptiveThinking(modelString: string): boolean;
/**
* Check if extended thinking is deprecated for this model.
*
* Extended thinking (thinking.type: "enabled" with budget_tokens) is deprecated
* but still functional on:
* - Claude Opus 4.6+
* - Claude Sonnet 4.6+
*
* @param modelString - The model identifier string
* @returns true if extended thinking is deprecated (adaptive thinking recommended)
*/
export declare function isExtendedThinkingDeprecated(modelString: string): boolean;
/**
* Check if a model requires adaptive thinking ONLY (extended thinking removed).
*
* On Opus 4.7+, extended thinking returns a 400 error. Only adaptive thinking is supported.
* Future models (Sonnet 4.7+, Haiku 4.7+, any 5.0+) follow the same pattern.
*
* @param modelString - The model identifier string
* @returns true if extended thinking is removed (returns 400 error)
*/
export declare function requiresAdaptiveThinkingOnly(modelString: string): boolean;
/**
* Check if a model has sampling parameter restrictions.
*
* On Opus 4.7+, setting temperature, top_p, or top_k to any non-default value
* returns a 400 error. Future models following the same pattern will also match:
* - Opus 4.7+ (current restriction)
* - Sonnet 4.7+, Haiku 4.7+ (future minor versions >= 7)
* - Sonnet 5.0+, Haiku 5.0+, Opus 5.0+ (future major versions)
*
* @param modelString - The model identifier string
* @returns true if sampling parameters are restricted
*/
export declare function hasSamplingParameterRestriction(modelString: string): boolean;
/** Available effort levels for Claude models. */
export type ClaudeEffortLevel = 'low' | 'medium' | 'high' | 'xhigh' | 'max';
/**
* Check if a model supports the effort parameter.
*
* Effort is supported on:
* - Claude Opus 4.5+
* - Claude Opus 4.6+
* - Claude Sonnet 4.6+
* - All variants at 4.7+ (Opus, Sonnet, Haiku)
* - All variants at 5.0+
*
* @param modelString - The model identifier string
* @returns true if the model supports the effort parameter
*/
export declare function supportsEffort(modelString: string): boolean;
/**
* Check if a model supports the xhigh effort level.
*
* xhigh is only available on Opus 4.7+.
*
* @param modelString - The model identifier string
* @returns true if the model supports xhigh effort
*/
export declare function supportsXHighEffort(modelString: string): boolean;
/**
* Get the available effort levels for a given Claude model.
*
* - Opus 4.7+: low, medium, high, xhigh, max
* - Opus 4.5+, Opus 4.6+, Sonnet 4.6+: low, medium, high, max
* - Other models: empty (effort not supported)
*
* @param modelString - The model identifier string
* @returns Record of display label to effort level value, or null if not supported
*/
export declare function getAvailableEffortLevels(modelString: string): Record<string, ClaudeEffortLevel> | null;
/**
* Extract Gemini version from a model ID.
*
* Examples:
* - "locations/global/publishers/google/models/gemini-2.5-flash" -> "2.5"
* - "publishers/google/models/gemini-3-pro-image-preview" -> "3"
* - "gemini-3.1-flash-lite-preview" -> "3.1"
*
* @param modelId - The model identifier string
* @returns Version string (e.g., "2.5", "3", "3.1"), or undefined if not parseable
*/
export declare function getGeminiModelVersion(modelId: string): string | undefined;
/**
* Parse a version string into major.minor components.
*
* @param version - Version string (e.g., "2.5", "3", "3.1")
* @returns Parsed version, or undefined if not parseable
*/
export declare function parseGeminiVersion(version: string): {
major: number;
minor: number;
} | undefined;
/**
* Check if a Gemini model version is greater than or equal to a minimum version.
*
* @param modelId - The model identifier string
* @param minVersion - Minimum version string (e.g., "2.5", "3.0")
* @returns true if model version >= min version
*/
export declare function isGeminiModelVersionGte(modelId: string, minVersion: string): boolean;
//# sourceMappingURL=version-parsing.d.ts.map