unstable_protocol_v2 only.Expand description
The SDK API for draft ACP protocol v2.
Start a v2 connection with Client.v2(),
Agent.v2() or Proxy.v2(). The
protocol v2 message types are in v2::schema.
This module uses the same names as crate::v1 for protocol v2’s
connection, builder, request handles and schema. The session APIs differ:
ActiveSession here only sends commands, and the session’s updates and
the agent’s requests arrive through typed handlers on the connection,
while v1::ActiveSession reads them from its own stream. InitializeOutcome
and, with unstable_session_fork, ForkSessionBuilder exist only here.
v1’s LoadSessionBuilder, SessionMessage and blocking states have no v2
counterpart.
Message types are not tied to a protocol version in the type system: a v2
connection accepts any JsonRpcRequest, so
sending a protocol v1 message through it compiles. Send the types from
schema.
The request handles here are the crate-root handles with the V2
protocol marker: id() returns a v2::schema::RequestId.
Requires the unstable_protocol_v2 crate feature.
use agent_client_protocol::schema::ProtocolVersion;
use agent_client_protocol::v2::schema::{Implementation, InitializeRequest};
use agent_client_protocol::v2::{ConnectionTo, InitializeOutcome};
use agent_client_protocol::{Agent, Client, ConnectTo};
Client
.v2()
.connect_with(transport, async |cx: ConnectionTo<Agent>| {
let request = InitializeRequest::new(
ProtocolVersion::V2,
Implementation::new("my-client", "0.1.0"),
);
let InitializeOutcome::Initialized(_response) =
cx.send_initialize(request).block_task().await?
else {
return Err(agent_client_protocol::Error::internal_error());
};
Ok(())
})
.await§Stability
Everything in this module is unstable and may change in a minor release.
Stabilizing protocol v2 only removes the unstable_protocol_v2 gate. See
Stability in the crate docs.
Modules§
- schema
- The protocol v2 message types: requests, responses, notifications and
their supporting types, re-exported from the
agent-client-protocol-schemacrate’sv2module.
Structs§
- Active
Session - Cloneable command handle for a draft protocol v2 session.
- Connection
To - A protocol-v2 connection context.
- Fork
Session Builder unstable_session_fork - Builder for an unstable draft protocol v2
session/forkrequest. - Resume
Session Builder - Builder for a draft protocol v2
session/resumerequest. - Session
Builder - Builder for a draft protocol v2
session/newrequest. - Session
Setup - A protocol v2 session and the response of the request that set it up.
Enums§
- Initialize
Outcome - The outcome of a v2 client’s
send_initialize.
Type Aliases§
- Builder
- A protocol v2 connection builder, returned by
Client.v2(),Agent.v2()andProxy.v2(). - Dispatch
- A message received by a typed handler on a v2
Builder: theDispatchwith v2 request handles. - Prepared
Request - A request prepared through a v2
ConnectionTo: thePreparedRequestwith a v2 request ID. - Responder
- A v2 request’s
Responder:id()returns av2::schema::RequestId. - Response
Router - A v2
ResponseRouter:id()returns av2::schema::RequestId. - Sent
Request - A request sent through a v2
ConnectionTo: theSentRequestwith a v2 request ID.