JrCxExt

Trait JrCxExt 

Source
pub trait JrCxExt {
    // Required methods
    fn send_request_to_successor<Req: JrRequest>(
        &self,
        request: Req,
    ) -> JrResponse<Req::Response>;
    fn send_notification_to_successor<Req: JrNotification>(
        &self,
        notification: Req,
    ) -> Result<(), Error>;
}
Expand description

Extension trait for JrConnectionCx that adds methods for sending to successor.

This trait provides convenient methods for proxies to forward messages downstream to their successor component (next proxy or agent). Messages are automatically wrapped in the _proxy/successor/send/* protocol format.

§Example

// Example using ACP request types
use sacp::proxy::JrCxExt;
use agent_client_protocol_schema_schema::agent::PromptRequest;

async fn forward_prompt(cx: &JsonRpcCx, prompt: PromptRequest) {
    let response = cx.send_request_to_successor(prompt).recv().await?;
    // response is the typed response from the successor
}

Required Methods§

Source

fn send_request_to_successor<Req: JrRequest>( &self, request: Req, ) -> JrResponse<Req::Response>

Send a request to the successor component.

The request is automatically wrapped in a ToSuccessorRequest and sent using the _proxy/successor/send/request method. The orchestrator routes it to the next component in the chain.

§Returns

Returns a JrResponse that can be awaited to get the successor’s response.

§Example
use sacp::proxy::JrCxExt;
use agent_client_protocol_schema_schema::agent::PromptRequest;

let prompt = PromptRequest { /* ... */ };
let response = cx.send_request_to_successor(prompt).recv().await?;
// response is the typed PromptResponse
Source

fn send_notification_to_successor<Req: JrNotification>( &self, notification: Req, ) -> Result<(), Error>

Send a notification to the successor component.

The notification is automatically wrapped in a ToSuccessorNotification and sent using the _proxy/successor/send/notification method. The orchestrator routes it to the next component in the chain.

Notifications are fire-and-forget - no response is expected.

§Errors

Returns an error if the notification fails to send.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl JrCxExt for JrConnectionCx

Source§

fn send_request_to_successor<Req: JrRequest>( &self, request: Req, ) -> JrResponse<Req::Response>

Source§

fn send_notification_to_successor<Req: JrNotification>( &self, notification: Req, ) -> Result<(), Error>

Implementors§