pub struct AgentSession { /* private fields */ }Expand description
Intercepting wrapper around a SessionWriter.
Adds input fan-out, middleware hooks, and state tracking without introducing a second queue (avoids double-queuing).
Implementations§
Source§impl AgentSession
impl AgentSession
Sourcepub fn new(session: SessionHandle) -> Self
pub fn new(session: SessionHandle) -> Self
Create a new AgentSession wrapping a SessionHandle.
Sourcepub fn from_writer(
writer: Arc<dyn SessionWriter>,
event_tx: Sender<SessionEvent>,
) -> Self
pub fn from_writer( writer: Arc<dyn SessionWriter>, event_tx: Sender<SessionEvent>, ) -> Self
Create from a trait-object writer (enables mock testing and middleware injection).
Sourcepub async fn send_audio(&self, data: impl Into<Bytes>) -> Result<(), AgentError>
pub async fn send_audio(&self, data: impl Into<Bytes>) -> Result<(), AgentError>
Send audio data. Fans out to input-streaming tools ONLY if listeners exist.
Sourcepub async fn send_text(&self, text: impl Into<String>) -> Result<(), AgentError>
pub async fn send_text(&self, text: impl Into<String>) -> Result<(), AgentError>
Send a text message.
Sourcepub async fn send_tool_response(
&self,
responses: Vec<FunctionResponse>,
) -> Result<(), AgentError>
pub async fn send_tool_response( &self, responses: Vec<FunctionResponse>, ) -> Result<(), AgentError>
Send tool responses.
Sourcepub async fn send_client_content(
&self,
turns: Vec<Content>,
turn_complete: bool,
) -> Result<(), AgentError>
pub async fn send_client_content( &self, turns: Vec<Content>, turn_complete: bool, ) -> Result<(), AgentError>
Send client content (conversation history or context injection).
Sourcepub async fn send_video(
&self,
jpeg_data: impl Into<Bytes>,
) -> Result<(), AgentError>
pub async fn send_video( &self, jpeg_data: impl Into<Bytes>, ) -> Result<(), AgentError>
Send video/image data (raw JPEG bytes).
Sourcepub async fn update_instruction(
&self,
instruction: impl Into<String>,
) -> Result<(), AgentError>
pub async fn update_instruction( &self, instruction: impl Into<String>, ) -> Result<(), AgentError>
Update the system instruction mid-session.
Sourcepub async fn signal_activity_start(&self) -> Result<(), AgentError>
pub async fn signal_activity_start(&self) -> Result<(), AgentError>
Signal activity start (user started speaking).
Sourcepub async fn signal_activity_end(&self) -> Result<(), AgentError>
pub async fn signal_activity_end(&self) -> Result<(), AgentError>
Signal activity end (user stopped speaking).
Sourcepub async fn disconnect(&self) -> Result<(), AgentError>
pub async fn disconnect(&self) -> Result<(), AgentError>
Gracefully disconnect.
Sourcepub fn subscribe_input(&self) -> Receiver<InputEvent>
pub fn subscribe_input(&self) -> Receiver<InputEvent>
Subscribe to input events (for input-streaming tools).
Sourcepub fn subscribe_events(&self) -> Receiver<SessionEvent>
pub fn subscribe_events(&self) -> Receiver<SessionEvent>
Subscribe to session events.
Sourcepub fn writer(&self) -> &dyn SessionWriter
pub fn writer(&self) -> &dyn SessionWriter
Access the underlying session writer.
Sourcepub fn input_subscriber_count(&self) -> usize
pub fn input_subscriber_count(&self) -> usize
Number of input-streaming subscribers (for diagnostics).
Trait Implementations§
Source§impl Clone for AgentSession
impl Clone for AgentSession
Source§fn clone(&self) -> AgentSession
fn clone(&self) -> AgentSession
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for AgentSession
impl !RefUnwindSafe for AgentSession
impl Send for AgentSession
impl Sync for AgentSession
impl Unpin for AgentSession
impl !UnwindSafe for AgentSession
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].