Execute a command in the system shell. Use this function when there is a need to run a system command, and execute programs. Args: command: The command to execute in the system shell. Returns: A string representation of the exit code and output of the command.
(command: str, context_variables)
| 312 | @register_tool("execute_command") |
| 313 | @process_terminal_response |
| 314 | def execute_command(command: str, context_variables) -> str: |
| 315 | """ |
| 316 | Execute a command in the system shell. Use this function when there is a need to run a system command, and execute programs. |
| 317 | Args: |
| 318 | command: The command to execute in the system shell. |
| 319 | Returns: |
| 320 | A string representation of the exit code and output of the command. |
| 321 | """ |
| 322 | env: Union[DockerEnv, LocalEnv] = context_variables.get("code_env", LocalEnv()) |
| 323 | try: |
| 324 | response = env.run_command(command, print_stream) |
| 325 | return response |
| 326 | except Exception as e: |
| 327 | return f"[ERROR] Error running command: {str(e)}" |
| 328 | |
| 329 | def print_stream(text): |
| 330 | console = Console() |
nothing calls this directly
no test coverage detected