src — protocols

Module: src-protocols Cohesion: 0.80 Members: 0

src — protocols

The src/protocols module defines the communication standards and implementations for inter-agent and enhanced agent interactions within the Code Buddy system. It currently encompasses two primary protocols:

  1. A2A (Agent-to-Agent) Protocol: Handles the core mechanics of task delegation, lifecycle management, and message exchange between agents.
  2. ACP (Enhanced Agent Communication Protocol): Provides advanced capabilities like context injection, tool delegation, and dynamic capability discovery, typically exposed via HTTP endpoints.

This module is crucial for enabling Code Buddy to operate as a multi-agent system, allowing different specialized agents to collaborate and delegate work.


A2A Protocol: Agent-to-Agent Communication (src/protocols/a2a/index.ts)

The A2A protocol implements a standardized way for agents to communicate, delegate tasks, and manage their lifecycle. It's designed for robust, asynchronous task execution and multi-turn interactions.

Purpose

The A2A protocol facilitates:

Core Concepts

The protocol is built around several key data structures:

Task Lifecycle

Tasks progress through various states, managed by the A2AAgentServer.

graph TD
    A[Task Submitted] -->|submitTask| B(Status: SUBMITTED)
    B -->|updateTaskStatus| C(Status: WORKING)
    C -->|TaskExecutor completes| D(Status: COMPLETED)
    C -->|TaskExecutor fails| E(Status: FAILED)
    C -->|yieldTask| F(Status: INPUT_REQUIRED)
    F -->|sendMessage or resumeTask| C
    B -->|cancelTask| G(Status: CANCELED)
    C -->|cancelTask| G
    F -->|cancelTask| G

Key Components

A2AAgentServer

This class represents an agent that receives and executes tasks. It acts as the server-side implementation of the A2A protocol.

A2AAgentClient

This class represents an entity (typically an orchestrator) that sends tasks to other agents. In this implementation, it's designed for in-process communication with A2AAgentServer instances.

Helper Functions

Integration Points


ACP Protocol: Enhanced Agent Communication Protocol (src/protocols/acp/acp-server.ts)

The ACP protocol provides a set of advanced HTTP endpoints for interacting with Code Buddy, focusing on context management, tool execution, and dynamic capability discovery. It's designed to enhance agent communication beyond basic task delegation.

Purpose

The ACP protocol aims to:

Core Concepts

createACPServerRoutes Function

This is a factory function that returns an Express Router configured with the ACP endpoints. It's designed to be integrated into an existing Express application.

Endpoints

  1. POST /api/acp/context

  1. POST /api/acp/delegate

  1. GET /api/acp/capabilities

Integration Points


Relationship Between A2A and ACP

While both protocols deal with agent communication, they serve different purposes and operate at different levels:

For instance, an external orchestrator might use ACP's /delegate endpoint to ask Code Buddy to run a tool, and Code Buddy might internally use A2A to delegate parts of that tool's execution to another specialized local agent. The server/routes/acp.ts module demonstrates this by using A2AAgentClient alongside createACPServerRoutes, indicating that the ACP endpoints might interact with the A2A layer.