Build latest book artifacts / build (push) Canceled after 0s
dependency resolution / resolve (3.11) (push) Canceled after 0s
dependency resolution / resolve (3.13) (push) Canceled after 0s
deploy-pages / build (push) Canceled after 0s
deploy-pages / deploy (push) Canceled after 0s
i18n consistency check / check (push) Canceled after 0s
provider adoption tests / test (chapter2/context-compression) (push) Canceled after 0s
provider adoption tests / test (chapter2/prompt-injection) (push) Canceled after 0s
provider adoption tests / test (chapter2/system-hint) (push) Canceled after 0s
provider adoption tests / test (chapter3/log-sanitization) (push) Canceled after 0s
web-search-agent tests / test (push) Canceled after 0s
web-search-agent tests / agentbook (push) Canceled after 0s
49 lines
1.4 KiB
Python
49 lines
1.4 KiB
Python
"""
|
|
Tool registry - Maps tool names to implementations
|
|
"""
|
|
|
|
from typing import Dict, Type
|
|
from tools import (
|
|
BaseTool, BashTool, BashOutputTool, KillBashTool,
|
|
ReadTool, WriteTool, EditTool, MultiEditTool,
|
|
GrepTool, GlobTool, LSTool,
|
|
TodoWriteTool, ExitPlanModeTool, NotebookEditTool,
|
|
WebFetchTool, WebSearchTool, TaskTool
|
|
)
|
|
|
|
|
|
class ToolRegistry:
|
|
"""Registry of all available tools"""
|
|
|
|
def __init__(self):
|
|
self._tools: Dict[str, Type[BaseTool]] = {
|
|
"Bash": BashTool,
|
|
"BashOutput": BashOutputTool,
|
|
"KillBash": KillBashTool,
|
|
"Read": ReadTool,
|
|
"Write": WriteTool,
|
|
"Edit": EditTool,
|
|
"MultiEdit": MultiEditTool,
|
|
"Grep": GrepTool,
|
|
"Glob": GlobTool,
|
|
"LS": LSTool,
|
|
"TodoWrite": TodoWriteTool,
|
|
"ExitPlanMode": ExitPlanModeTool,
|
|
"NotebookEdit": NotebookEditTool,
|
|
"WebFetch": WebFetchTool,
|
|
"WebSearch": WebSearchTool,
|
|
"Task": TaskTool,
|
|
}
|
|
|
|
def get_tool(self, name: str, system_state) -> BaseTool:
|
|
"""Get tool instance by name"""
|
|
tool_class = self._tools.get(name)
|
|
if tool_class is None:
|
|
raise ValueError(f"Unknown tool: {name}")
|
|
return tool_class(system_state)
|
|
|
|
def get_all_tool_names(self):
|
|
"""Get list of all tool names"""
|
|
return list(self._tools.keys())
|
|
|