contains_command_chaining

def contains_command_chaining(command: str):
Check if command contains chaining operators that could be used to bypass security.

sanitize_command

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)

is_uv_environment

def is_uv_environment():
Detect whether the current Python runtime is managed by uv.

ensure_uv_available

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)

setup_initial_env_with_uv

def setup_initial_env_with_uv(
    env_path: str,
    uv_path: str,
    working_dir: str,
    update_callback = None
):
Set up initial environment using uv.

setup_initial_env_with_venv

def setup_initial_env_with_venv(env_path: str, working_dir: str, update_callback = None):
Set up initial environment using standard venv.

clone_current_environment

def clone_current_environment(env_path: str, working_dir: str, update_callback = None):
Create a new Python virtual environment, optionally using uv.

check_nodejs_availability

def check_nodejs_availability(update_callback = None):
Check if Node.js is available without modifying the system.