Add typed event payload modules for the streaming service.

This commit is contained in:
CREDO23 2026-05-06 20:08:47 +02:00
parent a9bf7ab7d2
commit 5510c6c314
11 changed files with 571 additions and 0 deletions

View file

@ -0,0 +1,23 @@
"""Single terminal error path the orchestrator must route through."""
from __future__ import annotations
from typing import Any
from ..emitter import Emitter, attach_emitted_by
from ..envelope import format_sse
def format_error(
error_text: str,
*,
error_code: str | None = None,
extra: dict[str, Any] | None = None,
emitter: Emitter | None = None,
) -> str:
payload: dict[str, Any] = {"type": "error", "errorText": error_text}
if error_code:
payload["errorCode"] = error_code
if extra:
payload.update(extra)
return format_sse(attach_emitted_by(payload, emitter))