Skip to main content

AppServerHandle

Struct AppServerHandle 

Source
pub struct AppServerHandle { /* private fields */ }
Expand description

A cloneable handle for sending to the server.

It can send requests and answer the server’s, but not read events: that stays with the AppServer, so a task can steer or interrupt a turn while another reads its notifications. Every method fails once the session has ended.

Implementations§

Source§

impl AppServerHandle

Source

pub async fn request(&self, method: &str, params: Value) -> Result<Value>

Send a request and wait for its answer, returning the result value.

Requests may run concurrently; each answer is matched by id. A JSON-RPC error from the server is Error::AppServerRpc. The client’s timeout, when set, bounds the wait and yields Error::Timeout. Pass Value::Null for no parameters.

§Errors

Fails if the server rejects the request, the wait times out, or the session ends first.

Source

pub fn notify(&self, method: &str, params: Value) -> Result<()>

Send a notification, which has no answer. Returns once it is queued for writing.

§Errors

Fails if the session has ended.

Source

pub fn respond(&self, id: RequestId, result: Value) -> Result<()>

Answer a ServerRequest with a result. Returns once it is queued for writing.

§Errors

Fails if the session has ended.

Source

pub fn respond_error( &self, id: RequestId, code: i64, message: impl Into<String>, ) -> Result<()>

Answer a ServerRequest with a JSON-RPC error. Use it for a request the caller does not handle, so the turn that raised it is not left waiting. Returns once it is queued for writing.

§Errors

Fails if the session has ended.

Source

pub async fn thread_start(&self, params: ThreadStartParams) -> Result<Thread>

Start a thread (thread/start).

§Errors

As request, and a protocol error if the response has no thread id.

Source

pub async fn turn_start(&self, params: TurnStartParams) -> Result<Turn>

Start a turn (turn/start). The turn runs in the background: watch for its turn/completed notification.

§Errors

As request, and a protocol error if the response has no turn.

Source

pub async fn turn_steer( &self, thread_id: &str, expected_turn_id: &str, input: Vec<UserInput>, ) -> Result<String>

Add input to a running turn (turn/steer) and return the id of the turn it landed on.

The server delivers it to the model at the next item boundary, so a long tool call delays it. expected_turn_id must be the active turn. With no active turn the server fails the request with no active turn to steer, and with a different one with expected active turn id ...; both are Error::AppServerRpc.

§Errors

As request.

Source

pub async fn turn_interrupt(&self, thread_id: &str, turn_id: &str) -> Result<()>

Stop a running turn (turn/interrupt). The turn then ends with a turn/completed notification whose status is TurnStatus::Interrupted.

With no active turn the server fails the request with no active turn to interrupt, and with a different one with expected active turn id ...; both are Error::AppServerRpc.

§Errors

As request.

Trait Implementations§

Source§

impl Clone for AppServerHandle

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AppServerHandle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more