"""Test registration of native Anthropic tools in the agent loop."""

import pytest
from pathlib import Path
from unittest.mock import AsyncMock, MagicMock

from nanobot.agent.loop import AgentLoop
from nanobot.agent.tools.anthropic import (
    BashTool20250124,
    EditTool20250728,
    ComputerTool20251124,
)


@pytest.fixture
def mock_provider():
    """Create a mock provider."""
    provider = MagicMock()
    provider.chat = AsyncMock(return_value="test response")
    provider.get_default_model = MagicMock(return_value="test-model")
    return provider


@pytest.fixture
def mock_bus():
    """Create a mock message bus."""
    bus = MagicMock()
    bus.publish_outbound = AsyncMock()
    return bus


def test_native_tools_registered(mock_provider, mock_bus, tmp_path):
    """Test that native Anthropic tools are registered in the agent loop."""
    # Create agent loop
    loop = AgentLoop(
        provider=mock_provider,
        bus=mock_bus,
        workspace=tmp_path,
    )

    # Get all registered tool names
    tool_names = [tool.name for tool in loop.tools._tools.values()]

    # Verify native tools are registered (using their internal names)
    assert "bash" in tool_names, "bash tool should be registered"
    assert "str_replace_based_edit_tool" in tool_names, "str_replace_based_edit_tool tool should be registered"
    # Note: computer tool is intentionally disabled by default (requires VNC setup)

    # Verify we can get the tool instances
    bash_tool = loop.tools.get("bash")
    assert isinstance(bash_tool, BashTool20250124)

    editor_tool = loop.tools.get("str_replace_based_edit_tool")
    assert isinstance(editor_tool, EditTool20250728)
