teff.tool.builtin.shell¶
teff.tool.builtin.shell
¶
Shell tool — run shell commands asynchronously, without a shell.
Commands are tokenized with :func:shlex.split and executed directly via
execve (no /bin/sh involved), so shell metacharacters can never
escalate a permitted first token into arbitrary command execution. Tokens
containing shell metacharacters are rejected outright; &&, ;,
backticks and $(...) are never interpreted by the tool.
Classes:
| Name | Description |
|---|---|
ShellTool |
Run shell commands without a shell. |
ShellTool
¶
Bases: Tool
Run shell commands without a shell.
The command is split into an argument vector and executed via
execve directly — /bin/sh is never involved, so &&, ;,
pipes, backticks and $(...) are inert literal arguments, never
executed. Tokens that still contain shell metacharacters (globs,
redirections, quotes, whitespace) are rejected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root_dir
|
str
|
Working directory for the command. |
'.'
|
allowed_commands
|
list[str] | None
|
If set, only commands whose first token is in this
list are permitted. |
None
|
Source code in teff/tool/builtin/shell.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |