"""Agent tools for Hanzo MCP.

This module provides tools that allow Claude to delegate tasks to sub-agents,
enabling concurrent execution of multiple operations and specialized processing.
"""

from mcp.server.fastmcp import FastMCP

from hanzo_mcp.tools.agent.agent_tool import AgentTool
from hanzo_mcp.tools.common.base import BaseTool, ToolRegistry 
from hanzo_mcp.tools.common.context import DocumentContext
from hanzo_mcp.tools.common.permissions import PermissionManager
from hanzo_mcp.tools.shell.command_executor import CommandExecutor


def register_agent_tools(
    mcp_server: FastMCP,
    document_context: DocumentContext,
    permission_manager: PermissionManager,
    command_executor: CommandExecutor,
    agent_model: str | None = None,
    agent_max_tokens: int | None = None,
    agent_api_key: str | None = None,
    agent_max_iterations: int = 10,
    agent_max_tool_uses: int = 30,
) -> list[BaseTool]:
    """Register agent tools with the MCP server.

    Args:
        mcp_server: The FastMCP server instance
        document_context: Document context for tracking file contents
        permission_manager: Permission manager for access control
        command_executor: Command executor for running shell commands
        agent_model: Optional model name for agent tool in LiteLLM format
        agent_max_tokens: Optional maximum tokens for agent responses
        agent_api_key: Optional API key for the LLM provider
        agent_max_iterations: Maximum number of iterations for agent (default: 10)
        agent_max_tool_uses: Maximum number of total tool uses for agent (default: 30)

    Returns:
        List of registered tools
    """
    # Create agent tool
    agent_tool = AgentTool(
        document_context=document_context, 
        permission_manager=permission_manager,
        command_executor=command_executor,
        model=agent_model,
        api_key=agent_api_key,
        max_tokens=agent_max_tokens,
        max_iterations=agent_max_iterations,
        max_tool_uses=agent_max_tool_uses
    )

    # Register agent tool
    ToolRegistry.register_tool(mcp_server, agent_tool)

    # Return list of registered tools
    return [agent_tool]
