"""
tools/mock.py — Mock tools for testing the agent loop without real integrations.

EchoTool   — returns its input unchanged, no side effects
ConfirmTool — always requires confirmation; logs that confirmation was received
"""
from __future__ import annotations

from .base import BaseTool, ToolResult


class EchoTool(BaseTool):
    name = "echo"
    description = (
        "Returns whatever text you pass in. Useful for testing. "
        "Use this when you need to verify tool calling works."
    )
    input_schema = {
        "type": "object",
        "properties": {
            "message": {
                "type": "string",
                "description": "The text to echo back",
            }
        },
        "required": ["message"],
    }
    requires_confirmation = False
    allowed_in_scheduled_tasks = True

    async def execute(self, message: str = "", **kwargs) -> ToolResult:
        return ToolResult(success=True, data={"echo": message})


class ConfirmTool(BaseTool):
    name = "confirm_action"
    description = (
        "A test tool that always requires user confirmation before proceeding. "
        "Use to verify the confirmation flow works end-to-end."
    )
    input_schema = {
        "type": "object",
        "properties": {
            "action": {
                "type": "string",
                "description": "Description of the action requiring confirmation",
            }
        },
        "required": ["action"],
    }
    requires_confirmation = True
    allowed_in_scheduled_tasks = False

    async def execute(self, action: str = "", **kwargs) -> ToolResult:
        return ToolResult(
            success=True,
            data={"confirmed": True, "action": action},
        )

    def confirmation_description(self, action: str = "", **kwargs) -> str:
        return f"Perform action: {action}"
