Module: Legion::Extensions::Agentic::Attention::Regulation::Runners::AttentionRegulation

Includes:
Helpers::Constants, Helpers::Lex
Included in:
Client
Defined in:
lib/legion/extensions/agentic/attention/regulation/runners/attention_regulation.rb

Constant Summary

Constants included from Helpers::Constants

Helpers::Constants::ATTENTION_MODES, Helpers::Constants::CAPTURE_THRESHOLD, Helpers::Constants::DEFAULT_RESOURCE, Helpers::Constants::DEFAULT_ZOOM, Helpers::Constants::MAX_HISTORY, Helpers::Constants::MAX_TARGETS, Helpers::Constants::RESOURCE_CEILING, Helpers::Constants::RESOURCE_DRAIN, Helpers::Constants::RESOURCE_FLOOR, Helpers::Constants::RESOURCE_LABELS, Helpers::Constants::RESOURCE_RECOVERY, Helpers::Constants::TARGET_STATES, Helpers::Constants::ZOOM_CEILING, Helpers::Constants::ZOOM_FLOOR

Instance Method Summary collapse

Instance Method Details

#add_attention_target(name:, domain: :general, salience: 0.5) ⇒ Object



13
14
15
16
17
18
# File 'lib/legion/extensions/agentic/attention/regulation/runners/attention_regulation.rb', line 13

def add_attention_target(name:, domain: :general, salience: 0.5, **)
  target = controller.add_target(name: name, domain: domain, salience: salience)
  return { success: false, reason: :limit_reached } unless target

  { success: true, target_id: target.id, name: target.name, salience: target.salience }
end

#attention_regulation_statsObject



73
74
75
# File 'lib/legion/extensions/agentic/attention/regulation/runners/attention_regulation.rb', line 73

def attention_regulation_stats(**)
  { success: true }.merge(controller.to_h)
end

#current_attention_targetObject



54
55
56
57
58
59
# File 'lib/legion/extensions/agentic/attention/regulation/runners/attention_regulation.rb', line 54

def current_attention_target(**)
  target = controller.current_target
  return { success: true, target: nil } unless target

  { success: true, target: target.to_h }
end

#defocus_attentionObject



27
28
29
30
# File 'lib/legion/extensions/agentic/attention/regulation/runners/attention_regulation.rb', line 27

def defocus_attention(**)
  controller.defocus
  { success: true, mode: :diffuse }
end

#focus_attention(target_id:) ⇒ Object



20
21
22
23
24
25
# File 'lib/legion/extensions/agentic/attention/regulation/runners/attention_regulation.rb', line 20

def focus_attention(target_id:, **)
  target = controller.focus_on(target_id: target_id)
  return { success: false, reason: :not_found } unless target

  { success: true, target_id: target.id, mode: :focused }
end

#most_salient_targetObject



61
62
63
64
65
66
# File 'lib/legion/extensions/agentic/attention/regulation/runners/attention_regulation.rb', line 61

def most_salient_target(**)
  target = controller.most_salient
  return { success: true, target: nil } unless target

  { success: true, target: target.to_h }
end

#rest_attentionObject



39
40
41
42
# File 'lib/legion/extensions/agentic/attention/regulation/runners/attention_regulation.rb', line 39

def rest_attention(**)
  controller.rest
  { success: true, mode: :resting }
end

#scan_attentionObject



32
33
34
35
36
37
# File 'lib/legion/extensions/agentic/attention/regulation/runners/attention_regulation.rb', line 32

def scan_attention(**)
  captured = controller.scan
  result = { success: true, mode: :scanning }
  result[:captured_target_id] = captured.id if captured
  result
end

#update_attentionObject



68
69
70
71
# File 'lib/legion/extensions/agentic/attention/regulation/runners/attention_regulation.rb', line 68

def update_attention(**)
  controller.tick
  { success: true }.merge(controller.to_h)
end

#zoom_attention_in(amount: 0.1) ⇒ Object



44
45
46
47
# File 'lib/legion/extensions/agentic/attention/regulation/runners/attention_regulation.rb', line 44

def zoom_attention_in(amount: 0.1, **)
  zoom = controller.zoom_in(amount: amount)
  { success: true, zoom: zoom.round(4) }
end

#zoom_attention_out(amount: 0.1) ⇒ Object



49
50
51
52
# File 'lib/legion/extensions/agentic/attention/regulation/runners/attention_regulation.rb', line 49

def zoom_attention_out(amount: 0.1, **)
  zoom = controller.zoom_out(amount: amount)
  { success: true, zoom: zoom.round(4) }
end