Agent Client Protocol - v0.1.2
    Preparing search index...

    Class ClientSideConnection

    A client-side connection to an agent.

    This class provides the client's view of an ACP connection, allowing clients (such as code editors) to communicate with agents. It implements the Agent interface to provide methods for initializing sessions, sending prompts, and managing the agent lifecycle.

    See protocol docs: Client

    Implements

    Index

    Constructors

    • Creates a new client-side connection to an agent.

      This establishes the communication channel between a client and agent following the ACP specification.

      Parameters

      • toClient: (agent: Agent) => Client

        A function that creates a Client handler to process incoming agent requests

      • input: WritableStream<Uint8Array<ArrayBufferLike>>

        The stream for sending data to the agent (typically stdout)

      • output: ReadableStream<Uint8Array<ArrayBufferLike>>

        The stream for receiving data from the agent (typically stdin)

        See protocol docs: Communication Model

      Returns ClientSideConnection

    Methods

    • Loads an existing session to resume a previous conversation.

      This method is only available if the agent advertises the loadSession capability.

      The agent should:

      • Restore the session context and conversation history
      • Connect to the specified MCP servers
      • Stream the entire conversation history back to the client via notifications

      See protocol docs: Loading Sessions

      Parameters

      Returns Promise<null>

    • Authenticates the client using the specified authentication method.

      Called when the agent requires authentication before allowing session creation. The client provides the authentication method ID that was advertised during initialization.

      After successful authentication, the client can proceed to create sessions with newSession without receiving an auth_required error.

      See protocol docs: Initialization

      Parameters

      Returns Promise<void>

    • Processes a user prompt within a session.

      This method handles the whole lifecycle of a prompt:

      • Receives user messages with optional context (files, images, etc.)
      • Processes the prompt using language models
      • Reports language model content and tool calls to the Clients
      • Requests permission to run tools
      • Executes any requested tool calls
      • Returns when the turn is complete with a stop reason

      See protocol docs: Prompt Turn

      Parameters

      Returns Promise<PromptResponse>

    • Cancels ongoing operations for a session.

      This is a notification sent by the client to cancel an ongoing prompt turn.

      Upon receiving this notification, the Agent SHOULD:

      • Stop all language model requests as soon as possible
      • Abort all tool call invocations in progress
      • Send any pending session/update notifications
      • Respond to the original session/prompt request with StopReason::Cancelled

      See protocol docs: Cancellation

      Parameters

      Returns Promise<void>