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.
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/harnex/runtime/session.rb', line 15 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
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/harnex/runtime/session.rb', line 26 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
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/harnex/runtime/session.rb', line 39 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
50 51 52 |
# File 'lib/harnex/runtime/session.rb', line 50 def snapshot @counts.dup end |