Module: Legion::Extensions::Agentic::Integration::Tapestry::Runners::CognitiveTapestry
- Includes:
- Helpers::Lex
- Included in:
- Client
- Defined in:
- lib/legion/extensions/agentic/integration/tapestry/runners/cognitive_tapestry.rb
Instance Method Summary collapse
- #create_tapestry(name:, pattern:, capacity: 50, engine: nil) ⇒ Object
- #list_tapestries(engine: nil, pattern: nil, fraying_only: false) ⇒ Object
- #loom_status(engine: nil) ⇒ Object
- #spin_thread(thread_type:, domain:, content:, strength: nil, color: nil, engine: nil) ⇒ Object
- #weave(thread_id:, tapestry_id:, engine: nil) ⇒ Object
Instance Method Details
#create_tapestry(name:, pattern:, capacity: 50, engine: nil) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/legion/extensions/agentic/integration/tapestry/runners/cognitive_tapestry.rb', line 29 def create_tapestry(name:, pattern:, capacity: 50, engine: nil, **) eng = resolve_engine(engine) tap = eng.create_tapestry(name: name, pattern: pattern, capacity: capacity) threads_arr = eng.all_threads log.debug("[cognitive_tapestry] create_tapestry: name=#{name} pattern=#{pattern}") { success: true, tapestry: tap.to_h(threads_arr) } rescue ArgumentError => e { success: false, error: e. } end |
#list_tapestries(engine: nil, pattern: nil, fraying_only: false) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/legion/extensions/agentic/integration/tapestry/runners/cognitive_tapestry.rb', line 48 def list_tapestries(engine: nil, pattern: nil, fraying_only: false, **) eng = resolve_engine(engine) threads_arr = eng.all_threads results = eng.all_tapestries results = results.select { |tap| tap.pattern == pattern.to_sym } if pattern results = results.select { |tap| tap.(threads_arr) } if log.debug("[cognitive_tapestry] list_tapestries: count=#{results.size}") { success: true, tapestries: results.map { |tap| tap.to_h(threads_arr) }, count: results.size } end |
#loom_status(engine: nil) ⇒ Object
64 65 66 67 68 |
# File 'lib/legion/extensions/agentic/integration/tapestry/runners/cognitive_tapestry.rb', line 64 def loom_status(engine: nil, **) eng = resolve_engine(engine) log.debug('[cognitive_tapestry] loom_status') { success: true, report: eng.tapestry_report } end |
#spin_thread(thread_type:, domain:, content:, strength: nil, color: nil, engine: nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/legion/extensions/agentic/integration/tapestry/runners/cognitive_tapestry.rb', line 13 def spin_thread(thread_type:, domain:, content:, strength: nil, color: nil, engine: nil, **) eng = resolve_engine(engine) t = eng.spin_thread( thread_type: thread_type, domain: domain, content: content, strength: strength, color: color ) log.debug("[cognitive_tapestry] spin_thread: type=#{thread_type} domain=#{domain}") { success: true, thread: t.to_h } rescue ArgumentError => e { success: false, error: e. } end |
#weave(thread_id:, tapestry_id:, engine: nil) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/legion/extensions/agentic/integration/tapestry/runners/cognitive_tapestry.rb', line 39 def weave(thread_id:, tapestry_id:, engine: nil, **) eng = resolve_engine(engine) eng.weave(thread_id: thread_id, tapestry_id: tapestry_id) log.debug("[cognitive_tapestry] weave: thread_id=#{thread_id[0..7]} tapestry_id=#{tapestry_id[0..7]}") { success: true } rescue ArgumentError => e { success: false, error: e. } end |