//#region src/utils/cache-state.ts
const CACHING_SUPPORTED_PROVIDERS = new Set([
	"anthropic",
	"openai",
	"google",
	"gemini"
]);
function isProviderSupportedForCaching(provider) {
	return CACHING_SUPPORTED_PROVIDERS.has(provider.toLowerCase());
}
/**
* Resolve the provider to use for the caching-support gate.
*
* Vercel-AI-Gateway-routed deployments report `ai.model.provider = 'gateway'`,
* which is a router, not a caching-capable provider. The actual model provider
* that produced the response (and owns the cache keys) lives in
* `gen_ai.response.provider`. Prefer that resolved provider when present so the
* support gate reflects the real backend (e.g. 'anthropic'); fall back to the
* request-side `ai.model.provider` only when the resolved provider is absent.
*/
function resolveCachingProvider({ requestProvider, responseProvider }) {
	return (responseProvider || requestProvider || "").trim();
}
function deriveCacheState({ markerCount, cacheRead, providerSupportsCaching = true }) {
	if (!providerSupportsCaching) return "NOT-SUPPORTED-BY-PROVIDER";
	if (cacheRead > 0) return "HIT";
	if (markerCount <= 0) return "NOT-ATTEMPTED";
	return "MISS";
}

//#endregion
export { deriveCacheState, isProviderSupportedForCaching, resolveCachingProvider };