# Copyright (c) 2026 Krzysztof Rudnicki. MIT licence. """The seam between the bot and Signal. Everything above this interface is transport-agnostic, which is what lets the same bot code run against the real signal-cli-rest-api container and against the local fake used by the tests and the end-to-end script. """ from __future__ import annotations from typing import TYPE_CHECKING, Protocol, runtime_checkable if TYPE_CHECKING: from collections.abc import AsyncIterator from signal_bot.quoting import Quote @runtime_checkable class Transport(Protocol): """What the bot needs from a Signal backend.""" def receive(self) -> AsyncIterator[str]: """Yield raw envelope frames until the transport is closed.""" async def send_text(self, text: str, recipient: str, quote: Quote | None = None) -> None: """Send a plain-text message, optionally quoting one message.""" async def send_image( self, image_base64: str, recipient: str, quote: Quote | None = None ) -> None: """Send a base64-encoded image attachment, optionally quoting one message.""" async def list_attachments(self) -> list[str]: """Return the ids of attachments stored server-side.""" async def delete_attachment(self, attachment_id: str) -> None: """Delete one stored attachment by id."""