pub struct Client { /* private fields */ }Expand description
A session: cheap to clone, every method on &self, usable while a
turn’s stream is read (R8.1.2).
Implementations§
Source§impl Client
impl Client
Sourcepub async fn start(options: Options) -> Result<Client, Error>
pub async fn start(options: Options) -> Result<Client, Error>
Starts a session and reads its init.
Sourcepub async fn resume(session_id: &str, options: Options) -> Result<Client, Error>
pub async fn resume(session_id: &str, options: Options) -> Result<Client, Error>
Continues the session session_id (R2.5): the options send only
what a resume may give, and the same tools.
Sourcepub async fn send(&self, prompt: &str) -> Result<TurnStream, Error>
pub async fn send(&self, prompt: &str) -> Result<TurnStream, Error>
Starts a turn with prompt and returns its events, user to
result. One turn at a time: until the wire’s result (whether or
not the stream is read), or an Client::abort that took the
prompt back, another send is TurnInProgress.
Sourcepub async fn steer(&self, text: &str) -> Result<Disposition, Error>
pub async fn steer(&self, text: &str) -> Result<Disposition, Error>
Joins the running turn at its next landing point.
Sourcepub async fn abort(&self) -> Result<Disposition, Error>
pub async fn abort(&self) -> Result<Disposition, Error>
Interrupts the program’s turn, naming its prompt: a running one is
Interrupting; one still queued (behind a compaction) is taken
back, Dequeued, never runs, and its stream ends with no result.
With no turn of the program’s, whatever runs is interrupted.
Sourcepub async fn compact(&self) -> Result<Compaction, Error>
pub async fn compact(&self) -> Result<Compaction, Error>
Compacts the context: at once when idle, after the turn when one
runs. Done carries the compaction its own response names
(data.compacted); every compacted line goes to the running turn’s
stream or Client::session_events.
Sourcepub async fn away(&self, on: bool) -> Result<Disposition, Error>
pub async fn away(&self, on: bool) -> Result<Disposition, Error>
Puts the running or next task away, or ends away.
Sourcepub async fn respond(
&self,
request_id: &str,
decision: Decision,
) -> Result<(), Error>
pub async fn respond( &self, request_id: &str, decision: Decision, ) -> Result<(), Error>
Answers the approval request request_id (R8.3.3).
Sourcepub fn session_events(&self) -> Option<Events>
pub fn session_events(&self) -> Option<Events>
The events that arrive while no turn’s stream is open; the first
call takes the stream, later calls get None. Until it is taken,
those events are dropped.