from abc import ABC, abstractmethod
from typing import Dict, Any, Optional
from pydantic import BaseModel

class SkillResult(BaseModel):
    success: bool
    output: Any
    error: Optional[str] = None

class BaseSkill(ABC):
    """
    Abstract Base Class for all AI-Hub Skills (Tools).
    """
    
    @property
    @abstractmethod
    def name(self) -> str:
        """Unique name of the skill."""
        pass

    @property
    @abstractmethod
    def description(self) -> str:
        """Description of what the skill does, used by LLM."""
        pass

    @property
    @abstractmethod
    def parameters_schema(self) -> Dict[str, Any]:
        """JSON Schema of the input parameters."""
        pass

    @abstractmethod
    async def execute(self, **kwargs) -> SkillResult:
        """The actual logic of the skill."""
        pass

    def to_tool_definition(self) -> Dict[str, Any]:
        """Converts the skill to an LLM tool definition."""
        return {
            "type": "function",
            "function": {
                "name": self.name,
                "description": self.description,
                "parameters": self.parameters_schema
            }
        }
