Class: WriteTool
- Inherits:
-
LlmGateway::Tool
- Object
- LlmGateway::Tool
- WriteTool
- Defined in:
- lib/llm_gateway/agents/tools/write_tool.rb
Instance Method Summary collapse
Methods inherited from LlmGateway::Tool
cache, definition, description, #initialize, input_schema, name, tool_name
Constructor Details
This class inherits a constructor from LlmGateway::Tool
Instance Method Details
#execute(input) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/llm_gateway/agents/tools/write_tool.rb', line 19 def execute(input) path = input[:path] || input["path"] content = input[:content] || input["content"] absolute_path = ToolUtils.resolve_to_cwd(path) ToolUtils.with_file_mutation_lock(absolute_path) do FileUtils.mkdir_p(File.dirname(absolute_path)) File.write(absolute_path, content) end "Successfully wrote #{content.bytesize} bytes to #{path}" rescue StandardError => e e. end |