pub struct Prelude<'a> { /* private fields */ }Expand description
The events that take a joining client to where a run is.
Built by RunProgress::prelude. Each method adds something to send;
nothing is sent that was not asked for. See the module docs for
the order and for the reasoning behind each choice.
Implementations§
Source§impl Prelude<'_>
impl Prelude<'_>
Sourcepub fn messages(self, messages: impl Into<Vec<Message>>) -> Self
pub fn messages(self, messages: impl Into<Vec<Message>>) -> Self
Carries the conversation as MESSAGES_SNAPSHOT, right after
RUN_STARTED.
messages is everything the thread holds that is complete: the
earlier turns and what this run has finished. It may hold what is
open as well. The snapshot is these messages with what the prelude
restates taken out,
so no list makes a client hold anything twice.
A snapshot is the carrier to prefer. Every client takes it, and it
is right for a client that already holds part of the conversation:
it replaces the messages it carries and drops the ones it leaves out,
where echo_input at most adds.
Sourcepub fn echo_input(self, input: RunAgentInput) -> Self
pub fn echo_input(self, input: RunAgentInput) -> Self
Echoes a request on RUN_STARTED, as
Runner::echo_input does on a
run’s own.
The reference TypeScript client adds the echoed messages whose ids
it does not hold and leaves the ones it holds as they are, so the
echo carries the conversation to such a client when it holds none of
it. This crate’s own client reads the echo for who owns which
message and adds nothing to its conversation.
messages is the carrier for the rest. What the
prelude restates is taken out of input.messages as it is out of a
snapshot.
The echo is the whole request: state, tools, context and forwarded properties as well as the messages.
Sourcepub fn state(self, state: impl Into<Value>) -> Self
pub fn state(self, state: impl Into<Value>) -> Self
Carries the state as STATE_SNAPSHOT, before anything is re-opened.
For a run that publishes state: the STATE_DELTAs that follow patch
the state the client holds, and a client that joins holds none.
Sourcepub fn reopen_only(self) -> Self
pub fn reopen_only(self) -> Self
Re-opens what is open without restating it, and sends no snapshot.
For a client known to hold each open entity exactly as it stands at
this point of the run: see the module
docs. A snapshot
would replace what that client holds, so the messages given to
messages are dropped; calling messages
afterwards goes back to restating.
Sourcepub fn into_events(self) -> Vec<Event>
pub fn into_events(self) -> Vec<Event>
The prelude, in the order to send it.