from __future__ import annotations

from dataclasses import dataclass, field
from pathlib import Path
from typing import TYPE_CHECKING, Protocol

if TYPE_CHECKING:
    from cybervisor.logging import CybervisorLogger


class RunningProcess(Protocol):
    pid: int | None
    process_group_id: int | None

    def wait(self) -> tuple[int, str]:
        ...


@dataclass(frozen=True, slots=True)
class AdapterCapabilities:
    supports_hooks: bool = False
    supports_structured_streams: bool = False


@dataclass(frozen=True, slots=True)
class AdapterDescriptor:
    name: str
    display_name: str
    directory: Path
    capabilities: AdapterCapabilities = field(default_factory=AdapterCapabilities)


@dataclass(frozen=True, slots=True)
class LaunchRequest:
    prompt: str
    stage_name: str
    log_file: str
    logger: CybervisorLogger


@dataclass(frozen=True, slots=True)
class PreflightRequirements:
    required_binaries: tuple[str, ...] = ()
    required_environment_variables: tuple[str, ...] = ()

