Agent Client Protocol - v1.2.1
    Preparing search index...

    Class AgentSideConnection

    An agent-side connection to a client.

    This class provides the agent's view of an ACP connection, allowing agents to communicate with clients. It implements the Client interface to provide methods for requesting permissions, accessing the file system, and sending session updates.

    See protocol docs: Agent

    Prefer agent, which registers typed handlers with a single context object and supports direct app composition.

    Index
    • get signal(): AbortSignal

      AbortSignal that aborts when the connection closes.

      This signal can be used to:

      • Listen for connection closure: connection.signal.addEventListener('abort', () => {...})
      • Check connection status synchronously: if (connection.signal.aborted) {...}
      • Pass to other APIs (fetch, setTimeout) for automatic cancellation

      The connection closes when the underlying stream ends, either normally or due to an error.

      Returns AbortSignal

      const connection = new AgentSideConnection(agent, stream);

      // Listen for closure
      connection.signal.addEventListener('abort', () => {
      console.log('Connection closed - performing cleanup');
      });

      // Check status
      if (connection.signal.aborted) {
      console.log('Connection is already closed');
      }

      // Pass to other APIs
      fetch(url, { signal: connection.signal });
    • get closed(): Promise<void>

      Promise that resolves when the connection closes.

      The connection closes when the underlying stream ends, either normally or due to an error. Once closed, the connection cannot send or receive any more messages.

      This is useful for async/await style cleanup:

      Returns Promise<void>

      const connection = new AgentSideConnection(agent, stream);
      await connection.closed;
      console.log('Connection closed - performing cleanup');
    • Handles session update notifications from the agent.

      This is a notification endpoint (no response expected) that sends real-time updates about session progress, including message chunks, tool calls, and execution plans.

      Note: Clients SHOULD continue accepting tool call updates even after sending a session/cancel notification, as the agent may send final updates before responding with the cancelled stop reason.

      See protocol docs: Agent Reports Output

      Parameters

      Returns Promise<void>

    • Executes a command in a new terminal.

      Returns a TerminalHandle that can be used to get output, wait for exit, kill the command, or release the terminal.

      The terminal can also be embedded in tool calls by using its ID in ToolCallContent with type "terminal".

      Parameters

      Returns Promise<TerminalHandle>

      A handle to control and monitor the terminal

    • Experimental

      UNSTABLE

      This capability is not part of the spec yet, and may be removed or changed at any point.

      Creates an elicitation to request input from the user.

      Parameters

      • params: CreateElicitationRequest

      Returns Promise<CreateElicitationResponse>

    • Extension method.

      Parameters

      • method: string
      • params: Record<string, unknown>

      Returns Promise<Record<string, unknown>>

      Use request.

    • Extension notification.

      Parameters

      • method: string
      • params: Record<string, unknown>

      Returns Promise<void>

      Use notify.