"""Execution-surface value objects.

The surface is where a worker process starts and where its output lands.
It is not a host, a provider, or a role.
"""
from __future__ import annotations

from dataclasses import dataclass
from pathlib import Path


SURFACE_CMUX_PANE = "cmux-pane"
SURFACE_CLI_WRAPPER = "cli-wrapper"


class SurfaceUnavailable(Exception):
    """The surface could not be opened. The application may try the next one."""


class EnvironmentBlocked(Exception):
    """A sandbox hid the surface and the worker CLI config. Do not degrade."""


@dataclass(frozen=True)
class WorkerSpawnRequest:
    command: tuple[str, ...]
    cwd: Path
    title: str
    owned_surface_ids: tuple[str, ...] = ()


@dataclass(frozen=True)
class RuntimeHandle:
    surface: str
    identifier: str
    waitable: bool


@dataclass(frozen=True)
class ProgressEvent:
    message: str
    level: str = "info"
    notify_title: str | None = None
    notify_body: str | None = None
