> ## Documentation Index
> Fetch the complete documentation index at: https://docs.camel-ai.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Camel.toolkits.terminal toolkit.utils

<a id="camel.toolkits.terminal_toolkit.utils" />

<a id="camel.toolkits.terminal_toolkit.utils.check_command_safety" />

## check\_command\_safety

```python theme={"system"}
def check_command_safety(command: str, allowed_commands: Optional[Set[str]] = None):
```

Check if a command (potentially with chaining) is safe to execute.

**Parameters:**

* **command** (str): The command string to check
* **allowed\_commands** (Optional\[Set\[str]]): Set of allowed commands (whitelist mode)

**Returns:**

Tuple\[bool, str]: (is\_safe, reason)

<a id="camel.toolkits.terminal_toolkit.utils.sanitize_command" />

## sanitize\_command

```python theme={"system"}
def sanitize_command(
    command: str,
    use_docker_backend: bool = False,
    safe_mode: bool = True,
    working_dir: Optional[str] = None,
    allowed_commands: Optional[Set[str]] = None
):
```

A comprehensive command sanitizer for both local and Docker backends.

**Parameters:**

* **command** (str): The command to sanitize
* **use\_docker\_backend** (bool): Whether using Docker backend
* **safe\_mode** (bool): Whether to apply security checks
* **working\_dir** (Optional\[str]): Working directory for path validation
* **allowed\_commands** (Optional\[Set\[str]]): Set of allowed commands

**Returns:**

Tuple\[bool, str]: (is\_safe, message\_or\_command)

<a id="camel.toolkits.terminal_toolkit.utils.is_uv_environment" />

## is\_uv\_environment

```python theme={"system"}
def is_uv_environment():
```

Detect whether the current Python runtime is managed by uv.

<a id="camel.toolkits.terminal_toolkit.utils.ensure_uv_available" />

## ensure\_uv\_available

```python theme={"system"}
def ensure_uv_available(update_callback = None):
```

Ensure uv is available, installing it if necessary.

**Parameters:**

* **update\_callback**: Optional callback function to receive status updates

**Returns:**

Tuple\[bool, Optional\[str]]: (success, uv\_path)

<a id="camel.toolkits.terminal_toolkit.utils.setup_initial_env_with_uv" />

## setup\_initial\_env\_with\_uv

```python theme={"system"}
def setup_initial_env_with_uv(
    env_path: str,
    uv_path: str,
    working_dir: str,
    update_callback = None
):
```

Set up initial environment using uv.

<a id="camel.toolkits.terminal_toolkit.utils.setup_initial_env_with_venv" />

## setup\_initial\_env\_with\_venv

```python theme={"system"}
def setup_initial_env_with_venv(env_path: str, working_dir: str, update_callback = None):
```

Set up initial environment using standard venv.

<a id="camel.toolkits.terminal_toolkit.utils.clone_current_environment" />

## clone\_current\_environment

```python theme={"system"}
def clone_current_environment(env_path: str, working_dir: str, update_callback = None):
```

Clone the current Python environment to a new virtual environment.

This function creates a new virtual environment with the same Python
version as the current environment and installs all packages from
the current environment.

**Parameters:**

* **env\_path**: Path where the new environment will be created.
* **working\_dir**: Working directory for subprocess commands.
* **update\_callback**: Optional callback for status updates.

**Returns:**

True if the environment was created successfully, False otherwise.

<a id="camel.toolkits.terminal_toolkit.utils.check_nodejs_availability" />

## check\_nodejs\_availability

```python theme={"system"}
def check_nodejs_availability(update_callback = None):
```

Check if Node.js is available without modifying the system.
