Expand description
The SDK API for ACP protocol v1.
Start a v1 connection with Client.v1(),
Agent.v1() or Proxy.v1(). The
protocol v1 message types are in v1::schema.
With the unstable_protocol_v2 feature, agent_client_protocol::v2 uses
the same names for protocol v2’s connection, builder, request handles and
schema. The session APIs differ: ActiveSession here reads the
session’s updates from its own stream (read_update and
read_to_string), while v2::ActiveSession only sends commands and the
updates arrive through typed handlers on the connection. LoadSessionBuilder,
SessionMessage and the Blocking / NonBlocking states exist only
here.
Message types are not tied to a protocol version in the type system: a v1
connection accepts any JsonRpcRequest, so
sending a protocol v2 message through it compiles. Send the types from
schema.
The request handles here are the crate-root handles with the V1
protocol marker: id() returns a v1::schema::RequestId.
use agent_client_protocol::schema::ProtocolVersion;
use agent_client_protocol::v1::{ConnectionTo, schema::InitializeRequest};
use agent_client_protocol::{Agent, Client, ConnectTo};
Client
.v1()
.connect_with(transport, async |cx: ConnectionTo<Agent>| {
cx.send_request(InitializeRequest::new(ProtocolVersion::V1))
.block_task()
.await?;
Ok(())
})
.awaitModules§
- schema
- The protocol v1 message types: requests, responses, notifications and
their supporting types, re-exported from the
agent-client-protocol-schemacrate’sv1module.
Structs§
- Active
Session - Stable protocol v1 active session that lets you send prompts and receive updates.
- Blocking
- Marker type indicating the session builder will block the current task.
- Connection
To - A protocol-v1 connection context.
- NonBlocking
- Marker type indicating the session builder will not block the current task.
- Session
Builder - Stable protocol v1 session builder for a new session request. Allows you to add MCP servers or set other details for this session.
- Session
Setup - A stable protocol v1 session and the response of the request that set it up.
Enums§
- Session
Message - An item on a stable protocol v1 session’s update stream, returned by
ActiveSession::read_update.
Traits§
- Session
Block State - Trait for marker types that indicate blocking vs non-blocking API.
See
SessionBuilder::block_task.
Type Aliases§
- Builder
- A protocol v1 connection builder, returned by
Client.v1(),Agent.v1()andProxy.v1(). - Dispatch
- A message received by a typed handler on a v1
Builder: theDispatchwith v1 request handles. - Load
Session Builder - Stable protocol v1 builder for a
session/loadrequest, returned byConnectionTo::load_sessionandConnectionTo::load_session_from. - Prepared
Request - A request prepared through a v1
ConnectionTo: thePreparedRequestwith a v1 request ID. - Responder
- A v1 request’s
Responder:id()returns av1::schema::RequestId. - Response
Router - A v1
ResponseRouter:id()returns av1::schema::RequestId. - Resume
Session Builder - Stable protocol v1 builder for a
session/resumerequest, returned byConnectionTo::resume_sessionandConnectionTo::resume_session_from. - Sent
Request - A request sent through a v1
ConnectionTo: theSentRequestwith a v1 request ID.