Class: Legion::Extensions::Agentic::Attention::Regulation::Helpers::AttentionTarget

Inherits:
Object
  • Object
show all
Includes:
Constants
Defined in:
lib/legion/extensions/agentic/attention/regulation/helpers/attention_target.rb

Constant Summary

Constants included from Constants

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, name:, domain: :general, salience: 0.5) ⇒ AttentionTarget

Returns a new instance of AttentionTarget.



14
15
16
17
18
19
20
21
# File 'lib/legion/extensions/agentic/attention/regulation/helpers/attention_target.rb', line 14

def initialize(id:, name:, domain: :general, salience: 0.5)
  @id            = id
  @name          = name
  @domain        = domain
  @salience      = salience.to_f.clamp(0.0, 1.0)
  @state         = :peripheral
  @attended_since = nil
end

Instance Attribute Details

#attended_sinceObject (readonly)

Returns the value of attribute attended_since.



12
13
14
# File 'lib/legion/extensions/agentic/attention/regulation/helpers/attention_target.rb', line 12

def attended_since
  @attended_since
end

#domainObject (readonly)

Returns the value of attribute domain.



12
13
14
# File 'lib/legion/extensions/agentic/attention/regulation/helpers/attention_target.rb', line 12

def domain
  @domain
end

#idObject (readonly)

Returns the value of attribute id.



12
13
14
# File 'lib/legion/extensions/agentic/attention/regulation/helpers/attention_target.rb', line 12

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



12
13
14
# File 'lib/legion/extensions/agentic/attention/regulation/helpers/attention_target.rb', line 12

def name
  @name
end

#salienceObject (readonly)

Returns the value of attribute salience.



12
13
14
# File 'lib/legion/extensions/agentic/attention/regulation/helpers/attention_target.rb', line 12

def salience
  @salience
end

#stateObject (readonly)

Returns the value of attribute state.



12
13
14
# File 'lib/legion/extensions/agentic/attention/regulation/helpers/attention_target.rb', line 12

def state
  @state
end

Instance Method Details

#attend!Object



23
24
25
26
# File 'lib/legion/extensions/agentic/attention/regulation/helpers/attention_target.rb', line 23

def attend!
  @state = :attended
  @attended_since = Time.now.utc
end

#durationObject



42
43
44
45
46
# File 'lib/legion/extensions/agentic/attention/regulation/helpers/attention_target.rb', line 42

def duration
  return nil unless @state == :attended && @attended_since

  Time.now.utc - @attended_since
end

#ignore!Object



28
29
30
31
# File 'lib/legion/extensions/agentic/attention/regulation/helpers/attention_target.rb', line 28

def ignore!
  @state = :ignored
  @attended_since = nil
end

#peripheral!Object



33
34
35
36
# File 'lib/legion/extensions/agentic/attention/regulation/helpers/attention_target.rb', line 33

def peripheral!
  @state = :peripheral
  @attended_since = nil
end

#salient_enough_to_capture?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/legion/extensions/agentic/attention/regulation/helpers/attention_target.rb', line 38

def salient_enough_to_capture?
  @salience >= CAPTURE_THRESHOLD
end

#to_hObject



48
49
50
51
52
53
54
55
56
57
# File 'lib/legion/extensions/agentic/attention/regulation/helpers/attention_target.rb', line 48

def to_h
  {
    id:             @id,
    name:           @name,
    domain:         @domain,
    salience:       @salience.round(4),
    state:          @state,
    attended_since: @attended_since
  }
end