Module: SharedTools
- Defined in:
- lib/shared_tools/tools.rb,
lib/shared_tools.rb,
lib/shared_tools/version.rb,
lib/shared_tools/tools/version.rb,
lib/shared_tools/tools/dns_tool.rb,
lib/shared_tools/tools/doc_tool.rb,
lib/shared_tools/tools/cron_tool.rb,
lib/shared_tools/tools/disk_tool.rb,
lib/shared_tools/tools/eval_tool.rb,
lib/shared_tools/tools/browser_tool.rb,
lib/shared_tools/tools/weather_tool.rb,
lib/shared_tools/tools/computer_tool.rb,
lib/shared_tools/tools/database_tool.rb,
lib/shared_tools/tools/clipboard_tool.rb,
lib/shared_tools/tools/devops_toolkit.rb,
lib/shared_tools/tools/disk/base_tool.rb,
lib/shared_tools/tools/calculator_tool.rb,
lib/shared_tools/tools/data_science_kit.rb,
lib/shared_tools/tools/disk/base_driver.rb,
lib/shared_tools/tools/docker/base_tool.rb,
lib/shared_tools/tools/system_info_tool.rb,
lib/shared_tools/tools/browser/base_tool.rb,
lib/shared_tools/tools/disk/local_driver.rb,
lib/shared_tools/tools/browser/click_tool.rb,
lib/shared_tools/tools/browser/visit_tool.rb,
lib/shared_tools/tools/browser/base_driver.rb,
lib/shared_tools/tools/computer/mac_driver.rb,
lib/shared_tools/tools/database_query_tool.rb,
lib/shared_tools/tools/disk/file_move_tool.rb,
lib/shared_tools/tools/disk/file_read_tool.rb,
lib/shared_tools/tools/doc/pdf_reader_tool.rb,
lib/shared_tools/tools/error_handling_tool.rb,
lib/shared_tools/tools/eval/ruby_eval_tool.rb,
lib/shared_tools/tools/browser/inspect_tool.rb,
lib/shared_tools/tools/browser/watir_driver.rb,
lib/shared_tools/tools/computer/base_driver.rb,
lib/shared_tools/tools/database/base_driver.rb,
lib/shared_tools/tools/disk/file_write_tool.rb,
lib/shared_tools/tools/eval/shell_eval_tool.rb,
lib/shared_tools/tools/secure_tool_template.rb,
lib/shared_tools/tools/browser/inspect_utils.rb,
lib/shared_tools/tools/disk/file_create_tool.rb,
lib/shared_tools/tools/disk/file_delete_tool.rb,
lib/shared_tools/tools/eval/python_eval_tool.rb,
lib/shared_tools/tools/workflow_manager_tool.rb,
lib/shared_tools/tools/current_date_time_tool.rb,
lib/shared_tools/tools/database/sqlite_driver.rb,
lib/shared_tools/tools/disk/file_replace_tool.rb,
lib/shared_tools/tools/composite_analysis_tool.rb,
lib/shared_tools/tools/docker/compose_run_tool.rb,
lib/shared_tools/tools/database/postgres_driver.rb,
lib/shared_tools/tools/disk/directory_list_tool.rb,
lib/shared_tools/tools/disk/directory_move_tool.rb,
lib/shared_tools/tools/browser/page_inspect_tool.rb,
lib/shared_tools/tools/browser/selector_generator.rb,
lib/shared_tools/tools/disk/directory_create_tool.rb,
lib/shared_tools/tools/disk/directory_delete_tool.rb,
lib/shared_tools/tools/browser/page_screenshot_tool.rb,
lib/shared_tools/tools/browser/selector_inspect_tool.rb,
lib/shared_tools/tools/browser/elements/element_grouper.rb,
lib/shared_tools/tools/browser/text_field_area_set_tool.rb,
lib/shared_tools/tools/browser/formatters/input_formatter.rb,
lib/shared_tools/tools/browser/formatters/action_formatter.rb,
lib/shared_tools/tools/browser/formatters/element_formatter.rb,
lib/shared_tools/tools/browser/page_inspect/form_summarizer.rb,
lib/shared_tools/tools/browser/page_inspect/html_summarizer.rb,
lib/shared_tools/tools/browser/page_inspect/link_summarizer.rb,
lib/shared_tools/tools/browser/page_inspect/button_summarizer.rb,
lib/shared_tools/tools/browser/formatters/data_entry_formatter.rb,
lib/shared_tools/tools/browser/elements/nearby_element_detector.rb,
lib/shared_tools/tools/browser/selector_generator/base_selectors.rb,
lib/shared_tools/tools/browser/selector_generator/contextual_selectors.rb
Overview
Loader file for all tools - loaded automatically by Zeitwerk Individual tool collections can be loaded with:
require 'shared_tools/tools/disk' # Load all disk tools
require 'shared_tools/tools/browser' # Load all browser tools
Or load individual tools with Zeitwerk autoloading:
SharedTools::Tools::Disk::FileReadTool
SharedTools::Tools::Browser::VisitTool
Defined Under Namespace
Modules: Tools
Constant Summary collapse
- VERSION =
"0.3.1"
Class Method Summary collapse
- .auto_execute(wildwest = true) ⇒ Object
- .execute?(tool: 'unknown', stuff: '') ⇒ Boolean
-
.load_all_tools ⇒ Object
Load all tool classes so they’re available via ObjectSpace Call this when using AIA with –rq shared_tools Uses manual loading to gracefully handle missing dependencies.
-
.tools ⇒ Object
Get all available tool classes (those that inherit from RubyLLM::Tool) Only returns tools that can be successfully instantiated without arguments (RubyLLM requirement).
Class Method Details
.auto_execute(wildwest = true) ⇒ Object
28 29 30 |
# File 'lib/shared_tools.rb', line 28 def auto_execute(wildwest=true) @auto_execute = wildwest end |
.execute?(tool: 'unknown', stuff: '') ⇒ Boolean
68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/shared_tools.rb', line 68 def execute?(tool: 'unknown', stuff: '') # Return true if auto_execute is explicitly enabled return true if @auto_execute == true puts "\n\nThe AI (tool: #{tool}) wants to do the following ..." puts "="*42 puts(stuff.empty? ? "unknown strange and mysterious things" : stuff) puts "="*42 sleep 0.2 if defined?(AIA) # Allows CLI spinner to recycle print "\nIs it okay to proceed? (y/N" STDIN.getch == "y" end |
.load_all_tools ⇒ Object
Load all tool classes so they’re available via ObjectSpace Call this when using AIA with –rq shared_tools Uses manual loading to gracefully handle missing dependencies
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/shared_tools.rb', line 35 def load_all_tools tools_dir = File.join(__dir__, 'shared_tools', 'tools') Dir.glob(File.join(tools_dir, '*_tool.rb')).each do |tool_file| begin require tool_file rescue LoadError => e # Skip tools with missing dependencies warn "SharedTools: Skipping #{File.basename(tool_file)} - #{e.message}" if ENV['DEBUG'] end end end |
.tools ⇒ Object
Get all available tool classes (those that inherit from RubyLLM::Tool) Only returns tools that can be successfully instantiated without arguments (RubyLLM requirement)
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/shared_tools.rb', line 49 def tools load_all_tools ObjectSpace.each_object(Class).select do |klass| next false unless klass < RubyLLM::Tool next false unless klass.to_s.start_with?('SharedTools::') # Actually try to instantiate the tool to verify it works # RubyLLM calls tool.new without args, so tools must be instantiable this way begin klass.new true rescue ArgumentError, LoadError, StandardError => e # Skip tools that can't be instantiated (missing args, missing platform drivers, etc.) warn "SharedTools: Excluding #{klass} - #{e.message}" if ENV['DEBUG'] false end end end |