Module: Brute
- Defined in:
- lib/brute.rb,
lib/brute/skill.rb,
lib/brute/tools.rb,
lib/brute/prompts.rb,
lib/brute/version.rb,
lib/brute/messages.rb,
lib/brute/truncation.rb,
lib/brute/utils/diff.rb,
lib/brute/tools/shell.rb,
lib/brute/prompts/base.rb,
lib/brute/rack/adapter.rb,
lib/brute/system_prompt.rb,
lib/brute/tools/adapter.rb,
lib/brute/tools/fs_read.rb,
lib/brute/tools/fs_undo.rb,
lib/brute/turn/pipeline.rb,
lib/brute/events/handler.rb,
lib/brute/prompts/skills.rb,
lib/brute/tools/fs_patch.rb,
lib/brute/tools/fs_write.rb,
lib/brute/tools/question.rb,
lib/brute/tools/fs_remove.rb,
lib/brute/tools/fs_search.rb,
lib/brute/tools/net_fetch.rb,
lib/brute/tools/sub_agent.rb,
lib/brute/tools/todo_read.rb,
lib/brute/prompts/autonomy.rb,
lib/brute/prompts/identity.rb,
lib/brute/tools/skill_load.rb,
lib/brute/tools/todo_write.rb,
lib/brute/prompts/max_steps.rb,
lib/brute/prompts/code_style.rb,
lib/brute/prompts/git_safety.rb,
lib/brute/prompts/tool_usage.rb,
lib/brute/turn/tool_pipeline.rb,
lib/brute/middleware/006_loop.rb,
lib/brute/prompts/conventions.rb,
lib/brute/prompts/doing_tasks.rb,
lib/brute/prompts/environment.rb,
lib/brute/prompts/objectivity.rb,
lib/brute/turn/agent_pipeline.rb,
lib/brute/prompts/build_switch.rb,
lib/brute/prompts/instructions.rb,
lib/brute/middleware/user_queue.rb,
lib/brute/prompts/plan_reminder.rb,
lib/brute/prompts/proactiveness.rb,
lib/brute/tools/todo_list/store.rb,
lib/brute/middleware/005_tracing.rb,
lib/brute/prompts/frontend_tasks.rb,
lib/brute/prompts/tone_and_style.rb,
lib/brute/prompts/code_references.rb,
lib/brute/prompts/task_management.rb,
lib/brute/tools/fs/snapshot_store.rb,
lib/brute/middleware/001_otel_span.rb,
lib/brute/middleware/004_summarize.rb,
lib/brute/middleware/060_questions.rb,
lib/brute/middleware/event_handler.rb,
lib/brute/prompts/editing_approach.rb,
lib/brute/middleware/002_session_log.rb,
lib/brute/prompts/editing_constraints.rb,
lib/brute/prompts/security_and_safety.rb,
lib/brute/middleware/020_system_prompt.rb,
lib/brute/middleware/070_tool_pipeline.rb,
lib/brute/tools/fs/file_mutation_queue.rb,
lib/brute/middleware/010_max_iterations.rb,
lib/brute/middleware/073_otel_tool_call.rb,
lib/brute/events/terminal_output_handler.rb,
lib/brute/events/prefixed_terminal_output.rb,
lib/brute/middleware/015_otel_token_usage.rb,
lib/brute/middleware/040_compaction_check.rb,
lib/brute/middleware/075_otel_tool_results.rb
Defined Under Namespace
Modules: Diff, Events, Messages, Middleware, Prompts, Rack, Skill, Tools, Truncation, Turn Classes: SystemPrompt
Constant Summary collapse
- LOGO =
<<-LOGO .o8 . "888 .o8 888oooo. oooo d8b oooo oooo .o888oo .ooooo. d88' `88b `888""8P `888 `888 888 d88' `88b 888 888 888 888 888 888 888ooo888 888 888 888 888 888 888 . 888 .o `Y8bod8P' d888b `V88V"V8P' "888" `Y8bod8P' LOGO
- VERSION =
"3.0.0"
Class Method Summary collapse
-
.agent(&block) ⇒ Object
Start building an agent turn.
-
.log(*messages) ⇒ Object
Build a fresh conversation log (an Array + Messages sugar), optionally seeded with messages.
-
.provider ⇒ Object
NOTE: Brute owns no LLM configuration.
- .provider=(p) ⇒ Object
-
.rubyllm_tools(tools) ⇒ Object
Adapt any Brute tools (hashes, Brute::Turn::ToolPipeline, SubAgent, RubyLLM::Tool …) into a { name_sym => RubyLLM::Tool } hash — the shape an inline
runproc hands to RubyLLM.chat.with_tools or a provider #complete call.
Class Method Details
.agent(&block) ⇒ Object
Start building an agent turn. Returns an AgentPipeline — a rack-style
builder that is also the runnable Agent: chain .use for middleware and
.run for the terminal LLM-call proc (both return the AgentPipeline), then
invoke it with #start. It takes no config — LLM config lives in the run
proc, tools go to the ToolPipeline middleware, the log to SessionLog.
agent = Brute.agent
.use(Brute::Middleware::SystemPrompt)
.use(Brute::Middleware::ToolPipeline, tools: Brute::Tools::ALL)
.run ->(env) { ... } # the LLM-call proc (provider/model/creds here)
agent.start("what changed?")
A block form is equivalent (evaluated in the AgentPipeline's context):
Brute.agent do
use Brute::Middleware::SystemPrompt
run ->(env) { ... }
end
59 60 61 |
# File 'lib/brute.rb', line 59 def self.agent(&block) Brute::Turn::AgentPipeline.new(&block) end |
.log(*messages) ⇒ Object
23 24 25 |
# File 'lib/brute/messages.rb', line 23 def self.log(*) [].extend(Messages).tap { |log| .flatten.each { |m| log << m } } end |
.provider ⇒ Object
NOTE: Brute owns no LLM configuration. Calling an LLM is just
RubyLLM.chat.ask "...", and all provider/model/credential config lives
in the pipeline's terminal run proc — typically via RubyLLM.context:
run ->(env) do
context = RubyLLM.context { |c| c.ollama_api_base = ENV["OLLAMA_API_BASE"] }
...
end
See examples/agents/01_basic_agent.rb.
36 37 38 |
# File 'lib/brute.rb', line 36 def self.provider @provider ||= :anthropic end |
.provider=(p) ⇒ Object
70 71 72 |
# File 'lib/brute.rb', line 70 def self.provider=(p) @provider = p.to_sym end |
.rubyllm_tools(tools) ⇒ Object
Adapt any Brute tools (hashes, Brute::Turn::ToolPipeline, SubAgent, RubyLLM::Tool …)
into a { name_sym => RubyLLM::Tool } hash — the shape an inline run
proc hands to RubyLLM.chat.with_tools or a provider #complete call.
66 67 68 |
# File 'lib/brute.rb', line 66 def self.rubyllm_tools(tools) Brute::Tools::Adapter.wrap_all(tools || []).transform_values(&:to_ruby_llm) end |