Module: Legion::Extensions::Agentic::Social::Mirror::Runners::Observe

Includes:
Helpers::Lex
Included in:
Client
Defined in:
lib/legion/extensions/agentic/social/mirror/runners/observe.rb

Instance Method Summary collapse

Instance Method Details

#list_events(agent_id: nil, engine: nil) ⇒ Object



35
36
37
38
39
# File 'lib/legion/extensions/agentic/social/mirror/runners/observe.rb', line 35

def list_events(agent_id: nil, engine: nil, **)
  eng = engine || mirror_engine
  events = agent_id ? eng.events_for(agent_id) : eng.events
  { success: true, events: events.map(&:to_h), count: events.size }
end

#observe_action(agent_id:, action_type:, context: {}, emotional_valence: 0.0, engine: nil) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/legion/extensions/agentic/social/mirror/runners/observe.rb', line 13

def observe_action(agent_id:, action_type:, context: {}, emotional_valence: 0.0, engine: nil, **)
  eng = engine || mirror_engine

  unless Helpers::Constants::ACTION_TYPES.include?(action_type.to_sym)
    log.debug "[cognitive_mirror] unknown action_type=#{action_type}, mapping to :unknown"
  end

  event = eng.observe(
    agent_id:          agent_id,
    action_type:       action_type,
    context:           context,
    emotional_valence: emotional_valence
  )

  resonance_label = Helpers::Constants.label_for(Helpers::Constants::RESONANCE_LABELS,
                                                 eng.empathic_resonance(agent_id))
  log.debug "[cognitive_mirror] observed action=#{event.action_type} " \
            "agent=#{agent_id} resonance_tier=#{resonance_label}"

  { success: true, event: event.to_h, resonance_tier: resonance_label }
end