pub struct ComponentHandle { /* private fields */ }Expand description
Handle to send requests to the component actor.
Implementations§
Source§impl ComponentHandle
impl ComponentHandle
Sourcepub fn disconnected() -> Self
pub fn disconnected() -> Self
A handle with no actor behind it: every call answers
component actor unavailable.
For host tests that need to construct whatever holds a handle without standing up a component. The request enum is private, so a host cannot build one of these itself.
pub async fn list_tools( &self, metadata: &Metadata, ) -> Result<ListToolsResponse, ComponentError>
Sourcepub async fn call_tool(
&self,
name: &str,
arguments: Vec<u8>,
metadata: Vec<(String, Vec<u8>)>,
consent: Option<ConsentSink>,
) -> Result<CallToolResult, ComponentError>
pub async fn call_tool( &self, name: &str, arguments: Vec<u8>, metadata: Vec<(String, Vec<u8>)>, consent: Option<ConsentSink>, ) -> Result<CallToolResult, ComponentError>
consent is where a capability gate firing during this call sends its
question. None for transports that prompt locally or not at all — see
crate::consent for why the ask travels back to the caller rather
than the gate reaching for a peer itself.
Call a tool, after checking its arguments against the schema the
component published for it (ACT-SPEC.md §6.4).
The check happens here rather than in a transport so that every caller
gets it — act call on the command line as much as an agent over MCP.
A rejection is ComponentError::Tool with kind std:invalid-args, the
same shape the guest would have produced, and the guest is never
reached.
Sourcepub async fn open_session(
&self,
args: Vec<(String, Vec<u8>)>,
metadata: Vec<(String, Vec<u8>)>,
consent: Option<ConsentSink>,
) -> Result<Session, ComponentError>
pub async fn open_session( &self, args: Vec<(String, Vec<u8>)>, metadata: Vec<(String, Vec<u8>)>, consent: Option<ConsentSink>, ) -> Result<Session, ComponentError>
A component that exports no session-provider fails with
ComponentError::Internal — the host could not make the call, as
opposed to the component declining it.
pub async fn close_session( &self, session_id: String, ) -> Result<(), ComponentError>
Sourcepub async fn call_tool_servicing_consent<F, Fut>(
&self,
name: &str,
arguments: Vec<u8>,
metadata: Vec<(String, Vec<u8>)>,
answer: F,
) -> Result<CallToolResult, ComponentError>
pub async fn call_tool_servicing_consent<F, Fut>( &self, name: &str, arguments: Vec<u8>, metadata: Vec<(String, Vec<u8>)>, answer: F, ) -> Result<CallToolResult, ComponentError>
Self::call_tool, with consent questions routed back to answer
instead of denied. Transports with a back-channel to a human use this.
Sourcepub async fn open_session_servicing_consent<F, Fut>(
&self,
args: Vec<(String, Vec<u8>)>,
metadata: Vec<(String, Vec<u8>)>,
answer: F,
) -> Result<Session, ComponentError>
pub async fn open_session_servicing_consent<F, Fut>( &self, args: Vec<(String, Vec<u8>)>, metadata: Vec<(String, Vec<u8>)>, answer: F, ) -> Result<Session, ComponentError>
Self::open_session, with consent questions routed back to answer.
A bridge does its network I/O while opening a session, so this is where
its capability gate usually fires.
Sourcepub async fn open_session_args_schema(
&self,
metadata: Vec<(String, Vec<u8>)>,
) -> Result<String, ComponentError>
pub async fn open_session_args_schema( &self, metadata: Vec<(String, Vec<u8>)>, ) -> Result<String, ComponentError>
Returns a JSON Schema string. A component that exports no
session-provider fails with ComponentError::Internal.
Trait Implementations§
Source§impl Clone for ComponentHandle
impl Clone for ComponentHandle
Source§fn clone(&self) -> ComponentHandle
fn clone(&self) -> ComponentHandle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ComponentHandle
impl RefUnwindSafe for ComponentHandle
impl Send for ComponentHandle
impl Sync for ComponentHandle
impl Unpin for ComponentHandle
impl UnsafeUnpin for ComponentHandle
impl UnwindSafe for ComponentHandle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more