"""a2akit — A2A agent framework in one import."""

from a2akit.agent_card import (
    AgentCardConfig,
    CapabilitiesConfig,
    ExtensionConfig,
    ProviderConfig,
    SignatureConfig,
    SkillConfig,
)
from a2akit.broker import (
    Broker,
    CancelRegistry,
    InMemoryBroker,
    InMemoryCancelRegistry,
)
from a2akit.client import A2AClient, ClientResult
from a2akit.client import StreamEvent as ClientStreamEvent
from a2akit.config import Settings, get_settings
from a2akit.dependencies import Dependency, DependencyContainer
from a2akit.errors import AuthenticationRequiredError
from a2akit.event_bus import EventBus, InMemoryEventBus
from a2akit.event_emitter import DefaultEventEmitter, EventEmitter
from a2akit.hooks import HookableEmitter, LifecycleHooks
from a2akit.middleware import (
    A2AMiddleware,
    ApiKeyMiddleware,
    BearerTokenMiddleware,
    RequestEnvelope,
)
from a2akit.push import (
    InMemoryPushConfigStore,
    PushConfigStore,
    PushNotificationAuthenticationInfo,
    PushNotificationConfig,
    TaskPushNotificationConfig,
)
from a2akit.server import A2AServer
from a2akit.storage import (
    ArtifactWrite,
    ContentTypeNotSupportedError,
    ContextMismatchError,
    InMemoryStorage,
    InvalidAgentResponseError,
    Storage,
    TaskNotAcceptingMessagesError,
    TaskNotCancelableError,
    TaskNotFoundError,
    TaskTerminalStateError,
    UnsupportedOperationError,
)
from a2akit.storage.base import ListTasksQuery, ListTasksResult
from a2akit.task_manager import TaskManager
from a2akit.telemetry import OTEL_ENABLED
from a2akit.worker import FileInfo, TaskContext, Worker


def __getattr__(name: str) -> object:
    """Lazy-load Redis implementations to avoid hard dependency on redis-py."""
    _redis_names = {"RedisBroker", "RedisCancelRegistry", "RedisEventBus", "RedisStorage"}
    if name in _redis_names:
        if name in ("RedisBroker", "RedisCancelRegistry"):
            from a2akit.broker.redis import RedisBroker, RedisCancelRegistry

            globals()["RedisBroker"] = RedisBroker
            globals()["RedisCancelRegistry"] = RedisCancelRegistry
        if name == "RedisEventBus":
            from a2akit.event_bus.redis import RedisEventBus

            globals()["RedisEventBus"] = RedisEventBus
        if name == "RedisStorage":
            from a2akit.storage.redis import RedisStorage

            globals()["RedisStorage"] = RedisStorage
        return globals()[name]
    msg = f"module {__name__!r} has no attribute {name!r}"
    raise AttributeError(msg)


__all__ = [
    "OTEL_ENABLED",
    "A2AClient",
    "A2AMiddleware",
    "A2AServer",
    "AgentCardConfig",
    "ApiKeyMiddleware",
    "ArtifactWrite",
    "AuthenticationRequiredError",
    "BearerTokenMiddleware",
    "Broker",
    "CancelRegistry",
    "CapabilitiesConfig",
    "ClientResult",
    "ClientStreamEvent",
    "ContentTypeNotSupportedError",
    "ContextMismatchError",
    "DefaultEventEmitter",
    "Dependency",
    "DependencyContainer",
    "EventBus",
    "EventEmitter",
    "ExtensionConfig",
    "FileInfo",
    "HookableEmitter",
    "InMemoryBroker",
    "InMemoryCancelRegistry",
    "InMemoryEventBus",
    "InMemoryPushConfigStore",
    "InMemoryStorage",
    "InvalidAgentResponseError",
    "LifecycleHooks",
    "ListTasksQuery",
    "ListTasksResult",
    "ProviderConfig",
    "PushConfigStore",
    "PushNotificationAuthenticationInfo",
    "PushNotificationConfig",
    "RedisBroker",
    "RedisCancelRegistry",
    "RedisEventBus",
    "RedisStorage",
    "RequestEnvelope",
    "Settings",
    "SignatureConfig",
    "SkillConfig",
    "Storage",
    "TaskContext",
    "TaskManager",
    "TaskNotAcceptingMessagesError",
    "TaskNotCancelableError",
    "TaskNotFoundError",
    "TaskPushNotificationConfig",
    "TaskTerminalStateError",
    "UnsupportedOperationError",
    "Worker",
    "get_settings",
]
