lex-agentic-affect 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/Gemfile +2 -0
- data/LICENSE +201 -21
- data/README.md +1 -1
- data/lib/legion/extensions/agentic/affect/appraisal/client.rb +1 -0
- data/lib/legion/extensions/agentic/affect/appraisal/runners/appraisal.rb +18 -16
- data/lib/legion/extensions/agentic/affect/cognitive_empathy/client.rb +1 -0
- data/lib/legion/extensions/agentic/affect/cognitive_empathy/runners/cognitive_empathy.rb +3 -1
- data/lib/legion/extensions/agentic/affect/contagion/client.rb +1 -0
- data/lib/legion/extensions/agentic/affect/contagion/runners/cognitive_contagion.rb +24 -24
- data/lib/legion/extensions/agentic/affect/defusion/client.rb +1 -0
- data/lib/legion/extensions/agentic/affect/defusion/runners/cognitive_defusion.rb +21 -21
- data/lib/legion/extensions/agentic/affect/emotion/actors/momentum_decay.rb +1 -1
- data/lib/legion/extensions/agentic/affect/emotion/client.rb +1 -0
- data/lib/legion/extensions/agentic/affect/emotion/runners/gut.rb +7 -7
- data/lib/legion/extensions/agentic/affect/emotion/runners/valence.rb +10 -10
- data/lib/legion/extensions/agentic/affect/empathy/client.rb +1 -0
- data/lib/legion/extensions/agentic/affect/empathy/runners/empathy.rb +14 -14
- data/lib/legion/extensions/agentic/affect/fatigue/client.rb +1 -0
- data/lib/legion/extensions/agentic/affect/fatigue/runners/fatigue.rb +9 -9
- data/lib/legion/extensions/agentic/affect/flow/client.rb +1 -0
- data/lib/legion/extensions/agentic/affect/flow/runners/flow.rb +8 -8
- data/lib/legion/extensions/agentic/affect/interoception/actors/decay.rb +1 -1
- data/lib/legion/extensions/agentic/affect/interoception/client.rb +1 -0
- data/lib/legion/extensions/agentic/affect/interoception/runners/interoception.rb +12 -12
- data/lib/legion/extensions/agentic/affect/mood/client.rb +1 -0
- data/lib/legion/extensions/agentic/affect/mood/runners/mood.rb +7 -7
- data/lib/legion/extensions/agentic/affect/motivation/client.rb +1 -0
- data/lib/legion/extensions/agentic/affect/motivation/runners/motivation.rb +13 -13
- data/lib/legion/extensions/agentic/affect/reappraisal/actors/auto_regulate.rb +1 -1
- data/lib/legion/extensions/agentic/affect/reappraisal/client.rb +1 -0
- data/lib/legion/extensions/agentic/affect/reappraisal/helpers/llm_enhancer.rb +4 -4
- data/lib/legion/extensions/agentic/affect/reappraisal/runners/cognitive_reappraisal.rb +17 -17
- data/lib/legion/extensions/agentic/affect/regulation/client.rb +1 -0
- data/lib/legion/extensions/agentic/affect/regulation/runners/emotional_regulation.rb +12 -12
- data/lib/legion/extensions/agentic/affect/resilience/client.rb +1 -0
- data/lib/legion/extensions/agentic/affect/resilience/runners/resilience.rb +10 -10
- data/lib/legion/extensions/agentic/affect/resonance/client.rb +1 -0
- data/lib/legion/extensions/agentic/affect/resonance/helpers/resonance_engine.rb +10 -6
- data/lib/legion/extensions/agentic/affect/resonance/runners/cognitive_resonance.rb +12 -12
- data/lib/legion/extensions/agentic/affect/reward/client.rb +1 -0
- data/lib/legion/extensions/agentic/affect/reward/runners/reward.rb +10 -10
- data/lib/legion/extensions/agentic/affect/somatic_marker/actors/decay.rb +1 -1
- data/lib/legion/extensions/agentic/affect/somatic_marker/client.rb +1 -0
- data/lib/legion/extensions/agentic/affect/somatic_marker/runners/somatic_marker.rb +31 -31
- data/lib/legion/extensions/agentic/affect/version.rb +1 -1
- data/lib/legion/extensions/agentic/affect.rb +2 -2
- data/spec/legion/extensions/agentic/affect/somatic_marker/helpers/marker_store_spec.rb +1 -1
- metadata +1 -1
|
@@ -7,51 +7,51 @@ module Legion
|
|
|
7
7
|
module SomaticMarker
|
|
8
8
|
module Runners
|
|
9
9
|
module SomaticMarker
|
|
10
|
-
include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers) &&
|
|
11
|
-
Legion::Extensions::Helpers.const_defined?(:Lex)
|
|
10
|
+
include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers, false) &&
|
|
11
|
+
Legion::Extensions::Helpers.const_defined?(:Lex, false)
|
|
12
12
|
|
|
13
13
|
def register_marker(action:, domain:, valence:, source: :experience, **)
|
|
14
14
|
marker = store.register_marker(action: action, domain: domain, valence: valence, source: source)
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
log.debug("[somatic_marker] register: action=#{action} domain=#{domain} " \
|
|
16
|
+
"valence=#{valence.round(3)} source=#{source} id=#{marker.id}")
|
|
17
17
|
{ success: true, marker: marker.to_h }
|
|
18
18
|
rescue StandardError => e
|
|
19
|
-
|
|
19
|
+
log.error("[somatic_marker] register failed: #{e.message}")
|
|
20
20
|
{ success: false, error: e.message }
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def evaluate_option(action:, domain:, **)
|
|
24
24
|
result = store.evaluate_option(action: action, domain: domain)
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
log.debug("[somatic_marker] evaluate: action=#{action} domain=#{domain} " \
|
|
26
|
+
"signal=#{result[:signal]} valence=#{result[:valence].round(3)}")
|
|
27
27
|
{ success: true }.merge(result)
|
|
28
28
|
rescue StandardError => e
|
|
29
|
-
|
|
29
|
+
log.error("[somatic_marker] evaluate failed: #{e.message}")
|
|
30
30
|
{ success: false, error: e.message }
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def make_decision(options:, domain:, **)
|
|
34
34
|
result = store.decide(options: options, domain: domain)
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
log.debug("[somatic_marker] decide: domain=#{domain} options=#{options.size} " \
|
|
36
|
+
"top=#{result[:ranked].first&.fetch(:action)}")
|
|
37
37
|
{ success: true, decision: result }
|
|
38
38
|
rescue StandardError => e
|
|
39
|
-
|
|
39
|
+
log.error("[somatic_marker] decide failed: #{e.message}")
|
|
40
40
|
{ success: false, error: e.message }
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
def reinforce(marker_id:, outcome_valence:, **)
|
|
44
44
|
marker = store.reinforce_marker(marker_id: marker_id, outcome_valence: outcome_valence)
|
|
45
45
|
unless marker
|
|
46
|
-
|
|
46
|
+
log.debug("[somatic_marker] reinforce: marker_id=#{marker_id} not found")
|
|
47
47
|
return { success: false, error: 'marker not found' }
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
log.debug("[somatic_marker] reinforce: id=#{marker_id} " \
|
|
51
|
+
"outcome=#{outcome_valence.round(3)} new_valence=#{marker.valence.round(3)}")
|
|
52
52
|
{ success: true, marker: marker.to_h }
|
|
53
53
|
rescue StandardError => e
|
|
54
|
-
|
|
54
|
+
log.error("[somatic_marker] reinforce failed: #{e.message}")
|
|
55
55
|
{ success: false, error: e.message }
|
|
56
56
|
end
|
|
57
57
|
|
|
@@ -62,59 +62,59 @@ module Legion
|
|
|
62
62
|
comfort: comfort,
|
|
63
63
|
gut_signal: gut_signal
|
|
64
64
|
)
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
log.debug("[somatic_marker] body_update: composite=#{state.composite_valence.round(3)} " \
|
|
66
|
+
"stressed=#{state.stressed?}")
|
|
67
67
|
{ success: true, body_state: state.to_h }
|
|
68
68
|
rescue StandardError => e
|
|
69
|
-
|
|
69
|
+
log.error("[somatic_marker] body update failed: #{e.message}")
|
|
70
70
|
{ success: false, error: e.message }
|
|
71
71
|
end
|
|
72
72
|
|
|
73
73
|
def body_state(**)
|
|
74
74
|
state = store.body_state
|
|
75
|
-
|
|
75
|
+
log.debug("[somatic_marker] body_state: composite=#{state.composite_valence.round(3)}")
|
|
76
76
|
{ success: true, body_state: state.to_h }
|
|
77
77
|
rescue StandardError => e
|
|
78
|
-
|
|
78
|
+
log.error("[somatic_marker] body_state failed: #{e.message}")
|
|
79
79
|
{ success: false, error: e.message }
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
def markers_for_action(action:, domain:, **)
|
|
83
83
|
markers = store.markers_for(action: action, domain: domain)
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
log.debug("[somatic_marker] markers_for: action=#{action} domain=#{domain} " \
|
|
85
|
+
"count=#{markers.size}")
|
|
86
86
|
{ success: true, markers: markers.map(&:to_h), count: markers.size }
|
|
87
87
|
rescue StandardError => e
|
|
88
|
-
|
|
88
|
+
log.error("[somatic_marker] markers_for_action failed: #{e.message}")
|
|
89
89
|
{ success: false, error: e.message }
|
|
90
90
|
end
|
|
91
91
|
|
|
92
92
|
def recent_decisions(limit: 10, **)
|
|
93
93
|
decisions = store.decision_history(limit: limit)
|
|
94
|
-
|
|
94
|
+
log.debug("[somatic_marker] recent_decisions: limit=#{limit} count=#{decisions.size}")
|
|
95
95
|
{ success: true, decisions: decisions, count: decisions.size }
|
|
96
96
|
rescue StandardError => e
|
|
97
|
-
|
|
97
|
+
log.error("[somatic_marker] recent_decisions failed: #{e.message}")
|
|
98
98
|
{ success: false, error: e.message }
|
|
99
99
|
end
|
|
100
100
|
|
|
101
101
|
def update_somatic_markers(**)
|
|
102
102
|
result = store.decay_all
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
log.debug("[somatic_marker] decay: remaining=#{result[:markers_decayed]} " \
|
|
104
|
+
"removed=#{result[:markers_removed]}")
|
|
105
105
|
{ success: true }.merge(result)
|
|
106
106
|
rescue StandardError => e
|
|
107
|
-
|
|
107
|
+
log.error("[somatic_marker] decay failed: #{e.message}")
|
|
108
108
|
{ success: false, error: e.message }
|
|
109
109
|
end
|
|
110
110
|
|
|
111
111
|
def somatic_marker_stats(**)
|
|
112
112
|
stats = store.to_h
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
log.debug("[somatic_marker] stats: markers=#{stats[:marker_count]} " \
|
|
114
|
+
"decisions=#{stats[:decision_count]}")
|
|
115
115
|
{ success: true }.merge(stats)
|
|
116
116
|
rescue StandardError => e
|
|
117
|
-
|
|
117
|
+
log.error("[somatic_marker] stats failed: #{e.message}")
|
|
118
118
|
{ success: false, error: e.message }
|
|
119
119
|
end
|
|
120
120
|
|
|
@@ -23,9 +23,9 @@ module Legion
|
|
|
23
23
|
module Extensions
|
|
24
24
|
module Agentic
|
|
25
25
|
module Affect
|
|
26
|
-
extend Legion::Extensions::Core if Legion::Extensions.const_defined? :Core
|
|
26
|
+
extend Legion::Extensions::Core if Legion::Extensions.const_defined? :Core, false
|
|
27
27
|
|
|
28
|
-
def remote_invocable?
|
|
28
|
+
def self.remote_invocable?
|
|
29
29
|
false
|
|
30
30
|
end
|
|
31
31
|
end
|
|
@@ -107,7 +107,7 @@ RSpec.describe Legion::Extensions::Agentic::Affect::SomaticMarker::Helpers::Mark
|
|
|
107
107
|
|
|
108
108
|
it 'caps options at MAX_OPTIONS_PER_DECISION' do
|
|
109
109
|
max = Legion::Extensions::Agentic::Affect::SomaticMarker::Helpers::Constants::MAX_OPTIONS_PER_DECISION
|
|
110
|
-
options = (max + 5)
|
|
110
|
+
options = Array.new(max + 5) { |i| :"option_#{i}" }
|
|
111
111
|
result = store.decide(options: options, domain: :ops)
|
|
112
112
|
expect(result[:ranked].size).to eq(max)
|
|
113
113
|
end
|