MCPcopy Index your code
hub / github.com/MiniMax-AI/Mini-Agent / BashTool

Class BashTool

mini_agent/tools/bash_tool.py:217–438  ·  view source on GitHub ↗

Execute shell commands in foreground or background. Automatically detects OS and uses appropriate shell: - Windows: PowerShell - Unix/Linux/macOS: bash

Source from the content-addressed store, hash-verified

215
216
217class BashTool(Tool):
218 """Execute shell commands in foreground or background.
219
220 Automatically detects OS and uses appropriate shell:
221 - Windows: PowerShell
222 - Unix/Linux/macOS: bash
223 """
224
225 def __init__(self, workspace_dir: str | None = None):
226 """Initialize BashTool with OS-specific shell detection.
227
228 Args:
229 workspace_dir: Working directory for command execution.
230 If provided, all commands run in this directory.
231 If None, commands run in the process's cwd.
232 """
233 self.is_windows = platform.system() == "Windows"
234 self.shell_name = "PowerShell" if self.is_windows else "bash"
235 self.workspace_dir = workspace_dir
236
237 @property
238 def name(self) -> str:
239 return "bash"
240
241 @property
242 def description(self) -> str:
243 shell_examples = {
244 "Windows": """Execute PowerShell commands in foreground or background.
245
246For terminal operations like git, npm, docker, etc. DO NOT use for file operations - use specialized tools.
247
248Parameters:
249 - command (required): PowerShell command to execute
250 - timeout (optional): Timeout in seconds (default: 120, max: 600) for foreground commands
251 - run_in_background (optional): Set true for long-running commands (servers, etc.)
252
253Tips:
254 - Quote file paths with spaces: cd "My Documents"
255 - Chain dependent commands with semicolon: git add . ; git commit -m "msg"
256 - Use absolute paths instead of cd when possible
257 - For background commands, monitor with bash_output and terminate with bash_kill
258
259Examples:
260 - git status
261 - npm test
262 - python -m http.server 8080 (with run_in_background=true)""",
263 "Unix": """Execute bash commands in foreground or background.
264
265For terminal operations like git, npm, docker, etc. DO NOT use for file operations - use specialized tools.
266
267Parameters:
268 - command (required): Bash command to execute
269 - timeout (optional): Timeout in seconds (default: 120, max: 600) for foreground commands
270 - run_in_background (optional): Set true for long-running commands (servers, etc.)
271
272Tips:
273 - Quote file paths with spaces: cd "My Documents"
274 - Chain dependent commands with &&: git add . && git commit -m "msg"

Callers 15

add_workspace_toolsFunction · 0.90
test_bash_toolFunction · 0.90
test_agent_simple_taskFunction · 0.90
test_agent_bash_taskFunction · 0.90
test_foreground_commandFunction · 0.90
test_command_failureFunction · 0.90
test_command_timeoutFunction · 0.90
test_background_commandFunction · 0.90
test_bash_killFunction · 0.90

Calls

no outgoing calls

Tested by 14

test_bash_toolFunction · 0.72
test_agent_simple_taskFunction · 0.72
test_agent_bash_taskFunction · 0.72
test_foreground_commandFunction · 0.72
test_command_failureFunction · 0.72
test_command_timeoutFunction · 0.72
test_background_commandFunction · 0.72
test_bash_killFunction · 0.72