from dataclasses import dataclass from typing import List, Callable, Any @dataclass class SegmentStartEvent: segment_id: str timestamp: float @dataclass class SegmentEndEvent: segment_id: str duration: float timestamp: float @dataclass class ExecutionErrorEvent: segment_id: str error_msg: str timestamp: float class RuntimeEventBus: def __init__(self): self._subscribers: List[Callable] = [] def subscribe(self, callback: Callable): self._subscribers.append(callback) def publish(self, event: Any): for callback in self._subscribers: try: callback(event) except Exception: pass