Skip to main content

Client

Struct Client 

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

A cloneable client handle. Calls and the single ordered delivery stream share one serialized message stream, regardless of transport.

Implementations§

Source§

impl Client

Source§

impl Client

Source

pub fn connect_stream<T>(transport: T) -> Self
where T: Transport + 'static,

Connect an already-created message stream and start its routing task.

Source

pub fn connect_display_stream<T>(transport: T) -> Self
where T: Transport + 'static,

Connect a display-only consumer without queuing raw tool snapshots, deltas, or gaps. Durable events (including display and terminal results) and replay barriers are unchanged. Runtime output retention is unaffected.

Source

pub fn connect_with_event_sink<T, E>(transport: T, sink: E) -> Self
where T: Transport + 'static, E: ClientEventSink,

Connect a transport and forward ordered protocol deliveries to a consumer-defined sink.

Source

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

Complete the versioned protocol handshake.

Source

pub fn subscribe_deliveries(&self) -> Option<UnboundedReceiver<ClientDelivery>>

Take the sole live, replay, and output delivery receiver. It never backpressures the connection task.

Source

pub fn shutdown(&self)

End the connection and fail outstanding calls with ClientError::Closed.

Source

pub async fn create_session( &self, params: SessionCreateParams, ) -> Result<SessionCreateResult, ClientError>

Source

pub async fn list_sessions( &self, params: SessionListParams, ) -> Result<SessionListResult, ClientError>

Source

pub async fn get_session( &self, params: SessionGetParams, ) -> Result<SessionGetResult, ClientError>

Source

pub async fn get_session_goal( &self, params: SessionGoalGetParams, ) -> Result<SessionGoalGetResult, ClientError>

Source

pub async fn set_session_goal( &self, params: SessionGoalSetParams, ) -> Result<SessionGoalSetResult, ClientError>

Source

pub async fn change_session_goal_lifecycle( &self, params: SessionGoalLifecycleParams, ) -> Result<SessionGoalLifecycleResult, ClientError>

Source

pub async fn session_producers( &self, params: SessionProducersParams, ) -> Result<SessionProducersResult, ClientError>

Source

pub async fn session_usage( &self, params: SessionUsageParams, ) -> Result<SessionUsageResult, ClientError>

Source

pub async fn session_tree_usage( &self, params: SessionUsageParams, ) -> Result<SessionTreeUsageResult, ClientError>

Source

pub async fn agent_usage( &self, params: AgentUsageParams, ) -> Result<AgentUsageResult, ClientError>

Source

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

Source

pub async fn session_children( &self, params: SessionChildrenParams, ) -> Result<SessionChildrenResult, ClientError>

Source

pub async fn session_tree( &self, params: SessionTreeParams, ) -> Result<SessionTreeResult, ClientError>

Source

pub async fn resume_session( &self, params: SessionResumeParams, ) -> Result<SessionResumeResult, ClientError>

Source

pub async fn rename_session( &self, params: SessionRenameParams, ) -> Result<SessionRenameResult, ClientError>

Source

pub async fn set_permission_mode( &self, params: SessionSetPermissionModeParams, ) -> Result<SessionSetPermissionModeResult, ClientError>

Source

pub async fn get_session_permissions( &self, params: SessionPermissionGetParams, ) -> Result<SessionPermissionGetResult, ClientError>

Source

pub async fn set_session_permission( &self, params: SessionPermissionSetParams, ) -> Result<SessionPermissionMutationResult, ClientError>

Source

pub async fn clear_session_permission( &self, params: SessionPermissionClearParams, ) -> Result<SessionPermissionMutationResult, ClientError>

Source

pub async fn list_skills( &self, params: SkillsListParams, ) -> Result<SkillsListResult, ClientError>

Source

pub async fn get_skill( &self, params: SkillsGetParams, ) -> Result<SkillsGetResult, ClientError>

Source

pub async fn compact_session( &self, params: SessionCompactParams, ) -> Result<SessionCompactResult, ClientError>

Source

pub async fn revert_session( &self, params: SessionRevertParams, ) -> Result<SessionRevertResult, ClientError>

Source

pub async fn fork_session( &self, params: SessionForkParams, ) -> Result<SessionForkResult, ClientError>

Source

pub async fn start_run( &self, params: RunStartParams, ) -> Result<RunStartResult, ClientError>

Source

pub async fn steer_run( &self, params: RunSteerParams, ) -> Result<RunSteerResult, ClientError>

Source

pub async fn recall_steer( &self, params: RunRecallSteerParams, ) -> Result<RunRecallSteerResult, ClientError>

Source

pub async fn cancel_run( &self, params: RunCancelParams, ) -> Result<RunCancelResult, ClientError>

Source

pub async fn tool_stdin( &self, params: RunToolStdinParams, ) -> Result<RunToolStdinResult, ClientError>

Source

pub async fn respond_approval( &self, params: ApprovalRespondParams, ) -> Result<ApprovalRespondResult, ClientError>

