use vtcode_config::core::AnthropicPromptCacheSettings;
use crate::provider::PromptCacheProfile;
pub fn get_cache_ttl_for_seconds(ttl_seconds: u64) -> &'static str {
if ttl_seconds >= 3600 { "1h" } else { "5m" }
}
pub fn get_tools_cache_ttl(settings: &AnthropicPromptCacheSettings) -> &'static str {
if settings.prefer_extended_ttl {
return "1h";
}
get_cache_ttl_for_seconds(settings.tools_ttl_seconds)
}
pub fn get_messages_cache_ttl(settings: &AnthropicPromptCacheSettings) -> &'static str {
if settings.prefer_extended_ttl {
return "1h";
}
get_cache_ttl_for_seconds(settings.messages_ttl_seconds)
}
pub fn get_profile_cache_ttl(settings: &AnthropicPromptCacheSettings) -> &'static str {
match settings.extended_ttl_seconds {
Some(seconds) => get_cache_ttl_for_seconds(seconds),
None => "1h",
}
}
pub fn messages_cache_ttl_for_profile(
settings: &AnthropicPromptCacheSettings,
profile: Option<PromptCacheProfile>,
) -> &'static str {
match profile {
Some(PromptCacheProfile::BudgetContinuation) => get_profile_cache_ttl(settings),
None => get_messages_cache_ttl(settings),
}
}
pub fn requires_extended_ttl_beta(
settings: &AnthropicPromptCacheSettings,
profile: Option<PromptCacheProfile>,
) -> bool {
get_tools_cache_ttl(settings) == "1h" || messages_cache_ttl_for_profile(settings, profile) == "1h"
}