org.llm4s.toolapi.builtin.shell

Shell tools for executing system commands.

These tools provide safe shell access with configurable command allowlists and execution limits.

== Configuration ==

All shell tools require explicit command allowlisting via ShellConfig:

  • Allowed commands list (required for any execution)
  • Working directory configuration
  • Timeout limits
  • Output size limits

== Available Tools ==

  • ShellTool: Execute shell commands (requires explicit allowlist)

Attributes

Example
import org.llm4s.toolapi.builtin.shell._
import org.llm4s.toolapi.ToolRegistry
// Read-only shell (ls, cat, etc.)
val readOnlyShell = ShellTool.create(ShellConfig.readOnly())
// Development shell with common dev tools
val devShell = ShellTool.create(ShellConfig.development(
 workingDirectory = Some("/path/to/project")
))
// Custom restricted shell
val customShell = ShellTool.create(ShellConfig(
 allowedCommands = Seq("git", "npm"),
 timeoutMs = 60000
))
val tools = new ToolRegistry(Seq(devShell))

Members list

Type members

Classlikes

case class ShellConfig(allowedCommands: Seq[String], workingDirectory: Option[String], timeoutMs: Long, maxOutputSize: Int, environment: Map[String, String])

Configuration for shell command tool.

Configuration for shell command tool.

Value parameters

allowedCommands

List of allowed command names (e.g., "ls", "cat", "echo"). If empty, no commands are allowed.

environment

Additional environment variables to set.

maxOutputSize

Maximum output size in characters.

timeoutMs

Maximum execution time in milliseconds.

workingDirectory

Optional working directory for command execution.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object ShellConfig

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
case class ShellResult(command: String, exitCode: Int, stdout: String, stderr: String, executionTimeMs: Long, truncated: Boolean, timedOut: Boolean)

Shell command execution result.

Shell command execution result.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object ShellResult

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
object ShellTool

Tool for executing shell commands.

Tool for executing shell commands.

IMPORTANT: This tool requires an explicit allowlist of commands for safety. It will not execute any command that is not in the allowlist.

Features:

  • Command allowlist for security
  • Configurable working directory
  • Timeout support
  • Output size limits

Attributes

Example
{
import org.llm4s.toolapi.builtin.shell._
// Read-only shell (safe commands)
val readOnlyShell = ShellTool.create(ShellConfig.readOnly())
// Development shell (common dev tools)
val devShell = ShellTool.create(ShellConfig.development(
 workingDirectory = Some("/home/user/project")
))
val tools = new ToolRegistry(Seq(devShell))
agent.run("List files in the current directory", tools)

}

Supertypes
class Object
trait Matchable
class Any
Self type
ShellTool.type