Class: SwarmSDK::V3::Tools::ReadTracker
- Inherits:
-
Object
- Object
- SwarmSDK::V3::Tools::ReadTracker
- Defined in:
- lib/swarm_sdk/v3/tools/read_tracker.rb
Overview
Tracks which files have been read by each agent
Shared across Read, Write, and Edit tool instances for the same agent. Enforces read-before-write/edit rules to prevent accidental overwrites.
Instance Method Summary collapse
-
#file_read?(agent_name, path) ⇒ Boolean
Check if an agent has read a file.
-
#initialize ⇒ ReadTracker
constructor
A new instance of ReadTracker.
-
#register_read(agent_name, path) ⇒ void
Register that an agent has read a file.
Constructor Details
#initialize ⇒ ReadTracker
Returns a new instance of ReadTracker.
16 17 18 |
# File 'lib/swarm_sdk/v3/tools/read_tracker.rb', line 16 def initialize @reads = Hash.new { |h, k| h[k] = Set.new } end |
Instance Method Details
#file_read?(agent_name, path) ⇒ Boolean
Check if an agent has read a file
34 35 36 |
# File 'lib/swarm_sdk/v3/tools/read_tracker.rb', line 34 def file_read?(agent_name, path) @reads[agent_name].include?(path) end |
#register_read(agent_name, path) ⇒ void
This method returns an undefined value.
Register that an agent has read a file
25 26 27 |
# File 'lib/swarm_sdk/v3/tools/read_tracker.rb', line 25 def register_read(agent_name, path) @reads[agent_name].add(path) end |