"""
tools/__init__.py — Tool registry factory.

Call build_registry() to get a ToolRegistry populated with all
production tools. The agent loop calls this at startup.
"""
from __future__ import annotations


def build_registry(include_mock: bool = False, is_admin: bool = True):
    """
    Build and return a ToolRegistry with all production tools registered.

    Args:
        include_mock: If True, also register EchoTool and ConfirmTool (for testing).
    """
    from ..agent.tool_registry import ToolRegistry
    registry = ToolRegistry()

    # Production tools — each imported lazily to avoid errors if optional
    # dependencies are missing during development
    from .brain_tool import BrainTool
    from .browser_tool import BrowserTool
    from .caldav_tool import CalDAVTool
    from .contacts_tool import ContactsTool
    from .email_tool import EmailTool
    from .filesystem_tool import FilesystemTool
    from .image_gen_tool import ImageGenTool
    from .pushover_tool import PushoverTool
    from .telegram_tool import TelegramTool
    from .web_tool import WebTool
    from .webhook_tool import WebhookTool
    from .whitelist_tool import WhitelistTool

    if is_admin:
        from .bash_tool import BashTool
        registry.register(BashTool())
    registry.register(BrainTool())
    registry.register(BrowserTool())
    registry.register(CalDAVTool())
    registry.register(ContactsTool())
    registry.register(EmailTool())
    registry.register(FilesystemTool())
    registry.register(ImageGenTool())
    registry.register(WebTool())
    registry.register(WebhookTool())
    registry.register(PushoverTool())
    registry.register(TelegramTool())
    registry.register(WhitelistTool())

    if include_mock:
        from .mock import ConfirmTool, EchoTool
        registry.register(EchoTool())
        registry.register(ConfirmTool())

    return registry
