import asyncio

from ._types import ProviderResolution


def resolve_provider_sync(
    task_type: str,
    preferred: str | None = None,
    require_capability: str | None = None,
) -> ProviderResolution:
    """Sync wrapper for resolve_provider."""
    from .provider import resolve_provider

    return asyncio.run(resolve_provider(task_type, preferred, require_capability))


def get_managed_key_sync(provider: str) -> str | None:
    """Sync wrapper for get_managed_key."""
    from .managed_keys import get_managed_key

    return asyncio.run(get_managed_key(provider))


def report_usage_sync(
    service: str, credits: float = 0, requests: int = 1
) -> None:
    """Sync wrapper for report_usage."""
    from .usage import report_usage

    asyncio.run(report_usage(service, credits, requests))
