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
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 Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- class
- Supertypes
-
trait Producttrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
ShellConfig.type
Shell command execution result.
Shell command execution result.
Attributes
- Companion
- object
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- class
- Supertypes
-
trait Producttrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
ShellResult.type
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 Objecttrait Matchableclass Any
- Self type
-
ShellTool.type