starsnatched commited on
Commit
aee9883
·
1 Parent(s): 81b1292

Refactor execute_terminal function to set a fixed timeout and improve command validation

Browse files
Files changed (1) hide show
  1. src/tools.py +6 -2
src/tools.py CHANGED
@@ -17,15 +17,19 @@ def set_vm(vm: LinuxVM | None) -> None:
17
  _VM = vm
18
 
19
 
20
- def execute_terminal(command: str, *, timeout: int = 3) -> str:
21
  """
22
  Execute a shell command in a Linux terminal.
23
  Use this tool to run various commands.
24
 
25
  The command is executed with network access enabled. Output from both
26
  ``stdout`` and ``stderr`` is captured and returned. Commands are killed if
27
- they exceed ``timeout`` seconds.
28
  """
 
 
 
 
29
  if _VM:
30
  try:
31
  return _VM.execute(command, timeout=timeout)
 
17
  _VM = vm
18
 
19
 
20
+ def execute_terminal(command: str) -> str:
21
  """
22
  Execute a shell command in a Linux terminal.
23
  Use this tool to run various commands.
24
 
25
  The command is executed with network access enabled. Output from both
26
  ``stdout`` and ``stderr`` is captured and returned. Commands are killed if
27
+ they exceed 2 seconds.
28
  """
29
+ timeout = 2
30
+ if not command:
31
+ return "No command provided."
32
+
33
  if _VM:
34
  try:
35
  return _VM.execute(command, timeout=timeout)