Module: Legion::Extensions::Agentic::Self::NarrativeArc::Runners::Narrative
- Includes:
- Helpers::Lex
- Included in:
- Client
- Defined in:
- lib/legion/extensions/agentic/self/narrative_arc/runners/narrative.rb
Instance Method Summary collapse
- #active_arcs(engine: nil) ⇒ Object
- #add_beat(arc_id:, content:, intensity: 0.5, beat_type: :rising_action, domain: :general, emotional_charge: 0.0, engine: nil) ⇒ Object
- #arc_report(engine: nil) ⇒ Object
- #completed_arcs(engine: nil) ⇒ Object
- #create_arc(title:, domain: :general, initial_tension: Helpers::Constants::DEFAULT_TENSION, engine: nil) ⇒ Object
- #get_arc(arc_id:, engine: nil) ⇒ Object
- #most_dramatic_arc(engine: nil) ⇒ Object
Instance Method Details
#active_arcs(engine: nil) ⇒ Object
60 61 62 63 64 65 |
# File 'lib/legion/extensions/agentic/self/narrative_arc/runners/narrative.rb', line 60 def active_arcs(engine: nil, **) eng = engine || arc_engine arcs = eng.active_arcs log.debug "[narrative_arc] active arcs count=#{arcs.size}" { arcs: arcs.map(&:to_h), count: arcs.size } end |
#add_beat(arc_id:, content:, intensity: 0.5, beat_type: :rising_action, domain: :general, emotional_charge: 0.0, engine: nil) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/legion/extensions/agentic/self/narrative_arc/runners/narrative.rb', line 28 def add_beat(arc_id:, content:, intensity: 0.5, beat_type: :rising_action, domain: :general, emotional_charge: 0.0, engine: nil, **) eng = engine || arc_engine result = eng.add_beat( arc_id: arc_id, content: content, intensity: intensity, beat_type: beat_type, domain: domain, emotional_charge: emotional_charge ) if result[:success] arc = eng.get_arc(arc_id) log.debug "[narrative_arc] beat added: arc=#{arc_id[0..7]} type=#{beat_type} " \ "phase=#{result[:arc_phase]} tension=#{result[:tension_level].round(2)}" result[:dramatic_score] = arc.dramatic_score if arc else log.debug "[narrative_arc] add_beat failed: #{result[:reason]} arc=#{arc_id[0..7]}" end result end |
#arc_report(engine: nil) ⇒ Object
83 84 85 86 87 88 |
# File 'lib/legion/extensions/agentic/self/narrative_arc/runners/narrative.rb', line 83 def arc_report(engine: nil, **) eng = engine || arc_engine report = eng.arc_report log.debug "[narrative_arc] arc_report total=#{report[:total_arcs]} patterns=#{report[:patterns].inspect}" { success: true, report: report } end |
#completed_arcs(engine: nil) ⇒ Object
67 68 69 70 71 72 |
# File 'lib/legion/extensions/agentic/self/narrative_arc/runners/narrative.rb', line 67 def completed_arcs(engine: nil, **) eng = engine || arc_engine arcs = eng.completed_arcs log.debug "[narrative_arc] completed arcs count=#{arcs.size}" { arcs: arcs.map(&:to_h), count: arcs.size } end |
#create_arc(title:, domain: :general, initial_tension: Helpers::Constants::DEFAULT_TENSION, engine: nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/legion/extensions/agentic/self/narrative_arc/runners/narrative.rb', line 13 def create_arc(title:, domain: :general, initial_tension: Helpers::Constants::DEFAULT_TENSION, engine: nil, **) eng = engine || arc_engine arc = eng.create_arc(title: title, domain: domain, initial_tension: initial_tension) unless arc log.warn "[narrative_arc] create_arc failed: engine at capacity (#{Helpers::Constants::MAX_ARCS})" return { success: false, reason: :engine_at_capacity } end log.debug "[narrative_arc] arc created: #{arc.arc_id[0..7]} title=#{title} domain=#{domain}" { success: true, arc_id: arc.arc_id, title: arc.title, arc_phase: arc.arc_phase, tension_level: arc.tension_level } end |
#get_arc(arc_id:, engine: nil) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/legion/extensions/agentic/self/narrative_arc/runners/narrative.rb', line 52 def get_arc(arc_id:, engine: nil, **) eng = engine || arc_engine arc = eng.get_arc(arc_id) return { found: false, arc_id: arc_id } unless arc { found: true, arc: arc.to_h, beats: arc.beats.map(&:to_h) } end |
#most_dramatic_arc(engine: nil) ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'lib/legion/extensions/agentic/self/narrative_arc/runners/narrative.rb', line 74 def most_dramatic_arc(engine: nil, **) eng = engine || arc_engine arc = eng.most_dramatic_arc return { found: false } unless arc log.debug "[narrative_arc] most dramatic: #{arc.arc_id[0..7]} score=#{arc.dramatic_score.round(2)}" { found: true, arc: arc.to_h } end |