pub struct ClaudeAgentClient { /* private fields */ }Implementations§
Source§impl ClaudeAgentClient
impl ClaudeAgentClient
Sourcepub fn spawn_stream_message(
options: ClaudeAgentOptions,
content: impl Into<UserMessageInput>,
) -> UnboundedReceiver<StreamEvent>
pub fn spawn_stream_message( options: ClaudeAgentOptions, content: impl Into<UserMessageInput>, ) -> UnboundedReceiver<StreamEvent>
Fire-and-forget streaming for a single prompt.
Spawns a background task that creates a fresh client from options,
connects, and streams content, forwarding each StreamEvent to the
returned receiver. Unlike Self::stream_message, this returns
immediately and the spawned task owns the client for the lifetime of the
stream, so the caller only needs to hold the receiver. Connection or
streaming failures are surfaced as a final StreamEvent::Error.
Accepts any UserMessageInput: a plain String/&str for text-only
prompts, or a Vec<InputContentBlock> to deliver text plus images.
Must be called from within a Tokio runtime.
Sourcepub fn spawn_stream_message_supervised(
options: ClaudeAgentOptions,
content: impl Into<UserMessageInput>,
) -> SpawnedStream
pub fn spawn_stream_message_supervised( options: ClaudeAgentOptions, content: impl Into<UserMessageInput>, ) -> SpawnedStream
Starts a single-prompt stream with a handle that can await deterministic subprocess cleanup after the consumer drops the event receiver.
Sourcepub async fn run_client_stream(
client: Self,
content: UserMessageInput,
tx: UnboundedSender<StreamEvent>,
) -> Result<()>
pub async fn run_client_stream( client: Self, content: UserMessageInput, tx: UnboundedSender<StreamEvent>, ) -> Result<()>
Runs a prompt against an already constructed client and guarantees the transport is closed before returning. Advanced hosts can use this to retain explicit ownership of spawned-stream shutdown.
pub fn new(options: ClaudeAgentOptions) -> Result<Self>
pub fn with_transport( options: ClaudeAgentOptions, transport: Box<dyn Transport>, ) -> Result<Self>
pub async fn connect(&mut self) -> Result<()>
pub async fn connect_with_prompt( &mut self, content: impl Into<UserMessageInput>, ) -> Result<()>
pub async fn connect_with_stream<S>(&mut self, stream: S) -> Result<()>
pub async fn send_message( &mut self, content: impl Into<UserMessageInput>, ) -> Result<MessageResponse>
pub async fn query( &mut self, content: impl Into<UserMessageInput>, ) -> Result<()>
pub async fn query_with_session_id( &mut self, content: impl Into<UserMessageInput>, session_id: impl Into<String>, ) -> Result<()>
pub async fn query_stream<S>(&mut self, stream: S) -> Result<()>
pub async fn query_stream_with_session_id<S>( &mut self, stream: S, session_id: impl Into<String>, ) -> Result<()>
pub async fn receive_response(&mut self) -> Result<Vec<Message>>
pub async fn receive_messages(&mut self) -> Result<Vec<Message>>
pub async fn stream_message( &mut self, content: impl Into<UserMessageInput>, ) -> Result<UnboundedReceiver<StreamEvent>>
pub async fn get_conversation_history(&self) -> Result<Vec<Message>>
pub async fn abort(&mut self) -> Result<()>
pub async fn disconnect(&mut self) -> Result<()>
pub async fn close(self) -> Result<()>
pub async fn interrupt(&mut self) -> Result<()>
pub async fn set_permission_mode(&mut self, mode: PermissionMode) -> Result<()>
pub async fn set_model(&mut self, model: Option<String>) -> Result<()>
pub async fn rewind_files( &mut self, user_message_id: impl Into<String>, ) -> Result<()>
pub async fn reconnect_mcp_server( &mut self, server_name: impl Into<String>, ) -> Result<()>
pub async fn toggle_mcp_server( &mut self, server_name: impl Into<String>, enabled: bool, ) -> Result<()>
pub async fn stop_task(&mut self, task_id: impl Into<String>) -> Result<()>
pub async fn get_mcp_status(&mut self) -> Result<MCPStatusResponse>
pub async fn get_context_usage(&mut self) -> Result<ContextUsageResponse>
pub fn get_server_info(&self) -> Option<&Map<String, Value>>
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for ClaudeAgentClient
impl !UnwindSafe for ClaudeAgentClient
impl Freeze for ClaudeAgentClient
impl Send for ClaudeAgentClient
impl Sync for ClaudeAgentClient
impl Unpin for ClaudeAgentClient
impl UnsafeUnpin for ClaudeAgentClient
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
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