ReferenceAPI referenceagentspartyparticipants

Cli

Interactive human seam over a console: the person reads and types.

One menu per choice: every message class on offer, its intent when stated, and a prompt for the label (or its number) followed by the payload when the message carries one.

Functions

func__init__(self, console=None) -> None

Create an interactive seam over console (defaults to stdio).

› Source code
def __init__(self, console: Console | None = None) -> None:
    """Create an interactive seam over *console* (defaults to stdio).

    Args:
        console: The console to prompt on; ``StreamConsole`` when omitted.
    """
    self._console: Console = StreamConsole() if console is None else console
paramconsoleConsole | None
= None

The console to prompt on; StreamConsole when omitted.

Returns

None
funcchoose(self, offer) -> Message

Prompt the person for a message among offer's classes.

› Source code
async def choose(self, offer: Offer) -> Message:
    """Prompt the person for a message among *offer*'s classes.

    Args:
        offer: What the person may send, and to whom.

    Returns:
        The message the person chose, decoded to its declared class.
    """
    self._console.show(_cli_menu(offer))
    while True:
        chosen, error = await self._attempt_or_error(offer)
        if chosen is not None:
            return chosen
        self._console.show(f'error: {error}')
paramofferOffer

What the person may send, and to whom.

Returns

agentsparty.message.Message

The message the person chose, decoded to its declared class.

funcnotify(self, subject, envelope) -> None

Print envelope to the console.

› Source code
async def notify(self, subject: Role, envelope: Envelope) -> None:
    """Print *envelope* to the console.

    Args:
        subject: The human's own role.
        envelope: The protocol message being delivered.
    """
    self._console.show(str(envelope))
paramsubjectRole

The human's own role.

paramenvelopeEnvelope

The protocol message being delivered.

Returns

None
funcrecall(self, subject, envelope) -> None

Print a message this person sent in an earlier process.

› Source code
async def recall(self, subject: Role, envelope: Envelope) -> None:
    """Print a message this person sent in an earlier process.

    Args:
        subject: The human's own role.
        envelope: The protocol message they sent earlier.
    """
    self._console.show(str(envelope))
paramsubjectRole

The human's own role.

paramenvelopeEnvelope

The protocol message they sent earlier.

Returns

None
funccancel(self, subject, reason) -> None

Print that the session ended, and why.

› Source code
async def cancel(self, subject: Role, reason: str) -> None:
    """Print that the session ended, and why.

    Args:
        subject: The human's own role.
        reason: Why the session was rolled up.
    """
    self._console.show(f'[{subject.name}] session ended: {reason}')
paramsubjectRole

The human's own role.

paramreasonstr

Why the session was rolled up.

Returns

None

On this page