Source

pub async fn list_approvals( &self, params: ApprovalListParams, ) -> Result<ApprovalListResult, ClientError>

Source

pub async fn begin_mcp_auth( &self, params: McpAuthBeginParams, ) -> Result<McpAuthBeginResult, ClientError>

Source

pub async fn cancel_mcp_auth( &self, params: McpAuthCancelParams, ) -> Result<McpAuthCancelResult, ClientError>

Source

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

Source

pub async fn add_mcp_server( &self, params: McpServerAddParams, ) -> Result<McpServerMutationResult, ClientError>

Source

pub async fn edit_mcp_server( &self, params: McpServerEditParams, ) -> Result<McpServerMutationResult, ClientError>

Source

pub async fn remove_mcp_server( &self, params: McpServerNameParams, ) -> Result<McpServerMutationResult, ClientError>

Source

pub async fn set_mcp_server_enabled( &self, params: McpServerSetEnabledParams, ) -> Result<McpServerMutationResult, ClientError>

Source

pub async fn reconnect_mcp_server( &self, params: McpServerNameParams, ) -> Result<McpServerMutationResult, ClientError>

Source

pub async fn persist_mcp_server( &self, params: McpServerPersistParams, ) -> Result<McpServerMutationResult, ClientError>

Source

pub async fn subscribe_events( &self, session_id: SessionId, cursor: Option<u64>, ) -> Result<(), ClientError>

Start an initial cursor replay. Its contents are delivered only through Client::subscribe_deliveries.

Source

pub fn recover_session(&self, session_id: SessionId, full_replay: bool)

Recover one session. full_replay is used when its local projection is no longer trustworthy.

Source

pub async fn call<P, R>( &self, method: &str, params: &P, ) -> Result<R, ClientError>

Source

pub async fn call_sensitive<P, R>( &self, method: &str, params: P, ) -> Result<R, ClientError>

Send a secret-bearing request from wiping process-owned buffers.

The owned params are dropped immediately after serialization. The serialized JSON is wiped when dispatch completes or is cancelled.

Trait Implementations§

Source§

impl ClientProtocol for Client

Source§

