from __future__ import annotations
from typing import Protocol, runtime_checkable
from zempy.zosapi.tools.enums.run_status import RunStatus

class RunResult(tuple):
    """Lightweight (status, message) tuple-like result for tool runs."""
    __slots__ = ()
    status: RunStatus
    message: str | None

    def __new__(cls, status: RunStatus, message: str | None = None):
        return tuple.__new__(cls, (status, message))

    @property
    def ok(self) -> bool:
        return getattr(self, "status", None) == getattr(RunStatus, "COMPLETED", None)

@runtime_checkable
class ISystemTool(Protocol):
    """Python-facing contract matching ZOSAPI.Tools.ISystemTool core behavior."""
    def run(self) -> bool: ...
    def run_and_wait_for_completion(self) -> bool: ...
    def wait_for_completion(self) -> bool: ...
    def cancel(self) -> bool: ...
    def close(self) -> bool: ...
    def wait_with_timeout(self, timeout_s: float) -> RunStatus: ...
    def run_and_wait_with_timeout(self, timeout_s: float) -> RunStatus: ...
    @property
    def progress(self) -> int: ...
    @property
    def status(self) -> str: ...
    @property
    def is_running(self) -> bool: ...
    @property
    def can_cancel(self) -> bool: ...
    @property
    def is_asynchronous(self) -> bool: ...
    @property
    def is_finite_duration(self) -> bool: ...
    @property
    def is_valid(self) -> bool: ...
    @property
    def succeeded(self) -> bool: ...
    @property
    def error_message(self) -> str | None: ...
