Class: Brute::Turn::Pipeline

Inherits:
Rack::Builder
  • Object
show all
Includes:
Chainable
Defined in:
lib/brute/turn/pipeline.rb

Direct Known Subclasses

AgentPipeline

Defined Under Namespace

Modules: Chainable Classes: NullSink

Class Method Summary collapse

Methods included from Chainable

#run, #use

Class Method Details

.new_from_string(builder_script, path = "(rackup)", **options) ⇒ Object

Rack's new_from_string evaluates the script then returns to_app — the built callable. An agent, though, is the builder: you .start it, and it may be re-used or served through the Rack adapter. So evaluate the script against a fresh builder and hand back the builder itself. This also backs parse_file (→ load_file → here), so AgentPipeline.parse_file("agent.ru").start(prompt) works as documented.



32
33
34
35
36
# File 'lib/brute/turn/pipeline.rb', line 32

def self.new_from_string(builder_script, path = "(rackup)", **options)
  builder = new(**options)
  eval(builder_script, ::Rack::BUILDER_TOPLEVEL_BINDING.call(builder), path) # rubocop:disable Security/Eval
  builder
end