from typing import Type, Dict from pqai_agent.toolkit.function_tool import FunctionTool class ToolRegistry: tool_map: Dict[str, FunctionTool] = {} @classmethod def register_tools(cls, toolkit_class: Type): """ Register tools from a toolkit class into the global tool_map. Args: toolkit_class (Type): A class that implements a `get_tools` method. """ instance = toolkit_class() if not hasattr(instance, 'get_tools') or not callable(instance.get_tools): raise ValueError(f"{toolkit_class.__name__} must implement a callable `get_tools` method.") tools = instance.get_tools() for tool in tools: if not hasattr(tool, 'name'): raise ValueError(f"Tool {tool} must have a `name` attribute.") cls.tool_map[tool.name] = tool def register_toolkit(cls): ToolRegistry.register_tools(cls) return cls