Skip to main content

RpcClient

Struct RpcClient 

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

Typed RPC client. Cheap to clone.

Implementations§

Source§

impl RpcClient

Source

pub fn connect(transport: Transport) -> Result<Self, ClientError>

Connects over transport.

§Errors

The child could not be spawned.

Source

pub fn from_io<R, W>(reader: R, writer: W) -> Self
where R: AsyncRead + Unpin + Send + 'static, W: AsyncWrite + Unpin + Send + 'static,

A client over an already connected byte stream pair.

Source

pub fn events(&self) -> BoxStream<'static, JsonValue>

Raw wire events (everything that is not a reply to this client), from now on.

Source

pub async fn request( &self, command: RpcCommand, ) -> Result<RpcResponseData, ClientError>

Sends any command and waits for its reply.

§Errors

ClientError::Command with the server’s error text, ClientError::Closed when the server went away.

Source

pub async fn ui_respond(&self, response: &UiResponse) -> Result<(), ClientError>

Answers a dialog.

§Errors

The write failed.

Source

pub async fn close(&self) -> Result<Option<i32>, ClientError>

Closes stdin (orderly server shutdown) and waits for the child to exit.

§Errors

Waiting for the child failed.

Source

pub async fn prompt( &self, message: impl Into<String>, images: Vec<ImageContent>, streaming_behavior: Option<StreamingBehavior>, ) -> Result<PromptDisposition, ClientError>

prompt.

§Errors

Prompt errors.

Source

pub async fn steer( &self, message: impl Into<String>, images: Vec<ImageContent>, ) -> Result<PromptDisposition, ClientError>

steer.

§Errors

Extension commands cannot be queued.

Source

pub async fn follow_up( &self, message: impl Into<String>, images: Vec<ImageContent>, ) -> Result<PromptDisposition, ClientError>

follow_up.

§Errors

Extension commands cannot be queued.

Source

pub async fn abort(&self) -> Result<(), ClientError>

abort.

§Errors

Transport failures.

Source

pub async fn clear_queue(&self) -> Result<ClearedQueues, ClientError>

clear_queue.

§Errors

Transport failures.

Source

pub async fn new_session( &self, parent_session: Option<String>, ) -> Result<bool, ClientError>

new_session; true when an extension cancelled.

§Errors

Session file failures.

Source

pub async fn get_state(&self) -> Result<RpcSessionState, ClientError>

get_state.

§Errors

Transport failures.

Source

pub async fn set_model( &self, provider: impl Into<String>, model_id: impl Into<String>, ) -> Result<Model, ClientError>

set_model.

§Errors

Model not found: …, missing credentials.

Source

pub async fn cycle_model(&self) -> Result<Option<CycleModelResult>, ClientError>

cycle_model.

§Errors

Persisting the selection failed.

Source

pub async fn get_available_models(&self) -> Result<Vec<Model>, ClientError>

get_available_models.

§Errors

Transport failures.

Source

pub async fn set_thinking_level( &self, level: ThinkingLevel, ) -> Result<(), ClientError>

set_thinking_level.

§Errors

Transport failures.

Source

pub async fn cycle_thinking_level( &self, ) -> Result<Option<ThinkingLevel>, ClientError>

cycle_thinking_level.

§Errors

Transport failures.

Source

pub async fn get_available_thinking_levels( &self, ) -> Result<Vec<ThinkingLevel>, ClientError>

get_available_thinking_levels.

§Errors

Transport failures.

Source

pub async fn set_steering_mode( &self, mode: QueueMode, ) -> Result<(), ClientError>

set_steering_mode.

§Errors

Transport failures.

Source

pub async fn set_follow_up_mode( &self, mode: QueueMode, ) -> Result<(), ClientError>

set_follow_up_mode.

§Errors

Transport failures.

Source

pub async fn compact( &self, custom_instructions: Option<String>, ) -> Result<CompactionResult, ClientError>

compact.

§Errors

Compaction errors.

Source

pub async fn set_auto_compaction( &self, enabled: bool, ) -> Result<(), ClientError>

set_auto_compaction.

§Errors

Transport failures.

Source

pub async fn set_auto_retry(&self, enabled: bool) -> Result<(), ClientError>

set_auto_retry.

§Errors

Transport failures.

Source

pub async fn abort_retry(&self) -> Result<(), ClientError>

abort_retry.

§Errors

Transport failures.

Source

pub async fn bash( &self, command: impl Into<String>, exclude_from_context: bool, ) -> Result<BashResult, ClientError>

bash.

§Errors

The command could not run.

Source

pub async fn abort_bash(&self) -> Result<(), ClientError>

abort_bash.

§Errors

Transport failures.

Source

pub async fn get_session_stats(&self) -> Result<SessionStats, ClientError>

get_session_stats.

§Errors

Transport failures.

Source

pub async fn export_html( &self, output_path: Option<String>, ) -> Result<String, ClientError>

export_html; returns the written path.

§Errors

Write failures.

Source

pub async fn switch_session( &self, session_path: impl Into<String>, ) -> Result<bool, ClientError>

switch_session; true when an extension cancelled.

§Errors

The file cannot be opened.

Source

pub async fn fork( &self, entry_id: impl Into<String>, ) -> Result<ForkOutcome, ClientError>

fork.

§Errors

Invalid entry ID for forking.

Source

pub async fn clone_session(&self) -> Result<bool, ClientError>

clone; true when an extension cancelled.

§Errors

Cannot clone session: no current entry selected.

Source

pub async fn get_fork_messages(&self) -> Result<Vec<ForkMessage>, ClientError>

get_fork_messages.

§Errors

Transport failures.

Source

pub async fn get_entries( &self, since: Option<String>, ) -> Result<EntriesOutcome, ClientError>

get_entries.

§Errors

Entry not found: ….

Source

pub async fn get_tree(&self) -> Result<EntriesOutcome, ClientError>

get_tree (nodes as JSON in EntriesOutcome::entries).

§Errors

Transport failures.

Source

pub async fn get_last_assistant_text( &self, ) -> Result<Option<String>, ClientError>

get_last_assistant_text.

§Errors

Transport failures.

Source

pub async fn set_session_name( &self, name: impl Into<String>, ) -> Result<(), ClientError>

set_session_name.

§Errors

Session name cannot be empty.

Source

pub async fn get_messages(&self) -> Result<Vec<AgentMessage>, ClientError>

get_messages.

§Errors

Transport failures.

Source

pub async fn get_commands(&self) -> Result<Vec<SlashCommandInfo>, ClientError>

get_commands.

§Errors

Transport failures.

Trait Implementations§

Source§

impl Clone for RpcClient

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 RpcClient

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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