Class: BruteCLI::Providers::ShellResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/brute_cli/providers/shell_response.rb

Overview

Synthetic completion response returned by Brute::Providers::Shell.

When command is present, the response contains a single assistant message with a "shell" tool call. The agent loop picks it up and executes Brute::Tools::Shell through the normal pipeline.

When command is nil (tool results round-trip), the response contains an empty assistant message with no tool calls, causing the agent loop to exit.

Instance Method Summary collapse

Constructor Details

#initialize(command: nil, model: "bash", tools: []) ⇒ ShellResponse

Returns a new instance of ShellResponse.



21
22
23
24
25
# File 'lib/brute_cli/providers/shell_response.rb', line 21

def initialize(command: nil, model: "bash", tools: [])
  @command    = command
  @model_name = model
  @tools      = tools || []
end

Instance Method Details

#contentObject



69
70
71
72
# File 'lib/brute_cli/providers/shell_response.rb', line 69

def content
  msg = messages.find { |m| m.role == :assistant }
  msg&.content
end

#content!Object



74
75
76
# File 'lib/brute_cli/providers/shell_response.rb', line 74

def content!
  JSON.parse(content)
end

#input_tokensObject



53
54
55
# File 'lib/brute_cli/providers/shell_response.rb', line 53

def input_tokens
  0
end

#messagesObject Also known as: choices



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/brute_cli/providers/shell_response.rb', line 27

def messages
  if @command.nil?
    [empty_assistant]
  else
    call_id = "shell_#{SecureRandom.hex(8)}"
    tool_calls = [
      Brute::ToolCall.new(
        id:        call_id,
        name:      "shell",
        arguments: { "command" => @command },
      )
    ]
    [Brute::Message.new(
      role:       :assistant,
      content:    "",
      tool_calls: tool_calls,
    )
  ]
  end
end

#modelObject



49
50
51
# File 'lib/brute_cli/providers/shell_response.rb', line 49

def model
  @model_name
end

#output_tokensObject



57
58
59
# File 'lib/brute_cli/providers/shell_response.rb', line 57

def output_tokens
  0
end

#reasoning_contentObject



78
79
80
# File 'lib/brute_cli/providers/shell_response.rb', line 78

def reasoning_content
  nil
end

#reasoning_tokensObject



61
62
63
# File 'lib/brute_cli/providers/shell_response.rb', line 61

def reasoning_tokens
  0
end

#total_tokensObject



65
66
67
# File 'lib/brute_cli/providers/shell_response.rb', line 65

def total_tokens
  0
end

#usageObject



82
83
84
# File 'lib/brute_cli/providers/shell_response.rb', line 82

def usage
  { input: 0, output: 0, reasoning: 0 }
end