Files
leadchat/enterprise/app/services/captain/tool_registry_service.rb
Sojan Jose bc42aec68e chore: upgrade ruby version to 3.4.4 (#11524)
- Chore upgrade ruby version to 3.4.4 before we migrate to rails 7.2
over #11037
2025-05-21 19:40:07 +05:30

30 lines
637 B
Ruby

class Captain::ToolRegistryService
attr_reader :registered_tools, :tools
def initialize(assistant)
@assistant = assistant
@registered_tools = []
@tools = {}
end
def register_tool(tool_class)
tool = tool_class.new(@assistant)
return unless tool.active?
@tools[tool.name] = tool
@registered_tools << tool.to_registry_format
end
def method_missing(method_name, *)
if @tools.key?(method_name.to_s)
@tools[method_name.to_s].execute(*)
else
super
end
end
def respond_to_missing?(method_name, include_private = false)
@tools.key?(method_name.to_s) || super
end
end