Skip to content
Merged
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public class WeatherAgentCardProducer {
.tags(Collections.singletonList("weather"))
.examples(List.of("weather in LA, CA"))
.build()))
.protocolVersion("0.3.0")
.protocolVersion(io.a2a.spec.AgentCard.CURRENT_PROTOCOL_VERSION)
.build();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
package io.a2a.client;

import static io.a2a.spec.AgentCard.CURRENT_PROTOCOL_VERSION;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockserver.model.HttpRequest.request;
import static org.mockserver.model.HttpResponse.response;

import java.io.IOException;
import java.util.Collections;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;

import io.a2a.client.config.ClientConfig;
import io.a2a.client.transport.grpc.GrpcTransport;
import io.a2a.client.transport.grpc.GrpcTransportConfigBuilder;
Expand Down Expand Up @@ -30,18 +43,6 @@
import org.junit.jupiter.api.Test;
import org.mockserver.integration.ClientAndServer;

import java.io.IOException;
import java.util.Collections;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;

import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockserver.model.HttpRequest.request;
import static org.mockserver.model.HttpResponse.response;

/**
* Tests for handling HTTP 401 (Unauthorized) and 403 (Forbidden) responses
* when the client sends streaming and non-streaming messages.
Expand Down Expand Up @@ -89,7 +90,7 @@ public void setUp() {
.description("Test skill")
.tags(Collections.singletonList("test"))
.build()))
.protocolVersion("0.3.0")
.protocolVersion(CURRENT_PROTOCOL_VERSION)
.supportedInterfaces(java.util.Arrays.asList(
new AgentInterface(TransportProtocol.JSONRPC.asString(), AGENT_URL),
new AgentInterface(TransportProtocol.HTTP_JSON.asString(), AGENT_URL),
Expand Down
10 changes: 6 additions & 4 deletions client/base/src/test/java/io/a2a/client/ClientBuilderTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package io.a2a.client;

import static io.a2a.spec.AgentCard.CURRENT_PROTOCOL_VERSION;

import java.util.Collections;
import java.util.List;

import io.a2a.client.config.ClientConfig;
import io.a2a.client.http.JdkA2AHttpClient;
import io.a2a.client.transport.grpc.GrpcTransport;
Expand All @@ -16,9 +21,6 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.util.Collections;
import java.util.List;

public class ClientBuilderTest {

private AgentCard card = AgentCard.builder()
Expand All @@ -40,7 +42,7 @@ public class ClientBuilderTest {
.tags(Collections.singletonList("hello world"))
.examples(List.of("hi", "hello world"))
.build()))
.protocolVersion("0.3.0")
.protocolVersion(CURRENT_PROTOCOL_VERSION)
.supportedInterfaces(List.of(
new AgentInterface(TransportProtocol.JSONRPC.asString(), "http://localhost:9999")))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import static io.a2a.client.transport.jsonrpc.JsonMessages.SEND_MESSAGE_WITH_MIXED_PARTS_TEST_RESPONSE;
import static io.a2a.client.transport.jsonrpc.JsonMessages.SET_TASK_PUSH_NOTIFICATION_CONFIG_TEST_REQUEST;
import static io.a2a.client.transport.jsonrpc.JsonMessages.SET_TASK_PUSH_NOTIFICATION_CONFIG_TEST_RESPONSE;
import static io.a2a.spec.AgentCard.CURRENT_PROTOCOL_VERSION;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
Expand All @@ -43,6 +44,7 @@
import io.a2a.spec.AgentInterface;
import io.a2a.spec.AgentSkill;
import io.a2a.spec.Artifact;
import io.a2a.spec.AuthenticationInfo;
import io.a2a.spec.DataPart;
import io.a2a.spec.EventKind;
import io.a2a.spec.FileContent;
Expand All @@ -55,7 +57,6 @@
import io.a2a.spec.MessageSendParams;
import io.a2a.spec.OpenIdConnectSecurityScheme;
import io.a2a.spec.Part;
import io.a2a.spec.AuthenticationInfo;
import io.a2a.spec.PushNotificationConfig;
import io.a2a.spec.SecurityScheme;
import io.a2a.spec.Task;
Expand All @@ -66,7 +67,6 @@
import io.a2a.spec.TextPart;
import io.a2a.spec.TransportProtocol;
import io.a2a.util.Utils;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -417,7 +417,7 @@ public void testA2AClientGetAgentCard() throws Exception {
assertEquals(outputModes, skills.get(1).outputModes());
assertFalse(agentCard.supportsExtendedAgentCard());
assertEquals("https://georoute-agent.example.com/icon.png", agentCard.iconUrl());
assertEquals("0.2.9", agentCard.protocolVersion());
assertEquals(CURRENT_PROTOCOL_VERSION, agentCard.protocolVersion());
assertEquals("JSONRPC", agentCard.supportedInterfaces().get(0).protocolBinding());
List<AgentInterface> additionalInterfaces = agentCard.supportedInterfaces();
assertEquals(3, additionalInterfaces.size());
Expand Down Expand Up @@ -509,7 +509,7 @@ public void testA2AClientGetAuthenticatedExtendedAgentCard() throws Exception {
assertEquals(List.of("extended"), skills.get(2).tags());
assertTrue(agentCard.supportsExtendedAgentCard());
assertEquals("https://georoute-agent.example.com/icon.png", agentCard.iconUrl());
assertEquals("0.2.5", agentCard.protocolVersion());
assertEquals(CURRENT_PROTOCOL_VERSION, agentCard.protocolVersion());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
package io.a2a.client.transport.jsonrpc;

import static io.a2a.spec.AgentCard.CURRENT_PROTOCOL_VERSION;

import io.a2a.spec.AgentCard;

/**
* Request and response messages used by the tests. These have been created following examples from
* the <a href="https://google.github.io/A2A/specification/sample-messages">A2A sample messages</a>.
*/
public class JsonMessages {

static final String AGENT_CARD = """
static final String AGENT_CARD = String.format("""
{
"protocolVersion": "0.2.9",
"protocolVersion": "%s",
"name": "GeoSpatial Route Planner Agent",
"description": "Provides advanced route planning, traffic analysis, and custom map generation services. This agent can calculate optimal routes, estimate travel times considering real-time traffic, and create personalized maps with points of interest.",
"supportedInterfaces" : [
Expand Down Expand Up @@ -80,7 +84,7 @@ public class JsonMessages {
"signature": "QFdkNLNszlGj3z3u0YQGt_T9LixY3qtdQpZmsTdDHDe3fXV9y9-B3m2-XgCpzuhiLt8E0tV6HXoZKHv4GtHgKQ"
}
]
}""";
}""", CURRENT_PROTOCOL_VERSION);

