Class: LittleGhost::Tools::Shell

Inherits:
LittleGhost::Tool show all
Defined in:
lib/little_ghost/tools/shell.rb

Overview

Shell lets an agent run one executable through the configured Sandbox. It accepts an argument vector, so model-supplied values are not interpreted as shell syntax.

The child environment is cleared, runtime is limited to 30 seconds, and each output stream is limited to 1 MB. These defaults reduce accidental exposure but do not create an isolation boundary; the configured sandbox remains responsible for security.

Constant Summary collapse

DEFAULT_TIMEOUT =

:nodoc:

30
MAX_OUTPUT_BYTES =

:nodoc:

1_000_000

Instance Attribute Summary

Attributes inherited from LittleGhost::Tool

#context

Instance Method Summary collapse

Methods inherited from LittleGhost::Tool

#agent, define, description, #description, exclusive, #exclusive?, #execute, #initialize, input_schema, #input_schema, #model, #run, #runtime, #sandbox, specification, #specification, tool_name, #tool_name, #workspace

Methods included from Support::ClassAttributes

#class_attribute, included

Constructor Details

This class inherits a constructor from LittleGhost::Tool

Instance Method Details

#call(input) ⇒ Object

Executes input and returns a JSON result containing standard output, standard error, exit status, and success.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/little_ghost/tools/shell.rb', line 27

def call(input)
  result = sandbox.execute_program(
    input.fetch("command"),
    timeout: DEFAULT_TIMEOUT,
    context:,
    max_output_bytes: MAX_OUTPUT_BYTES,
    environment: {},
    inherit_environment: false
  )
  JSON.generate(
    stdout: result.stdout,
    stderr: result.stderr,
    exit_status: result.exit_code,
    success: result.success?
  )
end