"""
Base Tool interface for Metis Agent.

This module defines the base class that all tools must implement.
"""
from abc import ABC, abstractmethod
from typing import Any, Dict, Optional


class BaseTool(ABC):
    """
    Abstract base class for all tools.
    
    All tools must implement the can_handle and execute methods.
    """
    
    @abstractmethod
    def can_handle(self, task: str) -> bool:
        """
        Determine if this tool can handle the given task.
        
        Args:
            task: The task to check
            
        Returns:
            True if the tool can handle the task, False otherwise
        """
        pass
        
    @abstractmethod
    def execute(self, task: str) -> Any:
        """
        Execute the task using this tool.
        
        Args:
            task: The task to execute
            
        Returns:
            The result of executing the task
        """
        pass
        
    def get_description(self) -> str:
        """
        Get a description of this tool.
        
        Returns:
            Tool description
        """
        # Default to using the class docstring
        return self.__doc__ or f"{self.__class__.__name__} Tool"
        
    def get_examples(self) -> list:
        """
        Get example tasks that this tool can handle.
        
        Returns:
            List of example tasks
        """
        # Default to empty list, should be overridden by subclasses
        return []
        
    def __str__(self) -> str:
        """String representation of the tool."""
        return f"{self.__class__.__name__}"
        
    def __repr__(self) -> str:
        """Detailed string representation of the tool."""
        return f"{self.__class__.__name__}()"