TerminalToolkit
- timeout (Optional[float]): The timeout for terminal operations. (default: :obj:
20.0
) - shell_sessions (Optional[Dict[str, Any]]): A dictionary to store shell session information. If :obj:
None
, an empty dictionary will be used. (default: :obj:None
) - working_directory (Optional[str]): The working directory for operations. If not provided, it will be determined by the
CAMEL_WORKDIR
environment variable (if set). If the environment variable is not set, it defaults to./workspace
. All execution and write operations will be restricted to this directory. Read operations can access paths outside this directory. (default: :obj:None
) - need_terminal (bool): Whether to create a terminal interface. (default: :obj:
True
) - use_shell_mode (bool): Whether to use shell mode for command execution. (default: :obj:
True
) - clone_current_env (bool): Whether to clone the current Python environment. (default: :obj:
False
) - safe_mode (bool): Whether to enable safe mode to restrict operations. (default: :obj:
True
) - interactive (bool): Whether to use interactive mode for shell commands, connecting them to the terminal’s standard input. This is useful for commands that require user input, like
ssh
. Interactive mode is only supported on macOS and Linux. (default: :obj:False
) - log_dir (Optional[str]): Custom directory path for log files. If None, logs are saved to the current working directory. (default: :obj:
None
)
init
_setup_file_output
_clone_current_environment
_is_uv_environment
_ensure_uv_available
_prepare_initial_environment
_setup_initial_env_with_uv
_setup_initial_env_with_venv
_check_nodejs_availability
_create_terminal
_update_terminal_output
- output (str): The output to be sent to the agent
_is_path_within_working_dir
- path (str): The path to check
_enforce_working_dir_for_execution
- path (str): The path to be used for executing operations
_copy_external_file_to_workdir
- external_file (str): The path of the external file
_sanitize_command
- command (str): The command to check
- exec_dir (str): The directory to execute the command in
shell_exec
- id (str): A unique identifier for the shell session. This is used to manage multiple concurrent shell processes.
- command (str): The shell command to be executed.
shell_view
- id (str): The unique identifier of the shell session to view.
shell_wait
- id (str): The unique identifier of the target shell session.
- seconds (Optional[int], optional): The maximum time to wait, in seconds. If
None
, it waits indefinitely. (default: :obj:None
)
shell_write_to_process
- id (str): The unique identifier of the target shell session.
- input (str): The text to write to the process’s stdin.
- press_enter (bool): If
True
, a newline character (\n
) is appended to the input, simulating pressing the Enter key.
shell_kill_process
- id (str): The unique identifier of the shell session containing the process to be terminated.
ask_user_for_help
- id (str): The identifier of the shell session for the human to interact with. If the session does not exist, it will be created.