Module: Legion::Extensions::Agentic::Self::NarrativeSelf::Runners::NarrativeSelf
- Includes:
- Helpers::Lex
- Included in:
- Client
- Defined in:
- lib/legion/extensions/agentic/self/narrative_self/runners/narrative_self.rb
Instance Method Summary collapse
- #create_thread(theme:, domain: :general) ⇒ Object
- #episodes_by_type(episode_type:) ⇒ Object
- #narrative_self_stats ⇒ Object
- #recent_episodes(count: 10) ⇒ Object
- #record_episode(description:, episode_type: :insight, domain: :general, significance: nil, emotional_valence: 0.0, tags: []) ⇒ Object
- #self_summary ⇒ Object
- #significant_episodes(min_significance: 0.6) ⇒ Object
- #strongest_threads(count: 5) ⇒ Object
- #timeline(window: nil) ⇒ Object
- #update_narrative_self ⇒ Object
Instance Method Details
#create_thread(theme:, domain: :general) ⇒ Object
42 43 44 45 46 |
# File 'lib/legion/extensions/agentic/self/narrative_self/runners/narrative_self.rb', line 42 def create_thread(theme:, domain: :general, **) thread = autobiography.create_thread(theme: theme, domain: domain) log.debug "[narrative_self] created thread=#{theme} domain=#{domain}" { success: true, thread: thread.to_h } end |
#episodes_by_type(episode_type:) ⇒ Object
37 38 39 40 |
# File 'lib/legion/extensions/agentic/self/narrative_self/runners/narrative_self.rb', line 37 def episodes_by_type(episode_type:, **) episodes = autobiography.episodes_by_type(episode_type) { success: true, episodes: episodes.map(&:to_h), count: episodes.size } end |
#narrative_self_stats ⇒ Object
71 72 73 |
# File 'lib/legion/extensions/agentic/self/narrative_self/runners/narrative_self.rb', line 71 def narrative_self_stats(**) { success: true, stats: autobiography.to_h } end |
#recent_episodes(count: 10) ⇒ Object
27 28 29 30 |
# File 'lib/legion/extensions/agentic/self/narrative_self/runners/narrative_self.rb', line 27 def recent_episodes(count: 10, **) episodes = autobiography.recent_episodes(count) { success: true, episodes: episodes.map(&:to_h), count: episodes.size } end |
#record_episode(description:, episode_type: :insight, domain: :general, significance: nil, emotional_valence: 0.0, tags: []) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/legion/extensions/agentic/self/narrative_self/runners/narrative_self.rb', line 13 def record_episode(description:, episode_type: :insight, domain: :general, significance: nil, emotional_valence: 0.0, tags: [], **) episode = autobiography.record_episode( description: description, episode_type: episode_type, domain: domain, significance: significance, emotional_valence: emotional_valence, tags: ) log.debug "[narrative_self] recorded episode=#{episode_type} domain=#{domain} sig=#{episode.significance.round(3)}" { success: true, episode: episode.to_h } end |
#self_summary ⇒ Object
59 60 61 62 63 |
# File 'lib/legion/extensions/agentic/self/narrative_self/runners/narrative_self.rb', line 59 def self_summary(**) summary = autobiography.self_summary log.debug "[narrative_self] summary: episodes=#{summary[:total_episodes]} richness=#{summary[:narrative_richness].round(3)}" { success: true, summary: summary } end |
#significant_episodes(min_significance: 0.6) ⇒ Object
32 33 34 35 |
# File 'lib/legion/extensions/agentic/self/narrative_self/runners/narrative_self.rb', line 32 def significant_episodes(min_significance: 0.6, **) episodes = autobiography.significant_episodes(min_significance: min_significance) { success: true, episodes: episodes.map(&:to_h), count: episodes.size } end |
#strongest_threads(count: 5) ⇒ Object
48 49 50 51 |
# File 'lib/legion/extensions/agentic/self/narrative_self/runners/narrative_self.rb', line 48 def strongest_threads(count: 5, **) threads = autobiography.strongest_threads(count) { success: true, threads: threads.map(&:to_h), count: threads.size } end |
#timeline(window: nil) ⇒ Object
53 54 55 56 57 |
# File 'lib/legion/extensions/agentic/self/narrative_self/runners/narrative_self.rb', line 53 def timeline(window: nil, **) w = window || Helpers::Constants::MAX_TIMELINE_WINDOW entries = autobiography.timeline(window: w) { success: true, timeline: entries, count: entries.size } end |
#update_narrative_self ⇒ Object
65 66 67 68 69 |
# File 'lib/legion/extensions/agentic/self/narrative_self/runners/narrative_self.rb', line 65 def update_narrative_self(**) autobiography.decay_all log.debug "[narrative_self] tick: episodes=#{autobiography.episodes.size} threads=#{autobiography.threads.size}" { success: true, episode_count: autobiography.episodes.size, thread_count: autobiography.threads.size } end |