import httpx from core_domain import RunBootstrapContract, RunCreateContract class RuntimeServiceClientError(Exception): pass class RuntimeServiceClient: def __init__(self, base_url: str, timeout_seconds: float = 10.0) -> None: self.base_url = base_url.rstrip("/") self.timeout_seconds = timeout_seconds def create_run(self, payload: RunCreateContract) -> RunBootstrapContract: try: with httpx.Client(timeout=self.timeout_seconds) as client: response = client.post( f"{self.base_url}/runtime/runs", json=payload.model_dump(mode="json"), ) response.raise_for_status() return RunBootstrapContract.model_validate(response.json()) except httpx.HTTPError as exc: raise RuntimeServiceClientError(f"runtime-service request failed: {exc}") from exc