"""MCP tools for the approvals domain."""

from __future__ import annotations


def register_tools(mcp, api_fn):
    @mcp.tool()
    async def create_approval(
        title: str,
        options: list[str],
        context: str = "",
        priority: str = "medium",
        agent_session_id: int | None = None,
        task_id: int | None = None,
        ctx=None,
    ) -> dict | str:
        """Create an approval request for a human to review.

        Use this when you need human input before proceeding — e.g. destructive
        operations, ambiguous requirements, or risky actions.

        Args:
            title: Short description of what needs approval.
            options: List of action labels the human can choose from
                     (e.g. ["Approve", "Reject", "Defer", "Tell me more"]).
            context: 2-3 sentences explaining why approval is needed.
            priority: "critical" (never expires), "medium" (30 min), or "low" (2 hr).
            agent_session_id: The current agent session ID (for tracking).
            task_id: Associated task ID (pauses task while pending).
        """
        return await api_fn(ctx).create_approval(
            title=title,
            options=options,
            context=context,
            priority=priority,
            agent_session_id=agent_session_id,
            task_id=task_id,
        )

    @mcp.tool()
    async def get_approval(approval_id: str, ctx=None) -> dict | str:
        """Get the current state of an approval request.

        Poll this to check if a human has responded. The approval's status
        will be 'pending' until a human selects an option.

        Args:
            approval_id: UUID of the approval to check.
        """
        return await api_fn(ctx).get_approval(approval_id)
