"""
Tool Call Schema

Defines request/response structures for tool invocation.
"""

from pydantic import BaseModel, Field
from typing import Optional, Dict, Any, List
from datetime import datetime


class ToolCallRequest(BaseModel):
    """Tool call request"""

    tool_name: str = Field(..., description="Tool name")
    command: str = Field(..., description="Command name")
    parameters: Dict[str, Any] = Field(default_factory=dict, description="Parameters")
    timeout: Optional[int] = Field(default=None, description="Timeout override")
    context: Optional[Dict[str, Any]] = Field(default=None, description="Context information")


class ToolCallResponse(BaseModel):
    """Tool call response"""

    status: str = Field(..., description="Status: success/error")
    result: Optional[Any] = Field(default=None, description="Execution result")
    error: Optional[str] = Field(default=None, description="Error message")
    message: Optional[str] = Field(default=None, description="AI-friendly message")
    base64: Optional[str] = Field(default=None, description="Base64 data")
    duration_ms: Optional[int] = Field(default=None, description="Execution duration")
    timestamp: datetime = Field(default_factory=datetime.utcnow)


class ToolExecutionLog(BaseModel):
    """Tool execution log"""

    id: str
    tool_name: str
    command: str
    parameters: Dict[str, Any]
    status: str
    duration_ms: int
    error: Optional[str] = None
    user_id: Optional[str] = None
    agent_id: Optional[str] = None
    created_at: datetime = Field(default_factory=datetime.utcnow)
