Module: RubyCode::Tools
- Defined in:
- lib/rubycode/tools.rb,
lib/rubycode/tools/base.rb,
lib/rubycode/tools/bash.rb,
lib/rubycode/tools/done.rb,
lib/rubycode/tools/read.rb,
lib/rubycode/tools/fetch.rb,
lib/rubycode/tools/write.rb,
lib/rubycode/tools/search.rb,
lib/rubycode/tools/update.rb,
lib/rubycode/tools/explore.rb,
lib/rubycode/tools/web_search.rb
Overview
Collection of available tools for the AI agent
Defined Under Namespace
Classes: Base, Bash, Done, Explore, Fetch, Read, Search, Update, WebSearch, Write
Constant Summary collapse
- TOOLS =
Registry of all available tools
[ Bash, Read, Search, Write, Update, Done, WebSearch, Fetch, Explore ].freeze
Class Method Summary collapse
Class Method Details
.definitions ⇒ Object
30 31 32 |
# File 'lib/rubycode/tools.rb', line 30 def self.definitions TOOLS.map(&:definition) end |
.execute(tool_name:, params:, context:) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rubycode/tools.rb', line 34 def self.execute(tool_name:, params:, context:) tool_class = TOOLS.find { |t| t.definition[:function][:name] == tool_name } raise ToolError, "Unknown tool '#{tool_name}'" unless tool_class # Instantiate tool and call execute tool_instance = tool_class.new(context: context) result = tool_instance.execute(params) # Convert result to string for history compatibility result.respond_to?(:to_s) ? result.to_s : result end |