Skip to content

Commit cd3d25d

Browse files
kabirehsavoie
authored andcommitted
Update AgentCard and transport discovery.
Remove the deprecated fields for now
1 parent 7c50785 commit cd3d25d

File tree

34 files changed

+161
-198
lines changed

34 files changed

+161
-198
lines changed

client/base/src/main/java/io/a2a/client/ClientBuilder.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,8 @@ private ClientTransport buildClientTransport() throws A2AClientException {
110110

111111
private Map<String, String> getServerPreferredTransports() {
112112
Map<String, String> serverPreferredTransports = new LinkedHashMap<>();
113-
serverPreferredTransports.put(agentCard.preferredTransport(), agentCard.url());
114-
if (agentCard.additionalInterfaces() != null) {
115-
for (AgentInterface agentInterface : agentCard.additionalInterfaces()) {
116-
serverPreferredTransports.putIfAbsent(agentInterface.protocolBinding(), agentInterface.url());
117-
}
113+
for (AgentInterface agentInterface : agentCard.supportedInterfaces()) {
114+
serverPreferredTransports.putIfAbsent(agentInterface.protocolBinding(), agentInterface.url());
118115
}
119116
return serverPreferredTransports;
120117
}

client/base/src/test/java/io/a2a/client/AuthenticationAuthorizationTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ public void setUp() {
7777
agentCard = new AgentCard.Builder()
7878
.name("Test Agent")
7979
.description("Test agent for auth tests")
80-
.url(AGENT_URL)
8180
.version("1.0.0")
8281
.capabilities(new AgentCapabilities.Builder()
8382
.streaming(true) // Support streaming for all tests
@@ -91,7 +90,7 @@ public void setUp() {
9190
.tags(Collections.singletonList("test"))
9291
.build()))
9392
.protocolVersion("0.3.0")
94-
.additionalInterfaces(java.util.Arrays.asList(
93+
.supportedInterfaces(java.util.Arrays.asList(
9594
new AgentInterface(TransportProtocol.JSONRPC.asString(), AGENT_URL),
9695
new AgentInterface(TransportProtocol.HTTP_JSON.asString(), AGENT_URL),
9796
new AgentInterface(TransportProtocol.GRPC.asString(), grpcServerName)))

client/base/src/test/java/io/a2a/client/ClientBuilderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class ClientBuilderTest {
2424
private AgentCard card = new AgentCard.Builder()
2525
.name("Hello World Agent")
2626
.description("Just a hello world agent")
27-
.url("http://localhost:9999")
27+
.supportedInterfaces(Collections.singletonList(new AgentInterface("jsonrpc", "http://localhost:9999")))
2828
.version("1.0.0")
2929
.documentationUrl("http://example.com/docs")
3030
.capabilities(new AgentCapabilities.Builder()

client/transport/jsonrpc/src/main/java/io/a2a/client/transport/jsonrpc/JSONRPCTransport.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public JSONRPCTransport(String agentUrl) {
7676
}
7777

7878
public JSONRPCTransport(AgentCard agentCard) {
79-
this(null, agentCard, agentCard.url(), null);
79+
this(null, agentCard, agentCard.supportedInterfaces().get(0).url(), null);
8080
}
8181

8282
public JSONRPCTransport(@Nullable A2AHttpClient httpClient, @Nullable AgentCard agentCard,

client/transport/jsonrpc/src/test/java/io/a2a/client/transport/jsonrpc/JSONRPCTransportTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ public void testA2AClientGetAgentCard() throws Exception {
369369
AgentCard agentCard = client.getAgentCard(null);
370370
assertEquals("GeoSpatial Route Planner Agent", agentCard.name());
371371
assertEquals("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.", agentCard.description());
372-
assertEquals("https://georoute-agent.example.com/a2a/v1", agentCard.url());
372+
assertEquals("https://georoute-agent.example.com/a2a/v1", agentCard.supportedInterfaces().get(0).url());
373373
assertEquals("Example Geo Services Inc.", agentCard.provider().organization());
374374
assertEquals("https://www.examplegeoservices.com", agentCard.provider().url());
375375
assertEquals("1.2.0", agentCard.version());
@@ -419,8 +419,8 @@ public void testA2AClientGetAgentCard() throws Exception {
419419
assertFalse(agentCard.supportsAuthenticatedExtendedCard());
420420
assertEquals("https://georoute-agent.example.com/icon.png", agentCard.iconUrl());
421421
assertEquals("0.2.9", agentCard.protocolVersion());
422-
assertEquals("JSONRPC", agentCard.preferredTransport());
423-
List<AgentInterface> additionalInterfaces = agentCard.additionalInterfaces();
422+
assertEquals("JSONRPC", agentCard.supportedInterfaces().get(0).protocolBinding());
423+
List<AgentInterface> additionalInterfaces = agentCard.supportedInterfaces();
424424
assertEquals(3, additionalInterfaces.size());
425425
AgentInterface jsonrpc = new AgentInterface(TransportProtocol.JSONRPC.asString(), "https://georoute-agent.example.com/a2a/v1");
426426
AgentInterface grpc = new AgentInterface(TransportProtocol.GRPC.asString(), "https://georoute-agent.example.com/a2a/grpc");
@@ -458,7 +458,7 @@ public void testA2AClientGetAuthenticatedExtendedAgentCard() throws Exception {
458458
AgentCard agentCard = client.getAgentCard(null);
459459
assertEquals("GeoSpatial Route Planner Agent Extended", agentCard.name());
460460
assertEquals("Extended description", agentCard.description());
461-
assertEquals("https://georoute-agent.example.com/a2a/v1", agentCard.url());
461+
assertEquals("https://georoute-agent.example.com/a2a/v1", agentCard.supportedInterfaces().get(0).url());
462462
assertEquals("Example Geo Services Inc.", agentCard.provider().organization());
463463
assertEquals("https://www.examplegeoservices.com", agentCard.provider().url());
464464
assertEquals("1.2.0", agentCard.version());

client/transport/jsonrpc/src/test/java/io/a2a/client/transport/jsonrpc/JsonMessages.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ public class JsonMessages {
1111
"protocolVersion": "0.2.9",
1212
"name": "GeoSpatial Route Planner Agent",
1313
"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.",
14-
"url": "https://georoute-agent.example.com/a2a/v1",
15-
"preferredTransport": "JSONRPC",
16-
"additionalInterfaces" : [
14+
"supportedInterfaces" : [
1715
{"url": "https://georoute-agent.example.com/a2a/v1", "protocolBinding": "JSONRPC"},
1816
{"url": "https://georoute-agent.example.com/a2a/grpc", "protocolBinding": "GRPC"},
1917
{"url": "https://georoute-agent.example.com/a2a/json", "protocolBinding": "HTTP+JSON"}
@@ -87,7 +85,9 @@ public class JsonMessages {
8785
{
8886
"name": "GeoSpatial Route Planner Agent Extended",
8987
"description": "Extended description",
90-
"url": "https://georoute-agent.example.com/a2a/v1",
88+
"supportedInterfaces": [
89+
{"url": "https://georoute-agent.example.com/a2a/v1", "protocolBinding": "JSONRPC"}
90+
],
9191
"provider": {
9292
"organization": "Example Geo Services Inc.",
9393
"url": "https://www.examplegeoservices.com"
@@ -628,7 +628,9 @@ public class JsonMessages {
628628
"result": {
629629
"name": "GeoSpatial Route Planner Agent Extended",
630630
"description": "Extended description",
631-
"url": "https://georoute-agent.example.com/a2a/v1",
631+
"supportedInterfaces": [
632+
{"url": "https://georoute-agent.example.com/a2a/v1", "protocolBinding": "JSONRPC"}
633+
],
632634
"provider": {
633635
"organization": "Example Geo Services Inc.",
634636
"url": "https://www.examplegeoservices.com"
@@ -706,7 +708,9 @@ public class JsonMessages {
706708
{
707709
"name": "GeoSpatial Route Planner Agent",
708710
"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.",
709-
"url": "https://georoute-agent.example.com/a2a/v1",
711+
"supportedInterfaces": [
712+
{"url": "https://georoute-agent.example.com/a2a/v1", "protocolBinding": "JSONRPC"}
713+
],
710714
"provider": {
711715
"organization": "Example Geo Services Inc.",
712716
"url": "https://www.examplegeoservices.com"

client/transport/rest/src/main/java/io/a2a/client/transport/rest/RestTransport.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public class RestTransport implements ClientTransport {
6161
private boolean needsExtendedCard = false;
6262

6363
public RestTransport(AgentCard agentCard) {
64-
this(null, agentCard, agentCard.url(), null);
64+
this(null, agentCard, agentCard.supportedInterfaces().get(0).url(), null);
6565
}
6666

6767
public RestTransport(@Nullable A2AHttpClient httpClient, AgentCard agentCard,

client/transport/rest/src/test/java/io/a2a/client/transport/rest/JsonRestMessages.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ public class JsonRestMessages {
109109
{
110110
"name": "GeoSpatial Route Planner Agent",
111111
"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.",
112-
"url": "https://georoute-agent.example.com/a2a/v1",
112+
"supportedInterfaces": [
113+
{"url": "https://georoute-agent.example.com/a2a/v1", "protocolBinding": "HTTP+JSON"}
114+
],
113115
"provider": {
114116
"organization": "Example Geo Services Inc.",
115117
"url": "https://www.examplegeoservices.com"
@@ -174,7 +176,9 @@ public class JsonRestMessages {
174176
{
175177
"name": "GeoSpatial Route Planner Agent",
176178
"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.",
177-
"url": "https://georoute-agent.example.com/a2a/v1",
179+
"supportedInterfaces": [
180+
{"url": "https://georoute-agent.example.com/a2a/v1", "protocolBinding": "HTTP+JSON"}
181+
],
178182
"provider": {
179183
"organization": "Example Geo Services Inc.",
180184
"url": "https://www.examplegeoservices.com"
@@ -239,7 +243,9 @@ public class JsonRestMessages {
239243
{
240244
"name": "GeoSpatial Route Planner Agent Extended",
241245
"description": "Extended description",
242-
"url": "https://georoute-agent.example.com/a2a/v1",
246+
"supportedInterfaces": [
247+
{"url": "https://georoute-agent.example.com/a2a/v1", "protocolBinding": "HTTP+JSON"}
248+
],
243249
"provider": {
244250
"organization": "Example Geo Services Inc.",
245251
"url": "https://www.examplegeoservices.com"

client/transport/rest/src/test/java/io/a2a/client/transport/rest/RestTransportTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public class RestTransportTest {
7070
private static final AgentCard CARD = new AgentCard.Builder()
7171
.name("Hello World Agent")
7272
.description("Just a hello world agent")
73-
.url("http://localhost:4001")
73+
.supportedInterfaces(Collections.singletonList(new io.a2a.spec.AgentInterface("HTTP+JSON", "http://localhost:4001")))
7474
.version("1.0.0")
7575
.documentationUrl("http://example.com/docs")
7676
.capabilities(new AgentCapabilities.Builder()

client/transport/spi/src/test/java/io/a2a/client/transport/spi/interceptors/auth/AuthInterceptorTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import io.a2a.spec.APIKeySecurityScheme;
1414
import io.a2a.spec.AgentCapabilities;
1515
import io.a2a.spec.AgentCard;
16+
import io.a2a.spec.AgentInterface;
1617
import io.a2a.spec.HTTPAuthSecurityScheme;
1718
import io.a2a.spec.OAuth2SecurityScheme;
1819
import io.a2a.spec.OAuthFlows;
@@ -229,7 +230,7 @@ void testAvailableSecuritySchemeNotInAgentCardSecuritySchemes() {
229230
AgentCard agentCard = new AgentCard.Builder()
230231
.name("missing")
231232
.description("Uses missing scheme definition")
232-
.url("http://agent.com/rpc")
233+
.supportedInterfaces(List.of(new AgentInterface("jsonrpc", "http://agent.com/rpc")))
233234
.version("1.0")
234235
.capabilities(new AgentCapabilities.Builder().build())
235236
.defaultInputModes(List.of("text"))
@@ -283,7 +284,7 @@ void testNoAgentCardSecuritySpecified() {
283284
AgentCard agentCard = new AgentCard.Builder()
284285
.name("nosecuritybot")
285286
.description("A bot with no security requirements")
286-
.url("http://agent.com/rpc")
287+
.supportedInterfaces(List.of(new AgentInterface("jsonrpc", "http://agent.com/rpc")))
287288
.version("1.0")
288289
.capabilities(new AgentCapabilities.Builder().build())
289290
.defaultInputModes(List.of("text"))
@@ -315,7 +316,7 @@ private AgentCard createAgentCard(String schemeName, SecurityScheme securitySche
315316
return new AgentCard.Builder()
316317
.name(schemeName + "bot")
317318
.description("A bot that uses " + schemeName)
318-
.url("http://agent.com/rpc")
319+
.supportedInterfaces(List.of(new AgentInterface("jsonrpc", "http://agent.com/rpc")))
319320
.version("1.0")
320321
.capabilities(new AgentCapabilities.Builder().build())
321322
.defaultInputModes(List.of("text"))

0 commit comments

Comments
 (0)