static final String SEND_MESSAGE_TEST_REQUEST = """
{
Expand Down Expand Up @@ -588,7 +592,7 @@ public class JsonMessages {
}
""";

static final String GET_AUTHENTICATED_EXTENDED_AGENT_CARD_RESPONSE = """
static final String GET_AUTHENTICATED_EXTENDED_AGENT_CARD_RESPONSE = String.format("""
{
"jsonrpc": "2.0",
"id": "1",
Expand Down Expand Up @@ -662,17 +666,17 @@ public class JsonMessages {
}
],
"supportsExtendedAgentCard": true,
"protocolVersion": "0.2.5",
"protocolVersion": "%s",
"signatures": [
{
"protected": "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpPU0UiLCJraWQiOiJrZXktMSIsImprdUI6Imh0dHBzOi8vZXhhbXBsZS5jb20vYWdlbnQvandrcy5qc29uIn0",
"signature": "QFdkNLNszlGj3z3u0YQGt_T9LixY3qtdQpZmsTdDHDe3fXV9y9-B3m2-XgCpzuhiLt8E0tV6HXoZKHv4GtHgKQ"
}
]
}
}""";
}""", CURRENT_PROTOCOL_VERSION);

static final String AGENT_CARD_SUPPORTS_EXTENDED = """
static final String AGENT_CARD_SUPPORTS_EXTENDED = String.format("""
{
"name": "GeoSpatial Route Planner Agent",
"description": "Provides advanced route planning, traffic analysis, and custom map generation services. This agent can calculate optimal routes, estimate travel times considering real-time traffic, and create personalized maps with points of interest.",
Expand Down Expand Up @@ -737,6 +741,6 @@ public class JsonMessages {
}
],
"supportsExtendedAgentCard": true,
"protocolVersion": "1.0.0"
}""";
"protocolVersion": "%s"
}""", CURRENT_PROTOCOL_VERSION);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
import static io.a2a.client.transport.rest.JsonRestMessages.GET_TASK_PUSH_NOTIFICATION_CONFIG_TEST_RESPONSE;
import static io.a2a.client.transport.rest.JsonRestMessages.GET_TASK_TEST_RESPONSE;
import static io.a2a.client.transport.rest.JsonRestMessages.LIST_TASK_PUSH_NOTIFICATION_CONFIG_TEST_RESPONSE;
import static io.a2a.client.transport.rest.JsonRestMessages.SEND_MESSAGE_STREAMING_TEST_REQUEST;
import static io.a2a.client.transport.rest.JsonRestMessages.SEND_MESSAGE_STREAMING_TEST_RESPONSE;
import static io.a2a.client.transport.rest.JsonRestMessages.SEND_MESSAGE_TEST_REQUEST;
import static io.a2a.client.transport.rest.JsonRestMessages.SEND_MESSAGE_TEST_RESPONSE;
import static io.a2a.client.transport.rest.JsonRestMessages.SEND_MESSAGE_STREAMING_TEST_REQUEST;
import static io.a2a.client.transport.rest.JsonRestMessages.SET_TASK_PUSH_NOTIFICATION_CONFIG_TEST_REQUEST;
import static io.a2a.client.transport.rest.JsonRestMessages.SET_TASK_PUSH_NOTIFICATION_CONFIG_TEST_RESPONSE;
import static io.a2a.client.transport.rest.JsonRestMessages.TASK_RESUBSCRIPTION_REQUEST_TEST_RESPONSE;
import static io.a2a.spec.AgentCard.CURRENT_PROTOCOL_VERSION;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
Expand All @@ -21,11 +22,21 @@
import static org.mockserver.model.HttpRequest.request;
import static org.mockserver.model.HttpResponse.response;

