Class: Legion::Extensions::Agentic::Executive::Autopilot::Helpers::ModeEvent

Inherits:
Object
  • Object
show all
Includes:
Constants
Defined in:
lib/legion/extensions/agentic/executive/autopilot/helpers/mode_event.rb

Constant Summary

Constants included from Constants

Constants::AUTOPILOT_COST, Constants::AUTOPILOT_THRESHOLD, Constants::DEFAULT_ENERGY, Constants::DELIBERATE_COST, Constants::DELIBERATE_THRESHOLD, Constants::ENERGY_LABELS, Constants::FAMILIARITY_BOOST, Constants::FAMILIARITY_DECAY, Constants::FAMILIARITY_LABELS, Constants::MAX_EVENTS, Constants::MAX_ROUTINES, Constants::MODE_LABELS, Constants::OVERRIDE_COST, Constants::PROCESSING_MODES, Constants::TASK_DOMAINS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Constants

label_for

Constructor Details

#initialize(from_mode:, to_mode:, trigger:, energy_cost: 0.0) ⇒ ModeEvent

Returns a new instance of ModeEvent.



16
17
18
19
20
21
22
23
# File 'lib/legion/extensions/agentic/executive/autopilot/helpers/mode_event.rb', line 16

def initialize(from_mode:, to_mode:, trigger:, energy_cost: 0.0)
  @id          = SecureRandom.uuid
  @from_mode   = from_mode.to_sym
  @to_mode     = to_mode.to_sym
  @trigger     = trigger.to_s
  @energy_cost = energy_cost.to_f.clamp(0.0, 1.0).round(10)
  @created_at  = Time.now.utc
end

Instance Attribute Details

#created_atObject (readonly)

Returns the value of attribute created_at.



14
15
16
# File 'lib/legion/extensions/agentic/executive/autopilot/helpers/mode_event.rb', line 14

def created_at
  @created_at
end

#energy_costObject (readonly)

Returns the value of attribute energy_cost.



14
15
16
# File 'lib/legion/extensions/agentic/executive/autopilot/helpers/mode_event.rb', line 14

def energy_cost
  @energy_cost
end

#from_modeObject (readonly)

Returns the value of attribute from_mode.



14
15
16
# File 'lib/legion/extensions/agentic/executive/autopilot/helpers/mode_event.rb', line 14

def from_mode
  @from_mode
end

#idObject (readonly)

Returns the value of attribute id.



14
15
16
# File 'lib/legion/extensions/agentic/executive/autopilot/helpers/mode_event.rb', line 14

def id
  @id
end

#to_modeObject (readonly)

Returns the value of attribute to_mode.



14
15
16
# File 'lib/legion/extensions/agentic/executive/autopilot/helpers/mode_event.rb', line 14

def to_mode
  @to_mode
end

#triggerObject (readonly)

Returns the value of attribute trigger.



14
15
16
# File 'lib/legion/extensions/agentic/executive/autopilot/helpers/mode_event.rb', line 14

def trigger
  @trigger
end

Instance Method Details

#engage_autopilot?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/legion/extensions/agentic/executive/autopilot/helpers/mode_event.rb', line 29

def engage_autopilot?
  @from_mode == :deliberate && @to_mode == :autopilot
end

#override?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/legion/extensions/agentic/executive/autopilot/helpers/mode_event.rb', line 25

def override?
  @from_mode == :autopilot && @to_mode == :deliberate
end

#to_hObject



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/legion/extensions/agentic/executive/autopilot/helpers/mode_event.rb', line 33

def to_h
  {
    id:               @id,
    from_mode:        @from_mode,
    to_mode:          @to_mode,
    trigger:          @trigger,
    energy_cost:      @energy_cost,
    override:         override?,
    engage_autopilot: engage_autopilot?,
    created_at:       @created_at
  }
end