"""Tools module for X-Agents. This module provides tool infrastructure for the agent system. It wraps and extends the nanobot tool implementation. """ from nanobot.agent.tools.base import Tool from nanobot.agent.tools.registry import ToolRegistry from agents.tools.builtin import ( get_builtin_tools, ReadFileTool, WriteFileTool, ListDirectoryTool, SearchTool, WebSearchTool, CalculatorTool, GetTimeTool, BashTool, ) from agents.tools.manager import ToolManager def create_default_registry(use_sandbox: bool = False) -> ToolRegistry: """Create a tool registry with default tools. Args: use_sandbox: Whether to use sandbox for shell execution Returns: Tool registry with built-in tools """ registry = ToolRegistry() # Register built-in tools for tool in get_builtin_tools(use_sandbox=use_sandbox): registry.register(tool) return registry # Import sandbox tools from nanobot (optional) try: from nanobot.agent.tools.sandbox_execution import ( SandboxType, SandboxCodeExecutionTool, SandboxBashTool, get_sandbox_tools, ) from nanobot.agent.tools.bwrap_sandbox import ( BwrapSandbox, get_bwrap_sandbox, execute_in_bwrap, ) from nanobot.agent.tools.gvisor_sandbox import ( GvisorSandbox, get_gvisor_sandbox, execute_in_gvisor, ) SANDBOX_AVAILABLE = True except ImportError as e: SandboxType = None SandboxCodeExecutionTool = None SandboxBashTool = None get_sandbox_tools = None BwrapSandbox = None get_bwrap_sandbox = None execute_in_bwrap = None GvisorSandbox = None get_gvisor_sandbox = None execute_in_gvisor = None SANDBOX_AVAILABLE = False __all__ = [ "Tool", "ToolRegistry", "ToolManager", "create_default_registry", "get_builtin_tools", "ReadFileTool", "WriteFileTool", "ListDirectoryTool", "SearchTool", "WebSearchTool", "CalculatorTool", "GetTimeTool", "BashTool", # Sandbox tools "SANDBOX_AVAILABLE", "SandboxType", "SandboxCodeExecutionTool", "SandboxBashTool", "get_sandbox_tools", "BwrapSandbox", "GvisorSandbox", "get_bwrap_sandbox", "get_gvisor_sandbox", "execute_in_bwrap", "execute_in_gvisor", ]