Skip to content
This repository has been archived by the owner on Jan 7, 2025. It is now read-only.

add session stream channel documentation #468

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions mentat/session_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:<message_id>: 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:<message_id>: 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):
Expand Down