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.
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/harnex/runtime/session.rb', line 21 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
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/harnex/runtime/session.rb', line 32 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
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/harnex/runtime/session.rb', line 45 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
56 57 58 |
# File 'lib/harnex/runtime/session.rb', line 56 def snapshot @counts.dup end |