Class: Brute::Middleware::Base

Inherits:
Object
  • Object
show all
Includes:
Hooks
Defined in:
lib/brute/middleware/000_base.rb

Overview

The parent of every middleware: it takes the next app, does its work around it, and calls it.

class Shout < Brute::Middleware::Base
def call(env)
  emit(ENTER_EVENT, env, self)
  @app.call(env)
end
end

Brute::Hooks is included, so the event names are first class in every subclass — ENTER_EVENT, not Brute::Hooks::ENTER_EVENT.

Constant Summary

Constants included from Hooks

Hooks::AFTER_LLM_EVENT, Hooks::AFTER_TOOL_EVENT, Hooks::APPROVE_TOOL_EVENT, Hooks::BEFORE_LLM_EVENT, Hooks::BEFORE_TOOL_EVENT, Hooks::COMPACTED_EVENT, Hooks::COMPACT_DURATION_EVENT, Hooks::DURATION_EVENT, Hooks::ENTER_EVENT, Hooks::EXIT_EVENT, Hooks::FARADAY_ERROR_EVENT, Hooks::LLM_DURATION_EVENT, Hooks::LLM_FAILURE_EVENT, Hooks::MIDDLEWARE_ADDED_EVENT, Hooks::OPEN_ROUTER_SERVER_ERROR_EVENT, Hooks::STANDARD_ERROR_EVENT, Hooks::TOOL_DURATION_EVENT, Hooks::TURN_DURATION_EVENT, Hooks::TURN_END_EVENT, Hooks::TURN_START_EVENT

Instance Method Summary collapse

Methods included from Hooks

new

Constructor Details

#initialize(app) ⇒ Base

Returns a new instance of Base.



24
25
26
# File 'lib/brute/middleware/000_base.rb', line 24

def initialize(app, *, **)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object

A layer that adds nothing passes the turn straight through.



29
# File 'lib/brute/middleware/000_base.rb', line 29

def call(env) = @app.call(env)