fn handshake<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<ServerHello, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn create_session<'life0, 'async_trait>( &'life0 self, params: SessionCreateParams, ) -> Pin<Box<dyn Future<Output = Result<SessionCreateResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn list_sessions<'life0, 'async_trait>( &'life0 self, params: SessionListParams, ) -> Pin<Box<dyn Future<Output = Result<SessionListResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn get_session<'life0, 'async_trait>( &'life0 self, params: SessionGetParams, ) -> Pin<Box<dyn Future<Output = Result<SessionGetResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn get_session_goal<'life0, 'async_trait>( &'life0 self, params: SessionGoalGetParams, ) -> Pin<Box<dyn Future<Output = Result<SessionGoalGetResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn set_session_goal<'life0, 'async_trait>( &'life0 self, params: SessionGoalSetParams, ) -> Pin<Box<dyn Future<Output = Result<SessionGoalSetResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn change_session_goal_lifecycle<'life0, 'async_trait>( &'life0 self, params: SessionGoalLifecycleParams, ) -> Pin<Box<dyn Future<Output = Result<SessionGoalLifecycleResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn session_producers<'life0, 'async_trait>( &'life0 self, params: SessionProducersParams, ) -> Pin<Box<dyn Future<Output = Result<SessionProducersResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn session_usage<'life0, 'async_trait>( &'life0 self, params: SessionUsageParams, ) -> Pin<Box<dyn Future<Output = Result<SessionUsageResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn session_tree_usage<'life0, 'async_trait>( &'life0 self, params: SessionUsageParams, ) -> Pin<Box<dyn Future<Output = Result<SessionTreeUsageResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn agent_usage<'life0, 'async_trait>( &'life0 self, params: AgentUsageParams, ) -> Pin<Box<dyn Future<Output = Result<AgentUsageResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn global_usage<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<GlobalUsageResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn session_children<'life0, 'async_trait>( &'life0 self, params: SessionChildrenParams, ) -> Pin<Box<dyn Future<Output = Result<SessionChildrenResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn session_tree<'life0, 'async_trait>( &'life0 self, params: SessionTreeParams, ) -> Pin<Box<dyn Future<Output = Result<SessionTreeResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn resume_session<'life0, 'async_trait>( &'life0 self, params: SessionResumeParams, ) -> Pin<Box<dyn Future<Output = Result<SessionResumeResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn rename_session<'life0, 'async_trait>( &'life0 self, params: SessionRenameParams, ) -> Pin<Box<dyn Future<Output = Result<SessionRenameResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn set_permission_mode<'life0, 'async_trait>( &'life0 self, params: SessionSetPermissionModeParams, ) -> Pin<Box<dyn Future<Output = Result<SessionSetPermissionModeResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn get_session_permissions<'life0, 'async_trait>( &'life0 self, params: SessionPermissionGetParams, ) -> Pin<Box<dyn Future<Output = Result<SessionPermissionGetResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn set_session_permission<'life0, 'async_trait>( &'life0 self, params: SessionPermissionSetParams, ) -> Pin<Box<dyn Future<Output = Result<SessionPermissionMutationResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn clear_session_permission<'life0, 'async_trait>( &'life0 self, params: SessionPermissionClearParams, ) -> Pin<Box<dyn Future<Output = Result<SessionPermissionMutationResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn list_skills<'life0, 'async_trait>( &'life0 self, params: SkillsListParams, ) -> Pin<Box<dyn Future<Output = Result<SkillsListResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn get_skill<'life0, 'async_trait>( &'life0 self, params: SkillsGetParams, ) -> Pin<Box<dyn Future<Output = Result<SkillsGetResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn compact_session<'life0, 'async_trait>( &'life0 self, params: SessionCompactParams, ) -> Pin<Box<dyn Future<Output = Result<SessionCompactResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn revert_session<'life0, 'async_trait>( &'life0 self, params: SessionRevertParams, ) -> Pin<Box<dyn Future<Output = Result<SessionRevertResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn fork_session<'life0, 'async_trait>( &'life0 self, params: SessionForkParams, ) -> Pin<Box<dyn Future<Output = Result<SessionForkResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn start_run<'life0, 'async_trait>( &'life0 self, params: RunStartParams, ) -> Pin<Box<dyn Future<Output = Result<RunStartResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn steer_run<'life0, 'async_trait>( &'life0 self, params: RunSteerParams, ) -> Pin<Box<dyn Future<Output = Result<RunSteerResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn recall_steer<'life0, 'async_trait>( &'life0 self, params: RunRecallSteerParams, ) -> Pin<Box<dyn Future<Output = Result<RunRecallSteerResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn cancel_run<'life0, 'async_trait>( &'life0 self, params: RunCancelParams, ) -> Pin<Box<dyn Future<Output = Result<RunCancelResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn tool_stdin<'life0, 'async_trait>( &'life0 self, params: RunToolStdinParams, ) -> Pin<Box<dyn Future<Output = Result<RunToolStdinResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn respond_approval<'life0, 'async_trait>( &'life0 self, params: ApprovalRespondParams, ) -> Pin<Box<dyn Future<Output = Result<ApprovalRespondResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn list_approvals<'life0, 'async_trait>( &'life0 self, params: ApprovalListParams, ) -> Pin<Box<dyn Future<Output = Result<ApprovalListResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn begin_mcp_auth<'life0, 'async_trait>( &'life0 self, params: McpAuthBeginParams, ) -> Pin<Box<dyn Future<Output = Result<McpAuthBeginResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn cancel_mcp_auth<'life0, 'async_trait>( &'life0 self, params: McpAuthCancelParams, ) -> Pin<Box<dyn Future<Output = Result<McpAuthCancelResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn list_mcp_servers<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<McpServerListResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn add_mcp_server<'life0, 'async_trait>( &'life0 self, params: McpServerAddParams, ) -> Pin<Box<dyn Future<Output = Result<McpServerMutationResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn edit_mcp_server<'life0, 'async_trait>( &'life0 self, params: McpServerEditParams, ) -> Pin<Box<dyn Future<Output = Result<McpServerMutationResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn remove_mcp_server<'life0, 'async_trait>( &'life0 self, params: McpServerNameParams, ) -> Pin<Box<dyn Future<Output = Result<McpServerMutationResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn set_mcp_server_enabled<'life0, 'async_trait>( &'life0 self, params: McpServerSetEnabledParams, ) -> Pin<Box<dyn Future<Output = Result<McpServerMutationResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn reconnect_mcp_server<'life0, 'async_trait>( &'life0 self, params: McpServerNameParams, ) -> Pin<Box<dyn Future<Output = Result<McpServerMutationResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn persist_mcp_server<'life0, 'async_trait>( &'life0 self, params: McpServerPersistParams, ) -> Pin<Box<dyn Future<Output = Result<McpServerMutationResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn subscribe_events<'life0, 'async_trait>( &'life0 self, session_id: SessionId, cursor: Option<u64>, ) -> Pin<Box<dyn Future<Output = Result<(), ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn runtime_snapshot<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<RuntimeSnapshotResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn connect_provider<'life0, 'async_trait>( &'life0 self, params: ProviderConnectParams, ) -> Pin<Box<dyn Future<Output = Result<ProviderConnectResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn disconnect_provider<'life0, 'async_trait>( &'life0 self, params: ProviderDisconnectParams, ) -> Pin<Box<dyn Future<Output = Result<ProviderDisconnectResult, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn recover_session(&self, session_id: SessionId, full_replay: bool)

Source§

fn shutdown(&self)

Source§

impl Clone for Client

Source§

fn clone(&self) -> Client

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

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.