"""Single place to recognise router sentinels. ``route_message()`` normally returns text to post back to the user. Two special values are protocol instead of a reply, and every adapter must catch them before sending anything: - ``__AUDIO__:`` — a TTS result; the payload is a WAV path to attach. - ``__STEERED__`` — the message was injected into an in-flight turn; the adapter should react (not reply) and post nothing. Zero dependencies on adapters or router — importable standalone. """ from __future__ import annotations AUDIO_PREFIX = "__AUDIO__:" STEERED = "__STEERED__" def audio_path(response: str | None) -> str | None: """Return the WAV path if `response` is an audio sentinel, else None.""" if response and response.startswith(AUDIO_PREFIX): return response[len(AUDIO_PREFIX):] return None def is_steered(response: str | None) -> bool: """True if `response` is the steering-acknowledgement sentinel.""" return response == STEERED if __name__ == "__main__": assert audio_path("__AUDIO__:/tmp/x.wav") == "/tmp/x.wav" assert audio_path("hello") is None assert audio_path("") is None assert audio_path(None) is None assert is_steered("__STEERED__") is True assert is_steered("__STEERED__ ") is False assert is_steered("") is False assert is_steered(None) is False print("ok")