multiple-changes-made

This commit is contained in:
eweeman
2026-01-14 11:44:13 -08:00
parent 9d31399518
commit 9de6602e0d
39 changed files with 806 additions and 66 deletions

40
tool_loader.py Normal file
View File

@@ -0,0 +1,40 @@
import importlib
import logging
from pathlib import Path
def load_tools(tools_path: Path):
registry = {}
for file in tools_path.glob("*.py"):
if file.name.startswith("_"):
continue
module_name = f"tools.{file.stem}"
try:
module = importlib.import_module(module_name)
# Check if TOOL_DEFINITION exists
if not hasattr(module, "TOOL_DEFINITION"):
logging.warning(f"Tool {file.name} missing TOOL_DEFINITION, skipping")
continue
# Check if run function exists
if not hasattr(module, "run"):
logging.warning(f"Tool {file.name} missing 'run' function, skipping")
continue
name = module.TOOL_DEFINITION["name"]
func = getattr(module, "run")
registry[name] = {
"definition": module.TOOL_DEFINITION,
"function": func,
}
logging.info(f"Loaded tool: {name}")
except Exception as e:
logging.error(f"Failed to load tool {file.name}", exc_info=True)
return registry