Class: RubyLLM::Toolbox::Tools::DeleteFile
- Defined in:
- lib/ruby_llm/toolbox/tools/delete_file.rb
Overview
EXEC. Deletes a file or directory within fs_root. Deleting a non-empty directory requires recursive: true, so a single mistaken call can’t wipe a tree by accident. Confinement to the jail bounds the blast radius to fs_root regardless.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#call, exec_tool!, exec_tool?, #initialize, #name
Constructor Details
This class inherits a constructor from RubyLLM::Toolbox::Base
Instance Method Details
#execute(path:, recursive: false) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ruby_llm/toolbox/tools/delete_file.rb', line 27 def execute(path:, recursive: false) jail = Safety::PathJail.new(config.fs_root) real = jail.resolve(path) return error("refusing to delete fs_root itself", code: :refused) if real == jail.root return error("path does not exist: #{path}", code: :not_found) unless File.exist?(real) if File.directory?(real) delete_directory(real, path, recursive) else File.delete(real) "Deleted file #{path}" end rescue Safety::PathJail::Jailbreak => e error(e., code: :path_denied) end |