Class: Tools::Read
Overview
Reads file contents with smart truncation and offset/limit paging. Returns plain text without line numbers, normalized to LF line endings.
Truncation limits: ‘Anima::Settings.max_read_lines` lines or `Anima::Settings.max_read_bytes` bytes, whichever hits first. When truncated, appends a continuation hint with the next offset value so the agent can page through large files.
Class Method Summary collapse
Instance Method Summary collapse
- #execute(input) ⇒ String, Hash
-
#initialize(shell_session: nil) ⇒ Read
constructor
A new instance of Read.
Methods inherited from Base
Constructor Details
#initialize(shell_session: nil) ⇒ Read
Returns a new instance of Read.
36 37 38 |
# File 'lib/tools/read.rb', line 36 def initialize(shell_session: nil, **) @working_directory = shell_session&.pwd end |
Class Method Details
.description ⇒ Object
21 |
# File 'lib/tools/read.rb', line 21 def self.description = "Read file contents. Returns plain text with smart truncation. Use offset/limit to page through large files." |
.input_schema ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/tools/read.rb', line 23 def self.input_schema { type: "object", properties: { path: {type: "string", description: "Absolute or relative file path (relative resolved against working directory)"}, offset: {type: "integer", description: "1-indexed line number to start from (default: 1)"}, limit: {type: "integer", description: "Maximum lines to read (subject to line and byte caps from config)"} }, required: ["path"] } end |
.tool_name ⇒ Object
19 |
# File 'lib/tools/read.rb', line 19 def self.tool_name = "read" |
Instance Method Details
#execute(input) ⇒ String, Hash
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/tools/read.rb', line 43 def execute(input) path, offset, limit = extract_params(input) return {error: "Path cannot be blank"} if path.empty? path = resolve_path(path) error = validate_file(path) return error if error read_file(path, offset, limit) end |