__init__.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. """
  2. Tools 包 - 工具注册和 Schema 生成
  3. """
  4. import os
  5. from agent.tools.registry import ToolRegistry, tool, get_tool_registry
  6. from agent.tools.schema import SchemaGenerator
  7. from agent.tools.models import ToolResult, ToolContext, ToolContextImpl
  8. # 导入 builtin 工具以触发 @tool 装饰器注册
  9. # noqa: F401 表示这是故意的副作用导入
  10. import agent.tools.builtin # noqa: F401
  11. # 默认:bash / 文件类工具在存在 gateway_exec 或 AGENT_DEFAULT_DOCKER_CONTAINER 时走 docker exec
  12. # (见 agent.tools.docker_runner)。本机执行可设 AGENT_DISABLE_GATEWAY_WORKSPACE_DISPATCH /
  13. # AGENT_DISABLE_BASH_GATEWAY_DISPATCH=true。
  14. _reg = get_tool_registry()
  15. if os.getenv("AGENT_DISABLE_GATEWAY_WORKSPACE_DISPATCH", "").strip().lower() not in (
  16. "1",
  17. "true",
  18. "yes",
  19. ):
  20. from agent.tools.docker_runner import install_workspace_file_tools_dispatch
  21. install_workspace_file_tools_dispatch(_reg)
  22. if os.getenv("AGENT_DISABLE_BASH_GATEWAY_DISPATCH", "").strip().lower() not in (
  23. "1",
  24. "true",
  25. "yes",
  26. ):
  27. from agent.tools.docker_runner import install_bash_gateway_dispatch
  28. install_bash_gateway_dispatch(_reg)
  29. __all__ = [
  30. "ToolRegistry",
  31. "tool",
  32. "get_tool_registry",
  33. "SchemaGenerator",
  34. "ToolResult",
  35. "ToolContext",
  36. "ToolContextImpl",
  37. ]