Module: Legion::Extensions::Agentic::Integration::Tapestry::Runners::CognitiveTapestry

Extended by:
CognitiveTapestry
Includes:
Helpers::Lex
Included in:
Client, CognitiveTapestry
Defined in:
lib/legion/extensions/agentic/integration/tapestry/runners/cognitive_tapestry.rb

Instance Method Summary collapse

Instance Method Details

#create_tapestry(name:, pattern:, capacity: 50, engine: nil) ⇒ Object



29
30
31
32
33
34
35
36
# 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
  { success: true, tapestry: tap.to_h(threads_arr) }
rescue ArgumentError => e
  { success: false, error: e.message }
end

#list_tapestries(engine: nil, pattern: nil, fraying_only: false) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/legion/extensions/agentic/integration/tapestry/runners/cognitive_tapestry.rb', line 46

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.fraying?(threads_arr) }     if fraying_only

  {
    success:    true,
    tapestries: results.map { |tap| tap.to_h(threads_arr) },
    count:      results.size
  }
end

#loom_status(engine: nil) ⇒ Object



61
62
63
64
# File 'lib/legion/extensions/agentic/integration/tapestry/runners/cognitive_tapestry.rb', line 61

def loom_status(engine: nil, **)
  eng = resolve_engine(engine)
  { success: true, report: eng.tapestry_report }
end

#spin_thread(thread_type:, domain:, content:, strength: nil, color: nil, engine: nil) ⇒ Object



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 14

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
  )
  { success: true, thread: t.to_h }
rescue ArgumentError => e
  { success: false, error: e.message }
end

#weave(thread_id:, tapestry_id:, engine: nil) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/legion/extensions/agentic/integration/tapestry/runners/cognitive_tapestry.rb', line 38

def weave(thread_id:, tapestry_id:, engine: nil, **)
  eng = resolve_engine(engine)
  t   = eng.weave(thread_id: thread_id, tapestry_id: tapestry_id)
  { success: true, thread: t.to_h }
rescue ArgumentError => e
  { success: false, error: e.message }
end