Module: Brute
- Defined in:
- lib/brute.rb,
lib/brute/tool.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/message_transport.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/message_transport/llm.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/message_transport/openai.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/message_transport/ruby_llm.rb,
lib/brute/middleware/002_session_log.rb,
lib/brute/message_transport/anthropic.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: Message, MessageTransport, SystemPrompt, Tool, ToolCall
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.1"
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 and no LLM library.
- .provider=(p) ⇒ Object
-
.tools(tools) ⇒ Object
Adapt any Brute tools (hashes, Brute::Tool, Brute::Turn::ToolPipeline, SubAgent …) into a { name_sym => Brute::Tools::Adapter } hash.
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
56 57 58 |
# File 'lib/brute.rb', line 56 def self.agent(&block) Brute::Turn::AgentPipeline.new(&block) end |
.log(*messages) ⇒ Object
65 66 67 |
# File 'lib/brute/messages.rb', line 65 def self.log(*) [].extend(Messages).tap { |log| .flatten.each { |m| log << m } } end |
.provider ⇒ Object
NOTE: Brute owns no LLM configuration and no LLM library. All
provider/model/credential config lives in the pipeline's terminal run
proc, which the user writes with whatever LLM library they prefer
(ruby_llm, llm.rb, openai, anthropic, raw HTTP, ...). The proc converts
env (Brute::Message values — see Brute.log) to the library's
format, makes the call, and appends the response back as Brute::Message
values — the MessageTransport pattern. See examples/ruby_llm.rb,
examples/llm.rb, examples/openai.rb and examples/anthropic.rb.
33 34 35 |
# File 'lib/brute.rb', line 33 def self.provider @provider ||= :anthropic end |
.provider=(p) ⇒ Object
69 70 71 |
# File 'lib/brute.rb', line 69 def self.provider=(p) @provider = p.to_sym end |
.tools(tools) ⇒ Object
Adapt any Brute tools (hashes, Brute::Tool, Brute::Turn::ToolPipeline,
SubAgent …) into a { name_sym => Brute::Tools::Adapter } hash. Each
adapter exposes #to_h — a neutral JSON-Schema-ish definition the inline
run proc converts to whatever its LLM library expects.
64 65 66 |
# File 'lib/brute.rb', line 64 def self.tools(tools) Brute::Tools::Adapter.wrap_all(tools || []) end |