pub struct AgentdHttp { /* private fields */ }Expand description
The SDK’s transport, backed by agentd’s authenticated HTTP.
Implementations§
Source§impl AgentdHttp
impl AgentdHttp
pub fn new(http: Arc<HttpTransport>, timeout: Duration) -> AgentdHttp
Trait Implementations§
Source§impl Clone for AgentdHttp
impl Clone for AgentdHttp
Source§fn clone(&self) -> AgentdHttp
fn clone(&self) -> AgentdHttp
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl StreamableHttpClient for AgentdHttp
impl StreamableHttpClient for AgentdHttp
Source§async fn post_message(
&self,
_uri: Arc<str>,
message: ClientJsonRpcMessage,
_session_id: Option<Arc<str>>,
auth_header: Option<String>,
custom_headers: HashMap<HeaderName, HeaderValue>,
) -> Result<StreamableHttpPostResponse, StreamableHttpError<Self::Error>>
async fn post_message( &self, _uri: Arc<str>, message: ClientJsonRpcMessage, _session_id: Option<Arc<str>>, auth_header: Option<String>, custom_headers: HashMap<HeaderName, HeaderValue>, ) -> Result<StreamableHttpPostResponse, StreamableHttpError<Self::Error>>
POST one message.
Everything the server says in reply — whatever it interleaves, then the
response itself — is handed back as a stream, because that is the only
shape that can carry more than one message and the SDK reads it the same
either way. A notification-only POST is answered 202 Accepted by the
server and reported as accepted here.
The stream is live, not a replay. The spec lets a server interleave a REQUEST of its own on the response stream of a POST — an elicitation, a sampling call — and then block until the client answers it (over a separate POST) before finishing the original reply. Collecting the frames and returning them once the reply landed would deadlock exactly that exchange: the server waits for an answer the SDK has not been shown yet, the POST runs to its timeout, and the frames are dropped with the error. So the blocking read runs on its own thread and forwards each frame as it arrives; this returns as soon as the FIRST one does.
Source§async fn delete_session(
&self,
_uri: Arc<str>,
session_id: Arc<str>,
auth_header: Option<String>,
custom_headers: HashMap<HeaderName, HeaderValue>,
) -> Result<(), StreamableHttpError<Self::Error>>
async fn delete_session( &self, _uri: Arc<str>, session_id: Arc<str>, auth_header: Option<String>, custom_headers: HashMap<HeaderName, HeaderValue>, ) -> Result<(), StreamableHttpError<Self::Error>>
End a session. Best-effort by design: a server that has already forgotten the session, or that never had one, is not an error worth failing a shutdown over.
Source§async fn get_stream(
&self,
_uri: Arc<str>,
_session_id: Option<Arc<str>>,
last_event_id: Option<String>,
auth_header: Option<String>,
custom_headers: HashMap<HeaderName, HeaderValue>,
) -> Result<BoxStream<'static, Result<Sse, SseError>>, StreamableHttpError<Self::Error>>
async fn get_stream( &self, _uri: Arc<str>, _session_id: Option<Arc<str>>, last_event_id: Option<String>, auth_header: Option<String>, custom_headers: HashMap<HeaderName, HeaderValue>, ) -> Result<BoxStream<'static, Result<Sse, SseError>>, StreamableHttpError<Self::Error>>
Open the server→client event stream: the channel a server uses to send requests of its own (elicitation, sampling, roots) and unsolicited notifications.