Class: LLM::Tool::Shell

Inherits:
LLM::Tool show all
Defined in:
lib/llm/tools/shell.rb

Overview

The Shell class implements a tool that can spawn a command. That can be dangerous given a low-quality model, or a high-quality model that simply makes a bad decision. The risk can be reduced through a confirmation step such as LLM::Agent.confirm, or by managing the tool loop manually through LLM::Context.

Instance Method Summary collapse

Methods inherited from LLM::Tool

a2a, a2a?, #a2a?, clear_registry!, description, find_by_name!, function, #function, inherited, mcp, mcp?, #mcp?, name, #on_cancel, #on_interrupt, params, register, registry, skill?, #skill?, unregister

Methods included from Param

#param, #required

Methods included from Function::Registry

#clear_registry!, extended, #find_by_name, #lock, #register, #registry, #registry_key, #tool_name, #unregister

Instance Method Details

#call(name:, arguments: nil) ⇒ Hash

Parameters:

  • name (String)

    The name of a command

  • arguments (Array<String>) (defaults to: nil)

    One or more command-line arguments

Returns:

  • (Hash)


27
28
29
30
# File 'lib/llm/tools/shell.rb', line 27

def call(name:, arguments: nil)
  command = spawn(name:, arguments:)
  {ok: command.success?, stdout: command.stdout, stderr: command.stderr}
end