Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 44 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,54 @@
# A2A Java SDK for Jakarta Servers

This is the integration of the A2A Java SDK for use in Jakarta servers.
This is the integration of the [A2A Java SDK](https://github.com/a2aproject/a2a-java) for use in Jakarta servers. It is currently tested on **WildFly**, but it should be usable in other compliant Jakarta servers such as Tomcat, Jetty, and OpenLiberty. For Quarkus, use the reference implementation in the [A2A Java SDK](https://github.com/a2aproject/a2a-java) project.

It is currently tested on WildFly, but should be usable in other compliant Jakarta servers.
For more information about the A2A protocol, see [here](https://github.com/a2aproject/a2a-spec).

For more information about the A2A protocol, see [here](https://a2aproject.github.io/A2A/latest/).
And for more information about the A2A Java SDK, see [here](https://github.com/a2aproject/a2a-java).
## Getting Started

To use the A2A Java SDK in your application, you will need to package it as a `.war` file. This can be done with your standard build tool.

### Packaging your application

The key to enabling A2A in your Java application is to correctly package it. Here are the general steps you need to follow:

1. **Create a standard `.war` archive:** Your project should be configured to produce a `.war` file. This is a standard format for web applications in Java and is supported by all major runtimes.

2. **Provide implementations for `AgentExecutor` and `AgentCard`:** The A2A SDK requires you to provide your own implementations of the `AgentExecutor` and `AgentCard` interfaces. These are the core components that define the behavior of your agent. You can find more information about them in the [A2A Java SDK documentation](https://github.com/a2aproject/a2a-java).

3. **Manage Dependencies:** Your `.war` file must contain all necessary libraries in the `/WEB-INF/lib` directory. However, some libraries may already be provided by the application server itself.

* **Bundling Dependencies:** For libraries not provided by the server, you must bundle them inside your `.war`.

* **Provided Dependencies:** To avoid conflicts and reduce the size of your archive, you should exclude libraries that your target runtime already provides. For example, **WildFly** includes the **Jackson** libraries, so you do not need to package them in your application. Check the documentation for your specific runtime (Tomcat, Jetty, OpenLiberty, etc.) to see which dependencies are provided.

### Example

The [tck/pom.xml](./tck/pom.xml) is a good example of how to package an A2A application. In this case, the application is deployed in WildFly, so the dependencies included in the `.war` are tailored to what WildFly provides.

In this case we have the following dependencies:

* `org.wildfly.extras.a2a:a2a-java-sdk-server-jakarta` - this is the main dependency which transitively pulls in all the dependencies from the A2A Java SDK project.
* Since some of these dependencies are provided by WildFly already, we exclude those so they do not become part of the `.war`, in order to avoid inconsistencies.
* `jakarta.ws.rs:jakarta.ws.rs-api` - this is not part of the dependencies brought in via `org.wildfly.extras.a2a:a2a-java-sdk-server-jakarta` but is needed to compile the TCK module. Since it is provided by WildFly, we make the scope `provided` so it is not included in the `.war`.
* `io.github.a2asdk:a2a-tck-server` - this is the application, which contains the `AgentExecutor` and `AgentCard` implementations for the TCK. In your case, they will most likely be implemented in the project you use to create the `.war`.
* In this case we exclude all transitive dependencies, since we are doing the main dependency management via the `org.wildfly.extras.a2a:a2a-java-sdk-server-jakarta` dependency.

## Running the TCK

The project includes a TCK (Technology Compatibility Kit) that you can use to test the integration with WildFly.

To run the TCK, build the full project
```bash
mvn clean install -DskipTests
```

You now have a server provisioned with the `.war` deployed in the `tck/target/wildfly` folder.

We can start the server using the following command:

```bash
./tck/target/wildfly/bin/standalone.sh
```
Once the server is up and running, run the TCK with the instructions in [a2aproject/a2a-tck](a2aproject/a2a-tck). Make sure you check out the correct tag of `a2aproject/a2a-tck` for the protocol version we are targeting.

75 changes: 48 additions & 27 deletions tck/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,50 +18,71 @@
<description>Java SDK for the Agent2Agent Protocol (A2A) - SDK - Jakarta - TCK - WildFly Jar</description>

<dependencies>
<!--
Dependencies needed to build the application.
-->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>a2a-java-sdk-server-jakarta-wildfly</artifactId>
<artifactId>a2a-java-sdk-server-jakarta</artifactId>
<version>${project.version}</version>
<exclusions>
<!--
Exclude these transitive dependencies since we are deploying the TCK in WildFly,
where the server provides these dependencies.
Other servlet containers/application servers may provide other things.
-->
<exclusion>
<groupId>*</groupId>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
</exclusion>
<exclusion>
<groupId>jakarta.inject</groupId>
<artifactId>jakarta.inject-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.github.a2asdk</groupId>
<artifactId>a2a-java-sdk-spec</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.github.a2asdk</groupId>
<artifactId>a2a-tck-server</artifactId>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
<scope>provided</scope>
</dependency>

<!--
Include the TCK server from the a2a-java project.
This is the application we will be using, providing the AgentExecutor and the AgentCard.
For your own applications you should not use this dependency, but rather provide your own.
-->
<dependency>
<groupId>io.github.a2asdk</groupId>
<artifactId>a2a-tck-server</artifactId>
<exclusions>
<!--
Exclude all dependencies, since we are managing what is included in the jar in the
org.wildfly.extras.a2a:ctId>a2a-java-sdk-server-jakarta dependency.
-->
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<!--
WildFly specific plugin to provision a WildFly server with the functionality required to
run our .war file.
It deploys the war renamed to 'ROOT.war' so that it is deployed under the root context, i.e. under '/'.
By default, this will be under http://localhost:8080/.
-->
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
Expand Down
Loading