class Shell
A pseudo-LLM provider that executes user input as code via the existing Brute::Tools::Shell tool.
Models correspond to interpreters:
bash - pass-through (default) ruby - ruby -e '...' python - python3 -c '...' nix - nix eval --expr '...'
The provider's #complete method returns a synthetic response containing a single "shell" tool call. The agent loop executes it through the normal pipeline — all middleware (message tracking, session persistence, token tracking, etc.) fires as usual.
Nested
Definitions
def models
For the REPL model picker: provider.models.all.select(&:chat?)
Implementation
def models
ModelList.new(MODELS)
end
def extract_text(prompt)
Extract the user's text from the messages array. Returns nil when the messages contain tool results (the second round-trip) so #complete knows to return an empty response.
Implementation
def extract_text(prompt)
case prompt
when String
prompt
when ::Array
return nil if prompt.any? { |m| m.respond_to?(:role) && m.role == :tool }
user_msg = prompt.reverse_each.find { |m| m.respond_to?(:role) && m.role == :user }
user_msg&.content.to_s
else
prompt.to_s
end
end