Skip to main content

Module v1

Module v1 

Source
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(())
    })
    .await

Modules§

schema
The protocol v1 message types: requests, responses, notifications and their supporting types, re-exported from the agent-client-protocol-schema crate’s v1 module.

Structs§

ActiveSession
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.
ConnectionTo
A protocol-v1 connection context.
NonBlocking
Marker type indicating the session builder will not block the current task.
SessionBuilder
Stable protocol v1 session builder for a new session request. Allows you to add MCP servers or set other details for this session.
SessionSetup
A stable protocol v1 session and the response of the request that set it up.

Enums§

SessionMessage
An item on a stable protocol v1 session’s update stream, returned by ActiveSession::read_update.

Traits§

SessionBlockState
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() and Proxy.v1().
Dispatch
A message received by a typed handler on a v1 Builder: the Dispatch with v1 request handles.
LoadSessionBuilder
Stable protocol v1 builder for a session/load request, returned by ConnectionTo::load_session and ConnectionTo::load_session_from.
PreparedRequest
A request prepared through a v1 ConnectionTo: the PreparedRequest with a v1 request ID.
Responder
A v1 request’s Responder: id() returns a v1::schema::RequestId.
ResponseRouter
A v1 ResponseRouter: id() returns a v1::schema::RequestId.
ResumeSessionBuilder
Stable protocol v1 builder for a session/resume request, returned by ConnectionTo::resume_session and ConnectionTo::resume_session_from.
SentRequest
A request sent through a v1 ConnectionTo: the SentRequest with a v1 request ID.