From c9434b049a90cc9f458e35190ab99099c9c616b8 Mon Sep 17 00:00:00 2001 From: Paul Swingle Date: Wed, 10 Jan 2024 15:38:13 -0800 Subject: [PATCH] add session stream channel documentation --- mentat/session_stream.py | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/mentat/session_stream.py b/mentat/session_stream.py index 09751d3f9..957633ae9 100644 --- a/mentat/session_stream.py +++ b/mentat/session_stream.py @@ -26,12 +26,30 @@ class StreamMessage: class SessionStream: - """Replaces `cprint` and `print` + """ + Used to send and receive messages from the client. + + Channels and their expected behavior (starred channels are sent by the client): + + default: Any data sent to the client over this channel should be displayed. Valid kwargs: color, style] + + *session_exit: Sent by the client, suggesting that the session should exit whenever possible. + client_exit: Sent by the server directly before shutting down. Client should shut down when received. + + loading: Used to tell the client to display a loading bar. Valid kwargs: progress, terminate + + input_request: Used to request input from the client (data unused). Valid kwargs: plain + *input_request:: Sent by the client. The channel the response to an input_request is sent over. + + edits_complete: A boolean sent when edits have been completed. True if any edits were accepted. + + *completion_request: Sent by the client, asking for autocompletions for the given string. + completion_request:: The response to the given completion request. - Stores message history for a Session and holds an in-memory message bus. + default_prompt: The prefilled prompt to show on next user input request. Should be additive and reset + after every input request. See TerminalClient for exact implementation. - Terminal and extension clients can read these messages and render them accordingly. - For the terminal, they would be rendered with `cprint`. + *interrupt: Sent by the client. Sent whenever client interrupts current work. Equivalent to ctrl-C """ def __init__(self):