Skip to main content

V2ResumeSessionBuilder

Struct V2ResumeSessionBuilder 

Source
pub struct V2ResumeSessionBuilder<Counterpart, Run = NullRun>
where Counterpart: HasPeer<Agent>, Run: RunWithConnectionTo<Counterpart>,
{ /* private fields */ }
Available on crate feature unstable_protocol_v2 only.
Expand description

Builder for a draft protocol v2 session/resume request.

Replay updates arrive before the resume response. Direct clients must register typed v2::UpdateSessionNotification and interactive request handlers on crate::Builder before connecting. Proxies should use Self::on_proxy_session_start, which makes downstream session routing ready before publishing the resume request.

With both the unstable_protocol_v2 and unstable_mcp_over_acp features, with_mcp_server attaches an MCP server to the resumed session and makes it ready before the agent can send replay or its response.

Implementations§

Source§

impl<Counterpart, Run> V2ResumeSessionBuilder<Counterpart, Run>
where Counterpart: HasPeer<Agent>, Run: RunWithConnectionTo<Counterpart>,

Source

pub fn with_mcp_server<McpRun>( self, mcp_server: McpServer<Counterpart, McpRun>, ) -> Result<V2ResumeSessionBuilder<Counterpart, ChainRun<Run, McpRun>>, Error>
where McpRun: RunWithConnectionTo<Counterpart>,

Available on crate feature unstable_mcp_over_acp only.

Attach an MCP server to this resumed protocol v2 session.

This method is available when both unstable_protocol_v2 and unstable_mcp_over_acp are enabled. MCP routes are installed and their runner tasks receive an initial poll before session/resume is published, allowing the agent to use the server during replay and session setup. A successful attachment remains active for the lifetime of the connection.

Source

pub fn start_session( self, ) -> SentRequest<OpenedV2Session<Counterpart, ResumeSessionResponse>>
where Run: 'static,

Send session/resume and return its independently consumable request.

The successful result contains both a cloneable command handle and the complete v2::ResumeSessionResponse. Consume the returned request with SentRequest::block_task, SentRequest::on_receiving_result, or another explicit SentRequest completion mode.

Replay is delivered through the typed connection handlers before the response. Attached MCP routes and runner tasks are ready before the request is published. A valid success response promotes them to the connection lifetime independently from how this request handle is consumed; setup errors clean up the pending attachment.

Source

pub fn on_proxy_session_start<F, Fut>( self, responder: Responder<ResumeSessionResponse>, op: F, ) -> Result<(), Error>
where Counterpart: HasPeer<Client>, Run: 'static, F: FnOnce(OpenedV2Session<Counterpart, ResumeSessionResponse>) -> Fut + Send + 'static, Fut: Future<Output = Result<(), Error>> + Send,

Resume a protocol v2 session through a proxy and forward its response.

The session ID is known before the request, so this helper installs and acknowledges downstream session routing before publishing the ordered session/resume request. Replay can therefore be forwarded before the response as required by the protocol. The downstream request inherits cancellation from the upstream request.

On success, the helper forwards the complete response and spawns op with an OpenedV2Session containing the command-only session handle plus that response. The callback runs outside the ordered response barrier, so it may wait for later connection traffic without deadlocking the dispatch loop.

Trait Implementations§

Source§

impl<Counterpart, Run> Debug for V2ResumeSessionBuilder<Counterpart, Run>
where Counterpart: HasPeer<Agent> + Debug, Run: RunWithConnectionTo<Counterpart> + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Counterpart, Run = NullRun> !RefUnwindSafe for V2ResumeSessionBuilder<Counterpart, Run>

§

impl<Counterpart, Run = NullRun> !UnwindSafe for V2ResumeSessionBuilder<Counterpart, Run>

§

impl<Counterpart, Run> Freeze for V2ResumeSessionBuilder<Counterpart, Run>
where V2ConnectionTo<Counterpart>: Freeze, Vec<DynamicHandlerGuard<Counterpart>>: Freeze, Run: Freeze,

§

impl<Counterpart, Run> Send for V2ResumeSessionBuilder<Counterpart, Run>
where V2ConnectionTo<Counterpart>: Send, Vec<DynamicHandlerGuard<Counterpart>>: Send,

§

impl<Counterpart, Run> Sync for V2ResumeSessionBuilder<Counterpart, Run>
where V2ConnectionTo<Counterpart>: Sync, Vec<DynamicHandlerGuard<Counterpart>>: Sync, Run: Sync,

§

impl<Counterpart, Run> Unpin for V2ResumeSessionBuilder<Counterpart, Run>
where V2ConnectionTo<Counterpart>: Unpin, Vec<DynamicHandlerGuard<Counterpart>>: Unpin, Run: Unpin,

§

impl<Counterpart, Run> UnsafeUnpin for V2ResumeSessionBuilder<Counterpart, Run>
where V2ConnectionTo<Counterpart>: UnsafeUnpin, Vec<DynamicHandlerGuard<Counterpart>>: UnsafeUnpin, Run: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoMaybeUndefined<T> for T

Source§

fn into_maybe_undefined(self) -> MaybeUndefined<T>

Converts this value into a three-state builder argument.
Source§

impl<T> IntoOption<T> for T

Source§

fn into_option(self) -> Option<T>

Converts this value into an optional builder argument.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more