import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
import java.util.logging.Logger;

import io.a2a.client.transport.spi.interceptors.ClientCallContext;
import io.a2a.spec.AgentCapabilities;
import io.a2a.spec.AgentCard;
import io.a2a.spec.AgentSkill;
import io.a2a.spec.Artifact;
import io.a2a.spec.AuthenticationInfo;
import io.a2a.spec.DeleteTaskPushNotificationConfigParams;
import io.a2a.spec.EventKind;
import io.a2a.spec.FilePart;
Expand All @@ -38,7 +49,6 @@
import io.a2a.spec.MessageSendParams;
import io.a2a.spec.Part;
import io.a2a.spec.Part.Kind;
import io.a2a.spec.AuthenticationInfo;
import io.a2a.spec.PushNotificationConfig;
import io.a2a.spec.StreamingEventKind;
import io.a2a.spec.Task;
Expand All @@ -47,14 +57,6 @@
import io.a2a.spec.TaskQueryParams;
import io.a2a.spec.TaskState;
import io.a2a.spec.TextPart;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
import java.util.logging.Logger;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -86,7 +88,7 @@ public class RestTransportTest {
.tags(Collections.singletonList("hello world"))
.examples(List.of("hi", "hello world"))
.build()))
.protocolVersion("0.3.0")
.protocolVersion(CURRENT_PROTOCOL_VERSION)
.build();

@BeforeEach
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
package io.a2a.examples.cloud;

import static io.a2a.spec.AgentCard.CURRENT_PROTOCOL_VERSION;

import java.util.Collections;
import java.util.List;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.Produces;
import jakarta.inject.Inject;

import io.a2a.server.PublicAgentCard;
import io.a2a.spec.AgentCapabilities;
import io.a2a.spec.AgentCard;
import io.a2a.spec.AgentInterface;
import io.a2a.spec.AgentSkill;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.Produces;
import jakarta.inject.Inject;

import org.eclipse.microprofile.config.inject.ConfigProperty;

import java.util.Collections;
import java.util.List;

/**
* Producer for the cloud deployment example agent card.
*/
Expand Down Expand Up @@ -56,7 +58,7 @@ public AgentCard agentCard() {
))
.build()
))
.protocolVersion("0.3.0")
.protocolVersion(CURRENT_PROTOCOL_VERSION)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.a2a.examples.helloworld;

import static io.a2a.spec.AgentCard.CURRENT_PROTOCOL_VERSION;

import java.util.Collections;
import java.util.List;

Expand Down Expand Up @@ -41,7 +43,7 @@ public AgentCard agentCard() {
.tags(Collections.singletonList("hello world"))
.examples(List.of("hi", "hello world"))
.build()))
.protocolVersion("0.3.0")
.protocolVersion(CURRENT_PROTOCOL_VERSION)
.build();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.a2a.extras.queuemanager.replicated.tests.multiinstance.common;

import static io.a2a.spec.AgentCard.CURRENT_PROTOCOL_VERSION;

import java.util.Collections;
import java.util.List;

Expand Down Expand Up @@ -46,7 +48,7 @@ public static AgentCard createAgentCard(int instanceNumber, int port) {
.description("Fire-and-forget agent for testing replication")
.tags(Collections.singletonList("test"))
.build()))
.protocolVersion("0.3.0")
.protocolVersion(CURRENT_PROTOCOL_VERSION)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package io.a2a.extras.queuemanager.replicated.tests;

import static io.a2a.spec.AgentCard.CURRENT_PROTOCOL_VERSION;

import java.util.List;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.Produces;

import io.a2a.server.PublicAgentCard;
import io.a2a.spec.AgentCard;
import io.a2a.spec.AgentCapabilities;
import io.a2a.spec.AgentCard;
import io.a2a.spec.AgentInterface;
import io.a2a.spec.TransportProtocol;
import io.quarkus.arc.profile.IfBuildProfile;
Expand Down Expand Up @@ -37,7 +39,7 @@ public AgentCard agentCard() {
.skills(List.of())
.supportedInterfaces(List.of(
new AgentInterface(TransportProtocol.JSONRPC.asString(), "http://localhost:8081")))
.protocolVersion("0.2.5")
.protocolVersion(CURRENT_PROTOCOL_VERSION)
.build();
}
}
Loading