Class: Harnex::Session::EventCounters
- Inherits:
-
Object
- Object
- Harnex::Session::EventCounters
- Defined in:
- lib/harnex/runtime/session.rb
Instance Method Summary collapse
-
#initialize ⇒ EventCounters
constructor
A new instance of EventCounters.
- #record(type) ⇒ Object
- #record_item(item) ⇒ Object
- #snapshot ⇒ Object
Constructor Details
#initialize ⇒ EventCounters
Returns a new instance of EventCounters.
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/harnex/runtime/session.rb', line 20 def initialize @counts = { stalls: 0, force_resumes: 0, disconnections: 0, compactions: 0, tool_calls: 0, commands_executed: 0 } end |
Instance Method Details
#record(type) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/harnex/runtime/session.rb', line 31 def record(type) case type.to_s when "log_idle" @counts[:stalls] += 1 when "resume" @counts[:force_resumes] += 1 when "disconnect", "disconnection", "disconnected" @counts[:disconnections] += 1 when "compaction" @counts[:compactions] += 1 end end |
#record_item(item) ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/harnex/runtime/session.rb', line 44 def record_item(item) return unless item.is_a?(Hash) case item["type"] when "mcpToolCall", "dynamicToolCall" @counts[:tool_calls] += 1 when "commandExecution" @counts[:commands_executed] += 1 end end |
#snapshot ⇒ Object
55 56 57 |
# File 'lib/harnex/runtime/session.rb', line 55 def snapshot @counts.dup end |