Class: DebugAgent::ToolRegistry
- Inherits:
-
Object
- Object
- DebugAgent::ToolRegistry
- Defined in:
- lib/debug_agent/tool_registry.rb
Instance Method Summary collapse
- #all_schemas ⇒ Object
- #execute(name, args) ⇒ Object
- #get(name) ⇒ Object
-
#initialize ⇒ ToolRegistry
constructor
A new instance of ToolRegistry.
- #names ⇒ Object
- #register(tool) ⇒ Object
Constructor Details
#initialize ⇒ ToolRegistry
Returns a new instance of ToolRegistry.
13 14 15 |
# File 'lib/debug_agent/tool_registry.rb', line 13 def initialize @tools = {} end |
Instance Method Details
#all_schemas ⇒ Object
25 26 27 |
# File 'lib/debug_agent/tool_registry.rb', line 25 def all_schemas @tools.values.map(&:to_schema) end |
#execute(name, args) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/debug_agent/tool_registry.rb', line 29 def execute(name, args) tool = @tools[name] return { error: "Unknown tool: #{name}" } unless tool begin result = tool.func.call(**args) result rescue => e { error: e. } end end |
#get(name) ⇒ Object
21 22 23 |
# File 'lib/debug_agent/tool_registry.rb', line 21 def get(name) @tools[name] end |
#names ⇒ Object
41 42 43 |
# File 'lib/debug_agent/tool_registry.rb', line 41 def names @tools.keys end |
#register(tool) ⇒ Object
17 18 19 |
# File 'lib/debug_agent/tool_registry.rb', line 17 def register(tool) @tools[tool.name] = tool end |