pub struct Proxy;Expand description
The proxy role - an intermediary that can intercept and modify messages.
Proxies sit between a client and an agent (or another proxy), and can:
- Add tools via MCP servers
- Filter or transform messages
- Inject additional context
Proxies connect to a Conductor which orchestrates the proxy chain.
Implementations§
Source§impl Proxy
impl Proxy
Sourcepub fn v1(self) -> Builder<Proxy>
pub fn v1(self) -> Builder<Proxy>
Create a stable protocol v1 connection builder for a proxy.
The proxy negotiates proxy/initialize the way a v1 agent negotiates
initialize: it selects v1 for every requested version. A request for
a newer version keeps what parses under v1, and one below v1 keeps
v1’s fallback-to-latest rule.
Use Proxy::v2 for a protocol-v2-only proxy with typed callbacks and
wire validation. Protocol-routing infrastructure that deliberately
selects a version itself can use the unguarded
Builder::new(Proxy).
Typed handlers on this builder receive V1 request
handles.
Sourcepub fn v2(self) -> Builder<Proxy>
Available on crate feature unstable_protocol_v2 only.
pub fn v2(self) -> Builder<Proxy>
unstable_protocol_v2 only.Create a proxy builder that uses the ACP protocol v2 API.
The proxy negotiates proxy/initialize the way a v2 agent negotiates
initialize: it selects v2 for a request for v2 or newer, keeping what
parses under v2 for a newer request, and rejects a request below v2
with -32022.
Fluent callbacks receive v2::ConnectionTo<Conductor>, while
low-level custom handlers and runners retain the protocol-neutral
ConnectionTo interface.
Requires the unstable_protocol_v2 crate feature.
Sourcepub fn protocol_router(self) -> ProxyProtocolRouter
Available on crate feature unstable_protocol_v2 only.
pub fn protocol_router(self) -> ProxyProtocolRouter
unstable_protocol_v2 only.Create a router that chooses between configured proxy implementations.
Add implementations with ProxyProtocolRouter::with_v1 and
ProxyProtocolRouter::with_v2. The router reads the initial
proxy/initialize request and selects an implementation exactly as
Agent::protocol_router does for initialize: a request for v2 or
newer selects the v2 implementation, keeping what parses under v2 for
a newer request. With a v1 implementation configured, everything else
is handed to the v1 implementation, which negotiates it as it would
without the router. A v2-only router rejects a request below v2 with
-32022. Like the agent router, it answers each rejected request or
malformed frame with an error and keeps reading, so the conductor can
send proxy/initialize again. A request for exactly the selected
version is handed over in the complete, unchanged initial transport
frame. The router does not convert later messages.
Requires the unstable_protocol_v2 crate feature while protocol v2
stabilizes.
Trait Implementations§
impl Copy for Proxy
impl Eq for Proxy
Source§impl HasPeer<Proxy> for Proxy
impl HasPeer<Proxy> for Proxy
Source§fn remote_style(&self, _peer: Proxy) -> RemoteStyle
fn remote_style(&self, _peer: Proxy) -> RemoteStyle
Source§impl Ord for Proxy
impl Ord for Proxy
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Proxy
impl PartialOrd for Proxy
Source§impl Role for Proxy
impl Role for Proxy
Source§type Counterpart = Conductor
type Counterpart = Conductor
Source§fn default_handle_dispatch_from(
&self,
message: Dispatch,
_connection: ConnectionTo<Self>,
) -> impl Future<Output = Result<Handled<Dispatch>, Error>> + Send
fn default_handle_dispatch_from( &self, message: Dispatch, _connection: ConnectionTo<Self>, ) -> impl Future<Output = Result<Handled<Dispatch>, Error>> + Send
Source§fn counterpart(&self) -> Self::Counterpart
fn counterpart(&self) -> Self::Counterpart
impl StructuralPartialEq for Proxy
Auto Trait Implementations§
impl Freeze for Proxy
impl RefUnwindSafe for Proxy
impl Send for Proxy
impl Sync for Proxy
impl Unpin for Proxy
impl UnsafeUnpin for Proxy
impl UnwindSafe for Proxy
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,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.